commit a2638072efc3506c854a7967a5282fc13e8d8473 Author: Gavin Lin Date: Tue Aug 7 00:51:35 2018 -0700 init commit diff --git a/gmsv/autil.c b/gmsv/autil.c new file mode 100644 index 0000000..dbc7fd3 --- /dev/null +++ b/gmsv/autil.c @@ -0,0 +1,550 @@ +// Arminius' protocol utilities ver 0.1 +// +// Any questions and bugs, mailto: arminius@mail.hwaei.com.tw + +// ------------------------------------------------------------------- +// The following definitions is to define game-dependent codes. +// Before compiling, remove the "//". +#define __STONEAGE +#include "version.h" +#include +#include +#include "autil.h" +#include "char.h" +#ifdef __STONEAGE +#include "lssproto_util.h" +#include "common.h" +#endif + + +// Nuke 0701 fix +char *MesgSlice[SLICE_MAX]; +int SliceCount; + +char PersonalKey[4096]; + +// ------------------------------------------------------------------- +// Initialize utilities +// +BOOL util_Init( void) +{ + int i; + + for (i=0; i=0)) { + ptr[0] = '\0'; + if (strlen(head) func(%d)\n", file, line, func); + return; + } + + // Robin adjust + //sprintf(t1, "&;%d%s;#;", func, buffer); + sprintf(t1, "&;%d%s;#;", func+23, buffer); + util_EncodeMessage(t2, t1); +#ifdef _CHECK_BATTLE_IO + if( InBattleLoop) { + battle_write_cnt++; + battle_write += strlen( buffer); + } + else { + other_write += strlen( buffer); + other_write_cnt++; + } +#endif +#ifdef __STONEAGE + lssproto_Send(fd, t2); +#endif +} + +int util_256to64(char *dst, char *src, int len, char *table) +{ + unsigned int dw,dwcounter,i; + + if (!dst || !src || !table) return 0; + dw=0; + dwcounter=0; + for (i=0; i> 6 ); + if (i%3==2) { + dst[ dwcounter++ ] = table[ dw & 0x3f ]; + dw = 0; + } + } + if (dw) dst[ dwcounter++ ] = table[ dw ]; + dst[ dwcounter ] = '\0'; + return dwcounter; +} + +// ------------------------------------------------------------------- +// Convert 6-bit strings into 8-bit strings, buffers that store these strings +// must have enough space. +// +// arg: dst=6-bit string; src=8-bit string; table=mapping table +// ret: 0=failed >0=bytes converted +int util_64to256(char *dst, char *src, char *table) +{ + unsigned int dw,dwcounter,i; + char *ptr = NULL; + + dw=0; + dwcounter=0; + if (!dst || !src || !table) return 0; + for (i=0; i> 8; + } else { + dw = (unsigned int)(ptr-table) & 0x3f; + } + } + if (dw) dst[ dwcounter++ ] = dw & 0xff; + dst[ dwcounter ] = '\0'; + return dwcounter; +} + +// ------------------------------------------------------------------- +// This basically is a 256to64 encoder. But it shifts the result by key. +// +// arg: dst=6-bit string; src=8-bit string; len=src strlen; +// table=mapping table; key=rotate key; +// ret: 0=failed >0=bytes converted +int util_256to64_shr(char *dst, char *src, int len, char *table, char *key) +{ + unsigned int dw,dwcounter,i,j; + + if (!dst || !src || !table || !key) return 0; + if (strlen(key)<1) return 0; // key can't be empty. + dw=0; + dwcounter=0; + j=0; + for (i=0; i> 6 ); + if (i%3==2) { + dst[ dwcounter++ ] = table[ ((dw & 0x3f) + key[j]) % 64 ];// check! + j++; if (!key[j]) j=0; + dw = 0; + } + } + if (dw) dst[ dwcounter++ ] = table[ (dw + key[j]) % 64 ]; // check! + dst[ dwcounter ] = '\0'; + return dwcounter; +} + +// ------------------------------------------------------------------- +// Decoding function of util_256to64_shr. +// +// arg: dst=8-bit string; src=6-bit string; table=mapping table; +// key=rotate key; +// ret: 0=failed >0=bytes converted +int util_shl_64to256(char *dst, char *src, char *table, char *key) +{ + unsigned int dw,dwcounter,i,j; + char *ptr = NULL; + + if (!key || (strlen(key)<1)) return 0; // must have key + + dw=0; + dwcounter=0; + j=0; + if (!dst || !src || !table) return 0; + for (i=0; i> 8; + } else { + // check! + dw = (((unsigned int)(ptr-table) & 0x3f) + 64 - key[j]) % 64; + j++; if (!key[j]) j=0; + } + } + if (dw) dst[ dwcounter++ ] = dw & 0xff; + dst[ dwcounter ] = '\0'; + return dwcounter; +} + +// ------------------------------------------------------------------- +// This basically is a 256to64 encoder. But it shifts the result by key. +// +// arg: dst=6-bit string; src=8-bit string; len=src strlen; +// table=mapping table; key=rotate key; +// ret: 0=failed >0=bytes converted +int util_256to64_shl(char *dst, char *src, int len, char *table, char *key) +{ + unsigned int dw,dwcounter,i,j; + + if (!dst || !src || !table || !key) return 0; + if (strlen(key)<1) return 0; // key can't be empty. + dw=0; + dwcounter=0; + j=0; + for (i=0; i> 6 ); + if (i%3==2) { + dst[ dwcounter++ ] = table[ ((dw & 0x3f) + 64 - key[j]) % 64 ]; // check! + j++; if (!key[j]) j=0; + dw = 0; + } + } + if (dw) dst[ dwcounter++ ] = table[ (dw + 64 - key[j]) % 64 ]; // check! + dst[ dwcounter ] = '\0'; + return dwcounter; +} + +// ------------------------------------------------------------------- +// Decoding function of util_256to64_shl. +// +// arg: dst=8-bit string; src=6-bit string; table=mapping table; +// key=rotate key; +// ret: 0=failed >0=bytes converted +int util_shr_64to256(char *dst, char *src, char *table, char *key) +{ + unsigned int dw,dwcounter,i,j; + char *ptr = NULL; + + if (!key || (strlen(key)<1)) return 0; // must have key + + dw=0; + dwcounter=0; + j=0; + if (!dst || !src || !table) return 0; + for (i=0; i> 8; + } else { + // check! + dw = (((unsigned int)(ptr-table) & 0x3f) + key[j]) % 64; + j++; if (!key[j]) j=0; + } + } + if (dw) dst[ dwcounter++ ] = dw & 0xff; + dst[ dwcounter ] = '\0'; + return dwcounter; +} + +// ------------------------------------------------------------------- +// Swap a integer (4 byte). +// The value "rule" indicates the swaping rule. It's a 4 byte string +// such as "1324" or "2431". +// +void util_swapint(int *dst, int *src, char *rule) +{ + char *ptr, *qtr; + int i; + + ptr = (char *) src; + qtr = (char *) dst; + for (i=0; i<4; i++) qtr[rule[i]-'1']=ptr[i]; +} + +// ------------------------------------------------------------------- +// Xor a string. Be careful that your string contains '0xff'. Your +// data may lose. +// +void util_xorstring(char *dst, char *src) +{ + int i; + if (strlen(src)>65500) return; + +DebugPoint=100000; + + for (i=0; i +#include +#include +#include "buf.h" +#include"object.h" +#include"char.h" +#include"char_base.h" +#include"char_data.h" +#include"battle.h" +#include"battle_event.h" +#include"battle_command.h" +#include"battle_ai.h" +#include"configfile.h" +#include"lssproto_serv.h" +#include"encount.h" +#include"enemy.h" +#include"handletime.h" +#include"readmap.h" +#include"pet_skill.h" +#include "npcutil.h" +#include "magic.h" +#include "npc_npcenemy.h" +#include "log.h" +#include "pet_skillinfo.h" +#include "anim_tbl.h" +#include "common.h" +#include "battle_magic.h" +#ifdef _Item_ReLifeAct +#include "item.h" +#endif +#include "correct_bug.h" + +#ifdef _DEATH_CONTEND +#include "deathcontend.h" +#endif + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 +#include "profession_skill.h" +#include "skill.h" +#endif + +//#define DANTAI +static int Total_BattleNum=0; +BATTLE *BattleArray; +int BATTLE_battlenum; +static int BATTLE_searchCnt = 0; + +#ifdef _PET_LIMITLEVEL //ANDY_ADD + void Pet_Check_Die( int petindex); +#endif +static int BATTLE_SearchTask( void ); +static int BATTLE_Battling( int battleindex ); + +#ifdef _Item_ReLifeAct + BOOL CHECK_ITEM_RELIFE( int battleindex, int toindex); +#endif +#ifdef _LOSE_FINCH_ + BOOL CHECK_PET_RELIFE( int battleindex, int petindex); +#endif +char szAllBattleString[BATTLE_STRING_MAX]; +#ifdef _OTHER_MAGICSTAUTS +void BATTLE_MagicStatusSeq( int charaindex ); +#endif + +//Terry 2001/11/28 +char szBattleString[512]; +char *pszBattleTop, + *pszBattleLast; + +char szBadStatusString[1024]; + +int gWeponType; +float gDamageDiv; +int gItemCrushRate = 400000; + +int BoomerangVsTbl[4][5] = { + { 4+5*0,2+5*0,0+5*0,1+5*0,3+5*0 }, + { 4+5*1,2+5*1,0+5*1,1+5*1,3+5*1 }, + { 4+5*2,2+5*2,0+5*2,1+5*2,3+5*2 }, + { 4+5*3,2+5*3,0+5*3,1+5*3,3+5*3 }, + +}; + +void BATTLE_BadStatusAllClr( int charaindex ) +{ + int i ; + for( i = 1; i < BATTLE_ST_END; i ++ ){ + CHAR_setWorkInt( charaindex, StatusTbl[i], 0 ); + } +#ifdef _OTHER_MAGICSTAUTS + for( i = 1; i < MAXSTATUSTYPE; i++ ){ + CHAR_setWorkInt( charaindex, MagicTbl[i], 0); + CHAR_setWorkInt( charaindex, CHAR_OTHERSTATUSNUMS, 0); + } +#endif +#ifdef _IMPRECATE_ITEM + for( i=0; i<3; i++) { + CHAR_setWorkInt( charaindex, CHAR_WORKIMPRECATENUM1+i, 0 ); + } +#endif + +#ifdef _PETSKILL_SETDUCK + CHAR_setWorkInt( charaindex, CHAR_MYSKILLDUCK, 0); + CHAR_setWorkInt( charaindex, CHAR_MYSKILLDUCKPOWER, 0 ); +#ifdef _MAGICPET_SKILL + CHAR_setWorkInt( charaindex, CHAR_MYSKILLSTR, 0); + CHAR_setWorkInt( charaindex, CHAR_MYSKILLSTRPOWER, 0 ); + CHAR_setWorkInt( charaindex, CHAR_MYSKILLTGH, 0); + CHAR_setWorkInt( charaindex, CHAR_MYSKILLTGHPOWER, 0 ); + CHAR_setWorkInt( charaindex, CHAR_MYSKILLDEX, 0); + CHAR_setWorkInt( charaindex, CHAR_MYSKILLDEXPOWER, 0 ); + CHAR_setWorkInt( charaindex, CHAR_MAGICPETMP, 0 ); +#endif +#endif + + CHAR_setFlg( charaindex, CHAR_ISDIE, 0 ); + +#ifdef _BATTLE_PROPERTY + { + Char *ch; + ch = CHAR_getCharPointer( charaindex); + if( ch == NULL ) return; + strcpysafe( ch->charfunctable[CHAR_BATTLEPROPERTY].string, + sizeof( ch->charfunctable[CHAR_BATTLEPROPERTY]), "");//战斗 + CHAR_constructFunctable( charaindex); + } +#endif + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + CHAR_setWorkInt( charaindex, CHAR_MYSKILLHIT, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORK_P_DUCK, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORKMOD_P_DUCK, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORK_WEAPON, 0 ); // 武器专精 + + // 火冰电抗性 + for( i=0; i<3; i++) + CHAR_setWorkInt( charaindex, CHAR_WORK_F_RESIST+i, 0/*CHAR_getInt( charaindex, PROFESSION_FIRE_R+i )*/ ); + +#endif + +#ifdef _PETSKILL_BECOMEPIG + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ) + { + for( i =0; i < CHAR_MAXPETHAVE; i++){ + int pindex = CHAR_getCharPet( charaindex, i ); + if( !CHAR_CHECKINDEX( pindex ) ) + continue; + CHAR_setInt( pindex, CHAR_BECOMEPIG, -1 ); + } + } +#endif + +} + +int BATTLE_getTopBattle( int battleindex ) +{ + + BATTLE *pBattleTop; + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE ) return -1; + + pBattleTop = &BattleArray[battleindex]; + + while( pBattleTop != NULL ){ + pBattleTop = BattleArray[battleindex].pBefore; + } + + if( BATTLE_CHECKINDEX( pBattleTop->battleindex ) == FALSE ){ + return -1; + }else{ + return pBattleTop->battleindex; + } +} + +static int BATTLE_getBattleFieldNo( int floor, int x, int y ) +{ + int tile[2], map[3], iRet; + if( !MAP_getTileAndObjData( floor, x, y, &tile[0], &tile[1] ) ) + return FALSE; + map[0] = MAP_getImageInt( tile[0], MAP_BATTLEMAP ); + map[1] = MAP_getImageInt( tile[0], MAP_BATTLEMAP2 ); + map[2] = MAP_getImageInt( tile[0], MAP_BATTLEMAP3 ); + iRet = map[RAND( 0, 2 )]; + return iRet; +} + +void BATTLE_BadStatusString( int defNo, int status ) +{ + char szWork[256]; + if( status < 1 || status >= BATTLE_ST_END ){ + status = 0; + } + sprintf( szWork, "BM|%X|%X|", defNo, status ); + strncat( szBadStatusString, szWork, sizeof( szBadStatusString ) ); +} + + + +#ifdef __ATTACK_MAGIC + +static int CharTableIdx[20][2] = +{ + { 3 , 2 } , { 3 , 1 } , { 3 , 3 } , { 3 , 0 } , { 3 , 4 } , + { 2 , 2 } , { 2 , 1 } , { 2 , 3 } , { 2 , 0 } , { 2 , 4 } , + { 0 , 2 } , { 0 , 1 } , { 0 , 3 } , { 0 , 0 } , { 0 , 4 } , + { 1 , 2 } , { 1 , 1 } , { 1 , 3 } , { 1 , 0 } , { 1 , 4 } + +}; + +typedef int ( *FUNCSORTLOC )( const void* , const void* ); + +static int SortLoc( const int *pEle1 , const int *pEle2 ) +{ + int ele1basex , ele1basey; + int ele2basex , ele2basey; + + ele1basex = CharTableIdx[*pEle1][1]; + ele1basey = CharTableIdx[*pEle1][0]; + ele2basex = CharTableIdx[*pEle2][1]; + ele2basey = CharTableIdx[*pEle2][0]; + + if( *pEle1 >= 10 ){ + if( ele1basey != ele2basey ) + return ( ele1basey - ele2basey ); + return ( ele1basex - ele2basex ); + }else{ // 右下方 + if( ele1basey != ele2basey ) + return ( ele2basey - ele1basey ); + return ( ele2basex - ele1basey ); + } + return 0; +} +#endif + +int BATTLE_MultiList( int battleindex, int toNo, int ToList[] ) +{ + int j , i , cnt=0,nLife = 0,nLifeArea[10]; +#ifdef __ATTACK_MAGIC + // 单人攻击 + if(0 <= toNo && toNo <= 19){ + memset(nLifeArea,-1,sizeof(nLifeArea)); + // 如果被攻击者是右下方的人 + if(toNo >= 0 && toNo <= 9){ + for(i=0;i<10;i++){ + // 确定活着的人数,并记录活着的人的号码 + if(BATTLE_TargetCheck(battleindex,i) == TRUE) nLifeArea[nLife++] = i; + } + } + // 如果被攻击者是左上方的人 + if(toNo >= 10 && toNo <= 19){ + for(i=10;i<20;i++){ + // 确定活着的人数,并记录活着的人的号码 + if(BATTLE_TargetCheck(battleindex,i) == TRUE) nLifeArea[nLife++] = i; + } + } + + // 全死(虽然不太可能,但..) + if(nLife == 0){ + print("\nAll die!!"); + return -1; + }else{ + // 被攻击的对象已经死亡或不在战场上 + if(BATTLE_TargetCheck(battleindex,toNo) == FALSE) + // 随机找一只来打 + while((toNo = nLifeArea[rand()%10]) == -1); + } + ToList[0] = toNo; + ToList[1] = -1; + cnt = 1; + } + // 右下後一列攻击 + else if( TARGET_SIDE_0_B_ROW == toNo ){ + for( j = 0 , i = 0 ; i < SIDE_OFFSET / 2 ; i++ ){ + if( TRUE == BATTLE_TargetCheck( battleindex , i ) ){ + ToList[j] = i; + j++; + } + } + ToList[j] = -1; + cnt = j; + // 如果这一排都没有人可以打 + if(j == 0){ + // 换前一排 + for( j = 0 , i = SIDE_OFFSET / 2 ; i < SIDE_OFFSET ; i++ ){ + if( TRUE == BATTLE_TargetCheck( battleindex , i ) ){ + ToList[j] = i; + j++; + } + } + ToList[j] = -1; + cnt = j; + // 如果全死 + if(j == 0) return -1; + toNo = TARGET_SIDE_0_F_ROW; + } + } + // 右下前一列攻击 + else if( TARGET_SIDE_0_F_ROW == toNo ) + { + for( j = 0 , i = SIDE_OFFSET / 2 ; i < SIDE_OFFSET ; i++ ) + { + if( TRUE == BATTLE_TargetCheck( battleindex , i ) ) + { + ToList[j] = i; + j++; + } + } + ToList[j] = -1; + cnt = j; + // 如果这一排都没有人可以打 + if(j == 0) + { + // 换後一排 + for( j = 0 , i = 0 ; i < SIDE_OFFSET / 2 ; i++ ) + { + if( TRUE == BATTLE_TargetCheck( battleindex , i ) ) + { + ToList[j] = i; + j++; + } + } + ToList[j] = -1; + cnt = j; + // 如果全死 + if(j == 0) return -1; + toNo = TARGET_SIDE_0_B_ROW; + } + } + // 左下後一列攻击 + else if( TARGET_SIDE_1_B_ROW == toNo ) + { + for( j = 0 , i = SIDE_OFFSET ; i < SIDE_OFFSET + SIDE_OFFSET / 2 ; i++ ) + { + if( TRUE == BATTLE_TargetCheck( battleindex , i ) ) + { + ToList[j] = i; + j++; + } + } + ToList[j] = -1; + cnt = j; + // 如果这一排都没有人可以打 + if(j == 0) + { + // 换前一排 + for( j = 0 , i = SIDE_OFFSET + SIDE_OFFSET / 2 ; i < SIDE_OFFSET * 2 ; i++ ) + { + if( TRUE == BATTLE_TargetCheck( battleindex , i ) ) + { + ToList[j] = i; + j++; + } + } + ToList[j] = -1; + cnt = j; + // 如果全死 + if(j == 0) return -1; + toNo = TARGET_SIDE_1_F_ROW; + } + } + // 左上前一列攻击 + else if( TARGET_SIDE_1_F_ROW == toNo ) + { + for( j = 0 , i = SIDE_OFFSET + SIDE_OFFSET / 2 ; i < SIDE_OFFSET * 2 ; i++ ) + { + if( TRUE == BATTLE_TargetCheck( battleindex , i ) ) + { + ToList[j] = i; + j++; + } + } + ToList[j] = -1; + cnt = j; + // 如果这一排都没有人可以打 + if(j == 0) + { + // 换後一排 + for( j = 0 , i = SIDE_OFFSET ; i < SIDE_OFFSET + SIDE_OFFSET / 2 ; i++ ) + { + if( TRUE == BATTLE_TargetCheck( battleindex , i ) ) + { + ToList[j] = i; + j++; + } + } + ToList[j] = -1; + cnt = j; + // 如果全死 + if(j == 0) return -1; + toNo = TARGET_SIDE_1_B_ROW; + } + } + // 右下方所有攻击 + else if( TARGET_SIDE_0 == toNo ) + { + //print("BATTLE_MultiList(20)toNo->%d\n",toNo); + for( j = 0 , i = 0 ; i < SIDE_OFFSET ; i++ ) + { + if( TRUE == BATTLE_TargetCheck( battleindex , i ) ) + { + ToList[j] = i; + j++; + } + } + + ToList[j] = -1; + cnt = j; + } + // 左上方所有攻击 + else if( toNo == TARGET_SIDE_1 ) + { + for( j = 0 , i = SIDE_OFFSET ; i < SIDE_OFFSET * 2 ; i++ ) + { + if( TRUE == BATTLE_TargetCheck( battleindex , i ) ) + { + ToList[j] = i; + j++; + } + } + + ToList[j] = -1; + cnt = j; + } + // 所有人攻击 + else if( toNo == TARGET_ALL ){ +#ifdef _FIX_ARRAYBUG + for( j = 0 , i = 0 ; i < SIDE_OFFSET * 2 ; i++ ){ +#else + for( j = 0 , i = 0 ; i < SIDE_OFFSET * 2 ; i++ , j++ ) { +#endif + if( TRUE == BATTLE_TargetCheck( battleindex , i ) ){ + ToList[j] = i; + j++; + } + } + ToList[i] = -1; + cnt = j; + // won add 前後排攻击 + }else if( toNo == TARGER_THROUGH ){ + int toNo2=-1, count=0; + + if(BATTLE_TargetCheck(battleindex,toNo) != FALSE){ + ToList[count] = toNo; + count++; + cnt = count; + } + + if( toNo < (SIDE_OFFSET/2) ) toNo2= toNo + (SIDE_OFFSET/2); + else if( toNo < (SIDE_OFFSET) ) toNo2= toNo - (SIDE_OFFSET/2); + else if( toNo < (SIDE_OFFSET*1.5) ) toNo2= toNo + (SIDE_OFFSET/2); + else if( toNo < (SIDE_OFFSET*2) ) toNo2= toNo - (SIDE_OFFSET/2); + + if(BATTLE_TargetCheck(battleindex,toNo2) != FALSE){ + ToList[count] = toNo2; + count++; + cnt = count; + } + }else{ + ToList[0] = toNo; + ToList[1] = -1; + cnt = 1; + } + + if( cnt > 1 ) qsort( ToList , cnt , sizeof( ToList[0] ) , ( FUNCSORTLOC )SortLoc ); + return toNo; + +#else + if( 0 <= toNo && toNo <= 19 ) + { + if( BATTLE_TargetCheck( battleindex, toNo ) == TRUE ) + { + ToList[0] = toNo; + ToList[1] = -1; + cnt = 1; + } + else + { + ToList[0] = -1; + ToList[1] = -1; + cnt = 0; + } + } + else if( toNo == TARGET_SIDE_0 ) + { + for( j = 0, i = 0; i < SIDE_OFFSET; i ++) + { + if( BATTLE_TargetCheck( battleindex, i ) == TRUE ) + { + ToList[j] = i; + j ++ ; + } + } + ToList[j] = -1; + cnt = j; + } + else if( toNo == TARGET_SIDE_1 ) + { + for( j = 0, i = SIDE_OFFSET; i < SIDE_OFFSET*2; i ++ ) + { + if( BATTLE_TargetCheck( battleindex, i ) == TRUE ) + { + ToList[j] = i; + j ++ ; + } + } + ToList[j] = -1; + cnt = j; + } + else if( toNo == TARGET_ALL ){ + for( j = 0, i = 0; i < SIDE_OFFSET*2; i ++, j ++ ){ + if( BATTLE_TargetCheck( battleindex, i ) == TRUE ){ + ToList[j] = i; + j ++ ; + } + } + ToList[i] = -1; + cnt = j; + } + else + { + ToList[0] = toNo; + ToList[1] = -1; + cnt = 1; + } + + return 1; +#endif +} + +void BATTLE_MultiListDead( int battleindex, int toNo, int ToList[] ) +{ + int j, i; + if( 0 <= toNo && toNo <= 19 ){ + if( BATTLE_TargetCheckDead( battleindex, toNo ) == TRUE ){ + ToList[0] = toNo; + ToList[1] = -1; + }else{ + ToList[0] = -1; + ToList[1] = -1; + } + }else + if( toNo == TARGET_SIDE_0 ){ + for( j = 0, i = 0; i < SIDE_OFFSET; i ++){ + if( BATTLE_TargetCheckDead( battleindex, i ) == TRUE ){ + ToList[j] = i; + j ++ ; + } + } + ToList[j] = -1; + }else + if( toNo == TARGET_SIDE_1 ){ + for( j = 0, i = SIDE_OFFSET; i < SIDE_OFFSET*2; i ++ ){ + if( BATTLE_TargetCheckDead( battleindex, i ) == TRUE ){ + ToList[j] = i; + j ++ ; + } + } + ToList[j] = -1; + }else{ + if( toNo == TARGET_ALL ){ +#ifdef _FIX_ARRAYBUG + for( j = 0, i = 0; i < SIDE_OFFSET*2; i ++){ +#else + for( j = 0, i = 0; i < SIDE_OFFSET*2; i ++, j ++ ){ +#endif + if( BATTLE_TargetCheckDead( battleindex, i ) == TRUE ){ + ToList[j] = i; + j ++ ; + } + } +#ifdef _FIX_ITEMRELIFE // WON ADD 修正替身娃娃问题 + ToList[j] = -1; +#else + ToList[i] = -1; +#endif + }else{ + ToList[0] = toNo; + ToList[1] = -1; + } + } +} + +BOOL BATTLE_IsThrowWepon( int itemindex){ + int itemtype; + if( ITEM_CHECKINDEX( itemindex ) == FALSE ){ + return FALSE; + } + itemtype = ITEM_getInt( itemindex, ITEM_TYPE ); + if( itemtype == ITEM_BOOMERANG + || itemtype == ITEM_BOW + || itemtype == ITEM_BREAKTHROW + || itemtype == ITEM_BOUNDTHROW ){ + return TRUE; + }else{ + return FALSE; + } +} + +int BATTLE_ClearGetExp( int charaindex ) +{ + int i, pindex; + + if( CHAR_CHECKINDEX( charaindex ) == FALSE ){ + return BATTLE_ERR_CHARAINDEX; + } + CHAR_setWorkInt( charaindex, CHAR_WORKGETEXP, 0 ); + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + pindex = CHAR_getCharPet( charaindex, i ); + if( CHAR_CHECKINDEX( pindex ) == FALSE )continue; + CHAR_setWorkInt( pindex, CHAR_WORKGETEXP, 0 ); + } + + return 0; +} + +INLINE void _BATTLE_ExitAll( char *file, int line, int battleindex) +{ + int j,i, charaindex; + for( j = 0; j < 2; j ++ ){ + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = BattleArray[battleindex].Side[j].Entry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + BATTLE_Exit( charaindex, battleindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, + BATTLE_CHARMODE_NONE ); + } + } +} + +void BATTLE_AllCharaFinishSet( int battleindex ) +{ + int j,i, charaindex; + for( j = 0; j < 2; j ++ ){ + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = BattleArray[battleindex].Side[j].Entry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, + BATTLE_CHARMODE_FINAL ); + } + } +} + +BOOL BATTLE_IsCharge( int charaindex ) +{ + int com; + com = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ); + if( com == BATTLE_COM_S_CHARGE + || com == BATTLE_COM_S_EARTHROUND1 + || com == BATTLE_COM_S_EARTHROUND0 +#ifdef _PROFESSION_ADDSKILL + || CHAR_getWorkInt( charaindex, CHAR_DOOMTIME ) > 0 +#endif + ){ + return TRUE; + } + return FALSE; +} + +void BATTLE_AllCharaCWaitSet( int battleindex ) +{ + int j,i, charaindex; + for( j = 0; j < 2; j ++ ){ + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = BattleArray[battleindex].Side[j].Entry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + + if( BATTLE_IsCharge( charaindex ) == TRUE ){ + }else{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, + BATTLE_COM_NONE ); + } + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, + BATTLE_CHARMODE_C_WAIT ); + } + } +} + +void BATTLE_AllCharaWatchWaitSet( int battleindex ) +{ + int i, charaindex; + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = BattleArray[battleindex].Side[0].Entry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) + != BATTLE_CHARMODE_WATCHINIT + ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, + BATTLE_CHARMODE_C_WAIT ); + } + } +} + +void BATTLE_SurpriseSet( + int battleindex, + int side +) +{ + BATTLE_ENTRY *pEntry; + int i, charaindex; + + pEntry = BattleArray[battleindex].Side[side].Entry; + + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pEntry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + } + } + + +} + +BOOL BATTLE_initBattleArray( + int battlenum +) +{ + + int i; + BATTLE_battlenum = battlenum; + + BattleArray = allocateMemory( sizeof( BATTLE ) * BATTLE_battlenum ); + if( BattleArray == NULL ) return FALSE; + for( i = 0 ; i < BATTLE_battlenum ; i ++ ){ + memset( &BattleArray[i], 0 , sizeof( BATTLE )); + } + return TRUE; + +} + +static void EntryInit( BATTLE_ENTRY *pEntry ){ + int i; + pEntry->charaindex = -1; + pEntry->bid = -1; + pEntry->escape = 0; + for( i = 0; i < GETITEM_MAX; i ++ ){ + pEntry->getitem[i] = -1; + } +} + +int BATTLE_CreateBattle( void ) +{ + int battleindex, i, j; + BATTLE *pBattle; + battleindex = BATTLE_SearchTask( ); + // NUKE 0701 + if( battleindex < 0 )return -1; + pBattle = &BattleArray[battleindex]; + // NUKE 0701 + if (pBattle==NULL) return -1; + pBattle->use = TRUE; + pBattle->mode = BATTLE_MODE_INIT; + pBattle->turn = 0; + pBattle->dpbattle = 0; + pBattle->norisk = 0; + pBattle->flg = 0; + pBattle->field_att = BATTLE_ATTR_NONE; + pBattle->att_count = 0; + for( j = 0; j < 2; j ++ ){ + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + EntryInit( &pBattle->Side[j].Entry[i] ); + } + } + for( i = 0; i < BATTLE_ENTRY_MAX*2; i ++ ){ + pBattle->iEntryBack[i] = -1; + pBattle->iEntryBack2[i] = -1; + } + pBattle->WinFunc = NULL; +#ifdef _DEATH_CONTEND//计算胜败func + pBattle->PkFunc = NULL; + pBattle->battlemap = -1; +#endif + pBattle->pNext = NULL; + pBattle->pBefore = NULL; + pBattle->battleindex = battleindex; + Total_BattleNum ++; +#ifdef _BATTLECOMMAND_TIME + pBattle->PartTime = 0; +#endif +#ifdef _PROFESSION_ADDSKILL + //冰爆术存放 +/* pBattle->ice_count = 0; + for( i = 0; i < 20; i ++ ){ + pBattle->ice_bout[i]=0; + pBattle->ice_use[i]=FALSE; + pBattle->ice_toNo[i]=0; + pBattle->ice_level[i]=0; + pBattle->ice_array[i]=0; + pBattle->ice_attackNo[i]=0; + pBattle->ice_charaindex[i]=-1; + }*/ +#endif + return battleindex; +} + +static int BATTLE_SearchTask( void ) +{ + int i, j; + i = BATTLE_searchCnt; + for( j = 0; j < BATTLE_battlenum; j ++ ){ + if( i >= BATTLE_battlenum ) i = 0; + if( BattleArray[i].use == FALSE ){ + BATTLE_searchCnt = i + 1; + return i; + } + i ++; + } + return -1; +} + +void BATTLE_DeleteItem( int battleindex ) +{ + int i, j, k; + BATTLE_ENTRY *pEntry; + + for( j = 0; j < 2; j ++ ){ + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + pEntry = &BattleArray[battleindex].Side[j].Entry[i]; + for( k = 0; k < GETITEM_MAX; k ++ ){ + if( pEntry->getitem[k] >= 0 ){ + print( "// 找寻(消去)道具(%d),(%s)\n", + pEntry->getitem[k], + ITEM_getAppropriateName(pEntry->getitem[k]) ); + ITEM_endExistItemsOne( pEntry->getitem[k] ); + } + } + } + } +} + + +int BATTLE_DeleteBattle( + int battleindex +) +{ + int i, j; + BATTLE *pBattle; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE ){ + fprint( "err:battle index error\n" ); + return BATTLE_ERR_BATTLEINDEX; + } + if( BATTLE_WatchUnLink( battleindex ) == FALSE ){ + fprint( "err:battle link 不脱离\n" ); + } + + pBattle = &BattleArray[battleindex]; + pBattle->use = FALSE; + pBattle->mode = BATTLE_MODE_NONE; + BATTLE_DeleteItem( battleindex ); + for( j = 0; j < 2; j ++ ){ + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + EntryInit( &pBattle->Side[j].Entry[i] ); + } + } + Total_BattleNum--; + return 0; +} + + +int BATTLE_No2Index( + int battleindex, + int bid +) +{ + BATTLE_ENTRY *pEntry; + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return -1; + if( BATTLE_CHECKNO( bid ) == FALSE )return -1; + + if( bid >= 10 ){ + pEntry = BattleArray[battleindex].Side[1].Entry; + bid -= SIDE_OFFSET; + }else{ + pEntry = BattleArray[battleindex].Side[0].Entry; + } + if( CHAR_CHECKINDEX( pEntry[bid].charaindex ) == FALSE )return -1; + + return pEntry[bid].charaindex; + +} +#ifdef _Item_ReLifeAct +int BATTLE_getBattleDieIndex( int battleindex, int bid ) +{ + BATTLE_ENTRY *pEntry; + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return -1; + if( BATTLE_CHECKNO( bid ) == FALSE )return -1; + + if( bid >= 10 ){ + pEntry = BattleArray[battleindex].Side[1].Entry; + bid -= SIDE_OFFSET; + }else{ + pEntry = BattleArray[battleindex].Side[0].Entry; + } + if( CHAR_CHECKINDEX( pEntry[bid].charaindex ) == FALSE )return -1; + if( pEntry[bid].flg & BENT_FLG_ULTIMATE ) return -1; + + return pEntry[bid].charaindex; + +} +#endif + +#ifdef _PROFESSION_ADDSKILL +BOOL BATTLE_BattleUltimate( int battleindex, int bid ) //检查此位 上是否被打飞 +{ + BATTLE_ENTRY *pEntry; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return FALSE; + if( BATTLE_CHECKNO( bid ) == FALSE )return FALSE; + if( bid >= 10 ){ + pEntry = BattleArray[battleindex].Side[1].Entry; + bid -= SIDE_OFFSET; + }else{ + pEntry = BattleArray[battleindex].Side[0].Entry; + } + if( pEntry[bid].flg & BENT_FLG_ULTIMATE ) return TRUE; + else return TRUE; +} +#endif + +int BATTLE_Index2No( + int battleindex, + int charaindex +) +{ + BATTLE_ENTRY *pEntry; + int i, j; + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return -1; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return -1; + + for( j = 0; j < 2; j ++ ){ + pEntry = BattleArray[battleindex].Side[j].Entry; + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + if( pEntry[i].charaindex == charaindex ){ + return i + j * SIDE_OFFSET; + } + } + } + + return -1; + +} + + +char *BATTLE_CharTitle( int charaindex ) +{ + char *pName; + static char Len0Buff[2] = ""; + + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + pName = Len0Buff; + }else{ + pName = CHAR_getChar( charaindex, CHAR_OWNTITLE ); + if( pName[0] == 0 ){ + pName = Len0Buff; + } + } + return pName; +} + + +int BATTLE_CharaBackUp( int battleindex ) +{ + int i, j, k, charaindex; + BATTLE *pBattle; + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE ){ + return BATTLE_ERR_BATTLEINDEX; + } + + pBattle = &BattleArray[battleindex]; + k = 0; + + for( j = 0; j < 2; j ++ ){ + k = j * SIDE_OFFSET; + for( i = 0; i < BATTLE_ENTRY_MAX/2; i ++ ){ + charaindex = pBattle->Side[j].Entry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == TRUE + && CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER + ){ + pBattle->iEntryBack[k] = pBattle->Side[j].Entry[i].charaindex; + pBattle->iEntryBack2[k] = pBattle->Side[j].Entry[i].charaindex; + }else{ + pBattle->iEntryBack[k] = -1; + pBattle->iEntryBack2[k] = -1; + } + k ++; + } + } + + return 0; +} + + + + +int BATTLE_NewEntry( + int charaindex, + int battleindex, + int side +) +{ + BATTLE_ENTRY *pEntry; + BATTLE *pBattle; + int i, iEntryMax, iEntryFirst; + + if( BATTLE_CHECKSIDE( side ) == FALSE )return BATTLE_ERR_PARAM; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return BATTLE_ERR_CHARAINDEX; + + pBattle = &BattleArray[battleindex]; + + if( pBattle->use == FALSE )return BATTLE_ERR_NOUSE; + + if( side < 0 || side > 1 ){ + return BATTLE_ERR_PARAM; + } + + switch( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) ){ + int work; + + case CHAR_TYPEPLAYER: + if( pBattle->Side[side].type != BATTLE_S_TYPE_PLAYER ){ + return BATTLE_ERR_TYPE; + } + iEntryFirst = 0; + iEntryMax = BATTLE_PLAYER_MAX; + break; + case CHAR_TYPEENEMY: + if( pBattle->Side[side].type != BATTLE_S_TYPE_ENEMY ){ + return BATTLE_ERR_TYPE; + } + iEntryFirst = 0; + iEntryMax = BATTLE_ENTRY_MAX; + break; + case CHAR_TYPEPET: + if( pBattle->Side[side].type != BATTLE_S_TYPE_PLAYER ){ + return BATTLE_ERR_TYPE; + } + + work = CHAR_getWorkInt( charaindex, CHAR_WORKPLAYERINDEX ); + pEntry = pBattle->Side[side].Entry; + + work = BATTLE_Index2No( battleindex, work ); + work -= side * SIDE_OFFSET; + work += 5; + iEntryFirst = work; + iEntryMax = work+1; + break; + default: + print( "不明(%s)(%d)\n", + CHAR_getUseName( charaindex ), + CHAR_getInt( charaindex, CHAR_WHICHTYPE ) ); + return BATTLE_ERR_TYPE; + } + + + pEntry = pBattle->Side[side].Entry; + + for( i = iEntryFirst; i < iEntryMax; i ++ ){ + if( pEntry[i].charaindex == -1 )break; + } + + if( i == iEntryMax ){ + return BATTLE_ERR_ENTRYMAX; + } + + EntryInit( &pEntry[i] ); + + pEntry[i].charaindex = charaindex; + + pEntry[i].bid = i + side * SIDE_OFFSET; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEINDEX, + battleindex ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, + BATTLE_CHARMODE_INIT ); + // shan 2001/12/27 Begin + { + int fd; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE)==CHAR_TYPEPLAYER ){ + fd = CHAR_getWorkInt( charaindex, CHAR_WORKFD); + CONNECT_SetBattleRecvTime( fd, &NowTime); + } + } + // End + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLESIDE, side ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEFLG, 0 ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, -1 ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, -1 ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM3, -1 ); + + CHAR_setWorkInt( charaindex, CHAR_WORKMODATTACK, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORKMODDEFENCE, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORKMODQUICK, 0 ); + + CHAR_setWorkInt( charaindex, CHAR_WORKDAMAGEABSROB, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORKDAMAGEREFLEC, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORKDAMAGEVANISH, 0 ); + + + CHAR_setWorkInt( charaindex, CHAR_WORKMODCAPTURE, 0 ); + + CHAR_setFlg( charaindex, CHAR_ISATTACKED, 1 ); + + BATTLE_BadStatusAllClr( charaindex ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEWATCH, 0 ); + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + CHAR_setWorkInt( charaindex, CHAR_WORKTRAP, 0 ); //陷阱 + BATTLE_ProfessionStatus_init( battleindex, charaindex ); +#endif + +#ifdef _PETSKILL_ACUPUNCTURE + CHAR_setWorkInt( charaindex, CHAR_WORKACUPUNCTURE, 0 );//针刺外皮 +#endif + +#ifdef _PETSKILL_RETRACE + CHAR_setWorkInt( charaindex, CHAR_WORKRETRACE, 0 );//追迹攻击 +#endif + +#ifdef _PETSKILL_BECOMEFOX //将媚惑术中招时间清除为-1 + CHAR_setWorkInt( charaindex, CHAR_WORKFOXROUND, -1 ); +#endif +#ifdef _PROFESSION_ADDSKILL + //结界清除 + CHAR_setWorkInt( charaindex, CHAR_WORKFIXEARTHAT_BOUNDARY, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORKFIXWATERAT_BOUNDARY, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORKFIXFIREAT_BOUNDARY, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORKFIXWINDAT_BOUNDARY, 0 ); + CHAR_setWorkInt( charaindex, CHAR_DOOMTIME, 0 );//世界末日集气 + CHAR_setWorkInt( charaindex, CHAR_WORK_com1, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORK_toNo, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORK_mode, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORK_skill_level, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORK_array, 0 ); +#endif + return 0; +} + +INLINE int _BATTLE_Exit( char *file, int line, int charaindex ,int battleindex) +{ + BATTLE_ENTRY *pEntry; + int i, j, k; + BATTLE *pBattle; + char szPet[32]; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return BATTLE_ERR_CHARAINDEX; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE ){ + return BATTLE_ERR_BATTLEINDEX; + } +#ifdef _PROFESSION_ADDSKILL + CHAR_setWorkInt( charaindex, CHAR_DOOMTIME, 0 );//世界末日集气 +#endif +#ifdef _PETSKILL_BECOMEFOX // 离开战斗时将媚惑术造成的变身效果清除 + //print("\n检查图号:%s,%d", CHAR_getChar( charaindex, CHAR_NAME), CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER)); + + if( CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER)==101749 + || CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND ) != -1 ){ //变成小狐狸 + CHAR_setInt( charaindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( charaindex, CHAR_BASEBASEIMAGENUMBER) ); + CHAR_setWorkInt( charaindex, CHAR_WORKFOXROUND, -1); + //print("\n变回去:%d",CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER)); + } +#endif + +#ifdef _PETSKILL_BECOMEPIG + if( CHAR_getInt( charaindex, CHAR_BECOMEPIG) > -1 + && CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + CHAR_setInt( charaindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( charaindex, CHAR_BECOMEPIG_BBI ) ); + CHAR_complianceParameter( charaindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + } +#endif + + +#ifdef _MAGIC_NOCAST // 精灵:沉默 + // WON ADD + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ) + lssproto_NC_send( getfdFromCharaIndex( charaindex ), 0);//复原 +#endif + pBattle = &BattleArray[battleindex]; + if( pBattle->use == FALSE ) + return BATTLE_ERR_NOUSE; + + for( j = 0; j < 2; j ++ ){ + pEntry = pBattle->Side[j].Entry; + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + if( pEntry[i].charaindex != charaindex ) + continue; + pEntry[i].charaindex = -1; + pEntry[i].escape = 0; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_FINAL ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEINDEX, -1 ); +#ifdef _LOSE_FINCH_ + CHAR_setWorkInt( charaindex, CHAR_WORKSPETRELIFE, 0); +#endif + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ){ + CHAR_endCharOneArray( charaindex ); + }else if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + int petindex = pEntry[i+5].charaindex; + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == TRUE + || CHAR_getInt( charaindex, CHAR_HP ) == TRUE ) + { + +#ifdef _ACTION_BULLSCR +#ifndef _BULL_CUTBULLSCR + { + if( CHAR_getInt( charaindex, CHAR_ABULLSTART) == 10 ){ + char buf[256]; + sprintf( buf, "因战斗中倒地,活动积分不予计算。"); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + } + } +#endif +#endif + +#ifdef _FIX_SPEED_UPLEVEL // WON ADD 修正加速 + // Robin cancel + //if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == TRUE ){ + //}else + { + // Robin cancel + //if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1) != BATTLE_COM_ESCAPE ) + { + unsigned int Dtimes; + unsigned int battletime; + int fd = getfdFromCharaIndex( charaindex ); + Dtimes = BattleArray[battleindex].CreateTime; + battletime = (unsigned int)(BattleArray[battleindex].flgTime/100); + + //if( CHAR_getWorkInt( charaindex, CHAR_WORKFLG) & WORKFLG_DEBUGMODE ){ + //}else + { + CheckDefBTime( charaindex, fd, Dtimes, battletime, 10);//lowTime延迟时间 + } + } + } +#endif + CHAR_setFlg( charaindex, CHAR_ISDIE, 0 ); + CHAR_setInt( charaindex, CHAR_HP, 1 ); + // CoolFish: Faily PK 2001/8/3 + CHAR_setWorkInt(charaindex, CHAR_WORKFMPKFLAG, -1); + + }else { +#ifdef _BATTLE_TIMESPEED + // Robin cancel + //if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1) != BATTLE_COM_ESCAPE ) + { + unsigned int Dtimes; + unsigned int battletime; + + int fd = getfdFromCharaIndex( charaindex ); + Dtimes = BattleArray[battleindex].CreateTime; + battletime = (unsigned int)(BattleArray[battleindex].flgTime/100); + //if( CHAR_getWorkInt( charaindex, CHAR_WORKFLG) & WORKFLG_DEBUGMODE ) { + //}else + { + CheckDefBTime( charaindex, fd, Dtimes, battletime, 0);//lowTime延迟时间 + } + } +#endif +#ifdef _ACTION_BULLSCR +#ifndef _BULL_CUTBULLSCR + + if( CHAR_getInt( charaindex, CHAR_ABULLSTART) == 10 && + BattleArray[battleindex].CreateTime > 0 ) { + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1) != BATTLE_COM_ESCAPE && + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEWATCH ) != 1 ) { + char buf[256]; + unsigned int Dtimes; + int ntime, deftime=0,Scount=0; + int nowtime = (unsigned int)time(NULL);//CHAR_BULLSHOWCOUNT + Scount = CHAR_getWorkInt( charaindex, CHAR_BULLSHOWCOUNT); + if( Scount < 0 ) Scount = 0; + ntime = CHAR_getInt( charaindex, CHAR_ABULLTIME); + Dtimes = BattleArray[battleindex].CreateTime; + deftime = (nowtime - (int)Dtimes)-5; + if( ntime < 0 ) ntime = 0; + if( deftime > (60*60) ) deftime = (60*60); + if( deftime < 0 ) deftime = 0; + + if( CHAR_getWorkInt( charaindex, CHAR_WORKGETEXP) > + (BattleArray[battleindex].enemynum * 2) || + BattleArray[battleindex].type == BATTLE_TYPE_P_vs_P){ + ntime = (ntime + deftime); + Scount += deftime; + if( Scount >= (5*60) ){ + Scount = 0; + sprintf( buf, "战斗时间已累积%d分%d秒。", ntime/60, ntime%60); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + } + CHAR_setWorkInt( charaindex, CHAR_BULLSHOWCOUNT, Scount); + CHAR_setInt( charaindex, CHAR_ABULLTIME, ntime); + if( ntime >= (60*60) ){//活动一小时 + //if( ntime > 10 ){//测试加快 //CHAR_setWorkInt( charaindex, CHAR_WORKGETEXP, 0 ); + int nScore = CHAR_getInt( charaindex, CHAR_ABULLSCORE); + ntime = ntime - (60*60); + ntime = ( ntime<0)?0:ntime; + CHAR_setInt( charaindex, CHAR_ABULLTIME, ntime); + CHAR_setInt( charaindex, CHAR_ABULLSCORE, nScore+10 ); + sprintf( buf, "战斗满1小时时间取得10分,总共取得%d绩分。", nScore+10); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + } + }else{ + sprintf( buf, "因此场战斗取得经验值不足,活动积分不予计算。"); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + } + }else{ + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1) == BATTLE_COM_ESCAPE){ + char buf[256]; + sprintf( buf, "因战斗逃跑,活动积分不予计算。"); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + } + } + } + //BattleArray[battleindex].CreateTime = 0; +#endif +#endif + } + if( CHAR_CHECKINDEX( petindex ) == TRUE ){ + pEntry[i+5].charaindex = -1; + CHAR_setWorkInt( petindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_NONE ); + CHAR_setWorkInt( petindex, CHAR_WORKBATTLEINDEX, -1 ); + } + BATTLE_BadStatusAllClr( charaindex ); + CHAR_complianceParameter( charaindex ); + CHAR_Skillupsend( charaindex ); + // Robin 0730 + if( CHAR_getWorkInt( charaindex, CHAR_WORKPETFALL) ) + { + CHAR_setWorkInt( charaindex, CHAR_WORKPETFALL, 0 ); + CHAR_setInt( charaindex, CHAR_RIDEPET, -2 ); + } + CHAR_send_P_StatusString( charaindex , + CHAR_P_STRING_HP|CHAR_P_STRING_EXP| + CHAR_P_STRING_MP|CHAR_P_STRING_DUELPOINT| + CHAR_P_STRING_CHARM | + CHAR_P_STRING_EARTH | + CHAR_P_STRING_WATER | + CHAR_P_STRING_FIRE | + CHAR_P_STRING_WIND | + CHAR_P_STRING_RIDEPET + ); + // Robin 0730 + if( CHAR_getInt( charaindex, CHAR_RIDEPET ) == -2 ){ + CHAR_setInt( charaindex, CHAR_RIDEPET, -1 ); + } + for( k = 0; k < CHAR_MAXPETHAVE; k ++ ){ + petindex = CHAR_getCharPet( charaindex, k ); + if( CHAR_CHECKINDEX( petindex ) == FALSE )continue; + if( CHAR_getInt( petindex, CHAR_MAILMODE) != CHAR_PETMAIL_NONE ) continue; + if( CHAR_getFlg( petindex, CHAR_ISDIE ) == TRUE + || CHAR_getInt( petindex, CHAR_HP ) <= 0 ){ + CHAR_setFlg( petindex, CHAR_ISDIE, 0 ); + CHAR_setInt( petindex, CHAR_HP, 1 ); + } + CHAR_setWorkInt( petindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_NONE ); +#ifdef _LOSE_FINCH_ + CHAR_setWorkInt( charaindex, CHAR_WORKSPETRELIFE, 0); +#endif +#ifdef _VARY_WOLF + if( CHAR_getInt( petindex, CHAR_BASEBASEIMAGENUMBER) != CHAR_getInt( petindex, CHAR_BASEIMAGENUMBER) ) // Robin fix + { + CHAR_setInt( petindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( petindex, CHAR_BASEBASEIMAGENUMBER)); + sprintf( szPet, "K%d", k); + CHAR_sendStatusString( charaindex , szPet); + } +#endif +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + // 遗忘 + if( CHAR_getWorkInt( petindex, CHAR_WORKOBLIVION ) > 0 ) // Robin fix + { + int pet_no = CHAR_getInt( charaindex, CHAR_DEFAULTPET ); + CHAR_setWorkInt( petindex, CHAR_WORKOBLIVION, 0 ); + // 宠物编号 + sprintf( szPet, "W%d", pet_no); + CHAR_sendStatusString( charaindex , szPet); + } +#endif + BATTLE_BadStatusAllClr( petindex ); + CHAR_complianceParameter( petindex ); + CHAR_send_K_StatusString( charaindex , k, + CHAR_K_STRING_HP|CHAR_K_STRING_EXP| + CHAR_K_STRING_AI| CHAR_K_STRING_MP | + CHAR_K_STRING_ATK | CHAR_K_STRING_DEF | + CHAR_K_STRING_QUICK | + CHAR_K_STRING_EARTH | + CHAR_K_STRING_WATER | + CHAR_K_STRING_FIRE | + CHAR_K_STRING_WIND + ); + } + if( BattleArray[battleindex].type == BATTLE_TYPE_P_vs_P ){ + int flg = 0; + CHAR_setFlg( charaindex, CHAR_ISDUEL, 0); + if( CHAR_getFlg( charaindex, CHAR_ISPARTY)) flg |= CHAR_FS_PARTY; + if( CHAR_getFlg( charaindex, CHAR_ISDUEL)) flg |= CHAR_FS_DUEL; + if( CHAR_getFlg( charaindex, CHAR_ISPARTYCHAT)) flg |= CHAR_FS_PARTYCHAT; + if( CHAR_getFlg( charaindex, CHAR_ISTRADECARD)) flg |= CHAR_FS_TRADECARD; +#ifdef _CHANNEL_MODIFY + if( CHAR_getFlg( charaindex, CHAR_ISTELL)) flg |= CHAR_FS_TELL; + if( CHAR_getFlg( charaindex, CHAR_ISFM)) flg |= CHAR_FS_FM; + if( CHAR_getFlg( charaindex, CHAR_ISOCC)) flg |= CHAR_FS_OCC; + if( CHAR_getFlg( charaindex, CHAR_ISCHAT)) flg |= CHAR_FS_CHAT; + if( CHAR_getFlg( charaindex, CHAR_ISSAVE)) flg |= CHAR_FS_SAVE; +#endif + lssproto_FS_send( getfdFromCharaIndex(charaindex), flg); + } + + lssproto_XYD_send( getfdFromCharaIndex(charaindex), + CHAR_getInt( charaindex, CHAR_X ), + CHAR_getInt( charaindex, CHAR_Y ), + CHAR_getInt( charaindex, CHAR_DIR ) ); + } + break; + } + } + CHAR_PartyUpdate( charaindex, CHAR_N_STRING_HP ); + +#ifdef _TIME_TICKET + { + int nowtime = time(NULL); + int tickettime = CHAR_getWorkInt( charaindex, CHAR_WORKTICKETTIME); + int totaltime; + char msg[1024]; + if( tickettime > 0 && tickettime < nowtime ) { + //int floor, x, y; + CHAR_talkToCli( charaindex, -1, "谢谢光顾。", CHAR_COLORYELLOW); + if( CHAR_getWorkInt( charaindex, CHAR_WORKTICKETTIMESTART) > 0 ) { + totaltime = nowtime - CHAR_getWorkInt( charaindex, CHAR_WORKTICKETTIMESTART); + sprintf( msg, "总入场时间%d分%d秒。", totaltime/60, totaltime%60); + CHAR_talkToCli( charaindex, -1, msg, CHAR_COLORYELLOW); + } + CHAR_setWorkInt( charaindex, CHAR_WORKTICKETTIME, 0); + CHAR_setWorkInt( charaindex, CHAR_WORKTICKETTIMESTART, 0); + /*if( CHAR_getElderPosition( CHAR_getInt( charaindex, CHAR_LASTTALKELDER), &floor, &x, &y ) != TRUE ) { + CHAR_warpToSpecificPoint( charaindex, 1006, 15, 15); + } + else { + CHAR_warpToSpecificPoint( charaindex, floor, x, y); + }*/ + CHAR_warpToSpecificPoint( charaindex, 7001, 41, 6); + } + } +#endif + + return BATTLE_ERR_NONE; +} + + +int BATTLE_PetDefaultExit( + int charaindex, + int battleindex +) +{ + int pno, pindex, iRet; + + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return BATTLE_ERR_CHARAINDEX; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER) return 0; + pno = CHAR_getInt( charaindex, CHAR_DEFAULTPET ); + if( pno < 0 )return 0; + pindex = CHAR_getCharPet( charaindex, pno ); + + iRet = BATTLE_Exit( pindex, battleindex ); + + if( iRet ){ + iRet *= -1; + }else{ + return 1; + } + + return iRet; +} + + +int BATTLE_PetDefaultEntry( + int charaindex, + int battleindex, + int side +) +{ + int pindex; + +#if 1 + int pno; + + int ret = 0; + + pno = CHAR_getInt( charaindex, CHAR_DEFAULTPET ); + if( pno == -1 ) return 0; + pindex = CHAR_getCharPet( charaindex, pno ); + + if( CHAR_CHECKINDEX( pindex ) && + + !CHAR_getFlg( pindex, CHAR_ISDIE ) && + CHAR_getInt( pindex, CHAR_HP ) > 0 ) + { + if( BATTLE_NewEntry( pindex, battleindex, side ) ){ + }else{ + ret = 0; + } + } + else { + CHAR_setInt( charaindex, CHAR_DEFAULTPET, -1 ); + } + + return ret; +#else + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + pindex = CHAR_getCharPet( charaindex, i ); + + if( CHAR_CHECKINDEX( pindex ) == FALSE )continue; + + if( CHAR_getFlg( pindex, CHAR_ISDIE ) == TRUE )continue; + if( CHAR_getInt( pindex, CHAR_HP ) <= 0 )continue; + + if( BATTLE_NewEntry( pindex, battleindex, side ) ){ + }else{ + CHAR_setInt( charaindex, CHAR_DEFAULTPET, i ); + break; + } + } + + if( i == CHAR_MAXPETHAVE ){ + CHAR_setInt( charaindex, CHAR_DEFAULTPET, -1 ); + } + return 0; +#endif +} + +int BATTLE_RescueEntry( int charaindex, int toindex ) +{ + int iRet = 0, battleindex, fd, pindex; + char szBuffer[256]=""; + +#ifdef _BATTLE_TIMESPEED + fd = getfdFromCharaIndex( charaindex); + if( CONNECT_getBDTime( fd) > time( NULL) ) { + return 1; + } +#endif + + battleindex = CHAR_getWorkInt( toindex, CHAR_WORKBATTLEINDEX ); + if( !BATTLE_CHECKINDEX( battleindex) ) return 1; + if( ( fd = getfdFromCharaIndex(charaindex) ) < 0 ) return 1; + + if( CHAR_getWorkInt( toindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_FINAL + || CHAR_getWorkInt( toindex, CHAR_WORKBATTLEINDEX ) == -1 ){ + iRet = 1; + } + + if( BattleArray[battleindex].type == BATTLE_TYPE_P_vs_P ){ + iRet = 1; + }else{ + iRet = BATTLE_NewEntry( + charaindex, + battleindex, + CHAR_getWorkInt( toindex, CHAR_WORKBATTLESIDE ) ); + } + + if( iRet == 0 ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_RESCUE ); + iRet = BATTLE_PetDefaultEntry( + charaindex, + battleindex, + CHAR_getWorkInt( toindex, CHAR_WORKBATTLESIDE ) + ); + } + + + + if( iRet == 0 ){ + int flg; + if( CHAR_getInt( charaindex, CHAR_DEFAULTPET ) >= 0 ){ + pindex = CHAR_getCharPet( charaindex, CHAR_getInt( charaindex, CHAR_DEFAULTPET ) ); + CHAR_setWorkInt( pindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_RESCUE ); + } + //snprintf( szBuffer, sizeof( szBuffer ), "(%s)加入作战。", + // CHAR_getUseName( charaindex ) ); + //BATTLE_BroadCast( battleindex, szBuffer, CHAR_COLORYELLOW ); + if( ( fd = getfdFromCharaIndex(charaindex) ) != -1 ){ + lssproto_EN_send( fd, BattleArray[battleindex].type, BattleArray[battleindex].field_no ); + } + flg = (BattleArray[battleindex].Side[ + CHAR_getWorkInt( toindex, CHAR_WORKBATTLESIDE)].flg + & BSIDE_FLG_HELP_OK)? TRUE:FALSE; + lssproto_HL_send( fd, flg); + sprintf( szBuffer, "BP|%X|%X|%X", + BATTLE_Index2No( battleindex, charaindex ), BP_FLG_JOIN, CHAR_getInt(charaindex, CHAR_MP ) ); + BATTLE_CommandSend( charaindex, szBuffer ); + }else{ + snprintf( szBuffer, sizeof( szBuffer ), "无法参战。" ); + CHAR_talkToCli( charaindex, -1, szBuffer, CHAR_COLORYELLOW); + if( ( fd = getfdFromCharaIndex(charaindex) ) != -1 ){ + lssproto_EN_send( fd, FALSE, BattleArray[battleindex].field_no ); + } + } + BATTLE_ClearGetExp( charaindex ); + return iRet; +} + +BOOL BATTLE_RescueTry( int charaindex) +{ + int x,y; + OBJECT object; + int pfound = FALSE; + int result = FALSE; + int fd; + int i; + int cnt; + + fd = getfdFromCharaIndex( charaindex); + if( fd == -1 ) return FALSE; +#if 1 // 修正利用参战重复加入战斗 Robin + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) { + CHAR_talkToCli( charaindex, -1, " 重复加入战斗! ", CHAR_COLORRED); + print("\n 改封包!!重复加入战斗!:%s ", CHAR_getChar( charaindex, CHAR_CDKEY) ); + //lssproto_EN_send( fd, FALSE, 0 ); + return FALSE; + } +#endif + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE ) { + lssproto_EN_send( fd, FALSE, 0 ); + return FALSE; + } +#ifdef _BATTLE_TIMESPEED + if( CONNECT_getBDTime( fd) > time( NULL) ) { + return FALSE; + } +#endif + for( i = 0; i < CONNECT_WINDOWBUFSIZE; i ++ ) { + CONNECT_setBattlecharaindex(fd,i,-1); + } + CHAR_getCoordinationDir( CHAR_getInt( charaindex, CHAR_DIR ) , + CHAR_getInt( charaindex , CHAR_X ), + CHAR_getInt( charaindex , CHAR_Y ) , + 1 , &x , &y ); + + cnt = 0; + for( object = MAP_getTopObj( CHAR_getInt( charaindex, CHAR_FLOOR),x,y) ; + object ; + object = NEXT_OBJECT(object ) ) + { + int toindex; + int objindex = GET_OBJINDEX(object); + if( OBJECT_getType( objindex) != OBJTYPE_CHARA) continue; + toindex = OBJECT_getIndex( objindex); + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ) continue; + pfound = TRUE; + if( CHAR_getWorkInt( toindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE ){ + continue; + } + if( BattleArray[ CHAR_getWorkInt( toindex, CHAR_WORKBATTLEINDEX)].type + != BATTLE_TYPE_P_vs_E ){ + continue; + } + if( !(BattleArray[CHAR_getWorkInt( toindex,CHAR_WORKBATTLEINDEX)].Side[ + CHAR_getWorkInt( toindex, CHAR_WORKBATTLESIDE)].flg + & BSIDE_FLG_HELP_OK)){ + continue; + } + CONNECT_setBattlecharaindex( fd, cnt, toindex ); + cnt++; + if( cnt == CONNECT_WINDOWBUFSIZE ) break; + } + if( cnt == 0 ) { + if( pfound == FALSE ) { + CHAR_talkToCli( charaindex, -1, "那里没有任何人。", + CHAR_COLORYELLOW); + } + lssproto_EN_send( fd, FALSE, 0 ); + }else if( cnt == 1 ) { + if( BATTLE_RescueEntry( charaindex, + CONNECT_getBattlecharaindex(fd,0) ) ){ + CHAR_talkToCli( charaindex, -1, "无法参战。", CHAR_COLORYELLOW); + }else { + result = TRUE; + } + }else if( cnt > 1 ) { + int strlength; + char msgbuf[1024]; + char escapebuf[2048]; + strcpy( msgbuf, "1\n加入谁的战斗呢?\n"); + strlength = strlen( msgbuf); + for( i = 0; + CONNECT_getBattlecharaindex( fd,i ) != -1 + && i< CONNECT_WINDOWBUFSIZE; i ++ ){ + char *a = CHAR_getChar( CONNECT_getBattlecharaindex(fd,i), CHAR_NAME); + char buf[256]; + snprintf( buf, sizeof( buf),"%s\n", a); + if( strlength + strlen( buf) > arraysizeof( msgbuf)){ + print( "\nerr:%s:%d 视窗的讯息缓冲不足\n", + __FILE__,__LINE__); + break; + } + strcpy( &msgbuf[strlength], buf); + strlength += strlen(buf); + } + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_SELECTBATTLE, + -1, + makeEscapeString( msgbuf, escapebuf, sizeof(escapebuf))); + + } + + return result; +} + + + + +BOOL BATTLE_RescueParentTry( int charaindex, int pindex) +{ + int result = FALSE; + if( CHAR_getFlg( charaindex, CHAR_ISDIE)) return FALSE; + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYINDEX1) != pindex ) return FALSE; + if( CHAR_getWorkInt( pindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE ){ + return FALSE; + } + if( BATTLE_RescueEntry( charaindex, pindex ) ){ + result = FALSE; + }else{ + result = TRUE; + } + if( result == FALSE ) { + CHAR_talkToCli( charaindex, -1, "无法参战。", CHAR_COLORYELLOW); + } + return result; +} + +int BATTLE_PartyNewEntry( + int charaindex, + int battleindex, + int side +) +{ + int iRet = 0, i, work; +#if 1 + + iRet = BATTLE_NewEntry( charaindex, battleindex, side ); + if( iRet )return iRet; + CAflush( charaindex ); + CDflush( charaindex ); + iRet = BATTLE_PetDefaultEntry( charaindex, battleindex, side ); + if( iRet )return iRet; + BATTLE_ClearGetExp( charaindex ); +#endif + + for( i = 1; i < CHAR_PARTYMAX; i ++ ){ + work = CHAR_getWorkInt( charaindex, i + CHAR_WORKPARTYINDEX1 ); + if( CHAR_CHECKINDEX( work ) == FALSE )continue; + if( CHAR_getWorkInt( work, CHAR_WORKBATTLEMODE ) != 0 ){ + continue; + } + iRet = BATTLE_NewEntry( work, battleindex, side ); + if( iRet )break; + CAflush( work ); + CDflush( work ); + iRet = BATTLE_PetDefaultEntry( work, battleindex, side ); + if( iRet )return iRet; + BATTLE_ClearGetExp( work ); + } + return iRet; +} + + + + + + + + + + + + + + +#if 1 + +int BATTLE_WatchNewEntry( + int charaindex, + int battleindex, + int side +) +{ + BATTLE_ENTRY *pEntry; + BATTLE *pBattle; + int iEntryFirst = 0, iEntryMax = BATTLE_ENTRY_MAX, i; + + if( BATTLE_CHECKSIDE( side ) == FALSE )return BATTLE_ERR_PARAM; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return BATTLE_ERR_CHARAINDEX; + + pBattle = &BattleArray[battleindex]; + + if( pBattle->use == FALSE )return BATTLE_ERR_NOUSE; + + if( side < 0 || side > 1 ){ + return BATTLE_ERR_PARAM; + } + + switch( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) ){ + + + case CHAR_TYPEPLAYER: + if( pBattle->Side[side].type != BATTLE_S_TYPE_PLAYER ){ + return BATTLE_ERR_TYPE; + } + iEntryFirst = 0; + iEntryMax = BATTLE_PLAYER_MAX; + break; + default: + print( "不明(%s)(%d)\n", + CHAR_getUseName( charaindex ), + CHAR_getInt( charaindex, CHAR_WHICHTYPE ) ); + return BATTLE_ERR_TYPE; + } + + + pEntry = pBattle->Side[side].Entry; + + for( i = iEntryFirst; i < iEntryMax; i ++ ){ + if( pEntry[i].charaindex == -1 )break; + } + + if( i == iEntryMax ){ + return BATTLE_ERR_ENTRYMAX; + } + + EntryInit( &pEntry[i] ); + + pEntry[i].charaindex = charaindex; + + pEntry[i].bid = i + side * SIDE_OFFSET; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEINDEX, + battleindex ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, + BATTLE_CHARMODE_WATCHINIT ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLESIDE, side ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEFLG, 0 ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, -1 ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, -1 ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM3, -1 ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEWATCH, 1 ); + + return 0; +} + + +int BATTLE_WatchPartyNewEntry( + int charaindex, + int battleindex, + int side +) +{ + int iRet = 0, i, work; +#if 1 + + iRet = BATTLE_WatchNewEntry( charaindex, battleindex, side ); + if( iRet )return iRet; + + CAflush( charaindex ); + + CDflush( charaindex ); + +#endif + + for( i = 1; i < CHAR_PARTYMAX; i ++ ){ + + work = CHAR_getWorkInt( charaindex, i + CHAR_WORKPARTYINDEX1 ); + if( CHAR_CHECKINDEX( work ) == FALSE )continue; + + if( CHAR_getWorkInt( work, CHAR_WORKBATTLEMODE ) != 0 ){ + continue; + } + + iRet = BATTLE_WatchNewEntry( work, battleindex, side ); + + if( iRet )break; + + CAflush( work ); + CDflush( work ); + } + return iRet; + +} + + + + +int BATTLE_CreateForWatcher( int charaindex, int topbattleindex ); + +int BATTLE_WatchEntry( + int charaindex, + int toindex + ) +{ + int iRet = 0, battleindex, fd; + char szBuffer[256]=""; + + battleindex = CHAR_getWorkInt( toindex, CHAR_WORKBATTLEINDEX ); + + if( CHAR_getWorkInt( toindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_FINAL + || CHAR_getWorkInt( toindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE + || CHAR_getWorkInt( toindex, CHAR_WORKBATTLEINDEX ) == -1 + ){ + iRet = 1; + } + + if( iRet == 0 ){ + iRet = BATTLE_CreateForWatcher( charaindex, battleindex ); + } + if( iRet == 0 ){ + //snprintf( szBuffer, sizeof( szBuffer ), "(%s)开始观战。", + // CHAR_getUseName( charaindex ) ); + + //BATTLE_BroadCast( battleindex, szBuffer, CHAR_COLORYELLOW ); + if( ( fd = getfdFromCharaIndex(charaindex) ) != -1 ){ + lssproto_EN_send( fd, BattleArray[battleindex].type, BattleArray[battleindex].field_no ); + } + + sprintf( szBuffer, "BP|%X|%X|%X", + 20, BP_FLG_JOIN, CHAR_getInt(charaindex, CHAR_MP ) ); + BATTLE_CommandSend( charaindex, szBuffer ); + + }else{ + snprintf( szBuffer, sizeof( szBuffer ), "无法观战。" ); + CHAR_talkToCli( charaindex, -1, szBuffer, CHAR_COLORYELLOW); + + if( ( fd = getfdFromCharaIndex(charaindex) ) != -1 ){ + lssproto_EN_send( fd, FALSE, 0 ); + } + } + + return iRet; +} + + + +BOOL BATTLE_WatchTry( int charaindex ) +{ + int x,y; + OBJECT object; + int pfound = FALSE; + int result = FALSE; + int fd; + int i; + int cnt; + + + fd = getfdFromCharaIndex( charaindex); + if( fd == -1 )return FALSE; + + for( i = 0; i < CONNECT_WINDOWBUFSIZE ; i ++ ) { + CONNECT_setBattlecharaindex( fd,i,-1); + } + /* 及蟆及甄 毛 月 */ + CHAR_getCoordinationDir( CHAR_getInt( charaindex, CHAR_DIR ) , + CHAR_getInt( charaindex , CHAR_X ), + CHAR_getInt( charaindex , CHAR_Y ) , + 1 , &x , &y ); + + cnt = 0; + /*愤坌及 及蟆及平乓仿毛潸 允月 */ + for( object = MAP_getTopObj( CHAR_getInt( charaindex, CHAR_FLOOR),x,y) ; + object ; + object = NEXT_OBJECT(object ) ) + { + int toindex; + int objindex = GET_OBJINDEX(object); + /* 平乓仿弁正□元扎卅中 */ + if( OBJECT_getType( objindex) != OBJTYPE_CHARA) continue; + toindex = OBJECT_getIndex( objindex); + /* 皿伊奶乩□元扎卅中 */ + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ) continue; + pfound = TRUE; + /* 爵 匹卅中卅日戚尺 */ + if( CHAR_getWorkInt( toindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE ){ + continue; + } + + CONNECT_setBattlecharaindex( fd,cnt, toindex ); + cnt++; + if( cnt == CONNECT_WINDOWBUFSIZE ) break; + } + if( cnt == 0 ) { + if( pfound == FALSE ) { + CHAR_talkToCli( charaindex, -1, "那里没有任何人。", + CHAR_COLORYELLOW); + } + // 分木手中卅仁化棋爵撩 + lssproto_EN_send( fd, FALSE, 0 ); + } + /* ㄠ谛仄井中卅中桦宁反巨件玄伉□今六月 */ + else if( cnt == 1 ) { + if( BATTLE_WatchEntry( charaindex,CONNECT_getBattlecharaindex(fd,0)) ) + { + result = FALSE; + } else { + result = TRUE; + } + } + /* 醒谛中凶日它奴件玉它毛请仄化 中宁歹六月 */ + else if( cnt > 1 ) { + int strlength; + char msgbuf[1024]; + char escapebuf[2048]; + strcpy( msgbuf, "1\n观看谁的战斗呢?\n"); + strlength = strlen( msgbuf); + /* 它奴件玉它及丢永本□斥综岳[ + * 爵 及平乓仿及域 + */ + for( i = 0; + CONNECT_getBattlecharaindex( fd,i ) != -1 + && i< CONNECT_WINDOWBUFSIZE; + i ++ ) + { + char *a = CHAR_getChar( CONNECT_getBattlecharaindex(fd,i), + CHAR_NAME); + char buf[256]; + snprintf( buf, sizeof( buf),"%s\n", a); + if( strlength + strlen( buf) > arraysizeof( msgbuf)){ + print( "\nerr:%s:%d 视窗的讯息缓冲不足\n", + __FILE__,__LINE__); + break; + } + strcpy( &msgbuf[strlength], buf); + strlength += strlen(buf); + } + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_SELECTBATTLEWATCH, + -1, + makeEscapeString( msgbuf, escapebuf, sizeof(escapebuf))); + } + + return result; +} + + +#endif + + + + + + + +#define MAX_DOUJYOUENEMY 64 +static int DoujyouEnemyTbl[10]; // ㄠㄟ手中日氏仃升 +/*************************************************************** + * 桦乒□玉迕卞衬平乓仿潸 + ***************************************************************/ +int *Doujyou_GetEnemy( int meindex, int charaindex ) +{ + int i; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024]; + int ret; + int insert; + int WorkEnemyTbl[MAX_DOUJYOUENEMY]; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + /* 赓渝祭 */ + for( i = 0; i < arraysizeof(WorkEnemyTbl); i ++ ) { + WorkEnemyTbl[i] = -1; + } + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "enemyno", buf, sizeof( buf)) + == NULL ) + { + return NULL; + } + + insert = 0; + /* 娄醒卞踏中化丐月衬毛巨件玄伉□今六月 */ + for( i = 0; i < MAX_DOUJYOUENEMY; i ++ ) { + int curEnemy; + char data[128]; + + ret = getStringFromIndexWithDelim( buf,",", i + 1,data, sizeof(data)); + if( ret == FALSE) { + break; + } + + curEnemy = ENEMY_getEnemyArrayFromId( atoi( data)); + if( !ENEMY_CHECKINDEX( curEnemy) ) continue; + WorkEnemyTbl[insert] = curEnemy; + insert ++; + } + // 分木手中卅井匀凶日巨仿□ + if( insert <= 0 )return NULL; + + // ㄠ 仿件母丞涩烂 + DoujyouEnemyTbl[0] = WorkEnemyTbl[RAND( 0, insert-1 )]; + + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "enemypetno", buf, sizeof( buf)) + == NULL ) + { + // 中卅井匀凶日窒手踏井卅中 + DoujyouEnemyTbl[1] = -1; + }else{ + insert = 0; + /* 娄醒卞踏中化丐月衬毛巨件玄伉□今六月 */ + for( i = 0; i < MAX_DOUJYOUENEMY; i ++ ) { + int curEnemy; + char data[128]; + + ret = getStringFromIndexWithDelim( buf,",", i + 1,data, sizeof(data)); + if( ret == FALSE) { + break; + } + + curEnemy = ENEMY_getEnemyArrayFromId( atoi( data)); + if( !ENEMY_CHECKINDEX( curEnemy) ) continue; + WorkEnemyTbl[insert] = curEnemy; + insert ++; + } + // ㄡ 仿件母丞涩烂 + DoujyouEnemyTbl[1] = WorkEnemyTbl[RAND( 0, insert-1 )]; + } + + // ㄢ 仄 + DoujyouEnemyTbl[2] = -1; + + return DoujyouEnemyTbl; +} + + + +static int DoujyouWeponTbl[] = { + -1, + ITEM_FIST, + ITEM_AXE, + ITEM_CLUB, + ITEM_SPEAR, + ITEM_BOW, + ITEM_BOOMERANG, + ITEM_BOUNDTHROW, + ITEM_BREAKTHROW, +}; +int DoujyouRandomWeponSet( int charaindex ){ + int wepon = -1, itemindex; + int work = RAND( 0, arraysizeof( DoujyouWeponTbl ) - 1 ); + switch( DoujyouWeponTbl[work] ){ + case ITEM_AXE: wepon = 0;break; + case ITEM_CLUB: wepon = 100;break; + case ITEM_SPEAR: wepon = 200;break; + case ITEM_BOW: wepon = 2498;break; + case ITEM_BOOMERANG:wepon = 500;break; + case ITEM_BOUNDTHROW:wepon = 600;break; + case ITEM_BREAKTHROW:wepon = 700;break; + } + itemindex = CHAR_getItemIndex( charaindex, CHAR_ARM ); + if( ITEM_CHECKINDEX( itemindex ) == TRUE ){ + ITEM_endExistItemsOne( itemindex ); + } + + if( wepon >= 0 ){ + itemindex = ITEM_makeItemAndRegist( wepon ) ; + CHAR_setItemIndex( charaindex, CHAR_ARM, itemindex ); + ITEM_setWorkInt( itemindex, ITEM_WORKCHARAINDEX, charaindex ); + ITEM_setWorkInt( itemindex, ITEM_WORKOBJINDEX, -1 ); + } + switch( DoujyouWeponTbl[work] ){ + case -1: + case ITEM_AXE: + case ITEM_CLUB: + case ITEM_SPEAR: + return 0; + } + return 1; + +} + +static int BattleERSkill1[]={ +3, 10, 11, 12, 30, 31, 40, 41, 50, 51, 52, 60, 61, 80, 90, 110, 120, 150, 210, +303, 309, 315, 321, 503, 504, 506, 507, 541, 542, 543, 544, 545, 546, 547, 575, 579, 580, +606, 613, 615 }; + +static int BattleERSkill2[]={ +12, 13, 20, 41, 52, 152, 210, 306, 312, 318, 324, 325, 500, 501, 502, 505, +508, 541, 542, 543, 544, 545, 546, 547, 576, 580, 594, 606, 613, 616 }; + +void BATTLE_EnemyRandowSetSkill( int enemyindex, int skillType) +{ + int i; + switch( skillType){ + case 1: + for( i=0; i<7; i++){ + int skillarray, skillID, Ri; + Ri = RAND( 0, arraysizeof( BattleERSkill1) - 1 ); + skillID = BattleERSkill1[Ri]; + skillarray = PETSKILL_getPetskillArray( skillID); + if( PETSKILL_CHECKINDEX( skillarray) == FALSE ){ + CHAR_setPetSkill( enemyindex, i, 1); + //andy_log + print("ANDY EnemyRandowSetSkill( ) skillID:%d array:%d err \n", + skillID, skillarray ); + continue; + } + CHAR_setPetSkill( enemyindex, i, skillID); + } + break; + case 2: + for( i=0; i<7; i++){ + int skillarray, skillID, Ri; + Ri = RAND( 0, arraysizeof( BattleERSkill2) - 1 ); + skillID = BattleERSkill2[Ri]; + skillarray = PETSKILL_getPetskillArray( skillID); + if( PETSKILL_CHECKINDEX( skillarray) == FALSE ){ + CHAR_setPetSkill( enemyindex, i, 1); + //andy_log + print("ANDY *EnemyRandowSetSkill( ) skillID:%d array:%d err \n", + skillID, skillarray ); + continue; + } + CHAR_setPetSkill( enemyindex, i, skillID); + } + break; + default : return; + break; + } + +} + +int BATTLE_CreateVsEnemy( int charaindex, int mode, int npcindex ) +{ + int battleindex, iRet = 0, enemyindex, i, pindex; + int *enemytable = NULL, fd, field_no, baselevel = 0; + int skillType=0; + int EnemyList[20]; + + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return BATTLE_ERR_CHARAINDEX; + +#ifdef _STREET_VENDOR + // 摆摊中不可进入战斗 + if( CHAR_getWorkInt(charaindex,CHAR_WORKSTREETVENDOR) > -1) return BATTLE_ERR_END; +#endif + +#ifdef _ANGEL_SUMMON // 装备使者信物不遇敌 + if( CHAR_getWorkInt(charaindex,CHAR_WORKANGELMODE) == TRUE ) return BATTLE_ERR_END; +#endif + + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ){ + CHAR_talkToCli( charaindex, -1, "二重遭遇。", CHAR_COLORYELLOW ); + return BATTLE_ERR_ALREADYBATTLE; + } + battleindex = BATTLE_CreateBattle( ); + if( battleindex < 0 )return BATTLE_ERR_NOTASK; + + if( CHAR_CHECKINDEX( npcindex) ){ + skillType = CHAR_getWorkInt( npcindex, CHAR_NPCWORKINT11); + } + + field_no = BATTLE_getBattleFieldNo( + CHAR_getInt( charaindex, CHAR_FLOOR ) , + CHAR_getInt( charaindex, CHAR_X ) , + CHAR_getInt( charaindex, CHAR_Y ) ); + if( field_no > BATTLE_MAP_MAX || field_no < 0 ){ + field_no = RAND( 0, BATTLE_MAP_MAX ); + } + + BattleArray[battleindex].Side[0].type = BATTLE_S_TYPE_PLAYER; + BattleArray[battleindex].Side[1].type = BATTLE_S_TYPE_ENEMY; + BattleArray[battleindex].leaderindex = charaindex; + BattleArray[battleindex].type = BATTLE_TYPE_P_vs_E; + BattleArray[battleindex].createindex = npcindex; + BattleArray[battleindex].field_no = field_no; + //andy_edit 2002/10/23 + /* + if( (iRet = BATTLE_PartyNewEntry( charaindex, battleindex, 0 ) ) ){ + goto BATTLE_CreateVsEnemy_End; + } + */ + BattleArray[battleindex].Side[0].flg &= ~BSIDE_FLG_HELP_OK; + if( mode == 0 ) { + enemytable = ENEMY_getEnemy( charaindex, + CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y)); + }else if( mode == 1 ) { + enemytable = NPC_Util_getEnemy( npcindex, charaindex); + }else if( mode == 2 ) { + enemytable = Doujyou_GetEnemy( npcindex, charaindex ); + baselevel = CHAR_getInt( npcindex, CHAR_LV ); + BattleArray[battleindex].norisk = 1; + } + if( enemytable == NULL ) { + iRet = BATTLE_ERR_NOENEMY; + goto BATTLE_CreateVsEnemy_End; + } + + for( i = 0; *(enemytable+i)!= -1 && i < arraysizeof( EnemyList )-1; i ++ ){ + EnemyList[i] = *(enemytable+i); + } + EnemyList[i] = -1; + +#ifdef _BATTLE_TIMESPEED + fd = getfdFromCharaIndex( charaindex ); + BattleArray[battleindex].CreateTime = time(NULL); + BattleArray[battleindex].flgTime = 200; // 1/100 sec +#endif + +#ifdef _ACTION_BULLSCR +#ifndef _BULL_CUTBULLSCR + BattleArray[battleindex].enemynum=0; +#endif +#endif + for( i = 0; EnemyList[i] != -1; i ++ ){ + int work; + enemyindex = ENEMY_createEnemy( EnemyList[i], baselevel ); +#ifdef _ACTION_BULLSCR +#ifndef _BULL_CUTBULLSCR + BattleArray[battleindex].enemynum++; +#endif +#endif + if( skillType > 0 ){ + //int ENEMY_RandomChange( int enemyindex, int tempno ){ + BATTLE_EnemyRandowSetSkill( enemyindex, skillType); + } + if( enemyindex < 0 ){ + iRet = BATTLE_ERR_NOENEMY; + goto BATTLE_CreateVsEnemy_End; + } + + if( mode == 2 ){ + if( i == 0 ){ + CHAR_setInt( enemyindex, CHAR_BASEBASEIMAGENUMBER, + CHAR_getInt( npcindex, CHAR_BASEBASEIMAGENUMBER ) ); + CHAR_setInt( enemyindex, CHAR_BASEIMAGENUMBER, + CHAR_getInt( npcindex, CHAR_BASEBASEIMAGENUMBER ) ); + CHAR_setChar( enemyindex, CHAR_NAME, + CHAR_getChar( npcindex, CHAR_NAME ) ); + CHAR_complianceParameter( enemyindex ); + } + } + if( ( iRet = BATTLE_NewEntry( enemyindex, battleindex, 1 ) ) ){ + goto BATTLE_CreateVsEnemy_End; + } + if( CHAR_getInt( enemyindex, CHAR_DUELPOINT ) > 0 ){ + BattleArray[battleindex].dpbattle = 1; + } + work = CHAR_getInt( enemyindex, CHAR_BASEBASEIMAGENUMBER ); + if( 100466 <= work && work <= 100471 ){ + CHAR_setWorkInt( enemyindex, CHAR_WORKBATTLEFLG, + CHAR_getWorkInt( enemyindex, CHAR_WORKBATTLEFLG ) | CHAR_BATTLEFLG_ABIO ); + print( "(%s)无生物\n", CHAR_getUseName( enemyindex ) ); + } + } + //andy_edit 2002/10/23 + if( (iRet = BATTLE_PartyNewEntry( charaindex, battleindex, 0 ) ) ){ + goto BATTLE_CreateVsEnemy_End; + } + { + BATTLE_ENTRY *pEntry, EntryWork; + pEntry = BattleArray[battleindex].Side[1].Entry; + for( i = 0; i < 5; i ++ ){ + EntryWork = pEntry[i]; + pEntry[i] = pEntry[i+5]; + pEntry[i+5] = EntryWork; + pEntry[i].bid = i + SIDE_OFFSET; + pEntry[i+5].bid = i + 5 + SIDE_OFFSET; + } + } + +BATTLE_CreateVsEnemy_End:; + fd = getfdFromCharaIndex( charaindex); + + if( iRet ){ + BATTLE_ExitAll( battleindex ); + BATTLE_DeleteBattle( battleindex ); + if( fd != -1 )lssproto_EN_send( fd, FALSE, field_no ); + }else{ + if( fd != -1 ){ + if( BattleArray[battleindex].dpbattle ){ + lssproto_EN_send( fd, BATTLE_TYPE_DP_BATTLE, field_no ); + }else{ + if( mode == 1 ){ + lssproto_EN_send( fd, BATTLE_TYPE_BOSS_BATTLE, field_no ); + }else{ + lssproto_EN_send( fd, BattleArray[battleindex].type, field_no ); + } + } + }else { + BATTLE_ExitAll( battleindex ); + BATTLE_DeleteBattle( battleindex ); + return iRet; + } + + for( i = 1; i < CHAR_PARTYMAX; i ++ ){ + pindex = CHAR_getWorkInt( charaindex, i + CHAR_WORKPARTYINDEX1 ); + if( CHAR_CHECKINDEX( pindex ) == FALSE )continue; + if( CHAR_getWorkInt( pindex, CHAR_WORKBATTLEMODE ) == + BATTLE_CHARMODE_FINAL ) continue; + fd = getfdFromCharaIndex(pindex); + if( fd != -1 ){ + if( mode == 1 ){ + lssproto_EN_send( fd, BATTLE_TYPE_BOSS_BATTLE, field_no ); + }else{ + lssproto_EN_send( fd, BattleArray[battleindex].type, field_no ); + } + } + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKACTION) != -1 ) { + CHAR_sendWatchEvent( + CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), + CHAR_ACTSTAND, + NULL, 0, FALSE); + CHAR_setWorkInt( charaindex, CHAR_WORKACTION, -1); + } + CHAR_sendBattleEffect( charaindex, ON); + for( i = 1; i < CHAR_PARTYMAX; i ++ ){ + pindex = CHAR_getWorkInt( charaindex, i + CHAR_WORKPARTYINDEX1 ); + if( CHAR_CHECKINDEX( pindex ) == FALSE )continue; + if( CHAR_getWorkInt( pindex, CHAR_WORKACTION) != -1 ) { + CHAR_sendWatchEvent( + CHAR_getWorkInt( pindex, CHAR_WORKOBJINDEX), + CHAR_ACTSTAND, + NULL, 0, FALSE); + CHAR_setWorkInt( pindex, CHAR_WORKACTION, -1); + } + CHAR_sendBattleEffect( pindex, ON); + } + } + return iRet; +} + +int BATTLE_CreateVsPlayer( int charaindex0, int charaindex1 ) +{ + int battleindex, pindex, field_no, + i, j, charaindex[2], + parent[2], fd, + iRet = 0; + + if( CHAR_CHECKINDEX( charaindex0 ) == FALSE )return BATTLE_ERR_CHARAINDEX; + if( CHAR_CHECKINDEX( charaindex1 ) == FALSE )return BATTLE_ERR_CHARAINDEX; + + if( CHAR_getWorkInt( charaindex0, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ){ + CHAR_talkToCli( charaindex0, -1, "二重遭遇。", CHAR_COLORYELLOW ); + CHAR_talkToCli( charaindex1, -1, "二重遭遇。", CHAR_COLORYELLOW ); + return BATTLE_ERR_ALREADYBATTLE; + } + if( CHAR_getWorkInt( charaindex1, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ){ + CHAR_talkToCli( charaindex0, -1, "二重遭遇。", CHAR_COLORYELLOW ); + CHAR_talkToCli( charaindex1, -1, "二重遭遇。", CHAR_COLORYELLOW ); + return BATTLE_ERR_ALREADYBATTLE; + } +#ifdef _DEATH_CONTEND + if( CHAR_getInt( charaindex0, CHAR_FLOOR) == 8250 || + CHAR_getInt( charaindex0, CHAR_PKLISTLEADER) != 1 || + CHAR_getInt( charaindex0, CHAR_PKLISTTEAMNUM) == -1 || +// CHAR_getWorkInt( charaindex0, CHAR_WORKPARTYMODE ) != CHAR_PARTY_LEADER || + CHAR_getInt( charaindex1, CHAR_PKLISTLEADER) != 1 || + CHAR_getInt( charaindex1, CHAR_PKLISTTEAMNUM) == -1 //|| +// CHAR_getWorkInt( charaindex1, CHAR_WORKPARTYMODE ) != CHAR_PARTY_LEADER + + ){ + + + CHAR_talkToCli( charaindex0, -1, "无效战斗。", CHAR_COLORYELLOW ); + CHAR_talkToCli( charaindex1, -1, "无效战斗。", CHAR_COLORYELLOW ); + return BATTLE_ERR_ALREADYBATTLE; + } +/* + + if( PKLIST_CheckPKReapetTeam( + CHAR_getInt( charaindex0, CHAR_PKLISTTEAMNUM), + CHAR_getInt( charaindex1, CHAR_PKLISTTEAMNUM) ) == FALSE ){ + CHAR_talkToCli( charaindex0, -1, "重复战斗。", CHAR_COLORYELLOW ); + CHAR_talkToCli( charaindex1, -1, "重复战斗。", CHAR_COLORYELLOW ); + return BATTLE_ERR_ALREADYBATTLE; + } +*/ +#endif + + field_no = BATTLE_getBattleFieldNo( + CHAR_getInt( charaindex0, CHAR_FLOOR ) , + CHAR_getInt( charaindex0, CHAR_X ), + CHAR_getInt( charaindex0, CHAR_Y ) ); + + charaindex[0] = charaindex0; + charaindex[1] = charaindex1; + for( j = 0; j < 2; j ++ ){ + if( CHAR_getWorkInt( charaindex[j], CHAR_WORKBATTLEMODE ) != 0 ){ + return BATTLE_ERR_ALREADYBATTLE; + } + } + for( j = 0; j < 2; j ++ ){ + if( CHAR_getWorkInt( charaindex[j], CHAR_WORKPARTYMODE ) == CHAR_PARTY_LEADER ){ + parent[j] = charaindex[j]; + }else + if( CHAR_getWorkInt( charaindex[j], CHAR_WORKPARTYMODE ) == CHAR_PARTY_CLIENT ){ + parent[j] = CHAR_getWorkInt( charaindex[j], CHAR_WORKPARTYINDEX1 ); + }else{ + parent[j] = -1; + } + } + if( parent[0] != -1 && parent[0] == parent[1] ){ + return BATTLE_ERR_SAMEPARTY; + } + battleindex = BATTLE_CreateBattle( ); + if( battleindex < 0 )return BATTLE_ERR_NOTASK; + + BattleArray[battleindex].Side[0].type = BATTLE_S_TYPE_PLAYER; + BattleArray[battleindex].Side[1].type = BATTLE_S_TYPE_PLAYER; + BattleArray[battleindex].leaderindex = charaindex0; + BattleArray[battleindex].type = BATTLE_TYPE_P_vs_P; + BattleArray[battleindex].dpbattle = 1; + BattleArray[battleindex].field_no = field_no; +#ifdef _BATTLE_TIMESPEED + BattleArray[battleindex].CreateTime = time(NULL); +#endif + +#ifdef _DEATH_CONTEND//计算胜败func + BattleArray[battleindex].PkFunc = NPC_PKLIST_Finish_Exit; + //winside = 0 + BattleArray[battleindex].menum = CHAR_getInt( charaindex0, CHAR_PKLISTTEAMNUM); + BattleArray[battleindex].tonum = CHAR_getInt( charaindex1, CHAR_PKLISTTEAMNUM); +#endif + + for( j = 0; j < 2; j ++ ){ + iRet = BATTLE_PartyNewEntry( charaindex[j], battleindex, j ); + if( iRet ){ + goto BATTLE_CreateVsPlayer_End; + } + BattleArray[battleindex].Side[j].flg &= ~BSIDE_FLG_HELP_OK; + } +BATTLE_CreateVsPlayer_End:; + if( iRet ){ + BATTLE_ExitAll( battleindex ); + BATTLE_DeleteBattle( battleindex ); + fd = getfdFromCharaIndex(charaindex[0]); + if( fd != -1 )lssproto_EN_send( fd, FALSE, field_no ); + }else{ + for( j = 0; j < 2; j ++ ){ + fd = getfdFromCharaIndex(charaindex[j]); + if( fd != -1 )lssproto_EN_send( fd, BattleArray[battleindex].type, field_no ); + if( CHAR_getWorkInt( charaindex[j], CHAR_WORKACTION) != -1 ) { + CHAR_sendWatchEvent( + CHAR_getWorkInt( charaindex[j], CHAR_WORKOBJINDEX), + CHAR_ACTSTAND, + NULL, 0, FALSE); + CHAR_setWorkInt( charaindex[j], CHAR_WORKACTION, -1); + + } + CHAR_sendBattleEffect( charaindex[j], ON); + for( i = 1; i < CHAR_PARTYMAX; i ++ ){ + pindex = CHAR_getWorkInt( charaindex[j], i + CHAR_WORKPARTYINDEX1 ); + if( CHAR_CHECKINDEX( pindex ) == FALSE )continue; + if( CHAR_getWorkInt( pindex, CHAR_WORKBATTLEMODE ) == + BATTLE_CHARMODE_FINAL ) continue; + + fd = getfdFromCharaIndex(pindex); + if( fd != -1 )lssproto_EN_send( fd, BattleArray[battleindex].type, field_no ); + if( CHAR_getWorkInt( pindex, CHAR_WORKACTION) != -1 ) { + CHAR_sendWatchEvent( + CHAR_getWorkInt( pindex, CHAR_WORKOBJINDEX), + CHAR_ACTSTAND, + NULL, 0, FALSE); + CHAR_setWorkInt( pindex, CHAR_WORKACTION, -1); + + } + CHAR_sendBattleEffect( pindex, ON ); + } + } + } + return iRet; +} + + +//********************************************************* +// +// 棋爵迕田玄伙正旦弁毛馨笛[玄永皿及戚卞涩烂允月 +// +int BATTLE_WatchLink( int topbattleindex, int battleindex ) +// +// +//********************************************************* +{ + BATTLE *pWork, *pTop; + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE ){ + fprint( "err:battle index 奇怪(%d)\n", battleindex ); + return FALSE; + } + if( BATTLE_CHECKINDEX( topbattleindex ) == FALSE ){ + fprint( "err:battle index 奇怪(%d)\n", topbattleindex ); + return FALSE; + } + + pTop = &BattleArray[topbattleindex]; + + if( BATTLE_CHECKADDRESS( pTop ) == FALSE ){ + fprint( "err:battle address 奇怪(%p)\n", pTop ); + return FALSE; + } + + + pWork = pTop->pNext; // 田永弁失永皿 + + if( pWork ){ + if( BATTLE_CHECKADDRESS( pWork ) == FALSE ){ + fprint( "err:battle address 奇怪(%p)\n", pWork ); + return FALSE; + } + } + + // 愤坌毛蟆及戚卞允月 + pTop->pNext = &BattleArray[battleindex]; + // 愤坌及蟆田玄伙毛涩烂 + BattleArray[battleindex].pBefore = pTop; + // 愤坌及戚田玄伙毛涩烂 + BattleArray[battleindex].pNext = pWork; + // 戚及蟆反愤坌 + if( pWork ){ + pWork->pBefore = &BattleArray[battleindex]; + } + return TRUE; +} + +//********************************************************* +// +// 棋爵迕田玄伙正旦弁毛夫午勾 仁 +// +int BATTLE_WatchUnLink( int battleindex ) +// +// +//********************************************************* +{ + BATTLE *pTop; + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE ){ + fprint( "err:battle index 奇怪(%d)\n", battleindex ); + return FALSE; + } + + // 愤坌毛蟆及田玄伙 + pTop = BattleArray[battleindex].pBefore; + + if( pTop ){ + if( BATTLE_CHECKADDRESS( pTop ) == FALSE ){ + fprint( "err:battle address 奇怪(%p)\n", pTop ); + }else{ + // 勾卅亢卅云仄 + pTop->pNext = BattleArray[battleindex].pNext; + } + } + if( BattleArray[battleindex].pNext ){ + if( BATTLE_CHECKADDRESS( BattleArray[battleindex].pNext ) == FALSE ){ + fprint( "err:battle address 奇怪(%p)\n", BattleArray[battleindex].pNext ); + }else{ + BattleArray[battleindex].pNext->pBefore = pTop; + } + } + // 愤坌及蟆田玄伙毛涩烂 + BattleArray[battleindex].pBefore = NULL; + // 愤坌及戚田玄伙反 仄 + BattleArray[battleindex].pNext = NULL; + + return TRUE; + +} + + +//********************************************************* +// +// 棋爵迕卞田玄伙正旦弁毛综岳允月 +// +int BATTLE_CreateForWatcher( int charaindex, int topbattleindex ) +// +// 曰袄 BATTLE_ERR +// +//********************************************************* +{ + int battleindex, field_no , pindex, + i, fd, + iRet = 0; + + // 由仿丢□正民尼永弁 + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return BATTLE_ERR_CHARAINDEX; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ){ + CHAR_talkToCli( charaindex, -1, "二重遭遇。", CHAR_COLORYELLOW ); + return BATTLE_ERR_ALREADYBATTLE; + } + + // 允匹卞爵 匹卅中井 + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) != 0 ){ + return BATTLE_ERR_ALREADYBATTLE; + } + + // 爵 正旦弁毛综岳允月 + battleindex = BATTLE_CreateBattle( ); + if( battleindex < 0 )return BATTLE_ERR_NOTASK;// 正旦弁 苇匹五卅井匀凶巨仿□ + + // 仇切日及讽采反皿伊奶乩□讽采匹丐月午烂聒允月[ + BattleArray[battleindex].Side[0].type = BATTLE_S_TYPE_PLAYER; + // 轾仇丹础及讽采手皿伊奶乩□讽采匹丐月午烂聒允月[ + BattleArray[battleindex].Side[1].type = BATTLE_S_TYPE_PLAYER; + // 伉□母□毛忡绣 + BattleArray[battleindex].leaderindex = charaindex; + // 爵 及正奶皿 + BattleArray[battleindex].type = BATTLE_TYPE_WATCH; + BattleArray[battleindex].mode = BATTLE_MODE_WATCHBC; + // 田玄伙白奴□伙玉 寞 + field_no = BattleArray[battleindex].field_no = BattleArray[topbattleindex].field_no; + BattleArray[battleindex].turn = BattleArray[topbattleindex].turn; + + // 伉件弁今六月 + if( BATTLE_WatchLink( topbattleindex, battleindex ) == FALSE ){ + fprint( "err:battle link error(%d),(%d)\n", + topbattleindex, battleindex ); + // 巨仿□质 匹及 GOTO + goto BATTLE_CreateForWatcher_End; + } + + // 由□ 奴仍午巨件玄伉□ + iRet = BATTLE_WatchPartyNewEntry( charaindex, battleindex, 0 ); + if( iRet ){ + // 巨仿□质 匹及 GOTO + goto BATTLE_CreateForWatcher_End; + } + + +// 巨仿□及桦宁反允什卞戊戊卞 月 +BATTLE_CreateForWatcher_End:; + + if( iRet ){ // 巨仿□互丐匀凶日正旦弁 滋 + // 蝈够 仃月 + BATTLE_ExitAll( battleindex ); + //{爵 正旦弁绰轮 + BATTLE_DeleteBattle( battleindex ); + fd = getfdFromCharaIndex( charaindex ); + if( fd != -1 )lssproto_EN_send( fd, FALSE, field_no ); + }else{ + fd = getfdFromCharaIndex( charaindex ); + /* 巨件市它件玄岳 毛项尹月 */ + if( fd != -1 )lssproto_EN_send( fd, BattleArray[battleindex].type, field_no ); + /* 切禾□术霜月 */ + if( CHAR_getWorkInt( charaindex, CHAR_WORKACTION) != -1 ) { + CHAR_sendWatchEvent( + CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), + CHAR_ACTSTAND, + NULL, 0, FALSE); + CHAR_setWorkInt( charaindex, CHAR_WORKACTION, -1); + } + /* 爵 失奶戊件 憎CA霜耨 */ + CHAR_sendBattleWatch( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX ), ON); + + // 醮棉卞手项尹月 + for( i = 1; i < CHAR_PARTYMAX; i ++ ){ + pindex = CHAR_getWorkInt( charaindex, i + CHAR_WORKPARTYINDEX1 ); + if( CHAR_CHECKINDEX( pindex ) == FALSE )continue; + // 切扎氏午巨件市它件玄匹五化卅中卅日霜日卅中 + // FINAL 分匀凶日蟆及爵 苇化中月 + if( CHAR_getWorkInt( pindex, CHAR_WORKBATTLEMODE ) == + BATTLE_CHARMODE_FINAL ) continue; + + fd = getfdFromCharaIndex(pindex); + /* 巨件市它件玄岳 */ + if( fd != -1 )lssproto_EN_send( fd, BattleArray[battleindex].type, field_no ); + /* 切禾□术霜月 */ + if( CHAR_getWorkInt( pindex, CHAR_WORKACTION) != -1 ) { + CHAR_sendWatchEvent( + CHAR_getWorkInt( pindex, CHAR_WORKOBJINDEX), + CHAR_ACTSTAND, + NULL, 0, FALSE); + CHAR_setWorkInt( pindex, CHAR_WORKACTION, -1); + } + /* 爵 失奶戊件 憎CA霜耨 */ + CHAR_sendBattleWatch( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX ), ON); + } +/* + print( "以(%s)为领队与敌军交手。", + CHAR_getChar( charaindex, CHAR_NAME ) ); +*/ + } + + + return iRet; +} + + + + + + +/*------------------------------------------------------------ + * 爵 毛 蝇允月 + ------------------------------------------------------------*/ +void BATTLE_WatchStop( int charaindex ) +{ + int battleindex; + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return; + // 平乓仿弁正互中凶日 仃今六月 + BATTLE_Exit( charaindex, battleindex ); + // 由□ 奴 仃月 + CHAR_DischargePartyNoMsg( charaindex ); + + CHAR_talkToCli( charaindex, -1, + "战斗中止。", CHAR_COLORYELLOW ); + + lssproto_B_send( getfdFromCharaIndex( charaindex ), "BU" ); + +} + + + + + + + + + +//************************************************************* +// +// 正□件备潘热诸匹 蛹仄凶由仿丢□正毛俅孺仄化中仁 +// +void BATTLE_TurnParam( + int charaindex, + int fixkind, + int mod, + int last +) +// +// +//************************************************************* +{ + int modparam, fixparam, lastparam; + + if( fixkind == -1 ){ + fixparam = 0; // 葭互 中桦宁反ㄟ + }else{ + fixparam = CHAR_getWorkInt( charaindex, fixkind ); + } + if( last == -1 ){ + lastparam = 0; + }else{ + lastparam = CHAR_getWorkInt( charaindex, last ); + } + modparam = CHAR_getWorkInt( charaindex, mod ); + // 仇仇匹 ≈ 午 及 毛苇化} + // 及袄毛俅孺仄化中仁 + + // 漆反 MODPARAM 毛ㄡㄟ⊙蛹仄化中仁 + modparam *= 0.8; + CHAR_setWorkInt( charaindex, mod, modparam ); + + // 卞笛尹月 + if( last != -1 ){ + CHAR_setWorkInt( + charaindex, + last, + lastparam + modparam * 0.01 ); + } + +} + +void BATTLE_AttReverse( int charaindex ) +{ + int earth, water, fire, wind; + //ttom start because the second had this + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_REVERSE ){ + // 鳖仄化月卅日戚尺 + }else{ + // 鳖仄化卅中及匹伉正□件 + return; + } + //ttom end + earth = CHAR_getWorkInt( charaindex, CHAR_WORKFIXEARTHAT ); + water = CHAR_getWorkInt( charaindex, CHAR_WORKFIXWATERAT ); + fire = CHAR_getWorkInt( charaindex, CHAR_WORKFIXFIREAT ); + wind = CHAR_getWorkInt( charaindex, CHAR_WORKFIXWINDAT ); + + CHAR_setWorkInt( charaindex, CHAR_WORKFIXEARTHAT, fire ); + CHAR_setWorkInt( charaindex, CHAR_WORKFIXWATERAT, wind ); + CHAR_setWorkInt( charaindex, CHAR_WORKFIXFIREAT, earth ); + CHAR_setWorkInt( charaindex, CHAR_WORKFIXWINDAT, water ); + +} + +void BATTLE_PreCommandSeq( int battleindex ) +{ + BATTLE_ENTRY *pEntry; + BATTLE *pBattle; + int i, j, charaindex; + BATTLE_CharSendAll( battleindex ); + BATTLE_CharaBackUp( battleindex ); + BattleArray[battleindex].timer = NowTime.tv_sec; + BATTLE_AllCharaCWaitSet( battleindex ); + BATTLE_ActSettingSend( battleindex ); + BattleArray[battleindex].flg |= BATTLE_FLG_FREEDP; + pBattle = &BattleArray[battleindex]; + for( j = 0; j < 2; j ++ ){ + int flg; + pEntry = pBattle->Side[j].Entry; + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + pEntry[i].guardian = -1; + charaindex = pEntry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + flg = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEFLG ); +//ttom the second only one //flg &= ~CHAR_BATTLEFLG_GUARDIAN; + flg &= ~CHAR_BATTLEFLG_GUARDIAN; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEFLG, flg ); + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_EARTHROUND0 ) continue; + + CHAR_complianceParameter( charaindex ); + BATTLE_TurnParam( charaindex, + CHAR_WORKFIXSTR, // 猾 + CHAR_WORKMODATTACK, + CHAR_WORKATTACKPOWER + ); + BATTLE_TurnParam( charaindex, + CHAR_WORKFIXTOUGH, // 潮 + CHAR_WORKMODDEFENCE, + CHAR_WORKDEFENCEPOWER + ); + BATTLE_TurnParam( charaindex, + CHAR_WORKFIXDEX, // 豳镀今 + CHAR_WORKMODQUICK, + CHAR_WORKQUICK + ); + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + BATTLE_TurnParam( charaindex, + -1, + CHAR_WORKMODCHARM, // + CHAR_WORKFIXCHARM + ); + } + BATTLE_TurnParam( charaindex, + -1, // 凯 + CHAR_WORKMODCHARM, + -1 + ); + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_REVERSE ){ + BATTLE_AttReverse( charaindex ); + } + } + } +} + + +//************************************************** +// +// 棋爵及桦宁及戊穴件玉谨切尺 月凛及域 及 木 +// +void BATTLE_PreWatchWaitSeq( int battleindex ) +// +// +//************************************************** +{ + // 仇及凛鳔匹凛对忡绣 + BattleArray[battleindex].timer = NowTime.tv_sec; + // 蝈够及乒□玉毛戊穴件玉 蟆卞允月 + BATTLE_AllCharaWatchWaitSet( battleindex ); +} +static int BATTLE_Init( int battleindex ) +{ + BATTLE *pBattle; + int iRet = 0; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + pBattle = &BattleArray[battleindex]; + pBattle->mode = BATTLE_MODE_BATTLE; + iRet = BATTLE_SurpriseCheck( battleindex ); + if( iRet == 0 ){ + }else + if( iRet == 1 ){ + BattleArray[battleindex].Side[1].flg |= BSIDE_FLG_SURPRISE; + }else + if( iRet == 2 ){ + BattleArray[battleindex].Side[0].flg |= BSIDE_FLG_SURPRISE; + } + BATTLE_PreCommandSeq( battleindex ); + return 0; +} +int BATTLE_CountEntry( + int battleindex, + int side +) +{ + int i; + BATTLE_ENTRY *pEntry; + int cnt = 0; + + // 由仿丢□正民尼永弁 + if( BATTLE_CHECKSIDE( side ) == FALSE )return -BATTLE_ERR_PARAM; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return -BATTLE_ERR_BATTLEINDEX; + + // 巨件玄伉□ + pEntry = BattleArray[battleindex].Side[side].Entry; + + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + if( pEntry[i].charaindex != -1 ){ // 平乓仿互中凶日醒尹月 + cnt ++; + } + } + return cnt; +} + +static BOOL BATTLE_CommandWait( int battleindex, int side) +{ + int i, charaindex, BeOk=0; + BATTLE_ENTRY *pEntry; + BOOL iRet = TRUE; + BOOL TimeOut = FALSE; + if( BATTLE_CHECKSIDE( side ) == FALSE )return TRUE;//检查值是否在合法 围 + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return TRUE; + if( BattleArray[battleindex].Side[side].type == BATTLE_S_TYPE_ENEMY ) return TRUE; + pEntry = BattleArray[battleindex].Side[side].Entry; + +#ifdef _BATTLECOMMAND_TIME + if( BattleArray[battleindex].PartTime > 1 && + BattleArray[battleindex].PartTime < time(NULL) ){ + TimeOut = TRUE; + } +#endif + + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pEntry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == TRUE ){ + continue; + } + switch ( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) ){ + case BATTLE_CHARMODE_C_OK: + BeOk++; + case BATTLE_CHARMODE_INIT: + case BATTLE_CHARMODE_RESCUE: + case BATTLE_CHARMODE_WATCHINIT: + break; + case BATTLE_CHARMODE_C_WAIT: + { +#ifdef _BATTLECOMMAND_TIME + if( TimeOut == TRUE ){ + //andy_log + print("ANDY TimeOut Exit:%d-[%s|%s]\n", + charaindex, CHAR_getUseName( charaindex), + CHAR_getChar( charaindex, CHAR_CDKEY) ); + + CHAR_talkToCli( charaindex, -1, "超过时间未下指令,强迫离开战斗!", CHAR_COLORYELLOW); + + CHAR_DischargeParty( charaindex, 0);//解散团队 + CHAR_setWorkInt(charaindex, CHAR_WORKFMPKFLAG, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_COMPELESCAPE ); + BATTLE_Exit( charaindex, battleindex ); + lssproto_B_send( getfdFromCharaIndex( charaindex ), "BU" ); +// CONNECT_setCloseRequest( getfdFromCharaIndex( charaindex) , 1 ); + break; + } +#endif + iRet = FALSE; + } + break; + default : + BATTLE_Exit( charaindex, battleindex ); + break; + } + } + + if( BeOk > 0 ){ +#ifdef _BATTLECOMMAND_TIME + if( BattleArray[ battleindex].PartTime <= 0 ){ + //如果战役中有任一人执行指令, 则延迟时间设为120秒 + BattleArray[battleindex].PartTime = (int)time(NULL) + 120; + } +#endif + } + return iRet; +} + + +#ifdef _ITEM_ADDEXP //vincent 经验提升 +#ifdef _ITEM_ADDEQUIPEXP +int BATTLE_GetExp( int charaindex, int midx ) +#else +int BATTLE_GetExp( int charaindex ) +#endif +{ + int addexp,i; + int modexp=0, getexp=0; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return 0; + + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPET) { + int ownerindex = CHAR_getWorkInt( charaindex, CHAR_WORKPLAYERINDEX); + if( CHAR_CHECKINDEX( ownerindex) && CHAR_getWorkInt( ownerindex, CHAR_WORKITEM_ADDEXP) > 0){ + modexp = CHAR_getWorkInt( ownerindex, CHAR_WORKITEM_ADDEXP); + } + }else if(CHAR_getWorkInt(charaindex,CHAR_WORKITEM_ADDEXP) > 0){ + modexp = CHAR_getWorkInt(charaindex,CHAR_WORKITEM_ADDEXP); + } + + getexp = CHAR_getWorkInt( charaindex, CHAR_WORKGETEXP ); +#ifdef _NEWOPEN_MAXEXP + if( getexp > 1000000000 ) getexp = 1000000000; +#endif + if( getexp < 0 ) getexp = 0; + addexp = getexp+((getexp*modexp)/100); +#ifdef _GET_BATTLE_EXP + addexp*=getBattleexp(); +#endif +#ifdef _ITEM_ADDEQUIPEXP + if( CHAR_CHECKINDEX( midx ) ){ + for( i = 0 ; i < CHAR_EQUIPPLACENUM ; i ++ ){ + int id = CHAR_getItemIndex(midx,i);//道具id + if( ITEM_CHECKINDEX(id) ){ + char *arg,*P; + arg = ITEM_getChar(id, ITEM_ARGUMENT );//道具参数 + if( (P = strstr( arg, "EXPUP" )) ){ + if( (P = strstr( arg, "人" )) ){//只对人有效 + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) + addexp += getexp*atoi(P+=2)*0.01; + } + else if( (P = strstr( arg, "宠" )) ){//只对宠有效 + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPET + && (CHAR_getInt( midx, CHAR_RIDEPET) != charaindex ) ) + addexp += getexp*atoi(P+=2)*0.01; + } + else if( (P = strstr( arg, "骑" )) ){//只对骑宠有效 + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPET + && (CHAR_getInt( midx, CHAR_RIDEPET) == charaindex ) ) + addexp += getexp*atoi(P+=2)*0.01; + } + else{ + P = strstr( arg, "EXPUP" ); + addexp += getexp*atoi(P+=5)*0.01; + } + } + } + } + } +#endif +#ifdef _ITEM_ADDPETEXP + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPET ) + if( CHAR_getInt( charaindex, CHAR_PETID) == 1163 ) + addexp = 0; + +#endif + addexp = (addexp<0)?0:addexp; + if( CHAR_getInt( charaindex, CHAR_LV) >= CHAR_MAXUPLEVEL ) addexp = 0; + CHAR_setWorkInt( charaindex, CHAR_WORKGETEXP, addexp );//回存CHAR_WORKGETEXP + + CHAR_AddMaxExp( charaindex, addexp); + + return addexp; +} +#else + +#ifdef _ITEM_ADDEQUIPEXP +int BATTLE_GetExp( int charaindex, int midx ) +#else +int BATTLE_GetExp( int charaindex ) +#endif +{ + int addexp, nowexp; + + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return 0; + nowexp = CHAR_getInt( charaindex, CHAR_EXP ); + addexp = CHAR_getWorkInt( charaindex, CHAR_WORKGETEXP ); + // shan 11/27 10^9 1224160000 + CHAR_AddMaxExp( charaindex, addexp); + return addexp; +} +#endif + +int BATTLE_DpCalc( int battleindex ) +{ + BATTLE_ENTRY *pLooseEntry, *pWinEntry; + int winside, looseside, i, charaindex, dpadd, dpall, num = 0; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + + winside = BattleArray[battleindex].winside; + looseside = 1 - winside; + if( winside != 0 && winside != 1 )return BATTLE_ERR_PARAM; + + // 宁煌袄赓渝祭 + dpall = 0; + + // 仃凶 井日 毛畴丹 + pLooseEntry = BattleArray[battleindex].Side[looseside].Entry; + for( i = 0 ; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pLooseEntry[i].charaindex; + // 皿伊奶乩□动陆反饬 仄 + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER )continue; + // ㄠㄟ坌及ㄠ手日尹月 + dpadd = CHAR_getInt( charaindex, CHAR_DUELPOINT ) * DUELPOINT_RATE; + // 仃凶 卞反 毛穴奶瓜旦涩烂 + CHAR_setWorkInt( charaindex, CHAR_WORKGETEXP, + CHAR_getWorkInt( charaindex, CHAR_WORKGETEXP) - dpadd ); + // 宁煌袄卞笛遥 + dpall += dpadd; + } + + // 今日卞 仆凶曰仄凶谛迕及 毛笛遥 + dpall += BattleArray[battleindex].Side[winside].common_dp; + + pWinEntry = BattleArray[battleindex].Side[winside].Entry; + for( num = 0,i = 0 ; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pWinEntry[i].charaindex; + // 皿伊奶乩□动陆反饬 仄 + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER )continue; + num++; + } + // 卅兮井 匀凶幻丹卞簿手中卅中 + if( num <= 0 )return BATTLE_ERR_BATTLEINDEX; + dpadd = dpall / num; + if( dpadd <= 0 )dpadd = 1; // 斓匹手ㄠ反芨尹月 + + for( num = 0,i = 0 ; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pWinEntry[i].charaindex; + // 皿伊奶乩□动陆反饬 仄 + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER )continue; + + // 匀凶 卞反 毛涩烂 + CHAR_setWorkInt( charaindex, CHAR_WORKGETEXP, + CHAR_getWorkInt( charaindex, CHAR_WORKGETEXP) + dpadd ); + } + + return 0; +} + +//#define RS_LIST_MAX 4 // 凛卞窒谛爵 瑛绊霜月井 +#define RS_LIST_MAX 5 +typedef struct{ + int num; + int exp; + int levelup; +}RS_LIST; + +int BATTLE_GetDuelPoint( + int battleindex, // 爵 奶件犯永弁旦 + int side, // 扔奶玉 ㄟ ㄠ + int num // 愤坌反 及窒 及平乓仿井 +) +{ + char szBuffer[1024]=""; + int charaindex; + int dpnow, dpadd; + int fd; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + if( BATTLE_CHECKSIDE( side ) == FALSE )return BATTLE_ERR_PARAM; + if( num < 0 || num >= BATTLE_ENTRY_MAX )return BATTLE_ERR_PARAM; + charaindex = BattleArray[battleindex].Side[side].Entry[num].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return BATTLE_ERR_PARAM; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + return 0; + } + if( BattleArray[battleindex].Side[side].type != BATTLE_S_TYPE_PLAYER ){ + return 0; + } + dpadd = CHAR_getWorkInt( charaindex, CHAR_WORKGETEXP ); + if( dpadd == 0 ){ + dpadd = 0; // 仇及桦宁反ㄟ + }else + if( dpadd < 0 ){ + dpadd = min( -1, dpadd ); // 剂卅仁午手ㄠ反手日丹 + }else{ + dpadd = max( 1, dpadd ); // 剂卅仁午手ㄠ反手日丹 + } + dpnow = CHAR_getInt( charaindex, CHAR_DUELPOINT ) + dpadd; + dpnow = max( dpnow, 0 ); + + CHAR_setInt( charaindex, CHAR_DUELPOINT, min( dpnow, CHAR_MAXDUELPOINT ) ); + + szBuffer[0] = 0; + { + char szAdd[64], szNow[64]; + cnv10to62( dpadd, szAdd, sizeof( szAdd ) ); + cnv10to62( dpnow, szNow, sizeof( szNow ) ); + snprintf( szBuffer, sizeof( szBuffer ), + "%s|%s|", szAdd, szNow ); + } + + fd = getfdFromCharaIndex( charaindex ); + lssproto_RD_send( fd, szBuffer ); + + CHAR_send_DpDBUpdate( charaindex ); +#ifndef _NET_REDUCESEND + CHAR_send_DpDBUpdate_AddressBook( charaindex, TRUE ); +#endif + return 0; +} + +int BATTLE_GetExpGold( + int battleindex, // 爵 奶件犯永弁旦 + int side, // 扔奶玉 ㄟ ㄠ + int num // 愤坌反 及窒 及平乓仿井 +) +{ + BATTLE_ENTRY *pEntryChara; + char szBuffer[1024]="", szItemString[512], szEscItemString[256]; + int charaindex, UpLevel, petindex, i, j, itemindex = -1; + int rsCnt = 0; + RS_LIST aRsList[RS_LIST_MAX]; + int itemgroup[CHAR_MAXITEMHAVE-CHAR_STARTITEMARRAY]; + int itemnum = 0; + memset( aRsList, 0, sizeof( aRsList ) ); + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + if( BATTLE_CHECKSIDE( side ) == FALSE )return BATTLE_ERR_PARAM; + if( num < 0 || num >= BATTLE_ENTRY_MAX )return BATTLE_ERR_PARAM; + charaindex = BattleArray[battleindex].Side[side].Entry[num].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return BATTLE_ERR_PARAM; + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == TRUE ){ + return 0; + } + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + return 0; + } + if( BattleArray[battleindex].Side[side].type != BATTLE_S_TYPE_PLAYER ){ + return 0; + } + pEntryChara = &BattleArray[battleindex].Side[side].Entry[num]; + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == FALSE ){ +#ifdef _ITEM_ADDEQUIPEXP + BATTLE_GetExp( charaindex , charaindex ); +#else + BATTLE_GetExp( charaindex ); +#endif + if( getBattleDebugMsg( ) != 0 ){ + snprintf( szBuffer, sizeof(szBuffer), + "(%s) 得到 EXP %d", + CHAR_getUseName( charaindex ), + CHAR_getWorkInt( charaindex, CHAR_WORKGETEXP ) + ); + BATTLE_talkToCli( charaindex, szBuffer, CHAR_COLORYELLOW ); + } + + } + UpLevel = CHAR_LevelUpCheck( charaindex , -1); + if( UpLevel > 0 ){ + aRsList[rsCnt].levelup = 1; + }else{ + aRsList[rsCnt].levelup = 0; + } + aRsList[rsCnt].num = -2; + aRsList[rsCnt].exp = CHAR_getWorkInt( charaindex, CHAR_WORKGETEXP ); + rsCnt ++; + if( UpLevel > 0 ){ + int work; + + if( getBattleDebugMsg( ) != 0 ){ + snprintf( szBuffer, sizeof(szBuffer), + "(%s) 升级至 %d", + CHAR_getUseName( charaindex ), + CHAR_getInt( charaindex, CHAR_LV ) + ); + BATTLE_talkToCli( charaindex, szBuffer, CHAR_COLORYELLOW ); + } + CHAR_setInt( charaindex, CHAR_SKILLUPPOINT, + CHAR_getInt( charaindex, CHAR_SKILLUPPOINT) + UpLevel*3 ); + work = CHAR_getInt( charaindex, CHAR_CHARM ); + work += CH_FIX_PLAYERLEVELUP; + CHAR_setInt( charaindex, CHAR_CHARM, min( 100, work ) ); + CHAR_complianceParameter( charaindex ); + CHAR_send_P_StatusString( charaindex , + CHAR_P_STRING_LV|CHAR_P_STRING_NEXTEXP|CHAR_P_STRING_DUELPOINT + ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX ) ); + CHAR_PartyUpdate( charaindex, CHAR_N_STRING_LV ); +#ifndef _NET_REDUCESEND + CHAR_send_DpDBUpdate_AddressBook( charaindex, TRUE ); +#endif + } + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + petindex = CHAR_getCharPet( charaindex, i ); + if( CHAR_CHECKINDEX( petindex ) == FALSE )continue; + if( CHAR_getFlg( petindex, CHAR_ISDIE ) == TRUE )continue; + if( CHAR_getWorkInt( petindex, CHAR_WORKGETEXP ) <= 0 ){ + CHAR_complianceParameter( petindex ); + sprintf( szBuffer, "K%d", i ); + CHAR_sendStatusString( charaindex , szBuffer ); + + continue; + } +#ifdef _ITEM_ADDEQUIPEXP + BATTLE_GetExp( petindex, charaindex ); +#else + BATTLE_GetExp( petindex ); +#endif + if( getBattleDebugMsg( ) != 0 ){ + snprintf( szBuffer, sizeof(szBuffer), + "(%s) 得到 EXP %d", + CHAR_getUseName( petindex ), + CHAR_getWorkInt( petindex, CHAR_WORKGETEXP ) + ); + BATTLE_talkToCli( charaindex, szBuffer, CHAR_COLORYELLOW ); + } + UpLevel = CHAR_LevelUpCheck( petindex , charaindex); + if( UpLevel > 0 ){ + if( getBattleDebugMsg( ) != 0 ){ + snprintf( szBuffer, sizeof(szBuffer), + "(%s) 升级至 %d", + CHAR_getUseName( petindex ), + CHAR_getInt( petindex, CHAR_LV ) + ); + BATTLE_talkToCli( charaindex, szBuffer, CHAR_COLORYELLOW ); + } + for( j = 0; j < UpLevel; j ++ ){ + CHAR_PetLevelUp( petindex ); + CHAR_PetAddVariableAi( petindex, AI_FIX_PETLEVELUP ); + } + aRsList[rsCnt].levelup = 1; + }else{ + aRsList[rsCnt].levelup = 0; + } + aRsList[rsCnt].num = i; + aRsList[rsCnt].exp = CHAR_getWorkInt( petindex, CHAR_WORKGETEXP ); + rsCnt ++; + CHAR_complianceParameter( petindex ); + if( UpLevel > 0 ){ + sprintf( szBuffer, "K%d", i ); + CHAR_sendStatusString( charaindex , szBuffer ); + + } + + } + szItemString[0] = 0; + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == FALSE ){ + for( i = 0; i < GETITEM_MAX; i ++ ){ + int ItemGet = FALSE; + szEscItemString[0] = 0; + itemindex = pEntryChara->getitem[i]; + if( itemindex < 0 ){ + itemindex = -1; + }else + if( CHAR_findEmptyItemBox( charaindex ) >= 0 ){ + int ret; + ret = CHAR_addItemSpecificItemIndex(charaindex,itemindex); + if( 0 <= ret && ret < CHAR_EQUIPPLACENUM ){ + print( "itemget err: 在这里不能取得item(%s)(%d)(%s)\n", + CHAR_getUseName( charaindex ), + ret, + ITEM_getAppropriateName(itemindex) + ); + } + if( !CHAR_CHECKITEMINDEX( charaindex, ret) ){ + ItemGet = FALSE; + }else{ + ItemGet = TRUE; + itemgroup[itemnum] = ret; + itemnum ++; + } + } + if( ItemGet == TRUE ){ + if( getBattleDebugMsg( ) != 0 ){ + snprintf( szBuffer, sizeof(szBuffer), + "拾获(%s)", + ITEM_getAppropriateName(itemindex) ); + BATTLE_talkToCli( charaindex, szBuffer, CHAR_COLORYELLOW ); + } + + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), /* 失奶 丞 寞 */ +#endif + "BattleGet(战斗後所得的道具)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar(itemindex, ITEM_UNIQUECODE),// shan 2001/12/14 + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + makeEscapeString( ITEM_getAppropriateName(itemindex), + szEscItemString, + sizeof( szEscItemString ) ); + strncat( szItemString, szEscItemString, sizeof( szItemString ) ); + pEntryChara->getitem[i] = -1; + }else{ + if( itemindex >= 0 ){ + ITEM_endExistItemsOne(itemindex); + }else{ + } + pEntryChara->getitem[i] = -1; + } + strncat( szItemString, "|", sizeof( szItemString ) ); + + } + } + + szBuffer[0] = 0; + for( i = 0; i < RS_LIST_MAX; i ++ ){ + char szWork[256], sz62[64]; + szWork[0] = 0; + if( aRsList[i].exp > 0 || i == 0 ){ + cnv10to62( aRsList[i].exp, sz62, sizeof( sz62 ) ); + snprintf( szWork, sizeof( szWork ), + "%d|%d|%s", aRsList[i].num, + aRsList[i].levelup, + sz62 + ); + } + strncat( szBuffer, szWork, sizeof( szBuffer ) ); + strncat( szBuffer, ",", sizeof( szBuffer ) ); + } + strncat( szBuffer, szItemString, sizeof( szBuffer ) ); + { + int fd; + fd = getfdFromCharaIndex( charaindex ); + lssproto_RS_send( fd, szBuffer ); + } + if( itemnum > 0 ){ + int inum, ie; + for( inum = 0; inum < itemnum; inum ++ ){ + ie = CHAR_getItemIndex( charaindex, itemgroup[inum] ); + } + CHAR_sendItemData( charaindex, itemgroup, itemnum); + } + return 0; +} + +int BATTLE_GetProfit( int battleindex, int side, int num ) +{ + if( BattleArray[battleindex].dpbattle == 1 ){ + return BATTLE_GetDuelPoint( battleindex, side, num ); + }else{ + return BATTLE_GetExpGold( battleindex, side, num ); + } + +} + +int BATTLE_FinishSet( battleindex ) +{ + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + BattleArray[battleindex].mode = BATTLE_MODE_FINISH; + return 0; +} + +static int BATTLE_Finish( int battleindex ) +{ + BATTLE *pBattle; + BATTLE_ENTRY *pEntry; + int i, charaindex, j; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + if( BattleArray[battleindex].winside == 0 + && BattleArray[battleindex].type == BATTLE_TYPE_P_vs_E + && BattleArray[battleindex].WinFunc != NULL){ + BattleArray[battleindex].WinFunc( battleindex, + BattleArray[battleindex].createindex ); + } + +#ifdef _DEATH_CONTEND + if( BattleArray[battleindex].type == BATTLE_TYPE_P_vs_P && + BattleArray[battleindex].PkFunc != NULL ){ + BattleArray[battleindex].PkFunc( + BattleArray[battleindex].menum, BattleArray[battleindex].tonum, + BattleArray[battleindex].winside, BattleArray[battleindex].battlemap ); // winside 0 menum 1 tonum + } +#endif + +#ifdef DANTAI + if( BattleArray[battleindex].type == BATTLE_TYPE_P_vs_P ){ + BATTLE_DpCalc( battleindex ); + } +#endif + + for( j = 0; j < 2; j ++ ){ + pEntry = BattleArray[battleindex].Side[j].Entry; +#ifdef _PET_TALK + for( i = 0 ; i < BATTLE_ENTRY_MAX ; i ++ ){ +#else + for( i = BATTLE_ENTRY_MAX-1; i >= 0 ; i -- ){ +#endif + charaindex = pEntry[i].charaindex; + + if( CHAR_CHECKINDEX( charaindex ) == FALSE ) + continue; + + BATTLE_GetProfit( battleindex, j, i ); //包括取得经验值 + BATTLE_Exit( charaindex, battleindex ); + } + } + if( BattleArray[battleindex].type == BATTLE_TYPE_WATCH ){ + }else{ + pBattle = BattleArray[battleindex].pNext; + for( ;pBattle; pBattle = pBattle->pNext ){ + if( BATTLE_CHECKADDRESS( pBattle ) == FALSE ){ + fprint( "err:battle address 奇怪(%p)\n", pBattle ); + break; + } + for( i = BATTLE_ENTRY_MAX-1; i >= 0 ; i -- ){ + charaindex = pBattle->Side[0].Entry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + BATTLE_Exit( charaindex, pBattle->battleindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_FINAL ); + } + } + pBattle = BattleArray[battleindex].pNext; + for( ;pBattle; pBattle = pBattle->pNext ){ + if( BATTLE_CHECKADDRESS( pBattle ) == FALSE ){ + fprint( "err:battle address 奇怪(%p)\n", pBattle ); + break; + } + BATTLE_DeleteBattle( pBattle->battleindex ); + } + } + BATTLE_DeleteBattle( battleindex ); + return 0; +} + +int BATTLE_StopSet( battleindex ) +{ + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + BattleArray[battleindex].mode = BATTLE_MODE_STOP; + + return 0; +} + +static int BATTLE_Stop( int battleindex ) +{ + BATTLE_ENTRY *pEntry; + int i, charaindex, j; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + + for( j = 0; j < 2; j ++ ){ + pEntry = BattleArray[battleindex].Side[j].Entry; + for( i = BATTLE_ENTRY_MAX-1; i >= 0 ; i -- ){ + charaindex = pEntry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE ) + continue; + BATTLE_GetProfit( battleindex, j, i ); + BATTLE_Exit( charaindex, battleindex ); + } + } + + BATTLE_DeleteBattle( battleindex ); + return 0; +} + +int BATTLE_DefaultAttacker( int battleindex, int side ) +{ + int i, rnd, cnt; + int CharaTbl[BATTLE_ENTRY_MAX]; + + BATTLE_ENTRY *pEntry; + + pEntry = BattleArray[battleindex].Side[side].Entry; + cnt = 0; + + for( i = 0 ; i < BATTLE_ENTRY_MAX; i ++ ){ + CharaTbl[i] = -1; + if( CHAR_CHECKINDEX( pEntry[i].charaindex ) == FALSE ){ + continue; + } + + if( CHAR_getWorkInt( pEntry[i].charaindex, CHAR_WORKBATTLEMODE ) + == BATTLE_CHARMODE_RESCUE ){ + continue; + } + + if( BATTLE_TargetCheck( battleindex, i + side * SIDE_OFFSET ) == FALSE )continue; + + CharaTbl[cnt] = i + side * SIDE_OFFSET; + cnt ++; + } + + if( cnt == 0 ){ + return -1; + } + + rnd = RAND( 0, cnt-1 ); + return CharaTbl[rnd]; + +} + +#if 0 +//********************************************************* +// +// 衬平乓仿卞爵 戊穴件玉毛 木月 + +static int BATTLE_EnemyCommand( int battleindex, int side ) +// +// 曰袄 BATTLE_ERR +// +//********************************************************* +{ + int i, charaindex; + BATTLE_ENTRY *pEntry; + + // 由仿丢□正民尼永弁 + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + if( BATTLE_CHECKSIDE( side ) == FALSE )return BATTLE_ERR_PARAM; + + // 及扔奶玉隋垫丹 + // 衬平乓仿动陆反 仃月 + if( BattleArray[battleindex].Side[side].type != BATTLE_S_TYPE_ENEMY ) return 0; + + pEntry = BattleArray[battleindex].Side[side].Entry; + + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pEntry[i].charaindex; + // 平乓仿弁正银匀化卅井匀凶日戚尺 + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + // 衬平乓仿元扎卅井匀凶日戚尺 + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEENEMY ){ + continue; + } + // 反仇仇匹檗 午井卞杀元化戊穴件玉毛 尹月互} + // 漆反爵丹及心午允月[ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + // 锹澎反赝癫 + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, BATTLE_DefaultAttacker( battleindex, 0 ) ); + // 戊穴件玉 OK 午仄化云仁 + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + } + + return 0; +} +#endif + +//********************************************************* +// +// 爵 丐月扔奶玉及戏五酸曰皿伊奶乩□卞 毛笛遥 +// +int BATTLE_AddDpAlive( + int battleindex, // 田玄伙奶件犯永弁旦 + int side, // 扔奶玉( 0 or 1 ) + int dp +) +// +// 曰袄“{戏五酸匀化中月皿伊奶乩□及醒 +//{{{{{ 爵 互垫歹木化中卅仃木壬 及袄 +// +//********************************************************* +{ + int i, charaindex; + BATTLE_ENTRY *pEntry; + int cnt = 0; + + // 由仿丢□正民尼永弁 + if( BATTLE_CHECKSIDE( side ) == FALSE )return -BATTLE_ERR_PARAM; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return -BATTLE_ERR_BATTLEINDEX; + + // 巨件玄伉□ + pEntry = BattleArray[battleindex].Side[side].Entry; + + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pEntry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE ) continue; + // 矢永玄反仇及端楮溢卅中 + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ) continue; + // 戏五化中引允[笛遥 + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == FALSE ){ + CHAR_setWorkInt( charaindex, CHAR_WORKGETEXP, + CHAR_getWorkInt( charaindex, CHAR_WORKGETEXP) + dp ); + } + } + + return cnt; +} + +#if 1 +//********************************************************* +// +// 爵 }皿伊奶乩□互戏五酸匀化中月井譬屯月 +// +int BATTLE_CountAlive( + int battleindex, // 田玄伙奶件犯永弁旦 + int side // 扔奶玉( 0 or 1 ) +) +// +// 曰袄“{戏五酸匀化中月皿伊奶乩□及醒 +//{{{{{ 爵 互垫歹木化中卅仃木壬 及袄 +// +//********************************************************* +{ + int i, charaindex; + BATTLE_ENTRY *pEntry; + int cnt = 0; + + // 由仿丢□正民尼永弁 + if( BATTLE_CHECKSIDE( side ) == FALSE )return -BATTLE_ERR_PARAM; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return -BATTLE_ERR_BATTLEINDEX; + + // 巨件玄伉□ + pEntry = BattleArray[battleindex].Side[side].Entry; + + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pEntry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE ) continue; + // 矢永玄反仇及端楮溢卅中 + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ) continue; + // 戏五化中引允[ + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == FALSE ){ + cnt ++; + } + } + + return cnt; +} +#endif + + +//********************************************************* +// +// 爵 }辅爵仄凶化皿伊奶乩□及心互戏五化中月橇谪井毛民尼永弁 +// +int BATTLE_OnlyRescue( + int battleindex, // 田玄伙奶件犯永弁旦 + int side, // 扔奶玉( 0 or 1 ) + int *pOnlyFlg +) +// +// 曰袄“{戏五酸匀化中月皿伊奶乩□及醒 +//{{{{{ 爵 互垫歹木化中卅仃木壬 及袄 +// +//********************************************************* +{ + int i, charaindex; + BATTLE_ENTRY *pEntry; + int cnt = 0, OnlyRescue = 1; + + (*pOnlyFlg) = 0; + + // 由仿丢□正民尼永弁 + if( BATTLE_CHECKSIDE( side ) == FALSE )return -BATTLE_ERR_PARAM; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return -BATTLE_ERR_BATTLEINDEX; + + // 巨件玄伉□ + pEntry = BattleArray[battleindex].Side[side].Entry; + + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pEntry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE ){ + continue; + } + // 矢永玄反仇及端楮溢卅中 + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ) continue; + // 戏五化中引允[ + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == FALSE ){ + cnt ++; + // 戏五化中月支勾反辅爵 井" + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_RESCUE ){ + }else{ + OnlyRescue = 0; + } + } +#ifdef _PETSKILL_LER + if(CHAR_getWorkInt(charaindex,CHAR_WORK_RELIFE) > 0) cnt++; +#endif + } + + // 戏五化中月支勾互中化公中勾反辅爵 分匀凶日 + if( cnt > 0 && OnlyRescue ){ + // 白仿弘毛 化月 + (*pOnlyFlg) = 1; + }else{ + // 切互匀凶日ㄟ卞允月 + (*pOnlyFlg) = 0; + } + + return cnt; +} + +static BOOL BATTLE_TimeOutCheck( int battleindex ) +{ + int i, j, charaindex; + BATTLE *pBattle; + BATTLE_ENTRY *pEntry; + pBattle = &BattleArray[battleindex]; + + if( NowTime.tv_sec > pBattle->timer + BATTLE_TIME_LIMIT ){ + }else{ + return FALSE; + } + //BATTLE_BroadCast( battleindex, "server时间已到。", CHAR_COLORYELLOW ); + for( j = 0; j < 2; j ++ ){ + pEntry = pBattle->Side[j].Entry; + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pEntry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE ) + continue; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ){ + continue; + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) + == BATTLE_CHARMODE_C_WAIT ){ + BATTLE_Exit( charaindex, battleindex ); + CHAR_DischargePartyNoMsg( charaindex ); + CHAR_talkToCli( charaindex, -1, + "时间到,结束战斗。", CHAR_COLORYELLOW ); + BATTLE_CommandSend( charaindex, "BU" ); + } + } + } + + return TRUE; +} + +int BATTLE_WatchWait( int battleindex ) +{ + BATTLE *pBattle; + BOOL commandflg = TRUE; + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + pBattle = &BattleArray[battleindex]; + if( BATTLE_TimeOutCheck( battleindex ) == TRUE ){ + commandflg = TRUE; + } + if( commandflg == FALSE ){ + return 0; + } + pBattle->mode = BATTLE_MODE_WATCHMOVIE; + pBattle->turn ++; + return 0; +} + +int BATTLE_WatchMovie( int battleindex ) +{ + return 0; + +} + +int BATTLE_WatchAfter( int battleindex ) +{ + BattleArray[battleindex].mode = BATTLE_MODE_WATCHPRE; + + return 0; + +} + +int BATTLE_WatchBC( int battleindex ) +{ + return 0; +} + +int BATTLE_WatchPre( int battleindex ) +{ + // 戊穴件玉谨切尺 月凛及域 及 木 + BATTLE_PreWatchWaitSeq( battleindex ); + BattleArray[battleindex].mode = BATTLE_MODE_WATCHWAIT; + return 0; +} + +static int BATTLE_Command( int battleindex ) +{ + BATTLE *pBattle, *pWatchBattle; + BOOL commandflg = TRUE, iFinish = FALSE; + int OnlyRescue[2], i, j, charaindex; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + pBattle = &BattleArray[battleindex]; + + if( BATTLE_CommandWait( battleindex, 0) == FALSE ){ + commandflg = FALSE; + } + if( BATTLE_CommandWait( battleindex, 1) == FALSE ){ + commandflg = FALSE; + } + pWatchBattle = pBattle->pNext; + for( ; pWatchBattle ; pWatchBattle = pWatchBattle->pNext ){ + if( BATTLE_CHECKADDRESS( pWatchBattle ) == FALSE ){ + fprint( "err:观战battle address错误(%p)\n", pWatchBattle ); + break; + } + + if( pWatchBattle->mode == BATTLE_MODE_WATCHBC ){ + + BATTLE_MakeCharaString( battleindex, szAllBattleString, + sizeof(szAllBattleString) ); + BATTLE_BpSendToWatch( pWatchBattle, szAllBattleString ); + + pWatchBattle->mode = BATTLE_MODE_WATCHPRE; + commandflg = FALSE; + + }else if( pWatchBattle->mode != BATTLE_MODE_WATCHMOVIE ){ + commandflg = FALSE; + } + } + if( BATTLE_TimeOutCheck( battleindex ) == TRUE ){ + commandflg = TRUE; + } + if( commandflg == FALSE ){ + return 0; + } +#ifdef _BATTLECOMMAND_TIME + BattleArray[battleindex].PartTime = 0; +#endif + + + pBattle->turn ++;//自己回合数增加 + BATTLE_ai_all( battleindex, 0, 0); + BATTLE_ai_all( battleindex, 1, 0); + BATTLE_Battling( battleindex );//处理战斗 + pBattle->Side[0].flg &= ~BSIDE_FLG_SURPRISE; + pBattle->Side[1].flg &= ~BSIDE_FLG_SURPRISE; + if( BATTLE_OnlyRescue( battleindex, 0, &OnlyRescue[0] ) == 0 ){ + pBattle->winside = 1; + iFinish = TRUE; + }else + if( BATTLE_OnlyRescue( battleindex, 1, &OnlyRescue[1] ) == 0 ){ + pBattle->winside = 0; + iFinish = TRUE; + } + for( j = 0; j < 2; j ++ ){ + if( OnlyRescue[j] != 1 )continue; + for( i = 0; i < BATTLE_ENTRY_MAX/2; i ++ ){ + charaindex = pBattle->Side[j].Entry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE ) + continue; + if( CHAR_getInt( charaindex, CHAR_HP ) <= 0 ){ + BATTLE_Exit( charaindex, battleindex ); + } + } + } + BATTLE_PreCommandSeq( battleindex ); + if( iFinish == TRUE ){ + BATTLE_FinishSet( battleindex ); + } + return 0; +} + +#ifdef _CHECK_BATTLE_IO +extern int InBattleLoop; +extern int battle_write; +extern int other_write; +extern int battle_write_cnt; +extern int other_write_cnt; +#endif + +extern void BATTLE_changeRideImage( int index ); + +int BATTLE_Loop( void ) +{ + int i, cnt = 0; + +#ifdef _CHECK_BATTLE_IO + InBattleLoop = TRUE; +#endif + + rand(); + for( i = 0; i < BATTLE_battlenum; i ++ ){//最多战斗场数 + if( BattleArray[i].use == FALSE )continue; + if( BattleArray[i].type == BATTLE_TYPE_WATCH ){//若是观战模式 + if( BATTLE_CountAlive( i, 0 ) == 0 ){ + BATTLE_FinishSet( i ); + } + } + + switch( BattleArray[i].mode ){ + case BATTLE_MODE_NONE://未战斗 + break; + case BATTLE_MODE_INIT://战斗初始化 + BATTLE_Init( i ); + break; + case BATTLE_MODE_BATTLE://Server内部战斗中 + BATTLE_Command( i ); + break; + case BATTLE_MODE_FINISH://战斗结束 + BATTLE_Finish( i ); + break; + case BATTLE_MODE_STOP://战斗中断 + BATTLE_Stop( i ); + break; + case BATTLE_MODE_WATCHBC://观战中... + BATTLE_WatchBC( i ); + break; + + case BATTLE_MODE_WATCHPRE: + BATTLE_WatchPre( i ); + break; + case BATTLE_MODE_WATCHWAIT: + BATTLE_WatchWait( i ); + break; + + case BATTLE_MODE_WATCHMOVIE: + BATTLE_WatchMovie( i ); + break; + + case BATTLE_MODE_WATCHAFTER: + BATTLE_WatchAfter( i ); + break; + } + cnt ++; + } + +#ifdef _CHECK_BATTLE_IO + InBattleLoop = FALSE; +#endif + + return cnt; +} + + + + + +typedef struct { + int charaindex; // 平乓仿弁正奶件犯永弁旦 + int side; // 扔奶玉 + int dex; // 豳镀今 + int num; // 巨件玄伉□ 寞 + int combo; // 宁 猾允月谛棉井" +#ifdef _EQUIT_SEQUENCE + int sequence; +#endif +}BATTLE_CHARLIST; + + +typedef int (*FUNC)( const void *, const void * ); + +//************************************************************ +// +// 爵 及豳镀今 胜楮醒 +// +// 豳镀今反袄互 五中 互穸木化中月[嫦赐末□玄匹丐月[ +// +static int EsCmp( + const BATTLE_CHARLIST *pC1, + const BATTLE_CHARLIST *pC2 +) +{ +#ifdef _EQUIT_SEQUENCE + return( (pC2->dex+pC2->sequence) - (pC1->dex+pC1->sequence) ); +#else + return( pC2->dex - pC1->dex ); +#endif +} + +#ifdef _EQUIT_SEQUENCE +void Replacement_Entry( BATTLE_CHARLIST *temp1, BATTLE_CHARLIST *temp2) +{ + temp1->charaindex = temp2->charaindex; + temp1->combo = temp2->combo; + temp1->dex = temp2->dex; + temp1->num = temp2->num; + temp1->sequence = temp2->sequence; + temp1->side = temp2->side; +} +#endif +static void EntrySort( BATTLE_CHARLIST *EntryList, int listsize) +{ +#ifdef _EQUIT_SEQUENCE +// int i, j; + qsort( EntryList, listsize, sizeof( BATTLE_CHARLIST ), (FUNC)EsCmp ); +/* + for( i=0; i 0 ){ + int maxcheck, now; + BATTLE_CHARLIST temp; + + maxcheck = EntryList[i].sequence/8; + maxcheck = RAND( 1, maxcheck); + maxcheck = ( maxcheck>=i )?(i/3):maxcheck; + maxcheck = ( maxcheck<0)?0:maxcheck; + now = i; + for( j=0; j0; j++){ + if( EntryList[now].sequence > (EntryList[now-1].sequence *0.9) ){ + + Replacement_Entry( &temp, &EntryList[now]); + Replacement_Entry( &EntryList[now], &EntryList[now-1]); + Replacement_Entry( &EntryList[now-1], &temp); + now = now-1; + + +// temp = &EntryList[now]; +// EntryList[now] = EntryList[now-1]; +// EntryList[now-1] = *temp; +// temp = NULL; + + } + } + } + } +*/ +#else + qsort( EntryList, listsize, sizeof( BATTLE_CHARLIST ), (FUNC)EsCmp ); +#endif +} + + + +//************************************************************ +// +// 豳镀今毛煌遥允月[ +// +static int BATTLE_DexCalc( + int charaindex +) +// +// 曰袄 豳镀今 +// +//************************************************************ +{ + int dex = 0; + int work, COM; + int petindex = BATTLE_getRidePet( charaindex ); + + // 戊穴件玉潸 + COM = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ); + +#ifdef _PETSKILL_BECOMEFOX // 攻击顺序中的敏捷降下20% + if( CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND ) != -1 ){ + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + dex = work *0.8;//敏降20% + } +#endif +#ifdef _PROFESSION_ADDSKILL + if( CHAR_getWorkInt( charaindex, CHAR_WORKFEAR ) > 0 ){ + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + dex = work*0.8;//敏降20% + } +#endif + // 骚橘 猾及桦宁 + switch( COM ){ +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + case BATTLE_COM_S_BLOOD: // 嗜血成性 + case BATTLE_COM_S_BLOOD_WORMS: // 嗜血蛊 + case BATTLE_COM_S_SIGN: // 一针见血 +#endif + +#ifdef _BATTLE_NEWPOWER + case BATTLE_COM_JYUJYUTU: + case BATTLE_COM_S_ATTACK_MAGIC: + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + dex = work - RAND( 0, work * 0.3 ); + break; +#endif + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + case BATTLE_COM_S_FIRE_ENCLOSE: // 火附体 + case BATTLE_COM_S_ICE_ENCLOSE: // 冰附体 + case BATTLE_COM_S_THUNDER_ENCLOSE: // 雷附体 + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + dex = work - RAND( work * 0.3, work * 0.5 ); + break; + case BATTLE_COM_S_VOLCANO_SPRINGS:// 火山泉 + case BATTLE_COM_S_SUMMON_THUNDER: // 召雷术 + case BATTLE_COM_S_ICE_ARROW: // 冰箭术 + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + dex = work - RAND( 0, work * 0.2 ); + break; + case BATTLE_COM_S_CURRENT: // 电流术 + case BATTLE_COM_S_FIRE_BALL:// 火星球 + case BATTLE_COM_S_ICE_CRACK: // 冰爆术 + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + dex = work - RAND( 0, work * 0.5 ); + break; + case BATTLE_COM_S_FIRE_SPEAR:// 火龙枪 + case BATTLE_COM_S_STORM: // 暴风雨 + case BATTLE_COM_S_ICE_MIRROR: // 冰镜术 + case BATTLE_COM_S_ENCLOSE: // 附身术 + case BATTLE_COM_S_TRANSPOSE: // 移形换位 + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + dex = work - RAND( work * 0.2, work * 0.5 ); + break; + + case BATTLE_COM_S_DOOM: // 世界末日 + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + dex = work - RAND( 0.3, work * 0.6 ); + break; +#endif + +#ifdef _SKILL_SPEEDY_ATT //vincent 宠技:疾速攻击 + case BATTLE_COM_S_SPEEDYATTACK: + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + dex = work + work*0.3;//敏加30% + break; +#endif +#ifdef _PETSKILL_DAMAGETOHP //宠技:暗月狂狼(嗜血技的变体) + case BATTLE_COM_S_DAMAGETOHP2: + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + dex = work + work*0.2;//敏加20% + break; +#endif + + case BATTLE_COM_ITEM: // 失奶 丞毛银丹桦宁 + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + dex = work - RAND( 0, work * 0.3 ) + work * 0.15; + break; + default: // 骚橘 爵丹卅升) + // Robin 0727 ride pet + if( petindex == -1 ) + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + else + work = BATTLE_adjustRidePet3A( charaindex, petindex, CHAR_WORKQUICK, ATTACKSIDE )+20; + dex = work - RAND( 0, work * 0.3 ); + break; + } + + // 穴奶瓜旦卞卅匀化仄引匀凶日" + if( dex <= 0 )dex = 1; + + return dex; +} + + + + + + +//************************************************************* +// +// 戊件申生□扑亦件互丐月井升丹井民尼永弁 +// +static void ComboCheck( + BATTLE_CHARLIST *pEntryList, + int entrynum +) +// +//************************************************************* +{ + + int i, + charaindex, + com, + enemy, + side, + oldside = -3, // 赝癫卞丐曰尹卅中袄 + oldenemy = -3, // 赝癫卞丐曰尹卅中袄 + armtype, + move, + per, + ComboId = 1, // 戊件示 + start = -1; +#ifdef _ITEM_ADDCOMBO + int j; +#endif + + for( i = 0; i < entrynum; i ++ ){ + + charaindex = pEntryList[i].charaindex; + com = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ); + enemy = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + side = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLESIDE ); + armtype = 0; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ){ + per = 20; // 衬反ㄡㄟ⊙ + }else{ + per = 50; // 愤坌反ㄤㄟ⊙ +#ifdef _ITEM_ADDCOMBO + for( j = 0 ; j < CHAR_EQUIPPLACENUM ; j ++ ){ + int id = CHAR_getItemIndex(charaindex,j);//道具id + if( ITEM_CHECKINDEX(id) ){ + char *arg; + arg = ITEM_getChar(id, ITEM_ARGUMENT );//道具参数 + if( strstr( arg, "合击" ) ){ + int k,battleindex,lr; + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX );//战场编号 + lr = BATTLE_Index2No( battleindex, charaindex );//所站位置 + for( k = 0; k < entrynum; k ++ ){//战场上所有人回圈 + if( BATTLE_TargetCheck(battleindex, pEntryList[k].charaindex ) ){//活着 + if( ( lr < 10 + && BATTLE_Index2No( battleindex, pEntryList[k].charaindex ) < 10 ) + || ( lr >= 10 + && BATTLE_Index2No( battleindex, pEntryList[k].charaindex ) >= 10 ) ){//同一队 + int l; + for( l = 0 ; l < CHAR_EQUIPPLACENUM ; l ++ ){ + int lid = CHAR_getItemIndex(charaindex,l);//道具id + if( ITEM_CHECKINDEX(lid) ){ + arg = ITEM_getChar(lid, ITEM_ARGUMENT );//道具参数 + if( strstr( arg, "合击" ) ){//同一队有2个人以上有载此道具 + int add=0; + sscanf( arg+4, "%d", &add );//取得追加的%数 + per += add; + break; + } + } + } + } + } + } + break; + } + } + } +#endif + } + + // 互ㄟ井 仃卅井匀凶日 + if( CHAR_getInt( charaindex, CHAR_HP ) <= 0 + || BATTLE_CanMoveCheck( charaindex ) == FALSE + ){ + move = 0; + }else{ + move = 1; + } + + // 猾础及 湛毛潸 [髑仆烟卅日母丢 + // 髑仆烟卅日母丢 + if( BATTLE_IsThrowWepon( + CHAR_getItemIndex( charaindex, CHAR_ARM ) ) == TRUE + ){ + armtype = 1; + } + + pEntryList[i].combo = 0; // 赓渝祭 + + if( start != -1 ){ // 宁 猾 + if( com != BATTLE_COM_ATTACK // 猾戊穴件玉匹卅中 + || enemy != oldenemy // 谎匀化月衬互 元匹卅中 + || side != oldside // 扔奶玉互啜丹 + || armtype == 1 // 髑仆烟匹丐月 + || move == 0 // 仃卅中 + ){ + start = -1; // 蔽 + oldside = side; // 扔奶玉创尹月 + }else{ + // 戊件示涩烂 + CHAR_setWorkInt( pEntryList[i].charaindex, + CHAR_WORKBATTLECOM1,BATTLE_COM_COMBO ); + pEntryList[i].combo = ComboId; + // 赓及谛手域杀涩烂 + CHAR_setWorkInt( pEntryList[start].charaindex, + CHAR_WORKBATTLECOM1,BATTLE_COM_COMBO ); + pEntryList[start].combo = ComboId; + } + } + if( start == -1 ){// 宁 猾 仄化中卅中桦宁 + if( com == BATTLE_COM_ATTACK + && armtype != 1 // 髑仆烟匹卅中 + && move == 1 // 仃月 + && RAND( 1, 100 ) <= per + ){ // 骚橘 猾 匹丐月 + start = i; + oldenemy = enemy; // 谎匀化月衬毛创尹月 + oldside = side; // 扔奶玉创尹月 + ComboId ++; + } + } + + } + +} + +//************************************************************* +// +// 戊件申生□扑亦件互 癫卞匹五月井民尼永弁 +//{戚及谛互戊件示匹五月橇谪元扎卅井匀凶日 FALSE +// +static BOOL ComboCheck2( + BATTLE_CHARLIST *pEntryList, // 巨件玄伉□伉旦玄 + int nownum, // 蜇箕及赐 + int entrynum // 巨件玄伉□ 醒 +) +// +// 戊件示匹五月 TRUE +// 匹五卅中 FALSE +// +//************************************************************* +{ + + int i, + iRet = FALSE, + ComboId, + charaindex; + + // 戊件示 忡绣 + ComboId = pEntryList[nownum].combo; + + charaindex = pEntryList[nownum].charaindex; + + // 愤坌互镝擦蘸撩 仄化中凶日撩 + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEFLG) & CHAR_BATTLEFLG_AIBAD ) + { +// print( "由於忠诚度不足使用必杀技失败( %s )\n",CHAR_getUseName( charaindex ) ); + return FALSE; + } + + // 戚及谛互戊件示卞辅笛匹五月井割 + for( i = nownum+1; i < entrynum; i ++ ){ + charaindex = pEntryList[i].charaindex; + + // 戊件示 啜丹午镀仁手撩 + if( ComboId != pEntryList[i].combo )break; + + // 爵 卞辅笛仄化中卅井匀凶日戚尺 + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) == 0 ) break; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_FINAL ) break; + + if( CHAR_getInt( charaindex, CHAR_HP ) <= 0 + || BATTLE_CanMoveCheck( charaindex ) == FALSE + ){ + }else{ + iRet = TRUE; + break; + } + } +/* + if( iRet == FALSE ){ + print( "必杀技失败( %s )\n", + CHAR_getUseName( pEntryList[nownum].charaindex ) ); + } +*/ + return iRet; + +} + + +void BATTLE_UltimateExtra( + int battleindex, + int charaindex, + int enemyindex +) +{ + char szBuffer[256]=""; + int pindex, pno; +#ifndef _DEATH_CONTEND + int floor=0, x=0, y=0; +#endif + szBuffer[0] = 0; + + if( CHAR_getInt( enemyindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + BATTLE_PetDefaultExit( enemyindex, battleindex ); + + if( BattleArray[battleindex].type != BATTLE_TYPE_P_vs_P ){ + int levelflg = 1; + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)被击飞至远方。", + // CHAR_getUseName( enemyindex ) ); + if( CHAR_getInt( enemyindex, CHAR_LV ) <= 10 ){ + levelflg = 2; + } + + if( BattleArray[battleindex].norisk == 0 ){; + CHAR_AddCharm( enemyindex, CH_FIX_PLAYEULTIMATE/levelflg ); + pno = CHAR_getInt( enemyindex, CHAR_DEFAULTPET ); + if( 0 <= pno && pno < CHAR_MAXPETHAVE ){ + pindex = CHAR_getCharPet( enemyindex, pno ); + if( CHAR_CHECKINDEX( pindex ) == TRUE ){ + CHAR_PetAddVariableAi( pindex, AI_FIX_PLAYERULTIMATE/levelflg ); + } + } + } +#ifdef _DEATH_CONTEND + CHAR_warpToSpecificPoint( enemyindex, 8250, 22, 22 ); +#else +#ifdef _BAD_PLAYER // WON ADD 送坏玩家去关 + if( NPC_EventCheckFlg( enemyindex, 135 ) ){ + CHAR_warpToSpecificPoint( enemyindex, 887, 56, 14 ); + }else{ +#endif + if( CHAR_getElderPosition( + CHAR_getInt( enemyindex, CHAR_LASTTALKELDER), &floor, &x, &y ) + != TRUE + ){ + }else{ + CHAR_warpToSpecificPoint( enemyindex, floor, x, y ); + } +#ifdef _BAD_PLAYER + } +#endif +#endif + } + BATTLE_Exit( enemyindex, battleindex ); + CHAR_DischargePartyNoMsg( enemyindex ); + if( getBattleDebugMsg( ) != 0 ){ + BATTLE_talkToCli( enemyindex, szBuffer, CHAR_COLORYELLOW ); + } + + }else + // 矢永玄卅日 + if( CHAR_getInt( enemyindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + int levelflg = 1; + int playerindex = CHAR_getWorkInt( enemyindex, CHAR_WORKPLAYERINDEX ); + + // 伊矛伙互斓中桦宁反 蛹月 坌 + if( CHAR_getInt( playerindex, CHAR_LV ) <= 10 ){ + levelflg = 2; + } + + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)被击飞。", + // CHAR_getUseName( enemyindex ) ); + + // 潜谛及犯白巧伙玄井日反内允 + CHAR_setInt( playerindex, CHAR_DEFAULTPET, -1 ); + + // 犯亘巨伙动陆反镝擦艘毛票仆月 + if( BattleArray[battleindex].type != BATTLE_TYPE_P_vs_P ){ + // 伉旦弁及 中田玄伙井"丐月卅日镝擦 毛票仆月 + if( BattleArray[battleindex].norisk == 0 ){; + CHAR_PetAddVariableAi( enemyindex, AI_FIX_PETULTIMATE/levelflg ); + } + // 潜谛及矢永玄韶氏分荚醒毛市它件玄允月 + CHAR_setInt( playerindex, CHAR_DEADPETCOUNT, + CHAR_getInt( playerindex, CHAR_DEADPETCOUNT ) + 1 ); + } +/* + // 矢永玄互中凶日爵 井日厄仃今六月[ + BATTLE_PetDefaultExit( enemyindex, battleindex ); +*/ + + // 愤坌手 仃月 + BATTLE_Exit( enemyindex, battleindex ); + + }else{ + int flg; + // 公木动陆匹失伙 奴丢永玄韶 + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)被击飞。", + // CHAR_getUseName( enemyindex ) ); + // 衬平乓仿反扔□田□卞酸仄化云仁 +// BATTLE_Exit( enemyindex, battleindex ); + flg = CHAR_getWorkInt( enemyindex, CHAR_WORKBATTLEFLG ); + flg |= CHAR_BATTLEFLG_ULTIMATE; // 失伙 奴丢永玄熬仃凶 + CHAR_setWorkInt( enemyindex, CHAR_WORKBATTLEFLG, flg ); + BATTLE_Exit( enemyindex, battleindex ); + } + + // 须 煤 + //BATTLE_BroadCast( battleindex, szBuffer, CHAR_COLORYELLOW ); + +} + + +//************************************************************* +// +// 骚橘卞竣濮今六凶桦宁及 溃质 +// +void BATTLE_NormalDeadExtra( + int battleindex, // 爵 奶件犯永弁旦 + int charaindex, // 诮仄凶平乓仿及奶件犯永弁旦 + int enemyindex // 诮今木凶平乓仿及奶件犯永弁旦 +) +// +// +//************************************************************* +{ + int pindex, pno; + char szBuffer[256]=""; + + szBuffer[0] = 0; + + // 皿伊奶乩□匹 + // 衬午及爵 分匀凶日 + // 伉旦弁及 中田玄伙卅日 + if( CHAR_getInt( enemyindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER + && BattleArray[battleindex].type == BATTLE_TYPE_P_vs_E + && BattleArray[battleindex].norisk == 0 + ){ + int levelflg = 1; + // 愤坌及 毛票仆月 + // 伊矛伙ㄠㄟ动票及谛反 坌分仃票互月 + if( CHAR_getInt( enemyindex, CHAR_LV ) <= 10 ){ + levelflg = 2; + } + CHAR_AddCharm( enemyindex, CH_FIX_PLAYERDEAD/levelflg ); + // 爵 卞辅笛仄化中凶矢永玄及 毛票仆月 + pno = CHAR_getInt( enemyindex, CHAR_DEFAULTPET ); + if( 0 <= pno && pno < CHAR_MAXPETHAVE ){ + // 矢永玄及奶件犯永弁旦 + pindex = CHAR_getCharPet( enemyindex, pno ); + if( CHAR_CHECKINDEX( pindex ) == TRUE ){ + CHAR_PetAddVariableAi( pindex, AI_FIX_PLAYERDEAD/levelflg ); + } + } + // 韶氏分平乓仿及戊穴件玉反侉木月 + CHAR_setWorkInt( enemyindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + }else + // 矢永玄卅日 + if( CHAR_getInt( enemyindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET + && BattleArray[battleindex].type == BATTLE_TYPE_P_vs_E + && BattleArray[battleindex].norisk == 0 + ){ + int levelflg = 1; + int playerindex = CHAR_getWorkInt( enemyindex, CHAR_WORKPLAYERINDEX ); + + // 潜谛及伊矛伙ㄠㄟ动票及谛反 坌分仃票互月 + if( CHAR_getInt( playerindex, CHAR_LV ) <= 10 ){ + levelflg = 2; + } + // 愤坌及镝擦艘毛票仆月 + CHAR_PetAddVariableAi( enemyindex, AI_FIX_PETDEAD/levelflg ); + // 潜谛及矢永玄韶氏分荚醒毛市它件玄允月 + CHAR_setInt( playerindex, CHAR_DEADPETCOUNT, + CHAR_getInt( playerindex, CHAR_DEADPETCOUNT ) + 1 ); + + // 韶氏分平乓仿及戊穴件玉反侉木月 + CHAR_setWorkInt( enemyindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + + }else{ + // 公木动陆 + } + + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)失去意识。", + // CHAR_getUseName( enemyindex ) ); + + //BATTLE_BroadCast( battleindex, szBuffer, CHAR_COLORYELLOW ); + +} + +#ifndef DANTAI +void BATTLE_EscapeDpSend( int battleindex, int charaindex ) +{ + + int enemyside, cnt, dpadd; + BATTLE_ENTRY *pEntry; + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE ){ + return; + } + + if( BattleArray[battleindex].type != BATTLE_TYPE_P_vs_P ){ + return; + } + if( BattleArray[battleindex].flg & BATTLE_FLG_FREEDP ){ + CHAR_setWorkInt( charaindex, CHAR_WORKGETEXP, 0 ); + return ; + } + BattleArray[battleindex].flg |= BATTLE_FLG_CHARALOST; + enemyside = 1 - CHAR_getWorkInt( charaindex, CHAR_WORKBATTLESIDE ); + pEntry = BattleArray[battleindex].Side[enemyside].Entry; + cnt = BATTLE_CountAlive( battleindex, enemyside ); + if( cnt == 0 )return; + dpadd = CHAR_getInt( charaindex, CHAR_DUELPOINT ) * DUELPOINT_RATE; + if( dpadd < 1 )dpadd = 1; + CHAR_setWorkInt( charaindex, CHAR_WORKGETEXP, -dpadd*2 ); + dpadd /= cnt; + if( dpadd < 1 )dpadd = 1; + BATTLE_AddDpAlive( battleindex, enemyside, dpadd ); +} +#else +void BATTLE_EscapeDpSend( int battleindex, int charaindex ) +{ + + int enemyside, dpadd; + BATTLE_ENTRY *pEntry; + + // Nuke 0725: Avoid too large number + if ((battleindex<0)||(battleindex>getBattlenum())) return; + // 动陆反 仃月 + if( BattleArray[battleindex].type != BATTLE_TYPE_P_vs_P ){ + return; + } + + // 锹澎扔奶玉 + enemyside = 1 - CHAR_getWorkInt( charaindex, CHAR_WORKBATTLESIDE ); + + pEntry = BattleArray[battleindex].Side[enemyside].Entry; + + // 锹澎础卞中月谛醒毛醒尹月 + dpadd = CHAR_getInt( charaindex, CHAR_DUELPOINT ) * DUELPOINT_RATE; + if( dpadd < 1 )dpadd = 1; // 斓匹手ㄠ + + // 谛井日娄中化云仁 + CHAR_setWorkInt( charaindex, CHAR_WORKGETEXP, -dpadd*2 ); + + // 锹澎础卞反箫允 + BattleArray[battleindex].Side[enemyside].common_dp += dpadd; + + +} +#endif + + +#ifndef DANTAI +int BATTLE_AddDuelPoint( int battleindex, int *pBidList ) +{ + int enemyindex, i, side, num, j, k, + charaindex[BATTLE_ENTRY_MAX+1]; + BATTLE_ENTRY + *pEntryEnemy; + int allnum = 0; + int bid = pBidList[0]; + + if( pBidList < 0 )return BATTLE_ERR_PARAM; + if( bid >= SIDE_OFFSET ){ + num = bid - SIDE_OFFSET; + side = 1; + }else{ + num = bid ; + side = 0; + } + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + if( BATTLE_CHECKSIDE( side ) == FALSE )return BATTLE_ERR_PARAM; + if( num < 0 || num >= BATTLE_ENTRY_MAX )return BATTLE_ERR_PARAM; + + for( i = 0; i < BATTLE_ENTRY_MAX + 1 ; i ++ ){ + charaindex[i] = -1; + } + + for( i = 0; i < BATTLE_ENTRY_MAX && pBidList[i] != -1 ; i ++ ){ + int work; + work = BATTLE_No2Index( battleindex, pBidList[i] ); + if( work < 0 )return BATTLE_ERR_PARAM; + if( CHAR_getInt( work, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ){ + continue; + } + if( CHAR_getInt( work, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + work = CHAR_getWorkInt( work, CHAR_WORKPLAYERINDEX ); + } + if( work < 0 )return BATTLE_ERR_PARAM; + for( k = 0; k < allnum; k ++ ){ + if( charaindex[i] == work )break; + } + if( i < allnum )continue; + charaindex[i] = work; + allnum ++; + } + charaindex[i] = -1; + + for( j = 0; j < 2; j ++ ){ + pEntryEnemy = BattleArray[battleindex].Side[j].Entry; + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + int enemytype = 0; + enemyindex = pEntryEnemy[i].charaindex; + if( CHAR_CHECKINDEX( enemyindex ) == FALSE )continue; + if( CHAR_getInt( enemyindex, CHAR_HP ) <= 0 + && CHAR_getFlg( enemyindex, CHAR_ISDIE ) == FALSE){ + }else{ + continue; + } + enemytype = CHAR_getInt( enemyindex, CHAR_WHICHTYPE ); + if( enemytype == CHAR_TYPEPLAYER ){ + BattleArray[battleindex].flg |= BATTLE_FLG_CHARALOST; + } + if( enemytype == CHAR_TYPEPLAYER || enemytype == CHAR_TYPEENEMY ){ + int dpadd, dpnow; + dpnow = CHAR_getInt( enemyindex, CHAR_DUELPOINT ); + dpadd = dpnow * DUELPOINT_RATE; + dpnow -= dpadd; + CHAR_setWorkInt( enemyindex, CHAR_WORKGETEXP, + CHAR_getWorkInt( enemyindex, CHAR_WORKGETEXP) - dpadd ); + + if( side != j ){ + for( k = 0; charaindex[k] != -1; k ++ ); + if( k <= 0 )k = 1; + dpadd /= k; + if( dpadd <= 0 ) dpadd = 1; + for( k = 0; charaindex[k] != -1; k ++ ){ + CHAR_setWorkInt( charaindex[k], CHAR_WORKGETEXP, + CHAR_getWorkInt( charaindex[k], CHAR_WORKGETEXP ) + dpadd ); + } + }else{ + int dpdiv = dpadd, alive; + alive = BATTLE_CountAlive( battleindex, 1-j ); + if( alive <= 0 )alive = 1; + dpdiv /= alive; + if( dpdiv <= 0 )dpdiv = 1; + BATTLE_AddDpAlive( battleindex, 1-j, dpdiv ); + } + } + CHAR_setFlg( enemyindex, CHAR_ISDIE, 1 ); + CHAR_setInt( enemyindex, CHAR_DEADCOUNT, + CHAR_getInt( enemyindex, CHAR_DEADCOUNT ) + 1 ); + + if( pEntryEnemy[i].flg & BENT_FLG_ULTIMATE ){ + BATTLE_GetProfit( battleindex, j, i ); + BATTLE_UltimateExtra( battleindex, charaindex[0], enemyindex ); + }else{ + BATTLE_NormalDeadExtra( battleindex, charaindex[0], enemyindex ); + } + } + } + return 0; +} +#else + +int BATTLE_AddDuelPoint( + int battleindex, + int *pBidList ) +{ + int enemyindex, i, otherside, j, + charaindex[BATTLE_ENTRY_MAX+1]; + BATTLE_ENTRY + *pEntryEnemy; + if( pBidList < 0 )return BATTLE_ERR_PARAM; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + for( j = 0; j < 2; j ++ ){ + pEntryEnemy = BattleArray[battleindex].Side[j].Entry; + otherside = 1 - j; + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + enemyindex = pEntryEnemy[i].charaindex; + if( CHAR_CHECKINDEX( enemyindex ) == FALSE )continue; + if( CHAR_getInt( enemyindex, CHAR_HP ) <= 0 + && CHAR_getFlg( enemyindex, CHAR_ISDIE ) == FALSE){ + }else{ + continue; + } + + CHAR_setFlg( enemyindex, CHAR_ISDIE, 1 ); + CHAR_setInt( enemyindex, CHAR_DEADCOUNT, + CHAR_getInt( enemyindex, CHAR_DEADCOUNT ) + 1 ); + if( pEntryEnemy[i].flg & BENT_FLG_ULTIMATE ){ + if( CHAR_getInt( enemyindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + int dpadd, dpnow; + dpnow = CHAR_getInt( enemyindex, CHAR_DUELPOINT ); + dpadd = dpnow * DUELPOINT_RATE; // ㄠㄟ坌及ㄠ手日尹月 + dpnow -= dpadd; + CHAR_setWorkInt( enemyindex, CHAR_WORKGETEXP, + CHAR_getWorkInt( enemyindex, CHAR_WORKGETEXP) - dpadd ); + BattleArray[battleindex].Side[otherside].common_dp += dpadd; + BATTLE_GetProfit( battleindex, j, i ); + } + BATTLE_UltimateExtra( battleindex, charaindex[0], enemyindex ); + }else{ + BATTLE_NormalDeadExtra( battleindex, charaindex[0], enemyindex ); + } + } + } + return 0; +} +#endif + +int BATTLE_ItemDelCheck( int itemindex ) +{ int icnt, jcnt, playernum; + playernum = getFdnum(); + for( icnt = 0; icnt < playernum; icnt ++ ) { + if( CHAR_CHECKINDEX( icnt ) ) { + for( jcnt = 0; jcnt < CHAR_MAXITEMHAVE; jcnt ++ ) { + if( CHAR_getItemIndex( icnt, jcnt ) == itemindex ) { + print( "err:战利品奇怪的item处理(%s)(%s)index(%d)\n", + CHAR_getUseName(icnt),ITEM_getAppropriateName(itemindex), + itemindex ); + return FALSE; + } + } + } + } + return TRUE; +} + +int BATTLE_AddExpItem( int battleindex, int *pBidList ) +{ + int enemyindex, i, side, num, proflg = 1, j, exp, k, enemylevel, + charaindex[BATTLE_ENTRY_MAX+1]; + BATTLE_ENTRY + *pEntryEnemy, + *pEntryChara[BATTLE_ENTRY_MAX+1], + *pEntryPlayer[BATTLE_ENTRY_MAX+1]; + int item=0,itemindex,itemloop,allnum = 0; + int bid = pBidList[0]; + if( pBidList[0] < 0 )return BATTLE_ERR_PARAM; + if( bid >= SIDE_OFFSET ){ + num = bid - SIDE_OFFSET; + side = 1; + }else{ + num = bid ; + side = 0; + } + if( BATTLE_CHECKSIDE( side ) == FALSE )return BATTLE_ERR_PARAM; + if( num < 0 || num >= BATTLE_ENTRY_MAX )return BATTLE_ERR_PARAM; + for( i = 0; i < BATTLE_ENTRY_MAX + 1 ; i ++ ){ + charaindex[i] = -1; + pEntryPlayer[i] = NULL; + } + if( BattleArray[battleindex].Side[side].type != BATTLE_S_TYPE_PLAYER + || BattleArray[battleindex].Side[1-side].type == BATTLE_S_TYPE_PLAYER){ + proflg = 0; + } + for( i = 0; i < BATTLE_ENTRY_MAX && pBidList[i] != -1 ; i ++ ){ + int subnum; + charaindex[i] = BATTLE_No2Index( battleindex, pBidList[i] ); + if( charaindex[i] < 0 )return BATTLE_ERR_PARAM; + subnum = pBidList[i]-side*SIDE_OFFSET; + pEntryChara[i] = &BattleArray[battleindex].Side[side].Entry[subnum]; + if( CHAR_getInt( charaindex[i], CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + pEntryPlayer[i] = &BattleArray[battleindex].Side[side].Entry[subnum-5]; + }else{ + pEntryPlayer[i] = pEntryChara[i]; + } + } + charaindex[i] = -1; + allnum = i; + for( j = 0; j < 2; j ++ ){ + pEntryEnemy = BattleArray[battleindex].Side[j].Entry; + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + enemyindex = pEntryEnemy[i].charaindex; + if( CHAR_CHECKINDEX( enemyindex ) == FALSE )continue; + + if( CHAR_getInt( enemyindex, CHAR_HP ) <= 0 + && CHAR_getFlg( enemyindex, CHAR_ISDIE ) == FALSE ){ + }else{ + continue; + } + if( proflg == 1 && side != j ){ + if( CHAR_getInt( enemyindex, CHAR_WHICHTYPE ) != CHAR_TYPEENEMY ){ + print( "\nerr: 夺取敌人以外的战利品(%s:%d)\n", + __FILE__, __LINE__ ); + } + for(item=CHAR_STARTITEMARRAY; item < CHAR_STARTITEMARRAY+10; item++){ + itemindex = CHAR_getItemIndex( enemyindex, item ); + if(ITEM_CHECKINDEX( itemindex ) == FALSE ){ + continue; + } + if( ITEM_getWorkInt( itemindex, ITEM_WORKCHARAINDEX ) <= getFdnum() ){ + print( "\nerr: 将玩家的item当做战利品(%s:%d)\n", + __FILE__, __LINE__ ); + continue; + } + CHAR_setItemIndex( enemyindex, item, -1 ); + k = RAND( 0, (allnum-1) ); + for(itemloop=0;itemloop<3;itemloop++){ + if(pEntryPlayer[k]->getitem[itemloop]==-1){ + pEntryPlayer[k]->getitem[itemloop]=itemindex; + break; + } + } + if( itemloop >= 3 ){ + if( RAND( 0, 1 ) ) { + int olditem; + int randwork = RAND( 0, 2 ); + olditem = pEntryPlayer[k]->getitem[randwork]; + pEntryPlayer[k]->getitem[randwork]=itemindex; + if( BATTLE_ItemDelCheck( olditem ) == TRUE ){ + ITEM_endExistItemsOne(olditem); + } + }else { + ITEM_endExistItemsOne(itemindex); + } + } + + } + +#define EXPGET_MAXLEVEL 5 +#define EXPGET_DIV 15 + exp = CHAR_getInt( enemyindex, CHAR_EXP ); + enemylevel = CHAR_getInt( enemyindex, CHAR_LV ); + for( k = 0; charaindex[k] != -1; k ++ ){ + int nowexp, b_level; + int ridepet; + b_level = CHAR_getInt( charaindex[k], CHAR_LV ) - enemylevel; + if( b_level <= EXPGET_MAXLEVEL ){//如 人物大怪物5以下 或怪物大於人物 + nowexp = exp; + }else{//如果人物大於怪物5以上 + b_level = EXPGET_MAXLEVEL+EXPGET_DIV - b_level; + if( b_level > EXPGET_DIV ) b_level = EXPGET_DIV; + if( b_level <= 0 ){ + nowexp = 1; + }else{ + nowexp = exp * b_level / EXPGET_DIV; + } + if( nowexp < 1 ) nowexp = 1; + } + CHAR_setWorkInt( charaindex[k], CHAR_WORKGETEXP, + CHAR_getWorkInt( charaindex[k], CHAR_WORKGETEXP ) + nowexp ); + CHAR_setInt( charaindex[k], CHAR_KILLPETCOUNT, + CHAR_getInt( charaindex[k], CHAR_KILLPETCOUNT ) + 1 ); + ridepet = BATTLE_getRidePet( charaindex[k] ); + //andy_edit + if( CHAR_CHECKINDEX( ridepet) ){ + int nowexp, b_level; + b_level = CHAR_getInt( ridepet, CHAR_LV ) - enemylevel; + if( b_level <= EXPGET_MAXLEVEL ){ + nowexp = exp; + }else{ + b_level = EXPGET_MAXLEVEL+EXPGET_DIV - b_level; + if( b_level > EXPGET_DIV ) b_level = EXPGET_DIV; + if( b_level <= 0 ){ + nowexp = 1; + }else{ + nowexp = exp * b_level / EXPGET_DIV; + } + if( nowexp < 1 ) nowexp = 1; + } + nowexp *= 0.6; + CHAR_setWorkInt( ridepet, CHAR_WORKGETEXP, + CHAR_getWorkInt( ridepet, CHAR_WORKGETEXP ) + nowexp ); + CHAR_setInt( ridepet, CHAR_KILLPETCOUNT, + CHAR_getInt( ridepet, CHAR_KILLPETCOUNT ) + 1 ); + } + if( BattleArray[battleindex].norisk == 0 + && CHAR_getInt( charaindex[k], CHAR_WHICHTYPE ) == CHAR_TYPEPET){ + if( CHAR_getInt( enemyindex, CHAR_LV ) > CHAR_getInt( charaindex[k], CHAR_LV ) ){ + CHAR_PetAddVariableAi( charaindex[k], AI_FIX_PETGOLDWIN ); + }else{ + CHAR_PetAddVariableAi( charaindex[k], AI_FIX_PETWIN ); + } + } + } + CHAR_setMaxExp( enemyindex, 0); + } + CHAR_setFlg( enemyindex, CHAR_ISDIE, 1 ); +#ifdef _PET_LIMITLEVEL + Pet_Check_Die( enemyindex ); +#endif + CHAR_setInt( enemyindex, CHAR_DEADCOUNT, + CHAR_getInt( enemyindex, CHAR_DEADCOUNT ) + 1 ); + if( pEntryEnemy[i].flg & BENT_FLG_ULTIMATE ){ + BATTLE_UltimateExtra( battleindex, charaindex[0], enemyindex ); + }else{ + BATTLE_NormalDeadExtra( battleindex, charaindex[0], enemyindex ); + } + } + } + return 0; +} + +#ifdef _PET_LIMITLEVEL +void Pet_Check_Die( int petindex ) +{ + + int LevelUpPoint; + int vital, str, tgh, dex; + float modai; + +#define RAND(x,y) ((x-1)+1+ (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) ) + //玛宠死亡 扣基本属性及忠诚 + if( CHAR_getInt( petindex, CHAR_PETID) == 718 ) { + LevelUpPoint = CHAR_getInt( petindex, CHAR_ALLOCPOINT ); + vital = (( LevelUpPoint >> 24 ) & 0xff); + str = (( LevelUpPoint >> 16 ) & 0xff); + tgh = (( LevelUpPoint >> 8 ) & 0xff); + dex = (( LevelUpPoint >> 0 ) & 0xff); +// enemyindex = pEntryEnemy[i].charaindex; + + print("\n lvup <<%d %d %d %d>>", vital, str, tgh, dex ); + + vital = vital - RAND( 1, 8); + str = str - RAND( 1, 4); + tgh = tgh - RAND( 1, 4); + dex = dex - RAND( 1, 4); + print("\n lvup <<%d %d %d %d>>", vital, str, tgh, dex ); + + if( vital < 0 ) vital = 0; + if( str < 0 ) str = 0; + if( tgh < 0 ) tgh = 0; + if( dex < 0 ) dex = 0; + + if( vital > 50 ) vital = 50; + if( str > 50 ) str = 50; + if( tgh > 50 ) tgh = 50; + if( dex > 50 ) dex = 50; + LevelUpPoint = ( vital << 24 ) + ( str << 16 ) + ( tgh << 8 ) + ( dex << 0 ); + CHAR_setInt( petindex, CHAR_ALLOCPOINT , LevelUpPoint ); + print("\n lvup <<%d %d %d %d>>", vital, str, tgh, dex ); + modai = CHAR_getInt( petindex, CHAR_MODAI ); + modai = modai - ( (modai * 5) / 100 ); + CHAR_setInt( petindex, CHAR_MODAI, modai); + + LogPetPointChange( + CHAR_getChar( petindex, CHAR_OWNERCHARANAME), + CHAR_getChar( petindex, CHAR_OWNERCDKEY), + CHAR_getChar( petindex, CHAR_NAME), + petindex, 2, + CHAR_getInt( petindex, CHAR_LV), + "battle_die(战斗死亡)", + CHAR_getInt( petindex,CHAR_FLOOR), + 0, + 0 + ); + } + return; + +} +#endif + +int BATTLE_AddProfit( int battleindex, int *pBidList) +{ + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + + if( BattleArray[battleindex].dpbattle == 1 ){ + return BATTLE_AddDuelPoint( battleindex, pBidList ); + }else{ + return BATTLE_AddExpItem( battleindex, pBidList ); + } + +} + +int BATTLE_TargetCheck( + int battleindex, + int defNo +) +{ + int defindex = BATTLE_No2Index( battleindex, defNo ); + + if( CHAR_CHECKINDEX( defindex ) == FALSE + || CHAR_getWorkInt( defindex, CHAR_WORKBATTLEMODE ) == 0 + || CHAR_getFlg( defindex, CHAR_ISDIE ) == TRUE + || CHAR_getInt( defindex, CHAR_HP ) <= 0 + || CHAR_getFlg( defindex, CHAR_ISATTACKED ) == FALSE + || CHAR_getWorkInt( defindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_RESCUE + ){ + return FALSE; + } + return TRUE; +} + +int BATTLE_TargetCheckDead( + int battleindex, + int defNo +) +{ + int defindex = BATTLE_No2Index( battleindex, defNo ); + if( CHAR_CHECKINDEX( defindex ) == FALSE + || CHAR_getWorkInt( defindex, CHAR_WORKBATTLEMODE ) == 0 + || CHAR_getWorkInt( defindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_RESCUE + || CHAR_getFlg( defindex, CHAR_ISATTACKED ) == FALSE + || CHAR_getFlg( defindex, CHAR_ISDIE ) == FALSE ){ + //BATTLE_CHARMODE_RESCUE 5 + print("\n [ %d, %d, %d, %d]", + CHAR_getWorkInt( defindex, CHAR_WORKBATTLEMODE ), + CHAR_getWorkInt( defindex, CHAR_WORKBATTLEMODE ), + CHAR_getFlg( defindex, CHAR_ISATTACKED ), + CHAR_getFlg( defindex, CHAR_ISDIE )); + return FALSE; + } + return TRUE; +} + + + + +int BATTLE_TargetAdjust( int battleindex, int charaindex, int myside ) +{ + int defNo; + + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + + if( BATTLE_TargetCheck( battleindex, defNo ) == FALSE ){ + defNo = BATTLE_DefaultAttacker( battleindex, 1 - myside ); + } + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, defNo ); + + return defNo; +} + +void Compute_Down( int charaindex, int rideindex, int *down1, int *down2, int flg) +{ + int hp=0, pethp=0; + int downs = 0; + + *down1 = 0; + *down2 = 0; + //人物 + downs = + CHAR_getInt( charaindex, CHAR_VITAL ) + + CHAR_getInt( charaindex, CHAR_STR ) + + CHAR_getInt( charaindex, CHAR_DEX ) + + CHAR_getInt( charaindex, CHAR_TOUGH ); + if( (downs = (((downs/100)-20)/4)) < 1 ) + downs = 1; + hp = CHAR_getInt( charaindex, CHAR_HP ); + if( hp <= downs ) downs = hp - 1; + if( downs >= 0 ){ + hp = ((hp-downs)<1)?1:(hp-downs); + CHAR_setInt( charaindex, CHAR_HP, hp ); + *down1 = downs; + } + if( flg == -1 ) { + }else {//骑乘宠物 + if( !CHAR_CHECKINDEX( rideindex)) return; + downs = + CHAR_getInt( rideindex, CHAR_VITAL ) + + CHAR_getInt( rideindex, CHAR_STR ) + + CHAR_getInt( rideindex, CHAR_DEX ) + + CHAR_getInt( rideindex, CHAR_TOUGH ); + if( (downs = (((downs/100)-20)/4)) < 1 ) + downs = 1; + pethp = CHAR_getInt( rideindex, CHAR_HP ); + if( pethp <= downs ) downs = pethp - 1; + if( downs >= 0 ){ + pethp = ((pethp-downs)<1)?1:(pethp-downs); + + CHAR_setInt( rideindex, CHAR_HP, pethp); + *down2 = downs; + } + } +} + +#ifdef _PET_SKILL_SARS // WON ADD 毒煞蔓延 +void Compute_Down_SARS( int charaindex, int rideindex, int *down1, int *down2, int flg) +{ + int hp=0, pethp=0; + int downs = 0; + + *down1 = 0; + *down2 = 0; + //人物 +/* + downs = + CHAR_getInt( charaindex, CHAR_VITAL ) + + CHAR_getInt( charaindex, CHAR_STR ) + + CHAR_getInt( charaindex, CHAR_DEX ) + + CHAR_getInt( charaindex, CHAR_TOUGH ); + if( (downs = (((downs/100)-20)/4)) < 1 ) + downs = 1; +*/ + + hp = CHAR_getInt( charaindex, CHAR_HP ); + downs = hp * 10 / 100; + + if( hp <= downs ) downs = hp - 1; + if( downs >= 0 ){ + hp = ((hp-downs)<1)?1:(hp-downs); + CHAR_setInt( charaindex, CHAR_HP, hp ); + *down1 = downs; + } + if( flg == -1 ) { + }else {//骑乘宠物 + if( !CHAR_CHECKINDEX( rideindex)) return; + downs = + CHAR_getInt( rideindex, CHAR_VITAL ) + + CHAR_getInt( rideindex, CHAR_STR ) + + CHAR_getInt( rideindex, CHAR_DEX ) + + CHAR_getInt( rideindex, CHAR_TOUGH ); + if( (downs = (((downs/100)-20)/4)) < 1 ) + downs = 1; + pethp = CHAR_getInt( rideindex, CHAR_HP ); + if( pethp <= downs ) downs = pethp - 1; + if( downs >= 0 ){ + pethp = ((pethp-downs)<1)?1:(pethp-downs); + + CHAR_setInt( rideindex, CHAR_HP, pethp); + *down2 = downs; + } + } +} +#endif + +#ifdef _PROFESSION_ADDSKILL +void WorkIceCrackPlay(int charaindex, int cnt, int workicecracknum ) +{ + char szBuffer[256]=""; + int i,value=0; + int battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + int defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 );//defNo = BATTLE_Index2No( battleindex, charaindex ); + int ridepet = BATTLE_getRidePet( charaindex ); + int bid = BATTLE_Index2No( battleindex, charaindex ); + value = CHAR_getWorkInt( charaindex, workicecracknum ); + + if( cnt <= 0 && value > 0 ){ + int damage=0, petdamage=0; + + int ToList[SIDE_OFFSET*2+1]; + memset( ToList, -1, sizeof( ToList)); + BATTLE_MultiList( battleindex, TARGET_SIDE_1, ToList ); + // 将魔法参数代入动画 + analysis_profession_parameter( 2, 4, defNo, charaindex ); + PROFESSION_MAGIC_ATTAIC_Effect( battleindex, bid, ToList, 2); + + if( defNo == 20 || defNo == 25 || defNo == 26 )//右 + bid = 0; + else + bid = 10; + + + for( i = bid ; i < bid+10 ; i++ ) { + int defType, charaidx, petidx; + charaidx = BATTLE_No2Index( battleindex , i); + if( CHAR_CHECKINDEX( charaidx ) ){ + if( CHAR_getInt( charaidx, CHAR_HP ) > 0 ){ + int hp,pethp = 0; + petidx = BATTLE_getRidePet( charaidx ); + defType = CHAR_getInt(charaidx, CHAR_WHICHTYPE); + CHAR_setWorkInt( charaidx, workicecracknum, 0 ); + + damage = value; + + hp = CHAR_getInt( charaidx, CHAR_HP ); + if( petidx == -1 ) { + hp -= damage; + if( hp < 0 ) hp = 0; + }else { + int defquick=0, petquick=0, playerdamage=0; + pethp = CHAR_getInt( petidx, CHAR_HP ); + defquick = CHAR_getWorkInt( charaidx, CHAR_WORKDEFENCEPOWER ); + petquick = CHAR_getWorkInt( petidx, CHAR_WORKDEFENCEPOWER ); + if( pethp > 0 ){ + playerdamage = (damage*petquick)/(defquick+petquick) +1; + petdamage = damage - playerdamage +1 ; + hp -= playerdamage; + pethp -= petdamage; + }else{ + hp -= damage; + } + if( hp < 0 ) hp = 0; + if( pethp < 0 ) pethp = 0; + CHAR_setInt( petidx, CHAR_HP, pethp ); + } + + CHAR_setInt( charaidx, CHAR_HP, hp ); + + if( hp <= 0 ){ + CHAR_setFlg( charaidx, CHAR_ISDIE, 1 ); + CHAR_setWorkInt( charaidx, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + if( pethp <= 0 ){ + CHAR_setFlg( petidx, CHAR_ISDIE, 1 ); + CHAR_setWorkInt( ridepet, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + + + if( damage >= 0 ){ + sprintf( szBuffer , "%X|%X|%X|%X|" , i , i ,(int)(damage) , (int)(petdamage)); + BATTLESTR_ADD( szBuffer ); + } + if( petidx != -1 && petdamage >= 0 ){ + + } + } + } + } + sprintf( szBuffer , "%X|" , 0x5711438 ); + BATTLESTR_ADD( szBuffer ); + } +} +#endif + +static int BATTLE_StatusSeq( int charaindex ) +{ + int cnt, i, bid, battleindex, down; + char szBuffer[256]=""; +#ifdef _MAGIC_DEEPPOISON + int defNo,defindex=0; + char szCommand[1024]; +#endif + int ridepet = BATTLE_getRidePet( charaindex ); + int hp=0, pethp=0; + + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + +#ifdef _MAGIC_DEEPPOISON + defNo = BATTLE_Index2No( battleindex, charaindex ); + defindex = BATTLE_No2Index( battleindex, defNo ); +#endif + bid = BATTLE_Index2No( battleindex, charaindex ); + if( BATTLE_CanMoveCheck( charaindex ) == FALSE ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + + for( i = 1; i < BATTLE_ST_END; i++ ){ + if( ( cnt = CHAR_getWorkInt( charaindex, StatusTbl[i] )) <= 0 )continue; + CHAR_setWorkInt( charaindex, StatusTbl[i], --cnt ); +#ifdef _MAGIC_WEAKEN // 虚弱 + if(CHAR_getWorkInt(charaindex,CHAR_WORKWEAKEN) > 0) + CHAR_setWorkInt( charaindex, StatusTbl[i], cnt+1 ); +#endif +#ifdef _MAGIC_BARRIER// vincent 精灵:魔障 + if(CHAR_getWorkInt(charaindex,CHAR_WORKBARRIER) > 0) + CHAR_setWorkInt( charaindex, StatusTbl[i], cnt+1 ); +#endif + + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + if( cnt <= 0 && ( StatusTbl[i] != CHAR_WORKICECRACK ) +#ifdef _PROFESSION_ADDSKILL + && ( StatusTbl[i] != CHAR_WORKICECRACK2 ) + && ( StatusTbl[i] != CHAR_WORKICECRACK3 ) + && ( StatusTbl[i] != CHAR_WORKICECRACK4 ) + && ( StatusTbl[i] != CHAR_WORKICECRACK5 ) + && ( StatusTbl[i] != CHAR_WORKICECRACK6 ) + && ( StatusTbl[i] != CHAR_WORKICECRACK7 ) + && ( StatusTbl[i] != CHAR_WORKICECRACK8 ) + && ( StatusTbl[i] != CHAR_WORKICECRACK9 ) + && ( StatusTbl[i] != CHAR_WORKICECRACK10 ) +#endif + ){ // 冰爆术 +#else + if( cnt <= 0 ){ +#endif + BATTLE_BadStatusString( bid, 0 ); + //snprintf( szBuffer, sizeof( szBuffer ), "(%s)将(%s)修理完毕。", + // CHAR_getUseName( charaindex ), aszStatusFull[i] ); + // BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; +//Terry del +// sprintf( szBuffer, "BM|%X|%X|", bid, 0 ); +// BATTLESTR_ADD( szBuffer ); +#ifdef _MAGIC_NOCAST + if( StatusTbl[i] == CHAR_WORKNOCAST ){ + lssproto_NC_send( getfdFromCharaIndex( charaindex ), 0);//复原 + } +#endif + if( StatusTbl[i] == CHAR_WORKDRUNK ){ + if( ridepet != -1 ){ + CHAR_setWorkInt( charaindex, CHAR_WORKQUICK, + CHAR_getWorkInt( charaindex, CHAR_WORKQUICK ) + + CHAR_getWorkInt( ridepet, CHAR_WORKQUICK ) ); + }else{ + CHAR_setWorkInt( charaindex, CHAR_WORKQUICK, + CHAR_getWorkInt( charaindex, CHAR_WORKQUICK ) * 2 ); + } + } + continue; + } + + switch( StatusTbl[i] ){ + + case CHAR_WORKPOISON: + { + int petdown=-1; + Compute_Down( charaindex, ridepet, &down, &petdown, ridepet); + if( down >= 0 ){ + //snprintf( szBuffer, sizeof( szBuffer ), + // "(%s)因(%s)受到(%d)的损伤。", + // CHAR_getUseName( charaindex ), + // aszStatusFull[i], + // down ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + +#ifdef _NOTRIDE_ + sprintf( szBuffer, "BD|r%X|0|0|%X|", bid, (int)(down) ); + BATTLESTR_ADD( szBuffer ); +#else + sprintf( szBuffer, "BD|r%X|0|0|%X|p%X|", bid, (int)(down), (int)(petdown) ); + BATTLESTR_ADD( szBuffer ); +#endif + } + if( ridepet != -1 && petdown >= 0 ){ + //snprintf( szBuffer, sizeof( szBuffer ), + // "(%s的骑宠)因(%s)受到(%d)的损伤。", + // CHAR_getUseName( charaindex ), + // aszStatusFull[i], petdown ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + } + } + break; +#ifdef _MAGIC_DEEPPOISON + case CHAR_WORKDEEPPOISON: + if(CHAR_getInt( defindex, CHAR_HP ) <= 1){ + snprintf( szCommand, sizeof( szCommand ),"Bd|a%X|r%X|f%X|d%X|p%X|FF|",defNo,defNo,BCF_NORMAL,1, 0 ); + BATTLESTR_ADD( szCommand ); + CHAR_setInt( defindex, CHAR_HP,0); + CHAR_setWorkInt( defindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + CHAR_setFlg( defindex, CHAR_ISDIE, 1 ); + break; + } + + if(CHAR_getWorkInt( defindex, CHAR_WORKDEEPPOISON) <= 1){ + snprintf( szCommand, sizeof( szCommand ),"Bd|a%X|r%X|f%X|d%X|p%X|FF|",defNo,defNo,BCF_NORMAL,CHAR_getInt( charaindex, CHAR_HP), 0 ); + BATTLESTR_ADD( szCommand ); + CHAR_setInt( defindex, CHAR_HP,0); + CHAR_setFlg( defindex, CHAR_ISDIE, 1 ); + CHAR_setWorkInt( defindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + sprintf(szBuffer, "%s身中剧毒未解而阵亡了!!", CHAR_getChar( defindex, CHAR_NAME )); + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + CHAR_talkToCli( CHAR_getWorkInt(defindex, CHAR_WORKPLAYERINDEX), -1, szBuffer, CHAR_COLORYELLOW); + }else{ + CHAR_talkToCli( defindex, -1, szBuffer, CHAR_COLORYELLOW); + } + break; + } + if( ridepet == -1 ){// Robin 0728 ride Pet + down = + CHAR_getInt( charaindex, CHAR_VITAL ) + + CHAR_getInt( charaindex, CHAR_STR ) + + CHAR_getInt( charaindex, CHAR_DEX ) + + CHAR_getInt( charaindex, CHAR_TOUGH ); + down = ( down / 100 - 20 ) / 4; + if( down < 1 ) down = 1; + hp = CHAR_getInt( charaindex, CHAR_HP ); + if( hp <= down ) down = hp - 1; + if( down >= 0 ){ + CHAR_setInt( charaindex, CHAR_HP, hp - down ); + //snprintf( szBuffer, sizeof( szBuffer ), + // "(%s)因(%s)受到(%d)的损伤。", + // CHAR_getUseName( charaindex ), + // aszStatusFull[i], + // down ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; +#ifdef _NOTRIDE_ + sprintf( szBuffer, "BD|r%X|0|0|%X|", bid, (int)(down) ); + BATTLESTR_ADD( szBuffer ); +#else + sprintf( szBuffer, "BD|r%X|0|0|%X|p%X|", bid, (int)(down), 0 ); + BATTLESTR_ADD( szBuffer ); +#endif + } + break; + }else { + int petdown; + down = + CHAR_getInt( charaindex, CHAR_VITAL ) + + CHAR_getInt( charaindex, CHAR_STR ) + + CHAR_getInt( charaindex, CHAR_DEX ) + + CHAR_getInt( charaindex, CHAR_TOUGH ); + petdown = + CHAR_getInt( ridepet, CHAR_VITAL ) + + CHAR_getInt( ridepet, CHAR_STR ) + + CHAR_getInt( ridepet, CHAR_DEX ) + + CHAR_getInt( ridepet, CHAR_TOUGH ); + down = ( down / 100 - 20 ) / 4; + petdown = ( petdown / 100 - 20 ) /4; + if( down < 1 ) down = 1; + if( petdown < 1 ) petdown = 1; + hp = CHAR_getInt( charaindex, CHAR_HP ); + pethp = CHAR_getInt( ridepet, CHAR_HP ); + if( hp <= down ) down = hp - 1; + if( pethp <= petdown ) petdown = pethp - 1; + if( down >= 0 ){ + CHAR_setInt( charaindex, CHAR_HP, hp - down ); + //snprintf( szBuffer, sizeof( szBuffer ), + // "(%s)因(%s)受到(%d)的损伤。", + // CHAR_getUseName( charaindex ), + // aszStatusFull[i], + // down ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + #ifdef _NOTRIDE_ + sprintf( szBuffer, "BD|r%X|0|0|%X|", bid, (int)(down) ); + BATTLESTR_ADD( szBuffer ); + #else + sprintf( szBuffer, "BD|r%X|0|0|%X|p%X|", bid, (int)(down), (int)(petdown) ); + BATTLESTR_ADD( szBuffer ); + #endif + } + if( petdown >= 0 ){ + CHAR_setInt( ridepet, CHAR_HP, pethp - petdown ); + //snprintf( szBuffer, sizeof( szBuffer ), + // "(%s的骑宠)因(%s)受到(%d)的损伤。", + // CHAR_getUseName( charaindex ), + // aszStatusFull[i], + // petdown ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + } + break; + } +#endif +#ifdef _MAGIC_NOCAST // 精灵:沉默 + case CHAR_WORKNOCAST: + lssproto_NC_send( getfdFromCharaIndex( charaindex ), 1);//沉默 + break; +#endif + case CHAR_WORKCONFUSION: + { int side, pos, defNo, lop; + if( RAND( 1, 100 ) > 80 ){ + break; + } + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + side = RAND( 0, 1 ); + pos = RAND( 0, 9 ); + for( lop = 0; lop < SIDE_OFFSET; lop ++ ){ + if( ++pos >= SIDE_OFFSET )pos = 0; + defNo = side * SIDE_OFFSET + pos; + if( defNo == bid ) continue; + if( BATTLE_TargetCheck( battleindex, defNo ) == TRUE ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, defNo ); + break; + } + } + if( lop >= SIDE_OFFSET ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, -1 ); + } + } + break; +#ifdef _PROFESSION_ADDSKILL + case CHAR_WORKANNEX://附身术 + { int side, pos, defNo, lop; + + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + side = RAND( 0, 1 ); + pos = RAND( 0, 9 ); + for( lop = 0; lop < SIDE_OFFSET; lop ++ ){ + if( ++pos >= SIDE_OFFSET )pos = 0; + defNo = side * SIDE_OFFSET + pos; + if( defNo == bid ) continue; + if( BATTLE_TargetCheck( battleindex, defNo ) == TRUE ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, defNo ); + break; + } + } + if( lop >= SIDE_OFFSET ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, -1 ); + } + + } + break; +#endif + case CHAR_WORKDRUNK: + break; + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + case CHAR_WORKOBLIVION: // 遗忘 + { + // 恢复技能 + if( cnt <= 1 ){ + int defNo = BATTLE_Index2No( battleindex, charaindex ); + int toNo = defNo - 5; + int toNoindex = -1, pet_no = -1; + char msg[20]; + + memset( msg, -1, sizeof(msg) ); + + // 主人index + toNoindex = BATTLE_No2Index( battleindex, toNo ); + CHAR_setWorkInt(charaindex, StatusTbl[BATTLE_ST_OBLIVION], 0 ); + + // 宠物编号 + pet_no = CHAR_getInt( toNoindex, CHAR_DEFAULTPET ); + sprintf( msg, "W%d", pet_no ); + + CHAR_sendStatusString( toNoindex, msg ); + + + BATTLE_BadStatusString( bid, 0 ); + sprintf( szBuffer, "BM|%X|%X|", bid, 0 ); + BATTLESTR_ADD( szBuffer ); + } + break; + } + case CHAR_WORK_F_ENCLOSE: // 火附体 + { + int ToList[SIDE_OFFSET*2+1]; + int defNo = BATTLE_Index2No( battleindex, charaindex ); + int old_hp = CHAR_getInt( charaindex, CHAR_HP ); + int dec_hp = 0, hp = 0; + int DAMAGE = 50; + + memset( ToList, -1, sizeof( ToList)); + BATTLE_MultiList( battleindex, defNo, ToList ); + BATTLE_MagicEffect( battleindex, defNo, ToList, 101699, 101699 ); + + // 取魔法伤害值 + DAMAGE = DAMAGE * cnt; +#ifdef _PROFESSION_ADDSKILL + dec_hp = PROFESSION_MAGIC_GET_DAMAGE( charaindex, charaindex, 1, DAMAGE, 0); +#else + dec_hp = PROFESSION_MAGIC_GET_DAMAGE( charaindex, charaindex, 1, DAMAGE ); +#endif + hp = old_hp - dec_hp; + + if( hp <= 0 ){ + CHAR_setInt( charaindex, CHAR_HP, 0 ); + CHAR_setFlg( charaindex, CHAR_ISDIE, 1 ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + }else{ + CHAR_setInt( charaindex, CHAR_HP, hp ); + } + + sprintf( szCommand, "BD|r%X|0|0|%X|", defNo, dec_hp ); + BATTLESTR_ADD( szCommand ); + + break; + } + case CHAR_WORK_I_ENCLOSE: // 冰附体 + { + int old_dex = CHAR_getInt( charaindex, CHAR_DEX ); + int dex = 0; + int ToList[SIDE_OFFSET*2+1]; + int defNo = BATTLE_Index2No( battleindex, charaindex ); + + memset( ToList, -1, sizeof( ToList)); + BATTLE_MultiList( battleindex, defNo, ToList ); + BATTLE_MagicEffect( battleindex, defNo, ToList, 27692, 101700 ); + + dex = old_dex * 0.9; + CHAR_setWorkInt(charaindex,CHAR_WORKFIXDEX, dex ); + sprintf( szCommand, "BD|r%X|0|6|%X|", defNo, (-1) * (int)((old_dex * 0.1) / 100) ); + BATTLESTR_ADD( szCommand ); + + break; + } + case CHAR_WORKRESIST_F: // 火抗性提升 + { + // 恢复抗性 + if( cnt <= 1 ){ + int add_value = 0; + int old_value = 0; + old_value = CHAR_getWorkInt( charaindex, CHAR_WORK_F_RESIST ); + add_value = CHAR_getWorkInt( charaindex, CHAR_WORKMODRESIST_F ); + + CHAR_setWorkInt( charaindex, CHAR_WORK_F_RESIST, old_value - add_value ); + CHAR_talkToCli( charaindex, -1 , "火抗性恢复" , CHAR_COLORYELLOW ); + } + break; + } + case CHAR_WORKRESIST_I: // 冰抗性提升 + { + // 恢复抗性 + if( cnt <= 1 ){ + int add_value = 0; + int old_value = 0; + old_value = CHAR_getWorkInt( charaindex, CHAR_WORK_I_RESIST ); + add_value = CHAR_getWorkInt( charaindex, CHAR_WORKMODRESIST_I ); + + CHAR_setWorkInt( charaindex, CHAR_WORK_I_RESIST, old_value - add_value ); + CHAR_talkToCli( charaindex, -1 , "冰抗性恢复" , CHAR_COLORYELLOW ); + } + + break; + } + case CHAR_WORKRESIST_T: // 雷抗性提升 + { + // 恢复抗性 + if( cnt <= 1 ){ + int add_value = 0; + int old_value = 0; + old_value = CHAR_getWorkInt( charaindex, CHAR_WORK_T_RESIST ); + add_value = CHAR_getWorkInt( charaindex, CHAR_WORKMODRESIST_T ); + + CHAR_setWorkInt( charaindex, CHAR_WORK_T_RESIST, old_value - add_value ); + CHAR_talkToCli( charaindex, -1 , "雷抗性恢复" , CHAR_COLORYELLOW ); + } + + break; + } +#ifdef _PROFESSION_ADDSKILL +/* case CHAR_WORKERSIST_F_I_T: // 提升火冰雷抗性 + { + // 恢复抗性 + if( cnt <= 1 ){ + int add_value = 0; + int old_value = 0; + old_value = CHAR_getWorkInt( charaindex, CHAR_WORK_F_RESIST ); + add_value = CHAR_getWorkInt( charaindex, CHAR_WORKMODRESIST_F ); + CHAR_setWorkInt( charaindex, CHAR_WORK_F_RESIST, old_value - add_value ); + CHAR_talkToCli( charaindex, -1 , "火抗性恢复" , CHAR_COLORYELLOW ); + + old_value = CHAR_getWorkInt( charaindex, CHAR_WORK_I_RESIST ); + add_value = CHAR_getWorkInt( charaindex, CHAR_WORKMODRESIST_I ); + CHAR_setWorkInt( charaindex, CHAR_WORK_I_RESIST, old_value - add_value ); + CHAR_talkToCli( charaindex, -1 , "冰抗性恢复" , CHAR_COLORYELLOW ); + + old_value = CHAR_getWorkInt( charaindex, CHAR_WORK_T_RESIST ); + add_value = CHAR_getWorkInt( charaindex, CHAR_WORKMODRESIST_T ); + CHAR_setWorkInt( charaindex, CHAR_WORK_T_RESIST, old_value - add_value ); + CHAR_talkToCli( charaindex, -1 , "雷抗性恢复" , CHAR_COLORYELLOW ); + } + + break; + }*/ + case CHAR_WORKFEAR: + if( cnt <= 0 ) + CHAR_talkToCli( charaindex, -1 , "攻、防、敏恢复" , CHAR_COLORYELLOW ); + break; +#endif + case CHAR_WORKINSTIGATE: // 挑拨 + { + int side, pos, defNo, lop, rate=0; + if( RAND( 1, 100 ) > 80 ){ + break; + } + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + side = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLESIDE ); + + rate = CHAR_getWorkInt( charaindex, CHAR_WORKMODINSTIGATE); + + CHAR_setWorkInt( charaindex, CHAR_WORKFIXSTR, (CHAR_getWorkInt( charaindex, CHAR_WORKFIXSTR) * (100 - rate) /100 )); + CHAR_setWorkInt( charaindex, CHAR_WORKFIXTOUGH, (CHAR_getWorkInt( charaindex, CHAR_WORKFIXTOUGH) * (100 - rate) /100 )); + CHAR_setWorkInt( charaindex, CHAR_WORKFIXDEX, (CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX) * (100 - rate) /100 )); + + pos = RAND( 0, 9 ); + for( lop = 0; lop < SIDE_OFFSET; lop ++ ){ + if( ++pos >= SIDE_OFFSET )pos = 0; + defNo = side * SIDE_OFFSET + pos; + if( defNo == bid ) continue; + if( BATTLE_TargetCheck( battleindex, defNo ) == TRUE ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, defNo ); + break; + } + } + if( lop >= SIDE_OFFSET ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, -1 ); + } + break; + } +/* + case CHAR_WORK_FOCUS: // 专注战斗 + { + if( cnt <= 1 ){ + int atk_to_index = CHAR_getWorkInt( charaindex, CHAR_WORKMOD_FOCUS ); + int atk_to_no = BATTLE_Index2No( battleindex, atk_to_index ); + + if( BATTLE_TargetCheck( battleindex, atk_to_no ) != TRUE ) break; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, atk_to_no ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, 1 ); + } + break; + } +*/ + case CHAR_WORKSIGN: // 一针见血 + { + // 吸血 + int skill_level = CHAR_getWorkInt( charaindex, CHAR_WORKMODSIGN ); + int old_hp = CHAR_getInt( charaindex, CHAR_HP ); + int old_mp = CHAR_getInt( charaindex, CHAR_MP ); + int to_index = CHAR_getWorkInt( charaindex, CHAR_WORKSIGNID ); + int to_old_hp = CHAR_getInt( to_index, CHAR_HP ); + int to_old_mp = CHAR_getInt( to_index, CHAR_MP ); + int dec_hp=0, dec_mp=0, rate=0, hp=0, mp=0, add_hp=0, add_mp=0; + + if( old_hp <= 0 ) break; + +#ifdef _PROFESSION_ADDSKILL + if( skill_level >= 10 ){ + dec_hp = 200; + dec_mp = 30; + }else if( skill_level > 6 ){ + dec_hp = 150; + dec_mp = 20; + }else if( skill_level > 3 ){ + dec_hp = 100; + dec_mp = 15; + }else{ + dec_hp = 50; + dec_mp = 10; + } + // 增加hp + if( skill_level > 8 ) rate = 100; + else if( skill_level > 7 ) rate = 50; + else rate = 0; + add_hp = dec_hp * rate / 100; + + // 增加mp + if( skill_level > 8 ) rate = 100; + else rate = 0; + add_mp = dec_mp * rate / 100; + +#else + if( skill_level >= 10 ){ + dec_hp = 300; + dec_mp = 70; + }else if( skill_level >= 9 ){ + dec_hp = 200; + dec_mp = 50; + }else if( skill_level >= 7 ){ + dec_hp = 150; + dec_mp = 30; + }else if( skill_level >= 4 ){ + dec_hp = 100; + dec_mp = 20; + }else{ + dec_hp = 50; + dec_mp = 10; + } + // 增加hp + if( skill_level >= 9 ) rate = 80; + else if( skill_level >= 7 ) rate = (skill_level - 1 ) * 10; + else if( skill_level >= 4 ) rate = (skill_level - 2 ) * 10; + else rate = skill_level * 10; + add_hp = dec_hp * rate / 100; + + // 增加mp + if( skill_level >= 9 ) rate = 100; + else if( skill_level >= 7 ) rate = (skill_level - 1 ) * 10; + else if( skill_level >= 4 ) rate = (skill_level - 2 ) * 10; + else rate = skill_level * 10; + add_mp = dec_mp * rate / 100; +#endif + + // 中嗜血蛊的人减 HP + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + mp = old_mp - dec_mp; + if( mp < 0 ){ + mp = 0; + add_mp=0; + } + CHAR_setInt(charaindex, CHAR_MP, mp); + } + + // 中嗜血蛊的人减 HP + if( ridepet == -1 ) { + hp = old_hp - dec_hp; + if( hp < 0 ) hp = 0; + CHAR_setInt(charaindex, CHAR_HP, hp); + sprintf( szCommand, "BD|r%X|0|0|%X|m%X|", bid, dec_hp, dec_mp ); + }else{ + int pet_old_hp = CHAR_getInt( ridepet, CHAR_HP ); + int pet_hp=0; + + dec_hp /= 2; + hp = old_hp - dec_hp; + pet_hp = pet_old_hp - dec_hp; + + if( hp < 0 ) hp = 0; + if( pet_hp < 0 ) pet_hp = 0; + + CHAR_setInt(charaindex, CHAR_HP, hp); + CHAR_setInt(ridepet, CHAR_HP, pet_hp); + if( pet_hp <= 0 ){ + CHAR_setFlg( ridepet, CHAR_ISDIE, 1 ); + CHAR_setWorkInt( ridepet, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + sprintf( szCommand, "BD|r%X|0|0|%X|m%X|p%X|", bid, dec_hp, dec_mp, dec_hp ); + } + + if( hp <= 0 ){ + CHAR_setFlg( charaindex, CHAR_ISDIE, 1 ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + + BATTLESTR_ADD( szCommand ); + + // 使用嗜血蛊的人加 HP、MP + if( (add_hp > 0) && (to_old_hp > 0) ){ + int to_bid=0, to_hp=0, to_mp=0; + + to_bid = BATTLE_Index2No( battleindex, to_index ); + sprintf( szCommand, "BD|r%X|0|1|%X|m%X|", to_bid, add_hp, add_mp ); + BATTLESTR_ADD( szCommand ); + + to_hp = to_old_hp + add_hp; + if( to_hp > CHAR_getWorkInt( to_index , CHAR_WORKMAXHP ) ) + to_hp = CHAR_getWorkInt( to_index , CHAR_WORKMAXHP ); + + to_mp = to_old_mp + add_mp; + if( to_mp > CHAR_getWorkInt( to_index , CHAR_WORKMAXMP ) ) + to_mp = CHAR_getWorkInt( to_index , CHAR_WORKMAXMP ); + + CHAR_setInt(to_index, CHAR_HP, to_hp); + CHAR_setInt(to_index, CHAR_MP, to_mp); + } + + break; + } + case CHAR_WORKBLOODWORMS: // 嗜血蛊 + { + // 吸血 + int skill_level = CHAR_getWorkInt( charaindex, CHAR_WORKMODBLOODWORMS ); + int old_hp = CHAR_getInt( charaindex, CHAR_HP ); + int to_index = CHAR_getWorkInt( charaindex, CHAR_WORKBLOODWORMSID ); + int to_old_hp = CHAR_getInt( to_index, CHAR_HP ); + int dec_hp=0, rate=0, hp=0, add_hp=0; + + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_M( skill_level ); + + if( old_hp <= 0 ) break; + + dec_hp = skill_level * 10 + 30; + if( skill_level >= 10 ) rate = 20; + else if( skill_level >= 7 ) rate = 15; + else if( skill_level >= 5 ) rate = 10; + else rate = 5; + + add_hp = dec_hp * rate / 100; + + // 中嗜血蛊的人减 HP + if( ridepet == -1 ) { + hp = old_hp - dec_hp; + if( hp < 0 ) hp = 0; + + CHAR_setInt(charaindex, CHAR_HP, hp); + sprintf( szCommand, "BD|r%X|0|0|%X|", bid, dec_hp ); + }else{ + int pet_old_hp = CHAR_getInt( ridepet, CHAR_HP ); + int pet_hp=0; + + dec_hp /= 2; + hp = old_hp - dec_hp; + pet_hp = pet_old_hp - dec_hp; + + if( hp < 0 ) hp = 0; + if( pet_hp < 0 ) pet_hp = 0; + + CHAR_setInt(charaindex, CHAR_HP, hp); + CHAR_setInt(ridepet, CHAR_HP, pet_hp); + if( pet_hp == 0 ){ + CHAR_setFlg( ridepet, CHAR_ISDIE, 1 ); + CHAR_setWorkInt( ridepet, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + sprintf( szCommand, "BD|r%X|0|0|%X|p%X|", bid, dec_hp, dec_hp ); + } + + if( hp <= 0 ){ + CHAR_setFlg( charaindex, CHAR_ISDIE, 1 ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + + BATTLESTR_ADD( szCommand ); + + // 使用嗜血蛊的人加 HP + if( (add_hp > 0) && (to_old_hp > 0) ){ + int to_bid=0, to_hp=0; + + to_bid = BATTLE_Index2No( battleindex, to_index ); + sprintf( szCommand, "BD|r%X|0|1|%X|", to_bid, add_hp ); + BATTLESTR_ADD( szCommand ); + + to_hp = to_old_hp + add_hp; + if( to_hp > CHAR_getWorkInt( to_index , CHAR_WORKMAXHP ) ) + to_hp = CHAR_getWorkInt( to_index , CHAR_WORKMAXHP ); + + CHAR_setInt(to_index, CHAR_HP, to_hp); + } + + break; + } + case CHAR_WORKICEARROW: // 冰箭 + { + // 减敏 + int dec_dex = CHAR_getWorkInt( charaindex, CHAR_WORKMODICEARROW ); + int old_dex = CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX ); + int dex=0; + + dex = old_dex * ( 100 - dec_dex ) / 100; + CHAR_setWorkInt(charaindex,CHAR_WORKFIXDEX, dex); + sprintf( szCommand, "BD|r%X|0|6|%X|", bid, (-1) * dec_dex ); + + BATTLESTR_ADD( szCommand ); + + break; + } + case CHAR_WORKICECRACK: // 冰爆术 + { + int value=0; + int defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 );//defNo = BATTLE_Index2No( battleindex, charaindex ); + + value = CHAR_getWorkInt( charaindex, CHAR_WORKMODICECRACK ); + + if( cnt <= 0 && value > 0 ){ + int damage=0, petdamage=0; + + int ToList[SIDE_OFFSET*2+1]; + memset( ToList, -1, sizeof( ToList)); + BATTLE_MultiList( battleindex, TARGET_SIDE_1, ToList ); + // 将魔法参数代入动画 + analysis_profession_parameter( 2, 4, defNo, charaindex ); + PROFESSION_MAGIC_ATTAIC_Effect( battleindex, bid, ToList, 2); + + if( defNo == 20 || defNo == 25 || defNo == 26 )//右 + bid = 0; + else + bid = 10; + + + for( i = bid ; i < bid+10 ; i++ ) { + int defType, charaidx, petidx; + charaidx = BATTLE_No2Index( battleindex , i); + if( CHAR_CHECKINDEX( charaidx ) ){ + if( CHAR_getInt( charaidx, CHAR_HP ) > 0 ){ + petidx = BATTLE_getRidePet( charaidx ); + defType = CHAR_getInt(charaidx, CHAR_WHICHTYPE); + CHAR_setWorkInt( charaidx, CHAR_WORKICECRACK, 0 ); + //BATTLE_BadStatusString( bid, 0 ); + //snprintf( szBuffer, sizeof( szBuffer ), "(%s)将(%s)修理完毕。", + // CHAR_getUseName( charaindex ), aszStatusFull[i] ); + // BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + //sprintf( szBuffer, "BM|%X|%X|", bid, 0 ); + //BATTLESTR_ADD( szBuffer ); + + damage = value; + + hp = CHAR_getInt( charaidx, CHAR_HP ); + if( petidx == -1 ) { + hp -= damage; + if( hp < 0 ) hp = 0; + } + else{ + int defquick=0, petquick=0, playerdamage=0; + pethp = CHAR_getInt( petidx, CHAR_HP ); + defquick = CHAR_getWorkInt( charaidx, CHAR_WORKDEFENCEPOWER ); + petquick = CHAR_getWorkInt( petidx, CHAR_WORKDEFENCEPOWER ); + if( pethp > 0 ){ + playerdamage = (damage*petquick)/(defquick+petquick) +1; + petdamage = damage - playerdamage +1 ; + hp -= playerdamage; + pethp -= petdamage; + } + else{ + hp -= damage; + } + if( hp < 0 ) hp = 0; + if( pethp < 0 ) pethp = 0; + CHAR_setInt( petidx, CHAR_HP, pethp ); + } + + CHAR_setInt( charaidx, CHAR_HP, hp ); + + if( hp <= 0 ){ + CHAR_setFlg( charaidx, CHAR_ISDIE, 1 ); + CHAR_setWorkInt( charaidx, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + if( pethp <= 0 ){ + CHAR_setFlg( petidx, CHAR_ISDIE, 1 ); + CHAR_setWorkInt( ridepet, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + + if( damage >= 0 ){ + //snprintf( szBuffer, sizeof( szBuffer ), + // "(%s)因(%s)受到(%d)的损伤。", + // CHAR_getUseName( charaindex ), + // aszStatusFull[i], + // damage ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + sprintf( szBuffer , "%X|%X|%X|%X|" , i , i ,(int)(damage) , (int)(petdamage)); + + //sprintf( szBuffer, "BD|r%X|0|0|%X|p%X|", i, (int)(damage), (int)(petdamage) ); + BATTLESTR_ADD( szBuffer ); + } + if( petidx != -1 && petdamage >= 0 ){ + //snprintf( szBuffer, sizeof( szBuffer ), + // "(%s的骑宠)因(%s)受到(%d)的损伤。", + // CHAR_getUseName( charaindex ), + // aszStatusFull[i], petdamage ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + } + } + } + } + sprintf( szBuffer , "%X|" , 0x5711438 ); + BATTLESTR_ADD( szBuffer ); + } + } + print("\n冰爆术"); + break; +#ifdef _PROFESSION_ADDSKILL + case CHAR_WORKICECRACK2: // 冰爆术2 + WorkIceCrackPlay( charaindex, cnt, CHAR_WORKICECRACK2 );print("\n冰爆术2");break; + case CHAR_WORKICECRACK3: // 冰爆术3 + WorkIceCrackPlay( charaindex, cnt, CHAR_WORKICECRACK3 );print("\n冰爆术3");break; + case CHAR_WORKICECRACK4: // 冰爆术4 + WorkIceCrackPlay( charaindex, cnt, CHAR_WORKICECRACK4 );print("\n冰爆术4");break; + case CHAR_WORKICECRACK5: // 冰爆术5 + WorkIceCrackPlay( charaindex, cnt, CHAR_WORKICECRACK5 );print("\n冰爆术5");break; + case CHAR_WORKICECRACK6: // 冰爆术6 + WorkIceCrackPlay( charaindex, cnt, CHAR_WORKICECRACK6 );print("\n冰爆术6");break; + case CHAR_WORKICECRACK7: // 冰爆术7 + WorkIceCrackPlay( charaindex, cnt, CHAR_WORKICECRACK7 );print("\n冰爆术7");break; + case CHAR_WORKICECRACK8: // 冰爆术8 + WorkIceCrackPlay( charaindex, cnt, CHAR_WORKICECRACK8 );print("\n冰爆术8");break; + case CHAR_WORKICECRACK9: // 冰爆术9 + WorkIceCrackPlay( charaindex, cnt, CHAR_WORKICECRACK9 );print("\n冰爆术9");break; + case CHAR_WORKICECRACK10: // 冰爆术10 + WorkIceCrackPlay( charaindex, cnt, CHAR_WORKICECRACK10 );print("\n冰爆术10");break; +#endif //_PROFESSION_ADDSKILL + +#endif + +#ifdef _PET_SKILL_SARS // WON ADD 毒煞蔓延 + case CHAR_WORKSARS: + { + int j; + int rate = 60; // 传染 SARS 机率 + + // 受传染的人受伤 + { + int petdown=-1; + int dec_mp = 0; + + Compute_Down_SARS( charaindex, ridepet, &down, &petdown, ridepet); + if( down >= 0 ){ + //snprintf( szBuffer, sizeof( szBuffer ), + // "(%s)因(%s)受到(%d)的损伤。", + // CHAR_getUseName( charaindex ), + // aszStatusFull[i], + // down ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + // 如果是玩家扣 MP + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + int old_mp = CHAR_getInt( charaindex, CHAR_MP ); + dec_mp = old_mp / 10 ; + if( dec_mp < 0 ) dec_mp = 0; + CHAR_setInt( charaindex, CHAR_MP, old_mp - dec_mp ); + sprintf( szBuffer, "BD|r%X|0|0|%X|p%X|m%X|", bid, (int)(down), (int)(petdown), dec_mp ); + }else + sprintf( szBuffer, "BD|r%X|0|0|%X|p%X|", bid, (int)(down), (int)(petdown) ); + + BATTLESTR_ADD( szBuffer ); + } + if( ridepet != -1 && petdown >= 0 ){ + //snprintf( szBuffer, sizeof( szBuffer ), + // "(%s的骑宠)因(%s)受到(%d)的损伤。", + // CHAR_getUseName( charaindex ), + // aszStatusFull[i], petdown ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + } + } + + // 主传染者传SARS + if( CHAR_getWorkInt( charaindex, CHAR_WORKMODSARS ) > 0 ){ + int buf2[5], ti=0; + int tibuf[10]={ + 3,1,0,2,4, + 8,6,5,7,9 }; + + memset( buf2, -1, sizeof(buf2)); + + if( defNo > 9 ){ + for( j=0; j<10; j++ ){ + tibuf[j] += 10; + } + } + + for( j=0; j<10; j++){ + if( tibuf[j] != defNo ) continue; + if( j > 4 ){ + if( (j+1) < 10 ) buf2[ti++]=tibuf[j+1]; + if( (j-1) > 4 ) buf2[ti++]=tibuf[j-1]; + //不等边 + if( (j-5+1) < 5 ) buf2[ti++]=tibuf[j-5+1]; + if( (j-5-1) >= 0 ) buf2[ti++]=tibuf[j-5-1]; + if( (j-5) >= 0 ) buf2[ti++]=tibuf[j-5]; + }else{ + if( (j+1) < 5 ) buf2[ti++]=tibuf[j+1]; + if( (j-1) >= 0 ) buf2[ti++]=tibuf[j-1]; + //不等边 + if( (j+5+1) < 10 ) buf2[ti++]=tibuf[j+5+1]; + if( (j+5-1) > 4 ) buf2[ti++]=tibuf[j+5-1]; + if( (j+5) < 10 ) buf2[ti++]=tibuf[j+5]; + } + break; + } + + print("buf2[%d,%d,%d,%d,%d]\n", buf2[0], buf2[1], buf2[2], buf2[3], buf2[4]); + + for( j=0; j<5; j++ ){ + + int toindex = 0; + if( buf2[j] == -1 ) continue; + + toindex = BATTLE_No2Index( battleindex, buf2[j] ); + + // 得到sars的离开 + if( CHAR_getWorkInt( toindex,CHAR_WORKSARS ) > 0 ) continue; + + if( RAND( 1, 100 ) <= rate ){ // 中 SARS + if( toindex == charaindex ) continue; + if( CHAR_getInt( toindex, CHAR_HP ) <= 0 ) continue; + + CHAR_setWorkInt( toindex,CHAR_WORKSARS, 3 ); + } + } + } + } + break; +#endif + + default : + //snprintf( szBuffer, sizeof( szBuffer ), + // "(%s)是(%s)", CHAR_getUseName( charaindex ), + // aszStatusFull[i] ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + break; + } + } + +#ifdef _SUIT_ITEM + { + int defCode; + int AddHp=0, AddMp=0; +#ifdef _IMPRECATE_ITEM + int nums1, nums2, nums3, delMp=0; +#endif + if( (defCode=CHAR_getWorkInt( charaindex, CHAR_WORKSUITITEM)) > 0){ + AddHp = CHAR_getWorkInt( charaindex, CHAR_WORKROUNDHP); + AddMp = CHAR_getWorkInt( charaindex, CHAR_WORKROUNDMP); + } + +#ifdef _IMPRECATE_ITEM + if( (nums1 = CHAR_getWorkInt( charaindex, CHAR_WORKIMPRECATENUM1)) > 0 ){ + delMp = CHAR_getWorkInt( charaindex, CHAR_WORKHURTMP); + CHAR_setWorkInt( charaindex, CHAR_WORKIMPRECATENUM1, nums1-1); + } + if( (nums2 = CHAR_getWorkInt( charaindex, CHAR_WORKIMPRECATENUM2)) > 0 ){ + AddHp += CHAR_getWorkInt( charaindex, CHAR_WORKWISHESHP); + CHAR_setWorkInt( charaindex, CHAR_WORKIMPRECATENUM2, nums2-1); + } + if( (nums3 = CHAR_getWorkInt( charaindex, CHAR_WORKIMPRECATENUM3)) > 0 ){ + AddMp += CHAR_getWorkInt( charaindex, CHAR_WORKWISHESMP); + CHAR_setWorkInt( charaindex, CHAR_WORKIMPRECATENUM3, nums3-1); + } + AddMp = AddMp - delMp; +#endif + if( AddHp != 0 || AddMp != 0 ) { + int AddPHp=0; + + +#ifdef _TYPE_TOXICATION + if( AddHp != 0 && CHAR_CanCureFlg( charaindex, "FALSE") != FALSE ){ +#else + if( AddHp != 0 ) { +#endif + int MyHp = CHAR_getInt( charaindex, CHAR_HP); + int MaxHp = CHAR_getWorkInt( charaindex, CHAR_WORKMAXHP); + MyHp = ((MyHp+AddHp)>=MaxHp)?MaxHp:(MyHp+AddHp); + MyHp = (MyHp<= 1 )?1:MyHp; + CHAR_setInt( charaindex, CHAR_HP, MyHp); + //snprintf( szBuffer, sizeof( szBuffer ), "(%s)增加(%d)的HP。", + // CHAR_getUseName( charaindex ), AddHp ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + if( ridepet != -1 ){ + int PetMaxHp = CHAR_getWorkInt( ridepet, CHAR_WORKMAXHP); + int PetHp = CHAR_getInt( ridepet, CHAR_HP); + AddPHp = AddHp; + PetHp = ((PetHp+AddPHp)>=PetMaxHp)?PetMaxHp:(PetHp+AddPHp); + PetHp = (PetHp<=1)?1:PetHp; + CHAR_setInt( ridepet, CHAR_HP, PetHp); + } + } + if( AddMp != 0 ) { + int MyMp = CHAR_getInt( charaindex, CHAR_MP); + int MaxMp = CHAR_getWorkInt( charaindex, CHAR_WORKMAXMP); + MyMp = ((MyMp+AddMp)>MaxMp)?MaxMp:(MyMp+AddMp); + MyMp = (MyMp<0)?0:MyMp; + CHAR_setInt( charaindex, CHAR_MP, MyMp); +/* +#ifdef _FIXITEMANISHOW + sprintf( szBuffer, "BD|r%X|0|1|%X|p%X|m%X|", bid, AddHp, AddPHp, AddMp); + }else { + sprintf( szBuffer, "BD|r%X|0|1|%X|p%X|", bid, AddHp, AddPHp ); +#else +*/ + sprintf( szBuffer, "BD|r%X|0|2|%X|p%X|m%X|", bid, AddHp, AddPHp, AddMp); + }else { + sprintf( szBuffer, "BD|r%X|0|2|%X|p%X|", bid, AddHp, AddPHp ); +//#endif + } + BATTLESTR_ADD( szBuffer ); + } + } +#endif +#ifdef _PETSKILL_SETDUCK + { + int turns=0, nums=0; + if( (turns=CHAR_getWorkInt( charaindex, CHAR_MYSKILLDUCK)) > 0 ){ + turns--; + if( turns == 0 ){ + nums = CHAR_getWorkInt( charaindex, CHAR_MYSKILLDUCKPOWER); + sprintf( szBuffer, "BD|r%X|0|3|%X|", bid, nums*(-1)); + BATTLESTR_ADD( szBuffer ); + } + CHAR_setWorkInt( charaindex, CHAR_MYSKILLDUCK, turns); + } +#ifdef _MAGICPET_SKILL + if( (turns=CHAR_getWorkInt( charaindex, CHAR_MYSKILLSTR)) > 0 ){ + turns--; + if( turns == 0 ){ + nums = CHAR_getWorkInt( charaindex, CHAR_MYSKILLSTRPOWER); + sprintf( szBuffer, "BD|r%X|0|4|%X|", bid, nums*(-1)); + BATTLESTR_ADD( szBuffer ); + } + CHAR_setWorkInt( charaindex, CHAR_MYSKILLSTR, turns); + } + if( (turns=CHAR_getWorkInt( charaindex, CHAR_MYSKILLTGH)) > 0 ){ + turns--; + if( turns == 0 ){ + nums = CHAR_getWorkInt( charaindex, CHAR_MYSKILLTGHPOWER); + sprintf( szBuffer, "BD|r%X|0|5|%X|", bid, nums*(-1)); + BATTLESTR_ADD( szBuffer ); + } + CHAR_setWorkInt( charaindex, CHAR_MYSKILLTGH, turns); + } + if( (turns=CHAR_getWorkInt( charaindex, CHAR_MYSKILLDEX)) > 0 ){ + turns--; + if( turns == 0 ){ + nums = CHAR_getWorkInt( charaindex, CHAR_MYSKILLDEXPOWER); + sprintf( szBuffer, "BD|r%X|0|6|%X|", bid, nums*(-1)); + BATTLESTR_ADD( szBuffer ); + } + CHAR_setWorkInt( charaindex, CHAR_MYSKILLDEX, turns); + } +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + if( (turns=CHAR_getWorkInt( charaindex, CHAR_MYSKILLHIT)) > 0 ){ + turns--; + if( turns == 0 ){ + int dec_num = CHAR_getWorkInt( charaindex, CHAR_MYSKILLHIT_NUM); + nums = CHAR_getWorkInt( charaindex, CHAR_WORKHITRIGHT); + nums -= dec_num; + CHAR_setWorkInt( charaindex, CHAR_WORKHITRIGHT, nums); + + CHAR_talkToCli( charaindex, -1, "恢复命中率", CHAR_COLORYELLOW); + //sprintf( szBuffer, "BD|r%X|0|6|%X|", bid, dec_num*(-1)); + //BATTLESTR_ADD( szBuffer ); + } + CHAR_setWorkInt( charaindex, CHAR_MYSKILLHIT, turns); + } +#endif + +#endif + } +#endif + return 0; + +} + + +BOOL BATTLE_CanMoveCheck( int charaindex ) +{ + + // + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARALYSIS ) > 0 ){ + return FALSE; + } + + // 檗祭 + if( CHAR_getWorkInt( charaindex, CHAR_WORKSTONE ) > 0 ){ + return FALSE; + } + // 戽曰 + if( CHAR_getWorkInt( charaindex, CHAR_WORKSLEEP ) > 0 ){ + return FALSE; + } +#ifdef _MAGIC_BARRIER + if( CHAR_getWorkInt( charaindex, CHAR_WORKBARRIER ) > 0 ){ + return FALSE; + } +#endif + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + // 晕眩 + if( CHAR_getWorkInt( charaindex, CHAR_WORKDIZZY ) > 0 ){ + return FALSE; + } + // 天罗地网 + if( CHAR_getWorkInt( charaindex, CHAR_WORKDRAGNET ) > 0 ){ + return FALSE; + } +/* + // 冰箭术 + if( CHAR_getWorkInt( charaindex, CHAR_WORKICEARROW ) > 0 ){ + return FALSE; + } +*/ +/* + // 专注战斗 + if( CHAR_getWorkInt( charaindex, CHAR_WORK_FOCUS ) > 0 ){ + return FALSE; + } +*/ + // 雷附体 + if( CHAR_getWorkInt( charaindex, CHAR_WORK_T_ENCLOSE ) > 0 ){ + return FALSE; + } +#endif +#ifdef _PROFESSION_ADDSKILL + if( CHAR_getWorkInt( charaindex, CHAR_DOOMTIME ) > 0 ){ + return FALSE; + } +#endif + return TRUE; +} + +#ifdef _ITEM_EQUITSPACE +int BATTLE_GetEqShield( int charaindex ) +{ + int iRet = ITEM_FIST, itemindex; + + itemindex = CHAR_getItemIndex( charaindex, CHAR_EQSHIELD ); + if( ITEM_CHECKINDEX( itemindex ) == FALSE ){ + iRet = ITEM_FIST; + }else{ + iRet = ITEM_getInt( itemindex, ITEM_TYPE ); + } + return iRet; +} +#endif + +int BATTLE_GetWepon( int charaindex ) //取得角色手持武器 +{ + int iRet = ITEM_FIST, itemindex; + + itemindex = CHAR_getItemIndex( charaindex, CHAR_ARM ); + if( ITEM_CHECKINDEX( itemindex ) == FALSE ){ + iRet = ITEM_FIST; + }else{ + iRet = ITEM_getInt( itemindex, ITEM_TYPE ); + } + + return iRet; +} + +static int aBowW[50] = +{ + 0, 2, 1, 4, 3, 0, 1, 2, 3, 4, + 1, 0, 3, 2, 4, 1, 3, 0, 2, 4, + 2, 4, 0, 1, 3, 2, 0, 4, 1, 3, + 3, 1, 0, 2, 4, 3, 1, 0, 2, 4, + 4, 2, 0, 1, 3, 4, 2, 0, 1, 3, +}; + +void BATTLE_TargetListSet( int charaindex, int attackNo, int *pList) +{ + int i, j=0, defNo, battleindex=-1; + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + +#ifdef _SKILLLIMIT // (可开放) Syu ADD 不得攻击我方限制 + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_FALLRIDE || // 落马 + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_WILDVIOLENTATTACK || //狂暴攻击 + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_TIMID || // 怯战 + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_MPDAMAGE || // MP攻击 + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_WEAKEN || // 虚弱 + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_DAMAGETOHP || // 嗜血 + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_STEALMONEY ) { // 捐献 + if( BATTLE_CheckSameSide( charaindex, defNo) == 1 ) { + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); +// BATTLE_NoAction( battleindex, attackNo ); + return; + } + } +#endif + + for( i = 0; i < BATTLE_ENTRY_MAX*2; i ++ ){ + pList[i] = defNo; + } +#ifdef _BATTLE_ATTCRAZED // ANDY 疯狂暴走 +#ifdef _SHOOTCHESTNUT // Syu ADD 宠技:丢栗子 + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_ATTCRAZED || + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_ATTSHOOT ){ +#else + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_ATTCRAZED ){ +#endif + int deftop,defsub; + int plive[10]; + int n = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + + +#ifdef _SHOOTCHESTNUT // Syu ADD 宠技:丢栗子 + if( BATTLE_CheckSameSide( charaindex, defNo) == 1 ) { + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + BATTLE_NoAction( battleindex, attackNo ); + return; + } +#endif + if( 0 <= defNo && defNo <= 9 ){ + defsub = 0; + deftop = 9; + }else if( 10 <= defNo && defNo <= 19 ){ + defsub = 10; + deftop = 19; + }else{ + pList[1] = -1; + return; + } + for( i = defsub; i < deftop; i ++ ){ + if( BATTLE_TargetCheck( battleindex, i) == FALSE ) continue; + plive[j++] = i; + } + if( j == 0 ) return; + for( i=0; i= CHAR_MAXPETSKILLHAVE ) i = 0; + + if( CHAR_getCharHaveSkill( charaindex, i ) == NULL ){ + continue; + } + + pskill_array = PETSKILL_GetArray( charaindex, i ); + skill_type = PETSKILL_getInt( pskill_array, PETSKILL_FIELD ); + + + if( skill_type == PETSKILL_FIELD_BATTLE + || skill_type == PETSKILL_FIELD_ALL + ){ + }else{ + continue; + } + + if( j < iNum ){ + j++; + continue; + } + + if( PETSKILL_Use( charaindex, iNum, toNo, NULL ) == TRUE ){ + + }else{ + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + break; + } + + if( k >= PETSKILLSERCHTIME ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + return 0; +} + + +enum{ + PETAI_MODE_NORMAL, + PETAI_MODE_TARGETRANDOM, + PETAI_MODE_RANDOMACT, + PETAI_MODE_OWNERATTACK, + PETAI_MODE_ENEMYATTACK, + PETAI_MODE_ESCAPE, + PETAI_MODE_NOACT, + PETAI_MODE_END +}; + +static int BATTLE_PetLoyalCheck( int battleindex, int bid, int charaindex ) +{ + int ai, toNo, mode = 0, type, Rand, toSide = 1, flg, i; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPET ){ + return 0; + } + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == TRUE ) + return 0; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_WAIT ){ + return 0; + } + flg = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEFLG ); + flg &= ~CHAR_BATTLEFLG_AIBAD; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEFLG, flg ); + if( BATTLE_CanMoveCheck( charaindex ) == FALSE ){ + return 0; + } + toNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + toSide = ( 0 <= toNo && toNo < BATTLE_ENTRY_MAX )?(0):(1); + ai = CHAR_getWorkInt( charaindex, CHAR_WORKFIXAI ); + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_GUARD + || bid == toNo + ){ + type = 1; + }else{ + type = 0; + } + + Rand = RAND( 1, 100 ); + + mode = 0; // 恳仄中垫 + if( ai >= 80 ){ // 镝擦蘸ㄧㄟ⊙动晓 + mode = PETAI_MODE_NORMAL; // 濮覆岳 + }else + if( ai >= 70 ){ // 镝擦蘸ㄦㄟ⊙动晓 + if( Rand < 10 )mode = PETAI_MODE_TARGETRANDOM; // 正□必永玄 + }else + if( ai >= 60 ){ + if( Rand < 20 )mode = PETAI_MODE_TARGETRANDOM; // 正□必永玄 + }else + if( ai >= 50 ){ + if( Rand < 35 )mode = PETAI_MODE_TARGETRANDOM; // 正□必永玄 + }else + if( ai >= 40 ){ + if( Rand < 50 )mode = PETAI_MODE_TARGETRANDOM; // 正□必永玄 + }else + if( ai >= 30 ){ + if( Rand < 70 )mode = PETAI_MODE_RANDOMACT; // 垫 仿件母丞 + }else + if( ai >= 20 ){ + if( Rand < 70 )mode = PETAI_MODE_RANDOMACT; // 垫 仿件母丞 + }else + if( ai >= 10 ){ + if( Rand < 80 ){ + mode = PETAI_MODE_OWNERATTACK; // 潜谛 猾 + }else{ + mode = PETAI_MODE_ENEMYATTACK; // 衬 猾 + } + }else{ + if( Rand < 60 ){ + mode = PETAI_MODE_OWNERATTACK; // 潜谛 猾 + }else{ + mode = PETAI_MODE_ESCAPE; // 仆月 + } + } + + + if( mode == PETAI_MODE_NORMAL )return 0; + + for( i = 0; i < CHAR_MAXPETSKILLHAVE;i ++ ){ + if( CHAR_getCharHaveSkill( charaindex, i ) ){ + break; + } + } + if( i >= CHAR_MAXPETSKILLHAVE ){ + mode = PETAI_MODE_NOACT; + } + flg = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEFLG ); + flg |= CHAR_BATTLEFLG_AIBAD; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEFLG, flg ); + + + switch( mode ){ + case PETAI_MODE_NOACT: + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, + BATTLE_COM_NONE ); + break; + case PETAI_MODE_TARGETRANDOM: + if( type == 1 ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, + BATTLE_COM_NONE ); + }else{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, + BATTLE_DefaultAttacker( battleindex, toSide ) ); + + } + break; + case PETAI_MODE_RANDOMACT: // 垫 互仿件母丞 + // 哗萄ㄠ葱 猾蟆反濮覆井尹切扎母丢 + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_EARTHROUND0 ){ + return 0; + } + + // 布□犯奴失件白仿弘毛反内允 + flg = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEFLG ); + flg &= ~CHAR_BATTLEFLG_GUARDIAN; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEFLG, flg ); + + if( toNo == bid ){ // 愤坌毛蓟氏匹仄引匀凶日 + // 窒手匹五卅中仇午卞允月 + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + }else{ + // 仿件母丞卞檗 毛本永玄 + BATTLE_PetRandomSkill( battleindex, charaindex ); + } + break; + + case PETAI_MODE_OWNERATTACK: // 潜谛 猾 + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, bid-5 ); + break; + + case PETAI_MODE_ENEMYATTACK: // 衬 猾 + { int myside = 0; + if( bid >= BATTLE_ENTRY_MAX ) myside = 1; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + // 锹澎扔奶玉卞 + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, + BATTLE_DefaultAttacker( battleindex, 1 - myside ) ); + } + break; + + case PETAI_MODE_ESCAPE: // 仆月公及 夫旦玄 + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_LOSTESCAPE ); + break; + + } + + return 1; + +} + +#ifdef __ATTACK_MAGIC + +#define MAX_MAGIC_NUMBER 25 + +// 每一种魔法的攻击 围 (id,area) +int TargetIndex[MAX_MAGIC_NUMBER][2] = +{ + {301,-1},{302,-1},{303,26},{304,-1},{305,20},{306,20}, + {307,-1},{308,-1},{309,-1},{310,-1},{311,26},{312,20}, + {313,-1},{314,-1},{315,-1},{316,-1},{317,26},{318,20}, + {319,-1},{320,-1},{321,26},{322,-1},{323,26},{324,20},{325,20} +}; + +int magic,toindex,magic_count; + +#endif + + + +static int BATTLE_Battling( int battleindex ) +{ + BATTLE *pBattle, *pWatchBattle; + BATTLE_ENTRY *pEntry[2]; + char *aszFieldAttr[] = { "无", "地", "水", "火", "风" }, + szBuffer[256]="", + szWork[256]; + int i,j,k, + len, + entrynum, + charaindex, + attackNo, + defNo=-1, + aAttackList[BATTLE_ENTRY_MAX*2+1], + aDefList[BATTLE_ENTRY_MAX*2+1], + ComboId, + itemindex, + AllSize = 0; + BATTLE_CHARLIST EntryList[40]; + int ContFlg, attackNoSub, defNoSub; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + pBattle = &BattleArray[battleindex]; + pEntry[0] = pBattle->Side[0].Entry; + pEntry[1] = pBattle->Side[1].Entry; + + for( i = 0; i < arraysizeof(EntryList); i ++ ){ + EntryList[i].charaindex = -1; + EntryList[i].combo = 0; + } + + sprintf( szBuffer, "战役 %d 转换 %d 属性 %s", + battleindex, pBattle->turn, + aszFieldAttr[pBattle->field_att] + ); + + entrynum = 0; + + for( j = 0; j < 2; j ++ ){ + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + pEntry[j][i].flg &= ~BENT_FLG_ULTIMATE; + if( pEntry[j][i].charaindex == -1 )continue; + EntryList[entrynum].charaindex = pEntry[j][i].charaindex; + EntryList[entrynum].side = j; + EntryList[entrynum].num = pEntry[j][i].bid; + EntryList[entrynum].dex = BATTLE_DexCalc( pEntry[j][i].charaindex ); +#ifdef _EQUIT_SEQUENCE + EntryList[entrynum].sequence = CHAR_getWorkInt( pEntry[j][i].charaindex, CHAR_WORKSEQUENCEPOWER); +#endif + BATTLE_talkToCli( pEntry[j][i].charaindex, szBuffer, CHAR_COLORYELLOW ); + entrynum ++; + } + } + szAllBattleString[0] = 0; + k = 0; + for( j = 0; j < 2; j ++ ){ + k = j * SIDE_OFFSET; + for( i = 0; i < BATTLE_ENTRY_MAX/2; i ++ ){ + szBattleString[0] = 0; + if( pBattle->iEntryBack[k] >= 0 + && pBattle->Side[j].Entry[i].charaindex == -1){ + if( pBattle->iEntryBack2[k] >= 0 ){ + sprintf( szBattleString, "BE|et%X|f1|", k ); + //BATTLE_BroadCast( battleindex, "突然有人不见了。", CHAR_COLORYELLOW ); + }else{ + print( "应是输入ID不正确出现的error。\n" ); + //BATTLE_BroadCast( battleindex, "ID错误的error。", CHAR_COLORYELLOW ); + } + } + k ++; + strcat( szAllBattleString, szBattleString ); + } + } + len = strlen( szAllBattleString ); + AllSize += len; + EntrySort( EntryList, entrynum ); + ComboCheck( EntryList, entrynum ); + for( i = 0; i < entrynum; i ++ ){ + int COM, myside, otherside, bi, + attack_flg = 1, + attack_max = 1, + attack_count = 0; + + charaindex = EntryList[i].charaindex; + myside = EntryList[i].side; + otherside = 1-myside; + attackNo = EntryList[i].num; + bi = attackNo - myside * SIDE_OFFSET; + + aAttackList[0] = attackNo; + aAttackList[1] = -1; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == TRUE )continue; + szBadStatusString[0] = 0; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) + != BATTLE_CHARMODE_C_OK ){ + //sprintf( szBuffer, "指令输入不完全。(%s)", CHAR_getUseName( charaindex ) ); + //BATTLE_BroadCast( battleindex, szBuffer, CHAR_COLORYELLOW ); + continue; + } + if( CHAR_getInt( charaindex, CHAR_HP ) <= 0 )continue; + +#ifdef _CHECK_BATTLETIME + check_battle_com_begin(); +#endif + + szBattleString[0] = 0; + pszBattleTop = szBattleString; + pszBattleLast = szBattleString+arraysizeof(szBattleString); + + // WON ADD + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) != TRUE ) + BATTLE_StatusSeq( charaindex ); + +#ifdef _OTHER_MAGICSTAUTS + BATTLE_MagicStatusSeq( charaindex ); +#endif + +#ifdef _MAGIC_DEEPPOISON // 剧毒 + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == TRUE ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } +#endif + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + BATTLE_ProfessionStatusSeq( battleindex, charaindex); +#endif + + + if( BATTLE_CanMoveCheck( charaindex ) == FALSE ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + gBattleDamageModyfy = 1.0; + gBattleDuckModyfy = 0; + gBattleStausChange = -1; + gBattleStausTurn = 0; + gWeponType = ITEM_FIST; + gWeponType = BATTLE_GetWepon( charaindex ); +#ifdef _PETSKILL_BECOMEFOX + if( CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND ) != -1 //若是变成小狐狸 + || CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER)==101749) + { + int COM = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ); + + gWeponType = ITEM_FIST; + + if( !(COM == BATTLE_COM_ATTACK + || COM == BATTLE_COM_GUARD + || COM == BATTLE_COM_NONE) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + CHAR_talkToCli( charaindex, -1, "变成小狐狸後只能攻击、防御和待机!", CHAR_COLORYELLOW ); + } + } +#endif +#ifdef _PETSKILL_BECOMEPIG + if( CHAR_getInt( charaindex, CHAR_BECOMEPIG) > -1 //变成乌力了 + && (CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER) ) + { + int COM = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ); + + gWeponType = ITEM_FIST; + //CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + if( !(COM == BATTLE_COM_ATTACK + || COM == BATTLE_COM_GUARD + || COM == BATTLE_COM_NONE + || COM == BATTLE_COM_ITEM + || COM == BATTLE_COM_ESCAPE + || COM == BATTLE_COM_CAPTURE + || COM == BATTLE_COM_WAIT + || COM == BATTLE_COM_PETIN + || COM == BATTLE_COM_PETOUT) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_GUARD ); + //CHAR_talkToCli( charaindex, -1, "变成乌力後只能攻击、防御、待机、逃跑和使用道具!", CHAR_COLORYELLOW ); + CHAR_talkToCli( charaindex, -1, "变成乌力後不能使用咒术和职业技能!", CHAR_COLORYELLOW ); + } + } +#endif + gDamageDiv = 1.0; + attack_max = BATTLE_GetAttackCount( charaindex ); + if( attack_max <= 0 ){ + int work, randwork; + work = CHAR_getInt( charaindex, CHAR_LV ); + if( work < 10 || CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ){ + attack_max = 1; + }else{ + int luckwork = CHAR_getInt( charaindex, CHAR_LUCK )*5; + if( luckwork > 5*5 ){ + print( "\nerr:运气奇怪(%s)(%d)\n", + CHAR_getUseName( charaindex ), + CHAR_getInt( charaindex, CHAR_LUCK ) ); + luckwork = 5*5; + } + randwork = RAND( 1, 1000 ); + if( randwork <= 10 + luckwork){ + attack_max = RAND( 5, 10 ); + }else + if( randwork <= 30 + luckwork ){ + attack_max = 3; + }else + if( randwork <= 70 + luckwork ){ + attack_max = 2; + }else{ + attack_max = 1; + } + } + }else{ + if( gWeponType == ITEM_FIST )gDamageDiv = attack_max; + } + if( gWeponType == ITEM_BREAKTHROW ){ + gBattleStausChange = BATTLE_ST_PARALYSIS; + gBattleStausTurn = 1-1; + }else{ + } + + if( BattleArray[battleindex].Side[myside].flg & BSIDE_FLG_SURPRISE ){ + }else{ + if( BATTLE_PetLoyalCheck( battleindex, attackNo, charaindex ) ) { +#ifdef _FIXWOLF // Syu ADD 修正狼人变身Bug + if ( CHAR_getInt ( charaindex , CHAR_BASEIMAGENUMBER) == 101428 ) { + if( CHAR_getWorkInt ( charaindex , CHAR_WORKTURN ) == 0){ + CHAR_setInt( charaindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( charaindex , CHAR_BASEBASEIMAGENUMBER)); + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, CHAR_getWorkInt( charaindex , CHAR_WORKFIXSTR)); + CHAR_setWorkInt( charaindex, CHAR_WORKQUICK, CHAR_getWorkInt( charaindex , CHAR_WORKFIXDEX)); + } + } +#endif + sprintf( szWork, "BX|%X|", attackNo); + BATTLESTR_ADD( szWork ); + } + } + +#ifdef _PROFESSION_ADDSKILL + if( CHAR_getWorkInt( charaindex, CHAR_DOOMTIME ) > 0 ){ + CHAR_setWorkInt( charaindex, CHAR_DOOMTIME, CHAR_getWorkInt( charaindex, CHAR_DOOMTIME) - 1 ); + } + if( CHAR_getWorkInt( charaindex, CHAR_DOOMTIME ) == 0 + && ( CHAR_getWorkInt( charaindex, CHAR_WORK_com1 ) == BATTLE_COM_S_FIRE_SPEAR + || CHAR_getWorkInt( charaindex, CHAR_WORK_com1 ) == BATTLE_COM_S_DOOM ) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, CHAR_getWorkInt( charaindex, CHAR_WORK_com1 ) ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, CHAR_getWorkInt( charaindex, CHAR_WORK_toNo ) ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, CHAR_getWorkInt( charaindex, CHAR_WORK_mode ) ); + CHAR_SETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3, CHAR_getWorkInt( charaindex, CHAR_WORK_skill_level ) ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, CHAR_getWorkInt( charaindex, CHAR_WORK_array ) ); + CHAR_setWorkInt( charaindex, CHAR_WORK_com1, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORK_toNo, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORK_mode, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORK_skill_level, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORK_array, 0 ); + } + +#endif + COM = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ); + + switch( COM ){ + case BATTLE_COM_ATTACK: + if( gWeponType == ITEM_BOOMERANG ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_BOOMERANG ); + +#ifdef _PETSKILL_BECOMEFOX + if( CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER)==101749 + || CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND ) != -1 ){ //若是变成小狐狸不可以使用回力标 + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } +#endif +#ifdef _PETSKILL_BECOMEPIG + if( CHAR_getInt( charaindex, CHAR_BECOMEPIG) > -1 ){//变成乌力了 + gWeponType = ITEM_FIST; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + } +#endif + } + break; + case BATTLE_COM_COMBO: + if( ComboCheck2( EntryList, i, entrynum ) == FALSE ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + } + break; + + case BATTLE_COM_S_STATUSCHANGE: + gBattleStausChange = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3 ); + gBattleStausTurn = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3 ); + break; + +#ifdef _PETSKILL_HECTOR + case BATTLE_COM_S_HECTOR: + gBattleStausChange = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3 ); + gBattleStausTurn = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3 ); + break; +#endif + +#ifdef _PET_SKILL_SARS // WON ADD 毒煞蔓延 + case BATTLE_COM_S_SARS: + gBattleStausChange = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3 ); + gBattleStausTurn = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3 ); + break; +#endif + + case BATTLE_COM_S_CHARGE: + BATTLE_Charge( battleindex, attackNo ); + break; + case BATTLE_COM_S_RENZOKU: + attack_max = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3 ); + gDamageDiv = attack_max; + break; +#ifdef _VARY_WOLF + case BATTLE_COM_S_VARY: + // 先用不到 + break; +#endif +#ifdef _SKILL_WILDVIOLENT_ATT + //狂暴攻击 vincent add 2002/05/16 + case BATTLE_COM_S_WILDVIOLENTATTACK: + attack_max = RAND(3,10);//攻击次数 + gDamageDiv = attack_max;//每次攻击造成伤害 + gBattleDuckModyfy = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3 );//命中率 + break; +#endif + case BATTLE_COM_S_EARTHROUND0: + gBattleDamageModyfy = 1.0 + 0.01 * CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM3 ); + break; +#ifdef _BATTLE_ATTCRAZED + case BATTLE_COM_S_ATTCRAZED: + attack_max = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + break; +#endif +#ifdef _SHOOTCHESTNUT // Syu ADD 宠技:丢栗子 + case BATTLE_COM_S_ATTSHOOT: + attack_max = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + gDamageDiv = attack_max;//每次攻击造成伤害 + break; +#endif + case BATTLE_COM_S_MIGHTY: + gBattleDamageModyfy = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3 ) * 0.01; + gBattleDuckModyfy = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3 ); // 歹今木膜恳骚橘尺 + break; + } + + BATTLE_TargetListSet( charaindex, attackNo, aDefList ); + COM = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ); + + ContFlg = FALSE; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_AIBAD + && COM == BATTLE_COM_COMBO ){ + print( "由於忠诚度不足使用必杀技失败(%s)\n", CHAR_getUseName( charaindex ) ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + } +#ifdef _BATTLE_TIMESPEED//动画播放速度 + { + int flgtime = 0; + switch( COM ){ +#ifdef _BATTLE_ATTCRAZED + case BATTLE_COM_S_ATTCRAZED: + flgtime = 200*3; + break; +#endif +#ifdef _SHOOTCHESTNUT // Syu ADD 宠技:丢栗子 + case BATTLE_COM_S_ATTSHOOT: + flgtime = 80*attack_max; + break; +#endif + case BATTLE_COM_JYUJYUTU: + case BATTLE_COM_S_ATTACK_MAGIC: + flgtime = 260; // 1/100sec + break; + case BATTLE_COM_COMBO: + flgtime = 200; // 1/100sec + break; + case BATTLE_COM_GUARD: + break; + case BATTLE_COM_WAIT: + default : + flgtime = 150; // 1/100sec + break; + } + BattleArray[battleindex].flgTime += flgtime; + } +#endif + +#ifdef _PETSKILL_BECOMEFOX // 中了媚惑术後攻防敏能力各降 20% + if( CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND ) != -1 ){ //变成小狐狸 + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, CHAR_getWorkInt( charaindex, CHAR_WORKFIXSTR)*0.8);//攻降20% + CHAR_setWorkInt( charaindex, CHAR_WORKDEFENCEPOWER, CHAR_getWorkInt( charaindex, CHAR_WORKFIXTOUGH)*0.8);//防降20% + CHAR_setWorkInt( charaindex, CHAR_WORKQUICK, CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX)*0.8);//敏降20% + } +#endif + switch( COM ){//处理攻击 + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + //==== 直接攻击系 =============================================================== + case BATTLE_COM_S_BRUST: // 爆击 + case BATTLE_COM_S_CHAIN_ATK: // 连环攻击 + case BATTLE_COM_S_CHAIN_ATK_2: // 双重攻击 + case BATTLE_COM_S_CAVALRY: // 座骑攻击 + case BATTLE_COM_S_DEAD_ATTACK: // 濒死攻击 + case BATTLE_COM_S_ATTACK_WEAK: // 弱点攻击 + case BATTLE_COM_S_PLUNDER: // 体掠夺 + case BATTLE_COM_S_CHAOS: // 混乱攻击 + { + // 防止同队互打 + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + if( BATTLE_CheckSameSide( charaindex, defNo) == 1 ){ + BATTLE_NoAction( battleindex, attackNo ); break; + } + } + case BATTLE_COM_S_ENRAGE_PET: // 激怒宠物 + { + CHAR_setFlg( charaindex, CHAR_ISATTACKED, 1 ); + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + battle_profession_attack_fun(battleindex, attackNo, defNo, charaindex); + //change fix 修正使用职业得不到道具 + //BATTLE_AddProfit( battleindex, aAttackList); + } + break; + //==== 魔法攻击系 ================================================================ + case BATTLE_COM_S_VOLCANO_SPRINGS: // 火山泉 + case BATTLE_COM_S_FIRE_BALL: // 火星球 + case BATTLE_COM_S_FIRE_SPEAR: // 火龙枪 + case BATTLE_COM_S_SUMMON_THUNDER: // 召雷术 + case BATTLE_COM_S_CURRENT: // 电流术 + case BATTLE_COM_S_STORM: // 暴风雨 + case BATTLE_COM_S_ICE_ARROW: // 冰箭 + case BATTLE_COM_S_ICE_CRACK: // 冰爆术 + case BATTLE_COM_S_ICE_MIRROR: // 冰镜术 + case BATTLE_COM_S_DOOM: // 世界末日 + case BATTLE_COM_S_BLOOD_WORMS: // 嗜血蛊 + case BATTLE_COM_S_SIGN: // 一针见血 + case BATTLE_COM_S_ENCLOSE: // 附身术 + case BATTLE_COM_S_THROUGH_ATTACK: // 贯穿攻击 + case BATTLE_COM_S_CONVOLUTE: // 回旋攻击 + { +#ifdef _PROFESSION_ADDSKILL + /* if( COM == BATTLE_COM_S_DOOM //世界末日集气 + || COM == BATTLE_COM_S_FIRE_SPEAR){ + if( CHAR_getWorkInt( charaindex, CHAR_DOOMTIME ) > 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + sprintf( szWork, "bt|%x|", attackNo ); + BATTLESTR_ADD( szWork ); + break; + } + }*/ +#endif + // 防止同队互打 + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + if( BATTLE_CheckSameSide( charaindex, defNo) == 1 ){ + BATTLE_NoAction( battleindex, attackNo ); break; + } + } + case BATTLE_COM_S_BLOOD: // 嗜血成性 + { + CHAR_setFlg( charaindex, CHAR_ISATTACKED, 1 ); + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); +#if 1 // Robin fix 修正嗜血吸别人的血 + if( defNo != attackNo && COM == BATTLE_COM_S_BLOOD ){ + print("\n 改封包!嗜血吸别人的血!!:%s ", CHAR_getChar( charaindex, CHAR_CDKEY) ); + defNo = attackNo; + + CHAR_talkToCli( charaindex, -1, "因封包异常而断线。", CHAR_COLORYELLOW); + CONNECT_setCloseRequest( CHAR_getWorkInt( charaindex, CHAR_WORKFD ) , 1 ); + break; + } +#endif +#ifdef _PROFESSION_ADDSKILL + if( COM == BATTLE_COM_S_ICE_CRACK ){ + if( pBattle->ice_count >= 20 ) + pBattle->ice_count = 0; + pBattle->ice_use[pBattle->ice_count] = TRUE; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + pBattle->ice_level[pBattle->ice_count] = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + pBattle->ice_bout[pBattle->ice_count] = 2; + pBattle->ice_toNo[pBattle->ice_count] = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + pBattle->ice_array[pBattle->ice_count] = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3); + pBattle->ice_charaindex[pBattle->ice_count] = charaindex; + pBattle->ice_attackNo[pBattle->ice_count] = attackNo; + ++pBattle->ice_count; + BATTLE_NoAction( battleindex, attackNo ); + print("\n进入冰爆"); + break; + } +#endif + battle_profession_attack_magic_fun(battleindex, attackNo, defNo, charaindex); + //change fix 修正使用职业得不到道具 + //BATTLE_AddProfit( battleindex, aAttackList); + break; + } + //==== 提升自已能力系 ==================================================================== + case BATTLE_COM_S_FOCUS: // 专注战斗 + case BATTLE_COM_S_AVOID: // 回避 + case BATTLE_COM_S_RECOVERY: // 补血 + case BATTLE_COM_S_SCAPEGOAT: // 舍已为友 + case BATTLE_COM_S_ENRAGE: // 激化攻击 + case BATTLE_COM_S_COLLECT: // 能量聚集 + case BATTLE_COM_S_TRAP: // 陷阱 + case BATTLE_COM_S_TRANSPOSE: // 移形换位 + case BATTLE_COM_S_DOCILE: // 驯伏宠物 +#ifdef _PROFESSION_ADDSKILL + case BATTLE_COM_S_CALL_NATURE: // 号召自然 +#endif + { + CHAR_setFlg( charaindex, CHAR_ISATTACKED, 1 ); + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + battle_profession_assist_fun(battleindex, attackNo, defNo, charaindex); + break; + } + //==== 击中改变状态系 ==================================================================== + case BATTLE_COM_S_SHIELD_ATTACK: // 盾击 + case BATTLE_COM_S_ENTWINE: // 树根缠绕 + case BATTLE_COM_S_DRAGNET: // 天罗地网 + case BATTLE_COM_S_TOXIN_WEAPON: // 毒素武器 + case BATTLE_COM_S_INSTIGATE: // 挑拨 + case BATTLE_COM_S_OBLIVION: // 遗忘 + { + // 防止同队互打 + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + if( BATTLE_CheckSameSide( charaindex, defNo) == 1 ){ + BATTLE_NoAction( battleindex, attackNo ); + if( COM == BATTLE_COM_S_TOXIN_WEAPON ) + printf("\nbug-同队互打"); + break; + } + } + case BATTLE_COM_S_RESIST_FIRE: // 火抗性提升 + case BATTLE_COM_S_RESIST_ICE: // 冰抗性提升 + case BATTLE_COM_S_RESIST_THUNDER: // 雷抗性提升 +#ifdef _PROFESSION_ADDSKILL + case BATTLE_COM_S_RESIST_F_I_T: // 自然威能 + case BATTLE_COM_S_BOUNDARY: // 四属性结界 +#endif + case BATTLE_COM_S_FIRE_ENCLOSE: // 火附体 + case BATTLE_COM_S_ICE_ENCLOSE: // 冰附体 + case BATTLE_COM_S_THUNDER_ENCLOSE: // 雷附体 + { + + CHAR_setFlg( charaindex, CHAR_ISATTACKED, 1 ); + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + battle_profession_status_chang_fun(battleindex, attackNo, defNo, charaindex); + + if( COM == BATTLE_COM_S_TOXIN_WEAPON ) + printf("\nbug-毒素武器处理结束"); + break; + } + //==================================================================================== +#endif + +#ifdef _PETSKILL_ACUPUNCTURE + case BATTLE_COM_S_ACUPUNCTURE: //针刺外皮 + CHAR_setWorkInt( charaindex, CHAR_WORKACUPUNCTURE, 1); + //print("\n针刺:%s",CHAR_getChar(charaindex,CHAR_NAME)); +#endif + case BATTLE_COM_S_CHARGE_OK: + case BATTLE_COM_S_POWERBALANCE: + case BATTLE_COM_S_STATUSCHANGE: + case BATTLE_COM_S_EARTHROUND0: + case BATTLE_COM_S_MIGHTY: + case BATTLE_COM_S_GUARDIAN_ATTACK: + case BATTLE_COM_S_RENZOKU: +#ifdef _BATTLE_ATTCRAZED // ANDY 疯狂暴走 + case BATTLE_COM_S_ATTCRAZED: +#endif +#ifdef _SHOOTCHESTNUT // Syu ADD 宠技:丢栗子 + case BATTLE_COM_S_ATTSHOOT: +#endif +#ifdef _SKILL_WILDVIOLENT_ATT + case BATTLE_COM_S_WILDVIOLENTATTACK://狂暴攻击 vincent add 2002/05/16 +#endif + +#ifdef _SKILL_SPEEDY_ATT + case BATTLE_COM_S_SPEEDYATTACK: //疾速攻击 vincent add 2002/05/20 +#endif + case BATTLE_COM_ATTACK: +#ifdef _PET_SKILL_SARS // WON ADD 毒煞蔓延 + case BATTLE_COM_S_SARS: +#endif + +#ifdef _PETSKILL_BECOMEFOX + case BATTLE_COM_S_BECOMEFOX: +#endif + +#ifdef _PETSKILL_BECOMEPIG + case BATTLE_COM_S_BECOMEPIG: +#endif + +#ifdef _PETSKILL_SHOWMERCY + case BATTLE_COM_S_SHOWMERCY: +#endif + +#ifdef _PETSKILL_GYRATE + case BATTLE_COM_S_GYRATE: + if( COM == BATTLE_COM_S_GYRATE ){ + int i,j=0,f_num,temp[5]={0}; + char szWork[256]; + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + if(defNo < 5) + f_num = 0; + else if(defNo >=5 && defNo < 10) + f_num = 5; + else if(defNo >=10 && defNo < 15) + f_num = 10; + else + f_num = 15; + + // 取出战场上存活的人 + for( i=f_num; i= 10 ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + defNo = aDefList[0]; + }else + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 + || defNo == attackNo){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + if( COM == BATTLE_COM_S_EARTHROUND0 ){ + sprintf( szWork, "BI|a%X|", attackNo ); + }else { +#ifdef _FIXBUG_ATTACKBOW + if( CHAR_getWorkInt( charaindex, CHAR_WORKITEMMETAMO) > 0 || + CHAR_getWorkInt( charaindex, CHAR_WORKNPCMETAMO) > 0 + || CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND ) != -1 ){ //若是变成小狐狸 + + if( gWeponType == ITEM_BOW || gWeponType == ITEM_BOUNDTHROW || + gWeponType == ITEM_BREAKTHROW || gWeponType == ITEM_BOOMERANG) { + CHAR_talkToCli( charaindex, -1, "变身中无法使用远距离武器!!", CHAR_COLORYELLOW); + continue; + } + + } +#endif + + if( gWeponType == ITEM_BOW ) sprintf( szWork, "BB|a%X|w0|", attackNo ); + else if( gWeponType == ITEM_BOUNDTHROW ) //若是丢斧头 + sprintf( szWork, "BB|a%X|w1|", attackNo ); + else if( gWeponType == ITEM_BREAKTHROW ) + sprintf( szWork, "BB|a%X|w2|", attackNo ); + else sprintf( szWork, "BH|a%X|", attackNo ); + } + +#ifdef _SHOOTCHESTNUT // Syu ADD 宠技:丢栗子 + if ( COM == BATTLE_COM_S_ATTSHOOT ) + sprintf( szWork, "BB|a%X|w0|", attackNo ); +#endif + + BATTLESTR_ADD( szWork ); + if( COM == BATTLE_COM_S_CHARGE_OK || + COM == BATTLE_COM_S_EARTHROUND0 ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + }else{ + +#ifdef _SHOOTCHESTNUT // Syu ADD 宠技:丢栗子 + if ( CHAR_getWorkInt(charaindex, CHAR_WORKBATTLECOM1) != BATTLE_COM_S_ATTSHOOT) +#endif +#ifdef _PETSKILL_SHOWMERCY + if( CHAR_getWorkInt(charaindex, CHAR_WORKBATTLECOM1) != BATTLE_COM_S_SHOWMERCY) +#endif + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1,BATTLE_COM_ATTACK ); + } + for( attack_count = 0, k = 0;; ){ + if( gWeponType == ITEM_BOW ){ + if( BATTLE_TargetCheck( battleindex, defNo ) == FALSE ){ + attack_flg = 0; + }else{ + attack_flg = 1; + } + } + + + if( attack_flg ){ + + + ContFlg = BATTLE_Attack( battleindex, attackNo, defNo ); +#ifdef _PETSKILL_RETRACE + if( Battle_Attack_ReturnData_x.Battle_Attack_ReturnData == BATTLE_RET_DODGE + && COM == BATTLE_COM_S_RETRACE ){ + if( RAND(1,100) < 80 ){ //80%机率发动2次攻击 + //攻+20% + + CHAR_setWorkInt( BATTLE_No2Index( battleindex, attackNo ), + CHAR_WORKATTACKPOWER, + ( CHAR_getWorkInt( BATTLE_No2Index( battleindex, attackNo ), CHAR_WORKFIXSTR) + ( CHAR_getWorkInt( BATTLE_No2Index( battleindex, attackNo ), CHAR_WORKFIXSTR) * 0.2 ) ) ); + + BATTLE_Attack( battleindex, attackNo, defNo ); + + } + Battle_Attack_ReturnData_x.Battle_Attack_ReturnData = 0; + } +#endif + BATTLE_AddProfit( battleindex, aAttackList); + if( ++attack_count >= attack_max ) break; + if( CHAR_getInt( charaindex, CHAR_HP ) <= 0 ) { + ContFlg = FALSE; + break; + } + } + defNo = aDefList[++k]; + if( defNo < 0 ) break; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, defNo ); + if( gWeponType == ITEM_BOW ){ + }else + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + break; + } + if( BATTLE_CountAlive( battleindex, 0) == 0 || BATTLE_CountAlive( battleindex, 1) == 0) { + break; + } + } + gBattleDamageModyfy = 1.0; + gBattleDuckModyfy = 0; + + for( k = 0; k < 5 && ContFlg == TRUE; k ++ ){ + if( ( k & 1 ) == 1 ){ + attackNoSub = attackNo; + defNoSub = defNo; + }else{ + defNoSub = attackNo; + attackNoSub = defNo; + } + + ContFlg = BATTLE_Counter(battleindex, attackNoSub, defNoSub ); + + aAttackList[0] = attackNoSub; + aAttackList[1] = -1; + BATTLE_AddProfit( battleindex, aAttackList); + } + aAttackList[0] = -1; + BATTLESTR_ADD( "FF|" ); + +#ifdef _PETSKILL_BECOMEFOX // 向对方使用媚惑术 + if ( (COM == BATTLE_COM_S_BECOMEFOX ) + && (Battle_Attack_ReturnData_x.Battle_Attack_ReturnData != BATTLE_RET_MISS) //没有miss + && (Battle_Attack_ReturnData_x.Battle_Attack_ReturnData != BATTLE_RET_DODGE) //没有闪避过 + && (Battle_Attack_ReturnData_x.Battle_Attack_ReturnData != BATTLE_RET_ALLGUARD) + && (Battle_Attack_ReturnData_x.Battle_Attack_ReturnData != BATTLE_RET_ARRANGE) + && (BATTLE_TargetCheck( battleindex, defNo )) //还活着 + && (rand()%100 < 31) + && (CHAR_getInt( BATTLE_No2Index( battleindex, defNo ), CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER) //只有宠物(CHAR_TYPEPET)才可以被媚惑 + && (CHAR_getWorkInt( BATTLE_No2Index( battleindex, defNo ), CHAR_WORK_PETFLG ) != 0 ) +#ifdef _PETSKILL_BECOMEPIG + && (CHAR_getInt( charaindex, CHAR_BECOMEPIG) == -1)//没有处於乌力化 +#endif + ) + { + int ToList[SIDE_OFFSET*2+1]; + int defindex = BATTLE_No2Index( battleindex, defNo ); + + BATTLE_MultiList( battleindex, defNo, ToList ); + BATTLE_MagicEffect( battleindex, defNo, ToList, 101120, 101750); + + CHAR_setWorkInt( defindex, CHAR_WORKFOXROUND, pBattle->turn ); + + if( CHAR_getInt( defindex, CHAR_RIDEPET) != -1 ) { //骑宠就要让他落马 + CHAR_setInt( defindex, CHAR_RIDEPET, -1 ); + BATTLE_changeRideImage( defindex ); + CHAR_setWorkInt( defindex, CHAR_WORKPETFALL, 1 ); + } + + CHAR_setInt( defindex, CHAR_BASEIMAGENUMBER, 101749); + } +#endif +#ifdef _PETSKILL_BECOMEPIG // 向对方使用乌力化 + if ( (COM == BATTLE_COM_S_BECOMEPIG ) + && (Battle_Attack_ReturnData_x.Battle_Attack_ReturnData != BATTLE_RET_MISS) //没有miss + && (Battle_Attack_ReturnData_x.Battle_Attack_ReturnData != BATTLE_RET_DODGE) //没有闪避过 + && (Battle_Attack_ReturnData_x.Battle_Attack_ReturnData != BATTLE_RET_ALLGUARD) + && (Battle_Attack_ReturnData_x.Battle_Attack_ReturnData != BATTLE_RET_ARRANGE) + && (BATTLE_TargetCheck( battleindex, defNo )) //还活着 + && (CHAR_getInt( BATTLE_No2Index( battleindex, defNo ), CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER) //只有玩家才可以被乌力化 + && (BATTLE_CheckSameSide( charaindex, defNo) != 1 ) // 防止同队互打 + && CHAR_getInt( BATTLE_No2Index( battleindex, defNo ), CHAR_BECOMEPIG) < 2000000000 ) //防止破表 + { + char temp[64]; + int ToList[SIDE_OFFSET*2+1], compute,petrate,pettime,pigbbi=100250; + char *pszOption=NULL; + int defindex = BATTLE_No2Index( battleindex, defNo ); + pszOption = PETSKILL_getChar( CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3 ), PETSKILL_OPTION ); + if( pszOption ) + sscanf( pszOption, "%d %d %d", &petrate, &pettime, &pigbbi); + else + petrate = 100, pettime = 60, pigbbi = 100250; + + if( rand()%100 < petrate ){ + CHAR_setWorkInt( defindex, CHAR_WORKITEMMETAMO, 0);//道具变身取消 + CHAR_setWorkInt( defindex, CHAR_WORKNPCMETAMO, 0 );//NPC变身取消 + CHAR_setWorkInt( defindex, CHAR_WORKFOXROUND, -1);//媚惑术变身取消 + + BATTLE_MultiList( battleindex, defNo, ToList ); + BATTLE_MagicEffect( battleindex, defNo, ToList, 101120, 101750); + + if( CHAR_getInt( defindex, CHAR_RIDEPET) != -1 ){ //骑宠就要让他落马 + CHAR_setInt( defindex, CHAR_RIDEPET, -1 ); + BATTLE_changeRideImage( defindex ); + CHAR_setWorkInt( defindex, CHAR_WORKPETFALL, 1 ); + } + + CHAR_setInt( defindex, CHAR_BECOMEPIG_BBI, pigbbi ); + + compute = CHAR_getInt( defindex, CHAR_BECOMEPIG); + CHAR_setInt( defindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( defindex, CHAR_BECOMEPIG_BBI ) ); + if( compute == -1 )//第一次中 + CHAR_setInt( defindex, CHAR_BECOMEPIG, pettime + 1 + compute ); //乌力化时间(单位:秒) + else + CHAR_setInt( defindex, CHAR_BECOMEPIG, pettime + compute ); + sprintf(temp, "乌力时间:%d秒", CHAR_getInt( defindex, CHAR_BECOMEPIG) ); + CHAR_talkToCli( defindex, -1, temp, CHAR_COLORYELLOW); + + print("\n乌力化开始0:%s,round:%d", CHAR_getChar( defindex, CHAR_NAME), CHAR_getWorkInt( defindex, CHAR_WORKFOXROUND)); + } + } +#endif + break; +//以下处理特殊攻击 + case BATTLE_COM_BOOMERANG: + gBattleDamageModyfy = 0.3; + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + if( defNo < 0 ){ + defNo = BATTLE_DefaultAttacker( battleindex, 1 - myside ); + } + if( 0 <= defNo && defNo <= 19 ){ + defNo /= 5; // + }else{ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + if( (int)(attackNo / 5 ) == defNo ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + { + int *pBoomerangTbl = BoomerangVsTbl[defNo]; + for( k = 0; k < 5; k ++ ){ + if( BATTLE_TargetCheck( battleindex, pBoomerangTbl[k] ) == FALSE ){ + continue; + }else{ + break; + } + } + if( k == 5 ){ + defNo = BATTLE_DefaultAttacker( battleindex, 1 - myside ); + if( 0 <= defNo && defNo <= 19 ){ + defNo /= 5; + }else{ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + } + } + sprintf( szWork, "BO|a%X|", attackNo ); + BATTLESTR_ADD( szWork ); + { + int *pBoomerangTbl = BoomerangVsTbl[defNo]; + if( myside == 1 ){ + k = 4; j = -1; + }else{ + k = 0; j = 1; + } + for( ; ; k += j ){ + if( j > 0 && k > 4 )break; + if( j < 0 && k < 0 )break; + defNo = pBoomerangTbl[k]; + if( BATTLE_TargetCheck( battleindex, defNo ) == FALSE ){ + continue; + } + BATTLE_Attack( battleindex, attackNo, defNo ); + } + } + gBattleDamageModyfy = 1.0; + gBattleDuckModyfy = 0; + BATTLESTR_ADD( "FF|" ); + break; + + //--------------------------------------------- + case BATTLE_COM_CAPTURE: + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + BATTLE_Capture( battleindex, attackNo, defNo ); + break; + + //--------------------------------------------- +#ifdef _VARY_WOLF + case BATTLE_COM_S_VARY: + { + int ToList[SIDE_OFFSET*2+1]; + int bk_amn = 0; + + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + bk_amn = (CHAR_getInt( charaindex, CHAR_BASEBASEIMAGENUMBER) + 5) + (myside*4); + BATTLE_MultiList( battleindex, defNo, ToList ); + BATTLE_MagicEffect( battleindex, attackNo, ToList, 101120, bk_amn); + } + break; +#endif + case BATTLE_COM_GUARD: + BATTLE_Guard( battleindex, attackNo ); + + break; + case BATTLE_COM_ESCAPE: + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPET ){ + if (BATTLE_Escape(battleindex, attackNo, 0) == TRUE) + { + if (CHAR_getWorkInt(charaindex, CHAR_WORKFMPKFLAG) == 1) + CHAR_setWorkInt(charaindex, CHAR_WORKFMPKFLAG, -1); +#ifdef _ESCAPE_RESET // 恶宝中纪录逃跑时间 + if( getStayEncount( getfdFromCharaIndex(charaindex) ) ) { + CHAR_setWorkInt( charaindex, CHAR_WORKLASTESCAPE, time(NULL)); + //print(" 逃了 "); + } +#endif + } + } + break; + case BATTLE_COM_COMPELESCAPE: //强制离开 + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPET ){ + BATTLE_Escape( battleindex, attackNo, 1); + if (CHAR_getWorkInt(charaindex, CHAR_WORKFMPKFLAG) == 1) + CHAR_setWorkInt(charaindex, CHAR_WORKFMPKFLAG, -1); + } + break; + + case BATTLE_COM_PETIN: + if( CHAR_getInt( charaindex, CHAR_DEFAULTPET ) == -1 ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + { + char szWork[256]; + snprintf( szWork, sizeof( szWork ), "K%d", CHAR_getInt( charaindex, CHAR_DEFAULTPET ) ); + CHAR_sendStatusString( charaindex, szWork ); + + } + BATTLE_PetIn( battleindex, attackNo ); + lssproto_KS_send( + getfdFromCharaIndex( charaindex ), + CHAR_getInt( charaindex, CHAR_DEFAULTPET ), 1 ); + break; + case BATTLE_COM_PETOUT: + if( CHAR_getInt( charaindex, CHAR_DEFAULTPET ) != -1 ){ + lssproto_KS_send( + getfdFromCharaIndex( charaindex ), + CHAR_getInt( charaindex, CHAR_DEFAULTPET ), 1 ); + { + char szWork[256]; + snprintf( szWork, sizeof( szWork ), "K%d", CHAR_getInt( charaindex, CHAR_DEFAULTPET ) ); + CHAR_sendStatusString( charaindex, szWork ); + + } + BATTLE_PetIn( battleindex, attackNo ); + } + // shan 2002/01/14 Begin 五只宠 + { + int attackindex, petNo; + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + petNo = CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM2 ); + if( CHAR_getWorkInt(charaindex, CHAR_WORK_PET0_STAT+petNo) != PET_STAT_SELECT) + break; + } + // shan End + BATTLE_PetOut( battleindex, attackNo ); + lssproto_KS_send( + getfdFromCharaIndex( charaindex ), + CHAR_getInt( charaindex, CHAR_DEFAULTPET ), 1 ); + break; +// Terry add 2001/11/05 +#ifdef __ATTACK_MAGIC + case BATTLE_COM_S_ATTACK_MAGIC: // 宠物魔法 + magic = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + toindex = CHAR_getWorkInt(charaindex,CHAR_WORKBATTLECOM2); +// print("magic->%d,toindex->%d\n",magic,toindex); + // 判断攻 围 + for(magic_count=0;magic_count= 0 && toindex <= 4) + toindex = TargetIndex[magic_count][1]; + // 打右下的前面那一排 + else + toindex = TargetIndex[magic_count][1]-1; + } + break; + } + } +// print("toindex->%d\n",toindex); + MAGIC_DirectUse(charaindex,magic,toindex,CHAR_GETWORKINT_HIGH(charaindex,CHAR_WORKBATTLECOM3)); + BATTLE_AddProfit( battleindex, aAttackList ); + break; +#endif + case BATTLE_COM_JYUJYUTU: + MAGIC_DirectUse( + charaindex, + CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3 ), + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ), + CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3 ) + ); + break; + + case BATTLE_COM_ITEM: + itemindex = CHAR_getItemIndex(charaindex, + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM3 )); + if( ITEM_CHECKINDEX( itemindex ) == FALSE ){ + print( "\nerr:要使用的item位置奇怪(%s)(%d)\n", + CHAR_getUseName( charaindex ), CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM3 ) ); + break; + } + +#if 1 // Robin fix 战斗不可换防具饰品 + { + int itemtype = ITEM_getInt( itemindex, ITEM_TYPE ); + if( itemtype == ITEM_HELM + || itemtype == ITEM_ARMOUR + || itemtype == ITEM_BRACELET + //|| itemtype == ITEM_MUSIC + || itemtype == ITEM_NECKLACE + || itemtype == ITEM_RING + || itemtype == ITEM_BELT + || itemtype == ITEM_EARRING + || itemtype == ITEM_NOSERING + || itemtype == ITEM_AMULET + //|| itemtype == CHAR_HEAD + ) + { + print("\n 改封包!战斗不可换防具!!:%s ", CHAR_getChar( charaindex, CHAR_CDKEY) ); + break; + } + } +#endif + +#ifdef _FIXBUG_ATTACKBOW + { + if( CHAR_getWorkInt( charaindex, CHAR_WORKITEMMETAMO) > 0 || + CHAR_getWorkInt( charaindex, CHAR_WORKNPCMETAMO) > 0 + || CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND ) != -1 ){ //若是变成小狐狸 + + int armtype; + int itemindex = CHAR_getItemIndex( charaindex, CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM3 )); + if( !ITEM_CHECKINDEX(itemindex) ) break; + armtype = ITEM_getInt( itemindex, ITEM_TYPE ); + + if( armtype == ITEM_BOW || armtype == ITEM_BOUNDTHROW || + armtype == ITEM_BREAKTHROW || armtype == ITEM_BOOMERANG) { + CHAR_talkToCli( charaindex, -1, "变身无法使用远距离武器!", CHAR_COLORYELLOW ); + break; + } + } + } +#endif + + CHAR_ItemUse( + charaindex, + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ), + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM3 ) + ); + + + if( ITEM_getEquipPlace( charaindex, itemindex ) == CHAR_ARM ){ + sprintf( szWork, "BN|a%X|%X|", attackNo, + CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER ) ); + BATTLESTR_ADD( szWork ); + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + // 武器专精 + BATTLE_ProfessionStatus_init( battleindex, charaindex ); +#endif + + }else{ + } + + break; + +#ifdef _PSKILL_FALLGROUND + case BATTLE_COM_S_FALLRIDE://落马术 + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + print("\n BATTLE_NoAction()"); + break; + } + ContFlg = BATTLE_S_FallGround( battleindex, attackNo, defNo, BATTLE_COM_S_FALLRIDE); + break; + +#endif +#ifdef _PETSKILL_EXPLODE + case BATTLE_COM_S_EXPLODE: + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + print("\n BATTLE_NoAction()"); + break; + } + ContFlg = BATTLE_S_Explode( battleindex, attackNo, defNo, BATTLE_COM_S_EXPLODE); + break; +#endif + +#ifdef _PETSKILL_TIMID + case BATTLE_COM_S_TIMID: + { + int skill; + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + print("\n BATTLE_NoAction()"); + break; + } + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_TIMID, skill); + } + break; +#endif +#ifdef _PETSKILL_2TIMID + case BATTLE_COM_S_2TIMID: + { + int skill; + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + print("\n BATTLE_NoAction()"); + break; + } + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_2TIMID, skill); + } + break; +#endif + +#ifdef _PETSKILL_PROPERTY + case BATTLE_COM_S_PROPERTYSKILL: + { + int skill; + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + BATTLE_S_PetSkillProperty( battleindex, attackNo, COM, skill); + BATTLE_NoAction( battleindex, attackNo ); + } + break; +#endif + +#ifdef _BATTLE_LIGHTTAKE + case BATTLE_COM_S_LIGHTTAKE: + { + int skill; + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + print("\n BATTLE_NoAction()"); + break; + } + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_LIGHTTAKE, skill); + } + break; +#endif + +#ifdef _SKILL_DAMAGETOHP + case BATTLE_COM_S_DAMAGETOHP: //嗜血技 + { + int skill; + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + print("\n BATTLE_NoAction()"); + break; + } + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_DAMAGETOHP, skill); + } + break; +#endif + +#ifdef _PETSKILL_DAMAGETOHP + case BATTLE_COM_S_DAMAGETOHP2: //暗月狂狼(嗜血技的变体) + { + int skill,attackidxtemp; + attackidxtemp = BATTLE_No2Index( battleindex, attackNo ); + + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + print("\n BATTLE_NoAction()"); + break; + } + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_DAMAGETOHP2, skill); + + } + break; +#endif + +#ifdef _Skill_MPDAMAGE + case BATTLE_COM_S_MPDAMAGE: //MP伤害 + { + int skill; + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + print("\n BATTLE_NoAction()"); + break; + } + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_MPDAMAGE, skill); + break; + } + break; +#endif +#ifdef _SKILL_TOOTH + case BATTLE_COM_S_TOOTHCRUSHE: + { + int skill; + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + print("\n BATTLE_NoAction()"); + break; + } + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_TOOTHCRUSHE, skill); + break; + } + break; +#endif +#ifdef _PSKILL_MODIFY + case BATTLE_COM_S_MODIFYATT: + { + int skill; + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + print("\n BATTLE_NoAction()"); + break; + } + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_MODIFYATT, skill); + } + break; +#endif +#ifdef _PSKILL_MDFYATTACK + case BATTLE_COM_S_MDFYATTACK: + { + int skill; + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + print("\n BATTLE_NoAction()"); + break; + } + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_MDFYATTACK, skill); + } + break; +#endif + +#ifdef _PETSKILL_TEAR + case BATTLE_COM_S_PETSKILLTEAR: + { + int skill; + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + print("\n BATTLE_NoAction()"); + break; + } + skill = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3); + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_PETSKILLTEAR, skill); + } + break; +#endif + +#ifdef _SONIC_ATTACK // WON ADD 音波攻击 + case BATTLE_COM_S_SONIC: + { + int skill, defNo2=-1, index2=-1; + + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + print("\n BATTLE_NoAction()"); + break; + } + skill = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3); + + if( defNo >= 15 && defNo < 20 ) defNo2 = defNo - 5; + else if( defNo >= 5 && defNo < 10 ) defNo2 = defNo - 5; + else defNo2 = -1; + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + index2 = BATTLE_No2Index( battleindex, defNo2 ); + + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_SONIC, skill ); + + if( index2 >= 0 ){ + if( defNo2 >= 0 ){ + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo2, BATTLE_COM_S_SONIC2, skill ); + } + } + + } + break; +#endif + +#ifdef _PETSKILL_REGRET + case BATTLE_COM_S_REGRET: + { + int skill, defNo2=-1, index2=-1; + + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + print("\n BATTLE_NoAction()"); + break; + } + skill = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3); + + if( defNo >= 15 && defNo < 20 ) defNo2 = defNo - 5; + else if( defNo >= 5 && defNo < 10 ) defNo2 = defNo - 5; + else defNo2 = -1; + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + index2 = BATTLE_No2Index( battleindex, defNo2 ); + + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_REGRET, skill ); + if( index2 >= 0 ){ + if( defNo2 >= 0 ){ + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo2, BATTLE_COM_S_REGRET2, skill ); + } + } + + } + break; +#endif + +#ifdef _MAGIC_SUPERWALL + case BATTLE_COM_S_SUPERWALL: + { + int skill; + defNo = CHAR_getWorkInt(charaindex,CHAR_WORKBATTLECOM2); + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + ContFlg = PETSKILL_MagicStatusChange_Battle( battleindex, attackNo, defNo, skill); + } + break; +#endif +#ifdef _PETSKILL_SETDUCK + case BATTLE_COM_S_SETDUCK: + { + int skill; + defNo = CHAR_getWorkInt(charaindex,CHAR_WORKBATTLECOM2); + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + ContFlg = PETSKILL_SetDuckChange_Battle( battleindex, attackNo, defNo, skill); + break; + } +#endif +#ifdef _MAGICPET_SKILL + case BATTLE_COM_S_SETMAGICPET: + { + int skill; + defNo = CHAR_getWorkInt(charaindex,CHAR_WORKBATTLECOM2); + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + ContFlg = PETSKILL_SetMagicPet_Battle( battleindex, attackNo, defNo, skill); + break; + } +#endif +#ifdef _PRO_BATTLEENEMYSKILL + case BATTLE_COM_S_ENEMYRELIFE: + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + print("\n BATTLE_NoAction()"); + break; + } + + ContFlg =BATTLE_E_ENEMYREFILE( battleindex, attackNo, defNo, BATTLE_COM_S_ENEMYRELIFE); + if( ContFlg == FALSE ) { + CHAR_setFlg( charaindex, CHAR_ISATTACKED, 1 ); + ContFlg = BATTLE_Attack( battleindex, attackNo, defNo ); + BATTLE_AddProfit( battleindex, aAttackList ); + } + BATTLE_AddProfit( battleindex, aAttackList ); + break; + + case BATTLE_COM_S_ENEMYREHP: + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + print("\n BATTLE_NoAction()"); + break; + } + ContFlg =BATTLE_E_ENEMYREHP( battleindex, attackNo, defNo, BATTLE_COM_S_ENEMYREHP); + if( ContFlg == FALSE ) { + CHAR_setFlg( charaindex, CHAR_ISATTACKED, 1 ); + ContFlg = BATTLE_Attack( battleindex, attackNo, defNo ); + BATTLE_AddProfit( battleindex, aAttackList ); + } + BATTLE_AddProfit( battleindex, aAttackList ); + break; + + case BATTLE_COM_S_ENEMYHELP: + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + print("\n BATTLE_NoAction()"); + break; + } + ContFlg =BATTLE_E_ENEMYHELP( battleindex, attackNo, defNo, BATTLE_COM_S_ENEMYREHP); + if( ContFlg == FALSE ) { + CHAR_setFlg( charaindex, CHAR_ISATTACKED, 1 ); + ContFlg = BATTLE_Attack( battleindex, attackNo, defNo ); + BATTLE_AddProfit( battleindex, aAttackList ); + } + BATTLE_AddProfit( battleindex, aAttackList ); + break; +#endif + case BATTLE_COM_S_GBREAK: //破除防御 + + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + ContFlg = BATTLE_S_GBreak( battleindex, attackNo, defNo ); + break; +#ifdef _SKILL_GUARDBREAK2//破除防御2 vincent add 2002/05/20 + case BATTLE_COM_S_GBREAK2: + //确定攻击对象 + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + ContFlg = BATTLE_S_GBreak2( battleindex, attackNo, defNo ); + break; +#endif + +#ifdef _SKILL_SACRIFICE + case BATTLE_COM_S_SACRIFICE://救援 vincent add 2002/05/30 + //确定攻击对象 + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + ContFlg = BATTLE_S_Sacrifice( battleindex, attackNo, defNo ); + + break; +#endif + +#ifdef _SKILL_REFRESH + case BATTLE_COM_S_REFRESH://状态回复 vincent add 2002/08/08 + { + int array; + array = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); +// print("\n vincent--case BATTLE_COM_S_REFRESH:-->defNo:%d",defNo); + ContFlg = BATTLE_S_Refresh( battleindex, attackNo, defNo ,array); + } + break; +#endif + +#ifdef _SKILL_WEAKEN //vincent宠技:虚弱 + case BATTLE_COM_S_WEAKEN: + { + int array; + array = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + //print("\n vincent--case BATTLE_COM_S_WEAKEN:-->defNo:%d",defNo); + ContFlg = BATTLE_S_Weaken( battleindex, attackNo, defNo ,array); + } + break; +#endif + +#ifdef _SKILL_DEEPPOISON //vincent宠技:剧毒 + case BATTLE_COM_S_DEEPPOISON: + { + int array; + array = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + ContFlg = BATTLE_S_Deeppoison( battleindex, attackNo, defNo ,array); + } + break; +#endif + +#ifdef _SKILL_BARRIER //vincent宠技:魔障 + case BATTLE_COM_S_BARRIER: + { + int array; + array = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + ContFlg = BATTLE_S_Barrier( battleindex, attackNo, defNo ,array); + } + break; +#endif + +#ifdef _SKILL_NOCAST //vincent宠技:沉默 + case BATTLE_COM_S_NOCAST: + { + int array; + array = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + ContFlg = BATTLE_S_Nocast( battleindex, attackNo, defNo ,array); + } + break; +#endif + +#ifdef _SKILL_ROAR //vincent宠技:大吼 + case BATTLE_COM_S_ROAR: + { + int array; + //确定攻击对象 + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + array = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + ContFlg = BATTLE_S_Roar( battleindex, attackNo, defNo ,array); + } + break; +#endif + case BATTLE_COM_S_ABDUCT: + { + int array; + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + array = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3); + BATTLE_Abduct( battleindex, attackNo, defNo, array); + } + break; + case BATTLE_COM_COMBO: + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + gDamageDiv = 1.0; + ComboId = EntryList[i].combo; + aAttackList[0] = EntryList[i].num; // 伉旦玄卞笛尹月 + i ++; // 戚及谛井日 + k = 1; + for( ; EntryList[i].combo == ComboId && i < entrynum; i ++ ){ + int charmode; + // 绣箕允月井民尼永弁 + if( CHAR_CHECKINDEX( EntryList[i].charaindex ) == FALSE )continue; + + // 爵 卞辅笛仄化中卅中桦宁反戚尺 + charmode = CHAR_getWorkInt( EntryList[i].charaindex, CHAR_WORKBATTLEMODE ); + if( charmode == 0 || charmode == BATTLE_CHARMODE_FINAL ){ + continue; + } + + // 旦 □正旦唱橘荚汊↓ 质 + BATTLE_StatusSeq( EntryList[i].charaindex ); +#ifdef _OTHER_MAGICSTAUTS + BATTLE_MagicStatusSeq( EntryList[i].charaindex ); +#endif + // 仃卅井匀凶桦宁 + if( BATTLE_CanMoveCheck( EntryList[i].charaindex ) == FALSE ){ + continue; + } + if( CHAR_getInt( EntryList[i].charaindex, CHAR_HP ) <= 0 ){ + continue; + } + aAttackList[k++] = EntryList[i].num; + } + aAttackList[k] = -1; + i--; + if( k == 1 ){ + print( "\nerr:一人combo bug\n" ); + } + sprintf( szWork, "BY|r%X|", defNo ); + BATTLESTR_ADD( szWork ); + BATTLE_Combo( battleindex, aAttackList, defNo ); + +#ifdef _Item_ReLifeAct + BATTLE_AddProfit( battleindex, aAttackList ); +#endif + // 反 FF 毛仁匀勾仃月 + BATTLESTR_ADD( "FF|" ); + break; + + //--------------------------------------------- + case BATTLE_COM_WAIT: + case BATTLE_COM_NONE: + BATTLE_NoAction( battleindex, attackNo ); + break; + + //--------------------------------------------- + case BATTLE_COM_S_EARTHROUND1: + BATTLE_EarthRoundHide( battleindex, attackNo ); + break; + + //--------------------------------------------- + case BATTLE_COM_S_LOSTESCAPE: + BATTLE_LostEscape( battleindex, attackNo ); + break; + + case BATTLE_COM_S_STEAL: + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + BATTLE_Steal( battleindex, attackNo, defNo ); + break; + +#ifdef _BATTLESTEAL_FIX + case BATTLE_COM_S_STEALMONEY: + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + BATTLE_StealMoney( battleindex, attackNo, defNo) ; + break; +#endif + case BATTLE_COM_S_NOGUARD: + BATTLE_NoAction( battleindex, attackNo ); + break; + case BATTLE_COM_S_CHARGE: + sprintf( szWork, "bt|%x|", attackNo ); + BATTLESTR_ADD( szWork ); + break; +#ifdef _PETSKILL_LER + case BATTLE_COM_S_BAT_FLY: + { + if((defNo = BATTLE_TargetAdjust(battleindex,charaindex,myside)) < 0){ + BATTLE_NoAction(battleindex,attackNo); + break; + } + + BATTLE_BatFly(battleindex,attackNo,myside); + } + break; + case BATTLE_COM_S_DIVIDE_ATTACK: + { + if((defNo = BATTLE_TargetAdjust(battleindex,charaindex,myside)) < 0){ + BATTLE_NoAction(battleindex,attackNo); + break; + } + + BATTLE_DivideAttack(battleindex,attackNo,myside); + } + break; +#endif +#ifdef _PETSKILL_BATTLE_MODEL + case BATTLE_COM_S_BATTLE_MODEL: + BATTLE_BattleModel(battleindex,attackNo,myside); + break; +#endif + //--------------------------------------------- + default: + print( "\nerr:奇怪的命令(%d:%d:%s)\n", charaindex, COM, + CHAR_getUseName( charaindex ) ); + sprintf( szWork, "bg|%x|", attackNo ); + BATTLESTR_ADD( szWork ); + break; + } +#ifdef _VARY_WOLF + if(CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER)==101428) + { + if(CHAR_getWorkInt( charaindex, CHAR_WORKTURN)==0) + CHAR_setWorkInt( charaindex, CHAR_WORKTURN, 1); + else + CHAR_setWorkInt( charaindex, CHAR_WORKTURN, CHAR_getWorkInt( charaindex, CHAR_WORKTURN)+1); + + if(CHAR_getWorkInt( charaindex, CHAR_WORKTURN)>5) + { + CHAR_setInt( charaindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( charaindex, CHAR_BASEBASEIMAGENUMBER)); + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, CHAR_getWorkInt( charaindex, CHAR_WORKFIXSTR)); + CHAR_setWorkInt( charaindex, CHAR_WORKQUICK, CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX)); + CHAR_setWorkInt( charaindex, CHAR_WORKTURN, 0); + } + } +#endif + +#ifdef _PETSKILL_BECOMEFOX // 判断中了媚惑术後是否已到恢复的回合数 + //if(CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER)==101749) //用图号判断的话,若是人变身时,会被自动改回去 + if( CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND ) != -1 ) //若是变成小狐狸 + { + if(CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER)!=101749) + CHAR_setInt( charaindex, CHAR_BASEIMAGENUMBER, 101749 ); + + if(pBattle->turn - CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND) > 2) + { + int defNo = BATTLE_Index2No( battleindex, charaindex ); + int toNo = defNo - 5;//主人的编号 + //print("\n变身人物回复:%s,round:%d", CHAR_getChar( charaindex, CHAR_NAME), CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND)); + + CHAR_setInt( charaindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( charaindex, CHAR_BASEBASEIMAGENUMBER)); + + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, CHAR_getWorkInt( charaindex, CHAR_WORKFIXSTR)); + CHAR_setWorkInt( charaindex, CHAR_WORKDEFENCEPOWER, CHAR_getWorkInt( charaindex, CHAR_WORKFIXTOUGH)); + CHAR_setWorkInt( charaindex, CHAR_WORKQUICK, CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX)); + CHAR_setWorkInt( charaindex, CHAR_WORKFOXROUND, -1); + + //Change fix 回复宠物忘掉的技能 + sprintf( szWork, "W%d", CHAR_getInt( BATTLE_No2Index( battleindex, toNo ), CHAR_DEFAULTPET ) ); + CHAR_sendStatusString( BATTLE_No2Index( battleindex, toNo ), szWork ); + } + } +#endif +#ifdef _PETSKILL_BECOMEPIG + if( CHAR_getInt( charaindex, CHAR_BECOMEPIG) > -1 + && (CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER) ) + { + char pigbuffer[128]; + CHAR_setInt( charaindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( charaindex, CHAR_BECOMEPIG_BBI ) ); + if( CHAR_getInt( charaindex, CHAR_BECOMEPIG) > 0 ){ + sprintf(pigbuffer, "乌力时间:%d秒", CHAR_getInt( charaindex, CHAR_BECOMEPIG )); + CHAR_talkToCli( charaindex,-1,pigbuffer,CHAR_COLORWHITE); + } + else{ + sprintf(pigbuffer, " 乌力时间结束,离开战斗後可解除乌力化:%d ", CHAR_getInt( charaindex, CHAR_BECOMEPIG )); + CHAR_talkToCli( charaindex,-1,pigbuffer,CHAR_COLORWHITE); + } + } +#endif + +#ifdef _PROFESSION_ADDSKILL + { +/* for(i=0;i<20;i++){ + if( pBattle->ice_use[i] ){//冰爆准备中 + print("\n冰爆准备中"); + if( pBattle->ice_bout[i] > 0 ){//冰爆倒数 + print("\n冰爆倒数"); + if( --pBattle->ice_bout[i] == 0 ){//放冰爆 + print("\n放冰爆"); + pBattle->ice_use[i] = FALSE; + if( CHAR_CHECKINDEX(pBattle->ice_charaindex[i]) ){ + int battlecom = CHAR_getWorkInt( pBattle->ice_charaindex[i], CHAR_WORKBATTLECOM1 ); + print("\n冰爆"); + print("\nbattlecom:%d",battlecom); + CHAR_setWorkInt( pBattle->ice_charaindex[i], CHAR_WORKBATTLECOM1, BATTLE_COM_S_ICE_CRACK ); + CHAR_SETWORKINT_HIGH( pBattle->ice_charaindex[i], CHAR_WORKBATTLECOM3, pBattle->ice_level[i] ); + CHAR_setWorkInt( pBattle->ice_charaindex[i], CHAR_WORKBATTLECOM2, pBattle->ice_toNo[i] ); + CHAR_SETWORKINT_HIGH( pBattle->ice_charaindex[i], CHAR_WORKBATTLECOM3, pBattle->ice_level[i] ); + CHAR_SETWORKINT_LOW( pBattle->ice_charaindex[i], CHAR_WORKBATTLECOM3, pBattle->ice_array[i] ); + battle_profession_attack_magic_fun(battleindex, pBattle->ice_attackNo[i], pBattle->ice_toNo[i], pBattle->ice_charaindex[i]); + CHAR_setWorkInt( pBattle->ice_charaindex[i], CHAR_WORKBATTLECOM1, battlecom ); + } + } + } + } + }*/ + } + { + int earth_boundary = GETHIGHVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXEARTHAT_BOUNDARY ) ); + int water_boundary = GETHIGHVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXWATERAT_BOUNDARY ) ); + int fire_boundary = GETHIGHVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXFIREAT_BOUNDARY ) ); + int wind_boundary = GETHIGHVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXWINDAT_BOUNDARY ) ); + int boundary_turn=0; + BOOL boundaryclear = FALSE; + if( earth_boundary > 0 ){//地结界 + boundary_turn = GETLOWVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXEARTHAT_BOUNDARY ) ) - 1; +print("\n地:%d ",boundary_turn ); + if( boundary_turn <= -1 ) + CHAR_setWorkInt( charaindex, CHAR_WORKFIXEARTHAT_BOUNDARY, 0 ),boundaryclear = TRUE; + else + CHAR_setWorkInt( charaindex, CHAR_WORKFIXEARTHAT_BOUNDARY, MAKE2VALUE(earth_boundary,boundary_turn) ); + + } + if( water_boundary > 0 ){//水结界 + boundary_turn = GETLOWVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXWATERAT_BOUNDARY ) ) - 1; +print("\n水:%d ",boundary_turn ); + + if( boundary_turn <= -1 ) + CHAR_setWorkInt( charaindex, CHAR_WORKFIXWATERAT_BOUNDARY, 0 ),boundaryclear = TRUE; + else + CHAR_setWorkInt( charaindex, CHAR_WORKFIXWATERAT_BOUNDARY, MAKE2VALUE(water_boundary,boundary_turn) ); + + } + if( fire_boundary > 0 ){//火结界 + boundary_turn = GETLOWVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXFIREAT_BOUNDARY ) ) - 1; +print("\n火:%d ",boundary_turn ); + + if( boundary_turn <= -1 ) + CHAR_setWorkInt( charaindex, CHAR_WORKFIXFIREAT_BOUNDARY, 0 ),boundaryclear = TRUE; + else + CHAR_setWorkInt( charaindex, CHAR_WORKFIXFIREAT_BOUNDARY, MAKE2VALUE(fire_boundary,boundary_turn) ); + + } + if( wind_boundary > 0 ){//风结界 + boundary_turn = GETLOWVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXWINDAT_BOUNDARY ) ) - 1; +print("\n风:%d ",boundary_turn ); + + if( boundary_turn <= -1 ) + CHAR_setWorkInt( charaindex, CHAR_WORKFIXWINDAT_BOUNDARY, 0 ),boundaryclear = TRUE; + else + CHAR_setWorkInt( charaindex, CHAR_WORKFIXWINDAT_BOUNDARY, MAKE2VALUE(wind_boundary,boundary_turn) ); + + } + if( GETHIGHVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXEARTHAT_BOUNDARY ) ) == 0 + && GETHIGHVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXWATERAT_BOUNDARY ) ) == 0 + && GETHIGHVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXFIREAT_BOUNDARY ) ) == 0 + && GETHIGHVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXWINDAT_BOUNDARY ) ) == 0 + && boundaryclear ){ + int toNo = BATTLE_Index2No( battleindex, charaindex ); + if( toNo < 10 )//右方 + snprintf( szWork, sizeof( szWork ), "Ba|%X|%X|", 0,1 ); + else + snprintf( szWork, sizeof( szWork ), "Ba|%X|%X|", 0,0 ); + BATTLESTR_ADD( szWork ); + BATTLESTR_ADD( "FF|" ); + } + } +#endif + +#ifdef _Item_ReLifeAct + { + //pEntry + int k, userindex=-1; + // if( BattleArray[ battleindex].type != BATTLE_TYPE_P_vs_P){ + for( k=0; k<20; k++) { + userindex = BATTLE_getBattleDieIndex( battleindex, k); + if( !CHAR_CHECKINDEX( userindex) ) continue; + //Change fix CHECK_ITEM_RELIFE里面有检查了,这里不用 + //if( CHAR_getFlg( userindex, CHAR_ISDIE ) == FALSE ) + // continue; + if( CHAR_getInt( userindex, CHAR_HP) > 0 ) + continue; + if( CHAR_getInt( userindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ) { + CHECK_ITEM_RELIFE( battleindex, userindex); + } +#ifdef _LOSE_FINCH_ + else if( CHAR_getInt( userindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + CHECK_PET_RELIFE( battleindex, userindex); + } +#endif + } + } +#endif + BATTLESTR_ADD( szBadStatusString ); + BATTLE_AddProfit( battleindex, aAttackList );//取得经验值 + len = pszBattleTop - szBattleString; + if( AllSize + len >= sizeof( szAllBattleString ) - 1 ){ + // 引匹中匀凶井日窒手仄卅中 + }else{ + memcpy( szAllBattleString+AllSize, szBattleString, len ); + szAllBattleString[AllSize+len] = 0;// NULL 毛本永玄 + AllSize += len; + } + +#ifdef _CHECK_BATTLETIME + check_battle_com_end( COM); +#endif + + if( BATTLE_CountAlive( battleindex, 0 ) == 0 || BATTLE_CountAlive( battleindex, 1 ) == 0 ) { + break; + } + } +#ifdef _PETSKILL_LER + { + register int i,dieindex; + for(i=0;i<20;i++){ + dieindex = BATTLE_getBattleDieIndex(battleindex,i); + if(!CHAR_CHECKINDEX(dieindex)) continue; + if(CHAR_getFlg(dieindex,CHAR_ISDIE) == FALSE) continue; + if(CHAR_getInt(dieindex,CHAR_HP) > 0) continue; + // 雷尔死亡,变身 + if(CHAR_getInt(dieindex,CHAR_BASEBASEIMAGENUMBER) == 101813 || + CHAR_getInt(dieindex,CHAR_BASEBASEIMAGENUMBER) == 101814) + BATTLE_LerChange(battleindex,dieindex,i); + } + } +#endif + + szBattleString[0] = 0; + pszBattleTop = szBattleString; + pszBattleLast = szBattleString+arraysizeof(szBattleString); + if( pBattle->field_att != BATTLE_ATTR_NONE ){ + pBattle->att_count--; + if( pBattle->att_count <= 0 ){ + pBattle->field_att = BATTLE_ATTR_NONE; + //snprintf( szBuffer, sizeof(szBuffer), + // "field回复成无属性。" + //); + //BATTLE_BroadCast( battleindex, szBuffer, CHAR_COLORYELLOW ); + BATTLESTR_ADD( "BV|15|0|" ); + } + } + + strncat( szAllBattleString, szBattleString, sizeof( szAllBattleString ) ); + for( i = 0; i < entrynum; i ++ ){ + charaindex = EntryList[i].charaindex; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_RESCUE ) + continue; + + if( BATTLE_CommandSend( charaindex, szAllBattleString ) == TRUE ){ + } + } + pWatchBattle = pBattle->pNext; + for( ; pWatchBattle ; pWatchBattle = pWatchBattle->pNext ){ + if( BATTLE_CHECKADDRESS( pWatchBattle ) == FALSE ){ + print( "err:观战battle address错误(%p)\n", pWatchBattle ); + break; + } + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pWatchBattle->Side[0].Entry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + BATTLE_CommandSend( charaindex, szAllBattleString ); + } + pWatchBattle->mode = BATTLE_MODE_WATCHAFTER; + } + + return 0; +} + +#ifdef _Item_ReLifeAct +BOOL CHECK_ITEM_RELIFE( int battleindex, int toindex) +{ + int i, itemindex; + CHAR_EquipPlace ep; + typedef void (*DIERELIFEFUNC)(int,int,int); + DIERELIFEFUNC Drf; + + if( CHAR_getInt( toindex, CHAR_HP) > 0 ) + return FALSE; + +#ifdef _DUMMYDIE + if( CHAR_getFlg( toindex, CHAR_ISDIE ) == FALSE && CHAR_getFlg( toindex, CHAR_ISDUMMYDIE ) == FALSE ) +#else + if( CHAR_getFlg( toindex, CHAR_ISDIE ) == FALSE ) +#endif + return FALSE; + + for( i = 0 ; i < 5 ; i++ ){ + itemindex = CHAR_getItemIndex( toindex , i ); + if( !ITEM_CHECKINDEX( itemindex)) + continue; + ep = ITEM_getEquipPlace( toindex, itemindex ); + if( ep == -1 ) + continue; + Drf=(DIERELIFEFUNC)ITEM_getFunctionPointer(itemindex, ITEM_DIERELIFEFUNC); + if( Drf ) { + Drf( toindex, itemindex, i); + return TRUE; + } + } + + return FALSE; + +} +#endif + +#ifdef _LOSE_FINCH_ +BOOL CHECK_PET_RELIFE( int battleindex, int petindex) +{ + int ReceveEffect=-1; + int toNo; + int attackNo=-1; + int WORK_HP=1; + int i; + struct _RePet{ + int petid; + int Effect; + int Addhp; +//Syu Mod +// }rePet[]={{1,SPR_fukkatu3,100},{-1,0,0}}; + }rePet[]={{-1,0,0}}; + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE ) { + return FALSE; + } + if( CHAR_CHECKINDEX( petindex) == FALSE ) + return FALSE; + + if( CHAR_getFlg( petindex, CHAR_ISDIE) == FALSE ) { + print("\n PET_RELIFE:[ %d, CHAR_ISDIE FALSE] return !", petindex); + return FALSE; + } + if( CHAR_getWorkInt( petindex, CHAR_WORKSPETRELIFE) != 0 ) + return FALSE; + for( i=0;iskill, SKILL_LEVEL); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_M( skill_level ); + + if( skill_level >= 6 ) add_practice = (skill_level-5) * 3 + 10; + else add_practice = skill_level * 2; + if( add_practice > 25 ) add_practice = 25; + + add_practice += old_practice; + // 因为old_practice=0所以add_practice为2~25 + + CHAR_setWorkInt( charaindex, CHAR_WORK_F_PROFICIENCY, add_practice ); + + }else + // 冰熟练度 + if( (strcmp( skill_name , "PROFESSION_ICE_PRACTICE" )) == 0 ){ + int old_practice = CHAR_getInt( charaindex, PROFESSION_ICE_P ); + int add_practice = 0; + int skill_level = 0; + + // 技能等级 + hskill = CHAR_getCharHaveSkill( charaindex, i ); + skill_level = SKILL_getInt( &hskill->skill, SKILL_LEVEL); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_M( skill_level ); + + if( skill_level >= 6 ) add_practice = (skill_level-5) * 3 + 10; + else add_practice = skill_level * 2; + if( add_practice > 25 ) add_practice = 25; + + add_practice += old_practice; + + CHAR_setWorkInt( charaindex, CHAR_WORK_I_PROFICIENCY, add_practice ); + + }else + // 雷熟练度 + if( (strcmp( skill_name , "PROFESSION_THUNDER_PRACTICE" )) == 0 ){ + int old_practice = CHAR_getInt( charaindex, PROFESSION_THUNDER_P ); + int add_practice = 0; + int skill_level = 0; + + // 技能等级 + hskill = CHAR_getCharHaveSkill( charaindex, i ); + skill_level = SKILL_getInt( &hskill->skill, SKILL_LEVEL); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_M( skill_level ); + + if( skill_level >= 6 ) add_practice = (skill_level-5) * 3 + 10; + else add_practice = skill_level * 2; + if( add_practice > 25 ) add_practice = 25; + + add_practice += old_practice; + + CHAR_setWorkInt( charaindex, CHAR_WORK_T_PROFICIENCY, add_practice ); + + }else + // 回避 + if( (strcmp( skill_name , "PROFESSION_AVOID" )) == 0 ){ + int skill_level = 0; + + if( profession_class != PROFESSION_SKILL_getInt( Pskillid, PROFESSION_SKILL_PROFESSION_CLASS) ) return; + + // 技能等级 + hskill = CHAR_getCharHaveSkill( charaindex, i ); + skill_level = SKILL_getInt( &hskill->skill, SKILL_LEVEL); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_A( skill_level ); + + if( skill_level <=5 ) + value = skill_level * 2; + else + value = (skill_level-5) * 3; + if( value > 25 ) value = 25; + + CHAR_setWorkInt( charaindex, CHAR_WORK_P_DUCK, 1); + CHAR_setWorkInt( charaindex, CHAR_WORKMOD_P_DUCK, value ); + + }else + // 格档 + if( (strcmp( skill_name , "PROFESSION_DEFLECT" )) == 0 ){ + int skill_level = 0; + int old_value = 0, add_value = 0; + + if( profession_class != PROFESSION_SKILL_getInt( Pskillid, PROFESSION_SKILL_PROFESSION_CLASS) ) return; + + // 技能等级 + hskill = CHAR_getCharHaveSkill( charaindex, i ); + skill_level = SKILL_getInt( &hskill->skill, SKILL_LEVEL); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_A( skill_level ); + + old_value = CHAR_getWorkInt( charaindex, CHAR_WORKFIXARRANGE ); + add_value = old_value + skill_level + 10; + + CHAR_setWorkInt( charaindex, CHAR_WORKFIXARRANGE, add_value ); + CHAR_complianceParameter( charaindex ); + + }else + // 武器专精 + if( (strcmp( skill_name , "PROFESSION_WEAPON_FOCUS" )) == 0 ){ + int skill_level = 0; + + rate = 0; + if( profession_class != PROFESSION_SKILL_getInt( Pskillid, PROFESSION_SKILL_PROFESSION_CLASS) ) continue; + + // 技能等级 + hskill = CHAR_getCharHaveSkill( charaindex, i ); + skill_level = SKILL_getInt( &hskill->skill, SKILL_LEVEL); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_A( skill_level ); + + // 技能参数 + pszOption = PROFESSION_SKILL_getChar( Pskillid, PROFESSION_SKILL_OPTION); + if( pszOption == NULL ) continue; + + // 装备武器 + WeaponType = BATTLE_GetWepon( charaindex ); + + switch( WeaponType ){ + case ITEM_AXE: + if( (pszP=strstr( pszOption, "斧" ))!=NULL) rate = 1; break; + case ITEM_CLUB: + if( (pszP=strstr( pszOption, "棍" ))!=NULL) rate = 1; break; + case ITEM_SPEAR: + if( (pszP=strstr( pszOption, "枪" ))!=NULL) rate = 1; break; + case ITEM_BOW: + if( (pszP=strstr( pszOption, "弓" ))!=NULL) rate = 1; break; + case ITEM_BOOMERANG: // 回旋标 + if( (pszP=strstr( pszOption, "镖" ))!=NULL) rate = 1; break; + case ITEM_BOUNDTHROW: // 投掷斧头 + if( (pszP=strstr( pszOption, "投" ))!=NULL) rate = 1; break; + case ITEM_BREAKTHROW: // 投掷石 + if( (pszP=strstr( pszOption, "石" ))!=NULL) rate = 1; break; + default: rate = 0; break; + } + + if( rate == 1 ){ + old_value = CHAR_getWorkInt( charaindex, CHAR_MYSKILLSTRPOWER); + + if( skill_level <=5 ) + value = skill_level * 2 + old_value; + else + value = (skill_level-5) * 3 + 10 + old_value; + + if( value > 25 ) value = 25; + + CHAR_setWorkInt( charaindex, CHAR_WORK_WEAPON, 1 ); + CHAR_setWorkInt( charaindex, CHAR_WORKMOD_WEAPON, value ); + } + } + } + } + return; +} + + +void BATTLE_ProfessionStatusSeq( int battleindex, int charaindex ) +{ + int profession_class=0, i=0, j=0, Pskillid=-1, skillid=-1; + int skill_level=0, value=0, old_value=0; + int bid=-1, hp=0, flag=0; + char *skill_name, szcommand[256]; + CHAR_HaveSkill* hskill; + + + int status_table[9]={ 2, //麻痹 + 3, //睡眠 + 4, //石化 + 12, //晕眩 + 13, //缠绕 + 14, //天罗 + 15, //冰暴 + 17, //冰箭 + 23, }; //雷附体 + +#ifdef _PETSKILL_DAMAGETOHP +/* { + char msg[32]={0}; + int pet,pindex; + pet = CHAR_getInt( charaindex, CHAR_DEFAULTPET ); + if( pet >= 0 ){ + sprintf( msg, "o%d", pet ); + //if(CHAR_getInt( petindex, CHAR_PETID) == "狼" //宠物ID + // && CHAR_getInt( petindex, CHAR_HP) ) + CHAR_sendStatusString( charaindex, msg ); + pindex = CHAR_getCharPet( charaindex, pet ); + print("\n宠物名:%s",CHAR_getChar( pindex, CHAR_NAME)); + } + else + print("\无宠物"); + + } */ +#endif + + if ( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) return; + + profession_class=CHAR_getInt( charaindex, PROFESSION_CLASS); + if( profession_class <= PROFESSION_CLASS_NONE ) return; + + for( i=0; i 0 ){ + flag=1; + break; + } + } + + if( flag > 0 ){ + // 技能等级 + hskill = CHAR_getCharHaveSkill( charaindex, i ); + skill_level = SKILL_getInt( &hskill->skill, SKILL_LEVEL); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_M( skill_level ); + + value = skill_level * 2; + if( value > 20 ) value = 20; + + old_value = CHAR_getWorkInt( charaindex, CHAR_WORKMAXHP); + + value = old_value * value / 100 ; + + hp = CHAR_getInt( charaindex, CHAR_HP); + + if( value + hp > old_value ) + value = old_value - hp; + + if( value < 0 ) value = 0; + + CHAR_setInt( charaindex, CHAR_HP, value + hp ); + + bid = BATTLE_Index2No( battleindex, charaindex ); + sprintf( szcommand, "BD|r%X|0|1|%X|", bid, value ); + BATTLESTR_ADD( szcommand ); + + PROFESSION_SKILL_LVEVEL_UP( charaindex, "PROFESSION_REBACK" ); + } + } + + // 陷阱 + if( (strcmp( skill_name , "PROFESSION_TRAP" )) == 0 ){ + int count=0; + + count = CHAR_getWorkInt( charaindex, CHAR_WORKTRAP); + if( count > 0 ){ + count--; + CHAR_setWorkInt( charaindex, CHAR_WORKTRAP, count ); + }else if( count == 0 ){ + CHAR_setWorkInt( charaindex, CHAR_WORKTRAP, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORKMODTRAP, 0 ); + } + } + } + + return; +} + +#endif diff --git a/gmsv/battle/battle.c.bak b/gmsv/battle/battle.c.bak new file mode 100644 index 0000000..f7e0f27 --- /dev/null +++ b/gmsv/battle/battle.c.bak @@ -0,0 +1,9437 @@ +#include "version.h" +#include +#include +#include +#include "buf.h" +#include"object.h" +#include"char.h" +#include"char_base.h" +#include"char_data.h" +#include"battle.h" +#include"battle_event.h" +#include"battle_command.h" +#include"battle_ai.h" +#include"configfile.h" +#include"lssproto_serv.h" +#include"encount.h" +#include"enemy.h" +#include"handletime.h" +#include"readmap.h" +#include"pet_skill.h" +#include "npcutil.h" +#include "magic.h" +#include "npc_npcenemy.h" +#include "log.h" +#include "pet_skillinfo.h" +#include "anim_tbl.h" +#include "common.h" +#include "battle_magic.h" +#ifdef _Item_ReLifeAct +#include "item.h" +#endif +#include "correct_bug.h" + +#ifdef _DEATH_CONTEND +#include "deathcontend.h" +#endif + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 +#include "profession_skill.h" +#include "skill.h" +#endif + +//#define DANTAI +static int Total_BattleNum=0; +BATTLE *BattleArray; +int BATTLE_battlenum; +static int BATTLE_searchCnt = 0; + +#ifdef _PET_LIMITLEVEL //ANDY_ADD + void Pet_Check_Die( int petindex); +#endif +static int BATTLE_SearchTask( void ); +static int BATTLE_Battling( int battleindex ); + +#ifdef _Item_ReLifeAct + BOOL CHECK_ITEM_RELIFE( int battleindex, int toindex); +#endif +#ifdef _LOSE_FINCH_ + BOOL CHECK_PET_RELIFE( int battleindex, int petindex); +#endif +char szAllBattleString[BATTLE_STRING_MAX]; +#ifdef _OTHER_MAGICSTAUTS +void BATTLE_MagicStatusSeq( int charaindex ); +#endif + +//Terry 2001/11/28 +char szBattleString[512]; +char *pszBattleTop, + *pszBattleLast; + +char szBadStatusString[1024]; + +int gWeponType; +float gDamageDiv; +int gItemCrushRate = 400000; + +int BoomerangVsTbl[4][5] = { + { 4+5*0,2+5*0,0+5*0,1+5*0,3+5*0 }, + { 4+5*1,2+5*1,0+5*1,1+5*1,3+5*1 }, + { 4+5*2,2+5*2,0+5*2,1+5*2,3+5*2 }, + { 4+5*3,2+5*3,0+5*3,1+5*3,3+5*3 }, + +}; + +void BATTLE_BadStatusAllClr( int charaindex ) +{ + int i ; + for( i = 1; i < BATTLE_ST_END; i ++ ){ + CHAR_setWorkInt( charaindex, StatusTbl[i], 0 ); + } +#ifdef _OTHER_MAGICSTAUTS + for( i = 1; i < MAXSTATUSTYPE; i++ ){ + CHAR_setWorkInt( charaindex, MagicTbl[i], 0); + CHAR_setWorkInt( charaindex, CHAR_OTHERSTATUSNUMS, 0); + } +#endif +#ifdef _IMPRECATE_ITEM + for( i=0; i<3; i++) { + CHAR_setWorkInt( charaindex, CHAR_WORKIMPRECATENUM1+i, 0 ); + } +#endif + +#ifdef _PETSKILL_SETDUCK + CHAR_setWorkInt( charaindex, CHAR_MYSKILLDUCK, 0); + CHAR_setWorkInt( charaindex, CHAR_MYSKILLDUCKPOWER, 0 ); +#ifdef _MAGICPET_SKILL + CHAR_setWorkInt( charaindex, CHAR_MYSKILLSTR, 0); + CHAR_setWorkInt( charaindex, CHAR_MYSKILLSTRPOWER, 0 ); + CHAR_setWorkInt( charaindex, CHAR_MYSKILLTGH, 0); + CHAR_setWorkInt( charaindex, CHAR_MYSKILLTGHPOWER, 0 ); + CHAR_setWorkInt( charaindex, CHAR_MYSKILLDEX, 0); + CHAR_setWorkInt( charaindex, CHAR_MYSKILLDEXPOWER, 0 ); + CHAR_setWorkInt( charaindex, CHAR_MAGICPETMP, 0 ); +#endif +#endif + + CHAR_setFlg( charaindex, CHAR_ISDIE, 0 ); + +#ifdef _BATTLE_PROPERTY + { + Char *ch; + ch = CHAR_getCharPointer( charaindex); + if( ch == NULL ) return; + strcpysafe( ch->charfunctable[CHAR_BATTLEPROPERTY].string, + sizeof( ch->charfunctable[CHAR_BATTLEPROPERTY]), "");//战斗 + CHAR_constructFunctable( charaindex); + } +#endif + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + CHAR_setWorkInt( charaindex, CHAR_MYSKILLHIT, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORK_P_DUCK, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORKMOD_P_DUCK, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORK_WEAPON, 0 ); // 武器专精 + + // 火冰电抗性 + for( i=0; i<3; i++) + CHAR_setWorkInt( charaindex, CHAR_WORK_F_RESIST+i, 0/*CHAR_getInt( charaindex, PROFESSION_FIRE_R+i )*/ ); + +#endif + +#ifdef _PETSKILL_BECOMEPIG + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ) + { + for( i =0; i < CHAR_MAXPETHAVE; i++){ + int pindex = CHAR_getCharPet( charaindex, i ); + if( !CHAR_CHECKINDEX( pindex ) ) + continue; + CHAR_setInt( pindex, CHAR_BECOMEPIG, -1 ); + } + } +#endif + +} + +int BATTLE_getTopBattle( int battleindex ) +{ + + BATTLE *pBattleTop; + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE ) return -1; + + pBattleTop = &BattleArray[battleindex]; + + while( pBattleTop != NULL ){ + pBattleTop = BattleArray[battleindex].pBefore; + } + + if( BATTLE_CHECKINDEX( pBattleTop->battleindex ) == FALSE ){ + return -1; + }else{ + return pBattleTop->battleindex; + } +} + +static int BATTLE_getBattleFieldNo( int floor, int x, int y ) +{ + int tile[2], map[3], iRet; + if( !MAP_getTileAndObjData( floor, x, y, &tile[0], &tile[1] ) ) + return FALSE; + map[0] = MAP_getImageInt( tile[0], MAP_BATTLEMAP ); + map[1] = MAP_getImageInt( tile[0], MAP_BATTLEMAP2 ); + map[2] = MAP_getImageInt( tile[0], MAP_BATTLEMAP3 ); + iRet = map[RAND( 0, 2 )]; + return iRet; +} + +void BATTLE_BadStatusString( int defNo, int status ) +{ + char szWork[256]; + if( status < 1 || status >= BATTLE_ST_END ){ + status = 0; + } + sprintf( szWork, "BM|%X|%X|", defNo, status ); + strncat( szBadStatusString, szWork, sizeof( szBadStatusString ) ); +} + + + +#ifdef __ATTACK_MAGIC + +static int CharTableIdx[20][2] = +{ + { 3 , 2 } , { 3 , 1 } , { 3 , 3 } , { 3 , 0 } , { 3 , 4 } , + { 2 , 2 } , { 2 , 1 } , { 2 , 3 } , { 2 , 0 } , { 2 , 4 } , + { 0 , 2 } , { 0 , 1 } , { 0 , 3 } , { 0 , 0 } , { 0 , 4 } , + { 1 , 2 } , { 1 , 1 } , { 1 , 3 } , { 1 , 0 } , { 1 , 4 } + +}; + +typedef int ( *FUNCSORTLOC )( const void* , const void* ); + +static int SortLoc( const int *pEle1 , const int *pEle2 ) +{ + int ele1basex , ele1basey; + int ele2basex , ele2basey; + + ele1basex = CharTableIdx[*pEle1][1]; + ele1basey = CharTableIdx[*pEle1][0]; + ele2basex = CharTableIdx[*pEle2][1]; + ele2basey = CharTableIdx[*pEle2][0]; + + if( *pEle1 >= 10 ){ + if( ele1basey != ele2basey ) + return ( ele1basey - ele2basey ); + return ( ele1basex - ele2basex ); + }else{ // 右下方 + if( ele1basey != ele2basey ) + return ( ele2basey - ele1basey ); + return ( ele2basex - ele1basey ); + } + return 0; +} +#endif + +int BATTLE_MultiList( int battleindex, int toNo, int ToList[] ) +{ + int j , i , cnt=0,nLife = 0,nLifeArea[10]; +#ifdef __ATTACK_MAGIC + // 单人攻击 + if(0 <= toNo && toNo <= 19){ + memset(nLifeArea,-1,sizeof(nLifeArea)); + // 如果被攻击者是右下方的人 + if(toNo >= 0 && toNo <= 9){ + for(i=0;i<10;i++){ + // 确定活着的人数,并记录活着的人的号码 + if(BATTLE_TargetCheck(battleindex,i) == TRUE) nLifeArea[nLife++] = i; + } + } + // 如果被攻击者是左上方的人 + if(toNo >= 10 && toNo <= 19){ + for(i=10;i<20;i++){ + // 确定活着的人数,并记录活着的人的号码 + if(BATTLE_TargetCheck(battleindex,i) == TRUE) nLifeArea[nLife++] = i; + } + } + + // 全死(虽然不太可能,但..) + if(nLife == 0){ + print("\nAll die!!"); + return -1; + }else{ + // 被攻击的对象已经死亡或不在战场上 + if(BATTLE_TargetCheck(battleindex,toNo) == FALSE) + // 随机找一只来打 + while((toNo = nLifeArea[rand()%10]) == -1); + } + ToList[0] = toNo; + ToList[1] = -1; + cnt = 1; + } + // 右下後一列攻击 + else if( TARGET_SIDE_0_B_ROW == toNo ){ + for( j = 0 , i = 0 ; i < SIDE_OFFSET / 2 ; i++ ){ + if( TRUE == BATTLE_TargetCheck( battleindex , i ) ){ + ToList[j] = i; + j++; + } + } + ToList[j] = -1; + cnt = j; + // 如果这一排都没有人可以打 + if(j == 0){ + // 换前一排 + for( j = 0 , i = SIDE_OFFSET / 2 ; i < SIDE_OFFSET ; i++ ){ + if( TRUE == BATTLE_TargetCheck( battleindex , i ) ){ + ToList[j] = i; + j++; + } + } + ToList[j] = -1; + cnt = j; + // 如果全死 + if(j == 0) return -1; + toNo = TARGET_SIDE_0_F_ROW; + } + } + // 右下前一列攻击 + else if( TARGET_SIDE_0_F_ROW == toNo ) + { + for( j = 0 , i = SIDE_OFFSET / 2 ; i < SIDE_OFFSET ; i++ ) + { + if( TRUE == BATTLE_TargetCheck( battleindex , i ) ) + { + ToList[j] = i; + j++; + } + } + ToList[j] = -1; + cnt = j; + // 如果这一排都没有人可以打 + if(j == 0) + { + // 换後一排 + for( j = 0 , i = 0 ; i < SIDE_OFFSET / 2 ; i++ ) + { + if( TRUE == BATTLE_TargetCheck( battleindex , i ) ) + { + ToList[j] = i; + j++; + } + } + ToList[j] = -1; + cnt = j; + // 如果全死 + if(j == 0) return -1; + toNo = TARGET_SIDE_0_B_ROW; + } + } + // 左下後一列攻击 + else if( TARGET_SIDE_1_B_ROW == toNo ) + { + for( j = 0 , i = SIDE_OFFSET ; i < SIDE_OFFSET + SIDE_OFFSET / 2 ; i++ ) + { + if( TRUE == BATTLE_TargetCheck( battleindex , i ) ) + { + ToList[j] = i; + j++; + } + } + ToList[j] = -1; + cnt = j; + // 如果这一排都没有人可以打 + if(j == 0) + { + // 换前一排 + for( j = 0 , i = SIDE_OFFSET + SIDE_OFFSET / 2 ; i < SIDE_OFFSET * 2 ; i++ ) + { + if( TRUE == BATTLE_TargetCheck( battleindex , i ) ) + { + ToList[j] = i; + j++; + } + } + ToList[j] = -1; + cnt = j; + // 如果全死 + if(j == 0) return -1; + toNo = TARGET_SIDE_1_F_ROW; + } + } + // 左上前一列攻击 + else if( TARGET_SIDE_1_F_ROW == toNo ) + { + for( j = 0 , i = SIDE_OFFSET + SIDE_OFFSET / 2 ; i < SIDE_OFFSET * 2 ; i++ ) + { + if( TRUE == BATTLE_TargetCheck( battleindex , i ) ) + { + ToList[j] = i; + j++; + } + } + ToList[j] = -1; + cnt = j; + // 如果这一排都没有人可以打 + if(j == 0) + { + // 换後一排 + for( j = 0 , i = SIDE_OFFSET ; i < SIDE_OFFSET + SIDE_OFFSET / 2 ; i++ ) + { + if( TRUE == BATTLE_TargetCheck( battleindex , i ) ) + { + ToList[j] = i; + j++; + } + } + ToList[j] = -1; + cnt = j; + // 如果全死 + if(j == 0) return -1; + toNo = TARGET_SIDE_1_B_ROW; + } + } + // 右下方所有攻击 + else if( TARGET_SIDE_0 == toNo ) + { + //print("BATTLE_MultiList(20)toNo->%d\n",toNo); + for( j = 0 , i = 0 ; i < SIDE_OFFSET ; i++ ) + { + if( TRUE == BATTLE_TargetCheck( battleindex , i ) ) + { + ToList[j] = i; + j++; + } + } + + ToList[j] = -1; + cnt = j; + } + // 左上方所有攻击 + else if( toNo == TARGET_SIDE_1 ) + { + for( j = 0 , i = SIDE_OFFSET ; i < SIDE_OFFSET * 2 ; i++ ) + { + if( TRUE == BATTLE_TargetCheck( battleindex , i ) ) + { + ToList[j] = i; + j++; + } + } + + ToList[j] = -1; + cnt = j; + } + // 所有人攻击 + else if( toNo == TARGET_ALL ){ +#ifdef _FIX_ARRAYBUG + for( j = 0 , i = 0 ; i < SIDE_OFFSET * 2 ; i++ ){ +#else + for( j = 0 , i = 0 ; i < SIDE_OFFSET * 2 ; i++ , j++ ) { +#endif + if( TRUE == BATTLE_TargetCheck( battleindex , i ) ){ + ToList[j] = i; + j++; + } + } + ToList[i] = -1; + cnt = j; + // won add 前後排攻击 + }else if( toNo == TARGER_THROUGH ){ + int toNo2=-1, count=0; + + if(BATTLE_TargetCheck(battleindex,toNo) != FALSE){ + ToList[count] = toNo; + count++; + cnt = count; + } + + if( toNo < (SIDE_OFFSET/2) ) toNo2= toNo + (SIDE_OFFSET/2); + else if( toNo < (SIDE_OFFSET) ) toNo2= toNo - (SIDE_OFFSET/2); + else if( toNo < (SIDE_OFFSET*1.5) ) toNo2= toNo + (SIDE_OFFSET/2); + else if( toNo < (SIDE_OFFSET*2) ) toNo2= toNo - (SIDE_OFFSET/2); + + if(BATTLE_TargetCheck(battleindex,toNo2) != FALSE){ + ToList[count] = toNo2; + count++; + cnt = count; + } + }else{ + ToList[0] = toNo; + ToList[1] = -1; + cnt = 1; + } + + if( cnt > 1 ) qsort( ToList , cnt , sizeof( ToList[0] ) , ( FUNCSORTLOC )SortLoc ); + return toNo; + +#else + if( 0 <= toNo && toNo <= 19 ) + { + if( BATTLE_TargetCheck( battleindex, toNo ) == TRUE ) + { + ToList[0] = toNo; + ToList[1] = -1; + cnt = 1; + } + else + { + ToList[0] = -1; + ToList[1] = -1; + cnt = 0; + } + } + else if( toNo == TARGET_SIDE_0 ) + { + for( j = 0, i = 0; i < SIDE_OFFSET; i ++) + { + if( BATTLE_TargetCheck( battleindex, i ) == TRUE ) + { + ToList[j] = i; + j ++ ; + } + } + ToList[j] = -1; + cnt = j; + } + else if( toNo == TARGET_SIDE_1 ) + { + for( j = 0, i = SIDE_OFFSET; i < SIDE_OFFSET*2; i ++ ) + { + if( BATTLE_TargetCheck( battleindex, i ) == TRUE ) + { + ToList[j] = i; + j ++ ; + } + } + ToList[j] = -1; + cnt = j; + } + else if( toNo == TARGET_ALL ){ + for( j = 0, i = 0; i < SIDE_OFFSET*2; i ++, j ++ ){ + if( BATTLE_TargetCheck( battleindex, i ) == TRUE ){ + ToList[j] = i; + j ++ ; + } + } + ToList[i] = -1; + cnt = j; + } + else + { + ToList[0] = toNo; + ToList[1] = -1; + cnt = 1; + } + + return 1; +#endif +} + +void BATTLE_MultiListDead( int battleindex, int toNo, int ToList[] ) +{ + int j, i; + if( 0 <= toNo && toNo <= 19 ){ + if( BATTLE_TargetCheckDead( battleindex, toNo ) == TRUE ){ + ToList[0] = toNo; + ToList[1] = -1; + }else{ + ToList[0] = -1; + ToList[1] = -1; + } + }else + if( toNo == TARGET_SIDE_0 ){ + for( j = 0, i = 0; i < SIDE_OFFSET; i ++){ + if( BATTLE_TargetCheckDead( battleindex, i ) == TRUE ){ + ToList[j] = i; + j ++ ; + } + } + ToList[j] = -1; + }else + if( toNo == TARGET_SIDE_1 ){ + for( j = 0, i = SIDE_OFFSET; i < SIDE_OFFSET*2; i ++ ){ + if( BATTLE_TargetCheckDead( battleindex, i ) == TRUE ){ + ToList[j] = i; + j ++ ; + } + } + ToList[j] = -1; + }else{ + if( toNo == TARGET_ALL ){ +#ifdef _FIX_ARRAYBUG + for( j = 0, i = 0; i < SIDE_OFFSET*2; i ++){ +#else + for( j = 0, i = 0; i < SIDE_OFFSET*2; i ++, j ++ ){ +#endif + if( BATTLE_TargetCheckDead( battleindex, i ) == TRUE ){ + ToList[j] = i; + j ++ ; + } + } +#ifdef _FIX_ITEMRELIFE // WON ADD 修正替身娃娃问题 + ToList[j] = -1; +#else + ToList[i] = -1; +#endif + }else{ + ToList[0] = toNo; + ToList[1] = -1; + } + } +} + +BOOL BATTLE_IsThrowWepon( int itemindex){ + int itemtype; + if( ITEM_CHECKINDEX( itemindex ) == FALSE ){ + return FALSE; + } + itemtype = ITEM_getInt( itemindex, ITEM_TYPE ); + if( itemtype == ITEM_BOOMERANG + || itemtype == ITEM_BOW + || itemtype == ITEM_BREAKTHROW + || itemtype == ITEM_BOUNDTHROW ){ + return TRUE; + }else{ + return FALSE; + } +} + +int BATTLE_ClearGetExp( int charaindex ) +{ + int i, pindex; + + if( CHAR_CHECKINDEX( charaindex ) == FALSE ){ + return BATTLE_ERR_CHARAINDEX; + } + CHAR_setWorkInt( charaindex, CHAR_WORKGETEXP, 0 ); + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + pindex = CHAR_getCharPet( charaindex, i ); + if( CHAR_CHECKINDEX( pindex ) == FALSE )continue; + CHAR_setWorkInt( pindex, CHAR_WORKGETEXP, 0 ); + } + + return 0; +} + +INLINE void _BATTLE_ExitAll( char *file, int line, int battleindex) +{ + int j,i, charaindex; + for( j = 0; j < 2; j ++ ){ + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = BattleArray[battleindex].Side[j].Entry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + BATTLE_Exit( charaindex, battleindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, + BATTLE_CHARMODE_NONE ); + } + } +} + +void BATTLE_AllCharaFinishSet( int battleindex ) +{ + int j,i, charaindex; + for( j = 0; j < 2; j ++ ){ + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = BattleArray[battleindex].Side[j].Entry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, + BATTLE_CHARMODE_FINAL ); + } + } +} + +BOOL BATTLE_IsCharge( int charaindex ) +{ + int com; + com = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ); + if( com == BATTLE_COM_S_CHARGE + || com == BATTLE_COM_S_EARTHROUND1 + || com == BATTLE_COM_S_EARTHROUND0 +#ifdef _PROFESSION_ADDSKILL + || CHAR_getWorkInt( charaindex, CHAR_DOOMTIME ) > 0 +#endif + ){ + return TRUE; + } + return FALSE; +} + +void BATTLE_AllCharaCWaitSet( int battleindex ) +{ + int j,i, charaindex; + for( j = 0; j < 2; j ++ ){ + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = BattleArray[battleindex].Side[j].Entry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + + if( BATTLE_IsCharge( charaindex ) == TRUE ){ + }else{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, + BATTLE_COM_NONE ); + } + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, + BATTLE_CHARMODE_C_WAIT ); + } + } +} + +void BATTLE_AllCharaWatchWaitSet( int battleindex ) +{ + int i, charaindex; + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = BattleArray[battleindex].Side[0].Entry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) + != BATTLE_CHARMODE_WATCHINIT + ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, + BATTLE_CHARMODE_C_WAIT ); + } + } +} + +void BATTLE_SurpriseSet( + int battleindex, + int side +) +{ + BATTLE_ENTRY *pEntry; + int i, charaindex; + + pEntry = BattleArray[battleindex].Side[side].Entry; + + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pEntry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + } + } + + +} + +BOOL BATTLE_initBattleArray( + int battlenum +) +{ + + int i; + BATTLE_battlenum = battlenum; + + BattleArray = allocateMemory( sizeof( BATTLE ) * BATTLE_battlenum ); + if( BattleArray == NULL ) return FALSE; + for( i = 0 ; i < BATTLE_battlenum ; i ++ ){ + memset( &BattleArray[i], 0 , sizeof( BATTLE )); + } + return TRUE; + +} + +static void EntryInit( BATTLE_ENTRY *pEntry ){ + int i; + pEntry->charaindex = -1; + pEntry->bid = -1; + pEntry->escape = 0; + for( i = 0; i < GETITEM_MAX; i ++ ){ + pEntry->getitem[i] = -1; + } +} + +int BATTLE_CreateBattle( void ) +{ + int battleindex, i, j; + BATTLE *pBattle; + battleindex = BATTLE_SearchTask( ); + // NUKE 0701 + if( battleindex < 0 )return -1; + pBattle = &BattleArray[battleindex]; + // NUKE 0701 + if (pBattle==NULL) return -1; + pBattle->use = TRUE; + pBattle->mode = BATTLE_MODE_INIT; + pBattle->turn = 0; + pBattle->dpbattle = 0; + pBattle->norisk = 0; + pBattle->flg = 0; + pBattle->field_att = BATTLE_ATTR_NONE; + pBattle->att_count = 0; + for( j = 0; j < 2; j ++ ){ + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + EntryInit( &pBattle->Side[j].Entry[i] ); + } + } + for( i = 0; i < BATTLE_ENTRY_MAX*2; i ++ ){ + pBattle->iEntryBack[i] = -1; + pBattle->iEntryBack2[i] = -1; + } + pBattle->WinFunc = NULL; +#ifdef _DEATH_CONTEND//计算胜败func + pBattle->PkFunc = NULL; + pBattle->battlemap = -1; +#endif + pBattle->pNext = NULL; + pBattle->pBefore = NULL; + pBattle->battleindex = battleindex; + Total_BattleNum ++; +#ifdef _BATTLECOMMAND_TIME + pBattle->PartTime = 0; +#endif +#ifdef _PROFESSION_ADDSKILL + //冰爆术存放 +/* pBattle->ice_count = 0; + for( i = 0; i < 20; i ++ ){ + pBattle->ice_bout[i]=0; + pBattle->ice_use[i]=FALSE; + pBattle->ice_toNo[i]=0; + pBattle->ice_level[i]=0; + pBattle->ice_array[i]=0; + pBattle->ice_attackNo[i]=0; + pBattle->ice_charaindex[i]=-1; + }*/ +#endif + return battleindex; +} + +static int BATTLE_SearchTask( void ) +{ + int i, j; + i = BATTLE_searchCnt; + for( j = 0; j < BATTLE_battlenum; j ++ ){ + if( i >= BATTLE_battlenum ) i = 0; + if( BattleArray[i].use == FALSE ){ + BATTLE_searchCnt = i + 1; + return i; + } + i ++; + } + return -1; +} + +void BATTLE_DeleteItem( int battleindex ) +{ + int i, j, k; + BATTLE_ENTRY *pEntry; + + for( j = 0; j < 2; j ++ ){ + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + pEntry = &BattleArray[battleindex].Side[j].Entry[i]; + for( k = 0; k < GETITEM_MAX; k ++ ){ + if( pEntry->getitem[k] >= 0 ){ + print( "// 找寻(消去)道具(%d),(%s)\n", + pEntry->getitem[k], + ITEM_getAppropriateName(pEntry->getitem[k]) ); + ITEM_endExistItemsOne( pEntry->getitem[k] ); + } + } + } + } +} + + +int BATTLE_DeleteBattle( + int battleindex +) +{ + int i, j; + BATTLE *pBattle; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE ){ + fprint( "err:battle index error\n" ); + return BATTLE_ERR_BATTLEINDEX; + } + if( BATTLE_WatchUnLink( battleindex ) == FALSE ){ + fprint( "err:battle link 不脱离\n" ); + } + + pBattle = &BattleArray[battleindex]; + pBattle->use = FALSE; + pBattle->mode = BATTLE_MODE_NONE; + BATTLE_DeleteItem( battleindex ); + for( j = 0; j < 2; j ++ ){ + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + EntryInit( &pBattle->Side[j].Entry[i] ); + } + } + Total_BattleNum--; + return 0; +} + + +int BATTLE_No2Index( + int battleindex, + int bid +) +{ + BATTLE_ENTRY *pEntry; + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return -1; + if( BATTLE_CHECKNO( bid ) == FALSE )return -1; + + if( bid >= 10 ){ + pEntry = BattleArray[battleindex].Side[1].Entry; + bid -= SIDE_OFFSET; + }else{ + pEntry = BattleArray[battleindex].Side[0].Entry; + } + if( CHAR_CHECKINDEX( pEntry[bid].charaindex ) == FALSE )return -1; + + return pEntry[bid].charaindex; + +} +#ifdef _Item_ReLifeAct +int BATTLE_getBattleDieIndex( int battleindex, int bid ) +{ + BATTLE_ENTRY *pEntry; + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return -1; + if( BATTLE_CHECKNO( bid ) == FALSE )return -1; + + if( bid >= 10 ){ + pEntry = BattleArray[battleindex].Side[1].Entry; + bid -= SIDE_OFFSET; + }else{ + pEntry = BattleArray[battleindex].Side[0].Entry; + } + if( CHAR_CHECKINDEX( pEntry[bid].charaindex ) == FALSE )return -1; + if( pEntry[bid].flg & BENT_FLG_ULTIMATE ) return -1; + + return pEntry[bid].charaindex; + +} +#endif + +#ifdef _PROFESSION_ADDSKILL +BOOL BATTLE_BattleUltimate( int battleindex, int bid ) //检查此位 上是否被打飞 +{ + BATTLE_ENTRY *pEntry; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return FALSE; + if( BATTLE_CHECKNO( bid ) == FALSE )return FALSE; + if( bid >= 10 ){ + pEntry = BattleArray[battleindex].Side[1].Entry; + bid -= SIDE_OFFSET; + }else{ + pEntry = BattleArray[battleindex].Side[0].Entry; + } + if( pEntry[bid].flg & BENT_FLG_ULTIMATE ) return TRUE; + else return TRUE; +} +#endif + +int BATTLE_Index2No( + int battleindex, + int charaindex +) +{ + BATTLE_ENTRY *pEntry; + int i, j; + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return -1; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return -1; + + for( j = 0; j < 2; j ++ ){ + pEntry = BattleArray[battleindex].Side[j].Entry; + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + if( pEntry[i].charaindex == charaindex ){ + return i + j * SIDE_OFFSET; + } + } + } + + return -1; + +} + + +char *BATTLE_CharTitle( int charaindex ) +{ + char *pName; + static char Len0Buff[2] = ""; + + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + pName = Len0Buff; + }else{ + pName = CHAR_getChar( charaindex, CHAR_OWNTITLE ); + if( pName[0] == 0 ){ + pName = Len0Buff; + } + } + return pName; +} + + +int BATTLE_CharaBackUp( int battleindex ) +{ + int i, j, k, charaindex; + BATTLE *pBattle; + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE ){ + return BATTLE_ERR_BATTLEINDEX; + } + + pBattle = &BattleArray[battleindex]; + k = 0; + + for( j = 0; j < 2; j ++ ){ + k = j * SIDE_OFFSET; + for( i = 0; i < BATTLE_ENTRY_MAX/2; i ++ ){ + charaindex = pBattle->Side[j].Entry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == TRUE + && CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER + ){ + pBattle->iEntryBack[k] = pBattle->Side[j].Entry[i].charaindex; + pBattle->iEntryBack2[k] = pBattle->Side[j].Entry[i].charaindex; + }else{ + pBattle->iEntryBack[k] = -1; + pBattle->iEntryBack2[k] = -1; + } + k ++; + } + } + + return 0; +} + + + + +int BATTLE_NewEntry( + int charaindex, + int battleindex, + int side +) +{ + BATTLE_ENTRY *pEntry; + BATTLE *pBattle; + int i, iEntryMax, iEntryFirst; + + if( BATTLE_CHECKSIDE( side ) == FALSE )return BATTLE_ERR_PARAM; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return BATTLE_ERR_CHARAINDEX; + + pBattle = &BattleArray[battleindex]; + + if( pBattle->use == FALSE )return BATTLE_ERR_NOUSE; + + if( side < 0 || side > 1 ){ + return BATTLE_ERR_PARAM; + } + + switch( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) ){ + int work; + + case CHAR_TYPEPLAYER: + if( pBattle->Side[side].type != BATTLE_S_TYPE_PLAYER ){ + return BATTLE_ERR_TYPE; + } + iEntryFirst = 0; + iEntryMax = BATTLE_PLAYER_MAX; + break; + case CHAR_TYPEENEMY: + if( pBattle->Side[side].type != BATTLE_S_TYPE_ENEMY ){ + return BATTLE_ERR_TYPE; + } + iEntryFirst = 0; + iEntryMax = BATTLE_ENTRY_MAX; + break; + case CHAR_TYPEPET: + if( pBattle->Side[side].type != BATTLE_S_TYPE_PLAYER ){ + return BATTLE_ERR_TYPE; + } + + work = CHAR_getWorkInt( charaindex, CHAR_WORKPLAYERINDEX ); + pEntry = pBattle->Side[side].Entry; + + work = BATTLE_Index2No( battleindex, work ); + work -= side * SIDE_OFFSET; + work += 5; + iEntryFirst = work; + iEntryMax = work+1; + break; + default: + print( "不明(%s)(%d)\n", + CHAR_getUseName( charaindex ), + CHAR_getInt( charaindex, CHAR_WHICHTYPE ) ); + return BATTLE_ERR_TYPE; + } + + + pEntry = pBattle->Side[side].Entry; + + for( i = iEntryFirst; i < iEntryMax; i ++ ){ + if( pEntry[i].charaindex == -1 )break; + } + + if( i == iEntryMax ){ + return BATTLE_ERR_ENTRYMAX; + } + + EntryInit( &pEntry[i] ); + + pEntry[i].charaindex = charaindex; + + pEntry[i].bid = i + side * SIDE_OFFSET; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEINDEX, + battleindex ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, + BATTLE_CHARMODE_INIT ); + // shan 2001/12/27 Begin + { + int fd; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE)==CHAR_TYPEPLAYER ){ + fd = CHAR_getWorkInt( charaindex, CHAR_WORKFD); + CONNECT_SetBattleRecvTime( fd, &NowTime); + } + } + // End + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLESIDE, side ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEFLG, 0 ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, -1 ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, -1 ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM3, -1 ); + + CHAR_setWorkInt( charaindex, CHAR_WORKMODATTACK, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORKMODDEFENCE, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORKMODQUICK, 0 ); + + CHAR_setWorkInt( charaindex, CHAR_WORKDAMAGEABSROB, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORKDAMAGEREFLEC, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORKDAMAGEVANISH, 0 ); + + + CHAR_setWorkInt( charaindex, CHAR_WORKMODCAPTURE, 0 ); + + CHAR_setFlg( charaindex, CHAR_ISATTACKED, 1 ); + + BATTLE_BadStatusAllClr( charaindex ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEWATCH, 0 ); + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + CHAR_setWorkInt( charaindex, CHAR_WORKTRAP, 0 ); //陷阱 + BATTLE_ProfessionStatus_init( battleindex, charaindex ); +#endif + +#ifdef _PETSKILL_ACUPUNCTURE + CHAR_setWorkInt( charaindex, CHAR_WORKACUPUNCTURE, 0 );//针刺外皮 +#endif + +#ifdef _PETSKILL_RETRACE + CHAR_setWorkInt( charaindex, CHAR_WORKRETRACE, 0 );//追迹攻击 +#endif + +#ifdef _PETSKILL_BECOMEFOX //将媚惑术中招时间清除为-1 + CHAR_setWorkInt( charaindex, CHAR_WORKFOXROUND, -1 ); +#endif +#ifdef _PROFESSION_ADDSKILL + //结界清除 + CHAR_setWorkInt( charaindex, CHAR_WORKFIXEARTHAT_BOUNDARY, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORKFIXWATERAT_BOUNDARY, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORKFIXFIREAT_BOUNDARY, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORKFIXWINDAT_BOUNDARY, 0 ); + CHAR_setWorkInt( charaindex, CHAR_DOOMTIME, 0 );//世界末日集气 + CHAR_setWorkInt( charaindex, CHAR_WORK_com1, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORK_toNo, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORK_mode, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORK_skill_level, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORK_array, 0 ); +#endif + return 0; +} + +INLINE int _BATTLE_Exit( char *file, int line, int charaindex ,int battleindex) +{ + BATTLE_ENTRY *pEntry; + int i, j, k; + BATTLE *pBattle; + char szPet[32]; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return BATTLE_ERR_CHARAINDEX; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE ){ + return BATTLE_ERR_BATTLEINDEX; + } +#ifdef _PROFESSION_ADDSKILL + CHAR_setWorkInt( charaindex, CHAR_DOOMTIME, 0 );//世界末日集气 +#endif +#ifdef _PETSKILL_BECOMEFOX // 离开战斗时将媚惑术造成的变身效果清除 + //print("\n检查图号:%s,%d", CHAR_getChar( charaindex, CHAR_NAME), CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER)); + + if( CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER)==101749 + || CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND ) != -1 ){ //变成小狐狸 + CHAR_setInt( charaindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( charaindex, CHAR_BASEBASEIMAGENUMBER) ); + CHAR_setWorkInt( charaindex, CHAR_WORKFOXROUND, -1); + //print("\n变回去:%d",CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER)); + } +#endif + +#ifdef _PETSKILL_BECOMEPIG + if( CHAR_getInt( charaindex, CHAR_BECOMEPIG) > -1 + && CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + CHAR_setInt( charaindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( charaindex, CHAR_BECOMEPIG_BBI ) ); + CHAR_complianceParameter( charaindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + } +#endif + + +#ifdef _MAGIC_NOCAST // 精灵:沉默 + // WON ADD + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ) + lssproto_NC_send( getfdFromCharaIndex( charaindex ), 0);//复原 +#endif + pBattle = &BattleArray[battleindex]; + if( pBattle->use == FALSE ) + return BATTLE_ERR_NOUSE; + + for( j = 0; j < 2; j ++ ){ + pEntry = pBattle->Side[j].Entry; + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + if( pEntry[i].charaindex != charaindex ) + continue; + pEntry[i].charaindex = -1; + pEntry[i].escape = 0; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_FINAL ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEINDEX, -1 ); +#ifdef _LOSE_FINCH_ + CHAR_setWorkInt( charaindex, CHAR_WORKSPETRELIFE, 0); +#endif + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ){ + CHAR_endCharOneArray( charaindex ); + }else if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + int petindex = pEntry[i+5].charaindex; + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == TRUE + || CHAR_getInt( charaindex, CHAR_HP ) == TRUE ) + { + +#ifdef _ACTION_BULLSCR +#ifndef _BULL_CUTBULLSCR + { + if( CHAR_getInt( charaindex, CHAR_ABULLSTART) == 10 ){ + char buf[256]; + sprintf( buf, "因战斗中倒地,活动积分不予计算。"); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + } + } +#endif +#endif + +#ifdef _FIX_SPEED_UPLEVEL // WON ADD 修正加速 + // Robin cancel + //if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == TRUE ){ + //}else + { + // Robin cancel + //if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1) != BATTLE_COM_ESCAPE ) + { + unsigned int Dtimes; + unsigned int battletime; + int fd = getfdFromCharaIndex( charaindex ); + Dtimes = BattleArray[battleindex].CreateTime; + battletime = (unsigned int)(BattleArray[battleindex].flgTime/100); + + //if( CHAR_getWorkInt( charaindex, CHAR_WORKFLG) & WORKFLG_DEBUGMODE ){ + //}else + { + CheckDefBTime( charaindex, fd, Dtimes, battletime, 10);//lowTime延迟时间 + } + } + } +#endif + CHAR_setFlg( charaindex, CHAR_ISDIE, 0 ); + CHAR_setInt( charaindex, CHAR_HP, 1 ); + // CoolFish: Faily PK 2001/8/3 + CHAR_setWorkInt(charaindex, CHAR_WORKFMPKFLAG, -1); + + }else { +#ifdef _BATTLE_TIMESPEED + // Robin cancel + //if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1) != BATTLE_COM_ESCAPE ) + { + unsigned int Dtimes; + unsigned int battletime; + + int fd = getfdFromCharaIndex( charaindex ); + Dtimes = BattleArray[battleindex].CreateTime; + battletime = (unsigned int)(BattleArray[battleindex].flgTime/100); + //if( CHAR_getWorkInt( charaindex, CHAR_WORKFLG) & WORKFLG_DEBUGMODE ) { + //}else + { + CheckDefBTime( charaindex, fd, Dtimes, battletime, 0);//lowTime延迟时间 + } + } +#endif +#ifdef _ACTION_BULLSCR +#ifndef _BULL_CUTBULLSCR + + if( CHAR_getInt( charaindex, CHAR_ABULLSTART) == 10 && + BattleArray[battleindex].CreateTime > 0 ) { + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1) != BATTLE_COM_ESCAPE && + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEWATCH ) != 1 ) { + char buf[256]; + unsigned int Dtimes; + int ntime, deftime=0,Scount=0; + int nowtime = (unsigned int)time(NULL);//CHAR_BULLSHOWCOUNT + Scount = CHAR_getWorkInt( charaindex, CHAR_BULLSHOWCOUNT); + if( Scount < 0 ) Scount = 0; + ntime = CHAR_getInt( charaindex, CHAR_ABULLTIME); + Dtimes = BattleArray[battleindex].CreateTime; + deftime = (nowtime - (int)Dtimes)-5; + if( ntime < 0 ) ntime = 0; + if( deftime > (60*60) ) deftime = (60*60); + if( deftime < 0 ) deftime = 0; + + if( CHAR_getWorkInt( charaindex, CHAR_WORKGETEXP) > + (BattleArray[battleindex].enemynum * 2) || + BattleArray[battleindex].type == BATTLE_TYPE_P_vs_P){ + ntime = (ntime + deftime); + Scount += deftime; + if( Scount >= (5*60) ){ + Scount = 0; + sprintf( buf, "战斗时间已累积%d分%d秒。", ntime/60, ntime%60); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + } + CHAR_setWorkInt( charaindex, CHAR_BULLSHOWCOUNT, Scount); + CHAR_setInt( charaindex, CHAR_ABULLTIME, ntime); + if( ntime >= (60*60) ){//活动一小时 + //if( ntime > 10 ){//测试加快 //CHAR_setWorkInt( charaindex, CHAR_WORKGETEXP, 0 ); + int nScore = CHAR_getInt( charaindex, CHAR_ABULLSCORE); + ntime = ntime - (60*60); + ntime = ( ntime<0)?0:ntime; + CHAR_setInt( charaindex, CHAR_ABULLTIME, ntime); + CHAR_setInt( charaindex, CHAR_ABULLSCORE, nScore+10 ); + sprintf( buf, "战斗满1小时时间取得10分,总共取得%d绩分。", nScore+10); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + } + }else{ + sprintf( buf, "因此场战斗取得经验值不足,活动积分不予计算。"); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + } + }else{ + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1) == BATTLE_COM_ESCAPE){ + char buf[256]; + sprintf( buf, "因战斗逃跑,活动积分不予计算。"); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + } + } + } + //BattleArray[battleindex].CreateTime = 0; +#endif +#endif + } + if( CHAR_CHECKINDEX( petindex ) == TRUE ){ + pEntry[i+5].charaindex = -1; + CHAR_setWorkInt( petindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_NONE ); + CHAR_setWorkInt( petindex, CHAR_WORKBATTLEINDEX, -1 ); + } + BATTLE_BadStatusAllClr( charaindex ); + CHAR_complianceParameter( charaindex ); + CHAR_Skillupsend( charaindex ); + // Robin 0730 + if( CHAR_getWorkInt( charaindex, CHAR_WORKPETFALL) ) + { + CHAR_setWorkInt( charaindex, CHAR_WORKPETFALL, 0 ); + CHAR_setInt( charaindex, CHAR_RIDEPET, -2 ); + } + CHAR_send_P_StatusString( charaindex , + CHAR_P_STRING_HP|CHAR_P_STRING_EXP| + CHAR_P_STRING_MP|CHAR_P_STRING_DUELPOINT| + CHAR_P_STRING_CHARM | + CHAR_P_STRING_EARTH | + CHAR_P_STRING_WATER | + CHAR_P_STRING_FIRE | + CHAR_P_STRING_WIND | + CHAR_P_STRING_RIDEPET + ); + // Robin 0730 + if( CHAR_getInt( charaindex, CHAR_RIDEPET ) == -2 ){ + CHAR_setInt( charaindex, CHAR_RIDEPET, -1 ); + } + for( k = 0; k < CHAR_MAXPETHAVE; k ++ ){ + petindex = CHAR_getCharPet( charaindex, k ); + if( CHAR_CHECKINDEX( petindex ) == FALSE )continue; + if( CHAR_getInt( petindex, CHAR_MAILMODE) != CHAR_PETMAIL_NONE ) continue; + if( CHAR_getFlg( petindex, CHAR_ISDIE ) == TRUE + || CHAR_getInt( petindex, CHAR_HP ) <= 0 ){ + CHAR_setFlg( petindex, CHAR_ISDIE, 0 ); + CHAR_setInt( petindex, CHAR_HP, 1 ); + } + CHAR_setWorkInt( petindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_NONE ); +#ifdef _LOSE_FINCH_ + CHAR_setWorkInt( charaindex, CHAR_WORKSPETRELIFE, 0); +#endif +#ifdef _VARY_WOLF + if( CHAR_getInt( petindex, CHAR_BASEBASEIMAGENUMBER) != CHAR_getInt( petindex, CHAR_BASEIMAGENUMBER) ) // Robin fix + { + CHAR_setInt( petindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( petindex, CHAR_BASEBASEIMAGENUMBER)); + sprintf( szPet, "K%d", k); + CHAR_sendStatusString( charaindex , szPet); + } +#endif +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + // 遗忘 + if( CHAR_getWorkInt( petindex, CHAR_WORKOBLIVION ) > 0 ) // Robin fix + { + int pet_no = CHAR_getInt( charaindex, CHAR_DEFAULTPET ); + CHAR_setWorkInt( petindex, CHAR_WORKOBLIVION, 0 ); + // 宠物编号 + sprintf( szPet, "W%d", pet_no); + CHAR_sendStatusString( charaindex , szPet); + } +#endif + BATTLE_BadStatusAllClr( petindex ); + CHAR_complianceParameter( petindex ); + CHAR_send_K_StatusString( charaindex , k, + CHAR_K_STRING_HP|CHAR_K_STRING_EXP| + CHAR_K_STRING_AI| CHAR_K_STRING_MP | + CHAR_K_STRING_ATK | CHAR_K_STRING_DEF | + CHAR_K_STRING_QUICK | + CHAR_K_STRING_EARTH | + CHAR_K_STRING_WATER | + CHAR_K_STRING_FIRE | + CHAR_K_STRING_WIND + ); + } + if( BattleArray[battleindex].type == BATTLE_TYPE_P_vs_P ){ + int flg = 0; + CHAR_setFlg( charaindex, CHAR_ISDUEL, 0); + if( CHAR_getFlg( charaindex, CHAR_ISPARTY)) flg |= CHAR_FS_PARTY; + if( CHAR_getFlg( charaindex, CHAR_ISDUEL)) flg |= CHAR_FS_DUEL; + if( CHAR_getFlg( charaindex, CHAR_ISPARTYCHAT)) flg |= CHAR_FS_PARTYCHAT; + if( CHAR_getFlg( charaindex, CHAR_ISTRADECARD)) flg |= CHAR_FS_TRADECARD; +#ifdef _CHANNEL_MODIFY + if( CHAR_getFlg( charaindex, CHAR_ISTELL)) flg |= CHAR_FS_TELL; + if( CHAR_getFlg( charaindex, CHAR_ISFM)) flg |= CHAR_FS_FM; + if( CHAR_getFlg( charaindex, CHAR_ISOCC)) flg |= CHAR_FS_OCC; + if( CHAR_getFlg( charaindex, CHAR_ISCHAT)) flg |= CHAR_FS_CHAT; + if( CHAR_getFlg( charaindex, CHAR_ISSAVE)) flg |= CHAR_FS_SAVE; +#endif + lssproto_FS_send( getfdFromCharaIndex(charaindex), flg); + } + + lssproto_XYD_send( getfdFromCharaIndex(charaindex), + CHAR_getInt( charaindex, CHAR_X ), + CHAR_getInt( charaindex, CHAR_Y ), + CHAR_getInt( charaindex, CHAR_DIR ) ); + } + break; + } + } + CHAR_PartyUpdate( charaindex, CHAR_N_STRING_HP ); + +#ifdef _TIME_TICKET + { + int nowtime = time(NULL); + int tickettime = CHAR_getWorkInt( charaindex, CHAR_WORKTICKETTIME); + int totaltime; + char msg[1024]; + if( tickettime > 0 && tickettime < nowtime ) { + //int floor, x, y; + CHAR_talkToCli( charaindex, -1, "谢谢光顾。", CHAR_COLORYELLOW); + if( CHAR_getWorkInt( charaindex, CHAR_WORKTICKETTIMESTART) > 0 ) { + totaltime = nowtime - CHAR_getWorkInt( charaindex, CHAR_WORKTICKETTIMESTART); + sprintf( msg, "总入场时间%d分%d秒。", totaltime/60, totaltime%60); + CHAR_talkToCli( charaindex, -1, msg, CHAR_COLORYELLOW); + } + CHAR_setWorkInt( charaindex, CHAR_WORKTICKETTIME, 0); + CHAR_setWorkInt( charaindex, CHAR_WORKTICKETTIMESTART, 0); + /*if( CHAR_getElderPosition( CHAR_getInt( charaindex, CHAR_LASTTALKELDER), &floor, &x, &y ) != TRUE ) { + CHAR_warpToSpecificPoint( charaindex, 1006, 15, 15); + } + else { + CHAR_warpToSpecificPoint( charaindex, floor, x, y); + }*/ + CHAR_warpToSpecificPoint( charaindex, 7001, 41, 6); + } + } +#endif + + return BATTLE_ERR_NONE; +} + + +int BATTLE_PetDefaultExit( + int charaindex, + int battleindex +) +{ + int pno, pindex, iRet; + + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return BATTLE_ERR_CHARAINDEX; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER) return 0; + pno = CHAR_getInt( charaindex, CHAR_DEFAULTPET ); + if( pno < 0 )return 0; + pindex = CHAR_getCharPet( charaindex, pno ); + + iRet = BATTLE_Exit( pindex, battleindex ); + + if( iRet ){ + iRet *= -1; + }else{ + return 1; + } + + return iRet; +} + + +int BATTLE_PetDefaultEntry( + int charaindex, + int battleindex, + int side +) +{ + int pindex; + +#if 1 + int pno; + + int ret = 0; + + pno = CHAR_getInt( charaindex, CHAR_DEFAULTPET ); + if( pno == -1 ) return 0; + pindex = CHAR_getCharPet( charaindex, pno ); + + if( CHAR_CHECKINDEX( pindex ) && + + !CHAR_getFlg( pindex, CHAR_ISDIE ) && + CHAR_getInt( pindex, CHAR_HP ) > 0 ) + { + if( BATTLE_NewEntry( pindex, battleindex, side ) ){ + }else{ + ret = 0; + } + } + else { + CHAR_setInt( charaindex, CHAR_DEFAULTPET, -1 ); + } + + return ret; +#else + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + pindex = CHAR_getCharPet( charaindex, i ); + + if( CHAR_CHECKINDEX( pindex ) == FALSE )continue; + + if( CHAR_getFlg( pindex, CHAR_ISDIE ) == TRUE )continue; + if( CHAR_getInt( pindex, CHAR_HP ) <= 0 )continue; + + if( BATTLE_NewEntry( pindex, battleindex, side ) ){ + }else{ + CHAR_setInt( charaindex, CHAR_DEFAULTPET, i ); + break; + } + } + + if( i == CHAR_MAXPETHAVE ){ + CHAR_setInt( charaindex, CHAR_DEFAULTPET, -1 ); + } + return 0; +#endif +} + +int BATTLE_RescueEntry( int charaindex, int toindex ) +{ + int iRet = 0, battleindex, fd, pindex; + char szBuffer[256]=""; + +#ifdef _BATTLE_TIMESPEED + fd = getfdFromCharaIndex( charaindex); + if( CONNECT_getBDTime( fd) > time( NULL) ) { + return 1; + } +#endif + + battleindex = CHAR_getWorkInt( toindex, CHAR_WORKBATTLEINDEX ); + if( !BATTLE_CHECKINDEX( battleindex) ) return 1; + if( ( fd = getfdFromCharaIndex(charaindex) ) < 0 ) return 1; + + if( CHAR_getWorkInt( toindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_FINAL + || CHAR_getWorkInt( toindex, CHAR_WORKBATTLEINDEX ) == -1 ){ + iRet = 1; + } + + if( BattleArray[battleindex].type == BATTLE_TYPE_P_vs_P ){ + iRet = 1; + }else{ + iRet = BATTLE_NewEntry( + charaindex, + battleindex, + CHAR_getWorkInt( toindex, CHAR_WORKBATTLESIDE ) ); + } + + if( iRet == 0 ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_RESCUE ); + iRet = BATTLE_PetDefaultEntry( + charaindex, + battleindex, + CHAR_getWorkInt( toindex, CHAR_WORKBATTLESIDE ) + ); + } + + + + if( iRet == 0 ){ + int flg; + if( CHAR_getInt( charaindex, CHAR_DEFAULTPET ) >= 0 ){ + pindex = CHAR_getCharPet( charaindex, CHAR_getInt( charaindex, CHAR_DEFAULTPET ) ); + CHAR_setWorkInt( pindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_RESCUE ); + } + //snprintf( szBuffer, sizeof( szBuffer ), "(%s)加入作战。", + // CHAR_getUseName( charaindex ) ); + //BATTLE_BroadCast( battleindex, szBuffer, CHAR_COLORYELLOW ); + if( ( fd = getfdFromCharaIndex(charaindex) ) != -1 ){ + lssproto_EN_send( fd, BattleArray[battleindex].type, BattleArray[battleindex].field_no ); + } + flg = (BattleArray[battleindex].Side[ + CHAR_getWorkInt( toindex, CHAR_WORKBATTLESIDE)].flg + & BSIDE_FLG_HELP_OK)? TRUE:FALSE; + lssproto_HL_send( fd, flg); + sprintf( szBuffer, "BP|%X|%X|%X", + BATTLE_Index2No( battleindex, charaindex ), BP_FLG_JOIN, CHAR_getInt(charaindex, CHAR_MP ) ); + BATTLE_CommandSend( charaindex, szBuffer ); + }else{ + snprintf( szBuffer, sizeof( szBuffer ), "无法参战。" ); + CHAR_talkToCli( charaindex, -1, szBuffer, CHAR_COLORYELLOW); + if( ( fd = getfdFromCharaIndex(charaindex) ) != -1 ){ + lssproto_EN_send( fd, FALSE, BattleArray[battleindex].field_no ); + } + } + BATTLE_ClearGetExp( charaindex ); + return iRet; +} + +BOOL BATTLE_RescueTry( int charaindex) +{ + int x,y; + OBJECT object; + int pfound = FALSE; + int result = FALSE; + int fd; + int i; + int cnt; + + fd = getfdFromCharaIndex( charaindex); + if( fd == -1 ) return FALSE; +#if 1 // 修正利用参战重复加入战斗 Robin + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) { + CHAR_talkToCli( charaindex, -1, " 重复加入战斗! ", CHAR_COLORRED); + print("\n 改封包!!重复加入战斗!:%s ", CHAR_getChar( charaindex, CHAR_CDKEY) ); + //lssproto_EN_send( fd, FALSE, 0 ); + return FALSE; + } +#endif + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE ) { + lssproto_EN_send( fd, FALSE, 0 ); + return FALSE; + } +#ifdef _BATTLE_TIMESPEED + if( CONNECT_getBDTime( fd) > time( NULL) ) { + return FALSE; + } +#endif + for( i = 0; i < CONNECT_WINDOWBUFSIZE; i ++ ) { + CONNECT_setBattlecharaindex(fd,i,-1); + } + CHAR_getCoordinationDir( CHAR_getInt( charaindex, CHAR_DIR ) , + CHAR_getInt( charaindex , CHAR_X ), + CHAR_getInt( charaindex , CHAR_Y ) , + 1 , &x , &y ); + + cnt = 0; + for( object = MAP_getTopObj( CHAR_getInt( charaindex, CHAR_FLOOR),x,y) ; + object ; + object = NEXT_OBJECT(object ) ) + { + int toindex; + int objindex = GET_OBJINDEX(object); + if( OBJECT_getType( objindex) != OBJTYPE_CHARA) continue; + toindex = OBJECT_getIndex( objindex); + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ) continue; + pfound = TRUE; + if( CHAR_getWorkInt( toindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE ){ + continue; + } + if( BattleArray[ CHAR_getWorkInt( toindex, CHAR_WORKBATTLEINDEX)].type + != BATTLE_TYPE_P_vs_E ){ + continue; + } + if( !(BattleArray[CHAR_getWorkInt( toindex,CHAR_WORKBATTLEINDEX)].Side[ + CHAR_getWorkInt( toindex, CHAR_WORKBATTLESIDE)].flg + & BSIDE_FLG_HELP_OK)){ + continue; + } + CONNECT_setBattlecharaindex( fd, cnt, toindex ); + cnt++; + if( cnt == CONNECT_WINDOWBUFSIZE ) break; + } + if( cnt == 0 ) { + if( pfound == FALSE ) { + CHAR_talkToCli( charaindex, -1, "那里没有任何人。", + CHAR_COLORYELLOW); + } + lssproto_EN_send( fd, FALSE, 0 ); + }else if( cnt == 1 ) { + if( BATTLE_RescueEntry( charaindex, + CONNECT_getBattlecharaindex(fd,0) ) ){ + CHAR_talkToCli( charaindex, -1, "无法参战。", CHAR_COLORYELLOW); + }else { + result = TRUE; + } + }else if( cnt > 1 ) { + int strlength; + char msgbuf[1024]; + char escapebuf[2048]; + strcpy( msgbuf, "1\n加入谁的战斗呢?\n"); + strlength = strlen( msgbuf); + for( i = 0; + CONNECT_getBattlecharaindex( fd,i ) != -1 + && i< CONNECT_WINDOWBUFSIZE; i ++ ){ + char *a = CHAR_getChar( CONNECT_getBattlecharaindex(fd,i), CHAR_NAME); + char buf[256]; + snprintf( buf, sizeof( buf),"%s\n", a); + if( strlength + strlen( buf) > arraysizeof( msgbuf)){ + print( "\nerr:%s:%d 视窗的讯息缓冲不足\n", + __FILE__,__LINE__); + break; + } + strcpy( &msgbuf[strlength], buf); + strlength += strlen(buf); + } + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_SELECTBATTLE, + -1, + makeEscapeString( msgbuf, escapebuf, sizeof(escapebuf))); + + } + + return result; +} + + + + +BOOL BATTLE_RescueParentTry( int charaindex, int pindex) +{ + int result = FALSE; + if( CHAR_getFlg( charaindex, CHAR_ISDIE)) return FALSE; + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYINDEX1) != pindex ) return FALSE; + if( CHAR_getWorkInt( pindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE ){ + return FALSE; + } + if( BATTLE_RescueEntry( charaindex, pindex ) ){ + result = FALSE; + }else{ + result = TRUE; + } + if( result == FALSE ) { + CHAR_talkToCli( charaindex, -1, "无法参战。", CHAR_COLORYELLOW); + } + return result; +} + +int BATTLE_PartyNewEntry( + int charaindex, + int battleindex, + int side +) +{ + int iRet = 0, i, work; +#if 1 + + iRet = BATTLE_NewEntry( charaindex, battleindex, side ); + if( iRet )return iRet; + CAflush( charaindex ); + CDflush( charaindex ); + iRet = BATTLE_PetDefaultEntry( charaindex, battleindex, side ); + if( iRet )return iRet; + BATTLE_ClearGetExp( charaindex ); +#endif + + for( i = 1; i < CHAR_PARTYMAX; i ++ ){ + work = CHAR_getWorkInt( charaindex, i + CHAR_WORKPARTYINDEX1 ); + if( CHAR_CHECKINDEX( work ) == FALSE )continue; + if( CHAR_getWorkInt( work, CHAR_WORKBATTLEMODE ) != 0 ){ + continue; + } + iRet = BATTLE_NewEntry( work, battleindex, side ); + if( iRet )break; + CAflush( work ); + CDflush( work ); + iRet = BATTLE_PetDefaultEntry( work, battleindex, side ); + if( iRet )return iRet; + BATTLE_ClearGetExp( work ); + } + return iRet; +} + + + + + + + + + + + + + + +#if 1 + +int BATTLE_WatchNewEntry( + int charaindex, + int battleindex, + int side +) +{ + BATTLE_ENTRY *pEntry; + BATTLE *pBattle; + int iEntryFirst = 0, iEntryMax = BATTLE_ENTRY_MAX, i; + + if( BATTLE_CHECKSIDE( side ) == FALSE )return BATTLE_ERR_PARAM; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return BATTLE_ERR_CHARAINDEX; + + pBattle = &BattleArray[battleindex]; + + if( pBattle->use == FALSE )return BATTLE_ERR_NOUSE; + + if( side < 0 || side > 1 ){ + return BATTLE_ERR_PARAM; + } + + switch( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) ){ + + + case CHAR_TYPEPLAYER: + if( pBattle->Side[side].type != BATTLE_S_TYPE_PLAYER ){ + return BATTLE_ERR_TYPE; + } + iEntryFirst = 0; + iEntryMax = BATTLE_PLAYER_MAX; + break; + default: + print( "不明(%s)(%d)\n", + CHAR_getUseName( charaindex ), + CHAR_getInt( charaindex, CHAR_WHICHTYPE ) ); + return BATTLE_ERR_TYPE; + } + + + pEntry = pBattle->Side[side].Entry; + + for( i = iEntryFirst; i < iEntryMax; i ++ ){ + if( pEntry[i].charaindex == -1 )break; + } + + if( i == iEntryMax ){ + return BATTLE_ERR_ENTRYMAX; + } + + EntryInit( &pEntry[i] ); + + pEntry[i].charaindex = charaindex; + + pEntry[i].bid = i + side * SIDE_OFFSET; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEINDEX, + battleindex ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, + BATTLE_CHARMODE_WATCHINIT ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLESIDE, side ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEFLG, 0 ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, -1 ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, -1 ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM3, -1 ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEWATCH, 1 ); + + return 0; +} + + +int BATTLE_WatchPartyNewEntry( + int charaindex, + int battleindex, + int side +) +{ + int iRet = 0, i, work; +#if 1 + + iRet = BATTLE_WatchNewEntry( charaindex, battleindex, side ); + if( iRet )return iRet; + + CAflush( charaindex ); + + CDflush( charaindex ); + +#endif + + for( i = 1; i < CHAR_PARTYMAX; i ++ ){ + + work = CHAR_getWorkInt( charaindex, i + CHAR_WORKPARTYINDEX1 ); + if( CHAR_CHECKINDEX( work ) == FALSE )continue; + + if( CHAR_getWorkInt( work, CHAR_WORKBATTLEMODE ) != 0 ){ + continue; + } + + iRet = BATTLE_WatchNewEntry( work, battleindex, side ); + + if( iRet )break; + + CAflush( work ); + CDflush( work ); + } + return iRet; + +} + + + + +int BATTLE_CreateForWatcher( int charaindex, int topbattleindex ); + +int BATTLE_WatchEntry( + int charaindex, + int toindex + ) +{ + int iRet = 0, battleindex, fd; + char szBuffer[256]=""; + + battleindex = CHAR_getWorkInt( toindex, CHAR_WORKBATTLEINDEX ); + + if( CHAR_getWorkInt( toindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_FINAL + || CHAR_getWorkInt( toindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE + || CHAR_getWorkInt( toindex, CHAR_WORKBATTLEINDEX ) == -1 + ){ + iRet = 1; + } + + if( iRet == 0 ){ + iRet = BATTLE_CreateForWatcher( charaindex, battleindex ); + } + if( iRet == 0 ){ + //snprintf( szBuffer, sizeof( szBuffer ), "(%s)开始观战。", + // CHAR_getUseName( charaindex ) ); + + //BATTLE_BroadCast( battleindex, szBuffer, CHAR_COLORYELLOW ); + if( ( fd = getfdFromCharaIndex(charaindex) ) != -1 ){ + lssproto_EN_send( fd, BattleArray[battleindex].type, BattleArray[battleindex].field_no ); + } + + sprintf( szBuffer, "BP|%X|%X|%X", + 20, BP_FLG_JOIN, CHAR_getInt(charaindex, CHAR_MP ) ); + BATTLE_CommandSend( charaindex, szBuffer ); + + }else{ + snprintf( szBuffer, sizeof( szBuffer ), "无法观战。" ); + CHAR_talkToCli( charaindex, -1, szBuffer, CHAR_COLORYELLOW); + + if( ( fd = getfdFromCharaIndex(charaindex) ) != -1 ){ + lssproto_EN_send( fd, FALSE, 0 ); + } + } + + return iRet; +} + + + +BOOL BATTLE_WatchTry( int charaindex ) +{ + int x,y; + OBJECT object; + int pfound = FALSE; + int result = FALSE; + int fd; + int i; + int cnt; + + + fd = getfdFromCharaIndex( charaindex); + if( fd == -1 )return FALSE; + + for( i = 0; i < CONNECT_WINDOWBUFSIZE ; i ++ ) { + CONNECT_setBattlecharaindex( fd,i,-1); + } + /* 及蟆及甄 毛 月 */ + CHAR_getCoordinationDir( CHAR_getInt( charaindex, CHAR_DIR ) , + CHAR_getInt( charaindex , CHAR_X ), + CHAR_getInt( charaindex , CHAR_Y ) , + 1 , &x , &y ); + + cnt = 0; + /*愤坌及 及蟆及平乓仿毛潸 允月 */ + for( object = MAP_getTopObj( CHAR_getInt( charaindex, CHAR_FLOOR),x,y) ; + object ; + object = NEXT_OBJECT(object ) ) + { + int toindex; + int objindex = GET_OBJINDEX(object); + /* 平乓仿弁正□元扎卅中 */ + if( OBJECT_getType( objindex) != OBJTYPE_CHARA) continue; + toindex = OBJECT_getIndex( objindex); + /* 皿伊奶乩□元扎卅中 */ + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ) continue; + pfound = TRUE; + /* 爵 匹卅中卅日戚尺 */ + if( CHAR_getWorkInt( toindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE ){ + continue; + } + + CONNECT_setBattlecharaindex( fd,cnt, toindex ); + cnt++; + if( cnt == CONNECT_WINDOWBUFSIZE ) break; + } + if( cnt == 0 ) { + if( pfound == FALSE ) { + CHAR_talkToCli( charaindex, -1, "那里没有任何人。", + CHAR_COLORYELLOW); + } + // 分木手中卅仁化棋爵撩 + lssproto_EN_send( fd, FALSE, 0 ); + } + /* ㄠ谛仄井中卅中桦宁反巨件玄伉□今六月 */ + else if( cnt == 1 ) { + if( BATTLE_WatchEntry( charaindex,CONNECT_getBattlecharaindex(fd,0)) ) + { + result = FALSE; + } else { + result = TRUE; + } + } + /* 醒谛中凶日它奴件玉它毛请仄化 中宁歹六月 */ + else if( cnt > 1 ) { + int strlength; + char msgbuf[1024]; + char escapebuf[2048]; + strcpy( msgbuf, "1\n观看谁的战斗呢?\n"); + strlength = strlen( msgbuf); + /* 它奴件玉它及丢永本□斥综岳[ + * 爵 及平乓仿及域 + */ + for( i = 0; + CONNECT_getBattlecharaindex( fd,i ) != -1 + && i< CONNECT_WINDOWBUFSIZE; + i ++ ) + { + char *a = CHAR_getChar( CONNECT_getBattlecharaindex(fd,i), + CHAR_NAME); + char buf[256]; + snprintf( buf, sizeof( buf),"%s\n", a); + if( strlength + strlen( buf) > arraysizeof( msgbuf)){ + print( "\nerr:%s:%d 视窗的讯息缓冲不足\n", + __FILE__,__LINE__); + break; + } + strcpy( &msgbuf[strlength], buf); + strlength += strlen(buf); + } + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_SELECTBATTLEWATCH, + -1, + makeEscapeString( msgbuf, escapebuf, sizeof(escapebuf))); + } + + return result; +} + + +#endif + + + + + + + +#define MAX_DOUJYOUENEMY 64 +static int DoujyouEnemyTbl[10]; // ㄠㄟ手中日氏仃升 +/*************************************************************** + * 桦乒□玉迕卞衬平乓仿潸 + ***************************************************************/ +int *Doujyou_GetEnemy( int meindex, int charaindex ) +{ + int i; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024]; + int ret; + int insert; + int WorkEnemyTbl[MAX_DOUJYOUENEMY]; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + /* 赓渝祭 */ + for( i = 0; i < arraysizeof(WorkEnemyTbl); i ++ ) { + WorkEnemyTbl[i] = -1; + } + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "enemyno", buf, sizeof( buf)) + == NULL ) + { + return NULL; + } + + insert = 0; + /* 娄醒卞踏中化丐月衬毛巨件玄伉□今六月 */ + for( i = 0; i < MAX_DOUJYOUENEMY; i ++ ) { + int curEnemy; + char data[128]; + + ret = getStringFromIndexWithDelim( buf,",", i + 1,data, sizeof(data)); + if( ret == FALSE) { + break; + } + + curEnemy = ENEMY_getEnemyArrayFromId( atoi( data)); + if( !ENEMY_CHECKINDEX( curEnemy) ) continue; + WorkEnemyTbl[insert] = curEnemy; + insert ++; + } + // 分木手中卅井匀凶日巨仿□ + if( insert <= 0 )return NULL; + + // ㄠ 仿件母丞涩烂 + DoujyouEnemyTbl[0] = WorkEnemyTbl[RAND( 0, insert-1 )]; + + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "enemypetno", buf, sizeof( buf)) + == NULL ) + { + // 中卅井匀凶日窒手踏井卅中 + DoujyouEnemyTbl[1] = -1; + }else{ + insert = 0; + /* 娄醒卞踏中化丐月衬毛巨件玄伉□今六月 */ + for( i = 0; i < MAX_DOUJYOUENEMY; i ++ ) { + int curEnemy; + char data[128]; + + ret = getStringFromIndexWithDelim( buf,",", i + 1,data, sizeof(data)); + if( ret == FALSE) { + break; + } + + curEnemy = ENEMY_getEnemyArrayFromId( atoi( data)); + if( !ENEMY_CHECKINDEX( curEnemy) ) continue; + WorkEnemyTbl[insert] = curEnemy; + insert ++; + } + // ㄡ 仿件母丞涩烂 + DoujyouEnemyTbl[1] = WorkEnemyTbl[RAND( 0, insert-1 )]; + } + + // ㄢ 仄 + DoujyouEnemyTbl[2] = -1; + + return DoujyouEnemyTbl; +} + + + +static int DoujyouWeponTbl[] = { + -1, + ITEM_FIST, + ITEM_AXE, + ITEM_CLUB, + ITEM_SPEAR, + ITEM_BOW, + ITEM_BOOMERANG, + ITEM_BOUNDTHROW, + ITEM_BREAKTHROW, +}; +int DoujyouRandomWeponSet( int charaindex ){ + int wepon = -1, itemindex; + int work = RAND( 0, arraysizeof( DoujyouWeponTbl ) - 1 ); + switch( DoujyouWeponTbl[work] ){ + case ITEM_AXE: wepon = 0;break; + case ITEM_CLUB: wepon = 100;break; + case ITEM_SPEAR: wepon = 200;break; + case ITEM_BOW: wepon = 2498;break; + case ITEM_BOOMERANG:wepon = 500;break; + case ITEM_BOUNDTHROW:wepon = 600;break; + case ITEM_BREAKTHROW:wepon = 700;break; + } + itemindex = CHAR_getItemIndex( charaindex, CHAR_ARM ); + if( ITEM_CHECKINDEX( itemindex ) == TRUE ){ + ITEM_endExistItemsOne( itemindex ); + } + + if( wepon >= 0 ){ + itemindex = ITEM_makeItemAndRegist( wepon ) ; + CHAR_setItemIndex( charaindex, CHAR_ARM, itemindex ); + ITEM_setWorkInt( itemindex, ITEM_WORKCHARAINDEX, charaindex ); + ITEM_setWorkInt( itemindex, ITEM_WORKOBJINDEX, -1 ); + } + switch( DoujyouWeponTbl[work] ){ + case -1: + case ITEM_AXE: + case ITEM_CLUB: + case ITEM_SPEAR: + return 0; + } + return 1; + +} + +static int BattleERSkill1[]={ +3, 10, 11, 12, 30, 31, 40, 41, 50, 51, 52, 60, 61, 80, 90, 110, 120, 150, 210, +303, 309, 315, 321, 503, 504, 506, 507, 541, 542, 543, 544, 545, 546, 547, 575, 579, 580, +606, 613, 615 }; + +static int BattleERSkill2[]={ +12, 13, 20, 41, 52, 152, 210, 306, 312, 318, 324, 325, 500, 501, 502, 505, +508, 541, 542, 543, 544, 545, 546, 547, 576, 580, 594, 606, 613, 616 }; + +void BATTLE_EnemyRandowSetSkill( int enemyindex, int skillType) +{ + int i; + switch( skillType){ + case 1: + for( i=0; i<7; i++){ + int skillarray, skillID, Ri; + Ri = RAND( 0, arraysizeof( BattleERSkill1) - 1 ); + skillID = BattleERSkill1[Ri]; + skillarray = PETSKILL_getPetskillArray( skillID); + if( PETSKILL_CHECKINDEX( skillarray) == FALSE ){ + CHAR_setPetSkill( enemyindex, i, 1); + //andy_log + print("ANDY EnemyRandowSetSkill( ) skillID:%d array:%d err \n", + skillID, skillarray ); + continue; + } + CHAR_setPetSkill( enemyindex, i, skillID); + } + break; + case 2: + for( i=0; i<7; i++){ + int skillarray, skillID, Ri; + Ri = RAND( 0, arraysizeof( BattleERSkill2) - 1 ); + skillID = BattleERSkill2[Ri]; + skillarray = PETSKILL_getPetskillArray( skillID); + if( PETSKILL_CHECKINDEX( skillarray) == FALSE ){ + CHAR_setPetSkill( enemyindex, i, 1); + //andy_log + print("ANDY *EnemyRandowSetSkill( ) skillID:%d array:%d err \n", + skillID, skillarray ); + continue; + } + CHAR_setPetSkill( enemyindex, i, skillID); + } + break; + default : return; + break; + } + +} + +int BATTLE_CreateVsEnemy( int charaindex, int mode, int npcindex ) +{ + int battleindex, iRet = 0, enemyindex, i, pindex; + int *enemytable = NULL, fd, field_no, baselevel = 0; + int skillType=0; + int EnemyList[20]; + + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return BATTLE_ERR_CHARAINDEX; + +#ifdef _STREET_VENDOR + // 摆摊中不可进入战斗 + if( CHAR_getWorkInt(charaindex,CHAR_WORKSTREETVENDOR) > -1) return BATTLE_ERR_END; +#endif + +#ifdef _ANGEL_SUMMON // 装备使者信物不遇敌 + if( CHAR_getWorkInt(charaindex,CHAR_WORKANGELMODE) == TRUE ) return BATTLE_ERR_END; +#endif + + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ){ + CHAR_talkToCli( charaindex, -1, "二重遭遇。", CHAR_COLORYELLOW ); + return BATTLE_ERR_ALREADYBATTLE; + } + battleindex = BATTLE_CreateBattle( ); + if( battleindex < 0 )return BATTLE_ERR_NOTASK; + + if( CHAR_CHECKINDEX( npcindex) ){ + skillType = CHAR_getWorkInt( npcindex, CHAR_NPCWORKINT11); + } + + field_no = BATTLE_getBattleFieldNo( + CHAR_getInt( charaindex, CHAR_FLOOR ) , + CHAR_getInt( charaindex, CHAR_X ) , + CHAR_getInt( charaindex, CHAR_Y ) ); + if( field_no > BATTLE_MAP_MAX || field_no < 0 ){ + field_no = RAND( 0, BATTLE_MAP_MAX ); + } + + BattleArray[battleindex].Side[0].type = BATTLE_S_TYPE_PLAYER; + BattleArray[battleindex].Side[1].type = BATTLE_S_TYPE_ENEMY; + BattleArray[battleindex].leaderindex = charaindex; + BattleArray[battleindex].type = BATTLE_TYPE_P_vs_E; + BattleArray[battleindex].createindex = npcindex; + BattleArray[battleindex].field_no = field_no; + //andy_edit 2002/10/23 + /* + if( (iRet = BATTLE_PartyNewEntry( charaindex, battleindex, 0 ) ) ){ + goto BATTLE_CreateVsEnemy_End; + } + */ + BattleArray[battleindex].Side[0].flg &= ~BSIDE_FLG_HELP_OK; + if( mode == 0 ) { + enemytable = ENEMY_getEnemy( charaindex, + CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y)); + }else if( mode == 1 ) { + enemytable = NPC_Util_getEnemy( npcindex, charaindex); + }else if( mode == 2 ) { + enemytable = Doujyou_GetEnemy( npcindex, charaindex ); + baselevel = CHAR_getInt( npcindex, CHAR_LV ); + BattleArray[battleindex].norisk = 1; + } + if( enemytable == NULL ) { + iRet = BATTLE_ERR_NOENEMY; + goto BATTLE_CreateVsEnemy_End; + } + + for( i = 0; *(enemytable+i)!= -1 && i < arraysizeof( EnemyList )-1; i ++ ){ + EnemyList[i] = *(enemytable+i); + } + EnemyList[i] = -1; + +#ifdef _BATTLE_TIMESPEED + fd = getfdFromCharaIndex( charaindex ); + BattleArray[battleindex].CreateTime = time(NULL); + BattleArray[battleindex].flgTime = 200; // 1/100 sec +#endif + +#ifdef _ACTION_BULLSCR +#ifndef _BULL_CUTBULLSCR + BattleArray[battleindex].enemynum=0; +#endif +#endif + for( i = 0; EnemyList[i] != -1; i ++ ){ + int work; + enemyindex = ENEMY_createEnemy( EnemyList[i], baselevel ); +#ifdef _ACTION_BULLSCR +#ifndef _BULL_CUTBULLSCR + BattleArray[battleindex].enemynum++; +#endif +#endif + if( skillType > 0 ){ + //int ENEMY_RandomChange( int enemyindex, int tempno ){ + BATTLE_EnemyRandowSetSkill( enemyindex, skillType); + } + if( enemyindex < 0 ){ + iRet = BATTLE_ERR_NOENEMY; + goto BATTLE_CreateVsEnemy_End; + } + + if( mode == 2 ){ + if( i == 0 ){ + CHAR_setInt( enemyindex, CHAR_BASEBASEIMAGENUMBER, + CHAR_getInt( npcindex, CHAR_BASEBASEIMAGENUMBER ) ); + CHAR_setInt( enemyindex, CHAR_BASEIMAGENUMBER, + CHAR_getInt( npcindex, CHAR_BASEBASEIMAGENUMBER ) ); + CHAR_setChar( enemyindex, CHAR_NAME, + CHAR_getChar( npcindex, CHAR_NAME ) ); + CHAR_complianceParameter( enemyindex ); + } + } + if( ( iRet = BATTLE_NewEntry( enemyindex, battleindex, 1 ) ) ){ + goto BATTLE_CreateVsEnemy_End; + } + if( CHAR_getInt( enemyindex, CHAR_DUELPOINT ) > 0 ){ + BattleArray[battleindex].dpbattle = 1; + } + work = CHAR_getInt( enemyindex, CHAR_BASEBASEIMAGENUMBER ); + if( 100466 <= work && work <= 100471 ){ + CHAR_setWorkInt( enemyindex, CHAR_WORKBATTLEFLG, + CHAR_getWorkInt( enemyindex, CHAR_WORKBATTLEFLG ) | CHAR_BATTLEFLG_ABIO ); + print( "(%s)无生物\n", CHAR_getUseName( enemyindex ) ); + } + } + //andy_edit 2002/10/23 + if( (iRet = BATTLE_PartyNewEntry( charaindex, battleindex, 0 ) ) ){ + goto BATTLE_CreateVsEnemy_End; + } + { + BATTLE_ENTRY *pEntry, EntryWork; + pEntry = BattleArray[battleindex].Side[1].Entry; + for( i = 0; i < 5; i ++ ){ + EntryWork = pEntry[i]; + pEntry[i] = pEntry[i+5]; + pEntry[i+5] = EntryWork; + pEntry[i].bid = i + SIDE_OFFSET; + pEntry[i+5].bid = i + 5 + SIDE_OFFSET; + } + } + +BATTLE_CreateVsEnemy_End:; + fd = getfdFromCharaIndex( charaindex); + + if( iRet ){ + BATTLE_ExitAll( battleindex ); + BATTLE_DeleteBattle( battleindex ); + if( fd != -1 )lssproto_EN_send( fd, FALSE, field_no ); + }else{ + if( fd != -1 ){ + if( BattleArray[battleindex].dpbattle ){ + lssproto_EN_send( fd, BATTLE_TYPE_DP_BATTLE, field_no ); + }else{ + if( mode == 1 ){ + lssproto_EN_send( fd, BATTLE_TYPE_BOSS_BATTLE, field_no ); + }else{ + lssproto_EN_send( fd, BattleArray[battleindex].type, field_no ); + } + } + }else { + BATTLE_ExitAll( battleindex ); + BATTLE_DeleteBattle( battleindex ); + return iRet; + } + + for( i = 1; i < CHAR_PARTYMAX; i ++ ){ + pindex = CHAR_getWorkInt( charaindex, i + CHAR_WORKPARTYINDEX1 ); + if( CHAR_CHECKINDEX( pindex ) == FALSE )continue; + if( CHAR_getWorkInt( pindex, CHAR_WORKBATTLEMODE ) == + BATTLE_CHARMODE_FINAL ) continue; + fd = getfdFromCharaIndex(pindex); + if( fd != -1 ){ + if( mode == 1 ){ + lssproto_EN_send( fd, BATTLE_TYPE_BOSS_BATTLE, field_no ); + }else{ + lssproto_EN_send( fd, BattleArray[battleindex].type, field_no ); + } + } + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKACTION) != -1 ) { + CHAR_sendWatchEvent( + CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), + CHAR_ACTSTAND, + NULL, 0, FALSE); + CHAR_setWorkInt( charaindex, CHAR_WORKACTION, -1); + } + CHAR_sendBattleEffect( charaindex, ON); + for( i = 1; i < CHAR_PARTYMAX; i ++ ){ + pindex = CHAR_getWorkInt( charaindex, i + CHAR_WORKPARTYINDEX1 ); + if( CHAR_CHECKINDEX( pindex ) == FALSE )continue; + if( CHAR_getWorkInt( pindex, CHAR_WORKACTION) != -1 ) { + CHAR_sendWatchEvent( + CHAR_getWorkInt( pindex, CHAR_WORKOBJINDEX), + CHAR_ACTSTAND, + NULL, 0, FALSE); + CHAR_setWorkInt( pindex, CHAR_WORKACTION, -1); + } + CHAR_sendBattleEffect( pindex, ON); + } + } + return iRet; +} + +int BATTLE_CreateVsPlayer( int charaindex0, int charaindex1 ) +{ + int battleindex, pindex, field_no, + i, j, charaindex[2], + parent[2], fd, + iRet = 0; + + if( CHAR_CHECKINDEX( charaindex0 ) == FALSE )return BATTLE_ERR_CHARAINDEX; + if( CHAR_CHECKINDEX( charaindex1 ) == FALSE )return BATTLE_ERR_CHARAINDEX; + + if( CHAR_getWorkInt( charaindex0, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ){ + CHAR_talkToCli( charaindex0, -1, "二重遭遇。", CHAR_COLORYELLOW ); + CHAR_talkToCli( charaindex1, -1, "二重遭遇。", CHAR_COLORYELLOW ); + return BATTLE_ERR_ALREADYBATTLE; + } + if( CHAR_getWorkInt( charaindex1, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ){ + CHAR_talkToCli( charaindex0, -1, "二重遭遇。", CHAR_COLORYELLOW ); + CHAR_talkToCli( charaindex1, -1, "二重遭遇。", CHAR_COLORYELLOW ); + return BATTLE_ERR_ALREADYBATTLE; + } +#ifdef _DEATH_CONTEND + if( CHAR_getInt( charaindex0, CHAR_FLOOR) == 8250 || + CHAR_getInt( charaindex0, CHAR_PKLISTLEADER) != 1 || + CHAR_getInt( charaindex0, CHAR_PKLISTTEAMNUM) == -1 || +// CHAR_getWorkInt( charaindex0, CHAR_WORKPARTYMODE ) != CHAR_PARTY_LEADER || + CHAR_getInt( charaindex1, CHAR_PKLISTLEADER) != 1 || + CHAR_getInt( charaindex1, CHAR_PKLISTTEAMNUM) == -1 //|| +// CHAR_getWorkInt( charaindex1, CHAR_WORKPARTYMODE ) != CHAR_PARTY_LEADER + + ){ + + + CHAR_talkToCli( charaindex0, -1, "无效战斗。", CHAR_COLORYELLOW ); + CHAR_talkToCli( charaindex1, -1, "无效战斗。", CHAR_COLORYELLOW ); + return BATTLE_ERR_ALREADYBATTLE; + } +/* + + if( PKLIST_CheckPKReapetTeam( + CHAR_getInt( charaindex0, CHAR_PKLISTTEAMNUM), + CHAR_getInt( charaindex1, CHAR_PKLISTTEAMNUM) ) == FALSE ){ + CHAR_talkToCli( charaindex0, -1, "重复战斗。", CHAR_COLORYELLOW ); + CHAR_talkToCli( charaindex1, -1, "重复战斗。", CHAR_COLORYELLOW ); + return BATTLE_ERR_ALREADYBATTLE; + } +*/ +#endif + + field_no = BATTLE_getBattleFieldNo( + CHAR_getInt( charaindex0, CHAR_FLOOR ) , + CHAR_getInt( charaindex0, CHAR_X ), + CHAR_getInt( charaindex0, CHAR_Y ) ); + + charaindex[0] = charaindex0; + charaindex[1] = charaindex1; + for( j = 0; j < 2; j ++ ){ + if( CHAR_getWorkInt( charaindex[j], CHAR_WORKBATTLEMODE ) != 0 ){ + return BATTLE_ERR_ALREADYBATTLE; + } + } + for( j = 0; j < 2; j ++ ){ + if( CHAR_getWorkInt( charaindex[j], CHAR_WORKPARTYMODE ) == CHAR_PARTY_LEADER ){ + parent[j] = charaindex[j]; + }else + if( CHAR_getWorkInt( charaindex[j], CHAR_WORKPARTYMODE ) == CHAR_PARTY_CLIENT ){ + parent[j] = CHAR_getWorkInt( charaindex[j], CHAR_WORKPARTYINDEX1 ); + }else{ + parent[j] = -1; + } + } + if( parent[0] != -1 && parent[0] == parent[1] ){ + return BATTLE_ERR_SAMEPARTY; + } + battleindex = BATTLE_CreateBattle( ); + if( battleindex < 0 )return BATTLE_ERR_NOTASK; + + BattleArray[battleindex].Side[0].type = BATTLE_S_TYPE_PLAYER; + BattleArray[battleindex].Side[1].type = BATTLE_S_TYPE_PLAYER; + BattleArray[battleindex].leaderindex = charaindex0; + BattleArray[battleindex].type = BATTLE_TYPE_P_vs_P; + BattleArray[battleindex].dpbattle = 1; + BattleArray[battleindex].field_no = field_no; +#ifdef _BATTLE_TIMESPEED + BattleArray[battleindex].CreateTime = time(NULL); +#endif + +#ifdef _DEATH_CONTEND//计算胜败func + BattleArray[battleindex].PkFunc = NPC_PKLIST_Finish_Exit; + //winside = 0 + BattleArray[battleindex].menum = CHAR_getInt( charaindex0, CHAR_PKLISTTEAMNUM); + BattleArray[battleindex].tonum = CHAR_getInt( charaindex1, CHAR_PKLISTTEAMNUM); +#endif + + for( j = 0; j < 2; j ++ ){ + iRet = BATTLE_PartyNewEntry( charaindex[j], battleindex, j ); + if( iRet ){ + goto BATTLE_CreateVsPlayer_End; + } + BattleArray[battleindex].Side[j].flg &= ~BSIDE_FLG_HELP_OK; + } +BATTLE_CreateVsPlayer_End:; + if( iRet ){ + BATTLE_ExitAll( battleindex ); + BATTLE_DeleteBattle( battleindex ); + fd = getfdFromCharaIndex(charaindex[0]); + if( fd != -1 )lssproto_EN_send( fd, FALSE, field_no ); + }else{ + for( j = 0; j < 2; j ++ ){ + fd = getfdFromCharaIndex(charaindex[j]); + if( fd != -1 )lssproto_EN_send( fd, BattleArray[battleindex].type, field_no ); + if( CHAR_getWorkInt( charaindex[j], CHAR_WORKACTION) != -1 ) { + CHAR_sendWatchEvent( + CHAR_getWorkInt( charaindex[j], CHAR_WORKOBJINDEX), + CHAR_ACTSTAND, + NULL, 0, FALSE); + CHAR_setWorkInt( charaindex[j], CHAR_WORKACTION, -1); + + } + CHAR_sendBattleEffect( charaindex[j], ON); + for( i = 1; i < CHAR_PARTYMAX; i ++ ){ + pindex = CHAR_getWorkInt( charaindex[j], i + CHAR_WORKPARTYINDEX1 ); + if( CHAR_CHECKINDEX( pindex ) == FALSE )continue; + if( CHAR_getWorkInt( pindex, CHAR_WORKBATTLEMODE ) == + BATTLE_CHARMODE_FINAL ) continue; + + fd = getfdFromCharaIndex(pindex); + if( fd != -1 )lssproto_EN_send( fd, BattleArray[battleindex].type, field_no ); + if( CHAR_getWorkInt( pindex, CHAR_WORKACTION) != -1 ) { + CHAR_sendWatchEvent( + CHAR_getWorkInt( pindex, CHAR_WORKOBJINDEX), + CHAR_ACTSTAND, + NULL, 0, FALSE); + CHAR_setWorkInt( pindex, CHAR_WORKACTION, -1); + + } + CHAR_sendBattleEffect( pindex, ON ); + } + } + } + return iRet; +} + + +//********************************************************* +// +// 棋爵迕田玄伙正旦弁毛馨笛[玄永皿及戚卞涩烂允月 +// +int BATTLE_WatchLink( int topbattleindex, int battleindex ) +// +// +//********************************************************* +{ + BATTLE *pWork, *pTop; + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE ){ + fprint( "err:battle index 奇怪(%d)\n", battleindex ); + return FALSE; + } + if( BATTLE_CHECKINDEX( topbattleindex ) == FALSE ){ + fprint( "err:battle index 奇怪(%d)\n", topbattleindex ); + return FALSE; + } + + pTop = &BattleArray[topbattleindex]; + + if( BATTLE_CHECKADDRESS( pTop ) == FALSE ){ + fprint( "err:battle address 奇怪(%p)\n", pTop ); + return FALSE; + } + + + pWork = pTop->pNext; // 田永弁失永皿 + + if( pWork ){ + if( BATTLE_CHECKADDRESS( pWork ) == FALSE ){ + fprint( "err:battle address 奇怪(%p)\n", pWork ); + return FALSE; + } + } + + // 愤坌毛蟆及戚卞允月 + pTop->pNext = &BattleArray[battleindex]; + // 愤坌及蟆田玄伙毛涩烂 + BattleArray[battleindex].pBefore = pTop; + // 愤坌及戚田玄伙毛涩烂 + BattleArray[battleindex].pNext = pWork; + // 戚及蟆反愤坌 + if( pWork ){ + pWork->pBefore = &BattleArray[battleindex]; + } + return TRUE; +} + +//********************************************************* +// +// 棋爵迕田玄伙正旦弁毛夫午勾 仁 +// +int BATTLE_WatchUnLink( int battleindex ) +// +// +//********************************************************* +{ + BATTLE *pTop; + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE ){ + fprint( "err:battle index 奇怪(%d)\n", battleindex ); + return FALSE; + } + + // 愤坌毛蟆及田玄伙 + pTop = BattleArray[battleindex].pBefore; + + if( pTop ){ + if( BATTLE_CHECKADDRESS( pTop ) == FALSE ){ + fprint( "err:battle address 奇怪(%p)\n", pTop ); + }else{ + // 勾卅亢卅云仄 + pTop->pNext = BattleArray[battleindex].pNext; + } + } + if( BattleArray[battleindex].pNext ){ + if( BATTLE_CHECKADDRESS( BattleArray[battleindex].pNext ) == FALSE ){ + fprint( "err:battle address 奇怪(%p)\n", BattleArray[battleindex].pNext ); + }else{ + BattleArray[battleindex].pNext->pBefore = pTop; + } + } + // 愤坌及蟆田玄伙毛涩烂 + BattleArray[battleindex].pBefore = NULL; + // 愤坌及戚田玄伙反 仄 + BattleArray[battleindex].pNext = NULL; + + return TRUE; + +} + + +//********************************************************* +// +// 棋爵迕卞田玄伙正旦弁毛综岳允月 +// +int BATTLE_CreateForWatcher( int charaindex, int topbattleindex ) +// +// 曰袄 BATTLE_ERR +// +//********************************************************* +{ + int battleindex, field_no , pindex, + i, fd, + iRet = 0; + + // 由仿丢□正民尼永弁 + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return BATTLE_ERR_CHARAINDEX; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ){ + CHAR_talkToCli( charaindex, -1, "二重遭遇。", CHAR_COLORYELLOW ); + return BATTLE_ERR_ALREADYBATTLE; + } + + // 允匹卞爵 匹卅中井 + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) != 0 ){ + return BATTLE_ERR_ALREADYBATTLE; + } + + // 爵 正旦弁毛综岳允月 + battleindex = BATTLE_CreateBattle( ); + if( battleindex < 0 )return BATTLE_ERR_NOTASK;// 正旦弁 苇匹五卅井匀凶巨仿□ + + // 仇切日及讽采反皿伊奶乩□讽采匹丐月午烂聒允月[ + BattleArray[battleindex].Side[0].type = BATTLE_S_TYPE_PLAYER; + // 轾仇丹础及讽采手皿伊奶乩□讽采匹丐月午烂聒允月[ + BattleArray[battleindex].Side[1].type = BATTLE_S_TYPE_PLAYER; + // 伉□母□毛忡绣 + BattleArray[battleindex].leaderindex = charaindex; + // 爵 及正奶皿 + BattleArray[battleindex].type = BATTLE_TYPE_WATCH; + BattleArray[battleindex].mode = BATTLE_MODE_WATCHBC; + // 田玄伙白奴□伙玉 寞 + field_no = BattleArray[battleindex].field_no = BattleArray[topbattleindex].field_no; + BattleArray[battleindex].turn = BattleArray[topbattleindex].turn; + + // 伉件弁今六月 + if( BATTLE_WatchLink( topbattleindex, battleindex ) == FALSE ){ + fprint( "err:battle link error(%d),(%d)\n", + topbattleindex, battleindex ); + // 巨仿□质 匹及 GOTO + goto BATTLE_CreateForWatcher_End; + } + + // 由□ 奴仍午巨件玄伉□ + iRet = BATTLE_WatchPartyNewEntry( charaindex, battleindex, 0 ); + if( iRet ){ + // 巨仿□质 匹及 GOTO + goto BATTLE_CreateForWatcher_End; + } + + +// 巨仿□及桦宁反允什卞戊戊卞 月 +BATTLE_CreateForWatcher_End:; + + if( iRet ){ // 巨仿□互丐匀凶日正旦弁 滋 + // 蝈够 仃月 + BATTLE_ExitAll( battleindex ); + //{爵 正旦弁绰轮 + BATTLE_DeleteBattle( battleindex ); + fd = getfdFromCharaIndex( charaindex ); + if( fd != -1 )lssproto_EN_send( fd, FALSE, field_no ); + }else{ + fd = getfdFromCharaIndex( charaindex ); + /* 巨件市它件玄岳 毛项尹月 */ + if( fd != -1 )lssproto_EN_send( fd, BattleArray[battleindex].type, field_no ); + /* 切禾□术霜月 */ + if( CHAR_getWorkInt( charaindex, CHAR_WORKACTION) != -1 ) { + CHAR_sendWatchEvent( + CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), + CHAR_ACTSTAND, + NULL, 0, FALSE); + CHAR_setWorkInt( charaindex, CHAR_WORKACTION, -1); + } + /* 爵 失奶戊件 憎CA霜耨 */ + CHAR_sendBattleWatch( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX ), ON); + + // 醮棉卞手项尹月 + for( i = 1; i < CHAR_PARTYMAX; i ++ ){ + pindex = CHAR_getWorkInt( charaindex, i + CHAR_WORKPARTYINDEX1 ); + if( CHAR_CHECKINDEX( pindex ) == FALSE )continue; + // 切扎氏午巨件市它件玄匹五化卅中卅日霜日卅中 + // FINAL 分匀凶日蟆及爵 苇化中月 + if( CHAR_getWorkInt( pindex, CHAR_WORKBATTLEMODE ) == + BATTLE_CHARMODE_FINAL ) continue; + + fd = getfdFromCharaIndex(pindex); + /* 巨件市它件玄岳 */ + if( fd != -1 )lssproto_EN_send( fd, BattleArray[battleindex].type, field_no ); + /* 切禾□术霜月 */ + if( CHAR_getWorkInt( pindex, CHAR_WORKACTION) != -1 ) { + CHAR_sendWatchEvent( + CHAR_getWorkInt( pindex, CHAR_WORKOBJINDEX), + CHAR_ACTSTAND, + NULL, 0, FALSE); + CHAR_setWorkInt( pindex, CHAR_WORKACTION, -1); + } + /* 爵 失奶戊件 憎CA霜耨 */ + CHAR_sendBattleWatch( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX ), ON); + } +/* + print( "以(%s)为领队与敌军交手。", + CHAR_getChar( charaindex, CHAR_NAME ) ); +*/ + } + + + return iRet; +} + + + + + + +/*------------------------------------------------------------ + * 爵 毛 蝇允月 + ------------------------------------------------------------*/ +void BATTLE_WatchStop( int charaindex ) +{ + int battleindex; + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return; + // 平乓仿弁正互中凶日 仃今六月 + BATTLE_Exit( charaindex, battleindex ); + // 由□ 奴 仃月 + CHAR_DischargePartyNoMsg( charaindex ); + + CHAR_talkToCli( charaindex, -1, + "战斗中止。", CHAR_COLORYELLOW ); + + lssproto_B_send( getfdFromCharaIndex( charaindex ), "BU" ); + +} + + + + + + + + + +//************************************************************* +// +// 正□件备潘热诸匹 蛹仄凶由仿丢□正毛俅孺仄化中仁 +// +void BATTLE_TurnParam( + int charaindex, + int fixkind, + int mod, + int last +) +// +// +//************************************************************* +{ + int modparam, fixparam, lastparam; + + if( fixkind == -1 ){ + fixparam = 0; // 葭互 中桦宁反ㄟ + }else{ + fixparam = CHAR_getWorkInt( charaindex, fixkind ); + } + if( last == -1 ){ + lastparam = 0; + }else{ + lastparam = CHAR_getWorkInt( charaindex, last ); + } + modparam = CHAR_getWorkInt( charaindex, mod ); + // 仇仇匹 ≈ 午 及 毛苇化} + // 及袄毛俅孺仄化中仁 + + // 漆反 MODPARAM 毛ㄡㄟ⊙蛹仄化中仁 + modparam *= 0.8; + CHAR_setWorkInt( charaindex, mod, modparam ); + + // 卞笛尹月 + if( last != -1 ){ + CHAR_setWorkInt( + charaindex, + last, + lastparam + modparam * 0.01 ); + } + +} + +void BATTLE_AttReverse( int charaindex ) +{ + int earth, water, fire, wind; + //ttom start because the second had this + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_REVERSE ){ + // 鳖仄化月卅日戚尺 + }else{ + // 鳖仄化卅中及匹伉正□件 + return; + } + //ttom end + earth = CHAR_getWorkInt( charaindex, CHAR_WORKFIXEARTHAT ); + water = CHAR_getWorkInt( charaindex, CHAR_WORKFIXWATERAT ); + fire = CHAR_getWorkInt( charaindex, CHAR_WORKFIXFIREAT ); + wind = CHAR_getWorkInt( charaindex, CHAR_WORKFIXWINDAT ); + + CHAR_setWorkInt( charaindex, CHAR_WORKFIXEARTHAT, fire ); + CHAR_setWorkInt( charaindex, CHAR_WORKFIXWATERAT, wind ); + CHAR_setWorkInt( charaindex, CHAR_WORKFIXFIREAT, earth ); + CHAR_setWorkInt( charaindex, CHAR_WORKFIXWINDAT, water ); + +} + +void BATTLE_PreCommandSeq( int battleindex ) +{ + BATTLE_ENTRY *pEntry; + BATTLE *pBattle; + int i, j, charaindex; + BATTLE_CharSendAll( battleindex ); + BATTLE_CharaBackUp( battleindex ); + BattleArray[battleindex].timer = NowTime.tv_sec; + BATTLE_AllCharaCWaitSet( battleindex ); + BATTLE_ActSettingSend( battleindex ); + BattleArray[battleindex].flg |= BATTLE_FLG_FREEDP; + pBattle = &BattleArray[battleindex]; + for( j = 0; j < 2; j ++ ){ + int flg; + pEntry = pBattle->Side[j].Entry; + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + pEntry[i].guardian = -1; + charaindex = pEntry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + flg = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEFLG ); +//ttom the second only one //flg &= ~CHAR_BATTLEFLG_GUARDIAN; + flg &= ~CHAR_BATTLEFLG_GUARDIAN; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEFLG, flg ); + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_EARTHROUND0 ) continue; + + CHAR_complianceParameter( charaindex ); + BATTLE_TurnParam( charaindex, + CHAR_WORKFIXSTR, // 猾 + CHAR_WORKMODATTACK, + CHAR_WORKATTACKPOWER + ); + BATTLE_TurnParam( charaindex, + CHAR_WORKFIXTOUGH, // 潮 + CHAR_WORKMODDEFENCE, + CHAR_WORKDEFENCEPOWER + ); + BATTLE_TurnParam( charaindex, + CHAR_WORKFIXDEX, // 豳镀今 + CHAR_WORKMODQUICK, + CHAR_WORKQUICK + ); + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + BATTLE_TurnParam( charaindex, + -1, + CHAR_WORKMODCHARM, // + CHAR_WORKFIXCHARM + ); + } + BATTLE_TurnParam( charaindex, + -1, // 凯 + CHAR_WORKMODCHARM, + -1 + ); + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_REVERSE ){ + BATTLE_AttReverse( charaindex ); + } + } + } +} + + +//************************************************** +// +// 棋爵及桦宁及戊穴件玉谨切尺 月凛及域 及 木 +// +void BATTLE_PreWatchWaitSeq( int battleindex ) +// +// +//************************************************** +{ + // 仇及凛鳔匹凛对忡绣 + BattleArray[battleindex].timer = NowTime.tv_sec; + // 蝈够及乒□玉毛戊穴件玉 蟆卞允月 + BATTLE_AllCharaWatchWaitSet( battleindex ); +} +static int BATTLE_Init( int battleindex ) +{ + BATTLE *pBattle; + int iRet = 0; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + pBattle = &BattleArray[battleindex]; + pBattle->mode = BATTLE_MODE_BATTLE; + iRet = BATTLE_SurpriseCheck( battleindex ); + if( iRet == 0 ){ + }else + if( iRet == 1 ){ + BattleArray[battleindex].Side[1].flg |= BSIDE_FLG_SURPRISE; + }else + if( iRet == 2 ){ + BattleArray[battleindex].Side[0].flg |= BSIDE_FLG_SURPRISE; + } + BATTLE_PreCommandSeq( battleindex ); + return 0; +} +int BATTLE_CountEntry( + int battleindex, + int side +) +{ + int i; + BATTLE_ENTRY *pEntry; + int cnt = 0; + + // 由仿丢□正民尼永弁 + if( BATTLE_CHECKSIDE( side ) == FALSE )return -BATTLE_ERR_PARAM; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return -BATTLE_ERR_BATTLEINDEX; + + // 巨件玄伉□ + pEntry = BattleArray[battleindex].Side[side].Entry; + + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + if( pEntry[i].charaindex != -1 ){ // 平乓仿互中凶日醒尹月 + cnt ++; + } + } + return cnt; +} + +static BOOL BATTLE_CommandWait( int battleindex, int side) +{ + int i, charaindex, BeOk=0; + BATTLE_ENTRY *pEntry; + BOOL iRet = TRUE; + BOOL TimeOut = FALSE; + if( BATTLE_CHECKSIDE( side ) == FALSE )return TRUE;//检查值是否在合法 围 + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return TRUE; + if( BattleArray[battleindex].Side[side].type == BATTLE_S_TYPE_ENEMY ) return TRUE; + pEntry = BattleArray[battleindex].Side[side].Entry; + +#ifdef _BATTLECOMMAND_TIME + if( BattleArray[battleindex].PartTime > 1 && + BattleArray[battleindex].PartTime < time(NULL) ){ + TimeOut = TRUE; + } +#endif + + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pEntry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == TRUE ){ + continue; + } + switch ( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) ){ + case BATTLE_CHARMODE_C_OK: + BeOk++; + case BATTLE_CHARMODE_INIT: + case BATTLE_CHARMODE_RESCUE: + case BATTLE_CHARMODE_WATCHINIT: + break; + case BATTLE_CHARMODE_C_WAIT: + { +#ifdef _BATTLECOMMAND_TIME + if( TimeOut == TRUE ){ + //andy_log + print("ANDY TimeOut Exit:%d-[%s|%s]\n", + charaindex, CHAR_getUseName( charaindex), + CHAR_getChar( charaindex, CHAR_CDKEY) ); + + CHAR_talkToCli( charaindex, -1, "超过时间未下指令,强迫离开战斗!", CHAR_COLORYELLOW); + + CHAR_DischargeParty( charaindex, 0);//解散团队 + CHAR_setWorkInt(charaindex, CHAR_WORKFMPKFLAG, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_COMPELESCAPE ); + BATTLE_Exit( charaindex, battleindex ); + lssproto_B_send( getfdFromCharaIndex( charaindex ), "BU" ); +// CONNECT_setCloseRequest( getfdFromCharaIndex( charaindex) , 1 ); + break; + } +#endif + iRet = FALSE; + } + break; + default : + BATTLE_Exit( charaindex, battleindex ); + break; + } + } + + if( BeOk > 0 ){ +#ifdef _BATTLECOMMAND_TIME + if( BattleArray[ battleindex].PartTime <= 0 ){ + //如果战役中有任一人执行指令, 则延迟时间设为120秒 + BattleArray[battleindex].PartTime = (int)time(NULL) + 120; + } +#endif + } + return iRet; +} + + +#ifdef _ITEM_ADDEXP //vincent 经验提升 +#ifdef _ITEM_ADDEQUIPEXP +int BATTLE_GetExp( int charaindex, int midx ) +#else +int BATTLE_GetExp( int charaindex ) +#endif +{ + int addexp,i; + int modexp=0, getexp=0; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return 0; + + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPET) { + int ownerindex = CHAR_getWorkInt( charaindex, CHAR_WORKPLAYERINDEX); + if( CHAR_CHECKINDEX( ownerindex) && CHAR_getWorkInt( ownerindex, CHAR_WORKITEM_ADDEXP) > 0){ + modexp = CHAR_getWorkInt( ownerindex, CHAR_WORKITEM_ADDEXP); + } + }else if(CHAR_getWorkInt(charaindex,CHAR_WORKITEM_ADDEXP) > 0){ + modexp = CHAR_getWorkInt(charaindex,CHAR_WORKITEM_ADDEXP); + } + + getexp = CHAR_getWorkInt( charaindex, CHAR_WORKGETEXP ); +#ifdef _NEWOPEN_MAXEXP + if( getexp > 1000000000 ) getexp = 1000000000; +#endif + if( getexp < 0 ) getexp = 0; + addexp = getexp+((getexp*modexp)/100); +#ifdef _GET_BATTLE_EXP + addexp*=getBattleexp(); +#endif +#ifdef _ITEM_ADDEQUIPEXP + if( CHAR_CHECKINDEX( midx ) ){ + for( i = 0 ; i < CHAR_EQUIPPLACENUM ; i ++ ){ + int id = CHAR_getItemIndex(midx,i);//道具id + if( ITEM_CHECKINDEX(id) ){ + char *arg,*P; + arg = ITEM_getChar(id, ITEM_ARGUMENT );//道具参数 + if( (P = strstr( arg, "EXPUP" )) ){ + if( (P = strstr( arg, "人" )) ){//只对人有效 + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) + addexp += getexp*atoi(P+=2)*0.01; + } + else if( (P = strstr( arg, "宠" )) ){//只对宠有效 + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPET + && (CHAR_getInt( midx, CHAR_RIDEPET) != charaindex ) ) + addexp += getexp*atoi(P+=2)*0.01; + } + else if( (P = strstr( arg, "骑" )) ){//只对骑宠有效 + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPET + && (CHAR_getInt( midx, CHAR_RIDEPET) == charaindex ) ) + addexp += getexp*atoi(P+=2)*0.01; + } + else{ + P = strstr( arg, "EXPUP" ); + addexp += getexp*atoi(P+=5)*0.01; + } + } + } + } + } +#endif +#ifdef _ITEM_ADDPETEXP + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPET ) + if( CHAR_getInt( charaindex, CHAR_PETID) == 1163 ) + addexp = 0; + +#endif + addexp = (addexp<0)?0:addexp; + if( CHAR_getInt( charaindex, CHAR_LV) >= CHAR_MAXUPLEVEL ) addexp = 0; + CHAR_setWorkInt( charaindex, CHAR_WORKGETEXP, addexp );//回存CHAR_WORKGETEXP + + CHAR_AddMaxExp( charaindex, addexp); + + return addexp; +} +#else + +#ifdef _ITEM_ADDEQUIPEXP +int BATTLE_GetExp( int charaindex, int midx ) +#else +int BATTLE_GetExp( int charaindex ) +#endif +{ + int addexp, nowexp; + + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return 0; + nowexp = CHAR_getInt( charaindex, CHAR_EXP ); + addexp = CHAR_getWorkInt( charaindex, CHAR_WORKGETEXP ); + // shan 11/27 10^9 1224160000 + CHAR_AddMaxExp( charaindex, addexp); + return addexp; +} +#endif + +int BATTLE_DpCalc( int battleindex ) +{ + BATTLE_ENTRY *pLooseEntry, *pWinEntry; + int winside, looseside, i, charaindex, dpadd, dpall, num = 0; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + + winside = BattleArray[battleindex].winside; + looseside = 1 - winside; + if( winside != 0 && winside != 1 )return BATTLE_ERR_PARAM; + + // 宁煌袄赓渝祭 + dpall = 0; + + // 仃凶 井日 毛畴丹 + pLooseEntry = BattleArray[battleindex].Side[looseside].Entry; + for( i = 0 ; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pLooseEntry[i].charaindex; + // 皿伊奶乩□动陆反饬 仄 + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER )continue; + // ㄠㄟ坌及ㄠ手日尹月 + dpadd = CHAR_getInt( charaindex, CHAR_DUELPOINT ) * DUELPOINT_RATE; + // 仃凶 卞反 毛穴奶瓜旦涩烂 + CHAR_setWorkInt( charaindex, CHAR_WORKGETEXP, + CHAR_getWorkInt( charaindex, CHAR_WORKGETEXP) - dpadd ); + // 宁煌袄卞笛遥 + dpall += dpadd; + } + + // 今日卞 仆凶曰仄凶谛迕及 毛笛遥 + dpall += BattleArray[battleindex].Side[winside].common_dp; + + pWinEntry = BattleArray[battleindex].Side[winside].Entry; + for( num = 0,i = 0 ; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pWinEntry[i].charaindex; + // 皿伊奶乩□动陆反饬 仄 + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER )continue; + num++; + } + // 卅兮井 匀凶幻丹卞簿手中卅中 + if( num <= 0 )return BATTLE_ERR_BATTLEINDEX; + dpadd = dpall / num; + if( dpadd <= 0 )dpadd = 1; // 斓匹手ㄠ反芨尹月 + + for( num = 0,i = 0 ; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pWinEntry[i].charaindex; + // 皿伊奶乩□动陆反饬 仄 + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER )continue; + + // 匀凶 卞反 毛涩烂 + CHAR_setWorkInt( charaindex, CHAR_WORKGETEXP, + CHAR_getWorkInt( charaindex, CHAR_WORKGETEXP) + dpadd ); + } + + return 0; +} + +//#define RS_LIST_MAX 4 // 凛卞窒谛爵 瑛绊霜月井 +#define RS_LIST_MAX 5 +typedef struct{ + int num; + int exp; + int levelup; +}RS_LIST; + +int BATTLE_GetDuelPoint( + int battleindex, // 爵 奶件犯永弁旦 + int side, // 扔奶玉 ㄟ ㄠ + int num // 愤坌反 及窒 及平乓仿井 +) +{ + char szBuffer[1024]=""; + int charaindex; + int dpnow, dpadd; + int fd; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + if( BATTLE_CHECKSIDE( side ) == FALSE )return BATTLE_ERR_PARAM; + if( num < 0 || num >= BATTLE_ENTRY_MAX )return BATTLE_ERR_PARAM; + charaindex = BattleArray[battleindex].Side[side].Entry[num].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return BATTLE_ERR_PARAM; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + return 0; + } + if( BattleArray[battleindex].Side[side].type != BATTLE_S_TYPE_PLAYER ){ + return 0; + } + dpadd = CHAR_getWorkInt( charaindex, CHAR_WORKGETEXP ); + if( dpadd == 0 ){ + dpadd = 0; // 仇及桦宁反ㄟ + }else + if( dpadd < 0 ){ + dpadd = min( -1, dpadd ); // 剂卅仁午手ㄠ反手日丹 + }else{ + dpadd = max( 1, dpadd ); // 剂卅仁午手ㄠ反手日丹 + } + dpnow = CHAR_getInt( charaindex, CHAR_DUELPOINT ) + dpadd; + dpnow = max( dpnow, 0 ); + + CHAR_setInt( charaindex, CHAR_DUELPOINT, min( dpnow, CHAR_MAXDUELPOINT ) ); + + szBuffer[0] = 0; + { + char szAdd[64], szNow[64]; + cnv10to62( dpadd, szAdd, sizeof( szAdd ) ); + cnv10to62( dpnow, szNow, sizeof( szNow ) ); + snprintf( szBuffer, sizeof( szBuffer ), + "%s|%s|", szAdd, szNow ); + } + + fd = getfdFromCharaIndex( charaindex ); + lssproto_RD_send( fd, szBuffer ); + + CHAR_send_DpDBUpdate( charaindex ); +#ifndef _NET_REDUCESEND + CHAR_send_DpDBUpdate_AddressBook( charaindex, TRUE ); +#endif + return 0; +} + +int BATTLE_GetExpGold( + int battleindex, // 爵 奶件犯永弁旦 + int side, // 扔奶玉 ㄟ ㄠ + int num // 愤坌反 及窒 及平乓仿井 +) +{ + BATTLE_ENTRY *pEntryChara; + char szBuffer[1024]="", szItemString[512], szEscItemString[256]; + int charaindex, UpLevel, petindex, i, j, itemindex = -1; + int rsCnt = 0; + RS_LIST aRsList[RS_LIST_MAX]; + int itemgroup[CHAR_MAXITEMHAVE-CHAR_STARTITEMARRAY]; + int itemnum = 0; + memset( aRsList, 0, sizeof( aRsList ) ); + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + if( BATTLE_CHECKSIDE( side ) == FALSE )return BATTLE_ERR_PARAM; + if( num < 0 || num >= BATTLE_ENTRY_MAX )return BATTLE_ERR_PARAM; + charaindex = BattleArray[battleindex].Side[side].Entry[num].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return BATTLE_ERR_PARAM; + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == TRUE ){ + return 0; + } + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + return 0; + } + if( BattleArray[battleindex].Side[side].type != BATTLE_S_TYPE_PLAYER ){ + return 0; + } + pEntryChara = &BattleArray[battleindex].Side[side].Entry[num]; + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == FALSE ){ +#ifdef _ITEM_ADDEQUIPEXP + BATTLE_GetExp( charaindex , charaindex ); +#else + BATTLE_GetExp( charaindex ); +#endif + if( getBattleDebugMsg( ) != 0 ){ + snprintf( szBuffer, sizeof(szBuffer), + "(%s) 得到 EXP %d", + CHAR_getUseName( charaindex ), + CHAR_getWorkInt( charaindex, CHAR_WORKGETEXP ) + ); + BATTLE_talkToCli( charaindex, szBuffer, CHAR_COLORYELLOW ); + } + + } + UpLevel = CHAR_LevelUpCheck( charaindex , -1); + if( UpLevel > 0 ){ + aRsList[rsCnt].levelup = 1; + }else{ + aRsList[rsCnt].levelup = 0; + } + aRsList[rsCnt].num = -2; + aRsList[rsCnt].exp = CHAR_getWorkInt( charaindex, CHAR_WORKGETEXP ); + rsCnt ++; + if( UpLevel > 0 ){ + int work; + + if( getBattleDebugMsg( ) != 0 ){ + snprintf( szBuffer, sizeof(szBuffer), + "(%s) 升级至 %d", + CHAR_getUseName( charaindex ), + CHAR_getInt( charaindex, CHAR_LV ) + ); + BATTLE_talkToCli( charaindex, szBuffer, CHAR_COLORYELLOW ); + } + CHAR_setInt( charaindex, CHAR_SKILLUPPOINT, + CHAR_getInt( charaindex, CHAR_SKILLUPPOINT) + UpLevel*3 ); + work = CHAR_getInt( charaindex, CHAR_CHARM ); + work += CH_FIX_PLAYERLEVELUP; + CHAR_setInt( charaindex, CHAR_CHARM, min( 100, work ) ); + CHAR_complianceParameter( charaindex ); + CHAR_send_P_StatusString( charaindex , + CHAR_P_STRING_LV|CHAR_P_STRING_NEXTEXP|CHAR_P_STRING_DUELPOINT + ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX ) ); + CHAR_PartyUpdate( charaindex, CHAR_N_STRING_LV ); +#ifndef _NET_REDUCESEND + CHAR_send_DpDBUpdate_AddressBook( charaindex, TRUE ); +#endif + } + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + petindex = CHAR_getCharPet( charaindex, i ); + if( CHAR_CHECKINDEX( petindex ) == FALSE )continue; + if( CHAR_getFlg( petindex, CHAR_ISDIE ) == TRUE )continue; + if( CHAR_getWorkInt( petindex, CHAR_WORKGETEXP ) <= 0 ){ + CHAR_complianceParameter( petindex ); + sprintf( szBuffer, "K%d", i ); + CHAR_sendStatusString( charaindex , szBuffer ); + + continue; + } +#ifdef _ITEM_ADDEQUIPEXP + BATTLE_GetExp( petindex, charaindex ); +#else + BATTLE_GetExp( petindex ); +#endif + if( getBattleDebugMsg( ) != 0 ){ + snprintf( szBuffer, sizeof(szBuffer), + "(%s) 得到 EXP %d", + CHAR_getUseName( petindex ), + CHAR_getWorkInt( petindex, CHAR_WORKGETEXP ) + ); + BATTLE_talkToCli( charaindex, szBuffer, CHAR_COLORYELLOW ); + } + UpLevel = CHAR_LevelUpCheck( petindex , charaindex); + if( UpLevel > 0 ){ + if( getBattleDebugMsg( ) != 0 ){ + snprintf( szBuffer, sizeof(szBuffer), + "(%s) 升级至 %d", + CHAR_getUseName( petindex ), + CHAR_getInt( petindex, CHAR_LV ) + ); + BATTLE_talkToCli( charaindex, szBuffer, CHAR_COLORYELLOW ); + } + for( j = 0; j < UpLevel; j ++ ){ + CHAR_PetLevelUp( petindex ); + CHAR_PetAddVariableAi( petindex, AI_FIX_PETLEVELUP ); + } + aRsList[rsCnt].levelup = 1; + }else{ + aRsList[rsCnt].levelup = 0; + } + aRsList[rsCnt].num = i; + aRsList[rsCnt].exp = CHAR_getWorkInt( petindex, CHAR_WORKGETEXP ); + rsCnt ++; + CHAR_complianceParameter( petindex ); + if( UpLevel > 0 ){ + sprintf( szBuffer, "K%d", i ); + CHAR_sendStatusString( charaindex , szBuffer ); + + } + + } + szItemString[0] = 0; + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == FALSE ){ + for( i = 0; i < GETITEM_MAX; i ++ ){ + int ItemGet = FALSE; + szEscItemString[0] = 0; + itemindex = pEntryChara->getitem[i]; + if( itemindex < 0 ){ + itemindex = -1; + }else + if( CHAR_findEmptyItemBox( charaindex ) >= 0 ){ + int ret; + ret = CHAR_addItemSpecificItemIndex(charaindex,itemindex); + if( 0 <= ret && ret < CHAR_EQUIPPLACENUM ){ + print( "itemget err: 在这里不能取得item(%s)(%d)(%s)\n", + CHAR_getUseName( charaindex ), + ret, + ITEM_getAppropriateName(itemindex) + ); + } + if( !CHAR_CHECKITEMINDEX( charaindex, ret) ){ + ItemGet = FALSE; + }else{ + ItemGet = TRUE; + itemgroup[itemnum] = ret; + itemnum ++; + } + } + if( ItemGet == TRUE ){ + if( getBattleDebugMsg( ) != 0 ){ + snprintf( szBuffer, sizeof(szBuffer), + "拾获(%s)", + ITEM_getAppropriateName(itemindex) ); + BATTLE_talkToCli( charaindex, szBuffer, CHAR_COLORYELLOW ); + } + + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), /* 失奶 丞 寞 */ +#endif + "BattleGet(战斗後所得的道具)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar(itemindex, ITEM_UNIQUECODE),// shan 2001/12/14 + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + makeEscapeString( ITEM_getAppropriateName(itemindex), + szEscItemString, + sizeof( szEscItemString ) ); + strncat( szItemString, szEscItemString, sizeof( szItemString ) ); + pEntryChara->getitem[i] = -1; + }else{ + if( itemindex >= 0 ){ + ITEM_endExistItemsOne(itemindex); + }else{ + } + pEntryChara->getitem[i] = -1; + } + strncat( szItemString, "|", sizeof( szItemString ) ); + + } + } + + szBuffer[0] = 0; + for( i = 0; i < RS_LIST_MAX; i ++ ){ + char szWork[256], sz62[64]; + szWork[0] = 0; + if( aRsList[i].exp > 0 || i == 0 ){ + cnv10to62( aRsList[i].exp, sz62, sizeof( sz62 ) ); + snprintf( szWork, sizeof( szWork ), + "%d|%d|%s", aRsList[i].num, + aRsList[i].levelup, + sz62 + ); + } + strncat( szBuffer, szWork, sizeof( szBuffer ) ); + strncat( szBuffer, ",", sizeof( szBuffer ) ); + } + strncat( szBuffer, szItemString, sizeof( szBuffer ) ); + { + int fd; + fd = getfdFromCharaIndex( charaindex ); + lssproto_RS_send( fd, szBuffer ); + } + if( itemnum > 0 ){ + int inum, ie; + for( inum = 0; inum < itemnum; inum ++ ){ + ie = CHAR_getItemIndex( charaindex, itemgroup[inum] ); + } + CHAR_sendItemData( charaindex, itemgroup, itemnum); + } + return 0; +} + +int BATTLE_GetProfit( int battleindex, int side, int num ) +{ + if( BattleArray[battleindex].dpbattle == 1 ){ + return BATTLE_GetDuelPoint( battleindex, side, num ); + }else{ + return BATTLE_GetExpGold( battleindex, side, num ); + } + +} + +int BATTLE_FinishSet( battleindex ) +{ + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + BattleArray[battleindex].mode = BATTLE_MODE_FINISH; + return 0; +} + +static int BATTLE_Finish( int battleindex ) +{ + BATTLE *pBattle; + BATTLE_ENTRY *pEntry; + int i, charaindex, j; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + if( BattleArray[battleindex].winside == 0 + && BattleArray[battleindex].type == BATTLE_TYPE_P_vs_E + && BattleArray[battleindex].WinFunc != NULL){ + BattleArray[battleindex].WinFunc( battleindex, + BattleArray[battleindex].createindex ); + } + +#ifdef _DEATH_CONTEND + if( BattleArray[battleindex].type == BATTLE_TYPE_P_vs_P && + BattleArray[battleindex].PkFunc != NULL ){ + BattleArray[battleindex].PkFunc( + BattleArray[battleindex].menum, BattleArray[battleindex].tonum, + BattleArray[battleindex].winside, BattleArray[battleindex].battlemap ); // winside 0 menum 1 tonum + } +#endif + +#ifdef DANTAI + if( BattleArray[battleindex].type == BATTLE_TYPE_P_vs_P ){ + BATTLE_DpCalc( battleindex ); + } +#endif + + for( j = 0; j < 2; j ++ ){ + pEntry = BattleArray[battleindex].Side[j].Entry; +#ifdef _PET_TALK + for( i = 0 ; i < BATTLE_ENTRY_MAX ; i ++ ){ +#else + for( i = BATTLE_ENTRY_MAX-1; i >= 0 ; i -- ){ +#endif + charaindex = pEntry[i].charaindex; + + if( CHAR_CHECKINDEX( charaindex ) == FALSE ) + continue; + + BATTLE_GetProfit( battleindex, j, i ); //包括取得经验值 + BATTLE_Exit( charaindex, battleindex ); + } + } + if( BattleArray[battleindex].type == BATTLE_TYPE_WATCH ){ + }else{ + pBattle = BattleArray[battleindex].pNext; + for( ;pBattle; pBattle = pBattle->pNext ){ + if( BATTLE_CHECKADDRESS( pBattle ) == FALSE ){ + fprint( "err:battle address 奇怪(%p)\n", pBattle ); + break; + } + for( i = BATTLE_ENTRY_MAX-1; i >= 0 ; i -- ){ + charaindex = pBattle->Side[0].Entry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + BATTLE_Exit( charaindex, pBattle->battleindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_FINAL ); + } + } + pBattle = BattleArray[battleindex].pNext; + for( ;pBattle; pBattle = pBattle->pNext ){ + if( BATTLE_CHECKADDRESS( pBattle ) == FALSE ){ + fprint( "err:battle address 奇怪(%p)\n", pBattle ); + break; + } + BATTLE_DeleteBattle( pBattle->battleindex ); + } + } + BATTLE_DeleteBattle( battleindex ); + return 0; +} + +int BATTLE_StopSet( battleindex ) +{ + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + BattleArray[battleindex].mode = BATTLE_MODE_STOP; + + return 0; +} + +static int BATTLE_Stop( int battleindex ) +{ + BATTLE_ENTRY *pEntry; + int i, charaindex, j; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + + for( j = 0; j < 2; j ++ ){ + pEntry = BattleArray[battleindex].Side[j].Entry; + for( i = BATTLE_ENTRY_MAX-1; i >= 0 ; i -- ){ + charaindex = pEntry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE ) + continue; + BATTLE_GetProfit( battleindex, j, i ); + BATTLE_Exit( charaindex, battleindex ); + } + } + + BATTLE_DeleteBattle( battleindex ); + return 0; +} + +int BATTLE_DefaultAttacker( int battleindex, int side ) +{ + int i, rnd, cnt; + int CharaTbl[BATTLE_ENTRY_MAX]; + + BATTLE_ENTRY *pEntry; + + pEntry = BattleArray[battleindex].Side[side].Entry; + cnt = 0; + + for( i = 0 ; i < BATTLE_ENTRY_MAX; i ++ ){ + CharaTbl[i] = -1; + if( CHAR_CHECKINDEX( pEntry[i].charaindex ) == FALSE ){ + continue; + } + + if( CHAR_getWorkInt( pEntry[i].charaindex, CHAR_WORKBATTLEMODE ) + == BATTLE_CHARMODE_RESCUE ){ + continue; + } + + if( BATTLE_TargetCheck( battleindex, i + side * SIDE_OFFSET ) == FALSE )continue; + + CharaTbl[cnt] = i + side * SIDE_OFFSET; + cnt ++; + } + + if( cnt == 0 ){ + return -1; + } + + rnd = RAND( 0, cnt-1 ); + return CharaTbl[rnd]; + +} + +#if 0 +//********************************************************* +// +// 衬平乓仿卞爵 戊穴件玉毛 木月 + +static int BATTLE_EnemyCommand( int battleindex, int side ) +// +// 曰袄 BATTLE_ERR +// +//********************************************************* +{ + int i, charaindex; + BATTLE_ENTRY *pEntry; + + // 由仿丢□正民尼永弁 + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + if( BATTLE_CHECKSIDE( side ) == FALSE )return BATTLE_ERR_PARAM; + + // 及扔奶玉隋垫丹 + // 衬平乓仿动陆反 仃月 + if( BattleArray[battleindex].Side[side].type != BATTLE_S_TYPE_ENEMY ) return 0; + + pEntry = BattleArray[battleindex].Side[side].Entry; + + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pEntry[i].charaindex; + // 平乓仿弁正银匀化卅井匀凶日戚尺 + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + // 衬平乓仿元扎卅井匀凶日戚尺 + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEENEMY ){ + continue; + } + // 反仇仇匹檗 午井卞杀元化戊穴件玉毛 尹月互} + // 漆反爵丹及心午允月[ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + // 锹澎反赝癫 + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, BATTLE_DefaultAttacker( battleindex, 0 ) ); + // 戊穴件玉 OK 午仄化云仁 + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + } + + return 0; +} +#endif + +//********************************************************* +// +// 爵 丐月扔奶玉及戏五酸曰皿伊奶乩□卞 毛笛遥 +// +int BATTLE_AddDpAlive( + int battleindex, // 田玄伙奶件犯永弁旦 + int side, // 扔奶玉( 0 or 1 ) + int dp +) +// +// 曰袄“{戏五酸匀化中月皿伊奶乩□及醒 +//{{{{{ 爵 互垫歹木化中卅仃木壬 及袄 +// +//********************************************************* +{ + int i, charaindex; + BATTLE_ENTRY *pEntry; + int cnt = 0; + + // 由仿丢□正民尼永弁 + if( BATTLE_CHECKSIDE( side ) == FALSE )return -BATTLE_ERR_PARAM; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return -BATTLE_ERR_BATTLEINDEX; + + // 巨件玄伉□ + pEntry = BattleArray[battleindex].Side[side].Entry; + + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pEntry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE ) continue; + // 矢永玄反仇及端楮溢卅中 + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ) continue; + // 戏五化中引允[笛遥 + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == FALSE ){ + CHAR_setWorkInt( charaindex, CHAR_WORKGETEXP, + CHAR_getWorkInt( charaindex, CHAR_WORKGETEXP) + dp ); + } + } + + return cnt; +} + +#if 1 +//********************************************************* +// +// 爵 }皿伊奶乩□互戏五酸匀化中月井譬屯月 +// +int BATTLE_CountAlive( + int battleindex, // 田玄伙奶件犯永弁旦 + int side // 扔奶玉( 0 or 1 ) +) +// +// 曰袄“{戏五酸匀化中月皿伊奶乩□及醒 +//{{{{{ 爵 互垫歹木化中卅仃木壬 及袄 +// +//********************************************************* +{ + int i, charaindex; + BATTLE_ENTRY *pEntry; + int cnt = 0; + + // 由仿丢□正民尼永弁 + if( BATTLE_CHECKSIDE( side ) == FALSE )return -BATTLE_ERR_PARAM; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return -BATTLE_ERR_BATTLEINDEX; + + // 巨件玄伉□ + pEntry = BattleArray[battleindex].Side[side].Entry; + + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pEntry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE ) continue; + // 矢永玄反仇及端楮溢卅中 + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ) continue; + // 戏五化中引允[ + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == FALSE ){ + cnt ++; + } + } + + return cnt; +} +#endif + + +//********************************************************* +// +// 爵 }辅爵仄凶化皿伊奶乩□及心互戏五化中月橇谪井毛民尼永弁 +// +int BATTLE_OnlyRescue( + int battleindex, // 田玄伙奶件犯永弁旦 + int side, // 扔奶玉( 0 or 1 ) + int *pOnlyFlg +) +// +// 曰袄“{戏五酸匀化中月皿伊奶乩□及醒 +//{{{{{ 爵 互垫歹木化中卅仃木壬 及袄 +// +//********************************************************* +{ + int i, charaindex; + BATTLE_ENTRY *pEntry; + int cnt = 0, OnlyRescue = 1; + + (*pOnlyFlg) = 0; + + // 由仿丢□正民尼永弁 + if( BATTLE_CHECKSIDE( side ) == FALSE )return -BATTLE_ERR_PARAM; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return -BATTLE_ERR_BATTLEINDEX; + + // 巨件玄伉□ + pEntry = BattleArray[battleindex].Side[side].Entry; + + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pEntry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE ){ + continue; + } + // 矢永玄反仇及端楮溢卅中 + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ) continue; + // 戏五化中引允[ + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == FALSE ){ + cnt ++; + // 戏五化中月支勾反辅爵 井" + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_RESCUE ){ + }else{ + OnlyRescue = 0; + } + } +#ifdef _PETSKILL_LER + if(CHAR_getWorkInt(charaindex,CHAR_WORK_RELIFE) > 0) cnt++; +#endif + } + + // 戏五化中月支勾互中化公中勾反辅爵 分匀凶日 + if( cnt > 0 && OnlyRescue ){ + // 白仿弘毛 化月 + (*pOnlyFlg) = 1; + }else{ + // 切互匀凶日ㄟ卞允月 + (*pOnlyFlg) = 0; + } + + return cnt; +} + +static BOOL BATTLE_TimeOutCheck( int battleindex ) +{ + int i, j, charaindex; + BATTLE *pBattle; + BATTLE_ENTRY *pEntry; + pBattle = &BattleArray[battleindex]; + + if( NowTime.tv_sec > pBattle->timer + BATTLE_TIME_LIMIT ){ + }else{ + return FALSE; + } + //BATTLE_BroadCast( battleindex, "server时间已到。", CHAR_COLORYELLOW ); + for( j = 0; j < 2; j ++ ){ + pEntry = pBattle->Side[j].Entry; + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pEntry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE ) + continue; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ){ + continue; + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) + == BATTLE_CHARMODE_C_WAIT ){ + BATTLE_Exit( charaindex, battleindex ); + CHAR_DischargePartyNoMsg( charaindex ); + CHAR_talkToCli( charaindex, -1, + "时间到,结束战斗。", CHAR_COLORYELLOW ); + BATTLE_CommandSend( charaindex, "BU" ); + } + } + } + + return TRUE; +} + +int BATTLE_WatchWait( int battleindex ) +{ + BATTLE *pBattle; + BOOL commandflg = TRUE; + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + pBattle = &BattleArray[battleindex]; + if( BATTLE_TimeOutCheck( battleindex ) == TRUE ){ + commandflg = TRUE; + } + if( commandflg == FALSE ){ + return 0; + } + pBattle->mode = BATTLE_MODE_WATCHMOVIE; + pBattle->turn ++; + return 0; +} + +int BATTLE_WatchMovie( int battleindex ) +{ + return 0; + +} + +int BATTLE_WatchAfter( int battleindex ) +{ + BattleArray[battleindex].mode = BATTLE_MODE_WATCHPRE; + + return 0; + +} + +int BATTLE_WatchBC( int battleindex ) +{ + return 0; +} + +int BATTLE_WatchPre( int battleindex ) +{ + // 戊穴件玉谨切尺 月凛及域 及 木 + BATTLE_PreWatchWaitSeq( battleindex ); + BattleArray[battleindex].mode = BATTLE_MODE_WATCHWAIT; + return 0; +} + +static int BATTLE_Command( int battleindex ) +{ + BATTLE *pBattle, *pWatchBattle; + BOOL commandflg = TRUE, iFinish = FALSE; + int OnlyRescue[2], i, j, charaindex; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + pBattle = &BattleArray[battleindex]; + + if( BATTLE_CommandWait( battleindex, 0) == FALSE ){ + commandflg = FALSE; + } + if( BATTLE_CommandWait( battleindex, 1) == FALSE ){ + commandflg = FALSE; + } + pWatchBattle = pBattle->pNext; + for( ; pWatchBattle ; pWatchBattle = pWatchBattle->pNext ){ + if( BATTLE_CHECKADDRESS( pWatchBattle ) == FALSE ){ + fprint( "err:观战battle address错误(%p)\n", pWatchBattle ); + break; + } + + if( pWatchBattle->mode == BATTLE_MODE_WATCHBC ){ + + BATTLE_MakeCharaString( battleindex, szAllBattleString, + sizeof(szAllBattleString) ); + BATTLE_BpSendToWatch( pWatchBattle, szAllBattleString ); + + pWatchBattle->mode = BATTLE_MODE_WATCHPRE; + commandflg = FALSE; + + }else if( pWatchBattle->mode != BATTLE_MODE_WATCHMOVIE ){ + commandflg = FALSE; + } + } + if( BATTLE_TimeOutCheck( battleindex ) == TRUE ){ + commandflg = TRUE; + } + if( commandflg == FALSE ){ + return 0; + } +#ifdef _BATTLECOMMAND_TIME + BattleArray[battleindex].PartTime = 0; +#endif + + + pBattle->turn ++;//自己回合数增加 + BATTLE_ai_all( battleindex, 0, 0); + BATTLE_ai_all( battleindex, 1, 0); + BATTLE_Battling( battleindex );//处理战斗 + pBattle->Side[0].flg &= ~BSIDE_FLG_SURPRISE; + pBattle->Side[1].flg &= ~BSIDE_FLG_SURPRISE; + if( BATTLE_OnlyRescue( battleindex, 0, &OnlyRescue[0] ) == 0 ){ + pBattle->winside = 1; + iFinish = TRUE; + }else + if( BATTLE_OnlyRescue( battleindex, 1, &OnlyRescue[1] ) == 0 ){ + pBattle->winside = 0; + iFinish = TRUE; + } + for( j = 0; j < 2; j ++ ){ + if( OnlyRescue[j] != 1 )continue; + for( i = 0; i < BATTLE_ENTRY_MAX/2; i ++ ){ + charaindex = pBattle->Side[j].Entry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE ) + continue; + if( CHAR_getInt( charaindex, CHAR_HP ) <= 0 ){ + BATTLE_Exit( charaindex, battleindex ); + } + } + } + BATTLE_PreCommandSeq( battleindex ); + if( iFinish == TRUE ){ + BATTLE_FinishSet( battleindex ); + } + return 0; +} + +#ifdef _CHECK_BATTLE_IO +extern int InBattleLoop; +extern int battle_write; +extern int other_write; +extern int battle_write_cnt; +extern int other_write_cnt; +#endif + +extern void BATTLE_changeRideImage( int index ); + +int BATTLE_Loop( void ) +{ + int i, cnt = 0; + +#ifdef _CHECK_BATTLE_IO + InBattleLoop = TRUE; +#endif + + rand(); + for( i = 0; i < BATTLE_battlenum; i ++ ){//最多战斗场数 + if( BattleArray[i].use == FALSE )continue; + if( BattleArray[i].type == BATTLE_TYPE_WATCH ){//若是观战模式 + if( BATTLE_CountAlive( i, 0 ) == 0 ){ + BATTLE_FinishSet( i ); + } + } + + switch( BattleArray[i].mode ){ + case BATTLE_MODE_NONE://未战斗 + break; + case BATTLE_MODE_INIT://战斗初始化 + BATTLE_Init( i ); + break; + case BATTLE_MODE_BATTLE://Server内部战斗中 + BATTLE_Command( i ); + break; + case BATTLE_MODE_FINISH://战斗结束 + BATTLE_Finish( i ); + break; + case BATTLE_MODE_STOP://战斗中断 + BATTLE_Stop( i ); + break; + case BATTLE_MODE_WATCHBC://观战中... + BATTLE_WatchBC( i ); + break; + + case BATTLE_MODE_WATCHPRE: + BATTLE_WatchPre( i ); + break; + case BATTLE_MODE_WATCHWAIT: + BATTLE_WatchWait( i ); + break; + + case BATTLE_MODE_WATCHMOVIE: + BATTLE_WatchMovie( i ); + break; + + case BATTLE_MODE_WATCHAFTER: + BATTLE_WatchAfter( i ); + break; + } + cnt ++; + } + +#ifdef _CHECK_BATTLE_IO + InBattleLoop = FALSE; +#endif + + return cnt; +} + + + + + +typedef struct { + int charaindex; // 平乓仿弁正奶件犯永弁旦 + int side; // 扔奶玉 + int dex; // 豳镀今 + int num; // 巨件玄伉□ 寞 + int combo; // 宁 猾允月谛棉井" +#ifdef _EQUIT_SEQUENCE + int sequence; +#endif +}BATTLE_CHARLIST; + + +typedef int (*FUNC)( const void *, const void * ); + +//************************************************************ +// +// 爵 及豳镀今 胜楮醒 +// +// 豳镀今反袄互 五中 互穸木化中月[嫦赐末□玄匹丐月[ +// +static int EsCmp( + const BATTLE_CHARLIST *pC1, + const BATTLE_CHARLIST *pC2 +) +{ +#ifdef _EQUIT_SEQUENCE + return( (pC2->dex+pC2->sequence) - (pC1->dex+pC1->sequence) ); +#else + return( pC2->dex - pC1->dex ); +#endif +} + +#ifdef _EQUIT_SEQUENCE +void Replacement_Entry( BATTLE_CHARLIST *temp1, BATTLE_CHARLIST *temp2) +{ + temp1->charaindex = temp2->charaindex; + temp1->combo = temp2->combo; + temp1->dex = temp2->dex; + temp1->num = temp2->num; + temp1->sequence = temp2->sequence; + temp1->side = temp2->side; +} +#endif +static void EntrySort( BATTLE_CHARLIST *EntryList, int listsize) +{ +#ifdef _EQUIT_SEQUENCE +// int i, j; + qsort( EntryList, listsize, sizeof( BATTLE_CHARLIST ), (FUNC)EsCmp ); +/* + for( i=0; i 0 ){ + int maxcheck, now; + BATTLE_CHARLIST temp; + + maxcheck = EntryList[i].sequence/8; + maxcheck = RAND( 1, maxcheck); + maxcheck = ( maxcheck>=i )?(i/3):maxcheck; + maxcheck = ( maxcheck<0)?0:maxcheck; + now = i; + for( j=0; j0; j++){ + if( EntryList[now].sequence > (EntryList[now-1].sequence *0.9) ){ + + Replacement_Entry( &temp, &EntryList[now]); + Replacement_Entry( &EntryList[now], &EntryList[now-1]); + Replacement_Entry( &EntryList[now-1], &temp); + now = now-1; + + +// temp = &EntryList[now]; +// EntryList[now] = EntryList[now-1]; +// EntryList[now-1] = *temp; +// temp = NULL; + + } + } + } + } +*/ +#else + qsort( EntryList, listsize, sizeof( BATTLE_CHARLIST ), (FUNC)EsCmp ); +#endif +} + + + +//************************************************************ +// +// 豳镀今毛煌遥允月[ +// +static int BATTLE_DexCalc( + int charaindex +) +// +// 曰袄 豳镀今 +// +//************************************************************ +{ + int dex = 0; + int work, COM; + int petindex = BATTLE_getRidePet( charaindex ); + + // 戊穴件玉潸 + COM = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ); + +#ifdef _PETSKILL_BECOMEFOX // 攻击顺序中的敏捷降下20% + if( CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND ) != -1 ){ + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + dex = work *0.8;//敏降20% + } +#endif +#ifdef _PROFESSION_ADDSKILL + if( CHAR_getWorkInt( charaindex, CHAR_WORKFEAR ) > 0 ){ + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + dex = work*0.8;//敏降20% + } +#endif + // 骚橘 猾及桦宁 + switch( COM ){ +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + case BATTLE_COM_S_BLOOD: // 嗜血成性 + case BATTLE_COM_S_BLOOD_WORMS: // 嗜血蛊 + case BATTLE_COM_S_SIGN: // 一针见血 +#endif + +#ifdef _BATTLE_NEWPOWER + case BATTLE_COM_JYUJYUTU: + case BATTLE_COM_S_ATTACK_MAGIC: + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + dex = work - RAND( 0, work * 0.3 ); + break; +#endif + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + case BATTLE_COM_S_FIRE_ENCLOSE: // 火附体 + case BATTLE_COM_S_ICE_ENCLOSE: // 冰附体 + case BATTLE_COM_S_THUNDER_ENCLOSE: // 雷附体 + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + dex = work - RAND( work * 0.3, work * 0.5 ); + break; + case BATTLE_COM_S_VOLCANO_SPRINGS:// 火山泉 + case BATTLE_COM_S_SUMMON_THUNDER: // 召雷术 + case BATTLE_COM_S_ICE_ARROW: // 冰箭术 + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + dex = work - RAND( 0, work * 0.2 ); + break; + case BATTLE_COM_S_CURRENT: // 电流术 + case BATTLE_COM_S_FIRE_BALL:// 火星球 + case BATTLE_COM_S_ICE_CRACK: // 冰爆术 + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + dex = work - RAND( 0, work * 0.5 ); + break; + case BATTLE_COM_S_FIRE_SPEAR:// 火龙枪 + case BATTLE_COM_S_STORM: // 暴风雨 + case BATTLE_COM_S_ICE_MIRROR: // 冰镜术 + case BATTLE_COM_S_ENCLOSE: // 附身术 + case BATTLE_COM_S_TRANSPOSE: // 移形换位 + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + dex = work - RAND( work * 0.2, work * 0.5 ); + break; + + case BATTLE_COM_S_DOOM: // 世界末日 + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + dex = work - RAND( 0.3, work * 0.6 ); + break; +#endif + +#ifdef _SKILL_SPEEDY_ATT //vincent 宠技:疾速攻击 + case BATTLE_COM_S_SPEEDYATTACK: + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + dex = work + work*0.3;//敏加30% + break; +#endif +#ifdef _PETSKILL_DAMAGETOHP //宠技:暗月狂狼(嗜血技的变体) + case BATTLE_COM_S_DAMAGETOHP2: + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + dex = work + work*0.2;//敏加20% + break; +#endif + + case BATTLE_COM_ITEM: // 失奶 丞毛银丹桦宁 + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + dex = work - RAND( 0, work * 0.3 ) + work * 0.15; + break; + default: // 骚橘 爵丹卅升) + // Robin 0727 ride pet + if( petindex == -1 ) + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + else + work = BATTLE_adjustRidePet3A( charaindex, petindex, CHAR_WORKQUICK, ATTACKSIDE )+20; + dex = work - RAND( 0, work * 0.3 ); + break; + } + + // 穴奶瓜旦卞卅匀化仄引匀凶日" + if( dex <= 0 )dex = 1; + + return dex; +} + + + + + + +//************************************************************* +// +// 戊件申生□扑亦件互丐月井升丹井民尼永弁 +// +static void ComboCheck( + BATTLE_CHARLIST *pEntryList, + int entrynum +) +// +//************************************************************* +{ + + int i, + charaindex, + com, + enemy, + side, + oldside = -3, // 赝癫卞丐曰尹卅中袄 + oldenemy = -3, // 赝癫卞丐曰尹卅中袄 + armtype, + move, + per, + ComboId = 1, // 戊件示 + start = -1; +#ifdef _ITEM_ADDCOMBO + int j; +#endif + + for( i = 0; i < entrynum; i ++ ){ + + charaindex = pEntryList[i].charaindex; + com = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ); + enemy = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + side = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLESIDE ); + armtype = 0; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ){ + per = 20; // 衬反ㄡㄟ⊙ + }else{ + per = 50; // 愤坌反ㄤㄟ⊙ +#ifdef _ITEM_ADDCOMBO + for( j = 0 ; j < CHAR_EQUIPPLACENUM ; j ++ ){ + int id = CHAR_getItemIndex(charaindex,j);//道具id + if( ITEM_CHECKINDEX(id) ){ + char *arg; + arg = ITEM_getChar(id, ITEM_ARGUMENT );//道具参数 + if( strstr( arg, "合击" ) ){ + int k,battleindex,lr; + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX );//战场编号 + lr = BATTLE_Index2No( battleindex, charaindex );//所站位置 + for( k = 0; k < entrynum; k ++ ){//战场上所有人回圈 + if( BATTLE_TargetCheck(battleindex, pEntryList[k].charaindex ) ){//活着 + if( ( lr < 10 + && BATTLE_Index2No( battleindex, pEntryList[k].charaindex ) < 10 ) + || ( lr >= 10 + && BATTLE_Index2No( battleindex, pEntryList[k].charaindex ) >= 10 ) ){//同一队 + int l; + for( l = 0 ; l < CHAR_EQUIPPLACENUM ; l ++ ){ + int lid = CHAR_getItemIndex(charaindex,l);//道具id + if( ITEM_CHECKINDEX(lid) ){ + arg = ITEM_getChar(lid, ITEM_ARGUMENT );//道具参数 + if( strstr( arg, "合击" ) ){//同一队有2个人以上有载此道具 + int add=0; + sscanf( arg+4, "%d", &add );//取得追加的%数 + per += add; + break; + } + } + } + } + } + } + break; + } + } + } +#endif + } + + // 互ㄟ井 仃卅井匀凶日 + if( CHAR_getInt( charaindex, CHAR_HP ) <= 0 + || BATTLE_CanMoveCheck( charaindex ) == FALSE + ){ + move = 0; + }else{ + move = 1; + } + + // 猾础及 湛毛潸 [髑仆烟卅日母丢 + // 髑仆烟卅日母丢 + if( BATTLE_IsThrowWepon( + CHAR_getItemIndex( charaindex, CHAR_ARM ) ) == TRUE + ){ + armtype = 1; + } + + pEntryList[i].combo = 0; // 赓渝祭 + + if( start != -1 ){ // 宁 猾 + if( com != BATTLE_COM_ATTACK // 猾戊穴件玉匹卅中 + || enemy != oldenemy // 谎匀化月衬互 元匹卅中 + || side != oldside // 扔奶玉互啜丹 + || armtype == 1 // 髑仆烟匹丐月 + || move == 0 // 仃卅中 + ){ + start = -1; // 蔽 + oldside = side; // 扔奶玉创尹月 + }else{ + // 戊件示涩烂 + CHAR_setWorkInt( pEntryList[i].charaindex, + CHAR_WORKBATTLECOM1,BATTLE_COM_COMBO ); + pEntryList[i].combo = ComboId; + // 赓及谛手域杀涩烂 + CHAR_setWorkInt( pEntryList[start].charaindex, + CHAR_WORKBATTLECOM1,BATTLE_COM_COMBO ); + pEntryList[start].combo = ComboId; + } + } + if( start == -1 ){// 宁 猾 仄化中卅中桦宁 + if( com == BATTLE_COM_ATTACK + && armtype != 1 // 髑仆烟匹卅中 + && move == 1 // 仃月 + && RAND( 1, 100 ) <= per + ){ // 骚橘 猾 匹丐月 + start = i; + oldenemy = enemy; // 谎匀化月衬毛创尹月 + oldside = side; // 扔奶玉创尹月 + ComboId ++; + } + } + + } + +} + +//************************************************************* +// +// 戊件申生□扑亦件互 癫卞匹五月井民尼永弁 +//{戚及谛互戊件示匹五月橇谪元扎卅井匀凶日 FALSE +// +static BOOL ComboCheck2( + BATTLE_CHARLIST *pEntryList, // 巨件玄伉□伉旦玄 + int nownum, // 蜇箕及赐 + int entrynum // 巨件玄伉□ 醒 +) +// +// 戊件示匹五月 TRUE +// 匹五卅中 FALSE +// +//************************************************************* +{ + + int i, + iRet = FALSE, + ComboId, + charaindex; + + // 戊件示 忡绣 + ComboId = pEntryList[nownum].combo; + + charaindex = pEntryList[nownum].charaindex; + + // 愤坌互镝擦蘸撩 仄化中凶日撩 + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEFLG) & CHAR_BATTLEFLG_AIBAD ) + { +// print( "由於忠诚度不足使用必杀技失败( %s )\n",CHAR_getUseName( charaindex ) ); + return FALSE; + } + + // 戚及谛互戊件示卞辅笛匹五月井割 + for( i = nownum+1; i < entrynum; i ++ ){ + charaindex = pEntryList[i].charaindex; + + // 戊件示 啜丹午镀仁手撩 + if( ComboId != pEntryList[i].combo )break; + + // 爵 卞辅笛仄化中卅井匀凶日戚尺 + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) == 0 ) break; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_FINAL ) break; + + if( CHAR_getInt( charaindex, CHAR_HP ) <= 0 + || BATTLE_CanMoveCheck( charaindex ) == FALSE + ){ + }else{ + iRet = TRUE; + break; + } + } +/* + if( iRet == FALSE ){ + print( "必杀技失败( %s )\n", + CHAR_getUseName( pEntryList[nownum].charaindex ) ); + } +*/ + return iRet; + +} + + +void BATTLE_UltimateExtra( + int battleindex, + int charaindex, + int enemyindex +) +{ + char szBuffer[256]=""; + int pindex, pno; +#ifndef _DEATH_CONTEND + int floor=0, x=0, y=0; +#endif + szBuffer[0] = 0; + + if( CHAR_getInt( enemyindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + BATTLE_PetDefaultExit( enemyindex, battleindex ); + + if( BattleArray[battleindex].type != BATTLE_TYPE_P_vs_P ){ + int levelflg = 1; + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)被击飞至远方。", + // CHAR_getUseName( enemyindex ) ); + if( CHAR_getInt( enemyindex, CHAR_LV ) <= 10 ){ + levelflg = 2; + } + + if( BattleArray[battleindex].norisk == 0 ){; + CHAR_AddCharm( enemyindex, CH_FIX_PLAYEULTIMATE/levelflg ); + pno = CHAR_getInt( enemyindex, CHAR_DEFAULTPET ); + if( 0 <= pno && pno < CHAR_MAXPETHAVE ){ + pindex = CHAR_getCharPet( enemyindex, pno ); + if( CHAR_CHECKINDEX( pindex ) == TRUE ){ + CHAR_PetAddVariableAi( pindex, AI_FIX_PLAYERULTIMATE/levelflg ); + } + } + } +#ifdef _DEATH_CONTEND + CHAR_warpToSpecificPoint( enemyindex, 8250, 22, 22 ); +#else +#ifdef _BAD_PLAYER // WON ADD 送坏玩家去关 + if( NPC_EventCheckFlg( enemyindex, 135 ) ){ + CHAR_warpToSpecificPoint( enemyindex, 887, 56, 14 ); + }else{ +#endif + if( CHAR_getElderPosition( + CHAR_getInt( enemyindex, CHAR_LASTTALKELDER), &floor, &x, &y ) + != TRUE + ){ + }else{ + CHAR_warpToSpecificPoint( enemyindex, floor, x, y ); + } +#ifdef _BAD_PLAYER + } +#endif +#endif + } + BATTLE_Exit( enemyindex, battleindex ); + CHAR_DischargePartyNoMsg( enemyindex ); + if( getBattleDebugMsg( ) != 0 ){ + BATTLE_talkToCli( enemyindex, szBuffer, CHAR_COLORYELLOW ); + } + + }else + // 矢永玄卅日 + if( CHAR_getInt( enemyindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + int levelflg = 1; + int playerindex = CHAR_getWorkInt( enemyindex, CHAR_WORKPLAYERINDEX ); + + // 伊矛伙互斓中桦宁反 蛹月 坌 + if( CHAR_getInt( playerindex, CHAR_LV ) <= 10 ){ + levelflg = 2; + } + + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)被击飞。", + // CHAR_getUseName( enemyindex ) ); + + // 潜谛及犯白巧伙玄井日反内允 + CHAR_setInt( playerindex, CHAR_DEFAULTPET, -1 ); + + // 犯亘巨伙动陆反镝擦艘毛票仆月 + if( BattleArray[battleindex].type != BATTLE_TYPE_P_vs_P ){ + // 伉旦弁及 中田玄伙井"丐月卅日镝擦 毛票仆月 + if( BattleArray[battleindex].norisk == 0 ){; + CHAR_PetAddVariableAi( enemyindex, AI_FIX_PETULTIMATE/levelflg ); + } + // 潜谛及矢永玄韶氏分荚醒毛市它件玄允月 + CHAR_setInt( playerindex, CHAR_DEADPETCOUNT, + CHAR_getInt( playerindex, CHAR_DEADPETCOUNT ) + 1 ); + } +/* + // 矢永玄互中凶日爵 井日厄仃今六月[ + BATTLE_PetDefaultExit( enemyindex, battleindex ); +*/ + + // 愤坌手 仃月 + BATTLE_Exit( enemyindex, battleindex ); + + }else{ + int flg; + // 公木动陆匹失伙 奴丢永玄韶 + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)被击飞。", + // CHAR_getUseName( enemyindex ) ); + // 衬平乓仿反扔□田□卞酸仄化云仁 +// BATTLE_Exit( enemyindex, battleindex ); + flg = CHAR_getWorkInt( enemyindex, CHAR_WORKBATTLEFLG ); + flg |= CHAR_BATTLEFLG_ULTIMATE; // 失伙 奴丢永玄熬仃凶 + CHAR_setWorkInt( enemyindex, CHAR_WORKBATTLEFLG, flg ); + BATTLE_Exit( enemyindex, battleindex ); + } + + // 须 煤 + //BATTLE_BroadCast( battleindex, szBuffer, CHAR_COLORYELLOW ); + +} + + +//************************************************************* +// +// 骚橘卞竣濮今六凶桦宁及 溃质 +// +void BATTLE_NormalDeadExtra( + int battleindex, // 爵 奶件犯永弁旦 + int charaindex, // 诮仄凶平乓仿及奶件犯永弁旦 + int enemyindex // 诮今木凶平乓仿及奶件犯永弁旦 +) +// +// +//************************************************************* +{ + int pindex, pno; + char szBuffer[256]=""; + + szBuffer[0] = 0; + + // 皿伊奶乩□匹 + // 衬午及爵 分匀凶日 + // 伉旦弁及 中田玄伙卅日 + if( CHAR_getInt( enemyindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER + && BattleArray[battleindex].type == BATTLE_TYPE_P_vs_E + && BattleArray[battleindex].norisk == 0 + ){ + int levelflg = 1; + // 愤坌及 毛票仆月 + // 伊矛伙ㄠㄟ动票及谛反 坌分仃票互月 + if( CHAR_getInt( enemyindex, CHAR_LV ) <= 10 ){ + levelflg = 2; + } + CHAR_AddCharm( enemyindex, CH_FIX_PLAYERDEAD/levelflg ); + // 爵 卞辅笛仄化中凶矢永玄及 毛票仆月 + pno = CHAR_getInt( enemyindex, CHAR_DEFAULTPET ); + if( 0 <= pno && pno < CHAR_MAXPETHAVE ){ + // 矢永玄及奶件犯永弁旦 + pindex = CHAR_getCharPet( enemyindex, pno ); + if( CHAR_CHECKINDEX( pindex ) == TRUE ){ + CHAR_PetAddVariableAi( pindex, AI_FIX_PLAYERDEAD/levelflg ); + } + } + // 韶氏分平乓仿及戊穴件玉反侉木月 + CHAR_setWorkInt( enemyindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + }else + // 矢永玄卅日 + if( CHAR_getInt( enemyindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET + && BattleArray[battleindex].type == BATTLE_TYPE_P_vs_E + && BattleArray[battleindex].norisk == 0 + ){ + int levelflg = 1; + int playerindex = CHAR_getWorkInt( enemyindex, CHAR_WORKPLAYERINDEX ); + + // 潜谛及伊矛伙ㄠㄟ动票及谛反 坌分仃票互月 + if( CHAR_getInt( playerindex, CHAR_LV ) <= 10 ){ + levelflg = 2; + } + // 愤坌及镝擦艘毛票仆月 + CHAR_PetAddVariableAi( enemyindex, AI_FIX_PETDEAD/levelflg ); + // 潜谛及矢永玄韶氏分荚醒毛市它件玄允月 + CHAR_setInt( playerindex, CHAR_DEADPETCOUNT, + CHAR_getInt( playerindex, CHAR_DEADPETCOUNT ) + 1 ); + + // 韶氏分平乓仿及戊穴件玉反侉木月 + CHAR_setWorkInt( enemyindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + + }else{ + // 公木动陆 + } + + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)失去意识。", + // CHAR_getUseName( enemyindex ) ); + + //BATTLE_BroadCast( battleindex, szBuffer, CHAR_COLORYELLOW ); + +} + +#ifndef DANTAI +void BATTLE_EscapeDpSend( int battleindex, int charaindex ) +{ + + int enemyside, cnt, dpadd; + BATTLE_ENTRY *pEntry; + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE ){ + return; + } + + if( BattleArray[battleindex].type != BATTLE_TYPE_P_vs_P ){ + return; + } + if( BattleArray[battleindex].flg & BATTLE_FLG_FREEDP ){ + CHAR_setWorkInt( charaindex, CHAR_WORKGETEXP, 0 ); + return ; + } + BattleArray[battleindex].flg |= BATTLE_FLG_CHARALOST; + enemyside = 1 - CHAR_getWorkInt( charaindex, CHAR_WORKBATTLESIDE ); + pEntry = BattleArray[battleindex].Side[enemyside].Entry; + cnt = BATTLE_CountAlive( battleindex, enemyside ); + if( cnt == 0 )return; + dpadd = CHAR_getInt( charaindex, CHAR_DUELPOINT ) * DUELPOINT_RATE; + if( dpadd < 1 )dpadd = 1; + CHAR_setWorkInt( charaindex, CHAR_WORKGETEXP, -dpadd*2 ); + dpadd /= cnt; + if( dpadd < 1 )dpadd = 1; + BATTLE_AddDpAlive( battleindex, enemyside, dpadd ); +} +#else +void BATTLE_EscapeDpSend( int battleindex, int charaindex ) +{ + + int enemyside, dpadd; + BATTLE_ENTRY *pEntry; + + // Nuke 0725: Avoid too large number + if ((battleindex<0)||(battleindex>getBattlenum())) return; + // 动陆反 仃月 + if( BattleArray[battleindex].type != BATTLE_TYPE_P_vs_P ){ + return; + } + + // 锹澎扔奶玉 + enemyside = 1 - CHAR_getWorkInt( charaindex, CHAR_WORKBATTLESIDE ); + + pEntry = BattleArray[battleindex].Side[enemyside].Entry; + + // 锹澎础卞中月谛醒毛醒尹月 + dpadd = CHAR_getInt( charaindex, CHAR_DUELPOINT ) * DUELPOINT_RATE; + if( dpadd < 1 )dpadd = 1; // 斓匹手ㄠ + + // 谛井日娄中化云仁 + CHAR_setWorkInt( charaindex, CHAR_WORKGETEXP, -dpadd*2 ); + + // 锹澎础卞反箫允 + BattleArray[battleindex].Side[enemyside].common_dp += dpadd; + + +} +#endif + + +#ifndef DANTAI +int BATTLE_AddDuelPoint( int battleindex, int *pBidList ) +{ + int enemyindex, i, side, num, j, k, + charaindex[BATTLE_ENTRY_MAX+1]; + BATTLE_ENTRY + *pEntryEnemy; + int allnum = 0; + int bid = pBidList[0]; + + if( pBidList < 0 )return BATTLE_ERR_PARAM; + if( bid >= SIDE_OFFSET ){ + num = bid - SIDE_OFFSET; + side = 1; + }else{ + num = bid ; + side = 0; + } + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + if( BATTLE_CHECKSIDE( side ) == FALSE )return BATTLE_ERR_PARAM; + if( num < 0 || num >= BATTLE_ENTRY_MAX )return BATTLE_ERR_PARAM; + + for( i = 0; i < BATTLE_ENTRY_MAX + 1 ; i ++ ){ + charaindex[i] = -1; + } + + for( i = 0; i < BATTLE_ENTRY_MAX && pBidList[i] != -1 ; i ++ ){ + int work; + work = BATTLE_No2Index( battleindex, pBidList[i] ); + if( work < 0 )return BATTLE_ERR_PARAM; + if( CHAR_getInt( work, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ){ + continue; + } + if( CHAR_getInt( work, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + work = CHAR_getWorkInt( work, CHAR_WORKPLAYERINDEX ); + } + if( work < 0 )return BATTLE_ERR_PARAM; + for( k = 0; k < allnum; k ++ ){ + if( charaindex[i] == work )break; + } + if( i < allnum )continue; + charaindex[i] = work; + allnum ++; + } + charaindex[i] = -1; + + for( j = 0; j < 2; j ++ ){ + pEntryEnemy = BattleArray[battleindex].Side[j].Entry; + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + int enemytype = 0; + enemyindex = pEntryEnemy[i].charaindex; + if( CHAR_CHECKINDEX( enemyindex ) == FALSE )continue; + if( CHAR_getInt( enemyindex, CHAR_HP ) <= 0 + && CHAR_getFlg( enemyindex, CHAR_ISDIE ) == FALSE){ + }else{ + continue; + } + enemytype = CHAR_getInt( enemyindex, CHAR_WHICHTYPE ); + if( enemytype == CHAR_TYPEPLAYER ){ + BattleArray[battleindex].flg |= BATTLE_FLG_CHARALOST; + } + if( enemytype == CHAR_TYPEPLAYER || enemytype == CHAR_TYPEENEMY ){ + int dpadd, dpnow; + dpnow = CHAR_getInt( enemyindex, CHAR_DUELPOINT ); + dpadd = dpnow * DUELPOINT_RATE; + dpnow -= dpadd; + CHAR_setWorkInt( enemyindex, CHAR_WORKGETEXP, + CHAR_getWorkInt( enemyindex, CHAR_WORKGETEXP) - dpadd ); + + if( side != j ){ + for( k = 0; charaindex[k] != -1; k ++ ); + if( k <= 0 )k = 1; + dpadd /= k; + if( dpadd <= 0 ) dpadd = 1; + for( k = 0; charaindex[k] != -1; k ++ ){ + CHAR_setWorkInt( charaindex[k], CHAR_WORKGETEXP, + CHAR_getWorkInt( charaindex[k], CHAR_WORKGETEXP ) + dpadd ); + } + }else{ + int dpdiv = dpadd, alive; + alive = BATTLE_CountAlive( battleindex, 1-j ); + if( alive <= 0 )alive = 1; + dpdiv /= alive; + if( dpdiv <= 0 )dpdiv = 1; + BATTLE_AddDpAlive( battleindex, 1-j, dpdiv ); + } + } + CHAR_setFlg( enemyindex, CHAR_ISDIE, 1 ); + CHAR_setInt( enemyindex, CHAR_DEADCOUNT, + CHAR_getInt( enemyindex, CHAR_DEADCOUNT ) + 1 ); + + if( pEntryEnemy[i].flg & BENT_FLG_ULTIMATE ){ + BATTLE_GetProfit( battleindex, j, i ); + BATTLE_UltimateExtra( battleindex, charaindex[0], enemyindex ); + }else{ + BATTLE_NormalDeadExtra( battleindex, charaindex[0], enemyindex ); + } + } + } + return 0; +} +#else + +int BATTLE_AddDuelPoint( + int battleindex, + int *pBidList ) +{ + int enemyindex, i, otherside, j, + charaindex[BATTLE_ENTRY_MAX+1]; + BATTLE_ENTRY + *pEntryEnemy; + if( pBidList < 0 )return BATTLE_ERR_PARAM; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + for( j = 0; j < 2; j ++ ){ + pEntryEnemy = BattleArray[battleindex].Side[j].Entry; + otherside = 1 - j; + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + enemyindex = pEntryEnemy[i].charaindex; + if( CHAR_CHECKINDEX( enemyindex ) == FALSE )continue; + if( CHAR_getInt( enemyindex, CHAR_HP ) <= 0 + && CHAR_getFlg( enemyindex, CHAR_ISDIE ) == FALSE){ + }else{ + continue; + } + + CHAR_setFlg( enemyindex, CHAR_ISDIE, 1 ); + CHAR_setInt( enemyindex, CHAR_DEADCOUNT, + CHAR_getInt( enemyindex, CHAR_DEADCOUNT ) + 1 ); + if( pEntryEnemy[i].flg & BENT_FLG_ULTIMATE ){ + if( CHAR_getInt( enemyindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + int dpadd, dpnow; + dpnow = CHAR_getInt( enemyindex, CHAR_DUELPOINT ); + dpadd = dpnow * DUELPOINT_RATE; // ㄠㄟ坌及ㄠ手日尹月 + dpnow -= dpadd; + CHAR_setWorkInt( enemyindex, CHAR_WORKGETEXP, + CHAR_getWorkInt( enemyindex, CHAR_WORKGETEXP) - dpadd ); + BattleArray[battleindex].Side[otherside].common_dp += dpadd; + BATTLE_GetProfit( battleindex, j, i ); + } + BATTLE_UltimateExtra( battleindex, charaindex[0], enemyindex ); + }else{ + BATTLE_NormalDeadExtra( battleindex, charaindex[0], enemyindex ); + } + } + } + return 0; +} +#endif + +int BATTLE_ItemDelCheck( int itemindex ) +{ int icnt, jcnt, playernum; + playernum = getFdnum(); + for( icnt = 0; icnt < playernum; icnt ++ ) { + if( CHAR_CHECKINDEX( icnt ) ) { + for( jcnt = 0; jcnt < CHAR_MAXITEMHAVE; jcnt ++ ) { + if( CHAR_getItemIndex( icnt, jcnt ) == itemindex ) { + print( "err:战利品奇怪的item处理(%s)(%s)index(%d)\n", + CHAR_getUseName(icnt),ITEM_getAppropriateName(itemindex), + itemindex ); + return FALSE; + } + } + } + } + return TRUE; +} + +int BATTLE_AddExpItem( int battleindex, int *pBidList ) +{ + int enemyindex, i, side, num, proflg = 1, j, exp, k, enemylevel, + charaindex[BATTLE_ENTRY_MAX+1]; + BATTLE_ENTRY + *pEntryEnemy, + *pEntryChara[BATTLE_ENTRY_MAX+1], + *pEntryPlayer[BATTLE_ENTRY_MAX+1]; + int item=0,itemindex,itemloop,allnum = 0; + int bid = pBidList[0]; + if( pBidList[0] < 0 )return BATTLE_ERR_PARAM; + if( bid >= SIDE_OFFSET ){ + num = bid - SIDE_OFFSET; + side = 1; + }else{ + num = bid ; + side = 0; + } + if( BATTLE_CHECKSIDE( side ) == FALSE )return BATTLE_ERR_PARAM; + if( num < 0 || num >= BATTLE_ENTRY_MAX )return BATTLE_ERR_PARAM; + for( i = 0; i < BATTLE_ENTRY_MAX + 1 ; i ++ ){ + charaindex[i] = -1; + pEntryPlayer[i] = NULL; + } + if( BattleArray[battleindex].Side[side].type != BATTLE_S_TYPE_PLAYER + || BattleArray[battleindex].Side[1-side].type == BATTLE_S_TYPE_PLAYER){ + proflg = 0; + } + for( i = 0; i < BATTLE_ENTRY_MAX && pBidList[i] != -1 ; i ++ ){ + int subnum; + charaindex[i] = BATTLE_No2Index( battleindex, pBidList[i] ); + if( charaindex[i] < 0 )return BATTLE_ERR_PARAM; + subnum = pBidList[i]-side*SIDE_OFFSET; + pEntryChara[i] = &BattleArray[battleindex].Side[side].Entry[subnum]; + if( CHAR_getInt( charaindex[i], CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + pEntryPlayer[i] = &BattleArray[battleindex].Side[side].Entry[subnum-5]; + }else{ + pEntryPlayer[i] = pEntryChara[i]; + } + } + charaindex[i] = -1; + allnum = i; + for( j = 0; j < 2; j ++ ){ + pEntryEnemy = BattleArray[battleindex].Side[j].Entry; + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + enemyindex = pEntryEnemy[i].charaindex; + if( CHAR_CHECKINDEX( enemyindex ) == FALSE )continue; + + if( CHAR_getInt( enemyindex, CHAR_HP ) <= 0 + && CHAR_getFlg( enemyindex, CHAR_ISDIE ) == FALSE ){ + }else{ + continue; + } + if( proflg == 1 && side != j ){ + if( CHAR_getInt( enemyindex, CHAR_WHICHTYPE ) != CHAR_TYPEENEMY ){ + print( "\nerr: 夺取敌人以外的战利品(%s:%d)\n", + __FILE__, __LINE__ ); + } + for(item=CHAR_STARTITEMARRAY; item < CHAR_STARTITEMARRAY+10; item++){ + itemindex = CHAR_getItemIndex( enemyindex, item ); + if(ITEM_CHECKINDEX( itemindex ) == FALSE ){ + continue; + } + if( ITEM_getWorkInt( itemindex, ITEM_WORKCHARAINDEX ) <= getFdnum() ){ + print( "\nerr: 将玩家的item当做战利品(%s:%d)\n", + __FILE__, __LINE__ ); + continue; + } + CHAR_setItemIndex( enemyindex, item, -1 ); + k = RAND( 0, (allnum-1) ); + for(itemloop=0;itemloop<3;itemloop++){ + if(pEntryPlayer[k]->getitem[itemloop]==-1){ + pEntryPlayer[k]->getitem[itemloop]=itemindex; + break; + } + } + if( itemloop >= 3 ){ + if( RAND( 0, 1 ) ) { + int olditem; + int randwork = RAND( 0, 2 ); + olditem = pEntryPlayer[k]->getitem[randwork]; + pEntryPlayer[k]->getitem[randwork]=itemindex; + if( BATTLE_ItemDelCheck( olditem ) == TRUE ){ + ITEM_endExistItemsOne(olditem); + } + }else { + ITEM_endExistItemsOne(itemindex); + } + } + + } + +#define EXPGET_MAXLEVEL 5 +#define EXPGET_DIV 15 + exp = CHAR_getInt( enemyindex, CHAR_EXP ); + enemylevel = CHAR_getInt( enemyindex, CHAR_LV ); + for( k = 0; charaindex[k] != -1; k ++ ){ + int nowexp, b_level; + int ridepet; + b_level = CHAR_getInt( charaindex[k], CHAR_LV ) - enemylevel; + if( b_level <= EXPGET_MAXLEVEL ){//如 人物大怪物5以下 或怪物大於人物 + nowexp = exp; + }else{//如果人物大於怪物5以上 + b_level = EXPGET_MAXLEVEL+EXPGET_DIV - b_level; + if( b_level > EXPGET_DIV ) b_level = EXPGET_DIV; + if( b_level <= 0 ){ + nowexp = 1; + }else{ + nowexp = exp * b_level / EXPGET_DIV; + } + if( nowexp < 1 ) nowexp = 1; + } + CHAR_setWorkInt( charaindex[k], CHAR_WORKGETEXP, + CHAR_getWorkInt( charaindex[k], CHAR_WORKGETEXP ) + nowexp ); + CHAR_setInt( charaindex[k], CHAR_KILLPETCOUNT, + CHAR_getInt( charaindex[k], CHAR_KILLPETCOUNT ) + 1 ); + ridepet = BATTLE_getRidePet( charaindex[k] ); + //andy_edit + if( CHAR_CHECKINDEX( ridepet) ){ + int nowexp, b_level; + b_level = CHAR_getInt( ridepet, CHAR_LV ) - enemylevel; + if( b_level <= EXPGET_MAXLEVEL ){ + nowexp = exp; + }else{ + b_level = EXPGET_MAXLEVEL+EXPGET_DIV - b_level; + if( b_level > EXPGET_DIV ) b_level = EXPGET_DIV; + if( b_level <= 0 ){ + nowexp = 1; + }else{ + nowexp = exp * b_level / EXPGET_DIV; + } + if( nowexp < 1 ) nowexp = 1; + } + nowexp *= 0.6; + CHAR_setWorkInt( ridepet, CHAR_WORKGETEXP, + CHAR_getWorkInt( ridepet, CHAR_WORKGETEXP ) + nowexp ); + CHAR_setInt( ridepet, CHAR_KILLPETCOUNT, + CHAR_getInt( ridepet, CHAR_KILLPETCOUNT ) + 1 ); + } + if( BattleArray[battleindex].norisk == 0 + && CHAR_getInt( charaindex[k], CHAR_WHICHTYPE ) == CHAR_TYPEPET){ + if( CHAR_getInt( enemyindex, CHAR_LV ) > CHAR_getInt( charaindex[k], CHAR_LV ) ){ + CHAR_PetAddVariableAi( charaindex[k], AI_FIX_PETGOLDWIN ); + }else{ + CHAR_PetAddVariableAi( charaindex[k], AI_FIX_PETWIN ); + } + } + } + CHAR_setMaxExp( enemyindex, 0); + } + CHAR_setFlg( enemyindex, CHAR_ISDIE, 1 ); +#ifdef _PET_LIMITLEVEL + Pet_Check_Die( enemyindex ); +#endif + CHAR_setInt( enemyindex, CHAR_DEADCOUNT, + CHAR_getInt( enemyindex, CHAR_DEADCOUNT ) + 1 ); + if( pEntryEnemy[i].flg & BENT_FLG_ULTIMATE ){ + BATTLE_UltimateExtra( battleindex, charaindex[0], enemyindex ); + }else{ + BATTLE_NormalDeadExtra( battleindex, charaindex[0], enemyindex ); + } + } + } + return 0; +} + +#ifdef _PET_LIMITLEVEL +void Pet_Check_Die( int petindex ) +{ + + int LevelUpPoint; + int vital, str, tgh, dex; + float modai; + +#define RAND(x,y) ((x-1)+1+ (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) ) + //玛宠死亡 扣基本属性及忠诚 + if( CHAR_getInt( petindex, CHAR_PETID) == 718 ) { + LevelUpPoint = CHAR_getInt( petindex, CHAR_ALLOCPOINT ); + vital = (( LevelUpPoint >> 24 ) & 0xff); + str = (( LevelUpPoint >> 16 ) & 0xff); + tgh = (( LevelUpPoint >> 8 ) & 0xff); + dex = (( LevelUpPoint >> 0 ) & 0xff); +// enemyindex = pEntryEnemy[i].charaindex; + + print("\n lvup <<%d %d %d %d>>", vital, str, tgh, dex ); + + vital = vital - RAND( 1, 8); + str = str - RAND( 1, 4); + tgh = tgh - RAND( 1, 4); + dex = dex - RAND( 1, 4); + print("\n lvup <<%d %d %d %d>>", vital, str, tgh, dex ); + + if( vital < 0 ) vital = 0; + if( str < 0 ) str = 0; + if( tgh < 0 ) tgh = 0; + if( dex < 0 ) dex = 0; + + if( vital > 50 ) vital = 50; + if( str > 50 ) str = 50; + if( tgh > 50 ) tgh = 50; + if( dex > 50 ) dex = 50; + LevelUpPoint = ( vital << 24 ) + ( str << 16 ) + ( tgh << 8 ) + ( dex << 0 ); + CHAR_setInt( petindex, CHAR_ALLOCPOINT , LevelUpPoint ); + print("\n lvup <<%d %d %d %d>>", vital, str, tgh, dex ); + modai = CHAR_getInt( petindex, CHAR_MODAI ); + modai = modai - ( (modai * 5) / 100 ); + CHAR_setInt( petindex, CHAR_MODAI, modai); + + LogPetPointChange( + CHAR_getChar( petindex, CHAR_OWNERCHARANAME), + CHAR_getChar( petindex, CHAR_OWNERCDKEY), + CHAR_getChar( petindex, CHAR_NAME), + petindex, 2, + CHAR_getInt( petindex, CHAR_LV), + "battle_die(战斗死亡)", + CHAR_getInt( petindex,CHAR_FLOOR), + 0, + 0 + ); + } + return; + +} +#endif + +int BATTLE_AddProfit( int battleindex, int *pBidList) +{ + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + + if( BattleArray[battleindex].dpbattle == 1 ){ + return BATTLE_AddDuelPoint( battleindex, pBidList ); + }else{ + return BATTLE_AddExpItem( battleindex, pBidList ); + } + +} + +int BATTLE_TargetCheck( + int battleindex, + int defNo +) +{ + int defindex = BATTLE_No2Index( battleindex, defNo ); + + if( CHAR_CHECKINDEX( defindex ) == FALSE + || CHAR_getWorkInt( defindex, CHAR_WORKBATTLEMODE ) == 0 + || CHAR_getFlg( defindex, CHAR_ISDIE ) == TRUE + || CHAR_getInt( defindex, CHAR_HP ) <= 0 + || CHAR_getFlg( defindex, CHAR_ISATTACKED ) == FALSE + || CHAR_getWorkInt( defindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_RESCUE + ){ + return FALSE; + } + return TRUE; +} + +int BATTLE_TargetCheckDead( + int battleindex, + int defNo +) +{ + int defindex = BATTLE_No2Index( battleindex, defNo ); + if( CHAR_CHECKINDEX( defindex ) == FALSE + || CHAR_getWorkInt( defindex, CHAR_WORKBATTLEMODE ) == 0 + || CHAR_getWorkInt( defindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_RESCUE + || CHAR_getFlg( defindex, CHAR_ISATTACKED ) == FALSE + || CHAR_getFlg( defindex, CHAR_ISDIE ) == FALSE ){ + //BATTLE_CHARMODE_RESCUE 5 + print("\n [ %d, %d, %d, %d]", + CHAR_getWorkInt( defindex, CHAR_WORKBATTLEMODE ), + CHAR_getWorkInt( defindex, CHAR_WORKBATTLEMODE ), + CHAR_getFlg( defindex, CHAR_ISATTACKED ), + CHAR_getFlg( defindex, CHAR_ISDIE )); + return FALSE; + } + return TRUE; +} + + + + +int BATTLE_TargetAdjust( int battleindex, int charaindex, int myside ) +{ + int defNo; + + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + + if( BATTLE_TargetCheck( battleindex, defNo ) == FALSE ){ + defNo = BATTLE_DefaultAttacker( battleindex, 1 - myside ); + } + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, defNo ); + + return defNo; +} + +void Compute_Down( int charaindex, int rideindex, int *down1, int *down2, int flg) +{ + int hp=0, pethp=0; + int downs = 0; + + *down1 = 0; + *down2 = 0; + //人物 + downs = + CHAR_getInt( charaindex, CHAR_VITAL ) + + CHAR_getInt( charaindex, CHAR_STR ) + + CHAR_getInt( charaindex, CHAR_DEX ) + + CHAR_getInt( charaindex, CHAR_TOUGH ); + if( (downs = (((downs/100)-20)/4)) < 1 ) + downs = 1; + hp = CHAR_getInt( charaindex, CHAR_HP ); + if( hp <= downs ) downs = hp - 1; + if( downs >= 0 ){ + hp = ((hp-downs)<1)?1:(hp-downs); + CHAR_setInt( charaindex, CHAR_HP, hp ); + *down1 = downs; + } + if( flg == -1 ) { + }else {//骑乘宠物 + if( !CHAR_CHECKINDEX( rideindex)) return; + downs = + CHAR_getInt( rideindex, CHAR_VITAL ) + + CHAR_getInt( rideindex, CHAR_STR ) + + CHAR_getInt( rideindex, CHAR_DEX ) + + CHAR_getInt( rideindex, CHAR_TOUGH ); + if( (downs = (((downs/100)-20)/4)) < 1 ) + downs = 1; + pethp = CHAR_getInt( rideindex, CHAR_HP ); + if( pethp <= downs ) downs = pethp - 1; + if( downs >= 0 ){ + pethp = ((pethp-downs)<1)?1:(pethp-downs); + + CHAR_setInt( rideindex, CHAR_HP, pethp); + *down2 = downs; + } + } +} + +#ifdef _PET_SKILL_SARS // WON ADD 毒煞蔓延 +void Compute_Down_SARS( int charaindex, int rideindex, int *down1, int *down2, int flg) +{ + int hp=0, pethp=0; + int downs = 0; + + *down1 = 0; + *down2 = 0; + //人物 +/* + downs = + CHAR_getInt( charaindex, CHAR_VITAL ) + + CHAR_getInt( charaindex, CHAR_STR ) + + CHAR_getInt( charaindex, CHAR_DEX ) + + CHAR_getInt( charaindex, CHAR_TOUGH ); + if( (downs = (((downs/100)-20)/4)) < 1 ) + downs = 1; +*/ + + hp = CHAR_getInt( charaindex, CHAR_HP ); + downs = hp * 10 / 100; + + if( hp <= downs ) downs = hp - 1; + if( downs >= 0 ){ + hp = ((hp-downs)<1)?1:(hp-downs); + CHAR_setInt( charaindex, CHAR_HP, hp ); + *down1 = downs; + } + if( flg == -1 ) { + }else {//骑乘宠物 + if( !CHAR_CHECKINDEX( rideindex)) return; + downs = + CHAR_getInt( rideindex, CHAR_VITAL ) + + CHAR_getInt( rideindex, CHAR_STR ) + + CHAR_getInt( rideindex, CHAR_DEX ) + + CHAR_getInt( rideindex, CHAR_TOUGH ); + if( (downs = (((downs/100)-20)/4)) < 1 ) + downs = 1; + pethp = CHAR_getInt( rideindex, CHAR_HP ); + if( pethp <= downs ) downs = pethp - 1; + if( downs >= 0 ){ + pethp = ((pethp-downs)<1)?1:(pethp-downs); + + CHAR_setInt( rideindex, CHAR_HP, pethp); + *down2 = downs; + } + } +} +#endif + +#ifdef _PROFESSION_ADDSKILL +void WorkIceCrackPlay(int charaindex, int cnt, int workicecracknum ) +{ + char szBuffer[256]=""; + int i,value=0; + int battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + int defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 );//defNo = BATTLE_Index2No( battleindex, charaindex ); + int ridepet = BATTLE_getRidePet( charaindex ); + int bid = BATTLE_Index2No( battleindex, charaindex ); + value = CHAR_getWorkInt( charaindex, workicecracknum ); + + if( cnt <= 0 && value > 0 ){ + int damage=0, petdamage=0; + + int ToList[SIDE_OFFSET*2+1]; + memset( ToList, -1, sizeof( ToList)); + BATTLE_MultiList( battleindex, TARGET_SIDE_1, ToList ); + // 将魔法参数代入动画 + analysis_profession_parameter( 2, 4, defNo, charaindex ); + PROFESSION_MAGIC_ATTAIC_Effect( battleindex, bid, ToList, 2); + + if( defNo == 20 || defNo == 25 || defNo == 26 )//右 + bid = 0; + else + bid = 10; + + + for( i = bid ; i < bid+10 ; i++ ) { + int defType, charaidx, petidx; + charaidx = BATTLE_No2Index( battleindex , i); + if( CHAR_CHECKINDEX( charaidx ) ){ + if( CHAR_getInt( charaidx, CHAR_HP ) > 0 ){ + int hp,pethp = 0; + petidx = BATTLE_getRidePet( charaidx ); + defType = CHAR_getInt(charaidx, CHAR_WHICHTYPE); + CHAR_setWorkInt( charaidx, workicecracknum, 0 ); + + damage = value; + + hp = CHAR_getInt( charaidx, CHAR_HP ); + if( petidx == -1 ) { + hp -= damage; + if( hp < 0 ) hp = 0; + }else { + int defquick=0, petquick=0, playerdamage=0; + pethp = CHAR_getInt( petidx, CHAR_HP ); + defquick = CHAR_getWorkInt( charaidx, CHAR_WORKDEFENCEPOWER ); + petquick = CHAR_getWorkInt( petidx, CHAR_WORKDEFENCEPOWER ); + if( pethp > 0 ){ + playerdamage = (damage*petquick)/(defquick+petquick) +1; + petdamage = damage - playerdamage +1 ; + hp -= playerdamage; + pethp -= petdamage; + }else{ + hp -= damage; + } + if( hp < 0 ) hp = 0; + if( pethp < 0 ) pethp = 0; + CHAR_setInt( petidx, CHAR_HP, pethp ); + } + + CHAR_setInt( charaidx, CHAR_HP, hp ); + + if( hp <= 0 ){ + CHAR_setFlg( charaidx, CHAR_ISDIE, 1 ); + CHAR_setWorkInt( charaidx, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + if( pethp <= 0 ){ + CHAR_setFlg( petidx, CHAR_ISDIE, 1 ); + CHAR_setWorkInt( ridepet, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + + + if( damage >= 0 ){ + sprintf( szBuffer , "%X|%X|%X|%X|" , i , i ,(int)(damage) , (int)(petdamage)); + BATTLESTR_ADD( szBuffer ); + } + if( petidx != -1 && petdamage >= 0 ){ + + } + } + } + } + sprintf( szBuffer , "%X|" , 0x5711438 ); + BATTLESTR_ADD( szBuffer ); + } +} +#endif + +static int BATTLE_StatusSeq( int charaindex ) +{ + int cnt, i, bid, battleindex, down; + char szBuffer[256]=""; +#ifdef _MAGIC_DEEPPOISON + int defNo,defindex=0; + char szCommand[1024]; +#endif + int ridepet = BATTLE_getRidePet( charaindex ); + int hp=0, pethp=0; + + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + +#ifdef _MAGIC_DEEPPOISON + defNo = BATTLE_Index2No( battleindex, charaindex ); + defindex = BATTLE_No2Index( battleindex, defNo ); +#endif + bid = BATTLE_Index2No( battleindex, charaindex ); + if( BATTLE_CanMoveCheck( charaindex ) == FALSE ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + + for( i = 1; i < BATTLE_ST_END; i++ ){ + if( ( cnt = CHAR_getWorkInt( charaindex, StatusTbl[i] )) <= 0 )continue; + CHAR_setWorkInt( charaindex, StatusTbl[i], --cnt ); +#ifdef _MAGIC_WEAKEN // 虚弱 + if(CHAR_getWorkInt(charaindex,CHAR_WORKWEAKEN) > 0) + CHAR_setWorkInt( charaindex, StatusTbl[i], cnt+1 ); +#endif +#ifdef _MAGIC_BARRIER// vincent 精灵:魔障 + if(CHAR_getWorkInt(charaindex,CHAR_WORKBARRIER) > 0) + CHAR_setWorkInt( charaindex, StatusTbl[i], cnt+1 ); +#endif + + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + if( cnt <= 0 && ( StatusTbl[i] != CHAR_WORKICECRACK ) +#ifdef _PROFESSION_ADDSKILL + && ( StatusTbl[i] != CHAR_WORKICECRACK2 ) + && ( StatusTbl[i] != CHAR_WORKICECRACK3 ) + && ( StatusTbl[i] != CHAR_WORKICECRACK4 ) + && ( StatusTbl[i] != CHAR_WORKICECRACK5 ) + && ( StatusTbl[i] != CHAR_WORKICECRACK6 ) + && ( StatusTbl[i] != CHAR_WORKICECRACK7 ) + && ( StatusTbl[i] != CHAR_WORKICECRACK8 ) + && ( StatusTbl[i] != CHAR_WORKICECRACK9 ) + && ( StatusTbl[i] != CHAR_WORKICECRACK10 ) +#endif + ){ // 冰爆术 +#else + if( cnt <= 0 ){ +#endif + BATTLE_BadStatusString( bid, 0 ); + //snprintf( szBuffer, sizeof( szBuffer ), "(%s)将(%s)修理完毕。", + // CHAR_getUseName( charaindex ), aszStatusFull[i] ); + // BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; +//Terry del +// sprintf( szBuffer, "BM|%X|%X|", bid, 0 ); +// BATTLESTR_ADD( szBuffer ); +#ifdef _MAGIC_NOCAST + if( StatusTbl[i] == CHAR_WORKNOCAST ){ + lssproto_NC_send( getfdFromCharaIndex( charaindex ), 0);//复原 + } +#endif + if( StatusTbl[i] == CHAR_WORKDRUNK ){ + if( ridepet != -1 ){ + CHAR_setWorkInt( charaindex, CHAR_WORKQUICK, + CHAR_getWorkInt( charaindex, CHAR_WORKQUICK ) + + CHAR_getWorkInt( ridepet, CHAR_WORKQUICK ) ); + }else{ + CHAR_setWorkInt( charaindex, CHAR_WORKQUICK, + CHAR_getWorkInt( charaindex, CHAR_WORKQUICK ) * 2 ); + } + } + continue; + } + + switch( StatusTbl[i] ){ + + case CHAR_WORKPOISON: + { + int petdown=-1; + Compute_Down( charaindex, ridepet, &down, &petdown, ridepet); + if( down >= 0 ){ + //snprintf( szBuffer, sizeof( szBuffer ), + // "(%s)因(%s)受到(%d)的损伤。", + // CHAR_getUseName( charaindex ), + // aszStatusFull[i], + // down ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + +#ifdef _NOTRIDE_ + sprintf( szBuffer, "BD|r%X|0|0|%X|", bid, (int)(down) ); + BATTLESTR_ADD( szBuffer ); +#else + sprintf( szBuffer, "BD|r%X|0|0|%X|p%X|", bid, (int)(down), (int)(petdown) ); + BATTLESTR_ADD( szBuffer ); +#endif + } + if( ridepet != -1 && petdown >= 0 ){ + //snprintf( szBuffer, sizeof( szBuffer ), + // "(%s的骑宠)因(%s)受到(%d)的损伤。", + // CHAR_getUseName( charaindex ), + // aszStatusFull[i], petdown ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + } + } + break; +#ifdef _MAGIC_DEEPPOISON + case CHAR_WORKDEEPPOISON: + if(CHAR_getInt( defindex, CHAR_HP ) <= 1){ + snprintf( szCommand, sizeof( szCommand ),"Bd|a%X|r%X|f%X|d%X|p%X|FF|",defNo,defNo,BCF_NORMAL,1, 0 ); + BATTLESTR_ADD( szCommand ); + CHAR_setInt( defindex, CHAR_HP,0); + CHAR_setWorkInt( defindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + CHAR_setFlg( defindex, CHAR_ISDIE, 1 ); + break; + } + + if(CHAR_getWorkInt( defindex, CHAR_WORKDEEPPOISON) <= 1){ + snprintf( szCommand, sizeof( szCommand ),"Bd|a%X|r%X|f%X|d%X|p%X|FF|",defNo,defNo,BCF_NORMAL,CHAR_getInt( charaindex, CHAR_HP), 0 ); + BATTLESTR_ADD( szCommand ); + CHAR_setInt( defindex, CHAR_HP,0); + CHAR_setFlg( defindex, CHAR_ISDIE, 1 ); + CHAR_setWorkInt( defindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + sprintf(szBuffer, "%s身中剧毒未解而阵亡了!!", CHAR_getChar( defindex, CHAR_NAME )); + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + CHAR_talkToCli( CHAR_getWorkInt(defindex, CHAR_WORKPLAYERINDEX), -1, szBuffer, CHAR_COLORYELLOW); + }else{ + CHAR_talkToCli( defindex, -1, szBuffer, CHAR_COLORYELLOW); + } + break; + } + if( ridepet == -1 ){// Robin 0728 ride Pet + down = + CHAR_getInt( charaindex, CHAR_VITAL ) + + CHAR_getInt( charaindex, CHAR_STR ) + + CHAR_getInt( charaindex, CHAR_DEX ) + + CHAR_getInt( charaindex, CHAR_TOUGH ); + down = ( down / 100 - 20 ) / 4; + if( down < 1 ) down = 1; + hp = CHAR_getInt( charaindex, CHAR_HP ); + if( hp <= down ) down = hp - 1; + if( down >= 0 ){ + CHAR_setInt( charaindex, CHAR_HP, hp - down ); + //snprintf( szBuffer, sizeof( szBuffer ), + // "(%s)因(%s)受到(%d)的损伤。", + // CHAR_getUseName( charaindex ), + // aszStatusFull[i], + // down ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; +#ifdef _NOTRIDE_ + sprintf( szBuffer, "BD|r%X|0|0|%X|", bid, (int)(down) ); + BATTLESTR_ADD( szBuffer ); +#else + sprintf( szBuffer, "BD|r%X|0|0|%X|p%X|", bid, (int)(down), 0 ); + BATTLESTR_ADD( szBuffer ); +#endif + } + break; + }else { + int petdown; + down = + CHAR_getInt( charaindex, CHAR_VITAL ) + + CHAR_getInt( charaindex, CHAR_STR ) + + CHAR_getInt( charaindex, CHAR_DEX ) + + CHAR_getInt( charaindex, CHAR_TOUGH ); + petdown = + CHAR_getInt( ridepet, CHAR_VITAL ) + + CHAR_getInt( ridepet, CHAR_STR ) + + CHAR_getInt( ridepet, CHAR_DEX ) + + CHAR_getInt( ridepet, CHAR_TOUGH ); + down = ( down / 100 - 20 ) / 4; + petdown = ( petdown / 100 - 20 ) /4; + if( down < 1 ) down = 1; + if( petdown < 1 ) petdown = 1; + hp = CHAR_getInt( charaindex, CHAR_HP ); + pethp = CHAR_getInt( ridepet, CHAR_HP ); + if( hp <= down ) down = hp - 1; + if( pethp <= petdown ) petdown = pethp - 1; + if( down >= 0 ){ + CHAR_setInt( charaindex, CHAR_HP, hp - down ); + //snprintf( szBuffer, sizeof( szBuffer ), + // "(%s)因(%s)受到(%d)的损伤。", + // CHAR_getUseName( charaindex ), + // aszStatusFull[i], + // down ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + #ifdef _NOTRIDE_ + sprintf( szBuffer, "BD|r%X|0|0|%X|", bid, (int)(down) ); + BATTLESTR_ADD( szBuffer ); + #else + sprintf( szBuffer, "BD|r%X|0|0|%X|p%X|", bid, (int)(down), (int)(petdown) ); + BATTLESTR_ADD( szBuffer ); + #endif + } + if( petdown >= 0 ){ + CHAR_setInt( ridepet, CHAR_HP, pethp - petdown ); + //snprintf( szBuffer, sizeof( szBuffer ), + // "(%s的骑宠)因(%s)受到(%d)的损伤。", + // CHAR_getUseName( charaindex ), + // aszStatusFull[i], + // petdown ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + } + break; + } +#endif +#ifdef _MAGIC_NOCAST // 精灵:沉默 + case CHAR_WORKNOCAST: + lssproto_NC_send( getfdFromCharaIndex( charaindex ), 1);//沉默 + break; +#endif + case CHAR_WORKCONFUSION: + { int side, pos, defNo, lop; + if( RAND( 1, 100 ) > 80 ){ + break; + } + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + side = RAND( 0, 1 ); + pos = RAND( 0, 9 ); + for( lop = 0; lop < SIDE_OFFSET; lop ++ ){ + if( ++pos >= SIDE_OFFSET )pos = 0; + defNo = side * SIDE_OFFSET + pos; + if( defNo == bid ) continue; + if( BATTLE_TargetCheck( battleindex, defNo ) == TRUE ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, defNo ); + break; + } + } + if( lop >= SIDE_OFFSET ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, -1 ); + } + } + break; +#ifdef _PROFESSION_ADDSKILL + case CHAR_WORKANNEX://附身术 + { int side, pos, defNo, lop; + + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + side = RAND( 0, 1 ); + pos = RAND( 0, 9 ); + for( lop = 0; lop < SIDE_OFFSET; lop ++ ){ + if( ++pos >= SIDE_OFFSET )pos = 0; + defNo = side * SIDE_OFFSET + pos; + if( defNo == bid ) continue; + if( BATTLE_TargetCheck( battleindex, defNo ) == TRUE ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, defNo ); + break; + } + } + if( lop >= SIDE_OFFSET ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, -1 ); + } + + } + break; +#endif + case CHAR_WORKDRUNK: + break; + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + case CHAR_WORKOBLIVION: // 遗忘 + { + // 恢复技能 + if( cnt <= 1 ){ + int defNo = BATTLE_Index2No( battleindex, charaindex ); + int toNo = defNo - 5; + int toNoindex = -1, pet_no = -1; + char msg[20]; + + memset( msg, -1, sizeof(msg) ); + + // 主人index + toNoindex = BATTLE_No2Index( battleindex, toNo ); + CHAR_setWorkInt(charaindex, StatusTbl[BATTLE_ST_OBLIVION], 0 ); + + // 宠物编号 + pet_no = CHAR_getInt( toNoindex, CHAR_DEFAULTPET ); + sprintf( msg, "W%d", pet_no ); + + CHAR_sendStatusString( toNoindex, msg ); + + + BATTLE_BadStatusString( bid, 0 ); + sprintf( szBuffer, "BM|%X|%X|", bid, 0 ); + BATTLESTR_ADD( szBuffer ); + } + break; + } + case CHAR_WORK_F_ENCLOSE: // 火附体 + { + int ToList[SIDE_OFFSET*2+1]; + int defNo = BATTLE_Index2No( battleindex, charaindex ); + int old_hp = CHAR_getInt( charaindex, CHAR_HP ); + int dec_hp = 0, hp = 0; + int DAMAGE = 50; + + memset( ToList, -1, sizeof( ToList)); + BATTLE_MultiList( battleindex, defNo, ToList ); + BATTLE_MagicEffect( battleindex, defNo, ToList, 101699, 101699 ); + + // 取魔法伤害值 + DAMAGE = DAMAGE * cnt; +#ifdef _PROFESSION_ADDSKILL + dec_hp = PROFESSION_MAGIC_GET_DAMAGE( charaindex, charaindex, 1, DAMAGE, 0); +#else + dec_hp = PROFESSION_MAGIC_GET_DAMAGE( charaindex, charaindex, 1, DAMAGE ); +#endif + hp = old_hp - dec_hp; + + if( hp <= 0 ){ + CHAR_setInt( charaindex, CHAR_HP, 0 ); + CHAR_setFlg( charaindex, CHAR_ISDIE, 1 ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + }else{ + CHAR_setInt( charaindex, CHAR_HP, hp ); + } + + sprintf( szCommand, "BD|r%X|0|0|%X|", defNo, dec_hp ); + BATTLESTR_ADD( szCommand ); + + break; + } + case CHAR_WORK_I_ENCLOSE: // 冰附体 + { + int old_dex = CHAR_getInt( charaindex, CHAR_DEX ); + int dex = 0; + int ToList[SIDE_OFFSET*2+1]; + int defNo = BATTLE_Index2No( battleindex, charaindex ); + + memset( ToList, -1, sizeof( ToList)); + BATTLE_MultiList( battleindex, defNo, ToList ); + BATTLE_MagicEffect( battleindex, defNo, ToList, 27692, 101700 ); + + dex = old_dex * 0.9; + CHAR_setWorkInt(charaindex,CHAR_WORKFIXDEX, dex ); + sprintf( szCommand, "BD|r%X|0|6|%X|", defNo, (-1) * (int)((old_dex * 0.1) / 100) ); + BATTLESTR_ADD( szCommand ); + + break; + } + case CHAR_WORKRESIST_F: // 火抗性提升 + { + // 恢复抗性 + if( cnt <= 1 ){ + int add_value = 0; + int old_value = 0; + old_value = CHAR_getWorkInt( charaindex, CHAR_WORK_F_RESIST ); + add_value = CHAR_getWorkInt( charaindex, CHAR_WORKMODRESIST_F ); + + CHAR_setWorkInt( charaindex, CHAR_WORK_F_RESIST, old_value - add_value ); + CHAR_talkToCli( charaindex, -1 , "火抗性恢复" , CHAR_COLORYELLOW ); + } + break; + } + case CHAR_WORKRESIST_I: // 冰抗性提升 + { + // 恢复抗性 + if( cnt <= 1 ){ + int add_value = 0; + int old_value = 0; + old_value = CHAR_getWorkInt( charaindex, CHAR_WORK_I_RESIST ); + add_value = CHAR_getWorkInt( charaindex, CHAR_WORKMODRESIST_I ); + + CHAR_setWorkInt( charaindex, CHAR_WORK_I_RESIST, old_value - add_value ); + CHAR_talkToCli( charaindex, -1 , "冰抗性恢复" , CHAR_COLORYELLOW ); + } + + break; + } + case CHAR_WORKRESIST_T: // 雷抗性提升 + { + // 恢复抗性 + if( cnt <= 1 ){ + int add_value = 0; + int old_value = 0; + old_value = CHAR_getWorkInt( charaindex, CHAR_WORK_T_RESIST ); + add_value = CHAR_getWorkInt( charaindex, CHAR_WORKMODRESIST_T ); + + CHAR_setWorkInt( charaindex, CHAR_WORK_T_RESIST, old_value - add_value ); + CHAR_talkToCli( charaindex, -1 , "雷抗性恢复" , CHAR_COLORYELLOW ); + } + + break; + } +#ifdef _PROFESSION_ADDSKILL +/* case CHAR_WORKERSIST_F_I_T: // 提升火冰雷抗性 + { + // 恢复抗性 + if( cnt <= 1 ){ + int add_value = 0; + int old_value = 0; + old_value = CHAR_getWorkInt( charaindex, CHAR_WORK_F_RESIST ); + add_value = CHAR_getWorkInt( charaindex, CHAR_WORKMODRESIST_F ); + CHAR_setWorkInt( charaindex, CHAR_WORK_F_RESIST, old_value - add_value ); + CHAR_talkToCli( charaindex, -1 , "火抗性恢复" , CHAR_COLORYELLOW ); + + old_value = CHAR_getWorkInt( charaindex, CHAR_WORK_I_RESIST ); + add_value = CHAR_getWorkInt( charaindex, CHAR_WORKMODRESIST_I ); + CHAR_setWorkInt( charaindex, CHAR_WORK_I_RESIST, old_value - add_value ); + CHAR_talkToCli( charaindex, -1 , "冰抗性恢复" , CHAR_COLORYELLOW ); + + old_value = CHAR_getWorkInt( charaindex, CHAR_WORK_T_RESIST ); + add_value = CHAR_getWorkInt( charaindex, CHAR_WORKMODRESIST_T ); + CHAR_setWorkInt( charaindex, CHAR_WORK_T_RESIST, old_value - add_value ); + CHAR_talkToCli( charaindex, -1 , "雷抗性恢复" , CHAR_COLORYELLOW ); + } + + break; + }*/ + case CHAR_WORKFEAR: + if( cnt <= 0 ) + CHAR_talkToCli( charaindex, -1 , "攻、防、敏恢复" , CHAR_COLORYELLOW ); + break; +#endif + case CHAR_WORKINSTIGATE: // 挑拨 + { + int side, pos, defNo, lop, rate=0; + if( RAND( 1, 100 ) > 80 ){ + break; + } + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + side = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLESIDE ); + + rate = CHAR_getWorkInt( charaindex, CHAR_WORKMODINSTIGATE); + + CHAR_setWorkInt( charaindex, CHAR_WORKFIXSTR, (CHAR_getWorkInt( charaindex, CHAR_WORKFIXSTR) * (100 - rate) /100 )); + CHAR_setWorkInt( charaindex, CHAR_WORKFIXTOUGH, (CHAR_getWorkInt( charaindex, CHAR_WORKFIXTOUGH) * (100 - rate) /100 )); + CHAR_setWorkInt( charaindex, CHAR_WORKFIXDEX, (CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX) * (100 - rate) /100 )); + + pos = RAND( 0, 9 ); + for( lop = 0; lop < SIDE_OFFSET; lop ++ ){ + if( ++pos >= SIDE_OFFSET )pos = 0; + defNo = side * SIDE_OFFSET + pos; + if( defNo == bid ) continue; + if( BATTLE_TargetCheck( battleindex, defNo ) == TRUE ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, defNo ); + break; + } + } + if( lop >= SIDE_OFFSET ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, -1 ); + } + break; + } +/* + case CHAR_WORK_FOCUS: // 专注战斗 + { + if( cnt <= 1 ){ + int atk_to_index = CHAR_getWorkInt( charaindex, CHAR_WORKMOD_FOCUS ); + int atk_to_no = BATTLE_Index2No( battleindex, atk_to_index ); + + if( BATTLE_TargetCheck( battleindex, atk_to_no ) != TRUE ) break; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, atk_to_no ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, 1 ); + } + break; + } +*/ + case CHAR_WORKSIGN: // 一针见血 + { + // 吸血 + int skill_level = CHAR_getWorkInt( charaindex, CHAR_WORKMODSIGN ); + int old_hp = CHAR_getInt( charaindex, CHAR_HP ); + int old_mp = CHAR_getInt( charaindex, CHAR_MP ); + int to_index = CHAR_getWorkInt( charaindex, CHAR_WORKSIGNID ); + int to_old_hp = CHAR_getInt( to_index, CHAR_HP ); + int to_old_mp = CHAR_getInt( to_index, CHAR_MP ); + int dec_hp=0, dec_mp=0, rate=0, hp=0, mp=0, add_hp=0, add_mp=0; + + if( old_hp <= 0 ) break; + +#ifdef _PROFESSION_ADDSKILL + if( skill_level >= 10 ){ + dec_hp = 200; + dec_mp = 30; + }else if( skill_level > 6 ){ + dec_hp = 150; + dec_mp = 20; + }else if( skill_level > 3 ){ + dec_hp = 100; + dec_mp = 15; + }else{ + dec_hp = 50; + dec_mp = 10; + } + // 增加hp + if( skill_level > 8 ) rate = 100; + else if( skill_level > 7 ) rate = 50; + else rate = 0; + add_hp = dec_hp * rate / 100; + + // 增加mp + if( skill_level > 8 ) rate = 100; + else rate = 0; + add_mp = dec_mp * rate / 100; + +#else + if( skill_level >= 10 ){ + dec_hp = 300; + dec_mp = 70; + }else if( skill_level >= 9 ){ + dec_hp = 200; + dec_mp = 50; + }else if( skill_level >= 7 ){ + dec_hp = 150; + dec_mp = 30; + }else if( skill_level >= 4 ){ + dec_hp = 100; + dec_mp = 20; + }else{ + dec_hp = 50; + dec_mp = 10; + } + // 增加hp + if( skill_level >= 9 ) rate = 80; + else if( skill_level >= 7 ) rate = (skill_level - 1 ) * 10; + else if( skill_level >= 4 ) rate = (skill_level - 2 ) * 10; + else rate = skill_level * 10; + add_hp = dec_hp * rate / 100; + + // 增加mp + if( skill_level >= 9 ) rate = 100; + else if( skill_level >= 7 ) rate = (skill_level - 1 ) * 10; + else if( skill_level >= 4 ) rate = (skill_level - 2 ) * 10; + else rate = skill_level * 10; + add_mp = dec_mp * rate / 100; +#endif + + // 中嗜血蛊的人减 HP + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + mp = old_mp - dec_mp; + if( mp < 0 ){ + mp = 0; + add_mp=0; + } + CHAR_setInt(charaindex, CHAR_MP, mp); + } + + // 中嗜血蛊的人减 HP + if( ridepet == -1 ) { + hp = old_hp - dec_hp; + if( hp < 0 ) hp = 0; + CHAR_setInt(charaindex, CHAR_HP, hp); + sprintf( szCommand, "BD|r%X|0|0|%X|m%X|", bid, dec_hp, dec_mp ); + }else{ + int pet_old_hp = CHAR_getInt( ridepet, CHAR_HP ); + int pet_hp=0; + + dec_hp /= 2; + hp = old_hp - dec_hp; + pet_hp = pet_old_hp - dec_hp; + + if( hp < 0 ) hp = 0; + if( pet_hp < 0 ) pet_hp = 0; + + CHAR_setInt(charaindex, CHAR_HP, hp); + CHAR_setInt(ridepet, CHAR_HP, pet_hp); + if( pet_hp <= 0 ){ + CHAR_setFlg( ridepet, CHAR_ISDIE, 1 ); + CHAR_setWorkInt( ridepet, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + sprintf( szCommand, "BD|r%X|0|0|%X|m%X|p%X|", bid, dec_hp, dec_mp, dec_hp ); + } + + if( hp <= 0 ){ + CHAR_setFlg( charaindex, CHAR_ISDIE, 1 ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + + BATTLESTR_ADD( szCommand ); + + // 使用嗜血蛊的人加 HP、MP + if( (add_hp > 0) && (to_old_hp > 0) ){ + int to_bid=0, to_hp=0, to_mp=0; + + to_bid = BATTLE_Index2No( battleindex, to_index ); + sprintf( szCommand, "BD|r%X|0|1|%X|m%X|", to_bid, add_hp, add_mp ); + BATTLESTR_ADD( szCommand ); + + to_hp = to_old_hp + add_hp; + if( to_hp > CHAR_getWorkInt( to_index , CHAR_WORKMAXHP ) ) + to_hp = CHAR_getWorkInt( to_index , CHAR_WORKMAXHP ); + + to_mp = to_old_mp + add_mp; + if( to_mp > CHAR_getWorkInt( to_index , CHAR_WORKMAXMP ) ) + to_mp = CHAR_getWorkInt( to_index , CHAR_WORKMAXMP ); + + CHAR_setInt(to_index, CHAR_HP, to_hp); + CHAR_setInt(to_index, CHAR_MP, to_mp); + } + + break; + } + case CHAR_WORKBLOODWORMS: // 嗜血蛊 + { + // 吸血 + int skill_level = CHAR_getWorkInt( charaindex, CHAR_WORKMODBLOODWORMS ); + int old_hp = CHAR_getInt( charaindex, CHAR_HP ); + int to_index = CHAR_getWorkInt( charaindex, CHAR_WORKBLOODWORMSID ); + int to_old_hp = CHAR_getInt( to_index, CHAR_HP ); + int dec_hp=0, rate=0, hp=0, add_hp=0; + + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_M( skill_level ); + + if( old_hp <= 0 ) break; + + dec_hp = skill_level * 10 + 30; + if( skill_level >= 10 ) rate = 20; + else if( skill_level >= 7 ) rate = 15; + else if( skill_level >= 5 ) rate = 10; + else rate = 5; + + add_hp = dec_hp * rate / 100; + + // 中嗜血蛊的人减 HP + if( ridepet == -1 ) { + hp = old_hp - dec_hp; + if( hp < 0 ) hp = 0; + + CHAR_setInt(charaindex, CHAR_HP, hp); + sprintf( szCommand, "BD|r%X|0|0|%X|", bid, dec_hp ); + }else{ + int pet_old_hp = CHAR_getInt( ridepet, CHAR_HP ); + int pet_hp=0; + + dec_hp /= 2; + hp = old_hp - dec_hp; + pet_hp = pet_old_hp - dec_hp; + + if( hp < 0 ) hp = 0; + if( pet_hp < 0 ) pet_hp = 0; + + CHAR_setInt(charaindex, CHAR_HP, hp); + CHAR_setInt(ridepet, CHAR_HP, pet_hp); + if( pet_hp == 0 ){ + CHAR_setFlg( ridepet, CHAR_ISDIE, 1 ); + CHAR_setWorkInt( ridepet, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + sprintf( szCommand, "BD|r%X|0|0|%X|p%X|", bid, dec_hp, dec_hp ); + } + + if( hp <= 0 ){ + CHAR_setFlg( charaindex, CHAR_ISDIE, 1 ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + + BATTLESTR_ADD( szCommand ); + + // 使用嗜血蛊的人加 HP + if( (add_hp > 0) && (to_old_hp > 0) ){ + int to_bid=0, to_hp=0; + + to_bid = BATTLE_Index2No( battleindex, to_index ); + sprintf( szCommand, "BD|r%X|0|1|%X|", to_bid, add_hp ); + BATTLESTR_ADD( szCommand ); + + to_hp = to_old_hp + add_hp; + if( to_hp > CHAR_getWorkInt( to_index , CHAR_WORKMAXHP ) ) + to_hp = CHAR_getWorkInt( to_index , CHAR_WORKMAXHP ); + + CHAR_setInt(to_index, CHAR_HP, to_hp); + } + + break; + } + case CHAR_WORKICEARROW: // 冰箭 + { + // 减敏 + int dec_dex = CHAR_getWorkInt( charaindex, CHAR_WORKMODICEARROW ); + int old_dex = CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX ); + int dex=0; + + dex = old_dex * ( 100 - dec_dex ) / 100; + CHAR_setWorkInt(charaindex,CHAR_WORKFIXDEX, dex); + sprintf( szCommand, "BD|r%X|0|6|%X|", bid, (-1) * dec_dex ); + + BATTLESTR_ADD( szCommand ); + + break; + } + case CHAR_WORKICECRACK: // 冰爆术 + { + int value=0; + int defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 );//defNo = BATTLE_Index2No( battleindex, charaindex ); + + value = CHAR_getWorkInt( charaindex, CHAR_WORKMODICECRACK ); + + if( cnt <= 0 && value > 0 ){ + int damage=0, petdamage=0; + + int ToList[SIDE_OFFSET*2+1]; + memset( ToList, -1, sizeof( ToList)); + BATTLE_MultiList( battleindex, TARGET_SIDE_1, ToList ); + // 将魔法参数代入动画 + analysis_profession_parameter( 2, 4, defNo, charaindex ); + PROFESSION_MAGIC_ATTAIC_Effect( battleindex, bid, ToList, 2); + + if( defNo == 20 || defNo == 25 || defNo == 26 )//右 + bid = 0; + else + bid = 10; + + + for( i = bid ; i < bid+10 ; i++ ) { + int defType, charaidx, petidx; + charaidx = BATTLE_No2Index( battleindex , i); + if( CHAR_CHECKINDEX( charaidx ) ){ + if( CHAR_getInt( charaidx, CHAR_HP ) > 0 ){ + petidx = BATTLE_getRidePet( charaidx ); + defType = CHAR_getInt(charaidx, CHAR_WHICHTYPE); + CHAR_setWorkInt( charaidx, CHAR_WORKICECRACK, 0 ); + //BATTLE_BadStatusString( bid, 0 ); + //snprintf( szBuffer, sizeof( szBuffer ), "(%s)将(%s)修理完毕。", + // CHAR_getUseName( charaindex ), aszStatusFull[i] ); + // BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + //sprintf( szBuffer, "BM|%X|%X|", bid, 0 ); + //BATTLESTR_ADD( szBuffer ); + + damage = value; + + hp = CHAR_getInt( charaidx, CHAR_HP ); + if( petidx == -1 ) { + hp -= damage; + if( hp < 0 ) hp = 0; + } + else{ + int defquick=0, petquick=0, playerdamage=0; + pethp = CHAR_getInt( petidx, CHAR_HP ); + defquick = CHAR_getWorkInt( charaidx, CHAR_WORKDEFENCEPOWER ); + petquick = CHAR_getWorkInt( petidx, CHAR_WORKDEFENCEPOWER ); + if( pethp > 0 ){ + playerdamage = (damage*petquick)/(defquick+petquick) +1; + petdamage = damage - playerdamage +1 ; + hp -= playerdamage; + pethp -= petdamage; + } + else{ + hp -= damage; + } + if( hp < 0 ) hp = 0; + if( pethp < 0 ) pethp = 0; + CHAR_setInt( petidx, CHAR_HP, pethp ); + } + + CHAR_setInt( charaidx, CHAR_HP, hp ); + + if( hp <= 0 ){ + CHAR_setFlg( charaidx, CHAR_ISDIE, 1 ); + CHAR_setWorkInt( charaidx, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + if( pethp <= 0 ){ + CHAR_setFlg( petidx, CHAR_ISDIE, 1 ); + CHAR_setWorkInt( ridepet, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + + if( damage >= 0 ){ + //snprintf( szBuffer, sizeof( szBuffer ), + // "(%s)因(%s)受到(%d)的损伤。", + // CHAR_getUseName( charaindex ), + // aszStatusFull[i], + // damage ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + sprintf( szBuffer , "%X|%X|%X|%X|" , i , i ,(int)(damage) , (int)(petdamage)); + + //sprintf( szBuffer, "BD|r%X|0|0|%X|p%X|", i, (int)(damage), (int)(petdamage) ); + BATTLESTR_ADD( szBuffer ); + } + if( petidx != -1 && petdamage >= 0 ){ + //snprintf( szBuffer, sizeof( szBuffer ), + // "(%s的骑宠)因(%s)受到(%d)的损伤。", + // CHAR_getUseName( charaindex ), + // aszStatusFull[i], petdamage ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + } + } + } + } + sprintf( szBuffer , "%X|" , 0x5711438 ); + BATTLESTR_ADD( szBuffer ); + } + } + print("\n冰爆术"); + break; +#ifdef _PROFESSION_ADDSKILL + case CHAR_WORKICECRACK2: // 冰爆术2 + WorkIceCrackPlay( charaindex, cnt, CHAR_WORKICECRACK2 );print("\n冰爆术2");break; + case CHAR_WORKICECRACK3: // 冰爆术3 + WorkIceCrackPlay( charaindex, cnt, CHAR_WORKICECRACK3 );print("\n冰爆术3");break; + case CHAR_WORKICECRACK4: // 冰爆术4 + WorkIceCrackPlay( charaindex, cnt, CHAR_WORKICECRACK4 );print("\n冰爆术4");break; + case CHAR_WORKICECRACK5: // 冰爆术5 + WorkIceCrackPlay( charaindex, cnt, CHAR_WORKICECRACK5 );print("\n冰爆术5");break; + case CHAR_WORKICECRACK6: // 冰爆术6 + WorkIceCrackPlay( charaindex, cnt, CHAR_WORKICECRACK6 );print("\n冰爆术6");break; + case CHAR_WORKICECRACK7: // 冰爆术7 + WorkIceCrackPlay( charaindex, cnt, CHAR_WORKICECRACK7 );print("\n冰爆术7");break; + case CHAR_WORKICECRACK8: // 冰爆术8 + WorkIceCrackPlay( charaindex, cnt, CHAR_WORKICECRACK8 );print("\n冰爆术8");break; + case CHAR_WORKICECRACK9: // 冰爆术9 + WorkIceCrackPlay( charaindex, cnt, CHAR_WORKICECRACK9 );print("\n冰爆术9");break; + case CHAR_WORKICECRACK10: // 冰爆术10 + WorkIceCrackPlay( charaindex, cnt, CHAR_WORKICECRACK10 );print("\n冰爆术10");break; +#endif //_PROFESSION_ADDSKILL + +#endif + +#ifdef _PET_SKILL_SARS // WON ADD 毒煞蔓延 + case CHAR_WORKSARS: + { + int j; + int rate = 60; // 传染 SARS 机率 + + // 受传染的人受伤 + { + int petdown=-1; + int dec_mp = 0; + + Compute_Down_SARS( charaindex, ridepet, &down, &petdown, ridepet); + if( down >= 0 ){ + //snprintf( szBuffer, sizeof( szBuffer ), + // "(%s)因(%s)受到(%d)的损伤。", + // CHAR_getUseName( charaindex ), + // aszStatusFull[i], + // down ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + // 如果是玩家扣 MP + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + int old_mp = CHAR_getInt( charaindex, CHAR_MP ); + dec_mp = old_mp / 10 ; + if( dec_mp < 0 ) dec_mp = 0; + CHAR_setInt( charaindex, CHAR_MP, old_mp - dec_mp ); + sprintf( szBuffer, "BD|r%X|0|0|%X|p%X|m%X|", bid, (int)(down), (int)(petdown), dec_mp ); + }else + sprintf( szBuffer, "BD|r%X|0|0|%X|p%X|", bid, (int)(down), (int)(petdown) ); + + BATTLESTR_ADD( szBuffer ); + } + if( ridepet != -1 && petdown >= 0 ){ + //snprintf( szBuffer, sizeof( szBuffer ), + // "(%s的骑宠)因(%s)受到(%d)的损伤。", + // CHAR_getUseName( charaindex ), + // aszStatusFull[i], petdown ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + } + } + + // 主传染者传SARS + if( CHAR_getWorkInt( charaindex, CHAR_WORKMODSARS ) > 0 ){ + int buf2[5], ti=0; + int tibuf[10]={ + 3,1,0,2,4, + 8,6,5,7,9 }; + + memset( buf2, -1, sizeof(buf2)); + + if( defNo > 9 ){ + for( j=0; j<10; j++ ){ + tibuf[j] += 10; + } + } + + for( j=0; j<10; j++){ + if( tibuf[j] != defNo ) continue; + if( j > 4 ){ + if( (j+1) < 10 ) buf2[ti++]=tibuf[j+1]; + if( (j-1) > 4 ) buf2[ti++]=tibuf[j-1]; + //不等边 + if( (j-5+1) < 5 ) buf2[ti++]=tibuf[j-5+1]; + if( (j-5-1) >= 0 ) buf2[ti++]=tibuf[j-5-1]; + if( (j-5) >= 0 ) buf2[ti++]=tibuf[j-5]; + }else{ + if( (j+1) < 5 ) buf2[ti++]=tibuf[j+1]; + if( (j-1) >= 0 ) buf2[ti++]=tibuf[j-1]; + //不等边 + if( (j+5+1) < 10 ) buf2[ti++]=tibuf[j+5+1]; + if( (j+5-1) > 4 ) buf2[ti++]=tibuf[j+5-1]; + if( (j+5) < 10 ) buf2[ti++]=tibuf[j+5]; + } + break; + } + + print("buf2[%d,%d,%d,%d,%d]\n", buf2[0], buf2[1], buf2[2], buf2[3], buf2[4]); + + for( j=0; j<5; j++ ){ + + int toindex = 0; + if( buf2[j] == -1 ) continue; + + toindex = BATTLE_No2Index( battleindex, buf2[j] ); + + // 得到sars的离开 + if( CHAR_getWorkInt( toindex,CHAR_WORKSARS ) > 0 ) continue; + + if( RAND( 1, 100 ) <= rate ){ // 中 SARS + if( toindex == charaindex ) continue; + if( CHAR_getInt( toindex, CHAR_HP ) <= 0 ) continue; + + CHAR_setWorkInt( toindex,CHAR_WORKSARS, 3 ); + } + } + } + } + break; +#endif + + default : + //snprintf( szBuffer, sizeof( szBuffer ), + // "(%s)是(%s)", CHAR_getUseName( charaindex ), + // aszStatusFull[i] ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + break; + } + } + +#ifdef _SUIT_ITEM + { + int defCode; + int AddHp=0, AddMp=0; +#ifdef _IMPRECATE_ITEM + int nums1, nums2, nums3, delMp=0; +#endif + if( (defCode=CHAR_getWorkInt( charaindex, CHAR_WORKSUITITEM)) > 0){ + AddHp = CHAR_getWorkInt( charaindex, CHAR_WORKROUNDHP); + AddMp = CHAR_getWorkInt( charaindex, CHAR_WORKROUNDMP); + } + +#ifdef _IMPRECATE_ITEM + if( (nums1 = CHAR_getWorkInt( charaindex, CHAR_WORKIMPRECATENUM1)) > 0 ){ + delMp = CHAR_getWorkInt( charaindex, CHAR_WORKHURTMP); + CHAR_setWorkInt( charaindex, CHAR_WORKIMPRECATENUM1, nums1-1); + } + if( (nums2 = CHAR_getWorkInt( charaindex, CHAR_WORKIMPRECATENUM2)) > 0 ){ + AddHp += CHAR_getWorkInt( charaindex, CHAR_WORKWISHESHP); + CHAR_setWorkInt( charaindex, CHAR_WORKIMPRECATENUM2, nums2-1); + } + if( (nums3 = CHAR_getWorkInt( charaindex, CHAR_WORKIMPRECATENUM3)) > 0 ){ + AddMp += CHAR_getWorkInt( charaindex, CHAR_WORKWISHESMP); + CHAR_setWorkInt( charaindex, CHAR_WORKIMPRECATENUM3, nums3-1); + } + AddMp = AddMp - delMp; +#endif + if( AddHp != 0 || AddMp != 0 ) { + int AddPHp=0; + + +#ifdef _TYPE_TOXICATION + if( AddHp != 0 && CHAR_CanCureFlg( charaindex, "FALSE") != FALSE ){ +#else + if( AddHp != 0 ) { +#endif + int MyHp = CHAR_getInt( charaindex, CHAR_HP); + int MaxHp = CHAR_getWorkInt( charaindex, CHAR_WORKMAXHP); + MyHp = ((MyHp+AddHp)>=MaxHp)?MaxHp:(MyHp+AddHp); + MyHp = (MyHp<= 1 )?1:MyHp; + CHAR_setInt( charaindex, CHAR_HP, MyHp); + //snprintf( szBuffer, sizeof( szBuffer ), "(%s)增加(%d)的HP。", + // CHAR_getUseName( charaindex ), AddHp ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + if( ridepet != -1 ){ + int PetMaxHp = CHAR_getWorkInt( ridepet, CHAR_WORKMAXHP); + int PetHp = CHAR_getInt( ridepet, CHAR_HP); + AddPHp = AddHp; + PetHp = ((PetHp+AddPHp)>=PetMaxHp)?PetMaxHp:(PetHp+AddPHp); + PetHp = (PetHp<=1)?1:PetHp; + CHAR_setInt( ridepet, CHAR_HP, PetHp); + } + } + if( AddMp != 0 ) { + int MyMp = CHAR_getInt( charaindex, CHAR_MP); + int MaxMp = CHAR_getWorkInt( charaindex, CHAR_WORKMAXMP); + MyMp = ((MyMp+AddMp)>MaxMp)?MaxMp:(MyMp+AddMp); + MyMp = (MyMp<0)?0:MyMp; + CHAR_setInt( charaindex, CHAR_MP, MyMp); +/* +#ifdef _FIXITEMANISHOW + sprintf( szBuffer, "BD|r%X|0|1|%X|p%X|m%X|", bid, AddHp, AddPHp, AddMp); + }else { + sprintf( szBuffer, "BD|r%X|0|1|%X|p%X|", bid, AddHp, AddPHp ); +#else +*/ + sprintf( szBuffer, "BD|r%X|0|2|%X|p%X|m%X|", bid, AddHp, AddPHp, AddMp); + }else { + sprintf( szBuffer, "BD|r%X|0|2|%X|p%X|", bid, AddHp, AddPHp ); +//#endif + } + BATTLESTR_ADD( szBuffer ); + } + } +#endif +#ifdef _PETSKILL_SETDUCK + { + int turns=0, nums=0; + if( (turns=CHAR_getWorkInt( charaindex, CHAR_MYSKILLDUCK)) > 0 ){ + turns--; + if( turns == 0 ){ + nums = CHAR_getWorkInt( charaindex, CHAR_MYSKILLDUCKPOWER); + sprintf( szBuffer, "BD|r%X|0|3|%X|", bid, nums*(-1)); + BATTLESTR_ADD( szBuffer ); + } + CHAR_setWorkInt( charaindex, CHAR_MYSKILLDUCK, turns); + } +#ifdef _MAGICPET_SKILL + if( (turns=CHAR_getWorkInt( charaindex, CHAR_MYSKILLSTR)) > 0 ){ + turns--; + if( turns == 0 ){ + nums = CHAR_getWorkInt( charaindex, CHAR_MYSKILLSTRPOWER); + sprintf( szBuffer, "BD|r%X|0|4|%X|", bid, nums*(-1)); + BATTLESTR_ADD( szBuffer ); + } + CHAR_setWorkInt( charaindex, CHAR_MYSKILLSTR, turns); + } + if( (turns=CHAR_getWorkInt( charaindex, CHAR_MYSKILLTGH)) > 0 ){ + turns--; + if( turns == 0 ){ + nums = CHAR_getWorkInt( charaindex, CHAR_MYSKILLTGHPOWER); + sprintf( szBuffer, "BD|r%X|0|5|%X|", bid, nums*(-1)); + BATTLESTR_ADD( szBuffer ); + } + CHAR_setWorkInt( charaindex, CHAR_MYSKILLTGH, turns); + } + if( (turns=CHAR_getWorkInt( charaindex, CHAR_MYSKILLDEX)) > 0 ){ + turns--; + if( turns == 0 ){ + nums = CHAR_getWorkInt( charaindex, CHAR_MYSKILLDEXPOWER); + sprintf( szBuffer, "BD|r%X|0|6|%X|", bid, nums*(-1)); + BATTLESTR_ADD( szBuffer ); + } + CHAR_setWorkInt( charaindex, CHAR_MYSKILLDEX, turns); + } +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + if( (turns=CHAR_getWorkInt( charaindex, CHAR_MYSKILLHIT)) > 0 ){ + turns--; + if( turns == 0 ){ + int dec_num = CHAR_getWorkInt( charaindex, CHAR_MYSKILLHIT_NUM); + nums = CHAR_getWorkInt( charaindex, CHAR_WORKHITRIGHT); + nums -= dec_num; + CHAR_setWorkInt( charaindex, CHAR_WORKHITRIGHT, nums); + + CHAR_talkToCli( charaindex, -1, "恢复命中率", CHAR_COLORYELLOW); + //sprintf( szBuffer, "BD|r%X|0|6|%X|", bid, dec_num*(-1)); + //BATTLESTR_ADD( szBuffer ); + } + CHAR_setWorkInt( charaindex, CHAR_MYSKILLHIT, turns); + } +#endif + +#endif + } +#endif + return 0; + +} + + +BOOL BATTLE_CanMoveCheck( int charaindex ) +{ + + // + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARALYSIS ) > 0 ){ + return FALSE; + } + + // 檗祭 + if( CHAR_getWorkInt( charaindex, CHAR_WORKSTONE ) > 0 ){ + return FALSE; + } + // 戽曰 + if( CHAR_getWorkInt( charaindex, CHAR_WORKSLEEP ) > 0 ){ + return FALSE; + } +#ifdef _MAGIC_BARRIER + if( CHAR_getWorkInt( charaindex, CHAR_WORKBARRIER ) > 0 ){ + return FALSE; + } +#endif + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + // 晕眩 + if( CHAR_getWorkInt( charaindex, CHAR_WORKDIZZY ) > 0 ){ + return FALSE; + } + // 天罗地网 + if( CHAR_getWorkInt( charaindex, CHAR_WORKDRAGNET ) > 0 ){ + return FALSE; + } +/* + // 冰箭术 + if( CHAR_getWorkInt( charaindex, CHAR_WORKICEARROW ) > 0 ){ + return FALSE; + } +*/ +/* + // 专注战斗 + if( CHAR_getWorkInt( charaindex, CHAR_WORK_FOCUS ) > 0 ){ + return FALSE; + } +*/ + // 雷附体 + if( CHAR_getWorkInt( charaindex, CHAR_WORK_T_ENCLOSE ) > 0 ){ + return FALSE; + } +#endif +#ifdef _PROFESSION_ADDSKILL + if( CHAR_getWorkInt( charaindex, CHAR_DOOMTIME ) > 0 ){ + return FALSE; + } +#endif + return TRUE; +} + +#ifdef _ITEM_EQUITSPACE +int BATTLE_GetEqShield( int charaindex ) +{ + int iRet = ITEM_FIST, itemindex; + + itemindex = CHAR_getItemIndex( charaindex, CHAR_EQSHIELD ); + if( ITEM_CHECKINDEX( itemindex ) == FALSE ){ + iRet = ITEM_FIST; + }else{ + iRet = ITEM_getInt( itemindex, ITEM_TYPE ); + } + return iRet; +} +#endif + +int BATTLE_GetWepon( int charaindex ) //取得角色手持武器 +{ + int iRet = ITEM_FIST, itemindex; + + itemindex = CHAR_getItemIndex( charaindex, CHAR_ARM ); + if( ITEM_CHECKINDEX( itemindex ) == FALSE ){ + iRet = ITEM_FIST; + }else{ + iRet = ITEM_getInt( itemindex, ITEM_TYPE ); + } + + return iRet; +} + +static int aBowW[50] = +{ + 0, 2, 1, 4, 3, 0, 1, 2, 3, 4, + 1, 0, 3, 2, 4, 1, 3, 0, 2, 4, + 2, 4, 0, 1, 3, 2, 0, 4, 1, 3, + 3, 1, 0, 2, 4, 3, 1, 0, 2, 4, + 4, 2, 0, 1, 3, 4, 2, 0, 1, 3, +}; + +void BATTLE_TargetListSet( int charaindex, int attackNo, int *pList) +{ + int i, j=0, defNo, battleindex=-1; + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + +#ifdef _SKILLLIMIT // (可开放) Syu ADD 不得攻击我方限制 + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_FALLRIDE || // 落马 + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_WILDVIOLENTATTACK || //狂暴攻击 + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_TIMID || // 怯战 + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_MPDAMAGE || // MP攻击 + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_WEAKEN || // 虚弱 + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_DAMAGETOHP || // 嗜血 + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_STEALMONEY ) { // 捐献 + if( BATTLE_CheckSameSide( charaindex, defNo) == 1 ) { + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); +// BATTLE_NoAction( battleindex, attackNo ); + return; + } + } +#endif + + for( i = 0; i < BATTLE_ENTRY_MAX*2; i ++ ){ + pList[i] = defNo; + } +#ifdef _BATTLE_ATTCRAZED // ANDY 疯狂暴走 +#ifdef _SHOOTCHESTNUT // Syu ADD 宠技:丢栗子 + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_ATTCRAZED || + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_ATTSHOOT ){ +#else + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_ATTCRAZED ){ +#endif + int deftop,defsub; + int plive[10]; + int n = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + + +#ifdef _SHOOTCHESTNUT // Syu ADD 宠技:丢栗子 + if( BATTLE_CheckSameSide( charaindex, defNo) == 1 ) { + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + BATTLE_NoAction( battleindex, attackNo ); + return; + } +#endif + if( 0 <= defNo && defNo <= 9 ){ + defsub = 0; + deftop = 9; + }else if( 10 <= defNo && defNo <= 19 ){ + defsub = 10; + deftop = 19; + }else{ + pList[1] = -1; + return; + } + for( i = defsub; i < deftop; i ++ ){ + if( BATTLE_TargetCheck( battleindex, i) == FALSE ) continue; + plive[j++] = i; + } + if( j == 0 ) return; + for( i=0; i= CHAR_MAXPETSKILLHAVE ) i = 0; + + if( CHAR_getCharHaveSkill( charaindex, i ) == NULL ){ + continue; + } + + pskill_array = PETSKILL_GetArray( charaindex, i ); + skill_type = PETSKILL_getInt( pskill_array, PETSKILL_FIELD ); + + + if( skill_type == PETSKILL_FIELD_BATTLE + || skill_type == PETSKILL_FIELD_ALL + ){ + }else{ + continue; + } + + if( j < iNum ){ + j++; + continue; + } + + if( PETSKILL_Use( charaindex, iNum, toNo, NULL ) == TRUE ){ + + }else{ + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + break; + } + + if( k >= PETSKILLSERCHTIME ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + return 0; +} + + +enum{ + PETAI_MODE_NORMAL, + PETAI_MODE_TARGETRANDOM, + PETAI_MODE_RANDOMACT, + PETAI_MODE_OWNERATTACK, + PETAI_MODE_ENEMYATTACK, + PETAI_MODE_ESCAPE, + PETAI_MODE_NOACT, + PETAI_MODE_END +}; + +static int BATTLE_PetLoyalCheck( int battleindex, int bid, int charaindex ) +{ + int ai, toNo, mode = 0, type, Rand, toSide = 1, flg, i; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPET ){ + return 0; + } + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == TRUE ) + return 0; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_WAIT ){ + return 0; + } + flg = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEFLG ); + flg &= ~CHAR_BATTLEFLG_AIBAD; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEFLG, flg ); + if( BATTLE_CanMoveCheck( charaindex ) == FALSE ){ + return 0; + } + toNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + toSide = ( 0 <= toNo && toNo < BATTLE_ENTRY_MAX )?(0):(1); + ai = CHAR_getWorkInt( charaindex, CHAR_WORKFIXAI ); + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_GUARD + || bid == toNo + ){ + type = 1; + }else{ + type = 0; + } + + Rand = RAND( 1, 100 ); + + mode = 0; // 恳仄中垫 + if( ai >= 80 ){ // 镝擦蘸ㄧㄟ⊙动晓 + mode = PETAI_MODE_NORMAL; // 濮覆岳 + }else + if( ai >= 70 ){ // 镝擦蘸ㄦㄟ⊙动晓 + if( Rand < 10 )mode = PETAI_MODE_TARGETRANDOM; // 正□必永玄 + }else + if( ai >= 60 ){ + if( Rand < 20 )mode = PETAI_MODE_TARGETRANDOM; // 正□必永玄 + }else + if( ai >= 50 ){ + if( Rand < 35 )mode = PETAI_MODE_TARGETRANDOM; // 正□必永玄 + }else + if( ai >= 40 ){ + if( Rand < 50 )mode = PETAI_MODE_TARGETRANDOM; // 正□必永玄 + }else + if( ai >= 30 ){ + if( Rand < 70 )mode = PETAI_MODE_RANDOMACT; // 垫 仿件母丞 + }else + if( ai >= 20 ){ + if( Rand < 70 )mode = PETAI_MODE_RANDOMACT; // 垫 仿件母丞 + }else + if( ai >= 10 ){ + if( Rand < 80 ){ + mode = PETAI_MODE_OWNERATTACK; // 潜谛 猾 + }else{ + mode = PETAI_MODE_ENEMYATTACK; // 衬 猾 + } + }else{ + if( Rand < 60 ){ + mode = PETAI_MODE_OWNERATTACK; // 潜谛 猾 + }else{ + mode = PETAI_MODE_ESCAPE; // 仆月 + } + } + + + if( mode == PETAI_MODE_NORMAL )return 0; + + for( i = 0; i < CHAR_MAXPETSKILLHAVE;i ++ ){ + if( CHAR_getCharHaveSkill( charaindex, i ) ){ + break; + } + } + if( i >= CHAR_MAXPETSKILLHAVE ){ + mode = PETAI_MODE_NOACT; + } + flg = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEFLG ); + flg |= CHAR_BATTLEFLG_AIBAD; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEFLG, flg ); + + + switch( mode ){ + case PETAI_MODE_NOACT: + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, + BATTLE_COM_NONE ); + break; + case PETAI_MODE_TARGETRANDOM: + if( type == 1 ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, + BATTLE_COM_NONE ); + }else{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, + BATTLE_DefaultAttacker( battleindex, toSide ) ); + + } + break; + case PETAI_MODE_RANDOMACT: // 垫 互仿件母丞 + // 哗萄ㄠ葱 猾蟆反濮覆井尹切扎母丢 + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_EARTHROUND0 ){ + return 0; + } + + // 布□犯奴失件白仿弘毛反内允 + flg = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEFLG ); + flg &= ~CHAR_BATTLEFLG_GUARDIAN; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEFLG, flg ); + + if( toNo == bid ){ // 愤坌毛蓟氏匹仄引匀凶日 + // 窒手匹五卅中仇午卞允月 + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + }else{ + // 仿件母丞卞檗 毛本永玄 + BATTLE_PetRandomSkill( battleindex, charaindex ); + } + break; + + case PETAI_MODE_OWNERATTACK: // 潜谛 猾 + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, bid-5 ); + break; + + case PETAI_MODE_ENEMYATTACK: // 衬 猾 + { int myside = 0; + if( bid >= BATTLE_ENTRY_MAX ) myside = 1; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + // 锹澎扔奶玉卞 + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, + BATTLE_DefaultAttacker( battleindex, 1 - myside ) ); + } + break; + + case PETAI_MODE_ESCAPE: // 仆月公及 夫旦玄 + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_LOSTESCAPE ); + break; + + } + + return 1; + +} + +#ifdef __ATTACK_MAGIC + +#define MAX_MAGIC_NUMBER 25 + +// 每一种魔法的攻击 围 (id,area) +int TargetIndex[MAX_MAGIC_NUMBER][2] = +{ + {301,-1},{302,-1},{303,26},{304,-1},{305,20},{306,20}, + {307,-1},{308,-1},{309,-1},{310,-1},{311,26},{312,20}, + {313,-1},{314,-1},{315,-1},{316,-1},{317,26},{318,20}, + {319,-1},{320,-1},{321,26},{322,-1},{323,26},{324,20},{325,20} +}; + +int magic,toindex,magic_count; + +#endif + + + +static int BATTLE_Battling( int battleindex ) +{ + BATTLE *pBattle, *pWatchBattle; + BATTLE_ENTRY *pEntry[2]; + char *aszFieldAttr[] = { "无", "地", "水", "火", "风" }, + szBuffer[256]="", + szWork[256]; + int i,j,k, + len, + entrynum, + charaindex, + attackNo, + defNo=-1, + aAttackList[BATTLE_ENTRY_MAX*2+1], + aDefList[BATTLE_ENTRY_MAX*2+1], + ComboId, + itemindex, + AllSize = 0; + BATTLE_CHARLIST EntryList[40]; + int ContFlg, attackNoSub, defNoSub; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + pBattle = &BattleArray[battleindex]; + pEntry[0] = pBattle->Side[0].Entry; + pEntry[1] = pBattle->Side[1].Entry; + + for( i = 0; i < arraysizeof(EntryList); i ++ ){ + EntryList[i].charaindex = -1; + EntryList[i].combo = 0; + } + + sprintf( szBuffer, "战役 %d 转换 %d 属性 %s", + battleindex, pBattle->turn, + aszFieldAttr[pBattle->field_att] + ); + + entrynum = 0; + + for( j = 0; j < 2; j ++ ){ + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + pEntry[j][i].flg &= ~BENT_FLG_ULTIMATE; + if( pEntry[j][i].charaindex == -1 )continue; + EntryList[entrynum].charaindex = pEntry[j][i].charaindex; + EntryList[entrynum].side = j; + EntryList[entrynum].num = pEntry[j][i].bid; + EntryList[entrynum].dex = BATTLE_DexCalc( pEntry[j][i].charaindex ); +#ifdef _EQUIT_SEQUENCE + EntryList[entrynum].sequence = CHAR_getWorkInt( pEntry[j][i].charaindex, CHAR_WORKSEQUENCEPOWER); +#endif + BATTLE_talkToCli( pEntry[j][i].charaindex, szBuffer, CHAR_COLORYELLOW ); + entrynum ++; + } + } + szAllBattleString[0] = 0; + k = 0; + for( j = 0; j < 2; j ++ ){ + k = j * SIDE_OFFSET; + for( i = 0; i < BATTLE_ENTRY_MAX/2; i ++ ){ + szBattleString[0] = 0; + if( pBattle->iEntryBack[k] >= 0 + && pBattle->Side[j].Entry[i].charaindex == -1){ + if( pBattle->iEntryBack2[k] >= 0 ){ + sprintf( szBattleString, "BE|et%X|f1|", k ); + //BATTLE_BroadCast( battleindex, "突然有人不见了。", CHAR_COLORYELLOW ); + }else{ + print( "应是输入ID不正确出现的error。\n" ); + //BATTLE_BroadCast( battleindex, "ID错误的error。", CHAR_COLORYELLOW ); + } + } + k ++; + strcat( szAllBattleString, szBattleString ); + } + } + len = strlen( szAllBattleString ); + AllSize += len; + EntrySort( EntryList, entrynum ); + ComboCheck( EntryList, entrynum ); + for( i = 0; i < entrynum; i ++ ){ + int COM, myside, otherside, bi, + attack_flg = 1, + attack_max = 1, + attack_count = 0; + + charaindex = EntryList[i].charaindex; + myside = EntryList[i].side; + otherside = 1-myside; + attackNo = EntryList[i].num; + bi = attackNo - myside * SIDE_OFFSET; + + aAttackList[0] = attackNo; + aAttackList[1] = -1; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == TRUE )continue; + szBadStatusString[0] = 0; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) + != BATTLE_CHARMODE_C_OK ){ + //sprintf( szBuffer, "指令输入不完全。(%s)", CHAR_getUseName( charaindex ) ); + //BATTLE_BroadCast( battleindex, szBuffer, CHAR_COLORYELLOW ); + continue; + } + if( CHAR_getInt( charaindex, CHAR_HP ) <= 0 )continue; + +#ifdef _CHECK_BATTLETIME + check_battle_com_begin(); +#endif + + szBattleString[0] = 0; + pszBattleTop = szBattleString; + pszBattleLast = szBattleString+arraysizeof(szBattleString); + + // WON ADD + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) != TRUE ) + BATTLE_StatusSeq( charaindex ); + +#ifdef _OTHER_MAGICSTAUTS + BATTLE_MagicStatusSeq( charaindex ); +#endif + +#ifdef _MAGIC_DEEPPOISON // 剧毒 + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == TRUE ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } +#endif + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + BATTLE_ProfessionStatusSeq( battleindex, charaindex); +#endif + + + if( BATTLE_CanMoveCheck( charaindex ) == FALSE ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + gBattleDamageModyfy = 1.0; + gBattleDuckModyfy = 0; + gBattleStausChange = -1; + gBattleStausTurn = 0; + gWeponType = ITEM_FIST; + gWeponType = BATTLE_GetWepon( charaindex ); +#ifdef _PETSKILL_BECOMEFOX + if( CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND ) != -1 //若是变成小狐狸 + || CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER)==101749) + { + int COM = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ); + + gWeponType = ITEM_FIST; + + if( !(COM == BATTLE_COM_ATTACK + || COM == BATTLE_COM_GUARD + || COM == BATTLE_COM_NONE) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + CHAR_talkToCli( charaindex, -1, "变成小狐狸後只能攻击、防御和待机!", CHAR_COLORYELLOW ); + } + } +#endif +#ifdef _PETSKILL_BECOMEPIG + if( CHAR_getInt( charaindex, CHAR_BECOMEPIG) > -1 //变成乌力了 + && (CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER) ) + { + int COM = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ); + + gWeponType = ITEM_FIST; + //CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + if( !(COM == BATTLE_COM_ATTACK + || COM == BATTLE_COM_GUARD + || COM == BATTLE_COM_NONE + || COM == BATTLE_COM_ITEM + || COM == BATTLE_COM_ESCAPE + || COM == BATTLE_COM_CAPTURE + || COM == BATTLE_COM_WAIT + || COM == BATTLE_COM_PETIN + || COM == BATTLE_COM_PETOUT) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_GUARD ); + //CHAR_talkToCli( charaindex, -1, "变成乌力後只能攻击、防御、待机、逃跑和使用道具!", CHAR_COLORYELLOW ); + CHAR_talkToCli( charaindex, -1, "变成乌力後不能使用咒术和职业技能!", CHAR_COLORYELLOW ); + } + } +#endif + gDamageDiv = 1.0; + attack_max = BATTLE_GetAttackCount( charaindex ); + if( attack_max <= 0 ){ + int work, randwork; + work = CHAR_getInt( charaindex, CHAR_LV ); + if( work < 10 || CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ){ + attack_max = 1; + }else{ + int luckwork = CHAR_getInt( charaindex, CHAR_LUCK )*5; + if( luckwork > 5*5 ){ + print( "\nerr:运气奇怪(%s)(%d)\n", + CHAR_getUseName( charaindex ), + CHAR_getInt( charaindex, CHAR_LUCK ) ); + luckwork = 5*5; + } + randwork = RAND( 1, 1000 ); + if( randwork <= 10 + luckwork){ + attack_max = RAND( 5, 10 ); + }else + if( randwork <= 30 + luckwork ){ + attack_max = 3; + }else + if( randwork <= 70 + luckwork ){ + attack_max = 2; + }else{ + attack_max = 1; + } + } + }else{ + if( gWeponType == ITEM_FIST )gDamageDiv = attack_max; + } + if( gWeponType == ITEM_BREAKTHROW ){ + gBattleStausChange = BATTLE_ST_PARALYSIS; + gBattleStausTurn = 1-1; + }else{ + } + + if( BattleArray[battleindex].Side[myside].flg & BSIDE_FLG_SURPRISE ){ + }else{ + if( BATTLE_PetLoyalCheck( battleindex, attackNo, charaindex ) ) { +#ifdef _FIXWOLF // Syu ADD 修正狼人变身Bug + if ( CHAR_getInt ( charaindex , CHAR_BASEIMAGENUMBER) == 101428 ) { + if( CHAR_getWorkInt ( charaindex , CHAR_WORKTURN ) == 0){ + CHAR_setInt( charaindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( charaindex , CHAR_BASEBASEIMAGENUMBER)); + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, CHAR_getWorkInt( charaindex , CHAR_WORKFIXSTR)); + CHAR_setWorkInt( charaindex, CHAR_WORKQUICK, CHAR_getWorkInt( charaindex , CHAR_WORKFIXDEX)); + } + } +#endif + sprintf( szWork, "BX|%X|", attackNo); + BATTLESTR_ADD( szWork ); + } + } + +#ifdef _PROFESSION_ADDSKILL + if( CHAR_getWorkInt( charaindex, CHAR_DOOMTIME ) > 0 ){ + CHAR_setWorkInt( charaindex, CHAR_DOOMTIME, CHAR_getWorkInt( charaindex, CHAR_DOOMTIME) - 1 ); + } + if( CHAR_getWorkInt( charaindex, CHAR_DOOMTIME ) == 0 + && ( CHAR_getWorkInt( charaindex, CHAR_WORK_com1 ) == BATTLE_COM_S_FIRE_SPEAR + || CHAR_getWorkInt( charaindex, CHAR_WORK_com1 ) == BATTLE_COM_S_DOOM ) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, CHAR_getWorkInt( charaindex, CHAR_WORK_com1 ) ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, CHAR_getWorkInt( charaindex, CHAR_WORK_toNo ) ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, CHAR_getWorkInt( charaindex, CHAR_WORK_mode ) ); + CHAR_SETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3, CHAR_getWorkInt( charaindex, CHAR_WORK_skill_level ) ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, CHAR_getWorkInt( charaindex, CHAR_WORK_array ) ); + CHAR_setWorkInt( charaindex, CHAR_WORK_com1, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORK_toNo, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORK_mode, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORK_skill_level, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORK_array, 0 ); + } + +#endif + COM = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ); + + switch( COM ){ + case BATTLE_COM_ATTACK: + if( gWeponType == ITEM_BOOMERANG ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_BOOMERANG ); + +#ifdef _PETSKILL_BECOMEFOX + if( CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER)==101749 + || CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND ) != -1 ){ //若是变成小狐狸不可以使用回力标 + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } +#endif +#ifdef _PETSKILL_BECOMEPIG + if( CHAR_getInt( charaindex, CHAR_BECOMEPIG) > -1 ){//变成乌力了 + gWeponType = ITEM_FIST; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + } +#endif + } + break; + case BATTLE_COM_COMBO: + if( ComboCheck2( EntryList, i, entrynum ) == FALSE ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + } + break; + + case BATTLE_COM_S_STATUSCHANGE: + gBattleStausChange = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3 ); + gBattleStausTurn = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3 ); + break; + +#ifdef _PETSKILL_HECTOR + case BATTLE_COM_S_HECTOR: + gBattleStausChange = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3 ); + gBattleStausTurn = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3 ); + break; +#endif + +#ifdef _PET_SKILL_SARS // WON ADD 毒煞蔓延 + case BATTLE_COM_S_SARS: + gBattleStausChange = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3 ); + gBattleStausTurn = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3 ); + break; +#endif + + case BATTLE_COM_S_CHARGE: + BATTLE_Charge( battleindex, attackNo ); + break; + case BATTLE_COM_S_RENZOKU: + attack_max = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3 ); + gDamageDiv = attack_max; + break; +#ifdef _VARY_WOLF + case BATTLE_COM_S_VARY: + // 先用不到 + break; +#endif +#ifdef _SKILL_WILDVIOLENT_ATT + //狂暴攻击 vincent add 2002/05/16 + case BATTLE_COM_S_WILDVIOLENTATTACK: + attack_max = RAND(3,10);//攻击次数 + gDamageDiv = attack_max;//每次攻击造成伤害 + gBattleDuckModyfy = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3 );//命中率 + break; +#endif + case BATTLE_COM_S_EARTHROUND0: + gBattleDamageModyfy = 1.0 + 0.01 * CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM3 ); + break; +#ifdef _BATTLE_ATTCRAZED + case BATTLE_COM_S_ATTCRAZED: + attack_max = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + break; +#endif +#ifdef _SHOOTCHESTNUT // Syu ADD 宠技:丢栗子 + case BATTLE_COM_S_ATTSHOOT: + attack_max = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + gDamageDiv = attack_max;//每次攻击造成伤害 + break; +#endif + case BATTLE_COM_S_MIGHTY: + gBattleDamageModyfy = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3 ) * 0.01; + gBattleDuckModyfy = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3 ); // 歹今木膜恳骚橘尺 + break; + } + + BATTLE_TargetListSet( charaindex, attackNo, aDefList ); + COM = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ); + + ContFlg = FALSE; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_AIBAD + && COM == BATTLE_COM_COMBO ){ + print( "由於忠诚度不足使用必杀技失败(%s)\n", CHAR_getUseName( charaindex ) ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + } +#ifdef _BATTLE_TIMESPEED//动画播放速度 + { + int flgtime = 0; + switch( COM ){ +#ifdef _BATTLE_ATTCRAZED + case BATTLE_COM_S_ATTCRAZED: + flgtime = 200*3; + break; +#endif +#ifdef _SHOOTCHESTNUT // Syu ADD 宠技:丢栗子 + case BATTLE_COM_S_ATTSHOOT: + flgtime = 80*attack_max; + break; +#endif + case BATTLE_COM_JYUJYUTU: + case BATTLE_COM_S_ATTACK_MAGIC: + flgtime = 260; // 1/100sec + break; + case BATTLE_COM_COMBO: + flgtime = 200; // 1/100sec + break; + case BATTLE_COM_GUARD: + break; + case BATTLE_COM_WAIT: + default : + flgtime = 150; // 1/100sec + break; + } + BattleArray[battleindex].flgTime += flgtime; + } +#endif + +#ifdef _PETSKILL_BECOMEFOX // 中了媚惑术後攻防敏能力各降 20% + if( CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND ) != -1 ){ //变成小狐狸 + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, CHAR_getWorkInt( charaindex, CHAR_WORKFIXSTR)*0.8);//攻降20% + CHAR_setWorkInt( charaindex, CHAR_WORKDEFENCEPOWER, CHAR_getWorkInt( charaindex, CHAR_WORKFIXTOUGH)*0.8);//防降20% + CHAR_setWorkInt( charaindex, CHAR_WORKQUICK, CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX)*0.8);//敏降20% + } +#endif + switch( COM ){//处理攻击 + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + //==== 直接攻击系 =============================================================== + case BATTLE_COM_S_BRUST: // 爆击 + case BATTLE_COM_S_CHAIN_ATK: // 连环攻击 + case BATTLE_COM_S_CHAIN_ATK_2: // 双重攻击 + case BATTLE_COM_S_CAVALRY: // 座骑攻击 + case BATTLE_COM_S_DEAD_ATTACK: // 濒死攻击 + case BATTLE_COM_S_ATTACK_WEAK: // 弱点攻击 + case BATTLE_COM_S_PLUNDER: // 体掠夺 + case BATTLE_COM_S_CHAOS: // 混乱攻击 + { + // 防止同队互打 + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + if( BATTLE_CheckSameSide( charaindex, defNo) == 1 ){ + BATTLE_NoAction( battleindex, attackNo ); break; + } + } + case BATTLE_COM_S_ENRAGE_PET: // 激怒宠物 + { + CHAR_setFlg( charaindex, CHAR_ISATTACKED, 1 ); + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + battle_profession_attack_fun(battleindex, attackNo, defNo, charaindex); + //change fix 修正使用职业得不到道具 + //BATTLE_AddProfit( battleindex, aAttackList); + } + break; + //==== 魔法攻击系 ================================================================ + case BATTLE_COM_S_VOLCANO_SPRINGS: // 火山泉 + case BATTLE_COM_S_FIRE_BALL: // 火星球 + case BATTLE_COM_S_FIRE_SPEAR: // 火龙枪 + case BATTLE_COM_S_SUMMON_THUNDER: // 召雷术 + case BATTLE_COM_S_CURRENT: // 电流术 + case BATTLE_COM_S_STORM: // 暴风雨 + case BATTLE_COM_S_ICE_ARROW: // 冰箭 + case BATTLE_COM_S_ICE_CRACK: // 冰爆术 + case BATTLE_COM_S_ICE_MIRROR: // 冰镜术 + case BATTLE_COM_S_DOOM: // 世界末日 + case BATTLE_COM_S_BLOOD_WORMS: // 嗜血蛊 + case BATTLE_COM_S_SIGN: // 一针见血 + case BATTLE_COM_S_ENCLOSE: // 附身术 + case BATTLE_COM_S_THROUGH_ATTACK: // 贯穿攻击 + case BATTLE_COM_S_CONVOLUTE: // 回旋攻击 + { +#ifdef _PROFESSION_ADDSKILL + /* if( COM == BATTLE_COM_S_DOOM //世界末日集气 + || COM == BATTLE_COM_S_FIRE_SPEAR){ + if( CHAR_getWorkInt( charaindex, CHAR_DOOMTIME ) > 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + sprintf( szWork, "bt|%x|", attackNo ); + BATTLESTR_ADD( szWork ); + break; + } + }*/ +#endif + // 防止同队互打 + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + if( BATTLE_CheckSameSide( charaindex, defNo) == 1 ){ + BATTLE_NoAction( battleindex, attackNo ); break; + } + } + case BATTLE_COM_S_BLOOD: // 嗜血成性 + { + CHAR_setFlg( charaindex, CHAR_ISATTACKED, 1 ); + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); +#if 1 // Robin fix 修正嗜血吸别人的血 + if( defNo != attackNo && COM == BATTLE_COM_S_BLOOD ){ + print("\n 改封包!嗜血吸别人的血!!:%s ", CHAR_getChar( charaindex, CHAR_CDKEY) ); + defNo = attackNo; + + CHAR_talkToCli( charaindex, -1, "因封包异常而断线。", CHAR_COLORYELLOW); + CONNECT_setCloseRequest( CHAR_getWorkInt( charaindex, CHAR_WORKFD ) , 1 ); + break; + } +#endif +#ifdef _PROFESSION_ADDSKILL + if( COM == BATTLE_COM_S_ICE_CRACK ){ + if( pBattle->ice_count >= 20 ) + pBattle->ice_count = 0; + pBattle->ice_use[pBattle->ice_count] = TRUE; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + pBattle->ice_level[pBattle->ice_count] = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + pBattle->ice_bout[pBattle->ice_count] = 2; + pBattle->ice_toNo[pBattle->ice_count] = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + pBattle->ice_array[pBattle->ice_count] = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3); + pBattle->ice_charaindex[pBattle->ice_count] = charaindex; + pBattle->ice_attackNo[pBattle->ice_count] = attackNo; + ++pBattle->ice_count; + BATTLE_NoAction( battleindex, attackNo ); + print("\n进入冰爆"); + break; + } +#endif + battle_profession_attack_magic_fun(battleindex, attackNo, defNo, charaindex); + //change fix 修正使用职业得不到道具 + //BATTLE_AddProfit( battleindex, aAttackList); + break; + } + //==== 提升自已能力系 ==================================================================== + case BATTLE_COM_S_FOCUS: // 专注战斗 + case BATTLE_COM_S_AVOID: // 回避 + case BATTLE_COM_S_RECOVERY: // 补血 + case BATTLE_COM_S_SCAPEGOAT: // 舍已为友 + case BATTLE_COM_S_ENRAGE: // 激化攻击 + case BATTLE_COM_S_COLLECT: // 能量聚集 + case BATTLE_COM_S_TRAP: // 陷阱 + case BATTLE_COM_S_TRANSPOSE: // 移形换位 + case BATTLE_COM_S_DOCILE: // 驯伏宠物 +#ifdef _PROFESSION_ADDSKILL + case BATTLE_COM_S_CALL_NATURE: // 号召自然 +#endif + { + CHAR_setFlg( charaindex, CHAR_ISATTACKED, 1 ); + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + battle_profession_assist_fun(battleindex, attackNo, defNo, charaindex); + break; + } + //==== 击中改变状态系 ==================================================================== + case BATTLE_COM_S_SHIELD_ATTACK: // 盾击 + case BATTLE_COM_S_ENTWINE: // 树根缠绕 + case BATTLE_COM_S_DRAGNET: // 天罗地网 + case BATTLE_COM_S_TOXIN_WEAPON: // 毒素武器 + case BATTLE_COM_S_INSTIGATE: // 挑拨 + case BATTLE_COM_S_OBLIVION: // 遗忘 + { + // 防止同队互打 + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + if( BATTLE_CheckSameSide( charaindex, defNo) == 1 ){ + BATTLE_NoAction( battleindex, attackNo ); + if( COM == BATTLE_COM_S_TOXIN_WEAPON ) + printf("\nbug-同队互打"); + break; + } + } + case BATTLE_COM_S_RESIST_FIRE: // 火抗性提升 + case BATTLE_COM_S_RESIST_ICE: // 冰抗性提升 + case BATTLE_COM_S_RESIST_THUNDER: // 雷抗性提升 +#ifdef _PROFESSION_ADDSKILL + case BATTLE_COM_S_RESIST_F_I_T: // 自然威能 + case BATTLE_COM_S_BOUNDARY: // 四属性结界 +#endif + case BATTLE_COM_S_FIRE_ENCLOSE: // 火附体 + case BATTLE_COM_S_ICE_ENCLOSE: // 冰附体 + case BATTLE_COM_S_THUNDER_ENCLOSE: // 雷附体 + { + + CHAR_setFlg( charaindex, CHAR_ISATTACKED, 1 ); + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + battle_profession_status_chang_fun(battleindex, attackNo, defNo, charaindex); + + if( COM == BATTLE_COM_S_TOXIN_WEAPON ) + printf("\nbug-毒素武器处理结束"); + break; + } + //==================================================================================== +#endif + +#ifdef _PETSKILL_ACUPUNCTURE + case BATTLE_COM_S_ACUPUNCTURE: //针刺外皮 + CHAR_setWorkInt( charaindex, CHAR_WORKACUPUNCTURE, 1); + //print("\n针刺:%s",CHAR_getChar(charaindex,CHAR_NAME)); +#endif + case BATTLE_COM_S_CHARGE_OK: + case BATTLE_COM_S_POWERBALANCE: + case BATTLE_COM_S_STATUSCHANGE: + case BATTLE_COM_S_EARTHROUND0: + case BATTLE_COM_S_MIGHTY: + case BATTLE_COM_S_GUARDIAN_ATTACK: + case BATTLE_COM_S_RENZOKU: +#ifdef _BATTLE_ATTCRAZED // ANDY 疯狂暴走 + case BATTLE_COM_S_ATTCRAZED: +#endif +#ifdef _SHOOTCHESTNUT // Syu ADD 宠技:丢栗子 + case BATTLE_COM_S_ATTSHOOT: +#endif +#ifdef _SKILL_WILDVIOLENT_ATT + case BATTLE_COM_S_WILDVIOLENTATTACK://狂暴攻击 vincent add 2002/05/16 +#endif + +#ifdef _SKILL_SPEEDY_ATT + case BATTLE_COM_S_SPEEDYATTACK: //疾速攻击 vincent add 2002/05/20 +#endif + case BATTLE_COM_ATTACK: +#ifdef _PET_SKILL_SARS // WON ADD 毒煞蔓延 + case BATTLE_COM_S_SARS: +#endif + +#ifdef _PETSKILL_BECOMEFOX + case BATTLE_COM_S_BECOMEFOX: +#endif + +#ifdef _PETSKILL_BECOMEPIG + case BATTLE_COM_S_BECOMEPIG: +#endif + +#ifdef _PETSKILL_SHOWMERCY + case BATTLE_COM_S_SHOWMERCY: +#endif + +#ifdef _PETSKILL_GYRATE + case BATTLE_COM_S_GYRATE: + if( COM == BATTLE_COM_S_GYRATE ){ + int i,j=0,f_num,temp[5]={0}; + char szWork[256]; + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + if(defNo < 5) + f_num = 0; + else if(defNo >=5 && defNo < 10) + f_num = 5; + else if(defNo >=10 && defNo < 15) + f_num = 10; + else + f_num = 15; + + // 取出战场上存活的人 + for( i=f_num; i= 10 ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + defNo = aDefList[0]; + }else + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 + || defNo == attackNo){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + if( COM == BATTLE_COM_S_EARTHROUND0 ){ + sprintf( szWork, "BI|a%X|", attackNo ); + }else { +#ifdef _FIXBUG_ATTACKBOW + if( CHAR_getWorkInt( charaindex, CHAR_WORKITEMMETAMO) > 0 || + CHAR_getWorkInt( charaindex, CHAR_WORKNPCMETAMO) > 0 + || CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND ) != -1 ){ //若是变成小狐狸 + + if( gWeponType == ITEM_BOW || gWeponType == ITEM_BOUNDTHROW || + gWeponType == ITEM_BREAKTHROW || gWeponType == ITEM_BOOMERANG) { + CHAR_talkToCli( charaindex, -1, "变身中无法使用远距离武器!!", CHAR_COLORYELLOW); + continue; + } + + } +#endif + + if( gWeponType == ITEM_BOW ) sprintf( szWork, "BB|a%X|w0|", attackNo ); + else if( gWeponType == ITEM_BOUNDTHROW ) //若是丢斧头 + sprintf( szWork, "BB|a%X|w1|", attackNo ); + else if( gWeponType == ITEM_BREAKTHROW ) + sprintf( szWork, "BB|a%X|w2|", attackNo ); + else sprintf( szWork, "BH|a%X|", attackNo ); + } + +#ifdef _SHOOTCHESTNUT // Syu ADD 宠技:丢栗子 + if ( COM == BATTLE_COM_S_ATTSHOOT ) + sprintf( szWork, "BB|a%X|w0|", attackNo ); +#endif + + BATTLESTR_ADD( szWork ); + if( COM == BATTLE_COM_S_CHARGE_OK || + COM == BATTLE_COM_S_EARTHROUND0 ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + }else{ + +#ifdef _SHOOTCHESTNUT // Syu ADD 宠技:丢栗子 + if ( CHAR_getWorkInt(charaindex, CHAR_WORKBATTLECOM1) != BATTLE_COM_S_ATTSHOOT) +#endif +#ifdef _PETSKILL_SHOWMERCY + if( CHAR_getWorkInt(charaindex, CHAR_WORKBATTLECOM1) != BATTLE_COM_S_SHOWMERCY) +#endif + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1,BATTLE_COM_ATTACK ); + } + for( attack_count = 0, k = 0;; ){ + if( gWeponType == ITEM_BOW ){ + if( BATTLE_TargetCheck( battleindex, defNo ) == FALSE ){ + attack_flg = 0; + }else{ + attack_flg = 1; + } + } + + + if( attack_flg ){ + + + ContFlg = BATTLE_Attack( battleindex, attackNo, defNo ); +#ifdef _PETSKILL_RETRACE + if( Battle_Attack_ReturnData_x.Battle_Attack_ReturnData == BATTLE_RET_DODGE + && COM == BATTLE_COM_S_RETRACE ){ + if( RAND(1,100) < 80 ){ //80%机率发动2次攻击 + //攻+20% + + CHAR_setWorkInt( BATTLE_No2Index( battleindex, attackNo ), + CHAR_WORKATTACKPOWER, + ( CHAR_getWorkInt( BATTLE_No2Index( battleindex, attackNo ), CHAR_WORKFIXSTR) + ( CHAR_getWorkInt( BATTLE_No2Index( battleindex, attackNo ), CHAR_WORKFIXSTR) * 0.2 ) ) ); + + BATTLE_Attack( battleindex, attackNo, defNo ); + + } + Battle_Attack_ReturnData_x.Battle_Attack_ReturnData = 0; + } +#endif + BATTLE_AddProfit( battleindex, aAttackList); + if( ++attack_count >= attack_max ) break; + if( CHAR_getInt( charaindex, CHAR_HP ) <= 0 ) { + ContFlg = FALSE; + break; + } + } + defNo = aDefList[++k]; + if( defNo < 0 ) break; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, defNo ); + if( gWeponType == ITEM_BOW ){ + }else + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + break; + } + if( BATTLE_CountAlive( battleindex, 0) == 0 || BATTLE_CountAlive( battleindex, 1) == 0) { + break; + } + } + gBattleDamageModyfy = 1.0; + gBattleDuckModyfy = 0; + + for( k = 0; k < 5 && ContFlg == TRUE; k ++ ){ + if( ( k & 1 ) == 1 ){ + attackNoSub = attackNo; + defNoSub = defNo; + }else{ + defNoSub = attackNo; + attackNoSub = defNo; + } + + ContFlg = BATTLE_Counter(battleindex, attackNoSub, defNoSub ); + + aAttackList[0] = attackNoSub; + aAttackList[1] = -1; + BATTLE_AddProfit( battleindex, aAttackList); + } + aAttackList[0] = -1; + BATTLESTR_ADD( "FF|" ); + +#ifdef _PETSKILL_BECOMEFOX // 向对方使用媚惑术 + if ( (COM == BATTLE_COM_S_BECOMEFOX ) + && (Battle_Attack_ReturnData_x.Battle_Attack_ReturnData != BATTLE_RET_MISS) //没有miss + && (Battle_Attack_ReturnData_x.Battle_Attack_ReturnData != BATTLE_RET_DODGE) //没有闪避过 + && (Battle_Attack_ReturnData_x.Battle_Attack_ReturnData != BATTLE_RET_ALLGUARD) + && (Battle_Attack_ReturnData_x.Battle_Attack_ReturnData != BATTLE_RET_ARRANGE) + && (BATTLE_TargetCheck( battleindex, defNo )) //还活着 + && (rand()%100 < 31) + && (CHAR_getInt( BATTLE_No2Index( battleindex, defNo ), CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER) //只有宠物(CHAR_TYPEPET)才可以被媚惑 + && (CHAR_getWorkInt( BATTLE_No2Index( battleindex, defNo ), CHAR_WORK_PETFLG ) != 0 ) +#ifdef _PETSKILL_BECOMEPIG + && (CHAR_getInt( charaindex, CHAR_BECOMEPIG) == -1)//没有处於乌力化 +#endif + ) + { + int ToList[SIDE_OFFSET*2+1]; + int defindex = BATTLE_No2Index( battleindex, defNo ); + + BATTLE_MultiList( battleindex, defNo, ToList ); + BATTLE_MagicEffect( battleindex, defNo, ToList, 101120, 101750); + + CHAR_setWorkInt( defindex, CHAR_WORKFOXROUND, pBattle->turn ); + + if( CHAR_getInt( defindex, CHAR_RIDEPET) != -1 ) { //骑宠就要让他落马 + CHAR_setInt( defindex, CHAR_RIDEPET, -1 ); + BATTLE_changeRideImage( defindex ); + CHAR_setWorkInt( defindex, CHAR_WORKPETFALL, 1 ); + } + + CHAR_setInt( defindex, CHAR_BASEIMAGENUMBER, 101749); + } +#endif +#ifdef _PETSKILL_BECOMEPIG // 向对方使用乌力化 + if ( (COM == BATTLE_COM_S_BECOMEPIG ) + && (Battle_Attack_ReturnData_x.Battle_Attack_ReturnData != BATTLE_RET_MISS) //没有miss + && (Battle_Attack_ReturnData_x.Battle_Attack_ReturnData != BATTLE_RET_DODGE) //没有闪避过 + && (Battle_Attack_ReturnData_x.Battle_Attack_ReturnData != BATTLE_RET_ALLGUARD) + && (Battle_Attack_ReturnData_x.Battle_Attack_ReturnData != BATTLE_RET_ARRANGE) + && (BATTLE_TargetCheck( battleindex, defNo )) //还活着 + && (CHAR_getInt( BATTLE_No2Index( battleindex, defNo ), CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER) //只有玩家才可以被乌力化 + && (BATTLE_CheckSameSide( charaindex, defNo) != 1 ) // 防止同队互打 + && CHAR_getInt( BATTLE_No2Index( battleindex, defNo ), CHAR_BECOMEPIG) < 2000000000 ) //防止破表 + { + char temp[64]; + int ToList[SIDE_OFFSET*2+1], compute,petrate,pettime,pigbbi=100250; + char *pszOption=NULL; + int defindex = BATTLE_No2Index( battleindex, defNo ); + pszOption = PETSKILL_getChar( CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3 ), PETSKILL_OPTION ); + if( pszOption ) + sscanf( pszOption, "%d %d %d", &petrate, &pettime, &pigbbi); + else + petrate = 100, pettime = 60, pigbbi = 100250; + + if( rand()%100 < petrate ){ + CHAR_setWorkInt( defindex, CHAR_WORKITEMMETAMO, 0);//道具变身取消 + CHAR_setWorkInt( defindex, CHAR_WORKNPCMETAMO, 0 );//NPC变身取消 + CHAR_setWorkInt( defindex, CHAR_WORKFOXROUND, -1);//媚惑术变身取消 + + BATTLE_MultiList( battleindex, defNo, ToList ); + BATTLE_MagicEffect( battleindex, defNo, ToList, 101120, 101750); + + if( CHAR_getInt( defindex, CHAR_RIDEPET) != -1 ){ //骑宠就要让他落马 + CHAR_setInt( defindex, CHAR_RIDEPET, -1 ); + BATTLE_changeRideImage( defindex ); + CHAR_setWorkInt( defindex, CHAR_WORKPETFALL, 1 ); + } + + CHAR_setInt( defindex, CHAR_BECOMEPIG_BBI, pigbbi ); + + compute = CHAR_getInt( defindex, CHAR_BECOMEPIG); + CHAR_setInt( defindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( defindex, CHAR_BECOMEPIG_BBI ) ); + if( compute == -1 )//第一次中 + CHAR_setInt( defindex, CHAR_BECOMEPIG, pettime + 1 + compute ); //乌力化时间(单位:秒) + else + CHAR_setInt( defindex, CHAR_BECOMEPIG, pettime + compute ); + sprintf(temp, "乌力时间:%d秒", CHAR_getInt( defindex, CHAR_BECOMEPIG) ); + CHAR_talkToCli( defindex, -1, temp, CHAR_COLORYELLOW); + + print("\n乌力化开始0:%s,round:%d", CHAR_getChar( defindex, CHAR_NAME), CHAR_getWorkInt( defindex, CHAR_WORKFOXROUND)); + } + } +#endif + break; +//以下处理特殊攻击 + case BATTLE_COM_BOOMERANG: + gBattleDamageModyfy = 0.3; + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + if( defNo < 0 ){ + defNo = BATTLE_DefaultAttacker( battleindex, 1 - myside ); + } + if( 0 <= defNo && defNo <= 19 ){ + defNo /= 5; // + }else{ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + if( (int)(attackNo / 5 ) == defNo ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + { + int *pBoomerangTbl = BoomerangVsTbl[defNo]; + for( k = 0; k < 5; k ++ ){ + if( BATTLE_TargetCheck( battleindex, pBoomerangTbl[k] ) == FALSE ){ + continue; + }else{ + break; + } + } + if( k == 5 ){ + defNo = BATTLE_DefaultAttacker( battleindex, 1 - myside ); + if( 0 <= defNo && defNo <= 19 ){ + defNo /= 5; + }else{ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + } + } + sprintf( szWork, "BO|a%X|", attackNo ); + BATTLESTR_ADD( szWork ); + { + int *pBoomerangTbl = BoomerangVsTbl[defNo]; + if( myside == 1 ){ + k = 4; j = -1; + }else{ + k = 0; j = 1; + } + for( ; ; k += j ){ + if( j > 0 && k > 4 )break; + if( j < 0 && k < 0 )break; + defNo = pBoomerangTbl[k]; + if( BATTLE_TargetCheck( battleindex, defNo ) == FALSE ){ + continue; + } + BATTLE_Attack( battleindex, attackNo, defNo ); + } + } + gBattleDamageModyfy = 1.0; + gBattleDuckModyfy = 0; + BATTLESTR_ADD( "FF|" ); + break; + + //--------------------------------------------- + case BATTLE_COM_CAPTURE: + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + BATTLE_Capture( battleindex, attackNo, defNo ); + break; + + //--------------------------------------------- +#ifdef _VARY_WOLF + case BATTLE_COM_S_VARY: + { + int ToList[SIDE_OFFSET*2+1]; + int bk_amn = 0; + + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + bk_amn = (CHAR_getInt( charaindex, CHAR_BASEBASEIMAGENUMBER) + 5) + (myside*4); + BATTLE_MultiList( battleindex, defNo, ToList ); + BATTLE_MagicEffect( battleindex, attackNo, ToList, 101120, bk_amn); + } + break; +#endif + case BATTLE_COM_GUARD: + BATTLE_Guard( battleindex, attackNo ); + + break; + case BATTLE_COM_ESCAPE: + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPET ){ + if (BATTLE_Escape(battleindex, attackNo, 0) == TRUE) + { + if (CHAR_getWorkInt(charaindex, CHAR_WORKFMPKFLAG) == 1) + CHAR_setWorkInt(charaindex, CHAR_WORKFMPKFLAG, -1); +#ifdef _ESCAPE_RESET // 恶宝中纪录逃跑时间 + if( getStayEncount( getfdFromCharaIndex(charaindex) ) ) { + CHAR_setWorkInt( charaindex, CHAR_WORKLASTESCAPE, time(NULL)); + //print(" 逃了 "); + } +#endif + } + } + break; + case BATTLE_COM_COMPELESCAPE: //强制离开 + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPET ){ + BATTLE_Escape( battleindex, attackNo, 1); + if (CHAR_getWorkInt(charaindex, CHAR_WORKFMPKFLAG) == 1) + CHAR_setWorkInt(charaindex, CHAR_WORKFMPKFLAG, -1); + } + break; + + case BATTLE_COM_PETIN: + if( CHAR_getInt( charaindex, CHAR_DEFAULTPET ) == -1 ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + { + char szWork[256]; + snprintf( szWork, sizeof( szWork ), "K%d", CHAR_getInt( charaindex, CHAR_DEFAULTPET ) ); + CHAR_sendStatusString( charaindex, szWork ); + + } + BATTLE_PetIn( battleindex, attackNo ); + lssproto_KS_send( + getfdFromCharaIndex( charaindex ), + CHAR_getInt( charaindex, CHAR_DEFAULTPET ), 1 ); + break; + case BATTLE_COM_PETOUT: + if( CHAR_getInt( charaindex, CHAR_DEFAULTPET ) != -1 ){ + lssproto_KS_send( + getfdFromCharaIndex( charaindex ), + CHAR_getInt( charaindex, CHAR_DEFAULTPET ), 1 ); + { + char szWork[256]; + snprintf( szWork, sizeof( szWork ), "K%d", CHAR_getInt( charaindex, CHAR_DEFAULTPET ) ); + CHAR_sendStatusString( charaindex, szWork ); + + } + BATTLE_PetIn( battleindex, attackNo ); + } + // shan 2002/01/14 Begin 五只宠 + { + int attackindex, petNo; + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + petNo = CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM2 ); + if( CHAR_getWorkInt(charaindex, CHAR_WORK_PET0_STAT+petNo) != PET_STAT_SELECT) + break; + } + // shan End + BATTLE_PetOut( battleindex, attackNo ); + lssproto_KS_send( + getfdFromCharaIndex( charaindex ), + CHAR_getInt( charaindex, CHAR_DEFAULTPET ), 1 ); + break; +// Terry add 2001/11/05 +#ifdef __ATTACK_MAGIC + case BATTLE_COM_S_ATTACK_MAGIC: // 宠物魔法 + magic = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + toindex = CHAR_getWorkInt(charaindex,CHAR_WORKBATTLECOM2); +// print("magic->%d,toindex->%d\n",magic,toindex); + // 判断攻 围 + for(magic_count=0;magic_count= 0 && toindex <= 4) + toindex = TargetIndex[magic_count][1]; + // 打右下的前面那一排 + else + toindex = TargetIndex[magic_count][1]-1; + } + break; + } + } +// print("toindex->%d\n",toindex); + MAGIC_DirectUse(charaindex,magic,toindex,CHAR_GETWORKINT_HIGH(charaindex,CHAR_WORKBATTLECOM3)); + BATTLE_AddProfit( battleindex, aAttackList ); + break; +#endif + case BATTLE_COM_JYUJYUTU: + MAGIC_DirectUse( + charaindex, + CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3 ), + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ), + CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3 ) + ); + break; + + case BATTLE_COM_ITEM: + itemindex = CHAR_getItemIndex(charaindex, + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM3 )); + if( ITEM_CHECKINDEX( itemindex ) == FALSE ){ + print( "\nerr:要使用的item位置奇怪(%s)(%d)\n", + CHAR_getUseName( charaindex ), CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM3 ) ); + break; + } + +#if 1 // Robin fix 战斗不可换防具饰品 + { + int itemtype = ITEM_getInt( itemindex, ITEM_TYPE ); + if( itemtype == ITEM_HELM + || itemtype == ITEM_ARMOUR + || itemtype == ITEM_BRACELET + //|| itemtype == ITEM_MUSIC + || itemtype == ITEM_NECKLACE + || itemtype == ITEM_RING + || itemtype == ITEM_BELT + || itemtype == ITEM_EARRING + || itemtype == ITEM_NOSERING + || itemtype == ITEM_AMULET + //|| itemtype == CHAR_HEAD + ) + { + print("\n 改封包!战斗不可换防具!!:%s ", CHAR_getChar( charaindex, CHAR_CDKEY) ); + break; + } + } +#endif + +#ifdef _FIXBUG_ATTACKBOW + { + if( CHAR_getWorkInt( charaindex, CHAR_WORKITEMMETAMO) > 0 || + CHAR_getWorkInt( charaindex, CHAR_WORKNPCMETAMO) > 0 + || CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND ) != -1 ){ //若是变成小狐狸 + + int armtype; + int itemindex = CHAR_getItemIndex( charaindex, CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM3 )); + if( !ITEM_CHECKINDEX(itemindex) ) break; + armtype = ITEM_getInt( itemindex, ITEM_TYPE ); + + if( armtype == ITEM_BOW || armtype == ITEM_BOUNDTHROW || + armtype == ITEM_BREAKTHROW || armtype == ITEM_BOOMERANG) { + CHAR_talkToCli( charaindex, -1, "变身无法使用远距离武器!", CHAR_COLORYELLOW ); + break; + } + } + } +#endif + + CHAR_ItemUse( + charaindex, + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ), + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM3 ) + ); + + + if( ITEM_getEquipPlace( charaindex, itemindex ) == CHAR_ARM ){ + sprintf( szWork, "BN|a%X|%X|", attackNo, + CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER ) ); + BATTLESTR_ADD( szWork ); + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + // 武器专精 + BATTLE_ProfessionStatus_init( battleindex, charaindex ); +#endif + + }else{ + } + + break; + +#ifdef _PSKILL_FALLGROUND + case BATTLE_COM_S_FALLRIDE://落马术 + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + print("\n BATTLE_NoAction()"); + break; + } + ContFlg = BATTLE_S_FallGround( battleindex, attackNo, defNo, BATTLE_COM_S_FALLRIDE); + break; + +#endif +#ifdef _PETSKILL_EXPLODE + case BATTLE_COM_S_EXPLODE: + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + print("\n BATTLE_NoAction()"); + break; + } + ContFlg = BATTLE_S_Explode( battleindex, attackNo, defNo, BATTLE_COM_S_EXPLODE); + break; +#endif + +#ifdef _PETSKILL_TIMID + case BATTLE_COM_S_TIMID: + { + int skill; + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + print("\n BATTLE_NoAction()"); + break; + } + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_TIMID, skill); + } + break; +#endif +#ifdef _PETSKILL_2TIMID + case BATTLE_COM_S_2TIMID: + { + int skill; + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + print("\n BATTLE_NoAction()"); + break; + } + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_2TIMID, skill); + } + break; +#endif + +#ifdef _PETSKILL_PROPERTY + case BATTLE_COM_S_PROPERTYSKILL: + { + int skill; + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + BATTLE_S_PetSkillProperty( battleindex, attackNo, COM, skill); + BATTLE_NoAction( battleindex, attackNo ); + } + break; +#endif + +#ifdef _BATTLE_LIGHTTAKE + case BATTLE_COM_S_LIGHTTAKE: + { + int skill; + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + print("\n BATTLE_NoAction()"); + break; + } + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_LIGHTTAKE, skill); + } + break; +#endif + +#ifdef _SKILL_DAMAGETOHP + case BATTLE_COM_S_DAMAGETOHP: //嗜血技 + { + int skill; + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + print("\n BATTLE_NoAction()"); + break; + } + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_DAMAGETOHP, skill); + } + break; +#endif + +#ifdef _PETSKILL_DAMAGETOHP + case BATTLE_COM_S_DAMAGETOHP2: //暗月狂狼(嗜血技的变体) + { + int skill,attackidxtemp; + attackidxtemp = BATTLE_No2Index( battleindex, attackNo ); + + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + print("\n BATTLE_NoAction()"); + break; + } + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_DAMAGETOHP2, skill); + + } + break; +#endif + +#ifdef _Skill_MPDAMAGE + case BATTLE_COM_S_MPDAMAGE: //MP伤害 + { + int skill; + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + print("\n BATTLE_NoAction()"); + break; + } + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_MPDAMAGE, skill); + break; + } + break; +#endif +#ifdef _SKILL_TOOTH + case BATTLE_COM_S_TOOTHCRUSHE: + { + int skill; + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + print("\n BATTLE_NoAction()"); + break; + } + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_TOOTHCRUSHE, skill); + break; + } + break; +#endif +#ifdef _PSKILL_MODIFY + case BATTLE_COM_S_MODIFYATT: + { + int skill; + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + print("\n BATTLE_NoAction()"); + break; + } + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_MODIFYATT, skill); + } + break; +#endif +#ifdef _PSKILL_MDFYATTACK + case BATTLE_COM_S_MDFYATTACK: + { + int skill; + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + print("\n BATTLE_NoAction()"); + break; + } + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_MDFYATTACK, skill); + } + break; +#endif + +#ifdef _PETSKILL_TEAR + case BATTLE_COM_S_PETSKILLTEAR: + { + int skill; + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + print("\n BATTLE_NoAction()"); + break; + } + skill = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3); + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_PETSKILLTEAR, skill); + } + break; +#endif + +#ifdef _SONIC_ATTACK // WON ADD 音波攻击 + case BATTLE_COM_S_SONIC: + { + int skill, defNo2=-1, index2=-1; + + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + print("\n BATTLE_NoAction()"); + break; + } + skill = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3); + + if( defNo >= 15 && defNo < 20 ) defNo2 = defNo - 5; + else if( defNo >= 5 && defNo < 10 ) defNo2 = defNo - 5; + else defNo2 = -1; + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + index2 = BATTLE_No2Index( battleindex, defNo2 ); + + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_SONIC, skill ); + + if( index2 >= 0 ){ + if( defNo2 >= 0 ){ + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo2, BATTLE_COM_S_SONIC2, skill ); + } + } + + } + break; +#endif + +#ifdef _PETSKILL_REGRET + case BATTLE_COM_S_REGRET: + { + int skill, defNo2=-1, index2=-1; + + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + print("\n BATTLE_NoAction()"); + break; + } + skill = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3); + + if( defNo >= 15 && defNo < 20 ) defNo2 = defNo - 5; + else if( defNo >= 5 && defNo < 10 ) defNo2 = defNo - 5; + else defNo2 = -1; + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + index2 = BATTLE_No2Index( battleindex, defNo2 ); + + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_REGRET, skill ); + if( index2 >= 0 ){ + if( defNo2 >= 0 ){ + ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo2, BATTLE_COM_S_REGRET2, skill ); + } + } + + } + break; +#endif + +#ifdef _MAGIC_SUPERWALL + case BATTLE_COM_S_SUPERWALL: + { + int skill; + defNo = CHAR_getWorkInt(charaindex,CHAR_WORKBATTLECOM2); + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + ContFlg = PETSKILL_MagicStatusChange_Battle( battleindex, attackNo, defNo, skill); + } + break; +#endif +#ifdef _PETSKILL_SETDUCK + case BATTLE_COM_S_SETDUCK: + { + int skill; + defNo = CHAR_getWorkInt(charaindex,CHAR_WORKBATTLECOM2); + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + ContFlg = PETSKILL_SetDuckChange_Battle( battleindex, attackNo, defNo, skill); + break; + } +#endif +#ifdef _MAGICPET_SKILL + case BATTLE_COM_S_SETMAGICPET: + { + int skill; + defNo = CHAR_getWorkInt(charaindex,CHAR_WORKBATTLECOM2); + skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + ContFlg = PETSKILL_SetMagicPet_Battle( battleindex, attackNo, defNo, skill); + break; + } +#endif +#ifdef _PRO_BATTLEENEMYSKILL + case BATTLE_COM_S_ENEMYRELIFE: + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + print("\n BATTLE_NoAction()"); + break; + } + + ContFlg =BATTLE_E_ENEMYREFILE( battleindex, attackNo, defNo, BATTLE_COM_S_ENEMYRELIFE); + if( ContFlg == FALSE ) { + CHAR_setFlg( charaindex, CHAR_ISATTACKED, 1 ); + ContFlg = BATTLE_Attack( battleindex, attackNo, defNo ); + BATTLE_AddProfit( battleindex, aAttackList ); + } + BATTLE_AddProfit( battleindex, aAttackList ); + break; + + case BATTLE_COM_S_ENEMYREHP: + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + print("\n BATTLE_NoAction()"); + break; + } + ContFlg =BATTLE_E_ENEMYREHP( battleindex, attackNo, defNo, BATTLE_COM_S_ENEMYREHP); + if( ContFlg == FALSE ) { + CHAR_setFlg( charaindex, CHAR_ISATTACKED, 1 ); + ContFlg = BATTLE_Attack( battleindex, attackNo, defNo ); + BATTLE_AddProfit( battleindex, aAttackList ); + } + BATTLE_AddProfit( battleindex, aAttackList ); + break; + + case BATTLE_COM_S_ENEMYHELP: + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + print("\n BATTLE_NoAction()"); + break; + } + ContFlg =BATTLE_E_ENEMYHELP( battleindex, attackNo, defNo, BATTLE_COM_S_ENEMYREHP); + if( ContFlg == FALSE ) { + CHAR_setFlg( charaindex, CHAR_ISATTACKED, 1 ); + ContFlg = BATTLE_Attack( battleindex, attackNo, defNo ); + BATTLE_AddProfit( battleindex, aAttackList ); + } + BATTLE_AddProfit( battleindex, aAttackList ); + break; +#endif + case BATTLE_COM_S_GBREAK: //破除防御 + + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + ContFlg = BATTLE_S_GBreak( battleindex, attackNo, defNo ); + break; +#ifdef _SKILL_GUARDBREAK2//破除防御2 vincent add 2002/05/20 + case BATTLE_COM_S_GBREAK2: + //确定攻击对象 + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + ContFlg = BATTLE_S_GBreak2( battleindex, attackNo, defNo ); + break; +#endif + +#ifdef _SKILL_SACRIFICE + case BATTLE_COM_S_SACRIFICE://救援 vincent add 2002/05/30 + //确定攻击对象 + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + ContFlg = BATTLE_S_Sacrifice( battleindex, attackNo, defNo ); + + break; +#endif + +#ifdef _SKILL_REFRESH + case BATTLE_COM_S_REFRESH://状态回复 vincent add 2002/08/08 + { + int array; + array = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); +// print("\n vincent--case BATTLE_COM_S_REFRESH:-->defNo:%d",defNo); + ContFlg = BATTLE_S_Refresh( battleindex, attackNo, defNo ,array); + } + break; +#endif + +#ifdef _SKILL_WEAKEN //vincent宠技:虚弱 + case BATTLE_COM_S_WEAKEN: + { + int array; + array = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + //print("\n vincent--case BATTLE_COM_S_WEAKEN:-->defNo:%d",defNo); + ContFlg = BATTLE_S_Weaken( battleindex, attackNo, defNo ,array); + } + break; +#endif + +#ifdef _SKILL_DEEPPOISON //vincent宠技:剧毒 + case BATTLE_COM_S_DEEPPOISON: + { + int array; + array = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + ContFlg = BATTLE_S_Deeppoison( battleindex, attackNo, defNo ,array); + } + break; +#endif + +#ifdef _SKILL_BARRIER //vincent宠技:魔障 + case BATTLE_COM_S_BARRIER: + { + int array; + array = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + ContFlg = BATTLE_S_Barrier( battleindex, attackNo, defNo ,array); + } + break; +#endif + +#ifdef _SKILL_NOCAST //vincent宠技:沉默 + case BATTLE_COM_S_NOCAST: + { + int array; + array = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + ContFlg = BATTLE_S_Nocast( battleindex, attackNo, defNo ,array); + } + break; +#endif + +#ifdef _SKILL_ROAR //vincent宠技:大吼 + case BATTLE_COM_S_ROAR: + { + int array; + //确定攻击对象 + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + array = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3); + ContFlg = BATTLE_S_Roar( battleindex, attackNo, defNo ,array); + } + break; +#endif + case BATTLE_COM_S_ABDUCT: + { + int array; + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + array = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3); + BATTLE_Abduct( battleindex, attackNo, defNo, array); + } + break; + case BATTLE_COM_COMBO: + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + gDamageDiv = 1.0; + ComboId = EntryList[i].combo; + aAttackList[0] = EntryList[i].num; // 伉旦玄卞笛尹月 + i ++; // 戚及谛井日 + k = 1; + for( ; EntryList[i].combo == ComboId && i < entrynum; i ++ ){ + int charmode; + // 绣箕允月井民尼永弁 + if( CHAR_CHECKINDEX( EntryList[i].charaindex ) == FALSE )continue; + + // 爵 卞辅笛仄化中卅中桦宁反戚尺 + charmode = CHAR_getWorkInt( EntryList[i].charaindex, CHAR_WORKBATTLEMODE ); + if( charmode == 0 || charmode == BATTLE_CHARMODE_FINAL ){ + continue; + } + + // 旦 □正旦唱橘荚汊↓ 质 + BATTLE_StatusSeq( EntryList[i].charaindex ); +#ifdef _OTHER_MAGICSTAUTS + BATTLE_MagicStatusSeq( EntryList[i].charaindex ); +#endif + // 仃卅井匀凶桦宁 + if( BATTLE_CanMoveCheck( EntryList[i].charaindex ) == FALSE ){ + continue; + } + if( CHAR_getInt( EntryList[i].charaindex, CHAR_HP ) <= 0 ){ + continue; + } + aAttackList[k++] = EntryList[i].num; + } + aAttackList[k] = -1; + i--; + if( k == 1 ){ + print( "\nerr:一人combo bug\n" ); + } + sprintf( szWork, "BY|r%X|", defNo ); + BATTLESTR_ADD( szWork ); + BATTLE_Combo( battleindex, aAttackList, defNo ); + +#ifdef _Item_ReLifeAct + BATTLE_AddProfit( battleindex, aAttackList ); +#endif + // 反 FF 毛仁匀勾仃月 + BATTLESTR_ADD( "FF|" ); + break; + + //--------------------------------------------- + case BATTLE_COM_WAIT: + case BATTLE_COM_NONE: + BATTLE_NoAction( battleindex, attackNo ); + break; + + //--------------------------------------------- + case BATTLE_COM_S_EARTHROUND1: + BATTLE_EarthRoundHide( battleindex, attackNo ); + break; + + //--------------------------------------------- + case BATTLE_COM_S_LOSTESCAPE: + BATTLE_LostEscape( battleindex, attackNo ); + break; + + case BATTLE_COM_S_STEAL: + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + BATTLE_Steal( battleindex, attackNo, defNo ); + break; + +#ifdef _BATTLESTEAL_FIX + case BATTLE_COM_S_STEALMONEY: + if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){ + BATTLE_NoAction( battleindex, attackNo ); + break; + } + BATTLE_StealMoney( battleindex, attackNo, defNo) ; + break; +#endif + case BATTLE_COM_S_NOGUARD: + BATTLE_NoAction( battleindex, attackNo ); + break; + case BATTLE_COM_S_CHARGE: + sprintf( szWork, "bt|%x|", attackNo ); + BATTLESTR_ADD( szWork ); + break; +#ifdef _PETSKILL_LER + case BATTLE_COM_S_BAT_FLY: + { + if((defNo = BATTLE_TargetAdjust(battleindex,charaindex,myside)) < 0){ + BATTLE_NoAction(battleindex,attackNo); + break; + } + + BATTLE_BatFly(battleindex,attackNo,myside); + } + break; + case BATTLE_COM_S_DIVIDE_ATTACK: + { + if((defNo = BATTLE_TargetAdjust(battleindex,charaindex,myside)) < 0){ + BATTLE_NoAction(battleindex,attackNo); + break; + } + + BATTLE_DivideAttack(battleindex,attackNo,myside); + } + break; +#endif +#ifdef _PETSKILL_BATTLE_MODEL + case BATTLE_COM_S_BATTLE_MODEL: + BATTLE_BattleModel(battleindex,attackNo,myside); + break; +#endif + //--------------------------------------------- + default: + print( "\nerr:奇怪的命令(%d:%d:%s)\n", charaindex, COM, + CHAR_getUseName( charaindex ) ); + sprintf( szWork, "bg|%x|", attackNo ); + BATTLESTR_ADD( szWork ); + break; + } +#ifdef _VARY_WOLF + if(CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER)==101428) + { + if(CHAR_getWorkInt( charaindex, CHAR_WORKTURN)==0) + CHAR_setWorkInt( charaindex, CHAR_WORKTURN, 1); + else + CHAR_setWorkInt( charaindex, CHAR_WORKTURN, CHAR_getWorkInt( charaindex, CHAR_WORKTURN)+1); + + if(CHAR_getWorkInt( charaindex, CHAR_WORKTURN)>5) + { + CHAR_setInt( charaindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( charaindex, CHAR_BASEBASEIMAGENUMBER)); + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, CHAR_getWorkInt( charaindex, CHAR_WORKFIXSTR)); + CHAR_setWorkInt( charaindex, CHAR_WORKQUICK, CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX)); + CHAR_setWorkInt( charaindex, CHAR_WORKTURN, 0); + } + } +#endif + +#ifdef _PETSKILL_BECOMEFOX // 判断中了媚惑术後是否已到恢复的回合数 + //if(CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER)==101749) //用图号判断的话,若是人变身时,会被自动改回去 + if( CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND ) != -1 ) //若是变成小狐狸 + { + if(CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER)!=101749) + CHAR_setInt( charaindex, CHAR_BASEIMAGENUMBER, 101749 ); + + if(pBattle->turn - CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND) > 2) + { + int defNo = BATTLE_Index2No( battleindex, charaindex ); + int toNo = defNo - 5;//主人的编号 + //print("\n变身人物回复:%s,round:%d", CHAR_getChar( charaindex, CHAR_NAME), CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND)); + + CHAR_setInt( charaindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( charaindex, CHAR_BASEBASEIMAGENUMBER)); + + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, CHAR_getWorkInt( charaindex, CHAR_WORKFIXSTR)); + CHAR_setWorkInt( charaindex, CHAR_WORKDEFENCEPOWER, CHAR_getWorkInt( charaindex, CHAR_WORKFIXTOUGH)); + CHAR_setWorkInt( charaindex, CHAR_WORKQUICK, CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX)); + CHAR_setWorkInt( charaindex, CHAR_WORKFOXROUND, -1); + + //Change fix 回复宠物忘掉的技能 + sprintf( szWork, "W%d", CHAR_getInt( BATTLE_No2Index( battleindex, toNo ), CHAR_DEFAULTPET ) ); + CHAR_sendStatusString( BATTLE_No2Index( battleindex, toNo ), szWork ); + } + } +#endif +#ifdef _PETSKILL_BECOMEPIG + if( CHAR_getInt( charaindex, CHAR_BECOMEPIG) > -1 + && (CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER) ) + { + char pigbuffer[128]; + CHAR_setInt( charaindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( charaindex, CHAR_BECOMEPIG_BBI ) ); + if( CHAR_getInt( charaindex, CHAR_BECOMEPIG) > 0 ){ + sprintf(pigbuffer, "乌力时间:%d秒", CHAR_getInt( charaindex, CHAR_BECOMEPIG )); + CHAR_talkToCli( charaindex,-1,pigbuffer,CHAR_COLORWHITE); + } + else{ + sprintf(pigbuffer, " 乌力时间结束,离开战斗後可解除乌力化:%d ", CHAR_getInt( charaindex, CHAR_BECOMEPIG )); + CHAR_talkToCli( charaindex,-1,pigbuffer,CHAR_COLORWHITE); + } + } +#endif + +#ifdef _PROFESSION_ADDSKILL + { +/* for(i=0;i<20;i++){ + if( pBattle->ice_use[i] ){//冰爆准备中 + print("\n冰爆准备中"); + if( pBattle->ice_bout[i] > 0 ){//冰爆倒数 + print("\n冰爆倒数"); + if( --pBattle->ice_bout[i] == 0 ){//放冰爆 + print("\n放冰爆"); + pBattle->ice_use[i] = FALSE; + if( CHAR_CHECKINDEX(pBattle->ice_charaindex[i]) ){ + int battlecom = CHAR_getWorkInt( pBattle->ice_charaindex[i], CHAR_WORKBATTLECOM1 ); + print("\n冰爆"); + print("\nbattlecom:%d",battlecom); + CHAR_setWorkInt( pBattle->ice_charaindex[i], CHAR_WORKBATTLECOM1, BATTLE_COM_S_ICE_CRACK ); + CHAR_SETWORKINT_HIGH( pBattle->ice_charaindex[i], CHAR_WORKBATTLECOM3, pBattle->ice_level[i] ); + CHAR_setWorkInt( pBattle->ice_charaindex[i], CHAR_WORKBATTLECOM2, pBattle->ice_toNo[i] ); + CHAR_SETWORKINT_HIGH( pBattle->ice_charaindex[i], CHAR_WORKBATTLECOM3, pBattle->ice_level[i] ); + CHAR_SETWORKINT_LOW( pBattle->ice_charaindex[i], CHAR_WORKBATTLECOM3, pBattle->ice_array[i] ); + battle_profession_attack_magic_fun(battleindex, pBattle->ice_attackNo[i], pBattle->ice_toNo[i], pBattle->ice_charaindex[i]); + CHAR_setWorkInt( pBattle->ice_charaindex[i], CHAR_WORKBATTLECOM1, battlecom ); + } + } + } + } + }*/ + } + { + int earth_boundary = GETHIGHVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXEARTHAT_BOUNDARY ) ); + int water_boundary = GETHIGHVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXWATERAT_BOUNDARY ) ); + int fire_boundary = GETHIGHVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXFIREAT_BOUNDARY ) ); + int wind_boundary = GETHIGHVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXWINDAT_BOUNDARY ) ); + int boundary_turn=0; + BOOL boundaryclear = FALSE; + if( earth_boundary > 0 ){//地结界 + boundary_turn = GETLOWVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXEARTHAT_BOUNDARY ) ) - 1; +print("\n地:%d ",boundary_turn ); + if( boundary_turn <= -1 ) + CHAR_setWorkInt( charaindex, CHAR_WORKFIXEARTHAT_BOUNDARY, 0 ),boundaryclear = TRUE; + else + CHAR_setWorkInt( charaindex, CHAR_WORKFIXEARTHAT_BOUNDARY, MAKE2VALUE(earth_boundary,boundary_turn) ); + + } + if( water_boundary > 0 ){//水结界 + boundary_turn = GETLOWVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXWATERAT_BOUNDARY ) ) - 1; +print("\n水:%d ",boundary_turn ); + + if( boundary_turn <= -1 ) + CHAR_setWorkInt( charaindex, CHAR_WORKFIXWATERAT_BOUNDARY, 0 ),boundaryclear = TRUE; + else + CHAR_setWorkInt( charaindex, CHAR_WORKFIXWATERAT_BOUNDARY, MAKE2VALUE(water_boundary,boundary_turn) ); + + } + if( fire_boundary > 0 ){//火结界 + boundary_turn = GETLOWVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXFIREAT_BOUNDARY ) ) - 1; +print("\n火:%d ",boundary_turn ); + + if( boundary_turn <= -1 ) + CHAR_setWorkInt( charaindex, CHAR_WORKFIXFIREAT_BOUNDARY, 0 ),boundaryclear = TRUE; + else + CHAR_setWorkInt( charaindex, CHAR_WORKFIXFIREAT_BOUNDARY, MAKE2VALUE(fire_boundary,boundary_turn) ); + + } + if( wind_boundary > 0 ){//风结界 + boundary_turn = GETLOWVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXWINDAT_BOUNDARY ) ) - 1; +print("\n风:%d ",boundary_turn ); + + if( boundary_turn <= -1 ) + CHAR_setWorkInt( charaindex, CHAR_WORKFIXWINDAT_BOUNDARY, 0 ),boundaryclear = TRUE; + else + CHAR_setWorkInt( charaindex, CHAR_WORKFIXWINDAT_BOUNDARY, MAKE2VALUE(wind_boundary,boundary_turn) ); + + } + if( GETHIGHVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXEARTHAT_BOUNDARY ) ) == 0 + && GETHIGHVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXWATERAT_BOUNDARY ) ) == 0 + && GETHIGHVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXFIREAT_BOUNDARY ) ) == 0 + && GETHIGHVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXWINDAT_BOUNDARY ) ) == 0 + && boundaryclear ){ + int toNo = BATTLE_Index2No( battleindex, charaindex ); + if( toNo < 10 )//右方 + snprintf( szWork, sizeof( szWork ), "Ba|%X|%X|", 0,1 ); + else + snprintf( szWork, sizeof( szWork ), "Ba|%X|%X|", 0,0 ); + BATTLESTR_ADD( szWork ); + BATTLESTR_ADD( "FF|" ); + } + } +#endif + +#ifdef _Item_ReLifeAct + { + //pEntry + int k, userindex=-1; + // if( BattleArray[ battleindex].type != BATTLE_TYPE_P_vs_P){ + for( k=0; k<20; k++) { + userindex = BATTLE_getBattleDieIndex( battleindex, k); + if( !CHAR_CHECKINDEX( userindex) ) continue; + //Change fix CHECK_ITEM_RELIFE里面有检查了,这里不用 + //if( CHAR_getFlg( userindex, CHAR_ISDIE ) == FALSE ) + // continue; + if( CHAR_getInt( userindex, CHAR_HP) > 0 ) + continue; + if( CHAR_getInt( userindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ) { + CHECK_ITEM_RELIFE( battleindex, userindex); + } +#ifdef _LOSE_FINCH_ + else if( CHAR_getInt( userindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + CHECK_PET_RELIFE( battleindex, userindex); + } +#endif + } + } +#endif + BATTLESTR_ADD( szBadStatusString ); + BATTLE_AddProfit( battleindex, aAttackList );//取得经验值 + len = pszBattleTop - szBattleString; + if( AllSize + len >= sizeof( szAllBattleString ) - 1 ){ + // 引匹中匀凶井日窒手仄卅中 + }else{ + memcpy( szAllBattleString+AllSize, szBattleString, len ); + szAllBattleString[AllSize+len] = 0;// NULL 毛本永玄 + AllSize += len; + } + +#ifdef _CHECK_BATTLETIME + check_battle_com_end( COM); +#endif + + if( BATTLE_CountAlive( battleindex, 0 ) == 0 || BATTLE_CountAlive( battleindex, 1 ) == 0 ) { + break; + } + } +#ifdef _PETSKILL_LER + { + register int i,dieindex; + for(i=0;i<20;i++){ + dieindex = BATTLE_getBattleDieIndex(battleindex,i); + if(!CHAR_CHECKINDEX(dieindex)) continue; + if(CHAR_getFlg(dieindex,CHAR_ISDIE) == FALSE) continue; + if(CHAR_getInt(dieindex,CHAR_HP) > 0) continue; + // 雷尔死亡,变身 + if(CHAR_getInt(dieindex,CHAR_BASEBASEIMAGENUMBER) == 101813 || + CHAR_getInt(dieindex,CHAR_BASEBASEIMAGENUMBER) == 101814) + BATTLE_LerChange(battleindex,dieindex,i); + } + } +#endif + + szBattleString[0] = 0; + pszBattleTop = szBattleString; + pszBattleLast = szBattleString+arraysizeof(szBattleString); + if( pBattle->field_att != BATTLE_ATTR_NONE ){ + pBattle->att_count--; + if( pBattle->att_count <= 0 ){ + pBattle->field_att = BATTLE_ATTR_NONE; + //snprintf( szBuffer, sizeof(szBuffer), + // "field回复成无属性。" + //); + //BATTLE_BroadCast( battleindex, szBuffer, CHAR_COLORYELLOW ); + BATTLESTR_ADD( "BV|15|0|" ); + } + } + + strncat( szAllBattleString, szBattleString, sizeof( szAllBattleString ) ); + for( i = 0; i < entrynum; i ++ ){ + charaindex = EntryList[i].charaindex; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_RESCUE ) + continue; + + if( BATTLE_CommandSend( charaindex, szAllBattleString ) == TRUE ){ + } + } + pWatchBattle = pBattle->pNext; + for( ; pWatchBattle ; pWatchBattle = pWatchBattle->pNext ){ + if( BATTLE_CHECKADDRESS( pWatchBattle ) == FALSE ){ + print( "err:观战battle address错误(%p)\n", pWatchBattle ); + break; + } + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pWatchBattle->Side[0].Entry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + BATTLE_CommandSend( charaindex, szAllBattleString ); + } + pWatchBattle->mode = BATTLE_MODE_WATCHAFTER; + } + + return 0; +} + +#ifdef _Item_ReLifeAct +BOOL CHECK_ITEM_RELIFE( int battleindex, int toindex) +{ + int i, itemindex; + CHAR_EquipPlace ep; + typedef void (*DIERELIFEFUNC)(int,int,int); + DIERELIFEFUNC Drf; + + if( CHAR_getInt( toindex, CHAR_HP) > 0 ) + return FALSE; + +#ifdef _DUMMYDIE + if( CHAR_getFlg( toindex, CHAR_ISDIE ) == FALSE && CHAR_getFlg( toindex, CHAR_ISDUMMYDIE ) == FALSE ) +#else + if( CHAR_getFlg( toindex, CHAR_ISDIE ) == FALSE ) +#endif + return FALSE; + + for( i = 0 ; i < 5 ; i++ ){ + itemindex = CHAR_getItemIndex( toindex , i ); + if( !ITEM_CHECKINDEX( itemindex)) + continue; + ep = ITEM_getEquipPlace( toindex, itemindex ); + if( ep == -1 ) + continue; + Drf=(DIERELIFEFUNC)ITEM_getFunctionPointer(itemindex, ITEM_DIERELIFEFUNC); + if( Drf ) { + Drf( toindex, itemindex, i); + return TRUE; + } + } + + return FALSE; + +} +#endif + +#ifdef _LOSE_FINCH_ +BOOL CHECK_PET_RELIFE( int battleindex, int petindex) +{ + int ReceveEffect=-1; + int toNo; + int attackNo=-1; + int WORK_HP=1; + int i; + struct _RePet{ + int petid; + int Effect; + int Addhp; +//Syu Mod +// }rePet[]={{1,SPR_fukkatu3,100},{-1,0,0}}; + }rePet[]={{-1,0,0}}; + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE ) { + return FALSE; + } + if( CHAR_CHECKINDEX( petindex) == FALSE ) + return FALSE; + + if( CHAR_getFlg( petindex, CHAR_ISDIE) == FALSE ) { + print("\n PET_RELIFE:[ %d, CHAR_ISDIE FALSE] return !", petindex); + return FALSE; + } + if( CHAR_getWorkInt( petindex, CHAR_WORKSPETRELIFE) != 0 ) + return FALSE; + for( i=0;iskill, SKILL_LEVEL); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_M( skill_level ); + + if( skill_level >= 6 ) add_practice = (skill_level-5) * 3 + 10; + else add_practice = skill_level * 2; + if( add_practice > 25 ) add_practice = 25; + + add_practice += old_practice; + // 因为old_practice=0所以add_practice为2~25 + + CHAR_setWorkInt( charaindex, CHAR_WORK_F_PROFICIENCY, add_practice ); + + }else + // 冰熟练度 + if( (strcmp( skill_name , "PROFESSION_ICE_PRACTICE" )) == 0 ){ + int old_practice = CHAR_getInt( charaindex, PROFESSION_ICE_P ); + int add_practice = 0; + int skill_level = 0; + + // 技能等级 + hskill = CHAR_getCharHaveSkill( charaindex, i ); + skill_level = SKILL_getInt( &hskill->skill, SKILL_LEVEL); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_M( skill_level ); + + if( skill_level >= 6 ) add_practice = (skill_level-5) * 3 + 10; + else add_practice = skill_level * 2; + if( add_practice > 25 ) add_practice = 25; + + add_practice += old_practice; + + CHAR_setWorkInt( charaindex, CHAR_WORK_I_PROFICIENCY, add_practice ); + + }else + // 雷熟练度 + if( (strcmp( skill_name , "PROFESSION_THUNDER_PRACTICE" )) == 0 ){ + int old_practice = CHAR_getInt( charaindex, PROFESSION_THUNDER_P ); + int add_practice = 0; + int skill_level = 0; + + // 技能等级 + hskill = CHAR_getCharHaveSkill( charaindex, i ); + skill_level = SKILL_getInt( &hskill->skill, SKILL_LEVEL); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_M( skill_level ); + + if( skill_level >= 6 ) add_practice = (skill_level-5) * 3 + 10; + else add_practice = skill_level * 2; + if( add_practice > 25 ) add_practice = 25; + + add_practice += old_practice; + + CHAR_setWorkInt( charaindex, CHAR_WORK_T_PROFICIENCY, add_practice ); + + }else + // 回避 + if( (strcmp( skill_name , "PROFESSION_AVOID" )) == 0 ){ + int skill_level = 0; + + if( profession_class != PROFESSION_SKILL_getInt( Pskillid, PROFESSION_SKILL_PROFESSION_CLASS) ) return; + + // 技能等级 + hskill = CHAR_getCharHaveSkill( charaindex, i ); + skill_level = SKILL_getInt( &hskill->skill, SKILL_LEVEL); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_A( skill_level ); + + if( skill_level <=5 ) + value = skill_level * 2; + else + value = (skill_level-5) * 3; + if( value > 25 ) value = 25; + + CHAR_setWorkInt( charaindex, CHAR_WORK_P_DUCK, 1); + CHAR_setWorkInt( charaindex, CHAR_WORKMOD_P_DUCK, value ); + + }else + // 格档 + if( (strcmp( skill_name , "PROFESSION_DEFLECT" )) == 0 ){ + int skill_level = 0; + int old_value = 0, add_value = 0; + + if( profession_class != PROFESSION_SKILL_getInt( Pskillid, PROFESSION_SKILL_PROFESSION_CLASS) ) return; + + // 技能等级 + hskill = CHAR_getCharHaveSkill( charaindex, i ); + skill_level = SKILL_getInt( &hskill->skill, SKILL_LEVEL); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_A( skill_level ); + + old_value = CHAR_getWorkInt( charaindex, CHAR_WORKFIXARRANGE ); + add_value = old_value + skill_level + 10; + + CHAR_setWorkInt( charaindex, CHAR_WORKFIXARRANGE, add_value ); + CHAR_complianceParameter( charaindex ); + + }else + // 武器专精 + if( (strcmp( skill_name , "PROFESSION_WEAPON_FOCUS" )) == 0 ){ + int skill_level = 0; + + rate = 0; + if( profession_class != PROFESSION_SKILL_getInt( Pskillid, PROFESSION_SKILL_PROFESSION_CLASS) ) continue; + + // 技能等级 + hskill = CHAR_getCharHaveSkill( charaindex, i ); + skill_level = SKILL_getInt( &hskill->skill, SKILL_LEVEL); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_A( skill_level ); + + // 技能参数 + pszOption = PROFESSION_SKILL_getChar( Pskillid, PROFESSION_SKILL_OPTION); + if( pszOption == NULL ) continue; + + // 装备武器 + WeaponType = BATTLE_GetWepon( charaindex ); + + switch( WeaponType ){ + case ITEM_AXE: + if( (pszP=strstr( pszOption, "斧" ))!=NULL) rate = 1; break; + case ITEM_CLUB: + if( (pszP=strstr( pszOption, "棍" ))!=NULL) rate = 1; break; + case ITEM_SPEAR: + if( (pszP=strstr( pszOption, "枪" ))!=NULL) rate = 1; break; + case ITEM_BOW: + if( (pszP=strstr( pszOption, "弓" ))!=NULL) rate = 1; break; + case ITEM_BOOMERANG: // 回旋标 + if( (pszP=strstr( pszOption, "镖" ))!=NULL) rate = 1; break; + case ITEM_BOUNDTHROW: // 投掷斧头 + if( (pszP=strstr( pszOption, "投" ))!=NULL) rate = 1; break; + case ITEM_BREAKTHROW: // 投掷石 + if( (pszP=strstr( pszOption, "石" ))!=NULL) rate = 1; break; + default: rate = 0; break; + } + + if( rate == 1 ){ + old_value = CHAR_getWorkInt( charaindex, CHAR_MYSKILLSTRPOWER); + + if( skill_level <=5 ) + value = skill_level * 2 + old_value; + else + value = (skill_level-5) * 3 + 10 + old_value; + + if( value > 25 ) value = 25; + + CHAR_setWorkInt( charaindex, CHAR_WORK_WEAPON, 1 ); + CHAR_setWorkInt( charaindex, CHAR_WORKMOD_WEAPON, value ); + } + } + } + } + return; +} + + +void BATTLE_ProfessionStatusSeq( int battleindex, int charaindex ) +{ + int profession_class=0, i=0, j=0, Pskillid=-1, skillid=-1; + int skill_level=0, value=0, old_value=0; + int bid=-1, hp=0, flag=0; + char *skill_name, szcommand[256]; + CHAR_HaveSkill* hskill; + + + int status_table[9]={ 2, //麻痹 + 3, //睡眠 + 4, //石化 + 12, //晕眩 + 13, //缠绕 + 14, //天罗 + 15, //冰暴 + 17, //冰箭 + 23, }; //雷附体 + +#ifdef _PETSKILL_DAMAGETOHP +/* { + char msg[32]={0}; + int pet,pindex; + pet = CHAR_getInt( charaindex, CHAR_DEFAULTPET ); + if( pet >= 0 ){ + sprintf( msg, "o%d", pet ); + //if(CHAR_getInt( petindex, CHAR_PETID) == "狼" //宠物ID + // && CHAR_getInt( petindex, CHAR_HP) ) + CHAR_sendStatusString( charaindex, msg ); + pindex = CHAR_getCharPet( charaindex, pet ); + print("\n宠物名:%s",CHAR_getChar( pindex, CHAR_NAME)); + } + else + print("\无宠物"); + + } */ +#endif + + if ( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) return; + + profession_class=CHAR_getInt( charaindex, PROFESSION_CLASS); + if( profession_class <= PROFESSION_CLASS_NONE ) return; + + for( i=0; i 0 ){ + flag=1; + break; + } + } + + if( flag > 0 ){ + // 技能等级 + hskill = CHAR_getCharHaveSkill( charaindex, i ); + skill_level = SKILL_getInt( &hskill->skill, SKILL_LEVEL); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_M( skill_level ); + + value = skill_level * 2; + if( value > 20 ) value = 20; + + old_value = CHAR_getWorkInt( charaindex, CHAR_WORKMAXHP); + + value = old_value * value / 100 ; + + hp = CHAR_getInt( charaindex, CHAR_HP); + + if( value + hp > old_value ) + value = old_value - hp; + + if( value < 0 ) value = 0; + + CHAR_setInt( charaindex, CHAR_HP, value + hp ); + + bid = BATTLE_Index2No( battleindex, charaindex ); + sprintf( szcommand, "BD|r%X|0|1|%X|", bid, value ); + BATTLESTR_ADD( szcommand ); + + PROFESSION_SKILL_LVEVEL_UP( charaindex, "PROFESSION_REBACK" ); + } + } + + // 陷阱 + if( (strcmp( skill_name , "PROFESSION_TRAP" )) == 0 ){ + int count=0; + + count = CHAR_getWorkInt( charaindex, CHAR_WORKTRAP); + if( count > 0 ){ + count--; + CHAR_setWorkInt( charaindex, CHAR_WORKTRAP, count ); + }else if( count == 0 ){ + CHAR_setWorkInt( charaindex, CHAR_WORKTRAP, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORKMODTRAP, 0 ); + } + } + } + + return; +} + +#endif diff --git a/gmsv/battle/battle_ai.c b/gmsv/battle/battle_ai.c new file mode 100644 index 0000000..b2ce8a3 --- /dev/null +++ b/gmsv/battle/battle_ai.c @@ -0,0 +1,533 @@ +#include "version.h" +#include +#include "common.h" +#include "char.h" +#include "char_base.h" +#include "battle.h" +#include "npcutil.h" +#include "pet_skill.h" + +struct B_AI_RESULT { + BATTLE_COM command; /* 窒毛允月井 */ + int target; /* 簿卞 */ +}; + +static int BATTLE_ai_normal( int, int, BATTLE_ENTRY *,struct B_AI_RESULT *); + +static int (*functbl[])( int, int, BATTLE_ENTRY *,struct B_AI_RESULT *) = { + NULL, + BATTLE_ai_normal, +}; + +int BATTLE_ai_all( int battleindex, int side, int turn) +{ + int i; + int rc = FALSE; + BATTLE_ENTRY *pEntry; + struct B_AI_RESULT result; + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + if( BATTLE_CHECKSIDE( side ) == FALSE )return BATTLE_ERR_PARAM; + if( BATTLE_CHECKSIDE( side ^1) == FALSE )return BATTLE_ERR_PARAM; + if( BattleArray[battleindex].Side[side].type != BATTLE_S_TYPE_ENEMY ) return FALSE; + pEntry = BattleArray[battleindex].Side[side^1].Entry; + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + int charaindex = BattleArray[battleindex].Side[side].Entry[i].charaindex; + int mode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + + mode = CHAR_getWorkInt( charaindex, CHAR_WORKTACTICS); + if( mode < 0 || mode >= arraysizeof( functbl)){ + print( "BATTLE_ai_all 中,战斗逻辑模式很奇怪(%s)(%d)\n", + CHAR_getUseName( charaindex ), mode ); + mode = 1; + } + if( BATTLE_IsCharge( charaindex ) == TRUE ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + continue; + } + if( BattleArray[battleindex].Side[side].flg & BSIDE_FLG_SURPRISE) { + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + }else { + if( functbl[mode] != NULL ) { + rc = functbl[mode]( turn, charaindex, pEntry, &result); + if( BATTLE_CanMoveCheck( charaindex ) == FALSE ){ + result.command = BATTLE_COM_NONE; + } + } + if( rc ) { +#ifdef _BATTLENPC_WARP_PLAYER + if(result.command==BATTLE_COM_WARP){ + for( i=0; icharaindex; + if( !CHAR_CHECKINDEX( tindex ))continue; + if( CHAR_getFlg( tindex, CHAR_ISDIE)) continue; + if( CHAR_getWorkInt( tindex, CHAR_WORKBATTLEMODE) + == BATTLE_CHARMODE_RESCUE ) continue; + if( CHAR_getInt( tindex, CHAR_WHICHTYPE)==CHAR_TYPEPLAYER){ + char sBuff[1024]="", sBuff1[1024]=""; + int ss[3]; + int sii; + int rc = 1; + if( NPC_Util_GetStrFromStrWithDelim( CHAR_getWorkChar( charaindex, CHAR_WORKBATTLE_ACT_CONDITION), + "wp", sBuff, sizeof( sBuff))!=NULL){ + for( sii=1; sii<=3; sii++){ + if(getStringFromIndexWithDelim( sBuff, ";", sii, sBuff1, sizeof( sBuff1))) + {ss[sii-1]=atoi(sBuff1);} + else + {rc=0;} + } + if(rc){ + CHAR_warpToSpecificPoint( tindex, ss[0], ss[1], ss[2]); + BATTLE_WatchStop( tindex); + } + } + } + } + } +#endif + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, result.command ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, + result.target + (side^1)*SIDE_OFFSET); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + //CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); + + } + } + } + return TRUE; +} + +int BATTLE_ai_one( int charaindex, int battleindex, int side, int turn) +{ + int rc = FALSE; + BATTLE_ENTRY *pEntry; + struct B_AI_RESULT result; + int mode; + + /* 由仿丢□正民尼永弁 */ + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + if( BATTLE_CHECKSIDE( side ) == FALSE )return BATTLE_ERR_PARAM; + if( BATTLE_CHECKSIDE( side ^1) == FALSE )return BATTLE_ERR_PARAM; + + /* 及扔奶玉隋垫丹 */ + /* 衬平乓仿动陆反 仃月 */ + if( BattleArray[battleindex].Side[side].type != BATTLE_S_TYPE_ENEMY ) return 0; + + /* 覆础扔奶玉 */ + pEntry = BattleArray[battleindex].Side[side^1].Entry; + + mode = CHAR_getWorkInt( charaindex, CHAR_WORKTACTICS); + /* 质 毛蕊曰坌仃月 */ + if( mode < 0 || mode >= arraysizeof( functbl)) return FALSE; + /* 质 毛蕊曰坌仃月 */ + if( functbl[mode] != NULL ) { + rc = functbl[mode]( turn, charaindex, pEntry, &result); + } + if( rc ) { + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, result.command ); + if( result.command == BATTLE_COM_ATTACK) { + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, + result.target + (side^1)*SIDE_OFFSET); + } + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + } + return TRUE; +} + +/* 骚卞锹澎毛瑁户月 */ + +#define B_AI_NORMAL_ATTACKOPTION "at" /* 猾左皿扑亦件 */ +#define B_AI_NORMAL_GUARDOPTION "gu" /* 豢左皿扑亦件 */ +#define B_AI_NORMAL_MAGICOPTION "ma" /* 热诸左皿扑亦件 */ +#define B_AI_NORMAL_ESCAPEOPTION "es" /* 仆月左皿扑亦件 */ +#define B_AI_NORMAL_WAZAOPTION "wa" /* 左皿扑亦件 */ +#ifdef _ENEMY_ATTACK_AI +#define B_AI_NORMAL_RANDAOPTION "rn" +#define B_AI_NORMAL_RANDOMOPTIONNUM 1 +#endif + +#define B_AI_NORMAL_ATTACKSUBOPTIONNUM 3 +#define B_AI_NORMAL_GUARDSUBOPTIONNUM 1 +#define B_AI_NORMAL_MAGICSUBOPTIONNUM 1 +#define B_AI_NORMAL_ESCAPESUBOPTIONNUM 1 +#define B_AI_NORMAL_WAZASUBOPTIONNUM 7 + +/* 左皿扑亦件娄醒及 侬及烂聒 */ +#define B_AI_NORMAL_TARGET_ALL 1 +#define B_AI_NORMAL_TARGET_PLAYER 2 +#define B_AI_NORMAL_TARGET_PET 3 +#ifdef _ENEMY_ATTACK_AI +#define B_AI_NORMAL_TARGET_LEADER 4 +#endif +#define B_AI_NORMAL_SELECT_RANDOM 1 +#define B_AI_NORMAL_SELECT_HP_MAX 2 +#define B_AI_NORMAL_SELECT_HP_MIN 3 +#ifdef _ENEMY_ATTACK_AI +#define B_AI_NORMAL_SELECT_STR_MAX 4 +#define B_AI_NORMAL_SELECT_DEX_MAX 5 +#define B_AI_NORMAL_SELECT_DEX_MIN 6 +#define B_AI_NORMAL_SELECT_ATT_SUBDUE 7 +enum{ + AI_ATT_EARTHAT = 1, + AI_ATT_WATERAT, + AI_ATT_FIREAT, + AI_ATT_WINDAT +}; +int GetSubdueAttribute(int index){ + int s_a = CHAR_getWorkInt( index, CHAR_WORKFIXEARTHAT); + int s_b = CHAR_getWorkInt( index, CHAR_WORKFIXWATERAT); + int s_c = CHAR_getWorkInt( index, CHAR_WORKFIXFIREAT); + int s_d = CHAR_getWorkInt( index, CHAR_WORKFIXWINDAT); + return ((s_a>s_c)?((s_b>s_d)?((s_a>s_b)?(2):(3)):((s_a>s_d)?(2):(1))):((s_b>s_d)?((s_c>s_b)?(4):(3)):((s_c>s_d)?(4):(1)))); +} +#endif + +typedef enum { + B_AI_ATTACKMODE = 1, + B_AI_GURADMODE, + B_AI_MAGICMODE, + B_AI_ESCAPEMODE, + B_AI_WAZAMODE0, + B_AI_WAZAMODE1, + B_AI_WAZAMODE2, + B_AI_WAZAMODE3, + B_AI_WAZAMODE4, + B_AI_WAZAMODE5, + B_AI_WAZAMODE6, +}B_AI_MODE; + +static int BATTLE_ai_normal( int turn, int charaindex, + BATTLE_ENTRY *pEntry, + struct B_AI_RESULT *result) +{ + int at[B_AI_NORMAL_ATTACKSUBOPTIONNUM] = { 0,0,0}; /* 猾左皿扑亦件 */ + int gu[B_AI_NORMAL_GUARDSUBOPTIONNUM] = {0}; /* 左皿扑亦件 */ + int ma[B_AI_NORMAL_MAGICSUBOPTIONNUM] = {0}; /* 左皿扑亦件 */ + int es[B_AI_NORMAL_ESCAPESUBOPTIONNUM] = {0}; /* 左皿扑亦件 */ + int wa[B_AI_NORMAL_WAZASUBOPTIONNUM] = {0,0,0,0, 0,0,0};/* 左皿扑亦件 */ +#ifdef _ENEMY_ATTACK_AI + int rn[B_AI_NORMAL_RANDOMOPTIONNUM] = {1}; +#endif + int target[BATTLE_ENTRY_MAX]; + int cnt; + int i; + int r; + int rc; + int mode=0; + char buff[256]; + char buff2[256]; + + if( turn == 1 ) { + print( "应该没这回事。\n" ); + return FALSE; + } + if( NPC_Util_GetStrFromStrWithDelim( CHAR_getWorkChar( charaindex, CHAR_WORKBATTLE_TACTICSOPTION), + B_AI_NORMAL_ATTACKOPTION, buff, sizeof( buff)) != NULL ){ + for( i = 1; i < B_AI_NORMAL_ATTACKSUBOPTIONNUM + 1; i ++ ) { + rc = getStringFromIndexWithDelim( buff, ";", i, buff2, sizeof( buff2)); + if( rc != TRUE ) { + print( "battle_ai.c:Invarid Param [%s]\n", + CHAR_getWorkChar( charaindex, CHAR_WORKBATTLE_TACTICSOPTION)); + return FALSE; + } + at[i-1] = atoi( buff2); + } + } + + if( NPC_Util_GetStrFromStrWithDelim( CHAR_getWorkChar( charaindex, CHAR_WORKBATTLE_TACTICSOPTION), + B_AI_NORMAL_GUARDOPTION, buff, sizeof( buff)) != NULL ){ + for( i = 1; i < B_AI_NORMAL_GUARDSUBOPTIONNUM + 1; i ++ ) { + rc = getStringFromIndexWithDelim( buff, ";", i, buff2, sizeof( buff2)); + if( rc != TRUE ) { + print( "battle_ai.c:Invarid Param [%s]\n", + CHAR_getWorkChar( charaindex, CHAR_WORKBATTLE_TACTICSOPTION)); + return FALSE; + } + gu[i-1] = atoi( buff2); + } + } + if( NPC_Util_GetStrFromStrWithDelim( CHAR_getWorkChar( charaindex, CHAR_WORKBATTLE_TACTICSOPTION), + B_AI_NORMAL_MAGICOPTION, + buff, sizeof( buff)) != NULL ){ + for( i = 1; i < B_AI_NORMAL_MAGICSUBOPTIONNUM + 1; i ++ ) { + rc = getStringFromIndexWithDelim( buff, ";", i, buff2, sizeof( buff2)); + if( rc != TRUE ) { + print( "battle_ai.c:Invarid Param [%s]\n", + CHAR_getWorkChar( charaindex, CHAR_WORKBATTLE_TACTICSOPTION)); + return FALSE; + } + ma[i-1] = atoi( buff2); + + } + } + if( NPC_Util_GetStrFromStrWithDelim( CHAR_getWorkChar( charaindex, CHAR_WORKBATTLE_TACTICSOPTION), + B_AI_NORMAL_ESCAPEOPTION, + buff, sizeof( buff)) != NULL ){ + for( i = 1; i < B_AI_NORMAL_ESCAPESUBOPTIONNUM + 1; i ++ ) { + rc = getStringFromIndexWithDelim( buff, ";", i, buff2, sizeof( buff2)); + + if( rc != TRUE ) { + print( "battle_ai.c:Invarid Param [%s]\n", + CHAR_getWorkChar( charaindex, CHAR_WORKBATTLE_TACTICSOPTION)); + return FALSE; + } + es[i-1] = atoi( buff2); + } + } + if( NPC_Util_GetStrFromStrWithDelim( CHAR_getWorkChar( charaindex, CHAR_WORKBATTLE_TACTICSOPTION), + B_AI_NORMAL_WAZAOPTION, + buff, sizeof( buff)) != NULL ){ + for( i = 1; i < B_AI_NORMAL_WAZASUBOPTIONNUM + 1; i ++ ) { + rc = getStringFromIndexWithDelim( buff, ";", i, buff2, sizeof( buff2)); + if( rc != TRUE ) { + }else{ + wa[i-1] = atoi( buff2); + } + } + } +#ifdef _ENEMY_ATTACK_AI + if( NPC_Util_GetStrFromStrWithDelim( CHAR_getWorkChar( charaindex, CHAR_WORKBATTLE_TACTICSOPTION), + B_AI_NORMAL_RANDAOPTION, + buff, sizeof( buff))!=NULL){ + for( i=1; icommand = BATTLE_COM_WARP; + return TRUE; + } + } +#endif + if( at[0] == 0 && gu[0] == 0 && ma[0] == 0 && es[0] == 0 ){ + for( i = 0; i < B_AI_NORMAL_WAZASUBOPTIONNUM; i ++ ){ + if( wa[i] != 0 )break; + } + if( i >= B_AI_NORMAL_WAZASUBOPTIONNUM ){ + print( "无指定任何的攻击方式。\n" ); + return FALSE; + } + } + while( !mode ) { + int work = 0; + work = at[0]+gu[0]+ma[0]+es[0]; + for( i = 0; i < B_AI_NORMAL_WAZASUBOPTIONNUM; i ++ ){ + work += wa[i]; + } + r = RAND( 0, work - 1 ); + if( at[0] != 0 && r < at[0] ) mode = B_AI_ATTACKMODE; + else if( gu[0] != 0 && r < at[0] + gu[0]) mode = B_AI_GURADMODE; + else if( ma[0] != 0 && r < at[0] + gu[0] + ma[0]) mode = B_AI_MAGICMODE; + else if( es[0] != 0 && r < at[0] + gu[0] + ma[0] + es[0] ){ + mode = B_AI_ESCAPEMODE; + } + if( mode ) break; + work = at[0] + gu[0] + ma[0] + es[0]; + for( i = 0; i < B_AI_NORMAL_WAZASUBOPTIONNUM; i ++ ){ + work += wa[i]; + if( wa[i] != 0 && r < work ){ + mode = B_AI_WAZAMODE0+i; + break; + } + } + } + if( mode == B_AI_ATTACKMODE || ( B_AI_WAZAMODE0 <= mode && mode <= B_AI_WAZAMODE6 )){ + while( 1 ) { + for( i = 0 ; i < BATTLE_ENTRY_MAX; i ++ ) { + target[i] = -1; + } + cnt = 0; + for( i = 0; i < BATTLE_ENTRY_MAX ; i ++ ) { + int tindex = (pEntry+i)->charaindex; + if( !CHAR_CHECKINDEX( tindex ))continue; + if( CHAR_getFlg( tindex, CHAR_ISDIE)) continue; + if( CHAR_getWorkInt( tindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_RESCUE ) continue; + switch( at[1]) { + case B_AI_NORMAL_TARGET_PLAYER: + if( CHAR_getInt( tindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ){ + target[cnt++] = i; + } + break; + case B_AI_NORMAL_TARGET_PET: + if( CHAR_getInt( tindex, CHAR_WHICHTYPE) == CHAR_TYPEPET){ + target[cnt++] = i; + } + break; +#ifdef _ENEMY_ATTACK_AI + case B_AI_NORMAL_TARGET_LEADER: + if( CHAR_getWorkInt( tindex, CHAR_WORKPARTYMODE ) == CHAR_PARTY_LEADER) { + target[cnt++] = i; + }else if(!RAND( 0, 2)) { + target[cnt++] = i; + } + break; +#endif + default: + target[cnt++] = i; + break; + } + } + if( cnt == 0 && at[1] == B_AI_NORMAL_TARGET_ALL ) return FALSE; + if( cnt > 0 ) break; + at[1] = B_AI_NORMAL_TARGET_ALL; + } + result->command = BATTLE_COM_NONE; + if( at[2] == B_AI_NORMAL_SELECT_RANDOM ) { + r = RAND( 0, cnt-1); + result->command = BATTLE_COM_ATTACK; + result->target = target[r]; + }else if( at[2] == B_AI_NORMAL_SELECT_HP_MAX || at[2] == B_AI_NORMAL_SELECT_HP_MIN ){ + int top = 0; + for( i = 0; i < cnt; i ++ ) { + if( i ==0 ) top = target[i]; + else { + int tophp = CHAR_getInt((pEntry+top)->charaindex, CHAR_HP); + int comphp = CHAR_getInt((pEntry+target[i])->charaindex, CHAR_HP); + if( at[2] == B_AI_NORMAL_SELECT_HP_MAX ) { + if( comphp > tophp ) top = target[i]; + } + else { + if( comphp < tophp ) top = target[i]; + } + } + } +#ifdef _ENEMY_ATTACK_AI + if(!RAND( 0, rn[0])) + result->target = target[RAND( 0, cnt-1)]; + else + result->target = top; + result->command = BATTLE_COM_ATTACK; +#else + result->command = BATTLE_COM_ATTACK; + result->target = top; +#endif + } +#ifdef _ENEMY_ATTACK_AI + else if(at[2] == B_AI_NORMAL_SELECT_STR_MAX) { + int top = 0; + for( i=0; icharaindex, CHAR_STR); + int compstr = CHAR_getInt( (pEntry+target[i])->charaindex, CHAR_STR); + if(compstr>topstr) top = target[i]; + } + } + if(!RAND( 0, rn[0])) + result->target = target[RAND( 0, cnt-1)]; + else + result->target = top; + result->command = BATTLE_COM_ATTACK; + } + else if(at[2] == B_AI_NORMAL_SELECT_DEX_MAX || + at[2] == B_AI_NORMAL_SELECT_DEX_MIN) { + int top = 0; + for( i=0; icharaindex, CHAR_DEX); + int compdex = CHAR_getInt( (pEntry+target[i])->charaindex, CHAR_DEX); + if(at[2]==B_AI_NORMAL_SELECT_DEX_MAX) { + if(compdex>topdex) top = target[i]; + }else { + if(compdextarget = target[RAND( 0, cnt-1)]; + else + result->target = top; + result->command = BATTLE_COM_ATTACK; + } + else if(at[2] == B_AI_NORMAL_SELECT_ATT_SUBDUE) { + int top = 0; + for( i=0; icharaindex, CHAR_WORKFIXEARTHAT); + int compatt = CHAR_getWorkInt( (pEntry+target[i])->charaindex, CHAR_WORKFIXEARTHAT); + if(compatt>topatt) top = target[i]; + } + break; + case AI_ATT_WATERAT: + { + int topatt = CHAR_getWorkInt( (pEntry+top)->charaindex, CHAR_WORKFIXWATERAT); + int compatt = CHAR_getWorkInt( (pEntry+target[i])->charaindex, CHAR_WORKFIXWATERAT); + if(compatt>topatt) top = target[i]; + } + break; + case AI_ATT_FIREAT: + { + int topatt = CHAR_getWorkInt( (pEntry+top)->charaindex, CHAR_WORKFIXFIREAT); + int compatt = CHAR_getWorkInt( (pEntry+target[i])->charaindex, CHAR_WORKFIXFIREAT); + if(compatt>topatt) top = target[i]; + } + break; + case AI_ATT_WINDAT: + { + int topatt = CHAR_getWorkInt( (pEntry+top)->charaindex, CHAR_WORKFIXWINDAT); + int compatt = CHAR_getWorkInt( (pEntry+target[i])->charaindex, CHAR_WORKFIXWINDAT); + if(compatt>topatt) top = target[i]; + } + break; + default: + break; + } + } + } + if(!RAND( 0, rn[0])) + result->target = target[RAND( 0, cnt-1)]; + else + result->target = top; + result->command = BATTLE_COM_ATTACK; + } +#endif + else{ + return FALSE; + } + if( B_AI_WAZAMODE0 <= mode && mode <= B_AI_WAZAMODE6 ){ + if( PETSKILL_Use( charaindex, mode - B_AI_WAZAMODE0, result->target,NULL ) == TRUE ){ + result->command = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ); + return TRUE; + }else{ + print( "此项技能尚未设定(%s):(%d)\n", + CHAR_getUseName( charaindex), mode - B_AI_WAZAMODE0 ); + return FALSE; + } + }else + if( mode == B_AI_ATTACKMODE ){ + result->command = BATTLE_COM_ATTACK; + return TRUE; + } + }else if( mode == B_AI_GURADMODE ) { + result->command = BATTLE_COM_GUARD; + return TRUE; + }else if( mode == B_AI_ESCAPEMODE ) { + result->command = BATTLE_COM_ESCAPE; + return TRUE; + } + return FALSE; +} diff --git a/gmsv/battle/battle_command.c b/gmsv/battle/battle_command.c new file mode 100644 index 0000000..555aa0a --- /dev/null +++ b/gmsv/battle/battle_command.c @@ -0,0 +1,1087 @@ +#include "version.h" +#include +#include +#include"char.h" +#include"char_base.h" +#include "battle.h" +#include "pet_skill.h" +#include "battle_event.h" +#include "battle_command.h" +#include "lssproto_serv.h" +#include "magic.h" +#include "magic_base.h" +#include "handletime.h" + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 +#include "profession_skill.h" +#endif + +int NowBattlerFd; +#if 1 +int BATTLE_MpDown( int charaindex, int down ) +{ + return 0; +} +#else +{ + int mp, battleindex; + // 爵 反覆谛爵井}???爵井 + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return TRUE; + // 覆谛爵元扎卅井匀凶日?? + if( BattleArray[battleindex].type != BATTLE_TYPE_P_vs_P ){ + return TRUE; + } + + // ??毛蛹日六月井" + mp = CHAR_getInt( charaindex, CHAR_MP ); + if( mp < down ){ + // 蛹日六卅中及匹窒手仄卅中午允月 + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + // 戊穴件玉OK及隙烂 + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + return FALSE; + } + mp -= down; + CHAR_setInt( charaindex, CHAR_MP, mp ); + return TRUE; +} +#endif + + +void BattleCommandDispach( int fd, char *command ) +{ + int endFlg = 0, battleindex; + int EscapeFree = BATTLE_FLG_FREEDP; + int charaindex = CONNECT_getCharaindex(fd); + char szBuffer[256]=""; +#ifdef _FIXWOLF // Syu ADD 修正狼人变身Bug + int i , j , pindex; + BATTLE_ENTRY *pEntry; +#endif + + NowBattlerFd = fd; + + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return; + + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ){ + return; + } + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE || + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE ){ + + return; + } + + + if( BattleArray[battleindex].flg & BATTLE_FLG_CHARALOST ){ + EscapeFree = 0; + } + + if( strncmp( command, "U", 1 ) == 0 ){ + // shan 2001/12/25 begin + EscapeFree = 0; + if (CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEWATCH )!=TRUE){ + CHAR_talkToCli( charaindex, -1, + "华义大魔王使出定身法,定定定定定定把你定在战斗里。", CHAR_COLORYELLOW ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_GUARD ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + //sprintf( szBuffer, "Command(%s)(防御)", CHAR_getUseName( charaindex ) ); + endFlg = 1; + BATTLE_MpDown( charaindex, 2 ); + }else{ + BATTLE_WatchStop( charaindex ); + } + // shan end + }else + if( strncmp( command, "E", 1 ) == 0 ){ + + if( checkErrorStatus( charaindex) ) { + BattleCommandDispach( fd, "N"); + return; + } + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ESCAPE ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + //sprintf( szBuffer, "Command(%s)(逃跑)", CHAR_getUseName( charaindex ) ); + endFlg = 1; + + BATTLE_MpDown( charaindex, 20 ); + + }else + if( strncmp( command, "H|", 2 ) == 0 ){ + int iNum = -1, At_SoubiIndex; + if( sscanf( command+2, "%X", &iNum ) != 1 + || ( iNum < 0 || iNum >= 20 ) + ){ + iNum = -1; + } + + if( checkErrorStatus( charaindex) ) { + BattleCommandDispach( fd, "N"); + return; + } + + EscapeFree = 0; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, iNum ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + + At_SoubiIndex = CHAR_getItemIndex( charaindex, CHAR_ARM ); + if( ITEM_CHECKINDEX( At_SoubiIndex ) == FALSE ){ + + }else{ + + if( ITEM_getInt( At_SoubiIndex, ITEM_TYPE ) == ITEM_BOOMERANG ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_BOOMERANG ); +#ifdef _PETSKILL_BECOMEFOX + if( CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER)==101749 + || CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND ) != -1 ){ //若是变成小狐狸不可以使用回力标 + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } +#endif +#ifdef _PETSKILL_BECOMEPIG + if( CHAR_getInt( charaindex, CHAR_BECOMEPIG) > -1 ){//变成乌力了 + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + } +#endif + } + } + + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, 1 ); + //sprintf( szBuffer, "Command(%s)(战斗)", CHAR_getUseName( charaindex ) ); + + endFlg = 1; + + BATTLE_MpDown( charaindex, 5 ); + + }else + if( strncmp( command, "G", 1 ) == 0 ){ + + if( checkErrorStatus( charaindex) ) { + BattleCommandDispach( fd, "N"); + return; + } + + EscapeFree = 0; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_GUARD ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + sprintf( szBuffer, "Command(%s)(防御)", CHAR_getUseName( charaindex ) ); + endFlg = 1; + + BATTLE_MpDown( charaindex, 2 ); + + }else + if( strncmp( command, "N", 1 ) == 0 ){ + + EscapeFree = 0; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_WAIT ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); +// sprintf( szBuffer, "Command(%s)(server托管)", CHAR_getUseName( charaindex ) ); + //sprintf( szBuffer, "Command(%s)(待机)", CHAR_getUseName( charaindex ) ); + endFlg = 1; + + }else + if( strncmp( command, "T|", 2 ) == 0 ){ + int iNum = -1; + + if( checkErrorStatus( charaindex) ) { + BattleCommandDispach( fd, "N"); + return; + } + + EscapeFree = 0; + + if( sscanf( command+2, "%X", &iNum ) != 1 + || ( iNum < 0 || iNum >= 20 ) + ){ + iNum = -1; + } + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, iNum ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_CAPTURE ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + //sprintf( szBuffer, "Command(%s)(捕获)", CHAR_getUseName( charaindex ) ); + endFlg = 1; + + BATTLE_MpDown( charaindex, 20 ); + + }else + if( strncmp( command, "S|", 2 ) == 0 ){ + int iNum = -1; + + if( checkErrorStatus( charaindex) ) { + BattleCommandDispach( fd, "N"); + return; + } + + EscapeFree = 0; + + // shan 2002/01/08 begin + if( sscanf( command+2, "%d", &iNum ) != 1 + || ( iNum < -1 || iNum >= CHAR_MAXPETHAVE ) + || ( CHAR_getInt(charaindex,CHAR_RIDEPET)==iNum) + ){ + iNum = -1; + } + // shan end + +#ifdef _STANDBYPET + if( iNum >= 0) { + if( ! (CHAR_getWorkInt( charaindex, CHAR_WORKSTANDBYPET) & ( 1 << iNum)) ) { + print("\n 改封包!叫出非待机宠!!:%s ", CHAR_getChar( charaindex, CHAR_CDKEY) ); + iNum = -1; + } + } +#endif + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, iNum ); + if( iNum < 0 ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_PETIN ); + //sprintf( szBuffer, "Command(%s)(唤回宠物)", CHAR_getUseName( charaindex ) ); + }else{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_PETOUT ); + //sprintf( szBuffer, "Command(%s)(叫出宠物)", CHAR_getUseName( charaindex ) ); + } + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + endFlg = 1; + + BATTLE_MpDown( charaindex, 10 ); + + }else + if( strncmp( command, "W|", 2 ) == 0 ){ + int iNum = -1, petskillindex = -1, ToNo = -1, petnum, petindex; + + if( sscanf( command+2, "%X|%X", &iNum, &ToNo ) < 1 ){ + iNum = -1; ToNo = -1; + } + petnum = CHAR_getInt( charaindex, CHAR_DEFAULTPET ); + petindex = CHAR_getCharPet( charaindex, petnum ); + if( CHAR_CHECKINDEX( petindex ) == FALSE ){ + }else{ + + if( iNum < 0 || iNum >= CHAR_MAXPETSKILLHAVE +#ifdef _PETSKILLBUG //Add By Syu 2002.0805 + || (CHAR_getFlg( charaindex, CHAR_ISDIE ) == TRUE )|| + (CHAR_getInt( charaindex, CHAR_HP ) <= 0) +#endif + || checkErrorStatus( petindex) + ) + { + //sprintf( szBuffer, "Command(%s)(自动)", CHAR_getUseName( petindex ) ); + CHAR_setWorkInt( petindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); +#ifdef _PETSKILLBUG //Add By Syu 2002.0805 + }else if ((CHAR_getInt(petindex, CHAR_TRANSMIGRATION)<1) + && ( iNum>=CHAR_getInt(petindex, CHAR_SLOT) ) ) + { + //sprintf( szBuffer, "Command(%s)(自动)", CHAR_getUseName( petindex ) ); + CHAR_setWorkInt( petindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); +#endif + }else{ + petskillindex = PETSKILL_GetArray( petindex, iNum); +#ifdef _FIXWOLF // Syu ADD 修正狼人变身Bug + if( (CHAR_getPetSkill( petindex , iNum )== 600) && (ToNo == -1)) + { + for( j = 0; j < 2; j ++ ) + { + pEntry = BattleArray[battleindex].Side[j].Entry; + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ) + { + pindex = pEntry[i].charaindex; + if( pindex == petindex) + { + ToNo=i + ( j * 10 ); + break; + } + } + } + } +#endif + if( petskillindex >= 0 + && PETSKILL_Use( petindex, iNum, ToNo, NULL ) == TRUE + ){ + //sprintf( szBuffer, "Command(%s)(石版)", CHAR_getUseName( petindex ) ); + + EscapeFree = 0; + + }else{ + //sprintf( szBuffer, "Command(%s)(自动)", CHAR_getUseName( petindex ) ); + CHAR_setWorkInt( petindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + } + } + } + endFlg = 1; + + BATTLE_MpDown( charaindex, 10 ); + + }else + if( strncmp( command, "J|", 1 ) == 0 ){ + int iNum = -1, magicindex = -1, ToNo = -1; + int valid = -1; + int itemindex=-1; + + if( checkErrorStatus( charaindex) ) { + BattleCommandDispach( fd, "N"); + return; + } + + EscapeFree = 0; + + if( sscanf( command+2, "%X|%X", &iNum, &ToNo ) != 2 ){ + iNum = -1; ToNo = -1; + } + + if( iNum < CHAR_EQUIPPLACENUM && iNum >= CHAR_HEAD ){ + magicindex = MAGIC_GetArrayNo( charaindex, iNum ); + itemindex = CHAR_getItemIndex( charaindex, iNum ); + valid = MAGIC_isTargetValid( magicindex, ToNo); + + if ((valid <0 ) || ( magicindex < 0 ) || (itemindex < 0 )){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_WAIT ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + }else{ +#ifdef _ITEM_ATTSKILLMAGIC + char *magicarg; + int magic_array = -1; + magic_array = MAGIC_getMagicArray( magicindex ); + magicarg = MAGIC_getChar( magic_array, MAGIC_OPTION ); + if( magicarg != NULL && strstr( magicarg, "SKILL") != NULL ) { + int mp = ITEM_getInt( itemindex, ITEM_MAGICUSEMP ); + if( MAGIC_AttSkill( charaindex, ToNo, magic_array, mp) == FALSE ) { + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_WAIT ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + } + }else { +#endif + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, ToNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_JYUJYUTU ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, magicindex ); + CHAR_SETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3, iNum ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + //sprintf( szBuffer, "Command(%s)(咒术)", CHAR_getUseName( charaindex ) ); +#ifdef _ITEM_ATTSKILLMAGIC + } +#endif + } + }else{ + EscapeFree = 0; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_WAIT ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + //sprintf( szBuffer, "Command(%s)(待机)", CHAR_getUseName( charaindex ) ); + } + endFlg = 1; + }else + if( strncmp( command, "I|", 1 ) == 0 ){ + int iNum = -1, ToNo = -1; + int valid = 0, itemindex = -1; + + if( checkErrorStatus( charaindex) ) { + BattleCommandDispach( fd, "N"); + return; + } + + EscapeFree = 0; + + if( sscanf( command+2, "%X|%X", &iNum, &ToNo ) != 2 ){ + iNum = -1; ToNo = -1; + } + itemindex = CHAR_getItemIndex( charaindex, iNum ); + if ( !ITEM_CHECKINDEX( itemindex) ) valid=-1; + if (valid >= 0) valid = ITEM_isTargetValid( charaindex, itemindex, ToNo ); + if (valid < 0 ) { + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_WAIT ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + } else { + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, ToNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ITEM ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM3, iNum ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + //sprintf( szBuffer, "Command(%s)(道具)", CHAR_getUseName( charaindex ) ); + endFlg = 1; + } + }else + if( strncmp( command, "@", 1 ) == 0 ){ + //sprintf( szBuffer, "Command(%s)(通用)", CHAR_getUseName( charaindex ) ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + endFlg = 1; + + CHAR_setInt( charaindex, CHAR_MP, + min( 100, CHAR_getInt( charaindex, CHAR_MP ) + 30 ) ); + + }else +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + if( strncmp( command, "P", 1 ) == 0 ){ + int iNum=-1, ToNo=-1; + int skillindex=-1; + int char_pskill=-1, profession_skill=-1, Pskillid=-1; + + if( checkErrorStatus( charaindex) ) { + BattleCommandDispach( fd, "N"); + return; + } + + EscapeFree = 0; + + if( sscanf( command+2, "%X|%X", &iNum, &ToNo ) < 1 ){ + iNum = -1; ToNo = -1; + } + + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE ){ + print("\n\n 非法封包(19001)(%s)(%s)\n\n", CHAR_getChar(charaindex, CHAR_CDKEY), CHAR_getChar(charaindex, CHAR_NAME) ); +#ifdef _PROSKILL_ERR_KICK + saacproto_ACKick_send( acfd, CHAR_getChar(charaindex,CHAR_CDKEY), getFdidFromCharaIndex( charaindex), 1); +#endif + return; + } +#ifdef _PROSKILL_OPTIMUM // Robin fix cancel 此处略过职业检查, 改在 PROFESSION_SKILL_Use 中检查 + // 人物的职业 + char_pskill = CHAR_getInt( charaindex, PROFESSION_CLASS ); + // 技能的职业 + skillindex = PROFESSION_SKILL_GetArray( charaindex, iNum); + Pskillid = PROFESSION_SKILL_getskillArray( skillindex); + profession_skill = PROFESSION_SKILL_getInt( Pskillid, PROFESSION_SKILL_PROFESSION_CLASS); + + if( (char_pskill > 0) && (char_pskill == profession_skill) ){ +#else + if( 1 ) { +#endif + if( PROFESSION_SKILL_Use( charaindex, iNum, ToNo, NULL ) == 1 ){ + //sprintf( szBuffer, "Command(%s)(职业技能)", CHAR_getUseName( charaindex ) ); + endFlg = 1; + }else{ + print("\n职业技能失败!! "); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_WAIT ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + //sprintf( szBuffer, "Command(%s)(待机)", CHAR_getUseName( charaindex ) ); +#ifdef _PROSKILL_ERR_KICK + saacproto_ACKick_send( acfd, CHAR_getChar(charaindex,CHAR_CDKEY), getFdidFromCharaIndex( charaindex), 1); +#endif + } + }else{ + print("\n改封包??职业技能ID不正确:%s:%d:%d \n", + CHAR_getChar( charaindex, CHAR_CDKEY), char_pskill, profession_skill); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_WAIT ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + //sprintf( szBuffer, "Command(%s)(待机)", CHAR_getUseName( charaindex ) ); +#ifdef _PROSKILL_ERR_KICK + saacproto_ACKick_send( acfd, CHAR_getChar(charaindex,CHAR_CDKEY), getFdidFromCharaIndex( charaindex), 1); +#endif + } + + EscapeFree = 0; + }else +#endif + + { + //sprintf( szBuffer, "Command(%s)(失败)", CHAR_getUseName( charaindex ) ); + endFlg = 2; + } + + + if( endFlg ){ + BATTLE_ActSettingSend( battleindex ); + + if( endFlg==1 ){ + int fd; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE)==CHAR_TYPEPLAYER ){ + fd = CHAR_getWorkInt( charaindex, CHAR_WORKFD); + CONNECT_SetBattleRecvTime( fd, &NowTime); + } + } + } + + { + //if( BATTLE_CHECKINDEX( battleindex ) == TRUE ){ + // BATTLE_BroadCast( battleindex, szBuffer, CHAR_COLORWHITE ) ; + //} + } + + if( BattleArray[battleindex].turn == 0 ){ + BattleArray[battleindex].flg |= EscapeFree; + }else{ + BattleArray[battleindex].flg &= EscapeFree; + } +} + + +void BATTLE_ActSettingSend( int battleindex ) +{ + int pindex, k = 0, i, j, charaindex; + int endBit = 0; + char szBA[256]; + BATTLE_ENTRY *pEntry; + BATTLE *pBattle; + + for( j = 0; j < 2; j ++ ){ + pEntry = BattleArray[battleindex].Side[j].Entry; + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + pindex = pEntry[i].charaindex; + // 戊穴件玉 匹五化中凶日 + if( CHAR_getWorkInt( pindex, CHAR_WORKBATTLEMODE ) + == BATTLE_CHARMODE_C_OK + ){ + endBit |= 1 << k; // 申永玄 化月 + }else + // 衬分匀凶日濮覆 井允 + if( CHAR_getInt( pindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ) + { + endBit |= 1 << k; // 申永玄 化月 + } + k ++; + } + } + sprintf( szBA, "BA|%X|%X|", endBit, BattleArray[battleindex].turn ); +// print( "%s\n", szBA ); + //今日卞蝈够伙□皿仄化霜月 + for( j = 0; j < 2; j ++ ){ + pEntry = BattleArray[battleindex].Side[j].Entry; + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + pindex = pEntry[i].charaindex; + if( CHAR_CHECKINDEX( pindex ) == FALSE )continue; + // 辅爵仄凶化及平乓仿卞反霜日卅中 + if( CHAR_getWorkInt( pindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_RESCUE )continue; + // 皿伊奶乩□分匀凶日 + if( CHAR_getInt( pindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER + ){ // 戊穴件玉霜月 + BATTLE_CommandSend( pindex, szBA ); + } + } + } + + + // 棋爵仄化中月谛卞手霜月 + pBattle = BattleArray[battleindex].pNext; + for( ; pBattle ; pBattle = pBattle->pNext ){ + // 仇及失玉伊旦互恳仄中井民尼永弁 + if( BATTLE_CHECKADDRESS( pBattle ) == FALSE ){ + fprint( "err:观战battle address错误(%p)\n", pBattle ); + break; + } + // 蝈够卞霜耨 + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pBattle->Side[0].Entry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER )continue; + // 戊穴件玉霜月 + BATTLE_CommandSend( pindex, szBA ); + } + } + +} + + + +BOOL BATTLE_IsHide( int charaindex ){ + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_EARTHROUND0 + ){ + return TRUE; + } + return FALSE; +} + + + + + +//******************************************************* +// +// 田玄伙及戊穴件玉毛弁仿奶失件玄卞霜月 +// +BOOL BATTLE_CommandSend( int charaindex, char *pszCommand ) +// +//******************************************************** +{ + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; + if( getfdFromCharaIndex( charaindex ) < 0 )return FALSE; + lssproto_B_send( getfdFromCharaIndex( charaindex ), pszCommand ); + return TRUE; +} + + +BOOL BATTLE_MakeCharaString( + int battleindex, + char *pszCommand, + int size +) +{ + int i, j, iOffset, charaindex, flg; + BATTLE_ENTRY *pEntry; + char szBuffer[4096]="", *pszTop, *pszLast; + char szEscapeName[128], szEscapeTitle[128]; + char szEscapePetName[128]; + int rideflg = 0, petindex = -1, petlevel, pethp, petmaxhp; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return FALSE; + pszTop = pszCommand; + pszLast = pszCommand+size-1; +#if 1 + sprintf( szBuffer, "BC|%X|", BattleArray[battleindex].field_att ); +#else + sprintf( szBuffer, "BC|" ); +#endif + STRCPY_TAIL( pszTop, pszLast, szBuffer ); + + for( j = 0; j < 2; j ++ ){ + if( j == 1 ){ + iOffset = SIDE_OFFSET; // 轾仇丹础扔奶玉及桦宁反皿仿旦允月 + }else{ + iOffset = 0; + } + pEntry = BattleArray[battleindex].Side[j].Entry; + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pEntry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEFLG ) + & CHAR_BATTLEFLG_ULTIMATE )continue; + flg = 0; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) + == BATTLE_CHARMODE_INIT ) flg |= BC_FLG_NEW; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) + == BATTLE_CHARMODE_RESCUE ) flg |= BC_FLG_NEW; + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == TRUE ){ + flg |= BC_FLG_DEAD; + }else + if( CHAR_getWorkInt( charaindex, CHAR_WORKPOISON ) > 0 ){ + flg |= BC_FLG_POISON; + }else +#ifdef _MAGIC_WEAKEN // 虚弱 + if( CHAR_getWorkInt( charaindex, CHAR_WORKWEAKEN ) > 0 ){ + flg |= BC_FLG_WEAKEN; + }else +#endif +#ifdef _MAGIC_DEEPPOISON // 剧毒 + if( CHAR_getWorkInt( charaindex, CHAR_WORKDEEPPOISON ) > 0 ){ + flg |= BC_FLG_DEEPPOISON; + }else +#endif +#ifdef _MAGIC_NOCAST // 沉默 + if( CHAR_getWorkInt( charaindex, CHAR_WORKNOCAST ) > 0 ){ + flg |= BC_FLG_NOCAST; + }else +#endif +#ifdef _MAGIC_BARRIER // 魔障 + if( CHAR_getWorkInt( charaindex, CHAR_WORKBARRIER ) > 0 ){ + flg |= BC_FLG_BARRIER; + }else +#endif + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARALYSIS ) > 0 ){ + flg |= BC_FLG_PARALYSIS; + }else + if( CHAR_getWorkInt( charaindex, CHAR_WORKSLEEP ) > 0 ){ + flg |= BC_FLG_SLEEP; + }else + if( CHAR_getWorkInt( charaindex, CHAR_WORKSTONE ) > 0 ){ + flg |= BC_FLG_STONE; + }else + if( CHAR_getWorkInt( charaindex, CHAR_WORKDRUNK ) > 0 ){ + flg |= BC_FLG_DRUNK; + }else + if( CHAR_getWorkInt( charaindex, CHAR_WORKCONFUSION ) > 0 ){ + flg |= BC_FLG_CONFUSION; + } + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + flg |= BC_FLG_PLAYER; + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_REVERSE ){ + flg |= BC_FLG_REVERSE; + } + if( BATTLE_IsHide( charaindex ) == TRUE ){ + flg |= BC_FLG_HIDE; + } +#ifdef _PET_SKILL_SARS // WON ADD 毒煞蔓延 + if( CHAR_getWorkInt( charaindex, CHAR_WORKSARS ) > 0 ){ + flg |= BC_FLG_SARS; + } +#endif +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + if( CHAR_getWorkInt( charaindex, CHAR_WORKDIZZY ) > 0 ){ + flg |= BC_FLG_DIZZY; // 晕眩 + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKENTWINE ) > 0 ){ + flg |= BC_FLG_ENTWINE; // 树根缠绕 + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKDRAGNET ) > 0 ){ + flg |= BC_FLG_DRAGNET; // 天罗地网 + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKICECRACK ) > 0 ){ + // flg |= BC_FLG_ICECRACK; // 冰爆术 + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKOBLIVION ) > 0 ){ + flg |= BC_FLG_OBLIVION; // 遗忘 + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKICEARROW ) > 0 ){ + flg |= BC_FLG_ICEARROW; // 冰箭 + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKBLOODWORMS ) > 0 ){ + flg |= BC_FLG_BLOODWORMS; // 嗜血蛊 + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKSIGN ) > 0 ){ + flg |= BC_FLG_SIGN; // 一针见血 + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKINSTIGATE ) > 0 ){ + flg |= BC_FLG_CARY; // 挑拨 + } + if( CHAR_getWorkInt( charaindex, CHAR_WORK_F_ENCLOSE ) > 0 ){ + flg |= BC_FLG_F_ENCLOSE; // 火附体 + } + if( CHAR_getWorkInt( charaindex, CHAR_WORK_I_ENCLOSE ) > 0 ){ + flg |= BC_FLG_I_ENCLOSE; // 冰附体 + } + if( CHAR_getWorkInt( charaindex, CHAR_WORK_T_ENCLOSE ) > 0 ){ + flg |= BC_FLG_T_ENCLOSE; // 雷附体 + } +#endif +#ifdef _PROFESSION_ADDSKILL + if( CHAR_getWorkInt( charaindex, CHAR_WORKANNEX ) > 0 ){ + flg |= BC_FLG_T_ENCLOSE; // 附身术 + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKWATER ) > 0 ){ + flg |= BC_FLG_WATER; // 水附体 + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKFEAR ) > 0 ){ + flg |= BC_FLG_FEAR; // 恐惧 + } +#endif +#ifdef _PETSKILL_LER + if(CHAR_getWorkInt(charaindex,CHAR_WORK_RELIFE) > 0){ + flg |= BC_FLG_CHANGE; // 雷尔变身 + CHAR_setWorkInt(charaindex,CHAR_WORK_RELIFE,0); + } +#endif + makeEscapeString( CHAR_getUseName( charaindex ), + szEscapeName, + sizeof( szEscapeName ) ); + makeEscapeString( BATTLE_CharTitle( charaindex ), + szEscapeTitle, + sizeof( szEscapeTitle ) ); + // Robin 0728 ride Pet + petindex = BATTLE_getRidePet( charaindex ); + if( petindex != -1 ){ + rideflg = 1; + makeEscapeString( CHAR_getUseName( petindex ), + szEscapePetName, + sizeof( szEscapePetName ) ); + petlevel = CHAR_getInt( petindex, CHAR_LV); + pethp = CHAR_getInt( petindex, CHAR_HP); + petmaxhp = CHAR_getWorkInt( petindex, CHAR_WORKMAXHP); + + }else { + if( CHAR_getWorkInt( charaindex, CHAR_WORKPETFALL ) == 1 ){ + rideflg = -1; +#ifdef _PETSKILL_BECOMEFOX // 若中了媚惑术而落马时将讯息传给 Client + if( CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND ) != -1 ) + rideflg = -2; //client用来判断显示落马的文字 (对应的client变数为p_party[ BattleMyNo ]->onRide) +#endif +#ifdef _PETSKILL_BECOMEPIG // 若中了乌力化而落马时将讯息传给 Client + if( CHAR_getInt( charaindex, CHAR_BECOMEPIG) > 120 )//变成乌力了 + rideflg = -3; //client用来判断显示落马的文字 (对应的client变数为p_party[ BattleMyNo ]->onRide) +#endif + CHAR_setWorkInt( charaindex, CHAR_WORKPETFALL, 0 ); + } + else + rideflg = 0; + szEscapePetName[0] = 0; + petlevel = 0; + pethp = 0; + petmaxhp = 0; + } + + sprintf( szBuffer, "%X|%s|%s|%X|%X|%X|%X|%X|%X|%s|%X|%X|%X|", + pEntry[i].bid, + szEscapeName, + szEscapeTitle, + CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER ), + CHAR_getInt( charaindex, CHAR_LV ), + max( CHAR_getInt( charaindex, CHAR_HP ),0), + CHAR_getWorkInt( charaindex, CHAR_WORKMAXHP ), + flg, + rideflg, + szEscapePetName, + petlevel, + pethp, + petmaxhp + ); + STRCPY_TAIL( pszTop, pszLast, szBuffer ); + if( pszTop >= pszLast )return FALSE;// 译尹凶日撩 + } + } + + return TRUE; +} + +void BATTLE_BpSendToWatch( + BATTLE *pBattle, // 棋爵田玄伙正旦弁及禾奶件正 + char *pszBcString // BC 侬 +) +{ + + char szBp[256]; + int flg = 0, i, charaindex; + +// for( ; pBattle ; pBattle = pBattle->pNext ){ + if( pBattle == NULL )return; + // 仇及失玉伊旦互恳仄中井民尼永弁 + if( BATTLE_CHECKADDRESS( pBattle ) == FALSE ){ + fprint( "err:观战battle address错误(%p)\n", pBattle ); + return; + } + + // 蝈够卞霜耨 + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = pBattle->Side[0].Entry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) + != CHAR_TYPEPLAYER ) continue; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) + == BATTLE_CHARMODE_WATCHINIT){ + flg |= BP_FLG_JOIN; // 蕙筋辅笛 + } + flg |= BP_FLG_PLAYER_MENU_OFF; // 皿伊奶乩□丢瓦亘□请今卅中 + // 皿伊奶乩□ 寞霜月 + sprintf( szBp, "BP|%X|%X|%X", 20, flg, 0 ); + BATTLE_CommandSend( charaindex, szBp ); + // 蝈够隋骚树 霜月 + BATTLE_CommandSend( charaindex, pszBcString ); + } + // 戊穴件玉谨切尺 + pBattle->mode = BATTLE_MODE_WATCHPRE; +// } +} + +void BATTLE_CharSendAll( int battleindex ) +{ + int i, j, charaindex, flg, pet, At_SoubiIndex, pindex; + char szBp[256]; + BATTLE *pBattle; + + BATTLE_MakeCharaString( + battleindex, + szAllBattleString, + sizeof(szAllBattleString) + ); + + for( j = 0; j < 2; j ++ ){ + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + charaindex = BattleArray[battleindex].Side[j].Entry[i].charaindex; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )continue; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER )continue; + flg = 0; + if( BattleArray[battleindex].Side[j].flg & BSIDE_FLG_SURPRISE ){ + flg |= BP_FLG_ENEMY_SURPRISAL; + }else + if( BattleArray[battleindex].Side[1-j].flg & BSIDE_FLG_SURPRISE ){ + flg |= BP_FLG_PLAYER_SURPRISAL; + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) + == BATTLE_CHARMODE_RESCUE){ + flg |= BP_FLG_JOIN; // 辅爵 + } + At_SoubiIndex = CHAR_getItemIndex( charaindex, CHAR_ARM ); + if( ITEM_CHECKINDEX( At_SoubiIndex ) == FALSE ){ + }else{ + if( ITEM_getInt( At_SoubiIndex, ITEM_TYPE ) == ITEM_BOOMERANG ){ + flg |= BP_FLG_BOOMERANG; + } + } + + pet = CHAR_getInt( charaindex, CHAR_DEFAULTPET ); + if( pet >= 0 ){ + snprintf( szBp, sizeof( szBp ), "K%d", pet ); + CHAR_sendStatusString( charaindex, szBp ); + + pindex = CHAR_getCharPet( charaindex, pet ); + +#ifdef _PETSKILL_DAMAGETOHP + { +/* + 让开,让开~~~~~~~ + + ΘΘ + ⊙ ⊙ 我来给你送月饼了 +*/ + char msg[32]={0}; + //print("\n宠物id:%d",CHAR_getInt( pindex, CHAR_PETID)); + //print("\n宠物名:%s",CHAR_getChar( pindex, CHAR_NAME)); + //if( CHAR_getInt( pindex, CHAR_PETID) == 777 ){//宠物ID 水双头狼 + // || CHAR_getInt( pindex, CHAR_PETID) == 146 ) //火双头狼 + // && CHAR_getInt( pindex, CHAR_HP) ){ + sprintf( msg, "o%d", pet ); + CHAR_sendStatusString( charaindex, msg ); + + //} + } +#endif + +#ifdef _PETSKILL_BECOMEFOX // 限制中了媚惑术的宠物的技能 + //if( CHAR_getInt( pindex, CHAR_BASEIMAGENUMBER) == 101749 ){ + if( CHAR_getWorkInt( pindex, CHAR_WORKFOXROUND ) != -1 ){ //若是变成小狐狸 + char msg[32]={0}; + sprintf( msg, "a%d", pet ); + CHAR_sendStatusString( charaindex, msg ); + + } +#endif + + if( CHAR_CHECKINDEX( pindex ) == TRUE ){ + if( BATTLE_IsCharge( pindex ) == TRUE){ + flg |= BP_FLG_PET_MENU_OFF; + } + if( BATTLE_CanMoveCheck( pindex ) == FALSE ){ + flg |= BP_FLG_PET_MENU_OFF; + } + if( CHAR_getFlg( pindex, CHAR_ISDIE ) == TRUE ){ + flg |= BP_FLG_PET_MENU_OFF; + } + } + }else{ + flg |= BP_FLG_PET_MENU_OFF; + } + + if( BATTLE_CanMoveCheck( charaindex ) == FALSE + || CHAR_getFlg( charaindex, CHAR_ISDIE ) == TRUE + ){ + flg |= BP_FLG_PLAYER_MENU_OFF; + } + + if( BattleArray[battleindex].Side[j].flg & BSIDE_FLG_SURPRISE ){ + flg |= BP_FLG_PLAYER_MENU_OFF; + flg |= BP_FLG_PET_MENU_OFF; + } + sprintf( szBp, "BP|%X|%X|%X", + i + SIDE_OFFSET * j, + flg, CHAR_getInt( charaindex, CHAR_MP ) + ); + BATTLE_CommandSend( charaindex, szBp ); + BATTLE_CommandSend( charaindex, szAllBattleString ); + } + } + pBattle = BattleArray[battleindex].pNext; + for( ; pBattle ; pBattle = pBattle->pNext ){ + // 仇及失玉伊旦互恳仄中井民尼永弁 + if( BATTLE_CHECKADDRESS( pBattle ) == FALSE ){ + fprint( "err:观战battle address错误(%p)\n", pBattle ); + break; + } + + BATTLE_BpSendToWatch( pBattle, szAllBattleString ); + + } + + + +} + +void BattleEncountOut( int charaindex) +{ + + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEINDEX, -1 ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_MODE_NONE ); + + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX ) ); + CHAR_sendArroundCharaData( charaindex ); + + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEWATCH ) == 0 ){ + CHAR_sendBattleEffect( charaindex, OFF); + }else{ + CHAR_sendBattleWatch( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX ), OFF); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEWATCH, 0 ); + } + + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE ) == CHAR_PARTY_CLIENT ){ + int pmode/*, battleindex*/; + int pindex = CHAR_getWorkInt( charaindex, CHAR_WORKPARTYINDEX1 ); + pmode = CHAR_getWorkInt( pindex, CHAR_WORKBATTLEMODE ); + if( pmode > 0 && pmode != BATTLE_CHARMODE_FINAL ){ + BATTLE_RescueParentTry( charaindex, pindex ); + print( "较慢参加战斗(%s)\n", CHAR_getUseName( charaindex ) ); + } + } + +} + + +//************************************************** +// +// 犯白巧伙玄及戊穴件玉毛 木月矢永玄迕 +// +BOOL BATTLE_PetDefaultCommand( int petindex ) +// +//************************************************** +{ + if( CHAR_CHECKINDEX( petindex ) == FALSE )return FALSE; + // 锹澎及隙烂 + CHAR_setWorkInt( petindex, CHAR_WORKBATTLECOM2, -1 ); + // 骚橘 猾及隙烂 + CHAR_setWorkInt( petindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + // 戊穴件玉OK及隙烂 + CHAR_setWorkInt( petindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + return TRUE; +} + +#if 0 +{ + int Sign, Damage, i; + Sign = (LifeUp >= 0)?(1):(0); + Damage = ABS( LifeUp ); + + for( i = 0; i < ; i ++ ){ + // (蕙滇)仇仇匹戊穴件玉毛中木月 + snprintf( szCommand, sizeof(szCommand), "BD|r%X|0|%X|d%X|", ToList[i], Sign, Damage ); + BATTLESTR_ADD( szCommand ); +} + +#endif + +// Robin fix 检查石化昏睡不可战斗 +int checkErrorStatus( int charaindex) +{ + //if( BATTLE_CanMoveCheck( charaindex) == FALSE) { + + if( + CHAR_getWorkInt( charaindex, CHAR_WORKPARALYSIS ) > 0 // 麻痹 + || CHAR_getWorkInt( charaindex, CHAR_WORKSTONE ) > 0 // 石化 + || CHAR_getWorkInt( charaindex, CHAR_WORKSLEEP ) > 0 // 睡眠 + //|| CHAR_getWorkInt( charaindex, CHAR_WORKBARRIER ) > 0 // 魔障 + || CHAR_getWorkInt( charaindex, CHAR_WORKDIZZY ) > 0 // 晕眩 + || CHAR_getWorkInt( charaindex, CHAR_WORKDRAGNET ) > 0 // 天罗地网 + //|| CHAR_getWorkInt( charaindex, CHAR_WORK_T_ENCLOSE ) > 0 // 雷附体 +#ifdef _PROFESSION_ADDSKILL +// || CHAR_getWorkInt( charaindex, CHAR_DOOMTIME ) > 0 //世界末日集气 +#endif + ) + { + + char cdkey[128]; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) + strcpy( cdkey, CHAR_getChar( charaindex, CHAR_CDKEY)); + else + strcpy( cdkey, CHAR_getChar( charaindex, CHAR_OWNERCDKEY) ); + + print("\n 改封包!不可战斗的状态!!:%s ", cdkey ); + + return 1; + } + return 0; +} + diff --git a/gmsv/battle/battle_event.c b/gmsv/battle/battle_event.c new file mode 100644 index 0000000..86f7a4a --- /dev/null +++ b/gmsv/battle/battle_event.c @@ -0,0 +1,10231 @@ +#include "version.h" +#include +#include +#include "char.h" +#include "char_event.h" +#include "battle.h" +#include "battle_event.h" +#include "configfile.h" +#include "pet.h" +#include "log.h" +#include "lssproto_serv.h" +#include "anim_tbl.h" +#include "battle_magic.h" +#include "util.h" +#include "enemy.h" +#include "pet_skill.h" +#include "char_base.h" +#include "item_event.h" + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 +#include "profession_skill.h" +#include "item.h" +#include "skill.h" +#endif +#ifdef _PETSKILL_LER +#include "magic_base.h" +#endif + +#define DEFENSE_RATE (0.5) +#define DAMAGE_RATE (2.0) +#define CRITICAL_RATE (1.0) +#define KAWASHI_MAX_RATE (75) + +#define AJ_SAME (1.0) + +#define AJ_UP (1.5) +#define AJ_DOWN (0.6) + +#define ATTR_MAX 100 +#define D_ATTR (1.0/(ATTR_MAX*ATTR_MAX)) + +#define D_16 (1.0/16) +#define D_8 (1.0/8) + +float gKawashiPara = 0.02; +float gCounterPara = 0.08; +float gCriticalPara = 0.09; + +float gBattleDamageModyfy; +int gBattleDuckModyfy; +int gBattleStausChange; +int gBattleStausTurn; +float gDuckPer; +int gCriper; + +int gBattleBadStatusTbl[BATTLE_ENTRY_MAX*2]; + +#ifdef _OTHER_MAGICSTAUTS +#ifdef _MAGICSTAUTS_RESIST +char MagicStatus[MAXSTATUSTYPE][36] = { "NULL","魔抗","铁壁","火抗","电抗","冰抗"}; +int MagicTbl[] = { -1, CHAR_DEFMAGICSTATUS, CHAR_MAGICSUPERWALL, CHAR_MAGICFIRE, CHAR_MAGICTHUNDER, CHAR_MAGICICE }; +#else +char MagicStatus[MAXSTATUSTYPE][36] = { "NULL","魔抗","铁壁"}; +int MagicTbl[] = { -1, CHAR_DEFMAGICSTATUS, CHAR_MAGICSUPERWALL }; +#endif //_MAGICSTAUTS_RESIST +#endif + +char *aszStatus[] = { "全", "毒", "麻", "眠", "石", "醉", "乱", "虚", "剧", "障", "默" +#ifdef _PET_SKILL_SARS // WON ADD 毒煞蔓延 + ,"煞" +#endif +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + ,"晕","缠","罗","爆","忘","箭","蛊","针","挑","烧","霜","电","专","火","冰","雷","炎","冻","击" +#endif +#ifdef _PROFESSION_ADDSKILL + ,"抗" +#endif +}; + +char *aszStatusFull[] = { "全快", "毒", "麻痹", "睡眠", "石化", "酒醉", "混乱", "虚弱", "剧毒", "魔障", "沉默" +#ifdef _PET_SKILL_SARS // WON ADD 毒煞蔓延 + ,"毒煞" +#endif +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + ,"晕眩","缠绕","天罗","冰爆","遗忘","冰箭","嗜血蛊","一针见血","挑拨","火附体", + "冰附体","雷附体","专注战斗","火抗","冰抗","雷抗","火附","冰附","雷附" +#endif +}; + +int StatusTbl[] = { -1, CHAR_WORKPOISON, CHAR_WORKPARALYSIS, + CHAR_WORKSLEEP, CHAR_WORKSTONE, + CHAR_WORKDRUNK, CHAR_WORKCONFUSION, + CHAR_WORKWEAKEN, CHAR_WORKDEEPPOISON, + CHAR_WORKBARRIER, CHAR_WORKNOCAST +#ifdef _PET_SKILL_SARS // WON ADD 毒煞蔓延 + ,CHAR_WORKSARS +#endif +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + ,CHAR_WORKDIZZY, CHAR_WORKENTWINE + ,CHAR_WORKDRAGNET, CHAR_WORKICECRACK + ,CHAR_WORKOBLIVION, CHAR_WORKICEARROW + ,CHAR_WORKBLOODWORMS, CHAR_WORKSIGN + ,CHAR_WORKINSTIGATE, CHAR_WORK_F_ENCLOSE + ,CHAR_WORK_I_ENCLOSE, CHAR_WORK_T_ENCLOSE + ,CHAR_WORK_FOCUS, CHAR_WORKRESIST_F + ,CHAR_WORKRESIST_I, CHAR_WORKRESIST_T + ,CHAR_WORK_F_ENCLOSE_2, CHAR_WORK_I_ENCLOSE_2 + ,CHAR_WORK_T_ENCLOSE_2 +#endif +#ifdef _PROFESSION_ADDSKILL + ,CHAR_WORKERSIST_F_I_T, CHAR_WORKWATER//水附体 + ,CHAR_WORKANNEX//附身 + ,CHAR_WORKFEAR//恐惧 + ,CHAR_WORKICECRACK2 + ,CHAR_WORKICECRACK3 + ,CHAR_WORKICECRACK4 + ,CHAR_WORKICECRACK5 + ,CHAR_WORKICECRACK6 + ,CHAR_WORKICECRACK7 + ,CHAR_WORKICECRACK8 + ,CHAR_WORKICECRACK9 + ,CHAR_WORKICECRACK10 +#endif + }; + +int RegTbl[] = { -1, CHAR_WORKMODPOISON, CHAR_WORKMODPARALYSIS, + CHAR_WORKMODSLEEP, CHAR_WORKMODSTONE, + CHAR_WORKMODDRUNK, CHAR_WORKMODCONFUSION, + CHAR_WORKMODWEAKEN, CHAR_WORKMODDEEPPOISON, + CHAR_WORKMODBARRIER, CHAR_WORKMODNOCAST +#ifdef _PET_SKILL_SARS // WON ADD 毒煞蔓延 + ,CHAR_WORKMODSARS +#endif +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + ,CHAR_WORKMODDIZZY, CHAR_WORKMODENTWINE + ,CHAR_WORKMODDRAGNET, CHAR_WORKMODICECRACK + ,CHAR_WORKMODOBLIVION, CHAR_WORKMODICEARROW + ,CHAR_WORKMODBLOODWORMS, CHAR_WORKMODSIGN + ,CHAR_WORKMODINSTIGATE, CHAR_WORKMOD_F_ENCLOSE + ,CHAR_WORKMOD_I_ENCLOSE, CHAR_WORKMOD_T_ENCLOSE + ,CHAR_WORKMOD_FOCUS, CHAR_WORKMODRESIST_F + ,CHAR_WORKMODRESIST_I, CHAR_WORKMODRESIST_T + ,CHAR_WORKMOD_F_ENCLOSE_2, CHAR_WORKMOD_I_ENCLOSE_2 + ,CHAR_WORKMOD_T_ENCLOSE_2 +#endif + }; + +char *aszMagicDef[] = { "常", "吸", "反", "无" +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + ,"陷" +#endif +#ifdef _PETSKILL_ACUPUNCTURE + ,"刺" +#endif +}; + + + +char *aszMagicDefFull[] = { "通常", "吸收", "反射", "无效化" +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + ,"陷阱" +#endif +#ifdef _PETSKILL_ACUPUNCTURE + ,"针刺" +#endif +}; + + +int MagicDefTbl[] = { -1, CHAR_WORKDAMAGEABSROB, CHAR_WORKDAMAGEREFLEC, CHAR_WORKDAMAGEVANISH +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + ,CHAR_WORKTRAP +#endif +#ifdef _PETSKILL_ACUPUNCTURE + ,CHAR_WORKACUPUNCTURE +#endif +}; + +char *aszParamChange[] = { "无", "攻", "防", "早", "魅", "捕" }; +char *aszParamChangeFull[] = { "无", "攻击力", "防御力", "速度", "魅力", "捕获率" }; +int aParamChangeTbl[] = { -1, CHAR_WORKMODATTACK, CHAR_WORKMODDEFENCE, + CHAR_WORKMODQUICK, CHAR_WORKMODCHARM, CHAR_WORKMODCAPTURE }; + +// Robin 0727 Ride Pet +// 取得骑宠的index +int BATTLE_getRidePet( int charaindex ) +{ + int petindex = -1; + + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) + return -1; + else + { + int rideIndex = CHAR_getInt( charaindex, CHAR_RIDEPET ); + if( rideIndex == -1 ) + return -1; + petindex = CHAR_getCharPet( charaindex, rideIndex ); + if( !CHAR_CHECKINDEX( petindex ) ) return -1; + + } + + return petindex; + +} + +#ifdef _BACK_VERSION // 复刻版骑宠公式修改 +// Robin 0727 Ride Pet +// 取得骑宠时的叁围 复刻版 +float BATTLE_adjustRidePet3A( int charaindex, int petindex, int workindex, int action ) +{ + float ret = CHAR_getWorkInt( charaindex, workindex ); + BOOL throwweapon = BATTLE_IsThrowWepon(CHAR_getItemIndex( charaindex, CHAR_ARM ) ); + + switch( workindex ) { + case CHAR_WORKATTACKPOWER : // 攻击力 + if( throwweapon ) // 投掷 + ret = CHAR_getWorkInt( charaindex, CHAR_WORKATTACKPOWER );//间接攻击:人物 + else // 近战 + ret = CHAR_getWorkInt( petindex, CHAR_WORKATTACKPOWER );//直接攻击:宠物 + break; + case CHAR_WORKDEFENCEPOWER : // 防御力 + ret = ( CHAR_getWorkInt( charaindex, CHAR_WORKDEFENCEPOWER ) + CHAR_getWorkInt( petindex, CHAR_WORKDEFENCEPOWER ) ) / 2; + break; + case CHAR_WORKQUICK : // 敏捷力 + if( action == ATTACKSIDE ) { + if( throwweapon ) { + ret = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK ); + }else { + ret = CHAR_getWorkInt( petindex, CHAR_WORKQUICK ); + } + }else if( action == DEFFENCESIDE ){ + ret = CHAR_getWorkInt( petindex, CHAR_WORKQUICK ); + } + break; + default : + ret = CHAR_getWorkInt( charaindex, workindex ); + } + + //print(" adj3A_Old:%d:%d=%f ", charaindex, workindex, ret); + + return ret; +} + +#else +// 取得骑宠时的叁围 正常版 +float BATTLE_adjustRidePet3A( int charaindex, int petindex, int workindex, int action ) +{ + float ret = CHAR_getWorkInt( charaindex, workindex ); + BOOL throwweapon = BATTLE_IsThrowWepon(CHAR_getItemIndex( charaindex, CHAR_ARM ) ); + + switch( workindex ) { + case CHAR_WORKATTACKPOWER : // 攻击力 + if( throwweapon ) // 投掷 + ret = CHAR_getWorkInt( charaindex, CHAR_WORKATTACKPOWER ) +#ifdef _BATTLE_NEWPOWER //andy 1/24 reEdit + + CHAR_getWorkInt( petindex, CHAR_WORKATTACKPOWER )*0.4; +#else + + CHAR_getWorkInt( petindex, CHAR_WORKATTACKPOWER )*0.2; +#endif + else // 近战 + ret = CHAR_getWorkInt( charaindex, CHAR_WORKATTACKPOWER )*0.8 + + CHAR_getWorkInt( petindex, CHAR_WORKATTACKPOWER )*0.8; + break; + case CHAR_WORKDEFENCEPOWER : // 防御力 + ret = CHAR_getWorkInt( charaindex, CHAR_WORKDEFENCEPOWER )*0.7 + + CHAR_getWorkInt( petindex, CHAR_WORKDEFENCEPOWER )*0.7; + break; + case CHAR_WORKQUICK : // 敏捷力 + if( action == ATTACKSIDE ) { + if( throwweapon ) { + ret = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )*0.8 + + CHAR_getWorkInt( petindex, CHAR_WORKQUICK )*0.2; + }else { +#ifdef _BATTLE_NEWPOWER //andy 1/24 reEdit + ret = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )*0.2 + + CHAR_getWorkInt( petindex, CHAR_WORKQUICK )*0.8; + +#else + ret = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )*0.5 + + CHAR_getWorkInt( petindex, CHAR_WORKQUICK )*0.5; +#endif + } + }else + if( action == DEFFENCESIDE ){ + ret = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )*0.1 + + CHAR_getWorkInt( petindex, CHAR_WORKQUICK )*0.9; + } + break; + default : + ret = CHAR_getWorkInt( charaindex, workindex ); + } + + //print(" adj3A_Now:%d:%d=%f ", charaindex, workindex, ret); + + return ret; +} +#endif + +// Robin 0727 ride Pet 落马改图 +void BATTLE_changeRideImage( int index ) +{ + int itemindex = CHAR_getItemIndex(index,CHAR_ARM); + int category; + int newimagenumber; + int basebaseimagenumber + = CHAR_getInt(index,CHAR_BASEBASEIMAGENUMBER); + if( !ITEM_CHECKINDEX(itemindex) ) { + category = ITEM_FIST; + }else { + category = ITEM_getInt(itemindex,ITEM_TYPE ); + } + newimagenumber = CHAR_getNewImagenumberFromEquip( + basebaseimagenumber, category); + if( newimagenumber == -1) { + CHAR_setInt( index, CHAR_BASEIMAGENUMBER, basebaseimagenumber); + }else { + CHAR_setInt( index, CHAR_BASEIMAGENUMBER, newimagenumber); + } +} + +void BATTLE_talkToCli( + int charaindex, + char *pszBuffer, + int color +) +{ + if( getBattleDebugMsg( ) != 0 + && CHAR_getFlg( charaindex, CHAR_ISSHOWBATTLEMSG ) + ){ + CHAR_talkToCli( charaindex, -1, pszBuffer, color ); + } +} + + +int BATTLE_BroadCastBase( + int battleindex, + char *pszBuffer, + int color, + int flg +) +{ + int i, j, pindex; + BATTLE_ENTRY *pEntry; + + if( flg != 1 && getBattleDebugMsg( ) == 0 )return 0; + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX; + + for( j = 0; j < 2; j ++ ){ + pEntry = BattleArray[battleindex].Side[j].Entry; + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + pindex = pEntry[i].charaindex; + if( CHAR_CHECKINDEX( pindex ) == FALSE )continue; + if( CHAR_getInt( pindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER )continue; + if( CHAR_getFlg( pindex, CHAR_ISSHOWBATTLEMSG ) == FALSE ) continue; + CHAR_talkToCli( pindex, -1, pszBuffer, color ); + } + } + + return 0; +} + +// Nuke 20040112 fix for performance +/*int BATTLE_BroadCast( + int battleindex, + char *pszBuffer, + int color +) +{ + return BATTLE_BroadCastBase( battleindex, pszBuffer, color, 0 ); + +} + +int BATTLE_BroadCastOn( + int battleindex, + char *pszBuffer, + int color +) +{ + return BATTLE_BroadCastBase( battleindex, pszBuffer, color, 1 ); +} +*/ + +#ifdef _TAKE_ITEMDAMAGE +int BATTLE_ItemCrushCheck( int charaindex , int flg) +{//flg def 1 att 2 + int EquipTbl[CHAR_EQUIPPLACENUM], itemindex; + int i, rndwork; + int Crushs=0; + //char szBuffer[256]; + + memset( EquipTbl, -1, sizeof( EquipTbl)); + if( flg == 2 ) { + itemindex = CHAR_getItemIndex( charaindex, CHAR_ARM); + if( ITEM_CHECKINDEX( itemindex) == TRUE ) { + return CHAR_ARM; + } + return -1; + }else { + Crushs = rand()%100; + if( Crushs < 50 ) { + rndwork = CHAR_BODY; + }else if( Crushs >= 50 && Crushs < 67 ) { + rndwork = CHAR_HEAD; + }else if( Crushs >= 67 && Crushs < 84 ) { + rndwork = CHAR_DECORATION1; + }else { + rndwork = CHAR_DECORATION2; + } + + for( i = 0; i < CHAR_EQUIPPLACENUM; i ++ ){//CHAR_ARM + itemindex = CHAR_getItemIndex( charaindex, rndwork); + if( ITEM_CHECKINDEX( itemindex) == TRUE && rndwork != CHAR_ARM ){ + return rndwork; + }else { + rndwork++; + rndwork=rndwork%5; + } + } + } + return -1; +} +#else +int BATTLE_ItemCrushCheck( int charaindex ) +{ + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ){ + return FALSE; + } + if( RAND( 1, gItemCrushRate ) < CHAR_getInt( charaindex, CHAR_LV ) ){ + return TRUE; + }else{ + return FALSE; + } +} +#endif + +#define BREAK_NAME_WEPON "武器" +#define BREAK_NAME_AROMER "防具" +#define BREAK_BRACELET "护腕" +#define BREAK_MUSIC "乐器" +#define BREAK_NECKLACE "头饰" +#define BREAK_RING "戒指" +#define BREAK_BELT "皮带" +#define BREAK_EARRING "耳饰" +#define BREAK_NOSERING "鼻环" +#define BREAK_AMULET "护身符" +#define BREAK_OTHER "道具" + +#ifdef _TAKE_ITEMDAMAGE +static char *aszCrushTbl[] = { "完好", "受损", "毁坏" , "不堪使用" , "碎片" }; +#else +static char *aszCrushTbl[] = { "受损", "毁坏" }; +#endif + + +#ifdef _TAKE_ITEMDAMAGE +int BATTLE_ItemCrush( int charaindex, int ItemEquip, int Damages, int flg) +{ + int itemindex, breadnums; + int crushlevel, crushenum, maxcrushenum; + char szBuffer[256]=""; + int battleindex, bid; + + itemindex = CHAR_getItemIndex( charaindex, ItemEquip ); + if( ITEM_CHECKINDEX( itemindex ) == FALSE ) + return -1; + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + + bid = BATTLE_Index2No( battleindex, charaindex ); + + crushlevel = ITEM_getInt( itemindex, ITEM_CRUSHLEVEL); + if( crushlevel < 0 ) crushlevel=0; + + crushenum = ITEM_getInt( itemindex, ITEM_DAMAGECRUSHE); + maxcrushenum = ITEM_getInt( itemindex, ITEM_MAXDAMAGECRUSHE); + if( maxcrushenum < 1 ) return -1; + if( ItemEquip == CHAR_ARM ) { + if( (breadnums = ((Damages-50)/40)) <= 0 ) + breadnums = 1; + }else { + if( Damages >= 200 ) breadnums = 1; + if( (breadnums = ((200 - Damages)/20)) < 0 ) + breadnums = 1; + } + crushenum = crushenum - RAND( breadnums, (breadnums*1.4) ); + ITEM_setInt( itemindex, ITEM_DAMAGECRUSHE, crushenum); + + if( crushenum <= 0 ){ //损坏消失 + crushenum = 0; + sprintf(szBuffer, "%s因过度损坏而消失。\n", ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, szBuffer, CHAR_COLORYELLOW); + + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), +#endif + "因过度损坏而消失", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + CHAR_DelItem( charaindex, ItemEquip); + crushlevel = 4; + }else { //损坏扣值 + int defs, level=0; + + + defs = (crushenum*100)/maxcrushenum; + + if( defs >= 70 ){ + level = 0; + }else if( defs >= 50 && defs < 70 ) { + level = 1; + }else if( defs >= 30 && defs < 50 ) { + level = 2; + }else if( defs < 30 ) { + level = 3; + } + + if( level != crushlevel && defs < 70 ) { + ITEM_setInt( itemindex, ITEM_CRUSHLEVEL, level); +// for( i = 0; i < arraysizeof( ItemBreakPos ); i ++ ){ +// work = ITEM_getInt( itemindex, ItemBreakPos[i] ); +// if( work <= 0 )continue; +// work *=0.95; +// ITEM_setInt( itemindex, ItemBreakPos[i], work ); +// } + sprintf( szBuffer, "%s是%s的。", + ITEM_getChar( itemindex, ITEM_NAME ), aszCrushTbl[level] ); + CHAR_talkToCli( charaindex, -1, szBuffer, CHAR_COLORRED); + //更改道具说明 +// buf1 = ITEM_getChar( itemindex, ITEM_SECRETNAME); +// if( strstr( buf1, "(") != 0 ) { +// char buf5[256]; +// if( getStringFromIndexWithDelim( buf1,"(",1, buf5, sizeof( buf5)) != FALSE ) { +// sprintf( buf1, buf5); +// } +// } +// sprintf( buf2, "%s(%s)", buf1, aszCrushTbl[level]); +// ITEM_setChar( itemindex, ITEM_SECRETNAME, buf2); + } + } + + CHAR_sendItemDataOne( charaindex, ItemEquip ); + CHAR_complianceParameter( charaindex ); + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_ATK | CHAR_P_STRING_DEF + | CHAR_P_STRING_QUICK | CHAR_P_STRING_CHARM ); + + return TRUE; +} +#else +int BATTLE_ItemCrush( int charaindex ) +{ + int EquipTbl[CHAR_EQUIPPLACENUM], i, itemindex, rndwork, type; + int work, crushlevel, j, ItemEquip; + char szBuffer[256]=""; + + int ItemBreakPos[] = { + ITEM_ATTACKNUM_MIN, + ITEM_ATTACKNUM_MAX, + ITEM_MODIFYATTACK, + ITEM_MODIFYDEFENCE, + ITEM_MODIFYQUICK, + ITEM_MODIFYHP, + ITEM_MODIFYMP, + ITEM_MODIFYLUCK, + ITEM_MODIFYCHARM, + ITEM_MODIFYAVOID, + }; + + for( j = 0, i = 0; i < CHAR_EQUIPPLACENUM; i ++ ){ + itemindex = CHAR_getItemIndex( charaindex, i ); + if( ITEM_CHECKINDEX( itemindex ) == TRUE + && ITEM_getInt( itemindex, ITEM_MERGEFLG ) == 1 ){ + EquipTbl[j] = i; + j ++; + } + } + if( j == 0 )return FALSE; + rndwork = RAND( 0, j-1 ); + ItemEquip = EquipTbl[rndwork]; + itemindex = CHAR_getItemIndex( charaindex, ItemEquip ); + if( ITEM_CHECKINDEX( itemindex ) == FALSE )return FALSE; + crushlevel = ITEM_getInt( itemindex, ITEM_CRUSHLEVEL ); + if( crushlevel > 1 ) return FALSE; + { + if( crushlevel == 1 ){ + sprintf( szBuffer, "CrushLv2(毁坏道具Lv2)" ); + }else{ + sprintf( szBuffer, "CrushLv1(毁坏道具Lv1)" ); + } + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), +#endif + szBuffer, + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + + ); + } + + /*{ int battleindex, bid; + //sprintf( szBuffer, "(%s)的(%s)是(%s)\n", + // CHAR_getUseName( charaindex ), + // ITEM_getChar( itemindex, ITEM_NAME ), + // aszCrushTbl[crushlevel] ); + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + + bid = BATTLE_Index2No( battleindex, charaindex ); + //BATTLE_BroadCast( battleindex, szBuffer, + (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + }*/ + + type = ITEM_getInt( itemindex, ITEM_TYPE ); + szBuffer[0] = 0; + switch( type ){ + case ITEM_FIST: + case ITEM_AXE: + case ITEM_CLUB: + case ITEM_SPEAR: + case ITEM_BOW: + case ITEM_BOOMERANG: + case ITEM_BOUNDTHROW: + case ITEM_BREAKTHROW: + sprintf( szBuffer, "%s%s", aszCrushTbl[crushlevel], BREAK_NAME_WEPON ); + break; + + case ITEM_HELM: + case ITEM_ARMOUR: + sprintf( szBuffer, "%s%s", aszCrushTbl[crushlevel], BREAK_NAME_AROMER ); + break; + + case ITEM_BRACELET: sprintf( szBuffer, "%s%s", aszCrushTbl[crushlevel], BREAK_BRACELET );break; + case ITEM_MUSIC: sprintf( szBuffer, "%s%s", aszCrushTbl[crushlevel], BREAK_MUSIC );break; + case ITEM_NECKLACE: sprintf( szBuffer, "%s%s", aszCrushTbl[crushlevel], BREAK_NECKLACE );break; + case ITEM_RING: sprintf( szBuffer, "%s%s", aszCrushTbl[crushlevel], BREAK_RING );break; + case ITEM_BELT: sprintf( szBuffer, "%s%s", aszCrushTbl[crushlevel], BREAK_BELT );break; + case ITEM_EARRING: sprintf( szBuffer, "%s%s", aszCrushTbl[crushlevel], BREAK_EARRING );break; + case ITEM_NOSERING: sprintf( szBuffer, "%s%s", aszCrushTbl[crushlevel], BREAK_NOSERING );break; + case ITEM_AMULET: sprintf( szBuffer, "%s%s", aszCrushTbl[crushlevel], BREAK_AMULET );break; + case ITEM_OTHER: sprintf( szBuffer, "%s%s", aszCrushTbl[crushlevel], BREAK_OTHER );break; + default: + sprintf( szBuffer, "%s%s", aszCrushTbl[crushlevel], BREAK_OTHER );break; + break; + } + ITEM_setChar( itemindex, ITEM_SECRETNAME, szBuffer ); + + for( i = 0; i < arraysizeof( ItemBreakPos ); i ++ ){ + work = ITEM_getInt( itemindex, ItemBreakPos[i] ); + if( work <= 0 )continue; + if( crushlevel == 1 ){ + work = 1; + }else{ + work /= 2; + if( work < 1 ) work = 1; + } + ITEM_setInt( itemindex, ItemBreakPos[i], work ); + } + CHAR_sendItemDataOne( charaindex, ItemEquip ); + ITEM_setInt( itemindex, ITEM_CRUSHLEVEL, crushlevel + 1 ); + CHAR_complianceParameter( charaindex ); + CHAR_send_P_StatusString( charaindex, + CHAR_P_STRING_ATK + | CHAR_P_STRING_DEF + | CHAR_P_STRING_QUICK + | CHAR_P_STRING_CHARM ); + + return TRUE; +} +#endif + +#ifdef _TAKE_ITEMDAMAGE +static int BATTLE_ItemCrushSeq( int attackindex, int charaindex, int Damages) +{ + int iRet = FALSE; + int crushindex=-1, crushpower; + int flg=0;//flg def 1 att 2 + + flg=1; + if( ( crushindex = BATTLE_ItemCrushCheck( charaindex, flg) ) >= 0 ) { + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ){ + crushpower = CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER); + BATTLE_ItemCrush( charaindex, crushindex, Damages, flg); + } + } + flg=2; + if( ( crushindex = BATTLE_ItemCrushCheck( attackindex, flg) ) >= 0 ) { + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ){ + crushpower = CHAR_getWorkInt( charaindex, CHAR_WORKDEFENCEPOWER); + BATTLE_ItemCrush( attackindex, crushindex, Damages, flg); + } + } + + return iRet; +} + +#else + +static int BATTLE_ItemCrushSeq( int charaindex ) +{ + char szWork[256]; + int iRet = FALSE; + + if( BATTLE_ItemCrushCheck( charaindex ) == TRUE ){ + if( BATTLE_ItemCrush( charaindex ) == TRUE ){ + sprintf( szWork, "BK|%s的\t装备受到损伤。", + CHAR_getUseName( charaindex ) ); + strcat( szBadStatusString, szWork ); + iRet = TRUE; + } + } + return iRet; +} +#endif + +#ifdef _EQUIT_ARRANGE +static BOOL BATTLE_ArrangeCheck( int attackindex, int defindex) +{ + int DEF_ARR; + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_GUARD ){ + return FALSE; + } + if( BATTLE_GetDamageReact( defindex ) > 0 ){ + return FALSE; + } + if( BATTLE_CanMoveCheck( defindex ) == FALSE ){ + return FALSE; + } + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_NODUCK ){ + return FALSE; + } + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_ABIO ){ + return FALSE; + } + if( (DEF_ARR = CHAR_getWorkInt( defindex, CHAR_WORKARRANGEPOWER )) > 0 ){ + int per = (DEF_ARR > 700)?700:DEF_ARR; + if( RAND( 1, 1000 ) <= per ){ + return TRUE; + } + } + + return FALSE; +} +#endif + +//回避判定 +static BOOL BATTLE_DuckCheck( + int attackindex, + int defindex +) +{ + int flg = FALSE; + + int Df_Dex, At_Dex, Df_Luck = 0; + float per, Work, wari, Big, Small; + + gDuckPer = 0; + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_GUARD ){ + return FALSE; + } + if( BATTLE_GetDamageReact( defindex ) > 0 ){ + return FALSE; + } + if( BATTLE_CanMoveCheck( defindex ) == FALSE ){ +#ifdef _PROFESSION_ADDSKILL + if( CHAR_getWorkInt( defindex, CHAR_DOOMTIME ) <= 0 )//集气时可闪避(并且没有处於天罗地网和盾击的状态) + return FALSE; + else{ + if( CHAR_getWorkInt( defindex, CHAR_WORKDRAGNET ) == 0 + && CHAR_getWorkInt( defindex, CHAR_WORKDIZZY ) == 0 ){ + } + else{ + return FALSE; + } + } +#else + return FALSE; +#endif + } + + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_NODUCK ){ + return FALSE; + } + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_ABIO ){ + return FALSE; + } + +#ifdef _PETSKILL_SETDUCK + if( BATTLE_CheckMySkillDuck( defindex ) == TRUE ){ + return TRUE; + } +#endif + + At_Dex = CHAR_getWorkInt( attackindex, CHAR_WORKFIXDEX ); + Df_Dex = CHAR_getWorkInt( defindex, CHAR_WORKFIXDEX ); + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + Df_Luck = CHAR_getWorkInt( defindex, CHAR_WORKFIXLUCK ); + } + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY + && CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + At_Dex *= 0.8; + }else + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) != CHAR_TYPEENEMY + && CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET + ){ + Df_Dex *= 0.8; + }else + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER + && CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + At_Dex *= 0.6; + }else + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER + && CHAR_getInt( defindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ){ + Df_Dex *= 0.6; + } + + if( Df_Dex >= At_Dex ){ + Big = Df_Dex; + Small = At_Dex; + wari = 1.0; + }else{ + Big = At_Dex; + Small = Df_Dex; + if( Big <= 0 ){ + wari = 0.0; + }else{ + wari = Small / Big; + } + } + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_JYUJYUTU ){ + gKawashiPara = 0.027; + }else{ + gKawashiPara = 0.02; + } + Work = ( Big - Small ) / gKawashiPara; + if( Work <= 0 ) Work = 0; + per = (float)( sqrt( (double)Work ) ); + per *= wari; + per += Df_Luck; + + per += gBattleDuckModyfy; + if( CHAR_getWorkInt( attackindex, CHAR_WORKDRUNK ) > 0 ){ + per += RAND( 20, 30 ); + } + if( gWeponType == ITEM_BOW ){ + per += 20; + } + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_NOGUARD ){ + per += CHAR_GETWORKINT_HIGH( defindex, CHAR_WORKBATTLECOM3 ); + } + + if( gWeponType == ITEM_BOW ){ + per += 20; + } + + per *= 100; + if( per > KAWASHI_MAX_RATE*100 ) per = KAWASHI_MAX_RATE*100; + if( per <= 0 ) per = 1; + + gDuckPer = per * 0.01; +#ifdef _EQUIT_HITRIGHT + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + int AddHit = CHAR_getWorkInt( attackindex, CHAR_WORKHITRIGHT); + per -= RAND( AddHit*0.8, AddHit*1.2); + per = ( per < 0 )?0:per; + } +#endif + + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + per = BATTLE_check_profession_duck( defindex, per ); +#endif + +#ifdef _PROFESSION_ADDSKILL + if( CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_CHAOS ){ //混乱攻击时命中降低 + per += (per*0.4); + } +#endif + + if( RAND( 1, 10000 ) <= per ){ + flg = TRUE; +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + // 回避技能升级 + if( (CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER) ){ + PROFESSION_SKILL_LVEVEL_UP( defindex, "PROFESSION_AVOID" ); + } +#endif + }else{ + flg = FALSE; + } + return flg; +} + +static int BATTLE_AttrCalc( + int My_Fire, + int My_Water, + int My_Earth, + int My_Wind, + int My_None, + int Vs_Fire, + int Vs_Water, + int Vs_Earth, + int Vs_Wind, + int Vs_None +) +{ + int iRet = 0; + My_Fire = My_Fire * Vs_None * AJ_UP + + My_Fire * Vs_Fire * AJ_SAME + + My_Fire * Vs_Water * AJ_DOWN + + My_Fire * Vs_Earth * AJ_SAME + + My_Fire * Vs_Wind * AJ_UP; + My_Water = My_Water * Vs_None * AJ_UP + + My_Water * Vs_Fire * AJ_UP + + My_Water * Vs_Water * AJ_SAME + + My_Water * Vs_Earth * AJ_DOWN + + My_Water * Vs_Wind * AJ_SAME; + + My_Earth = My_Earth * Vs_None * AJ_UP + + My_Earth * Vs_Fire * AJ_SAME + + My_Earth * Vs_Water * AJ_UP + + My_Earth * Vs_Earth * AJ_SAME + + My_Earth * Vs_Wind * AJ_DOWN; + + My_Wind = My_Wind * Vs_None * AJ_UP + + My_Wind * Vs_Fire * AJ_DOWN + + My_Wind * Vs_Water * AJ_SAME + + My_Wind * Vs_Earth * AJ_UP + + My_Wind * Vs_Wind * AJ_SAME; + + My_None = My_None * Vs_None * AJ_SAME + + My_None * Vs_Fire * AJ_DOWN + + My_None * Vs_Water * AJ_DOWN + + My_None * Vs_Earth * AJ_DOWN + + My_None * Vs_Wind * AJ_DOWN; + + iRet = (My_Fire + My_Water + My_Earth + My_Wind + My_None) ; + return (iRet * D_ATTR); +} + +static void BATTLE_GetAttr( int charaindex, int *T_pow ) +{ +#ifdef _BATTLE_NEWPOWER +#else + int petindex = BATTLE_getRidePet( charaindex ); + if( petindex == -1 ){ +#endif + T_pow[0] = CHAR_getWorkInt( charaindex, CHAR_WORKFIXEARTHAT ); + T_pow[1] = CHAR_getWorkInt( charaindex, CHAR_WORKFIXWATERAT ); + T_pow[2] = CHAR_getWorkInt( charaindex, CHAR_WORKFIXFIREAT ); + T_pow[3] = CHAR_getWorkInt( charaindex, CHAR_WORKFIXWINDAT ); +/* + *pAt_Fire = CHAR_getWorkInt( charaindex, CHAR_WORKFIXFIREAT ); + *pAt_Water = CHAR_getWorkInt( charaindex, CHAR_WORKFIXWATERAT ); + *pAt_Earth = CHAR_getWorkInt( charaindex, CHAR_WORKFIXEARTHAT ); + *pAt_Wind = CHAR_getWorkInt( charaindex, CHAR_WORKFIXWINDAT ); +*/ +#ifdef _BATTLE_NEWPOWER +#else + }else { // Robin 0727 when Ride Pet +#endif +#ifdef _BATTLE_NEWPOWER +#else + T_pow[0] = ( CHAR_getWorkInt( charaindex, CHAR_WORKFIXEARTHAT ) + + CHAR_getWorkInt( petindex, CHAR_WORKFIXEARTHAT )) /2; + T_pow[1] = ( CHAR_getWorkInt( charaindex, CHAR_WORKFIXWATERAT ) + + CHAR_getWorkInt( petindex, CHAR_WORKFIXWATERAT )) /2; + T_pow[2] = ( CHAR_getWorkInt( charaindex, CHAR_WORKFIXFIREAT ) + + CHAR_getWorkInt( petindex, CHAR_WORKFIXFIREAT )) /2; + T_pow[3] = ( CHAR_getWorkInt( charaindex, CHAR_WORKFIXWINDAT ) + + CHAR_getWorkInt( petindex, CHAR_WORKFIXWINDAT )) /2; +/* + *pAt_Fire = ( CHAR_getWorkInt( charaindex, CHAR_WORKFIXFIREAT ) + + CHAR_getWorkInt( petindex, CHAR_WORKFIXFIREAT )) /2; + *pAt_Water = ( CHAR_getWorkInt( charaindex, CHAR_WORKFIXWATERAT ) + + CHAR_getWorkInt( petindex, CHAR_WORKFIXWATERAT )) /2; + *pAt_Earth = ( CHAR_getWorkInt( charaindex, CHAR_WORKFIXEARTHAT ) + + CHAR_getWorkInt( petindex, CHAR_WORKFIXEARTHAT )) /2; + *pAt_Wind = ( CHAR_getWorkInt( charaindex, CHAR_WORKFIXWINDAT ) + + CHAR_getWorkInt( petindex, CHAR_WORKFIXWINDAT )) /2; +*/ + } +#endif +#ifdef _PROFESSION_ADDSKILL + //加上结界 + //T_pow[0] += T_pow[0]*( (CHAR_getWorkInt( charaindex, CHAR_WORKFIXEARTHAT_BOUNDARY )>>16&0x0000ffff) /100 ); + //T_pow[1] += T_pow[1]*( (CHAR_getWorkInt( charaindex, CHAR_WORKFIXWATERAT_BOUNDARY )>>16&0x0000ffff) /100 ); + //T_pow[2] += T_pow[2]*( (CHAR_getWorkInt( charaindex, CHAR_WORKFIXFIREAT_BOUNDARY )>>16&0x0000ffff) /100 ); + //T_pow[3] += T_pow[3]*( (CHAR_getWorkInt( charaindex, CHAR_WORKFIXWINDAT_BOUNDARY )>>16&0x0000ffff) /100 ); +#endif +#ifdef _SUIT_TWFWENDUM + T_pow[0] = (T_pow[0]+CHAR_getWorkInt( charaindex, CHAR_WORK_EA ))>100?100:(T_pow[0]+CHAR_getWorkInt( charaindex, CHAR_WORK_EA )); + T_pow[1] = (T_pow[1]+CHAR_getWorkInt( charaindex, CHAR_WORK_WR ))>100?100:(T_pow[1]+CHAR_getWorkInt( charaindex, CHAR_WORK_EA )); + T_pow[2] = (T_pow[2]+CHAR_getWorkInt( charaindex, CHAR_WORK_FI ))>100?100:(T_pow[2]+CHAR_getWorkInt( charaindex, CHAR_WORK_EA )); + T_pow[3] = (T_pow[3]+CHAR_getWorkInt( charaindex, CHAR_WORK_WI ))>100?100:(T_pow[3]+CHAR_getWorkInt( charaindex, CHAR_WORK_EA )); +#endif + { + int i, renum=ATTR_MAX; + for( i=0; i<4; i++) { + if( T_pow[ i] < 0 ) T_pow[ i] = 0; + renum -= T_pow[ i]; + } + if( renum < 0 ) renum = 0; + T_pow[ 4] = renum; + } +/* + if( *pAt_Fire < 0 ) *pAt_Fire = 0; + if( *pAt_Water < 0 ) *pAt_Water = 0; + if( *pAt_Earth < 0 ) *pAt_Earth = 0; + if( *pAt_Wind < 0 ) *pAt_Wind = 0; + *pAt_None = ATTR_MAX - *pAt_Fire - *pAt_Water - *pAt_Earth - *pAt_Wind; + if( *pAt_None < 0 )*pAt_None = 0; +*/ +} + + +float BATTLE_FieldAttAdjust( + int battleindex, + int pAt_Fire, + int pAt_Water, + int pAt_Earth, + int pAt_Wind +) +{ +#define AJ_BOTTOM (0.5) +#define AJ_PLUS (0.5) + int att; + float power, a_pow; + att = BattleArray[battleindex].field_att; + a_pow = (float)(BattleArray[battleindex].att_pow); + + switch( att ){ + case BATTLE_ATTR_EARTH: + power = AJ_BOTTOM + (pAt_Earth) * a_pow * 0.01 * 0.01 * AJ_PLUS; + break; + case BATTLE_ATTR_WATER: + power = AJ_BOTTOM + (pAt_Water) * a_pow * 0.01 * 0.01 * AJ_PLUS ; + break; + case BATTLE_ATTR_FIRE: + power = AJ_BOTTOM + (pAt_Fire) * a_pow * 0.01 * 0.01 * AJ_PLUS ; + break; + case BATTLE_ATTR_WIND: + power = AJ_BOTTOM + (pAt_Wind) * a_pow * 0.01 * 0.01 * AJ_PLUS ; + break; + default: + power = AJ_BOTTOM; + break; + } + return power; +} + +static int BATTLE_AttrAdjust( + int attackindex, + int defindex, + int damage +) +{ + int At_pow[5]={0,0,0,0,0}; //地水火风 + int Dt_pow[5]={0,0,0,0,0}; + int i; + float At_FieldPow, Df_FieldPow; +#ifdef _BATTLE_PROPERTY + int (*loopfunc)(int,int,int*,int*,int)=NULL; +#endif + + BATTLE_GetAttr( attackindex, At_pow); + BATTLE_GetAttr( defindex, Dt_pow); + +#ifdef _PSKILL_MDFYATTACK + if( CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM1) == BATTLE_COM_S_MDFYATTACK ) { + int MKind=-1, MODS=0; + MKind = CHAR_GETWORKINT_LOW( attackindex, CHAR_WORKBATTLECOM4); + MODS = CHAR_GETWORKINT_HIGH( attackindex, CHAR_WORKBATTLECOM4); + + for( i=0; i<5; i++) { + At_pow[ i] = 0; + } + + if( MKind >= 0 && MKind <= 4 ){ + At_pow[ MKind] = MODS; + At_pow[ 4] = 0; + } + } +#endif +#ifdef _BATTLE_PROPERTY + loopfunc =(int(*)(int,int,int*,int*,int))CHAR_getFunctionPointer( attackindex, CHAR_BATTLEPROPERTY); + if( loopfunc ){ + loopfunc( attackindex, defindex, &damage, At_pow, 5); + } +#endif +#ifdef _BATTLE_PROPERTY + loopfunc = NULL; + loopfunc =(int(*)(int,int,int*,int*,int))CHAR_getFunctionPointer( defindex, CHAR_BATTLEPROPERTY); + if( loopfunc ){ + loopfunc( defindex, attackindex, &damage, Dt_pow, 5); + } +#endif + + At_FieldPow = BATTLE_FieldAttAdjust( + CHAR_getWorkInt( attackindex, CHAR_WORKBATTLEINDEX ), At_pow[ 2], At_pow[ 1], At_pow[ 0], At_pow[ 3] ); + Df_FieldPow = BATTLE_FieldAttAdjust( + CHAR_getWorkInt( defindex, CHAR_WORKBATTLEINDEX ), Dt_pow[ 2], Dt_pow[ 1], Dt_pow[ 0], Dt_pow[ 3] ); + + for( i=0; i<5; i++) { + At_pow[ i] *= damage; + } +/* + At_Fire *= damage; At_Water *= damage; At_pow[0] *= damage; + At_Wind *= damage; At_none *= damage; +*/ + damage = BATTLE_AttrCalc(//火2水1第0封3 + At_pow[ 2], At_pow[ 1], At_pow[ 0], At_pow[ 3], At_pow[ 4], + Dt_pow[ 2], Dt_pow[ 1], Dt_pow[ 0], Dt_pow[ 3], Dt_pow[ 4] ); + damage *= (At_FieldPow / Df_FieldPow); + + return damage; +} + +int BATTLE_GuardAdjust( int damage ) +{ + int Rand = RAND( 1, 100 ); + if( Rand <= 25 ){ + damage *= 0.00; + }else{ + if( Rand <= 50 ){ + damage *= 0.10; + }else{ + if( Rand <= 70 ){ + damage *= 0.20; + }else{ + if( Rand <= 85 ){ + damage *= 0.30; + }else{ + if( Rand <= 95 ){ + damage *= 0.40; + }else{ + damage *= 0.50; + } + } + } + } + } + return damage; +} + +//计算伤害值 +int BATTLE_DamageCalc( int attackindex, int defindex ) +{ + float attack, defense; + int damage = 0; + int attackpet = BATTLE_getRidePet( attackindex ); + int defpet = BATTLE_getRidePet( defindex ); + + // Robin 0727 Ride Pet + if( attackpet == -1 ) { + attack = CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER ); + }else { + attack = BATTLE_adjustRidePet3A( attackindex, attackpet, CHAR_WORKATTACKPOWER, ATTACKSIDE ); + } + if( defpet == -1 ) { +#ifdef _BATTLE_NEWPOWER + defense = CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ) * 0.70; +#else + defense = CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ) * 0.45; + defense += CHAR_getWorkInt( defindex, CHAR_WORKQUICK ) * 0.2; + defense += CHAR_getWorkInt( defindex, CHAR_WORKFIXVITAL ) * 0.1; +#endif + }else { +#ifdef _BATTLE_NEWPOWER + defense = BATTLE_adjustRidePet3A( defindex, defpet, CHAR_WORKDEFENCEPOWER, DEFFENCESIDE ) * 0.70; +#else + defense = BATTLE_adjustRidePet3A( defindex, defpet, CHAR_WORKDEFENCEPOWER, DEFFENCESIDE ) * 0.45; + defense += BATTLE_adjustRidePet3A( defindex, defpet, CHAR_WORKQUICK, DEFFENCESIDE ) * 0.20; + defense += CHAR_getWorkInt( defindex, CHAR_WORKFIXVITAL ) * 0.05; +#endif + } + +#ifdef _MAGIC_SUPERWALL //铁壁防御 + if( CHAR_getWorkInt( defindex, CHAR_MAGICSUPERWALL ) > 0 ){ + float def = (float)(CHAR_getWorkInt( defindex, CHAR_OTHERSTATUSNUMS )); + def = (def + rand()%20)/100; + defense += defense * def; + } +#endif +#ifdef _NPCENEMY_ADDPOWER //修改怪物的能力值 + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ) { + defense += (defense*(rand()%10)+2)/100; + } + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ) { + attack += (attack*(rand()%10)+2)/100; + } +#endif + if( CHAR_getWorkInt( defindex, CHAR_WORKSTONE ) > 0 ) defense *= 2.0; + +#ifdef _PETSKILL_REGRET + //无装备防御 + if( CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_REGRET + || CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_REGRET2 ) + defense = CHAR_getWorkInt(defindex,CHAR_WORKFIXTOUGH); +#endif + +#ifdef _EQUIT_NEGLECTGUARD //忽视目标防御力% + if( CHAR_getWorkInt( attackindex, CHAR_WORKNEGLECTGUARD) > 1 ) { + float defp = (float)CHAR_getWorkInt( attackindex, CHAR_WORKNEGLECTGUARD); + defp = 1 - (defp/100); + defense = defense*defp; + } +#endif + + if( defense <= attack && attack < (defense * 8.0/7.0) ){ + damage = (int)(RAND( 0, attack * D_16 )); + }else + if( defense > attack ){ + damage = (int)(RAND( 0, 1 )); + }else + if( attack >= (defense * 8/7) ){ + float K0; + K0 = RAND( 0, attack*D_8 ) - attack*D_16; + damage = (int)(( (attack - defense )*DAMAGE_RATE ) + K0); + } + + //四属性 + damage = BATTLE_AttrAdjust( attackindex, defindex, damage ); + +#ifdef _PROFESSION_ADDSKILL + { + //四属结界 + if( ((CHAR_getWorkInt( defindex, CHAR_WORKFIXEARTHAT_BOUNDARY )>>16) & 0x0000ffff) > 0 ){ + if( CHAR_getWorkInt( attackindex, CHAR_WORKFIXEARTHAT ) > 0 ) + damage -= damage*(float)((CHAR_getWorkInt( attackindex, CHAR_WORKFIXEARTHAT )/200.0)); + }else if( ((CHAR_getWorkInt( defindex, CHAR_WORKFIXWATERAT_BOUNDARY )>>16) & 0x0000ffff) > 0 ){ + if( CHAR_getWorkInt( attackindex, CHAR_WORKFIXWATERAT ) > 0 ) + damage -= damage*(float)((CHAR_getWorkInt( attackindex, CHAR_WORKFIXWATERAT )/200.0)); + }else if( ((CHAR_getWorkInt( defindex, CHAR_WORKFIXFIREAT_BOUNDARY )>>16) & 0x0000ffff) > 0 ){ + if( CHAR_getWorkInt( attackindex, CHAR_WORKFIXFIREAT ) > 0 ) + damage -= damage*(float)((CHAR_getWorkInt( attackindex, CHAR_WORKFIXFIREAT )/200.0)); + }else if( ((CHAR_getWorkInt( defindex, CHAR_WORKFIXWINDAT_BOUNDARY )>>16) & 0x0000ffff) > 0 ){ + if( CHAR_getWorkInt( attackindex, CHAR_WORKFIXWINDAT ) > 0 ) + damage -= damage*(float)((CHAR_getWorkInt( attackindex, CHAR_WORKFIXWINDAT )/200.0)); + } + //T_pow[1] += T_pow[1]*( (CHAR_getWorkInt( charaindex, CHAR_WORKFIXWATERAT_BOUNDARY )>>16&0x0000ffff) /100 ); + //T_pow[2] += T_pow[2]*( (CHAR_getWorkInt( charaindex, CHAR_WORKFIXFIREAT_BOUNDARY )>>16&0x0000ffff) /100 ); + //T_pow[3] += T_pow[3]*( (CHAR_getWorkInt( charaindex, CHAR_WORKFIXWINDAT_BOUNDARY )>>16&0x0000ffff) /100 ); + } +#endif + +#ifdef _ADD_DEAMGEDEFC //额外伤害 & 附加攻击 + { + int apower, dpower, otherpower; + apower = CHAR_getWorkInt( attackindex, CHAR_WORKOTHERDMAGE); + dpower = CHAR_getWorkInt( defindex, CHAR_WORKOTHERDEFC); + + otherpower = RAND( apower*0.3, apower) - RAND( dpower*0.3, dpower); + if( otherpower != 0 ) { + damage += otherpower; + } + } + if( damage < 0 ) + damage = 0; +#endif + + return damage; +} + +static int BATTLE_CriticalCheckPlayer( int attackindex, int defindex ) +{ + int At_Dex, At_Luck = 0, At_Kiryoku = 0, At_Soubi = 0; + int At_SoubiIndex, Df_Dex, root = 1; + float per, Work, Big, Small, wari, divpara = gCriticalPara; + + // WON REM + //if( gWeponType == ITEM_BOW )return 0; + + At_Dex = CHAR_getWorkInt( attackindex, CHAR_WORKFIXDEX ); + Df_Dex = CHAR_getWorkInt( defindex, CHAR_WORKFIXDEX ); + + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + At_Luck = CHAR_getWorkInt( attackindex, CHAR_WORKFIXLUCK ); + } + At_SoubiIndex = CHAR_getItemIndex( attackindex, CHAR_ARM ); + At_Kiryoku = CHAR_getInt( attackindex, CHAR_MP ); + + if( ITEM_CHECKINDEX( At_SoubiIndex ) == TRUE ){ + At_Soubi = ITEM_getInt( At_SoubiIndex, ITEM_CRITICAL ); + } + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET + && CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY){ + Df_Dex *= 0.8; + }else + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY + && CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET){ + divpara = 10.0; + root = 0; + }else + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER + && CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER){ + divpara = 10.0; + root = 0; + }else + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER + && CHAR_getInt( defindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER){ + Df_Dex *= 0.6; + } + + if( At_Dex >= Df_Dex ){ + Big = At_Dex; + Small = Df_Dex; + wari = 1.0; + }else{ + Big = Df_Dex; + Small = At_Dex; + if( Big <= 0 ){ + wari = 0.0; + }else{ + wari = Small / Big; + } + } + Work = ( Big - Small ) / divpara; + if( Work <= 0 ) Work = 0; + + if( root == 1 ){ + per = (float)( sqrt( (double)Work ) ) + At_Soubi * 0.5; + }else{ + per = (float)Work + At_Soubi * 0.5; + } + per *= wari; + per += At_Luck ; + per *= 100; + if( per < 0 ) per = 1; + if( per > 10000 ) per = 10000; +#ifdef _PETSKILL_LER + // 雷尔不能被打飞 + if(CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101813 || + CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101814) per = 0; +#endif + return (int)per; +} + +#if 0 +static int BATTLE_CriticalCheckEnemy( + int attackindex, + int defindex +) +{ + int At_Dex, At_Luck = 0, At_Kiryoku = 0, At_Soubi = 0; + int At_SoubiIndex, Df_Dex; + float per, Work, Big, Small, wari; + + if( gWeponType == ITEM_BOW )return 0; + + At_Dex = CHAR_getWorkInt( attackindex, CHAR_WORKFIXDEX ); + Df_Dex = CHAR_getWorkInt( defindex, CHAR_WORKFIXDEX ); + + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + At_Luck = CHAR_getWorkInt( attackindex, CHAR_WORKFIXLUCK ); + } + At_SoubiIndex = CHAR_getItemIndex( attackindex, CHAR_ARM ); + At_Kiryoku = CHAR_getInt( attackindex, CHAR_MP ); + + if( ITEM_CHECKINDEX( At_SoubiIndex ) == TRUE ){ + At_Soubi = ITEM_getInt( At_SoubiIndex, ITEM_CRITICAL ); + } + + if( At_Dex >= Df_Dex ){ + Big = At_Dex; + Small = Df_Dex; + wari = 1.0; + }else{ + Big = Df_Dex; + Small = At_Dex; + if( Big <= 0 ){ + wari = 0.0; + }else{ + wari = Small / Big; + } + } + + Work = ( Big - Small ) / 0.13; + if( Work <= 0 ) Work = 0; + + per = (float)( sqrt( (double)Work ) ) + + At_Soubi * 0.5; + + per *= wari; + + per += At_Luck ; + + if( per < 0 ) per = 0; + + if( per > 100 ) per = 100; + + return (int)per; +} +#endif + + +static int BATTLE_CounterCalc( int attackindex, int defindex ) +{ + int Df_Dex, At_Dex, Work, root = 1; + float per, Big, Small, wari, divpara = gCounterPara; + + At_Dex = CHAR_getWorkInt( attackindex, CHAR_WORKFIXDEX ); + Df_Dex = CHAR_getWorkInt( defindex, CHAR_WORKFIXDEX ); + + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY + && CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET + ){ + divpara = 10; + root = 0; + }else if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET + && CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY + ){ + Df_Dex *= 0.8; + }else if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER + && CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER + ){ + divpara = 10; + root = 0; + }else if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER + && CHAR_getInt( defindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER + ){ + Df_Dex *= 0.6; + } + + if( At_Dex >= Df_Dex ){ + Big = At_Dex; + Small = Df_Dex; + wari = 1.0; + }else{ + Big = Df_Dex; + Small = At_Dex; + if( Big <= 0 ){ + wari = 0.0; + }else{ + wari = Small / Big; + } + } + Work = ( Big - Small ) / divpara; + if( Work <= 0 ) Work = 0; + if( root == 1 ){ + per = (float)( (double)sqrt( Work ) ); + }else{ + per = (float)( Work); + } + per *= wari; + + return per; +} + + +#if 0 +static int BATTLE_CriticalCheckPet( int attackindex, int defindex ) +{ + float per; + int iWork = 0; + + per = CHAR_getInt( attackindex, CHAR_CRITIAL ); + + if( CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM1 ) + == BATTLE_COM_S_NOGUARD + ){ + iWork = CHAR_GETWORKINT_LOW( attackindex, CHAR_WORKBATTLECOM3 ); + iWork = iWork & 0xFF; + if( iWork > 127 )iWork *= -1; + } + + per += iWork; + + if( per < 0 ) per = 0; + + if( per > 100 ) per = 100; + + return per; +} + +#endif + +static int BATTLE_CriticalCheck( int attackindex, int defindex ) +{ + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + return BATTLE_CriticalCheckPlayer( attackindex, defindex ); + }else{ + return BATTLE_CriticalCheckPlayer( attackindex, defindex ); + } +} + +static int BATTLE_CriDamageCalc( int attackindex, int defindex ) +{ + int damage = 0; + damage = BATTLE_DamageCalc( attackindex, defindex ); + + damage += CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ) + * (float)CHAR_getInt( attackindex, CHAR_LV ) + / (float)CHAR_getInt( defindex, CHAR_LV ) + * 0.5; + return damage; +} + +static int BATTLE_GuardianCheck( int attackindex, int defindex ) +{ + int GuardianIndex, Guardian, battleindex; + int DefSide = 0, i, DefNo; + //char szBuffer[256]=""; + + battleindex = CHAR_getWorkInt( attackindex, CHAR_WORKBATTLEINDEX ); + + DefNo = BATTLE_Index2No( battleindex, defindex ); + i = DefNo; + if( i >= SIDE_OFFSET ){ + i -= SIDE_OFFSET; + DefSide = 1; + } + + if( BattleArray[battleindex].Side[DefSide].Entry[i].guardian == -1 ){ + return -1; + } + + Guardian = BattleArray[battleindex].Side[DefSide].Entry[i].guardian; +// Terry add fix 使用舍已为人技能时,若攻击使用此技能的人client会当 + if(Guardian == DefNo) return -1; +// end + GuardianIndex = BATTLE_No2Index( battleindex, Guardian ); + + if( CHAR_CHECKINDEX( GuardianIndex ) == FALSE )return -1; + + if( CHAR_getFlg( GuardianIndex, CHAR_ISDIE ) == TRUE )return -1; + + if( CHAR_getWorkInt( GuardianIndex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_GUARDIAN ){ + }else{ + return -1; + } + + if( CHAR_getWorkInt( GuardianIndex, CHAR_WORKSLEEP ) > 0 + || CHAR_getWorkInt( GuardianIndex, CHAR_WORKCONFUSION ) > 0 + || CHAR_getWorkInt( GuardianIndex, CHAR_WORKPARALYSIS ) > 0 + || CHAR_getWorkInt( GuardianIndex, CHAR_WORKSTONE ) > 0 + || CHAR_getWorkInt( GuardianIndex, CHAR_WORKBARRIER ) > 0 + || GuardianIndex == attackindex +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + || CHAR_getWorkInt( GuardianIndex, CHAR_WORKDIZZY ) > 0 // 晕眩 + || CHAR_getWorkInt( GuardianIndex, CHAR_WORKDRAGNET ) > 0 // 天罗地网 + || CHAR_getWorkInt( GuardianIndex, CHAR_WORKINSTIGATE ) > 0 // 挑拨 +#endif +#ifdef _PROFESSION_ADDSKILL + || CHAR_getWorkInt( GuardianIndex, CHAR_DOOMTIME ) > 0 //世界末日集气 +#endif + ){ + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)想要守住(%s)可是没成功\。", + // CHAR_getUseName( GuardianIndex ), + // CHAR_getUseName( defindex ) + //); + //BATTLE_BroadCast( battleindex, szBuffer, + // (DefNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + return -1; + } + + if( BATTLE_IsThrowWepon( + CHAR_getItemIndex( attackindex, CHAR_ARM ) ) == TRUE + ){ + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)想要守住(%s)可是没成功\。", + // CHAR_getUseName( GuardianIndex ), + // CHAR_getUseName( defindex ) + //); + //BATTLE_BroadCast( battleindex, szBuffer, + // (DefNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + return -1; + } + + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)护住了(%s)。", + // CHAR_getUseName( GuardianIndex ), + // CHAR_getUseName( defindex ) + //); + //BATTLE_BroadCast( battleindex, szBuffer, + // (DefNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + return Guardian; +} + + +static int BATTLE_DamageWakeUp( int battleindex, int defindex ) +{ + int bid; + char szBuffer[256]=""; + CHAR_setInt( defindex, CHAR_DAMAGECOUNT, + CHAR_getInt( defindex, CHAR_DAMAGECOUNT ) +1 ); + + if( CHAR_getWorkInt( defindex, CHAR_WORKSLEEP ) > 0 ){ + CHAR_setWorkInt( defindex, CHAR_WORKSLEEP, 0 ); + bid = BATTLE_Index2No( battleindex, defindex ); + //sprintf( szBuffer, "(%s)被击中跳了起来。\n", + // CHAR_getUseName( defindex ) ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (bid >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + sprintf( szBuffer, "BM|%X|%X|", bid, 0 ); + strcat( szBadStatusString, szBuffer ); + } + return 0; +} + +static int BATTLE_AttackSeq( int attackindex, int defindex, int *pDamage, int *pGuardian, int opt ) +{ + int iRet = 0, perCri = 0; + int GuardianIndex = -1,battleindex; + + battleindex = CHAR_getWorkInt( attackindex, CHAR_WORKBATTLEINDEX ); + + // 主人打宠 + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET + && BattleArray[battleindex].norisk == 0 + && BattleArray[battleindex].type == BATTLE_TYPE_P_vs_E){ + if( CHAR_getWorkInt( defindex, CHAR_WORKPLAYERINDEX ) == attackindex ){ + CHAR_PetAddVariableAi( defindex, AI_FIX_SEKKAN ); // 修正忠诚度 + } + } + + // 闪避 + if( opt != BATTLE_COM_COMBO ){ + if( BATTLE_DuckCheck( attackindex, defindex ) == TRUE ){ + return BATTLE_RET_DODGE; + } +#ifdef _SUIT_ADDPART3 + if( CHAR_getWorkInt( defindex, CHAR_WORKDUCKPOWER) > 0 ){ + if( rand()%100 < CHAR_getWorkInt( defindex, CHAR_WORKDUCKPOWER) ) + return BATTLE_RET_DODGE; + } +#endif + } + + // 检查被攻击方有无被别人用忠犬保护 + if( *pGuardian == -1 ){ + *pGuardian = BATTLE_GuardianCheck( attackindex, defindex ); + if( *pGuardian != -1 ){ + GuardianIndex = BATTLE_No2Index( battleindex, *pGuardian ); + defindex = GuardianIndex; + } + } + + // 会心一击 + perCri = BATTLE_CriticalCheck( attackindex, defindex ); + +#ifdef _PETSKILL_DAMAGETOHP + if( opt == BATTLE_COM_S_DAMAGETOHP2 ){ //暗月狂狼 (会心一击上升30%) && CHAR_getInt( attackindex, CHAR_HP) <= CHAR_getWorkInt( attackindex, CHAR_MAXMP)*0.5 + //print("\n1会心一击:%d",perCri); + //print("\n1攻:%d", CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER)); + //print("\n1敏:%d", CHAR_getWorkInt( attackindex, CHAR_WORKQUICK)); + perCri = perCri + (perCri*0.3); //会心一击上升30% + CHAR_setWorkInt( attackindex, CHAR_WORKATTACKPOWER, CHAR_getWorkInt( attackindex,CHAR_WORKFIXSTR)+CHAR_getWorkInt( attackindex,CHAR_WORKFIXSTR)*0.2);//攻上升20% + CHAR_setWorkInt( attackindex, CHAR_WORKQUICK, CHAR_getWorkInt( attackindex, CHAR_WORKFIXDEX)+CHAR_getWorkInt( attackindex, CHAR_WORKFIXDEX) *0.2 );//敏上升20% + //print("\n2会心一击:%d",perCri); + //print("\n2攻:%d", CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER)); + //print("\n2敏:%d", CHAR_getWorkInt( attackindex, CHAR_WORKQUICK)); + } +#endif + + gCriper = perCri; + if( RAND( 1, 10000 ) < perCri ){ + // WON ADD + int gWeponType = BATTLE_GetWepon( attackindex ); + if( gWeponType != ITEM_BOW ){ + (*pDamage) = BATTLE_CriDamageCalc( attackindex, defindex ); + }else{ + (*pDamage) = BATTLE_DamageCalc( attackindex, defindex ); + } + iRet = BATTLE_RET_CRITICAL; + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + // 勇士武器专精技能升级 + PROFESSION_SKILL_WEAPON_FOCUS_LVEVEL_UP( attackindex, "PROFESSION_WEAPON_FOCUS" ); + // 勇士二刀流技能升级 + PROFESSION_SKILL_DUAL_WEAPON_LVEVEL_UP( attackindex, "PROFESSION_DUAL_WEAPON" ); + } + }else{ + (*pDamage) = BATTLE_DamageCalc( attackindex, defindex ); + iRet = BATTLE_RET_NORMAL; + } + + if( opt == BATTLE_COM_S_GBREAK){ + ;; + }else +#ifdef _SKILL_GUARDBREAK2//破除防御2 vincent add 2002/05/20 + if( opt == BATTLE_COM_S_GBREAK2){ + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_GUARD){ + (*pDamage) = (*pDamage)*1.3; + }else{ + (*pDamage) = (*pDamage)*0.7; + } + }else +#endif + +#ifdef _PETSKILL_REGRET + if( opt == BATTLE_COM_S_REGRET2 ){// 人物伤害减少 + (*pDamage) = (*pDamage)*0.8; + }else +#endif +#ifdef _SONIC_ATTACK // WON ADD 音波攻击 + if( opt == BATTLE_COM_S_SONIC2 ){// 人物伤害减半 + (*pDamage) = (*pDamage)*0.5; + }else +#endif + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_GUARD + && CHAR_getWorkInt( defindex, CHAR_WORKCONFUSION ) <= 0 ){ + (*pDamage) = BATTLE_GuardAdjust( (*pDamage) ); + } + if( (*pDamage) < 1 ) (*pDamage) = RAND( 0, 1 ); + +#ifdef _PREVENT_TEAMATTACK // 防止同队互打 + if (CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER || + CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ) { + int myside = CHAR_getWorkInt( defindex, CHAR_WORKBATTLESIDE);//attackindex + if( myside == CHAR_getWorkInt( attackindex, CHAR_WORKBATTLESIDE)){ + if( CHAR_getWorkInt( attackindex, CHAR_WORKCONFUSION) > 0 +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + || CHAR_getWorkInt( attackindex, CHAR_WORKINSTIGATE) > 0 // 挑拨 +#endif +#ifdef _PROFESSION_ADDSKILL + || CHAR_getWorkInt( attackindex, CHAR_WORKANNEX) > 0 //附身 +#endif + ){ //攻击方异常混乱 +#ifdef _PETSKILL_TEMPTATION + }else if( CHAR_getWorkInt( attackindex, CHAR_WORKTEMPTATION ) > 0 ){//水漾诱惑 +#endif + }else if( CHAR_getInt( attackindex, CHAR_WHICHTYPE) == CHAR_TYPEPET && + CHAR_getWorkInt( attackindex, CHAR_WORKBATTLEFLG) & CHAR_BATTLEFLG_AIBAD ){ //nono宠 + }else if( CHAR_getInt( defindex, CHAR_WHICHTYPE) == CHAR_TYPEPET && + CHAR_getWorkInt( defindex, CHAR_WORKPLAYERINDEX) == attackindex ){ // 自已宠物 + }else { + int myhp, mymaxhp; + mymaxhp = CHAR_getWorkInt( defindex, CHAR_WORKMAXHP); + myhp = CHAR_getInt( defindex, CHAR_HP ) - *pDamage; + mymaxhp = mymaxhp *0.40; + if( mymaxhp >= myhp || mymaxhp < 40 ){ + *pDamage = 0; + }else { + *pDamage = 1; + } + } + } + } +#endif + +#ifdef _EQUIT_ARRANGE + if( BATTLE_ArrangeCheck( attackindex, defindex) == TRUE ){ + *pDamage *= 0.1; + iRet = BATTLE_RET_ARRANGE; + + // 勇士格挡技能增加 + if( (CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER) ) + PROFESSION_SKILL_LVEVEL_UP( defindex, "PROFESSION_DEFLECT" ); + } +#endif + + if( (*pDamage) == 0 ){ + iRet = BATTLE_RET_MISS; + if( GuardianIndex != -1 ){ + iRet = BATTLE_RET_NORMAL; + *pDamage = 1; + }else if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_GUARD + && CHAR_getWorkInt( defindex, CHAR_WORKCONFUSION ) <= 0 ){ + iRet = BATTLE_RET_ALLGUARD; + } + } + + (*pDamage) *= gBattleDamageModyfy; + return iRet; +} + +#ifdef _PETSKILL_SETDUCK +BOOL BATTLE_CheckMySkillDuck( int charaindex ) +{ + int SDuck=0,rad=0; + if( !CHAR_CHECKINDEX( charaindex) ) + return FALSE; + if( (SDuck=CHAR_getWorkInt( charaindex, CHAR_MYSKILLDUCK)) > 0 ){ + int duck1 = CHAR_getWorkInt( charaindex, CHAR_MYSKILLDUCKPOWER); + if( (rad = (rand()%100)) > duck1 ){ + return FALSE; + }else {//回避 + return TRUE; + } + } + return FALSE; +} +#endif + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 +int BATTLE_check_profession_duck( int charaindex, int per ) +{ + + int SDuck=0; + + if( (SDuck=CHAR_getWorkInt( charaindex, CHAR_WORK_P_DUCK)) > 0 ){ + int duck1 = CHAR_getWorkInt( charaindex, CHAR_WORKMOD_P_DUCK); + per = per * ( 100 + duck1 ) / 100; + } + + return per; +} +#endif + + +int BATTLE_GetDamageReact( int charaindex ) +{ + if( CHAR_getWorkInt( charaindex, CHAR_WORKDAMAGEVANISH ) > 0 ){ + return BATTLE_MD_VANISH; + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKDAMAGEABSROB ) > 0 ){ + return BATTLE_MD_ABSROB; + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKDAMAGEREFLEC ) > 0 ){ + return BATTLE_MD_REFLEC; + } + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + if( CHAR_getWorkInt( charaindex, CHAR_WORKTRAP ) > 0 ){ //陷阱 + return BATTLE_MD_TRAP; + } +#endif +#ifdef _PETSKILL_ACUPUNCTURE + if( CHAR_getWorkInt( charaindex, CHAR_WORKACUPUNCTURE ) > 0 ){ //针刺外皮 + //print("\n针刺:BATTLE_GetDamageReact"); + return BATTLE_MD_ACUPUNCTURE; + } +#endif + return 0; +} + +int BATTLE_DamageSub( int attackindex, int defindex, int *pDamage, int *pPetDamage, int *pRefrect ) +{ + + int hp = 0, addpoint = 0, maxhp, IsUltimate = 0, react, work, battleindex; + int damage, playerdamage, petdamage; + int attackpet, defpet; + int pethp = 0, petmaxhp = 0; + int defquick = 0, petquick = 0; + + damage = *pDamage; + petdamage = *pPetDamage; + playerdamage = damage; + if( damage <= 0 )return 0; + +#ifdef _PETSKILL_SHOWMERCY + if( CHAR_getInt( defindex, CHAR_HP ) - damage <= 0 + && CHAR_getWorkInt(attackindex, CHAR_WORKBATTLECOM1) == BATTLE_COM_S_SHOWMERCY ){ + damage = CHAR_getInt( defindex, CHAR_HP ) - 1; + *pDamage = damage; + playerdamage = damage; + } +#endif + + attackpet = BATTLE_getRidePet( attackindex ); + defpet = BATTLE_getRidePet( defindex ); + if( defpet != -1 ) { + defquick = CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ); + petquick = CHAR_getWorkInt( defpet, CHAR_WORKDEFENCEPOWER ); + } + + if( *pRefrect != -1 ){ + react = BATTLE_GetDamageReact( defindex ); + }else{ + react = BATTLE_MD_NONE; + } + battleindex = CHAR_getWorkInt( defindex, CHAR_WORKBATTLEINDEX ); + + if( react == BATTLE_MD_REFLEC ){ + if( BATTLE_IsThrowWepon( CHAR_getItemIndex( attackindex, CHAR_ARM ) ) == FALSE ){ + *pRefrect = BATTLE_MD_REFLEC; + }else{ + *pRefrect = BATTLE_MD_NONE; + } + }else{ + } + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + if( react == BATTLE_MD_TRAP ){ + if( BATTLE_IsThrowWepon( CHAR_getItemIndex( attackindex, CHAR_ARM ) ) == FALSE ) + *pRefrect = BATTLE_MD_TRAP; + else + *pRefrect = BATTLE_MD_NONE; + } +#endif + +#ifdef _PETSKILL_ACUPUNCTURE + if( react == BATTLE_MD_ACUPUNCTURE ){ + if( BATTLE_IsThrowWepon( CHAR_getItemIndex( attackindex, CHAR_ARM ) ) == FALSE ){ + *pRefrect = BATTLE_MD_ACUPUNCTURE; + }else{ + *pRefrect = BATTLE_MD_NONE; + } + } +#endif + + if( react == BATTLE_MD_ABSROB ){ + hp = CHAR_getInt( defindex, CHAR_HP ); + if( defpet == -1 ) { + hp += damage; + }else { + pethp = CHAR_getInt( defpet, CHAR_HP ); + playerdamage = (damage*petquick)/(defquick+petquick) +1 ; + petdamage = damage - playerdamage +1 ; + hp += playerdamage; + pethp += petdamage; + + } + work = CHAR_getWorkInt( defindex, CHAR_WORKDAMAGEABSROB ) - 1; + CHAR_setWorkInt( defindex, CHAR_WORKDAMAGEABSROB, max( work, 0 ) ); + *pRefrect = BATTLE_MD_ABSROB; + }else + if( *pRefrect == BATTLE_MD_REFLEC ){ +#ifdef _PETSKILL_BATTLE_MODEL + if(CHAR_getWorkInt(defindex,CHAR_NPCWORKINT1) == BATTLE_COM_S_BATTLE_MODEL){ + work = CHAR_getWorkInt( defindex, CHAR_WORKDAMAGEREFLEC ) - 1; + CHAR_setWorkInt( defindex, CHAR_WORKDAMAGEREFLEC, max( work, 0 ) ); + hp = CHAR_getInt(defindex,CHAR_HP); + pethp = CHAR_getInt(defpet,CHAR_HP); + } + else +#endif + { + hp = CHAR_getInt( attackindex, CHAR_HP ); + if( attackpet == -1 ) { + hp -= damage; + }else { + pethp = CHAR_getInt( attackpet, CHAR_HP ); + defquick = CHAR_getWorkInt( attackindex, CHAR_WORKDEFENCEPOWER ); + petquick = CHAR_getWorkInt( attackpet, CHAR_WORKDEFENCEPOWER ); + if( pethp > 0 ) { + playerdamage = (damage*petquick)/(defquick+petquick) +1; + petdamage = damage - playerdamage +1 ; + hp -= playerdamage; + pethp -= petdamage; + }else + hp -= damage; + } + work = CHAR_getWorkInt( defindex, CHAR_WORKDAMAGEREFLEC ) - 1; + CHAR_setWorkInt( defindex, CHAR_WORKDAMAGEREFLEC, max( work, 0 ) ); + defindex = attackindex; + defpet = attackpet; + } + }else +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + if( *pRefrect == BATTLE_MD_TRAP ){ //陷阱 +#ifdef _PETSKILL_BATTLE_MODEL + if(CHAR_getWorkInt(defindex,CHAR_NPCWORKINT1) == BATTLE_COM_S_BATTLE_MODEL){ + CHAR_setWorkInt( defindex, CHAR_WORKTRAP, 0 ); + CHAR_setWorkInt( defindex, CHAR_WORKMODTRAP, 0 ); + hp = CHAR_getInt(defindex,CHAR_HP); + pethp = CHAR_getInt(defpet,CHAR_HP); + } + else +#endif + { + int value=0; + value = CHAR_getWorkInt( defindex, CHAR_WORKMODTRAP ); + damage = value; + + playerdamage = damage; + + hp = CHAR_getInt( attackindex, CHAR_HP ); + if( attackpet == -1 ) { + hp -= damage; + }else { + pethp = CHAR_getInt( attackpet, CHAR_HP ); + defquick = CHAR_getWorkInt( attackindex, CHAR_WORKDEFENCEPOWER ); + petquick = CHAR_getWorkInt( attackpet, CHAR_WORKDEFENCEPOWER ); + if( pethp > 0 ) { + playerdamage = (damage*petquick)/(defquick+petquick) +1; + petdamage = damage - playerdamage +1 ; + hp -= playerdamage; + pethp -= petdamage; + }else + hp -= damage; + } + + CHAR_setWorkInt( defindex, CHAR_WORKTRAP, 0 ); + CHAR_setWorkInt( defindex, CHAR_WORKMODTRAP, 0 ); + + defindex = attackindex; + defpet = attackpet; + } + }else +#endif +#ifdef _PETSKILL_ACUPUNCTURE + if( *pRefrect == BATTLE_MD_ACUPUNCTURE ){ //针刺外皮 + + if( damage%2 != 0 ) + damage+=1; + playerdamage = damage; + + //先扣被攻击方的血,因为之後的动作都是对攻击方做的 + hp = CHAR_getInt( defindex, CHAR_HP ); + if( attackpet == -1 ) { + hp -= damage; + if(hp<0)hp=0; + maxhp = CHAR_getWorkInt( defindex, CHAR_WORKMAXHP ); + CHAR_setInt( defindex, CHAR_HP, min( hp, maxhp ) ); + }else { + pethp = CHAR_getInt( defpet, CHAR_HP ); + defquick = CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ); + petquick = CHAR_getWorkInt( defpet, CHAR_WORKDEFENCEPOWER ); + if( pethp > 0 ) { + playerdamage = (damage*petquick)/(defquick+petquick) +1; + petdamage = damage - playerdamage +1 ; + if(playerdamage%2 != 0) playerdamage+=1; + if(petdamage%2 != 0) petdamage+=1; + hp -= playerdamage; + pethp -= petdamage; + if(hp<0)hp=0; + maxhp = CHAR_getWorkInt( defindex, CHAR_WORKMAXHP ); + CHAR_setInt( defindex, CHAR_HP, min( hp, maxhp ) ); + if( pethp < 0 ) pethp = 0; + petmaxhp = CHAR_getWorkInt( defpet, CHAR_WORKMAXHP ); + CHAR_setInt( defpet, CHAR_HP, min( pethp, petmaxhp ) ); + }else{ + hp -= damage; + if(hp<0)hp=0; + maxhp = CHAR_getWorkInt( defindex, CHAR_WORKMAXHP ); + CHAR_setInt( defindex, CHAR_HP, min( hp, maxhp ) ); + } + } + + //Change 2003/08/22 + if( (damage) >= CHAR_getWorkInt( defindex, CHAR_WORKMAXHP ) * 1.2 + 20 ){ + int DefSide=0,i; + int defNo = BATTLE_Index2No( battleindex, defindex ); + CHAR_setWorkInt( defindex, CHAR_WORKULTIMATE, 0 ); + + //死亡的宠物改为休息 + if( defNo >= SIDE_OFFSET ){ + i = defNo - SIDE_OFFSET; + DefSide = 1; + }else{ + i = defNo; + } + i = defNo-DefSide*SIDE_OFFSET; + BattleArray[battleindex].Side[DefSide].Entry[i].flg |= BENT_FLG_ULTIMATE; + } + + //针刺外皮技能回合数设为0 + CHAR_setWorkInt( defindex, CHAR_WORKACUPUNCTURE, 0); + //if( CHAR_getWorkInt( defindex, CHAR_WORKSLEEP ) > 0 )//检查有无昏睡 + // CHAR_setWorkInt( defindex, CHAR_WORKSLEEP, 0); + +#ifdef _PETSKILL_BATTLE_MODEL + if(CHAR_getWorkInt(defindex,CHAR_NPCWORKINT1) != BATTLE_COM_S_BATTLE_MODEL) +#endif + { + //扣攻击方的血 + hp = CHAR_getInt( attackindex, CHAR_HP ); + if( attackpet == -1 ) { + hp -= damage/2; + }else { + pethp = CHAR_getInt( attackpet, CHAR_HP ); + defquick = CHAR_getWorkInt( attackindex, CHAR_WORKDEFENCEPOWER ); + petquick = CHAR_getWorkInt( attackpet, CHAR_WORKDEFENCEPOWER ); + if( pethp > 0 ) { + playerdamage = (damage*petquick)/(defquick+petquick) +1; + petdamage = damage - playerdamage +1 ; + if(playerdamage%2 != 0) playerdamage+=1; + if(petdamage%2 != 0) petdamage+=1; + hp -= playerdamage/2; + pethp -= petdamage/2; + }else + hp -= damage/2; + } + playerdamage /= 2; + + defindex = attackindex; + defpet = attackpet; + } + }else +#endif + if( react == BATTLE_MD_VANISH ){ + hp = CHAR_getInt( defindex, CHAR_HP ); + if( defpet != -1 ) + pethp = CHAR_getInt( defpet, CHAR_HP ); + work = CHAR_getWorkInt( defindex, CHAR_WORKDAMAGEVANISH ) - 1; + CHAR_setWorkInt( defindex, CHAR_WORKDAMAGEVANISH, max( work, 0 ) ); + *pRefrect = BATTLE_MD_VANISH; + //andy_log + print("*pRefrect = BATTLE_MD_VANISH !!\n"); + }else{ + hp = CHAR_getInt( defindex, CHAR_HP ); + if( defpet == -1 ) { + hp -= damage; + }else { + pethp = CHAR_getInt( defpet, CHAR_HP ); + if( pethp > 0 ) { + //andy_edit 2002/07/31 + defquick = defquick>0?defquick:1; + petquick = petquick>0?petquick:1; + playerdamage = (damage*petquick)/(defquick+petquick)+ 1; + //playerdamage = (damage*petquick)/(defquick+petquick) +1; + petdamage = damage - playerdamage +1; + hp -= playerdamage; + pethp -= petdamage; + //print(" def_damage:%d ridepet_damage:%d ", (damage*petquick)/(defquick+petquick), damage - playerdamage); + }else + hp -= damage; + } + *pRefrect = 0; + } + + if( hp < 0 ){ + addpoint = -hp; + hp = 0; + } + + + maxhp = CHAR_getWorkInt( defindex, CHAR_WORKMAXHP ); + CHAR_setInt( defindex, CHAR_HP, min( hp, maxhp ) ); + if( defpet != -1 ) { + if( pethp < 0 ) pethp = 0; + petmaxhp = CHAR_getWorkInt( defpet, CHAR_WORKMAXHP ); + CHAR_setInt( defpet, CHAR_HP, min( pethp, petmaxhp ) ); + // Robin 0804 + if( pethp <= 0 ) { + CHAR_setInt( defindex, CHAR_RIDEPET, -1 ); + BATTLE_changeRideImage( defindex ); + CHAR_setWorkInt( defindex, CHAR_WORKPETFALL, 1 ); + print(" defpet_die! "); + } + } + + if( (damage) >= maxhp * 1.2 + 20 ){ + IsUltimate = 2; + }else{ + if( addpoint > 0 ){ + addpoint += CHAR_getWorkInt( defindex, CHAR_WORKULTIMATE ); + CHAR_setWorkInt( defindex, CHAR_WORKULTIMATE, addpoint ); + if( addpoint >= maxhp * 1.2 + 20 )IsUltimate = 1; + } + } + + if( BattleArray[battleindex].type == BATTLE_TYPE_P_vs_P ){ + } +#ifdef _PETSKILL_LER +// 雷尔不能被打飞 + if(CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101813 || + CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101814) IsUltimate = 0; +#endif + + if( IsUltimate ){ + CHAR_setWorkInt( defindex, CHAR_WORKULTIMATE, 0 ); + } + if( playerdamage < 0 ) playerdamage = 0; + if( petdamage < 0 ) petdamage = 0; + *pDamage = playerdamage; + *pPetDamage = petdamage; + + return IsUltimate; +} + +#ifdef _PETSKILL_FIREKILL //火线猎杀专用 +int BATTLE_DamageSub_FIREKILL( int attackindex, int defindex, int *pDamage, int *pPetDamage, int *pRefrect ) +{ + + int hp, addpoint = 0, maxhp, IsUltimate = 0, react, work, battleindex; + int damage, playerdamage, petdamage; + int attackpet, defpet; + int pethp = 0, petmaxhp = 0; + int defquick = 0, petquick = 0; + damage = *pDamage; + petdamage = *pPetDamage; + playerdamage = damage; + if( damage <= 0 )return 0; + + attackpet = BATTLE_getRidePet( attackindex ); + defpet = BATTLE_getRidePet( defindex ); + if( defpet != -1 ) { + defquick = CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ); + petquick = CHAR_getWorkInt( defpet, CHAR_WORKDEFENCEPOWER ); + } + + if( *pRefrect != -1 ){ + react = BATTLE_GetDamageReact( defindex ); + }else{ + react = BATTLE_MD_NONE; + } + + react = BATTLE_MD_NONE; + + battleindex = CHAR_getWorkInt( defindex, CHAR_WORKBATTLEINDEX ); + + if( react == BATTLE_MD_REFLEC ){ + if( BATTLE_IsThrowWepon( CHAR_getItemIndex( attackindex, CHAR_ARM ) ) == FALSE ){ + *pRefrect = BATTLE_MD_REFLEC; + }else{ + *pRefrect = BATTLE_MD_NONE; + } + }else{ + } + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + if( react == BATTLE_MD_TRAP ){ + if( BATTLE_IsThrowWepon( CHAR_getItemIndex( attackindex, CHAR_ARM ) ) == FALSE ) + *pRefrect = BATTLE_MD_TRAP; + else + *pRefrect = BATTLE_MD_NONE; + } +#endif + +#ifdef _PETSKILL_ACUPUNCTURE + if( react == BATTLE_MD_ACUPUNCTURE ){ + if( BATTLE_IsThrowWepon( CHAR_getItemIndex( attackindex, CHAR_ARM ) ) == FALSE ){ + *pRefrect = BATTLE_MD_ACUPUNCTURE; + }else{ + *pRefrect = BATTLE_MD_NONE; + } + } +#endif + + if( react == BATTLE_MD_ABSROB ){ + hp = CHAR_getInt( defindex, CHAR_HP ); + if( defpet == -1 ) { + hp += damage; + }else { + pethp = CHAR_getInt( defpet, CHAR_HP ); + playerdamage = (damage*petquick)/(defquick+petquick) +1 ; + petdamage = damage - playerdamage +1 ; + hp += playerdamage; + pethp += petdamage; + + } + work = CHAR_getWorkInt( defindex, CHAR_WORKDAMAGEABSROB ) - 1; + CHAR_setWorkInt( defindex, CHAR_WORKDAMAGEABSROB, max( work, 0 ) ); + *pRefrect = BATTLE_MD_ABSROB; + }else + if( *pRefrect == BATTLE_MD_REFLEC ){ + hp = CHAR_getInt( attackindex, CHAR_HP ); + if( attackpet == -1 ) { + hp -= damage; + }else { + pethp = CHAR_getInt( attackpet, CHAR_HP ); + defquick = CHAR_getWorkInt( attackindex, CHAR_WORKDEFENCEPOWER ); + petquick = CHAR_getWorkInt( attackpet, CHAR_WORKDEFENCEPOWER ); + if( pethp > 0 ) { + playerdamage = (damage*petquick)/(defquick+petquick) +1; + petdamage = damage - playerdamage +1 ; + hp -= playerdamage; + pethp -= petdamage; + }else + hp -= damage; + } + work = CHAR_getWorkInt( defindex, CHAR_WORKDAMAGEREFLEC ) - 1; + CHAR_setWorkInt( defindex, CHAR_WORKDAMAGEREFLEC, max( work, 0 ) ); + defindex = attackindex; + defpet = attackpet; + + }else +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + if( *pRefrect == BATTLE_MD_TRAP ){ //陷阱 + int value=0; + value = CHAR_getWorkInt( defindex, CHAR_WORKMODTRAP ); + damage = value; + + playerdamage = damage; + + hp = CHAR_getInt( attackindex, CHAR_HP ); + if( attackpet == -1 ) { + hp -= damage; + }else { + pethp = CHAR_getInt( attackpet, CHAR_HP ); + defquick = CHAR_getWorkInt( attackindex, CHAR_WORKDEFENCEPOWER ); + petquick = CHAR_getWorkInt( attackpet, CHAR_WORKDEFENCEPOWER ); + if( pethp > 0 ) { + playerdamage = (damage*petquick)/(defquick+petquick) +1; + petdamage = damage - playerdamage +1 ; + hp -= playerdamage; + pethp -= petdamage; + }else + hp -= damage; + } + + CHAR_setWorkInt( defindex, CHAR_WORKTRAP, 0 ); + CHAR_setWorkInt( defindex, CHAR_WORKMODTRAP, 0 ); + + defindex = attackindex; + defpet = attackpet; + + }else +#endif +#ifdef _PETSKILL_ACUPUNCTURE + if( *pRefrect == BATTLE_MD_ACUPUNCTURE ){ //针刺外皮 + + if( damage%2 != 0 ) + damage+=1; + playerdamage = damage; + + //先扣被攻击方的血,因为之後的动作都是对攻击方做的 + hp = CHAR_getInt( defindex, CHAR_HP ); + if( attackpet == -1 ) { + hp -= damage; + if(hp<0)hp=0; + maxhp = CHAR_getWorkInt( defindex, CHAR_WORKMAXHP ); + CHAR_setInt( defindex, CHAR_HP, min( hp, maxhp ) ); + }else { + pethp = CHAR_getInt( defpet, CHAR_HP ); + defquick = CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ); + petquick = CHAR_getWorkInt( defpet, CHAR_WORKDEFENCEPOWER ); + if( pethp > 0 ) { + playerdamage = (damage*petquick)/(defquick+petquick) +1; + petdamage = damage - playerdamage +1 ; + if(playerdamage%2 != 0) playerdamage+=1; + if(petdamage%2 != 0) petdamage+=1; + hp -= playerdamage; + pethp -= petdamage; + if(hp<0)hp=0; + maxhp = CHAR_getWorkInt( defindex, CHAR_WORKMAXHP ); + CHAR_setInt( defindex, CHAR_HP, min( hp, maxhp ) ); + if( pethp < 0 ) pethp = 0; + petmaxhp = CHAR_getWorkInt( defpet, CHAR_WORKMAXHP ); + CHAR_setInt( defpet, CHAR_HP, min( pethp, petmaxhp ) ); + }else{ + hp -= damage; + if(hp<0)hp=0; + maxhp = CHAR_getWorkInt( defindex, CHAR_WORKMAXHP ); + CHAR_setInt( defindex, CHAR_HP, min( hp, maxhp ) ); + } + } + + //Change 2003/08/22 + if( (damage) >= CHAR_getWorkInt( defindex, CHAR_WORKMAXHP ) * 1.2 + 20 ){ + int DefSide=0,i; + int defNo = BATTLE_Index2No( battleindex, defindex ); + CHAR_setWorkInt( defindex, CHAR_WORKULTIMATE, 0 ); + + //死亡的宠物改为休息 + if( defNo >= SIDE_OFFSET ){ + i = defNo - SIDE_OFFSET; + DefSide = 1; + }else{ + i = defNo; + } + i = defNo-DefSide*SIDE_OFFSET; + BattleArray[battleindex].Side[DefSide].Entry[i].flg |= BENT_FLG_ULTIMATE; + } + + //针刺外皮技能回合数设为0 + CHAR_setWorkInt( defindex, CHAR_WORKACUPUNCTURE, 0); + //if( CHAR_getWorkInt( defindex, CHAR_WORKSLEEP ) > 0 )//检查有无昏睡 + // CHAR_setWorkInt( defindex, CHAR_WORKSLEEP, 0); + + //扣攻击方的血 + hp = CHAR_getInt( attackindex, CHAR_HP ); + if( attackpet == -1 ) { + hp -= damage/2; + }else { + pethp = CHAR_getInt( attackpet, CHAR_HP ); + defquick = CHAR_getWorkInt( attackindex, CHAR_WORKDEFENCEPOWER ); + petquick = CHAR_getWorkInt( attackpet, CHAR_WORKDEFENCEPOWER ); + if( pethp > 0 ) { + playerdamage = (damage*petquick)/(defquick+petquick) +1; + petdamage = damage - playerdamage +1 ; + if(playerdamage%2 != 0) playerdamage+=1; + if(petdamage%2 != 0) petdamage+=1; + hp -= playerdamage/2; + pethp -= petdamage/2; + }else + hp -= damage/2; + } + + playerdamage /= 2; + + defindex = attackindex; + defpet = attackpet; + + }else +#endif + if( react == BATTLE_MD_VANISH ){ + hp = CHAR_getInt( defindex, CHAR_HP ); + if( defpet != -1 ) + pethp = CHAR_getInt( defpet, CHAR_HP ); + work = CHAR_getWorkInt( defindex, CHAR_WORKDAMAGEVANISH ) - 1; + CHAR_setWorkInt( defindex, CHAR_WORKDAMAGEVANISH, max( work, 0 ) ); + *pRefrect = BATTLE_MD_VANISH; + //andy_log + print("*pRefrect = BATTLE_MD_VANISH !!\n"); + }else{ + hp = CHAR_getInt( defindex, CHAR_HP ); + if( defpet == -1 ) { + hp -= damage; + }else { + pethp = CHAR_getInt( defpet, CHAR_HP ); + if( pethp > 0 ) { + //andy_edit 2002/07/31 + defquick = defquick>0?defquick:1; + petquick = petquick>0?petquick:1; + playerdamage = (damage*petquick)/(defquick+petquick)+ 1; + //playerdamage = (damage*petquick)/(defquick+petquick) +1; + petdamage = damage - playerdamage +1; + hp -= playerdamage; + pethp -= petdamage; + //print(" def_damage:%d ridepet_damage:%d ", (damage*petquick)/(defquick+petquick), damage - playerdamage); + }else + hp -= damage; + } + *pRefrect = 0; + } + if( hp < 0 ){ + addpoint = -hp; + hp = 0; + } + + maxhp = CHAR_getWorkInt( defindex, CHAR_WORKMAXHP ); + CHAR_setInt( defindex, CHAR_HP, min( hp, maxhp ) ); + if( defpet != -1 ) { + if( pethp < 0 ) pethp = 0; + petmaxhp = CHAR_getWorkInt( defpet, CHAR_WORKMAXHP ); + CHAR_setInt( defpet, CHAR_HP, min( pethp, petmaxhp ) ); + // Robin 0804 + if( pethp <= 0 ) { + CHAR_setInt( defindex, CHAR_RIDEPET, -1 ); + BATTLE_changeRideImage( defindex ); + CHAR_setWorkInt( defindex, CHAR_WORKPETFALL, 1 ); + print(" defpet_die! "); + } + } + + if( (damage) >= maxhp * 1.2 + 20 ){ + IsUltimate = 2; + }else{ + if( addpoint > 0 ){ + addpoint += CHAR_getWorkInt( defindex, CHAR_WORKULTIMATE ); + CHAR_setWorkInt( defindex, CHAR_WORKULTIMATE, addpoint ); + if( addpoint >= maxhp * 1.2 + 20 )IsUltimate = 1; + } + } + + if( BattleArray[battleindex].type == BATTLE_TYPE_P_vs_P ){ + } + +#ifdef _PETSKILL_LER +// 雷尔不能被打飞 + if(CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101813 || + CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101814) IsUltimate = 0; +#endif + + if( IsUltimate ){ + CHAR_setWorkInt( defindex, CHAR_WORKULTIMATE, 0 ); + } + if( playerdamage < 0 ) playerdamage = 0; + if( petdamage < 0 ) petdamage = 0; + *pDamage = playerdamage; + *pPetDamage = petdamage; + + return IsUltimate; +} +#endif + + +// Robin 0910 RidePetDebug +int BATTLE_DamageSub2( int attackindex, int defindex, int *pDamage, int *pPetDamage, int *pRefrect ) +{ + + int hp, addpoint = 0, maxhp, IsUltimate = 0, react, work, battleindex; + int damage, playerdamage, petdamage; + int attackpet, defpet; + int pethp = 0, petmaxhp = 0; + + damage = *pDamage; + petdamage = *pPetDamage; + playerdamage = *pDamage; + + if( damage <= 0 )return 0; + + attackpet = BATTLE_getRidePet( attackindex ); + defpet = BATTLE_getRidePet( defindex ); + + if( *pRefrect != -1 ){ + react = BATTLE_GetDamageReact( defindex ); + }else{ + react = BATTLE_MD_NONE; + } + + if( react == BATTLE_MD_REFLEC ){ + if( BATTLE_IsThrowWepon( CHAR_getItemIndex( attackindex, CHAR_ARM ) ) == FALSE ){ + *pRefrect = BATTLE_MD_REFLEC; + }else{ + *pRefrect = BATTLE_MD_NONE; + } + } + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + if( react == BATTLE_MD_TRAP ){ + if( BATTLE_IsThrowWepon( CHAR_getItemIndex( attackindex, CHAR_ARM ) ) == FALSE ) + *pRefrect = BATTLE_MD_TRAP; + else + *pRefrect = BATTLE_MD_NONE; + } +#endif + + if( react == BATTLE_MD_ABSROB ){ + + hp = CHAR_getInt( defindex, CHAR_HP ); + hp += playerdamage; + if( defpet != -1 ) { + pethp = CHAR_getInt( defpet, CHAR_HP ); + pethp += petdamage; + } + + work = CHAR_getWorkInt( defindex, CHAR_WORKDAMAGEABSROB ) - 1; + CHAR_setWorkInt( defindex, CHAR_WORKDAMAGEABSROB, max( work, 0 ) ); + + *pRefrect = BATTLE_MD_ABSROB; + + }else + if( *pRefrect == BATTLE_MD_REFLEC ){ + + hp = CHAR_getInt( attackindex, CHAR_HP ); + hp -= playerdamage; + if( attackpet != -1 ) { + pethp = CHAR_getInt( attackpet, CHAR_HP ); + if( pethp > 0 ) { + pethp -= petdamage; + } + } + + work = CHAR_getWorkInt( defindex, CHAR_WORKDAMAGEREFLEC ) - 1; + CHAR_setWorkInt( defindex, CHAR_WORKDAMAGEREFLEC, max( work, 0 ) ); + + defindex = attackindex; + defpet = attackpet; + + }else +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + if( *pRefrect == BATTLE_MD_TRAP ){ //陷阱 + + hp = CHAR_getInt( attackindex, CHAR_HP ); + hp -= playerdamage; + if( attackpet != -1 ) { + pethp = CHAR_getInt( attackpet, CHAR_HP ); + if( pethp > 0 ) { + pethp -= petdamage; + } + } + + CHAR_setWorkInt( defindex, CHAR_WORKTRAP, 0 ); + CHAR_setWorkInt( defindex, CHAR_WORKMODTRAP, 0 ); + + defindex = attackindex; + defpet = attackpet; + + }else +#endif + if( react == BATTLE_MD_VANISH ){ + hp = CHAR_getInt( defindex, CHAR_HP ); + if( defpet != -1 ) + pethp = CHAR_getInt( defpet, CHAR_HP ); + + work = CHAR_getWorkInt( defindex, CHAR_WORKDAMAGEVANISH ) - 1; + CHAR_setWorkInt( defindex, CHAR_WORKDAMAGEVANISH, max( work, 0 ) ); + + *pRefrect = BATTLE_MD_VANISH; + + }else{ + hp = CHAR_getInt( defindex, CHAR_HP ); + hp -= playerdamage; + if( defpet != -1 ){ + pethp = CHAR_getInt( defpet, CHAR_HP ); + if( pethp > 0 ) { + pethp -= petdamage; + //print(" def_damage:%d ridepet_damage:%d ", (damage*petquick)/(defquick+petquick), damage - playerdamage); + } + } + *pRefrect = 0; + } + + if( hp < 0 ){ + addpoint = -hp; + hp = 0; + } + + maxhp = CHAR_getWorkInt( defindex, CHAR_WORKMAXHP ); + + CHAR_setInt( defindex, CHAR_HP, min( hp, maxhp ) ); + + + if( defpet != -1 ) { + if( pethp < 0 ) pethp = 0; + petmaxhp = CHAR_getWorkInt( defpet, CHAR_WORKMAXHP ); + CHAR_setInt( defpet, CHAR_HP, min( pethp, petmaxhp ) ); + + // Robin 0804 + if( pethp <= 0 ) { + CHAR_setInt( defindex, CHAR_RIDEPET, -1 ); + BATTLE_changeRideImage( defindex ); + CHAR_setWorkInt( defindex, CHAR_WORKPETFALL, 1 ); + print(" defpet_die! "); + } + } + + if( (damage) >= maxhp * 1.2 + 20 ){ + IsUltimate = 2; + }else{ + if( addpoint > 0 ){ + addpoint += CHAR_getWorkInt( defindex, CHAR_WORKULTIMATE ); + CHAR_setWorkInt( defindex, CHAR_WORKULTIMATE, addpoint ); + if( addpoint >= maxhp * 1.2 + 20 )IsUltimate = 1; + } + } + + battleindex = CHAR_getWorkInt( defindex, CHAR_WORKBATTLEINDEX ); + if( BattleArray[battleindex].type == BATTLE_TYPE_P_vs_P ){ + } +#ifdef _PETSKILL_LER +// 雷尔不能被打飞 + if(CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101813 || + CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101814) IsUltimate = 0; +#endif + + if( IsUltimate ){ + CHAR_setWorkInt( defindex, CHAR_WORKULTIMATE, 0 ); + } + + //*pDamage = damage; + *pDamage = playerdamage; + *pPetDamage = petdamage; + + return IsUltimate; +} + + + +void BATTLE_DamageSubCale( + int attackindex, + int defindex, + int *pDamage, + int *pPetDamage +) +{ + int pethp; + int damage, playerdamage, petdamage; + int attackpet, defpet; + int defquick = 0, petquick = 0; + + damage = *pDamage; + petdamage = *pPetDamage; + playerdamage = damage; + + attackpet = BATTLE_getRidePet( attackindex ); + defpet = BATTLE_getRidePet( defindex ); + + defquick = CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ); + defquick = ( defquick < 1)?1:defquick; + if( defpet != -1 ) { + petquick = CHAR_getWorkInt( defpet, CHAR_WORKDEFENCEPOWER ); + petquick = ( petquick < 1)?1:petquick; + + pethp = CHAR_getInt( defpet, CHAR_HP ); + if( pethp > 0 ) { + playerdamage = (damage*petquick)/(defquick+petquick); + petdamage = damage - playerdamage; + if( damage > 0 && playerdamage < 1 ) + playerdamage = 1; + } + } + + *pDamage = playerdamage; + *pPetDamage = petdamage; + +} + +int BATTLE_Attack( int battleindex, int attackNo, int defNo ) +{ + char szBuffer[512]=""; + char szCommand[1024]; + int damage = 0, petdamage = 0, attackindex, toindex, ultimate = 0, + defindex, react = 0, statusDefNo, opt = 0; + int flg = 0, iWork, par, perStatus, i, DefSide = 0, Guardian = -1; + BOOL iRet = TRUE; + int suitpoison=30;//基本中毒% + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + defindex = toindex = BATTLE_No2Index( battleindex, defNo ); + if( CHAR_CHECKINDEX( attackindex ) == FALSE ) return FALSE; + if( CHAR_CHECKINDEX( defindex ) == FALSE ) return FALSE; + + +#ifdef _PETSKILL_RETRACE + Battle_Attack_ReturnData_x.Battle_Attack_ReturnData = 0; +#endif + + if( gWeponType == ITEM_BOW ){ + if( toindex < 0 || CHAR_getInt( toindex, CHAR_HP ) <= 0 ){ + snprintf( szCommand, sizeof( szCommand ), "r%X|f0|d0|", defNo ); + BATTLESTR_ADD( szCommand ); + return FALSE; + } + } + + if( CHAR_getInt( toindex, CHAR_HP ) <= 0 ) return FALSE; + + if( CHAR_getInt( attackindex, CHAR_HP ) <= 0 ) return FALSE; + + // 光、镜、守 + if( BATTLE_GetDamageReact( attackindex ) > 0 ) iRet = FALSE; + else if( BATTLE_GetDamageReact( defindex ) > 0 ) iRet = FALSE; + + // 攻击模式 + iWork = BATTLE_AttackSeq( attackindex, toindex, &damage, &Guardian, opt ); + + if( Guardian >= 0 ) + defindex = BATTLE_No2Index( battleindex, Guardian ); + + if( gDamageDiv != 0.0 && damage > 0 ){ + damage /= gDamageDiv; + if( damage <= 0 ) damage = 1; + } + + par = BATTLE_AttrAdjust( attackindex, defindex, 100 ); + react = 0; + + ultimate = BATTLE_DamageSub( attackindex, defindex, &damage, &petdamage, &react ); + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + if( react == BATTLE_MD_TRAP ){ + defindex = attackindex; + statusDefNo = attackNo; + } +#endif +#ifdef _PETSKILL_ACUPUNCTURE + if( react == BATTLE_MD_ACUPUNCTURE ){ + defindex = attackindex; + statusDefNo = attackNo; + } +#endif + if( react == BATTLE_MD_REFLEC ){ + defindex = attackindex; + statusDefNo = attackNo; + }else{ + if( 0 <= Guardian && Guardian <= 19 ){ + statusDefNo = Guardian; + }else{ + statusDefNo = defNo; + } + } + +#ifdef _PETSKILL_ACUPUNCTURE + if( react == BATTLE_MD_ACUPUNCTURE ){ //针刺外皮时会无法正常解除被打方的状态,所以把index换回来 + defindex = toindex = BATTLE_No2Index( battleindex, defNo ); + statusDefNo = defNo; + } +#endif + + //昏睡时,在这里解除状态(也有其它的状态) + if( damage > 0 && ( react != BATTLE_MD_ABSROB ) && ( react != BATTLE_MD_VANISH ) ){ + BATTLE_DamageWakeUp( battleindex, defindex ); + } + +#ifdef _PETSKILL_ACUPUNCTURE + if( react == BATTLE_MD_ACUPUNCTURE ){ + defindex = attackindex; + statusDefNo = attackNo; + } +#endif + + switch( iWork ){ + case BATTLE_RET_ALLGUARD: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)朝向(%s)攻击,轻易地被躲开。", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ) + //); + flg |= BCF_NORMAL; +#ifdef _PETSKILL_RETRACE + Battle_Attack_ReturnData_x.Battle_Attack_ReturnData = BATTLE_RET_ALLGUARD; +#endif + break; + case BATTLE_RET_MISS: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)朝向(%s)攻击,没击中。", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ) + //); +#ifdef _PETSKILL_RETRACE + Battle_Attack_ReturnData_x.Battle_Attack_ReturnData = BATTLE_RET_MISS; +#endif + break; + case BATTLE_RET_DODGE: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)攻击了(%s)躲开了(%.2f%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // gDuckPer + //); + flg |= BCF_DODGE; +#ifdef _PETSKILL_RETRACE + Battle_Attack_ReturnData_x.Battle_Attack_ReturnData = BATTLE_RET_DODGE; +#endif + break; + case BATTLE_RET_NORMAL: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)受到(%s)的攻击(%d)遭受损伤(%d:%d:%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // damage, + // CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER ), + // CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ), + // par + //); + //andy_edit + flg |= BATTLE_getReactFlg( defindex, react); + flg |= BCF_NORMAL; + break; + case BATTLE_RET_CRITICAL: + //snprintf( szBuffer, sizeof(szBuffer), + //"(%s)向(%s)CRITICAL(%d%%)(%d)不可以(%d:%d:%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // (int)(gCriper*0.01), + // damage, + // CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER ), + // CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ), + // par + //); + //andy_edit + flg |= BATTLE_getReactFlg( defindex, react); + flg |= BCF_KAISHIN; + iRet = FALSE; + break; +#ifdef _EQUIT_ARRANGE + case BATTLE_RET_ARRANGE: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)攻击了(%s)挡掉了(%.2f%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // gDuckPer + //); + flg |= BCF_B_ARRANGE; +#ifdef _PETSKILL_RETRACE + Battle_Attack_ReturnData_x.Battle_Attack_ReturnData = BATTLE_RET_ARRANGE; +#endif + break; +#endif + } + + + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_GUARD + && CHAR_getWorkInt( defindex, CHAR_WORKCONFUSION ) <= 0){ + strncat( szBuffer, "(GUARD)", sizeof( szBuffer ) ); + flg |= BCF_GUARD; + iRet = FALSE; + } + + if( CHAR_getInt( defindex, CHAR_HP ) <= 0 ){ + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_ABIO ){ + ultimate = 1; + }else if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER && flg & BCF_KAISHIN ){ + if( RAND( 1, 100 ) < 50 ){ + ultimate = 1; + } + } + +#ifdef _PETSKILL_LER +// 雷尔不能被打飞 + if(CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101813 || + CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101814) ultimate = 0; +#endif + iRet = FALSE; + flg |= BCF_DEATH; + + if( ultimate == 1 ){ + flg |= BCF_ULTIMATE_1; + strcat( szBuffer, "ultimate嘆" ); + } + if( ultimate == 2 ){ + flg |= BCF_ULTIMATE_2; + strcat( szBuffer, "ultimate嘇" ); + } + } + + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + +#ifdef _PETSKILL_ACUPUNCTURE + if( react == BATTLE_MD_ACUPUNCTURE ){ //针刺外皮不会反射特殊状态,所以要改回来 + defindex = toindex = BATTLE_No2Index( battleindex, defNo ); + statusDefNo = defNo; + } + //注意:之後要不要再改回原本反射.......???? +#endif + +#ifdef _SUIT_ADDPART4 + if( gBattleStausChange == -1 && CHAR_getWorkInt( attackindex, CHAR_SUITPOISON ) > 0 )//带毒装备 + gBattleStausChange = 1,gBattleStausTurn = 3, suitpoison=CHAR_getWorkInt( attackindex, CHAR_SUITPOISON ); +#endif + + if( damage > 0 && gBattleStausChange >= 0 ){ + if( BATTLE_StatusAttackCheck( + attackindex, + defindex, + gBattleStausChange, + suitpoison, + 40, + 2.0, + &perStatus + ) == TRUE + ){ + CHAR_setWorkInt( defindex, StatusTbl[gBattleStausChange], + gBattleStausTurn + 1 ); + + if( gBattleStausChange == BATTLE_ST_DRUNK ){ + CHAR_setWorkInt( defindex, CHAR_WORKDRUNK, + CHAR_getWorkInt( defindex, CHAR_WORKDRUNK ) / 2 ); + } + +#ifdef _PET_SKILL_SARS // WON ADD 毒煞蔓延 + if( gBattleStausChange == BATTLE_ST_SARS ){ + CHAR_setWorkInt( defindex, CHAR_WORKMODSARS, 1); + } +#endif + + if( gBattleStausChange == BATTLE_ST_PARALYSIS + || gBattleStausChange == BATTLE_ST_SLEEP + || gBattleStausChange == BATTLE_ST_STONE + || gBattleStausChange == BATTLE_ST_BARRIER + ){ + CHAR_setWorkInt( defindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + + //snprintf( szBuffer, sizeof(szBuffer), + //"(%s)变成(%s)(%d%%)", + // CHAR_getUseName( defindex ), + // aszStatusFull[gBattleStausChange], + // perStatus + //); + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + BATTLE_BadStatusString( statusDefNo, gBattleStausChange ); + }else{ + //snprintf( szBuffer, sizeof(szBuffer), + //"(%s)无法成功\(%d%%)", + // aszStatusFull[gBattleStausChange], + // perStatus ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + } + } +#ifdef _SHOOTCHESTNUT // Syu ADD 宠技:丢栗子 + if ( ( damage > 0 ) && ( CHAR_getWorkInt( attackindex , CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_ATTSHOOT ) ) { + if ( RAND ( 1 , 5 ) > 4 ) { + CHAR_setWorkInt( defindex, CHAR_WORKSLEEP , 3 ); //设定昏睡 + CHAR_setWorkInt( defindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE );//因为设定了昏睡,所以设定无动作 + } + } +#endif + if( damage > 0 ){ +#ifdef _TAKE_ITEMDAMAGE + if( BATTLE_ItemCrushSeq( attackindex, defindex, damage) == TRUE ){ +#else + if( BATTLE_ItemCrushSeq( defindex ) == TRUE ){ +#endif + flg |= BCF_CRUSH; + } + } + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + if( damage > 0 && (CHAR_getInt(attackindex, CHAR_WHICHTYPE)== CHAR_TYPEPLAYER) ){ + int i; + // 检查火、冰、雷附体 + for( i=0; i<3; i++ ){ + int turn = 0, status = -1; + + turn = CHAR_getWorkInt( attackindex, CHAR_WORK_F_ENCLOSE_2+i ); + + if( turn > 0 ){ + int skill_type = CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM1 ); + int perStatus = 0, j = 0; + int skill_level = CHAR_getWorkInt( attackindex, CHAR_WORKMOD_F_ENCLOSE_2+i ); + char pszP[3][10] = { "烧","霜","电" }; + int img1 = 101697, img2 = 101698 + i; + + // 状态 + for( j = 1; j < BATTLE_ST_END; j ++ ){ + if( strncmp( pszP[i], aszStatus[j], 2 ) == 0 ){ + status = j; + break; + } + } + + // 命中率 + perStatus = 20 + skill_level * 2; + + // 回合数 + if( skill_level >= 10 ) turn = 3; + else if( skill_level >= 5 ) turn = 2; + else turn = 1; + + // 雷附体一回合数 + if( i == 2 ) turn = 1; + + // 火、冰、雷附体附加攻击 +// Terry add fix 忠犬bug + if(Guardian >= 0) iRet = BATTLE_PROFESSION_RANG_ATTACK_DAMAGE(attackindex, attackNo, Guardian, skill_type, status, turn, perStatus, 0, img1, img2 ); + else iRet = BATTLE_PROFESSION_RANG_ATTACK_DAMAGE(attackindex, attackNo, defNo, skill_type, status, turn, perStatus, 0, img1, img2 ); + + break; + } + } + } +#endif + + + if( 0 <= Guardian && Guardian <= 19 ){ + iRet = FALSE; + flg |= BCF_GUARDIAN; + snprintf( szCommand, sizeof( szCommand ), + "r%X|f%X|d%X|p%X|g%X|", + defNo, + flg, + damage, + petdamage, + Guardian ); + }else{ + snprintf( szCommand, sizeof( szCommand ), + "r%X|f%X|d%X|p%X|", + defNo, + flg, + damage, + petdamage ); + } + + BATTLESTR_ADD( szCommand ); + + defNo = BATTLE_Index2No( battleindex, defindex ); + + if( defNo >= SIDE_OFFSET ){ + i = defNo - SIDE_OFFSET; + DefSide = 1; + }else{ + i = defNo; + } + + i = defNo-DefSide*SIDE_OFFSET; + if( ultimate > 0 ){ + BattleArray[battleindex].Side[DefSide].Entry[i].flg |= BENT_FLG_ULTIMATE; + } + return iRet; + +} + +#ifdef _PETSKILL_FIREKILL +int BATTLE_Attack_FIREKILL( int battleindex, int attackNo, int defNo ) +{ + char szBuffer[512]=""; + char szCommand[1024]; + int damage = 0, petdamage = 0, attackindex, toindex, ultimate = 0, + defindex, react = 0, statusDefNo, opt = 0; + int flg = 0, iWork, par, perStatus, i, DefSide = 0, Guardian = -1; + BOOL iRet = TRUE; + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + defindex = toindex = BATTLE_No2Index( battleindex, defNo ); + if( CHAR_CHECKINDEX( attackindex ) == FALSE ) return FALSE; + if( CHAR_CHECKINDEX( defindex ) == FALSE ) return FALSE; + + +#ifdef _PETSKILL_RETRACE + Battle_Attack_ReturnData_x.Battle_Attack_ReturnData = 0; +#endif + + if( gWeponType == ITEM_BOW ){ + if( toindex < 0 || CHAR_getInt( toindex, CHAR_HP ) <= 0 ){ + snprintf( szCommand, sizeof( szCommand ), "r%X|f0|d0|", defNo ); + BATTLESTR_ADD( szCommand ); + return FALSE; + } + } + + if( CHAR_getInt( toindex, CHAR_HP ) <= 0 ) return FALSE; + + if( CHAR_getInt( attackindex, CHAR_HP ) <= 0 ) return FALSE; + + // 光、镜、守 +// if( BATTLE_GetDamageReact( attackindex ) > 0 ) iRet = FALSE; +// else if( BATTLE_GetDamageReact( defindex ) > 0 ) iRet = FALSE; + + // 攻击模式 + iWork = BATTLE_AttackSeq( attackindex, toindex, &damage, &Guardian, opt ); + + if( Guardian >= 0 ) + defindex = BATTLE_No2Index( battleindex, Guardian ); + + if( gDamageDiv != 0.0 && damage > 0 ){ + damage /= gDamageDiv; + if( damage <= 0 ) damage = 1; + } + + par = BATTLE_AttrAdjust( attackindex, defindex, 100 ); + react = 0; + + ultimate = BATTLE_DamageSub_FIREKILL( attackindex, defindex, &damage, &petdamage, &react ); + +//#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 +// if( react == BATTLE_MD_TRAP ){ +// defindex = attackindex; +// statusDefNo = attackNo; +// } +//#endif +//#ifdef _PETSKILL_ACUPUNCTURE +// if( react == BATTLE_MD_ACUPUNCTURE ){ +// defindex = attackindex; +// statusDefNo = attackNo; +// } +//#endif +// if( react == BATTLE_MD_REFLEC ){ +// defindex = attackindex; +// statusDefNo = attackNo; +// }else{ + if( 0 <= Guardian && Guardian <= 19 ){ + statusDefNo = Guardian; + }else{ + statusDefNo = defNo; + } +// } + +//#ifdef _PETSKILL_ACUPUNCTURE +// if( react == BATTLE_MD_ACUPUNCTURE ){ //针刺外皮时会无法正常解除被打方的状态,所以把index换回来 +// defindex = toindex = BATTLE_No2Index( battleindex, defNo ); +// statusDefNo = defNo; +// } +//#endif + + //昏睡时,在这里解除状态(也有其它的状态) + if( damage > 0 && ( react != BATTLE_MD_ABSROB ) && ( react != BATTLE_MD_VANISH ) ){ + BATTLE_DamageWakeUp( battleindex, defindex ); + } + +//#ifdef _PETSKILL_ACUPUNCTURE +// if( react == BATTLE_MD_ACUPUNCTURE ){ +// defindex = attackindex; +// statusDefNo = attackNo; +// } +//#endif + + switch( iWork ){ + case BATTLE_RET_ALLGUARD: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)朝向(%s)攻击,轻易地被躲开。", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ) + //); + flg |= BCF_NORMAL; + break; + case BATTLE_RET_MISS: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)朝向(%s)攻击,没击中。", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ) + //); + break; + case BATTLE_RET_DODGE: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)攻击了(%s)躲开了(%.2f%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // gDuckPer + //); + flg |= BCF_DODGE; +#ifdef _PETSKILL_RETRACE + Battle_Attack_ReturnData_x.Battle_Attack_ReturnData = BATTLE_RET_DODGE; +#endif + break; + case BATTLE_RET_NORMAL: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)受到(%s)的攻击(%d)遭受损伤(%d:%d:%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // damage, + // CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER ), + // CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ), + // par + //); + //andy_edit + flg |= BATTLE_getReactFlg( defindex, react); + flg |= BCF_NORMAL; + break; + case BATTLE_RET_CRITICAL: + //snprintf( szBuffer, sizeof(szBuffer), + //"(%s)向(%s)CRITICAL(%d%%)(%d)不可以(%d:%d:%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // (int)(gCriper*0.01), + // damage, + // CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER ), + // CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ), + // par + //); + //andy_edit + flg |= BATTLE_getReactFlg( defindex, react); + flg |= BCF_KAISHIN; + iRet = FALSE; + break; +#ifdef _EQUIT_ARRANGE + case BATTLE_RET_ARRANGE: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)攻击了(%s)挡掉了(%.2f%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // gDuckPer + //); + flg |= BCF_B_ARRANGE; + break; +#endif + } + + + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_GUARD + && CHAR_getWorkInt( defindex, CHAR_WORKCONFUSION ) <= 0){ + strncat( szBuffer, "(GUARD)", sizeof( szBuffer ) ); + flg |= BCF_GUARD; + iRet = FALSE; + } + + if( CHAR_getInt( defindex, CHAR_HP ) <= 0 ){ + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_ABIO ){ + ultimate = 1; + }else if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER && flg & BCF_KAISHIN ){ + if( RAND( 1, 100 ) < 50 ){ + ultimate = 1; + } + } +#ifdef _PETSKILL_LER +// 雷尔不能被打飞 + if(CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101813 || + CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101814) ultimate = 0; +#endif + iRet = FALSE; + flg |= BCF_DEATH; + + if( ultimate == 1 ){ + flg |= BCF_ULTIMATE_1; + strcat( szBuffer, "ultimate嘆" ); + } + if( ultimate == 2 ){ + flg |= BCF_ULTIMATE_2; + strcat( szBuffer, "ultimate嘇" ); + } + } + + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + +//#ifdef _PETSKILL_ACUPUNCTURE +// if( react == BATTLE_MD_ACUPUNCTURE ){ //针刺外皮不会反射特殊状态,所以要改回来 +// defindex = toindex = BATTLE_No2Index( battleindex, defNo ); +// statusDefNo = defNo; +// } +// //注意:之後要不要再改回原本反射.......???? +//#endif + + + if( damage > 0 && gBattleStausChange >= 0 ){ + if( BATTLE_StatusAttackCheck( + attackindex, + defindex, + gBattleStausChange, + 30, + 40, + 2.0, + &perStatus + ) == TRUE + ){ + CHAR_setWorkInt( defindex, StatusTbl[gBattleStausChange], + gBattleStausTurn + 1 ); + + if( gBattleStausChange == BATTLE_ST_DRUNK ){ + CHAR_setWorkInt( defindex, CHAR_WORKDRUNK, + CHAR_getWorkInt( defindex, CHAR_WORKDRUNK ) / 2 ); + } + +#ifdef _PET_SKILL_SARS // WON ADD 毒煞蔓延 + if( gBattleStausChange == BATTLE_ST_SARS ){ + CHAR_setWorkInt( defindex, CHAR_WORKMODSARS, 1); + } +#endif + + if( gBattleStausChange == BATTLE_ST_PARALYSIS + || gBattleStausChange == BATTLE_ST_SLEEP + || gBattleStausChange == BATTLE_ST_STONE + || gBattleStausChange == BATTLE_ST_BARRIER + ){ + CHAR_setWorkInt( defindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + + //snprintf( szBuffer, sizeof(szBuffer), + //"(%s)变成(%s)(%d%%)", + // CHAR_getUseName( defindex ), + // aszStatusFull[gBattleStausChange], + // perStatus + //); + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + BATTLE_BadStatusString( statusDefNo, gBattleStausChange ); + }else{ + //snprintf( szBuffer, sizeof(szBuffer), + //"(%s)无法成功\(%d%%)", + // aszStatusFull[gBattleStausChange], + // perStatus ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + } + } +#ifdef _SHOOTCHESTNUT // Syu ADD 宠技:丢栗子 + if ( ( damage > 0 ) && ( CHAR_getWorkInt( attackindex , CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_ATTSHOOT ) ) { + if ( RAND ( 1 , 5 ) > 4 ) { + CHAR_setWorkInt( defindex, CHAR_WORKSLEEP , 3 ); //设定昏睡 + CHAR_setWorkInt( defindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE );//因为设定了昏睡,所以设定无动作 + } + } +#endif + if( damage > 0 ){ +#ifdef _TAKE_ITEMDAMAGE + if( BATTLE_ItemCrushSeq( attackindex, defindex, damage) == TRUE ){ +#else + if( BATTLE_ItemCrushSeq( defindex ) == TRUE ){ +#endif + flg |= BCF_CRUSH; + } + } + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + if( damage > 0 && (CHAR_getInt(attackindex, CHAR_WHICHTYPE)== CHAR_TYPEPLAYER) ){ + int i; + // 检查火、冰、雷附体 + for( i=0; i<3; i++ ){ + int turn = 0, status = -1; + + turn = CHAR_getWorkInt( attackindex, CHAR_WORK_F_ENCLOSE_2+i ); + + if( turn > 0 ){ + int skill_type = CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM1 ); + int perStatus = 0, j = 0; + int skill_level = CHAR_getWorkInt( attackindex, CHAR_WORKMOD_F_ENCLOSE_2+i ); + char pszP[3][10] = { "烧","霜","电" }; + int img1 = 101697, img2 = 101698 + i; + + // 状态 + for( j = 1; j < BATTLE_ST_END; j ++ ){ + if( strncmp( pszP[i], aszStatus[j], 2 ) == 0 ){ + status = j; + break; + } + } + + // 命中率 + perStatus = 20 + skill_level * 2; + + // 回合数 + if( skill_level >= 10 ) turn = 3; + else if( skill_level >= 5 ) turn = 2; + else turn = 1; + + // 雷附体一回合数 + if( i == 2 ) turn = 1; + + // 火、冰、雷附体附加攻击 +// Terry add fix 忠犬bug + if(Guardian >= 0) iRet = BATTLE_PROFESSION_RANG_ATTACK_DAMAGE(attackindex, attackNo, Guardian, skill_type, status, turn, perStatus, 0, img1, img2 ); + else iRet = BATTLE_PROFESSION_RANG_ATTACK_DAMAGE(attackindex, attackNo, defNo, skill_type, status, turn, perStatus, 0, img1, img2 ); + + break; + } + } + } +#endif + + if( 0 <= Guardian && Guardian <= 19 ){ + iRet = FALSE; + flg |= BCF_GUARDIAN; + snprintf( szCommand, sizeof( szCommand ), + "r%X|f%X|d%X|p%X|g%X|", + defNo, + flg, + damage, + petdamage, + Guardian ); + }else{ + snprintf( szCommand, sizeof( szCommand ), + "r%X|f%X|d%X|p%X|", + defNo, + flg, + damage, + petdamage ); + } + + BATTLESTR_ADD( szCommand ); + + defNo = BATTLE_Index2No( battleindex, defindex ); + + if( defNo >= SIDE_OFFSET ){ + i = defNo - SIDE_OFFSET; + DefSide = 1; + }else{ + i = defNo; + } + + i = defNo-DefSide*SIDE_OFFSET; + if( ultimate > 0 ){ + BattleArray[battleindex].Side[DefSide].Entry[i].flg |= BENT_FLG_ULTIMATE; + } + return iRet; + +} + +#endif + + +enum { + BATTLE_C_NONE = 0, + BATTLE_C_CLAW, + BATTLE_C_AXE, + BATTLE_C_CLUB, + BATTLE_C_SPEAR, + BATTLE_C_BOW, + BATTLE_C_THROU, + BATTLE_C_OTHER, + BATTLE_C_MAX +}; + +static int CounterTbl[] = { + 10, 9, 8, 8, 5, 0, 0, 0 , + 10, 9, 7, 7, 6, 0, 0, 0 , + 9, 8,10,10, 7, 0, 0, 0 , + 8, 8,10,10, 7, 0, 0, 0 , + 6, 6, 8, 8, 9, 0, 0, 0 , + 0, 0, 0, 0, 0, 0, 0, 0 , + 0, 0, 0, 0, 0, 0, 0, 0 , +}; + +static int BATTLE_ItemType2ItemMap( int type ){ + int iRet = BATTLE_C_NONE; + if( type == ITEM_FIST ) iRet = BATTLE_C_CLAW; + if( type == ITEM_AXE ) iRet = BATTLE_C_AXE; + if( type == ITEM_CLUB ) iRet = BATTLE_C_CLUB; + if( type == ITEM_BOW ) iRet = BATTLE_C_BOW; + if( type == ITEM_BOOMERANG ) iRet = BATTLE_C_THROU; + if( type == ITEM_BOUNDTHROW ) iRet = BATTLE_C_THROU; + if( type == ITEM_BREAKTHROW ) iRet = BATTLE_C_THROU; + return iRet; +} + +static BOOL BATTLE_CounterCheckPlayer( int attackindex, int defindex, int *pPar ) +{ + int + At_SoubiIndex, At_SoubiType, + Df_SoubiIndex, Df_SoubiType, + At_Soubi, CriPer, + At_Luck = 0, + flg = FALSE; + + float per; + + CriPer = BATTLE_CounterCalc( attackindex, defindex ); + + At_SoubiIndex = CHAR_getItemIndex( attackindex, CHAR_ARM ); + + if( BATTLE_IsThrowWepon( At_SoubiIndex ) == TRUE ){ + *pPar = 0.0; + return FALSE; + } + + if( ITEM_CHECKINDEX( At_SoubiIndex ) == FALSE ){ + At_SoubiType = ITEM_FIST; + }else{ + At_SoubiType = ITEM_getInt( At_SoubiIndex, ITEM_TYPE ); + } + + At_SoubiIndex = BATTLE_ItemType2ItemMap( At_SoubiType ); + + Df_SoubiIndex = CHAR_getItemIndex( defindex, CHAR_ARM ); + + if( BATTLE_IsThrowWepon( Df_SoubiIndex ) == TRUE ){ + *pPar = 0.0; + return FALSE; + } + + if( ITEM_CHECKINDEX( Df_SoubiIndex ) == FALSE ){ + Df_SoubiType = ITEM_FIST; + }else{ + Df_SoubiType = ITEM_getInt( Df_SoubiIndex, ITEM_TYPE ); + } + + Df_SoubiIndex = BATTLE_ItemType2ItemMap( Df_SoubiType ); + + At_Soubi = CounterTbl[BATTLE_C_MAX * At_SoubiIndex + Df_SoubiIndex]; + + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + At_Luck = CHAR_getWorkInt( attackindex, CHAR_WORKFIXLUCK ); + } + +#ifdef _SUIT_ADDENDUM + per = CriPer * At_Soubi * 0.1 + At_Luck + CHAR_getWorkInt( attackindex, CHAR_WORKCOUNTER ); +#else + per = CriPer * At_Soubi * 0.1 + At_Luck; +#endif + + *pPar = per; + + per *= 100; + if( per <= 0 ){ + per = 1; + *pPar = 0; + } + + if( RAND( 1, 10000 ) < per ){ + flg = TRUE; + }else{ + flg = FALSE; + } + return flg; +} + + +static BOOL BATTLE_CounterCheckPet( int attackindex, int defindex, int *pPer ) +{ + int At_SoubiIndex; + int flg = FALSE, Df_SoubiIndex, iWork; + + float per; + + At_SoubiIndex = CHAR_getItemIndex( attackindex, CHAR_ARM ); + + if( BATTLE_IsThrowWepon( At_SoubiIndex ) == TRUE ){ + *pPer = 0.0; + return FALSE; + } + + + Df_SoubiIndex = CHAR_getItemIndex( defindex, CHAR_ARM ); + + if( BATTLE_IsThrowWepon( Df_SoubiIndex ) == TRUE ){ + *pPer = 0.0; + return FALSE; + } + + per = BATTLE_CounterCalc( attackindex, defindex ); + + if( CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_NOGUARD ){ + iWork = CHAR_GETWORKINT_LOW( attackindex, CHAR_WORKBATTLECOM3 ); + iWork = iWork >> 8; + if( iWork > 127 )iWork *= -1; + per += iWork; + } + + if( per > 100 ) per = 100; + *pPer = per; + per *= 100; + + if( per <= 0 ){ + per = 1; + *pPer = per; + } + + if( RAND( 1, 10000 ) <= per ){ + flg = TRUE; + }else{ + flg = FALSE; + } + return flg; +} + +static BOOL BATTLE_CounterCheck( int attackindex, int defindex, int *pPar ) +{ +#ifdef _SHOOTCHESTNUT // Syu ADD 宠技:丢栗子 + if ( CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_ATTSHOOT || + CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_ATTSHOOT + ) { + return FALSE; + } +#endif + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + return BATTLE_CounterCheckPlayer( attackindex, defindex, pPar ); + }else{ + return BATTLE_CounterCheckPet( attackindex, defindex, pPar ); + } +} + + + +//反击判定 +BOOL BATTLE_Counter( int battleindex, int attackNo, int defNo ) +{ + + char szBuffer[512]=""; + char szCommand[1024]; + int damage = 0, petdamage = 0, attackindex, defindex, Guardian = -2, react = 0, ultimate = 0; + int flg = 0, iWork, par, DefSide = 0, i, per = 0; + BOOL iRet = TRUE; + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + defindex = BATTLE_No2Index( battleindex, defNo ); + +#ifdef _SHOOTCHESTNUT // Syu ADD 宠技:丢栗子 + if ( CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_ATTSHOOT ) { + return FALSE; + } +#endif + + if( CHAR_getInt( defindex, CHAR_HP ) <= 0 ) return FALSE; + if( CHAR_getInt( attackindex, CHAR_HP ) <= 0 ) return FALSE; + + if( CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_ATTACK + || CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_NOGUARD){ + ;; + }else{ + return FALSE; + } + + // nono宠 + if( CHAR_getWorkInt( attackindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_ABIO ) return FALSE; + + // 反击条件 + if( BATTLE_CounterCheck( attackindex, defindex, &per ) == FALSE ) return FALSE; + + // 光、镜、守 + if( BATTLE_GetDamageReact( attackindex ) > 0 ) + iRet = FALSE; + else if( BATTLE_GetDamageReact( defindex ) > 0 ) + iRet = FALSE; + + gWeponType = BATTLE_GetWepon( attackindex ); + + gDamageDiv = 1.0; + + iWork = BATTLE_AttackSeq( attackindex, defindex, &damage, &Guardian, -1 ); + + if( damage <= 0 ){ + damage = 0; + }else{ + damage *= 0.75; + if( damage < 1 ) damage = 1; + } + + react = 0; + ultimate = BATTLE_DamageSub( attackindex, defindex, &damage, &petdamage, &react ); + if( react == BATTLE_MD_REFLEC ) defindex = attackindex; + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + if( react == BATTLE_MD_TRAP ) defindex = attackindex; +#endif + +#ifdef _PETSKILL_ACUPUNCTURE + if( react == BATTLE_MD_ACUPUNCTURE ) defindex = attackindex; +#endif + + if( damage > 0 && ( react != BATTLE_MD_ABSROB ) && ( react != BATTLE_MD_VANISH )){ + BATTLE_DamageWakeUp( battleindex, defindex ); + } + par = BATTLE_AttrAdjust( attackindex, defindex, 100 ); + switch( iWork ){ + case BATTLE_RET_MISS: +/* + snprintf( szBuffer, sizeof(szBuffer), + "(%s)朝向(%s)反击,没击中。", + CHAR_getUseName( attackindex ), + CHAR_getUseName( defindex ) + ); +*/ + return FALSE; + + case BATTLE_RET_DODGE: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)意外攻击(%d%%)!但是(%s)闪开了(%.2f%%)", + // CHAR_getUseName( attackindex ), + // per, + // CHAR_getUseName( defindex ), + // gDuckPer + //); + flg |= BCF_DODGE; + break; + + case BATTLE_RET_NORMAL: + //snprintf( szBuffer, sizeof(szBuffer), + //"(%s)的反击!(%d%%)(%d)损伤 (%d:%d:%d%%)", + // CHAR_getUseName( attackindex ), + // per, + // damage, + // CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER ), + // CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ), + // par + //); + //andy_edit + flg |= BATTLE_getReactFlg( defindex, react); + break; + + case BATTLE_RET_CRITICAL: + //snprintf( szBuffer, sizeof(szBuffer), + //"(%s)的CRITICAL!(%d%%)(%d)损伤 (%d:%d:%d%%)", + // CHAR_getUseName( attackindex ), + // per, + // damage, + // CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER ), + // CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ), + // par + //); + flg |= BCF_KAISHIN; + iRet = FALSE; + //andy_edit + flg |= BATTLE_getReactFlg( defindex, react); + break; +#ifdef _EQUIT_ARRANGE + case BATTLE_RET_ARRANGE: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)攻击了(%s)挡掉了(%.2f%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // gDuckPer + //); + flg |= BCF_B_ARRANGE; + break; +#endif + } + + flg |= BCF_COUNTER; + + if( CHAR_getInt( defindex, CHAR_HP ) <= 0 ){ + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_ABIO ){ + ultimate = 1; + }else + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER + && flg & BCF_KAISHIN + ){ + if( RAND( 1, 100 ) < 50 ){ + ultimate = 1; + } + } +#ifdef _PETSKILL_LER +// 雷尔不能被打飞 + if(CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101813 || + CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101814) ultimate = 0; +#endif + iRet = FALSE; + flg |= BCF_DEATH; + + if( ultimate == 1 ){ + flg |= BCF_ULTIMATE_1; + strcat( szBuffer, "ultimate嘆" ); + } + if( ultimate == 2 ){ + flg |= BCF_ULTIMATE_2; + strcat( szBuffer, "ultimate嘇" ); + } + } + + if( damage > 0 ){ +#ifdef _TAKE_ITEMDAMAGE + if( BATTLE_ItemCrushSeq( attackindex, defindex, damage) == TRUE ){ +#else + if( BATTLE_ItemCrushSeq( defindex ) == TRUE ){ +#endif + flg |= BCF_CRUSH; + } + } + +#ifdef _NOTRIDE_ + snprintf( szCommand, sizeof( szCommand ), + "r%X|f%X|counter%X|", + defNo, + flg, + damage ); +#else + snprintf( szCommand, sizeof( szCommand ), + "r%X|f%X|counter%X|p%X|", + defNo, + flg, + damage, + petdamage + ); +#endif + //print(" CounterAttack!:%s ", szCommand ); + + BATTLESTR_ADD( szCommand ); + + + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + if( defNo >= SIDE_OFFSET ){ + i = defNo - SIDE_OFFSET; + DefSide = 1; + } + + i = defNo-DefSide*SIDE_OFFSET; + if( ultimate > 0 ){ + BattleArray[battleindex].Side[DefSide].Entry[i].flg |= BENT_FLG_ULTIMATE; + } + + return iRet; +} + + +static BOOL BATTLE_CaptureCheck( + int attackindex, + int defindex, + float *pPer +) +{ + float + Df_MaxHp = 0, + Df_HpPer = 0, + At_Charm = 0, + At_Level = 0, + At_Dex = 0, + At_Luck = 0, + Df_Level = 0, + Df_Dex = 0, + Df_Ge = 30; + float WorkGet; + + *pPer = 0; + + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) != CHAR_TYPEENEMY ){ + return FALSE; + } + + if( CHAR_getWorkInt( defindex, CHAR_WORK_PETFLG ) == 0 ){ + return FALSE; + } + + if( CHAR_getWorkInt( attackindex, CHAR_PickAllPet) != TRUE ) { + if( CHAR_getInt( attackindex, CHAR_LV ) + 5 < CHAR_getInt( defindex, CHAR_LV )){ + return FALSE; + } + } + + At_Charm = CHAR_getWorkInt( attackindex, CHAR_WORKFIXCHARM ); + At_Level = CHAR_getInt( attackindex, CHAR_LV ); + Df_Level = CHAR_getInt( defindex, CHAR_LV ); + At_Dex = CHAR_getWorkInt( attackindex, CHAR_WORKFIXDEX ); + Df_Dex = CHAR_getWorkInt( defindex, CHAR_WORKFIXDEX ); + Df_Ge = CHAR_getWorkInt( defindex, CHAR_WORKMODCAPTUREDEFAULT ); + At_Luck = CHAR_getWorkInt( attackindex, CHAR_WORKFIXLUCK ); + Df_HpPer = CHAR_getInt( defindex, CHAR_HP ); + Df_MaxHp = CHAR_getWorkInt( defindex, CHAR_WORKMAXHP ); + if( Df_MaxHp <= 0 ) Df_MaxHp = 1; + + Df_HpPer = 10 - ( Df_HpPer * Df_HpPer ) / Df_MaxHp; + Df_Level = ( At_Level/2 - Df_Level/2 ); + Df_Dex = At_Dex / 15 - Df_Dex / 15; + + WorkGet = ( Df_HpPer + Df_Level + Df_Dex + ( Df_Ge + At_Luck ) ) * At_Charm / 50; + + WorkGet += CHAR_getWorkInt( attackindex, CHAR_WORKMODCAPTURE ); + + if( CHAR_getWorkInt( defindex, CHAR_WORKSLEEP ) > 0 ){ + WorkGet += 15; + } + + if( WorkGet > 99 ) WorkGet = 99; + + *pPer = WorkGet; + + if( RAND( 1,100 ) < WorkGet ){ + return TRUE; + }else{ + return FALSE; + } + +} +#ifdef _CAPTURE_FREES +#define MAXCAPTRUEFREE 15 + +typedef struct _NeedItemEnemy{ + int EnemyId; + int ItemId[MAXCAPTRUEFREE]; +}NEEDITEMENEMY; +NEEDITEMENEMY NeedEnemy[] = { + { 524, { 2456, -1, -1, -1, -1, -1, -1, -1, -1, -1} }, + //伊甸任务 + { 961, {20219, -1, -1, -1, -1, -1, -1, -1, -1, -1} }, + { 953, {20223, -1, -1, -1, -1, -1, -1, -1, -1, -1} }, + { 962, {20222, -1, -1, -1, -1, -1, -1, -1, -1, -1} }, + + { 777, {20253, -1, -1, -1, -1, -1, -1, -1, -1, -1} }, + { 796, {20247, -1, -1, -1, -1, -1, -1, -1, -1, -1} }, + { 812, {20259, -1, -1, -1, -1, -1, -1, -1, -1, -1} }, + + { 1105, {1690, 1691, 1692, -1, -1, -1, -1, -1, -1, -1} }, + { 8, {1810, -1, -1, -1, -1, -1, -1, -1, -1, -1} }, +#ifdef _WOLF_TAKE_AXE // WON ADD 抓双头狼的限制 + { 145, {2236, -1, -1, -1, -1, -1, -1, -1, -1, -1} }, + { 146, {2236, -1, -1, -1, -1, -1, -1, -1, -1, -1} }, +#endif +}; +#else +typedef struct _NeedItemEnemy{ + int EnemyId; + int ItemId; +}NEEDITEMENEMY; +NEEDITEMENEMY NeedEnemy[] = { + { 524, 2456 }, + //伊甸任务 + { 961, 20219}, + { 953, 20223}, + { 962, 20222}, + + { 777, 20253}, + { 796, 20247}, + { 812, 20259}, + +}; +#endif + +static int IsNeedCaptureItem( int charaindex ) +{ + int i=0; + for( i = 0; i < arraysizeof( NeedEnemy ); i ++ ){ + if( NeedEnemy[i].EnemyId != CHAR_getInt( charaindex, CHAR_PETID ) )continue; +#ifdef _CAPTURE_FREES + return i; +#else + return NeedEnemy[i].ItemId; +#endif + } + return -1; +} + +BOOL BATTLE_CaptureItemCheck( int attackindex, int defindex ) +{ +#ifdef _CAPTURE_FREES + int i; +#endif + int j, ti, itemindex; + + ti = IsNeedCaptureItem( defindex ); + if( ti < 0 ) return TRUE; + +#ifdef _CAPTURE_FREES + for( i=0; i= CHAR_MAXITEMHAVE ) return FALSE; + } + return TRUE; +#else + for( j = CHAR_STARTITEMARRAY; j < CHAR_MAXITEMHAVE; j ++ ){ + itemindex =CHAR_getItemIndex( attackindex, j ); + if( ITEM_CHECKINDEX( itemindex ) == FALSE )continue; + if( ITEM_getInt( itemindex, ITEM_ID ) == ti ){ + return TRUE; + } + } + return FALSE; +#endif + +} + +#ifdef _CAPTURE_FREES +BOOL BATTLE_CaptureItemDelAll( int attackindex, int defindex ) +{ + int i, j, itemindex=-1,ti; + + ti = IsNeedCaptureItem( defindex ); + if( ti < 0 ) return TRUE; + + for( i=0; i= 0 ){ + for( i = CHAR_STARTITEMARRAY; i < CHAR_MAXITEMHAVE; i ++ ) { + itemindex = CHAR_getItemIndex( attackindex, i ); + if( ITEM_CHECKINDEX( itemindex ) == FALSE )continue; + if( ITEM_getInt( itemindex, ITEM_ID ) == needItemId ){ + { + char token[256]; + LogItem( + CHAR_getChar( attackindex, CHAR_NAME ), + CHAR_getChar( attackindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), +#endif + "PetEaten(使用料理捕获宠物)", + CHAR_getInt( attackindex,CHAR_FLOOR), + CHAR_getInt( attackindex,CHAR_X ), + CHAR_getInt( attackindex,CHAR_Y ), + ITEM_getChar(itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + CHAR_DelItem( attackindex, i); + } + } + } +#endif + CHAR_setInt( attackindex, CHAR_GETPETCOUNT, + CHAR_getInt( attackindex, CHAR_GETPETCOUNT ) + 1 ); + + BATTLE_Exit( defindex, battleindex ); + CHAR_complianceParameter( pindex ); + CHAR_setInt( pindex, CHAR_VARIABLEAI, 0 ); + ai = CHAR_DEFAULTMAXAI - CHAR_getWorkInt( pindex, CHAR_WORKFIXAI ); + if( ai < 0 ){ + CHAR_PetAddVariableAi( pindex, ai * 100 ); + CHAR_setWorkInt( pindex, CHAR_WORKFIXAI, + CHAR_getWorkInt( pindex, CHAR_WORKFIXAI ) + ai ); + } + } + } + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + { + char szCommand[1024]; + snprintf( szCommand, sizeof( szCommand ), + "BT|a%X|r%X|f%X|", + attackNo, + defNo, + flg ); + BATTLESTR_ADD( szCommand ); + } + return ( flg )?(TRUE):(FALSE); +} + +void BATTLE_Guard( + int battleindex, + int attackNo +) +{ + char szCommand[128]; + //int attackindex; + sprintf( szCommand, "bg|%x|", attackNo ); + BATTLESTR_ADD( szCommand ); + /*attackindex = BATTLE_No2Index( battleindex, attackNo ); + { + char szBuffer[256]=""; + //snprintf( szBuffer, sizeof(szBuffer), "(%s)保住了自身安全。", + // CHAR_getUseName( attackindex ) + //); + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + }*/ + +} + +BOOL BATTLE_EscapeCheck( int attackindex, int attackNo, int *pPar ) +{ + int Esc = 100; + + int myside, otherside, battleindex; + int mylevel, enemylevel = 0, enemycnt = 0, i, enemyindex, luck, + escape_cnt, rare, SubNo; + BATTLE_ENTRY *pEntry; + + myside = CHAR_getWorkInt( attackindex, CHAR_WORKBATTLESIDE ); + otherside = 1 - myside; + + battleindex = CHAR_getWorkInt( attackindex, CHAR_WORKBATTLEINDEX ); + + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return TRUE; + + if( BattleArray[battleindex].type == BATTLE_TYPE_P_vs_P )return TRUE; + + if( attackNo >= SIDE_OFFSET ){ + SubNo = attackNo - SIDE_OFFSET; + }else{ + SubNo = attackNo; + } + + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ){ + rare = CHAR_getInt( attackindex, CHAR_RARE ); + switch( rare ){ + case 0: luck = 1; break; + case 1: luck = 3; break; + default:luck = 5; break; + } + }else{ + luck = min( 5, CHAR_getWorkInt( attackindex, CHAR_WORKFIXLUCK ) ); + luck = max( 1, luck ); + } + + mylevel = CHAR_getInt( attackindex, CHAR_LV ); + pEntry = BattleArray[battleindex].Side[otherside].Entry; + + escape_cnt = BattleArray[battleindex].Side[myside].Entry[SubNo].escape+1; + + for( i = 0; i < BATTLE_ENTRY_MAX; i ++ ){ + enemyindex = pEntry[i].charaindex; + if( CHAR_CHECKINDEX( enemyindex ) == FALSE )continue; + + if( CHAR_getWorkInt( enemyindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_ABIO ) + enemylevel -= 100; + + enemylevel += CHAR_getInt( enemyindex, CHAR_LV ); + + enemycnt ++; + } + + if( enemycnt <= 0 ){ + enemylevel = 0; + Esc = 100; + }else{ + enemylevel /= enemycnt; + if( luck >= 5 ){ + Esc = 95 * escape_cnt; + }else + if( luck >= 4 ){ + Esc = ( 60 * escape_cnt ) - 2*( enemylevel - mylevel ); + }else + if( luck >= 3 ){ + Esc = ( 50 * escape_cnt ) - 2*( enemylevel - mylevel ); + }else + if( luck >= 2 ){ + Esc = ( 40 * escape_cnt ) - 2*( enemylevel - mylevel ); + }else + if( luck >= 1 ){ + Esc = ( 30 * escape_cnt ) - 2*( enemylevel - mylevel ); + }else{ + Esc = 95 * escape_cnt; + } + } + + if( Esc < 1 )Esc = 1; + + *pPar = Esc; + + if( RAND( 1,100 ) < Esc ){ + return TRUE; + }else{ + return FALSE; + } +} + + +BOOL BATTLE_Escape( int battleindex, int attackNo, int flag) +{ + //char szBuffer[512]=""; + char szCommand[1024]; + int attackindex, flg = FALSE, side, SubNo, iPar; + + sprintf( szCommand, "BE|e%X|", attackNo ); + BATTLESTR_ADD( szCommand ); + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + + if( !CHAR_CHECKINDEX( attackindex ) ){ + return FALSE; + } + + if( attackNo >= SIDE_OFFSET ){ + side = 1; SubNo = attackNo - SIDE_OFFSET; + }else{ + side = 0; SubNo = attackNo; + } + + BattleArray[battleindex].Side[side].Entry[SubNo].escape ++; + + if( BATTLE_EscapeCheck( attackindex, attackNo, &iPar ) == FALSE ){ + flg = 0; + }else{ + flg = 1; + } + + if( flg == 1 || flag == 1 ){ + //snprintf( szBuffer, sizeof(szBuffer), "(%s)逃跑了(%d%%)", + // CHAR_getUseName( attackindex ), iPar + //); + //if( getBattleDebugMsg( ) != 0 ){ + // BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + //} + + if( BattleArray[battleindex].type == BATTLE_TYPE_P_vs_P + && CHAR_getInt( attackindex, CHAR_HP ) > 0 ){ + BATTLE_EscapeDpSend( battleindex, attackindex ); + BATTLE_GetDuelPoint( battleindex, side, SubNo ); + } + CHAR_DischargePartyNoMsg( attackindex ); + BATTLE_Exit( attackindex, battleindex ); + CHAR_setWorkInt( attackindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_FINAL ); + }else{ + //if( getBattleDebugMsg( ) != 0 ){ + //snprintf( szBuffer, sizeof(szBuffer), "(%s)差点跑了(%d%%)", + // CHAR_getUseName( attackindex ), iPar + //); + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + //} + } + snprintf( szCommand, sizeof( szCommand ), "f%X|", flg ); + BATTLESTR_ADD( szCommand ); + + return ( flg )?(TRUE):(FALSE); +} + + +int BATTLE_SurpriseCheck( int battleindex ) +{ + int iRet = 0, Rnd, charaindex, luck, a = 0, b = 7; + + if( BattleArray[battleindex].Side[0].type == BATTLE_S_TYPE_PLAYER + && BattleArray[battleindex].Side[1].type == BATTLE_S_TYPE_PLAYER + ){ + return 0; + } + + charaindex = BattleArray[battleindex].Side[0].Entry[0].charaindex; + + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return 0; + + if( BattleArray[battleindex].WinFunc != NULL )return 0; + + luck = CHAR_getWorkInt( charaindex, CHAR_WORKFIXLUCK ); + + switch( luck ){ + case 5: a = 20; b = 0; break; + case 4: a = 15; b = 2; break; + case 3: a = 10; b = 3; break; + case 2: a = 5; b = 5; break; + default: a = 0; b = 7; break; + } + + Rnd = RAND( 1, 100 ); + + if( Rnd <= a ){ + iRet = 1; + }else + if( Rnd < a + b ){ + iRet = 2; + } + + return iRet; +} + + +int BATTLE_NoAction( int battleindex, int attackNo ) +{ + //char szBuffer[512]=""; + char szCommand[512]; + int attackindex ; + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + + sprintf( szCommand, "bn|%x|", attackNo ); + BATTLESTR_ADD( szCommand ); + + //snprintf( szBuffer, sizeof(szBuffer), "(%s)什麽也不能做。", + // CHAR_getUseName( attackindex ) + //); + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + return 0; +} + + +int BATTLE_PetIn( int battleindex, int attackNo ) +{ + //char szBuffer[512]=""; + char szCommand[1024]; + int attackindex, petindex ; + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + petindex = CHAR_getInt( attackindex, CHAR_DEFAULTPET ); + petindex = CHAR_getCharPet( attackindex, petindex ); +#ifdef _FIXWOLF // Syu ADD 修正狼人变身Bug + if ( CHAR_getInt ( petindex , CHAR_BASEIMAGENUMBER) == 101428 ) + { + CHAR_setInt( petindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( petindex , CHAR_BASEBASEIMAGENUMBER)); + CHAR_setWorkInt( petindex, CHAR_WORKATTACKPOWER, CHAR_getWorkInt( petindex , CHAR_WORKFIXSTR)); + CHAR_setWorkInt( petindex, CHAR_WORKQUICK, CHAR_getWorkInt( petindex , CHAR_WORKFIXDEX)); + } +#endif +#ifdef _PETSKILL_BECOMEFOX // 宠物中媚惑术收回後再放出来时要恢复正常状态 + if ( CHAR_getInt ( petindex , CHAR_WORKFOXROUND) != -1 + || CHAR_getInt( petindex, CHAR_BASEIMAGENUMBER) == 101749 ){ //若是变身为狸 + CHAR_setInt( petindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( petindex , CHAR_BASEBASEIMAGENUMBER)); + CHAR_setWorkInt( petindex, CHAR_WORKATTACKPOWER, CHAR_getWorkInt( petindex , CHAR_WORKFIXSTR)); + CHAR_setWorkInt( petindex, CHAR_WORKQUICK, CHAR_getWorkInt( petindex , CHAR_WORKFIXDEX)); + CHAR_setInt ( petindex , CHAR_WORKFOXROUND, -1 ); + } +#endif + if( CHAR_getWorkInt( petindex, CHAR_WORKBATTLEFLG ) + & CHAR_BATTLEFLG_NORETURN + ){ + //snprintf( szBuffer, sizeof(szBuffer), "(%s)无法回复成(%s)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( petindex ) + //); + return 0; + } + + BATTLE_PetDefaultExit( attackindex, battleindex ); + CHAR_setInt( attackindex, CHAR_DEFAULTPET, -1 ); + + //snprintf( szBuffer, sizeof(szBuffer), "(%s)回复成(%s)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( petindex ) + //); + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + sprintf( szCommand, "BS|s%X|f0|", attackNo ); + BATTLESTR_ADD( szCommand ); + + return 0; + +} + +int BATTLE_PetOut( int battleindex, int attackNo ) +{ + //char szBuffer[512]=""; + char szCommand[1024], szEscapeName[128]; + int attackindex, petindex, petNo, flg = 0,iRet ; + + szCommand[0] = 0; + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + petNo = CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM2 ); + + CHAR_setInt( attackindex, CHAR_DEFAULTPET, petNo ); + + iRet = BATTLE_PetDefaultEntry( attackindex, battleindex, + CHAR_getWorkInt( attackindex, CHAR_WORKBATTLESIDE ) ); + + if( iRet < 0 ){ + //snprintf( szBuffer, sizeof(szBuffer), "(%s)呼唤宠物,可是没有出现其踪迹。", + // CHAR_getUseName( attackindex ) + //); + }else + if( CHAR_getInt( attackindex, CHAR_DEFAULTPET ) < 0 ){ + //snprintf( szBuffer, sizeof(szBuffer), "(%s)呼唤宠物,可是没有出现其踪迹。", + // CHAR_getUseName( attackindex ) + //); + }else{ + flg = 1; + petNo = CHAR_getInt( attackindex, CHAR_DEFAULTPET ); + petindex = CHAR_getCharPet( attackindex, petNo ); + + CHAR_setWorkInt( petindex, CHAR_WORKBATTLEMODE, + BATTLE_CHARMODE_C_OK ); + + //snprintf( szBuffer, sizeof(szBuffer), "(%s)呼唤(%s)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( petindex ) + //); + + makeEscapeString( CHAR_getUseName( petindex ), + szEscapeName, + sizeof( szEscapeName ) ); + + sprintf( szCommand, "BS|s%X|f1|g%X|l%X|h%X|%s|m%X|", + attackNo, + CHAR_getInt( petindex, CHAR_BASEIMAGENUMBER), + CHAR_getInt( petindex, CHAR_LV), + CHAR_getInt( petindex, CHAR_HP), + szEscapeName, + CHAR_getWorkInt( petindex, CHAR_WORKMAXHP) + ); + BATTLESTR_ADD( szCommand ); + } + + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + return ( flg )?(TRUE):(FALSE); + +} + + +int BATTLE_Magic( int battleindex, int attackNo ) +{ + int attackindex, defindex, defNo; + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + defNo = CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM2 ); + defindex = BATTLE_No2Index( battleindex, defNo ); + + return 0; +} + + +//判别攻击是否命中 +int BATTLE_S_GBreak( int battleindex, int attackNo, int defNo ) +{ + char szBuffer[512]=""; + char szCommand[1024]; + int damage = 0, petdamage = 0, attackindex, defindex, ultimate = 0; + int flg = 0, iWork, par, i, DefSide = 0, + react = 0, + Guardian = -1; + BOOL iRet = FALSE; + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + defindex = BATTLE_No2Index( battleindex, defNo ); + + if( defNo >= SIDE_OFFSET ){ + i = defNo - SIDE_OFFSET; + DefSide = 1; + } + + iWork = BATTLE_AttackSeq( attackindex, defindex, &damage, + &Guardian, BATTLE_COM_S_GBREAK ); + + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_GUARD + && CHAR_getWorkInt( defindex, CHAR_WORKCONFUSION ) <= 0 + ){ + react = 0; + ultimate = BATTLE_DamageSub( attackindex, defindex, &damage, &petdamage, &react ); + if( react == BATTLE_MD_REFLEC )defindex = attackindex; +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + if( react == BATTLE_MD_TRAP ) defindex = attackindex; +#endif +#ifdef _PETSKILL_ACUPUNCTURE + if( react == BATTLE_MD_ACUPUNCTURE ) defindex = attackindex; +#endif + + }else{ + //若敌非防御则damage为0 + damage = 0; + iWork = BATTLE_RET_MISS; + } + + if( damage > 0 + && ( react != BATTLE_MD_ABSROB ) + && ( react != BATTLE_MD_VANISH ) + ){ + BATTLE_DamageWakeUp( battleindex, defindex ); + } + + par = BATTLE_AttrAdjust( attackindex, defindex, 100 ); + switch( iWork ){ + + case BATTLE_RET_ALLGUARD: + case BATTLE_RET_MISS: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)朝向(%s)发动绝技,没击中。", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ) + //); + iRet = TRUE; + break; + + case BATTLE_RET_DODGE: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)展开防御攻击(%s)躲开了(%.2f%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // gDuckPer + //); + flg |= BCF_DODGE; + iRet = TRUE; + break; + + case BATTLE_RET_NORMAL: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)受到(%s)的绝技攻击(%d)损伤(%d:%d:%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // damage, + // CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER ), + // CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ), + // par + //); + //andy_edit + flg |= BATTLE_getReactFlg( defindex, react); + flg |= BCF_NORMAL; + iRet = TRUE; + break; + + case BATTLE_RET_CRITICAL: + //snprintf( szBuffer, sizeof(szBuffer), + //"(%s)受到(%s)的绝技CRITICAL(%d)损伤(%d:%d:%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // damage, + // CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER ), + // CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ), + // par + //); + flg |= BCF_KAISHIN; + iRet = FALSE; + //andy_edit + flg |= BATTLE_getReactFlg( defindex, react); + break; +#ifdef _EQUIT_ARRANGE + case BATTLE_RET_ARRANGE: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)攻击了(%s)挡掉了(%.2f%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // gDuckPer + //); + flg |= BCF_B_ARRANGE; + break; +#endif + } + + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_GUARD + && CHAR_getWorkInt( defindex, CHAR_WORKCONFUSION ) <= 0 + ){ + strncat( szBuffer, "(GUARD)", sizeof( szBuffer ) ); + iRet = FALSE; + } + + flg |= BCF_GBREAK; + + if( CHAR_getInt( defindex, CHAR_HP ) <= 0 ){ + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_ABIO ){ + ultimate = 1; + }else + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY + && flg & BCF_KAISHIN + ){ + if( RAND( 1, 100 ) < 50 ){ + ultimate = 1; + } + } +#ifdef _PETSKILL_LER +// 雷尔不能被打飞 + if(CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101813 || + CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101814) ultimate = 0; +#endif + iRet = FALSE; + flg |= BCF_DEATH; + + if( ultimate == 1 ){ + flg |= BCF_ULTIMATE_1; + strcat( szBuffer, "ultimate嘆" ); + } + if( ultimate == 2 ){ + flg |= BCF_ULTIMATE_2; + strcat( szBuffer, "ultimate嘇" ); + } + } + + if( damage > 0 ){ +#ifdef _TAKE_ITEMDAMAGE + if( BATTLE_ItemCrushSeq( attackindex, defindex, damage) == TRUE ){ +#else + if( BATTLE_ItemCrushSeq( defindex ) == TRUE ){ +#endif + flg |= BCF_CRUSH; + } + } + +#ifdef _NOTRIDE_ + snprintf( szCommand, sizeof( szCommand ), + "BH|a%X|r%X|f%X|d%X|FF|", + attackNo, + defNo, + flg, + damage ); +#else + snprintf( szCommand, sizeof( szCommand ), + "BH|a%X|r%X|f%X|d%X|p%X|FF|", + attackNo, + defNo, + flg, + damage, + petdamage + ); +#endif + + BATTLESTR_ADD( szCommand ); + + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + i = defNo-DefSide*SIDE_OFFSET; + if( ultimate > 0 ){ + BattleArray[battleindex].Side[DefSide].Entry[i].flg |= BENT_FLG_ULTIMATE; + } + + return iRet; +} + + +#ifdef _SKILL_SACRIFICE//救援 vincent add 2002/05/30 +int BATTLE_S_Sacrifice( int battleindex, int attackNo, int defNo ) +{ + int attackindex, defindex = 0; + int DefSide ,Damage= 0; + BOOL iRet = FALSE; + char szCommand[256]; + int ToList[SIDE_OFFSET*2+1]; + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + defindex = BATTLE_No2Index( battleindex, defNo ); + if( defNo >= SIDE_OFFSET ){ + DefSide = 1; + } + + //修正HP + CHAR_setInt(attackindex,CHAR_HP,(CHAR_getInt(attackindex,CHAR_HP)*0.5)); + CHAR_setInt(defindex,CHAR_HP,min(CHAR_getInt(attackindex,CHAR_HP)+CHAR_getInt(defindex,CHAR_HP),CHAR_getWorkInt(defindex,CHAR_WORKMAXHP))); + Damage=CHAR_getInt(attackindex,CHAR_HP); + + //魔法动画 + BATTLE_MultiList( battleindex, defNo, ToList ); + //秀hp改变数值 + BATTLE_MagicEffect(battleindex, attackNo, ToList, MAGIC_EFFECT_USER, SPR_heal2 ); + snprintf( szCommand, sizeof(szCommand),"BD|r%X|%X|%X|d%X|p%X|", attackNo, BD_KIND_HP, 0, Damage, 0 ); + BATTLESTR_ADD( szCommand ); + snprintf( szCommand, sizeof(szCommand),"BD|r%X|%X|%X|d%X|p%X|", ToList[0], BD_KIND_HP, 1, Damage, 0 ); + BATTLESTR_ADD( szCommand ); + return iRet; +} +#endif + + +#ifdef _SKILL_REFRESH +int BATTLE_S_Refresh( int battleindex, int attackNo, int defNo, int marray ) +{ + BOOL iRet = FALSE; + char *magicarg; + int status = -1, i,charaindex; + int ReceveEffect= 0; + char *pszP; + magicarg = PETSKILL_getChar( marray, PETSKILL_OPTION ); + pszP = magicarg; + + for( ;status == -1 && pszP[0] != 0; pszP++ ){ + for( i = 0; i < BATTLE_ST_END; i ++ ){ + if( strncmp( pszP, aszStatus[i], 2 ) == 0 ){ + status = i; + pszP +=2; + break; + } + } + } + + if( status == -1 ) return iRet; + charaindex = BATTLE_No2Index( battleindex, attackNo ); + if( CHAR_getWorkInt( charaindex, StatusTbl[status] ) > 0 ){ + ReceveEffect = SPR_tyusya; + iRet = TRUE; + }else{ + ReceveEffect = SPR_hoshi; + } + + BATTLE_MultiStatusRecovery( battleindex, attackNo, defNo, + status, MAGIC_EFFECT_USER, ReceveEffect ); + return iRet; +} +#endif + +#ifdef _SKILL_ROAR //vincent宠技:大吼 +int BATTLE_S_Roar( int battleindex, int attackNo, int defNo, int marray ) +{ + int masteridx=-1, index2, charaindex; + BOOL iRet = FALSE; + char buf1[256]; + char szWork[128]; + int petid=-1, i=1; + BOOL FINDPET=FALSE; + + char *magicarg; + int flg=0; + + charaindex = BATTLE_No2Index( battleindex, attackNo ); + + index2 = BATTLE_No2Index( battleindex, defNo);//被击中目标之index + + if( !CHAR_CHECKINDEX( index2) ) return iRet; + if( BATTLE_Index2No( battleindex, charaindex ) == defNo ){//用在自身 + return iRet; + } + + if( CHAR_getInt( index2, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) { + petid = -1;//作用在人物 + }else if( CHAR_getInt( index2, CHAR_WHICHTYPE) == CHAR_TYPEPET ) { + masteridx = BATTLE_No2Index(battleindex,defNo-5);//作用在宠物 + if( !CHAR_CHECKINDEX( masteridx) ) return iRet; + petid = CHAR_getInt(index2,CHAR_PETID);//宠物id + }else if( CHAR_getInt( index2, CHAR_WHICHTYPE) == CHAR_TYPEENEMY ) { + petid = CHAR_getInt(index2,CHAR_PETID); + } + + magicarg = PETSKILL_getChar( marray, PETSKILL_OPTION ); + while( getStringFromIndexWithDelim( magicarg,"|", i, buf1, sizeof( buf1)) != FALSE ) { + if( petid == atoi( buf1) ){//年兽判别 + FINDPET = TRUE; + break; + } + i++; + } + +//送讯息至玩家 + if( FINDPET == TRUE ) {//若为年兽 + char buf4[255]; + sprintf( buf4, "%s被吼声吓跑了!", CHAR_getChar( index2, CHAR_NAME)); + BATTLE_Exit(index2,battleindex);//离开战斗 + if( CHAR_CHECKINDEX( masteridx) ){ + CHAR_setInt(masteridx,CHAR_DEFAULTPET,-1);//无参战宠 + CHAR_talkToCli( masteridx,-1, buf4, CHAR_COLORYELLOW); + } + + //前攻动画 + flg |= BCF_ROAR; + sprintf( szWork, "BH|a%X|", attackNo ); + BATTLESTR_ADD( szWork ); + snprintf( szWork, sizeof( szWork ), "r%X|f%X|d%X|p%X|", defNo, flg, 0, 0 ); + + BATTLESTR_ADD(szWork); + BATTLESTR_ADD( "FF|" ); + sprintf(szWork,"BQ|e%X|",defNo);//逃跑动画 + BATTLESTR_ADD(szWork); + CHAR_talkToCli( CHAR_getWorkInt(charaindex, CHAR_WORKPLAYERINDEX),-1, buf4, CHAR_COLORYELLOW); + } + + return iRet; +} +#endif + +#ifdef _SKILL_GUARDBREAK2//破除防御2 vincent add 2002/05/20 +int BATTLE_S_GBreak2( int battleindex, int attackNo, int defNo ) +{ + char szBuffer[512]=""; + char szCommand[1024]; + int damage = 0, petdamage = 0, attackindex, defindex, ultimate = 0; + int flg = 0, iWork, par, i, DefSide = 0, + react = 0, + Guardian = -1; + BOOL iRet = FALSE; + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + defindex = BATTLE_No2Index( battleindex, defNo ); + + if( defNo >= SIDE_OFFSET ){ + i = defNo - SIDE_OFFSET; + DefSide = 1; + } + + iWork = BATTLE_AttackSeq( attackindex, defindex, &damage, + &Guardian, BATTLE_COM_S_GBREAK2 ); + react = 0; + ultimate = BATTLE_DamageSub( attackindex, defindex, &damage, &petdamage, &react ); + if( react == BATTLE_MD_REFLEC )defindex = attackindex; + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + if( react == BATTLE_MD_TRAP ) defindex = attackindex; +#endif +#ifdef _PETSKILL_ACUPUNCTURE + if( react == BATTLE_MD_ACUPUNCTURE ) defindex = attackindex; +#endif + + + if( damage > 0 + && ( react != BATTLE_MD_ABSROB ) + && ( react != BATTLE_MD_VANISH ) + ){ + BATTLE_DamageWakeUp( battleindex, defindex ); + } + + par = BATTLE_AttrAdjust( attackindex, defindex, 100 ); + switch( iWork ){ + + case BATTLE_RET_ALLGUARD: + case BATTLE_RET_MISS: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)朝向(%s)发动绝技,没击中。", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ) + //); + iRet = TRUE; + break; + + case BATTLE_RET_DODGE: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)展开防御攻击(%s)躲开了(%.2f%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // gDuckPer + //); + flg |= BCF_DODGE; + iRet = TRUE; + break; + + case BATTLE_RET_NORMAL: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)受到(%s)的绝技攻击(%d)损伤(%d:%d:%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // damage, + // CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER ), + // CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ), + // par + //); + //andy_edit + flg |= BATTLE_getReactFlg( defindex, react); + flg |= BCF_NORMAL; + iRet = TRUE; + break; + + case BATTLE_RET_CRITICAL: + //snprintf( szBuffer, sizeof(szBuffer), + //"(%s)受到(%s)的绝技CRITICAL(%d)损伤(%d:%d:%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // damage, + // CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER ), + // CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ), + // par + //); + flg |= BCF_KAISHIN; + iRet = FALSE; + //andy_edit + flg |= BATTLE_getReactFlg( defindex, react); + break; +#ifdef _EQUIT_ARRANGE + case BATTLE_RET_ARRANGE: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)攻击了(%s)挡掉了(%.2f%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // gDuckPer + //); + flg |= BCF_B_ARRANGE; + break; +#endif + } + + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_GUARD + && CHAR_getWorkInt( defindex, CHAR_WORKCONFUSION ) <= 0 + ){ + strncat( szBuffer, "(GUARD)", sizeof( szBuffer ) ); + flg |= BCF_GUARD; + flg |= BCF_GBREAK; + iRet = FALSE; + } + + if( CHAR_getInt( defindex, CHAR_HP ) <= 0 ){ + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_ABIO ){ + ultimate = 1; + }else if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY && flg & BCF_KAISHIN ){ + if( RAND( 1, 100 ) < 50 ){ + ultimate = 1; + } + } +#ifdef _PETSKILL_LER +// 雷尔不能被打飞 + if(CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101813 || + CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101814) ultimate = 0; +#endif + iRet = FALSE; + flg |= BCF_DEATH; + + if( ultimate == 1 ){ + flg |= BCF_ULTIMATE_1; + strcat( szBuffer, "ultimate嘆" ); + } + if( ultimate == 2 ){ + flg |= BCF_ULTIMATE_2; + strcat( szBuffer, "ultimate嘇" ); + } + } + + if( damage > 0 ){ +#ifdef _TAKE_ITEMDAMAGE + if( BATTLE_ItemCrushSeq( attackindex, defindex, damage) == TRUE ){ +#else + if( BATTLE_ItemCrushSeq( defindex ) == TRUE ){ +#endif + flg |= BCF_CRUSH; + } + } + +#ifdef _NOTRIDE_ + snprintf( szCommand, sizeof( szCommand ), + "BH|a%X|r%X|f%X|d%X|FF|", + attackNo, + defNo, + flg, + damage ); +#else + snprintf( szCommand, sizeof( szCommand ), + "BH|a%X|r%X|f%X|d%X|p%X|FF|", + attackNo, + defNo, + flg, + damage, + petdamage + ); +#endif + + BATTLESTR_ADD( szCommand ); + + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + i = defNo-DefSide*SIDE_OFFSET; + if( ultimate > 0 ){ + BattleArray[battleindex].Side[DefSide].Entry[i].flg |= BENT_FLG_ULTIMATE; + } + + return iRet; + +} +#endif + + +int BATTLE_Charge( int battleindex, int attackNo ) +{ + //char szBuffer[512]=""; + int attackindex, iWork, N, pow; + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + + iWork = CHAR_GETWORKINT_LOW( attackindex, CHAR_WORKBATTLECOM3 ); + + if( iWork <= 0 ){ + + N = CHAR_GETWORKINT_HIGH( attackindex, CHAR_WORKBATTLECOM3 ); + pow = CHAR_getWorkInt( attackindex, CHAR_WORKFIXSTR ); + pow += pow * N * 0.01; + CHAR_setWorkInt( attackindex, CHAR_WORKATTACKPOWER, + pow + CHAR_getWorkInt( attackindex, CHAR_WORKMODATTACK ) ); + + CHAR_setWorkInt( attackindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_CHARGE_OK ); + return TRUE; + }else{ + + CHAR_SETWORKINT_LOW( attackindex, CHAR_WORKBATTLECOM3, iWork - 1); + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)保持体力中。", + // CHAR_getUseName( attackindex ) + //); + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + BATTLE_NoAction( battleindex, attackNo ); + + return FALSE; + } +} + +//状态攻击命中判定 +int BATTLE_StatusAttackCheck( + int attackindex, + int defindex, + int status, + int PerOffset, + int Range, + float Bai, + int *pPer +) +{ + + int Df_Reg = 0, level = 0, per = 0, i ; + int battleindex; + if( status >= BATTLE_ST_END || status <= 0 )return FALSE; + for( i = 1; i < BATTLE_ST_END; i++ ){//若已有异常状态则return + if( CHAR_getWorkInt( defindex, StatusTbl[i] ) > 0 )return FALSE; + } + + if( status == BATTLE_ST_PARALYSIS){ + per = 20; + per -= CHAR_getWorkInt( defindex, RegTbl[status] ); + *pPer = per; + }else{ + float templP = 0.0; + float fVitalP = 0.0; + fVitalP = CHAR_getInt( defindex, CHAR_VITAL ) + + CHAR_getInt( defindex, CHAR_STR ) + + CHAR_getInt( defindex, CHAR_TOUGH ) + + CHAR_getInt( defindex, CHAR_DEX ); + + templP = (float)CHAR_getInt( defindex, CHAR_VITAL ) / (fVitalP); + +#ifdef _PET_SKILL_SARS //andy_add 2003/06/20 + if( status == BATTLE_ST_SARS ){ + templP = (1 - templP)*0.9; + } +#endif + + fVitalP = templP / 0.25; + + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + fVitalP *= 10.0; + }else{ + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + fVitalP *= 10.0; + }else{ + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ){ + fVitalP *= 10.0; + }else{ + fVitalP *= 10.0; + } + } + } + + if( status >= arraysizeof( RegTbl) || status < 0 ) { + Df_Reg = 0; + }else { + Df_Reg = CHAR_getWorkInt( defindex, RegTbl[status] ); + } + + battleindex = CHAR_getWorkInt( attackindex, CHAR_WORKBATTLEINDEX ); + if( BattleArray[battleindex].type != BATTLE_TYPE_P_vs_P ){ + level = CHAR_getInt( attackindex, CHAR_LV ) + - CHAR_getInt( defindex, CHAR_LV ); + level *= Bai; + }else{ + level = 0; + } + if( level > Range )level = Range; + if( level < -Range )level = -Range; + +#ifdef _SUIT_ADDENDUM + per = PerOffset + level + CHAR_getWorkInt( attackindex, CHAR_WORKFIXLUCK ) + - Df_Reg - fVitalP - CHAR_getWorkInt( defindex, CHAR_WORKRESIST ); +#else + per = PerOffset + level + CHAR_getWorkInt( attackindex, CHAR_WORKFIXLUCK ) + - Df_Reg - fVitalP; +#endif //_SUIT_ADDENDUM +#ifdef _EQUIT_RESIST + if( status == CHAR_WORKWEAKEN ) + per -= CHAR_getWorkInt( defindex, CHAR_WORKEQUITWEAKEN ); + else if( status == CHAR_WORKBARRIER ) + per -= CHAR_getWorkInt( defindex, CHAR_WORKEQUITBARRIER ); + else if( status == CHAR_WORKNOCAST ) + per -= CHAR_getWorkInt( defindex, CHAR_WORKEQUITNOCAST ); +#endif //_EQUIT_RESIST +#ifdef _SUIT_ADDPART3 + if( status == CHAR_WORKWEAKEN ) + per -= CHAR_getWorkInt( defindex, CHAR_WORKRENOCAST ); +#endif + if( per > 80 )per = 80; + *pPer = per; + } + + if( RAND( 1, 100 ) < per ){ + return TRUE; + }else{ + return FALSE; + } +} + +//职业技能状态攻击命中判定 +int PROFESSION_BATTLE_StatusAttackCheck( int charaindex, int toindex, int status, int Success ) +{ + int rand_num = RAND( 1, 100 ); + int i; + + if( status >= BATTLE_ST_END || status <= 0 ) return 0; + if( CHAR_getInt( toindex , CHAR_HP) <= 0 ) return 0; + if( CHAR_getFlg( toindex, CHAR_ISDIE ) == TRUE ) return 0; + +#ifdef _PROFESSION_ADDSKILL + if( status == BATTLE_ST_RESIST_F_I_T ){//自然威能 + if( CHAR_getWorkInt( toindex, StatusTbl[BATTLE_ST_RESIST_F] ) > 0 ) return 0; + if( CHAR_getWorkInt( toindex, StatusTbl[BATTLE_ST_RESIST_I] ) > 0 ) return 0; + if( CHAR_getWorkInt( toindex, StatusTbl[BATTLE_ST_RESIST_T] ) > 0 ) return 0; + return 1; + } + if( status == CHAR_WORKICECRACK + || status == CHAR_WORKICECRACK2 + || status == CHAR_WORKICECRACK3 + || status == CHAR_WORKICECRACK4 + || status == CHAR_WORKICECRACK5 + || status == CHAR_WORKICECRACK6 + || status == CHAR_WORKICECRACK7 + || status == CHAR_WORKICECRACK8 + || status == CHAR_WORKICECRACK9 + || status == CHAR_WORKICECRACK10){ + return 1; + } +#endif + + for( i = 1; i < BATTLE_ST_END; i++ ){//若已有异常状态则return + if( CHAR_getWorkInt( toindex, StatusTbl[i] ) > 0 ) return 0; + } + + if( rand_num < Success ){ + return 1; + }else{ + return 0; + } +} + + + +int BATTLE_Combo( int battleindex, int *pAttackList, int defNo ) +{ + char szBuffer[512]=""; + char szCommand[1024]; + int damage = 0, petdamage = 0, + attackindex, + toindex, + defindex, + ultimate = 0, + AllDamage = 0, + AllPetDamage = 0, + react = 0, + attackNo; + int flg = 0, iWork, par, i, DefSide = 0, + Guardian = -2; + BOOL iRet = FALSE; + + defindex = toindex = BATTLE_No2Index( battleindex, defNo ); + + //BATTLE_BroadCast( battleindex, "发动必杀技!!", + // (pAttackList[0] >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + for( i = 0; pAttackList[i] != -1 && i < BATTLE_ENTRY_MAX; i ++ ){ + attackNo = pAttackList[i]; + + defindex = toindex; + + flg = 0; + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + + if( CHAR_getInt( toindex, CHAR_HP ) <= 0 ){ + return FALSE; + } + + if( CHAR_getInt( attackindex, CHAR_HP ) <= 0 ){ + return FALSE; + } + + Guardian = -2; + iWork = BATTLE_AttackSeq( attackindex, toindex, &damage, + &Guardian, BATTLE_COM_COMBO ); + Guardian = -1; + if( damage <= 0 )damage = 1; + + par = BATTLE_AttrAdjust( attackindex, defindex, 100 ); + + react = BATTLE_GetDamageReact( defindex ); + if( ( react == BATTLE_MD_REFLEC +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + || react == BATTLE_MD_TRAP +#endif +#ifdef _PETSKILL_ACUPUNCTURE + || react == BATTLE_MD_ACUPUNCTURE +#endif + ) && BATTLE_IsThrowWepon( CHAR_getItemIndex( attackindex, CHAR_ARM ) ) == FALSE ){ + + int refrect = 0; + BATTLE_DamageSub( attackindex, + defindex, &damage, &petdamage, &refrect ); + }else + if( react == BATTLE_MD_ABSROB + || react == BATTLE_MD_VANISH + ){ + int refrect = 0; + BATTLE_DamageSub( attackindex, + defindex, &damage, &petdamage, &refrect ); + }else{ + + BATTLE_DamageSubCale( attackindex, + defindex, &damage, &petdamage ); + AllDamage += damage; + AllPetDamage += petdamage; + } + + if( pAttackList[i+1] == -1 ){ + int refrect = -1; + ultimate = BATTLE_DamageSub2( attackindex, + defindex, &AllDamage, &AllPetDamage, &refrect ); + } + if( react == BATTLE_MD_REFLEC ){ + defindex = attackindex; + } +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + if( react == BATTLE_MD_TRAP ) defindex = attackindex; +#endif +#ifdef _PETSKILL_ACUPUNCTURE + if( react == BATTLE_MD_ACUPUNCTURE ) defindex = attackindex; +#endif + if( damage > 0 && ( react != BATTLE_MD_ABSROB )&& ( react != BATTLE_MD_VANISH )){ + BATTLE_DamageWakeUp( battleindex, defindex ); + } + + szBuffer[0] = 0; + switch( iWork ){ + + case BATTLE_RET_MISS: + case BATTLE_RET_ALLGUARD: + case BATTLE_RET_NORMAL: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)受到(%s)的攻击(%d)遭受损伤(%d:%d:%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // damage, + // CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER ), + // CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ), + // par + //); + flg |= BCF_NORMAL; + iRet = TRUE; + //andy_edit + flg |= BATTLE_getReactFlg( defindex, react); + break; + + case BATTLE_RET_CRITICAL: + //snprintf( szBuffer, sizeof(szBuffer), + //"(%s)向(%s)CRITICAL(%d%%)(%d)不可以(%d:%d:%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // (int)(gCriper*0.01), + // damage, + // CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER ), + // CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ), + // par + //); + flg |= BCF_KAISHIN; + iRet = FALSE; + //andy_edit + flg |= BATTLE_getReactFlg( defindex, react); + break; + + } + + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_GUARD + && CHAR_getWorkInt( defindex, CHAR_WORKCONFUSION ) <= 0 + ){ + strncat( szBuffer, "(GUARD)", sizeof( szBuffer ) ); + flg |= BCF_GUARD; + iRet = FALSE; + } + + if( CHAR_getInt( defindex, CHAR_HP ) <= 0 ){ + + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_ABIO ){ + ultimate = 1; + }else + + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY + && flg & BCF_KAISHIN + ){ + if( RAND( 1, 100 ) < 50 ){ + ultimate = 1; + } + } +#ifdef _PETSKILL_LER +// 雷尔不能被打飞 + if(CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101813 || + CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101814) ultimate = 0; +#endif + iRet = FALSE; + flg |= BCF_DEATH; + + if( ultimate == 1 ){ + flg |= BCF_ULTIMATE_1; + strcat( szBuffer, "ultimate嘆" ); + } + if( ultimate == 2 ){ + flg |= BCF_ULTIMATE_2; + strcat( szBuffer, "ultimate嘇" ); + } + } + + if( damage > 0 ){ +#ifdef _TAKE_ITEMDAMAGE + if( BATTLE_ItemCrushSeq( attackindex, defindex, damage) == TRUE ){ +#else + if( BATTLE_ItemCrushSeq( defindex ) == TRUE ){ +#endif + flg |= BCF_CRUSH; + } + } +#ifdef _NOTRIDE_ + if( 0 <= Guardian && Guardian <= 19 ){ + iRet = FALSE; + flg |= BCF_GUARDIAN; + snprintf( szCommand, sizeof( szCommand ), + "a%X|f%X|d%X|g%X|", + attackNo, + flg, + damage, + Guardian ); + }else{ + snprintf( szCommand, sizeof( szCommand ), + "a%X|f%X|d%X|", + attackNo, + flg, + damage ); + } +#else + if( 0 <= Guardian && Guardian <= 19 ){ + iRet = FALSE; + flg |= BCF_GUARDIAN; + snprintf( szCommand, sizeof( szCommand ), + "a%X|f%X|d%X|p%X|g%X|", + attackNo, + flg, + damage, + petdamage, + Guardian ); + }else{ + snprintf( szCommand, sizeof( szCommand ), + "a%X|f%X|d%X|p%X|", + attackNo, + flg, + damage, + petdamage ); + } + +#endif + BATTLESTR_ADD( szCommand ); + + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + defNo = BATTLE_Index2No( battleindex, defindex ); + + if( defNo >= SIDE_OFFSET ){ + iWork = defNo - SIDE_OFFSET; + DefSide = 1; + }else{ + iWork = defNo; + } + + iWork = defNo-DefSide*SIDE_OFFSET; + if( ultimate > 0 ){ + BattleArray[battleindex].Side[DefSide].Entry[iWork].flg |= BENT_FLG_ULTIMATE; + } + + } + + return iRet; +} + + + +int BATTLE_EarthRoundHide( int battleindex, int attackNo ) +{ + //char szBuffer[512]=""; + char szCommand[1024]; + int attackindex, flg = 0 ; + + szCommand[0] = 0; + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + + sprintf( szCommand, "BF|%X|", attackNo ); + BATTLESTR_ADD( szCommand ); + + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)绕到背後去。", + // CHAR_getUseName( attackindex ) + //); + + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + CHAR_setFlg( attackindex, CHAR_ISATTACKED, 0 ); + + CHAR_setWorkInt( attackindex, CHAR_WORKBATTLECOM1, + BATTLE_COM_S_EARTHROUND0 ); + + return ( flg )?(TRUE):(FALSE); + +} + + + +BOOL BATTLE_LostEscape( int battleindex, int attackNo ) +{ + char szBuffer[512]=""; + char szCommand[1024]; + int attackindex, flg = FALSE, side, SubNo, + oyaindex, pno; + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + + if( attackNo >= SIDE_OFFSET ){ + side = 1; SubNo = attackNo - SIDE_OFFSET; + }else{ + side = 0; SubNo = attackNo; + } + + oyaindex = CHAR_getWorkInt( attackindex, CHAR_WORKPLAYERINDEX ); + + pno = CHAR_getInt( oyaindex, CHAR_DEFAULTPET ); + if( pno < 0 )return FALSE; + +#if 0 // nono宠逃走改休息 + CHAR_setCharPet( oyaindex, pno, -1); +#else + print(" nono宠改休息 "); +#endif + + BATTLE_Exit( attackindex, battleindex ); + + CHAR_setInt( oyaindex, CHAR_DEFAULTPET, -1 ); + + CHAR_AddCharm( oyaindex, CH_FIX_PETESCAPE ); + + LogPet( + CHAR_getUseName( oyaindex ), + CHAR_getUseID( oyaindex ), + CHAR_getChar( attackindex, CHAR_NAME ), + CHAR_getInt( attackindex, CHAR_LV ), +#if 0 // nono宠逃走改休息 + "EscapeLost(战斗逃走)", +#else + "EscapeLost(战斗逃走并回收)", +#endif + CHAR_getInt( oyaindex, CHAR_FLOOR ), + CHAR_getInt( oyaindex, CHAR_X ), + CHAR_getInt( oyaindex, CHAR_Y ), + CHAR_getChar( attackindex, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + + //snprintf( szBuffer, sizeof(szBuffer), "(%s)走掉了。", + // CHAR_getUseName( attackindex ) + //); + //if( getBattleDebugMsg( ) != 0 ){ + // BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + //} + + sprintf( szCommand, "BQ|e%X|", attackNo ); + BATTLESTR_ADD( szCommand ); + + snprintf( szBuffer, sizeof( szBuffer ), "K%d", pno ); + + CHAR_sendStatusString( oyaindex, szBuffer ); + + + + return ( flg )?(TRUE):(FALSE); + + +} + +BOOL BATTLE_Abduct( + int battleindex, + int attackNo, + int defNo, + int array +) +{ + //char szBuffer[512]=""; + char szCommand[1024]; +#ifdef _BATTLE_ABDUCTII + char *pszP=NULL; +#endif + int attackindex, defindex, per, flg, attackoyaindex, defoyaindex = -1; + int attacklevel, deflevel; + int Attacktype, Deftype; + BOOL iRet = FALSE; + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + defindex = BATTLE_No2Index( battleindex, defNo ); + if( CHAR_CHECKINDEX( attackindex ) == FALSE ) return iRet; + if( CHAR_CHECKINDEX( defindex ) == FALSE ) return iRet; +#ifdef _BATTLE_ABDUCTII + // 取得宠物技能命令 + pszP = PETSKILL_getChar( array, PETSKILL_OPTION ); + if( pszP == NULL ) return iRet; +#endif + + //ANDY_ReEdit + Attacktype = CHAR_getInt( attackindex, CHAR_WHICHTYPE); + if( Attacktype == CHAR_TYPEENEMY ) { + attackoyaindex = -1; + }else if( Attacktype == CHAR_TYPEPET ) { + attackoyaindex = CHAR_getWorkInt( attackindex, CHAR_WORKPLAYERINDEX ); + if( CHAR_CHECKINDEX( attackoyaindex ) == FALSE ) return iRet; + }else { + return iRet; + } + //ANDY_ReEdit + Deftype = CHAR_getInt( defindex, CHAR_WHICHTYPE ); + if( Deftype == CHAR_TYPEPET ){ + defoyaindex = CHAR_getWorkInt( defindex, CHAR_WORKPLAYERINDEX ); + if( CHAR_CHECKINDEX( defoyaindex ) == FALSE ) return iRet; + }else { + defoyaindex = -1; + } + + if( Deftype != CHAR_TYPEPLAYER ){ +#ifdef _BATTLE_ABDUCTII + int AiPer=0; + // 取得宠物技能命令 + AiPer = atoi( pszP); + if( AiPer <= 0 || Deftype != CHAR_TYPEPET ){ +#endif + attacklevel = CHAR_getInt( attackindex, CHAR_LV ); + deflevel = CHAR_getInt( defindex, CHAR_LV ); + per = ( deflevel - attacklevel ) * 0.6 + 30; + per = max( per, 50 ); +#ifdef _BATTLE_ABDUCTII + }else { + per = 0; + if( CHAR_getWorkInt( defindex, CHAR_WORKFIXAI) < AiPer ){ + per = 200; + } + } +#endif + }else{ + per = 0; + return iRet; + } + if( BattleArray[battleindex].WinFunc != NULL ){ + per = 0; + } + + iRet = TRUE; + if( RAND( 1, 100 ) < per ){ + flg = 1; + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)带着(%s)离开该处(%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // per + //); + if( Deftype == CHAR_TYPEPET ){ + BATTLE_PetDefaultExit( defoyaindex, battleindex ); + CHAR_setInt( defoyaindex, CHAR_DEFAULTPET, -1 ); + }else if( Deftype == CHAR_TYPEENEMY ) { + BATTLE_Exit( defindex, battleindex ); + } + }else{ + flg = 0; + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)无法带离(%s)一个人默默地离开(%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // per + //); + } + + //if( getBattleDebugMsg( ) != 0 ){ + // BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + //} + sprintf( szCommand, "B!|a%X|d%X|f%X|", attackNo, defNo, flg ); + BATTLESTR_ADD( szCommand ); + + //ANDY_ReEdit + if( Attacktype == CHAR_TYPEPET ) { + BATTLE_PetDefaultExit( attackoyaindex, battleindex ); + CHAR_setInt( attackoyaindex, CHAR_DEFAULTPET, -1 ); + }else { + BATTLE_Exit( attackindex, battleindex); + } + return iRet; +} +#ifdef _BATTLESTEAL_FIX +void BATTLE_StealMoney( int battleindex, int attackNo, int defNo) +{ + char szBuffer[512]=""; + char szCommand[1024]; + int attackindex, defindex, per; + int S_FLG = 0, GOLD = 0; + int LV=0; + char buf1[256]; + int masterindex; + int safeSide=0; + + if( BATTLE_CHECKINDEX( battleindex) == FALSE ) return; + attackindex = BATTLE_No2Index( battleindex, attackNo ); + if( CHAR_CHECKINDEX( attackindex ) == FALSE ) return; + defindex = BATTLE_No2Index( battleindex, defNo ); + if( CHAR_CHECKINDEX( defindex ) == FALSE ) return; + masterindex = CHAR_getWorkInt( attackindex, CHAR_WORKPLAYERINDEX ); + if( !CHAR_CHECKINDEX( masterindex ) ) return; + LV = CHAR_getInt( defindex, CHAR_LV ); + per = 0; + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ) { + if( attackNo > 10 ) { + safeSide = 1; + } + if( defNo>=safeSide*SIDE_OFFSET && defNo<((safeSide*SIDE_OFFSET)+SIDE_OFFSET)){//同边 + per = 0; + }else { //不同边 + per = 50; + per = (((per+LV)/4)+10)>>1; + } + }else if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ) { + per=5; + } + S_FLG = 0; + + + + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ) { + if( CHAR_getInt( masterindex, CHAR_GOLD) >= CHAR_getMaxHaveGold( masterindex) ) + per = 0; + } + + if( RAND( 1, 100 ) < per ){ + S_FLG = 1; + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ) { + GOLD = CHAR_getInt( defindex, CHAR_GOLD ); + GOLD = (int)( (float)GOLD * RAND( 1, 15 ) * 0.01 ); + if( (CHAR_getInt( masterindex, CHAR_GOLD) + GOLD) >= CHAR_getMaxHaveGold( masterindex) ) { + GOLD = CHAR_getMaxHaveGold( masterindex) - CHAR_getInt( masterindex, CHAR_GOLD); + } + }else { + GOLD = RAND( 10, 100); + } + if( GOLD <= 0 ){ + S_FLG = 0; + }else{ + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)从(%s)获得了(%d)STONE(%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // GOLD, + // per + // ); + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ) { + CHAR_setInt( defindex, CHAR_GOLD, CHAR_getInt( defindex, CHAR_GOLD ) - GOLD ); + CHAR_send_P_StatusString( defindex, CHAR_P_STRING_GOLD ); + } + } + }else{ + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)没从(%s)获得东西(%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // per + //); + } + sprintf( buf1, "被偷了一些石币"); + if( S_FLG) { + sprintf( szBuffer, "BK|%s%s。|", CHAR_getUseName( defindex ), buf1 ); + strcat( szBadStatusString, szBuffer ); + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + int attackoyaindex = CHAR_getWorkInt( attackindex, CHAR_WORKPLAYERINDEX ); + if( CHAR_CHECKINDEX( attackoyaindex ) == TRUE ){ + BATTLE_PetDefaultExit( attackoyaindex, battleindex ); + CHAR_setInt( attackoyaindex, CHAR_DEFAULTPET, -1 ); + { + int playergold=CHAR_getInt( attackoyaindex, CHAR_GOLD)+GOLD; + if( playergold > CHAR_getMaxHaveGold( attackoyaindex) ) playergold = CHAR_getMaxHaveGold( attackoyaindex); + CHAR_setInt( attackoyaindex, CHAR_GOLD , playergold); + CHAR_send_P_StatusString( attackoyaindex, CHAR_P_STRING_GOLD ); + } + lssproto_KS_send( getfdFromCharaIndex( attackoyaindex ), + CHAR_getInt( attackoyaindex, CHAR_DEFAULTPET ), 1 ); + } + BATTLE_Exit( attackindex, battleindex ); + }else{ + BATTLE_Exit( attackindex, battleindex ); + } + } + //if( getBattleDebugMsg( ) != 0 ) { + // BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + //} + sprintf( szCommand, "B#|a%X|d%X|f%X|", attackNo, defNo, S_FLG ); + BATTLESTR_ADD( szCommand ); +} +#endif + +void BATTLE_Steal( int battleindex, int attackNo, int defNo ) +{ + char szBuffer[512]=""; + char szCommand[1024]; + int attackindex, defindex, per, flg, i, j; + int enemytype, stealmode = 0, gold, itemindex; + int itemtbl[CHAR_MAXITEMNUM]; + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + if( CHAR_CHECKINDEX( attackindex ) == FALSE )return; + defindex = BATTLE_No2Index( battleindex, defNo ); + if( CHAR_CHECKINDEX( defindex ) == FALSE )return; + enemytype = CHAR_getInt( defindex, CHAR_WHICHTYPE ); + if( enemytype == CHAR_TYPEPLAYER ){ + per = 50; + }else{ + per = 0; + } + + if( RAND( 1, 100 ) < per ){ + flg = 1; + if( RAND( 1, 100 ) < 50 ){ + stealmode = 0; + gold = CHAR_getInt( defindex, CHAR_GOLD ); + gold = (int)( (float)gold * RAND( 8, 12 ) * 0.01 ); + if( gold <= 0 ){ + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)无法获得(%s)的STONE(%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // per + //); + flg = 0; + }else{ + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)从(%s)获得了(%d)STONE(%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // gold, + // per + //); + CHAR_setInt( defindex, CHAR_GOLD, + CHAR_getInt( defindex, CHAR_GOLD ) - gold ); + CHAR_send_P_StatusString( defindex, CHAR_P_STRING_GOLD ); + } + }else{ + stealmode = 1; + for( j = 0, i = CHAR_STARTITEMARRAY; i < CHAR_MAXITEMHAVE; i ++ ){ + itemindex = CHAR_getItemIndex( defindex, i ); + if( ITEM_CHECKINDEX( itemindex ) == TRUE ){ + itemtbl[j++] = i; + } + } + if( j <= 0 ){ + itemindex = -1; + }else{ + itemindex = -1; + i = RAND( 0, j-1 ); + if( i >= 0 ){ + if( 0 <= itemtbl[i] && itemtbl[i] < CHAR_STARTITEMARRAY ){ + fprint( "err:要盗取装备品(%d)\n", itemtbl[i] ); + }else{ + itemindex = CHAR_getItemIndex( defindex, itemtbl[i] ); + } + } + } + if( itemindex == - 1 ){ + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)无法获得(%s)的道具(%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // per + //); + flg = 0; + }else{ + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)从(%s)获得了(%s)(%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // ITEM_getAppropriateName( itemindex ), + // per + //); + CHAR_setItemIndex( defindex, itemtbl[i], -1 ); + CHAR_sendItemDataOne( defindex, itemtbl[i] ); + { + LogItem( + CHAR_getChar( defindex, CHAR_NAME ), + CHAR_getChar( defindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), +#endif + "Stealed(偷窃的道具)", + CHAR_getInt( defindex,CHAR_FLOOR), + CHAR_getInt( defindex,CHAR_X ), + CHAR_getInt( defindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + ITEM_endExistItemsOne( itemindex ); + } + } + }else{ + flg = 0; + //snprintf( szBuffer, sizeof(szBuffer), "(%s)没从(%s)获得东西(%d%%)", + // CHAR_getUseName( attackindex ), CHAR_getUseName( defindex ), per ); + } + if( flg == 1 ){ + sprintf( szBuffer, "BK|%s被偷了一些东西。|", + CHAR_getUseName( defindex ) ); + strcat( szBadStatusString, szBuffer ); + if( CHAR_getInt( attackindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + int attackoyaindex = CHAR_getWorkInt( attackindex, CHAR_WORKPLAYERINDEX ); + if( CHAR_CHECKINDEX( attackoyaindex ) == TRUE ){ + BATTLE_PetDefaultExit( attackoyaindex, battleindex ); + CHAR_setInt( attackoyaindex, CHAR_DEFAULTPET, -1 ); + }else{ + BATTLE_Exit( attackindex, battleindex ); + } + }else{ + BATTLE_Exit( attackindex, battleindex ); + } + } + //if( getBattleDebugMsg( ) != 0 ){ + // BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + //} + sprintf( szCommand, "B#|a%X|d%X|f%X|", attackNo, defNo, flg ); + BATTLESTR_ADD( szCommand ); +} + +#ifdef _PSKILL_FALLGROUND //落马术 +int BATTLE_S_FallGround( int battleindex, int attackNo, int defNo, int skill_type) +{ + char szBuffer[512]=""; + char szCommand[1024]; + int attackindex, defindex; + int damage=0, petdamage=0, i=0, iWork, Guardian=-1; + int flg = 0, DefSide=0,par,ultimate=0, react=0; + BOOL iRet = FALSE; + attackindex = BATTLE_No2Index( battleindex, attackNo ); //攻方index + defindex = BATTLE_No2Index( battleindex, defNo ); //守方index + + + if( defNo >= SIDE_OFFSET ){ + i = defNo - SIDE_OFFSET; + DefSide = 1; + } + react = 0; + react = BATTLE_GetDamageReact( defindex);//有光镜守 + //取得攻击後状态 + iWork = BATTLE_AttackSeq( attackindex, defindex, &damage, + &Guardian, BATTLE_COM_S_FALLRIDE ); + + + ultimate = BATTLE_DamageSub( attackindex, defindex, &damage, &petdamage, &react ); + if( react == BATTLE_MD_REFLEC ) defindex = attackindex; + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + if( react == BATTLE_MD_TRAP ) defindex = attackindex; +#endif +#ifdef _PETSKILL_ACUPUNCTURE + if( react == BATTLE_MD_ACUPUNCTURE ) defindex = attackindex; +#endif + if( damage > 0 && ( react != BATTLE_MD_ABSROB )&& ( react != BATTLE_MD_VANISH )){ + BATTLE_DamageWakeUp( battleindex, defindex ); + } + par = BATTLE_AttrAdjust( attackindex, defindex, 100 ); + + + + switch( iWork ){ + case BATTLE_RET_ALLGUARD: + case BATTLE_RET_MISS: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)朝向(%s)发动绝技,没击中。", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ) + //); + iRet = TRUE; + break; + case BATTLE_RET_DODGE: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)展开防御攻击(%s)躲开了(%.2f%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // gDuckPer + //); + flg |= BCF_DODGE; + iRet = TRUE; + break; + case BATTLE_RET_NORMAL: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)受到(%s)的绝技攻击(%d)损伤(%d:%d:%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // damage, + // CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER ), + // CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ), + // par + //); + //andy_edit + flg |= BATTLE_getReactFlg( defindex, react); + flg |= BCF_NORMAL; + iRet = TRUE; + break; + case BATTLE_RET_CRITICAL: + //snprintf( szBuffer, sizeof(szBuffer), + //"(%s)受到(%s)的绝技CRITICAL(%d)损伤(%d:%d:%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // damage, + // CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER ), + // CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ), + // par + //); + flg |= BCF_KAISHIN; + iRet = FALSE; + flg |= BATTLE_getReactFlg( defindex, react); + break; +#ifdef _EQUIT_ARRANGE + case BATTLE_RET_ARRANGE: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)攻击了(%s)挡掉了(%.2f%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // gDuckPer + //); + flg |= BCF_B_ARRANGE; + break; +#endif + } + + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_GUARD + && CHAR_getWorkInt( defindex, CHAR_WORKCONFUSION ) <= 0 ){ + strncat( szBuffer, "(GUARD)", sizeof( szBuffer ) ); + iRet = FALSE; + } + + if( skill_type == BATTLE_COM_S_FALLRIDE && damage > 0 && react == 0 +#ifdef _PREVENT_TEAMATTACK + && BATTLE_CheckSameSide( attackindex, defNo) == 0 +#endif + ){ //落马 + int fallflg = RAND( 0, 100); + if( +#ifdef _EQUIT_RESIST + fallflg > 50 + CHAR_getWorkInt( defindex, CHAR_WORKEQUITFALLRIDE ) +#else + fallflg > 50 +#endif + ){ + if( CHAR_getInt( defindex , CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ) { +#ifdef _FIXPETFALL //Syu ADD 修正落马术 + if( CHAR_getInt( defindex, CHAR_RIDEPET) >= 0 ) { +#else + if( CHAR_getInt( defindex, CHAR_RIDEPET) > 0 ) { +#endif + flg |= BCF_FALL; + CHAR_setInt( defindex, CHAR_RIDEPET, -1 ); + BATTLE_changeRideImage( defindex ); + CHAR_setWorkInt( defindex, CHAR_WORKPETFALL, 1 ); + } + } +#ifdef _ENEMY_FALLGROUND + else if( CHAR_getInt( defindex , CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ) { + if( CHAR_getInt( defindex, CHAR_RIDEPET) > 0 ) { + CHAR_setInt( defindex, CHAR_RIDEPET, -1 ); + BATTLE_changeRideImage( defindex ); + CHAR_setWorkInt( defindex, CHAR_WORKPETFALL, 1 ); + + CHAR_setInt( defindex, CHAR_STR, CHAR_getInt( defindex, CHAR_STR)*0.7); + CHAR_setInt( defindex, CHAR_TOUGH, CHAR_getInt( defindex, CHAR_TOUGH)*0.7); + CHAR_setInt( defindex, CHAR_VITAL, CHAR_getInt( defindex, CHAR_VITAL)*0.7); + CHAR_complianceParameter( defindex ); + if( CHAR_getInt( defindex , CHAR_HP) > CHAR_getWorkInt( defindex , CHAR_WORKMAXHP ) ) { + CHAR_setInt( defindex , CHAR_HP , CHAR_getWorkInt( defindex , CHAR_WORKMAXHP ) ); + } + } + } +#endif + } + } + + if( CHAR_getInt( defindex, CHAR_HP ) <= 0 ){ + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_ABIO ){ + ultimate = 1; + }else + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY && flg & BCF_KAISHIN ){ + if( RAND( 1, 100 ) < 50 ){ + ultimate = 1; + } + } +#ifdef _PETSKILL_LER +// 雷尔不能被打飞 + if(CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101813 || + CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101814) ultimate = 0; +#endif + iRet = FALSE; + flg |= BCF_DEATH; + if( ultimate == 1 ){ + flg |= BCF_ULTIMATE_1; + strcat( szBuffer, "ultimate嘆" ); + } + if( ultimate == 2 ){ + flg |= BCF_ULTIMATE_2; + strcat( szBuffer, "ultimate嘇" ); + } + } + if( damage > 0 ){ +#ifdef _TAKE_ITEMDAMAGE + if( BATTLE_ItemCrushSeq( attackindex, defindex, damage) == TRUE ){ +#else + if( BATTLE_ItemCrushSeq( defindex ) == TRUE ){ +#endif + flg |= BCF_CRUSH; + } + } + snprintf( szCommand, sizeof( szCommand ), "BH|a%X|r%X|f%X|d%X|p%X|FF|", + attackNo, defNo, flg, damage, petdamage ); + + BATTLESTR_ADD( szCommand ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + i = defNo-DefSide*SIDE_OFFSET; + if( ultimate > 0 ){ + BattleArray[battleindex].Side[DefSide].Entry[i].flg |= BENT_FLG_ULTIMATE; + } + + return iRet; +} +#endif +#ifdef _PETSKILL_EXPLODE +int BATTLE_S_Explode( int battleindex, int attackNo, int defNo, int skill_type) +{ + char szBuffer[512]=""; + char szCommand[1024]; + int attackindex, defindex; + int damage=0, petdamage=0, i=0, iWork, Guardian=-1; + int flg = 0, DefSide=0,par,ultimate=0, react=0; + BOOL iRet = FALSE; + attackindex = BATTLE_No2Index( battleindex, attackNo ); //攻方index + defindex = BATTLE_No2Index( battleindex, defNo ); //守方index + + if( defNo >= SIDE_OFFSET ){ + i = defNo - SIDE_OFFSET; + DefSide = 1; + } + react = 0; + react = BATTLE_GetDamageReact( defindex);//有光镜守 + //取得攻击後状态 + iWork = BATTLE_AttackSeq( attackindex, defindex, &damage, + &Guardian, BATTLE_COM_S_EXPLODE ); + + if( damage > 0 ){ + damage = ( CHAR_getInt(defindex,CHAR_HP) >> 1 ); + flg |= BCF_EXPLODE; + CHAR_setInt( attackindex, CHAR_HP ,1); + } + + ultimate = BATTLE_DamageSub( attackindex, defindex, &damage, &petdamage, &react ); + if( react == BATTLE_MD_REFLEC ) defindex = attackindex; + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + if( react == BATTLE_MD_TRAP ) defindex = attackindex; +#endif +#ifdef _PETSKILL_ACUPUNCTURE + if( react == BATTLE_MD_ACUPUNCTURE ) defindex = attackindex; +#endif + if( damage > 0 && ( react != BATTLE_MD_ABSROB )&& ( react != BATTLE_MD_VANISH )){ + BATTLE_DamageWakeUp( battleindex, defindex ); + } + par = BATTLE_AttrAdjust( attackindex, defindex, 100 ); + + switch( iWork ){ + case BATTLE_RET_ALLGUARD: + case BATTLE_RET_MISS: + iRet = TRUE; + break; + case BATTLE_RET_DODGE: + flg |= BCF_DODGE; + iRet = TRUE; + break; + case BATTLE_RET_NORMAL: + flg |= BATTLE_getReactFlg( defindex, react); + flg |= BCF_NORMAL; + iRet = TRUE; + break; + case BATTLE_RET_CRITICAL: + flg |= BCF_KAISHIN; + iRet = FALSE; + flg |= BATTLE_getReactFlg( defindex, react); + break; +#ifdef _EQUIT_ARRANGE + case BATTLE_RET_ARRANGE: + flg |= BCF_B_ARRANGE; + break; +#endif + } + + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_GUARD + && CHAR_getWorkInt( defindex, CHAR_WORKCONFUSION ) <= 0 ){ + strncat( szBuffer, "(GUARD)", sizeof( szBuffer ) ); + iRet = FALSE; + } + + if( skill_type == BATTLE_COM_S_EXPLODE && damage > 0 && react == 0 +#ifdef _PREVENT_TEAMATTACK + && BATTLE_CheckSameSide( attackindex, defNo) == 0 +#endif + ){ //落马 + int fallflg = 100;//= RAND( 0, 100); + if( +#ifdef _EQUIT_RESIST + fallflg > 50 + CHAR_getWorkInt( defindex, CHAR_WORKEQUITFALLRIDE ) +#else + fallflg > 50 +#endif + ){ + if( CHAR_getInt( defindex , CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ) { +#ifdef _FIXPETFALL //Syu ADD 修正落马术 + if( CHAR_getInt( defindex, CHAR_RIDEPET) >= 0 ) { +#else + if( CHAR_getInt( defindex, CHAR_RIDEPET) > 0 ) { +#endif + flg |= BCF_FALL; + CHAR_setInt( defindex, CHAR_RIDEPET, -1 ); + BATTLE_changeRideImage( defindex ); + CHAR_setWorkInt( defindex, CHAR_WORKPETFALL, 1 ); + } + } +#ifdef _ENEMY_FALLGROUND + else if( CHAR_getInt( defindex , CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ) { + if( CHAR_getInt( defindex, CHAR_RIDEPET) > 0 ) { + CHAR_setInt( defindex, CHAR_RIDEPET, -1 ); + BATTLE_changeRideImage( defindex ); + CHAR_setWorkInt( defindex, CHAR_WORKPETFALL, 1 ); + + CHAR_setInt( defindex, CHAR_STR, CHAR_getInt( defindex, CHAR_STR)*0.7); + CHAR_setInt( defindex, CHAR_TOUGH, CHAR_getInt( defindex, CHAR_TOUGH)*0.7); + CHAR_setInt( defindex, CHAR_VITAL, CHAR_getInt( defindex, CHAR_VITAL)*0.7); + CHAR_complianceParameter( defindex ); + if( CHAR_getInt( defindex , CHAR_HP) > CHAR_getWorkInt( defindex , CHAR_WORKMAXHP ) ) { + CHAR_setInt( defindex , CHAR_HP , CHAR_getWorkInt( defindex , CHAR_WORKMAXHP ) ); + } + } + } +#endif + } + } + + if( CHAR_getInt( defindex, CHAR_HP ) <= 0 ){ + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_ABIO ){ + ultimate = 1; + }else + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY && flg & BCF_KAISHIN ){ + if( RAND( 1, 100 ) < 50 ){ + ultimate = 1; + } + } +#ifdef _PETSKILL_LER +// 雷尔不能被打飞 + if(CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101813 || + CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101814) ultimate = 0; +#endif + iRet = FALSE; + flg |= BCF_DEATH; + if( ultimate == 1 ){ + flg |= BCF_ULTIMATE_1; + strcat( szBuffer, "ultimate嘆" ); + } + if( ultimate == 2 ){ + flg |= BCF_ULTIMATE_2; + strcat( szBuffer, "ultimate嘇" ); + } + } + if( damage > 0 ){ +#ifdef _TAKE_ITEMDAMAGE + if( BATTLE_ItemCrushSeq( attackindex, defindex, damage) == TRUE ){ +#else + if( BATTLE_ItemCrushSeq( defindex ) == TRUE ){ +#endif + flg |= BCF_CRUSH; + } + } + snprintf( szCommand, sizeof( szCommand ), "BH|a%X|r%X|f%X|d%X|p%X|FF|", + attackNo, defNo, flg, damage, petdamage ); + + BATTLESTR_ADD( szCommand ); + i = defNo-DefSide*SIDE_OFFSET; + if( ultimate > 0 ){ + BattleArray[battleindex].Side[DefSide].Entry[i].flg |= BENT_FLG_ULTIMATE; + } + + return iRet; +} +#endif + +#ifdef _PRO_BATTLEENEMYSKILL +int BATTLE_E_ENEMYREFILE( int battleindex, int attackNo, int defNo, int skill_type ) +{ + int ReceveEffect; + BOOL iRet = FALSE; + int attackindex, defindex, pow, toNo; + + toNo=-1; + attackindex = BATTLE_No2Index( battleindex, attackNo); + + if( !CHAR_CHECKINDEX( attackindex) ) return iRet; + if( CHAR_getInt( attackindex , CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ) { + int k=0, j=0, index; + int ToNoList[10]; + int l=0; + memset( ToNoList,-1, sizeof( ToNoList)); + + for( k=10;k<20;k++) { + index = BATTLE_getBattleDieIndex( battleindex, k); + if( !CHAR_CHECKINDEX( index) ) continue; + if( CHAR_getFlg( index, CHAR_ISDIE ) == TRUE ) { + ToNoList[j] = k; + j++; + } + } + if( j == 0 ) return iRet; + toNo = ToNoList[ l=RAND( 0, j-1)]; + if( toNo < 0 || toNo > 20 ) + return iRet; + for( k=0;k<10;k++) + print("\n RE[ %d. %d]", k,ToNoList[ k]); + }else if( CHAR_getInt( attackindex , CHAR_WHICHTYPE ) == CHAR_TYPEPET ) { + toNo = defNo; + }else { + return iRet; + } + if( !BATTLE_CHECKNO( toNo) ) return iRet; + ReceveEffect = SPR_fukkatu1; + defindex = BATTLE_No2Index( battleindex, toNo); + if( !CHAR_CHECKINDEX( defindex) ) return iRet; + pow = CHAR_getWorkInt( defindex, CHAR_WORKMAXHP)/2; + BATTLE_MultiRessurect( battleindex, attackNo, toNo, + pow, 0, SPR_item3, ReceveEffect ); + iRet = TRUE; + + return iRet; +} + +int BATTLE_E_ENEMYREHP( int battleindex, int attackNo, int defNo, int skill_type) +{ + BOOL iRet=FALSE; + int attackindex, defindex; + int power = 0, per = 0, HealedEffect, toNo=-1; + int kind; + + attackindex = BATTLE_No2Index( battleindex, attackNo); + if( CHAR_CHECKINDEX( attackindex ) == FALSE ) return iRet; + if( CHAR_getWorkInt( attackindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_INIT || + !CHAR_getWorkInt( attackindex, CHAR_WORKBATTLEMODE ) ){ + return iRet; + } + + if( CHAR_getInt( attackindex , CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ) { + int k=0, j=0, l, index; + int ToNoList[10]; + memset( ToNoList,-1, sizeof( ToNoList)); + for( k=10;k<20;k++) { + index = BATTLE_No2Index( battleindex, k); + if( !CHAR_CHECKINDEX( index) ) continue; + if( CHAR_getInt( index, CHAR_HP) <= 0 ) continue; + if( CHAR_getInt( index, CHAR_HP) < (CHAR_getWorkInt( index, CHAR_WORKMAXHP) *2/3)) { + ToNoList[j] = k; + j++; + } + } + if( j == 0 ) return iRet; + toNo = ToNoList[ l=RAND( 0, j-1)]; + if( toNo < 0 || toNo > 20 ) + return iRet; + for( k=0;k<10;k++) + print("\n HP[ %d. %d]", k,ToNoList[ k]); + + }else if( CHAR_getInt( attackindex , CHAR_WHICHTYPE ) == CHAR_TYPEPET ) { + toNo = defNo; + }else { + return iRet; + } + defindex = BATTLE_No2Index( battleindex, toNo); + if( CHAR_CHECKINDEX( defindex ) == FALSE ) return iRet; + + kind = 0; + power = RAND( 100, CHAR_getWorkInt( defindex, CHAR_WORKMAXHP)); + HealedEffect = SPR_heal2; + +#ifdef _CHANGEITEMUSE // Syu ADD 调整战斗中使用料理设定 + BATTLE_MultiRecovery( battleindex, attackNo, toNo, + kind, power, per, SPR_item3, HealedEffect , 0); +#else + BATTLE_MultiRecovery( battleindex, attackNo, toNo, + kind, power, per, SPR_item3, HealedEffect ); +#endif + + iRet = TRUE; + return iRet; +} + +int BATTLE_E_ENEMYHELP( int battleindex, int attackNo, int defNo, int skill_type ) +{ + BOOL iRet = FALSE; + int attackindex, enindex, array; + int Side=-1, LV, i, enemynum, PetID; + //char szBuffer[256]=""; + print("\n BATTLE_E_ENEMYHELP()"); + + attackindex = BATTLE_No2Index( battleindex, attackNo); + if( CHAR_CHECKINDEX( attackindex ) == FALSE ) return iRet; + if( CHAR_getInt( attackindex , CHAR_WHICHTYPE ) != CHAR_TYPEENEMY || + BattleArray[battleindex].type == BATTLE_TYPE_P_vs_P || + CHAR_getInt( attackindex , CHAR_HP) <= 0 ) { + return iRet; + } + + if( CHAR_getInt( attackindex , CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ) { + int k=0, index; + int ToNoList[10]; + memset( ToNoList,-1, sizeof( ToNoList)); + for( k=10;k<20;k++) { + index = BATTLE_No2Index( battleindex, k); + if( !CHAR_CHECKINDEX( index) ) { + break; + } + } + if( k == 20 ) return iRet; + } + LV = CHAR_getInt( attackindex, CHAR_LV ); + + PetID = CHAR_getInt( attackindex, CHAR_PETID ); + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + //if( ENEMY_getInt( i, ENEMY_ID ) == PetID ) + if( ENEMY_getInt( i, ENEMY_TEMPNO ) == PetID ) + break; + } + if( i == enemynum ) + return iRet; + array = i; + + Side = CHAR_getWorkInt( attackindex, CHAR_WORKBATTLESIDE ); + enindex = ENEMY_createEnemy( array, RAND( (LV*0.8), LV*1.2)); + if( !CHAR_CHECKINDEX( enindex ) ) return iRet; + if( BATTLE_NewEntry( enindex, battleindex, Side) ) { + //CHAR_setWorkInt( enindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_RESCUE ); + CHAR_setWorkInt( enindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + //snprintf( szBuffer, sizeof( szBuffer ), "(%s)加入作战。", + // CHAR_getUseName( enindex ) ); + //BATTLE_BroadCast( battleindex, szBuffer, CHAR_COLORYELLOW ); + }else { + + } + iRet = TRUE; + return iRet; + +} + +#endif + +int BATTLE_DefineAttack( int attackindex, int defindex, int iWork, + char *szBuffer, int damage, int react, int *flg) +{ + int iRet; + int par; + iRet = TRUE; + par = BATTLE_AttrAdjust( attackindex, defindex, 100 ); + switch( iWork ){ + case BATTLE_RET_ALLGUARD: + case BATTLE_RET_MISS: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)朝向(%s)发动绝技,没击中。", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ) + //); + iRet = TRUE; + break; + case BATTLE_RET_DODGE: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)展开防御攻击(%s)躲开了(%.2f%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // gDuckPer + //); + *flg |= BCF_DODGE; + iRet = TRUE; + break; + case BATTLE_RET_NORMAL: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)受到(%s)的绝技攻击(%d)损伤(%d:%d:%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // damage, + // CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER ), + // CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ), + // par + //); + + *flg |= BATTLE_getReactFlg( defindex, react); + *flg |= BCF_NORMAL; + iRet = TRUE; + break; + case BATTLE_RET_CRITICAL: + //snprintf( szBuffer, sizeof(szBuffer), + //"(%s)受到(%s)的绝技CRITICAL(%d)损伤(%d:%d:%d%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // damage, + // CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER ), + // CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ), + // par + //); + *flg |= BCF_KAISHIN; + iRet = FALSE; + *flg |= BATTLE_getReactFlg( defindex, react); + break; +#ifdef _EQUIT_ARRANGE + case BATTLE_RET_ARRANGE: + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)攻击了(%s)挡掉了(%.2f%%)", + // CHAR_getUseName( attackindex ), + // CHAR_getUseName( defindex ), + // gDuckPer + //); + *flg |= BCF_B_ARRANGE; + break; +#endif + } + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_GUARD + && CHAR_getWorkInt( defindex, CHAR_WORKCONFUSION ) <= 0 ){ + //strncat( szBuffer, "(GUARD)", sizeof( szBuffer ) ); + iRet = FALSE; + } + + return iRet; +} + +int BATTLE_DefDieType( int defindex, int iRet, int *ultimate, int *flg, char *szBuffer) +{ + + if( CHAR_getInt( defindex, CHAR_HP ) <= 0 ){ + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_ABIO ){ + *ultimate = 1; + }else + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEENEMY && *flg & BCF_KAISHIN ){ + if( RAND( 1, 100 ) < 50 ){ + *ultimate = 1; + } + } + +#ifdef _PETSKILL_LER +// 雷尔不能被打飞 + if(CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101813 || + CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101814) *ultimate = 0; +#endif + iRet = FALSE; + *flg |= BCF_DEATH; + if( *ultimate == 1 ){ + *flg |= BCF_ULTIMATE_1; + strcat( szBuffer, "ultimate嘆" ); + } + if( *ultimate == 2 ){ + *flg |= BCF_ULTIMATE_2; + strcat( szBuffer, "ultimate嘇" ); + } + } + return iRet; +} + +#ifdef _SKILL_DAMAGETOHP +int BATTLE_S_DamageToHp( int battleindex, int attackindex, int defindex, int Damage, int skill) +{ + char *pszOption; + char buf1[256]; + int A_HP=0, pHP,defi=0; + float def=0.00; + if( Damage < 1 ) return A_HP; + if( BATTLE_GetDamageReact( defindex) > 0 )//有光镜守 + return A_HP; + + pszOption = PETSKILL_getChar( skill, PETSKILL_OPTION ); + if( pszOption == NULL ) + return A_HP; + memset( buf1, 0, sizeof( buf1)); + if( getStringFromIndexWithDelim( pszOption, "|",2, buf1,sizeof( buf1)) == FALSE ) + return A_HP; + + defi = atoi( buf1); + def = ((float)defi)/100; + A_HP = (int)(Damage*def); + if( (A_HP+CHAR_getInt( attackindex, CHAR_HP)) > CHAR_getWorkInt( attackindex, CHAR_WORKMAXHP ) ){ + A_HP = CHAR_getWorkInt( attackindex, CHAR_WORKMAXHP )-CHAR_getInt( attackindex, CHAR_HP); + } + + pHP = CHAR_getInt( attackindex, CHAR_HP) + A_HP; + CHAR_setInt( attackindex, CHAR_HP, min( pHP, CHAR_getWorkInt( attackindex, CHAR_WORKMAXHP ))); + CHAR_send_P_StatusString( attackindex, CHAR_P_STRING_HP); + return A_HP; +} +#endif + +#ifdef _PETSKILL_DAMAGETOHP +int BATTLE_S_DamageToHp2( int battleindex, int attackindex, int defindex, int Damage, int skill) +{ + char *pszOption; + char buf1[256]; + int A_HP=0, pHP,defi=0; + float def=0.00; + if( Damage < 1 ) return A_HP; + if( BATTLE_GetDamageReact( defindex) > 0 )//有光镜守 + return A_HP; + + pszOption = PETSKILL_getChar( skill, PETSKILL_OPTION ); + if( pszOption == NULL ) + return A_HP; + memset( buf1, 0, sizeof( buf1)); + sprintf(buf1,"%s",pszOption); + //if( getStringFromIndexWithDelim( pszOption, "|",2, buf1,sizeof( buf1)) == FALSE ) + // return A_HP; + + defi = atoi( buf1); + def = ((float)defi)/100; + A_HP = (int)(Damage*def); + if( (A_HP+CHAR_getInt( attackindex, CHAR_HP)) > CHAR_getWorkInt( attackindex, CHAR_WORKMAXHP ) ){ + A_HP = CHAR_getWorkInt( attackindex, CHAR_WORKMAXHP )-CHAR_getInt( attackindex, CHAR_HP); + } + //print("\n伤:%d 回血:%d",Damage,A_HP); + pHP = CHAR_getInt( attackindex, CHAR_HP) + A_HP; + CHAR_setInt( attackindex, CHAR_HP, min( pHP, CHAR_getWorkInt( attackindex, CHAR_WORKMAXHP ))); + CHAR_send_P_StatusString( attackindex, CHAR_P_STRING_HP); + return A_HP; +} +#endif + +#ifdef _Skill_MPDAMAGE //BATTLE_COM_S_MPDAMAGE +int BATTLE_S_MpDamage( int battleindex, int attackindex, int defindex, int damage, int skill) +{ + char *pszOption; + char buf1[256]; + int D_MP=0,defi=0; + float def=0.00; + if( damage < 1 ) return D_MP; + if( BATTLE_GetDamageReact( defindex) > 0 )//有光镜守 + return D_MP; + if( CHAR_getInt( defindex, CHAR_WHICHTYPE) == CHAR_TYPEENEMY || + CHAR_getInt( defindex, CHAR_WHICHTYPE) == CHAR_TYPEPET ) + return D_MP; + if( CHAR_getInt( defindex, CHAR_MP) <= 0 ) return D_MP; + + pszOption = PETSKILL_getChar( skill, PETSKILL_OPTION ); + if( pszOption == NULL ) return D_MP; + memset( buf1, 0, sizeof( buf1)); + if( getStringFromIndexWithDelim( pszOption, "|",2, buf1,sizeof( buf1)) == FALSE ) + return D_MP; + defi = atoi( buf1); + def = ((float)defi)/100; + D_MP = (int)(CHAR_getInt( defindex, CHAR_MP)*def); + CHAR_setInt( defindex, CHAR_MP, ( CHAR_getInt( defindex, CHAR_MP) - D_MP) ); + CHAR_send_P_StatusString( defindex, CHAR_P_STRING_MP); + return D_MP; +} +#endif +#ifdef _SKILL_TOOTH +void BATTLE_S_ToothCrushe( int battleindex, int attackindex, int defindex, int damage, int skill) +{ + int crushindex, itemindex; //aszCrushTbl + //char *strCrushTbl[] = { "完好", "受损", "毁坏" , "不堪使用" , "碎片" }; + if( CHAR_getInt( defindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ) + return; +#ifdef _TAKE_ITEMDAMAGE + if( ( crushindex = BATTLE_ItemCrushCheck( defindex, 1) ) >= 0 ) { + int crushenum, maxcrushenum, level=0; + float def=0.00; + itemindex = CHAR_getItemIndex( defindex, crushindex ); + if( ITEM_CHECKINDEX(itemindex) == FALSE ) return; + crushenum = ITEM_getInt( itemindex, ITEM_DAMAGECRUSHE); + maxcrushenum = ITEM_getInt( itemindex, ITEM_MAXDAMAGECRUSHE); + if( maxcrushenum < 1 ) return; + def = ((float)crushenum/maxcrushenum); + if( def >= 1 ) { + level = 1; + def = 0.70; + }else if( def >= 0.50 ){ + level = 2; + def = 0.30; + }else if( def >= 0.30 ){ + level = 3; + def = 0.10; + }else{ + def = 0.00; + } + crushenum = (int)((float)maxcrushenum*def); + ITEM_setInt( itemindex, ITEM_DAMAGECRUSHE, crushenum); + + if( crushenum <= 0 ) { + char buf2[256]; + sprintf(buf2, "%s因过度损坏而消失。\n", ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( defindex, -1, buf2, CHAR_COLORYELLOW); + + LogItem( + CHAR_getChar( defindex, CHAR_NAME ), + CHAR_getChar( defindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), +#endif + "因过度损坏而消失", + CHAR_getInt( defindex,CHAR_FLOOR), + CHAR_getInt( defindex,CHAR_X ), + CHAR_getInt( defindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + + CHAR_setItemIndex( defindex, crushindex ,-1); + ITEM_endExistItemsOne( itemindex); + + }else { + char buf2[256]; + sprintf( buf2, "%s是%s的。", ITEM_getChar( itemindex, ITEM_NAME ), aszCrushTbl[level] ); + CHAR_talkToCli( defindex, -1, buf2, CHAR_COLORYELLOW); + //更改道具说明 +// buf1 = ITEM_getChar( itemindex, ITEM_SECRETNAME); +// if( strstr( buf1, "(") != 0 ) { +// char buf5[256]; +// if( getStringFromIndexWithDelim( buf1,"(",1, buf5, sizeof( buf5)) != FALSE ) { +// sprintf( buf1, buf5); +// } +// } +// sprintf( buf2, "%s(%s)", buf1, aszCrushTbl[level]); +// ITEM_setChar( itemindex, ITEM_SECRETNAME, buf2); + ITEM_setInt( itemindex, ITEM_CRUSHLEVEL, level); + } + CHAR_sendItemDataOne( defindex, crushindex ); + CHAR_complianceParameter( defindex ); + CHAR_send_P_StatusString( defindex, CHAR_P_STRING_ATK | CHAR_P_STRING_DEF + | CHAR_P_STRING_QUICK | CHAR_P_STRING_CHARM ); + + } +#endif +} +#endif + +#ifdef _PSKILL_MODIFY +void BATTLE_S_Modifyattack( int battleindex, int attackindex, int defindex, int *damage, int skill) +{ + int i; + char *pszOption=NULL; + int array = skill; + char buf1[256], buf2[256]; + float def=0.00; + struct tagModKind{ + char szModKind[36]; + int Kind; + }KModKind[5] = { + { "EA", CHAR_EARTHAT}, { "WA", CHAR_WATERAT}, + { "FI", CHAR_FIREAT} , { "WI", CHAR_WINDAT}, + { "ALL",100} + }; + + + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + if( pszOption == NULL ) return; + if( getStringFromIndexWithDelim( pszOption, "|", 1, buf1, sizeof( buf1)) == FALSE ) + return; + + if( getStringFromIndexWithDelim( pszOption, "|", 2, buf2, sizeof( buf1)) == FALSE ) + return; + def = ((float)(atoi( buf2))/100); + + for( i=0; i< 4; i++) { + int ModNum=0; + if( strcmp( KModKind[i].szModKind , buf1)) continue; + if( (ModNum = CHAR_getInt( defindex, KModKind[i].Kind )) > 0 ) { + def += (float)((rand()%(ModNum+5))/100); + *damage += *damage * def; + break; + } + } +} +#endif + +#ifdef _PETSKILL_PROPERTY +int BATTLE_S_PetSkillProperty( int battleindex, int attackNo, int skill_type, int skill) +{ + int attackindex; + BOOL iRet = FALSE; + char *pszP=NULL; + + pszP = PETSKILL_getChar( skill, PETSKILL_OPTION ); + if( pszP == NULL ) return iRet; + + + attackindex = BATTLE_No2Index( battleindex, attackNo ); //攻方index + if( !CHAR_CHECKINDEX( attackindex)) return iRet; + switch( skill_type){ + case BATTLE_COM_S_PROPERTYSKILL: + { + Char *ch; + ch = CHAR_getCharPointer( attackindex); + if( ch == NULL ) return iRet; + strcpysafe( ch->charfunctable[CHAR_BATTLEPROPERTY].string, + sizeof( ch->charfunctable[CHAR_BATTLEPROPERTY]), pszP);//战斗 + CHAR_constructFunctable( attackindex); + iRet = TRUE; + } + break; + } + return iRet; +} +#endif + +int BATTLE_S_AttackDamage( int battleindex, int attackNo, int defNo, int skill_type, int skill) +{ + char szBuffer[512]=""; + char szCommand[1024]; + int attackindex, defindex; + int damage=0, petdamage=0, i=0, iWork, Guardian=-1,react; + int flg = 0, DefSide=0,ultimate=0; + int otherdamage=0; + BOOL iRet = FALSE; + int ReactType = 0; + + char *pszP=NULL; + pszP = PETSKILL_getChar( skill, PETSKILL_OPTION ); + if( pszP == NULL ) return iRet; + + react = 0; + attackindex = BATTLE_No2Index( battleindex, attackNo ); //攻方index + defindex = BATTLE_No2Index( battleindex, defNo ); //守方index + if( (ReactType=BATTLE_GetDamageReact( defindex)) > 0 ) { //有光镜守 + react = ReactType; +#ifdef _BATTLE_LIGHTTAKE + if( skill_type == BATTLE_COM_S_LIGHTTAKE ){ + int Statustype = -2; + if( strstr( pszP, "VANISH") != 0 ) Statustype = BATTLE_MD_VANISH; + else if( strstr( pszP, "ABSROB") != 0 ) Statustype = BATTLE_MD_ABSROB; + else if( strstr( pszP, "REFLEC") != 0 ) Statustype = BATTLE_MD_REFLEC; + if( ReactType == Statustype ){ + react=0; + }else{ + skill_type=-1; + } + }else{ + skill_type=-1; + } +#else + skill_type=-1; +#endif + } + + if( defNo >= SIDE_OFFSET ){ + i = defNo - SIDE_OFFSET; + DefSide = 1; + } + + //取得攻击後状态 + iWork = BATTLE_AttackSeq( attackindex, defindex, &damage, &Guardian, skill_type ); + + switch( skill_type){ +#ifdef _PSKILL_MODIFY + case BATTLE_COM_S_MODIFYATT: + if( damage > 0 ){ + BATTLE_S_Modifyattack( battleindex, attackindex, defindex, &damage, skill); + } + break; +#endif +#ifdef _PETSKILL_TEAR + case BATTLE_COM_S_PETSKILLTEAR: +#ifdef _PREVENT_TEAMATTACK + if( BATTLE_CheckSameSide( attackindex, defNo) == 1 ){ + }else +#endif + if( iWork != BATTLE_RET_DODGE && react == 0 ){ + int userhp=0, petindex; + float def=0; + userhp = CHAR_getWorkInt( defindex, CHAR_WORKMAXHP) - CHAR_getInt( defindex, CHAR_HP); + if( CHAR_getInt( defindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER && + (petindex = BATTLE_getRidePet( defindex )) != -1 ){ + userhp += CHAR_getWorkInt( petindex, CHAR_WORKMAXHP) - CHAR_getInt( petindex, CHAR_HP); + } + def = ((float)atoi( pszP))/100; + userhp = userhp * def; + if( userhp <= 0 ) damage = 0; + else damage += userhp; + } + break; +#endif + } + ultimate = BATTLE_DamageSub( attackindex, defindex, &damage, &petdamage, &react); + + if( react == BATTLE_MD_REFLEC ) defindex = attackindex; + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + if( react == BATTLE_MD_TRAP ) defindex = attackindex; +#endif + +#ifdef _PETSKILL_ACUPUNCTURE + if( react == BATTLE_MD_ACUPUNCTURE ) defindex = attackindex; +#endif + + if( damage > 0 && ( react != BATTLE_MD_ABSROB )&& ( react != BATTLE_MD_VANISH )){ + BATTLE_DamageWakeUp( battleindex, defindex ); + } + iRet = BATTLE_DefineAttack( attackindex, defindex, iWork, szBuffer, damage, react, &flg); + if( CHAR_getInt( defindex, CHAR_HP ) <= 0 ) + iRet = BATTLE_DefDieType( defindex, iRet, &ultimate, &flg, szBuffer); +#ifdef _PETSKILL_ANTINTER + //强制将死掉的宠打飞 + if( CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_ANTINTER + && CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + ultimate = 2; + flg &= (!BCF_ULTIMATE_1); + flg |= BCF_DEATH; + flg |= BCF_ULTIMATE_2; + CHAR_setWorkInt( defindex, CHAR_WORKULTIMATE, 0 ); + damage=1;//因後面有判断若 damage<=0 则 skill_type=-1 所以这里damage设为1 + } +#endif + + if( damage > 0 ){ +#ifdef _TAKE_ITEMDAMAGE + if( BATTLE_ItemCrushSeq( attackindex, defindex, damage) == TRUE ){ +#else + if( BATTLE_ItemCrushSeq( defindex ) == TRUE ){ +#endif + flg |= BCF_CRUSH; + } + } + + if( damage <= 0 ) { +#ifdef _SONIC_ATTACK // WON ADD 音波攻击 + if( skill_type != BATTLE_COM_S_SONIC && skill_type != BATTLE_COM_S_SONIC2 +#ifdef _PETSKILL_REGRET + && skill_type != BATTLE_COM_S_REGRET && skill_type != BATTLE_COM_S_REGRET2 +#endif + ) +#endif + skill_type=-1; + } + + + + + memset( szCommand, 0, sizeof( szCommand)); + switch( skill_type) { + case -1: + snprintf( szCommand, sizeof( szCommand ), "BH|a%X|r%X|f%X|d%X|p%X|FF|", + attackNo, defNo, flg, damage, petdamage ); + BATTLESTR_ADD( szCommand ); + break; + +#ifdef _PETSKILL_TEAR + case BATTLE_COM_S_PETSKILLTEAR: + snprintf( szCommand, sizeof( szCommand ), "BH|a%X|r%X|f%X|d%X|p%X|FF|", + attackNo, defNo, flg, damage, petdamage ); + BATTLESTR_ADD( szCommand ); + break; +#endif + +#ifdef _SKILL_DAMAGETOHP + case BATTLE_COM_S_DAMAGETOHP: + otherdamage = BATTLE_S_DamageToHp( battleindex, attackindex, defindex,damage+petdamage, skill); + snprintf( szCommand, sizeof( szCommand ), "Bh|a%X|r%X|f%X|d%X|p%X|j%X|FF|", + attackNo, defNo, flg, damage, petdamage, otherdamage); + BATTLESTR_ADD( szCommand ); + break; +#endif + +#ifdef _PETSKILL_DAMAGETOHP + case BATTLE_COM_S_DAMAGETOHP2: + otherdamage = BATTLE_S_DamageToHp2( battleindex, attackindex, defindex,damage+petdamage, skill); + snprintf( szCommand, sizeof( szCommand ), "Bh|a%X|r%X|f%X|d%X|p%X|j%X|FF|", + attackNo, defNo, flg, damage, petdamage, otherdamage); + BATTLESTR_ADD( szCommand ); + break; +#endif + +#ifdef _Skill_MPDAMAGE + case BATTLE_COM_S_MPDAMAGE: + otherdamage = BATTLE_S_MpDamage( battleindex, attackindex, defindex, damage, skill); + snprintf( szCommand, sizeof( szCommand ), "Bp|a%X|r%X|f%X|d%X|p%X|j%X|FF|", + attackNo, defNo, flg, damage, petdamage, otherdamage); + BATTLESTR_ADD( szCommand ); + break; +#endif + +#ifdef _SKILL_TOOTH + case BATTLE_COM_S_TOOTHCRUSHE: // 齿术 tooth + flg |= BCF_TOOTH; + BATTLE_S_ToothCrushe( battleindex, attackindex, defindex, damage, skill); + snprintf( szCommand, sizeof( szCommand ), "BH|a%X|r%X|f%X|d%X|p%X|FF|", + attackNo, defNo, flg, damage, petdamage ); + BATTLESTR_ADD( szCommand ); + break; +#endif + +#ifdef _PSKILL_MDFYATTACK + case BATTLE_COM_S_MDFYATTACK: + flg |= BCF_MODIFY; + snprintf( szCommand, sizeof( szCommand ), "BH|a%X|r%X|f%X|d%X|p%X|g%X|FF|", + attackNo, defNo, flg, damage, petdamage, skill); + BATTLESTR_ADD( szCommand ); + break; +#endif +#ifdef _PSKILL_MODIFY + case BATTLE_COM_S_MODIFYATT: + flg |= BCF_ATTDOUBLE; + snprintf( szCommand, sizeof( szCommand ), "BH|a%X|r%X|f%X|d%X|p%X|g%X|FF|", + attackNo, defNo, flg, damage, petdamage, skill); + BATTLESTR_ADD( szCommand ); + break; +#endif + +#ifdef _PETSKILL_TIMID + case BATTLE_COM_S_TIMID: + { + int timid = rand()%100; + snprintf( szCommand, sizeof( szCommand ), "BH|a%X|r%X|f%X|d%X|p%X|FF|", + attackNo, defNo, flg, damage, petdamage ); + BATTLESTR_ADD( szCommand ); + if( timid < 15 && damage > 1 ){//怯战 + BATTLE_NoAction( battleindex, defNo ); + sprintf( szCommand, "BE|e%X|", defNo ); + BATTLESTR_ADD( szCommand ); + snprintf( szCommand, sizeof( szCommand ), "f%X|", 1); + BATTLESTR_ADD( szCommand ); + + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + int defkoyaindex = CHAR_getWorkInt( defindex, CHAR_WORKPLAYERINDEX ); +#ifdef _PETS_SELECTCON + lssproto_PETS_send( getfdFromCharaIndex(defkoyaindex), + CHAR_getInt( defkoyaindex, CHAR_DEFAULTPET), FALSE); + CHAR_setWorkInt( defkoyaindex, + CHAR_WORK_PET0_STAT+CHAR_getInt( defkoyaindex, CHAR_DEFAULTPET), FALSE); +#endif + BATTLE_PetDefaultExit( defkoyaindex, battleindex ); + CHAR_setInt( defkoyaindex, CHAR_DEFAULTPET, -1 ); + + }else { + BATTLE_Exit( defindex, battleindex); + CHAR_DischargePartyNoMsg( defindex);//解散团队 + } + } + } + break; +#endif +#ifdef _PETSKILL_2TIMID + case BATTLE_COM_S_2TIMID: + { + int timid=0; + char *timidc=NULL; + pszP = PETSKILL_getChar( skill, PETSKILL_OPTION ); + if( ( timidc = strstr( pszP, "命%" ) ) != NULL ) + sscanf( timidc+3,"%d", &timid ); + snprintf( szCommand, sizeof( szCommand ), "BH|a%X|r%X|f%X|d%X|p%X|FF|", + attackNo, defNo, flg, damage, petdamage ); + BATTLESTR_ADD( szCommand ); + if( rand()%100 < timid && damage > 1 ){ + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + int defkoyaindex = CHAR_getWorkInt( defindex, CHAR_WORKPLAYERINDEX ); + + snprintf( szCommand, sizeof( szCommand ), "K%d", CHAR_getInt( defkoyaindex, CHAR_DEFAULTPET ) ); + CHAR_sendStatusString( defkoyaindex, szCommand ); + + BATTLE_PetIn( battleindex, defNo-5 ); + lssproto_KS_send( getfdFromCharaIndex( defkoyaindex ), CHAR_getInt( defkoyaindex, CHAR_DEFAULTPET ), 1 ); + + /*BATTLE_NoAction( battleindex, defNo ); + sprintf( szCommand, "BE|e%X|", defNo ); + BATTLESTR_ADD( szCommand ); + snprintf( szCommand, sizeof( szCommand ), "f%X|", 1); + BATTLESTR_ADD( szCommand ); + + BATTLE_PetDefaultExit( defkoyaindex, battleindex ); + CHAR_setInt( defkoyaindex, CHAR_DEFAULTPET, -1 ); + + print("\ndefNo:%d",defNo);*/ + } + } + } + break; +#endif + +#ifdef _PETSKILL_ANTINTER + case BATTLE_COM_S_ANTINTER: + { + pszP = PETSKILL_getChar( skill, PETSKILL_OPTION ); + //flg &= !(BCF_ULTIMATE_1 | BCF_ULTIMATE_2); + snprintf( szCommand, sizeof( szCommand ), "BH|a%X|r%X|f%X|d%X|p%X|FF|", + attackNo, defNo, flg |= BCF_ANTINTER , 0, 0 ); + BATTLESTR_ADD( szCommand ); + if( CHAR_getInt( defindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + int defkoyaindex = CHAR_getWorkInt( defindex, CHAR_WORKPLAYERINDEX ); + BATTLE_PetDefaultExit( defkoyaindex, battleindex );//宠物离开战场 + CHAR_setInt( defkoyaindex, CHAR_DEFAULTPET, -1 );//设定无参战宠物 + } + } + break; +#endif + +#ifdef _BATTLE_LIGHTTAKE + case BATTLE_COM_S_LIGHTTAKE: + { + int Typenum = 0; + if( strstr( pszP, "VANISH") != 0 ){ + if( ReactType == BATTLE_MD_VANISH ){ + Typenum = CHAR_getWorkInt( defindex, CHAR_WORKDAMAGEVANISH ); + CHAR_setWorkInt( attackindex, CHAR_WORKDAMAGEVANISH, Typenum); + } + }else if( strstr( pszP, "ABSROB") != 0 ){ + if( ReactType == BATTLE_MD_ABSROB ){ + Typenum = CHAR_getWorkInt( defindex, CHAR_WORKDAMAGEABSROB ); + CHAR_setWorkInt( attackindex, CHAR_WORKDAMAGEABSROB, Typenum); + } + }else if( strstr( pszP, "REFLEC") != 0 ){ + if( ReactType == BATTLE_MD_REFLEC ){ + Typenum = CHAR_getWorkInt( defindex, CHAR_WORKDAMAGEREFLEC ); + CHAR_setWorkInt( attackindex, CHAR_WORKDAMAGEREFLEC, Typenum); + } + } + snprintf( szCommand, sizeof( szCommand ), "BH|a%X|r%X|f%X|d%X|p%X|FF|", + attackNo, defNo, flg, damage, petdamage ); + BATTLESTR_ADD( szCommand ); + } + break; +#endif + +#ifdef _SONIC_ATTACK // WON ADD 音波攻击 + // 宠物伤害 + case BATTLE_COM_S_SONIC: + { + int img2=0; + if( defNo >= 10 ) img2 = 101703; + else img2 = 101704; + + flg |= BCF_B_SKILLACT; //击中後秀图 + + snprintf( szCommand, sizeof( szCommand ), "B+|a%X|r%X|f%X|d%X|e%X|s%X|h%X|FF|", + attackNo, defNo, flg, damage, 0, 0, img2 ); + BATTLESTR_ADD( szCommand ); + + break; + } + // 人物伤害 + case BATTLE_COM_S_SONIC2: + { + sprintf( szCommand, "BD|r%X|0|0|d%X|p%X|", defNo, damage, petdamage ); + BATTLESTR_ADD( szCommand ); + + break; + } +#endif +#ifdef _PETSKILL_REGRET + // 宠物伤害 + case BATTLE_COM_S_REGRET: + { + int img2=0,Success=0; + char *psz = NULL; + if( (psz = strstr( pszP, "命%" ) ) != NULL ) sscanf( psz+3, "%d", &Success ); + if( (PROFESSION_BATTLE_StatusAttackCheck( attackindex, defindex, 12, Success ) == 0 ) + || (CHAR_getInt( defindex, CHAR_HP ) <= 0 ) ){ + + }else{ + CHAR_setWorkInt( defindex, StatusTbl[12], 2 );//晕眩1回合 + CHAR_setWorkInt( defindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + BATTLE_BadStatusString( defNo, 12 ); + } + + if( defNo >= 10 ) img2 = 101418;//101703; + else img2 = 101418;//101704; + + flg |= BCF_B_SKILLACT; //击中後秀图 + snprintf( szCommand, sizeof( szCommand ), "B+|a%X|r%X|f%X|d%X|e%X|s%X|h%X|FF|", + attackNo, defNo, flg, damage, 0, 0, img2 ); + BATTLESTR_ADD( szCommand ); + break; + } + // 人物伤害 + case BATTLE_COM_S_REGRET2: + { + int Success; + char *psz = NULL; + if( (psz = strstr( pszP, "命%" ) ) != NULL ) sscanf( psz+3, "%d", &Success ); + if( (PROFESSION_BATTLE_StatusAttackCheck( attackindex, defindex, 12, Success ) == 0 ) + || (CHAR_getInt( defindex, CHAR_HP ) <= 0 ) ){ + + }else{ + CHAR_setWorkInt( defindex, StatusTbl[12], 2 );//晕眩1回合 + CHAR_setWorkInt( defindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + BATTLE_BadStatusString( defNo, 12 ); + } + + sprintf( szCommand, "BD|r%X|0|0|d%X|p%X|", defNo, damage, petdamage ); + BATTLESTR_ADD( szCommand ); + break; + } +#endif + + default: + snprintf( szCommand, sizeof( szCommand ), "BH|a%X|r%X|f%X|d%X|p%X|FF|", + attackNo, defNo, flg, damage, petdamage ); + BATTLESTR_ADD( szCommand ); + break; + } + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + i = defNo-DefSide*SIDE_OFFSET; + if( ultimate > 0 ){ + BattleArray[battleindex].Side[DefSide].Entry[i].flg |= BENT_FLG_ULTIMATE; + } + return iRet; +} + +#ifdef _MAGIC_SUPERWALL +int PETSKILL_MagicStatusChange_Battle( int battleindex, int attackNo, int toNo, int marray) +{ + char *magicarg; + int status = -1, i, turn = 3, nums=0; + int ReceveEffect, charaindex=-1; + char buf1[256]; + charaindex = BATTLE_No2Index( battleindex, attackNo ); //攻方index + if( !CHAR_CHECKINDEX( charaindex)) return FALSE; + magicarg = PETSKILL_getChar( marray, PETSKILL_OPTION ); + if( getStringFromIndexWithDelim( magicarg,"|",1, buf1, sizeof( buf1)) == FALSE ) + return FALSE; + for( i=0; i= 20 ) + return FALSE; + } + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + //attackNo = BATTLE_Index2No( battleindex, charaindex ); +/* //动画图号决定 + if( status == BATTLE_ST_NONE ){ + ReceveEffect = SPR_tyusya; + }else{ + ReceveEffect = SPR_hoshi; + } +*/ + ReceveEffect = SPR_hoshi; + BATTLE_MultiMagicStatusChange( + battleindex, attackNo, toNo, status, + turn, MAGIC_EFFECT_USER, ReceveEffect, nums ); + + return TRUE; +} +#endif + +#ifdef _PETSKILL_SETDUCK +int PETSKILL_SetDuckChange_Battle( int battleindex, int attackNo, int toNo, int marray) +{ + char *skillarg=NULL; + int turn = 3, nums=0; + int charaindex=-1; + char buf1[256]; + + charaindex = BATTLE_No2Index( battleindex, attackNo ); //攻方index + if( !CHAR_CHECKINDEX( charaindex)) return FALSE; + if( BATTLE_No2Index( battleindex, toNo ) != charaindex ) return FALSE; + + skillarg = PETSKILL_getChar( marray, PETSKILL_OPTION ); + if( skillarg == NULL ) return FALSE; + if( getStringFromIndexWithDelim( skillarg,"|",1, buf1, sizeof( buf1)) == FALSE ) + return FALSE; + turn = atoi( buf1); + if( getStringFromIndexWithDelim( skillarg,"|",2, buf1, sizeof( buf1)) == FALSE ) + return FALSE; + nums = atoi( buf1); + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + { + int ToList[SIDE_OFFSET*2+1]; + char szBuffer[256]=""; + memset( szBuffer, 0, sizeof( szBuffer)); + memset( ToList, -1, sizeof( ToList)); + BATTLE_MultiList( battleindex, toNo, ToList ); + BATTLE_MagicEffect( battleindex, attackNo, ToList, MAGIC_EFFECT_USER, SPR_hoshi ); + if( CHAR_getWorkInt( charaindex, CHAR_MYSKILLDUCK) > 0){ + }else { + CHAR_setWorkInt( charaindex, CHAR_MYSKILLDUCK, turn); + CHAR_setWorkInt( charaindex, CHAR_MYSKILLDUCKPOWER, nums ); + sprintf( szBuffer, "BD|r%X|0|3|%X|", toNo, nums); + BATTLESTR_ADD( szBuffer ); + } + } + return TRUE; +} +#endif + +#ifdef _MAGICPET_SKILL +int PETSKILL_SetMagicPet_Battle( int battleindex, int attackNo, int toNo, int marray) +{ + char *skillarg=NULL; + int turn = 3, nums=0; + int charaindex=-1; + char buf1[256]; + + charaindex = BATTLE_No2Index( battleindex, attackNo ); //攻方index + if( !CHAR_CHECKINDEX( charaindex)) return FALSE; + if( BATTLE_CHECKINDEX( battleindex ) == FALSE ) return FALSE; + + skillarg = PETSKILL_getChar( marray, PETSKILL_OPTION ); + if( skillarg == NULL ) return FALSE; + if( getStringFromIndexWithDelim( skillarg,"|",1, buf1, sizeof( buf1)) == FALSE ) + return FALSE; + turn = atoi( buf1); + if( getStringFromIndexWithDelim( skillarg,"|",2, buf1, sizeof( buf1)) == FALSE ) + return FALSE; + nums = atoi( buf1); + if( getStringFromIndexWithDelim( skillarg,"|",3, buf1, sizeof( buf1)) == FALSE ) + return FALSE; + if( strstr( buf1, "HP") != 0 ) { +#ifdef _CHANGEITEMUSE // Syu ADD 调整战斗中使用料理设定 + BATTLE_MultiRecovery( battleindex, attackNo, toNo, + BD_KIND_HP, nums, 0, MAGIC_EFFECT_USER, SPR_heal3 , 0); +#else + BATTLE_MultiRecovery( battleindex, attackNo, toNo, + BD_KIND_HP, nums, 0, MAGIC_EFFECT_USER, SPR_heal3 ); +#endif + }else{ + int ToList[SIDE_OFFSET*2+1]; + char szBuffer[256]=""; + int todef=0, i; + + memset( szBuffer, 0, sizeof( szBuffer)); + memset( ToList, -1, sizeof( ToList)); + BATTLE_MultiList( battleindex, toNo, ToList ); + BATTLE_MagicEffect( battleindex, attackNo, ToList, MAGIC_EFFECT_USER, SPR_hoshi ); + + for( i = 0; ToList[i] != -1; i ++ ){ + int bid; + int toindex = BATTLE_No2Index( battleindex, ToList[i] ); + if( !CHAR_CHECKINDEX( toindex ))continue; + + if( CHAR_getWorkInt( toindex, CHAR_MYSKILLDUCK) > 0 || + CHAR_getWorkInt( toindex, CHAR_MYSKILLSTR) > 0 || + CHAR_getWorkInt( toindex, CHAR_MYSKILLTGH) > 0 || + CHAR_getWorkInt( toindex, CHAR_MYSKILLDEX) > 0 ) continue; + + if( strstr( buf1, "STR") != 0 ) { + CHAR_setWorkInt( toindex, CHAR_MYSKILLSTR, turn); + CHAR_setWorkInt( toindex, CHAR_MYSKILLSTRPOWER, nums ); + todef = 4; + }else if( strstr( buf1, "TGH") != 0 ){ + CHAR_setWorkInt( toindex, CHAR_MYSKILLTGH, turn); + CHAR_setWorkInt( toindex, CHAR_MYSKILLTGHPOWER, nums ); + todef = 5; + }else if( strstr( buf1, "DEX") != 0 ){ + CHAR_setWorkInt( toindex, CHAR_MYSKILLDEX, turn); + CHAR_setWorkInt( toindex, CHAR_MYSKILLDEXPOWER, nums ); + todef = 6; + } + bid = BATTLE_Index2No( battleindex, toindex ); + sprintf( szBuffer, "BD|r%X|0|%d|%X|", bid, todef, nums); + BATTLESTR_ADD( szBuffer ); + } + } + return TRUE; +} +#endif + +#ifdef _SKILL_WEAKEN //vincent宠技:虚弱 +int BATTLE_S_Weaken( + int battleindex, + int attackNo, + int defNo, + int marray +) +{ + BOOL iRet = FALSE; + char *magicarg; + int status = -1, i, turn = 3; + int ReceveEffect, Success = 0; + char *pszP; + char szTurn[] = "turn"; + char szSuccess[] = "成"; + magicarg = PETSKILL_getChar( marray, PETSKILL_OPTION ); + if( magicarg == NULL ) { + print("\n magicarg == NULL "); + return FALSE; + } + pszP = magicarg; + + for( ;status == -1 && pszP[0] != 0; pszP++ ){ + for( i = 1; i < BATTLE_ST_END; i ++ ){ + if( strncmp( pszP, aszStatus[i], 2 ) == 0 ){ + status = i; + pszP +=2; + break; + } + } + } + + if( status == -1 ) return FALSE; + + if( ( pszP = strstr( pszP, szTurn ) ) != NULL){ + pszP += sizeof( szTurn ); + sscanf( pszP, "%d", &turn ); + } + + if( ( pszP = strstr( pszP, szSuccess ) ) != NULL){ + pszP += sizeof( szSuccess ); + sscanf( pszP, "%d", &Success ); + } + + if( status == BATTLE_ST_NONE ){ + ReceveEffect = SPR_tyusya; + }else{ + ReceveEffect = SPR_hoshi; + } + BATTLE_MultiParamChangeTurn( battleindex, attackNo, defNo, status, + MAGIC_EFFECT_USER, ReceveEffect, turn, Success); + + return iRet; +} +#endif + +#ifdef _PETSKILL_TEMPTATION +BOOL BATTLE_S_Temptation( int battleindex,int attackNo,int defNo, int skill ) +{ + BOOL iRet = FALSE; + char *magicarg; + char szWork[256]; + int attackindex,defindex,defside,flg=0,img2,img1; + int target; + + magicarg = PETSKILL_getChar( skill , PETSKILL_OPTION ); + if( magicarg == NULL ) { + print("\n magicarg == NULL "); + return iRet; + } + attackindex = BATTLE_No2Index( battleindex, attackNo ); + defindex = BATTLE_No2Index( battleindex, defNo ); + if( CHAR_CHECKINDEX( attackindex ) == FALSE )return iRet; + if( CHAR_CHECKINDEX( defindex ) == FALSE )return iRet; + if( CHAR_getInt( defindex, CHAR_WHICHTYPE) != CHAR_TYPEPET ) return iRet; + if( CHAR_getWorkInt( defindex , CHAR_WORKFIXAI ) <= atoi(magicarg)){ + //技能攻击 + CHAR_setWorkInt( defindex, CHAR_WORKTEMPTATION , 1 ); //用来解除打自己方1滴血的限制 + defside = CHAR_getWorkInt( defindex, CHAR_WORKBATTLESIDE); + target = CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM2 ); + + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_ATTACK ){ + CHAR_setWorkInt( defindex , CHAR_WORKBATTLECOM2, + BATTLE_DefaultAttacker(battleindex,defside)); + }else{ + CHAR_setWorkInt( defindex , CHAR_WORKBATTLECOM2, + BATTLE_DefaultAttacker(battleindex,defside)); + } + img1 = 101505; //珠珠动画101637; //准备期动画 + img2 = 101502; //珠珠动画101645; //击中後动画 + flg |= BCF_NO_DAMAGE; + flg |= BCF_B_SKILLACT; //击中後秀图 + snprintf( szWork, sizeof( szWork ), "B+|a%X|r%X|f%X|d%X|p%X|e%X|s%X|h%X|FF|", + attackNo, defNo, flg, 0, 0, 1 , img1 , img2 ); + BATTLESTR_ADD( szWork ); + iRet = TRUE; + } + return iRet; + +} +#endif + +#ifdef _SKILL_DEEPPOISON //vincent宠技:剧毒 +int BATTLE_S_Deeppoison( int battleindex, int attackNo, int defNo, int marray ) +{ + BOOL iRet = FALSE; + char *magicarg; + int status = -1, i, turn = 3; + int ReceveEffect, Success = 0; + char *pszP; + char szTurn[] = "turn"; + char szSuccess[] = "成"; + magicarg = PETSKILL_getChar( marray, PETSKILL_OPTION ); + if( magicarg == NULL ) { + print("\n magicarg == NULL "); + return FALSE; + } + pszP = magicarg; + + for( ;status == -1 && pszP[0] != 0; pszP++ ){ + for( i = 1; i < BATTLE_ST_END; i ++ ){ + if( strncmp( pszP, aszStatus[i], 2 ) == 0 ){ + status = i; + pszP +=2; + break; + } + } + } + + if( status == -1 ) return FALSE; + + if( ( pszP = strstr( pszP, szTurn ) ) != NULL){ + pszP += sizeof( szTurn ); + sscanf( pszP, "%d", &turn ); + } + + if( ( pszP = strstr( pszP, szSuccess ) ) != NULL){ + pszP += sizeof( szSuccess ); + sscanf( pszP, "%d", &Success ); + } + + if( status == BATTLE_ST_NONE ){ + ReceveEffect = SPR_tyusya; + }else{ + ReceveEffect = SPR_hoshi; + } + + BATTLE_MultiStatusChange( battleindex, attackNo, defNo, + status, turn+2, MAGIC_EFFECT_USER, ReceveEffect, Success ); + + return iRet; +} +#endif + +#ifdef _SKILL_BARRIER //vincent宠技:魔障 +int BATTLE_S_Barrier( + int battleindex, + int attackNo, + int defNo , + int marray +) +{ + BOOL iRet = FALSE; + int battlemode; + int i,turn,perStatus,charaindex,toindex; + int ToList[SIDE_OFFSET*2+1]; + char *magicarg; + int Success = 0; + char szTurn[] = "turn"; + char szSuccess[] = "成"; + char *pszP; + charaindex = BATTLE_No2Index( battleindex, attackNo ); //攻方index + //check index + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; + + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + + if( battlemode == BATTLE_CHARMODE_INIT ){ + return FALSE; + } + + magicarg = PETSKILL_getChar( marray, PETSKILL_OPTION ); + if( magicarg == NULL ) { + print("\n magicarg == NULL "); + return FALSE; + } + + pszP = magicarg; + + //读取作用回合数 + if( ( pszP = strstr( pszP, szTurn ) ) != NULL){ + pszP += sizeof( szTurn ); + sscanf( pszP, "%d", &turn ); + } + //命中率 + if( ( pszP = strstr( pszP, szSuccess ) ) != NULL){ + pszP += sizeof( szSuccess ); + sscanf( pszP, "%d", &Success ); + } + + BATTLE_MultiList( battleindex, defNo, ToList ); + + //施魔法动画效果 + BATTLE_MagicEffect(battleindex, attackNo, ToList, MAGIC_EFFECT_USER, SPR_hoshi); + + //check是否战斗中 + if( IsBATTLING( charaindex ) == TRUE ) + { + + for( i = 0; ToList[i] != -1; i ++ ) + { + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + if( BATTLE_StatusAttackCheck( charaindex,toindex, BATTLE_ST_BARRIER, Success, 30, 1.0, &perStatus ) == TRUE ) + { + CHAR_setWorkInt( toindex, CHAR_WORKBARRIER, turn+1); + } + } + + } + return iRet; +} +#endif + +#ifdef _SKILL_NOCAST //vincent宠技:沉默 +int BATTLE_S_Nocast( + int battleindex, + int attackNo, + int defNo , + int marray +) +{ + BOOL iRet = FALSE; + int battlemode; + int i,turn,perStatus,charaindex,toindex; + int ToList[SIDE_OFFSET*2+1]; + char *magicarg; + int Success = 0; + char szTurn[] = "turn"; + char szSuccess[] = "成"; + char *pszP; + charaindex = BATTLE_No2Index( battleindex, attackNo ); //攻方index + //check index + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; + + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + + if( battlemode == BATTLE_CHARMODE_INIT ){ + return FALSE; + } + + magicarg = PETSKILL_getChar( marray, PETSKILL_OPTION ); + if( magicarg == NULL ) { + print("\n magicarg == NULL "); + return FALSE; + } + + pszP = magicarg; + + //读取作用回合数 + if( ( pszP = strstr( pszP, szTurn ) ) != NULL){ + pszP += sizeof( szTurn ); + sscanf( pszP, "%d", &turn ); + } + //命中率 + if( ( pszP = strstr( pszP, szSuccess ) ) != NULL){ + pszP += sizeof( szSuccess ); + sscanf( pszP, "%d", &Success ); + } + + BATTLE_MultiList( battleindex, defNo, ToList ); + + //施魔法动画效果 + BATTLE_MagicEffect(battleindex, attackNo, ToList, MAGIC_EFFECT_USER, SPR_hoshi); + + //check是否战斗中 + if( IsBATTLING( charaindex ) == TRUE ){ + + for( i = 0; ToList[i] != -1; i ++ ){ + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + if( BATTLE_StatusAttackCheck( charaindex,toindex, BATTLE_ST_NOCAST, Success, 30, 1.0, &perStatus ) == TRUE + && CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPET){ + //无法展开咒术页 + lssproto_NC_send( getfdFromCharaIndex( toindex ), 1); + CHAR_setWorkInt( toindex, CHAR_WORKNOCAST, turn ); + BATTLE_BadStatusString( ToList[i], BATTLE_ST_NOCAST ); + } + } + + } + return iRet; +} +#endif + +int BATTLE_getReactFlg( int index, int react) +{ + int flg=0; + if( react == BATTLE_MD_ABSROB )flg |= BCF_ABSORB; + if( react == BATTLE_MD_REFLEC )flg |= BCF_REFRECT; + if( react == BATTLE_MD_VANISH )flg |= BCF_VANISH; +#ifdef _MAGIC_SUPERWALL + if( CHAR_getWorkInt( index, CHAR_MAGICSUPERWALL ) > 0 ){ + flg |= BCF_SUPERWALL; + } +#endif +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + if( react == BATTLE_MD_TRAP ) flg |= BCF_TRAP; +#endif +#ifdef _PETSKILL_ACUPUNCTURE + if( react == BATTLE_MD_ACUPUNCTURE ) flg |= BCF_ACUPUNCTURE; +#endif + return flg; +} + +#ifdef _PREVENT_TEAMATTACK +int BATTLE_CheckSameSide( int charaindex, int toNo) +{ + int ToList[SIDE_OFFSET*2+1]; + int toindex, i, battleindex; + int MySide; + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + MySide = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLESIDE); + +//toindex = BATTLE_No2Index( battleindex, ToList[i] ); + if( toNo < 20 ){//单一目标 + toindex = BATTLE_No2Index( battleindex, toNo); + if( CHAR_getWorkInt( toindex, CHAR_WORKBATTLESIDE) == MySide ) return 1;//同边 + }else if( toNo){ + + BATTLE_MultiList( battleindex, toNo, ToList ); + for( i = 0; ToList[i] != -1; i ++ ){ + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + if( !CHAR_CHECKINDEX( toindex) ) continue; + + if( CHAR_getWorkInt( toindex, CHAR_WORKBATTLESIDE) == MySide ) return 1;//同边 + } + } + return 0; +} +#endif + + +#ifdef _USER_CHARLOOPS +int CHAR_BattleStayLoop( int charaindex) +{ + int fd = getfdFromCharaIndex( charaindex); + if( getStayEncount( fd) ) { + if( CONNECT_getBDTime( fd) < time( NULL) ) { + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE){ + lssproto_EN_recv( fd, CHAR_getInt( charaindex,CHAR_X), CHAR_getInt( charaindex,CHAR_Y)); + CONNECT_setBDTime( fd, (int)time( NULL)); + } + } + }else{ + Char *ch; + ch = CHAR_getCharPointer( charaindex); + if( ch == NULL ) return 0; + strcpysafe( ch->charfunctable[CHAR_LOOPFUNCTEMP1].string, + sizeof( ch->charfunctable[CHAR_LOOPFUNCTEMP1]), "");//战斗 + CHAR_setInt( charaindex, CHAR_LOOPINTERVAL, 0); + CHAR_constructFunctable( charaindex); + } + + return 1; +} +#endif + +#ifdef _PETSKILL_PROPERTY +int PET_PetskillPropertyEvent( int Myindex, int defindex, int *damage, int *T_Pow, int size) +{ + int My_Pow[5]={0,0,0,0,0}; + int i, totals=100; + if( !CHAR_CHECKINDEX( Myindex)) return 0; + if( !CHAR_CHECKINDEX( defindex)) return 0; + BATTLE_GetAttr( defindex, My_Pow); + + //被攻击方转变属性 + for( i=0; i<4; i++) { + int nums = (i+3)%4; + if( My_Pow[i] != 0 ){ + T_Pow[ nums] = My_Pow[i]; + totals -= My_Pow[i]; + }else{ + T_Pow[ nums] = 0; + } + } + T_Pow[ 4] = totals; + return 1; +} +#endif + + + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + +// 直接攻击函式 +int battle_profession_attack_fun(int battleindex, int attackNo, int defNo, int charaindex) +{ + char szBuffer[512]=""; + char szCommand[1024]; + int attackindex, defindex=-1; + int damage=0, petdamage=0, i=0, iWork, Guardian=-1,react; + int flg = 0, DefSide=0,ultimate=0; + BOOL iRet = FALSE; + int ReactType=0, skill_type=-1, skill=-1; + char *pszP = NULL; + char *pszOption = NULL; + int effect=0, img1=0, img2=0, atk_num=0, skill_level; + + skill = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3); + skill_type=CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ); + + //攻方index + attackindex = BATTLE_No2Index( battleindex, attackNo ); + if( CHAR_CHECKINDEX( attackindex ) == FALSE ) return iRet; + + //守方index + defindex = BATTLE_No2Index( battleindex, defNo ); + if( CHAR_CHECKINDEX( defindex ) == FALSE ){ + return iRet; + } + + // 体掠夺 + if( (CHAR_getInt( defindex, CHAR_HP ) <= 0) && (skill_type != BATTLE_COM_S_PLUNDER) ){ + return iRet; + } + + // 非战斗使用技能 + if( !PROFESSION_SKILL_getInt( skill, PROFESSION_SKILL_USE_FLAG) ) return iRet; + + // 取得技能参数 + pszOption = PROFESSION_SKILL_getChar( skill, PROFESSION_SKILL_OPTION); + if( pszOption == NULL ) return iRet; + + // 技能等级 + skill_level = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_A( skill_level ); + + // 动画方式 0原地秀动画 1人物移动秀动画 + if( (pszP = strstr( pszOption, "效%" ) ) != NULL ) sscanf( pszP+3, "%d", &effect ); + + // 准备期的动画 + img1 = PROFESSION_SKILL_getInt( skill, PROFESSION_SKILL_IMG_1 ); + + // 击中後的动画 + img2 = PROFESSION_SKILL_getInt( skill, PROFESSION_SKILL_IMG_2 ); + + // 目标地球一周,不动作 + if( defNo >= 0 && defNo <= 19 ){ + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_EARTHROUND0 ){ + return iRet; + } + } + + // 取出各技能参数 + switch( skill_type){ + case BATTLE_COM_S_BRUST: // 爆击 + { + int str=0, old_str=0; + + // 增加攻击力 + old_str = CHAR_getWorkInt( charaindex, CHAR_WORKFIXSTR); + str = old_str * ( skill_level * 3 + 100 ) / 100; + + CHAR_setWorkInt( charaindex, CHAR_WORKFIXSTR, str ); + + break; + } + case BATTLE_COM_S_CHAOS: // 混乱攻击 + { + int atk = 0; + // 减30%攻击力 + atk = CHAR_getWorkInt( charaindex, CHAR_WORKATTACKPOWER ); + atk = atk * 70 / 100; + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER, atk ); + + if( skill_level >= 10 ) atk_num = 5; + else if( skill_level >= 5 ) atk_num = 4; + else atk_num = 3; + + break; + } + case BATTLE_COM_S_CHAIN_ATK: // 连环攻击 + { + int rand_num = RAND(1, 100); + int hit; + + if( skill_level % 10 != 0 ) + skill_level += 1; + hit = skill_level * 5 + 15; + + if( rand_num <= hit ) + atk_num=2; // 攻击二次 + else + atk_num=0; + + break; + } + case BATTLE_COM_S_ENRAGE_PET: // 激怒宠物 + { + // 判断是否同队 + if( BATTLE_CheckSameSide( charaindex, defNo) != 1 ) return iRet; + + defNo = attackNo; + + // 攻击力 1 + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER, 0 ); + + break; + } + case BATTLE_COM_S_CHAIN_ATK_2: // 双重攻击 + { + int atkpower = 0; + int absrob_num = CHAR_getWorkInt( defindex, CHAR_WORKDAMAGEABSROB ); // 光 + //int reflec_num = CHAR_getWorkInt( defindex, CHAR_WORKDAMAGEREFLEC ); // 镜 + int evanish_num = CHAR_getWorkInt( defindex, CHAR_WORKDAMAGEVANISH ); // 守 + int trap_num = CHAR_getWorkInt( defindex, CHAR_WORKTRAP ); // 陷阱 + + if( absrob_num > 0 ) CHAR_setWorkInt( defindex, CHAR_WORKDAMAGEABSROB, max(absrob_num - 1, 0) ); + //if( reflec_num > 0 ) CHAR_setWorkInt( defindex, CHAR_WORKDAMAGEREFLEC, max(reflec_num - 1, 0) );//让镜有效,这行要拿掉 + if( evanish_num > 0 ) CHAR_setWorkInt( defindex, CHAR_WORKDAMAGEVANISH, max(evanish_num - 1, 0) ); + if( trap_num > 0 ) CHAR_setWorkInt( defindex, CHAR_WORKTRAP, 0 ); + + // 第一下攻击力 0 + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER, 0 ); + + snprintf( szCommand, sizeof( szCommand ), "B+|a%X|r%X|f%X|d%X|p%X|e%X|s%X|h%X|", + attackNo, defNo, BCF_NO_DAMAGE, 0, 0, effect, img1, img2 ); + BATTLESTR_ADD( szCommand ); + + // 增加攻击力 + atkpower =(int)( CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR) * (skill_level * 2 + 100) /100 ); + + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER, atkpower ); + + if( (CHAR_getInt( charaindex, CHAR_HP ) > 0 ) && + (CHAR_getInt( defindex, CHAR_HP ) > 0 ) ){ + BATTLE_Attack( battleindex, attackNo, defNo ); + } + + snprintf( szCommand, sizeof( szCommand ), "FF|"); + BATTLESTR_ADD( szCommand ); + + return iRet; + } + case BATTLE_COM_S_DEAD_ATTACK: // 濒死攻击 + { + int hit=0, hp=0, old_hp=0, rate=0; + + rate = skill_level * 2 + 10 ; + old_hp = CHAR_getInt(charaindex, CHAR_HP); + hp = old_hp * rate / 100; + + if( old_hp <= 10 ){ + CHAR_talkToCli( charaindex, -1, "HP不足,无法使用技能", CHAR_COLORYELLOW); + return iRet; + } + + hit = skill_level * 2 + 80; + + CHAR_setWorkInt(charaindex,CHAR_WORKHITRIGHT, CHAR_getWorkInt(charaindex,CHAR_WORKHITRIGHT) + hit ); + CHAR_setWorkInt( charaindex, CHAR_MYSKILLHIT, 1); + CHAR_setWorkInt( charaindex, CHAR_MYSKILLHIT_NUM, hit); + CHAR_talkToCli( charaindex, -1, "命中率上升", CHAR_COLORYELLOW); + + sprintf( szCommand, "BD|r%X|0|1|%X|", attackNo, (-1) * (old_hp - hp) ); + BATTLESTR_ADD( szCommand ); + + CHAR_setInt(charaindex, CHAR_HP, hp); + break; + } + case BATTLE_COM_S_ATTACK_WEAK: // 弱点攻击 + { + float str=0.0, dex=0.0; + int whichtype; + + whichtype = CHAR_getInt( defindex, CHAR_WHICHTYPE); + + // 目标为宠物时升攻 + if( (whichtype == CHAR_TYPEPET) || (whichtype == CHAR_TYPEENEMY) ){ + str = skill_level * 2 +10 + 100; + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER, CHAR_getWorkInt(charaindex,CHAR_WORKATTACKPOWER) * (str/100) ); + } + + // 降敏 + dex = 100 - ( skill_level + 10 ); + CHAR_setWorkInt(charaindex,CHAR_WORKQUICK, CHAR_getWorkInt(charaindex,CHAR_WORKFIXDEX) * (dex/100) ); + sprintf( szCommand, "BD|r%X|0|6|%X|", attackNo, (-1) * (skill_level + 10) ); + BATTLESTR_ADD( szCommand ); + + break; + } + case BATTLE_COM_S_PLUNDER: // 体掠夺 + { + char pBidList[BATTLE_ENTRY_MAX*2+1]; + int item, start = 0; + memset( pBidList, -1, sizeof(pBidList) ); + pBidList[0] = defNo; + + // 掠夺的目标 + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + defindex = BATTLE_No2Index( battleindex, defNo ); + if( CHAR_getInt( defindex, CHAR_WHICHTYPE) != CHAR_TYPEENEMY ) return 1; + + snprintf( szCommand, sizeof( szCommand ), "B+|a%X|r%X|f%X|d%X|p%X|e%X|s%X|h%X|FF|", + attackNo, defNo, flg, 0, 0, effect, img1, img2 ); + BATTLESTR_ADD( szCommand ); + + if( defNo < 10 ) start = 0; + else start = 10; + + for( i = start; i < start+10; i++ ){ + for(item=CHAR_STARTITEMARRAY; item < CHAR_STARTITEMARRAY+10; item++){ + int enemy_index = -1; + int itemindex = -1; + + enemy_index = BATTLE_No2Index( battleindex, i ); + if( !CHAR_CHECKINDEX(enemy_index) ) break; + + itemindex = CHAR_getItemIndex( enemy_index, item ); + + if(ITEM_CHECKINDEX( itemindex ) == TRUE ){ + char msg[64], *item_name; + + CHAR_AddPileItem( charaindex, itemindex); + + item_name = ITEM_getChar( itemindex, ITEM_NAME); + + sprintf( msg, "得到%s", item_name ); + CHAR_talkToCli( charaindex, -1, msg, CHAR_COLORYELLOW); + + CHAR_setItemIndex( enemy_index, item, -1 ); + + BATTLE_Exit( defindex, battleindex ); + + return 1; + } + } + } + + BATTLE_Exit( defindex, battleindex ); + + return 1; + } + default: + break; + } + + + react = 0; + if( (ReactType=BATTLE_GetDamageReact( defindex)) > 0 ) { //有光镜守 + react = ReactType; + if( skill_type != BATTLE_COM_S_CHAIN_ATK ){ + react=0; +// skill_type=-1; + } + } + + + if( defNo >= SIDE_OFFSET ){ + i = defNo - SIDE_OFFSET; + DefSide = 1; + } + + //取得攻击後状态 + iWork = BATTLE_AttackSeq( attackindex, defindex, &damage, &Guardian, skill_type ); + if( skill_type == BATTLE_COM_S_ENRAGE_PET ){//让激怒宠物技能不要真的打死宠物 + if( CHAR_getInt( defindex, CHAR_HP ) <= damage ){ + damage = 0; + } + } + +#ifdef CAVALRY_DEBUG + ultimate = BATTLE_DamageSub( attackindex, defindex, &damage, &petdamage, &react); +#else + if( skill_type == BATTLE_COM_S_CAVALRY) // 座骑攻击 + ultimate = BATTLE_PROFESSION_ATK_PET_DamageSub( attackindex, defindex, &damage, &petdamage, &react, skill_level ); + else + ultimate = BATTLE_DamageSub( attackindex, defindex, &damage, &petdamage, &react); +#endif + + if( react == BATTLE_MD_REFLEC ) defindex = attackindex; + if( react == BATTLE_MD_TRAP ) defindex = attackindex; +#ifdef _PETSKILL_ACUPUNCTURE + if( react == BATTLE_MD_ACUPUNCTURE ) defindex = attackindex; +#endif + if( damage > 0 && ( react != BATTLE_MD_ABSROB )&& ( react != BATTLE_MD_VANISH )){ + BATTLE_DamageWakeUp( battleindex, defindex ); + } + + iRet = BATTLE_DefineAttack( attackindex, defindex, iWork, szBuffer, damage, react, &flg); + + // 将 NORMAL 及 CRITICAL 的 flg 改成 职业的flg + if( img2 != 0 ){ + if( flg == BCF_NORMAL || flg == BCF_KAISHIN ){ + if( (pszP = strstr( pszOption, "前" ) ) != NULL ) + flg |= BCF_F_SKILLACT; //击中前秀图 + else + flg |= BCF_B_SKILLACT; //击中後秀 + } + } + + if( CHAR_getInt( defindex, CHAR_HP ) <= 0 ){ + iRet = BATTLE_DefDieType( defindex, iRet, &ultimate, &flg, szBuffer); + } + + if( damage > 0 ){ + if( BATTLE_ItemCrushSeq( attackindex, defindex, damage) == TRUE ) + flg |= BCF_CRUSH; + } + + + memset( szCommand, 0, sizeof( szCommand)); + switch( skill_type){ + case BATTLE_COM_S_BRUST: // 爆击 + case BATTLE_COM_S_DEAD_ATTACK: // 濒死攻击 + case BATTLE_COM_S_ATTACK_WEAK: // 弱点攻击 + case BATTLE_COM_S_CAVALRY: // 座骑攻击 + { + snprintf( szCommand, sizeof( szCommand ), "B+|a%X|r%X|f%X|d%X|p%X|e%X|s%X|h%X|FF|", + attackNo, defNo, flg, damage, petdamage, effect, img1, img2 ); + BATTLESTR_ADD( szCommand ); + break; + } + case BATTLE_COM_S_ENRAGE_PET: // 激怒宠物 + { + int str = 0; + int turn = 0; + int pindex = -1; + + + flg |= BCF_NO_DAMAGE; + flg |= BCF_B_SKILLACT; //击中後秀图 + + defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + + pindex = BATTLE_No2Index( battleindex, defNo ); + + // 检查是否为宠物 + if( CHAR_getInt( pindex, CHAR_WHICHTYPE) != CHAR_TYPEPET ) break; + + snprintf( szCommand, sizeof( szCommand ), "B+|a%X|r%X|f%X|d%X|p%X|e%X|s%X|h%X|FF|", + attackNo, defNo, flg, 0, 0, effect, img1, img2 ); + BATTLESTR_ADD( szCommand ); + + // 加攻 + str = skill_level * 2 + 10; + sprintf( szCommand, "BD|r%X|0|4|%X|", defNo, str); + BATTLESTR_ADD( szCommand ); + CHAR_setWorkInt( pindex, CHAR_MYSKILLSTRPOWER, str); + + if( skill_level >= 10 ) turn=5; + else if( skill_level >= 5 ) turn=4; + else turn=3; + + CHAR_setWorkInt( pindex, CHAR_MYSKILLSTR, turn ); + + break; + } + case BATTLE_COM_S_CHAOS: // 混乱攻击 + { + int i=0, j=0, k=0, f_num=0; + int temp[10], chose_temp[10]; + int defNo_index = BATTLE_No2Index( battleindex, defNo ); + + memset( temp, -1, sizeof( temp ) ); + memset( chose_temp, -1, sizeof( chose_temp ) ); + + if( CHAR_getWorkInt( defNo_index, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_EARTHROUND0 ){ + break; + } + + if( defNo >= 10 ) f_num = 10; + else f_num = 0; + + // 减30%攻击力 + //CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER, CHAR_getWorkInt( charaindex, CHAR_WORKATTACKPOWER ) * 70 / 100 ); + + //传给client减攻击力效果 + sprintf( szCommand, "BD|r%X|0|4|%X|", attackNo, -30 ); + BATTLESTR_ADD( szCommand ); + + snprintf( szCommand, sizeof( szCommand ), "B+|a%X|r%X|f%X|d%X|p%X|e%X|s%X|h%X|", + attackNo, defNo, flg, damage, petdamage, effect, img1, img2 ); + BATTLESTR_ADD( szCommand ); + + // 取出战场上存活的人 + for( i=f_num; i 0 ){ + int atk_to_index = -1; + atk_to_index = BATTLE_No2Index( battleindex, chose_temp[k] ); + + if( ( atk_to_index >= 0 ) && + ( BATTLE_TargetCheck(battleindex, chose_temp[k] ) != FALSE ) && + ( CHAR_getWorkInt( atk_to_index, CHAR_WORKBATTLECOM1 ) != BATTLE_COM_S_EARTHROUND0 ) + ){ + BATTLE_Attack( battleindex, attackNo, chose_temp[k] ); + k++; + atk_num --; + }else{ + + memset( temp, -1, sizeof( temp ) ); + memset( chose_temp, -1, sizeof( chose_temp ) ); + j = 0; k = 0; + + // 取出战场上存活的人 + for( i=f_num; i 0 ) && + (CHAR_getInt( defindex, CHAR_HP ) > 0 ) ){ + BATTLE_Attack( battleindex, attackNo, defNo ); + } + + snprintf( szCommand, sizeof( szCommand ), "FF|"); + BATTLESTR_ADD( szCommand ); + + break; + } + } + + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + i = defNo-DefSide*SIDE_OFFSET; + if( ultimate > 0 ){ + BattleArray[battleindex].Side[DefSide].Entry[i].flg |= BENT_FLG_ULTIMATE; + } + return iRet; +} + + +// 魔法攻击函式 +int battle_profession_attack_magic_fun(int battleindex, int attackNo, int defNo, int charaindex) +{ + int attr=-1, attIdx=0, skill=-1, toindex; + + // 取技能ID + skill = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3); + + // 攻击目标 + // Robin fix + //toindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ); + toindex = defNo; + + + // 攻击 围 0单体 1单排 2一方全体 + if( toindex < 20 ){ // 单体 + attIdx = 0; + }else if( toindex>=23 && toindex<=26 ){ // 单排 + attIdx = 1; + }else if( toindex==20 || toindex==21 ){ // 一方全体 + attIdx = 2; + } + + // Robin fix 增加战场属性优势 + attr = BattleArray[battleindex].field_att -1; + + PROFESSION_MAGIC_ATTAIC( battleindex, attackNo, toindex, attIdx, attr, skill); + + return TRUE; +} + +// 提升自已能力系函式 +int battle_profession_assist_fun(int battleindex, int attackNo, int defNo, int charaindex) +{ + int i, skill, skill_type, skill_level, img1, img2, turn=1; + char *pszP = NULL, *pszOption = NULL, szCommand[256]; + BOOL iRet = FALSE; + int ToList[SIDE_OFFSET*2+1]; + + skill = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3); + skill_type = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ); + + // 非战斗使用技能 + if( !PROFESSION_SKILL_getInt( skill, PROFESSION_SKILL_USE_FLAG) ) return iRet; + + // 技能的参数 + pszOption = PROFESSION_SKILL_getChar( skill, PROFESSION_SKILL_OPTION); + if( pszOption == NULL ) return iRet; + + // 技能等级 + skill_level = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + + // 准备期的动画 + img1 = PROFESSION_SKILL_getInt( skill, PROFESSION_SKILL_IMG_1 ); + + // 击中後的动画 + img2 = PROFESSION_SKILL_getInt( skill, PROFESSION_SKILL_IMG_2 ); + + // 使用回合数 + if( (pszP = strstr( pszOption, "回%" ) ) != NULL ) sscanf( pszP+3, "%d", &turn ); + if(turn < 1) turn=1; + + switch(skill_type){ + case BATTLE_COM_S_TRANSPOSE: // 移形换位 + { + int defNo2 = CHAR_getWorkInt(charaindex,CHAR_WORKBATTLECOM2); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_M( skill_level ); + + memset( ToList, -1, sizeof( ToList)); + BATTLE_MultiList( battleindex, defNo2, ToList ); + BATTLE_MagicEffect( battleindex, attackNo, ToList, img1, img2 ); + + for( i = 0; ToList[i] != -1; i ++ ){ + int avoid=0; + int toindex = BATTLE_No2Index( battleindex, ToList[i] ); + if( !CHAR_CHECKINDEX( toindex ))continue; + if( charaindex != toindex ) continue; + + // 回避率 + if( skill_level >= 10 ) avoid = 70; + else if( skill_level >= 9 ) avoid = 60; + else if( skill_level >= 8 ) avoid = 50; + else if( skill_level >= 6 ) avoid = 45; + else if( skill_level >= 5 ) avoid = 30; + else if( skill_level >= 3 ) avoid = 25; + else avoid = 10; + + if( skill_level >= 10 ) turn = 5; + else if( skill_level >= 6 ) turn = 4; + else turn = 3; + + if( CHAR_getWorkInt( toindex, CHAR_MYSKILLDUCK) <= 0){ + CHAR_setWorkInt( toindex, CHAR_MYSKILLDUCK, turn+1); + CHAR_setWorkInt( toindex, CHAR_MYSKILLDUCKPOWER, avoid ); + sprintf( szCommand, "BD|r%X|0|3|%X|", ToList[i], avoid); + BATTLESTR_ADD( szCommand ); + iRet = TRUE; + } + } + break; + } + case BATTLE_COM_S_SCAPEGOAT: // 舍已为友 + { + int tgh=0, old_tgh=0, flg=0, rate=0; + int pos=0, side=0, ownerpos=0; + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_A( skill_level ); + + pos = BATTLE_Index2No( battleindex, charaindex ); + side = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLESIDE ); + + if( skill_level >= 10 ){ // 我方全体 + for(i=0; i<10; i++){ + if(pos != i ) + BattleArray[battleindex].Side[side].Entry[i].guardian = pos; + } + }else if( skill_level >= 5 ){ // 我方所有宠物 + for(i=5; i<10; i++){ + if(pos != i ) + BattleArray[battleindex].Side[side].Entry[i].guardian = pos; + } + }else{ // 人物之宠物 + ownerpos = pos + 5; + if( ownerpos >= 10 ) ownerpos -= 10; + if( ownerpos < 0 || ownerpos > 19 ){ + }else{ + BattleArray[battleindex].Side[side].Entry[ownerpos].guardian = pos; + } + } + + rate = skill_level * 2; + + tgh = 30 - rate; + sprintf( szCommand, "BD|r%X|0|5|%X|", attackNo, (-1) * tgh ); + BATTLESTR_ADD( szCommand ); + + old_tgh = CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH); + tgh = (int)( old_tgh * (100-tgh) / 100 ); + CHAR_setWorkInt( charaindex, CHAR_WORKFIXTOUGH, tgh); + + flg = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEFLG ); + flg |= CHAR_BATTLEFLG_GUARDIAN; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEFLG, flg ); + + iRet = TRUE; + + break; + } + case BATTLE_COM_S_ENRAGE: // 激化攻击 + { + int str=0, tgh=0; + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_A( skill_level ); + + memset( ToList, -1, sizeof( ToList)); + BATTLE_MultiList( battleindex, attackNo, ToList ); + BATTLE_MagicEffect( battleindex, attackNo, ToList, img1, img2 ); + + // 减防 + tgh = skill_level * 2 + 10; + sprintf( szCommand, "BD|r%X|0|5|%X|", attackNo, (-1) * tgh ); + BATTLESTR_ADD( szCommand ); + + CHAR_setWorkInt(charaindex,CHAR_MYSKILLTGHPOWER, (-1) * tgh); + + // 加攻 + str = skill_level * 2 + 20; + sprintf( szCommand, "BD|r%X|0|4|%X|", attackNo, str); + BATTLESTR_ADD( szCommand ); + + CHAR_setWorkInt( charaindex, CHAR_MYSKILLSTRPOWER, str); + + if( skill_level >= 10 ) turn=5; + else if( skill_level >= 5 ) turn=4; + else turn=3; + + CHAR_setWorkInt( charaindex, CHAR_MYSKILLSTR, turn ); + CHAR_setWorkInt( charaindex, CHAR_MYSKILLTGH, turn ); + + iRet = TRUE; + break; + } + case BATTLE_COM_S_COLLECT: // 能量聚集 + { + int dex=0, tgh=0; + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_A( skill_level ); + + memset( ToList, -1, sizeof( ToList)); + BATTLE_MultiList( battleindex, attackNo, ToList ); + BATTLE_MagicEffect( battleindex, attackNo, ToList, img1, img2 ); + + // 减敏 + dex = (skill_level * 2) + 10; + sprintf( szCommand, "BD|r%X|0|6|%X|", attackNo, (-1) * dex ); + BATTLESTR_ADD( szCommand ); + CHAR_setWorkInt(charaindex,CHAR_MYSKILLDEXPOWER, dex); + + // 加防 + tgh = (skill_level * 2) + 20; + sprintf( szCommand, "BD|r%X|0|5|%X|", attackNo, tgh); + BATTLESTR_ADD( szCommand ); + CHAR_setWorkInt( charaindex, CHAR_MYSKILLTGHPOWER, tgh); + + if( skill_level >= 10 ) turn=5; + else if( skill_level >= 5 ) turn=4; + else turn=3; + + CHAR_setWorkInt( charaindex, CHAR_MYSKILLDEX, turn ); + CHAR_setWorkInt( charaindex, CHAR_MYSKILLTGH, turn ); + + iRet = TRUE; + break; + } + case BATTLE_COM_S_FOCUS: // 专注战斗 + { + int ToList[SIDE_OFFSET*2+1]; + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_A( skill_level ); + + memset( ToList, -1, sizeof( ToList)); + BATTLE_MultiList( battleindex, attackNo, ToList ); + BATTLE_MagicEffect( battleindex, attackNo, ToList, img1, img2 ); + + CHAR_setWorkInt( charaindex, CHAR_MYSKILLHIT, 2); + CHAR_setWorkInt( charaindex, CHAR_MYSKILLHIT_NUM, 100); + + CHAR_talkToCli( charaindex, -1, "命中率上升", CHAR_COLORYELLOW); + + iRet = TRUE; + break; + } + case BATTLE_COM_S_TRAP: // 陷阱 + { + int value; + int ToList[SIDE_OFFSET*2+1]; + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_M( skill_level ); + + memset( ToList, -1, sizeof(ToList) ); + ToList[0] = attackNo; + + value = skill_level * 30 + 100; + BATTLE_MagicEffect( battleindex, attackNo, ToList, img1, img2 ); + + if( skill_level >= 10 ) turn=3; + else if( skill_level >= 5 ) turn=2; + else turn=1; + + CHAR_setWorkInt( charaindex, CHAR_WORKTRAP, turn); + CHAR_setWorkInt( charaindex, CHAR_WORKMODTRAP, value); + + iRet = TRUE; + break; + } + case BATTLE_COM_S_DOCILE: // 驯伏宠物 + { + int rate = 0; + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_A( skill_level ); + + rate = skill_level * 2 + 10; + + BATTLE_MultiCaptureUp( battleindex, attackNo, defNo, rate, img1, img2 ); + + iRet = TRUE; + break; + } +#ifdef _PROFESSION_ADDSKILL + case BATTLE_COM_S_CALL_NATURE: // 号召自然 + { + int ridepet=0,count=0,addhp=0,toindex=-1; + int ToList[SIDE_OFFSET*2+1]; + BATTLE_MultiList( battleindex, defNo, ToList ); + + if( defNo == 20 || defNo == 25 || defNo == 26 )//右方 + img1 = 101772; + for( i = 0; ToList[i] != -1; i ++ ){ + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + if( CHAR_CHECKINDEX( toindex ) == FALSE ) continue; + ridepet = BATTLE_getRidePet( toindex ); + if( ridepet == -1 ) + ++count; + else + count += 2; + } + if( skill_level >= 100 ) addhp = 5000/count; + else if( skill_level > 95 ) addhp = 4500/count; + else if( skill_level > 90 ) addhp = 4000/count; + else if( skill_level > 85 ) addhp = 3500/count; + else if( skill_level > 80 ) addhp = 3000/count; + else if( skill_level > 60 ) addhp = 2500/count; + else if( skill_level > 40 ) addhp = 2000/count; + else if( skill_level > 20 ) addhp = 1000/count; + else addhp = 500/count; + if( addhp <= 100 ) + img2 = SPR_heal; + else if( addhp <= 300 ) + img2 = SPR_heal2; + else + img2 = SPR_heal3; + BATTLE_MagicEffect( battleindex, attackNo, ToList, img1, img2 ); + + for( i = 0; ToList[i] != -1; i ++ ){ + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + if( CHAR_CHECKINDEX( toindex ) == FALSE ) continue; + ridepet = BATTLE_getRidePet( toindex ); + if( ridepet == -1 ){ + CHAR_setInt( toindex, CHAR_HP, + min( addhp+CHAR_getInt( toindex, CHAR_HP ), CHAR_getWorkInt( toindex, CHAR_WORKMAXHP ) ) ); + } + else{ + CHAR_setInt( toindex, CHAR_HP, + min( addhp+CHAR_getInt( toindex, CHAR_HP ), CHAR_getWorkInt( toindex, CHAR_WORKMAXHP ) ) ); + CHAR_setInt( ridepet, CHAR_HP, + min( addhp+CHAR_getInt( ridepet, CHAR_HP ), CHAR_getWorkInt( ridepet, CHAR_WORKMAXHP ) ) ); + } + snprintf( szCommand, sizeof(szCommand),"BD|r%X|%X|%X|d%X|p%X|", ToList[i], BD_KIND_HP, 1, addhp, ridepet?addhp:0 ); + BATTLESTR_ADD( szCommand ); + + + if( BattleArray[battleindex].norisk == 0 + && CHAR_getInt( toindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET) + { + int flg = CHAR_getWorkInt( toindex, CHAR_WORKBATTLEFLG ); + if( flg & CHAR_BATTLEFLG_RECOVERY ) + {} + else + { + CHAR_PetAddVariableAi( toindex, AI_FIX_PETRECOVERY ); + CHAR_setWorkInt( toindex, CHAR_WORKBATTLEFLG, flg | CHAR_BATTLEFLG_RECOVERY ); + } + } + } + + iRet = TRUE; + break; + } +#endif + default: + break; + } + + + return iRet; +} + +#ifdef _PROFESSION_ADDSKILL +extern unsigned int GET_PROFESSION_magic_array(int idx); +#endif + +// 击中改变状态系函式 +extern void BATTLE_TargetListSet( int charaindex, int attackNo, int *pList); +extern int BoomerangVsTbl[4][5]; +int battle_profession_status_chang_fun(int battleindex, int attackNo, int defNo, int charaindex) +{ + int i, skill, skill_type, skill_level, img1=0, img2=0, turn=1, j; + char *pszP = NULL, *pszOption = NULL, szCommand[512]; + float rate=0.0; + BOOL iRet = FALSE; + int defindex; + int damage=0, petdamage=0, iWork, Guardian=-1,react; + int flg=0, DefSide=0,ultimate=0; + int ReactType=0, effect=0; + + skill = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3 ); + skill_type=CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1 ); + + // 非战斗使用技能 + if( !PROFESSION_SKILL_getInt( skill, PROFESSION_SKILL_USE_FLAG) ) return iRet; + + // 技能的参数 + pszOption = PROFESSION_SKILL_getChar( skill, PROFESSION_SKILL_OPTION); + if( pszOption == NULL ) return iRet; + + // 技能等级 + skill_level = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_A( skill_level ); + + // 技能等级 rate + if( (pszP = strstr( pszOption, "倍%" ) ) != NULL ) sscanf( pszP+3, "%f", &rate ); + + // 准备期的动画 + img1 = PROFESSION_SKILL_getInt( skill, PROFESSION_SKILL_IMG_1 ); + + // 击中後的动画 + img2 = PROFESSION_SKILL_getInt( skill, PROFESSION_SKILL_IMG_2 ); + + // 使用回合数 + if( (pszP = strstr( pszOption, "回%" ) ) != NULL ) sscanf( pszP+3, "%d", &turn ); + if(turn < 1) turn=1; + + // 动画方式 0原地秀动画 1人物移动秀动画 + if( (pszP = strstr( pszOption, "效%" ) ) != NULL ) sscanf( pszP+3, "%d", &effect ); + + // 目标地球一周,不动作 + if( defNo >= 0 && defNo <= 19 ){ + defindex = BATTLE_No2Index( battleindex, defNo ); + if( CHAR_CHECKINDEX( defindex ) == FALSE ) return iRet; + if( CHAR_getWorkInt( defindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_EARTHROUND0 ){ + return iRet; // Miss + } + } + + switch(skill_type){ + // 不移动型 + case BATTLE_COM_S_ENTWINE: // 树根缠绕 + case BATTLE_COM_S_DRAGNET: // 天罗地网 + case BATTLE_COM_S_INSTIGATE: // 挑拨 + case BATTLE_COM_S_OBLIVION: // 遗忘 + case BATTLE_COM_S_RESIST_FIRE: // 火抗性提升 + case BATTLE_COM_S_RESIST_ICE: // 冰抗性提升 + case BATTLE_COM_S_RESIST_THUNDER: // 雷抗性提升 +#ifdef _PROFESSION_ADDSKILL + case BATTLE_COM_S_RESIST_F_I_T: // 自然威能 +#endif + case BATTLE_COM_S_FIRE_ENCLOSE: // 火附体 + case BATTLE_COM_S_ICE_ENCLOSE: // 冰附体 + case BATTLE_COM_S_THUNDER_ENCLOSE: // 雷附体 + { + int perStatus=0, toindex=-1, status=-1, Success=0, dex=0, old_dex; + //char szBuffer[256]=""; + int ToList[SIDE_OFFSET*2+1]; + int defNo2 = CHAR_getWorkInt(charaindex,CHAR_WORKBATTLECOM2); + + // 使用对象 + if( skill_type == BATTLE_COM_S_RESIST_FIRE || // 火抗性提升 + skill_type == BATTLE_COM_S_RESIST_ICE || // 冰抗性提升 + skill_type == BATTLE_COM_S_RESIST_THUNDER // 雷抗性提升 +#ifdef _PROFESSION_ADDSKILL + || skill_type == BATTLE_COM_S_RESIST_F_I_T // 自然威能 +#endif + ){ +#ifdef _PROFESSION_ADDSKILL + defNo2 = BATTLE_Index2No( battleindex, charaindex ); +#else + if( defNo2 < 10 ){ + if( skill_level >= 10 ) defNo2 = 20; + else if( skill_level >= 5 ) defNo2 = 25; + }else{ + if( skill_level >= 10 ) defNo2 = 21; + else if( skill_level >= 5 ) defNo2 = 24; + } +#endif + } + + memset( ToList, -1, sizeof( ToList)); + BATTLE_MultiList( battleindex, defNo2, ToList ); + + BATTLE_MagicEffect( battleindex, attackNo, ToList, img1, img2 ); + + charaindex = BATTLE_No2Index( battleindex, attackNo ); + if( CHAR_CHECKINDEX( charaindex ) == FALSE ) return iRet; + + // 改变状态 + if( ((pszP = strstr( pszOption, "缠" ) ) != NULL ) || + ((pszP = strstr( pszOption, "挑" ) ) != NULL ) || + ((pszP = strstr( pszOption, "忘" ) ) != NULL ) || + ((pszP = strstr( pszOption, "火" ) ) != NULL ) || + ((pszP = strstr( pszOption, "冰" ) ) != NULL ) || + ((pszP = strstr( pszOption, "雷" ) ) != NULL ) || + ((pszP = strstr( pszOption, "罗" ) ) != NULL ) || + ((pszP = strstr( pszOption, "击" ) ) != NULL ) || + ((pszP = strstr( pszOption, "冻" ) ) != NULL ) || + ((pszP = strstr( pszOption, "炎" ) ) != NULL ) +#ifdef _PROFESSION_ADDSKILL + || ((pszP = strstr( pszOption, "抗" ) ) != NULL ) +#endif + ){ + for( i = 1; i < BATTLE_ST_END; i ++ ){ + if( strncmp( pszP, aszStatus[i], 2 ) == 0 ){ + status = i; + break; + } + } + } + + // 成功率 + if( (pszP = strstr( pszOption, "成%" ) ) != NULL ) sscanf( pszP+3, "%d", &Success ); + + Success = Success + skill_level * 4; + + if( skill_type == BATTLE_COM_S_DRAGNET ){ + int DRAGNET=0,dragnet_idx=-1; + //找出攻方是那一边的 + if( attackNo > 9 ){//左边 + for(i=0;i<10;i++){//计算右边有多少人中天罗 + dragnet_idx = BATTLE_No2Index( battleindex, i ); + if( CHAR_CHECKINDEX( dragnet_idx ) ) + if( CHAR_getWorkInt( dragnet_idx, CHAR_WORKDRAGNET ) > 0 ) + ++DRAGNET; + } + } + else{//右 + for(i=10;i<20;i++){//计算左边有多少人中天罗 + dragnet_idx = BATTLE_No2Index( battleindex, i ); + if( CHAR_CHECKINDEX( dragnet_idx ) ) + if( CHAR_getWorkInt( BATTLE_No2Index( battleindex, i ), CHAR_WORKDRAGNET ) > 0 ) + ++DRAGNET; + } + } + if( DRAGNET == 1 ) + Success *= 0.64; + else if( DRAGNET > 1 ) + Success *= 0.4; + } + + perStatus = Success; + + // 回合数 + if( (skill_type == BATTLE_COM_S_INSTIGATE) && (skill_level == 10) ){ // 挑拨 + turn = 4; + }else if( (skill_type == BATTLE_COM_S_RESIST_FIRE) || // 火抗性提升 + (skill_type == BATTLE_COM_S_RESIST_ICE) || // 冰抗性提升 + (skill_type == BATTLE_COM_S_RESIST_THUNDER) ){ // 雷抗性提升 + + if( skill_level >= 10 ) turn = 5; + else if( skill_level >= 5 ) turn = 4; + else turn = 3; + }else if( skill_type == BATTLE_COM_S_OBLIVION ){ // 遗忘 + if( skill_level >= 10 ){ turn = 4; + }else if( skill_level >= 5 ){ turn = 3; + }else{ turn = 2; } + } +#ifdef _PROFESSION_ADDSKILL + else if( skill_type == BATTLE_COM_S_RESIST_F_I_T ){ // 自然威能 + skill_level = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + if( skill_level >= 100 ) turn = 5; + else if( skill_level > 80 ) turn = 4; + else turn = 3; + } +#endif + + switch( skill_type ){ + case BATTLE_COM_S_RESIST_FIRE: + CHAR_talkToCli( charaindex, -1 , "火抗性提升" , CHAR_COLORYELLOW ); break; + case BATTLE_COM_S_RESIST_ICE: + CHAR_talkToCli( charaindex, -1 , "冰抗性提升" , CHAR_COLORYELLOW ); break; + case BATTLE_COM_S_RESIST_THUNDER: + CHAR_talkToCli( charaindex, -1 , "雷抗性提升" , CHAR_COLORYELLOW ); break; +#ifdef _PROFESSION_ADDSKILL + case BATTLE_COM_S_RESIST_F_I_T: + CHAR_talkToCli( charaindex, -1 , "火冰雷抗性提升" , CHAR_COLORYELLOW ); break; +#endif + } + + for( i = 0; ToList[i] != -1; i ++ ){ + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + if( CHAR_CHECKINDEX( toindex ) == FALSE ) return iRet; + + // 挑拨不可施於玩家人物身上 + if( skill_type == BATTLE_COM_S_INSTIGATE ){ + if( CHAR_getInt( toindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + CHAR_talkToCli( charaindex, -1, "不可施於人物身上", CHAR_COLORYELLOW ); + break; + } + } + + // 状态命中检定 + if( (PROFESSION_BATTLE_StatusAttackCheck( charaindex, toindex, status, Success ) == 0 ) + || (CHAR_getInt( toindex, CHAR_HP ) <= 0 ) ){ + + //snprintf( szBuffer, sizeof(szBuffer), "(%s)无法将(%s)做成(%s)(%d%%)", + // CHAR_getUseName( charaindex ), CHAR_getUseName( toindex ), + // aszStatusFull[status], perStatus ); + + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + }else{ +#ifdef _PROFESSION_ADDSKILL + if( status == BATTLE_ST_RESIST_F_I_T ){//自然威能 + CHAR_setWorkInt( toindex, StatusTbl[BATTLE_ST_RESIST_F], turn + 1 ); + CHAR_setWorkInt( toindex, StatusTbl[BATTLE_ST_RESIST_I], turn + 1 ); + CHAR_setWorkInt( toindex, StatusTbl[BATTLE_ST_RESIST_T], turn + 1 ); + } + else +#endif + CHAR_setWorkInt( toindex, StatusTbl[status], turn + 1 ); + + if( status == BATTLE_ST_PARALYSIS + || status == BATTLE_ST_SLEEP + || status == BATTLE_ST_STONE + || status == BATTLE_ST_BARRIER + || status == BATTLE_ST_DIZZY + || status == BATTLE_ST_ENTWINE + || status == BATTLE_ST_DRAGNET + || status == BATTLE_ST_ICECRACK + || status == BATTLE_ST_ICEARROW ){ + CHAR_setWorkInt( toindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + if( status == BATTLE_ST_DRAGNET ){//天罗地网 + CHAR_setWorkInt( toindex, CHAR_DOOMTIME, 0 );//世界末日集气 + CHAR_setWorkInt( toindex, CHAR_WORK_com1, 0 ); + CHAR_setWorkInt( toindex, CHAR_WORK_toNo, 0 ); + CHAR_setWorkInt( toindex, CHAR_WORK_mode, 0 ); + CHAR_setWorkInt( toindex, CHAR_WORK_skill_level, 0 ); + CHAR_setWorkInt( toindex, CHAR_WORK_array, 0 ); + } + if( skill_type == BATTLE_COM_S_FIRE_ENCLOSE ){ // 火附体 + CHAR_setWorkInt( toindex, CHAR_WORKMOD_F_ENCLOSE_2, skill_level ); + // 加火熟练度经验值 + PROFESSION_SKILL_LVEVEL_UP( charaindex, "PROFESSION_FIRE_PRACTICE" ); + }else if(skill_type == BATTLE_COM_S_ICE_ENCLOSE ){ // 冰附体 + CHAR_setWorkInt( toindex, CHAR_WORKMOD_I_ENCLOSE_2, skill_level ); + // 加冰熟练度经验值 + PROFESSION_SKILL_LVEVEL_UP( charaindex, "PROFESSION_ICE_PRACTICE" ); + }else if(skill_type == BATTLE_COM_S_THUNDER_ENCLOSE ){ // 雷附体 + CHAR_setWorkInt( toindex, CHAR_WORKMOD_T_ENCLOSE_2, skill_level ); + // 加雷熟练度经验值 + PROFESSION_SKILL_LVEVEL_UP( charaindex, "PROFESSION_THUNDER_PRACTICE" ); + } + + // 遗忘 宠物遗忘技能 + if( skill_type == BATTLE_COM_S_OBLIVION ){ + int toNo = -1, toNoindex = -1, pet_no = -1, num = 0; + char msg[20]; + + memset( msg, -1, sizeof(msg) ); + + // 主人index + toNo = ToList[i] - 5; + toNoindex = BATTLE_No2Index( battleindex, toNo ); + + // 宠物编号 + pet_no = CHAR_getInt( toNoindex, CHAR_DEFAULTPET ); + + // 遗忘宠技数量 + num = skill_level / 2; + if( num < 1 ) num = 1; + CHAR_setWorkInt( toindex, CHAR_WORKMODOBLIVION, num ); + + // 传给 client 遗忘技能 + if( toNoindex != -1 ){ + sprintf( msg, "W%d", pet_no ); + CHAR_sendStatusString( toNoindex, msg ); + + sprintf( msg, "Y%d", pet_no ); + CHAR_sendStatusString( toNoindex, msg ); + + } + } + + // 挑拨 降属性 + if(skill_type == BATTLE_COM_S_INSTIGATE ){ + int rate=0; + rate = skill_level * 1 + 10; + CHAR_setWorkInt( toindex, CHAR_WORKMODINSTIGATE, rate); + + sprintf( szCommand, "BD|r%X|0|4|%X|", ToList[i], (-1) * rate); + BATTLESTR_ADD( szCommand ); + sprintf( szCommand, "BD|r%X|0|5|%X|", ToList[i], (-1) * rate); + BATTLESTR_ADD( szCommand ); + sprintf( szCommand, "BD|r%X|0|6|%X|", ToList[i], (-1) * rate ); + BATTLESTR_ADD( szCommand ); + + } + + // 树根缠绕 降敏 + if(skill_type == BATTLE_COM_S_ENTWINE ){ + if( (pszP = strstr( pszOption, "敏%" ) ) != NULL ) sscanf( pszP+3, "%d", &dex ); + dex = skill_level * 4 + dex; + old_dex = CHAR_getWorkInt( toindex, CHAR_WORKFIXDEX); + old_dex = old_dex * (100 - dex) / 100; + CHAR_setWorkInt( toindex, CHAR_WORKFIXDEX, old_dex ); + sprintf( szCommand, "BD|r%X|0|6|%X|", ToList[i], (-1) * dex ); + BATTLESTR_ADD( szCommand ); + } + + // 火抗性提升 + if(skill_type == BATTLE_COM_S_RESIST_FIRE ){ + int old_value = CHAR_getWorkInt( toindex, CHAR_WORK_F_RESIST ); + int up_value = skill_level + 10; + CHAR_setWorkInt( toindex, CHAR_WORKMODRESIST_F, up_value ); + CHAR_setWorkInt( toindex, CHAR_WORK_F_RESIST, old_value + up_value ); + + }else + // 冰抗性提升 + if(skill_type == BATTLE_COM_S_RESIST_ICE ){ + int old_value = CHAR_getWorkInt( toindex, CHAR_WORK_I_RESIST ); + int up_value = skill_level + 10; + CHAR_setWorkInt( toindex, CHAR_WORKMODRESIST_I, up_value ); + CHAR_setWorkInt( toindex, CHAR_WORK_I_RESIST, old_value + up_value ); + + }else + // 雷抗性提升 + if(skill_type == BATTLE_COM_S_RESIST_THUNDER ){ + int old_value = CHAR_getWorkInt( toindex, CHAR_WORK_T_RESIST ); + int up_value = skill_level + 10; + CHAR_setWorkInt( toindex, CHAR_WORKMODRESIST_T, up_value ); + CHAR_setWorkInt( toindex, CHAR_WORK_T_RESIST, old_value + up_value ); + + } +#ifdef _PROFESSION_ADDSKILL + else + // 自然威能 + if(skill_type == BATTLE_COM_S_RESIST_F_I_T ){ + int old_value = CHAR_getWorkInt( toindex, CHAR_WORK_F_RESIST ); + int up_value = 2; //抗性值 + + if( skill_level >= 10 ) up_value = 20; + else if( skill_level > 8 ) up_value = 18; + else if( skill_level > 7 ) up_value = 16; + else if( skill_level > 6 ) up_value = 14; + else if( skill_level > 5 ) up_value = 12; + else if( skill_level > 4 ) up_value = 10; + else if( skill_level > 3 ) up_value = 8; + else if( skill_level > 2 ) up_value = 6; + else if( skill_level > 1 ) up_value = 4; + else up_value = 2; + + CHAR_setWorkInt( toindex, CHAR_WORKMODRESIST_F, up_value ); + CHAR_setWorkInt( toindex, CHAR_WORK_F_RESIST, old_value + up_value ); + + old_value = CHAR_getWorkInt( toindex, CHAR_WORK_I_RESIST ); + CHAR_setWorkInt( toindex, CHAR_WORKMODRESIST_I, up_value ); + CHAR_setWorkInt( toindex, CHAR_WORK_I_RESIST, old_value + up_value ); + + old_value = CHAR_getWorkInt( toindex, CHAR_WORK_T_RESIST ); + CHAR_setWorkInt( toindex, CHAR_WORKMODRESIST_T, up_value ); + CHAR_setWorkInt( toindex, CHAR_WORK_T_RESIST, old_value + up_value ); + + } +#endif + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)将(%s)做成(%s)(%d%%)", CHAR_getUseName( charaindex ), + // CHAR_getUseName( toindex ), aszStatusFull[status], perStatus ); + + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + BATTLE_BadStatusString( ToList[i], status ); + iRet = TRUE; + } + } + break; + } + // 移动型 + case BATTLE_COM_S_SHIELD_ATTACK: // 盾击 + { + int itmid=-1; + int perStatus, status=-1, Success=-1; + char szBuffer[256]=""; + int ToList[SIDE_OFFSET*2+1]; + int defNo2 = CHAR_getWorkInt(charaindex,CHAR_WORKBATTLECOM2); + + itmid = CHAR_getItemIndex( charaindex, CHAR_EQSHIELD ); + + if( ( itmid < 0 ) || ITEM_WSHIELD != ITEM_getInt( itmid , ITEM_TYPE ) ){ + CHAR_talkToCli( charaindex, -1, "未装备盾牌,无法使用此技能", CHAR_COLORYELLOW); + iRet = FALSE; + break; + } + + // 攻击力减半 + if( skill_level != 10 ) + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER, (int)(CHAR_getWorkInt(charaindex,CHAR_WORKATTACKPOWER) * 0.5 ) ); + + memset( ToList, -1, sizeof( ToList)); + BATTLE_MultiList( battleindex, defNo2, ToList ); + + // 改变状态 + if( (pszP = strstr( pszOption, "晕" ) ) != NULL ){ + for( i = 1; i < BATTLE_ST_END; i ++ ){ + if( strncmp( pszP, aszStatus[i], 2 ) == 0 ){ + status = i; + break; + } + } + } + + // 成功率 + if( (pszP = strstr( pszOption, "成%" ) ) != NULL ) sscanf( pszP+3, "%d", &Success ); + Success += skill_level * 4; + perStatus = Success; + + if( defNo2 >= SIDE_OFFSET ){ + i = defNo2 - SIDE_OFFSET; + DefSide = 1; + } + + for( i = 0; ToList[i] != -1; i ++ ){ + int hit = -1; + react = 0; + + defindex = BATTLE_No2Index( battleindex, ToList[i] ); //守方index + if( CHAR_CHECKINDEX( defindex ) == FALSE ) continue; + + if( (ReactType=BATTLE_GetDamageReact( defindex)) > 0 ) { //有光镜守 + react = ReactType; + skill_type=-1; + } + + //取得攻击後状态 + iWork = BATTLE_AttackSeq( charaindex, defindex, &damage, &Guardian, skill_type ); + + ultimate = BATTLE_DamageSub( charaindex, defindex, &damage, &petdamage, &react); + + if( damage > 0 && ( react != BATTLE_MD_ABSROB )&& ( react != BATTLE_MD_VANISH )){ + BATTLE_DamageWakeUp( battleindex, defindex ); + } + + iRet = BATTLE_DefineAttack( charaindex, defindex, iWork, szBuffer, damage, react, &flg); + + // 将 NORMAL 及 CRITICAL 的 flg 改成 职业的flg + if( img2 != 0 ){ + if( flg == BCF_NORMAL || flg == BCF_KAISHIN ){ + hit=1; + if( (pszP = strstr( pszOption, "前" ) ) != NULL ){ + flg |= BCF_F_SKILLACT; //击中前秀图 + }else{ + flg |= BCF_B_SKILLACT; //击中後秀图 + } + } + } + + if( CHAR_getInt( defindex, CHAR_HP ) <= 0 ) + iRet = BATTLE_DefDieType( defindex, iRet, &ultimate, &flg, szBuffer); + + if( damage > 0 ){ + if( BATTLE_ItemCrushSeq( charaindex, defindex, damage) == TRUE ){ + flg |= BCF_CRUSH; + } + } + + if( hit == 1 ){ + if( (PROFESSION_BATTLE_StatusAttackCheck( charaindex, defindex, status, Success ) == 0 ) + || (CHAR_getInt( defindex, CHAR_HP ) <= 0 ) ){ + + //snprintf( szBuffer, sizeof(szBuffer), "(%s)无法将(%s)做成(%s)(%d%%)", + // CHAR_getUseName( charaindex ), CHAR_getUseName( defindex ), aszStatusFull[status], perStatus ); + + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + }else{ + CHAR_setWorkInt( defindex, StatusTbl[status], turn + 1 ); + + if( status == BATTLE_ST_PARALYSIS + || status == BATTLE_ST_SLEEP + || status == BATTLE_ST_STONE + || status == BATTLE_ST_BARRIER + || status == BATTLE_ST_DIZZY + || status == BATTLE_ST_ENTWINE + || status == BATTLE_ST_DRAGNET + || status == BATTLE_ST_ICECRACK + || status == BATTLE_ST_ICEARROW + ){ + CHAR_setWorkInt( defindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)将(%s)做成(%s)(%d%%)", + // CHAR_getUseName( charaindex ), + // CHAR_getUseName( defindex ), + // aszStatusFull[status], + // perStatus + //); + + BATTLE_BadStatusString( ToList[i], status ); + } + } + + snprintf( szCommand, sizeof( szCommand ), "B+|a%X|r%X|f%X|d%X|p%X|e%X|s%X|h%X|FF|", + attackNo, ToList[i], flg, damage, petdamage, effect, img1, img2 ); + BATTLESTR_ADD( szCommand ); + + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + i = defNo2-DefSide*SIDE_OFFSET; + if( ultimate > 0 ){ + BattleArray[battleindex].Side[DefSide].Entry[i].flg |= BENT_FLG_ULTIMATE; + } + + iRet = TRUE; + } + break; + + } + case BATTLE_COM_S_TOXIN_WEAPON: // 毒素武器 + { + int perStatus, status=-1, Success=-1; + int defNo2 = CHAR_getWorkInt(charaindex,CHAR_WORKBATTLECOM2); + + charaindex = BATTLE_No2Index( battleindex, attackNo ); + if( CHAR_CHECKINDEX( charaindex ) == FALSE ) return iRet; + + // 改变状态 + if( ((pszP = strstr( pszOption, "毒" ) ) != NULL ) ){ + + for( i = 1; i < BATTLE_ST_END; i ++ ){ + if( strncmp( pszP, aszStatus[i], 2 ) == 0 ){ + status = i; + break; + } + } + } + + // 成功率 + if( (pszP = strstr( pszOption, "成%" ) ) != NULL ) sscanf( pszP+3, "%d", &Success ); + Success += skill_level * 2; + perStatus = Success; + + if( defNo2 >= SIDE_OFFSET ){ + i = defNo2 - SIDE_OFFSET; + DefSide = 1; + } + + { + int gWeponType = BATTLE_GetWepon( charaindex ); + char szCommand[512]; + int i = 0, ReactType = 0, iRet = -1; + int ToList[SIDE_OFFSET*2+1]; + BOOL bChange = FALSE; + + memset( ToList, -1, sizeof( ToList)); + BATTLE_MultiList( battleindex, defNo, ToList ); + + memset( szCommand, -1, sizeof(szCommand) ); + + // 有无变身 +#ifdef _PETSKILL_BECOMEPIG + if(CHAR_getWorkInt(charaindex, CHAR_WORKFOXROUND) > 0 + || CHAR_getWorkInt(charaindex, CHAR_BECOMEPIG) > 0) bChange = TRUE; +#else + if(CHAR_getWorkInt(charaindex, CHAR_WORKFOXROUND) > 0) bChange = TRUE; +#endif + if(!bChange){ + // 武器为远程武器 + if( gWeponType == ITEM_BOW ){ + sprintf( szCommand, "BB|a%X|w0|", attackNo ); + BATTLESTR_ADD( szCommand ); + memset( ToList, -1, sizeof( ToList)); + BATTLE_TargetListSet(charaindex,attackNo,ToList); + }else if( gWeponType == ITEM_BOUNDTHROW ){ + sprintf( szCommand, "BB|a%X|w1|", attackNo ); + BATTLESTR_ADD( szCommand ); + }else if( gWeponType == ITEM_BREAKTHROW ){ + sprintf( szCommand, "BB|a%X|w2|", attackNo ); + BATTLESTR_ADD( szCommand ); + }else if( gWeponType == ITEM_BOOMERANG){ + sprintf( szCommand, "BO|a%X|", attackNo ); + BATTLESTR_ADD( szCommand ); + memset(ToList,-1,sizeof(ToList)); + for(i=0;i<5;i++) ToList[i] = BoomerangVsTbl[defNo/5][i]; + gBattleDamageModyfy = 0.3; + } + } + + for( i = 0; ToList[i] != -1; i ++ ){ + int defindex = -1, j = -1; + int react = 0; + char szBuffer[256] = ""; + + damage = 0; + petdamage = 0; + flg = 0; + + //memset( szBuffer, 0, sizeof( szBuffer ) ); + + defindex = BATTLE_No2Index( battleindex, ToList[i] ); //守方index + if( CHAR_CHECKINDEX( defindex ) == FALSE ) continue; + if( CHAR_getInt( defindex, CHAR_HP ) <= 0 ) continue; + + if( (ReactType=BATTLE_GetDamageReact( defindex)) > 0 ){ //有光镜守 + react = ReactType; + skill_type=-1; + } + + //取得攻击後状态 + iWork = BATTLE_AttackSeq( charaindex, defindex, &damage, &Guardian, skill_type ); + if(Guardian >= 0) defindex = BATTLE_No2Index( battleindex, Guardian ); + + iRet = BATTLE_DefineAttack( charaindex, defindex, iWork, szBuffer, damage, react, &flg); + + if(damage > 0){ + ultimate = BATTLE_DamageSub( charaindex, defindex, &damage, &petdamage, &react); + + if((react != BATTLE_MD_ABSROB ) && ( react != BATTLE_MD_VANISH ) ){ + BATTLE_DamageWakeUp( battleindex, defindex ); + } + + if( CHAR_getInt( defindex, CHAR_HP ) <= 0 ) + iRet = BATTLE_DefDieType( defindex, iRet, &ultimate, &flg, szBuffer); + + if( BATTLE_ItemCrushSeq( charaindex, defindex, damage) == TRUE ){ + flg |= BCF_CRUSH; + } + + if( (PROFESSION_BATTLE_StatusAttackCheck( charaindex, defindex, status, perStatus ) == 0 ) + || (CHAR_getInt( defindex, CHAR_HP ) <= 0 ) ){ + + //snprintf( szBuffer, sizeof(szBuffer), "(%s)无法将(%s)做成(%s)(%d%%)", + // CHAR_getUseName( charaindex ), CHAR_getUseName( defindex ), aszStatusFull[status], perStatus ); + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + }else{ + CHAR_setWorkInt( defindex, StatusTbl[status], turn + 1 ); + + if( status == BATTLE_ST_PARALYSIS + || status == BATTLE_ST_SLEEP + || status == BATTLE_ST_STONE + || status == BATTLE_ST_BARRIER + || status == BATTLE_ST_DIZZY + || status == BATTLE_ST_ENTWINE + || status == BATTLE_ST_DRAGNET + || status == BATTLE_ST_ICECRACK + || status == BATTLE_ST_ICEARROW + ){ + CHAR_setWorkInt( defindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)将(%s)做成(%s)(%d%%)", + // CHAR_getUseName( charaindex ), + // CHAR_getUseName( defindex ), + // aszStatusFull[status], + // perStatus + //); + + BATTLE_BadStatusString( ToList[i], status ); + } + } + + // 武器为远程武器时 + + if(((gWeponType == ITEM_BOW) + || (gWeponType == ITEM_BOUNDTHROW) + || (gWeponType == ITEM_BREAKTHROW) + || (gWeponType == ITEM_BOOMERANG)) && !bChange){ + snprintf( szCommand, sizeof( szCommand ), "r%X|f%X|d%X|p%X|", ToList[i], flg, damage, petdamage ); + BATTLESTR_ADD( szCommand ); + }else{ + snprintf( szCommand, sizeof( szCommand ), "BH|a%X|r%X|f%X|d%X|p%X|FF|", attackNo, ToList[i], flg, damage, petdamage); + BATTLESTR_ADD( szCommand ); + } + + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + j = ToList[i]-DefSide*SIDE_OFFSET; + if( ultimate > 0 ){ + BattleArray[battleindex].Side[DefSide].Entry[j].flg |= BENT_FLG_ULTIMATE; + } + + iRet = TRUE; + } + + // 武器为远程武器时 + if((( gWeponType == ITEM_BOW ) || ( gWeponType == ITEM_BOUNDTHROW ) || ( gWeponType == ITEM_BREAKTHROW ) || ( gWeponType == ITEM_BOOMERANG )) && !bChange){ + snprintf( szCommand, sizeof( szCommand ), "FF|" ); + BATTLESTR_ADD( szCommand ); + } + } + if(gWeponType == ITEM_BOOMERANG) gBattleDamageModyfy = 1.0; + break; + } +#ifdef _PROFESSION_ADDSKILL + case BATTLE_COM_S_BOUNDARY: // 四属性结界 + { + int ToList[SIDE_OFFSET*2+1],status=-1,power=20,toindex=-1,loop=1; + int defNo2 = defNo;//CHAR_getWorkInt(charaindex,CHAR_WORKBATTLECOM2); + int rand_boundary,rand_boundary2 = RAND( 1, 100 ); + + if( skill_level >= 10 ) turn = 5; + else if( skill_level > 9 ) turn = 4; + else if( skill_level > 8 ) turn = 3; + else if( skill_level > 4 ) turn = 2; + else turn = 1; + + skill_level = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + + if( skill_level >= 100 ) power = 100; + else if( skill_level > 95 ) power = 90; + else if( skill_level > 90 ) power = 80; + else if( skill_level > 85 ) power = 70; + else if( skill_level > 80 ) power = 60; + else if( skill_level > 60 ) power = 50; + else if( skill_level > 40 ) power = 40; + else if( skill_level > 20 ) power = 30; + else power = 20; + + if( ((pszP = strstr( pszOption, "地结界" ) ) != NULL ) ) + status = CHAR_WORKFIXEARTHAT_BOUNDARY; + else if( ((pszP = strstr( pszOption, "水结界" ) ) != NULL ) ) + status = CHAR_WORKFIXWATERAT_BOUNDARY; + else if( ((pszP = strstr( pszOption, "火结界" ) ) != NULL ) ) + status = CHAR_WORKFIXFIREAT_BOUNDARY; + else if( ((pszP = strstr( pszOption, "风结界" ) ) != NULL ) ){ + status = CHAR_WORKFIXWINDAT_BOUNDARY; + } + else{//破结界 + status = CHAR_WORKFIXEARTHAT_BOUNDARY; + + if( skill_level >= 100 ) rand_boundary = 100; + else if( skill_level > 80 ) rand_boundary = 80; + else if( skill_level > 40 ) rand_boundary = 70; + else if( skill_level > 20 ) rand_boundary = 60; + else rand_boundary = 50; + if( rand_boundary2 <= rand_boundary ){ + loop = 4; + power=0; + turn=0; + } + else + loop = 0; + } + + if( ((pszP = strstr( pszOption, "破结界" ) ) != NULL ) ){ + if( defNo2 < 10 )defNo2 = 20; else defNo2 = 21; + } + + memset( ToList, -1, sizeof( ToList)); + BATTLE_MultiList( battleindex, defNo2, ToList ); + + if( ((pszP = strstr( pszOption, "破结界" ) ) == NULL ) ){//先把所有结界清除 + for( j=CHAR_WORKFIXEARTHAT_BOUNDARY; j 0 ) { + playerdamage = (damage*petquick)/(defquick+petquick) +1; + petdamage = damage - playerdamage +1 ; + hp -= playerdamage; + pethp -= petdamage; + }else + hp -= damage; + } + work = CHAR_getWorkInt( defindex, CHAR_WORKDAMAGEREFLEC ) - 1; + CHAR_setWorkInt( defindex, CHAR_WORKDAMAGEREFLEC, max( work, 0 ) ); + defindex = attackindex; + defpet = attackpet; + + }else + if( *pRefrect == BATTLE_MD_TRAP ){ //陷阱 + int value=0; + value = CHAR_getWorkInt( defindex, CHAR_WORKMODTRAP ); + damage = value; + + hp = CHAR_getInt( attackindex, CHAR_HP ); + if( attackpet == -1 ) { + hp -= damage; + playerdamage = hp; + }else { + pethp = CHAR_getInt( attackpet, CHAR_HP ); + defquick = CHAR_getWorkInt( attackindex, CHAR_WORKDEFENCEPOWER ); + petquick = CHAR_getWorkInt( attackpet, CHAR_WORKDEFENCEPOWER ); + if( pethp > 0 ) { + playerdamage = (damage*petquick)/(defquick+petquick) +1; + petdamage = damage - playerdamage +1 ; + hp -= playerdamage; + pethp -= petdamage; + }else + hp -= damage; + } + + CHAR_setWorkInt( defindex, CHAR_WORKTRAP, 0 ); + CHAR_setWorkInt( defindex, CHAR_WORKMODTRAP, 0 ); + defindex = attackindex; + defpet = attackpet; + + }else +#ifdef _PETSKILL_ACUPUNCTURE +/* if( *pRefrect == BATTLE_MD_ACUPUNCTURE ){ + hp = CHAR_getInt( attackindex, CHAR_HP ); + if( attackpet == -1 ) { + hp -= ( damage/2 ? damage/2:1 ); + }else { + pethp = CHAR_getInt( attackpet, CHAR_HP ); + defquick = CHAR_getWorkInt( attackindex, CHAR_WORKDEFENCEPOWER ); + petquick = CHAR_getWorkInt( attackpet, CHAR_WORKDEFENCEPOWER ); + if( pethp > 0 ) { + playerdamage = (damage*petquick)/(defquick+petquick) +1; + petdamage = damage - playerdamage +1 ; + hp -= ( playerdamage/2 ? playerdamage/2:1 ); + pethp -= ( petdamage/2 ? petdamage/2:1 ); + }else + hp -= ( damage/2 ? damage/2:1 ); + } + //work = CHAR_getWorkInt( defindex, CHAR_WORKACUPUNCTURE ) - 1; + CHAR_setWorkInt( defindex, CHAR_WORKACUPUNCTURE, 0);//max( work, 0 ) ); + defindex = attackindex; + defpet = attackpet; + }*/ +#endif + if( react == BATTLE_MD_VANISH ){ + hp = CHAR_getInt( defindex, CHAR_HP ); + if( defpet != -1 ) + pethp = CHAR_getInt( defpet, CHAR_HP ); + work = CHAR_getWorkInt( defindex, CHAR_WORKDAMAGEVANISH ) - 1; + CHAR_setWorkInt( defindex, CHAR_WORKDAMAGEVANISH, max( work, 0 ) ); + *pRefrect = BATTLE_MD_VANISH; + }else{ + hp = CHAR_getInt( defindex, CHAR_HP ); + + if( defpet == -1 ) { + hp -= (damage * 0.7); + }else { + pethp = CHAR_getInt( defpet, CHAR_HP ); + if( pethp > 0 ) { + int rate=0; + rate = skill_level * 2 + 60; + + petdamage = damage * rate / 100; + playerdamage = damage - petdamage; + + hp -= playerdamage; + pethp -= petdamage; + + }else + hp -= damage; + } + *pRefrect = 0; + } + if( hp < 0 ){ + addpoint = -hp; + hp = 0; + } + maxhp = CHAR_getWorkInt( defindex, CHAR_WORKMAXHP ); + CHAR_setInt( defindex, CHAR_HP, min( hp, maxhp ) ); + if( defpet != -1 ) { + if( pethp < 0 ) pethp = 0; + petmaxhp = CHAR_getWorkInt( defpet, CHAR_WORKMAXHP ); + CHAR_setInt( defpet, CHAR_HP, min( pethp, petmaxhp ) ); + // Robin 0804 + if( pethp <= 0 ) { + CHAR_setInt( defindex, CHAR_RIDEPET, -1 ); + BATTLE_changeRideImage( defindex ); + CHAR_setWorkInt( defindex, CHAR_WORKPETFALL, 1 ); + print(" defpet_die! "); + } + } + + if( (damage) >= maxhp * 1.2 + 20 ){ + IsUltimate = 2; + }else{ + if( addpoint > 0 ){ + addpoint += CHAR_getWorkInt( defindex, CHAR_WORKULTIMATE ); + CHAR_setWorkInt( defindex, CHAR_WORKULTIMATE, addpoint ); + if( addpoint >= maxhp * 1.2 + 20 )IsUltimate = 1; + } + } + + if( BattleArray[battleindex].type == BATTLE_TYPE_P_vs_P ){ + } +#ifdef _PETSKILL_LER +// 雷尔不能被打飞 + if(CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101813 || + CHAR_getInt(defindex,CHAR_BASEBASEIMAGENUMBER) == 101814) IsUltimate = 0; +#endif + + if( IsUltimate ){ + CHAR_setWorkInt( defindex, CHAR_WORKULTIMATE, 0 ); + } + if( playerdamage < 0 ) playerdamage = 0; + if( petdamage < 0 ) petdamage = 0; + *pDamage = playerdamage; + *pPetDamage = petdamage; + return IsUltimate; +} + + +// 取得回旋攻击伤害 +int BATTLE_PROFESSION_CONVOLUTE_GET_DAMAGE( int attackindex, int defindex, int skill_level ) +{ + int damage = 0, old_atk = 0, atk = 0; + int rand_num = RAND(1, 10000 ); + // 会心一击 + int perCri = BATTLE_CriticalCheck( attackindex, defindex ); + + old_atk = CHAR_getWorkInt( attackindex, CHAR_WORKATTACKPOWER ); + atk = old_atk * (100 -( 50 - skill_level )) / 100; + CHAR_setWorkInt( attackindex, CHAR_WORKATTACKPOWER, atk ); + + if( rand_num < perCri ){ + damage = BATTLE_CriDamageCalc( attackindex, defindex ); + }else{ + //profession fix + if( BATTLE_DuckCheck( attackindex, defindex ) ) + return 0; + damage = BATTLE_DamageCalc( attackindex, defindex ); + } + + return damage; +} + +// 取得贯穿攻击伤害 +int BATTLE_PROFESSION_THROUGH_ATTACK_GET_DAMAGE( int attackindex, int defindex ) +{ + int damage = 0; + int rand_num = RAND(1, 10000 ); + // 会心一击 + int perCri = BATTLE_CriticalCheck( attackindex, defindex ); + + if( rand_num < perCri ){ + damage = BATTLE_CriDamageCalc( attackindex, defindex ); + }else{ + //profession fix + if( BATTLE_DuckCheck( attackindex, defindex ) ) + return 0; + damage = BATTLE_DamageCalc( attackindex, defindex ); + } + + return damage; +} + +// 火、冰、雷附体附加攻击 +int BATTLE_PROFESSION_RANG_ATTACK_DAMAGE( int charaindex, int attackNo, int defNo, int skill_type, int status, int turn, int perStatus, int effect, int img1, int img2 ) +{ + int ReactType = 0, iRet = -1,defindex = -1,react = 0; + int battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + //char szBuffer[256]=""; + + //memset( szBuffer, 0, sizeof( szBuffer ) ); + + defindex = BATTLE_No2Index( battleindex, defNo); //守方index + if( defindex == -1 ) return iRet; + + if( (ReactType=BATTLE_GetDamageReact( defindex)) > 0 ){ //有光镜守 + react = ReactType; + skill_type=-1; + } + + if( img1 != 0 ){ + if( (PROFESSION_BATTLE_StatusAttackCheck( charaindex, defindex, status, perStatus ) == 0 ) + || (CHAR_getInt( defindex, CHAR_HP ) <= 0 ) ){ + //snprintf( szBuffer, sizeof(szBuffer), "(%s)无法将(%s)做成(%s)(%d%%)", + // CHAR_getUseName( charaindex ), CHAR_getUseName( defindex ), aszStatusFull[status], perStatus ); + //BATTLE_BroadCast( battleindex, szBuffer,(attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + } + else{ + CHAR_setWorkInt( defindex, StatusTbl[status], turn + 1 ); + + if( status == BATTLE_ST_PARALYSIS + || status == BATTLE_ST_SLEEP + || status == BATTLE_ST_STONE + || status == BATTLE_ST_BARRIER + || status == BATTLE_ST_DIZZY + || status == BATTLE_ST_ENTWINE + || status == BATTLE_ST_DRAGNET + || status == BATTLE_ST_ICECRACK + || status == BATTLE_ST_ICEARROW + ) CHAR_setWorkInt( defindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)将(%s)做成(%s)(%d%%)", + // CHAR_getUseName( charaindex ), + // CHAR_getUseName( defindex ), + // aszStatusFull[status], + // perStatus + // ); + + BATTLE_BadStatusString( defNo, status ); + iRet = TRUE; + } + //BATTLE_BroadCast( battleindex, szBuffer,(attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + } + + return iRet; +} + +#endif + +#ifdef _PETSKILL_LER +extern ToCallMagic PROFESSION_magic[3]; +// 雷尔技 - 群蝠四窜 +void BATTLE_BatFly( int battleindex, int attackNo,int myside) +{ + int ToList[SIDE_OFFSET*2+1],i,toindex; + int petidx,addhp = 0,charhp,pethp,charaindex; + char szCommand[1024]; + + charaindex = BATTLE_No2Index(battleindex,attackNo); + if(CHAR_CHECKINDEX(charaindex) == FALSE) return; + + memset(ToList,-1,sizeof(ToList)); + if(myside) BATTLE_MultiList(battleindex,TARGET_SIDE_0,ToList); // 打右上 + else BATTLE_MultiList(battleindex,TARGET_SIDE_1,ToList); // 打左下 + + PROFESSION_magic[2].uiSpriteNum = myside ? 101806:101807; + PROFESSION_magic[2].siSx = 320; + PROFESSION_magic[2].siSy = 240; + PROFESSION_magic[2].uiPrevMagicNum = myside ? 101808:101809; // 前置动画 + PROFESSION_magic[2].uiPostMagicNum = 0xffffffff; // 无後置动画 + PROFESSION_magic[2].uiShowType = 1; + PROFESSION_magic[2].uiShowBehindChar = 1; + PROFESSION_magic[2].siPrevMagicSx = 0; + PROFESSION_magic[2].siPrevMagicSy = 0; + PROFESSION_MAGIC_ATTAIC_Effect(battleindex,attackNo,ToList,2); + sprintf(szCommand,"%X|",0x5711438); + BATTLESTR_ADD(szCommand); + + for(i=0;i CHAR_getWorkInt(charaindex,CHAR_WORKMAXHP)){ + CHAR_setInt(charaindex,CHAR_HP,CHAR_getWorkInt(charaindex,CHAR_WORKMAXHP)); + addhp = 0; + } + else CHAR_setInt(charaindex,CHAR_HP,CHAR_getInt(charaindex,CHAR_HP) + addhp); + sprintf(szCommand,"BD|r%X|%X|1|d%X|p0|",attackNo,BD_KIND_HP,addhp); + BATTLESTR_ADD(szCommand); +} + +// 雷尔技 - 分身地裂 +void BATTLE_DivideAttack( int battleindex, int attackNo,int myside) +{ + int ToList[SIDE_OFFSET*2+1],i,toindex; + int petidx,charhp,charmp,pethp,charaindex; + char szCommand[1024]; + + charaindex = BATTLE_No2Index(battleindex,attackNo); + if(CHAR_CHECKINDEX(charaindex) == FALSE) return; + + memset(ToList,-1,sizeof(ToList)); + if(myside) BATTLE_MultiList(battleindex,TARGET_SIDE_0,ToList); // 打左上 + else BATTLE_MultiList(battleindex,TARGET_SIDE_1,ToList); // 打右下 + + PROFESSION_magic[2].uiSpriteNum = myside ? 101798:101800; + PROFESSION_magic[2].siSx = 320; + PROFESSION_magic[2].siSy = 240; + PROFESSION_magic[2].uiPrevMagicNum = myside ? 101808:101809; // 前置动画 + PROFESSION_magic[2].uiPostMagicNum = 0xffffffff; // 无後置动画 + PROFESSION_magic[2].uiShowType = 1; + PROFESSION_magic[2].uiShowBehindChar = 0; + PROFESSION_magic[2].siPrevMagicSx = 0; + PROFESSION_magic[2].siPrevMagicSy = 0; + PROFESSION_MAGIC_ATTAIC_Effect(battleindex,attackNo,ToList,2); + sprintf(szCommand,"%X|",0x5711438); + BATTLESTR_ADD(szCommand); + + // 先完成扣MP的动作 + for(i=0;i>1)); + charmp >>= 1; + sprintf(szCommand,"BD|r%X|%X|0|d%X|",ToList[i],BD_KIND_MP,charmp); + BATTLESTR_ADD(szCommand); + } + } + for(i=0;i 10 ? 1:0); + } + else if(CHAR_getInt(charaindex,CHAR_BASEBASEIMAGENUMBER) == 101814){ + array = ENEMY_getEnemyArrayFromId(2510); + if(array == -1) return; + newindex = ENEMY_createEnemy(array,300); + if(newindex == -1) return; + CHAR_setWorkInt(newindex,CHAR_WORK_RELIFE,101811); + CHAR_setWorkInt(newindex,CHAR_WORKBATTLESIDE,no > 10 ? 1:0); + } + pBattle = &BattleArray[battleindex]; + pEntry = pBattle->Side[no > 10 ? 1:0].Entry; + pEntry[no > 10 ? no-10:no].charaindex = newindex; +} +#endif + +#ifdef _PETSKILL_BATTLE_MODEL +typedef struct _tsAttackObject{ + int index; // 攻击物件编号 + int target; // 目标编号 + int actionNumber; // 攻击物件图号 +}AttackObject; +// BATTLE_BattleModel 用的攻击函式 +void BATTLE_BattleModel_ATTACK( + int battleindex, + int charaindex, + AttackObject *pAAttackObject, + int iEffect, + int iTurn, + int iEffectHit, + int iType) +{ + int i,iDefindex,iPetindex,iToindex,iDamage,iPetDamage,iGuardian = -1,iDefState,iUltimate = 0,iTemp = 0,iTemp2 = 0,iFlg = 0; + char szCommand[1024]; + + // 检查目标存不存在或有没有死亡 + if(!BATTLE_TargetCheck(battleindex,pAAttackObject->target)) return; + iToindex = iDefindex = BATTLE_No2Index(battleindex,pAAttackObject->target); + // 若是宠物,检查主人在不在场上 + if(CHAR_getInt(iToindex,CHAR_WHICHTYPE ) == CHAR_TYPEPET){ + if(pAAttackObject->target + 5 >= SIDE_OFFSET) iFlg = 1; + i = pAAttackObject->target + 5 - iFlg * SIDE_OFFSET; + if(BattleArray[battleindex].Side[iFlg].Entry[i].flg & BENT_FLG_ULTIMATE) return; + } + iPetindex = BATTLE_getRidePet(iToindex); + // 计算伤害 + iDefState = BATTLE_AttackSeq(charaindex,iToindex,&iDamage,&iGuardian,-1); + // iType & 0x00000004 为 true 表示为物理攻击 + if(iType & 0x00000004){ + // 若忠犬没死亡,设定忠犬 + if(BATTLE_TargetCheck(battleindex,iGuardian)){ + // 若有忠犬,把被攻击者设定为使用忠犬技能的角色,否则被攻击者为原目标 + if(iGuardian >= 0) iDefindex = BATTLE_No2Index(battleindex,iGuardian); + } + else iGuardian = -1; + } + // 设定 CHAR_NPCWORKINT1 为 BATTLE_COM_S_BATTLE_MODEL 在 BATTLE_DamageSub 会用到 + iTemp2 = CHAR_getWorkInt(iDefindex,CHAR_NPCWORKINT1); + CHAR_setWorkInt(iDefindex,CHAR_NPCWORKINT1,BATTLE_COM_S_BATTLE_MODEL); + // 在这之後的 iDefindex 才是真正会受伤的目标 + if(gDamageDiv != 0.0 && iDamage > 0){ + iDamage /= gDamageDiv; + if(iDamage <= 0) iDamage = 1; + } + // 若没有下列任一项,进行扣血 + if(!(iDefState == BATTLE_RET_DODGE)){ + // 扣血 + // 物理攻击 + if(iType & 0x00000004) iUltimate = BATTLE_DamageSub(charaindex,iDefindex,&iDamage,&iPetDamage,&iTemp); + // 非物理攻击 + else{ + iTemp = -1; + iUltimate = BATTLE_DamageSub(charaindex,iDefindex,&iDamage,&iPetDamage,&iTemp); + } + } + iFlg = 0; + // 回传状态检查 + switch(iDefState){ + case BATTLE_RET_ALLGUARD:iFlg |= BCF_GUARD;break; + case BATTLE_RET_MISS:iDamage = 0;break; + case BATTLE_RET_DODGE:iDamage = 0;iFlg |= BCF_DODGE;break; + case BATTLE_RET_NORMAL: + iFlg |= BATTLE_getReactFlg(iDefindex,iTemp); + iFlg |= BCF_NORMAL; + break; + case BATTLE_RET_CRITICAL: + iFlg |= BATTLE_getReactFlg(iDefindex,iTemp); + iFlg |= BCF_KAISHIN; + break; +#ifdef _EQUIT_ARRANGE + case BATTLE_RET_ARRANGE:iFlg |= BCF_B_ARRANGE;break; +#endif + } + + //昏睡时,在这里解除状态(也有其它的状态) + if(iDamage > 0 && (iTemp != BATTLE_MD_ABSROB) && (iTemp != BATTLE_MD_VANISH)) BATTLE_DamageWakeUp(battleindex,iDefindex); + + // 目标是否死亡 + if(CHAR_getInt(iDefindex,CHAR_HP) <= 0){ + if(CHAR_getWorkInt(iDefindex,CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_ABIO) iUltimate = 1; + else if(CHAR_getInt(iDefindex,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER && (iFlg & BCF_KAISHIN)){ + if(RAND(1,100) < 50) iUltimate = 1; + } +#ifdef _PETSKILL_LER + // 雷尔不能被打飞 + if(CHAR_getInt(iDefindex,CHAR_BASEBASEIMAGENUMBER) == 101813 || + CHAR_getInt(iDefindex,CHAR_BASEBASEIMAGENUMBER) == 101814) iUltimate = 0; +#endif + iFlg |= BCF_DEATH; + if(iUltimate == 1) iFlg |= BCF_ULTIMATE_1; + if(iUltimate == 2) iFlg |= BCF_ULTIMATE_2; + } + else{ +#ifdef _TAKE_ITEMDAMAGE + if(BATTLE_ItemCrushSeq(charaindex,iDefindex,iDamage) == TRUE) +#else + if(BATTLE_ItemCrushSeq(iDefindex) == TRUE) +#endif + iFlg |= BCF_CRUSH; + // 状态命中判定 + if(iDamage > 0 && BATTLE_StatusAttackCheck(charaindex,iDefindex,iEffect,iEffectHit,30,1.0,&iTemp)){ + CHAR_setWorkInt(iDefindex,StatusTbl[iEffect],iTurn); + if(iEffect == BATTLE_ST_DRUNK) CHAR_setWorkInt(iDefindex,CHAR_WORKDRUNK,CHAR_getWorkInt(iDefindex,CHAR_WORKDRUNK) >> 1); + // 中以下状态的目标该回合之後不能行动 + if(iEffect == BATTLE_ST_PARALYSIS || iEffect == BATTLE_ST_SLEEP || iEffect == BATTLE_ST_STONE || iEffect == BATTLE_ST_BARRIER) + CHAR_setWorkInt(iDefindex,CHAR_WORKBATTLECOM1,BATTLE_COM_NONE); + // 回传client那一个目标要执行状态改变 + if(iGuardian >= 0) BATTLE_BadStatusString(iGuardian,iEffect); // iGuardian 大於等於 0 表示有目标使用了忠犬,该目标状态改变 + else BATTLE_BadStatusString(pAAttackObject->target,iEffect); // 否则原目标状态改变 + } + } + + if(iGuardian >= 0){ + iFlg |= BCF_GUARDIAN; + snprintf(szCommand,sizeof(szCommand), + "r%X|i%X|f%X|d%X|p%X|a%X|g%X|", + pAAttackObject->target, + pAAttackObject->index, + iFlg, + iDamage, + iPetDamage, + pAAttackObject->actionNumber, + iGuardian); + }else + snprintf(szCommand,sizeof(szCommand), + "r%X|i%X|f%X|d%X|p%X|a%X|", + pAAttackObject->target, + pAAttackObject->index, + iFlg, + iDamage, + iPetDamage, + pAAttackObject->actionNumber); + + // 把命令送入传给client的buffer + BATTLESTR_ADD(szCommand); + + iTemp = BATTLE_Index2No(battleindex,iDefindex); + + // iFlg 已没作用,拿来作别的用途 + iFlg = 0; + if(iTemp >= SIDE_OFFSET) iFlg = 1; + + i = iTemp - iFlg * SIDE_OFFSET; + if(iUltimate > 0) BattleArray[battleindex].Side[iFlg].Entry[i].flg |= BENT_FLG_ULTIMATE; + CHAR_setWorkInt(iDefindex,CHAR_NPCWORKINT1,iTemp2); +} + +void BATTLE_BattleModel(int battleindex,int attackNo,int myside) +{ + int iToList[SIDE_OFFSET*2+1],i,i0,i1,i2,iEffect = -1,iTurn = -1,iEffectHit = 0,iType,iObjectNum,charaindex; + int iActionNumber[4] = {-1,-1,-1,-1},iActionAmount = 0; + char szData[32],szData2[32],*pszOption = NULL; + AttackObject AAttackObject[10]; + + charaindex = BATTLE_No2Index(battleindex,attackNo); + if(CHAR_CHECKINDEX(charaindex) == FALSE) return; + + pszOption = PETSKILL_getChar(CHAR_getWorkInt(charaindex,CHAR_WORKBATTLECOM3),PETSKILL_OPTION); + + if(pszOption == NULL){ + printf("BATTLE_BattleModel: read PETSKILL_OPTION error!!(array:%d,file:%s,line:%d)\n", + CHAR_getWorkInt(charaindex,CHAR_WORKBATTLECOM3),__FILE__,__LINE__); + return; + } + + // 取得效果 + if(getStringFromIndexWithDelim(pszOption,"|",3,szData,sizeof(szData)) != FALSE){ + for(i=1;i= iActionAmount) i1 = 0; + } + + // 检查场上目标剩几只 + for(i=0;i= i){ + i0 = i; // 记录场上目标只数 + + for(i=0;i +#include "char.h" +#include "char_base.h" +#include "battle.h" +#include "battle_event.h" +#include "battle_item.h" +#include "battle_magic.h" +#include "item_event.h" +#include "log.h" +#include "anim_tbl.h" +#include "npcutil.h" +#include "magic_base.h" +#include "lssproto_serv.h" + + +int BATTLE_ItemUseDelete( + int charaindex, + int haveitemindex +) +{ + int itemindex; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( ITEM_CHECKINDEX( itemindex ) == FALSE ) return 0; + { + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), +#endif + "BattleUse(战斗中使用掉的道具)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + CHAR_DelItemMess( charaindex, haveitemindex, 0); + + return 0; +} + +#ifdef _IMPRECATE_ITEM +void ITEM_useImprecate( int charaindex, int toNo, int haveitemindex ) +{ + int i; + int battleindex, attackNo,itemindex; + char *arg; + char buf[256]; + + struct tagImprecate { + char fun[256]; + int intfun; + }; + struct tagImprecate ImList[3] ={ + {"咒",BD_KIND_CURSE},{"恩",BD_KIND_BESTOW},{"祝",BD_KIND_WISHES} }; + + if( !CHAR_CHECKINDEX( charaindex) ) return; + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + + if( (attackNo = BATTLE_Index2No( battleindex, charaindex )) < 0 ){ + print( "ANDY attackNo=%d\n", attackNo); + return; + } + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + arg = ITEM_getChar(itemindex, ITEM_ARGUMENT ); + if( arg == NULL ){ + print( "ANDY ITEM id:%d=>arg err\n", ITEM_getInt( itemindex, ITEM_ID)); + return; + } + + for( i=0; i<3; i++) { + if( strstr( arg, ImList[i].fun ) != 0 ) { + char buf1[256]; + int kind,powers, rounds, HealedEffect; + + if( NPC_Util_GetStrFromStrWithDelim( arg, ImList[i].fun, buf, sizeof( buf)) == NULL )continue; + kind = ImList[i].intfun; + if( getStringFromIndexWithDelim( buf,"x", 1, buf1, sizeof( buf1)) == FALSE ) continue; + powers = atoi( buf1); + if( getStringFromIndexWithDelim( buf,"x", 2, buf1, sizeof( buf1)) == FALSE ) continue; + rounds = atoi( buf1); + HealedEffect = SPR_hoshi; + BATTLE_ImprecateRecovery( + battleindex, attackNo, toNo, kind, powers, + rounds, SPR_item3, HealedEffect ); + CHAR_setItemIndex(charaindex, haveitemindex ,-1); + CHAR_sendItemDataOne( charaindex, haveitemindex); + ITEM_endExistItemsOne( itemindex ); + break; + } + } +} +#endif + +#ifdef _ITEM_MAGICRECOVERY +void ITEM_useMRecovery_Battle( int charaindex, int toNo, int haveitemindex ) +{ + int battleindex, attackNo, itemindex; + int turn=0, magicid, marray; + char buf1[256]; + char *arg=NULL; + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + if( BATTLE_CHECKINDEX( battleindex ) == FALSE ) return; + if( (attackNo = BATTLE_Index2No( battleindex, charaindex )) == -1 ) return; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + arg = ITEM_getChar( itemindex, ITEM_ARGUMENT ); + + + if( getStringFromIndexWithDelim( arg, ":", 2, buf1, sizeof(buf1)) ==FALSE ) return; + turn = atoi( buf1); + if( getStringFromIndexWithDelim( arg, ":", 1, buf1, sizeof(buf1)) ==FALSE ) return; + + if( strstr( buf1, "全" ) != NULL ){ + }else{ + } + + magicid = ITEM_getInt( itemindex, ITEM_MAGICID); + marray = MAGIC_getMagicArray( magicid); + if( marray == -1 ) return; + + + if( IsBATTLING( charaindex ) == TRUE ){ + int i, status=-1; + char *magicarg=NULL, *pszP=NULL; +#ifdef _PREVENT_TEAMATTACK //光镜守..不得使用敌方 + int battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER + //&& BattleArray[battleindex].type != BATTLE_TYPE_P_vs_P + ){ + if( BATTLE_CheckSameSide( charaindex, toNo) == 0 ){//不同边 + int battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + BATTLE_NoAction( battleindex, BATTLE_Index2No( battleindex, charaindex) ); + CHAR_talkToCli( charaindex, -1, "光镜守..不得施予非玩家敌方。", CHAR_COLORYELLOW); + return; + } + } +#endif + + magicarg = MAGIC_getChar( marray, MAGIC_OPTION ); + pszP = magicarg; + for( ;status == -1 && pszP[0] != 0; pszP++ ){ + for( i = 1; i < BATTLE_MD_END; i ++ ){ + if( strncmp( pszP, aszMagicDef[i], 2 ) == 0 ){ + status = i; + pszP +=2; + break; + } + } + } + if( status == -1 ) return; + + BATTLE_MultiMagicDef( battleindex, attackNo, toNo, + status, turn, MAGIC_EFFECT_USER, SPR_difence ); + + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), +#endif + "BattleUse(战斗中使用掉的道具)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + + CHAR_DelItemMess( charaindex, haveitemindex, 0); +} +#endif + +#ifdef _ITEM_USEMAGIC +void ITEM_useMagic_Battle( int charaindex, int toNo, int haveitemindex ) +{ + int itemindex,itemmaxuse; + char *arg=NULL; + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + arg = ITEM_getChar( itemindex, ITEM_ARGUMENT ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_JYUJYUTU ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, atoi(arg) ); + CHAR_SETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + MAGIC_DirectUse( + charaindex, + CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3 ), + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ), + CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3 ) + ); + + itemmaxuse = ITEM_getInt( itemindex, ITEM_DAMAGEBREAK); + if( itemmaxuse > 0 ) + ITEM_setInt( itemindex, ITEM_DAMAGEBREAK, itemmaxuse-1 ); + else{ + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), +#endif + "BattleUse(战斗中使用掉的道具)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + + CHAR_DelItemMess( charaindex, haveitemindex, 0); + } +} +#endif + +void ITEM_useRecovery_Battle( int charaindex, int toNo, int haveitemindex ) +{ +#ifdef _CHANGEITEMUSE // Syu ADD 调整战斗中使用料理设定 + int power1 = 0; +#endif + int power = 0, per = 0, HealedEffect=0; + int battleindex, attackNo,itemindex, kind = BD_KIND_HP; + char *p = NULL, *arg; + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + arg = ITEM_getChar(itemindex, ITEM_ARGUMENT ); +#ifdef _CHANGEITEMUSE // Syu ADD 调整战斗中使用料理设定 + if( ((p = strstr( arg, "体" )) != NULL) && ((p = strstr( arg,"气")) != NULL)) + { + kind = BD_KIND_HP_MP; + p = strstr( arg,"气"); + if( sscanf( p+2, "%d", &power1 ) != 1 ) + { + power1 = 0; + } + p = strstr( arg,"体"); + } + else if( (p = strstr( arg, "体" )) != NULL ) +#else + if( (p = strstr( arg, "体" )) != NULL ) +#endif + { + kind = BD_KIND_HP; + } + else if( (p = strstr( arg, "气" )) != NULL ) + { + kind = BD_KIND_MP; + } + else +#ifdef _ITEM_UNBECOMEPIG + if( (p = strstr( arg, "解猪" )) != NULL ){ + kind = BD_KIND_UNBECOMEPIG; + HealedEffect = 100608; //特效编号 + } + else +#endif +#ifdef _ITEM_LVUPUP + if( (p = strstr( arg, "LVUPUP" )) != NULL ){ + return; + } + else +#endif +#ifdef _ITEM_PROPERTY + if( (p = strstr( arg, "PROPERTY" )) != NULL ){ + kind = BD_KIND_PROPERTY; + HealedEffect = 100608; //特效编号 + if( strstr( arg, "+" ) ) + power = 1; + else if( strstr( arg, "-" ) ) + power = 2; + } + else +#endif +#ifdef _ITEM_ADDPETEXP + if( (p = strstr( arg, "GETEXP" )) != NULL ){ + return; + } + else +#endif + return; + +#ifdef _ITEM_UNBECOMEPIG + if( HealedEffect != 100608 ){ +#endif + if( sscanf( p+2, "%d", &power ) != 1 ) + power = 0; + if( power <= 100 ) + HealedEffect = SPR_heal;//SPR_hoshi + else if( power <= 300 ) + HealedEffect = SPR_heal2; + else + HealedEffect = SPR_heal3; +#ifdef _ITEM_UNBECOMEPIG + } +#endif + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + attackNo = BATTLE_Index2No( battleindex, charaindex ); + if( attackNo < 0 )return; + +#ifdef _CHANGEITEMUSE // Syu ADD 调整战斗中使用料理设定 + BATTLE_MultiRecovery( battleindex, attackNo, toNo, + kind, power, per, SPR_item3, HealedEffect , power1); +#else + BATTLE_MultiRecovery( battleindex, attackNo, toNo, + kind, power, per, SPR_item3, HealedEffect ); +#endif + { + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), +#endif + "BattleUse(战斗中使用掉的道具)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + CHAR_DelItemMess( charaindex, haveitemindex, 0); +} + +void ITEM_useStatusChange_Battle( + int charaindex, + int toNo, + int haveitemindex +){ + int turn = 0, i; + int battleindex, attackNo,itemindex, status = -1, Success = 15; + int ReceveEffect; + char *pszP = NULL, *arg; + char szTurn[] = "turn"; + char szSuccess[] = "成"; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + arg = ITEM_getChar(itemindex, ITEM_ARGUMENT ); + pszP = arg; + for( ;status == -1 && pszP[0] != 0; pszP++ ){ + for( i = 0; i < BATTLE_ST_END; i ++ ){ + if( strncmp( pszP, aszStatus[i], 2 ) == 0 ){ + status = i; + pszP +=2; + break; + } + } + } + if( status == -1 ) return ; + if( ( pszP = strstr( arg, szTurn ) ) != NULL){ + pszP += sizeof( szTurn ); + sscanf( pszP, "%d", &turn ); + } + if( ( pszP = strstr( arg, szSuccess ) ) != NULL){ + pszP += sizeof( szSuccess ); + sscanf( pszP, "%d", &Success ); + } + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + attackNo = BATTLE_Index2No( battleindex, charaindex ); + + if( status == BATTLE_ST_NONE ){ + ReceveEffect = SPR_tyusya; + }else{ + ReceveEffect = SPR_hoshi; + } + BATTLE_MultiStatusChange( battleindex, attackNo, toNo, + status, turn, SPR_item3, ReceveEffect, Success ); + BATTLE_ItemUseDelete( charaindex, haveitemindex ); +} + +void ITEM_useStatusRecovery_Battle( + int charaindex, // 银匀凶谛及奶件犯永弁旦 + int toNo, // 银歹木月谛及 寞 + int haveitemindex // 银丹谛及失奶 丞及 寞 +){ + int i; + int battleindex, attackNo,itemindex, status = -1; + int ReceveEffect; + char *pszP = NULL, *arg; + + // 失奶 丞互丐月井升丹井 + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + // 由仿丢□正毛潸 + arg = ITEM_getChar(itemindex, ITEM_ARGUMENT ); + + pszP = arg; + // 躲绊毛潸 + for( ;status == -1 && pszP[0] != 0; pszP++ ){ + // 蝈莒手丐月及匹ㄟ井日腹绸 + for( i = 0; i < BATTLE_ST_END; i ++ ){ + // 躲绊疋永正伉井" + if( strncmp( pszP, aszStatus[i], 2 ) == 0 ){ + status = i; + pszP +=2; + break; + } + } + } + // 躲绊卅中及匹撩 + if( status == -1 ) return ; + + //------- 仇仇井日荚汊质 ----------- + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + + attackNo = BATTLE_Index2No( battleindex, charaindex ); + + ReceveEffect = SPR_tyusya; // 月午五反仇木 + + // 蝈够 + BATTLE_MultiStatusRecovery( battleindex, attackNo, toNo, + status, SPR_item3, ReceveEffect ); + + // 爵 卞失奶 丞互壅尹凶桦宁及隋骚质 + BATTLE_ItemUseDelete( charaindex, haveitemindex ); + +} + + + + + + +void ITEM_useMagicDef_Battle( + int charaindex, + int toNo, + int haveitemindex +) +{ + int turn = 0, i; + int battleindex, attackNo,itemindex, status = -1; + char *pszP = NULL, *arg; + + char szTurn[] = "turn"; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + arg = ITEM_getChar(itemindex, ITEM_ARGUMENT ); + + pszP = arg; + + for( ;status == -1 && pszP[0] != 0; pszP++ ){ + for( i = 1; i < BATTLE_MD_END; i ++ ){ + if( strncmp( pszP, aszMagicDef[i], 2 ) == 0 ){ + status = i; + pszP +=2; + break; + } + } + } + + if( status == -1 ) return ; + + if( ( pszP = strstr( arg, szTurn ) ) != NULL){ + pszP += sizeof( szTurn ); + sscanf( pszP, "%d", &turn ); + } + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + + attackNo = BATTLE_Index2No( battleindex, charaindex ); + + BATTLE_MultiMagicDef( battleindex, attackNo, toNo, + status, turn, SPR_item3, SPR_difence ); + + BATTLE_ItemUseDelete( charaindex, haveitemindex ); + + +} + + + + + + +//-------------------------------------------------------------- +// 由仿丢□正 凳失奶 丞毛银匀凶桦宁及质 +//-------------------------------------------------------------- +// 爵 及桦宁 +void ITEM_useParamChange_Battle( + int charaindex, // 银匀凶谛及奶件犯永弁旦 + int toNo, // 银歹木月谛及 寞 + int haveitemindex // 银丹谛及失奶 丞及 寞 +) +{ + int i; + int battleindex, attackNo,itemindex; + int pow, par = 0; + int kind = -1; + char *pszP = NULL, *arg; + + // 失奶 丞互丐月井升丹井 + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + // 由仿丢□正毛潸 + arg = ITEM_getChar(itemindex, ITEM_ARGUMENT ); + + pszP = arg; + // 躲绊毛潸 + for( ;kind == -1 && pszP[0] != 0; pszP++ ){ + for( i = 1; i < BATTLE_MD_END; i ++ ){ + // 躲绊疋永正伉井" + if( strncmp( pszP, aszParamChange[i], 2 ) == 0 ){ + kind = i; + pszP +=2; + break; + } + } + } + // 躲绊卅中及匹撩 + if( kind == -1 ) return ; + + + if( strstr( pszP, "%" ) ){ // 仇及桦宁反⊙煌遥 + par = 1; + } + + if( sscanf( pszP, "%d", &pow ) != 1 ){ + // 窒禾奶件玄丐仆月井 + pow = 30; + } + + //------- 仇仇井日质 ----------- + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + + attackNo = BATTLE_Index2No( battleindex, charaindex ); + + // 蝈够 + BATTLE_MultiParamChange( battleindex, attackNo, toNo, + kind, pow, par, SPR_item3, SPR_hoshi ); + + + // 爵 卞失奶 丞互壅尹凶桦宁及隋骚质 + BATTLE_ItemUseDelete( charaindex, haveitemindex ); + + +} + + + + + + +//-------------------------------------------------------------- +// 白奴□伙玉箪岭 凳失奶 丞毛银匀凶桦宁及质 +//-------------------------------------------------------------- +// 爵 及桦宁 +void ITEM_useFieldChange_Battle( + int charaindex, // 银匀凶谛及奶件犯永弁旦 + int toNo, // 银歹木月谛及 寞 + int haveitemindex // 银丹谛及失奶 丞及 寞 +) +{ + int itemindex; + char *pArg; + + // 失奶 丞互丐月井升丹井 + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + //------- 仇仇井日质 ----------- + // 由仿丢□正毛潸 + pArg = ITEM_getChar(itemindex, ITEM_ARGUMENT ); + + // 由仿丢□正 中及匹撩 + if( pArg == NULL )return ; + + BATTLE_FieldAttChange( charaindex, pArg ); + + // 爵 卞失奶 丞互壅尹凶桦宁及隋骚质 + BATTLE_ItemUseDelete( charaindex, haveitemindex ); + +} + + +//-------------------------------------------------------------- +// 箪岭 鳖失奶 丞毛银匀凶桦宁及质 +//-------------------------------------------------------------- +// 爵 及桦宁 +void ITEM_useAttReverse_Battle( + int charaindex, // 银匀凶谛及奶件犯永弁旦 + int toNo, // 银歹木月谛及 寞 + int haveitemindex // 银丹谛及失奶 丞及 寞 +) +{ + int itemindex, battleindex, attackNo; + + + // 失奶 丞互丐月井升丹井 + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + //------- 仇仇井日质 ----------- + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + + attackNo = BATTLE_Index2No( battleindex, charaindex ); + + // 蝈够 + BATTLE_MultiAttReverse( battleindex, attackNo, toNo, + SPR_item3, SPR_kyu ); + + // 爵 卞失奶 丞互壅尹凶桦宁及隋骚质 + BATTLE_ItemUseDelete( charaindex, haveitemindex ); + + +} + + +//-------------------------------------------------------------- +// 竣濮井日汊唾毛银匀凶桦宁及质 +//-------------------------------------------------------------- +// 爵 及桦宁 +void ITEM_useRessurect( + int charaindex, // 银匀凶谛及奶件犯永弁旦 + int toNo, // 银歹木月谛及 寞 + int haveitemindex // 银丹谛及失奶 丞及 寞 +) +{ + int itemindex, battleindex, attackNo, par = 0, pow = 0, ReceveEffect; + char *pszP = NULL; + + + // 失奶 丞互丐月井升丹井 + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + //------- 仇仇井日质 ----------- + pszP = ITEM_getChar(itemindex, ITEM_ARGUMENT ); + + if( strstr( pszP, "%" ) ){ // 仇及桦宁反⊙煌遥 + par = 1; + } + + if( sscanf( pszP, "%d", &pow ) != 1 ){ + // 窒禾奶件玄荚汊允月井" + pow = 0; // ㄟ及桦宁反敦蝈荚汊 + } + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + + attackNo = BATTLE_Index2No( battleindex, charaindex ); + + if( pow <= 0 ){ + ReceveEffect = SPR_fukkatu3; + }else + if( pow <= 100 ){ + ReceveEffect = SPR_fukkatu1; + }else + if( pow <= 300 ){ + ReceveEffect = SPR_fukkatu2; + }else{ + ReceveEffect = SPR_fukkatu3; + } + + // 蝈够 + BATTLE_MultiRessurect( battleindex, attackNo, toNo, + pow, par, SPR_item3, ReceveEffect ); + + + // 爵 卞失奶 丞互壅尹凶桦宁及隋骚质 + BATTLE_ItemUseDelete( charaindex, haveitemindex ); + +} + + + +//-------------------------------------------------------------- +// 凯 膜恳毛银匀凶桦宁及质 +//-------------------------------------------------------------- +// 爵 及桦宁 +void ITEM_useCaptureUp_Battle( + int charaindex, // 银匀凶谛及奶件犯永弁旦 + int toNo, // 银歹木月谛及 寞 + int haveitemindex // 银丹谛及失奶 丞及 寞 +) +{ + int itemindex, battleindex, attackNo, pow = 5, ReceveEffect; + char *pArg; + + // 失奶 丞互丐月井升丹井 + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + //------- 仇仇井日质 ----------- + // 由仿丢□正毛潸 + pArg = ITEM_getChar(itemindex, ITEM_ARGUMENT ); + + // 由仿丢□正 中及匹撩 + if( pArg == NULL )return ; + + if( sscanf( pArg, "%d", &pow ) != 1 ){ + // 窒禾奶件玄荚汊允月井" + pow = 5; + } + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + + attackNo = BATTLE_Index2No( battleindex, charaindex ); + + ReceveEffect = SPR_hoshi; + + // 蝈够 + BATTLE_MultiCaptureUp( battleindex, attackNo, toNo, + pow, SPR_item3, ReceveEffect ); + + // 爵 卞失奶 丞互壅尹凶桦宁及隋骚质 + BATTLE_ItemUseDelete( charaindex, haveitemindex ); + +} +#ifdef _ITEM_CRACKER +void ITEM_useCracker_Effect( charaindex, toindex, haveitemindex) +{ + int itemindex,x,y,tofd; + + itemindex = CHAR_getItemIndex(charaindex,haveitemindex); + // 检查物品 + if(!ITEM_CHECKINDEX(itemindex)) return; + + x = CHAR_getInt( charaindex, CHAR_X); + y = CHAR_getInt( charaindex, CHAR_Y); + + CHAR_setMyPosition( charaindex, x, y, TRUE); + CHAR_setWorkInt( charaindex, CHAR_WORKITEM_CRACKER, 1); + CHAR_sendCrackerEffect( charaindex, 101125); + //to client + tofd = getfdFromCharaIndex( charaindex ); + lssproto_IC_send(tofd, x, y); + //清除道具 + BATTLE_ItemUseDelete(charaindex,haveitemindex); + CHAR_talkToCli(charaindex,-1,"道具消失了。",CHAR_COLORYELLOW); + +} +#endif +#ifdef _ITEM_REFRESH //vincent 解除异常状态道具 +void ITEM_useRefresh_Effect( charaindex, toindex, haveitemindex) +{ + int i,itemindex,ReceveEffect; + char *arg; +// char szBuffer[128]=""; + int status = -1,attackNo,index2; + int battleindex; + char *pszP; + +//print("\nvincent--ITEM_useRefresh_Effect"); + // 检查物品 + itemindex = CHAR_getItemIndex(charaindex,haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + arg = ITEM_getChar(itemindex, ITEM_ARGUMENT ); + pszP = arg; + // 躲绊毛潸 + for( ;status == -1 && pszP[0] != 0; pszP++ ){ + // ㄠ井日腹绸 + for( i = 1; i < BATTLE_ST_END; i ++ ){ + // 躲绊疋永正伉井" + if( strncmp( pszP, aszStatus[i], 2 ) == 0 ){ + status = i; + pszP +=2; + break; + } + } + } +//print("\nvincent-->status:%d",status); + // 躲绊卅中及匹撩 + if( status == -1 ) return; + + // 田玄伙 寞 + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + index2 = BATTLE_No2Index( battleindex, toindex);//被击中目标之index + attackNo = BATTLE_Index2No( battleindex, charaindex ); +// defNo = BATTLE_Index2No( battleindex, index2 ); +//print("\nvincent-->charaindex:%d,attackNo:%d,index2:%d,defNo:%d,",charaindex,attackNo,index2,defNo); + + /* 平乓仿弁正□及赭 伉旦玄井日壅蛔 */ + CHAR_setItemIndex(charaindex, haveitemindex ,-1); + CHAR_sendItemDataOne( charaindex, haveitemindex);/* 失奶 丞凳蕙 */ +// if( CHAR_getWorkInt( charaindex, StatusTbl[status] ) > 0 ){ +// ReceveEffect = SPR_tyusya; +// }else{ +// ReceveEffect = SPR_hoshi; +// } + ReceveEffect = SPR_tyusya;//打针 + BATTLE_MultiStatusRecovery( battleindex, attackNo, toindex, + status, MAGIC_EFFECT_USER, ReceveEffect ); + /* 壅允 */ + ITEM_endExistItemsOne( itemindex ); +////////////////////////// +// BATTLE_MultiList( battleindex, defNo, ToList ); +// for( i = 0; ToList[i] != -1; i ++ ){ +// toindex = BATTLE_No2Index( battleindex, ToList[i] ); +// +// } + + + +//////////////////////////// +} +#endif +#ifdef _ITEM_ADDEXP //vincent 经验提升 +void ITEM_useAddexp_Effect( charaindex, toindex, haveitemindex) +{ + int itemindex,power,vtime; + //,pindex + char *p = NULL, *arg; + char szBuffer[1024]=""; + + itemindex = CHAR_getItemIndex(charaindex,haveitemindex); + + // 检查物品 + if(!ITEM_CHECKINDEX(itemindex)) return; + arg = ITEM_getChar(itemindex, ITEM_ARGUMENT ); + + if( (p = strstr( arg, "增" )) != NULL ){ + sscanf( p+2, "%d", &power ); + } + if( (p = strstr( arg, "分" )) != NULL ){ + sscanf( p+2, "%d", &vtime ); + } + if( p == NULL )return; +#ifdef _ITEM_ADDEXP2 // 智果时间可以累加 + { + int point; + point = CHAR_getWorkInt( charaindex, CHAR_WORKITEM_ADDEXP) + * (int)(CHAR_getWorkInt( charaindex, CHAR_WORKITEM_ADDEXPTIME)/60); + if( point >= 72000) { + CHAR_talkToCli( charaindex, -1, "智慧之果累计时间及效果已达上限。", CHAR_COLORYELLOW); + return; + } + point += (power * vtime); + point = min( point, 72000); + vtime = (int)(point / power); +#ifdef _LOG_OTHER + sprintf( szBuffer, "使用智慧之果 %d\t累积效果= 分数%d 能力%d% 时间%d分 ", + ITEM_getInt( itemindex, ITEM_ID ), point, power, vtime); + LogOther( + CHAR_getChar( charaindex, CHAR_CDKEY), + CHAR_getChar( charaindex, CHAR_NAME), + szBuffer ); +#endif + //CHAR_setInt( charaindex, CHAR_ADDEXPPOWER, power); + //CHAR_setInt( charaindex, CHAR_ADDEXPTIME,vtime*60 ); + + //sprintf(szBuffer, "测试讯息:目前分数%d 时间%d秒。", point, vtime*60); + //CHAR_talkToCli(charaindex,-1,szBuffer,CHAR_COLORRED); + } +#endif + CHAR_setWorkInt( charaindex, CHAR_WORKITEM_ADDEXP, power); + CHAR_setWorkInt( charaindex, CHAR_WORKITEM_ADDEXPTIME,vtime*60 ); + + //清除道具 + BATTLE_ItemUseDelete(charaindex,haveitemindex); + //sprintf(szBuffer, "学习经验的能力提升了%d%", power); + sprintf(szBuffer, "学习经验的能力提升了%d%,时效剩馀%d分钟。", power, vtime); + CHAR_talkToCli(charaindex,-1,szBuffer,CHAR_COLORYELLOW); + +} +#endif +//Terry add 2001/12/24 +#ifdef _ITEM_FIRECRACKER +void ITEM_useFirecracker_Battle( charaindex, toindex, haveitemindex) +{ + int itemindex, battleindex, masteridx=-1, index2; + + char szWork[128]; +#ifdef _FIX_FIRECRACKER + int petid=-1, i=1; + BOOL FINDPET=FALSE; + char *buff1; + char token[256], buf1[256]; +#else + int PetEscape = 0; +#endif + + itemindex = CHAR_getItemIndex(charaindex,haveitemindex); + // 检查物品 + if(!ITEM_CHECKINDEX(itemindex)) return; + + battleindex = CHAR_getWorkInt(charaindex,CHAR_WORKBATTLEINDEX); +#ifdef _FIX_FIRECRACKER + index2 = BATTLE_No2Index( battleindex, toindex); + if( !CHAR_CHECKINDEX( index2) ) return; + { + int attackNo = BATTLE_Index2No( battleindex, charaindex ); + int safeSide = 0; + int MySide_start, MySide_end; + if( attackNo >= 10 ) + safeSide = 1; + + MySide_start = safeSide*SIDE_OFFSET; + MySide_end = ((safeSide*SIDE_OFFSET) + SIDE_OFFSET); + + if( (toindex >= MySide_start) && (toindex= 901 && CHAR_getInt(index2,CHAR_PETID) <= 904){ + // 取得目标的正後方的角色的index + masteridx = BATTLE_No2Index(battleindex,toindex-5); + // 如果对战的是玩家 + if(CHAR_getInt(masteridx,CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) PetEscape = 1; + else print("\n年兽在遇敌时出现"); + } + } + + // 如果不是炸自己 + if(BATTLE_Index2No(battleindex,charaindex) != toindex) + { + sprintf(szWork,"BB|a%X|w3|r%X|f0|d0|p0|FF|",BATTLE_Index2No(battleindex,charaindex),toindex); + BATTLESTR_ADD(szWork); + if(PetEscape) + { + BATTLE_Exit(index2,battleindex); + CHAR_setInt(masteridx,CHAR_DEFAULTPET,-1); + sprintf(szWork,"BQ|e%X|",toindex); + BATTLESTR_ADD(szWork); + CHAR_talkToCli(masteridx,-1,"年兽被吓跑了!",CHAR_COLORWHITE); + CHAR_talkToCli(charaindex,-1,"年兽被吓跑了!",CHAR_COLORWHITE); + } + } + CHAR_talkToCli(charaindex,-1,"什麽事都没发生。",CHAR_COLORWHITE); + CHAR_talkToCli(charaindex,-1,"道具消失了。",CHAR_COLORWHITE); + // 使用後道具消失 + BATTLE_ItemUseDelete(charaindex,haveitemindex); +#endif +} +#endif + +//Terry end + + + + +//气绝状态回复耐力,复加复活(光,镜,守)精灵 参数同魔法(光,镜,守)精灵,但只能在战斗之使用,用完就没了 +//参数 例如:耐力值 吸 turn 1 +#ifdef _FEV_ADD_NEW_ITEM // FEV ADD 增加复活守精 +void ITEM_ResAndDef( int charaindex, int toindex, int haveitemindex ) +{ + int itemindex, battleindex, attackNo, par = 0, pow = 0, ReceveEffect; + char *buffer = NULL; + char *magicarg = NULL; + char *magicarg2 = NULL; + char *magicarg3 = NULL; + char magicarg4[200]; + + char *pszP = NULL; + char delim[] = " ";//协助分解字串的区隔字元 + + int status = -1, i, turn = 3; + char szTurn[] = "turn"; + + // 失奶 丞互丐月井升丹井 + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + buffer = ITEM_getChar(itemindex, ITEM_ARGUMENT );//整串字串 + pszP = strtok(buffer, delim);//第一个参数 + magicarg = strtok(NULL, delim);//第二个参数 + magicarg2 = strtok(NULL, delim);//第叁个参数 + magicarg3 = strtok(NULL, delim);//第四个参数 + sprintf(magicarg4,"%s %s %s",magicarg,magicarg2,magicarg3); + magicarg = (char*)magicarg4; + + //光镜守..不得使用敌方 + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER + //&& BattleArray[battleindex].type != BATTLE_TYPE_P_vs_P + ){ + if( BATTLE_CheckSameSide( charaindex, toindex) == 0 ){//不同边 + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + BATTLE_NoAction( battleindex, BATTLE_Index2No( battleindex, charaindex) ); + CHAR_talkToCli( charaindex, -1, "光镜守..不得施予非玩家敌方。", CHAR_COLORYELLOW); + return; + } + } + + //在气绝状态回复耐力 + if( strstr( pszP, "%" ) ){ + par = 1; + } + + if( sscanf( pszP, "%d", &pow ) != 1 ){ + pow = 0; + } + + attackNo = BATTLE_Index2No( battleindex, charaindex ); + + //选择代表的特效 + if( pow <= 0 ){ + ReceveEffect = SPR_fukkatu3; + }else + if( pow <= 100 ){ + ReceveEffect = SPR_fukkatu1; + }else + if( pow <= 300 ){ + ReceveEffect = SPR_fukkatu2; + }else{ + ReceveEffect = SPR_fukkatu3; + } + + BATTLE_MultiRessurect( battleindex, attackNo, toindex, + pow, par, SPR_item3, ReceveEffect ); + + + //(光,镜,守)精灵 + + // 躲绊毛潸 + for( ;status == -1 && magicarg[0] != 0; magicarg++ ){ + for( i = 1; i < BATTLE_MD_END; i ++ ){ + // 躲绊疋永正伉井" + if( strncmp( magicarg, aszMagicDef[i], 2 ) == 0 ){ + status = i; + pszP +=2; + break; + } + } + } + // 躲绊卅中及匹撩 + if( status == -1 ) return; + + // 窒荚 凳今六月井" + if( ( magicarg = strstr( magicarg, szTurn ) ) != NULL){ + magicarg += sizeof( szTurn ); + sscanf( magicarg, "%d", &turn ); + } + + //print("次数:%d",turn); + + // 田玄伙 寞 + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + attackNo = BATTLE_Index2No( battleindex, charaindex ); + + // 蝈够 + BATTLE_MultiMagicDef( battleindex, attackNo, toindex, + status, turn, MAGIC_EFFECT_USER, SPR_difence ); + + + BATTLE_ItemUseDelete( charaindex, haveitemindex ); + +} + +#endif + + + + + diff --git a/gmsv/battle/battle_magic.c b/gmsv/battle/battle_magic.c new file mode 100644 index 0000000..5f71bbf --- /dev/null +++ b/gmsv/battle/battle_magic.c @@ -0,0 +1,5627 @@ +#include "version.h" +#include +#include"char.h" +#include"char_base.h" +#include"battle.h" +#include"battle_event.h" +#include"magic_base.h" +#include"battle_magic.h" +#include"item_event.h" +#include"anim_tbl.h" +#include"common.h" +#include"lssproto_serv.h" + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 +#include "profession_skill.h" +#include "skill.h" +#endif + +#ifdef __ATTACK_MAGIC + +extern AttMagic *ATTMAGIC_magic; +extern int ATTMAGIC_magicnum; + +#define AJ_SAME (1.0) +#define AJ_UP (1.5) +#define AJ_DOWN (0.6) + +#define ATTR_MAX 100 +#define D_ATTR (1.0/(ATTR_MAX*ATTR_MAX)) +#ifdef _FIX_MAGICDAMAGE +static int BATTLE_getMagicAdjustInt( int attackindex, int defindex, int MagicLv, int flg,int damage ); +void Magic_ComputeAttExp( int charindex, int Mnum, int MagicLv, int Expoint); +void Magic_ComputeDefExp( int charindex, int Mnum, int MagicLv, int Damage); +#endif + +#ifdef _MAGIC_TOCALL +/* +typedef struct tagToCallMagic +{ + unsigned int uiSpriteNum; // 此咒术在Spr_x.bin的编号 + unsigned int uiAttackType; // 攻击的方式:单人,整排( 轮流 ) , 整排( 轮流 ) , 整排( 同时 ) , 全体( 轮流 ) , 全体( 同时 ) + unsigned int uiSliceTime; // 轮流攻击时的时间差 + unsigned int uiShowType; // 显示的位置方式:中央、指定 + int siSx; // 显示的位置 - X轴 + int siSy; // 显示的位置 - Y轴 + unsigned int uiShowBehindChar; // 显示在人物的前方或下方 + unsigned int uiShakeScreen; // 是否震动画面 + unsigned int uiShakeFrom; // 震动画面的起始时间( 毫秒 ) + unsigned int uiShakeTo; // 震动画面的结束时间( 毫秒 _ + unsigned int uiPrevMagicNum; // 前置咒术的索引号( 0XFFFFFFFFFF 表示无前置咒术 ) + int siPrevMagicSx; // 前置咒术的显示位置 - X轴 + int siPrevMagicSy; // 前置咒术的显示位置 - Y轴 + int siPrevMagicOnChar; // 前置咒术显示在人物的前方或下方 + unsigned int uiPostMagicNum; // 後置咒术的索引号( 0XFFFFFFFF 表示无後置咒术 ) + int siPostMagicSx; // 後置咒术的显示位置 - X轴 + int siPostMagicSy; // 後置咒术的显示位置 - Y轴 + int siPostMagicOnChar; // 後置咒术显示在人物的前方或下方 + int isPostDisappear; // 咒术一般攻击完时是否马上消失 + int ToCallMagicNo; // 召唤术的编号 +}ToCallMagic; +*/ + +ToCallMagic TOCALL_magic[3] = { {100354,0,0,0,50,25,1,0,0,0,101120,65528,65485,0,-1,0,0,0,1,0}, + {100354,1,0,0,50,25,1,0,0,0,101120,65528,65485,0,-1,0,0,0,1,1}, + {100354,5,0,0,0,0,1,1,1000,4000,101120,65528,65485,0,-1,0,0,0,0,2}, + }; + +#endif + +// 魔法熟练度及抗性升级所需经验值 +int Magic_Level_Table[101] = +{ + 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, //lv 1~10 + 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, //lv 11~20 + 231, 253, 276, 300, 325, 351, 378, 406, 435, 465, //lv 21~30 + 496, 528, 561, 595, 630, 666, 703, 741, 780, 820, //lv 31~40 + 861, 903, 946, 990,1035,1081,1128,1176,1225,1275, //lv 41~50 + 1326,1378,1431,1485,1540,1596,1653,1711,1770,1830, //lv 51~60 + 1891,1953,2016,2080,2145,2211,2278,2346,2415,2485, //lv 61~70 + 2556,2628,2701,2775,2850,2926,3003,3081,3160,3240, //lv 71~80 + 3321,3403,3486,3570,3655,3741,3828,3916,4005,4095, //lv 81~90 + 4186,4278,4371,4465,4560,4656,4753,4851,4950,5050, //lv 91~100 + 9999 +}; +#endif + +#if 0 + +int BATTLE_PointChange( + int ToList[], // + int kind, + int point +) + +{ + + return 0; +} +#endif + +int BATTLE_MagicEffect( int battleindex, int attackNo, int ToList[], int MyEffect, int ToEffect ) +{ + int i; + char szCommand[256]; + int attackindex; + + attackindex = BATTLE_No2Index( battleindex, attackNo ); + if( CHAR_CHECKINDEX( attackindex ) == FALSE )return 0; + + snprintf( szCommand, sizeof(szCommand), + "BJ|a%X|m%X|e%X|e%X|", + attackNo, + CHAR_getInt( attackindex, CHAR_MP ), + MyEffect, + ToEffect + ); + + + BATTLESTR_ADD( szCommand ); + + for( i = 0; ToList[i] != -1; i ++ ){ + snprintf( szCommand, sizeof(szCommand), "r%X|",ToList[i]); + BATTLESTR_ADD( szCommand ); + } + BATTLESTR_ADD( "FF|" ); + + return 0; +} + +#ifdef __ATTACK_MAGIC + +int BATTLE_AttMagicEffect( int battleindex , int attackNo , int ToList[] , int AttackMgcNo ) +{ + int i; + char szcommand[256]; + int attackindex; + + attackindex = BATTLE_No2Index( battleindex , attackNo ); + if( FALSE == CHAR_CHECKINDEX( attackindex ) ) + return 0; + + if( attackNo >= 10 ) + i = AttackMgcNo * 2; + else + i = AttackMgcNo * 2 + 1; + + snprintf( + szcommand , sizeof( szcommand ) , "BJ|a%X|i%X|m%X|%X|%X|%X|s%X|t%X|l%X|%X|%X|%X|%X|%X|%X|o%X|o%X|o%X|s%X|%X|%X|" , + attackNo , 12345678 , CHAR_getInt( attackindex , CHAR_MP ) , + ATTMAGIC_magic[i].uiPrevMagicNum , + ATTMAGIC_magic[i].uiSpriteNum , + ATTMAGIC_magic[i].uiPostMagicNum , + ATTMAGIC_magic[i].uiAttackType , + ATTMAGIC_magic[i].uiSliceTime , + ATTMAGIC_magic[i].uiShowType , + ATTMAGIC_magic[i].siSx , + ATTMAGIC_magic[i].siSy , + ATTMAGIC_magic[i].siPrevMagicSx , + ATTMAGIC_magic[i].siPrevMagicSy , + ATTMAGIC_magic[i].siPostMagicSx , + ATTMAGIC_magic[i].siPostMagicSy , + ATTMAGIC_magic[i].siPrevMagicOnChar , + ATTMAGIC_magic[i].uiShowBehindChar , + ATTMAGIC_magic[i].siPostMagicOnChar , + ATTMAGIC_magic[i].uiShakeScreen , + ATTMAGIC_magic[i].uiShakeFrom , + ATTMAGIC_magic[i].uiShakeTo + ); + + BATTLESTR_ADD( szcommand ); + + for( i = 0 ; ToList[i] != -1 ; i++ ) + { + snprintf( szcommand , sizeof( szcommand ) , "r%X|" , ToList[i] ); + BATTLESTR_ADD( szcommand ); + } + + BATTLESTR_ADD( "FF|" ); + + return 0; +} + +#endif + + +#ifdef _MAGIC_TOCALL + +int BATTLE_ToCallDragonEffect( int battleindex , int attackNo , int ToList[] , int AttackMgcNo ) +{ + int i; + char szcommand[256]; + int attackindex; + + attackindex = BATTLE_No2Index( battleindex , attackNo ); + if( FALSE == CHAR_CHECKINDEX( attackindex ) ) + return 0; +/* + if( attackNo >= 10 ) + i = AttackMgcNo * 2; + else + i = AttackMgcNo * 2 + 1; +*/ + snprintf( + szcommand , sizeof( szcommand ) , "B$|a%X|i%X|m%X|%X|%X|%X|s%X|t%X|l%X|%X|%X|%X|%X|%X|%X|o%X|o%X|o%X|s%X|%X|%X|%X|%X|" , + attackNo , 5711438 , CHAR_getInt( attackindex , CHAR_MP ) , + TOCALL_magic[AttackMgcNo].uiPrevMagicNum , + TOCALL_magic[AttackMgcNo].uiSpriteNum , + TOCALL_magic[AttackMgcNo].uiPostMagicNum , + TOCALL_magic[AttackMgcNo].uiAttackType , + TOCALL_magic[AttackMgcNo].uiSliceTime , + TOCALL_magic[AttackMgcNo].uiShowType , + TOCALL_magic[AttackMgcNo].siSx , + TOCALL_magic[AttackMgcNo].siSy , + TOCALL_magic[AttackMgcNo].siPrevMagicSx , + TOCALL_magic[AttackMgcNo].siPrevMagicSy , + TOCALL_magic[AttackMgcNo].siPostMagicSx , + TOCALL_magic[AttackMgcNo].siPostMagicSy , + TOCALL_magic[AttackMgcNo].siPrevMagicOnChar , + TOCALL_magic[AttackMgcNo].uiShowBehindChar , + TOCALL_magic[AttackMgcNo].siPostMagicOnChar , + TOCALL_magic[AttackMgcNo].uiShakeScreen , + TOCALL_magic[AttackMgcNo].uiShakeFrom , + TOCALL_magic[AttackMgcNo].uiShakeTo , + TOCALL_magic[AttackMgcNo].isPostDisappear , + TOCALL_magic[AttackMgcNo].ToCallMagicNo + ); + + BATTLESTR_ADD( szcommand ); + + for( i = 0 ; ToList[i] != -1 ; i++ ) + { + snprintf( szcommand , sizeof( szcommand ) , "r%X|" , ToList[i] ); + BATTLESTR_ADD( szcommand ); + } + + BATTLESTR_ADD( "FF|" ); + + return 0; +} + +#endif +#ifdef _IMPRECATE_ITEM +void BATTLE_ImprecateRecovery( + int battleindex, int attackNo, int toNo, int kind, int powers, + int rounds, int UseEffect, int RecevEffect ) +{ + int i, toindex, flg; + int ToList[SIDE_OFFSET*2+1]; + //char szBuffer[256]=""; + BATTLE_MultiList( battleindex, toNo, ToList ); + + BATTLE_MagicEffect( + battleindex, attackNo, ToList, + UseEffect, RecevEffect ); + for( i = 0; ToList[i] != -1; i ++ ){ + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + if( CHAR_CHECKINDEX( toindex ) == FALSE )continue; + switch( kind ){ +#ifdef _IMPRECATE_ITEM + case BD_KIND_CURSE: + if( CHAR_getWorkInt( toindex, CHAR_WORKIMPRECATENUM1 ) <= 0 && + CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) { + CHAR_setWorkInt( toindex, CHAR_WORKHURTMP, powers); //伤害 MP + CHAR_setWorkInt( toindex, CHAR_WORKIMPRECATENUM1, rounds); + } + break; + case BD_KIND_BESTOW: + if( CHAR_getWorkInt( toindex, CHAR_WORKIMPRECATENUM2 ) <= 0 ){ +#ifdef _TYPE_TOXICATION + if( CHAR_CanCureFlg( toindex, "HP") == FALSE ) break; +#endif + CHAR_setWorkInt( toindex, CHAR_WORKWISHESHP, powers); //祝福 hp + CHAR_setWorkInt( toindex, CHAR_WORKIMPRECATENUM2, rounds); + } + break; + case BD_KIND_WISHES: + if( CHAR_getWorkInt( toindex, CHAR_WORKIMPRECATENUM3 ) <= 0 && + CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) { + CHAR_setWorkInt( toindex, CHAR_WORKWISHESMP, powers); //祝福 MP + CHAR_setWorkInt( toindex, CHAR_WORKIMPRECATENUM3, rounds); + } + break; +#endif + } + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + if( BattleArray[battleindex].norisk == 0 + && CHAR_getInt( toindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET){ + flg = CHAR_getWorkInt( toindex, CHAR_WORKBATTLEFLG ); + if( flg & CHAR_BATTLEFLG_RECOVERY ){ + }else{ + CHAR_PetAddVariableAi( toindex, AI_FIX_PETRECOVERY ); + CHAR_setWorkInt( toindex, CHAR_WORKBATTLEFLG, flg | CHAR_BATTLEFLG_RECOVERY ); + } + } + } + return; +} +#endif + +void BATTLE_MultiRecovery( + int battleindex, + int attackNo, + int toNo, + int kind, + int power, + int per, + int UseEffect, +#ifdef _CHANGEITEMUSE // Syu ADD 调整战斗中使用料理设定 + int RecevEffect, + int power1 +#else + int RecevEffect +#endif +) +{ + int i, toindex, UpPoint = 0, workhp, oldhp, flg; +#ifdef _CHANGEITEMUSE // Syu ADD 调整战斗中使用料理设定 + int UpPoint1 = 0; +#endif + int ToList[SIDE_OFFSET*2+1]; + + //char szBuffer[256]=""; + char szCommand[256]; + + int ridepet, petUpPoint =0; + + + BATTLE_MultiList( battleindex, toNo, ToList ); + + BATTLE_MagicEffect( battleindex, attackNo, ToList, UseEffect, RecevEffect ); + + for( i = 0; ToList[i] != -1; i ++ ){ + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + + if( CHAR_CHECKINDEX( toindex ) == FALSE ) continue; + + ridepet = BATTLE_getRidePet( toindex ); + + switch( kind ){ +#ifdef _ITEM_UNBECOMEPIG + case BD_KIND_UNBECOMEPIG: + if( CHAR_getInt( toindex, CHAR_BECOMEPIG ) > -1 ){ + CHAR_setInt( toindex, CHAR_BECOMEPIG, -1 ); + CHAR_setInt( toindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( toindex, CHAR_BASEBASEIMAGENUMBER)); + CHAR_complianceParameter( toindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( toindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( toindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + CHAR_talkToCli( toindex,-1,"乌力化失效了。",CHAR_COLORWHITE); + } + break; +#endif +#ifdef _ITEM_PROPERTY + case BD_KIND_PROPERTY: + { + if (CHAR_getInt(toindex, CHAR_WHICHTYPE)!=CHAR_TYPEPLAYER) + return; + //print("地水火风:%d %d %d %d", CHAR_getInt( toindex, CHAR_EARTHAT ), CHAR_getInt( toindex, CHAR_WATERAT ), CHAR_getInt( toindex, CHAR_FIREAT ), CHAR_getInt( toindex, CHAR_WINDAT ) ); + if( power == 1 ){//旋转属性 正转 + if( CHAR_getInt( toindex, CHAR_EARTHAT ) == 100 ) + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )-10 ), + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_WATERAT ) == 100 ) + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )-10 ), + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_FIREAT ) == 100 ) + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )-10 ), + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_WINDAT ) == 100 ) + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )-10 ), + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_EARTHAT ) > 0 && CHAR_getInt( toindex, CHAR_WATERAT ) > 0 ) + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )-10 ), + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_WATERAT ) > 0 && CHAR_getInt( toindex, CHAR_FIREAT ) > 0 ) + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )-10 ), + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_FIREAT ) > 0 && CHAR_getInt( toindex, CHAR_WINDAT ) > 0 ) + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )-10 ), + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_WINDAT ) > 0 && CHAR_getInt( toindex, CHAR_EARTHAT ) > 0 ) + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )-10 ), + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )+10 ); + } + if( power == 2 ){//旋转属性 反转 + if( CHAR_getInt( toindex, CHAR_EARTHAT ) == 100 ) + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )-10 ), + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_WATERAT ) == 100 ) + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )-10 ), + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_FIREAT ) == 100 ) + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )-10 ), + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_WINDAT ) == 100 ) + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )-10 ), + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_EARTHAT ) > 0 && CHAR_getInt( toindex, CHAR_WATERAT ) > 0 ) + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )+10 ), + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )-10 ); + else if( CHAR_getInt( toindex, CHAR_WATERAT ) > 0 && CHAR_getInt( toindex, CHAR_FIREAT ) > 0 ) + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )+10 ), + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )-10 ); + else if( CHAR_getInt( toindex, CHAR_FIREAT ) > 0 && CHAR_getInt( toindex, CHAR_WINDAT ) > 0 ) + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )+10 ), + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )-10 ); + else if( CHAR_getInt( toindex, CHAR_WINDAT ) > 0 && CHAR_getInt( toindex, CHAR_EARTHAT ) > 0 ) + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )+10 ), + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )-10 ); + } + } +#endif + case BD_KIND_HP: +#ifdef _TYPE_TOXICATION + if( CHAR_CanCureFlg( toindex, "HP") == FALSE ) continue; +#endif + // Robin 0728 ride Pet + if( ridepet == -1 ) { + UpPoint = RAND( (power*0.9), (power*1.1) ); +#ifdef _MAGIC_REHPAI +#else + if( per ){ + UpPoint *= CHAR_getWorkInt( toindex, CHAR_WORKMAXHP ) * 0.01; + } + UpPoint *= GetRecoveryRate( toindex ); +#endif + workhp = CHAR_getInt( toindex, CHAR_HP ); + oldhp = workhp; + workhp += (int)UpPoint; + CHAR_setInt( toindex, CHAR_HP, + min( workhp, CHAR_getWorkInt( toindex, CHAR_WORKMAXHP ) ) ); + + //snprintf( szBuffer, sizeof(szBuffer), "(%s)的耐久力回复(%d)", CHAR_getUseName( toindex ), UpPoint ); + + }else { + int allUpPoint; + UpPoint = RAND( (power*0.9), (power*1.1) ); +#ifdef _MAGIC_REHPAI + allUpPoint = UpPoint; + UpPoint = (allUpPoint * Magic_RideGetHP( toindex, ridepet, 1 ))/100; + petUpPoint = allUpPoint - UpPoint; +#else + petUpPoint = UpPoint; + if( per ){ + UpPoint *= CHAR_getWorkInt( toindex, CHAR_WORKMAXHP ) * 0.01; + petUpPoint *= CHAR_getWorkInt( ridepet, CHAR_WORKMAXHP ) * 0.01; + + } + UpPoint *= GetRecoveryRate( toindex ); + petUpPoint *= GetRecoveryRate( ridepet ); +#endif + + + allUpPoint = UpPoint + petUpPoint; +#ifdef _MAGIC_REHPAI +#else + UpPoint = (UpPoint * UpPoint) / allUpPoint; + petUpPoint = (petUpPoint * petUpPoint) / allUpPoint; +#endif + workhp = CHAR_getInt( toindex, CHAR_HP ); + oldhp = workhp; + workhp += (int)UpPoint; + CHAR_setInt( toindex, CHAR_HP, + min( workhp, CHAR_getWorkInt( toindex, CHAR_WORKMAXHP ) ) ); + workhp = CHAR_getInt( ridepet, CHAR_HP ); + oldhp = workhp; + workhp += (int)petUpPoint; + CHAR_setInt( ridepet, CHAR_HP, + min( workhp, CHAR_getWorkInt( ridepet, CHAR_WORKMAXHP ) ) ); + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)的耐久力回复(%d),(%s的骑宠)的耐久力回复(%d)", + // CHAR_getUseName( toindex ), + // UpPoint, + // CHAR_getUseName( toindex ), + // petUpPoint + // ); + } + break; + case BD_KIND_MP: + UpPoint = RAND( (power*0.9), (power*1.1) ); + if( per ){ + UpPoint *= CHAR_getWorkInt( toindex, CHAR_WORKMAXMP ) * 0.01; + } + workhp = CHAR_getInt( toindex, CHAR_MP ); + oldhp = workhp; + workhp += (int)UpPoint; + CHAR_setInt( toindex, CHAR_MP, + min( workhp, CHAR_getWorkInt( toindex, CHAR_WORKMAXMP ) ) ); + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)的气力回复(%d)", + // CHAR_getUseName( toindex ), + // UpPoint + // ); + break; +#ifdef _CHANGEITEMUSE // Syu ADD 调整战斗中使用料理设定 + case BD_KIND_HP_MP: +#ifdef _TYPE_TOXICATION + if( CHAR_CanCureFlg( toindex, "HP") == FALSE ) + continue; +#endif + if( ridepet == -1 ) + { + UpPoint = RAND( (power*0.9), (power*1.1) ); +#ifdef _MAGIC_REHPAI +#else + if( per ) + { + UpPoint *= CHAR_getWorkInt( toindex, CHAR_WORKMAXHP ) * 0.01; + } + UpPoint *= GetRecoveryRate( toindex ); +#endif + workhp = CHAR_getInt( toindex, CHAR_HP ); + oldhp = workhp; + workhp += (int)UpPoint; + CHAR_setInt( toindex, CHAR_HP, + min( workhp, CHAR_getWorkInt( toindex, CHAR_WORKMAXHP ) ) ); + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)的耐久力回复(%d)", + // CHAR_getUseName( toindex ), + // UpPoint + // ); + } + else + { + int allUpPoint; + UpPoint = RAND( (power*0.9), (power*1.1) ); +#ifdef _MAGIC_REHPAI + allUpPoint = UpPoint; + UpPoint = (allUpPoint * Magic_RideGetHP( toindex, ridepet, 1 ))/100; + petUpPoint = allUpPoint - UpPoint; +#else + petUpPoint = UpPoint; + if( per ) + { + UpPoint *= CHAR_getWorkInt( toindex, CHAR_WORKMAXHP ) * 0.01; + petUpPoint *= CHAR_getWorkInt( ridepet, CHAR_WORKMAXHP ) * 0.01; + + } + UpPoint *= GetRecoveryRate( toindex ); + petUpPoint *= GetRecoveryRate( ridepet ); +#endif + allUpPoint = UpPoint + petUpPoint; +#ifdef _MAGIC_REHPAI +#else + UpPoint = (UpPoint * UpPoint) / allUpPoint; + petUpPoint = (petUpPoint * petUpPoint) / allUpPoint; +#endif + workhp = CHAR_getInt( toindex, CHAR_HP ); + oldhp = workhp; + workhp += (int)UpPoint; + CHAR_setInt( toindex, CHAR_HP, + min( workhp, CHAR_getWorkInt( toindex, CHAR_WORKMAXHP ) ) ); + workhp = CHAR_getInt( ridepet, CHAR_HP ); + oldhp = workhp; + workhp += (int)petUpPoint; + CHAR_setInt( ridepet, CHAR_HP, + min( workhp, CHAR_getWorkInt( ridepet, CHAR_WORKMAXHP ) ) ); + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)的耐久力回复(%d),(%s的骑宠)的耐久力回复(%d)", + // CHAR_getUseName( toindex ), + // UpPoint, + // CHAR_getUseName( toindex ), + // petUpPoint + // ); + } + UpPoint1 = RAND( (power1*0.9), (power1*1.1) ); + if( per ) + { + UpPoint1 *= CHAR_getWorkInt( toindex, CHAR_WORKMAXMP ) * 0.01; + } + workhp = CHAR_getInt( toindex, CHAR_MP ); + oldhp = workhp; + workhp += (int)UpPoint1; + CHAR_setInt( toindex, CHAR_MP, + min( workhp, CHAR_getWorkInt( toindex, CHAR_WORKMAXMP ) ) ); + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)的气力回复(%d)", + // CHAR_getUseName( toindex ), + // UpPoint1); + break; +#endif + } + +#ifdef _CHANGEITEMUSE // Syu ADD 调整战斗中使用料理设定 + if ( kind == BD_KIND_HP_MP) + { + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + { + //补体的部分 + int Sign, Damage, petDamage; + Sign = (UpPoint >= 0)?(1):(0); + Damage = ABS( UpPoint ); + petDamage = ABS( petUpPoint ); +#ifdef _NOTRIDE_ + snprintf( szCommand, sizeof(szCommand), + "BD|r%X|%X|%X|d%X|", ToList[i], BD_KIND_HP, Sign, Damage ); +#else + snprintf( szCommand, sizeof(szCommand), + "BD|r%X|%X|%X|d%X|p%X|", ToList[i], BD_KIND_HP, Sign, Damage, petDamage ); +#endif //_NOTRIDE_ + BATTLESTR_ADD( szCommand ); + } + + { + //补气的部分 + int Sign, Damage, petDamage; + Sign = (UpPoint1 >= 0)?(1):(0); + Damage = ABS( UpPoint1 ); + petDamage = ABS( petUpPoint ); +#ifdef _NOTRIDE_ + snprintf( szCommand, sizeof(szCommand), + "BD|r%X|%X|%X|d%X|", ToList[i], BD_KIND_MP, Sign, Damage ); +#else + snprintf( szCommand, sizeof(szCommand), + "BD|r%X|%X|%X|d%X|p%X|", ToList[i], BD_KIND_MP, Sign, Damage, petDamage ); +#endif //_NOTRIDE_ + BATTLESTR_ADD( szCommand ); + } + + } + else + { + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + { + int Sign, Damage, petDamage; + Sign = (UpPoint >= 0)?(1):(0); + Damage = ABS( UpPoint ); + petDamage = ABS( petUpPoint ); +#ifdef _NOTRIDE_ + snprintf( szCommand, sizeof(szCommand), + "BD|r%X|%X|%X|d%X|", ToList[i], kind, Sign, Damage ); +#else + snprintf( szCommand, sizeof(szCommand), + "BD|r%X|%X|%X|d%X|p%X|", ToList[i], kind, Sign, Damage, petDamage ); +#endif //_NOTRIDE_ + BATTLESTR_ADD( szCommand ); + } + } + if( BattleArray[battleindex].norisk == 0 + && CHAR_getInt( toindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET) + { + flg = CHAR_getWorkInt( toindex, CHAR_WORKBATTLEFLG ); + if( flg & CHAR_BATTLEFLG_RECOVERY ) + {} + else + { + CHAR_PetAddVariableAi( toindex, AI_FIX_PETRECOVERY ); + CHAR_setWorkInt( toindex, CHAR_WORKBATTLEFLG, flg | CHAR_BATTLEFLG_RECOVERY ); + } + } +#else //_CHANGEITEMUSE + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + { + int Sign, Damage, petDamage; + Sign = (UpPoint >= 0)?(1):(0); + Damage = ABS( UpPoint ); + petDamage = ABS( petUpPoint ); +#ifdef _NOTRIDE_ + snprintf( szCommand, sizeof(szCommand), + "BD|r%X|%X|%X|d%X|", ToList[i], kind, Sign, Damage ); +#else + snprintf( szCommand, sizeof(szCommand), + "BD|r%X|%X|%X|d%X|p%X|", ToList[i], kind, Sign, Damage, petDamage ); +#endif //_NOTRIDE_ + BATTLESTR_ADD( szCommand ); + } + + if( BattleArray[battleindex].norisk == 0 + && CHAR_getInt( toindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET){ + flg = CHAR_getWorkInt( toindex, CHAR_WORKBATTLEFLG ); + if( flg & CHAR_BATTLEFLG_RECOVERY ){ + }else{ + CHAR_PetAddVariableAi( toindex, AI_FIX_PETRECOVERY ); + CHAR_setWorkInt( toindex, CHAR_WORKBATTLEFLG, flg | CHAR_BATTLEFLG_RECOVERY ); + } + } +#endif //_CHANGEITEMUSE + } + return; +} + +#ifdef _MAGIC_REHPAI +int Magic_RideGetHP( int toindex, int petindex, int flg) +{ + int allDHp=1; + int petDHp=1; + int CharDHp=1; + int ISIZE = 100; + + CharDHp = CHAR_getWorkInt( toindex, CHAR_WORKMAXHP ) - CHAR_getInt( toindex, CHAR_HP); + petDHp = CHAR_getWorkInt( petindex, CHAR_WORKMAXHP ) - CHAR_getInt( petindex, CHAR_HP); + allDHp = (CharDHp + petDHp); + + if( allDHp <= 0 ) allDHp=1; + if( flg == 1) + return (int)((CharDHp*ISIZE)/allDHp); + else + return (int)((petDHp*ISIZE)/allDHp); +} +#endif + +int MAGIC_Recovery_Battle( int charaindex, int toNo, int marray, int mp ) +{ + char *magicarg; + float power; + int battleindex, attackNo, HealedEffect = 0, per = 0; + int range; + if( !CHAR_CHECKINDEX( charaindex) ) return FALSE; + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + attackNo = BATTLE_Index2No( battleindex, charaindex ); + +#if 1 // Robin fix 防封包改Magic 围 + range = MAGIC_getInt( marray, MAGIC_TARGET ); + //print(" MAGIC_TARGET:%d toNo:%d ", range, toNo); + if( range == 0 && toNo != attackNo ) { // 只能对自己使用 + print("\n 改封包!MAGIC只能对自己使用!!:%s ", CHAR_getChar( charaindex, CHAR_CDKEY) ); + return FALSE; + } + if( range == 1 && toNo >= 20 ) { // 只能对单体使用 + print("\n 改封包!MAGIC只能对单体使用!!:%s ", CHAR_getChar( charaindex, CHAR_CDKEY) ); + return FALSE; + } +#endif + + // shan(对全体使用魔法的bug),修改者jinchao+2001/12/07 + if( BATTLE_CHECKINDEX( battleindex ) == FALSE ) return FALSE; + magicarg = MAGIC_getChar( marray, MAGIC_OPTION ); + // shan(对全体使用魔法的bug),修改者jinchao+2001/12/07 + if (!magicarg) return FALSE; + + power = atoi( magicarg ); + if( strstr( magicarg, "%" ) ){ + per = 1; + } + + if( power <= 100 ){ + HealedEffect = SPR_heal; + }else + if( power <= 300 ){ + HealedEffect = SPR_heal2; + }else{ + HealedEffect = SPR_heal3; + } + +#ifdef _CHANGEITEMUSE // Syu ADD 调整战斗中使用料理设定 + BATTLE_MultiRecovery( battleindex, attackNo, toNo, + BD_KIND_HP, (int)power, per, MAGIC_EFFECT_USER, HealedEffect , 0); +#else + BATTLE_MultiRecovery( battleindex, attackNo, toNo, + BD_KIND_HP, (int)power, per, MAGIC_EFFECT_USER, HealedEffect ); +#endif + return TRUE; +} + +void BATTLE_MultiResAndDef( + int battleindex, // 田玄伙奶件犯永弁旦 + int attackNo, // 井仃月谛 寞 + int toNo, // 井仃日木月谛 寞 + int power, // 湘 荚汊袄 + int per, // ⊙井" + int kind, // 芊 豢及潘 + int count, // 窒荚 什井 + int UseEffect, // 银丹谛及巨白尼弁玄 + int RecevEffect // 井仃日木月谛及巨白尼弁玄 +) +{ + int i, toindex, charaindex, UpPoint = 0, workhp; + int ToList[SIDE_OFFSET*2+1]; + + //char szBuffer[256]=""; + char szCommand[256]; + + + BATTLE_MultiListDead( battleindex, toNo, ToList ); + + BATTLE_MagicEffect( + battleindex, // 田玄伙奶件犯永弁旦 + attackNo, // 井仃月谛 寞(ㄟ ㄠㄨ) + ToList, // 井仃日木月谛 寞伉旦玄(ㄟ ㄠㄨ) + UseEffect, // 井仃月谛巨白尼弁玄 + RecevEffect // 井仃日木月谛巨白尼弁玄 + ); + charaindex = BATTLE_No2Index( battleindex, attackNo ); + for( i = 0; ToList[i] != -1; i ++ ){ + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + if( BattleArray[battleindex].type == BATTLE_TYPE_P_vs_P + && CHAR_getInt( toindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER){ + continue; + } + if( CHAR_getFlg( toindex, CHAR_ISDIE ) == FALSE ){ + continue; + } + UpPoint = power; +#ifdef _MAGIC_REHPAI +#else + if( per ){ + UpPoint *= CHAR_getWorkInt( toindex, CHAR_WORKMAXHP ) * 0.01; + } +#endif + if( power == 0 ){ + UpPoint = CHAR_getWorkInt( toindex, CHAR_WORKMAXHP ); + }else{ + UpPoint = RAND( (power*0.9), (power*1.1) ); + } + UpPoint = max( 1, UpPoint ); + workhp = CHAR_getInt( toindex, CHAR_HP ) + UpPoint; + CHAR_setInt( toindex, CHAR_HP, + min( workhp, CHAR_getWorkInt( toindex, CHAR_WORKMAXHP ) ) ); + CHAR_setFlg( toindex, CHAR_ISDIE, 0 ); + CHAR_setWorkInt( toindex, MagicDefTbl[kind], count ); + + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)恢复意识", + // CHAR_getUseName( toindex ) ); + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)将(%s)遭受(损伤%s)", + // CHAR_getUseName( charaindex ), + // CHAR_getUseName( toindex ), + // aszMagicDefFull[kind] + //); + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + snprintf( szCommand, sizeof(szCommand), + "BL|r%X|h%X|", ToList[i], CHAR_getInt( toindex, CHAR_HP ) ); + BATTLESTR_ADD( szCommand ); + if( BattleArray[battleindex].norisk == 0 + && BattleArray[battleindex].type == BATTLE_TYPE_P_vs_E ){ + if( CHAR_getInt( toindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + CHAR_PetAddVariableAi( toindex, AI_FIX_PETRESSURECT ); + } + } + } +} + +#ifdef __ATTACK_MAGIC + +static int CharTable[4][5] = +{ + { 13 , 11 , 10 , 12 , 14 } , + { 18 , 16 , 15 , 17 , 19 } , + { 8 , 6 , 5 , 7 , 9 } , + { 3 , 1 , 0 , 2 , 4 } +}; + +static int CharTableIdx[20][2] = +{ + { 3 , 2 } , { 3 , 1 } , { 3 , 3 } , { 3 , 0 } , { 3 , 4 } , + { 2 , 2 } , { 2 , 1 } , { 2 , 3 } , { 2 , 0 } , { 2 , 4 } , + { 0 , 2 } , { 0 , 1 } , { 0 , 3 } , { 0 , 0 } , { 0 , 4 } , + { 1 , 2 } , { 1 , 1 } , { 1 , 3 } , { 1 , 0 } , { 1 , 4 } +}; + + + +typedef int ( *FUNC )( const void* , const void* ); + +static int SortLoc( const int *pEle1 , const int *pEle2 ) +{ + int ele1basex , ele1basey; + int ele2basex , ele2basey; + + ele1basex = CharTableIdx[*pEle1][1]; + ele1basey = CharTableIdx[*pEle1][0]; + ele2basex = CharTableIdx[*pEle2][1]; + ele2basey = CharTableIdx[*pEle2][0]; + + // 左上方 + if( *pEle1 >= 10 ) + { + if( ele1basey != ele2basey ) + return ( ele1basey - ele2basey ); + + return ( ele1basex - ele2basex ); + } + // 右下方 + else + { + if( ele1basey != ele2basey ) + return ( ele2basey - ele1basey ); + + return ( ele2basex - ele1basey ); + } + + return 0; +} + + +static void BATTLE_GetAttr( int charaindex , int *pAt_Fire , int *pAt_Water , int *pAt_Earth , int *pAt_Wind , int *pAt_None ) +{ + + int petindex = BATTLE_getRidePet( charaindex ); + + if( petindex == -1 ) + { + *pAt_Fire = CHAR_getWorkInt( charaindex , CHAR_WORKFIXFIREAT ); + *pAt_Water = CHAR_getWorkInt( charaindex , CHAR_WORKFIXWATERAT ); + *pAt_Earth = CHAR_getWorkInt( charaindex , CHAR_WORKFIXEARTHAT ); + *pAt_Wind = CHAR_getWorkInt( charaindex , CHAR_WORKFIXWINDAT ); + } + else + { + *pAt_Fire = ( CHAR_getWorkInt( charaindex , CHAR_WORKFIXFIREAT ) + + CHAR_getWorkInt( petindex , CHAR_WORKFIXFIREAT ) ) / 2; + *pAt_Water = ( CHAR_getWorkInt( charaindex , CHAR_WORKFIXWATERAT ) + + CHAR_getWorkInt( petindex , CHAR_WORKFIXWATERAT ) ) / 2; + *pAt_Earth = ( CHAR_getWorkInt( charaindex , CHAR_WORKFIXEARTHAT ) + + CHAR_getWorkInt( petindex , CHAR_WORKFIXEARTHAT ) ) / 2; + *pAt_Wind = ( CHAR_getWorkInt( charaindex , CHAR_WORKFIXWINDAT ) + + CHAR_getWorkInt( petindex , CHAR_WORKFIXWINDAT ) ) / 2; + } + + if( *pAt_Fire < 0 ) *pAt_Fire = 0; + if( *pAt_Water < 0 ) *pAt_Water = 0; + if( *pAt_Earth < 0 ) *pAt_Earth = 0; + if( *pAt_Wind < 0 ) *pAt_Wind = 0; + + *pAt_None = 100 - *pAt_Fire - *pAt_Water - *pAt_Earth - *pAt_Wind; + + if( *pAt_None < 0 ) + *pAt_None = 0; +} + +static void BATTLE_GetPureAttr( int charaindex , int *pAt_Fire , int *pAt_Water, int *pAt_Earth , int *pAt_Wind ) +{ + *pAt_Fire = CHAR_getWorkInt( charaindex , CHAR_WORKFIXFIREAT ); + *pAt_Water = CHAR_getWorkInt( charaindex , CHAR_WORKFIXWATERAT ); + *pAt_Earth = CHAR_getWorkInt( charaindex , CHAR_WORKFIXEARTHAT ); + *pAt_Wind = CHAR_getWorkInt( charaindex , CHAR_WORKFIXWINDAT ); + + if( *pAt_Fire < 0 ) *pAt_Fire = 0; + if( *pAt_Water < 0 ) *pAt_Water = 0; + if( *pAt_Earth < 0 ) *pAt_Earth = 0; + if( *pAt_Wind < 0 ) *pAt_Wind = 0; +} + + + +int BATTLE_CalAttMagicEffect( int AttEle , int DefPosEleValue , int DefNegEleValue ) +{ + int value; + + value = ( 100 * DefPosEleValue - 100 * DefNegEleValue ) / 1000; + + if( value > 10 ) + return 10; + else if( value < -10 ) + return -10; + + return value; +} + + + +int BATTLE_CalcCharaRatio( int AttEle , int charaidx ) +{ + int petidx , charahurt , pethurt; + int charaattr[4] , petattr[4]; + + // 没有宠物 + if( -1 == ( petidx = BATTLE_getRidePet( charaidx ) ) ) + return 10; + + // Nuke 20040330: Fix bug + if ( -1 == AttEle ) + return 5; + + BATTLE_GetPureAttr( charaidx , &charaattr[2] , &charaattr[1] , &charaattr[0], &charaattr[3] ); + BATTLE_GetPureAttr( petidx , &petattr[2] , &petattr[1] , &petattr[0] , &petattr[3] ); + + //print("\nAttEle: %d %d %d %d %d ",AttEle, charaattr[( AttEle + 1 ) % 4], charaattr[AttEle],petattr[( AttEle + 1 ) %4] , petattr[AttEle]); + + charahurt = 20 + BATTLE_CalAttMagicEffect( AttEle , charaattr[( AttEle + 1 ) % 4] , charaattr[AttEle] ); + pethurt = 20 + BATTLE_CalAttMagicEffect( AttEle , petattr[( AttEle + 1 ) %4] , petattr[AttEle] ); + + charahurt = 10 * charahurt / ( charahurt + pethurt ); + + if( charahurt < 2 ) + return 2; + else if( charahurt > 8 ) + return 8; + + return charahurt; +} + +static int BATTLE_AttrCalc( + int My_Fire, // 愤坌础(膜恳熬仃月幻丹) + int My_Water, + int My_Earth, + int My_Wind, + int My_None, + int Vs_Fire, // 锹澎础 + int Vs_Water, + int Vs_Earth, + int Vs_Wind, + int Vs_None +) +{ + int iRet = 0; + + // 绍及 猾 宁煌允月[ + My_Fire = My_Fire * Vs_None * AJ_UP // 绍 雄中 + + My_Fire * Vs_Fire * AJ_SAME // 绍 绍 元 + + My_Fire * Vs_Water * AJ_DOWN // 绍 浇中 + + My_Fire * Vs_Earth * AJ_SAME // 绍 萝 元 + + My_Fire * Vs_Wind * AJ_UP; // 绍 氘 雄中 + + // 及 猾 宁煌允月[ + My_Water = My_Water * Vs_None * AJ_UP // 雄中 + + My_Water * Vs_Fire * AJ_UP // 绍 雄中 + + My_Water * Vs_Water * AJ_SAME // 元 + + My_Water * Vs_Earth * AJ_DOWN // 萝 浇中 + + My_Water * Vs_Wind * AJ_SAME; // 氘 元 + + // 萝 + My_Earth = My_Earth * Vs_None * AJ_UP // 萝 雄中 + + My_Earth * Vs_Fire * AJ_SAME // 萝 绍 元 + + My_Earth * Vs_Water * AJ_UP // 萝 雄中 + + My_Earth * Vs_Earth * AJ_SAME // 萝 萝 元 + + My_Earth * Vs_Wind * AJ_DOWN; // 萝 氘 浇中 + + // 氘 + My_Wind = My_Wind * Vs_None * AJ_UP // 氘 雄中 + + My_Wind * Vs_Fire * AJ_DOWN // 氘 绍 浇中 + + My_Wind * Vs_Water * AJ_SAME // 氘 元 + + My_Wind * Vs_Earth * AJ_UP // 氘 萝 雄中 + + My_Wind * Vs_Wind * AJ_SAME; // 氘 氘 元 + + // 箪岭 + My_None = My_None * Vs_None * AJ_SAME // 元 + + My_None * Vs_Fire * AJ_DOWN // 绍 浇中 + + My_None * Vs_Water * AJ_DOWN // 浇中 + + My_None * Vs_Earth * AJ_DOWN // 萝 浇中 + + My_None * Vs_Wind * AJ_DOWN; // 氘 浇中 + + // 蝈 宁煌允月 + iRet = (My_Fire + My_Water + My_Earth + My_Wind + My_None) ; + + // 喘仃遥壬匀井曰匹 五仁卅匀凶及匹公及坌尺日允 + return (iRet * D_ATTR); +} + +extern float BATTLE_FieldAttAdjust(int battleindex,int pAt_Fire,int pAt_Water,int pAt_Earth,int pAt_Wind); +#ifndef _FIX_MAGICDAMAGE +static int BATTLE_AttrAdjust( + int attackindex, + int defindex, + int damage +) +{ + int At_Fire, At_Earth, At_Water, At_Wind, At_none; + int Df_Fire, Df_Earth, Df_Water, Df_Wind, Df_none; + float At_FieldPow, Df_FieldPow; + + BATTLE_GetAttr(attackindex,&At_Fire,&At_Water,&At_Earth,&At_Wind,&At_none); + + At_FieldPow = BATTLE_FieldAttAdjust( + CHAR_getWorkInt( attackindex, CHAR_WORKBATTLEINDEX ), + At_Fire, At_Water, At_Earth, At_Wind ); + + At_Fire *= damage; At_Water *= damage; At_Earth *= damage; + At_Wind *= damage; At_none *= damage; + BATTLE_GetAttr( defindex, &Df_Fire, &Df_Water, + &Df_Earth,&Df_Wind, &Df_none ); + Df_FieldPow = BATTLE_FieldAttAdjust( + CHAR_getWorkInt( defindex, CHAR_WORKBATTLEINDEX ), + Df_Fire, Df_Water, Df_Earth, Df_Wind ); + damage = BATTLE_AttrCalc( + At_Fire, At_Water, At_Earth, At_Wind, At_none, + Df_Fire, Df_Water, Df_Earth, Df_Wind, Df_none ); + damage *= (At_FieldPow / Df_FieldPow); + return damage; +} +#endif +// 计算闪避率 +// return: 0:没闪过 1:闪过 +int BATTLE_MagicDodge(int charindex,int nDefKind,int nFieldAttr) +{ + float fLuck = 0,fResist = 0; +#ifdef _EQUIT_DEFMAGIC + float Dluck=0.0; +#endif + int charType = CHAR_getInt( charindex, CHAR_WHICHTYPE); + // 如果是防守者是玩家 + if( charType == CHAR_TYPEPLAYER ){ + fLuck = (float)CHAR_getInt( charindex, CHAR_LUCK) * 3; + fResist = (float)CHAR_getInt( charindex, CHAR_EARTH_RESIST + nFieldAttr) * 0.15; + fLuck += fResist; +#ifdef _EQUIT_DEFMAGIC + Dluck = (float)(CHAR_getWorkInt( charindex, CHAR_EQUITQUIMAGIC)*0.9); + fLuck += Dluck; +#endif + }else {// 如果是防守者是宠物 + fLuck = (float)CHAR_getInt( charindex, CHAR_LV) * 0.2; + if(fLuck > 30) fLuck = 30; + } + if(rand()%100+1 > (int)fLuck) + return 0; + else + return 1; +} + + +#define DEF_MAGIC_NUM 4 + +extern void BATTLE_changeRideImage( int index ); + +#ifdef _FIX_MAGICDAMAGE +void BATTLE_MultiAttMagic( int battleindex, int attackNo, int toNo, + int attIdx ,int FieldAttr ,int Power, int MagicLv) +#else +void BATTLE_MultiAttMagic( int battleindex, int attackNo, int toNo , int attIdx, + int FieldAttr , int Power) +#endif +{ + int list[SIDE_OFFSET * 2 + 1]; + int listidx,i,j,k,z; + int basex , basey , magicattidx,def_is_player[10],def_be_hit[10]; + int att_magic_lv[4]; + int def_magic_resist[DEF_MAGIC_NUM]; + int attvalue , charahp , pethp , charaidx , petidx , charahurt,pet_att_lv = 1,pet_def_lv = 1,charahurt_temp; + char szcommand[256]; + int AttIsPlayer=0,DefIsPlayer=0; + int getexp = 0; + +#ifndef _FIX_MAGICDAMAGE + int att_magic_exp_add,att_magic_exp_sub,def_magic_exp_add,def_magic_exp_sub; + int lv_up_exp,DefFieldAttr = 0; + float temp = 0.0f; +// int attattr[5], defattr[5]; + char msgbuf[64]; + char kind[4][3] = {"地","水","火","风"}; +#else + BOOL TrueMagic=FALSE; +#endif + + // terry + + + if((z = BATTLE_MultiList(battleindex,toNo,list)) == -1) + return; + else + { + if(z != toNo) toNo = z; + } + + BATTLE_AttMagicEffect( battleindex , attackNo , list , attIdx ); + + // 计算攻击的人物清单 + if( attackNo < 10 ) + magicattidx = attIdx * 2 + 1; + else + magicattidx = attIdx * 2; + + listidx = 0; + memset(def_is_player,-1,sizeof(def_is_player)); + memset(def_be_hit,-1,sizeof(def_be_hit)); + + // 单人攻击 + if( toNo < 20 ){ + toNo = list[0]; + basex = CharTableIdx[toNo][1]; + basey = CharTableIdx[toNo][0]; + + for( i = 0 , j = basey - 1 ; j <= basey + 1 ; i++ , j++ ){ + if( toNo < 10 && ( j < 2 || j > 3 ) ) + continue; + else if( toNo >= 10 && ( j < 0 || j > 1 ) ) + continue; + // 计算那些人需要加入清单 + for( k = 0 ; k < 5 ; k++ ){ + if( basex - 2 + k < 0 || basex - 2 + k > 4 ) + continue; + + if( ATTMAGIC_magic[magicattidx].siField[i][k] && TRUE == BATTLE_TargetCheck( battleindex , CharTable[j][basex - 2 + k] ) ) + { + list[listidx] = CharTable[j][basex - 2 + k]; + listidx++; + } + } + } + }else if( 20 == toNo ){ // 右下全体 + for( i = 0 ; i < 2 ; i++ ){ + for( j = 0 ; j < 5 ; j++ ){ + if( ATTMAGIC_magic[magicattidx].siField[i][j] && TRUE == BATTLE_TargetCheck( battleindex , CharTable[i + 2][j] ) ){ + list[listidx] = CharTable[i + 2][j]; + listidx++; + } + } + } + }else if( 21 == toNo ){ // 左上全体 + for( i = 0 ; i < 2 ; i++ ){ + for( j = 0 ; j < 5 ; j++ ){ + if( ATTMAGIC_magic[magicattidx].siField[i][j] && TRUE == BATTLE_TargetCheck( battleindex , CharTable[i][j] ) ){ + list[listidx] = CharTable[i][j]; + listidx++; + } + } + } + } + // 左上第一列 , 左上第二列 , 右下第一列 , 右下第二列 + else if( 23 == toNo || 24 == toNo || 25 == toNo || 26 == toNo ){ + basey = toNo - 23; + + for( i = 0 , j = basey - 1 ; j <= basey + 1 ; i++ , j++ ){ + if( ( 25 == toNo || 26 == toNo ) && ( j < 2 || j > 3 ) ) + continue; + else if( ( 23 == toNo || 24 == toNo ) && ( j < 0 || j > 1 ) ) + continue; + + // 计算那些人需要加入清单 + for( k = 0 ; k < 5 ; k++ ){ + if( ATTMAGIC_magic[magicattidx].siField[i][k] && TRUE == BATTLE_TargetCheck( battleindex , CharTable[j][k] ) ) + { + list[listidx] = CharTable[j][k]; + listidx++; + } + } + } + } + + + qsort( list , listidx , sizeof( list[0] ) , ( FUNC )SortLoc );// 排序位置 + + // 取得人物的属性(不论玩家或是宠物) + //BATTLE_GetAttr( BATTLE_No2Index( battleindex , attackNo ) , &attattr[2] , &attattr[1] , &attattr[0] , &attattr[3] , &attattr[4] ); + // 如果攻击者是玩家,取得人物的魔法熟练度及魔法抗性 + { + int attType = CHAR_getInt(BATTLE_No2Index(battleindex,attackNo),CHAR_WHICHTYPE); + int Check=0; + AttIsPlayer=0; + if( attType == CHAR_TYPEPLAYER) { + AttIsPlayer = 1; + for(i=0;i<4;i++){ // att_magic_lv[i]: i = 0:地 1:水 2:火 3:风 + att_magic_lv[i] = CHAR_getInt(BATTLE_No2Index(battleindex,attackNo),CHAR_EARTH_EXP+i); + } + }else if( attType == CHAR_TYPEENEMY ) { + for(i=0;i<4;i++){ + att_magic_lv[i] = (CHAR_getInt(BATTLE_No2Index(battleindex,attackNo), CHAR_LV)*0.9); + } + }else { +#ifdef _FIX_MAGICDAMAGE + AttIsPlayer = 1; +#endif + for(i=0;i<4;i++){ +#ifdef _FIX_MAGICDAMAGE + att_magic_lv[i] = CHAR_getInt(BATTLE_No2Index(battleindex,attackNo),CHAR_EARTH_EXP+i); +#else + att_magic_lv[i] = 0; +#endif + } + } + Check = rand()%100; +#ifdef _FIX_MAGICDAMAGE + if( Check > att_magic_lv[ FieldAttr] ) TrueMagic = FALSE; + else TrueMagic = TRUE; +#endif + } + pet_att_lv = CHAR_getInt(BATTLE_No2Index(battleindex,attackNo), CHAR_LV); + + z = 0; + for(i=0;i 0 ){ + float def = (float)(CHAR_getWorkInt( charaidx, CHAR_OTHERSTATUSNUMS )); + def = def/100; + for(j=0;j 0) { + CHAR_setWorkInt(def_be_hit[i],CHAR_WORKSLEEP,0); + z = BATTLE_Index2No(battleindex,def_be_hit[i]); + sprintf(szcommand,"BM|%X|%X|",z,0); + BATTLESTR_ADD(szcommand); + } + } +#else + //TrueMagic == FALSE + // 攻击方的经验值----------------------------------------------------------------------------- + if(AttIsPlayer){ + // 被克的魔法 + DefFieldAttr = (FieldAttr+1)%4; + // 取得玩家所用的魔法的经验值 + att_magic_exp_add = CHAR_getInt(BATTLE_No2Index(battleindex,attackNo),CHAR_EARTH_ATTMAGIC_EXP+FieldAttr); + // 取得玩家所用的魔法的被克魔法经验值 + att_magic_exp_sub = CHAR_getInt(BATTLE_No2Index(battleindex,attackNo),CHAR_EARTH_ATTMAGIC_EXP+DefFieldAttr); + // 依所使用的魔法加该属性的exp,打几只算几点exp + att_magic_exp_add += getexp; + // 依所使用的魔法扣被克属性的exp,打几只扣几点exp + att_magic_exp_sub -= getexp; + lv_up_exp = Magic_Level_Table[att_magic_lv[FieldAttr]]; + while(att_magic_exp_add >= lv_up_exp || att_magic_exp_sub < 0){ + // 如果玩家所用的魔法的经验值现在可以升级了 + if(att_magic_exp_add >= lv_up_exp){ + // 如果超过了100级 + if(att_magic_lv[FieldAttr] + 1 > 100){ + att_magic_lv[FieldAttr] = 100; + // 经验值清为0 + att_magic_exp_add = 0; + }else{ + att_magic_lv[FieldAttr]++; + // 把现在的经验值扣掉升了级所用的经验值 + att_magic_exp_add -= lv_up_exp; + snprintf(msgbuf,sizeof(msgbuf),"你的 %s 魔法熟练度升级为 %d。",kind[FieldAttr],att_magic_lv[FieldAttr]); + CHAR_talkToCli(BATTLE_No2Index(battleindex,attackNo),-1,msgbuf,CHAR_COLORRED); + } + } + // 如果玩家所用的魔法的相克魔法的经验值现在可以降级了 + if(att_magic_exp_sub < 0 ){ + // 如果等级已经是1级 + if(att_magic_lv[DefFieldAttr] <= 1){ + att_magic_lv[DefFieldAttr] = 1; + // 经验值清为0 + att_magic_exp_sub = 0; + }else{ + att_magic_lv[DefFieldAttr]--; + // 把下一个等级的经验值扣掉现在的经验值 + att_magic_exp_sub = Magic_Level_Table[att_magic_lv[DefFieldAttr]] + att_magic_exp_sub; + snprintf(msgbuf,sizeof(msgbuf),"你的 %s 魔法熟练度降级为 %d。",kind[DefFieldAttr],att_magic_lv[DefFieldAttr]); + CHAR_talkToCli(BATTLE_No2Index(battleindex,attackNo),-1,msgbuf,CHAR_COLORRED); + } + } + lv_up_exp = Magic_Level_Table[att_magic_lv[FieldAttr]]; + } + CHAR_setInt(BATTLE_No2Index(battleindex,attackNo),CHAR_EARTH_EXP+FieldAttr,att_magic_lv[FieldAttr]); + CHAR_setInt(BATTLE_No2Index(battleindex,attackNo),CHAR_EARTH_ATTMAGIC_EXP+FieldAttr,att_magic_exp_add); + CHAR_setInt(BATTLE_No2Index(battleindex,attackNo),CHAR_EARTH_EXP+DefFieldAttr,att_magic_lv[DefFieldAttr]); + CHAR_setInt(BATTLE_No2Index(battleindex,attackNo),CHAR_EARTH_ATTMAGIC_EXP+DefFieldAttr,att_magic_exp_sub); + } + + // 防守方的经验值----------------------------------------------------------------------------- + for(i=0;i= lv_up_exp || def_magic_exp_sub < 0){ + // 如果防守方玩家对此魔法的抗性的经验值现在可以升级了 + if(def_magic_exp_add >= lv_up_exp){ + // 如果超过了100级 + if(def_magic_resist[FieldAttr] + 1 > 100) def_magic_resist[FieldAttr] = 100; + else { + def_magic_resist[FieldAttr]++; + snprintf(msgbuf,sizeof(msgbuf),"你的 %s 魔法抗性升级为 %d。",kind[FieldAttr],def_magic_resist[FieldAttr]); + CHAR_talkToCli(charaidx,-1,msgbuf,CHAR_COLORRED); + } + // 经验值清为0 + def_magic_exp_add = 0; + } + // 如果防守方玩家对此魔法的抗性的相克魔法的经验值现在可以降级了 + if(def_magic_exp_sub < 0 ) { + // 如果等级已经是1级 + if(def_magic_resist[DefFieldAttr] <= 1) def_magic_exp_sub = 0; // 经验值清为0 + else { + def_magic_resist[DefFieldAttr]--; + // 经验值变成下一个等级的经验值 + def_magic_exp_sub = Magic_Level_Table[def_magic_resist[DefFieldAttr]]; + snprintf(msgbuf,sizeof(msgbuf),"你的 %s 魔法抗性降级为 %d。",kind[DefFieldAttr],def_magic_resist[DefFieldAttr]); + CHAR_talkToCli(charaidx,-1,msgbuf,CHAR_COLORRED); + } + } + lv_up_exp = Magic_Level_Table[def_magic_resist[FieldAttr]]; + } + CHAR_setInt(charaidx,CHAR_EARTH_RESIST+FieldAttr,def_magic_resist[FieldAttr]); + CHAR_setInt(charaidx,CHAR_EARTH_DEFMAGIC_EXP+FieldAttr,def_magic_exp_add); + CHAR_setInt(charaidx,CHAR_EARTH_RESIST+DefFieldAttr,def_magic_resist[DefFieldAttr]); + CHAR_setInt(charaidx,CHAR_EARTH_DEFMAGIC_EXP+DefFieldAttr,def_magic_exp_sub); + } + // 如果被攻击者中了睡眠 + if(CHAR_getWorkInt(def_be_hit[i],CHAR_WORKSLEEP) > 0) { + CHAR_setWorkInt(def_be_hit[i],CHAR_WORKSLEEP,0); + z = BATTLE_Index2No(battleindex,def_be_hit[i]); + sprintf(szcommand,"BM|%X|%X|",z,0); + BATTLESTR_ADD(szcommand); + } + } +#endif +} + +#endif + +#ifdef _MAGIC_TOCALL +void BATTLE_MultiToCallDragonMagic( int battleindex, int attackNo, int toNo, + int attIdx ,int FieldAttr ,int Power, int ImageNo) +{ + int list[SIDE_OFFSET * 2 + 1]; + int listidx,i,j,k,z; + int /*basex , */basey , magicattidx,def_is_player[10],def_be_hit[10]; + int attvalue , charahp , pethp , charaidx , petidx , charahurt,charahurt_temp; + char szcommand[256]; + int /*AttIsPlayer = 0,*/DefIsPlayer = 0; + +#ifndef _FIX_MAGICDAMAGE + int att_magic_exp_add,att_magic_exp_sub,def_magic_exp_add,def_magic_exp_sub; + int lv_up_exp,DefFieldAttr = 0; + float temp = 0.0f; + char msgbuf[64]; +#else +#endif + + int icindex, ioindex; + // terry + print("BATTLE_MultiToCallDragonMagic in.............\n"); + if((z = BATTLE_MultiList(battleindex,toNo,list)) == -1) + return; + else{ + if(z != toNo) toNo = z; + } + + TOCALL_magic[attIdx].uiSpriteNum = ImageNo; + + BATTLE_ToCallDragonEffect( battleindex , attackNo , list , attIdx); + + // 计算攻击的人物清单 + if( attackNo < 10 ) + magicattidx = attIdx * 2 + 1; + else + magicattidx = attIdx * 2; + + + listidx = 0; + memset(def_is_player,-1,sizeof(def_is_player)); + memset(def_be_hit,-1,sizeof(def_be_hit)); + + // 单人攻击 + if( toNo < 20 ){ + toNo = list[0]; + listidx++; + + } else if( 20 == toNo ){ // 右下全体 + for( i = 0 ; i < 2 ; i++ ){ + for( j = 0 ; j < 5 ; j++ ){ + if(TRUE == BATTLE_TargetCheck( battleindex , CharTable[i + 2][j] ) ){ + list[listidx] = CharTable[i + 2][j]; + listidx++; + } + } + } + } else if( 21 == toNo ){ // 左上全体 + for( i = 0 ; i < 2 ; i++ ){ + for( j = 0 ; j < 5 ; j++ ){ + if(TRUE == BATTLE_TargetCheck( battleindex , CharTable[i][j] ) ){ + list[listidx] = CharTable[i][j]; + listidx++; + } + } + } + } // 左上第一列 , 左上第二列 , 右下第一列 , 右下第二列 + else if( 23 == toNo || 24 == toNo || 25 == toNo || 26 == toNo ){ + basey = toNo - 23; + for( i = 0 , j = basey - 1 ; j <= basey + 1 ; i++ , j++ ){ + if( ( 25 == toNo || 26 == toNo ) && ( j < 2 || j > 3 ) ) + continue; + else if( ( 23 == toNo || 24 == toNo ) && ( j < 0 || j > 1 ) ) + continue; + // 计算那些人需要加入清单 + for( k = 0 ; k < 5 ; k++ ){ + if(TRUE == BATTLE_TargetCheck( battleindex , CharTable[j][k] ) ) + { + list[listidx] = CharTable[j][k]; + listidx++; + } + } + } + } + print("listidx=%d............................\n", listidx); + qsort( list , listidx , sizeof( list[0] ) , ( FUNC )SortLoc );// 排序位置 + for( i = 0 ; i < listidx ; i++ ) { + int defType; + charaidx = BATTLE_No2Index( battleindex , list[i] ); + petidx = BATTLE_getRidePet( charaidx ); + defType = CHAR_getInt(charaidx, CHAR_WHICHTYPE); + DefIsPlayer = 0; + if (defType == CHAR_TYPEPLAYER) { + DefIsPlayer = 1; + } + if (CHAR_createCharacter( 100354 /*image no*/, 100, 600, 370, 0, + &icindex, &ioindex, 0) == TRUE) { + + print("char create success\n"); +// CHAR_setInt( icindex, CHAR_STR, 100); + CHAR_setInt( icindex, CHAR_LUCK, 1); + CHAR_setWorkInt( icindex, CHAR_WORKATTACKPOWER, + Power ); + CHAR_setWorkInt( icindex, CHAR_WORKOTHERDMAGE, + 0); + + if (BATTLE_MagicDodge(charaidx, DefIsPlayer, FieldAttr)) { +// 没击中 + attvalue = 0; + } else { + if( 0 == TOCALL_magic[attIdx].uiAttackType ) {// 单人攻击 + attvalue = BATTLE_DamageCalc(icindex, charaidx); + } + else { + attvalue = BATTLE_DamageCalc(icindex, charaidx); + } + } + print("char create success=%d %d\n", icindex, attvalue); + CHAR_CharaDelete(icindex); + charahp = CHAR_getInt( charaidx , CHAR_HP ); + if (-1 == petidx || CHAR_getInt(petidx, CHAR_HP) <= 0) { +// 没骑宠物 + if( ( charahp -= attvalue ) < 0 ) { + charahp = 0; + } + CHAR_setInt( charaidx , CHAR_HP , charahp ); + pethp = 0; + if( 0 == TOCALL_magic[attIdx].uiAttackType ) {// 单人攻击 + sprintf( szcommand , "%X|%X|%X|%X|" , toNo , list[i] , attvalue , pethp); + } else + sprintf( szcommand , "%X|%X|%X|%X|" , list[i] , list[i] , attvalue , pethp); + }else{ + pethp = CHAR_getInt( petidx , CHAR_HP ); + charahurt = attvalue * BATTLE_CalcCharaRatio( FieldAttr , charaidx ) / 10; + + charahurt_temp = charahurt; + if( ( charahp -= charahurt ) < 0 ) + { + charahurt = charahp; + charahp = 0; + } + + attvalue = attvalue - charahurt; + if( ( pethp -= attvalue ) < 0) + { + pethp = 0; + // 宠物没血了退出战场 + CHAR_setInt(charaidx,CHAR_RIDEPET,-1); + BATTLE_changeRideImage(charaidx); + CHAR_setWorkInt(charaidx,CHAR_WORKPETFALL,1); + } + CHAR_setInt( charaidx , CHAR_HP , charahp ); + CHAR_setInt( petidx , CHAR_HP , pethp ); + + charahurt = charahurt_temp; + + if( 0 == TOCALL_magic[attIdx].uiAttackType ) {// 单人攻击 + sprintf( szcommand , "%X|%X|%X|%X|" , toNo , list[i] , charahurt , attvalue); + } else + sprintf( szcommand , "%X|%X|%X|%X|" , list[i] , list[i] , charahurt , attvalue); + + } + + BATTLESTR_ADD( szcommand ); + } + } + + sprintf( szcommand , "%X|" , 0x5711438 ); + BATTLESTR_ADD( szcommand ); + +} + +#endif + +//*********************************************************** +// +// 芊羁匹 醒及平乓仿弁正□毛汊唾今六月 +// +void BATTLE_MultiRessurect( + int battleindex, // 田玄伙奶件犯永弁旦 + int attackNo, // 井仃月谛 寞 + int toNo, // 井仃日木月谛 寞 + int power, // 湘 荚汊袄 + int per, // ⊙井" + int UseEffect, // 银丹谛及巨白尼弁玄 + int RecevEffect // 井仃日木月谛及巨白尼弁玄 +) +// +//*********************************************************** +{ + int i, toindex, UpPoint = 0, workhp; + int ToList[SIDE_OFFSET*2+1]; + + //char szBuffer[256]=""; + char szCommand[256]; + + + BATTLE_MultiListDead( battleindex, toNo, ToList ); + + BATTLE_MagicEffect( + battleindex, // 田玄伙奶件犯永弁旦 + attackNo, // 井仃月谛 寞(ㄟ ㄠㄨ) + ToList, // 井仃日木月谛 寞伉旦玄(ㄟ ㄠㄨ) + UseEffect, // 井仃月谛巨白尼弁玄 + RecevEffect // 井仃日木月谛巨白尼弁玄 + ); + + // 汊唾今六月 + for( i = 0; ToList[i] != -1; i ++ ){ + // 锹澎及奶件犯永弁旦 + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + + // 反皿伊奶乩□及戏五忒曰 仄 + if( BattleArray[battleindex].type == BATTLE_TYPE_P_vs_P + && CHAR_getInt( toindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER + ){ + continue; + } + + // 竣濮仄化中卅仃木壬汊唾今六卅中 + if( CHAR_getFlg( toindex, CHAR_ISDIE ) == FALSE ){ + continue; + } + + // 公及引引及煌遥 + UpPoint = power; + + if( per ){ + // ⊙煌遥 + UpPoint *= CHAR_getWorkInt( toindex, CHAR_WORKMAXHP ) * 0.01; + } + + if( power == 0 ){ + // 仇及桦宁反敦蝈荚汊 + UpPoint = CHAR_getWorkInt( toindex, CHAR_WORKMAXHP ); + }else{ + // 荚汊汹卞汔毛 凶六月(漆反赝癫) + UpPoint = RAND( (power*0.9), (power*1.1) ); + } + // 斓匹手ㄠ + UpPoint = max( 1, UpPoint ); + + workhp = CHAR_getInt( toindex, CHAR_HP ) + UpPoint; + + // 毛译尹卅中方丹卞荚汊 + CHAR_setInt( toindex, CHAR_HP, + min( workhp, CHAR_getWorkInt( toindex, CHAR_WORKMAXHP ) ) ); + + // 汊唾 + CHAR_setFlg( toindex, CHAR_ISDIE, 0 ); + + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)恢复意识", + // CHAR_getUseName( toindex ) ); + + // 须 煤 + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + // (汊唾)戊穴件玉毛中木月 + snprintf( szCommand, sizeof(szCommand), + "BL|r%X|h%X|", ToList[i], CHAR_getInt( toindex, CHAR_HP ) ); + + // 侬 馨笛 + BATTLESTR_ADD( szCommand ); +/* + { int Sign, Damage; + Sign = (UpPoint >= 0)?(1):(0); + Damage = ABS( UpPoint ); + // ( 荚汊)戊穴件玉毛中木月 + snprintf( szCommand, sizeof(szCommand), + "BD|r%X|%X|%X|d%X|", ToList[i], 0, Sign, Damage ); + } + // 侬 馨笛 + BATTLESTR_ADD( szCommand ); +*/ + + // 衬午及爵 匹伉旦弁互卅井匀凶日 + if( BattleArray[battleindex].norisk == 0 + && BattleArray[battleindex].type == BATTLE_TYPE_P_vs_E + ){ + // 仇仇匹矢永玄分匀凶日袄毛皿仿旦允月 + if( CHAR_getInt( toindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + CHAR_PetAddVariableAi( toindex, AI_FIX_PETRESSURECT ); + } + } + } + + return; + +} + +#ifdef _Item_ReLifeAct +void BATTLE_MultiReLife( int battleindex, int attackNo, int toNo, + int power, int RecevEffect ) +{ + int i, toindex, UpPoint = 0, workhp; + int ToList[SIDE_OFFSET*2+1]; + //char szBuffer[256]=""; + char szCommand[256]; + char buf1[256]; + + memset(szCommand, 0, sizeof(szCommand)); + BATTLE_MultiListDead( battleindex, toNo, ToList ); + + + //snprintf( szCommand, sizeof(szCommand), "Bj|"); + for( i = 0; ToList[i] != -1; i ++ ){ + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + //if( BattleArray[battleindex].type == BATTLE_TYPE_P_vs_P + //&& CHAR_getInt( toindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + // continue; + //} + if( CHAR_getFlg( toindex, CHAR_ISDIE ) == FALSE ){ + continue; + } + UpPoint = power; + workhp = max( 1, UpPoint ); + + CHAR_setInt( toindex, CHAR_HP, min( workhp, CHAR_getWorkInt( toindex, CHAR_WORKMAXHP ) ) ); + CHAR_setFlg( toindex, CHAR_ISDIE, 0 ); + //snprintf( szBuffer, sizeof(szBuffer), "(%s)恢复意识", CHAR_getUseName( toindex ) ); +#if 0 // Robin 修正多人同时替身娃娃复活会当机 + snprintf( buf1, sizeof(buf1), "Bj|r%X|l%X|e%X|h%X|FF|", + ToList[i], 1, RecevEffect, CHAR_getInt( toindex, CHAR_HP )); + strcat( szCommand, buf1); +#else + snprintf( buf1, sizeof(buf1), + "BJ|a%X|m%X|e%X|e%X|FF|", + ToList[i], + CHAR_getInt( toindex, CHAR_MP ), + RecevEffect, //MyEffect, + 0 //ToEffect + ); + strcat( szCommand, buf1); + + snprintf( buf1, sizeof(buf1), + "BL|r%X|h%X|", ToList[i], CHAR_getInt( toindex, CHAR_HP ) ); + strcat( szCommand, buf1); + +#endif + if( BattleArray[battleindex].norisk == 0 + && BattleArray[battleindex].type == BATTLE_TYPE_P_vs_E ){ + if( CHAR_getInt( toindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + CHAR_PetAddVariableAi( toindex, AI_FIX_PETRESSURECT ); + } + } + } + //strcat( szCommand, "FF|"); + BATTLESTR_ADD( szCommand ); + return; +} +#endif + +void BATTLE_MultiStatusChange( + int battleindex, // 田玄伙奶件犯永弁旦 + int attackNo, // 井仃月谛 寞 + int toNo, // 井仃日木月谛 寞 + int status, // 旦 □正旦潘 + int turn, // 正□件醒 + int UseEffect, // 银丹谛及巨白尼弁玄 + int RecevEffect, // 井仃日木月谛及巨白尼弁玄 + int Success // 岳 +) +{ + int i, toindex, charaindex; + int perStatus; + int ToList[SIDE_OFFSET*2+1]; + //char szBuffer[256]=""; + + BATTLE_MultiList( battleindex, toNo, ToList ); + BATTLE_MagicEffect( + battleindex, // 田玄伙奶件犯永弁旦 + attackNo, // 井仃月谛 寞(ㄟ ㄠㄨ) + ToList, // 井仃日木月谛 寞伉旦玄(ㄟ ㄠㄨ) + UseEffect, // 井仃月谛巨白尼弁玄 + RecevEffect // 井仃日木月谛巨白尼弁玄 + ); + + charaindex = BATTLE_No2Index( battleindex, attackNo ); + for( i = 0; ToList[i] != -1; i ++ ){ + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + if( BATTLE_StatusAttackCheck( charaindex, + toindex, status, Success, 30, 1.0, &perStatus ) == FALSE ){ + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)无法将(%s)做成(%s)(%d%%)", + // CHAR_getUseName( charaindex ), + // CHAR_getUseName( toindex ), + // aszStatusFull[status], + // perStatus + //); + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + }else{ + CHAR_setWorkInt( toindex, StatusTbl[status], turn ); + + if( status == BATTLE_ST_PARALYSIS + || status == BATTLE_ST_SLEEP + || status == BATTLE_ST_STONE + || status == BATTLE_ST_BARRIER ){ + CHAR_setWorkInt( toindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + } + + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)将(%s)做成(%s)(%d%%)", + // CHAR_getUseName( charaindex ), + // CHAR_getUseName( toindex ), + // aszStatusFull[status], + // perStatus + //); + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + BATTLE_BadStatusString( ToList[i], status ); + } + } + return; +} + +#ifdef _OTHER_MAGICSTAUTS +void BATTLE_MultiMagicStatusChange( int battleindex, int attackNo, int toNo, int status, int turn, + int UseEffect, int RecevEffect, int nums ) +{ + int i, j, toindex, charaindex; + int ToList[SIDE_OFFSET*2+1]; + + BATTLE_MultiList( battleindex, toNo, ToList ); + BATTLE_MagicEffect( battleindex, attackNo, ToList, UseEffect, RecevEffect ); + + charaindex = BATTLE_No2Index( battleindex, attackNo ); + for( i = 0; ToList[i] != -1; i ++ ){ + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + for( j=1; j 0 ){ + tostatus = j; + } + } + //======== 仇仇匹岳 井升丹井毛 烂今六月 ========== + if( tostatus == 0 ){//正常 + // 撩 凛 +// print("\n vincent--很健康"); + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)很健康", + // CHAR_getUseName( toindex ) ); + }else + // 蝈莒隙烂匹尕麻僖分匀凶日 + if( ( status == 0 && tostatus != 0 && tostatus <= CHAR_WORKCONFUSION ) // 蝈莒隙烂匹尕麻僖//找到异常 + || ( status == tostatus ) // 唱橘午荚汊椭互穴永民仄凶 + ){ + // 荚汊允月 + CHAR_setWorkInt( toindex, StatusTbl[tostatus], 0 ); +#ifdef _MAGIC_NOCAST + if( StatusTbl[tostatus] == CHAR_WORKNOCAST ){ + //print("\nvincent-->lssproto_NC_send"); + lssproto_NC_send( getfdFromCharaIndex( toindex ), 0);//沉默解除 + } +#endif +// print("\n vincent--解除了:%d",tostatus); + // 岳 凛 + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)解除了(%s)的(%s)", + // CHAR_getUseName( charaindex ), + // CHAR_getUseName( toindex ), + // aszStatusFull[tostatus] + //); + // 仇仇匹旦 □正旦唱橘迕 侬 戊穴件玉毛中木月 + BATTLE_BadStatusString( ToList[i], 0 );//解除异常 + + }else{ +// print("\n vincent--不"); + // 撩 凛 +/* snprintf( szBuffer, sizeof(szBuffer), + "(%s)不(%s)", + CHAR_getUseName( toindex ), + aszStatusFull[status] + ); +*/ + } + // 须 煤 + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + } + + return; +} + +//*********************************************************** +// +// 芊羁匹 醒及平乓仿弁正□毛 芊 豢 +// +void BATTLE_MultiMagicDef( + int battleindex, // 田玄伙奶件犯永弁旦 + int attackNo, // 井仃月谛 寞 + int toNo, // 井仃日木月谛 寞 + int kind, // 升及 芊 豢井 + int count, // 荚醒 + int UseEffect, // 银丹谛及巨白尼弁玄 + int RecevEffect // 井仃日木月谛及巨白尼弁玄 +) +// +//*********************************************************** +{ + + int i, toindex, charaindex; + int ToList[SIDE_OFFSET*2+1]; + + //char szBuffer[256]=""; + + + BATTLE_MultiList( battleindex, toNo, ToList ); + + BATTLE_MagicEffect( + battleindex, // 田玄伙奶件犯永弁旦 + attackNo, // 井仃月谛 寞(ㄟ ㄠㄨ) + ToList, // 井仃日木月谛 寞伉旦玄(ㄟ ㄠㄨ) + UseEffect, // 井仃月谛巨白尼弁玄 + RecevEffect // 井仃日木月谛巨白尼弁玄 + ); + + charaindex = BATTLE_No2Index( battleindex, attackNo ); + for( i = 0; ToList[i] != -1; i ++ ){ + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + CHAR_setWorkInt( toindex, MagicDefTbl[kind], count ); + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)将(%s)遭受(损伤%s)", + // CHAR_getUseName( charaindex ), + // CHAR_getUseName( toindex ), + // aszMagicDefFull[kind] + //); + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + } + + return; + + + +} + + +#if 1 + +//*********************************************************** +// +// 芊羁匹 醒及平乓仿弁正□及由仿丢□正毛晓票今六月 +// +void BATTLE_MultiParamChange( + int battleindex, // 田玄伙奶件犯永弁旦 + int attackNo, // 井仃月谛 寞 + int toNo, // 井仃日木月谛 寞 + int kind, // 升及由仿丢□正井 + int power, // 禾奶件玄 + int par, // ⊙煌遥允月 + int UseEffect, // 银丹谛及巨白尼弁玄 + int RecevEffect // 井仃日木月谛及巨白尼弁玄 +) +// +//*********************************************************** +{ + + int i, toindex, charaindex; + int ToList[SIDE_OFFSET*2+1]; + int res = 0, work; + //char szBuffer[256]=""; + + + BATTLE_MultiList( battleindex, toNo, ToList ); + + BATTLE_MagicEffect( + battleindex, // 田玄伙奶件犯永弁旦 + attackNo, // 井仃月谛 寞(ㄟ ㄠㄨ) + ToList, // 井仃日木月谛 寞伉旦玄(ㄟ ㄠㄨ) + UseEffect, // 井仃月谛巨白尼弁玄 + RecevEffect // 井仃日木月谛巨白尼弁玄 + ); + + charaindex = BATTLE_No2Index( battleindex, attackNo ); + + // 升及由仿丢□正卞允月井 + for( i = 0; ToList[i] != -1; i ++ ){ + + // 锹澎及奶件犯永弁旦 + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + + switch( kind ){ + case PC_KIND_ATTACK: + if( par ){ + // ⊙煌遥卅凶户}ㄠㄟㄟ反井仃卅中 + work = CHAR_getWorkInt( toindex, CHAR_WORKFIXSTR ); + work = work * power; + }else{ + // 公及引引及煌遥卅凶户ㄠㄟㄟ井仃月 + work = power * 100; + } + CHAR_setWorkInt( toindex, CHAR_WORKMODATTACK, + CHAR_getWorkInt( toindex, CHAR_WORKMODATTACK ) + work ); + res = work * 0.01; + break; + case PC_KIND_DEFENSE: + if( par ){ + // ⊙煌遥卅凶户}ㄠㄟㄟ反井仃卅中 + work = CHAR_getWorkInt( toindex, CHAR_WORKFIXTOUGH ); + work = work * power; + }else{ + // 公及引引及煌遥卅凶户ㄠㄟㄟ井仃月 + work = power * 100; + } + CHAR_setWorkInt( toindex, CHAR_WORKMODDEFENCE, + CHAR_getWorkInt( toindex, CHAR_WORKMODDEFENCE ) + work ); + res = work * 0.01; + break; + case PC_KIND_QUICK: + if( par ){ + // ⊙煌遥卅凶户}ㄠㄟㄟ反井仃卅中 + work = CHAR_getWorkInt( toindex, CHAR_WORKFIXDEX ); + work = work * power; + }else{ + // 公及引引及煌遥卅凶户ㄠㄟㄟ井仃月 + work = power * 100; + } + CHAR_setWorkInt( toindex, CHAR_WORKMODQUICK, + CHAR_getWorkInt( toindex, CHAR_WORKMODQUICK ) + work ); + res = work * 0.01; + break; + case PC_KIND_CHARM: + if( par ){ + // CHARM 反 100 今木化卅中凶户}100坌及ㄠ允月 + work = CHAR_getWorkInt( toindex, CHAR_WORKFIXCHARM ); + work = work * power * 0.01; + }else{ + // 公及引引及煌遥 + work = power; + } + CHAR_setWorkInt( toindex, CHAR_WORKMODCHARM, + CHAR_getWorkInt( toindex, CHAR_WORKMODCHARM ) + work ); + res = work; + break; + case PC_KIND_CAPTURE: + // CAPTURE 反 % 及心 + work = power; + CHAR_setWorkInt( toindex, CHAR_WORKMODCAPTURE, + CHAR_getWorkInt( toindex, CHAR_WORKMODCAPTURE ) + work ); + res = work; + break; + } + + // 仇仇引匹 凶日 内岳 + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)被(%s)(%+d)", + // CHAR_getUseName( toindex ), + // aszParamChangeFull[kind], + // res + //); + + // 须 煤 + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + } + + return; +} + +#endif + + +//*********************************************************** +// +// 芊羁匹 醒及箪岭 鳖 +// +void BATTLE_MultiAttReverse( + int battleindex, // 田玄伙奶件犯永弁旦 + int attackNo, // 井仃月谛 寞 + int toNo, // 井仃日木月谛 寞 + int UseEffect, // 银丹谛及巨白尼弁玄 + int RecevEffect // 井仃日木月谛及巨白尼弁玄 +) +// +//*********************************************************** +{ + + int i, toindex, charaindex; + int ToList[SIDE_OFFSET*2+1]; + int flg, OnOff; + char szBuffer[256]=""; + + BATTLE_MultiList( battleindex, toNo, ToList ); + + BATTLE_MagicEffect( + battleindex, // 田玄伙奶件犯永弁旦 + attackNo, // 井仃月谛 寞(ㄟ ㄠㄨ) + ToList, // 井仃日木月谛 寞伉旦玄(ㄟ ㄠㄨ) + UseEffect, // 井仃月谛巨白尼弁玄 + RecevEffect // 井仃日木月谛巨白尼弁玄 + ); + + charaindex = BATTLE_No2Index( battleindex, attackNo ); + + // 升及由仿丢□正卞允月井 + for( i = 0; ToList[i] != -1; i ++ ){ + + // 锹澎及奶件犯永弁旦 + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + + flg = CHAR_getWorkInt( toindex, CHAR_WORKBATTLEFLG ); + flg ^= CHAR_BATTLEFLG_REVERSE; // 鳖 + CHAR_setWorkInt( toindex, CHAR_WORKBATTLEFLG, flg ); + OnOff = ( flg & CHAR_BATTLEFLG_REVERSE )?(1):(0); + + // 仇仇匹允井今内 鳖今六月 + BATTLE_AttReverse( toindex ); + + if( OnOff ){ + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)的属性变成相反。", + // CHAR_getUseName( toindex ) ); + }else{ + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)回复成原本的属性。", + // CHAR_getUseName( toindex ) ); + } + + // 须 煤 + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + // 仇仇匹箪岭 鳖及 侬 毛霜月 + sprintf( szBuffer, "BR|%X|%X|", ToList[i], OnOff ); + BATTLESTR_ADD( szBuffer ); + } + + return; + +} + +void BATTLE_MultiCaptureUp( + int battleindex, + int attackNo, + int toNo, + int power, + int UseEffect, + int RecevEffect +) +{ + int i, toindex, UpPoint = 0, workhp; + int ToList[SIDE_OFFSET*2+1]; + + //char szBuffer[256]=""; + char szCommand[256]; + + BATTLE_MultiList( battleindex, toNo, ToList ); + + BATTLE_MagicEffect( + battleindex, + attackNo, + ToList, + UseEffect, + RecevEffect + ); + + for( i = 0; ToList[i] != -1; i ++ ){ + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + + if( CHAR_getInt( toindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ){ + continue; + } + + if( CHAR_getFlg( toindex, CHAR_ISDIE ) == TRUE ){ + continue; + } + + UpPoint = power; + + UpPoint = RAND( (power*0.9), (power*1.1) ); + + workhp = CHAR_getWorkInt( toindex, CHAR_WORKMODCAPTURE ) + UpPoint; + + CHAR_setWorkInt( toindex, CHAR_WORKMODCAPTURE, workhp ); + + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)的捕获率变成(%d)", + // CHAR_getUseName( toindex ), UpPoint ); + + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + snprintf( szCommand, sizeof( szCommand ), + "B%%|%X|%X|", ToList[i], BFUKI_CAPTUREUP ); + + BATTLESTR_ADD( szCommand ); + } + return; +} + + + + + +//**************************************************************** +// +// 白奴□伙玉箪岭 凳热诸 +// +int BATTLE_FieldAttChange( + int charaindex, // 井仃月谛及奶件犯永弁旦 + char *pArg +) +// +// 岳 允木壬 TRUE +// 撩 卅日 FALSE +// +//**************************************************************** + +{ + + int attr = -1, i, attackNo, turn = 3; + int battleindex, power = 30; + int FieldAttr[] = { BATTLE_ATTR_NONE, BATTLE_ATTR_EARTH, BATTLE_ATTR_WATER, BATTLE_ATTR_FIRE, BATTLE_ATTR_WIND }; + char szBuffer[256]=""; + char szCommand[256], + // Robin 03/20 debug + //*pszP, *aszAttr[] = { "无", "土", "水", "火", "风" }; + *pszP, *aszAttr[] = { "无", "地", "水", "火", "风" }; + // Robin 03/21 debug + //char szTurn[] = "回"; + char szTurn[] = "turn"; + + + pszP = pArg; + // 箪岭毛潸 + for( ;attr == -1 && pszP[0] != 0; pszP++ ){ + for( i = 0; i < 5; i ++ ){ + // 箪岭疋永正伉井" + if( strncmp( pszP, aszAttr[i], 2 ) == 0 ){ + attr = i; + pszP +=2; + break; + } + } + } + // 箪岭 中及匹撩 + if( attr == -1 ) + { + return FALSE; + } + + // 升木仁日中 凳今六月井" + sscanf( pszP, "%d", &power ); + if( power < 0 || power > 100 )power = 30; + + // 窒正□件 凳今六月井" + if( ( pszP = strstr( pszP, szTurn ) ) != NULL){ + pszP += sizeof( szTurn ); + sscanf( pszP, "%d", &turn ); + } + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return FALSE; + // 祭今六月箪岭 + BattleArray[battleindex].field_att = FieldAttr[attr]; + // 膜恳允月由伐□ + BattleArray[battleindex].att_pow = power; + // 膜恳允月正□件醒 + BattleArray[battleindex].att_count = turn; + + // 仇仇引匹 凶日 内岳 + if( attr >= 0 ){ + //snprintf( szBuffer, sizeof(szBuffer), + // "(%s)将field的属性改为(%s)", + // CHAR_getUseName( charaindex ), + // aszAttr[attr] + //); + } + + attackNo = BATTLE_Index2No( battleindex, charaindex ); + + // 须 煤 + //BATTLE_BroadCast( battleindex, szBuffer, + // (attackNo >= 10)? CHAR_COLORGRAY : CHAR_COLORPURPLE ) ; + + // 仇仇匹 侬 戊穴件玉毛中木月 + sprintf( szCommand, "BV|%X|%X|",attackNo, attr ); + BATTLESTR_ADD( szCommand ); + + return TRUE; + +} + + + + +//**************************************************************** +// +// 白奴□伙玉箪岭 凳热诸 +// +int MAGIC_FieldAttChange_Battle( + int charaindex, // 井仃月谛及奶件犯永弁旦 + int toNo, // 井仃日木月谛及奶件犯永弁旦( 银迕) + int marray, // magicindex + int mp // MP +) +// 岳 允木壬 TRUE +// 撩 卅日 FALSE +// +//**************************************************************** + +{ + char *pArg; + + // 由仿丢□正毛潸 + pArg = MAGIC_getChar( marray, MAGIC_OPTION ); + // 由仿丢□正 中及匹撩 + if( pArg == NULL )return FALSE; + + return BATTLE_FieldAttChange( charaindex, pArg ); + +} +//**************************************************************** +// +// 旦 □正旦唱橘毛芨尹月热诸 +// +int MAGIC_StatusChange_Battle( + int charaindex, // 井仃月谛及奶件犯永弁旦 + int toNo, // 井仃日木月谛及奶件犯永弁旦 + int marray, // magicindex + int mp // MP +) +// 岳 仄凶日 TRUE +// 撩 仄凶日 FALSE +//**************************************************************** + +{ + char *magicarg; + int status = -1, i, attackNo, turn = 3; + int battleindex, ReceveEffect, Success = 15; + char *pszP; + char szTurn[] = "turn"; + char szSuccess[] = "成"; + + magicarg = MAGIC_getChar( marray, MAGIC_OPTION ); + pszP = magicarg; + for( ;status == -1 && pszP[0] != 0; pszP++ ){ + for( i = 1; i < BATTLE_ST_END; i ++ ){ + if( strncmp( pszP, aszStatus[i], 2 ) == 0 ){ + status = i; + pszP +=2; + break; + } + } + } + if( status == -1 ) return FALSE; + if( ( pszP = strstr( pszP, szTurn ) ) != NULL){ + pszP += sizeof( szTurn ); + sscanf( pszP, "%d", &turn ); + } + if( ( pszP = strstr( pszP, szSuccess ) ) != NULL){ + pszP += sizeof( szSuccess ); + sscanf( pszP, "%d", &Success ); + } + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + attackNo = BATTLE_Index2No( battleindex, charaindex ); + if( status == BATTLE_ST_NONE ){ + ReceveEffect = SPR_tyusya; // 月午五反仇木 + }else{ + ReceveEffect = SPR_hoshi; // 井井月午五反仇木 + } + + BATTLE_MultiStatusChange( battleindex, attackNo, toNo, + status, turn, MAGIC_EFFECT_USER, ReceveEffect, Success ); + + + return TRUE; + +} + +#ifdef _MAGIC_DEEPPOISON +int MAGIC_StatusChange_Battle2( + int charaindex, // 井仃月谛及奶件犯永弁旦 + int toNo, // 井仃日木月谛及奶件犯永弁旦 + int marray, // magicindex + int mp // MP +) +// 岳 仄凶日 TRUE +// 撩 仄凶日 FALSE +//**************************************************************** + +{ + char *magicarg; + int status = -1, i, attackNo, turn = 3; + int battleindex, ReceveEffect, Success = 15; + char *pszP; + char szTurn[] = "turn"; + char szSuccess[] = "成"; + magicarg = MAGIC_getChar( marray, MAGIC_OPTION ); + if( magicarg == NULL ) { + print("\n magicarg == NULL "); + return FALSE; + } + pszP = magicarg; + // 躲绊毛潸 + for( ;status == -1 && pszP[0] != 0; pszP++ ){ + // ㄠ井日腹绸 + for( i = 1; i < BATTLE_ST_END; i ++ ){ + // 躲绊疋永正伉井" + if( strncmp( pszP, aszStatus[i], 2 ) == 0 ){ + status = i; + pszP +=2; + break; + } + } + } + // 躲绊卅中及匹撩 + if( status == -1 ) return FALSE; + + // 窒正□件 凳今六月井" + if( ( pszP = strstr( pszP, szTurn ) ) != NULL){ + pszP += sizeof( szTurn ); + sscanf( pszP, "%d", &turn ); + } + + // 岳 涩烂 + if( ( pszP = strstr( pszP, szSuccess ) ) != NULL){ + pszP += sizeof( szSuccess ); + sscanf( pszP, "%d", &Success ); + } + + + + // 田玄伙 寞 + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + attackNo = BATTLE_Index2No( battleindex, charaindex ); + + if( status == BATTLE_ST_NONE ){ + ReceveEffect = SPR_tyusya; // 月午五反仇木 + }else{ + ReceveEffect = SPR_hoshi; // 井井月午五反仇木 + } + // 蝈够 + BATTLE_MultiStatusChange( battleindex, attackNo, toNo, + status, turn+2, MAGIC_EFFECT_USER, ReceveEffect, Success ); + return TRUE; +} +#endif +#ifdef _OTHER_MAGICSTAUTS +int MAGIC_MagicStatusChange_Battle( int charaindex, int toNo, int marray, int mp ) +{ + char *magicarg; + int status = -1, i, attackNo, turn = 3, nums=0; + int battleindex, ReceveEffect; + char buf1[256]; + + magicarg = MAGIC_getChar( marray, MAGIC_OPTION ); + + if( getStringFromIndexWithDelim( magicarg,"|",1, buf1, sizeof( buf1)) == FALSE ) + return FALSE; + for( i=0; i= 20 ) + return FALSE; + } + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + attackNo = BATTLE_Index2No( battleindex, charaindex ); + //动画图号决定 +#define SPR_mic_def 101411 + ReceveEffect = SPR_heal2; + if( status == 1 ) + ReceveEffect = SPR_mic_def; +#ifdef _MAGICSTAUTS_RESIST + else if( status == 3 ) + ReceveEffect = 101802; + else if( status == 4 ) + ReceveEffect = 101804; + else if( status == 5 ) + ReceveEffect = 101803; +#endif + //else{ + // ReceveEffect = SPR_hoshi; + //} + + BATTLE_MultiMagicStatusChange( + battleindex, attackNo, toNo, status, + turn, MAGIC_EFFECT_USER, ReceveEffect, nums ); + + return TRUE; +} +#endif + + +int MAGIC_MagicDef_Battle( + int charaindex, + int toNo, + int marray, + int mp +) +{ + char *magicarg; + int status = -1, i, attackNo, turn = 3; + int battleindex; + char *pszP; + + char szTurn[] = "turn"; + + magicarg = MAGIC_getChar( marray, MAGIC_OPTION ); + + pszP = magicarg; + + for( ;status == -1 && pszP[0] != 0; pszP++ ){ + for( i = 1; i < BATTLE_MD_END; i ++ ){ + if( strncmp( pszP, aszMagicDef[i], 2 ) == 0 ){ + status = i; + pszP +=2; + break; + } + } + } + + if( status == -1 ) return FALSE; + + if( ( pszP = strstr( pszP, szTurn ) ) != NULL){ + pszP += sizeof( szTurn ); + sscanf( pszP, "%d", &turn ); + } + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + attackNo = BATTLE_Index2No( battleindex, charaindex ); + + BATTLE_MultiMagicDef( battleindex, attackNo, toNo, + status, turn, MAGIC_EFFECT_USER, SPR_difence ); + + + return TRUE; +} + + + + + + + +#if 1 + +//**************************************************************** +// +// 由仿丢□正 祭毛芨尹月热诸 +// +int MAGIC_ParamChange_Battle( + int charaindex, // 井仃月谛及奶件犯永弁旦 + int toNo, // 井仃日木月谛及奶件犯永弁旦 + int marray, // magicindex + int mp // MP +) +// 岳 仄凶日 TRUE +// 撩 仄凶日 FALSE +//**************************************************************** + +{ + char *magicarg; + int kind = -1, i, attackNo; + int battleindex, pow, par = 0; + + char *pszP; + + // 由仿丢□正毛潸 //魔法名称 + magicarg = MAGIC_getChar( marray, MAGIC_OPTION ); + + pszP = magicarg; + // 躲绊毛潸 //取得更改参数(无,攻,防,早,魅,捕) + for( ;kind == -1 && pszP[0] != 0; pszP++ ){ + for( i = 1; i < BATTLE_MD_END; i ++ ){ + // 躲绊疋永正伉井" + if( strncmp( pszP, aszParamChange[i], 2 ) == 0 ){ + kind = i; + pszP +=2; + break; + } + } + } + // 躲绊卅中及匹撩 + if( kind == -1 ) return FALSE; + + if( strstr( pszP, "%" ) ){ // 仇及桦宁反⊙煌遥 + par = 1; + } + + if( sscanf( pszP, "%d", &pow ) != 1 ){ + // 窒禾奶件玄丐仆月井 + pow = 30; + } + + // 田玄伙 寞 + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + attackNo = BATTLE_Index2No( battleindex, charaindex ); + + // 蝈够 + BATTLE_MultiParamChange( battleindex, attackNo, toNo, + kind, pow, par, MAGIC_EFFECT_USER, SPR_hoshi ); + + + return TRUE; +} + + + +#endif + + + + + + + +//**************************************************************** +// +// 蜊谛及箪岭 鳖毛芨尹月热诸 +// +int MAGIC_AttReverse_Battle( + int charaindex, // 井仃月谛及奶件犯永弁旦 + int toNo, // 井仃日木月谛及奶件犯永弁旦 + int marray, // magicindex + int mp // MP +) +// 岳 仄凶日 TRUE +// 撩 仄凶日 FALSE +//**************************************************************** + +{ + int attackNo; + int battleindex; + + // 由仿丢□正反漆及午仇欠 中 + // 田玄伙 寞 + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + attackNo = BATTLE_Index2No( battleindex, charaindex ); + + // 蝈够 + BATTLE_MultiAttReverse( battleindex, attackNo, toNo, + MAGIC_EFFECT_USER, SPR_kyu ); + + + return TRUE; +} + + + +//**************************************************************** +// +// 旦 □正旦唱橘毛荚汊允月热诸 +// +int MAGIC_StatusRecovery_Battle( + int charaindex, // 井仃月谛及奶件犯永弁旦 + int toNo, // 井仃日木月谛及奶件犯永弁旦 + int marray, // magicindex + int mp // MP +) +// 岳 仄凶日 TRUE +// 撩 仄凶日 FALSE +//**************************************************************** +{ + char *magicarg; + int status = -1, i, attackNo; + int battleindex, ReceveEffect; + char *pszP; + + // 由仿丢□正毛潸 + magicarg = MAGIC_getChar( marray, MAGIC_OPTION ); + + pszP = magicarg; + // 躲绊毛潸 + for( ;status == -1 && pszP[0] != 0; pszP++ ){ + // 蝈莒手丐月及匹ㄟ井日腹绸 + for( i = 0; i < BATTLE_ST_END; i ++ ){ + // 躲绊疋永正伉井" + if( strncmp( pszP, aszStatus[i], 2 ) == 0 ){ + status = i; + pszP +=2; + break; + } + } + } + // 躲绊卅中及匹撩 + if( status == -1 ) return FALSE; + + + // 田玄伙 寞 + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + attackNo = BATTLE_Index2No( battleindex, charaindex ); + + ReceveEffect = SPR_tyusya; // 月午五反仇木 + + // 蝈够 + BATTLE_MultiStatusRecovery( battleindex, attackNo, toNo, + status, MAGIC_EFFECT_USER, ReceveEffect ); + + + return TRUE; + +} + + +//**************************************************************** +// +// 竣濮井日汊唾允月热诸 +// +int MAGIC_Ressurect_Battle( + int charaindex, // 井仃月谛及奶件犯永弁旦 + int toNo, // 井仃日木月谛及奶件犯永弁旦 + int marray, // magicindex + int mp // MP +) +// 岳 仄凶日 TRUE +// 撩 仄凶日 FALSE +//**************************************************************** +{ + char *magicarg; + int attackNo, ReceveEffect; + int battleindex, pow = 0, par = 0; + + char *pszP; + + // 由仿丢□正毛潸 + magicarg = MAGIC_getChar( marray, MAGIC_OPTION ); + + pszP = magicarg; + + if( strstr( pszP, "%" ) ){ // 仇及桦宁反⊙煌遥 + par = 1; + } + if( sscanf( pszP, "%d", &pow ) != 1 ){ + // 窒禾奶件玄荚汊允月井" + pow = 0; // ㄟ及桦宁反敦蝈荚汊 + } + + if( pow <= 0 ){ + ReceveEffect = SPR_fukkatu3; + }else + if( pow <= 100 ){ + ReceveEffect = SPR_fukkatu1; + }else + if( pow <= 300 ){ + ReceveEffect = SPR_fukkatu2; + }else{ + ReceveEffect = SPR_fukkatu3; + } + + // 田玄伙 寞 + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + attackNo = BATTLE_Index2No( battleindex, charaindex ); + + // 蝈够 + BATTLE_MultiRessurect( battleindex, attackNo, toNo, + pow, par, MAGIC_EFFECT_USER, ReceveEffect ); + + return TRUE; +} + + +int MAGIC_ResAndDef_Battle( + int charaindex, + int toNo, + int marray, + int mp +) +{ + char *magicarg; + int attackNo, i; + int battleindex, pow = 0, par = 0, turn = 3, status = -1; + // Robin 03/21 debug + //char szTurn[] = "回"; + char szTurn[] = "turn"; + + char *pszP; + +// Terry add 2004/12/7 + // 复活光..不得使用敌方 + battleindex = CHAR_getWorkInt(charaindex, CHAR_WORKBATTLEINDEX); + if(CHAR_getInt(charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) + { + if(BATTLE_CheckSameSide(charaindex, toNo) == 0) //不同边 + { + battleindex = CHAR_getWorkInt(charaindex, CHAR_WORKBATTLEINDEX); + BATTLE_NoAction(battleindex, BATTLE_Index2No(battleindex, charaindex)); + CHAR_talkToCli(charaindex, -1, "复活光镜守..不得施予非玩家敌方。", CHAR_COLORYELLOW); + return; + } + } +// end + // 由仿丢□正毛潸 + magicarg = MAGIC_getChar( marray, MAGIC_OPTION ); + + pszP = magicarg; + + if( strstr( pszP, "%" ) ){ // 仇及桦宁反⊙煌遥 + par = 1; + } + if( sscanf( pszP, "%d", &pow ) != 1 ){ + // 窒禾奶件玄荚汊允月井" + pow = 0; // ㄟ及桦宁反敦蝈荚汊 + } + + // 馨笛允月 芊 豢躲绊毛潸 + for( ;status == -1 && pszP[0] != 0; pszP++ ){ + for( i = 1; i < BATTLE_MD_END; i ++ ){ + char *p; + // 躲绊疋永正伉井" + p = strstr( pszP, aszMagicDef[i] ); + if( p != NULL ){ + status = i; + pszP = p; + break; + } + } + } + + // 躲绊卅中及匹撩 + if( status == -1 ) return FALSE; + + // 窒荚 凳今六月井" + if( ( pszP = strstr( pszP, szTurn ) ) != NULL){ + pszP += sizeof( szTurn ); + sscanf( pszP, "%d", &turn ); + } + + // 田玄伙 寞 + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + attackNo = BATTLE_Index2No( battleindex, charaindex ); + + // 蝈够 + BATTLE_MultiResAndDef( battleindex, attackNo, toNo, + pow, par, status, turn, MAGIC_EFFECT_USER, SPR_difence ); + + return TRUE; +} + +#ifdef __ATTACK_MAGIC + +int MAGIC_AttMagic_Battle( int charaindex , int toNo , int marray , int mp ) +{ + int attno , attidx , battleindex; + int attr = -1, i , power; + char aszattr[][32] = { "地", "水", "火", "风" }; + char buf1[256]; + char *magicarg; + int magiclv=0; + magicarg = MAGIC_getChar( marray , MAGIC_OPTION ); + if( magicarg == NULL ) { + print("\n Magic magicarg == NULL "); + return FALSE; + } + + for( i=0; i<4; i++) { + if( strstr( magicarg, aszattr[i]) != NULL ) { + attr = i; + break; + } + } + if( i == 4 ) { + print("\n not find aszattr !!"); + return FALSE; + } + memset( buf1, 0, sizeof( buf1)); + if( getStringFromIndexWithDelim( magicarg, "|", 2, buf1, sizeof( buf1)) == FALSE ) return FALSE; + power = atoi( buf1); + + if( getStringFromIndexWithDelim( magicarg, "|", 3, buf1, sizeof( buf1)) == FALSE ) return FALSE; + magiclv = atoi( buf1); + + battleindex = CHAR_getWorkInt( charaindex , CHAR_WORKBATTLEINDEX ); + attno = BATTLE_Index2No( battleindex , charaindex ); + attidx = MAGIC_getInt( marray , MAGIC_IDX ); + if( -1 == attidx || attidx >= ATTMAGIC_magicnum ) + return FALSE; +#ifdef _FIX_MAGICDAMAGE + BATTLE_MultiAttMagic( battleindex , attno , toNo , attidx , attr , power, magiclv); +#else + BATTLE_MultiAttMagic( battleindex , attno , toNo , attidx , attr , power ); +#endif + return TRUE; +} + +#endif + + +#ifdef _MAGIC_TOCALL + +int MAGIC_ToCallDragon_Battle( int charaindex , int toNo , int marray , int mp ) +{ + int attno , attidx , battleindex; + int attr = -1,/* i , */power, imageno; +// char aszattr[][32] = { "地", "水", "火", "风" }; + char buf1[256]; + char *magicarg; + //int magiclv=0; + magicarg = MAGIC_getChar( marray , MAGIC_OPTION ); + print("charaindex=%d, toNo=%d, marray=%d, mp=%d\n", charaindex, toNo, marray, mp); + + if( magicarg == NULL ) { + print("\n Magic magicarg == NULL "); + return FALSE; + } +/* + for( i=0; i<4; i++) { + if( strstr( magicarg, aszattr[i]) != NULL ) { + attr = i; + break; + } + } + if( i == 4 ) { + print("\n not find aszattr !!"); + return FALSE; + } +*/ + memset( buf1, 0, sizeof( buf1)); + if( getStringFromIndexWithDelim( magicarg, "|", 1, buf1, sizeof( buf1)) == FALSE ) return FALSE; + imageno = atoi( buf1); + if( getStringFromIndexWithDelim( magicarg, "|", 2, buf1, sizeof( buf1)) == FALSE ) return FALSE; + power = atoi( buf1); + + battleindex = CHAR_getWorkInt( charaindex , CHAR_WORKBATTLEINDEX ); + attno = BATTLE_Index2No( battleindex , charaindex ); + attidx = MAGIC_getInt( marray , MAGIC_IDX ); + print("attidx=%d....................\n", attidx); + if( -1 == attidx || attidx >= ATTMAGIC_magicnum ) + return FALSE; + print("battleindex=%d, attno=%d, attidx=%d, attr=%d, power=%d\n", battleindex, attno, attidx, attr, power); + + BATTLE_MultiToCallDragonMagic( battleindex , attno , toNo , attidx , attr , power, imageno); + + return TRUE; +} + +#endif + +//**************************************************************** +// +// 凯 祭允月热诸 +// +int MAGIC_CaptureUp_Battle( + int charaindex, // 井仃月谛及奶件犯永弁旦 + int toNo, // 井仃日木月谛及奶件犯永弁旦 + int marray, // magicindex + int mp // MP +) +// 岳 仄凶日 TRUE +// 撩 仄凶日 FALSE +//**************************************************************** +{ + char *magicarg; + int attackNo, ReceveEffect; + int battleindex, pow = 5; + + // 由仿丢□正毛潸 + magicarg = MAGIC_getChar( marray, MAGIC_OPTION ); + + if( sscanf( magicarg, "%d", &pow ) != 1 ){ + // 窒禾奶件玄荚汊允月井" + pow = 5; + } + + ReceveEffect = SPR_hoshi; + + // 田玄伙 寞 + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + attackNo = BATTLE_Index2No( battleindex, charaindex ); + + // 蝈够 + BATTLE_MultiCaptureUp( battleindex, attackNo, toNo, + pow, MAGIC_EFFECT_USER, ReceveEffect ); + + return TRUE; +} +#ifdef _FIX_MAGICDAMAGE +static int BATTLE_getMagicAdjustInt( int attackindex, int defindex, int MagicLv, int flg,int damage ) +{ + int At_Fire, At_Earth, At_Water, At_Wind, At_none; + int Df_Fire, Df_Earth, Df_Water, Df_Wind, Df_none; + float At_FieldPow, Df_FieldPow; + + //取得施法者属性 + BATTLE_GetAttr(attackindex,&At_Fire,&At_Water,&At_Earth,&At_Wind,&At_none); + MagicLv *=10; + switch( flg) { //将属性置换为魔法牵引属性 + case 0: + At_Earth = MagicLv+(MagicLv*(At_Earth/50)); + At_Water=0; At_Fire=0; At_Wind=0; + break; + case 1: + At_Water = MagicLv+(MagicLv*(At_Water/50)); + At_Earth=0; At_Fire=0; At_Wind=0; + break; + case 2: + At_Fire = MagicLv+(MagicLv*(At_Fire/50)); + At_Earth=0; At_Water=0; At_Wind=0; + break; + case 3: + At_Wind = MagicLv+(MagicLv*(At_Wind/50)); + At_Earth=0; At_Water=0; At_Fire=0; + break; + } + //取得该场属性加成 + At_FieldPow = BATTLE_FieldAttAdjust( + CHAR_getWorkInt( attackindex, CHAR_WORKBATTLEINDEX ), + At_Fire, At_Water, + At_Earth, At_Wind ); + + At_Fire *= damage; At_Water *= damage; At_Earth *= damage; + At_Wind *= damage; At_none *= damage; + + //取得防守方属性 + BATTLE_GetAttr( defindex, &Df_Fire, &Df_Water, + &Df_Earth,&Df_Wind, &Df_none ); + //取得该场属性加成 + Df_FieldPow = BATTLE_FieldAttAdjust( + CHAR_getWorkInt( defindex, CHAR_WORKBATTLEINDEX ), + Df_Fire, Df_Water, Df_Earth, Df_Wind ); + //四属相克 + damage = BATTLE_AttrCalc( + At_Fire, At_Water, At_Earth, At_Wind, At_none, + Df_Fire, Df_Water, Df_Earth, Df_Wind, Df_none ); + damage *= (At_FieldPow / Df_FieldPow); + return damage; +} + +void Magic_ComputeAttExp( int charindex, int Mnum, int MagicLv, int Expoint) +{ + int magiclv1, magicex1; + int addEx = (MagicLv * 3) * Expoint; + char MagicStr[][128]={"地","水","火","风"}; + char buf1[256]; + memset( buf1, 0, sizeof( buf1)); + magiclv1 = CHAR_getInt( charindex, CHAR_EARTH_EXP+Mnum); + magicex1 = CHAR_getInt( charindex, CHAR_EARTH_ATTMAGIC_EXP+Mnum); + magicex1 += addEx; + if( magicex1 > 100 ) { + magicex1 = 0; + if( magiclv1 < 100 ) { + magiclv1 += 1; + sprintf( buf1,"%s魔法熟练度提升为%d。", MagicStr[Mnum], magiclv1); + CHAR_talkToCli( charindex, -1, buf1, CHAR_COLORYELLOW); + } + } + if( magicex1 < 0 ) magicex1 = 0; + if( magiclv1 < 0 ) magiclv1 = 0; + if( magiclv1 > 100 ) magiclv1 = 100; + CHAR_setInt( charindex, CHAR_EARTH_EXP+Mnum, magiclv1); + CHAR_setInt( charindex, CHAR_EARTH_ATTMAGIC_EXP+Mnum, magicex1); + + Mnum = (Mnum+1)%4; //相克的魔法 + magiclv1 = CHAR_getInt( charindex, CHAR_EARTH_EXP+Mnum); + magicex1 = CHAR_getInt( charindex, CHAR_EARTH_ATTMAGIC_EXP+Mnum); + if( magiclv1 > 1 ) { + magicex1 -= addEx*0.5; + if( magicex1 < 0 ) { + magicex1 = 0; + magiclv1 -= 1; + if( magiclv1 < 0 ) magiclv1 = 0; + CHAR_setInt( charindex, CHAR_EARTH_EXP+Mnum, magiclv1); + sprintf( buf1,"%s魔法熟练度下降为%d。", MagicStr[Mnum], magiclv1); + CHAR_talkToCli( charindex, -1, buf1, CHAR_COLORYELLOW); + } + CHAR_setInt( charindex, CHAR_EARTH_ATTMAGIC_EXP+Mnum, magicex1); + } + return; +} + +void Magic_ComputeDefExp( int charindex, int Mnum, int MagicLv, int Damage) +{ + int magiclv1; + int magicex1; + int addEx; + char buf1[256]; + char MagicStr[][128]={"地","水","火","风"}; + if( Damage < 200 ) return; + memset( buf1, 0, sizeof( buf1)); + magiclv1 = CHAR_getInt( charindex, CHAR_EARTH_RESIST+Mnum); + magicex1 = CHAR_getInt( charindex, CHAR_EARTH_DEFMAGIC_EXP+Mnum); + addEx = (Damage/20)*(MagicLv*2); + magicex1+=addEx; + if( magiclv1 < 0 ) magiclv1 = 0; + if( magicex1 > 100 ) { + magicex1 = 0; + if( magiclv1 < 100 ) { + magiclv1 +=1; + if( magiclv1 < 0 ) magiclv1 = 0; + if( magiclv1 > 100 ) magiclv1 = 100; + CHAR_setInt( charindex, CHAR_EARTH_RESIST+Mnum, magiclv1); + sprintf( buf1,"%s抗魔值提升为%d。", MagicStr[Mnum], magiclv1); + CHAR_talkToCli( charindex, -1, buf1, CHAR_COLORYELLOW); + } + } + if( magicex1 < 0 ) magicex1 = 0; + CHAR_setInt( charindex, CHAR_EARTH_DEFMAGIC_EXP+Mnum, magicex1); + Mnum = (Mnum+1)%4; //相克的魔法 + magiclv1 = CHAR_getInt( charindex, CHAR_EARTH_RESIST+Mnum); + magicex1 = CHAR_getInt( charindex, CHAR_EARTH_DEFMAGIC_EXP+Mnum); + if( magiclv1 > 1 ) { + magicex1 -=2; + if( magicex1 < 0 ) { + magicex1 = 90; + magiclv1 -=1; + if( magiclv1 < 0 ) + magiclv1 = 0; + sprintf( buf1,"%s抗魔值下降为%d。", MagicStr[Mnum], magiclv1); + CHAR_talkToCli( charindex, -1, buf1, CHAR_COLORYELLOW); + CHAR_setInt( charindex, CHAR_EARTH_RESIST+Mnum, magiclv1); + } + CHAR_setInt( charindex, CHAR_EARTH_DEFMAGIC_EXP+Mnum, magicex1); + } + return; +} + +#endif + +#ifdef _MAGIC_WEAKEN +int MAGIC_ParamChange_Turn_Battle( + int charaindex, + int toNo, + int marray, + int mp +) +{ + char *magicarg; + int status = -1, i, attackNo, turn = 3; + int battleindex, Success = 15; + char *pszP; + char szTurn[] = "turn"; + char szSuccess[] = "成"; + magicarg = MAGIC_getChar( marray, MAGIC_OPTION ); + if( magicarg == NULL ) { + print("\n magicarg == NULL "); + return FALSE; + } + pszP = magicarg; + // 躲绊毛潸 + for( ;status == -1 && pszP[0] != 0; pszP++ ){ + // ㄠ井日腹绸 + for( i = 1; i < BATTLE_ST_END; i ++ ){ + // 躲绊疋永正伉井" + if( strncmp( pszP, aszStatus[i], 2 ) == 0 ){ + status = i; + pszP +=2; + break; + } + } + } + + if( status == -1 ) return FALSE; + + if( ( pszP = strstr( pszP, szTurn ) ) != NULL){ + pszP += sizeof( szTurn ); + sscanf( pszP, "%d", &turn ); + } + + if( ( pszP = strstr( pszP, szSuccess ) ) != NULL){ + pszP += sizeof( szSuccess ); + sscanf( pszP, "%d", &Success ); + } + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + attackNo = BATTLE_Index2No( battleindex, charaindex ); + BATTLE_MultiParamChangeTurn( battleindex, attackNo, toNo, status, MAGIC_EFFECT_USER, SPR_hoshi, turn, Success ); + return TRUE; +} + +void BATTLE_MultiParamChangeTurn( + int battleindex, + int attackNo, + int toNo, + int status, + int UseEffect, + int RecevEffect, + int turn, + int Success +) +{ + + int i, toindex,perStatus,charaindex; + int ToList[SIDE_OFFSET*2+1]; + charaindex = BATTLE_No2Index( battleindex, attackNo ); //攻方index + BATTLE_MultiList( battleindex, toNo, ToList ); + + //施魔法动画效果 + BATTLE_MagicEffect(battleindex, attackNo, ToList, UseEffect, RecevEffect); + + for( i = 0; ToList[i] != -1; i ++ ) + { + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + + if( BATTLE_StatusAttackCheck( charaindex, + toindex, status, Success, 30, 1.0, &perStatus ) == TRUE ) + { + CHAR_setWorkInt( toindex, CHAR_WORKWEAKEN, turn+1 ); + } + } + return; + +} +#endif + + +/* +typedef struct tagToCallMagic +{ + unsigned int uiSpriteNum; // 此咒术在Spr_x.bin的编号 + unsigned int uiAttackType; // 攻击的方式:单人,整排( 轮流 ) , 整排( 轮流 ) , 整排( 同时 ) , 全体( 轮流 ) , 全体( 同时 ) + unsigned int uiSliceTime; // 轮流攻击时的时间差 + unsigned int uiShowType; // 显示的位置方式:中央、指定 + int siSx; // 显示的位置 - X轴 + int siSy; // 显示的位置 - Y轴 + unsigned int uiShowBehindChar; // 显示在人物的前方或下方 + unsigned int uiShakeScreen; // 是否震动画面 + unsigned int uiShakeFrom; // 震动画面的起始时间( 毫秒 ) + unsigned int uiShakeTo; // 震动画面的结束时间( 毫秒 _ + unsigned int uiPrevMagicNum; // 前置咒术的索引号( 0XFFFFFFFFFF 表示无前置咒术 ) + int siPrevMagicSx; // 前置咒术的显示位置 - X轴 + int siPrevMagicSy; // 前置咒术的显示位置 - Y轴 + int siPrevMagicOnChar; // 前置咒术显示在人物的前方或下方 + unsigned int uiPostMagicNum; // 後置咒术的索引号( 0XFFFFFFFF 表示无後置咒术 ) + int siPostMagicSx; // 後置咒术的显示位置 - X轴 + int siPostMagicSy; // 後置咒术的显示位置 - Y轴 + int siPostMagicOnChar; // 後置咒术显示在人物的前方或下方 + int isPostDisappear; // 咒术一般攻击完时是否马上消失 + int ToCallMagicNo; // 召唤术的编号 +}ToCallMagic; +*/ + +ToCallMagic PROFESSION_magic[3] = { {0,0,0,1,0,0,1,1,0,0,0,65528,65485,0,-1,0,0,0,1,0}, // 单人 + {0,3,0,1,0,0,1,1,0,0,0,65528,65485,0,-1,0,0,0,1,1}, // 单排 + {0,5,0,1,0,0,1,1,0,0,0,65528,65485,0,-1,0,0,0,0,2}, // 全体 + }; + + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 +void PROFESSION_MAGIC_ATTAIC( int battleindex, int attackNo, int toNo, int attIdx ,int FieldAttr, int skill) +{ + int list[SIDE_OFFSET * 2 + 1]; + int listidx,i,j,k,z; + int basey, def_is_player[10],def_be_hit[10]; + int attvalue , charahp , pethp , charaidx , petidx , charahurt,charahurt_temp; + char szcommand[256]; + int DefIsPlayer=0, power=0, skill_level; + float hp_power=0, mp_power=0, add_hp=0, add_mp=0, dec_hp=0, dec_mp=0; + int icindex, ioindex; + int charaindex, command, magic_type=0; +#ifdef _PROFESSION_ADDSKILL + int decmplist[]={-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}, decmplistcount=0; +#endif + charaindex = BATTLE_No2Index(battleindex, attackNo); + if( !CHAR_CHECKINDEX(charaindex) ) return; + + if((z = BATTLE_MultiList(battleindex,toNo,list)) == -1) return; + else if(z != toNo){ + toNo = z; +// terry fix for 不设定为新的目标会有问题 2004/02/10 + CHAR_setWorkInt(charaindex,CHAR_WORKBATTLECOM2,toNo); +// end + } + + // 技能 + command = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1); + + // 技能等级 + skill_level = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_M( skill_level ); + + // 将魔法参数代入动画 + magic_type = analysis_profession_parameter( attIdx, skill, toNo, charaindex ); + PROFESSION_MAGIC_ATTAIC_Effect( battleindex, attackNo, list, attIdx); + + listidx = 0; + memset(def_is_player,-1,sizeof(def_is_player)); + memset(def_be_hit,-1,sizeof(def_be_hit)); + + // 单人攻击 + if( toNo < 20 ){ + toNo = list[0]; + listidx++; + + } else if( 20 == toNo ){ // 右下全体 + for( i = 0 ; i < 2 ; i++ ){ + for( j = 0 ; j < 5 ; j++ ){ + if(TRUE == BATTLE_TargetCheck( battleindex , CharTable[i + 2][j] ) ){ + list[listidx] = CharTable[i + 2][j]; + listidx++; + } + } + } + } else if( 21 == toNo ){ // 左上全体 + for( i = 0 ; i < 2 ; i++ ){ + for( j = 0 ; j < 5 ; j++ ){ + if(TRUE == BATTLE_TargetCheck( battleindex , CharTable[i][j] ) ){ + list[listidx] = CharTable[i][j]; + listidx++; + } + } + } + } // 左上第一列 , 左上第二列 , 右下第一列 , 右下第二列 + else if( 23 == toNo || 24 == toNo || 25 == toNo || 26 == toNo ){ + basey = toNo - 23; + for( i = 0 , j = basey - 1 ; j <= basey + 1 ; i++ , j++ ){ + if( ( 25 == toNo || 26 == toNo ) && ( j < 2 || j > 3 ) ) + continue; + else if( ( 23 == toNo || 24 == toNo ) && ( j < 0 || j > 1 ) ) + continue; + // 计算那些人需要加入清单 + for( k = 0 ; k < 5 ; k++ ){ + if(TRUE == BATTLE_TargetCheck( battleindex , CharTable[j][k] ) ) + { + list[listidx] = CharTable[j][k]; + listidx++; + } + } + } + } + qsort( list , listidx , sizeof( list[0] ) , ( FUNC )SortLoc );// 排序位置 + + // 取熟练度 + PROFESSION_MAGIC_GET_PRACTICE( &hp_power, &mp_power, &dec_hp, &dec_mp, charaindex ); + + + power = hp_power; + + // 取出攻击 list + PROFESSION_MAGIC_TOLIST_SORT( list, &listidx, charaindex ); + + for( i = 0 ; i < listidx ; i++ ) { + int defType; + charaidx = BATTLE_No2Index( battleindex , list[i] ); + petidx = BATTLE_getRidePet( charaidx ); + defType = CHAR_getInt(charaidx, CHAR_WHICHTYPE); + DefIsPlayer = 0; + + if( !CHAR_CHECKINDEX(charaidx) ) continue; + + // 制作魔法特效 + if (CHAR_createCharacter( 100354, 777, 45, 45, 0, &icindex, &ioindex, 0) == TRUE){ + + CHAR_setInt( icindex, CHAR_LUCK, 1); + CHAR_setWorkInt( icindex, CHAR_WORKATTACKPOWER, power ); + CHAR_setWorkInt( icindex, CHAR_WORKOTHERDMAGE, 0 ); + + + // 魔法命中检定 + if( PROFESSION_MAGIC_DODGE( charaindex, charaidx, magic_type ) == 1 ){ + // MISS + attvalue = 0; + }else{ + // 取特殊魔法伤害值 + power = PROFESSION_MAGIC_GET_ICE_MIRROR_DAMAGE( charaindex, charaidx, command, power ); +#ifdef _SUIT_ADDPART4 + if( CHAR_getWorkInt( charaidx, CHAR_WORKUNMPOWER ) > 0 ){//抵抗法师魔法的装备 + power -= power * (CHAR_getWorkInt( charaidx, CHAR_WORKUNMPOWER )/100.00); + print("\nWORKUNMPOWER:%d", CHAR_getWorkInt( charaidx, CHAR_WORKUNMPOWER )); + } +#endif + // 取魔法伤害值 +#ifdef _PROFESSION_ADDSKILL + attvalue = PROFESSION_MAGIC_GET_DAMAGE( charaindex, charaidx, magic_type, power, command ); +#else + attvalue = PROFESSION_MAGIC_GET_DAMAGE( charaindex, charaidx, magic_type, power ); +#endif + // 改变自身状态魔法 + PROFESSION_MAGIC_CHANGE_STATUS( charaindex, attvalue, mp_power, &add_hp, &add_mp ); + + // 特殊攻击 + attvalue = PROFESSION_MAGIC_CHANG_STATUS( command, battleindex, charaindex, charaidx, attvalue, i ); + def_be_hit[i] = charaidx; + +#ifdef _PROFESSION_ADDSKILL + if( command == BATTLE_COM_S_STORM ){// 暴风雨 水附体 + if( (PROFESSION_BATTLE_StatusAttackCheck( charaindex, charaidx, BATTLE_ST_WATER, 30 ) == 0 )// 状态命中检定 + || (CHAR_getInt( charaidx, CHAR_HP ) <= 0 ) ){ + + }else{ + int bid = BATTLE_Index2No( battleindex, charaidx ); + int watercount=0; + if( skill_level > 8 ) watercount=5; + else if( skill_level > 6 ) watercount=4; + else if( skill_level > 4 ) watercount=3; + else if( skill_level > 3 ) watercount=2; + else watercount=1; + CHAR_setWorkInt( charaidx, CHAR_WORKWATER, watercount ); + BATTLE_BadStatusString( bid, BATTLE_ST_WATER ); + } + } + + //记录被攻击方的idx + decmplist[decmplistcount++] = list[i]; +#endif + } + + // 清除魔法特效 + CHAR_CharaDelete(icindex); + + + charahp = CHAR_getInt( charaidx, CHAR_HP ); + + // 没骑宠物 + if( -1 == petidx || CHAR_getInt(petidx, CHAR_HP) <= 0 ){ + if( ( charahp -= attvalue ) < 0 ){ + charahp = 0; + } + CHAR_setInt( charaidx , CHAR_HP , charahp ); + pethp = 0; + if( 0 == PROFESSION_magic[attIdx].uiAttackType ) {// 单人攻击 + sprintf( szcommand , "%X|%X|%X|%X|" , toNo , list[i] , attvalue , pethp); + } else + sprintf( szcommand , "%X|%X|%X|%X|" , list[i] , list[i] , attvalue , pethp); + + }else{ + pethp = CHAR_getInt( petidx , CHAR_HP ); + charahurt = attvalue * BATTLE_CalcCharaRatio( FieldAttr , charaidx ) / 10; + + //以下的计算,若人物被打死,血不够扣的话,会将多出来的伤害再累加至宠物身上 + charahurt_temp = charahurt; + if( ( charahp -= charahurt ) < 0 ) + { + charahurt = charahp; + charahp = 0; + } + + attvalue = attvalue - charahurt; + if( ( pethp -= attvalue ) < 0) + { + pethp = 0; + // 宠物没血了退出战场 + CHAR_setInt(charaidx,CHAR_RIDEPET,-1); + BATTLE_changeRideImage(charaidx); + CHAR_setWorkInt(charaidx,CHAR_WORKPETFALL,1); + } + CHAR_setInt( charaidx , CHAR_HP , charahp ); + CHAR_setInt( petidx , CHAR_HP , pethp ); + + charahurt = charahurt_temp; + + if( 0 == PROFESSION_magic[attIdx].uiAttackType ) {// 单人攻击 + sprintf( szcommand , "%X|%X|%X|%X|" , toNo , list[i] , charahurt , attvalue); + } else + sprintf( szcommand , "%X|%X|%X|%X|" , list[i] , list[i] , charahurt , attvalue); + } + + + { + //Change fix 加上这个先拿到DP值 + int aAttackList[BATTLE_ENTRY_MAX*2+1]; + aAttackList[0] = attackNo; + aAttackList[1] = -1; + BATTLE_AddProfit( battleindex, aAttackList); + } + //change fix 让替身娃娃可正常运作 (这样做所有法术类职技战斗後都拿不到DP值,不过上面先拿到,所以没关系) + if( CHAR_getInt( charaidx, CHAR_HP ) <= 0 + && CHAR_getInt( charaidx, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER + /*&& !BattleArray[battleindex].dpbattle*/ ) + CHAR_setFlg( charaidx, CHAR_ISDIE, 1 ); + + BATTLESTR_ADD( szcommand ); + } + } + + sprintf( szcommand , "%X|" , 0x5711438 ); + BATTLESTR_ADD( szcommand ); + +#ifdef _PROFESSION_ADDSKILL + //扣敌方mp + if( (int)mp_power != 0 ){ + for( i=0;i 0 ){ + int mp = CHAR_getInt( BATTLE_No2Index( battleindex , decmplist[i] ), CHAR_MP); + if( mp > 0 ){ + mp = mp_power>mp?mp:mp_power; + sprintf( szcommand, "BD|r%X|1|0|m%X|", decmplist[i], mp ); + BATTLESTR_ADD( szcommand ); + CHAR_setInt(BATTLE_No2Index( battleindex , decmplist[i] ), CHAR_MP, CHAR_getInt( BATTLE_No2Index( battleindex , decmplist[i] ), CHAR_MP) - mp); + } + } + } + } + } + if( command == BATTLE_COM_S_DOOM ){ //世界末日 灭敏效果 + if( skill_level >= 10 ){ + int work=0; + for( i=0;i 0 ){ + CHAR_setWorkInt( BATTLE_No2Index( battleindex , decmplist[i] ), CHAR_WORKFEAR, 4 ); + BATTLE_BadStatusString( decmplist[i], BATTLE_ST_FEAR ); + sprintf( szcommand, "BD|r%X|0|6|%X|", decmplist[i], -20 );//敏降30% + BATTLESTR_ADD( szcommand ); + // 减攻 + sprintf( szcommand, "BD|r%X|0|4|%X|", decmplist[i], -10 ); + BATTLESTR_ADD( szcommand ); + // 减防 + sprintf( szcommand, "BD|r%X|0|5|%X|", decmplist[i], -10 ); + BATTLESTR_ADD( szcommand ); + } + } + } + } +#endif + if( (int)add_hp != 0 ){ + int hp=0; + + hp = CHAR_getInt( charaindex, CHAR_HP) + add_hp; + + if( hp >= CHAR_getWorkInt(charaindex, CHAR_WORKMAXHP) ){ + hp = CHAR_getWorkInt(charaindex, CHAR_WORKMAXHP); + add_hp = hp - CHAR_getInt( charaindex, CHAR_HP); + }else if ( hp <= 1 ){ + hp = 1; + add_hp = 1 - CHAR_getInt( charaindex, CHAR_HP); + } + CHAR_setInt(charaindex, CHAR_HP, hp); + + sprintf( szcommand, "BD|r%X|0|1|%X|", attackNo, (int)add_hp); + BATTLESTR_ADD( szcommand ); + } + + + if( (int)add_mp != 0 ){ + int mp=0; + + mp = CHAR_getInt( charaindex, CHAR_MP) + add_mp; + + if( mp >= CHAR_getWorkInt(charaindex, CHAR_WORKMAXMP) ){ + mp = CHAR_getWorkInt(charaindex, CHAR_WORKMAXMP); + add_mp = mp - CHAR_getInt( charaindex, CHAR_MP); + }else if ( mp <= 1 ){ + mp = 1; + add_mp = 1 - CHAR_getInt( charaindex, CHAR_MP); + } + + CHAR_setInt(charaindex, CHAR_MP, mp); + + sprintf( szcommand, "BD|r%X|1|1|m%X|", attackNo, (int)add_mp); + + BATTLESTR_ADD( szcommand ); + } +// Terry fix 2003/11/17 修正睡眠者中了攻击性法术不会醒 + for(i=0; i 0) { + CHAR_setWorkInt(def_be_hit[i],CHAR_WORKSLEEP,0); + sprintf(szcommand,"BM|%X|%X|",BATTLE_Index2No(battleindex,def_be_hit[i]),0); + BATTLESTR_ADD(szcommand); + } + } +// Terry end +} + + +int PROFESSION_MAGIC_ATTAIC_Effect( int battleindex, int attackNo , int ToList[] , int AttackMgcNo ) +{ + int i; + char szcommand[256]; + int attackindex; + + + attackindex = BATTLE_No2Index( battleindex , attackNo ); + if( FALSE == CHAR_CHECKINDEX( attackindex ) ) + return 0; +#ifdef _PROFESSION_ADDSKILL + //if( CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_ICE_CRACK ) //冰爆术不先秀特效 + // return 0; +#endif + snprintf( szcommand , sizeof( szcommand ) , "B$|a%X|i%X|m%X|%X|%X|%X|s%X|t%X|l%X|%X|%X|%X|%X|%X|%X|o%X|o%X|o%X|s%X|%X|%X|%X|%X|" , + attackNo , 5711438 , CHAR_getInt( attackindex , CHAR_MP ) , + PROFESSION_magic[AttackMgcNo].uiPrevMagicNum , + PROFESSION_magic[AttackMgcNo].uiSpriteNum , + PROFESSION_magic[AttackMgcNo].uiPostMagicNum , + PROFESSION_magic[AttackMgcNo].uiAttackType , + PROFESSION_magic[AttackMgcNo].uiSliceTime , + PROFESSION_magic[AttackMgcNo].uiShowType , + PROFESSION_magic[AttackMgcNo].siSx , + PROFESSION_magic[AttackMgcNo].siSy , + PROFESSION_magic[AttackMgcNo].siPrevMagicSx , + PROFESSION_magic[AttackMgcNo].siPrevMagicSy , + PROFESSION_magic[AttackMgcNo].siPostMagicSx , + PROFESSION_magic[AttackMgcNo].siPostMagicSy , + PROFESSION_magic[AttackMgcNo].siPrevMagicOnChar , + PROFESSION_magic[AttackMgcNo].uiShowBehindChar , + PROFESSION_magic[AttackMgcNo].siPostMagicOnChar , + PROFESSION_magic[AttackMgcNo].uiShakeScreen , + PROFESSION_magic[AttackMgcNo].uiShakeFrom , + PROFESSION_magic[AttackMgcNo].uiShakeTo , + PROFESSION_magic[AttackMgcNo].isPostDisappear , + PROFESSION_magic[AttackMgcNo].ToCallMagicNo + ); + + BATTLESTR_ADD( szcommand ); + + for( i = 0 ; ToList[i] != -1 ; i++ ){ + snprintf( szcommand , sizeof( szcommand ) , "r%X|" , ToList[i] ); + BATTLESTR_ADD( szcommand ); + } + + BATTLESTR_ADD( "FF|" ); + + return 0; +} + +int analysis_profession_parameter( int attIdx, int skill, int toNo, int charaindex ) +{ + int image_1, image_2, place, place2, shake_s_time; + int shake_e_time, disappear, x, y, i; + char temp[64]; + char *pszOption; + // Robin fix profession magic_type + //char magic[3][5]={"火","电","冰"}; + char magic[3][5]={"火","冰","电"}; + int magic_type=-1; + + + // 取得技能参数 + if( (pszOption=PROFESSION_SKILL_getChar(skill,PROFESSION_SKILL_OPTION)) == NULL ) return -1; + + // 魔法属性 + memset( temp, 0, sizeof(temp) ); + if( !getStringFromIndexWithDelim(pszOption,"|",1,temp,sizeof(temp)) ) return -1; + + for( i=0; i<3; i++){ + if( (strcmp( magic[i], temp )) == 0 ) + magic_type = i+1; + } + + switch( magic_type ){ + case 1: + // 加火熟练度经验值 + PROFESSION_SKILL_LVEVEL_UP( charaindex, "PROFESSION_FIRE_PRACTICE" ); + break; + case 2: + // 加冰熟练度经验值 + PROFESSION_SKILL_LVEVEL_UP( charaindex, "PROFESSION_ICE_PRACTICE" ); + break; + case 3: + // 加雷熟练度经验值 + PROFESSION_SKILL_LVEVEL_UP( charaindex, "PROFESSION_THUNDER_PRACTICE" ); + break; + + } + + // 显示的位置方式 0人物 1画面中央 + memset( temp, 0, sizeof(temp) ); + if( !getStringFromIndexWithDelim(pszOption,"|",2,temp,sizeof(temp)) ) return -1; + place = atoi(temp); + PROFESSION_magic[attIdx].uiShowType = place; + + // 显示在人物的前方或下方 + memset( temp, 0, sizeof(temp) ); + if( !getStringFromIndexWithDelim(pszOption,"|",3,temp,sizeof(temp)) ) return -1; + place2 = atoi(temp); + PROFESSION_magic[attIdx].uiShowBehindChar = place2; + + // 显示的位置X + memset( temp, 0, sizeof(temp) ); + if( !getStringFromIndexWithDelim(pszOption,"|",4,temp,sizeof(temp)) ) return -1; + x = atoi(temp); + + // 显示的位置Y + memset( temp, 0, sizeof(temp) ); + if( !getStringFromIndexWithDelim(pszOption,"|",5,temp,sizeof(temp)) ) return -1; + y = atoi(temp); + + // 震动画面的开始毫秒数 + memset( temp, 0, sizeof(temp) ); + if( !getStringFromIndexWithDelim(pszOption,"|",6,temp,sizeof(temp)) ) return -1; + shake_s_time = atoi(temp); + + // 震动画面的结束毫秒数 + memset( temp, 0, sizeof(temp) ); + if( !getStringFromIndexWithDelim(pszOption,"|",7,temp,sizeof(temp)) ) return -1; + shake_e_time = atoi(temp); + + // 咒术一般攻击完时是否马上消失 + memset( temp, 0, sizeof(temp) ); + if( !getStringFromIndexWithDelim(pszOption,"|",8,temp,sizeof(temp)) ) return -1; + disappear = atoi(temp); + + // 准备动作的魔法图号 + image_1 = PROFESSION_SKILL_getInt( skill, PROFESSION_SKILL_IMG_1); + PROFESSION_magic[attIdx].uiPrevMagicNum = image_1; // 前置动画 + + // 战斗的魔法图号 + image_2 = PROFESSION_SKILL_getInt( skill, PROFESSION_SKILL_IMG_2); + PROFESSION_magic[attIdx].uiSpriteNum = image_2; // 後置动画 + + // 显示在画面的 x,y座标 + PROFESSION_magic[attIdx].siSx = x; + PROFESSION_magic[attIdx].siSy = y; + + // 取得攻击右边的魔法图号及座标 + PROFESSION_MAGIC_GET_IMG2( toNo, charaindex, attIdx, pszOption ); + + // 地震的时间 + if( (shake_s_time>0) || (shake_e_time>0) ){ + PROFESSION_magic[attIdx].uiShakeScreen = 1; + PROFESSION_magic[attIdx].uiShakeFrom = shake_s_time; + PROFESSION_magic[attIdx].uiShakeTo = shake_e_time; + }else{ + PROFESSION_magic[attIdx].uiShakeScreen = 0; + PROFESSION_magic[attIdx].uiShakeFrom = 0; + PROFESSION_magic[attIdx].uiShakeTo = 0; + } + + + return magic_type; +} + + +// 取熟练度得伤害力 +void PROFESSION_MAGIC_GET_PRACTICE( + float *hp_power, + float *mp_power, + float *dec_hp, + float *dec_mp, + int charaindex +) +{ + int skill_level=0, critical=0, command=0; + + skill_level = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_M( skill_level ); + + command = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1); + + critical = RAND( 1,100); + + switch( command ){ + case BATTLE_COM_S_VOLCANO_SPRINGS: // 火山泉 + { + *hp_power = skill_level * 10 + 100; + + if( skill_level >= 10 ){ + if( critical <= 25 ) + *hp_power *= 1.5; + }else{ + if( critical <= (skill_level+12) ) + *hp_power *= 1.5; + } + + break; + } + case BATTLE_COM_S_FIRE_BALL: // 火星球 + { + if( skill_level >= 10 ) + *hp_power = 360; + else if( skill_level >= 9 ) + *hp_power = 320; + else if( skill_level >= 8 ) + *hp_power = 280; + else if( skill_level >= 7) + *hp_power = 260; + else if( skill_level >= 5) + *hp_power = 220; + else if( skill_level >= 3) + *hp_power = 180; + else + *hp_power = 160; + + break; + } + case BATTLE_COM_S_SUMMON_THUNDER: // 召雷术 + { + *hp_power = skill_level*10 + 200; + break; + } + case BATTLE_COM_S_CURRENT: // 电流术 + { +#ifdef _PROFESSION_ADDSKILL + if( skill_level >= 10 ) + *hp_power = 300; + else if( skill_level > 9 ) + *hp_power = 250; + else if( skill_level > 7 ) + *hp_power = 200; + else if( skill_level > 4 ) + *hp_power = 150; + else if( skill_level > 1 ) + *hp_power = 10; + else + *hp_power = 50; +#else + *hp_power = skill_level*50 + 100; +#endif + break; + } + case BATTLE_COM_S_STORM: // 暴风雨 + { +#ifdef _PROFESSION_ADDSKILL + if( skill_level > 9 ) + *hp_power = 200; + else if( skill_level > 7 ) + *hp_power = 180; + else if( skill_level > 5 ) + *hp_power = 160; + else if( skill_level > 3 ) + *hp_power = 140; + else + *hp_power = 120; +#else + *hp_power = skill_level*10 + 100; +#endif + break; + } + case BATTLE_COM_S_ICE_ARROW: // 冰箭术 + { + if( skill_level >= 10 ) + *hp_power = 250; + else + *hp_power = skill_level*10 + 130; + break; + } + case BATTLE_COM_S_ICE_CRACK: // 冰爆术 + { + if( skill_level >= 10 ) + *hp_power = 400; + else if ( skill_level == 9 ) + *hp_power = 300; + else + *hp_power = skill_level*10 + 210; + + break; + } + case BATTLE_COM_S_DOOM: // 世界末日 + { + if( skill_level >= 10 ) + *hp_power = 550; + else if( skill_level > 9 ) + *hp_power = 500; + else if( skill_level > 8 ) + *hp_power = 450; + else if( skill_level > 7 ) + *hp_power = 400; + else if( skill_level > 6 ) + *hp_power = 350; + else if( skill_level > 4 ) + *hp_power = 300; + else if( skill_level > 2 ) + *hp_power = 250; + else + *hp_power = 200; + break; + } + case BATTLE_COM_S_FIRE_SPEAR: // 火龙枪 + { + if( skill_level > 9 ) + *hp_power = 800; + else if( skill_level > 8 ) + *hp_power = 450; + else if( skill_level > 7 ) + *hp_power = 400; + else if( skill_level > 6 ) + *hp_power = 350; + else if( skill_level > 5 ) + *hp_power = 300; + else if( skill_level > 3 ) + *hp_power = 200; + else + *hp_power = 100; + break; + } + + case BATTLE_COM_S_BLOOD: // 嗜血成性 + { + int hp = CHAR_getInt( charaindex, CHAR_HP); + if( hp > 1 ) + *hp_power = CHAR_getInt( charaindex, CHAR_HP) * (skill_level*5 +10) /100; + else + *hp_power = 0; + + break; + } + case BATTLE_COM_S_BLOOD_WORMS: // 嗜血蛊 + { + *hp_power = skill_level*10+20; + break; + } + case BATTLE_COM_S_SIGN: // 一针见血 + { +#ifdef _PROFESSION_ADDSKILL + if( skill_level >= 10 ){ + *hp_power = 200; + *mp_power = 30; + }else if( skill_level > 6 ){ + *hp_power = 150; + *mp_power = 20; + }else if( skill_level > 3 ){ + *hp_power = 100; + *mp_power = 15; + }else{ + *hp_power = 50; + *mp_power = 10; + } +#else + if( skill_level >= 10 ){ + *hp_power = 300; + *mp_power = 70; + }else if( skill_level >= 9 ){ + *hp_power = 200; + *mp_power = 50; + }else if( skill_level >= 7 ){ + *hp_power = 150; + *mp_power = 30; + }else if( skill_level >= 4 ){ + *hp_power = 100; + *mp_power = 20; + }else{ + *hp_power = 50; + *mp_power = 10; + } +#endif + break; + } + case BATTLE_COM_S_ENCLOSE: // 附身术 + { +#ifdef _PROFESSION_ADDSKILL + if( skill_level >= 10 ) + *hp_power = 400; + else if( skill_level > 9 ) + *hp_power = 300; + else if( skill_level > 7 ) + *hp_power = 250; + else if( skill_level > 4 ) + *hp_power = 200; + else + *hp_power = 150; + break; +#else + if( skill_level >= 10 ) + *hp_power = 300; + else if( skill_level >= 8 ) + *hp_power = 250; + else if( skill_level >= 5 ) + *hp_power = 200; + else + *hp_power = 150; + break; +#endif + } + default: + break; + } + +#ifdef _SUIT_ADDENDUM + *hp_power += *hp_power * (CHAR_getWorkInt( charaindex, CHAR_WORKMPOWER )/100.00); +#endif +#ifdef _SUIT_ADDPART4 + if( rand()%100 < 30 ) + *hp_power += *hp_power * (CHAR_getWorkInt( charaindex, CHAR_WORKMPOWER2 )/100.00);//加强法师魔法的装备(限定30%机率) +#endif + + if( *hp_power > 0 ){ + float rand_num = RAND( 98, 102 ); + *hp_power *= rand_num / 100; + }else{ + *hp_power = 0; + } +} + + +// 选择改击数量 +void PROFESSION_MAGIC_TOLIST_SORT( int *list, int *listidx, int charaindex ) +{ + int j=0, get_num=0, temp[SIDE_OFFSET * 2 + 1]; + int skill_level=-1, command=-1; + + skill_level = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_M( skill_level ); + + command = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1); + + switch(command){ + case BATTLE_COM_S_CURRENT: // 电流术 + { +#ifdef _PROFESSION_ADDSKILL + if( skill_level > 9 ) get_num = 10; + else if( skill_level > 8 ) get_num = 9; + else if( skill_level > 7 ) get_num = 8; + else if( skill_level > 6 ) get_num = 7; + else if( skill_level > 5 ) get_num = 6; + else if( skill_level > 4 ) get_num = 5; + else if( skill_level > 3 ) get_num = 4; + else if( skill_level > 2 ) get_num = 3; + else if( skill_level > 1 ) get_num = 2; + else get_num = 1; +#else + if( skill_level >= 9 ) get_num = 5; + else if( skill_level >= 7 ) get_num = 4; + else if( skill_level >= 5 ) get_num = 3; + else if( skill_level >= 3 ) get_num = 2; + else get_num = 1; +#endif + break; + } + case BATTLE_COM_S_STORM: // 暴风雨 + { + get_num = skill_level; + break; + } + case BATTLE_COM_S_DOOM: // 世界末日 + { + if( skill_level >= 8 ) get_num = 10; + else if( skill_level >= 7 ) get_num = 8; + else if( skill_level >= 5 ) get_num = 6; + else if( skill_level >= 3 ) get_num = 4; + else get_num = 2; + break; + } + case BATTLE_COM_S_FIRE_SPEAR: // 火龙枪 + { + /*int miss_rate=0, rand_num=0; + + miss_rate = skill_level * 2 + 10; + rand_num = RAND(0, 100); + + if( rand_num <= miss_rate ){ + memset(list, -1, sizeof(list)); + *listidx = 0; + return; + }else + get_num = skill_level; + + break;*/ + /* + if( skill_level > 9 ) get_num = 10; + else if( skill_level > 8) get_num = 9; + else if( skill_level > 7 ) get_num = 8; + else if( skill_level > 6 ) get_num = 7; + else if( skill_level > 5 ) get_num = 6; + else if( skill_level > 4 ) get_num = 5; + else if( skill_level > 3 ) get_num = 4; + else if( skill_level > 2 ) get_num = 3; + else if( skill_level > 1 ) get_num = 2; + else get_num = 1; + */ + break; + } + case BATTLE_COM_S_SIGN: // 一针见血 + { +#ifdef _PROFESSION_ADDSKILL + get_num = 10; +#else + if( skill_level >= 10 ) get_num = 5; + else if( skill_level >= 8 ) get_num = 4; + else if( skill_level >= 6 ) get_num = 3; + else if( skill_level >= 3 ) get_num = 2; + else get_num = 1; +#endif + break; + } + case BATTLE_COM_S_CONVOLUTE: // 回旋攻击 + case BATTLE_COM_S_FIRE_BALL: // 火星球 + { + int toNo=-1, toNo2=-1, battleindex=-1, i=0, count=0; + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + + if(battleindex == -1) return; + + toNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2); + memset( temp, -1, sizeof( temp ) ); + + if( toNo == 24 ) toNo2 = 15; + else if( toNo == 23 ) toNo2 = 10; + else if( toNo == 25 ) toNo2 = 5; + else if( toNo == 26 ) toNo2 = 0; + else return; + + for( i=0; i<5; i++ ){ + if(BATTLE_TargetCheck(battleindex,toNo2+i) != FALSE){ + temp[count] = toNo2+i; + count++; + } + } + + memset(list, -1, sizeof(list)); + memcpy( list, temp, sizeof(temp) ); + + *listidx = count; + + return; + } + case BATTLE_COM_S_THROUGH_ATTACK: // 贯穿攻击 + { + int toNo = -1, toNo2 = -1, battleindex = -1; + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + if(battleindex == -1) return; + + toNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2); + memset( temp, -1, sizeof( temp ) ); + temp[0] = toNo; + + if( toNo < (SIDE_OFFSET/2) ) toNo2= toNo + (SIDE_OFFSET/2); + else if( toNo < (SIDE_OFFSET) ) toNo2= toNo - (SIDE_OFFSET/2); + else if( toNo < (SIDE_OFFSET*1.5) ) toNo2= toNo + (SIDE_OFFSET/2); + else if( toNo < (SIDE_OFFSET*2) ) toNo2= toNo - (SIDE_OFFSET/2); + + if(BATTLE_TargetCheck( battleindex, toNo2 ) != FALSE){ + if( toNo2 > toNo ){ + temp[0] = toNo2; + temp[1] = toNo; + }else + temp[1] = toNo2; + + *listidx = 2; + }else + *listidx = 1; + + memset(list, -1, sizeof(list)); + memcpy( list, temp, sizeof(temp) ); + + } + default: + return; + } + + if( get_num == 0 ) return; + + if( get_num >= 10) get_num=10; + + if( get_num >= *listidx ) return; + + memset(temp, -1, sizeof(temp)); + + while( j < get_num ){ + int rand_num=-1, out_num=-1; + + rand_num = RAND(0, *listidx-1); + out_num = list[rand_num]; + list[rand_num] = -1; + + if(out_num > 0){ + temp[j] = out_num; + j++; + } + } + + memset(list, -1, sizeof(list)); + memcpy( list, temp, sizeof(temp) ); + + *listidx = j; + + return; +} + + +// 改变自身状态 +void PROFESSION_MAGIC_CHANGE_STATUS( + int charaindex, + int hp_power, + float mp_power, + float *add_hp, + float *add_mp +) +{ + int skill_level=0, command=0, critical=0; + critical = RAND( 1,100); + + skill_level = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_M( skill_level ); + + command = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1); + + switch( command ){ + case BATTLE_COM_S_BLOOD: // 嗜血成性 + { + int rate = 0; + + if( skill_level >= 10 ) rate = 20; + else if( skill_level >= 7 ) rate = 15; + else if( skill_level >= 5 ) rate = 10; + else if( skill_level >= 3 ) rate = 5; + else rate = 0; + + *add_mp += hp_power * ( rate + 40 ) / 100; + + break; + } + case BATTLE_COM_S_BLOOD_WORMS: // 嗜血蛊 + { + if( skill_level >= 10 ){ + *add_hp += hp_power * 0.2; + break; + }else{ + *add_hp += hp_power * ((skill_level/4)*5 + 5) / 100; + break; + } + break; + } +#ifdef _PROFESSION_ADDSKILL + case BATTLE_COM_S_SIGN: // 一针见血 + { + int success=10; + /*( skill_level >= 10 ) success = 30;//成功率 + else if( skill_level > 9 ) success = 25; + else if( skill_level > 8 ) success = 20; + else if( skill_level > 7 ) success = 15; + else success = 10; + success = 30;*/ + if( RAND(0,100) < success ){ + if( skill_level > 8 ){ + *add_hp += hp_power; + *add_mp += mp_power; + } + else if( skill_level > 7 ){ + *add_hp += hp_power/2; + *add_mp += 0; + } + } + else + { + *add_hp += 0; + *add_mp += 0; + } + break; + } +#endif + default: + break; + } +} + +// 取得位置不是在中央的多人魔法图号及座标 +void PROFESSION_MAGIC_GET_IMG2( int toNo, int charaindex, int attIdx, char *pszOption ) +{ + int command=0, img2=0, x=0, y=0; + char temp[64]; + int skill_level=0; + + skill_level = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_M( skill_level ); + + command = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM1); + + switch( command ){ + case BATTLE_COM_S_BLOOD: // 嗜血成性 + { + int img=0; + + if( skill_level >= 10 ) img = 101689; + else if( skill_level >= 7 ) img = 101690; + else if( skill_level >= 3 ) img = 101691; + else img = 101692; + + PROFESSION_MAGIC_CHANG_IMG2( img, pszOption, attIdx ); + return; + } + case BATTLE_COM_S_VOLCANO_SPRINGS: // 火山泉 + { + int img=0; + + if( skill_level >= 10 ) img = 101686; + else if( skill_level >= 5 ) img = 101687; + else img = 101688; + + if( toNo >= 0 && toNo < 10 ) + PROFESSION_MAGIC_CHANG_IMG2( img, pszOption, attIdx ); + else{ + int x=0, y=0; + char temp[128]; + + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",11,temp,sizeof(temp)) ) x = atoi(temp); + + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",12,temp,sizeof(temp)) ) y = atoi(temp); + + // 後置动画 + PROFESSION_magic[attIdx].uiSpriteNum = img; + + // 後置动画座标 + PROFESSION_magic[attIdx].siSx = x; + PROFESSION_magic[attIdx].siSy = y; + } + + return; + } + case BATTLE_COM_S_BLOOD_WORMS: // 嗜血蛊 + { + // 右方 + if( toNo == 20 || toNo == 25 || toNo == 26 || + ( toNo >= 0 && toNo < SIDE_OFFSET ) ) + PROFESSION_MAGIC_CHANG_IMG2( 101623, pszOption, attIdx ); + return; + } + case BATTLE_COM_S_ICE_MIRROR: // 冰镜术 + { + if( toNo >= 0 && toNo < 10 ) + PROFESSION_MAGIC_CHANG_IMG2( 101652, pszOption, attIdx ); + else{ + int x=0, y=0; + char temp[128]; + + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",11,temp,sizeof(temp)) ) x = atoi(temp); + + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",12,temp,sizeof(temp)) ) y = atoi(temp); + + // 後置动画 + PROFESSION_magic[attIdx].uiSpriteNum = 101652; + + // 後置动画座标 + PROFESSION_magic[attIdx].siSx = x; + PROFESSION_magic[attIdx].siSy = y; + } + + return; + } + case BATTLE_COM_S_ENCLOSE: // 附身术 + { + // 右方 + if( toNo == 20 || toNo == 25 || toNo == 26 || + ( toNo >= 0 && toNo < SIDE_OFFSET ) ) + PROFESSION_MAGIC_CHANG_IMG2( 101643, pszOption, attIdx ); + return; + } + case BATTLE_COM_S_FIRE_SPEAR: // 火龙枪 + { + // 右方 + //if( toNo == 20 || toNo == 25 || toNo == 26 ) + if( toNo < 10 ) + PROFESSION_MAGIC_CHANG_IMG2( 101642, pszOption, attIdx ); + return; + } + case BATTLE_COM_S_DOOM: // 世界末日 + { + // 右方 + if( toNo == 20 || toNo == 25 || toNo == 26 ) + PROFESSION_MAGIC_CHANG_IMG2( 101639, pszOption, attIdx ); + return; + } + case BATTLE_COM_S_ICE_CRACK: // 冰爆术 + { + // 右方 + if( toNo == 20 || toNo == 25 || toNo == 26 ) + PROFESSION_MAGIC_CHANG_IMG2( 101650, pszOption, attIdx ); + return; + } + case BATTLE_COM_S_ICE_ARROW: // 冰箭术 + { + // 右方 + if( toNo == 20 || toNo == 25 || toNo == 26 || + ( toNo >= 0 && toNo < SIDE_OFFSET ) ) + PROFESSION_MAGIC_CHANG_IMG2( 101649, pszOption, attIdx ); + return; + + } + case BATTLE_COM_S_STORM: // 暴风雨 + { + // 右方 + if( toNo == 20 || toNo == 25 || toNo == 26 ) + PROFESSION_MAGIC_CHANG_IMG2( 101677, pszOption, attIdx ); + return; + } +#ifdef _PROFESSION_ADDSKILL + case BATTLE_COM_S_BOUNDARY: // 四属性结界 + { + // 右方 + if( toNo == 20 || toNo == 25 || toNo == 26 ){ + if( getStringFromIndexWithDelim(pszOption,"|",1,temp,sizeof(temp)) ) + { + if( strcmp( "地结界", temp ) == 0 ) + PROFESSION_MAGIC_CHANG_IMG2( 101786, pszOption, attIdx ); + else if( strcmp( "水结界", temp ) == 0 ) + PROFESSION_MAGIC_CHANG_IMG2( 101774, pszOption, attIdx ); + else if( strcmp( "火结界", temp ) == 0 ) + PROFESSION_MAGIC_CHANG_IMG2( 101780, pszOption, attIdx ); + else if( strcmp( "风结界", temp ) == 0 ) + PROFESSION_MAGIC_CHANG_IMG2( 101792, pszOption, attIdx ); + else + PROFESSION_MAGIC_CHANG_IMG2( 101770, pszOption, attIdx ); + } + } + return; + } +#endif + case BATTLE_COM_S_CONVOLUTE: // 回旋攻击 + { + img2=101656; + if( toNo == 25 ){ // 右 1 + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",9,temp,sizeof(temp)) ) x = atoi(temp); + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",10,temp,sizeof(temp)) ) y = atoi(temp); + }else if( toNo == 26 ){ // 右 2 + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",11,temp,sizeof(temp)) ) x = atoi(temp); + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",12,temp,sizeof(temp)) ) y = atoi(temp); + }else if( toNo == 23 ){ // 左 1 + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",13,temp,sizeof(temp)) ) x = atoi(temp); + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",14,temp,sizeof(temp)) ) y = atoi(temp); + }else if( toNo == 24 ){ // 左 2 + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",15,temp,sizeof(temp)) ) x = atoi(temp); + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",16,temp,sizeof(temp)) ) y = atoi(temp); + }else + return; + + // 後置动画 + PROFESSION_magic[attIdx].uiSpriteNum = img2; + + // 後置动画座标 + PROFESSION_magic[attIdx].siSx = x; + PROFESSION_magic[attIdx].siSy = y; + + break; + } + case BATTLE_COM_S_THROUGH_ATTACK: // 贯穿攻击 + { + if( (toNo == 13) || (toNo == 18) ){ // 左下 1 + img2=101676; + x = 50; + y = 240; + }else if( (toNo == 11) || (toNo == 16) ){ // 左 2 + img2=101675; + x = 120; + y = 200; + }else if( (toNo == 10) || (toNo == 15) ){ // 左 3 + img2=101674; + x = 140; + y = 160; + }else if( (toNo == 12) || (toNo == 17) ){ // 左 4 + img2=101673; + x = 160; + y = 120; + }else if( (toNo == 14) || (toNo == 19) ){ // 左 5 + img2=101672; + x = 180; + y = 80; + }else if( (toNo == 3) || (toNo == 8) ){ // 右 1 + img2=101665; + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",9,temp,sizeof(temp)) ) x = atoi(temp); + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",10,temp,sizeof(temp)) ) y = atoi(temp); + }else if( (toNo == 1) || (toNo == 6) ){ // 右 2 + img2=101664; + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",11,temp,sizeof(temp)) ) x = atoi(temp); + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",12,temp,sizeof(temp)) ) y = atoi(temp); + }else if( (toNo == 0) || (toNo == 5) ){ // 右 3 + img2=101663; + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",13,temp,sizeof(temp)) ) x = atoi(temp); + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",14,temp,sizeof(temp)) ) y = atoi(temp); + }else if( (toNo == 2) || (toNo == 7) ){ // 右 4 + img2=101662; + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",15,temp,sizeof(temp)) ) x = atoi(temp); + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",16,temp,sizeof(temp)) ) y = atoi(temp); + }else if( (toNo == 4) || (toNo == 9) ){ // 右 5 + img2=101661; + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",17,temp,sizeof(temp)) ) x = atoi(temp); + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",18,temp,sizeof(temp)) ) y = atoi(temp); + }else + return; + + // 後置动画 + PROFESSION_magic[attIdx].uiSpriteNum = img2; + + // 後置动画座标 + PROFESSION_magic[attIdx].siSx = x; + PROFESSION_magic[attIdx].siSy = y; + + // 前置动画 + if( toNo >= 10 ){ + int img1 = 101671; + PROFESSION_magic[attIdx].uiPrevMagicNum = img1; + } + break; + } + case BATTLE_COM_S_FIRE_BALL: // 火星球 + { + if( toNo == 25 ){ // 右 1 + img2=101694; + + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",9,temp,sizeof(temp)) ) x = atoi(temp); + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",10,temp,sizeof(temp)) ) y = atoi(temp); + }else if( toNo == 26 ){ // 右 2 + img2=101694; + + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",11,temp,sizeof(temp)) ) x = atoi(temp); + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",12,temp,sizeof(temp)) ) y = atoi(temp); + }else if( toNo == 23 ){ // 左 1 + img2=101693; + + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",13,temp,sizeof(temp)) ) x = atoi(temp); + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",14,temp,sizeof(temp)) ) y = atoi(temp); + }else if( toNo == 24 ){ // 左 2 + img2=101693; + + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",15,temp,sizeof(temp)) ) x = atoi(temp); + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",16,temp,sizeof(temp)) ) y = atoi(temp); + }else + return; + + // 後置动画 + PROFESSION_magic[attIdx].uiSpriteNum = img2; + + // 後置动画座标 + PROFESSION_magic[attIdx].siSx = x; + PROFESSION_magic[attIdx].siSy = y; + + break; + } + default: return; + } + +} + + +#define D_16 (1.0/16) +#define D_8 (1.0/8) +// 取得攻击伤害 +#ifdef _PROFESSION_ADDSKILL +int PROFESSION_MAGIC_GET_DAMAGE( int attackindex, int defindex, int magic_type, int power, int command ) +#else +int PROFESSION_MAGIC_GET_DAMAGE( int attackindex, int defindex, int magic_type, int power ) +#endif +{ + int attack=0; + int damage = 0, rand_num=0; + int fire_proficiency = -1, electric_proficiency = -1, ice_proficiency = -1;//熟练度 + int fire_resist = -1, electric_resist = -1, ice_resist = -1; + +#ifdef _FIX_MAGIC_RESIST // WON ADD 修正魔法抗性 + int proficiency=0;//熟练度 + int resist=0;//抗性 + int suit=0;//装备 + int spirit=0;//使用精灵造成的抗性 + + if( command == BATTLE_COM_S_DOOM ) + magic_type = 1; + + if( magic_type == 1){ // 火属性 + proficiency = CHAR_getWorkInt( attackindex, CHAR_WORK_F_PROFICIENCY); // 火熟练度 + resist = CHAR_getWorkInt( defindex, CHAR_WORK_F_RESIST); // 火抗 +#ifdef _EQUIT_RESIST + suit = CHAR_getWorkInt( defindex, CHAR_WORK_F_SUIT)+CHAR_getWorkInt( defindex, CHAR_WORKEQUITFIRE ); +#else + suit = CHAR_getWorkInt( defindex, CHAR_WORK_F_SUIT); +#endif +#ifdef _MAGICSTAUTS_RESIST + if( CHAR_getWorkInt( defindex, CHAR_MAGICFIRE) > 0 ) + spirit = CHAR_getWorkInt( defindex, CHAR_OTHERSTATUSNUMS ); +#endif + } + + if( command == BATTLE_COM_S_DOOM ){ + damage = power * (1+proficiency/100.0) * (1-(resist/100.0)) * (1-(suit/100.0)) * (1-(spirit/100.0)); + magic_type = 2; + } + + if( magic_type == 2){ // 电属性 + proficiency = CHAR_getWorkInt( attackindex, CHAR_WORK_T_PROFICIENCY); // 电熟练度 + resist = CHAR_getWorkInt( defindex, CHAR_WORK_T_RESIST); // 电抗 +#ifdef _EQUIT_RESIST + suit = CHAR_getWorkInt( defindex, CHAR_WORK_I_SUIT)+CHAR_getWorkInt( defindex, CHAR_WORKEQUITTHUNDER ); +#else + suit = CHAR_getWorkInt( defindex, CHAR_WORK_I_SUIT); +#endif +#ifdef _MAGICSTAUTS_RESIST + if( CHAR_getWorkInt( defindex, CHAR_MAGICTHUNDER) > 0 ) + spirit = CHAR_getWorkInt( defindex, CHAR_OTHERSTATUSNUMS ); +#endif + } + + if( command == BATTLE_COM_S_DOOM ){ + damage += power * (1+proficiency/100.0) * (1-(resist/100.0)) * (1-(suit/100.0)) * (1-(spirit/100.0)); + magic_type = 3; + } + + if( magic_type == 3){ // 冰属性 + proficiency = CHAR_getWorkInt( attackindex, CHAR_WORK_I_PROFICIENCY); // 冰熟练度 + resist = CHAR_getWorkInt( defindex, CHAR_WORK_I_RESIST); // 冰抗 +#ifdef _EQUIT_RESIST + suit = CHAR_getWorkInt( defindex, CHAR_WORK_T_SUIT)+CHAR_getWorkInt( defindex, CHAR_WORKEQUITICE ); +#else + suit = CHAR_getWorkInt( defindex, CHAR_WORK_T_SUIT); +#endif +#ifdef _MAGICSTAUTS_RESIST + if( CHAR_getWorkInt( defindex, CHAR_MAGICICE) > 0 ) + spirit = CHAR_getWorkInt( defindex, CHAR_OTHERSTATUSNUMS ); +#endif + } + + if( command == BATTLE_COM_S_DOOM ){ + damage += power * (1+proficiency/100.0) * (1-(resist/100.0)) * (1-(suit/100.0)) * (1-(spirit/100.0)); + damage /= 3.0; + } + else + damage = power * (1+proficiency/100.0) * (1-(resist/100.0)) * (1-(suit/100.0)) * (1-(spirit/100.0)); + +#else //_FIX_MAGIC_RESIST + + fire_proficiency = CHAR_getWorkInt( attackindex, CHAR_WORK_F_PROFICIENCY); // 火熟练度 + electric_proficiency = CHAR_getWorkInt( attackindex, CHAR_WORK_T_PROFICIENCY); // 电熟练度 + ice_proficiency = CHAR_getWorkInt( attackindex, CHAR_WORK_I_PROFICIENCY); // 冰熟练度 + fire_resist = CHAR_getWorkInt( defindex, CHAR_WORK_F_RESIST); // 火抗 + electric_resist = CHAR_getWorkInt( defindex, CHAR_WORK_T_RESIST); // 电抗 + ice_resist = CHAR_getWorkInt( defindex, CHAR_WORK_I_RESIST); // 冰抗 + +// print("\n won test 0.0 ==> f(%d) e(%d) i(%d)", fire_proficiency, electric_proficiency, ice_proficiency ); +// print("\n won test 0.1 ==> f(%d) e(%d) i(%d)", fire_resist, electric_resist, ice_resist ); + + if( magic_type == 1){ // 火属性 + + attack = power * ( 100 + fire_proficiency ) / 100; // 攻击加成 + + if( rand_num < 40){ // 原攻击伤害 + attack = attack * ( 100 - fire_resist ) / 100; + }else{ // 乱数取伤害 + rand_num = RAND(-20, 20); + attack = attack * ( 100 - (rand_num + fire_resist) ) / 100; + } +//print( "\nattack:%d ", attack ); + + }else + if( magic_type == 2){ // 电属性 + + attack = power * ( 100 + electric_proficiency ) / 100; // 攻击加成 + + if( rand_num < 40){ // 原攻击伤害 + attack = attack * ( 100 - electric_resist ) / 100; + }else{ // 乱数取伤害 + rand_num = RAND(-20, 20); + attack = attack * ( 100 - (rand_num + electric_resist) ) / 100; + } + }else + if( magic_type == 3){ // 冰属性 + + attack = power * ( 100 + ice_proficiency ) / 100; // 攻击加成 + + if( rand_num < 40){ // 原攻击伤害 + attack = attack * ( 100 - ice_resist ) / 100; + }else{ // 乱数取伤害 + rand_num = RAND(-20, 20); + attack = attack * ( 100 - (rand_num + ice_resist) ) / 100; + } + }else{ // 无 + attack = power; + } + + damage = attack; + +#endif + + if( damage < 0 ) + damage = 0; + + return damage; +} + + +// 取得特殊攻击伤害 +int PROFESSION_MAGIC_GET_ICE_MIRROR_DAMAGE( int attackindex, int defindex, int command, int power ) +{ + int damage = power; + + if( command == BATTLE_COM_S_ICE_MIRROR ){ // 冰镜术 + float defense = -1; + int rate=0; + int defpet = BATTLE_getRidePet( defindex ); + int skill_level = CHAR_GETWORKINT_HIGH( attackindex, CHAR_WORKBATTLECOM3); + int base_defense = CHAR_getInt( defindex, CHAR_TOUGH ) / 100; + + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_M( skill_level ); + + if( defpet == -1 ) + defense = CHAR_getWorkInt( defindex, CHAR_WORKDEFENCEPOWER ); + else + defense = BATTLE_adjustRidePet3A( defindex, defpet, CHAR_WORKDEFENCEPOWER, DEFFENCESIDE ); + + if( skill_level >= 10 ){ + rate = 60; + }else{ + rate = skill_level * 5 + 5; + } + + //andy_Edit + damage = 120 + (int)( ( defense * rate / 100 ) + ( ( defense - base_defense ) * rate / 200 ) ); + //控制对npc的伤害 + if( CHAR_getInt( defense , CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ) + damage = damage > 800 ? 800 : damage; + + }else + if( command == BATTLE_COM_S_CONVOLUTE ){ // 回旋攻击 + int skill_level = CHAR_GETWORKINT_HIGH( attackindex, CHAR_WORKBATTLECOM3); + int hit=0; + int rand_num = RAND( 1, 100); + + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_A( skill_level ); + + hit = skill_level * 2 + 60; + + //if( rand_num <= hit ){ + // 取得回旋攻击伤害 + damage = BATTLE_PROFESSION_CONVOLUTE_GET_DAMAGE( attackindex, defindex, skill_level ); + //}else{ + // damage = 0; + //} + }else + if( command == BATTLE_COM_S_THROUGH_ATTACK ){ // 贯穿攻击 + int skill_level = CHAR_GETWORKINT_HIGH( attackindex, CHAR_WORKBATTLECOM3); + + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_A( skill_level ); + + if( skill_level != 10 ){ + // 命中率下降 + CHAR_setWorkInt( attackindex, CHAR_MYSKILLHIT, 1); + CHAR_setWorkInt( attackindex, CHAR_MYSKILLHIT_NUM, -70); + CHAR_setWorkInt( attackindex, CHAR_WORKHITRIGHT, CHAR_getWorkInt(attackindex,CHAR_WORKHITRIGHT) -50 ); + } + + // 取得贯穿攻击伤害 + damage = BATTLE_PROFESSION_THROUGH_ATTACK_GET_DAMAGE( attackindex, defindex ); + } +#ifdef _PROFESSION_ADDSKILL + else + if( command == BATTLE_COM_S_CURRENT //电流术 + || command == BATTLE_COM_S_SUMMON_THUNDER ){//召雷术 + if( CHAR_getWorkInt( defindex, CHAR_WORKWATER ) > 0 ){//水附体 + if( RAND(1, 100) < 75 ) + damage *= 3; + } + } +#endif + return damage; +} + + + +// 计算闪避率 +// return: 0:没闪过 1:闪过 +int PROFESSION_MAGIC_DODGE( int atk_index, int def_index, int magic_type ) +{ + float fLuck = 0,fResist = 0, proficiency = 0; + float Dluck=0.0; + int charType = CHAR_getInt( def_index, CHAR_WHICHTYPE); + int rand_num = RAND( 1, 100 ); + int command; + + + // 目标地球一周,不动作 + if( CHAR_getWorkInt( def_index, CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_EARTHROUND0 ){ + return 1; // Miss + } + + // 如果是防守者是玩家 + if( charType == CHAR_TYPEPLAYER ){ + + // 幸运 + fLuck = (float)CHAR_getInt( def_index, CHAR_LUCK) * 3; + + // 抗性 + if( magic_type != 0 ){ + fResist = (float)(CHAR_getWorkInt( def_index, CHAR_WORK_F_RESIST + magic_type - 1 )) * 0.5; + } + fLuck += fResist; + + // 抗魔装备 + Dluck = (float)(CHAR_getWorkInt( def_index, CHAR_EQUITQUIMAGIC)*0.4); + + fLuck += Dluck; + + }else {// 如果是防守者是宠物 + fLuck = (float)CHAR_getInt( def_index, CHAR_LV) * 0.15; + if(fLuck > 20) fLuck = 20; + } + + // 熟练度 + // Robin fix + //if( magic_type != 0 ){ + if( magic_type > 0 ){ + proficiency = (float)CHAR_getInt( atk_index, (CHAR_WORK_F_PROFICIENCY + magic_type - 1) ) * 0.2; + fLuck -= proficiency; + } + +/* print("\n PROFESSION_MAGIC_DODGE atk=%s def=%s magic_type(%d)", + CHAR_getChar( atk_index, CHAR_NAME), + CHAR_getChar( def_index, CHAR_NAME), + magic_type ); + print("\n won test 4 ==> rand_num(%d) lucky(%d) fResist(%f) Dluck(%f) proficiency(%f) fLuck(%f)", + rand_num, + CHAR_getInt( def_index, CHAR_LUCK) * 3, + fResist, + Dluck, + proficiency, + fLuck ); +*/ + if( rand_num > (int)fLuck){ +#ifdef _PROFESSION_ADDSKILL + command = CHAR_getWorkInt( atk_index, CHAR_WORKBATTLECOM1); + switch( command ){ + case BATTLE_COM_S_CURRENT: + case BATTLE_COM_S_STORM: + if( RAND( 1, 100 ) < 75 ) + return 0; + else + return 1; + break; + case BATTLE_COM_S_FIRE_SPEAR: + case BATTLE_COM_S_DOOM: + if( RAND( 1, 100 ) < 90 ) + return 0; + else + return 1; + break; + case BATTLE_COM_S_SIGN: + if( RAND( 1, 100 ) < 50 ) + return 0; + else + return 1; + break; + } +#endif + return 0; // hit + } + else + return 1; // Miss +} + +void PROFESSION_MAGIC_CHANG_IMG2( int img2, char *pszOption, int attIdx ) +{ + int x=0, y=0; + char temp[128]; + + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",9,temp,sizeof(temp)) ) x = atoi(temp); + + memset( temp, 0, sizeof(temp) ); + if( getStringFromIndexWithDelim(pszOption,"|",10,temp,sizeof(temp)) ) y = atoi(temp); + + // 後置动画 + PROFESSION_magic[attIdx].uiSpriteNum = img2; + + // 後置动画座标 + PROFESSION_magic[attIdx].siSx = x; + PROFESSION_magic[attIdx].siSy = y; +} + + + +int PROFESSION_MAGIC_CHANG_STATUS(int command,int battleindex, int charaindex, int charaidx, int attvalue, int no ) +{ + int i,j; + int skill_level=0; + + skill_level = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_M( skill_level ); + + switch( command ){ + case BATTLE_COM_S_THROUGH_ATTACK: // 贯穿攻击 + { + int skill_level = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_A( skill_level ); + + if( no == 0 ){ // 攻击前排的 + attvalue = attvalue * (skill_level * 2 + 70) / 100; + }else if( no == 1 ){ // 攻击後排的 + attvalue = attvalue * (skill_level * 2 + 50) / 100; + } + + break; + } + case BATTLE_COM_S_ICE_CRACK: // 冰爆术 + { + int hit=0, rand_num = RAND( 0, 100 ); + + //for( j = 1; j < BATTLE_ST_END; j++ ){ //若已有异常状态则return + // if( CHAR_getWorkInt( charaidx, StatusTbl[j] ) > 0 ) return 0; + //} + // 命中率 + if( skill_level >= 10 ) hit = 80; + else if( skill_level >= 7 ) hit = 70; + else if( skill_level >= 5 ) hit = 80; + else if( skill_level >= 3 ) hit = 90; + else hit = 100; + + hit = 100; + if( rand_num < hit ){ + int damage=0; + int bid = BATTLE_Index2No( battleindex, charaidx ); + + if( skill_level >= 10 ) damage = attvalue * 1.3; + else if( skill_level >= 7 ) damage = attvalue * 1.25; + else if( skill_level >= 4 ) damage = attvalue * 1.2; + else damage = attvalue * 1.1; + + if( damage <= 0 ) break; + + for( i=0; i<10; i++ ){ + if( CHAR_getWorkInt( charaidx, CHAR_WORKICECRACK+i ) <= 0 ){ + CHAR_setWorkInt( charaidx, CHAR_WORKICECRACK+i, 3 ); + CHAR_setWorkInt( charaidx, CHAR_WORKMODICECRACK+i, damage ); + print("\niceidx:%d",charaidx); + break; + } + } + //BATTLE_BadStatusString( bid, BATTLE_ST_ICECRACK ); + + } + + // 冰爆术第一击无伤害 + attvalue = 0; + + break; + } + case BATTLE_COM_S_ENCLOSE: // 附身术 + { + for( j = 1; j < BATTLE_ST_END; j++ ) //若已有异常状态则return + if( CHAR_getWorkInt( charaidx, StatusTbl[j] ) > 0 ) return attvalue; + + { + int success=0, rand_num=0, round=1; + int bid = BATTLE_Index2No( battleindex, charaidx ); + + skill_level = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3); + + if( skill_level >= 100 ) success = 50; + else if( skill_level > 90 ) success = 40; + else if( skill_level > 80 ) success = 30; + else if( skill_level > 60 ) success = 25; + else if( skill_level > 30 ) success = 20; + else success = 10; + + if( skill_level > 80 ) round = 3; + else if( skill_level > 50 ) round = 2; + else round = 1; + + rand_num = RAND(0,100); + + if( rand_num <= success ){ //成功时目标混乱 +#ifdef _PROFESSION_ADDSKILL + CHAR_setWorkInt( charaidx, CHAR_WORKANNEX, round ); + print("\n附身round:%d",round); +#else + CHAR_setWorkInt( charaidx, CHAR_WORKCONFUSION, 4 ); + CHAR_setWorkInt( charaidx, CHAR_WORKMODCONFUSION, 100 ); +#endif + BATTLE_BadStatusString( bid, BATTLE_ST_CONFUSION ); + } + } + break; + } + case BATTLE_COM_S_ICE_ARROW: // 冰箭 + { + for( j = 1; j < BATTLE_ST_END; j++ ){ //若已有异常状态则return + if( CHAR_getWorkInt( charaidx, StatusTbl[j] ) > 0 ) return attvalue; + } + { + int success=0, rand_num=0; + int bid = BATTLE_Index2No( battleindex, charaidx ); + + if( skill_level >= 8 ) success = 25; + else if( skill_level >= 5 ) success = 20; + else if( skill_level >= 2 ) success = 15; + else success = 10; + rand_num = RAND(0,100); + + if( rand_num <= success ){ //成功时目标降敏 + int dec_dex=0, turn=0; + + if( skill_level >= 8 ) dec_dex = 25; + else if( skill_level >= 5 ) dec_dex = 20; + else dec_dex = 10; + + if( skill_level >= 10 ) turn = 3; + else if( skill_level >= 6 ) turn = 2; + else turn = 1; + + CHAR_setWorkInt( charaidx, CHAR_WORKICEARROW, turn + 1 ); + CHAR_setWorkInt( charaidx, CHAR_WORKMODICEARROW, dec_dex ); + + BATTLE_BadStatusString( bid, BATTLE_ST_ICEARROW ); + } + } + break; + } + case BATTLE_COM_S_BLOOD_WORMS: // 嗜血蛊 + { + for( j = 1; j < BATTLE_ST_END; j++ ){ //若已有异常状态则return + if( CHAR_getWorkInt( charaidx, StatusTbl[j] ) > 0 ) return attvalue; + } + { + int turn=0; + int bid = BATTLE_Index2No( battleindex, charaidx ); + + if( skill_level >= 10 ) turn = 5; + else if( skill_level >= 8 ) turn = 4; + else if( skill_level >= 5 ) turn = 3; + else turn = 2; + + CHAR_setWorkInt( charaidx, CHAR_WORKBLOODWORMS, turn + 1 ); + CHAR_setWorkInt( charaidx, CHAR_WORKMODBLOODWORMS, skill_level ); + CHAR_setWorkInt( charaidx, CHAR_WORKBLOODWORMSID, charaindex ); + + BATTLE_BadStatusString( bid, BATTLE_ST_BLOODWORMS ); + + } + break; + } + case BATTLE_COM_S_SIGN: // 一针见血 + { +#ifdef _PROFESSION_ADDSKILL +#else + for( j = 1; j < BATTLE_ST_END; j++ ){ //若已有异常状态则return + if( CHAR_getWorkInt( charaidx, StatusTbl[j] ) > 0 ) return attvalue; + } + { + int turn=0, success=0, rand_num=0; + int bid = BATTLE_Index2No( battleindex, charaidx ); + + // 非玩家离开 +// if( CHAR_getInt( charaidx, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) return attvalue; + + if( skill_level == 10 ) success = 35; + else if( skill_level >= 8 ) success = (skill_level - 3) * 5; + else if( skill_level >= 6 ) success = 20; + else if( skill_level >= 4 ) success = 15; + else if( skill_level >= 2 ) success = 10; + else success = 5; + + rand_num = RAND(0,100); + + if( rand_num <= success ){ //成功时目标吸血 + if( skill_level >= 10 ) turn = 5; + else if( skill_level >= 7 ) turn = 4; + else if( skill_level >= 4 ) turn = 3; + else turn = 2; + + CHAR_setWorkInt( charaidx, CHAR_WORKSIGN, turn + 1 ); + CHAR_setWorkInt( charaidx, CHAR_WORKMODSIGN, skill_level ); + CHAR_setWorkInt( charaidx, CHAR_WORKSIGNID, charaindex ); + + BATTLE_BadStatusString( bid, BATTLE_ST_SIGN ); + } + } +#endif + break; + } + case BATTLE_COM_S_DOOM: // 世界末日 + { +/* int rand_num = RAND( 1, 100 ), work, dex; + char szCommand[64]; + int bid = BATTLE_Index2No( battleindex, charaidx ); + + if( skill_level < 10 ) break; +#ifdef _PROFESSION_ADDSKILL + CHAR_setWorkInt( charaidx, CHAR_WORKFEAR, 2 ); + BATTLE_BadStatusString( bid, BATTLE_ST_FEAR ); + work = CHAR_getWorkInt( charaindex, CHAR_WORKQUICK )+20; + dex = work>>1;//敏降50% + sprintf( szCommand, "BD|r%X|0|6|%X|", bid, (-1) * dex ); + BATTLESTR_ADD( szCommand ); +#endif + // 中麻痹 + /*if( rand_num <= 20 ){ + CHAR_setWorkInt( charaidx, CHAR_WORKPARALYSIS, 3 ); + BATTLE_BadStatusString( bid, BATTLE_ST_PARALYSIS ); + }else{ + rand_num = RAND( 1, 100 ); + if( rand_num <= 10 ){ + CHAR_setWorkInt( charaidx, CHAR_WORKCONFUSION, 3 ); + BATTLE_BadStatusString( bid, BATTLE_ST_CONFUSION ); + } + }*/ + + break; + } + } + + + return attvalue; +} + + +#endif + + +#ifdef _PETSKILL_FIREKILL +/* + . ..·. ..··. .○ + *. ..· ★.* ·. . + ★ . ·● ● ·. .★. + ..· / \_/ \_ ·. + ??√√ √√??? + 中秋节快乐 +*/ +void BATTLE_MultiAttMagic_Fire( int battleindex, int attackNo, int defNo, + int FieldAttr , int Power) + +{ + int list[SIDE_OFFSET * 2 + 1]; + int listidx=0,i,j,z,def_be_hit[10],att_magic_lv[4]; + int def_magic_resist[DEF_MAGIC_NUM]; + int attvalue , charahp , pethp , charaidx , petidx , charahurt,pet_att_lv = 1,pet_def_lv = 1,charahurt_temp; + char szcommand[256]; + int AttIsPlayer=0,DefIsPlayer=0; + int getexp = 0; + +#ifndef _FIX_MAGICDAMAGE + int att_magic_exp_add,att_magic_exp_sub,def_magic_exp_add,def_magic_exp_sub; + int lv_up_exp,DefFieldAttr = 0; + float temp = 0.0f; +// int attattr[5], defattr[5]; + char msgbuf[64]; + char kind[4][3] = {"地","水","火","风"}; +#else + BOOL TrueMagic=FALSE; +#endif + int f_num=0; + int MagicLv=4; + + memset(def_be_hit,-1,sizeof(def_be_hit)); + + if(defNo < 5) + f_num = 0; + else if(defNo >=5 && defNo < 10) + f_num = 5; + else if(defNo >=10 && defNo < 15) + f_num = 10; + else + f_num = 15; + + // 取出战场上存活的人 + for( i=f_num; i att_magic_lv[ FieldAttr] ) TrueMagic = FALSE; + else TrueMagic = TRUE; +#endif + } + pet_att_lv = CHAR_getInt(BATTLE_No2Index(battleindex,attackNo), CHAR_LV); + + z = 0; + for(i=0;i 0 ){ + float def = (float)(CHAR_getWorkInt( charaidx, CHAR_OTHERSTATUSNUMS )); + def = def/100; + for(j=0;j 0) { + CHAR_setWorkInt(def_be_hit[i],CHAR_WORKSLEEP,0); + z = BATTLE_Index2No(battleindex,def_be_hit[i]); + sprintf(szcommand,"BM|%X|%X|",z,0); + BATTLESTR_ADD(szcommand); + } + } +} +#endif + +#ifdef _PROFESSION_ADDSKILL +unsigned int GET_PROFESSION_magic_array(int idx) +{ + return PROFESSION_magic[idx].uiSpriteNum; +} +#endif + + + + diff --git a/gmsv/battle/makefile b/gmsv/battle/makefile new file mode 100644 index 0000000..5bc7f32 --- /dev/null +++ b/gmsv/battle/makefile @@ -0,0 +1,376 @@ + +INCFLAGS=-I.. -I../include + +CFLAGS=-w -O3 $(INCFLAGS) + +PROG=libbattle.a + +SRC=battle.c battle_event.c battle_command.c battle_ai.c battle_magic.c pet_skill.c battle_item.c profession_skill.c +OBJ=$(SRC:.c=.o) + +ifeq (0,$(MAKELEVEL)) +CC=gcc +RM=rm -f +AR=ar cr +MV=mv +RANLIB=ranlib +SED=sed +SHELL=/bin/sh +endif + +all: $(PROG) + +$(PROG): $(OBJ) + $(RM) $(PROG) + $(AR) $(PROG) $(OBJ) + $(RANLIB) $(PROG) + +depend: + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(CC) $(INCFLAGS) -M $(SRC) >> makefile + +clean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + +distclean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(RM) makefile.bak + +# DO NOT DELETE THIS LINE +battle.o: battle.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/stdlib.h /usr/include/sys/types.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/time.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/buf.h ../include/common.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h ../include/object.h \ + ../include/char.h ../include/char_base.h ../include/skill.h \ + ../include/util.h /usr/include/sys/time.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/netinet/in.h \ + /usr/include/stdint.h /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/battle.h ../include/battle_event.h \ + ../include/battle_command.h ../include/battle_ai.h \ + ../include/configfile.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/encount.h ../include/enemy.h \ + ../include/handletime.h ../include/readmap.h ../include/pet_skill.h \ + ../include/npcutil.h ../include/magic.h ../include/npc_npcenemy.h \ + ../include/log.h ../include/pet_skillinfo.h ../include/anim_tbl.h \ + ../include/battle_magic.h ../include/profession_skill.h +battle_event.o: battle_event.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/math.h /usr/include/bits/huge_val.h \ + /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/char_event.h ../include/battle.h ../include/battle_event.h \ + ../include/configfile.h ../include/pet.h ../include/log.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/anim_tbl.h ../include/battle_magic.h \ + ../include/enemy.h ../include/pet_skill.h ../include/item_event.h \ + ../include/profession_skill.h ../include/magic_base.h +battle_command.o: battle_command.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/stdlib.h /usr/include/sys/types.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/time.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/char.h ../include/common.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/battle.h ../include/pet_skill.h ../include/battle_event.h \ + ../include/battle_command.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/magic.h ../include/magic_base.h \ + ../include/handletime.h ../include/profession_skill.h +battle_ai.o: battle_ai.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + ../include/common.h /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/battle.h ../include/npcutil.h ../include/pet_skill.h +battle_magic.o: battle_magic.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/battle.h ../include/battle_event.h ../include/magic_base.h \ + ../include/battle_magic.h ../include/item_event.h ../include/anim_tbl.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/profession_skill.h +pet_skill.o: pet_skill.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/string.h ../include/common.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h ../include/buf.h ../include/configfile.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/char.h ../include/pet_skill.h ../include/battle.h \ + ../include/battle_event.h ../include/battle_magic.h \ + ../include/item_gen.h ../include/char_talk.h +battle_item.o: battle_item.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/battle.h ../include/battle_event.h ../include/battle_item.h \ + ../include/battle_magic.h ../include/item_event.h ../include/log.h \ + ../include/anim_tbl.h ../include/npcutil.h ../include/magic_base.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h +profession_skill.o: profession_skill.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/string.h /usr/include/time.h /usr/include/bits/time.h \ + ../include/buf.h ../include/common.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h ../include/profession_skill.h \ + ../include/util.h /usr/include/sys/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/skill.h ../include/char_base.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/battle.h ../include/magic_base.h \ + ../include/configfile.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h diff --git a/gmsv/battle/makefile.bak b/gmsv/battle/makefile.bak new file mode 100644 index 0000000..1c63209 --- /dev/null +++ b/gmsv/battle/makefile.bak @@ -0,0 +1,281 @@ + +INCFLAGS=-I.. -I../include + +CFLAGS=-w -O3 $(INCFLAGS) + +PROG=libbattle.a + +SRC=battle.c battle_event.c battle_command.c battle_ai.c battle_magic.c pet_skill.c battle_item.c profession_skill.c +OBJ=$(SRC:.c=.o) + +ifeq (0,$(MAKELEVEL)) +CC=gcc +RM=rm -f +AR=ar cr +MV=mv +RANLIB=ranlib +SED=sed +SHELL=/bin/sh +endif + +all: $(PROG) + +$(PROG): $(OBJ) + $(RM) $(PROG) + $(AR) $(PROG) $(OBJ) + $(RANLIB) $(PROG) + +depend: + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(CC) $(INCFLAGS) -M $(SRC) >> makefile + +clean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + +distclean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(RM) makefile.bak + +# DO NOT DELETE THIS LINE +battle.o: battle.c /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/stdlib.h /usr/include/sys/types.h \ + /usr/include/bits/types.h /usr/include/time.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/sys/sysmacros.h /usr/include/alloca.h ../include/buf.h \ + ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/bits/stdio_lim.h ../include/object.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/bits/time.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/battle.h ../include/battle_event.h \ + ../include/battle_command.h ../include/battle_ai.h \ + ../include/configfile.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/encount.h ../include/enemy.h ../include/handletime.h \ + ../include/readmap.h ../include/pet_skill.h ../include/npcutil.h \ + ../include/magic.h ../include/npc_npcenemy.h ../include/log.h \ + ../include/pet_skillinfo.h +battle_event.o: battle_event.c /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/math.h /usr/include/bits/huge_val.h \ + /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/float.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/char_event.h ../include/battle.h ../include/battle_event.h \ + ../include/configfile.h ../include/pet.h ../include/log.h +battle_command.o: battle_command.c /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/stdlib.h /usr/include/sys/types.h \ + /usr/include/bits/types.h /usr/include/time.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/sys/sysmacros.h /usr/include/alloca.h ../include/char.h \ + ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/bits/stdio_lim.h ../include/char_base.h \ + ../include/skill.h ../include/util.h /usr/include/sys/time.h \ + /usr/include/bits/time.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/battle.h ../include/pet_skill.h ../include/battle_event.h \ + ../include/battle_command.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h ../include/magic.h \ + ../include/magic_base.h +battle_ai.o: battle_ai.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/common.h ../include/char.h ../include/char_base.h \ + ../include/skill.h ../include/util.h /usr/include/sys/time.h \ + /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/battle.h ../include/npcutil.h ../include/pet_skill.h +battle_magic.o: battle_magic.c /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/battle.h ../include/battle_event.h ../include/magic_base.h \ + ../include/battle_magic.h ../include/item_event.h \ + ../include/anim_tbl.h +pet_skill.o: pet_skill.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + /usr/include/string.h ../include/common.h ../include/buf.h \ + ../include/configfile.h ../include/char_base.h ../include/skill.h \ + ../include/util.h /usr/include/sys/time.h /usr/include/time.h \ + /usr/include/bits/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/char.h ../include/pet_skill.h ../include/battle.h \ + ../include/battle_event.h ../include/item_gen.h +battle_item.o: battle_item.c /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/battle.h ../include/battle_event.h \ + ../include/battle_item.h ../include/battle_magic.h \ + ../include/item_event.h ../include/log.h ../include/anim_tbl.h +profession_skill.o: profession_skill.c /usr/include/stdio.h \ + /usr/include/string.h ../include/buf.h ../include/profession_skill.h \ + ../include/char_base.h ../include/battle.h ../include/magic_base.h \ + ../include/configfile.h + diff --git a/gmsv/battle/pet_skill.c b/gmsv/battle/pet_skill.c new file mode 100644 index 0000000..978f23a --- /dev/null +++ b/gmsv/battle/pet_skill.c @@ -0,0 +1,2462 @@ +#include "version.h" +#include +#include +#include "common.h" +#include "buf.h" +#include "configfile.h" +#include "char_base.h" +#include "char_data.h" +#include "pet_skill.h" +#include "battle.h" +#include "battle_event.h" +#include "battle_magic.h" +#include "item.h" +#include "item_gen.h" +#include "char_talk.h" + +/*======================================================================== + * 矢永玄及 卞勾中化及末□旦 宠物的各式技能 + *========================================================================*/ + + +static Petskill *PETSKILL_petskill; +static int PETSKILL_petskillnum; + +typedef struct tagPetskill_PetskillFunctionTable +{ + char *functionname; /* 涩烂白央奶伙卞踏仁楮醒及 蟆 */ + PETSKILL_CALLFUNC func; /* 端卞裟太请今木月楮醒 */ + int hash; /* hash */ + int status; /* 仇及戊穴件玉毛矢永玄互隙烂仄凶执 */ +}PETSKILL_PetskillFunctionTable; + +/* 毛 支仄凶日仇仇卞瓒 允月仪 */ +static PETSKILL_PetskillFunctionTable PETSKILL_functbl[] = { + { "PETSKILL_None", PETSKILL_None, 0 }, + { "PETSKILL_NormalAttack", PETSKILL_NormalAttack, 0 }, + { "PETSKILL_NormalGuard", PETSKILL_NormalGuard, 0 }, + { "PETSKILL_ContinuationAttack",PETSKILL_ContinuationAttack, 0 }, + { "PETSKILL_ChargeAttack", PETSKILL_ChargeAttack, 0 }, + { "PETSKILL_Guardian", PETSKILL_Guardian, 0 }, + { "PETSKILL_PowerBalance", PETSKILL_PowerBalance, 0 }, + { "PETSKILL_Mighty", PETSKILL_Mighty, 0 }, + { "PETSKILL_StatusChange", PETSKILL_StatusChange, 0 }, + { "PETSKILL_EarthRound", PETSKILL_EarthRound, 0 }, + { "PETSKILL_GuardBreak", PETSKILL_GuardBreak, 0 }, +#ifdef _SKILL_GUARDBREAK2//破除防御2 vincent add 2002/05/20 + { "PETSKILL_GuardBreak2", PETSKILL_GuardBreak2, 0 }, +#endif + { "PETSKILL_Abduct", PETSKILL_Abduct, 0 }, + { "PETSKILL_Steal", PETSKILL_Steal, 0 }, + { "PETSKILL_Merge", PETSKILL_Merge, 0 }, +#ifdef _ALCHEMIST + { "PETSKILL_Alchemist", PETSKILL_Merge, 0 }, +#endif + { "PETSKILL_NoGuard", PETSKILL_NoGuard, 0 }, +#ifdef _ITEM_INSLAY + { "PETSKILL_Inslay", PETSKILL_Inslay, 0 }, +#endif +#ifdef _PETSKILL_FIXITEM + { "PETSKILL_Fixitem", PETSKILL_Fixitem, 0 }, +#endif + +#ifdef _MAGIC_SUPERWALL + { "PETSKILL_MagicStatusChange" , PETSKILL_MagicStatusChange, 0}, +#endif + +// Terry add 2001/11/05 +#ifdef __ATTACK_MAGIC + { "PETSKILL_AttackMagic", PETSKILL_AttackMagic,0}, +#endif + +#ifdef _PSKILL_FALLGROUND + { "PETSKILL_FallGround", PETSKILL_FallGround, 0}, +#endif +#ifdef _PETSKILL_EXPLODE + { "PETSKILL_Explode", PETSKILL_Explode, 0}, +#endif +#ifdef _BATTLESTEAL_FIX + { "PETSKILL_StealMoney", PETSKILL_StealMoney, 0 }, +#endif +#ifdef _PRO_BATTLEENEMYSKILL + { "ENEMYSKILL_ReLife", ENEMYSKILL_ReLife, 0}, + { "ENEMYSKILL_ReHP", ENEMYSKILL_ReHP, 0}, + { "ENEMYSKILL_EnemyHelp", ENEMYSKILL_EnemyHelp, 0}, +#endif +#ifdef _SKILL_DAMAGETOHP + { "PETSKILL_DamageToHp", PETSKILL_DamageToHp, 0}, +#endif + +#ifdef _PETSKILL_TIMID + { "PETSKILL_BattleTimid", PETSKILL_BattleTimid, 0}, +#endif +#ifdef _PETSKILL_2TIMID + { "PETSKILL_2BattleTimid", PETSKILL_2BattleTimid, 0}, +#endif +#ifdef _PETSKILL_ANTINTER + { "PETSKILL_AntInter", PETSKILL_AntInter, 0}, +#endif + +#ifdef _PETSKILL_PROPERTY + { "PETSKILL_BattleProperty", PETSKILL_BattleProperty, 0}, +#endif + +#ifdef _PETSKILL_TEAR + { "PETSKILL_BattleTearDamage", PETSKILL_BattleTearDamage, 0}, +#endif + +#ifdef _BATTLE_LIGHTTAKE + { "PETSKILL_Lighttakeed", PETSKILL_Lighttakeed, 0}, +#endif + +#ifdef _BATTLE_ATTCRAZED + { "PETSKILL_AttackCrazed", PETSKILL_AttackCrazed, 0}, +#endif + +#ifdef _SHOOTCHESTNUT // Syu ADD 宠技:丢栗子 + { "PETSKILL_AttackShoot", PETSKILL_AttackShoot, 0}, +#endif + +#ifdef _Skill_MPDAMAGE + { "PETSKILL_MpDamage", PETSKILL_MpDamage, 0}, +#endif + +#ifdef _SKILL_TOOTH + { "PETSKILL_ToothCrushe", PETSKILL_ToothCrushe, 0}, +#endif + +#ifdef _PETSKILL_SETDUCK + { "PETSKILL_SetDuck", PETSKILL_SetDuck, 0}, +#endif +#ifdef _MAGICPET_SKILL + { "PETSKILL_SetMagicPet", PETSKILL_SetMagicPet, 0}, +#endif +#ifdef _PSKILL_MODIFY + { "PETSKILL_Modifyattack", PETSKILL_Modifyattack, 0}, +#endif + +#ifdef _PSKILL_MDFYATTACK + { "PETSKILL_Mdfyattack", PETSKILL_Mdfyattack, 0}, +#endif +#ifdef _VARY_WOLF + { "PETSKILL_Vary", PETSKILL_Vary, 0}, +#endif +#ifdef _SKILL_WILDVIOLENT_ATT + { "PETSKILL_WildViolentAttack", PETSKILL_WildViolentAttack, 0},//vincent add 2002/05/16 +#endif + +#ifdef _SKILL_SPEEDY_ATT + { "PETSKILL_SpeedyAttack", PETSKILL_SpeedyAttack, 0},//vincent add 2002/05/20 +#endif +#ifdef _SKILL_SACRIFICE + { "PETSKILL_Sacrifice", PETSKILL_Sacrifice, 0},//vincent add 2002/05/30 +#endif +#ifdef _SKILL_REFRESH + { "PETSKILL_Refresh", PETSKILL_Refresh, 0},//vincent add 2002/08/08 +#endif +#ifdef _SKILL_WEAKEN //vincent宠技:虚弱 + { "PETSKILL_Weaken", PETSKILL_Weaken, 0},//vincent add 2002/07/11 +#endif +#ifdef _SKILL_DEEPPOISON //vincent宠技:剧毒 + { "PETSKILL_Deeppoison", PETSKILL_Deeppoison, 0},//vincent add 2002/07/16 +#endif +#ifdef _SKILL_BARRIER //vincent宠技:魔障 + { "PETSKILL_Barrier", PETSKILL_Barrier, 0},//vincent add 2002/07/16 +#endif +#ifdef _SKILL_NOCAST //vincent宠技:沉默 + { "PETSKILL_Nocast", PETSKILL_Nocast, 0},//vincent add 2002/07/16 +#endif +#ifdef _SKILL_ROAR //vincent宠技:大吼 + { "PETSKILL_Roar", PETSKILL_Roar, 0},//vincent add 2002/07/11 +#endif + +#ifdef _PET_SKILL_SARS // WON ADD 毒煞蔓延 + { "PETSKILL_Sars", PETSKILL_Sars, 0}, +#endif + +#ifdef _SONIC_ATTACK // WON ADD 音波攻击 + { "PETSKILL_Sonic", PETSKILL_Sonic, 0}, +#endif +#ifdef _PETSKILL_REGRET + { "PETSKILL_Regret", PETSKILL_Regret, 0}, +#endif + +#ifdef _PETSKILL_GYRATE + { "PETSKILL_Gyrate", PETSKILL_Gyrate, 0}, +#endif + +#ifdef _PETSKILL_ACUPUNCTURE //针刺外皮 + { "PETSKILL_Acupuncture", PETSKILL_Acupuncture, 0}, +#endif + +#ifdef _PETSKILL_RETRACE + { "PETSKILL_Retrace", PETSKILL_Retrace, 0}, +#endif + +#ifdef _PETSKILL_HECTOR + { "PETSKILL_Hector", PETSKILL_Hector, 0}, +#endif + +#ifdef _PETSKILL_FIREKILL + { "PETSKILL_Firekill", PETSKILL_Firekill, 0}, +#endif + +#ifdef _PETSKILL_DAMAGETOHP + { "PETSKILL_DamageToHp2", PETSKILL_DamageToHp2, 0}, +#endif + +#ifdef _PETSKILL_BECOMEFOX + { "PETSKILL_BecomeFox", PETSKILL_BecomeFox, 0}, +#endif + +#ifdef _PETSKILL_BECOMEPIG + { "PETSKILL_BecomePig", PETSKILL_BecomePig, 0}, +#endif + +#ifdef _PETSKILL_SHOWMERCY + { "PETSKILL_ShowMercy", PETSKILL_ShowMercy, 0}, +#endif + +#ifdef _PETSKILL_COMBINED + { "PETSKILL_Combined", PETSKILL_Combined, 0}, +#endif +#ifdef _PETSKILL_LER + { "PETSKILL_BatFly", PETSKILL_BatFly, 0}, + { "PETSKILL_DivideAttack", PETSKILL_DivideAttack, 0}, +#endif +#ifdef _PETSKILL_BATTLE_MODEL + { "PETSKILL_BattleModel", PETSKILL_BattleModel, 0}, +#endif + +}; + +/*----------------------------------------------------------------------*/ + + +/* 湘 民尼永弁]失弁本旦楮溢 */ +/*----------------------------------------------------------------------*/ +INLINE BOOL PETSKILL_CHECKINDEX( int index ) +{ + if( PETSKILL_petskillnum<=index || index<0 )return FALSE; + return TRUE; +} +/*----------------------------------------------------------------------*/ +static INLINE BOOL PETSKILL_CHECKINTDATAINDEX( int index) +{ + if( PETSKILL_DATAINTNUM <= index || index < 0 ) return FALSE; + return TRUE; +} +/*----------------------------------------------------------------------*/ +static INLINE BOOL PETSKILL_CHECKCHARDATAINDEX( int index) +{ + if( PETSKILL_DATACHARNUM <= index || index < 0 ) return FALSE; + return TRUE; +} +/*----------------------------------------------------------------------*/ +INLINE int PETSKILL_getInt( int index, PETSKILL_DATAINT element) +{ + return PETSKILL_petskill[index].data[element]; +} +/*----------------------------------------------------------------------*/ +INLINE int PETSKILL_setInt( int index, PETSKILL_DATAINT element, int data) +{ + int buf; + buf = PETSKILL_petskill[index].data[element]; + PETSKILL_petskill[index].data[element]=data; + return buf; +} +/*----------------------------------------------------------------------*/ +INLINE char* PETSKILL_getChar( int index, PETSKILL_DATACHAR element) +{ + if( !PETSKILL_CHECKINDEX( index)) return NULL; + if( !PETSKILL_CHECKCHARDATAINDEX( element)) return NULL; + return PETSKILL_petskill[index].string[element].string; +} + +/*----------------------------------------------------------------------*/ +INLINE BOOL PETSKILL_setChar( int index ,PETSKILL_DATACHAR element, char* new ) +{ + if(!PETSKILL_CHECKINDEX(index))return FALSE; + if(!PETSKILL_CHECKCHARDATAINDEX(element))return FALSE; + strcpysafe( PETSKILL_petskill[index].string[element].string, + sizeof(PETSKILL_petskill[index].string[element].string), + new ); + return TRUE; +} +/*---------------------------------------------------------------------- + * 矢永玄 及醒毛襞月[ + *---------------------------------------------------------------------*/ +int PETSKILL_getPetskillNum( void) +{ + return PETSKILL_petskillnum; +} + +#ifdef _CFREE_petskill +#define PETSKILL_STARTINTNUM 7 //PETSKILL_DATACHARNUM+1 +#else +#define PETSKILL_STARTINTNUM 5 +#endif + +/*---------------------------------------------------------------------- + * 矢永玄 及涩烂白央奶伙毛 戈//初始宠技 + *---------------------------------------------------------------------*/ +BOOL PETSKILL_initPetskill( char *filename) +{ + FILE* f; + char line[256]; + int linenum=0; + int petskill_readlen=0; + int i,j; + int max_skillid =0; + + f = fopen(filename,"r"); + if( f == NULL ){ + print( "file open error\n"); + return FALSE; + } + + PETSKILL_petskillnum=0; + + /* 引内 躲卅垫互窒垫丐月井升丹井譬屯月 *///读曲宠技总数 + while( fgets( line, sizeof( line ), f ) ){ + char token[256]; + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + PETSKILL_petskillnum++; +#ifdef _PETSKILL_OPTIMUM // Robin 取出最大宠技ID + if( getStringFromIndexWithDelim( line, ",", PETSKILL_STARTINTNUM, token, sizeof(token)) == FALSE ) + continue; + //print("\n 宠技ID:%d %s ", atoi( token), line); + max_skillid = max( atoi( token), max_skillid); +#endif + } + + if( fseek( f, 0, SEEK_SET ) == -1 ){ + fprint( "寻找失败\n" ); + fclose(f); + return FALSE; + } + +#ifdef _PETSKILL_OPTIMUM // 宠技Table数为 最大技能ID +1 + PETSKILL_petskillnum = max_skillid +1; +// print("\n 最大宠技ID = %d\n", max_skillid); +#endif + + PETSKILL_petskill = allocateMemory( sizeof(struct tagPetskill) + * PETSKILL_petskillnum ); + if( PETSKILL_petskill == NULL ){ + fprint( "无法分配内存 %d\n" , + sizeof(struct tagPetskill)*PETSKILL_petskillnum); + fclose( f ); + return FALSE; + } + + /* 赓渝祭 */ + for( i = 0; i < PETSKILL_petskillnum; i ++ ) { + for( j = 0; j < PETSKILL_DATAINTNUM; j ++ ) { + PETSKILL_setInt( i,j,-1); + } + for( j = 0; j < PETSKILL_DATACHARNUM; j ++ ) { + PETSKILL_setChar( i,j,""); + } + } + + /* 引凶 心 允 */ + linenum = 0; + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + + chomp( line ); + + /* 垫毛帮溥允月 */ + /* 引内 tab 毛 " " 卞 五晶尹月 */ + replaceString( line, '\t' , ' ' ); + /* 燮 及旦矢□旦毛潸月[*/ +{ + char buf[256]; + for( i = 0; i < strlen( line); i ++) { + if( line[i] != ' ' ) { + break; + } + strcpy( buf, &line[i]); + } + if( i != 0 ) { + strcpy( line, buf); + } +} +{ + char token[256]; + int ret; + +#ifdef _PETSKILL_OPTIMUM // 读取本行宠技的ID, 直接以宠技ID当Table index + ret = getStringFromIndexWithDelim( line, ",", PETSKILL_STARTINTNUM, token, sizeof(token)); + if( ret==FALSE ){ + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + break; + } + petskill_readlen = atoi( token); +#endif + + for( i = 0; i < PETSKILL_DATACHARNUM; i ++ ) { + /* 侬 迕玄□弁件毛苇月 */ + ret = getStringFromIndexWithDelim( line,",", i + 1, token,sizeof(token)); + if( ret==FALSE ){ + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + break; + } + PETSKILL_setChar( petskill_readlen, i, token); + } + + /* 4勾 动嫦反醒袄犯□正 */ + for( i = PETSKILL_STARTINTNUM; i < PETSKILL_DATAINTNUM+PETSKILL_STARTINTNUM; i ++ ) { + ret = getStringFromIndexWithDelim( line,",",i,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + break; + } + if( strlen( token) != 0 ) { + PETSKILL_setInt( petskill_readlen, i - PETSKILL_STARTINTNUM, atoi( token)); + } + } + if( i < PETSKILL_DATAINTNUM+PETSKILL_STARTINTNUM ) continue; + +#ifdef _CFREE_petskill + if(line[0]=='E') PETSKILL_setInt( petskill_readlen, PETSKILL_ILLEGAL, 1); +#else + // Robin 2001/02/26 +1 set_illegal_Skill + if(line[0]=='T') PETSKILL_setInt( petskill_readlen, PETSKILL_ILLEGAL, 1); +#endif + //print("Id:%d illegal:%d\n",PETSKILL_getInt(petskill_readlen,PETSKILL_ID),PETSKILL_getInt(petskill_readlen,PETSKILL_ILLEGAL)); + + petskill_readlen ++; +} + + } + fclose(f); + + PETSKILL_petskillnum = petskill_readlen; + + + print( "有效宠物技能数是 %d...", PETSKILL_petskillnum ); + + /* hash 及瓒 */ + for( i = 0; i < arraysizeof( PETSKILL_functbl); i ++ ) { + PETSKILL_functbl[i].hash = hashpjw( PETSKILL_functbl[i].functionname); + } +/* +#ifdef _CFREE_petskill + for( i=0; i = 0 && petskillid < PETSKILL_petskillnum ) + return PETSKILL_petskill[petskillid].data[PETSKILL_ID]; +#else + int i; + for( i = 0; i < PETSKILL_petskillnum; i ++ ) { + if( PETSKILL_petskill[i].data[PETSKILL_ID] == petskillid ) { + return i; + } + } +#endif + return -1; +} +/*------------------------------------------------------------ + * 矢永玄 及楮醒 井日禾奶件正□毛忒允 + * 娄醒 + * name char* 热诸及 蟆 + * 忒曰袄 + * 楮醒尺及禾奶件正[卅中桦宁卞反NULL + ------------------------------------------------------------*/ +PETSKILL_CALLFUNC PETSKILL_getPetskillFuncPointer(char* name ) +{ + int i; + int hash = hashpjw( name ); + for( i = 0 ; i< arraysizeof( PETSKILL_functbl) ; i++ ) { + if( PETSKILL_functbl[i].hash == hash ) { + if( strcmp( PETSKILL_functbl[i].functionname, name ) == 0 ) { + return PETSKILL_functbl[i].func; + } + } + } + return NULL; +} + +int PETSKILL_Use( + int charaindex, + int havepetskill, + int toindex, + char *data + //BOOL isCLI // Robin 2001/02/26 if owner is player +) +{ + int array, petskillid; + int ret,i; + PETSKILL_CALLFUNC func; + char combined[32], *pszOption; + + petskillid = CHAR_getPetSkill( charaindex, havepetskill); +#ifdef _FIXWOLF // Syu ADD 修正狼人变身Bug + if( petskillid == 600 ){ + if ( CHAR_getInt ( charaindex , CHAR_BASEIMAGENUMBER) == 101428 ) + petskillid = -1; + } +#endif + + array = PETSKILL_getPetskillArray( petskillid); + if( array == -1 ) return FALSE; + + if(PETSKILL_getInt(array, PETSKILL_ILLEGAL)){ + if( (CHAR_getInt(charaindex, CHAR_WHICHTYPE)==CHAR_TYPEPET) ){ + print(" CHAR_TYPEPET:%d ", charaindex); + return FALSE; + } + } +#ifdef _PETSKILL_CHECKTYPE +#define _SKILLTYPE_NONE 0x01 +#define _SKILLTYPE_BATTLE 0x02 + if( (CHAR_getInt(charaindex, CHAR_WHICHTYPE)==CHAR_TYPEPET) && + (PETSKILL_getInt( array, PETSKILL_USETYPE) & _SKILLTYPE_BATTLE) > 0){ + int masterindex = CHAR_getWorkInt( charaindex, CHAR_WORKPLAYERINDEX); + if( !CHAR_CHECKINDEX( masterindex) ) return FALSE; + if( CHAR_getWorkInt( masterindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE ){ + return FALSE; + } + } +#endif + func = PETSKILL_getPetskillFuncPointer( PETSKILL_getChar( array, PETSKILL_FUNCNAME) ); + if( func ) { + ret = func( charaindex, toindex, array, data ); + }else { + ret = FALSE; + } + return ret; +} + + +int _PETSKILL_GetArray( char *file, int line, int charaindex, int havepetskill ) +{ + int petskillid,array; + + petskillid = CHAR_getPetSkill( charaindex, havepetskill); + if( petskillid == -1 ) { + return -1; + } + + array = PETSKILL_getPetskillArray( petskillid); + + return array; +} + + +//---------------------------------------------------------------------- +int PETSKILL_ContinuationAttack( + int charaindex, + int toindex, + int array, + char *data + +) +{ + char *pszOption; + int N = 1; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_RENZOKU ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + if( sscanf( pszOption, "%d", &N ) == 1 ){ + if( N < 1 || N > 10 )N = 1; + }else{ + N = 1; + } + + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, N ); + + return TRUE; +} + +int PETSKILL_ChargeAttack( + int charaindex, + int toindex, + int array, + char *data +) +{ + char *pszOption, *pszP; + int N = 1, Per = 0; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_CHARGE ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + if( sscanf( pszOption, "%d", &N ) == 1 ){ + if( N < 1 || N > 10 )N = 1; + }else{ + N = 1; + } + if( (pszP = strstr( pszOption, "攻%" ) ) != NULL ){ + sscanf( pszP+3, "%d", &Per ); + } + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, N ); + CHAR_SETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3, Per ); + return TRUE; +} + +int PETSKILL_Guardian( + int charaindex, + int toNo, + int array, + char *data +) +{ + char *pszOption, *pszP; + int + battleindex, side, pos, ownerpos, + strdef, flg; + float fPer = 0.01; + + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + + if( (pszP = strstr( pszOption, "攻%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR)+strdef)); + } + + if( (pszP = strstr( pszOption, "防%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKDEFENCEPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH)+strdef)); + } + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_GUARDIAN_ATTACK ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + flg = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEFLG ); + flg |= CHAR_BATTLEFLG_GUARDIAN; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEFLG, flg ); + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + + pos = BATTLE_Index2No( battleindex, charaindex ); + + if( (pszP = strstr( pszOption, "COM:" ) ) != NULL + && strstr( pszP+4, "防御" ) != NULL + ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_GUARD ); + + side = ( toNo >= SIDE_OFFSET )?( 1 ):( 0 ); + ownerpos = toNo - side * SIDE_OFFSET; + + if( 0 <= ownerpos && ownerpos < SIDE_OFFSET ){ + BattleArray[battleindex].Side[side].Entry[ownerpos].guardian = pos; + } + + }else{ + side = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLESIDE ); + ownerpos = pos - 5; + ownerpos -= side * SIDE_OFFSET; + + if( ownerpos < 0 || ownerpos > 19 ){ + }else{ + BattleArray[battleindex].Side[side].Entry[ownerpos].guardian = pos; + } + } + + return TRUE; +} + +int PETSKILL_Mighty( + int charaindex, + int toindex, + int array, + char *data +) +{ + char *pszOption, *pszP; + int iBai = 0, iDuck = 0; + float fBai = 2.00; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_MIGHTY ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + if( (pszP = strstr( pszOption, "倍" ) ) != NULL ){ + sscanf( pszP+2, "%f", &fBai ); + iBai = (int)(fBai * 100); + } + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, iBai ); + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + if( ( pszP = strstr( pszOption, "避" ) ) != NULL){ + sscanf( pszP+2, "%d", &iDuck ); + } + CHAR_SETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3, iDuck ); + return TRUE; +} + + + +int PETSKILL_PowerBalance( + int charaindex, + int toindex, + int array, + char *data +) +{ + char *pszOption, *pszP; + float fPer = 0.01; + int strdef; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_POWERBALANCE); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + + if( pszOption == NULL ) { + print("\n pszOption == NULL "); + return FALSE; + } + if( (pszP = strstr( pszOption, "攻%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR)+strdef)); + } + + if( (pszP = strstr( pszOption, "防%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKDEFENCEPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH)+strdef)); + } + + return TRUE; +} + +//---------------------------------------------------------------------- +int PETSKILL_StatusChange( + int charaindex, + int toindex, + int array, + char *data + +) +{ + char *pszOption, *pszP; + float fPer = 0.01; + int strdef; + int status = -1, i = 0, turn = 3; + char szTurn[] = "turn"; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_STATUSCHANGE ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + pszP = pszOption; + + for( ;status == -1 && pszP[0] != 0; pszP++ ){ + for( i = 1; i < BATTLE_ST_END; i ++ ){ + if( strncmp( pszP, aszStatus[i], 2 ) == 0 ){ + status = i; + pszP +=2; + break; + } + } + } + + if( ( pszP = strstr( pszP, szTurn ) ) != NULL){ + pszP += sizeof( szTurn ); + sscanf( pszP, "%d", &turn ); + } + + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, i ); + CHAR_SETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3, turn ); + + if( (pszP = strstr( pszOption, "攻%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER, + (CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR)+strdef) ); + } + + if( (pszP = strstr( pszOption, "防%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKDEFENCEPOWER, + (CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH)+strdef)); + } + + + return TRUE; + +} + +#ifdef _VARY_WOLF + +int PETSKILL_Vary( int cindex, int tindex, int id, char* data) +{ + char *pszOption, *pszP; + float fPer = 0.01; + int a_dep; + int d_dep; + int i; + int petid[4] = {981,982,983,984}; + + for( i=0; i<4; i++) { + if( CHAR_getInt( cindex, CHAR_PETID) == petid[i] ) break; + } + if( i>= 4 ) return FALSE; + + CHAR_setWorkInt( cindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_VARY); + CHAR_setWorkInt( cindex, CHAR_WORKBATTLECOM2, tindex ); + CHAR_setWorkInt( cindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + pszOption = PETSKILL_getChar( id, PETSKILL_OPTION ); + + + if(pszOption==NULL){ + print("\n pszOption==NULL"); + return FALSE; + } + if( (pszP = strstr( pszOption, "攻%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + CHAR_setWorkInt( cindex, CHAR_SKILLSTRPOWER, fPer); + fPer = fPer / 100; + a_dep = CHAR_getWorkInt( cindex, CHAR_WORKFIXSTR); + a_dep = (int)(a_dep * fPer); + CHAR_setWorkInt( cindex, CHAR_WORKATTACKPOWER, CHAR_getWorkInt( cindex, CHAR_WORKFIXSTR) + a_dep); + + } + if( (pszP = strstr( pszOption, "敏%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + CHAR_setWorkInt( cindex, CHAR_SKILLDEXPOWER, fPer); + fPer = fPer / 100; + d_dep = CHAR_getWorkInt( cindex, CHAR_WORKFIXDEX); + d_dep = (int)(d_dep * fPer); + CHAR_setWorkInt( cindex, CHAR_WORKQUICK, CHAR_getWorkInt( cindex, CHAR_WORKFIXDEX) + d_dep); + + } + CHAR_setInt( cindex, CHAR_BASEIMAGENUMBER, 101428); + CHAR_setWorkInt( cindex, CHAR_WORKTURN, 0); + + return TRUE; +} +#endif + +#ifdef _SKILL_WILDVIOLENT_ATT + +int PETSKILL_WildViolentAttack( + int charaindex, + int toindex, + int array, + char *data + +) +{ + char *pszOption, *pszP; + float fPer = 0.01; + int strdef=0; + int iDuck = 0; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_WILDVIOLENTATTACK); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toindex ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + + if( pszOption == NULL ) { + print("\n pszOption == NULL "); + return FALSE; + } + //读取攻值 + if( (pszP = strstr( pszOption, "攻%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + + //设定修正值 + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR)+strdef)); + } + //读取防值 + if( (pszP = strstr( pszOption, "防%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + + //设定修正值 + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKDEFENCEPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH)+strdef)); + } + //读取避值 + if( ( pszP = strstr( pszOption, "避" ) ) != NULL){ + sscanf( pszP+2, "%d", &iDuck ); + } + // 膜恳毛忡绣 + CHAR_SETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3, iDuck ); + + return TRUE; +} +#endif + +#ifdef _SKILL_SACRIFICE +int PETSKILL_Sacrifice( + int charaindex, + int toindex, + int array, + char *data + +) +{ + char buf[256]; + + if(CHAR_getInt(charaindex,CHAR_HP) > CHAR_getWorkInt(charaindex,CHAR_WORKMAXHP)*0.2 ) + { + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_SACRIFICE); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + } + else + { + + sprintf(buf, "%s自身耐久力不足 救援失败!!", CHAR_getChar( charaindex, CHAR_NAME )); + CHAR_talkToCli( CHAR_getWorkInt(charaindex, CHAR_WORKPLAYERINDEX), -1, buf, CHAR_COLORYELLOW); + return FALSE; + } + return TRUE; +} +#endif +#ifdef _SKILL_REFRESH +int PETSKILL_Refresh( + int charaindex, + int toindex, + int array, + char *data + +) +{ + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_REFRESH); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); + return TRUE; +} +#endif +#ifdef _SKILL_WEAKEN //vincent宠技:虚弱 +int PETSKILL_Weaken( + int charaindex, + int toindex, + int array, + char *data + +) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_WEAKEN); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); + return TRUE; +} +#endif +#ifdef _SKILL_DEEPPOISON //vincent宠技:剧毒 +int PETSKILL_Deeppoison( + int charaindex, + int toindex, + int array, + char *data + +) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_DEEPPOISON); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); + return TRUE; +} +#endif + +#ifdef _SKILL_BARRIER //vincent宠技:魔障 +int PETSKILL_Barrier( + int charaindex, + int toindex, + int array, + char *data + +) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_BARRIER); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); + return TRUE; +} +#endif + +#ifdef _SKILL_NOCAST //vincent宠技:沉默 +int PETSKILL_Nocast( + int charaindex, + int toindex, + int array, + char *data + +) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_NOCAST); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); + return TRUE; +} +#endif + +#ifdef _SKILL_ROAR //vincent宠技:大吼 +int PETSKILL_Roar( + int charaindex, + int toindex, + int array, + char *data + +) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_ROAR); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); + return TRUE; +} +#endif + +#ifdef _SKILL_GUARDBREAK2//破除防御2 vincent add 2002/05/20 +int PETSKILL_GuardBreak2( + int charaindex, + int toNo, + int array, + char *data + +) +{ + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_GBREAK2 ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + return TRUE; + +} +#endif + +//******************************************************* +int PETSKILL_NormalAttack( + int charaindex, + int toindex, + int array, + char *data + +) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + return TRUE; + +} + +int PETSKILL_NormalGuard( + int charaindex, + int toindex, + int array, + char *data + +) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_GUARD ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + return TRUE; + +} + + +int PETSKILL_None( + int charaindex, + int toindex, + int array, + char *data +) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + return TRUE; +} + + +int PETSKILL_EarthRound( + int charaindex, + int toNo, + int array, + char *data +) +{ + char *pszOption, *pszP; + float fPer = 0.01; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_EARTHROUND1 ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + + if( (pszP = strstr( pszOption, "攻%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + CHAR_setWorkInt(charaindex,CHAR_WORKBATTLECOM3, (int)fPer ); + } + + + return TRUE; + +} + + +int PETSKILL_GuardBreak( + int charaindex, + int toNo, + int array, + char *data + +) +{ + char *pszOption, *pszP; + float fPer = 0.01; + int strdef; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_GBREAK ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + + if( (pszP = strstr( pszOption, "攻%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR)+strdef)); + } + + + return TRUE; + +} +#ifdef _SKILL_SPEEDY_ATT//疾速攻击 vincent add 2002/05/20 +int PETSKILL_SpeedyAttack( + int charaindex, + int toNo, + int array, + char *data + +) +{ + char *pszOption, *pszP; + float fPer = 0.01; + int strdef=0; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_SPEEDYATTACK ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + + if( pszOption == NULL ) { + print("\n pszOption == NULL "); + return FALSE; + } + + //读取防值 + if( (pszP = strstr( pszOption, "防%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + + //设定修正值 + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKDEFENCEPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH)+strdef)); + } + + return TRUE; + +} +#endif + +int PETSKILL_Abduct( + int charaindex, + int toNo, + int array, + char *data +) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_ABDUCT ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); + + return TRUE; +} + +int PETSKILL_Steal( + int charaindex, + int toNo, + int array, + char *data +) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_STEAL ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + return TRUE; +} + +#ifdef _BATTLESTEAL_FIX +int PETSKILL_StealMoney( int charaindex, int toNo, int array, char *data) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_STEALMONEY ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + return TRUE; +} +#endif + +//******************************************************* +// 檗 -- 失奶 丞宁岳 +// +int PETSKILL_Merge( + int charaindex, + int toNo, + int array, + char *data +) +{ + int ret, ownerindex; + + // Robin 0521 debug + ownerindex = CHAR_getWorkInt( charaindex, CHAR_WORKPLAYERINDEX); + if( CHAR_getWorkInt( ownerindex, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ){ + print(" Merge_ErrB:fd=%d ", ownerindex); + return FALSE; + } + ret = ITEM_mergeItem_merge( CHAR_getWorkInt( charaindex, CHAR_WORKPLAYERINDEX), + CHAR_getInt( charaindex, CHAR_PETID), data, charaindex, 0); + return ret; +} + +#ifdef _ALCHEMIST +int PETSKILL_Alchemist( + int charaindex, + int toNo, + int array, + char *data +) +{ + int ret, ownerindex; + + // Robin 0521 debug + ownerindex = CHAR_getWorkInt( charaindex, CHAR_WORKPLAYERINDEX); + if( CHAR_getWorkInt( ownerindex, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ){ + print(" Merge_Alchemist_ErrB:fd=%d ", ownerindex); + return FALSE; + } + ret = ITEM_mergeItem_merge( CHAR_getWorkInt( charaindex, CHAR_WORKPLAYERINDEX), + CHAR_getInt( charaindex, CHAR_PETID), data, charaindex, 1); + return ret; +} +#endif + +int PETSKILL_NoGuard( + int charaindex, + int toNo, + int array, + char *data + +) +{ + char *pszOption, *pszP; + int Duck = 0, Counter = 0, Critical = 0; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_NOGUARD ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + if( (pszP = strstr( pszOption, "避%" ) ) != NULL ){ + sscanf( pszP+3, "%d", &Duck ); + CHAR_SETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3, Duck ); + } + if( (pszP = strstr( pszOption, "击%" ) ) != NULL ){ + sscanf( pszP+3, "%d", &Counter ); + } + if( (pszP = strstr( pszOption, "心%" ) ) != NULL ){ + sscanf( pszP+3, "%d", &Critical ); + } + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, + (Counter << 8) + Critical ); + + return TRUE; +} + +#ifdef __ATTACK_MAGIC + +int PETSKILL_AttackMagic( + int charaindex, + int toindex, + int array, + char *data +) +{ + char *pszP; + char szMagic[] = "magic"; + char szItem[] = "item"; + int magic = 313,item = 19659; // magic id预设为火魔法等级一,item index预设为19659 + + // 取得宠物技能命令 + pszP = PETSKILL_getChar( array, PETSKILL_OPTION ); + + // 取得施放的魔法的magic id + if((pszP = strstr(pszP,szMagic)) != NULL) + { + pszP += sizeof(szMagic); + sscanf(pszP,"%d",&magic); + } + // 取得有此魔法属性的item index + if((pszP = strstr(pszP,szItem)) != NULL) + { + pszP += sizeof(szItem); + sscanf(pszP,"%d",&item); + } + // 设定宠物技能为魔法 + CHAR_setWorkInt(charaindex,CHAR_WORKBATTLECOM1,BATTLE_COM_S_ATTACK_MAGIC ); + // 攻击目标设定 + CHAR_setWorkInt(charaindex,CHAR_WORKBATTLECOM2,toindex); + // 设定所使用的是那一种魔法 + CHAR_SETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3,magic); + // 设定所使用的魔法的道具 + CHAR_SETWORKINT_HIGH(charaindex,CHAR_WORKBATTLECOM3,item); + // 命令下达完毕 + CHAR_setWorkInt(charaindex,CHAR_WORKBATTLEMODE,BATTLE_CHARMODE_C_OK ); + + return TRUE; +} + +#endif + +#ifdef _PSKILL_FALLGROUND //落马术 +int PETSKILL_FallGround( int charaindex, int toNo, int array, char *data ) +{ + char *pszOption, *pszP; + float fPer = 0.01; + int strdef; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_FALLRIDE ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + if( (pszP = strstr( pszOption, "攻%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR)+strdef)); + } + return TRUE; + +} //BATTLE_COM_S_DAMAGETOHP +#endif +#ifdef _PETSKILL_EXPLODE +int PETSKILL_Explode( int charaindex, int toNo, int array, char *data ) +{ + char *pszOption, *pszP; + float fPer = 0.01; + int strdef; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + if( BattleArray[CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX )].type != BATTLE_TYPE_P_vs_P ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK ); + return TRUE; + } + else + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_EXPLODE ); + + + + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + if( (pszP = strstr( pszOption, "命%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKFIXDEX,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXDEX)+strdef)); + } + if( (pszP = strstr( pszOption, "防%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR)+strdef)); + } + return TRUE; + +} +#endif + +#ifdef _PRO_BATTLEENEMYSKILL +int ENEMYSKILL_ReLife( int enemyindex, int toNo, int array, char *data ) +{ + CHAR_setWorkInt( enemyindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_ENEMYRELIFE ); + CHAR_setWorkInt( enemyindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( enemyindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + return TRUE; +} + +int ENEMYSKILL_ReHP( int enemyindex, int toNo, int array, char *data ) +{ + CHAR_setWorkInt( enemyindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_ENEMYREHP ); + CHAR_setWorkInt( enemyindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( enemyindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + return TRUE; +} + +int ENEMYSKILL_EnemyHelp( int enemyindex, int toNo, int array, char *data ) +{ + CHAR_setWorkInt( enemyindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_ENEMYHELP ); + CHAR_setWorkInt( enemyindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( enemyindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + return TRUE; +} + +#endif + +#ifdef _SKILL_DAMAGETOHP //嗜血技 { "PETSKILL_DamageToHp", PETSKILL_DamageToHp, 0}, +int PETSKILL_DamageToHp( int charaindex, int toNo, int array, char *data ) +{ + char *pszOption; + char buf1[256]; + int strdef; + float def=0.00; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_DAMAGETOHP ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3, array); //记录技能 + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + + if( pszOption == NULL ) return FALSE; + if( getStringFromIndexWithDelim( pszOption, "|", 1, buf1, sizeof( buf1)) == FALSE ) + return FALSE; + + strdef = CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR); + def = (atoi( buf1)/100); + strdef = strdef - (int)(strdef*def); + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, strdef); + + return TRUE; + +} +#endif + +#ifdef _Skill_MPDAMAGE +int PETSKILL_MpDamage( int charaindex, int toNo, int array, char *data ) +{ + char *pszOption; + char buf1[256]; + int strdef; + float def=0.00; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_MPDAMAGE ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3, array); ////记录技能 + + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + if( pszOption == NULL ) return FALSE; + if( getStringFromIndexWithDelim( pszOption, "|", 1, buf1, sizeof( buf1)) == FALSE ) + return FALSE; + + def = (float)(atoi( buf1)/100); + strdef = CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR); + strdef = strdef - (int)( strdef*def); + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, strdef); + + return TRUE; +} +#endif + + +#ifdef _SKILL_TOOTH +int PETSKILL_ToothCrushe( int charaindex, int toNo, int array, char *data ) +{ + //char *pszOption; + //char buf1[256]; + //int strdef; + //float def=0.00; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_TOOTHCRUSHE ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); //记录技能 +/* + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + if( pszOption == NULL ) return FALSE; + if( getStringFromIndexWithDelim( pszOption, "|", 1, buf1, sizeof( buf1)) == FALSE ) + return FALSE; + + def = (float)(atoi( buf1)/100); + strdef = CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR); + strdef = strdef - (int)( strdef*def); + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, strdef); +*/ + return TRUE; +} +#endif +#ifdef _PSKILL_MODIFY +int PETSKILL_Modifyattack( int charaindex, int toNo, int array, char *data ) +{ + //char *pszOption; + //char buf1[256]; + //int strdef; + //float def=0.00; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_MODIFYATT ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); //记录技能 +/* + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + if( pszOption == NULL ) return FALSE; + if( getStringFromIndexWithDelim( pszOption, "|", 1, buf1, sizeof( buf1)) == FALSE ) + return FALSE; + + def = (float)(atoi( buf1)/100); + strdef = CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR); + strdef = strdef - (int)( strdef*def); + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, strdef); +*/ + return TRUE; +} +#endif + +#ifdef _PSKILL_MDFYATTACK +int PETSKILL_Mdfyattack( int charaindex, int toNo, int array, char *data ) +{ + char *pszOption; + char buf1[256]; + char MNodify[][36]={"EA","WA","FI","WI"}; + int nums, i; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_MDFYATTACK); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array);//记录属性 + + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + if( pszOption == NULL ) return FALSE; + if( getStringFromIndexWithDelim( pszOption, "|", 1, buf1, sizeof( buf1)) == FALSE ) + return FALSE; + for( i=0; i<4; i++) { + if( strcmp( buf1, MNodify[i]) ) continue; + break; + } + if( i == 4 ) return FALSE; + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM4, i);//记录属性 + if( getStringFromIndexWithDelim( pszOption, "|", 2, buf1, sizeof( buf1)) == FALSE ) + return FALSE; + nums=atoi( buf1); + CHAR_SETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM4, nums);//记录数值 + return TRUE; +} +#endif + +#ifdef _ITEM_INSLAY +int PETSKILL_Inslay( int index, int toNo, int array, char *data) +{ + int charaindex, petid; + + int inslayindex=-1, inslayno=-1; + int i, j, itemno; +#define MAXINSLAY 4 + int itemindexs[MAXINSLAY]={-1,-1,-1,-1}; + int itemnos[MAXINSLAY]={-1,-1,-1,-1}; + + if( !CHAR_CHECKINDEX( index) ) return FALSE; + if( CHAR_getInt( index, CHAR_WHICHTYPE) != CHAR_TYPEPET ) return FALSE; + charaindex = CHAR_getWorkInt( index, CHAR_WORKPLAYERINDEX); + if( !CHAR_CHECKINDEX( charaindex) ) return FALSE; + + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ) + return FALSE; + petid = CHAR_getInt( charaindex, CHAR_PETID); + + + for( i = 0; i < 15; i ++ ) { + char buf[256]; + char *buf1; + int itemindex; + if( getStringFromIndexWithDelim( data , "|", i+1, buf, sizeof( buf ) ) == FALSE ) break; + itemno = atoi( buf); + if( !CHAR_CHECKITEMINDEX( charaindex, itemno) ) continue; + itemindex = CHAR_getItemIndex( charaindex, itemno); + if( !ITEM_CHECKINDEX( itemindex) ) continue; + + if( i >= MAXINSLAY ) { + CHAR_talkToCli( charaindex, -1, "精工每次只能选择四个物品。", CHAR_COLORYELLOW); + return FALSE; + } + for( j=0; j< MAXINSLAY; j++ ) { + if( itemindexs[j] == itemindex ) { + print("精工物品index相同 ERROR !!\n"); + return FALSE; + } + } + if( (buf1 = ITEM_getChar( itemindex, ITEM_TYPECODE)) == NULL ) { + print(" ITEM_TYPECODE == NULL 错误 !!\n"); + return FALSE; + } + if( !strcmp( buf1, "\0") || !strcmp( buf1, "NULL") ) { + CHAR_talkToCli( charaindex, -1, "这样物品不适合精工。", CHAR_COLORYELLOW); + return FALSE; + } + if( strstr( buf1, "INSLAY") != 0 ) { + if( !ITEM_CHECKINDEX( inslayindex)) { + inslayindex = itemindex; + inslayno = itemno; + }else { + CHAR_talkToCli( charaindex, -1, "精工每次只能选择一个武器或防具。", CHAR_COLORYELLOW); + return FALSE; + } + } + itemindexs[i] = itemindex; + itemnos[i] = itemno; + } + + if( !ITEM_CHECKINDEX( inslayindex) ) { + CHAR_talkToCli( charaindex, -1, "精工必须选择一个武器或防具。", CHAR_COLORYELLOW); + return FALSE; + } + + for( i=0; i< MAXINSLAY; i++) { + if( !ITEM_CHECKINDEX( itemindexs[i]) )break; + if( inslayindex == itemindexs[i] ) continue; + if( PETSKILL_ITEM_inslay( charaindex, inslayindex, itemindexs[i] ) == FALSE ){ + return FALSE; + } + CHAR_DelItem( charaindex, itemnos[i]); +/* + CHAR_setItemIndex( charaindex, itemnos[i] ,-1); + CHAR_sendItemDataOne( charaindex, itemnos[i] ); + ITEM_endExistItemsOne( itemindexs[i]); +*/ + } + + CHAR_sendItemDataOne( charaindex, inslayno ); + CHAR_complianceParameter( charaindex ); + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_ATK | CHAR_P_STRING_DEF + | CHAR_P_STRING_QUICK | CHAR_P_STRING_CHARM ); + + return TRUE; +} + +#endif + +#ifdef _MAGIC_SUPERWALL +int PETSKILL_MagicStatusChange( int charaindex, int toindex, int array, char *data ) +{ + if( CHAR_CHECKINDEX( charaindex ) == FALSE ) return FALSE; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_SUPERWALL); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toindex ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array);//记录属性 + + return TRUE; +} + +#endif + +#ifdef _PETSKILL_SETDUCK +int PETSKILL_SetDuck( int charaindex, int toNo, int array, char *data ) +{ + if( CHAR_CHECKINDEX( charaindex ) == FALSE ) + return FALSE; + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_SETDUCK); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array);//记录属性 + + + CHAR_setWorkInt( charaindex, CHAR_MAGICPETMP, 0 ); + return TRUE; +} +#endif + +#ifdef _MAGICPET_SKILL +int PETSKILL_SetMagicPet( int charaindex, int toNo, int array, char *data ) +{ + int nums=0; + if( CHAR_CHECKINDEX( charaindex ) == FALSE ) + return FALSE; + + nums = CHAR_getWorkInt( charaindex, CHAR_MAGICPETMP); + if( nums >= 3 ){ + int toindex = CHAR_getWorkInt( charaindex, CHAR_WORKPLAYERINDEX); + CHAR_talkToCli( toindex, -1, "此技能单场限用叁次。", CHAR_COLORYELLOW); + return FALSE; + } + CHAR_setWorkInt( charaindex, CHAR_MAGICPETMP, nums ); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_SETMAGICPET); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array);//记录属性 + return TRUE; +} +#endif + +#ifdef _PETSKILL_FIXITEM +int PETSKILL_Fixitem( int index, int toNo, int array, char *data) +{ + int charaindex, petid; + + int fixindex=-1, fixno=-1; + int i, j, itemno; +#define MAXFIXITEM 2 + int itemindexs[MAXFIXITEM]={-1,-1}; + int itemnos[MAXFIXITEM]={-1,-1}; + + if( !CHAR_CHECKINDEX( index) ) return FALSE; + if( CHAR_getInt( index, CHAR_WHICHTYPE) != CHAR_TYPEPET ) return FALSE; + charaindex = CHAR_getWorkInt( index, CHAR_WORKPLAYERINDEX); + if( !CHAR_CHECKINDEX( charaindex) ) return FALSE; + + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ) + return FALSE; + petid = CHAR_getInt( charaindex, CHAR_PETID); + + + for( i = 0; i < 15; i ++ ) { + char buf[256]; + int itemtype=-1; + int itemindex; + if( getStringFromIndexWithDelim( data , "|", i+1, buf, sizeof( buf ) ) == FALSE ) break; + itemno = atoi( buf); + if( !CHAR_CHECKITEMINDEX( charaindex, itemno) ) continue; + itemindex = CHAR_getItemIndex( charaindex, itemno); + if( !ITEM_CHECKINDEX( itemindex) ) continue; + + if( i >= MAXFIXITEM ) { + CHAR_talkToCli( charaindex, -1, "修复每次只能选择两个物品。", CHAR_COLORYELLOW); + return FALSE; + } + for( j=0; j< MAXFIXITEM; j++ ) { + if( itemindexs[j] == itemindex ) { + print("修复物品index相同 ERROR !!\n"); + return FALSE; + } + } + itemtype = ITEM_getInt( itemindex, ITEM_TYPE); + if( itemtype == ITEM_DISH ) { + CHAR_talkToCli( charaindex, -1, "料理不能做修复。", CHAR_COLORYELLOW); + return FALSE; + } + + if( (itemtype >= ITEM_FIST && itemtype <= ITEM_AMULET) || + itemtype == ITEM_BOOMERANG || itemtype == ITEM_BOUNDTHROW || itemtype == ITEM_BREAKTHROW){ + if( !ITEM_CHECKINDEX( fixindex)) { + fixindex = itemindex; + fixno = itemno; + }else { + CHAR_talkToCli( charaindex, -1, "修复每次只能选择一个武器或防具。", CHAR_COLORYELLOW); + return FALSE; + } + } + + itemindexs[i] = itemindex; + itemnos[i] = itemno; + } + + if( !ITEM_CHECKINDEX( fixindex) ) { + CHAR_talkToCli( charaindex, -1, "修复必须选择一个武器或防具。", CHAR_COLORYELLOW); + return FALSE; + } + + if( PETSKILL_ITEM_FixItem( charaindex, fixindex, itemindexs ) == FALSE ){ + return FALSE; + }else { + for( i=0; i< MAXFIXITEM; i++) { + if( !ITEM_CHECKINDEX( itemindexs[i]) )break; + if( fixindex == itemindexs[i] ) continue; + CHAR_setItemIndex( charaindex, itemnos[i] ,-1); + CHAR_sendItemDataOne( charaindex, itemnos[i] ); + ITEM_endExistItemsOne( itemindexs[i]); + } + } + + CHAR_sendItemDataOne( charaindex, fixno ); + CHAR_complianceParameter( charaindex ); + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_ATK | CHAR_P_STRING_DEF + | CHAR_P_STRING_QUICK | CHAR_P_STRING_CHARM ); + CHAR_talkToCli( charaindex, -1, "修复完成。", CHAR_COLORYELLOW); + return TRUE; +} +#endif + +#ifdef _PETSKILL_TIMID +int PETSKILL_BattleTimid( int charaindex, int toNo, int array, char *data ) +{ + if( !CHAR_CHECKINDEX( charaindex) ) return FALSE; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) return FALSE; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_TIMID ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, ( CHAR_getWorkInt( charaindex, CHAR_WORKFIXSTR)*0.7) ); + CHAR_setWorkInt( charaindex, CHAR_WORKDEFENCEPOWER, ( CHAR_getWorkInt( charaindex, CHAR_WORKFIXTOUGH)*0.4) ); + CHAR_setWorkInt( charaindex, CHAR_WORKQUICK, ( CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX)*0.8) ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array);//记录属性 + + return TRUE; +} +#endif +#ifdef _PETSKILL_2TIMID +int PETSKILL_2BattleTimid( int charaindex, int toNo, int array, char *data ) +{ + char *pszOption=NULL; + char *pszP; + float fPer=0; + if( !CHAR_CHECKINDEX( charaindex) ) return FALSE; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_2TIMID ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + if( pszOption == NULL ) return FALSE; + if( (pszP = strstr( pszOption, "-攻%" ) ) != NULL ){ + sscanf( pszP+4, "%f", &fPer ); + fPer=(fPer/100); + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, (CHAR_getWorkInt( charaindex, CHAR_WORKFIXSTR)*fPer) ); + } + if( (pszP = strstr( pszOption, "+攻%" ) ) != NULL ){ + sscanf( pszP+4, "%f", &fPer ); + fPer=(fPer/100); + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, CHAR_getWorkInt( charaindex, CHAR_WORKFIXSTR)+(CHAR_getWorkInt( charaindex, CHAR_WORKFIXSTR)*fPer) ); + } + if( (pszP = strstr( pszOption, "-防%" ) ) != NULL ){ + sscanf( pszP+4, "%f", &fPer ); + fPer=(fPer/100); + CHAR_setWorkInt( charaindex, CHAR_WORKDEFENCEPOWER, ( CHAR_getWorkInt( charaindex, CHAR_WORKFIXTOUGH)*fPer) ); + } + if( (pszP = strstr( pszOption, "+防%" ) ) != NULL ){ + sscanf( pszP+4, "%f", &fPer ); + fPer=(fPer/100); + CHAR_setWorkInt( charaindex, CHAR_WORKDEFENCEPOWER, CHAR_getWorkInt( charaindex, CHAR_WORKFIXTOUGH)+(CHAR_getWorkInt( charaindex, CHAR_WORKFIXTOUGH)*fPer) ); + } + if( (pszP = strstr( pszOption, "-敏%" ) ) != NULL ){ + sscanf( pszP+4, "%f", &fPer ); + fPer=(fPer/100); + CHAR_setWorkInt( charaindex, CHAR_WORKQUICK, ( CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX)*fPer) ); + } + if( (pszP = strstr( pszOption, "+敏%" ) ) != NULL ){ + sscanf( pszP+4, "%f", &fPer ); + fPer=(fPer/100); + CHAR_setWorkInt( charaindex, CHAR_WORKQUICK, CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX)+(CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX)*fPer) ); + } + + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array);//记录属性 + + return TRUE; +} +#endif +#ifdef _PETSKILL_ANTINTER +int PETSKILL_AntInter( int charaindex, int toNo, int array, char* data) +{ + if( !CHAR_CHECKINDEX( charaindex) ) return FALSE; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_ANTINTER); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array);//记录属性 + return TRUE; +} +#endif + +#ifdef _PETSKILL_PROPERTY +int PETSKILL_BattleProperty( int charaindex, int toNo, int array, char *data ) +{ + if( !CHAR_CHECKINDEX( charaindex) ) return FALSE; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) return FALSE; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_PROPERTYSKILL ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + +// CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, ( CHAR_getWorkInt( charaindex, CHAR_WORKFIXSTR)*0.7) ); +// CHAR_setWorkInt( charaindex, CHAR_WORKDEFENCEPOWER, ( CHAR_getWorkInt( charaindex, CHAR_WORKFIXTOUGH)*0.5) ); +// CHAR_setWorkInt( charaindex, CHAR_WORKQUICK, ( CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX)*0.95) ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array);//记录属性 + + return TRUE; +} +#endif + +#ifdef _PETSKILL_TEAR +int PETSKILL_BattleTearDamage( int charaindex, int toNo, int array, char *data ) +{ + if( !CHAR_CHECKINDEX( charaindex) ) return FALSE; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) return FALSE; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_PETSKILLTEAR ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, ( CHAR_getWorkInt( charaindex, CHAR_WORKFIXSTR)*0.9) ); + CHAR_setWorkInt( charaindex, CHAR_WORKDEFENCEPOWER, ( CHAR_getWorkInt( charaindex, CHAR_WORKFIXTOUGH)*0.8) ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array);//记录属性 + return TRUE; +} +#endif + + +#ifdef _BATTLE_LIGHTTAKE +int PETSKILL_Lighttakeed( int charaindex, int toNo, int array, char *data ) +{ + if( !CHAR_CHECKINDEX( charaindex) ) return FALSE; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) return FALSE; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_LIGHTTAKE ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, (CHAR_getWorkInt( charaindex, CHAR_WORKFIXSTR)*0.7) ); + CHAR_setWorkInt( charaindex, CHAR_WORKDEFENCEPOWER, (CHAR_getWorkInt( charaindex, CHAR_WORKFIXTOUGH)*0.5) ); +// CHAR_setWorkInt( charaindex, CHAR_WORKQUICK, (CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX)*0.95) ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array);//记录属性 + return TRUE; +} +#endif + +#ifdef _BATTLE_ATTCRAZED +int PETSKILL_AttackCrazed( int charaindex, int toNo, int array, char *data ) +{ + char *pszOption=NULL; + if( !CHAR_CHECKINDEX( charaindex) ) return FALSE; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) return FALSE; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_ATTCRAZED ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, (CHAR_getWorkInt( charaindex, CHAR_WORKFIXSTR)*0.8) ); + CHAR_setWorkInt( charaindex, CHAR_WORKDEFENCEPOWER, (CHAR_getWorkInt( charaindex, CHAR_WORKFIXTOUGH)*0.7) ); + + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + if( pszOption == NULL ) return FALSE; + + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array);//记录属性 + CHAR_SETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3, atoi(pszOption)); + return TRUE; +} +#endif + +#ifdef _SHOOTCHESTNUT // Syu ADD 宠技:丢栗子 +int PETSKILL_AttackShoot( int charaindex, int toNo, int array, char *data ) +{ + //int n = RAND ( 3 , 5 ) ; + int n ; + int loyal = CHAR_getWorkInt( charaindex, CHAR_WORKFIXAI ); + char bb1[16] , bb2[16] ; + char *buf = NULL ; + if( !CHAR_CHECKINDEX( charaindex) ) return FALSE; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) return FALSE; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_ATTSHOOT ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + buf = PETSKILL_getChar( array , PETSKILL_OPTION ) ; + if ( buf == NULL ) return FALSE; + getStringFromIndexWithDelim( buf , "|", 1 , bb1 , sizeof( bb1 ) ); + getStringFromIndexWithDelim( buf , "|", 2 , bb2 , sizeof( bb2 ) ); + n = RAND ( atoi(bb1) , atoi(bb2) ) ; + if ( loyal >= 100 ) { + if ( RAND ( 1 , 300 ) > 299 ) + n = 8 ; + else if ( (CHAR_getInt( charaindex , CHAR_HP )) < 20 && ( RAND ( 1 , 50 ) > 49 ) ) + n = 8 ; + } +/* + if ( n != 8 ) + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, (CHAR_getWorkInt( charaindex, CHAR_WORKFIXSTR) * 1.2 / n ) ); + else + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, (CHAR_getWorkInt( charaindex, CHAR_WORKFIXSTR) * 1.2 / 4 ) ); + CHAR_setWorkInt( charaindex, CHAR_WORKDEFENCEPOWER, (CHAR_getWorkInt( charaindex, CHAR_WORKFIXTOUGH) * 1) ); +*/ + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array);//记录属性 + CHAR_SETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3, n); + return TRUE; +} +#endif + +#ifdef _PET_SKILL_SARS // WON ADD 毒煞蔓延 +int PETSKILL_Sars( int charaindex, int toNo, int array, char *data ) +{ + + char *pszOption, *pszP; + int status = -1, i = 0, turn = 3; + char szTurn[] = "turn"; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_SARS ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + pszP = pszOption; + + for( ;status == -1 && pszP[0] != 0; pszP++ ){ + for( i = 1; i < BATTLE_ST_END; i ++ ){ + if( strncmp( pszP, aszStatus[i], 2 ) == 0 ){ + status = i; + pszP +=2; + break; + } + } + } + + if( ( pszP = strstr( pszP, szTurn ) ) != NULL){ + pszP += sizeof( szTurn ); + sscanf( pszP, "%d", &turn ); + } + + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, status ); + CHAR_SETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3, turn ); + + return TRUE; + + +} +#endif + +#ifdef _SONIC_ATTACK // WON ADD 音波攻击 +int PETSKILL_Sonic( int charaindex, int toNo, int array, char *data ) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_SONIC ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); //记录属性 + return TRUE; + +} +#endif +#ifdef _PETSKILL_REGRET +int PETSKILL_Regret( int charaindex, int toNo, int array, char *data ) +{ + char *pszOption, *pszP; + int strdef; + float fPer = 0.01; + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + if( (pszP = strstr( pszOption, "攻%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR)+strdef)); + } + + if( (pszP = strstr( pszOption, "防%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKDEFENCEPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXTOUGH)+strdef)); + } + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_REGRET ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); //记录属性 + return TRUE; + +} +#endif + +#ifdef _PETSKILL_GYRATE +int PETSKILL_Gyrate( int charaindex, int toNo, int array, char *data ) +{ + char *pszOption, *pszP; + float fPer = 0.01; + int strdef=0; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_GYRATE ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); //攻击对象 23,24,25,26 为单排 + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + + if( pszOption == NULL ) { + print("\n pszOption == NULL "); + return FALSE; + } + + //读取攻值 + if( (pszP = strstr( pszOption, "攻%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + + //设定修正值 + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR)+strdef)); + } + + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); //记录属性 + return TRUE; +} +#endif + +#ifdef _PETSKILL_ACUPUNCTURE +int PETSKILL_Acupuncture( int charaindex, int toNo, int array, char *data ) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_ACUPUNCTURE ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); //记录属性 + return TRUE; +} +#endif + +#ifdef _PETSKILL_RETRACE +int PETSKILL_Retrace( int charaindex, int toNo, int array, char *data ) +{ + //char *pszOption, *pszP; + //float fPer = 0.01; + //int strdef=0; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_RETRACE ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + +/* pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + + if( pszOption == NULL ) { + print("\n pszOption == NULL "); + return FALSE; + } + + //读取攻值 + if( (pszP = strstr( pszOption, "攻%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + //设定修正值 + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR)+strdef)); + } +*/ + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); //记录属性 + return TRUE; +} +#endif + +#ifdef _PETSKILL_HECTOR +int PETSKILL_Hector( int charaindex, int toNo, int array, char *data ) +{ + char *pszOption, *pszP; + float fPer = 0.01; + int strdef; + int status = -1;//, i = 0, turn = 3; + //char szTurn[] = "turn"; + int d_dep; + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_HECTOR ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + + if( pszOption == NULL ) { + print("\n pszOption == NULL "); + return FALSE; + } + + //读取攻值 + if( (pszP = strstr( pszOption, "攻%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + fPer=(fPer/100); + + //设定修正值 + strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR); + strdef=(int)(strdef * fPer); + CHAR_setWorkInt(charaindex,CHAR_WORKATTACKPOWER,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR)+strdef)); + } + + if( (pszP = strstr( pszOption, "敏%" ) ) != NULL ){ + sscanf( pszP+3, "%f", &fPer ); + CHAR_setWorkInt( charaindex, CHAR_SKILLDEXPOWER, fPer); + fPer = fPer / 100; + d_dep = CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX); + d_dep = (int)(d_dep * fPer); + CHAR_setWorkInt( charaindex, CHAR_WORKQUICK, CHAR_getWorkInt( charaindex, CHAR_WORKFIXDEX) + d_dep); + } + + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); //记录属性 + + return TRUE; +} +#endif + +#ifdef _PETSKILL_FIREKILL +int PETSKILL_Firekill( int charaindex, int toNo, int array, char *data ) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_FIREKILL ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); //记录属性 + + return TRUE; +} +#endif + +#ifdef _PETSKILL_DAMAGETOHP +int PETSKILL_DamageToHp2( int charaindex, int toNo, int array, char *data ) +{ + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_DAMAGETOHP2 ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3, array); //记录技能 +/* pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + + if( pszOption == NULL ) return FALSE; + + strdef = CHAR_getWorkInt(charaindex,CHAR_WORKFIXSTR); + def = (atoi( pszOption)/100); + strdef = strdef - (int)(strdef*def); + CHAR_setWorkInt( charaindex, CHAR_WORKATTACKPOWER, strdef); +*/ + + return TRUE; + +} +#endif + +#ifdef _PETSKILL_BECOMEFOX +int PETSKILL_BecomeFox( int charaindex, int toNo, int array, char* data) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_BECOMEFOX); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3, array); //记录技能 + + return TRUE; +} +#endif + +#ifdef _PETSKILL_BECOMEPIG +int PETSKILL_BecomePig( int charaindex, int toNo, int array, char* data) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_BECOMEPIG); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); //记录属性 + return TRUE; +} +#endif + +#ifdef _PETSKILL_LER +int PETSKILL_BatFly(int charaindex,int toNo,int array,char* data) +{ + CHAR_setWorkInt(charaindex,CHAR_WORKBATTLECOM1,BATTLE_COM_S_BAT_FLY); + CHAR_setWorkInt(charaindex,CHAR_WORKBATTLECOM2,toNo); + CHAR_setWorkInt(charaindex,CHAR_WORKBATTLEMODE,BATTLE_CHARMODE_C_OK); + CHAR_SETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3,array); + return TRUE; +} + +int PETSKILL_DivideAttack( int charaindex, int toNo, int array, char* data) +{ + CHAR_setWorkInt(charaindex,CHAR_WORKBATTLECOM1,BATTLE_COM_S_DIVIDE_ATTACK); + CHAR_setWorkInt(charaindex,CHAR_WORKBATTLECOM2,toNo); + CHAR_setWorkInt(charaindex,CHAR_WORKBATTLEMODE,BATTLE_CHARMODE_C_OK); + CHAR_SETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3,array); + return TRUE; +} +#endif + +#ifdef _PETSKILL_BATTLE_MODEL +int PETSKILL_BattleModel(int charaindex, int toindex, int array, char* data) +{ + float fPer; + int i,iType,iObjectNum,iValue; + int iAddPowerType[3] = {CHAR_WORKATTACKPOWER,CHAR_WORKDEFENCEPOWER,CHAR_WORKQUICK}; + char *pszOption,szData[32],szData2[32]; + char szWord[3][3] = {"攻","防","敏"}; + + pszOption = PETSKILL_getChar(array,PETSKILL_OPTION); + if(pszOption == NULL){ + printf("PETSKILL_BattleModel: 读取 PETSKILL_OPTION 错误!!(数组:%d,文件:%s,第%d行)\n",array,__FILE__,__LINE__); + return FALSE; + } + + // 取得攻击类型 + if(getStringFromIndexWithDelim(pszOption,"|",1,szData,sizeof(szData)) == FALSE){ + printf("PETSKILL_BattleModel: no type data!!(文件:%s,第%d行)\n",__FILE__,__LINE__); + return FALSE; + } + iType = atoi(szData); + // 取得攻击物件数量 + if(getStringFromIndexWithDelim(pszOption,"|",2,szData,sizeof(szData)) == FALSE){ + printf("PETSKILL_BattleModel: no object number data!!(文件:%s,第%d行)\n",__FILE__,__LINE__); + return FALSE; + } + iObjectNum = atoi(szData); + if(iObjectNum <= 0) iObjectNum = RAND(1,10); + else if(iObjectNum > 10) iObjectNum = 10; + // 取得能力增减 + if(getStringFromIndexWithDelim(pszOption,"|",6,szData,sizeof(szData)) != FALSE){ + for(i=0;i<3;i++){ + if(getStringFromIndexWithDelim(szData," ",i+1,szData2,sizeof(szData2)) != FALSE){ + // 检查设定 + if(strstr(szData2,szWord[i]) != NULL){ + iValue = CHAR_getWorkInt(charaindex,CHAR_WORKATTACKPOWER); + // 有带 "%" 的设定 ex: "攻%" + if(strstr(szData2,"%") != NULL){ + sscanf(szData2 + 3,"%f",&fPer); + fPer = (fPer/100); + iValue += (int)(iValue * fPer); + } + // 没带 "%" 的设定 ex: "攻" + else{ + sscanf(szData2 + 2,"%f",&fPer); + iValue = (int)fPer; + } + CHAR_setWorkInt(charaindex,iAddPowerType[i],iValue); + } + } + else break; + } + } + + CHAR_setWorkInt(charaindex,CHAR_WORKBATTLEMODE,BATTLE_CHARMODE_C_OK); + CHAR_setWorkInt(charaindex,CHAR_WORKBATTLECOM1,BATTLE_COM_S_BATTLE_MODEL); + CHAR_SETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM2,iType); // 记录攻击类型 + CHAR_SETWORKINT_HIGH(charaindex,CHAR_WORKBATTLECOM2,iObjectNum); // 记录攻击物件数量 + CHAR_setWorkInt(charaindex,CHAR_WORKBATTLECOM3,array); + return TRUE; +} +#endif + +#ifdef _PETSKILL_SHOWMERCY +int PETSKILL_ShowMercy( int charaindex, int toNo, int array, char* data) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_SHOWMERCY); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + + return TRUE; +} +#endif + +#ifdef _PETSKILL_COMBINED +int PETSKILL_Combined( int charaindex, int toNo, int array, char* data) +{ + char *pszOption; + char combined[32]; + int kill[10],count,i; + char killstr[32],countstr[32]; + + pszOption = PETSKILL_getChar( array, PETSKILL_OPTION ); + if( pszOption == NULL ) return FALSE; + + strcpy( combined, " " ); + getStringFromIndexWithDelim( pszOption, "|", 1, combined, sizeof( combined)); + if( strcmp( combined, "综合法" ) == 0 ){ + if( getStringFromIndexWithDelim( pszOption, "|", 2, countstr, sizeof( countstr)) == FALSE ) + return FALSE; + count = atoi(countstr); + if( count > 10 ) + count = 10; + for(i=0;i +#include +#include +#include "buf.h" +#include "profession_skill.h" +#include "char_base.h" +#include "battle.h" +#include "magic_base.h" +#include "configfile.h" +#include "char.h" +#include "lssproto_serv.h" +#include "skill.h" + +static Professionskill *PROFESSION_skill; + + +typedef struct tagProfessionskill_skillFunctionTable +{ + char *functionname; + PROFESSION_SKILL_CALLFUNC func; + int hash; +// int status; +}PROFESSION_SKILL_skillFunctionTable; + +static PROFESSION_SKILL_skillFunctionTable PROFESSION_SKILL_functbl[] = { + +// 巫师技能 + { "PROFESSION_VOLCANO_SPRINGS", PROFESSION_volcano_springs, 0 }, // 火山泉 + { "PROFESSION_FIRE_BALL", PROFESSION_fire_ball, 0 }, // 火星球 + { "PROFESSION_FIRE_SPEAR", PROFESSION_fire_spear, 0 }, // 火龙枪 + { "PROFESSION_SUMMON_THUNDER", PROFESSION_summon_thunder, 0 }, // 召雷术 + { "PROFESSION_CURRENT", PROFESSION_current, 0 }, // 电流术 + { "PROFESSION_STORM", PROFESSION_storm, 0 }, // 暴风雨 + { "PROFESSION_ICE_ARROW", PROFESSION_ice_arrow, 0 }, // 冰箭术 + { "PROFESSION_ICE_CRACK", PROFESSION_ice_crack, 0 }, // 冰爆术 + { "PROFESSION_ICE_MIRROR", PROFESSION_ice_mirror, 0 }, // 冰镜术 + { "PROFESSION_DOOM", PROFESSION_doom, 0 }, // 世界末日 + { "PROFESSION_BLOOD", PROFESSION_blood, 0 }, // 嗜血成性 + { "PROFESSION_BLOOD_WORMS", PROFESSION_blood_worms, 0 }, // 嗜血蛊 + { "PROFESSION_SIGN", PROFESSION_sign, 0 }, // 一针见血 + { "PROFESSION_FIRE_ENCLOSE", PROFESSION_fire_enclose, 0 }, // 火附体 + { "PROFESSION_ICE_ENCLOSE", PROFESSION_ice_eclose, 0 }, // 冰附体 + { "PROFESSION_THUNDER_ENCLOSE", PROFESSION_thunder_enclose, 0 }, // 雷附体 + { "PROFESSION_FIRE_PRACTICE", PROFESSION_fire_practice, 0 }, // 火魔法熟练度 + { "PROFESSION_ICE_PRACTICE", PROFESSION_ice_practice, 0 }, // 冰魔法熟练度 + { "PROFESSION_THUNDER_PRACTICE",PROFESSION_thunder_practice,0 }, // 雷魔法熟练度 + { "PROFESSION_ENCLOSE", PROFESSION_enclose, 0 }, // 附身术 + { "PROFESSION_TRANSPOSE", PROFESSION_transpose, 0 }, // 移形换位 +// { "PROFESSION_ALCHEMY", PROFESSION_alchemy, 0 }, // 炼金术 + +// 勇士技能 + { "PROFESSION_CHAIN_ATK", PROFESSION_chain_atk, 0 }, // 连环攻击 + { "PROFESSION_AVOID", PROFESSION_avoid, 0 }, // 回避 + { "PROFESSION_WEAPON_FOCUS", PROFESSION_weapon_focus, 0 }, // 武器专精 + { "PROFESSION_REBACK", PROFESSION_reback, 0 }, // 状态回复 + { "PROFESSION_BRUST", PROFESSION_brust, 0 }, // 爆击 + { "PROFESSION_CHAIN_ATK_2", PROFESSION_chain_atk_2, 0 }, // 双重攻击 + { "PROFESSION_SCAPEGOAT", PROFESSION_scapegoat, 0 }, // 舍已为友 + { "PROFESSION_ENRAGE", PROFESSION_enrage, 0 }, // 激化攻击 + { "PROFESSION_ENERGY_COLLECT", PROFESSION_energy_collect, 0 }, // 能量聚集 + { "PROFESSION_FOCUS", PROFESSION_focus, 0 }, // 专注战斗 + { "PROFESSION_SHIELD_ATTACK", PROFESSION_shield_attack, 0 }, // 盾击 + { "PROFESSION_DUAL_WEAPON", PROFESSION_dual_weapon, 0 }, // 二刀流 + { "PROFESSION_DEFLECT", PROFESSION_deflect, 0 }, // 格档 + { "PROFESSION_THROUGH_ATTACK", PROFESSION_through_attack, 0 }, // 贯穿攻击 + { "PROFESSION_CAVALRY", PROFESSION_cavalry, 0 }, // 座骑攻击 + { "PROFESSION_DEAD_ATTACK", PROFESSION_dead_attack, 0 }, // 濒死攻击 + { "PROFESSION_CONVOLUTE", PROFESSION_convolute, 0 }, // 回旋攻击 + { "PROFESSION_CHAOS", PROFESSION_chaos, 0 }, // 混乱攻击 + +// 猎人 + { "PROFESSION_TRACK", PROFESSION_track, 0 }, // 追寻敌踪 + { "PROFESSION_ESCAPE", PROFESSION_escape, 0 }, // 回避战斗 + { "PROFESSION_DOCILE", PROFESSION_docile, 0 }, // 驯伏宠物 + { "PROFESSION_TRAP", PROFESSION_trap, 0 }, // 陷阱 + { "PROFESSION_ENRAGE_PET", PROFESSION_enrage_pet, 0 }, // 激怒宠物 + { "PROFESSION_DRAGNET", PROFESSION_dragnet, 0 }, // 天罗地网 + { "PROFESSION_ENTWINE", PROFESSION_entwine, 0 }, // 树根缠绕 + { "PROFESSION_AUTARKY", PROFESSION_autarky, 0 }, // 自给自足 + { "PROFESSION_PLUNDER", PROFESSION_plunder, 0 }, // 体掠夺 + { "PROFESSION_TOXIN_WEAPON", PROFESSION_toxin_weapon, 0 }, // 毒素武器 + { "PROFESSION_RESIST_FIRE", PROFESSION_resist_fire, 0 }, // 火抗性 + { "PROFESSION_RESIST_ICE", PROFESSION_resist_ice, 0 }, // 冰抗性 + { "PROFESSION_RESIST_THUNDER", PROFESSION_resist_thunder, 0 }, // 雷抗性 +#ifdef _PROFESSION_ADDSKILL + { "PROFESSION_RESIST_F_I_T", PROFESSION_resist_f_i_t, 0 }, // 自然威能 + { "PROFESSION_CALL_NATURE", PROFESSION_call_nature, 0 }, // 号召自然 + { "PROFESSION_BOUNDARY", PROFESSION_boundary, 0 }, // 四属性结界 +#endif + { "PROFESSION_G_RESIST_FIRE", PROFESSION_g_resist_fire, 0 }, // 团体火抗性 + { "PROFESSION_G_RESIST_ICE", PROFESSION_g_resist_ice, 0 }, // 团体冰抗性 + { "PROFESSION_G_RESIST_THUNDER",PROFESSION_g_resist_thunder,0 }, // 团体雷抗性 + { "PROFESSION_ATTACK_WEAK", PROFESSION_attack_weak, 0 }, // 弱点攻击 + { "PROFESSION_INSTIGATE", PROFESSION_instigate, 0 }, // 挑拨 + { "PROFESSION_OBLIVION", PROFESSION_oblivion, 0 }, // 遗忘 + +// 共同技能 + { "PROFESSION_FULL_MP", PROFESSION_full_mp, 0 }, // 气力充沛 + { "PROFESSION_STRONG_BACK", PROFESSION_strong_back, 0 }, // 负重增加 + { "PROFESSION_STRENGTHEN", PROFESSION_strengthen, 0 }, // 自我强化 + +}; + + +static int profession_skill_num; // 职业技能总数 + +// 将 profession.txt 载入 +BOOL PROFESSION_initSkill( char *filename) +{ + + FILE* f; + char line[256]; + int linenum=-1; + int skill_readlen=0; + int i, j; + + int max_skillid = 0; + + f = fopen(filename,"r"); + if( f == NULL ){ + print( "file open error\n"); + return FALSE; + } + + profession_skill_num=0; + + while( fgets( line, sizeof( line ), f ) ){ + char token[256]; + + linenum ++; + if( line[0] == '#' )continue; + if( line[0] == '\n' )continue; + chomp( line ); + profession_skill_num++; +#ifdef _PROSKILL_OPTIMUM // Robin 取出最大职技ID + if( getStringFromIndexWithDelim( line, ",", + PROFESSION_SKILL_DATACHARNUM+PROFESSION_SKILL_ID+1, + token, sizeof(token)) == FALSE ) + continue; + max_skillid = max( atoi( token), max_skillid); +#endif + } + + if( fseek( f, 0, SEEK_SET ) == -1 ){ + fprint( "Seek Error\n" ); + fclose(f); + return FALSE; + } + +#ifdef _PROSKILL_OPTIMUM // 职技Table数为 最大技能ID +1 + profession_skill_num = max_skillid +1; + print("最大职技ID = %d ...", max_skillid); +#endif + + PROFESSION_skill = allocateMemory( sizeof(struct tagProfessionkill) * profession_skill_num + 1 ); + + + if( PROFESSION_skill == NULL ){ + fprint( "无法分配内存 %d\n", sizeof(struct tagProfessionkill)*profession_skill_num); + fclose( f ); + return FALSE; + } + + // init skill + for( i = 0; i < profession_skill_num; i ++ ) { + for( j = 0; j < PROFESSION_SKILL_DATAINTNUM; j ++ ) + PROFESSION_SKILL_setInt( i,j,-1); + + for( j = 0; j < PROFESSION_SKILL_DATACHARNUM; j ++ ) + PROFESSION_SKILL_setChar( i,j,""); + } + + linenum = -1; + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; + if( line[0] == '\n' )continue; + + chomp( line ); + + replaceString( line, '\t' , ' ' ); + + { + char buf[256]; + for( i = 0; i < strlen( line); i ++) { + if( line[i] != ' ' ) { + break; + } + strcpy( buf, &line[i]); + } + + if( i != 0 ) { + strcpy( line, buf); + } + } + { + char token[256]; + int ret; + +#ifdef _PROSKILL_OPTIMUM // 读取本行职技的ID, 直接以职技ID当Table index + ret = getStringFromIndexWithDelim( line, ",", PROFESSION_SKILL_DATACHARNUM+PROFESSION_SKILL_ID+1, token, sizeof(token)); + if( ret==FALSE ){ + fprint("Syntax Error file:%s line:%d\n",filename,linenum); + break; + } + skill_readlen = atoi( token); +#endif + for( i = 0; i < PROFESSION_SKILL_DATACHARNUM; i ++ ) { + + ret = getStringFromIndexWithDelim( line,",", i + 1, token,sizeof(token)); + if( ret==FALSE ){ + fprint("Syntax Error file:%s line:%d\n",filename,linenum); + break; + } + PROFESSION_SKILL_setChar( skill_readlen, i, token); + } + + for( i = 0; i < PROFESSION_SKILL_DATAINTNUM; i ++ ) { + ret = getStringFromIndexWithDelim( line, ",", i+PROFESSION_SKILL_DATACHARNUM+1, token, sizeof(token)); + + if( ret==FALSE ){ + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + break; + } + if( strlen( token) != 0 ) { + PROFESSION_SKILL_setInt( skill_readlen, i , atoi( token )); + } + } + skill_readlen ++; + } + } + fclose(f); + + profession_skill_num = skill_readlen; + + for( i = 0; i < arraysizeof( PROFESSION_SKILL_functbl); i ++ ){ + PROFESSION_SKILL_functbl[i].hash = hashpjw( PROFESSION_SKILL_functbl[i].functionname ); + } + + return TRUE; + +} + + +// 重新载入 profession.txt +void rePROFESSION_initSkill() +{ + freeMemory( PROFESSION_skill ); + PROFESSION_initSkill(getProfession()); +} + +INLINE BOOL PROFESSION_SKILL_CHECKINDEX( int index ) +{ + if( profession_skill_num < index || index < 0 )return FALSE; + return TRUE; +} + +static INLINE BOOL PROFESSION_SKILL_CHECKINTDATAINDEX( int index) +{ + if( PROFESSION_SKILL_DATAINTNUM < index || index < 0 ) return FALSE; + return TRUE; +} + +static INLINE BOOL PROFESSION_SKILL_CHECKCHARDATAINDEX( int index) +{ + if( PROFESSION_SKILL_DATACHARNUM < index || index < 0 ) return FALSE; + return TRUE; +} + +INLINE int PROFESSION_SKILL_getInt( int index, PROFESSION_SKILL_DATAINT element) +{ + return PROFESSION_skill[index].data[element]; +} + +INLINE int PROFESSION_SKILL_setInt( int index, PROFESSION_SKILL_DATAINT element, int data) +{ + int buf; + buf = PROFESSION_skill[index].data[element]; + PROFESSION_skill[index].data[element]=data; + return buf; +} + +INLINE char* PROFESSION_SKILL_getChar( int index, PROFESSION_SKILL_DATACHAR element) +{ + if( !PROFESSION_SKILL_CHECKINDEX( index)) return NULL; + if( !PROFESSION_SKILL_CHECKCHARDATAINDEX( element)) return NULL; + return PROFESSION_skill[index].string[element].string; +} + +INLINE BOOL PROFESSION_SKILL_setChar( int index ,PROFESSION_SKILL_DATACHAR element, char* new ) +{ + if(!PROFESSION_SKILL_CHECKINDEX(index))return FALSE; + if(!PROFESSION_SKILL_CHECKCHARDATAINDEX(element))return FALSE; + + strcpysafe( PROFESSION_skill[index].string[element].string, + sizeof(PROFESSION_skill[index].string[element].string), + new ); + return TRUE; +} + +int PROFESSION_SKILL_getskillNum( void) +{ + return profession_skill_num; +} + + +/*----------------------------------------------------------------------*/ + +int PROFESSION_SKILL_getskillArray( int skillid) +{ +#ifdef _PROSKILL_OPTIMUM // 查询职技ID改为阵列式 + if( skillid >= 0 && skillid < profession_skill_num ) + return PROFESSION_skill[skillid].data[PROFESSION_SKILL_ID]; +#else + int i; + for( i = 0; i <= profession_skill_num; i ++ ) { // 待优化 + if( PROFESSION_skill[i].data[PROFESSION_SKILL_ID] == skillid ) + return i; + } +#endif + return -1; +} + +PROFESSION_SKILL_CALLFUNC PROFESSION_SKILL_getskillFuncPointer(char* name ) +{ + int i; + int hash = hashpjw( name ); + + for( i = 0; i< arraysizeof( PROFESSION_SKILL_functbl); i++ ){ + if( PROFESSION_SKILL_functbl[i].hash == hash ){ + if( strcmp( PROFESSION_SKILL_functbl[i].functionname, name ) == 0 ){ + return PROFESSION_SKILL_functbl[i].func; + } + } + } + + return NULL; +} + +int _PROFESSION_SKILL_GetArray( char *file, int line, int charaindex, int skill ) +{ + int skillid,array; + + skillid = CHAR_getCharSkill( charaindex, skill); + + if( skillid < 0 ) return -1; + + array = PROFESSION_SKILL_getskillArray( skillid ); + + return array; +} + + +/*----------------------------------------------------------------------*/ + +// 使用职业技能 +int PROFESSION_SKILL_Use( int charaindex, int skill, int toNo, char *data ) +{ + int Pskillid, skillid; + int ret=-1, skill_level; + PROFESSION_SKILL_CALLFUNC func; + CHAR_HaveSkill* hskill; + int char_pskill, profession_skill; + + skillid = CHAR_getCharSkill( charaindex, skill); + Pskillid = PROFESSION_SKILL_getskillArray( skillid); + //print("\n skillid:%d Pskillid:%d ", skillid, Pskillid); // Robin log + if( Pskillid == -1 ) { + printf("\n 改封包??找不到该职技! "); + return ret; + } + +#ifdef _PROSKILL_OPTIMUM // Robin fix 检查职业是否相符 + char_pskill = CHAR_getInt( charaindex, PROFESSION_CLASS ); + profession_skill = PROFESSION_SKILL_getInt( Pskillid, PROFESSION_SKILL_PROFESSION_CLASS); + if( (char_pskill <=0) || (char_pskill != profession_skill) ) { + print("\n 改封包??职技的职业不正确!:%d:%d ", char_pskill, profession_skill); + return ret; + } +#endif + + // 找寻对应 function + func = PROFESSION_SKILL_getskillFuncPointer( PROFESSION_SKILL_getChar( Pskillid, PROFESSION_SKILL_FUNCNAME) ); + + // 判断是否为人物 + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ) return ret; + + + if( func ){ + // 人物技能等级 + hskill = CHAR_getCharHaveSkill( charaindex, skill ); + skill_level = SKILL_getInt( &hskill->skill, SKILL_LEVEL); + + // 耗损 MP + if( PROFESSION_SKILL_DEC_COST_MP( charaindex, skill, Pskillid, skill_level ) != 1 ) { + print("\n Error:职技MP:%d:%d:%d ", skill, Pskillid, skill_level); + return ret; + } + + // 使用职业技能 + ret = func( charaindex, toNo, Pskillid, data, skill_level ); + if( ret == -1 ){ + int rands = rand()%10; + //andy_log + print("ret = %d, rands:%d \n", ret, rands); + if( rands > 5 ) return ret; + } + + if( Pskillid == 57 //激怒宠物 选宠物才有经验值 + && CHAR_getInt( BATTLE_No2Index( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ), toNo ), CHAR_WHICHTYPE) != CHAR_TYPEPET ) + return ret; + + // 一般技能升级 + PROFESSION_NORMAL_SKILL_LEVLE_UP( &hskill->skill, Pskillid, charaindex ); + } + else { + print("\n 错误!找不到职技func "); + } + + return ret; +} + +// 特殊技能升级 +void PROFESSION_SKILL_LVEVEL_UP( int charaindex, char *name ) +{ + int skill=-1; + int skillid=0, Pskillid=0, i; + char *skill_name; + CHAR_HaveSkill* hskill; + + for( i=0; i CHAR_SKILLMAXHAVE) ) return; + + skillid = CHAR_getCharSkill( charaindex, skill); + Pskillid = PROFESSION_SKILL_getskillArray( skillid); + if( Pskillid == -1 ) return; + + // 人物技能等级 + hskill = CHAR_getCharHaveSkill( charaindex, skill ); + + // 一般技能升级 + PROFESSION_NORMAL_SKILL_LEVLE_UP( &hskill->skill, Pskillid, charaindex ); + + return; +} + +// 二刀流技能升级 +void PROFESSION_SKILL_DUAL_WEAPON_LVEVEL_UP( int charaindex, char *name ) +{ + int skill=-1, arm = 0, shield = 0; + int skillid=0, Pskillid=0, i; + char *skill_name; + CHAR_HaveSkill* hskill; + + // 检查左右手装备 + for( i = 0 ; i < CHAR_EQUIPPLACENUM ; i ++ ){ + int id = CHAR_getItemIndex(charaindex,i); + if( ITEM_CHECKINDEX(id) ){ + if( i == CHAR_ARM ) arm = 1; + else if( i == CHAR_EQSHIELD ) shield = 1; + } + } + + if( arm != 1 || shield != 1 ) return; + + for( i=0; i CHAR_SKILLMAXHAVE) ) return; + + skillid = CHAR_getCharSkill( charaindex, skill); + Pskillid = PROFESSION_SKILL_getskillArray( skillid); + if( Pskillid == -1 ) return; + + // 人物技能等级 + hskill = CHAR_getCharHaveSkill( charaindex, skill ); + + // 一般技能升级 + PROFESSION_NORMAL_SKILL_LEVLE_UP( &hskill->skill, Pskillid, charaindex ); + + return; +} + + +// 武器专精技能升级 +void PROFESSION_SKILL_WEAPON_FOCUS_LVEVEL_UP( int charaindex, char *name ) +{ + int skill = -1; + int skillid=0, Pskillid = 0, i; + char *skill_name, *pszOption, *pszP, diff[20]; + int WeaponType = -1; + CHAR_HaveSkill* hskill; + + memset( diff, -1, sizeof(diff) ); + // 装备武器 + WeaponType = BATTLE_GetWepon( charaindex ); + + switch( WeaponType ){ + case ITEM_AXE: + sprintf( diff, "斧" ); break; + case ITEM_CLUB: + sprintf( diff, "棍" ); break; + case ITEM_SPEAR: + sprintf( diff, "枪" ); break; + case ITEM_BOW: + sprintf( diff, "弓" ); break; + case ITEM_BOOMERANG: // 回旋标 + sprintf( diff, "镖" ); break; + case ITEM_BOUNDTHROW: // 投掷斧头 + sprintf( diff, "投" ); break; + case ITEM_BREAKTHROW: // 投掷石 + sprintf( diff, "石" ); break; + default: + sprintf( diff, "无" ); break; + } + + for( i=0; i CHAR_SKILLMAXHAVE) ) return; + + skillid = CHAR_getCharSkill( charaindex, skill); + Pskillid = PROFESSION_SKILL_getskillArray( skillid); + if( Pskillid == -1 ) return; + + // 人物技能等级 + hskill = CHAR_getCharHaveSkill( charaindex, skill ); + + // 一般技能升级 + PROFESSION_NORMAL_SKILL_LEVLE_UP( &hskill->skill, Pskillid, charaindex ); + + return; +} + +// 耗损 MP +int PROFESSION_SKILL_DEC_COST_MP( int charaindex, int skill, int Pskillid, int skill_level ) +{ + + if(skill_level > 0){ + int dec_mp; + int old_mp = CHAR_getInt( charaindex, CHAR_MP ); + int mp=0; + + // 取出耗损 MP + if( (dec_mp = PROFESSION_MAGIC_COST_MP( charaindex, skill )) == -1 ) + dec_mp = PROFESSION_SKILL_getInt( Pskillid, PROFESSION_SKILL_COST_MP ); + + // 检查 MP量 + if( old_mp < dec_mp ) return -1; + + // 嗜血成性 + if( Pskillid != 11 +#ifdef _PROFESSION_ADDSKILL + // && Pskillid != 2 //针针相对不扣 MP +#endif + ) + if( dec_mp <= 0 ) return -1; + + // 扣掉人物 MP + mp = old_mp - dec_mp; + if( mp < 0 ) mp = 0; + CHAR_setInt( charaindex , CHAR_MP , mp ); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_MP); + + return 1; + } + + return -1; +} + + + +// 一般技能升级 +void PROFESSION_NORMAL_SKILL_LEVLE_UP(Skill *skill, int Pskillid, int charaindex ) +{ + int skill_level = 0, up_fix_value = 0; + int rand_num = RAND( 0, 10000 ), rand_num2 = 0; + + // 技能等级到达上限不升级 + skill_level = SKILL_getRealInt( skill, SKILL_LEVEL); + if( skill_level >= PROFESSION_SKILL_MAX_LEVEL * 100 ) return; + + // 升级修正数值 + up_fix_value = PROFESSION_SKILL_getInt( Pskillid, PROFESSION_SKILL_FIX_VALUE) * 100; + rand_num2 = RAND( 0, up_fix_value); + + // 升级检定 +#ifdef _75_TEST +#else + if( rand_num > skill_level + rand_num2){ +#endif + // 增加熟练度 + skill_level += PROFESSION_SKILL_ADD_POINT; +#ifdef _75_TEST + if( skill_level > 10000 ) + skill_level = 10000; +#endif + SKILL_setInt( skill, SKILL_LEVEL, skill_level ); + + if( ( skill_level % 100 ) == 0 ){ + char msg[256]; + sprintf( msg, "%s技能熟练度上升为%d", PROFESSION_SKILL_getChar( Pskillid, PROFESSION_SKILL_NAME), skill_level/100 ); + CHAR_talkToCli( charaindex, -1, msg, CHAR_COLORYELLOW); + CHAR_sendStatusString( charaindex , "S"); + + + // 职业经验值增加 + PROFESSION_LEVEL_CHECK_UP( charaindex ); + } +#ifdef _75_TEST +#else + } +#endif + return; +} + + +void PROFESSION_LEVEL_CHECK_UP( int charaindex ) +{ + int skill_level_add = 0, skill_level_sum = 0, i = 0; + int old_level = CHAR_getInt( charaindex, PROFESSION_LEVEL ); + int next_level_need_point = 9999999; + CHAR_HaveSkill* hskill; + + // 下一级职业升级点数 + next_level_need_point = old_level * 70 * 100; + + for( i=0; iskill, SKILL_IDENTITY); + if( skillID <= 0 ) continue; + + // 共通技能熟练度 50 + if( (skillID == 63) || (skillID == 64) || (skillID == 65) ){ + skill_level_add = 50*100; + }else{ + skill_level_add = SKILL_getRealInt( &hskill->skill, SKILL_LEVEL); + } + + skill_level_sum += skill_level_add; + } + + print("\n技能熟练度上升 ==> 当前熟练度点数(%d) 下一级熟练度升级点数(%d)", skill_level_sum, next_level_need_point ); + + // 技能熟练度达到下一级职业升级点数时,职业等级增加 + if( skill_level_sum >= next_level_need_point ){ + int old_skill_point = CHAR_getInt( charaindex, PROFESSION_SKILL_POINT ); + int next_skill_point = old_skill_point+1; + char msg[64]; + + print("\n职业等级上升 ==> 当前职业等级点数(%d) 下一级职业等级升级点数(%d)", old_skill_point, next_skill_point ); + + CHAR_setInt( charaindex, PROFESSION_LEVEL, old_level + 1 ); + CHAR_setInt( charaindex, PROFESSION_SKILL_POINT, next_skill_point ); + CHAR_sendStatusString( charaindex , "P"); + + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + + sprintf( msg, "职业等级上升为%d级,技能点数上升1点", old_level + 1 ); + CHAR_talkToCli( charaindex, -1, msg, CHAR_COLORYELLOW); + } +} + +// 增加技能 +int PROFESSION_SKILL_ADDSK( int charaindex, int skill, int level ) +{ + int i; + + CHAR_HaveSkill *pSkil; + + if( level > 100 ) level = 100; + else if( level < 1 ) level = 1; + + for( i = 0; i < CHAR_SKILLMAXHAVE; i ++ ){ + int skill_id = -1; + + pSkil = CHAR_getCharHaveSkill( charaindex, i ); + skill_id = SKILL_getInt( &pSkil->skill, SKILL_IDENTITY); + if( skill == skill_id && skill_id != -1 ){ + CHAR_talkToCli(charaindex,-1, "你已经学习过此技能", CHAR_COLORYELLOW); + return -1; + } + + if( pSkil == NULL )continue; + if( pSkil->use != 0 )continue; + break; + } + if( i >= CHAR_SKILLMAXHAVE ){ + CHAR_talkToCli(charaindex,-1, "技能数量已达上限", CHAR_COLORYELLOW); + return -1; + }else{ + level *= 100; + SKILL_makeSkillData( &pSkil->skill, skill, level); + pSkil->use = TRUE; + } + + CHAR_sendStatusString( charaindex , "S"); + + + return 1; +} + +void profession_common_fun( int charaindex, int toNo, int skill_level, int array, int com1 ) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, com1 ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK ); + CHAR_SETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3, skill_level); + CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, array); +#ifdef _PROFESSION_ADDSKILL + if( com1 == BATTLE_COM_S_DOOM + /*&& CHAR_getWorkInt( charaindex, CHAR_DOOMTIME) == 0*/ ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + CHAR_setWorkInt( charaindex, CHAR_WORK_com1, com1 ); + CHAR_setWorkInt( charaindex, CHAR_WORK_toNo, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORK_mode, BATTLE_CHARMODE_C_OK ); + CHAR_setWorkInt( charaindex, CHAR_WORK_skill_level, skill_level ); + CHAR_setWorkInt( charaindex, CHAR_WORK_array, array ); + CHAR_setWorkInt( charaindex, CHAR_DOOMTIME, 3); + } + else if( com1 == BATTLE_COM_S_FIRE_SPEAR + /*&& CHAR_getWorkInt( charaindex, CHAR_DOOMTIME) == 0*/ ){ + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE ); + CHAR_setWorkInt( charaindex, CHAR_WORK_com1, com1 ); + CHAR_setWorkInt( charaindex, CHAR_WORK_toNo, toNo ); + CHAR_setWorkInt( charaindex, CHAR_WORK_mode, BATTLE_CHARMODE_C_OK ); + CHAR_setWorkInt( charaindex, CHAR_WORK_skill_level, skill_level ); + CHAR_setWorkInt( charaindex, CHAR_WORK_array, array ); + CHAR_setWorkInt( charaindex, CHAR_DOOMTIME, 2); + } +#endif +} + +/*----------------------------------------------------------------------*/ +// 以下为职业技能 + +// 巫师技能-火山泉 +int PROFESSION_volcano_springs( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_VOLCANO_SPRINGS ); + return TRUE; +} + +// 巫师技能-火星球 +int PROFESSION_fire_ball( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_FIRE_BALL ); + return TRUE; +} + +// 巫师技能-火龙枪 +int PROFESSION_fire_spear( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_FIRE_SPEAR ); + return TRUE; +} + +// 巫师技能-召雷术 +int PROFESSION_summon_thunder( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_SUMMON_THUNDER ); + return TRUE; +} + +// 巫师技能-电流术 +int PROFESSION_current( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_CURRENT ); + return TRUE; +} + +// 巫师技能-暴风雨 +int PROFESSION_storm( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_STORM ); + return TRUE; +} + +// 巫师技能-冰箭术 +int PROFESSION_ice_arrow( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_ICE_ARROW ); + return TRUE; +} + +// 巫师技能-冰爆术 +int PROFESSION_ice_crack( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_ICE_CRACK ); + return TRUE; +} + +// 巫师技能-冰镜术 +int PROFESSION_ice_mirror( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_ICE_MIRROR ); + return TRUE; +} + +// 巫师技能-世界末日 +int PROFESSION_doom( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_DOOM ); + return TRUE; +} + +// 巫师技能-嗜血成性 +int PROFESSION_blood( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_BLOOD ); + return TRUE; +} + +// 巫师技能-嗜血蛊 +int PROFESSION_blood_worms( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_BLOOD_WORMS ); + return TRUE; +} + +// 巫师技能-一针见血 +int PROFESSION_sign( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_SIGN ); + return TRUE; +} + +// 巫师技能-火附体 +int PROFESSION_fire_enclose( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_FIRE_ENCLOSE ); + return TRUE; +} + +// 巫师技能-冰附体 +int PROFESSION_ice_eclose( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_ICE_ENCLOSE ); + return TRUE; +} + +// 巫师技能-雷附体 +int PROFESSION_thunder_enclose( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_THUNDER_ENCLOSE ); + return TRUE; +} + +// 巫师技能-火魔法熟练度 +int PROFESSION_fire_practice( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + return TRUE; +} + +// 巫师技能-冰魔法熟练度 +int PROFESSION_ice_practice( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + return TRUE; +} + +// 巫师技能-雷魔法熟练度 +int PROFESSION_thunder_practice( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + return TRUE; +} + +// 巫师技能-附身术 +int PROFESSION_enclose( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_ENCLOSE ); + return TRUE; +} + +// 巫师技能-移形换位 +int PROFESSION_transpose( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_TRANSPOSE ); + return TRUE; +} + + +/*----------------------------------------------------------------------*/ + +// 勇士技能-爆击 +int PROFESSION_brust( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_BRUST ); + return TRUE; +} + +// 勇士技能-连环攻击 +int PROFESSION_chain_atk( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_CHAIN_ATK ); + return TRUE; +} + +// 勇士技能-回避 +int PROFESSION_avoid( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_AVOID ); + return TRUE; +} + +// 勇士技能-补血 +int PROFESSION_recovery( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_RECOVERY ); + return TRUE; +} + +// 勇士技能-武器专精 +int PROFESSION_weapon_focus( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + return TRUE; +} + +// 勇士技能-状态回复 +int PROFESSION_reback( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_REBACK ); + return TRUE; +} + +// 勇士技能-双重攻击 +int PROFESSION_chain_atk_2( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_CHAIN_ATK_2 ); + return TRUE; +} + +// 勇士技能-舍已为友 +int PROFESSION_scapegoat( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_SCAPEGOAT ); + return TRUE; +} + +// 勇士技能-激化攻击 +int PROFESSION_enrage( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_ENRAGE ); + return TRUE; +} + +// 勇士技能-能量聚集 +int PROFESSION_energy_collect( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_COLLECT ); + return TRUE; +} + +// 勇士技能-专注战斗 +int PROFESSION_focus( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_FOCUS ); + return TRUE; +} + +// 勇士技能-盾击 +int PROFESSION_shield_attack( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_SHIELD_ATTACK ); + return TRUE; +} + +// 勇士技能-二刀流 +int PROFESSION_dual_weapon( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + return TRUE; +} + +// 勇士技能-格档 +int PROFESSION_deflect( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_DEFLECT ); + return TRUE; +} + +// 勇士技能-贯穿攻击 +int PROFESSION_through_attack( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_THROUGH_ATTACK ); + return TRUE; +} + +// 勇士技能-座骑攻击 +int PROFESSION_cavalry( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_CAVALRY ); + return TRUE; +} + +// 勇士技能-濒死攻击 +int PROFESSION_dead_attack( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_DEAD_ATTACK ); + return TRUE; +} + +// 勇士技能-回旋攻击 +int PROFESSION_convolute( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_CONVOLUTE ); + return TRUE; +} + +// 勇士技能-混乱攻击 +int PROFESSION_chaos( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_CHAOS ); + return TRUE; +} + +/*----------------------------------------------------------------------*/ + +// 猎人技能-陷阱 +int PROFESSION_trap( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_TRAP ); + return TRUE; +} + +// 猎人技能-驯伏宠物 +int PROFESSION_docile( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_DOCILE ); + return TRUE; +} + +// 猎人技能-激怒宠物 +int PROFESSION_enrage_pet( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_ENRAGE_PET ); + return TRUE; +} + +// 猎人技能-天罗地网 +int PROFESSION_dragnet( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_DRAGNET ); + return TRUE; +} + +// 猎人技能-树根缠绕 +int PROFESSION_entwine( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_ENTWINE ); + return TRUE; +} + +// 猎人技能-自给自足 +int PROFESSION_autarky( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + return TRUE; +} + +// 猎人技能- 体掠夺 +int PROFESSION_plunder( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_PLUNDER ); + return TRUE; +} + +// 猎人技能-毒素武器 +int PROFESSION_toxin_weapon( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_TOXIN_WEAPON ); + return TRUE; +} + +// 猎人技能-火抗性提升 +int PROFESSION_resist_fire( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_RESIST_FIRE ); + return TRUE; +} + +// 猎人技能-冰抗性提升 +int PROFESSION_resist_ice( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_RESIST_ICE ); + return TRUE; +} + +// 猎人技能-雷抗性提升 +int PROFESSION_resist_thunder( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_RESIST_THUNDER ); + return TRUE; +} + +#ifdef _PROFESSION_ADDSKILL +// 猎人技能-自然威能 +int PROFESSION_resist_f_i_t( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_RESIST_F_I_T ); + return TRUE; +} +// 猎人技能-号召自然 +int PROFESSION_call_nature( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_CALL_NATURE ); + return TRUE; +} +// 猎人技能-四属性结界 +int PROFESSION_boundary( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_BOUNDARY ); + return TRUE; +} +#endif + +// 猎人技能-团体火抗性提升 +int PROFESSION_g_resist_fire( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_G_RESIST_FIRE ); + return TRUE; +} + +// 猎人技能-团体冰抗性提升 +int PROFESSION_g_resist_ice( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_G_RESIST_ICE ); + return TRUE; +} + +// 猎人技能-团体雷抗性提升 +int PROFESSION_g_resist_thunder( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_G_RESIST_THUNDER ); + return TRUE; +} + +// 猎人技能-弱点攻击 +int PROFESSION_attack_weak( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_ATTACK_WEAK ); + return TRUE; +} + +// 猎人技能-挑拨 +int PROFESSION_instigate( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_INSTIGATE ); + return TRUE; +} + +// 猎人技能-遗忘 +int PROFESSION_oblivion( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + profession_common_fun( charaindex, toNo, skill_level, array, BATTLE_COM_S_OBLIVION ); + return TRUE; +} + + +/*----------------------------------------------------------------------*/ +// 非战斗技能 + +// 猎人技能-追寻敌踪 +int PROFESSION_track( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + char *pszP = NULL, *pszOption = NULL, msg[20]; + int per=0, rate=0, img1, ret = 1; + skill_level /= 10; + + if( CHAR_getWorkInt( charaindex, CHAR_ENCOUNT_NUM) >= (int)time(NULL) ){ + ret = -1; + } + + // 技能的参数 + pszOption = PROFESSION_SKILL_getChar( array, PROFESSION_SKILL_OPTION); + + // 技能等级 rate + if( (pszP = strstr( pszOption, "倍%" ) ) != NULL ) sscanf( pszP+3, "%d", &rate ); + per = skill_level * rate; + + // 准备期的动画 + img1 = PROFESSION_SKILL_getInt( array, PROFESSION_SKILL_IMG_1 ); + + CHAR_setWorkInt( charaindex, CHAR_ENCOUNT_FIX, per); + CHAR_talkToCli( charaindex, -1, "遇敌率上升", CHAR_COLORRED); + CHAR_setWorkInt( charaindex, CHAR_ENCOUNT_NUM, (int)time(NULL) + (60 * 3) ); + + sprintf( msg, "%d", img1); + lssproto_BATTLESKILL_send ( getfdFromCharaIndex(charaindex), msg ) ; + + return ret; +} + +// 猎人技能-回避战斗 +int PROFESSION_escape( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + char *pszP = NULL, *pszOption = NULL, msg[20]; + int per=0, rate=0, img1, ret =1; + skill_level /= 10; + + if( CHAR_getWorkInt( charaindex, CHAR_ENCOUNT_NUM) >= (int)time(NULL) ){ + ret = -1; + } + + // 技能的参数 + pszOption = PROFESSION_SKILL_getChar( array, PROFESSION_SKILL_OPTION); + + // 技能等级 rate + if( (pszP = strstr( pszOption, "倍%" ) ) != NULL ) sscanf( pszP+3, "%d", &rate ); + per = skill_level * rate; + + // 准备期的动画 + img1 = PROFESSION_SKILL_getInt( array, PROFESSION_SKILL_IMG_1 ); + + CHAR_setWorkInt( charaindex, CHAR_ENCOUNT_FIX, (-1) * per); + CHAR_talkToCli( charaindex, -1, "遇敌率下降", CHAR_COLORGREEN); + + CHAR_setWorkInt( charaindex, CHAR_ENCOUNT_NUM, (int)time(NULL) + (60 * 3) ); + + sprintf( msg, "%d", img1); + lssproto_BATTLESKILL_send ( getfdFromCharaIndex(charaindex), msg ) ; + + return ret; +} + + + +// 共同技能-气力充沛 +int PROFESSION_full_mp( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + return TRUE; +} +// 共同技能-负重增加 +int PROFESSION_strong_back( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + return TRUE; +} +// 共同技能-自我强化 +int PROFESSION_strengthen( int charaindex, int toNo, int array, char *data, int skill_level ) +{ + return TRUE; +} + +#endif + diff --git a/gmsv/buf.c b/gmsv/buf.c new file mode 100644 index 0000000..0002082 --- /dev/null +++ b/gmsv/buf.c @@ -0,0 +1,195 @@ +#define __BUF_C__ +#include "version.h" +#include +#include +#include + +#include "buf.h" +#include "handletime.h" + +static int UNIT; +static int UNITNUMBER; +static int memconfig; +static int readblock; +static int NowMemory; +static struct timeval AllocOldTime; + + +typedef struct tagMemory +{ + char* pointer; + BOOL used; + + unsigned int nsize; +}Memory; +static Memory *mem; + + +void memEnd( void ) +{ + if( mem != NULL && mem[0].pointer != NULL ){ + free(mem[0].pointer); + free(mem); + } +} + +BOOL configmem( int unit , int unitnumber ) +{ + if( memconfig == TRUE ) + return FALSE; + UNIT = unit; + UNITNUMBER = unitnumber; + if( UNIT <= 0 || UNITNUMBER <= 0 ) + return memconfig = FALSE; + return memconfig = TRUE; +} + +BOOL memInit( void ) +{ + int i; + if( memconfig == FALSE ) + return FALSE; + mem = calloc( 1, sizeof( Memory ) * UNITNUMBER ); + if( mem == NULL ){ + print( "memInit: Can't alloc memory: %d\n" , + sizeof(Memory)*UNITNUMBER ); + return FALSE; + } + + memset( mem , 0 , sizeof( Memory )* UNITNUMBER ); + for( i = 0 ; i < UNITNUMBER ; i ++ ){ + mem[i].pointer = NULL; + mem[i].used = FALSE; + mem[i].nsize = 0; + } + mem[0].pointer = calloc( 1, UNIT*UNITNUMBER ); + if( mem[0].pointer == NULL ){ + print( "memInit: Can't Allocate %d byte\n" , UNIT*UNITNUMBER ); + free( mem ); + return FALSE; + } + memset( mem[0].pointer , 0 , sizeof( UNIT*UNITNUMBER )); + +#ifdef DEBUG + print( "Allocate %d byte( %.2fK byte %.2fM byte )\n" , + UNIT*UNITNUMBER, + UNIT*UNITNUMBER/1024.0, + UNIT*UNITNUMBER/1024.0/1024.0 + ); +#endif + readblock = 0; + for( i = 0 ; i < UNITNUMBER ; i ++ ) + mem[i].pointer = mem[0].pointer + i * UNIT; + + NowMemory = 0; + AllocOldTime.tv_sec = NowTime.tv_sec; + AllocOldTime.tv_usec = NowTime.tv_usec; + + return TRUE; +} + +void* allocateMemory( const unsigned int nbyte ) +{ + int i; + int arrayAllocSize; + BOOL flg = FALSE; + void *ret; + int first = 0; + + arrayAllocSize = nbyte/UNIT + ( nbyte%UNIT ? 1 : 0 ); + if( arrayAllocSize == 0 )return NULL; +#ifdef DEBUG + debug( arrayAllocSize , d ); +#endif + i = readblock; + while( 1 ) { + if( i > UNITNUMBER - arrayAllocSize) { + i = 0; + } + if( mem[i].used != FALSE ){ + i += mem[i].nsize; + }else{ + int j; + BOOL found = TRUE; + for( j = i; j < i + arrayAllocSize; j ++ ) { + if( mem[j].used != FALSE ){ + i = j + mem[j].nsize; + found = FALSE; + if( first == 0 ) first = 1; + break; + } + } + if( found ) { + mem[i].used=TRUE; + mem[i].nsize = arrayAllocSize; + readblock = i + arrayAllocSize; + ret = mem[i].pointer; + break; + } + } + if( ( i >= readblock || i > UNITNUMBER - arrayAllocSize ) + && flg == TRUE ) { + ret = NULL; + break; + } + if( i > UNITNUMBER - arrayAllocSize) { + i = 0; + flg = TRUE; + } + + } + if( ret == NULL ) { + print( "Can't Allocate %d byte .remnants:%4.2f\n" , nbyte, (float)(NowMemory/UNITNUMBER)); + }else { + NowMemory += arrayAllocSize; + + if( NowTime.tv_sec > AllocOldTime.tv_sec +10 ) { + print( "\n"); + if( NowMemory > (double)UNITNUMBER * 0.9) { + print( "Warning!! Memory use rate exceeded 90%% .remnants:%d\n", UNITNUMBER-NowMemory); + }else if( NowMemory > (double)UNITNUMBER * 0.8) { + print( "Warning!! Memory use rate exceeded 80%% .remnants:%d\n", UNITNUMBER-NowMemory); + }else if( NowMemory > (double)UNITNUMBER * 0.7) { + print( "Memory use rate exceeded 70%% .remnants:%d\n", UNITNUMBER-NowMemory); + } + memcpy( &AllocOldTime, &NowTime, sizeof( AllocOldTime)); + } + //print( "NowMemory.remnants:%4.2f\n", (float)(UNITNUMBER-NowMemory)/UNITNUMBER); + } + + return ret; + +} + + + +/*------------------------------------------------------------ + * allocateMemory匹割忡仄凶丢乒伉□毛free允月[ + * 娄醒 + * freepointer int 割忡允月燮 及禾奶件正□ + * 忒曰袄 + * 卅仄 + ------------------------------------------------------------*/ +void freeMemory( void* freepointer ) +{ + int arrayindex; + char* toppointer; + toppointer = mem[0].pointer; + if( freepointer == NULL )return; + arrayindex = ((int)freepointer-(int)toppointer)/UNIT; + if( arrayindex < readblock) { + readblock = arrayindex; + } + mem[arrayindex].used = FALSE; + + NowMemory -= mem[arrayindex].nsize; + +} + +void showMem( char *buf) +{ + sprintf( buf, "NowMemory.remnants:%d%%", ((UNITNUMBER-NowMemory)*100)/UNITNUMBER); + printf( "\n" ); + printf( buf ); +} + diff --git a/gmsv/callfromac.c b/gmsv/callfromac.c new file mode 100644 index 0000000..eb3a26d --- /dev/null +++ b/gmsv/callfromac.c @@ -0,0 +1,1854 @@ +#include +#include "version.h" +#include "common.h" +#include "saacproto_cli.h" +#include "lssproto_serv.h" +#include "net.h" +#include "char.h" +#include "object.h" +#include "readmap.h" +#include "msignal.h" +#include "map_deal.h" +#include "npc_duelranking.h" +#include "npc_warpman.h" +#include "handletime.h" +#include "npc_scheduleman.h" +#include "configfile.h" +#include "chatroom.h" +#ifdef _PAUCTION_MAN +#include "npc_pauctionman.h" +#endif +#include "npc_eventaction.h" +// CoolFish: Family 2001/5/24 +#include "family.h" +#include "defend.h" +#include "log.h" +#include "buf.h" +#ifdef _ALLDOMAN // (不可开) Syu ADD 排行榜NPC +#include "npc_alldoman.h" +#endif + +#ifdef _RACEMAN +#include "npc_raceman.h" +#endif + +#ifdef _DEATH_CONTEND +#include "deathcontend.h" +#endif +time_t initTime =0; + +extern BOOL bNewServer; + +extern int i_shutdown_time;//ttom + +void saacproto_ACGmsvDownRequest_recv( int fd, int min) +{ + char buff[256]; + int i; + int playernum = CHAR_getPlayerMaxNum(); + + snprintf( buff, sizeof( buff),"极度的系统公告。"); + for( i = 0 ; i < playernum ; i++) { + if( CHAR_getCharUse(i) != FALSE ) { + CHAR_talkToCli( i, -1, buff, CHAR_COLORYELLOW); + } + } + SERVSTATE_setLimittime(min); + SERVSTATE_setShutdown( NowTime.tv_sec ); + SERVSTATE_setDsptime( 0 ); + +} +//检查是否有和ac连接,以及载入家族 +void saacproto_ACServerLogin_recv (int fd, char* result,char* data) +{ + if( strcmp( result , SUCCESSFUL ) != 0 ){ + /* 夫弘奶件撩 */ + print( "saacproto_ACServerLogin fail! so quitting...[%s][%s]\n", + result,data ); + shutdownProgram( ); + exit(1); + } + print("SAAC登陆成功\n"); + time(&initTime); + if( bNewServer ) + print("新服务器! "); + else + print("旧服务器! "); +#ifdef _SERVER_NUMS + print( " 版本 : <%s>" , SERVER_VERSION); +#endif + print(" 正常服务器!\n"); + + // Robin 0530 + //saacproto_ACShowFMList_send( acfd ); + FAMILY_Init(); +#ifdef _UNIVERSE_CHATROOM + CHATROOM_getChatRoomList(); +#endif + +#ifdef _ANGEL_SUMMON + saacproto_ACMissionTable_send( acfd, -1, 1, "", ""); +#endif +} + +void saacproto_ACCharList_recv(int fd, char* result, char* data,int retfd) +{ + int clifd = getfdFromFdid(retfd); + + + if( CONNECT_checkfd(clifd) == FALSE ){ + return; + } + lssproto_CharList_send( clifd, result , data ); + CONNECT_setState( clifd, NOTLOGIN ); +} + +void saacproto_ACCharLoad_recv(int fd , char* result,char* data,int retfd,int saveindex) +{ + int clifd = getfdFromFdid(retfd); + if( CONNECT_checkfd( clifd ) == FALSE )return; + + if(( strcmp( result , SUCCESSFUL ) == 0 )&&(data[0])) { +#ifdef _BAD_PLAYER // WON ADD 送坏玩家去关 + CHAR_login( clifd, data, saveindex, 0 ); // 正常玩家 + }else if( ( strcmp( result , BADPLAYER ) == 0 ) && (data[0]) ){ + CHAR_login( clifd, data, saveindex, 1 ); // 坏玩家 +#else + CHAR_login( clifd,data,saveindex ); +#endif + + }else{ + char cdkey[64]; +#ifndef _FIX_MESSAGE // WON ADD 修改WORKER封包内容 + data = ""; +#endif + CONNECT_getCdkey( clifd, cdkey , sizeof( cdkey )); + print(" (%s)ACCharLoad错误:%s ", cdkey, data); + lssproto_CharLogin_send( clifd, result ,data ); + CONNECT_setState( clifd, NOTLOGIN ); + } +} + +#ifdef _DEATH_CONTEND +void saacproto_LoadPkTeamListData_recv(int fd , char* result, char* data, int ti ) +{ + //andy_log + print("加载PK团队数据接收( %s, %d) 数据长度:%d\n", result, ti, strlen(data) ); + if( !strcmp( result, "success") ){ + if( PKLIST_LoadPkTeamListData() == FALSE ) return; + if( ti != - 1 ) + saacproto_LoadPkTeamListData_send( fd , ti, 1000); + } +} +//要求资讯 +void saacproto_PKLISTCHARTS_recv( int fd, char *data, int type, int flg) +{ + //andy_log + print("接收PK名称() \n"); + if( data == NULL ) return; + PKLIST_HandleChartsMess( fd, data, type, flg); +} + +#endif + +#ifdef _PAUCTION_MAN +void saacproto_ACItemAuction_recv( int fd, char *ITEMNAME, char *data, int itemID, int ret, int flg) +{ + //物品处理 + switch( flg) { + case 1: + { + int itemindex=-1; + itemindex = NPC_PAItemShop_AddItem( itemID, ret); + if( !ITEM_CHECKINDEX( itemindex) ) + return; + NPC_PAItemShop_reItem( itemindex, data); + } + break; + case 2: + { + NPC_PAItemShop_DelItem( ret, -1); + } + break; + } +} +#endif + +/* + *本□皮卞凶中允月忒蚕[ + * state卞方匀化质 毛坌仃月 + */ + +void saacproto_ACCharSave_recv(int fd ,char* result, char* data,int retfd) +{ + int clifd = getfdFromFdid(retfd) , fdid; + char cdkey[CDKEYLEN], passwd[PASSWDLEN], charname[CHARNAMELEN]; + /* + * 端巨仿□匹手卅中及卞仇仇匹反元井木月仪反丐月 + * 公木反}中五卅曰涛粮毛濠匀凶凛分[ + */ + if( CONNECT_checkfd( clifd )== FALSE ) return; + + CONNECT_getCdkey( clifd, cdkey, sizeof( cdkey )); + CONNECT_getPasswd( clifd, passwd, sizeof( passwd)); + + CONNECT_getCharname( clifd, charname, sizeof( charname )); + + fdid = CONNECT_getFdid( clifd ); + switch( CONNECT_getState( clifd ) ){ + case WHILECREATE: + /* 平乓仿综曰匹及本□皮 */ + /* 公木毛弁仿奶失件玄卞中丹( 公及引引 )*/ + if( strcmp(result,FAILED) ==0 ) data =""; + lssproto_CreateNewChar_send( clifd , result , data); + CONNECT_setState( clifd, NOTLOGIN ); + break; + + case WHILELOGOUTSAVE: + /* 骚及夫弘失它玄及凛及本□皮及忒蚕 */ + if( strcmp( result , SUCCESSFUL ) == 0 ) + /* 岳 */ + lssproto_CharLogout_send( clifd, result , "success" ); + else + /* 巨仿□支午仄扎屯月 */ + lssproto_CharLogout_send( clifd, result , "Cannot save" ); + CONNECT_setState( clifd, NOTLOGIN ); + CONNECT_setCharaindex( clifd, -1 ); + break; + + case WHILELOSTCHARSAVE: + /* 瑛绊互升丹匹丐木}仇及平乓仿反绰轮允月 */ + saacproto_ACCharDelete_send( acfd, cdkey,passwd,charname,"",fdid ); + CONNECT_setState( clifd, WHILELOSTCHARDELETE ); + CONNECT_setCharaindex( clifd, -1 ); + break; + + case WHILECLOSEALLSOCKETSSAVE: + CONNECT_setState( clifd, NOTLOGIN ); + // Arminius debug + // CONNECT_endOne_debug(clifd); + CONNECT_setUse( clifd , FALSE); + + SERVSTATE_decrementCloseallsocketnum(); + if( SERVSTATE_getCloseallsocketnum() == 0 ) { + SERVSTATE_SetAcceptMore( -1 ); + print( "所有人物存档\n" ); + print("\n 关闭服务器时间 =%d",i_shutdown_time);//ttom + if(i_shutdown_time==1){ + system( "正常关闭" ); + sigshutdown( 0 ); + } + } + default: + break; + } +} + + +void saacproto_ACCharDelete_recv(int fd,char* result,char* data,int retfd) +{ + int clifd = getfdFromFdid(retfd); + if( CONNECT_checkfd( clifd ) == FALSE )return; + + switch( CONNECT_getState(clifd) ){ + case WHILELOSTCHARDELETE: + /* 夫旦玄匹平乓仿壅仄 及忒蚕 */ + /* 窒手仄卅中 */ + /* 橇谪毛 允 */ + CONNECT_setState(clifd, NOTLOGIN ); + CONNECT_setCharaindex( clifd, -1 ); + break; + case WHILECHARDELETE: + /* 骚及平乓仿壅仄 */ + /* 公及引引霜月 */ + if( strcmp(result,FAILED) == 0)data=""; + lssproto_CharDelete_send( clifd, result , data ); + CONNECT_setState( clifd, NOTLOGIN ); + CONNECT_setCharaindex( clifd, -1 ); + break; + default: + break; + } +} + +/* + * 夫永弁及忒蚕[仇木反荸轮卞仄井银歹卅中[蜇箕幻廿银歹木月 烂反卅中 + */ +void saacproto_ACLock_recv(int fd , char* result, char* data ,int retfd) +{ + int clifd = getfdFromFdid(retfd); + char cdkey[CDKEYLEN]; + int cindex = getCharindexFromFdid(retfd); + + if( CONNECT_checkfd(clifd) == FALSE) return; + + // Arminius 7.25 GM unlock test + if (strncmp(data, "USRLOCKED", 9)==0) { + char buf[4096]; + sprintf(buf, "%s", &data[10]); + CHAR_talkToCli(cindex, -1, buf, CHAR_COLORYELLOW); + return; + } else if (strncmp(data, "USRUNLOCKED", 11)==0) { + CHAR_talkToCli(cindex, -1, "User not locked.", CHAR_COLORYELLOW); + return; + } else if (strncmp(data, "GMUNLOCKSUCCESS", 15)==0) { + CHAR_talkToCli(cindex, -1, "User unlock success", CHAR_COLORYELLOW); + return; + } else if (strncmp(data, "GMUNLOCKFAIL", 12)==0) { + CHAR_talkToCli(cindex, -1, "User unlock failed", CHAR_COLORYELLOW); + return; + } else if (strncmp(data, "GMUNLOCKALL", 11)==0) { + CHAR_talkToCli(cindex, -1, "Server unlocked", CHAR_COLORYELLOW); + return; + } + + CONNECT_getCdkey( clifd, cdkey , sizeof( cdkey )); + + switch( CONNECT_getState( clifd ) ){ + case WHILECANNOTLOGIN: + /* 夫弘奶件撩 仄凶凛及夫永弁及忒蚕 */ + if( strcmp( result , SUCCESSFUL ) == 0 ){ + /* 岳 匹窒手仄化中卅中橇谪卞允月 */ + CONNECT_setState( clifd, NOTLOGIN ); + + }else{ + /* + * 丢永本□斥毛苇月 + */ + char mesg[128]; + snprintf( mesg ,sizeof( mesg ), "%s hasn't been locked" ,cdkey); + if( strcmp( data , mesg ) == 0 ){ + /* + * 夫永弁今木化中卅中及匹手丹窒手仄卅中[ + * 岳 仄凶及午 元健中卞允月[ + */ + CONNECT_setState( clifd, NOTLOGIN ); + }else{ + /* + * 疯蘸夫永弁荸轮仄方丹午允月 + * state 及 祭卅仄[ + */ + saacproto_ACLock_send(fd, cdkey , + UNLOCK, CONNECT_getFdid( clifd) ); + } + } + + break; + default: + break; + } +} + +void saacproto_ACUCheck_recv( int fd , char *cd ) +{ + int conind; + int flag = 0; + conind = getfdFromCdkeyWithLogin( cd ); + flag = ( conind >= 0 ) ? 1 : 0; + saacproto_ACUCheck_send( fd , cd , flag ); +} + + +/* --------------------------------------------- + * 犯□正矛□旦凳蕙熬仃午曰质 醒袄 + * --------------------------------------------*/ +void saacproto_DBUpdateEntryInt_recv( int fd,char* result, + char* table,char* key,int msgid,int msgid2 ) +{ + if( strcmp( result, NET_STRING_FAILED) == 0 ) { + print( "failed: DBUpdateEntryInt\n"); + return; + } +} +/* --------------------------------------------- + * 犯□正矛□旦凳蕙熬仃午曰质 侬 + * --------------------------------------------*/ +void saacproto_DBUpdateEntryString_recv( int fd,char* result, + char* table,char* key,int msgid,int msgid2 ) +{ + if( strcmp( result, NET_STRING_FAILED) == 0 ) { + print( "failed: DBUpdateEntryString\n"); + return; + } +} + +/* --------------------------------------------- + * 犯□正矛□旦熬仃午曰质 仿件弁 + * --------------------------------------------*/ +void saacproto_DBGetEntryRank_recv( int fd,char* result,int rank,int count, + char* table,char* key,int msgid,int msgid2 ) +{ + if( strcmp( result, NET_STRING_FAILED) == 0 ) { + print( "failed: DBGetEntryRank\n"); + return; + } + if( strcmp( table, DB_DUELPOINT) == 0 ) { + if( CHAR_getInt( OBJECT_getIndex( msgid2), CHAR_WHICHTYPE) == CHAR_TYPEDUELRANKING){ + NPC_Duelranking_CallMyRanking( count, msgid, msgid2); + }else { + NPC_GetDuelRank( rank, msgid, msgid2); + } + } +} + +void saacproto_DBDeleteEntryInt_recv( int fd,char* result, + char* table,char* key,int msgid,int msgid2 ) +{ + if( strcmp( result, NET_STRING_FAILED) == 0 ) { + print( "failed: DBDeleteEntryInt\n"); + return; + } + +} +/* --------------------------------------------- + * 犯□正矛□旦绰轮熬仃午曰质 侬 + * --------------------------------------------*/ +void saacproto_DBDeleteEntryString_recv( int fd,char* result, + char* table,char* key,int msgid,int msgid2 ) +{ + if( strcmp( result, NET_STRING_FAILED) == 0 ) { + print( "failed: DBDeleteEntryString\n"); + return; + } + +} + + +/* --------------------------------------------- + * 犯□正矛□旦熬仃午曰质 醒袄 + * --------------------------------------------*/ +void saacproto_DBGetEntryInt_recv( int fd,char* result,int value, + char* table,char* key,int msgid,int msgid2 ) +{ + if( strcmp( result, NET_STRING_FAILED) == 0 ) { + print( "failed: DBGetEntryInt\n"); + return; + } +} +/* --------------------------------------------- + * 犯□正矛□旦熬仃午曰质 侬 + * --------------------------------------------*/ +void saacproto_DBGetEntryString_recv( int fd,char* result,char *value, + char* table,char* key,int msgid,int msgid2 ) +{ + char cdkey[32]; + char charaname[32]; + + if( strcmp( table, DB_ADDRESSBOOK) == 0 ){ + int mode = 1; + if( strcmp( result, NET_STRING_FAILED) == 0 ) { + mode = 0; + } + makeStringFromEscaped( key); + if( !getStringFromIndexWithDelim( key, "_", 1, cdkey, sizeof( cdkey)) ){ + return; + } + if( !getStringFromIndexWithDelim( key, "_", 2, charaname, sizeof( charaname)) ){ + return; + } + ADDRESSBOOK_DispatchMessage( cdkey, charaname, value, mode); + }else { + if( strcmp( result, NET_STRING_FAILED) == 0 ) { + print( "failed: DBGetEntryString\n"); + return; + } + } +} + +void saacproto_DBGetEntryByRank_recv( int fd,char* result,char* list, + char* table,int msgid,int msgid2 ) +{ + if( strcmp( result, NET_STRING_FAILED) == 0 ) { + print( "failed: DBGetEntryByRank\n"); + return; + } +} +/* --------------------------------------------- + * 犯□正矛□旦熬仃午曰质 市它件玄 + * --------------------------------------------*/ +void saacproto_DBGetEntryByCount_recv( int fd,char* result,char* list, + char* table,int count_start,int msgid,int msgid2 ) +{ + if( strcmp( result, NET_STRING_FAILED) == 0 ) { + print( "failed: DBGetEntryByCount\n"); + return; + } + /* duelpoint database 及质 */ + if( strcmp( table, DB_DUELPOINT) == 0 ) { + NPC_Duelranking_PrintRanking( list, count_start, msgid, msgid2); + } +} +#ifdef _ALLDOMAN // (不可开) Syu ADD 排行榜NPC +void saacproto_UpdataStele_recv( int fd , char *token) +{ + NPC_AlldomanWriteStele( token ); +} +void saacproto_S_UpdataStele_recv( int i , char *ocdkey , char *oname , char *ncdkey , + char *nname , char *title , int level , int trns , int floor ) +{ + print("\nSyu log 收到Single=> %s , %s , %s , %s ",ocdkey , oname , ncdkey , nname); + NPC_Alldoman_S_WriteStele( ocdkey , oname , ncdkey , nname , title , level , trns , floor ) ; +} + +#endif +/* --------------------------------------------- + * 皮夫□玉平乓旦玄丢永本□斥熬仃午曰 + * --------------------------------------------*/ +void saacproto_Broadcast_recv( int fd,char* id,char* charname,char *message ) +{ +#ifndef _DEATH_CONTEND + if( strstr( message, "online") == 0 || + strstr( message, "offline") == 0 || + strstr( message, "param") == 0 || + strstr( message, "chardelete") == 0 ){ + char buff[512]; + char escapebuf[1024]; + + snprintf( buff, sizeof( buff),"%s_%s", id, charname ); + makeEscapeString( buff, escapebuf, sizeof(escapebuf)); + + saacproto_DBGetEntryString_send( acfd, DB_ADDRESSBOOK, escapebuf, 0,0); + } +#endif +} + +void saacproto_Message_recv( int fd,char* id_from,char* charname_from, + char* id_to,char* charname_to, + char* message,int option,int mesgid ) +{ + BOOL ret; + ret = ADDRESSBOOK_sendMessage_FromOther( id_from, charname_from, + id_to, charname_to, + message, option + ); + if( ret == TRUE) { + saacproto_MessageAck_send( acfd, id_to, charname_to, + "successful",mesgid); + } +} + +/* --------------------------------------------- + * CoolFish: Family 2001/5/9 + * --------------------------------------------*/ +void saacproto_ACAddFM_recv(int fd, char *result, int fmindex, int charfdid, + int index) +{ + int ret; + int clifd = getfdFromFdid(charfdid); +// print("ACAddFM_0\n"); + if (CONNECT_checkfd(clifd) == FALSE) return; + if (strcmp(result, SUCCESSFUL) == 0) ret = 1; + else ret = 0; +// print("ACAddFM_1 clifd:%d ret:%d fmindex:%d index:%d\n", +// clifd, ret, fmindex, index); + ACAddFM(clifd, ret, fmindex, index); +} +void saacproto_ACJoinFM_recv(int fd, char *result, int recv, int charfdid) +{ + int ret; + int clifd = getfdFromFdid(charfdid); + if (CONNECT_checkfd(clifd) == FALSE) return; + if (strcmp(result, SUCCESSFUL) == 0) ret = 1; + else ret = 0; + ACJoinFM(clifd, ret, recv); +} +void saacproto_ACLeaveFM_recv(int fd, char *result, int resultflag, int charfdid) +{ + int ret; + int clifd = getfdFromFdid(charfdid); + if (CONNECT_checkfd(clifd) == FALSE) return; + if (strcmp(result, SUCCESSFUL) == 0) ret = 1; + else ret = 0; + ACLeaveFM(clifd, ret, resultflag); + + print(" ACLeaveFM_%d ", ret ); +} +void saacproto_ACChangeFM_recv(int fd, char *result, int charfdid) +{ + +} +void saacproto_ACDelFM_recv(int fd, char *result, int charfdid) +{ + int ret; + int clifd = getfdFromFdid(charfdid); + if (CONNECT_checkfd(clifd) == FALSE) return; + if (strcmp(result, SUCCESSFUL) == 0) ret = 1; + else ret = 0; + + ACDelFM(clifd, ret); + + print(" ACDelFM_%d ", ret); +} +void saacproto_ACShowFMList_recv(int fd, char *result, int fmnum, char *data) +{ + int ret; + if (strcmp(result, SUCCESSFUL) == 0) ret = 1; + else ret = 0; + ACShowFMList(ret, fmnum, data); +} + +#ifdef _DEATH_FAMILY_GM_COMMAND // WON ADD 家族战GM指令 +void saacproto_ACRELOADFMOK_recv( int fd, int charindex ) +{ + CHAR_talkToCli( charindex, -1, "重读家族资料OK!", CHAR_COLORYELLOW); + +} + +void saacproto_ACSHOWMEMBERLIST2_recv( int fd, int charaindex, int fm1, char *fm1_name, int fm2, char *fm2_name, int time, int id ) +{ + int i, hour = 0, min = 0; + int fmpks_pos = id * 24; + char f1[20] = {0}, f2[20] = {0}; + + hour = time / 100; + min = time % 100; + + if( fm1_name == NULL || fm2_name == NULL ) return; + + sprintf( f1, "%s", fm1_name ); + sprintf( f2, "%s", fm2_name ); + + for( i=0; i 0 ) { + CHAR_setInt( charaindex, CHAR_GOLD, CHAR_getInt( charaindex, CHAR_GOLD ) +atoi(data1) ); + } + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_GOLD); + return; + }else { + if( atoi(data1) < 0 ) { + CHAR_setInt( charaindex, CHAR_GOLD, CHAR_getInt( charaindex, CHAR_GOLD ) -atoi(data1) ); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_GOLD); + } +#ifdef _FAMILYBANKSTONELOG + CHAR_setInt(charaindex,CHAR_FMBANKGOLD,CHAR_getInt(charaindex,CHAR_FMBANKGOLD)+intdata); + LogFamilyBankStone( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), + intdata, + CHAR_getInt( charaindex, CHAR_GOLD ), + (intdata>0)?"FMBank(存款)(家族银行)":"FMBank(取款)(家族银行)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + CHAR_getInt( charaindex,CHAR_FMBANKGOLD) + ); +#else + LogStone( + atoi(data2), + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), + -intdata, + CHAR_getInt( charaindex, CHAR_GOLD ), + "FMBank(家族银行)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ) + ); +#endif + } + }else if( kindflag == FM_FIX_FMLEADERCHANGE ){ + ACFMJob( clifd, ret, data1, data2 ); + } + // CoolFish: 2001/10/03 + else if (kindflag == FM_FIX_FMADV || kindflag == FM_FIX_FMFEED + || kindflag == FM_FIX_FMSYNTHESIZE || kindflag == FM_FIX_FMDEALFOOD) + { + char tmpbuf[1024], flag[128]; +#ifdef _NEW_MANOR_LAW + int i; +#endif + if (kindflag == FM_FIX_FMADV) strcpy(flag, "ADV"); + else if (kindflag == FM_FIX_FMFEED) strcpy(flag, "FEED"); + else if (kindflag == FM_FIX_FMSYNTHESIZE) strcpy(flag, "SYN"); + else if (kindflag == FM_FIX_FMDEALFOOD) strcpy(flag, "FOOD"); + sprintf(tmpbuf, "%s::%d %s %s", flag, + CHAR_getInt(charaindex, CHAR_FMINDEX), + CHAR_getChar(charaindex, CHAR_FMNAME), data1); + // print("ACFixFMData tmpbuf:%s\n", tmpbuf); + LogFMPOP(tmpbuf); +#ifdef _NEW_MANOR_LAW + for(i=0;i= FAMILY_MAXNUM ){ + print(" fmindex:%d if FALSE !!\n", fmindex); + return; + } + familyTax[ fmindex] = data; + sprintf( buf, "B|T|%d", data ); + lssproto_FM_send( clifd, buf ); + } + +} +void saacproto_ACFMClearPK_recv(int fd, char *result, char *fmname, int fmindex, + int index) +{ + int ret, i = 0; + + if (strcmp(result, SUCCESSFUL) == 0) ret = 1; + else ret = 0; + for (i = 0; i < MAX_SCHEDULEMAN * MAX_SCHEDULE; i++) + { + { + if (fmpks[i].flag == -1) continue; + if (fmpks[i].host_index == index + || fmpks[i].guest_index == index) + { + fmpks[i].host_index = -1; + strcpy(fmpks[i].host_name, ""); + fmpks[i].guest_index = -1; + strcpy(fmpks[i].guest_name, ""); + fmpks[i].prepare_time = -1; + fmpks[i].max_player = -1; + fmpks[i].win = -1; + fmpks[i].flag = -1; + } + } + } +} + +#ifdef _ACFMPK_LIST +void saacproto_ACSendFmPk_recv( int fd, int toindex, int flg) +{ + char buf[256]; + if( flg == 0){ + sprintf( buf, "庄园挑战登录失败!!"); + CHAR_talkToCli( toindex, -1, buf, CHAR_COLORRED); + }else{ + sprintf( buf, "庄园挑战登录确认OK,请好好准备。"); + CHAR_talkToCli( toindex, -1, buf, CHAR_COLORYELLOW); + } +} +void saacproto_ACLoadFmPk_recv(int fd, char *data) +{ + char buf[10], fm_pk_data[128]; + char token[256], skip[256]; + int fm_pk_num , fmpks_pos=-1; + + easyGetTokenFromString( data , 1 , buf , sizeof(buf)); + fm_pk_num = atoi(buf); + sprintf(fm_pk_data , "%s", data+2 ); + + if( ((fmpks_pos=fm_pk_num*MAX_SCHEDULE)== -1) || (fm_pk_num > FMPOINTNUM) ){ + print("\n err fm_pk_num(%d)", fm_pk_num ); + return; + } + // 时间 + if (getStringFromIndexWithDelim(data,"|",2,token,sizeof(token))) { + fmpks[fmpks_pos+1].dueltime=atoi(token); + } + // 主队 familyindex + if (getStringFromIndexWithDelim(data,"|",3,token,sizeof(token))) { + fmpks[fmpks_pos+1].host_index=atoi(token); + } + // 主队 家族名 + if (getStringFromIndexWithDelim(data,"|",4,token,sizeof(token))) { + strcpy(fmpks[fmpks_pos+1].host_name,makeStringFromEscaped(token)); + } + // 客队 familyindex + if (getStringFromIndexWithDelim(data,"|",5,token,sizeof(token))) { + fmpks[fmpks_pos+1].guest_index=atoi(token); + } + // 客队 家族名 + if (getStringFromIndexWithDelim(data,"|",6,token,sizeof(token))) { + strcpy(fmpks[fmpks_pos+1].guest_name,makeStringFromEscaped(token)); + } + // 准备时间 + if (getStringFromIndexWithDelim(data,"|",7,token,sizeof(token))) { + fmpks[fmpks_pos+1].prepare_time=atoi(token); + } + // 最大人数 + if (getStringFromIndexWithDelim(data,"|",8,token,sizeof(token))) { + int maxnum = atoi( token); + if( maxnum < 50 ) maxnum = 50; + fmpks[fmpks_pos+1].max_player = maxnum; + } + // 旗标 + if (getStringFromIndexWithDelim(data,"|",9,token,sizeof(token))) { + fmpks[fmpks_pos+1].flag=atoi(token); + } + if( fmpks[fmpks_pos+1].flag == FMPKS_FLAG_MANOR_OTHERPLANET ){ + // 对战星球 + if (getStringFromIndexWithDelim(data,"|",10,token,sizeof(token))) { + strcpy(fmpks[fmpks_pos+2].host_name,makeStringFromEscaped(token)); + strcpy(skip, makeStringFromEscaped(token)); + if (strcmp(getGameserverID(), skip)==0) { + fmpks[fmpks_pos+1].flag=8; + }else if( fmpks[fmpks_pos+1].flag == 8) { + fmpks[fmpks_pos+1].flag=10; + } + } + }else{ + strcpy( fmpks[fmpks_pos+2].host_name, ""); + } +} +#endif + + +void saacproto_ACManorPKAck_recv(int fd, char *data) +{ + // 更新这个 server 的 庄园 pk scheduleman + int i; + char token[256], skip[256]; + int char_max=CHAR_getCharNum(); + + print("ACManorPKAck_recv: %s\n",data); + + for (i=0; i= 990000 ){ + sprintf( buf,"帐号人物[%s]持有石币将超过100万,取消领取资格!", CdKey); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + }else{ + NPC_ActionAddGold( charaindex, 10000); + } + break; + case NEW_DELERR: //新帐号人物删除发生错误! + CHAR_talkToCli( charaindex, -1, "此帐号人物无法领取石币!", CHAR_COLORYELLOW); + break; + case NEW_ADDOK: + sprintf( buf,"新帐号人物[%s]增加完成!", CdKey); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + break; + case NEW_ADDERR: + sprintf( buf,"新帐号人物[%s]增加发生错误!", CdKey); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + break; + case NEW_LISTFULL: + CHAR_talkToCli( charaindex, -1, "新帐号人物列表已满!", CHAR_COLORYELLOW); + break; + } +} +#endif + + +#ifdef _NEW_PLAYERGOLD +void saacproto_LoadNEWPlayer_recv(int fd , int charaindex, char *data) +{ + CHAR_talkToCli( charaindex, -1, data, CHAR_COLORYELLOW); +} +#endif + +#ifdef _WAEI_KICK +void saacproto_ACKick_recv(int fd , int act, char* data ,int retfd) +{ + int clifd = getfdFromFdid(retfd); + //char cdkey[CDKEYLEN]; + int cindex = getCharindexFromFdid(retfd); + + print("状态:%s \n", data); + + switch( act) { + case 0: //FAIL + if( CONNECT_checkfd(clifd) == FALSE) return; + CHAR_talkToCli( cindex, -1, data, CHAR_COLORYELLOW); + break; + case 1: //跨星球踢人 + { + char cdkey[256]; + char szName[256]; + int i, MAX_USER=0; + BOOL find=FALSE; + + print(" SAAC踢人:%s ", data); + + MAX_USER=getFdnum(); + for(i=0;i%s ", fd_charaindex, cdkey); + CHAR_talkToCli( fd_charaindex, -1, "因准备移民而断线!", + CHAR_COLORYELLOW); + } +#endif +#ifdef _TIMEOUTKICK + else if( retfd == -3 ){ // Robin add + print(" 因WGS点数不足:%d->%s ", fd_charaindex, cdkey); + CHAR_talkToCli( fd_charaindex, -1, "您的WGS点数不足!", + CHAR_COLORYELLOW); + } +#endif + else{ + print(" 因做坏事 "); + CHAR_talkToCli(fd_charaindex, -1, "因做坏事而断线。", + CHAR_COLORYELLOW); + } + CONNECT_setCloseRequest( i , 1 ); + find=TRUE; + } + } + } + + if( find == TRUE && retfd != -1 && CHAR_CHECKINDEX( cindex) ) { + char buf1[256];//, buf2[256]; + sprintf(buf1,"系统将[%s]逐出伺服器。", /*CHAR_getChar( cindex, CHAR_NAME),*/ szName); + for( i=0; iindexOfExistDepotItems = allocateMemory( sizeof( int ) * CHAR_MAXDEPOTITEMHAVE ); + if( ch->indexOfExistDepotItems == NULL ) return; + for( i=0; iindexOfExistDepotItems[i] = -1; + + if( CHAR_makeDepotItemStringToChar( charaindex, data) == FALSE ){ + CHAR_talkToCli( charaindex, -1, "道具仓库资料读取失败!", CHAR_COLORYELLOW); + CHAR_removeDepotItem( charaindex); + return; + } + if( !CHAR_CHECKINDEX( meindex) ) return; + if( clifd != -1 ) { + char message[1024]; + char buf[1024]; + strcpy( message, + "3\n\n" + " 使用道具仓库\n\n" + " <存放道具>\n" + " <取回道具>\n" + ); + lssproto_WN_send( clifd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_CANCEL, + 311, //CHAR_WINDOWTYPE_DEPOTITEMSHOP_HANDLE, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( message, buf, sizeof(buf)) ); + } + +} + +#endif//,。! + + +#ifdef _CHAR_POOLPET +void saacproto_ACCharSavePoolPet_recv(int fd ,char* result, char* data,int retfd) +{ + int charaindex = getCharindexFromFdid( retfd); + if( !CHAR_CHECKINDEX(charaindex) ) return; + if( strstr( result, FAILED ) != NULL ){ + CHAR_talkToCli( charaindex, -1, "宠物仓库资料存档失败!", CHAR_COLORYELLOW); + return; + + } +} + +void saacproto_ACCharGetPoolPet_recv(int fd ,char* result, char* data,int retfd, int meindex) +{ + Char* ch = NULL; + int i, clifd, charaindex; + + if( strcmp( result , SUCCESSFUL ) != 0 ) return; + charaindex = getCharindexFromFdid(retfd); + if( !CHAR_CHECKINDEX( charaindex) ) return; + clifd = getfdFromCharaIndex( charaindex); + if( CHAR_CheckDepotPet( charaindex) ) return;//仓库已存在 + + if( (ch = CHAR_getCharPointer( charaindex)) == NULL ) return; + ch->indexOfExistDepotPets = allocateMemory( sizeof( int ) * CHAR_MAXDEPOTPETHAVE ); + if( ch->indexOfExistDepotPets == NULL ) return; + for( i=0; iindexOfExistDepotPets[i] = -1; + + if( CHAR_makeDepotPetStringToChar( charaindex, data) == FALSE ){ + CHAR_talkToCli( charaindex, -1, "宠物仓库资料读取失败!", CHAR_COLORYELLOW); + CHAR_removeDepotPet( charaindex); + return; + } + if( !CHAR_CHECKINDEX( meindex) ) return; + if( clifd != -1 ) { + char message[1024]; + char buf[1024]; + strcpy( message, + "3\n\n" + " 使用宠物仓库\n\n" + " <存放宠物>\n" + " <取回宠物>\n" + ); + lssproto_WN_send( clifd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_DEPOTPETSHOP_HANDLE, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( message, buf, sizeof(buf)) ); + } + +} + +#endif + + +#ifdef _UNIVERSE_CHATROOM//ACUniChatroom +void saacproto_ACUniChatroom_recv( int acfd, int charaindex, int clifdid, char *result, + char *CdKey, char *data) +{ + saac_ChatRoom_recvall ( acfd, result, data, charaindex, clifdid ); +} +#endif + + +#ifdef _ANGEL_SUMMON +//void saacproto_ACMissionTable_recv( int fd, int num, int type, char *data, int charaindex) +void saacproto_ACMissionTable_recv( int fd, int num, int type, char *data, char* angelinfo) +{ + char msg[1024]; + + if( type == 1 ) { // get data list + //if( num == -1) // get all data + { + int di, ti; + char onedata[1024], token[1024]; + + if( num == -1 ) { + print("获得所有任务!!\n"); + memset( missiontable, 0, sizeof(missiontable)); + } + else + print("获得一个任务!!:%s\n", data); + + for( di =1; di = MAXMISSIONTABLE) continue; + getStringFromIndexWithDelim( onedata, "|", 2, token, sizeof(token)); + strcpy( missiontable[ti].angelinfo, token); + getStringFromIndexWithDelim( onedata, "|", 3, token, sizeof(token)); + strcpy( missiontable[ti].heroinfo, token); + getStringFromIndexWithDelim( onedata, "|", 4, token, sizeof(token)); + missiontable[ti].mission = atoi( token); + getStringFromIndexWithDelim( onedata, "|", 5, token, sizeof(token)); + missiontable[ti].flag = atoi( token); + getStringFromIndexWithDelim( onedata, "|", 6, token, sizeof(token)); + missiontable[ti].time = atoi( token); + getStringFromIndexWithDelim( onedata, "|", 7, token, sizeof(token)); + missiontable[ti].limittime = atoi( token); + } + } + } + else if( type == 2 ) { // add data return + int angelindex =-1, i, maxChar; + char nameinfo[128], msgbuf[1024]; + + if( num == -1) { + sprintf( msg, "任务已满\n"); + print( msg); + LogAngel( msg); + return; + } + + sprintf( msgbuf, "收到AC回应(add data) num=%d nameinfo=%s ", num, angelinfo); + print( msgbuf); + LogAngel( msgbuf); + + maxChar = CHAR_getPlayerMaxNum(); + for( i =0; i = MAXMISSIONTABLE) return; + + sprintf( msg, " AC清除 任务:%d %s %s ", num, missiontable[num].angelinfo, missiontable[num].heroinfo); + print( msg); + LogAngel( msg); + + strcpy( missiontable[num].angelinfo, ""); + strcpy( missiontable[num].heroinfo, ""); + missiontable[num].mission = 0; + missiontable[num].flag = 0; + missiontable[num].time = 0; + missiontable[num].limittime = 0; + + } + +} + +#endif + +#ifdef _TEACHER_SYSTEM +void saacproto_ACCheckCharacterOnLine_recv( int acfd, int charaindex, int iOnline,char *data,int flag) +{ + switch(flag){ + case R_F_TEACHER_SYSTEM: + CHAR_Teacher_system_View(charaindex,iOnline,data); + break; + default:printf("saacproto_ACCheckCharacterOnLine_recv(): error flag type!!(%d)\n",flag); + } +} +#endif + +#ifdef _RACEMAN +void saacproto_ACRaceRecordandSort_recv(int fd,int charaindex,int racetype,char *data) +{ + int i,j=0; + char perdata[128]; + char buuf[16384]; + + //sprintf(buuf,"recv_type:%d data:%s",racetype,data); + //CHAR_talkToCli( charaindex , -1, buuf , CHAR_COLORYELLOW); + + //print("race_recv:%s",data); + + if(racetype == 0 || racetype == 9 ) return; //因为登记动作而接收到ac的回传,所以不用处理 + + //或许可以原封不动传给CLIENT + + if(racetype == 1){ //gamemode 1 + memset(ranktable1,0,sizeof(ranktable1)); + for(i=0;i +#include +#include +#include "common.h" +#include "util.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "net.h" +#include "char.h" +#include "object.h" +#include "readmap.h" +#include "addressbook.h" +#include "handletime.h" +#include "configfile.h" +#include "event.h" +#include "pet.h" +#include "battle.h" +#include "battle_command.h" +#include "magic.h" +#include "petmail.h" +#include "item_gen.h" +#include "pet_skill.h" +#include "log.h" //add this because the second had it +#include "map_deal.h" // CoolFish: 2001/4/18 +#include "trade.h" // CoolFish: Trade 2001/4/18 +#include "family.h" // CoolFish: Family 2001/5/24 +#include "item_event.h" // shan: blackmarket + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 +#include "profession_skill.h" +#endif +#ifdef _CHATROOMPROTOCOL // (不可开) Syu ADD 聊天室频道 +#include "chatroom.h" +#endif +BOOL checkStringErr( char * ); + +// shan add +extern struct FM_PKFLOOR fmpkflnum[FAMILY_FMPKFLOOR]; + + +/* ----------------------------------------------------------------------- + * 蓟 仄凶 读及 寞井日平乓仿奶件犯永弁旦毛 月 + * ----------------------------------------------------------------------*/ +static int Callfromcli_Util_getTargetCharaindex( int fd, int toindex) +{ + int to_charaindex = -1; + int fd_charaindex = CONNECT_getCharaindex( fd ); + + /* 愤坌愤褥 */ + if( toindex == 0 ) { + to_charaindex = fd_charaindex; + } + /* 矢永玄 1 5 */ + else if( toindex > 0 && toindex < 6 ) { + to_charaindex = CHAR_getCharPet( fd_charaindex, toindex-1); + if( !CHAR_CHECKINDEX( to_charaindex)) { + to_charaindex = -1; + } + } + /* 醮棉 6 10 */ + else if( toindex > 5 && toindex < 11 ) { + to_charaindex = CHAR_getPartyIndex( fd_charaindex, toindex - 6); + } + return to_charaindex; +} +/*---------------------------------------- + * 弁仿奶失件玄互夫弘奶件允月 匹手丢乒伉卞卺户月分仃卅及匹民尼永弁反卅中 + * 仇木毛裟少午 CLI 卞卅月[ + ----------------------------------------*/ +void lssproto_ClientLogin_recv( int fd,char* cdkey, char* passwd ) +{ + /* 2褐卞仇木互裟壬木月及反中中 */ + /* 由旦伐□玉 凳毛仄化岳 分匀凶日疯太仇木毛裟少仪[*/ + {//ttom avoid the restore 2001/01/09 + int fd_charaindex; + Char *chwk; + + // CoolFish: +2 2001/4/18 + fd_charaindex = CONNECT_getCharaindex(fd); + chwk = CHAR_getCharPointer(fd_charaindex); + if(CONNECT_isNOTLOGIN(fd)==FALSE){ + print("\n the Client had Logined fd=%d",fd); + return; + } + } + //print( "CliLogin cdkey=%s\n" , cdkey ); + /* connect卞戊疋□允月 */ + CONNECT_setCdkey( fd, cdkey ); + CONNECT_setPasswd( fd, passwd ); + CONNECT_setCtype( fd, CLI ); + {//ttom + unsigned long ip; + int a,b,c,d; + int i; + ip=CONNECT_get_userip(fd); + a=(ip % 0x100); ip=ip / 0x100; + b=(ip % 0x100); ip=ip / 0x100; + c=(ip % 0x100); ip=ip / 0x100; + d=(ip % 0x100); + print( "\n登陆账号=%s 来自 %d.%d.%d.%d \n",cdkey,a,b,c,d); + + for(i=0;i= 32 ){ + lssproto_CreateNewChar_send(fd,FAILED, "Too long charname\n"); + return; + // Nuke start 0711: Avoid naming as WAEI + }else if (strstr(charname,"华义") +// WON ADD + || strstr(charname,"gm") || strstr(charname,"GM") + || strstr(charname,"Gm") || strstr(charname,"gM") + || strstr(charname,"gm") || strstr(charname,"GM") + || strstr(charname,"Gm") || strstr(charname,"gM") +#ifdef _UNREG_NEMA + || (strstr(charname,getUnregname(0)) && strlen(getUnregname(0))>0) + || (strstr(charname,getUnregname(1)) && strlen(getUnregname(1))>0) + || (strstr(charname,getUnregname(2)) && strlen(getUnregname(2))>0) + || (strstr(charname,getUnregname(3)) && strlen(getUnregname(3))>0) + || (strstr(charname,getUnregname(4)) && strlen(getUnregname(4))>0) +#endif + || strstr(charname,"神秘人物") +// WON END + ) { + + unsigned ip=CONNECT_get_userip(fd); + int a, b, c, d, ck; + + a=(ip % 0x100); ip=ip / 0x100; + b=(ip % 0x100); ip=ip / 0x100; + c=(ip % 0x100); ip=ip / 0x100; + d=(ip % 0x100); + + ck= ( + ( (a== 10) && (b==0) && (c==0) ) || + ( (a==211) && (b==76) && (c==176) && (d==21) ) || // 台北wayi + ( (a==210) && (b==64) && (c==97) && ((d>=21)&&(d<=25)) ) || + ( (a==61) && (b==222) && (c==142) && (d==66) ) + ); + + print(" name_WAEI_IP:%d.%d.%d.%d ck:%d ",a,b,c,d,ck ); + + if( !ck ) { + lssproto_CreateNewChar_send(fd,FAILED, "Invalid charname\n"); + return; + } + } + { + // Nuke start 0801,0916: Avoid strange name + int i,ach; + for (i=0,ach=0;i=0x7f)&& + ((unsigned char)charname[i]<=0xa0)) { ach=1; break; } // Force no 0x7f~0xa0 + if ((unsigned char)charname[i]<=0x20) { ach=1; break; } // Force greater than 0x20 + if (ach) { + if ((((unsigned char)charname[i]>=0x40)&&((unsigned char)charname[i]<=0x7e))|| + (((unsigned char)charname[i]>=0xa1)&&((unsigned char)charname[i]<=0xfe))) ach=0; + } else { + if (((unsigned char)charname[i]>=0xa1)&&((unsigned char)charname[i]<=0xfe)) ach=1; + } + } + if (ach) { lssproto_CreateNewChar_send(fd,FAILED, "Error in Chinese\n"); return; } + // Nuke end + } + // Nuke end + + + CONNECT_getCdkey( fd, cdkey, sizeof( cdkey )); + CHAR_createNewChar( fd, dataplacenum, charname ,imgno, faceimgno, + vital, str, tgh, dex, + earth, water, fire, wind, + hometown , cdkey ); +} + +void lssproto_CharLogin_recv( int fd,char* charname ) +{ + char cdkey[CDKEYLEN], passwd[PASSWDLEN]; + + if( CONNECT_isCLI( fd ) == FALSE )return; + print( "\n尝试登陆: 人物名称=%s\n", charname); + if( charname[0] == '\0' ){ + lssproto_CharLogin_send( fd, FAILED, "\n人物名称含有不能访问字符\n" ); + return; + } + if( CONNECT_isNOTLOGIN(fd) == FALSE ){ + lssproto_CharLogin_send( fd, FAILED, "Already Logged in\n" ); + return; + } + CONNECT_setCharname( fd, charname ); + CONNECT_getCdkey( fd, cdkey, sizeof( cdkey )); + CONNECT_getPasswd( fd, passwd, sizeof(passwd)); + saacproto_ACCharLoad_send( acfd, cdkey,passwd, charname,1,"", + CONNECT_getFdid(fd) ); + CONNECT_setState( fd, WHILELOGIN ); +} + +#ifdef _ITEM_CHECKDROPATLOGOUT +BOOL CheckDropatLogout(int charaindex ) +{ + int i; + for( i=0 ; i= 0) || getMuseum() ) +#else + if( CHAR_getInt( charaindex, CHAR_LASTTALKELDER) >= 0 ) +#endif + { +#ifdef _MUSEUM + if( getMuseum() ) { + fl = 9000; x = 40; y = 40; + } + else { + CHAR_getElderPosition( CHAR_getInt( charaindex, CHAR_LASTTALKELDER), &fl, &x, &y ); + } +#else + CHAR_getElderPosition( CHAR_getInt( charaindex, CHAR_LASTTALKELDER), &fl, &x, &y ); +#endif + +#ifdef _CHAR_NEWLOGOUT + if( flg == 1 ){//回纪录点 + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE){ + CHAR_talkToCli( charaindex, -1, "战斗中无法回纪录点!", CHAR_COLORYELLOW); + return; + } +#ifdef _ITEM_CHECKWARES + if( CHAR_CheckInItemForWares( charaindex, 0) == FALSE ){ + CHAR_talkToCli( charaindex, -1, "携带货物无法使用。", CHAR_COLORYELLOW); + return; + } +#endif +#ifdef _BAD_PLAYER // WON ADD 送坏玩家去关 + if( (CHAR_getInt(charaindex,CHAR_FLOOR)==117)||(CHAR_getInt(charaindex,CHAR_FLOOR)==887) ){ + CHAR_talkToCli( charaindex, -1, "此处无法使用。", CHAR_COLORYELLOW); + return; + } +#endif + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE ) != CHAR_PARTY_NONE ){ + CHAR_talkToCli( charaindex, -1, "团队中无法回纪录点!", CHAR_COLORYELLOW); + return; + } +#ifdef _ITEM_CHECKDROPATLOGOUT + if( CheckDropatLogout( charaindex ) ){ + CHAR_talkToCli( charaindex, -1, "携带的物品使你无法回纪录点!", CHAR_COLORYELLOW); + return; + } +#endif +#ifdef _DEATH_CONTEND +/* + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE){ + if( CHAR_getInt( charaindex, CHAR_FLOOR) != 8250 && + CHAR_getInt( charaindex, CHAR_PKLISTLEADER) == 1 ){ + //andy_log + print("PlayerLogout_Exit()\n"); + NPC_PKLIST_PlayerLogout_Exit( charaindex ); + CHAR_warpToSpecificPoint( charaindex, 8250, 17, 17 ); + } + } +*/ +#else + if( CHAR_getInt( charaindex,CHAR_FLOOR ) != 117 && + CHAR_getInt( charaindex,CHAR_FLOOR ) != 887 +#ifdef _ADD_DUNGEON //追加地牢 + && CHAR_getInt( charaindex,CHAR_FLOOR ) != 8513 +#endif + ){ + CHAR_warpToSpecificPoint( charaindex, fl, x, y ); + + } +#endif + return; + } +#else + if( CHAR_getInt(charaindex,CHAR_FLOOR ) == 117){ + CHAR_setInt(charaindex,CHAR_X,225); + CHAR_setInt(charaindex,CHAR_Y,13); + }else{ + CHAR_setInt(charaindex,CHAR_FLOOR,fl); + CHAR_setInt(charaindex,CHAR_X,x); + CHAR_setInt(charaindex,CHAR_Y,y); + } +#endif + } + + // Robin add + //CHAR_setInt( charaindex, CHAR_LASTLEAVETIME, (int)time(NULL)); + } + + CHAR_logout(fd,TRUE); + CONNECT_setState( fd, WHILELOGOUTSAVE ); + CONNECT_setCharaindex( fd, -1 ); + CONNECT_getCdkey( fd, cdkey, sizeof(cdkey )); + CONNECT_getCharname( fd, charname, sizeof(charname)); + print( "Logout cdkey:%s charname=%s\n" , cdkey, charname ); +} + +void lssproto_CharDelete_recv( int fd , char* charname) +{ + char cdkey[CDKEYLEN],passwd[PASSWDLEN]; + int fdid; + + if( CONNECT_isCLI( fd ) == FALSE )return; + if( CONNECT_isNOTLOGIN( fd ) == FALSE ){ + lssproto_CharDelete_send( fd, FAILED, "Already Logged in\n" ); + return; + } + CONNECT_getCdkey( fd, cdkey, sizeof(cdkey)); + CONNECT_getPasswd( fd, passwd, sizeof(passwd)); + fdid = CONNECT_getFdid(fd); + saacproto_ACCharDelete_send( acfd, cdkey,passwd, charname , "" ,fdid ); + +#ifndef _DEATH_CONTEND + { + char buff[512]; + char escapebuf[1024]; + snprintf( buff, sizeof(buff), "%s_%s", cdkey, charname); + makeEscapeString( buff, escapebuf, sizeof(escapebuf)); + saacproto_DBDeleteEntryInt_send(acfd, DB_DUELPOINT, escapebuf, fdid, 0 ); + saacproto_DBDeleteEntryString_send( acfd, DB_ADDRESSBOOK, escapebuf, fdid, 0 ); + } + saacproto_Broadcast_send( acfd, cdkey, charname, "chardelete", 0); +#endif + + CONNECT_setState( fd, WHILECHARDELETE ); +} + +void lssproto_CharList_recv( int fd ) +{ + char cdkey[CDKEYLEN], passwd[PASSWDLEN]; + int fdid=-1; + + if( CONNECT_isCLI( fd ) == FALSE )return; + + if( CONNECT_isNOTLOGIN( fd ) == FALSE ){ + lssproto_CharList_send( fd, FAILED, "Already Logged in\n" ); + return; + } + + CONNECT_getCdkey( fd, cdkey, sizeof(cdkey)); + CONNECT_getPasswd( fd, passwd, sizeof(passwd)); + fdid = CONNECT_getFdid( fd ); + { + int i; + int playernum = CHAR_getPlayerMaxNum(); + for( i=0; i1)||(i_diff_y>1) ){ + // Robin 0518 + //CHAR_talkToCli(fd_charaindex, -1, "因走路座标错误而断线。", CHAR_COLORYELLOW); + + //return; + x = ix; + y = iy; + } + } + if(!(MAP_walkAble(fd_charaindex,CHAR_getInt(fd_charaindex, CHAR_FLOOR),x,y))){ + // Robin 03/14 + x = ix; + y = iy; + }else{ + } + CHAR_walk_init( fd, x, y, direction, TRUE); +} +/*------------------------------------------------------------ + * 汹仁 + ------------------------------------------------------------*/ +void lssproto_W2_recv( int fd,int x,int y,char* direction ) +{ + //ttom +3 + int fd_charaindex, ix, iy, i_fl; + //Char *chwk;// CoolFish: Rem 2001/4/18 + fd_charaindex = CONNECT_getCharaindex( fd ); + + ix=CHAR_getInt(fd_charaindex, CHAR_X); + iy=CHAR_getInt(fd_charaindex, CHAR_Y); + i_fl=CHAR_getInt(fd_charaindex, CHAR_FLOOR); + + // CoolFish: Prevent Trade Cheat 2001/4/18 + if (CHAR_getWorkInt(fd_charaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE) + return; + + //ttom avoid the warp at will 11/6 + { + int i_diff_x,i_diff_y; + //ix=CHAR_getInt(fd_charaindex, CHAR_X); + //iy=CHAR_getInt(fd_charaindex, CHAR_Y); + //i_fl=CHAR_getInt(fd_charaindex, CHAR_FLOOR); + i_diff_x=abs(ix-x); + i_diff_y=abs(iy-y); + if( (i_diff_x>1)||(i_diff_y>1) ){//2 + //print("\nWarp Error!!!!!!!!!"); + //print("\nthe origion->fd=%d,x=%d,y=%d",fd,ix,iy); + //print("\nthe modify-->fd=%d,X=%d,Y=%d,dir=%s",fd,x,y,direction); + x=ix; + y=iy; + // Robin 03/14 + //return; + } + //if((i_fl==117)&&(ix==225)&&(iy==13)) goto END_w; + }//ttom + if(!(MAP_walkAble(fd_charaindex,CHAR_getInt(fd_charaindex, CHAR_FLOOR),x,y))){ + print("\n the map is invaild(f:%d,x:%d,y:%d)",CHAR_getInt(fd_charaindex, CHAR_FLOOR),x,y); + x = ix; + y = iy; + } +//END_w: + CHAR_walk_init( fd, x, y, direction, FALSE); +} + +void lssproto_SKD_recv( int fd,int dir, int index) +{ + CHECKFDANDTIME; +} + +void lssproto_ID_recv( int fd,int x,int y,int haveitemindex,int toindex ) +{ + int to_charaindex; + int fd_charaindex; + + CHECKFDANDTIME; + fd_charaindex = CONNECT_getCharaindex( fd ); + + // CoolFish: Prevent Trade Cheat 2001/4/18 + if (CHAR_getWorkInt(fd_charaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE) + return; + + /* 爵 凛反轮仁 仿弘匹仇木卞娄匀井井月第 岭丐曰 */ + if( CHAR_getWorkInt( fd_charaindex, CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) return ; + //ttom avoid the warp at will 12/5 + { + int ix,iy; + ix=CHAR_getInt(fd_charaindex, CHAR_X); + iy=CHAR_getInt(fd_charaindex, CHAR_Y); + x=ix; + y=iy; + } + CHAR_setMyPosition( fd_charaindex, x,y,TRUE); + to_charaindex = Callfromcli_Util_getTargetCharaindex( fd, toindex); + CHAR_ItemUse( fd_charaindex, to_charaindex, haveitemindex ); +} + + +/*------------------------------------------------------------ + * 惫寞毛蓟少 + ------------------------------------------------------------*/ +void lssproto_ST_recv( int fd,int titleindex ) +{ + CHECKFDANDTIME; + CHAR_selectTitle( CONNECT_getCharaindex( fd) , titleindex ); +} +/*------------------------------------------------------------ + * 惫寞毛绰轮允月 + ------------------------------------------------------------*/ +void lssproto_DT_recv( int fd,int titleindex ) +{ + CHECKFDANDTIME; + CHAR_deleteTitle( CONNECT_getCharaindex(fd) , titleindex ); +} + + +/*------------------------------------------------------------ + * 愤裘惫寞毛 允月 + ------------------------------------------------------------*/ +void lssproto_FT_recv( int fd,char* data ) +{ + CHECKFDANDTIME; + + // Robin 04/23 debug + if( strlen(data) > 12 ) return; + + if( checkStringErr(data) ) return; + + CHAR_inputOwnTitle( CONNECT_getCharaindex(fd) , data); +} + +/*------------------------------------------------------------ + * 失奶 丞毛胶丹 + ------------------------------------------------------------*/ +void lssproto_PI_recv( int fd,int x, int y, int dir ) +{ + int fd_charaindex; + CHECKFDANDTIME; + fd_charaindex = CONNECT_getCharaindex( fd ); + {//ttom avoid warp at will + int ix,iy; + ix=CHAR_getInt(fd_charaindex, CHAR_X); + iy=CHAR_getInt(fd_charaindex, CHAR_Y); + if( (ix!=x)||(iy!=y)){ + //print("\n--Error!!!!"); + //print("\norigion x=%d,y=%d",ix,iy); + //print("\nmodify X=%d,Y=%d",x,y); + x=ix; + y=iy; + } + }//ttom end + + CHAR_setMyPosition( fd_charaindex, x,y,TRUE); + if( CHAR_getWorkInt( fd_charaindex, CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) return ; + CHAR_PickUpItem( fd_charaindex, dir); +} + +void lssproto_DI_recv( int fd,int x, int y, int itemindex ) +{ + int charaindex; + CHECKFDANDTIME; + charaindex = CONNECT_getCharaindex( fd ); + + if( CHAR_getWorkInt(charaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE) return; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) return; + + CHAR_setMyPosition( charaindex , + CHAR_getInt( charaindex, CHAR_X), CHAR_getInt( charaindex, CHAR_Y), TRUE); + + CHAR_DropItem( charaindex, itemindex ); +} + +void lssproto_DP_recv( int fd,int x, int y, int petindex ) +{ + int fd_charaindex; + CHECKFDANDTIME; + fd_charaindex = CONNECT_getCharaindex( fd ); + if (CHAR_getWorkInt(fd_charaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE) + return; + { + int ix,iy; + ix=CHAR_getInt(fd_charaindex, CHAR_X); + iy=CHAR_getInt(fd_charaindex, CHAR_Y); + x=ix; + y=iy; + } + CHAR_setMyPosition( fd_charaindex , x,y,TRUE); + if( CHAR_getWorkInt( fd_charaindex , CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) return ; + PET_dropPet( fd_charaindex, petindex); +} + +/*------------------------------------------------------------ + * 嗯毛 仁 + ------------------------------------------------------------*/ +void lssproto_DG_recv( int fd,int x, int y, int amount ) +{ + int fd_charaindex; + CHECKFDANDTIME; + fd_charaindex = CONNECT_getCharaindex( fd ); + //ttom avoid the warp at will 12/15 + { + int ix,iy; + ix=CHAR_getInt(fd_charaindex, CHAR_X); + iy=CHAR_getInt(fd_charaindex, CHAR_Y); + x=ix; + y=iy; + } + CHAR_setMyPosition( fd_charaindex, x,y,TRUE); + + /* 爵 反轮仁 仿弘匹仇木卞娄匀井井月第 岭丐曰 */ + if( CHAR_getWorkInt( fd_charaindex, CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) return ; + + // CoolFish: Prevent Trade Cheat 2001/4/18 + if (CHAR_getWorkInt(fd_charaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE) + return; + + + CHAR_DropMoney( fd_charaindex, amount ); +} + +/*------------------------------------------------------------ + * 失奶 丞毛啖 允月[隶 手仇木匹 + ------------------------------------------------------------*/ +void lssproto_MI_recv( int fd,int fromindex,int toindex ) +{ + int fd_charaindex; + CHECKFDANDTIME; + fd_charaindex = CONNECT_getCharaindex( fd ); + + // CoolFish: Prevent Trade Cheat 2001/4/18 + if (CHAR_getWorkInt(fd_charaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE) + return; + + /* 爵 反轮仁 仿弘匹仇木卞娄匀井井月第 岭丐曰 */ + if( CHAR_getWorkInt( fd_charaindex, CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) return ; + CHAR_moveEquipItem( fd_charaindex, fromindex, toindex ); + +} + +/*------------------------------------------------------------ + * 旦平伙失永皿 + ------------------------------------------------------------*/ +void lssproto_SKUP_recv( int fd,int skillid ) +{ + int fd_charaindex; + CHECKFDANDTIME; + fd_charaindex = CONNECT_getCharaindex(fd); + + /* 爵 反轮仁 仿弘匹仇木卞娄匀井井月第 岭丐曰 */ + if( CHAR_getWorkInt( fd_charaindex, CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) return ; + CHAR_SkillUp(fd_charaindex,skillid); +} + +/*------------------------------------------------------------ + * 戊生弁扑亦件锹澎卞丢永本□斥毛霜耨 + ------------------------------------------------------------*/ +void lssproto_MSG_recv( int fd,int index,char* message, int color ) +{ + int fd_charaindex; + CHECKFD; + fd_charaindex = CONNECT_getCharaindex( fd); + ADDRESSBOOK_sendMessage( fd_charaindex, index,message, color ); + +} + +/*------------------------------------------------------------ + * 失玉伊旦皮永弁及 毛母它件夫□玉允月邰菲互 凶 + ------------------------------------------------------------*/ +void lssproto_AB_recv( int fd ) +{ + int fd_charaindex; + CHECKFDANDTIME; + fd_charaindex = CONNECT_getCharaindex( fd ); + ADDRESSBOOK_sendAddressbookTable( fd_charaindex ); +} + +/*------------------------------------------------------------ + * 失玉伊旦皮永弁及嫩 毛绰轮允月 + ------------------------------------------------------------*/ +void lssproto_DAB_recv( int fd , int index) +{ + int fd_charaindex; + CHECKFDANDTIME; + fd_charaindex = CONNECT_getCharaindex( fd ); + ADDRESSBOOK_deleteEntry( fd_charaindex ,index); +} + +void lssproto_AAB_recv( int fd , int x, int y) +{ + int fd_charaindex; + CHECKFDANDTIME; + fd_charaindex = CONNECT_getCharaindex( fd ); + { + int ix,iy; + ix=CHAR_getInt(fd_charaindex, CHAR_X); + iy=CHAR_getInt(fd_charaindex, CHAR_Y); + if( (ix!=x)||(iy!=y)){ + x=ix; + y=iy; + } + } + CHAR_setMyPosition( fd_charaindex , x,y,TRUE); + ADDRESSBOOK_addEntry( fd_charaindex ); +} + +void lssproto_L_recv( int fd, int dir ) +{ + int fd_charaindex; + CHECKFDANDTIME; + fd_charaindex = CONNECT_getCharaindex( fd ); + CHAR_Look( fd_charaindex ,dir ); +} + + +/*------------------------------------------------------------ + * 民乓永玄迕丢永本□斥及霜耨 + ------------------------------------------------------------*/ +void lssproto_TK_recv( int fd,int x, int y,char* message,int color, int area ) +{ + int fd_charaindex,ix,iy;//ttom+2 + int fmindex, channel; + + CHECKFD; + fd_charaindex = CONNECT_getCharaindex( fd ); + fmindex = CHAR_getInt( fd_charaindex, CHAR_FMINDEX ); + channel = CHAR_getWorkInt( fd_charaindex, CHAR_WORKFMCHANNEL ); + {// Robin 0629 silent + int silentSec, talkCount; + silentSec = CHAR_getInt(fd_charaindex,CHAR_SILENT); + if( silentSec > 0 ) { + int loginTime; + char buf[256]; + int leftSec; + loginTime = CHAR_getWorkInt(fd_charaindex, CHAR_WORKLOGINTIME ); + // 防止时间修正回朔後 异常禁言 Robin 20040817 + if( (int)NowTime.tv_sec < loginTime) { + CHAR_setInt(fd_charaindex, CHAR_SILENT, 0 ); + return; + } + if( ((int)NowTime.tv_sec -loginTime) > silentSec ) { + CHAR_setInt(fd_charaindex, CHAR_SILENT, 0 ); + return; + } + silentSec += 10; //多禁10秒 + + leftSec = silentSec - ((int)NowTime.tv_sec - loginTime); + sprintf(buf, "禁言中!!还有%d秒,再讲多禁10秒钟。", leftSec ); + CHAR_talkToCli(fd_charaindex, -1, buf, color); + CHAR_setInt(fd_charaindex, CHAR_SILENT, silentSec ); + return; + } + + talkCount = CHAR_getWorkInt(fd_charaindex, CHAR_WORKTALKCOUNT ); + talkCount ++; + CHAR_setWorkInt( fd_charaindex, CHAR_WORKTALKCOUNT, talkCount); + if( talkCount > 8 ) { + int lastTalkTime = CHAR_getWorkInt(fd_charaindex, CHAR_WORKTALKTIME ); + if( (int)NowTime.tv_sec - lastTalkTime < 10 ) { + CHAR_setInt( fd_charaindex,CHAR_SILENT, 60 ); + CHAR_setWorkInt( fd_charaindex, CHAR_WORKLOGINTIME, (int)NowTime.tv_sec ); + CHAR_talkToCli( fd_charaindex, -1, "你太多话了唷,请你的嘴巴先休息个一分钟吧!", color); + CHAR_setWorkInt(fd_charaindex, CHAR_WORKTALKCOUNT, 0 ); + return; + }else { + CHAR_setWorkInt( fd_charaindex, CHAR_WORKTALKTIME, (int)NowTime.tv_sec ); + CHAR_setWorkInt(fd_charaindex, CHAR_WORKTALKCOUNT, 0 ); + } + } + + } + ix=CHAR_getInt(fd_charaindex, CHAR_X); + iy=CHAR_getInt(fd_charaindex, CHAR_Y); + x=ix; + y=iy; + CHAR_setMyPosition( fd_charaindex, x,y,TRUE); + if(!CONNECT_get_shutup(fd)){ //ttom add the shut up function + CHAR_Talk( fd,fd_charaindex, message, color, area ); + } +} + +void lssproto_M_recv( int fd, int fl, int x1, int y1 , int x2, int y2 ) +{ + char* mapdata; + RECT seek={x1,y1,x2-x1,y2-y1},ret; + CHECKFD; + + mapdata = MAP_getdataFromRECT(fl,&seek,&ret); + if( mapdata != NULL ){ + lssproto_M_send( fd, fl, ret.x, ret.y, + ret.x+ret.width, ret.y+ret.height, mapdata ); + } +} + +/*------------------------------------------------------------ + * 平乓仿犯□正 邰菲[ + ------------------------------------------------------------*/ +void lssproto_C_recv( int fd, int index ) +{ + /* 仇木分仃凛棉及涩烂毛苇卅中仪卞允月 */ + CHECKFD; + CHAR_sendCSpecifiedObjindex( fd, index); +} + +void lssproto_S_recv( int fd, char* category ) +{ + char* string; + int fd_charaindex; + + fd_charaindex = CONNECT_getCharaindex( fd ); + string = CHAR_makeStatusString( fd_charaindex, category ); + if( string != NULL ) + lssproto_S_send( fd , string ); + +} + +void lssproto_EV_recv( int fd,int event,int seqno,int x,int y, int dir ) +{ + int rc; + int fx,fy; + int fd_charaindex; + + CHECKFD; + fd_charaindex = CONNECT_getCharaindex( fd ); + { + int ix,iy; + ix=CHAR_getInt(fd_charaindex, CHAR_X); + iy=CHAR_getInt(fd_charaindex, CHAR_Y); + if( ( ix != x ) || ( iy != y ) ){ + goto CK1; + } + goto OK; + } +CK1: + { + OBJECT object; + int ix,iy,ifloor,i,j; + int warp_point_x[9]; + int warp_point_y[9]; + int warp_point=0; + ix=CHAR_getInt(fd_charaindex, CHAR_X); + iy=CHAR_getInt(fd_charaindex, CHAR_Y); + ifloor=CHAR_getInt(fd_charaindex,CHAR_FLOOR); + for(i=iy-1;i<=iy+1;i++){ + for(j=ix-1;j<=ix+1;j++){ + for( object = MAP_getTopObj(ifloor,j,i) ; object ;object = NEXT_OBJECT(object ) ){ + int o = GET_OBJINDEX(object); + if( OBJECT_getType(o) == OBJTYPE_CHARA ){ + int etype; + int charaindex=OBJECT_getIndex(o); + if( !CHAR_CHECKINDEX(charaindex) ) continue; + etype = CHAR_getWorkInt( charaindex, CHAR_WORKEVENTTYPE); + if( etype != CHAR_EVENT_NONE ) { + if(etype==CHAR_EVENT_WARP){ + warp_point_x[warp_point]=j; + warp_point_y[warp_point]=i; + warp_point++; + } + } + } +#ifdef _MAP_WARPPOINT + else if( OBJECT_getType(o) == OBJTYPE_WARPPOINT ){ + int etype = OBJECT_getchartype( o); + if( etype != CHAR_EVENT_NONE ) { + warp_point_x[warp_point]=j; + warp_point_y[warp_point]=i; + warp_point++; + break; + } + } +#endif + } + } + } + + for(i=0;i 7) { + fx = CHAR_getInt(fd_charaindex, CHAR_X); + fy = CHAR_getInt(fd_charaindex, CHAR_Y); + }else { + CHAR_getCoordinationDir( dir, CHAR_getInt(fd_charaindex, CHAR_X), + CHAR_getInt(fd_charaindex, CHAR_Y),1,&fx,&fy); + } + rc = EVENT_main(fd_charaindex, event,fx,fy); + lssproto_EV_send( fd, seqno, rc); +} +/*------------------------------------------------------------ + * 巨件市它件玄 戏 + ------------------------------------------------------------*/ +void lssproto_EN_recv( int fd , int x,int y ) +{ + int ret = FALSE, err = 0; + int fd_charaindex; + CHECKFD; + fd_charaindex = CONNECT_getCharaindex( fd); + + //print(" EN_recv "); + + if( CHAR_getWorkInt( fd_charaindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_CLIENT){ + CHAR_setMyPosition( fd_charaindex, x,y,TRUE); + CHAR_setWorkChar( fd_charaindex, CHAR_WORKWALKARRAY,""); + err = BATTLE_CreateVsEnemy( fd_charaindex,0, -1); + if( err != 0 ){ + ret = FALSE; + }else{ + ret = TRUE; + } + } +} +/*------------------------------------------------------------ + * 皿伊奶乩□ 衔匹巨件市它件玄 瑁 戏 + ------------------------------------------------------------*/ +void lssproto_DU_recv( int fd , int x,int y ) +{ + OBJECT object; + int fd_charaindex; + int ret = FALSE, charaindex = -1, enemyindex; + int frontx,fronty; + int cnt = 0; + BOOL found = FALSE; + CHECKFDANDTIME; + fd_charaindex = CONNECT_getCharaindex( fd ); + {//ttom avoid warp at will + int ix,iy; + ix=CHAR_getInt(fd_charaindex, CHAR_X); + iy=CHAR_getInt(fd_charaindex, CHAR_Y); + if( (ix!=x)||(iy!=y)){ + //print("\n--Error!!!!"); + //print("\norigion x=%d,y=%d",ix,iy); + //print("\nmodify X=%d,Y=%d",x,y); + x=ix; + y=iy; + } + } + + + /* 阂及凛反 骰允月 */ + if( CHAR_getWorkInt( fd_charaindex, CHAR_WORKPARTYMODE) + != CHAR_PARTY_CLIENT) + { + int i; + // 愤坌及奶件犯永弁旦 + charaindex = fd_charaindex; + CHAR_setMyPosition( charaindex, x,y,TRUE); + /* WALKARRAY毛弁伉失允月 */ + CHAR_setWorkChar( charaindex, CHAR_WORKWALKARRAY,""); + + + /* 赓渝祭允月 */ + for( i = 0; i < CONNECT_WINDOWBUFSIZE ; i ++ ) { + CONNECT_setDuelcharaindex( fd, i, -1 ); + } + + /* 及蟆及甄 毛 月 */ + CHAR_getCoordinationDir( CHAR_getInt( charaindex, CHAR_DIR ) , + CHAR_getInt( charaindex , CHAR_X ), + CHAR_getInt( charaindex , CHAR_Y ) , + 1 , &frontx , &fronty ); + + /*愤坌及 及蟆及平乓仿毛潸 允月 */ + for( object = MAP_getTopObj( CHAR_getInt( charaindex, CHAR_FLOOR), + frontx,fronty) ; + object ; + object = NEXT_OBJECT(object ) ) + { + int toindex; + int objindex = GET_OBJINDEX(object); + /* 平乓仿弁正□元扎卅中 */ + if( OBJECT_getType( objindex) != OBJTYPE_CHARA) continue; + toindex = OBJECT_getIndex( objindex); + /* 皿伊奶乩□元扎卅中 */ + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ) continue; + found = TRUE; + /* 爵 分匀凶日蛲 */ + if( CHAR_getWorkInt( toindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE ){ + continue; + } + /* 辅爵蛐 卅日蛲 */ + if( !CHAR_getFlg( toindex, CHAR_ISDUEL)) continue; + + // shan begin + { + int i; + for( i=0; i 1 ) { + int strlength; + char msgbuf[1024]; + char escapebuf[2048]; + strcpy( msgbuf, "1\n要和谁战斗?\n"); + strlength = strlen( msgbuf); + /* 它奴件玉它及丢永本□斥综岳[ + * 爵 及平乓仿及域 + */ + for( i = 0; + CONNECT_getDuelcharaindex( fd,i) != -1 + && i< CONNECT_WINDOWBUFSIZE; + i ++ ) + { + char *a = CHAR_getChar( + CONNECT_getDuelcharaindex( fd,i) , CHAR_NAME); + char buf[256]; + snprintf( buf, sizeof( buf),"%s [%s]\n", a, + CHAR_getWorkInt( + CONNECT_getDuelcharaindex(fd,i), + CHAR_WORKPARTYMODE ) + != CHAR_PARTY_NONE ? "团体": "单独"); + if( strlength + strlen( buf) > arraysizeof( msgbuf)){ + print( "%s:%d视窗讯息buffer不足。\n", + __FILE__,__LINE__); + break; + } + strcpy( &msgbuf[strlength], buf); + strlength += strlen(buf); + } + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_SELECTDUEL, + -1, + makeEscapeString( msgbuf, escapebuf, sizeof(escapebuf))); + ret = TRUE; + } + } + + +// 巨仿□质 +lssproto_DU_recv_Err:; + if( ret == FALSE ) { + /* 瑛绊霜耨 */ + lssproto_EN_send( fd, FALSE, 0 ); + if( cnt > 0 ) CHAR_talkToCli( charaindex, -1, "遭遇失败!", CHAR_COLORYELLOW); + else if( found ) CHAR_talkToCli( charaindex, -1, "无人可以对战。", CHAR_COLORYELLOW); + else CHAR_talkToCli( charaindex, -1, "那里没有任何人。", CHAR_COLORYELLOW); + } +} +/*------------------------------------------------------------ + * 巨件市它件玄蔽 + ------------------------------------------------------------*/ +void lssproto_EO_recv( int fd, int dummy ) +{ + int fd_charaindex; + int battle_index;//ttom++ + CHECKFD; + fd_charaindex = CONNECT_getCharaindex( fd ); + BattleEncountOut( fd_charaindex ); + // Nuke start 0827 : Battle acceleration + battle_index=CHAR_getWorkInt(fd_charaindex,CHAR_WORKBATTLEINDEX); + if( BATTLE_CHECKINDEX( battle_index ) == FALSE ){ + return; + } + if(BattleArray[battle_index].type != BATTLE_TYPE_P_vs_P){ + if(CONNECT_get_watchmode(fd)) { + //print("fd= %d Watching the battle __ lssprot_EO_recv \n",fd);//for debug + CONNECT_set_watchmode(fd,FALSE); + return; + } + else if (checkBEOTime( fd ) < 0) { + //CHAR_talkToCli(fd_charaindex, -1, "你加速喔。", CHAR_COLORYELLOW); + } + } + // Nuke end + +} + +/*------------------------------------------------------------ + * 巨件市它件玄 蝇邰菲 + ------------------------------------------------------------*/ +void lssproto_BU_recv( int fd, int dummy) +{ + int fd_charaindex; + CHECKFD; + fd_charaindex = CONNECT_getCharaindex( fd ); + // shan 2001/12/25 + //BATTLE_WatchStop( fd_charaindex ); +} + +void lssproto_B_recv( int fd, char *command ) +{ + int fd_charaindex; + int battle_index;//ttom++ + CHECKFD; + fd_charaindex = CONNECT_getCharaindex( fd ); + BattleCommandDispach( fd, command ); + // Nuke +1 0827: Battle acceleration + battle_index=CHAR_getWorkInt(fd_charaindex,CHAR_WORKBATTLEINDEX); + if( BATTLE_CHECKINDEX( battle_index ) == FALSE ){ + return; + } + if(BattleArray[battle_index].type != BATTLE_TYPE_P_vs_P){ + if(BattleArray[battle_index].type == BATTLE_TYPE_WATCH) { + CONNECT_set_watchmode(fd,TRUE); + return; + } + } + //Nuke end +} + +void lssproto_FS_recv( int fd,int flg ) +{ + int fd_charaindex; + CHECKFDANDTIME; + + fd_charaindex = CONNECT_getCharaindex( fd ); + /* 椭瘀反竣卞六内卞公及引引白仿弘凳蕙 */ + CHAR_setFlg( fd_charaindex, CHAR_ISPARTY, + (flg & CHAR_FS_PARTY )? TRUE:FALSE); + //CHAR_setFlg( fd_charaindex, CHAR_ISBATTLE, + // (flg & CHAR_FS_BATTLE )? TRUE:FALSE); + CHAR_setFlg( fd_charaindex, CHAR_ISDUEL, + (flg & CHAR_FS_DUEL )? TRUE:FALSE); + CHAR_setFlg( fd_charaindex, CHAR_ISPARTYCHAT, + (flg & CHAR_FS_PARTYCHAT )? TRUE:FALSE); + CHAR_setFlg( fd_charaindex, CHAR_ISTRADECARD, + (flg & CHAR_FS_TRADECARD )? TRUE:FALSE); +#ifdef _CHANNEL_MODIFY + //密语频道开关 + CHAR_setFlg(fd_charaindex,CHAR_ISTELL,(flg & CHAR_FS_TELL )? TRUE:FALSE); + //家族频道开关 + CHAR_setFlg(fd_charaindex,CHAR_ISFM,(flg & CHAR_FS_FM )? TRUE:FALSE); + //职业频道开关 + CHAR_setFlg(fd_charaindex,CHAR_ISOCC,(flg & CHAR_FS_OCC )? TRUE:FALSE); + //聊天室 + CHAR_setFlg(fd_charaindex,CHAR_ISCHAT,(flg & CHAR_FS_CHAT )? TRUE:FALSE); + //储存对话开关 + CHAR_setFlg(fd_charaindex,CHAR_ISSAVE,(flg & CHAR_FS_SAVE )? TRUE:FALSE); +#endif +#ifdef _AUCPROTOCOL // (不可开) Syu ADD 拍卖频道开关Protocol + CHAR_setFlg( fd_charaindex, CHAR_ISAUC, + (flg & CHAR_FS_AUC )? TRUE:FALSE); +#endif + // CoolFish: Trade 2001/4/18 + CHAR_setFlg( fd_charaindex, CHAR_ISTRADE, + (flg & CHAR_FS_TRADE )? TRUE:FALSE); + /* + if (CHAR_getFlg(fd_charaindex, CHAR_ISTRADECARD) == TRUE) + CHAR_setFlg(fd_charaindex, CHAR_ISTRADE, FALSE); + if (CHAR_getFlg(fd_charaindex, CHAR_ISTRADE) == TRUE) + CHAR_setFlg(fd_charaindex, CHAR_ISTRADECARD, FALSE); + */ + + lssproto_FS_send( fd, flg); +} +/*------------------------------------------------------------ + * 醮棉邰菲 戏[ + ------------------------------------------------------------*/ +void lssproto_PR_recv( int fd,int x, int y, int request ) +{ + int result = FALSE; + int fd_charaindex; + CHECKFDANDTIME; + + fd_charaindex = CONNECT_getCharaindex( fd ); + +#if 1 // 禁止组队区域 + if( request == 1 ) + { + int nowFloor; + nowFloor = CHAR_getInt( fd_charaindex, CHAR_FLOOR); + if( nowFloor == 31706 + || nowFloor == 10204 + || (10601 <= nowFloor && nowFloor <= 10605 ) + || nowFloor == 10919 || nowFloor == 10920 + || nowFloor == 20711 || nowFloor == 20712 + || nowFloor == 1008 || nowFloor == 1021 + || nowFloor == 3008 || nowFloor == 3021 + || ( nowFloor <= 8213 && nowFloor >= 8200 ) + || ( nowFloor >= 30017 && nowFloor <= 30021 ) +#ifdef _TIME_TICKET + || check_TimeTicketMap(nowFloor) +#endif + ){ + print("\n 改封包!禁止组队区域!!:%s ", CHAR_getChar( fd_charaindex, CHAR_CDKEY) ); + return; + } + } +#endif + + {//ttom avoid warp at will + int ix,iy; + ix=CHAR_getInt(fd_charaindex, CHAR_X); + iy=CHAR_getInt(fd_charaindex, CHAR_Y); + if( (ix!=x)||(iy!=y)){ + //print("\n--Error!!!!"); + //print("\norigion x=%d,y=%d",ix,iy); + //print("\nmodify X=%d,Y=%d",x,y); + x=ix; + y=iy; + } + } + CHAR_setMyPosition( fd_charaindex, x,y,TRUE); + + if( request == 0 ) { + /* 轮迩允月 */ + result = CHAR_DischargeParty(fd_charaindex, 0); + } + else if( request == 1 ) { + /* 迩允月 */ + result = CHAR_JoinParty(fd_charaindex); + } +} +/*------------------------------------------------------------ + * 爵 卞瓒 允月矢永玄毛蓟 仄凶[ + ------------------------------------------------------------*/ +void lssproto_KS_recv( int fd,int petarray ) +{ + int ret , fd_charaindex; + CHECKFDANDTIME; + fd_charaindex = CONNECT_getCharaindex( fd ); + + if( CHAR_getInt( fd_charaindex, CHAR_RIDEPET) == petarray ) + lssproto_KS_send( fd, petarray, FALSE); + + ret = PET_SelectBattleEntryPet( fd_charaindex, petarray); + lssproto_KS_send( fd, petarray, ret); +} + +#ifdef _STANDBYPET +void lssproto_SPET_recv( int fd, int standbypet ) +{ + int fd_charaindex; + int i, s_pet =0, cnt =0; + + CHECKFDANDTIME; + fd_charaindex = CONNECT_getCharaindex( fd ); + + if( CHAR_getWorkInt( fd_charaindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE + && standbypet >= CHAR_getWorkInt( fd_charaindex, CHAR_WORKSTANDBYPET) ) { + print("\n 改封包!??战斗中用SPET增加待机宠!!:%s ", CHAR_getChar( fd_charaindex, CHAR_CDKEY) ); + return; + } + + //if( CHAR_getInt( fd_charaindex, CHAR_RIDEPET) == petarray ) { + // lssproto_SPET_send( fd, petarray, FALSE); + //} + + for( i =0; i < CHAR_MAXPETHAVE; i++) { + if( standbypet & ( 1 << i ) ) { + + //if( CHAR_getInt( fd_charaindex, CHAR_RIDEPET) == i ) + // continue; + + cnt++; + if( cnt > 3 ) { + print("\n 改封包!待机宠超过数量!!:%s ", CHAR_getChar( fd_charaindex, CHAR_CDKEY) ); + //lssproto_SPET_send( fd, s_pet, FALSE); + break; + } + + s_pet |= ( 1 << i ); + } + } + CHAR_setWorkInt( fd_charaindex, CHAR_WORKSTANDBYPET, s_pet); + + lssproto_SPET_send( fd, s_pet, TRUE); +} +#endif + +/*------------------------------------------------------------ + * 减变升啼卅升及 蜇六方午熬仃午匀凶 + ------------------------------------------------------------*/ +void lssproto_AC_recv( int fd,int x, int y,int actionno ) +{ + int fd_charaindex; + CHECKFDANDTIME; + fd_charaindex = CONNECT_getCharaindex( fd ); + {//ttom avoid the warp at will + Char *ch; + ch = CHAR_getCharPointer( fd_charaindex); + // CoolFish: +1 2001/11/05 + if (!ch) return; + + if((ch->data[CHAR_X]!=x)||(ch->data[CHAR_Y]!=y)){ + return; + } + } + CHAR_setMyPosition( fd_charaindex, x,y,TRUE); + CHAR_sendAction( fd_charaindex, actionno, FALSE); + return; +} +/*------------------------------------------------------------ + * 芊毛银匀凶[ + ------------------------------------------------------------*/ +void lssproto_MU_recv( int fd,int x,int y,int array,int toindex ) +{ + int to_charaindex = -1, fd_charaindex; + CHECKFDANDTIME; + fd_charaindex = CONNECT_getCharaindex( fd ); + {//ttom avoid warp at will + int ix,iy; + ix=CHAR_getInt(fd_charaindex, CHAR_X); + iy=CHAR_getInt(fd_charaindex, CHAR_Y); + if( (ix!=x)||(iy!=y)){ + //print("\n--Error!!!!"); + //print("\norigion x=%d,y=%d",ix,iy); + //print("\nmodify X=%d,Y=%d",x,y); + x=ix; + y=iy; + } + } + + CHAR_setMyPosition( fd_charaindex, x,y,TRUE); + /* toindex 毛平乓仿弁正□犯□正及index卞 晶允月 */ + to_charaindex = Callfromcli_Util_getTargetCharaindex( fd, toindex); + MAGIC_Use( fd_charaindex, array, to_charaindex); +} + +void lssproto_JB_recv( int fd,int x,int y ) +{ + int charaindex, floor; + + CHECKFDANDTIME; + charaindex = CONNECT_getCharaindex( fd ); + { + int ix,iy; + ix=CHAR_getInt(charaindex, CHAR_X); + iy=CHAR_getInt(charaindex, CHAR_Y); + if( (ix!=x)||(iy!=y)){ + x=ix; + y=iy; + } + } + + CHAR_setMyPosition( charaindex, x,y,TRUE); + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return; + floor = CHAR_getInt( charaindex, CHAR_FLOOR ); + if( floor == 1007 + || floor == 2007 + || floor == 3007 + || floor == 4007 + || floor == 130 ){ + BATTLE_WatchTry( charaindex ); + }else{ + BATTLE_RescueTry( charaindex ); + } +} + +void lssproto_KN_recv( int fd,int havepetindex,char* data ) +{ + int fd_charaindex; + CHECKFD; + fd_charaindex = CONNECT_getCharaindex( fd ); + + // Robin 04/26 debug + if( strlen(data) > 16 ) return; + + // CoolFish: Prevent Trade Cheat 2001/4/18 + if (CHAR_getWorkInt(fd_charaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE) + return; + + if( checkStringErr(data) ) return; + + CHAR_inputUserPetName( fd_charaindex, havepetindex, data); + +} +/*------------------------------------------------------------ + * 它奴件玉它毛蓟 仄凶[ + ------------------------------------------------------------*/ +void lssproto_WN_recv( int fd,int x,int y,int seqno, + int objindex,int select, char* data ) +{ + int fd_charaindex; + + CHECKFDANDTIME; + + if( checkStringErr(data) ) return; +#ifdef _NO_WARP + { + if(seqno!=CONNECT_get_seqno(fd)){ + return; + } + if( !( (select)&(CONNECT_get_selectbutton(fd)) ) && select ){ + if( CONNECT_get_seqno(fd)==CHAR_WINDOWTYPE_QUIZ_MAIN ){ + }else if( ( (CONNECT_get_seqno(fd)==CHAR_WINDOWTYPE_SCHEDULEMAN_START) + || (CONNECT_get_seqno(fd)==CHAR_WINDOWTYPE_SCHEDULEMAN_SELECT) ) + && (select==1) ){ + }else{ + return ; + } + } + } // shan End +#endif + + fd_charaindex = CONNECT_getCharaindex( fd ); + // CoolFish: Prevent Trade Cheat 2001/4/18 + if (CHAR_getWorkInt(fd_charaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE) { + return; + } + // Robin + if( checkStringErr(data) ) return; + +#ifdef _ANGEL_SUMMON + if( seqno == CHAR_WINDOWTYPE_ANGEL_ASK ) + { + print("\n CHAR_WINDOWTYPE_ANGEL_ASK objindex:%d select:%d data:%s ", + objindex, select, data ); + + if(select==WINDOW_BUTTONTYPE_YES ) { + if( AngelCreate( fd_charaindex) == FALSE ) { + sendAngelCleanToCli( fd ); + } + } + else if(select==WINDOW_BUTTONTYPE_NO ) { + int mindex; + char nameinfo[64]; + mindex = checkIfAngel( fd_charaindex); + print(" ====不接受召唤任务==== "); + getMissionNameInfo( fd_charaindex, nameinfo); + saacproto_ACMissionTable_send( acfd, mindex, 3, nameinfo, ""); + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + "真是遗憾。\n少了你的帮助,看来魔族会继续危害大陆的人民了。" ); + + //CHAR_talkToCli( fd_charaindex, -1, "天之声:真是可惜,这可是难得的机会呀。", CHAR_COLORYELLOW); + + sendAngelCleanToCli( fd ); + } + } +#endif + +#ifdef _CONTRACT + if( seqno == CHAR_WINDOWTYPE_CONTRACT_ANSWER ) { + ITEM_contractSign( fd, objindex, select); + } +#endif + + {//ttom avoid the warp at will + Char *ch; + ch = CHAR_getCharPointer( fd_charaindex); + // CoolFish: +1 2001/11/05 + if (!ch) return; + if((ch->data[CHAR_X]!=x)||(ch->data[CHAR_Y]!=y)){ + // Robin 04/20 test + return; + x=ch->data[CHAR_X]; + y=ch->data[CHAR_Y]; + } + //ttom avoid WN at will + if(seqno==CHAR_WINDOWTYPE_NPCENEMY_START){ +// Char *ch; + OBJECT object; + int ix,iy,ifloor,i,j; + int whichtype= -1; + int enemy=0; + int enemy_index; + if(!CHECKOBJECT(objindex)){ + goto FIRST; + } + enemy_index=OBJECT_getIndex(objindex);//ttom 11/15/2000 + ix =ch->data[CHAR_X]; + iy =ch->data[CHAR_Y]; + ifloor=ch->data[CHAR_FLOOR]; + for(i=iy-1;i<=iy+1;i++){ + for(j=ix-1;j<=ix+1;j++){ + for( object = MAP_getTopObj(ifloor,j,i) ; object ; + object = NEXT_OBJECT(object ) ){ + int objindex = GET_OBJINDEX(object); + switch( OBJECT_getType(objindex) ){ + case OBJTYPE_CHARA: + whichtype = CHAR_getInt( OBJECT_getIndex( objindex), CHAR_WHICHTYPE); + if( whichtype == CHAR_TYPENPCENEMY){ + int i_ene_temp; + i_ene_temp=OBJECT_getIndex( objindex); + //print("\n--enetemp=%d",i_ene_temp); + if(i_ene_temp== enemy_index){ + goto START_WN; + }else{ + enemy=0; + } + } + break; + case OBJTYPE_ITEM: + break; + case OBJTYPE_GOLD: + break; + default: + break; + } + } + } + } + if(enemy==0){ +FIRST: + + lssproto_EN_send( fd, FALSE, 0 ); + CHAR_talkToCli(fd_charaindex, -1, "事件错误。", CHAR_COLORYELLOW); + goto END_WN; + } + } + } + //ttom end +START_WN: + CHAR_setMyPosition( fd_charaindex, x,y,TRUE); + if( CHAR_getWorkInt( fd_charaindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE){ + if(seqno==CHAR_WINDOWTYPE_WINDOWWARPMAN_MAIN){ + if(!CONNECT_get_first_warp(fd)){ + select=1; + } + } + CHAR_processWindow( fd_charaindex, seqno, + select, objindex, makeStringFromEscaped(data)); + +#ifdef _NO_WARP + if (CONNECT_get_seqno(fd)==CHAR_WINDOWTYPE_WINDOWWARPMAN_MAIN) + { + CONNECT_set_seqno(fd,-1); + CONNECT_set_selectbutton(fd,1); + } +#endif + } +//ttom+1 +END_WN: + return; + //CONNECT_set_pass(fd,TRUE);//ttom +} + +/*------------------------------------------------------------ + * 云踞仃乒□玉 凳毛熬仃凶 + ------------------------------------------------------------*/ +void lssproto_HL_recv( int fd,int flg ) +{ + char msgbuf[128]; + int i, fd_charaindex; + CHECKFD; + + fd_charaindex = CONNECT_getCharaindex( fd ); + /* 爵 元扎卅井匀凶日 骰允月 */ + if( CHAR_getWorkInt( fd_charaindex, CHAR_WORKBATTLEMODE) + == BATTLE_CHARMODE_NONE) + { + return; + } +#ifdef _LOCKHELP_OK // (不可开) Syu ADD 锁定不可加入战斗 + if((CHAR_getInt(fd_charaindex,CHAR_FLOOR) >= 8200 && CHAR_getInt(fd_charaindex,CHAR_FLOOR) <= 8213) || + (CHAR_getInt(fd_charaindex,CHAR_FLOOR) >= 30017 && CHAR_getInt(fd_charaindex,CHAR_FLOOR) <= 30021) + ){ + return ; + } +#endif + if( flg == TRUE ) { + +#ifdef _ESCAPE_RESET // 使用恶宝逃跑後x分钟内不可求救 + if( getStayEncount( fd ) ) { + //print(" 恶宝中组队 "); + if( time(NULL) - CHAR_getWorkInt( fd_charaindex, CHAR_WORKLASTESCAPE) < 5*60 ) { + lssproto_HL_send( fd, FALSE); + //print(" 恶宝逃跑後组队 "); + CHAR_talkToCli( fd_charaindex, -1, "暂时不可以求救。", CHAR_COLORYELLOW); + return; + } + } +#endif + + /* 云踞仃乒□玉及白仿弘 化月 */ + BattleArray[CHAR_getWorkInt( fd_charaindex, + CHAR_WORKBATTLEINDEX)].Side[ + CHAR_getWorkInt( fd_charaindex, + CHAR_WORKBATTLESIDE)].flg |= BSIDE_FLG_HELP_OK; + + snprintf( msgbuf, sizeof( msgbuf), + "%s 在求救!", + CHAR_getChar( fd_charaindex, CHAR_NAME)); + } + else { + /* 云踞仃乒□玉及白仿弘 午允 */ + BattleArray[CHAR_getWorkInt( fd_charaindex, + CHAR_WORKBATTLEINDEX)].Side[ + CHAR_getWorkInt( fd_charaindex, + CHAR_WORKBATTLESIDE)].flg &= ~BSIDE_FLG_HELP_OK; + + snprintf( msgbuf, sizeof( msgbuf), + "%s 决定拒绝帮助。", + CHAR_getChar( fd_charaindex, CHAR_NAME)); + } + + /* 云踞仃橇谪互 歹匀凶仪毛爵 醮棉卞(愤坌殖戈)霜耨 */ + for( i = 0; i < 5; i ++ ) { + int toindex = BattleArray[CHAR_getWorkInt( + fd_charaindex, CHAR_WORKBATTLEINDEX)].Side[ + CHAR_getWorkInt( fd_charaindex, + CHAR_WORKBATTLESIDE)].Entry[i].charaindex; + if( CHAR_CHECKINDEX( toindex)) { + int tofd = getfdFromCharaIndex( toindex ); + if( tofd != -1 ) { + lssproto_HL_send( tofd, flg); + } + /* 丢永本□斥霜耨 */ + CHAR_talkToCli( toindex, -1, msgbuf, CHAR_COLORYELLOW); + /* 云踞仃CA 憎]引凶反壅允 */ + CHAR_sendBattleEffect( toindex, ON); + } + } +} +/*------------------------------------------------------------ + * proc 毛仁木午蜕歹木凶[ + ------------------------------------------------------------*/ +void lssproto_ProcGet_recv( int fd ) +{ + outputNetProcLog( fd, 1); +} +/*------------------------------------------------------------ + * 皿伊奶乩□醒毛仁木午蜕歹木凶[ + ------------------------------------------------------------*/ +void lssproto_PlayerNumGet_recv( int fd ) +{ + int i; + int clicnt =0; + int playercnt = 0; + for( i = 0; i < ConnectLen; i ++ ) { + if( CONNECT_getUse_debug(i,1017) ){ + if( CONNECT_getCtype(i) == CLI) { + clicnt ++; + if( CONNECT_getCharaindex(i) >= 0 ) playercnt++; + } + } + } + lssproto_PlayerNumGet_send( fd, clicnt, playercnt); +} + + +/*------------------------------------------------------------ + * 棋爵邰菲 戏[ + ------------------------------------------------------------*/ +void lssproto_LB_recv( int fd,int x,int y ) +{ + int fd_charaindex; + + CHECKFDANDTIME; + fd_charaindex = CONNECT_getCharaindex( fd ); + {//ttom avoid warp at will + int ix,iy; + ix=CHAR_getInt(fd_charaindex, CHAR_X); + iy=CHAR_getInt(fd_charaindex, CHAR_Y); + if( (ix!=x)||(iy!=y)){ + //print("\n--Error!!!!"); + //print("\norigion x=%d,y=%d",ix,iy); + //print("\nmodify X=%d,Y=%d",x,y); + x=ix; + y=iy; + } + } + CHAR_setMyPosition( fd_charaindex, x,y,TRUE); + /* 杀梁匹五月井民尼永弁仄化杀梁允月 */ + BATTLE_WatchTry( fd_charaindex ); +} +/*------------------------------------------------------------ + * 扑乓永玄母它件质 钒铵 + ------------------------------------------------------------*/ +void lssproto_Shutdown_recv( int fd,char* passwd,int min ) +{ + char buff[256]; + if( strcmp( passwd, "hogehoge") == 0 ) { + int i; + int playernum = CHAR_getPlayerMaxNum(); + + snprintf( buff, sizeof( buff),"极度的系统公告。"); + for( i = 0 ; i < playernum ; i++) { + if( CHAR_getCharUse(i) != FALSE ) { + CHAR_talkToCli( i, -1, buff, CHAR_COLORYELLOW); + } + } + SERVSTATE_setLimittime(min); + SERVSTATE_setShutdown( NowTime.tv_sec ); + SERVSTATE_setDsptime( 0 ); + } +} +void lssproto_PMSG_recv( int fd,int index,int petindex,int itemindex, + char* message,int color ) +{ + + // CoolFish: Prevent Trade Cheat 2001/4/18 + int fd_charaindex; + fd_charaindex = CONNECT_getCharaindex(fd); + if (CHAR_getWorkInt(fd_charaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE) + return; + PETMAIL_sendPetMail( CONNECT_getCharaindex( fd ), + index, petindex, itemindex, message, color); + +} +/*------------------------------------------------------------ + * 矢永玄 银迕熬耨 + ------------------------------------------------------------*/ +void lssproto_PS_recv( int fd, int havepetindex, int havepetskill, int toindex, char* data ) +{ + int to_charaindex = Callfromcli_Util_getTargetCharaindex( fd, toindex); + int charaindex = CONNECT_getCharaindex( fd ); + int petindex; + BOOL ret; + petindex = CHAR_getCharPet( charaindex, havepetindex); + if( !CHAR_CHECKINDEX( petindex)) return; + + ret = PETSKILL_Use( petindex, havepetskill, to_charaindex, data ); + lssproto_PS_send( fd, ret, havepetindex, havepetskill, toindex); +} +/*------------------------------------------------------------ + * 甄 毛本永玄允月 + ------------------------------------------------------------*/ +void lssproto_SP_recv( int fd,int x,int y, int dir ) +{ + int fd_charaindex; + + fd_charaindex = CONNECT_getCharaindex( fd ); + {//ttom avoid the warp at will + int i_x,i_y; + i_x=CHAR_getInt(fd_charaindex, CHAR_X); + i_y=CHAR_getInt(fd_charaindex, CHAR_Y); + + if((i_x!=x)||(i_y!=y)){ + x=i_x; + y=i_y; + } + }//ttom + + CHAR_setMyPosition_main( fd_charaindex, x,y,dir,TRUE); + +} + +/*------------------------------------------------------------ + * CoolFish: Trade Command 2001/4/18 + ------------------------------------------------------------*/ +void lssproto_TD_recv( int fd, char* message ) +{ + int fd_charaindex; + CHECKFDANDTIME; + + fd_charaindex = CONNECT_getCharaindex( fd ); + print(" MAP_TRADEPICKUP_check0 "); + CHAR_Trade(fd, fd_charaindex, message); +} + +/*------------------------------------------------------------ + * CoolFish: Family Command 2001/5/24 + ------------------------------------------------------------*/ +void lssproto_FM_recv( int fd, char* message ) +{ + int fd_charaindex; + struct timeval recvtime; + CHECKFDANDTIME; + + // add code by shan + CONNECT_getLastrecvtime( fd, &recvtime); + if( time_diff( NowTime, recvtime) < 0.5 ){ + return; + } + CONNECT_setLastrecvtime(fd, &NowTime); + + fd_charaindex = CONNECT_getCharaindex( fd ); + + if( checkStringErr( message ) ) return; + + CHAR_Family(fd, fd_charaindex, message); + +} + +// shan 2002/01/10 +void lssproto_PETST_recv( int fd, int nPet, int sPet ) +{ + int charaindex; + int i, nums=0; + CHECKFDANDTIME; + + charaindex = CONNECT_getCharaindex( fd ); + if (!CHAR_CHECKINDEX( charaindex ) ) return; + + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) return ; + + for( i=0; i<5; i++) { + if( CHAR_getWorkInt( charaindex, CHAR_WORK_PET0_STAT+i) == TRUE ) + nums++; + } + if( nums <= 3 ) + CHAR_setWorkInt( charaindex, CHAR_WORK_PET0_STAT+nPet, sPet); + +} + +void lssproto_BM_recv(int fd, int iindex) +{ +#ifdef _BLACK_MARKET + int charaindex; + CHECKFDANDTIME; + + charaindex = CONNECT_getCharaindex( fd); + if(!CHAR_CHECKINDEX( charaindex)) return; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) return ; + + ITEM_BM_Exchange( charaindex, iindex); +#endif +} + +#ifdef _MIND_ICON +void lssproto_MA_recv(int fd, int x, int y, int nMind) +{ + int charaindex; + CHECKFDANDTIME; + + charaindex = CONNECT_getCharaindex( fd); + if(!CHAR_CHECKINDEX( charaindex)) return; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) return ; + + { + int i_x, i_y; + i_x = CHAR_getInt( charaindex, CHAR_X); + i_y = CHAR_getInt( charaindex, CHAR_Y); + + if((i_x!=x)||(i_y!=y)){ + x = i_x; + y = i_y; + } + } + + //print("\nshan------------------>mind action->%d x->%d y->%d", nMind, x, y); + CHAR_setMyPosition( charaindex, x, y, TRUE); + CHAR_setWorkInt( charaindex, CHAR_MIND_NUM, nMind); + CHAR_sendMindEffect( charaindex, CHAR_getWorkInt( charaindex, CHAR_MIND_NUM)); + if(CHAR_getWorkInt( charaindex, CHAR_MIND_NUM) != 101290 && + CHAR_getWorkInt( charaindex, CHAR_MIND_NUM) != 101294 && + CHAR_getWorkInt( charaindex, CHAR_MIND_NUM) != 101288 ) + CHAR_setWorkInt( charaindex, CHAR_MIND_NUM, 0); + //print("\nshan------------------>end"); + + return; +} +#endif +BOOL checkStringErr( char *checkstring ) +{ + int i,ach; + for (i=0,ach=0;i=0x40)&&((unsigned char)checkstring[i]<=0x7e))|| + (((unsigned char)checkstring[i]>=0xa1)&&((unsigned char)checkstring[i]<=0xfe))) ach=0; + } else { + if (((unsigned char)checkstring[i]>=0xa1)&&((unsigned char)checkstring[i]<=0xfe)) ach=1; + } + } + if (ach) + { + print(" StringDog! "); + return TRUE; + } + + return FALSE; + +} + +#ifdef _FIX_DEL_MAP // WON ADD 玩家抽地图送监狱 +void lssproto_DM_recv( int fd ) +{ + int index; + index = CONNECT_getCharaindex( fd ); + if( !CHAR_CHECKINDEX( index)) return; + CHAR_warpToSpecificPoint(index,117,225,13); +} +#endif + +#ifdef _CHECK_GAMESPEED +void lssproto_CS_recv( int fd ) +{ + int index, Ttime, NowTimes; + index = CONNECT_getCharaindex( fd ); + if( !CHAR_CHECKINDEX( index)) return; + + NowTimes = (int)time(NULL); + Ttime = getGameSpeedTime( fd); + setGameSpeedTime( fd, NowTimes); + + if( CHAR_getWorkInt( index, CHAR_WORKFLG) & WORKFLG_DEBUGMODE ) { + }else if( (NowTimes-Ttime) < 20 ){ + lssproto_CS_send( fd, 20 - (NowTimes-Ttime)); + } +} +#endif + +#ifdef _TEAM_KICKPARTY +void lssproto_KTEAM_recv( int fd, int si) +{ + int charaindex=-1, pindex; + if( si < 0 || si > 5 ) return; + charaindex = CONNECT_getCharaindex( fd ); + if( !CHAR_CHECKINDEX( charaindex) ) return; + + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_LEADER ) return; + + pindex = CHAR_getWorkInt( charaindex, si + CHAR_WORKPARTYINDEX1); + if( !CHAR_CHECKINDEX( pindex) ) return; + if( CHAR_getWorkInt( pindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_LEADER ) return; + + if( CHAR_DischargeParty( pindex, 0) == FALSE ){ + CHAR_talkToCli( charaindex, -1, "踢除失败!", CHAR_COLORYELLOW); + }else{ + char buf1[256]; + sprintf( buf1, "队长[%s]将你踢除!", CHAR_getUseName( charaindex )); + CHAR_talkToCli( pindex, -1, buf1, CHAR_COLORYELLOW); + sprintf( buf1, "将[%s]踢除出团队!", CHAR_getUseName( pindex )); + CHAR_talkToCli( charaindex, -1, buf1, CHAR_COLORYELLOW); + } +} +#endif + +#ifdef _CHATROOMPROTOCOL // (不可开) Syu ADD 聊天室频道 +void lssproto_CHATROOM_recv (int fd , char *data) +{ + ChatRoom_recvall ( fd , data ) ; +} +#endif + +#ifdef _NEWREQUESTPROTOCOL // (不可开) Syu ADD 新增Protocol要求细项 +void lssproto_RESIST_recv (int fd ) +{ + int charindex = -1 ; + + char token[256]; + charindex = CONNECT_getCharaindex( fd ); + if( !CHAR_CHECKINDEX( charindex) ) return; + sprintf ( token , "%d|%d|%d|%d|%d|%d|%d|%d" , + CHAR_getInt( charindex, CHAR_EARTH_RESIST ) , + CHAR_getInt( charindex, CHAR_WATER_RESIST ) , + CHAR_getInt( charindex, CHAR_FIRE_RESIST ) , + CHAR_getInt( charindex, CHAR_WIND_RESIST ) , + CHAR_getInt( charindex, CHAR_EARTH_EXP ) , + CHAR_getInt( charindex, CHAR_WATER_EXP ) , + CHAR_getInt( charindex, CHAR_FIRE_EXP ) , + CHAR_getInt( charindex, CHAR_WIND_EXP ) + ); + lssproto_RESIST_send ( fd , token ) ; +} +#endif + +#ifdef _OUTOFBATTLESKILL // (不可开) Syu ADD 非战斗时技能Protocol +void lssproto_BATTLESKILL_recv (int fd, int iNum) +{ + int charaindex = CONNECT_getCharaindex( fd ); +#ifndef _PROSKILL_OPTIMUM + int skillindex=-1,char_pskill=-1,profession_skill=-1; +#endif + + if( !CHAR_CHECKINDEX( charaindex) ) return; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE ) return; + +#ifndef _PROSKILL_OPTIMUM // Robin fix cancel 此处略过职业检查, 改在 PROFESSION_SKILL_Use 中检查 + // 人物的职业 + char_pskill = CHAR_getInt( charaindex, PROFESSION_CLASS ); + + skillindex = PROFESSION_SKILL_GetArray( charaindex, iNum); + Pskillid = skillindex; + // 技能的职业 + profession_skill = PROFESSION_SKILL_getInt( Pskillid, PROFESSION_SKILL_PROFESSION_CLASS); + + if( (char_pskill > 0) && (char_pskill == profession_skill) ){ +#else + if( 1 ){ +#endif + if( PROFESSION_SKILL_Use( charaindex, iNum, 0, NULL ) != 1 ){ + print("\n 玩家(%s)使用技能错误!", CHAR_getUseName( charaindex ) ); + saacproto_ACKick_send( acfd, CHAR_getChar(charaindex,CHAR_CDKEY), getFdidFromCharaIndex( charaindex), 1); + } + } + +} + +#endif + +#ifdef _STREET_VENDOR +void lssproto_STREET_VENDOR_recv(int fd,char *message) +{ + int charaindex = CONNECT_getCharaindex(fd); + + if(!CHAR_CHECKINDEX(charaindex)) return; + if(CHAR_getWorkInt(charaindex,CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) return; + if(CHAR_getWorkInt(charaindex,CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE){ + CHAR_talkToCli(charaindex,-1,"组队状态下不能交易",CHAR_COLORYELLOW); + return; + } + CHAR_sendStreetVendor(charaindex,message); +} +#endif + +#ifdef _RIGHTCLICK +void lssproto_RCLICK_recv(int fd, int type, char* data) +{ + print("\n RCLICK_recv( type=%d data=%s) ", type, data); +} +#endif + +#ifdef _JOBDAILY +void lssproto_JOBDAILY_recv(int fd,char *data) +{ + int charaindex = CONNECT_getCharaindex(fd); + if(!CHAR_CHECKINDEX(charaindex)) return; + + CHAR_JobDaily(charaindex,data); +} +#endif + +#ifdef _TEACHER_SYSTEM +void lssproto_TEACHER_SYSTEM_recv(int fd,char *data) +{ + int charaindex = CONNECT_getCharaindex(fd); + + if(!CHAR_CHECKINDEX(charaindex)) return; + CHAR_Teacher_system(charaindex,data); +} +#endif diff --git a/gmsv/char/addressbook.c b/gmsv/char/addressbook.c new file mode 100644 index 0000000..b63599f --- /dev/null +++ b/gmsv/char/addressbook.c @@ -0,0 +1,907 @@ +#define __ADDRESSBOOK_C_ +#include "version.h" + +#include +#include +#include +#include + +#include "addressbook.h" +#include "char.h" +#include "handletime.h" +#include "buf.h" +#include "net.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "object.h" +#include "battle.h" +#include "configfile.h" +#include "npcutil.h" +#include "pet.h" +#include "petmail.h" +#include "log.h" + +/*裔烂丢永本□斥及 赢赢今[票匹烂聒允月 侬 及赢今反 + 仇木动票卞允月仇午*/ +#define ADDRESSBOOK_FIXEDMESSAGE_MAXLEN 128 + +/* 愤坌及蟆卞簿手中卅井匀凶及匹}失玉伊旦皮永弁卞馨笛匹五卅井匀凶 + 午五及裔烂丢永本□斥 */ +#define ADDRESSBOOK_CANTADD "那里没有任何人。" +#define ADDRESSBOOK_CANTADD2 "无法交换名片。" + +/* 簿井毛笛尹月仇午互匹五凶午五}笛尹方丹午仄凶谛卞霜耨允月丢永本□斥*/ +#define ADDRESSBOOK_ADDED "和%s交换名片 。" + +/* 簿井卞涌毛创尹日木凶日 */ +#define ADDRESSBOOK_BEINGADDED "和%s交换名片 。" + +/* 巨件玄伉互中匀天中分匀凶午五及丢永本□斥 */ +#define ADDRESSBOOK_MYTABLEFULL "名片匣已满。" + +/* 锹澎及巨件玄伉互中匀天中分匀凶午五及丢永本□斥 */ +#define ADDRESSBOOK_HISTABLEFULL "对方的名片匣已满。" + + +/* 丢永本□斥毛霜耨允月及卞岳 仄凶午五 */ +#define ADDRESSBOOK_SENT "送信给%s 。" + +/* 丢永本□斥毛霜耨允月及卞撩 仄凶午五 */ +#define ADDRESSBOOK_UNSENT "无法送信给%s 。" + +/* 簿井毛创尹方丹午仄凶互}湃卞创尹化中凶 */ +#define ADDRESSBOOK_ALREADYADDED "已经和%s交换过名片了。 " + +/* 铜毛域 读卞 丹橇谪 */ +#define ADDRESSBOOK_GIVEADDRESS "从%s得到名片。" + +/* 铜毛域 读卞丐仆月橇谪 */ +#define ADDRESSBOOK_TAKEADDRESS1 "给%s自己的名片。" +/* 铜毛域 读卞丐仆月橇谪 */ +#define ADDRESSBOOK_TAKEADDRESS2 "因为%s想要名片,所以将名片给他了。" + +#define ADDRESSBOOK_RETURNED1 \ +"从%s寄来信件,但由於没有%s的名片又将信件退回。" + +#define ADDRESSBOOK_RETURNED2 \ +"寄信件给%s,但由於%s 没有名片,所以信件又被退回来了。" + +#define PETMAIL_RETURNED1 \ +"%s不在这个世界里,所以无法寄送信件给他。" + + +/* static匹银丹迕[ 五中袄手*/ +char ADDRESSBOOK_returnstring[25*128]; + + + +static int ADDRESSBOOK_findBlankEntry( int cindex ); +static BOOL ADDRESSBOOK_makeEntryFromCharaindex( int charaindex, + ADDRESSBOOK_entry* ae); + +/*------------------------------------------------------------ + * 失玉伊旦皮永弁及丢永本□斥毛霜耨允月 + * MSG皿夫玄戊伙井日勾井歹木月[ + * + * 支月仇午反}connection井日cdkey匹腹绸仄化}平乓仿 手 + * 甲永玄仄凶日} MSG_send允月[公及午五卞}愤坌及树 互 + * 锹澎及伉旦玄卞卅井匀凶日窒手仄卅中午中丹仇午分[ + * 娄醒 + * cindex int 平乓仿及index + * aindex int 失玉伊旦皮永弁及index + * text char* 霜耨允月 侬 + * color int 缙 + * 忒曰袄 + * 左件仿奶件及平乓仿卞丢永本□斥毛霜耨仄凶日TRUE , + * 左白仿奶件卞瓒 仄凶日FALSE毛井尹允 + ------------------------------------------------------------*/ +BOOL ADDRESSBOOK_sendMessage( int cindex, int aindex, char* text , int color ) +{ + int i ; + char tmpmsg[256]; + char textbuffer[2048]; + char *mycd; + char *mycharaname = CHAR_getChar(cindex,CHAR_NAME ); + struct tm tm1; + ADDRESSBOOK_entry *ae; + int playernum = CHAR_getPlayerMaxNum(); + + if( !CHAR_CHECKINDEX(cindex) )return FALSE; + + ae = CHAR_getAddressbookEntry( cindex , aindex ); + if( ae == NULL )return FALSE; + + //getcdkeyFromCharaIndex(cindex, mycd,sizeof(mycd) ); + mycd = CHAR_getChar( cindex, CHAR_CDKEY); + + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + + snprintf( textbuffer, sizeof( textbuffer), + "%2d/%02d %2d:%02d|%s|-1", + tm1.tm_mon +1, tm1.tm_mday, tm1.tm_hour, tm1.tm_min, + text); + + /* 扔□田□ 卞中月凛 */ + for( i = 0 ; i < playernum ; i ++){ + if( CHAR_CHECKINDEX( i) && + strcmp( CHAR_getChar( i, CHAR_CDKEY), ae->cdkey) == 0 && + strcmp( CHAR_getChar( i, CHAR_NAME), ae->charname) == 0 ) + { + /* + * CDKEY 手 平乓仿 手域谯仄凶[公及平乓仿弁正及 + * 失玉伊旦皮永弁卞愤坌及树 互丐月井譬屯化} + * 绣箕仄凶日}MSG允月[ + */ + int index_to_my_info = + ADDRESSBOOK_getIndexInAddressbook( i , + mycd, mycharaname); + + int fd; + if( index_to_my_info < 0 ){ + /* + * 锹澎互愤坌毛坫壅仄化仄引匀化月[ + * 域杀 谛卞]丢□伙互 凶午分仃骚襞允月[ + */ + //snprintf( tmpmsg, sizeof( tmpmsg), + // ADDRESSBOOK_RETURNED1, + // ae->charname + // ); + + //CHAR_talkToCli( CONNECT_getCharaindex(i), -1, + // tmpmsg , CHAR_COLORYELLOW ); + + snprintf( tmpmsg, sizeof( tmpmsg), + ADDRESSBOOK_RETURNED2, + CHAR_getChar( i, CHAR_NAME), + CHAR_getChar( i, CHAR_NAME)); + + /* 霜曰潜卞手丢永本□斥 */ + CHAR_talkToCli( cindex, -1, + tmpmsg , CHAR_COLORYELLOW ); + return FALSE; + } + + fd = getfdFromCharaIndex( i); + if( fd != -1 ) { + lssproto_MSG_send( fd , index_to_my_info , textbuffer , color ); + /* 夫弘午曰 */ + printl( LOG_TALK, "CD=%s\tNM=%s\tT=%s" , mycd, mycharaname, textbuffer ); + + } + + snprintf( tmpmsg , sizeof( tmpmsg),ADDRESSBOOK_SENT, + ae->charname ); + CHAR_talkToCli(cindex,-1, tmpmsg , color ); + + // WON ADD 修正snprintf会导致当机的bug + { + char tmp[1000]; + sprintf( tmp , "ADDRESSBOOK_sendMessage:" + "Send MSG to: %s %s\n", + ae->cdkey , ae->charname ); + // print( tmp ); + } + + CHAR_setInt( cindex, CHAR_SENDMAILCOUNT, + CHAR_getInt( cindex, CHAR_SENDMAILCOUNT)+1); + return TRUE; + } + } + /* 苇勾井日卅井匀凶凛反]失市它件玄扔□田□卞霜月 */ + saacproto_Message_send( acfd, mycd, mycharaname, + ae->cdkey, ae->charname, textbuffer, color); + CHAR_setInt( cindex, CHAR_SENDMAILCOUNT, + CHAR_getInt( cindex, CHAR_SENDMAILCOUNT)+1); + + + snprintf( tmpmsg , sizeof( tmpmsg),ADDRESSBOOK_SENT,ae->charname ); + CHAR_talkToCli( cindex,-1, tmpmsg , CHAR_COLORWHITE ); + + return FALSE; +} +/*------------------------------------------------------------ + * 失玉伊旦皮永弁及丢永本□斥毛霜耨允月 + * saac 井日msg 毛熬仃午匀化弁仿奶失件玄卞禾旦玄允月[ + * + * 忒曰袄 + ------------------------------------------------------------*/ +BOOL ADDRESSBOOK_sendMessage_FromOther( char *fromcdkey, char *fromcharaname, + char *tocdkey, char *tocharaname, + char* text , int color ) +{ +#define ADDRESSBOOK_SYSTEM "system" + + int i ; + char tmpmsg[256]; + int playernum = CHAR_getPlayerMaxNum(); + + /* 扔□田□ 毛腹绸允月 */ + for( i = 0 ; i < playernum ; i ++){ + if( CHAR_CHECKINDEX( i) && + strcmp( CHAR_getChar( i, CHAR_CDKEY), tocdkey) == 0 && + strcmp( CHAR_getChar( i, CHAR_NAME), tocharaname) == 0) + { + int index_to_my_info; + /* + * CDKEY 手 平乓仿 手域谯仄凶[公及平乓仿弁正及 + * 失玉伊旦皮永弁卞愤坌及树 互丐月井譬屯化} + * 绣箕仄凶日}MSG允月[ + */ + + /* 扑旦 丞丢永本□斥互窖匀化五凶 */ + if( strcmp( fromcdkey, ADDRESSBOOK_SYSTEM) == 0 && + strcmp( fromcharaname, ADDRESSBOOK_SYSTEM ) == 0 ) + { + /* 扑旦 丞丢永本□斥毛龚仁 */ + CHAR_talkToCli( i, -1, text , color ); + break; + } + + index_to_my_info = + ADDRESSBOOK_getIndexInAddressbook( i , + fromcdkey, fromcharaname); + if( index_to_my_info < 0 ){ + /* + * 锹澎互愤坌毛坫壅仄化仄引匀化月[ + */ + + snprintf( tmpmsg, sizeof( tmpmsg), ADDRESSBOOK_RETURNED2, + tocharaname, tocharaname); + + /* 霜曰潜卞手丢永本□斥 */ + saacproto_Message_send( acfd, ADDRESSBOOK_SYSTEM , ADDRESSBOOK_SYSTEM, + fromcdkey, fromcharaname, tmpmsg, CHAR_COLORYELLOW); + + } + else { + int fd = getfdFromCharaIndex( i); + if( fd != -1 ) { + lssproto_MSG_send( fd , index_to_my_info , text , color ); + /* 夫弘午曰 */ + printl( LOG_TALK, "CD=%s\tNM=%s\tT=%s" , fromcdkey, + fromcharaname, text ); + } + } + break; + } + } + if( i == playernum ) return FALSE; + return TRUE; +} + +int ADDRESSBOOK_getIndexInAddressbook(int cindex , char *cdkey, + char *charname) +{ + int i ; + + if( !CHAR_CHECKINDEX( cindex ) ) return -1; + + for( i = 0 ; i < ADDRESSBOOK_MAX ; i++){ + ADDRESSBOOK_entry *ae = CHAR_getAddressbookEntry( cindex , i ); + if( ae && ae->use && strcmp( ae->cdkey, cdkey )==0 && + strcmp( ae->charname , charname ) == 0 ){ + return i; + } + } + return -1; +} + +BOOL ADDRESSBOOK_deleteEntry( int meindex ,int index ) +{ + ADDRESSBOOK_entry ent; + BOOL ret; + if( !CHAR_CHECKINDEX( meindex ) ) return FALSE; + + memset( &ent ,0, sizeof( ADDRESSBOOK_entry )); + ret = CHAR_setAddressbookEntry( meindex , index , &ent ); + if( ret == TRUE ){ + ADDRESSBOOK_sendAddressbookTable( meindex ); + return TRUE; + } + return FALSE; +} + +BOOL ADDRESSBOOK_addEntry( int meindex ) +{ + int objbuf[20]; + int found_count; + int front_x , front_y; + int i; + int cnt = 0; + int fd; + char *mycd , *tocd; + BOOL found = FALSE; + + if( !CHAR_CHECKINDEX( meindex ) )return FALSE; + + fd = getfdFromCharaIndex( meindex); + if( fd == -1 ) return FALSE; + + if( ADDRESSBOOK_findBlankEntry( meindex ) < 0) { + CHAR_talkToCli( meindex , -1,ADDRESSBOOK_MYTABLEFULL,CHAR_COLORWHITE ); + return FALSE; + } + + for( i = 0; i < CONNECT_WINDOWBUFSIZE; i ++ ) { + CONNECT_setTradecardcharaindex( fd,i,-1); + } + + CHAR_getCoordinationDir( CHAR_getInt( meindex, CHAR_DIR ) , + CHAR_getInt( meindex , CHAR_X ), + CHAR_getInt( meindex , CHAR_Y ) , + 1 , &front_x , &front_y ); + + found_count = CHAR_getSameCoordinateObjects( objbuf, + arraysizeof( objbuf), + CHAR_getInt(meindex,CHAR_FLOOR), + front_x,front_y ); + if( found_count == 0 ){ + CHAR_talkToCli( meindex, -1, ADDRESSBOOK_CANTADD, CHAR_COLORWHITE); + return FALSE; + } + for( i = 0 ; i < found_count; i++ ){ + int objindex = objbuf[i]; + int index = OBJECT_getIndex( objindex); + if( OBJECT_getType(objindex) != OBJTYPE_CHARA ) { + continue; + } + if( CHAR_getInt( index,CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ){ + continue; + } + if( index == meindex ) { + continue; + } + found = TRUE; + if( CHAR_getWorkInt( index, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) { + continue; + } + if(!CHAR_getFlg( index, CHAR_ISTRADECARD)) { + continue; + } + if( ADDRESSBOOK_findBlankEntry( index ) < 0 ) { + continue; + } + tocd = CHAR_getChar( index, CHAR_CDKEY); + mycd = CHAR_getChar( meindex, CHAR_CDKEY); + if( ADDRESSBOOK_getIndexInAddressbook( meindex, tocd, + CHAR_getChar( index, CHAR_NAME)) >= 0 && + ADDRESSBOOK_getIndexInAddressbook( index, mycd, + CHAR_getChar(meindex, CHAR_NAME) ) >= 0 ) { + continue; + } + + CONNECT_setTradecardcharaindex( fd,cnt,index); + cnt ++; + if( cnt == CONNECT_WINDOWBUFSIZE ) break; + } + + if( cnt == 0 ) { + if( found ) { + CHAR_talkToCli( meindex, -1, ADDRESSBOOK_CANTADD2, CHAR_COLORWHITE); + }else { + CHAR_talkToCli( meindex, -1, ADDRESSBOOK_CANTADD, CHAR_COLORWHITE); + } + return FALSE; + } + if( cnt == 1 ) { + ADDRESSBOOK_addAddressBook( meindex, + CONNECT_getTradecardcharaindex(fd,0) ); + return TRUE; + }else if( cnt > 1 ) { + int strlength; + char msgbuf[1024]; + char escapebuf[2048]; + strcpy( msgbuf, "1\n和谁交换名片呢?\n"); + strlength = strlen( msgbuf); + for( i = 0; + CONNECT_getTradecardcharaindex(fd,i) != -1 + && i< CONNECT_WINDOWBUFSIZE; i ++ ){ + char *a = CHAR_getChar( CONNECT_getTradecardcharaindex(fd,i), + CHAR_NAME); + char buf[256]; + snprintf( buf, sizeof( buf),"%s\n", a); + if( strlength + strlen( buf) > arraysizeof( msgbuf)){ + print( "%s:%d视窗讯息buffer不足。\n", + __FILE__,__LINE__); + break; + } + strcpy( &msgbuf[strlength], buf); + strlength += strlen(buf); + } + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_SELECTTRADECARD, + -1, + makeEscapeString( msgbuf, escapebuf, sizeof(escapebuf))); + return TRUE; + } + + return FALSE; +} + +static int ADDRESSBOOK_findBlankEntry( int cindex ) +{ + int i; + + if( CHAR_CHECKINDEX( cindex ) == FALSE )return -1; + + for( i=0 ; iuse == FALSE ) { + return i; + } + } + return -1; +} + +static BOOL ADDRESSBOOK_makeEntryFromCharaindex( int charaindex, + ADDRESSBOOK_entry* ae) +{ + char *cdkey; + + if( !CHAR_CHECKINDEX(charaindex) ) return FALSE; + + memset( ae,0,sizeof(ADDRESSBOOK_entry) ); + cdkey = CHAR_getChar( charaindex, CHAR_CDKEY); + if( cdkey == NULL ){ + print( "ADDRESSBOOK_makeEntryFromCharaindex:" + " strange! getcdkeyFromCharaIndex returns NULL!" + " charaindex: %d\n" , charaindex ); + return FALSE; + } + strcpysafe( ae->cdkey , sizeof( ae->cdkey ),cdkey); + + strcpysafe( ae->charname,sizeof( ae->charname), + CHAR_getChar(charaindex,CHAR_NAME) ); + ae->level = CHAR_getInt( charaindex , CHAR_LV ); + ae->duelpoint = CHAR_getInt( charaindex, CHAR_DUELPOINT); + ae->graphicsno = CHAR_getInt( charaindex , CHAR_FACEIMAGENUMBER ); + ae->online = getServernumber(); + ae->use = TRUE; + ae->transmigration = CHAR_getInt( charaindex, CHAR_TRANSMIGRATION); + + return TRUE; +} + +void ADDRESSBOOK_notifyLoginLogout( int cindex , int flg ) +{ + int i; + char *cd=NULL; + char *nm = CHAR_getChar( cindex , CHAR_NAME ); + int playernum = CHAR_getPlayerMaxNum(); + + if( !CHAR_CHECKINDEX( cindex ) )return; + cd = CHAR_getChar( cindex, CHAR_CDKEY); + + CHAR_send_DpDBUpdate_AddressBook( cindex, flg ); + + for( i = 0 ; i < playernum ; i++){ + if( CHAR_CHECKINDEX( i) && i != cindex ) { + int j; + for( j = 0 ; juse == TRUE && + strcmp( ae->cdkey , cd ) == 0 && + strcmp( ae->charname, nm ) == 0 ){ + + ae->online = (flg == 0 ) ? 0: getServernumber(); + ae->level = CHAR_getInt( cindex , CHAR_LV ); + ae->duelpoint = CHAR_getInt( cindex, CHAR_DUELPOINT); + ae->graphicsno = CHAR_getInt( cindex, CHAR_FACEIMAGENUMBER ); + ae->transmigration = CHAR_getInt( cindex, CHAR_TRANSMIGRATION); + + ADDRESSBOOK_sendAddressbookTableOne( i,j ); + + break; + } + } + } + } + + if( flg == 0 ){ + saacproto_Broadcast_send( acfd,cd, nm, "offline", 1); + }else if( flg == 1 ) { + for( i = 0 ; i < ADDRESSBOOK_MAX; i++ ){ + int j; + ADDRESSBOOK_entry* ae; + ae = CHAR_getAddressbookEntry( cindex, i ); + if( ae->use == 0 )continue; + ae->online = 0; + for( j=0 ; j < playernum ; j++ ) { + if( CHAR_CHECKINDEX( j) && + strcmp( ae->cdkey, CHAR_getChar( j, CHAR_CDKEY)) == 0 && + strcmp( ae->charname, CHAR_getChar( j, CHAR_NAME) )== 0){ + ae->level = CHAR_getInt( j, CHAR_LV ); + ae->graphicsno = CHAR_getInt( j, CHAR_FACEIMAGENUMBER ); + ae->online = getServernumber(); + ae->transmigration = CHAR_getInt( j, CHAR_TRANSMIGRATION); + break; + } + } + if( j == playernum) { +#ifndef _DEATH_CONTEND + char buff[512]; + char escapebuf[1024]; + ae->online = 0; + snprintf( buff, sizeof(buff), "%s_%s", ae->cdkey, ae->charname); + makeEscapeString( buff, escapebuf, sizeof(escapebuf)); + saacproto_DBGetEntryString_send( acfd, DB_ADDRESSBOOK, escapebuf, 0,0); +#endif + } + } + ADDRESSBOOK_sendAddressbookTable(cindex); + saacproto_Broadcast_send( acfd,cd, nm, "online", 1); + saacproto_MessageFlush_send( acfd, cd, nm); + } +} + +BOOL ADDRESSBOOK_sendAddressbookTable( int cindex ) +{ + int stringlen=0; + int i; + + if( !CHAR_CHECKINDEX( cindex ) )return FALSE; + + for( i=0 ; iuse ){ + char tmp[CHARNAMELEN+32]; + char charname_escaped[CHARNAMELEN*2]; + makeEscapeString( ae->charname, charname_escaped , + sizeof(charname_escaped )); + /* 银迕白仿弘| 蟆|伊矛伙|仿奶白|白仿弘 */ + snprintf( tmp , sizeof( tmp ), + "%d|%s|%d|%d|%d|%d|%d|" , + ae->use, + charname_escaped , ae->level , + ae->duelpoint,ae->online,ae->graphicsno, + ae->transmigration); + strcpysafe ( ADDRESSBOOK_returnstring + stringlen , + sizeof(ADDRESSBOOK_returnstring) - stringlen, + tmp ); + stringlen += strlen( tmp ); + if( stringlen >= sizeof(ADDRESSBOOK_returnstring) ) { + break; + } + }else{ + /*银匀化卅中犯□正手冲徇及心匹霜月 */ + char tmp[32]; + snprintf( tmp , sizeof( tmp ), "|||||||" ); + strcpysafe ( ADDRESSBOOK_returnstring + stringlen , + sizeof(ADDRESSBOOK_returnstring) - stringlen, + tmp ); + stringlen += strlen( tmp ); + if( stringlen >= sizeof(ADDRESSBOOK_returnstring)) { + break; + } + } + } + + dchop( ADDRESSBOOK_returnstring, "|" ); + + { + int fd; + fd = getfdFromCharaIndex( cindex ); + if( fd == -1 ) return FALSE; + lssproto_AB_send( fd, ADDRESSBOOK_returnstring ); + } + return TRUE; +} + +BOOL ADDRESSBOOK_sendAddressbookTableOne( int cindex, int num ) +{ + int stringlen=0; + ADDRESSBOOK_entry *ae; + + if( !CHAR_CHECKINDEX( cindex ) )return FALSE; + if( num < 0 || num > ADDRESSBOOK_MAX) return FALSE; + + ae = CHAR_getAddressbookEntry( cindex , num ); + + if( ae && ae->use ){ + char tmp[CHARNAMELEN+32]; + char charname_escaped[CHARNAMELEN*2]; + makeEscapeString( ae->charname, charname_escaped , + sizeof(charname_escaped )); + snprintf( tmp , sizeof( tmp ), + "%d|%s|%d|%d|%d|%d|%d|" , + ae->use, + charname_escaped , ae->level , + ae->duelpoint,ae->online,ae->graphicsno, + ae->transmigration); + strcpysafe ( ADDRESSBOOK_returnstring + stringlen , + sizeof(ADDRESSBOOK_returnstring) - stringlen, + tmp ); + stringlen += strlen( tmp ); + if( stringlen >= sizeof(ADDRESSBOOK_returnstring) ) { + return FALSE; + } + }else{ + char tmp[32]; + snprintf( tmp , sizeof( tmp ), "|||||||" ); + strcpysafe ( ADDRESSBOOK_returnstring + stringlen , + sizeof(ADDRESSBOOK_returnstring) - stringlen, + tmp ); + stringlen += strlen( tmp ); + if( stringlen >= sizeof(ADDRESSBOOK_returnstring)) { + return FALSE; + } + } + + { + int fd; + fd = getfdFromCharaIndex( cindex ); + if( fd == -1 ) return FALSE; + lssproto_ABI_send( fd, num, ADDRESSBOOK_returnstring ); + } + return TRUE; +} + +/*------------------------------------------------------------ + * 夫午勾及失玉伊旦皮永弁巨件玄伉毛} 侬 卞卅云允[ + * 仇木反平乓仿忡绣迕卅及匹弁仿奶失件玄卞霜耨允月方曰手恳割 + * 卅手及匹丐月 邰互丐月[ + * 娄醒 + * a ADDRESSBOOK_entry* 侬 卞仄凶中厌瞻 尺及禾奶件正 + * 忒曰袄 + * char * + ------------------------------------------------------------*/ +char *ADDRESSBOOK_makeAddressbookString( ADDRESSBOOK_entry *a ) +{ + char work1[256], work2[256]; + + if( a->use == 0 ){ + /* 坞巨件玄伉分匀凶日坞 侬 */ + ADDRESSBOOK_returnstring[0] = '\0'; + return ADDRESSBOOK_returnstring; + } + + makeEscapeString( a->cdkey, work1, sizeof( work1 )); + makeEscapeString( a->charname , work2 , sizeof( work2 )); + snprintf( ADDRESSBOOK_returnstring, + sizeof( ADDRESSBOOK_returnstring ), + "%s|%s|%d|%d|%d|%d", + work1, work2, a->level, a->duelpoint, a->graphicsno,a->transmigration); + + return ADDRESSBOOK_returnstring; + +} + +/*------------------------------------------------------------ + * 侬 祭今木化中月失玉伊旦皮永弁巨件玄伉毛}厌瞻 卞卅云允[ + * 仇及瑛绊厌瞻 及use动陆及树 反敦僬卞卅月[ + * 娄醒 + * in char* 侬 + * a ADDRESSBOOK_entry* 犯□正毛璋户月赭 + * 忒曰袄 + * 勾友卞TRUE + ------------------------------------------------------------*/ +BOOL ADDRESSBOOK_makeAddressbookEntry( char *in , ADDRESSBOOK_entry *a ) +{ + char work1[256], work2[256] , work3[256] , work4[256],work5[256],work6[256]; + int ret; + if( strlen( in ) == 0 ){ + memset( a,0,sizeof(ADDRESSBOOK_entry) ); + a->use = 0; + return TRUE; + } + + getStringFromIndexWithDelim( in, "|" , 1 , work1 , sizeof( work1 )); + getStringFromIndexWithDelim( in, "|" , 2 , work2 , sizeof( work2 )); + getStringFromIndexWithDelim( in, "|" , 3 , work3 , sizeof( work3 )); + getStringFromIndexWithDelim( in, "|" , 4 , work4 , sizeof( work4 )); + getStringFromIndexWithDelim( in, "|" , 5 , work5 , sizeof( work5 )); + work6[0] = '\0'; + ret = getStringFromIndexWithDelim( in, "|" , 6 , work6 , sizeof( work6 )); + if( ret == FALSE ) { + a->transmigration = 0; + } + else { + a->transmigration = atoi( work6); + } + a->use = 1; + + makeStringFromEscaped( work1 ); + makeStringFromEscaped( work2 ); + + strcpysafe( a->cdkey , sizeof(a->cdkey) , work1 ); + strcpysafe( a->charname , sizeof(a->charname), work2 ); + + a->level = atoi( work3 ); + a->duelpoint = atoi( work4 ); + a->graphicsno = atoi( work5 ); + + return FALSE; +} + +void ADDRESSBOOK_addAddressBook( int meindex, int toindex) +{ + char tmpstring[CHARNAMELEN + + ADDRESSBOOK_FIXEDMESSAGE_MAXLEN]; + + int hisblank; + int myblank; + int myaddindex, toaddindex; + int dir; + char *cdkey; + + hisblank = ADDRESSBOOK_findBlankEntry( toindex ); + if( hisblank < 0 ) { + CHAR_talkToCli( meindex, -1, ADDRESSBOOK_HISTABLEFULL, CHAR_COLORWHITE); + return ; + } + myblank = ADDRESSBOOK_findBlankEntry( meindex ); + if( myblank < 0 ){ + CHAR_talkToCli( meindex , -1, ADDRESSBOOK_MYTABLEFULL, CHAR_COLORWHITE ); + return ; + } + + cdkey = CHAR_getChar( toindex, CHAR_CDKEY); + myaddindex = ADDRESSBOOK_getIndexInAddressbook( meindex, cdkey, + CHAR_getChar( toindex, CHAR_NAME)); + cdkey = CHAR_getChar( meindex, CHAR_CDKEY); + toaddindex = ADDRESSBOOK_getIndexInAddressbook( toindex, cdkey, + CHAR_getChar(meindex, CHAR_NAME)); + if( myaddindex < 0 ){ + ADDRESSBOOK_entry hisentry; + + if( ADDRESSBOOK_makeEntryFromCharaindex(toindex,&hisentry) == FALSE ){ + return ; + } + CHAR_setAddressbookEntry( meindex, myblank,&hisentry ); + + snprintf( tmpstring, sizeof( tmpstring), + toaddindex < 0 ? ADDRESSBOOK_ADDED: ADDRESSBOOK_GIVEADDRESS, + hisentry.charname); + CHAR_talkToCli( meindex , -1,tmpstring, CHAR_COLORWHITE ); + ADDRESSBOOK_sendAddressbookTableOne( meindex, myblank); + }else{ + snprintf( tmpstring, sizeof( tmpstring), ADDRESSBOOK_TAKEADDRESS1, + CHAR_getChar( toindex, CHAR_NAME)); + CHAR_talkToCli( meindex, -1, tmpstring, CHAR_COLORWHITE); + + } + if( toaddindex < 0 ) { + ADDRESSBOOK_entry meae; + if( ADDRESSBOOK_makeEntryFromCharaindex(meindex,&meae) == FALSE) { + return; + } + CHAR_setAddressbookEntry( toindex, hisblank,&meae ); + snprintf( tmpstring , sizeof( tmpstring), + myaddindex < 0 ? ADDRESSBOOK_ADDED : ADDRESSBOOK_GIVEADDRESS, + CHAR_getChar( meindex, CHAR_NAME ) ); + CHAR_talkToCli( toindex, -1, tmpstring, CHAR_COLORWHITE); + ADDRESSBOOK_sendAddressbookTableOne( toindex , hisblank); + }else { + if( myaddindex < 0 ) { + snprintf( tmpstring , sizeof( tmpstring), + ADDRESSBOOK_TAKEADDRESS2, + CHAR_getChar( meindex, CHAR_NAME ) ); + CHAR_talkToCli( toindex, -1, tmpstring, CHAR_COLORWHITE); + } + } + dir = NPC_Util_GetDirCharToChar( toindex, meindex, 0); + if( dir != -1) { + + if( CHAR_getInt( toindex, CHAR_DIR) != dir) { + CHAR_setInt( toindex, CHAR_DIR, dir); + } + CHAR_sendWatchEvent( CHAR_getWorkInt( toindex, CHAR_WORKOBJINDEX), + CHAR_ACTNOD,NULL,0,TRUE); + CHAR_setWorkInt( toindex, CHAR_WORKACTION, CHAR_ACTNOD); + CHAR_sendWatchEvent( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + CHAR_ACTNOD,NULL,0,TRUE); + CHAR_setWorkInt( meindex, CHAR_WORKACTION, CHAR_ACTNOD); + } + return; +} + + +void ADDRESSBOOK_DispatchMessage( char *cd, char *nm, char *value, int mode) +{ + int i; + char work[256]; + int online,level,duelpoint, faceimagenumber, transmigration; + int playernum = CHAR_getPlayerMaxNum(); + int ret; + + getStringFromIndexWithDelim( value, "|" , 1 , work , sizeof( work )); + online = atoi( work); + getStringFromIndexWithDelim( value, "|" , 2 , work , sizeof( work )); + level = atoi( work); + getStringFromIndexWithDelim( value, "|" , 3 , work , sizeof( work )); + duelpoint = atoi( work); + getStringFromIndexWithDelim( value, "|" , 4 , work , sizeof( work )); + faceimagenumber = atoi( work); + ret = getStringFromIndexWithDelim( value, "|" , 5 , work , sizeof( work )); + if( ret ) { + transmigration = atoi( work); + } + else { + transmigration = 0; + } + + if( online == getServernumber()) { + for( i = 0 ; i < playernum ; i++) { + if( CHAR_CHECKINDEX( i )) { + char *c = CHAR_getChar( i, CHAR_CDKEY); + char *n = CHAR_getChar( i, CHAR_NAME); + if( c == NULL || n == NULL ) continue; + if( strcmp( c , cd ) == 0 && strcmp( n, nm ) == 0 ) { + break; + } + } + } + if( i == playernum ) { + online = 0; + saacproto_Broadcast_send( acfd,cd, nm, "offline", 1); + } + } + + for( i = 0 ; i < playernum ; i++) { + if( CHAR_CHECKINDEX( i )) { + int j; + for( j = 0 ; j < ADDRESSBOOK_MAX ; j++) { + ADDRESSBOOK_entry *ae; + ae = CHAR_getAddressbookEntry( i ,j ); + if( ae && ae->use == TRUE && + strcmp( ae->cdkey , cd ) == 0 && + strcmp( ae->charname, nm ) == 0 ) + { + if( mode == 0 ) { + ae->use = FALSE; + }else { + ae->online = online; + ae->level = level; + ae->duelpoint = duelpoint; + ae->graphicsno = faceimagenumber; + ae->transmigration = transmigration; + } + ADDRESSBOOK_sendAddressbookTableOne( i,j ); + + break; + } + } + } + } +} + + +BOOL ADDRESSBOOK_AutoaddAddressBook( int meindex, int toindex) +{ + int hisblank; + int myblank; + int myaddindex, toaddindex; + + char *cdkey; + + myblank = ADDRESSBOOK_findBlankEntry( meindex ); + hisblank = ADDRESSBOOK_findBlankEntry( toindex ); + if( hisblank < 0 || myblank < 0) { //"名片匣已满。" + return FALSE; + } + + cdkey = CHAR_getChar( toindex, CHAR_CDKEY); + myaddindex = ADDRESSBOOK_getIndexInAddressbook( meindex, cdkey, + CHAR_getChar( toindex, CHAR_NAME)); + cdkey = CHAR_getChar( meindex, CHAR_CDKEY); + toaddindex = ADDRESSBOOK_getIndexInAddressbook( toindex, cdkey, + CHAR_getChar(meindex, CHAR_NAME)); + if( myaddindex < 0 ){ + ADDRESSBOOK_entry meae; + ADDRESSBOOK_entry hisentry; + if( ADDRESSBOOK_makeEntryFromCharaindex(toindex,&hisentry) == FALSE || + ADDRESSBOOK_makeEntryFromCharaindex(meindex,&meae) == FALSE ){ + return FALSE; + } + CHAR_setAddressbookEntry( meindex, myblank,&hisentry ); + CHAR_setAddressbookEntry( toindex, hisblank,&meae ); + ADDRESSBOOK_sendAddressbookTableOne( meindex, myblank); + ADDRESSBOOK_sendAddressbookTableOne( toindex , hisblank); + } + return TRUE; +} + diff --git a/gmsv/char/char.c b/gmsv/char/char.c new file mode 100644 index 0000000..18f5808 --- /dev/null +++ b/gmsv/char/char.c @@ -0,0 +1,8706 @@ +#include "version.h" +#include +#include +#include +#include // shan +#include +#include +#include +#include +#include "common.h" +#include "char_base.h" +#include "char_data.h" +#include "char.h" +#include "lssproto_serv.h" +#include "item.h" +#include "item_event.h" +#include "buf.h" +#include "object.h" +#include "map_deal.h" +#include "saacproto_cli.h" +#include "readmap.h" +#include "handletime.h" +#include "char_event.h" +#include "npccreate.h" +#include "addressbook.h" +#include "item_event.h" +#include "magic_base.h" +#include "magic.h" +#include "chatmagic.h" +#include "configfile.h" +#include "log.h" +#include "anim_tbl.h" +#include "encount.h" +#include "battle.h" +#include "pet_skill.h" +#include "util.h" +#include "enemy.h" +#include "npcutil.h" +#include "pet.h" +#include "family.h" +#include "defend.h" +#ifdef _NPCSERVER_NEW +#include "npcserver.h" +#endif +#ifdef _DEATH_CONTEND +#include "deathcontend.h" +#endif +#include "correct_bug.h" +#ifdef _JOBDAILY +#include "npc_checkman.h" +#endif + +#ifdef _CHAR_PROFESSION // WON ADD 人物职业栏位 +#include "profession_skill.h" +#endif +#ifdef _CHATROOMPROTOCOL // (不可开) Syu ADD 聊天室频道 +#include "chatroom.h" +#endif + +extern int channelMember[FAMILY_MAXNUM][FAMILY_MAXCHANNEL][FAMILY_MAXMEMBER]; +extern int familyMemberIndex[FAMILY_MAXNUM][FAMILY_MAXMEMBER]; + +extern tagRidePetTable ridePetTable[296]; +extern int BATTLE_getRidePet( int charaindex ); + +#ifdef _CHANNEL_MODIFY +extern int InitOccChannel(void); +#endif + +#ifdef _ANGEL_SUMMON +extern int checkIfAngelByName( char* nameinfo); +extern char* getMissionNameInfo( int charaindex, char* nameinfo); +extern void CHAR_sendAngelMark( int objindex, int flag); +extern int checkIfOnlyAngel( int charaindex); +extern void selectAngel( int charaindex, int heroindex, int mission, int gm_cmd); +#endif + +extern void GOLD_DeleteTimeCheckOne( int objindex); + +// WON ADD 修正道具的设定问题 +void fix_item_bug(int charaindex, int i); + + +/*====================平乓仿及综岳卞楮允月楮醒====================*/ +/*------------------------------------------------------------ + * 综岳允月凛及左皿扑亦件及袄毛涩烂仄方丹午允月[ + * 娄醒 + * ch Char* 涩烂燮及平乓仿及犯□正 + * option char* 弁仿奶失件玄井日仁月犯□正 + * 忒曰袄 + * 岳 TRUE + * 撩 FALSE + ------------------------------------------------------------*/ +static BOOL CHAR_makeCharFromOptionAtCreate( Char* ch , + int vital, int str, int tgh, int dex, + int earth, int water, int fire, int wind) +{ + + /* 躲岭及腹据毛垫丹 */ + int para[4]; + int attr[4]; + int i; + int parasum,attrsum; + int cnt; + + para[0] = vital; + para[1] = str; + para[2] = tgh; + para[3] = dex; + + attr[0] = earth; + attr[1] = water; + attr[2] = fire; + attr[3] = wind; + +#define MAXPARAMETER 20 +#define PKMAXPARAMETER 300 + parasum = 0; + /* + * 允屯化及犯□正及 卞 - 反丐匀化反卅日卅中仄 + * 瑕丐孔木及仪毛哔尹化云中化 及袄手译尹卅中 + */ + + for( i = 0; i < arraysizeof( para); i ++ ) { + if( para[i] < 0 || para[i] > MAXPARAMETER )return FALSE; + parasum += para[i]; + } +#ifdef _NEW_PLAYER_CF //新手出生配置 + if( parasum > MAXPARAMETER ) return FALSE; +#else + if( parasum != MAXPARAMETER ) return FALSE; +#endif + +/*#ifdef _NEW_TESTSERVER //测试伺服 + if( parasum > MAXPARAMETER ) return FALSE; +#else + if( parasum != MAXPARAMETER ) return FALSE; +#endif*/ + + +#undef MAXPARAMETER + + +#define MAXATTRIBUTE 10 + cnt = 0; + attrsum = 0; + /* 箪岭及民尼永弁毛允月 */ + for( i = 0; i < arraysizeof( para); i ++ ) { + if( attr[i] < 0 || attr[i] > MAXATTRIBUTE )return FALSE; + attrsum += attr[i]; + if( attr[i] > 0 ) cnt ++; + } + /* 宁煌袄反10 */ + if( attrsum != MAXATTRIBUTE ) return FALSE; + + /* 2勾方曰聂仁喃曰癫化日木化中凶日蛲 */ + if( cnt > 2 ) return FALSE; + + /* 菅箪岭反喃曰癫化日木卅中 */ + if( attr[0] > 0 && attr[2] > 0 ) return FALSE; + if( attr[1] > 0 && attr[3] > 0 ) return FALSE; + +#undef MAXATTRIBUTE + + /* 戊疋□ */ + ch->data[CHAR_VITAL] = vital*100; + ch->data[CHAR_STR] = str*100; + ch->data[CHAR_TOUGH] = tgh*100; + ch->data[CHAR_DEX] = dex*100; + + ch->data[CHAR_EARTHAT] = attr[0] * 10; + ch->data[CHAR_WATERAT] = attr[1] * 10; + ch->data[CHAR_FIREAT] = attr[2] * 10; + ch->data[CHAR_WINDAT] = attr[3] * 10; +#ifdef _NEWOPEN_MAXEXP + ch->data[CHAR_OLDEXP] = 0; +#endif + ch->data[CHAR_EXP] = 0; + + +#ifdef _NEW_PLAYER_CF //新手出生配置 + ch->data[CHAR_TRANSMIGRATION] = getNewplayertrans(); + ch->data[CHAR_GOLD] = getNewplayergivegold();; + ch->data[CHAR_LV] = getNewplayerlv();//120; +// ch->data[CHAR_LEARNRIDE] = 200; +// ch->data[CHAR_LASTTALKELDER] = (rand()%10)>5?35:36;//34; +// ch->data[CHAR_SKILLUPPOINT] = 616;//600; +#ifdef _75_TEST + ch->data[CHAR_TRANSEQUATION] = (100 << 16) + 650; +#endif +#ifdef _NEW_RIDEPETS + //ch->data[CHAR_LOWRIDEPETS] = 0xffffffff; +#endif +#endif + +/*#ifdef _NEW_TESTSERVER //测试伺服 + ch->data[CHAR_SKILLUPPOINT] = "";//600; + ch->data[CHAR_TRANSMIGRATION] = 5; + ch->data[CHAR_GOLD] = CHAR_MAXGOLDHAVE; + ch->data[CHAR_LV] = 140;//120; + ch->data[CHAR_LEARNRIDE] = 200; +// ch->data[CHAR_LASTTALKELDER] = (rand()%10)>5?35:36;//34; + ch->data[CHAR_SKILLUPPOINT] = 616;//600; +#ifdef _75_TEST + ch->data[CHAR_TRANSEQUATION] = (100 << 16) + 650; +#endif +#ifdef _NEW_RIDEPETS + //ch->data[CHAR_LOWRIDEPETS] = 0xffffffff; +#endif +#endif*/ + +#ifdef _PETSKILL_BECOMEPIG + ch->data[CHAR_BECOMEPIG] = -1; + ch->data[CHAR_BECOMEPIG_BBI] = 100250; +#endif + + ch->data[CHAR_LASTLEAVETIME] = 0; + + return TRUE; +} + +#ifdef _HELP_NEWHAND +void CHAR_loginAddItemForNew( int charindex ) +{ + int emptyitemindexinchara, itemindex; + int i; + + char msgbuf[128]; + + for( i = 0; i < 15; i ++ ) { + emptyitemindexinchara = CHAR_findEmptyItemBox( charindex ); + + if( emptyitemindexinchara < 0 ){ + sprintf( msgbuf, "空间栏位不足。" ); + + CHAR_talkToCli( charindex, -1, msgbuf, CHAR_COLORYELLOW); + return; + } + if(getNewplayergiveitem(i)==-1)continue; + itemindex = ITEM_makeItemAndRegist( getNewplayergiveitem(i) ); + + if( itemindex != -1 ){ + CHAR_setItemIndex( charindex, emptyitemindexinchara, itemindex ); + ITEM_setWorkInt(itemindex, ITEM_WORKOBJINDEX,-1); + ITEM_setWorkInt(itemindex, ITEM_WORKCHARAINDEX,charindex); + CHAR_sendItemDataOne( charindex, emptyitemindexinchara); + } + } + print("Get New Hand Item"); +} +#endif + +void CHAR_createNewChar( int clifd, int dataplacenum, char* charname , + int imgno,int faceimgno, + int vital,int str,int tgh,int dex, + int earth,int water,int fire,int wind, + int hometown , char *cdkey ) +{ + + Char ch, *chwk; + int charaindex, petindex; + int enemyarray; + char szKey[256]; + +/*#ifdef _NEW_TESTSERVER //测试伺服 + int add_pet[]={0,0,0,0,0}; +#endif*/ + +#ifdef _NEW_PLAYER_CF //新手出生配置 + int add_pet[]={0,0,0,0,0}; +#endif + +#ifdef _DELBORNPLACE //Syu ADD 6.0 统一出生於新手村 + int BornPet = hometown; + if( getMuseum() ) + hometown = 1; +#endif + memset(&ch,0,sizeof(Char)); + + if( !CHAR_checkPlayerImageNumber( imgno)) { + lssproto_CreateNewChar_send( clifd ,FAILED, "" ); + CONNECT_setState( clifd, NOTLOGIN ); + return; + } + if( !CHAR_checkFaceImageNumber( imgno, faceimgno)) { + lssproto_CreateNewChar_send( clifd ,FAILED, "" ); + CONNECT_setState( clifd, NOTLOGIN ); + return; + } + CHAR_getDefaultChar(&ch,imgno); + ch.data[CHAR_WALKINTERVAL] = getWalksendinterval(); + + if( CHAR_getInitElderPosition( &ch ,hometown) == FALSE ){ + lssproto_CreateNewChar_send( clifd ,FAILED, "" ); + CONNECT_setState( clifd, NOTLOGIN ); + return; + + }else if( MAP_checkCoordinates( ch.data[CHAR_FLOOR], ch.data[CHAR_X], + ch.data[CHAR_Y] ) == FALSE ){ + lssproto_CreateNewChar_send( clifd ,FAILED, ""); + CONNECT_setState( clifd, NOTLOGIN ); + return; + } + strcpysafe( ch.string[CHAR_NAME].string , + sizeof(ch.string[CHAR_NAME].string), + charname); + + if( CHAR_getNewImagenumberFromEquip( imgno,0) == -1 ){ + lssproto_CreateNewChar_send( clifd ,FAILED, ""); + CONNECT_setState( clifd, NOTLOGIN ); + return; + } + ch.data[CHAR_BASEIMAGENUMBER] = imgno; + ch.data[CHAR_BASEBASEIMAGENUMBER] = imgno; + ch.data[CHAR_FACEIMAGENUMBER] = faceimgno; + ch.data[CHAR_DATAPLACENUMBER] = dataplacenum; + +#ifdef _FM_JOINLIMIT + ch.data[CHAR_FMTIMELIMIT] = 0; +#endif + +#ifdef _NEWSAVE + ch.data[CHAR_SAVEINDEXNUMBER] = -1; +#endif + ch.data[CHAR_HP] = 0x7fffffff; + + ch.data[CHAR_CHARM] = 60; + ch.data[CHAR_MAXMP] = ch.data[CHAR_MP] = 100; + strcpysafe( ch.string[CHAR_CDKEY].string, + sizeof( ch.string[CHAR_CDKEY].string), cdkey ); + + // Robin 0724 + ch.data[CHAR_RIDEPET] = -1; + ch.data[CHAR_LEARNRIDE] = 0; + +#ifdef _NEW_RIDEPETS + ch.data[CHAR_LOWRIDEPETS] = 0; +#endif + +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + ch.data[CHAR_FAME] = 0; +#endif +#ifdef _NEW_MANOR_LAW + ch.data[CHAR_MOMENTUM] = 0; // 个人气势 +#endif +#ifdef _TEACHER_SYSTEM + ch.data[CHAR_TEACHER_FAME] = 0; // 导师领导声望 +#endif +#ifdef _RACEMAN + ch.data[CHAR_CHECKIN] = 0; // 宠物登记 + ch.data[CHAR_CATCHCNT1] = 0; // 新手限 猎宠次数 + ch.data[CHAR_CATCHCNT2] = 0; // 老手限 猎宠次数 + ch.data[CHAR_CATCHCNT3] = 0; // 家族限 猎宠次数 + ch.data[CHAR_CATCHCNT4] = 0; // 老手不限 猎宠次数 + ch.data[CHAR_CATCHCNT5] = 0; // 家族不限 猎宠次数 + ch.data[CHAR_KINDCNT1] = 0; + ch.data[CHAR_KINDCNT2] = 0; + ch.data[CHAR_KINDCNT3] = 0; + ch.data[CHAR_KINDCNT4] = 0; + ch.data[CHAR_KINDCNT5] = 0; + ch.data[CHAR_KINDCNT6] = 0; + ch.data[CHAR_KINDCNT7] = 0; + ch.data[CHAR_KINDCNT8] = 0; + ch.data[CHAR_KINDCNT9] = 0; + ch.data[CHAR_KINDCNT10] = 0; +#endif +#ifdef _CHAR_PROFESSION // WON ADD 人物职业 + ch.data[PROFESSION_CLASS] = 0; + ch.data[PROFESSION_LEVEL] = 0; +// ch.data[PROFESSION_EXP] = 0; + ch.data[PROFESSION_SKILL_POINT] = 0; + ch.data[ATTACHPILE] = 0; +#endif + +#ifdef _GM_IDENTIFY + sprintf(ch.string[CHAR_GMIDENTIFY].string,"%s",""); //gm名称清为空字串 +#endif +#ifdef _TEACHER_SYSTEM + memset(ch.string[CHAR_TEACHER_ID].string,0,sizeof(STRING128)); + memset(ch.string[CHAR_TEACHER_NAME].string,0,sizeof(STRING128)); +#endif + +#ifdef _ITEM_SETLOVER + memset(ch.string[CHAR_LOVERID].string,0,sizeof(STRING128)); + memset(ch.string[CHAR_LOVERNAME].string,0,sizeof(STRING128)); +#endif + +#ifdef _PETSKILL_BECOMEPIG + ch.data[CHAR_BECOMEPIG] = -1; + ch.data[CHAR_BECOMEPIG_BBI] = 100250; +#endif + + strcpysafe( ch.string[CHAR_FMNAME].string, + sizeof( ch.string[CHAR_FMNAME].string), "\0" ); + ch.data[CHAR_FMINDEX] = -1; + + if( CHAR_makeCharFromOptionAtCreate( &ch, + vital,str,tgh,dex, + earth,water,fire,wind ) == FALSE ) + { + lssproto_CreateNewChar_send( clifd ,FAILED, + "option data is invalid\n"); + CONNECT_setState( clifd, NOTLOGIN ); + return; + } + { + int mp=ch.data[CHAR_MAXMP]; + int str=ch.data[CHAR_STR]; + int tough=ch.data[CHAR_TOUGH]; + + ch.data[CHAR_INITDATA] = 2*100*100*100*100 /*+ hp*100*100*100*/ + + mp*100*100 + str* 100 + tough; + } + + charaindex = CHAR_initCharOneArray( &ch ); + if( charaindex == -1 ) { + lssproto_CreateNewChar_send( clifd ,FAILED, ""); + CONNECT_setState( clifd, NOTLOGIN ); + return; + } + +/*#ifdef _NEW_TESTSERVER //伊甸测试伺服 + { + int petTemp[]={ 2258, 1610, 353, 2474, -1}; //朱雀、 + int petNum=0; + int k=0; + int i=0,j=0; + +#ifdef _75_TEST + if( CHAR_getInt( charaindex, CHAR_LASTTALKELDER) == 1 )//玛丽娜丝 + petTemp[4] = 2;//凯比 + else if( CHAR_getInt( charaindex, CHAR_LASTTALKELDER) == 2 )//加加 + petTemp[4] = 3;//克克尔 + else if( CHAR_getInt( charaindex, CHAR_LASTTALKELDER) == 3 )//卡鲁它那 + petTemp[4] = 4;//威伯 + else + petTemp[4] = 1;//乌力 +#else + j=2; + for( i=0; i< arraysizeof(ridePetTable) ; i++ ){ + if( CHAR_getInt( charaindex, CHAR_BASEBASEIMAGENUMBER) == ridePetTable[i].charNo ){ + petTemp[j]= ridePetTable[i].petId; + j++; + if( j >= arraysizeof( petTemp) ) + break; + } + } +#endif + + j=0; + for( petNum=0; petNum 3 ) BornPet = 3; + if ( BornPet < 0 ) BornPet = 0; + enemyarray = ENEMY_getEnemyArrayFromId( BornPet + 2076); + } + else { + enemyarray = ENEMY_getEnemyArrayFromId( hometown + 1); + } +#else + enemyarray = ENEMY_getEnemyArrayFromId( hometown + 1); +#endif + petindex = ENEMY_createPetFromEnemyIndex( charaindex, enemyarray); + if( !CHAR_CHECKINDEX( petindex )){ + CHAR_endCharOneArray( charaindex); + lssproto_CreateNewChar_send( clifd ,FAILED, ""); + CONNECT_setState( clifd, NOTLOGIN ); + return; + } + CHAR_setMaxExpFromLevel( petindex, 1); + +#endif*/ + +#ifdef _NEW_PLAYER_CF //新手出生配置 + int petTemp[]={ 2258, 1610, 353, 2474, -1}; //朱雀、 + int petNum=0; + int k=0; + int i=0,j=0; + int mylevel,level; + if(getNewplayergivepet(0)==-1){ + if( CHAR_getInt( charaindex, CHAR_LASTTALKELDER) == 1 )//玛丽娜丝 + setNewplayergivepet(0,2); + else if( CHAR_getInt( charaindex, CHAR_LASTTALKELDER) == 2 )//加加 + setNewplayergivepet(0,3); + else if( CHAR_getInt( charaindex, CHAR_LASTTALKELDER) == 3 )//卡鲁它那 + setNewplayergivepet(0,4); + else + setNewplayergivepet(0,1); + } + + for( petNum=0; petNum<5; petNum++) { + if(getNewplayergivepet(petNum)==-1)continue; + enemyarray = ENEMY_getEnemyArrayFromId( getNewplayergivepet(petNum)); //白虎 + petindex = ENEMY_createPetFromEnemyIndex( charaindex, enemyarray); + if( petindex == -1 ) { + continue; + } + add_pet[j]=petindex; + mylevel = CHAR_getInt( petindex, CHAR_LV); + level = getNewplayerpetlv()-mylevel; + if(level<1)level=1; + for( k = 1; k < level; k ++ ){ //升级 + CHAR_PetLevelUp( petindex ); + CHAR_PetAddVariableAi( petindex, AI_FIX_PETLEVELUP ); + CHAR_setInt( petindex, CHAR_LV, CHAR_getInt( petindex, CHAR_LV) +1 ); + } + CHAR_complianceParameter( petindex ); + CHAR_setInt( petindex , CHAR_HP , CHAR_getWorkInt( petindex , CHAR_WORKMAXHP ) ); + } +#endif + +#ifdef _HELP_NEWHAND + CHAR_loginAddItemForNew(charaindex); +#endif + +#if 1 + if( CHAR_makeDBKey( charaindex, szKey, sizeof( szKey ) ) != FALSE ){ + int dp; + char info[512]; + snprintf( info, sizeof( info), + "%d,%d,%d,%d,%d,%d", + CHAR_getInt( charaindex, CHAR_LV), + CHAR_getInt( charaindex, CHAR_DUELBATTLECOUNT), + CHAR_getInt( charaindex, CHAR_DUELWINCOUNT), + CHAR_getInt( charaindex, CHAR_DUELLOSECOUNT), + CHAR_getInt( charaindex, CHAR_DUELSTWINCOUNT), + CHAR_getInt( charaindex, CHAR_DUELMAXSTWINCOUNT)); + dp = CHAR_getInt( charaindex, CHAR_DUELPOINT ); + saacproto_DBUpdateEntryInt_send( + acfd, + DB_DUELPOINT, + szKey, + (max(dp,0)), + info, + CONNECT_getFdid(clifd ),0 ); + } +#endif + chwk = CHAR_getCharPointer( charaindex); +#ifdef _AUTO_ADDADDRESS + { + int playernum = CHAR_getPlayerMaxNum(); + int i, k, oldnum=0, newnum=0; + i = charaindex; + for( k=0 ; k< playernum ; k++ ){ + char token[256]; + if( ++i >= playernum ) i = 0; + if( i < 0 ) i =0; + if( !CHAR_getCharUse(i) ) continue; + if( charaindex == i ) continue; + if( !CHAR_getFlg( i, CHAR_ISTRADECARD) ) continue; + if( oldnum < 3 && CHAR_getInt( i, CHAR_LV) > 100 ){ + if( ADDRESSBOOK_AutoaddAddressBook( charaindex, i) == TRUE ){ + sprintf( token, "新手-%s 加入石器,并与你交换名片。", CHAR_getUseName( charaindex)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW); + oldnum++; + } + }else if( newnum < 5 && CHAR_getInt( i, CHAR_LV) < 30 ){ + if( ADDRESSBOOK_AutoaddAddressBook( charaindex, i) == TRUE ){ + sprintf( token, "新手-%s 加入石器,并与你交换名片。", CHAR_getUseName( charaindex)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW); + newnum++; + } + } + if( newnum >= 5 && oldnum >= 3 ) + break; + } + } +#endif + +#ifdef _NEW_PLAYER_CF //新手出生配置 + + CHAR_charSaveFromConnectAndChar( clifd,chwk ,FALSE ); + CHAR_endCharData(&ch); + CHAR_endCharOneArray( charaindex); + { + int k=0; + for( k=0;kcharfunctable[i].string, + sizeof( ch->charfunctable[i]), + tmp[i]); + } +} + +void CHAR_loginAddItem( int charaindex ) +{ +/* + int emptyindex, itemindex, id; + int itemID[10]={ 20128, 20130, 20171, 20176, 20296, + 20287, 20288, 20289, 20290, 20291}; + + { + int trn_num=0; + trn_num=CHAR_getInt(charaindex,CHAR_TRANSMIGRATION); + CHAR_setInt( charaindex, CHAR_MAXPOOLITEMHAVELIMIT, 10 + (trn_num * 4) ) ; + CHAR_setInt( charaindex, CHAR_MAXPOOLPETHAVELIMIT , 5 + (trn_num * 2) ); + } + while( 1){ + emptyindex = CHAR_findEmptyItemBox( charaindex ); + if( emptyindex == -1 ) break; + id = rand()%10; + itemindex = ITEM_makeItemAndRegist( itemID[id] ); + if( !ITEM_CHECKINDEX( itemindex) ) break; + CHAR_setItemIndex( charaindex, emptyindex, itemindex); + ITEM_setWorkInt( itemindex, ITEM_WORKCHARAINDEX, charaindex); + ITEM_setWorkInt( itemindex, ITEM_WORKOBJINDEX, -1); + //andy_log + print("@:%d.", emptyindex); + } + while( 1){ + emptyindex = CHAR_findEmptyPoolItemBox( charaindex ); + if( emptyindex == -1 ) break; + id = rand()%10; + itemindex = ITEM_makeItemAndRegist( itemID[id] ); + if( !ITEM_CHECKINDEX( itemindex) ) break; + + CHAR_setPoolItemIndex( charaindex, emptyindex, itemindex); + ITEM_setWorkInt( itemindex, ITEM_WORKCHARAINDEX, charaindex); + ITEM_setWorkInt( itemindex, ITEM_WORKOBJINDEX, -1); + //andy_log + print("&:%d.", emptyindex); + } +*/ +} + +void CHAR_loginCheckUserItem( int charaindex) +{ + typedef void (*ATTACHFUNC)(int,int); + int i, itemindex; + for( i=0; i 0 ){ + if( (ti = CHAR_findEmptyItemBox( charaindex )) != -1 ){ + CHAR_setItemIndex( charaindex , i, -1); + CHAR_setItemIndex( charaindex , ti, itemindex); + } + continue; + } + } + //////////////////////////////////////////// + + + if( (i == ITEM_getEquipPlace( charaindex, itemindex )) || + i == CHAR_DECORATION1 || i == CHAR_DECORATION2 ){ + char category[256]; + ATTACHFUNC atf; + atf=(ATTACHFUNC)ITEM_getFunctionPointer(itemindex,ITEM_ATTACHFUNC); + if( atf ) atf( charaindex, itemindex ); + if( ITEM_canuseMagic( itemindex)) { + snprintf( category, sizeof( category), "J%d",i); + CHAR_sendStatusString( charaindex, category ); + } + }else{ + if( (ti = CHAR_findEmptyItemBox( charaindex )) == -1 ) continue; + CHAR_setItemIndex( charaindex , i, -1); + CHAR_setItemIndex( charaindex , ti, itemindex); + } + } + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE ; i++ ){ //检查携带道具 + itemindex = CHAR_getItemIndex( charaindex , i ); + if( !ITEM_CHECKINDEX( itemindex)) continue; + ITEM_reChangeItemName( itemindex); +#ifdef _ITEM_PILENUMS + ITEM_reChangeItemToPile( itemindex); +#endif + +#ifdef _ANGEL_SUMMON + if( ITEM_getInt( itemindex, ITEM_ID) == ANGELITEM + || ITEM_getInt( itemindex, ITEM_ID) == HEROITEM ) { + int mindex, mission; + // 检查信物所有人是否任务中 + mindex = checkIfAngelByName( ITEM_getChar( itemindex, ITEM_ANGELINFO)); + mission = atoi( ITEM_getChar( itemindex, ITEM_ANGELMISSION)); + if( mindex < 0 || mission != missiontable[mindex].mission ) { + CHAR_setItemIndex( charaindex, i, -1 ); + ITEM_endExistItemsOne( itemindex); + CHAR_sendItemDataOne( charaindex, i); + continue; + } + } +#endif + + ITEM_setItemUniCode( itemindex); + +#ifdef _DEATH_FAMILY_LOGIN_CHECK // WON ADD 家族战登入检查 + if( ITEM_getInt( itemindex, ITEM_TYPE) == ITEM_WARES || + ITEM_getInt( itemindex, ITEM_TYPE) == ITEM_DISH || + ITEM_getInt( itemindex, ITEM_TYPE) == ITEM_OTHER ){ + CHAR_setItemIndex( charaindex, i, -1 ); + ITEM_endExistItemsOne( itemindex); + CHAR_sendItemDataOne( charaindex, i); + } + +#endif + +#ifdef _DEATH_CONTEND + if( ITEM_getInt( itemindex, ITEM_TYPE) == ITEM_WARES || + ITEM_getInt( itemindex, ITEM_TYPE) == ITEM_DISH || + ITEM_getInt( itemindex, ITEM_TYPE) == ITEM_OTHER ){ + CHAR_setItemIndex( charaindex, i, -1 ); + ITEM_endExistItemsOne( itemindex); + CHAR_sendItemDataOne( charaindex, i); + } +#endif + + } + //检查寄放店道具 + for( i = 0 ; i < CHAR_MAXPOOLITEMHAVE ; i++ ){ + itemindex = CHAR_getPoolItemIndex( charaindex , i ); + if( !ITEM_CHECKINDEX( itemindex) ) continue; + + ITEM_reChangeItemName( itemindex); +#ifdef _ITEM_PILENUMS + ITEM_reChangeItemToPile( itemindex); +#endif + +#ifdef _ANGEL_SUMMON + if( ITEM_getInt( itemindex, ITEM_ID) == ANGELITEM + || ITEM_getInt( itemindex, ITEM_ID) == HEROITEM ) { + int mindex, mission; + // 检查信物所有人是否任务中 + mindex = checkIfAngelByName( ITEM_getChar( itemindex, ITEM_ANGELINFO)); + mission = atoi( ITEM_getChar( itemindex, ITEM_ANGELMISSION)); + if( mindex < 0 || mission != missiontable[mindex].mission ) { + CHAR_setPoolItemIndex( charaindex, i, -1 ); + ITEM_endExistItemsOne( itemindex); + continue; + } + } +#endif + + ITEM_setItemUniCode( itemindex); + +#ifdef _DEATH_FAMILY_LOGIN_CHECK // WON ADD 家族战登入检查 + if( ITEM_getInt( itemindex, ITEM_TYPE) == ITEM_WARES || + ITEM_getInt( itemindex, ITEM_TYPE) == ITEM_DISH || + ITEM_getInt( itemindex, ITEM_TYPE) == ITEM_OTHER ){ + CHAR_setPoolItemIndex( charaindex, i, -1 ); + ITEM_endExistItemsOne( itemindex); + } +#endif + +#ifdef _DEATH_CONTEND + if( ITEM_getInt( itemindex, ITEM_TYPE) == ITEM_WARES || + ITEM_getInt( itemindex, ITEM_TYPE) == ITEM_DISH || + ITEM_getInt( itemindex, ITEM_TYPE) == ITEM_OTHER ){ + CHAR_setPoolItemIndex( charaindex, i, -1 ); + ITEM_endExistItemsOne( itemindex); + } +#endif + } + + // WON ADD 修正道具的设定问题 + if(!NPC_EventCheckFlg( charaindex,134)){ + for (i = 0; i < CHAR_MAXITEMHAVE; i ++) { + itemindex = CHAR_getItemIndex(charaindex, i); + fix_item_bug(charaindex, itemindex); + } + for (i = 0; i < CHAR_MAXPOOLITEMHAVE; i++) { + itemindex = CHAR_getPoolItemIndex(charaindex, i); + fix_item_bug(charaindex, itemindex); + } + NPC_EventSetFlg(charaindex, 134); + } + + Check_P_I_UniCode( charaindex); +} +void CHAR_LoginBesideSetWorkInt( int charaindex, int clifd) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKPARTYMODE, CHAR_PARTY_NONE); + CHAR_setWorkInt( charaindex, CHAR_WORKPARTYINDEX1, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKPARTYINDEX2, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKPARTYINDEX3, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKPARTYINDEX4, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKPARTYINDEX5, -1); + + CHAR_setWorkInt( charaindex, CHAR_WORKTRADEMODE, CHAR_TRADE_FREE); + CHAR_setWorkInt( charaindex, CHAR_WORKFMINDEXI, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKFMCHANNEL, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKFMCHANNELQUICK, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKFMFLOOR, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKFMDP, 0); + CHAR_setWorkInt( charaindex, CHAR_WORKFMPKFLAG, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKFMSETUPFLAG, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKFMMANINDEX, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKFMCHARINDEX, -1); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEFLAG, -1); + CHAR_setWorkInt( charaindex, CHAR_WORK_PET0_STAT, 0); + CHAR_setWorkInt( charaindex, CHAR_WORK_PET1_STAT, 0); + CHAR_setWorkInt( charaindex, CHAR_WORK_PET2_STAT, 0); + CHAR_setWorkInt( charaindex, CHAR_WORK_PET3_STAT, 0); + CHAR_setWorkInt( charaindex, CHAR_WORK_PET4_STAT, 0); + CHAR_setWorkInt( charaindex, CHAR_WORKACTION, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKEFFECT, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKFD, clifd); + + + if( CHAR_getInt( charaindex, CHAR_SILENT) > 100000000 ) + CHAR_setInt( charaindex, CHAR_SILENT, 0); + CHAR_setWorkInt( charaindex, CHAR_WORKLOGINTIME, (int)NowTime.tv_sec); + CHAR_setWorkInt( charaindex, CHAR_WORKTALKCOUNT, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORKTALKTIME, (int)NowTime.tv_sec); + CHAR_setWorkInt( charaindex, CHAR_WORKPETFOLLOW, -1); +#ifdef _ITEM_ADDEXP //vincent 经验提升 + CHAR_setWorkInt(charaindex,CHAR_WORKITEM_ADDEXP, 0); + CHAR_setWorkInt(charaindex,CHAR_WORKITEM_ADDEXPTIME, 0); +#endif +#ifdef _BULL_FIXPLAYER + if( NPC_EventCheckFlg( charaindex, 131 ) != TRUE ) { + if( CHAR_getInt( charaindex, CHAR_ABULLSCORE) > 100 ) + CHAR_setInt( charaindex, CHAR_ABULLSCORE, 100); + CHAR_setInt( charaindex, CHAR_ABULLTIME, 0); + NPC_EventSetFlg( charaindex, 131); + NPC_NowEndEventSetFlgCls( charaindex, 130); + } +#endif +#ifdef _STATUS_WATERWORD //水世界状态 + if( MAP_getMapFloorType( CHAR_getInt( charaindex, CHAR_FLOOR)) == 1 ){ + CHAR_setWorkInt( charaindex, CHAR_WORKMAPFLOORTYPE, 1); + }else{ + CHAR_setWorkInt( charaindex, CHAR_WORKMAPFLOORTYPE, 0); + } +#endif +#ifdef _NEWOPEN_MAXEXP + if( CHAR_getInt( charaindex, CHAR_OLDEXP) > 0 || CHAR_getInt( charaindex, CHAR_OLDEXP) < 0 ){ + CHAR_ChangeExp( charaindex); + } +#endif +#ifdef _PETSKILL_BECOMEFOX + CHAR_setWorkInt( charaindex, CHAR_WORKFOXROUND, -1 ); +#endif +#ifdef _MAP_TIME + CHAR_setWorkInt(charaindex,CHAR_WORK_MAP_TIME,0); +#endif +#ifdef _PETSKILL_LER + CHAR_setWorkInt(charaindex,CHAR_WORK_RELIFE,0); +#endif + +#ifdef _ITEM_ADDEXP2 + CHAR_setWorkInt( charaindex, CHAR_WORKITEM_ADDEXP, + CHAR_getInt( charaindex, CHAR_ADDEXPPOWER) ); + CHAR_setWorkInt( charaindex, CHAR_WORKITEM_ADDEXPTIME , + CHAR_getInt( charaindex, CHAR_ADDEXPTIME) ); +#endif + +} + +void CHAR_CheckProfessionSkill( int charaindex) +{ + int i, Pclass, skpoint=0, mynum=0; + CHAR_HaveSkill *pSkil; + + if( NPC_EventCheckFlg( charaindex, 155) ) return; + + Pclass = CHAR_getInt( charaindex, PROFESSION_CLASS ); + skpoint = CHAR_getInt( charaindex, PROFESSION_SKILL_POINT); + if( Pclass == PROFESSION_CLASS_NONE )return; + + + for( i=0; iskill, 0, 0 ); + pSkil->use = 0; + break; + case 64: + CHAR_setInt( charaindex, CHAR_MAXMP, 100); + CHAR_setInt( charaindex, PROFESSION_SKILL_POINT, skpoint+1 ); + pSkil = CHAR_getCharHaveSkill( charaindex, i ); + SKILL_makeSkillData( &pSkil->skill, 0, 0 ); + pSkil->use = 0; + break; + case 65: + CHAR_setInt( charaindex, ATTACHPILE, 0); + CHAR_setInt( charaindex, PROFESSION_SKILL_POINT, skpoint+1 ); + pSkil = CHAR_getCharHaveSkill( charaindex, i ); + SKILL_makeSkillData( &pSkil->skill, 0, 0 ); + pSkil->use = 0; + break; + } + } + { + int myskillpoint, myskillnum=0, myskilllevel; + int mysknum=0; + + myskillpoint= CHAR_getInt( charaindex, PROFESSION_SKILL_POINT ); + myskilllevel= CHAR_getInt( charaindex, PROFESSION_LEVEL ); + + for( i=0; i 0 ){ + CHAR_setInt( charaindex, PROFESSION_SKILL_POINT, myskillpoint + mysknum ); + }else if( mysknum < 0 ){ + int defsknum = (myskillpoint + myskillnum)-myskilllevel; + while( 1){ + if( defsknum<= 0 || + (myskillpoint= CHAR_getInt( charaindex, PROFESSION_SKILL_POINT )) <= 0 ) break; + CHAR_setInt( charaindex, PROFESSION_SKILL_POINT, myskillpoint-1); + defsknum--; + } + } + } + + NPC_EventSetFlg( charaindex, 155); +} + +void CHAR_ResetPoolPetEgg( int charaindex) +{ + int levelup, vital, str, tgh, dex; + int raise, petindex, i; + + + if( NPC_EventCheckFlg( charaindex, 157) ) return; + + for( i = 0; i < CHAR_MAXPOOLPETHAVE; i ++ ) { + petindex = CHAR_getCharPoolPet( charaindex, i); + if( !CHAR_CHECKINDEX( petindex) ) continue; + + if( CHAR_getInt( petindex, CHAR_FUSIONBEIT) != 1 || + CHAR_getInt( petindex, CHAR_FUSIONRAISE) <= 0 ) continue; + + raise = CHAR_getInt( petindex, CHAR_FUSIONRAISE); + raise--; + CHAR_setInt( petindex, CHAR_FUSIONTIMELIMIT, (int)time(NULL)+PETFEEDTIME); + if( raise < 1 ) raise = 1; + if( raise >= 40 ) raise = 30; + CHAR_setInt( petindex, CHAR_FUSIONRAISE, raise); + + levelup = CHAR_getInt( petindex, CHAR_ALLOCPOINT); + vital = ((levelup>>24) & 0xFF) + 4; + str = ((levelup>>16) & 0xFF) + 4; + tgh = ((levelup>> 8) & 0xFF) + 4; + dex = ((levelup>> 0) & 0xFF) + 4; + if( vital < 0 ) vital = 0; + if( str < 0 ) str = 0; + if( tgh < 0 ) tgh = 0; + if( dex < 0 ) dex = 0; + //扣属性 + levelup = (vital<<24) + (str<<16) + (tgh<<8) + (dex<<0); + CHAR_setInt( petindex, CHAR_ALLOCPOINT, levelup); + } + NPC_EventSetFlg( charaindex, 157); +} + +// Robin add 重设宠蛋 养时间 +void CHAR_ResetPetEggFusionTime(int charaindex) +{ + int i, petindex; + int nowTime =0; + //int leaveTime =0; + //int lastFeedTime =0; + //int anhour = PETFEEDTIME; + + //if( NPC_EventCheckFlg( charaindex, 157) ) return; + + nowTime = (int)time(NULL); + //leaveTime = CHAR_getInt( charaindex, CHAR_LASTLEAVETIME); + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + petindex = CHAR_getCharPet( charaindex, i); + if( !CHAR_CHECKINDEX( petindex) ) continue; + + if( CHAR_getInt( petindex, CHAR_FUSIONBEIT) != 1 || + CHAR_getInt( petindex, CHAR_FUSIONRAISE) <= 0 ) continue; + + //lastFeedTime = CHAR_getInt( petindex, CHAR_FUSIONTIMELIMIT); + //if( leaveTime > 0) { + // CHAR_setInt( petindex, CHAR_FUSIONTIMELIMIT, nowTime- (leaveTime-lastFeedTime)); + //} + //else + // CHAR_setInt( petindex, CHAR_FUSIONTIMELIMIT, nowTime); + + CHAR_setInt( petindex, CHAR_FUSIONTIMELIMIT, nowTime); + + } + + //NPC_EventSetFlg( charaindex, 157); + +} + + +BOOL CHAR_CheckProfessionEquit( int toindex) +{ + int i, j, itemindex, newindex; + int FixItem[16]={ + 2028,2029,2030,2031,2032,2033,2034,2035, + 2036,2037,2038,2039,2040,2041,2042,2043 + }; + CHAR_HaveSkill *pSkil; + + if(!NPC_EventCheckFlg( toindex, 149)){ + for (i = 0; i < CHAR_MAXITEMHAVE; i ++) { + itemindex = CHAR_getItemIndex( toindex, i); + if( !ITEM_CHECKINDEX( itemindex)) continue; + + for( j=0; j<16; j++){ + if( ITEM_getInt( itemindex, ITEM_ID) == FixItem[j] ){ + CHAR_setItemIndex( toindex, i, -1 ); + ITEM_endExistItemsOne( itemindex); + newindex = ITEM_makeItemAndRegist( FixItem[j]); + if( !ITEM_CHECKINDEX( newindex) ) break; + CHAR_setItemIndex( toindex , i, newindex); + ITEM_setWorkInt( itemindex, ITEM_WORKCHARAINDEX, toindex); + ITEM_setWorkInt( itemindex, ITEM_WORKOBJINDEX, -1); + + CHAR_sendItemDataOne( toindex, i); + + } + } + } + + for (i = 0; i < CHAR_MAXPOOLITEMHAVE; i++){ + int itemindex = CHAR_getPoolItemIndex(toindex, i); + if( !ITEM_CHECKINDEX( itemindex)) continue; + for( j=0; j<16; j++){ + if( ITEM_getInt( itemindex, ITEM_ID) == FixItem[j] ){ + CHAR_setPoolItemIndex( toindex, i, -1); + ITEM_endExistItemsOne( itemindex); + + newindex = ITEM_makeItemAndRegist( FixItem[j]); + if( !ITEM_CHECKINDEX( newindex) ) break; + CHAR_setPoolItemIndex( toindex , i, newindex); + ITEM_setWorkInt( itemindex, ITEM_WORKCHARAINDEX, toindex); + ITEM_setWorkInt( itemindex, ITEM_WORKOBJINDEX, -1); + + } + } + } + + NPC_EventSetFlg( toindex, 149); + } + + + if( NPC_EventCheckFlg( toindex, 156) ) return TRUE; + + // WON ADD + for( i=0; i 0 ) continue; + + pSkil = CHAR_getCharHaveSkill( toindex, i ); + SKILL_makeSkillData( &pSkil->skill, 0, 0 ); + pSkil->use = 0; + } + { + int myskillpoint= CHAR_getInt( toindex, PROFESSION_SKILL_POINT ); + int myskilllevel= CHAR_getInt( toindex, PROFESSION_LEVEL ); + int myskillnum = 0, mysknum = 0; + + for( i=0; i 0 ){ + CHAR_setInt( toindex, PROFESSION_SKILL_POINT, myskillpoint + mysknum ); + } + } + + { + Skill work1[PROFESSION_MAX_LEVEL]; + int cnt=0; + for( i=0; iuse = 0; + if( work1[i].data[SKILL_IDENTITY] == -1 ) continue; + SKILL_makeSkillData( &pSkil->skill, work1[i].data[SKILL_IDENTITY], work1[i].data[SKILL_LEVEL] ); + pSkil->use = 1; + } + } + + NPC_EventSetFlg( toindex, 156); + + return TRUE; +} + +static void CHAR_setLuck( int charaindex); + +#ifdef _CHANNEL_MODIFY +extern int *piOccChannelMember; +#endif + +#ifdef _BAD_PLAYER // WON ADD 送坏玩家去关 +void CHAR_login( int clifd, char* data, int saveindex, int badplayer ) +#else +void CHAR_login( int clifd, char* data, int saveindex ) +#endif +{ + int charaindex,objindex; + Char ch; + int per; +DebugPoint=50; +// char c_temp2[4096]; + if( CHAR_makeCharFromStringToArg( data , &ch ) == FALSE ){ + fprint ("make char error\n"); + goto MAKECHARDATAERROR; + } +DebugPoint=70; + CHAR_setCharFuncTable( &ch); +DebugPoint=71; + charaindex = CHAR_initCharOneArray( &ch ); +DebugPoint=72; + if( charaindex == -1 ){ + fprint ("make char error\n"); + CHAR_endCharData(&ch); + goto MAKECHARDATAERROR; + } +DebugPoint=80; +#ifdef _NEWSAVE + CHAR_setInt( charaindex, CHAR_SAVEINDEXNUMBER, saveindex); + print("存档装载索引:%d\n", CHAR_getInt( charaindex, CHAR_SAVEINDEXNUMBER) ); +#endif + if( CHAR_getFlg( charaindex, CHAR_ISDIE)){ + print( "?data? ISDIE flg is standing.\n"); + CHAR_setFlg( charaindex, CHAR_ISDIE, FALSE); + } +#ifdef _75_TEST + { + int event_end[] = { 4, 32, 33, 34, 81, 86, 87, 105, 83}; + int i; + for( i=0; i < arraysizeof(event_end); i++) { + NPC_EventSetFlg( charaindex, event_end[i]); + } + } +#endif +#ifndef _FIX_UNNECESSARY + // Arminius 7.9 airplane logout + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_CLIENT ) { + int oyaindex = CHAR_getWorkInt( charaindex, CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX( oyaindex)) { + if (CHAR_getInt( oyaindex, CHAR_WHICHTYPE ) == CHAR_TYPEBUS) { + if ((CHAR_getInt( oyaindex, CHAR_BASEIMAGENUMBER) !=100355) && + (CHAR_getInt( oyaindex, CHAR_BASEIMAGENUMBER) !=100461)) { + + if(CHAR_getWorkInt(oyaindex,CHAR_NPCWORKINT5)==1) { + if( CHAR_getInt( charaindex, CHAR_LASTTALKELDER)>=0){ + int fl,x,y; + CHAR_getElderPosition( CHAR_getInt( charaindex, CHAR_LASTTALKELDER), + &fl, &x, &y ); + CHAR_setInt(charaindex,CHAR_FLOOR,fl); + CHAR_setInt(charaindex,CHAR_X,x); + CHAR_setInt(charaindex,CHAR_Y,y); + } + } + } + } + } + } +#endif +// Nuke 20040420: CHECK MAX POINT +#if 1 + { + int lv,vi,str,tou,dx,skup,trn,teq,quest,level,total,max; + float table[]={437,490,521,550,578,620}; //各转最高点数(减10) + //float table[]={620,660,700,740,780,820}; //各转最高点数(减10) + lv = CHAR_getInt(charaindex,CHAR_LV); + vi = CHAR_getInt(charaindex,CHAR_VITAL); + str = CHAR_getInt(charaindex,CHAR_STR); + tou = CHAR_getInt(charaindex,CHAR_TOUGH); + dx = CHAR_getInt(charaindex,CHAR_DEX); + trn = CHAR_getInt(charaindex,CHAR_TRANSMIGRATION); + teq = CHAR_getInt(charaindex,CHAR_TRANSEQUATION); + skup = CHAR_getInt(charaindex,CHAR_SKILLUPPOINT); + quest=(teq >> 16)& 0xFFFF; + level=teq & 0xFFFF; + total=(vi+str+tou+dx)/100+skup; + max=(trn==0)?(lv-1)*3+20+10: // 0转447 + (lv-1)*3+table[trn-1]/12.0+quest/4.0+(level-trn*85)/4.0+10+1+10+trn*10; + + +/* 1转以上=升级点数+继承点术+历史任务+历史等级+转前祝福+误差1点+转後祝福+转生红利 */ + if (trn==6) max=max-20; /* 六转时没有转前祝福与转後祝福 */ + if (total>max) + { + print("\n重调点数[%s:%s]:%d->%d ", + CHAR_getChar(charaindex,CHAR_CDKEY), + CHAR_getChar(charaindex,CHAR_NAME), + total,max); + CHAR_setInt(charaindex,CHAR_VITAL,1000); + CHAR_setInt(charaindex,CHAR_STR,0); + CHAR_setInt(charaindex,CHAR_TOUGH,0); + CHAR_setInt(charaindex,CHAR_DEX,0); + CHAR_setInt(charaindex,CHAR_SKILLUPPOINT,max-10); + } + // 补足六转点数不足之玩家 + if ((trn==6) && (total < max)) + { + print("\n补足点数[%s:%s]:%d->%d ", + CHAR_getChar(charaindex,CHAR_CDKEY), + CHAR_getChar(charaindex,CHAR_NAME), + total,max); + CHAR_setInt(charaindex,CHAR_SKILLUPPOINT, + CHAR_getInt(charaindex,CHAR_SKILLUPPOINT)+(max-total)); + } + } +#endif + { + int EQ_BBI=-1, EQ_ARM=-1, EQ_NUM=-1, EQ_BI=-1; + int CH_BI = CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER); + + EQ_BBI = CHAR_getInt( charaindex, CHAR_BASEBASEIMAGENUMBER); + EQ_ARM = CHAR_getItemIndex(charaindex,CHAR_ARM); + EQ_NUM=ITEM_FIST; + if ( ITEM_CHECKINDEX( EQ_ARM)) { + EQ_NUM=ITEM_getInt(EQ_ARM,ITEM_TYPE); + } + + EQ_BI=CHAR_getNewImagenumberFromEquip( EQ_BBI, EQ_NUM); + + if( CHAR_getInt( charaindex, CHAR_RIDEPET) != -1 ) { //骑宠 + + }else { //非骑宠 + if( EQ_BI != CH_BI ) { + print("\n 非骑宠形象 %d [%d=>%d]", charaindex, + CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER), + EQ_BI ); + CHAR_setInt( charaindex, CHAR_BASEIMAGENUMBER, EQ_BI); + } + } + } + { + int x,y; + if( CHAR_isAppearPosition( CHAR_getInt( charaindex, CHAR_FLOOR),&x, &y )) { + int flelder, xelder, yelder; + CHAR_getElderPosition(CHAR_getInt(charaindex, CHAR_LASTTALKELDER), + &flelder, &xelder, &yelder); + CHAR_setInt(charaindex, CHAR_FLOOR, flelder); + CHAR_setInt(charaindex, CHAR_X, xelder); + CHAR_setInt(charaindex, CHAR_Y, yelder); + } + } + +#ifdef _FIX_GAMBLENUM + { + if( CHAR_getInt(charaindex, CHAR_GAMBLENUM) < 0){ + CHAR_setInt(charaindex, CHAR_GAMBLENUM, 0); + } + } +#endif + +#ifdef _DEATH_CONTEND + { + char cdkey[CDKEYLEN]; + memset( cdkey, 0, sizeof(cdkey)); + CONNECT_getCdkey( clifd, cdkey, sizeof( cdkey )); + if( strlen(cdkey) > 0 ) { + if( strcmp( cdkey, CHAR_getChar( charaindex, CHAR_CDKEY) ) ){ + print("账号错误 %s->%s\n", CHAR_getChar( charaindex, CHAR_CDKEY), cdkey); + CHAR_setChar( charaindex, CHAR_CDKEY, cdkey); + } + }else{ + print("账号错误:%d\n", clifd); + } + } + CHAR_setInt( charaindex, CHAR_PKLISTTEAMNUM, -1); + CHAR_setInt( charaindex, CHAR_PKLISTLEADER, -1); + //CHAR_setInt( charaindex, CHAR_GOLD, 1000000); + PKLIST_InsertTeamNum( charaindex); + if( CHAR_getInt( charaindex, CHAR_PKLISTTEAMNUM ) < 0 || + CHAR_getInt( charaindex, CHAR_PKLISTLEADER ) < 0 ){ + PKLIST_InsertTeamNum( charaindex); + } +#endif + +#ifdef _MAP_NOEXIT + { + int exfloor=-1,ex_X=-1,ex_Y=-1; + int map_type=0; + unsigned int point; + point = MAP_getExFloor_XY( CHAR_getInt(charaindex, CHAR_FLOOR) , &map_type); + if( point > 0 ) { + if( CHAR_getInt( charaindex, CHAR_LASTTALKELDER) >= 0 ) { + CHAR_getElderPosition(CHAR_getInt(charaindex, CHAR_LASTTALKELDER), + &exfloor, &ex_X, &ex_Y); + } + if( map_type >= 0 ) { // map_type >= 0 优先回纪录点 + if( exfloor == map_type && exfloor >= 0 ) {//回纪录点 + }else { + exfloor = (point>>16)&0xffffff; + ex_X = (point>>8)&0xff; + ex_Y = (point>>0)&0xff; + } + } + if( CHECKFLOORID( exfloor) ) { //检查房间号 + CHAR_setInt(charaindex, CHAR_FLOOR, exfloor); + CHAR_setInt(charaindex, CHAR_X, ex_X); + CHAR_setInt(charaindex, CHAR_Y, ex_Y); + } + } + +#ifdef _BAD_PLAYER // WON ADD 送坏玩家去关 + + NPC_NowEndEventSetFlgCls( charaindex, 135); // 旗标 + if( badplayer ){ + NPC_EventSetFlg(charaindex, 135); // 旗标 + CHAR_setInt(charaindex, CHAR_FLOOR, 887); + CHAR_setInt(charaindex, CHAR_X, 56); + CHAR_setInt(charaindex, CHAR_Y, 14); + + }else if( CHAR_getInt(charaindex, CHAR_FLOOR) == 887 ){ // 如果在888,回记录点 + CHAR_getElderPosition(CHAR_getInt(charaindex, CHAR_LASTTALKELDER), &exfloor, &ex_X, &ex_Y); + CHAR_setInt(charaindex, CHAR_FLOOR, exfloor); + CHAR_setInt(charaindex, CHAR_X, ex_X); + CHAR_setInt(charaindex, CHAR_Y, ex_Y); + + } +#endif +#ifdef _DEATH_FAMILY_LOGIN_CHECK + CHAR_setInt( charaindex, CHAR_FLOOR, 130); + CHAR_setInt( charaindex, CHAR_X, 56); + CHAR_setInt( charaindex, CHAR_Y, 12); +#endif + +#ifdef _NEW_INSERVERPOINT + CHAR_setInt( charaindex, CHAR_FLOOR, 8250); + CHAR_setInt( charaindex, CHAR_X, 15); + CHAR_setInt( charaindex, CHAR_Y, 15); +#endif + } +#endif + if( CHAR_getInt(charaindex,CHAR_X) < 0 || CHAR_getInt(charaindex,CHAR_Y) < 0 ){ + CHAR_setInt(charaindex,CHAR_X,1); + CHAR_setInt(charaindex,CHAR_Y,1); + } +#ifdef _MAP_TIME + // 如果登入的地图是这些编号的话,回到入口 + if(CHAR_getInt(charaindex,CHAR_FLOOR) >= 30017 && CHAR_getInt(charaindex, CHAR_FLOOR) <= 30021){ + CHAR_setInt(charaindex,CHAR_FLOOR,30008); + CHAR_setInt(charaindex,CHAR_X,39); + CHAR_setInt(charaindex,CHAR_Y,38); + } +#endif + + objindex = initObjectFromObjectMember(OBJTYPE_CHARA,charaindex, + CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y), + CHAR_getInt(charaindex,CHAR_FLOOR)); + if( objindex == -1 ){ + fprint ("init obj error\n"); + goto DELETECHARDATA; + } + + CHAR_setWorkInt( charaindex,CHAR_WORKOBJINDEX,objindex ); + CONNECT_setState( clifd, LOGIN ); + CONNECT_setCharaindex( clifd, charaindex ); + CHAR_LoginBesideSetWorkInt( charaindex, clifd); + +#ifdef _CHANGEGOATMETAMO // (不可开) Syu 羊年兽更换新图 + if( NPC_EventCheckFlg( charaindex, 141 ) != TRUE ) { + int z; + int PETID1; + int PETBASE1; + for ( z = 0 ; z < CHAR_MAXPETHAVE; z ++ ) { + int petindex = CHAR_getCharPet(charaindex,z); + if( CHAR_CHECKINDEX( petindex) ) { + PETID1 = CHAR_getInt( petindex, CHAR_PETID); + PETBASE1 = CHAR_getInt( petindex , CHAR_BASEBASEIMAGENUMBER ); + if ( PETID1 == 1056 && PETBASE1 == 101497 ) + CHAR_setInt( petindex , CHAR_BASEBASEIMAGENUMBER , 101607 ) ; + if ( PETID1 == 1057 && PETBASE1 == 101498 ) + CHAR_setInt( petindex , CHAR_BASEBASEIMAGENUMBER , 101608 ) ; + if ( PETID1 == 1058 && PETBASE1 == 101499 ) + CHAR_setInt( petindex , CHAR_BASEBASEIMAGENUMBER , 101609 ) ; + if ( PETID1 == 1059 && PETBASE1 == 101500 ) + CHAR_setInt( petindex , CHAR_BASEBASEIMAGENUMBER , 101610 ) ; + } + } + for ( z = 0 ; z < CHAR_MAXPOOLPETHAVE; z ++ ) { + int petindex = CHAR_getCharPoolPet(charaindex,z); + if( CHAR_CHECKINDEX( petindex) ) { + PETID1 = CHAR_getInt( petindex, CHAR_PETID); + PETBASE1 = CHAR_getInt( petindex , CHAR_BASEBASEIMAGENUMBER ); + if ( PETID1 == 1056 && PETBASE1 == 101497 ) + CHAR_setInt( petindex , CHAR_BASEBASEIMAGENUMBER , 101607 ) ; + if ( PETID1 == 1057 && PETBASE1 == 101498 ) + CHAR_setInt( petindex , CHAR_BASEBASEIMAGENUMBER , 101608 ) ; + if ( PETID1 == 1058 && PETBASE1 == 101499 ) + CHAR_setInt( petindex , CHAR_BASEBASEIMAGENUMBER , 101609 ) ; + if ( PETID1 == 1059 && PETBASE1 == 101500 ) + CHAR_setInt( petindex , CHAR_BASEBASEIMAGENUMBER , 101610 ) ; + } + } + } + NPC_EventSetFlg( charaindex, 141); +#endif + + CHAR_complianceParameter( charaindex ); + //检查人物身上 + { + int i; +// char *petstring; + int ID1; + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + int petindex = CHAR_getCharPet(charaindex,i); + if( CHAR_CHECKINDEX( petindex) ) { + +#ifdef _CHECK_ENEMY_PET + { + int j; + for( j=0;j 0 || CHAR_getInt( charaindex, CHAR_OLDEXP) < 0 ){ + CHAR_ChangeExp( petindex); + } +#endif + ID1=CHAR_getInt( petindex, CHAR_PETID); +// petstring = CHAR_makePetStringFromPetIndex( petindex); +#ifdef _REEDIT_PETBBIS + if( ID1 == 1133 ){ + CHAR_setInt( petindex, CHAR_BASEIMAGENUMBER, 101578); + CHAR_setInt( petindex, CHAR_BASEBASEIMAGENUMBER, 101578); + print("PET:%s fix BBI\n", CHAR_getUseName(petindex)); + } +#endif + // WON ADD 修正白虎七技 + if( ID1 == 777 )CHAR_setInt( petindex, CHAR_SLOT, 7); + CHAR_setWorkInt( petindex, CHAR_WORKPLAYERINDEX, charaindex); + // 修正宠技最大值变-1 Robin 20040803 + if( CHAR_getInt( petindex, CHAR_SLOT) < 0 ) { + int j; + for( j=0; j= 0) + CHAR_setInt( petindex, CHAR_SLOT, j+1); + } + //print(" 宠技MAX变-1改6 "); + } + + CHAR_complianceParameter( petindex ); +#ifdef _FIX_GP_PET_SKILL // WON ADD 修正gp宠会落马术 + if( ID1 == 1133){ + int j; + for( j=0; j 0 || + CHAR_getInt( charaindex, CHAR_OLDEXP) < 0 ){ + CHAR_ChangeExp( petindex); + } +#endif + b_find=FALSE; + ID1=CHAR_getInt( petindex, CHAR_PETID); +#ifdef _REEDIT_PETBBIS + if( ID1 == 1133 ){ + CHAR_setInt( petindex, CHAR_BASEIMAGENUMBER, 101578); + CHAR_setInt( petindex, CHAR_BASEBASEIMAGENUMBER, 101578); + } +#endif +/* + tran_no=CHAR_getInt( charaindex, CHAR_TRANSMIGRATION); + petstring = CHAR_makePetStringFromPetIndex( petindex); + c_ptr_index=strstr(petstring,"name:"); + getStringFromIndexWithDelim(c_ptr_index,":",2,c_temp,sizeof(c_temp)); + c_ptr_index=c_temp; + getStringFromIndexWithDelim(c_ptr_index,"|",1,c_temp1,sizeof(c_temp1)); + + if(b_find){//ttom + CHAR_setCharPoolPet( charaindex, i, -1); + print("\nKill pool pet ID=%d name=%s",ID1,c_temp1); + sprintf(c_temp2,"Kill pool pet ID=%d name=%s",ID1,c_temp1); + LogKill(CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), + c_temp2); + }else{//ttom +*/ + CHAR_setWorkInt( petindex, CHAR_WORKPLAYERINDEX, charaindex); + CHAR_complianceParameter( petindex ); +// }//ttom + } + } + } + +// CHAR_ResetPoolPetEgg( charaindex); +// CHAR_CheckProfessionEquit( charaindex); + CHAR_CheckProfessionSkill( charaindex); + { + int i=0; + int skidx[]={2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,3,3,3,3,3,3,3}; + //20040702 Change fix + //检查是否有职业不该有的技能并删除 + for( i = CHAR_SKILLMAXHAVE-1; i >= 0; i -- ){ + CHAR_HaveSkill *pSkil; + Skill* skill; + + pSkil = CHAR_getCharHaveSkill( charaindex, i ); + skill = &pSkil->skill; + if( pSkil == NULL )continue; + if( pSkil->use == 0 )continue; + if( skidx[skill->data[SKILL_IDENTITY]] != CHAR_getInt( charaindex, PROFESSION_CLASS ) + && skidx[skill->data[SKILL_IDENTITY]] != 4 ){//共通技不删 + SKILL_makeSkillData( &pSkil->skill, 0, 0 ); + pSkil->use = 0; + } + } + } +#ifdef _LOGIN_ADDITEM + CHAR_loginAddItem( charaindex); +#endif + CHAR_loginCheckUserItem( charaindex); +#ifdef _FIX_TSKILLCAN + CHAR_PETSKILLCAN( charaindex); +#endif + CHAR_complianceParameter( charaindex ); + + // Robin add 重设宠蛋 养时间 + CHAR_ResetPetEggFusionTime( charaindex); + +#ifdef _PROFESSION_FIX_LEVEL // WON ADD 修正职业经验值 + { + int i=0; + for( i = 0 ; i < CHAR_SKILLMAXHAVE ; i ++ ){ + CHAR_HaveSkill* hskill; + + hskill = CHAR_getCharHaveSkill( charaindex, i ); + + if( hskill != NULL && hskill->use == TRUE ){ + int skill_level = SKILL_getInt( &hskill->skill, SKILL_LEVEL); + if( skill_level < 10 ){ + SKILL_setInt( &hskill->skill, SKILL_LEVEL, 10* 100 ); + } + } + } + } +#endif + +#ifdef _CHANNEL_MODIFY + if(CHAR_getInt(charaindex,PROFESSION_CLASS) > 0){ + int i,pclass = CHAR_getInt(charaindex,PROFESSION_CLASS) - 1,Empty = -1; + // 若旧的职业频道记录有记录在就留着,若没有加入频道 + for(i=0;i MAX_PERSONAL_MOMENTUM) CHAR_setInt(charaindex,CHAR_MOMENTUM,MAX_PERSONAL_MOMENTUM); +#endif + +#ifdef _PETSKILL_BECOMEPIG + if( CHAR_getInt( charaindex, CHAR_BECOMEPIG) > -1 ){ + CHAR_setInt( charaindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( charaindex, CHAR_BECOMEPIG_BBI ) ); + } + //change fix 处理负很大的乌力时间 + else{ + CHAR_setInt( charaindex, CHAR_BECOMEPIG, -1 ); + } +#endif + + + lssproto_CharLogin_send( clifd, SUCCESSFUL,"" ); + per = ENCOUNT_getEncountPercentMin( charaindex, + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y)); + if( per != -1) { + CHAR_setWorkInt( charaindex, CHAR_WORKENCOUNTPROBABILITY_MIN, per); + } + per = ENCOUNT_getEncountPercentMax( charaindex, + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y)); + if( per != -1) { + CHAR_setWorkInt( charaindex, CHAR_WORKENCOUNTPROBABILITY_MAX, per); + } + + CHAR_setLuck( charaindex); + { + int i; + char* statuscat[]={"C","P","I","S","D","E","F"}; + for( i=0 ; i=1 ) + CHAR_Skillupsend(charaindex); + CHAR_checkEffect( charaindex); + +#ifdef _DEATH_FAMILY_LOGIN_CHECK // WON ADD 家族战登入检查 +// if( NPC_EventCheckFlg( charaindex, 150 ) != TRUE ) { + { + char *char_id, *char_name; + // 清除家族旗标 + SetFMVarInit(charaindex); + char_id = CHAR_getChar( charaindex, CHAR_CDKEY ); + char_name = CHAR_getChar( charaindex, CHAR_NAME ); + saacproto_new_ACFM_Login_send(acfd, charaindex, char_id, char_name ); + } +// NPC_EventSetFlg( charaindex, 150); +// } +#else + + // CoolFish: Family 2001/5/30 + if ((CHAR_getChar(charaindex, CHAR_FMNAME)!=NULL) && + (CHAR_getInt(charaindex, CHAR_FMINDEX) >= 0) && + (strcmp(CHAR_getChar(charaindex, CHAR_FMNAME), "") != 0)) + { +#ifdef _FMVER21 + int eventflag = 0; + // 是否符合族长得资格 + if (CheckLeaderQ(charaindex) >= 0) + eventflag = 1; + if (CHAR_getInt(charaindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER) + SetFMPetVarInit(charaindex); + saacproto_ACFMCharLogin_send( + acfd, + CHAR_getChar(charaindex, CHAR_FMNAME), + CHAR_getInt(charaindex, CHAR_FMINDEX), + CHAR_getChar(charaindex, CHAR_NAME), + CHAR_getChar(charaindex, CHAR_CDKEY), + CHAR_getInt(charaindex, CHAR_LV), eventflag, + CONNECT_getFdid(clifd) +#ifdef _FM_MODIFY + ,getServernumber() +#endif + ); +#endif + } +#ifdef _FMVER21 + else + SetFMVarInit(charaindex); +#endif + +#endif + + AnnounceToPlayerWN( clifd ); + +#ifdef _ANGEL_SUMMON + { + int mindex; + mindex = checkIfOnlyAngel( charaindex); + if( mindex != -1 ) { + if( missiontable[mindex].flag == MISSION_WAIT_ANSWER ) { + lssproto_WN_send( clifd, WINDOW_MESSAGETYPE_ANGELMESSAGE, + WINDOW_BUTTONTYPE_YESNO, + CHAR_WINDOWTYPE_ANGEL_ASK, + -1, + "目前魔族肆虐,精灵们需要你的帮忙,前往寻找勇者来消灭这些魔族,你是否愿意帮忙?" ); + } + } + } +#endif + + print("\n登陆人物名称:%s ", CHAR_getChar(charaindex, CHAR_NAME ) ); + + { + unsigned long ip; + char ipstr[512]; + + ip=CONNECT_get_userip(clifd); + sprintf(ipstr,"%d.%d.%d.%d", + ((unsigned char *)&ip)[0], + ((unsigned char *)&ip)[1], + ((unsigned char *)&ip)[2], + ((unsigned char *)&ip)[3]); + + LogLogin( + CHAR_getChar( charaindex, CHAR_CDKEY), + CHAR_getChar( charaindex, CHAR_NAME), + saveindex, ipstr + ); + } + +#ifdef _TEACHER_SYSTEM + // 学生上线通知导师 + if(strlen(CHAR_getChar(charaindex,CHAR_TEACHER_ID)) > 0 && strlen(CHAR_getChar(charaindex,CHAR_TEACHER_NAME)) > 0){ + int iPlayernum = CHAR_getPlayerMaxNum(),i; + char szMsg[128]; + + for(i=0;i 0 && + strlen(CHAR_getChar(charaindex,CHAR_LOVERID))>0 && + strlen(CHAR_getChar(charaindex,CHAR_LOVERNAME))>0){ + int iPlayernum = CHAR_getPlayerMaxNum(),i; + char szMsg[128]; + for(i=0;idata[CHAR_SAVEINDEXNUMBER]); + saacproto_ACCharSave_send( acfd, cdkey, + ch->string[CHAR_NAME].string, + CHAR_makeOptionString( ch ), chardata, + unlock, CONNECT_getFdid(fd), ch->data[CHAR_SAVEINDEXNUMBER] ); +#else + saacproto_ACCharSave_send( acfd, cdkey, + ch->string[CHAR_NAME].string, + CHAR_makeOptionString( ch ), chardata, + unlock, CONNECT_getFdid(fd) ); +#endif + return TRUE; +} + +BOOL CHAR_charSaveFromConnect( int fd , BOOL unlock) +{ + Char* ch; + int charaindex = CONNECT_getCharaindex(fd); + if( CHAR_CHECKINDEX( charaindex ) == FALSE)return FALSE; + ch = CHAR_getCharPointer( charaindex ); + if( !ch )return FALSE; +#ifdef _CHAR_POOLITEM + if( CHAR_SaveDepotItem( charaindex) == TRUE ){ + print("saveDepotItem:%d \n", charaindex); + } +#endif +#ifdef _CHAR_POOLPET + if( CHAR_SaveDepotPet( charaindex) == TRUE ){ + print("saveDepotPet:%d \n", charaindex); + } +#endif + + return CHAR_charSaveFromConnectAndChar( fd, ch, unlock ); +} + + +/*------------------------------------------------------------ + * 夫弘失它玄允月凛卞 匀凶引引夫弘失它玄匹五卅中失奶 丞毛 + * 允 + * 娄醒 + * charaindex int 平乓仿弁正□及奶件犯永弁旦 + * 忒曰袄 + * 卅仄 + ------------------------------------------------------------*/ +static void CHAR_dropItemAtLogout( int charaindex ) +{ + int i; + for( i=0 ; i= 0 ){ + BATTLE_EscapeDpSend( battleindex, charindex ); + CHAR_setInt( charindex, CHAR_DUELPOINT, + CHAR_getInt( charindex, CHAR_DUELPOINT ) + + CHAR_getWorkInt( charindex, CHAR_WORKGETEXP ) ); + BATTLE_Exit( charindex, battleindex ); + } + + CHAR_dropItemAtLogout( charindex ); + CHAR_DischargeParty( charindex, 0); + if(CHAR_getChar(charindex, CHAR_FMNAME) != NULL ) { + if(strlen(CHAR_getChar(charindex, CHAR_FMNAME)) > 0 && + strlen(CHAR_getChar(charindex, CHAR_FMNAME)) < sizeof( STRING32) ) + if( (CHAR_getInt(charindex, CHAR_FMINDEX) >= 0) && + (strcmp(CHAR_getChar(charindex, CHAR_FMNAME), "") != 0) ) { + saacproto_ACFMCharLogout_send(acfd, + CHAR_getChar(charindex, CHAR_FMNAME), + CHAR_getInt(charindex, CHAR_FMINDEX), + CHAR_getChar(charindex, CHAR_NAME), + CHAR_getChar(charindex, CHAR_CDKEY), + CHAR_getInt(charindex, CHAR_LV), + CHAR_getWorkInt(charindex, CHAR_WORKFMINDEXI), + CONNECT_getFdid(clifd)); + } + } + +#ifdef _CHATROOMPROTOCOL // (不可开) Syu ADD 聊天室频道 + if ( CHAR_getWorkInt ( charindex , CHAR_WORKCHATROOMTYPE ) != 0 ) { + ChatRoom_Leave ( charindex ) ; + } +#endif +#ifdef _STREET_VENDOR + // 若玩家是卖方且正在交易中 + if(CHAR_getWorkInt(charindex,CHAR_WORKSTREETVENDOR) == 2){ + // 取出和他交易的人 + toindex = CHAR_getWorkInt(charindex,CHAR_WORKSTREETVENDOR_WHO); + if(toindex > -1 && CHAR_CHECKINDEX(toindex)){ + CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR_WHO,-1); + CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR,-1); + lssproto_STREET_VENDOR_send(getfdFromCharaIndex(toindex),"C|"); + CHAR_talkToCli(toindex,-1,"店家取消交易",CHAR_COLORYELLOW); + } + } + // 玩家是买方 + else if(CHAR_getWorkInt(charindex,CHAR_WORKSTREETVENDOR) == 3){ + // 取出卖方 + toindex = CHAR_getWorkInt(charindex,CHAR_WORKSTREETVENDOR_WHO); + if(toindex > -1 && CHAR_CHECKINDEX(toindex)){ + CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR_WHO,-1); + CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR,1); + } + } +#endif + + // Robin 0606 channel + fmindexi = CHAR_getWorkInt(charindex, CHAR_WORKFMINDEXI); + channel = CHAR_getWorkInt(charindex, CHAR_WORKFMCHANNEL); + i = 0; + if( (fmindexi > 0) && (channel >= 0) && (fmindexi < FAMILY_MAXNUM) && (channel < FAMILY_MAXCHANNEL)) { + while( i < FAMILY_MAXMEMBER ) { + if( channelMember[fmindexi][channel][i] == charindex ) { + channelMember[fmindexi][channel][i] = -1; + break; + } + i++; + } + } +#ifdef _CHANNEL_MODIFY + if(CHAR_getInt(charindex,PROFESSION_CLASS) > 0){ + int i,pclass = CHAR_getInt(charindex,PROFESSION_CLASS) - 1; + for(i=0;i 0) && (fmindexi < FAMILY_MAXNUM)){ + if( familyMemberIndex[fmindexi][i] == charindex ) + familyMemberIndex[fmindexi][i] = -1; + } + } + // Robin 0629 silent + if( CHAR_getInt( charindex, CHAR_SILENT) > 0 ){ + int silent_t, login_t; + login_t = CHAR_getWorkInt(charindex, CHAR_WORKLOGINTIME); + silent_t = CHAR_getInt( charindex, CHAR_SILENT); + silent_t = silent_t - ( (int)NowTime.tv_sec-login_t); + if( silent_t<0 ) silent_t = 0; + CHAR_setInt( charindex, CHAR_SILENT, silent_t); + } + +#ifdef _ITEM_ADDEXP2 + if( CHAR_getWorkInt( charindex, CHAR_WORKITEM_ADDEXP) > 0 ) { + // 登入时智果效果自动减90秒 + CHAR_setWorkInt( charindex, CHAR_WORKITEM_ADDEXPTIME, + CHAR_getWorkInt( charindex, CHAR_WORKITEM_ADDEXPTIME) - 90 ); + if( CHAR_getWorkInt( charindex, CHAR_WORKITEM_ADDEXPTIME) <= 0 ) { + CHAR_setWorkInt( charindex, CHAR_WORKITEM_ADDEXPTIME, 0); + CHAR_setWorkInt( charindex, CHAR_WORKITEM_ADDEXP, 0); + } + } + CHAR_setInt( charindex, CHAR_ADDEXPPOWER, + CHAR_getWorkInt( charindex, CHAR_WORKITEM_ADDEXP) ); + CHAR_setInt( charindex, CHAR_ADDEXPTIME, + CHAR_getWorkInt( charindex, CHAR_WORKITEM_ADDEXPTIME) ); +#endif + +#ifdef _TIME_TICKET + if( check_TimeTicketMap( CHAR_getInt( charindex, CHAR_FLOOR)) ) { + CHAR_warpToSpecificPoint( charindex, 7001, 41, 6); + } +#endif + + // Robin add + CHAR_setInt( charindex, CHAR_LASTLEAVETIME, (int)time(NULL)); + + if( save ){ + CHAR_charSaveFromConnect( clifd ,TRUE); + } + +#ifndef _DEATH_CONTEND + ADDRESSBOOK_notifyLoginLogout(charindex,0); +#endif + CHAR_CharaDeleteHavePet( charindex); + CHAR_CharaDelete( charindex ); + + return ret; +} +/*------------------------------------------------------------ + * watch奶矛件玄毛霜月井升丹井民尼永弁允月 + * 娄醒 + * objindex int 奶矛件玄毛云仇仄凶平乓仿及左皮斥尼弁玄 + * 奶件犯永弁旦 + * index int 奶矛件玄毛云仇仄凶平乓仿及奶件犯永弁旦 + * recvindex int 奶矛件玄毛熬仃午月平乓仿及index + * chac int 失弁扑亦件及潘 + * 忒曰袄 TRUE: 霜匀化中中方 + * FALSE: 蛲 + ------------------------------------------------------------*/ +static BOOL CHAR_sendWatchEvent_sendCheck( int objindex, int index, + int recvindex, int chac) +{ + /* 愤坌互NPC匹锹澎手NPC及凛 仃月 */ + if( OBJECT_getType( objindex) == OBJTYPE_CHARA && + CHAR_getInt( index, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER && + CHAR_getInt(recvindex, CHAR_WHICHTYPE ) + != CHAR_TYPEPLAYER ) + { + return FALSE; + } + /* 平乓仿动陆及watch 反民尼永弁 仄卞蕞 */ + if( OBJECT_getType( objindex) != OBJTYPE_CHARA) { + return TRUE; + } + /* + * 愤坌尺及汹五及 反 仄卞允月 + */ + if( index == recvindex && chac == CHAR_ACTWALK ) { + return FALSE; + } + + if( CHAR_getInt( recvindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + /* 爵 及谛卞反 蛲分井日霜耨仄卅中 */ + if( CHAR_getWorkInt( recvindex,CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) + { + return FALSE; + } + /* 失弁扑亦件元扎 中凛 */ + if( CHAR_getWorkInt( index, CHAR_WORKACTION) == -1 ) { + if( OBJECT_getType(objindex) == OBJTYPE_CHARA) { + /* 元由□ 奴分匀凶日 + * 褪动陆反职及丢件田□卞汹五毛霜耨仄卅中 + */ + if( CHAR_getWorkInt( index, CHAR_WORKPARTYMODE ) + == CHAR_PARTY_CLIENT && + CHAR_getWorkInt( recvindex, CHAR_WORKPARTYMODE) + != CHAR_PARTY_NONE && + chac == CHAR_ACTWALK ) + { + int found = FALSE; + int loop; + /* 阂毛譬屯月 */ + for( loop = 1; loop < CHAR_PARTYMAX; loop ++ ) { + int partycharaindex = CHAR_getPartyIndex( recvindex, loop); + /* 中凶平乓仿互愤坌及由□ 奴及阂分匀凶 */ + if( partycharaindex == index ) { + found = TRUE; + break; + } + } + if( found ) return FALSE; + } + /* 褪反阂及STAND毛霜耨仄卅中 */ + if( CHAR_getWorkInt( index, CHAR_WORKPARTYMODE) + == CHAR_PARTY_CLIENT && + CHAR_getWorkInt( recvindex, CHAR_WORKPARTYMODE) + == CHAR_PARTY_LEADER && + chac == CHAR_ACTSTAND) + { + int found = FALSE; + int loop; + /* 阂毛譬屯月 */ + for( loop = 1; loop < CHAR_PARTYMAX; loop ++ ) { + int partycharaindex + = CHAR_getWorkInt( recvindex, + CHAR_WORKPARTYINDEX1+loop); + /* STAND仄凶平乓仿互愤坌及由□ 奴及阂分匀凶 */ + if( partycharaindex == index ) { + found = TRUE; + break; + } + } + if( found ) return FALSE; + } + } + } + } + return TRUE; +} + +void CHAR_sendWatchEvent( int objindex, int chac, int* opt, + int optlen,BOOL myflg ) +{ + int i; + int j; + int x=0,y=0,dir=0; + int floor; + int watchopt[32]; + int watchoptlen=0; + typedef void (*WATCHF)(int,int,CHAR_ACTION,int,int,int,int*,int); + int index; + + if( !CHECKOBJECTUSE(objindex) )return; + index = OBJECT_getIndex( objindex); + switch( OBJECT_getType(objindex) ){ + case OBJTYPE_CHARA: + for( i=0; i= 4 ){ + return; + } + // 引分由仿丢□正失永皿匹五月井" + cnt = CHAR_getInt(charaindex,CHAR_SKILLUPPOINT); + if( cnt <= 0 )return; + +#ifdef _CHAR_PROFESSION // WON ADD 人物职业栏位 + { + int p_class = CHAR_getInt( charaindex, PROFESSION_CLASS ); + int fd=-1; + + switch( p_class ){ + case PROFESSION_CLASS_FIGHTER: + // 勇士锁敏200 + if( SkUpTbl[skillid] == CHAR_DEX ){ + if( CHAR_getInt( charaindex, SkUpTbl[skillid] ) >= 200 * 100 ){ + CHAR_talkToCli(charaindex, -1, "你的能力值已达上限", CHAR_COLORYELLOW ); + fd = getfdFromCharaIndex(charaindex); + if( fd != -1 ) lssproto_SKUP_send( fd, cnt ); + return; + } + } + break; + case PROFESSION_CLASS_WIZARD: + // 巫师锁攻200 + if( SkUpTbl[skillid] == CHAR_STR ){ + if( CHAR_getInt( charaindex, SkUpTbl[skillid] ) >= 200 * 100 ){ + CHAR_talkToCli(charaindex, -1, "你的能力值已达上限", CHAR_COLORYELLOW ); + fd = getfdFromCharaIndex(charaindex); + if( fd != -1 ) lssproto_SKUP_send( fd, cnt ); + return; + } + } + // 巫师锁防200 + if( SkUpTbl[skillid] == CHAR_TOUGH ){ + if( CHAR_getInt( charaindex, SkUpTbl[skillid] ) >= 200 * 100 ){ + CHAR_talkToCli(charaindex, -1, "你的能力值已达上限", CHAR_COLORYELLOW ); + fd = getfdFromCharaIndex(charaindex); + if( fd != -1 ) lssproto_SKUP_send( fd, cnt ); + return; + } + } + break; + case PROFESSION_CLASS_HUNTER: + // 猎人锁攻200 + if( SkUpTbl[skillid] == CHAR_STR ){ + if( CHAR_getInt( charaindex, SkUpTbl[skillid] ) >= 200 * 100 ){ + CHAR_talkToCli(charaindex, -1, "你的能力值已达上限", CHAR_COLORYELLOW ); + fd = getfdFromCharaIndex(charaindex); + if( fd != -1 ) lssproto_SKUP_send( fd, cnt ); + return; + } + } + // 猎人锁防200 + if( SkUpTbl[skillid] == CHAR_TOUGH ){ + if( CHAR_getInt( charaindex, SkUpTbl[skillid] ) >= 200 * 100 ){ + CHAR_talkToCli(charaindex, -1, "你的能力值已达上限", CHAR_COLORYELLOW ); + fd = getfdFromCharaIndex(charaindex); + if( fd != -1 ) lssproto_SKUP_send( fd, cnt ); + return; + } + } + // 猎人锁敏400 + if( SkUpTbl[skillid] == CHAR_DEX ){ + if( CHAR_getInt( charaindex, SkUpTbl[skillid] ) >= 400 * 100 ){ + CHAR_talkToCli(charaindex, -1, "你的能力值已达上限", CHAR_COLORYELLOW ); + fd = getfdFromCharaIndex(charaindex); + if( fd != -1 ) lssproto_SKUP_send( fd, cnt ); + return; + } + } + break; + default: break; + } + + fd = getfdFromCharaIndex(charaindex); + if( fd != -1 ) lssproto_SKUP_send( fd, cnt-1 ); + } +#endif + + CHAR_setInt( charaindex,CHAR_SKILLUPPOINT,cnt-1); + CHAR_setInt( charaindex, SkUpTbl[skillid], CHAR_getInt( charaindex, SkUpTbl[skillid] ) + 1*100 ); + + CHAR_complianceParameter(charaindex); + CHAR_send_P_StatusString( charaindex, SendTbl[skillid]); + +#ifdef _ANGEL_SUMMON // 加点时检查资格 + if( cnt-1 == 0 ) + //selectAngel( charaindex); + selectAngel( charaindex, -1, -1 , FALSE); + +#endif + } + CHAR_PartyUpdate( charaindex, CHAR_N_STRING_MAXHP ); + +} + +INLINE void CHAR_getDXDY( int dir , int* dx, int* dy ) +{ + static POINT CHAR_dxdy[8]= + { + { 0,-1}, /* */ + { 1,-1}, /* */ + { 1, 0}, /* */ + { 1, 1}, /* */ + { 0, 1}, /* */ + {-1, 1}, /* */ + {-1, 0}, /* */ + {-1,-1}, /* */ + }; + VALIDATEDIR(dir); + + if( dx )*dx = CHAR_dxdy[dir].x; + if( dy )*dy = CHAR_dxdy[dir].y; +} +INLINE int CHAR_getDX( int dir ) +{ + int tmp; + CHAR_getDXDY( dir,&tmp,NULL); + return tmp; +} +INLINE int CHAR_getDY( int dir ) +{ + int tmp; + CHAR_getDXDY( dir,NULL,&tmp); + return tmp; +} + +/*------------------------------------------------------------ + * 元穴旦及平乓仿弁正□毛 月[ + * 娄醒 + * objbuf int* object 匹及 index 毛医 允月 + * 田永白央 + * siz int objbuf 及 扔奶术 + * ff int 白夫失 + * fx int x + * fy int y + * 忒曰袄 + * 窒蜊平乓仿互中月井[ + ------------------------------------------------------------*/ +int CHAR_getSameCoordinateObjects(int* objbuf, int siz,int ff, int fx, + int fy) +{ + OBJECT object; + int findobjnum=0; + + for( object = MAP_getTopObj(ff,fx,fy) ; object ; + object = NEXT_OBJECT(object ) ){ + int objindex = GET_OBJINDEX(object); + + if( siz <= findobjnum )break; + if( OBJECT_getType(objindex) != OBJTYPE_NOUSE ) + objbuf[findobjnum++] = objindex; + } + return findobjnum; +} + + +/*====================平乓仿及树 毛 月烟及楮醒====================*/ +/*左皿扑亦件犯□正及 侬 毛忡绣允月楮醒*/ +static char CHAR_optiondataString[STRINGBUFSIZ]; +/*------------------------------------------------------------ + * 左皿扑亦件迕及 侬 毛综月[ + * level, showstring , 熔及醒 , 飓 寞} 窒荚夫弘奶件仄凶井[ + * 弁仿旦[ + * 娄醒 + * ch Char* 平乓仿犯□正 + * 忒曰袄 + * char* static 卅 毛忒允及匹戚荚及裟太请仄及凛卞反 互 + * 凳今木化中月[娄醒毛公及引引忡绣仄卅中仪[ + ------------------------------------------------------------*/ +char* CHAR_makeOptionString( Char* ch ) +{ + char escapeshowstring[256]; + char *showstr = MAP_getfloorShowstring(ch->data[CHAR_FLOOR]); + if( ! showstr ){ + CHAR_optiondataString[0] = '\0'; + return CHAR_optiondataString; + } else { + +#if 0 /* 动票反LS2酷 匹丐月 */ + snprintf( CHAR_optiondataString, + sizeof( CHAR_optiondataString ), + "%d|%s|1|%d|%d", + ch->data[CHAR_LV], + makeEscapeString( showstr , + escapeshowstring,sizeof(escapeshowstring) ), + ch->data[CHAR_BASEIMAGENUMBER], + ch->data[CHAR_LOGINCOUNT]); +#endif + + /* 动票反StoneAge 酷 匹丐月[ + + dataplace|faceimg|level|hp|str|def|dex|charm|dp|earth|water|fire|wind|login|Name|Place + 午卅月[ + */ + { + snprintf( CHAR_optiondataString, + sizeof( CHAR_optiondataString ), + "%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%s|%s", + ch->data[CHAR_DATAPLACENUMBER], + ch->data[CHAR_FACEIMAGENUMBER], + ch->data[CHAR_LV], + ch->workint[CHAR_WORKMAXHP], + ch->workint[CHAR_WORKATTACKPOWER], + ch->workint[CHAR_WORKDEFENCEPOWER], + ch->workint[CHAR_WORKQUICK], + ch->workint[CHAR_WORKFIXCHARM], + ch->data[CHAR_DUELPOINT], /* dp, FIXME */ + ch->workint[CHAR_WORKFIXEARTHAT], + ch->workint[CHAR_WORKFIXWATERAT], + ch->workint[CHAR_WORKFIXFIREAT], + ch->workint[CHAR_WORKFIXWINDAT], + ch->data[CHAR_LOGINCOUNT], + ch->string[CHAR_NAME].string, + makeEscapeString( showstr , + escapeshowstring, + sizeof(escapeshowstring) ) + ); + } + } + return CHAR_optiondataString; +} + +static char CHAR_statusSendBuffer[STRINGBUFSIZ]; + +char* CHAR_makeStatusString( int index, char* category ) +{ + char c = tolower( category[0] ); + int strlength=0; + + if( !CHAR_CHECKINDEX( index ) ) return NULL; + + if( category == NULL ){ + CHAR_statusSendBuffer[0] = '\0'; + return CHAR_statusSendBuffer; + } +DebugPoint = 100; + switch( c ){ + case 'p': + { + int i; + int getCharDataArray[]= { + CHAR_NAME, + CHAR_OWNTITLE, + //CHAR_FMNAME, + }; + int maxexp = 200; + int exp; + int attr[4]; + { + exp = CHAR_getInt(index,CHAR_EXP ); + maxexp = CHAR_GetLevelExp( index, CHAR_getInt( index, CHAR_LV ) + 1); + } + + for( i = 0; i < 4; i ++ ) { + attr[i] = CHAR_getWorkInt( index, CHAR_WORKFIXEARTHAT + i); + if( attr[i] < 0 ) attr[i] = 0; + } + + snprintf(CHAR_statusSendBuffer,sizeof(CHAR_statusSendBuffer), + "P1|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|", + CHAR_getInt(index,CHAR_HP), + CHAR_getWorkInt(index,CHAR_WORKMAXHP), + CHAR_getInt(index,CHAR_MP), + CHAR_getWorkInt(index,CHAR_WORKMAXMP), + CHAR_getInt(index,CHAR_VITAL)/100, + CHAR_getInt(index,CHAR_STR)/100, + CHAR_getInt(index,CHAR_TOUGH)/100, + CHAR_getInt(index,CHAR_DEX)/100, + exp, maxexp, + CHAR_getInt(index,CHAR_LV), + CHAR_getWorkInt(index,CHAR_WORKATTACKPOWER), + CHAR_getWorkInt(index,CHAR_WORKDEFENCEPOWER), + CHAR_getWorkInt( index, CHAR_WORKQUICK), + CHAR_getWorkInt( index, CHAR_WORKFIXCHARM), + CHAR_getWorkInt( index, CHAR_WORKFIXLUCK), + attr[0], + attr[1], + attr[2], + attr[3], + CHAR_getInt(index,CHAR_GOLD), + CHAR_getInt(index,CHAR_INDEXOFEQTITLE), + CHAR_getInt(index,CHAR_DUELPOINT), + CHAR_getInt( index, CHAR_TRANSMIGRATION), + CHAR_getInt(index,CHAR_RIDEPET), + CHAR_getInt(index,CHAR_LEARNRIDE), + CHAR_getInt(index,CHAR_BASEBASEIMAGENUMBER) +#ifdef _NEW_RIDEPETS + ,CHAR_getInt( index, CHAR_LOWRIDEPETS) +#endif + + ); + strlength = strlen( CHAR_statusSendBuffer ); + for( i = 0 ; i < arraysizeof( getCharDataArray ) ; i ++ ){ + char token[256]; + char escapebuffer[128]; + snprintf( token, + sizeof( token ), + "%s" STATUSSENDDELIMITER, + makeEscapeString( CHAR_getChar(index, getCharDataArray[i]), + escapebuffer,sizeof(escapebuffer) + )); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof( CHAR_statusSendBuffer ) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= sizeof( CHAR_statusSendBuffer ) ) + return CHAR_statusSendBuffer; + } + return CHAR_statusSendBuffer; + break; + } +#ifdef _NEW_RIDEPETS + case 'x': + { + snprintf(CHAR_statusSendBuffer,sizeof(CHAR_statusSendBuffer), "X0|%d", + CHAR_getInt( index, CHAR_LOWRIDEPETS)); + return CHAR_statusSendBuffer; + break; + } +#endif + case 'f': + { + int big4fm =0; +#ifndef _NEW_RIDEPETS + switch( CHAR_getWorkInt( index, CHAR_WORKFMFLOOR) ) + { + case 1041: + big4fm = 1; + break; + case 2031: + big4fm = 2; + break; + case 3031: + big4fm = 3; + break; + case 4031: + big4fm = 4; + break; + default: + big4fm = 0; + } +#endif +#ifdef _FIX_FMNAME_RULE // WON ADD 家族未成立,不显示名称 + if( CHAR_getWorkInt(index, CHAR_WORKFMSETUPFLAG)==1 ){ + snprintf( CHAR_statusSendBuffer, + sizeof( CHAR_statusSendBuffer ), + "F%s|%d|%d|%d|%d", + "(待审)", + CHAR_getInt( index, CHAR_FMLEADERFLAG), + CHAR_getWorkInt( index, CHAR_WORKFMCHANNEL), + CHAR_getInt( index, CHAR_FMSPRITE), big4fm ); + }else +#endif + + snprintf( CHAR_statusSendBuffer, + sizeof( CHAR_statusSendBuffer ), + "F%s|%d|%d|%d|%d", + CHAR_getChar( index, CHAR_FMNAME), + CHAR_getInt( index, CHAR_FMLEADERFLAG), + CHAR_getWorkInt( index, CHAR_WORKFMCHANNEL), + CHAR_getInt( index, CHAR_FMSPRITE), big4fm ); + return CHAR_statusSendBuffer; + break; + } + case 'c': + { + int floor,xsiz,ysiz; + floor = CHAR_getInt(index,CHAR_FLOOR); + xsiz = MAP_getfloorX(floor); + ysiz = MAP_getfloorY(floor); + snprintf( CHAR_statusSendBuffer, + sizeof( CHAR_statusSendBuffer ), + "C%d|%d|%d|%d|%d", + CHAR_getInt(index,CHAR_FLOOR), + xsiz, ysiz, + CHAR_getInt(index,CHAR_X), + CHAR_getInt(index,CHAR_Y) ); + return CHAR_statusSendBuffer; + break; + } + case 'i': + { + int i; + CHAR_statusSendBuffer[0] = 'I'; + strlength = 1; + for( i = 0 ; i < CHAR_MAXITEMHAVE ; i ++ ){ + char token[512]; + int itemindex; + itemindex = CHAR_getItemIndex( index, i ); + if( itemindex >= 0 ) { + snprintf( token ,sizeof(token),"%s|" ,ITEM_makeItemStatusString( -1, itemindex ) ); + }else { + snprintf( token ,sizeof(token),"%s|" , ITEM_makeItemFalseString() ); + } + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof(CHAR_statusSendBuffer) - strlength, token ); + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_statusSendBuffer) ) return CHAR_statusSendBuffer; + } + dchop( CHAR_statusSendBuffer , "|" ); + return CHAR_statusSendBuffer; + break; + } + case 's': + { + int i; + CHAR_statusSendBuffer[0] = 'S'; + strlength = 1; + + for( i = 0 ; i < CHAR_SKILLMAXHAVE ; i ++ ){ + char token[256]; + CHAR_HaveSkill* hskill; + + hskill = CHAR_getCharHaveSkill( index, i ); + + if( hskill != NULL && hskill->use == TRUE ){ +#ifdef _CHAR_PROFESSION // WON ADD 人物职业 + snprintf( token , sizeof(token), "%s|", SKILL_makeSkillStatusString(&hskill->skill, index, i) ); +#else + snprintf( token , sizeof(token), "%s|", SKILL_makeSkillStatusString(&hskill->skill) ); +#endif + }else{ + snprintf( token , sizeof(token), "%s|", SKILL_makeSkillFalseString() ); + } + + strcpysafe( CHAR_statusSendBuffer + strlength, sizeof(CHAR_statusSendBuffer)-strlength, token ); + + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_statusSendBuffer) ) + return CHAR_statusSendBuffer; + } + + dchop( CHAR_statusSendBuffer , "|" ); + return CHAR_statusSendBuffer; + break; + } + case 't': + { + int i; + CHAR_statusSendBuffer[0] = 'T'; + strlength = 1; + for( i = 0 ; i < CHAR_TITLEMAXHAVE ; i ++ ){ + char token[256]; + char escape[256]; + snprintf( token , sizeof(token), "%s|" , + makeEscapeString( TITLE_makeTitleStatusString(index, + i ), + escape,sizeof(escape) ) ); + + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof(CHAR_statusSendBuffer) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_statusSendBuffer) ) + return CHAR_statusSendBuffer; + } + dchop( CHAR_statusSendBuffer , "|" ); + return CHAR_statusSendBuffer; + break; + } + case 'd': + snprintf( CHAR_statusSendBuffer,sizeof(CHAR_statusSendBuffer), + "D%d|%ld",CHAR_getWorkInt(index,CHAR_WORKOBJINDEX), + NowTime.tv_sec ); + return CHAR_statusSendBuffer; + break; + case 'm': + snprintf( CHAR_statusSendBuffer,sizeof(CHAR_statusSendBuffer), + "M%d|%d|%d", + CHAR_getInt( index,CHAR_HP ), + CHAR_getInt( index,CHAR_MP ), + CHAR_getInt( index,CHAR_EXP ) ); + return CHAR_statusSendBuffer; + break; + case 'e': + return NULL; + + case 'n': + { + int num; + + int i, nindex = -1; + int getCharDataArray[]= { + CHAR_NAME + }; + num = tolower( category[1] ) - '0'; + + if( num < 0 || num >= CHAR_PARTYMAX ){ + print( "朋友模式失败 (%c)%d \n", num, num ); + break; + } + + nindex = CHAR_getPartyIndex( index, num); + + if( nindex == -1 ){ + snprintf(CHAR_statusSendBuffer,sizeof(CHAR_statusSendBuffer), + "N%d|0|", num ); + return CHAR_statusSendBuffer; + }else{ + snprintf(CHAR_statusSendBuffer,sizeof(CHAR_statusSendBuffer), + "N%d|1|%d|%d|%d|%d|%d|", + num, + CHAR_getWorkInt( nindex, CHAR_WORKOBJINDEX), + CHAR_getInt( nindex, CHAR_LV), + CHAR_getWorkInt( nindex, CHAR_WORKMAXHP), + CHAR_getInt( nindex, CHAR_HP), + CHAR_getInt( nindex, CHAR_MP) + + ); + } + strlength = strlen( CHAR_statusSendBuffer ); + + for( i = 0 ; i < arraysizeof( getCharDataArray ) ; i ++ ){ + char token[256]; + char escapebuffer[128]; + snprintf( token, + sizeof( token ), + "%s" STATUSSENDDELIMITER, + makeEscapeString( CHAR_getChar(nindex, + getCharDataArray[i]), + escapebuffer,sizeof(escapebuffer) + )); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof( CHAR_statusSendBuffer ) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= sizeof( CHAR_statusSendBuffer ) ) + return CHAR_statusSendBuffer; + } + + return CHAR_statusSendBuffer; + break; + } + case 'k': + { + int num; + int i, pindex; + int getCharDataArray[]= { + CHAR_NAME, + CHAR_USERPETNAME, + }; + num = tolower( category[1] ) - '0'; + if( num < 0 || num >= CHAR_MAXPETHAVE ){ + print( "宠物模式失败 (%c)%d \n", num, num ); + break; + } + pindex = CHAR_getCharPet( index, num ); + if( pindex == -1 ){ + snprintf(CHAR_statusSendBuffer,sizeof(CHAR_statusSendBuffer), + "K%d|0|", num ); + return CHAR_statusSendBuffer; + }else{ + int attr[4]; + BOOL changenameflg = FALSE; + char *mycdkey; + char *cdkey = NULL; + for( i = 0; i < 4; i ++ ) { + attr[i] = CHAR_getWorkInt( pindex, CHAR_WORKFIXEARTHAT + i); + if( attr[i] < 0 ) attr[i] = 0; + } + mycdkey = CHAR_getChar( index, CHAR_CDKEY); + { + cdkey = CHAR_getChar( pindex, CHAR_CDKEY); + if( cdkey == NULL ) { + print( "can't get CDKEY\n"); + }else { + + if( strlen( cdkey) == 0 || + strcmp( cdkey, mycdkey) == 0 ){ + changenameflg = TRUE; + } + } + } + snprintf(CHAR_statusSendBuffer,sizeof(CHAR_statusSendBuffer), +// Syu ADD 改变交易时宠物转生颜色 +#ifdef _SHOW_FUSION + "K%d|1|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|", +#else + "K%d|1|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|", +#endif + num, + CHAR_getInt(pindex,CHAR_BASEIMAGENUMBER), + CHAR_getInt(pindex,CHAR_HP), + CHAR_getWorkInt(pindex,CHAR_WORKMAXHP), + CHAR_getInt(pindex,CHAR_MP), + CHAR_getWorkInt(pindex,CHAR_WORKMAXMP), + CHAR_getInt(pindex,CHAR_EXP ), + CHAR_GetLevelExp( pindex,CHAR_getInt( pindex, CHAR_LV ) + 1), + CHAR_getInt(pindex,CHAR_LV), + CHAR_getWorkInt(pindex,CHAR_WORKATTACKPOWER), + CHAR_getWorkInt(pindex,CHAR_WORKDEFENCEPOWER), + CHAR_getWorkInt( pindex, CHAR_WORKQUICK), + CHAR_getWorkInt( pindex, CHAR_WORKFIXAI), + attr[0], + attr[1], + attr[2], + attr[3], + CHAR_getInt( pindex, CHAR_SLOT), +// Syu ADD 改变交易时宠物转生颜色 + changenameflg, + CHAR_getInt( pindex,CHAR_TRANSMIGRATION) +#ifdef _SHOW_FUSION + ,CHAR_getInt ( pindex, CHAR_FUSIONBEIT) +#endif + ); + } + strlength = strlen( CHAR_statusSendBuffer ); + for( i = 0 ; i < arraysizeof( getCharDataArray ) ; i ++ ){ + char token[256]; + char escapebuffer[128]; + snprintf( token, + sizeof( token ), + "%s" STATUSSENDDELIMITER, + makeEscapeString( CHAR_getChar(pindex, + getCharDataArray[i]), + escapebuffer,sizeof(escapebuffer) + )); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof( CHAR_statusSendBuffer ) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= sizeof( CHAR_statusSendBuffer ) ) + return CHAR_statusSendBuffer; + } + return CHAR_statusSendBuffer; + break; + } + + case 'j': +{ + + int num; + int i, itemindex; + int getMagicDataArray[]= { + MAGIC_NAME, + MAGIC_COMMENT, + }; + num = tolower( category[1] ) - '0'; + + if( num < 0 || num >= CHAR_EQUIPPLACENUM ){ + break; + } + + itemindex = CHAR_getItemIndex( index, num ); + if( !ITEM_CHECKINDEX( itemindex) ) { + snprintf(CHAR_statusSendBuffer,sizeof(CHAR_statusSendBuffer), + "J%d|0|", num ); + return CHAR_statusSendBuffer; + }else{ + int magicindex = MAGIC_getMagicArray( ITEM_getInt( itemindex, ITEM_MAGICID)); + if( magicindex == -1 ) { + snprintf(CHAR_statusSendBuffer,sizeof(CHAR_statusSendBuffer), + "J%d|0|", num ); + return CHAR_statusSendBuffer; + } + snprintf(CHAR_statusSendBuffer,sizeof(CHAR_statusSendBuffer), + "J%d|1|%d|%d|%d|", + num, + ITEM_getInt( itemindex, ITEM_MAGICUSEMP), + MAGIC_getInt( magicindex, MAGIC_FIELD), + MAGIC_getInt( magicindex, MAGIC_TARGET)); + strlength = strlen( CHAR_statusSendBuffer ); + + for( i = 0 ; i < arraysizeof( getMagicDataArray ) ; i ++ ){ + char token[256]; + char escapebuffer[128]; + snprintf( token, + sizeof( token ), + "%s" STATUSSENDDELIMITER, + makeEscapeString( MAGIC_getChar(magicindex, + getMagicDataArray[i]), + escapebuffer,sizeof(escapebuffer) + )); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof( CHAR_statusSendBuffer ) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= sizeof( CHAR_statusSendBuffer ) ) + return CHAR_statusSendBuffer; + } + return CHAR_statusSendBuffer; + } + } + break; + + case 'w': +{ + int num; + int i,petskillloop, pindex; + char tmp[16]; + int getPetSkillDataArray[]= { + PETSKILL_NAME, + PETSKILL_COMMENT, + }; + + num = tolower( category[1] ) - '0'; + if( num < 0 || num >= CHAR_MAXPETHAVE ){ + print( "宠物特技资料失败 (%c)%d \n", num, num ); + break; + } + + pindex = CHAR_getCharPet( index, num ); + if( !CHAR_CHECKINDEX(pindex)){ + return NULL; + } + snprintf( tmp, sizeof( tmp), "W%d|", num); + strcpysafe( CHAR_statusSendBuffer, sizeof( CHAR_statusSendBuffer), + tmp); + strlength += strlen( tmp); + if( strlength >= arraysizeof( CHAR_statusSendBuffer) ) { + return CHAR_statusSendBuffer; + } + for( petskillloop = 0; petskillloop < CHAR_MAXPETSKILLHAVE; petskillloop ++ ) { + int skillid = CHAR_getPetSkill( pindex, petskillloop); + int petskillindex = PETSKILL_getPetskillArray( skillid ); + if( PETSKILL_CHECKINDEX( petskillindex) ) { + char token[256]; + snprintf( token, sizeof( token), + "%d|%d|%d|", + + PETSKILL_getInt( petskillindex, PETSKILL_ID), + PETSKILL_getInt( petskillindex, PETSKILL_FIELD), + PETSKILL_getInt( petskillindex, PETSKILL_TARGET) + ); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof(CHAR_statusSendBuffer) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_statusSendBuffer)) { + return CHAR_statusSendBuffer; + } + + for( i = 0 ; i < arraysizeof( getPetSkillDataArray ) ; i ++ ){ + char escapebuffer[128]; + snprintf( token, + sizeof( token ), + "%s" STATUSSENDDELIMITER, + makeEscapeString( + PETSKILL_getChar(petskillindex, + getPetSkillDataArray[i]), + escapebuffer,sizeof(escapebuffer) + )); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof( CHAR_statusSendBuffer ) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= sizeof( CHAR_statusSendBuffer )) { + return CHAR_statusSendBuffer; + } + } + } + else { + char token[256]; + snprintf( token, sizeof( token),"|||||"); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof(CHAR_statusSendBuffer) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_statusSendBuffer) ) { + return CHAR_statusSendBuffer; + } + } + } + return CHAR_statusSendBuffer; +} + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + case 'y': +{ + int num = 0, f_num = 0; + int i,petskillloop, pindex; + char tmp[16]; + int getPetSkillDataArray[]= { + PETSKILL_NAME, + PETSKILL_COMMENT, + }; + + num = tolower( category[1] ) - '0'; + if( num < 0 || num >= CHAR_MAXPETHAVE ){ + print( "宠物特技资料失败 (%c)%d \n", num, num ); + break; + } + + pindex = CHAR_getCharPet( index, num ); + if( !CHAR_CHECKINDEX(pindex)){ + return NULL; + } + snprintf( tmp, sizeof( tmp), "W%d|", num); + strcpysafe( CHAR_statusSendBuffer, sizeof( CHAR_statusSendBuffer), + tmp); + strlength += strlen( tmp); + if( strlength >= arraysizeof( CHAR_statusSendBuffer) ) { + return CHAR_statusSendBuffer; + } + + if( CHAR_getWorkInt( pindex, CHAR_WORKOBLIVION) > 0 ) + f_num = CHAR_getWorkInt( pindex, CHAR_WORKMODOBLIVION ) + 1;// 遗忘宠技数量 + + for( petskillloop = 0; petskillloop < CHAR_MAXPETSKILLHAVE; petskillloop ++ ) { + int skillid = CHAR_getPetSkill( pindex, petskillloop); + int petskillindex = PETSKILL_getPetskillArray( skillid ); + if( PETSKILL_CHECKINDEX( petskillindex) ) { + char token[256]; + int field = -1, target = -1; + int oblivion = CHAR_getWorkInt( pindex, CHAR_WORKOBLIVION ); + int p_id = PETSKILL_getInt( petskillindex, PETSKILL_ID); + int rand_num = RAND( 0, 100 ); + + // 中了遗忘 + if( (oblivion > 0) && ( f_num > 0 ) && ( rand_num <= 60 ) && ( p_id != 1 ) ){ + field = PETSKILL_FIELD_MAP; + target = PETSKILL_TARGET_NONE; + f_num --; + }else{ + field = PETSKILL_getInt( petskillindex, PETSKILL_FIELD); + target = PETSKILL_getInt( petskillindex, PETSKILL_TARGET); + } + + snprintf( token, sizeof( token),"%d|%d|%d|", +// PETSKILL_getInt( petskillindex, PETSKILL_ID), + p_id, + field, target + ); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof(CHAR_statusSendBuffer) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_statusSendBuffer)) { + return CHAR_statusSendBuffer; + } + + for( i = 0 ; i < arraysizeof( getPetSkillDataArray ) ; i ++ ){ + char escapebuffer[128]; + snprintf( token, + sizeof( token ), + "%s" STATUSSENDDELIMITER, + makeEscapeString( + PETSKILL_getChar(petskillindex, + getPetSkillDataArray[i]), + escapebuffer,sizeof(escapebuffer) + )); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof( CHAR_statusSendBuffer ) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= sizeof( CHAR_statusSendBuffer )) { + return CHAR_statusSendBuffer; + } + } + } + else { + char token[256]; + snprintf( token, sizeof( token),"|||||"); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof(CHAR_statusSendBuffer) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_statusSendBuffer) ) { + return CHAR_statusSendBuffer; + } + } + } + return CHAR_statusSendBuffer; +} +#endif + +#ifdef _PETSKILL_DAMAGETOHP + case 'o': +{ + int getPetSkillDataArray[]= { + PETSKILL_NAME, + PETSKILL_COMMENT, + }; + int i,petskillloop, pindex=index; + int num = 0;//, f_num = 0; + char tmp[16]; + + num = tolower( category[1] ) - '0'; + if( num < 0 || num >= CHAR_MAXPETHAVE ){ + print( "宠物特技资料失败 (%c)%d \n", num, num ); + break; + } + + pindex = CHAR_getCharPet( index, num ); + if( !CHAR_CHECKINDEX(pindex)){ + return NULL; + } + snprintf( tmp, sizeof( tmp), "W%d|", num); + strcpysafe( CHAR_statusSendBuffer, sizeof( CHAR_statusSendBuffer), + tmp); + strlength += strlen( tmp); + if( strlength >= arraysizeof( CHAR_statusSendBuffer) ) { + return CHAR_statusSendBuffer; + } + + for( petskillloop = 0; petskillloop < CHAR_MAXPETSKILLHAVE; petskillloop ++ ) { + int skillid = CHAR_getPetSkill( pindex, petskillloop); + int petskillindex = PETSKILL_getPetskillArray( skillid ); + if( PETSKILL_CHECKINDEX( petskillindex) ) { + char token[256]; + int field = -1, target = -1; + //int oblivion = CHAR_getWorkInt( pindex, CHAR_WORKOBLIVION ); + int p_id = PETSKILL_getInt( petskillindex, PETSKILL_ID); + + //生命大於50%且技能名称若为 浴血狂袭 技能不能选 + if( ( CHAR_getInt( pindex, CHAR_HP ) > CHAR_getWorkInt( pindex, CHAR_WORKMAXHP )*0.5 + && strcmp(PETSKILL_getChar( petskillindex, PETSKILL_NAME),"浴血狂袭" ) == 0 ) +#ifdef _PETSKILL_EXPLODE + || ( CHAR_getInt( pindex, CHAR_HP ) < (CHAR_getWorkInt( pindex, CHAR_WORKMAXHP ) >> 1 ) + && strcmp(PETSKILL_getChar( petskillindex, PETSKILL_NAME),"爆裂攻击" ) == 0 ) +#endif + ){ + field = PETSKILL_FIELD_MAP; + target = PETSKILL_TARGET_NONE; + }else{ + field = PETSKILL_getInt( petskillindex, PETSKILL_FIELD); + target = PETSKILL_getInt( petskillindex, PETSKILL_TARGET); + } + + snprintf( token, sizeof( token),"%d|%d|%d|", +// PETSKILL_getInt( petskillindex, PETSKILL_ID), + p_id, + field, target + ); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof(CHAR_statusSendBuffer) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_statusSendBuffer)) { + return CHAR_statusSendBuffer; + } + + for( i = 0 ; i < arraysizeof( getPetSkillDataArray ) ; i ++ ){ + char escapebuffer[128]; + snprintf( token, + sizeof( token ), + "%s" STATUSSENDDELIMITER, + makeEscapeString( + PETSKILL_getChar(petskillindex, + getPetSkillDataArray[i]), + escapebuffer,sizeof(escapebuffer) + )); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof( CHAR_statusSendBuffer ) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= sizeof( CHAR_statusSendBuffer )) { + return CHAR_statusSendBuffer; + } + } + } + else { + char token[256]; + snprintf( token, sizeof( token),"|||||"); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof(CHAR_statusSendBuffer) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_statusSendBuffer) ) { + return CHAR_statusSendBuffer; + } + } + } + return CHAR_statusSendBuffer; +} +#endif + +#ifdef _PETSKILL_BECOMEFOX + case 'a': +{ + int getPetSkillDataArray[]= { + PETSKILL_NAME, + PETSKILL_COMMENT, + }; + int i,petskillloop, pindex=index; + int num = 0;//, f_num = 0; + char tmp[16]; + + num = tolower( category[1] ) - '0'; + if( num < 0 || num >= CHAR_MAXPETHAVE ){ + print( "宠物特技资料失败 (%c)%d \n", num, num ); + break; + } + print( "宠物特技资料" ); + pindex = CHAR_getCharPet( index, num ); + if( !CHAR_CHECKINDEX(pindex)){ + return NULL; + } + snprintf( tmp, sizeof( tmp), "W%d|", num); + strcpysafe( CHAR_statusSendBuffer, sizeof( CHAR_statusSendBuffer), + tmp); + strlength += strlen( tmp); + if( strlength >= arraysizeof( CHAR_statusSendBuffer) ) { + return CHAR_statusSendBuffer; + } + + for( petskillloop = 0; petskillloop < CHAR_MAXPETSKILLHAVE; petskillloop ++ ) { + int skillid = CHAR_getPetSkill( pindex, petskillloop); + int petskillindex = PETSKILL_getPetskillArray( skillid ); + if( PETSKILL_CHECKINDEX( petskillindex) ) { + char token[256]; + int field = -1, target = -1; + //int oblivion = CHAR_getWorkInt( pindex, CHAR_WORKOBLIVION ); + int p_id = PETSKILL_getInt( petskillindex, PETSKILL_ID); + + //技能名称若为 待机 攻击 防御 技能才能选 + print("\n技能名称:%s",PETSKILL_getChar( petskillindex, PETSKILL_NAME)); + if( strcmp(PETSKILL_getChar( petskillindex, PETSKILL_NAME),"待机" ) == 0 + || strcmp(PETSKILL_getChar( petskillindex, PETSKILL_NAME),"攻击" ) == 0 + || strcmp(PETSKILL_getChar( petskillindex, PETSKILL_NAME),"防御" ) == 0){ + field = PETSKILL_getInt( petskillindex, PETSKILL_FIELD); + target = PETSKILL_getInt( petskillindex, PETSKILL_TARGET); + }else{ + field = PETSKILL_FIELD_MAP; + target = PETSKILL_TARGET_NONE; + } + + snprintf( token, sizeof( token),"%d|%d|%d|", +// PETSKILL_getInt( petskillindex, PETSKILL_ID), + p_id, + field, target + ); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof(CHAR_statusSendBuffer) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_statusSendBuffer)) { + return CHAR_statusSendBuffer; + } + + for( i = 0 ; i < arraysizeof( getPetSkillDataArray ) ; i ++ ){ + char escapebuffer[128]; + snprintf( token, + sizeof( token ), + "%s" STATUSSENDDELIMITER, + makeEscapeString( + PETSKILL_getChar(petskillindex, + getPetSkillDataArray[i]), + escapebuffer,sizeof(escapebuffer) + )); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof( CHAR_statusSendBuffer ) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= sizeof( CHAR_statusSendBuffer )) { + return CHAR_statusSendBuffer; + } + } + } + else { + char token[256]; + snprintf( token, sizeof( token),"|||||"); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof(CHAR_statusSendBuffer) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_statusSendBuffer) ) { + return CHAR_statusSendBuffer; + } + } + } + return CHAR_statusSendBuffer; +} +#endif + + default: + break; + } + + CHAR_statusSendBuffer[0] = '\0'; + return CHAR_statusSendBuffer; +} + +//BOOL CHAR_sendStatusString( int charaindex, char* category ) +BOOL _CHAR_sendStatusString( int charaindex, char* category, char* file, int line ) +{ + char* string; + + //print("\nsend_S:%s:%d ", file, line); + + if( CHAR_getInt(charaindex,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ){ + return FALSE; + } + string = CHAR_makeStatusString( charaindex, category ); + + if( string != NULL ){ + int fd; + fd = getfdFromCharaIndex( charaindex ); + if( fd != -1 ){ + lssproto_S_send( fd, string ); + return TRUE; + } + } + return FALSE; +} + +void CHAR_inputOwnTitle( int index ,char* name ) +{ + if( !CHAR_CHECKINDEX( index ) ) return; + + if( CHAR_getFlg( index,CHAR_ISDIE ) )return; + + CHAR_setChar( index, CHAR_OWNTITLE ,name); + + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( index, CHAR_WORKOBJINDEX) ); + + CHAR_send_P_StatusString( index, CHAR_P_STRING_OWNTITLE ); +} + + +void CHAR_selectTitle( int index, int titleindex ) +{ + if( !CHAR_CHECKINDEX( index ) )return; + + if( CHAR_getFlg( index,CHAR_ISDIE ) )return; + + if( titleindex == -1 ){ + CHAR_setInt( index, CHAR_INDEXOFEQTITLE, titleindex); + }else if( titleindex < 0 || titleindex >= CHAR_TITLEMAXHAVE ) { + return; + } + else{ + + int title = CHAR_getCharHaveTitle( index,titleindex ); + + if( TITLE_getTitleIndex( title) != -1 ){ + CHAR_setInt( index, CHAR_INDEXOFEQTITLE, titleindex); + } + } + + CHAR_sendStatusString( index, "T" ); + CHAR_send_P_StatusString( index, CHAR_P_STRING_TITLE ); +} + + +void CHAR_deleteTitle( int index, int titleindex ) +{ + int title; + + if( !CHAR_CHECKINDEX( index ) )return; + /* 韶氏匹中月凛反分户 */ + if( CHAR_getFlg( index,CHAR_ISDIE ) )return; + + if( titleindex < 0 || titleindex >= CHAR_TITLEMAXHAVE )return; + title = CHAR_getCharHaveTitle( index,titleindex ); + /*if( TITLE_CHECKTABLEINDEX( title ) == FALSE )*/ + if( TITLE_getTitleIndex( title) == -1 ) { + return; + } + CHAR_setCharHaveTitle( index,titleindex,-1 ); + + /* 愤坌互银匀化中凶支勾卅日壬}公木手卅仄卞允月 */ + if( CHAR_getInt(index, CHAR_INDEXOFEQTITLE) == titleindex ) + CHAR_setInt(index, CHAR_INDEXOFEQTITLE, -1 ); + + /* + * 旦 □正旦树 毛霜月[ + */ + CHAR_sendStatusString( index, "T" ); + CHAR_send_P_StatusString( index, CHAR_P_STRING_TITLE ); +} + +static void CHAR_initcharWorkInt( index ) +{ + float hp; + static struct substitutionTable{ + CHAR_WORKDATAINT workindex; + CHAR_DATAINT intindex; + }subtbl[]={ + { CHAR_WORKMAXMP, CHAR_MAXMP }, + { CHAR_WORKFIXFIREAT, CHAR_FIREAT }, + { CHAR_WORKFIXWATERAT, CHAR_WATERAT}, + { CHAR_WORKFIXEARTHAT, CHAR_EARTHAT}, + { CHAR_WORKFIXWINDAT, CHAR_WINDAT }, + { CHAR_WORKFIXCHARM, CHAR_CHARM }, + { CHAR_WORKFIXLUCK, CHAR_LUCK }, + { CHAR_WORKFIXLUCK, CHAR_LUCK }, + { CHAR_WORKMODPOISON, CHAR_POISON }, + { CHAR_WORKMODPARALYSIS,CHAR_PARALYSIS }, + { CHAR_WORKMODSLEEP, CHAR_SLEEP }, + { CHAR_WORKMODSTONE, CHAR_STONE }, + { CHAR_WORKMODDRUNK, CHAR_DRUNK }, + { CHAR_WORKMODCONFUSION, CHAR_CONFUSION } + }; + int i; + for( i=0 ; i 0 ){ + CHAR_setWorkInt( index, CHAR_WORKFIXEARTHAT + (i + 2) % 4, attr * -1); + } + } + +#ifdef _MAGIC_RESIST_EQUIT // WON ADD 职业抗性装备 + { + // 火冰电抗性 + //for( i=0; i<3; i++) + // CHAR_setWorkInt( index, CHAR_WORK_F_RESIST+i, CHAR_getInt( index, PROFESSION_FIRE_R+i ) ); + } +#endif + + + CHAR_setWorkInt( index, CHAR_WORKFIXDEX, + CHAR_getInt( index, CHAR_DEX) * 0.01 ); + CHAR_setWorkInt( index, CHAR_WORKFIXVITAL, + CHAR_getInt( index, CHAR_VITAL) * 0.01 ); + + CHAR_setWorkInt( index, CHAR_WORKFIXSTR, + CHAR_getInt( index, CHAR_STR) * 0.01 * 1.0 +//#ifdef _BATTLE_NEWPOWER +// + CHAR_getInt( index, CHAR_DEX) * 0.01 * 0.05 +// + CHAR_getInt( index, CHAR_VITAL) * 0.01 * 0.05 ); // 耐力 +//#else + + CHAR_getInt( index, CHAR_TOUGH) * 0.01 * 0.1 + + CHAR_getInt( index, CHAR_VITAL) * 0.01 * 0.1 + + CHAR_getInt( index, CHAR_DEX) * 0.01 * 0.05 ); +//#endif + CHAR_setWorkInt( index, CHAR_WORKFIXTOUGH, + CHAR_getInt( index, CHAR_TOUGH) * 0.01 * 1.0 +//#ifdef _BATTLE_NEWPOWER +// + CHAR_getInt( index, CHAR_DEX) * 0.01 * 0.05 +// + CHAR_getInt( index, CHAR_VITAL) * 0.01 * 0.05 ); // 力量 +//#else + + CHAR_getInt(index,CHAR_STR) * 0.01 * 0.1 + + CHAR_getInt(index,CHAR_VITAL) * 0.01 * 0.1 + + CHAR_getInt(index,CHAR_DEX) * 0.01 * 0.05 ); +//#endif + +#ifdef _ITEMSET5_TXT + { + CHAR_setWorkInt( index, CHAR_WORKFIXARRANGE, 0); + CHAR_setWorkInt( index, CHAR_WORKFIXSEQUENCE, 0); + CHAR_setWorkInt( index, CHAR_WORKATTACHPILE, 0); + CHAR_setWorkInt( index, CHAR_WORKHITRIGHT, 0); + } +#endif + + + +#ifdef _ITEMSET6_TXT + { + CHAR_setWorkInt( index, CHAR_WORKNEGLECTGUARD, 0); + } +#endif + + CHAR_setWorkInt( index, CHAR_WORKATTACKPOWER, + CHAR_getWorkInt(index,CHAR_WORKFIXSTR) ); + CHAR_setWorkInt( index, CHAR_WORKDEFENCEPOWER, + CHAR_getWorkInt(index,CHAR_WORKFIXTOUGH) ); + CHAR_setWorkInt( index, CHAR_WORKQUICK, + CHAR_getWorkInt( index, CHAR_WORKFIXDEX)); + + hp = ( CHAR_getInt(index,CHAR_VITAL) * 4 + + CHAR_getInt(index,CHAR_STR) * 1 + + CHAR_getInt(index,CHAR_TOUGH) * 1 + + CHAR_getInt(index,CHAR_DEX) * 1 ) * 0.01; + + CHAR_setWorkInt( index, CHAR_WORKMAXHP, (int)hp ); + CHAR_setWorkInt( index, CHAR_WORKMAXMP, CHAR_getInt( index, CHAR_MAXMP)); + +#ifdef _ADD_DEAMGEDEFC + CHAR_setWorkInt( index, CHAR_WORKOTHERDMAGE, 0); + CHAR_setWorkInt( index, CHAR_WORKOTHERDEFC, 0); +#endif + + if( CHAR_getInt( index, CHAR_WHICHTYPE) == CHAR_TYPEPET) { + int hostindex; + CHAR_setWorkInt( index, CHAR_WORKFIXAI, 0); + hostindex = CHAR_getWorkInt( index, CHAR_WORKPLAYERINDEX); + if( CHAR_CHECKINDEX( hostindex)) { + int ai; + int modai = CHAR_getInt( index, CHAR_MODAI); + double R; + if( modai <= 0 ) modai = 100; + R = 1.10; + ai = ( (CHAR_getInt( hostindex, CHAR_LV) + * CHAR_getWorkInt( hostindex, CHAR_WORKFIXCHARM ) + * R) + / + (CHAR_getInt( index, CHAR_LV)* modai) * 100 ) ; + if( ai > 100 ) ai = 100; + + ai += CHAR_getInt( index, CHAR_VARIABLEAI) * 0.01; + if( CHAR_getInt( hostindex, CHAR_TRANSMIGRATION ) > 0 ){ + // shan 120 -> 140 + ai += ( CHAR_GetLevel() - CHAR_getInt( hostindex, CHAR_LV ) ) / 2; + } + if( ai < 0 ) ai = 0; + if( ai > 100 ) ai = 100; + CHAR_setWorkInt( index, CHAR_WORKFIXAI, ai); + } + } +} + +int _CHAR_complianceParameter( int index, char *FILE, int LINE) +{ + //print("\ncompPara:%s:%d", FILE, LINE); + + if( !CHAR_CHECKINDEX( index)) return 0; + + CHAR_initcharWorkInt( index ); + ITEM_equipEffect( index ); + + CHAR_setWorkInt(index, CHAR_WORKATTACKPOWER, + CHAR_getWorkInt( index, CHAR_WORKFIXSTR ) ); + CHAR_setWorkInt(index, CHAR_WORKDEFENCEPOWER, + CHAR_getWorkInt( index, CHAR_WORKFIXTOUGH ) ); + CHAR_setWorkInt(index, CHAR_WORKQUICK, + CHAR_getWorkInt( index, CHAR_WORKFIXDEX ) ); + +#ifdef _ITEMSET5_TXT + CHAR_setWorkInt(index, CHAR_WORKARRANGEPOWER, + CHAR_getWorkInt( index, CHAR_WORKFIXARRANGE ) ); + CHAR_setWorkInt(index, CHAR_WORKSEQUENCEPOWER, + CHAR_getWorkInt( index, CHAR_WORKFIXSEQUENCE ) ); +#endif + + Other_DefcharWorkInt( index); + CHAR_setInt( index, CHAR_HP, min( CHAR_getInt(index,CHAR_HP), CHAR_getWorkInt( index, CHAR_WORKMAXHP))); + CHAR_setInt( index, CHAR_MP, min( CHAR_getInt(index,CHAR_MP), CHAR_getWorkInt( index, CHAR_WORKMAXMP))); + + if( CHAR_getInt( index, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ){ + if( CHAR_getWorkInt( index, CHAR_WORKPETFOLLOW ) != -1 ){ + int petindex = CHAR_getWorkInt( index, CHAR_WORKPETFOLLOW ); + if( !CHAR_CHECKINDEX( petindex) ){ + CHAR_setWorkInt( index, CHAR_WORKPETFOLLOW, -1); + }else{ + if( CHAR_getInt( petindex, CHAR_WHICHTYPE) == CHAR_TYPEPET && + !CHAR_CHECKINDEX( CHAR_getWorkInt( petindex, CHAR_WORKPLAYERINDEX)) ){ + CHAR_setWorkInt( index, CHAR_WORKPETFOLLOW, petindex); + CHAR_setWorkInt( petindex, CHAR_WORKPLAYERINDEX, index); + } + } + } + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + { + int i, add_pile = 0; + int old_pile = CHAR_getWorkInt( index, CHAR_WORKATTACHPILE); + + for( i=0; i NowTime.tv_sec +#ifdef _NPCCHANGE_PLAYERIMG + || CHAR_getWorkInt( index, CHAR_WORKNPCMETAMO) > 0 +#endif +#ifdef _PETSKILL_BECOMEPIG + || CHAR_getInt( index, CHAR_BECOMEPIG) > -1 +#endif + ){ + newimagenumber = oldimagenumber; //不恢复成原本的图 + } +#endif + // Arminius 8.9 airplane + if (oldimagenumber==100259) newimagenumber=100259; +#ifdef _VARY_WOLF + if( (CHAR_getInt( index, CHAR_WHICHTYPE) == CHAR_TYPEPET) && + (CHAR_getWorkInt( index, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) && + oldimagenumber == 101428 ){ + newimagenumber = 101428; + } +#endif + +#ifdef _ENEMY_FALLGROUND + if( CHAR_getInt( index, CHAR_WHICHTYPE) == CHAR_TYPEENEMY ) { + return 0; + }else { +#endif + if( newimagenumber == -1 ) { + CHAR_setInt(index,CHAR_BASEIMAGENUMBER, basebaseimagenumber); + }else { + CHAR_setInt(index,CHAR_BASEIMAGENUMBER,newimagenumber); + } + +#ifdef _ENEMY_FALLGROUND + } +#endif +#ifdef _NEW_RIDEPETS + if( (CHAR_getWorkInt(index, CHAR_WORKITEMMETAMO)>NowTime.tv_sec) + || (CHAR_getWorkInt(index,CHAR_WORKNPCMETAMO)>0)){ + return 0; + } +#endif + // Robin 0725 + if( CHAR_getInt(index, CHAR_RIDEPET) != -1 ){ + int i; +#ifndef _NEW_RIDEPETS + int big4fm =0; +#endif +#ifdef _NEW_RIDEPETS + BOOL FindGraNo = FALSE; +#endif + int petindex = CHAR_getCharPet( index, CHAR_getInt(index, CHAR_RIDEPET) ); +#ifndef _NEW_RIDEPETS + int leaderGraNo = 100700 + + ((CHAR_getInt( index, CHAR_BASEBASEIMAGENUMBER)-100000)/20)*10 + + CHAR_getInt( index, CHAR_FMSPRITE)*5; + switch( CHAR_getWorkInt( index, CHAR_WORKFMFLOOR) ){ + + case 1041: + big4fm = 1; + break; + case 2031: + big4fm = 2; + break; + case 3031: + big4fm = 3; + break; + case 4031: + big4fm = 4; + break; + default: + big4fm = 0; + } +#endif + for( i=0; i< arraysizeof(ridePetTable) ; i++ ) { +#ifdef _NEW_RIDEPETS + if( (( CHAR_getInt( index, CHAR_BASEIMAGENUMBER) == ridePetTable[i].charNo ) || + ( CHAR_getInt( index, CHAR_BASEBASEIMAGENUMBER) == ridePetTable[i].charNo )) +#else + if( ( CHAR_getInt( index, CHAR_BASEBASEIMAGENUMBER) == ridePetTable[i].charNo ) +#endif + && ( CHAR_getInt( petindex, CHAR_BASEBASEIMAGENUMBER) == ridePetTable[i].petNo ) ) { + CHAR_setInt( index, CHAR_BASEIMAGENUMBER, ridePetTable[i].rideNo ); +#ifdef _NEW_RIDEPETS + FindGraNo = TRUE; +#endif + break; + } +#ifndef _NEW_RIDEPETS + else if( ( leaderGraNo == ridePetTable[i].charNo ) + && ( CHAR_getInt( petindex, CHAR_BASEBASEIMAGENUMBER) == ridePetTable[i].petNo ) +#ifdef _EVERYONE_RIDE + && big4fm != 0 ){ +#else + && CHAR_getInt( index, CHAR_FMLEADERFLAG ) == FMMEMBER_LEADER ){ +#endif + CHAR_setInt( index, CHAR_BASEIMAGENUMBER, ridePetTable[i].rideNo ); + break; + } +#endif + } + +#ifdef _NEW_RIDEPETS + { + int ti=-1, Noindex, image=-1; + int petNo = CHAR_getInt( petindex, CHAR_BASEBASEIMAGENUMBER); + int playerNo = CHAR_getInt( index, CHAR_BASEBASEIMAGENUMBER); + + int playerlowsride = CHAR_getInt( index, CHAR_LOWRIDEPETS); + if( (ti = RIDEPET_getPETindex( petNo, playerlowsride )) >= 0 ) { + if( (Noindex = RIDEPET_getNOindex( playerNo)) >= 0 ){ + if( (image = RIDEPET_getRIDEno( Noindex,ti)) >= 0 ) { + FindGraNo = TRUE; + CHAR_setInt( index, CHAR_BASEIMAGENUMBER, image ); + } + } + } + } + if( FindGraNo == FALSE ){ + CHAR_setInt( index , CHAR_RIDEPET, -1 ); + CHAR_setInt( index , CHAR_BASEIMAGENUMBER , CHAR_getInt( index, CHAR_BASEBASEIMAGENUMBER) ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( index, CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( index, CHAR_P_STRING_RIDEPET ); + } +#endif + } + } + return 1; +} + +/*====================================================================== + 平乓仿及失奶 丞毛健丹楮醒 + ======================================================================*/ + +/*====================苇月====================*/ +/*------------------------------------------------------------ + * 轾隙烂匹}公及 轾及平乓仿弁正卞苇月奶矛件玄毛 戏今六月 + * 娄醒 + * charaindex int 平乓仿奶件犯永弁旦 + * dir int 轾 + * 忒曰袄 + * 卅仄 + ------------------------------------------------------------*/ +void CHAR_Look( int charaindex, int dir ) +{ + int fl ,x,y; + OBJECT object; + + /* 奶件犯永弁旦及民尼永弁 */ + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return; + + if( dir < 0 ) { + dir = CHAR_getInt(charaindex,CHAR_DIR); + } + VALIDATEDIR(dir); + if( CHAR_getInt( charaindex, CHAR_DIR) != dir ) { + CHAR_setInt(charaindex,CHAR_DIR,dir); + /* 轾 晶仄凶失弁扑亦件毛霜耨允月 */ + CHAR_sendWatchEvent(CHAR_getWorkInt(charaindex,CHAR_WORKOBJINDEX), + CHAR_ACTTURN,NULL,0,TRUE); + } + + fl = CHAR_getInt(charaindex,CHAR_FLOOR); + CHAR_getCoordinationDir( CHAR_getInt(charaindex,CHAR_DIR), + CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y), + 1, &x, &y ); + + //CHAR_talkToCli( charaindex, -1, "调查四周环境。", CHAR_COLORWHITE ); + + for( object=MAP_getTopObj(fl,x,y) ; object ; + object = NEXT_OBJECT(object) ){ + int objindex = GET_OBJINDEX(object); + if( OBJECT_getType(objindex) == OBJTYPE_CHARA ){ + typedef void (*LOOKF)(int,int); + LOOKF lf; + lf = (LOOKF)CHAR_getFunctionPointer( + OBJECT_getIndex(objindex),CHAR_LOOKEDFUNC); + if( lf ) lf(OBJECT_getIndex(objindex),charaindex); + } + } +} + +BOOL _CHAR_makeObjectCString( char *file, int line, int objindex,char* buf, int buflen ) +{ + char objindexbuf[64]; + if( CHECKOBJECT(objindex) == FALSE ) return FALSE; + + switch( OBJECT_getType(objindex) ){ + case OBJTYPE_NOUSE: + return FALSE; + break; + case OBJTYPE_CHARA: + { + int charaindex = OBJECT_getIndex(objindex); + char escapename[256]; + char escapetitle[256]; + // shan add +1 + char tmp[128]; + int namecolor; +#ifdef _TRANS_6 +#ifdef _TRANS_7 + int namecolortbl[] = { CHAR_COLORWHITE, CHAR_COLORYELLOW, CHAR_COLORGREEN, + CHAR_COLORCYAN, CHAR_COLORRED, CHAR_COLORPURPLE, CHAR_COLORBLUE2,CHAR_COLORGRAY};//转生後的颜色 +#else + int namecolortbl[] = { CHAR_COLORWHITE, CHAR_COLORYELLOW, CHAR_COLORGREEN, + CHAR_COLORCYAN, CHAR_COLORRED, CHAR_COLORPURPLE, CHAR_COLORBLUE2};//转生後的颜色 +#endif +#else + int namecolortbl[] = { CHAR_COLORWHITE, CHAR_COLORYELLOW, CHAR_COLORGREEN, + CHAR_COLORCYAN, CHAR_COLORRED, CHAR_COLORPURPLE}; +#endif + int ridepet = BATTLE_getRidePet( charaindex ); + char petname[64] = ""; + char escapepetname[256]; + int petlevel = 0; + + if( !CHAR_getFlg(charaindex,CHAR_ISVISIBLE) )return FALSE; + namecolor = CHAR_getInt( charaindex, CHAR_TRANSMIGRATION); +#ifdef _TRANS_6 +#ifdef _TRANS_7 + if( namecolor > 7 ) namecolor = 7; +#else + if( namecolor > 6 ) namecolor = 6; +#endif +#else + if( namecolor > 5 ) namecolor = 5; +#endif + if( namecolor < 0 ) namecolor = 0; + + // shan add begin + if( CHAR_getWorkInt(charaindex, CHAR_WORKFMINDEXI) >= 0 + && CHAR_getWorkInt(charaindex, CHAR_WORKFMINDEXI) < FAMILY_MAXNUM + && CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER + && CHAR_getWorkInt(charaindex, CHAR_WORKFMSETUPFLAG)!=1) +#ifdef _ITEM_SETLOVER + if(strlen( CHAR_getChar( charaindex, CHAR_LOVE)) > 0 && + strlen(CHAR_getChar(charaindex,CHAR_LOVERID))>0 && + strlen(CHAR_getChar(charaindex,CHAR_LOVERNAME))>0) + sprintf(tmp, "%s§♂%s♀",CHAR_getChar( charaindex, CHAR_FMNAME),CHAR_getChar( charaindex, CHAR_LOVERNAME)); + else + sprintf(tmp, "%s",CHAR_getChar( charaindex, CHAR_FMNAME)); +#else + sprintf(tmp, "%s",CHAR_getChar( charaindex, CHAR_FMNAME)); +#endif + else +#ifdef _ITEM_SETLOVER + if(strlen( CHAR_getChar( charaindex, CHAR_LOVE)) > 0 && + strlen(CHAR_getChar(charaindex,CHAR_LOVERID))>0 && + strlen(CHAR_getChar(charaindex,CHAR_LOVERNAME))>0) + sprintf(tmp, "♂%s♀",CHAR_getChar( charaindex, CHAR_LOVERNAME)); + else + strcpy(tmp, ""); +#else + strcpy(tmp, ""); +#endif + + // Robin 0730 + if( ridepet >= 0 ){ + if( ! strcmp( CHAR_getChar( ridepet, CHAR_USERPETNAME), "") ) + strcpy( petname, CHAR_getChar( ridepet, CHAR_NAME )); + else + strcpy( petname, CHAR_getChar( ridepet, CHAR_USERPETNAME )); + petlevel = CHAR_getInt( ridepet, CHAR_LV); + } +#ifdef _OBJSEND_C + #ifdef _CHAR_PROFESSION // WON ADD 人物职业 + #ifdef _ALLDOMAN // (不可开) Syu ADD 排行榜NPC + snprintf( buf, buflen, "%d|%d|%s|%d|%d|%d|%d|%d|%d|%s|%s|%d|%d|%d|%s|%s|%d|%d|%d|%d|%d", + #else + snprintf( buf, buflen, "%d|%d|%s|%d|%d|%d|%d|%d|%d|%s|%s|%d|%d|%d|%s|%s|%d|%d|%d|%d", + #endif + #else + snprintf( buf, buflen, "%d|%d|%s|%d|%d|%d|%d|%d|%d|%s|%s|%d|%d|%d|%s|%s|%d", + #endif + OBJTYPE_CHARA, +#else + #ifdef _GM_IDENTIFY + snprintf( buf, buflen, "%d|%s|%d|%d|%d|%d|%d|%d|%s|%s|%d|%d|%d|%s|%s|%d|%s", //多出了gm名称这个栏位 + #else + snprintf( buf, buflen, "%d|%s|%d|%d|%d|%d|%d|%d|%s|%s|%d|%d|%d|%s|%s|%d", + #endif +#endif + CHAR_getInt( charaindex, CHAR_WHICHTYPE), + cnv10to62( objindex,objindexbuf, sizeof(objindexbuf)), + OBJECT_getX(objindex), + OBJECT_getY(objindex), + CHAR_getInt( charaindex, CHAR_DIR), + CHAR_getInt( charaindex,CHAR_BASEIMAGENUMBER ), + CHAR_getInt( charaindex,CHAR_LV ), + namecolortbl[namecolor], + makeEscapeString( CHAR_getChar( charaindex,CHAR_NAME ), escapename, sizeof(escapename)), + makeEscapeString(CHAR_getChar(charaindex,CHAR_OWNTITLE), escapetitle,sizeof(escapetitle)), + CHAR_getFlg( charaindex,CHAR_ISOVERED ), + CHAR_getFlg( charaindex,CHAR_HAVEHEIGHT ), + CHAR_getInt( charaindex, CHAR_POPUPNAMECOLOR), + tmp, + makeEscapeString( petname, escapepetname, sizeof(escapepetname)), + petlevel +#ifdef _CHAR_PROFESSION // WON ADD 人物职业 + ,CHAR_getInt( charaindex, PROFESSION_CLASS) // 职业别 + ,CHAR_getInt( charaindex, PROFESSION_LEVEL) // 职业等级 +// ,CHAR_getInt( charaindex, PROFESSION_EXP) // 职业经验值 + ,CHAR_getInt( charaindex, PROFESSION_SKILL_POINT) // 技能点数 +#endif +#ifdef _ALLDOMAN // (不可开) Syu ADD 排行榜NPC + ,CHAR_getInt( charaindex, CHAR_HEROFLOOR ) // 英雄战场楼层 +#endif +#ifdef _GM_IDENTIFY + ,CHAR_getChar(charaindex, CHAR_GMIDENTIFY) //gm的名称 +#endif +#ifdef _PETSKILL_BECOMEPIG + // ,CHAR_getInt(charaindex, CHAR_BECOMEPIG) +#endif + ); + break; + } + case OBJTYPE_ITEM: + { + int itemindex = OBJECT_getIndex(objindex); + int nameint; + int leaklevel; + int color; + char bufbuf[256]; + char *temp; + leaklevel = ITEM_getInt( itemindex,ITEM_LEAKLEVEL ); + + nameint = ITEM_SECRETNAME; +// if( leaklevel >=1 ) { +// nameint = ITEM_SECRETNAME; +// }else { +// nameint = ITEM_NAME; +// } + color = CHAR_COLORWHITE; + if (ITEM_getChar( itemindex, ITEM_CDKEY) == NULL){ + return FALSE; + break; + } + temp=ITEM_getChar( itemindex, ITEM_CDKEY); + if( temp && strlen( temp ) ) { + color = CHAR_COLORGREEN; + }else { + if( ITEM_getInt( itemindex, ITEM_MERGEFLG) ) { + color = CHAR_COLORYELLOW; + } + } +#ifdef _OBJSEND_C + snprintf( buf, buflen, "%d|%s|%d|%d|%d|%d|%s", + OBJTYPE_ITEM, +#else + snprintf( buf, buflen, "%s|%d|%d|%d|%d|%s", +#endif + cnv10to62( objindex,objindexbuf, sizeof(objindexbuf)), + OBJECT_getX(objindex), OBJECT_getY(objindex), + ITEM_getInt( itemindex,ITEM_BASEIMAGENUMBER ), + color, + makeEscapeString( ITEM_getChar( itemindex,nameint), bufbuf, sizeof(bufbuf)) + ); + break; + } + case OBJTYPE_GOLD: +#ifdef _OBJSEND_C + snprintf( buf, buflen, "%d|%s|%d|%d|%d", + OBJTYPE_GOLD, +#else + snprintf( buf, buflen, "%s|%d|%d|%d", +#endif + cnv10to62( objindex,objindexbuf, sizeof(objindexbuf)), + OBJECT_getX(objindex),OBJECT_getY(objindex), + OBJECT_getIndex(objindex) ); + break; +#ifdef _OBJSEND_C +#ifdef _NPCSERVER_NEW + case OBJTYPE_NPCSCHARA: + { + char bufbuf[256]; + snprintf( buf, buflen, "%d|%s|%s|%d|%d|%d|%d", + OBJTYPE_NPCSCHARA, + cnv10to62( objindex,objindexbuf, sizeof(objindexbuf)), + makeEscapeString( OBJECT_getName( objindex), bufbuf, sizeof(bufbuf)), + OBJECT_getNpcdir( objindex), + OBJECT_getNpcImage( objindex), + OBJECT_getX(objindex), + OBJECT_getY(objindex)); + } + break; +#endif +#endif + default: + return FALSE; + break; + } + return TRUE; +} + +void CHAR_sendCSpecifiedObjindex( int fd, int index) +{ + char introduction[512]; + if( CHECKOBJECTUSE( index ) + && CHAR_makeObjectCString( index, introduction, + sizeof(introduction) ) ){ + lssproto_C_send( fd,introduction ); + }else{ + char mesg[32]; + cnv10to62( index, mesg, sizeof( mesg)); + lssproto_C_send( fd, mesg ); + } +} + +void CHAR_sendSpecifiedobjindexCToCharaindex(int charaindex,int objindex) +{ + int fd; + fd = getfdFromCharaIndex(charaindex); + if( fd == -1)return; + CHAR_sendCSpecifiedObjindex(fd,objindex); +} + +void CHAR_sendCToArroundCharacter( int objindex ) +{ + char introduction[512]; + int x,y,fl; + int i,j; + + if( CHAR_makeObjectCString( objindex,introduction, sizeof(introduction) ) == FALSE ) return; + + x = OBJECT_getX(objindex); + y = OBJECT_getY(objindex); + fl =OBJECT_getFloor(objindex); + + for( i = x - CHAR_DEFAULTSEESIZ/2 ; + i <= x +CHAR_DEFAULTSEESIZ/2 ; i ++ ){ + for( j = y - CHAR_DEFAULTSEESIZ/2; + j <= y + CHAR_DEFAULTSEESIZ/2; j ++ ){ + OBJECT object; + for( object = MAP_getTopObj( fl, i,j); + object; + object = NEXT_OBJECT(object) ){ + int objindexwk = GET_OBJINDEX( object); + if( OBJECT_getType(objindexwk) == OBJTYPE_CHARA ){ + int index = OBJECT_getIndex(objindexwk); + if( CHAR_getInt( index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + int fd; + if( CHAR_getWorkInt( index, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) continue; + fd = getfdFromCharaIndex( index); + if( fd == -1 )continue; + lssproto_C_send( fd,introduction ); + } + } + } + } + } +} + +void CHAR_sendCDArroundChar_Main( int fl, int x, int y, int objindex, BOOL mode ) +{ +#define CHAR_CDSEESIZ CHAR_DEFAULTSEESIZ+10 + + int i,j; + char cdmsg[64*2]; + cnv10to62( objindex,cdmsg, sizeof(cdmsg)); + for( i = x - CHAR_CDSEESIZ/2 ; i <= x +CHAR_CDSEESIZ/2 ; i ++ ){ + for( j = y - CHAR_CDSEESIZ/2; j <= y + CHAR_CDSEESIZ/2; j ++ ){ + OBJECT object; + for( object = MAP_getTopObj( fl, i,j); object; + object = NEXT_OBJECT(object) ){ + + int objindexwk = GET_OBJINDEX( object); + if( OBJECT_getType(objindexwk) == OBJTYPE_CHARA ){ + int index = OBJECT_getIndex( objindexwk); + if( CHAR_getInt( index,CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER) { + if( objindexwk != objindex ) { + int fd; + fd = getfdFromCharaIndex(index); + if( fd == -1 )continue; + if( CHAR_getWorkInt( index, CHAR_WORKBATTLEMODE) + == BATTLE_CHARMODE_NONE ) + { + CONNECT_appendCDbuf( fd, cdmsg, strlen( cdmsg)); + CDflush( index); + } + } + } + } + } + } + } +} + +void CHAR_sendCDArroundChar( int fl, int x, int y, int objindex ) +{ + CHAR_sendCDArroundChar_Main( fl,x,y,objindex,FALSE); +} + +void CHAR_sendArroundCharaData( int charaindex ) +{ + int fd; + int i,j,x, y,fl; + char introduction[512*2]; + char c_msg[1024*96]; + int strpos = 0; + char cabuf[128*2]; + fd = getfdFromCharaIndex( charaindex ); + if( fd == -1 )return; + c_msg[0] = '\0'; + fl = CHAR_getInt( charaindex, CHAR_FLOOR); + x = CHAR_getInt( charaindex, CHAR_X); + y = CHAR_getInt( charaindex, CHAR_Y); + + for( i = x-CHAR_DEFAULTSEESIZ/2 ; i <= x+CHAR_DEFAULTSEESIZ/2 ; i++ ){ + for( j = y-CHAR_DEFAULTSEESIZ/2 ; j <= y+CHAR_DEFAULTSEESIZ/2 ; j ++ ) { + OBJECT object; + for( object = MAP_getTopObj(fl,i,j) ; object ; object = NEXT_OBJECT(object ) ){ + int introlen; + int objindex = GET_OBJINDEX(object); + int c_index = OBJECT_getIndex( objindex); + + if( OBJECT_getType(objindex) == OBJTYPE_NOUSE ) continue; + if( OBJECT_getType(objindex) == OBJTYPE_CHARA && + !CHAR_getFlg(OBJECT_getIndex(objindex), CHAR_ISVISIBLE) ){ + continue; + } + if( OBJECT_getType( objindex) == OBJTYPE_CHARA) { + if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + /* 苇尹凶平乓仿互醮棉汹五及褪卅日壬伉□母□ 憎CA毛霜月 */ + if( CHAR_getWorkInt( c_index, CHAR_WORKPARTYMODE )== CHAR_PARTY_LEADER ){ + if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), CHAR_ACTLEADER,1 )) { + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + } + } + // Robin 0611 trade + /* 角色交易中 */ + if( CHAR_getWorkInt( c_index, CHAR_WORKTRADEMODE ) != CHAR_TRADE_FREE ) { + if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), CHAR_ACTTRADE,1 )){ + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + } + } + +#ifdef _ANGEL_SUMMON + if( CHAR_getWorkInt( c_index, CHAR_WORKANGELMODE ) == TRUE ) { + if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), CHAR_ACTANGEL,1 )){ + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + } + } +#endif + +#ifdef _MIND_ICON + //print("\nshan--->(batlmode)->%d", CHAR_getWorkInt( c_index, CHAR_WORKBATTLEMODE )); + if(CHAR_getWorkInt( c_index, CHAR_MIND_NUM) && + CHAR_getWorkInt( c_index, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE){ + if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), + CHAR_MIND, CHAR_getWorkInt( c_index, CHAR_MIND_NUM))){ + CONNECT_appendCAbuf( fd, cabuf, strlen(cabuf)); + //print("\nshan---->(1)cabuf-->%s", cabuf); + } + } +#endif + +#ifdef _STREET_VENDOR + if(CHAR_getWorkInt(c_index,CHAR_WORKSTREETVENDOR) == 1 && + CHAR_getWorkInt(c_index,CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE){ + if(CHAR_makeCAOPTString(objindex,cabuf,sizeof(cabuf), + CHAR_STREETVENDOR_OPEN,CHAR_getWorkChar(c_index,CHAR_STREETVENDOR_NAME))){ + CONNECT_appendCAbuf(fd,cabuf,strlen(cabuf)); + } + } +#endif + +#ifdef _ITEM_CRACKER + if(CHAR_getWorkInt( c_index, CHAR_WORKITEM_CRACKER)&& + CHAR_getWorkInt( c_index, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE) + { + if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), + CHAR_ITEM_CRACKER, CHAR_getWorkInt( c_index, CHAR_WORKITEM_CRACKER))) + { + CONNECT_appendCAbuf( fd, cabuf, strlen(cabuf)); + } + } +#endif + if( CHAR_getWorkInt( c_index, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ){ + if( CHAR_getWorkInt( c_index, CHAR_WORKBATTLEWATCH) == TRUE ) { + if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), CHAR_ACTBATTLEWATCH, 1)) { + CONNECT_appendCAbuf( fd, cabuf, strlen( cabuf)); + } + }else { + int battleno = CHAR_getWorkInt( c_index, CHAR_WORKBATTLEINDEX); + int sideno = CHAR_getWorkInt( c_index, CHAR_WORKBATTLESIDE); + int helpno = FALSE; + if( BATTLE_CHECKINDEX( battleno ) == FALSE ){ + }else { + helpno = (BattleArray[ battleno].Side[ + CHAR_getWorkInt( c_index, CHAR_WORKBATTLESIDE)].flg & BSIDE_FLG_HELP_OK)?TRUE:FALSE; + } + if( CHAR_makeCAOPT3String( objindex, cabuf, sizeof( cabuf), CHAR_ACTBATTLE, + battleno,sideno,helpno)){ + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + + } + } + } + if( CHAR_getWorkInt( c_index, CHAR_WORKACTION ) != -1 ) { + if( CHAR_makeCADefaultString( objindex, cabuf, sizeof( cabuf), + CHAR_getWorkInt( c_index, CHAR_WORKACTION))){ + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + + } + } + }else if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPET ) { + if( CHAR_getWorkInt( c_index, CHAR_WORKACTION ) != -1 ){ + if( CHAR_makeCADefaultString( objindex, cabuf, sizeof( cabuf), + CHAR_getWorkInt( c_index, CHAR_WORKACTION))){ + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + } + } + } +#ifdef _ADD_ACTION + else { //npc + + if( CHAR_CHECKINDEX( c_index) ) { + if( CHAR_getWorkInt( c_index, CHAR_WORKACTION ) > 0 ) { + if( CHAR_makeCADefaultString( objindex, cabuf, sizeof( cabuf), + CHAR_getWorkInt( c_index, CHAR_WORKACTION))) { + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + + } + } + } + } +#endif + } + if( c_index == charaindex) continue; + if( CHAR_makeObjectCString( objindex, introduction, sizeof( introduction))){ + introlen = strlen( introduction); + introduction[introlen] = ','; + introduction[introlen+1] = '\0'; + + strcpysafe( &c_msg[strpos], sizeof( c_msg) - strpos, + introduction); + strpos += strlen( introduction); + } + } + } + } + dchop( c_msg, "," ); + if( strlen( c_msg) == 0 ) return; + lssproto_C_send( fd, c_msg); +} + +BOOL _CHAR_warpToSpecificPoint( char *file, int line, int charaindex, int floor, int x, int y) +{ + int objindex; + int per; + objindex = CHAR_getWorkInt(charaindex,CHAR_WORKOBJINDEX); + if( !MAP_IsValidCoordinate( floor, x, y )) { + print( "error: invalid Coordinate fl[%d] x[%d] y[%d] %s:%d from %s:%d\n", + floor, x, y, __FILE__, __LINE__, file, line); + return FALSE; + } + CHAR_sendCDArroundChar_Main( OBJECT_getFloor(objindex), + OBJECT_getX(objindex), + OBJECT_getY(objindex), + objindex, TRUE ); + + CHAR_setInt( charaindex,CHAR_FLOOR,floor); + CHAR_setInt( charaindex,CHAR_X,x); + CHAR_setInt( charaindex,CHAR_Y,y); + { + int of,ox,oy; + of = OBJECT_setFloor(objindex,floor); + ox = OBJECT_setX(objindex,x); + oy = OBJECT_setY(objindex,y); + if( !MAP_objmove( objindex,of,ox,oy,floor,x,y ) ){ + fprint( "ERROR MAP_OBJMOVE objindex=%d\n",objindex ); + } + } + per = ENCOUNT_getEncountPercentMin( charaindex, floor,x,y); + if( per != -1 ) { + CHAR_setWorkInt( charaindex, CHAR_WORKENCOUNTPROBABILITY_MIN, per); + } + per = ENCOUNT_getEncountPercentMax( charaindex, floor,x,y); + if( per != -1 ) { + CHAR_setWorkInt( charaindex, CHAR_WORKENCOUNTPROBABILITY_MAX, per); + } + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + CHAR_setWorkInt( charaindex, CHAR_ENCOUNT_FIX, 0); +#endif + + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) { + CAflush( charaindex ); + { + int i; + char* statuscat[]={"C","E",}; + for( i=0 ; i -1) && (CHAR_CHECKINDEX( petindex )) ) + + CHAR_warpToSpecificPoint( petindex, floor, x, y ); + } +#ifdef _STATUS_WATERWORD //水世界状态 + if( MAP_getMapFloorType( floor) == 1 ){ + CHAR_setWorkInt( charaindex, CHAR_WORKMAPFLOORTYPE, 1); + }else { + CHAR_setWorkInt( charaindex, CHAR_WORKMAPFLOORTYPE, 0); + } +#endif +#ifdef _MAP_TIME + // 如果进入的地图是这些编号的话,设定倒数 + if(floor >= 30017 && floor <= 30021){ + if(CHAR_getWorkInt(charaindex,CHAR_WORK_MAP_TIME) <= 0) CHAR_setWorkInt(charaindex,CHAR_WORK_MAP_TIME,60); + } + // 如果进入正常的地图 + else CHAR_setWorkInt(charaindex,CHAR_WORK_MAP_TIME,0); +#endif + +#ifdef _ANGEL_SUMMON + if( CHAR_getWorkInt( charaindex, CHAR_WORKANGELMODE ) == TRUE ) { + CHAR_sendAngelMark( objindex, 1); + } +#endif + + }else if( OBJECT_getType( objindex) == OBJTYPE_CHARA ){ + MAP_sendArroundChar( charaindex ); + } + + return TRUE; +} + +static void CHAR_walk_check( int charaindex ) +{ + if( strlen( CHAR_getWorkChar( charaindex ,CHAR_WORKWALKARRAY ) ) != 0 ){ + struct timeval old; + old.tv_sec = CHAR_getWorkInt(charaindex,CHAR_WORKWALKSTARTSEC); + old.tv_usec = CHAR_getWorkInt(charaindex,CHAR_WORKWALKSTARTMSEC); + if( time_diff_us(NowTime,old) >= CHAR_getInt(charaindex,CHAR_WALKINTERVAL)*1000.0 ) { + CHAR_walkcall( charaindex ); + }else { + } + } +} + +static BOOL CHAR_callLoop( int charaindex ) +{ + unsigned int timediff_us; + struct timeval old; + int loopinterval, iRet = FALSE; + loopinterval = CHAR_getInt(charaindex,CHAR_LOOPINTERVAL); + if( loopinterval <= 0 )return FALSE; + + //print("\n CHAR_callLoop:%d", charaindex); + + old.tv_sec = CHAR_getWorkInt(charaindex,CHAR_WORKLOOPSTARTSEC); + old.tv_usec = CHAR_getWorkInt(charaindex,CHAR_WORKLOOPSTARTMSEC); + timediff_us = time_diff_us( NowTime , old ); + + if( timediff_us >= loopinterval*1000.0 ){ + int (*loopfunc)(int)=NULL; + loopfunc =(int(*)(int))CHAR_getFunctionPointer( charaindex, CHAR_LOOPFUNC); + if( loopfunc ){ + loopfunc(charaindex); + iRet = TRUE; + } +#ifdef _USER_CHARLOOPS + loopfunc =(int(*)(int))CHAR_getFunctionPointer( charaindex, CHAR_LOOPFUNCTEMP1); + if( loopfunc ){ + loopfunc(charaindex); + iRet = TRUE; + } +#endif + if( iRet == FALSE ){ + CHAR_setInt( charaindex, CHAR_LOOPINTERVAL, 0); + } + + CHAR_setWorkInt(charaindex,CHAR_WORKLOOPSTARTSEC, NowTime.tv_sec); + CHAR_setWorkInt(charaindex,CHAR_WORKLOOPSTARTMSEC, NowTime.tv_usec); + } + return iRet; +} + + +int EnemyMoveNum = 10; +void CHAR_Loop( void ) +{ + int charnum=CHAR_getCharNum(); + int playernum = CHAR_getPlayerMaxNum(); + int petnum = CHAR_getPetMaxNum(); + static int charcnt = 0; + int i, movecnt=0; + + + if( charcnt == -1 ) { + charcnt = CHAR_getCharNum(); + } + + // 玩家用的loop + for( i=0 ; i< playernum ; i++ ){ + if( CHAR_getCharUse(i) == FALSE )continue; + CHAR_walk_check( i ); + CHAR_callLoop( i ); +#ifdef _TEACHER_SYSTEM + // 有获得导师声望 + if(CHAR_getWorkInt(i,CHAR_WORK_GET_TEACHER_FAME) > 0){ + int iAddTFame = CHAR_getInt(i,CHAR_TEACHER_FAME) + CHAR_getWorkInt(i,CHAR_WORK_GET_TEACHER_FAME); + int iAddFame = CHAR_getInt(i,CHAR_FAME) + CHAR_getWorkInt(i,CHAR_WORK_GET_TEACHER_FAME); + + // 加导师声望(导师声望最大值和个人声望最大值一样) + if(iAddTFame > MAX_PERSONALFAME) iAddTFame = MAX_PERSONALFAME; + else if(iAddTFame < 0) iAddTFame = 0; + CHAR_setInt(i,CHAR_TEACHER_FAME,iAddTFame); + // 加声望 + if(iAddFame > MAX_PERSONALFAME) iAddFame = MAX_PERSONALFAME; + else if(iAddFame < 0) iAddFame = 0; + CHAR_setInt(i,CHAR_FAME,iAddFame); + // 清为 0 + CHAR_setWorkInt(i,CHAR_WORK_GET_TEACHER_FAME,0); + // 若有家族,上传给ac保持二边资料同步 + if(CHAR_getInt(i,CHAR_FMLEADERFLAG) > 0 && CHAR_getInt(i,CHAR_FMLEADERFLAG) != FMMEMBER_APPLY){ + char tmpbuf1[16]; + + sprintf(tmpbuf1,"%d",iAddFame); + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(i,CHAR_FMNAME), + CHAR_getInt(i,CHAR_FMINDEX), + CHAR_getWorkInt(i,CHAR_WORKFMINDEXI), + FM_FIX_FMFEED, + "0", // 只是为了同步资料,所以设为0,不动到家族的资料 + tmpbuf1, // 同步个人声望资料 + CHAR_getWorkInt(i,CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(getfdFromCharaIndex(i)) + ); + } + } +#endif + } + + // 玩家以外的Object用的loop + for( i = 0, movecnt = 0 ; i < (petnum/2) ; i++, charcnt++ ){ + if( charcnt >= charnum )charcnt = playernum ; + if( CHAR_getCharUse(charcnt) == FALSE )continue; + if( CHAR_callLoop(charcnt) == TRUE ){ + if( ++movecnt >= EnemyMoveNum )break; + } + } + +} + +char* CHAR_appendNameAndTitle( int charaindex, char* src, char* buf, + int buflen ) +{ + if( buflen > 0 ){ + if( CHAR_CHECKINDEX(charaindex) == FALSE ) + snprintf( buf,buflen,"%s",src ); + else{ + int titleindex = CHAR_getInt(charaindex,CHAR_INDEXOFEQTITLE); + if( titleindex == -1 ) + snprintf( buf,buflen, "%s:%s", + CHAR_getChar(charaindex,CHAR_NAME), src ); + else + snprintf( buf,buflen, "%s(%s):%s", + CHAR_getChar(charaindex,CHAR_NAME), + TITLE_makeTitleStatusString(charaindex, + titleindex), src ); + } + } + return buf; +} + +void CHAR_getCoordinationDir( int dir , int x, int y ,int c, + int *xout , int *yout ) +{ + *xout = x + CHAR_getDX(dir) * c; + *yout = y + CHAR_getDY(dir) * c; +} + +BOOL CHAR_createCharacter( int type, int floor, int x, int y,int dir, + int* charaindex, int* objindex, BOOL seemap ) +{ + Char ch; + Object ob; + if( !CHAR_getDefaultChar( &ch,type ) )return FALSE; + + ch.data[CHAR_FLOOR] = floor; + ch.data[CHAR_X] = x; + ch.data[CHAR_Y] = y; + ch.data[CHAR_DIR] = dir; + + *charaindex = CHAR_initCharOneArray( &ch ); + if( *charaindex == -1 )return FALSE; + + ob.type = OBJTYPE_CHARA; + ob.index = *charaindex; + ob.floor = floor; + ob.x = x; + ob.y = y; + + if( seemap && MAP_walkAble( *charaindex, floor,x,y ) == FALSE ){ + CHAR_endCharOneArray( *charaindex ); + return FALSE; + } + + *objindex = initObjectOne( &ob ); + if( *objindex == -1 ){ + CHAR_endCharOneArray(*charaindex); + return FALSE; + } + CHAR_setWorkInt( *charaindex,CHAR_WORKOBJINDEX,*objindex); + + /* 生永玄伐□弁毛垫丹 */ + + CHAR_sendWatchEvent( *objindex,CHAR_ACTSTAND,NULL,0,TRUE); + + return TRUE; +} + +void CHAR_ObjectDelete( int objindex ) +{ + CHAR_sendCDArroundChar( OBJECT_getFloor(objindex), + OBJECT_getX(objindex), + OBJECT_getY(objindex), + objindex ); +#ifdef _MAP_WARPPOINT + if( OBJECT_getType( objindex) == OBJTYPE_WARPPOINT ){ + print("Delete OBJTYPE_WARPPOINT endObjectOne( %d) [%d,%d,%d] \n ", objindex, + OBJECT_getFloor(objindex), OBJECT_getX(objindex), + OBJECT_getY(objindex) ); + } +#endif + endObjectOne(objindex); +} + +/*------------------------------------------------------------ + * 平乓仿毛绰轮允月[左皮斥尼弁玄手绰轮允月[ + * 生永玄伐□弁及支曰酸仄毛卅仁允凶户及手及 + * 娄醒 + * charaindex int 平乓仿奶件犯永永弁旦 + * 忒曰袄 + * 卅仄 + ------------------------------------------------------------*/ +void CHAR_CharaDelete( int charaindex ) +{ + /* 左皮斥尼弁玄毛绰轮 */ + CHAR_ObjectDelete( CHAR_getWorkInt( charaindex,CHAR_WORKOBJINDEX ) ); + /* 平乓仿及绰轮 */ + CHAR_endCharOneArray( charaindex ); +} +/*------------------------------------------------------------ + * 皿伊奶乩□及 匀化中月矢永玄毛壅允 + ------------------------------------------------------------*/ +void CHAR_CharaDeleteHavePet( int charaindex) +{ + int i; + int pindex; + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + pindex = CHAR_getCharPet( charaindex, i); + if( CHAR_CHECKINDEX( pindex)) { + CHAR_endCharOneArray( pindex ); + } + } + for( i = 0; i < CHAR_MAXPOOLPETHAVE; i ++ ) { + pindex = CHAR_getCharPoolPet( charaindex, i); + if( CHAR_CHECKINDEX( pindex)) { + CHAR_endCharOneArray( pindex ); + } + } +} +/*------------------------------------------------------------ + * 减变升啼卅升毛 蜇允月[ + * mode int 0: 愤坌卞反CA霜日卅中 + * 1: 愤坌卞手CA霜月 + ------------------------------------------------------------*/ +int CHAR_sendAction( int charaindex, int action, int mode) +{ + /* 霜日木化 凶失弁扑亦件午CA毛域谯今六月 □皮伙 */ + static int table[] = { + CHAR_ACTATTACK,CHAR_ACTDAMAGE,CHAR_ACTDOWN,CHAR_ACTACTIONSTAND, + CHAR_ACTACTIONWALK,CHAR_ACTSIT,CHAR_ACTHAND,CHAR_ACTPLEASURE, + CHAR_ACTANGRY,CHAR_ACTSAD,CHAR_ACTGUARD, CHAR_ACTNOD, CHAR_ACTTHROW + }; + if( action < 0 || action >= arraysizeof( table)) return FALSE; + + /* 璃曰卞失弁扑亦件毛霜耨允月 */ + CHAR_sendWatchEvent( + CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), + table[action], + NULL,0,mode); + + /* 失弁扑亦件及瓒 */ + CHAR_setWorkInt( charaindex, CHAR_WORKACTION, table[action]); + + return TRUE; +} +/*------------------------------------------------------------ + * 愤坌互爵 匹丐月午中丹仪毛霜耨允月[ + ------------------------------------------------------------*/ +void CHAR_sendBattleEffect( int charaindex, int onoff) +{ + int opt[3]; + + if( onoff == 1) { + opt[0] = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX); + opt[1] = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLESIDE); + opt[2] = (BattleArray[CHAR_getWorkInt( charaindex, + CHAR_WORKBATTLEINDEX)].Side[ + CHAR_getWorkInt( charaindex, + CHAR_WORKBATTLESIDE)].flg & BSIDE_FLG_HELP_OK) ? TRUE:FALSE; + } + else { + opt[0] = -1; + opt[1] = -1; + opt[2] = 0; + } + + CHAR_sendWatchEvent( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), + CHAR_ACTBATTLE,opt,arraysizeof(opt),TRUE); +} + +/*------------------------------------------------------------ + * 交易中传送讯息 add code Shan 2001/06/30 + ------------------------------------------------------------*/ +void CHAR_sendTradeEffect( int charaindex, int onoff) +{ + int opt[1]; + + if( onoff == 1) { + opt[0] = 1; + } + else { + opt[0] = -1; + } + CHAR_sendWatchEvent( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), + CHAR_ACTTRADE,opt,arraysizeof(opt),TRUE); +} + +#ifdef _ANGEL_SUMMON +void CHAR_sendAngelEffect( int charaindex, int onoff) +{ + int opt[1]; + + if( onoff == 1) { + opt[0] = 1; + } + else { + opt[0] = -1; + } + CHAR_sendWatchEvent( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), + CHAR_ACTANGEL,opt,arraysizeof(opt),TRUE); +} +#endif + +#ifdef _MIND_ICON +void CHAR_sendMindEffect( int charaindex, int onoff) +{ + int opt[1]; + + if(onoff>0){ + opt[0] = onoff; + } + else{ + opt[0] = 0; + } + CHAR_sendWatchEvent( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), + CHAR_MIND, opt, arraysizeof(opt), FALSE); +} +#endif +#ifdef _ITEM_CRACKER +void CHAR_sendCrackerEffect( int charaindex, int onoff) +{ + int opt[1]; + opt[0] = onoff; + CHAR_sendWatchEvent( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), + CHAR_ITEM_CRACKER, opt, arraysizeof(opt), FALSE); +} +#endif + +void CHAR_inputUserPetName( int index , int havepetindex, char* name ) +{ + int petindex; + //char category[3]; + char *mycdkey=NULL, *cdkey = NULL; + BOOL changenameflg = FALSE; + + if( !CHAR_CHECKINDEX( index ) ) return; + + petindex = CHAR_getCharPet( index, havepetindex); + if( !CHAR_CHECKINDEX( petindex)) return; + + if (CHAR_getInt(petindex, CHAR_PETFAMILY) == 1){ + CHAR_talkToCli(index, -1, "家族守护兽无法修改名字!", CHAR_COLORYELLOW); + return; + } + + mycdkey = CHAR_getChar( index, CHAR_CDKEY); + cdkey = CHAR_getChar( petindex, CHAR_CDKEY); + if( cdkey == NULL ) { + print( "can't get CDKEY\n"); + }else { + if( strlen( cdkey) == 0 || strcmp( cdkey, mycdkey) == 0 ) { + changenameflg = TRUE; + } + } + if( !changenameflg) { + CHAR_talkToCli( index, -1, "无法为宠物命名。", CHAR_COLORYELLOW ); + return; + } + + CHAR_setChar( petindex, CHAR_USERPETNAME ,name); + + if( strlen( name ) == 0 || + strcmp( CHAR_getChar( petindex, CHAR_NAME), name) == 0 ){ + CHAR_setChar( petindex, CHAR_CDKEY, ""); + }else { + CHAR_setChar( petindex, CHAR_CDKEY, mycdkey); + } + CHAR_send_K_StatusString( index, havepetindex, CHAR_K_STRING_USERPETNAME); +} + +static void CHAR_setLuck( int charaindex) +{ + LSTIME nowlstime; + LSTIME mylstime; + struct { + int prob; + int luck; + }lucktbl[] = { + { 60, 1 }, /* 40% */ + { 30, 2 }, /* 30% */ + { 10, 3 }, /* 20% */ + { 3, 4 }, /* 7% */ + { 0, 5 } /* 3% */ + }; + + if( !CHAR_CHECKINDEX( charaindex)) return; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER) return; + + RealTimeToLSTime( NowTime.tv_sec, &nowlstime); + RealTimeToLSTime( CHAR_getInt( charaindex, CHAR_LASTTIMESETLUCK), &mylstime); + + /* LS凛棉匹ㄠ 动晓烦匀化中木壬CHAR_LUCK毛凳蕙允月 */ + if( nowlstime.day != mylstime.day || nowlstime.year != mylstime.year ) { + int i,r; + r = RAND( 0, 99); + for( i = 0; i < arraysizeof( lucktbl); i ++ ) { + if( r >= lucktbl[i].prob ) { + CHAR_setInt( charaindex, CHAR_LUCK, lucktbl[i].luck); + CHAR_setInt( charaindex, CHAR_LASTTIMESETLUCK, NowTime.tv_sec); + return; + } + } + } +} +void CHAR_JoinBattle_WindowResult( int charaindex, int select, char *data) +{ + int ret = FALSE; + int fd = getfdFromCharaIndex( charaindex); + +#if 1 // 修正利用参战重复加入战斗 Robin + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) { + CHAR_talkToCli( charaindex, -1, " 重复加入战斗! ", CHAR_COLORRED); + print("\n 改封包!!重复加入战斗!:%s ", CHAR_getChar( charaindex, CHAR_CDKEY) ); + //lssproto_EN_send( fd, FALSE, 0 ); + return; + } +#endif + if( select != WINDOW_BUTTONTYPE_CANCEL && + CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_NONE ){ + while( 1 ) { + int selected; + int bcharaindex; + if( fd == -1 ) break; + selected = atoi( data)-1; + + if( !CHAR_CHECKINDEX( CONNECT_getBattlecharaindex(fd,selected))) { + break; + } + if( CHAR_getWorkInt( CONNECT_getBattlecharaindex(fd,selected), + CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE){ + break; + } + if( BattleArray[ CHAR_getWorkInt( + CONNECT_getBattlecharaindex( fd,selected), + CHAR_WORKBATTLEINDEX)].type != BATTLE_TYPE_P_vs_E ){ + break; + } + bcharaindex = CONNECT_getBattlecharaindex( fd,selected); + if( !(BattleArray[CHAR_getWorkInt( bcharaindex, + CHAR_WORKBATTLEINDEX)].Side[ + CHAR_getWorkInt( bcharaindex, + CHAR_WORKBATTLESIDE)].flg + & BSIDE_FLG_HELP_OK)){ + break; + } + if(NPC_Util_CharDistance( charaindex, + CONNECT_getBattlecharaindex( + fd,selected) )> 1){ + break; + } + if( BATTLE_RescueEntry( charaindex, + CONNECT_getBattlecharaindex(fd,selected) )){ + CHAR_talkToCli( charaindex, -1, "无法参战。", + CHAR_COLORYELLOW); + }else { + ret = TRUE; + } + + break; + } + } + if( ret == FALSE ) { + if( fd != -1 ) { + lssproto_EN_send( fd, FALSE, 0 ); + } + } +} +void CHAR_JoinDuel_WindowResult( int charaindex, int select, char *data) +{ + int ret = FALSE; + int fd = getfdFromCharaIndex( charaindex); + /* 手丹域蘸民尼永弁允月 */ + if( select != WINDOW_BUTTONTYPE_CANCEL && + CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_CLIENT ) + { + /* 生旦玄互丹匀午云仄中及匹ㄠ蘸分仃伙□皿毛银丹 */ + while( 1 ) { + int selected; + int enemyindex; + + if( fd == -1 ) break; + selected = atoi( data)-1; + /* 躲卅index井 */ + if( !CHAR_CHECKINDEX( CONNECT_getDuelcharaindex(fd,selected)) ) { + break; + } + /* 爵 井升丹井 */ + if( CHAR_getWorkInt( CONNECT_getDuelcharaindex(fd,selected), + CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) + { + break; + } + /* duel第井 */ + if( !CHAR_getFlg( CONNECT_getDuelcharaindex(fd,selected), + CHAR_ISDUEL)) + { + break; + } + /* ㄠ汹动 卞中月井(它奴件玉它匹 中宁歹六仄化月棉卞 仃月啃) */ + if(NPC_Util_CharDistance( charaindex, + CONNECT_getDuelcharaindex(fd,selected) ) + > 1) + { + break; + } + // 及蟆及平乓仿及奶件犯永弁旦 + enemyindex = CONNECT_getDuelcharaindex( fd,selected); + // 锹澎互褪卅日公及引引巨件市它件玄今六月互 + // 阂间卅日褪毛裟氏匹仁月 + if( CHAR_getWorkInt( enemyindex, CHAR_WORKPARTYMODE ) + == CHAR_PARTY_CLIENT ) + { + enemyindex = CHAR_getWorkInt( enemyindex, CHAR_WORKPARTYINDEX1 ); + // 卅兮井褪互中卅中 + if( enemyindex < 0 ) break; + } + /* 锹澎互皿伊奶乩□匹卅中仪手丐月 */ + if( CHAR_getWorkInt( enemyindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER){ + break; + } + ret = BATTLE_CreateVsPlayer( charaindex, enemyindex ); + if( ret != 0 ){ + CHAR_talkToCli( charaindex, -1, + "遭遇失败!", CHAR_COLORYELLOW); + ret = FALSE; + } + else { + ret = TRUE; + } + break; + } + } + if( ret == FALSE ) { + /* 瑛绊霜耨 */ + if( fd != -1 ) { + lssproto_EN_send( fd, FALSE, 0 ); + } + } +} +void CHAR_SelectCard_WindowResult( int charaindex, int select, char *data) +{ + if( select != WINDOW_BUTTONTYPE_CANCEL ){ + while( 1 ) { + int selected; + int fd; + fd = getfdFromCharaIndex( charaindex); + if( fd == -1 ) break; + selected = atoi( data)-1; + if( !CHAR_CHECKINDEX( + CONNECT_getTradecardcharaindex(fd,selected))) { + break; + } + if( CHAR_getWorkInt( CONNECT_getTradecardcharaindex(fd,selected), + CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE){ + break; + } + if(!CHAR_getFlg( CONNECT_getTradecardcharaindex(fd,selected), + CHAR_ISTRADECARD)){ + break; + } + if( NPC_Util_CharDistance( charaindex, + CONNECT_getTradecardcharaindex + (fd,selected) ) > 1){ + break; + } + ADDRESSBOOK_addAddressBook( charaindex, + CONNECT_getTradecardcharaindex( + fd,selected)); + break; + } + } +} + +void CHAR_JoinParty_WindowResult( int charaindex , int select, char *data) +{ + int ret = FALSE; + int fd = getfdFromCharaIndex( charaindex); + /* 手丹域蘸民尼永弁允月 */ + if( select != WINDOW_BUTTONTYPE_CANCEL && + /* 愤坌互由□ 奴赚氏匹凶日蛲 */ + CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_NONE ) + { + /* 生旦玄互丹匀午云仄中及匹ㄠ蘸分仃伙□皿毛银丹 */ + while( 1 ) { + int parray; + int selected; + int toindex = -1; + if( fd == -1 ) break; + selected = atoi( data)-1; + + /* 躲卅index井 + * (褐邰“它奴件玉它匹 中宁歹六仄化月棉卞 + * 躲卅index卞卅月第 岭互丐月) + */ + if( !CHAR_CHECKINDEX( + CONNECT_getJoinpartycharaindex(fd,selected))) { + break; + } + /* 褪互中凶日娄匀舰曰请允 */ + if( CHAR_getWorkInt( CONNECT_getJoinpartycharaindex( + fd,selected), CHAR_WORKPARTYMODE) + == CHAR_PARTY_NONE ) + { + toindex = CONNECT_getJoinpartycharaindex( fd,selected ); + } + else { + toindex = CHAR_getPartyIndex( + CONNECT_getJoinpartycharaindex(fd,selected), 0); + if( !CHAR_CHECKINDEX( toindex) ) { + print( " %s:%d err\n", __FILE__, __LINE__); + break; + } + } + /* ㄠ汹动 卞中月井(它奴件玉它匹 中宁歹六仄化月棉卞 仃月啃) */ + if( NPC_Util_CharDistance( charaindex, toindex ) > 1) { + break; + } + /* 爵 反分户 */ + if( CHAR_getWorkInt( toindex, CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) + { + break; + } + /* 醮棉袱第乒□玉井 */ + if( !CHAR_getFlg( toindex, CHAR_ISPARTY)) { + break; + } + + /* 锹澎由□ 奴及谛醒反 井" */ + parray = CHAR_getEmptyPartyArray( toindex) ; + if( parray == -1 ) break; + +#ifdef _DEATH_CONTEND + if(CHAR_getInt(toindex,CHAR_PKLISTTEAMNUM) == -1 && CHAR_getInt(charaindex,CHAR_PKLISTTEAMNUM) == -1){ + }else if(CHAR_getInt(charaindex,CHAR_PKLISTLEADER) > 0 || + CHAR_getInt(toindex, CHAR_PKLISTTEAMNUM) < 0 || + CHAR_getInt(charaindex, CHAR_PKLISTTEAMNUM) < 0 || + CHAR_getInt(toindex,CHAR_PKLISTTEAMNUM) != CHAR_getInt(charaindex,CHAR_PKLISTTEAMNUM) || + CHAR_getInt(toindex,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER){ + CHAR_talkToCli( charaindex, -1, "队伍不同,无法加入团队。", CHAR_COLORYELLOW); + ret = FALSE; + break; + } +#endif + + /* 由□ 奴卞 日六月 */ + CHAR_JoinParty_Main( charaindex, toindex); + + ret = TRUE; + + break; + } + } + if( ret == FALSE ) { + CHAR_talkToCli( charaindex, -1, "无法加入团队。", + CHAR_COLORYELLOW); + } + /* 瑛绊霜耨 */ + if( fd != -1 ) { + lssproto_PR_send( fd, 1, ret); + } +} +void CHAR_JoinBattleWatch_WindowResult( int charaindex, int select, char *data) +{ + int ret = FALSE; + int fd = getfdFromCharaIndex( charaindex); + /* 手丹域蘸民尼永弁允月 */ + if( select != WINDOW_BUTTONTYPE_CANCEL ) { + /* 生旦玄互丹匀午云仄中及匹ㄠ蘸分仃伙□皿毛银丹 */ + while( 1 ) { + int selected; + if( fd == -1 ) break; + selected = atoi( data)-1; + + /* 躲卅index井 + * (褐邰“它奴件玉它匹 中宁歹六仄化月棉卞 + * 躲卅index卞卅月第 岭互丐月) + */ + if( !CHAR_CHECKINDEX( CONNECT_getBattlecharaindex(fd,selected))) { + break; + } + /* 爵 井升丹井 */ + if( CHAR_getWorkInt( CONNECT_getBattlecharaindex(fd,selected), + CHAR_WORKBATTLEMODE) + == BATTLE_CHARMODE_NONE) + { + break; + } + /* ㄠ汹动 卞中月井(它奴件玉它匹 中宁歹六仄化月棉卞 仃月啃) */ + if(NPC_Util_CharDistance( charaindex, + CONNECT_getBattlecharaindex( + fd,selected) ) + > 1) + { + break; + } + /* 巨件玄伉□今六月 */ + if( BATTLE_WatchEntry( charaindex, + CONNECT_getBattlecharaindex(fd,selected) + )) + { + CHAR_talkToCli( charaindex, -1, "无法观战。", + CHAR_COLORYELLOW); + } + else { + ret = TRUE; + } + + break; + } + } + if( ret == FALSE ) { + /* 瑛绊霜耨 */ + if( fd != -1 ) { + lssproto_EN_send( fd, FALSE, 0 ); + } + } +} + +#ifdef _FM_MODIFY +extern void NPC_FmDengonWindowTalked( int index, int talker, int seqno, int select, char *data); +#endif + +void CHAR_processWindow(int charaindex, int seqno, int select, + int objindex, char* data ) +{ + if( CHECKOBJECTUSE(objindex)) { + if( OBJECT_getType(objindex) == OBJTYPE_CHARA ) { + typedef void (*WINDF)(int,int,int, int,char*); + WINDF windowtalkedfunc=NULL; + windowtalkedfunc = (WINDF)CHAR_getFunctionPointer( + OBJECT_getIndex(objindex),CHAR_WINDOWTALKEDFUNC); + if( windowtalkedfunc ) { + windowtalkedfunc( OBJECT_getIndex(objindex), charaindex, + seqno, select, data); + } + } +#ifdef _NPCSERVER_NEW //CHAR_WINDOWTALKEDFUNC + else if( OBJECT_getType(objindex) == OBJTYPE_NPCSCHARA ) { + int npcindex = OBJECT_getNpcIndex( objindex); + if( npcfd != -1 ) + NPCS_NpcWinMess_send( objindex, npcindex, charaindex, data, seqno, select); + } +#endif + }else { + if( seqno == CHAR_WINDOWTYPE_SELECTBATTLE) { + CHAR_JoinBattle_WindowResult( charaindex, select, data); + }else if( seqno == CHAR_WINDOWTYPE_SELECTDUEL) { + CHAR_JoinDuel_WindowResult( charaindex, select, data); + }else if( seqno == CHAR_WINDOWTYPE_SELECTTRADECARD) { + CHAR_SelectCard_WindowResult( charaindex, select, data); + }else{ + if( seqno == CHAR_WINDOWTYPE_SELECTPARTY) { + CHAR_JoinParty_WindowResult( charaindex, select, data); + }else { + if( seqno == CHAR_WINDOWTYPE_SELECTBATTLEWATCH) { + CHAR_JoinBattleWatch_WindowResult( charaindex, select, data); + }else if( seqno >= CHAR_WINDOWTYPE_SELECTRENAMEITEM_PAGE1 && + seqno <= CHAR_WINDOWTYPE_SELECTRENAMEITEM_RENAME_ATTENTION ){ + ITEM_useRenameItem_WindowResult( charaindex, seqno, select, data); + } +#ifdef _PETSKILL_CANNEDFOOD + else if( seqno == ITEM_WINDOWTYPE_SELECTPETSKILL_SELECT ){ + ITEM_usePetSkillCanned_WindowResult( charaindex, seqno, select, data); + } +#endif + } + } +#ifdef _FM_MODIFY + if(seqno >= CHAR_WINDOWTYPE_FM_DENGON || seqno <= CHAR_WINDOWTYPE_FM_DPSELECT) + NPC_FmDengonWindowTalked(0,charaindex,seqno,select,data); +#endif + } +} + +void CHAR_PartyUpdate( int charaindex, int senddata ){ + int i, ownerindex, mode, pindex, pno; + mode = CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE ); + if( mode == CHAR_PARTY_NONE )return; + if( mode == CHAR_PARTY_LEADER ){ + ownerindex = charaindex; + }else{ + ownerindex = CHAR_getWorkInt( charaindex, CHAR_WORKPARTYINDEX1 ); + } + + for( pno = 0; pno < CHAR_PARTYMAX; pno ++ ){ + pindex = CHAR_getWorkInt( ownerindex, CHAR_WORKPARTYINDEX1+pno ); + if( pindex == charaindex )break; + } + if( pno == CHAR_PARTYMAX )return; + for( i = 0; i < CHAR_PARTYMAX; i ++ ){ + pindex = CHAR_getWorkInt( ownerindex, CHAR_WORKPARTYINDEX1+i ); + if( pindex == charaindex )continue; + if( pindex < 0 )continue; + CHAR_send_N_StatusString( pindex, pno, senddata ); + } +} + +static int CHAR_getObjectByPosition( int myobjindex, int fl, int x, int y, + int *objbuf, int objbuflen) +{ + int i,j; + int cnt = 0; + + for( i = x-CHAR_DEFAULTSEESIZ/2 ; i <= x+CHAR_DEFAULTSEESIZ/2 ; i++ ){ + for( j = y-CHAR_DEFAULTSEESIZ/2 ; j <= y+CHAR_DEFAULTSEESIZ/2 ; + j ++ ) + { + OBJECT object; + for( object = MAP_getTopObj(fl,i,j) ; + object ; + object = NEXT_OBJECT(object ) ) + { + int objindex = GET_OBJINDEX(object); + if( OBJECT_getType(objindex) == OBJTYPE_NOUSE ) continue; + if( OBJECT_getType( objindex) == OBJTYPE_CHARA && + !CHAR_getFlg( OBJECT_getIndex( objindex), CHAR_ISVISIBLE)) + { + continue; + } + /* 愤坌反中中方 */ + if( objindex == myobjindex) continue; + + objbuf[cnt] = objindex; + cnt ++; + if( cnt >= objbuflen) return cnt; + } + } + } + return cnt; +} +static void CHAR_setMyPosition_sendData( int charaindex,int prev_x, int prev_y, int x, int y) +{ + int CurrentObjCollection[CHAR_DEFAULTSEESIZ*CHAR_DEFAULTSEESIZ*10]; + int PrevObjCollection[CHAR_DEFAULTSEESIZ*CHAR_DEFAULTSEESIZ*10]; + int curcnt,prevcnt; + int objindex; + int fl; + char introduction[512]; + char c_msg[1024*96]; + char buf[64]; + int strpos; + int fd; + int i,j; + char cabuf[128]; + char myintroduction[512]; + char cd_msg[128]; + + fd = CHAR_getWorkInt( charaindex, CHAR_WORKFD); + if( fd == -1 )return; + + objindex = CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX); + fl = CHAR_getInt( charaindex, CHAR_FLOOR); + + curcnt = CHAR_getObjectByPosition( objindex, fl,x,y, CurrentObjCollection, sizeof(CurrentObjCollection)); + prevcnt = CHAR_getObjectByPosition( objindex, fl, prev_x, prev_y, PrevObjCollection, sizeof(PrevObjCollection)); + strpos = 0; + c_msg[0] = '\0'; + if( !CHAR_makeObjectCString( objindex, myintroduction,sizeof( myintroduction))){ + myintroduction[0] = '\0'; + } + + for( i = 0 ; i < curcnt; i ++ ) { + int findflg = FALSE; + for( j = 0; j < prevcnt; j ++ ) { + if( CurrentObjCollection[i] == PrevObjCollection[j] ) { + findflg = TRUE; + break; + } + } + if( !findflg ) { + int introlen; + int c_index = OBJECT_getIndex( CurrentObjCollection[i]); + if( CHAR_makeObjectCString( CurrentObjCollection[i], introduction, + sizeof( introduction))) + { + introlen = strlen( introduction); + introduction[introlen] = ','; + introduction[introlen+1] = '\0'; + + strcpysafe( &c_msg[strpos], sizeof( c_msg) - strpos, + introduction); + strpos += strlen( introduction); + if( strpos >= sizeof( c_msg)) break; + } + if( strlen( myintroduction) != 0 ) { + if( OBJECT_getType( CurrentObjCollection[i] ) == OBJTYPE_CHARA ) { + if( CHAR_getInt( c_index, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + int tofd = getfdFromCharaIndex( c_index ); + CDsend( tofd); + lssproto_C_send( tofd, myintroduction); + } + } + } + if( OBJECT_getType( CurrentObjCollection[i]) == OBJTYPE_CHARA ) { + if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && + CHAR_getWorkInt( c_index, CHAR_WORKPARTYMODE ) + == CHAR_PARTY_LEADER ){ + if( CHAR_makeCAOPT1String( CurrentObjCollection[i], cabuf, sizeof( cabuf), + CHAR_ACTLEADER,1 )){ + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + } + } + + // Robin 0611 trade + /* 角色交易中 */ + if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && + CHAR_getWorkInt( c_index, CHAR_WORKTRADEMODE ) != CHAR_TRADE_FREE ) { + if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), CHAR_ACTTRADE,1 )) + { + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + } + } + +#ifdef _ANGEL_SUMMON + if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && + CHAR_getWorkInt( c_index, CHAR_WORKANGELMODE ) == TRUE ) { + if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), CHAR_ACTANGEL,1 )) + { + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + } + } +#endif + +#ifdef _MIND_ICON + if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && + CHAR_getWorkInt( c_index, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE && + CHAR_getWorkInt( c_index, CHAR_MIND_NUM)) + { + if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), + CHAR_MIND, CHAR_getWorkInt( c_index, CHAR_MIND_NUM))) + { + CONNECT_appendCAbuf( fd, cabuf, strlen( cabuf)); + //print("\nshan---->(2)cabuf-->%s", cabuf); + } + } +#endif +#ifdef _STREET_VENDOR + if(CHAR_getWorkInt(c_index,CHAR_WORKSTREETVENDOR) == 1 && + CHAR_getWorkInt(c_index,CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE){ + if(CHAR_makeCAOPTString(objindex,cabuf,sizeof(cabuf), + CHAR_STREETVENDOR_OPEN,CHAR_getWorkChar(c_index,CHAR_STREETVENDOR_NAME))) + CONNECT_appendCAbuf(fd,cabuf,strlen(cabuf)); + } +#endif +#ifdef _ITEM_CRACKER + if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && + CHAR_getWorkInt( c_index, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE && + CHAR_getWorkInt( c_index, CHAR_WORKITEM_CRACKER)) + { + if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), + CHAR_ITEM_CRACKER, CHAR_getWorkInt( c_index, CHAR_WORKITEM_CRACKER))) + { + CONNECT_appendCAbuf( fd, cabuf, strlen( cabuf)); + } + } +#endif + /* 愤坌互褪匹锹澎互爵 匹卅中卅日锹澎卞伉□母□ 憎CA毛霜月 */ + if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && + CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE ) + == CHAR_PARTY_LEADER && + CHAR_getWorkInt( c_index, CHAR_WORKBATTLEMODE) + == BATTLE_CHARMODE_NONE) + { + int tofd = getfdFromCharaIndex( c_index ); + if( tofd != -1 ) { + if( CHAR_makeCAOPT1String( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), + cabuf, sizeof( cabuf), + CHAR_ACTLEADER,1 )) + { + CONNECT_appendCAbuf( tofd,cabuf,strlen(cabuf)); + } + } + } + /* 苇尹凶平乓仿互爵 卅日爵 失奶戊件 憎 毛霜月 */ + if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && + CHAR_getWorkInt( c_index, CHAR_WORKBATTLEMODE ) + != BATTLE_CHARMODE_NONE ) + { + /* 棋爵CA */ + if( CHAR_getWorkInt( c_index, CHAR_WORKBATTLEWATCH) == TRUE ) { + if( CHAR_makeCAOPT1String( CurrentObjCollection[i], cabuf, + sizeof( cabuf), + CHAR_ACTBATTLEWATCH, + 1)) + { + CONNECT_appendCAbuf( fd, cabuf, strlen( cabuf)); + } + } + else { + int battleno = CHAR_getWorkInt( c_index, + CHAR_WORKBATTLEINDEX); + int sideno = CHAR_getWorkInt( c_index, + CHAR_WORKBATTLESIDE); + int helpno = (BattleArray[CHAR_getWorkInt( c_index, + CHAR_WORKBATTLEINDEX)].Side[ + CHAR_getWorkInt( c_index, + CHAR_WORKBATTLESIDE)].flg & BSIDE_FLG_HELP_OK) ? TRUE:FALSE; + /* HelpNo = 1 反移 */ + if( CHAR_makeCAOPT3String( CurrentObjCollection[i], cabuf, sizeof( cabuf), + CHAR_ACTBATTLE, + battleno,sideno,helpno + )) + { + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + } + } + } + /* 苇尹凶平乓仿互窒井及失弁扑亦件毛仄化中木壬霜月[ */ + if( ( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER || + CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPET ) && + CHAR_getWorkInt( c_index, CHAR_WORKACTION ) != -1 ) + { + if( CHAR_makeCADefaultString( CurrentObjCollection[i], cabuf, sizeof( cabuf), + CHAR_getWorkInt( c_index, CHAR_WORKACTION))) + { + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + } + } + } + } + } + dchop( c_msg, "," ); + if( strlen( c_msg) != 0 ) { + lssproto_C_send( fd, c_msg); + } + + /* 愤坌及CD综岳 */ + cnv10to62( objindex,cd_msg, sizeof(cd_msg)); + + for( i = 0 ; i < prevcnt; i ++ ) { + int findflg = FALSE; + /* 蟆及匏 卞中月左皮斥尼弁玄匹]蜇箕及甄 卞中卅中 + * 左皮斥尼弁玄卅日壅允屯五左皮斥尼弁玄分 + */ + for( j = 0; j < curcnt; j ++ ) { + if( PrevObjCollection[i] == CurrentObjCollection[j] ) { + findflg = TRUE; + break; + } + } + if( !findflg ) { + cnv10to62( PrevObjCollection[i], buf, sizeof( buf)); + CONNECT_appendCDbuf( fd, buf, strlen( buf)); + + /* 锹澎卞手 霜月 */ + if( OBJECT_getType( PrevObjCollection[i]) == OBJTYPE_CHARA ) { + int tocharaindex = OBJECT_getIndex( PrevObjCollection[i]); + if( CHAR_getInt( tocharaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + int tofd = CHAR_getWorkInt( tocharaindex, CHAR_WORKFD); + if( tofd != -1 ) { + CONNECT_appendCDbuf( tofd, cd_msg, strlen( cd_msg)); + CDsend( tofd); + } + } + } + } + } + CDsend( fd); + + +} +BOOL CHAR_setMyPosition( int index, int x, int y, BOOL CAFlg) +{ + return CHAR_setMyPosition_main( index,x,y,-1,CAFlg); +} + +BOOL CHAR_setMyPosition_main( int index, int x, int y, int setdir, BOOL CAFlg) +{ + int objindex; + int prev_x,prev_y; + int fl; + + prev_x = CHAR_getInt( index, CHAR_X); + prev_y = CHAR_getInt( index, CHAR_Y); + if( prev_x == x && prev_y == y ) { + return FALSE; + } + + if( CHAR_getWorkInt( index, CHAR_WORKPARTYMODE) == CHAR_PARTY_CLIENT) { + return FALSE; + } + + if( CHAR_getFlg( index, CHAR_ISWARP)) return FALSE; + + objindex = CHAR_getWorkInt(index,CHAR_WORKOBJINDEX); + fl = CHAR_getInt( index, CHAR_FLOOR); + + if( !MAP_IsValidCoordinate( fl, x, y )) { + print( "error: invalid Coordinate fl[%d] x[%d] y[%d] %s:%d\n", + fl, x, y, __FILE__, __LINE__); + CONNECT_setCloseRequest( CHAR_getWorkInt( index, CHAR_WORKFD), 1); + return FALSE; + } + + if( ABS( x - prev_x) > CHAR_DEFAULTSEESIZ/2 || + ABS( y - prev_y) > CHAR_DEFAULTSEESIZ/2 ) + { + CHAR_sendCDArroundChar( fl,prev_x,prev_y,objindex ); + } + + if( ABS( x - prev_x) <= 1 && ABS( y - prev_y ) <= 1){ + POINT start,end; + int dir; + start.x = CHAR_getInt( index, CHAR_X); + start.y = CHAR_getInt( index, CHAR_Y); + end.x = x; + end.y = y; + dir = NPC_Util_getDirFromTwoPoint( &start, &end); + if( dir != -1 ) { + CHAR_walk( index, dir, 0); + } + } + else { + CHAR_setInt( index, CHAR_X,x); + CHAR_setInt( index, CHAR_Y,y); + if( setdir >= 0 && setdir < 8) CHAR_setInt( index, CHAR_DIR, setdir); + { + int of,ox,oy; + of = OBJECT_setFloor(objindex,fl); + ox = OBJECT_setX(objindex,x); + oy = OBJECT_setY(objindex,y); + + if( !MAP_objmove( objindex,of,ox,oy,fl,x,y ) ){ + fprint( "ERROR MAP_OBJMOVE objindex=%d\n",objindex ); + return FALSE; + } + } + if( ABS( x - prev_x) > CHAR_DEFAULTSEESIZ/2 || + ABS( y - prev_y) > CHAR_DEFAULTSEESIZ/2 ) + { + CHAR_sendWatchEvent(objindex,CHAR_ACTWARP,NULL,0,FALSE); + } + else if( CAFlg == TRUE ) { + CHAR_sendWatchEvent(objindex,CHAR_ACTWARP,NULL,0,FALSE); + } + } + + if( CHAR_getWorkInt( index, CHAR_WORKPARTYMODE) == CHAR_PARTY_LEADER ) { + if( ABS( x - prev_x) <= 1 && ABS( y - prev_y ) <= 1){ + int i; + int prevparty_x = prev_x; + int prevparty_y = prev_y; + for( i = 1; i < CHAR_PARTYMAX; i ++ ) { + int toindex = CHAR_getWorkInt( index, i + CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX(toindex) ) { + int client_x = prevparty_x; + int client_y = prevparty_y; + int dir; + POINT start, end; + + prevparty_x = CHAR_getInt( toindex, CHAR_X); + prevparty_y = CHAR_getInt( toindex, CHAR_Y); + start.x = prevparty_x; + start.y = prevparty_y; + + end.x = client_x; + end.y = client_y; + + dir = NPC_Util_getDirFromTwoPoint( &start, &end); + if( dir != - 1 ) { + CHAR_walk( toindex, dir, 0); + } + } + } + } + + else if( ABS( x - prev_x) > CHAR_DEFAULTSEESIZ/2 || + ABS( y - prev_y) > CHAR_DEFAULTSEESIZ/2 ) + { + int i; + for( i = 1; i < CHAR_PARTYMAX; i ++ ) { + int toindex = CHAR_getWorkInt( index, i + CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX(toindex) ) { + CHAR_warpToSpecificPoint( toindex,fl , x,y); + } + } + } + } + + if( ABS( x - prev_x) <= CHAR_DEFAULTSEESIZ/2 && + ABS( y - prev_y) <= CHAR_DEFAULTSEESIZ/2 ) + { + CHAR_setMyPosition_sendData( index, prev_x, prev_y, x, y); + } + + return TRUE; +} + + +static char CHAR_P_statusSendBuffer[STRINGBUFSIZ]; + + + +static char *CHAR_make_P_StatusString( int charaindex, unsigned int indextable ) +{ + int i,j; + int ret = 0; + int strlength; + char buf[64]; + struct { + unsigned int kind; + int intdataindex; + int gettype; + }chk[] = { + { CHAR_P_STRING_HP, CHAR_HP, 0 }, + { CHAR_P_STRING_MAXHP, CHAR_WORKMAXHP, 1 }, + { CHAR_P_STRING_MP, CHAR_MP, 0 }, + { CHAR_P_STRING_MAXMP, CHAR_WORKMAXMP, 1 }, + { CHAR_P_STRING_EXP, CHAR_EXP, 0 }, + { CHAR_P_STRING_LV, CHAR_LV, 0 }, + { CHAR_P_STRING_ATK, CHAR_WORKATTACKPOWER, 1 }, + { CHAR_P_STRING_DEF, CHAR_WORKDEFENCEPOWER, 1 }, + { CHAR_P_STRING_QUICK, CHAR_WORKQUICK, 1 }, + { CHAR_P_STRING_CHARM, CHAR_WORKFIXCHARM, 1 }, + { CHAR_P_STRING_LUCK, CHAR_WORKFIXLUCK, 1 }, + { CHAR_P_STRING_GOLD, CHAR_GOLD, 0 }, + { CHAR_P_STRING_TITLE, CHAR_INDEXOFEQTITLE, 0 }, + { CHAR_P_STRING_NAME, CHAR_NAME, 2 }, + { CHAR_P_STRING_OWNTITLE, CHAR_OWNTITLE, 2 }, + { CHAR_P_STRING_VITAL, CHAR_VITAL, 10 }, + { CHAR_P_STRING_STR, CHAR_STR, 10 }, + { CHAR_P_STRING_TOUGH, CHAR_TOUGH, 10 }, + { CHAR_P_STRING_DEX, CHAR_DEX, 10 }, + { CHAR_P_STRING_EARTH, CHAR_WORKFIXEARTHAT, 11 }, + { CHAR_P_STRING_WATER, CHAR_WORKFIXWATERAT, 11 }, + { CHAR_P_STRING_FIRE, CHAR_WORKFIXFIREAT, 11 }, + { CHAR_P_STRING_WIND, CHAR_WORKFIXWINDAT, 11 }, + { CHAR_P_STRING_DUELPOINT, CHAR_DUELPOINT, 0 }, + { CHAR_P_STRING_TRANSMIGRATION, CHAR_TRANSMIGRATION, 0}, + { CHAR_P_STRING_RIDEPET, CHAR_RIDEPET, 0}, + { CHAR_P_STRING_LEARNRIDE, CHAR_LEARNRIDE, 0}, + { CHAR_P_STRING_BASEBASEIMAGENUMBER, CHAR_BASEBASEIMAGENUMBER, 0}, + { CHAR_P_STRING_SKYWALKER, CHAR_WORKSKYWALKER, 1}, + { CHAR_P_STRING_DEBUGMODE, CHAR_WORKDEBUGMODE, 1}, +/* +#ifdef _CHAR_PROFESSION +#ifdef _SEND_PROF_DATA + { CHAR_P_STRING_PROFESSION, PROFESSION_CLASS, 20}, +#endif +#endif +*/ + }; + + snprintf( CHAR_P_statusSendBuffer, sizeof( CHAR_P_statusSendBuffer), + "P%s|", cnv10to62( indextable, buf,sizeof(buf))); + strlength = strlen( CHAR_P_statusSendBuffer ); + + for( i = 1; i < sizeof( int) * 8; i ++ ){ + if( indextable & (1 << i) ) { + char tmp[256]; + BOOL found = FALSE; + for( j = 0; j < arraysizeof( chk); j ++ ) { + if( chk[j].kind == 1 << i ) { + if( chk[j].gettype == 0 ) { + ret = CHAR_getInt( charaindex,chk[j].intdataindex); + snprintf( tmp, sizeof( tmp), "%d|", ret); + }else if( chk[j].gettype == 1 ) { + ret = CHAR_getWorkInt( charaindex,chk[j].intdataindex); + snprintf( tmp, sizeof( tmp), "%d|", ret); + }else if( chk[j].gettype == 10 ) { + ret = CHAR_getInt( charaindex, chk[j].intdataindex)/100; + snprintf( tmp, sizeof( tmp), "%d|", ret); + }else if( chk[j].gettype == 11 ) { + ret = CHAR_getWorkInt( charaindex, chk[j].intdataindex); + if( ret < 0) ret = 0; + snprintf( tmp, sizeof( tmp), "%d|", ret); + }else if( chk[j].gettype == 2 ) { + char escapebuffer[128]; + char *a = CHAR_getChar( charaindex, chk[j].intdataindex); + + snprintf( tmp,sizeof( tmp ), + "%s|", + makeEscapeString( a, escapebuffer, + sizeof(escapebuffer) + )); + } +/* +#ifdef _CHAR_PROFESSION +#ifdef _SEND_PROF_DATA + else if( chk[j].gettype == 20 ) { + int k; + char tempbuf[256]; + strcpy( tmp, ""); + for( k=0; k<11; k++){ + ret = CHAR_getInt( charaindex, chk[j].intdataindex + k ); + snprintf( tempbuf, sizeof( tempbuf), "%d|", ret); + strcat( tmp, tempbuf); + } + } +#endif +#endif +*/ + found = TRUE; + break; + } + } + if( !found) { + if( indextable & CHAR_P_STRING_NEXTEXP ) { + ret = CHAR_GetLevelExp( charaindex, CHAR_getInt( charaindex, CHAR_LV ) + 1); + snprintf( tmp, sizeof( tmp), "%d|", ret); + found = TRUE; + } + } + if( !found) { + print( "找不到指定的参数[%d]\n",indextable); + }else { + strcpysafe( &CHAR_P_statusSendBuffer[ strlength], + sizeof( CHAR_P_statusSendBuffer) - strlength, + tmp); + + strlength += strlen( tmp ); + if( strlength >= sizeof( CHAR_P_statusSendBuffer ) ) { + return CHAR_P_statusSendBuffer; + } + } + } + } + return CHAR_P_statusSendBuffer; +} + + + +BOOL CHAR_send_P_StatusString( int charaindex, unsigned int indextable ) +{ + char* string; + //if( indextable >= ( CHAR_P_STRING_BASEBASEIMAGENUMBER << 1)) { + if( indextable >= ( CHAR_P_STRING_SKYWALKER << 1)) { + //if( indextable >= ( CHAR_P_STRING_DEBUGMODE << 1)) { + print( "send_P invalid index[%d]\n", indextable); + return FALSE; + } + + if( CHAR_getInt(charaindex,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ){ + return FALSE; + } + + string = CHAR_make_P_StatusString( charaindex, indextable ); + + if( string != NULL ){ + int fd; + fd = getfdFromCharaIndex( charaindex ); + if( fd != -1 ){ + lssproto_S_send( fd, string ); + return TRUE; + } + } + return FALSE; +} +static char CHAR_N_statusSendBuffer[STRINGBUFSIZ]; +/*------------------------------------------------------------ + * 弁仿奶失件玄卞霜月 { 及 侬 毛综岳允月[ + * 娄醒 + * charaindex int 平乓仿奶件犯弁永旦 + * indextable int P 毛霜月由仿丢□正及螂宁 [ + *------------------------------------------------------------*/ +static char *CHAR_make_N_StatusString( int charaindex, int num, unsigned int indextable ) +{ + int i,j; + int nindex = -1; + int ret = 0; + int strlength; + char buf[64]; + struct { + unsigned int kind; + int intdataindex; + int gettype; + }chk[] = { + { CHAR_N_STRING_OBJINDEX, CHAR_WORKOBJINDEX, 1 }, + { CHAR_N_STRING_LV, CHAR_LV, 0 }, + { CHAR_N_STRING_MAXHP, CHAR_WORKMAXHP, 1 }, + { CHAR_N_STRING_HP, CHAR_HP, 0 }, + { CHAR_N_STRING_MP, CHAR_MP, 0 }, + { CHAR_N_STRING_NAME, CHAR_NAME, 2 }, + + + }; + /* 醮棉旦 □正旦犯□正 */ + /* 凝民尼永弁 */ + if( num < 0 || num >= CHAR_PARTYMAX ){ + print( "朋友模式失败 (%c)%d \n", num, num ); + return NULL; + } + /* 醮棉及奶件犯永弁旦毛潸 */ + nindex = CHAR_getPartyIndex( charaindex, num); + + if( nindex == -1 ){ + /* 鬼支仃升 snprintf 允月 */ + snprintf( CHAR_N_statusSendBuffer,sizeof(CHAR_N_statusSendBuffer), + "N%d|0|", num ); + return CHAR_N_statusSendBuffer; + } + + snprintf( CHAR_N_statusSendBuffer, sizeof( CHAR_N_statusSendBuffer), + "N%d|%s|", num,cnv10to62( indextable, buf,sizeof(buf))); + strlength = strlen( CHAR_N_statusSendBuffer ); + + /* indextable及 匹 匀化中月申永玄毛赐 卞譬屯月 */ + for( i = 1; i < sizeof( int) * 8; i ++ ){ + if( indextable & (1 << i) ) { + char tmp[256]; + BOOL found = FALSE; + /* 匀化中月申永玄午]chk卞甲永玄允月井譬屯月 */ + for( j = 0; j < arraysizeof( chk); j ++ ) { + if( chk[j].kind == 1 << i ) { + /* 域谯仄凶及匹袄毛潸 允月 */ + /* 醒袄烟及犯□正 */ + if( chk[j].gettype == 0 ) { + ret = CHAR_getInt( nindex,chk[j].intdataindex); + snprintf( tmp, sizeof( tmp), "%d|", ret); + } + else if( chk[j].gettype == 1 ) { + ret = CHAR_getWorkInt( nindex,chk[j].intdataindex); + snprintf( tmp, sizeof( tmp), "%d|", ret); + } + else if( chk[j].gettype == 10 ) { + ret = CHAR_getInt( nindex, chk[j].intdataindex)/100; + snprintf( tmp, sizeof( tmp), "%d|", ret); + } + else if( chk[j].gettype == 11 ) { + ret = CHAR_getWorkInt( nindex, chk[j].intdataindex); + if( ret < 0) ret = 0; + snprintf( tmp, sizeof( tmp), "%d|", ret); + } + /* 侬 烟及犯□正 */ + else if( chk[j].gettype == 2 ) { + char escapebuffer[128]; + char *a = CHAR_getChar( nindex, chk[j].intdataindex); + + snprintf( tmp,sizeof( tmp ), + "%s|", + makeEscapeString( a, escapebuffer, + sizeof(escapebuffer) + )); + } + found = TRUE; + break; + } + } + /* 职及正奶皿及犯□正井手仄木卅中 */ + if( !found) { + /* 仇仇井日反ㄠ勾ㄠ勾 */ + } + if( !found) { + print( "找不到指定的参数[%d]\n",indextable); + } + else { + strcpysafe( &CHAR_N_statusSendBuffer[ strlength], + sizeof( CHAR_N_statusSendBuffer) - strlength, + tmp); + + strlength += strlen( tmp ); + if( strlength >= sizeof( CHAR_N_statusSendBuffer ) ) { + return CHAR_N_statusSendBuffer; + } + } + } + } + return CHAR_N_statusSendBuffer; +} +/*------------------------------------------------------------ + * S P 旦 □正旦毛霜月[民尼永弁允月及匹}晓匹反民尼永弁仄卅仁化方中[ + * 娄醒 + * charaindex int 平乓仿奶件犯弁永旦 + * num int 醮棉 寞 + * indextable int P 毛霜月由仿丢□正及螂宁 [ + * 忒曰袄 + * 霜匀凶[TRUE(1) + * 霜木卅井匀凶[FALSE(0) + *------------------------------------------------------------*/ +BOOL CHAR_send_N_StatusString( int charaindex, int num, unsigned int indextable ) +{ + char* string; + + if( indextable >= (CHAR_N_STRING_NAME << 1)) { + print( "send_N invalid index[%d]\n", indextable); + return FALSE; + } + + if( CHAR_getInt(charaindex,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ){ + return FALSE; + } + string = CHAR_make_N_StatusString( charaindex, num, indextable ); + if( string != NULL ){ + int fd; + fd = getfdFromCharaIndex( charaindex ); + if( fd != -1 ){ + lssproto_S_send( fd, string ); + return TRUE; + } + } + return FALSE; +} + +static char CHAR_K_statusSendBuffer[STRINGBUFSIZ]; +static char *CHAR_make_K_StatusString( int charaindex, int num, unsigned int indextable ) +{ + int i,j; + int ret = 0; + int strlength; + int pindex; + char buf[64]; + struct { + unsigned int kind; + int intdataindex; + int gettype; + }chk[] = { + { CHAR_K_STRING_BASEIMAGENUMBER, CHAR_BASEIMAGENUMBER, 0 }, + { CHAR_K_STRING_HP, CHAR_HP, 0 }, + { CHAR_K_STRING_MAXHP, CHAR_WORKMAXHP, 1 }, + { CHAR_K_STRING_MP, CHAR_MP, 0 }, + { CHAR_K_STRING_MAXHP, CHAR_WORKMAXMP, 1 }, + { CHAR_K_STRING_EXP, CHAR_EXP, 0 }, + { CHAR_K_STRING_LV, CHAR_LV, 0 }, + { CHAR_K_STRING_ATK, CHAR_WORKATTACKPOWER, 1 }, + { CHAR_K_STRING_DEF, CHAR_WORKDEFENCEPOWER, 1 }, + { CHAR_K_STRING_QUICK, CHAR_WORKQUICK, 1 }, + { CHAR_K_STRING_AI, CHAR_WORKFIXAI, 1 }, + { CHAR_K_STRING_EARTH, CHAR_WORKFIXEARTHAT, 11}, + { CHAR_K_STRING_WATER, CHAR_WORKFIXWATERAT, 11}, + { CHAR_K_STRING_FIRE, CHAR_WORKFIXFIREAT, 11}, + { CHAR_K_STRING_WIND, CHAR_WORKFIXWINDAT, 11}, + { CHAR_K_STRING_SLOT, CHAR_SLOT, 0 }, + { CHAR_K_STRING_NAME, CHAR_NAME, 2 }, + { CHAR_K_STRING_USERPETNAME, CHAR_USERPETNAME, 2 }, + + }; + /* 凝民尼永弁 */ + if( num < 0 || num >= CHAR_MAXPETHAVE ){ + print( "宠物模式失败 (%c)%d \n", num, num ); + return NULL; + } + /* 矢永玄及奶件犯永弁旦毛潸 */ + pindex = CHAR_getCharPet( charaindex, num ); + if( pindex == -1 ){ + /* 鬼支仃升 snprintf 允月 */ + snprintf(CHAR_K_statusSendBuffer,sizeof(CHAR_K_statusSendBuffer), + "K%d|0|", num ); + return CHAR_K_statusSendBuffer; + } + + snprintf( CHAR_K_statusSendBuffer, sizeof( CHAR_K_statusSendBuffer), + "K%d|%s|", num, cnv10to62( indextable, buf,sizeof(buf))); + strlength = strlen( CHAR_K_statusSendBuffer ); + + for( i = 1; i < sizeof( int) * 8; i ++ ){ + if( indextable & (1 << i) ) { + char tmp[256]; + BOOL found = FALSE; + for( j = 0; j < arraysizeof( chk); j ++ ) { + if( chk[j].kind == 1 << i ) { + if( chk[j].gettype == 0 ) { + ret = CHAR_getInt( pindex,chk[j].intdataindex); + snprintf( tmp, sizeof( tmp), "%d|", ret); + } + else if( chk[j].gettype == 1 ) { + ret = CHAR_getWorkInt( pindex,chk[j].intdataindex); + snprintf( tmp, sizeof( tmp), "%d|", ret); + } + else if( chk[j].gettype == 10 ) { + ret = CHAR_getInt( pindex, chk[j].intdataindex)/100; + snprintf( tmp, sizeof( tmp), "%d|", ret); + } + else if( chk[j].gettype == 11 ) { + ret = CHAR_getWorkInt( pindex, chk[j].intdataindex); + if( ret < 0) ret = 0; + snprintf( tmp, sizeof( tmp), "%d|", ret); + } + /* 侬 烟及犯□正 */ + else if( chk[j].gettype == 2 ) { + char escapebuffer[128]; + char *a = CHAR_getChar( pindex, chk[j].intdataindex); + + snprintf( tmp,sizeof( tmp ), + "%s|", + makeEscapeString( a, escapebuffer, + sizeof(escapebuffer) + )); + } + found = TRUE; + break; + } + } + if( !found) { + if( indextable & CHAR_K_STRING_NEXTEXP ) { + ret = CHAR_GetLevelExp( pindex, CHAR_getInt( pindex, CHAR_LV ) + 1); + snprintf( tmp, sizeof( tmp), "%d|", ret); + found = TRUE; + } + if( indextable & CHAR_K_STRING_CHANGENAMEFLG ) { + BOOL changenameflg = FALSE; + char *mycdkey, *cdkey = NULL; + mycdkey = CHAR_getChar( charaindex, CHAR_CDKEY); + { + cdkey = CHAR_getChar( pindex, CHAR_CDKEY); + if( cdkey == NULL ) { + print( "can't get CDKEY\n"); + }else { + if( strlen( cdkey) == 0 || + strcmp( cdkey, mycdkey) == 0 ){ + changenameflg = TRUE; + } + } + } + snprintf( tmp, sizeof( tmp), "%d|", changenameflg); + found = TRUE; + } + } + if( !found) { + print( "找不到指定的参数[%d]\n",indextable); + }else { + strcpysafe( &CHAR_K_statusSendBuffer[ strlength], + sizeof( CHAR_K_statusSendBuffer) - strlength, + tmp); + + strlength += strlen( tmp ); + if( strlength >= sizeof( CHAR_K_statusSendBuffer ) ) { + return CHAR_K_statusSendBuffer; + } + } + } + } + return CHAR_K_statusSendBuffer; +} +/*------------------------------------------------------------ + * S K 旦 □正旦毛霜月[民尼永弁允月及匹}晓匹反民尼永弁仄卅仁化方中[ + * 娄醒 + * charaindex int 平乓仿奶件犯弁永旦 + * indextable int P 毛霜月由仿丢□正及螂宁 [ + * 忒曰袄 + * 霜匀凶[TRUE(1) + * 霜木卅井匀凶[FALSE(0) + *------------------------------------------------------------*/ +BOOL CHAR_send_K_StatusString( int charaindex, int num, unsigned int indextable ) +{ + char* string; + + if( indextable >= (CHAR_K_STRING_USERPETNAME << 1)) { + print( "send_K invalid index[%d]\n", indextable); + return FALSE; + } + + if( CHAR_getInt(charaindex,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ){ + return FALSE; + } + string = CHAR_make_K_StatusString( charaindex, num, indextable ); + if( string != NULL ){ + int fd; + fd = getfdFromCharaIndex( charaindex ); + if( fd != -1 ){ + lssproto_S_send( fd, string ); + return TRUE; + } + } + return FALSE; +} + + + +//------------------------------------------------------------ +// 皿伊奶乩□及 毛笛遥 +//------------------------------------------------------------ +void CHAR_AddCharm( int charaindex, int iValue ) +{ + int iWork; + iWork = CHAR_getInt( charaindex, CHAR_CHARM ) + iValue; + iWork = max( 0, iWork ); // 凝ㄟ + iWork = min( 100, iWork ); // ㄠㄟㄟ + CHAR_setInt( charaindex, CHAR_CHARM, iWork ); +} + +//------------------------------------------------------------ +// 矢永玄及镝擦蘸 祭袄毛笛遥允月[ +//------------------------------------------------------------ +void CHAR_PetAddVariableAi( int petindex, int iValue ) +{ + int iWork; + iWork = CHAR_getInt( petindex, CHAR_VARIABLEAI ) + iValue; + iWork = min( CHAR_MAXVARIABLEAI, iWork ); + iWork = max( CHAR_MINVARIABLEAI, iWork ); + CHAR_setInt( petindex, CHAR_VARIABLEAI, iWork ); + +} + +//------------------------------------------------------------ +// 犯□正矛□旦卞瓒 允月平□ 蟆 毛综岳允月[ +//------------------------------------------------------------ +int CHAR_makeDBKey( int charaindex, char *pszBuffer, int size ){ + + char *cdkey; + char buff[512]; + char escapebuf[1024]; + + pszBuffer[0] = 0; // 赓渝祭 + cdkey = CHAR_getChar( charaindex, CHAR_CDKEY); + if( cdkey == NULL )return FALSE; // 瓒 匹五卅中 + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; + + // 平□反 cdkey_ 蟆 + snprintf( buff, sizeof(buff), + "%s_%s", cdkey, CHAR_getChar( charaindex, CHAR_NAME ) ); + makeEscapeString( buff, escapebuf, sizeof(escapebuf)); + strcpysafe( pszBuffer, size, escapebuf); + + return TRUE; +} + + +//------------------------------------------------------------ +// +// 犯□正矛□旦及嫩 毛凳蕙 +// +// DuelPoint 及 DBUpdateEntry毛霜月 +//------------------------------------------------------------ +BOOL CHAR_send_DpDBUpdate( int charaindex ) +{ + int fd,dp; + char szKey[256]; + if( CHAR_makeDBKey( charaindex, szKey, sizeof( szKey ) ) == FALSE ){ + return FALSE; + } + dp = CHAR_getInt( charaindex, CHAR_DUELPOINT ); + fd = getfdFromCharaIndex( charaindex); + if( fd != -1 ) { + char info[512]; + //char escapebuff[1024]; + /* "等级|几战|几胜|几败|几连胜|最高连胜数" */ + snprintf( info, sizeof( info), + "%d,%d,%d,%d,%d,%d", + CHAR_getInt( charaindex, CHAR_LV), + CHAR_getInt( charaindex, CHAR_DUELBATTLECOUNT), + CHAR_getInt( charaindex, CHAR_DUELWINCOUNT), + CHAR_getInt( charaindex, CHAR_DUELLOSECOUNT), + CHAR_getInt( charaindex, CHAR_DUELSTWINCOUNT), + CHAR_getInt( charaindex, CHAR_DUELMAXSTWINCOUNT)); + saacproto_DBUpdateEntryInt_send( + acfd, DB_DUELPOINT, szKey, max(dp,0), info, + CONNECT_getFdid( fd ) ,0 ); + } + + return TRUE; +} + +char *CHAR_getUseName( int charaindex ) +{ + char *pName=NULL; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + pName = CHAR_getChar( charaindex, CHAR_USERPETNAME ); + if( pName[0] == 0 ){ + pName = CHAR_getChar( charaindex, CHAR_NAME ); + } + }else{ +// if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ) +// pName = CHAR_getChar( charaindex, CHAR_OWNTITLE ); +// if( pName == NULL || strlen(pName) <= 0 ) + pName = CHAR_getChar( charaindex, CHAR_NAME ); + } + return pName; +} + +// Robin extend_of_CHAR_getUseName() 2001/02/15 +char *CHAR_getUseID( int charaindex ) +{ + char *pName; + // 矢永玄分匀凶日白伉□生□丞卞允月 + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + pName = "NO_USER"; + }else{ + pName = CHAR_getChar( charaindex, CHAR_CDKEY ); + } + return pName; +} + +BOOL CHAR_send_DpDBUpdate_AddressBook( int charaindex, int mode ) +{ + int fd; + char szKey[256]; + if( CHAR_makeDBKey( charaindex, szKey, sizeof( szKey ) ) == FALSE ){ + return FALSE; + } + + fd = getfdFromCharaIndex( charaindex); + if( fd != -1 ) { + char msgbuf[512]; + snprintf( msgbuf, sizeof( msgbuf), + "%d|%d|%d|%d|%d|", + (mode == 0 ) ? 0 : getServernumber(), + CHAR_getInt( charaindex, CHAR_LV), + CHAR_getInt( charaindex, CHAR_DUELPOINT), + CHAR_getInt( charaindex, CHAR_FACEIMAGENUMBER), + CHAR_getInt( charaindex, CHAR_TRANSMIGRATION) ); + + saacproto_DBUpdateEntryString_send( + acfd, DB_ADDRESSBOOK, szKey, msgbuf, CONNECT_getFdid( fd ),0 ); + + saacproto_Broadcast_send( acfd, CHAR_getChar( charaindex, CHAR_CDKEY), + CHAR_getChar( charaindex, CHAR_NAME), "param", 0); + + } + return TRUE; +} + +void CHAR_sendBattleWatch( int objindex, int onoff) +{ + int opt[1]; + opt[0] = onoff; + CHAR_sendWatchEvent( objindex,CHAR_ACTBATTLEWATCH,opt,1,TRUE); +} +/*------------------------------------------------------------ + * 隙烂今木凶 毛莫曰及谛卞矢永玄丢□伙及梢请毛允月[ + * 娄醒 + * charaindex int chara 匹及奶件犯弁永旦 + * 忒曰袄 + * 卅仄 + ------------------------------------------------------------*/ +void CHAR_sendPMEToArroundCharacterFLXY( int petindex, int fl, int x, int y, + int dir, int flg, int no ) +{ + int i,j; + int objindex; + int graphicsno; + char buff[2048]; + + objindex = CHAR_getWorkInt( petindex, CHAR_WORKOBJINDEX); + graphicsno = CHAR_getInt( petindex, CHAR_BASEIMAGENUMBER); + if( CHAR_makeObjectCString( objindex, buff, sizeof( buff)) == FALSE ) { + buff[0] = '\0'; + } + + for( i = x - CHAR_DEFAULTSEESIZ/2 ; + i <= x +CHAR_DEFAULTSEESIZ/2 ; i ++ ){ + for( j = y - CHAR_DEFAULTSEESIZ/2; + j <= y + CHAR_DEFAULTSEESIZ/2; j ++ ){ + + OBJECT object; + for( object = MAP_getTopObj( fl, i,j); + object; + object = NEXT_OBJECT(object) ){ + int objindexwk = GET_OBJINDEX( object); + if( OBJECT_getType(objindexwk) == OBJTYPE_CHARA ){ + int index = OBJECT_getIndex(objindexwk); + if( CHAR_getInt( index,CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + int fd; + if( CHAR_getWorkInt( index, CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) continue; + fd = getfdFromCharaIndex( index); + if( fd == -1 )continue; + lssproto_PME_send( fd, objindex, graphicsno, + x,y, dir,flg,no,buff + ); + } + } + } + } + } +} +/*------------------------------------------------------------ + * charaindex 匹隙烂今木凶 毛莫曰及谛卞矢永玄丢□伙及梢请毛允月[ + * 娄醒 + * charaindex int chara 匹及奶件犯弁永旦 + * 忒曰袄 + * 卅仄 + ------------------------------------------------------------*/ +void CHAR_sendPMEToArroundCharacter( int charaindex, int petindex, int flg, int no ) +{ + int dirx[9],diry[9]; + int i; + int fl,x,y; + int dir; + for( i = 0 ; i < 7 ; i ++ ){ + dirx[i+2] = CHAR_getDX(CHAR_getInt(charaindex,CHAR_DIR) + i+1); + diry[i+2] = CHAR_getDY(CHAR_getInt(charaindex,CHAR_DIR) + i+1); + } + dirx[0] = CHAR_getDX(CHAR_getInt(charaindex,CHAR_DIR)); + diry[0] = CHAR_getDY(CHAR_getInt(charaindex,CHAR_DIR)); + dirx[1] = 0; + diry[1] = 0; + + fl = CHAR_getInt( charaindex,CHAR_FLOOR ); + dir = CHAR_getInt( charaindex, CHAR_DIR); + + /* 仁 轾潸 */ + for( i = 0 ; i < 9 ; i ++ ){ + int x = CHAR_getInt( charaindex, CHAR_X) + dirx[i]; + int y = CHAR_getInt( charaindex, CHAR_Y) + diry[i]; + /* 矢永玄毛 仃月桦赭井譬屯月 */ + if( PET_isPutPoint( fl, x, y ) == TRUE ) { + break; + } + } + /* 卅仃木壬箫葭 */ + if( i == 9 ) i = 1; + + x = CHAR_getInt(charaindex,CHAR_X)+dirx[i]; + y = CHAR_getInt(charaindex,CHAR_Y)+diry[i]; + + CHAR_sendPMEToArroundCharacterFLXY( petindex, + fl, x, y, dir, flg, no); +} +/*------------------------------------------------------------ + * SE毛 日允[ + * 耨葭毛 艘卞]苇尹月 区坌霜耨允月 + * 娄醒 + * fl,x,y 耨葭及甄 + * senumber 及 寞[sndcnf.h毛辅寰及仇午[ + * sw 日允井鞅户月井 0 : 鞅户月 1 : 日允 + ------------------------------------------------------------*/ +void CHAR_sendSEoArroundCharacter( int fl, int x, int y, int senumber, int sw ) +{ + int i,j; + + for( i = x - CHAR_DEFAULTSEESIZ/2 ; + i <= x +CHAR_DEFAULTSEESIZ/2 ; i ++ ){ + for( j = y - CHAR_DEFAULTSEESIZ/2; + j <= y + CHAR_DEFAULTSEESIZ/2; j ++ ){ + + OBJECT object; + for( object = MAP_getTopObj( fl, i,j); + object; + object = NEXT_OBJECT(object) ){ + int objindexwk = GET_OBJINDEX( object); + if( OBJECT_getType(objindexwk) == OBJTYPE_CHARA ){ + int index = OBJECT_getIndex(objindexwk); + if( CHAR_getInt( index,CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + int fd; + if( CHAR_getWorkInt( index, CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) continue; + fd = getfdFromCharaIndex( index); + if( fd == -1 )continue; + lssproto_SE_send( fd,x, y, senumber, sw ); + } + } + } + } + } +} +/*====================梢请涩烂====================*/ + + +#ifndef _SEND_EFFECT // WON ADD AC送下雪、下雨等特效 + +#define CHAR_EFFECT_SETTINGBUFFER 256 +typedef struct tagCHAR_effectsetting +{ + int floor; // 白夫失 + int effect; // 梢请 寞 + int level; // 梢请及伊矛伙[ 蜇及雄今[ + int sendflg; // 憎巨白尼弁玄毛霜匀凶井升丹井[ + char month[CHAR_EFFECT_SETTINGBUFFER]; // 垫允月畸 + char day[CHAR_EFFECT_SETTINGBUFFER]; // 垫允月 + char hour[CHAR_EFFECT_SETTINGBUFFER]; // 垫允月凛棉 + char min[CHAR_EFFECT_SETTINGBUFFER]; // 垫允月坌 + char expire[CHAR_EFFECT_SETTINGBUFFER]; // 垫仄化中月赢今[( + +}CHAR_effectsetting; + +CHAR_effectsetting* CHAR_effect; +int CHAR_effectnum; + +#endif + + + +/*------------------------------------------------------------ + * 梢请涩烂及赓渝祭毛允月[ + * 娄醒 + * filename char* 涩烂白央奶伙 + * 忒曰袄 + * 岳 TRUE(1) + * 撩 FALSE(0) + *------------------------------------------------------------*/ +BOOL CHAR_initEffectSetting( char* filename ) +{ + FILE* f; + char line[256]; + int linenum=0; + + int effectreadlen=0; + + f = fopen(filename,"r"); + if( f == NULL ){ + errorprint; + return FALSE; + } + + CHAR_effectnum=0; + + /* 引内 躲卅垫互窒垫丐月井升丹井譬屯月 */ + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + + CHAR_effectnum++; + } + + if( fseek( f, 0, SEEK_SET ) == -1 ){ + fprint( "Seek Error\n" ); + fclose(f); + return FALSE; + } + + CHAR_effect = allocateMemory( sizeof(CHAR_effectsetting) + * CHAR_effectnum ); + if( CHAR_effect == NULL ){ + fprint( "Can't allocate Memory %d\n" , + sizeof(CHAR_effectsetting)*CHAR_effectnum); + fclose( f ); + return FALSE; + } + /* 赓渝祭 */ +{ + int i; + for( i = 0; i < CHAR_effectnum; i ++ ) { + CHAR_effect[i].floor = 0; + CHAR_effect[i].effect = 0; + CHAR_effect[i].level = 0; + CHAR_effect[i].sendflg = 0; + CHAR_effect[i].month[0] = '\0'; + CHAR_effect[i].day[0] = '\0'; + CHAR_effect[i].hour[0] = '\0'; + CHAR_effect[i].min[0] = '\0'; + CHAR_effect[i].expire[0] = '\0'; + + } +} + + /* 引凶 心 允 */ + linenum = 0; + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + + /* 垫毛帮溥允月 */ + /* 引内 tab 毛 " " 卞 五晶尹月 */ + replaceString( line, '\t' , ' ' ); + /* 粮仄凶 " " 毛夫午勾卞允月 */ + deleteSequentChar( line, " " ); + + /* 仇仇引匹帮溥仄化}燮 互 旦矢□旦分匀凶日 */ + /* 引卅中 */ + if( line[0] == ' ' )continue; + + { + char token[256]; + int ret; + + /* 夫午勾户及玄□弁件毛苇月 */ + ret = getStringFromIndexWithDelim( line," ",1,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("文件秩序错误:%s 第%d行\n",filename,linenum); + continue; + } + CHAR_effect[effectreadlen].floor = atoi(token); + + /* 2勾户及玄□弁件毛苇月 */ + ret = getStringFromIndexWithDelim( line," ",2,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("文件秩序错误:%s 第%d行\n",filename,linenum); + continue; + } + + CHAR_effect[effectreadlen].effect = atoi( token ); + + /* 3勾户及玄□弁件毛苇月 */ + ret = getStringFromIndexWithDelim( line," ",3,token, + sizeof(token)); + if( ret ==FALSE){ + fprint("文件秩序错误:%s 第%d行\n",filename,linenum); + continue; + } + + CHAR_effect[effectreadlen].level = atoi( token ); + + /* 4勾户及玄□弁件毛苇月 */ + ret = getStringFromIndexWithDelim( line," ",4,token, + sizeof(token)); + if( ret ==FALSE){ + fprint("文件秩序错误:%s 第%d行\n",filename,linenum); + continue; + } + strcpysafe( CHAR_effect[effectreadlen].month, + sizeof( CHAR_effect[effectreadlen].month), + token); + + /* 5勾户及玄□弁件毛苇月 */ + ret = getStringFromIndexWithDelim( line," ",5,token, + sizeof(token)); + if( ret ==FALSE){ + fprint("文件秩序错误:%s 第%d行\n",filename,linenum); + continue; + } + strcpysafe( CHAR_effect[effectreadlen].day, + sizeof( CHAR_effect[effectreadlen].day), + token); + + /* 6勾户及玄□弁件毛苇月 */ + ret = getStringFromIndexWithDelim( line," ",6,token, + sizeof(token)); + if( ret ==FALSE){ + fprint("文件秩序错误:%s 第%d行\n",filename,linenum); + continue; + } + strcpysafe( CHAR_effect[effectreadlen].hour, + sizeof( CHAR_effect[effectreadlen].hour), + token); + + /* 7勾户及玄□弁件毛苇月 */ + ret = getStringFromIndexWithDelim( line," ",7,token, + sizeof(token)); + if( ret ==FALSE){ + fprint("文件秩序错误:%s 第%d行\n",filename,linenum); + continue; + } + strcpysafe( CHAR_effect[effectreadlen].min, + sizeof( CHAR_effect[effectreadlen].min), + token); + + /* 8勾户及玄□弁件毛苇月 */ + ret = getStringFromIndexWithDelim( line," ",8,token, + sizeof(token)); + if( ret ==FALSE){ + fprint("文件秩序错误:%s 第%d行\n",filename,linenum); + continue; + } + strcpysafe( CHAR_effect[effectreadlen].expire, + sizeof( CHAR_effect[effectreadlen].expire), + token); + + effectreadlen ++; + } + } + fclose(f); + + CHAR_effectnum = effectreadlen; + + print( "有效设置总数 %d...", CHAR_effectnum ); +#ifdef DEBUG + + { + int i; + for( i=0; i tim && NowTime.tv_sec < tim+atoi(CHAR_effect[num].expire)) { + flg = TRUE; + break; + } + } + if( !flg ) break; + } + } + // 坌互隙烂 仄分匀凶日手丹OK + + returnflg = TRUE; + break; + } + return returnflg; +} +//------------------------------------------------------------------------- +// 平乓仿弁正□及匏 午凛棉毛葭卞] +// 巨白尼弁玄毛霜月 邰互丐木壬霜月 +//------------------------------------------------------------------------- +void CHAR_checkEffect( int charaindex) +{ + int i; + int fl = CHAR_getInt( charaindex, CHAR_FLOOR); + int fd = getfdFromCharaIndex( charaindex); + + // 巨白尼弁玄域绎壅允 + lssproto_EF_send( fd, 0, 0, ""); + CHAR_setWorkInt( charaindex, CHAR_WORKEFFECT, 0); + + for( i = 0; i < CHAR_effectnum; i ++){ + // 白夫失互域谯仄凶凛分仃 + if( CHAR_effect[i].floor == fl) { + // 椭瘀毛譬屯引允[ + if( CHAR_checkEffectTime( i)){ + // 巨白尼弁玄毛霜月 + lssproto_EF_send( fd, CHAR_effect[i].effect, CHAR_effect[i].level, ""); + if( CHAR_effect[i].level == 0 ) { + CHAR_setWorkInt( charaindex, CHAR_WORKEFFECT, + CHAR_getWorkInt( charaindex, CHAR_WORKEFFECT) & + ~CHAR_effect[i].effect); + } + else { + CHAR_setWorkInt( charaindex, CHAR_WORKEFFECT, + CHAR_getWorkInt( charaindex, CHAR_WORKEFFECT) | + CHAR_effect[i].effect); + } + } + } + } +} + +void CHAR_checkEffectLoop( void) +{ + int i,j; + int playernum = CHAR_getPlayerMaxNum(); + int player; + int efnum = 0; + + struct { + int floor; + int effect; + BOOL on; + BOOL off; + } ef[2048]; + + memset( &ef, 0, sizeof( ef)); + + for( i = 0; i < CHAR_effectnum; i ++){ + + if( CHAR_checkEffectTime( i)){ + if( !CHAR_effect[i].sendflg) { + + for( player = 0 ; player < playernum; player ++ ) { + if( CHAR_getInt( player, CHAR_FLOOR) == CHAR_effect[i].floor ) { + int fd = getfdFromCharaIndex( player); + lssproto_EF_send( fd, CHAR_effect[i].effect, CHAR_effect[i].level, ""); + if( CHAR_effect[i].level == 0 ) { + CHAR_setWorkInt( player, CHAR_WORKEFFECT, + CHAR_getWorkInt( player, CHAR_WORKEFFECT) & + ~CHAR_effect[i].effect); + } + else { + CHAR_setWorkInt( player, CHAR_WORKEFFECT, + CHAR_getWorkInt( player, CHAR_WORKEFFECT) | + CHAR_effect[i].effect); + } + } + } + CHAR_effect[i].sendflg = TRUE; + + } + + for( j = 0; j < efnum; j ++ ) { + if( ef[j].floor == CHAR_effect[i].floor && + ef[j].effect == CHAR_effect[i].effect) + { + ef[j].on = TRUE; + break; + } + } + if( j == efnum ) { + ef[j].floor = CHAR_effect[i].floor; + ef[j].effect = CHAR_effect[i].effect; + ef[j].on = TRUE; + efnum++; + if( efnum >= arraysizeof( ef)) { + print( "err buffer over %s:%d\n", __FILE__, __LINE__); + efnum --; + } + } + } + else { + if( CHAR_effect[i].sendflg) { + + for( j = 0; j < efnum; j ++ ) { + if( ef[j].floor == CHAR_effect[i].floor && + ef[j].effect == CHAR_effect[i].effect) + { + ef[j].off = TRUE; + break; + } + } + if( j == efnum ) { + ef[j].floor = CHAR_effect[i].floor; + ef[j].effect = CHAR_effect[i].effect; + ef[j].off = TRUE; + efnum++; + if( efnum >= arraysizeof( ef)) { + print( "err buffer over %s:%d\n", __FILE__, __LINE__); + efnum --; + } + } + CHAR_effect[i].sendflg = FALSE; + } + } + } + + for( i = 0; i < efnum; i ++ ) { + if( ef[i].on == FALSE && ef[i].off == TRUE ) { + + for( player = 0 ; player < playernum; player ++ ) { + if( CHAR_getInt( player, CHAR_FLOOR) == ef[i].floor ) { + int fd = getfdFromCharaIndex( player); + lssproto_EF_send( fd, 0, 0, ""); + CHAR_setWorkInt( player, CHAR_WORKEFFECT, 0); + } + } + } + } +} + +float GetRecoveryRate( int charaindex ){ + float fBai = 1.0; + + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + fBai = 1.0 + 0.00010 * CHAR_getInt( charaindex, CHAR_VITAL ); + }else{ + + fBai = 1.0 + 0.00005 * CHAR_getInt( charaindex, CHAR_VITAL ); + } + return fBai; + +} + + +#define CHARDATASIZE (1024*256) +#define SPACESTRING "|" + +static int makeSaveCharString( char *out , int outlen , + char *nm , char *opt , char *info ) +{ + char nmwork[256]; + char optwork[512]; + char infowork[CHARDATASIZE]; + char outwork[CHARDATASIZE]; + char *nmwork_p , *optwork_p , *infowork_p; + int l; + + strncpy( nmwork , nm , sizeof( nmwork )); + nmwork[strlen( nm)]=0; + + strncpy( optwork , opt , sizeof( optwork )); + optwork[strlen(opt)]=0; + + strncpy( infowork , info , sizeof( infowork )); + infowork[strlen(info)]=0; + + nmwork_p = makeEscapeString( nm , nmwork ,sizeof( nmwork )); + optwork_p = makeEscapeString( opt , optwork , sizeof( optwork )); + infowork_p = makeEscapeString( info , infowork , sizeof( infowork )); + + snprintf( outwork ,sizeof( outwork ) , + "%s" SPACESTRING "%s" SPACESTRING "%s" , + nmwork_p , optwork_p , infowork_p ); + + l = strlen( outwork ); + outwork[ strlen( outwork)+1] = 0; + if( l >= (outlen-1)){ + return -1; + } + + memcpy( out , outwork , l + 1 ); + + return 0; +} + +#ifdef _STORECHAR +int storeCharaData( void ){ + int i, charamax; + FILE *fp; + struct tm *pLtime; + char szFileName[256], *chardata; + char outbuff[CHARDATASIZE]; + Char* ch; + + print("\n保存运行中的数据\n"); + + pLtime = localtime( &NowTime.tv_sec ); + + charamax = getFdnum(); + + for( i = 0; i < charamax; i ++ ){ + int hash, dir, j; + char charId[32]; + char pathname[128]; + + if( CHAR_getCharUse( i ) == FALSE )continue; + + strcpy( charId, CHAR_getChar( i, CHAR_CDKEY ) ); + print("账号:%s", charId); + + hash = 0; + for( j=0; jtm_year+1900, + pLtime->tm_mon+1, + pLtime->tm_mday, + pLtime->tm_hour, + pLtime->tm_min + ); + + fp = fopen( szFileName, "w" ); + if( fp == NULL )continue; + + ch = CHAR_getCharPointer( i ); + if( !ch )continue; + + chardata = CHAR_makeStringFromCharData( ch ); + + if( makeSaveCharString( outbuff , sizeof( outbuff ), + CHAR_getChar( i, CHAR_NAME ), + CHAR_makeOptionString( ch ), + chardata ) == 0 + ){ + + fprintf( fp, outbuff ); + }else{ + fprintf( fp, "本□皮撩 \n" ); + } + + fclose( fp ); + } + return 0; +} + +#endif + +#ifdef _LASTERR_FUNCTION +DebugBreakPoint LastFunction[10]; +static int lastfunctionNum = 0; +void LastFunction_Init() +{ + int i; + for( i=0; i<10; i++) { + memset( LastFunction[i].FILE, 0, sizeof( char)*256); + memset( LastFunction[i].funName, 0, sizeof( char)*256); + LastFunction[i].line = -1; + } +} +void LastFunction_Add( char *file, int line, char *funName) +{ + lastfunctionNum ++; + if( lastfunctionNum >= 10 ) + lastfunctionNum = 0; + + strcpy( LastFunction[ lastfunctionNum].FILE, file); + LastFunction[ lastfunctionNum].line = line; + strcpy( LastFunction[ lastfunctionNum].funName, funName); +} + +int LastFunction_Get( int lasts, char *file, int *line, char *funName) +{ + if( lasts < 0 || lasts >= 10 ) + return -1; + strcpy( file, LastFunction[ lasts].FILE); + *line = LastFunction[ lasts].line = line; + strcpy( funName, LastFunction[ lasts].funName); + return lastfunctionNum; +} +#endif + + + +#ifdef _FIX_METAMORIDE +BOOL CHAR_CHECKJOINENEMY( int index) +{ + int masterindex=-1; + if( CHAR_getWorkInt( index, CHAR_WORKPARTYMODE) == CHAR_PARTY_CLIENT ) { + masterindex = CHAR_getWorkInt( index, CHAR_WORKPARTYINDEX1); + if( !CHAR_CHECKINDEX( masterindex) ) { + print( "err masterindex:%d %s:%d !!\n", masterindex,__FILE__, __LINE__); + return FALSE; + } + if( CHAR_getInt( masterindex, CHAR_WHICHTYPE) == CHAR_TYPEBUS) { + return TRUE; //JOIN ENEMY + } + } + + return FALSE; +} +#endif + + // WON ADD 修正道具的设定问题 +void fix_item_bug(int charaindex, int itemindex) +{ + + if (ITEM_CHECKINDEX(itemindex)){ + switch( ITEM_getInt(itemindex,ITEM_ID) ){ + case 19700: ITEM_setChar( itemindex, ITEM_ARGUMENT, "KPET:901_902_903_904"); break; // 鞭炮 + case 20242: ITEM_setChar( itemindex, ITEM_ARGUMENT, "KPET:957_958_959_960"); break; // 雄黄酒 + case 1292: ITEM_setInt( itemindex, ITEM_MAXDAMAGECRUSHE, 0); ITEM_setInt( itemindex, ITEM_DAMAGECRUSHE, 0); break; // 灵力铠 + case 19646: ITEM_setInt( itemindex, ITEM_MAXDAMAGECRUSHE, 0); ITEM_setInt( itemindex, ITEM_DAMAGECRUSHE, 0); break; // 灵力铠 + case 1478: ITEM_setChar( itemindex, ITEM_ARGUMENT, "HP:30"); break; // 洛克服 + case 20282: ITEM_setChar( itemindex, ITEM_EFFECTSTRING, "攻+25 伤+25 敏-4 魅+5"); ITEM_setInt( itemindex, ITEM_MODIFYQUICK, -4 ); break; // 铁枪1 + case 20283: ITEM_setChar( itemindex, ITEM_EFFECTSTRING, "攻+50 伤+50 敏-10 魅+10"); ITEM_setInt( itemindex, ITEM_MODIFYQUICK, -10 ); break; // 铁枪2 + case 20284: ITEM_setChar( itemindex, ITEM_EFFECTSTRING, "攻+100 伤+100 敏-20 魅+15"); ITEM_setInt( itemindex, ITEM_MODIFYQUICK, -20 ); break; // 铁枪3 + case 1210: ITEM_setChar( itemindex, ITEM_EFFECTSTRING, "攻 +4 防 -4 敏 +4 魅 +2"); break; // 碧玉的石手环 + case 1203: ITEM_setChar( itemindex, ITEM_EFFECTSTRING, "攻 +2 防 +2 敏 -2 魅 +1"); break; // 皮的手环(红) + case 1204: ITEM_setChar( itemindex, ITEM_EFFECTSTRING, "攻 -2 防 +2 敏 +2 魅 +1"); break; // 皮的手环(绿) + case 1205: ITEM_setChar( itemindex, ITEM_EFFECTSTRING, "攻 +2 防 -2 敏 +2 魅 +1"); break; // 皮的手环(青) + case 1483: ITEM_setInt( itemindex, ITEM_MODIFYCHARM, 5); break; // 库沙达号角 + case 20147: ITEM_setChar(itemindex,ITEM_INGNAME0,"木"); ITEM_setChar(itemindex,ITEM_INGNAME1,"骨"); ITEM_setInt(itemindex,ITEM_INGVALUE0, 1125 ); ITEM_setInt(itemindex,ITEM_INGVALUE1, 1125 ); break; // 双头叉 + default: + break; + } + } +} + + +#ifdef _NPCSERVER_NEW +BOOL NPCSERVER_CreateObjindexFromServer( int fd, int npcindex, char *Name, int image, + int dir, int floor, int x, int y) +{ + int objindex; + Object obj; + + obj.type = OBJTYPE_NPCSCHARA; + obj.index= -1; + memset( obj.objname, 0, sizeof( obj.objname)); + memcpy( obj.objname, Name, strlen( Name)+1); + obj.npcsindex = npcindex; + obj.imagenum = image; + obj.dir = dir; + obj.x = x; + obj.y = y; + obj.floor = floor; + objindex = initObjectOne( &obj ); + if( objindex == -1 ){ + return FALSE; + } + + return TRUE; +} +#endif + +#ifdef _PET_LOSTPET +BOOL CHAR_CharSaveLostPet( int petindex, int type)//地上0 溜宠 1 宠邮 2 +{ + int lv, cost=0; + char* CdKey=NULL; + char* Uniquecode; + char* petname; + + char lostpetstring[1024*2]; + char *petstring; + + if( !CHAR_CHECKINDEX( petindex) ) return FALSE; +//存入 + petstring = CHAR_makePetStringFromPetIndex( petindex); + if( petstring == NULL ) return FALSE; + CdKey = CHAR_getChar( petindex, CHAR_OWNERCDKEY); + if( CdKey == NULL ) return FALSE; + Uniquecode = CHAR_getChar( petindex, CHAR_UNIQUECODE); + if( Uniquecode == NULL ) return FALSE; + lv = CHAR_getInt( petindex, CHAR_LV); + petname = CHAR_getChar( petindex, CHAR_NAME); + + if( type == 1 ){ + cost = lv*300; + }else if( type == 2){ + cost = lv*1000; + }else{ + cost = lv*10000; + } + + sprintf( lostpetstring, "%s|%s|%d|%d|%s|%d#%s#%d", + CdKey, petname, lv, cost, Uniquecode, (int)time( NULL), petstring, + type); + + print("保存最后宠物:%s-%d\n", lostpetstring, strlen(lostpetstring)); + { + char buf[10][2048]={"","","","","","","","","",""}; + char line[2048]; + int count=0, i, start=0; + FILE *fp=NULL; + char filename[256]; + +/* + sprintf( filename, "lostpet/%s.txt", CdKey); + if( (fp=fopen( filename, "a+")) != NULL ){ + fprintf( fp, "%s\n", petstring); + fclose( fp); + }else{ + print("Can't Add %s \n", filename); + } + +*/ + + + sprintf( filename, "lostpet/%s.txt", CdKey); + if( (fp=fopen( filename, "r")) != NULL ){ + while( fgets( line , sizeof( line ) , fp ) && count < 7){ + if( strlen(line) <= 0 ) continue; + strcpy( buf[ count++] , line); + } + fclose( fp); + }else{ + print("Can't Read %s \n", filename); + } + + if( (fp=fopen( filename, "w+")) == NULL ){ + print("Can't Write %s \n", filename); + return FALSE; + } + if( strlen( buf[ 6]) > 0 ){ + start=2; + } + for( i=start; i<7; i++){ + if( strlen( buf[i]) > 0 ) { + print("Write %s \n", buf[i]); + fprintf( fp, "%s", buf[i]); + } + } + fprintf( fp, "%s\n", lostpetstring); + + fclose( fp); + } + return TRUE; +} +/* +while( fgets( line , sizeof( line ) , fp ) && count < 7){ +*/ +#endif + +#ifdef _ALLDOMAN +void InitHeroList( void) +{ + saacproto_UpdataStele_send ( acfd , "FirstLoad", "LoadHerolist" , "华义" , 0 , 0 , 0 , 999 ) ; +} +#endif + +#ifdef _STREET_VENDOR +void CHAR_sendStreetVendor(int charaindex,char *message) +{ + char szAction[2],szTemp[21],szMessage[4]; + int count = 0,i,j,iItemIndex = 0,iPetIndex = 0,iPileNum = 0,iMaxPileNum = 0; + int ix,iy,iPlayerNum = 0,tofd = -1,objbuf[16]; + + if(!getStringFromIndexWithDelim(message,"|",1,szAction,sizeof(szAction))) return; + // 开启摆摊介面 + if(szAction[0] == 'O'){ + CHAR_getCoordinationDir(CHAR_getInt(charaindex,CHAR_DIR),CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y),1,&ix,&iy); + // 取得前方玩家数量 + iPlayerNum = CHAR_getSameCoordinateObjects(objbuf,arraysizeof(objbuf),CHAR_getInt(charaindex,CHAR_FLOOR),ix,iy); + // 没有人 + if(iPlayerNum == 0){ + // 检查自己站的座标有没有人也在摆摊 + iPlayerNum = CHAR_getSameCoordinateObjects(objbuf,arraysizeof(objbuf), + CHAR_getInt(charaindex,CHAR_FLOOR), + CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y)); + // 不只自己一个人 + if(iPlayerNum > 1){ + // 检查别人有没有摆摊 + for(i=0;i 0){ + if(CHAR_getWorkInt(charaindex,CHAR_WORKSTREETVENDOR) == 1){ + // 修改内容中设成未摆摊 + CHAR_setWorkInt(charaindex,CHAR_WORKSTREETVENDOR,-1); + CHAR_sendStreetVendorDataToCli(charaindex,charaindex); + } + // 已在交易中但要改内容,关闭对方视窗 + else if(CHAR_getWorkInt(charaindex,CHAR_WORKSTREETVENDOR) == 2){ + int toindex = CHAR_getWorkInt(charaindex,CHAR_WORKSTREETVENDOR_WHO); + + if(toindex != -1 && CHAR_CHECKINDEX(toindex)){ + CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR,-1); + CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR_WHO,-1); + lssproto_STREET_VENDOR_send(getfdFromCharaIndex(toindex),"C|"); + CHAR_talkToCli(toindex,-1,"店家取消交易",CHAR_COLORYELLOW); + CHAR_setWorkInt(charaindex,CHAR_WORKSTREETVENDOR_WHO,-1); + // 清除交易图示 + CHAR_sendTradeEffect(charaindex,0); + CHAR_sendTradeEffect(toindex,0); + } + // 修改内容中,设成未摆摊 + CHAR_setWorkInt(charaindex,CHAR_WORKSTREETVENDOR,-1); + CHAR_sendStreetVendorDataToCli(charaindex,charaindex); + } + return; + } + // 检查对方是否卖完 + for(j=0;j 0){ + if(CHAR_getWorkInt(charaindex,CHAR_WORKSTREETVENDOR) == 1){ + // 修改内容中设成未摆摊 + CHAR_setWorkInt(charaindex,CHAR_WORKSTREETVENDOR,-1); + CHAR_sendStreetVendorDataToCli(charaindex,charaindex); + } + // 已在交易中但要改内容,关闭对方视窗 + else if(CHAR_getWorkInt(charaindex,CHAR_WORKSTREETVENDOR) == 2){ + int toindex = CHAR_getWorkInt(charaindex,CHAR_WORKSTREETVENDOR_WHO); + + if(toindex != -1 && CHAR_CHECKINDEX(toindex)){ + CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR,-1); + CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR_WHO,-1); + lssproto_STREET_VENDOR_send(getfdFromCharaIndex(toindex),"C|"); + CHAR_talkToCli(toindex,-1,"店家取消交易",CHAR_COLORYELLOW); + CHAR_setWorkInt(charaindex,CHAR_WORKSTREETVENDOR_WHO,-1); + // 清除交易图示 + CHAR_sendTradeEffect(charaindex,0); + CHAR_sendTradeEffect(toindex,0); + } + // 修改内容中,设成未摆摊 + CHAR_setWorkInt(charaindex,CHAR_WORKSTREETVENDOR,-1); + CHAR_sendStreetVendorDataToCli(charaindex,charaindex); + } + } + // 设定成摆摊 + else{ + sprintf(szMessage,"O|"); + lssproto_STREET_VENDOR_send(getfdFromCharaIndex(charaindex),szMessage); + } + return; + } + } + } + } + // 摆摊 + else if(szAction[0] == 'S'){ + int price; + + // 清除所有旧资料 + for(i=0;i 10000000) price = 10000000; + CHAR_setStreetVendor(charaindex,i,SV_PRICE,price); + } + if(!getStringFromIndexWithDelim(message,"|",6+(i-1)*3,szTemp,sizeof(szTemp))) return; + + // 检查cli端送来的资料 + for(i=0;i CHAR_getMaxHaveGold(toindex)){ + // 身上不够放,存入个人银行 + if(CHAR_getInt(toindex,CHAR_BANKGOLD) + iPrice > CHAR_MAXBANKGOLDHAVE){ + CHAR_talkToCli(charaindex,-1,"店家放不下石币了,交易取消。",CHAR_COLORRED); + CHAR_talkToCli(toindex,-1,"你身上及个人银行存款已满",CHAR_COLORRED); + break; + } + CHAR_talkToCli(toindex,-1,"贩卖所得已存入个人银行",CHAR_COLORRED); + bPutToBank = TRUE; + } + // 若是道具 + if(iKind == 0){ + iItemIndex = CHAR_getItemIndex(toindex,iFieldIndex); + // 道具不存在 + if(!ITEM_CHECKINDEX(iItemIndex)){ + CHAR_clearStreetVendor(toindex,iBuyIndex); + printf("\nCHAR_sendStreetVendor(B):找不到道具!!!!!!!\n"); + continue; + } + // 丢在地上会消失的道具不可贩卖 + if(ITEM_getInt(iItemIndex,ITEM_VANISHATDROP) == 1){ + CHAR_clearStreetVendor(toindex,iBuyIndex); + CHAR_talkToCli(charaindex,-1,"丢在地上会消失的道具不可贩卖,该选项取消",CHAR_COLORYELLOW); + CHAR_talkToCli(toindex,-1,"侦测到有丢在地上会消失的道具在贩卖,帐号已记录!",CHAR_COLORRED); + LogStreetVendor( + CHAR_getUseName(toindex), + CHAR_getUseID(toindex), + "", + "", + ITEM_getChar(iItemIndex,ITEM_NAME), + -1, + iPrice, + "StreetVendor(卖方改封包)", + CHAR_getInt(toindex,CHAR_FLOOR), + CHAR_getInt(toindex,CHAR_X), + CHAR_getInt(toindex,CHAR_Y), + -1,-1,-1, + ITEM_getChar(iItemIndex,ITEM_UNIQUECODE) + ); + continue; + } + // 议价物品不能卖 + if(iPrice == 0){ + LogStreetVendor( + CHAR_getUseName(toindex), + CHAR_getUseID(toindex), + CHAR_getUseName(charaindex), + CHAR_getUseID(charaindex), + ITEM_getChar(iItemIndex,ITEM_NAME), + -1, + iPrice, + "StreetVendor(买方改封包)", + CHAR_getInt(toindex,CHAR_FLOOR), + CHAR_getInt(toindex,CHAR_X), + CHAR_getInt(toindex,CHAR_Y), + CHAR_getInt(charaindex,CHAR_FLOOR), + CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y), + ITEM_getChar(iItemIndex,ITEM_UNIQUECODE) + ); + continue; + } + // 检查物品堆叠 + iPileNum = ITEM_getInt(iItemIndex,ITEM_USEPILENUMS); + // 买方最大堆叠数 + iMaxPileNum = CHAR_getMyMaxPilenum(charaindex); + // 若物品的堆叠数比身上的最大堆叠数少,把卖方的物品清掉,把物品新增至买方 + if(iPileNum - iMaxPileNum <= 0){ + if(!ITEM_CHECKINDEX(iItemIndex)){ + CHAR_talkToCli(charaindex,-1,"交易失败(1)。",CHAR_COLORRED); + break; + } +#ifdef _ITEM_PILENUMS + // 道具数量为0 + if(ITEM_getInt(iItemIndex,ITEM_USEPILENUMS) <= 0){ + CHAR_talkToCli(charaindex,-1,"交易失败(2)。",CHAR_COLORRED); + break; + } +#endif + // 新增买方的 + if((iRet = CHAR_addItemSpecificItemIndex(charaindex,iItemIndex)) >= CHAR_MAXITEMHAVE){ + CHAR_talkToCli(charaindex,-1,"道具栏满了。",CHAR_COLORRED); + break; + } + CHAR_sendItemDataOne(charaindex,iRet); + // 清掉卖方的 + CHAR_setItemIndex(toindex,iFieldIndex,-1); + CHAR_sendItemDataOne(toindex,iFieldIndex); + CHAR_clearStreetVendor(toindex,iBuyIndex); + // 扣钱 + CHAR_setInt(charaindex,CHAR_GOLD,CHAR_getInt(charaindex,CHAR_GOLD) - iPrice); + CHAR_send_P_StatusString(charaindex,CHAR_P_STRING_GOLD); + // 加钱 + if(bPutToBank) CHAR_setInt(toindex,CHAR_BANKGOLD,CHAR_getInt(toindex,CHAR_BANKGOLD) + iPrice); + else CHAR_setInt(toindex,CHAR_GOLD,CHAR_getInt(toindex,CHAR_GOLD) + iPrice); + CHAR_send_P_StatusString(toindex,CHAR_P_STRING_GOLD); + sprintf(szMsg,"道具 %s 交易完成",ITEM_getChar(iItemIndex,ITEM_NAME)); + CHAR_talkToCli(charaindex,-1,szMsg,CHAR_COLORWHITE); + sprintf(szMsg,"%s 买走了道具 %s",CHAR_getUseName(charaindex),ITEM_getChar(iItemIndex,ITEM_NAME)); + CHAR_talkToCli(toindex,-1,szMsg,CHAR_COLORWHITE); + LogStreetVendor( + CHAR_getUseName(toindex), + CHAR_getUseID(toindex), + CHAR_getUseName(charaindex), + CHAR_getUseID(charaindex), + ITEM_getChar(iItemIndex,ITEM_NAME), + -1, + iPrice, + "StreetVendor(道具)", + CHAR_getInt(toindex,CHAR_FLOOR), + CHAR_getInt(toindex,CHAR_X), + CHAR_getInt(toindex,CHAR_Y), + CHAR_getInt(charaindex,CHAR_FLOOR), + CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y), + ITEM_getChar(iItemIndex,ITEM_UNIQUECODE) + ); + } + else CHAR_talkToCli(charaindex,-1,"身上堆叠数上限不足。",CHAR_COLORRED); + } + // 若是宠物 + else if(iKind == 1){ + int iEmptyPetField; + + iPetIndex = CHAR_getCharPet(toindex,iFieldIndex); + // 宠物不存在 + if(!CHAR_CHECKINDEX(iPetIndex)){ + CHAR_clearStreetVendor(toindex,iBuyIndex); + printf("\nCHAR_sendStreetVendor(B):找不到宠物!!!!!!!\n"); + continue; + } + if(CHAR_getInt(iPetIndex,CHAR_PETFAMILY) == 1){ + CHAR_talkToCli(charaindex,-1,"家族守护兽无法贩卖,该选项取消",CHAR_COLORYELLOW); + CHAR_clearStreetVendor(toindex,iBuyIndex); + LogStreetVendor( + CHAR_getUseName(toindex), + CHAR_getUseID(toindex), + "", + "", + CHAR_getChar(iPetIndex,CHAR_NAME), + -1, + iPrice, + "StreetVendor(卖方改封包)", + CHAR_getInt(toindex,CHAR_FLOOR), + CHAR_getInt(toindex,CHAR_X), + CHAR_getInt(toindex,CHAR_Y), + -1,-1,-1, + CHAR_getChar(iPetIndex,CHAR_UNIQUECODE) + ); + continue; + } + if(CHAR_getInt(toindex,CHAR_RIDEPET) == CHAR_getStreetVendor(toindex,iBuyIndex,SV_INDEX)){ + CHAR_talkToCli(charaindex,-1,"骑乘中的宠物无法贩卖,该选项取消",CHAR_COLORYELLOW); + CHAR_clearStreetVendor(toindex,iBuyIndex); + LogStreetVendor( + CHAR_getUseName(toindex), + CHAR_getUseID(toindex), + "", + "", + CHAR_getChar(iPetIndex,CHAR_NAME), + -1, + iPrice, + "StreetVendor(卖方改封包)", + CHAR_getInt(toindex,CHAR_FLOOR), + CHAR_getInt(toindex,CHAR_X), + CHAR_getInt(toindex,CHAR_Y), + -1,-1,-1, + CHAR_getChar(iPetIndex,CHAR_UNIQUECODE) + ); + continue; + } + + // 议价物品不能卖 + if(iPrice == 0){ + LogStreetVendor( + CHAR_getUseName(toindex), + CHAR_getUseID(toindex), + CHAR_getUseName(charaindex), + CHAR_getUseID(charaindex), + CHAR_getChar(iPetIndex,CHAR_NAME), + -1, + iPrice, + "StreetVendor(买方改封包)", + CHAR_getInt(toindex,CHAR_FLOOR), + CHAR_getInt(toindex,CHAR_X), + CHAR_getInt(toindex,CHAR_Y), + CHAR_getInt(charaindex,CHAR_FLOOR), + CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y), + CHAR_getChar(iPetIndex,CHAR_UNIQUECODE) + ); + continue; + } + // 检查玩家有无装备驯兽戒指,检查玩家有没有转生过 + if(CHAR_getWorkInt(charaindex,CHAR_PickAllPet) == FALSE && CHAR_getInt(charaindex,CHAR_TRANSMIGRATION) < 1){ + // 检查玩家等级有没有比宠物高 + if(CHAR_getInt(iPetIndex,CHAR_LV) > (CHAR_getInt(charaindex,CHAR_LV) + 5)){ + CHAR_talkToCli(charaindex,-1,"你无法照顾该宠物。",CHAR_COLORRED); + continue; + } + } + // 以下是宠物交换 + iEmptyPetField = CHAR_getCharPetElement(charaindex); + // 身上有空栏位 + if(iEmptyPetField > -1){ + // 清卖方 + CHAR_setCharPet(toindex,iFieldIndex,-1); + CHAR_clearStreetVendor(toindex,iBuyIndex); + sprintf(szMsg,"K%d",iFieldIndex); + CHAR_sendStatusString(toindex,szMsg); + // 设定买方 + CHAR_setCharPet(charaindex,iEmptyPetField,iPetIndex); + CHAR_setWorkInt(iPetIndex,CHAR_WORKPLAYERINDEX,charaindex); + CHAR_setChar(iPetIndex,CHAR_OWNERCDKEY,CHAR_getChar(charaindex,CHAR_CDKEY)); + CHAR_setChar(iPetIndex,CHAR_OWNERCHARANAME,CHAR_getChar(charaindex,CHAR_NAME)); + CHAR_complianceParameter(iPetIndex); + sprintf(szMsg,"K%d",iEmptyPetField); + CHAR_sendStatusString(charaindex,szMsg); + sprintf(szMsg,"W%d",iEmptyPetField); + CHAR_sendStatusString(charaindex,szMsg); + // 扣钱 + CHAR_setInt(charaindex,CHAR_GOLD,CHAR_getInt(charaindex,CHAR_GOLD) - iPrice); + CHAR_send_P_StatusString(charaindex,CHAR_P_STRING_GOLD); + // 加钱 + if(bPutToBank) CHAR_setInt(toindex,CHAR_BANKGOLD,CHAR_getInt(toindex,CHAR_BANKGOLD) + iPrice); + else CHAR_setInt(toindex,CHAR_GOLD,CHAR_getInt(toindex,CHAR_GOLD) + iPrice); + CHAR_send_P_StatusString(toindex,CHAR_P_STRING_GOLD); + sprintf(szMsg,"%s 买走了宠物 %s",CHAR_getUseName(charaindex),CHAR_getChar(iPetIndex,CHAR_NAME)); + CHAR_talkToCli(charaindex,-1,szMsg,CHAR_COLORWHITE); + sprintf(szMsg,"宠物 %s 交易完成!",CHAR_getChar(iPetIndex,CHAR_NAME)); + CHAR_talkToCli(toindex,-1,szMsg,CHAR_COLORWHITE); + LogStreetVendor( + CHAR_getUseName(toindex), + CHAR_getUseID(toindex), + CHAR_getUseName(charaindex), + CHAR_getUseID(charaindex), + CHAR_getChar(iPetIndex,CHAR_NAME), + CHAR_getInt(iPetIndex,CHAR_LV), + iPrice, + "StreetVendor(宠物)", + CHAR_getInt(toindex,CHAR_FLOOR), + CHAR_getInt(toindex,CHAR_X), + CHAR_getInt(toindex,CHAR_Y), + CHAR_getInt(charaindex,CHAR_FLOOR), + CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y), + CHAR_getChar(iPetIndex,CHAR_UNIQUECODE) + ); + } + // 玩家宠物栏位满了 + else CHAR_talkToCli(charaindex,-1,"身上宠物栏栏位不足!",CHAR_COLORRED); + } + // 错的内容 + else{ + CHAR_clearStreetVendor(toindex,iBuyIndex); + printf("\nCHAR_sendStreetVendor(B):错的内容!!!!!!!\n"); + } + } + // 卖方设定为摆摊,清除买方状态 + CHAR_setWorkInt(charaindex,CHAR_WORKSTREETVENDOR,-1); + CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR,1); + // 清除交易图示 + CHAR_sendTradeEffect(charaindex,0); + CHAR_sendTradeEffect(toindex,0); + CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR_WHO,-1); + CHAR_setWorkInt(charaindex,CHAR_WORKSTREETVENDOR_WHO,-1); + } + else printf("StreetVendor交易找不到对方(%s)\n",CHAR_getChar(charaindex,CHAR_NAME)); + } +} + +void CHAR_sendStreetVendorDataToCli(int charaindex,int toindex) +{ + int i,count = 0; + + // 送贩卖内容给玩家自己,要修改贩卖内容 + if(charaindex == toindex){ + char szMsg[512],szTemp[512],szTemp1[16]; + + memset(szTemp,0,sizeof(szTemp)); + for(i=0;i=48){ + for(j=0;j 0 && strlen(CHAR_getChar(charaindex,CHAR_TEACHER_NAME)) > 0) bHasTeacher = TRUE; + // 检查正前方有没有人 + CHAR_getCoordinationDir(CHAR_getInt(charaindex,CHAR_DIR),CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y),1,&ix,&iy); + // 取得前方玩家数量 + iPlayerNum = CHAR_getSameCoordinateObjects(objbuf,arraysizeof(objbuf),CHAR_getInt(charaindex,CHAR_FLOOR),ix,iy); + // 没有人 + if(iPlayerNum == 0){ + // 已有导师,显示导师资料 + if(bHasTeacher){ + // 向 ac 要资料 + saacproto_ACCheckCharacterOnLine_send(acfd,charaindex,CHAR_getChar(charaindex,CHAR_TEACHER_ID), + CHAR_getChar(charaindex,CHAR_TEACHER_NAME), + R_F_TEACHER_SYSTEM); + } + // 没有导师,显示说明 + else lssproto_TEACHER_SYSTEM_send(getfdFromCharaIndex(charaindex),"M|"); + } + // 有人 + else{ + // 已有导师 + if(bHasTeacher){ + // 请玩家先取消原本的导师再进行找新导师动作 + CHAR_talkToCli(charaindex,-1,"请先取消原本的导师再找其他人作为你的导师",CHAR_COLORRED); + } + else{ + int objindex,index; + char szFindName[256]; + + if(iPlayerNum == 1){ + // 询问是否要对方当你的导师 + objindex = objbuf[0]; + index = OBJECT_getIndex(objindex); + + if(OBJECT_getType(objindex) != OBJTYPE_CHARA) break; + if(CHAR_getInt(index,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER) break; + if(index == charaindex) break; + // 检查对方是否为自己的学生 + if(strcmp(CHAR_getChar(index,CHAR_TEACHER_ID),CHAR_getChar(charaindex,CHAR_CDKEY)) == 0 && + strcmp(CHAR_getChar(index,CHAR_TEACHER_NAME),CHAR_getChar(charaindex,CHAR_NAME)) == 0){ + CHAR_talkToCli(charaindex,-1,"对方为你的学生,无法让对方成为你的导师",CHAR_COLORRED); + break; + } + sprintf(szMsg,"C|%s|%d",CHAR_getChar(index,CHAR_NAME),index); + lssproto_TEACHER_SYSTEM_send(getfdFromCharaIndex(charaindex),szMsg); + } + // 超过一人,询问要找谁当导师 + else{ + int iGetNum = 0; + char szBuf[1024]; + + memset(szBuf,0,sizeof(szBuf)); + for(i=0;i 0 && tickettime > nowtime+20 ) { + continue; + } + // 时限不到20秒 + else if( tickettime < nowtime+20 && tickettime >= nowtime ) { + sprintf( msg, "时间票剩馀时间%d秒。", tickettime - nowtime); + CHAR_talkToCli( i, -1, msg, CHAR_COLORYELLOW); + } + + // 超过时限 + else if( tickettime < nowtime ) { + int floor, x, y; + int totaltime; + char msg[1024]; + if( CHAR_getWorkInt( i, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE) { + CHAR_talkToCli( i, -1, "时间已到,谢谢光顾。", CHAR_COLORYELLOW); + if( CHAR_getWorkInt( i, CHAR_WORKTICKETTIMESTART) > 0 ) { + totaltime = nowtime - CHAR_getWorkInt( i, CHAR_WORKTICKETTIMESTART); + sprintf( msg, "总入场时间%d分%d秒。", totaltime/60, totaltime%60); + CHAR_talkToCli( i, -1, msg, CHAR_COLORYELLOW); + } + CHAR_setWorkInt( i, CHAR_WORKTICKETTIME, 0); + CHAR_setWorkInt( i, CHAR_WORKTICKETTIMESTART, 0); + /* + if( CHAR_getElderPosition( CHAR_getInt( i, CHAR_LASTTALKELDER), &floor, &x, &y ) != TRUE ) { + CHAR_warpToSpecificPoint( i, 1006, 15, 15); + } + else { + CHAR_warpToSpecificPoint( i, floor, x, y); + } + */ + CHAR_warpToSpecificPoint( i, 7001, 41, 6); + } + else { + CHAR_talkToCli( i, -1, "时间已到,将於战斗结束时离开。", CHAR_COLORYELLOW); + // 移至 BATTLE_Exit() 处理 + } + } + } + +} +#endif diff --git a/gmsv/char/char.c.bak b/gmsv/char/char.c.bak new file mode 100644 index 0000000..bab9417 --- /dev/null +++ b/gmsv/char/char.c.bak @@ -0,0 +1,8701 @@ +#include "version.h" +#include +#include +#include +#include // shan +#include +#include +#include +#include +#include "common.h" +#include "char_base.h" +#include "char_data.h" +#include "char.h" +#include "lssproto_serv.h" +#include "item.h" +#include "item_event.h" +#include "buf.h" +#include "object.h" +#include "map_deal.h" +#include "saacproto_cli.h" +#include "readmap.h" +#include "handletime.h" +#include "char_event.h" +#include "npccreate.h" +#include "addressbook.h" +#include "item_event.h" +#include "magic_base.h" +#include "magic.h" +#include "chatmagic.h" +#include "configfile.h" +#include "log.h" +#include "anim_tbl.h" +#include "encount.h" +#include "battle.h" +#include "pet_skill.h" +#include "util.h" +#include "enemy.h" +#include "npcutil.h" +#include "pet.h" +#include "family.h" +#include "defend.h" +#ifdef _NPCSERVER_NEW +#include "npcserver.h" +#endif +#ifdef _DEATH_CONTEND +#include "deathcontend.h" +#endif +#include "correct_bug.h" +#ifdef _JOBDAILY +#include "npc_checkman.h" +#endif + +#ifdef _CHAR_PROFESSION // WON ADD 人物职业栏位 +#include "profession_skill.h" +#endif +#ifdef _CHATROOMPROTOCOL // (不可开) Syu ADD 聊天室频道 +#include "chatroom.h" +#endif + +extern int channelMember[FAMILY_MAXNUM][FAMILY_MAXCHANNEL][FAMILY_MAXMEMBER]; +extern int familyMemberIndex[FAMILY_MAXNUM][FAMILY_MAXMEMBER]; + +extern tagRidePetTable ridePetTable[146]; +extern int BATTLE_getRidePet( int charaindex ); + +#ifdef _CHANNEL_MODIFY +extern int InitOccChannel(void); +#endif + +#ifdef _ANGEL_SUMMON +extern int checkIfAngelByName( char* nameinfo); +extern char* getMissionNameInfo( int charaindex, char* nameinfo); +extern void CHAR_sendAngelMark( int objindex, int flag); +extern int checkIfOnlyAngel( int charaindex); +extern void selectAngel( int charaindex, int heroindex, int mission, int gm_cmd); +#endif + +extern void GOLD_DeleteTimeCheckOne( int objindex); + +// WON ADD 修正道具的设定问题 +void fix_item_bug(int charaindex, int i); + + +/*====================平乓仿及综岳卞楮允月楮醒====================*/ +/*------------------------------------------------------------ + * 综岳允月凛及左皿扑亦件及袄毛涩烂仄方丹午允月[ + * 娄醒 + * ch Char* 涩烂燮及平乓仿及犯□正 + * option char* 弁仿奶失件玄井日仁月犯□正 + * 忒曰袄 + * 岳 TRUE + * 撩 FALSE + ------------------------------------------------------------*/ +static BOOL CHAR_makeCharFromOptionAtCreate( Char* ch , + int vital, int str, int tgh, int dex, + int earth, int water, int fire, int wind) +{ + + /* 躲岭及腹据毛垫丹 */ + int para[4]; + int attr[4]; + int i; + int parasum,attrsum; + int cnt; + + para[0] = vital; + para[1] = str; + para[2] = tgh; + para[3] = dex; + + attr[0] = earth; + attr[1] = water; + attr[2] = fire; + attr[3] = wind; + +#define MAXPARAMETER 20 +#define PKMAXPARAMETER 300 + parasum = 0; + /* + * 允屯化及犯□正及 卞 - 反丐匀化反卅日卅中仄 + * 瑕丐孔木及仪毛哔尹化云中化 及袄手译尹卅中 + */ + + for( i = 0; i < arraysizeof( para); i ++ ) { + if( para[i] < 0 || para[i] > MAXPARAMETER )return FALSE; + parasum += para[i]; + } +#ifdef _NEW_PLAYER_CF //新手出生配置 + if( parasum > MAXPARAMETER ) return FALSE; +#else + if( parasum != MAXPARAMETER ) return FALSE; +#endif + +/*#ifdef _NEW_TESTSERVER //测试伺服 + if( parasum > MAXPARAMETER ) return FALSE; +#else + if( parasum != MAXPARAMETER ) return FALSE; +#endif*/ + + +#undef MAXPARAMETER + + +#define MAXATTRIBUTE 10 + cnt = 0; + attrsum = 0; + /* 箪岭及民尼永弁毛允月 */ + for( i = 0; i < arraysizeof( para); i ++ ) { + if( attr[i] < 0 || attr[i] > MAXATTRIBUTE )return FALSE; + attrsum += attr[i]; + if( attr[i] > 0 ) cnt ++; + } + /* 宁煌袄反10 */ + if( attrsum != MAXATTRIBUTE ) return FALSE; + + /* 2勾方曰聂仁喃曰癫化日木化中凶日蛲 */ + if( cnt > 2 ) return FALSE; + + /* 菅箪岭反喃曰癫化日木卅中 */ + if( attr[0] > 0 && attr[2] > 0 ) return FALSE; + if( attr[1] > 0 && attr[3] > 0 ) return FALSE; + +#undef MAXATTRIBUTE + + /* 戊疋□ */ + ch->data[CHAR_VITAL] = vital*100; + ch->data[CHAR_STR] = str*100; + ch->data[CHAR_TOUGH] = tgh*100; + ch->data[CHAR_DEX] = dex*100; + + ch->data[CHAR_EARTHAT] = attr[0] * 10; + ch->data[CHAR_WATERAT] = attr[1] * 10; + ch->data[CHAR_FIREAT] = attr[2] * 10; + ch->data[CHAR_WINDAT] = attr[3] * 10; +#ifdef _NEWOPEN_MAXEXP + ch->data[CHAR_OLDEXP] = 0; +#endif + ch->data[CHAR_EXP] = 0; + + +#ifdef _NEW_PLAYER_CF //新手出生配置 + ch->data[CHAR_TRANSMIGRATION] = getNewplayertrans(); + ch->data[CHAR_GOLD] = getNewplayergivegold();; + ch->data[CHAR_LV] = getNewplayerlv();//120; +// ch->data[CHAR_LEARNRIDE] = 200; +// ch->data[CHAR_LASTTALKELDER] = (rand()%10)>5?35:36;//34; +// ch->data[CHAR_SKILLUPPOINT] = 616;//600; +#ifdef _75_TEST + ch->data[CHAR_TRANSEQUATION] = (100 << 16) + 650; +#endif +#ifdef _NEW_RIDEPETS + //ch->data[CHAR_LOWRIDEPETS] = 0xffffffff; +#endif +#endif + +/*#ifdef _NEW_TESTSERVER //测试伺服 + ch->data[CHAR_SKILLUPPOINT] = "";//600; + ch->data[CHAR_TRANSMIGRATION] = 5; + ch->data[CHAR_GOLD] = CHAR_MAXGOLDHAVE; + ch->data[CHAR_LV] = 140;//120; + ch->data[CHAR_LEARNRIDE] = 200; +// ch->data[CHAR_LASTTALKELDER] = (rand()%10)>5?35:36;//34; + ch->data[CHAR_SKILLUPPOINT] = 616;//600; +#ifdef _75_TEST + ch->data[CHAR_TRANSEQUATION] = (100 << 16) + 650; +#endif +#ifdef _NEW_RIDEPETS + //ch->data[CHAR_LOWRIDEPETS] = 0xffffffff; +#endif +#endif*/ + +#ifdef _PETSKILL_BECOMEPIG + ch->data[CHAR_BECOMEPIG] = -1; + ch->data[CHAR_BECOMEPIG_BBI] = 100250; +#endif + + ch->data[CHAR_LASTLEAVETIME] = 0; + + return TRUE; +} + +#ifdef _HELP_NEWHAND +void CHAR_loginAddItemForNew( int charindex ) +{ + int emptyitemindexinchara, itemindex; + int i; + + char msgbuf[128]; + + for( i = 0; i < 15; i ++ ) { + emptyitemindexinchara = CHAR_findEmptyItemBox( charindex ); + + if( emptyitemindexinchara < 0 ){ + sprintf( msgbuf, "空间栏位不足。" ); + + CHAR_talkToCli( charindex, -1, msgbuf, CHAR_COLORYELLOW); + return; + } + if(getNewplayergiveitem(i)==-1)continue; + itemindex = ITEM_makeItemAndRegist( getNewplayergiveitem(i) ); + + if( itemindex != -1 ){ + CHAR_setItemIndex( charindex, emptyitemindexinchara, itemindex ); + ITEM_setWorkInt(itemindex, ITEM_WORKOBJINDEX,-1); + ITEM_setWorkInt(itemindex, ITEM_WORKCHARAINDEX,charindex); + CHAR_sendItemDataOne( charindex, emptyitemindexinchara); + } + } + print("Get New Hand Item"); +} +#endif + +void CHAR_createNewChar( int clifd, int dataplacenum, char* charname , + int imgno,int faceimgno, + int vital,int str,int tgh,int dex, + int earth,int water,int fire,int wind, + int hometown , char *cdkey ) +{ + + Char ch, *chwk; + int charaindex, petindex; + int enemyarray; + char szKey[256]; + +/*#ifdef _NEW_TESTSERVER //测试伺服 + int add_pet[]={0,0,0,0,0}; +#endif*/ + +#ifdef _NEW_PLAYER_CF //新手出生配置 + int add_pet[]={0,0,0,0,0}; +#endif + +#ifdef _DELBORNPLACE //Syu ADD 6.0 统一出生於新手村 + int BornPet = hometown; + if( getMuseum() ) + hometown = 1; +#endif + memset(&ch,0,sizeof(Char)); + + if( !CHAR_checkPlayerImageNumber( imgno)) { + lssproto_CreateNewChar_send( clifd ,FAILED, "" ); + CONNECT_setState( clifd, NOTLOGIN ); + return; + } + if( !CHAR_checkFaceImageNumber( imgno, faceimgno)) { + lssproto_CreateNewChar_send( clifd ,FAILED, "" ); + CONNECT_setState( clifd, NOTLOGIN ); + return; + } + CHAR_getDefaultChar(&ch,imgno); + ch.data[CHAR_WALKINTERVAL] = getWalksendinterval(); + + if( CHAR_getInitElderPosition( &ch ,hometown) == FALSE ){ + lssproto_CreateNewChar_send( clifd ,FAILED, "" ); + CONNECT_setState( clifd, NOTLOGIN ); + return; + + }else if( MAP_checkCoordinates( ch.data[CHAR_FLOOR], ch.data[CHAR_X], + ch.data[CHAR_Y] ) == FALSE ){ + lssproto_CreateNewChar_send( clifd ,FAILED, ""); + CONNECT_setState( clifd, NOTLOGIN ); + return; + } + strcpysafe( ch.string[CHAR_NAME].string , + sizeof(ch.string[CHAR_NAME].string), + charname); + + if( CHAR_getNewImagenumberFromEquip( imgno,0) == -1 ){ + lssproto_CreateNewChar_send( clifd ,FAILED, ""); + CONNECT_setState( clifd, NOTLOGIN ); + return; + } + ch.data[CHAR_BASEIMAGENUMBER] = imgno; + ch.data[CHAR_BASEBASEIMAGENUMBER] = imgno; + ch.data[CHAR_FACEIMAGENUMBER] = faceimgno; + ch.data[CHAR_DATAPLACENUMBER] = dataplacenum; + +#ifdef _FM_JOINLIMIT + ch.data[CHAR_FMTIMELIMIT] = 0; +#endif + +#ifdef _NEWSAVE + ch.data[CHAR_SAVEINDEXNUMBER] = -1; +#endif + ch.data[CHAR_HP] = 0x7fffffff; + + ch.data[CHAR_CHARM] = 60; + ch.data[CHAR_MAXMP] = ch.data[CHAR_MP] = 100; + strcpysafe( ch.string[CHAR_CDKEY].string, + sizeof( ch.string[CHAR_CDKEY].string), cdkey ); + + // Robin 0724 + ch.data[CHAR_RIDEPET] = -1; + ch.data[CHAR_LEARNRIDE] = 0; + +#ifdef _NEW_RIDEPETS + ch.data[CHAR_LOWRIDEPETS] = 0; +#endif + +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + ch.data[CHAR_FAME] = 0; +#endif +#ifdef _NEW_MANOR_LAW + ch.data[CHAR_MOMENTUM] = 0; // 个人气势 +#endif +#ifdef _TEACHER_SYSTEM + ch.data[CHAR_TEACHER_FAME] = 0; // 导师领导声望 +#endif +#ifdef _RACEMAN + ch.data[CHAR_CHECKIN] = 0; // 宠物登记 + ch.data[CHAR_CATCHCNT1] = 0; // 新手限 猎宠次数 + ch.data[CHAR_CATCHCNT2] = 0; // 老手限 猎宠次数 + ch.data[CHAR_CATCHCNT3] = 0; // 家族限 猎宠次数 + ch.data[CHAR_CATCHCNT4] = 0; // 老手不限 猎宠次数 + ch.data[CHAR_CATCHCNT5] = 0; // 家族不限 猎宠次数 + ch.data[CHAR_KINDCNT1] = 0; + ch.data[CHAR_KINDCNT2] = 0; + ch.data[CHAR_KINDCNT3] = 0; + ch.data[CHAR_KINDCNT4] = 0; + ch.data[CHAR_KINDCNT5] = 0; + ch.data[CHAR_KINDCNT6] = 0; + ch.data[CHAR_KINDCNT7] = 0; + ch.data[CHAR_KINDCNT8] = 0; + ch.data[CHAR_KINDCNT9] = 0; + ch.data[CHAR_KINDCNT10] = 0; +#endif +#ifdef _CHAR_PROFESSION // WON ADD 人物职业 + ch.data[PROFESSION_CLASS] = 0; + ch.data[PROFESSION_LEVEL] = 0; +// ch.data[PROFESSION_EXP] = 0; + ch.data[PROFESSION_SKILL_POINT] = 0; + ch.data[ATTACHPILE] = 0; +#endif + +#ifdef _GM_IDENTIFY + sprintf(ch.string[CHAR_GMIDENTIFY].string,"%s",""); //gm名称清为空字串 +#endif +#ifdef _TEACHER_SYSTEM + memset(ch.string[CHAR_TEACHER_ID].string,0,sizeof(STRING128)); + memset(ch.string[CHAR_TEACHER_NAME].string,0,sizeof(STRING128)); +#endif + +#ifdef _ITEM_SETLOVER + memset(ch.string[CHAR_LOVERID].string,0,sizeof(STRING128)); + memset(ch.string[CHAR_LOVERNAME].string,0,sizeof(STRING128)); +#endif + +#ifdef _PETSKILL_BECOMEPIG + ch.data[CHAR_BECOMEPIG] = -1; + ch.data[CHAR_BECOMEPIG_BBI] = 100250; +#endif + + strcpysafe( ch.string[CHAR_FMNAME].string, + sizeof( ch.string[CHAR_FMNAME].string), "\0" ); + ch.data[CHAR_FMINDEX] = -1; + + if( CHAR_makeCharFromOptionAtCreate( &ch, + vital,str,tgh,dex, + earth,water,fire,wind ) == FALSE ) + { + lssproto_CreateNewChar_send( clifd ,FAILED, + "option data is invalid\n"); + CONNECT_setState( clifd, NOTLOGIN ); + return; + } + { + int mp=ch.data[CHAR_MAXMP]; + int str=ch.data[CHAR_STR]; + int tough=ch.data[CHAR_TOUGH]; + + ch.data[CHAR_INITDATA] = 2*100*100*100*100 /*+ hp*100*100*100*/ + + mp*100*100 + str* 100 + tough; + } + + charaindex = CHAR_initCharOneArray( &ch ); + if( charaindex == -1 ) { + lssproto_CreateNewChar_send( clifd ,FAILED, ""); + CONNECT_setState( clifd, NOTLOGIN ); + return; + } + +/*#ifdef _NEW_TESTSERVER //伊甸测试伺服 + { + int petTemp[]={ 2258, 1610, 353, 2474, -1}; //朱雀、 + int petNum=0; + int k=0; + int i=0,j=0; + +#ifdef _75_TEST + if( CHAR_getInt( charaindex, CHAR_LASTTALKELDER) == 1 )//玛丽娜丝 + petTemp[4] = 2;//凯比 + else if( CHAR_getInt( charaindex, CHAR_LASTTALKELDER) == 2 )//加加 + petTemp[4] = 3;//克克尔 + else if( CHAR_getInt( charaindex, CHAR_LASTTALKELDER) == 3 )//卡鲁它那 + petTemp[4] = 4;//威伯 + else + petTemp[4] = 1;//乌力 +#else + j=2; + for( i=0; i< arraysizeof(ridePetTable) ; i++ ){ + if( CHAR_getInt( charaindex, CHAR_BASEBASEIMAGENUMBER) == ridePetTable[i].charNo ){ + petTemp[j]= ridePetTable[i].petId; + j++; + if( j >= arraysizeof( petTemp) ) + break; + } + } +#endif + + j=0; + for( petNum=0; petNum 3 ) BornPet = 3; + if ( BornPet < 0 ) BornPet = 0; + enemyarray = ENEMY_getEnemyArrayFromId( BornPet + 2076); + } + else { + enemyarray = ENEMY_getEnemyArrayFromId( hometown + 1); + } +#else + enemyarray = ENEMY_getEnemyArrayFromId( hometown + 1); +#endif + petindex = ENEMY_createPetFromEnemyIndex( charaindex, enemyarray); + if( !CHAR_CHECKINDEX( petindex )){ + CHAR_endCharOneArray( charaindex); + lssproto_CreateNewChar_send( clifd ,FAILED, ""); + CONNECT_setState( clifd, NOTLOGIN ); + return; + } + CHAR_setMaxExpFromLevel( petindex, 1); + +#endif*/ + +#ifdef _NEW_PLAYER_CF //新手出生配置 + int petTemp[]={ 2258, 1610, 353, 2474, -1}; //朱雀、 + int petNum=0; + int k=0; + int i=0,j=0; + int mylevel,level; + if(getNewplayergivepet(0)==-1){ + if( CHAR_getInt( charaindex, CHAR_LASTTALKELDER) == 1 )//玛丽娜丝 + setNewplayergivepet(0,2); + else if( CHAR_getInt( charaindex, CHAR_LASTTALKELDER) == 2 )//加加 + setNewplayergivepet(0,3); + else if( CHAR_getInt( charaindex, CHAR_LASTTALKELDER) == 3 )//卡鲁它那 + setNewplayergivepet(0,4); + else + setNewplayergivepet(0,1); + } + + for( petNum=0; petNum<5; petNum++) { + if(getNewplayergivepet(petNum)==-1)continue; + enemyarray = ENEMY_getEnemyArrayFromId( getNewplayergivepet(petNum)); //白虎 + petindex = ENEMY_createPetFromEnemyIndex( charaindex, enemyarray); + if( petindex == -1 ) { + continue; + } + add_pet[j]=petindex; + mylevel = CHAR_getInt( petindex, CHAR_LV); + level = getNewplayerpetlv()-mylevel; + if(level<1)level=1; + for( k = 1; k < level; k ++ ){ //升级 + CHAR_PetLevelUp( petindex ); + CHAR_PetAddVariableAi( petindex, AI_FIX_PETLEVELUP ); + CHAR_setInt( petindex, CHAR_LV, CHAR_getInt( petindex, CHAR_LV) +1 ); + } + CHAR_complianceParameter( petindex ); + CHAR_setInt( petindex , CHAR_HP , CHAR_getWorkInt( petindex , CHAR_WORKMAXHP ) ); + } +#endif + +#ifdef _HELP_NEWHAND + CHAR_loginAddItemForNew(charaindex); +#endif + +#if 1 + if( CHAR_makeDBKey( charaindex, szKey, sizeof( szKey ) ) != FALSE ){ + int dp; + char info[512]; + snprintf( info, sizeof( info), + "%d,%d,%d,%d,%d,%d", + CHAR_getInt( charaindex, CHAR_LV), + CHAR_getInt( charaindex, CHAR_DUELBATTLECOUNT), + CHAR_getInt( charaindex, CHAR_DUELWINCOUNT), + CHAR_getInt( charaindex, CHAR_DUELLOSECOUNT), + CHAR_getInt( charaindex, CHAR_DUELSTWINCOUNT), + CHAR_getInt( charaindex, CHAR_DUELMAXSTWINCOUNT)); + dp = CHAR_getInt( charaindex, CHAR_DUELPOINT ); + saacproto_DBUpdateEntryInt_send( + acfd, + DB_DUELPOINT, + szKey, + (max(dp,0)), + info, + CONNECT_getFdid(clifd ),0 ); + } +#endif + chwk = CHAR_getCharPointer( charaindex); +#ifdef _AUTO_ADDADDRESS + { + int playernum = CHAR_getPlayerMaxNum(); + int i, k, oldnum=0, newnum=0; + i = charaindex; + for( k=0 ; k< playernum ; k++ ){ + char token[256]; + if( ++i >= playernum ) i = 0; + if( i < 0 ) i =0; + if( !CHAR_getCharUse(i) ) continue; + if( charaindex == i ) continue; + if( !CHAR_getFlg( i, CHAR_ISTRADECARD) ) continue; + if( oldnum < 3 && CHAR_getInt( i, CHAR_LV) > 100 ){ + if( ADDRESSBOOK_AutoaddAddressBook( charaindex, i) == TRUE ){ + sprintf( token, "新手-%s 加入石器,并与你交换名片。", CHAR_getUseName( charaindex)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW); + oldnum++; + } + }else if( newnum < 5 && CHAR_getInt( i, CHAR_LV) < 30 ){ + if( ADDRESSBOOK_AutoaddAddressBook( charaindex, i) == TRUE ){ + sprintf( token, "新手-%s 加入石器,并与你交换名片。", CHAR_getUseName( charaindex)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW); + newnum++; + } + } + if( newnum >= 5 && oldnum >= 3 ) + break; + } + } +#endif + +#ifdef _NEW_PLAYER_CF //新手出生配置 + + CHAR_charSaveFromConnectAndChar( clifd,chwk ,FALSE ); + CHAR_endCharData(&ch); + CHAR_endCharOneArray( charaindex); + { + int k=0; + for( k=0;kcharfunctable[i].string, + sizeof( ch->charfunctable[i]), + tmp[i]); + } +} + +void CHAR_loginAddItem( int charaindex ) +{ +/* + int emptyindex, itemindex, id; + int itemID[10]={ 20128, 20130, 20171, 20176, 20296, + 20287, 20288, 20289, 20290, 20291}; + + { + int trn_num=0; + trn_num=CHAR_getInt(charaindex,CHAR_TRANSMIGRATION); + CHAR_setInt( charaindex, CHAR_MAXPOOLITEMHAVELIMIT, 10 + (trn_num * 4) ) ; + CHAR_setInt( charaindex, CHAR_MAXPOOLPETHAVELIMIT , 5 + (trn_num * 2) ); + } + while( 1){ + emptyindex = CHAR_findEmptyItemBox( charaindex ); + if( emptyindex == -1 ) break; + id = rand()%10; + itemindex = ITEM_makeItemAndRegist( itemID[id] ); + if( !ITEM_CHECKINDEX( itemindex) ) break; + CHAR_setItemIndex( charaindex, emptyindex, itemindex); + ITEM_setWorkInt( itemindex, ITEM_WORKCHARAINDEX, charaindex); + ITEM_setWorkInt( itemindex, ITEM_WORKOBJINDEX, -1); + //andy_log + print("@:%d.", emptyindex); + } + while( 1){ + emptyindex = CHAR_findEmptyPoolItemBox( charaindex ); + if( emptyindex == -1 ) break; + id = rand()%10; + itemindex = ITEM_makeItemAndRegist( itemID[id] ); + if( !ITEM_CHECKINDEX( itemindex) ) break; + + CHAR_setPoolItemIndex( charaindex, emptyindex, itemindex); + ITEM_setWorkInt( itemindex, ITEM_WORKCHARAINDEX, charaindex); + ITEM_setWorkInt( itemindex, ITEM_WORKOBJINDEX, -1); + //andy_log + print("&:%d.", emptyindex); + } +*/ +} + +void CHAR_loginCheckUserItem( int charaindex) +{ + typedef void (*ATTACHFUNC)(int,int); + int i, itemindex; + for( i=0; i 0 ){ + if( (ti = CHAR_findEmptyItemBox( charaindex )) != -1 ){ + CHAR_setItemIndex( charaindex , i, -1); + CHAR_setItemIndex( charaindex , ti, itemindex); + } + continue; + } + } + //////////////////////////////////////////// + + + if( (i == ITEM_getEquipPlace( charaindex, itemindex )) || + i == CHAR_DECORATION1 || i == CHAR_DECORATION2 ){ + char category[256]; + ATTACHFUNC atf; + atf=(ATTACHFUNC)ITEM_getFunctionPointer(itemindex,ITEM_ATTACHFUNC); + if( atf ) atf( charaindex, itemindex ); + if( ITEM_canuseMagic( itemindex)) { + snprintf( category, sizeof( category), "J%d",i); + CHAR_sendStatusString( charaindex, category ); + } + }else{ + if( (ti = CHAR_findEmptyItemBox( charaindex )) == -1 ) continue; + CHAR_setItemIndex( charaindex , i, -1); + CHAR_setItemIndex( charaindex , ti, itemindex); + } + } + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE ; i++ ){ //检查携带道具 + itemindex = CHAR_getItemIndex( charaindex , i ); + if( !ITEM_CHECKINDEX( itemindex)) continue; + ITEM_reChangeItemName( itemindex); +#ifdef _ITEM_PILENUMS + ITEM_reChangeItemToPile( itemindex); +#endif + +#ifdef _ANGEL_SUMMON + if( ITEM_getInt( itemindex, ITEM_ID) == ANGELITEM + || ITEM_getInt( itemindex, ITEM_ID) == HEROITEM ) { + int mindex, mission; + // 检查信物所有人是否任务中 + mindex = checkIfAngelByName( ITEM_getChar( itemindex, ITEM_ANGELINFO)); + mission = atoi( ITEM_getChar( itemindex, ITEM_ANGELMISSION)); + if( mindex < 0 || mission != missiontable[mindex].mission ) { + CHAR_setItemIndex( charaindex, i, -1 ); + ITEM_endExistItemsOne( itemindex); + CHAR_sendItemDataOne( charaindex, i); + continue; + } + } +#endif + + ITEM_setItemUniCode( itemindex); + +#ifdef _DEATH_FAMILY_LOGIN_CHECK // WON ADD 家族战登入检查 + if( ITEM_getInt( itemindex, ITEM_TYPE) == ITEM_WARES || + ITEM_getInt( itemindex, ITEM_TYPE) == ITEM_DISH || + ITEM_getInt( itemindex, ITEM_TYPE) == ITEM_OTHER ){ + CHAR_setItemIndex( charaindex, i, -1 ); + ITEM_endExistItemsOne( itemindex); + CHAR_sendItemDataOne( charaindex, i); + } + +#endif + +#ifdef _DEATH_CONTEND + if( ITEM_getInt( itemindex, ITEM_TYPE) == ITEM_WARES || + ITEM_getInt( itemindex, ITEM_TYPE) == ITEM_DISH || + ITEM_getInt( itemindex, ITEM_TYPE) == ITEM_OTHER ){ + CHAR_setItemIndex( charaindex, i, -1 ); + ITEM_endExistItemsOne( itemindex); + CHAR_sendItemDataOne( charaindex, i); + } +#endif + + } + //检查寄放店道具 + for( i = 0 ; i < CHAR_MAXPOOLITEMHAVE ; i++ ){ + itemindex = CHAR_getPoolItemIndex( charaindex , i ); + if( !ITEM_CHECKINDEX( itemindex) ) continue; + + ITEM_reChangeItemName( itemindex); +#ifdef _ITEM_PILENUMS + ITEM_reChangeItemToPile( itemindex); +#endif + +#ifdef _ANGEL_SUMMON + if( ITEM_getInt( itemindex, ITEM_ID) == ANGELITEM + || ITEM_getInt( itemindex, ITEM_ID) == HEROITEM ) { + int mindex, mission; + // 检查信物所有人是否任务中 + mindex = checkIfAngelByName( ITEM_getChar( itemindex, ITEM_ANGELINFO)); + mission = atoi( ITEM_getChar( itemindex, ITEM_ANGELMISSION)); + if( mindex < 0 || mission != missiontable[mindex].mission ) { + CHAR_setPoolItemIndex( charaindex, i, -1 ); + ITEM_endExistItemsOne( itemindex); + continue; + } + } +#endif + + ITEM_setItemUniCode( itemindex); + +#ifdef _DEATH_FAMILY_LOGIN_CHECK // WON ADD 家族战登入检查 + if( ITEM_getInt( itemindex, ITEM_TYPE) == ITEM_WARES || + ITEM_getInt( itemindex, ITEM_TYPE) == ITEM_DISH || + ITEM_getInt( itemindex, ITEM_TYPE) == ITEM_OTHER ){ + CHAR_setPoolItemIndex( charaindex, i, -1 ); + ITEM_endExistItemsOne( itemindex); + } +#endif + +#ifdef _DEATH_CONTEND + if( ITEM_getInt( itemindex, ITEM_TYPE) == ITEM_WARES || + ITEM_getInt( itemindex, ITEM_TYPE) == ITEM_DISH || + ITEM_getInt( itemindex, ITEM_TYPE) == ITEM_OTHER ){ + CHAR_setPoolItemIndex( charaindex, i, -1 ); + ITEM_endExistItemsOne( itemindex); + } +#endif + } + + // WON ADD 修正道具的设定问题 + if(!NPC_EventCheckFlg( charaindex,134)){ + for (i = 0; i < CHAR_MAXITEMHAVE; i ++) { + itemindex = CHAR_getItemIndex(charaindex, i); + fix_item_bug(charaindex, itemindex); + } + for (i = 0; i < CHAR_MAXPOOLITEMHAVE; i++) { + itemindex = CHAR_getPoolItemIndex(charaindex, i); + fix_item_bug(charaindex, itemindex); + } + NPC_EventSetFlg(charaindex, 134); + } + + Check_P_I_UniCode( charaindex); +} +void CHAR_LoginBesideSetWorkInt( int charaindex, int clifd) +{ + CHAR_setWorkInt( charaindex, CHAR_WORKPARTYMODE, CHAR_PARTY_NONE); + CHAR_setWorkInt( charaindex, CHAR_WORKPARTYINDEX1, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKPARTYINDEX2, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKPARTYINDEX3, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKPARTYINDEX4, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKPARTYINDEX5, -1); + + CHAR_setWorkInt( charaindex, CHAR_WORKTRADEMODE, CHAR_TRADE_FREE); + CHAR_setWorkInt( charaindex, CHAR_WORKFMINDEXI, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKFMCHANNEL, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKFMCHANNELQUICK, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKFMFLOOR, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKFMDP, 0); + CHAR_setWorkInt( charaindex, CHAR_WORKFMPKFLAG, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKFMSETUPFLAG, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKFMMANINDEX, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKFMCHARINDEX, -1); + + CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEFLAG, -1); + CHAR_setWorkInt( charaindex, CHAR_WORK_PET0_STAT, 0); + CHAR_setWorkInt( charaindex, CHAR_WORK_PET1_STAT, 0); + CHAR_setWorkInt( charaindex, CHAR_WORK_PET2_STAT, 0); + CHAR_setWorkInt( charaindex, CHAR_WORK_PET3_STAT, 0); + CHAR_setWorkInt( charaindex, CHAR_WORK_PET4_STAT, 0); + CHAR_setWorkInt( charaindex, CHAR_WORKACTION, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKEFFECT, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKFD, clifd); + + + if( CHAR_getInt( charaindex, CHAR_SILENT) > 100000000 ) + CHAR_setInt( charaindex, CHAR_SILENT, 0); + CHAR_setWorkInt( charaindex, CHAR_WORKLOGINTIME, (int)NowTime.tv_sec); + CHAR_setWorkInt( charaindex, CHAR_WORKTALKCOUNT, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORKTALKTIME, (int)NowTime.tv_sec); + CHAR_setWorkInt( charaindex, CHAR_WORKPETFOLLOW, -1); +#ifdef _ITEM_ADDEXP //vincent 经验提升 + CHAR_setWorkInt(charaindex,CHAR_WORKITEM_ADDEXP, 0); + CHAR_setWorkInt(charaindex,CHAR_WORKITEM_ADDEXPTIME, 0); +#endif +#ifdef _BULL_FIXPLAYER + if( NPC_EventCheckFlg( charaindex, 131 ) != TRUE ) { + if( CHAR_getInt( charaindex, CHAR_ABULLSCORE) > 100 ) + CHAR_setInt( charaindex, CHAR_ABULLSCORE, 100); + CHAR_setInt( charaindex, CHAR_ABULLTIME, 0); + NPC_EventSetFlg( charaindex, 131); + NPC_NowEndEventSetFlgCls( charaindex, 130); + } +#endif +#ifdef _STATUS_WATERWORD //水世界状态 + if( MAP_getMapFloorType( CHAR_getInt( charaindex, CHAR_FLOOR)) == 1 ){ + CHAR_setWorkInt( charaindex, CHAR_WORKMAPFLOORTYPE, 1); + }else{ + CHAR_setWorkInt( charaindex, CHAR_WORKMAPFLOORTYPE, 0); + } +#endif +#ifdef _NEWOPEN_MAXEXP + if( CHAR_getInt( charaindex, CHAR_OLDEXP) > 0 || CHAR_getInt( charaindex, CHAR_OLDEXP) < 0 ){ + CHAR_ChangeExp( charaindex); + } +#endif +#ifdef _PETSKILL_BECOMEFOX + CHAR_setWorkInt( charaindex, CHAR_WORKFOXROUND, -1 ); +#endif +#ifdef _MAP_TIME + CHAR_setWorkInt(charaindex,CHAR_WORK_MAP_TIME,0); +#endif +#ifdef _PETSKILL_LER + CHAR_setWorkInt(charaindex,CHAR_WORK_RELIFE,0); +#endif + +#ifdef _ITEM_ADDEXP2 + CHAR_setWorkInt( charaindex, CHAR_WORKITEM_ADDEXP, + CHAR_getInt( charaindex, CHAR_ADDEXPPOWER) ); + CHAR_setWorkInt( charaindex, CHAR_WORKITEM_ADDEXPTIME , + CHAR_getInt( charaindex, CHAR_ADDEXPTIME) ); +#endif + +} + +void CHAR_CheckProfessionSkill( int charaindex) +{ + int i, Pclass, skpoint=0, mynum=0; + CHAR_HaveSkill *pSkil; + + if( NPC_EventCheckFlg( charaindex, 155) ) return; + + Pclass = CHAR_getInt( charaindex, PROFESSION_CLASS ); + skpoint = CHAR_getInt( charaindex, PROFESSION_SKILL_POINT); + if( Pclass == PROFESSION_CLASS_NONE )return; + + + for( i=0; iskill, 0, 0 ); + pSkil->use = 0; + break; + case 64: + CHAR_setInt( charaindex, CHAR_MAXMP, 100); + CHAR_setInt( charaindex, PROFESSION_SKILL_POINT, skpoint+1 ); + pSkil = CHAR_getCharHaveSkill( charaindex, i ); + SKILL_makeSkillData( &pSkil->skill, 0, 0 ); + pSkil->use = 0; + break; + case 65: + CHAR_setInt( charaindex, ATTACHPILE, 0); + CHAR_setInt( charaindex, PROFESSION_SKILL_POINT, skpoint+1 ); + pSkil = CHAR_getCharHaveSkill( charaindex, i ); + SKILL_makeSkillData( &pSkil->skill, 0, 0 ); + pSkil->use = 0; + break; + } + } + { + int myskillpoint, myskillnum=0, myskilllevel; + int mysknum=0; + + myskillpoint= CHAR_getInt( charaindex, PROFESSION_SKILL_POINT ); + myskilllevel= CHAR_getInt( charaindex, PROFESSION_LEVEL ); + + for( i=0; i 0 ){ + CHAR_setInt( charaindex, PROFESSION_SKILL_POINT, myskillpoint + mysknum ); + }else if( mysknum < 0 ){ + int defsknum = (myskillpoint + myskillnum)-myskilllevel; + while( 1){ + if( defsknum<= 0 || + (myskillpoint= CHAR_getInt( charaindex, PROFESSION_SKILL_POINT )) <= 0 ) break; + CHAR_setInt( charaindex, PROFESSION_SKILL_POINT, myskillpoint-1); + defsknum--; + } + } + } + + NPC_EventSetFlg( charaindex, 155); +} + +void CHAR_ResetPoolPetEgg( int charaindex) +{ + int levelup, vital, str, tgh, dex; + int raise, petindex, i; + + + if( NPC_EventCheckFlg( charaindex, 157) ) return; + + for( i = 0; i < CHAR_MAXPOOLPETHAVE; i ++ ) { + petindex = CHAR_getCharPoolPet( charaindex, i); + if( !CHAR_CHECKINDEX( petindex) ) continue; + + if( CHAR_getInt( petindex, CHAR_FUSIONBEIT) != 1 || + CHAR_getInt( petindex, CHAR_FUSIONRAISE) <= 0 ) continue; + + raise = CHAR_getInt( petindex, CHAR_FUSIONRAISE); + raise--; + CHAR_setInt( petindex, CHAR_FUSIONTIMELIMIT, (int)time(NULL)+PETFEEDTIME); + if( raise < 1 ) raise = 1; + if( raise >= 40 ) raise = 30; + CHAR_setInt( petindex, CHAR_FUSIONRAISE, raise); + + levelup = CHAR_getInt( petindex, CHAR_ALLOCPOINT); + vital = ((levelup>>24) & 0xFF) + 4; + str = ((levelup>>16) & 0xFF) + 4; + tgh = ((levelup>> 8) & 0xFF) + 4; + dex = ((levelup>> 0) & 0xFF) + 4; + if( vital < 0 ) vital = 0; + if( str < 0 ) str = 0; + if( tgh < 0 ) tgh = 0; + if( dex < 0 ) dex = 0; + //扣属性 + levelup = (vital<<24) + (str<<16) + (tgh<<8) + (dex<<0); + CHAR_setInt( petindex, CHAR_ALLOCPOINT, levelup); + } + NPC_EventSetFlg( charaindex, 157); +} + +// Robin add 重设宠蛋 养时间 +void CHAR_ResetPetEggFusionTime(int charaindex) +{ + int i, petindex; + int nowTime =0; + //int leaveTime =0; + //int lastFeedTime =0; + //int anhour = PETFEEDTIME; + + //if( NPC_EventCheckFlg( charaindex, 157) ) return; + + nowTime = (int)time(NULL); + //leaveTime = CHAR_getInt( charaindex, CHAR_LASTLEAVETIME); + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + petindex = CHAR_getCharPet( charaindex, i); + if( !CHAR_CHECKINDEX( petindex) ) continue; + + if( CHAR_getInt( petindex, CHAR_FUSIONBEIT) != 1 || + CHAR_getInt( petindex, CHAR_FUSIONRAISE) <= 0 ) continue; + + //lastFeedTime = CHAR_getInt( petindex, CHAR_FUSIONTIMELIMIT); + //if( leaveTime > 0) { + // CHAR_setInt( petindex, CHAR_FUSIONTIMELIMIT, nowTime- (leaveTime-lastFeedTime)); + //} + //else + // CHAR_setInt( petindex, CHAR_FUSIONTIMELIMIT, nowTime); + + CHAR_setInt( petindex, CHAR_FUSIONTIMELIMIT, nowTime); + + } + + //NPC_EventSetFlg( charaindex, 157); + +} + + +BOOL CHAR_CheckProfessionEquit( int toindex) +{ + int i, j, itemindex, newindex; + int FixItem[16]={ + 2028,2029,2030,2031,2032,2033,2034,2035, + 2036,2037,2038,2039,2040,2041,2042,2043 + }; + CHAR_HaveSkill *pSkil; + + if(!NPC_EventCheckFlg( toindex, 149)){ + for (i = 0; i < CHAR_MAXITEMHAVE; i ++) { + itemindex = CHAR_getItemIndex( toindex, i); + if( !ITEM_CHECKINDEX( itemindex)) continue; + + for( j=0; j<16; j++){ + if( ITEM_getInt( itemindex, ITEM_ID) == FixItem[j] ){ + CHAR_setItemIndex( toindex, i, -1 ); + ITEM_endExistItemsOne( itemindex); + newindex = ITEM_makeItemAndRegist( FixItem[j]); + if( !ITEM_CHECKINDEX( newindex) ) break; + CHAR_setItemIndex( toindex , i, newindex); + ITEM_setWorkInt( itemindex, ITEM_WORKCHARAINDEX, toindex); + ITEM_setWorkInt( itemindex, ITEM_WORKOBJINDEX, -1); + + CHAR_sendItemDataOne( toindex, i); + + } + } + } + + for (i = 0; i < CHAR_MAXPOOLITEMHAVE; i++){ + int itemindex = CHAR_getPoolItemIndex(toindex, i); + if( !ITEM_CHECKINDEX( itemindex)) continue; + for( j=0; j<16; j++){ + if( ITEM_getInt( itemindex, ITEM_ID) == FixItem[j] ){ + CHAR_setPoolItemIndex( toindex, i, -1); + ITEM_endExistItemsOne( itemindex); + + newindex = ITEM_makeItemAndRegist( FixItem[j]); + if( !ITEM_CHECKINDEX( newindex) ) break; + CHAR_setPoolItemIndex( toindex , i, newindex); + ITEM_setWorkInt( itemindex, ITEM_WORKCHARAINDEX, toindex); + ITEM_setWorkInt( itemindex, ITEM_WORKOBJINDEX, -1); + + } + } + } + + NPC_EventSetFlg( toindex, 149); + } + + + if( NPC_EventCheckFlg( toindex, 156) ) return TRUE; + + // WON ADD + for( i=0; i 0 ) continue; + + pSkil = CHAR_getCharHaveSkill( toindex, i ); + SKILL_makeSkillData( &pSkil->skill, 0, 0 ); + pSkil->use = 0; + } + { + int myskillpoint= CHAR_getInt( toindex, PROFESSION_SKILL_POINT ); + int myskilllevel= CHAR_getInt( toindex, PROFESSION_LEVEL ); + int myskillnum = 0, mysknum = 0; + + for( i=0; i 0 ){ + CHAR_setInt( toindex, PROFESSION_SKILL_POINT, myskillpoint + mysknum ); + } + } + + { + Skill work1[PROFESSION_MAX_LEVEL]; + int cnt=0; + for( i=0; iuse = 0; + if( work1[i].data[SKILL_IDENTITY] == -1 ) continue; + SKILL_makeSkillData( &pSkil->skill, work1[i].data[SKILL_IDENTITY], work1[i].data[SKILL_LEVEL] ); + pSkil->use = 1; + } + } + + NPC_EventSetFlg( toindex, 156); + + return TRUE; +} + +static void CHAR_setLuck( int charaindex); + +#ifdef _CHANNEL_MODIFY +extern int *piOccChannelMember; +#endif + +#ifdef _BAD_PLAYER // WON ADD 送坏玩家去关 +void CHAR_login( int clifd, char* data, int saveindex, int badplayer ) +#else +void CHAR_login( int clifd, char* data, int saveindex ) +#endif +{ + int charaindex,objindex; + Char ch; + int per; +DebugPoint=50; +// char c_temp2[4096]; + if( CHAR_makeCharFromStringToArg( data , &ch ) == FALSE ){ + fprint ("make char error\n"); + goto MAKECHARDATAERROR; + } +DebugPoint=70; + CHAR_setCharFuncTable( &ch); +DebugPoint=71; + charaindex = CHAR_initCharOneArray( &ch ); +DebugPoint=72; + if( charaindex == -1 ){ + fprint ("make char error\n"); + CHAR_endCharData(&ch); + goto MAKECHARDATAERROR; + } +DebugPoint=80; +#ifdef _NEWSAVE + CHAR_setInt( charaindex, CHAR_SAVEINDEXNUMBER, saveindex); + print("存档装载索引:%d\n", CHAR_getInt( charaindex, CHAR_SAVEINDEXNUMBER) ); +#endif + if( CHAR_getFlg( charaindex, CHAR_ISDIE)){ + print( "?data? ISDIE flg is standing.\n"); + CHAR_setFlg( charaindex, CHAR_ISDIE, FALSE); + } +#ifdef _75_TEST + { + int event_end[] = { 4, 32, 33, 34, 81, 86, 87, 105, 83}; + int i; + for( i=0; i < arraysizeof(event_end); i++) { + NPC_EventSetFlg( charaindex, event_end[i]); + } + } +#endif +#ifndef _FIX_UNNECESSARY + // Arminius 7.9 airplane logout + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_CLIENT ) { + int oyaindex = CHAR_getWorkInt( charaindex, CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX( oyaindex)) { + if (CHAR_getInt( oyaindex, CHAR_WHICHTYPE ) == CHAR_TYPEBUS) { + if ((CHAR_getInt( oyaindex, CHAR_BASEIMAGENUMBER) !=100355) && + (CHAR_getInt( oyaindex, CHAR_BASEIMAGENUMBER) !=100461)) { + + if(CHAR_getWorkInt(oyaindex,CHAR_NPCWORKINT5)==1) { + if( CHAR_getInt( charaindex, CHAR_LASTTALKELDER)>=0){ + int fl,x,y; + CHAR_getElderPosition( CHAR_getInt( charaindex, CHAR_LASTTALKELDER), + &fl, &x, &y ); + CHAR_setInt(charaindex,CHAR_FLOOR,fl); + CHAR_setInt(charaindex,CHAR_X,x); + CHAR_setInt(charaindex,CHAR_Y,y); + } + } + } + } + } + } +#endif +// Nuke 20040420: CHECK MAX POINT +#if 1 + { + int lv,vi,str,tou,dx,skup,trn,teq,quest,level,total,max; + //float table[]={437,490,521,550,578,620}; //各转最高点数(减10) + float table[]={620,660,700,740,780,820}; //各转最高点数(减10) + lv = CHAR_getInt(charaindex,CHAR_LV); + vi = CHAR_getInt(charaindex,CHAR_VITAL); + str = CHAR_getInt(charaindex,CHAR_STR); + tou = CHAR_getInt(charaindex,CHAR_TOUGH); + dx = CHAR_getInt(charaindex,CHAR_DEX); + trn = CHAR_getInt(charaindex,CHAR_TRANSMIGRATION); + teq = CHAR_getInt(charaindex,CHAR_TRANSEQUATION); + skup = CHAR_getInt(charaindex,CHAR_SKILLUPPOINT); + quest=(teq >> 16)& 0xFFFF; + level=teq & 0xFFFF; + total=(vi+str+tou+dx)/100+skup; + max=(trn==0)?(lv-1)*3+20+10: // 0转447 + (lv-1)*3+table[trn-1]/12.0+quest/4.0+(level-trn*85)/4.0+10+1+10+trn*10; +/* 1转以上=升级点数+继承点术+历史任务+历史等级+转前祝福+误差1点+转後祝福+转生红利 */ + if (trn==6) max=max-20; /* 六转时没有转前祝福与转後祝福 */ + if (total>max) + { + print("\n重调点数[%s:%s]:%d->%d ", + CHAR_getChar(charaindex,CHAR_CDKEY), + CHAR_getChar(charaindex,CHAR_NAME), + total,max); + CHAR_setInt(charaindex,CHAR_VITAL,1000); + CHAR_setInt(charaindex,CHAR_STR,0); + CHAR_setInt(charaindex,CHAR_TOUGH,0); + CHAR_setInt(charaindex,CHAR_DEX,0); + CHAR_setInt(charaindex,CHAR_SKILLUPPOINT,max-10); + } + // 补足六转点数不足之玩家 + if ((trn==6) && (total < max)) + { + print("\n补足点数[%s:%s]:%d->%d ", + CHAR_getChar(charaindex,CHAR_CDKEY), + CHAR_getChar(charaindex,CHAR_NAME), + total,max); + CHAR_setInt(charaindex,CHAR_SKILLUPPOINT, + CHAR_getInt(charaindex,CHAR_SKILLUPPOINT)+(max-total)); + } + } +#endif + { + int EQ_BBI=-1, EQ_ARM=-1, EQ_NUM=-1, EQ_BI=-1; + int CH_BI = CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER); + + EQ_BBI = CHAR_getInt( charaindex, CHAR_BASEBASEIMAGENUMBER); + EQ_ARM = CHAR_getItemIndex(charaindex,CHAR_ARM); + EQ_NUM=ITEM_FIST; + if ( ITEM_CHECKINDEX( EQ_ARM)) { + EQ_NUM=ITEM_getInt(EQ_ARM,ITEM_TYPE); + } + + EQ_BI=CHAR_getNewImagenumberFromEquip( EQ_BBI, EQ_NUM); + + if( CHAR_getInt( charaindex, CHAR_RIDEPET) != -1 ) { //骑宠 + + }else { //非骑宠 + if( EQ_BI != CH_BI ) { + print("\n 非骑宠形象 %d [%d=>%d]", charaindex, + CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER), + EQ_BI ); + CHAR_setInt( charaindex, CHAR_BASEIMAGENUMBER, EQ_BI); + } + } + } + { + int x,y; + if( CHAR_isAppearPosition( CHAR_getInt( charaindex, CHAR_FLOOR),&x, &y )) { + int flelder, xelder, yelder; + CHAR_getElderPosition(CHAR_getInt(charaindex, CHAR_LASTTALKELDER), + &flelder, &xelder, &yelder); + CHAR_setInt(charaindex, CHAR_FLOOR, flelder); + CHAR_setInt(charaindex, CHAR_X, xelder); + CHAR_setInt(charaindex, CHAR_Y, yelder); + } + } + +#ifdef _FIX_GAMBLENUM + { + if( CHAR_getInt(charaindex, CHAR_GAMBLENUM) < 0){ + CHAR_setInt(charaindex, CHAR_GAMBLENUM, 0); + } + } +#endif + +#ifdef _DEATH_CONTEND + { + char cdkey[CDKEYLEN]; + memset( cdkey, 0, sizeof(cdkey)); + CONNECT_getCdkey( clifd, cdkey, sizeof( cdkey )); + if( strlen(cdkey) > 0 ) { + if( strcmp( cdkey, CHAR_getChar( charaindex, CHAR_CDKEY) ) ){ + print("账号错误 %s->%s\n", CHAR_getChar( charaindex, CHAR_CDKEY), cdkey); + CHAR_setChar( charaindex, CHAR_CDKEY, cdkey); + } + }else{ + print("账号错误:%d\n", clifd); + } + } + CHAR_setInt( charaindex, CHAR_PKLISTTEAMNUM, -1); + CHAR_setInt( charaindex, CHAR_PKLISTLEADER, -1); + //CHAR_setInt( charaindex, CHAR_GOLD, 1000000); + PKLIST_InsertTeamNum( charaindex); + if( CHAR_getInt( charaindex, CHAR_PKLISTTEAMNUM ) < 0 || + CHAR_getInt( charaindex, CHAR_PKLISTLEADER ) < 0 ){ + PKLIST_InsertTeamNum( charaindex); + } +#endif + +#ifdef _MAP_NOEXIT + { + int exfloor=-1,ex_X=-1,ex_Y=-1; + int map_type=0; + unsigned int point; + point = MAP_getExFloor_XY( CHAR_getInt(charaindex, CHAR_FLOOR) , &map_type); + if( point > 0 ) { + if( CHAR_getInt( charaindex, CHAR_LASTTALKELDER) >= 0 ) { + CHAR_getElderPosition(CHAR_getInt(charaindex, CHAR_LASTTALKELDER), + &exfloor, &ex_X, &ex_Y); + } + if( map_type >= 0 ) { // map_type >= 0 优先回纪录点 + if( exfloor == map_type && exfloor >= 0 ) {//回纪录点 + }else { + exfloor = (point>>16)&0xffffff; + ex_X = (point>>8)&0xff; + ex_Y = (point>>0)&0xff; + } + } + if( CHECKFLOORID( exfloor) ) { //检查房间号 + CHAR_setInt(charaindex, CHAR_FLOOR, exfloor); + CHAR_setInt(charaindex, CHAR_X, ex_X); + CHAR_setInt(charaindex, CHAR_Y, ex_Y); + } + } + +#ifdef _BAD_PLAYER // WON ADD 送坏玩家去关 + + NPC_NowEndEventSetFlgCls( charaindex, 135); // 旗标 + if( badplayer ){ + NPC_EventSetFlg(charaindex, 135); // 旗标 + CHAR_setInt(charaindex, CHAR_FLOOR, 887); + CHAR_setInt(charaindex, CHAR_X, 56); + CHAR_setInt(charaindex, CHAR_Y, 14); + + }else if( CHAR_getInt(charaindex, CHAR_FLOOR) == 887 ){ // 如果在888,回记录点 + CHAR_getElderPosition(CHAR_getInt(charaindex, CHAR_LASTTALKELDER), &exfloor, &ex_X, &ex_Y); + CHAR_setInt(charaindex, CHAR_FLOOR, exfloor); + CHAR_setInt(charaindex, CHAR_X, ex_X); + CHAR_setInt(charaindex, CHAR_Y, ex_Y); + + } +#endif +#ifdef _DEATH_FAMILY_LOGIN_CHECK + CHAR_setInt( charaindex, CHAR_FLOOR, 130); + CHAR_setInt( charaindex, CHAR_X, 56); + CHAR_setInt( charaindex, CHAR_Y, 12); +#endif + +#ifdef _NEW_INSERVERPOINT + CHAR_setInt( charaindex, CHAR_FLOOR, 8250); + CHAR_setInt( charaindex, CHAR_X, 15); + CHAR_setInt( charaindex, CHAR_Y, 15); +#endif + } +#endif + if( CHAR_getInt(charaindex,CHAR_X) < 0 || CHAR_getInt(charaindex,CHAR_Y) < 0 ){ + CHAR_setInt(charaindex,CHAR_X,1); + CHAR_setInt(charaindex,CHAR_Y,1); + } +#ifdef _MAP_TIME + // 如果登入的地图是这些编号的话,回到入口 + if(CHAR_getInt(charaindex,CHAR_FLOOR) >= 30017 && CHAR_getInt(charaindex, CHAR_FLOOR) <= 30021){ + CHAR_setInt(charaindex,CHAR_FLOOR,30008); + CHAR_setInt(charaindex,CHAR_X,39); + CHAR_setInt(charaindex,CHAR_Y,38); + } +#endif + + objindex = initObjectFromObjectMember(OBJTYPE_CHARA,charaindex, + CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y), + CHAR_getInt(charaindex,CHAR_FLOOR)); + if( objindex == -1 ){ + fprint ("init obj error\n"); + goto DELETECHARDATA; + } + + CHAR_setWorkInt( charaindex,CHAR_WORKOBJINDEX,objindex ); + CONNECT_setState( clifd, LOGIN ); + CONNECT_setCharaindex( clifd, charaindex ); + CHAR_LoginBesideSetWorkInt( charaindex, clifd); + +#ifdef _CHANGEGOATMETAMO // (不可开) Syu 羊年兽更换新图 + if( NPC_EventCheckFlg( charaindex, 141 ) != TRUE ) { + int z; + int PETID1; + int PETBASE1; + for ( z = 0 ; z < CHAR_MAXPETHAVE; z ++ ) { + int petindex = CHAR_getCharPet(charaindex,z); + if( CHAR_CHECKINDEX( petindex) ) { + PETID1 = CHAR_getInt( petindex, CHAR_PETID); + PETBASE1 = CHAR_getInt( petindex , CHAR_BASEBASEIMAGENUMBER ); + if ( PETID1 == 1056 && PETBASE1 == 101497 ) + CHAR_setInt( petindex , CHAR_BASEBASEIMAGENUMBER , 101607 ) ; + if ( PETID1 == 1057 && PETBASE1 == 101498 ) + CHAR_setInt( petindex , CHAR_BASEBASEIMAGENUMBER , 101608 ) ; + if ( PETID1 == 1058 && PETBASE1 == 101499 ) + CHAR_setInt( petindex , CHAR_BASEBASEIMAGENUMBER , 101609 ) ; + if ( PETID1 == 1059 && PETBASE1 == 101500 ) + CHAR_setInt( petindex , CHAR_BASEBASEIMAGENUMBER , 101610 ) ; + } + } + for ( z = 0 ; z < CHAR_MAXPOOLPETHAVE; z ++ ) { + int petindex = CHAR_getCharPoolPet(charaindex,z); + if( CHAR_CHECKINDEX( petindex) ) { + PETID1 = CHAR_getInt( petindex, CHAR_PETID); + PETBASE1 = CHAR_getInt( petindex , CHAR_BASEBASEIMAGENUMBER ); + if ( PETID1 == 1056 && PETBASE1 == 101497 ) + CHAR_setInt( petindex , CHAR_BASEBASEIMAGENUMBER , 101607 ) ; + if ( PETID1 == 1057 && PETBASE1 == 101498 ) + CHAR_setInt( petindex , CHAR_BASEBASEIMAGENUMBER , 101608 ) ; + if ( PETID1 == 1058 && PETBASE1 == 101499 ) + CHAR_setInt( petindex , CHAR_BASEBASEIMAGENUMBER , 101609 ) ; + if ( PETID1 == 1059 && PETBASE1 == 101500 ) + CHAR_setInt( petindex , CHAR_BASEBASEIMAGENUMBER , 101610 ) ; + } + } + } + NPC_EventSetFlg( charaindex, 141); +#endif + + CHAR_complianceParameter( charaindex ); + //检查人物身上 + { + int i; +// char *petstring; + int ID1; + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + int petindex = CHAR_getCharPet(charaindex,i); + if( CHAR_CHECKINDEX( petindex) ) { + +#ifdef _CHECK_ENEMY_PET + { + int j; + for( j=0;j 0 || CHAR_getInt( charaindex, CHAR_OLDEXP) < 0 ){ + CHAR_ChangeExp( petindex); + } +#endif + ID1=CHAR_getInt( petindex, CHAR_PETID); +// petstring = CHAR_makePetStringFromPetIndex( petindex); +#ifdef _REEDIT_PETBBIS + if( ID1 == 1133 ){ + CHAR_setInt( petindex, CHAR_BASEIMAGENUMBER, 101578); + CHAR_setInt( petindex, CHAR_BASEBASEIMAGENUMBER, 101578); + print("PET:%s fix BBI\n", CHAR_getUseName(petindex)); + } +#endif + // WON ADD 修正白虎七技 + if( ID1 == 777 )CHAR_setInt( petindex, CHAR_SLOT, 7); + CHAR_setWorkInt( petindex, CHAR_WORKPLAYERINDEX, charaindex); + // 修正宠技最大值变-1 Robin 20040803 + if( CHAR_getInt( petindex, CHAR_SLOT) < 0 ) { + int j; + for( j=0; j= 0) + CHAR_setInt( petindex, CHAR_SLOT, j+1); + } + //print(" 宠技MAX变-1改6 "); + } + + CHAR_complianceParameter( petindex ); +#ifdef _FIX_GP_PET_SKILL // WON ADD 修正gp宠会落马术 + if( ID1 == 1133){ + int j; + for( j=0; j 0 || + CHAR_getInt( charaindex, CHAR_OLDEXP) < 0 ){ + CHAR_ChangeExp( petindex); + } +#endif + b_find=FALSE; + ID1=CHAR_getInt( petindex, CHAR_PETID); +#ifdef _REEDIT_PETBBIS + if( ID1 == 1133 ){ + CHAR_setInt( petindex, CHAR_BASEIMAGENUMBER, 101578); + CHAR_setInt( petindex, CHAR_BASEBASEIMAGENUMBER, 101578); + } +#endif +/* + tran_no=CHAR_getInt( charaindex, CHAR_TRANSMIGRATION); + petstring = CHAR_makePetStringFromPetIndex( petindex); + c_ptr_index=strstr(petstring,"name:"); + getStringFromIndexWithDelim(c_ptr_index,":",2,c_temp,sizeof(c_temp)); + c_ptr_index=c_temp; + getStringFromIndexWithDelim(c_ptr_index,"|",1,c_temp1,sizeof(c_temp1)); + + if(b_find){//ttom + CHAR_setCharPoolPet( charaindex, i, -1); + print("\nKill pool pet ID=%d name=%s",ID1,c_temp1); + sprintf(c_temp2,"Kill pool pet ID=%d name=%s",ID1,c_temp1); + LogKill(CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), + c_temp2); + }else{//ttom +*/ + CHAR_setWorkInt( petindex, CHAR_WORKPLAYERINDEX, charaindex); + CHAR_complianceParameter( petindex ); +// }//ttom + } + } + } + +// CHAR_ResetPoolPetEgg( charaindex); +// CHAR_CheckProfessionEquit( charaindex); + CHAR_CheckProfessionSkill( charaindex); + { + int i=0; + int skidx[]={2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,3,3,3,3,3,3,3}; + //20040702 Change fix + //检查是否有职业不该有的技能并删除 + for( i = CHAR_SKILLMAXHAVE-1; i >= 0; i -- ){ + CHAR_HaveSkill *pSkil; + Skill* skill; + + pSkil = CHAR_getCharHaveSkill( charaindex, i ); + skill = &pSkil->skill; + if( pSkil == NULL )continue; + if( pSkil->use == 0 )continue; + if( skidx[skill->data[SKILL_IDENTITY]] != CHAR_getInt( charaindex, PROFESSION_CLASS ) + && skidx[skill->data[SKILL_IDENTITY]] != 4 ){//共通技不删 + SKILL_makeSkillData( &pSkil->skill, 0, 0 ); + pSkil->use = 0; + } + } + } +#ifdef _LOGIN_ADDITEM + CHAR_loginAddItem( charaindex); +#endif + CHAR_loginCheckUserItem( charaindex); +#ifdef _FIX_TSKILLCAN + CHAR_PETSKILLCAN( charaindex); +#endif + CHAR_complianceParameter( charaindex ); + + // Robin add 重设宠蛋 养时间 + CHAR_ResetPetEggFusionTime( charaindex); + +#ifdef _PROFESSION_FIX_LEVEL // WON ADD 修正职业经验值 + { + int i=0; + for( i = 0 ; i < CHAR_SKILLMAXHAVE ; i ++ ){ + CHAR_HaveSkill* hskill; + + hskill = CHAR_getCharHaveSkill( charaindex, i ); + + if( hskill != NULL && hskill->use == TRUE ){ + int skill_level = SKILL_getInt( &hskill->skill, SKILL_LEVEL); + if( skill_level < 10 ){ + SKILL_setInt( &hskill->skill, SKILL_LEVEL, 10* 100 ); + } + } + } + } +#endif + +#ifdef _CHANNEL_MODIFY + if(CHAR_getInt(charaindex,PROFESSION_CLASS) > 0){ + int i,pclass = CHAR_getInt(charaindex,PROFESSION_CLASS) - 1,Empty = -1; + // 若旧的职业频道记录有记录在就留着,若没有加入频道 + for(i=0;i MAX_PERSONAL_MOMENTUM) CHAR_setInt(charaindex,CHAR_MOMENTUM,MAX_PERSONAL_MOMENTUM); +#endif + +#ifdef _PETSKILL_BECOMEPIG + if( CHAR_getInt( charaindex, CHAR_BECOMEPIG) > -1 ){ + CHAR_setInt( charaindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( charaindex, CHAR_BECOMEPIG_BBI ) ); + } + //change fix 处理负很大的乌力时间 + else{ + CHAR_setInt( charaindex, CHAR_BECOMEPIG, -1 ); + } +#endif + + + lssproto_CharLogin_send( clifd, SUCCESSFUL,"" ); + per = ENCOUNT_getEncountPercentMin( charaindex, + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y)); + if( per != -1) { + CHAR_setWorkInt( charaindex, CHAR_WORKENCOUNTPROBABILITY_MIN, per); + } + per = ENCOUNT_getEncountPercentMax( charaindex, + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y)); + if( per != -1) { + CHAR_setWorkInt( charaindex, CHAR_WORKENCOUNTPROBABILITY_MAX, per); + } + + CHAR_setLuck( charaindex); + { + int i; + char* statuscat[]={"C","P","I","S","D","E","F"}; + for( i=0 ; i=1 ) + CHAR_Skillupsend(charaindex); + CHAR_checkEffect( charaindex); + +#ifdef _DEATH_FAMILY_LOGIN_CHECK // WON ADD 家族战登入检查 +// if( NPC_EventCheckFlg( charaindex, 150 ) != TRUE ) { + { + char *char_id, *char_name; + // 清除家族旗标 + SetFMVarInit(charaindex); + char_id = CHAR_getChar( charaindex, CHAR_CDKEY ); + char_name = CHAR_getChar( charaindex, CHAR_NAME ); + saacproto_new_ACFM_Login_send(acfd, charaindex, char_id, char_name ); + } +// NPC_EventSetFlg( charaindex, 150); +// } +#else + + // CoolFish: Family 2001/5/30 + if ((CHAR_getChar(charaindex, CHAR_FMNAME)!=NULL) && + (CHAR_getInt(charaindex, CHAR_FMINDEX) >= 0) && + (strcmp(CHAR_getChar(charaindex, CHAR_FMNAME), "") != 0)) + { +#ifdef _FMVER21 + int eventflag = 0; + // 是否符合族长得资格 + if (CheckLeaderQ(charaindex) >= 0) + eventflag = 1; + if (CHAR_getInt(charaindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER) + SetFMPetVarInit(charaindex); + saacproto_ACFMCharLogin_send( + acfd, + CHAR_getChar(charaindex, CHAR_FMNAME), + CHAR_getInt(charaindex, CHAR_FMINDEX), + CHAR_getChar(charaindex, CHAR_NAME), + CHAR_getChar(charaindex, CHAR_CDKEY), + CHAR_getInt(charaindex, CHAR_LV), eventflag, + CONNECT_getFdid(clifd) +#ifdef _FM_MODIFY + ,getServernumber() +#endif + ); +#endif + } +#ifdef _FMVER21 + else + SetFMVarInit(charaindex); +#endif + +#endif + + AnnounceToPlayerWN( clifd ); + +#ifdef _ANGEL_SUMMON + { + int mindex; + mindex = checkIfOnlyAngel( charaindex); + if( mindex != -1 ) { + if( missiontable[mindex].flag == MISSION_WAIT_ANSWER ) { + lssproto_WN_send( clifd, WINDOW_MESSAGETYPE_ANGELMESSAGE, + WINDOW_BUTTONTYPE_YESNO, + CHAR_WINDOWTYPE_ANGEL_ASK, + -1, + "目前魔族肆虐,精灵们需要你的帮忙,前往寻找勇者来消灭这些魔族,你是否愿意帮忙?" ); + } + } + } +#endif + + print("\n登陆人物名称:%s ", CHAR_getChar(charaindex, CHAR_NAME ) ); + + { + unsigned long ip; + char ipstr[512]; + + ip=CONNECT_get_userip(clifd); + sprintf(ipstr,"%d.%d.%d.%d", + ((unsigned char *)&ip)[0], + ((unsigned char *)&ip)[1], + ((unsigned char *)&ip)[2], + ((unsigned char *)&ip)[3]); + + LogLogin( + CHAR_getChar( charaindex, CHAR_CDKEY), + CHAR_getChar( charaindex, CHAR_NAME), + saveindex, ipstr + ); + } + +#ifdef _TEACHER_SYSTEM + // 学生上线通知导师 + if(strlen(CHAR_getChar(charaindex,CHAR_TEACHER_ID)) > 0 && strlen(CHAR_getChar(charaindex,CHAR_TEACHER_NAME)) > 0){ + int iPlayernum = CHAR_getPlayerMaxNum(),i; + char szMsg[128]; + + for(i=0;i 0 && + strlen(CHAR_getChar(charaindex,CHAR_LOVERID))>0 && + strlen(CHAR_getChar(charaindex,CHAR_LOVERNAME))>0){ + int iPlayernum = CHAR_getPlayerMaxNum(),i; + char szMsg[128]; + for(i=0;idata[CHAR_SAVEINDEXNUMBER]); + saacproto_ACCharSave_send( acfd, cdkey, + ch->string[CHAR_NAME].string, + CHAR_makeOptionString( ch ), chardata, + unlock, CONNECT_getFdid(fd), ch->data[CHAR_SAVEINDEXNUMBER] ); +#else + saacproto_ACCharSave_send( acfd, cdkey, + ch->string[CHAR_NAME].string, + CHAR_makeOptionString( ch ), chardata, + unlock, CONNECT_getFdid(fd) ); +#endif + return TRUE; +} + +BOOL CHAR_charSaveFromConnect( int fd , BOOL unlock) +{ + Char* ch; + int charaindex = CONNECT_getCharaindex(fd); + if( CHAR_CHECKINDEX( charaindex ) == FALSE)return FALSE; + ch = CHAR_getCharPointer( charaindex ); + if( !ch )return FALSE; +#ifdef _CHAR_POOLITEM + if( CHAR_SaveDepotItem( charaindex) == TRUE ){ + print("saveDepotItem:%d \n", charaindex); + } +#endif +#ifdef _CHAR_POOLPET + if( CHAR_SaveDepotPet( charaindex) == TRUE ){ + print("saveDepotPet:%d \n", charaindex); + } +#endif + + return CHAR_charSaveFromConnectAndChar( fd, ch, unlock ); +} + + +/*------------------------------------------------------------ + * 夫弘失它玄允月凛卞 匀凶引引夫弘失它玄匹五卅中失奶 丞毛 + * 允 + * 娄醒 + * charaindex int 平乓仿弁正□及奶件犯永弁旦 + * 忒曰袄 + * 卅仄 + ------------------------------------------------------------*/ +static void CHAR_dropItemAtLogout( int charaindex ) +{ + int i; + for( i=0 ; i= 0 ){ + BATTLE_EscapeDpSend( battleindex, charindex ); + CHAR_setInt( charindex, CHAR_DUELPOINT, + CHAR_getInt( charindex, CHAR_DUELPOINT ) + + CHAR_getWorkInt( charindex, CHAR_WORKGETEXP ) ); + BATTLE_Exit( charindex, battleindex ); + } + + CHAR_dropItemAtLogout( charindex ); + CHAR_DischargeParty( charindex, 0); + if(CHAR_getChar(charindex, CHAR_FMNAME) != NULL ) { + if(strlen(CHAR_getChar(charindex, CHAR_FMNAME)) > 0 && + strlen(CHAR_getChar(charindex, CHAR_FMNAME)) < sizeof( STRING32) ) + if( (CHAR_getInt(charindex, CHAR_FMINDEX) >= 0) && + (strcmp(CHAR_getChar(charindex, CHAR_FMNAME), "") != 0) ) { + saacproto_ACFMCharLogout_send(acfd, + CHAR_getChar(charindex, CHAR_FMNAME), + CHAR_getInt(charindex, CHAR_FMINDEX), + CHAR_getChar(charindex, CHAR_NAME), + CHAR_getChar(charindex, CHAR_CDKEY), + CHAR_getInt(charindex, CHAR_LV), + CHAR_getWorkInt(charindex, CHAR_WORKFMINDEXI), + CONNECT_getFdid(clifd)); + } + } + +#ifdef _CHATROOMPROTOCOL // (不可开) Syu ADD 聊天室频道 + if ( CHAR_getWorkInt ( charindex , CHAR_WORKCHATROOMTYPE ) != 0 ) { + ChatRoom_Leave ( charindex ) ; + } +#endif +#ifdef _STREET_VENDOR + // 若玩家是卖方且正在交易中 + if(CHAR_getWorkInt(charindex,CHAR_WORKSTREETVENDOR) == 2){ + // 取出和他交易的人 + toindex = CHAR_getWorkInt(charindex,CHAR_WORKSTREETVENDOR_WHO); + if(toindex > -1 && CHAR_CHECKINDEX(toindex)){ + CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR_WHO,-1); + CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR,-1); + lssproto_STREET_VENDOR_send(getfdFromCharaIndex(toindex),"C|"); + CHAR_talkToCli(toindex,-1,"店家取消交易",CHAR_COLORYELLOW); + } + } + // 玩家是买方 + else if(CHAR_getWorkInt(charindex,CHAR_WORKSTREETVENDOR) == 3){ + // 取出卖方 + toindex = CHAR_getWorkInt(charindex,CHAR_WORKSTREETVENDOR_WHO); + if(toindex > -1 && CHAR_CHECKINDEX(toindex)){ + CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR_WHO,-1); + CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR,1); + } + } +#endif + + // Robin 0606 channel + fmindexi = CHAR_getWorkInt(charindex, CHAR_WORKFMINDEXI); + channel = CHAR_getWorkInt(charindex, CHAR_WORKFMCHANNEL); + i = 0; + if( (fmindexi > 0) && (channel >= 0) && (fmindexi < FAMILY_MAXNUM) && (channel < FAMILY_MAXCHANNEL)) { + while( i < FAMILY_MAXMEMBER ) { + if( channelMember[fmindexi][channel][i] == charindex ) { + channelMember[fmindexi][channel][i] = -1; + break; + } + i++; + } + } +#ifdef _CHANNEL_MODIFY + if(CHAR_getInt(charindex,PROFESSION_CLASS) > 0){ + int i,pclass = CHAR_getInt(charindex,PROFESSION_CLASS) - 1; + for(i=0;i 0) && (fmindexi < FAMILY_MAXNUM)){ + if( familyMemberIndex[fmindexi][i] == charindex ) + familyMemberIndex[fmindexi][i] = -1; + } + } + // Robin 0629 silent + if( CHAR_getInt( charindex, CHAR_SILENT) > 0 ){ + int silent_t, login_t; + login_t = CHAR_getWorkInt(charindex, CHAR_WORKLOGINTIME); + silent_t = CHAR_getInt( charindex, CHAR_SILENT); + silent_t = silent_t - ( (int)NowTime.tv_sec-login_t); + if( silent_t<0 ) silent_t = 0; + CHAR_setInt( charindex, CHAR_SILENT, silent_t); + } + +#ifdef _ITEM_ADDEXP2 + if( CHAR_getWorkInt( charindex, CHAR_WORKITEM_ADDEXP) > 0 ) { + // 登入时智果效果自动减90秒 + CHAR_setWorkInt( charindex, CHAR_WORKITEM_ADDEXPTIME, + CHAR_getWorkInt( charindex, CHAR_WORKITEM_ADDEXPTIME) - 90 ); + if( CHAR_getWorkInt( charindex, CHAR_WORKITEM_ADDEXPTIME) <= 0 ) { + CHAR_setWorkInt( charindex, CHAR_WORKITEM_ADDEXPTIME, 0); + CHAR_setWorkInt( charindex, CHAR_WORKITEM_ADDEXP, 0); + } + } + CHAR_setInt( charindex, CHAR_ADDEXPPOWER, + CHAR_getWorkInt( charindex, CHAR_WORKITEM_ADDEXP) ); + CHAR_setInt( charindex, CHAR_ADDEXPTIME, + CHAR_getWorkInt( charindex, CHAR_WORKITEM_ADDEXPTIME) ); +#endif + +#ifdef _TIME_TICKET + if( check_TimeTicketMap( CHAR_getInt( charindex, CHAR_FLOOR)) ) { + CHAR_warpToSpecificPoint( charindex, 7001, 41, 6); + } +#endif + + // Robin add + CHAR_setInt( charindex, CHAR_LASTLEAVETIME, (int)time(NULL)); + + if( save ){ + CHAR_charSaveFromConnect( clifd ,TRUE); + } + +#ifndef _DEATH_CONTEND + ADDRESSBOOK_notifyLoginLogout(charindex,0); +#endif + CHAR_CharaDeleteHavePet( charindex); + CHAR_CharaDelete( charindex ); + + return ret; +} +/*------------------------------------------------------------ + * watch奶矛件玄毛霜月井升丹井民尼永弁允月 + * 娄醒 + * objindex int 奶矛件玄毛云仇仄凶平乓仿及左皮斥尼弁玄 + * 奶件犯永弁旦 + * index int 奶矛件玄毛云仇仄凶平乓仿及奶件犯永弁旦 + * recvindex int 奶矛件玄毛熬仃午月平乓仿及index + * chac int 失弁扑亦件及潘 + * 忒曰袄 TRUE: 霜匀化中中方 + * FALSE: 蛲 + ------------------------------------------------------------*/ +static BOOL CHAR_sendWatchEvent_sendCheck( int objindex, int index, + int recvindex, int chac) +{ + /* 愤坌互NPC匹锹澎手NPC及凛 仃月 */ + if( OBJECT_getType( objindex) == OBJTYPE_CHARA && + CHAR_getInt( index, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER && + CHAR_getInt(recvindex, CHAR_WHICHTYPE ) + != CHAR_TYPEPLAYER ) + { + return FALSE; + } + /* 平乓仿动陆及watch 反民尼永弁 仄卞蕞 */ + if( OBJECT_getType( objindex) != OBJTYPE_CHARA) { + return TRUE; + } + /* + * 愤坌尺及汹五及 反 仄卞允月 + */ + if( index == recvindex && chac == CHAR_ACTWALK ) { + return FALSE; + } + + if( CHAR_getInt( recvindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + /* 爵 及谛卞反 蛲分井日霜耨仄卅中 */ + if( CHAR_getWorkInt( recvindex,CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) + { + return FALSE; + } + /* 失弁扑亦件元扎 中凛 */ + if( CHAR_getWorkInt( index, CHAR_WORKACTION) == -1 ) { + if( OBJECT_getType(objindex) == OBJTYPE_CHARA) { + /* 元由□ 奴分匀凶日 + * 褪动陆反职及丢件田□卞汹五毛霜耨仄卅中 + */ + if( CHAR_getWorkInt( index, CHAR_WORKPARTYMODE ) + == CHAR_PARTY_CLIENT && + CHAR_getWorkInt( recvindex, CHAR_WORKPARTYMODE) + != CHAR_PARTY_NONE && + chac == CHAR_ACTWALK ) + { + int found = FALSE; + int loop; + /* 阂毛譬屯月 */ + for( loop = 1; loop < CHAR_PARTYMAX; loop ++ ) { + int partycharaindex = CHAR_getPartyIndex( recvindex, loop); + /* 中凶平乓仿互愤坌及由□ 奴及阂分匀凶 */ + if( partycharaindex == index ) { + found = TRUE; + break; + } + } + if( found ) return FALSE; + } + /* 褪反阂及STAND毛霜耨仄卅中 */ + if( CHAR_getWorkInt( index, CHAR_WORKPARTYMODE) + == CHAR_PARTY_CLIENT && + CHAR_getWorkInt( recvindex, CHAR_WORKPARTYMODE) + == CHAR_PARTY_LEADER && + chac == CHAR_ACTSTAND) + { + int found = FALSE; + int loop; + /* 阂毛譬屯月 */ + for( loop = 1; loop < CHAR_PARTYMAX; loop ++ ) { + int partycharaindex + = CHAR_getWorkInt( recvindex, + CHAR_WORKPARTYINDEX1+loop); + /* STAND仄凶平乓仿互愤坌及由□ 奴及阂分匀凶 */ + if( partycharaindex == index ) { + found = TRUE; + break; + } + } + if( found ) return FALSE; + } + } + } + } + return TRUE; +} + +void CHAR_sendWatchEvent( int objindex, int chac, int* opt, + int optlen,BOOL myflg ) +{ + int i; + int j; + int x=0,y=0,dir=0; + int floor; + int watchopt[32]; + int watchoptlen=0; + typedef void (*WATCHF)(int,int,CHAR_ACTION,int,int,int,int*,int); + int index; + + if( !CHECKOBJECTUSE(objindex) )return; + index = OBJECT_getIndex( objindex); + switch( OBJECT_getType(objindex) ){ + case OBJTYPE_CHARA: + for( i=0; i= 4 ){ + return; + } + // 引分由仿丢□正失永皿匹五月井" + cnt = CHAR_getInt(charaindex,CHAR_SKILLUPPOINT); + if( cnt <= 0 )return; + +#ifdef _CHAR_PROFESSION // WON ADD 人物职业栏位 + { + int p_class = CHAR_getInt( charaindex, PROFESSION_CLASS ); + int fd=-1; + + switch( p_class ){ + case PROFESSION_CLASS_FIGHTER: + // 勇士锁敏200 + if( SkUpTbl[skillid] == CHAR_DEX ){ + if( CHAR_getInt( charaindex, SkUpTbl[skillid] ) >= 200 * 100 ){ + CHAR_talkToCli(charaindex, -1, "你的能力值已达上限", CHAR_COLORYELLOW ); + fd = getfdFromCharaIndex(charaindex); + if( fd != -1 ) lssproto_SKUP_send( fd, cnt ); + return; + } + } + break; + case PROFESSION_CLASS_WIZARD: + // 巫师锁攻200 + if( SkUpTbl[skillid] == CHAR_STR ){ + if( CHAR_getInt( charaindex, SkUpTbl[skillid] ) >= 200 * 100 ){ + CHAR_talkToCli(charaindex, -1, "你的能力值已达上限", CHAR_COLORYELLOW ); + fd = getfdFromCharaIndex(charaindex); + if( fd != -1 ) lssproto_SKUP_send( fd, cnt ); + return; + } + } + // 巫师锁防200 + if( SkUpTbl[skillid] == CHAR_TOUGH ){ + if( CHAR_getInt( charaindex, SkUpTbl[skillid] ) >= 200 * 100 ){ + CHAR_talkToCli(charaindex, -1, "你的能力值已达上限", CHAR_COLORYELLOW ); + fd = getfdFromCharaIndex(charaindex); + if( fd != -1 ) lssproto_SKUP_send( fd, cnt ); + return; + } + } + break; + case PROFESSION_CLASS_HUNTER: + // 猎人锁攻200 + if( SkUpTbl[skillid] == CHAR_STR ){ + if( CHAR_getInt( charaindex, SkUpTbl[skillid] ) >= 200 * 100 ){ + CHAR_talkToCli(charaindex, -1, "你的能力值已达上限", CHAR_COLORYELLOW ); + fd = getfdFromCharaIndex(charaindex); + if( fd != -1 ) lssproto_SKUP_send( fd, cnt ); + return; + } + } + // 猎人锁防200 + if( SkUpTbl[skillid] == CHAR_TOUGH ){ + if( CHAR_getInt( charaindex, SkUpTbl[skillid] ) >= 200 * 100 ){ + CHAR_talkToCli(charaindex, -1, "你的能力值已达上限", CHAR_COLORYELLOW ); + fd = getfdFromCharaIndex(charaindex); + if( fd != -1 ) lssproto_SKUP_send( fd, cnt ); + return; + } + } + // 猎人锁敏400 + if( SkUpTbl[skillid] == CHAR_DEX ){ + if( CHAR_getInt( charaindex, SkUpTbl[skillid] ) >= 400 * 100 ){ + CHAR_talkToCli(charaindex, -1, "你的能力值已达上限", CHAR_COLORYELLOW ); + fd = getfdFromCharaIndex(charaindex); + if( fd != -1 ) lssproto_SKUP_send( fd, cnt ); + return; + } + } + break; + default: break; + } + + fd = getfdFromCharaIndex(charaindex); + if( fd != -1 ) lssproto_SKUP_send( fd, cnt-1 ); + } +#endif + + CHAR_setInt( charaindex,CHAR_SKILLUPPOINT,cnt-1); + CHAR_setInt( charaindex, SkUpTbl[skillid], CHAR_getInt( charaindex, SkUpTbl[skillid] ) + 1*100 ); + + CHAR_complianceParameter(charaindex); + CHAR_send_P_StatusString( charaindex, SendTbl[skillid]); + +#ifdef _ANGEL_SUMMON // 加点时检查资格 + if( cnt-1 == 0 ) + //selectAngel( charaindex); + selectAngel( charaindex, -1, -1 , FALSE); + +#endif + } + CHAR_PartyUpdate( charaindex, CHAR_N_STRING_MAXHP ); + +} + +INLINE void CHAR_getDXDY( int dir , int* dx, int* dy ) +{ + static POINT CHAR_dxdy[8]= + { + { 0,-1}, /* */ + { 1,-1}, /* */ + { 1, 0}, /* */ + { 1, 1}, /* */ + { 0, 1}, /* */ + {-1, 1}, /* */ + {-1, 0}, /* */ + {-1,-1}, /* */ + }; + VALIDATEDIR(dir); + + if( dx )*dx = CHAR_dxdy[dir].x; + if( dy )*dy = CHAR_dxdy[dir].y; +} +INLINE int CHAR_getDX( int dir ) +{ + int tmp; + CHAR_getDXDY( dir,&tmp,NULL); + return tmp; +} +INLINE int CHAR_getDY( int dir ) +{ + int tmp; + CHAR_getDXDY( dir,NULL,&tmp); + return tmp; +} + +/*------------------------------------------------------------ + * 元穴旦及平乓仿弁正□毛 月[ + * 娄醒 + * objbuf int* object 匹及 index 毛医 允月 + * 田永白央 + * siz int objbuf 及 扔奶术 + * ff int 白夫失 + * fx int x + * fy int y + * 忒曰袄 + * 窒蜊平乓仿互中月井[ + ------------------------------------------------------------*/ +int CHAR_getSameCoordinateObjects(int* objbuf, int siz,int ff, int fx, + int fy) +{ + OBJECT object; + int findobjnum=0; + + for( object = MAP_getTopObj(ff,fx,fy) ; object ; + object = NEXT_OBJECT(object ) ){ + int objindex = GET_OBJINDEX(object); + + if( siz <= findobjnum )break; + if( OBJECT_getType(objindex) != OBJTYPE_NOUSE ) + objbuf[findobjnum++] = objindex; + } + return findobjnum; +} + + +/*====================平乓仿及树 毛 月烟及楮醒====================*/ +/*左皿扑亦件犯□正及 侬 毛忡绣允月楮醒*/ +static char CHAR_optiondataString[STRINGBUFSIZ]; +/*------------------------------------------------------------ + * 左皿扑亦件迕及 侬 毛综月[ + * level, showstring , 熔及醒 , 飓 寞} 窒荚夫弘奶件仄凶井[ + * 弁仿旦[ + * 娄醒 + * ch Char* 平乓仿犯□正 + * 忒曰袄 + * char* static 卅 毛忒允及匹戚荚及裟太请仄及凛卞反 互 + * 凳今木化中月[娄醒毛公及引引忡绣仄卅中仪[ + ------------------------------------------------------------*/ +char* CHAR_makeOptionString( Char* ch ) +{ + char escapeshowstring[256]; + char *showstr = MAP_getfloorShowstring(ch->data[CHAR_FLOOR]); + if( ! showstr ){ + CHAR_optiondataString[0] = '\0'; + return CHAR_optiondataString; + } else { + +#if 0 /* 动票反LS2酷 匹丐月 */ + snprintf( CHAR_optiondataString, + sizeof( CHAR_optiondataString ), + "%d|%s|1|%d|%d", + ch->data[CHAR_LV], + makeEscapeString( showstr , + escapeshowstring,sizeof(escapeshowstring) ), + ch->data[CHAR_BASEIMAGENUMBER], + ch->data[CHAR_LOGINCOUNT]); +#endif + + /* 动票反StoneAge 酷 匹丐月[ + + dataplace|faceimg|level|hp|str|def|dex|charm|dp|earth|water|fire|wind|login|Name|Place + 午卅月[ + */ + { + snprintf( CHAR_optiondataString, + sizeof( CHAR_optiondataString ), + "%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%s|%s", + ch->data[CHAR_DATAPLACENUMBER], + ch->data[CHAR_FACEIMAGENUMBER], + ch->data[CHAR_LV], + ch->workint[CHAR_WORKMAXHP], + ch->workint[CHAR_WORKATTACKPOWER], + ch->workint[CHAR_WORKDEFENCEPOWER], + ch->workint[CHAR_WORKQUICK], + ch->workint[CHAR_WORKFIXCHARM], + ch->data[CHAR_DUELPOINT], /* dp, FIXME */ + ch->workint[CHAR_WORKFIXEARTHAT], + ch->workint[CHAR_WORKFIXWATERAT], + ch->workint[CHAR_WORKFIXFIREAT], + ch->workint[CHAR_WORKFIXWINDAT], + ch->data[CHAR_LOGINCOUNT], + ch->string[CHAR_NAME].string, + makeEscapeString( showstr , + escapeshowstring, + sizeof(escapeshowstring) ) + ); + } + } + return CHAR_optiondataString; +} + +static char CHAR_statusSendBuffer[STRINGBUFSIZ]; + +char* CHAR_makeStatusString( int index, char* category ) +{ + char c = tolower( category[0] ); + int strlength=0; + + if( !CHAR_CHECKINDEX( index ) ) return NULL; + + if( category == NULL ){ + CHAR_statusSendBuffer[0] = '\0'; + return CHAR_statusSendBuffer; + } +DebugPoint = 100; + switch( c ){ + case 'p': + { + int i; + int getCharDataArray[]= { + CHAR_NAME, + CHAR_OWNTITLE, + //CHAR_FMNAME, + }; + int maxexp = 200; + int exp; + int attr[4]; + { + exp = CHAR_getInt(index,CHAR_EXP ); + maxexp = CHAR_GetLevelExp( index, CHAR_getInt( index, CHAR_LV ) + 1 ); + } + + for( i = 0; i < 4; i ++ ) { + attr[i] = CHAR_getWorkInt( index, CHAR_WORKFIXEARTHAT + i); + if( attr[i] < 0 ) attr[i] = 0; + } + + snprintf(CHAR_statusSendBuffer,sizeof(CHAR_statusSendBuffer), + "P1|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|", + CHAR_getInt(index,CHAR_HP), + CHAR_getWorkInt(index,CHAR_WORKMAXHP), + CHAR_getInt(index,CHAR_MP), + CHAR_getWorkInt(index,CHAR_WORKMAXMP), + CHAR_getInt(index,CHAR_VITAL)/100, + CHAR_getInt(index,CHAR_STR)/100, + CHAR_getInt(index,CHAR_TOUGH)/100, + CHAR_getInt(index,CHAR_DEX)/100, + exp, maxexp, + CHAR_getInt(index,CHAR_LV), + CHAR_getWorkInt(index,CHAR_WORKATTACKPOWER), + CHAR_getWorkInt(index,CHAR_WORKDEFENCEPOWER), + CHAR_getWorkInt( index, CHAR_WORKQUICK), + CHAR_getWorkInt( index, CHAR_WORKFIXCHARM), + CHAR_getWorkInt( index, CHAR_WORKFIXLUCK), + attr[0], + attr[1], + attr[2], + attr[3], + CHAR_getInt(index,CHAR_GOLD), + CHAR_getInt(index,CHAR_INDEXOFEQTITLE), + CHAR_getInt(index,CHAR_DUELPOINT), + CHAR_getInt( index, CHAR_TRANSMIGRATION), + CHAR_getInt(index,CHAR_RIDEPET), + CHAR_getInt(index,CHAR_LEARNRIDE), + CHAR_getInt(index,CHAR_BASEBASEIMAGENUMBER) +#ifdef _NEW_RIDEPETS + ,CHAR_getInt( index, CHAR_LOWRIDEPETS) +#endif + + ); + strlength = strlen( CHAR_statusSendBuffer ); + for( i = 0 ; i < arraysizeof( getCharDataArray ) ; i ++ ){ + char token[256]; + char escapebuffer[128]; + snprintf( token, + sizeof( token ), + "%s" STATUSSENDDELIMITER, + makeEscapeString( CHAR_getChar(index, getCharDataArray[i]), + escapebuffer,sizeof(escapebuffer) + )); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof( CHAR_statusSendBuffer ) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= sizeof( CHAR_statusSendBuffer ) ) + return CHAR_statusSendBuffer; + } + return CHAR_statusSendBuffer; + break; + } +#ifdef _NEW_RIDEPETS + case 'x': + { + snprintf(CHAR_statusSendBuffer,sizeof(CHAR_statusSendBuffer), "X0|%d", + CHAR_getInt( index, CHAR_LOWRIDEPETS)); + return CHAR_statusSendBuffer; + break; + } +#endif + case 'f': + { + int big4fm =0; +#ifndef _NEW_RIDEPETS + switch( CHAR_getWorkInt( index, CHAR_WORKFMFLOOR) ) + { + case 1041: + big4fm = 1; + break; + case 2031: + big4fm = 2; + break; + case 3031: + big4fm = 3; + break; + case 4031: + big4fm = 4; + break; + default: + big4fm = 0; + } +#endif +#ifdef _FIX_FMNAME_RULE // WON ADD 家族未成立,不显示名称 + if( CHAR_getWorkInt(index, CHAR_WORKFMSETUPFLAG)==1 ){ + snprintf( CHAR_statusSendBuffer, + sizeof( CHAR_statusSendBuffer ), + "F%s|%d|%d|%d|%d", + "(待审)", + CHAR_getInt( index, CHAR_FMLEADERFLAG), + CHAR_getWorkInt( index, CHAR_WORKFMCHANNEL), + CHAR_getInt( index, CHAR_FMSPRITE), big4fm ); + }else +#endif + + snprintf( CHAR_statusSendBuffer, + sizeof( CHAR_statusSendBuffer ), + "F%s|%d|%d|%d|%d", + CHAR_getChar( index, CHAR_FMNAME), + CHAR_getInt( index, CHAR_FMLEADERFLAG), + CHAR_getWorkInt( index, CHAR_WORKFMCHANNEL), + CHAR_getInt( index, CHAR_FMSPRITE), big4fm ); + return CHAR_statusSendBuffer; + break; + } + case 'c': + { + int floor,xsiz,ysiz; + floor = CHAR_getInt(index,CHAR_FLOOR); + xsiz = MAP_getfloorX(floor); + ysiz = MAP_getfloorY(floor); + snprintf( CHAR_statusSendBuffer, + sizeof( CHAR_statusSendBuffer ), + "C%d|%d|%d|%d|%d", + CHAR_getInt(index,CHAR_FLOOR), + xsiz, ysiz, + CHAR_getInt(index,CHAR_X), + CHAR_getInt(index,CHAR_Y) ); + return CHAR_statusSendBuffer; + break; + } + case 'i': + { + int i; + CHAR_statusSendBuffer[0] = 'I'; + strlength = 1; + for( i = 0 ; i < CHAR_MAXITEMHAVE ; i ++ ){ + char token[512]; + int itemindex; + itemindex = CHAR_getItemIndex( index, i ); + if( itemindex >= 0 ) { + snprintf( token ,sizeof(token),"%s|" ,ITEM_makeItemStatusString( -1, itemindex ) ); + }else { + snprintf( token ,sizeof(token),"%s|" , ITEM_makeItemFalseString() ); + } + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof(CHAR_statusSendBuffer) - strlength, token ); + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_statusSendBuffer) ) return CHAR_statusSendBuffer; + } + dchop( CHAR_statusSendBuffer , "|" ); + return CHAR_statusSendBuffer; + break; + } + case 's': + { + int i; + CHAR_statusSendBuffer[0] = 'S'; + strlength = 1; + + for( i = 0 ; i < CHAR_SKILLMAXHAVE ; i ++ ){ + char token[256]; + CHAR_HaveSkill* hskill; + + hskill = CHAR_getCharHaveSkill( index, i ); + + if( hskill != NULL && hskill->use == TRUE ){ +#ifdef _CHAR_PROFESSION // WON ADD 人物职业 + snprintf( token , sizeof(token), "%s|", SKILL_makeSkillStatusString(&hskill->skill, index, i) ); +#else + snprintf( token , sizeof(token), "%s|", SKILL_makeSkillStatusString(&hskill->skill) ); +#endif + }else{ + snprintf( token , sizeof(token), "%s|", SKILL_makeSkillFalseString() ); + } + + strcpysafe( CHAR_statusSendBuffer + strlength, sizeof(CHAR_statusSendBuffer)-strlength, token ); + + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_statusSendBuffer) ) + return CHAR_statusSendBuffer; + } + + dchop( CHAR_statusSendBuffer , "|" ); + return CHAR_statusSendBuffer; + break; + } + case 't': + { + int i; + CHAR_statusSendBuffer[0] = 'T'; + strlength = 1; + for( i = 0 ; i < CHAR_TITLEMAXHAVE ; i ++ ){ + char token[256]; + char escape[256]; + snprintf( token , sizeof(token), "%s|" , + makeEscapeString( TITLE_makeTitleStatusString(index, + i ), + escape,sizeof(escape) ) ); + + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof(CHAR_statusSendBuffer) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_statusSendBuffer) ) + return CHAR_statusSendBuffer; + } + dchop( CHAR_statusSendBuffer , "|" ); + return CHAR_statusSendBuffer; + break; + } + case 'd': + snprintf( CHAR_statusSendBuffer,sizeof(CHAR_statusSendBuffer), + "D%d|%ld",CHAR_getWorkInt(index,CHAR_WORKOBJINDEX), + NowTime.tv_sec ); + return CHAR_statusSendBuffer; + break; + case 'm': + snprintf( CHAR_statusSendBuffer,sizeof(CHAR_statusSendBuffer), + "M%d|%d|%d", + CHAR_getInt( index,CHAR_HP ), + CHAR_getInt( index,CHAR_MP ), + CHAR_getInt( index,CHAR_EXP ) ); + return CHAR_statusSendBuffer; + break; + case 'e': + return NULL; + + case 'n': + { + int num; + + int i, nindex = -1; + int getCharDataArray[]= { + CHAR_NAME + }; + num = tolower( category[1] ) - '0'; + + if( num < 0 || num >= CHAR_PARTYMAX ){ + print( "朋友模式失败 (%c)%d \n", num, num ); + break; + } + + nindex = CHAR_getPartyIndex( index, num); + + if( nindex == -1 ){ + snprintf(CHAR_statusSendBuffer,sizeof(CHAR_statusSendBuffer), + "N%d|0|", num ); + return CHAR_statusSendBuffer; + }else{ + snprintf(CHAR_statusSendBuffer,sizeof(CHAR_statusSendBuffer), + "N%d|1|%d|%d|%d|%d|%d|", + num, + CHAR_getWorkInt( nindex, CHAR_WORKOBJINDEX), + CHAR_getInt( nindex, CHAR_LV), + CHAR_getWorkInt( nindex, CHAR_WORKMAXHP), + CHAR_getInt( nindex, CHAR_HP), + CHAR_getInt( nindex, CHAR_MP) + + ); + } + strlength = strlen( CHAR_statusSendBuffer ); + + for( i = 0 ; i < arraysizeof( getCharDataArray ) ; i ++ ){ + char token[256]; + char escapebuffer[128]; + snprintf( token, + sizeof( token ), + "%s" STATUSSENDDELIMITER, + makeEscapeString( CHAR_getChar(nindex, + getCharDataArray[i]), + escapebuffer,sizeof(escapebuffer) + )); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof( CHAR_statusSendBuffer ) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= sizeof( CHAR_statusSendBuffer ) ) + return CHAR_statusSendBuffer; + } + + return CHAR_statusSendBuffer; + break; + } + case 'k': + { + int num; + int i, pindex; + int getCharDataArray[]= { + CHAR_NAME, + CHAR_USERPETNAME, + }; + num = tolower( category[1] ) - '0'; + if( num < 0 || num >= CHAR_MAXPETHAVE ){ + print( "宠物模式失败 (%c)%d \n", num, num ); + break; + } + pindex = CHAR_getCharPet( index, num ); + if( pindex == -1 ){ + snprintf(CHAR_statusSendBuffer,sizeof(CHAR_statusSendBuffer), + "K%d|0|", num ); + return CHAR_statusSendBuffer; + }else{ + int attr[4]; + BOOL changenameflg = FALSE; + char *mycdkey; + char *cdkey = NULL; + for( i = 0; i < 4; i ++ ) { + attr[i] = CHAR_getWorkInt( pindex, CHAR_WORKFIXEARTHAT + i); + if( attr[i] < 0 ) attr[i] = 0; + } + mycdkey = CHAR_getChar( index, CHAR_CDKEY); + { + cdkey = CHAR_getChar( pindex, CHAR_CDKEY); + if( cdkey == NULL ) { + print( "can't get CDKEY\n"); + }else { + + if( strlen( cdkey) == 0 || + strcmp( cdkey, mycdkey) == 0 ){ + changenameflg = TRUE; + } + } + } + snprintf(CHAR_statusSendBuffer,sizeof(CHAR_statusSendBuffer), +// Syu ADD 改变交易时宠物转生颜色 +#ifdef _SHOW_FUSION + "K%d|1|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|", +#else + "K%d|1|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|", +#endif + num, + CHAR_getInt(pindex,CHAR_BASEIMAGENUMBER), + CHAR_getInt(pindex,CHAR_HP), + CHAR_getWorkInt(pindex,CHAR_WORKMAXHP), + CHAR_getInt(pindex,CHAR_MP), + CHAR_getWorkInt(pindex,CHAR_WORKMAXMP), + CHAR_getInt(pindex,CHAR_EXP ), + CHAR_GetLevelExp( pindex,CHAR_getInt( pindex, CHAR_LV ) + 1 ), + CHAR_getInt(pindex,CHAR_LV), + CHAR_getWorkInt(pindex,CHAR_WORKATTACKPOWER), + CHAR_getWorkInt(pindex,CHAR_WORKDEFENCEPOWER), + CHAR_getWorkInt( pindex, CHAR_WORKQUICK), + CHAR_getWorkInt( pindex, CHAR_WORKFIXAI), + attr[0], + attr[1], + attr[2], + attr[3], + CHAR_getInt( pindex, CHAR_SLOT), +// Syu ADD 改变交易时宠物转生颜色 + changenameflg, + CHAR_getInt( pindex,CHAR_TRANSMIGRATION) +#ifdef _SHOW_FUSION + ,CHAR_getInt ( pindex, CHAR_FUSIONBEIT) +#endif + ); + } + strlength = strlen( CHAR_statusSendBuffer ); + for( i = 0 ; i < arraysizeof( getCharDataArray ) ; i ++ ){ + char token[256]; + char escapebuffer[128]; + snprintf( token, + sizeof( token ), + "%s" STATUSSENDDELIMITER, + makeEscapeString( CHAR_getChar(pindex, + getCharDataArray[i]), + escapebuffer,sizeof(escapebuffer) + )); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof( CHAR_statusSendBuffer ) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= sizeof( CHAR_statusSendBuffer ) ) + return CHAR_statusSendBuffer; + } + return CHAR_statusSendBuffer; + break; + } + + case 'j': +{ + + int num; + int i, itemindex; + int getMagicDataArray[]= { + MAGIC_NAME, + MAGIC_COMMENT, + }; + num = tolower( category[1] ) - '0'; + + if( num < 0 || num >= CHAR_EQUIPPLACENUM ){ + break; + } + + itemindex = CHAR_getItemIndex( index, num ); + if( !ITEM_CHECKINDEX( itemindex) ) { + snprintf(CHAR_statusSendBuffer,sizeof(CHAR_statusSendBuffer), + "J%d|0|", num ); + return CHAR_statusSendBuffer; + }else{ + int magicindex = MAGIC_getMagicArray( ITEM_getInt( itemindex, ITEM_MAGICID)); + if( magicindex == -1 ) { + snprintf(CHAR_statusSendBuffer,sizeof(CHAR_statusSendBuffer), + "J%d|0|", num ); + return CHAR_statusSendBuffer; + } + snprintf(CHAR_statusSendBuffer,sizeof(CHAR_statusSendBuffer), + "J%d|1|%d|%d|%d|", + num, + ITEM_getInt( itemindex, ITEM_MAGICUSEMP), + MAGIC_getInt( magicindex, MAGIC_FIELD), + MAGIC_getInt( magicindex, MAGIC_TARGET)); + strlength = strlen( CHAR_statusSendBuffer ); + + for( i = 0 ; i < arraysizeof( getMagicDataArray ) ; i ++ ){ + char token[256]; + char escapebuffer[128]; + snprintf( token, + sizeof( token ), + "%s" STATUSSENDDELIMITER, + makeEscapeString( MAGIC_getChar(magicindex, + getMagicDataArray[i]), + escapebuffer,sizeof(escapebuffer) + )); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof( CHAR_statusSendBuffer ) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= sizeof( CHAR_statusSendBuffer ) ) + return CHAR_statusSendBuffer; + } + return CHAR_statusSendBuffer; + } + } + break; + + case 'w': +{ + int num; + int i,petskillloop, pindex; + char tmp[16]; + int getPetSkillDataArray[]= { + PETSKILL_NAME, + PETSKILL_COMMENT, + }; + + num = tolower( category[1] ) - '0'; + if( num < 0 || num >= CHAR_MAXPETHAVE ){ + print( "宠物特技资料失败 (%c)%d \n", num, num ); + break; + } + + pindex = CHAR_getCharPet( index, num ); + if( !CHAR_CHECKINDEX(pindex)){ + return NULL; + } + snprintf( tmp, sizeof( tmp), "W%d|", num); + strcpysafe( CHAR_statusSendBuffer, sizeof( CHAR_statusSendBuffer), + tmp); + strlength += strlen( tmp); + if( strlength >= arraysizeof( CHAR_statusSendBuffer) ) { + return CHAR_statusSendBuffer; + } + for( petskillloop = 0; petskillloop < CHAR_MAXPETSKILLHAVE; petskillloop ++ ) { + int skillid = CHAR_getPetSkill( pindex, petskillloop); + int petskillindex = PETSKILL_getPetskillArray( skillid ); + if( PETSKILL_CHECKINDEX( petskillindex) ) { + char token[256]; + snprintf( token, sizeof( token), + "%d|%d|%d|", + + PETSKILL_getInt( petskillindex, PETSKILL_ID), + PETSKILL_getInt( petskillindex, PETSKILL_FIELD), + PETSKILL_getInt( petskillindex, PETSKILL_TARGET) + ); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof(CHAR_statusSendBuffer) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_statusSendBuffer)) { + return CHAR_statusSendBuffer; + } + + for( i = 0 ; i < arraysizeof( getPetSkillDataArray ) ; i ++ ){ + char escapebuffer[128]; + snprintf( token, + sizeof( token ), + "%s" STATUSSENDDELIMITER, + makeEscapeString( + PETSKILL_getChar(petskillindex, + getPetSkillDataArray[i]), + escapebuffer,sizeof(escapebuffer) + )); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof( CHAR_statusSendBuffer ) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= sizeof( CHAR_statusSendBuffer )) { + return CHAR_statusSendBuffer; + } + } + } + else { + char token[256]; + snprintf( token, sizeof( token),"|||||"); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof(CHAR_statusSendBuffer) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_statusSendBuffer) ) { + return CHAR_statusSendBuffer; + } + } + } + return CHAR_statusSendBuffer; +} + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + case 'y': +{ + int num = 0, f_num = 0; + int i,petskillloop, pindex; + char tmp[16]; + int getPetSkillDataArray[]= { + PETSKILL_NAME, + PETSKILL_COMMENT, + }; + + num = tolower( category[1] ) - '0'; + if( num < 0 || num >= CHAR_MAXPETHAVE ){ + print( "宠物特技资料失败 (%c)%d \n", num, num ); + break; + } + + pindex = CHAR_getCharPet( index, num ); + if( !CHAR_CHECKINDEX(pindex)){ + return NULL; + } + snprintf( tmp, sizeof( tmp), "W%d|", num); + strcpysafe( CHAR_statusSendBuffer, sizeof( CHAR_statusSendBuffer), + tmp); + strlength += strlen( tmp); + if( strlength >= arraysizeof( CHAR_statusSendBuffer) ) { + return CHAR_statusSendBuffer; + } + + if( CHAR_getWorkInt( pindex, CHAR_WORKOBLIVION) > 0 ) + f_num = CHAR_getWorkInt( pindex, CHAR_WORKMODOBLIVION ) + 1;// 遗忘宠技数量 + + for( petskillloop = 0; petskillloop < CHAR_MAXPETSKILLHAVE; petskillloop ++ ) { + int skillid = CHAR_getPetSkill( pindex, petskillloop); + int petskillindex = PETSKILL_getPetskillArray( skillid ); + if( PETSKILL_CHECKINDEX( petskillindex) ) { + char token[256]; + int field = -1, target = -1; + int oblivion = CHAR_getWorkInt( pindex, CHAR_WORKOBLIVION ); + int p_id = PETSKILL_getInt( petskillindex, PETSKILL_ID); + int rand_num = RAND( 0, 100 ); + + // 中了遗忘 + if( (oblivion > 0) && ( f_num > 0 ) && ( rand_num <= 60 ) && ( p_id != 1 ) ){ + field = PETSKILL_FIELD_MAP; + target = PETSKILL_TARGET_NONE; + f_num --; + }else{ + field = PETSKILL_getInt( petskillindex, PETSKILL_FIELD); + target = PETSKILL_getInt( petskillindex, PETSKILL_TARGET); + } + + snprintf( token, sizeof( token),"%d|%d|%d|", +// PETSKILL_getInt( petskillindex, PETSKILL_ID), + p_id, + field, target + ); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof(CHAR_statusSendBuffer) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_statusSendBuffer)) { + return CHAR_statusSendBuffer; + } + + for( i = 0 ; i < arraysizeof( getPetSkillDataArray ) ; i ++ ){ + char escapebuffer[128]; + snprintf( token, + sizeof( token ), + "%s" STATUSSENDDELIMITER, + makeEscapeString( + PETSKILL_getChar(petskillindex, + getPetSkillDataArray[i]), + escapebuffer,sizeof(escapebuffer) + )); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof( CHAR_statusSendBuffer ) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= sizeof( CHAR_statusSendBuffer )) { + return CHAR_statusSendBuffer; + } + } + } + else { + char token[256]; + snprintf( token, sizeof( token),"|||||"); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof(CHAR_statusSendBuffer) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_statusSendBuffer) ) { + return CHAR_statusSendBuffer; + } + } + } + return CHAR_statusSendBuffer; +} +#endif + +#ifdef _PETSKILL_DAMAGETOHP + case 'o': +{ + int getPetSkillDataArray[]= { + PETSKILL_NAME, + PETSKILL_COMMENT, + }; + int i,petskillloop, pindex=index; + int num = 0;//, f_num = 0; + char tmp[16]; + + num = tolower( category[1] ) - '0'; + if( num < 0 || num >= CHAR_MAXPETHAVE ){ + print( "宠物特技资料失败 (%c)%d \n", num, num ); + break; + } + + pindex = CHAR_getCharPet( index, num ); + if( !CHAR_CHECKINDEX(pindex)){ + return NULL; + } + snprintf( tmp, sizeof( tmp), "W%d|", num); + strcpysafe( CHAR_statusSendBuffer, sizeof( CHAR_statusSendBuffer), + tmp); + strlength += strlen( tmp); + if( strlength >= arraysizeof( CHAR_statusSendBuffer) ) { + return CHAR_statusSendBuffer; + } + + for( petskillloop = 0; petskillloop < CHAR_MAXPETSKILLHAVE; petskillloop ++ ) { + int skillid = CHAR_getPetSkill( pindex, petskillloop); + int petskillindex = PETSKILL_getPetskillArray( skillid ); + if( PETSKILL_CHECKINDEX( petskillindex) ) { + char token[256]; + int field = -1, target = -1; + //int oblivion = CHAR_getWorkInt( pindex, CHAR_WORKOBLIVION ); + int p_id = PETSKILL_getInt( petskillindex, PETSKILL_ID); + + //生命大於50%且技能名称若为 浴血狂袭 技能不能选 + if( ( CHAR_getInt( pindex, CHAR_HP ) > CHAR_getWorkInt( pindex, CHAR_WORKMAXHP )*0.5 + && strcmp(PETSKILL_getChar( petskillindex, PETSKILL_NAME),"浴血狂袭" ) == 0 ) +#ifdef _PETSKILL_EXPLODE + || ( CHAR_getInt( pindex, CHAR_HP ) < (CHAR_getWorkInt( pindex, CHAR_WORKMAXHP ) >> 1 ) + && strcmp(PETSKILL_getChar( petskillindex, PETSKILL_NAME),"爆裂攻击" ) == 0 ) +#endif + ){ + field = PETSKILL_FIELD_MAP; + target = PETSKILL_TARGET_NONE; + }else{ + field = PETSKILL_getInt( petskillindex, PETSKILL_FIELD); + target = PETSKILL_getInt( petskillindex, PETSKILL_TARGET); + } + + snprintf( token, sizeof( token),"%d|%d|%d|", +// PETSKILL_getInt( petskillindex, PETSKILL_ID), + p_id, + field, target + ); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof(CHAR_statusSendBuffer) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_statusSendBuffer)) { + return CHAR_statusSendBuffer; + } + + for( i = 0 ; i < arraysizeof( getPetSkillDataArray ) ; i ++ ){ + char escapebuffer[128]; + snprintf( token, + sizeof( token ), + "%s" STATUSSENDDELIMITER, + makeEscapeString( + PETSKILL_getChar(petskillindex, + getPetSkillDataArray[i]), + escapebuffer,sizeof(escapebuffer) + )); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof( CHAR_statusSendBuffer ) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= sizeof( CHAR_statusSendBuffer )) { + return CHAR_statusSendBuffer; + } + } + } + else { + char token[256]; + snprintf( token, sizeof( token),"|||||"); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof(CHAR_statusSendBuffer) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_statusSendBuffer) ) { + return CHAR_statusSendBuffer; + } + } + } + return CHAR_statusSendBuffer; +} +#endif + +#ifdef _PETSKILL_BECOMEFOX + case 'a': +{ + int getPetSkillDataArray[]= { + PETSKILL_NAME, + PETSKILL_COMMENT, + }; + int i,petskillloop, pindex=index; + int num = 0;//, f_num = 0; + char tmp[16]; + + num = tolower( category[1] ) - '0'; + if( num < 0 || num >= CHAR_MAXPETHAVE ){ + print( "宠物特技资料失败 (%c)%d \n", num, num ); + break; + } + print( "宠物特技资料" ); + pindex = CHAR_getCharPet( index, num ); + if( !CHAR_CHECKINDEX(pindex)){ + return NULL; + } + snprintf( tmp, sizeof( tmp), "W%d|", num); + strcpysafe( CHAR_statusSendBuffer, sizeof( CHAR_statusSendBuffer), + tmp); + strlength += strlen( tmp); + if( strlength >= arraysizeof( CHAR_statusSendBuffer) ) { + return CHAR_statusSendBuffer; + } + + for( petskillloop = 0; petskillloop < CHAR_MAXPETSKILLHAVE; petskillloop ++ ) { + int skillid = CHAR_getPetSkill( pindex, petskillloop); + int petskillindex = PETSKILL_getPetskillArray( skillid ); + if( PETSKILL_CHECKINDEX( petskillindex) ) { + char token[256]; + int field = -1, target = -1; + //int oblivion = CHAR_getWorkInt( pindex, CHAR_WORKOBLIVION ); + int p_id = PETSKILL_getInt( petskillindex, PETSKILL_ID); + + //技能名称若为 待机 攻击 防御 技能才能选 + print("\n技能名称:%s",PETSKILL_getChar( petskillindex, PETSKILL_NAME)); + if( strcmp(PETSKILL_getChar( petskillindex, PETSKILL_NAME),"待机" ) == 0 + || strcmp(PETSKILL_getChar( petskillindex, PETSKILL_NAME),"攻击" ) == 0 + || strcmp(PETSKILL_getChar( petskillindex, PETSKILL_NAME),"防御" ) == 0){ + field = PETSKILL_getInt( petskillindex, PETSKILL_FIELD); + target = PETSKILL_getInt( petskillindex, PETSKILL_TARGET); + }else{ + field = PETSKILL_FIELD_MAP; + target = PETSKILL_TARGET_NONE; + } + + snprintf( token, sizeof( token),"%d|%d|%d|", +// PETSKILL_getInt( petskillindex, PETSKILL_ID), + p_id, + field, target + ); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof(CHAR_statusSendBuffer) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_statusSendBuffer)) { + return CHAR_statusSendBuffer; + } + + for( i = 0 ; i < arraysizeof( getPetSkillDataArray ) ; i ++ ){ + char escapebuffer[128]; + snprintf( token, + sizeof( token ), + "%s" STATUSSENDDELIMITER, + makeEscapeString( + PETSKILL_getChar(petskillindex, + getPetSkillDataArray[i]), + escapebuffer,sizeof(escapebuffer) + )); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof( CHAR_statusSendBuffer ) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= sizeof( CHAR_statusSendBuffer )) { + return CHAR_statusSendBuffer; + } + } + } + else { + char token[256]; + snprintf( token, sizeof( token),"|||||"); + strcpysafe( CHAR_statusSendBuffer + strlength, + sizeof(CHAR_statusSendBuffer) - strlength, + token ); + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_statusSendBuffer) ) { + return CHAR_statusSendBuffer; + } + } + } + return CHAR_statusSendBuffer; +} +#endif + + default: + break; + } + + CHAR_statusSendBuffer[0] = '\0'; + return CHAR_statusSendBuffer; +} + +//BOOL CHAR_sendStatusString( int charaindex, char* category ) +BOOL _CHAR_sendStatusString( int charaindex, char* category, char* file, int line ) +{ + char* string; + + //print("\nsend_S:%s:%d ", file, line); + + if( CHAR_getInt(charaindex,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ){ + return FALSE; + } + string = CHAR_makeStatusString( charaindex, category ); + + if( string != NULL ){ + int fd; + fd = getfdFromCharaIndex( charaindex ); + if( fd != -1 ){ + lssproto_S_send( fd, string ); + return TRUE; + } + } + return FALSE; +} + +void CHAR_inputOwnTitle( int index ,char* name ) +{ + if( !CHAR_CHECKINDEX( index ) ) return; + + if( CHAR_getFlg( index,CHAR_ISDIE ) )return; + + CHAR_setChar( index, CHAR_OWNTITLE ,name); + + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( index, CHAR_WORKOBJINDEX) ); + + CHAR_send_P_StatusString( index, CHAR_P_STRING_OWNTITLE ); +} + + +void CHAR_selectTitle( int index, int titleindex ) +{ + if( !CHAR_CHECKINDEX( index ) )return; + + if( CHAR_getFlg( index,CHAR_ISDIE ) )return; + + if( titleindex == -1 ){ + CHAR_setInt( index, CHAR_INDEXOFEQTITLE, titleindex); + }else if( titleindex < 0 || titleindex >= CHAR_TITLEMAXHAVE ) { + return; + } + else{ + + int title = CHAR_getCharHaveTitle( index,titleindex ); + + if( TITLE_getTitleIndex( title) != -1 ){ + CHAR_setInt( index, CHAR_INDEXOFEQTITLE, titleindex); + } + } + + CHAR_sendStatusString( index, "T" ); + CHAR_send_P_StatusString( index, CHAR_P_STRING_TITLE ); +} + + +void CHAR_deleteTitle( int index, int titleindex ) +{ + int title; + + if( !CHAR_CHECKINDEX( index ) )return; + /* 韶氏匹中月凛反分户 */ + if( CHAR_getFlg( index,CHAR_ISDIE ) )return; + + if( titleindex < 0 || titleindex >= CHAR_TITLEMAXHAVE )return; + title = CHAR_getCharHaveTitle( index,titleindex ); + /*if( TITLE_CHECKTABLEINDEX( title ) == FALSE )*/ + if( TITLE_getTitleIndex( title) == -1 ) { + return; + } + CHAR_setCharHaveTitle( index,titleindex,-1 ); + + /* 愤坌互银匀化中凶支勾卅日壬}公木手卅仄卞允月 */ + if( CHAR_getInt(index, CHAR_INDEXOFEQTITLE) == titleindex ) + CHAR_setInt(index, CHAR_INDEXOFEQTITLE, -1 ); + + /* + * 旦 □正旦树 毛霜月[ + */ + CHAR_sendStatusString( index, "T" ); + CHAR_send_P_StatusString( index, CHAR_P_STRING_TITLE ); +} + +static void CHAR_initcharWorkInt( index ) +{ + float hp; + static struct substitutionTable{ + CHAR_WORKDATAINT workindex; + CHAR_DATAINT intindex; + }subtbl[]={ + { CHAR_WORKMAXMP, CHAR_MAXMP }, + { CHAR_WORKFIXFIREAT, CHAR_FIREAT }, + { CHAR_WORKFIXWATERAT, CHAR_WATERAT}, + { CHAR_WORKFIXEARTHAT, CHAR_EARTHAT}, + { CHAR_WORKFIXWINDAT, CHAR_WINDAT }, + { CHAR_WORKFIXCHARM, CHAR_CHARM }, + { CHAR_WORKFIXLUCK, CHAR_LUCK }, + { CHAR_WORKFIXLUCK, CHAR_LUCK }, + { CHAR_WORKMODPOISON, CHAR_POISON }, + { CHAR_WORKMODPARALYSIS,CHAR_PARALYSIS }, + { CHAR_WORKMODSLEEP, CHAR_SLEEP }, + { CHAR_WORKMODSTONE, CHAR_STONE }, + { CHAR_WORKMODDRUNK, CHAR_DRUNK }, + { CHAR_WORKMODCONFUSION, CHAR_CONFUSION } + }; + int i; + for( i=0 ; i 0 ){ + CHAR_setWorkInt( index, CHAR_WORKFIXEARTHAT + (i + 2) % 4, attr * -1); + } + } + +#ifdef _MAGIC_RESIST_EQUIT // WON ADD 职业抗性装备 + { + // 火冰电抗性 + //for( i=0; i<3; i++) + // CHAR_setWorkInt( index, CHAR_WORK_F_RESIST+i, CHAR_getInt( index, PROFESSION_FIRE_R+i ) ); + } +#endif + + + CHAR_setWorkInt( index, CHAR_WORKFIXDEX, + CHAR_getInt( index, CHAR_DEX) * 0.01 ); + CHAR_setWorkInt( index, CHAR_WORKFIXVITAL, + CHAR_getInt( index, CHAR_VITAL) * 0.01 ); + + CHAR_setWorkInt( index, CHAR_WORKFIXSTR, + CHAR_getInt( index, CHAR_STR) * 0.01 * 1.0 +//#ifdef _BATTLE_NEWPOWER +// + CHAR_getInt( index, CHAR_DEX) * 0.01 * 0.05 +// + CHAR_getInt( index, CHAR_VITAL) * 0.01 * 0.05 ); // 耐力 +//#else + + CHAR_getInt( index, CHAR_TOUGH) * 0.01 * 0.1 + + CHAR_getInt( index, CHAR_VITAL) * 0.01 * 0.1 + + CHAR_getInt( index, CHAR_DEX) * 0.01 * 0.05 ); +//#endif + CHAR_setWorkInt( index, CHAR_WORKFIXTOUGH, + CHAR_getInt( index, CHAR_TOUGH) * 0.01 * 1.0 +//#ifdef _BATTLE_NEWPOWER +// + CHAR_getInt( index, CHAR_DEX) * 0.01 * 0.05 +// + CHAR_getInt( index, CHAR_VITAL) * 0.01 * 0.05 ); // 力量 +//#else + + CHAR_getInt(index,CHAR_STR) * 0.01 * 0.1 + + CHAR_getInt(index,CHAR_VITAL) * 0.01 * 0.1 + + CHAR_getInt(index,CHAR_DEX) * 0.01 * 0.05 ); +//#endif + +#ifdef _ITEMSET5_TXT + { + CHAR_setWorkInt( index, CHAR_WORKFIXARRANGE, 0); + CHAR_setWorkInt( index, CHAR_WORKFIXSEQUENCE, 0); + CHAR_setWorkInt( index, CHAR_WORKATTACHPILE, 0); + CHAR_setWorkInt( index, CHAR_WORKHITRIGHT, 0); + } +#endif + + + +#ifdef _ITEMSET6_TXT + { + CHAR_setWorkInt( index, CHAR_WORKNEGLECTGUARD, 0); + } +#endif + + CHAR_setWorkInt( index, CHAR_WORKATTACKPOWER, + CHAR_getWorkInt(index,CHAR_WORKFIXSTR) ); + CHAR_setWorkInt( index, CHAR_WORKDEFENCEPOWER, + CHAR_getWorkInt(index,CHAR_WORKFIXTOUGH) ); + CHAR_setWorkInt( index, CHAR_WORKQUICK, + CHAR_getWorkInt( index, CHAR_WORKFIXDEX)); + + hp = ( CHAR_getInt(index,CHAR_VITAL) * 4 + + CHAR_getInt(index,CHAR_STR) * 1 + + CHAR_getInt(index,CHAR_TOUGH) * 1 + + CHAR_getInt(index,CHAR_DEX) * 1 ) * 0.01; + + CHAR_setWorkInt( index, CHAR_WORKMAXHP, (int)hp ); + CHAR_setWorkInt( index, CHAR_WORKMAXMP, CHAR_getInt( index, CHAR_MAXMP)); + +#ifdef _ADD_DEAMGEDEFC + CHAR_setWorkInt( index, CHAR_WORKOTHERDMAGE, 0); + CHAR_setWorkInt( index, CHAR_WORKOTHERDEFC, 0); +#endif + + if( CHAR_getInt( index, CHAR_WHICHTYPE) == CHAR_TYPEPET) { + int hostindex; + CHAR_setWorkInt( index, CHAR_WORKFIXAI, 0); + hostindex = CHAR_getWorkInt( index, CHAR_WORKPLAYERINDEX); + if( CHAR_CHECKINDEX( hostindex)) { + int ai; + int modai = CHAR_getInt( index, CHAR_MODAI); + double R; + if( modai <= 0 ) modai = 100; + R = 1.10; + ai = ( (CHAR_getInt( hostindex, CHAR_LV) + * CHAR_getWorkInt( hostindex, CHAR_WORKFIXCHARM ) + * R) + / + (CHAR_getInt( index, CHAR_LV)* modai) * 100 ) ; + if( ai > 100 ) ai = 100; + + ai += CHAR_getInt( index, CHAR_VARIABLEAI) * 0.01; + if( CHAR_getInt( hostindex, CHAR_TRANSMIGRATION ) > 0 ){ + // shan 120 -> 140 + ai += ( CHAR_GetLevel() - CHAR_getInt( hostindex, CHAR_LV ) ) / 2; + } + if( ai < 0 ) ai = 0; + if( ai > 100 ) ai = 100; + CHAR_setWorkInt( index, CHAR_WORKFIXAI, ai); + } + } +} + +int _CHAR_complianceParameter( int index, char *FILE, int LINE) +{ + //print("\ncompPara:%s:%d", FILE, LINE); + + if( !CHAR_CHECKINDEX( index)) return 0; + + CHAR_initcharWorkInt( index ); + ITEM_equipEffect( index ); + + CHAR_setWorkInt(index, CHAR_WORKATTACKPOWER, + CHAR_getWorkInt( index, CHAR_WORKFIXSTR ) ); + CHAR_setWorkInt(index, CHAR_WORKDEFENCEPOWER, + CHAR_getWorkInt( index, CHAR_WORKFIXTOUGH ) ); + CHAR_setWorkInt(index, CHAR_WORKQUICK, + CHAR_getWorkInt( index, CHAR_WORKFIXDEX ) ); + +#ifdef _ITEMSET5_TXT + CHAR_setWorkInt(index, CHAR_WORKARRANGEPOWER, + CHAR_getWorkInt( index, CHAR_WORKFIXARRANGE ) ); + CHAR_setWorkInt(index, CHAR_WORKSEQUENCEPOWER, + CHAR_getWorkInt( index, CHAR_WORKFIXSEQUENCE ) ); +#endif + + Other_DefcharWorkInt( index); + CHAR_setInt( index, CHAR_HP, min( CHAR_getInt(index,CHAR_HP), CHAR_getWorkInt( index, CHAR_WORKMAXHP))); + CHAR_setInt( index, CHAR_MP, min( CHAR_getInt(index,CHAR_MP), CHAR_getWorkInt( index, CHAR_WORKMAXMP))); + + if( CHAR_getInt( index, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ){ + if( CHAR_getWorkInt( index, CHAR_WORKPETFOLLOW ) != -1 ){ + int petindex = CHAR_getWorkInt( index, CHAR_WORKPETFOLLOW ); + if( !CHAR_CHECKINDEX( petindex) ){ + CHAR_setWorkInt( index, CHAR_WORKPETFOLLOW, -1); + }else{ + if( CHAR_getInt( petindex, CHAR_WHICHTYPE) == CHAR_TYPEPET && + !CHAR_CHECKINDEX( CHAR_getWorkInt( petindex, CHAR_WORKPLAYERINDEX)) ){ + CHAR_setWorkInt( index, CHAR_WORKPETFOLLOW, petindex); + CHAR_setWorkInt( petindex, CHAR_WORKPLAYERINDEX, index); + } + } + } + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + { + int i, add_pile = 0; + int old_pile = CHAR_getWorkInt( index, CHAR_WORKATTACHPILE); + + for( i=0; i NowTime.tv_sec +#ifdef _NPCCHANGE_PLAYERIMG + || CHAR_getWorkInt( index, CHAR_WORKNPCMETAMO) > 0 +#endif +#ifdef _PETSKILL_BECOMEPIG + || CHAR_getInt( index, CHAR_BECOMEPIG) > -1 +#endif + ){ + newimagenumber = oldimagenumber; //不恢复成原本的图 + } +#endif + // Arminius 8.9 airplane + if (oldimagenumber==100259) newimagenumber=100259; +#ifdef _VARY_WOLF + if( (CHAR_getInt( index, CHAR_WHICHTYPE) == CHAR_TYPEPET) && + (CHAR_getWorkInt( index, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) && + oldimagenumber == 101428 ){ + newimagenumber = 101428; + } +#endif + +#ifdef _ENEMY_FALLGROUND + if( CHAR_getInt( index, CHAR_WHICHTYPE) == CHAR_TYPEENEMY ) { + return 0; + }else { +#endif + if( newimagenumber == -1 ) { + CHAR_setInt(index,CHAR_BASEIMAGENUMBER, basebaseimagenumber); + }else { + CHAR_setInt(index,CHAR_BASEIMAGENUMBER,newimagenumber); + } + +#ifdef _ENEMY_FALLGROUND + } +#endif +#ifdef _NEW_RIDEPETS + if( (CHAR_getWorkInt(index, CHAR_WORKITEMMETAMO)>NowTime.tv_sec) + || (CHAR_getWorkInt(index,CHAR_WORKNPCMETAMO)>0)){ + return 0; + } +#endif + // Robin 0725 + if( CHAR_getInt(index, CHAR_RIDEPET) != -1 ){ + int i; +#ifndef _NEW_RIDEPETS + int big4fm =0; +#endif +#ifdef _NEW_RIDEPETS + BOOL FindGraNo = FALSE; +#endif + int petindex = CHAR_getCharPet( index, CHAR_getInt(index, CHAR_RIDEPET) ); +#ifndef _NEW_RIDEPETS + int leaderGraNo = 100700 + + ((CHAR_getInt( index, CHAR_BASEBASEIMAGENUMBER)-100000)/20)*10 + + CHAR_getInt( index, CHAR_FMSPRITE)*5; + switch( CHAR_getWorkInt( index, CHAR_WORKFMFLOOR) ){ + + case 1041: + big4fm = 1; + break; + case 2031: + big4fm = 2; + break; + case 3031: + big4fm = 3; + break; + case 4031: + big4fm = 4; + break; + default: + big4fm = 0; + } +#endif + for( i=0; i< arraysizeof(ridePetTable) ; i++ ) { +#ifdef _NEW_RIDEPETS + if( (( CHAR_getInt( index, CHAR_BASEIMAGENUMBER) == ridePetTable[i].charNo ) || + ( CHAR_getInt( index, CHAR_BASEBASEIMAGENUMBER) == ridePetTable[i].charNo )) +#else + if( ( CHAR_getInt( index, CHAR_BASEBASEIMAGENUMBER) == ridePetTable[i].charNo ) +#endif + && ( CHAR_getInt( petindex, CHAR_BASEBASEIMAGENUMBER) == ridePetTable[i].petNo ) ) { + CHAR_setInt( index, CHAR_BASEIMAGENUMBER, ridePetTable[i].rideNo ); +#ifdef _NEW_RIDEPETS + FindGraNo = TRUE; +#endif + break; + } +#ifndef _NEW_RIDEPETS + else if( ( leaderGraNo == ridePetTable[i].charNo ) + && ( CHAR_getInt( petindex, CHAR_BASEBASEIMAGENUMBER) == ridePetTable[i].petNo ) +#ifdef _EVERYONE_RIDE + && big4fm != 0 ){ +#else + && CHAR_getInt( index, CHAR_FMLEADERFLAG ) == FMMEMBER_LEADER ){ +#endif + CHAR_setInt( index, CHAR_BASEIMAGENUMBER, ridePetTable[i].rideNo ); + break; + } +#endif + } + +#ifdef _NEW_RIDEPETS + { + int ti=-1, Noindex, image=-1; + int petNo = CHAR_getInt( petindex, CHAR_BASEBASEIMAGENUMBER); + int playerNo = CHAR_getInt( index, CHAR_BASEBASEIMAGENUMBER); + + int playerlowsride = CHAR_getInt( index, CHAR_LOWRIDEPETS); + if( (ti = RIDEPET_getPETindex( petNo, playerlowsride )) >= 0 ) { + if( (Noindex = RIDEPET_getNOindex( playerNo)) >= 0 ){ + if( (image = RIDEPET_getRIDEno( Noindex,ti)) >= 0 ) { + FindGraNo = TRUE; + CHAR_setInt( index, CHAR_BASEIMAGENUMBER, image ); + } + } + } + } + if( FindGraNo == FALSE ){ + CHAR_setInt( index , CHAR_RIDEPET, -1 ); + CHAR_setInt( index , CHAR_BASEIMAGENUMBER , CHAR_getInt( index, CHAR_BASEBASEIMAGENUMBER) ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( index, CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( index, CHAR_P_STRING_RIDEPET ); + } +#endif + } + } + return 1; +} + +/*====================================================================== + 平乓仿及失奶 丞毛健丹楮醒 + ======================================================================*/ + +/*====================苇月====================*/ +/*------------------------------------------------------------ + * 轾隙烂匹}公及 轾及平乓仿弁正卞苇月奶矛件玄毛 戏今六月 + * 娄醒 + * charaindex int 平乓仿奶件犯永弁旦 + * dir int 轾 + * 忒曰袄 + * 卅仄 + ------------------------------------------------------------*/ +void CHAR_Look( int charaindex, int dir ) +{ + int fl ,x,y; + OBJECT object; + + /* 奶件犯永弁旦及民尼永弁 */ + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return; + + if( dir < 0 ) { + dir = CHAR_getInt(charaindex,CHAR_DIR); + } + VALIDATEDIR(dir); + if( CHAR_getInt( charaindex, CHAR_DIR) != dir ) { + CHAR_setInt(charaindex,CHAR_DIR,dir); + /* 轾 晶仄凶失弁扑亦件毛霜耨允月 */ + CHAR_sendWatchEvent(CHAR_getWorkInt(charaindex,CHAR_WORKOBJINDEX), + CHAR_ACTTURN,NULL,0,TRUE); + } + + fl = CHAR_getInt(charaindex,CHAR_FLOOR); + CHAR_getCoordinationDir( CHAR_getInt(charaindex,CHAR_DIR), + CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y), + 1, &x, &y ); + + //CHAR_talkToCli( charaindex, -1, "调查四周环境。", CHAR_COLORWHITE ); + + for( object=MAP_getTopObj(fl,x,y) ; object ; + object = NEXT_OBJECT(object) ){ + int objindex = GET_OBJINDEX(object); + if( OBJECT_getType(objindex) == OBJTYPE_CHARA ){ + typedef void (*LOOKF)(int,int); + LOOKF lf; + lf = (LOOKF)CHAR_getFunctionPointer( + OBJECT_getIndex(objindex),CHAR_LOOKEDFUNC); + if( lf ) lf(OBJECT_getIndex(objindex),charaindex); + } + } +} + +BOOL _CHAR_makeObjectCString( char *file, int line, int objindex,char* buf, int buflen ) +{ + char objindexbuf[64]; + if( CHECKOBJECT(objindex) == FALSE ) return FALSE; + + switch( OBJECT_getType(objindex) ){ + case OBJTYPE_NOUSE: + return FALSE; + break; + case OBJTYPE_CHARA: + { + int charaindex = OBJECT_getIndex(objindex); + char escapename[256]; + char escapetitle[256]; + // shan add +1 + char tmp[128]; + int namecolor; +#ifdef _TRANS_6 +#ifdef _TRANS_7 + int namecolortbl[] = { CHAR_COLORWHITE, CHAR_COLORYELLOW, CHAR_COLORGREEN, + CHAR_COLORCYAN, CHAR_COLORRED, CHAR_COLORPURPLE, CHAR_COLORBLUE2,CHAR_COLORGRAY};//转生後的颜色 +#else + int namecolortbl[] = { CHAR_COLORWHITE, CHAR_COLORYELLOW, CHAR_COLORGREEN, + CHAR_COLORCYAN, CHAR_COLORRED, CHAR_COLORPURPLE, CHAR_COLORBLUE2};//转生後的颜色 +#endif +#else + int namecolortbl[] = { CHAR_COLORWHITE, CHAR_COLORYELLOW, CHAR_COLORGREEN, + CHAR_COLORCYAN, CHAR_COLORRED, CHAR_COLORPURPLE}; +#endif + int ridepet = BATTLE_getRidePet( charaindex ); + char petname[64] = ""; + char escapepetname[256]; + int petlevel = 0; + + if( !CHAR_getFlg(charaindex,CHAR_ISVISIBLE) )return FALSE; + namecolor = CHAR_getInt( charaindex, CHAR_TRANSMIGRATION); +#ifdef _TRANS_6 +#ifdef _TRANS_7 + if( namecolor > 7 ) namecolor = 7; +#else + if( namecolor > 6 ) namecolor = 6; +#endif +#else + if( namecolor > 5 ) namecolor = 5; +#endif + if( namecolor < 0 ) namecolor = 0; + + // shan add begin + if( CHAR_getWorkInt(charaindex, CHAR_WORKFMINDEXI) >= 0 + && CHAR_getWorkInt(charaindex, CHAR_WORKFMINDEXI) < FAMILY_MAXNUM + && CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER + && CHAR_getWorkInt(charaindex, CHAR_WORKFMSETUPFLAG)!=1) +#ifdef _ITEM_SETLOVER + if(strlen( CHAR_getChar( charaindex, CHAR_LOVE)) > 0 && + strlen(CHAR_getChar(charaindex,CHAR_LOVERID))>0 && + strlen(CHAR_getChar(charaindex,CHAR_LOVERNAME))>0) + sprintf(tmp, "%s§♂%s♀",CHAR_getChar( charaindex, CHAR_FMNAME),CHAR_getChar( charaindex, CHAR_LOVERNAME)); + else + sprintf(tmp, "%s",CHAR_getChar( charaindex, CHAR_FMNAME)); +#else + sprintf(tmp, "%s",CHAR_getChar( charaindex, CHAR_FMNAME)); +#endif + else +#ifdef _ITEM_SETLOVER + if(strlen( CHAR_getChar( charaindex, CHAR_LOVE)) > 0 && + strlen(CHAR_getChar(charaindex,CHAR_LOVERID))>0 && + strlen(CHAR_getChar(charaindex,CHAR_LOVERNAME))>0) + sprintf(tmp, "♂%s♀",CHAR_getChar( charaindex, CHAR_LOVERNAME)); + else + strcpy(tmp, ""); +#else + strcpy(tmp, ""); +#endif + + // Robin 0730 + if( ridepet >= 0 ){ + if( ! strcmp( CHAR_getChar( ridepet, CHAR_USERPETNAME), "") ) + strcpy( petname, CHAR_getChar( ridepet, CHAR_NAME )); + else + strcpy( petname, CHAR_getChar( ridepet, CHAR_USERPETNAME )); + petlevel = CHAR_getInt( ridepet, CHAR_LV); + } +#ifdef _OBJSEND_C + #ifdef _CHAR_PROFESSION // WON ADD 人物职业 + #ifdef _ALLDOMAN // (不可开) Syu ADD 排行榜NPC + snprintf( buf, buflen, "%d|%d|%s|%d|%d|%d|%d|%d|%d|%s|%s|%d|%d|%d|%s|%s|%d|%d|%d|%d|%d", + #else + snprintf( buf, buflen, "%d|%d|%s|%d|%d|%d|%d|%d|%d|%s|%s|%d|%d|%d|%s|%s|%d|%d|%d|%d", + #endif + #else + snprintf( buf, buflen, "%d|%d|%s|%d|%d|%d|%d|%d|%d|%s|%s|%d|%d|%d|%s|%s|%d", + #endif + OBJTYPE_CHARA, +#else + #ifdef _GM_IDENTIFY + snprintf( buf, buflen, "%d|%s|%d|%d|%d|%d|%d|%d|%s|%s|%d|%d|%d|%s|%s|%d|%s", //多出了gm名称这个栏位 + #else + snprintf( buf, buflen, "%d|%s|%d|%d|%d|%d|%d|%d|%s|%s|%d|%d|%d|%s|%s|%d", + #endif +#endif + CHAR_getInt( charaindex, CHAR_WHICHTYPE), + cnv10to62( objindex,objindexbuf, sizeof(objindexbuf)), + OBJECT_getX(objindex), + OBJECT_getY(objindex), + CHAR_getInt( charaindex, CHAR_DIR), + CHAR_getInt( charaindex,CHAR_BASEIMAGENUMBER ), + CHAR_getInt( charaindex,CHAR_LV ), + namecolortbl[namecolor], + makeEscapeString( CHAR_getChar( charaindex,CHAR_NAME ), escapename, sizeof(escapename)), + makeEscapeString(CHAR_getChar(charaindex,CHAR_OWNTITLE), escapetitle,sizeof(escapetitle)), + CHAR_getFlg( charaindex,CHAR_ISOVERED ), + CHAR_getFlg( charaindex,CHAR_HAVEHEIGHT ), + CHAR_getInt( charaindex, CHAR_POPUPNAMECOLOR), + tmp, + makeEscapeString( petname, escapepetname, sizeof(escapepetname)), + petlevel +#ifdef _CHAR_PROFESSION // WON ADD 人物职业 + ,CHAR_getInt( charaindex, PROFESSION_CLASS) // 职业别 + ,CHAR_getInt( charaindex, PROFESSION_LEVEL) // 职业等级 +// ,CHAR_getInt( charaindex, PROFESSION_EXP) // 职业经验值 + ,CHAR_getInt( charaindex, PROFESSION_SKILL_POINT) // 技能点数 +#endif +#ifdef _ALLDOMAN // (不可开) Syu ADD 排行榜NPC + ,CHAR_getInt( charaindex, CHAR_HEROFLOOR ) // 英雄战场楼层 +#endif +#ifdef _GM_IDENTIFY + ,CHAR_getChar(charaindex, CHAR_GMIDENTIFY) //gm的名称 +#endif +#ifdef _PETSKILL_BECOMEPIG + // ,CHAR_getInt(charaindex, CHAR_BECOMEPIG) +#endif + ); + break; + } + case OBJTYPE_ITEM: + { + int itemindex = OBJECT_getIndex(objindex); + int nameint; + int leaklevel; + int color; + char bufbuf[256]; + char *temp; + leaklevel = ITEM_getInt( itemindex,ITEM_LEAKLEVEL ); + + nameint = ITEM_SECRETNAME; +// if( leaklevel >=1 ) { +// nameint = ITEM_SECRETNAME; +// }else { +// nameint = ITEM_NAME; +// } + color = CHAR_COLORWHITE; + if (ITEM_getChar( itemindex, ITEM_CDKEY) == NULL){ + return FALSE; + break; + } + temp=ITEM_getChar( itemindex, ITEM_CDKEY); + if( temp && strlen( temp ) ) { + color = CHAR_COLORGREEN; + }else { + if( ITEM_getInt( itemindex, ITEM_MERGEFLG) ) { + color = CHAR_COLORYELLOW; + } + } +#ifdef _OBJSEND_C + snprintf( buf, buflen, "%d|%s|%d|%d|%d|%d|%s", + OBJTYPE_ITEM, +#else + snprintf( buf, buflen, "%s|%d|%d|%d|%d|%s", +#endif + cnv10to62( objindex,objindexbuf, sizeof(objindexbuf)), + OBJECT_getX(objindex), OBJECT_getY(objindex), + ITEM_getInt( itemindex,ITEM_BASEIMAGENUMBER ), + color, + makeEscapeString( ITEM_getChar( itemindex,nameint), bufbuf, sizeof(bufbuf)) + ); + break; + } + case OBJTYPE_GOLD: +#ifdef _OBJSEND_C + snprintf( buf, buflen, "%d|%s|%d|%d|%d", + OBJTYPE_GOLD, +#else + snprintf( buf, buflen, "%s|%d|%d|%d", +#endif + cnv10to62( objindex,objindexbuf, sizeof(objindexbuf)), + OBJECT_getX(objindex),OBJECT_getY(objindex), + OBJECT_getIndex(objindex) ); + break; +#ifdef _OBJSEND_C +#ifdef _NPCSERVER_NEW + case OBJTYPE_NPCSCHARA: + { + char bufbuf[256]; + snprintf( buf, buflen, "%d|%s|%s|%d|%d|%d|%d", + OBJTYPE_NPCSCHARA, + cnv10to62( objindex,objindexbuf, sizeof(objindexbuf)), + makeEscapeString( OBJECT_getName( objindex), bufbuf, sizeof(bufbuf)), + OBJECT_getNpcdir( objindex), + OBJECT_getNpcImage( objindex), + OBJECT_getX(objindex), + OBJECT_getY(objindex)); + } + break; +#endif +#endif + default: + return FALSE; + break; + } + return TRUE; +} + +void CHAR_sendCSpecifiedObjindex( int fd, int index) +{ + char introduction[512]; + if( CHECKOBJECTUSE( index ) + && CHAR_makeObjectCString( index, introduction, + sizeof(introduction) ) ){ + lssproto_C_send( fd,introduction ); + }else{ + char mesg[32]; + cnv10to62( index, mesg, sizeof( mesg)); + lssproto_C_send( fd, mesg ); + } +} + +void CHAR_sendSpecifiedobjindexCToCharaindex(int charaindex,int objindex) +{ + int fd; + fd = getfdFromCharaIndex(charaindex); + if( fd == -1)return; + CHAR_sendCSpecifiedObjindex(fd,objindex); +} + +void CHAR_sendCToArroundCharacter( int objindex ) +{ + char introduction[512]; + int x,y,fl; + int i,j; + + if( CHAR_makeObjectCString( objindex,introduction, sizeof(introduction) ) == FALSE ) return; + + x = OBJECT_getX(objindex); + y = OBJECT_getY(objindex); + fl =OBJECT_getFloor(objindex); + + for( i = x - CHAR_DEFAULTSEESIZ/2 ; + i <= x +CHAR_DEFAULTSEESIZ/2 ; i ++ ){ + for( j = y - CHAR_DEFAULTSEESIZ/2; + j <= y + CHAR_DEFAULTSEESIZ/2; j ++ ){ + OBJECT object; + for( object = MAP_getTopObj( fl, i,j); + object; + object = NEXT_OBJECT(object) ){ + int objindexwk = GET_OBJINDEX( object); + if( OBJECT_getType(objindexwk) == OBJTYPE_CHARA ){ + int index = OBJECT_getIndex(objindexwk); + if( CHAR_getInt( index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + int fd; + if( CHAR_getWorkInt( index, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) continue; + fd = getfdFromCharaIndex( index); + if( fd == -1 )continue; + lssproto_C_send( fd,introduction ); + } + } + } + } + } +} + +void CHAR_sendCDArroundChar_Main( int fl, int x, int y, int objindex, BOOL mode ) +{ +#define CHAR_CDSEESIZ CHAR_DEFAULTSEESIZ+10 + + int i,j; + char cdmsg[64*2]; + cnv10to62( objindex,cdmsg, sizeof(cdmsg)); + for( i = x - CHAR_CDSEESIZ/2 ; i <= x +CHAR_CDSEESIZ/2 ; i ++ ){ + for( j = y - CHAR_CDSEESIZ/2; j <= y + CHAR_CDSEESIZ/2; j ++ ){ + OBJECT object; + for( object = MAP_getTopObj( fl, i,j); object; + object = NEXT_OBJECT(object) ){ + + int objindexwk = GET_OBJINDEX( object); + if( OBJECT_getType(objindexwk) == OBJTYPE_CHARA ){ + int index = OBJECT_getIndex( objindexwk); + if( CHAR_getInt( index,CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER) { + if( objindexwk != objindex ) { + int fd; + fd = getfdFromCharaIndex(index); + if( fd == -1 )continue; + if( CHAR_getWorkInt( index, CHAR_WORKBATTLEMODE) + == BATTLE_CHARMODE_NONE ) + { + CONNECT_appendCDbuf( fd, cdmsg, strlen( cdmsg)); + CDflush( index); + } + } + } + } + } + } + } +} + +void CHAR_sendCDArroundChar( int fl, int x, int y, int objindex ) +{ + CHAR_sendCDArroundChar_Main( fl,x,y,objindex,FALSE); +} + +void CHAR_sendArroundCharaData( int charaindex ) +{ + int fd; + int i,j,x, y,fl; + char introduction[512*2]; + char c_msg[1024*96]; + int strpos = 0; + char cabuf[128*2]; + fd = getfdFromCharaIndex( charaindex ); + if( fd == -1 )return; + c_msg[0] = '\0'; + fl = CHAR_getInt( charaindex, CHAR_FLOOR); + x = CHAR_getInt( charaindex, CHAR_X); + y = CHAR_getInt( charaindex, CHAR_Y); + + for( i = x-CHAR_DEFAULTSEESIZ/2 ; i <= x+CHAR_DEFAULTSEESIZ/2 ; i++ ){ + for( j = y-CHAR_DEFAULTSEESIZ/2 ; j <= y+CHAR_DEFAULTSEESIZ/2 ; j ++ ) { + OBJECT object; + for( object = MAP_getTopObj(fl,i,j) ; object ; object = NEXT_OBJECT(object ) ){ + int introlen; + int objindex = GET_OBJINDEX(object); + int c_index = OBJECT_getIndex( objindex); + + if( OBJECT_getType(objindex) == OBJTYPE_NOUSE ) continue; + if( OBJECT_getType(objindex) == OBJTYPE_CHARA && + !CHAR_getFlg(OBJECT_getIndex(objindex), CHAR_ISVISIBLE) ){ + continue; + } + if( OBJECT_getType( objindex) == OBJTYPE_CHARA) { + if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + /* 苇尹凶平乓仿互醮棉汹五及褪卅日壬伉□母□ 憎CA毛霜月 */ + if( CHAR_getWorkInt( c_index, CHAR_WORKPARTYMODE )== CHAR_PARTY_LEADER ){ + if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), CHAR_ACTLEADER,1 )) { + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + } + } + // Robin 0611 trade + /* 角色交易中 */ + if( CHAR_getWorkInt( c_index, CHAR_WORKTRADEMODE ) != CHAR_TRADE_FREE ) { + if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), CHAR_ACTTRADE,1 )){ + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + } + } + +#ifdef _ANGEL_SUMMON + if( CHAR_getWorkInt( c_index, CHAR_WORKANGELMODE ) == TRUE ) { + if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), CHAR_ACTANGEL,1 )){ + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + } + } +#endif + +#ifdef _MIND_ICON + //print("\nshan--->(batlmode)->%d", CHAR_getWorkInt( c_index, CHAR_WORKBATTLEMODE )); + if(CHAR_getWorkInt( c_index, CHAR_MIND_NUM) && + CHAR_getWorkInt( c_index, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE){ + if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), + CHAR_MIND, CHAR_getWorkInt( c_index, CHAR_MIND_NUM))){ + CONNECT_appendCAbuf( fd, cabuf, strlen(cabuf)); + //print("\nshan---->(1)cabuf-->%s", cabuf); + } + } +#endif + +#ifdef _STREET_VENDOR + if(CHAR_getWorkInt(c_index,CHAR_WORKSTREETVENDOR) == 1 && + CHAR_getWorkInt(c_index,CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE){ + if(CHAR_makeCAOPTString(objindex,cabuf,sizeof(cabuf), + CHAR_STREETVENDOR_OPEN,CHAR_getWorkChar(c_index,CHAR_STREETVENDOR_NAME))){ + CONNECT_appendCAbuf(fd,cabuf,strlen(cabuf)); + } + } +#endif + +#ifdef _ITEM_CRACKER + if(CHAR_getWorkInt( c_index, CHAR_WORKITEM_CRACKER)&& + CHAR_getWorkInt( c_index, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE) + { + if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), + CHAR_ITEM_CRACKER, CHAR_getWorkInt( c_index, CHAR_WORKITEM_CRACKER))) + { + CONNECT_appendCAbuf( fd, cabuf, strlen(cabuf)); + } + } +#endif + if( CHAR_getWorkInt( c_index, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ){ + if( CHAR_getWorkInt( c_index, CHAR_WORKBATTLEWATCH) == TRUE ) { + if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), CHAR_ACTBATTLEWATCH, 1)) { + CONNECT_appendCAbuf( fd, cabuf, strlen( cabuf)); + } + }else { + int battleno = CHAR_getWorkInt( c_index, CHAR_WORKBATTLEINDEX); + int sideno = CHAR_getWorkInt( c_index, CHAR_WORKBATTLESIDE); + int helpno = FALSE; + if( BATTLE_CHECKINDEX( battleno ) == FALSE ){ + }else { + helpno = (BattleArray[ battleno].Side[ + CHAR_getWorkInt( c_index, CHAR_WORKBATTLESIDE)].flg & BSIDE_FLG_HELP_OK)?TRUE:FALSE; + } + if( CHAR_makeCAOPT3String( objindex, cabuf, sizeof( cabuf), CHAR_ACTBATTLE, + battleno,sideno,helpno)){ + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + + } + } + } + if( CHAR_getWorkInt( c_index, CHAR_WORKACTION ) != -1 ) { + if( CHAR_makeCADefaultString( objindex, cabuf, sizeof( cabuf), + CHAR_getWorkInt( c_index, CHAR_WORKACTION))){ + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + + } + } + }else if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPET ) { + if( CHAR_getWorkInt( c_index, CHAR_WORKACTION ) != -1 ){ + if( CHAR_makeCADefaultString( objindex, cabuf, sizeof( cabuf), + CHAR_getWorkInt( c_index, CHAR_WORKACTION))){ + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + } + } + } +#ifdef _ADD_ACTION + else { //npc + + if( CHAR_CHECKINDEX( c_index) ) { + if( CHAR_getWorkInt( c_index, CHAR_WORKACTION ) > 0 ) { + if( CHAR_makeCADefaultString( objindex, cabuf, sizeof( cabuf), + CHAR_getWorkInt( c_index, CHAR_WORKACTION))) { + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + + } + } + } + } +#endif + } + if( c_index == charaindex) continue; + if( CHAR_makeObjectCString( objindex, introduction, sizeof( introduction))){ + introlen = strlen( introduction); + introduction[introlen] = ','; + introduction[introlen+1] = '\0'; + + strcpysafe( &c_msg[strpos], sizeof( c_msg) - strpos, + introduction); + strpos += strlen( introduction); + } + } + } + } + dchop( c_msg, "," ); + if( strlen( c_msg) == 0 ) return; + lssproto_C_send( fd, c_msg); +} + +BOOL _CHAR_warpToSpecificPoint( char *file, int line, int charaindex, int floor, int x, int y) +{ + int objindex; + int per; + objindex = CHAR_getWorkInt(charaindex,CHAR_WORKOBJINDEX); + if( !MAP_IsValidCoordinate( floor, x, y )) { + print( "error: invalid Coordinate fl[%d] x[%d] y[%d] %s:%d from %s:%d\n", + floor, x, y, __FILE__, __LINE__, file, line); + return FALSE; + } + CHAR_sendCDArroundChar_Main( OBJECT_getFloor(objindex), + OBJECT_getX(objindex), + OBJECT_getY(objindex), + objindex, TRUE ); + + CHAR_setInt( charaindex,CHAR_FLOOR,floor); + CHAR_setInt( charaindex,CHAR_X,x); + CHAR_setInt( charaindex,CHAR_Y,y); + { + int of,ox,oy; + of = OBJECT_setFloor(objindex,floor); + ox = OBJECT_setX(objindex,x); + oy = OBJECT_setY(objindex,y); + if( !MAP_objmove( objindex,of,ox,oy,floor,x,y ) ){ + fprint( "ERROR MAP_OBJMOVE objindex=%d\n",objindex ); + } + } + per = ENCOUNT_getEncountPercentMin( charaindex, floor,x,y); + if( per != -1 ) { + CHAR_setWorkInt( charaindex, CHAR_WORKENCOUNTPROBABILITY_MIN, per); + } + per = ENCOUNT_getEncountPercentMax( charaindex, floor,x,y); + if( per != -1 ) { + CHAR_setWorkInt( charaindex, CHAR_WORKENCOUNTPROBABILITY_MAX, per); + } + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + CHAR_setWorkInt( charaindex, CHAR_ENCOUNT_FIX, 0); +#endif + + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) { + CAflush( charaindex ); + { + int i; + char* statuscat[]={"C","E",}; + for( i=0 ; i -1) && (CHAR_CHECKINDEX( petindex )) ) + + CHAR_warpToSpecificPoint( petindex, floor, x, y ); + } +#ifdef _STATUS_WATERWORD //水世界状态 + if( MAP_getMapFloorType( floor) == 1 ){ + CHAR_setWorkInt( charaindex, CHAR_WORKMAPFLOORTYPE, 1); + }else { + CHAR_setWorkInt( charaindex, CHAR_WORKMAPFLOORTYPE, 0); + } +#endif +#ifdef _MAP_TIME + // 如果进入的地图是这些编号的话,设定倒数 + if(floor >= 30017 && floor <= 30021){ + if(CHAR_getWorkInt(charaindex,CHAR_WORK_MAP_TIME) <= 0) CHAR_setWorkInt(charaindex,CHAR_WORK_MAP_TIME,60); + } + // 如果进入正常的地图 + else CHAR_setWorkInt(charaindex,CHAR_WORK_MAP_TIME,0); +#endif + +#ifdef _ANGEL_SUMMON + if( CHAR_getWorkInt( charaindex, CHAR_WORKANGELMODE ) == TRUE ) { + CHAR_sendAngelMark( objindex, 1); + } +#endif + + }else if( OBJECT_getType( objindex) == OBJTYPE_CHARA ){ + MAP_sendArroundChar( charaindex ); + } + + return TRUE; +} + +static void CHAR_walk_check( int charaindex ) +{ + if( strlen( CHAR_getWorkChar( charaindex ,CHAR_WORKWALKARRAY ) ) != 0 ){ + struct timeval old; + old.tv_sec = CHAR_getWorkInt(charaindex,CHAR_WORKWALKSTARTSEC); + old.tv_usec = CHAR_getWorkInt(charaindex,CHAR_WORKWALKSTARTMSEC); + if( time_diff_us(NowTime,old) >= CHAR_getInt(charaindex,CHAR_WALKINTERVAL)*1000.0 ) { + CHAR_walkcall( charaindex ); + }else { + } + } +} + +static BOOL CHAR_callLoop( int charaindex ) +{ + unsigned int timediff_us; + struct timeval old; + int loopinterval, iRet = FALSE; + loopinterval = CHAR_getInt(charaindex,CHAR_LOOPINTERVAL); + if( loopinterval <= 0 )return FALSE; + + //print("\n CHAR_callLoop:%d", charaindex); + + old.tv_sec = CHAR_getWorkInt(charaindex,CHAR_WORKLOOPSTARTSEC); + old.tv_usec = CHAR_getWorkInt(charaindex,CHAR_WORKLOOPSTARTMSEC); + timediff_us = time_diff_us( NowTime , old ); + + if( timediff_us >= loopinterval*1000.0 ){ + int (*loopfunc)(int)=NULL; + loopfunc =(int(*)(int))CHAR_getFunctionPointer( charaindex, CHAR_LOOPFUNC); + if( loopfunc ){ + loopfunc(charaindex); + iRet = TRUE; + } +#ifdef _USER_CHARLOOPS + loopfunc =(int(*)(int))CHAR_getFunctionPointer( charaindex, CHAR_LOOPFUNCTEMP1); + if( loopfunc ){ + loopfunc(charaindex); + iRet = TRUE; + } +#endif + if( iRet == FALSE ){ + CHAR_setInt( charaindex, CHAR_LOOPINTERVAL, 0); + } + + CHAR_setWorkInt(charaindex,CHAR_WORKLOOPSTARTSEC, NowTime.tv_sec); + CHAR_setWorkInt(charaindex,CHAR_WORKLOOPSTARTMSEC, NowTime.tv_usec); + } + return iRet; +} + + +int EnemyMoveNum = 10; +void CHAR_Loop( void ) +{ + int charnum=CHAR_getCharNum(); + int playernum = CHAR_getPlayerMaxNum(); + int petnum = CHAR_getPetMaxNum(); + static int charcnt = 0; + int i, movecnt=0; + + + if( charcnt == -1 ) { + charcnt = CHAR_getCharNum(); + } + + // 玩家用的loop + for( i=0 ; i< playernum ; i++ ){ + if( CHAR_getCharUse(i) == FALSE )continue; + CHAR_walk_check( i ); + CHAR_callLoop( i ); +#ifdef _TEACHER_SYSTEM + // 有获得导师声望 + if(CHAR_getWorkInt(i,CHAR_WORK_GET_TEACHER_FAME) > 0){ + int iAddTFame = CHAR_getInt(i,CHAR_TEACHER_FAME) + CHAR_getWorkInt(i,CHAR_WORK_GET_TEACHER_FAME); + int iAddFame = CHAR_getInt(i,CHAR_FAME) + CHAR_getWorkInt(i,CHAR_WORK_GET_TEACHER_FAME); + + // 加导师声望(导师声望最大值和个人声望最大值一样) + if(iAddTFame > MAX_PERSONALFAME) iAddTFame = MAX_PERSONALFAME; + else if(iAddTFame < 0) iAddTFame = 0; + CHAR_setInt(i,CHAR_TEACHER_FAME,iAddTFame); + // 加声望 + if(iAddFame > MAX_PERSONALFAME) iAddFame = MAX_PERSONALFAME; + else if(iAddFame < 0) iAddFame = 0; + CHAR_setInt(i,CHAR_FAME,iAddFame); + // 清为 0 + CHAR_setWorkInt(i,CHAR_WORK_GET_TEACHER_FAME,0); + // 若有家族,上传给ac保持二边资料同步 + if(CHAR_getInt(i,CHAR_FMLEADERFLAG) > 0 && CHAR_getInt(i,CHAR_FMLEADERFLAG) != FMMEMBER_APPLY){ + char tmpbuf1[16]; + + sprintf(tmpbuf1,"%d",iAddFame); + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(i,CHAR_FMNAME), + CHAR_getInt(i,CHAR_FMINDEX), + CHAR_getWorkInt(i,CHAR_WORKFMINDEXI), + FM_FIX_FMFEED, + "0", // 只是为了同步资料,所以设为0,不动到家族的资料 + tmpbuf1, // 同步个人声望资料 + CHAR_getWorkInt(i,CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(getfdFromCharaIndex(i)) + ); + } + } +#endif + } + + // 玩家以外的Object用的loop + for( i = 0, movecnt = 0 ; i < (petnum/2) ; i++, charcnt++ ){ + if( charcnt >= charnum )charcnt = playernum ; + if( CHAR_getCharUse(charcnt) == FALSE )continue; + if( CHAR_callLoop(charcnt) == TRUE ){ + if( ++movecnt >= EnemyMoveNum )break; + } + } + +} + +char* CHAR_appendNameAndTitle( int charaindex, char* src, char* buf, + int buflen ) +{ + if( buflen > 0 ){ + if( CHAR_CHECKINDEX(charaindex) == FALSE ) + snprintf( buf,buflen,"%s",src ); + else{ + int titleindex = CHAR_getInt(charaindex,CHAR_INDEXOFEQTITLE); + if( titleindex == -1 ) + snprintf( buf,buflen, "%s:%s", + CHAR_getChar(charaindex,CHAR_NAME), src ); + else + snprintf( buf,buflen, "%s(%s):%s", + CHAR_getChar(charaindex,CHAR_NAME), + TITLE_makeTitleStatusString(charaindex, + titleindex), src ); + } + } + return buf; +} + +void CHAR_getCoordinationDir( int dir , int x, int y ,int c, + int *xout , int *yout ) +{ + *xout = x + CHAR_getDX(dir) * c; + *yout = y + CHAR_getDY(dir) * c; +} + +BOOL CHAR_createCharacter( int type, int floor, int x, int y,int dir, + int* charaindex, int* objindex, BOOL seemap ) +{ + Char ch; + Object ob; + if( !CHAR_getDefaultChar( &ch,type ) )return FALSE; + + ch.data[CHAR_FLOOR] = floor; + ch.data[CHAR_X] = x; + ch.data[CHAR_Y] = y; + ch.data[CHAR_DIR] = dir; + + *charaindex = CHAR_initCharOneArray( &ch ); + if( *charaindex == -1 )return FALSE; + + ob.type = OBJTYPE_CHARA; + ob.index = *charaindex; + ob.floor = floor; + ob.x = x; + ob.y = y; + + if( seemap && MAP_walkAble( *charaindex, floor,x,y ) == FALSE ){ + CHAR_endCharOneArray( *charaindex ); + return FALSE; + } + + *objindex = initObjectOne( &ob ); + if( *objindex == -1 ){ + CHAR_endCharOneArray(*charaindex); + return FALSE; + } + CHAR_setWorkInt( *charaindex,CHAR_WORKOBJINDEX,*objindex); + + /* 生永玄伐□弁毛垫丹 */ + + CHAR_sendWatchEvent( *objindex,CHAR_ACTSTAND,NULL,0,TRUE); + + return TRUE; +} + +void CHAR_ObjectDelete( int objindex ) +{ + CHAR_sendCDArroundChar( OBJECT_getFloor(objindex), + OBJECT_getX(objindex), + OBJECT_getY(objindex), + objindex ); +#ifdef _MAP_WARPPOINT + if( OBJECT_getType( objindex) == OBJTYPE_WARPPOINT ){ + print("Delete OBJTYPE_WARPPOINT endObjectOne( %d) [%d,%d,%d] \n ", objindex, + OBJECT_getFloor(objindex), OBJECT_getX(objindex), + OBJECT_getY(objindex) ); + } +#endif + endObjectOne(objindex); +} + +/*------------------------------------------------------------ + * 平乓仿毛绰轮允月[左皮斥尼弁玄手绰轮允月[ + * 生永玄伐□弁及支曰酸仄毛卅仁允凶户及手及 + * 娄醒 + * charaindex int 平乓仿奶件犯永永弁旦 + * 忒曰袄 + * 卅仄 + ------------------------------------------------------------*/ +void CHAR_CharaDelete( int charaindex ) +{ + /* 左皮斥尼弁玄毛绰轮 */ + CHAR_ObjectDelete( CHAR_getWorkInt( charaindex,CHAR_WORKOBJINDEX ) ); + /* 平乓仿及绰轮 */ + CHAR_endCharOneArray( charaindex ); +} +/*------------------------------------------------------------ + * 皿伊奶乩□及 匀化中月矢永玄毛壅允 + ------------------------------------------------------------*/ +void CHAR_CharaDeleteHavePet( int charaindex) +{ + int i; + int pindex; + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + pindex = CHAR_getCharPet( charaindex, i); + if( CHAR_CHECKINDEX( pindex)) { + CHAR_endCharOneArray( pindex ); + } + } + for( i = 0; i < CHAR_MAXPOOLPETHAVE; i ++ ) { + pindex = CHAR_getCharPoolPet( charaindex, i); + if( CHAR_CHECKINDEX( pindex)) { + CHAR_endCharOneArray( pindex ); + } + } +} +/*------------------------------------------------------------ + * 减变升啼卅升毛 蜇允月[ + * mode int 0: 愤坌卞反CA霜日卅中 + * 1: 愤坌卞手CA霜月 + ------------------------------------------------------------*/ +int CHAR_sendAction( int charaindex, int action, int mode) +{ + /* 霜日木化 凶失弁扑亦件午CA毛域谯今六月 □皮伙 */ + static int table[] = { + CHAR_ACTATTACK,CHAR_ACTDAMAGE,CHAR_ACTDOWN,CHAR_ACTACTIONSTAND, + CHAR_ACTACTIONWALK,CHAR_ACTSIT,CHAR_ACTHAND,CHAR_ACTPLEASURE, + CHAR_ACTANGRY,CHAR_ACTSAD,CHAR_ACTGUARD, CHAR_ACTNOD, CHAR_ACTTHROW + }; + if( action < 0 || action >= arraysizeof( table)) return FALSE; + + /* 璃曰卞失弁扑亦件毛霜耨允月 */ + CHAR_sendWatchEvent( + CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), + table[action], + NULL,0,mode); + + /* 失弁扑亦件及瓒 */ + CHAR_setWorkInt( charaindex, CHAR_WORKACTION, table[action]); + + return TRUE; +} +/*------------------------------------------------------------ + * 愤坌互爵 匹丐月午中丹仪毛霜耨允月[ + ------------------------------------------------------------*/ +void CHAR_sendBattleEffect( int charaindex, int onoff) +{ + int opt[3]; + + if( onoff == 1) { + opt[0] = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX); + opt[1] = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLESIDE); + opt[2] = (BattleArray[CHAR_getWorkInt( charaindex, + CHAR_WORKBATTLEINDEX)].Side[ + CHAR_getWorkInt( charaindex, + CHAR_WORKBATTLESIDE)].flg & BSIDE_FLG_HELP_OK) ? TRUE:FALSE; + } + else { + opt[0] = -1; + opt[1] = -1; + opt[2] = 0; + } + + CHAR_sendWatchEvent( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), + CHAR_ACTBATTLE,opt,arraysizeof(opt),TRUE); +} + +/*------------------------------------------------------------ + * 交易中传送讯息 add code Shan 2001/06/30 + ------------------------------------------------------------*/ +void CHAR_sendTradeEffect( int charaindex, int onoff) +{ + int opt[1]; + + if( onoff == 1) { + opt[0] = 1; + } + else { + opt[0] = -1; + } + CHAR_sendWatchEvent( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), + CHAR_ACTTRADE,opt,arraysizeof(opt),TRUE); +} + +#ifdef _ANGEL_SUMMON +void CHAR_sendAngelEffect( int charaindex, int onoff) +{ + int opt[1]; + + if( onoff == 1) { + opt[0] = 1; + } + else { + opt[0] = -1; + } + CHAR_sendWatchEvent( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), + CHAR_ACTANGEL,opt,arraysizeof(opt),TRUE); +} +#endif + +#ifdef _MIND_ICON +void CHAR_sendMindEffect( int charaindex, int onoff) +{ + int opt[1]; + + if(onoff>0){ + opt[0] = onoff; + } + else{ + opt[0] = 0; + } + CHAR_sendWatchEvent( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), + CHAR_MIND, opt, arraysizeof(opt), FALSE); +} +#endif +#ifdef _ITEM_CRACKER +void CHAR_sendCrackerEffect( int charaindex, int onoff) +{ + int opt[1]; + opt[0] = onoff; + CHAR_sendWatchEvent( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), + CHAR_ITEM_CRACKER, opt, arraysizeof(opt), FALSE); +} +#endif + +void CHAR_inputUserPetName( int index , int havepetindex, char* name ) +{ + int petindex; + //char category[3]; + char *mycdkey=NULL, *cdkey = NULL; + BOOL changenameflg = FALSE; + + if( !CHAR_CHECKINDEX( index ) ) return; + + petindex = CHAR_getCharPet( index, havepetindex); + if( !CHAR_CHECKINDEX( petindex)) return; + + if (CHAR_getInt(petindex, CHAR_PETFAMILY) == 1){ + CHAR_talkToCli(index, -1, "家族守护兽无法修改名字!", CHAR_COLORYELLOW); + return; + } + + mycdkey = CHAR_getChar( index, CHAR_CDKEY); + cdkey = CHAR_getChar( petindex, CHAR_CDKEY); + if( cdkey == NULL ) { + print( "can't get CDKEY\n"); + }else { + if( strlen( cdkey) == 0 || strcmp( cdkey, mycdkey) == 0 ) { + changenameflg = TRUE; + } + } + if( !changenameflg) { + CHAR_talkToCli( index, -1, "无法为宠物命名。", CHAR_COLORYELLOW ); + return; + } + + CHAR_setChar( petindex, CHAR_USERPETNAME ,name); + + if( strlen( name ) == 0 || + strcmp( CHAR_getChar( petindex, CHAR_NAME), name) == 0 ){ + CHAR_setChar( petindex, CHAR_CDKEY, ""); + }else { + CHAR_setChar( petindex, CHAR_CDKEY, mycdkey); + } + CHAR_send_K_StatusString( index, havepetindex, CHAR_K_STRING_USERPETNAME); +} + +static void CHAR_setLuck( int charaindex) +{ + LSTIME nowlstime; + LSTIME mylstime; + struct { + int prob; + int luck; + }lucktbl[] = { + { 60, 1 }, /* 40% */ + { 30, 2 }, /* 30% */ + { 10, 3 }, /* 20% */ + { 3, 4 }, /* 7% */ + { 0, 5 } /* 3% */ + }; + + if( !CHAR_CHECKINDEX( charaindex)) return; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER) return; + + RealTimeToLSTime( NowTime.tv_sec, &nowlstime); + RealTimeToLSTime( CHAR_getInt( charaindex, CHAR_LASTTIMESETLUCK), &mylstime); + + /* LS凛棉匹ㄠ 动晓烦匀化中木壬CHAR_LUCK毛凳蕙允月 */ + if( nowlstime.day != mylstime.day || nowlstime.year != mylstime.year ) { + int i,r; + r = RAND( 0, 99); + for( i = 0; i < arraysizeof( lucktbl); i ++ ) { + if( r >= lucktbl[i].prob ) { + CHAR_setInt( charaindex, CHAR_LUCK, lucktbl[i].luck); + CHAR_setInt( charaindex, CHAR_LASTTIMESETLUCK, NowTime.tv_sec); + return; + } + } + } +} +void CHAR_JoinBattle_WindowResult( int charaindex, int select, char *data) +{ + int ret = FALSE; + int fd = getfdFromCharaIndex( charaindex); + +#if 1 // 修正利用参战重复加入战斗 Robin + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) { + CHAR_talkToCli( charaindex, -1, " 重复加入战斗! ", CHAR_COLORRED); + print("\n 改封包!!重复加入战斗!:%s ", CHAR_getChar( charaindex, CHAR_CDKEY) ); + //lssproto_EN_send( fd, FALSE, 0 ); + return; + } +#endif + if( select != WINDOW_BUTTONTYPE_CANCEL && + CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_NONE ){ + while( 1 ) { + int selected; + int bcharaindex; + if( fd == -1 ) break; + selected = atoi( data)-1; + + if( !CHAR_CHECKINDEX( CONNECT_getBattlecharaindex(fd,selected))) { + break; + } + if( CHAR_getWorkInt( CONNECT_getBattlecharaindex(fd,selected), + CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE){ + break; + } + if( BattleArray[ CHAR_getWorkInt( + CONNECT_getBattlecharaindex( fd,selected), + CHAR_WORKBATTLEINDEX)].type != BATTLE_TYPE_P_vs_E ){ + break; + } + bcharaindex = CONNECT_getBattlecharaindex( fd,selected); + if( !(BattleArray[CHAR_getWorkInt( bcharaindex, + CHAR_WORKBATTLEINDEX)].Side[ + CHAR_getWorkInt( bcharaindex, + CHAR_WORKBATTLESIDE)].flg + & BSIDE_FLG_HELP_OK)){ + break; + } + if(NPC_Util_CharDistance( charaindex, + CONNECT_getBattlecharaindex( + fd,selected) )> 1){ + break; + } + if( BATTLE_RescueEntry( charaindex, + CONNECT_getBattlecharaindex(fd,selected) )){ + CHAR_talkToCli( charaindex, -1, "无法参战。", + CHAR_COLORYELLOW); + }else { + ret = TRUE; + } + + break; + } + } + if( ret == FALSE ) { + if( fd != -1 ) { + lssproto_EN_send( fd, FALSE, 0 ); + } + } +} +void CHAR_JoinDuel_WindowResult( int charaindex, int select, char *data) +{ + int ret = FALSE; + int fd = getfdFromCharaIndex( charaindex); + /* 手丹域蘸民尼永弁允月 */ + if( select != WINDOW_BUTTONTYPE_CANCEL && + CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_CLIENT ) + { + /* 生旦玄互丹匀午云仄中及匹ㄠ蘸分仃伙□皿毛银丹 */ + while( 1 ) { + int selected; + int enemyindex; + + if( fd == -1 ) break; + selected = atoi( data)-1; + /* 躲卅index井 */ + if( !CHAR_CHECKINDEX( CONNECT_getDuelcharaindex(fd,selected)) ) { + break; + } + /* 爵 井升丹井 */ + if( CHAR_getWorkInt( CONNECT_getDuelcharaindex(fd,selected), + CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) + { + break; + } + /* duel第井 */ + if( !CHAR_getFlg( CONNECT_getDuelcharaindex(fd,selected), + CHAR_ISDUEL)) + { + break; + } + /* ㄠ汹动 卞中月井(它奴件玉它匹 中宁歹六仄化月棉卞 仃月啃) */ + if(NPC_Util_CharDistance( charaindex, + CONNECT_getDuelcharaindex(fd,selected) ) + > 1) + { + break; + } + // 及蟆及平乓仿及奶件犯永弁旦 + enemyindex = CONNECT_getDuelcharaindex( fd,selected); + // 锹澎互褪卅日公及引引巨件市它件玄今六月互 + // 阂间卅日褪毛裟氏匹仁月 + if( CHAR_getWorkInt( enemyindex, CHAR_WORKPARTYMODE ) + == CHAR_PARTY_CLIENT ) + { + enemyindex = CHAR_getWorkInt( enemyindex, CHAR_WORKPARTYINDEX1 ); + // 卅兮井褪互中卅中 + if( enemyindex < 0 ) break; + } + /* 锹澎互皿伊奶乩□匹卅中仪手丐月 */ + if( CHAR_getWorkInt( enemyindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER){ + break; + } + ret = BATTLE_CreateVsPlayer( charaindex, enemyindex ); + if( ret != 0 ){ + CHAR_talkToCli( charaindex, -1, + "遭遇失败!", CHAR_COLORYELLOW); + ret = FALSE; + } + else { + ret = TRUE; + } + break; + } + } + if( ret == FALSE ) { + /* 瑛绊霜耨 */ + if( fd != -1 ) { + lssproto_EN_send( fd, FALSE, 0 ); + } + } +} +void CHAR_SelectCard_WindowResult( int charaindex, int select, char *data) +{ + if( select != WINDOW_BUTTONTYPE_CANCEL ){ + while( 1 ) { + int selected; + int fd; + fd = getfdFromCharaIndex( charaindex); + if( fd == -1 ) break; + selected = atoi( data)-1; + if( !CHAR_CHECKINDEX( + CONNECT_getTradecardcharaindex(fd,selected))) { + break; + } + if( CHAR_getWorkInt( CONNECT_getTradecardcharaindex(fd,selected), + CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE){ + break; + } + if(!CHAR_getFlg( CONNECT_getTradecardcharaindex(fd,selected), + CHAR_ISTRADECARD)){ + break; + } + if( NPC_Util_CharDistance( charaindex, + CONNECT_getTradecardcharaindex + (fd,selected) ) > 1){ + break; + } + ADDRESSBOOK_addAddressBook( charaindex, + CONNECT_getTradecardcharaindex( + fd,selected)); + break; + } + } +} + +void CHAR_JoinParty_WindowResult( int charaindex , int select, char *data) +{ + int ret = FALSE; + int fd = getfdFromCharaIndex( charaindex); + /* 手丹域蘸民尼永弁允月 */ + if( select != WINDOW_BUTTONTYPE_CANCEL && + /* 愤坌互由□ 奴赚氏匹凶日蛲 */ + CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_NONE ) + { + /* 生旦玄互丹匀午云仄中及匹ㄠ蘸分仃伙□皿毛银丹 */ + while( 1 ) { + int parray; + int selected; + int toindex = -1; + if( fd == -1 ) break; + selected = atoi( data)-1; + + /* 躲卅index井 + * (褐邰“它奴件玉它匹 中宁歹六仄化月棉卞 + * 躲卅index卞卅月第 岭互丐月) + */ + if( !CHAR_CHECKINDEX( + CONNECT_getJoinpartycharaindex(fd,selected))) { + break; + } + /* 褪互中凶日娄匀舰曰请允 */ + if( CHAR_getWorkInt( CONNECT_getJoinpartycharaindex( + fd,selected), CHAR_WORKPARTYMODE) + == CHAR_PARTY_NONE ) + { + toindex = CONNECT_getJoinpartycharaindex( fd,selected ); + } + else { + toindex = CHAR_getPartyIndex( + CONNECT_getJoinpartycharaindex(fd,selected), 0); + if( !CHAR_CHECKINDEX( toindex) ) { + print( " %s:%d err\n", __FILE__, __LINE__); + break; + } + } + /* ㄠ汹动 卞中月井(它奴件玉它匹 中宁歹六仄化月棉卞 仃月啃) */ + if( NPC_Util_CharDistance( charaindex, toindex ) > 1) { + break; + } + /* 爵 反分户 */ + if( CHAR_getWorkInt( toindex, CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) + { + break; + } + /* 醮棉袱第乒□玉井 */ + if( !CHAR_getFlg( toindex, CHAR_ISPARTY)) { + break; + } + + /* 锹澎由□ 奴及谛醒反 井" */ + parray = CHAR_getEmptyPartyArray( toindex) ; + if( parray == -1 ) break; + +#ifdef _DEATH_CONTEND + if(CHAR_getInt(toindex,CHAR_PKLISTTEAMNUM) == -1 && CHAR_getInt(charaindex,CHAR_PKLISTTEAMNUM) == -1){ + }else if(CHAR_getInt(charaindex,CHAR_PKLISTLEADER) > 0 || + CHAR_getInt(toindex, CHAR_PKLISTTEAMNUM) < 0 || + CHAR_getInt(charaindex, CHAR_PKLISTTEAMNUM) < 0 || + CHAR_getInt(toindex,CHAR_PKLISTTEAMNUM) != CHAR_getInt(charaindex,CHAR_PKLISTTEAMNUM) || + CHAR_getInt(toindex,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER){ + CHAR_talkToCli( charaindex, -1, "队伍不同,无法加入团队。", CHAR_COLORYELLOW); + ret = FALSE; + break; + } +#endif + + /* 由□ 奴卞 日六月 */ + CHAR_JoinParty_Main( charaindex, toindex); + + ret = TRUE; + + break; + } + } + if( ret == FALSE ) { + CHAR_talkToCli( charaindex, -1, "无法加入团队。", + CHAR_COLORYELLOW); + } + /* 瑛绊霜耨 */ + if( fd != -1 ) { + lssproto_PR_send( fd, 1, ret); + } +} +void CHAR_JoinBattleWatch_WindowResult( int charaindex, int select, char *data) +{ + int ret = FALSE; + int fd = getfdFromCharaIndex( charaindex); + /* 手丹域蘸民尼永弁允月 */ + if( select != WINDOW_BUTTONTYPE_CANCEL ) { + /* 生旦玄互丹匀午云仄中及匹ㄠ蘸分仃伙□皿毛银丹 */ + while( 1 ) { + int selected; + if( fd == -1 ) break; + selected = atoi( data)-1; + + /* 躲卅index井 + * (褐邰“它奴件玉它匹 中宁歹六仄化月棉卞 + * 躲卅index卞卅月第 岭互丐月) + */ + if( !CHAR_CHECKINDEX( CONNECT_getBattlecharaindex(fd,selected))) { + break; + } + /* 爵 井升丹井 */ + if( CHAR_getWorkInt( CONNECT_getBattlecharaindex(fd,selected), + CHAR_WORKBATTLEMODE) + == BATTLE_CHARMODE_NONE) + { + break; + } + /* ㄠ汹动 卞中月井(它奴件玉它匹 中宁歹六仄化月棉卞 仃月啃) */ + if(NPC_Util_CharDistance( charaindex, + CONNECT_getBattlecharaindex( + fd,selected) ) + > 1) + { + break; + } + /* 巨件玄伉□今六月 */ + if( BATTLE_WatchEntry( charaindex, + CONNECT_getBattlecharaindex(fd,selected) + )) + { + CHAR_talkToCli( charaindex, -1, "无法观战。", + CHAR_COLORYELLOW); + } + else { + ret = TRUE; + } + + break; + } + } + if( ret == FALSE ) { + /* 瑛绊霜耨 */ + if( fd != -1 ) { + lssproto_EN_send( fd, FALSE, 0 ); + } + } +} + +#ifdef _FM_MODIFY +extern void NPC_FmDengonWindowTalked( int index, int talker, int seqno, int select, char *data); +#endif + +void CHAR_processWindow(int charaindex, int seqno, int select, + int objindex, char* data ) +{ + if( CHECKOBJECTUSE(objindex)) { + if( OBJECT_getType(objindex) == OBJTYPE_CHARA ) { + typedef void (*WINDF)(int,int,int, int,char*); + WINDF windowtalkedfunc=NULL; + windowtalkedfunc = (WINDF)CHAR_getFunctionPointer( + OBJECT_getIndex(objindex),CHAR_WINDOWTALKEDFUNC); + if( windowtalkedfunc ) { + windowtalkedfunc( OBJECT_getIndex(objindex), charaindex, + seqno, select, data); + } + } +#ifdef _NPCSERVER_NEW //CHAR_WINDOWTALKEDFUNC + else if( OBJECT_getType(objindex) == OBJTYPE_NPCSCHARA ) { + int npcindex = OBJECT_getNpcIndex( objindex); + if( npcfd != -1 ) + NPCS_NpcWinMess_send( objindex, npcindex, charaindex, data, seqno, select); + } +#endif + }else { + if( seqno == CHAR_WINDOWTYPE_SELECTBATTLE) { + CHAR_JoinBattle_WindowResult( charaindex, select, data); + }else if( seqno == CHAR_WINDOWTYPE_SELECTDUEL) { + CHAR_JoinDuel_WindowResult( charaindex, select, data); + }else if( seqno == CHAR_WINDOWTYPE_SELECTTRADECARD) { + CHAR_SelectCard_WindowResult( charaindex, select, data); + }else{ + if( seqno == CHAR_WINDOWTYPE_SELECTPARTY) { + CHAR_JoinParty_WindowResult( charaindex, select, data); + }else { + if( seqno == CHAR_WINDOWTYPE_SELECTBATTLEWATCH) { + CHAR_JoinBattleWatch_WindowResult( charaindex, select, data); + }else if( seqno >= CHAR_WINDOWTYPE_SELECTRENAMEITEM_PAGE1 && + seqno <= CHAR_WINDOWTYPE_SELECTRENAMEITEM_RENAME_ATTENTION ){ + ITEM_useRenameItem_WindowResult( charaindex, seqno, select, data); + } +#ifdef _PETSKILL_CANNEDFOOD + else if( seqno == ITEM_WINDOWTYPE_SELECTPETSKILL_SELECT ){ + ITEM_usePetSkillCanned_WindowResult( charaindex, seqno, select, data); + } +#endif + } + } +#ifdef _FM_MODIFY + if(seqno >= CHAR_WINDOWTYPE_FM_DENGON || seqno <= CHAR_WINDOWTYPE_FM_DPSELECT) + NPC_FmDengonWindowTalked(0,charaindex,seqno,select,data); +#endif + } +} + +void CHAR_PartyUpdate( int charaindex, int senddata ){ + int i, ownerindex, mode, pindex, pno; + mode = CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE ); + if( mode == CHAR_PARTY_NONE )return; + if( mode == CHAR_PARTY_LEADER ){ + ownerindex = charaindex; + }else{ + ownerindex = CHAR_getWorkInt( charaindex, CHAR_WORKPARTYINDEX1 ); + } + + for( pno = 0; pno < CHAR_PARTYMAX; pno ++ ){ + pindex = CHAR_getWorkInt( ownerindex, CHAR_WORKPARTYINDEX1+pno ); + if( pindex == charaindex )break; + } + if( pno == CHAR_PARTYMAX )return; + for( i = 0; i < CHAR_PARTYMAX; i ++ ){ + pindex = CHAR_getWorkInt( ownerindex, CHAR_WORKPARTYINDEX1+i ); + if( pindex == charaindex )continue; + if( pindex < 0 )continue; + CHAR_send_N_StatusString( pindex, pno, senddata ); + } +} + +static int CHAR_getObjectByPosition( int myobjindex, int fl, int x, int y, + int *objbuf, int objbuflen) +{ + int i,j; + int cnt = 0; + + for( i = x-CHAR_DEFAULTSEESIZ/2 ; i <= x+CHAR_DEFAULTSEESIZ/2 ; i++ ){ + for( j = y-CHAR_DEFAULTSEESIZ/2 ; j <= y+CHAR_DEFAULTSEESIZ/2 ; + j ++ ) + { + OBJECT object; + for( object = MAP_getTopObj(fl,i,j) ; + object ; + object = NEXT_OBJECT(object ) ) + { + int objindex = GET_OBJINDEX(object); + if( OBJECT_getType(objindex) == OBJTYPE_NOUSE ) continue; + if( OBJECT_getType( objindex) == OBJTYPE_CHARA && + !CHAR_getFlg( OBJECT_getIndex( objindex), CHAR_ISVISIBLE)) + { + continue; + } + /* 愤坌反中中方 */ + if( objindex == myobjindex) continue; + + objbuf[cnt] = objindex; + cnt ++; + if( cnt >= objbuflen) return cnt; + } + } + } + return cnt; +} +static void CHAR_setMyPosition_sendData( int charaindex,int prev_x, int prev_y, int x, int y) +{ + int CurrentObjCollection[CHAR_DEFAULTSEESIZ*CHAR_DEFAULTSEESIZ*10]; + int PrevObjCollection[CHAR_DEFAULTSEESIZ*CHAR_DEFAULTSEESIZ*10]; + int curcnt,prevcnt; + int objindex; + int fl; + char introduction[512]; + char c_msg[1024*96]; + char buf[64]; + int strpos; + int fd; + int i,j; + char cabuf[128]; + char myintroduction[512]; + char cd_msg[128]; + + fd = CHAR_getWorkInt( charaindex, CHAR_WORKFD); + if( fd == -1 )return; + + objindex = CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX); + fl = CHAR_getInt( charaindex, CHAR_FLOOR); + + curcnt = CHAR_getObjectByPosition( objindex, fl,x,y, CurrentObjCollection, sizeof(CurrentObjCollection)); + prevcnt = CHAR_getObjectByPosition( objindex, fl, prev_x, prev_y, PrevObjCollection, sizeof(PrevObjCollection)); + strpos = 0; + c_msg[0] = '\0'; + if( !CHAR_makeObjectCString( objindex, myintroduction,sizeof( myintroduction))){ + myintroduction[0] = '\0'; + } + + for( i = 0 ; i < curcnt; i ++ ) { + int findflg = FALSE; + for( j = 0; j < prevcnt; j ++ ) { + if( CurrentObjCollection[i] == PrevObjCollection[j] ) { + findflg = TRUE; + break; + } + } + if( !findflg ) { + int introlen; + int c_index = OBJECT_getIndex( CurrentObjCollection[i]); + if( CHAR_makeObjectCString( CurrentObjCollection[i], introduction, + sizeof( introduction))) + { + introlen = strlen( introduction); + introduction[introlen] = ','; + introduction[introlen+1] = '\0'; + + strcpysafe( &c_msg[strpos], sizeof( c_msg) - strpos, + introduction); + strpos += strlen( introduction); + if( strpos >= sizeof( c_msg)) break; + } + if( strlen( myintroduction) != 0 ) { + if( OBJECT_getType( CurrentObjCollection[i] ) == OBJTYPE_CHARA ) { + if( CHAR_getInt( c_index, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + int tofd = getfdFromCharaIndex( c_index ); + CDsend( tofd); + lssproto_C_send( tofd, myintroduction); + } + } + } + if( OBJECT_getType( CurrentObjCollection[i]) == OBJTYPE_CHARA ) { + if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && + CHAR_getWorkInt( c_index, CHAR_WORKPARTYMODE ) + == CHAR_PARTY_LEADER ){ + if( CHAR_makeCAOPT1String( CurrentObjCollection[i], cabuf, sizeof( cabuf), + CHAR_ACTLEADER,1 )){ + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + } + } + + // Robin 0611 trade + /* 角色交易中 */ + if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && + CHAR_getWorkInt( c_index, CHAR_WORKTRADEMODE ) != CHAR_TRADE_FREE ) { + if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), CHAR_ACTTRADE,1 )) + { + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + } + } + +#ifdef _ANGEL_SUMMON + if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && + CHAR_getWorkInt( c_index, CHAR_WORKANGELMODE ) == TRUE ) { + if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), CHAR_ACTANGEL,1 )) + { + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + } + } +#endif + +#ifdef _MIND_ICON + if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && + CHAR_getWorkInt( c_index, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE && + CHAR_getWorkInt( c_index, CHAR_MIND_NUM)) + { + if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), + CHAR_MIND, CHAR_getWorkInt( c_index, CHAR_MIND_NUM))) + { + CONNECT_appendCAbuf( fd, cabuf, strlen( cabuf)); + //print("\nshan---->(2)cabuf-->%s", cabuf); + } + } +#endif +#ifdef _STREET_VENDOR + if(CHAR_getWorkInt(c_index,CHAR_WORKSTREETVENDOR) == 1 && + CHAR_getWorkInt(c_index,CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE){ + if(CHAR_makeCAOPTString(objindex,cabuf,sizeof(cabuf), + CHAR_STREETVENDOR_OPEN,CHAR_getWorkChar(c_index,CHAR_STREETVENDOR_NAME))) + CONNECT_appendCAbuf(fd,cabuf,strlen(cabuf)); + } +#endif +#ifdef _ITEM_CRACKER + if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && + CHAR_getWorkInt( c_index, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE && + CHAR_getWorkInt( c_index, CHAR_WORKITEM_CRACKER)) + { + if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), + CHAR_ITEM_CRACKER, CHAR_getWorkInt( c_index, CHAR_WORKITEM_CRACKER))) + { + CONNECT_appendCAbuf( fd, cabuf, strlen( cabuf)); + } + } +#endif + /* 愤坌互褪匹锹澎互爵 匹卅中卅日锹澎卞伉□母□ 憎CA毛霜月 */ + if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && + CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE ) + == CHAR_PARTY_LEADER && + CHAR_getWorkInt( c_index, CHAR_WORKBATTLEMODE) + == BATTLE_CHARMODE_NONE) + { + int tofd = getfdFromCharaIndex( c_index ); + if( tofd != -1 ) { + if( CHAR_makeCAOPT1String( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), + cabuf, sizeof( cabuf), + CHAR_ACTLEADER,1 )) + { + CONNECT_appendCAbuf( tofd,cabuf,strlen(cabuf)); + } + } + } + /* 苇尹凶平乓仿互爵 卅日爵 失奶戊件 憎 毛霜月 */ + if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && + CHAR_getWorkInt( c_index, CHAR_WORKBATTLEMODE ) + != BATTLE_CHARMODE_NONE ) + { + /* 棋爵CA */ + if( CHAR_getWorkInt( c_index, CHAR_WORKBATTLEWATCH) == TRUE ) { + if( CHAR_makeCAOPT1String( CurrentObjCollection[i], cabuf, + sizeof( cabuf), + CHAR_ACTBATTLEWATCH, + 1)) + { + CONNECT_appendCAbuf( fd, cabuf, strlen( cabuf)); + } + } + else { + int battleno = CHAR_getWorkInt( c_index, + CHAR_WORKBATTLEINDEX); + int sideno = CHAR_getWorkInt( c_index, + CHAR_WORKBATTLESIDE); + int helpno = (BattleArray[CHAR_getWorkInt( c_index, + CHAR_WORKBATTLEINDEX)].Side[ + CHAR_getWorkInt( c_index, + CHAR_WORKBATTLESIDE)].flg & BSIDE_FLG_HELP_OK) ? TRUE:FALSE; + /* HelpNo = 1 反移 */ + if( CHAR_makeCAOPT3String( CurrentObjCollection[i], cabuf, sizeof( cabuf), + CHAR_ACTBATTLE, + battleno,sideno,helpno + )) + { + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + } + } + } + /* 苇尹凶平乓仿互窒井及失弁扑亦件毛仄化中木壬霜月[ */ + if( ( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER || + CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPET ) && + CHAR_getWorkInt( c_index, CHAR_WORKACTION ) != -1 ) + { + if( CHAR_makeCADefaultString( CurrentObjCollection[i], cabuf, sizeof( cabuf), + CHAR_getWorkInt( c_index, CHAR_WORKACTION))) + { + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + } + } + } + } + } + dchop( c_msg, "," ); + if( strlen( c_msg) != 0 ) { + lssproto_C_send( fd, c_msg); + } + + /* 愤坌及CD综岳 */ + cnv10to62( objindex,cd_msg, sizeof(cd_msg)); + + for( i = 0 ; i < prevcnt; i ++ ) { + int findflg = FALSE; + /* 蟆及匏 卞中月左皮斥尼弁玄匹]蜇箕及甄 卞中卅中 + * 左皮斥尼弁玄卅日壅允屯五左皮斥尼弁玄分 + */ + for( j = 0; j < curcnt; j ++ ) { + if( PrevObjCollection[i] == CurrentObjCollection[j] ) { + findflg = TRUE; + break; + } + } + if( !findflg ) { + cnv10to62( PrevObjCollection[i], buf, sizeof( buf)); + CONNECT_appendCDbuf( fd, buf, strlen( buf)); + + /* 锹澎卞手 霜月 */ + if( OBJECT_getType( PrevObjCollection[i]) == OBJTYPE_CHARA ) { + int tocharaindex = OBJECT_getIndex( PrevObjCollection[i]); + if( CHAR_getInt( tocharaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + int tofd = CHAR_getWorkInt( tocharaindex, CHAR_WORKFD); + if( tofd != -1 ) { + CONNECT_appendCDbuf( tofd, cd_msg, strlen( cd_msg)); + CDsend( tofd); + } + } + } + } + } + CDsend( fd); + + +} +BOOL CHAR_setMyPosition( int index, int x, int y, BOOL CAFlg) +{ + return CHAR_setMyPosition_main( index,x,y,-1,CAFlg); +} + +BOOL CHAR_setMyPosition_main( int index, int x, int y, int setdir, BOOL CAFlg) +{ + int objindex; + int prev_x,prev_y; + int fl; + + prev_x = CHAR_getInt( index, CHAR_X); + prev_y = CHAR_getInt( index, CHAR_Y); + if( prev_x == x && prev_y == y ) { + return FALSE; + } + + if( CHAR_getWorkInt( index, CHAR_WORKPARTYMODE) == CHAR_PARTY_CLIENT) { + return FALSE; + } + + if( CHAR_getFlg( index, CHAR_ISWARP)) return FALSE; + + objindex = CHAR_getWorkInt(index,CHAR_WORKOBJINDEX); + fl = CHAR_getInt( index, CHAR_FLOOR); + + if( !MAP_IsValidCoordinate( fl, x, y )) { + print( "error: invalid Coordinate fl[%d] x[%d] y[%d] %s:%d\n", + fl, x, y, __FILE__, __LINE__); + CONNECT_setCloseRequest( CHAR_getWorkInt( index, CHAR_WORKFD), 1); + return FALSE; + } + + if( ABS( x - prev_x) > CHAR_DEFAULTSEESIZ/2 || + ABS( y - prev_y) > CHAR_DEFAULTSEESIZ/2 ) + { + CHAR_sendCDArroundChar( fl,prev_x,prev_y,objindex ); + } + + if( ABS( x - prev_x) <= 1 && ABS( y - prev_y ) <= 1){ + POINT start,end; + int dir; + start.x = CHAR_getInt( index, CHAR_X); + start.y = CHAR_getInt( index, CHAR_Y); + end.x = x; + end.y = y; + dir = NPC_Util_getDirFromTwoPoint( &start, &end); + if( dir != -1 ) { + CHAR_walk( index, dir, 0); + } + } + else { + CHAR_setInt( index, CHAR_X,x); + CHAR_setInt( index, CHAR_Y,y); + if( setdir >= 0 && setdir < 8) CHAR_setInt( index, CHAR_DIR, setdir); + { + int of,ox,oy; + of = OBJECT_setFloor(objindex,fl); + ox = OBJECT_setX(objindex,x); + oy = OBJECT_setY(objindex,y); + + if( !MAP_objmove( objindex,of,ox,oy,fl,x,y ) ){ + fprint( "ERROR MAP_OBJMOVE objindex=%d\n",objindex ); + return FALSE; + } + } + if( ABS( x - prev_x) > CHAR_DEFAULTSEESIZ/2 || + ABS( y - prev_y) > CHAR_DEFAULTSEESIZ/2 ) + { + CHAR_sendWatchEvent(objindex,CHAR_ACTWARP,NULL,0,FALSE); + } + else if( CAFlg == TRUE ) { + CHAR_sendWatchEvent(objindex,CHAR_ACTWARP,NULL,0,FALSE); + } + } + + if( CHAR_getWorkInt( index, CHAR_WORKPARTYMODE) == CHAR_PARTY_LEADER ) { + if( ABS( x - prev_x) <= 1 && ABS( y - prev_y ) <= 1){ + int i; + int prevparty_x = prev_x; + int prevparty_y = prev_y; + for( i = 1; i < CHAR_PARTYMAX; i ++ ) { + int toindex = CHAR_getWorkInt( index, i + CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX(toindex) ) { + int client_x = prevparty_x; + int client_y = prevparty_y; + int dir; + POINT start, end; + + prevparty_x = CHAR_getInt( toindex, CHAR_X); + prevparty_y = CHAR_getInt( toindex, CHAR_Y); + start.x = prevparty_x; + start.y = prevparty_y; + + end.x = client_x; + end.y = client_y; + + dir = NPC_Util_getDirFromTwoPoint( &start, &end); + if( dir != - 1 ) { + CHAR_walk( toindex, dir, 0); + } + } + } + } + + else if( ABS( x - prev_x) > CHAR_DEFAULTSEESIZ/2 || + ABS( y - prev_y) > CHAR_DEFAULTSEESIZ/2 ) + { + int i; + for( i = 1; i < CHAR_PARTYMAX; i ++ ) { + int toindex = CHAR_getWorkInt( index, i + CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX(toindex) ) { + CHAR_warpToSpecificPoint( toindex,fl , x,y); + } + } + } + } + + if( ABS( x - prev_x) <= CHAR_DEFAULTSEESIZ/2 && + ABS( y - prev_y) <= CHAR_DEFAULTSEESIZ/2 ) + { + CHAR_setMyPosition_sendData( index, prev_x, prev_y, x, y); + } + + return TRUE; +} + + +static char CHAR_P_statusSendBuffer[STRINGBUFSIZ]; + + + +static char *CHAR_make_P_StatusString( int charaindex, unsigned int indextable ) +{ + int i,j; + int ret = 0; + int strlength; + char buf[64]; + struct { + unsigned int kind; + int intdataindex; + int gettype; + }chk[] = { + { CHAR_P_STRING_HP, CHAR_HP, 0 }, + { CHAR_P_STRING_MAXHP, CHAR_WORKMAXHP, 1 }, + { CHAR_P_STRING_MP, CHAR_MP, 0 }, + { CHAR_P_STRING_MAXMP, CHAR_WORKMAXMP, 1 }, + { CHAR_P_STRING_EXP, CHAR_EXP, 0 }, + { CHAR_P_STRING_LV, CHAR_LV, 0 }, + { CHAR_P_STRING_ATK, CHAR_WORKATTACKPOWER, 1 }, + { CHAR_P_STRING_DEF, CHAR_WORKDEFENCEPOWER, 1 }, + { CHAR_P_STRING_QUICK, CHAR_WORKQUICK, 1 }, + { CHAR_P_STRING_CHARM, CHAR_WORKFIXCHARM, 1 }, + { CHAR_P_STRING_LUCK, CHAR_WORKFIXLUCK, 1 }, + { CHAR_P_STRING_GOLD, CHAR_GOLD, 0 }, + { CHAR_P_STRING_TITLE, CHAR_INDEXOFEQTITLE, 0 }, + { CHAR_P_STRING_NAME, CHAR_NAME, 2 }, + { CHAR_P_STRING_OWNTITLE, CHAR_OWNTITLE, 2 }, + { CHAR_P_STRING_VITAL, CHAR_VITAL, 10 }, + { CHAR_P_STRING_STR, CHAR_STR, 10 }, + { CHAR_P_STRING_TOUGH, CHAR_TOUGH, 10 }, + { CHAR_P_STRING_DEX, CHAR_DEX, 10 }, + { CHAR_P_STRING_EARTH, CHAR_WORKFIXEARTHAT, 11 }, + { CHAR_P_STRING_WATER, CHAR_WORKFIXWATERAT, 11 }, + { CHAR_P_STRING_FIRE, CHAR_WORKFIXFIREAT, 11 }, + { CHAR_P_STRING_WIND, CHAR_WORKFIXWINDAT, 11 }, + { CHAR_P_STRING_DUELPOINT, CHAR_DUELPOINT, 0 }, + { CHAR_P_STRING_TRANSMIGRATION, CHAR_TRANSMIGRATION, 0}, + { CHAR_P_STRING_RIDEPET, CHAR_RIDEPET, 0}, + { CHAR_P_STRING_LEARNRIDE, CHAR_LEARNRIDE, 0}, + { CHAR_P_STRING_BASEBASEIMAGENUMBER, CHAR_BASEBASEIMAGENUMBER, 0}, + { CHAR_P_STRING_SKYWALKER, CHAR_WORKSKYWALKER, 1}, + { CHAR_P_STRING_DEBUGMODE, CHAR_WORKDEBUGMODE, 1}, +/* +#ifdef _CHAR_PROFESSION +#ifdef _SEND_PROF_DATA + { CHAR_P_STRING_PROFESSION, PROFESSION_CLASS, 20}, +#endif +#endif +*/ + }; + + snprintf( CHAR_P_statusSendBuffer, sizeof( CHAR_P_statusSendBuffer), + "P%s|", cnv10to62( indextable, buf,sizeof(buf))); + strlength = strlen( CHAR_P_statusSendBuffer ); + + for( i = 1; i < sizeof( int) * 8; i ++ ){ + if( indextable & (1 << i) ) { + char tmp[256]; + BOOL found = FALSE; + for( j = 0; j < arraysizeof( chk); j ++ ) { + if( chk[j].kind == 1 << i ) { + if( chk[j].gettype == 0 ) { + ret = CHAR_getInt( charaindex,chk[j].intdataindex); + snprintf( tmp, sizeof( tmp), "%d|", ret); + }else if( chk[j].gettype == 1 ) { + ret = CHAR_getWorkInt( charaindex,chk[j].intdataindex); + snprintf( tmp, sizeof( tmp), "%d|", ret); + }else if( chk[j].gettype == 10 ) { + ret = CHAR_getInt( charaindex, chk[j].intdataindex)/100; + snprintf( tmp, sizeof( tmp), "%d|", ret); + }else if( chk[j].gettype == 11 ) { + ret = CHAR_getWorkInt( charaindex, chk[j].intdataindex); + if( ret < 0) ret = 0; + snprintf( tmp, sizeof( tmp), "%d|", ret); + }else if( chk[j].gettype == 2 ) { + char escapebuffer[128]; + char *a = CHAR_getChar( charaindex, chk[j].intdataindex); + + snprintf( tmp,sizeof( tmp ), + "%s|", + makeEscapeString( a, escapebuffer, + sizeof(escapebuffer) + )); + } +/* +#ifdef _CHAR_PROFESSION +#ifdef _SEND_PROF_DATA + else if( chk[j].gettype == 20 ) { + int k; + char tempbuf[256]; + strcpy( tmp, ""); + for( k=0; k<11; k++){ + ret = CHAR_getInt( charaindex, chk[j].intdataindex + k ); + snprintf( tempbuf, sizeof( tempbuf), "%d|", ret); + strcat( tmp, tempbuf); + } + } +#endif +#endif +*/ + found = TRUE; + break; + } + } + if( !found) { + if( indextable & CHAR_P_STRING_NEXTEXP ) { + ret = CHAR_GetLevelExp( charaindex, CHAR_getInt( charaindex, CHAR_LV ) + 1 ); + snprintf( tmp, sizeof( tmp), "%d|", ret); + found = TRUE; + } + } + if( !found) { + print( "找不到指定的参数[%d]\n",indextable); + }else { + strcpysafe( &CHAR_P_statusSendBuffer[ strlength], + sizeof( CHAR_P_statusSendBuffer) - strlength, + tmp); + + strlength += strlen( tmp ); + if( strlength >= sizeof( CHAR_P_statusSendBuffer ) ) { + return CHAR_P_statusSendBuffer; + } + } + } + } + return CHAR_P_statusSendBuffer; +} + + + +BOOL CHAR_send_P_StatusString( int charaindex, unsigned int indextable ) +{ + char* string; + //if( indextable >= ( CHAR_P_STRING_BASEBASEIMAGENUMBER << 1)) { + if( indextable >= ( CHAR_P_STRING_SKYWALKER << 1)) { + //if( indextable >= ( CHAR_P_STRING_DEBUGMODE << 1)) { + print( "send_P invalid index[%d]\n", indextable); + return FALSE; + } + + if( CHAR_getInt(charaindex,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ){ + return FALSE; + } + + string = CHAR_make_P_StatusString( charaindex, indextable ); + + if( string != NULL ){ + int fd; + fd = getfdFromCharaIndex( charaindex ); + if( fd != -1 ){ + lssproto_S_send( fd, string ); + return TRUE; + } + } + return FALSE; +} +static char CHAR_N_statusSendBuffer[STRINGBUFSIZ]; +/*------------------------------------------------------------ + * 弁仿奶失件玄卞霜月 { 及 侬 毛综岳允月[ + * 娄醒 + * charaindex int 平乓仿奶件犯弁永旦 + * indextable int P 毛霜月由仿丢□正及螂宁 [ + *------------------------------------------------------------*/ +static char *CHAR_make_N_StatusString( int charaindex, int num, unsigned int indextable ) +{ + int i,j; + int nindex = -1; + int ret = 0; + int strlength; + char buf[64]; + struct { + unsigned int kind; + int intdataindex; + int gettype; + }chk[] = { + { CHAR_N_STRING_OBJINDEX, CHAR_WORKOBJINDEX, 1 }, + { CHAR_N_STRING_LV, CHAR_LV, 0 }, + { CHAR_N_STRING_MAXHP, CHAR_WORKMAXHP, 1 }, + { CHAR_N_STRING_HP, CHAR_HP, 0 }, + { CHAR_N_STRING_MP, CHAR_MP, 0 }, + { CHAR_N_STRING_NAME, CHAR_NAME, 2 }, + + + }; + /* 醮棉旦 □正旦犯□正 */ + /* 凝民尼永弁 */ + if( num < 0 || num >= CHAR_PARTYMAX ){ + print( "朋友模式失败 (%c)%d \n", num, num ); + return NULL; + } + /* 醮棉及奶件犯永弁旦毛潸 */ + nindex = CHAR_getPartyIndex( charaindex, num); + + if( nindex == -1 ){ + /* 鬼支仃升 snprintf 允月 */ + snprintf( CHAR_N_statusSendBuffer,sizeof(CHAR_N_statusSendBuffer), + "N%d|0|", num ); + return CHAR_N_statusSendBuffer; + } + + snprintf( CHAR_N_statusSendBuffer, sizeof( CHAR_N_statusSendBuffer), + "N%d|%s|", num,cnv10to62( indextable, buf,sizeof(buf))); + strlength = strlen( CHAR_N_statusSendBuffer ); + + /* indextable及 匹 匀化中月申永玄毛赐 卞譬屯月 */ + for( i = 1; i < sizeof( int) * 8; i ++ ){ + if( indextable & (1 << i) ) { + char tmp[256]; + BOOL found = FALSE; + /* 匀化中月申永玄午]chk卞甲永玄允月井譬屯月 */ + for( j = 0; j < arraysizeof( chk); j ++ ) { + if( chk[j].kind == 1 << i ) { + /* 域谯仄凶及匹袄毛潸 允月 */ + /* 醒袄烟及犯□正 */ + if( chk[j].gettype == 0 ) { + ret = CHAR_getInt( nindex,chk[j].intdataindex); + snprintf( tmp, sizeof( tmp), "%d|", ret); + } + else if( chk[j].gettype == 1 ) { + ret = CHAR_getWorkInt( nindex,chk[j].intdataindex); + snprintf( tmp, sizeof( tmp), "%d|", ret); + } + else if( chk[j].gettype == 10 ) { + ret = CHAR_getInt( nindex, chk[j].intdataindex)/100; + snprintf( tmp, sizeof( tmp), "%d|", ret); + } + else if( chk[j].gettype == 11 ) { + ret = CHAR_getWorkInt( nindex, chk[j].intdataindex); + if( ret < 0) ret = 0; + snprintf( tmp, sizeof( tmp), "%d|", ret); + } + /* 侬 烟及犯□正 */ + else if( chk[j].gettype == 2 ) { + char escapebuffer[128]; + char *a = CHAR_getChar( nindex, chk[j].intdataindex); + + snprintf( tmp,sizeof( tmp ), + "%s|", + makeEscapeString( a, escapebuffer, + sizeof(escapebuffer) + )); + } + found = TRUE; + break; + } + } + /* 职及正奶皿及犯□正井手仄木卅中 */ + if( !found) { + /* 仇仇井日反ㄠ勾ㄠ勾 */ + } + if( !found) { + print( "找不到指定的参数[%d]\n",indextable); + } + else { + strcpysafe( &CHAR_N_statusSendBuffer[ strlength], + sizeof( CHAR_N_statusSendBuffer) - strlength, + tmp); + + strlength += strlen( tmp ); + if( strlength >= sizeof( CHAR_N_statusSendBuffer ) ) { + return CHAR_N_statusSendBuffer; + } + } + } + } + return CHAR_N_statusSendBuffer; +} +/*------------------------------------------------------------ + * S P 旦 □正旦毛霜月[民尼永弁允月及匹}晓匹反民尼永弁仄卅仁化方中[ + * 娄醒 + * charaindex int 平乓仿奶件犯弁永旦 + * num int 醮棉 寞 + * indextable int P 毛霜月由仿丢□正及螂宁 [ + * 忒曰袄 + * 霜匀凶[TRUE(1) + * 霜木卅井匀凶[FALSE(0) + *------------------------------------------------------------*/ +BOOL CHAR_send_N_StatusString( int charaindex, int num, unsigned int indextable ) +{ + char* string; + + if( indextable >= (CHAR_N_STRING_NAME << 1)) { + print( "send_N invalid index[%d]\n", indextable); + return FALSE; + } + + if( CHAR_getInt(charaindex,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ){ + return FALSE; + } + string = CHAR_make_N_StatusString( charaindex, num, indextable ); + if( string != NULL ){ + int fd; + fd = getfdFromCharaIndex( charaindex ); + if( fd != -1 ){ + lssproto_S_send( fd, string ); + return TRUE; + } + } + return FALSE; +} + +static char CHAR_K_statusSendBuffer[STRINGBUFSIZ]; +static char *CHAR_make_K_StatusString( int charaindex, int num, unsigned int indextable ) +{ + int i,j; + int ret = 0; + int strlength; + int pindex; + char buf[64]; + struct { + unsigned int kind; + int intdataindex; + int gettype; + }chk[] = { + { CHAR_K_STRING_BASEIMAGENUMBER, CHAR_BASEIMAGENUMBER, 0 }, + { CHAR_K_STRING_HP, CHAR_HP, 0 }, + { CHAR_K_STRING_MAXHP, CHAR_WORKMAXHP, 1 }, + { CHAR_K_STRING_MP, CHAR_MP, 0 }, + { CHAR_K_STRING_MAXHP, CHAR_WORKMAXMP, 1 }, + { CHAR_K_STRING_EXP, CHAR_EXP, 0 }, + { CHAR_K_STRING_LV, CHAR_LV, 0 }, + { CHAR_K_STRING_ATK, CHAR_WORKATTACKPOWER, 1 }, + { CHAR_K_STRING_DEF, CHAR_WORKDEFENCEPOWER, 1 }, + { CHAR_K_STRING_QUICK, CHAR_WORKQUICK, 1 }, + { CHAR_K_STRING_AI, CHAR_WORKFIXAI, 1 }, + { CHAR_K_STRING_EARTH, CHAR_WORKFIXEARTHAT, 11}, + { CHAR_K_STRING_WATER, CHAR_WORKFIXWATERAT, 11}, + { CHAR_K_STRING_FIRE, CHAR_WORKFIXFIREAT, 11}, + { CHAR_K_STRING_WIND, CHAR_WORKFIXWINDAT, 11}, + { CHAR_K_STRING_SLOT, CHAR_SLOT, 0 }, + { CHAR_K_STRING_NAME, CHAR_NAME, 2 }, + { CHAR_K_STRING_USERPETNAME, CHAR_USERPETNAME, 2 }, + + }; + /* 凝民尼永弁 */ + if( num < 0 || num >= CHAR_MAXPETHAVE ){ + print( "宠物模式失败 (%c)%d \n", num, num ); + return NULL; + } + /* 矢永玄及奶件犯永弁旦毛潸 */ + pindex = CHAR_getCharPet( charaindex, num ); + if( pindex == -1 ){ + /* 鬼支仃升 snprintf 允月 */ + snprintf(CHAR_K_statusSendBuffer,sizeof(CHAR_K_statusSendBuffer), + "K%d|0|", num ); + return CHAR_K_statusSendBuffer; + } + + snprintf( CHAR_K_statusSendBuffer, sizeof( CHAR_K_statusSendBuffer), + "K%d|%s|", num, cnv10to62( indextable, buf,sizeof(buf))); + strlength = strlen( CHAR_K_statusSendBuffer ); + + for( i = 1; i < sizeof( int) * 8; i ++ ){ + if( indextable & (1 << i) ) { + char tmp[256]; + BOOL found = FALSE; + for( j = 0; j < arraysizeof( chk); j ++ ) { + if( chk[j].kind == 1 << i ) { + if( chk[j].gettype == 0 ) { + ret = CHAR_getInt( pindex,chk[j].intdataindex); + snprintf( tmp, sizeof( tmp), "%d|", ret); + } + else if( chk[j].gettype == 1 ) { + ret = CHAR_getWorkInt( pindex,chk[j].intdataindex); + snprintf( tmp, sizeof( tmp), "%d|", ret); + } + else if( chk[j].gettype == 10 ) { + ret = CHAR_getInt( pindex, chk[j].intdataindex)/100; + snprintf( tmp, sizeof( tmp), "%d|", ret); + } + else if( chk[j].gettype == 11 ) { + ret = CHAR_getWorkInt( pindex, chk[j].intdataindex); + if( ret < 0) ret = 0; + snprintf( tmp, sizeof( tmp), "%d|", ret); + } + /* 侬 烟及犯□正 */ + else if( chk[j].gettype == 2 ) { + char escapebuffer[128]; + char *a = CHAR_getChar( pindex, chk[j].intdataindex); + + snprintf( tmp,sizeof( tmp ), + "%s|", + makeEscapeString( a, escapebuffer, + sizeof(escapebuffer) + )); + } + found = TRUE; + break; + } + } + if( !found) { + if( indextable & CHAR_K_STRING_NEXTEXP ) { + ret = CHAR_GetLevelExp( pindex, CHAR_getInt( pindex, CHAR_LV ) + 1 ); + snprintf( tmp, sizeof( tmp), "%d|", ret); + found = TRUE; + } + if( indextable & CHAR_K_STRING_CHANGENAMEFLG ) { + BOOL changenameflg = FALSE; + char *mycdkey, *cdkey = NULL; + mycdkey = CHAR_getChar( charaindex, CHAR_CDKEY); + { + cdkey = CHAR_getChar( pindex, CHAR_CDKEY); + if( cdkey == NULL ) { + print( "can't get CDKEY\n"); + }else { + if( strlen( cdkey) == 0 || + strcmp( cdkey, mycdkey) == 0 ){ + changenameflg = TRUE; + } + } + } + snprintf( tmp, sizeof( tmp), "%d|", changenameflg); + found = TRUE; + } + } + if( !found) { + print( "找不到指定的参数[%d]\n",indextable); + }else { + strcpysafe( &CHAR_K_statusSendBuffer[ strlength], + sizeof( CHAR_K_statusSendBuffer) - strlength, + tmp); + + strlength += strlen( tmp ); + if( strlength >= sizeof( CHAR_K_statusSendBuffer ) ) { + return CHAR_K_statusSendBuffer; + } + } + } + } + return CHAR_K_statusSendBuffer; +} +/*------------------------------------------------------------ + * S K 旦 □正旦毛霜月[民尼永弁允月及匹}晓匹反民尼永弁仄卅仁化方中[ + * 娄醒 + * charaindex int 平乓仿奶件犯弁永旦 + * indextable int P 毛霜月由仿丢□正及螂宁 [ + * 忒曰袄 + * 霜匀凶[TRUE(1) + * 霜木卅井匀凶[FALSE(0) + *------------------------------------------------------------*/ +BOOL CHAR_send_K_StatusString( int charaindex, int num, unsigned int indextable ) +{ + char* string; + + if( indextable >= (CHAR_K_STRING_USERPETNAME << 1)) { + print( "send_K invalid index[%d]\n", indextable); + return FALSE; + } + + if( CHAR_getInt(charaindex,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ){ + return FALSE; + } + string = CHAR_make_K_StatusString( charaindex, num, indextable ); + if( string != NULL ){ + int fd; + fd = getfdFromCharaIndex( charaindex ); + if( fd != -1 ){ + lssproto_S_send( fd, string ); + return TRUE; + } + } + return FALSE; +} + + + +//------------------------------------------------------------ +// 皿伊奶乩□及 毛笛遥 +//------------------------------------------------------------ +void CHAR_AddCharm( int charaindex, int iValue ) +{ + int iWork; + iWork = CHAR_getInt( charaindex, CHAR_CHARM ) + iValue; + iWork = max( 0, iWork ); // 凝ㄟ + iWork = min( 100, iWork ); // ㄠㄟㄟ + CHAR_setInt( charaindex, CHAR_CHARM, iWork ); +} + +//------------------------------------------------------------ +// 矢永玄及镝擦蘸 祭袄毛笛遥允月[ +//------------------------------------------------------------ +void CHAR_PetAddVariableAi( int petindex, int iValue ) +{ + int iWork; + iWork = CHAR_getInt( petindex, CHAR_VARIABLEAI ) + iValue; + iWork = min( CHAR_MAXVARIABLEAI, iWork ); + iWork = max( CHAR_MINVARIABLEAI, iWork ); + CHAR_setInt( petindex, CHAR_VARIABLEAI, iWork ); + +} + +//------------------------------------------------------------ +// 犯□正矛□旦卞瓒 允月平□ 蟆 毛综岳允月[ +//------------------------------------------------------------ +int CHAR_makeDBKey( int charaindex, char *pszBuffer, int size ){ + + char *cdkey; + char buff[512]; + char escapebuf[1024]; + + pszBuffer[0] = 0; // 赓渝祭 + cdkey = CHAR_getChar( charaindex, CHAR_CDKEY); + if( cdkey == NULL )return FALSE; // 瓒 匹五卅中 + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; + + // 平□反 cdkey_ 蟆 + snprintf( buff, sizeof(buff), + "%s_%s", cdkey, CHAR_getChar( charaindex, CHAR_NAME ) ); + makeEscapeString( buff, escapebuf, sizeof(escapebuf)); + strcpysafe( pszBuffer, size, escapebuf); + + return TRUE; +} + + +//------------------------------------------------------------ +// +// 犯□正矛□旦及嫩 毛凳蕙 +// +// DuelPoint 及 DBUpdateEntry毛霜月 +//------------------------------------------------------------ +BOOL CHAR_send_DpDBUpdate( int charaindex ) +{ + int fd,dp; + char szKey[256]; + if( CHAR_makeDBKey( charaindex, szKey, sizeof( szKey ) ) == FALSE ){ + return FALSE; + } + dp = CHAR_getInt( charaindex, CHAR_DUELPOINT ); + fd = getfdFromCharaIndex( charaindex); + if( fd != -1 ) { + char info[512]; + //char escapebuff[1024]; + /* "等级|几战|几胜|几败|几连胜|最高连胜数" */ + snprintf( info, sizeof( info), + "%d,%d,%d,%d,%d,%d", + CHAR_getInt( charaindex, CHAR_LV), + CHAR_getInt( charaindex, CHAR_DUELBATTLECOUNT), + CHAR_getInt( charaindex, CHAR_DUELWINCOUNT), + CHAR_getInt( charaindex, CHAR_DUELLOSECOUNT), + CHAR_getInt( charaindex, CHAR_DUELSTWINCOUNT), + CHAR_getInt( charaindex, CHAR_DUELMAXSTWINCOUNT)); + saacproto_DBUpdateEntryInt_send( + acfd, DB_DUELPOINT, szKey, max(dp,0), info, + CONNECT_getFdid( fd ) ,0 ); + } + + return TRUE; +} + +char *CHAR_getUseName( int charaindex ) +{ + char *pName=NULL; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + pName = CHAR_getChar( charaindex, CHAR_USERPETNAME ); + if( pName[0] == 0 ){ + pName = CHAR_getChar( charaindex, CHAR_NAME ); + } + }else{ +// if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ) +// pName = CHAR_getChar( charaindex, CHAR_OWNTITLE ); +// if( pName == NULL || strlen(pName) <= 0 ) + pName = CHAR_getChar( charaindex, CHAR_NAME ); + } + return pName; +} + +// Robin extend_of_CHAR_getUseName() 2001/02/15 +char *CHAR_getUseID( int charaindex ) +{ + char *pName; + // 矢永玄分匀凶日白伉□生□丞卞允月 + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + pName = "NO_USER"; + }else{ + pName = CHAR_getChar( charaindex, CHAR_CDKEY ); + } + return pName; +} + +BOOL CHAR_send_DpDBUpdate_AddressBook( int charaindex, int mode ) +{ + int fd; + char szKey[256]; + if( CHAR_makeDBKey( charaindex, szKey, sizeof( szKey ) ) == FALSE ){ + return FALSE; + } + + fd = getfdFromCharaIndex( charaindex); + if( fd != -1 ) { + char msgbuf[512]; + snprintf( msgbuf, sizeof( msgbuf), + "%d|%d|%d|%d|%d|", + (mode == 0 ) ? 0 : getServernumber(), + CHAR_getInt( charaindex, CHAR_LV), + CHAR_getInt( charaindex, CHAR_DUELPOINT), + CHAR_getInt( charaindex, CHAR_FACEIMAGENUMBER), + CHAR_getInt( charaindex, CHAR_TRANSMIGRATION) ); + + saacproto_DBUpdateEntryString_send( + acfd, DB_ADDRESSBOOK, szKey, msgbuf, CONNECT_getFdid( fd ),0 ); + + saacproto_Broadcast_send( acfd, CHAR_getChar( charaindex, CHAR_CDKEY), + CHAR_getChar( charaindex, CHAR_NAME), "param", 0); + + } + return TRUE; +} + +void CHAR_sendBattleWatch( int objindex, int onoff) +{ + int opt[1]; + opt[0] = onoff; + CHAR_sendWatchEvent( objindex,CHAR_ACTBATTLEWATCH,opt,1,TRUE); +} +/*------------------------------------------------------------ + * 隙烂今木凶 毛莫曰及谛卞矢永玄丢□伙及梢请毛允月[ + * 娄醒 + * charaindex int chara 匹及奶件犯弁永旦 + * 忒曰袄 + * 卅仄 + ------------------------------------------------------------*/ +void CHAR_sendPMEToArroundCharacterFLXY( int petindex, int fl, int x, int y, + int dir, int flg, int no ) +{ + int i,j; + int objindex; + int graphicsno; + char buff[2048]; + + objindex = CHAR_getWorkInt( petindex, CHAR_WORKOBJINDEX); + graphicsno = CHAR_getInt( petindex, CHAR_BASEIMAGENUMBER); + if( CHAR_makeObjectCString( objindex, buff, sizeof( buff)) == FALSE ) { + buff[0] = '\0'; + } + + for( i = x - CHAR_DEFAULTSEESIZ/2 ; + i <= x +CHAR_DEFAULTSEESIZ/2 ; i ++ ){ + for( j = y - CHAR_DEFAULTSEESIZ/2; + j <= y + CHAR_DEFAULTSEESIZ/2; j ++ ){ + + OBJECT object; + for( object = MAP_getTopObj( fl, i,j); + object; + object = NEXT_OBJECT(object) ){ + int objindexwk = GET_OBJINDEX( object); + if( OBJECT_getType(objindexwk) == OBJTYPE_CHARA ){ + int index = OBJECT_getIndex(objindexwk); + if( CHAR_getInt( index,CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + int fd; + if( CHAR_getWorkInt( index, CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) continue; + fd = getfdFromCharaIndex( index); + if( fd == -1 )continue; + lssproto_PME_send( fd, objindex, graphicsno, + x,y, dir,flg,no,buff + ); + } + } + } + } + } +} +/*------------------------------------------------------------ + * charaindex 匹隙烂今木凶 毛莫曰及谛卞矢永玄丢□伙及梢请毛允月[ + * 娄醒 + * charaindex int chara 匹及奶件犯弁永旦 + * 忒曰袄 + * 卅仄 + ------------------------------------------------------------*/ +void CHAR_sendPMEToArroundCharacter( int charaindex, int petindex, int flg, int no ) +{ + int dirx[9],diry[9]; + int i; + int fl,x,y; + int dir; + for( i = 0 ; i < 7 ; i ++ ){ + dirx[i+2] = CHAR_getDX(CHAR_getInt(charaindex,CHAR_DIR) + i+1); + diry[i+2] = CHAR_getDY(CHAR_getInt(charaindex,CHAR_DIR) + i+1); + } + dirx[0] = CHAR_getDX(CHAR_getInt(charaindex,CHAR_DIR)); + diry[0] = CHAR_getDY(CHAR_getInt(charaindex,CHAR_DIR)); + dirx[1] = 0; + diry[1] = 0; + + fl = CHAR_getInt( charaindex,CHAR_FLOOR ); + dir = CHAR_getInt( charaindex, CHAR_DIR); + + /* 仁 轾潸 */ + for( i = 0 ; i < 9 ; i ++ ){ + int x = CHAR_getInt( charaindex, CHAR_X) + dirx[i]; + int y = CHAR_getInt( charaindex, CHAR_Y) + diry[i]; + /* 矢永玄毛 仃月桦赭井譬屯月 */ + if( PET_isPutPoint( fl, x, y ) == TRUE ) { + break; + } + } + /* 卅仃木壬箫葭 */ + if( i == 9 ) i = 1; + + x = CHAR_getInt(charaindex,CHAR_X)+dirx[i]; + y = CHAR_getInt(charaindex,CHAR_Y)+diry[i]; + + CHAR_sendPMEToArroundCharacterFLXY( petindex, + fl, x, y, dir, flg, no); +} +/*------------------------------------------------------------ + * SE毛 日允[ + * 耨葭毛 艘卞]苇尹月 区坌霜耨允月 + * 娄醒 + * fl,x,y 耨葭及甄 + * senumber 及 寞[sndcnf.h毛辅寰及仇午[ + * sw 日允井鞅户月井 0 : 鞅户月 1 : 日允 + ------------------------------------------------------------*/ +void CHAR_sendSEoArroundCharacter( int fl, int x, int y, int senumber, int sw ) +{ + int i,j; + + for( i = x - CHAR_DEFAULTSEESIZ/2 ; + i <= x +CHAR_DEFAULTSEESIZ/2 ; i ++ ){ + for( j = y - CHAR_DEFAULTSEESIZ/2; + j <= y + CHAR_DEFAULTSEESIZ/2; j ++ ){ + + OBJECT object; + for( object = MAP_getTopObj( fl, i,j); + object; + object = NEXT_OBJECT(object) ){ + int objindexwk = GET_OBJINDEX( object); + if( OBJECT_getType(objindexwk) == OBJTYPE_CHARA ){ + int index = OBJECT_getIndex(objindexwk); + if( CHAR_getInt( index,CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + int fd; + if( CHAR_getWorkInt( index, CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) continue; + fd = getfdFromCharaIndex( index); + if( fd == -1 )continue; + lssproto_SE_send( fd,x, y, senumber, sw ); + } + } + } + } + } +} +/*====================梢请涩烂====================*/ + + +#ifndef _SEND_EFFECT // WON ADD AC送下雪、下雨等特效 + +#define CHAR_EFFECT_SETTINGBUFFER 256 +typedef struct tagCHAR_effectsetting +{ + int floor; // 白夫失 + int effect; // 梢请 寞 + int level; // 梢请及伊矛伙[ 蜇及雄今[ + int sendflg; // 憎巨白尼弁玄毛霜匀凶井升丹井[ + char month[CHAR_EFFECT_SETTINGBUFFER]; // 垫允月畸 + char day[CHAR_EFFECT_SETTINGBUFFER]; // 垫允月 + char hour[CHAR_EFFECT_SETTINGBUFFER]; // 垫允月凛棉 + char min[CHAR_EFFECT_SETTINGBUFFER]; // 垫允月坌 + char expire[CHAR_EFFECT_SETTINGBUFFER]; // 垫仄化中月赢今[( + +}CHAR_effectsetting; + +CHAR_effectsetting* CHAR_effect; +int CHAR_effectnum; + +#endif + + + +/*------------------------------------------------------------ + * 梢请涩烂及赓渝祭毛允月[ + * 娄醒 + * filename char* 涩烂白央奶伙 + * 忒曰袄 + * 岳 TRUE(1) + * 撩 FALSE(0) + *------------------------------------------------------------*/ +BOOL CHAR_initEffectSetting( char* filename ) +{ + FILE* f; + char line[256]; + int linenum=0; + + int effectreadlen=0; + + f = fopen(filename,"r"); + if( f == NULL ){ + errorprint; + return FALSE; + } + + CHAR_effectnum=0; + + /* 引内 躲卅垫互窒垫丐月井升丹井譬屯月 */ + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + + CHAR_effectnum++; + } + + if( fseek( f, 0, SEEK_SET ) == -1 ){ + fprint( "Seek Error\n" ); + fclose(f); + return FALSE; + } + + CHAR_effect = allocateMemory( sizeof(CHAR_effectsetting) + * CHAR_effectnum ); + if( CHAR_effect == NULL ){ + fprint( "Can't allocate Memory %d\n" , + sizeof(CHAR_effectsetting)*CHAR_effectnum); + fclose( f ); + return FALSE; + } + /* 赓渝祭 */ +{ + int i; + for( i = 0; i < CHAR_effectnum; i ++ ) { + CHAR_effect[i].floor = 0; + CHAR_effect[i].effect = 0; + CHAR_effect[i].level = 0; + CHAR_effect[i].sendflg = 0; + CHAR_effect[i].month[0] = '\0'; + CHAR_effect[i].day[0] = '\0'; + CHAR_effect[i].hour[0] = '\0'; + CHAR_effect[i].min[0] = '\0'; + CHAR_effect[i].expire[0] = '\0'; + + } +} + + /* 引凶 心 允 */ + linenum = 0; + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + + /* 垫毛帮溥允月 */ + /* 引内 tab 毛 " " 卞 五晶尹月 */ + replaceString( line, '\t' , ' ' ); + /* 粮仄凶 " " 毛夫午勾卞允月 */ + deleteSequentChar( line, " " ); + + /* 仇仇引匹帮溥仄化}燮 互 旦矢□旦分匀凶日 */ + /* 引卅中 */ + if( line[0] == ' ' )continue; + + { + char token[256]; + int ret; + + /* 夫午勾户及玄□弁件毛苇月 */ + ret = getStringFromIndexWithDelim( line," ",1,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("文件秩序错误:%s 第%d行\n",filename,linenum); + continue; + } + CHAR_effect[effectreadlen].floor = atoi(token); + + /* 2勾户及玄□弁件毛苇月 */ + ret = getStringFromIndexWithDelim( line," ",2,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("文件秩序错误:%s 第%d行\n",filename,linenum); + continue; + } + + CHAR_effect[effectreadlen].effect = atoi( token ); + + /* 3勾户及玄□弁件毛苇月 */ + ret = getStringFromIndexWithDelim( line," ",3,token, + sizeof(token)); + if( ret ==FALSE){ + fprint("文件秩序错误:%s 第%d行\n",filename,linenum); + continue; + } + + CHAR_effect[effectreadlen].level = atoi( token ); + + /* 4勾户及玄□弁件毛苇月 */ + ret = getStringFromIndexWithDelim( line," ",4,token, + sizeof(token)); + if( ret ==FALSE){ + fprint("文件秩序错误:%s 第%d行\n",filename,linenum); + continue; + } + strcpysafe( CHAR_effect[effectreadlen].month, + sizeof( CHAR_effect[effectreadlen].month), + token); + + /* 5勾户及玄□弁件毛苇月 */ + ret = getStringFromIndexWithDelim( line," ",5,token, + sizeof(token)); + if( ret ==FALSE){ + fprint("文件秩序错误:%s 第%d行\n",filename,linenum); + continue; + } + strcpysafe( CHAR_effect[effectreadlen].day, + sizeof( CHAR_effect[effectreadlen].day), + token); + + /* 6勾户及玄□弁件毛苇月 */ + ret = getStringFromIndexWithDelim( line," ",6,token, + sizeof(token)); + if( ret ==FALSE){ + fprint("文件秩序错误:%s 第%d行\n",filename,linenum); + continue; + } + strcpysafe( CHAR_effect[effectreadlen].hour, + sizeof( CHAR_effect[effectreadlen].hour), + token); + + /* 7勾户及玄□弁件毛苇月 */ + ret = getStringFromIndexWithDelim( line," ",7,token, + sizeof(token)); + if( ret ==FALSE){ + fprint("文件秩序错误:%s 第%d行\n",filename,linenum); + continue; + } + strcpysafe( CHAR_effect[effectreadlen].min, + sizeof( CHAR_effect[effectreadlen].min), + token); + + /* 8勾户及玄□弁件毛苇月 */ + ret = getStringFromIndexWithDelim( line," ",8,token, + sizeof(token)); + if( ret ==FALSE){ + fprint("文件秩序错误:%s 第%d行\n",filename,linenum); + continue; + } + strcpysafe( CHAR_effect[effectreadlen].expire, + sizeof( CHAR_effect[effectreadlen].expire), + token); + + effectreadlen ++; + } + } + fclose(f); + + CHAR_effectnum = effectreadlen; + + print( "有效设置总数 %d...", CHAR_effectnum ); +#ifdef DEBUG + + { + int i; + for( i=0; i tim && NowTime.tv_sec < tim+atoi(CHAR_effect[num].expire)) { + flg = TRUE; + break; + } + } + if( !flg ) break; + } + } + // 坌互隙烂 仄分匀凶日手丹OK + + returnflg = TRUE; + break; + } + return returnflg; +} +//------------------------------------------------------------------------- +// 平乓仿弁正□及匏 午凛棉毛葭卞] +// 巨白尼弁玄毛霜月 邰互丐木壬霜月 +//------------------------------------------------------------------------- +void CHAR_checkEffect( int charaindex) +{ + int i; + int fl = CHAR_getInt( charaindex, CHAR_FLOOR); + int fd = getfdFromCharaIndex( charaindex); + + // 巨白尼弁玄域绎壅允 + lssproto_EF_send( fd, 0, 0, ""); + CHAR_setWorkInt( charaindex, CHAR_WORKEFFECT, 0); + + for( i = 0; i < CHAR_effectnum; i ++){ + // 白夫失互域谯仄凶凛分仃 + if( CHAR_effect[i].floor == fl) { + // 椭瘀毛譬屯引允[ + if( CHAR_checkEffectTime( i)){ + // 巨白尼弁玄毛霜月 + lssproto_EF_send( fd, CHAR_effect[i].effect, CHAR_effect[i].level, ""); + if( CHAR_effect[i].level == 0 ) { + CHAR_setWorkInt( charaindex, CHAR_WORKEFFECT, + CHAR_getWorkInt( charaindex, CHAR_WORKEFFECT) & + ~CHAR_effect[i].effect); + } + else { + CHAR_setWorkInt( charaindex, CHAR_WORKEFFECT, + CHAR_getWorkInt( charaindex, CHAR_WORKEFFECT) | + CHAR_effect[i].effect); + } + } + } + } +} + +void CHAR_checkEffectLoop( void) +{ + int i,j; + int playernum = CHAR_getPlayerMaxNum(); + int player; + int efnum = 0; + + struct { + int floor; + int effect; + BOOL on; + BOOL off; + } ef[2048]; + + memset( &ef, 0, sizeof( ef)); + + for( i = 0; i < CHAR_effectnum; i ++){ + + if( CHAR_checkEffectTime( i)){ + if( !CHAR_effect[i].sendflg) { + + for( player = 0 ; player < playernum; player ++ ) { + if( CHAR_getInt( player, CHAR_FLOOR) == CHAR_effect[i].floor ) { + int fd = getfdFromCharaIndex( player); + lssproto_EF_send( fd, CHAR_effect[i].effect, CHAR_effect[i].level, ""); + if( CHAR_effect[i].level == 0 ) { + CHAR_setWorkInt( player, CHAR_WORKEFFECT, + CHAR_getWorkInt( player, CHAR_WORKEFFECT) & + ~CHAR_effect[i].effect); + } + else { + CHAR_setWorkInt( player, CHAR_WORKEFFECT, + CHAR_getWorkInt( player, CHAR_WORKEFFECT) | + CHAR_effect[i].effect); + } + } + } + CHAR_effect[i].sendflg = TRUE; + + } + + for( j = 0; j < efnum; j ++ ) { + if( ef[j].floor == CHAR_effect[i].floor && + ef[j].effect == CHAR_effect[i].effect) + { + ef[j].on = TRUE; + break; + } + } + if( j == efnum ) { + ef[j].floor = CHAR_effect[i].floor; + ef[j].effect = CHAR_effect[i].effect; + ef[j].on = TRUE; + efnum++; + if( efnum >= arraysizeof( ef)) { + print( "err buffer over %s:%d\n", __FILE__, __LINE__); + efnum --; + } + } + } + else { + if( CHAR_effect[i].sendflg) { + + for( j = 0; j < efnum; j ++ ) { + if( ef[j].floor == CHAR_effect[i].floor && + ef[j].effect == CHAR_effect[i].effect) + { + ef[j].off = TRUE; + break; + } + } + if( j == efnum ) { + ef[j].floor = CHAR_effect[i].floor; + ef[j].effect = CHAR_effect[i].effect; + ef[j].off = TRUE; + efnum++; + if( efnum >= arraysizeof( ef)) { + print( "err buffer over %s:%d\n", __FILE__, __LINE__); + efnum --; + } + } + CHAR_effect[i].sendflg = FALSE; + } + } + } + + for( i = 0; i < efnum; i ++ ) { + if( ef[i].on == FALSE && ef[i].off == TRUE ) { + + for( player = 0 ; player < playernum; player ++ ) { + if( CHAR_getInt( player, CHAR_FLOOR) == ef[i].floor ) { + int fd = getfdFromCharaIndex( player); + lssproto_EF_send( fd, 0, 0, ""); + CHAR_setWorkInt( player, CHAR_WORKEFFECT, 0); + } + } + } + } +} + +float GetRecoveryRate( int charaindex ){ + float fBai = 1.0; + + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + fBai = 1.0 + 0.00010 * CHAR_getInt( charaindex, CHAR_VITAL ); + }else{ + + fBai = 1.0 + 0.00005 * CHAR_getInt( charaindex, CHAR_VITAL ); + } + return fBai; + +} + + +#define CHARDATASIZE (1024*256) +#define SPACESTRING "|" + +static int makeSaveCharString( char *out , int outlen , + char *nm , char *opt , char *info ) +{ + char nmwork[256]; + char optwork[512]; + char infowork[CHARDATASIZE]; + char outwork[CHARDATASIZE]; + char *nmwork_p , *optwork_p , *infowork_p; + int l; + + strncpy( nmwork , nm , sizeof( nmwork )); + nmwork[strlen( nm)]=0; + + strncpy( optwork , opt , sizeof( optwork )); + optwork[strlen(opt)]=0; + + strncpy( infowork , info , sizeof( infowork )); + infowork[strlen(info)]=0; + + nmwork_p = makeEscapeString( nm , nmwork ,sizeof( nmwork )); + optwork_p = makeEscapeString( opt , optwork , sizeof( optwork )); + infowork_p = makeEscapeString( info , infowork , sizeof( infowork )); + + snprintf( outwork ,sizeof( outwork ) , + "%s" SPACESTRING "%s" SPACESTRING "%s" , + nmwork_p , optwork_p , infowork_p ); + + l = strlen( outwork ); + outwork[ strlen( outwork)+1] = 0; + if( l >= (outlen-1)){ + return -1; + } + + memcpy( out , outwork , l + 1 ); + + return 0; +} + +#ifdef _STORECHAR +int storeCharaData( void ){ + int i, charamax; + FILE *fp; + struct tm *pLtime; + char szFileName[256], *chardata; + char outbuff[CHARDATASIZE]; + Char* ch; + + print("\n保存运行中的数据\n"); + + pLtime = localtime( &NowTime.tv_sec ); + + charamax = getFdnum(); + + for( i = 0; i < charamax; i ++ ){ + int hash, dir, j; + char charId[32]; + char pathname[128]; + + if( CHAR_getCharUse( i ) == FALSE )continue; + + strcpy( charId, CHAR_getChar( i, CHAR_CDKEY ) ); + print(" 档案号:%s", charId); + + hash = 0; + for( j=0; jtm_year+1900, + pLtime->tm_mon+1, + pLtime->tm_mday, + pLtime->tm_hour, + pLtime->tm_min + ); + + fp = fopen( szFileName, "w" ); + if( fp == NULL )continue; + + ch = CHAR_getCharPointer( i ); + if( !ch )continue; + + chardata = CHAR_makeStringFromCharData( ch ); + + if( makeSaveCharString( outbuff , sizeof( outbuff ), + CHAR_getChar( i, CHAR_NAME ), + CHAR_makeOptionString( ch ), + chardata ) == 0 + ){ + + fprintf( fp, outbuff ); + }else{ + fprintf( fp, "本□皮撩 \n" ); + } + + fclose( fp ); + } + return 0; +} + +#endif + +#ifdef _LASTERR_FUNCTION +DebugBreakPoint LastFunction[10]; +static int lastfunctionNum = 0; +void LastFunction_Init() +{ + int i; + for( i=0; i<10; i++) { + memset( LastFunction[i].FILE, 0, sizeof( char)*256); + memset( LastFunction[i].funName, 0, sizeof( char)*256); + LastFunction[i].line = -1; + } +} +void LastFunction_Add( char *file, int line, char *funName) +{ + lastfunctionNum ++; + if( lastfunctionNum >= 10 ) + lastfunctionNum = 0; + + strcpy( LastFunction[ lastfunctionNum].FILE, file); + LastFunction[ lastfunctionNum].line = line; + strcpy( LastFunction[ lastfunctionNum].funName, funName); +} + +int LastFunction_Get( int lasts, char *file, int *line, char *funName) +{ + if( lasts < 0 || lasts >= 10 ) + return -1; + strcpy( file, LastFunction[ lasts].FILE); + *line = LastFunction[ lasts].line = line; + strcpy( funName, LastFunction[ lasts].funName); + return lastfunctionNum; +} +#endif + + + +#ifdef _FIX_METAMORIDE +BOOL CHAR_CHECKJOINENEMY( int index) +{ + int masterindex=-1; + if( CHAR_getWorkInt( index, CHAR_WORKPARTYMODE) == CHAR_PARTY_CLIENT ) { + masterindex = CHAR_getWorkInt( index, CHAR_WORKPARTYINDEX1); + if( !CHAR_CHECKINDEX( masterindex) ) { + print( "err masterindex:%d %s:%d !!\n", masterindex,__FILE__, __LINE__); + return FALSE; + } + if( CHAR_getInt( masterindex, CHAR_WHICHTYPE) == CHAR_TYPEBUS) { + return TRUE; //JOIN ENEMY + } + } + + return FALSE; +} +#endif + + // WON ADD 修正道具的设定问题 +void fix_item_bug(int charaindex, int itemindex) +{ + + if (ITEM_CHECKINDEX(itemindex)){ + switch( ITEM_getInt(itemindex,ITEM_ID) ){ + case 19700: ITEM_setChar( itemindex, ITEM_ARGUMENT, "KPET:901_902_903_904"); break; // 鞭炮 + case 20242: ITEM_setChar( itemindex, ITEM_ARGUMENT, "KPET:957_958_959_960"); break; // 雄黄酒 + case 1292: ITEM_setInt( itemindex, ITEM_MAXDAMAGECRUSHE, 0); ITEM_setInt( itemindex, ITEM_DAMAGECRUSHE, 0); break; // 灵力铠 + case 19646: ITEM_setInt( itemindex, ITEM_MAXDAMAGECRUSHE, 0); ITEM_setInt( itemindex, ITEM_DAMAGECRUSHE, 0); break; // 灵力铠 + case 1478: ITEM_setChar( itemindex, ITEM_ARGUMENT, "HP:30"); break; // 洛克服 + case 20282: ITEM_setChar( itemindex, ITEM_EFFECTSTRING, "攻+25 伤+25 敏-4 魅+5"); ITEM_setInt( itemindex, ITEM_MODIFYQUICK, -4 ); break; // 铁枪1 + case 20283: ITEM_setChar( itemindex, ITEM_EFFECTSTRING, "攻+50 伤+50 敏-10 魅+10"); ITEM_setInt( itemindex, ITEM_MODIFYQUICK, -10 ); break; // 铁枪2 + case 20284: ITEM_setChar( itemindex, ITEM_EFFECTSTRING, "攻+100 伤+100 敏-20 魅+15"); ITEM_setInt( itemindex, ITEM_MODIFYQUICK, -20 ); break; // 铁枪3 + case 1210: ITEM_setChar( itemindex, ITEM_EFFECTSTRING, "攻 +4 防 -4 敏 +4 魅 +2"); break; // 碧玉的石手环 + case 1203: ITEM_setChar( itemindex, ITEM_EFFECTSTRING, "攻 +2 防 +2 敏 -2 魅 +1"); break; // 皮的手环(红) + case 1204: ITEM_setChar( itemindex, ITEM_EFFECTSTRING, "攻 -2 防 +2 敏 +2 魅 +1"); break; // 皮的手环(绿) + case 1205: ITEM_setChar( itemindex, ITEM_EFFECTSTRING, "攻 +2 防 -2 敏 +2 魅 +1"); break; // 皮的手环(青) + case 1483: ITEM_setInt( itemindex, ITEM_MODIFYCHARM, 5); break; // 库沙达号角 + case 20147: ITEM_setChar(itemindex,ITEM_INGNAME0,"木"); ITEM_setChar(itemindex,ITEM_INGNAME1,"骨"); ITEM_setInt(itemindex,ITEM_INGVALUE0, 1125 ); ITEM_setInt(itemindex,ITEM_INGVALUE1, 1125 ); break; // 双头叉 + default: + break; + } + } +} + + +#ifdef _NPCSERVER_NEW +BOOL NPCSERVER_CreateObjindexFromServer( int fd, int npcindex, char *Name, int image, + int dir, int floor, int x, int y) +{ + int objindex; + Object obj; + + obj.type = OBJTYPE_NPCSCHARA; + obj.index= -1; + memset( obj.objname, 0, sizeof( obj.objname)); + memcpy( obj.objname, Name, strlen( Name)+1); + obj.npcsindex = npcindex; + obj.imagenum = image; + obj.dir = dir; + obj.x = x; + obj.y = y; + obj.floor = floor; + objindex = initObjectOne( &obj ); + if( objindex == -1 ){ + return FALSE; + } + + return TRUE; +} +#endif + +#ifdef _PET_LOSTPET +BOOL CHAR_CharSaveLostPet( int petindex, int type)//地上0 溜宠 1 宠邮 2 +{ + int lv, cost=0; + char* CdKey=NULL; + char* Uniquecode; + char* petname; + + char lostpetstring[1024*2]; + char *petstring; + + if( !CHAR_CHECKINDEX( petindex) ) return FALSE; +//存入 + petstring = CHAR_makePetStringFromPetIndex( petindex); + if( petstring == NULL ) return FALSE; + CdKey = CHAR_getChar( petindex, CHAR_OWNERCDKEY); + if( CdKey == NULL ) return FALSE; + Uniquecode = CHAR_getChar( petindex, CHAR_UNIQUECODE); + if( Uniquecode == NULL ) return FALSE; + lv = CHAR_getInt( petindex, CHAR_LV); + petname = CHAR_getChar( petindex, CHAR_NAME); + + if( type == 1 ){ + cost = lv*300; + }else if( type == 2){ + cost = lv*1000; + }else{ + cost = lv*10000; + } + + sprintf( lostpetstring, "%s|%s|%d|%d|%s|%d#%s#%d", + CdKey, petname, lv, cost, Uniquecode, (int)time( NULL), petstring, + type); + + print("保存最后宠物:%s-%d\n", lostpetstring, strlen(lostpetstring)); + { + char buf[10][2048]={"","","","","","","","","",""}; + char line[2048]; + int count=0, i, start=0; + FILE *fp=NULL; + char filename[256]; + +/* + sprintf( filename, "lostpet/%s.txt", CdKey); + if( (fp=fopen( filename, "a+")) != NULL ){ + fprintf( fp, "%s\n", petstring); + fclose( fp); + }else{ + print("Can't Add %s \n", filename); + } + +*/ + + + sprintf( filename, "lostpet/%s.txt", CdKey); + if( (fp=fopen( filename, "r")) != NULL ){ + while( fgets( line , sizeof( line ) , fp ) && count < 7){ + if( strlen(line) <= 0 ) continue; + strcpy( buf[ count++] , line); + } + fclose( fp); + }else{ + print("Can't Read %s \n", filename); + } + + if( (fp=fopen( filename, "w+")) == NULL ){ + print("Can't Write %s \n", filename); + return FALSE; + } + if( strlen( buf[ 6]) > 0 ){ + start=2; + } + for( i=start; i<7; i++){ + if( strlen( buf[i]) > 0 ) { + print("Write %s \n", buf[i]); + fprintf( fp, "%s", buf[i]); + } + } + fprintf( fp, "%s\n", lostpetstring); + + fclose( fp); + } + return TRUE; +} +/* +while( fgets( line , sizeof( line ) , fp ) && count < 7){ +*/ +#endif + +#ifdef _ALLDOMAN +void InitHeroList( void) +{ + saacproto_UpdataStele_send ( acfd , "FirstLoad", "LoadHerolist" , "华义" , 0 , 0 , 0 , 999 ) ; +} +#endif + +#ifdef _STREET_VENDOR +void CHAR_sendStreetVendor(int charaindex,char *message) +{ + char szAction[2],szTemp[21],szMessage[4]; + int count = 0,i,j,iItemIndex = 0,iPetIndex = 0,iPileNum = 0,iMaxPileNum = 0; + int ix,iy,iPlayerNum = 0,tofd = -1,objbuf[16]; + + if(!getStringFromIndexWithDelim(message,"|",1,szAction,sizeof(szAction))) return; + // 开启摆摊介面 + if(szAction[0] == 'O'){ + CHAR_getCoordinationDir(CHAR_getInt(charaindex,CHAR_DIR),CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y),1,&ix,&iy); + // 取得前方玩家数量 + iPlayerNum = CHAR_getSameCoordinateObjects(objbuf,arraysizeof(objbuf),CHAR_getInt(charaindex,CHAR_FLOOR),ix,iy); + // 没有人 + if(iPlayerNum == 0){ + // 检查自己站的座标有没有人也在摆摊 + iPlayerNum = CHAR_getSameCoordinateObjects(objbuf,arraysizeof(objbuf), + CHAR_getInt(charaindex,CHAR_FLOOR), + CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y)); + // 不只自己一个人 + if(iPlayerNum > 1){ + // 检查别人有没有摆摊 + for(i=0;i 0){ + if(CHAR_getWorkInt(charaindex,CHAR_WORKSTREETVENDOR) == 1){ + // 修改内容中设成未摆摊 + CHAR_setWorkInt(charaindex,CHAR_WORKSTREETVENDOR,-1); + CHAR_sendStreetVendorDataToCli(charaindex,charaindex); + } + // 已在交易中但要改内容,关闭对方视窗 + else if(CHAR_getWorkInt(charaindex,CHAR_WORKSTREETVENDOR) == 2){ + int toindex = CHAR_getWorkInt(charaindex,CHAR_WORKSTREETVENDOR_WHO); + + if(toindex != -1 && CHAR_CHECKINDEX(toindex)){ + CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR,-1); + CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR_WHO,-1); + lssproto_STREET_VENDOR_send(getfdFromCharaIndex(toindex),"C|"); + CHAR_talkToCli(toindex,-1,"店家取消交易",CHAR_COLORYELLOW); + CHAR_setWorkInt(charaindex,CHAR_WORKSTREETVENDOR_WHO,-1); + // 清除交易图示 + CHAR_sendTradeEffect(charaindex,0); + CHAR_sendTradeEffect(toindex,0); + } + // 修改内容中,设成未摆摊 + CHAR_setWorkInt(charaindex,CHAR_WORKSTREETVENDOR,-1); + CHAR_sendStreetVendorDataToCli(charaindex,charaindex); + } + return; + } + // 检查对方是否卖完 + for(j=0;j 0){ + if(CHAR_getWorkInt(charaindex,CHAR_WORKSTREETVENDOR) == 1){ + // 修改内容中设成未摆摊 + CHAR_setWorkInt(charaindex,CHAR_WORKSTREETVENDOR,-1); + CHAR_sendStreetVendorDataToCli(charaindex,charaindex); + } + // 已在交易中但要改内容,关闭对方视窗 + else if(CHAR_getWorkInt(charaindex,CHAR_WORKSTREETVENDOR) == 2){ + int toindex = CHAR_getWorkInt(charaindex,CHAR_WORKSTREETVENDOR_WHO); + + if(toindex != -1 && CHAR_CHECKINDEX(toindex)){ + CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR,-1); + CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR_WHO,-1); + lssproto_STREET_VENDOR_send(getfdFromCharaIndex(toindex),"C|"); + CHAR_talkToCli(toindex,-1,"店家取消交易",CHAR_COLORYELLOW); + CHAR_setWorkInt(charaindex,CHAR_WORKSTREETVENDOR_WHO,-1); + // 清除交易图示 + CHAR_sendTradeEffect(charaindex,0); + CHAR_sendTradeEffect(toindex,0); + } + // 修改内容中,设成未摆摊 + CHAR_setWorkInt(charaindex,CHAR_WORKSTREETVENDOR,-1); + CHAR_sendStreetVendorDataToCli(charaindex,charaindex); + } + } + // 设定成摆摊 + else{ + sprintf(szMessage,"O|"); + lssproto_STREET_VENDOR_send(getfdFromCharaIndex(charaindex),szMessage); + } + return; + } + } + } + } + // 摆摊 + else if(szAction[0] == 'S'){ + int price; + + // 清除所有旧资料 + for(i=0;i 10000000) price = 10000000; + CHAR_setStreetVendor(charaindex,i,SV_PRICE,price); + } + if(!getStringFromIndexWithDelim(message,"|",6+(i-1)*3,szTemp,sizeof(szTemp))) return; + + // 检查cli端送来的资料 + for(i=0;i CHAR_getMaxHaveGold(toindex)){ + // 身上不够放,存入个人银行 + if(CHAR_getInt(toindex,CHAR_BANKGOLD) + iPrice > CHAR_MAXBANKGOLDHAVE){ + CHAR_talkToCli(charaindex,-1,"店家放不下石币了,交易取消。",CHAR_COLORRED); + CHAR_talkToCli(toindex,-1,"你身上及个人银行存款已满",CHAR_COLORRED); + break; + } + CHAR_talkToCli(toindex,-1,"贩卖所得已存入个人银行",CHAR_COLORRED); + bPutToBank = TRUE; + } + // 若是道具 + if(iKind == 0){ + iItemIndex = CHAR_getItemIndex(toindex,iFieldIndex); + // 道具不存在 + if(!ITEM_CHECKINDEX(iItemIndex)){ + CHAR_clearStreetVendor(toindex,iBuyIndex); + printf("\nCHAR_sendStreetVendor(B):找不到道具!!!!!!!\n"); + continue; + } + // 丢在地上会消失的道具不可贩卖 + if(ITEM_getInt(iItemIndex,ITEM_VANISHATDROP) == 1){ + CHAR_clearStreetVendor(toindex,iBuyIndex); + CHAR_talkToCli(charaindex,-1,"丢在地上会消失的道具不可贩卖,该选项取消",CHAR_COLORYELLOW); + CHAR_talkToCli(toindex,-1,"侦测到有丢在地上会消失的道具在贩卖,帐号已记录!",CHAR_COLORRED); + LogStreetVendor( + CHAR_getUseName(toindex), + CHAR_getUseID(toindex), + "", + "", + ITEM_getChar(iItemIndex,ITEM_NAME), + -1, + iPrice, + "StreetVendor(卖方改封包)", + CHAR_getInt(toindex,CHAR_FLOOR), + CHAR_getInt(toindex,CHAR_X), + CHAR_getInt(toindex,CHAR_Y), + -1,-1,-1, + ITEM_getChar(iItemIndex,ITEM_UNIQUECODE) + ); + continue; + } + // 议价物品不能卖 + if(iPrice == 0){ + LogStreetVendor( + CHAR_getUseName(toindex), + CHAR_getUseID(toindex), + CHAR_getUseName(charaindex), + CHAR_getUseID(charaindex), + ITEM_getChar(iItemIndex,ITEM_NAME), + -1, + iPrice, + "StreetVendor(买方改封包)", + CHAR_getInt(toindex,CHAR_FLOOR), + CHAR_getInt(toindex,CHAR_X), + CHAR_getInt(toindex,CHAR_Y), + CHAR_getInt(charaindex,CHAR_FLOOR), + CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y), + ITEM_getChar(iItemIndex,ITEM_UNIQUECODE) + ); + continue; + } + // 检查物品堆叠 + iPileNum = ITEM_getInt(iItemIndex,ITEM_USEPILENUMS); + // 买方最大堆叠数 + iMaxPileNum = CHAR_getMyMaxPilenum(charaindex); + // 若物品的堆叠数比身上的最大堆叠数少,把卖方的物品清掉,把物品新增至买方 + if(iPileNum - iMaxPileNum <= 0){ + if(!ITEM_CHECKINDEX(iItemIndex)){ + CHAR_talkToCli(charaindex,-1,"交易失败(1)。",CHAR_COLORRED); + break; + } +#ifdef _ITEM_PILENUMS + // 道具数量为0 + if(ITEM_getInt(iItemIndex,ITEM_USEPILENUMS) <= 0){ + CHAR_talkToCli(charaindex,-1,"交易失败(2)。",CHAR_COLORRED); + break; + } +#endif + // 新增买方的 + if((iRet = CHAR_addItemSpecificItemIndex(charaindex,iItemIndex)) >= CHAR_MAXITEMHAVE){ + CHAR_talkToCli(charaindex,-1,"道具栏满了。",CHAR_COLORRED); + break; + } + CHAR_sendItemDataOne(charaindex,iRet); + // 清掉卖方的 + CHAR_setItemIndex(toindex,iFieldIndex,-1); + CHAR_sendItemDataOne(toindex,iFieldIndex); + CHAR_clearStreetVendor(toindex,iBuyIndex); + // 扣钱 + CHAR_setInt(charaindex,CHAR_GOLD,CHAR_getInt(charaindex,CHAR_GOLD) - iPrice); + CHAR_send_P_StatusString(charaindex,CHAR_P_STRING_GOLD); + // 加钱 + if(bPutToBank) CHAR_setInt(toindex,CHAR_BANKGOLD,CHAR_getInt(toindex,CHAR_BANKGOLD) + iPrice); + else CHAR_setInt(toindex,CHAR_GOLD,CHAR_getInt(toindex,CHAR_GOLD) + iPrice); + CHAR_send_P_StatusString(toindex,CHAR_P_STRING_GOLD); + sprintf(szMsg,"道具 %s 交易完成",ITEM_getChar(iItemIndex,ITEM_NAME)); + CHAR_talkToCli(charaindex,-1,szMsg,CHAR_COLORWHITE); + sprintf(szMsg,"%s 买走了道具 %s",CHAR_getUseName(charaindex),ITEM_getChar(iItemIndex,ITEM_NAME)); + CHAR_talkToCli(toindex,-1,szMsg,CHAR_COLORWHITE); + LogStreetVendor( + CHAR_getUseName(toindex), + CHAR_getUseID(toindex), + CHAR_getUseName(charaindex), + CHAR_getUseID(charaindex), + ITEM_getChar(iItemIndex,ITEM_NAME), + -1, + iPrice, + "StreetVendor(道具)", + CHAR_getInt(toindex,CHAR_FLOOR), + CHAR_getInt(toindex,CHAR_X), + CHAR_getInt(toindex,CHAR_Y), + CHAR_getInt(charaindex,CHAR_FLOOR), + CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y), + ITEM_getChar(iItemIndex,ITEM_UNIQUECODE) + ); + } + else CHAR_talkToCli(charaindex,-1,"身上堆叠数上限不足。",CHAR_COLORRED); + } + // 若是宠物 + else if(iKind == 1){ + int iEmptyPetField; + + iPetIndex = CHAR_getCharPet(toindex,iFieldIndex); + // 宠物不存在 + if(!CHAR_CHECKINDEX(iPetIndex)){ + CHAR_clearStreetVendor(toindex,iBuyIndex); + printf("\nCHAR_sendStreetVendor(B):找不到宠物!!!!!!!\n"); + continue; + } + if(CHAR_getInt(iPetIndex,CHAR_PETFAMILY) == 1){ + CHAR_talkToCli(charaindex,-1,"家族守护兽无法贩卖,该选项取消",CHAR_COLORYELLOW); + CHAR_clearStreetVendor(toindex,iBuyIndex); + LogStreetVendor( + CHAR_getUseName(toindex), + CHAR_getUseID(toindex), + "", + "", + CHAR_getChar(iPetIndex,CHAR_NAME), + -1, + iPrice, + "StreetVendor(卖方改封包)", + CHAR_getInt(toindex,CHAR_FLOOR), + CHAR_getInt(toindex,CHAR_X), + CHAR_getInt(toindex,CHAR_Y), + -1,-1,-1, + CHAR_getChar(iPetIndex,CHAR_UNIQUECODE) + ); + continue; + } + if(CHAR_getInt(toindex,CHAR_RIDEPET) == CHAR_getStreetVendor(toindex,iBuyIndex,SV_INDEX)){ + CHAR_talkToCli(charaindex,-1,"骑乘中的宠物无法贩卖,该选项取消",CHAR_COLORYELLOW); + CHAR_clearStreetVendor(toindex,iBuyIndex); + LogStreetVendor( + CHAR_getUseName(toindex), + CHAR_getUseID(toindex), + "", + "", + CHAR_getChar(iPetIndex,CHAR_NAME), + -1, + iPrice, + "StreetVendor(卖方改封包)", + CHAR_getInt(toindex,CHAR_FLOOR), + CHAR_getInt(toindex,CHAR_X), + CHAR_getInt(toindex,CHAR_Y), + -1,-1,-1, + CHAR_getChar(iPetIndex,CHAR_UNIQUECODE) + ); + continue; + } + + // 议价物品不能卖 + if(iPrice == 0){ + LogStreetVendor( + CHAR_getUseName(toindex), + CHAR_getUseID(toindex), + CHAR_getUseName(charaindex), + CHAR_getUseID(charaindex), + CHAR_getChar(iPetIndex,CHAR_NAME), + -1, + iPrice, + "StreetVendor(买方改封包)", + CHAR_getInt(toindex,CHAR_FLOOR), + CHAR_getInt(toindex,CHAR_X), + CHAR_getInt(toindex,CHAR_Y), + CHAR_getInt(charaindex,CHAR_FLOOR), + CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y), + CHAR_getChar(iPetIndex,CHAR_UNIQUECODE) + ); + continue; + } + // 检查玩家有无装备驯兽戒指,检查玩家有没有转生过 + if(CHAR_getWorkInt(charaindex,CHAR_PickAllPet) == FALSE && CHAR_getInt(charaindex,CHAR_TRANSMIGRATION) < 1){ + // 检查玩家等级有没有比宠物高 + if(CHAR_getInt(iPetIndex,CHAR_LV) > (CHAR_getInt(charaindex,CHAR_LV) + 5)){ + CHAR_talkToCli(charaindex,-1,"你无法照顾该宠物。",CHAR_COLORRED); + continue; + } + } + // 以下是宠物交换 + iEmptyPetField = CHAR_getCharPetElement(charaindex); + // 身上有空栏位 + if(iEmptyPetField > -1){ + // 清卖方 + CHAR_setCharPet(toindex,iFieldIndex,-1); + CHAR_clearStreetVendor(toindex,iBuyIndex); + sprintf(szMsg,"K%d",iFieldIndex); + CHAR_sendStatusString(toindex,szMsg); + // 设定买方 + CHAR_setCharPet(charaindex,iEmptyPetField,iPetIndex); + CHAR_setWorkInt(iPetIndex,CHAR_WORKPLAYERINDEX,charaindex); + CHAR_setChar(iPetIndex,CHAR_OWNERCDKEY,CHAR_getChar(charaindex,CHAR_CDKEY)); + CHAR_setChar(iPetIndex,CHAR_OWNERCHARANAME,CHAR_getChar(charaindex,CHAR_NAME)); + CHAR_complianceParameter(iPetIndex); + sprintf(szMsg,"K%d",iEmptyPetField); + CHAR_sendStatusString(charaindex,szMsg); + sprintf(szMsg,"W%d",iEmptyPetField); + CHAR_sendStatusString(charaindex,szMsg); + // 扣钱 + CHAR_setInt(charaindex,CHAR_GOLD,CHAR_getInt(charaindex,CHAR_GOLD) - iPrice); + CHAR_send_P_StatusString(charaindex,CHAR_P_STRING_GOLD); + // 加钱 + if(bPutToBank) CHAR_setInt(toindex,CHAR_BANKGOLD,CHAR_getInt(toindex,CHAR_BANKGOLD) + iPrice); + else CHAR_setInt(toindex,CHAR_GOLD,CHAR_getInt(toindex,CHAR_GOLD) + iPrice); + CHAR_send_P_StatusString(toindex,CHAR_P_STRING_GOLD); + sprintf(szMsg,"%s 买走了宠物 %s",CHAR_getUseName(charaindex),CHAR_getChar(iPetIndex,CHAR_NAME)); + CHAR_talkToCli(charaindex,-1,szMsg,CHAR_COLORWHITE); + sprintf(szMsg,"宠物 %s 交易完成!",CHAR_getChar(iPetIndex,CHAR_NAME)); + CHAR_talkToCli(toindex,-1,szMsg,CHAR_COLORWHITE); + LogStreetVendor( + CHAR_getUseName(toindex), + CHAR_getUseID(toindex), + CHAR_getUseName(charaindex), + CHAR_getUseID(charaindex), + CHAR_getChar(iPetIndex,CHAR_NAME), + CHAR_getInt(iPetIndex,CHAR_LV), + iPrice, + "StreetVendor(宠物)", + CHAR_getInt(toindex,CHAR_FLOOR), + CHAR_getInt(toindex,CHAR_X), + CHAR_getInt(toindex,CHAR_Y), + CHAR_getInt(charaindex,CHAR_FLOOR), + CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y), + CHAR_getChar(iPetIndex,CHAR_UNIQUECODE) + ); + } + // 玩家宠物栏位满了 + else CHAR_talkToCli(charaindex,-1,"身上宠物栏栏位不足!",CHAR_COLORRED); + } + // 错的内容 + else{ + CHAR_clearStreetVendor(toindex,iBuyIndex); + printf("\nCHAR_sendStreetVendor(B):错的内容!!!!!!!\n"); + } + } + // 卖方设定为摆摊,清除买方状态 + CHAR_setWorkInt(charaindex,CHAR_WORKSTREETVENDOR,-1); + CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR,1); + // 清除交易图示 + CHAR_sendTradeEffect(charaindex,0); + CHAR_sendTradeEffect(toindex,0); + CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR_WHO,-1); + CHAR_setWorkInt(charaindex,CHAR_WORKSTREETVENDOR_WHO,-1); + } + else printf("StreetVendor交易找不到对方(%s)\n",CHAR_getChar(charaindex,CHAR_NAME)); + } +} + +void CHAR_sendStreetVendorDataToCli(int charaindex,int toindex) +{ + int i,count = 0; + + // 送贩卖内容给玩家自己,要修改贩卖内容 + if(charaindex == toindex){ + char szMsg[512],szTemp[512],szTemp1[16]; + + memset(szTemp,0,sizeof(szTemp)); + for(i=0;i=48){ + for(j=0;j 0 && strlen(CHAR_getChar(charaindex,CHAR_TEACHER_NAME)) > 0) bHasTeacher = TRUE; + // 检查正前方有没有人 + CHAR_getCoordinationDir(CHAR_getInt(charaindex,CHAR_DIR),CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y),1,&ix,&iy); + // 取得前方玩家数量 + iPlayerNum = CHAR_getSameCoordinateObjects(objbuf,arraysizeof(objbuf),CHAR_getInt(charaindex,CHAR_FLOOR),ix,iy); + // 没有人 + if(iPlayerNum == 0){ + // 已有导师,显示导师资料 + if(bHasTeacher){ + // 向 ac 要资料 + saacproto_ACCheckCharacterOnLine_send(acfd,charaindex,CHAR_getChar(charaindex,CHAR_TEACHER_ID), + CHAR_getChar(charaindex,CHAR_TEACHER_NAME), + R_F_TEACHER_SYSTEM); + } + // 没有导师,显示说明 + else lssproto_TEACHER_SYSTEM_send(getfdFromCharaIndex(charaindex),"M|"); + } + // 有人 + else{ + // 已有导师 + if(bHasTeacher){ + // 请玩家先取消原本的导师再进行找新导师动作 + CHAR_talkToCli(charaindex,-1,"请先取消原本的导师再找其他人作为你的导师",CHAR_COLORRED); + } + else{ + int objindex,index; + char szFindName[256]; + + if(iPlayerNum == 1){ + // 询问是否要对方当你的导师 + objindex = objbuf[0]; + index = OBJECT_getIndex(objindex); + + if(OBJECT_getType(objindex) != OBJTYPE_CHARA) break; + if(CHAR_getInt(index,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER) break; + if(index == charaindex) break; + // 检查对方是否为自己的学生 + if(strcmp(CHAR_getChar(index,CHAR_TEACHER_ID),CHAR_getChar(charaindex,CHAR_CDKEY)) == 0 && + strcmp(CHAR_getChar(index,CHAR_TEACHER_NAME),CHAR_getChar(charaindex,CHAR_NAME)) == 0){ + CHAR_talkToCli(charaindex,-1,"对方为你的学生,无法让对方成为你的导师",CHAR_COLORRED); + break; + } + sprintf(szMsg,"C|%s|%d",CHAR_getChar(index,CHAR_NAME),index); + lssproto_TEACHER_SYSTEM_send(getfdFromCharaIndex(charaindex),szMsg); + } + // 超过一人,询问要找谁当导师 + else{ + int iGetNum = 0; + char szBuf[1024]; + + memset(szBuf,0,sizeof(szBuf)); + for(i=0;i 0 && tickettime > nowtime+20 ) { + continue; + } + // 时限不到20秒 + else if( tickettime < nowtime+20 && tickettime >= nowtime ) { + sprintf( msg, "时间票剩馀时间%d秒。", tickettime - nowtime); + CHAR_talkToCli( i, -1, msg, CHAR_COLORYELLOW); + } + + // 超过时限 + else if( tickettime < nowtime ) { + int floor, x, y; + int totaltime; + char msg[1024]; + if( CHAR_getWorkInt( i, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE) { + CHAR_talkToCli( i, -1, "时间已到,谢谢光顾。", CHAR_COLORYELLOW); + if( CHAR_getWorkInt( i, CHAR_WORKTICKETTIMESTART) > 0 ) { + totaltime = nowtime - CHAR_getWorkInt( i, CHAR_WORKTICKETTIMESTART); + sprintf( msg, "总入场时间%d分%d秒。", totaltime/60, totaltime%60); + CHAR_talkToCli( i, -1, msg, CHAR_COLORYELLOW); + } + CHAR_setWorkInt( i, CHAR_WORKTICKETTIME, 0); + CHAR_setWorkInt( i, CHAR_WORKTICKETTIMESTART, 0); + /* + if( CHAR_getElderPosition( CHAR_getInt( i, CHAR_LASTTALKELDER), &floor, &x, &y ) != TRUE ) { + CHAR_warpToSpecificPoint( i, 1006, 15, 15); + } + else { + CHAR_warpToSpecificPoint( i, floor, x, y); + } + */ + CHAR_warpToSpecificPoint( i, 7001, 41, 6); + } + else { + CHAR_talkToCli( i, -1, "时间已到,将於战斗结束时离开。", CHAR_COLORYELLOW); + // 移至 BATTLE_Exit() 处理 + } + } + } + +} +#endif diff --git a/gmsv/char/char_angel.c b/gmsv/char/char_angel.c new file mode 100644 index 0000000..72d6d91 --- /dev/null +++ b/gmsv/char/char_angel.c @@ -0,0 +1,685 @@ +#include "version.h" +#ifdef _ANGEL_SUMMON +#include +#include +#include +#include // shan +#include +#include +#include +#include +#include "common.h" +#include "char_base.h" +#include "char_data.h" +#include "char.h" +#include "lssproto_serv.h" +#include "item.h" +#include "item_event.h" +#include "buf.h" +#include "object.h" +#include "map_deal.h" +#include "saacproto_cli.h" +#include "readmap.h" +#include "handletime.h" +#include "char_event.h" +#include "npccreate.h" +#include "addressbook.h" +#include "item_event.h" +#include "magic_base.h" +#include "magic.h" +#include "chatmagic.h" +#include "configfile.h" +#include "log.h" +#include "anim_tbl.h" +#include "encount.h" +#include "battle.h" +#include "pet_skill.h" +#include "util.h" +#include "enemy.h" +#include "npcutil.h" +#include "pet.h" +#include "family.h" +#include "defend.h" +#include "npcserver.h" + + +struct MissionInfo missionlist[MAXMISSION]; +int mission_num =0; +struct MissionTable missiontable[MAXMISSIONTABLE]; + +//#define ANGELITEM 2884 //20701 //使者的信物 道具编号 +//#define HEROITEM 2885 //20702 //勇者的信物 道具编号 + +extern int AngelReady; + +char* getMissionNameInfo( int charaindex, char* nameinfo) +{ + sprintf( nameinfo, "%s:%s", CHAR_getChar( charaindex, CHAR_CDKEY), CHAR_getChar( charaindex, CHAR_NAME) ); + return nameinfo; +} + +int checkIfAngel( int charaindex) +{ + int i; + char nameinfo[512]; + + //sprintf( nameinfo, "%s:%s", CHAR_getChar( charaindex, CHAR_CDKEY), CHAR_getChar( charaindex, CHAR_NAME) ); + getMissionNameInfo( charaindex, nameinfo); + for( i =0; i + +// CoolFish: 2001/10/12 _UNIQUE_P_I +#include + + +#include "char_base.h" +#include "char_data.h" +#include "item.h" +#include "buf.h" +#include "magic.h" +#include "function.h" +#include "npccreate.h" +#include "configfile.h" +#include "title.h" +#include "pet.h" +#include "pet_skill.h" +#include "anim_tbl.h" +#include "enemy.h" +#include "saacproto_cli.h" + +// CoolFish: 2001/10/29 +#include "log.h" + +Char* CHAR_chara; + +static int CHAR_charanum; +static int CHAR_playernum; +static int CHAR_petnum; +static int CHAR_othersnum; + +// CoolFish: 2001/10/11 +#ifdef _UNIQUE_P_I +#define MAX_UNIQUE_P_I 1000 +static int unique_p = 0; +static int unique_i = 0; +#endif + +typedef struct tagINITCHARCOUNTER{ + int startcnt; + int cnt; + int endcnt; +}INITCHARCOUNTER; +static INITCHARCOUNTER initCharCounter[3] = { + {-1,-1,-1},{-1,-1,-1},{-1,-1,-1} +}; + + +tagRidePetTable ridePetTable[296] = +{ + { 101000, 100000, 100352, 331 }, + { 101001, 100005, 100352, 331 }, + { 101002, 100010, 100352, 331 }, + { 101003, 100015, 100352, 331 }, + { 101004, 100000, 100329, 309 }, + { 101005, 100005, 100327, 307 }, + { 101006, 100010, 100330, 310 }, + { 101007, 100015, 100328, 308 }, +// { 101008, 100700, 100372, 351 }, +// { 101009, 100705, 100373, 352 }, +#ifdef _GM_METAMO_RIDE + { 101000, 100700, 100352, 331 }, + { 101001, 100700, 100352, 331 }, + { 101002, 100700, 100352, 331 }, + { 101003, 100700, 100352, 331 }, + { 101004, 100700, 100329, 309 }, + { 101005, 100700, 100327, 307 }, + { 101006, 100700, 100330, 310 }, + { 101007, 100700, 100328, 308 }, + { 101000, 100705, 100352, 331 }, + { 101001, 100705, 100352, 331 }, + { 101002, 100705, 100352, 331 }, + { 101003, 100705, 100352, 331 }, + { 101004, 100705, 100329, 309 }, + { 101005, 100705, 100327, 307 }, + { 101006, 100705, 100330, 310 }, + { 101007, 100705, 100328, 308 }, +#endif + + { 101010, 100020, 100396, 483 }, + { 101011, 100025, 100396, 483 }, + { 101012, 100030, 100396, 483 }, + { 101013, 100035, 100396, 483 }, + { 101014, 100020, 100328, 308 }, + { 101015, 100025, 100329, 309 }, + { 101016, 100030, 100327, 307 }, + { 101017, 100035, 100330, 310 }, +// { 101018, 100710, 100372, 351 }, +// { 101019, 100715, 100373, 352 }, +#ifdef _GM_METAMO_RIDE + { 101010, 100710, 100396, 483 }, + { 101011, 100710, 100396, 483 }, + { 101012, 100710, 100396, 483 }, + { 101013, 100710, 100396, 483 }, + { 101014, 100710, 100328, 308 }, + { 101015, 100710, 100329, 309 }, + { 101016, 100710, 100327, 307 }, + { 101017, 100710, 100330, 310 }, + { 101010, 100715, 100396, 483 }, + { 101011, 100715, 100396, 483 }, + { 101012, 100715, 100396, 483 }, + { 101013, 100715, 100396, 483 }, + { 101014, 100715, 100328, 308 }, + { 101015, 100715, 100329, 309 }, + { 101016, 100715, 100327, 307 }, + { 101017, 100715, 100330, 310 }, + + { 100420, 100710, 100369, 348 }, + { 100425, 100710, 100370, 349 }, + { 100445, 100710, 100904, 1642 }, + + { 100420, 100715, 100369, 348 }, + { 100425, 100715, 100370, 349 }, + { 100445, 100715, 100904, 1642 }, +#endif + + { 101020, 100040, 100351, 330 }, + { 101021, 100045, 100351, 330 }, + { 101022, 100050, 100351, 330 }, + { 101023, 100055, 100351, 330 }, + { 101024, 100040, 100328, 308 }, + { 101025, 100045, 100330, 310 }, + { 101026, 100050, 100327, 307 }, + { 101027, 100055, 100329, 309 }, +// { 101028, 100720, 100372, 351 }, +// { 101029, 100725, 100373, 352 }, +#ifdef _GM_METAMO_RIDE + { 101020, 100720, 100351, 330 }, + { 101021, 100720, 100351, 330 }, + { 101022, 100720, 100351, 330 }, + { 101023, 100720, 100351, 330 }, + { 101024, 100720, 100328, 308 }, + { 101025, 100720, 100330, 310 }, + { 101026, 100720, 100327, 307 }, + { 101027, 100720, 100329, 309 }, + { 101020, 100725, 100351, 330 }, + { 101021, 100725, 100351, 330 }, + { 101022, 100725, 100351, 330 }, + { 101023, 100725, 100351, 330 }, + { 101024, 100725, 100328, 308 }, + { 101025, 100725, 100330, 310 }, + { 101026, 100725, 100327, 307 }, + { 101027, 100725, 100329, 309 }, +#endif + + { 101030, 100060, 100353, 332 }, + { 101031, 100065, 100353, 332 }, + { 101032, 100070, 100353, 332 }, + { 101033, 100075, 100353, 332 }, + { 101034, 100060, 100329, 309 }, + { 101035, 100065, 100327, 307 }, + { 101036, 100070, 100330, 310 }, + { 101037, 100075, 100328, 308 }, +// { 101038, 100730, 100372, 351 }, +// { 101039, 100735, 100373, 352 }, +#ifdef _GM_METAMO_RIDE + { 101030, 100730, 100353, 332 }, + { 101031, 100730, 100353, 332 }, + { 101032, 100730, 100353, 332 }, + { 101033, 100730, 100353, 332 }, + { 101034, 100730, 100329, 309 }, + { 101035, 100730, 100327, 307 }, + { 101036, 100730, 100330, 310 }, + { 101037, 100730, 100328, 308 }, + { 101030, 100735, 100353, 332 }, + { 101031, 100735, 100353, 332 }, + { 101032, 100735, 100353, 332 }, + { 101033, 100735, 100353, 332 }, + { 101034, 100735, 100329, 309 }, + { 101035, 100735, 100327, 307 }, + { 101036, 100735, 100330, 310 }, + { 101037, 100735, 100328, 308 }, +#endif + + { 101040, 100080, 100396, 483 }, + { 101041, 100085, 100396, 483 }, + { 101042, 100090, 100396, 483 }, + { 101043, 100095, 100396, 483 }, + { 101044, 100080, 100328, 308 }, + { 101045, 100085, 100327, 307 }, + { 101046, 100090, 100330, 310 }, + { 101047, 100095, 100329, 309 }, +// { 101048, 100740, 100372, 351 }, +// { 101049, 100745, 100373, 352 }, +#ifdef _GM_METAMO_RIDE + { 101040, 100740, 100396, 483 }, + { 101041, 100740, 100396, 483 }, + { 101042, 100740, 100396, 483 }, + { 101043, 100740, 100396, 483 }, + { 101044, 100740, 100328, 308 }, + { 101045, 100740, 100327, 307 }, + { 101046, 100740, 100330, 310 }, + { 101047, 100740, 100329, 309 }, + { 101040, 100740, 100396, 483 }, + { 101041, 100740, 100396, 483 }, + { 101042, 100740, 100396, 483 }, + { 101043, 100740, 100396, 483 }, + { 101044, 100740, 100328, 308 }, + { 101045, 100740, 100327, 307 }, + { 101046, 100740, 100330, 310 }, + { 101047, 100740, 100329, 309 }, +#endif + + { 101050, 100100, 100353, 332 }, + { 101051, 100105, 100353, 332 }, + { 101052, 100110, 100353, 332 }, + { 101053, 100115, 100353, 332 }, + { 101054, 100100, 100329, 309 }, + { 101055, 100105, 100328, 308 }, + { 101056, 100110, 100330, 310 }, + { 101057, 100115, 100327, 307 }, +// { 101058, 100750, 100372, 351 }, +// { 101059, 100755, 100373, 352 }, +#ifdef _GM_METAMO_RIDE + { 101050, 100750, 100353, 332 }, + { 101051, 100750, 100353, 332 }, + { 101052, 100750, 100353, 332 }, + { 101053, 100750, 100353, 332 }, + { 101054, 100750, 100329, 309 }, + { 101055, 100750, 100328, 308 }, + { 101056, 100750, 100330, 310 }, + { 101057, 100750, 100327, 307 }, + { 101050, 100755, 100353, 332 }, + { 101051, 100755, 100353, 332 }, + { 101052, 100755, 100353, 332 }, + { 101053, 100755, 100353, 332 }, + { 101054, 100755, 100329, 309 }, + { 101055, 100755, 100328, 308 }, + { 101056, 100755, 100330, 310 }, + { 101057, 100755, 100327, 307 }, +#endif + + { 101060, 100120, 100354, 333 }, + { 101061, 100125, 100354, 333 }, + { 101062, 100130, 100354, 333 }, + { 101063, 100135, 100354, 333 }, + { 101064, 100120, 100327, 307 }, + { 101065, 100125, 100330, 310 }, + { 101066, 100130, 100328, 308 }, + { 101067, 100135, 100329, 309 }, +// { 101068, 100760, 100372, 351 }, +// { 101069, 100765, 100373, 352 }, +#ifdef _GM_METAMO_RIDE + { 101060, 100760, 100354, 333 }, + { 101061, 100760, 100354, 333 }, + { 101062, 100760, 100354, 333 }, + { 101063, 100760, 100354, 333 }, + { 101064, 100760, 100327, 307 }, + { 101065, 100760, 100330, 310 }, + { 101066, 100760, 100328, 308 }, + { 101067, 100760, 100329, 309 }, + { 101060, 100765, 100354, 333 }, + { 101061, 100765, 100354, 333 }, + { 101062, 100765, 100354, 333 }, + { 101063, 100765, 100354, 333 }, + { 101064, 100765, 100327, 307 }, + { 101065, 100765, 100330, 310 }, + { 101066, 100765, 100328, 308 }, + { 101067, 100765, 100329, 309 }, +#endif + + { 101070, 100140, 100354, 333 }, + { 101071, 100145, 100354, 333 }, + { 101072, 100150, 100354, 333 }, + { 101073, 100155, 100354, 333 }, + { 101074, 100140, 100327, 307 }, + { 101075, 100145, 100329, 309 }, + { 101076, 100150, 100330, 310 }, + { 101077, 100155, 100328, 308 }, +// { 101078, 100770, 100372, 351 }, +// { 101079, 100775, 100373, 352 }, +#ifdef _GM_METAMO_RIDE + { 101070, 100770, 100354, 333 }, + { 101071, 100770, 100354, 333 }, + { 101072, 100770, 100354, 333 }, + { 101073, 100770, 100354, 333 }, + { 101074, 100770, 100327, 307 }, + { 101075, 100770, 100329, 309 }, + { 101076, 100770, 100330, 310 }, + { 101077, 100770, 100328, 308 }, + { 101070, 100775, 100354, 333 }, + { 101071, 100775, 100354, 333 }, + { 101072, 100775, 100354, 333 }, + { 101073, 100775, 100354, 333 }, + { 101074, 100775, 100327, 307 }, + { 101075, 100775, 100329, 309 }, + { 101076, 100775, 100330, 310 }, + { 101077, 100775, 100328, 308 }, +#endif + + { 101080, 100160, 100352, 331 }, + { 101081, 100165, 100352, 331 }, + { 101082, 100170, 100352, 331 }, + { 101083, 100175, 100352, 331 }, + { 101084, 100160, 100330, 310 }, + { 101085, 100165, 100329, 309 }, + { 101086, 100170, 100327, 307 }, + { 101087, 100175, 100328, 308 }, +// { 101088, 100780, 100372, 351 }, +// { 101089, 100785, 100373, 352 }, +#ifdef _GM_METAMO_RIDE + { 101040, 100780, 100396, 483 }, + { 101041, 100780, 100396, 483 }, + { 101042, 100780, 100396, 483 }, + { 101043, 100780, 100396, 483 }, + { 101044, 100780, 100328, 308 }, + { 101045, 100780, 100327, 307 }, + { 101046, 100780, 100330, 310 }, + { 101047, 100780, 100329, 309 }, + { 101080, 100785, 100352, 331 }, + { 101081, 100785, 100352, 331 }, + { 101082, 100785, 100352, 331 }, + { 101083, 100785, 100352, 331 }, + { 101084, 100785, 100330, 310 }, + { 101085, 100785, 100329, 309 }, + { 101086, 100785, 100327, 307 }, + { 101087, 100785, 100328, 308 }, +#endif + + { 101090, 100180, 100351, 330 }, + { 101091, 100185, 100351, 330 }, + { 101092, 100190, 100351, 330 }, + { 101093, 100195, 100351, 330 }, + { 101094, 100180, 100328, 308 }, + { 101095, 100185, 100330, 310 }, + { 101096, 100190, 100329, 309 }, + { 101097, 100195, 100327, 307 }, +// { 101098, 100790, 100372, 351 }, +// { 101099, 100795, 100373, 352 }, +#ifdef _GM_METAMO_RIDE + { 101090, 100790, 100351, 330 }, + { 101091, 100790, 100351, 330 }, + { 101092, 100790, 100351, 330 }, + { 101093, 100790, 100351, 330 }, + { 101094, 100790, 100328, 308 }, + { 101095, 100790, 100330, 310 }, + { 101096, 100790, 100329, 309 }, + { 101097, 100790, 100327, 307 }, + { 101090, 100795, 100351, 330 }, + { 101091, 100795, 100351, 330 }, + { 101092, 100795, 100351, 330 }, + { 101093, 100795, 100351, 330 }, + { 101094, 100795, 100328, 308 }, + { 101095, 100795, 100330, 310 }, + { 101096, 100795, 100329, 309 }, + { 101097, 100795, 100327, 307 }, +#endif + + { 101100, 100200, 100353, 332 }, + { 101101, 100205, 100353, 332 }, + { 101102, 100210, 100353, 332 }, + { 101103, 100215, 100353, 332 }, + { 101104, 100200, 100329, 309 }, + { 101105, 100205, 100328, 308 }, + { 101106, 100210, 100327, 307 }, + { 101107, 100215, 100330, 310 }, +// { 101108, 100800, 100372, 351 }, +// { 101109, 100805, 100373, 352 }, +#ifdef _GM_METAMO_RIDE + { 101100, 100800, 100353, 332 }, + { 101101, 100800, 100353, 332 }, + { 101102, 100800, 100353, 332 }, + { 101103, 100800, 100353, 332 }, + { 101104, 100800, 100329, 309 }, + { 101105, 100800, 100328, 308 }, + { 101106, 100800, 100327, 307 }, + { 101107, 100800, 100330, 310 }, + { 101100, 100805, 100353, 332 }, + { 101101, 100805, 100353, 332 }, + { 101102, 100805, 100353, 332 }, + { 101103, 100805, 100353, 332 }, + { 101104, 100805, 100329, 309 }, + { 101105, 100805, 100328, 308 }, + { 101106, 100805, 100327, 307 }, + { 101107, 100805, 100330, 310 }, +#endif + + { 101110, 100220, 100396, 483 }, + { 101111, 100225, 100396, 483 }, + { 101112, 100230, 100396, 483 }, + { 101113, 100235, 100396, 483 }, + { 101114, 100220, 100330, 310 }, + { 101115, 100225, 100327, 307 }, + { 101116, 100230, 100329, 309 }, + { 101117, 100235, 100328, 308 }, +// { 101118, 100810, 100372, 351 }, +// { 101119, 100815, 100373, 352 }, +#ifdef _GM_METAMO_RIDE + { 101110, 100810, 100396, 483 }, + { 101111, 100810, 100396, 483 }, + { 101112, 100810, 100396, 483 }, + { 101113, 100810, 100396, 483 }, + { 101114, 100810, 100330, 310 }, + { 101115, 100810, 100327, 307 }, + { 101116, 100810, 100329, 309 }, + { 101117, 100810, 100328, 308 }, + { 101110, 100815, 100396, 483 }, + { 101111, 100815, 100396, 483 }, + { 101112, 100815, 100396, 483 }, + { 101113, 100815, 100396, 483 }, + { 101114, 100815, 100330, 310 }, + { 101115, 100815, 100327, 307 }, + { 101116, 100815, 100329, 309 }, + { 101117, 100815, 100328, 308 }, +#endif + + { 101179, 101177, 101178, 1804}, + { 101179, 101178, 101177, 1926}, +}; + +#ifdef _NEW_RIDEPETS + +tagRideCodeMode RideCodeMode[] = { + { 100374, RIDE_PET0 }, /*骑宠帖拉所伊朵*/ + { 100358, RIDE_PET1 }, /*骑宠玛恩摩洛斯*/ + { 100362, RIDE_PET2 }, /*骑宠朵拉比斯*/ + { 100279, RIDE_PET3 }, /*骑宠拉奇鲁哥*/ + { 100288, RIDE_PET4 }, /*骑宠扬奇洛斯*/ + { 100283, RIDE_PET5 }, /*骑宠卡达鲁卡斯*/ + { 100346, RIDE_PET6 }, /*骑宠卡卡金宝*/ + { 100310, RIDE_PET7 }, /*骑宠格尔格*/ + { 100372, RIDE_PET8 }, /*骑宠左迪洛斯*/ + { 100373, RIDE_PET9 }, /*骑宠巴朵兰恩*/ + { 101532, RIDE_PET10 }, /*镲宠史卡鲁*/ + { 101576, RIDE_PET11 }, /*骑宠罗多克雷*/ +}; + +tagRideNoList RideNoList[] = { + {{ 101305, 101306, 101307, 101308, 101309, 101310, 101311, 101312, 101008, 101009, 101978, 101989},0}, //小矮子 + {{ 101313, 101314, 101315, 101316, 101317, 101318, 101319, 101320, 101018, 101019, 101986, 101988},0}, //赛亚人 + {{ 101321, 101322, 101323, 101324, 101325, 101326, 101327, 101328, 101028, 101029, 101975, 101965},0}, //辫子男孩 + {{ 101329, 101330, 101331, 101332, 101333, 101334, 101335, 101336, 101038, 101039, 101976, 101966},0}, //酷哥 + {{ 101337, 101338, 101339, 101340, 101341, 101342, 101343, 101344, 101048, 101049, 101984, 101973},0}, //熊皮男 + {{ 101345, 101346, 101347, 101348, 101349, 101350, 101351, 101352, 101058, 101059, 101985, 101974},0}, //大个 + {{ 101353, 101354, 101355, 101356, 101357, 101358, 101359, 101360, 101068, 101069, 101977, 101967},0}, //小矮妹 + {{ 101361, 101362, 101363, 101364, 101365, 101366, 101367, 101368, 101078, 101079, 101979, 101968},0}, //熊皮妹 + {{ 101369, 101370, 101371, 101372, 101373, 101374, 101375, 101376, 101088, 101089, 101981, 101970},0}, //帽子妹 + {{ 101377, 101378, 101379, 101380, 101381, 101382, 101383, 101384, 101098, 101099, 101980, 101969},0}, //短法发夹妹 + {{ 101385, 101386, 101387, 101388, 101389, 101390, 101391, 101392, 101108, 101109, 101983, 101972},0}, //手套女 + {{ 101393, 101394, 101395, 101396, 101397, 101398, 101399, 101400, 101118, 101119, 101982, 101970},0}, //辣妹 +}; + +tagRidePetList RPlistMode[] = { + { 100000, 0, 1 }, { 100005, 0, 1 }, { 100010, 0, 1 }, { 100015, 0, 1 }, { 100700, 0, 1 }, { 100705, 0, 1 }, //小矮子 + { 100020, 1, 1 }, { 100025, 1, 1 }, { 100030, 1, 1 }, { 100035, 1, 1 }, { 100710, 1, 1 }, { 100715, 1, 1 },//赛亚人 + { 100040, 2, 1 }, { 100045, 2, 1 }, { 100050, 2, 1 }, { 100055, 2, 1 }, { 100720, 2, 1 }, { 100725, 2, 1 }, //辫子男孩 + { 100060, 3, 1 }, { 100065, 3, 1 }, { 100070, 3, 1 }, { 100075, 3, 1 }, { 100730, 3, 1 }, { 100735, 3, 1 }, //酷哥 + { 100080, 4, 1 }, { 100085, 4, 1 }, { 100090, 4, 1 }, { 100095, 4, 1 }, { 100740, 4, 1 }, { 100745, 4, 1 }, //熊皮男 + { 100100, 5, 1 }, { 100105, 5, 1 }, { 100110, 5, 1 }, { 100115, 5, 1 }, { 100750, 5, 1 }, { 100755, 5, 1 }, //大个 + { 100120, 6, 2 }, { 100125, 6, 2 }, { 100130, 6, 2 }, { 100135, 6, 2 }, { 100760, 6, 2 }, { 100765, 6, 2 }, //小矮妹 + { 100140, 7, 2 }, { 100145, 7, 2 }, { 100150, 7, 2 }, { 100155, 7, 2 }, { 100770, 7, 2 }, { 100775, 7, 2 }, //熊皮妹 + { 100160, 8, 2 }, { 100165, 8, 2 }, { 100170, 8, 2 }, { 100175, 8, 2 }, { 100780, 8, 2 }, { 100785, 8, 2 }, //帽子妹 + { 100180, 9, 2 }, { 100185, 9, 2 }, { 100190, 9, 2 }, { 100195, 9, 2 }, { 100790, 9, 2 }, { 100795, 9, 2 }, //短发夹妹 + { 100200, 10, 2 }, { 100205, 10, 2 }, { 100210, 10, 2 }, { 100215, 10, 2 }, { 100800, 10, 2 }, { 100805, 10, 2 }, //手套女 + { 100220, 11, 2 }, { 100225, 11, 2 }, { 100230, 11, 2 }, { 100235, 11, 2 }, { 100810, 11, 2 }, { 100815, 11, 2 }, //辣妹 +}; + +int RIDEPET_getNOindex( int baseNo) +{ + int i; + for( i=0; i< sizeof(RPlistMode)/sizeof(tagRidePetList); i++ ) { + if( RPlistMode[i].charNo == baseNo ) { + return RPlistMode[i].Noindex; + } + } + return -1; +} + +int RIDEPET_getPETindex( int PetNo, int learnCode) +{ + int i; + for( i=0; i< sizeof(RideCodeMode)/sizeof(tagRideCodeMode); i++ ) { + if( RideCodeMode[i].petNo == PetNo && + (RideCodeMode[i].learnCode & learnCode) ) { + return i; + } + } + return -1; +} + +int RIDEPET_getRIDEno( int index, int ti) +{ + if( index < 0 || index >= sizeof( RideNoList)/sizeof( tagRideNoList) ) + return -1; + if( ti < 0 || ti >= MAXNOINDEX ) + return -1; + + return RideNoList[index].RideNo[ti]; +} +#endif + +#ifdef _EMENY_CHANCEMAN +int CHAR_getSexInt( int baseNo ) +{ + int i; + for( i=0; i< sizeof(RPlistMode)/sizeof(tagRidePetList); i++ ) { + if( RPlistMode[i].charNo == baseNo ) { + return RPlistMode[i].sex; + } + } + return -1; +} +#endif + +#ifdef _PET_EVOLUTION +#define MAXTABLE_X 29 +#define MAXTABLE_Y 29 +int PetTable[MAXTABLE_X][MAXTABLE_Y]={ + //0 4 9 14 19 24 + { 1, 2, 5, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 5, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5}, + { 2, 5, 1, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1}, + { 5, 1, 2, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2}, + { 1, 2, 5, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5}, + { 2, 5, 1, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1}, + + { 2, 1, 2, 1, 2, 2, 2, 5, 5, 1, 2, 5, 2, 1, 2, 1, 2, 5, 2, 1, 2, 1, 2, 5, 2, 5, 2, 1, 2}, + { 1, 2, 5, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 1}, + { 2, 5, 1, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 2}, + {10, 3,10, 3,10, 8,10, 8,10, 3,10, 3,10, 8,10, 8,10, 3,10, 3,10, 8,10, 8,10, 8,10, 3,10}, + { 3, 8, 3, 8, 3,10, 3,10, 8, 3, 3, 8, 3, 8, 3,10, 3,10, 3, 8, 3, 8, 3,10, 3,10, 3, 8, 3}, + + { 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8}, + { 5, 1, 5, 1, 5, 2, 5, 2, 5, 1, 5, 5, 5, 1, 5, 2, 5, 2, 5, 1, 5, 1, 5, 2, 5, 2, 5, 1, 5}, + { 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10}, + {10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3}, + { 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8}, + + { 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1}, + { 9, 0, 9, 0, 9, 4, 9, 4, 9, 0, 9, 0, 9, 4, 9, 4, 9, 0, 9, 0, 9, 4, 9, 4, 9, 0, 9, 4, 9}, + { 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2}, + { 6, 0, 6, 0, 6, 9, 6, 9, 6, 0, 6, 0, 6, 9, 6, 9, 6, 0, 6, 0, 6, 9, 6, 9, 6, 0, 6, 9, 6}, + { 4, 6, 4, 6, 4, 9, 4, 9, 4, 6, 4, 6, 4, 9, 4, 9, 4, 6, 4, 6, 4, 9, 4, 9, 4, 6, 4, 9, 4}, + + { 8, 3, 8, 3, 8,10, 8,10, 8, 3, 8, 3, 8,10, 8,10, 8, 3, 8, 3, 8,10, 8,10, 8, 3, 8,10, 8}, + { 8,10, 3, 8,10, 3, 8,10,10, 3, 8,10, 3, 8,10, 3,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10}, + { 1, 2, 5, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5}, + { 0, 4, 0, 4, 0, 6, 0, 6, 0, 4, 0, 4, 0, 6, 0, 6, 0, 4, 0, 4, 0, 6, 0, 4, 0, 6, 0, 4, 0}, + { 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2}, + + { 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8}, + {10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3}, + { 2, 1, 2, 1, 5, 1, 5, 1, 2, 1, 2, 1, 5, 1, 5, 1, 2, 1, 2, 1, 5, 1, 5, 1, 2, 1, 2, 5, 1}, + { 6, 9, 6, 9, 6, 0, 6, 0, 6, 9, 6, 9, 6, 0, 6, 0, 6, 9, 6, 9, 6, 0, 6, 0, 6, 9, 6, 0, 6} +}; + +int PropertyTable[4][4]={ + { 0, 4, 5, 6}, + { 7, 1, 8, 9}, + {10,11, 2,12}, + {13,14,15, 3}, +}; +#define MAXFTABLE_X 11 +#define MAXFTABLE_Y 16 +int FusionTable[MAXFTABLE_X][MAXFTABLE_Y]={ + { 989, 990, 991, 992, 989, 992, 989, 990, 990, 990, 991, 991, 991, 992, 989, 992}, + {1001,1002,1003,1004,1001,1001,1004,1001,1002,1002,1003,1003,1003,1004,1004,1003}, + {1005,1006,1007,1008,1005,1005,1005,1006,1006,1006,1007,1006,1007,1008,1008,1008}, + {1021,1025,1023,1024,1025,1021,1021,1022,1022,1022,1023,1023,1023,1021,1024,1024}, + {1030,1031,1032,1033,1030,1030,1030,1031,1031,1031,1032,1031,1032,1030,1033,1033}, + {1017,1018,1019,1020,1018,1017,1017,1018,1019,1018,1019,1019,1020,1017,1020,1020}, + {1009,1010,1011,1012,1010,1009,1009,1010,1010,1010,1011,1011,1011,1012,1012,1011}, + { 993, 994, 995, 996, 994, 993, 993, 994, 995, 994, 995, 993, 996, 993, 996, 996}, + {1026,1027,1028,1029,1026,1026,1026,1026,1028,1027,1028,1028,1029,1029,1029,1029}, + { 997, 998, 999, 999,1000, 997, 997,1000, 998, 998,1000, 998, 999, 999, 999, 999}, + {1013,1014,1015,1016,1013,1013,1016,1013,1015,1014,1015,1015,1015,1016,1016,1016} +}; + +int EVOLUTION_getPetFusionCode( int petid) +{ + int petarray = ENEMYTEMP_getEnemyTempArrayFromTempNo( petid); + return ENEMYTEMP_getInt( petarray, E_T_FUSIONCODE); +} + +int EVOLUTION_getPetTable( int charaindex, int petindex1, int petindex2) +{ + int table1,table2; + + if( !CHAR_CHECKINDEX( petindex1) ) return -1; + if( !CHAR_CHECKINDEX( petindex2) ) return -1; + + table2 = EVOLUTION_getPetFusionCode( CHAR_getInt( petindex1, CHAR_PETID)); + table1 = EVOLUTION_getPetFusionCode( CHAR_getInt( petindex2, CHAR_PETID)); + + if( table1 < 0 || table1 >= MAXTABLE_X ) return -1; + if( table2 < 0 || table2 >= MAXTABLE_Y ) return -1; + return PetTable[table1][table2]; +} + +int EVOLUTION_getPropertyTable( int charaindex, int petindex1, int petindex2) +{ + int i, k1=0, k2=0; + int table1,table2; + int Property1[4]={-1,-1,-1,-1}; + int Property2[4]={-1,-1,-1,-1}; + + if( !CHAR_CHECKINDEX( petindex1) ) return -1; + if( !CHAR_CHECKINDEX( petindex2) ) return -1; + + for( i=0; i<4; i++) { + if( CHAR_getInt( petindex1, CHAR_EARTHAT+i) > 0 ){ + Property1[k1] = i; + k1++; + } + if( CHAR_getInt( petindex2, CHAR_EARTHAT+i) > 0 ){ + Property2[k2] = i; + k2++; + } + } + if( k1 == 0 || k2 == 0 ) return -1; + + if( k1 <= 1 ) { + table1 = Property1[ 0]; + }else{ + table1 = Property1[ (rand()%(k1-1)) ]; + } + if( k2 <= 1 ) { + table2 = Property2[ 0]; + }else { + table2 = Property2[ (rand()%(k2-1)) ]; + } + + if( table1 < 0 || table1 >= 4 ) return -1; + if( table2 < 0 || table2 >= 4 ) return -1; + + return PropertyTable[table1][table2]; +} + +int EVOLUTION_getFusionTable( int charaindex, int px, int py) +{ + if( px >= MAXFTABLE_X || px < 0 ) return -1; + if( py >= MAXFTABLE_Y || py < 0 ) return -1; + return FusionTable[px][py]; +} +#endif + +#ifdef _CHAR_FIXDATADEF +/* +typedef struct _tagPetSetIntData{ + char com[256]; + int type; +}PetSetIntData; + +PetSetIntData PET_SetIntData[ ]={ +}; +*/ +#endif + +static char* CHAR_setintdata[CHAR_DATAINTNUM]={ + /* dci , PLAYER, */ + "pn", /* CHAR_DATAPLACENUMBER */ + + "bi", /* CHAR_BASEIMAGENUMBER */ + "bbi", /* CHAR_BASEBASEIMAGENUMBER */ + "fb", /* CHAR_FACEIMAGENUMBER */ + "fl", /* CHAR_FLOOR */ + "x", /* CHAR_X */ + "y", /* CHAR_Y */ + "dir", /* CHAR_DIR 12凛毛0卞凛煌璃曰卞 */ + "lv", /* CHAR_LV */ + "gld", /* CHAR_GOLD */ + + "hp", /* CHAR_HP */ + "mp", /* CHAR_MP */ + "mmp", /* CHAR_MAXMP */ + + "vi", /* CHAR_VITAL */ + "str", /* CHAR_STR */ + "tou", /* CHAR_TOUGH */ + "dx", /* CHAR_DEX */ + + "chr", /* CHAR_CHARM */ + "luc", /* CHAR_LUCK */ + "aea", /* 哗箪岭 */ + "awa", /* 箪岭 */ + "afi", /* 绍箪岭 */ + "awi", /* 氘箪岭 */ + + "slt", /* CHAR_SLOT */ + "cr", /* CHAR_CRITIAL */ + "cou", /* CHAR_COUNTER */ + "rar", /* CHAR_RARE */ + "rst", /* CHAR_RADARSTRLENGTH */ + "cvo", /* CHAR_CHATVOLUME */ + "ml", /* CHAR_MERCHANTLEVEL */ + "hl", /* CHAR_HEALERLEVEL */ + "di", /* CHAR_DETERMINEITEM */ + "ieqt", /* CHAR_INDEXOFEQTITLE */ + "poi", /* CHAR_POISON */ + "par", /* CHAR_PARALYSIS */ + "sil", /* CHAR_SILENCE */ + "sto", /* CHAR_STONE */ + "dar", /* CHAR_DARKNESS */ + "con", /* CHAR_CONFUSION */ + "loc", /* CHAR_LOGINCOUNT */ + "dc", /* CHAR_DEADCOUNT */ + "wc", /* CHAR_WALKCOUNT */ + "tc", /* CHAR_TALKCOUNT */ + "dmc", /* CHAR_DAMAGECOUNT */ + "gpc", /* CHAR_GETPETCOUNT */ + "kpc", /* CHAR_KILLPETCOUNT */ + "dpc", /* CHAR_DEADPETCOUNT */ + "smc", /* CHAR_SENDMAILCOUNT */ + "mic", /* CHAR_MERGEITEMCOUNT */ + "dbc", /* CHAR_DUELBATTLECOUNT */ + "dwc", /* CHAR_DUELWINCOUNT */ + "dlc", /* CHAR_DUELLOSECOUNT */ + "dswc", /* CHAR_DUELSTWINCOUNT */ + "dmswc", /* CHAR_DUELMAXSTWINCOUNT */ + "wht", /* CHAR_WHICHTYPE */ + "wint", /* CHAR_WALKNTERVAL */ + "lint", /* CHAR_LOOPINTERVAL */ +#ifdef _NEWOPEN_MAXEXP + "exp", /* CHAR_OLDEXP */ + "nexp", /* CHAR_EXP */ +#else + "exp", /* CHAR_EXP */ +#endif + "lte", /* CHAR_LASTTALKELDER */ + "skup", /* CHAR_SKILLUPPOINT */ + "lvup", /* CHAR_LEVELUPPOINT */ + "ity", /* CHAR_IMAGETYPE */ + "nc", /* CHAR_NAMECOLOR */ + "pnc", /* CHAR_POPUPNAMECOLOR */ + "llt", /* CHAR_LASTTIMESETLUCK */ + "duel", /* CHAR_DUELPOINT */ + "evt", /* CHAR_EVENT */ + "evt2", /* CHAR_EVENT2 */ + "evt3", /* CHAR_EVENT3 */ +#ifdef _NEWEVENT + "evt4", /* CHAR_EVENT4 */ + "evt5", /* CHAR_EVENT5 */ + "evt6", /* CHAR_EVENT6 */ +#endif +#ifdef _ADD_NEWEVENT // WON 多增任务旗标 + "evt7", /* CHAR_EVENT7 */ + "evt8", // CHAR_ENDEVENT8, 224~255 精灵召唤专用 +#endif + + "nev", /* CHAR_NOWEVENT */ + "nev2", /* CHAR_NOWEVENT2 */ + "nev3", /* CHAR_NOWEVENT3 */ +#ifdef _NEWEVENT + "nev4", /* CHAR_NOWEVENT4 */ + "nev5", /* CHAR_NOWEVENT5 */ + "nev6", /* CHAR_NOWEVENT6 */ +#endif +#ifdef _ADD_NEWEVENT // WON 多增任务旗标 + "nev7", /* CHAR_NOWEVENT7 */ + "nev8", // CHAR_NOWEVENT8, 224~255 精灵召唤专用 +#endif + + "trn", /* CHAR_TRANSMIGRATION */ + "teq", /* CHAR_TRANSEQUATION */ + + "ini", /* CHAR_INITDATA */ + "silent", /* CHAR_SILENT */ + "fmi", // CoolFish: Family 2001/5/24 家族 index + "fmlf", // CoolFish: Family 2001/5/24 是否为家族族长 + "fmspr", // CoolFish: Family 2001/7/13 家族守护精灵 + + "bankgld", /* CHAR_BANKGOLD */ + "ridepet", /* CHAR_RIDEPET */ + "learnride", /* CHAR_LEARNRIDE */ +#ifdef _NEW_RIDEPETS + "lowridepet", //CHAR_LOWRIDEPETS +#endif + "limitlv", // Arminius 7.30 pet limit level +#ifdef _PET_FUSION + "fusioncode", //CHAR_FUSIONCODE + "fusionindex", //CHAR_FUSIONINDEX + "fusionraise", //CHAR_FUSIONRAISE + "fusionbe", //CHAR_FUSIONBEIT + "futimelimit", //CHAR_FUSIONTIMELIMIT +#endif +#ifdef _DEATH_CONTEND + "pkltnum", //CHAR_PKLISTTEAMNUM, + "pkleader", //CHAR_PKLISTLEADER, +#endif + +#ifdef _PERSONAL_FAME // Arminius 8.30: 家族个人声望 + "fame", +#endif + +#ifdef _NEWSAVE + "sindex", /* CHAR_SAVEINDEXNUMBER */ +#endif + +#ifdef __ATTACK_MAGIC + "earth_exp", // 玩家的地魔法熟练度 + "water_exp", // 玩家的水魔法熟练度 + "fire_exp", // 玩家的火魔法熟练度 + "wind_exp", // 玩家的风魔法熟练度 + "earth_resist", // 玩家的地魔法抗性 + "water_resist", // 玩家的水魔法抗性 + "fire_resist", // 玩家的火魔法抗性 + "wind_resist", // 玩家的风魔法抗性 + "earth_attmagic_exp", // 玩家的地魔法熟练度经验值 + "water_attmagic_exp", // 玩家的水魔法熟练度经验值 + "fire_attmagic_exp", // 玩家的火魔法熟练度经验值 + "wind_attmagic_exp", // 玩家的风魔法熟练度经验值 + "earth_defmagic_exp", // 玩家的地魔法抗性经验值 + "water_defmagic_exp", // 玩家的水魔法抗性经验值 + "fire_defmagic_exp", // 玩家的火魔法抗性经验值 + "wind_defmagic_exp", // 玩家的风魔法抗性经验值 +#endif + +#ifdef _GAMBLE_BANK //个人银行 + "personaglod", //CHAR_PERSONAGOLD, +#endif +#ifdef _DROPSTAKENEW + "gamblenums", //CHAR_GAMBLENUM +#endif +#ifdef _ADD_ACTION //npc动作 + "actsty", //CHAR_ACTIONSTYLE +#endif +#ifdef _AUCTIONEER + "aucgold", // CHAR_AUCGOLD 拍卖所得 +#endif +#ifdef _PET_EVOLUTION + "evbasevtl",// CHAR_EVOLUTIONBASE, + "evbasestr",// CHAR_EVOLUTIONBASE, + "evbasetgh",// CHAR_EVOLUTIONBASE, + "evbasedex",// CHAR_EVOLUTIONBASE, +#endif + +#ifdef _ACTION_BULLSCR + "abullstart", //CHAR_ABULLSTART + "abullscore", //CHAR_ABULLSCORE, + "abulltime", //CHAR_ABULLTIME, + "abullstarttime", //CHAR_ABULLSTARTTIME +#endif + +#ifdef _ACTION_GMQUE + "gmqueflg", //CHAR_GMQUEFLG, + "gmquenum", //CHAR_GMQUENUMS, +#endif + + +#ifdef _FAMILYBANKSTONELOG + "fmbankgold", //家族银行存款 +#endif + +#ifdef _FM_JOINLIMIT + "fmtimelimit", // CHAR_FMTIMELIMIT, +#endif + +#ifdef _CHAR_PROFESSION // WON ADD 人物职业 + "profession_class", + "profession_level", +// "profession_exp", + "profession_skill_point", + "attachpile", + "profession_fire_p", + "profession_ice_p", + "profession_thunder_p", + "profession_fire_r", + "profession_ice_r", + "profession_thunder_r", +#endif +#ifdef _ALLDOMAN // (不可开) Syu ADD 排行榜NPC + "herofloor", +#endif +#ifdef _PETSKILL_BECOMEPIG + "becomepig", + "becomepig_bbi", +#endif + "leavetime", // CHAR_LASTLEAVETIME +#ifdef _NEW_MANOR_LAW + "momentum", // CHAR_MOMENTUM +#endif + +#ifdef _ITEM_ADDEXP2 + "aexp", // CHAR_ADDEXPPOWER + "aexpt", // CHAR_ADDEXPTIME +#endif + +#ifdef _ANGEL_SUMMON + "herocnt", // CHAR_HEROCNT +#endif +#ifdef _TEACHER_SYSTEM + "tsf", // CHAR_TEACHER_FAME, // 导师领导声望 +#endif + +#ifdef _RACEMAN + "checkin", // CHAR_CHECKIN + "catchcnt1", // CHAR_CATCHCNT1 + "catchcnt2", // CHAR_CATCHCNT2 + "catchcnt3", // CHAR_CATCHCNT3 + "catchcnt4", // CHAR_CATCHCNT4 + "catchcnt5", // CHAR_CATCHCNT5 + "kindcnt1", //CHAR_KINDCNT1, /* (0~31) */ + "kindcnt2", //CHAR_KINDCNT2, /* (32~63) */ + "kindcnt3", //CHAR_KINDCNT3, /* (64~95) */ + "kindcnt4", //CHAR_KINDCNT4, /* (96~127) */ + "kindcnt5", //CHAR_KINDCNT5, /* (128~159) */ + "kindcnt6", //CHAR_KINDCNT6, /* (160~191) */ + "kindcnt7", //CHAR_KINDCNT7, /* (192~223) */ + "kindcnt8", //CHAR_KINDCNT8, /* (224~255) */ + "kindcnt9", //CHAR_KINDCNT9, /* (256~287) */ + "kindcnt10", //CHAR_KINDCNT10, /* (288~319) */ +#endif +#ifdef _GM_ITEM + "gmtime", // 玩家GM命令次数 +#endif +}; + +static char* CHAR_setchardata[CHAR_DATACHARNUM]={ + /* dcc , PLAYER */ + "name" , /* CHAR_NAME */ + "ownt" , /* CHAR_OWNTITLE*/ + "arg", /* CHAR_NPCARGUMENT */ + "ocd", /* CHAR_OWNERCDKEY */ + "ocn", /* CHAR_OWNERCHARANAME */ + "fmname", // CoolFish: Family 2001/5/24 家族名称 CHAR_FMNAME +#ifdef _UNIQUE_P_I + "ucode", // CoolFish: 2001/10/11 UNIQUE_P_I CHAR_UNIQUECODE +#endif +#ifdef _ACTION_GMQUE + //人物 npc 使用 + "gmque", //CHAR_GMQUESTR1, + //"temp2", //CHAR_GMQUESTR2, + //"temp3", //CHAR_GMQUESTR3, + //"temp4", //CHAR_GMQUESTR4, +#endif + +#ifdef _GM_IDENTIFY + "gmidentify", //gm名称 +#endif +#ifdef _TEACHER_SYSTEM + "tsi", // 导师帐号 + "tsn", // 导师名字 +#endif + +#ifdef _ITEM_SETLOVER + "love", // 结婚判断 + "lovrrid", // 爱人帐号 + "lovrrneme", // 爱人名字 +#endif + +#ifdef _GM_ITEM + "gmfunction", // 玩家GM命令 +#endif +}; + +INLINE BOOL _CHAR_CHECKINDEX( char *file, int line, int index ) +{ + if( CHAR_charanum<=index || index<0 ) { + return FALSE; + } + if( CHAR_chara[(index)].use == FALSE ) { + return FALSE; + } + return TRUE; +} + +static INLINE BOOL CHAR_CHECKINTDATAINDEX(int index) +{ + if( CHAR_DATAINTNUM<=index || index<0 )return FALSE; + return TRUE; +} + +static INLINE BOOL CHAR_CHECKCHARDATAINDEX(int index) +{ + if( CHAR_DATACHARNUM<=index || index<0 )return FALSE; + return TRUE; +} + +static INLINE BOOL CHAR_CHECKFLGDATAINDEX( int index ) +{ + if( CHAR_FLGNUM<=index || index<0 )return FALSE; + return TRUE; +} + +static INLINE BOOL CHAR_CHECKCHARWORKDATAINDEX(int index) +{ + if( CHAR_WORKDATACHARNUM<=index || index<0 )return FALSE; + return TRUE; +} + +static INLINE BOOL CHAR_CHECKCHARFUNCTABLEINDEX(int index) +{ + if( CHAR_FUNCTABLENUM <= index || index < 0 )return FALSE; + return TRUE; +} + +INLINE BOOL _CHAR_CHECKITEMINDEX( char *file, int line, int charaindex, int ti ) +{ + if( 0 <= ti && ti < CHAR_MAXITEMHAVE ) return TRUE; + return FALSE; +} + +static INLINE BOOL CHAR_CHECKSKILLINDEX( int skillindex ) +{ + if( skillindex<0 || CHAR_SKILLMAXHAVE <= skillindex )return FALSE; + return TRUE; +} +static INLINE BOOL CHAR_CHECKADDRESSBOOKINDEX( int aindex ) +{ + if( aindex < 0 || ADDRESSBOOK_MAX <= aindex ) return FALSE; + return TRUE; +} + +static INLINE BOOL CHAR_CHECKTITLEINDEX( int titleindex ) +{ + if( titleindex<0 || CHAR_TITLEMAXHAVE <= titleindex )return FALSE; + return TRUE; +} + +INLINE BOOL _CHAR_CHECKPETINDEX( char *file, int line, int petindex ) +{ + if( petindex < 0 || CHAR_MAXPETHAVE <= petindex ) { + if( petindex != -1 ) { + print( "err %s:%d \n", file, line); + } + return FALSE; + } + return TRUE; +} + +INLINE BOOL _CHAR_CHECKPOOLPETINDEX( char *file, int line, int petindex ) +{ + if( petindex < 0 || CHAR_MAXPOOLPETHAVE <= petindex ) { + + if( petindex != -1 ) { + print( "err %s:%d :%d \n", file, line, petindex); + } + return FALSE; + } + return TRUE; +} + +INLINE BOOL _CHAR_CHECKPETSKILLINDEX( char *file, int line, int havepetskillindex ) +{ + if( havepetskillindex < 0 || CHAR_MAXPETSKILLHAVE <= havepetskillindex ) { + if( havepetskillindex != -1 ) { + print( "err %s:%d \n", file, line); + } + return FALSE; + } + return TRUE; +} + +INLINE int CHAR_getIntStrict( int index ,CHAR_DATAINT element,int* error) +{ + if(!CHAR_CHECKINDEX(index))return *error=FALSE; + if(!CHAR_CHECKINTDATAINDEX(element))return *error=FALSE; + return CHAR_chara[index].data[element]; +} + +INLINE int CHAR_getInt( int index , CHAR_DATAINT element) +{ + return CHAR_chara[index].data[element]; +} + +INLINE int CHAR_setIntStrict( int index ,CHAR_DATAINT element,int data, + int* error) +{ + int buf; + if(!CHAR_CHECKINDEX(index))return *error=FALSE; + if(!CHAR_CHECKINTDATAINDEX(element))return *error=FALSE; + buf = CHAR_chara[index].data[element]; + CHAR_chara[index].data[element] = data; + return buf; +} + +INLINE int _CHAR_setInt( char *file, int line, int index ,CHAR_DATAINT element, int data) +{ + int buf; + if( !CHAR_CHECKINDEX( index) ) { + //print(" err CHAR_setInt index:%d. !:%s-%d\n", index, file, line); + return -1; + } + if( CHAR_DATAPLACENUMBER > element || element >= CHAR_DATAINTNUM ) { + print(" err CHAR_setInt element:%d.%s :%s-%d\n", element, CHAR_getChar( index, CHAR_CDKEY),file, line); + return -1; + } + buf = CHAR_chara[index].data[element]; + CHAR_chara[index].data[element] = data; + return buf; +} + +#ifdef _FIX_SETWORKINT +INLINE int _CHAR_getWorkInt( char *file, int line, int index ,CHAR_WORKDATAINT element) +#else +INLINE int CHAR_getWorkInt( int index ,CHAR_WORKDATAINT element) +#endif +{ + if( CHAR_WORKBATTLEMODE > element || element >= CHAR_WORKDATAINTNUM ) { + print("err Get WorkInt element=%d :: file:%s %d!\n", element, file, line); + return -1; + } + return CHAR_chara[index].workint[element]; +} + +#ifdef _FIX_SETWORKINT +INLINE int _CHAR_setWorkInt( char *file, int line, int index ,CHAR_WORKDATAINT element, int data) +#else +INLINE int CHAR_setWorkInt( int index ,CHAR_WORKDATAINT element, int data) +#endif +{ + int buf; + if( !CHAR_CHECKINDEX( index) ) { + //print( "err Set WorkInt index:%d:%s[%d].\n", index, file, line); + return -1; + } + if( CHAR_WORKBATTLEMODE > element || element >= CHAR_WORKDATAINTNUM ) { +#ifdef _FIX_SETWORKINT + print("err Set WorkInt element=%d.%s:%s[%d]!\n", element, CHAR_getChar( index, CHAR_CDKEY), file, line); +#else + print("err Set WorkInt element=%d.%s!\n", element, CHAR_getChar( index, CHAR_CDKEY) ); +#endif + return -1; + } + + buf = CHAR_chara[index].workint[element]; + CHAR_chara[index].workint[element] = data; + return buf; +} + +INLINE char* _CHAR_getChar( char *file, int line, int index ,CHAR_DATACHAR element ) +{ + if(!CHAR_CHECKINDEX(index)) { + print( "err _CHAR_getChar %s:%d index[%d] !!\n", file, line, index); + return NULL; + } + if(!CHAR_CHECKCHARDATAINDEX(element)) { + print( "err _CHAR_getChar %s:%d element[%d] !!\n", file, line, element); + return NULL; + } + return CHAR_chara[index].string[element].string; +} + +INLINE BOOL _CHAR_setChar( char *file, int line, int index ,CHAR_DATACHAR element, char* new ) +{ + if(!CHAR_CHECKINDEX(index)) { + print( "err _CHAR_setChar %s:%d !\n", file, line); + return FALSE; + } + if(!CHAR_CHECKCHARDATAINDEX(element)) { + print( "err _CHAR_setChar %s:%d !\n", file, line); + return FALSE; + } + strcpysafe( CHAR_chara[index].string[element].string, + sizeof(CHAR_chara[index].string[element].string), + new ); + return TRUE; +} + +static INLINE char* CHAR_getCharfunctable( int index ,CHAR_FUNCTABLE element ) +{ + if(!CHAR_CHECKINDEX(index))return NULL; + if(!CHAR_CHECKCHARFUNCTABLEINDEX(element))return NULL; + + + return CHAR_chara[index].charfunctable[element].string; +} + +INLINE char* _CHAR_getWorkChar( char *file, int line, int index ,CHAR_WORKDATACHAR element ) +{ + if(!CHAR_CHECKINDEX(index)) { + print( "err %s:%d \n", file, line); + return NULL; + } + if(!CHAR_CHECKCHARWORKDATAINDEX(element)) { + print( "err %s:%d \n", file, line); + return NULL; + } + return CHAR_chara[index].workchar[element].string; +} + +INLINE BOOL _CHAR_setWorkChar( char *file, int line, int index ,CHAR_WORKDATACHAR element, + char* new ) +{ + if(!CHAR_CHECKINDEX(index)) { + print( "err %s:%d \n", file, line); + return FALSE; + } + if(!CHAR_CHECKCHARWORKDATAINDEX(element)) { + print( "err %s:%d \n", file, line); + return FALSE; + } + strcpysafe( CHAR_chara[index].workchar[element].string, + sizeof(CHAR_chara[index].workchar[element].string), + new ); + return TRUE; +} + +static char CHAR_flgbitmaskpattern[]= +{ + 0x01, + 0x02, + 0x04, + 0x08, + 0x10, + 0x20, + 0x40, + 0x80, +}; + +INLINE BOOL _CHAR_getFlg( char *file, int line, int index ,CHAR_DATAFLG element ) +{ + int elementnum; + int bitnum; + if(!CHAR_CHECKINDEX(index)) { + //print( "err %s:%d from %s:%d \n", __FILE__, __LINE__,file, line); + return FALSE; + } + if(!CHAR_CHECKFLGDATAINDEX(element)) { + //print( "err %s:%d from %s:%d \n", __FILE__, __LINE__,file, line); + return FALSE; + } + elementnum = element / (sizeof( char )*8); + bitnum = element % (sizeof( char )*8); + + + if( CHAR_chara[index].flg[elementnum] + & CHAR_flgbitmaskpattern[bitnum]) + return TRUE; + else + return FALSE; + +} + +INLINE char _CHAR_setFlg( char *file, int line, int index , CHAR_DATACHAR element, int newdata ) +{ + int buf; + int elementnum; + int bitnum; + char bitpattern; + + if(!CHAR_CHECKINDEX(index)) { + print( "err %s:%d \n", file, line); + return FALSE; + } + if(!CHAR_CHECKFLGDATAINDEX(element)) { + print( "err %s:%d \n", file, line); + return FALSE; + } + elementnum = element / (sizeof( char )*8); + bitnum = element % (sizeof( char )*8); + + /* 樯及袄毛转 */ + buf = CHAR_chara[index].flg[elementnum] + & CHAR_flgbitmaskpattern[bitnum]; + + if( newdata != 0 ){ + bitpattern = CHAR_flgbitmaskpattern[bitnum]; + CHAR_chara[index].flg[elementnum] |= bitpattern; + + }else{ + bitpattern = ~CHAR_flgbitmaskpattern[bitnum]; + CHAR_chara[index].flg[elementnum] &= bitpattern; + } + + if( buf )return 1; + else return 0; +} + +INLINE int _CHAR_getItemIndex( char *file, int line, int charaindex ,int ti) +{ + if( !CHAR_CHECKINDEX( charaindex)) { + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__,file, line); + return -1; + } + if( !CHAR_CHECKITEMINDEX( charaindex, ti) ){ + print( "err %s:%d from %s:%d \n", __FILE__, __LINE__,file, line); + return -1; + } + return CHAR_chara[charaindex].indexOfExistItems[ti]; +} + +INLINE int _CHAR_setItemIndex( char *file, int line, int index ,int iindex,int id ) +{ + int buf; + if( !CHAR_CHECKINDEX(index)) { + print( "err %s:%d \n", file, line); + return -1; + } + if( CHAR_MAXITEMHAVE <= iindex || iindex < 0 ) { + print( "err %s:%d \n", file, line); + return -1; + } + +// CoolFish: 2001/10/12 +#ifdef _UNIQUE_P_I + if ( (id != -1) && (ITEM_getChar(id, ITEM_UNIQUECODE) != NULL) ) // shan add hjj + ITEM_setItemUniCode(id); +#endif + +#ifdef _ITEM_TIME_LIMIT + if( (id != -1) && ITEM_getWorkInt( id, ITEM_WORKTIMELIMIT) == -1 ){ + char *arg, *p=NULL, tmp[16]=""; + long iTmp; + time_t iTime; + + time(&iTime); + iTmp = iTime; + arg = ITEM_getChar( id, ITEM_ARGUMENT); + if(arg && (p=strstr( arg, "Time")) != NULL ){ + //andy_log + print("%s setTime arg:%s \n", ITEM_getChar( id, ITEM_NAME), arg); + strcpy( tmp, (p+4)); + iTmp += atoi(tmp)*60; + ITEM_setWorkInt( id, ITEM_WORKTIMELIMIT, iTmp); + } + } +#endif + buf = CHAR_chara[index].indexOfExistItems[iindex]; + CHAR_chara[index].indexOfExistItems[iindex] = id; + return buf; +} +INLINE int _CHAR_getPoolItemIndex( char *file, int line, int index ,int iindex) +{ + if( !CHAR_CHECKINDEX(index)) { + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__,file, line); + return -1; + } + if( CHAR_MAXPOOLITEMHAVE <= iindex || iindex < 0 ) { + print( "err %s:%d from %s:%d \n", __FILE__, __LINE__,file, line); + return -1; + } + return CHAR_chara[index].indexOfExistPoolItems[iindex]; +} +INLINE int _CHAR_setPoolItemIndex( char *file, int line, int index ,int iindex,int id ) +{ + int buf; + if( !CHAR_CHECKINDEX(index)) { + print( "err %s:%d \n", file, line); + return -1; + } + if( CHAR_MAXPOOLITEMHAVE <= iindex || iindex < 0 ) { + print( "err %s:%d \n", file, line); + return -1; + } + buf = CHAR_chara[index].indexOfExistPoolItems[iindex]; + CHAR_chara[index].indexOfExistPoolItems[iindex] = id; + return buf; +} + +INLINE BOOL CHAR_setAddressbookEntry( int index , int aindex , + ADDRESSBOOK_entry *a ) +{ + if( !CHAR_CHECKINDEX(index))return FALSE; + if( !CHAR_CHECKADDRESSBOOKINDEX( aindex ))return FALSE; + + memcpy( & CHAR_chara[index].addressBook[aindex] , a , + sizeof(ADDRESSBOOK_entry )); + + return TRUE; +} + +INLINE ADDRESSBOOK_entry* CHAR_getAddressbookEntry( int index , + int aindex) +{ + if( !CHAR_CHECKINDEX(index))return (ADDRESSBOOK_entry*)NULL; + if( !CHAR_CHECKADDRESSBOOKINDEX( aindex )) + return (ADDRESSBOOK_entry*) NULL; + + return &CHAR_chara[index].addressBook[aindex]; +} + +INLINE Char* CHAR_getCharPointer( int index ) +{ + if( !CHAR_CHECKINDEX(index) )return NULL; + return &CHAR_chara[index]; +} + +INLINE int CHAR_getCharNum( void ) +{ + return CHAR_charanum; +} + +INLINE int CHAR_getPlayerMaxNum( void ) +{ + return CHAR_playernum; +} + +INLINE int CHAR_getPetMaxNum( void ) +{ + return CHAR_petnum; +} +INLINE int CHAR_getOthersMaxNum( void ) +{ + return CHAR_othersnum; +} + +INLINE BOOL CHAR_getCharUse( int index ) +{ + if( !CHAR_CHECKINDEX(index)) + return FALSE; + return CHAR_chara[index].use; +} + +INLINE CHAR_HaveSkill* CHAR_getCharHaveSkill( int index,int sindex ) +{ + if( !CHAR_CHECKINDEX(index))return NULL; + if( !CHAR_CHECKSKILLINDEX(sindex))return NULL; + return &CHAR_chara[index].haveSkill[sindex]; +} +//------------------------------------------------------------------------ +//人物index 技能位置 索引 +INLINE int _CHAR_getIntPSkill( char *file, int line, int index, int skillti, SKILL_DATAINT ti) +{ + if( !CHAR_CHECKINDEX( index) ) return -1; + if( !CHAR_CHECKSKILLINDEX( skillti) ) return -1; + if( ti >= SKILL_DATAINTNUM || ti < 0 ){ + print(" getIntPSkill() SKILL_DATAINT (%d) err -%s:%d!!\n", ti , file, line); + return -1; + } + if( CHAR_chara[index].haveSkill[skillti].skill.data[ti] <= 0 ) return -1; + return CHAR_chara[index].haveSkill[skillti].skill.data[ti]; +} +//人物index 技能位置 索引 欲设定值 +INLINE void _CHAR_setIntPSkill( char *file, int line, int index, int skillti, SKILL_DATAINT ti, int data) +{ + if( !CHAR_CHECKINDEX( index) ) return; + if( !CHAR_CHECKSKILLINDEX( skillti) ) return; + if( ti >= SKILL_DATAINTNUM || ti < 0 ){ + print(" getIntPSkill() SKILL_DATAINT (%d) err -%s:%d!!\n", ti , file, line); + return; + } +// if( CHAR_chara[index].haveSkill[sindex].use > 0 ) + CHAR_chara[index].haveSkill[skillti].skill.data[ti] = data; +} +//------------------------------------------------------------------------ + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 +int CHAR_getCharSkill( int index,int sindex ) +{ + CHAR_HaveSkill* hskill; + + hskill = CHAR_getCharHaveSkill( index, sindex ); + + if(hskill != NULL) + return SKILL_getInt( &hskill->skill, SKILL_IDENTITY); + else + return -1; + +} + +int CHAR_setCharSkill( int index,int sindex, int new ) +{ + CHAR_HaveSkill* hskill; + + if( !CHAR_CHECKINDEX(index)) return -1; + if( !CHAR_CHECKSKILLINDEX(sindex)) return -1; + + hskill = CHAR_getCharHaveSkill( index, sindex ); + SKILL_setInt( &hskill->skill, SKILL_IDENTITY, new); + return TRUE; +} +#endif + +INLINE int CHAR_getCharHaveTitle( int charaindex,int tindex ) +{ + if( !CHAR_CHECKINDEX(charaindex))return 0; + if( !CHAR_CHECKTITLEINDEX(tindex))return 0; + return CHAR_chara[charaindex].indexOfHaveTitle[tindex]; +} + +INLINE int CHAR_setCharHaveTitle( int charaindex,int tindex, int new ) +{ + int ret; + if( !CHAR_CHECKINDEX(charaindex))return 0; + if( !CHAR_CHECKTITLEINDEX(tindex))return 0; + if( new != -1 ) + if( TITLE_getTitleIndex( new) == -1 ) return 0; + ret = CHAR_getCharHaveTitle( charaindex,tindex); + CHAR_chara[charaindex].indexOfHaveTitle[tindex] = new; + return ret; +} + +INLINE int CHAR_getCharPet( int charaindex,int petindex ) +{ + if( !CHAR_CHECKINDEX(charaindex))return -1; + if( !CHAR_CHECKPETINDEX(petindex))return -1; + return CHAR_chara[charaindex].unionTable.indexOfPet[petindex]; +} + +INLINE int CHAR_setCharPet( int charaindex,int petindex, int new ) +{ + int ret; + if( !CHAR_CHECKINDEX(charaindex))return -1; + if( !CHAR_CHECKPETINDEX(petindex))return -1; + ret = CHAR_getCharPet( charaindex,petindex); + +// CoolFish: 2001/10/12 +#ifdef _UNIQUE_P_I + if (new != -1) + CHAR_setPetUniCode(new); +#endif + + CHAR_chara[charaindex].unionTable.indexOfPet[petindex] = new; + return ret; +} + +INLINE int CHAR_getCharPoolPet( int charaindex,int petindex ) +{ + if( !CHAR_CHECKINDEX(charaindex))return -1; + if( !CHAR_CHECKPOOLPETINDEX(petindex))return -1; + return CHAR_chara[charaindex].indexOfPoolPet[petindex]; +} + +INLINE int CHAR_setCharPoolPet( int charaindex,int petindex, int new ) +{ + int ret; + if( !CHAR_CHECKINDEX(charaindex))return -1; + if( !CHAR_CHECKPOOLPETINDEX(petindex))return -1; + ret = CHAR_getCharPoolPet( charaindex,petindex); + + CHAR_chara[charaindex].indexOfPoolPet[petindex] = new; + return ret; +} + +int CHAR_getCharPetElement( int charaindex ) +{ + int i; + if( !CHAR_CHECKINDEX(charaindex))return -1; + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + if( CHAR_getCharPet( charaindex,i) == -1 ) break; + } + return ( i == CHAR_MAXPETHAVE ? -1:i ); + +} + +int CHAR_getCharPoolPetElement( int charaindex ) +{ + int i; + int limit; + if( !CHAR_CHECKINDEX(charaindex))return -1; + + //andy_reEdit 2003/09/18 + limit = (CHAR_getInt(charaindex,CHAR_TRANSMIGRATION)*2)+5; + limit = min( limit, CHAR_MAXPOOLPETHAVE); + for( i = 0; i < limit; i ++ ) { + if( CHAR_getCharPoolPet( charaindex,i) == -1 ) break; + } + return ( i == limit ? -1:i ); + +} + +int CHAR_getCharPoolItemIndexElement( int charaindex ) +{ + int i; + int limit; + if( !CHAR_CHECKINDEX(charaindex))return -1; + //andy_reEdit 2003/09/18 + limit = (CHAR_getInt(charaindex,CHAR_TRANSMIGRATION)*4)+10; + limit = min( limit, CHAR_MAXPOOLITEMHAVE); + for( i = 0; i < limit; i ++ ) { + if( CHAR_getPoolItemIndex( charaindex,i) == -1 ) break; + } + // Robin fix + //return ( i == CHAR_MAXPOOLITEMHAVE ? -1:i ); + return ( i >= limit ? -1:i ); + +} + +int CHAR_getEmptyCharPoolItemIndexNum( int charaindex) +{ + int i, cnt = 0; + int limit; + if( !CHAR_CHECKINDEX(charaindex))return 0; + //andy_reEdit 2003/09/18 + limit = (CHAR_getInt(charaindex,CHAR_TRANSMIGRATION)*4)+10; + limit = min( limit, CHAR_MAXPOOLITEMHAVE); + + for( i = 0; i < limit; i ++ ) { + if( CHAR_getPoolItemIndex( charaindex, i) == -1 ) cnt++; + } + return cnt; +} + +INLINE int _CHAR_getPetSkill( char *file, int line, int petindex, int havepetskillindex ) +{ + if( !CHAR_CHECKINDEX(petindex)) { + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__, file, line); + return -1; + } + if( !CHAR_CHECKPETSKILLINDEX(havepetskillindex)) { + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__, file, line); + return -1; + } + return CHAR_chara[petindex].unionTable.indexOfPetskill[havepetskillindex]; +} + +INLINE int _CHAR_setPetSkill( char *file, int line, int petindex,int havepetskillindex, int new ) +{ + int ret; + if( !CHAR_CHECKINDEX(petindex)) { + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__, file, line); + return -1; + } + if( !CHAR_CHECKPETSKILLINDEX(havepetskillindex)) { + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__, file, line); + return -1; + } + ret = CHAR_getPetSkill( petindex,havepetskillindex); + CHAR_chara[petindex].unionTable.indexOfPetskill[havepetskillindex] = new; + return ret; +} + +int _CHAR_getPetSkillElement( char *file, int line, int petindex ) +{ + int i; + if( !CHAR_CHECKINDEX(petindex)) { + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__, file, line); + return -1; + } + for( i = 0; i < CHAR_MAXPETSKILLHAVE; i ++ ) { + if( CHAR_getPetSkill( petindex,i) == -1 ) break; + } + return ( i == CHAR_MAXPETSKILLHAVE ? -1:i ); + +} + +INLINE int CHAR_getCharMakeSequenceNumber( int charaindex ) +{ + if( !CHAR_CHECKINDEX(charaindex))return -1; + return CHAR_chara[charaindex].CharMakeSequenceNumber; +} + +void CHAR_constructFunctable( int charaindex ) +{ + int i; + if( !CHAR_CHECKINDEX(charaindex))return; + for( i=CHAR_FIRSTFUNCTION; i < CHAR_LASTFUNCTION ; i++ ) + CHAR_chara[charaindex].functable[i-CHAR_FIRSTFUNCTION] + = getFunctionPointerFromName( CHAR_getCharfunctable( charaindex,i ) ); +} + +void* CHAR_getFunctionPointer( int charaindex, int functype ) +{ + if( !CHAR_CHECKINDEX(charaindex) )return NULL; + if( functype < CHAR_FIRSTFUNCTION || functype >= CHAR_LASTFUNCTION ) + return NULL; + + return CHAR_chara[charaindex].functable[functype]; +} + +BOOL CHAR_initCharArray( int pnum, int petnum,int onum ) +{ + int i; + + BOOL CHAR_checksetdata( void ); + if( CHAR_checksetdata() == FALSE ){ + print(" err CHAR_checksetdata() FALSE !!\n"); + return FALSE; + } + + //andy_log + print("#"); + + CHAR_initSeekGraphicNumberFromString(); + CHAR_initChatMagic(); + CHAR_charanum = pnum + petnum +onum; + + //andy_log + print("#"); + + CHAR_chara = allocateMemory( sizeof( Char ) * CHAR_charanum ); + if( CHAR_chara == NULL ){ + print("无法分配人物内存 !!\n"); + return FALSE; + } + + + //andy_log + print("人物内存: %4.2f...", ((float)sizeof( Char )*CHAR_charanum)/1024); + + for( i = 0 ; i < CHAR_charanum ; i ++ ){ + memset( &CHAR_chara[i], 0 , sizeof( Char )); + + } + for( i = 0 ; i < pnum ; i ++ ){ +#ifdef _NPC_SEPARATEDATA + CHAR_InitCharTempNum( &CHAR_chara[i] ); +#endif + } + CHAR_playernum = pnum; + CHAR_petnum = petnum; + CHAR_othersnum = onum; + + return TRUE; +} + +BOOL CHAR_endCharArray( void ) +{ +#ifdef _NPC_SEPARATEDATA + CHAR_EndCharTempNum(); +#endif + freeMemory( CHAR_chara ); + CHAR_charanum = 0; + return TRUE; +} + +BOOL CHAR_getCharOnArrayPercentage( int mode, int *max, int *min, int *cnt) +{ + int po=0, Dnums=0; + po = initCharCounter[0].endcnt; + *cnt = -1; + while( 1){ + if( !CHAR_chara[po].use ){ + }else{ + Dnums++; + } + po++; + if( po >= initCharCounter[mode].endcnt ){ + break; + } + } + *cnt = Dnums; + *max = initCharCounter[mode].endcnt - initCharCounter[mode].startcnt; + *min = 0; + + return TRUE; +} + +int CHAR_initCharOneArray( Char* ch ) +{ + int i; + int mode; + int ret = TRUE; + int first; + static unsigned int CharMakeSequenceNumber = 0; + if( initCharCounter[0].startcnt == -1 ) { + initCharCounter[0].startcnt = 0; + initCharCounter[0].cnt = initCharCounter[0].startcnt; + initCharCounter[0].endcnt = CHAR_playernum; + + initCharCounter[1].startcnt = initCharCounter[0].endcnt; + initCharCounter[1].cnt = initCharCounter[0].endcnt; + initCharCounter[1].endcnt = CHAR_playernum + CHAR_petnum; + + initCharCounter[2].startcnt = initCharCounter[1].endcnt; + initCharCounter[2].cnt = initCharCounter[1].endcnt; + initCharCounter[2].endcnt = CHAR_charanum; + } + if( ch->data[CHAR_WHICHTYPE] == CHAR_TYPEPLAYER ){ + mode = 0; + }else if( CHAR_TYPEPET == ch->data[CHAR_WHICHTYPE] ) { + mode = 1; + }else{ + mode = 2; + } + i = initCharCounter[mode].cnt; + first = TRUE; + while( 1 ){ + if( !first && i >= initCharCounter[mode].cnt ) { + ret = FALSE; + break; + } + if( CHAR_chara[i].use == FALSE ){ + ret = TRUE; + break; + }else{ + i++; + if( i >= initCharCounter[mode].endcnt ){ + i = initCharCounter[mode].startcnt; + first = FALSE; + } + } + } + if( ret ){ + typedef BOOL (*INITFUNC)(int index); + INITFUNC initfunc; + +#ifdef _NPC_SEPARATEDATA + ch->tempint = CHAR_chara[i].tempint; + CHAR_getDefaultCharTempNum( ch); +#endif + memset( &CHAR_chara[i] , 0, sizeof( Char ) ); + memcpy( &CHAR_chara[i] , ch , sizeof( Char ) ); + + initfunc = (INITFUNC)getFunctionPointerFromName( + ch->charfunctable[CHAR_INITFUNC].string ); + if( initfunc ) { + if( initfunc( i ) == FALSE ){ + CHAR_chara[i].use = FALSE; + ret = FALSE; + } + } + if( ret ){ + CHAR_chara[i].use = TRUE; + CHAR_constructFunctable( i ); + if( i + 1 >= initCharCounter[mode].endcnt ) { + initCharCounter[mode].cnt + = initCharCounter[mode].startcnt; + }else { + initCharCounter[mode].cnt = i+1; + } + CHAR_chara[i].CharMakeSequenceNumber = CharMakeSequenceNumber++; + if( CharMakeSequenceNumber == 0xffffffff) CharMakeSequenceNumber = 0; + } + }else{ + fprint( "Error: Char full\n" ); + } + return ret ? i: -1; +} + +void CHAR_removeHaveItem( Char* ch ) +{ + int i; + if( ch == NULL )return; + for( i=0 ; iindexOfExistItems[i]; + ch->indexOfExistItems[i] = -1; + ITEM_endExistItemsOne( itemindex ); + } +} + +void CHAR_removeHavePoolItem( Char* ch ) +{ + int i; + if( ch == NULL )return; + for( i=0 ; iindexOfExistPoolItems[i]; + ch->indexOfExistPoolItems[i] = -1; + ITEM_endExistItemsOne( itemindex ); + } +} + +void CHAR_endCharData( Char* ch ) +{ + if( ch == NULL ){ + return; + } + CHAR_removeHaveItem( ch ); + CHAR_removeHavePoolItem( ch); + +#ifdef _CHAR_POOLITEM +// CHAR_removeHaveDepotItem( ch ); +#endif +#ifdef _CHAR_POOLPET +// CHAR_removeHaveDepotPet( ch ); +#endif + + ch->use = FALSE; +} + +void CHAR_endCharOneArray( int index ) +{ + Char* ch = NULL; + if( !CHAR_CHECKINDEX( index) ) return; + ch = CHAR_getCharPointer(index); + + if( ch == NULL ){ + print( "CHAR_endCharOneArray err ch == NULL :%d\n", index); + return; + } + CHAR_endCharData( ch ); +} +static char CHAR_dataString[STRINGBUFSIZ*16*2]; +BOOL CHAR_checksetdata( void ) +{ + int i; + char* strings[CHAR_DATAINTNUM + CHAR_DATACHARNUM]; + int stringnum=0; + for(i = 0; i < CHAR_DATAINTNUM ; i ++ ){ + if( CHAR_setintdata[i][0] != '#' ) + strings[stringnum++] = CHAR_setintdata[i]; + } + for( i = 0 ; i < CHAR_DATACHARNUM ; i ++ ){ + if( CHAR_setchardata[i][0] != '#' ) + strings[stringnum++] = CHAR_setchardata[i]; + } + if( ! checkStringsUnique( strings, stringnum , 1 ) ){ + fprint( "set????data is overlapped.\nIt is not allowed\n"); + return FALSE; + } + return TRUE; +} + +#define FLGRESERVESTRING "flg" +#define ITEMRESERVESTRING "item" +#define POOLITEMRESERVESTRING "poolitem" +#define SKILLRESERVESTRING "skill" +#define TITLERESERVESTRING "title" +#define ADDRESSBOOKRESERVESTRING "adr" +#define PETSERVERSTRING "pet" +#define PETITEMRESERVESTRING "pitem" +#define PETSKILLSERVERSTRING "psk" +#define POOLPETSERVERSTRING "poolpet" +#define ITEMPOOLRESERVESTRING "itempool" + +#define DATAENDCHECKPOINT "DATAEND" + + + + +#ifdef _CHAR_POOLITEM +#define DEPOTITEMRESERVESTRING "Depotitem" +#endif +#ifdef _CHAR_POOLPET +#define DEPOTPETRESERVESTRING "Depotpet" +#endif + +char* CHAR_makeStringFromCharData( Char* one ) +{ + int i; + int petnum; + int strlength=0; + + if (!one) return NULL; + + memset( CHAR_dataString, 0, sizeof(CHAR_dataString)); + for( i = 0 ; i < CHAR_DATAINTNUM ; i ++ ){ + char linedata[256]; + snprintf( linedata , sizeof(linedata), + "%s=%d" CHAR_DELIMITER, + CHAR_setintdata[i], + one->data[i] ); + strcpysafe( &CHAR_dataString[strlength], + sizeof( CHAR_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_dataString ) ) { + fprint( "err chardata buffer over\n"); + goto RETURN; + } + } + for( i = 0 ; i < CHAR_DATACHARNUM ; i ++ ){ + char linedata[256]; + char escapebuffer[256]; + snprintf( linedata , sizeof(linedata), + "%s=%s" CHAR_DELIMITER, + CHAR_setchardata[i], + makeEscapeString( one->string[i].string, escapebuffer, + sizeof( escapebuffer) )); + + strcpysafe( &CHAR_dataString[strlength], + sizeof( CHAR_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_dataString ) ) { + fprint( "err chardata buffer over\n"); + goto RETURN; + } + } + for( i = 0 ; i < arraysizeof( one->flg ) ; i ++ ){ + char linedata[128]; + snprintf( linedata , sizeof(linedata), + FLGRESERVESTRING "%d=%d" CHAR_DELIMITER, + i, one->flg[i]); + + strcpysafe( &CHAR_dataString[strlength], + sizeof( CHAR_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_dataString ) ) { + fprint( "err chardata buffer over\n"); + goto RETURN; + } + } + + for( i = 0 ; i < CHAR_SKILLMAXHAVE ; i ++ ){ + char linedata[128]; + char *skillstring=NULL; + if( one->haveSkill[i].use == TRUE) + skillstring = SKILL_makeStringFromSkillData( + &one->haveSkill[i].skill ); + if( skillstring == NULL ) continue; + snprintf( linedata , sizeof( linedata ), + SKILLRESERVESTRING "%d=%s" CHAR_DELIMITER, + i,skillstring ); + strcpysafe( &CHAR_dataString[strlength], + sizeof( CHAR_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_dataString ) ) { + fprint( "err chardata buffer over\n"); + goto RETURN; + } + } + + for( i = 0 ; i < CHAR_MAXITEMHAVE ; i ++ ){ + char linedata[2048]; + char *itemstring=NULL; + if( one->indexOfExistItems[i] != -1 ) + itemstring = ITEM_makeStringFromItemIndex( + one->indexOfExistItems[i], 0); + if( itemstring == NULL )continue; + snprintf( linedata , sizeof( linedata ), + ITEMRESERVESTRING "%d=%s" CHAR_DELIMITER, + i, itemstring); + strcpysafe( &CHAR_dataString[strlength], + sizeof( CHAR_dataString ) - strlength, + linedata ); + + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_dataString ) ) { + fprint( "err chardata buffer over\n"); + goto RETURN; + } + } + + for( i = 0 ; i < CHAR_MAXPOOLITEMHAVE ; i ++ ){ + char linedata[2048]; + char *itemstring=NULL; + if( one->indexOfExistPoolItems[i] != -1 ) + itemstring = ITEM_makeStringFromItemIndex( + one->indexOfExistPoolItems[i], 0); + if( itemstring == NULL )continue; + snprintf( linedata , sizeof( linedata ), + POOLITEMRESERVESTRING "%d=%s" CHAR_DELIMITER, + i, itemstring); + strcpysafe( &CHAR_dataString[strlength], + sizeof( CHAR_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_dataString ) ) { + fprint( "err chardata buffer over\n"); + goto RETURN; + } + } + + for( i = 0 ; i < CHAR_TITLEMAXHAVE ; i ++ ){ + char linedata[128]; + if( one->indexOfHaveTitle[i]< 0 || one->indexOfHaveTitle[i] >= CHAR_TITLEMAXHAVE ) { + continue; + } + snprintf( linedata , sizeof( linedata ), + TITLERESERVESTRING "%d=%d" CHAR_DELIMITER, + i, one->indexOfHaveTitle[i] ); + strcpysafe( &CHAR_dataString[strlength], + sizeof( CHAR_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_dataString ) ) { + fprint( "err chardata buffer over\n"); + goto RETURN; + } + } + for( i=0 ; i < ADDRESSBOOK_MAX ; i++ ){ + char linedata[512]; + char *p; + p = ADDRESSBOOK_makeAddressbookString(&one->addressBook[i]); + if( strlen( p) == 0 ) { + continue; + } + snprintf( linedata ,sizeof(linedata), + ADDRESSBOOKRESERVESTRING "%d=%s" CHAR_DELIMITER, + i,p + ); + strcpysafe( &CHAR_dataString[strlength], + sizeof( CHAR_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_dataString ) ) { + fprint( "err chardata buffer over\n"); + goto RETURN; + } + } + for( petnum = 0; petnum < CHAR_MAXPETHAVE; petnum ++ ) { + int petindex; + char linedata[4096*2]; + char *petstring; + petindex = one->unionTable.indexOfPet[petnum]; + if( !CHAR_CHECKINDEX(petindex))continue; + petstring = CHAR_makePetStringFromPetIndex( petindex); + if( petstring == NULL ) continue; + snprintf( linedata , sizeof(linedata), + PETSERVERSTRING "%d=%s" CHAR_DELIMITER,petnum,petstring ); + strcpysafe( &CHAR_dataString[strlength], + sizeof( CHAR_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_dataString ) ) { + fprint( "err chardata buffer over\n"); + goto RETURN; + } + } + + for( petnum = 0; petnum < CHAR_MAXPOOLPETHAVE; petnum ++ ) { + int petindex; + char linedata[4096*2]; + char *petstring; + petindex = one->indexOfPoolPet[petnum]; + if( !CHAR_CHECKINDEX(petindex))continue; + petstring = CHAR_makePetStringFromPetIndex( petindex); + if( petstring == NULL ) continue; + + //andy_log + if( strstr( petstring, "name:") == NULL || + strstr( petstring, "ownt:") == NULL ) { + LodBadPetString( "petstring", "poolpet string buffer err:", petnum); + fprint( "ANDY err poolpet string buffer err:\n%s\n", petstring); + goto RETURN; + } + + snprintf( linedata , sizeof(linedata), + POOLPETSERVERSTRING "%d=%s" CHAR_DELIMITER,petnum,petstring ); + + strcpysafe( &CHAR_dataString[strlength], + sizeof( CHAR_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_dataString ) ) { + fprint( "err chardata buffer over\n"); + goto RETURN; + } + } +#ifdef _CHAR_FIXDATADEF + { + char linedata[1024]; + memset( linedata, 0, sizeof(linedata)); + snprintf( linedata , sizeof(linedata), + DATAENDCHECKPOINT "=%d" CHAR_DELIMITER, (int)time(NULL)/1000); + + strcpysafe( &CHAR_dataString[strlength], + sizeof( CHAR_dataString ) - strlength, linedata ); + + if( strlength > sizeof( CHAR_dataString ) ) { + LodBadPetString( "DATAENDCHECKPOINT", "err chardata buffer over", -1); + fprint( "err chardata buffer over:DATAENDCHECKPOINT !\n"); + goto MAKESTRINGERR; + } + } +#endif + +RETURN: + if( strstr( CHAR_dataString, DATAENDCHECKPOINT) == NULL ){ + LodBadPetString( CHAR_dataString, "err mk dataString no end", -1); + } + + return CHAR_dataString; +MAKESTRINGERR: + return NULL; +} + +char* CHAR_makeStringFromCharIndex( int index ) +{ + if( 0 <= index && index <= CHAR_charanum /* index OK*/ + && CHAR_chara[index].use == TRUE ) + /* OK */; + else + return NULL; + return CHAR_makeStringFromCharData(&CHAR_chara[index]); + +} + +BOOL CHAR_makeCharFromStringToArg( char* data, Char* one) +{ + int i; + int readindex=1, rightData=0; + + if( data[0] == '\0' ) + return FALSE; +DebugPoint=51; + { + char name[4096]; + char *sp = strstr( data, "name="); + char *sp2 = strstr( data, "ownt="); + if( sp && sp2 ){ + snprintf( name, sp2-sp-5, "%s", sp+5 ); + print("\n开始登陆人物名称:%s ", name ); + }else + print("\n开始登陆人物名称错误! "); + + if( data[strlen(data)-2] != '\n' ){ + print("\n 登陆错误!:%s ",data+strlen(data)-20 ); + } + + if( strlen(name) > 16 ){ + print("人物名称过长!! 人物名称:%s 长度:%d ", name ,strlen(name) ); + } + } + + memset( one , 0 , sizeof( Char )); +DebugPoint=52; + CHAR_getDefaultChar(one, 0); + // Robin 0726 default RidePet + one->data[CHAR_RIDEPET] = -1; + strcpysafe( one->string[CHAR_FMNAME].string, + sizeof( one->string[CHAR_FMNAME].string), "\0" ); + one->data[CHAR_FMINDEX] = -1; +#ifdef _PETSKILL_BECOMEPIG + one->data[CHAR_BECOMEPIG] = -1; + one->data[CHAR_BECOMEPIG_BBI] = 100250; +#endif + +DebugPoint=53; + while( 1 ){ + BOOL ret; + char linebuf[4096]; + char firstToken[256]; + char secondToken[4096]; + memset( linebuf, 0, sizeof( linebuf)); + memset( firstToken, 0, sizeof( firstToken)); + memset( secondToken, 0, sizeof( secondToken)); +DebugPoint=54; + ret = getStringFromIndexWithDelim( data ,CHAR_DELIMITER, + readindex, + linebuf, sizeof( linebuf ) ); +DebugPoint=55; + if( ret == FALSE )break; + if( linebuf[0] == '#' || + linebuf[0] == '\n' || + linebuf[0] == '\0' ){ + readindex ++; + continue; + } +DebugPoint=56; + ret = getStringFromIndexWithDelim( linebuf , "=" , 1 , + firstToken , + sizeof(firstToken) ); + if( ret == FALSE ) return FALSE; +DebugPoint=57; + strcpysafe( secondToken , sizeof( secondToken ), + linebuf + strlen(firstToken) + strlen("=") ); +DebugPoint=58; + for( i = 0 ; i < CHAR_DATAINTNUM ; i ++ ){ + if( strcmp(firstToken ,CHAR_setintdata[i] ) == 0 ){ + one->data[i] = atoi( secondToken ); + goto NEXT; + } + } +DebugPoint=59; + for( i = 0 ; i < CHAR_DATACHARNUM ; i ++ ){ + if( strcmp( firstToken ,CHAR_setchardata[i] ) == 0 ){ + strcpysafe( one->string[i].string, + sizeof(one->string[i].string), + makeStringFromEscaped(secondToken) ); + if( strlen( one->string[i].string ) > 128 ){ + print(" CHARDATA_to_long!!:%s:%d ", one->string[i].string, strlen( one->string[i].string ) ); + one->string[i].string[0]=0; + } + goto NEXT; + } + } +DebugPoint=60; + if( strncmp( firstToken , FLGRESERVESTRING, + strlen( FLGRESERVESTRING ) ) == 0 ){ + int flgindex; + flgindex = atoi( firstToken+strlen(FLGRESERVESTRING) ); + if( flgindex < 0 || arraysizeof( one->flg ) <= flgindex ) + ; + else + one->flg[flgindex] = atoi( secondToken ); + + goto NEXT; + } +DebugPoint=61; + if( strncmp( firstToken , ITEMRESERVESTRING, + strlen( ITEMRESERVESTRING ) ) == 0 ){ + int itemindex; + if( strcmp( secondToken, NULLITEM) == 0 ) + goto NEXT; + itemindex = atoi( firstToken+strlen(ITEMRESERVESTRING) ); + if( itemindex < 0 || CHAR_MAXITEMHAVE <= itemindex + || one->indexOfExistItems[itemindex] != -1 ){ + ; + }else{ + ITEM_Item itmone; + BOOL ret; + + ret = ITEM_makeExistItemsFromStringToArg( secondToken, &itmone, 0); + + if( ret == TRUE ){ + int existitemindex; + existitemindex = ITEM_initExistItemsOne( &itmone ); + one->indexOfExistItems[itemindex] = existitemindex; + } + } + goto NEXT; + } +DebugPoint=62; + if( strncmp( firstToken , POOLITEMRESERVESTRING, + strlen( POOLITEMRESERVESTRING ) ) == 0 ){ + int itemindex; + if( strcmp( secondToken, NULLITEM) == 0 ) + goto NEXT; + itemindex = atoi( firstToken+strlen(POOLITEMRESERVESTRING) ); + if( itemindex < 0 || CHAR_MAXPOOLITEMHAVE <= itemindex + || one->indexOfExistPoolItems[itemindex] != -1 ){ + ; + }else{ + ITEM_Item itmone; + BOOL ret; + ret = ITEM_makeExistItemsFromStringToArg( secondToken , &itmone, 0 ); + + if( ret == TRUE ){ + int existitemindex; + existitemindex = ITEM_initExistItemsOne( &itmone ); + one->indexOfExistPoolItems[itemindex] = existitemindex; + } + } + goto NEXT; + } +DebugPoint=63; + if( strncmp( firstToken , SKILLRESERVESTRING, + strlen( SKILLRESERVESTRING ) ) == 0 ){ + int skillindex; + if( strcmp( secondToken, NULLSKILL) == 0 ) + goto NEXT; + skillindex =atoi( firstToken+strlen(SKILLRESERVESTRING) ); + if( skillindex < 0 || CHAR_SKILLMAXHAVE <= skillindex + || one->haveSkill[skillindex].use == TRUE ){ + }else{ + BOOL ret; + Skill skillone; + ret=SKILL_makeSkillFromStringToArg(secondToken,&skillone); + + if( ret == TRUE ){ + memcpy( &one->haveSkill[skillindex].skill , &skillone, + sizeof( Skill )); + one->haveSkill[skillindex].use = TRUE; + } + } + goto NEXT; + } +DebugPoint=64; + if( strncmp( firstToken , TITLERESERVESTRING, + strlen( TITLERESERVESTRING ) ) == 0 ){ + int titlenumber=atoi(firstToken+strlen(TITLERESERVESTRING)); + if( titlenumber < 0 || CHAR_TITLEMAXHAVE <= titlenumber ){ + }else{ + int titleindex = atoi( secondToken ); + if( TITLE_getTitleIndex( titleindex) != -1) + one->indexOfHaveTitle[titlenumber] = titleindex; + } + goto NEXT; + } +DebugPoint=65; + if( strncmp( firstToken , ADDRESSBOOKRESERVESTRING, + strlen( ADDRESSBOOKRESERVESTRING ) ) == 0 ){ + int addressnumber = atoi( firstToken + +strlen(ADDRESSBOOKRESERVESTRING)); + if( addressnumber < 0 || ADDRESSBOOK_MAX <= addressnumber ){ + }else{ + ADDRESSBOOK_makeAddressbookEntry( secondToken, + &one + ->addressBook[ + addressnumber]); + } + goto NEXT; + } +DebugPoint=66; + if( strncmp( firstToken , PETSERVERSTRING, + strlen( PETSERVERSTRING ) ) == 0 ){ + Char ch; + int ret; + int petnumber = atoi( firstToken+strlen(PETSERVERSTRING)); + if( !CHAR_CHECKPETINDEX( petnumber)) goto NEXT; + ret = CHAR_makePetFromStringToArg(secondToken,&ch, petnumber); + if( ret == TRUE ){ + int petindex = PET_initCharOneArray( &ch ); + if( petindex < 0 ){ + print( "宠物制作失败。\n"); + } + one->unionTable.indexOfPet[petnumber] = petindex; + goto NEXT; + }else{ + LodBadPetString( data, "错误总计", petnumber); + + fprint( "错误 宠物字符串 无法作成\n"); + return FALSE; + } + } +DebugPoint=67; + if( strncmp( firstToken , POOLPETSERVERSTRING, strlen( POOLPETSERVERSTRING ) ) == 0 ){ + + Char ch; + int ret; + int petnumber = atoi( firstToken+strlen(POOLPETSERVERSTRING)); + if( !CHAR_CHECKPOOLPETINDEX( petnumber)) goto NEXT; + ret = CHAR_makePetFromStringToArg( secondToken, &ch, petnumber); + if( ret == TRUE ) { + int petindex = PET_initCharOneArray( &ch ); + if( petindex < 0 ) { + fprint( "错误 宠物 无法作成\n"); + } + one->indexOfPoolPet[petnumber] = petindex; + goto NEXT; + }else{ + LodBadPetString( data, "err *total", petnumber); + fprint( "错误 合成宠物字符串 无法作成\n"); + return FALSE; + } + } + + if( strncmp( firstToken , DATAENDCHECKPOINT, strlen( DATAENDCHECKPOINT ) ) == 0 ){ + rightData=1; + goto NEXT; + } + + + print( "??? : %s[%s]\n" , linebuf, firstToken ); + NEXT: + readindex++; + } +DebugPoint=68; + // Robin 0913 bad_chardata + { + char name[4096]; + char* sp = strstr( data, "name="); + // shan add + char *sp2 = strstr( data, "ownt="); + if( sp && sp2 ){ + snprintf( name, sp2-sp-5, "%s", sp+5 ); + print("\n登陆成功 人物名称:%s ", name ); + } + else + print("\n登陆成功 人物名称错误! "); + + if( data[strlen(data)-2] != '\n' ){ + print("\n玩家登陆出错! "); + //return FALSE; + } + } +// if( rightData != 1 ){ +// return FALSE; +// } + return TRUE; +} +static char CHAR_petdataString[4096]; + +char *CHAR_makePetStringFromPetIndex( int petindex) +{ + int i; + int strlength = 0; + + memset( CHAR_petdataString, 0, sizeof(CHAR_petdataString)); + + for( i = 0 ; i < CHAR_DATAINTNUM ; i ++ ){ + char linedata[512]; + +#ifdef _SIMPLIFY_PETSTRING + if( CHAR_getInt( petindex, i) == 0 ) continue; +#endif + snprintf( linedata , sizeof(linedata), + "%s:%d" NONCHAR_DELIMITER, CHAR_setintdata[i], CHAR_getInt( petindex,i) ); + strcpysafe( &CHAR_petdataString[strlength], + sizeof( CHAR_petdataString ) - strlength, linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_petdataString ) ) { + fprint( "err petdata buffer over\n"); + return NULL; + } + } + + for( i = 0 ; i < CHAR_DATACHARNUM ; i ++ ){ + char linedata[512]; + char escapebuffer[512]; +#ifdef _SIMPLIFY_PETSTRING + if( *CHAR_getChar( petindex, i) == NULL + && strcmp( CHAR_setchardata[i], "name") + && strcmp( CHAR_setchardata[i], "ownt") ) + continue; +#endif + snprintf( linedata , sizeof(linedata), + "%s:%s" NONCHAR_DELIMITER, + CHAR_setchardata[i], + makeEscapeString( CHAR_getChar(petindex, i), escapebuffer, + sizeof( escapebuffer) )); + + strcpysafe( &CHAR_petdataString[strlength], + sizeof( CHAR_petdataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_petdataString ) ) { + fprint( "错误 宠物数据缓冲不足\n"); + return NULL; + } + } + + for( i = 0; i < CHAR_MAXPETSKILLHAVE; i ++ ) { + int petskillid; + char linedata[512]; + petskillid = CHAR_getPetSkill( petindex, i); + if( PETSKILL_getPetskillArray( petskillid) == -1 ) continue; + snprintf( linedata , sizeof(linedata), + PETSKILLSERVERSTRING "%d:%d" NONCHAR_DELIMITER,i ,petskillid ); + strcpysafe( &CHAR_petdataString[strlength], + sizeof( CHAR_petdataString ) - strlength, linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_petdataString ) ) { + fprint( "错误 宠物数据缓冲不足\n"); + return NULL; + } + } + +#ifndef _SIMPLIFY_ITEMSTRING + for( i = 0 ; i < CHAR_MAXITEMHAVE ; i ++ ){ + char linedata[2048]; + char *itemstring=NULL; + if( CHAR_getItemIndex( petindex, i) != -1 ) + itemstring = ITEM_makeStringFromItemIndex( + CHAR_getItemIndex( petindex, i), 1); + if( itemstring == NULL )continue; + snprintf( linedata , sizeof( linedata ), + PETITEMRESERVESTRING "%d:%s" NONCHAR_DELIMITER, + i, itemstring); + strcpysafe( &CHAR_petdataString[strlength], + sizeof( CHAR_petdataString ) - strlength, + linedata ); + + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_petdataString ) ) { + fprint( "错误 宠物数据缓冲不足\n"); + return NULL; + } + } +#endif + + if( strstr( CHAR_petdataString, "name:") == NULL || + strstr( CHAR_petdataString, "ownt:") == NULL ){ + LodBadPetString( CHAR_petdataString, "名字 错误", -1); + } + return CHAR_petdataString; +} +void LodBadPetString( char *data, char *err, int ti) +{ + FILE *fp=NULL; + if( data == NULL || strlen( data) <= 0 ) return; + if( (fp=fopen( "badpetstring.txt", "a+")) == NULL ) return; + fprintf( fp, "ti:%d %s:%s\n", ti, err, data); + + fclose( fp); +} +int CHAR_makePetFromStringToArg( char *src, Char *ch, int ti) +{ + int readnum = 1; + int rc; + BOOL found; + char buff[4096]; + char petfirstToken[256]; + char petsecondToken[4096]; + int i, findE=0; + + memset( ch, 0, sizeof( Char)); + CHAR_getDefaultChar(ch, 31010); + + if( strstr( src, "name:") == NULL || + strstr( src, "ownt:") == NULL ){//findE + LodBadPetString( src, "make name err", ti); + fprint( "err PetString make name err\n"); + return -1; + } + + while( 1 ) { + rc = getStringFromIndexWithDelim( src, NONCHAR_DELIMITER, readnum, buff, sizeof( buff )); + if( rc == TRUE ) { + if( buff[0] == '#' || buff[0] == '\n' || buff[0] == '\0' ){ + readnum ++; + continue; + } + } + if( rc == TRUE ) { + readnum ++; + rc = getStringFromIndexWithDelim( buff , ":" , 1 , + petfirstToken , + sizeof(petfirstToken) ); + if( rc == FALSE ) break; + strcpysafe( petsecondToken , sizeof( petsecondToken ), + buff + strlen(petfirstToken) + strlen(":") ); +// rc = getStringFromIndexWithDelim( buff , ":" , 2 , +// petsecondToken , +// sizeof(petsecondToken) ); + + found = FALSE; + for( i = 0 ; i < CHAR_DATAINTNUM ; i ++ ){ + if( strcmp(petfirstToken ,CHAR_setintdata[i] ) == 0 ){ + ch->data[i] = atoi( petsecondToken ); + found = TRUE; + break; + } + } + if( !found ) { + for( i = 0 ; i < CHAR_DATACHARNUM ; i ++ ){ + if( strcmp( petfirstToken ,CHAR_setchardata[i] ) == 0 ){ + strcpysafe( ch->string[i].string, + sizeof(ch->string[i].string), + makeStringFromEscaped(petsecondToken) ); + found = TRUE; + findE = 1; + break; + } + } + } + if( !found) { +#ifndef _SIMPLIFY_ITEMSTRING + if( strncmp( petfirstToken , PETITEMRESERVESTRING, + strlen( PETITEMRESERVESTRING ) ) == 0 ) + { + int itemindex; + itemindex = atoi( petfirstToken+strlen(PETITEMRESERVESTRING) ); + if( itemindex < 0 || CHAR_MAXITEMHAVE <= itemindex + || ch->indexOfExistItems[itemindex] != -1 ){ + ; + }else{ + ITEM_Item itmone; + BOOL ret; + + ret = ITEM_makeExistItemsFromStringToArg( petsecondToken , + &itmone,1); + + if( ret == TRUE ){ + int existitemindex; + existitemindex = ITEM_initExistItemsOne( &itmone ); + ch->indexOfExistItems[itemindex] = existitemindex; + found = TRUE; + break; + } + } + } +#endif + + } + if( !found ) { + if( strncmp( petfirstToken , PETSKILLSERVERSTRING, + strlen( PETSKILLSERVERSTRING ) ) == 0 ){ + int petskillnum = atoi( petfirstToken + strlen( PETSKILLSERVERSTRING)); + if( CHAR_CHECKPETSKILLINDEX( petskillnum) ) { + int petskillid = atoi( petsecondToken ); + if( PETSKILL_getPetskillArray(petskillid) != -1) { + ch->unionTable.indexOfPetskill[petskillnum] = petskillid; + found = TRUE; + } + } + } + } + if( !found) { + fprint( "makePetFromString err?: %s : %s [%s] \n" , src, buff, petfirstToken ); + } + }else { + break; + } + } + + if( findE == 0 ){//findE + LodBadPetString( src, "make charstr err", ti); + fprint( "err PetString make charstr err\n"); + return -1; + } + + return TRUE; +} + +#ifdef _PERSONAL_FAME // Arminius 8.30: 家族个人声望 + +void CHAR_earnFame(int index, int fame) +{ + int oldfame=CHAR_getInt(index, CHAR_FAME)+fame; +#ifdef _NEW_MANOR_LAW + int momentum = CHAR_getInt(index,CHAR_MOMENTUM) + fame; +#endif + + if (oldfame>MAX_PERSONALFAME) oldfame=MAX_PERSONALFAME; + if (oldfame<0) oldfame=0; + CHAR_setInt(index, CHAR_FAME, oldfame); +#ifdef _NEW_MANOR_LAW + if(momentum > MAX_PERSONAL_MOMENTUM) momentum = MAX_PERSONAL_MOMENTUM; + else if(momentum < 0) momentum = 0; + CHAR_setInt(index,CHAR_MOMENTUM,momentum); +#endif +} +#endif + +// CoolFish: 2001/10/11 Unique Pet Code +#ifdef _UNIQUE_P_I +void CHAR_setPetUniCode(int petindex) +{ + if( strcmp( CHAR_getChar(petindex, CHAR_UNIQUECODE), "" ) == 0 || + strstr( CHAR_getChar(petindex, CHAR_UNIQUECODE), "_" ) != NULL || + strstr( CHAR_getChar(petindex, CHAR_UNIQUECODE), UNIQUE_KEYCODEPET ) == NULL ){ + char petbuf[256]; + time_t t1; + time(&t1); + sprintf(petbuf, "%ld%s%d%d", t1, UNIQUE_KEYCODEPET, getServernumber(), unique_p); + unique_p++; + if (unique_p >= MAX_UNIQUE_P_I) + unique_p = 0; + CHAR_setChar(petindex, CHAR_UNIQUECODE, petbuf); + } +} + +void ITEM_setItemUniCode(int itemindex) +{ + if( strcmp( ITEM_getChar(itemindex, ITEM_UNIQUECODE), "") == 0 || + strstr( ITEM_getChar(itemindex, ITEM_UNIQUECODE), "_") != NULL ){ + char itembuf[256]; + time_t t1; + time(&t1); + + sprintf(itembuf, "%ld%s%d%d%d", t1, "i", unique_i, getServernumber(), UNIQUE_KEYCODEITEM); + + unique_i++; + if (unique_i >= MAX_UNIQUE_P_I) + unique_i = 0; + ITEM_setChar(itemindex, ITEM_UNIQUECODE, itembuf); + } +} + +void CHAR_DetainSameItem( int charaindex, int itemindex) +{ + ITEM_setWorkInt( itemindex, ITEM_WORKCHARAINDEX, 100000); + ITEM_setWorkInt( itemindex, ITEM_WORKOBJINDEX, -1); + + LogItem( + CHAR_getChar( charaindex, CHAR_NAME), + CHAR_getChar( charaindex, CHAR_CDKEY), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), +#endif + "SysDeleteSame(系统删除重覆道具)", + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); +// ITEM_endExistItemsOne( itemindex); +} + +void CHAR_DetainSamePet( int charaindex, int petindex) +{ + CHAR_setWorkInt( petindex, CHAR_WORKPLAYERINDEX, 100000); + CHAR_setChar( petindex, CHAR_OWNERCDKEY, "SYS"); + CHAR_setChar( petindex, CHAR_OWNERCHARANAME, "SYS"); + CHAR_complianceParameter( petindex ); + LogPet( + CHAR_getChar( charaindex, CHAR_NAME), + CHAR_getChar( charaindex, CHAR_CDKEY), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "SysDeleteSame(删除重覆宠物)", + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y), + CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14 + ); +// CHAR_endCharOneArray( petindex ); +} + +void CHAR_DetainSameUCodePet( int charaindex, int petindex, int Ti) +{ + if( Ti == -1 ){ + int i; + for( i = 0; i < CHAR_MAXPETHAVE; i++ ) { + int pindex = CHAR_getCharPet( charaindex, i); + if( !CHAR_CHECKINDEX( pindex) ) continue; + if( pindex == petindex ) break; + } + if( i >= CHAR_MAXPETHAVE ) return; + CHAR_setCharPet( charaindex, i, -1); + }else{ + CHAR_setCharPet( charaindex, Ti, -1); + } + CHAR_DetainSamePet( charaindex, petindex); +} + +void CHAR_DetainSameUCodePoolPet( int charaindex, int petindex, int Ti) +{ + if( Ti == -1 ){ + int i; + for( i = 0; i < CHAR_MAXPETHAVE; i++ ) { + int pindex = CHAR_getCharPet( charaindex, i); + if( !CHAR_CHECKINDEX( pindex) ) continue; + if( pindex == petindex ) break; + } + if( i >= CHAR_MAXPETHAVE ) return; + CHAR_setCharPoolPet( charaindex, i, -1); + }else{ + CHAR_setCharPoolPet( charaindex, Ti, -1); + } + CHAR_DetainSamePet( charaindex, petindex); +} + +void CHAR_DetainSameUCodeItem( int charaindex, int itemindex, int Ti) +{ + if( Ti == -1 ){ + int i; + for( i = 0; i < CHAR_MAXITEMHAVE; i++ ) { + int iindex = CHAR_getItemIndex( charaindex, i); + if( !ITEM_CHECKINDEX( iindex) ) continue; + if( iindex == itemindex ) break; + } + if( i >= CHAR_MAXITEMHAVE ) return; + CHAR_setItemIndex( charaindex, i, -1); + }else{ + CHAR_setItemIndex( charaindex, Ti, -1); + } + CHAR_DetainSameItem( charaindex, itemindex); +} + +void CHAR_DetainSameUCodePoolItem( int charaindex, int itemindex, int Ti) +{ + if( Ti == -1 ){ + int i; + for( i = 0; i < CHAR_MAXPOOLITEMHAVE; i++ ) { + int iindex = CHAR_getPoolItemIndex( charaindex, i); + if( !ITEM_CHECKINDEX( iindex) ) continue; + if( iindex == itemindex ) break; + } + if( i >= CHAR_MAXPOOLITEMHAVE ) return; + CHAR_setPoolItemIndex( charaindex, i, -1); + }else{ + CHAR_setPoolItemIndex( charaindex, Ti, -1); + } + CHAR_DetainSameItem( charaindex, itemindex); +} + +void Check_P_I_UniCode( int charaindex) +{ +#ifdef _CHECK_UCODE + int i = 0, j = 0; + int petindex, itemindex; + + int MAXPLAYER = CHAR_getPlayerMaxNum(); + int MAXPET = CHAR_getPetMaxNum(); + int MAXITEM = ITEM_getITEM_itemnum(); + + for( i=0; i < CHAR_MAXPETHAVE; i++ ) { + petindex = CHAR_getCharPet( charaindex, i); + if( !CHAR_CHECKINDEX( petindex) ) continue; + for( j=MAXPLAYER; j CHAR_GetOldLevelExp( level+1) ){ + Myexp = 0; + }else if( Myexp >= defexp ){ + Myexp = Myexp - defexp; + } + if( Myexp < 0 ) Myexp = 0; + + CHAR_setInt( charaindex, CHAR_EXP, Myexp); + CHAR_setInt( charaindex, CHAR_OLDEXP, 0); + + CHAR_send_P_StatusString( charaindex ,CHAR_P_STRING_EXP|CHAR_P_STRING_LV); + return Myexp; +} + +INLINE int CHAR_HandleExp( int charaindex ) +{ + int needexp, level, Myexp; + if( !CHAR_CHECKINDEX( charaindex) ) return -1; + level = CHAR_getInt( charaindex, CHAR_LV); + Myexp = CHAR_getInt( charaindex, CHAR_EXP); + if( (needexp = CHAR_GetLevelExp( charaindex, level+1)) < 0 ) return -1; + Myexp = Myexp - needexp; + if( Myexp < 0 ) Myexp = 0; + CHAR_setInt( charaindex, CHAR_EXP, Myexp); + return Myexp; +} +#endif + +#ifdef _FIX_TSKILLCAN +BOOL CHAR_PETSKILLCAN( int toindex) +{ + int i, j, itemindex, petindex; + int FixItem[20]={ + 20270, 20271, 20272, 20273, 20274, + 20275, 20276, 20277, 20278, 20279, + 20280, 20281, 20282, 20283, 20284, + 20287, 20288, 20289, 20290, 20291 + }; + for (i = CHAR_STARTITEMARRAY; i < CHAR_MAXITEMHAVE; i ++) { + itemindex = CHAR_getItemIndex( toindex, i); + if( !ITEM_CHECKINDEX( itemindex)) continue; + for( j=0; j<20; j++){ + if( ITEM_getInt( itemindex, ITEM_ID) == FixItem[j] ){ + ITEM_setInt( itemindex, ITEM_CANMERGEFROM, 0); + } + } + if( ITEM_getInt( itemindex, ITEM_ID) != 1623 )continue; + CHAR_setItemIndex( toindex, i, -1 ); + ITEM_endExistItemsOne( itemindex); + CHAR_sendItemDataOne( toindex, i); + } + + for (i = 0; i < CHAR_MAXPOOLITEMHAVE; i++){ + int itemindex = CHAR_getPoolItemIndex(toindex, i); + if( !ITEM_CHECKINDEX( itemindex)) continue; + for( j=0; j<20; j++){ + if( ITEM_getInt( itemindex, ITEM_ID) == FixItem[j] ){ + ITEM_setInt( itemindex, ITEM_CANMERGEFROM, 0); + } + } + if( ITEM_getInt( itemindex, ITEM_ID) != 1623 )continue; + CHAR_setPoolItemIndex( toindex, i, -1); + ITEM_endExistItemsOne( itemindex); + } + + for( i=0; i < CHAR_MAXPETHAVE; i++) { + char szPet[128]; + BOOL Finds = FALSE; + petindex = CHAR_getCharPet( toindex, i); + if( !CHAR_CHECKINDEX( petindex) ) continue; + + {//清除狂暴攻击 + int j; + for( j=0; j (surplus*mypile) || itempile <= 0 ){ + return -1; + } + + if( mypile >= itempile ){ + ret = CHAR_addItemSpecificItemIndex( charaindex, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + ITEM_endExistItemsOne( itemindex); + return -1; + } + CHAR_sendItemDataOne( charaindex, ret); + }else{ + int newindex[10]={ -1,-1,-1,-1,-1, + -1,-1,-1,-1,-1}; + int i, ti=0, ItemID, MaxPile; + MaxPile = itempile; + ItemID = ITEM_getInt( itemindex, ITEM_ID); + while( MaxPile > 0 ){ + if( ti >= 10 ) return -1; + newindex[ti] = ITEM_makeItemAndRegist( ItemID); + if( !ITEM_CHECKINDEX( newindex[ti]) ) return -1; + if( mypile > MaxPile ) mypile = MaxPile; + ITEM_setInt( newindex[ti], ITEM_USEPILENUMS, mypile); + ti++; + MaxPile -= mypile; + if( MaxPile < 0 ) return -1; + } + for( i=0; i<10; i++ ){ + if( newindex[i] == -1 ) break; + ret = CHAR_addItemSpecificItemIndex( charaindex, newindex[i]); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + ITEM_endExistItemsOne( newindex[i]); + return -1; + } + CHAR_sendItemDataOne( charaindex, ret); + } + ITEM_endExistItemsOne( itemindex); + } + return ret; +#endif +} + + +INLINE int _CHAR_DelItem( char *file, int line, int charaindex, int ti, int num, int flg) +{ +// char token[256]; + int pilenum; + int itemindex = CHAR_getItemIndex( charaindex , ti ); + if( !ITEM_CHECKINDEX(itemindex) ) return 0; +#ifdef _ITEM_PILENUMS + pilenum = ITEM_getInt( itemindex, ITEM_USEPILENUMS); + if( pilenum < num ) return FALSE; + pilenum = pilenum - num; + ITEM_setInt( itemindex, ITEM_USEPILENUMS, pilenum); + if( pilenum <= 0 ){ +#endif +/* + if( flg == 1 ){ + sprintf( token, "交出%s。", ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + } +*/ + CHAR_setItemIndex( charaindex, ti, -1); + ITEM_endExistItemsOne( itemindex); +#ifdef _ITEM_PILENUMS + } +#endif + CHAR_sendItemDataOne( charaindex, ti); + + return 1; +} + +int CHAR_getMaxHaveGold( int charaindex) +{ + int MaxGold; +#ifdef _FIX_MAX_GOLD // WON ADD 增加人物金钱上限 + int trans = CHAR_getInt( charaindex, CHAR_TRANSMIGRATION); + MaxGold = 1000000 + trans*( 1800000); +#else + MaxGold = CHAR_MAXGOLDHAVE; +#endif + + return MaxGold; +} + +INLINE int _CHAR_AddGold( char *file, int line, int charaindex, int gold) +{ + char token[256]; + int MyGold, MaxGold; + + MaxGold = CHAR_getMaxHaveGold( charaindex); + MyGold = CHAR_getInt( charaindex, CHAR_GOLD); + MyGold = (MyGold>MaxGold)?MaxGold:MyGold; + gold = (gold>MaxGold)?MaxGold:gold; + sprintf( token, "得到%d石币", gold); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + MyGold += gold; + + if( MyGold > MaxGold ){ + int reGolds=0; + int MyGBGold = CHAR_getInt( charaindex, CHAR_PERSONAGOLD); + reGolds = MyGold - MaxGold; + MyGBGold += reGolds; + MyGBGold = (MyGBGold > CHAR_MAXPERSONAGOLD)?CHAR_MAXPERSONAGOLD:MyGBGold; + CHAR_setInt( charaindex, CHAR_PERSONAGOLD, MyGBGold); + sprintf( token,"存款:%d ,银行剩馀:%d 。", reGolds, CHAR_getInt( charaindex, CHAR_PERSONAGOLD )); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + LogBankStone( CHAR_getChar( charaindex, CHAR_NAME ), CHAR_getChar( charaindex, CHAR_CDKEY ), + charaindex, reGolds, + "GB_Bank_save(宝箱)", + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X ), CHAR_getInt( charaindex, CHAR_Y ), + CHAR_getInt( charaindex, CHAR_GOLD ), + CHAR_getInt( charaindex, CHAR_PERSONAGOLD ) + ); + MyGold = MaxGold; + } + CHAR_setInt( charaindex, CHAR_GOLD, MyGold); + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_GOLD); + + return 1; +} + +INLINE int _CHAR_DelGold( char *file, int line, int charaindex, int gold) +{ + char token[256]; + int MyGold, MaxGold; + + MaxGold = CHAR_getMaxHaveGold( charaindex); + MyGold = CHAR_getInt( charaindex, CHAR_GOLD); + MyGold = (MyGold>MaxGold)?MaxGold:MyGold; + gold = (gold>MaxGold)?MaxGold:gold; + + if( MyGold < gold ){ + sprintf( token, "没有足够的石币!(%d石币)", gold); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + return 0; + } + MyGold -= gold; + MyGold = ( MyGold < 0 )?0:MyGold; + CHAR_setInt( charaindex, CHAR_GOLD, MyGold); + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_GOLD); + return 1; +} + + +#ifdef _CHAR_POOLITEM +INLINE int _CHAR_getDepotItemIndex( char *file, int line, int index ,int iindex) +{ + if( !CHAR_CHECKINDEX(index)) { + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__,file, line); + return -1; + } + if( CHAR_MAXDEPOTITEMHAVE <= iindex || iindex < 0 ) { + print( "err %s:%d from %s:%d \n", __FILE__, __LINE__,file, line); + return -1; + } + + if( !CHAR_CheckDepotItem( index) ){ + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__,file, line); + return -1; + } + + return CHAR_chara[index].indexOfExistDepotItems[iindex]; +} + +INLINE int _CHAR_setDepotItemIndex( char *file, int line, int index ,int iindex,int id ) +{ + int buf; + if( !CHAR_CHECKINDEX(index)) { + print( "err %s:%d \n", file, line); + return -1; + } + if( CHAR_MAXDEPOTITEMHAVE <= iindex || iindex < 0 ) { + print( "err %s:%d \n", file, line); + return -1; + } + if( !CHAR_CheckDepotItem( index) ){ + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__,file, line); + return -1; + } + buf = CHAR_chara[index].indexOfExistDepotItems[iindex]; + CHAR_chara[index].indexOfExistDepotItems[iindex] = id; + return buf; +} +void CHAR_removeHaveDepotItem( Char* ch ) +{ + if( ch == NULL )return; + if( ch->indexOfExistDepotItems == NULL ) return; + freeMemory( ch->indexOfExistDepotItems ); + ch->indexOfExistDepotItems = NULL; +} + +void CHAR_removeDepotItem( int charaindex) +{ + int i,itemindex; + Char* ch = NULL; + if( !CHAR_CHECKINDEX( charaindex) ) return; + if( !CHAR_CheckDepotItem( charaindex) ) return; //仓库未存在 + ch = CHAR_getCharPointer( charaindex); + if( ch == NULL ){ + print( "removeDepotItem err ch == NULL :%d\n", charaindex); + return; + } + + for( i=0; iindexOfExistDepotItems[i]; + if( !ITEM_CHECKINDEX( itemindex) ) continue; + itemstring = ITEM_makeStringFromItemIndex( ch->indexOfExistDepotItems[i], 0); + if( itemstring == NULL )continue; + + snprintf( linedata , sizeof( linedata ), + DEPOTITEMRESERVESTRING "%d=%s" CHAR_DELIMITER, i, itemstring); + + strcpysafe( &CHAR_dataString[strlength], sizeof( CHAR_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_dataString ) ) { + return NULL; + } + } + return CHAR_dataString; +} + +BOOL CHAR_makeDepotItemStringToChar( int charaindex, char* data) +{ + int readindex=1, itemindex; + Char* ch = NULL; + BOOL ret; + char firstToken[256], secondToken[4096], linebuf[4096]; + + if( data[0] == '\0' ) + return -1; + if( !CHAR_CHECKINDEX( charaindex) ) return FALSE; + ch = CHAR_getCharPointer( charaindex); + if( ch == NULL ){ + print( "makeDepotItem err ch == NULL :%d\n", charaindex); + return FALSE; + } + + while( 1 ){ + memset( linebuf, 0, sizeof( linebuf)); + memset( firstToken, 0, sizeof( firstToken)); + memset( secondToken, 0, sizeof( secondToken)); + ret = getStringFromIndexWithDelim( data ,CHAR_DELIMITER, + readindex, linebuf, sizeof( linebuf ) ); + if( ret == FALSE )break; + if( linebuf[0] == '#' || linebuf[0] == '\n' || linebuf[0] == '\0' ){ + goto NEXT; + } + if( (ret=getStringFromIndexWithDelim( linebuf , "=" , 1 , + firstToken, sizeof(firstToken) )) == FALSE ) return FALSE; + strcpysafe( secondToken , sizeof( secondToken ), + linebuf + strlen( firstToken) + strlen("=") ); + + if( strncmp( firstToken, DEPOTITEMRESERVESTRING, strlen( DEPOTITEMRESERVESTRING)) == 0 ){ + if( strcmp( secondToken, NULLITEM) == 0 ) goto NEXT; + itemindex = atoi( firstToken+strlen(DEPOTITEMRESERVESTRING) ); + if( itemindex < 0 || CHAR_MAXDEPOTITEMHAVE <= itemindex + || ch->indexOfExistDepotItems[itemindex] != -1 ){ + ; + }else{ + ITEM_Item itmone; + ret = ITEM_makeExistItemsFromStringToArg( secondToken , &itmone, 0 ); + if( ret == TRUE ){ + int existitemindex; + existitemindex = ITEM_initExistItemsOne( &itmone ); + ch->indexOfExistDepotItems[itemindex] = existitemindex; + } + } + goto NEXT; + } + print( "??? : %s[%s]\n" , linebuf, firstToken ); +NEXT: + readindex++; + } + return TRUE; +} + +void CHAR_ShowMyDepotItems( int charaindex) +{ + int i, itemindex; + + print( "\nShowMyDepotItems:\n"); + if( !CHAR_CheckDepotItem( charaindex) ) return; + for( i=0; iindexOfExistDepotItems == NULL ) return FALSE; + return TRUE; +} + +#endif + + +#ifdef _CHAR_POOLPET +INLINE int _CHAR_getDepotPetIndex( char *file, int line, int index ,int iindex) +{ + if( !CHAR_CHECKINDEX(index)) { + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__,file, line); + return -1; + } + if( CHAR_MAXDEPOTPETHAVE <= iindex || iindex < 0 ) { + print( "err %s:%d from %s:%d \n", __FILE__, __LINE__,file, line); + return -1; + } + + if( !CHAR_CheckDepotPet( index) ){ + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__,file, line); + return -1; + } + + return CHAR_chara[index].indexOfExistDepotPets[iindex]; +} + +INLINE int _CHAR_setDepotPetIndex( char *file, int line, int index ,int iindex,int id ) +{ + int buf; + if( !CHAR_CHECKINDEX(index)) { + print( "err %s:%d \n", file, line); + return -1; + } + if( CHAR_MAXDEPOTPETHAVE <= iindex || iindex < 0 ) { + print( "err %s:%d \n", file, line); + return -1; + } + if( !CHAR_CheckDepotPet( index) ){ + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__,file, line); + return -1; + } + buf = CHAR_chara[index].indexOfExistDepotPets[iindex]; + CHAR_chara[index].indexOfExistDepotPets[iindex] = id; + return buf; +} +void CHAR_removeHaveDepotPet( Char* ch ) +{ + if( ch == NULL )return; + if( ch->indexOfExistDepotPets == NULL ) return; + freeMemory( ch->indexOfExistDepotPets ); + ch->indexOfExistDepotPets = NULL; +} + +void CHAR_removeDepotPet( int charaindex) +{ + int i,petindex; + Char* ch = NULL; + if( !CHAR_CHECKINDEX( charaindex) ) return; + if( !CHAR_CheckDepotPet( charaindex) ) return; //仓库未存在 + ch = CHAR_getCharPointer( charaindex); + if( ch == NULL ){ + print( "removeDepotPet err ch == NULL :%d\n", charaindex); + return; + } + + for( i=0; iindexOfExistDepotPets[i]; + if( !CHAR_CHECKINDEX( petindex) ) continue; + petstring = CHAR_makePetStringFromPetIndex( ch->indexOfExistDepotPets[i]); + if( petstring == NULL )continue; + + snprintf( linedata , sizeof( linedata ), + DEPOTPETRESERVESTRING "%d=%s" CHAR_DELIMITER, i, petstring); + + strcpysafe( &CHAR_dataString[strlength], sizeof( CHAR_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_dataString ) ) { + return NULL; + } + } + return CHAR_dataString; +} + +BOOL CHAR_makeDepotPetStringToChar( int charaindex, char* data) +{ + int readindex=1, petindex; + Char* ch = NULL; + BOOL ret; + char firstToken[256], secondToken[4096], linebuf[4096]; + + if( data[0] == '\0' ) + return -1; + if( !CHAR_CHECKINDEX( charaindex) ) return FALSE; + ch = CHAR_getCharPointer( charaindex); + if( ch == NULL ){ + print( "makeDepotPet err ch == NULL :%d\n", charaindex); + return FALSE; + } + + while( 1 ){ + memset( linebuf, 0, sizeof( linebuf)); + memset( firstToken, 0, sizeof( firstToken)); + memset( secondToken, 0, sizeof( secondToken)); + ret = getStringFromIndexWithDelim( data ,CHAR_DELIMITER, + readindex, linebuf, sizeof( linebuf ) ); + if( ret == FALSE )break; + if( linebuf[0] == '#' || linebuf[0] == '\n' || linebuf[0] == '\0' ){ + goto NEXT; + } + if( (ret=getStringFromIndexWithDelim( linebuf , "=" , 1 , + firstToken, sizeof(firstToken) )) == FALSE ) return FALSE; + strcpysafe( secondToken , sizeof( secondToken ), + linebuf + strlen( firstToken) + strlen("=") ); + + if( strncmp( firstToken, DEPOTPETRESERVESTRING, strlen( DEPOTPETRESERVESTRING)) == 0 ){ + if( strcmp( secondToken, NULLITEM) == 0 ) goto NEXT; + petindex = atoi( firstToken+strlen(DEPOTPETRESERVESTRING) ); + if( petindex < 0 || CHAR_MAXDEPOTPETHAVE <= petindex + || ch->indexOfExistDepotPets[petindex] != -1 ){ + ; + }else{ + Char petone; + ret = CHAR_makePetFromStringToArg( secondToken , &petone, 0 ); + if( ret == TRUE ){ + int existpetindex; + existpetindex = PET_initCharOneArray( &petone ); + ch->indexOfExistDepotPets[petindex] = existpetindex; + CHAR_setWorkInt( existpetindex, CHAR_WORKPLAYERINDEX, charaindex); + CHAR_complianceParameter( existpetindex); + } + } + goto NEXT; + } + print( "??? : %s[%s]\n" , linebuf, firstToken ); +NEXT: + readindex++; + } + return TRUE; +} + +void CHAR_ShowMyDepotPets( int charaindex) +{ + int i, petindex; + + print( "\nShowMyDepotPets:\n"); + if( !CHAR_CheckDepotPet( charaindex) ) return; + for( i=0; iindexOfExistDepotPets == NULL ) return FALSE; + return TRUE; +} + +#endif + + + +#ifdef _NPC_SEPARATEDATA +void CHAR_showTempInt( int index) +{ + int j; + CHAR_chara[index].tempint = allocateMemory( sizeof( int ) * 10 ); + //andy_log + print("\n CHAR_chara[%d].tempint: %x\n", index, CHAR_chara[index].tempint ); + for( j=0; j<10; j++){ + print("%d,", CHAR_chara[index].tempint[j] ); + } + //andy_log + print("]\n"); +} + +BOOL CHAR_InitCharTempNum( Char* ch ) +{ + int j; + ch->tempint = allocateMemory( sizeof( int ) * 10 ); + print("\n init temp:%x,", ch->tempint ); + for( j=0; j<10; j++){ + ch->tempint[j] = 0; + print("%d,", ch->tempint[j] ); + } + return TRUE; +} + +void CHAR_EndCharTempNum( void ) +{ + int i; + + for( i = 0 ; i < CHAR_charanum ; i ++ ){ + freeMemory( CHAR_chara[i].tempint ); + } + +} + +void CHAR_getDefaultCharTempNum( Char* ch ) +{ + int j; + if( ch->tempint == NULL ) return; + for( j=0; j<10; j++){ + ch->tempint[j] = -1; + print("%d,", ch->tempint[j] ); + } +} +#endif + +#ifdef _STREET_VENDOR +BOOL CHAR_setStreetVendor(int charindex,int index,int set,int num) +{ + if(!CHAR_CHECKINDEX(charindex)) return FALSE; + if(index < 0 || index > MAX_SELL_ITEM) return FALSE; + switch(set){ + case SV_PILE: + CHAR_chara[charindex].StreetVendor[index].pile = num; + break; + case SV_PRICE: + CHAR_chara[charindex].StreetVendor[index].price = num; + break; + case SV_INDEX: + CHAR_chara[charindex].StreetVendor[index].index = num; + break; + case SV_KIND: + CHAR_chara[charindex].StreetVendor[index].kind = num; + break; + } + CHAR_chara[charindex].StreetVendor[index].usage = TRUE; + return TRUE; +} + +INLINE void CHAR_clearStreetVendor(int charindex,int index) +{ + if(!CHAR_CHECKINDEX(charindex)) return; + if(index < 0 || index > MAX_SELL_ITEM) return; + CHAR_chara[charindex].StreetVendor[index].index = -1; + CHAR_chara[charindex].StreetVendor[index].price = 0; + CHAR_chara[charindex].StreetVendor[index].pile = 0; + CHAR_chara[charindex].StreetVendor[index].kind = -1; + CHAR_chara[charindex].StreetVendor[index].usage = FALSE; +} + +int CHAR_getStreetVendor(int charindex,int index,int set) +{ + if(!CHAR_CHECKINDEX(charindex)) return -1; + if(index < 0 || index > MAX_SELL_ITEM) return -1; + switch(set){ + case SV_PILE: + return CHAR_chara[charindex].StreetVendor[index].pile; + case SV_PRICE: + return CHAR_chara[charindex].StreetVendor[index].price; + case SV_INDEX: + return CHAR_chara[charindex].StreetVendor[index].index; + case SV_KIND: + return CHAR_chara[charindex].StreetVendor[index].kind; + case SV_USAGE: + return CHAR_chara[charindex].StreetVendor[index].usage; + } + return -1; +} +#endif + +#ifdef _CHAR_POOLPET +int CHAR_getCharDepotPetElement( int charaindex ) +{ + int i; + int limit; + if( !CHAR_CHECKINDEX(charaindex))return -1; + + //andy_reEdit 2003/09/18 + //limit = (CHAR_getInt(charaindex,CHAR_TRANSMIGRATION)*2)+5; + //limit = min( limit, CHAR_MAXPOOLPETHAVE); + limit = CHAR_MAXDEPOTPETHAVE; + for( i = 0; i < limit; i ++ ) { + if( CHAR_getDepotPetIndex( charaindex,i) == -1 ) break; + } + return ( i == limit ? -1:i ); +} +#endif diff --git a/gmsv/char/char_base.c.bak b/gmsv/char/char_base.c.bak new file mode 100644 index 0000000..870cffa --- /dev/null +++ b/gmsv/char/char_base.c.bak @@ -0,0 +1,3654 @@ +#include "version.h" +#include + +// CoolFish: 2001/10/12 _UNIQUE_P_I +#include + + +#include "char_base.h" +#include "char_data.h" +#include "item.h" +#include "buf.h" +#include "magic.h" +#include "function.h" +#include "npccreate.h" +#include "configfile.h" +#include "title.h" +#include "pet.h" +#include "pet_skill.h" +#include "anim_tbl.h" +#include "enemy.h" +#include "saacproto_cli.h" + +// CoolFish: 2001/10/29 +#include "log.h" + +Char* CHAR_chara; + +static int CHAR_charanum; +static int CHAR_playernum; +static int CHAR_petnum; +static int CHAR_othersnum; + +// CoolFish: 2001/10/11 +#ifdef _UNIQUE_P_I +#define MAX_UNIQUE_P_I 1000 +static int unique_p = 0; +static int unique_i = 0; +#endif + +typedef struct tagINITCHARCOUNTER{ + int startcnt; + int cnt; + int endcnt; +}INITCHARCOUNTER; +static INITCHARCOUNTER initCharCounter[3] = { + {-1,-1,-1},{-1,-1,-1},{-1,-1,-1} +}; + + +tagRidePetTable ridePetTable[122] = +{ + { 101000, 100000, 100352, 331 }, + { 101001, 100005, 100352, 331 }, + { 101002, 100010, 100352, 331 }, + { 101003, 100015, 100352, 331 }, + { 101004, 100000, 100329, 309 }, + { 101005, 100005, 100327, 307 }, + { 101006, 100010, 100330, 310 }, + { 101007, 100015, 100328, 308 }, + { 101008, 100700, 100372, 351 }, + { 101009, 100705, 100373, 352 }, + + { 101010, 100020, 100396, 483 }, + { 101011, 100025, 100396, 483 }, + { 101012, 100030, 100396, 483 }, + { 101013, 100035, 100396, 483 }, + { 101014, 100020, 100328, 308 }, + { 101015, 100025, 100329, 309 }, + { 101016, 100030, 100327, 307 }, + { 101017, 100035, 100330, 310 }, + { 101018, 100710, 100372, 351 }, + { 101019, 100715, 100373, 352 }, + + { 101020, 100040, 100351, 330 }, + { 101021, 100045, 100351, 330 }, + { 101022, 100050, 100351, 330 }, + { 101023, 100055, 100351, 330 }, + { 101024, 100040, 100328, 308 }, + { 101025, 100045, 100330, 310 }, + { 101026, 100050, 100327, 307 }, + { 101027, 100055, 100329, 309 }, + { 101028, 100720, 100372, 351 }, + { 101029, 100725, 100373, 352 }, + + { 101030, 100060, 100353, 332 }, + { 101031, 100065, 100353, 332 }, + { 101032, 100070, 100353, 332 }, + { 101033, 100075, 100353, 332 }, + { 101034, 100060, 100329, 309 }, + { 101035, 100065, 100327, 307 }, + { 101036, 100070, 100330, 310 }, + { 101037, 100075, 100328, 308 }, + { 101038, 100730, 100372, 351 }, + { 101039, 100735, 100373, 352 }, + + { 101040, 100080, 100396, 483 }, + { 101041, 100085, 100396, 483 }, + { 101042, 100090, 100396, 483 }, + { 101043, 100095, 100396, 483 }, + { 101044, 100080, 100328, 308 }, + { 101045, 100085, 100327, 307 }, + { 101046, 100090, 100330, 310 }, + { 101047, 100095, 100329, 309 }, + { 101048, 100740, 100372, 351 }, + { 101049, 100745, 100373, 352 }, + + { 101050, 100100, 100353, 332 }, + { 101051, 100105, 100353, 332 }, + { 101052, 100110, 100353, 332 }, + { 101053, 100115, 100353, 332 }, + { 101054, 100100, 100329, 309 }, + { 101055, 100105, 100328, 308 }, + { 101056, 100110, 100330, 310 }, + { 101057, 100115, 100327, 307 }, + { 101058, 100750, 100372, 351 }, + { 101059, 100755, 100373, 352 }, + + { 101060, 100120, 100354, 333 }, + { 101061, 100125, 100354, 333 }, + { 101062, 100130, 100354, 333 }, + { 101063, 100135, 100354, 333 }, + { 101064, 100120, 100327, 307 }, + { 101065, 100125, 100330, 310 }, + { 101066, 100130, 100328, 308 }, + { 101067, 100135, 100329, 309 }, + { 101068, 100760, 100372, 351 }, + { 101069, 100765, 100373, 352 }, + + { 101070, 100140, 100354, 333 }, + { 101071, 100145, 100354, 333 }, + { 101072, 100150, 100354, 333 }, + { 101073, 100155, 100354, 333 }, + { 101074, 100140, 100327, 307 }, + { 101075, 100145, 100329, 309 }, + { 101076, 100150, 100330, 310 }, + { 101077, 100155, 100328, 308 }, + { 101078, 100770, 100372, 351 }, + { 101079, 100775, 100373, 352 }, + + { 101080, 100160, 100352, 331 }, + { 101081, 100165, 100352, 331 }, + { 101082, 100170, 100352, 331 }, + { 101083, 100175, 100352, 331 }, + { 101084, 100160, 100330, 310 }, + { 101085, 100165, 100329, 309 }, + { 101086, 100170, 100327, 307 }, + { 101087, 100175, 100328, 308 }, + { 101088, 100780, 100372, 351 }, + { 101089, 100785, 100373, 352 }, + + { 101090, 100180, 100351, 330 }, + { 101091, 100185, 100351, 330 }, + { 101092, 100190, 100351, 330 }, + { 101093, 100195, 100351, 330 }, + { 101094, 100180, 100328, 308 }, + { 101095, 100185, 100330, 310 }, + { 101096, 100190, 100329, 309 }, + { 101097, 100195, 100327, 307 }, + { 101098, 100790, 100372, 351 }, + { 101099, 100795, 100373, 352 }, + + { 101100, 100200, 100353, 332 }, + { 101101, 100205, 100353, 332 }, + { 101102, 100210, 100353, 332 }, + { 101103, 100215, 100353, 332 }, + { 101104, 100200, 100329, 309 }, + { 101105, 100205, 100328, 308 }, + { 101106, 100210, 100327, 307 }, + { 101107, 100215, 100330, 310 }, + { 101108, 100800, 100372, 351 }, + { 101109, 100805, 100373, 352 }, + + { 101110, 100220, 100396, 483 }, + { 101111, 100225, 100396, 483 }, + { 101112, 100230, 100396, 483 }, + { 101113, 100235, 100396, 483 }, + { 101114, 100220, 100330, 310 }, + { 101115, 100225, 100327, 307 }, + { 101116, 100230, 100329, 309 }, + { 101117, 100235, 100328, 308 }, + { 101118, 100810, 100372, 351 }, + { 101119, 100815, 100373, 352 }, + + { 101179, 101177, 101178, 1804}, + { 101179, 101178, 101177, 1926}, +}; + +#ifdef _NEW_RIDEPETS + +tagRideCodeMode RideCodeMode[] = { + { 100374, RIDE_PET0 }, /*骑宠帖拉所伊朵*/ + { 100358, RIDE_PET1 }, /*骑宠巴朵兰恩*/ + { 100362, RIDE_PET2 }, /*骑宠左迪洛斯*/ + { 100279, RIDE_PET3 }, /*骑宠格尔格*/ + { 100288, RIDE_PET4 }, /*骑宠玛恩摩洛斯*/ + { 100283, RIDE_PET5 }, /*骑宠拉奇鲁哥*/ + { 100346, RIDE_PET6 }, /*骑宠卡达鲁卡斯*/ + { 100310, RIDE_PET7 }, /*骑宠扬奇洛斯*/ + { 100372, RIDE_PET8 }, /*骑宠卡卡金宝*/ + { 100373, RIDE_PET9 }, /*骑宠朵拉比斯*/ + { 101576, RIDE_PET10 }, /*镲宠罗多克雷*/ + { 101532, RIDE_PET11 }, /*骑宠史卡鲁*/ +}; + +tagRideNoList RideNoList[] = { + {{ 101305, 101306, 101307, 101308, 101309, 101310, 101311, 101312, 101008, 101009, 101989, 101978},0}, //小矮子 + {{ 101313, 101314, 101315, 101316, 101317, 101318, 101319, 101320, 101018, 101019, 101988, 101986},0}, //赛亚人 + {{ 101321, 101322, 101323, 101324, 101325, 101326, 101327, 101328, 101028, 101029, 101965, 101975},0}, //辫子男孩 + {{ 101329, 101330, 101331, 101332, 101333, 101334, 101335, 101336, 101038, 101039, 101966, 101976},0}, //酷哥 + {{ 101337, 101338, 101339, 101340, 101341, 101342, 101343, 101344, 101048, 101049, 101973, 101984},0}, //熊皮男 + {{ 101345, 101346, 101347, 101348, 101349, 101350, 101351, 101352, 101058, 101059, 101974, 101985},0}, //大个 + {{ 101353, 101354, 101355, 101356, 101357, 101358, 101359, 101360, 101068, 101069, 101967, 101977},0}, //小矮妹 + {{ 101361, 101362, 101363, 101364, 101365, 101366, 101367, 101368, 101078, 101079, 101968, 101979},0}, //熊皮妹 + {{ 101369, 101370, 101371, 101372, 101373, 101374, 101375, 101376, 101088, 101089, 101970, 101981},0}, //帽子妹 + {{ 101377, 101378, 101379, 101380, 101381, 101382, 101383, 101384, 101098, 101099, 101969, 101980},0}, //短法发夹妹 + {{ 101385, 101386, 101387, 101388, 101389, 101390, 101391, 101392, 101108, 101109, 101972, 101983},0}, //手套女 + {{ 101393, 101394, 101395, 101396, 101397, 101398, 101399, 101400, 101118, 101119, 101970, 101982},0}, //辣妹 +}; + +tagRidePetList RPlistMode[] = { + { 100000, 0, 1 }, { 100005, 0, 1 }, { 100010, 0, 1 }, { 100015, 0, 1 }, //小矮子 + { 100020, 1, 1 }, { 100025, 1, 1 }, { 100030, 1, 1 }, { 100035, 1, 1 }, //赛亚人 + { 100040, 2, 1 }, { 100045, 2, 1 }, { 100050, 2, 1 }, { 100055, 2, 1 }, //辫子男孩 + { 100060, 3, 1 }, { 100065, 3, 1 }, { 100070, 3, 1 }, { 100075, 3, 1 }, //酷哥 + { 100080, 4, 1 }, { 100085, 4, 1 }, { 100090, 4, 1 }, { 100095, 4, 1 }, //熊皮男 + { 100100, 5, 1 }, { 100105, 5, 1 }, { 100110, 5, 1 }, { 100115, 5, 1 }, //大个 + { 100120, 6, 2 }, { 100125, 6, 2 }, { 100130, 6, 2 }, { 100135, 6, 2 }, //小矮妹 + { 100140, 7, 2 }, { 100145, 7, 2 }, { 100150, 7, 2 }, { 100155, 7, 2 }, //熊皮妹 + { 100160, 8, 2 }, { 100165, 8, 2 }, { 100170, 8, 2 }, { 100175, 8, 2 }, //帽子妹 + { 100180, 9, 2 }, { 100185, 9, 2 }, { 100190, 9, 2 }, { 100195, 9, 2 }, //短发夹妹 + { 100200, 10, 2 }, { 100205, 10, 2 }, { 100210, 10, 2 }, { 100215, 10, 2 }, //手套女 + { 100220, 11, 2 }, { 100225, 11, 2 }, { 100230, 11, 2 }, { 100235, 11, 2 }, //辣妹 +}; + +int RIDEPET_getNOindex( int baseNo) +{ + int i; + for( i=0; i< sizeof(RPlistMode)/sizeof(tagRidePetList); i++ ) { + if( RPlistMode[i].charNo == baseNo ) { + return RPlistMode[i].Noindex; + } + } + return -1; +} + +int RIDEPET_getPETindex( int PetNo, int learnCode) +{ + int i; + for( i=0; i< sizeof(RideCodeMode)/sizeof(tagRideCodeMode); i++ ) { + if( RideCodeMode[i].petNo == PetNo && + (RideCodeMode[i].learnCode & learnCode) ) { + return i; + } + } + return -1; +} + +int RIDEPET_getRIDEno( int index, int ti) +{ + if( index < 0 || index >= sizeof( RideNoList)/sizeof( tagRideNoList) ) + return -1; + if( ti < 0 || ti >= MAXNOINDEX ) + return -1; + + return RideNoList[index].RideNo[ti]; +} +#endif + +#ifdef _EMENY_CHANCEMAN +int CHAR_getSexInt( int baseNo ) +{ + int i; + for( i=0; i< sizeof(RPlistMode)/sizeof(tagRidePetList); i++ ) { + if( RPlistMode[i].charNo == baseNo ) { + return RPlistMode[i].sex; + } + } + return -1; +} +#endif + +#ifdef _PET_EVOLUTION +#define MAXTABLE_X 29 +#define MAXTABLE_Y 29 +int PetTable[MAXTABLE_X][MAXTABLE_Y]={ + //0 4 9 14 19 24 + { 1, 2, 5, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 5, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5}, + { 2, 5, 1, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1}, + { 5, 1, 2, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2}, + { 1, 2, 5, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5}, + { 2, 5, 1, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1}, + + { 2, 1, 2, 1, 2, 2, 2, 5, 5, 1, 2, 5, 2, 1, 2, 1, 2, 5, 2, 1, 2, 1, 2, 5, 2, 5, 2, 1, 2}, + { 1, 2, 5, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 1}, + { 2, 5, 1, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 2}, + {10, 3,10, 3,10, 8,10, 8,10, 3,10, 3,10, 8,10, 8,10, 3,10, 3,10, 8,10, 8,10, 8,10, 3,10}, + { 3, 8, 3, 8, 3,10, 3,10, 8, 3, 3, 8, 3, 8, 3,10, 3,10, 3, 8, 3, 8, 3,10, 3,10, 3, 8, 3}, + + { 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8}, + { 5, 1, 5, 1, 5, 2, 5, 2, 5, 1, 5, 5, 5, 1, 5, 2, 5, 2, 5, 1, 5, 1, 5, 2, 5, 2, 5, 1, 5}, + { 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10}, + {10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3}, + { 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8}, + + { 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1}, + { 9, 0, 9, 0, 9, 4, 9, 4, 9, 0, 9, 0, 9, 4, 9, 4, 9, 0, 9, 0, 9, 4, 9, 4, 9, 0, 9, 4, 9}, + { 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2}, + { 6, 0, 6, 0, 6, 9, 6, 9, 6, 0, 6, 0, 6, 9, 6, 9, 6, 0, 6, 0, 6, 9, 6, 9, 6, 0, 6, 9, 6}, + { 4, 6, 4, 6, 4, 9, 4, 9, 4, 6, 4, 6, 4, 9, 4, 9, 4, 6, 4, 6, 4, 9, 4, 9, 4, 6, 4, 9, 4}, + + { 8, 3, 8, 3, 8,10, 8,10, 8, 3, 8, 3, 8,10, 8,10, 8, 3, 8, 3, 8,10, 8,10, 8, 3, 8,10, 8}, + { 8,10, 3, 8,10, 3, 8,10,10, 3, 8,10, 3, 8,10, 3,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10}, + { 1, 2, 5, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5}, + { 0, 4, 0, 4, 0, 6, 0, 6, 0, 4, 0, 4, 0, 6, 0, 6, 0, 4, 0, 4, 0, 6, 0, 4, 0, 6, 0, 4, 0}, + { 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2, 5, 1, 2}, + + { 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8}, + {10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3, 8,10, 3}, + { 2, 1, 2, 1, 5, 1, 5, 1, 2, 1, 2, 1, 5, 1, 5, 1, 2, 1, 2, 1, 5, 1, 5, 1, 2, 1, 2, 5, 1}, + { 6, 9, 6, 9, 6, 0, 6, 0, 6, 9, 6, 9, 6, 0, 6, 0, 6, 9, 6, 9, 6, 0, 6, 0, 6, 9, 6, 0, 6} +}; + +int PropertyTable[4][4]={ + { 0, 4, 5, 6}, + { 7, 1, 8, 9}, + {10,11, 2,12}, + {13,14,15, 3}, +}; +#define MAXFTABLE_X 11 +#define MAXFTABLE_Y 16 +int FusionTable[MAXFTABLE_X][MAXFTABLE_Y]={ + { 989, 990, 991, 992, 989, 992, 989, 990, 990, 990, 991, 991, 991, 992, 989, 992}, + {1001,1002,1003,1004,1001,1001,1004,1001,1002,1002,1003,1003,1003,1004,1004,1003}, + {1005,1006,1007,1008,1005,1005,1005,1006,1006,1006,1007,1006,1007,1008,1008,1008}, + {1021,1025,1023,1024,1025,1021,1021,1022,1022,1022,1023,1023,1023,1021,1024,1024}, + {1030,1031,1032,1033,1030,1030,1030,1031,1031,1031,1032,1031,1032,1030,1033,1033}, + {1017,1018,1019,1020,1018,1017,1017,1018,1019,1018,1019,1019,1020,1017,1020,1020}, + {1009,1010,1011,1012,1010,1009,1009,1010,1010,1010,1011,1011,1011,1012,1012,1011}, + { 993, 994, 995, 996, 994, 993, 993, 994, 995, 994, 995, 993, 996, 993, 996, 996}, + {1026,1027,1028,1029,1026,1026,1026,1026,1028,1027,1028,1028,1029,1029,1029,1029}, + { 997, 998, 999, 999,1000, 997, 997,1000, 998, 998,1000, 998, 999, 999, 999, 999}, + {1013,1014,1015,1016,1013,1013,1016,1013,1015,1014,1015,1015,1015,1016,1016,1016} +}; + +int EVOLUTION_getPetFusionCode( int petid) +{ + int petarray = ENEMYTEMP_getEnemyTempArrayFromTempNo( petid); + return ENEMYTEMP_getInt( petarray, E_T_FUSIONCODE); +} + +int EVOLUTION_getPetTable( int charaindex, int petindex1, int petindex2) +{ + int table1,table2; + + if( !CHAR_CHECKINDEX( petindex1) ) return -1; + if( !CHAR_CHECKINDEX( petindex2) ) return -1; + + table2 = EVOLUTION_getPetFusionCode( CHAR_getInt( petindex1, CHAR_PETID)); + table1 = EVOLUTION_getPetFusionCode( CHAR_getInt( petindex2, CHAR_PETID)); + + if( table1 < 0 || table1 >= MAXTABLE_X ) return -1; + if( table2 < 0 || table2 >= MAXTABLE_Y ) return -1; + return PetTable[table1][table2]; +} + +int EVOLUTION_getPropertyTable( int charaindex, int petindex1, int petindex2) +{ + int i, k1=0, k2=0; + int table1,table2; + int Property1[4]={-1,-1,-1,-1}; + int Property2[4]={-1,-1,-1,-1}; + + if( !CHAR_CHECKINDEX( petindex1) ) return -1; + if( !CHAR_CHECKINDEX( petindex2) ) return -1; + + for( i=0; i<4; i++) { + if( CHAR_getInt( petindex1, CHAR_EARTHAT+i) > 0 ){ + Property1[k1] = i; + k1++; + } + if( CHAR_getInt( petindex2, CHAR_EARTHAT+i) > 0 ){ + Property2[k2] = i; + k2++; + } + } + if( k1 == 0 || k2 == 0 ) return -1; + + if( k1 <= 1 ) { + table1 = Property1[ 0]; + }else{ + table1 = Property1[ (rand()%(k1-1)) ]; + } + if( k2 <= 1 ) { + table2 = Property2[ 0]; + }else { + table2 = Property2[ (rand()%(k2-1)) ]; + } + + if( table1 < 0 || table1 >= 4 ) return -1; + if( table2 < 0 || table2 >= 4 ) return -1; + + return PropertyTable[table1][table2]; +} + +int EVOLUTION_getFusionTable( int charaindex, int px, int py) +{ + if( px >= MAXFTABLE_X || px < 0 ) return -1; + if( py >= MAXFTABLE_Y || py < 0 ) return -1; + return FusionTable[px][py]; +} +#endif + +#ifdef _CHAR_FIXDATADEF +/* +typedef struct _tagPetSetIntData{ + char com[256]; + int type; +}PetSetIntData; + +PetSetIntData PET_SetIntData[ ]={ +}; +*/ +#endif + +static char* CHAR_setintdata[CHAR_DATAINTNUM]={ + /* dci , PLAYER, */ + "pn", /* CHAR_DATAPLACENUMBER */ + + "bi", /* CHAR_BASEIMAGENUMBER */ + "bbi", /* CHAR_BASEBASEIMAGENUMBER */ + "fb", /* CHAR_FACEIMAGENUMBER */ + "fl", /* CHAR_FLOOR */ + "x", /* CHAR_X */ + "y", /* CHAR_Y */ + "dir", /* CHAR_DIR 12凛毛0卞凛煌璃曰卞 */ + "lv", /* CHAR_LV */ + "gld", /* CHAR_GOLD */ + + "hp", /* CHAR_HP */ + "mp", /* CHAR_MP */ + "mmp", /* CHAR_MAXMP */ + + "vi", /* CHAR_VITAL */ + "str", /* CHAR_STR */ + "tou", /* CHAR_TOUGH */ + "dx", /* CHAR_DEX */ + + "chr", /* CHAR_CHARM */ + "luc", /* CHAR_LUCK */ + "aea", /* 哗箪岭 */ + "awa", /* 箪岭 */ + "afi", /* 绍箪岭 */ + "awi", /* 氘箪岭 */ + + "slt", /* CHAR_SLOT */ + "cr", /* CHAR_CRITIAL */ + "cou", /* CHAR_COUNTER */ + "rar", /* CHAR_RARE */ + "rst", /* CHAR_RADARSTRLENGTH */ + "cvo", /* CHAR_CHATVOLUME */ + "ml", /* CHAR_MERCHANTLEVEL */ + "hl", /* CHAR_HEALERLEVEL */ + "di", /* CHAR_DETERMINEITEM */ + "ieqt", /* CHAR_INDEXOFEQTITLE */ + "poi", /* CHAR_POISON */ + "par", /* CHAR_PARALYSIS */ + "sil", /* CHAR_SILENCE */ + "sto", /* CHAR_STONE */ + "dar", /* CHAR_DARKNESS */ + "con", /* CHAR_CONFUSION */ + "loc", /* CHAR_LOGINCOUNT */ + "dc", /* CHAR_DEADCOUNT */ + "wc", /* CHAR_WALKCOUNT */ + "tc", /* CHAR_TALKCOUNT */ + "dmc", /* CHAR_DAMAGECOUNT */ + "gpc", /* CHAR_GETPETCOUNT */ + "kpc", /* CHAR_KILLPETCOUNT */ + "dpc", /* CHAR_DEADPETCOUNT */ + "smc", /* CHAR_SENDMAILCOUNT */ + "mic", /* CHAR_MERGEITEMCOUNT */ + "dbc", /* CHAR_DUELBATTLECOUNT */ + "dwc", /* CHAR_DUELWINCOUNT */ + "dlc", /* CHAR_DUELLOSECOUNT */ + "dswc", /* CHAR_DUELSTWINCOUNT */ + "dmswc", /* CHAR_DUELMAXSTWINCOUNT */ + "wht", /* CHAR_WHICHTYPE */ + "wint", /* CHAR_WALKNTERVAL */ + "lint", /* CHAR_LOOPINTERVAL */ +#ifdef _NEWOPEN_MAXEXP + "exp", /* CHAR_OLDEXP */ + "nexp", /* CHAR_EXP */ +#else + "exp", /* CHAR_EXP */ +#endif + "lte", /* CHAR_LASTTALKELDER */ + "skup", /* CHAR_SKILLUPPOINT */ + "lvup", /* CHAR_LEVELUPPOINT */ + "ity", /* CHAR_IMAGETYPE */ + "nc", /* CHAR_NAMECOLOR */ + "pnc", /* CHAR_POPUPNAMECOLOR */ + "llt", /* CHAR_LASTTIMESETLUCK */ + "duel", /* CHAR_DUELPOINT */ + "evt", /* CHAR_EVENT */ + "evt2", /* CHAR_EVENT2 */ + "evt3", /* CHAR_EVENT3 */ +#ifdef _NEWEVENT + "evt4", /* CHAR_EVENT4 */ + "evt5", /* CHAR_EVENT5 */ + "evt6", /* CHAR_EVENT6 */ +#endif +#ifdef _ADD_NEWEVENT // WON 多增任务旗标 + "evt7", /* CHAR_EVENT7 */ + "evt8", // CHAR_ENDEVENT8, 224~255 精灵召唤专用 +#endif + + "nev", /* CHAR_NOWEVENT */ + "nev2", /* CHAR_NOWEVENT2 */ + "nev3", /* CHAR_NOWEVENT3 */ +#ifdef _NEWEVENT + "nev4", /* CHAR_NOWEVENT4 */ + "nev5", /* CHAR_NOWEVENT5 */ + "nev6", /* CHAR_NOWEVENT6 */ +#endif +#ifdef _ADD_NEWEVENT // WON 多增任务旗标 + "nev7", /* CHAR_NOWEVENT7 */ + "nev8", // CHAR_NOWEVENT8, 224~255 精灵召唤专用 +#endif + + "trn", /* CHAR_TRANSMIGRATION */ + "teq", /* CHAR_TRANSEQUATION */ + + "ini", /* CHAR_INITDATA */ + "silent", /* CHAR_SILENT */ + "fmi", // CoolFish: Family 2001/5/24 家族 index + "fmlf", // CoolFish: Family 2001/5/24 是否为家族族长 + "fmspr", // CoolFish: Family 2001/7/13 家族守护精灵 + + "bankgld", /* CHAR_BANKGOLD */ + "ridepet", /* CHAR_RIDEPET */ + "learnride", /* CHAR_LEARNRIDE */ +#ifdef _NEW_RIDEPETS + "lowridepet", //CHAR_LOWRIDEPETS +#endif + "limitlv", // Arminius 7.30 pet limit level +#ifdef _PET_FUSION + "fusioncode", //CHAR_FUSIONCODE + "fusionindex", //CHAR_FUSIONINDEX + "fusionraise", //CHAR_FUSIONRAISE + "fusionbe", //CHAR_FUSIONBEIT + "futimelimit", //CHAR_FUSIONTIMELIMIT +#endif +#ifdef _DEATH_CONTEND + "pkltnum", //CHAR_PKLISTTEAMNUM, + "pkleader", //CHAR_PKLISTLEADER, +#endif + +#ifdef _PERSONAL_FAME // Arminius 8.30: 家族个人声望 + "fame", +#endif + +#ifdef _NEWSAVE + "sindex", /* CHAR_SAVEINDEXNUMBER */ +#endif + +#ifdef __ATTACK_MAGIC + "earth_exp", // 玩家的地魔法熟练度 + "water_exp", // 玩家的水魔法熟练度 + "fire_exp", // 玩家的火魔法熟练度 + "wind_exp", // 玩家的风魔法熟练度 + "earth_resist", // 玩家的地魔法抗性 + "water_resist", // 玩家的水魔法抗性 + "fire_resist", // 玩家的火魔法抗性 + "wind_resist", // 玩家的风魔法抗性 + "earth_attmagic_exp", // 玩家的地魔法熟练度经验值 + "water_attmagic_exp", // 玩家的水魔法熟练度经验值 + "fire_attmagic_exp", // 玩家的火魔法熟练度经验值 + "wind_attmagic_exp", // 玩家的风魔法熟练度经验值 + "earth_defmagic_exp", // 玩家的地魔法抗性经验值 + "water_defmagic_exp", // 玩家的水魔法抗性经验值 + "fire_defmagic_exp", // 玩家的火魔法抗性经验值 + "wind_defmagic_exp", // 玩家的风魔法抗性经验值 +#endif + +#ifdef _GAMBLE_BANK //个人银行 + "personaglod", //CHAR_PERSONAGOLD, +#endif +#ifdef _DROPSTAKENEW + "gamblenums", //CHAR_GAMBLENUM +#endif +#ifdef _ADD_ACTION //npc动作 + "actsty", //CHAR_ACTIONSTYLE +#endif +#ifdef _AUCTIONEER + "aucgold", // CHAR_AUCGOLD 拍卖所得 +#endif +#ifdef _PET_EVOLUTION + "evbasevtl",// CHAR_EVOLUTIONBASE, + "evbasestr",// CHAR_EVOLUTIONBASE, + "evbasetgh",// CHAR_EVOLUTIONBASE, + "evbasedex",// CHAR_EVOLUTIONBASE, +#endif + +#ifdef _ACTION_BULLSCR + "abullstart", //CHAR_ABULLSTART + "abullscore", //CHAR_ABULLSCORE, + "abulltime", //CHAR_ABULLTIME, + "abullstarttime", //CHAR_ABULLSTARTTIME +#endif + +#ifdef _ACTION_GMQUE + "gmqueflg", //CHAR_GMQUEFLG, + "gmquenum", //CHAR_GMQUENUMS, +#endif + + +#ifdef _FAMILYBANKSTONELOG + "fmbankgold", //家族银行存款 +#endif + +#ifdef _FM_JOINLIMIT + "fmtimelimit", // CHAR_FMTIMELIMIT, +#endif + +#ifdef _CHAR_PROFESSION // WON ADD 人物职业 + "profession_class", + "profession_level", +// "profession_exp", + "profession_skill_point", + "attachpile", + "profession_fire_p", + "profession_ice_p", + "profession_thunder_p", + "profession_fire_r", + "profession_ice_r", + "profession_thunder_r", +#endif +#ifdef _ALLDOMAN // (不可开) Syu ADD 排行榜NPC + "herofloor", +#endif +#ifdef _PETSKILL_BECOMEPIG + "becomepig", + "becomepig_bbi", +#endif + "leavetime", // CHAR_LASTLEAVETIME +#ifdef _NEW_MANOR_LAW + "momentum", // CHAR_MOMENTUM +#endif + +#ifdef _ITEM_ADDEXP2 + "aexp", // CHAR_ADDEXPPOWER + "aexpt", // CHAR_ADDEXPTIME +#endif + +#ifdef _ANGEL_SUMMON + "herocnt", // CHAR_HEROCNT +#endif +#ifdef _TEACHER_SYSTEM + "tsf", // CHAR_TEACHER_FAME, // 导师领导声望 +#endif + +#ifdef _RACEMAN + "checkin", // CHAR_CHECKIN + "catchcnt1", // CHAR_CATCHCNT1 + "catchcnt2", // CHAR_CATCHCNT2 + "catchcnt3", // CHAR_CATCHCNT3 + "catchcnt4", // CHAR_CATCHCNT4 + "catchcnt5", // CHAR_CATCHCNT5 + "kindcnt1", //CHAR_KINDCNT1, /* (0~31) */ + "kindcnt2", //CHAR_KINDCNT2, /* (32~63) */ + "kindcnt3", //CHAR_KINDCNT3, /* (64~95) */ + "kindcnt4", //CHAR_KINDCNT4, /* (96~127) */ + "kindcnt5", //CHAR_KINDCNT5, /* (128~159) */ + "kindcnt6", //CHAR_KINDCNT6, /* (160~191) */ + "kindcnt7", //CHAR_KINDCNT7, /* (192~223) */ + "kindcnt8", //CHAR_KINDCNT8, /* (224~255) */ + "kindcnt9", //CHAR_KINDCNT9, /* (256~287) */ + "kindcnt10", //CHAR_KINDCNT10, /* (288~319) */ +#endif + +}; + +static char* CHAR_setchardata[CHAR_DATACHARNUM]={ + /* dcc , PLAYER */ + "name" , /* CHAR_NAME */ + "ownt" , /* CHAR_OWNTITLE*/ + "arg", /* CHAR_NPCARGUMENT */ + "ocd", /* CHAR_OWNERCDKEY */ + "ocn", /* CHAR_OWNERCHARANAME */ + "fmname", // CoolFish: Family 2001/5/24 家族名称 CHAR_FMNAME +#ifdef _UNIQUE_P_I + "ucode", // CoolFish: 2001/10/11 UNIQUE_P_I CHAR_UNIQUECODE +#endif +#ifdef _ACTION_GMQUE + //人物 npc 使用 + "gmque", //CHAR_GMQUESTR1, + //"temp2", //CHAR_GMQUESTR2, + //"temp3", //CHAR_GMQUESTR3, + //"temp4", //CHAR_GMQUESTR4, +#endif + +#ifdef _GM_IDENTIFY + "gmidentify", //gm名称 +#endif +#ifdef _TEACHER_SYSTEM + "tsi", // 导师帐号 + "tsn", // 导师名字 +#endif + +#ifdef _ITEM_SETLOVER + "love", // 结婚判断 + "lovrrid", // 爱人帐号 + "lovrrneme", // 爱人名字 +#endif +}; + +INLINE BOOL _CHAR_CHECKINDEX( char *file, int line, int index ) +{ + if( CHAR_charanum<=index || index<0 ) { + return FALSE; + } + if( CHAR_chara[(index)].use == FALSE ) { + return FALSE; + } + return TRUE; +} + +static INLINE BOOL CHAR_CHECKINTDATAINDEX(int index) +{ + if( CHAR_DATAINTNUM<=index || index<0 )return FALSE; + return TRUE; +} + +static INLINE BOOL CHAR_CHECKCHARDATAINDEX(int index) +{ + if( CHAR_DATACHARNUM<=index || index<0 )return FALSE; + return TRUE; +} + +static INLINE BOOL CHAR_CHECKFLGDATAINDEX( int index ) +{ + if( CHAR_FLGNUM<=index || index<0 )return FALSE; + return TRUE; +} + +static INLINE BOOL CHAR_CHECKCHARWORKDATAINDEX(int index) +{ + if( CHAR_WORKDATACHARNUM<=index || index<0 )return FALSE; + return TRUE; +} + +static INLINE BOOL CHAR_CHECKCHARFUNCTABLEINDEX(int index) +{ + if( CHAR_FUNCTABLENUM <= index || index < 0 )return FALSE; + return TRUE; +} + +INLINE BOOL _CHAR_CHECKITEMINDEX( char *file, int line, int charaindex, int ti ) +{ + if( 0 <= ti && ti < CHAR_MAXITEMHAVE ) return TRUE; + return FALSE; +} + +static INLINE BOOL CHAR_CHECKSKILLINDEX( int skillindex ) +{ + if( skillindex<0 || CHAR_SKILLMAXHAVE <= skillindex )return FALSE; + return TRUE; +} +static INLINE BOOL CHAR_CHECKADDRESSBOOKINDEX( int aindex ) +{ + if( aindex < 0 || ADDRESSBOOK_MAX <= aindex ) return FALSE; + return TRUE; +} + +static INLINE BOOL CHAR_CHECKTITLEINDEX( int titleindex ) +{ + if( titleindex<0 || CHAR_TITLEMAXHAVE <= titleindex )return FALSE; + return TRUE; +} + +INLINE BOOL _CHAR_CHECKPETINDEX( char *file, int line, int petindex ) +{ + if( petindex < 0 || CHAR_MAXPETHAVE <= petindex ) { + if( petindex != -1 ) { + print( "err %s:%d \n", file, line); + } + return FALSE; + } + return TRUE; +} + +INLINE BOOL _CHAR_CHECKPOOLPETINDEX( char *file, int line, int petindex ) +{ + if( petindex < 0 || CHAR_MAXPOOLPETHAVE <= petindex ) { + + if( petindex != -1 ) { + print( "err %s:%d :%d \n", file, line, petindex); + } + return FALSE; + } + return TRUE; +} + +INLINE BOOL _CHAR_CHECKPETSKILLINDEX( char *file, int line, int havepetskillindex ) +{ + if( havepetskillindex < 0 || CHAR_MAXPETSKILLHAVE <= havepetskillindex ) { + if( havepetskillindex != -1 ) { + print( "err %s:%d \n", file, line); + } + return FALSE; + } + return TRUE; +} + +INLINE int CHAR_getIntStrict( int index ,CHAR_DATAINT element,int* error) +{ + if(!CHAR_CHECKINDEX(index))return *error=FALSE; + if(!CHAR_CHECKINTDATAINDEX(element))return *error=FALSE; + return CHAR_chara[index].data[element]; +} + +INLINE int CHAR_getInt( int index , CHAR_DATAINT element) +{ + return CHAR_chara[index].data[element]; +} + +INLINE int CHAR_setIntStrict( int index ,CHAR_DATAINT element,int data, + int* error) +{ + int buf; + if(!CHAR_CHECKINDEX(index))return *error=FALSE; + if(!CHAR_CHECKINTDATAINDEX(element))return *error=FALSE; + buf = CHAR_chara[index].data[element]; + CHAR_chara[index].data[element] = data; + return buf; +} + +INLINE int _CHAR_setInt( char *file, int line, int index ,CHAR_DATAINT element, int data) +{ + int buf; + if( !CHAR_CHECKINDEX( index) ) { + print(" err CHAR_setInt index:%d. !:%s-%d\n", index, file, line); + return -1; + } + if( CHAR_DATAPLACENUMBER > element || element >= CHAR_DATAINTNUM ) { + print(" err CHAR_setInt element:%d.%s :%s-%d\n", element, CHAR_getChar( index, CHAR_CDKEY),file, line); + return -1; + } + buf = CHAR_chara[index].data[element]; + CHAR_chara[index].data[element] = data; + return buf; +} + +#ifdef _FIX_SETWORKINT +INLINE int _CHAR_getWorkInt( char *file, int line, int index ,CHAR_WORKDATAINT element) +#else +INLINE int CHAR_getWorkInt( int index ,CHAR_WORKDATAINT element) +#endif +{ + if( CHAR_WORKBATTLEMODE > element || element >= CHAR_WORKDATAINTNUM ) { + print("err Get WorkInt element=%d :: file:%s %d!\n", element, file, line); + return -1; + } + return CHAR_chara[index].workint[element]; +} + +#ifdef _FIX_SETWORKINT +INLINE int _CHAR_setWorkInt( char *file, int line, int index ,CHAR_WORKDATAINT element, int data) +#else +INLINE int CHAR_setWorkInt( int index ,CHAR_WORKDATAINT element, int data) +#endif +{ + int buf; + if( !CHAR_CHECKINDEX( index) ) { + print( "err Set WorkInt index:%d:%s[%d].\n", index, file, line); + return -1; + } + if( CHAR_WORKBATTLEMODE > element || element >= CHAR_WORKDATAINTNUM ) { +#ifdef _FIX_SETWORKINT + print("err Set WorkInt element=%d.%s:%s[%d]!\n", element, CHAR_getChar( index, CHAR_CDKEY), file, line); +#else + print("err Set WorkInt element=%d.%s!\n", element, CHAR_getChar( index, CHAR_CDKEY) ); +#endif + return -1; + } + + buf = CHAR_chara[index].workint[element]; + CHAR_chara[index].workint[element] = data; + return buf; +} + +INLINE char* _CHAR_getChar( char *file, int line, int index ,CHAR_DATACHAR element ) +{ + if(!CHAR_CHECKINDEX(index)) { + print( "err _CHAR_getChar %s:%d index[%d] !!\n", file, line, index); + return NULL; + } + if(!CHAR_CHECKCHARDATAINDEX(element)) { + print( "err _CHAR_getChar %s:%d element[%d] !!\n", file, line, element); + return NULL; + } + return CHAR_chara[index].string[element].string; +} + +INLINE BOOL _CHAR_setChar( char *file, int line, int index ,CHAR_DATACHAR element, char* new ) +{ + if(!CHAR_CHECKINDEX(index)) { + print( "err _CHAR_setChar %s:%d !\n", file, line); + return FALSE; + } + if(!CHAR_CHECKCHARDATAINDEX(element)) { + print( "err _CHAR_setChar %s:%d !\n", file, line); + return FALSE; + } + strcpysafe( CHAR_chara[index].string[element].string, + sizeof(CHAR_chara[index].string[element].string), + new ); + return TRUE; +} + +static INLINE char* CHAR_getCharfunctable( int index ,CHAR_FUNCTABLE element ) +{ + if(!CHAR_CHECKINDEX(index))return NULL; + if(!CHAR_CHECKCHARFUNCTABLEINDEX(element))return NULL; + + + return CHAR_chara[index].charfunctable[element].string; +} + +INLINE char* _CHAR_getWorkChar( char *file, int line, int index ,CHAR_WORKDATACHAR element ) +{ + if(!CHAR_CHECKINDEX(index)) { + print( "err %s:%d \n", file, line); + return NULL; + } + if(!CHAR_CHECKCHARWORKDATAINDEX(element)) { + print( "err %s:%d \n", file, line); + return NULL; + } + return CHAR_chara[index].workchar[element].string; +} + +INLINE BOOL _CHAR_setWorkChar( char *file, int line, int index ,CHAR_WORKDATACHAR element, + char* new ) +{ + if(!CHAR_CHECKINDEX(index)) { + print( "err %s:%d \n", file, line); + return FALSE; + } + if(!CHAR_CHECKCHARWORKDATAINDEX(element)) { + print( "err %s:%d \n", file, line); + return FALSE; + } + strcpysafe( CHAR_chara[index].workchar[element].string, + sizeof(CHAR_chara[index].workchar[element].string), + new ); + return TRUE; +} + +static char CHAR_flgbitmaskpattern[]= +{ + 0x01, + 0x02, + 0x04, + 0x08, + 0x10, + 0x20, + 0x40, + 0x80, +}; + +INLINE BOOL _CHAR_getFlg( char *file, int line, int index ,CHAR_DATAFLG element ) +{ + int elementnum; + int bitnum; + if(!CHAR_CHECKINDEX(index)) { + //print( "err %s:%d from %s:%d \n", __FILE__, __LINE__,file, line); + return FALSE; + } + if(!CHAR_CHECKFLGDATAINDEX(element)) { + //print( "err %s:%d from %s:%d \n", __FILE__, __LINE__,file, line); + return FALSE; + } + elementnum = element / (sizeof( char )*8); + bitnum = element % (sizeof( char )*8); + + + if( CHAR_chara[index].flg[elementnum] + & CHAR_flgbitmaskpattern[bitnum]) + return TRUE; + else + return FALSE; + +} + +INLINE char _CHAR_setFlg( char *file, int line, int index , CHAR_DATACHAR element, int newdata ) +{ + int buf; + int elementnum; + int bitnum; + char bitpattern; + + if(!CHAR_CHECKINDEX(index)) { + print( "err %s:%d \n", file, line); + return FALSE; + } + if(!CHAR_CHECKFLGDATAINDEX(element)) { + print( "err %s:%d \n", file, line); + return FALSE; + } + elementnum = element / (sizeof( char )*8); + bitnum = element % (sizeof( char )*8); + + /* 樯及袄毛转 */ + buf = CHAR_chara[index].flg[elementnum] + & CHAR_flgbitmaskpattern[bitnum]; + + if( newdata != 0 ){ + bitpattern = CHAR_flgbitmaskpattern[bitnum]; + CHAR_chara[index].flg[elementnum] |= bitpattern; + + }else{ + bitpattern = ~CHAR_flgbitmaskpattern[bitnum]; + CHAR_chara[index].flg[elementnum] &= bitpattern; + } + + if( buf )return 1; + else return 0; +} + +INLINE int _CHAR_getItemIndex( char *file, int line, int charaindex ,int ti) +{ + if( !CHAR_CHECKINDEX( charaindex)) { + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__,file, line); + return -1; + } + if( !CHAR_CHECKITEMINDEX( charaindex, ti) ){ + print( "err %s:%d from %s:%d \n", __FILE__, __LINE__,file, line); + return -1; + } + return CHAR_chara[charaindex].indexOfExistItems[ti]; +} + +INLINE int _CHAR_setItemIndex( char *file, int line, int index ,int iindex,int id ) +{ + int buf; + if( !CHAR_CHECKINDEX(index)) { + print( "err %s:%d \n", file, line); + return -1; + } + if( CHAR_MAXITEMHAVE <= iindex || iindex < 0 ) { + print( "err %s:%d \n", file, line); + return -1; + } + +// CoolFish: 2001/10/12 +#ifdef _UNIQUE_P_I + if ( (id != -1) && (ITEM_getChar(id, ITEM_UNIQUECODE) != NULL) ) // shan add hjj + ITEM_setItemUniCode(id); +#endif + +#ifdef _ITEM_TIME_LIMIT + if( (id != -1) && ITEM_getWorkInt( id, ITEM_WORKTIMELIMIT) == -1 ){ + char *arg, *p=NULL, tmp[16]=""; + long iTmp; + time_t iTime; + + time(&iTime); + iTmp = iTime; + arg = ITEM_getChar( id, ITEM_ARGUMENT); + if(arg && (p=strstr( arg, "Time")) != NULL ){ + //andy_log + print("%s setTime arg:%s \n", ITEM_getChar( id, ITEM_NAME), arg); + strcpy( tmp, (p+4)); + iTmp += atoi(tmp)*60; + ITEM_setWorkInt( id, ITEM_WORKTIMELIMIT, iTmp); + } + } +#endif + buf = CHAR_chara[index].indexOfExistItems[iindex]; + CHAR_chara[index].indexOfExistItems[iindex] = id; + return buf; +} +INLINE int _CHAR_getPoolItemIndex( char *file, int line, int index ,int iindex) +{ + if( !CHAR_CHECKINDEX(index)) { + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__,file, line); + return -1; + } + if( CHAR_MAXPOOLITEMHAVE <= iindex || iindex < 0 ) { + print( "err %s:%d from %s:%d \n", __FILE__, __LINE__,file, line); + return -1; + } + return CHAR_chara[index].indexOfExistPoolItems[iindex]; +} +INLINE int _CHAR_setPoolItemIndex( char *file, int line, int index ,int iindex,int id ) +{ + int buf; + if( !CHAR_CHECKINDEX(index)) { + print( "err %s:%d \n", file, line); + return -1; + } + if( CHAR_MAXPOOLITEMHAVE <= iindex || iindex < 0 ) { + print( "err %s:%d \n", file, line); + return -1; + } + buf = CHAR_chara[index].indexOfExistPoolItems[iindex]; + CHAR_chara[index].indexOfExistPoolItems[iindex] = id; + return buf; +} + +INLINE BOOL CHAR_setAddressbookEntry( int index , int aindex , + ADDRESSBOOK_entry *a ) +{ + if( !CHAR_CHECKINDEX(index))return FALSE; + if( !CHAR_CHECKADDRESSBOOKINDEX( aindex ))return FALSE; + + memcpy( & CHAR_chara[index].addressBook[aindex] , a , + sizeof(ADDRESSBOOK_entry )); + + return TRUE; +} + +INLINE ADDRESSBOOK_entry* CHAR_getAddressbookEntry( int index , + int aindex) +{ + if( !CHAR_CHECKINDEX(index))return (ADDRESSBOOK_entry*)NULL; + if( !CHAR_CHECKADDRESSBOOKINDEX( aindex )) + return (ADDRESSBOOK_entry*) NULL; + + return &CHAR_chara[index].addressBook[aindex]; +} + +INLINE Char* CHAR_getCharPointer( int index ) +{ + if( !CHAR_CHECKINDEX(index) )return NULL; + return &CHAR_chara[index]; +} + +INLINE int CHAR_getCharNum( void ) +{ + return CHAR_charanum; +} + +INLINE int CHAR_getPlayerMaxNum( void ) +{ + return CHAR_playernum; +} + +INLINE int CHAR_getPetMaxNum( void ) +{ + return CHAR_petnum; +} +INLINE int CHAR_getOthersMaxNum( void ) +{ + return CHAR_othersnum; +} + +INLINE BOOL CHAR_getCharUse( int index ) +{ + if( !CHAR_CHECKINDEX(index)) + return FALSE; + return CHAR_chara[index].use; +} + +INLINE CHAR_HaveSkill* CHAR_getCharHaveSkill( int index,int sindex ) +{ + if( !CHAR_CHECKINDEX(index))return NULL; + if( !CHAR_CHECKSKILLINDEX(sindex))return NULL; + return &CHAR_chara[index].haveSkill[sindex]; +} +//------------------------------------------------------------------------ +//人物index 技能位置 索引 +INLINE int _CHAR_getIntPSkill( char *file, int line, int index, int skillti, SKILL_DATAINT ti) +{ + if( !CHAR_CHECKINDEX( index) ) return -1; + if( !CHAR_CHECKSKILLINDEX( skillti) ) return -1; + if( ti >= SKILL_DATAINTNUM || ti < 0 ){ + print(" getIntPSkill() SKILL_DATAINT (%d) err -%s:%d!!\n", ti , file, line); + return -1; + } + if( CHAR_chara[index].haveSkill[skillti].skill.data[ti] <= 0 ) return -1; + return CHAR_chara[index].haveSkill[skillti].skill.data[ti]; +} +//人物index 技能位置 索引 欲设定值 +INLINE void _CHAR_setIntPSkill( char *file, int line, int index, int skillti, SKILL_DATAINT ti, int data) +{ + if( !CHAR_CHECKINDEX( index) ) return; + if( !CHAR_CHECKSKILLINDEX( skillti) ) return; + if( ti >= SKILL_DATAINTNUM || ti < 0 ){ + print(" getIntPSkill() SKILL_DATAINT (%d) err -%s:%d!!\n", ti , file, line); + return; + } +// if( CHAR_chara[index].haveSkill[sindex].use > 0 ) + CHAR_chara[index].haveSkill[skillti].skill.data[ti] = data; +} +//------------------------------------------------------------------------ + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 +int CHAR_getCharSkill( int index,int sindex ) +{ + CHAR_HaveSkill* hskill; + + hskill = CHAR_getCharHaveSkill( index, sindex ); + + if(hskill != NULL) + return SKILL_getInt( &hskill->skill, SKILL_IDENTITY); + else + return -1; + +} + +int CHAR_setCharSkill( int index,int sindex, int new ) +{ + CHAR_HaveSkill* hskill; + + if( !CHAR_CHECKINDEX(index)) return -1; + if( !CHAR_CHECKSKILLINDEX(sindex)) return -1; + + hskill = CHAR_getCharHaveSkill( index, sindex ); + SKILL_setInt( &hskill->skill, SKILL_IDENTITY, new); + return TRUE; +} +#endif + +INLINE int CHAR_getCharHaveTitle( int charaindex,int tindex ) +{ + if( !CHAR_CHECKINDEX(charaindex))return 0; + if( !CHAR_CHECKTITLEINDEX(tindex))return 0; + return CHAR_chara[charaindex].indexOfHaveTitle[tindex]; +} + +INLINE int CHAR_setCharHaveTitle( int charaindex,int tindex, int new ) +{ + int ret; + if( !CHAR_CHECKINDEX(charaindex))return 0; + if( !CHAR_CHECKTITLEINDEX(tindex))return 0; + if( new != -1 ) + if( TITLE_getTitleIndex( new) == -1 ) return 0; + ret = CHAR_getCharHaveTitle( charaindex,tindex); + CHAR_chara[charaindex].indexOfHaveTitle[tindex] = new; + return ret; +} + +INLINE int CHAR_getCharPet( int charaindex,int petindex ) +{ + if( !CHAR_CHECKINDEX(charaindex))return -1; + if( !CHAR_CHECKPETINDEX(petindex))return -1; + return CHAR_chara[charaindex].unionTable.indexOfPet[petindex]; +} + +INLINE int CHAR_setCharPet( int charaindex,int petindex, int new ) +{ + int ret; + if( !CHAR_CHECKINDEX(charaindex))return -1; + if( !CHAR_CHECKPETINDEX(petindex))return -1; + ret = CHAR_getCharPet( charaindex,petindex); + +// CoolFish: 2001/10/12 +#ifdef _UNIQUE_P_I + if (new != -1) + CHAR_setPetUniCode(new); +#endif + + CHAR_chara[charaindex].unionTable.indexOfPet[petindex] = new; + return ret; +} + +INLINE int CHAR_getCharPoolPet( int charaindex,int petindex ) +{ + if( !CHAR_CHECKINDEX(charaindex))return -1; + if( !CHAR_CHECKPOOLPETINDEX(petindex))return -1; + return CHAR_chara[charaindex].indexOfPoolPet[petindex]; +} + +INLINE int CHAR_setCharPoolPet( int charaindex,int petindex, int new ) +{ + int ret; + if( !CHAR_CHECKINDEX(charaindex))return -1; + if( !CHAR_CHECKPOOLPETINDEX(petindex))return -1; + ret = CHAR_getCharPoolPet( charaindex,petindex); + + CHAR_chara[charaindex].indexOfPoolPet[petindex] = new; + return ret; +} + +int CHAR_getCharPetElement( int charaindex ) +{ + int i; + if( !CHAR_CHECKINDEX(charaindex))return -1; + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + if( CHAR_getCharPet( charaindex,i) == -1 ) break; + } + return ( i == CHAR_MAXPETHAVE ? -1:i ); + +} + +int CHAR_getCharPoolPetElement( int charaindex ) +{ + int i; + int limit; + if( !CHAR_CHECKINDEX(charaindex))return -1; + + //andy_reEdit 2003/09/18 + limit = (CHAR_getInt(charaindex,CHAR_TRANSMIGRATION)*2)+5; + limit = min( limit, CHAR_MAXPOOLPETHAVE); + for( i = 0; i < limit; i ++ ) { + if( CHAR_getCharPoolPet( charaindex,i) == -1 ) break; + } + return ( i == limit ? -1:i ); + +} + +int CHAR_getCharPoolItemIndexElement( int charaindex ) +{ + int i; + int limit; + if( !CHAR_CHECKINDEX(charaindex))return -1; + //andy_reEdit 2003/09/18 + limit = (CHAR_getInt(charaindex,CHAR_TRANSMIGRATION)*4)+10; + limit = min( limit, CHAR_MAXPOOLITEMHAVE); + for( i = 0; i < limit; i ++ ) { + if( CHAR_getPoolItemIndex( charaindex,i) == -1 ) break; + } + // Robin fix + //return ( i == CHAR_MAXPOOLITEMHAVE ? -1:i ); + return ( i >= limit ? -1:i ); + +} + +int CHAR_getEmptyCharPoolItemIndexNum( int charaindex) +{ + int i, cnt = 0; + int limit; + if( !CHAR_CHECKINDEX(charaindex))return 0; + //andy_reEdit 2003/09/18 + limit = (CHAR_getInt(charaindex,CHAR_TRANSMIGRATION)*4)+10; + limit = min( limit, CHAR_MAXPOOLITEMHAVE); + + for( i = 0; i < limit; i ++ ) { + if( CHAR_getPoolItemIndex( charaindex, i) == -1 ) cnt++; + } + return cnt; +} + +INLINE int _CHAR_getPetSkill( char *file, int line, int petindex, int havepetskillindex ) +{ + if( !CHAR_CHECKINDEX(petindex)) { + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__, file, line); + return -1; + } + if( !CHAR_CHECKPETSKILLINDEX(havepetskillindex)) { + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__, file, line); + return -1; + } + return CHAR_chara[petindex].unionTable.indexOfPetskill[havepetskillindex]; +} + +INLINE int _CHAR_setPetSkill( char *file, int line, int petindex,int havepetskillindex, int new ) +{ + int ret; + if( !CHAR_CHECKINDEX(petindex)) { + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__, file, line); + return -1; + } + if( !CHAR_CHECKPETSKILLINDEX(havepetskillindex)) { + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__, file, line); + return -1; + } + ret = CHAR_getPetSkill( petindex,havepetskillindex); + CHAR_chara[petindex].unionTable.indexOfPetskill[havepetskillindex] = new; + return ret; +} + +int _CHAR_getPetSkillElement( char *file, int line, int petindex ) +{ + int i; + if( !CHAR_CHECKINDEX(petindex)) { + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__, file, line); + return -1; + } + for( i = 0; i < CHAR_MAXPETSKILLHAVE; i ++ ) { + if( CHAR_getPetSkill( petindex,i) == -1 ) break; + } + return ( i == CHAR_MAXPETSKILLHAVE ? -1:i ); + +} + +INLINE int CHAR_getCharMakeSequenceNumber( int charaindex ) +{ + if( !CHAR_CHECKINDEX(charaindex))return -1; + return CHAR_chara[charaindex].CharMakeSequenceNumber; +} + +void CHAR_constructFunctable( int charaindex ) +{ + int i; + if( !CHAR_CHECKINDEX(charaindex))return; + for( i=CHAR_FIRSTFUNCTION; i < CHAR_LASTFUNCTION ; i++ ) + CHAR_chara[charaindex].functable[i-CHAR_FIRSTFUNCTION] + = getFunctionPointerFromName( CHAR_getCharfunctable( charaindex,i ) ); +} + +void* CHAR_getFunctionPointer( int charaindex, int functype ) +{ + if( !CHAR_CHECKINDEX(charaindex) )return NULL; + if( functype < CHAR_FIRSTFUNCTION || functype >= CHAR_LASTFUNCTION ) + return NULL; + + return CHAR_chara[charaindex].functable[functype]; +} + +BOOL CHAR_initCharArray( int pnum, int petnum,int onum ) +{ + int i; + + BOOL CHAR_checksetdata( void ); + if( CHAR_checksetdata() == FALSE ){ + print(" err CHAR_checksetdata() FALSE !!\n"); + return FALSE; + } + + //andy_log + print("#"); + + CHAR_initSeekGraphicNumberFromString(); + CHAR_initChatMagic(); + CHAR_charanum = pnum + petnum +onum; + + //andy_log + print("#"); + + CHAR_chara = allocateMemory( sizeof( Char ) * CHAR_charanum ); + if( CHAR_chara == NULL ){ + print("无法分配人物内存 !!\n"); + return FALSE; + } + + + //andy_log + print("人物内存: %4.2f...", ((float)sizeof( Char )*CHAR_charanum)/1024); + + for( i = 0 ; i < CHAR_charanum ; i ++ ){ + memset( &CHAR_chara[i], 0 , sizeof( Char )); + + } + for( i = 0 ; i < pnum ; i ++ ){ +#ifdef _NPC_SEPARATEDATA + CHAR_InitCharTempNum( &CHAR_chara[i] ); +#endif + } + CHAR_playernum = pnum; + CHAR_petnum = petnum; + CHAR_othersnum = onum; + + return TRUE; +} + +BOOL CHAR_endCharArray( void ) +{ +#ifdef _NPC_SEPARATEDATA + CHAR_EndCharTempNum(); +#endif + freeMemory( CHAR_chara ); + CHAR_charanum = 0; + return TRUE; +} + +BOOL CHAR_getCharOnArrayPercentage( int mode, int *max, int *min, int *cnt) +{ + int po=0, Dnums=0; + po = initCharCounter[0].endcnt; + *cnt = -1; + while( 1){ + if( !CHAR_chara[po].use ){ + }else{ + Dnums++; + } + po++; + if( po >= initCharCounter[mode].endcnt ){ + break; + } + } + *cnt = Dnums; + *max = initCharCounter[mode].endcnt - initCharCounter[mode].startcnt; + *min = 0; + + return TRUE; +} + +int CHAR_initCharOneArray( Char* ch ) +{ + int i; + int mode; + int ret = TRUE; + int first; + static unsigned int CharMakeSequenceNumber = 0; + if( initCharCounter[0].startcnt == -1 ) { + initCharCounter[0].startcnt = 0; + initCharCounter[0].cnt = initCharCounter[0].startcnt; + initCharCounter[0].endcnt = CHAR_playernum; + + initCharCounter[1].startcnt = initCharCounter[0].endcnt; + initCharCounter[1].cnt = initCharCounter[0].endcnt; + initCharCounter[1].endcnt = CHAR_playernum + CHAR_petnum; + + initCharCounter[2].startcnt = initCharCounter[1].endcnt; + initCharCounter[2].cnt = initCharCounter[1].endcnt; + initCharCounter[2].endcnt = CHAR_charanum; + } + if( ch->data[CHAR_WHICHTYPE] == CHAR_TYPEPLAYER ){ + mode = 0; + }else if( CHAR_TYPEPET == ch->data[CHAR_WHICHTYPE] ) { + mode = 1; + }else{ + mode = 2; + } + i = initCharCounter[mode].cnt; + first = TRUE; + while( 1 ){ + if( !first && i >= initCharCounter[mode].cnt ) { + ret = FALSE; + break; + } + if( CHAR_chara[i].use == FALSE ){ + ret = TRUE; + break; + }else{ + i++; + if( i >= initCharCounter[mode].endcnt ){ + i = initCharCounter[mode].startcnt; + first = FALSE; + } + } + } + if( ret ){ + typedef BOOL (*INITFUNC)(int index); + INITFUNC initfunc; + +#ifdef _NPC_SEPARATEDATA + ch->tempint = CHAR_chara[i].tempint; + CHAR_getDefaultCharTempNum( ch); +#endif + memset( &CHAR_chara[i] , 0, sizeof( Char ) ); + memcpy( &CHAR_chara[i] , ch , sizeof( Char ) ); + + initfunc = (INITFUNC)getFunctionPointerFromName( + ch->charfunctable[CHAR_INITFUNC].string ); + if( initfunc ) { + if( initfunc( i ) == FALSE ){ + CHAR_chara[i].use = FALSE; + ret = FALSE; + } + } + if( ret ){ + CHAR_chara[i].use = TRUE; + CHAR_constructFunctable( i ); + if( i + 1 >= initCharCounter[mode].endcnt ) { + initCharCounter[mode].cnt + = initCharCounter[mode].startcnt; + }else { + initCharCounter[mode].cnt = i+1; + } + CHAR_chara[i].CharMakeSequenceNumber = CharMakeSequenceNumber++; + if( CharMakeSequenceNumber == 0xffffffff) CharMakeSequenceNumber = 0; + } + }else{ + fprint( "Error: Char full\n" ); + } + return ret ? i: -1; +} + +void CHAR_removeHaveItem( Char* ch ) +{ + int i; + if( ch == NULL )return; + for( i=0 ; iindexOfExistItems[i]; + ch->indexOfExistItems[i] = -1; + ITEM_endExistItemsOne( itemindex ); + } +} + +void CHAR_removeHavePoolItem( Char* ch ) +{ + int i; + if( ch == NULL )return; + for( i=0 ; iindexOfExistPoolItems[i]; + ch->indexOfExistPoolItems[i] = -1; + ITEM_endExistItemsOne( itemindex ); + } +} + +void CHAR_endCharData( Char* ch ) +{ + if( ch == NULL ){ + return; + } + CHAR_removeHaveItem( ch ); + CHAR_removeHavePoolItem( ch); + +#ifdef _CHAR_POOLITEM +// CHAR_removeHaveDepotItem( ch ); +#endif +#ifdef _CHAR_POOLPET +// CHAR_removeHaveDepotPet( ch ); +#endif + + ch->use = FALSE; +} + +void CHAR_endCharOneArray( int index ) +{ + Char* ch = NULL; + if( !CHAR_CHECKINDEX( index) ) return; + ch = CHAR_getCharPointer(index); + + if( ch == NULL ){ + print( "CHAR_endCharOneArray err ch == NULL :%d\n", index); + return; + } + CHAR_endCharData( ch ); +} +static char CHAR_dataString[STRINGBUFSIZ*16*2]; +BOOL CHAR_checksetdata( void ) +{ + int i; + char* strings[CHAR_DATAINTNUM + CHAR_DATACHARNUM]; + int stringnum=0; + for(i = 0; i < CHAR_DATAINTNUM ; i ++ ){ + if( CHAR_setintdata[i][0] != '#' ) + strings[stringnum++] = CHAR_setintdata[i]; + } + for( i = 0 ; i < CHAR_DATACHARNUM ; i ++ ){ + if( CHAR_setchardata[i][0] != '#' ) + strings[stringnum++] = CHAR_setchardata[i]; + } + if( ! checkStringsUnique( strings, stringnum , 1 ) ){ + fprint( "set????data is overlapped.\nIt is not allowed\n"); + return FALSE; + } + return TRUE; +} + +#define FLGRESERVESTRING "flg" +#define ITEMRESERVESTRING "item" +#define POOLITEMRESERVESTRING "poolitem" +#define SKILLRESERVESTRING "skill" +#define TITLERESERVESTRING "title" +#define ADDRESSBOOKRESERVESTRING "adr" +#define PETSERVERSTRING "pet" +#define PETITEMRESERVESTRING "pitem" +#define PETSKILLSERVERSTRING "psk" +#define POOLPETSERVERSTRING "poolpet" +#define ITEMPOOLRESERVESTRING "itempool" + +#define DATAENDCHECKPOINT "DATAEND" + + + + +#ifdef _CHAR_POOLITEM +#define DEPOTITEMRESERVESTRING "Depotitem" +#endif +#ifdef _CHAR_POOLPET +#define DEPOTPETRESERVESTRING "Depotpet" +#endif + +char* CHAR_makeStringFromCharData( Char* one ) +{ + int i; + int petnum; + int strlength=0; + + if (!one) return NULL; + + memset( CHAR_dataString, 0, sizeof(CHAR_dataString)); + for( i = 0 ; i < CHAR_DATAINTNUM ; i ++ ){ + char linedata[256]; + snprintf( linedata , sizeof(linedata), + "%s=%d" CHAR_DELIMITER, + CHAR_setintdata[i], + one->data[i] ); + strcpysafe( &CHAR_dataString[strlength], + sizeof( CHAR_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_dataString ) ) { + fprint( "err chardata buffer over\n"); + goto RETURN; + } + } + for( i = 0 ; i < CHAR_DATACHARNUM ; i ++ ){ + char linedata[256]; + char escapebuffer[256]; + snprintf( linedata , sizeof(linedata), + "%s=%s" CHAR_DELIMITER, + CHAR_setchardata[i], + makeEscapeString( one->string[i].string, escapebuffer, + sizeof( escapebuffer) )); + + strcpysafe( &CHAR_dataString[strlength], + sizeof( CHAR_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_dataString ) ) { + fprint( "err chardata buffer over\n"); + goto RETURN; + } + } + for( i = 0 ; i < arraysizeof( one->flg ) ; i ++ ){ + char linedata[128]; + snprintf( linedata , sizeof(linedata), + FLGRESERVESTRING "%d=%d" CHAR_DELIMITER, + i, one->flg[i]); + + strcpysafe( &CHAR_dataString[strlength], + sizeof( CHAR_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_dataString ) ) { + fprint( "err chardata buffer over\n"); + goto RETURN; + } + } + + for( i = 0 ; i < CHAR_SKILLMAXHAVE ; i ++ ){ + char linedata[128]; + char *skillstring=NULL; + if( one->haveSkill[i].use == TRUE) + skillstring = SKILL_makeStringFromSkillData( + &one->haveSkill[i].skill ); + if( skillstring == NULL ) continue; + snprintf( linedata , sizeof( linedata ), + SKILLRESERVESTRING "%d=%s" CHAR_DELIMITER, + i,skillstring ); + strcpysafe( &CHAR_dataString[strlength], + sizeof( CHAR_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_dataString ) ) { + fprint( "err chardata buffer over\n"); + goto RETURN; + } + } + + for( i = 0 ; i < CHAR_MAXITEMHAVE ; i ++ ){ + char linedata[2048]; + char *itemstring=NULL; + if( one->indexOfExistItems[i] != -1 ) + itemstring = ITEM_makeStringFromItemIndex( + one->indexOfExistItems[i], 0); + if( itemstring == NULL )continue; + snprintf( linedata , sizeof( linedata ), + ITEMRESERVESTRING "%d=%s" CHAR_DELIMITER, + i, itemstring); + strcpysafe( &CHAR_dataString[strlength], + sizeof( CHAR_dataString ) - strlength, + linedata ); + + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_dataString ) ) { + fprint( "err chardata buffer over\n"); + goto RETURN; + } + } + + for( i = 0 ; i < CHAR_MAXPOOLITEMHAVE ; i ++ ){ + char linedata[2048]; + char *itemstring=NULL; + if( one->indexOfExistPoolItems[i] != -1 ) + itemstring = ITEM_makeStringFromItemIndex( + one->indexOfExistPoolItems[i], 0); + if( itemstring == NULL )continue; + snprintf( linedata , sizeof( linedata ), + POOLITEMRESERVESTRING "%d=%s" CHAR_DELIMITER, + i, itemstring); + strcpysafe( &CHAR_dataString[strlength], + sizeof( CHAR_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_dataString ) ) { + fprint( "err chardata buffer over\n"); + goto RETURN; + } + } + + for( i = 0 ; i < CHAR_TITLEMAXHAVE ; i ++ ){ + char linedata[128]; + if( one->indexOfHaveTitle[i]< 0 || one->indexOfHaveTitle[i] >= CHAR_TITLEMAXHAVE ) { + continue; + } + snprintf( linedata , sizeof( linedata ), + TITLERESERVESTRING "%d=%d" CHAR_DELIMITER, + i, one->indexOfHaveTitle[i] ); + strcpysafe( &CHAR_dataString[strlength], + sizeof( CHAR_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_dataString ) ) { + fprint( "err chardata buffer over\n"); + goto RETURN; + } + } + for( i=0 ; i < ADDRESSBOOK_MAX ; i++ ){ + char linedata[512]; + char *p; + p = ADDRESSBOOK_makeAddressbookString(&one->addressBook[i]); + if( strlen( p) == 0 ) { + continue; + } + snprintf( linedata ,sizeof(linedata), + ADDRESSBOOKRESERVESTRING "%d=%s" CHAR_DELIMITER, + i,p + ); + strcpysafe( &CHAR_dataString[strlength], + sizeof( CHAR_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_dataString ) ) { + fprint( "err chardata buffer over\n"); + goto RETURN; + } + } + for( petnum = 0; petnum < CHAR_MAXPETHAVE; petnum ++ ) { + int petindex; + char linedata[4096*2]; + char *petstring; + petindex = one->unionTable.indexOfPet[petnum]; + if( !CHAR_CHECKINDEX(petindex))continue; + petstring = CHAR_makePetStringFromPetIndex( petindex); + if( petstring == NULL ) continue; + snprintf( linedata , sizeof(linedata), + PETSERVERSTRING "%d=%s" CHAR_DELIMITER,petnum,petstring ); + strcpysafe( &CHAR_dataString[strlength], + sizeof( CHAR_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_dataString ) ) { + fprint( "err chardata buffer over\n"); + goto RETURN; + } + } + + for( petnum = 0; petnum < CHAR_MAXPOOLPETHAVE; petnum ++ ) { + int petindex; + char linedata[4096*2]; + char *petstring; + petindex = one->indexOfPoolPet[petnum]; + if( !CHAR_CHECKINDEX(petindex))continue; + petstring = CHAR_makePetStringFromPetIndex( petindex); + if( petstring == NULL ) continue; + + //andy_log + if( strstr( petstring, "name:") == NULL || + strstr( petstring, "ownt:") == NULL ) { + LodBadPetString( "petstring", "poolpet string buffer err:", petnum); + fprint( "ANDY err poolpet string buffer err:\n%s\n", petstring); + goto RETURN; + } + + snprintf( linedata , sizeof(linedata), + POOLPETSERVERSTRING "%d=%s" CHAR_DELIMITER,petnum,petstring ); + + strcpysafe( &CHAR_dataString[strlength], + sizeof( CHAR_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_dataString ) ) { + fprint( "err chardata buffer over\n"); + goto RETURN; + } + } +#ifdef _CHAR_FIXDATADEF + { + char linedata[1024]; + memset( linedata, 0, sizeof(linedata)); + snprintf( linedata , sizeof(linedata), + DATAENDCHECKPOINT "=%d" CHAR_DELIMITER, (int)time(NULL)/1000); + + strcpysafe( &CHAR_dataString[strlength], + sizeof( CHAR_dataString ) - strlength, linedata ); + + if( strlength > sizeof( CHAR_dataString ) ) { + LodBadPetString( "DATAENDCHECKPOINT", "err chardata buffer over", -1); + fprint( "err chardata buffer over:DATAENDCHECKPOINT !\n"); + goto MAKESTRINGERR; + } + } +#endif + +RETURN: + if( strstr( CHAR_dataString, DATAENDCHECKPOINT) == NULL ){ + LodBadPetString( CHAR_dataString, "err mk dataString no end", -1); + } + + return CHAR_dataString; +MAKESTRINGERR: + return NULL; +} + +char* CHAR_makeStringFromCharIndex( int index ) +{ + if( 0 <= index && index <= CHAR_charanum /* index OK*/ + && CHAR_chara[index].use == TRUE ) + /* OK */; + else + return NULL; + return CHAR_makeStringFromCharData(&CHAR_chara[index]); + +} + +BOOL CHAR_makeCharFromStringToArg( char* data, Char* one) +{ + int i; + int readindex=1, rightData=0; + + if( data[0] == '\0' ) + return FALSE; +DebugPoint=51; + { + char name[4096]; + char *sp = strstr( data, "name="); + char *sp2 = strstr( data, "ownt="); + if( sp && sp2 ){ + snprintf( name, sp2-sp-5, "%s", sp+5 ); + print("\n开始登陆人物名称:%s ", name ); + }else + print("\n开始登陆人物名称错误! "); + + if( data[strlen(data)-2] != '\n' ){ + print("\n 登陆错误!:%s ",data+strlen(data)-20 ); + } + + if( strlen(name) > 16 ){ + print("人物名称过长!! 人物名称:%s 长度:%d ", name ,strlen(name) ); + } + } + + memset( one , 0 , sizeof( Char )); +DebugPoint=52; + CHAR_getDefaultChar(one, 0); + // Robin 0726 default RidePet + one->data[CHAR_RIDEPET] = -1; + strcpysafe( one->string[CHAR_FMNAME].string, + sizeof( one->string[CHAR_FMNAME].string), "\0" ); + one->data[CHAR_FMINDEX] = -1; +#ifdef _PETSKILL_BECOMEPIG + one->data[CHAR_BECOMEPIG] = -1; + one->data[CHAR_BECOMEPIG_BBI] = 100250; +#endif + +DebugPoint=53; + while( 1 ){ + BOOL ret; + char linebuf[4096]; + char firstToken[256]; + char secondToken[4096]; + memset( linebuf, 0, sizeof( linebuf)); + memset( firstToken, 0, sizeof( firstToken)); + memset( secondToken, 0, sizeof( secondToken)); +DebugPoint=54; + ret = getStringFromIndexWithDelim( data ,CHAR_DELIMITER, + readindex, + linebuf, sizeof( linebuf ) ); +DebugPoint=55; + if( ret == FALSE )break; + if( linebuf[0] == '#' || + linebuf[0] == '\n' || + linebuf[0] == '\0' ){ + readindex ++; + continue; + } +DebugPoint=56; + ret = getStringFromIndexWithDelim( linebuf , "=" , 1 , + firstToken , + sizeof(firstToken) ); + if( ret == FALSE ) return FALSE; +DebugPoint=57; + strcpysafe( secondToken , sizeof( secondToken ), + linebuf + strlen(firstToken) + strlen("=") ); +DebugPoint=58; + for( i = 0 ; i < CHAR_DATAINTNUM ; i ++ ){ + if( strcmp(firstToken ,CHAR_setintdata[i] ) == 0 ){ + one->data[i] = atoi( secondToken ); + goto NEXT; + } + } +DebugPoint=59; + for( i = 0 ; i < CHAR_DATACHARNUM ; i ++ ){ + if( strcmp( firstToken ,CHAR_setchardata[i] ) == 0 ){ + strcpysafe( one->string[i].string, + sizeof(one->string[i].string), + makeStringFromEscaped(secondToken) ); + if( strlen( one->string[i].string ) > 128 ){ + print(" CHARDATA_to_long!!:%s:%d ", one->string[i].string, strlen( one->string[i].string ) ); + one->string[i].string[0]=0; + } + goto NEXT; + } + } +DebugPoint=60; + if( strncmp( firstToken , FLGRESERVESTRING, + strlen( FLGRESERVESTRING ) ) == 0 ){ + int flgindex; + flgindex = atoi( firstToken+strlen(FLGRESERVESTRING) ); + if( flgindex < 0 || arraysizeof( one->flg ) <= flgindex ) + ; + else + one->flg[flgindex] = atoi( secondToken ); + + goto NEXT; + } +DebugPoint=61; + if( strncmp( firstToken , ITEMRESERVESTRING, + strlen( ITEMRESERVESTRING ) ) == 0 ){ + int itemindex; + if( strcmp( secondToken, NULLITEM) == 0 ) + goto NEXT; + itemindex = atoi( firstToken+strlen(ITEMRESERVESTRING) ); + if( itemindex < 0 || CHAR_MAXITEMHAVE <= itemindex + || one->indexOfExistItems[itemindex] != -1 ){ + ; + }else{ + ITEM_Item itmone; + BOOL ret; + + ret = ITEM_makeExistItemsFromStringToArg( secondToken, &itmone, 0); + + if( ret == TRUE ){ + int existitemindex; + existitemindex = ITEM_initExistItemsOne( &itmone ); + one->indexOfExistItems[itemindex] = existitemindex; + } + } + goto NEXT; + } +DebugPoint=62; + if( strncmp( firstToken , POOLITEMRESERVESTRING, + strlen( POOLITEMRESERVESTRING ) ) == 0 ){ + int itemindex; + if( strcmp( secondToken, NULLITEM) == 0 ) + goto NEXT; + itemindex = atoi( firstToken+strlen(POOLITEMRESERVESTRING) ); + if( itemindex < 0 || CHAR_MAXPOOLITEMHAVE <= itemindex + || one->indexOfExistPoolItems[itemindex] != -1 ){ + ; + }else{ + ITEM_Item itmone; + BOOL ret; + ret = ITEM_makeExistItemsFromStringToArg( secondToken , &itmone, 0 ); + + if( ret == TRUE ){ + int existitemindex; + existitemindex = ITEM_initExistItemsOne( &itmone ); + one->indexOfExistPoolItems[itemindex] = existitemindex; + } + } + goto NEXT; + } +DebugPoint=63; + if( strncmp( firstToken , SKILLRESERVESTRING, + strlen( SKILLRESERVESTRING ) ) == 0 ){ + int skillindex; + if( strcmp( secondToken, NULLSKILL) == 0 ) + goto NEXT; + skillindex =atoi( firstToken+strlen(SKILLRESERVESTRING) ); + if( skillindex < 0 || CHAR_SKILLMAXHAVE <= skillindex + || one->haveSkill[skillindex].use == TRUE ){ + }else{ + BOOL ret; + Skill skillone; + ret=SKILL_makeSkillFromStringToArg(secondToken,&skillone); + + if( ret == TRUE ){ + memcpy( &one->haveSkill[skillindex].skill , &skillone, + sizeof( Skill )); + one->haveSkill[skillindex].use = TRUE; + } + } + goto NEXT; + } +DebugPoint=64; + if( strncmp( firstToken , TITLERESERVESTRING, + strlen( TITLERESERVESTRING ) ) == 0 ){ + int titlenumber=atoi(firstToken+strlen(TITLERESERVESTRING)); + if( titlenumber < 0 || CHAR_TITLEMAXHAVE <= titlenumber ){ + }else{ + int titleindex = atoi( secondToken ); + if( TITLE_getTitleIndex( titleindex) != -1) + one->indexOfHaveTitle[titlenumber] = titleindex; + } + goto NEXT; + } +DebugPoint=65; + if( strncmp( firstToken , ADDRESSBOOKRESERVESTRING, + strlen( ADDRESSBOOKRESERVESTRING ) ) == 0 ){ + int addressnumber = atoi( firstToken + +strlen(ADDRESSBOOKRESERVESTRING)); + if( addressnumber < 0 || ADDRESSBOOK_MAX <= addressnumber ){ + }else{ + ADDRESSBOOK_makeAddressbookEntry( secondToken, + &one + ->addressBook[ + addressnumber]); + } + goto NEXT; + } +DebugPoint=66; + if( strncmp( firstToken , PETSERVERSTRING, + strlen( PETSERVERSTRING ) ) == 0 ){ + Char ch; + int ret; + int petnumber = atoi( firstToken+strlen(PETSERVERSTRING)); + if( !CHAR_CHECKPETINDEX( petnumber)) goto NEXT; + ret = CHAR_makePetFromStringToArg(secondToken,&ch, petnumber); + if( ret == TRUE ){ + int petindex = PET_initCharOneArray( &ch ); + if( petindex < 0 ){ + print( "宠物制作失败。\n"); + } + one->unionTable.indexOfPet[petnumber] = petindex; + goto NEXT; + }else{ + LodBadPetString( data, "错误总计", petnumber); + + fprint( "错误 宠物字符串 无法作成\n"); + return FALSE; + } + } +DebugPoint=67; + if( strncmp( firstToken , POOLPETSERVERSTRING, strlen( POOLPETSERVERSTRING ) ) == 0 ){ + + Char ch; + int ret; + int petnumber = atoi( firstToken+strlen(POOLPETSERVERSTRING)); + if( !CHAR_CHECKPOOLPETINDEX( petnumber)) goto NEXT; + ret = CHAR_makePetFromStringToArg( secondToken, &ch, petnumber); + if( ret == TRUE ) { + int petindex = PET_initCharOneArray( &ch ); + if( petindex < 0 ) { + fprint( "错误 宠物 无法作成\n"); + } + one->indexOfPoolPet[petnumber] = petindex; + goto NEXT; + }else{ + LodBadPetString( data, "err *total", petnumber); + fprint( "错误 合成宠物字符串 无法作成\n"); + return FALSE; + } + } + + if( strncmp( firstToken , DATAENDCHECKPOINT, strlen( DATAENDCHECKPOINT ) ) == 0 ){ + rightData=1; + goto NEXT; + } + + + print( "??? : %s[%s]\n" , linebuf, firstToken ); + NEXT: + readindex++; + } +DebugPoint=68; + // Robin 0913 bad_chardata + { + char name[4096]; + char* sp = strstr( data, "name="); + // shan add + char *sp2 = strstr( data, "ownt="); + if( sp && sp2 ){ + snprintf( name, sp2-sp-5, "%s", sp+5 ); + print("\n登陆成功 人物名称:%s ", name ); + } + else + print("\n登陆成功 人物名称错误! "); + + if( data[strlen(data)-2] != '\n' ){ + print("\n玩家登陆出错! "); + //return FALSE; + } + } +// if( rightData != 1 ){ +// return FALSE; +// } + return TRUE; +} +static char CHAR_petdataString[4096]; + +char *CHAR_makePetStringFromPetIndex( int petindex) +{ + int i; + int strlength = 0; + + memset( CHAR_petdataString, 0, sizeof(CHAR_petdataString)); + + for( i = 0 ; i < CHAR_DATAINTNUM ; i ++ ){ + char linedata[512]; + +#ifdef _SIMPLIFY_PETSTRING + if( CHAR_getInt( petindex, i) == 0 ) continue; +#endif + snprintf( linedata , sizeof(linedata), + "%s:%d" NONCHAR_DELIMITER, CHAR_setintdata[i], CHAR_getInt( petindex,i) ); + strcpysafe( &CHAR_petdataString[strlength], + sizeof( CHAR_petdataString ) - strlength, linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_petdataString ) ) { + fprint( "err petdata buffer over\n"); + return NULL; + } + } + + for( i = 0 ; i < CHAR_DATACHARNUM ; i ++ ){ + char linedata[512]; + char escapebuffer[512]; +#ifdef _SIMPLIFY_PETSTRING + if( *CHAR_getChar( petindex, i) == NULL + && strcmp( CHAR_setchardata[i], "name") + && strcmp( CHAR_setchardata[i], "ownt") ) + continue; +#endif + snprintf( linedata , sizeof(linedata), + "%s:%s" NONCHAR_DELIMITER, + CHAR_setchardata[i], + makeEscapeString( CHAR_getChar(petindex, i), escapebuffer, + sizeof( escapebuffer) )); + + strcpysafe( &CHAR_petdataString[strlength], + sizeof( CHAR_petdataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_petdataString ) ) { + fprint( "错误 宠物数据缓冲不足\n"); + return NULL; + } + } + + for( i = 0; i < CHAR_MAXPETSKILLHAVE; i ++ ) { + int petskillid; + char linedata[512]; + petskillid = CHAR_getPetSkill( petindex, i); + if( PETSKILL_getPetskillArray( petskillid) == -1 ) continue; + snprintf( linedata , sizeof(linedata), + PETSKILLSERVERSTRING "%d:%d" NONCHAR_DELIMITER,i ,petskillid ); + strcpysafe( &CHAR_petdataString[strlength], + sizeof( CHAR_petdataString ) - strlength, linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_petdataString ) ) { + fprint( "错误 宠物数据缓冲不足\n"); + return NULL; + } + } + +#ifndef _SIMPLIFY_ITEMSTRING + for( i = 0 ; i < CHAR_MAXITEMHAVE ; i ++ ){ + char linedata[2048]; + char *itemstring=NULL; + if( CHAR_getItemIndex( petindex, i) != -1 ) + itemstring = ITEM_makeStringFromItemIndex( + CHAR_getItemIndex( petindex, i), 1); + if( itemstring == NULL )continue; + snprintf( linedata , sizeof( linedata ), + PETITEMRESERVESTRING "%d:%s" NONCHAR_DELIMITER, + i, itemstring); + strcpysafe( &CHAR_petdataString[strlength], + sizeof( CHAR_petdataString ) - strlength, + linedata ); + + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_petdataString ) ) { + fprint( "错误 宠物数据缓冲不足\n"); + return NULL; + } + } +#endif + + if( strstr( CHAR_petdataString, "name:") == NULL || + strstr( CHAR_petdataString, "ownt:") == NULL ){ + LodBadPetString( CHAR_petdataString, "名字 错误", -1); + } + return CHAR_petdataString; +} +void LodBadPetString( char *data, char *err, int ti) +{ + FILE *fp=NULL; + if( data == NULL || strlen( data) <= 0 ) return; + if( (fp=fopen( "badpetstring.txt", "a+")) == NULL ) return; + fprintf( fp, "ti:%d %s:%s\n", ti, err, data); + + fclose( fp); +} +int CHAR_makePetFromStringToArg( char *src, Char *ch, int ti) +{ + int readnum = 1; + int rc; + BOOL found; + char buff[4096]; + char petfirstToken[256]; + char petsecondToken[4096]; + int i, findE=0; + + memset( ch, 0, sizeof( Char)); + CHAR_getDefaultChar(ch, 31010); + + if( strstr( src, "name:") == NULL || + strstr( src, "ownt:") == NULL ){//findE + LodBadPetString( src, "make name err", ti); + fprint( "err PetString make name err\n"); + return -1; + } + + while( 1 ) { + rc = getStringFromIndexWithDelim( src, NONCHAR_DELIMITER, readnum, buff, sizeof( buff )); + if( rc == TRUE ) { + if( buff[0] == '#' || buff[0] == '\n' || buff[0] == '\0' ){ + readnum ++; + continue; + } + } + if( rc == TRUE ) { + readnum ++; + rc = getStringFromIndexWithDelim( buff , ":" , 1 , + petfirstToken , + sizeof(petfirstToken) ); + if( rc == FALSE ) break; + strcpysafe( petsecondToken , sizeof( petsecondToken ), + buff + strlen(petfirstToken) + strlen(":") ); +// rc = getStringFromIndexWithDelim( buff , ":" , 2 , +// petsecondToken , +// sizeof(petsecondToken) ); + + found = FALSE; + for( i = 0 ; i < CHAR_DATAINTNUM ; i ++ ){ + if( strcmp(petfirstToken ,CHAR_setintdata[i] ) == 0 ){ + ch->data[i] = atoi( petsecondToken ); + found = TRUE; + break; + } + } + if( !found ) { + for( i = 0 ; i < CHAR_DATACHARNUM ; i ++ ){ + if( strcmp( petfirstToken ,CHAR_setchardata[i] ) == 0 ){ + strcpysafe( ch->string[i].string, + sizeof(ch->string[i].string), + makeStringFromEscaped(petsecondToken) ); + found = TRUE; + findE = 1; + break; + } + } + } + if( !found) { +#ifndef _SIMPLIFY_ITEMSTRING + if( strncmp( petfirstToken , PETITEMRESERVESTRING, + strlen( PETITEMRESERVESTRING ) ) == 0 ) + { + int itemindex; + itemindex = atoi( petfirstToken+strlen(PETITEMRESERVESTRING) ); + if( itemindex < 0 || CHAR_MAXITEMHAVE <= itemindex + || ch->indexOfExistItems[itemindex] != -1 ){ + ; + }else{ + ITEM_Item itmone; + BOOL ret; + + ret = ITEM_makeExistItemsFromStringToArg( petsecondToken , + &itmone,1); + + if( ret == TRUE ){ + int existitemindex; + existitemindex = ITEM_initExistItemsOne( &itmone ); + ch->indexOfExistItems[itemindex] = existitemindex; + found = TRUE; + break; + } + } + } +#endif + + } + if( !found ) { + if( strncmp( petfirstToken , PETSKILLSERVERSTRING, + strlen( PETSKILLSERVERSTRING ) ) == 0 ){ + int petskillnum = atoi( petfirstToken + strlen( PETSKILLSERVERSTRING)); + if( CHAR_CHECKPETSKILLINDEX( petskillnum) ) { + int petskillid = atoi( petsecondToken ); + if( PETSKILL_getPetskillArray(petskillid) != -1) { + ch->unionTable.indexOfPetskill[petskillnum] = petskillid; + found = TRUE; + } + } + } + } + if( !found) { + fprint( "makePetFromString err?: %s : %s [%s] \n" , src, buff, petfirstToken ); + } + }else { + break; + } + } + + if( findE == 0 ){//findE + LodBadPetString( src, "make charstr err", ti); + fprint( "err PetString make charstr err\n"); + return -1; + } + + return TRUE; +} + +#ifdef _PERSONAL_FAME // Arminius 8.30: 家族个人声望 + +void CHAR_earnFame(int index, int fame) +{ + int oldfame=CHAR_getInt(index, CHAR_FAME)+fame; +#ifdef _NEW_MANOR_LAW + int momentum = CHAR_getInt(index,CHAR_MOMENTUM) + fame; +#endif + + if (oldfame>MAX_PERSONALFAME) oldfame=MAX_PERSONALFAME; + if (oldfame<0) oldfame=0; + CHAR_setInt(index, CHAR_FAME, oldfame); +#ifdef _NEW_MANOR_LAW + if(momentum > MAX_PERSONAL_MOMENTUM) momentum = MAX_PERSONAL_MOMENTUM; + else if(momentum < 0) momentum = 0; + CHAR_setInt(index,CHAR_MOMENTUM,momentum); +#endif +} +#endif + +// CoolFish: 2001/10/11 Unique Pet Code +#ifdef _UNIQUE_P_I +void CHAR_setPetUniCode(int petindex) +{ + if( strcmp( CHAR_getChar(petindex, CHAR_UNIQUECODE), "" ) == 0 || + strstr( CHAR_getChar(petindex, CHAR_UNIQUECODE), "_" ) != NULL || + strstr( CHAR_getChar(petindex, CHAR_UNIQUECODE), UNIQUE_KEYCODEPET ) == NULL ){ + char petbuf[256]; + time_t t1; + time(&t1); + sprintf(petbuf, "%ld%s%d%d", t1, UNIQUE_KEYCODEPET, getServernumber(), unique_p); + unique_p++; + if (unique_p >= MAX_UNIQUE_P_I) + unique_p = 0; + CHAR_setChar(petindex, CHAR_UNIQUECODE, petbuf); + } +} + +void ITEM_setItemUniCode(int itemindex) +{ + if( strcmp( ITEM_getChar(itemindex, ITEM_UNIQUECODE), "") == 0 || + strstr( ITEM_getChar(itemindex, ITEM_UNIQUECODE), "_") != NULL ){ + char itembuf[256]; + time_t t1; + time(&t1); + + sprintf(itembuf, "%ld%s%d%d%d", t1, "i", unique_i, getServernumber(), UNIQUE_KEYCODEITEM); + + unique_i++; + if (unique_i >= MAX_UNIQUE_P_I) + unique_i = 0; + ITEM_setChar(itemindex, ITEM_UNIQUECODE, itembuf); + } +} + +void CHAR_DetainSameItem( int charaindex, int itemindex) +{ + ITEM_setWorkInt( itemindex, ITEM_WORKCHARAINDEX, 100000); + ITEM_setWorkInt( itemindex, ITEM_WORKOBJINDEX, -1); + + LogItem( + CHAR_getChar( charaindex, CHAR_NAME), + CHAR_getChar( charaindex, CHAR_CDKEY), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), +#endif + "SysDeleteSame(系统删除重覆道具)", + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); +// ITEM_endExistItemsOne( itemindex); +} + +void CHAR_DetainSamePet( int charaindex, int petindex) +{ + CHAR_setWorkInt( petindex, CHAR_WORKPLAYERINDEX, 100000); + CHAR_setChar( petindex, CHAR_OWNERCDKEY, "SYS"); + CHAR_setChar( petindex, CHAR_OWNERCHARANAME, "SYS"); + CHAR_complianceParameter( petindex ); + LogPet( + CHAR_getChar( charaindex, CHAR_NAME), + CHAR_getChar( charaindex, CHAR_CDKEY), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "SysDeleteSame(删除重覆宠物)", + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y), + CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14 + ); +// CHAR_endCharOneArray( petindex ); +} + +void CHAR_DetainSameUCodePet( int charaindex, int petindex, int Ti) +{ + if( Ti == -1 ){ + int i; + for( i = 0; i < CHAR_MAXPETHAVE; i++ ) { + int pindex = CHAR_getCharPet( charaindex, i); + if( !CHAR_CHECKINDEX( pindex) ) continue; + if( pindex == petindex ) break; + } + if( i >= CHAR_MAXPETHAVE ) return; + CHAR_setCharPet( charaindex, i, -1); + }else{ + CHAR_setCharPet( charaindex, Ti, -1); + } + CHAR_DetainSamePet( charaindex, petindex); +} + +void CHAR_DetainSameUCodePoolPet( int charaindex, int petindex, int Ti) +{ + if( Ti == -1 ){ + int i; + for( i = 0; i < CHAR_MAXPETHAVE; i++ ) { + int pindex = CHAR_getCharPet( charaindex, i); + if( !CHAR_CHECKINDEX( pindex) ) continue; + if( pindex == petindex ) break; + } + if( i >= CHAR_MAXPETHAVE ) return; + CHAR_setCharPoolPet( charaindex, i, -1); + }else{ + CHAR_setCharPoolPet( charaindex, Ti, -1); + } + CHAR_DetainSamePet( charaindex, petindex); +} + +void CHAR_DetainSameUCodeItem( int charaindex, int itemindex, int Ti) +{ + if( Ti == -1 ){ + int i; + for( i = 0; i < CHAR_MAXITEMHAVE; i++ ) { + int iindex = CHAR_getItemIndex( charaindex, i); + if( !ITEM_CHECKINDEX( iindex) ) continue; + if( iindex == itemindex ) break; + } + if( i >= CHAR_MAXITEMHAVE ) return; + CHAR_setItemIndex( charaindex, i, -1); + }else{ + CHAR_setItemIndex( charaindex, Ti, -1); + } + CHAR_DetainSameItem( charaindex, itemindex); +} + +void CHAR_DetainSameUCodePoolItem( int charaindex, int itemindex, int Ti) +{ + if( Ti == -1 ){ + int i; + for( i = 0; i < CHAR_MAXPOOLITEMHAVE; i++ ) { + int iindex = CHAR_getPoolItemIndex( charaindex, i); + if( !ITEM_CHECKINDEX( iindex) ) continue; + if( iindex == itemindex ) break; + } + if( i >= CHAR_MAXPOOLITEMHAVE ) return; + CHAR_setPoolItemIndex( charaindex, i, -1); + }else{ + CHAR_setPoolItemIndex( charaindex, Ti, -1); + } + CHAR_DetainSameItem( charaindex, itemindex); +} + +void Check_P_I_UniCode( int charaindex) +{ +#ifdef _CHECK_UCODE + int i = 0, j = 0; + int petindex, itemindex; + + int MAXPLAYER = CHAR_getPlayerMaxNum(); + int MAXPET = CHAR_getPetMaxNum(); + int MAXITEM = ITEM_getITEM_itemnum(); + + for( i=0; i < CHAR_MAXPETHAVE; i++ ) { + petindex = CHAR_getCharPet( charaindex, i); + if( !CHAR_CHECKINDEX( petindex) ) continue; + for( j=MAXPLAYER; j CHAR_GetOldLevelExp( level+1) ){ + Myexp = 0; + }else if( Myexp >= defexp ){ + Myexp = Myexp - defexp; + } + if( Myexp < 0 ) Myexp = 0; + + CHAR_setInt( charaindex, CHAR_EXP, Myexp); + CHAR_setInt( charaindex, CHAR_OLDEXP, 0); + + CHAR_send_P_StatusString( charaindex ,CHAR_P_STRING_EXP|CHAR_P_STRING_LV); + return Myexp; +} + +INLINE int CHAR_HandleExp( int charaindex ) +{ + int needexp, level, Myexp; + if( !CHAR_CHECKINDEX( charaindex) ) return -1; + level = CHAR_getInt( charaindex, CHAR_LV); + Myexp = CHAR_getInt( charaindex, CHAR_EXP); + if( (needexp = CHAR_GetLevelExp( charaindex, level+1), 0) < 0 ) return -1; + Myexp = Myexp - needexp; + if( Myexp < 0 ) Myexp = 0; + CHAR_setInt( charaindex, CHAR_EXP, Myexp); + return Myexp; +} +#endif + +#ifdef _FIX_TSKILLCAN +BOOL CHAR_PETSKILLCAN( int toindex) +{ + int i, j, itemindex, petindex; + int FixItem[20]={ + 20270, 20271, 20272, 20273, 20274, + 20275, 20276, 20277, 20278, 20279, + 20280, 20281, 20282, 20283, 20284, + 20287, 20288, 20289, 20290, 20291 + }; + for (i = CHAR_STARTITEMARRAY; i < CHAR_MAXITEMHAVE; i ++) { + itemindex = CHAR_getItemIndex( toindex, i); + if( !ITEM_CHECKINDEX( itemindex)) continue; + for( j=0; j<20; j++){ + if( ITEM_getInt( itemindex, ITEM_ID) == FixItem[j] ){ + ITEM_setInt( itemindex, ITEM_CANMERGEFROM, 0); + } + } + if( ITEM_getInt( itemindex, ITEM_ID) != 1623 )continue; + CHAR_setItemIndex( toindex, i, -1 ); + ITEM_endExistItemsOne( itemindex); + CHAR_sendItemDataOne( toindex, i); + } + + for (i = 0; i < CHAR_MAXPOOLITEMHAVE; i++){ + int itemindex = CHAR_getPoolItemIndex(toindex, i); + if( !ITEM_CHECKINDEX( itemindex)) continue; + for( j=0; j<20; j++){ + if( ITEM_getInt( itemindex, ITEM_ID) == FixItem[j] ){ + ITEM_setInt( itemindex, ITEM_CANMERGEFROM, 0); + } + } + if( ITEM_getInt( itemindex, ITEM_ID) != 1623 )continue; + CHAR_setPoolItemIndex( toindex, i, -1); + ITEM_endExistItemsOne( itemindex); + } + + for( i=0; i < CHAR_MAXPETHAVE; i++) { + char szPet[128]; + BOOL Finds = FALSE; + petindex = CHAR_getCharPet( toindex, i); + if( !CHAR_CHECKINDEX( petindex) ) continue; + + {//清除狂暴攻击 + int j; + for( j=0; j (surplus*mypile) || itempile <= 0 ){ + return -1; + } + + if( mypile >= itempile ){ + ret = CHAR_addItemSpecificItemIndex( charaindex, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + ITEM_endExistItemsOne( itemindex); + return -1; + } + CHAR_sendItemDataOne( charaindex, ret); + }else{ + int newindex[10]={ -1,-1,-1,-1,-1, + -1,-1,-1,-1,-1}; + int i, ti=0, ItemID, MaxPile; + MaxPile = itempile; + ItemID = ITEM_getInt( itemindex, ITEM_ID); + while( MaxPile > 0 ){ + if( ti >= 10 ) return -1; + newindex[ti] = ITEM_makeItemAndRegist( ItemID); + if( !ITEM_CHECKINDEX( newindex[ti]) ) return -1; + if( mypile > MaxPile ) mypile = MaxPile; + ITEM_setInt( newindex[ti], ITEM_USEPILENUMS, mypile); + ti++; + MaxPile -= mypile; + if( MaxPile < 0 ) return -1; + } + for( i=0; i<10; i++ ){ + if( newindex[i] == -1 ) break; + ret = CHAR_addItemSpecificItemIndex( charaindex, newindex[i]); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + ITEM_endExistItemsOne( newindex[i]); + return -1; + } + CHAR_sendItemDataOne( charaindex, ret); + } + ITEM_endExistItemsOne( itemindex); + } + return ret; +#endif +} + + +INLINE int _CHAR_DelItem( char *file, int line, int charaindex, int ti, int num, int flg) +{ +// char token[256]; + int pilenum; + int itemindex = CHAR_getItemIndex( charaindex , ti ); + if( !ITEM_CHECKINDEX(itemindex) ) return 0; +#ifdef _ITEM_PILENUMS + pilenum = ITEM_getInt( itemindex, ITEM_USEPILENUMS); + if( pilenum < num ) return FALSE; + pilenum = pilenum - num; + ITEM_setInt( itemindex, ITEM_USEPILENUMS, pilenum); + if( pilenum <= 0 ){ +#endif +/* + if( flg == 1 ){ + sprintf( token, "交出%s。", ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + } +*/ + CHAR_setItemIndex( charaindex, ti, -1); + ITEM_endExistItemsOne( itemindex); +#ifdef _ITEM_PILENUMS + } +#endif + CHAR_sendItemDataOne( charaindex, ti); + + return 1; +} + +int CHAR_getMaxHaveGold( int charaindex) +{ + int MaxGold; +#ifdef _FIX_MAX_GOLD // WON ADD 增加人物金钱上限 + int trans = CHAR_getInt( charaindex, CHAR_TRANSMIGRATION); + MaxGold = 1000000 + trans*( 1800000); +#else + MaxGold = CHAR_MAXGOLDHAVE; +#endif + + return MaxGold; +} + +INLINE int _CHAR_AddGold( char *file, int line, int charaindex, int gold) +{ + char token[256]; + int MyGold, MaxGold; + + MaxGold = CHAR_getMaxHaveGold( charaindex); + MyGold = CHAR_getInt( charaindex, CHAR_GOLD); + MyGold = (MyGold>MaxGold)?MaxGold:MyGold; + gold = (gold>MaxGold)?MaxGold:gold; + sprintf( token, "得到%d石币", gold); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + MyGold += gold; + + if( MyGold > MaxGold ){ + int reGolds=0; + int MyGBGold = CHAR_getInt( charaindex, CHAR_PERSONAGOLD); + reGolds = MyGold - MaxGold; + MyGBGold += reGolds; + MyGBGold = (MyGBGold > CHAR_MAXPERSONAGOLD)?CHAR_MAXPERSONAGOLD:MyGBGold; + CHAR_setInt( charaindex, CHAR_PERSONAGOLD, MyGBGold); + sprintf( token,"存款:%d ,银行剩馀:%d 。", reGolds, CHAR_getInt( charaindex, CHAR_PERSONAGOLD )); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + LogBankStone( CHAR_getChar( charaindex, CHAR_NAME ), CHAR_getChar( charaindex, CHAR_CDKEY ), + charaindex, reGolds, + "GB_Bank_save(宝箱)", + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X ), CHAR_getInt( charaindex, CHAR_Y ), + CHAR_getInt( charaindex, CHAR_GOLD ), + CHAR_getInt( charaindex, CHAR_PERSONAGOLD ) + ); + MyGold = MaxGold; + } + CHAR_setInt( charaindex, CHAR_GOLD, MyGold); + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_GOLD); + + return 1; +} + +INLINE int _CHAR_DelGold( char *file, int line, int charaindex, int gold) +{ + char token[256]; + int MyGold, MaxGold; + + MaxGold = CHAR_getMaxHaveGold( charaindex); + MyGold = CHAR_getInt( charaindex, CHAR_GOLD); + MyGold = (MyGold>MaxGold)?MaxGold:MyGold; + gold = (gold>MaxGold)?MaxGold:gold; + + if( MyGold < gold ){ + sprintf( token, "没有足够的石币!(%d石币)", gold); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + return 0; + } + MyGold -= gold; + MyGold = ( MyGold < 0 )?0:MyGold; + CHAR_setInt( charaindex, CHAR_GOLD, MyGold); + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_GOLD); + return 1; +} + + +#ifdef _CHAR_POOLITEM +INLINE int _CHAR_getDepotItemIndex( char *file, int line, int index ,int iindex) +{ + if( !CHAR_CHECKINDEX(index)) { + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__,file, line); + return -1; + } + if( CHAR_MAXDEPOTITEMHAVE <= iindex || iindex < 0 ) { + print( "err %s:%d from %s:%d \n", __FILE__, __LINE__,file, line); + return -1; + } + + if( !CHAR_CheckDepotItem( index) ){ + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__,file, line); + return -1; + } + + return CHAR_chara[index].indexOfExistDepotItems[iindex]; +} + +INLINE int _CHAR_setDepotItemIndex( char *file, int line, int index ,int iindex,int id ) +{ + int buf; + if( !CHAR_CHECKINDEX(index)) { + print( "err %s:%d \n", file, line); + return -1; + } + if( CHAR_MAXDEPOTITEMHAVE <= iindex || iindex < 0 ) { + print( "err %s:%d \n", file, line); + return -1; + } + if( !CHAR_CheckDepotItem( index) ){ + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__,file, line); + return -1; + } + buf = CHAR_chara[index].indexOfExistDepotItems[iindex]; + CHAR_chara[index].indexOfExistDepotItems[iindex] = id; + return buf; +} +void CHAR_removeHaveDepotItem( Char* ch ) +{ + if( ch == NULL )return; + if( ch->indexOfExistDepotItems == NULL ) return; + freeMemory( ch->indexOfExistDepotItems ); + ch->indexOfExistDepotItems = NULL; +} + +void CHAR_removeDepotItem( int charaindex) +{ + int i,itemindex; + Char* ch = NULL; + if( !CHAR_CHECKINDEX( charaindex) ) return; + if( !CHAR_CheckDepotItem( charaindex) ) return; //仓库未存在 + ch = CHAR_getCharPointer( charaindex); + if( ch == NULL ){ + print( "removeDepotItem err ch == NULL :%d\n", charaindex); + return; + } + + for( i=0; iindexOfExistDepotItems[i]; + if( !ITEM_CHECKINDEX( itemindex) ) continue; + itemstring = ITEM_makeStringFromItemIndex( ch->indexOfExistDepotItems[i], 0); + if( itemstring == NULL )continue; + + snprintf( linedata , sizeof( linedata ), + DEPOTITEMRESERVESTRING "%d=%s" CHAR_DELIMITER, i, itemstring); + + strcpysafe( &CHAR_dataString[strlength], sizeof( CHAR_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_dataString ) ) { + return NULL; + } + } + return CHAR_dataString; +} + +BOOL CHAR_makeDepotItemStringToChar( int charaindex, char* data) +{ + int readindex=1, itemindex; + Char* ch = NULL; + BOOL ret; + char firstToken[256], secondToken[4096], linebuf[4096]; + + if( data[0] == '\0' ) + return -1; + if( !CHAR_CHECKINDEX( charaindex) ) return FALSE; + ch = CHAR_getCharPointer( charaindex); + if( ch == NULL ){ + print( "makeDepotItem err ch == NULL :%d\n", charaindex); + return FALSE; + } + + while( 1 ){ + memset( linebuf, 0, sizeof( linebuf)); + memset( firstToken, 0, sizeof( firstToken)); + memset( secondToken, 0, sizeof( secondToken)); + ret = getStringFromIndexWithDelim( data ,CHAR_DELIMITER, + readindex, linebuf, sizeof( linebuf ) ); + if( ret == FALSE )break; + if( linebuf[0] == '#' || linebuf[0] == '\n' || linebuf[0] == '\0' ){ + goto NEXT; + } + if( (ret=getStringFromIndexWithDelim( linebuf , "=" , 1 , + firstToken, sizeof(firstToken) )) == FALSE ) return FALSE; + strcpysafe( secondToken , sizeof( secondToken ), + linebuf + strlen( firstToken) + strlen("=") ); + + if( strncmp( firstToken, DEPOTITEMRESERVESTRING, strlen( DEPOTITEMRESERVESTRING)) == 0 ){ + if( strcmp( secondToken, NULLITEM) == 0 ) goto NEXT; + itemindex = atoi( firstToken+strlen(DEPOTITEMRESERVESTRING) ); + if( itemindex < 0 || CHAR_MAXDEPOTITEMHAVE <= itemindex + || ch->indexOfExistDepotItems[itemindex] != -1 ){ + ; + }else{ + ITEM_Item itmone; + ret = ITEM_makeExistItemsFromStringToArg( secondToken , &itmone, 0 ); + if( ret == TRUE ){ + int existitemindex; + existitemindex = ITEM_initExistItemsOne( &itmone ); + ch->indexOfExistDepotItems[itemindex] = existitemindex; + } + } + goto NEXT; + } + print( "??? : %s[%s]\n" , linebuf, firstToken ); +NEXT: + readindex++; + } + return TRUE; +} + +void CHAR_ShowMyDepotItems( int charaindex) +{ + int i, itemindex; + + print( "\nShowMyDepotItems:\n"); + if( !CHAR_CheckDepotItem( charaindex) ) return; + for( i=0; iindexOfExistDepotItems == NULL ) return FALSE; + return TRUE; +} + +#endif + + +#ifdef _CHAR_POOLPET +INLINE int _CHAR_getDepotPetIndex( char *file, int line, int index ,int iindex) +{ + if( !CHAR_CHECKINDEX(index)) { + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__,file, line); + return -1; + } + if( CHAR_MAXDEPOTPETHAVE <= iindex || iindex < 0 ) { + print( "err %s:%d from %s:%d \n", __FILE__, __LINE__,file, line); + return -1; + } + + if( !CHAR_CheckDepotPet( index) ){ + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__,file, line); + return -1; + } + + return CHAR_chara[index].indexOfExistDepotPets[iindex]; +} + +INLINE int _CHAR_setDepotPetIndex( char *file, int line, int index ,int iindex,int id ) +{ + int buf; + if( !CHAR_CHECKINDEX(index)) { + print( "err %s:%d \n", file, line); + return -1; + } + if( CHAR_MAXDEPOTPETHAVE <= iindex || iindex < 0 ) { + print( "err %s:%d \n", file, line); + return -1; + } + if( !CHAR_CheckDepotPet( index) ){ + print( "err %s:%d from %s:%d\n", __FILE__, __LINE__,file, line); + return -1; + } + buf = CHAR_chara[index].indexOfExistDepotPets[iindex]; + CHAR_chara[index].indexOfExistDepotPets[iindex] = id; + return buf; +} +void CHAR_removeHaveDepotPet( Char* ch ) +{ + if( ch == NULL )return; + if( ch->indexOfExistDepotPets == NULL ) return; + freeMemory( ch->indexOfExistDepotPets ); + ch->indexOfExistDepotPets = NULL; +} + +void CHAR_removeDepotPet( int charaindex) +{ + int i,petindex; + Char* ch = NULL; + if( !CHAR_CHECKINDEX( charaindex) ) return; + if( !CHAR_CheckDepotPet( charaindex) ) return; //仓库未存在 + ch = CHAR_getCharPointer( charaindex); + if( ch == NULL ){ + print( "removeDepotPet err ch == NULL :%d\n", charaindex); + return; + } + + for( i=0; iindexOfExistDepotPets[i]; + if( !CHAR_CHECKINDEX( petindex) ) continue; + petstring = CHAR_makePetStringFromPetIndex( ch->indexOfExistDepotPets[i]); + if( petstring == NULL )continue; + + snprintf( linedata , sizeof( linedata ), + DEPOTPETRESERVESTRING "%d=%s" CHAR_DELIMITER, i, petstring); + + strcpysafe( &CHAR_dataString[strlength], sizeof( CHAR_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( CHAR_dataString ) ) { + return NULL; + } + } + return CHAR_dataString; +} + +BOOL CHAR_makeDepotPetStringToChar( int charaindex, char* data) +{ + int readindex=1, petindex; + Char* ch = NULL; + BOOL ret; + char firstToken[256], secondToken[4096], linebuf[4096]; + + if( data[0] == '\0' ) + return -1; + if( !CHAR_CHECKINDEX( charaindex) ) return FALSE; + ch = CHAR_getCharPointer( charaindex); + if( ch == NULL ){ + print( "makeDepotPet err ch == NULL :%d\n", charaindex); + return FALSE; + } + + while( 1 ){ + memset( linebuf, 0, sizeof( linebuf)); + memset( firstToken, 0, sizeof( firstToken)); + memset( secondToken, 0, sizeof( secondToken)); + ret = getStringFromIndexWithDelim( data ,CHAR_DELIMITER, + readindex, linebuf, sizeof( linebuf ) ); + if( ret == FALSE )break; + if( linebuf[0] == '#' || linebuf[0] == '\n' || linebuf[0] == '\0' ){ + goto NEXT; + } + if( (ret=getStringFromIndexWithDelim( linebuf , "=" , 1 , + firstToken, sizeof(firstToken) )) == FALSE ) return FALSE; + strcpysafe( secondToken , sizeof( secondToken ), + linebuf + strlen( firstToken) + strlen("=") ); + + if( strncmp( firstToken, DEPOTPETRESERVESTRING, strlen( DEPOTPETRESERVESTRING)) == 0 ){ + if( strcmp( secondToken, NULLITEM) == 0 ) goto NEXT; + petindex = atoi( firstToken+strlen(DEPOTPETRESERVESTRING) ); + if( petindex < 0 || CHAR_MAXDEPOTPETHAVE <= petindex + || ch->indexOfExistDepotPets[petindex] != -1 ){ + ; + }else{ + Char petone; + ret = CHAR_makePetFromStringToArg( secondToken , &petone, 0 ); + if( ret == TRUE ){ + int existpetindex; + existpetindex = PET_initCharOneArray( &petone ); + ch->indexOfExistDepotPets[petindex] = existpetindex; + CHAR_setWorkInt( existpetindex, CHAR_WORKPLAYERINDEX, charaindex); + CHAR_complianceParameter( existpetindex); + } + } + goto NEXT; + } + print( "??? : %s[%s]\n" , linebuf, firstToken ); +NEXT: + readindex++; + } + return TRUE; +} + +void CHAR_ShowMyDepotPets( int charaindex) +{ + int i, petindex; + + print( "\nShowMyDepotPets:\n"); + if( !CHAR_CheckDepotPet( charaindex) ) return; + for( i=0; iindexOfExistDepotPets == NULL ) return FALSE; + return TRUE; +} + +#endif + + + +#ifdef _NPC_SEPARATEDATA +void CHAR_showTempInt( int index) +{ + int j; + CHAR_chara[index].tempint = allocateMemory( sizeof( int ) * 10 ); + //andy_log + print("\n CHAR_chara[%d].tempint: %x\n", index, CHAR_chara[index].tempint ); + for( j=0; j<10; j++){ + print("%d,", CHAR_chara[index].tempint[j] ); + } + //andy_log + print("]\n"); +} + +BOOL CHAR_InitCharTempNum( Char* ch ) +{ + int j; + ch->tempint = allocateMemory( sizeof( int ) * 10 ); + print("\n init temp:%x,", ch->tempint ); + for( j=0; j<10; j++){ + ch->tempint[j] = 0; + print("%d,", ch->tempint[j] ); + } + return TRUE; +} + +void CHAR_EndCharTempNum( void ) +{ + int i; + + for( i = 0 ; i < CHAR_charanum ; i ++ ){ + freeMemory( CHAR_chara[i].tempint ); + } + +} + +void CHAR_getDefaultCharTempNum( Char* ch ) +{ + int j; + if( ch->tempint == NULL ) return; + for( j=0; j<10; j++){ + ch->tempint[j] = -1; + print("%d,", ch->tempint[j] ); + } +} +#endif + +#ifdef _STREET_VENDOR +BOOL CHAR_setStreetVendor(int charindex,int index,int set,int num) +{ + if(!CHAR_CHECKINDEX(charindex)) return FALSE; + if(index < 0 || index > MAX_SELL_ITEM) return FALSE; + switch(set){ + case SV_PILE: + CHAR_chara[charindex].StreetVendor[index].pile = num; + break; + case SV_PRICE: + CHAR_chara[charindex].StreetVendor[index].price = num; + break; + case SV_INDEX: + CHAR_chara[charindex].StreetVendor[index].index = num; + break; + case SV_KIND: + CHAR_chara[charindex].StreetVendor[index].kind = num; + break; + } + CHAR_chara[charindex].StreetVendor[index].usage = TRUE; + return TRUE; +} + +INLINE void CHAR_clearStreetVendor(int charindex,int index) +{ + if(!CHAR_CHECKINDEX(charindex)) return; + if(index < 0 || index > MAX_SELL_ITEM) return; + CHAR_chara[charindex].StreetVendor[index].index = -1; + CHAR_chara[charindex].StreetVendor[index].price = 0; + CHAR_chara[charindex].StreetVendor[index].pile = 0; + CHAR_chara[charindex].StreetVendor[index].kind = -1; + CHAR_chara[charindex].StreetVendor[index].usage = FALSE; +} + +int CHAR_getStreetVendor(int charindex,int index,int set) +{ + if(!CHAR_CHECKINDEX(charindex)) return -1; + if(index < 0 || index > MAX_SELL_ITEM) return -1; + switch(set){ + case SV_PILE: + return CHAR_chara[charindex].StreetVendor[index].pile; + case SV_PRICE: + return CHAR_chara[charindex].StreetVendor[index].price; + case SV_INDEX: + return CHAR_chara[charindex].StreetVendor[index].index; + case SV_KIND: + return CHAR_chara[charindex].StreetVendor[index].kind; + case SV_USAGE: + return CHAR_chara[charindex].StreetVendor[index].usage; + } + return -1; +} +#endif + +#ifdef _CHAR_POOLPET +int CHAR_getCharDepotPetElement( int charaindex ) +{ + int i; + int limit; + if( !CHAR_CHECKINDEX(charaindex))return -1; + + //andy_reEdit 2003/09/18 + //limit = (CHAR_getInt(charaindex,CHAR_TRANSMIGRATION)*2)+5; + //limit = min( limit, CHAR_MAXPOOLPETHAVE); + limit = CHAR_MAXDEPOTPETHAVE; + for( i = 0; i < limit; i ++ ) { + if( CHAR_getDepotPetIndex( charaindex,i) == -1 ) break; + } + return ( i == limit ? -1:i ); +} +#endif diff --git a/gmsv/char/char_data.c b/gmsv/char/char_data.c new file mode 100644 index 0000000..03dfa0e --- /dev/null +++ b/gmsv/char/char_data.c @@ -0,0 +1,1908 @@ +#include "version.h" +#include +#include +#ifdef _REDHAT_V9 +#include +#endif + +#include "readmap.h" +#include "common.h" +#include "util.h" +#include "anim_tbl.h" +#include "battle.h" +#include "char.h" +#include "char_data.h" +#include "buf.h" +#include "item.h" +#include "log.h" +#include "pet.h" +#include "enemy.h" +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 +#include "char_base.h" +#include "configfile.h" +#endif + + +#include "defaultPlayer.h" +#include "defaultGroundEnemy.h" + + +#include "ls2data.dat" + +// CoolFish: Family 2001/7/28 +#include "family.h" +#include "saacproto_cli.h" + +#ifdef _PET_LIMITLEVEL +void CHAR_CheckPetDoLimitlevel( int petindex , int toindex, int level); +#endif + + +typedef struct tagdefaultCharcterGet +{ + int imagenumber; + Char* initchardata; + LevelUpPattern* lvpattern; + CHAR_ImageType imgtype; +}defaultCharacterGet; + +static defaultCharacterGet CHAR_defaultCharacterGet[]= +{ + /* CHAR_DEFAULTPLAYER */ +//阂间裆ㄠ + {SPR_001em,&player,&lvplayer00,CHAR_IMAGETYPE_CHILDBOY}, + {SPR_002em,&player,&lvplayer00,CHAR_IMAGETYPE_CHILDBOY}, + {SPR_003em,&player,&lvplayer00,CHAR_IMAGETYPE_CHILDBOY}, + {SPR_004em,&player,&lvplayer00,CHAR_IMAGETYPE_CHILDBOY}, + +//剂 ㄠ + {SPR_011em,&player,&lvplayer00,CHAR_IMAGETYPE_BOY}, + {SPR_012em,&player,&lvplayer00,CHAR_IMAGETYPE_BOY}, + {SPR_013em,&player,&lvplayer00,CHAR_IMAGETYPE_BOY}, + {SPR_014em,&player,&lvplayer00,CHAR_IMAGETYPE_BOY}, + +//剂 ㄡ + {SPR_021em,&player,&lvplayer00,CHAR_IMAGETYPE_BOY}, + {SPR_022em,&player,&lvplayer00,CHAR_IMAGETYPE_BOY}, + {SPR_023em,&player,&lvplayer00,CHAR_IMAGETYPE_BOY}, + {SPR_024em,&player,&lvplayer00,CHAR_IMAGETYPE_BOY}, + +//剂 ㄢ + {SPR_031em,&player,&lvplayer00,CHAR_IMAGETYPE_BOY}, + {SPR_032em,&player,&lvplayer00,CHAR_IMAGETYPE_BOY}, + {SPR_033em,&player,&lvplayer00,CHAR_IMAGETYPE_BOY}, + {SPR_034em,&player,&lvplayer00,CHAR_IMAGETYPE_BOY}, + +//敛 ㄠ + {SPR_041em,&player,&lvplayer00,CHAR_IMAGETYPE_MAN}, + {SPR_042em,&player,&lvplayer00,CHAR_IMAGETYPE_MAN}, + {SPR_043em,&player,&lvplayer00,CHAR_IMAGETYPE_MAN}, + {SPR_044em,&player,&lvplayer00,CHAR_IMAGETYPE_MAN}, + +//敛 ㄡ + {SPR_051em,&player,&lvplayer00,CHAR_IMAGETYPE_MAN}, + {SPR_052em,&player,&lvplayer00,CHAR_IMAGETYPE_MAN}, + {SPR_053em,&player,&lvplayer00,CHAR_IMAGETYPE_MAN}, + {SPR_054em,&player,&lvplayer00,CHAR_IMAGETYPE_MAN}, + +//阂间辉ㄠ + {SPR_061em,&player,&lvplayer00,CHAR_IMAGETYPE_CHILDGIRL}, + {SPR_062em,&player,&lvplayer00,CHAR_IMAGETYPE_CHILDGIRL}, + {SPR_063em,&player,&lvplayer00,CHAR_IMAGETYPE_CHILDGIRL}, + {SPR_064em,&player,&lvplayer00,CHAR_IMAGETYPE_CHILDGIRL}, + +//剂辉ㄠ + {SPR_071em,&player,&lvplayer00,CHAR_IMAGETYPE_GIRL}, + {SPR_072em,&player,&lvplayer00,CHAR_IMAGETYPE_GIRL}, + {SPR_073em,&player,&lvplayer00,CHAR_IMAGETYPE_GIRL}, + {SPR_074em,&player,&lvplayer00,CHAR_IMAGETYPE_GIRL}, + +//剂辉ㄡ + {SPR_081em,&player,&lvplayer00,CHAR_IMAGETYPE_GIRL}, + {SPR_082em,&player,&lvplayer00,CHAR_IMAGETYPE_GIRL}, + {SPR_083em,&player,&lvplayer00,CHAR_IMAGETYPE_GIRL}, + {SPR_084em,&player,&lvplayer00,CHAR_IMAGETYPE_GIRL}, + +//剂辉ㄢ + {SPR_091em,&player,&lvplayer00,CHAR_IMAGETYPE_GIRL}, + {SPR_092em,&player,&lvplayer00,CHAR_IMAGETYPE_GIRL}, + {SPR_093em,&player,&lvplayer00,CHAR_IMAGETYPE_GIRL}, + {SPR_094em,&player,&lvplayer00,CHAR_IMAGETYPE_GIRL}, + +//辉岭ㄠ + {SPR_101em,&player,&lvplayer00,CHAR_IMAGETYPE_WOMAN}, + {SPR_102em,&player,&lvplayer00,CHAR_IMAGETYPE_WOMAN}, + {SPR_103em,&player,&lvplayer00,CHAR_IMAGETYPE_WOMAN}, + {SPR_104em,&player,&lvplayer00,CHAR_IMAGETYPE_WOMAN}, + +//辉岭ㄡ + {SPR_111em,&player,&lvplayer00,CHAR_IMAGETYPE_WOMAN}, + {SPR_112em,&player,&lvplayer00,CHAR_IMAGETYPE_WOMAN}, + {SPR_113em,&player,&lvplayer00,CHAR_IMAGETYPE_WOMAN}, + {SPR_114em,&player,&lvplayer00,CHAR_IMAGETYPE_WOMAN}, + + {SPR_pet001,&player,&lvplayer00,CHAR_IMAGETYPE_DOG}, + {SPR_pet002,&player,&lvplayer00,CHAR_IMAGETYPE_DOG}, + {SPR_pet003,&player,&lvplayer00,CHAR_IMAGETYPE_DOG}, + {SPR_pet004,&player,&lvplayer00,CHAR_IMAGETYPE_DOG}, + {SPR_pet011,&player,&lvplayer00,CHAR_IMAGETYPE_DOG}, +}; + +BOOL CHAR_getDefaultChar( Char* nc , int imagenumber ) +{ + int i, j; + int defcharaindex; + + Char* defaultchar; + defaultchar = CHAR_defaultCharacterGet[arraysizeof(CHAR_defaultCharacterGet) - 1].initchardata; + + memset( nc,0,sizeof(Char) ); + defcharaindex = 0; + for( i = 0 ; i < arraysizeof( CHAR_defaultCharacterGet ) ; i ++ ){ + if( CHAR_defaultCharacterGet[i].imagenumber == imagenumber ){ + defaultchar = CHAR_defaultCharacterGet[i].initchardata; + defcharaindex = i; + break; + } + } + nc->data[CHAR_IMAGETYPE] = CHAR_defaultCharacterGet[defcharaindex].imgtype; + nc->use = TRUE; + +#ifdef _CHAR_FIXDATADEF + for( j = 0 ; j < CHAR_DATAINTNUM ; j ++ ){ + if( j < CHAR_INITDATA ) nc->data[j] = defaultchar->data[j]; + else nc->data[j] = 0; + } +#else + for( j = 0 ; j < CHAR_DATAINTNUM ; j ++ ) + nc->data[j] = defaultchar->data[j]; +#endif + for( j = 0 ; j < arraysizeof( nc->flg ) ; j ++ ) + nc->flg[j] = defaultchar->flg[j]; + + for( j = 0 ; j < CHAR_DATACHARNUM ; j ++ ) + nc->string[j].string[0] = '\0'; + for( j = 0 ; j < CHAR_MAXITEMHAVE ; j ++ ) + nc->indexOfExistItems[j] = -1; + for( j = 0 ; j < CHAR_MAXPOOLITEMHAVE ; j ++ ) + nc->indexOfExistPoolItems[j] = -1; + for( j = 0 ; j < CHAR_MAXPETSKILLHAVE ; j ++ ) + nc->unionTable.indexOfPetskill[j] = -1; + for( j = 0 ; j < CHAR_MAXPOOLPETHAVE ; j ++ ) + nc->indexOfPoolPet[j] = -1; + for( j = 0 ; j < CHAR_SKILLMAXHAVE ; j ++ ) + nc->haveSkill[j].use = FALSE; + for( j = 0 ; j < CHAR_TITLEMAXHAVE ; j ++ ) + nc->indexOfHaveTitle[j] = -1; + for( j=0 ; jaddressBook[j],0,sizeof(nc->addressBook[j]) ); + for( j = 0 ; j < CHAR_WORKDATAINTNUM ; j ++ ) + nc->workint[j] = 0; + for( j = 0 ; j < CHAR_WORKDATACHARNUM ; j ++ ) + nc->workchar[j].string[0] = '\0'; + nc->workint[CHAR_WORKFD] = -1; + nc->workint[CHAR_WORKCHATROOMNUM] = -1; +#ifdef _DEATH_CONTEND + nc->data[CHAR_PKLISTTEAMNUM] = -1; + nc->data[CHAR_PKLISTLEADER] = -1; +#endif +#ifdef _NPC_SEPARATEDATA + CHAR_getDefaultCharTempNum( nc); +#endif + + return TRUE; +} + +static int CHAR_playerImageNumber[]= +{ + /* CHAR_DEFAULTPLAYER */ + SPR_001em,SPR_002em,SPR_003em,SPR_004em,SPR_011em,SPR_012em, + SPR_013em,SPR_014em,SPR_021em,SPR_022em,SPR_023em,SPR_024em, + SPR_031em,SPR_032em,SPR_033em,SPR_034em,SPR_041em,SPR_042em, + SPR_043em,SPR_044em,SPR_051em,SPR_052em,SPR_053em,SPR_054em, + SPR_061em,SPR_062em,SPR_063em,SPR_064em,SPR_071em,SPR_072em, + SPR_073em,SPR_074em,SPR_081em,SPR_082em,SPR_083em,SPR_084em, + SPR_091em,SPR_092em,SPR_093em,SPR_094em,SPR_101em,SPR_102em, + SPR_103em,SPR_104em,SPR_111em,SPR_112em,SPR_113em,SPR_114em +}; + +BOOL CHAR_checkPlayerImageNumber( int imagenumber) +{ + int i; + for( i = 0; i < arraysizeof( CHAR_playerImageNumber); i ++ ) { + if( imagenumber == CHAR_playerImageNumber[i] ) break; + } + if( i == arraysizeof( CHAR_playerImageNumber)) return FALSE; + else return TRUE; +} +/*------------------------------------------------------------ + * 涌 飓 寞及民尼永弁 + * + * 涌 飓 寞反动票及白巧□穴永玄匹瑁引匀化中月 + * number = 窒谛 井 + * CG_CHR_MAKE_FACE + (number*100) + ( 缙 number * 25) + ( 寞 * 5 ) + 轼 寞 + * + ------------------------------------------------------------*/ +BOOL CHAR_checkFaceImageNumber( int imagenumber, int faceimagenumber) +{ + int image = imagenumber - SPR_001em; + int number; + int color; + number = (faceimagenumber - CG_CHR_MAKE_FACE)/ 100*20; + color = ((faceimagenumber - CG_CHR_MAKE_FACE)% 100) / 25*5; + if( image != number + color ) return FALSE; + return TRUE; +} +// 平乓仿 飓 □皮伙[ㄠ 丐凶曰隶 ㄤ潘 +int CHAR_eqimagetbl[][5]={ + // 允匹 {{{{ 轺徇 键 菰 + { SPR_001em,SPR_001ax,SPR_001cl,SPR_001sp,SPR_001bw }, + { SPR_002em,SPR_002ax,SPR_002cl,SPR_002sp,SPR_002bw }, + { SPR_003em,SPR_003ax,SPR_003cl,SPR_003sp,SPR_003bw }, + { SPR_004em,SPR_004ax,SPR_004cl,SPR_004sp,SPR_004bw }, + { SPR_011em,SPR_011ax,SPR_011cl,SPR_011sp,SPR_011bw }, + { SPR_012em,SPR_012ax,SPR_012cl,SPR_012sp,SPR_012bw }, + { SPR_013em,SPR_013ax,SPR_013cl,SPR_013sp,SPR_013bw }, + { SPR_014em,SPR_014ax,SPR_014cl,SPR_014sp,SPR_014bw }, + { SPR_021em,SPR_021ax,SPR_021cl,SPR_021sp,SPR_021bw }, + { SPR_022em,SPR_022ax,SPR_022cl,SPR_022sp,SPR_022bw }, + { SPR_023em,SPR_023ax,SPR_023cl,SPR_023sp,SPR_023bw }, + { SPR_024em,SPR_024ax,SPR_024cl,SPR_024sp,SPR_024bw }, + { SPR_021em,SPR_021ax,SPR_021cl,SPR_021sp,SPR_021bw }, + { SPR_031em,SPR_031ax,SPR_031cl,SPR_031sp,SPR_031bw }, + { SPR_032em,SPR_032ax,SPR_032cl,SPR_032sp,SPR_032bw }, + { SPR_033em,SPR_033ax,SPR_033cl,SPR_033sp,SPR_033bw }, + { SPR_034em,SPR_034ax,SPR_034cl,SPR_034sp,SPR_034bw }, + { SPR_041em,SPR_041ax,SPR_041cl,SPR_041sp,SPR_041bw }, + { SPR_042em,SPR_042ax,SPR_042cl,SPR_042sp,SPR_042bw }, + { SPR_043em,SPR_043ax,SPR_043cl,SPR_043sp,SPR_043bw }, + { SPR_044em,SPR_044ax,SPR_044cl,SPR_044sp,SPR_044bw }, + + { SPR_051em,SPR_051ax,SPR_051cl,SPR_051sp,SPR_051bw }, + { SPR_052em,SPR_052ax,SPR_052cl,SPR_052sp,SPR_052bw }, + { SPR_053em,SPR_053ax,SPR_053cl,SPR_053sp,SPR_053bw }, + { SPR_054em,SPR_054ax,SPR_054cl,SPR_054sp,SPR_054bw }, + + { SPR_061em,SPR_061ax,SPR_061cl,SPR_061sp,SPR_061bw }, + { SPR_062em,SPR_062ax,SPR_062cl,SPR_062sp,SPR_062bw }, + { SPR_063em,SPR_063ax,SPR_063cl,SPR_063sp,SPR_063bw }, + { SPR_064em,SPR_064ax,SPR_064cl,SPR_064sp,SPR_064bw }, + + { SPR_071em,SPR_071ax,SPR_071cl,SPR_071sp,SPR_071bw }, + { SPR_072em,SPR_072ax,SPR_072cl,SPR_072sp,SPR_072bw }, + { SPR_073em,SPR_073ax,SPR_073cl,SPR_073sp,SPR_073bw }, + { SPR_074em,SPR_074ax,SPR_074cl,SPR_074sp,SPR_074bw }, + + { SPR_081em,SPR_081ax,SPR_081cl,SPR_081sp,SPR_081bw }, + { SPR_082em,SPR_082ax,SPR_082cl,SPR_082sp,SPR_082bw }, + { SPR_083em,SPR_083ax,SPR_083cl,SPR_083sp,SPR_083bw }, + { SPR_084em,SPR_084ax,SPR_084cl,SPR_084sp,SPR_084bw }, + + { SPR_091em,SPR_091ax,SPR_091cl,SPR_091sp,SPR_091bw }, + { SPR_092em,SPR_092ax,SPR_092cl,SPR_092sp,SPR_092bw }, + { SPR_093em,SPR_093ax,SPR_093cl,SPR_093sp,SPR_093bw }, + { SPR_094em,SPR_094ax,SPR_094cl,SPR_094sp,SPR_094bw }, + + { SPR_101em,SPR_101ax,SPR_101cl,SPR_101sp,SPR_101bw }, + { SPR_102em,SPR_102ax,SPR_102cl,SPR_102sp,SPR_102bw }, + { SPR_103em,SPR_103ax,SPR_103cl,SPR_103sp,SPR_103bw }, + { SPR_104em,SPR_104ax,SPR_104cl,SPR_104sp,SPR_104bw }, + + { SPR_111em,SPR_111ax,SPR_111cl,SPR_111sp,SPR_111bw }, + { SPR_112em,SPR_112ax,SPR_112cl,SPR_112sp,SPR_112bw }, + { SPR_113em,SPR_113ax,SPR_113cl,SPR_113sp,SPR_113bw }, + { SPR_114em,SPR_114ax,SPR_114cl,SPR_114sp,SPR_114bw }, + + { SPR_091em,SPR_091ax,SPR_091cl,SPR_091sp,SPR_091bw }, + { SPR_092em,SPR_092ax,SPR_092cl,SPR_092sp,SPR_092bw }, + + { SPR_pet001,SPR_pet001,SPR_pet001,SPR_pet001,SPR_pet001}, + { SPR_pet002,SPR_pet002,SPR_pet002,SPR_pet002,SPR_pet002}, + { SPR_pet003,SPR_pet003,SPR_pet003,SPR_pet003,SPR_pet003}, + { SPR_pet004,SPR_pet004,SPR_pet004,SPR_pet004,SPR_pet004}, + + { SPR_pet011,SPR_pet011,SPR_pet011,SPR_pet011,SPR_pet011}, + + { SPR_121em,SPR_121ax,SPR_121cl,SPR_121sp,SPR_121bw }, + { SPR_122em,SPR_122ax,SPR_122cl,SPR_122sp,SPR_122bw }, + + { SPR_131em,SPR_131ax,SPR_131cl,SPR_131sp,SPR_131bw }, + { SPR_132em,SPR_132ax,SPR_132cl,SPR_132sp,SPR_132bw }, + { SPR_133em,SPR_133ax,SPR_133cl,SPR_133sp,SPR_133bw }, + + { SPR_141em,SPR_141ax,SPR_141cl,SPR_141sp,SPR_141bw }, + { SPR_142em,SPR_142ax,SPR_142cl,SPR_142sp,SPR_142bw }, + + { SPR_151em,SPR_151ax,SPR_151cl,SPR_151sp,SPR_151bw }, + { SPR_152em,SPR_152ax,SPR_152cl,SPR_152sp,SPR_152bw }, + + { SPR_161em,SPR_161ax,SPR_161cl,SPR_161sp,SPR_161bw }, + { SPR_162em,SPR_162ax,SPR_162cl,SPR_162sp,SPR_162bw }, + +}; + +/*------------------------------------------------------------ + * 隶 午 飓 寞井日蕙仄中 飓 寞毛 月[ + * 娄醒 + * basebaseimagenumber int 葭卞卅月 飓 寞 + * category ITEM_CATEGORY 失奶 丞及市 打伉 + * 忒曰袄 + * 蕙仄中 飓 寞[巨仿□及凛反}-1 + ------------------------------------------------------------*/ +int CHAR_getNewImagenumberFromEquip( int basebaseimagenumber, + ITEM_CATEGORY category ) +{ + int i; + /* ITEM_CATEGORY 民尼永弁 */ + if( category < 0 || category > arraysizeof(CHAR_eqimagetbl[0]) ) + return -1; + for( i=0 ; i rx )swap(lx,rx); + if( ly > ry )swap(ly,ry); + + CHAR_invarea[invreadlen].area.x = lx; + CHAR_invarea[invreadlen].area.y = ly; + CHAR_invarea[invreadlen].area.width = rx-lx; + CHAR_invarea[invreadlen].area.height= ry-ly; + invreadlen ++; + } + } + fclose(f); + CHAR_invareanum = invreadlen; + print( "有效不可战斗有效数是 %d...", CHAR_invareanum ); +#if 0 +{ + int i,j; + for( i=0; i 3 ) { + return FALSE; + } + index=hometown; +#endif + if( index >= arraysizeof( elders ) ){ + return FALSE; + } + + ch->data[CHAR_FLOOR] = elders[index].floor; + ch->data[CHAR_X] = elders[index].x; + ch->data[CHAR_Y] = elders[index].y; + ch->data[CHAR_LASTTALKELDER] = index; + point = ch->data[CHAR_SAVEPOINT]; + + +#ifdef _DELBORNPLACE //Syu ADD 6.0 统一出生於新手村 + if( getMuseum() ) { + ch->data[CHAR_FLOOR] = 815; + ch->data[CHAR_X] = 29; + ch->data[CHAR_Y] = 40; + ch->data[CHAR_LASTTALKELDER] = 35; + // point = point | (1<<35) ; + point = point | (1<data[CHAR_FLOOR] = 9000; + ch->data[CHAR_X] = 40; + ch->data[CHAR_Y] = 40; + } +#endif + + ch->data[CHAR_SAVEPOINT] = point; + + if( MAP_checkCoordinates( ch->data[CHAR_FLOOR], ch->data[CHAR_X], + ch->data[CHAR_Y] ) == FALSE ){ + return FALSE; + } + + return TRUE; +} + +/*------------------------------------------------------------ + * 巨伙母□及桦赭毛 月 + * 娄醒 + * elderindex int 巨伙母□奶件犯永弁旦 + * fl int* 白夫失毛熬仃潸月桦赭 + * x int* x毛熬仃潸月桦赭 + * y int* y毛熬仃潸月桦赭 + * 娄醒 + * 岳 TRUE(1) + * 撩 FALSE(0) + ------------------------------------------------------------*/ +BOOL CHAR_getElderPosition( int elderindex, int* fl, int* x, int* y ) +{ + if( elderindex<0 || arraysizeof(elders)<=elderindex )return FALSE; + + *fl = elders[elderindex].floor; + *x = elders[elderindex].x; + *y = elders[elderindex].y; + return TRUE; +} +/*------------------------------------------------------------ + * 赢 NPC互愤坌及赓渝祭及午五卞}赢 卞踏五仇戈及分[ + * 公及凶户及奶件正□白尼奶旦 + * 娄醒 + * index int 左□田□匹 撩 仄凶日FALSE 毛井尹允 + * fl int 匏 及树 + * x int + * y int + * NPC及伙□民件井日银歹木月及分[ + ------------------------------------------------------------*/ +BOOL CHAR_ElderSetPosition( int elderindex ,int fl,int x ,int y) +{ + if( elderindex < ELDERINDEXSTART || + elderindex >= MAXELDERS ){ + return FALSE; + } + + elders[elderindex].floor = fl; + elders[elderindex].x = x; + elders[elderindex].y = y; + return TRUE; +} + + +void CHAR_setInitValues( Char* ch ) +{ + +#ifndef _PROFESSION_SKILL // WON ADD 人物职业技能 + + static int CHAR_titleindextbl[] ={ 0,1,2,3,4,5,6 }; + int elderindex; + int i; + BOOL magician=FALSE; + BOOL priest=FALSE; + + elderindex = ch->data[CHAR_LASTTALKELDER]; + if( 0 <= elderindex + && elderindex < arraysizeof( CHAR_titleindextbl ) ) + ch->indexOfHaveTitle[0] = CHAR_titleindextbl[elderindex]; + + + for( i=0 ; ihaveSkill[i].use ){ + int j; + int skindex=ch->haveSkill[i].skill.data[SKILL_IDENTITY]; + + for( j=0 ; jdata[CHAR_GOLD] = 20; + + if( skindex == SKILL_MAGICIAN ) + magician = TRUE; + else if( skindex == SKILL_PRIEST ) + priest = TRUE; + + } + } + + if( magician || priest ) CHAR_addItemToChar( ch, 802 ); + +#endif +} + + +#if 1 +static int EnemyExpTbl[]={ +0, // 0 +2, // 1 +4, // 2 +6, // 3 +8, // 4 +10, // 5 +12, // 6 +14, // 7 +16, // 8 +18, // 9 +20, // 10 +26, // 11 +32, // 12 +38, // 13 +44, // 14 +50, // 15 +60, // 16 +70, // 17 +80, // 18 +90, // 19 +100, // 20 +115, // 21 +130, // 22 +145, // 23 +160, // 24 +175, // 25 +190, // 26 +205, // 27 +220, // 28 +235, // 29 +250, // 30 +270, // 31 +290, // 32 +310, // 33 +330, // 34 +350, // 35 +375, // 36 +400, // 37 +425, // 38 +450, // 39 +475, // 40 +500, // 41 +525, // 42 +550, // 43 +575, // 44 +600, // 45 +625, // 46 +650, // 47 +675, // 48 +700, // 49 +725, // 50 +750, // 51 +775, // 52 +800, // 53 +825, // 54 +850, // 55 +875, // 56 +900, // 57 +925, // 58 +950, // 59 +980, // 60 +1010, // 61 +1040, // 62 +1070, // 63 +1100, // 64 +1130, // 65 +1160, // 66 +1190, // 67 +1220, // 68 +1250, // 69 +1280, // 70 +1310, // 71 +1345, // 72 +1380, // 73 +1415, // 74 +1450, // 75 +1485, // 76 +1520, // 77 +1555, // 78 +1590, // 79 +1630, // 80 +1670, // 81 +1710, // 82 +1750, // 83 +1790, // 84 +1830, // 85 +1870, // 86 +1910, // 87 +1950, // 88 +1990 // 89 +}; // 90 + + + + + + + + + + + + + + + + +// 酵烂读卅烦董袄煌遥 +int GetEnemyExp( int level ){ +/* + int exp = 0; + if( level < 5 ){ + exp = 2 * level; + }else + if( level < 10 ){ + exp = 10 * level; + }else + if( level < 20 ){ + exp = 15 * level; + }else + if( level < 30 ){ + exp = 30 * level; + }else + if( level < 40 ){ + exp = 50 * level; + }else + if( level < 50 ){ + exp =60 * level; + }else + if( level < 60 ){ + exp =60 * level; + }else{ + exp =70 * level; + } +*/ + if( level >= arraysizeof( EnemyExpTbl ) )level = arraysizeof( EnemyExpTbl )-1; + return EnemyExpTbl[level]; +} +#endif + +#ifdef _NEWOPEN_MAXEXP +/*static int NeedLevelUpTbls[] = { + 0, 0, + 2, 6, 18, 37, 67, 110, 170, + 246, 344, 464, 610, 782, 986, 1221, + 1491, 1798, 2146, 2534, 2968, 3448, 3978, + 4558, 5194, 5885, 6635, 7446, 8322, 9262, + 10272, 11352, 12506, 13734, 15042, 16429, 17899, + 19454, 21098, 22830, 24656, 26576, 28594, 30710, + 32930, 35253, 37683, 40222, 42874, 45638, 48520, + 51520, 54642, 57886, 61258, 64757, 68387, 72150, + 76050, 80086, 84264, 106110, 113412, 121149, 129352, + 138044, 147256, 157019, 167366, 178334, 189958, 202282, + 215348, 229205, 243901, 259495, 276041, 293606, 312258, + 332071, 353126, 375511, 399318, 424655, 451631, 480370, + 511007, 543686, 578571, 615838, 655680, 698312, 743971, + 792917, 845443, 901868, 962554, 1027899, 1098353, 1174420, + 1256663, 1345723, 1442322, 1547281, 1661531, 1786143, 1922340, + 2071533, 2235351, 2415689, 2614754, 2835137, 3079892, 3352633, + 3657676, 4000195, 4386445, 4824041, 5322323, 5892866, 6550125, + 12326614, 15496114, 20025638, 26821885, 37698249, 56734876, 68097265, + 68290815, 68487425, 68687119, 68889921, 69095855, 69304945, 69517215, + 69732689, 69951391, 70173345, 70398575, 70627105, 70858959, 71244161, + 71342735, 71584705, 71830095, 72078929, 72331231, 72587025, 72846335, + 73109185, 73615599, 73655601, 73929215, 74206465, 74487375, 74771969, + 75060271, 75352305, 75648095, 75947665, 76421039, 76563241, 76874295, + 77189225, 77508055, 77830809, 78157511, 78488185, 78822855, 79161545, + 79724279, 79856081, 80206975, 80561985, 80921135, 81284449, 81651951, + 82023665, 82399615, 82779825, 83434319, 83558121, 83951255, 84348745, + 84750615, 85156889, 85567591, 85982745, 86402375, 86826505, 87575159, + 87693361, 88131135, 88573505, 89020495, 89472129, 89928431, 90389425, + 90855135, 91325585, 91800799 +}; +*/ +#endif +static int LevelUpTbl[] = { // 经验值 等级 换算表 +0, // 0 EX=(lv^4)/10 +0, // 1 + 2, 8, 25, 62, 129, + 240, 409, 656, 1000, 1464, // 11 + 2073, 2856, 3841, 5062, 6553, // 16 + 8352, 10497, 13032, 16000, 19448, 23425, // 22 + 27984, 33177, 39062, 45697, 53144, 61465, // 28 + 70728, 81000, 92352, 104857, 118592, 133633, // 34 + 150062, 167961, 187416, 208513, 231344, 256000, // 40 + 282576, 311169, 341880, 374809, 410062, 447745, // 46 + 487968, 530841, 576480, 625000, 676520, 731161, // 52 + 789048, 850305, 915062, 983449, 1055600, 1131649, // 58 + 1211736, 1296000, + 1402110, // 61 EX=(lv^4)/(10-0.125*(lv-60)) + 1515521, 1636671, 1766022, 1904066, 2051322, 2208342, // 67 + 2375708, 2554041, 2744000, 2946281, 3161630, 3390834, // 73 + 3634736, 3894230, 4170272, 4463878, 4776136, 5108207, // 79 + 5461333, 5836843, 6236162, 6660816, 7112448, 7592818, // 85 + 8103824, 8647511, 9226082, 9841920, 10497600, 11195912, // 91 + 11939882, 12732800, 13578242, 14480111, 15442664, 16470563, // 97 + 17568917, 18743336, 20000000, 21345723, 22788045, 24335325, // 103 + 25996856, 27783000, 29705340, 31776872, 34012224, 36427912, // 109 + 39042666, 41877804, 44957696, 48310329, 51968004, 55968200, // 115 + 60354645, 65178685, 70501009, 76393874, 82944000, + + 95270613, // 121 Nuke 0624 EX=(lv^4)/(2.5-0.25*(lv-120)) + 110766728, 130792366, 157614250, 195312500, // 125 + 252047376, // 126 EX=lv^4+60000000*(lv-126)^2 Nuke 0816 + 320144641, 388435456, 456922881, 525610000, 594499921, 663595776, // 132 + 732900721, 802417936, 872150625, 942102016,1012275361,1082673936, // 138 + 1153301041,1224160000 // 140 +}; + +int CHAR_GetLevel() +{ + return arraysizeof( LevelUpTbl )-1; +} +int CHAR_GetLevelExp( int charaindex, int level) +{ +#ifdef _NEWOPEN_MAXEXP +#ifdef _USER_EXP_CF + if(level>getMaxLevel())level=getMaxLevel(); + if(level>getYBLevel()) + if (CHAR_getInt(charaindex, CHAR_WHICHTYPE)==CHAR_TYPEPET) { + if(CHAR_getInt(charaindex,CHAR_TRANSMIGRATION)= arraysizeof( NeedLevelUpTbls ) ){ + return -1; + } + return NeedLevelUpTbls[level];*/ +#else + if( level >= arraysizeof( LevelUpTbl ) ){ + return -1; + } + return LevelUpTbl[level]; +#endif +} + +int CHAR_GetOldLevelExp( int level) +{ + if( level >= arraysizeof( LevelUpTbl ) ){ + return -1; + } + return LevelUpTbl[level]; +} + +int CHAR_LevelUpCheck( int charaindex , int toindex) +{ + int exp, level, nextexp, iRet = FALSE; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return 0; + exp = CHAR_getInt( charaindex, CHAR_EXP ); + while( 1 ){ + level = CHAR_getInt( charaindex, CHAR_LV ); + nextexp = CHAR_GetLevelExp( charaindex, level+1); + if( nextexp < 0 ) + break; + // Arminius 7.30 pet limit lv + if (CHAR_getInt(charaindex, CHAR_WHICHTYPE)==CHAR_TYPEPET) { + + if (level >= CHAR_getInt(charaindex, CHAR_LIMITLEVEL) && + CHAR_getInt(charaindex, CHAR_LIMITLEVEL) > 0 ) { +#ifdef _NEWOPEN_MAXEXP + CHAR_setInt( charaindex, CHAR_EXP , 0); +#else +#ifdef _PET_LIMITLEVEL + if( CHAR_getInt( charaindex, CHAR_PETID) == 718 +#ifdef _PET_2LIMITLEVEL + || CHAR_getInt( charaindex, CHAR_PETID) == 401 +#endif + ) { + nextexp = CHAR_GetLevelExp( charaindex, CHAR_getInt(charaindex, CHAR_LIMITLEVEL)); + CHAR_setInt( charaindex, CHAR_EXP , nextexp ); + } +#endif +#endif + break; + } + } + if( exp >= nextexp ){ + iRet ++; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + CHAR_setInt( charaindex, CHAR_DUELPOINT, + CHAR_getInt( charaindex, CHAR_DUELPOINT) + (level+1)*10 ); + } +#ifdef _PET_LIMITLEVEL + else { + CHAR_CheckPetDoLimitlevel( charaindex, toindex, level ); + } +#endif + +#ifdef _NEWOPEN_MAXEXP + if( level >= CHAR_MAXUPLEVEL ){ + }else{ + if( CHAR_HandleExp( charaindex) != -1 ){ + exp = CHAR_getInt( charaindex, CHAR_EXP ); + CHAR_setInt( charaindex, CHAR_LV, level+1 ); + } + } +#else + CHAR_setInt( charaindex, CHAR_LV, level+1 ); +#endif + }else{ + break; + } + } + return iRet; +} + +#ifdef _PET_LIMITLEVEL +void CHAR_CheckPetDoLimitlevel( int petindex , int toindex, int level) +{ + int LevelUpPoint,vital,str,tgh,dex; + int j,k; + char token[56]; +#define RAND(x,y) ((x-1)+1+ (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) ) + + if( CHAR_getInt( petindex, CHAR_PETID) == 718 +#ifdef _PET_2LIMITLEVEL + || CHAR_getInt( petindex, CHAR_PETID) == 401 +#endif + ) { + LevelUpPoint = CHAR_getInt( petindex, CHAR_ALLOCPOINT ); + vital = (int )(( LevelUpPoint >> 24 ) & 0xFF); + str = (int)(( LevelUpPoint >> 16 ) & 0xFF); + tgh = (int)(( LevelUpPoint >> 8 ) & 0xFF); + dex = (int)(( LevelUpPoint >> 0 ) & 0xFF); + + if( strcmp( CHAR_getChar( petindex, CHAR_OWNERCDKEY), CHAR_getChar( toindex, CHAR_CDKEY) ) || + strcmp( CHAR_getChar( petindex, CHAR_OWNERCHARANAME), CHAR_getChar( toindex, CHAR_NAME) )){ + sprintf(token,"我不认识你呀!快把我还给我主人!"); + //andy 1/11 reEdit + vital -= RAND(2,10); if (vital<0) vital=0; + str -= RAND(2,10); if (str<0) str=0; + tgh -= RAND(2,10); if (tgh<0) tgh=0; + dex -= RAND(2,10); if (dex<0) dex=0; + LevelUpPoint = (vital<<24)+(str<<16)+(tgh<<8)+(dex<<0); + + CHAR_setInt( petindex, CHAR_ALLOCPOINT , LevelUpPoint); + CHAR_talkToCli( toindex, petindex, token, CHAR_COLORWHITE); + + LogPetPointChange( + CHAR_getChar( toindex, CHAR_NAME ), + CHAR_getChar( toindex, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + petindex, 2, + CHAR_getInt( petindex, CHAR_LV), + "No_master(玛蕾不对主人)", + CHAR_getInt( toindex,CHAR_FLOOR), + CHAR_getInt( toindex,CHAR_X ), + CHAR_getInt( toindex,CHAR_Y ) + ); + } + + if( ( level % 20 ) == 0 ) { + for( j=0; j < 3; j++) { + k = RAND( 0, 3); + if( k == 0 ) + vital--; + if( k == 1 ) + str--; + if( k == 2 ) + tgh--; + if( k == 3 ) + dex--; + } + if( vital < 0 ) vital =0; + if( str < 0 ) str =0; + if( tgh < 0 ) tgh =0; + if( dex < 0 ) dex =0; + LevelUpPoint = (vital<<24)+(str<<16)+(tgh<<8)+(dex<<0); + CHAR_setInt( petindex, CHAR_ALLOCPOINT , LevelUpPoint); + //print("\n << ( level % 20 ) == 0 >> "); + LogPetPointChange( + CHAR_getChar( toindex, CHAR_NAME ), + CHAR_getChar( toindex, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + petindex,3, + CHAR_getInt( petindex, CHAR_LV), + "level%20", + CHAR_getInt( toindex,CHAR_FLOOR), + CHAR_getInt( toindex,CHAR_X ), + CHAR_getInt( toindex,CHAR_Y ) + ); + } + } +} +#endif +int CHAR_PetTakeDrop( int petindex, int floor, int ox, int oy) //强制丢弃宠物升级 +{ + int x, y, objindex; + + x = rand()%10; + y = rand()%10; + + //丢下宠物 CHAR_endCharOneArray + objindex = PET_dropPetAbsolute( petindex,floor,x,y, FALSE ); + if( objindex == -1 ) { + return -1; + } + CHAR_setWorkInt( petindex,CHAR_WORKOBJINDEX,objindex ); + CHAR_setInt( petindex, CHAR_FLOOR, floor); + CHAR_setInt( petindex, CHAR_X, x); + CHAR_setInt( petindex, CHAR_Y, y); + CHAR_sendCToArroundCharacter( objindex); + + return floor; +} + +int CHAR_PetTakeLevelUp( int petindex, int lv)//强制宠物升级 +{ + int k; + for( k = 1; k < lv; k ++ ){ + CHAR_PetLevelUp( petindex ); + CHAR_PetAddVariableAi( petindex, AI_FIX_PETLEVELUP ); + CHAR_setInt( petindex, CHAR_LV, CHAR_getInt( petindex, CHAR_LV) +1 ); + } + + CHAR_complianceParameter( petindex ); + return k; +} + +#ifdef _NEW_MANOR_LAW +extern struct FM_POINTLIST fmpointlist; +#endif + +int CHAR_PetLevelUp( int petindex ) +{ + struct _RankRandTbl{ + int min; + int max; + }RankRandTbl[] = { + { 450, 500 }, + { 470, 520 }, + { 490, 540 }, + { 510, 560 }, + { 530, 580 }, + { 550, 600 }, + }; + + float Param[4] = { 0.0, 0.0, 0.0, 0.0 }; + int LevelUpPoint, petrank; + float str, vital, dex, tgh, fRand, i; +#ifdef _TEACHER_SYSTEM + int iGetFame = 0; +#endif + // 娄醒民尼永弁 + if( CHAR_CHECKINDEX( petindex ) == FALSE ) return -1; + if( CHAR_getInt( petindex, CHAR_WHICHTYPE ) != CHAR_TYPEPET )return -1; + + LevelUpPoint = CHAR_getInt( petindex, CHAR_ALLOCPOINT ); + + // 矢永玄及仿件弁 + petrank = CHAR_getInt( petindex, CHAR_PETRANK ); + if( petrank < 0 || petrank > 5 ) petrank = 0; + + // 潸 + vital = (float)(( LevelUpPoint >> 24 ) & 0xFF); + str = (float)(( LevelUpPoint >> 16 ) & 0xFF); + tgh = (float)(( LevelUpPoint >> 8 ) & 0xFF); + dex = (float)(( LevelUpPoint >> 0 ) & 0xFF); + + // ㄠㄟ荚ㄣ 扔奶戊夫毛蕊匀化备嫩 卞ㄠ箫允 + for( i = 0; i < 10; i ++ ){ + Param[RAND( 0, 3 )] += 1.0; + } + + // 仿件弁卞方月 区及仿件母丞 + fRand = (float)RAND( RankRandTbl[petrank].min, RankRandTbl[petrank].max ) + * 0.01; + + // 喃曰蕊曰禾奶件玄方曰煌遥 + vital = (float)vital * fRand + Param[0] * fRand; + str = (float)str * fRand + Param[1] * fRand; + tgh = (float)tgh * fRand + Param[2] * fRand; + dex = (float)dex * fRand + Param[3] * fRand; + + // 煌遥 + CHAR_setInt( petindex, CHAR_VITAL, + CHAR_getInt( petindex, CHAR_VITAL ) + (int)vital ); + CHAR_setInt( petindex, CHAR_STR, + CHAR_getInt( petindex, CHAR_STR ) + (int)str ); + CHAR_setInt( petindex, CHAR_TOUGH, + CHAR_getInt( petindex, CHAR_TOUGH ) + (int)tgh ); + CHAR_setInt( petindex, CHAR_DEX, + CHAR_getInt( petindex, CHAR_DEX ) + (int)dex ); + + // CoolFish: 饲育家族声望更新 + { + int level = CHAR_getInt(petindex, CHAR_LV); + int exp1 = 0, exp2 = 0, feedpoint = 0; + if (level > 30){ + char tmpbuf[128]; +#ifdef _NEW_MANOR_LAW + char tmpbuf1[16]; +#endif + int ownerindex = CHAR_getWorkInt(petindex, CHAR_WORKPLAYERINDEX); +#ifdef _FMVER21 +#else + if (CHAR_getInt(ownerindex, CHAR_FMINDEX) < 0) return 0; + if (CHAR_getInt(ownerindex, CHAR_FMLEADERFLAG) <= 0 ) return 0; + if (strcmp(CHAR_getChar(ownerindex, CHAR_FMNAME), "") == 0) return 0; +#endif + if (CHAR_CHECKINDEX(ownerindex)){ + exp1 = CHAR_GetLevelExp( petindex, level); + exp2 = CHAR_GetLevelExp( petindex,level - 1); + +#ifdef _PERSONAL_FAME // Arminius 8.30: 家族个人声望 + feedpoint = (exp1 - exp2) / 20000; // 减半 +#else + feedpoint = (exp1 - exp2) / 10000; +#endif + sprintf(tmpbuf, "%d", feedpoint); + if (feedpoint > 0){ + // CoolFish: 2001/10/03 + int fd = getfdFromCharaIndex(ownerindex); +#ifdef _PERSONAL_FAME // Arminius 8.30: 家族个人声望 + CHAR_earnFame(ownerindex, feedpoint); +#endif +#ifdef _NEW_MANOR_LAW + sprintf(tmpbuf1, "%d", CHAR_getInt(ownerindex,CHAR_FAME)); +#endif +#ifdef _FMVER21 + if (CHAR_getInt(ownerindex, CHAR_FMLEADERFLAG) > 0 + && CHAR_getInt(ownerindex, CHAR_FMLEADERFLAG) != FMMEMBER_APPLY){ + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(ownerindex, CHAR_FMNAME), + CHAR_getInt(ownerindex, CHAR_FMINDEX), + CHAR_getWorkInt(ownerindex, CHAR_WORKFMINDEXI), + FM_FIX_FMFEED, tmpbuf, +#ifndef _NEW_MANOR_LAW + "", +#else + tmpbuf1, +#endif + // CoolFish: 2001/10/03 + CHAR_getWorkInt(ownerindex, CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(fd)); + // CHAR_getWorkInt(ownerindex, CHAR_WORKFMCHARINDEX), 0); +#ifdef _NEW_MANOR_LAW + { + int i; + for(i=0;i 0){ + // 检查有没有导师 + if(strlen(CHAR_getChar(ownerindex,CHAR_TEACHER_ID)) > 0 && strlen(CHAR_getChar(ownerindex,CHAR_TEACHER_NAME)) > 0){ + int iPlayernum = CHAR_getPlayerMaxNum(),i; + char szMsg[128]; + + // 检查导师在不在线上 + for(i=0;i 0 )return 0;//检查是否为融合宠 + for( i=0; i<4; i++) { + work[i] = 0; + } + if( PET_getBaseAndSkill( charaindex, Subindex1, base, petskill, 0) == FALSE ) + return 0; + if( CHAR_getInt( Subindex1, CHAR_LV) < 80 ){//等级销弱 + for( i=0; i<4; i++) { + base[i] = base[i]*0.8; + } + } + for( i=0; i<4; i++) { + work[i] = base[i]; + } + for( i=0; i<7; i++) { + skill[i] = petskill[i]; + } + if( !CHAR_CHECKINDEX( Subindex2)) return 1; + if( EVOLUTION_getPetFusionCode( CHAR_getInt( Subindex2, CHAR_PETID) ) < 0 ){ + return 0; + } + + if( CHAR_getInt( Subindex2, CHAR_FUSIONBEIT) == 1 || + CHAR_getInt( Subindex2, CHAR_FUSIONRAISE) > 0 )return 0;//检查是否为融合宠 + + if( PET_getBaseAndSkill( charaindex, Subindex2, base, NULL, 0) == FALSE ) + return 0; + if( CHAR_getInt( Subindex2, CHAR_LV) < 80 ){//等级销弱 + for( i=0; i<4; i++) { + base[i] = base[i]*0.8; + } + } + for( i=0; i<4; i++) { + work[i] += base[i]; + } + return 2; +} + +BOOL PETFUSION_FusionPetMain( int charaindex, int Mainindex, int *work, int *skill) +{ + int i; + int base[4]={0,0,0,0}; + int petskill[7]={-1,-1,-1,-1,-1,-1,-1}; + if( !CHAR_CHECKINDEX( Mainindex)) return FALSE; + if( EVOLUTION_getPetFusionCode( CHAR_getInt( Mainindex, CHAR_PETID) ) < 0 ){ + return 0; + } + if( CHAR_getInt( Mainindex, CHAR_FUSIONBEIT) == 1 || + CHAR_getInt( Mainindex, CHAR_FUSIONRAISE) > 0 )return FALSE;//检查是否为融合宠 + + if( PET_getBaseAndSkill( charaindex, Mainindex, base, petskill, 0) == FALSE ) + return -1; + if( CHAR_getInt( Mainindex, CHAR_LV) < 80 ){//等级销弱 + for( i=0; i<4; i++) { + base[i] = base[i]*0.8; + } + } + for( i=0; i<4; i++) { + work[i] += base[i]*0.6; + } + for( i=0; i<7; i++) { + skill[i] = petskill[i]; + } + + return TRUE; +} + +BOOL PETFUSION_DelPet( int toindex, int Mainindex, int Subindex1, int Subindex2, int flg) +{ + int i, j, cnt=0; + int petindex[3]; + + + petindex[0] = Mainindex; + petindex[1] = Subindex1; + petindex[2] = Subindex2; + + for( i=0; i<3; i++) { + if( !CHAR_CHECKINDEX( petindex[i] ) ) continue; + for( j=0; j= CHAR_MAXPETHAVE){ + + }else { + char szPet[256]; + char msgbuf[256]; + CHAR_setCharPet( toindex, j, -1); + snprintf( szPet, sizeof( szPet ), "K%d", j); + CHAR_sendStatusString( toindex, szPet ); + + snprintf( msgbuf,sizeof( msgbuf), "交出%s。", CHAR_getChar( petindex[i], CHAR_NAME)); + CHAR_talkToCli( toindex, -1, msgbuf, CHAR_COLORYELLOW); + LogPet( + CHAR_getChar( toindex, CHAR_NAME ), + CHAR_getChar( toindex, CHAR_CDKEY ), + CHAR_getChar( petindex[i], CHAR_NAME), + CHAR_getInt( petindex[i], CHAR_LV), + "TenseiDel", + CHAR_getInt( toindex,CHAR_FLOOR), + CHAR_getInt( toindex,CHAR_X ), + CHAR_getInt( toindex,CHAR_Y ), + CHAR_getChar( petindex[i], CHAR_UNIQUECODE) // shan 2001/12/14 + ); + } + CHAR_endCharOneArray( petindex[i] ); + cnt++; + } + if( cnt >= flg ) + return TRUE; + return FALSE; +} + +int PETFUSION_Evolution( int charaindex, int petindex) +{ + char buf[256], buf1[256]; + int newindex=-1; + CHAR_setInt( petindex, CHAR_FUSIONTIMELIMIT, -1); + + sprintf( buf, "蛋〈%s〉孵化成", CHAR_getChar( petindex, CHAR_NAME)); + newindex = EVOLUTION_createPetFromEnemyIndex( charaindex, petindex, 0); + if( !CHAR_CHECKINDEX( newindex) ){ + CHAR_talkToCli( charaindex, -1, "宠物孵化发生错误。", CHAR_COLORYELLOW); + return -1; + } + sprintf( buf1, "〈%s〉。", CHAR_getChar( newindex, CHAR_NAME)); + strcat( buf, buf1); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + + LogPetFeed( + CHAR_getChar( charaindex, CHAR_NAME), + CHAR_getChar( charaindex, CHAR_CDKEY), + CHAR_getChar( petindex, CHAR_NAME), + petindex, + CHAR_getInt( petindex, CHAR_LV), + buf, // Key + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y), + CHAR_getChar( petindex, CHAR_UNIQUECODE) ); + + return newindex; +} +#endif + +#ifdef _PET_TRANS +int PETTRANS_getPetBase( int petindex, int *work, int *petrank) +{ + int i, total=-1; + if( !CHAR_CHECKINDEX( petindex) ){ + total = 0; + *petrank = 1; + for( i=0; i<4; i++) { + work[i] = 50; + total += work[i]; + } + }else{ + int LevelUpPoint = CHAR_getInt( petindex, CHAR_ALLOCPOINT ); + *petrank = CHAR_getInt( petindex, CHAR_PETRANK ); + work[0] = (float)(( LevelUpPoint >> 24 ) & 0xFF); + work[1] = (float)(( LevelUpPoint >> 16 ) & 0xFF); + work[2] = (float)(( LevelUpPoint >> 8 ) & 0xFF); + work[3] = (float)(( LevelUpPoint >> 0 ) & 0xFF); + total = ( work[0] + work[1] + work[2] + work[3] ); + if( total > 150 ) total = 150; + if( total < 0 ) total = 0; + } + return total; +} + +#ifdef _PET_2TRANS +int NPC_PetTransManGetAns( int total1, int total2, int LV, int rank, int tran ) +#else +int NPC_PetTransManGetAns( int total1, int total2, int LV, int rank ) +#endif +{ + int ans=0 , TransLV = 100; + float total = 0.00; + int Fx=1; + + if( LV > 130 ) LV = 130; + total = ( (float)total1/100 ); // 玛蕾最高 total1=200 + total = total*total*total*total*total; + if( total < 1 ) total = 0; + else total= total*1.3; // 所以total最大=41.6 最小=0 + + Fx = (int)((5-rank)*1.2)+5; // rank=0~6 所以 Fx最大=11(rank=0)最小=4(rank=6) + ans = (int)total + total2 + ((LV-TransLV)/Fx); //42+150+30/11=194 + +#ifdef _PET_2TRANS + if( tran == 0 ){ + if( ans > 150 ) + ans = 150; + } + else{ + if( ans > 200 ) + ans = 200; + } +#else + if( ans > 150 ) { + ans = 150; + } +#endif + print("\n ans = %d", ans); + return ans; +} + +int PETTRANS_PetTransManStatus( int toindex, int petindex1, int petindex2) +{ + int petrank=0,i; + int total1,total2,total,petLV,ans; + int petID,enemynum,ret=-1; + int work[4]={0,0,0,0}; + int base[4]={0,0,0,0}; + +#define RAND(x,y) ((x-1)+1+ (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) ) + total1 = PETTRANS_getPetBase( petindex1, work, &petrank); + total2 = PETTRANS_getPetBase( petindex2, base, &petrank); + petLV = CHAR_getInt( petindex2, CHAR_LV); +#ifdef _PET_2TRANS + ans = NPC_PetTransManGetAns( total1, total2, petLV, petrank, CHAR_getInt( petindex2, CHAR_TRANSMIGRATION ) ); +#else + ans = NPC_PetTransManGetAns( total1, total2, petLV, petrank ); +#endif + total = total1 + (total2*4); + total2 = 0; + for( i=0; i<4; i++) { + work[i] = work[i]*4; + total2 += work[i]; + } + total = total1 + total2; + for( i=0; i<4; i++) { + base[i] = (ans * (base[i]+work[i])) /total; + } + enemynum = ENEMY_getEnemyNum(); + petID = CHAR_getInt( petindex2, CHAR_PETID); + for( i=0; i CHAR_getWorkInt( charaindex, CHAR_WORKMAXHP) ){ + Myhp = CHAR_getWorkInt( charaindex, CHAR_WORKMAXHP); + } + CHAR_setInt( charaindex, CHAR_HP, Myhp); + CHAR_complianceParameter( charaindex ); + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_HP); + for( i=0; i CHAR_getWorkInt( petindex, CHAR_WORKMAXHP) ){ + Myhp = CHAR_getWorkInt( petindex, CHAR_WORKMAXHP); + } + CHAR_setInt( petindex, CHAR_HP, Myhp); + CHAR_send_K_StatusString( charaindex, i, CHAR_K_STRING_HP|CHAR_K_STRING_AI); + } + break; + case 2://MP + Myhp = CHAR_getInt( charaindex, CHAR_MP); + dnums = CHAR_getWorkInt( charaindex, CHAR_WORKCHIKULAMP); + Myhp += dnums; + if( Myhp > CHAR_getWorkInt( charaindex, CHAR_WORKMAXMP) ){ + Myhp = CHAR_getWorkInt( charaindex, CHAR_WORKMAXMP); + } + CHAR_setInt( charaindex, CHAR_MP, Myhp); + CHAR_complianceParameter( charaindex ); + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_MP); + break; + } +} +#endif + +#ifdef _STATUS_WATERWORD //水世界状态 +void CHAR_CheckWaterStatus( int charaindex) +{ + if( !CHAR_CHECKINDEX( charaindex) ) return; + if( CHAR_getWorkInt( charaindex, CHAR_WORKSTATUSWATER) == -1 ){ + return; + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKSTATUSWATER) > 0 ){ + CHAR_setWorkInt( charaindex, CHAR_WORKSTATUSWATER, + CHAR_getWorkInt( charaindex, CHAR_WORKSTATUSWATER) -1 ); + + if( CHAR_getWorkInt( charaindex, CHAR_WORKSTATUSWATER) != 0 && + CHAR_getWorkInt( charaindex, CHAR_WORKSTATUSWATER)%10 == 0 ){ + char buf1[256]; + sprintf( buf1, "水中呼吸时间剩馀%d分。", + CHAR_getWorkInt( charaindex, CHAR_WORKSTATUSWATER)); + CHAR_talkToCli( charaindex, -1, buf1, CHAR_COLORYELLOW); + } + } + + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE ){ + return; + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKMAPFLOORTYPE) == 1 && + CHAR_getWorkInt( charaindex, CHAR_WORKSTATUSWATER) <= 0 ){//水世界 + char token[256]; + int defhp=0; + int maxhp = CHAR_getWorkInt( charaindex, CHAR_WORKMAXHP); + int myhp = CHAR_getInt( charaindex, CHAR_HP); + defhp = (maxhp*0.033); + if( defhp <= 0 ) defhp = 1; + myhp = myhp - defhp; + sprintf( token, "因无法呼吸,扣%d HP。", defhp); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + + if( myhp <= 0 ){ + myhp = 1; + if(CHAR_getInt(charaindex,CHAR_FLOOR) == 151 || CHAR_getInt(charaindex,CHAR_FLOOR) == 160 + || CHAR_getInt(charaindex,CHAR_FLOOR) == 161 ) CHAR_warpToSpecificPoint(charaindex,702,213,27); + else CHAR_warpToSpecificPoint( charaindex, 200,102,1021); + } + CHAR_setInt( charaindex, CHAR_HP, myhp); + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_HP); + } + +} +#endif + +int CHAR_findSurplusPetBox( int charaindex ) +{ + int i, remnants=0; + for( i=0; i +#include +#ifdef _REDHAT_V9 +#include +#endif + +#include "readmap.h" +#include "common.h" +#include "util.h" +#include "anim_tbl.h" +#include "battle.h" +#include "char.h" +#include "char_data.h" +#include "buf.h" +#include "item.h" +#include "log.h" +#include "pet.h" +#include "enemy.h" +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 +#include "char_base.h" +#include "configfile.h" +#endif + + +#include "defaultPlayer.h" +#include "defaultGroundEnemy.h" + + +#include "ls2data.dat" + +// CoolFish: Family 2001/7/28 +#include "family.h" +#include "saacproto_cli.h" + +#ifdef _PET_LIMITLEVEL +void CHAR_CheckPetDoLimitlevel( int petindex , int toindex, int level); +#endif + + +typedef struct tagdefaultCharcterGet +{ + int imagenumber; + Char* initchardata; + LevelUpPattern* lvpattern; + CHAR_ImageType imgtype; +}defaultCharacterGet; + +static defaultCharacterGet CHAR_defaultCharacterGet[]= +{ + /* CHAR_DEFAULTPLAYER */ +//阂间裆ㄠ + {SPR_001em,&player,&lvplayer00,CHAR_IMAGETYPE_CHILDBOY}, + {SPR_002em,&player,&lvplayer00,CHAR_IMAGETYPE_CHILDBOY}, + {SPR_003em,&player,&lvplayer00,CHAR_IMAGETYPE_CHILDBOY}, + {SPR_004em,&player,&lvplayer00,CHAR_IMAGETYPE_CHILDBOY}, + +//剂 ㄠ + {SPR_011em,&player,&lvplayer00,CHAR_IMAGETYPE_BOY}, + {SPR_012em,&player,&lvplayer00,CHAR_IMAGETYPE_BOY}, + {SPR_013em,&player,&lvplayer00,CHAR_IMAGETYPE_BOY}, + {SPR_014em,&player,&lvplayer00,CHAR_IMAGETYPE_BOY}, + +//剂 ㄡ + {SPR_021em,&player,&lvplayer00,CHAR_IMAGETYPE_BOY}, + {SPR_022em,&player,&lvplayer00,CHAR_IMAGETYPE_BOY}, + {SPR_023em,&player,&lvplayer00,CHAR_IMAGETYPE_BOY}, + {SPR_024em,&player,&lvplayer00,CHAR_IMAGETYPE_BOY}, + +//剂 ㄢ + {SPR_031em,&player,&lvplayer00,CHAR_IMAGETYPE_BOY}, + {SPR_032em,&player,&lvplayer00,CHAR_IMAGETYPE_BOY}, + {SPR_033em,&player,&lvplayer00,CHAR_IMAGETYPE_BOY}, + {SPR_034em,&player,&lvplayer00,CHAR_IMAGETYPE_BOY}, + +//敛 ㄠ + {SPR_041em,&player,&lvplayer00,CHAR_IMAGETYPE_MAN}, + {SPR_042em,&player,&lvplayer00,CHAR_IMAGETYPE_MAN}, + {SPR_043em,&player,&lvplayer00,CHAR_IMAGETYPE_MAN}, + {SPR_044em,&player,&lvplayer00,CHAR_IMAGETYPE_MAN}, + +//敛 ㄡ + {SPR_051em,&player,&lvplayer00,CHAR_IMAGETYPE_MAN}, + {SPR_052em,&player,&lvplayer00,CHAR_IMAGETYPE_MAN}, + {SPR_053em,&player,&lvplayer00,CHAR_IMAGETYPE_MAN}, + {SPR_054em,&player,&lvplayer00,CHAR_IMAGETYPE_MAN}, + +//阂间辉ㄠ + {SPR_061em,&player,&lvplayer00,CHAR_IMAGETYPE_CHILDGIRL}, + {SPR_062em,&player,&lvplayer00,CHAR_IMAGETYPE_CHILDGIRL}, + {SPR_063em,&player,&lvplayer00,CHAR_IMAGETYPE_CHILDGIRL}, + {SPR_064em,&player,&lvplayer00,CHAR_IMAGETYPE_CHILDGIRL}, + +//剂辉ㄠ + {SPR_071em,&player,&lvplayer00,CHAR_IMAGETYPE_GIRL}, + {SPR_072em,&player,&lvplayer00,CHAR_IMAGETYPE_GIRL}, + {SPR_073em,&player,&lvplayer00,CHAR_IMAGETYPE_GIRL}, + {SPR_074em,&player,&lvplayer00,CHAR_IMAGETYPE_GIRL}, + +//剂辉ㄡ + {SPR_081em,&player,&lvplayer00,CHAR_IMAGETYPE_GIRL}, + {SPR_082em,&player,&lvplayer00,CHAR_IMAGETYPE_GIRL}, + {SPR_083em,&player,&lvplayer00,CHAR_IMAGETYPE_GIRL}, + {SPR_084em,&player,&lvplayer00,CHAR_IMAGETYPE_GIRL}, + +//剂辉ㄢ + {SPR_091em,&player,&lvplayer00,CHAR_IMAGETYPE_GIRL}, + {SPR_092em,&player,&lvplayer00,CHAR_IMAGETYPE_GIRL}, + {SPR_093em,&player,&lvplayer00,CHAR_IMAGETYPE_GIRL}, + {SPR_094em,&player,&lvplayer00,CHAR_IMAGETYPE_GIRL}, + +//辉岭ㄠ + {SPR_101em,&player,&lvplayer00,CHAR_IMAGETYPE_WOMAN}, + {SPR_102em,&player,&lvplayer00,CHAR_IMAGETYPE_WOMAN}, + {SPR_103em,&player,&lvplayer00,CHAR_IMAGETYPE_WOMAN}, + {SPR_104em,&player,&lvplayer00,CHAR_IMAGETYPE_WOMAN}, + +//辉岭ㄡ + {SPR_111em,&player,&lvplayer00,CHAR_IMAGETYPE_WOMAN}, + {SPR_112em,&player,&lvplayer00,CHAR_IMAGETYPE_WOMAN}, + {SPR_113em,&player,&lvplayer00,CHAR_IMAGETYPE_WOMAN}, + {SPR_114em,&player,&lvplayer00,CHAR_IMAGETYPE_WOMAN}, + + {SPR_pet001,&player,&lvplayer00,CHAR_IMAGETYPE_DOG}, + {SPR_pet002,&player,&lvplayer00,CHAR_IMAGETYPE_DOG}, + {SPR_pet003,&player,&lvplayer00,CHAR_IMAGETYPE_DOG}, + {SPR_pet004,&player,&lvplayer00,CHAR_IMAGETYPE_DOG}, + {SPR_pet011,&player,&lvplayer00,CHAR_IMAGETYPE_DOG}, +}; + +BOOL CHAR_getDefaultChar( Char* nc , int imagenumber ) +{ + int i, j; + int defcharaindex; + + Char* defaultchar; + defaultchar = CHAR_defaultCharacterGet[arraysizeof(CHAR_defaultCharacterGet) - 1].initchardata; + + memset( nc,0,sizeof(Char) ); + defcharaindex = 0; + for( i = 0 ; i < arraysizeof( CHAR_defaultCharacterGet ) ; i ++ ){ + if( CHAR_defaultCharacterGet[i].imagenumber == imagenumber ){ + defaultchar = CHAR_defaultCharacterGet[i].initchardata; + defcharaindex = i; + break; + } + } + nc->data[CHAR_IMAGETYPE] = CHAR_defaultCharacterGet[defcharaindex].imgtype; + nc->use = TRUE; + +#ifdef _CHAR_FIXDATADEF + for( j = 0 ; j < CHAR_DATAINTNUM ; j ++ ){ + if( j < CHAR_INITDATA ) nc->data[j] = defaultchar->data[j]; + else nc->data[j] = 0; + } +#else + for( j = 0 ; j < CHAR_DATAINTNUM ; j ++ ) + nc->data[j] = defaultchar->data[j]; +#endif + for( j = 0 ; j < arraysizeof( nc->flg ) ; j ++ ) + nc->flg[j] = defaultchar->flg[j]; + + for( j = 0 ; j < CHAR_DATACHARNUM ; j ++ ) + nc->string[j].string[0] = '\0'; + for( j = 0 ; j < CHAR_MAXITEMHAVE ; j ++ ) + nc->indexOfExistItems[j] = -1; + for( j = 0 ; j < CHAR_MAXPOOLITEMHAVE ; j ++ ) + nc->indexOfExistPoolItems[j] = -1; + for( j = 0 ; j < CHAR_MAXPETSKILLHAVE ; j ++ ) + nc->unionTable.indexOfPetskill[j] = -1; + for( j = 0 ; j < CHAR_MAXPOOLPETHAVE ; j ++ ) + nc->indexOfPoolPet[j] = -1; + for( j = 0 ; j < CHAR_SKILLMAXHAVE ; j ++ ) + nc->haveSkill[j].use = FALSE; + for( j = 0 ; j < CHAR_TITLEMAXHAVE ; j ++ ) + nc->indexOfHaveTitle[j] = -1; + for( j=0 ; jaddressBook[j],0,sizeof(nc->addressBook[j]) ); + for( j = 0 ; j < CHAR_WORKDATAINTNUM ; j ++ ) + nc->workint[j] = 0; + for( j = 0 ; j < CHAR_WORKDATACHARNUM ; j ++ ) + nc->workchar[j].string[0] = '\0'; + nc->workint[CHAR_WORKFD] = -1; + nc->workint[CHAR_WORKCHATROOMNUM] = -1; +#ifdef _DEATH_CONTEND + nc->data[CHAR_PKLISTTEAMNUM] = -1; + nc->data[CHAR_PKLISTLEADER] = -1; +#endif +#ifdef _NPC_SEPARATEDATA + CHAR_getDefaultCharTempNum( nc); +#endif + + return TRUE; +} + +static int CHAR_playerImageNumber[]= +{ + /* CHAR_DEFAULTPLAYER */ + SPR_001em,SPR_002em,SPR_003em,SPR_004em,SPR_011em,SPR_012em, + SPR_013em,SPR_014em,SPR_021em,SPR_022em,SPR_023em,SPR_024em, + SPR_031em,SPR_032em,SPR_033em,SPR_034em,SPR_041em,SPR_042em, + SPR_043em,SPR_044em,SPR_051em,SPR_052em,SPR_053em,SPR_054em, + SPR_061em,SPR_062em,SPR_063em,SPR_064em,SPR_071em,SPR_072em, + SPR_073em,SPR_074em,SPR_081em,SPR_082em,SPR_083em,SPR_084em, + SPR_091em,SPR_092em,SPR_093em,SPR_094em,SPR_101em,SPR_102em, + SPR_103em,SPR_104em,SPR_111em,SPR_112em,SPR_113em,SPR_114em +}; + +BOOL CHAR_checkPlayerImageNumber( int imagenumber) +{ + int i; + for( i = 0; i < arraysizeof( CHAR_playerImageNumber); i ++ ) { + if( imagenumber == CHAR_playerImageNumber[i] ) break; + } + if( i == arraysizeof( CHAR_playerImageNumber)) return FALSE; + else return TRUE; +} +/*------------------------------------------------------------ + * 涌 飓 寞及民尼永弁 + * + * 涌 飓 寞反动票及白巧□穴永玄匹瑁引匀化中月 + * number = 窒谛 井 + * CG_CHR_MAKE_FACE + (number*100) + ( 缙 number * 25) + ( 寞 * 5 ) + 轼 寞 + * + ------------------------------------------------------------*/ +BOOL CHAR_checkFaceImageNumber( int imagenumber, int faceimagenumber) +{ + int image = imagenumber - SPR_001em; + int number; + int color; + number = (faceimagenumber - CG_CHR_MAKE_FACE)/ 100*20; + color = ((faceimagenumber - CG_CHR_MAKE_FACE)% 100) / 25*5; + if( image != number + color ) return FALSE; + return TRUE; +} +// 平乓仿 飓 □皮伙[ㄠ 丐凶曰隶 ㄤ潘 +int CHAR_eqimagetbl[][5]={ + // 允匹 {{{{ 轺徇 键 菰 + { SPR_001em,SPR_001ax,SPR_001cl,SPR_001sp,SPR_001bw }, + { SPR_002em,SPR_002ax,SPR_002cl,SPR_002sp,SPR_002bw }, + { SPR_003em,SPR_003ax,SPR_003cl,SPR_003sp,SPR_003bw }, + { SPR_004em,SPR_004ax,SPR_004cl,SPR_004sp,SPR_004bw }, + { SPR_011em,SPR_011ax,SPR_011cl,SPR_011sp,SPR_011bw }, + { SPR_012em,SPR_012ax,SPR_012cl,SPR_012sp,SPR_012bw }, + { SPR_013em,SPR_013ax,SPR_013cl,SPR_013sp,SPR_013bw }, + { SPR_014em,SPR_014ax,SPR_014cl,SPR_014sp,SPR_014bw }, + { SPR_021em,SPR_021ax,SPR_021cl,SPR_021sp,SPR_021bw }, + { SPR_022em,SPR_022ax,SPR_022cl,SPR_022sp,SPR_022bw }, + { SPR_023em,SPR_023ax,SPR_023cl,SPR_023sp,SPR_023bw }, + { SPR_024em,SPR_024ax,SPR_024cl,SPR_024sp,SPR_024bw }, + { SPR_021em,SPR_021ax,SPR_021cl,SPR_021sp,SPR_021bw }, + { SPR_031em,SPR_031ax,SPR_031cl,SPR_031sp,SPR_031bw }, + { SPR_032em,SPR_032ax,SPR_032cl,SPR_032sp,SPR_032bw }, + { SPR_033em,SPR_033ax,SPR_033cl,SPR_033sp,SPR_033bw }, + { SPR_034em,SPR_034ax,SPR_034cl,SPR_034sp,SPR_034bw }, + { SPR_041em,SPR_041ax,SPR_041cl,SPR_041sp,SPR_041bw }, + { SPR_042em,SPR_042ax,SPR_042cl,SPR_042sp,SPR_042bw }, + { SPR_043em,SPR_043ax,SPR_043cl,SPR_043sp,SPR_043bw }, + { SPR_044em,SPR_044ax,SPR_044cl,SPR_044sp,SPR_044bw }, + + { SPR_051em,SPR_051ax,SPR_051cl,SPR_051sp,SPR_051bw }, + { SPR_052em,SPR_052ax,SPR_052cl,SPR_052sp,SPR_052bw }, + { SPR_053em,SPR_053ax,SPR_053cl,SPR_053sp,SPR_053bw }, + { SPR_054em,SPR_054ax,SPR_054cl,SPR_054sp,SPR_054bw }, + + { SPR_061em,SPR_061ax,SPR_061cl,SPR_061sp,SPR_061bw }, + { SPR_062em,SPR_062ax,SPR_062cl,SPR_062sp,SPR_062bw }, + { SPR_063em,SPR_063ax,SPR_063cl,SPR_063sp,SPR_063bw }, + { SPR_064em,SPR_064ax,SPR_064cl,SPR_064sp,SPR_064bw }, + + { SPR_071em,SPR_071ax,SPR_071cl,SPR_071sp,SPR_071bw }, + { SPR_072em,SPR_072ax,SPR_072cl,SPR_072sp,SPR_072bw }, + { SPR_073em,SPR_073ax,SPR_073cl,SPR_073sp,SPR_073bw }, + { SPR_074em,SPR_074ax,SPR_074cl,SPR_074sp,SPR_074bw }, + + { SPR_081em,SPR_081ax,SPR_081cl,SPR_081sp,SPR_081bw }, + { SPR_082em,SPR_082ax,SPR_082cl,SPR_082sp,SPR_082bw }, + { SPR_083em,SPR_083ax,SPR_083cl,SPR_083sp,SPR_083bw }, + { SPR_084em,SPR_084ax,SPR_084cl,SPR_084sp,SPR_084bw }, + + { SPR_091em,SPR_091ax,SPR_091cl,SPR_091sp,SPR_091bw }, + { SPR_092em,SPR_092ax,SPR_092cl,SPR_092sp,SPR_092bw }, + { SPR_093em,SPR_093ax,SPR_093cl,SPR_093sp,SPR_093bw }, + { SPR_094em,SPR_094ax,SPR_094cl,SPR_094sp,SPR_094bw }, + + { SPR_101em,SPR_101ax,SPR_101cl,SPR_101sp,SPR_101bw }, + { SPR_102em,SPR_102ax,SPR_102cl,SPR_102sp,SPR_102bw }, + { SPR_103em,SPR_103ax,SPR_103cl,SPR_103sp,SPR_103bw }, + { SPR_104em,SPR_104ax,SPR_104cl,SPR_104sp,SPR_104bw }, + + { SPR_111em,SPR_111ax,SPR_111cl,SPR_111sp,SPR_111bw }, + { SPR_112em,SPR_112ax,SPR_112cl,SPR_112sp,SPR_112bw }, + { SPR_113em,SPR_113ax,SPR_113cl,SPR_113sp,SPR_113bw }, + { SPR_114em,SPR_114ax,SPR_114cl,SPR_114sp,SPR_114bw }, + + { SPR_091em,SPR_091ax,SPR_091cl,SPR_091sp,SPR_091bw }, + { SPR_092em,SPR_092ax,SPR_092cl,SPR_092sp,SPR_092bw }, + + { SPR_pet001,SPR_pet001,SPR_pet001,SPR_pet001,SPR_pet001}, + { SPR_pet002,SPR_pet002,SPR_pet002,SPR_pet002,SPR_pet002}, + { SPR_pet003,SPR_pet003,SPR_pet003,SPR_pet003,SPR_pet003}, + { SPR_pet004,SPR_pet004,SPR_pet004,SPR_pet004,SPR_pet004}, + + { SPR_pet011,SPR_pet011,SPR_pet011,SPR_pet011,SPR_pet011}, + + { SPR_121em,SPR_121ax,SPR_121cl,SPR_121sp,SPR_121bw }, + { SPR_122em,SPR_122ax,SPR_122cl,SPR_122sp,SPR_122bw }, + + { SPR_131em,SPR_131ax,SPR_131cl,SPR_131sp,SPR_131bw }, + { SPR_132em,SPR_132ax,SPR_132cl,SPR_132sp,SPR_132bw }, + { SPR_133em,SPR_133ax,SPR_133cl,SPR_133sp,SPR_133bw }, + + { SPR_141em,SPR_141ax,SPR_141cl,SPR_141sp,SPR_141bw }, + { SPR_142em,SPR_142ax,SPR_142cl,SPR_142sp,SPR_142bw }, + + { SPR_151em,SPR_151ax,SPR_151cl,SPR_151sp,SPR_151bw }, + { SPR_152em,SPR_152ax,SPR_152cl,SPR_152sp,SPR_152bw }, + + { SPR_161em,SPR_161ax,SPR_161cl,SPR_161sp,SPR_161bw }, + { SPR_162em,SPR_162ax,SPR_162cl,SPR_162sp,SPR_162bw }, + +}; + +/*------------------------------------------------------------ + * 隶 午 飓 寞井日蕙仄中 飓 寞毛 月[ + * 娄醒 + * basebaseimagenumber int 葭卞卅月 飓 寞 + * category ITEM_CATEGORY 失奶 丞及市 打伉 + * 忒曰袄 + * 蕙仄中 飓 寞[巨仿□及凛反}-1 + ------------------------------------------------------------*/ +int CHAR_getNewImagenumberFromEquip( int basebaseimagenumber, + ITEM_CATEGORY category ) +{ + int i; + /* ITEM_CATEGORY 民尼永弁 */ + if( category < 0 || category > arraysizeof(CHAR_eqimagetbl[0]) ) + return -1; + for( i=0 ; i rx )swap(lx,rx); + if( ly > ry )swap(ly,ry); + + CHAR_invarea[invreadlen].area.x = lx; + CHAR_invarea[invreadlen].area.y = ly; + CHAR_invarea[invreadlen].area.width = rx-lx; + CHAR_invarea[invreadlen].area.height= ry-ly; + invreadlen ++; + } + } + fclose(f); + CHAR_invareanum = invreadlen; + print( "有效不可战斗有效数是 %d...", CHAR_invareanum ); +#if 0 +{ + int i,j; + for( i=0; i 3 ) { + return FALSE; + } + index=hometown; +#endif + if( index >= arraysizeof( elders ) ){ + return FALSE; + } + + ch->data[CHAR_FLOOR] = elders[index].floor; + ch->data[CHAR_X] = elders[index].x; + ch->data[CHAR_Y] = elders[index].y; + ch->data[CHAR_LASTTALKELDER] = index; + point = ch->data[CHAR_SAVEPOINT]; + + +#ifdef _DELBORNPLACE //Syu ADD 6.0 统一出生於新手村 + if( getMuseum() ) { + ch->data[CHAR_FLOOR] = 815; + ch->data[CHAR_X] = 29; + ch->data[CHAR_Y] = 40; + ch->data[CHAR_LASTTALKELDER] = 35; + // point = point | (1<<35) ; + point = point | (1<data[CHAR_FLOOR] = 9000; + ch->data[CHAR_X] = 40; + ch->data[CHAR_Y] = 40; + } +#endif + + ch->data[CHAR_SAVEPOINT] = point; + + if( MAP_checkCoordinates( ch->data[CHAR_FLOOR], ch->data[CHAR_X], + ch->data[CHAR_Y] ) == FALSE ){ + return FALSE; + } + + return TRUE; +} + +/*------------------------------------------------------------ + * 巨伙母□及桦赭毛 月 + * 娄醒 + * elderindex int 巨伙母□奶件犯永弁旦 + * fl int* 白夫失毛熬仃潸月桦赭 + * x int* x毛熬仃潸月桦赭 + * y int* y毛熬仃潸月桦赭 + * 娄醒 + * 岳 TRUE(1) + * 撩 FALSE(0) + ------------------------------------------------------------*/ +BOOL CHAR_getElderPosition( int elderindex, int* fl, int* x, int* y ) +{ + if( elderindex<0 || arraysizeof(elders)<=elderindex )return FALSE; + + *fl = elders[elderindex].floor; + *x = elders[elderindex].x; + *y = elders[elderindex].y; + return TRUE; +} +/*------------------------------------------------------------ + * 赢 NPC互愤坌及赓渝祭及午五卞}赢 卞踏五仇戈及分[ + * 公及凶户及奶件正□白尼奶旦 + * 娄醒 + * index int 左□田□匹 撩 仄凶日FALSE 毛井尹允 + * fl int 匏 及树 + * x int + * y int + * NPC及伙□民件井日银歹木月及分[ + ------------------------------------------------------------*/ +BOOL CHAR_ElderSetPosition( int elderindex ,int fl,int x ,int y) +{ + if( elderindex < ELDERINDEXSTART || + elderindex >= MAXELDERS ){ + return FALSE; + } + + elders[elderindex].floor = fl; + elders[elderindex].x = x; + elders[elderindex].y = y; + return TRUE; +} + + +void CHAR_setInitValues( Char* ch ) +{ + +#ifndef _PROFESSION_SKILL // WON ADD 人物职业技能 + + static int CHAR_titleindextbl[] ={ 0,1,2,3,4,5,6 }; + int elderindex; + int i; + BOOL magician=FALSE; + BOOL priest=FALSE; + + elderindex = ch->data[CHAR_LASTTALKELDER]; + if( 0 <= elderindex + && elderindex < arraysizeof( CHAR_titleindextbl ) ) + ch->indexOfHaveTitle[0] = CHAR_titleindextbl[elderindex]; + + + for( i=0 ; ihaveSkill[i].use ){ + int j; + int skindex=ch->haveSkill[i].skill.data[SKILL_IDENTITY]; + + for( j=0 ; jdata[CHAR_GOLD] = 20; + + if( skindex == SKILL_MAGICIAN ) + magician = TRUE; + else if( skindex == SKILL_PRIEST ) + priest = TRUE; + + } + } + + if( magician || priest ) CHAR_addItemToChar( ch, 802 ); + +#endif +} + + +#if 1 +static int EnemyExpTbl[]={ +0, // 0 +2, // 1 +4, // 2 +6, // 3 +8, // 4 +10, // 5 +12, // 6 +14, // 7 +16, // 8 +18, // 9 +20, // 10 +26, // 11 +32, // 12 +38, // 13 +44, // 14 +50, // 15 +60, // 16 +70, // 17 +80, // 18 +90, // 19 +100, // 20 +115, // 21 +130, // 22 +145, // 23 +160, // 24 +175, // 25 +190, // 26 +205, // 27 +220, // 28 +235, // 29 +250, // 30 +270, // 31 +290, // 32 +310, // 33 +330, // 34 +350, // 35 +375, // 36 +400, // 37 +425, // 38 +450, // 39 +475, // 40 +500, // 41 +525, // 42 +550, // 43 +575, // 44 +600, // 45 +625, // 46 +650, // 47 +675, // 48 +700, // 49 +725, // 50 +750, // 51 +775, // 52 +800, // 53 +825, // 54 +850, // 55 +875, // 56 +900, // 57 +925, // 58 +950, // 59 +980, // 60 +1010, // 61 +1040, // 62 +1070, // 63 +1100, // 64 +1130, // 65 +1160, // 66 +1190, // 67 +1220, // 68 +1250, // 69 +1280, // 70 +1310, // 71 +1345, // 72 +1380, // 73 +1415, // 74 +1450, // 75 +1485, // 76 +1520, // 77 +1555, // 78 +1590, // 79 +1630, // 80 +1670, // 81 +1710, // 82 +1750, // 83 +1790, // 84 +1830, // 85 +1870, // 86 +1910, // 87 +1950, // 88 +1990 // 89 +}; // 90 + + + + + + + + + + + + + + + + +// 酵烂读卅烦董袄煌遥 +int GetEnemyExp( int level ){ +/* + int exp = 0; + if( level < 5 ){ + exp = 2 * level; + }else + if( level < 10 ){ + exp = 10 * level; + }else + if( level < 20 ){ + exp = 15 * level; + }else + if( level < 30 ){ + exp = 30 * level; + }else + if( level < 40 ){ + exp = 50 * level; + }else + if( level < 50 ){ + exp =60 * level; + }else + if( level < 60 ){ + exp =60 * level; + }else{ + exp =70 * level; + } +*/ + if( level >= arraysizeof( EnemyExpTbl ) )level = arraysizeof( EnemyExpTbl )-1; + return EnemyExpTbl[level]; +} +#endif + +#ifdef _NEWOPEN_MAXEXP +/*static int NeedLevelUpTbls[] = { + 0, 0, + 2, 6, 18, 37, 67, 110, 170, + 246, 344, 464, 610, 782, 986, 1221, + 1491, 1798, 2146, 2534, 2968, 3448, 3978, + 4558, 5194, 5885, 6635, 7446, 8322, 9262, + 10272, 11352, 12506, 13734, 15042, 16429, 17899, + 19454, 21098, 22830, 24656, 26576, 28594, 30710, + 32930, 35253, 37683, 40222, 42874, 45638, 48520, + 51520, 54642, 57886, 61258, 64757, 68387, 72150, + 76050, 80086, 84264, 106110, 113412, 121149, 129352, + 138044, 147256, 157019, 167366, 178334, 189958, 202282, + 215348, 229205, 243901, 259495, 276041, 293606, 312258, + 332071, 353126, 375511, 399318, 424655, 451631, 480370, + 511007, 543686, 578571, 615838, 655680, 698312, 743971, + 792917, 845443, 901868, 962554, 1027899, 1098353, 1174420, + 1256663, 1345723, 1442322, 1547281, 1661531, 1786143, 1922340, + 2071533, 2235351, 2415689, 2614754, 2835137, 3079892, 3352633, + 3657676, 4000195, 4386445, 4824041, 5322323, 5892866, 6550125, + 12326614, 15496114, 20025638, 26821885, 37698249, 56734876, 68097265, + 68290815, 68487425, 68687119, 68889921, 69095855, 69304945, 69517215, + 69732689, 69951391, 70173345, 70398575, 70627105, 70858959, 71244161, + 71342735, 71584705, 71830095, 72078929, 72331231, 72587025, 72846335, + 73109185, 73615599, 73655601, 73929215, 74206465, 74487375, 74771969, + 75060271, 75352305, 75648095, 75947665, 76421039, 76563241, 76874295, + 77189225, 77508055, 77830809, 78157511, 78488185, 78822855, 79161545, + 79724279, 79856081, 80206975, 80561985, 80921135, 81284449, 81651951, + 82023665, 82399615, 82779825, 83434319, 83558121, 83951255, 84348745, + 84750615, 85156889, 85567591, 85982745, 86402375, 86826505, 87575159, + 87693361, 88131135, 88573505, 89020495, 89472129, 89928431, 90389425, + 90855135, 91325585, 91800799 +}; +*/ +#endif +static int LevelUpTbl[] = { // 经验值 等级 换算表 +0, // 0 EX=(lv^4)/10 +0, // 1 + 2, 8, 25, 62, 129, + 240, 409, 656, 1000, 1464, // 11 + 2073, 2856, 3841, 5062, 6553, // 16 + 8352, 10497, 13032, 16000, 19448, 23425, // 22 + 27984, 33177, 39062, 45697, 53144, 61465, // 28 + 70728, 81000, 92352, 104857, 118592, 133633, // 34 + 150062, 167961, 187416, 208513, 231344, 256000, // 40 + 282576, 311169, 341880, 374809, 410062, 447745, // 46 + 487968, 530841, 576480, 625000, 676520, 731161, // 52 + 789048, 850305, 915062, 983449, 1055600, 1131649, // 58 + 1211736, 1296000, + 1402110, // 61 EX=(lv^4)/(10-0.125*(lv-60)) + 1515521, 1636671, 1766022, 1904066, 2051322, 2208342, // 67 + 2375708, 2554041, 2744000, 2946281, 3161630, 3390834, // 73 + 3634736, 3894230, 4170272, 4463878, 4776136, 5108207, // 79 + 5461333, 5836843, 6236162, 6660816, 7112448, 7592818, // 85 + 8103824, 8647511, 9226082, 9841920, 10497600, 11195912, // 91 + 11939882, 12732800, 13578242, 14480111, 15442664, 16470563, // 97 + 17568917, 18743336, 20000000, 21345723, 22788045, 24335325, // 103 + 25996856, 27783000, 29705340, 31776872, 34012224, 36427912, // 109 + 39042666, 41877804, 44957696, 48310329, 51968004, 55968200, // 115 + 60354645, 65178685, 70501009, 76393874, 82944000, + + 95270613, // 121 Nuke 0624 EX=(lv^4)/(2.5-0.25*(lv-120)) + 110766728, 130792366, 157614250, 195312500, // 125 + 252047376, // 126 EX=lv^4+60000000*(lv-126)^2 Nuke 0816 + 320144641, 388435456, 456922881, 525610000, 594499921, 663595776, // 132 + 732900721, 802417936, 872150625, 942102016,1012275361,1082673936, // 138 + 1153301041,1224160000 // 140 +}; + +int CHAR_GetLevel() +{ + return arraysizeof( LevelUpTbl )-1; +} +int CHAR_GetLevelExp( int candp, int level, int corp ) +{ +#ifdef _NEWOPEN_MAXEXP +#ifdef _USER_EXP_CF + if(corp=0){ + if(CHAR_getInt(candp,CHAR_TRANSMIGRATION)<6){ + if(level>140) + return -1; + }else{ + if(level>160) + return -1; + } + }else{ + if(CHAR_getInt(candp,CHAR_TRANSMIGRATION)<2){ + if(level>140) + return -1; + }else{ + if(level>160) + return -1; + } + return getNeedLevelUpTbls(level); +#endif +/* if( level >= arraysizeof( NeedLevelUpTbls ) ){ + return -1; + } + return NeedLevelUpTbls[level];*/ +#else + if( level >= arraysizeof( LevelUpTbl ) ){ + return -1; + } + return LevelUpTbl[level]; +#endif +} + +int CHAR_GetOldLevelExp( int level) +{ + if( level >= arraysizeof( LevelUpTbl ) ){ + return -1; + } + return LevelUpTbl[level]; +} + +int CHAR_LevelUpCheck( int charaindex , int toindex) +{ + int exp, level, nextexp, iRet = FALSE; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return 0; + exp = CHAR_getInt( charaindex, CHAR_EXP ); + while( 1 ){ + level = CHAR_getInt( charaindex, CHAR_LV ); + nextexp = CHAR_GetLevelExp( charaindex, level+1, 0 ); + if( nextexp < 0 ) + break; + // Arminius 7.30 pet limit lv + if (CHAR_getInt(charaindex, CHAR_WHICHTYPE)==CHAR_TYPEPET) { + + if (level >= CHAR_getInt(charaindex, CHAR_LIMITLEVEL) && + CHAR_getInt(charaindex, CHAR_LIMITLEVEL) > 0 ) { +#ifdef _NEWOPEN_MAXEXP + CHAR_setInt( charaindex, CHAR_EXP , 0); +#else +#ifdef _PET_LIMITLEVEL + if( CHAR_getInt( charaindex, CHAR_PETID) == 718 +#ifdef _PET_2LIMITLEVEL + || CHAR_getInt( charaindex, CHAR_PETID) == 401 +#endif + ) { + nextexp = CHAR_GetLevelExp( charaindex, CHAR_getInt(charaindex, CHAR_LIMITLEVEL), 0 ); + CHAR_setInt( charaindex, CHAR_EXP , nextexp ); + } +#endif +#endif + break; + } + } + if( exp >= nextexp ){ + iRet ++; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + CHAR_setInt( charaindex, CHAR_DUELPOINT, + CHAR_getInt( charaindex, CHAR_DUELPOINT) + (level+1)*10 ); + } +#ifdef _PET_LIMITLEVEL + else { + CHAR_CheckPetDoLimitlevel( charaindex, toindex, level ); + } +#endif + +#ifdef _NEWOPEN_MAXEXP + if( level >= CHAR_MAXUPLEVEL ){ + }else{ + if( CHAR_HandleExp( charaindex) != -1 ){ + exp = CHAR_getInt( charaindex, CHAR_EXP ); + CHAR_setInt( charaindex, CHAR_LV, level+1 ); + } + } +#else + CHAR_setInt( charaindex, CHAR_LV, level+1 ); +#endif + }else{ + break; + } + } + return iRet; +} + +#ifdef _PET_LIMITLEVEL +void CHAR_CheckPetDoLimitlevel( int petindex , int toindex, int level) +{ + int LevelUpPoint,vital,str,tgh,dex; + int j,k; + char token[56]; +#define RAND(x,y) ((x-1)+1+ (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) ) + + if( CHAR_getInt( petindex, CHAR_PETID) == 718 +#ifdef _PET_2LIMITLEVEL + || CHAR_getInt( petindex, CHAR_PETID) == 401 +#endif + ) { + LevelUpPoint = CHAR_getInt( petindex, CHAR_ALLOCPOINT ); + vital = (int )(( LevelUpPoint >> 24 ) & 0xFF); + str = (int)(( LevelUpPoint >> 16 ) & 0xFF); + tgh = (int)(( LevelUpPoint >> 8 ) & 0xFF); + dex = (int)(( LevelUpPoint >> 0 ) & 0xFF); + + if( strcmp( CHAR_getChar( petindex, CHAR_OWNERCDKEY), CHAR_getChar( toindex, CHAR_CDKEY) ) || + strcmp( CHAR_getChar( petindex, CHAR_OWNERCHARANAME), CHAR_getChar( toindex, CHAR_NAME) )){ + sprintf(token,"我不认识你呀!快把我还给我主人!"); + //andy 1/11 reEdit + vital -= RAND(2,10); if (vital<0) vital=0; + str -= RAND(2,10); if (str<0) str=0; + tgh -= RAND(2,10); if (tgh<0) tgh=0; + dex -= RAND(2,10); if (dex<0) dex=0; + LevelUpPoint = (vital<<24)+(str<<16)+(tgh<<8)+(dex<<0); + + CHAR_setInt( petindex, CHAR_ALLOCPOINT , LevelUpPoint); + CHAR_talkToCli( toindex, petindex, token, CHAR_COLORWHITE); + + LogPetPointChange( + CHAR_getChar( toindex, CHAR_NAME ), + CHAR_getChar( toindex, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + petindex, 2, + CHAR_getInt( petindex, CHAR_LV), + "No_master(玛蕾不对主人)", + CHAR_getInt( toindex,CHAR_FLOOR), + CHAR_getInt( toindex,CHAR_X ), + CHAR_getInt( toindex,CHAR_Y ) + ); + } + + if( ( level % 20 ) == 0 ) { + for( j=0; j < 3; j++) { + k = RAND( 0, 3); + if( k == 0 ) + vital--; + if( k == 1 ) + str--; + if( k == 2 ) + tgh--; + if( k == 3 ) + dex--; + } + if( vital < 0 ) vital =0; + if( str < 0 ) str =0; + if( tgh < 0 ) tgh =0; + if( dex < 0 ) dex =0; + LevelUpPoint = (vital<<24)+(str<<16)+(tgh<<8)+(dex<<0); + CHAR_setInt( petindex, CHAR_ALLOCPOINT , LevelUpPoint); + //print("\n << ( level % 20 ) == 0 >> "); + LogPetPointChange( + CHAR_getChar( toindex, CHAR_NAME ), + CHAR_getChar( toindex, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + petindex,3, + CHAR_getInt( petindex, CHAR_LV), + "level%20", + CHAR_getInt( toindex,CHAR_FLOOR), + CHAR_getInt( toindex,CHAR_X ), + CHAR_getInt( toindex,CHAR_Y ) + ); + } + } +} +#endif +int CHAR_PetTakeDrop( int petindex, int floor, int ox, int oy) //强制丢弃宠物升级 +{ + int x, y, objindex; + + x = rand()%10; + y = rand()%10; + + //丢下宠物 CHAR_endCharOneArray + objindex = PET_dropPetAbsolute( petindex,floor,x,y, FALSE ); + if( objindex == -1 ) { + return -1; + } + CHAR_setWorkInt( petindex,CHAR_WORKOBJINDEX,objindex ); + CHAR_setInt( petindex, CHAR_FLOOR, floor); + CHAR_setInt( petindex, CHAR_X, x); + CHAR_setInt( petindex, CHAR_Y, y); + CHAR_sendCToArroundCharacter( objindex); + + return floor; +} + +int CHAR_PetTakeLevelUp( int petindex, int lv)//强制宠物升级 +{ + int k; + for( k = 1; k < lv; k ++ ){ + CHAR_PetLevelUp( petindex ); + CHAR_PetAddVariableAi( petindex, AI_FIX_PETLEVELUP ); + CHAR_setInt( petindex, CHAR_LV, CHAR_getInt( petindex, CHAR_LV) +1 ); + } + + CHAR_complianceParameter( petindex ); + return k; +} + +#ifdef _NEW_MANOR_LAW +extern struct FM_POINTLIST fmpointlist; +#endif + +int CHAR_PetLevelUp( int petindex ) +{ + struct _RankRandTbl{ + int min; + int max; + }RankRandTbl[] = { + { 450, 500 }, + { 470, 520 }, + { 490, 540 }, + { 510, 560 }, + { 530, 580 }, + { 550, 600 }, + }; + + float Param[4] = { 0.0, 0.0, 0.0, 0.0 }; + int LevelUpPoint, petrank; + float str, vital, dex, tgh, fRand, i; +#ifdef _TEACHER_SYSTEM + int iGetFame = 0; +#endif + // 娄醒民尼永弁 + if( CHAR_CHECKINDEX( petindex ) == FALSE ) return -1; + if( CHAR_getInt( petindex, CHAR_WHICHTYPE ) != CHAR_TYPEPET )return -1; + + LevelUpPoint = CHAR_getInt( petindex, CHAR_ALLOCPOINT ); + + // 矢永玄及仿件弁 + petrank = CHAR_getInt( petindex, CHAR_PETRANK ); + if( petrank < 0 || petrank > 5 ) petrank = 0; + + // 潸 + vital = (float)(( LevelUpPoint >> 24 ) & 0xFF); + str = (float)(( LevelUpPoint >> 16 ) & 0xFF); + tgh = (float)(( LevelUpPoint >> 8 ) & 0xFF); + dex = (float)(( LevelUpPoint >> 0 ) & 0xFF); + + // ㄠㄟ荚ㄣ 扔奶戊夫毛蕊匀化备嫩 卞ㄠ箫允 + for( i = 0; i < 10; i ++ ){ + Param[RAND( 0, 3 )] += 1.0; + } + + // 仿件弁卞方月 区及仿件母丞 + fRand = (float)RAND( RankRandTbl[petrank].min, RankRandTbl[petrank].max ) + * 0.01; + + // 喃曰蕊曰禾奶件玄方曰煌遥 + vital = (float)vital * fRand + Param[0] * fRand; + str = (float)str * fRand + Param[1] * fRand; + tgh = (float)tgh * fRand + Param[2] * fRand; + dex = (float)dex * fRand + Param[3] * fRand; + + // 煌遥 + CHAR_setInt( petindex, CHAR_VITAL, + CHAR_getInt( petindex, CHAR_VITAL ) + (int)vital ); + CHAR_setInt( petindex, CHAR_STR, + CHAR_getInt( petindex, CHAR_STR ) + (int)str ); + CHAR_setInt( petindex, CHAR_TOUGH, + CHAR_getInt( petindex, CHAR_TOUGH ) + (int)tgh ); + CHAR_setInt( petindex, CHAR_DEX, + CHAR_getInt( petindex, CHAR_DEX ) + (int)dex ); + + // CoolFish: 饲育家族声望更新 + { + int level = CHAR_getInt(petindex, CHAR_LV); + int exp1 = 0, exp2 = 0, feedpoint = 0; + if (level > 30){ + char tmpbuf[128]; +#ifdef _NEW_MANOR_LAW + char tmpbuf1[16]; +#endif + int ownerindex = CHAR_getWorkInt(petindex, CHAR_WORKPLAYERINDEX); +#ifdef _FMVER21 +#else + if (CHAR_getInt(ownerindex, CHAR_FMINDEX) < 0) return 0; + if (CHAR_getInt(ownerindex, CHAR_FMLEADERFLAG) <= 0 ) return 0; + if (strcmp(CHAR_getChar(ownerindex, CHAR_FMNAME), "") == 0) return 0; +#endif + if (CHAR_CHECKINDEX(ownerindex)){ + exp1 = CHAR_GetLevelExp( petindex, level, 1); + exp2 = CHAR_GetLevelExp( petindex,level - 1, 1); + +#ifdef _PERSONAL_FAME // Arminius 8.30: 家族个人声望 + feedpoint = (exp1 - exp2) / 20000; // 减半 +#else + feedpoint = (exp1 - exp2) / 10000; +#endif + sprintf(tmpbuf, "%d", feedpoint); + if (feedpoint > 0){ + // CoolFish: 2001/10/03 + int fd = getfdFromCharaIndex(ownerindex); +#ifdef _PERSONAL_FAME // Arminius 8.30: 家族个人声望 + CHAR_earnFame(ownerindex, feedpoint); +#endif +#ifdef _NEW_MANOR_LAW + sprintf(tmpbuf1, "%d", CHAR_getInt(ownerindex,CHAR_FAME)); +#endif +#ifdef _FMVER21 + if (CHAR_getInt(ownerindex, CHAR_FMLEADERFLAG) > 0 + && CHAR_getInt(ownerindex, CHAR_FMLEADERFLAG) != FMMEMBER_APPLY){ + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(ownerindex, CHAR_FMNAME), + CHAR_getInt(ownerindex, CHAR_FMINDEX), + CHAR_getWorkInt(ownerindex, CHAR_WORKFMINDEXI), + FM_FIX_FMFEED, tmpbuf, +#ifndef _NEW_MANOR_LAW + "", +#else + tmpbuf1, +#endif + // CoolFish: 2001/10/03 + CHAR_getWorkInt(ownerindex, CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(fd)); + // CHAR_getWorkInt(ownerindex, CHAR_WORKFMCHARINDEX), 0); +#ifdef _NEW_MANOR_LAW + { + int i; + for(i=0;i 0){ + // 检查有没有导师 + if(strlen(CHAR_getChar(ownerindex,CHAR_TEACHER_ID)) > 0 && strlen(CHAR_getChar(ownerindex,CHAR_TEACHER_NAME)) > 0){ + int iPlayernum = CHAR_getPlayerMaxNum(),i; + char szMsg[128]; + + // 检查导师在不在线上 + for(i=0;i 0 )return 0;//检查是否为融合宠 + for( i=0; i<4; i++) { + work[i] = 0; + } + if( PET_getBaseAndSkill( charaindex, Subindex1, base, petskill, 0) == FALSE ) + return 0; + if( CHAR_getInt( Subindex1, CHAR_LV) < 80 ){//等级销弱 + for( i=0; i<4; i++) { + base[i] = base[i]*0.8; + } + } + for( i=0; i<4; i++) { + work[i] = base[i]; + } + for( i=0; i<7; i++) { + skill[i] = petskill[i]; + } + if( !CHAR_CHECKINDEX( Subindex2)) return 1; + if( EVOLUTION_getPetFusionCode( CHAR_getInt( Subindex2, CHAR_PETID) ) < 0 ){ + return 0; + } + + if( CHAR_getInt( Subindex2, CHAR_FUSIONBEIT) == 1 || + CHAR_getInt( Subindex2, CHAR_FUSIONRAISE) > 0 )return 0;//检查是否为融合宠 + + if( PET_getBaseAndSkill( charaindex, Subindex2, base, NULL, 0) == FALSE ) + return 0; + if( CHAR_getInt( Subindex2, CHAR_LV) < 80 ){//等级销弱 + for( i=0; i<4; i++) { + base[i] = base[i]*0.8; + } + } + for( i=0; i<4; i++) { + work[i] += base[i]; + } + return 2; +} + +BOOL PETFUSION_FusionPetMain( int charaindex, int Mainindex, int *work, int *skill) +{ + int i; + int base[4]={0,0,0,0}; + int petskill[7]={-1,-1,-1,-1,-1,-1,-1}; + if( !CHAR_CHECKINDEX( Mainindex)) return FALSE; + if( EVOLUTION_getPetFusionCode( CHAR_getInt( Mainindex, CHAR_PETID) ) < 0 ){ + return 0; + } + if( CHAR_getInt( Mainindex, CHAR_FUSIONBEIT) == 1 || + CHAR_getInt( Mainindex, CHAR_FUSIONRAISE) > 0 )return FALSE;//检查是否为融合宠 + + if( PET_getBaseAndSkill( charaindex, Mainindex, base, petskill, 0) == FALSE ) + return -1; + if( CHAR_getInt( Mainindex, CHAR_LV) < 80 ){//等级销弱 + for( i=0; i<4; i++) { + base[i] = base[i]*0.8; + } + } + for( i=0; i<4; i++) { + work[i] += base[i]*0.6; + } + for( i=0; i<7; i++) { + skill[i] = petskill[i]; + } + + return TRUE; +} + +BOOL PETFUSION_DelPet( int toindex, int Mainindex, int Subindex1, int Subindex2, int flg) +{ + int i, j, cnt=0; + int petindex[3]; + + + petindex[0] = Mainindex; + petindex[1] = Subindex1; + petindex[2] = Subindex2; + + for( i=0; i<3; i++) { + if( !CHAR_CHECKINDEX( petindex[i] ) ) continue; + for( j=0; j= CHAR_MAXPETHAVE){ + + }else { + char szPet[256]; + char msgbuf[256]; + CHAR_setCharPet( toindex, j, -1); + snprintf( szPet, sizeof( szPet ), "K%d", j); + CHAR_sendStatusString( toindex, szPet ); + + snprintf( msgbuf,sizeof( msgbuf), "交出%s。", CHAR_getChar( petindex[i], CHAR_NAME)); + CHAR_talkToCli( toindex, -1, msgbuf, CHAR_COLORYELLOW); + LogPet( + CHAR_getChar( toindex, CHAR_NAME ), + CHAR_getChar( toindex, CHAR_CDKEY ), + CHAR_getChar( petindex[i], CHAR_NAME), + CHAR_getInt( petindex[i], CHAR_LV), + "TenseiDel", + CHAR_getInt( toindex,CHAR_FLOOR), + CHAR_getInt( toindex,CHAR_X ), + CHAR_getInt( toindex,CHAR_Y ), + CHAR_getChar( petindex[i], CHAR_UNIQUECODE) // shan 2001/12/14 + ); + } + CHAR_endCharOneArray( petindex[i] ); + cnt++; + } + if( cnt >= flg ) + return TRUE; + return FALSE; +} + +int PETFUSION_Evolution( int charaindex, int petindex) +{ + char buf[256], buf1[256]; + int newindex=-1; + CHAR_setInt( petindex, CHAR_FUSIONTIMELIMIT, -1); + + sprintf( buf, "蛋〈%s〉孵化成", CHAR_getChar( petindex, CHAR_NAME)); + newindex = EVOLUTION_createPetFromEnemyIndex( charaindex, petindex, 0); + if( !CHAR_CHECKINDEX( newindex) ){ + CHAR_talkToCli( charaindex, -1, "宠物孵化发生错误。", CHAR_COLORYELLOW); + return -1; + } + sprintf( buf1, "〈%s〉。", CHAR_getChar( newindex, CHAR_NAME)); + strcat( buf, buf1); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + + LogPetFeed( + CHAR_getChar( charaindex, CHAR_NAME), + CHAR_getChar( charaindex, CHAR_CDKEY), + CHAR_getChar( petindex, CHAR_NAME), + petindex, + CHAR_getInt( petindex, CHAR_LV), + buf, // Key + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y), + CHAR_getChar( petindex, CHAR_UNIQUECODE) ); + + return newindex; +} +#endif + +#ifdef _PET_TRANS +int PETTRANS_getPetBase( int petindex, int *work, int *petrank) +{ + int i, total=-1; + if( !CHAR_CHECKINDEX( petindex) ){ + total = 0; + *petrank = 1; + for( i=0; i<4; i++) { + work[i] = 50; + total += work[i]; + } + }else{ + int LevelUpPoint = CHAR_getInt( petindex, CHAR_ALLOCPOINT ); + *petrank = CHAR_getInt( petindex, CHAR_PETRANK ); + work[0] = (float)(( LevelUpPoint >> 24 ) & 0xFF); + work[1] = (float)(( LevelUpPoint >> 16 ) & 0xFF); + work[2] = (float)(( LevelUpPoint >> 8 ) & 0xFF); + work[3] = (float)(( LevelUpPoint >> 0 ) & 0xFF); + total = ( work[0] + work[1] + work[2] + work[3] ); + if( total > 150 ) total = 150; + if( total < 0 ) total = 0; + } + return total; +} + +#ifdef _PET_2TRANS +int NPC_PetTransManGetAns( int total1, int total2, int LV, int rank, int tran ) +#else +int NPC_PetTransManGetAns( int total1, int total2, int LV, int rank ) +#endif +{ + int ans=0 , TransLV = 100; + float total = 0.00; + int Fx=1; + + if( LV > 130 ) LV = 130; + total = ( (float)total1/100 ); // 玛蕾最高 total1=200 + total = total*total*total*total*total; + if( total < 1 ) total = 0; + else total= total*1.3; // 所以total最大=41.6 最小=0 + + Fx = (int)((5-rank)*1.2)+5; // rank=0~6 所以 Fx最大=11(rank=0)最小=4(rank=6) + ans = (int)total + total2 + ((LV-TransLV)/Fx); //42+150+30/11=194 + +#ifdef _PET_2TRANS + if( tran == 0 ){ + if( ans > 150 ) + ans = 150; + } + else{ + if( ans > 200 ) + ans = 200; + } +#else + if( ans > 150 ) { + ans = 150; + } +#endif + print("\n ans = %d", ans); + return ans; +} + +int PETTRANS_PetTransManStatus( int toindex, int petindex1, int petindex2) +{ + int petrank=0,i; + int total1,total2,total,petLV,ans; + int petID,enemynum,ret=-1; + int work[4]={0,0,0,0}; + int base[4]={0,0,0,0}; + +#define RAND(x,y) ((x-1)+1+ (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) ) + total1 = PETTRANS_getPetBase( petindex1, work, &petrank); + total2 = PETTRANS_getPetBase( petindex2, base, &petrank); + petLV = CHAR_getInt( petindex2, CHAR_LV); +#ifdef _PET_2TRANS + ans = NPC_PetTransManGetAns( total1, total2, petLV, petrank, CHAR_getInt( petindex2, CHAR_TRANSMIGRATION ) ); +#else + ans = NPC_PetTransManGetAns( total1, total2, petLV, petrank ); +#endif + total = total1 + (total2*4); + total2 = 0; + for( i=0; i<4; i++) { + work[i] = work[i]*4; + total2 += work[i]; + } + total = total1 + total2; + for( i=0; i<4; i++) { + base[i] = (ans * (base[i]+work[i])) /total; + } + enemynum = ENEMY_getEnemyNum(); + petID = CHAR_getInt( petindex2, CHAR_PETID); + for( i=0; i CHAR_getWorkInt( charaindex, CHAR_WORKMAXHP) ){ + Myhp = CHAR_getWorkInt( charaindex, CHAR_WORKMAXHP); + } + CHAR_setInt( charaindex, CHAR_HP, Myhp); + CHAR_complianceParameter( charaindex ); + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_HP); + for( i=0; i CHAR_getWorkInt( petindex, CHAR_WORKMAXHP) ){ + Myhp = CHAR_getWorkInt( petindex, CHAR_WORKMAXHP); + } + CHAR_setInt( petindex, CHAR_HP, Myhp); + CHAR_send_K_StatusString( charaindex, i, CHAR_K_STRING_HP|CHAR_K_STRING_AI); + } + break; + case 2://MP + Myhp = CHAR_getInt( charaindex, CHAR_MP); + dnums = CHAR_getWorkInt( charaindex, CHAR_WORKCHIKULAMP); + Myhp += dnums; + if( Myhp > CHAR_getWorkInt( charaindex, CHAR_WORKMAXMP) ){ + Myhp = CHAR_getWorkInt( charaindex, CHAR_WORKMAXMP); + } + CHAR_setInt( charaindex, CHAR_MP, Myhp); + CHAR_complianceParameter( charaindex ); + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_MP); + break; + } +} +#endif + +#ifdef _STATUS_WATERWORD //水世界状态 +void CHAR_CheckWaterStatus( int charaindex) +{ + if( !CHAR_CHECKINDEX( charaindex) ) return; + if( CHAR_getWorkInt( charaindex, CHAR_WORKSTATUSWATER) == -1 ){ + return; + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKSTATUSWATER) > 0 ){ + CHAR_setWorkInt( charaindex, CHAR_WORKSTATUSWATER, + CHAR_getWorkInt( charaindex, CHAR_WORKSTATUSWATER) -1 ); + + if( CHAR_getWorkInt( charaindex, CHAR_WORKSTATUSWATER) != 0 && + CHAR_getWorkInt( charaindex, CHAR_WORKSTATUSWATER)%10 == 0 ){ + char buf1[256]; + sprintf( buf1, "水中呼吸时间剩馀%d分。", + CHAR_getWorkInt( charaindex, CHAR_WORKSTATUSWATER)); + CHAR_talkToCli( charaindex, -1, buf1, CHAR_COLORYELLOW); + } + } + + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE ){ + return; + } + if( CHAR_getWorkInt( charaindex, CHAR_WORKMAPFLOORTYPE) == 1 && + CHAR_getWorkInt( charaindex, CHAR_WORKSTATUSWATER) <= 0 ){//水世界 + char token[256]; + int defhp=0; + int maxhp = CHAR_getWorkInt( charaindex, CHAR_WORKMAXHP); + int myhp = CHAR_getInt( charaindex, CHAR_HP); + defhp = (maxhp*0.033); + if( defhp <= 0 ) defhp = 1; + myhp = myhp - defhp; + sprintf( token, "因无法呼吸,扣%d HP。", defhp); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + + if( myhp <= 0 ){ + myhp = 1; + if(CHAR_getInt(charaindex,CHAR_FLOOR) == 151 || CHAR_getInt(charaindex,CHAR_FLOOR) == 160 + || CHAR_getInt(charaindex,CHAR_FLOOR) == 161 ) CHAR_warpToSpecificPoint(charaindex,702,213,27); + else CHAR_warpToSpecificPoint( charaindex, 200,102,1021); + } + CHAR_setInt( charaindex, CHAR_HP, myhp); + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_HP); + } + +} +#endif + +int CHAR_findSurplusPetBox( int charaindex ) +{ + int i, remnants=0; + for( i=0; i + +#include "common.h" +#include "char.h" +#include "item_event.h" +#include "net.h" +#include "item.h" +#include "object.h" +#include "lssproto_serv.h" +#include "util.h" +#include "char_data.h" +#include "readmap.h" +#include "map_deal.h" +#include "item.h" +#include "saacproto_cli.h" +#include "npccreate.h" +#include "handletime.h" +#include "anim_tbl.h" +#include "family.h" + +#define SPR_kmydam CG_HIT_MARK_00 +BOOL CHAR_allprewalk( int index,int* dir,int* mode) +{ + int poisonvalue; + poisonvalue = CHAR_getInt(index, CHAR_POISON ); + if( poisonvalue >= 1 ){ + CHAR_setInt(index,CHAR_HP , CHAR_getInt(index,CHAR_HP) + - poisonvalue ); + CHAR_setWorkInt(index,CHAR_WORKLASTATTACKCHARAINDEX,-2); + { + int opt[2] = { SPR_kmydam,poisonvalue}; + CHAR_sendWatchEvent( CHAR_getWorkInt(index,CHAR_WORKOBJINDEX), + CHAR_ACTDAMAGE,opt,2,TRUE); + + CHAR_sendStatusString( index,"M"); + } + poisonvalue--; + if( poisonvalue <= 0)poisonvalue = 1; + CHAR_setInt(index,CHAR_POISON,poisonvalue); + } + if( CHAR_getInt(index,CHAR_CONFUSION) != 0 ) + *dir = RAND(0,7); + if( CHAR_getInt(index,CHAR_STONE) != 0 ) + return FALSE; + return TRUE; +} + +void CHAR_allpostwalk( int index ) +{ + return; +} + +BOOL CHAR_makeCADefaultString( int objindex,char* buf,int buflen, int act ) +{ + char objindexbuf[64]; + /* 民尼永弁 */ + if( CHECKOBJECT(objindex) == FALSE ) return FALSE; + if( OBJECT_getType(objindex) != OBJTYPE_CHARA ) return FALSE; + snprintf( buf,buflen,"%s|%d|%d|%d|%d", + cnv10to62( objindex,objindexbuf, sizeof(objindexbuf)), + OBJECT_getX(objindex), OBJECT_getY(objindex), + act, + CHAR_getInt(OBJECT_getIndex(objindex),CHAR_DIR)); + return TRUE; +} + +static void CHAR_makeCADAMAGEStringFromSpecifiedCoordinate( + int x , int y, char* buf,int buflen,int ef1,int damagevalue ) +{ + snprintf( buf,buflen,"%d|%d|%d|%d|%d|%d|%d", + -1,x,y, CHAR_ACTDAMAGE,0, ef1,damagevalue); +} + +BOOL CHAR_makeCAOPT1String( int objindex,char* buf, int buflen, int act,int opt1 ) +{ + char objindexbuf[64]; + if( CHECKOBJECT(objindex) == FALSE ) return FALSE; + if( OBJECT_getType(objindex) != OBJTYPE_CHARA ) return FALSE; + snprintf( buf,buflen,"%s|%d|%d|%d|%d|%d", + cnv10to62( objindex,objindexbuf, sizeof(objindexbuf)), + OBJECT_getX(objindex), OBJECT_getY(objindex), + act, + CHAR_getInt(OBJECT_getIndex(objindex),CHAR_DIR), opt1); + return TRUE; +} + +#ifdef _STREET_VENDOR +BOOL CHAR_makeCAOPTString(int objindex,char* buf,int buflen,int act,char *string) +{ + char objindexbuf[64]; + + if(CHECKOBJECT(objindex) == FALSE ) return FALSE; + if(OBJECT_getType(objindex) != OBJTYPE_CHARA ) return FALSE; + snprintf( buf,buflen,"%s|%d|%d|%d|%d|%s", + cnv10to62(objindex,objindexbuf, sizeof(objindexbuf)), + OBJECT_getX(objindex), OBJECT_getY(objindex),act, + CHAR_getInt(OBJECT_getIndex(objindex),CHAR_DIR),string); + return TRUE; +} +#endif + +BOOL CHAR_makeCAOPT3String( int objindex,char* buf, int buflen, int act,int opt1,int opt2,int opt3 ) +{ + char objindexbuf[64]; + + if( CHECKOBJECT(objindex) == FALSE ) return FALSE; + if( OBJECT_getType(objindex) != OBJTYPE_CHARA ) return FALSE; + snprintf( buf,buflen,"%s|%d|%d|%d|%d|%d|%d|%d", + cnv10to62( objindex,objindexbuf, sizeof(objindexbuf)), + OBJECT_getX(objindex), OBJECT_getY(objindex), + act, + CHAR_getInt(OBJECT_getIndex(objindex),CHAR_DIR), + opt1,opt2,opt3); + return TRUE; +} + +void CHAR_playerWatchfunc( int objmeindex, int objmoveindex, + CHAR_ACTION act, int x, int y, int dir, int* opt, int optlen ) +{ + int fd; + int meindex; + if( !CHECKOBJECTUSE(objmeindex) )return; + if( !CHECKOBJECTUSE(objmoveindex))return; + if( OBJECT_getType(objmeindex) != OBJTYPE_CHARA )return; + + meindex = OBJECT_getIndex(objmeindex); + if( CHAR_getInt( meindex,CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER )return; + + fd = getfdFromCharaIndex( meindex ); + if( fd == -1 )return; + switch( OBJECT_getType(objmoveindex) ){ + case OBJTYPE_CHARA: + { + char buf[128]; + if( !CHAR_getFlg( OBJECT_getIndex(objmoveindex),CHAR_ISVISIBLE) ) + return; + + switch( act ){ + case CHAR_ACTSTAND: + case CHAR_ACTWALK: + case CHAR_ACTATTACK: + case CHAR_ACTDEAD: + case CHAR_ACTMAGIC: + case CHAR_ACTITEM: + case CHAR_ACTDOWN: + case CHAR_ACTSIT: + case CHAR_ACTHAND: + case CHAR_ACTPLEASURE: + case CHAR_ACTANGRY: + case CHAR_ACTSAD: + case CHAR_ACTDAMAGE: + case CHAR_ACTGUARD: + case CHAR_ACTTURN: + case CHAR_ACTWARP: + case CHAR_ACTACTIONWALK: + case CHAR_ACTNOD: + case CHAR_ACTTHROW: + case CHAR_ACTACTIONSTAND: + if( CHAR_makeCADefaultString(objmoveindex,buf,sizeof(buf),act) ) { + CONNECT_appendCAbuf( fd,buf,strlen(buf)); + } + break; + // shan begin + case CHAR_ACTTRADE: + if( optlen == 1 ) + if( CHAR_makeCAOPT1String( objmoveindex, buf, + sizeof( buf), act, opt[0] ) ) + CONNECT_appendCAbuf( fd, buf, strlen(buf)); + break; + +#ifdef _ANGEL_SUMMON + case CHAR_ACTANGEL: + if( optlen == 1 ) + if( CHAR_makeCAOPT1String( objmoveindex, buf, + sizeof( buf), act, opt[0] ) ) + CONNECT_appendCAbuf( fd, buf, strlen(buf)); + break; +#endif + + // shan end +#ifdef _MIND_ICON + case CHAR_MIND: + if( optlen == 1 ) + if( CHAR_makeCAOPT1String( objmoveindex, buf, + sizeof(buf), act, opt[0])) + CONNECT_appendCAbuf( fd, buf, strlen(buf)); + break; +#endif +#ifdef _STREET_VENDOR + case CHAR_STREETVENDOR_OPEN: + if(CHAR_makeCAOPTString(objmoveindex,buf,sizeof(buf), + act,CHAR_getWorkChar(OBJECT_getIndex(objmoveindex),CHAR_STREETVENDOR_NAME))) + CONNECT_appendCAbuf(fd,buf,strlen(buf)); + break; + case CHAR_STREETVENDOR_CLOSE: + if(CHAR_makeCAOPTString(objmoveindex,buf,sizeof(buf), + act,CHAR_getWorkChar(OBJECT_getIndex(objmoveindex),CHAR_STREETVENDOR_NAME))) + CONNECT_appendCAbuf(fd,buf,strlen(buf)); + break; +#endif +#ifdef _ITEM_CRACKER + case CHAR_ITEM_CRACKER: + if( optlen == 1 ) + if( CHAR_makeCAOPT1String( objmoveindex, buf, + sizeof(buf), act, opt[0])) + CONNECT_appendCAbuf( fd, buf, strlen(buf)); + break; +#endif + case CHAR_ACTEFFECT: + if( optlen == 1 ) + if( CHAR_makeCAOPT1String(objmoveindex,buf, + sizeof(buf),act,opt[0] ) ) + CONNECT_appendCAbuf( fd,buf,strlen(buf)); + break; + case CHAR_ACTPOPUPNAME: + case CHAR_ACTLEADER: + case CHAR_ACTBATTLEWATCH: + if( optlen == 1 ) + if( CHAR_makeCAOPT1String(objmoveindex,buf, + sizeof(buf),act,opt[0] ) ) + CONNECT_appendCAbuf( fd,buf,strlen(buf)); + break; + case CHAR_ACTBATTLE: + if( optlen == 3 ) + if( CHAR_makeCAOPT3String( objmoveindex,buf, sizeof(buf), + act,opt[0],opt[1],opt[2] ) ) + CONNECT_appendCAbuf( fd,buf,strlen(buf)); + break; + default: + break; + } + + break; + } + case OBJTYPE_ITEM: + case OBJTYPE_GOLD: + CHAR_sendSpecifiedobjindexCToCharaindex(meindex,objmoveindex); + break; + default: + break; + } + +} + +void CHAR_sendWallDamage( int charaindex,int x, int y, int damage ) +{ + int fd; + char cabuf[256]=""; + + fd = getfdFromCharaIndex(charaindex); + if( fd == -1 )return; + + CHAR_makeCADAMAGEStringFromSpecifiedCoordinate( + x,y,cabuf,sizeof(cabuf),SPR_kmydam,damage ); + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); +} + + + +static struct ParamShow +{ + int paramindex; /* 由仿丢□正及奶件犯永弁旦 */ + char* offmessage; /* 匀凶凛及丢永本□斥 侬 */ +}pShow[]={ + {CHAR_PARALYSIS, CHAR_RECOVERPARALYSISSTRING}, + {CHAR_SLEEP, CHAR_RECOVERSILENCESTRING}, + {CHAR_STONE, CHAR_RECOVERSTONESTRING}, + {CHAR_DRUNK, CHAR_RECOVERDARKNESSSTRING}, + {CHAR_CONFUSION, CHAR_RECOVERCONFUSIONSTRING}, +}; + +void CHAR_recoveryStatus( int charaindex ) +{ + int i; + int cure=FALSE; + if( !CHAR_CHECKINDEX(charaindex) )return; + + for( i=0 ; i < arraysizeof(pShow) ; i ++ ){ + if( CHAR_getInt(charaindex,pShow[i].paramindex) > 0 ){ + int old; + old = CHAR_setInt(charaindex,pShow[i].paramindex, + CHAR_getInt(charaindex, + pShow[i].paramindex) - 1 ); + if( old == 1 ){ + if( CHAR_getInt(charaindex,CHAR_WHICHTYPE) == CHAR_TYPEPLAYER){ + CHAR_talkToCli( charaindex,-1, pShow[i].offmessage, + CHAR_COLORWHITE ); + } + cure = TRUE; + } + } + } + if( cure ){ + CHAR_sendStatusString( charaindex, "P" ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( + charaindex, CHAR_WORKOBJINDEX) ); + } +} + +static BOOL CHAR_clairvoyance_gold(int objindex,char* buf ) +{ + if( OBJECT_getType( objindex ) == OBJTYPE_GOLD ){ + *buf = 'G'; + return TRUE; + } + return FALSE; +} + +static BOOL CHAR_clairvoyance_item(int objindex,char* buf ) +{ + if( OBJECT_getType( objindex ) == OBJTYPE_ITEM){ + *buf = 'I'; + return TRUE; + } + return FALSE; +} + +static BOOL CHAR_clairvoyance_player(int objindex,char* buf ) +{ + if( OBJECT_getType( objindex ) == OBJTYPE_CHARA + && CHAR_getInt(OBJECT_getIndex(objindex),CHAR_WHICHTYPE) + == CHAR_TYPEPLAYER ){ + *buf = 'P'; + return TRUE; + } + return FALSE; +} + +static BOOL CHAR_clairvoyance_enemy(int objindex,char* buf ) +{ + if( OBJECT_getType( objindex ) == OBJTYPE_CHARA + && CHAR_getInt(OBJECT_getIndex(objindex),CHAR_WHICHTYPE) + == CHAR_TYPEENEMY ){ + *buf = 'E'; + return TRUE; + } + return FALSE; +} + +static char CHAR_clairvoyanceString[STRINGBUFSIZ]; + +static void CHAR_clairvoyance( int charaindex ) +{ + char onebuf[128]; + int stringlen=0; + int clairvoyancelevel; + int centerx,centery,fl; + int i,j; + BOOL sendclairvoyance=FALSE; + +#define CHAR_CLAIRVOYANCEWIDTH 81 + BOOL (*clairvoyancefunc[])(int,char*) ={ + CHAR_clairvoyance_gold, + CHAR_clairvoyance_item, + CHAR_clairvoyance_player, + CHAR_clairvoyance_enemy, + }; + if( CHAR_getWorkInt( charaindex, CHAR_WORKLOOPSTARTSEC)%10 != 0 ) + return; + + clairvoyancelevel = CHAR_getInt(charaindex,CHAR_RADARSTRENGTH ); + + if( clairvoyancelevel <= 0 )return; + if( clairvoyancelevel > arraysizeof( clairvoyancefunc ) ) + clairvoyancelevel = arraysizeof( clairvoyancefunc ); + + centerx = CHAR_getInt(charaindex,CHAR_X); + centery = CHAR_getInt(charaindex,CHAR_Y); + fl = CHAR_getInt(charaindex,CHAR_FLOOR); + + + for( i = centerx - CHAR_CLAIRVOYANCEWIDTH/2 ; + i < centerx + CHAR_CLAIRVOYANCEWIDTH/2 ; i ++ ){ + for( j = centery - CHAR_CLAIRVOYANCEWIDTH/2 ; + j < centery + CHAR_CLAIRVOYANCEWIDTH/2 ; j ++ ){ + OBJECT object; + for( object = MAP_getTopObj(fl,i,j) ; object ; + object = NEXT_OBJECT( object ) ){ + int objindex = GET_OBJINDEX(object); + int loop; + + if( OBJECT_getType(objindex) == OBJTYPE_NOUSE )continue; + if( OBJECT_getType(objindex) == OBJTYPE_CHARA + && OBJECT_getIndex(objindex) == charaindex) continue; + for( loop = 0 ; loop < clairvoyancelevel ; loop ++ ){ + BOOL ret; + char id; + ret = clairvoyancefunc[loop](objindex,&id); + if( ret == TRUE ){ + sendclairvoyance=TRUE; + snprintf( onebuf,sizeof(onebuf), + "%d|%d|%c|",i,j,id ); + strcpysafe( CHAR_clairvoyanceString + stringlen, + sizeof(CHAR_clairvoyanceString) + - stringlen, onebuf); + stringlen += strlen(onebuf); + if( stringlen > sizeof(CHAR_clairvoyanceString) ) + goto RETURN; + } + } + } + } + } + +RETURN: + if( stringlen >= 1 ){ + int fd; + fd = getfdFromCharaIndex( charaindex ); + dchop( CHAR_clairvoyanceString, "|" ); + if( fd != -1 ) + lssproto_R_send( fd, CHAR_clairvoyanceString ); + }else if( !sendclairvoyance ){ + int fd; + fd = getfdFromCharaIndex( charaindex ); + if( fd != -1 ) + lssproto_R_send( fd, "" ); + } +} + +void CHAR_loopFunc( int charaindex ) +{ + CHAR_recoveryStatus( charaindex ); + CHAR_clairvoyance( charaindex ); +} + +void CHAR_playerresurrect( int charaindex, int hp ) +{ + CHAR_setInt(charaindex,CHAR_BASEIMAGENUMBER, + CHAR_getInt(charaindex,CHAR_BASEBASEIMAGENUMBER)); + CHAR_setFlg(charaindex,CHAR_ISDIE, 0); + CHAR_setFlg(charaindex,CHAR_ISATTACKED, 1); + CHAR_setFlg(charaindex,CHAR_ISOVERED, 0); + if( hp >= CHAR_getWorkInt(charaindex,CHAR_WORKMAXHP) ) + hp = CHAR_getWorkInt(charaindex,CHAR_WORKMAXHP); + else if( hp <= 0 ) + hp = 1; + CHAR_setInt(charaindex,CHAR_HP, hp); +} + +int CHAR_die( int charaindex ) +{ + CHAR_DischargeParty( charaindex, 0); + { + int bymonster = 0; + int attackindex = CHAR_getWorkInt(charaindex, + CHAR_WORKLASTATTACKCHARAINDEX); + if( attackindex == -2 ) + bymonster = 0; + else if( CHAR_CHECKINDEX(attackindex) == TRUE ){ + if( CHAR_getInt(attackindex,CHAR_WHICHTYPE) + == CHAR_TYPEENEMY ){ + bymonster = 1; + }else{ + bymonster = 2; + } + } + if( bymonster == 0 || bymonster == 1 ){ + int i; + for( i=0 ; i= 1 ){ + int randomindex = RAND(0,itemhavenum-1); + CHAR_DropItem(charaindex,eqindex[randomindex]); + + } + } + + CHAR_DropMoney(charaindex, + CHAR_getInt(charaindex,CHAR_GOLD)/2 ); + CHAR_setInt(charaindex,CHAR_GOLD,0); + } + CHAR_complianceParameter(charaindex); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt(charaindex, CHAR_WORKOBJINDEX) ); + CHAR_setInt(charaindex,CHAR_DEADCOUNT, + CHAR_getInt(charaindex,CHAR_DEADCOUNT)+1); + { + int i; + BOOL old=FALSE; + for( i=0 ; i 0 ){ + old = TRUE; + } + if( CHAR_setInt( charaindex, CHAR_POISON, 0 ) > 0 )old=TRUE; + if( old ) + CHAR_sendCToArroundCharacter( CHAR_getInt(charaindex, CHAR_WORKOBJINDEX)); + } + CHAR_sendStatusString( charaindex, "P"); + CHAR_sendStatusString( charaindex, "I"); + CHAR_setFlg(charaindex,CHAR_ISDIE,1); + CHAR_setFlg(charaindex,CHAR_ISATTACKED,0); + return 0; +} + +void CHAR_playerTalkedfunc( int charaindex, int talkindex,char* message, int color, int channel ) +{ + int fd; + char lastbuf[4096]; + char mesgbuf[4096]; + char escapebuf[4096]; + int fmindex = CHAR_getInt( charaindex, CHAR_FMINDEX ); + fd = getfdFromCharaIndex( charaindex ); + if( fd == -1 )return; + if( (channel>-1) && (fmindex>0) ){ + if( channel == 0 ){ +#ifndef _CHANNEL_MODIFY + snprintf( lastbuf,sizeof(lastbuf),"P|[族]%s", +#else + snprintf( lastbuf,sizeof(lastbuf),"P|F|[族]%s", +#endif + makeEscapeString( CHAR_appendNameAndTitle(talkindex, message, mesgbuf,sizeof(mesgbuf)), + escapebuf,sizeof(escapebuf) )); + } +#ifdef _FMVER21 + else if( channel == FAMILY_MAXCHANNEL && CHAR_getInt( talkindex, CHAR_FMLEADERFLAG ) == FMMEMBER_LEADER ){ +#else + else if( channel == FAMILY_MAXCHANNEL && CHAR_getInt( talkindex, CHAR_FMLEADERFLAG ) == 1 ){ +#endif +#ifndef _CHANNEL_MODIFY + snprintf( lastbuf,sizeof(lastbuf),"P|[族长广播]%s", +#else + snprintf( lastbuf,sizeof(lastbuf),"P|F|[族长广播]%s", +#endif + makeEscapeString(CHAR_appendNameAndTitle(talkindex, message,mesgbuf,sizeof(mesgbuf)), + escapebuf,sizeof(escapebuf) )); + }else{ + snprintf( lastbuf,sizeof(lastbuf),"P|[%d]%s",channel, + makeEscapeString(CHAR_appendNameAndTitle(talkindex, message,mesgbuf,sizeof(mesgbuf)), + escapebuf,sizeof(escapebuf) )); + } + }else{ +#ifdef _CHANNEL_MODIFY + if(CHAR_getFlg(talkindex,CHAR_ISPARTYCHAT) && (CHAR_getWorkInt(talkindex,CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE)) + snprintf( lastbuf,sizeof(lastbuf),"P|T|[队]%s", + makeEscapeString(CHAR_appendNameAndTitle(talkindex, message,mesgbuf,sizeof(mesgbuf)), + escapebuf,sizeof(escapebuf) )); + else +#ifdef _FONT_SIZE + snprintf( lastbuf,sizeof(lastbuf),"P|P|%s|%d", + makeEscapeString(CHAR_appendNameAndTitle(talkindex, message,mesgbuf,sizeof(mesgbuf)), + escapebuf,sizeof(escapebuf) ), CHAR_getWorkInt( talkindex, CHAR_WORKFONTSIZE) ); +#else + snprintf( lastbuf,sizeof(lastbuf),"P|P|%s", + makeEscapeString(CHAR_appendNameAndTitle(talkindex, message,mesgbuf,sizeof(mesgbuf)), + escapebuf,sizeof(escapebuf) )); +#endif + +#else + snprintf( lastbuf,sizeof(lastbuf),"P|%s", + makeEscapeString(CHAR_appendNameAndTitle(talkindex, message,mesgbuf,sizeof(mesgbuf)), + escapebuf,sizeof(escapebuf) )); +#endif + } + lssproto_TK_send( fd, CHAR_getWorkInt( talkindex, CHAR_WORKOBJINDEX ),lastbuf, color); +} diff --git a/gmsv/char/char_item.c b/gmsv/char/char_item.c new file mode 100644 index 0000000..f6636b0 --- /dev/null +++ b/gmsv/char/char_item.c @@ -0,0 +1,2355 @@ +#include "version.h" +#include + +#include "readmap.h" +#include "map_deal.h" +#include "object.h" +#include "char.h" +#include "char_base.h" +#include "item.h" +#include "lssproto_serv.h" +#include "handletime.h" +#include "log.h" +#include "item_event.h" +#include "battle.h" +#include "petmail.h" +#ifdef _MARKET_TRADE +#include "item_trade.h" +#endif +#ifdef _DROPSTAKENEW +#define CASINOTOKENID 20121 // 游乐场彩券代号 +#define MAXCASINOMAPNUM 150 // 游乐场地图上限 +#define MAXACCUMULATION 1000000 // 积分上限 +typedef struct tagCasinoMapTable +{ + int casinofl; // 游乐场图层 + int casinox; // 游乐场X座标 + int casinoy; // 游乐场Y座标 + int casinotype; // 赌注类型 + int dropflag; // 是否可下注 flag + char casinoinfo[64]; // 赌注类型说明 + int accumulation; // 积分 + int stakenum; // 彩券数量 +}CasinoMapTable; +CasinoMapTable casinomap[MAXCASINOMAPNUM] = +{ + { 7008, 13, 13, DICE_BIG, 1, "骰子-大", 1, 0}, + { 7008, 14, 13, DICE_BIG, 1, "骰子-大", 1, 0}, + { 7008, 15, 13, DICE_BIG, 1, "骰子-大", 1, 0}, + { 7008, 16, 13, DICE_BIG, 1, "骰子-大", 1, 0}, + { 7008, 17, 13, DICE_BIG, 1, "骰子-大", 1, 0}, + { 7008, 13, 14, DICE_BIG, 1, "骰子-大", 1, 0}, + { 7008, 14, 14, DICE_BIG, 1, "骰子-大", 1, 0}, + { 7008, 15, 14, DICE_BIG, 1, "骰子-大", 1, 0}, + { 7008, 16, 14, DICE_BIG, 1, "骰子-大", 1, 0}, + { 7008, 17, 14, DICE_BIG, 1, "骰子-大", 1, 0}, + { 7008, 13, 15, DICE_BIG, 1, "骰子-大", 1, 0}, + { 7008, 14, 15, DICE_BIG, 1, "骰子-大", 1, 0}, + { 7008, 15, 15, DICE_BIG, 1, "骰子-大", 1, 0}, + { 7008, 16, 15, DICE_BIG, 1, "骰子-大", 1, 0}, + { 7008, 17, 15, DICE_BIG, 1, "骰子-大", 1, 0}, + { 7008, 8, 13, DICE_SMALL, 1, "骰子-小", 1, 0}, + { 7008, 9, 13, DICE_SMALL, 1, "骰子-小", 1, 0}, + { 7008, 10, 13, DICE_SMALL, 1, "骰子-小", 1, 0}, + { 7008, 11, 13, DICE_SMALL, 1, "骰子-小", 1, 0}, + { 7008, 12, 13, DICE_SMALL, 1, "骰子-小", 1, 0}, + { 7008, 8, 14, DICE_SMALL, 1, "骰子-小", 1, 0}, + { 7008, 9, 14, DICE_SMALL, 1, "骰子-小", 1, 0}, + { 7008, 10, 14, DICE_SMALL, 1, "骰子-小", 1, 0}, + { 7008, 11, 14, DICE_SMALL, 1, "骰子-小", 1, 0}, + { 7008, 12, 14, DICE_SMALL, 1, "骰子-小", 1, 0}, + { 7008, 8, 15, DICE_SMALL, 1, "骰子-小", 1, 0}, + { 7008, 9, 15, DICE_SMALL, 1, "骰子-小", 1, 0}, + { 7008, 10, 15, DICE_SMALL, 1, "骰子-小", 1, 0}, + { 7008, 11, 15, DICE_SMALL, 1, "骰子-小", 1, 0}, + { 7008, 12, 15, DICE_SMALL, 1, "骰子-小", 1, 0}, + + { 7005, 22, 21, PET_RACE1, 1, "竞速场-宠物1", 2, 0}, + { 7005, 23, 21, PET_RACE1, 1, "竞速场-宠物1", 2, 0}, + { 7005, 24, 21, PET_RACE1, 1, "竞速场-宠物1", 2, 0}, + { 7005, 25, 21, PET_RACE1, 1, "竞速场-宠物1", 2, 0}, + { 7005, 26, 21, PET_RACE1, 1, "竞速场-宠物1", 2, 0}, + { 7005, 27, 21, PET_RACE1, 1, "竞速场-宠物1", 2, 0}, + { 7005, 28, 21, PET_RACE1, 1, "竞速场-宠物1", 2, 0}, + { 7005, 22, 24, PET_RACE2, 1, "竞速场-宠物2", 2, 0}, + { 7005, 23, 24, PET_RACE2, 1, "竞速场-宠物2", 2, 0}, + { 7005, 24, 24, PET_RACE2, 1, "竞速场-宠物2", 2, 0}, + { 7005, 25, 24, PET_RACE2, 1, "竞速场-宠物2", 2, 0}, + { 7005, 26, 24, PET_RACE2, 1, "竞速场-宠物2", 2, 0}, + { 7005, 27, 24, PET_RACE2, 1, "竞速场-宠物2", 2, 0}, + { 7005, 28, 24, PET_RACE2, 1, "竞速场-宠物2", 2, 0}, + { 7005, 22, 27, PET_RACE3, 1, "竞速场-宠物3", 2, 0}, + { 7005, 23, 27, PET_RACE3, 1, "竞速场-宠物3", 2, 0}, + { 7005, 24, 27, PET_RACE3, 1, "竞速场-宠物3", 2, 0}, + { 7005, 25, 27, PET_RACE3, 1, "竞速场-宠物3", 2, 0}, + { 7005, 26, 27, PET_RACE3, 1, "竞速场-宠物3", 2, 0}, + { 7005, 27, 27, PET_RACE3, 1, "竞速场-宠物3", 2, 0}, + { 7005, 28, 27, PET_RACE3, 1, "竞速场-宠物3", 2, 0}, + + { 7003, 21, 15, ROULETTE1, 1, "轮盘红1", 1, 0}, { 7003, 17, 15, ROULETTE3, 1, "轮盘红3", 1, 0}, + { 7003, 13, 15, ROULETTE5, 1, "轮盘红5", 1, 0}, { 7003, 21, 21, ROULETTE6, 1, "轮盘红6", 1, 0}, + { 7003, 17, 21, ROULETTE8, 1, "轮盘红8", 1, 0}, { 7003, 15, 21, ROULETTE9, 1, "轮盘红9", 1, 0}, + { 7003, 13, 21, ROULETTE10, 1, "轮盘红10", 1, 0}, { 7003, 13, 18, ROULETTE13, 1, "轮盘红13", 1, 0}, + { 7003, 9, 21, ROULETTE17, 1, "轮盘红17", 1, 0}, { 7003, 21, 18, ROULETTE18, 1, "轮盘红18", 1, 0}, + + { 7003, 19, 15, ROULETTE22, 1, "轮盘绿2", 1, 0}, { 7003, 15, 15, ROULETTE24, 1, "轮盘绿4", 1, 0}, + { 7003, 19, 21, ROULETTE27, 1, "轮盘绿7", 1, 0}, { 7003, 11, 15, ROULETTE31, 1, "轮盘绿11", 1, 0}, + { 7003, 9, 15, ROULETTE32, 1, "轮盘绿12", 1, 0}, { 7003, 11, 18, ROULETTE34, 1, "轮盘绿14", 1, 0}, + { 7003, 9, 18, ROULETTE35, 1, "轮盘绿15", 1, 0}, { 7003, 11, 21, ROULETTE36, 1, "轮盘绿16", 1, 0}, + { 7003, 19, 18, ROULETTE39, 1, "轮盘绿19", 1, 0}, { 7003, 17, 18, ROULETTE40, 1, "轮盘绿20", 1, 0}, + { 7003, 17, 24, ROULETTE41, 1, "轮盘红", 1, 0}, { 7003, 16, 24, ROULETTE41, 1, "轮盘红", 1, 0}, + { 7003, 17, 25, ROULETTE41, 1, "轮盘红", 1, 0}, { 7003, 16, 25, ROULETTE41, 1, "轮盘红", 1, 0}, + { 7003, 14, 24, ROULETTE42, 1, "轮盘绿", 1, 0}, { 7003, 13, 24, ROULETTE42, 1, "轮盘绿", 1, 0}, + { 7003, 14, 25, ROULETTE42, 1, "轮盘绿", 1, 0}, { 7003, 13, 25, ROULETTE42, 1, "轮盘绿", 1, 0}, + + // WON ADD 修正地图上单双的错误 + { 7003, 11, 24, ROULETTE43, 1, "轮盘单", 1, 0}, { 7003, 10, 24, ROULETTE43, 1, "轮盘单", 1, 0}, + { 7003, 11, 25, ROULETTE43, 1, "轮盘单", 1, 0}, { 7003, 10, 25, ROULETTE43, 1, "轮盘单", 1, 0}, + { 7003, 20, 24, ROULETTE44, 1, "轮盘双", 1, 0}, { 7003, 19, 24, ROULETTE44, 1, "轮盘双", 1, 0}, + { 7003, 20, 25, ROULETTE44, 1, "轮盘双", 1, 0}, { 7003, 19, 25, ROULETTE44, 1, "轮盘双", 1, 0}, + + + + { 7003, 20, 15, (ROULETTE1<<16)+ROULETTE22, 1, "双号红1绿2", 1, 0}, + { 7003, 18, 15, (ROULETTE3<<16)+ROULETTE22, 1, "双号红3绿2", 1, 0}, + { 7003, 16, 15, (ROULETTE3<<16)+ROULETTE24, 1, "双号红3绿4", 1, 0}, + { 7003, 14, 15, (ROULETTE5<<16)+ROULETTE24, 1, "双号红5绿4", 1, 0}, + { 7003, 12, 15, (ROULETTE5<<16)+ROULETTE31, 1, "双号红5绿11", 1, 0}, + { 7003, 10, 15, (ROULETTE32<<16)+ROULETTE31, 1, "双号绿12绿11", 1, 0}, + + { 7003, 20, 18, (ROULETTE18<<16)+ROULETTE39, 1, "双号红18绿19", 1, 0}, + { 7003, 18, 18, (ROULETTE40<<16)+ROULETTE39, 1, "双号绿20绿19", 1, 0}, + { 7003, 16, 18, (ROULETTE40<<16)+ROULETTE45, 1, "双号绿20黑00", 1, 0}, + { 7003, 14, 18, (ROULETTE13<<16)+ROULETTE45, 1, "双号红13黑00", 1, 0}, + { 7003, 12, 18, (ROULETTE13<<16)+ROULETTE34, 1, "双号红13绿14", 1, 0}, + { 7003, 10, 18, (ROULETTE35<<16)+ROULETTE34, 1, "双号绿15绿14", 1, 0}, + + { 7003, 20, 21, (ROULETTE6<<16) +ROULETTE27, 1, "双号红6绿7", 1, 0}, + { 7003, 18, 21, (ROULETTE8<<16) +ROULETTE27, 1, "双号红8绿7", 1, 0}, + { 7003, 16, 21, (ROULETTE8<<16) + ROULETTE9, 1, "双号红8红9", 1, 0}, + { 7003, 14, 21, (ROULETTE10<<16)+ ROULETTE9, 1, "双号红10红9", 1, 0}, + { 7003, 12, 21, (ROULETTE10<<16)+ROULETTE36, 1, "双号红10绿16", 1, 0}, + { 7003, 10, 21, (ROULETTE17<<16)+ROULETTE36, 1, "双号红17绿16", 1, 0}, + { 7003, 8, 15, ROULETTE51, 1, "横列1", 1, 0}, //横列 + { 7003, 8, 18, ROULETTE52, 1, "横列2", 1, 0}, + { 7003, 8, 21, ROULETTE53, 1, "横列3", 1, 0}, + { 7003, 6, 15, ROULETTE61, 1, "号码1-10", 1, 0}, //1到10 + { 7003, 5, 15, ROULETTE61, 1, "号码1-10", 1, 0}, + { 7003, 6, 16, ROULETTE61, 1, "号码1-10", 1, 0}, + { 7003, 5, 16, ROULETTE61, 1, "号码1-10", 1, 0}, + { 7003, 24, 15, ROULETTE62, 1, "号码11-20", 1, 0}, //10到11 + { 7003, 23, 15, ROULETTE62, 1, "号码11-20", 1, 0}, + { 7003, 24, 16, ROULETTE62, 1, "号码11-20", 1, 0}, + { 7003, 23, 16, ROULETTE62, 1, "号码11-20", 1, 0}, + { 7003, 15, 18, ROULETTE45, 1, "轮盘(00)", 1, 0}, + +}; +#endif + + +static char CHAR_sendItemBuffer[STRINGBUFSIZ]; +BOOL CHAR_sendItemDataOne( int charaindex, int haveitemindex) +{ + int itemgrp[1]; + itemgrp[0] = haveitemindex; + return CHAR_sendItemData( charaindex, itemgrp, 1); +} + +BOOL CHAR_sendItemData( int charaindex, int *itemgroup, int num) +{ + int i; + int strlength = 0; + int fd; + + if( num <= 0 || num > CHAR_MAXITEMHAVE) return FALSE; + + if( CHAR_getInt(charaindex,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ) { + return FALSE; + } + for( i = 0; i < num; i ++ ) { + char token[512]; + int itemindex; +DebugPoint = 200; + if( !CHAR_CHECKITEMINDEX( charaindex, itemgroup[i])) { + continue; + } + itemindex = CHAR_getItemIndex( charaindex, itemgroup[i] ); + if( itemindex >= 0 ) { + snprintf( token ,sizeof(token),"%s|" , + ITEM_makeItemStatusString( itemgroup[i],itemindex ) ); + }else { + snprintf( token ,sizeof(token),"%s|" , + ITEM_makeItemFalseStringWithNum( itemgroup[i]) ); + } + strcpysafe( CHAR_sendItemBuffer + strlength, + sizeof(CHAR_sendItemBuffer) - strlength, token ); + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_sendItemBuffer) ) { + break; + } + } + dchop( CHAR_sendItemBuffer , "|" ); + fd = getfdFromCharaIndex( charaindex ); + if( fd != -1 ){ + lssproto_I_send( fd, CHAR_sendItemBuffer ); + return TRUE; + } + return FALSE; +} + +static void CHAR_sendItemDetachEvent( int charaindex,int itemid ) +{ + char mesg[256]; + + snprintf( mesg, sizeof( mesg), "卸下%s ", ITEM_getAppropriateName(itemid) ); + CHAR_talkToCli(charaindex,-1,mesg,CHAR_COLORWHITE); +#ifdef _ITEM_METAMO + if( ITEM_getEquipPlace( charaindex, itemid) == CHAR_BODY + && CHAR_getWorkInt( charaindex, CHAR_WORKITEMMETAMO) != 0 ) { + CHAR_setWorkInt( charaindex, CHAR_WORKITEMMETAMO, 0); + CHAR_setWorkInt( charaindex, CHAR_WORKNPCMETAMO, 0 ); //与npc对话後的变身也要变回来 + CHAR_complianceParameter( charaindex); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + CHAR_talkToCli( charaindex, -1, "变身失效了!", CHAR_COLORWHITE); + } +#endif + { + typedef void (*DETACHFUNC)(int,int); + DETACHFUNC def; + def=(DETACHFUNC)ITEM_getFunctionPointer(itemid,ITEM_DETACHFUNC); + if( def ) { + def( charaindex,itemid ); + } + } +} + +static void CHAR_sendItemAttachEvent( int charaindex,int itemid ) +{ + char mesg[256]; + snprintf( mesg, sizeof( mesg), "装备%s ", + ITEM_getAppropriateName(itemid) ); + CHAR_talkToCli(charaindex,-1,mesg,CHAR_COLORWHITE); + { + typedef void (*ATTACHFUNC)(int,int); + ATTACHFUNC atf; + atf=(ATTACHFUNC)ITEM_getFunctionPointer(itemid,ITEM_ATTACHFUNC); + if( atf ) + atf( charaindex,itemid ); + } +} + + +int CHAR_findSurplusItemBox( int charaindex ) +{ + int i, remnants=0, itemindex; + for(i=CHAR_STARTITEMARRAY; i< CHAR_MAXITEMHAVE; i++){ + itemindex = CHAR_getItemIndex( charaindex , i ); + if( itemindex == -1 ) remnants++; + } + return remnants; +} + + +static int CHAR_findEmptyItemBoxFromChar( Char* ch ) +{ + int i; + + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE ; i ++ ){ + int itemindex; + itemindex = ch->indexOfExistItems[i]; + if( itemindex == -1 )return i; + } + + return -1; +} + +static int CHAR_findEmptyPoolItemBoxFromChar( Char* ch ) +{ + int i; + for( i=0; iindexOfExistPoolItems[i]; + if( itemindex == -1 ) return i; + } + return -1; +} + +int CHAR_findEmptyPoolItemBox( int index ) +{ + Char* ch; + if( !CHAR_CHECKINDEX( index ) )return -1; + ch = CHAR_getCharPointer(index); + if( ch != NULL ) + return CHAR_findEmptyPoolItemBoxFromChar( ch ); + else + return -1; +} + +int CHAR_findEmptyItemBox( int index ) +{ + Char* ch; + + if( !CHAR_CHECKINDEX( index ) )return -1; + ch = CHAR_getCharPointer(index); + if( ch != NULL ) + return CHAR_findEmptyItemBoxFromChar( ch ); + else + return -1; + +} + +#define LACKOFCLASS {CHAR_talkToCli(index,-1,"能力不足无法装备。",CHAR_COLORWHITE);} +#define CANNOTEQUIP {CHAR_talkToCli(index,-1,"无法装备该项物品。",CHAR_COLORWHITE);} +#define CANNOTEQUIP2 {CHAR_talkToCli(index,-1,"无法同时装备两项同种类的物品。",CHAR_COLORWHITE);} +#define CANNOTEXCHANGE {CHAR_talkToCli(index,-1,"无法交换此两项物品。",CHAR_COLORWHITE);} +#define CANNOTMOVE {CHAR_talkToCli(index,-1,"无法移动该项物品。",CHAR_COLORWHITE);} + +static BOOL CHAR_sendSIToCli( int charindex , int from , int to ) +{ + int fd = getfdFromCharaIndex( charindex ); + if( fd != -1 ){ + lssproto_SI_send( fd , from, to ); + return TRUE; + } + return FALSE; +} + +static BOOL CHAR_moveItemFromItemBoxToEquip( int index, int fromindex, + int toindex ) +{ + int fromid,toid; + int fromeqplace; + BOOL flg = FALSE; + + if( !CHAR_CHECKINDEX( index ) )return FALSE; + + fromid = CHAR_getItemIndex(index,fromindex); + toid = CHAR_getItemIndex(index,toindex); + if( !ITEM_CHECKINDEX( fromid) ) + return FALSE; + + if( CHAR_getInt( index, CHAR_TRANSMIGRATION ) <= 0 ){ + if( ITEM_getInt(fromid,ITEM_LEVEL) > CHAR_getInt(index,CHAR_LV) ){ + LACKOFCLASS; + return FALSE; + } + } +#ifdef _ITEMSET4_TXT + if( CHAR_getInt( index, CHAR_STR) < ITEM_getInt( fromid, ITEM_NEEDSTR) ) return FALSE; + if( CHAR_getInt( index, CHAR_DEX) < ITEM_getInt( fromid, ITEM_NEEDDEX) ) return FALSE; + if( CHAR_getInt( index, CHAR_TRANSMIGRATION) < ITEM_getInt( fromid, ITEM_NEEDTRANS) ) return FALSE; +#ifdef _CHAR_PROFESSION // WON ADD 人物职业 + if( ITEM_getInt( fromid, ITEM_NEEDPROFESSION) != 0 ){ + if( CHAR_getInt( index, PROFESSION_CLASS ) != ITEM_getInt( fromid, ITEM_NEEDPROFESSION) ) + return FALSE; + } +#endif +#endif + +#ifdef _FIXBUG_ATTACKBOW + { + if( CHAR_getWorkInt( index, CHAR_WORKITEMMETAMO) > 0 || + CHAR_getWorkInt( index, CHAR_WORKNPCMETAMO) > 0 + || CHAR_getWorkInt( index, CHAR_WORKFOXROUND ) != -1){ //若是变成小狐狸 + + int armtype = ITEM_getInt( fromid, ITEM_TYPE ); + + if( armtype == ITEM_BOW || armtype == ITEM_BOUNDTHROW || + armtype == ITEM_BREAKTHROW || armtype == ITEM_BOOMERANG) { + CHAR_talkToCli( index, -1, "变身无法使用远距离武器!", CHAR_COLORYELLOW ); + return FALSE; + } + } + } +#endif + +#ifdef _ANGEL_SUMMON + //if( !strcmp( ITEM_getChar( fromid, ITEM_USEFUNC), "ITEM_AngelToken") ) { + if( ITEM_getInt( fromid, ITEM_ID) == ANGELITEM ) { + int mindex; + char nameinfo[64]; + + mindex = checkIfAngel( index); + getMissionNameInfo( index, nameinfo); + if( mindex < 0 || + strcmp( ITEM_getChar( fromid, ITEM_ANGELINFO), missiontable[mindex].angelinfo) || + strcmp( ITEM_getChar( fromid, ITEM_HEROINFO), missiontable[mindex].heroinfo) || + strcmp( ITEM_getChar( fromid, ITEM_ANGELINFO), nameinfo) ) { + + CHAR_talkToCli( index, -1, "这并不是属於你的信物,无法装备。", CHAR_COLORYELLOW ); + return FALSE; + } + } +#endif + + fromeqplace = ITEM_getEquipPlace( index, fromid ); + if( fromeqplace == -1 ){ + CANNOTEQUIP; + return FALSE; + } + //if( BATTLE_GetWepon( charaindex ) != ITEM_BOW ) + + if( fromeqplace == CHAR_DECORATION1 ) { + int checkplace = ( toindex == CHAR_DECORATION1) + ? CHAR_DECORATION2:CHAR_DECORATION1; + int otheritemindex; + + if( toindex == CHAR_DECORATION1 || toindex == CHAR_DECORATION2 ) { + otheritemindex = CHAR_getItemIndex( index, checkplace); + if( ITEM_CHECKINDEX( otheritemindex )) { + int otheritemtype = ITEM_getInt( otheritemindex, ITEM_TYPE); + int myitemtype = ITEM_getInt( CHAR_getItemIndex( index, fromindex) , ITEM_TYPE); + if( otheritemtype == myitemtype) { + if( toid < 0 ) { + CANNOTEQUIP2; + }else { + CANNOTEXCHANGE; + } + return FALSE; + } + } + flg = TRUE; + } + }else { + if( toindex == fromeqplace) flg = TRUE; + } + if( flg ){ + CHAR_setItemIndex(index,toindex,fromid); + CHAR_setItemIndex(index,fromindex,toid); + if( toid != -1 ) { + CHAR_sendItemDetachEvent( index, toid ); + } +#ifdef _CHECK_ITEM_MODIFY + ITEM_checkItemModify( index, fromid); +#endif + CHAR_sendItemAttachEvent( index, fromid ); + CHAR_sendSIToCli( index, fromindex,toindex ); + }else { + CANNOTEQUIP; + return FALSE; + } + +#if 0 //#ifdef _ANGEL_SUMMON + //if( !strcmp( ITEM_getChar( fromid, ITEM_USEFUNC), "ITEM_AngelToken") ) { + if( ITEM_getInt( fromid, ITEM_ID) == ANGELITEM ) { + print(" 装备使者信物 "); + CHAR_talkToCli( index, -1, "你受到了精灵保护,不会被敌人攻击。", CHAR_COLORYELLOW ); + //CHAR_setWorkInt( index, CHAR_WORKANGELMODE, TRUE); + CHAR_sendAngelMark( CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), 1); + } +#endif + + return TRUE; +} + +static BOOL CHAR_moveItemFromEquipToItemBox(int index, int fromindex, + int toindex) +{ + int fromid,toid; + + if( !CHAR_CHECKINDEX( index )) return FALSE; + + fromid = CHAR_getItemIndex(index,fromindex); + toid = CHAR_getItemIndex(index,toindex); + if( fromid < 0 ) + return FALSE; + else if( toid < 0 ){ + CHAR_setItemIndex(index,toindex,fromid); + CHAR_setItemIndex(index,fromindex,-1); + CHAR_sendItemDetachEvent( index,fromid ); + CHAR_sendSIToCli( index,fromindex,toindex); +#if 0 //#ifdef _ANGEL_SUMMON + //if( !strcmp( ITEM_getChar( fromid, ITEM_USEFUNC), "ITEM_AngelToken") ) { + if( ITEM_getInt( fromid, ITEM_ID) == ANGELITEM ) { + print(" 卸下使者信物 "); + CHAR_setWorkInt( index, CHAR_WORKANGELMODE, FALSE); + CHAR_sendAngelMark( CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), 0); + } +#endif + return TRUE; + } + + return CHAR_moveItemFromItemBoxToEquip(index, toindex,fromindex); +} + +#ifdef _ITEM_PILENUMS +int CHAR_getMyMaxPilenum( int charaindex) +{ + int maxpile; + maxpile = CHAR_getInt( charaindex, CHAR_TRANSMIGRATION) + + (CHAR_getInt( charaindex, CHAR_TRANSMIGRATION)/5) * 2 + 3; + +/* +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + maxpile += CHAR_getInt( charaindex, ATTACHPILE ); +#endif +*/ + +#ifdef _EQUIT_ADDPILE + maxpile += CHAR_getWorkInt( charaindex, CHAR_WORKATTACHPILE); + maxpile = (maxpile<0)?0:maxpile; +#endif + return maxpile; +} + +BOOL CHAR_PileItemFromItemBoxToItemBox( int charaindex, int fromindex, int toindex) +{ + int maxpile, fromid, toid; + if( !CHAR_CHECKINDEX( charaindex) ) return FALSE; + fromid = CHAR_getItemIndex( charaindex, fromindex); + toid = CHAR_getItemIndex( charaindex, toindex); + + maxpile = CHAR_getMyMaxPilenum( charaindex); + + if( ITEM_CHECKINDEX( toid) && ITEM_CHECKINDEX( fromid) && + (ITEM_getInt( toid, ITEM_ID) == ITEM_getInt( fromid, ITEM_ID)) && + (ITEM_getInt( toid, ITEM_CANBEPILE) == 1) && + (ITEM_getInt( toid, ITEM_USEPILENUMS) < maxpile) && + (ITEM_getInt( fromid, ITEM_USEPILENUMS) < maxpile) ){ + int formpilenum , pilenum, defpilenum; + + pilenum = ITEM_getInt( toid, ITEM_USEPILENUMS); + formpilenum = ITEM_getInt( fromid, ITEM_USEPILENUMS); + defpilenum = ((maxpile-pilenum)>formpilenum)? formpilenum:(maxpile-pilenum); + formpilenum = formpilenum - defpilenum; + pilenum = pilenum + defpilenum; + ITEM_setInt( toid, ITEM_USEPILENUMS, pilenum); + ITEM_setInt( fromid, ITEM_USEPILENUMS, formpilenum); + + if( formpilenum <= 0 ){ + CHAR_setItemIndex( charaindex, fromindex ,-1); + ITEM_endExistItemsOne( fromid); + } + return TRUE; + } + return FALSE; +} +#endif + +static BOOL CHAR_moveItemFromItemBoxToItemBox( int index, int fromindex, int toindex) +{ + int fromid, toid; + + if( !CHAR_CHECKINDEX( index ) ) return FALSE; +#ifdef _ITEM_PILENUMS + if( CHAR_PileItemFromItemBoxToItemBox( index, fromindex, toindex) == TRUE ){ + CHAR_sendItemDataOne( index, toindex); + CHAR_sendItemDataOne( index, fromindex); + return TRUE; + } +#endif + fromid = CHAR_getItemIndex( index, fromindex); + toid = CHAR_getItemIndex( index, toindex); + + CHAR_setItemIndex(index,toindex, CHAR_setItemIndex( index, fromindex, toid)); + CHAR_sendSIToCli( index,fromindex,toindex); + + return TRUE; +} + +void CHAR_moveEquipItem( int index, int fromindex, int toindex ) +{ +#define MOVEITEM_NONE 0 +#define MOVEITEM_EQUIPTOITEM 1 << 0 +#define MOVEITEM_ITEMTOEQUIP 1 << 1 +#define MOVEITEM_ITEMTOITEM 1 << 2 + + int fromid; /* item 匹及奶件犯永弁旦 */ + + + unsigned int moved_any = 0; + while( 1) { + if( !CHAR_CHECKINDEX( index ) )break; + if( CHAR_getFlg( index,CHAR_ISDIE ) )break; + if( fromindex < 0 || fromindex >= CHAR_MAXITEMHAVE || + toindex < 0 || toindex >= CHAR_MAXITEMHAVE ) + break; + + fromid = CHAR_getItemIndex(index,fromindex); + if( fromid == -1 || fromid == -2 )break; + if( fromindex == toindex )break; + if( fromindex < CHAR_EQUIPPLACENUM ){ + if( toindex < CHAR_EQUIPPLACENUM ){ + if( CHAR_getItemIndex(index,toindex) < 0 ){ + CANNOTMOVE; + }else{ + CANNOTEXCHANGE; + } + + }else { + moved_any |= CHAR_moveItemFromEquipToItemBox( + index, fromindex, toindex ) + ? MOVEITEM_EQUIPTOITEM : MOVEITEM_NONE; + if( moved_any & MOVEITEM_EQUIPTOITEM) { + char category[3]; + snprintf( category,sizeof( category),"J%d", fromindex); + CHAR_sendStatusString( index , category); + } + } + }else{ + if( toindex < CHAR_EQUIPPLACENUM ) { + moved_any |= CHAR_moveItemFromItemBoxToEquip( + index, fromindex , toindex ) + ? MOVEITEM_ITEMTOEQUIP : MOVEITEM_NONE; + if( moved_any & MOVEITEM_ITEMTOEQUIP) { + char category[3]; + snprintf( category,sizeof( category),"J%d", toindex); + CHAR_sendStatusString( index , category); + } + }else { + moved_any |= CHAR_moveItemFromItemBoxToItemBox( index,fromindex,toindex ) + ? MOVEITEM_ITEMTOITEM : MOVEITEM_NONE; + } + } + CHAR_complianceParameter( index ); + CHAR_sendCToArroundCharacter(CHAR_getWorkInt(index, CHAR_WORKOBJINDEX)); + break; + } + + if( (moved_any & MOVEITEM_EQUIPTOITEM) || (moved_any & MOVEITEM_ITEMTOEQUIP)){ + int i; + CHAR_send_P_StatusString( index, + CHAR_P_STRING_HP|CHAR_P_STRING_MAXHP| + CHAR_P_STRING_MP|CHAR_P_STRING_MAXMP| + CHAR_P_STRING_ATK|CHAR_P_STRING_DEF| + CHAR_P_STRING_QUICK|CHAR_P_STRING_CHARM| + CHAR_P_STRING_LUCK|CHAR_P_STRING_EARTH| + CHAR_P_STRING_WATER|CHAR_P_STRING_FIRE| + CHAR_P_STRING_WIND + ); + if( CHAR_getWorkInt( index,CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE ){ + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + int petindex = CHAR_getCharPet( index, i); + if( CHAR_CHECKINDEX( petindex) ) { + char category[3]; + CHAR_complianceParameter( petindex ); + snprintf( category, sizeof( category), "K%d",i); + CHAR_sendStatusString( index, category ); + } + } + } + + } + if( !moved_any ) { + CHAR_sendSIToCli( index,-1,-1); + } +} + +int CHAR_addItemToChar( Char* ch, int itemid ) +{ + int itembox; + itembox = CHAR_findEmptyItemBoxFromChar( ch ); + if( itembox == -1 )return -1; + + return ch->indexOfExistItems[itembox]=ITEM_makeItemAndRegist(itemid); +} + +int CHAR_addItem( int charaindex, int itemid ) +{ + Char* ch; + ch = CHAR_getCharPointer(charaindex); + if( ch != NULL ){ + int ret = CHAR_addItemToChar( ch,itemid ); + if( ret == -1 )return ret; + ITEM_setWorkInt(ret,ITEM_WORKCHARAINDEX,charaindex); + ITEM_setWorkInt(ret,ITEM_WORKOBJINDEX,-1); + return ret; + }else + return -1; +} + + +void CHAR_ItemUse( int charaindex, int to_charaindex, int haveitemindex ) +{ + void (*usefunc)(int,int,int)=NULL; + int itemindex; + if( !CHAR_CHECKINDEX( charaindex ) ){ + print( "ANDY charaindex=%d err\n", charaindex); + return; + } + if( CHAR_CHECKITEMINDEX( charaindex, haveitemindex) == FALSE ){ + print( "ANDY haveitemindex=%d err\n", haveitemindex); + return; + } + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) ){ + print( "ANDY charaindex=%d is CHAR_ISDIE err\n", charaindex); + return; + } +#ifdef _STREET_VENDOR + // 摆摊中不可使用道具 + if(CHAR_getWorkInt(charaindex,CHAR_WORKSTREETVENDOR) > -1){ + print("StreetVendor use item charaindex=%d,name=%s\n",charaindex,CHAR_getChar(charaindex,CHAR_NAME)); + return; + } +#endif + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE ) { + if( CHAR_getInt( to_charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + int action = ITEM_getInt( itemindex, ITEM_USEACTION); + if( action != -1 ) { + CHAR_sendAction( to_charaindex, action, TRUE); + } + } + } + //不等於料理 和 其他 + if( ITEM_getInt( itemindex,ITEM_TYPE) != ITEM_OTHER && + ITEM_getInt( itemindex,ITEM_TYPE) != ITEM_DISH ) { + CHAR_EquipPlace ep; + + ep = ITEM_getEquipPlace( charaindex, itemindex ); + if( ep == -1 )return; + if( ep == CHAR_DECORATION1 ) { + int flg = FALSE; + int toitemindex1 = CHAR_getItemIndex( charaindex, ep); + int toitemindex2 = CHAR_getItemIndex( charaindex, CHAR_DECORATION2); + int searchindex = -1; + int fromitemtype = ITEM_getInt( itemindex, ITEM_TYPE); + + if( !ITEM_CHECKINDEX( toitemindex1)) searchindex = toitemindex2; + else if(!ITEM_CHECKINDEX( toitemindex2)) searchindex = toitemindex1; + if( searchindex != -1 ) { + if( fromitemtype != ITEM_getInt( searchindex, ITEM_TYPE)) { + flg = TRUE; + ep = ( searchindex == toitemindex1) + ? CHAR_DECORATION2:CHAR_DECORATION1; + } + } + if( !flg) { + if( fromitemtype != ITEM_getInt( toitemindex2, ITEM_TYPE)) { + ep = CHAR_DECORATION1; + }else if( fromitemtype != ITEM_getInt( toitemindex1, ITEM_TYPE)) { + ep = CHAR_DECORATION2; + }else { + ep = CHAR_DECORATION1; + } + } + } + CHAR_moveEquipItem( charaindex, haveitemindex,ep ); + return; + } + + usefunc = (void(*)(int,int,int)) + ITEM_getFunctionPointer( itemindex,ITEM_USEFUNC ); + if( usefunc ){ + { + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), /* 失奶 丞 寞 */ +#endif + "Use(使用道具)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + usefunc(charaindex, to_charaindex, haveitemindex); + }else{ + char ansmsg[256]; + strcpysafe( ansmsg, sizeof(ansmsg), + "什麽也没有发生。"); + CHAR_talkToCli( charaindex, -1, ansmsg, CHAR_COLORWHITE ); + } +} + +BOOL CHAR_DropItemFXY( int charaindex, int itemcharaindex, int fl, + int x, int y, int* objindex ) +{ + int itemindex; + itemindex = CHAR_getItemIndex(charaindex,itemcharaindex); + if( ITEM_CHECKINDEX(itemindex) == FALSE )return -3; + if( MAP_walkAbleFromPoint( fl,x,y, FALSE ) == FALSE ){ + return -2; + } + + { + OBJECT object; + for( object=MAP_getTopObj(fl,x,y) ; object; object = NEXT_OBJECT(object ) ){ + int objindex = GET_OBJINDEX(object); + switch( OBJECT_getType(objindex) ){ + case OBJTYPE_NOUSE: + break; + case OBJTYPE_ITEM: +#ifdef _DROPSTAKENEW + if(ITEM_getInt(itemindex, ITEM_ID) == CASINOTOKENID) + { + int i = 0; + int dropflag = 0; + ITEM_Item *itm; + for(i = 0; i < arraysizeof(casinomap); i++){ + if(CHAR_getInt(charaindex, CHAR_FLOOR) == casinomap[i].casinofl){ + if(x == casinomap[i].casinox && y == casinomap[i].casinoy){ + dropflag = 1; + break; + } + } + } + if(dropflag == 1){ + if( (itm = ITEM_getItemPointer( itemindex)) == NULL ) return -1; + strcpysafe( itm->string[ITEM_WATCHFUNC].string, + sizeof(itm->string[ITEM_WATCHFUNC].string), "ITEM_DeleteTimeWatched" ); + + break; + }else{ + + return -1; + } + } +#endif + case OBJTYPE_GOLD: + { + + return -1; + } + case OBJTYPE_CHARA: + { + typedef BOOL (*ITEMPUTFUNC)(int,int); + ITEMPUTFUNC ipfunc; + ipfunc = (ITEMPUTFUNC)CHAR_getFunctionPointer( + OBJECT_getIndex(objindex),CHAR_ITEMPUTFUNC) ; + + if( ipfunc && ipfunc(OBJECT_getIndex(objindex), + itemindex) == TRUE) + return -3; + break; + } + default: + break; + } + } + + *objindex = CHAR_DropItemAbsolute( itemindex,fl,x,y, FALSE ); + + if( *objindex == -1 ) + return -3; + { + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), /* 失奶 丞 寞 */ +#endif + "Drop(丢出道具)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + + ); + } + return 0; + } +} + + +#ifdef _ITEM_PILENUMS //andy_edit 2003/04/01 + +void CHAR_SendDropItem_Stats( int charaindex, int itemindex, int itemcharaindex, int flg) +{ + if( flg == 1 ){ + CHAR_setItemIndex( charaindex, itemcharaindex , -1); + } + CHAR_sendItemDataOne( charaindex, itemcharaindex); + + if( CHAR_complianceParameter( charaindex ) ){ + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX)); + } + + if( 0 <= itemcharaindex && itemcharaindex < CHAR_STARTITEMARRAY && + CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ){ //如果丢弃物为装备 + if( ITEM_CHECKINDEX( itemindex) ) + CHAR_sendItemDetachEvent( charaindex, itemindex ); + + CHAR_send_P_StatusString( charaindex, + CHAR_P_STRING_HP|CHAR_P_STRING_MAXHP| + CHAR_P_STRING_MP|CHAR_P_STRING_MAXMP| + CHAR_P_STRING_ATK|CHAR_P_STRING_DEF| + CHAR_P_STRING_QUICK|CHAR_P_STRING_CHARM| + CHAR_P_STRING_LUCK|CHAR_P_STRING_EARTH| + CHAR_P_STRING_WATER|CHAR_P_STRING_FIRE| + CHAR_P_STRING_WIND ); + +#if 0 //#ifdef _ANGEL_SUMMON + if( ITEM_getInt( itemindex, ITEM_ID) == ANGELITEM ) { + print(" 卸下使者信物 "); + CHAR_setWorkInt( index, CHAR_WORKANGELMODE, FALSE); + CHAR_sendAngelMark( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), 0); + } +#endif + + } +} +#ifdef _DROPSTAKENEW +void CHAR_DropStakeByDropItem( int charaindex, int itemcharaindex, int itemindex, int fl, int x, int y) +{ + int j, k, casinoflag = 0, dropflag; + char tmpbuf[256]; + dropflag = CHAR_getWorkInt( charaindex, CHAR_WORKSTAKEFLAG); + if( dropflag >= MAXSTAKENUM){ + snprintf( tmpbuf, sizeof( tmpbuf), "你已经下注五次了,无法再下注!"); + CHAR_talkToCli(charaindex, -1, tmpbuf, CHAR_COLORYELLOW); + return; + } + for (j = 0; j < arraysizeof( casinomap); j++){ + if( CHAR_getInt( charaindex, CHAR_FLOOR) != casinomap[j].casinofl ) continue; + if( x != casinomap[j].casinox || y != casinomap[j].casinoy ) continue; + if( casinomap[j].dropflag == 0 ){ + CHAR_talkToCli( charaindex, -1, "现在无法下注!", CHAR_COLORYELLOW); + return; + }else{ + int objindex; + objindex = CHAR_DropItemAbsolute( itemindex, fl, x, y, FALSE ); + if( objindex == -1 ) return; + ITEM_setInt( itemindex, ITEM_PUTTIME, NowTime.tv_sec+30*60); + CHAR_sendWatchEvent( objindex, CHAR_ACTSTAND, NULL, 0, TRUE); + casinoflag = 1; + snprintf(tmpbuf, sizeof(tmpbuf), "你在 %s 下注了一张彩券", casinomap[j].casinoinfo); + for(k = 0; k < MAXSTAKENUM; k++){//下注设定 + if(CHAR_getWorkInt(charaindex, CHAR_WORKSTAKETYPE1 + k) != 0) continue; + CHAR_setWorkInt(charaindex, CHAR_WORKSTAKETYPE1 + k, casinomap[j].casinotype); + dropflag++; + break; + } + CHAR_talkToCli(charaindex, -1, tmpbuf, CHAR_COLORYELLOW); +#ifdef _FIX_GAMBLENUM + if (dropflag <= MAXSTAKENUM){ //做扣点的动作 + int nAcc = CHAR_getInt(charaindex, CHAR_GAMBLENUM); + nAcc -= casinomap[j].accumulation; + CHAR_setInt(charaindex, CHAR_GAMBLENUM, nAcc); + } +#endif + dropflag = ( dropflag >= MAXSTAKENUM )?MAXSTAKENUM:dropflag; + CHAR_setWorkInt(charaindex, CHAR_WORKSTAKEFLAG, dropflag); + break; + } + } + + if( casinoflag == 0) return; + LogItem(CHAR_getChar(charaindex, CHAR_NAME), + CHAR_getChar(charaindex, CHAR_CDKEY), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt(itemindex, ITEM_ID), +#endif + "StakeDrop(丢出彩券)", + CHAR_getInt(charaindex,CHAR_FLOOR), + CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y), + ITEM_getChar(itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + CHAR_SendDropItem_Stats( charaindex, itemindex, itemcharaindex, 1); + +} +#endif + +BOOL CHAR_FindAroundUsabilitySpace( int charaindex, int itemindex, int *fl, int *x, int *y) +{ + int dropx, dropy, i; + BOOL Find = FALSE; + int myfl = CHAR_getInt( charaindex, CHAR_FLOOR); + + for( i = 0 ; i < 8 ; i ++ ){ + OBJECT object; + Find = FALSE; + dropx = CHAR_getInt( charaindex, CHAR_X) + CHAR_getDX( CHAR_getInt( charaindex, CHAR_DIR) + i); + dropy = CHAR_getInt( charaindex, CHAR_Y) + CHAR_getDY( CHAR_getInt( charaindex, CHAR_DIR) + i); + if( MAP_walkAbleFromPoint( myfl, dropx, dropy, FALSE ) == FALSE ) continue; + for( object = MAP_getTopObj( myfl, dropx, dropy) ; object ; object = NEXT_OBJECT(object ) ){ + int objindex = GET_OBJINDEX(object); + if( !CHECKOBJECTUSE( objindex)) continue; + if( OBJECT_getType( objindex) == OBJTYPE_CHARA ){ + typedef BOOL (*ITEMPUTFUNC)(int,int); + ITEMPUTFUNC ipfunc; + ipfunc = (ITEMPUTFUNC)CHAR_getFunctionPointer( OBJECT_getIndex(objindex),CHAR_ITEMPUTFUNC) ; + if( ipfunc && ipfunc( OBJECT_getIndex( objindex), itemindex) == TRUE) + return FALSE; + }else{ + Find = TRUE; + break; + } + } + if( Find == FALSE ){ + *fl = myfl; + *x = dropx; + *y = dropy; + return TRUE; + } + } + return FALSE; +} + +void CHAR_DropItem( int charaindex, int itemcharaindex ) +{ + int itemindex, fl, x, y, ret, objindex, beDropOne = 1; + + if( !CHAR_CHECKINDEX( charaindex ) ) return; + + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ){ + CHAR_talkToCli( charaindex, -1, "战斗状态中无法丢道具装备。", CHAR_COLORYELLOW ); + return; + } +#ifdef _AVID_TRADETRYBUG //丢道具装备 + if( CHAR_getWorkInt(charaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE){ + CHAR_talkToCli( charaindex, -1, "交易状态中无法丢道具装备。", CHAR_COLORYELLOW ); + return; + } +#endif + + itemindex = CHAR_getItemIndex( charaindex, itemcharaindex); + if( !ITEM_CHECKINDEX( itemindex)) return; + + if( ITEM_getInt( itemindex, ITEM_ID) == CASINOTOKENID && + ( CHAR_getInt( charaindex, CHAR_FLOOR ) == 7008 || + CHAR_getInt( charaindex, CHAR_FLOOR ) == 7005 || + CHAR_getInt( charaindex, CHAR_FLOOR ) == 7003 ) ){ + + int dropx, dropy, dropfl; + dropfl = CHAR_getInt( charaindex, CHAR_FLOOR); + dropx = CHAR_getInt( charaindex, CHAR_X) + CHAR_getDX( CHAR_getInt( charaindex, CHAR_DIR)); + dropy = CHAR_getInt( charaindex, CHAR_Y) + CHAR_getDY( CHAR_getInt( charaindex, CHAR_DIR)); + CHAR_DropStakeByDropItem( charaindex, itemcharaindex, itemindex, dropfl, dropx, dropy); + return; + } + //找出周围空间 + if( CHAR_FindAroundUsabilitySpace( charaindex, itemindex, &fl, &x, &y) == FALSE ){ + CHAR_talkToCli( charaindex, -1, "周围的地面已经满了。", CHAR_COLORYELLOW ); + return; + } + +#ifdef _ITEM_PILENUMS + if( ITEM_getInt( itemindex, ITEM_CANBEPILE) == 1 && + ITEM_getInt( itemindex, ITEM_USEPILENUMS) > 1 ){ + int ret; + int nums = ITEM_getInt( itemindex, ITEM_USEPILENUMS); + ret = ITEM_makeItemAndRegist( ITEM_getInt( itemindex, ITEM_ID) ); + if( !ITEM_CHECKINDEX( ret)) return; + ITEM_setInt( itemindex, ITEM_USEPILENUMS, nums -1 ); + itemindex = ret; + beDropOne = 0; + } +#endif + //找到空间 + ret = ITEM_eventDrop( itemindex, charaindex, itemcharaindex ); + if( ret == 1 ){ //-1 物品不存在 1 消失 0 一般物品 + CHAR_SendDropItem_Stats( charaindex, itemindex, itemcharaindex, beDropOne); + return; + }else { + objindex = CHAR_DropItemAbsolute( itemindex, fl, x, y, FALSE ); + if( objindex == -1 ) return; + ITEM_setInt( itemindex, ITEM_PUTTIME, NowTime.tv_sec); + { + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), /* 失奶 丞 寞 */ +#endif + "Drop(丢出道具)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + CHAR_sendWatchEvent( objindex, CHAR_ACTSTAND, NULL, 0, TRUE); + } + CHAR_SendDropItem_Stats( charaindex, itemindex, itemcharaindex, beDropOne); +} +#else +void CHAR_DropItem( int charaindex, int itemcharaindex ) +{ + int dirx[9],diry[9]; + int i, j; + int floor, objindex=-1; + int droped =0; + int count_item =0, count_chara =0; + int fl, x, y; + int itemindex = CHAR_getItemIndex(charaindex,itemcharaindex); + + if( !CHAR_CHECKINDEX( charaindex ) ) return; + if( !ITEM_CHECKINDEX( itemindex) ) return; +#ifdef _AVID_TRADETRYBUG //丢道具装备 + if( CHAR_getWorkInt(charaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE){ + CHAR_talkToCli( charaindex, -1, "交易状态中无法丢道具装备。", CHAR_COLORYELLOW ); + return; + } +#endif + +#ifdef _DROPCHECK2 + fl = CHAR_getInt( charaindex, CHAR_FLOOR); + x = CHAR_getInt( charaindex, CHAR_X); + y = CHAR_getInt( charaindex, CHAR_Y); + + for( i = x-CHAR_DEFAULTSEESIZ/2 ; i <= x+CHAR_DEFAULTSEESIZ/2 ; i++ ){ + for( j = y-CHAR_DEFAULTSEESIZ/2 ; j <= y+CHAR_DEFAULTSEESIZ/2 ; j ++ ){ + OBJECT object; + for( object = MAP_getTopObj(fl,i,j); object ; object = NEXT_OBJECT(object ) ) { + int objindex = GET_OBJINDEX(object); + if( OBJECT_getType(objindex) == OBJTYPE_NOUSE ) continue; + if( OBJECT_getType(objindex) == OBJTYPE_ITEM || OBJECT_getType(objindex) == OBJTYPE_GOLD ) { + count_item++; + } + if( OBJECT_getType(objindex) == OBJTYPE_CHARA ) { + count_chara++; + } + } + } + +#ifdef _DROPSTAKENEW + if(ITEM_getInt(itemindex, ITEM_ID) == CASINOTOKENID){ + int k = 0; + int casinodropflag = 0; + for(k = 0; k < arraysizeof(casinomap); k++){ + if(fl == casinomap[k].casinofl){ + if(x >= casinomap[k].casinox - 1 && x <= casinomap[k].casinox + 1){ + if(y >= casinomap[k].casinoy - 1 && y <= casinomap[k].casinoy + 1){ + casinodropflag = 1; + break; + } + } + } + } + if(casinodropflag == 0){ +#endif + if( count_item > 80 || count_chara > 80 ) { + CHAR_talkToCli( charaindex, -1, "这里的物品已经太多了,不能再丢了。", CHAR_COLORYELLOW ); + return; + } +#ifdef _DROPSTAKENEW + } + } +#endif + } +#endif + + for( i = 1 ; i < 8 ; i ++ ){ + dirx[i] = CHAR_getDX(CHAR_getInt(charaindex,CHAR_DIR) + i); + diry[i] = CHAR_getDY(CHAR_getInt(charaindex,CHAR_DIR) + i); + } + dirx[0] = CHAR_getDX(CHAR_getInt(charaindex,CHAR_DIR)); + diry[0] = CHAR_getDY(CHAR_getInt(charaindex,CHAR_DIR)); + dirx[8] = 0; + diry[8] = 0; + floor = CHAR_getInt( charaindex,CHAR_FLOOR ); + { + int ret; + if( 0 <= itemcharaindex && itemcharaindex < CHAR_STARTITEMARRAY ){ //如果丢弃物为装备 + CHAR_sendItemDetachEvent( charaindex, itemindex ); + } + ret = ITEM_eventDrop( itemindex, charaindex, itemcharaindex ); + if( ret == 1 ){ //-1 物品不存在 1 消失 0 一般物品 + itemindex = -1; + goto END; + }else if( ret == -1 ){ + print( "%s:%d err\n", __FILE__,__LINE__); + return; + }else{ + ; + } + } +#ifdef _MARKET_TRADE + { + int user_floor = CHAR_getInt( charaindex, CHAR_FLOOR); + int item_x = CHAR_getInt( charaindex, CHAR_X)+dirx[0]; + int item_y = CHAR_getInt( charaindex, CHAR_Y)+diry[0]; + if( MAP_TRADEDROP( charaindex, itemindex, user_floor, item_x, item_y) == TRUE ) { + return; + } + } +#endif + droped = 0; + for( i = 0 ; i < 9 ; i ++ ){ + int x=CHAR_getInt(charaindex,CHAR_X)+dirx[i]; + int y=CHAR_getInt(charaindex,CHAR_Y)+diry[i]; +#ifdef _DROPSTAKENEW + // 判断物品是否为彩券 + if(ITEM_getInt(itemindex, ITEM_ID) == CASINOTOKENID){ + int j = 0, k = 0; + int bdropstake = 0; + int casinoflag = 0; + for (j = 0; j < arraysizeof(casinomap); j++){ + if (CHAR_getInt(charaindex, CHAR_FLOOR) == casinomap[j].casinofl){ + if (x == casinomap[j].casinox && y == casinomap[j].casinoy){ + char tmpbuf[256]; + int dropflag = CHAR_getWorkInt(charaindex, CHAR_WORKSTAKEFLAG); + casinoflag = 1; + if(casinomap[j].dropflag == 0){ + CHAR_talkToCli(charaindex, -1, "现在无法下注!", CHAR_COLORYELLOW); + return; + }else{ + snprintf(tmpbuf, sizeof(tmpbuf), "你在 %s 下注了一张彩券", casinomap[j].casinoinfo); + if(dropflag >= MAXSTAKENUM){ + snprintf(tmpbuf, sizeof(tmpbuf), "你已经下注五次了,无法再下注!"); + CHAR_talkToCli(charaindex, -1, tmpbuf, CHAR_COLORYELLOW); + return; + } + for(k = 0; k < MAXSTAKENUM; k++){ + if(CHAR_getWorkInt(charaindex, CHAR_WORKSTAKETYPE1 + k) == 0){ + CHAR_setWorkInt(charaindex, CHAR_WORKSTAKETYPE1 + k, casinomap[j].casinotype); + casinomap[j].stakenum = casinomap[j].stakenum + 1; + if(casinomap[j].stakenum >= 100000000) + casinomap[j].stakenum = 100000000; + dropflag++; + if(casinomap[j].stakenum <= 1) + bdropstake = 1; + break; + } + } + } + CHAR_talkToCli(charaindex, -1, tmpbuf, CHAR_COLORYELLOW); +#ifdef _FIX_GAMBLENUM + //做扣点的动作 + if (dropflag <= MAXSTAKENUM){ + int nAcc = CHAR_getInt(charaindex, CHAR_GAMBLENUM); + nAcc -= casinomap[j].accumulation; + CHAR_setInt(charaindex, CHAR_GAMBLENUM, nAcc); + } +#endif + if (dropflag >= MAXSTAKENUM){ + dropflag = 0; + for (k = 0; k < MAXSTAKENUM ; k++){ + if (CHAR_getWorkInt(charaindex, CHAR_WORKSTAKETYPE1 + k) > 0) + dropflag++; + } + CHAR_setWorkInt(charaindex, CHAR_WORKSTAKEFLAG, dropflag); + }else{ + CHAR_setWorkInt(charaindex, CHAR_WORKSTAKEFLAG, dropflag); + } + continue; + } + } + } + + // 此地方的彩券数量超过一张以上 + if(bdropstake == 0 && casinoflag != 0){ + CHAR_setItemIndex(charaindex, itemcharaindex ,-1); + CHAR_sendItemDataOne(charaindex, itemcharaindex); + LogItem(CHAR_getChar(charaindex, CHAR_NAME), + CHAR_getChar(charaindex, CHAR_CDKEY), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt(itemindex, ITEM_ID), +#endif + "StakeDrop(丢出彩券)", + CHAR_getInt(charaindex,CHAR_FLOOR), + CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y), + ITEM_getChar(itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + + ); + return; + } + } +#endif + { + int ret = CHAR_DropItemFXY( charaindex,itemcharaindex, + CHAR_getInt(charaindex,CHAR_FLOOR), x, y, &objindex ); + switch( ret ){ + case 0: + droped = 1; +#ifdef _ITEM_ORNAMENTS // WON FIX + if( ITEM_getWorkInt( itemindex, ITEM_CANPICKUP) > 0 ){ + ITEM_setInt( itemindex, ITEM_PUTTIME, NowTime.tv_sec + 60*5); + }else{ + ITEM_setInt( itemindex, ITEM_PUTTIME, NowTime.tv_sec); + } +#else + ITEM_setInt( itemindex, ITEM_PUTTIME, NowTime.tv_sec); +#endif + goto END; + break; + case -1: + case -2: + break; + case -3: + default: + return; + break; + } +#ifdef _DROPSTAKENEW + } +#endif + } +#ifdef _DROPCHECK + if( droped != 1 ) { + CHAR_talkToCli( charaindex, -1, "周围的地面已经满了。", CHAR_COLORYELLOW ); + return; + } +#endif +END: + CHAR_sendWatchEvent( objindex, CHAR_ACTSTAND, NULL, 0, TRUE); + CHAR_setItemIndex( charaindex, itemcharaindex ,-1); +{ + char category[3]; + snprintf( category,sizeof( category),"J%d", itemcharaindex); + CHAR_sendStatusString( charaindex , category); +} + if( CHAR_complianceParameter( charaindex ) ){ + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX) ); + } + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + CHAR_send_P_StatusString( charaindex, + CHAR_P_STRING_HP|CHAR_P_STRING_MAXHP| + CHAR_P_STRING_MP|CHAR_P_STRING_MAXMP| + CHAR_P_STRING_ATK|CHAR_P_STRING_DEF| + CHAR_P_STRING_QUICK|CHAR_P_STRING_CHARM| + CHAR_P_STRING_LUCK|CHAR_P_STRING_EARTH| + CHAR_P_STRING_WATER|CHAR_P_STRING_FIRE| + CHAR_P_STRING_WIND + ); + CHAR_sendItemDataOne( charaindex, itemcharaindex); + } + return; +} +#endif + +int CHAR_DropItemAbsolute( int itemindex, int floor, int x, int y, + BOOL net) +{ + Object object; + int objindex; + + if( !ITEM_CHECKINDEX( itemindex) )return FALSE; + + object.type = OBJTYPE_ITEM; + object.index = itemindex; + object.x = x; + object.y = y; + object.floor = floor; + objindex = initObjectOne( &object ); + ITEM_setWorkInt( itemindex,ITEM_WORKOBJINDEX, objindex ); + ITEM_setWorkInt( itemindex,ITEM_WORKCHARAINDEX, -1 ); + if( net ) + CHAR_sendWatchEvent( objindex,CHAR_ACTSTAND,NULL,0,TRUE); + + return objindex; +} + +int CHAR_addItemSpecificItemIndex( int charaindex, int itemindex ) +{ + int emptyindex; + if( CHAR_CHECKINDEX( charaindex) == FALSE) return -1; + if( ITEM_CHECKINDEX( itemindex) == FALSE) return -1; + emptyindex = CHAR_findEmptyItemBox( charaindex ); + if( emptyindex == -1 ){ + return CHAR_MAXITEMHAVE; + }else{ + CHAR_setItemIndex(charaindex,emptyindex,itemindex); + ITEM_setWorkInt(itemindex,ITEM_WORKCHARAINDEX,charaindex); + ITEM_setWorkInt(itemindex,ITEM_WORKOBJINDEX,-1); + } + return emptyindex; +} + +static int CHAR_PickUpItemFXY( int charaindex, int fl ,int x , int y , + int* contents,int* objindex ) +{ + OBJECT object; + + for( object=MAP_getTopObj(fl,x,y) ; object ; object = NEXT_OBJECT(object ) ){ + int index = GET_OBJINDEX(object); + int objtype = OBJECT_getType(index); + if( objtype == OBJTYPE_NOUSE )continue; + else if( objtype == OBJTYPE_ITEM ){ + int ret; + int itemindex = OBJECT_getIndex( index); +#ifdef _MARKET_TRADE //买 + if( ITEM_getWorkInt( itemindex, ITEM_WORKTRADETYPE) == TRADETYPE_SELL ) { + MAP_TRADEPICKUP( charaindex, itemindex, fl, x, y, TRADEITEMTYPE); + return -1; + } +#endif +#ifdef _ITEM_ORNAMENTS + if( ITEM_getWorkInt( itemindex, ITEM_CANPICKUP) > 0 ){ + return -1; + } +#endif +#ifdef _DROPSTAKENEW + // 判断物品是否为彩券 + if(ITEM_getInt(itemindex, ITEM_ID) == CASINOTOKENID){ + int i = 0; + int bdropstake = 0, casinoflag = 0, emptyitemindexinchara = -1; + for(i = 0; i < arraysizeof(casinomap); i++){ + if(fl == casinomap[i].casinofl){ + if(x == casinomap[i].casinox && y == casinomap[i].casinoy){ + int j = 0, stakeflag = 0; + int pickupflag = 0; + casinoflag = 1; + if(casinomap[i].dropflag == 0){ + CHAR_talkToCli(charaindex, -1, "现在已经无法取回下注彩券了!", CHAR_COLORYELLOW); + return -1; + } + stakeflag = CHAR_getWorkInt(charaindex, CHAR_WORKSTAKEFLAG); + if(stakeflag == 0){ + CHAR_talkToCli(charaindex, -1, "您并没有下注,所以无法取回彩券!", CHAR_COLORYELLOW); + return -1; + } + for(j = 0; j < MAXSTAKENUM; j++){ + if(CHAR_getWorkInt(charaindex, CHAR_WORKSTAKETYPE1 + j) == casinomap[i].casinotype){ + emptyitemindexinchara = CHAR_findEmptyItemBox(charaindex); + if(emptyitemindexinchara < 0) return -2; + CHAR_setWorkInt(charaindex, CHAR_WORKSTAKETYPE1 + j, 0); + casinomap[i].stakenum = casinomap[i].stakenum - 1; + stakeflag--; + pickupflag = 1; +#ifdef _FIX_GAMBLENUM + //做加点的动作 + { + int nAcc = CHAR_getInt(charaindex, CHAR_GAMBLENUM); + nAcc += casinomap[i].accumulation; + CHAR_setInt(charaindex, CHAR_GAMBLENUM, nAcc); + } +#endif + if(casinomap[i].stakenum <= 0){ + bdropstake = 1; + casinomap[i].stakenum = 0; + } + break; + } + } + if(stakeflag < 0){ + stakeflag = 0; + for(j = 0; j < MAXSTAKENUM; j++){ + if(CHAR_getWorkInt(charaindex, CHAR_WORKSTAKETYPE1 + j) > 0) + stakeflag++; + } + CHAR_setWorkInt(charaindex, CHAR_WORKSTAKEFLAG, stakeflag); + }else + CHAR_setWorkInt(charaindex, CHAR_WORKSTAKEFLAG, stakeflag); + if(pickupflag == 0){ + CHAR_talkToCli(charaindex, -1, "您没有在此下注,所以无法取回彩券!", CHAR_COLORYELLOW); + return -1; + } + } + } + } + + if(bdropstake == 0 && casinoflag != 0){// 此地方的彩券数量超过一张以上 + char tmpbuf[256]; + if(emptyitemindexinchara != -1){ + int itemid=-1, ret=-1; + itemid = ITEM_makeItemAndRegist(CASINOTOKENID); + if(itemid == -1) return -1; + ret = CHAR_addItemSpecificItemIndex( charaindex, itemid); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + ITEM_endExistItemsOne( itemid ); + return -1; + } + } + CHAR_sendItemDataOne(charaindex, emptyitemindexinchara); + snprintf(tmpbuf, sizeof(tmpbuf), "拾回%s,已将下注取消!", + ITEM_getChar(itemindex, ITEM_NAME)); + CHAR_talkToCli(charaindex, -1, tmpbuf, CHAR_COLORWHITE); + // 记录捡回记录 + LogItem(CHAR_getChar(charaindex, CHAR_NAME), + CHAR_getChar(charaindex, CHAR_CDKEY), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt(itemindex, ITEM_ID), +#endif + "StakePickUp(捡起彩券)", + CHAR_getInt(charaindex,CHAR_FLOOR), + CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y), + ITEM_getChar(itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + return -1; + } + } +#endif + ret = CHAR_addItemSpecificItemIndex( charaindex, itemindex ); + if(ret == CHAR_MAXITEMHAVE ){ + return -2; + }else if( ret != -1 ) { + typedef void (*PICKUPFUNC)( int, int); + PICKUPFUNC pickupfunc = NULL; + pickupfunc = (PICKUPFUNC)ITEM_getFunctionPointer( + itemindex, ITEM_PICKUPFUNC); + if( pickupfunc) pickupfunc( charaindex, itemindex); + + *contents = OBJECT_getIndex(index); + *objindex = index; + CHAR_sendItemDataOne( charaindex, ret); + return 0; + } + }else if( objtype == OBJTYPE_GOLD ){ + int MaxGold; + long dropgoldamount = 0, newamountgold = 0, Minus = 0, newgold = 0; + long mygold = (long) CHAR_getInt( charaindex, CHAR_GOLD ); + MaxGold = CHAR_getMaxHaveGold( charaindex); + if ((mygold <0) || (mygold > MaxGold))return -2; + dropgoldamount = OBJECT_getIndex(index); + newamountgold = (unsigned int) CHAR_getInt( charaindex,CHAR_GOLD ) + dropgoldamount; + Minus = newamountgold - MaxGold; + if( Minus > 0 ) { + newgold = Minus; + *contents = dropgoldamount - Minus; + }else { + newgold = 0; + *contents = dropgoldamount; + } + OBJECT_setIndex( index, newgold); + CHAR_setInt( charaindex, CHAR_GOLD, min( newamountgold, MaxGold ) ); + *objindex = index; + return 1; + }else if( objtype == OBJTYPE_CHARA ) { + int pindex = OBJECT_getIndex( index); + if( !CHAR_CHECKINDEX( pindex) ) continue; + if( CHAR_getInt( pindex, CHAR_WHICHTYPE) == CHAR_TYPEPET ) { + int havepetindex = CHAR_getCharPetElement( charaindex); + if( havepetindex == -1 ) { + if( CHAR_getWorkInt( pindex, CHAR_WORKPETFOLLOWMODE) != CHAR_PETFOLLOW_NOW ) + return -3; + } + if( CHAR_getWorkInt( charaindex, CHAR_PickAllPet) != TRUE ) { + if( (CHAR_getInt( pindex, CHAR_LV) - CHAR_getInt( charaindex, CHAR_LV) > 5 ) + && (CHAR_getInt( charaindex, CHAR_TRANSMIGRATION ) <= 0 )) { + return -4; + } + } + /*if( !strcmp( CHAR_getChar( pindex, CHAR_OWNERCDKEY), "SYSTEM_WAYI" ) && + !strcmp( CHAR_getChar( pindex, CHAR_OWNERCHARANAME), "SYSTEM_WAYI" ) ){ + }else{ + if( strcmp( CHAR_getChar( pindex, CHAR_OWNERCDKEY), CHAR_getChar( charaindex, CHAR_CDKEY) ) || + strcmp( CHAR_getChar( pindex, CHAR_OWNERCHARANAME), CHAR_getChar( charaindex, CHAR_NAME) )){ + return -5; + } + }*/ +#ifdef _MARKET_TRADE + if( CHAR_getWorkInt( pindex, CHAR_WORKTRADETYP) == TRADETYPE_SELL ) { //买宠 + MAP_TRADEPICKUP( charaindex, pindex, fl, x, y, TRADEPETTYPE ); + return -1; + } +#endif + if( CHAR_getWorkInt( pindex, CHAR_WORKPETFOLLOWMODE) == CHAR_PETFOLLOW_NOW ){ + CHAR_pickupFollowPet( charaindex, pindex ); + return -1; + } + if( CHAR_getInt( pindex, CHAR_MAILMODE) != CHAR_PETMAIL_NONE){ + if( strcmp( CHAR_getChar( pindex, CHAR_OWNERCDKEY), + CHAR_getChar( charaindex, CHAR_CDKEY)) != 0 || + strcmp( CHAR_getChar( pindex, CHAR_OWNERCHARANAME), + CHAR_getChar( charaindex, CHAR_NAME))!= 0 ){ + return -5; + }else if( CHAR_getInt( pindex, CHAR_MAILMODE) != CHAR_PETMAIL_IDLE5){ + return -5; + } + } + if( CHAR_getInt( pindex, CHAR_MAILMODE) != CHAR_PETMAIL_NONE){ + Char *ch; + CHAR_setInt( pindex, CHAR_MAILMODE, CHAR_PETMAIL_NONE); + CHAR_setInt( pindex, CHAR_PETMAILIDLETIME, 0); + PETMAIL_delPetMailTotalnums( 1); //手动捡起mail PET + ch = CHAR_getCharPointer( pindex); + if( ch != NULL ) { + strcpysafe( ch->charfunctable[CHAR_LOOPFUNC].string, + sizeof( ch->charfunctable[CHAR_LOOPFUNC]), ""); + CHAR_constructFunctable( pindex); + } + } + CHAR_setWorkInt( pindex, CHAR_WORKPLAYERINDEX, charaindex); + CHAR_setCharPet( charaindex, havepetindex, pindex); +#ifdef _PET_TALK + if( CHAR_getInt( pindex, CHAR_PETID) != 718 ) { +#endif + CHAR_setChar( pindex, CHAR_OWNERCDKEY, + CHAR_getChar( charaindex, CHAR_CDKEY)); + CHAR_setChar( pindex, CHAR_OWNERCHARANAME, + CHAR_getChar( charaindex, CHAR_NAME)); +#ifdef _PET_TALK + } +#endif + CHAR_complianceParameter( pindex); +{ + char category[3]; + snprintf( category,sizeof( category),"K%d",havepetindex); + CHAR_sendStatusString( charaindex, category); + snprintf( category,sizeof( category),"W%d",havepetindex); + CHAR_sendStatusString( charaindex, category); +} + CHAR_setInt( pindex, CHAR_PUTPETTIME, 0); + *contents = pindex; + *objindex = index; + return 2; + } + } + } + return -1; +} + +void CHAR_PickUpItem( int charaindex, int dir ) +{ + int i; + int dirx[2],diry[2]; + int searchloopcount=0; + + if( !CHAR_CHECKINDEX(charaindex) )return; + if( CHAR_getFlg( charaindex,CHAR_ISDIE ) )return; + if( CHAR_getWorkInt( charaindex,CHAR_WORKBATTLEMODE ) )return; + if( dir < 0 ){ + searchloopcount = 1; + dirx[0] = 0; + diry[0] = 0; + }else{ + if( dir != CHAR_getInt( charaindex, CHAR_DIR)) { + VALIDATEDIR(dir); + CHAR_setInt(charaindex,CHAR_DIR,dir); + CHAR_sendWatchEvent(CHAR_getWorkInt(charaindex,CHAR_WORKOBJINDEX), + CHAR_ACTSTAND,NULL,0,FALSE); + } + dirx[0] = CHAR_getDX(CHAR_getInt(charaindex,CHAR_DIR)); + diry[0] = CHAR_getDY(CHAR_getInt(charaindex,CHAR_DIR)); + dirx[1] = 0; + diry[1] = 0; + searchloopcount=2; + } + for( i = 0 ; i < searchloopcount ; i ++ ){ + int contents,objindex; + int fl = CHAR_getInt(charaindex,CHAR_FLOOR); + + int y = CHAR_getInt(charaindex,CHAR_Y)+diry[i]; + int x = CHAR_getInt(charaindex,CHAR_X)+dirx[i]; + int ret = CHAR_PickUpItemFXY( charaindex,fl,x,y,&contents, + &objindex); + switch( ret ){ + case 0: + CHAR_ObjectDelete(objindex); + { + char mesg[256]; +#ifdef _DROPSTAKENEW + int j = 0; + int dropflag = 0; + for(j = 0; j < arraysizeof(casinomap); j++) + { + if(CHAR_getInt(charaindex, CHAR_FLOOR) == casinomap[j].casinofl) + { + if(x == casinomap[j].casinox && y == casinomap[j].casinoy) + { + dropflag = 1; + break; + } + } + } + if(ITEM_getInt(contents, ITEM_ID) == CASINOTOKENID && dropflag == 1) + snprintf( mesg,sizeof(mesg), "拾回%s,已将下注取消!", + ITEM_getAppropriateName(contents)); + else +#endif + snprintf( mesg,sizeof(mesg), "拾获 %s", + ITEM_getAppropriateName(contents) ); + CHAR_talkToCli(charaindex,-1,mesg,CHAR_COLORWHITE); + } + + { + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + contents, +#else + ITEM_getInt(contents, ITEM_ID), +#endif + "PickUp(捡起道具)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( contents, ITEM_UNIQUECODE), + ITEM_getChar( contents, ITEM_NAME), + ITEM_getInt( contents, ITEM_ID) + ); + } + + return; + break; + case 1: + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_GOLD); + + if( OBJECT_getIndex( objindex) == 0 ) { + CHAR_ObjectDelete(objindex); + }else { + CHAR_sendWatchEvent(objindex,CHAR_ACTSTAND,NULL,0,TRUE); + } + { + char mesg[256]; + if( contents == 0 ) { + snprintf( mesg,sizeof(mesg), "无法再拾获Stone了。" ); + }else { + snprintf( mesg,sizeof(mesg), "拾获 %d Stone",contents ); + } + CHAR_talkToCli(charaindex,-1,mesg,CHAR_COLORWHITE); + } + if( contents != 0 ){ + LogStone( + -1, + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), + contents, + CHAR_getInt( charaindex, CHAR_GOLD ), + "PickUp(拾获金钱)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ) + ); + } + return; + break; + case 2: //宠物 + CHAR_ObjectDelete(objindex); + CHAR_setWorkInt( contents, CHAR_WORKOBJINDEX, -1); + { + char mesg[256]; + char *p = NULL; + p = CHAR_getChar( contents, CHAR_USERPETNAME); + if( strlen( p) == 0 ) { + p = CHAR_getChar( contents, CHAR_NAME); + } + + snprintf( mesg,sizeof(mesg), "拾获 %s", p); + CHAR_talkToCli(charaindex,-1,mesg,CHAR_COLORWHITE); + } + // 矢永玄毛胶匀凶夫弘 + LogPet( + CHAR_getChar( charaindex, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( charaindex, CHAR_CDKEY ), + CHAR_getChar( contents, CHAR_NAME), + CHAR_getInt( contents, CHAR_LV), + "PickUp(捡宠)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + CHAR_getChar( contents, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + return; + break; + // Robin 0701 petFollow + case 3: + + /* 引歹曰卞仇木毛壅六午中丹 */ + CHAR_ObjectDelete(objindex); + CHAR_setWorkInt( contents, CHAR_WORKOBJINDEX, -1); + { + char mesg[256]; + char *p = NULL; + p = CHAR_getChar( contents, CHAR_USERPETNAME); + if( strlen( p) == 0 ) { + p = CHAR_getChar( contents, CHAR_NAME); + } + + snprintf( mesg,sizeof(mesg), "拾回 %s", p); + CHAR_talkToCli(charaindex,-1,mesg,CHAR_COLORWHITE); + } + // 矢永玄毛胶匀凶夫弘 + LogPet( + CHAR_getChar( charaindex, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( charaindex, CHAR_CDKEY ), + CHAR_getChar( contents, CHAR_NAME), + CHAR_getInt( contents, CHAR_LV), + "FollowPickUp(收回溜宠)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + CHAR_getChar( contents, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + + return; + break; + case -1: + break; + case -2: + CHAR_talkToCli( charaindex,-1,"道具栏已满。", CHAR_COLORYELLOW); + break; + case -3: + CHAR_talkToCli( charaindex,-1,"宠物数已满。", CHAR_COLORYELLOW); + break; + case -4: + CHAR_talkToCli( charaindex,-1,"无法照顾该宠物。", CHAR_COLORYELLOW); + break; + case -5: + CHAR_talkToCli( charaindex,-1,"无法拾获该宠物。", CHAR_COLORYELLOW); + break; + case -6: + CHAR_talkToCli( charaindex,-1,"无法拾获该道具。", CHAR_COLORYELLOW); + break; + default: + return; + } + } + return; +} + +/*------------------------------------------------------------ + * 云嗯毛甄 隙烂匹 公丹午允月[CHAR_DropMoney井日及心匹银丹仪[ + * 娄醒 + * charaindex int 平乓仿奶件犯永弁旦 + * itemindex int 失奶 丞奶件犯永弁旦(平乓仿犯□正及 匹及) + * fl int 白夫失 + * x int x + * y int y + * force BOOL 仇及袄互恳分午 泫 允 + * objindex int* 中凶失奶 丞及 Object 匹及奶件犯弁永旦 + * 忒曰袄 + * 撩 (公氏卅卞云嗯毛 匀化中卅中) -1 + * 撩 (哗溥读卞分户) -2 + * 公木动陆及撩 -3 + * 撩 (公仇卞反公及汹及云嗯反聂允亢月) -4 + * 允匹卞职及失奶 丞互 切化中月 -5 + * 汹互 匹 [ -6 + * 岳 0 + ------------------------------------------------------------*/ +static BOOL CHAR_DropMoneyFXY( int charaindex, int amount, int fl , int x, + int y, BOOL force, int* objindex ) +{ + OBJECT object; + int MaxGold; + int mygold = CHAR_getInt( charaindex, CHAR_GOLD ); + if( amount <= 0 )return -6; + if( amount > mygold ) + return -1; + + MaxGold = CHAR_getMaxHaveGold( charaindex); + if ((mygold <0) || (mygold > MaxGold)) return -1; + + if( MAP_walkAbleFromPoint( fl,x,y,FALSE ) == FALSE )return -2; + for( object=MAP_getTopObj(fl,x,y) ; object; + object = NEXT_OBJECT(object) ){ + int index = GET_OBJINDEX(object); + int objtype = OBJECT_getType(index); + + if( objtype == OBJTYPE_NOUSE ) continue; + else if( objtype == OBJTYPE_GOLD ){ + long tmpamount = OBJECT_getIndex(index) + amount; + if( tmpamount > MaxGold ) + return -4; + OBJECT_setIndex(index,tmpamount); + CHAR_setInt(charaindex,CHAR_GOLD, + (unsigned int)CHAR_getInt(charaindex, + CHAR_GOLD ) + - amount ); + *objindex = index; +#ifdef _DEL_DROP_GOLD + OBJECT_setTime( index, NowTime.tv_sec); +#endif + if( amount >= 100 ){ /* 云嗯毛 中凶夫弘 */ + LogStone(-1,CHAR_getChar( charaindex, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( charaindex, CHAR_CDKEY ), /* 交□扒□ID */ + amount, /* 嗯喊 */ + CHAR_getInt( charaindex, CHAR_GOLD ), + "Drop(放置金钱)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ) + ); + } + return 0; + }else if( objtype == OBJTYPE_ITEM ){ + if( force==TRUE ) + continue; + else + /* 允匹卞失奶 丞互丐月及匹分户 */ + return -5; + } + } + + /* 仇仇引匹谗琼允月午中丹仪反蕙筋瓒 允月 */ + { + Object one; + one.type = OBJTYPE_GOLD; + one.x = x; + one.y = y; + one.floor = fl; + + if( amount > MaxGold ) + return -4; + + one.index = amount; + *objindex = initObjectOne( &one ); + /* 左皮斥尼弁玄瓒 允月 */ + if( *objindex == -1 ) + /* 瓒 撩 */ + return -3; + + /*云嗯毛蛹日允*/ + CHAR_setInt(charaindex,CHAR_GOLD, + (unsigned int)CHAR_getInt(charaindex,CHAR_GOLD ) + - amount ); +#ifdef _DEL_DROP_GOLD + OBJECT_setTime( *objindex, NowTime.tv_sec); +#endif + if( amount >= 100 ){ /* 云嗯毛 中凶夫弘 */ + LogStone(-1,CHAR_getChar( charaindex, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( charaindex, CHAR_CDKEY ), /* 交□扒□ID */ + amount, /* 嗯喊 */ + CHAR_getInt( charaindex, CHAR_GOLD ), + "Drop(放置金钱)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ) + ); + } + return 0; + } +} + +/*------------------------------------------------------------ + * 云嗯毛 允楮醒[ 及蟆井日 允[ + * 娄醒 + * charaindex int 平乓仿奶件犯永弁旦 + * amount int 云嗯及汹 + * + * 忒曰袄 + * 卅仄 + ------------------------------------------------------------*/ +void CHAR_DropMoney( int charaindex, int amount ) +{ + int dirx[9],diry[9]; + int ret; + int i; + int objindex, MaxGold; + + if( !CHAR_CHECKINDEX( charaindex ) )return; + +#ifdef _AVID_TRADETRYBUG //丢出石币 + if( CHAR_getWorkInt( charaindex, CHAR_WORKTRADEMODE) == CHAR_TRADE_TRADING ){ + CHAR_talkToCli( charaindex, -1, "交易状态中无法丢出石币。", CHAR_COLORYELLOW ); + return; + } +#endif + + MaxGold = CHAR_getMaxHaveGold( charaindex); + if( CHAR_getFlg( charaindex,CHAR_ISDIE ) )return; + + //ANDY_ADD 12/28 + { + int money=0; + money = CHAR_getInt( charaindex, CHAR_GOLD ); + if( money < 0 ) { + CHAR_setInt( charaindex, CHAR_GOLD, 0); + return; + } + if( (amount > money) || (money > MaxGold)) { + if( money > MaxGold ) { + CHAR_setInt( charaindex, CHAR_GOLD, 0 ); + print("\n ERR: %s(stone%d) dropMoney%d > CHAR_MAXGOLDHAVE !!", + CHAR_getChar(charaindex, CHAR_CDKEY), money, amount); + }else { + print("\n ERR: %s dropMoney > CHAR_GOLD !!", CHAR_getChar(charaindex, CHAR_CDKEY)); + } + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_GOLD); + return; + } + } + //ANDY_END + for( i = 0 ; i < 7 ; i ++ ){ + dirx[i+2] = CHAR_getDX( CHAR_getInt(charaindex,CHAR_DIR) + i+1 ); + diry[i+2] = CHAR_getDY( CHAR_getInt(charaindex,CHAR_DIR) + i+1 ); + } + + dirx[0] = CHAR_getDX(CHAR_getInt(charaindex,CHAR_DIR)); + diry[0] = CHAR_getDY(CHAR_getInt(charaindex,CHAR_DIR)); + dirx[1] = 0; + diry[1] = 0; + + for( i = 0 ; i < 9 ; i ++ ){ + int x = CHAR_getInt(charaindex,CHAR_X) + dirx[i]; + int y = CHAR_getInt(charaindex,CHAR_Y) + diry[i]; + +// CoolFish 2002/04/06 下注处不可丢置石币 +#ifdef _DROPSTAKENEW + { + int j = 0; + for(j = 0; j < arraysizeof(casinomap); j++) + { + if(CHAR_getInt(charaindex, CHAR_FLOOR) == casinomap[j].casinofl) + { + if (x == casinomap[j].casinox && y == casinomap[j].casinoy) + { + CHAR_talkToCli(charaindex, -1, "这里不能放置石币!", CHAR_COLORYELLOW); + return; + } + } + } + } +#endif + ret = CHAR_DropMoneyFXY( charaindex,amount, + CHAR_getInt(charaindex,CHAR_FLOOR), + x,y, FALSE, &objindex ); + switch( ret ){ + case 0: + goto END; + break; + case -1: + return; + break; + case -3: + return; + break; + case -2: + case -4: + case -5: + case -6: + break; + default: + break; + } + } + + { + int x = CHAR_getInt(charaindex,CHAR_X) + dirx[1]; + int y = CHAR_getInt(charaindex,CHAR_Y) + diry[1]; + + ret = CHAR_DropMoneyFXY( charaindex,amount, + CHAR_getInt(charaindex,CHAR_FLOOR), + x,y, TRUE, &objindex ); + switch( ret ){ + case 0: + goto END; + break; + case -1: + break; + case -3: + return; + break; + case -2: + case -4: + case -5: + break; + default: + break; + } + return; + } + +END: + CHAR_sendWatchEvent(objindex,CHAR_ACTSTAND,NULL,0,TRUE ); + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_GOLD); + return; +} + +static int CHAR_findEmptyItemBoxNoFromChar( Char* ch ) +{ + int i, j=0;; + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE ; i ++ ){ + int itemindex; + itemindex = ch->indexOfExistItems[i]; + if( itemindex == -1 ) j++; + } + return j; +} + +int CHAR_findEmptyItemBoxNo( int index ) +{ + Char* ch; + + if( !CHAR_CHECKINDEX( index ) )return -1; + ch = CHAR_getCharPointer(index); + if( ch != NULL ) + return CHAR_findEmptyItemBoxNoFromChar( ch ); + else + return -1; + +} + +// CoolFish: Trade 2001/4/4 +int CHAR_findTotalEmptyItem( int index ) +{ + int i, totaleptitem = 0; + Char* ch; + + if( !CHAR_CHECKINDEX( index ) )return -1; + ch = CHAR_getCharPointer(index); + if( ch != NULL ){ + for (i = CHAR_STARTITEMARRAY; i < CHAR_MAXITEMHAVE; i++){ + int itemindex = 0; + itemindex = ch->indexOfExistItems[i]; + if (itemindex == -1) totaleptitem++; + } + return totaleptitem; + } + + return -1; +} + +// Robin 0707 petFollow +int CHAR_pickupFollowPet( int charaindex, int pickupindex ) +{ + int petindex; + int objindex; + int havepetindex; + char category[3]; + + if( !CHAR_CHECKINDEX( charaindex ) ) return FALSE; + + if( pickupindex != -1 ) + petindex = pickupindex; + else + petindex = CHAR_getWorkInt( charaindex, CHAR_WORKPETFOLLOW ); + + if( !CHAR_CHECKINDEX( petindex ) ) + { + CHAR_setWorkInt( charaindex, CHAR_WORKPETFOLLOW, -1 ); + return FALSE; + } + + havepetindex = CHAR_getCharPetElement( charaindex); + if( havepetindex == -1 ) { + CHAR_talkToCli(charaindex,-1,"宠物栏已满!无法拾回!",CHAR_COLORYELLOW); + return FALSE; + } + + objindex = CHAR_getWorkInt( petindex, CHAR_WORKOBJINDEX ); + print(" objindex02:%d ", objindex); + + if( (pickupindex == -1) || (pickupindex == CHAR_getWorkInt( charaindex, CHAR_WORKPETFOLLOW ) ) ) + CHAR_setWorkInt( charaindex, CHAR_WORKPETFOLLOW, -1 ); + + /* CDKEY 午平乓仿 互域谯仄卅中午五反胶尹卅中 */ + if( strcmp( CHAR_getChar( petindex, CHAR_OWNERCDKEY), CHAR_getChar( charaindex, CHAR_CDKEY)) != 0 || + strcmp( CHAR_getChar( petindex, CHAR_OWNERCHARANAME), CHAR_getChar( charaindex, CHAR_NAME)) != 0 ) + { + //CHAR_setWorkInt( charaindex, CHAR_WORKPETFOLLOW, -1 ); + + return FALSE; + } + + + //CHAR_setWorkInt( charaindex, CHAR_WORKPETFOLLOW, -1 ); + + CHAR_ObjectDelete(objindex); + + CHAR_setWorkInt( petindex, CHAR_WORKPETFOLLOWMODE, CHAR_PETFOLLOW_NONE ); + + CHAR_setWorkInt( petindex, CHAR_WORKPLAYERINDEX, charaindex); + CHAR_setCharPet( charaindex, havepetindex, petindex); + +#ifdef _PET_TALK + if( CHAR_getInt( petindex, CHAR_PETID) != 718 ) { +#endif + CHAR_setChar( petindex, CHAR_OWNERCDKEY, CHAR_getChar( charaindex, CHAR_CDKEY)); + CHAR_setChar( petindex, CHAR_OWNERCHARANAME, CHAR_getChar( charaindex, CHAR_NAME)); +#ifdef _PET_TALK + } +#endif + + snprintf( category,sizeof( category),"K%d",havepetindex); + CHAR_sendStatusString( charaindex, category); + snprintf( category,sizeof( category),"W%d",havepetindex); + CHAR_sendStatusString( charaindex, category); + + CHAR_setInt( petindex, CHAR_PUTPETTIME, 0); + CHAR_setWorkInt( petindex, CHAR_WORKPETFOLLOWCOUNT, 0); + + + CHAR_setWorkInt( petindex, CHAR_WORKOBJINDEX, -1); + + { + char mesg[256]; + char *p = NULL; + p = CHAR_getChar( petindex, CHAR_USERPETNAME); + if( strlen( p) == 0 ) { + p = CHAR_getChar( petindex, CHAR_NAME); + } + snprintf( mesg,sizeof(mesg), "拾回 %s", p); + CHAR_talkToCli(charaindex,-1,mesg,CHAR_COLORYELLOW); + } + // 矢永玄毛胶匀凶夫弘 + LogPet( + CHAR_getChar( charaindex, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( charaindex, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "FollowPickUp(收回溜宠)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + + return TRUE; + +} +#ifdef _GAMBLE_ROULETTE +int NPC_MAPCLEANGOLD( int meindex , int floor) +{ + OBJECT object; + int x,y,fl; + int End_type; + fl = floor; + + for( End_type = 0; End_type < arraysizeof(casinomap) ; End_type++ ) { + if( floor != casinomap[ End_type].casinofl ) + continue; + x = casinomap[ End_type].casinox; + y = casinomap[ End_type].casinoy; + + for( object=MAP_getTopObj(fl,x,y) ; object ; object = NEXT_OBJECT(object ) ) { + int index = GET_OBJINDEX(object); + int objtype = OBJECT_getType(index); + int itemindex = OBJECT_getIndex( index); + + if( objtype == OBJTYPE_NOUSE )continue; + if( objtype == OBJTYPE_ITEM ){ + if(ITEM_getInt(itemindex, ITEM_ID) == CASINOTOKENID) { + ITEM_endExistItemsOne( itemindex); + OBJECT_setIndex( index, 0); + CHAR_ObjectDelete(index); //清除 + print(" clean( %d )", index ); + } + break; + } + } + casinomap[End_type].stakenum = 0; + } + return 1; +} +#endif + +#ifdef _DROPSTAKENEW +// casinotype : flg = 0 不分type,针对整层type做设定;扩充参数 +// mapdropflag : TRUE = 可以下注; +int SetCasinoMap(int npcindex, int casinotype, int mapdropflag) +{ + int npcfloor = CHAR_getInt(npcindex, CHAR_FLOOR); + int i = 0; + if (casinotype < 0 || mapdropflag < 0) + return -1; + for (i = 0; i < arraysizeof(casinomap); i++) + { + if (npcfloor == casinomap[i].casinofl) + { + if (casinotype != 0) + { + if (casinomap[i].casinotype == casinotype) + casinomap[i].dropflag = mapdropflag; + } + else + casinomap[i].dropflag = mapdropflag; + } + } + return 1; +} + +// 计算积分 +int CasinoAccumulation(int charindex, int npcindex, int floor, int wincasinotype) +{ + int i = 0; + int accumulation = CHAR_getInt(charindex, CHAR_GAMBLENUM); + char tmpbuf[256]; + for (i = 0; i < MAXSTAKENUM; i++) + { + if (CHAR_getWorkInt(charindex, CHAR_WORKSTAKETYPE1 + i) == wincasinotype) + { + int j = 0; + for (j = 0; j < arraysizeof(casinomap); j++) + { + if (casinomap[j].casinotype == wincasinotype) + { +#ifdef _FIX_GAMBLENUM + // 加 原本积分及WIN积分 + accumulation = accumulation + casinomap[j].accumulation * 2; +#else + accumulation += casinomap[j].accumulation; +#endif + CHAR_setWorkInt(charindex, CHAR_WORKSTAKETYPE1 + i, 0); + break; + } + } + } + + else if (CHAR_getWorkInt(charindex, CHAR_WORKSTAKETYPE1 + i) != 0) + { + int j = 0; + for (j = 0; j < arraysizeof(casinomap); j++) + { + if (casinomap[j].casinotype == CHAR_getWorkInt(charindex, CHAR_WORKSTAKETYPE1 + i)) + { +#ifndef _FIX_GAMBLENUM + accumulation -= casinomap[j].accumulation; +#endif + CHAR_setWorkInt(charindex, CHAR_WORKSTAKETYPE1 + i, 0); + break; + } + } + } + } + CHAR_setWorkInt(charindex, CHAR_WORKSTAKEFLAG, 0); + if (accumulation < 0) + accumulation = 0; + else if (accumulation > MAXACCUMULATION) + accumulation = MAXACCUMULATION; + CHAR_setInt(charindex, CHAR_GAMBLENUM, accumulation); + snprintf(tmpbuf, sizeof(tmpbuf), "您现在总共有%4d点游乐场积分", accumulation); + CHAR_talkToCli(charindex, npcindex, tmpbuf, CHAR_COLORWHITE); + return 1; +} + +int CasinoPay(int npcindex, int wincasinotype) +{ + int npcfloor = CHAR_getInt(npcindex, CHAR_FLOOR); + int i = 0; + int playernum = CHAR_getPlayerMaxNum(); + if (wincasinotype < 0) return FALSE; + for (i = 0; i < playernum; i++) + { + if (CHAR_getCharUse(i) == FALSE) continue; + if (!CHAR_CHECKINDEX(i)) continue; + if (CHAR_getInt(i, CHAR_FLOOR) == npcfloor) + { + // 查询玩家是否有下注 + if (CHAR_getWorkInt(i, CHAR_WORKSTAKEFLAG) == 0) + continue; + // 计算积分 + CasinoAccumulation(i, npcindex, npcfloor, wincasinotype); + } + } + // 清除此层地面彩券 + for (i = 0; i < arraysizeof(casinomap); i++) + { + OBJECT object; + if (casinomap[i].casinofl != npcfloor) continue; + for (object = MAP_getTopObj(casinomap[i].casinofl, casinomap[i].casinox, + casinomap[i].casinoy); object; object = NEXT_OBJECT(object)) + { + int index = GET_OBJINDEX(object); + int objtype = OBJECT_getType(index); + int itemindex = OBJECT_getIndex( index); + if (objtype == OBJTYPE_NOUSE) continue; + else if (objtype == OBJTYPE_ITEM) + { + if(ITEM_getInt(itemindex, ITEM_ID) == CASINOTOKENID) + { + OBJECT_setIndex(index, 0); + CHAR_ObjectDelete(index); + } + } + } + casinomap[i].stakenum = 0; + } + return TRUE; +} +#endif + + diff --git a/gmsv/char/char_item.c.bak b/gmsv/char/char_item.c.bak new file mode 100644 index 0000000..0356076 --- /dev/null +++ b/gmsv/char/char_item.c.bak @@ -0,0 +1,2355 @@ +#include "version.h" +#include + +#include "readmap.h" +#include "map_deal.h" +#include "object.h" +#include "char.h" +#include "char_base.h" +#include "item.h" +#include "lssproto_serv.h" +#include "handletime.h" +#include "log.h" +#include "item_event.h" +#include "battle.h" +#include "petmail.h" +#ifdef _MARKET_TRADE +#include "item_trade.h" +#endif +#ifdef _DROPSTAKENEW +#define CASINOTOKENID 20121 // 游乐场彩券代号 +#define MAXCASINOMAPNUM 150 // 游乐场地图上限 +#define MAXACCUMULATION 1000000 // 积分上限 +typedef struct tagCasinoMapTable +{ + int casinofl; // 游乐场图层 + int casinox; // 游乐场X座标 + int casinoy; // 游乐场Y座标 + int casinotype; // 赌注类型 + int dropflag; // 是否可下注 flag + char casinoinfo[64]; // 赌注类型说明 + int accumulation; // 积分 + int stakenum; // 彩券数量 +}CasinoMapTable; +CasinoMapTable casinomap[MAXCASINOMAPNUM] = +{ + { 7008, 13, 13, DICE_BIG, 1, "骰子-大", 1, 0}, + { 7008, 14, 13, DICE_BIG, 1, "骰子-大", 1, 0}, + { 7008, 15, 13, DICE_BIG, 1, "骰子-大", 1, 0}, + { 7008, 16, 13, DICE_BIG, 1, "骰子-大", 1, 0}, + { 7008, 17, 13, DICE_BIG, 1, "骰子-大", 1, 0}, + { 7008, 13, 14, DICE_BIG, 1, "骰子-大", 1, 0}, + { 7008, 14, 14, DICE_BIG, 1, "骰子-大", 1, 0}, + { 7008, 15, 14, DICE_BIG, 1, "骰子-大", 1, 0}, + { 7008, 16, 14, DICE_BIG, 1, "骰子-大", 1, 0}, + { 7008, 17, 14, DICE_BIG, 1, "骰子-大", 1, 0}, + { 7008, 13, 15, DICE_BIG, 1, "骰子-大", 1, 0}, + { 7008, 14, 15, DICE_BIG, 1, "骰子-大", 1, 0}, + { 7008, 15, 15, DICE_BIG, 1, "骰子-大", 1, 0}, + { 7008, 16, 15, DICE_BIG, 1, "骰子-大", 1, 0}, + { 7008, 17, 15, DICE_BIG, 1, "骰子-大", 1, 0}, + { 7008, 8, 13, DICE_SMALL, 1, "骰子-小", 1, 0}, + { 7008, 9, 13, DICE_SMALL, 1, "骰子-小", 1, 0}, + { 7008, 10, 13, DICE_SMALL, 1, "骰子-小", 1, 0}, + { 7008, 11, 13, DICE_SMALL, 1, "骰子-小", 1, 0}, + { 7008, 12, 13, DICE_SMALL, 1, "骰子-小", 1, 0}, + { 7008, 8, 14, DICE_SMALL, 1, "骰子-小", 1, 0}, + { 7008, 9, 14, DICE_SMALL, 1, "骰子-小", 1, 0}, + { 7008, 10, 14, DICE_SMALL, 1, "骰子-小", 1, 0}, + { 7008, 11, 14, DICE_SMALL, 1, "骰子-小", 1, 0}, + { 7008, 12, 14, DICE_SMALL, 1, "骰子-小", 1, 0}, + { 7008, 8, 15, DICE_SMALL, 1, "骰子-小", 1, 0}, + { 7008, 9, 15, DICE_SMALL, 1, "骰子-小", 1, 0}, + { 7008, 10, 15, DICE_SMALL, 1, "骰子-小", 1, 0}, + { 7008, 11, 15, DICE_SMALL, 1, "骰子-小", 1, 0}, + { 7008, 12, 15, DICE_SMALL, 1, "骰子-小", 1, 0}, + + { 7005, 22, 21, PET_RACE1, 1, "竞速场-宠物1", 2, 0}, + { 7005, 23, 21, PET_RACE1, 1, "竞速场-宠物1", 2, 0}, + { 7005, 24, 21, PET_RACE1, 1, "竞速场-宠物1", 2, 0}, + { 7005, 25, 21, PET_RACE1, 1, "竞速场-宠物1", 2, 0}, + { 7005, 26, 21, PET_RACE1, 1, "竞速场-宠物1", 2, 0}, + { 7005, 27, 21, PET_RACE1, 1, "竞速场-宠物1", 2, 0}, + { 7005, 28, 21, PET_RACE1, 1, "竞速场-宠物1", 2, 0}, + { 7005, 22, 24, PET_RACE2, 1, "竞速场-宠物2", 2, 0}, + { 7005, 23, 24, PET_RACE2, 1, "竞速场-宠物2", 2, 0}, + { 7005, 24, 24, PET_RACE2, 1, "竞速场-宠物2", 2, 0}, + { 7005, 25, 24, PET_RACE2, 1, "竞速场-宠物2", 2, 0}, + { 7005, 26, 24, PET_RACE2, 1, "竞速场-宠物2", 2, 0}, + { 7005, 27, 24, PET_RACE2, 1, "竞速场-宠物2", 2, 0}, + { 7005, 28, 24, PET_RACE2, 1, "竞速场-宠物2", 2, 0}, + { 7005, 22, 27, PET_RACE3, 1, "竞速场-宠物3", 2, 0}, + { 7005, 23, 27, PET_RACE3, 1, "竞速场-宠物3", 2, 0}, + { 7005, 24, 27, PET_RACE3, 1, "竞速场-宠物3", 2, 0}, + { 7005, 25, 27, PET_RACE3, 1, "竞速场-宠物3", 2, 0}, + { 7005, 26, 27, PET_RACE3, 1, "竞速场-宠物3", 2, 0}, + { 7005, 27, 27, PET_RACE3, 1, "竞速场-宠物3", 2, 0}, + { 7005, 28, 27, PET_RACE3, 1, "竞速场-宠物3", 2, 0}, + + { 7003, 21, 15, ROULETTE1, 1, "轮盘红1", 1, 0}, { 7003, 17, 15, ROULETTE3, 1, "轮盘红3", 1, 0}, + { 7003, 13, 15, ROULETTE5, 1, "轮盘红5", 1, 0}, { 7003, 21, 21, ROULETTE6, 1, "轮盘红6", 1, 0}, + { 7003, 17, 21, ROULETTE8, 1, "轮盘红8", 1, 0}, { 7003, 15, 21, ROULETTE9, 1, "轮盘红9", 1, 0}, + { 7003, 13, 21, ROULETTE10, 1, "轮盘红10", 1, 0}, { 7003, 13, 18, ROULETTE13, 1, "轮盘红13", 1, 0}, + { 7003, 9, 21, ROULETTE17, 1, "轮盘红17", 1, 0}, { 7003, 21, 18, ROULETTE18, 1, "轮盘红18", 1, 0}, + + { 7003, 19, 15, ROULETTE22, 1, "轮盘绿2", 1, 0}, { 7003, 15, 15, ROULETTE24, 1, "轮盘绿4", 1, 0}, + { 7003, 19, 21, ROULETTE27, 1, "轮盘绿7", 1, 0}, { 7003, 11, 15, ROULETTE31, 1, "轮盘绿11", 1, 0}, + { 7003, 9, 15, ROULETTE32, 1, "轮盘绿12", 1, 0}, { 7003, 11, 18, ROULETTE34, 1, "轮盘绿14", 1, 0}, + { 7003, 9, 18, ROULETTE35, 1, "轮盘绿15", 1, 0}, { 7003, 11, 21, ROULETTE36, 1, "轮盘绿16", 1, 0}, + { 7003, 19, 18, ROULETTE39, 1, "轮盘绿19", 1, 0}, { 7003, 17, 18, ROULETTE40, 1, "轮盘绿20", 1, 0}, + { 7003, 17, 24, ROULETTE41, 1, "轮盘红", 1, 0}, { 7003, 16, 24, ROULETTE41, 1, "轮盘红", 1, 0}, + { 7003, 17, 25, ROULETTE41, 1, "轮盘红", 1, 0}, { 7003, 16, 25, ROULETTE41, 1, "轮盘红", 1, 0}, + { 7003, 14, 24, ROULETTE42, 1, "轮盘绿", 1, 0}, { 7003, 13, 24, ROULETTE42, 1, "轮盘绿", 1, 0}, + { 7003, 14, 25, ROULETTE42, 1, "轮盘绿", 1, 0}, { 7003, 13, 25, ROULETTE42, 1, "轮盘绿", 1, 0}, + + // WON ADD 修正地图上单双的错误 + { 7003, 11, 24, ROULETTE43, 1, "轮盘单", 1, 0}, { 7003, 10, 24, ROULETTE43, 1, "轮盘单", 1, 0}, + { 7003, 11, 25, ROULETTE43, 1, "轮盘单", 1, 0}, { 7003, 10, 25, ROULETTE43, 1, "轮盘单", 1, 0}, + { 7003, 20, 24, ROULETTE44, 1, "轮盘双", 1, 0}, { 7003, 19, 24, ROULETTE44, 1, "轮盘双", 1, 0}, + { 7003, 20, 25, ROULETTE44, 1, "轮盘双", 1, 0}, { 7003, 19, 25, ROULETTE44, 1, "轮盘双", 1, 0}, + + + + { 7003, 20, 15, (ROULETTE1<<16)+ROULETTE22, 1, "双号红1绿2", 1, 0}, + { 7003, 18, 15, (ROULETTE3<<16)+ROULETTE22, 1, "双号红3绿2", 1, 0}, + { 7003, 16, 15, (ROULETTE3<<16)+ROULETTE24, 1, "双号红3绿4", 1, 0}, + { 7003, 14, 15, (ROULETTE5<<16)+ROULETTE24, 1, "双号红5绿4", 1, 0}, + { 7003, 12, 15, (ROULETTE5<<16)+ROULETTE31, 1, "双号红5绿11", 1, 0}, + { 7003, 10, 15, (ROULETTE32<<16)+ROULETTE31, 1, "双号绿12绿11", 1, 0}, + + { 7003, 20, 18, (ROULETTE18<<16)+ROULETTE39, 1, "双号红18绿19", 1, 0}, + { 7003, 18, 18, (ROULETTE40<<16)+ROULETTE39, 1, "双号绿20绿19", 1, 0}, + { 7003, 16, 18, (ROULETTE40<<16)+ROULETTE45, 1, "双号绿20黑00", 1, 0}, + { 7003, 14, 18, (ROULETTE13<<16)+ROULETTE45, 1, "双号红13黑00", 1, 0}, + { 7003, 12, 18, (ROULETTE13<<16)+ROULETTE34, 1, "双号红13绿14", 1, 0}, + { 7003, 10, 18, (ROULETTE35<<16)+ROULETTE34, 1, "双号绿15绿14", 1, 0}, + + { 7003, 20, 21, (ROULETTE6<<16) +ROULETTE27, 1, "双号红6绿7", 1, 0}, + { 7003, 18, 21, (ROULETTE8<<16) +ROULETTE27, 1, "双号红8绿7", 1, 0}, + { 7003, 16, 21, (ROULETTE8<<16) + ROULETTE9, 1, "双号红8红9", 1, 0}, + { 7003, 14, 21, (ROULETTE10<<16)+ ROULETTE9, 1, "双号红10红9", 1, 0}, + { 7003, 12, 21, (ROULETTE10<<16)+ROULETTE36, 1, "双号红10绿16", 1, 0}, + { 7003, 10, 21, (ROULETTE17<<16)+ROULETTE36, 1, "双号红17绿16", 1, 0}, + { 7003, 8, 15, ROULETTE51, 1, "横列1", 1, 0}, //横列 + { 7003, 8, 18, ROULETTE52, 1, "横列2", 1, 0}, + { 7003, 8, 21, ROULETTE53, 1, "横列3", 1, 0}, + { 7003, 6, 15, ROULETTE61, 1, "号码1-10", 1, 0}, //1到10 + { 7003, 5, 15, ROULETTE61, 1, "号码1-10", 1, 0}, + { 7003, 6, 16, ROULETTE61, 1, "号码1-10", 1, 0}, + { 7003, 5, 16, ROULETTE61, 1, "号码1-10", 1, 0}, + { 7003, 24, 15, ROULETTE62, 1, "号码11-20", 1, 0}, //10到11 + { 7003, 23, 15, ROULETTE62, 1, "号码11-20", 1, 0}, + { 7003, 24, 16, ROULETTE62, 1, "号码11-20", 1, 0}, + { 7003, 23, 16, ROULETTE62, 1, "号码11-20", 1, 0}, + { 7003, 15, 18, ROULETTE45, 1, "轮盘(00)", 1, 0}, + +}; +#endif + + +static char CHAR_sendItemBuffer[STRINGBUFSIZ]; +BOOL CHAR_sendItemDataOne( int charaindex, int haveitemindex) +{ + int itemgrp[1]; + itemgrp[0] = haveitemindex; + return CHAR_sendItemData( charaindex, itemgrp, 1); +} + +BOOL CHAR_sendItemData( int charaindex, int *itemgroup, int num) +{ + int i; + int strlength = 0; + int fd; + + if( num <= 0 || num > CHAR_MAXITEMHAVE) return FALSE; + + if( CHAR_getInt(charaindex,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ) { + return FALSE; + } + for( i = 0; i < num; i ++ ) { + char token[512]; + int itemindex; +DebugPoint = 200; + if( !CHAR_CHECKITEMINDEX( charaindex, itemgroup[i])) { + continue; + } + itemindex = CHAR_getItemIndex( charaindex, itemgroup[i] ); + if( itemindex >= 0 ) { + snprintf( token ,sizeof(token),"%s|" , + ITEM_makeItemStatusString( itemgroup[i],itemindex ) ); + }else { + snprintf( token ,sizeof(token),"%s|" , + ITEM_makeItemFalseStringWithNum( itemgroup[i]) ); + } + strcpysafe( CHAR_sendItemBuffer + strlength, + sizeof(CHAR_sendItemBuffer) - strlength, token ); + strlength += strlen( token ); + if( strlength >= arraysizeof(CHAR_sendItemBuffer) ) { + break; + } + } + dchop( CHAR_sendItemBuffer , "|" ); + fd = getfdFromCharaIndex( charaindex ); + if( fd != -1 ){ + lssproto_I_send( fd, CHAR_sendItemBuffer ); + return TRUE; + } + return FALSE; +} + +static void CHAR_sendItemDetachEvent( int charaindex,int itemid ) +{ + char mesg[256]; + + snprintf( mesg, sizeof( mesg), "卸下%s ", ITEM_getAppropriateName(itemid) ); + CHAR_talkToCli(charaindex,-1,mesg,CHAR_COLORWHITE); +#ifdef _ITEM_METAMO + if( ITEM_getEquipPlace( charaindex, itemid) == CHAR_BODY + && CHAR_getWorkInt( charaindex, CHAR_WORKITEMMETAMO) != 0 ) { + CHAR_setWorkInt( charaindex, CHAR_WORKITEMMETAMO, 0); + CHAR_setWorkInt( charaindex, CHAR_WORKNPCMETAMO, 0 ); //与npc对话後的变身也要变回来 + CHAR_complianceParameter( charaindex); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + CHAR_talkToCli( charaindex, -1, "变身失效了!", CHAR_COLORWHITE); + } +#endif + { + typedef void (*DETACHFUNC)(int,int); + DETACHFUNC def; + def=(DETACHFUNC)ITEM_getFunctionPointer(itemid,ITEM_DETACHFUNC); + if( def ) { + def( charaindex,itemid ); + } + } +} + +static void CHAR_sendItemAttachEvent( int charaindex,int itemid ) +{ + char mesg[256]; + snprintf( mesg, sizeof( mesg), "装备%s ", + ITEM_getAppropriateName(itemid) ); + CHAR_talkToCli(charaindex,-1,mesg,CHAR_COLORWHITE); + { + typedef void (*ATTACHFUNC)(int,int); + ATTACHFUNC atf; + atf=(ATTACHFUNC)ITEM_getFunctionPointer(itemid,ITEM_ATTACHFUNC); + if( atf ) + atf( charaindex,itemid ); + } +} + + +int CHAR_findSurplusItemBox( int charaindex ) +{ + int i, remnants=0, itemindex; + for(i=CHAR_STARTITEMARRAY; i< CHAR_MAXITEMHAVE; i++){ + itemindex = CHAR_getItemIndex( charaindex , i ); + if( itemindex == -1 ) remnants++; + } + return remnants; +} + + +static int CHAR_findEmptyItemBoxFromChar( Char* ch ) +{ + int i; + + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE ; i ++ ){ + int itemindex; + itemindex = ch->indexOfExistItems[i]; + if( itemindex == -1 )return i; + } + + return -1; +} + +static int CHAR_findEmptyPoolItemBoxFromChar( Char* ch ) +{ + int i; + for( i=0; iindexOfExistPoolItems[i]; + if( itemindex == -1 ) return i; + } + return -1; +} + +int CHAR_findEmptyPoolItemBox( int index ) +{ + Char* ch; + if( !CHAR_CHECKINDEX( index ) )return -1; + ch = CHAR_getCharPointer(index); + if( ch != NULL ) + return CHAR_findEmptyPoolItemBoxFromChar( ch ); + else + return -1; +} + +int CHAR_findEmptyItemBox( int index ) +{ + Char* ch; + + if( !CHAR_CHECKINDEX( index ) )return -1; + ch = CHAR_getCharPointer(index); + if( ch != NULL ) + return CHAR_findEmptyItemBoxFromChar( ch ); + else + return -1; + +} + +#define LACKOFCLASS {CHAR_talkToCli(index,-1,"能力不足无法装备。",CHAR_COLORWHITE);} +#define CANNOTEQUIP {CHAR_talkToCli(index,-1,"无法装备该项物品。",CHAR_COLORWHITE);} +#define CANNOTEQUIP2 {CHAR_talkToCli(index,-1,"无法同时装备两项同种类的物品。",CHAR_COLORWHITE);} +#define CANNOTEXCHANGE {CHAR_talkToCli(index,-1,"无法交换此两项物品。",CHAR_COLORWHITE);} +#define CANNOTMOVE {CHAR_talkToCli(index,-1,"无法移动该项物品。",CHAR_COLORWHITE);} + +static BOOL CHAR_sendSIToCli( int charindex , int from , int to ) +{ + int fd = getfdFromCharaIndex( charindex ); + if( fd != -1 ){ + lssproto_SI_send( fd , from, to ); + return TRUE; + } + return FALSE; +} + +static BOOL CHAR_moveItemFromItemBoxToEquip( int index, int fromindex, + int toindex ) +{ + int fromid,toid; + int fromeqplace; + BOOL flg = FALSE; + + if( !CHAR_CHECKINDEX( index ) )return FALSE; + + fromid = CHAR_getItemIndex(index,fromindex); + toid = CHAR_getItemIndex(index,toindex); + if( !ITEM_CHECKINDEX( fromid) ) + return FALSE; + + if( CHAR_getInt( index, CHAR_TRANSMIGRATION ) <= 0 ){ + if( ITEM_getInt(fromid,ITEM_LEVEL) > CHAR_getInt(index,CHAR_LV) ){ + LACKOFCLASS; + return FALSE; + } + } +#ifdef _ITEMSET4_TXT + if( CHAR_getInt( index, CHAR_STR) < ITEM_getInt( fromid, ITEM_NEEDSTR) ) return FALSE; + if( CHAR_getInt( index, CHAR_DEX) < ITEM_getInt( fromid, ITEM_NEEDDEX) ) return FALSE; + if( CHAR_getInt( index, CHAR_TRANSMIGRATION) < ITEM_getInt( fromid, ITEM_NEEDTRANS) ) return FALSE; +#ifdef _CHAR_PROFESSION // WON ADD 人物职业 + if( ITEM_getInt( fromid, ITEM_NEEDPROFESSION) != 0 ){ + if( CHAR_getInt( index, PROFESSION_CLASS ) != ITEM_getInt( fromid, ITEM_NEEDPROFESSION) ) + return FALSE; + } +#endif +#endif + +#ifdef _FIXBUG_ATTACKBOW + { + if( CHAR_getWorkInt( index, CHAR_WORKITEMMETAMO) > 0 || + CHAR_getWorkInt( index, CHAR_WORKNPCMETAMO) > 0 + || CHAR_getWorkInt( index, CHAR_WORKFOXROUND ) != -1){ //若是变成小狐狸 + + int armtype = ITEM_getInt( fromid, ITEM_TYPE ); + + if( armtype == ITEM_BOW || armtype == ITEM_BOUNDTHROW || + armtype == ITEM_BREAKTHROW || armtype == ITEM_BOOMERANG) { + CHAR_talkToCli( index, -1, "变身无法使用远距离武器!", CHAR_COLORYELLOW ); + return FALSE; + } + } + } +#endif + +#ifdef _ANGEL_SUMMON + //if( !strcmp( ITEM_getChar( fromid, ITEM_USEFUNC), "ITEM_AngelToken") ) { + if( ITEM_getInt( fromid, ITEM_ID) == ANGELITEM ) { + int mindex; + char nameinfo[64]; + + mindex = checkIfAngel( index); + getMissionNameInfo( index, nameinfo); + if( mindex < 0 || + strcmp( ITEM_getChar( fromid, ITEM_ANGELINFO), missiontable[mindex].angelinfo) || + strcmp( ITEM_getChar( fromid, ITEM_HEROINFO), missiontable[mindex].heroinfo) || + strcmp( ITEM_getChar( fromid, ITEM_ANGELINFO), nameinfo) ) { + + CHAR_talkToCli( index, -1, "这并不是属於你的信物,无法装备。", CHAR_COLORYELLOW ); + return FALSE; + } + } +#endif + + fromeqplace = ITEM_getEquipPlace( index, fromid ); + if( fromeqplace == -1 ){ + CANNOTEQUIP; + return FALSE; + } + //if( BATTLE_GetWepon( charaindex ) != ITEM_BOW ) + + if( fromeqplace == CHAR_DECORATION1 ) { + int checkplace = ( toindex == CHAR_DECORATION1) + ? CHAR_DECORATION2:CHAR_DECORATION1; + int otheritemindex; + + if( toindex == CHAR_DECORATION1 || toindex == CHAR_DECORATION2 ) { + otheritemindex = CHAR_getItemIndex( index, checkplace); + if( ITEM_CHECKINDEX( otheritemindex )) { + int otheritemtype = ITEM_getInt( otheritemindex, ITEM_TYPE); + int myitemtype = ITEM_getInt( CHAR_getItemIndex( index, fromindex) , ITEM_TYPE); + if( otheritemtype == myitemtype) { + if( toid < 0 ) { + CANNOTEQUIP2; + }else { + CANNOTEXCHANGE; + } + return FALSE; + } + } + flg = TRUE; + } + }else { + if( toindex == fromeqplace) flg = TRUE; + } + if( flg ){ + CHAR_setItemIndex(index,toindex,fromid); + CHAR_setItemIndex(index,fromindex,toid); + if( toid != -1 ) { + CHAR_sendItemDetachEvent( index, toid ); + } +#ifdef _CHECK_ITEM_MODIFY + ITEM_checkItemModify( index, fromid); +#endif + CHAR_sendItemAttachEvent( index, fromid ); + CHAR_sendSIToCli( index, fromindex,toindex ); + }else { + CANNOTEQUIP; + return FALSE; + } + +#if 0 //#ifdef _ANGEL_SUMMON + //if( !strcmp( ITEM_getChar( fromid, ITEM_USEFUNC), "ITEM_AngelToken") ) { + if( ITEM_getInt( fromid, ITEM_ID) == ANGELITEM ) { + print(" 装备使者信物 "); + CHAR_talkToCli( index, -1, "你受到了精灵保护,不会被敌人攻击。", CHAR_COLORYELLOW ); + //CHAR_setWorkInt( index, CHAR_WORKANGELMODE, TRUE); + CHAR_sendAngelMark( CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), 1); + } +#endif + + return TRUE; +} + +static BOOL CHAR_moveItemFromEquipToItemBox(int index, int fromindex, + int toindex) +{ + int fromid,toid; + + if( !CHAR_CHECKINDEX( index )) return FALSE; + + fromid = CHAR_getItemIndex(index,fromindex); + toid = CHAR_getItemIndex(index,toindex); + if( fromid < 0 ) + return FALSE; + else if( toid < 0 ){ + CHAR_setItemIndex(index,toindex,fromid); + CHAR_setItemIndex(index,fromindex,-1); + CHAR_sendItemDetachEvent( index,fromid ); + CHAR_sendSIToCli( index,fromindex,toindex); +#if 0 //#ifdef _ANGEL_SUMMON + //if( !strcmp( ITEM_getChar( fromid, ITEM_USEFUNC), "ITEM_AngelToken") ) { + if( ITEM_getInt( fromid, ITEM_ID) == ANGELITEM ) { + print(" 卸下使者信物 "); + CHAR_setWorkInt( index, CHAR_WORKANGELMODE, FALSE); + CHAR_sendAngelMark( CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), 0); + } +#endif + return TRUE; + } + + return CHAR_moveItemFromItemBoxToEquip(index, toindex,fromindex); +} + +#ifdef _ITEM_PILENUMS +int CHAR_getMyMaxPilenum( int charaindex) +{ + int maxpile; + maxpile = CHAR_getInt( charaindex, CHAR_TRANSMIGRATION) + + (CHAR_getInt( charaindex, CHAR_TRANSMIGRATION)/5) * 2 + 3; + +/* +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + maxpile += CHAR_getInt( charaindex, ATTACHPILE ); +#endif +*/ + +#ifdef _EQUIT_ADDPILE + maxpile += CHAR_getWorkInt( charaindex, CHAR_WORKATTACHPILE); + maxpile = (maxpile<0)?0:maxpile; +#endif + return maxpile; +} + +BOOL CHAR_PileItemFromItemBoxToItemBox( int charaindex, int fromindex, int toindex) +{ + int maxpile, fromid, toid; + if( !CHAR_CHECKINDEX( charaindex) ) return FALSE; + fromid = CHAR_getItemIndex( charaindex, fromindex); + toid = CHAR_getItemIndex( charaindex, toindex); + + maxpile = CHAR_getMyMaxPilenum( charaindex); + + if( ITEM_CHECKINDEX( toid) && ITEM_CHECKINDEX( fromid) && + (ITEM_getInt( toid, ITEM_ID) == ITEM_getInt( fromid, ITEM_ID)) && + (ITEM_getInt( toid, ITEM_CANBEPILE) == 1) && + (ITEM_getInt( toid, ITEM_USEPILENUMS) < maxpile) && + (ITEM_getInt( fromid, ITEM_USEPILENUMS) < maxpile) ){ + int formpilenum , pilenum, defpilenum; + + pilenum = ITEM_getInt( toid, ITEM_USEPILENUMS); + formpilenum = ITEM_getInt( fromid, ITEM_USEPILENUMS); + defpilenum = ((maxpile-pilenum)>formpilenum)? formpilenum:(maxpile-pilenum); + formpilenum = formpilenum - defpilenum; + pilenum = pilenum + defpilenum; + ITEM_setInt( toid, ITEM_USEPILENUMS, pilenum); + ITEM_setInt( fromid, ITEM_USEPILENUMS, formpilenum); + + if( formpilenum <= 0 ){ + CHAR_setItemIndex( charaindex, fromindex ,-1); + ITEM_endExistItemsOne( fromid); + } + return TRUE; + } + return FALSE; +} +#endif + +static BOOL CHAR_moveItemFromItemBoxToItemBox( int index, int fromindex, int toindex) +{ + int fromid, toid; + + if( !CHAR_CHECKINDEX( index ) ) return FALSE; +#ifdef _ITEM_PILENUMS + if( CHAR_PileItemFromItemBoxToItemBox( index, fromindex, toindex) == TRUE ){ + CHAR_sendItemDataOne( index, toindex); + CHAR_sendItemDataOne( index, fromindex); + return TRUE; + } +#endif + fromid = CHAR_getItemIndex( index, fromindex); + toid = CHAR_getItemIndex( index, toindex); + + CHAR_setItemIndex(index,toindex, CHAR_setItemIndex( index, fromindex, toid)); + CHAR_sendSIToCli( index,fromindex,toindex); + + return TRUE; +} + +void CHAR_moveEquipItem( int index, int fromindex, int toindex ) +{ +#define MOVEITEM_NONE 0 +#define MOVEITEM_EQUIPTOITEM 1 << 0 +#define MOVEITEM_ITEMTOEQUIP 1 << 1 +#define MOVEITEM_ITEMTOITEM 1 << 2 + + int fromid; /* item 匹及奶件犯永弁旦 */ + + + unsigned int moved_any = 0; + while( 1) { + if( !CHAR_CHECKINDEX( index ) )break; + if( CHAR_getFlg( index,CHAR_ISDIE ) )break; + if( fromindex < 0 || fromindex >= CHAR_MAXITEMHAVE || + toindex < 0 || toindex >= CHAR_MAXITEMHAVE ) + break; + + fromid = CHAR_getItemIndex(index,fromindex); + if( fromid == -1 || fromid == -2 )break; + if( fromindex == toindex )break; + if( fromindex < CHAR_EQUIPPLACENUM ){ + if( toindex < CHAR_EQUIPPLACENUM ){ + if( CHAR_getItemIndex(index,toindex) < 0 ){ + CANNOTMOVE; + }else{ + CANNOTEXCHANGE; + } + + }else { + moved_any |= CHAR_moveItemFromEquipToItemBox( + index, fromindex, toindex ) + ? MOVEITEM_EQUIPTOITEM : MOVEITEM_NONE; + if( moved_any & MOVEITEM_EQUIPTOITEM) { + char category[3]; + snprintf( category,sizeof( category),"J%d", fromindex); + CHAR_sendStatusString( index , category); + } + } + }else{ + if( toindex < CHAR_EQUIPPLACENUM ) { + moved_any |= CHAR_moveItemFromItemBoxToEquip( + index, fromindex , toindex ) + ? MOVEITEM_ITEMTOEQUIP : MOVEITEM_NONE; + if( moved_any & MOVEITEM_ITEMTOEQUIP) { + char category[3]; + snprintf( category,sizeof( category),"J%d", toindex); + CHAR_sendStatusString( index , category); + } + }else { + moved_any |= CHAR_moveItemFromItemBoxToItemBox( index,fromindex,toindex ) + ? MOVEITEM_ITEMTOITEM : MOVEITEM_NONE; + } + } + CHAR_complianceParameter( index ); + CHAR_sendCToArroundCharacter(CHAR_getWorkInt(index, CHAR_WORKOBJINDEX)); + break; + } + + if( (moved_any & MOVEITEM_EQUIPTOITEM) || (moved_any & MOVEITEM_ITEMTOEQUIP)){ + int i; + CHAR_send_P_StatusString( index, + CHAR_P_STRING_HP|CHAR_P_STRING_MAXHP| + CHAR_P_STRING_MP|CHAR_P_STRING_MAXMP| + CHAR_P_STRING_ATK|CHAR_P_STRING_DEF| + CHAR_P_STRING_QUICK|CHAR_P_STRING_CHARM| + CHAR_P_STRING_LUCK|CHAR_P_STRING_EARTH| + CHAR_P_STRING_WATER|CHAR_P_STRING_FIRE| + CHAR_P_STRING_WIND + ); + if( CHAR_getWorkInt( index,CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE ){ + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + int petindex = CHAR_getCharPet( index, i); + if( CHAR_CHECKINDEX( petindex) ) { + char category[3]; + CHAR_complianceParameter( petindex ); + snprintf( category, sizeof( category), "K%d",i); + CHAR_sendStatusString( index, category ); + } + } + } + + } + if( !moved_any ) { + CHAR_sendSIToCli( index,-1,-1); + } +} + +int CHAR_addItemToChar( Char* ch, int itemid ) +{ + int itembox; + itembox = CHAR_findEmptyItemBoxFromChar( ch ); + if( itembox == -1 )return -1; + + return ch->indexOfExistItems[itembox]=ITEM_makeItemAndRegist(itemid); +} + +int CHAR_addItem( int charaindex, int itemid ) +{ + Char* ch; + ch = CHAR_getCharPointer(charaindex); + if( ch != NULL ){ + int ret = CHAR_addItemToChar( ch,itemid ); + if( ret == -1 )return ret; + ITEM_setWorkInt(ret,ITEM_WORKCHARAINDEX,charaindex); + ITEM_setWorkInt(ret,ITEM_WORKOBJINDEX,-1); + return ret; + }else + return -1; +} + + +void CHAR_ItemUse( int charaindex, int to_charaindex, int haveitemindex ) +{ + void (*usefunc)(int,int,int)=NULL; + int itemindex; + if( !CHAR_CHECKINDEX( charaindex ) ){ + print( "ANDY charaindex=%d err\n", charaindex); + return; + } + if( CHAR_CHECKITEMINDEX( charaindex, haveitemindex) == FALSE ){ + print( "ANDY haveitemindex=%d err\n", haveitemindex); + return; + } + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( CHAR_getFlg( charaindex, CHAR_ISDIE ) ){ + print( "ANDY charaindex=%d is CHAR_ISDIE err\n", charaindex); + return; + } +#ifdef _STREET_VENDOR + // 摆摊中不可使用道具 + if(CHAR_getWorkInt(charaindex,CHAR_WORKSTREETVENDOR) > -1){ + print("StreetVendor use item charaindex=%d,name=%s\n",charaindex,CHAR_getChar(charaindex,CHAR_NAME)); + return; + } +#endif + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE ) { + if( CHAR_getInt( to_charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + int action = ITEM_getInt( itemindex, ITEM_USEACTION); + if( action != -1 ) { + CHAR_sendAction( to_charaindex, action, TRUE); + } + } + } + //不等於料理 和 其他 + if( ITEM_getInt( itemindex,ITEM_TYPE) != ITEM_OTHER && + ITEM_getInt( itemindex,ITEM_TYPE) != ITEM_DISH ) { + CHAR_EquipPlace ep; + + ep = ITEM_getEquipPlace( charaindex, itemindex ); + if( ep == -1 )return; + if( ep == CHAR_DECORATION1 ) { + int flg = FALSE; + int toitemindex1 = CHAR_getItemIndex( charaindex, ep); + int toitemindex2 = CHAR_getItemIndex( charaindex, CHAR_DECORATION2); + int searchindex = -1; + int fromitemtype = ITEM_getInt( itemindex, ITEM_TYPE); + + if( !ITEM_CHECKINDEX( toitemindex1)) searchindex = toitemindex2; + else if(!ITEM_CHECKINDEX( toitemindex2)) searchindex = toitemindex1; + if( searchindex != -1 ) { + if( fromitemtype != ITEM_getInt( searchindex, ITEM_TYPE)) { + flg = TRUE; + ep = ( searchindex == toitemindex1) + ? CHAR_DECORATION2:CHAR_DECORATION1; + } + } + if( !flg) { + if( fromitemtype != ITEM_getInt( toitemindex2, ITEM_TYPE)) { + ep = CHAR_DECORATION1; + }else if( fromitemtype != ITEM_getInt( toitemindex1, ITEM_TYPE)) { + ep = CHAR_DECORATION2; + }else { + ep = CHAR_DECORATION1; + } + } + } + CHAR_moveEquipItem( charaindex, haveitemindex,ep ); + return; + } + + usefunc = (void(*)(int,int,int)) + ITEM_getFunctionPointer( itemindex,ITEM_USEFUNC ); + if( usefunc ){ + { + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), /* 失奶 丞 寞 */ +#endif + "Use(使用道具)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + usefunc(charaindex, to_charaindex, haveitemindex); + }else{ + char ansmsg[256]; + strcpysafe( ansmsg, sizeof(ansmsg), + "什麽也没有发生。"); + CHAR_talkToCli( charaindex, -1, ansmsg, CHAR_COLORWHITE ); + } +} + +BOOL CHAR_DropItemFXY( int charaindex, int itemcharaindex, int fl, + int x, int y, int* objindex ) +{ + int itemindex; + itemindex = CHAR_getItemIndex(charaindex,itemcharaindex); + if( ITEM_CHECKINDEX(itemindex) == FALSE )return -3; + if( MAP_walkAbleFromPoint( fl,x,y, FALSE ) == FALSE ){ + return -2; + } + + { + OBJECT object; + for( object=MAP_getTopObj(fl,x,y) ; object; object = NEXT_OBJECT(object ) ){ + int objindex = GET_OBJINDEX(object); + switch( OBJECT_getType(objindex) ){ + case OBJTYPE_NOUSE: + break; + case OBJTYPE_ITEM: +#ifdef _DROPSTAKENEW + if(ITEM_getInt(itemindex, ITEM_ID) == CASINOTOKENID) + { + int i = 0; + int dropflag = 0; + ITEM_Item *itm; + for(i = 0; i < arraysizeof(casinomap); i++){ + if(CHAR_getInt(charaindex, CHAR_FLOOR) == casinomap[i].casinofl){ + if(x == casinomap[i].casinox && y == casinomap[i].casinoy){ + dropflag = 1; + break; + } + } + } + if(dropflag == 1){ + if( (itm = ITEM_getItemPointer( itemindex)) == NULL ) return -1; + strcpysafe( itm->string[ITEM_WATCHFUNC].string, + sizeof(itm->string[ITEM_WATCHFUNC].string), "ITEM_DeleteTimeWatched" ); + + break; + }else{ + + return -1; + } + } +#endif + case OBJTYPE_GOLD: + { + + return -1; + } + case OBJTYPE_CHARA: + { + typedef BOOL (*ITEMPUTFUNC)(int,int); + ITEMPUTFUNC ipfunc; + ipfunc = (ITEMPUTFUNC)CHAR_getFunctionPointer( + OBJECT_getIndex(objindex),CHAR_ITEMPUTFUNC) ; + + if( ipfunc && ipfunc(OBJECT_getIndex(objindex), + itemindex) == TRUE) + return -3; + break; + } + default: + break; + } + } + + *objindex = CHAR_DropItemAbsolute( itemindex,fl,x,y, FALSE ); + + if( *objindex == -1 ) + return -3; + { + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), /* 失奶 丞 寞 */ +#endif + "Drop(丢出道具)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + + ); + } + return 0; + } +} + + +#ifdef _ITEM_PILENUMS //andy_edit 2003/04/01 + +void CHAR_SendDropItem_Stats( int charaindex, int itemindex, int itemcharaindex, int flg) +{ + if( flg == 1 ){ + CHAR_setItemIndex( charaindex, itemcharaindex , -1); + } + CHAR_sendItemDataOne( charaindex, itemcharaindex); + + if( CHAR_complianceParameter( charaindex ) ){ + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX)); + } + + if( 0 <= itemcharaindex && itemcharaindex < CHAR_STARTITEMARRAY && + CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ){ //如果丢弃物为装备 + if( ITEM_CHECKINDEX( itemindex) ) + CHAR_sendItemDetachEvent( charaindex, itemindex ); + + CHAR_send_P_StatusString( charaindex, + CHAR_P_STRING_HP|CHAR_P_STRING_MAXHP| + CHAR_P_STRING_MP|CHAR_P_STRING_MAXMP| + CHAR_P_STRING_ATK|CHAR_P_STRING_DEF| + CHAR_P_STRING_QUICK|CHAR_P_STRING_CHARM| + CHAR_P_STRING_LUCK|CHAR_P_STRING_EARTH| + CHAR_P_STRING_WATER|CHAR_P_STRING_FIRE| + CHAR_P_STRING_WIND ); + +#if 0 //#ifdef _ANGEL_SUMMON + if( ITEM_getInt( itemindex, ITEM_ID) == ANGELITEM ) { + print(" 卸下使者信物 "); + CHAR_setWorkInt( index, CHAR_WORKANGELMODE, FALSE); + CHAR_sendAngelMark( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), 0); + } +#endif + + } +} +#ifdef _DROPSTAKENEW +void CHAR_DropStakeByDropItem( int charaindex, int itemcharaindex, int itemindex, int fl, int x, int y) +{ + int j, k, casinoflag = 0, dropflag; + char tmpbuf[256]; + dropflag = CHAR_getWorkInt( charaindex, CHAR_WORKSTAKEFLAG); + if( dropflag >= MAXSTAKENUM){ + snprintf( tmpbuf, sizeof( tmpbuf), "你已经下注五次了,无法再下注!"); + CHAR_talkToCli(charaindex, -1, tmpbuf, CHAR_COLORYELLOW); + return; + } + for (j = 0; j < arraysizeof( casinomap); j++){ + if( CHAR_getInt( charaindex, CHAR_FLOOR) != casinomap[j].casinofl ) continue; + if( x != casinomap[j].casinox || y != casinomap[j].casinoy ) continue; + if( casinomap[j].dropflag == 0 ){ + CHAR_talkToCli( charaindex, -1, "现在无法下注!", CHAR_COLORYELLOW); + return; + }else{ + int objindex; + objindex = CHAR_DropItemAbsolute( itemindex, fl, x, y, FALSE ); + if( objindex == -1 ) return; + ITEM_setInt( itemindex, ITEM_PUTTIME, NowTime.tv_sec+30*60); + CHAR_sendWatchEvent( objindex, CHAR_ACTSTAND, NULL, 0, TRUE); + casinoflag = 1; + snprintf(tmpbuf, sizeof(tmpbuf), "你在 %s 下注了一张彩券", casinomap[j].casinoinfo); + for(k = 0; k < MAXSTAKENUM; k++){//下注设定 + if(CHAR_getWorkInt(charaindex, CHAR_WORKSTAKETYPE1 + k) != 0) continue; + CHAR_setWorkInt(charaindex, CHAR_WORKSTAKETYPE1 + k, casinomap[j].casinotype); + dropflag++; + break; + } + CHAR_talkToCli(charaindex, -1, tmpbuf, CHAR_COLORYELLOW); +#ifdef _FIX_GAMBLENUM + if (dropflag <= MAXSTAKENUM){ //做扣点的动作 + int nAcc = CHAR_getInt(charaindex, CHAR_GAMBLENUM); + nAcc -= casinomap[j].accumulation; + CHAR_setInt(charaindex, CHAR_GAMBLENUM, nAcc); + } +#endif + dropflag = ( dropflag >= MAXSTAKENUM )?MAXSTAKENUM:dropflag; + CHAR_setWorkInt(charaindex, CHAR_WORKSTAKEFLAG, dropflag); + break; + } + } + + if( casinoflag == 0) return; + LogItem(CHAR_getChar(charaindex, CHAR_NAME), + CHAR_getChar(charaindex, CHAR_CDKEY), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt(itemindex, ITEM_ID), +#endif + "StakeDrop(丢出彩券)", + CHAR_getInt(charaindex,CHAR_FLOOR), + CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y), + ITEM_getChar(itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + CHAR_SendDropItem_Stats( charaindex, itemindex, itemcharaindex, 1); + +} +#endif + +BOOL CHAR_FindAroundUsabilitySpace( int charaindex, int itemindex, int *fl, int *x, int *y) +{ + int dropx, dropy, i; + BOOL Find = FALSE; + int myfl = CHAR_getInt( charaindex, CHAR_FLOOR); + + for( i = 0 ; i < 8 ; i ++ ){ + OBJECT object; + Find = FALSE; + dropx = CHAR_getInt( charaindex, CHAR_X) + CHAR_getDX( CHAR_getInt( charaindex, CHAR_DIR) + i); + dropy = CHAR_getInt( charaindex, CHAR_Y) + CHAR_getDY( CHAR_getInt( charaindex, CHAR_DIR) + i); + if( MAP_walkAbleFromPoint( myfl, dropx, dropy, FALSE ) == FALSE ) continue; + for( object = MAP_getTopObj( myfl, dropx, dropy) ; object ; object = NEXT_OBJECT(object ) ){ + int objindex = GET_OBJINDEX(object); + if( !CHECKOBJECTUSE( objindex)) continue; + if( OBJECT_getType( objindex) == OBJTYPE_CHARA ){ + typedef BOOL (*ITEMPUTFUNC)(int,int); + ITEMPUTFUNC ipfunc; + ipfunc = (ITEMPUTFUNC)CHAR_getFunctionPointer( OBJECT_getIndex(objindex),CHAR_ITEMPUTFUNC) ; + if( ipfunc && ipfunc( OBJECT_getIndex( objindex), itemindex) == TRUE) + return FALSE; + }else{ + Find = TRUE; + break; + } + } + if( Find == FALSE ){ + *fl = myfl; + *x = dropx; + *y = dropy; + return TRUE; + } + } + return FALSE; +} + +void CHAR_DropItem( int charaindex, int itemcharaindex ) +{ + int itemindex, fl, x, y, ret, objindex, beDropOne = 1; + + if( !CHAR_CHECKINDEX( charaindex ) ) return; + + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ){ + CHAR_talkToCli( charaindex, -1, "战斗状态中无法丢道具装备。", CHAR_COLORYELLOW ); + return; + } +#ifdef _AVID_TRADETRYBUG //丢道具装备 + if( CHAR_getWorkInt(charaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE){ + CHAR_talkToCli( charaindex, -1, "交易状态中无法丢道具装备。", CHAR_COLORYELLOW ); + return; + } +#endif + + itemindex = CHAR_getItemIndex( charaindex, itemcharaindex); + if( !ITEM_CHECKINDEX( itemindex)) return; + + if( ITEM_getInt( itemindex, ITEM_ID) == CASINOTOKENID && + ( CHAR_getInt( charaindex, CHAR_FLOOR ) == 7008 || + CHAR_getInt( charaindex, CHAR_FLOOR ) == 7005 || + CHAR_getInt( charaindex, CHAR_FLOOR ) == 7003 ) ){ + + int dropx, dropy, dropfl; + dropfl = CHAR_getInt( charaindex, CHAR_FLOOR); + dropx = CHAR_getInt( charaindex, CHAR_X) + CHAR_getDX( CHAR_getInt( charaindex, CHAR_DIR)); + dropy = CHAR_getInt( charaindex, CHAR_Y) + CHAR_getDY( CHAR_getInt( charaindex, CHAR_DIR)); + CHAR_DropStakeByDropItem( charaindex, itemcharaindex, itemindex, dropfl, dropx, dropy); + return; + } + //找出周围空间 + if( CHAR_FindAroundUsabilitySpace( charaindex, itemindex, &fl, &x, &y) == FALSE ){ + CHAR_talkToCli( charaindex, -1, "周围的地面已经满了。", CHAR_COLORYELLOW ); + return; + } + +#ifdef _ITEM_PILENUMS + if( ITEM_getInt( itemindex, ITEM_CANBEPILE) == 1 && + ITEM_getInt( itemindex, ITEM_USEPILENUMS) > 1 ){ + int ret; + int nums = ITEM_getInt( itemindex, ITEM_USEPILENUMS); + ret = ITEM_makeItemAndRegist( ITEM_getInt( itemindex, ITEM_ID) ); + if( !ITEM_CHECKINDEX( ret)) return; + ITEM_setInt( itemindex, ITEM_USEPILENUMS, nums -1 ); + itemindex = ret; + beDropOne = 0; + } +#endif + //找到空间 + ret = ITEM_eventDrop( itemindex, charaindex, itemcharaindex ); + if( ret == 1 ){ //-1 物品不存在 1 消失 0 一般物品 + CHAR_SendDropItem_Stats( charaindex, itemindex, itemcharaindex, beDropOne); + return; + }else { + objindex = CHAR_DropItemAbsolute( itemindex, fl, x, y, FALSE ); + if( objindex == -1 ) return; + ITEM_setInt( itemindex, ITEM_PUTTIME, NowTime.tv_sec); + { + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), /* 失奶 丞 寞 */ +#endif + "Drop(丢出道具)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + CHAR_sendWatchEvent( objindex, CHAR_ACTSTAND, NULL, 0, TRUE); + } + CHAR_SendDropItem_Stats( charaindex, itemindex, itemcharaindex, beDropOne); +} +#else +void CHAR_DropItem( int charaindex, int itemcharaindex ) +{ + int dirx[9],diry[9]; + int i, j; + int floor, objindex=-1; + int droped =0; + int count_item =0, count_chara =0; + int fl, x, y; + int itemindex = CHAR_getItemIndex(charaindex,itemcharaindex); + + if( !CHAR_CHECKINDEX( charaindex ) ) return; + if( !ITEM_CHECKINDEX( itemindex) ) return; +#ifdef _AVID_TRADETRYBUG //丢道具装备 + if( CHAR_getWorkInt(charaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE){ + CHAR_talkToCli( charaindex, -1, "交易状态中无法丢道具装备。", CHAR_COLORYELLOW ); + return; + } +#endif + +#ifdef _DROPCHECK2 + fl = CHAR_getInt( charaindex, CHAR_FLOOR); + x = CHAR_getInt( charaindex, CHAR_X); + y = CHAR_getInt( charaindex, CHAR_Y); + + for( i = x-CHAR_DEFAULTSEESIZ/2 ; i <= x+CHAR_DEFAULTSEESIZ/2 ; i++ ){ + for( j = y-CHAR_DEFAULTSEESIZ/2 ; j <= y+CHAR_DEFAULTSEESIZ/2 ; j ++ ){ + OBJECT object; + for( object = MAP_getTopObj(fl,i,j); object ; object = NEXT_OBJECT(object ) ) { + int objindex = GET_OBJINDEX(object); + if( OBJECT_getType(objindex) == OBJTYPE_NOUSE ) continue; + if( OBJECT_getType(objindex) == OBJTYPE_ITEM || OBJECT_getType(objindex) == OBJTYPE_GOLD ) { + count_item++; + } + if( OBJECT_getType(objindex) == OBJTYPE_CHARA ) { + count_chara++; + } + } + } + +#ifdef _DROPSTAKENEW + if(ITEM_getInt(itemindex, ITEM_ID) == CASINOTOKENID){ + int k = 0; + int casinodropflag = 0; + for(k = 0; k < arraysizeof(casinomap); k++){ + if(fl == casinomap[k].casinofl){ + if(x >= casinomap[k].casinox - 1 && x <= casinomap[k].casinox + 1){ + if(y >= casinomap[k].casinoy - 1 && y <= casinomap[k].casinoy + 1){ + casinodropflag = 1; + break; + } + } + } + } + if(casinodropflag == 0){ +#endif + if( count_item > 80 || count_chara > 80 ) { + CHAR_talkToCli( charaindex, -1, "这里的物品已经太多了,不能再丢了。", CHAR_COLORYELLOW ); + return; + } +#ifdef _DROPSTAKENEW + } + } +#endif + } +#endif + + for( i = 1 ; i < 8 ; i ++ ){ + dirx[i] = CHAR_getDX(CHAR_getInt(charaindex,CHAR_DIR) + i); + diry[i] = CHAR_getDY(CHAR_getInt(charaindex,CHAR_DIR) + i); + } + dirx[0] = CHAR_getDX(CHAR_getInt(charaindex,CHAR_DIR)); + diry[0] = CHAR_getDY(CHAR_getInt(charaindex,CHAR_DIR)); + dirx[8] = 0; + diry[8] = 0; + floor = CHAR_getInt( charaindex,CHAR_FLOOR ); + { + int ret; + if( 0 <= itemcharaindex && itemcharaindex < CHAR_STARTITEMARRAY ){ //如果丢弃物为装备 + CHAR_sendItemDetachEvent( charaindex, itemindex ); + } + ret = ITEM_eventDrop( itemindex, charaindex, itemcharaindex ); + if( ret == 1 ){ //-1 物品不存在 1 消失 0 一般物品 + itemindex = -1; + goto END; + }else if( ret == -1 ){ + print( "%s:%d err\n", __FILE__,__LINE__); + return; + }else{ + ; + } + } +#ifdef _MARKET_TRADE + { + int user_floor = CHAR_getInt( charaindex, CHAR_FLOOR); + int item_x = CHAR_getInt( charaindex, CHAR_X)+dirx[0]; + int item_y = CHAR_getInt( charaindex, CHAR_Y)+diry[0]; + if( MAP_TRADEDROP( charaindex, itemindex, user_floor, item_x, item_y) == TRUE ) { + return; + } + } +#endif + droped = 0; + for( i = 0 ; i < 9 ; i ++ ){ + int x=CHAR_getInt(charaindex,CHAR_X)+dirx[i]; + int y=CHAR_getInt(charaindex,CHAR_Y)+diry[i]; +#ifdef _DROPSTAKENEW + // 判断物品是否为彩券 + if(ITEM_getInt(itemindex, ITEM_ID) == CASINOTOKENID){ + int j = 0, k = 0; + int bdropstake = 0; + int casinoflag = 0; + for (j = 0; j < arraysizeof(casinomap); j++){ + if (CHAR_getInt(charaindex, CHAR_FLOOR) == casinomap[j].casinofl){ + if (x == casinomap[j].casinox && y == casinomap[j].casinoy){ + char tmpbuf[256]; + int dropflag = CHAR_getWorkInt(charaindex, CHAR_WORKSTAKEFLAG); + casinoflag = 1; + if(casinomap[j].dropflag == 0){ + CHAR_talkToCli(charaindex, -1, "现在无法下注!", CHAR_COLORYELLOW); + return; + }else{ + snprintf(tmpbuf, sizeof(tmpbuf), "你在 %s 下注了一张彩券", casinomap[j].casinoinfo); + if(dropflag >= MAXSTAKENUM){ + snprintf(tmpbuf, sizeof(tmpbuf), "你已经下注五次了,无法再下注!"); + CHAR_talkToCli(charaindex, -1, tmpbuf, CHAR_COLORYELLOW); + return; + } + for(k = 0; k < MAXSTAKENUM; k++){ + if(CHAR_getWorkInt(charaindex, CHAR_WORKSTAKETYPE1 + k) == 0){ + CHAR_setWorkInt(charaindex, CHAR_WORKSTAKETYPE1 + k, casinomap[j].casinotype); + casinomap[j].stakenum = casinomap[j].stakenum + 1; + if(casinomap[j].stakenum >= 100000000) + casinomap[j].stakenum = 100000000; + dropflag++; + if(casinomap[j].stakenum <= 1) + bdropstake = 1; + break; + } + } + } + CHAR_talkToCli(charaindex, -1, tmpbuf, CHAR_COLORYELLOW); +#ifdef _FIX_GAMBLENUM + //做扣点的动作 + if (dropflag <= MAXSTAKENUM){ + int nAcc = CHAR_getInt(charaindex, CHAR_GAMBLENUM); + nAcc -= casinomap[j].accumulation; + CHAR_setInt(charaindex, CHAR_GAMBLENUM, nAcc); + } +#endif + if (dropflag >= MAXSTAKENUM){ + dropflag = 0; + for (k = 0; k < MAXSTAKENUM ; k++){ + if (CHAR_getWorkInt(charaindex, CHAR_WORKSTAKETYPE1 + k) > 0) + dropflag++; + } + CHAR_setWorkInt(charaindex, CHAR_WORKSTAKEFLAG, dropflag); + }else{ + CHAR_setWorkInt(charaindex, CHAR_WORKSTAKEFLAG, dropflag); + } + continue; + } + } + } + + // 此地方的彩券数量超过一张以上 + if(bdropstake == 0 && casinoflag != 0){ + CHAR_setItemIndex(charaindex, itemcharaindex ,-1); + CHAR_sendItemDataOne(charaindex, itemcharaindex); + LogItem(CHAR_getChar(charaindex, CHAR_NAME), + CHAR_getChar(charaindex, CHAR_CDKEY), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt(itemindex, ITEM_ID), +#endif + "StakeDrop(丢出彩券)", + CHAR_getInt(charaindex,CHAR_FLOOR), + CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y), + ITEM_getChar(itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + + ); + return; + } + } +#endif + { + int ret = CHAR_DropItemFXY( charaindex,itemcharaindex, + CHAR_getInt(charaindex,CHAR_FLOOR), x, y, &objindex ); + switch( ret ){ + case 0: + droped = 1; +#ifdef _ITEM_ORNAMENTS // WON FIX + if( ITEM_getWorkInt( itemindex, ITEM_CANPICKUP) > 0 ){ + ITEM_setInt( itemindex, ITEM_PUTTIME, NowTime.tv_sec + 60*5); + }else{ + ITEM_setInt( itemindex, ITEM_PUTTIME, NowTime.tv_sec); + } +#else + ITEM_setInt( itemindex, ITEM_PUTTIME, NowTime.tv_sec); +#endif + goto END; + break; + case -1: + case -2: + break; + case -3: + default: + return; + break; + } +#ifdef _DROPSTAKENEW + } +#endif + } +#ifdef _DROPCHECK + if( droped != 1 ) { + CHAR_talkToCli( charaindex, -1, "周围的地面已经满了。", CHAR_COLORYELLOW ); + return; + } +#endif +END: + CHAR_sendWatchEvent( objindex, CHAR_ACTSTAND, NULL, 0, TRUE); + CHAR_setItemIndex( charaindex, itemcharaindex ,-1); +{ + char category[3]; + snprintf( category,sizeof( category),"J%d", itemcharaindex); + CHAR_sendStatusString( charaindex , category); +} + if( CHAR_complianceParameter( charaindex ) ){ + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX) ); + } + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + CHAR_send_P_StatusString( charaindex, + CHAR_P_STRING_HP|CHAR_P_STRING_MAXHP| + CHAR_P_STRING_MP|CHAR_P_STRING_MAXMP| + CHAR_P_STRING_ATK|CHAR_P_STRING_DEF| + CHAR_P_STRING_QUICK|CHAR_P_STRING_CHARM| + CHAR_P_STRING_LUCK|CHAR_P_STRING_EARTH| + CHAR_P_STRING_WATER|CHAR_P_STRING_FIRE| + CHAR_P_STRING_WIND + ); + CHAR_sendItemDataOne( charaindex, itemcharaindex); + } + return; +} +#endif + +int CHAR_DropItemAbsolute( int itemindex, int floor, int x, int y, + BOOL net) +{ + Object object; + int objindex; + + if( !ITEM_CHECKINDEX( itemindex) )return FALSE; + + object.type = OBJTYPE_ITEM; + object.index = itemindex; + object.x = x; + object.y = y; + object.floor = floor; + objindex = initObjectOne( &object ); + ITEM_setWorkInt( itemindex,ITEM_WORKOBJINDEX, objindex ); + ITEM_setWorkInt( itemindex,ITEM_WORKCHARAINDEX, -1 ); + if( net ) + CHAR_sendWatchEvent( objindex,CHAR_ACTSTAND,NULL,0,TRUE); + + return objindex; +} + +int CHAR_addItemSpecificItemIndex( int charaindex, int itemindex ) +{ + int emptyindex; + if( CHAR_CHECKINDEX( charaindex) == FALSE) return -1; + if( ITEM_CHECKINDEX( itemindex) == FALSE) return -1; + emptyindex = CHAR_findEmptyItemBox( charaindex ); + if( emptyindex == -1 ){ + return CHAR_MAXITEMHAVE; + }else{ + CHAR_setItemIndex(charaindex,emptyindex,itemindex); + ITEM_setWorkInt(itemindex,ITEM_WORKCHARAINDEX,charaindex); + ITEM_setWorkInt(itemindex,ITEM_WORKOBJINDEX,-1); + } + return emptyindex; +} + +static int CHAR_PickUpItemFXY( int charaindex, int fl ,int x , int y , + int* contents,int* objindex ) +{ + OBJECT object; + + for( object=MAP_getTopObj(fl,x,y) ; object ; object = NEXT_OBJECT(object ) ){ + int index = GET_OBJINDEX(object); + int objtype = OBJECT_getType(index); + if( objtype == OBJTYPE_NOUSE )continue; + else if( objtype == OBJTYPE_ITEM ){ + int ret; + int itemindex = OBJECT_getIndex( index); +#ifdef _MARKET_TRADE //买 + if( ITEM_getWorkInt( itemindex, ITEM_WORKTRADETYPE) == TRADETYPE_SELL ) { + MAP_TRADEPICKUP( charaindex, itemindex, fl, x, y, TRADEITEMTYPE); + return -1; + } +#endif +#ifdef _ITEM_ORNAMENTS + if( ITEM_getWorkInt( itemindex, ITEM_CANPICKUP) > 0 ){ + return -1; + } +#endif +#ifdef _DROPSTAKENEW + // 判断物品是否为彩券 + if(ITEM_getInt(itemindex, ITEM_ID) == CASINOTOKENID){ + int i = 0; + int bdropstake = 0, casinoflag = 0, emptyitemindexinchara = -1; + for(i = 0; i < arraysizeof(casinomap); i++){ + if(fl == casinomap[i].casinofl){ + if(x == casinomap[i].casinox && y == casinomap[i].casinoy){ + int j = 0, stakeflag = 0; + int pickupflag = 0; + casinoflag = 1; + if(casinomap[i].dropflag == 0){ + CHAR_talkToCli(charaindex, -1, "现在已经无法取回下注彩券了!", CHAR_COLORYELLOW); + return -1; + } + stakeflag = CHAR_getWorkInt(charaindex, CHAR_WORKSTAKEFLAG); + if(stakeflag == 0){ + CHAR_talkToCli(charaindex, -1, "您并没有下注,所以无法取回彩券!", CHAR_COLORYELLOW); + return -1; + } + for(j = 0; j < MAXSTAKENUM; j++){ + if(CHAR_getWorkInt(charaindex, CHAR_WORKSTAKETYPE1 + j) == casinomap[i].casinotype){ + emptyitemindexinchara = CHAR_findEmptyItemBox(charaindex); + if(emptyitemindexinchara < 0) return -2; + CHAR_setWorkInt(charaindex, CHAR_WORKSTAKETYPE1 + j, 0); + casinomap[i].stakenum = casinomap[i].stakenum - 1; + stakeflag--; + pickupflag = 1; +#ifdef _FIX_GAMBLENUM + //做加点的动作 + { + int nAcc = CHAR_getInt(charaindex, CHAR_GAMBLENUM); + nAcc += casinomap[i].accumulation; + CHAR_setInt(charaindex, CHAR_GAMBLENUM, nAcc); + } +#endif + if(casinomap[i].stakenum <= 0){ + bdropstake = 1; + casinomap[i].stakenum = 0; + } + break; + } + } + if(stakeflag < 0){ + stakeflag = 0; + for(j = 0; j < MAXSTAKENUM; j++){ + if(CHAR_getWorkInt(charaindex, CHAR_WORKSTAKETYPE1 + j) > 0) + stakeflag++; + } + CHAR_setWorkInt(charaindex, CHAR_WORKSTAKEFLAG, stakeflag); + }else + CHAR_setWorkInt(charaindex, CHAR_WORKSTAKEFLAG, stakeflag); + if(pickupflag == 0){ + CHAR_talkToCli(charaindex, -1, "您没有在此下注,所以无法取回彩券!", CHAR_COLORYELLOW); + return -1; + } + } + } + } + + if(bdropstake == 0 && casinoflag != 0){// 此地方的彩券数量超过一张以上 + char tmpbuf[256]; + if(emptyitemindexinchara != -1){ + int itemid=-1, ret=-1; + itemid = ITEM_makeItemAndRegist(CASINOTOKENID); + if(itemid == -1) return -1; + ret = CHAR_addItemSpecificItemIndex( charaindex, itemid); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + ITEM_endExistItemsOne( itemid ); + return -1; + } + } + CHAR_sendItemDataOne(charaindex, emptyitemindexinchara); + snprintf(tmpbuf, sizeof(tmpbuf), "拾回%s,已将下注取消!", + ITEM_getChar(itemindex, ITEM_NAME)); + CHAR_talkToCli(charaindex, -1, tmpbuf, CHAR_COLORWHITE); + // 记录捡回记录 + LogItem(CHAR_getChar(charaindex, CHAR_NAME), + CHAR_getChar(charaindex, CHAR_CDKEY), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt(itemindex, ITEM_ID), +#endif + "StakePickUp(捡起彩券)", + CHAR_getInt(charaindex,CHAR_FLOOR), + CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y), + ITEM_getChar(itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + return -1; + } + } +#endif + ret = CHAR_addItemSpecificItemIndex( charaindex, itemindex ); + if(ret == CHAR_MAXITEMHAVE ){ + return -2; + }else if( ret != -1 ) { + typedef void (*PICKUPFUNC)( int, int); + PICKUPFUNC pickupfunc = NULL; + pickupfunc = (PICKUPFUNC)ITEM_getFunctionPointer( + itemindex, ITEM_PICKUPFUNC); + if( pickupfunc) pickupfunc( charaindex, itemindex); + + *contents = OBJECT_getIndex(index); + *objindex = index; + CHAR_sendItemDataOne( charaindex, ret); + return 0; + } + }else if( objtype == OBJTYPE_GOLD ){ + int MaxGold; + long dropgoldamount = 0, newamountgold = 0, Minus = 0, newgold = 0; + long mygold = (long) CHAR_getInt( charaindex, CHAR_GOLD ); + MaxGold = CHAR_getMaxHaveGold( charaindex); + if ((mygold <0) || (mygold > MaxGold))return -2; + dropgoldamount = OBJECT_getIndex(index); + newamountgold = (unsigned int) CHAR_getInt( charaindex,CHAR_GOLD ) + dropgoldamount; + Minus = newamountgold - MaxGold; + if( Minus > 0 ) { + newgold = Minus; + *contents = dropgoldamount - Minus; + }else { + newgold = 0; + *contents = dropgoldamount; + } + OBJECT_setIndex( index, newgold); + CHAR_setInt( charaindex, CHAR_GOLD, min( newamountgold, MaxGold ) ); + *objindex = index; + return 1; + }else if( objtype == OBJTYPE_CHARA ) { + int pindex = OBJECT_getIndex( index); + if( !CHAR_CHECKINDEX( pindex) ) continue; + if( CHAR_getInt( pindex, CHAR_WHICHTYPE) == CHAR_TYPEPET ) { + int havepetindex = CHAR_getCharPetElement( charaindex); + if( havepetindex == -1 ) { + if( CHAR_getWorkInt( pindex, CHAR_WORKPETFOLLOWMODE) != CHAR_PETFOLLOW_NOW ) + return -3; + } + if( CHAR_getWorkInt( charaindex, CHAR_PickAllPet) != TRUE ) { + if( (CHAR_getInt( pindex, CHAR_LV) - CHAR_getInt( charaindex, CHAR_LV) > 5 ) + && (CHAR_getInt( charaindex, CHAR_TRANSMIGRATION ) <= 0 )) { + return -4; + } + } + /*if( !strcmp( CHAR_getChar( pindex, CHAR_OWNERCDKEY), "SYSTEM_WAYI" ) && + !strcmp( CHAR_getChar( pindex, CHAR_OWNERCHARANAME), "SYSTEM_WAYI" ) ){ + }else{ + if( strcmp( CHAR_getChar( pindex, CHAR_OWNERCDKEY), CHAR_getChar( charaindex, CHAR_CDKEY) ) || + strcmp( CHAR_getChar( pindex, CHAR_OWNERCHARANAME), CHAR_getChar( charaindex, CHAR_NAME) )){ + return -5; + } + }*/ +#ifdef _MARKET_TRADE + if( CHAR_getWorkInt( pindex, CHAR_WORKTRADETYP) == TRADETYPE_SELL ) { //买宠 + MAP_TRADEPICKUP( charaindex, pindex, fl, x, y, TRADEPETTYPE ); + return -1; + } +#endif + if( CHAR_getWorkInt( pindex, CHAR_WORKPETFOLLOWMODE) == CHAR_PETFOLLOW_NOW ){ + CHAR_pickupFollowPet( charaindex, pindex ); + return -1; + } + /*if( CHAR_getInt( pindex, CHAR_MAILMODE) != CHAR_PETMAIL_NONE){ + if( strcmp( CHAR_getChar( pindex, CHAR_OWNERCDKEY), + CHAR_getChar( charaindex, CHAR_CDKEY)) != 0 || + strcmp( CHAR_getChar( pindex, CHAR_OWNERCHARANAME), + CHAR_getChar( charaindex, CHAR_NAME))!= 0 ){ + return -5; + }else if( CHAR_getInt( pindex, CHAR_MAILMODE) != CHAR_PETMAIL_IDLE5){ + return -5; + } + }*/ + if( CHAR_getInt( pindex, CHAR_MAILMODE) != CHAR_PETMAIL_NONE){ + Char *ch; + CHAR_setInt( pindex, CHAR_MAILMODE, CHAR_PETMAIL_NONE); + CHAR_setInt( pindex, CHAR_PETMAILIDLETIME, 0); + PETMAIL_delPetMailTotalnums( 1); //手动捡起mail PET + ch = CHAR_getCharPointer( pindex); + if( ch != NULL ) { + strcpysafe( ch->charfunctable[CHAR_LOOPFUNC].string, + sizeof( ch->charfunctable[CHAR_LOOPFUNC]), ""); + CHAR_constructFunctable( pindex); + } + } + CHAR_setWorkInt( pindex, CHAR_WORKPLAYERINDEX, charaindex); + CHAR_setCharPet( charaindex, havepetindex, pindex); +#ifdef _PET_TALK + if( CHAR_getInt( pindex, CHAR_PETID) != 718 ) { +#endif + CHAR_setChar( pindex, CHAR_OWNERCDKEY, + CHAR_getChar( charaindex, CHAR_CDKEY)); + CHAR_setChar( pindex, CHAR_OWNERCHARANAME, + CHAR_getChar( charaindex, CHAR_NAME)); +#ifdef _PET_TALK + } +#endif + CHAR_complianceParameter( pindex); +{ + char category[3]; + snprintf( category,sizeof( category),"K%d",havepetindex); + CHAR_sendStatusString( charaindex, category); + snprintf( category,sizeof( category),"W%d",havepetindex); + CHAR_sendStatusString( charaindex, category); +} + CHAR_setInt( pindex, CHAR_PUTPETTIME, 0); + *contents = pindex; + *objindex = index; + return 2; + } + } + } + return -1; +} + +void CHAR_PickUpItem( int charaindex, int dir ) +{ + int i; + int dirx[2],diry[2]; + int searchloopcount=0; + + if( !CHAR_CHECKINDEX(charaindex) )return; + if( CHAR_getFlg( charaindex,CHAR_ISDIE ) )return; + if( CHAR_getWorkInt( charaindex,CHAR_WORKBATTLEMODE ) )return; + if( dir < 0 ){ + searchloopcount = 1; + dirx[0] = 0; + diry[0] = 0; + }else{ + if( dir != CHAR_getInt( charaindex, CHAR_DIR)) { + VALIDATEDIR(dir); + CHAR_setInt(charaindex,CHAR_DIR,dir); + CHAR_sendWatchEvent(CHAR_getWorkInt(charaindex,CHAR_WORKOBJINDEX), + CHAR_ACTSTAND,NULL,0,FALSE); + } + dirx[0] = CHAR_getDX(CHAR_getInt(charaindex,CHAR_DIR)); + diry[0] = CHAR_getDY(CHAR_getInt(charaindex,CHAR_DIR)); + dirx[1] = 0; + diry[1] = 0; + searchloopcount=2; + } + for( i = 0 ; i < searchloopcount ; i ++ ){ + int contents,objindex; + int fl = CHAR_getInt(charaindex,CHAR_FLOOR); + + int y = CHAR_getInt(charaindex,CHAR_Y)+diry[i]; + int x = CHAR_getInt(charaindex,CHAR_X)+dirx[i]; + int ret = CHAR_PickUpItemFXY( charaindex,fl,x,y,&contents, + &objindex); + switch( ret ){ + case 0: + CHAR_ObjectDelete(objindex); + { + char mesg[256]; +#ifdef _DROPSTAKENEW + int j = 0; + int dropflag = 0; + for(j = 0; j < arraysizeof(casinomap); j++) + { + if(CHAR_getInt(charaindex, CHAR_FLOOR) == casinomap[j].casinofl) + { + if(x == casinomap[j].casinox && y == casinomap[j].casinoy) + { + dropflag = 1; + break; + } + } + } + if(ITEM_getInt(contents, ITEM_ID) == CASINOTOKENID && dropflag == 1) + snprintf( mesg,sizeof(mesg), "拾回%s,已将下注取消!", + ITEM_getAppropriateName(contents)); + else +#endif + snprintf( mesg,sizeof(mesg), "拾获 %s", + ITEM_getAppropriateName(contents) ); + CHAR_talkToCli(charaindex,-1,mesg,CHAR_COLORWHITE); + } + + { + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + contents, +#else + ITEM_getInt(contents, ITEM_ID), +#endif + "PickUp(捡起道具)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( contents, ITEM_UNIQUECODE), + ITEM_getChar( contents, ITEM_NAME), + ITEM_getInt( contents, ITEM_ID) + ); + } + + return; + break; + case 1: + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_GOLD); + + if( OBJECT_getIndex( objindex) == 0 ) { + CHAR_ObjectDelete(objindex); + }else { + CHAR_sendWatchEvent(objindex,CHAR_ACTSTAND,NULL,0,TRUE); + } + { + char mesg[256]; + if( contents == 0 ) { + snprintf( mesg,sizeof(mesg), "无法再拾获Stone了。" ); + }else { + snprintf( mesg,sizeof(mesg), "拾获 %d Stone",contents ); + } + CHAR_talkToCli(charaindex,-1,mesg,CHAR_COLORWHITE); + } + if( contents != 0 ){ + LogStone( + -1, + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), + contents, + CHAR_getInt( charaindex, CHAR_GOLD ), + "PickUp(拾获金钱)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ) + ); + } + return; + break; + case 2: //宠物 + CHAR_ObjectDelete(objindex); + CHAR_setWorkInt( contents, CHAR_WORKOBJINDEX, -1); + { + char mesg[256]; + char *p = NULL; + p = CHAR_getChar( contents, CHAR_USERPETNAME); + if( strlen( p) == 0 ) { + p = CHAR_getChar( contents, CHAR_NAME); + } + + snprintf( mesg,sizeof(mesg), "拾获 %s", p); + CHAR_talkToCli(charaindex,-1,mesg,CHAR_COLORWHITE); + } + // 矢永玄毛胶匀凶夫弘 + LogPet( + CHAR_getChar( charaindex, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( charaindex, CHAR_CDKEY ), + CHAR_getChar( contents, CHAR_NAME), + CHAR_getInt( contents, CHAR_LV), + "PickUp(捡宠)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + CHAR_getChar( contents, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + return; + break; + // Robin 0701 petFollow + case 3: + + /* 引歹曰卞仇木毛壅六午中丹 */ + CHAR_ObjectDelete(objindex); + CHAR_setWorkInt( contents, CHAR_WORKOBJINDEX, -1); + { + char mesg[256]; + char *p = NULL; + p = CHAR_getChar( contents, CHAR_USERPETNAME); + if( strlen( p) == 0 ) { + p = CHAR_getChar( contents, CHAR_NAME); + } + + snprintf( mesg,sizeof(mesg), "拾回 %s", p); + CHAR_talkToCli(charaindex,-1,mesg,CHAR_COLORWHITE); + } + // 矢永玄毛胶匀凶夫弘 + LogPet( + CHAR_getChar( charaindex, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( charaindex, CHAR_CDKEY ), + CHAR_getChar( contents, CHAR_NAME), + CHAR_getInt( contents, CHAR_LV), + "FollowPickUp(收回溜宠)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + CHAR_getChar( contents, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + + return; + break; + case -1: + break; + case -2: + CHAR_talkToCli( charaindex,-1,"道具栏已满。", CHAR_COLORYELLOW); + break; + case -3: + CHAR_talkToCli( charaindex,-1,"宠物数已满。", CHAR_COLORYELLOW); + break; + case -4: + CHAR_talkToCli( charaindex,-1,"无法照顾该宠物。", CHAR_COLORYELLOW); + break; + case -5: + CHAR_talkToCli( charaindex,-1,"无法拾获该宠物。", CHAR_COLORYELLOW); + break; + case -6: + CHAR_talkToCli( charaindex,-1,"无法拾获该道具。", CHAR_COLORYELLOW); + break; + default: + return; + } + } + return; +} + +/*------------------------------------------------------------ + * 云嗯毛甄 隙烂匹 公丹午允月[CHAR_DropMoney井日及心匹银丹仪[ + * 娄醒 + * charaindex int 平乓仿奶件犯永弁旦 + * itemindex int 失奶 丞奶件犯永弁旦(平乓仿犯□正及 匹及) + * fl int 白夫失 + * x int x + * y int y + * force BOOL 仇及袄互恳分午 泫 允 + * objindex int* 中凶失奶 丞及 Object 匹及奶件犯弁永旦 + * 忒曰袄 + * 撩 (公氏卅卞云嗯毛 匀化中卅中) -1 + * 撩 (哗溥读卞分户) -2 + * 公木动陆及撩 -3 + * 撩 (公仇卞反公及汹及云嗯反聂允亢月) -4 + * 允匹卞职及失奶 丞互 切化中月 -5 + * 汹互 匹 [ -6 + * 岳 0 + ------------------------------------------------------------*/ +static BOOL CHAR_DropMoneyFXY( int charaindex, int amount, int fl , int x, + int y, BOOL force, int* objindex ) +{ + OBJECT object; + int MaxGold; + int mygold = CHAR_getInt( charaindex, CHAR_GOLD ); + if( amount <= 0 )return -6; + if( amount > mygold ) + return -1; + + MaxGold = CHAR_getMaxHaveGold( charaindex); + if ((mygold <0) || (mygold > MaxGold)) return -1; + + if( MAP_walkAbleFromPoint( fl,x,y,FALSE ) == FALSE )return -2; + for( object=MAP_getTopObj(fl,x,y) ; object; + object = NEXT_OBJECT(object) ){ + int index = GET_OBJINDEX(object); + int objtype = OBJECT_getType(index); + + if( objtype == OBJTYPE_NOUSE ) continue; + else if( objtype == OBJTYPE_GOLD ){ + long tmpamount = OBJECT_getIndex(index) + amount; + if( tmpamount > MaxGold ) + return -4; + OBJECT_setIndex(index,tmpamount); + CHAR_setInt(charaindex,CHAR_GOLD, + (unsigned int)CHAR_getInt(charaindex, + CHAR_GOLD ) + - amount ); + *objindex = index; +#ifdef _DEL_DROP_GOLD + OBJECT_setTime( index, NowTime.tv_sec); +#endif + if( amount >= 100 ){ /* 云嗯毛 中凶夫弘 */ + LogStone(-1,CHAR_getChar( charaindex, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( charaindex, CHAR_CDKEY ), /* 交□扒□ID */ + amount, /* 嗯喊 */ + CHAR_getInt( charaindex, CHAR_GOLD ), + "Drop(放置金钱)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ) + ); + } + return 0; + }else if( objtype == OBJTYPE_ITEM ){ + if( force==TRUE ) + continue; + else + /* 允匹卞失奶 丞互丐月及匹分户 */ + return -5; + } + } + + /* 仇仇引匹谗琼允月午中丹仪反蕙筋瓒 允月 */ + { + Object one; + one.type = OBJTYPE_GOLD; + one.x = x; + one.y = y; + one.floor = fl; + + if( amount > MaxGold ) + return -4; + + one.index = amount; + *objindex = initObjectOne( &one ); + /* 左皮斥尼弁玄瓒 允月 */ + if( *objindex == -1 ) + /* 瓒 撩 */ + return -3; + + /*云嗯毛蛹日允*/ + CHAR_setInt(charaindex,CHAR_GOLD, + (unsigned int)CHAR_getInt(charaindex,CHAR_GOLD ) + - amount ); +#ifdef _DEL_DROP_GOLD + OBJECT_setTime( *objindex, NowTime.tv_sec); +#endif + if( amount >= 100 ){ /* 云嗯毛 中凶夫弘 */ + LogStone(-1,CHAR_getChar( charaindex, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( charaindex, CHAR_CDKEY ), /* 交□扒□ID */ + amount, /* 嗯喊 */ + CHAR_getInt( charaindex, CHAR_GOLD ), + "Drop(放置金钱)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ) + ); + } + return 0; + } +} + +/*------------------------------------------------------------ + * 云嗯毛 允楮醒[ 及蟆井日 允[ + * 娄醒 + * charaindex int 平乓仿奶件犯永弁旦 + * amount int 云嗯及汹 + * + * 忒曰袄 + * 卅仄 + ------------------------------------------------------------*/ +void CHAR_DropMoney( int charaindex, int amount ) +{ + int dirx[9],diry[9]; + int ret; + int i; + int objindex, MaxGold; + + if( !CHAR_CHECKINDEX( charaindex ) )return; + +#ifdef _AVID_TRADETRYBUG //丢出石币 + if( CHAR_getWorkInt( charaindex, CHAR_WORKTRADEMODE) == CHAR_TRADE_TRADING ){ + CHAR_talkToCli( charaindex, -1, "交易状态中无法丢出石币。", CHAR_COLORYELLOW ); + return; + } +#endif + + MaxGold = CHAR_getMaxHaveGold( charaindex); + if( CHAR_getFlg( charaindex,CHAR_ISDIE ) )return; + + //ANDY_ADD 12/28 + { + int money=0; + money = CHAR_getInt( charaindex, CHAR_GOLD ); + if( money < 0 ) { + CHAR_setInt( charaindex, CHAR_GOLD, 0); + return; + } + if( (amount > money) || (money > MaxGold)) { + if( money > MaxGold ) { + CHAR_setInt( charaindex, CHAR_GOLD, 0 ); + print("\n ERR: %s(stone%d) dropMoney%d > CHAR_MAXGOLDHAVE !!", + CHAR_getChar(charaindex, CHAR_CDKEY), money, amount); + }else { + print("\n ERR: %s dropMoney > CHAR_GOLD !!", CHAR_getChar(charaindex, CHAR_CDKEY)); + } + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_GOLD); + return; + } + } + //ANDY_END + for( i = 0 ; i < 7 ; i ++ ){ + dirx[i+2] = CHAR_getDX( CHAR_getInt(charaindex,CHAR_DIR) + i+1 ); + diry[i+2] = CHAR_getDY( CHAR_getInt(charaindex,CHAR_DIR) + i+1 ); + } + + dirx[0] = CHAR_getDX(CHAR_getInt(charaindex,CHAR_DIR)); + diry[0] = CHAR_getDY(CHAR_getInt(charaindex,CHAR_DIR)); + dirx[1] = 0; + diry[1] = 0; + + for( i = 0 ; i < 9 ; i ++ ){ + int x = CHAR_getInt(charaindex,CHAR_X) + dirx[i]; + int y = CHAR_getInt(charaindex,CHAR_Y) + diry[i]; + +// CoolFish 2002/04/06 下注处不可丢置石币 +#ifdef _DROPSTAKENEW + { + int j = 0; + for(j = 0; j < arraysizeof(casinomap); j++) + { + if(CHAR_getInt(charaindex, CHAR_FLOOR) == casinomap[j].casinofl) + { + if (x == casinomap[j].casinox && y == casinomap[j].casinoy) + { + CHAR_talkToCli(charaindex, -1, "这里不能放置石币!", CHAR_COLORYELLOW); + return; + } + } + } + } +#endif + ret = CHAR_DropMoneyFXY( charaindex,amount, + CHAR_getInt(charaindex,CHAR_FLOOR), + x,y, FALSE, &objindex ); + switch( ret ){ + case 0: + goto END; + break; + case -1: + return; + break; + case -3: + return; + break; + case -2: + case -4: + case -5: + case -6: + break; + default: + break; + } + } + + { + int x = CHAR_getInt(charaindex,CHAR_X) + dirx[1]; + int y = CHAR_getInt(charaindex,CHAR_Y) + diry[1]; + + ret = CHAR_DropMoneyFXY( charaindex,amount, + CHAR_getInt(charaindex,CHAR_FLOOR), + x,y, TRUE, &objindex ); + switch( ret ){ + case 0: + goto END; + break; + case -1: + break; + case -3: + return; + break; + case -2: + case -4: + case -5: + break; + default: + break; + } + return; + } + +END: + CHAR_sendWatchEvent(objindex,CHAR_ACTSTAND,NULL,0,TRUE ); + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_GOLD); + return; +} + +static int CHAR_findEmptyItemBoxNoFromChar( Char* ch ) +{ + int i, j=0;; + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE ; i ++ ){ + int itemindex; + itemindex = ch->indexOfExistItems[i]; + if( itemindex == -1 ) j++; + } + return j; +} + +int CHAR_findEmptyItemBoxNo( int index ) +{ + Char* ch; + + if( !CHAR_CHECKINDEX( index ) )return -1; + ch = CHAR_getCharPointer(index); + if( ch != NULL ) + return CHAR_findEmptyItemBoxNoFromChar( ch ); + else + return -1; + +} + +// CoolFish: Trade 2001/4/4 +int CHAR_findTotalEmptyItem( int index ) +{ + int i, totaleptitem = 0; + Char* ch; + + if( !CHAR_CHECKINDEX( index ) )return -1; + ch = CHAR_getCharPointer(index); + if( ch != NULL ){ + for (i = CHAR_STARTITEMARRAY; i < CHAR_MAXITEMHAVE; i++){ + int itemindex = 0; + itemindex = ch->indexOfExistItems[i]; + if (itemindex == -1) totaleptitem++; + } + return totaleptitem; + } + + return -1; +} + +// Robin 0707 petFollow +int CHAR_pickupFollowPet( int charaindex, int pickupindex ) +{ + int petindex; + int objindex; + int havepetindex; + char category[3]; + + if( !CHAR_CHECKINDEX( charaindex ) ) return FALSE; + + if( pickupindex != -1 ) + petindex = pickupindex; + else + petindex = CHAR_getWorkInt( charaindex, CHAR_WORKPETFOLLOW ); + + if( !CHAR_CHECKINDEX( petindex ) ) + { + CHAR_setWorkInt( charaindex, CHAR_WORKPETFOLLOW, -1 ); + return FALSE; + } + + havepetindex = CHAR_getCharPetElement( charaindex); + if( havepetindex == -1 ) { + CHAR_talkToCli(charaindex,-1,"宠物栏已满!无法拾回!",CHAR_COLORYELLOW); + return FALSE; + } + + objindex = CHAR_getWorkInt( petindex, CHAR_WORKOBJINDEX ); + print(" objindex02:%d ", objindex); + + if( (pickupindex == -1) || (pickupindex == CHAR_getWorkInt( charaindex, CHAR_WORKPETFOLLOW ) ) ) + CHAR_setWorkInt( charaindex, CHAR_WORKPETFOLLOW, -1 ); + + /* CDKEY 午平乓仿 互域谯仄卅中午五反胶尹卅中 */ + if( strcmp( CHAR_getChar( petindex, CHAR_OWNERCDKEY), CHAR_getChar( charaindex, CHAR_CDKEY)) != 0 || + strcmp( CHAR_getChar( petindex, CHAR_OWNERCHARANAME), CHAR_getChar( charaindex, CHAR_NAME)) != 0 ) + { + //CHAR_setWorkInt( charaindex, CHAR_WORKPETFOLLOW, -1 ); + + return FALSE; + } + + + //CHAR_setWorkInt( charaindex, CHAR_WORKPETFOLLOW, -1 ); + + CHAR_ObjectDelete(objindex); + + CHAR_setWorkInt( petindex, CHAR_WORKPETFOLLOWMODE, CHAR_PETFOLLOW_NONE ); + + CHAR_setWorkInt( petindex, CHAR_WORKPLAYERINDEX, charaindex); + CHAR_setCharPet( charaindex, havepetindex, petindex); + +#ifdef _PET_TALK + if( CHAR_getInt( petindex, CHAR_PETID) != 718 ) { +#endif + CHAR_setChar( petindex, CHAR_OWNERCDKEY, CHAR_getChar( charaindex, CHAR_CDKEY)); + CHAR_setChar( petindex, CHAR_OWNERCHARANAME, CHAR_getChar( charaindex, CHAR_NAME)); +#ifdef _PET_TALK + } +#endif + + snprintf( category,sizeof( category),"K%d",havepetindex); + CHAR_sendStatusString( charaindex, category); + snprintf( category,sizeof( category),"W%d",havepetindex); + CHAR_sendStatusString( charaindex, category); + + CHAR_setInt( petindex, CHAR_PUTPETTIME, 0); + CHAR_setWorkInt( petindex, CHAR_WORKPETFOLLOWCOUNT, 0); + + + CHAR_setWorkInt( petindex, CHAR_WORKOBJINDEX, -1); + + { + char mesg[256]; + char *p = NULL; + p = CHAR_getChar( petindex, CHAR_USERPETNAME); + if( strlen( p) == 0 ) { + p = CHAR_getChar( petindex, CHAR_NAME); + } + snprintf( mesg,sizeof(mesg), "拾回 %s", p); + CHAR_talkToCli(charaindex,-1,mesg,CHAR_COLORYELLOW); + } + // 矢永玄毛胶匀凶夫弘 + LogPet( + CHAR_getChar( charaindex, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( charaindex, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "FollowPickUp(收回溜宠)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + + return TRUE; + +} +#ifdef _GAMBLE_ROULETTE +int NPC_MAPCLEANGOLD( int meindex , int floor) +{ + OBJECT object; + int x,y,fl; + int End_type; + fl = floor; + + for( End_type = 0; End_type < arraysizeof(casinomap) ; End_type++ ) { + if( floor != casinomap[ End_type].casinofl ) + continue; + x = casinomap[ End_type].casinox; + y = casinomap[ End_type].casinoy; + + for( object=MAP_getTopObj(fl,x,y) ; object ; object = NEXT_OBJECT(object ) ) { + int index = GET_OBJINDEX(object); + int objtype = OBJECT_getType(index); + int itemindex = OBJECT_getIndex( index); + + if( objtype == OBJTYPE_NOUSE )continue; + if( objtype == OBJTYPE_ITEM ){ + if(ITEM_getInt(itemindex, ITEM_ID) == CASINOTOKENID) { + ITEM_endExistItemsOne( itemindex); + OBJECT_setIndex( index, 0); + CHAR_ObjectDelete(index); //清除 + print(" clean( %d )", index ); + } + break; + } + } + casinomap[End_type].stakenum = 0; + } + return 1; +} +#endif + +#ifdef _DROPSTAKENEW +// casinotype : flg = 0 不分type,针对整层type做设定;扩充参数 +// mapdropflag : TRUE = 可以下注; +int SetCasinoMap(int npcindex, int casinotype, int mapdropflag) +{ + int npcfloor = CHAR_getInt(npcindex, CHAR_FLOOR); + int i = 0; + if (casinotype < 0 || mapdropflag < 0) + return -1; + for (i = 0; i < arraysizeof(casinomap); i++) + { + if (npcfloor == casinomap[i].casinofl) + { + if (casinotype != 0) + { + if (casinomap[i].casinotype == casinotype) + casinomap[i].dropflag = mapdropflag; + } + else + casinomap[i].dropflag = mapdropflag; + } + } + return 1; +} + +// 计算积分 +int CasinoAccumulation(int charindex, int npcindex, int floor, int wincasinotype) +{ + int i = 0; + int accumulation = CHAR_getInt(charindex, CHAR_GAMBLENUM); + char tmpbuf[256]; + for (i = 0; i < MAXSTAKENUM; i++) + { + if (CHAR_getWorkInt(charindex, CHAR_WORKSTAKETYPE1 + i) == wincasinotype) + { + int j = 0; + for (j = 0; j < arraysizeof(casinomap); j++) + { + if (casinomap[j].casinotype == wincasinotype) + { +#ifdef _FIX_GAMBLENUM + // 加 原本积分及WIN积分 + accumulation = accumulation + casinomap[j].accumulation * 2; +#else + accumulation += casinomap[j].accumulation; +#endif + CHAR_setWorkInt(charindex, CHAR_WORKSTAKETYPE1 + i, 0); + break; + } + } + } + + else if (CHAR_getWorkInt(charindex, CHAR_WORKSTAKETYPE1 + i) != 0) + { + int j = 0; + for (j = 0; j < arraysizeof(casinomap); j++) + { + if (casinomap[j].casinotype == CHAR_getWorkInt(charindex, CHAR_WORKSTAKETYPE1 + i)) + { +#ifndef _FIX_GAMBLENUM + accumulation -= casinomap[j].accumulation; +#endif + CHAR_setWorkInt(charindex, CHAR_WORKSTAKETYPE1 + i, 0); + break; + } + } + } + } + CHAR_setWorkInt(charindex, CHAR_WORKSTAKEFLAG, 0); + if (accumulation < 0) + accumulation = 0; + else if (accumulation > MAXACCUMULATION) + accumulation = MAXACCUMULATION; + CHAR_setInt(charindex, CHAR_GAMBLENUM, accumulation); + snprintf(tmpbuf, sizeof(tmpbuf), "您现在总共有%4d点游乐场积分", accumulation); + CHAR_talkToCli(charindex, npcindex, tmpbuf, CHAR_COLORWHITE); + return 1; +} + +int CasinoPay(int npcindex, int wincasinotype) +{ + int npcfloor = CHAR_getInt(npcindex, CHAR_FLOOR); + int i = 0; + int playernum = CHAR_getPlayerMaxNum(); + if (wincasinotype < 0) return FALSE; + for (i = 0; i < playernum; i++) + { + if (CHAR_getCharUse(i) == FALSE) continue; + if (!CHAR_CHECKINDEX(i)) continue; + if (CHAR_getInt(i, CHAR_FLOOR) == npcfloor) + { + // 查询玩家是否有下注 + if (CHAR_getWorkInt(i, CHAR_WORKSTAKEFLAG) == 0) + continue; + // 计算积分 + CasinoAccumulation(i, npcindex, npcfloor, wincasinotype); + } + } + // 清除此层地面彩券 + for (i = 0; i < arraysizeof(casinomap); i++) + { + OBJECT object; + if (casinomap[i].casinofl != npcfloor) continue; + for (object = MAP_getTopObj(casinomap[i].casinofl, casinomap[i].casinox, + casinomap[i].casinoy); object; object = NEXT_OBJECT(object)) + { + int index = GET_OBJINDEX(object); + int objtype = OBJECT_getType(index); + int itemindex = OBJECT_getIndex( index); + if (objtype == OBJTYPE_NOUSE) continue; + else if (objtype == OBJTYPE_ITEM) + { + if(ITEM_getInt(itemindex, ITEM_ID) == CASINOTOKENID) + { + OBJECT_setIndex(index, 0); + CHAR_ObjectDelete(index); + } + } + } + casinomap[i].stakenum = 0; + } + return TRUE; +} +#endif + + diff --git a/gmsv/char/char_party.c b/gmsv/char/char_party.c new file mode 100644 index 0000000..cc643ae --- /dev/null +++ b/gmsv/char/char_party.c @@ -0,0 +1,635 @@ +#include "version.h" +#include + +#include "readmap.h" +#include "object.h" +#include "char.h" +#include "char_base.h" +#include "battle.h" +#include "lssproto_serv.h" +#include "npcutil.h" +#include "npc_bus.h" +#include "npc_airplane.h" // Arminius 7.10 Airplane +#include "family.h" // shan + +#ifdef _ITEM_QUITPARTY +#include "init.h" +#endif +// shan add +extern struct FM_PKFLOOR fmpkflnum[FAMILY_FMPKFLOOR]; + +/*------------------------------------------------------------ + * 由□ 奴楮 及末□旦 + ------------------------------------------------------------*/ + +/*------------------------------------------------------------ + * 坞中化中月由□ 奴 毛茧允 + * 卅仃木壬-1毛忒允[ + ------------------------------------------------------------*/ +int CHAR_getEmptyPartyArray( int charaindex) +{ + int i = -1; + int rc = FALSE; + int toindex; + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_NONE ) { + toindex = charaindex; + } + else { + toindex = CHAR_getPartyIndex( charaindex, 0); + } + if( CHAR_CHECKINDEX( toindex)){ + for( i = 1; i < CHAR_PARTYMAX; i ++ ) { + if( CHAR_getWorkInt( toindex, i + CHAR_WORKPARTYINDEX1) == -1 ) { + rc = TRUE; + break; + } + } + } + return( rc ? i: -1); +} +/*------------------------------------------------------------ + * 端卞由□ 奴卞 月质 + * + * charaindex int 愤坌 + * targetindex int 月锹澎及谛 + ------------------------------------------------------------*/ +void CHAR_JoinParty_Main( int charaindex, int targetindex) +{ + int firstflg = FALSE; + int i; + char c[3]; + char buf[64]; + int toindex; + int parray; + + /* 褪互中凶日娄匀舰曰请允 */ + if( CHAR_getWorkInt( targetindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_NONE ) { + toindex = targetindex; + } + else { + toindex = CHAR_getPartyIndex( targetindex, 0); + if( !CHAR_CHECKINDEX( toindex) ) { + print( " %s:%d err\n", __FILE__, __LINE__); + return; + } + } + + + /* 锹澎由□ 奴及谛醒反 井" */ + parray = CHAR_getEmptyPartyArray( toindex) ; + if( parray == -1 ) { + print( "%s : %d err\n", __FILE__,__LINE__); + return; + } + /* 窒手 仄 褪及凛反褪卞卅匀凶CA毛霜耨允月 */ + if( CHAR_getWorkInt( toindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_NONE ) { + CHAR_sendLeader( CHAR_getWorkInt( toindex, CHAR_WORKOBJINDEX), 1); + /* 锹澎及橇谪及踏五晶尹 */ + /* 褪卞卅月 */ + CHAR_setWorkInt( toindex, CHAR_WORKPARTYMODE, 1); + CHAR_setWorkInt( toindex, CHAR_WORKPARTYINDEX1, toindex); + firstflg = TRUE; + } + CHAR_setWorkInt( toindex, parray + CHAR_WORKPARTYINDEX1, charaindex); + + CHAR_setWorkChar( charaindex, CHAR_WORKWALKARRAY, ""); + + CHAR_setWorkInt( charaindex, CHAR_WORKPARTYMODE, CHAR_PARTY_CLIENT); + + CHAR_setWorkInt( charaindex, CHAR_WORKPARTYINDEX1, toindex); + + if( firstflg ) { + CHAR_sendStatusString( toindex, "N0"); + } + + + for( i = 0; i < CHAR_PARTYMAX; i ++ ) { + int index = CHAR_getWorkInt( toindex, i + CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX(index)) { + snprintf( c, sizeof(c), "N%d", i); + CHAR_sendStatusString( charaindex, c); + } + } + + snprintf( buf,sizeof( buf), "%s 加入团队!", + CHAR_getChar( charaindex, CHAR_NAME)); + + for( i = 0; i < CHAR_PARTYMAX; i ++ ) { + int index = CHAR_getWorkInt( toindex, i + CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX(index)) { + if( index != charaindex ) { + snprintf( c, sizeof(c), "N%d", parray); + CHAR_sendStatusString( index, c); + CHAR_talkToCli( index, -1, buf, CHAR_COLORYELLOW); + } + else { + CHAR_talkToCli( index, -1, "加入团队!", CHAR_COLORYELLOW); + } + } + } +} +/*------------------------------------------------------------ + * 由□ 奴卞 欠丹午允月[ + ------------------------------------------------------------*/ +BOOL CHAR_JoinParty( int charaindex ) +{ + + int result = -1; + int x,y; + OBJECT object; + int found = FALSE; + int fd; + int cnt; + int i; + + fd = getfdFromCharaIndex( charaindex ); + if( fd == -1 ) { + print( "%s : %d err\n", __FILE__, __LINE__); + return FALSE; + } + + /* 愤坌互由□ 奴赚氏匹凶日蛲 */ + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE ) { + lssproto_PR_send( fd, 1, FALSE); + return FALSE; + } + + /* 及蟆及甄 毛 月 */ + CHAR_getCoordinationDir( CHAR_getInt( charaindex, CHAR_DIR ) , + CHAR_getInt( charaindex , CHAR_X ), + CHAR_getInt( charaindex , CHAR_Y ) , + 1 , &x , &y ); + + /* 赓渝祭允月 */ + for( i = 0; i < CONNECT_WINDOWBUFSIZE; i ++ ) { + CONNECT_setJoinpartycharaindex(fd,i,-1); + } + cnt = 0; + + /*愤坌及 及蟆及平乓仿毛潸 允月 */ + + for( object = MAP_getTopObj( CHAR_getInt( charaindex, CHAR_FLOOR),x,y) ; + object ; + object = NEXT_OBJECT(object ) ) + { + int toindex; + int parray; + int objindex = GET_OBJINDEX(object); + int targetindex = -1; + + /* 平乓仿弁正□元扎卅中 */ + if( OBJECT_getType( objindex) != OBJTYPE_CHARA) continue; + toindex = OBJECT_getIndex( objindex); + + // shan begin + if( CHAR_getInt(charaindex, CHAR_FMINDEX) > 0 && CHAR_getInt(toindex, CHAR_FMINDEX) >0){ + for( i = 0; i < FAMILY_FMPKFLOOR; i++){ + if( fmpkflnum[i].fl == CHAR_getInt( charaindex, CHAR_FLOOR) ) + if( CHAR_getInt(charaindex, CHAR_FMINDEX) != CHAR_getInt(toindex, CHAR_FMINDEX) ){ + lssproto_PR_send( fd, 1, FALSE); + return FALSE; + } + } + } + // shan end + + /* 皿伊奶乩□及凛 */ + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ){ + found = TRUE; + /* 锹澎互阂分匀凶日褪毛娄匀舰曰请允 */ + if( CHAR_getWorkInt( toindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_CLIENT ) { + targetindex = CHAR_getWorkInt( toindex, CHAR_WORKPARTYINDEX1); + if( !CHAR_CHECKINDEX( targetindex) ) { + print( " %s:%d err\n", __FILE__, __LINE__); + continue; + } + if( CHAR_getInt( targetindex, CHAR_WHICHTYPE) == CHAR_TYPEBUS) { + continue; + } + } + else { + targetindex = toindex; + } + + /* 褪午 ㄠ汹动 卞中月井 */ + if( NPC_Util_CharDistance( charaindex, targetindex ) > 1) { + continue; + } + + /* 爵 反匹卅中仪[*/ + if( CHAR_getWorkInt( targetindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE ){ + continue; + } + /* 醮棉袱第乒□玉井 */ + if( !CHAR_getFlg( targetindex, CHAR_ISPARTY) ) continue; + +#ifdef _ANGEL_SUMMON + if( CHAR_getWorkInt( targetindex, CHAR_WORKANGELMODE) == TRUE) { + CHAR_talkToCli( charaindex, -1, "使者不可以当领队。", CHAR_COLORYELLOW); + continue; + } +#endif +#ifdef _ESCAPE_RESET // 使用恶宝逃跑後x分钟内不可与人组队 + if( getStayEncount( getfdFromCharaIndex(targetindex) ) ) { + //print(" 恶宝中组队 "); + if( time(NULL) - CHAR_getWorkInt( targetindex, CHAR_WORKLASTESCAPE) < 5*60 ) { + //print(" 恶宝逃跑後组队 "); + CHAR_talkToCli( charaindex, -1, "此人暂时不可以当领队。", CHAR_COLORYELLOW); + continue; + } + } +#endif + } + /* 穴件乒旦田旦互中月凛反]谛棉方曰穸燮允月[ */ + else if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEBUS ) { + targetindex = toindex; + cnt = 0; + if( !NPC_BusCheckJoinParty( toindex, charaindex, TRUE)) { + /* 椭瘀毛 凶今卅井匀凶[醮棉 月及反蔽歹月[谛棉及质 手仄卅中[ + * 支支仇仄中及匹[ + */ + break; + } + { // Arminius 7.10 Airplane + int busimg=CHAR_getInt(toindex, CHAR_BASEIMAGENUMBER); + if ((busimg!=100355) && (busimg!=100461)) { + CHAR_setInt(charaindex,CHAR_BASEIMAGENUMBER,busimg); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , + CHAR_WORKOBJINDEX )); + // Robin debug 01/11/21 + if( CHAR_getInt( charaindex, CHAR_RIDEPET) != -1 ) { + CHAR_setInt( charaindex, CHAR_RIDEPET, -1); + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_RIDEPET); + } + /* + CHAR_sendPMEToArroundCharacterFLXY(charaindex, + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y), + 0,1,CHAR_getInt( charaindex, CHAR_PETMAILEFFECT) + ); + */ + } + } + } + /* 皿伊奶乩□坭反穴件乒旦田旦动陆反 骰允月 */ + else { + continue; + } + /* 锹澎由□ 奴及谛醒反 井" */ + parray = CHAR_getEmptyPartyArray( targetindex) ; + if( parray == -1 ) continue; + + /* 仇仇引匹仁木壬 */ + CONNECT_setJoinpartycharaindex( fd,cnt,toindex); + cnt++; + if( cnt == CONNECT_WINDOWBUFSIZE ) break; + + /* 穴件乒旦田旦 苇仄分中]伙□皿毛 仃月[ */ + if( CHAR_getInt( targetindex, CHAR_WHICHTYPE) == CHAR_TYPEBUS ) break; + + } + + if( cnt == 0 ) { + if( found == TRUE) { + CHAR_talkToCli( charaindex, -1, "无法加入团队。", CHAR_COLORYELLOW); + } + result = FALSE; + }else if( cnt == 1 ) { +#ifdef _DEATH_CONTEND + int toindex = CONNECT_getJoinpartycharaindex( fd, 0); + if(CHAR_getInt(toindex,CHAR_PKLISTTEAMNUM) == -1 && CHAR_getInt(charaindex,CHAR_PKLISTTEAMNUM) == -1){ + }else if( CHAR_getInt( charaindex, CHAR_PKLISTLEADER ) > 0 || + CHAR_getInt( toindex, CHAR_PKLISTTEAMNUM) < 0 || + CHAR_getInt( charaindex, CHAR_PKLISTTEAMNUM) < 0 || + CHAR_getInt( toindex, CHAR_PKLISTTEAMNUM) != CHAR_getInt( charaindex, CHAR_PKLISTTEAMNUM) || + CHAR_getInt(toindex,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER){ + + CHAR_talkToCli( charaindex, -1, "队伍不同,无法加入团队。", CHAR_COLORYELLOW); + result = FALSE; + }else{ +#endif + CHAR_JoinParty_Main( charaindex, CONNECT_getJoinpartycharaindex(fd,0)); + result = TRUE; +#ifdef _DEATH_CONTEND + } +#endif + }else { + int strlength; + char msgbuf[1024]; + char escapebuf[2048]; +#ifdef _DEATH_CONTEND + int toindex = CONNECT_getJoinpartycharaindex( fd, 0); + if(CHAR_getInt(toindex,CHAR_PKLISTTEAMNUM) == -1 && CHAR_getInt(charaindex,CHAR_PKLISTTEAMNUM) == -1){ + }else if( CHAR_getInt( charaindex, CHAR_PKLISTLEADER ) > 0 || + CHAR_getInt( toindex, CHAR_PKLISTTEAMNUM) < 0 || + CHAR_getInt( charaindex, CHAR_PKLISTTEAMNUM) < 0 || + CHAR_getInt( toindex, CHAR_PKLISTTEAMNUM) != CHAR_getInt( charaindex, CHAR_PKLISTTEAMNUM) || + CHAR_getInt(toindex,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER){ + + CHAR_talkToCli( charaindex, -1, "队伍不同,无法加入团队。", CHAR_COLORYELLOW); + result = FALSE; + } +#endif + strcpy( msgbuf, "1\n和谁组成团队呢?\n"); + strlength = strlen( msgbuf); + for( i = 0; + CONNECT_getJoinpartycharaindex( fd,i ) != -1 + && i< CONNECT_WINDOWBUFSIZE; + i ++ ){ + char *a = CHAR_getChar( + CONNECT_getJoinpartycharaindex(fd,i) , CHAR_NAME); + char buf[256]; + snprintf( buf, sizeof( buf),"%s\n", a); + if( strlength + strlen( buf) > arraysizeof( msgbuf)){ + print( "%s:%d视窗讯息buffer不足。\n", + __FILE__,__LINE__); + break; + } + strcpy( &msgbuf[strlength], buf); + strlength += strlen(buf); + } + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_SELECTPARTY, + -1, + makeEscapeString( msgbuf, escapebuf, sizeof(escapebuf))); + + + } + + if( result != -1 ) { + lssproto_PR_send( fd, 1, result); + } + + return result; +} + +static BOOL CHAR_DischargePartySub( int charaindex, int msgflg) +{ + char buf[64], c[3]; + int toindex,flg,i; +#ifdef _ITEM_QUITPARTY + int j = 0,k; +#endif + + + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_LEADER ) { + int pindex, airplaneflag=0; + // Arminius 7.10 Airplane + if( CHAR_getInt(charaindex, CHAR_WHICHTYPE) == CHAR_TYPEBUS ) { + if ((CHAR_getInt(charaindex, CHAR_BASEIMAGENUMBER) !=100355) && + (CHAR_getInt(charaindex, CHAR_BASEIMAGENUMBER) !=100461)){ + airplaneflag=1; + } + } + for( i = 0; i < CHAR_PARTYMAX; i ++ ) { + pindex = CHAR_getWorkInt( charaindex, i + CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX( pindex) ) { + int fd = getfdFromCharaIndex( pindex ); + CHAR_setWorkInt( pindex, CHAR_WORKPARTYINDEX1, -1); + CHAR_setWorkInt( pindex, CHAR_WORKPARTYMODE, CHAR_PARTY_NONE); + if( msgflg ){ + CHAR_talkToCli( pindex, -1, "团队已解散!", CHAR_COLORYELLOW); +#ifdef _ITEM_QUITPARTY + // won fix + for( j=0;j=0){ + int fl,x,y; + CHAR_getElderPosition( CHAR_getInt( charaindex, CHAR_LASTTALKELDER), + &fl, &x, &y ); + CHAR_warpToSpecificPoint(charaindex, fl, x, y); + } + } + } + } + CHAR_setWorkInt( charaindex, CHAR_WORKPARTYINDEX1, -1); + for( i = 0; i < CHAR_PARTYMAX; i ++ ) { + int index = CHAR_getWorkInt( toindex, i + CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX(index) ){ + if( index == charaindex) { + myarray = i; + break; + } + } + } + if( myarray == CHAR_PARTYMAX) { + print( "DischargeParty(): 真奇怪!"); + return FALSE; + } + CHAR_setWorkInt( toindex, CHAR_WORKPARTYINDEX1 + myarray, -1); + snprintf( buf,sizeof( buf), "%s 脱离团队!", + CHAR_getChar( charaindex, CHAR_NAME)); + if( msgflg ){ + CHAR_talkToCli( charaindex, -1, "脱离团队!", CHAR_COLORYELLOW); +#ifdef _ITEM_QUITPARTY + // won fix + for( i=0;i 1) { + int parent_dir; + start.x = CHAR_getInt( index, CHAR_X); + start.y = CHAR_getInt( index, CHAR_Y); + parent_dir = NPC_Util_getDirFromTwoPoint( &start,&end ); + end = start; + if( parent_dir != -1 ) { + CHAR_walk( index, parent_dir, 0); + } + } + previndex = index; + } + } + } + + } + + return TRUE; +} +BOOL CHAR_DischargeParty( int charaindex, int flg) +{ + return CHAR_DischargePartySub( charaindex, 1); +} + +BOOL CHAR_DischargePartyNoMsg( int charaindex) +{ + return CHAR_DischargePartySub( charaindex, 0); +} + + +/*------------------------------------------------------------ + * 愤坌互伉□母□井升丹井毛霜耨允月[ + ------------------------------------------------------------*/ +void CHAR_sendLeader( int objindex, int leader) +{ + int opt[1]; + opt[0] = leader; + CHAR_sendWatchEvent( objindex,CHAR_ACTLEADER,opt,1,TRUE); +} +/*------------------------------------------------------------ + * 醮棉毛赐 CHAR_WORKPARTYINDEX)隙烂匹平乓仿index毛娄匀舰月[ + * 愤坌互褪匹手阂匹手 [ + ------------------------------------------------------------*/ +int CHAR_getPartyIndex( int index, int num) +{ + int nindex = -1; + + /* 醮棉及奶件犯永弁旦毛潸 */ + /* 褪及桦宁 */ + if( CHAR_getWorkInt( index, CHAR_WORKPARTYMODE) == CHAR_PARTY_LEADER ) { + nindex = CHAR_getWorkInt( index, CHAR_WORKPARTYINDEX1 + num ); + } + /* 阂及桦宁 */ + else { + int oyaindex = CHAR_getWorkInt( index, CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX( oyaindex)) { + nindex = CHAR_getWorkInt( oyaindex, CHAR_WORKPARTYINDEX1+num); + } + } + return nindex; +} +/*------------------------------------------------------------ + * 丢永本□斥毛霜耨允月[ + * 醮棉互中木壬公及醮棉卞手丢永本□斥毛霜耨允月[ + ------------------------------------------------------------*/ +void CHAR_talkToCliAndParty( int talkedcharaindex,int talkcharaindex, + char* message, CHAR_COLOR color ) +{ + int i; + /* 引内愤坌 */ + CHAR_talkToCli( talkedcharaindex, talkcharaindex, message, color); + + for( i = 0; i < CHAR_PARTYMAX; i ++ ) { + int index = CHAR_getPartyIndex( talkedcharaindex, i); + if( CHAR_CHECKINDEX( index) && + index != talkedcharaindex) + { + CHAR_talkToCli( index, talkcharaindex, message, color); + } + } +} + diff --git a/gmsv/char/char_talk.c b/gmsv/char/char_talk.c new file mode 100644 index 0000000..b9491ae --- /dev/null +++ b/gmsv/char/char_talk.c @@ -0,0 +1,1561 @@ +#include "version.h" +#include +#include +#include + +#include "readmap.h" +#include "object.h" +#include "char.h" +#include "char_base.h" +#include "chatmagic.h" +#include "battle.h" +#include "log.h" +#include "configfile.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "family.h" +#ifdef _CHAR_PROFESSION +#include "profession_skill.h" +#endif +#ifdef _M_SERVER +#include "mclient.h" +#endif + +#ifdef _NPCSERVER_NEW +#include "npcserver.h" +#endif + +#include "net.h" + +extern int channelMember[FAMILY_MAXNUM][FAMILY_MAXCHANNEL][FAMILY_MAXMEMBER]; + +#ifdef _CHANNEL_MODIFY +int *piOccChannelMember = NULL; +#endif +/*------------------------------------------------------------ + * 民乓永玄楮 及末□旦 + ------------------------------------------------------------*/ +#define DEBUGCDKEYNUM 100 +struct tagDebugCDKey { + int use; + char cdkey[9]; +}; +static struct tagDebugCDKey DebugCDKey[DEBUGCDKEYNUM]; + +/*====================民乓永玄 芊====================*/ +typedef void (*CHATMAGICFUNC)(int,char*); +typedef struct tagCHAR_ChatMagicTable +{ + char* magicname; + CHATMAGICFUNC func; + BOOL isdebug; + int hash; + int level; + char* usestring; +}CHAR_ChatMagicTable; + +static CHAR_ChatMagicTable CHAR_cmtbl[]={ + //工程师专用 + { "programming_engineer", CHAR_CHAT_DEBUG_engineer, TRUE, 0, 3, ""}, + { "petlevelup", CHAR_CHAT_DEBUG_petlevelup, TRUE, 0, 2, "宠物栏号 等级 (账号)"}, + { "petexpup", CHAR_CHAT_DEBUG_petexpup, TRUE, 0, 2, "宠物栏号 经验 (账号)"}, + { "help", CHAR_CHAT_DEBUG_help, TRUE, 0, 1, "指令/all"}, + { "showtemp", CHAR_CHAT_DEBUG_showtemp, TRUE, 0, 3, "waei"}, +#ifdef _EQUIT_NEGLECTGUARD + { "setneguard", CHAR_CHAT_DEBUG_setneguard, TRUE, 0, 3, "waei"}, +#endif + { "reload_pkteamlist", CHAR_CHAT_DEBUG_reloadpkteamlist, TRUE, 0, 2, ""}, + { "set_battle", CHAR_CHAT_DEBUG_setBattle, TRUE, 0, 2, ""}, + +#ifdef _DEATH_CONTEND + { "updatepklist", CHAR_CHAT_DEBUG_updatepklist, TRUE, 0, 3, "无"}, +#endif + //人物属性 + { "info", CHAR_CHAT_DEBUG_info, TRUE, 0, 1, "数值"}, + { "level", CHAR_CHAT_DEBUG_level, TRUE, 0, 1, "数值 (账号)"}, + { "settrans", CHAR_CHAT_DEBUG_setTrans, TRUE, 0, 2, "数值 (账号)"}, + { "exp", CHAR_CHAT_DEBUG_exp, TRUE, 0, 2, "数值 (账号)"}, + { "hp", CHAR_CHAT_DEBUG_hp, TRUE, 0, 2, "数值 (账号)"}, + { "mp", CHAR_CHAT_DEBUG_mp, TRUE, 0, 2, "数值 (账号)"}, + { "setmp", CHAR_CHAT_DEBUG_setmp, TRUE, 0, 2, "数值 (账号)"}, + { "str", CHAR_CHAT_DEBUG_str, TRUE, 0, 2, "数值*100 (账号)"}, + { "dex", CHAR_CHAT_DEBUG_dex, TRUE, 0, 2, "数值*100 (账号)"}, + { "tgh", CHAR_CHAT_DEBUG_tgh, TRUE, 0, 2, "数值*100 (账号)"}, + { "vital", CHAR_CHAT_DEBUG_vital, TRUE, 0, 2, "数值*100 (账号)"}, + { "luck", CHAR_CHAT_DEBUG_luck, TRUE, 0, 2, "数值 (账号)"}, + { "superman", CHAR_CHAT_DEBUG_superman, TRUE, 0, 2, "(账号)"}, + { "dp", CHAR_CHAT_DEBUG_dp, TRUE, 0, 2, "数值 (账号)"}, +#ifdef _EQUIT_ARRANGE + { "arrange", CHAR_CHAT_DEBUG_arrange, TRUE, 0, 3, "数值"}, +#endif + +#ifdef _EQUIT_SEQUENCE + { "sequence", CHAR_CHAT_DEBUG_sequence, TRUE, 0, 3, "数值"}, +#endif + + //系统 + { "announce", CHAR_CHAT_DEBUG_announce, TRUE, 0, 1, "字串"}, + { "loginannounce", CHAR_CHAT_DEBUG_loginannounce, TRUE, 0, 1, "字串"}, + { "sysinfo", CHAR_CHAT_DEBUG_sysinfo, TRUE, 0, 1, "无"}, + { "effect", CHAR_CHAT_DEBUG_effect, TRUE, 0, 1, "alloff/地图号 特效"}, + { "remserver", CHAR_CHAT_DEBUG_remserver, TRUE, 0, 2, "on/off"}, + { "reset", CHAR_CHAT_DEBUG_reset, TRUE, 0, 2, "enemy/encount/magic/warppoint/petskill/pettalk/npc/all"}, + { "clean_floor", CHAR_CHAT_DEBUG_cleanfloor, TRUE, 0, 3, "地图号"}, + { "printcount", CHAR_CHAT_printcount, TRUE, 0, 1, ""}, +#ifdef _M_SERVER + { "reloadmsip", CHAR_CHAT_DEBUG_reloadmsip, TRUE, 0, 3, "address port"}, +#endif + { "enemyrestart", CHAR_CHAT_DEBUG_enemyrestart, TRUE, 0, 3, "无"}, + { "cleanfreepet", CHAR_CHAT_DEBUG_cleanfreepet, TRUE, 0, 3, "无"}, + +#ifdef _GMRELOAD + { "gmreload", CHAR_CHAT_DEBUG_gmreload, TRUE, 0, 3, "all/cdkey level"}, +#endif + + { "waeikickall", CHAR_CHAT_DEBUG_waeikickall, TRUE, 0, 3, "无"}, + { "checktrade", CHAR_CHAT_DEBUG_checktrade, TRUE, 0, 3, "waei"}, + //工具 初级GM + { "debug", CHAR_CHAT_DEBUG_debug, TRUE, 0, 1, "密码 debug on/off"}, + { "metamo", CHAR_CHAT_DEBUG_metamo, TRUE, 0, 1, "变身图号 (账号)"}, + { "checklock", CHAR_CHAT_DEBUG_checklock, TRUE, 0, 1, "帐号"}, + { "shutup", CHAR_CHAT_DEBUG_shutup, TRUE, 0, 1, "帐号 ON/OFF"}, +#ifdef _WAEI_KICK + { "gmkick", CHAR_CHAT_DEBUG_gmkick, TRUE, 0, 1, "帐号 LSLOCK/KICK/DEUNLOCK/UNLOCKALL/LOCK/TYPE/UNLOCK"}, +#endif + { "battlein", CHAR_CHAT_DEBUG_battlein, TRUE, 0, 1, "无"}, + { "battleout", CHAR_CHAT_DEBUG_battleout, TRUE, 0, 1, "无"}, + { "battlewatch", CHAR_CHAT_DEBUG_battlewatch, TRUE, 0, 1, "无"}, + { "getuser", CHAR_CHAT_DEBUG_getuser, TRUE, 0, 1, "人物名 地图号 (npc)"}, + { "warp", CHAR_CHAT_DEBUG_warp, TRUE, 0, 1, "floor x y"}, + { "waeikick", CHAR_CHAT_DEBUG_waeikick, TRUE, 0, 1, "帐号"}, + { "jail", CHAR_CHAT_DEBUG_jail, TRUE, 0, 1, "帐号"}, + { "send", CHAR_CHAT_DEBUG_send, TRUE, 0, 1, "floor x y 帐号"}, +#ifdef _SendTo + { "sendto", CHAR_CHAT_DEBUG_Sendto, TRUE, 0, 1, "帐号"}, +#endif + { "noenemy", CHAR_CHAT_DEBUG_noenemy, TRUE, 0, 1, "on/off"}, + { "watchevent", CHAR_CHAT_DEBUG_watchevent, TRUE, 0, 1, "无"}, +#ifdef _SEND_EFFECT // WON ADD AC送下雪、下雨等特效 + { "sendeffect", CHAR_CHAT_DEBUG_sendeffect, TRUE, 0, 1, ""}, +#endif + { "silent", CHAR_CHAT_DEBUG_silent, TRUE, 0, 2, "帐号 分钟"},//禁言 + { "unlock", CHAR_CHAT_DEBUG_unlock, TRUE, 0, 2, "帐号"}, + { "eventclean", CHAR_CHAT_DEBUG_eventclean, TRUE, 0, 2, "all/旗标 帐号 人物名"}, + { "eventsetend", CHAR_CHAT_DEBUG_eventsetend, TRUE, 0, 2, "all/旗标 帐号 人物名"}, + { "eventsetnow", CHAR_CHAT_DEBUG_eventsetnow, TRUE, 0, 2, "all/旗标 帐号 人物名"}, + + { "playerspread", CHAR_CHAT_DEBUG_playerspread, TRUE, 0, 3, "waei"}, + { "shutupall", CHAR_CHAT_DEBUG_shutupall, TRUE, 0, 3, "无"}, + { "unlockserver", CHAR_CHAT_DEBUG_unlockserver, TRUE, 0, 3, "无"}, + { "shutdown", CHAR_CHAT_DEBUG_shutdown, TRUE, 0, 3, ""}, + + //制成 + { "delitem", CHAR_CHAT_DEBUG_delitem, TRUE, 0, 1, "all/位置"}, + { "delpet", CHAR_CHAT_DEBUG_deletepet, TRUE, 0, 1, "all/位置"}, + { "additem", CHAR_CHAT_DEBUG_additem, TRUE, 0, 2, "道具ID ((数量) (账号))"}, + { "petmake", CHAR_CHAT_DEBUG_petmake, TRUE, 0, 2, "宠物ID ((等级) (账号))"}, + { "gold", CHAR_CHAT_DEBUG_gold, TRUE, 0, 2, "数量 (账号)"}, + + //家族工具 + { "manorpk", CHAR_CHAT_DEBUG_manorpk, TRUE, 0, 2, "allpeace/peace 庄园编号"}, + { "fixfmleader", CHAR_CHAT_DEBUG_fixfmleader, TRUE, 0, 2, "帐号 1"}, + { "fixfmpk", CHAR_CHAT_DEBUG_fixfmpk, TRUE, 0, 3, ""}, + { "fixfmdata", CHAR_CHAT_DEBUG_fixfmdata, TRUE, 0, 2, ""}, + + //测试用 + + +#ifdef _CHAR_POOLITEM + { "saveditem", CHAR_CHAT_DEBUG_saveditem, TRUE, 0, 3, ""}, + { "insertditem", CHAR_CHAT_DEBUG_insertditem, TRUE, 0, 3, ""}, + { "showdepot", CHAR_CHAT_DEBUG_ShowMyDepotItems, TRUE, 0, 3, ""}, + { "insidedepot", CHAR_CHAT_DEBUG_InSideMyDepotItems, TRUE, 0, 3, ""}, +#endif + +#ifdef _CHAR_POOLPET + { "savedpet", CHAR_CHAT_DEBUG_savedpet, TRUE, 0, 3, ""}, + { "insertdpet", CHAR_CHAT_DEBUG_insertdpet, TRUE, 0, 3, ""}, + { "showdepotpet", CHAR_CHAT_DEBUG_ShowMyDepotPets, TRUE, 0, 3, ""}, + { "insidedepotpet", CHAR_CHAT_DEBUG_InSideMyDepotPets, TRUE, 0, 3, ""}, +#endif + + +#ifdef _TEST_DROPITEMS + { "dropmypet", CHAR_CHAT_DEBUG_dropmypet, TRUE, 0, 3, "宠物编号"}, + { "dropmyitem", CHAR_CHAT_DEBUG_dropmyitem, TRUE, 0, 2, "道具编号/(0/1)"}, +#endif +#ifdef _CHAR_PROFESSION // WON ADD 人物职业 + { "addsk", CHAR_CHAT_DEBUG_addsk, TRUE, 0, 2, ""}, + { "delsk", CHAR_CHAT_DEBUG_delsk, TRUE, 0, 2, ""}, +#endif +#ifdef _TEST_PETCREATE + { "create_pet", CHAR_CHAT_DEBUG_createpet, TRUE, 0, 3, ""}, +#endif + { "checktime", CHAR_CHAT_DEBUG_checktime, TRUE, 0, 3, ""}, + +#ifdef _GAMBLE_BANK + { "setgamblenum", CHAR_CHAT_DEBUG_setgamblenum, TRUE, 0, 3, ""}, +#endif + // WON ADD 当机指令 + { "crash", CHAR_CHAT_DEBUG_crash, TRUE, 0, 3, ""}, +#ifdef _PETSKILL_SETDUCK + { "setDuck", CHAR_CHAT_DEBUG_SetDuck, TRUE, 0, 3, ""}, +#endif + +#ifdef _TYPE_TOXICATION + { "setTox", CHAR_CHAT_DEBUG_Toxication, TRUE, 0, 3, ""}, +#endif +#ifdef _ACTION_BULLSCR + { "setascore", CHAR_CHAT_DEBUG_setascore, TRUE, 0, 3, ""}, + { "getascore", CHAR_CHAT_DEBUG_getascore, TRUE, 0, 2, "all/start/score/btime/stime"}, +#endif + { "showMem", CHAR_CHAT_DEBUG_showMem, TRUE, 0, 2, "无"}, +#ifdef _NEW_PLAYERGOLD + { "acnewplayer", CHAR_CHAT_DEBUG_acnewplayer, TRUE, 0, 3, ""}, + { "loadnewplayer", CHAR_CHAT_DEBUG_loadnewplayer, TRUE, 0, 3, ""}, +#endif +#ifdef _ACTION_GMQUE // ANDY GM活动功能 永保留 + { "cleanqute", CHAR_CHAT_DEBUG_cleanqute, TRUE, 0, 3, ""}, +#endif +#ifdef _CHAR_PROFESSION // WON ADD 人物职业 + { "profession", CHAR_CHAT_DEBUG_show_profession,TRUE, 0, 2, ""}, + { "set_regist", CHAR_CHAT_DEBUG_set_regist, TRUE, 0, 1, ""}, +#endif + { "samecode", CHAR_CHAT_DEBUG_samecode, TRUE, 0, 3, ""}, +#ifdef _GM_IDENTIFY + { "gmidentify", CHAR_CHAR_DEBUG_gmidentify, TRUE, 0, 3, ""}, +#endif + +#ifdef _DEATH_FAMILY_GM_COMMAND // WON ADD 家族战GM指令 + { "reloadfm", CHAR_CHAR_DEBUG_reloadfm, TRUE, 0, 1, ""}, + { "fmpk", CHAR_CHAR_DEBUG_fmpk, TRUE, 0, 1, ""}, + { "fmpk_clean", CHAR_CHAR_DEBUG_fmpk_clean, TRUE, 0, 1, ""}, +#endif +#ifdef _NEW_MANOR_LAW + // 设定个人气势 + { "set_momentum",CHAR_CHAT_DEBUG_set_momentum,TRUE,0,2,"[set_momentum ]"}, + // 设定家族拥有庄园 + { "set_manor_owner",CHAR_CHAT_DEBUG_set_manor_owner,TRUE,0,2,"[set_manor_owner ]"}, + // 设定庄园挑战时间,设定的时间为目前每个挑战时期的经过时间(单位:分),ex:现在是休战期,共需要经过五天才会进 + // 入挑战期,则下指令设定为 5 ,则会由五天的等待期变成了只等五分钟 + { "set_schedule_time",CHAR_CHAT_DEBUG_set_schedule_time,TRUE,0,2,"[set_schedule_time ]"}, +#endif + +#ifdef _ANGEL_SUMMON + { "angelinfo", CHAR_CHAT_DEBUG_angelinfo, TRUE, 0, 2, ""}, + { "angelclean", CHAR_CHAT_DEBUG_angelclean, TRUE, 0, 2, ""}, + { "angelcreate", CHAR_CHAT_DEBUG_angelcreate, TRUE, 0, 2, ""}, + { "missionreload", CHAR_CHAT_DEBUG_missionreload, TRUE, 0, 2, ""}, +#endif + + { "itemreload", CHAR_CHAT_DEBUG_itemreload, TRUE, 0, 2, ""}, + + { "skywalker", CHAR_CHAT_DEBUG_skywalker, TRUE, 0, 1, ""}, +#ifdef _ITEM_ADDEXP + { "itemaddexp", CHAR_CHAT_DEBUG_itemaddexp, TRUE, 0, 1, ""}, +#endif + +#ifdef _DEF_FMFREETIME + { "fmfreetime", CHAR_CHAT_DEBUG_fmfreetime, TRUE, 0, 1, "帐号 人物名称"}, +#endif +#ifdef _DEF_GETYOU + { "getyou", CHAR_CHAT_DEBUG_getyou, TRUE, 0, 1, "格数 1~3"}, +#endif +#ifdef _DEF_NEWSEND + { "newsend", CHAR_CHAT_DEBUG_newsend, TRUE, 0, 1, "floor x y 帐号 无/要说的话"}, +#endif +#ifdef _DEF_SUPERSEND + { "supersend", CHAR_CHAT_DEBUG_supersend, TRUE, 0, 3, "floor x y 格数 无/要说的话"}, +#endif +#ifdef _FONT_SIZE + { "fsize", CHAR_CHAT_DEBUG_fsize, TRUE, 0, 1, ""}, +#endif +#ifdef _JOBDAILY + { "rejobdaily", CHAR_CHAT_DEBUG_rejobdaily, TRUE, 0, 3, "无"}, +#endif +#ifdef _RACEMAN + { "changeask", CHAR_CHAT_DEBUG_changeask, TRUE, 0, 2, "帐号 宠证id 0/1"}, +#endif +#ifdef _CREATE_MM_1_2 + { "MM", CHAR_CHAT_DEBUG_MM, TRUE, 0, 3, "MM 1/2 (账号)"}, +#endif +#ifdef _GM_ITEM + { "gmfunction", CHAR_CHAT_DEBUG_GMFUNCTION, TRUE, 0, 3, "命令 次数 (账号)"}, +#endif + +#ifdef _GM_RIDE + { "setride", CHAR_CHAT_DEBUG_SETRIDE, TRUE, 0, 3, "骑宠号 (账号)"}, + { "mvride", CHAR_CHAT_DEBUG_MVRIDE, TRUE, 0, 3, "骑宠号 (账号)"}, +#endif + +#ifdef _LOCK_IP + { "lockip", CHAR_CHAT_DEBUG_LOCK_IP, TRUE, 0, 3, "IP|登陆次数"}, + { "dislockip", CHAR_CHAT_DEBUG_DISPLAY_LOCK_IP, TRUE, 0, 3, ""}, +#endif +///////////////////////////////////////////////////////////////////////// + //工程师专用 +// { "programming_engineer", CHAR_CHAT_DEBUG_engineer, TRUE, 0, 3, ""}, + { "宠物等级", CHAR_CHAT_DEBUG_petlevelup, TRUE, 0, 2, "宠物栏号 等级 (账号)"}, + { "宠物经验", CHAR_CHAT_DEBUG_petexpup, TRUE, 0, 2, "宠物栏号 经验 (账号)"}, + { "帮助", CHAR_CHAT_DEBUG_help, TRUE, 0, 1, "指令/all"}, +// { "showtemp", CHAR_CHAT_DEBUG_showtemp, TRUE, 0, 3, "waei"}, +#ifdef _EQUIT_NEGLECTGUARD +// { "setneguard", CHAR_CHAT_DEBUG_setneguard, TRUE, 0, 3, "waei"}, +#endif +// { "reload_pkteamlist", CHAR_CHAT_DEBUG_reloadpkteamlist, TRUE, 0, 2, ""}, +// { "set_battle", CHAR_CHAT_DEBUG_setBattle, TRUE, 0, 2, ""}, + +#ifdef _DEATH_CONTEND +// { "updatepklist", CHAR_CHAT_DEBUG_updatepklist, TRUE, 0, 3, "无"}, +#endif + //人物属性 + { "人物信息", CHAR_CHAT_DEBUG_info, TRUE, 0, 1, "数值"}, + { "等级", CHAR_CHAT_DEBUG_level, TRUE, 0, 1, "数值 (账号)"}, + { "转生", CHAR_CHAT_DEBUG_setTrans, TRUE, 0, 2, "数值 (账号)"}, + { "经验", CHAR_CHAT_DEBUG_exp, TRUE, 0, 2, "数值 (账号)"}, + { "血", CHAR_CHAT_DEBUG_hp, TRUE, 0, 2, "数值 (账号)"}, + { "魔法", CHAR_CHAT_DEBUG_mp, TRUE, 0, 2, "数值 (账号)"}, + { "设置魔法", CHAR_CHAT_DEBUG_setmp, TRUE, 0, 2, "数值 (账号)"}, + { "腕力", CHAR_CHAT_DEBUG_str, TRUE, 0, 2, "数值*100 (账号)"}, + { "敏捷", CHAR_CHAT_DEBUG_dex, TRUE, 0, 2, "数值*100 (账号)"}, + { "耐力", CHAR_CHAT_DEBUG_tgh, TRUE, 0, 2, "数值*100 (账号)"}, + { "体力", CHAR_CHAT_DEBUG_vital, TRUE, 0, 2, "数值*100 (账号)"}, + { "运气", CHAR_CHAT_DEBUG_luck, TRUE, 0, 2, "数值 (账号)"}, + { "超人", CHAR_CHAT_DEBUG_superman, TRUE, 0, 2, "(账号)"}, + { "dp", CHAR_CHAT_DEBUG_dp, TRUE, 0, 2, "数值 (账号)"}, +#ifdef _EQUIT_ARRANGE + { "格档", CHAR_CHAT_DEBUG_arrange, TRUE, 0, 3, "数值"}, +#endif + +#ifdef _EQUIT_SEQUENCE + { "顺序", CHAR_CHAT_DEBUG_sequence, TRUE, 0, 3, "数值"}, +#endif + + //系统 + { "公告", CHAR_CHAT_DEBUG_announce, TRUE, 0, 1, "字串"}, + { "登陆公告", CHAR_CHAT_DEBUG_loginannounce, TRUE, 0, 1, "字串"}, + { "系统信息", CHAR_CHAT_DEBUG_sysinfo, TRUE, 0, 1, "无"}, + { "地图特效", CHAR_CHAT_DEBUG_effect, TRUE, 0, 1, "alloff/地图号 特效"}, +// { "remserver", CHAR_CHAT_DEBUG_remserver, TRUE, 0, 2, "on/off"}, +// { "reset", CHAR_CHAT_DEBUG_reset, TRUE, 0, 2, "enemy/encount/magic/warppoint/petskill/pettalk/npc/all"}, + { "清除地图物品", CHAR_CHAT_DEBUG_cleanfloor, TRUE, 0, 3, "地图号"}, +// { "printcount", CHAR_CHAT_printcount, TRUE, 0, 1, ""}, +#ifdef _M_SERVER +// { "reloadmsip", CHAR_CHAT_DEBUG_reloadmsip, TRUE, 0, 3, "address port"}, +#endif + { "重读宠物资料", CHAR_CHAT_DEBUG_enemyrestart, TRUE, 0, 3, "无"}, + { "清除地上宠物", CHAR_CHAT_DEBUG_cleanfreepet, TRUE, 0, 3, "无"}, + +#ifdef _GMRELOAD + { "读取GM设置", CHAR_CHAT_DEBUG_gmreload, TRUE, 0, 3, "all/cdkey level"}, +#endif + + { "踢除所有玩家", CHAR_CHAT_DEBUG_waeikickall, TRUE, 0, 3, "无"}, +// { "checktrade", CHAR_CHAT_DEBUG_checktrade, TRUE, 0, 3, "waei"}, + //工具 初级GM + { "调试", CHAR_CHAT_DEBUG_debug, TRUE, 0, 1, "密码 调试 on/off"}, + { "造型", CHAR_CHAT_DEBUG_metamo, TRUE, 0, 1, "变身图号 (账号)"}, + { "锁定帐号", CHAR_CHAT_DEBUG_checklock, TRUE, 0, 1, "帐号"}, + { "封嘴", CHAR_CHAT_DEBUG_shutup, TRUE, 0, 1, "帐号 ON/OFF"}, +#ifdef _WAEI_KICK +// { "gmkick", CHAR_CHAT_DEBUG_gmkick, TRUE, 0, 1, "帐号 LSLOCK/KICK/DEUNLOCK/UNLOCKALL/LOCK/TYPE/UNLOCK"}, +#endif + { "加入战斗", CHAR_CHAT_DEBUG_battlein, TRUE, 0, 1, "无"}, + { "结束战斗", CHAR_CHAT_DEBUG_battleout, TRUE, 0, 1, "无"}, + { "观看战斗", CHAR_CHAT_DEBUG_battlewatch, TRUE, 0, 1, "无"}, + { "显示信息", CHAR_CHAT_DEBUG_getuser, TRUE, 0, 1, "人物名 地图号 (npc)"}, + { "踢除玩家", CHAR_CHAT_DEBUG_waeikick, TRUE, 0, 1, "帐号"}, + { "关入监狱", CHAR_CHAT_DEBUG_jail, TRUE, 0, 1, "帐号"}, + { "传送", CHAR_CHAT_DEBUG_send, TRUE, 0, 1, "地图编号 x y 帐号"}, +#ifdef _SendTo + { "传送到玩家", CHAR_CHAT_DEBUG_Sendto, TRUE, 0, 1, "帐号"}, +#endif + { "不遇敌", CHAR_CHAT_DEBUG_noenemy, TRUE, 0, 1, "on/off"}, + { "显示完成任务", CHAR_CHAT_DEBUG_watchevent, TRUE, 0, 1, "无"}, +#ifdef _SEND_EFFECT // WON ADD AC送下雪、下雨等特效 + { "特效", CHAR_CHAT_DEBUG_sendeffect, TRUE, 0, 1, ""}, +#endif + { "禁言", CHAR_CHAT_DEBUG_silent, TRUE, 0, 2, "帐号 分钟"},//禁言 + { "踢人", CHAR_CHAT_DEBUG_unlock, TRUE, 0, 2, "帐号"}, + { "清除旗标", CHAR_CHAT_DEBUG_eventclean, TRUE, 0, 2, "all/旗标 帐号 人物名"}, + { "增加旗标", CHAR_CHAT_DEBUG_eventsetend, TRUE, 0, 2, "all/旗标 帐号 人物名"}, + { "重新任务", CHAR_CHAT_DEBUG_eventsetnow, TRUE, 0, 2, "all/旗标 帐号 人物名"}, + + { "人物地区显示", CHAR_CHAT_DEBUG_playerspread, TRUE, 0, 3, "waei"}, +// { "shutupall", CHAR_CHAT_DEBUG_shutupall, TRUE, 0, 3, "无"}, + { "解除服务器", CHAR_CHAT_DEBUG_unlockserver, TRUE, 0, 3, "无"}, + { "关服", CHAR_CHAT_DEBUG_shutdown, TRUE, 0, 3, "分钟"}, + + //制成 + { "删除物品", CHAR_CHAT_DEBUG_delitem, TRUE, 0, 1, "all/位置"}, + { "删除宠物", CHAR_CHAT_DEBUG_deletepet, TRUE, 0, 1, "all/位置"}, + { "制作物品", CHAR_CHAT_DEBUG_additem, TRUE, 0, 2, "道具ID ((数量) (账号))"}, + { "制作宠物", CHAR_CHAT_DEBUG_petmake, TRUE, 0, 2, "宠物ID ((等级) (账号))"}, + { "金钱", CHAR_CHAT_DEBUG_gold, TRUE, 0, 2, "数量 (账号)"}, + + //家族工具 +// { "manorpk", CHAR_CHAT_DEBUG_manorpk, TRUE, 0, 2, "allpeace/peace 庄园编号"}, + { "修改族长", CHAR_CHAT_DEBUG_fixfmleader, TRUE, 0, 2, "帐号 1"}, +// { "fixfmpk", CHAR_CHAT_DEBUG_fixfmpk, TRUE, 0, 3, ""}, +// { "fixfmdata", CHAR_CHAT_DEBUG_fixfmdata, TRUE, 0, 2, ""}, + + //测试用 + + +#ifdef _CHAR_POOLITEM +// { "saveditem", CHAR_CHAT_DEBUG_saveditem, TRUE, 0, 3, ""}, +// { "insertditem", CHAR_CHAT_DEBUG_insertditem, TRUE, 0, 3, ""}, +// { "showdepot", CHAR_CHAT_DEBUG_ShowMyDepotItems, TRUE, 0, 3, ""}, +// { "insidedepot", CHAR_CHAT_DEBUG_InSideMyDepotItems, TRUE, 0, 3, ""}, +#endif + +#ifdef _CHAR_POOLPET +// { "savedpet", CHAR_CHAT_DEBUG_savedpet, TRUE, 0, 3, ""}, +// { "insertdpet", CHAR_CHAT_DEBUG_insertdpet, TRUE, 0, 3, ""}, +// { "showdepotpet", CHAR_CHAT_DEBUG_ShowMyDepotPets, TRUE, 0, 3, ""}, +// { "insidedepotpet", CHAR_CHAT_DEBUG_InSideMyDepotPets, TRUE, 0, 3, ""}, +#endif + + +#ifdef _TEST_DROPITEMS + { "满地宠物", CHAR_CHAT_DEBUG_dropmypet, TRUE, 0, 3, "宠物编号"}, + { "满地宠物", CHAR_CHAT_DEBUG_dropmyitem, TRUE, 0, 2, "道具编号/(0/1)"}, +#endif +#ifdef _CHAR_PROFESSION // WON ADD 人物职业 + { "添加技能", CHAR_CHAT_DEBUG_addsk, TRUE, 0, 2, ""}, + { "删除技能", CHAR_CHAT_DEBUG_delsk, TRUE, 0, 2, ""}, +#endif +#ifdef _TEST_PETCREATE +// { "create_pet", CHAR_CHAT_DEBUG_createpet, TRUE, 0, 3, ""}, +#endif + { "显示时间", CHAR_CHAT_DEBUG_checktime, TRUE, 0, 3, ""}, + +#ifdef _GAMBLE_BANK + { "积分", CHAR_CHAT_DEBUG_setgamblenum, TRUE, 0, 3, ""}, +#endif + // WON ADD 当机指令 +// { "crash", CHAR_CHAT_DEBUG_crash, TRUE, 0, 3, ""}, +#ifdef _PETSKILL_SETDUCK +// { "setDuck", CHAR_CHAT_DEBUG_SetDuck, TRUE, 0, 3, ""}, +#endif + +#ifdef _TYPE_TOXICATION +// { "setTox", CHAR_CHAT_DEBUG_Toxication, TRUE, 0, 3, ""}, +#endif +#ifdef _ACTION_BULLSCR +// { "setascore", CHAR_CHAT_DEBUG_setascore, TRUE, 0, 3, ""}, +// { "getascore", CHAR_CHAT_DEBUG_getascore, TRUE, 0, 2, "all/start/score/btime/stime"}, +#endif + { "显示内存", CHAR_CHAT_DEBUG_showMem, TRUE, 0, 2, "无"}, +#ifdef _NEW_PLAYERGOLD +// { "acnewplayer", CHAR_CHAT_DEBUG_acnewplayer, TRUE, 0, 3, ""}, +// { "loadnewplayer", CHAR_CHAT_DEBUG_loadnewplayer, TRUE, 0, 3, ""}, +#endif +#ifdef _ACTION_GMQUE // ANDY GM活动功能 永保留 +// { "cleanqute", CHAR_CHAT_DEBUG_cleanqute, TRUE, 0, 3, ""}, +#endif +#ifdef _CHAR_PROFESSION // WON ADD 人物职业 +// { "职业", CHAR_CHAT_DEBUG_show_profession,TRUE, 0, 2, ""}, +// { "set_regist", CHAR_CHAT_DEBUG_set_regist, TRUE, 0, 1, ""}, +#endif +// { "samecode", CHAR_CHAT_DEBUG_samecode, TRUE, 0, 3, ""}, +#ifdef _GM_IDENTIFY +// { "gmidentify", CHAR_CHAR_DEBUG_gmidentify, TRUE, 0, 3, ""}, +#endif + +#ifdef _DEATH_FAMILY_GM_COMMAND // WON ADD 家族战GM指令 +// { "reloadfm", CHAR_CHAR_DEBUG_reloadfm, TRUE, 0, 1, ""}, +// { "fmpk", CHAR_CHAR_DEBUG_fmpk, TRUE, 0, 1, ""}, +// { "fmpk_clean", CHAR_CHAR_DEBUG_fmpk_clean, TRUE, 0, 1, ""}, +#endif +#ifdef _NEW_MANOR_LAW + // 设定个人气势 + { "个人气势",CHAR_CHAT_DEBUG_set_momentum,TRUE,0,2,"[个人气势 <名称> <数值>]"}, + // 设定家族拥有庄园 + { "庄园",CHAR_CHAT_DEBUG_set_manor_owner,TRUE,0,2,"[庄园 <庄园id> <0 or 1> <家族名 or 家族ID>]"}, + // 设定庄园挑战时间,设定的时间为目前每个挑战时期的经过时间(单位:分),ex:现在是休战期,共需要经过五天才会进 + // 入挑战期,则下指令设定为 5 ,则会由五天的等待期变成了只等五分钟 + { "庄园挑战时间",CHAR_CHAT_DEBUG_set_schedule_time,TRUE,0,2,"[set_schedule_time ]"}, +#endif + +#ifdef _ANGEL_SUMMON + { "精灵召唤", CHAR_CHAT_DEBUG_angelinfo, TRUE, 0, 2, ""}, + { "清除精灵召唤", CHAR_CHAT_DEBUG_angelclean, TRUE, 0, 2, ""}, + { "创建精灵召唤", CHAR_CHAT_DEBUG_angelcreate, TRUE, 0, 2, ""}, + { "重读使者任务", CHAR_CHAT_DEBUG_missionreload, TRUE, 0, 2, ""}, +#endif + + { "读取物品", CHAR_CHAT_DEBUG_itemreload, TRUE, 0, 2, ""}, + + { "天行者", CHAR_CHAT_DEBUG_skywalker, TRUE, 0, 1, ""}, +#ifdef _ITEM_ADDEXP +// { "itemaddexp", CHAR_CHAT_DEBUG_itemaddexp, TRUE, 0, 1, ""}, +#endif + +#ifdef _DEF_FMFREETIME +// { "fmfreetime", CHAR_CHAT_DEBUG_fmfreetime, TRUE, 0, 1, "帐号 人物名称"}, +#endif +#ifdef _DEF_GETYOU + { "获取账号", CHAR_CHAT_DEBUG_getyou, TRUE, 0, 1, "格数 1~3"}, +#endif +#ifdef _DEF_NEWSEND + { "传送玩家", CHAR_CHAT_DEBUG_newsend, TRUE, 0, 1, "地图编号 x y 帐号 无/要说的话"}, +#endif +#ifdef _DEF_SUPERSEND + { "群体传送", CHAR_CHAT_DEBUG_supersend, TRUE, 0, 3, "地图编号 x y 格数 无/要说的话"}, +#endif +#ifdef _FONT_SIZE + { "字体大小", CHAR_CHAT_DEBUG_fsize, TRUE, 0, 1, ""}, +#endif +#ifdef _JOBDAILY +// { "rejobdaily", CHAR_CHAT_DEBUG_rejobdaily, TRUE, 0, 3, "无"}, +#endif +#ifdef _RACEMAN +// { "changeask", CHAR_CHAT_DEBUG_changeask, TRUE, 0, 2, "帐号 宠证id 0/1"}, +#endif +#ifdef _GM_ITEM + { "权限", CHAR_CHAT_DEBUG_GMFUNCTION, TRUE, 0, 3, "命令 次数 (账号)"}, +#endif + +#ifdef _GM_RIDE + { "设置骑乘", CHAR_CHAT_DEBUG_SETRIDE, TRUE, 0, 3, "骑宠号 (账号)"}, + { "移除骑乘", CHAR_CHAT_DEBUG_MVRIDE, TRUE, 0, 3, "骑宠号 (账号)"}, +#endif + +#ifdef _LOCK_IP + { "锁定IP", CHAR_CHAT_DEBUG_LOCK_IP, TRUE, 0, 3, "IP|登陆次数"}, + { "显示锁定IP", CHAR_CHAT_DEBUG_DISPLAY_LOCK_IP, TRUE, 0, 3, ""}, +#endif + +}; + +void CHAR_initDebugChatCdkey( void) +{ + int i; + for( i = 0; i < DEBUGCDKEYNUM; i ++ ) { + DebugCDKey[i].use = FALSE; + DebugCDKey[i].cdkey[0] = '\0'; + } +} +/*------------------------------------------------------------ + * 民乓永玄 芊及甩永扑亘袄毛综月[ + * 娄醒}忒曰袄 + * 卅仄 + ------------------------------------------------------------*/ +void CHAR_initChatMagic(void) +{ + int i; + for( i=0 ; i 8 ) { + return -1; + } + for( i = 0; i < DEBUGCDKEYNUM; i ++ ) { + if( DebugCDKey[i].use == FALSE) { + if( mode == 0 ) { + DebugCDKey[i].use = TRUE; + strcpysafe( DebugCDKey[i].cdkey, sizeof( DebugCDKey[i].cdkey), cdkey); + found = TRUE; + break; + } + } + else { + if( mode == 1 ) { + if( strcmp( DebugCDKey[i].cdkey, cdkey) == 0 ) { + DebugCDKey[i].use = FALSE; + DebugCDKey[i].cdkey[0] = '\0'; + found = TRUE; + } + } + } + + } + if( !found ) return -1; + return i; +} + +static CHATMAGICFUNC CHAR_getChatMagicFuncPointer(char* name, BOOL isDebug) +{ + int i; + int hash = hashpjw( name ); + for( i=0 ; i= arraysizeof( CHAR_cmtbl) ) return -1; + if( CHAR_cmtbl[ ti].isdebug == isDebug && + CHAR_cmtbl[ ti].level <= level ){ + sprintf( name,"%s", CHAR_cmtbl[ ti].magicname ); + sprintf( usestring, "%s", CHAR_cmtbl[ ti].usestring ); + return 1; + } + return 0; +} + +int CHAR_getChatMagicFuncMaxNum( void) +{ + return arraysizeof( CHAR_cmtbl); +} + +/*------------------------------------------------------------ + * 民乓永玄 芊 + * 娄醒 + * charaindex int 平乓仿奶件犯永弁旦 + * message char* 丢永本□斥 + * isDebug BOOL 犯田永弘民乓永玄 芊井升丹井 + * 忒曰袄 + * 卅仄 + ------------------------------------------------------------*/ +static BOOL CHAR_useChatMagic( int charaindex, char* data, BOOL isDebug) +{ + char magicname[256]; + int ret; + int i; + int gmLevel = 0, magicLevel; + + CHATMAGICFUNC func; + +#ifdef _GMRELOAD + extern struct GMINFO gminfo[GMMAXNUM]; +#else +#endif + char *p = CHAR_getChar( charaindex, CHAR_CDKEY); + if( !p ) { + fprint( "err nothing cdkey\n"); + return FALSE; + } + + if( getChatMagicCDKeyCheck() == 1 ){ //第一次确认GM帐号 + if( CHAR_getWorkInt( charaindex, CHAR_WORKFLG) & WORKFLG_DEBUGMODE ) { + gmLevel = CHAR_getWorkInt( charaindex, CHAR_WORKGMLEVEL); + }else{ + + +#ifdef _GMRELOAD + for (i = 0; i < GMMAXNUM; i++){ + if (strcmp( p, gminfo[i].cdkey) == 0){ + gmLevel = gminfo[i].level; + CHAR_setWorkInt( charaindex, CHAR_WORKGMLEVEL, gmLevel); + break; + } + } +#else +#endif + if( i >= GMMAXNUM ){ + for( i = 0; i < DEBUGCDKEYNUM; i ++ ) { + if( DebugCDKey[i].use && strcmp( p, DebugCDKey[i].cdkey) == 0 ) { + break; + } + } + if( i >= DEBUGCDKEYNUM ) return FALSE; + } + } + + }else { + gmLevel = 3; + CHAR_setWorkInt( charaindex, CHAR_WORKGMLEVEL, gmLevel); + } + + ret = getStringFromIndexWithDelim( data, " ", 1, magicname, sizeof( magicname)); + if( ret == FALSE)return FALSE; + + // Robin 0618 chaeck GM Level + magicLevel = CHAR_getChatMagicFuncLevel( magicname, isDebug); + if( gmLevel < magicLevel ) + return FALSE; + + func = CHAR_getChatMagicFuncPointer(magicname,isDebug); + if( func ){ + LogGM( CHAR_getUseName( charaindex), CHAR_getChar( charaindex, CHAR_CDKEY), data, + CHAR_getInt( charaindex, CHAR_FLOOR), CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y) ); + func( charaindex, data + strlen( magicname)+1); + return TRUE; + }else{ + return FALSE; + } +} + +/*------------------------------------------------------------ + * 祥汹井日汔毛菲户月 + * 娄醒 + * volume int 祥汹 + * 忒曰袄 + * 穴永皿匹及穴旦 + ------------------------------------------------------------*/ +static int CHAR_getRangeFromVolume( int volume ) +{ + static int chatvol[]={ + 3,5,7,9,11,13,15,17,19,21,23,25,27,29,31 + }; + + if( volume < 0 )return 0; + else if( arraysizeof( chatvol ) <= volume ) { + return chatvol[arraysizeof(chatvol)-1]; + } + return chatvol[volume]; +} +/*------------------------------------------------------------ + * 擘及示伉亘□丞毛茧月[条卅中支曰井凶[ + * 娄醒 + * mesg char* 仄扎屯月蜕邯 + * 忒曰袄 + * -1 及午五反仇公仇公 + * 0 及午五反孔勾丹 + * 1 方曰云云五中午}仃勾卞勾中化中月 ! 及醒 + ------------------------------------------------------------*/ +static int CHAR_getVolume( char* mesg ) +{ + int stringlen = strlen( mesg ); + if( stringlen == 0 ) + return 0; + else if( stringlen == 1 ){ + if( mesg[0] == '!')return 1; + else return 0; + }else if( stringlen == 2 ){ + if( mesg[1] == '!'){ + if( mesg[0] == '!' )return 2; + else return 1; + }else + return 0; + }else{ + /* 3动晓 */ + if( mesg[stringlen-1] == '.' ){ + /* 仇公仇公及第 岭丐曰 */ + if( mesg[stringlen-2] == '.' && mesg[stringlen-3] == '.' ){ + /* 仇公仇公 */ + return -1; + } + return 0; + }else{ + /* 仇仇井日 ! 毛醒尹月*/ + int exnum=0; + int i; + for( i=stringlen-1; i>=0 ; i-- ){ + if( mesg[i] != '!' ) + break; + else + exnum++; + } + return exnum; + } + } +} + +/*------------------------------------------------------------ + * 丢永本□斥及 井日丢永本□斥及 坌毛潸曰请允 + * 娄醒 + * message char* 丢永本□斥 + * kind char* p or s or i卅及丢永本□斥 + * kindlen int kind 及赢今 + * body char** 丢永本□斥 及禾奶件正□及伞 桦赭 + * 忒曰袄 + * 卅仄 + ------------------------------------------------------------*/ +void CHAR_getMessageBody(char* message,char* kind,int kindlen,char** body) +{ + int firstchar; + + /* 1 侬 毛切之匀仁[1 侬匹丐月仇午反lssproto.html互忡据 */ + // Nuke +1: For invalid message attack + *body = 0; + firstchar = message[0]; + if( firstchar == 'P' || + firstchar == 'S' || + firstchar == 'D' + + // CoolFish: Trade 2001/4/18 + || firstchar == 'C' + || firstchar == 'T' + || firstchar == 'W' + + // CoolFish: Family 2001/5/28 + || firstchar == 'A' + || firstchar == 'J' + || firstchar == 'E' + || firstchar == 'M' + + || firstchar == 'B' + || firstchar == 'X' + || firstchar == 'R' + || firstchar == 'L' + + ){ + if( kindlen >= 2 ){ + kind[0] = firstchar; + kind[1] = '\0'; + } else { + return; + } + } else { + return; + } + + *body = message + 2; +} + + +static BOOL CHAR_Talk_check( int talkerindex, int talkedindex, int micflg ) +{ +#if 1 + if( !CHAR_getFlg( talkerindex, CHAR_ISPARTYCHAT )){ + int talker_b_mode = CHAR_getWorkInt( talkerindex, CHAR_WORKBATTLEMODE); + int talked_b_mode = CHAR_getWorkInt( talkedindex, CHAR_WORKBATTLEMODE); + if( talker_b_mode != BATTLE_CHARMODE_NONE + && CHAR_getInt( talkedindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER){ + return FALSE; + } + if( micflg != 0 )return TRUE; + if( talker_b_mode != BATTLE_CHARMODE_NONE && talked_b_mode != BATTLE_CHARMODE_NONE){ + if( CHAR_getWorkInt( talkerindex, CHAR_WORKBATTLEINDEX) + != CHAR_getWorkInt( talkedindex, CHAR_WORKBATTLEINDEX)){ + return FALSE; + } + }else if( talker_b_mode != BATTLE_CHARMODE_NONE || talked_b_mode != BATTLE_CHARMODE_NONE){ + return FALSE; + } + return TRUE; + } + if( CHAR_getInt( talkerindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + int talker_b_mode = CHAR_getWorkInt( talkerindex, CHAR_WORKBATTLEMODE); + int talked_b_mode = CHAR_getWorkInt( talkedindex, CHAR_WORKBATTLEMODE); + + if( talker_b_mode != BATTLE_CHARMODE_NONE && CHAR_getInt( talkedindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER){ + return FALSE; + } + if( micflg != 0 )return TRUE; + if( CHAR_getWorkInt( talkerindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE ){ + if( CHAR_getWorkInt( talkedindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE){ + if( CHAR_getWorkInt( talkerindex, CHAR_WORKPARTYINDEX1) + == CHAR_getWorkInt( talkedindex, CHAR_WORKPARTYINDEX1) ){ + return TRUE; + } + } + }else { + if( talker_b_mode != BATTLE_CHARMODE_NONE && talked_b_mode != BATTLE_CHARMODE_NONE){ + if( CHAR_getWorkInt( talkerindex, CHAR_WORKBATTLEINDEX) + != CHAR_getWorkInt( talkedindex, CHAR_WORKBATTLEINDEX)){ + return FALSE; + } + }else if( talker_b_mode != BATTLE_CHARMODE_NONE || + talked_b_mode != BATTLE_CHARMODE_NONE){ + return FALSE; + } + return TRUE; + } + } + return FALSE; + +#else + int MyBattleMode; + int ToBattleMode; + + MyBattleMode = CHAR_getWorkInt( talkerindex, CHAR_WORKBATTLEMODE); + ToBattleMode = CHAR_getWorkInt( talkedindex, CHAR_WORKBATTLEMODE); + + /* 爵 及凛 */ + if( MyBattleMode == BATTLE_CHARMODE_NONE ) { + if( ToBattleMode == BATTLE_CHARMODE_NONE ) { + return TRUE; + } + else { + return FALSE; + } + } + /* 爵 及凛 */ + else { + /* 爵 仄化中卅中谛卞反霜日卅中[ */ + if( ToBattleMode == BATTLE_CHARMODE_NONE) { + return FALSE; + } + /* 元爵 匹 元扔奶玉及谛卞仄井霜耨请 卅中 */ + if( CHAR_getWorkInt( talkerindex, CHAR_WORKBATTLEINDEX) + == CHAR_getWorkInt( talkedindex, CHAR_WORKBATTLEINDEX) && + CHAR_getWorkInt( talkerindex, CHAR_WORKBATTLESIDE) + == CHAR_getWorkInt( talkedindex, CHAR_WORKBATTLESIDE ) ) + { + return TRUE; + } + else { + return FALSE; + } + } + return FALSE; +#endif +} +#ifdef _TELLCHANNEL // (不可开) Syu ADD 密语频道 +static int TalkCount = 0 ; +void OneByOneTkChannel ( int fd , char *tmp1 , char *tmp2 , int color ) +{ + int i ; + int myindex ; + int playernum = CHAR_getPlayerMaxNum(); + char buf[512]; + int IndexList[10] = { 0 } ; + int IndexCount = 0 ; + char *addr; + int target; + myindex = CONNECT_getCharaindex(fd); + +DebugPoint=300; + if( strlen( tmp2) > (sizeof(buf)-1) ) return; +DebugPoint=301; + memset ( IndexList , -1 , sizeof( IndexList ) ); +DebugPoint=302; + + for( i = 0 ; i < playernum ; i++) { + if( CHAR_getCharUse(i) != FALSE ) { + if (!CHAR_CHECKINDEX(i)) + continue; + if ( strcmp ( tmp1 , CHAR_getChar( i , CHAR_NAME ) ) == 0 ) { + IndexList[ IndexCount ] = i ; + IndexCount ++ ; + if ( IndexCount >= 10 ) break; + } + } + } +DebugPoint=303; + if ( IndexCount == 1 ) { +DebugPoint=304; + if ( myindex == IndexList[0] ) + return; +#ifdef _CHANNEL_MODIFY + if(CHAR_getFlg(IndexList[0],CHAR_ISTELL) == FALSE){ + snprintf(buf,sizeof(buf) - 1,"%s 关闭了此频道" ,tmp1); + CHAR_talkToCli(myindex,-1,buf,color); + return; + } +#endif +#ifndef _CHANNEL_MODIFY + snprintf( buf, sizeof( buf)-1, "你告诉%s:%s" , tmp1 , tmp2 ) ; + CHAR_talkToCli( myindex, -1, buf , color); + snprintf( buf , sizeof( buf)-1,"%s告诉你:%s" , CHAR_getChar ( myindex , CHAR_NAME ) , tmp2 ) ; + CHAR_talkToCli( IndexList[0] , -1, buf , color); +#else + snprintf(buf,sizeof(buf) - 1,"P|M|你告诉%s:%s",tmp1,tmp2); + lssproto_TK_send(fd,CHAR_getWorkInt(myindex,CHAR_WORKOBJINDEX),buf,color); + snprintf(buf,sizeof(buf) - 1,"P|M|%s告诉你:%s",CHAR_getChar(myindex,CHAR_NAME),tmp2); + lssproto_TK_send(getfdFromCharaIndex(IndexList[0]),CHAR_getWorkInt(IndexList[0],CHAR_WORKOBJINDEX),buf,color); +#endif + TalkCount ++ ; + }else if ( IndexCount > 1 && IndexCount < 10 ) { +DebugPoint=305; + print( "\nSyu log 进入同名Func" ); + if ( ( addr = strstr ( tmp2 , "/T" ) ) != NULL ) { + addr = addr + 2 ; + target = atoi ( addr ) ; + print ( "\nSyu log addr => %s , target => %d " , addr , target ) ; + addr = strtok ( tmp2 , "/T" ) ; + if (!CHAR_CHECKINDEX(IndexList[target])) + return; + if ( strcmp ( tmp1 , CHAR_getChar ( IndexList[ target ] , CHAR_NAME ) ) == 0 && + IndexList[ target ] != -1 ) { + if ( myindex == IndexList[ target ] ) + return ; +#ifdef _CHANNEL_MODIFY + if(CHAR_getFlg(IndexList[target],CHAR_ISTELL) == FALSE){ + snprintf(buf,sizeof(buf) - 1,"%s 关闭了此频道" ,tmp1); + CHAR_talkToCli(myindex,-1,buf,color); + return; + } +#endif +#ifndef _CHANNEL_MODIFY + snprintf( buf , sizeof( buf)-1, "你告诉%s:%s" , tmp1 , addr ) ; + CHAR_talkToCli( myindex, -1, buf , color); + snprintf( buf , sizeof( buf)-1, "%s告诉你:%s" , CHAR_getChar ( myindex , CHAR_NAME ) , addr ) ; + CHAR_talkToCli( IndexList[ target ] , -1, buf , color); +#else + snprintf(buf,sizeof(buf) - 1,"P|M|你告诉%s:%s",tmp1,addr); + lssproto_TK_send(fd,CHAR_getWorkInt(myindex,CHAR_WORKOBJINDEX),buf,color); + snprintf(buf,sizeof(buf) - 1,"P|M|%s告诉你:%s",CHAR_getChar(myindex,CHAR_NAME),addr); + lssproto_TK_send(getfdFromCharaIndex(IndexList[target]),CHAR_getWorkInt(IndexList[target],CHAR_WORKOBJINDEX),buf,color); +#endif + TalkCount ++ ; + } + }else { +DebugPoint=306; + for ( i = 0 ; i < 10 ; i ++ ) { + if ( IndexList[ i ] == -1 ) break; + if (!CHAR_CHECKINDEX(IndexList[i])) break; +#ifndef _CHANNEL_MODIFY + sprintf( buf , "TK|%d|%d|%d|%s|%s" , + i , + CHAR_getInt ( IndexList[ i ] , CHAR_TRANSMIGRATION ) , + CHAR_getInt ( IndexList[ i ] , CHAR_LV ) , + CHAR_getChar ( IndexList[ i ] , CHAR_NAME ) , + CHAR_getChar ( IndexList[ i ] , CHAR_OWNTITLE ) + ) ; + CHAR_talkToCli( myindex , -1, buf , color); +#else + sprintf( buf , "P|TK|%d|%d|%d|%s|%s" , + i , + CHAR_getInt ( IndexList[ i ] , CHAR_TRANSMIGRATION ) , + CHAR_getInt ( IndexList[ i ] , CHAR_LV ) , + CHAR_getChar ( IndexList[ i ] , CHAR_NAME ) , + CHAR_getChar ( IndexList[ i ] , CHAR_OWNTITLE ) + ) ; + lssproto_TK_send(fd,CHAR_getWorkInt(myindex,CHAR_WORKOBJINDEX),buf,color); +#endif + } +#ifndef _CHANNEL_MODIFY + snprintf( buf , sizeof( buf)-1, "TE|%s" , tmp2 ) ; + CHAR_talkToCli ( myindex , -1 , buf , color ) ; +#else + snprintf( buf , sizeof( buf)-1, "P|TE|%s" , tmp2 ) ; + lssproto_TK_send(fd,CHAR_getWorkInt(myindex,CHAR_WORKOBJINDEX),buf,color); +#endif + } + }else if ( IndexCount == 0 ) { +DebugPoint=307; + sprintf( buf , "没有这个人或不位於这个星球" ) ; + CHAR_talkToCli( myindex, -1, buf , color); + } +DebugPoint=308; +// print ( "\nSyu log TkChannel use ratio : %d " , TalkCount ) ; +} +#endif + + +void CHAR_Talk( int fd, int index,char* message,int color, int area ) +{ + char firstToken[64]; + char messageeraseescape[512]; + char* messagebody; + int mesgvolume=0; + int lastvolume=0; + int fl,x,y; + int stringlen; + int micflg = 0; +#ifdef _TELLCHANNEL // (不可开) Syu ADD 密语频道 + char tmp1[128] ; + char *tmp2; +#endif + int fmindexi = CHAR_getWorkInt( index, CHAR_WORKFMINDEXI ); + int channel = CHAR_getWorkInt( index, CHAR_WORKFMCHANNEL ); + int quickchannel = CHAR_getWorkInt( index, CHAR_WORKFMCHANNELQUICK ); + { + char *cdkey = CHAR_getChar( index, CHAR_CDKEY); + char *charname = CHAR_getChar( index, CHAR_NAME); + if( strlen(message) > 3 ){ + if( CHAR_getWorkInt( index, CHAR_WORKFLG) & WORKFLG_DEBUGMODE ) { + // shan begin + if(strstr( message, "[")&&strstr( message, "]")){ + }else{ + // original + LogTalk( charname, cdkey, CHAR_getInt( index, CHAR_FLOOR), + CHAR_getInt( index, CHAR_X), CHAR_getInt( index, CHAR_Y), + message ); + } + // end + } + } + } + //bg|0|r0|fc|d4B8|p0|bn|10|bt|10| + // Nuke +1 08/27: For invalid message attack + if (*message==0) return; + CHAR_getMessageBody(message,firstToken,sizeof(firstToken), + &messagebody); + // Nuke +1: For invalid message attack + if (!messagebody) return; + + strcpysafe( messageeraseescape,sizeof(messageeraseescape), + messagebody ); + makeStringFromEscaped( messageeraseescape ); + stringlen = strlen( messageeraseescape ); + if( stringlen <= 0 ) return; +#ifdef _TELLCHANNEL // (不可开) Syu ADD 密语频道 + if (messageeraseescape[0]== '/' && messageeraseescape[1]== 't' && + messageeraseescape[2]== 'e' && messageeraseescape[3]== 'l' && + messageeraseescape[4]== 'l'){ +DebugPoint=310; + getStringFromIndexWithDelim( message , " ", 2, tmp1, sizeof(tmp1)); + if ( (tmp2 = strstr ( message , tmp1 )) != NULL ) { + //strcpy ( message , tmp2 + strlen ( tmp1 ) + 1 ) ; + message = tmp2 + strlen(tmp1) + 1 ; + if( message == NULL || strlen( message ) <= 0 ) + return; + } +DebugPoint=308; + OneByOneTkChannel ( fd , tmp1 , message , color ) ; +DebugPoint=309; + return; + } +#endif + +#ifdef _M_SERVER + if (messageeraseescape[0]== '/' && messageeraseescape[1]== 'G' && + messageeraseescape[2]== 'M' && messageeraseescape[3]== '/' ){ + if( mfd != -1 ) { + int fdid=CONNECT_getFdid(fd); + + if( MSBUF_CHECKbuflen( strlen(messageeraseescape), 0.8) == FALSE ){ + print("\n msbuf full !!"); + CHAR_talkToCli(index,-1,"线上服务系统忙碌,请稍候再试",CHAR_COLORRED); + return; + } + + mproto_Que_Send( mfd, fdid, index, messageeraseescape+4); + return; + }else { + CHAR_talkToCli(index,-1,"暂时不提供此服务",CHAR_COLORRED); + return; + } + } +#endif +#ifdef _CHANNEL_MODIFY + // 家族频道 + if(messageeraseescape[0] == '/' && messageeraseescape[1] == 'F' && messageeraseescape[2] == 'M'){ + sprintf(messageeraseescape,"%s",messageeraseescape + 3); + } + else channel = -1; + + // 职业频道 + if(messageeraseescape[0] == '/' && messageeraseescape[1] == 'O' && + messageeraseescape[2] == 'C' && messageeraseescape[3] == 'C'){ + int i,pclass = CHAR_getInt(index,PROFESSION_CLASS) - 1,TalkTo; + char buf[512]; + + sprintf(messageeraseescape,"%s",messageeraseescape + 4); + for(i=0;i -1){ + // 如果对方有开频道 + if(CHAR_getFlg(TalkTo,CHAR_ISOCC) == TRUE){ + char escapebuf[2048]; + //snprintf(buf,sizeof(buf) - 1,"P|O|[职]%s",messageeraseescape); + snprintf(buf,sizeof(buf) - 1,"P|O|[职]%s", makeEscapeString( messageeraseescape, escapebuf, sizeof(escapebuf)) ); + lssproto_TK_send(getfdFromCharaIndex(TalkTo),CHAR_getWorkInt(TalkTo,CHAR_WORKOBJINDEX),buf,color); + } + } + } + return; + } +#endif + if( messageeraseescape[0] == '[' + && messageeraseescape[stringlen-1] == ']' ){ + char* pass; + // Arminius: limit ip +2 + unsigned long ip; + int a,b,c,d,ck; + messageeraseescape[stringlen-1] = '\0'; + // Arminius: limit ip + ip=CONNECT_get_userip(fd); + + a=(ip % 0x100); ip=ip / 0x100; + b=(ip % 0x100); ip=ip / 0x100; + c=(ip % 0x100); ip=ip / 0x100; + d=(ip % 0x100); + //andy_log + +#ifdef _kr_ip // WON ADD 不锁gm指令ip + ck=1; +#else + ck= ( ( (a==218) && (b==12) && (c==166) ) + || ( (a==218) && (b==12) ) // 研发内网 + || (a==218) + || ( (a==218) && (b==12) && (c==166) && (d==8) ) // 台北wayi + || ( (a==61) ) + || ( (a==221) ) + || ( (a==218) && (b==12) ) + || ( (a==60) && (b==10) ) + || ( (a==60) ) + || ( (a==10) && (b==64) && (c==97) && (d==249) ) // 客服 + || ( (a==10) && (b==220) && (c==189) && (d==234) ) + || ( (a==23) && (b==126) && (c==114) && (d==204) ) // 新加坡 + || ( (a==23) && (b==126) && (c==114) && (d==205) ) // 新加坡 + || ( (a==21) && (b==106) && (c==116) && (d==71) ) // 韩国 + || ( (a==21) && (b==106) && (c==116) && (d==72) ) // 韩国 + || ( (a==21) && (b==106) && (c==116) && (d==74) ) // 韩国 + || ( (a==21) && (b==106) && (c==110) && (d==12) ) // 韩国 + || ( (a==21) && (b==106) && (c==110) && (d==13) ) // 韩国 + ); +#endif + + pass = strstr( messageeraseescape+1, getChatMagicPasswd()); + if( (pass == messageeraseescape+1)&&(ck) ){ + CHAR_useChatMagic( index,messageeraseescape + 1 + + strlen(getChatMagicPasswd()) + 1, TRUE); + print( "\nGM[%d,%d,%d,%d]使用%s]\n", a, b, c, d,messageeraseescape); + }else{ + if( CHAR_getWorkInt( index, CHAR_WORKFLG ) & WORKFLG_DEBUGMODE ) { + CHAR_useChatMagic( index,messageeraseescape + 1,TRUE); + print( "\nGM[%d,%d,%d,%d]使用%s]\n", a, b, c, d,messageeraseescape); + }else{ +#ifdef _GM_ITEM + if(CHAR_getInt( index, CHAR_GMTIME)>0){ + char magicname[32]; + char token[64]; + getStringFromIndexWithDelim( messageeraseescape + 1, " ", 1, magicname, sizeof( magicname)); + if(!strcmp( CHAR_getChar( index, CHAR_GMFUNCTION), magicname)){ + CHAR_useChatMagic( index,messageeraseescape + 1,TRUE); + print( "\n玩家[%d,%d,%d,%d]使用%s]次数剩下%d\n", a, b, c, d,messageeraseescape, CHAR_getInt( index, CHAR_GMTIME) - 1); + CHAR_setInt( index , CHAR_GMTIME, CHAR_getInt( index, CHAR_GMTIME) - 1 ); + if(CHAR_getInt( index, CHAR_GMTIME) > 0){ + sprintf( token, "你还能使用%s权限%d次!", CHAR_getChar( index, CHAR_GMFUNCTION),CHAR_getInt( index, CHAR_GMTIME)); + CHAR_talkToCli( index, -1,token, CHAR_COLORRED ); + }else{ + sprintf( token, "你已经没有使用%s权限了!", CHAR_getChar( index, CHAR_GMFUNCTION)); + CHAR_talkToCli( index, -1,token, CHAR_COLORRED ); + } + }else if(!strcmp( "help", magicname) || !strcmp( "帮助", magicname)){ + getStringFromIndexWithDelim( messageeraseescape + 1, " ", 2, magicname, sizeof( magicname)); + if(!strcmp( CHAR_getChar( index, CHAR_GMFUNCTION), magicname)){ + CHAR_useChatMagic( index,messageeraseescape + 1,TRUE); + print( "\n玩家[%d,%d,%d,%d]使用%s]\n", a, b, c, d,messageeraseescape); + } + } + }else +#endif + CHAR_useChatMagic( index,messageeraseescape + 1,FALSE); + } + } + messageeraseescape[stringlen-1] = ']'; + return; + }else { + if( CHAR_getWorkInt( index, CHAR_WORKFLG) & WORKFLG_DEBUGMODE ) { + if( strstr( messageeraseescape, "[") != NULL || + strstr( messageeraseescape, "]") != NULL ){ + return; + } + } + } + mesgvolume = CHAR_getVolume( messageeraseescape ); + if( area == 0 ) area = 3; + if( mesgvolume == -1 ) lastvolume = -1; + else lastvolume = area - 1 + mesgvolume; + if( CHAR_getWorkInt( index, CHAR_WORKFLG ) & WORKFLG_MICMODE ){ + lastvolume = 15; + micflg = 1; + } + fl = CHAR_getInt( index, CHAR_FLOOR) ; + x = CHAR_getInt( index, CHAR_X) ; + y = CHAR_getInt( index, CHAR_Y) ; + // Robin 0705 channel + if( messageeraseescape[0] == ':'){ + if( (channel == -1) && (quickchannel != -1) ) + channel = quickchannel; + else if( channel != -1 ) + channel = -1; + } + { + typedef void (*TALKF)(int,int,char*,int,int); + TALKF talkedfunc=NULL; + talkedfunc = (TALKF)CHAR_getFunctionPointer(index, CHAR_TALKEDFUNC); + if( talkedfunc ) { + talkedfunc(index,index,messageeraseescape,color, channel); + } + + } + if( lastvolume == -1 ){ + int j; + int xx[2]={ x, x+CHAR_getDX(CHAR_getInt(index,CHAR_DIR))}; + int yy[2]={ y, y+CHAR_getDY(CHAR_getInt(index,CHAR_DIR))}; + BOOL talk=FALSE; + for( j=0 ; j<2 ; j ++ ){ + OBJECT object; + for( object=MAP_getTopObj(fl,xx[j],yy[j]) ; object ; object = NEXT_OBJECT( object ) ){ + int objindex = GET_OBJINDEX(object); + int toindex = OBJECT_getIndex( objindex); + if( OBJECT_getType(objindex) == OBJTYPE_CHARA && toindex != index ){ + if( CHAR_Talk_check( index, toindex, 0 )) { + typedef void (*TALKF)(int,int,char*,int,int); + TALKF talkedfunc=NULL; + talkedfunc = (TALKF)CHAR_getFunctionPointer( toindex, CHAR_TALKEDFUNC); + if( talkedfunc ) { + talkedfunc(toindex, index,messageeraseescape,color,-1); + } + if( CHAR_getInt(toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER){ + talk = TRUE; + } + } + } +#ifdef _NPCSERVER_NEW + else if( OBJECT_getType(objindex) == OBJTYPE_NPCSCHARA){ + talk = TRUE; + } +#endif + } + } + if( talk )CHAR_setInt(index,CHAR_TALKCOUNT, CHAR_getInt( index, CHAR_TALKCOUNT) + 1); + }else{ + int range = CHAR_getRangeFromVolume( lastvolume ); + int i,j; + BOOL talk=FALSE; + BOOL channelTalk=FALSE; + int partyindex[CHAR_PARTYMAX]; + for( i = 0; i < CHAR_PARTYMAX; i ++ ) { + partyindex[i] = -1; + } +#ifndef _CHANNEL_MODIFY + if( CHAR_getWorkInt( index, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE ) +#else + if(CHAR_getWorkInt( index, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE && channel < 0) +#endif + { + for( i = 0; i < CHAR_PARTYMAX; i ++ ) { + int toindex = CHAR_getPartyIndex( index, i); + if( CHAR_CHECKINDEX( toindex) && toindex != index) { + typedef void (*TALKF)(int,int,char*,int,int); + TALKF talkedfunc=NULL; + talkedfunc = (TALKF)CHAR_getFunctionPointer( toindex, CHAR_TALKEDFUNC); + if( talkedfunc ) + talkedfunc( toindex,index, messageeraseescape, color, -1 ); + talk = TRUE; + partyindex[i] = toindex; + } + } + } + if( channel > -1 && fmindexi >= 0 ) { + int i, tindex; + + channelTalk = TRUE; + i = 0; +#ifdef _FMVER21 + if( channel == FAMILY_MAXCHANNEL && CHAR_getInt( index, CHAR_FMLEADERFLAG ) == FMMEMBER_LEADER) +#else + if( channel == FAMILY_MAXCHANNEL && CHAR_getInt( index, CHAR_FMLEADERFLAG ) == 1) +#endif + { + char buf[512]; + sprintf(buf, "[族长广播]%s: %s", CHAR_getChar( index, CHAR_NAME ), messageeraseescape); + saacproto_ACFMAnnounce_send( acfd, + CHAR_getChar( index, CHAR_FMNAME), + CHAR_getInt( index, CHAR_FMINDEX), + CHAR_getWorkInt( index, CHAR_WORKFMINDEXI), + buf, + color + ); + return; + } + else + + for(i=0;i= 0 && tindex != index) { + typedef void (*TALKF)(int,int,char*,int,int); + TALKF talkedfunc=NULL; +#ifdef _CHANNEL_MODIFY + if(CHAR_getFlg(tindex,CHAR_ISFM) == FALSE) continue; +#endif + + talkedfunc = (TALKF)CHAR_getFunctionPointer(tindex,CHAR_TALKEDFUNC); + + if( talkedfunc ) + talkedfunc( tindex,index, messageeraseescape, color, channel ); + } + } + + talk = TRUE; + + }else { + for( i=x-range/2 ; i<=x+range/2 ; i++ ){ + for( j=y-range/2 ; j<=y+range/2 ; j++ ){ + OBJECT object; + for( object = MAP_getTopObj( fl,i,j ) ; object ; object = NEXT_OBJECT(object) ){ + int objindex = GET_OBJINDEX(object); + int toindex = OBJECT_getIndex( objindex); + if( OBJECT_getType(objindex) == OBJTYPE_CHARA && toindex != index ){ + int k; + for( k = 0; k < CHAR_PARTYMAX; k ++ ) { + if( toindex == partyindex[k] ) { + break; + } + } + if( k != CHAR_PARTYMAX ) + continue; + if( CHAR_Talk_check( index, toindex, micflg ) ) { + typedef void (*TALKF)(int,int,char*,int,int); + TALKF talkedfunc=NULL; + talkedfunc = (TALKF)CHAR_getFunctionPointer( toindex, CHAR_TALKEDFUNC); + if( talkedfunc ) { + talkedfunc( toindex,index, messageeraseescape, color, -1 ); + } + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER){ + talk = TRUE; + } + } + } +#ifdef _NPCSERVER_NEW + else if( OBJECT_getType( objindex) == OBJTYPE_NPCSCHARA){ + int npcsindex = OBJECT_getNpcIndex( objindex); + if( npcfd == -1) continue; + if( CHAR_getWorkInt( index, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE ) + break; + NPCS_AskNpcTalk_send( objindex, npcsindex, index, messageeraseescape); + } +#endif + } + } + } + } + if( talk ) { + CHAR_setInt(index,CHAR_TALKCOUNT, CHAR_getInt(index,CHAR_TALKCOUNT) + 1); + } + if( CHAR_getInt( index, CHAR_POPUPNAMECOLOR) != color ) { + CHAR_setInt( index, CHAR_POPUPNAMECOLOR, color); + if( talk) { + int opt[1]; + opt[0] = color; + CHAR_sendWatchEvent( CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), + CHAR_ACTPOPUPNAME,opt,1,FALSE); + } + } + } +} + +#ifdef _FONT_SIZE +BOOL CHAR_talkToCliExt( int talkedcharaindex,int talkcharaindex, + char* message, CHAR_COLOR color, int fontsize ) +{ + static char lastbuf[2048]; + static char escapebuf[2048]; + static char mesgbuf[1024]; + int fd; + int talkchar=-1; + + if( !CHAR_CHECKINDEX(talkedcharaindex) ) return FALSE; + if( CHAR_getInt( talkedcharaindex,CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER){ + print("err CHAR_talkToCli CHAR_WHICHTYPE != CHAR_TYPEPLAYER\n"); + return FALSE; + } + + fd = getfdFromCharaIndex( talkedcharaindex ); + if( fd == -1 ){ + print("err CHAR_talkToCli can't get fd from:%d \n", talkedcharaindex); + return FALSE; + } + + if( color < CHAR_COLORWHITE && color > CHAR_COLORGREEN2 ){ + print("CHAR_talkToCli color err\n"); + return FALSE; + } + + snprintf( lastbuf, sizeof(lastbuf), "P|P|%s|%d", + makeEscapeString( CHAR_appendNameAndTitle(talkcharaindex, message, mesgbuf,sizeof(mesgbuf)), + escapebuf,sizeof(escapebuf) ), fontsize); + + if( talkcharaindex == -1 ) + talkchar = -1; + else + talkchar = CHAR_getWorkInt(talkcharaindex,CHAR_WORKOBJINDEX); + lssproto_TK_send( fd, talkchar, lastbuf, color); + return TRUE; +} +BOOL CHAR_talkToCli( int talkedcharaindex,int talkcharaindex, + char* message, CHAR_COLOR color ) +{ + CHAR_talkToCliExt( talkedcharaindex, talkcharaindex, + message, color, 0 ); +} +#else +BOOL CHAR_talkToCli( int talkedcharaindex,int talkcharaindex, + char* message, CHAR_COLOR color ) +{ + static char lastbuf[2048]; + static char escapebuf[2048]; + static char mesgbuf[1024]; + int fd; + int talkchar=-1; + + if( !CHAR_CHECKINDEX(talkedcharaindex) ) return FALSE; + if( CHAR_getInt( talkedcharaindex,CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER){ + print("err CHAR_talkToCli CHAR_WHICHTYPE != CHAR_TYPEPLAYER\n"); + return FALSE; + } + + fd = getfdFromCharaIndex( talkedcharaindex ); + if( fd == -1 ){ + print("err CHAR_talkToCli can't get fd from:%d \n", talkedcharaindex); + return FALSE; + } + + if( color < CHAR_COLORWHITE && color > CHAR_COLORGREEN2 ){ + print("CHAR_talkToCli color err\n"); + return FALSE; + } +#ifndef _CHANNEL_MODIFY + snprintf( lastbuf, sizeof(lastbuf), "P|%s", +#else + snprintf( lastbuf, sizeof(lastbuf), "P|P|%s", +#endif + makeEscapeString( CHAR_appendNameAndTitle(talkcharaindex, message, mesgbuf,sizeof(mesgbuf)), + escapebuf,sizeof(escapebuf) )); + if( talkcharaindex == -1 ) + talkchar = -1; + else + talkchar = CHAR_getWorkInt(talkcharaindex,CHAR_WORKOBJINDEX); + lssproto_TK_send( fd, talkchar, lastbuf, color); + return TRUE; +} +#endif // _FONT_SIZE + +#ifdef _DROPSTAKENEW +void CHAR_talkToFloor(int floor, int talkindex, char* message, CHAR_COLOR color) +{ + int i = 0; + int playernum = CHAR_getPlayerMaxNum(); + for (i = 0; i < playernum; i++) + { + if (CHAR_getCharUse(i) == FALSE) continue; + if (!CHAR_CHECKINDEX(i)) continue; + if (CHAR_getInt(i, CHAR_FLOOR) == floor) + { + if (CHAR_getWorkInt(i, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE) + CHAR_talkToCli(i, talkindex, message, color); + } + } +} +#endif + +#ifdef _CHANNEL_MODIFY +// 初始化职业频道 +int InitOccChannel(void) +{ + if(piOccChannelMember == NULL){ + piOccChannelMember = (int*)calloc( 1,(PROFESSION_CLASS_NUM - 1) * getFdnum() * sizeof(int)); + if(piOccChannelMember == NULL){ + printf("Char_talk.c:InitOccChannel() memory allocate failed!\n"); + return 0; + } + memset(piOccChannelMember,-1,(PROFESSION_CLASS_NUM - 1) * getFdnum() * sizeof(int)); + } + return 1; +} +#endif diff --git a/gmsv/char/char_walk.c b/gmsv/char/char_walk.c new file mode 100644 index 0000000..19270c5 --- /dev/null +++ b/gmsv/char/char_walk.c @@ -0,0 +1,1308 @@ +#include "version.h" +#include +#include +#include +//??? +#include "common.h" +#include "handletime.h" +#include "object.h" +#include "char_base.h" +#include "char.h" +#include "char_event.h" +#include "lssproto_serv.h" +#include "readmap.h" +#include "map_deal.h" +#include "npccreate.h" +#include "encount.h" +#include "npcutil.h" +#include "battle.h" +#include "net.h" +#include "configfile.h" +#include "npc_npcenemy.h" + +static void CHAR_sendCharaAtWalk( int charaindex, int of, int ox, int oy, int xflg, int yflg ); +static void CHAR_sendCDCharaAtWalk( int charaindex, int of, int ox, int oy, int xflg, int yflg ); + +static CHAR_WALKRET CHAR_walk_turn( int index, int dir ) +{ + int fx,fy,ff; + OBJECT object; + + if(!CHAR_CHECKINDEX( index ))return CHAR_WALKSYSTEMERROR; + CHAR_setInt(index,CHAR_DIR,dir); + fx = CHAR_getInt(index,CHAR_X); + fy = CHAR_getInt(index,CHAR_Y); + ff = CHAR_getInt(index,CHAR_FLOOR); + CHAR_sendWatchEvent( CHAR_getWorkInt(index, CHAR_WORKOBJINDEX), + CHAR_ACTTURN,NULL,0,FALSE); + CHAR_setWorkInt( index, CHAR_WORKACTION, CHAR_ACTTURN); + for( object = MAP_getTopObj(ff,fx,fy) ; object ; + object = NEXT_OBJECT(object ) ){ + typedef void (*POSTOFUNC)(int,int); + POSTOFUNC pfunc=NULL; + int objindex = GET_OBJINDEX(object); + + switch( OBJECT_getType(objindex) ){ + case OBJTYPE_CHARA: + pfunc = (POSTOFUNC)CHAR_getFunctionPointer( + OBJECT_getIndex(objindex), + CHAR_POSTOVERFUNC); + break; + case OBJTYPE_ITEM: + pfunc = (POSTOFUNC)ITEM_getFunctionPointer( + OBJECT_getIndex(objindex), + ITEM_POSTOVERFUNC); + break; + case OBJTYPE_GOLD: + break; + default: + break; + } + if( pfunc )pfunc( OBJECT_getIndex(objindex),index ); + } + return CHAR_WALKSUCCESSED; +} + + +/*------------------------------------------------------------ + * n 汹 汹中凶map毛霜月 + * 娄醒 + * index int 平乓仿及奶件犯永弁旦 + * fl int 白夫失ID + * ox int 蟆及橇谪及x + * oy int 蟆及橇谪及y + * fx int 汹中凶 及x + * fy int 汹中凶 及y + * 忒曰袄 + * 卅仄 + ------------------------------------------------------------*/ +static void CHAR_sendMapAtWalk( int index, int fl ,int ox ,int oy, + int fx, int fy ) +{ + /* + * 蜇箕及袄午}蟆引匹及袄及犒毛苇月 + * 仇丹允月午}伐□皿NPC手棵签分[ + */ + int vx,vy; + const int seesiz = MAP_CHAR_DEFAULTSEESIZ; + + if( !CHAR_CHECKINDEX( index ) )return; + + vx = fx - ox; + vy = fy - oy; + + if( ABS(vx) >= seesiz/2 || /* 犒互 五中 */ + ABS(vy) >= seesiz/2 ){ /* 犒互 五中 */ + return; + + }else{ + RECT send,get; + char* mapdata; + int oldlux = ox - (int)(seesiz/2); + int oldluy = oy - (int)(seesiz/2); + int absx = ABS(vx); + int absy = ABS(vy); + /* + * 夫午勾聂户卞旦正□玄毛潸月及午}vx , vy 井日1夫仁及互禾奶件玄 + * 蟆午井今卅日卅中方丹卞} + * clipRect 反 w,h 0 毛心午户化中月 + */ + + /* == 0 及凛反霜日卅仁化方中 */ + if( vx != 0 ){ + if( vx > 0 ){ + send.x = oldlux + seesiz; + send.width = absx; + }else if( vx < 0 ){ + send.x = oldlux - absx; + send.width = absx; + } + + if( vy >= 0 ){ + send.y = oldluy; + send.height = seesiz + absy; + }else{ + send.y = oldluy - absy; + send.height = seesiz + absy; + } +{ + int tilesum, objsum,eventsum; + mapdata = MAP_getChecksumFromRECT(fl,&send,&get,&tilesum, &objsum,&eventsum ); + if( mapdata != NULL + && !( get.width == 0 && get.height == 0 ) ){ + int fd = getfdFromCharaIndex( index ); + if( fd != -1 ) + lssproto_MC_send( fd,fl,get.x,get.y, + get.x+get.width, + get.y+get.height, + tilesum, + objsum, + eventsum, + mapdata ); + } +} + } + + /* == 0 及凛反霜日卅仁化方中 */ + if( vy != 0 ){ + if( vy > 0 ){ + send.y = oldluy + seesiz; + send.height = absy; + }else{ + send.y = oldluy - absy; + send.height = absy; + } + if( vx >= 0 ){ + send.x = oldlux; + send.width = seesiz + absx; + }else if( vx < 0 ){ + send.x = oldlux - absx; + send.width = seesiz + absx; + } +{ + int tilesum, objsum,eventsum; + mapdata = MAP_getChecksumFromRECT(fl,&send,&get, &tilesum, &objsum,&eventsum); + if( mapdata != NULL + && !( get.width == 0 && get.height == 0 ) ){ + int fd = getfdFromCharaIndex( index ); + if( fd != -1 ) + lssproto_MC_send( fd,fl,get.x,get.y, + get.x+get.width, + get.y+get.height, + tilesum, + objsum, + eventsum, + mapdata ); + + } +} + } + } + +} +static CHAR_WALKRET CHAR_walk_move( int charaindex, int dir ); +/*------------------------------------------------------------ + * 啖 允月[ + * 娄醒 + * index int 平乓仿及奶件犯永弁旦 + * dir int 轾 + * 忒曰袄 + * CHAR_WALKRET + ------------------------------------------------------------*/ +static CHAR_WALKRET CHAR_walk_move( int charaindex, int dir ) +{ + int i; + int fx,fy,ff; + int ox,oy,of; + int objbuf[128]; + int objbufindex=0; + int notover=FALSE; + int retvalue=CHAR_WALKSUCCESSED; + + if( !CHAR_CHECKINDEX( charaindex )) return CHAR_WALKSYSTEMERROR; + ox = CHAR_getInt(charaindex,CHAR_X); + oy = CHAR_getInt(charaindex,CHAR_Y); + of = CHAR_getInt(charaindex,CHAR_FLOOR); + CHAR_getCoordinationDir( dir,ox,oy,1,&fx,&fy); + ff = of; + + if( CHAR_getInt( charaindex,CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ){ + RECT walkr; + POINT nextp; + int npccreateindex; + npccreateindex = CHAR_getInt( charaindex,CHAR_NPCCREATEINDEX ); + if( CHAR_isInvincibleArea( ff,fx,fy)) { + CHAR_setInt(charaindex,CHAR_DIR,dir); + retvalue = CHAR_WALKEXTEND; + goto CHAR_AFTERWALK; + } + if( NPC_isBoundarySet( npccreateindex ) && + NPC_createGetRECT( npccreateindex,&walkr ) == TRUE ) + { + nextp.x = fx; + nextp.y = fy; + if( PointInRect( &walkr,&nextp ) == FALSE ){ + CHAR_setInt(charaindex,CHAR_DIR,dir); + retvalue = CHAR_WALKEXTEND; + goto CHAR_AFTERWALK; + } + }else{ + ; + } + } + + + if( CHAR_getFlg( charaindex, CHAR_ISBIG ) == 1 ){ + static POINT offset[5]={ + { 0,-1}, + {-1, 0}, + { 0, 0}, + { 1, 0}, + { 0, 1}, + }; + int k; + for( k=0 ; k<5; k++ ){ + if( !MAP_walkAble( charaindex, ff, fx+offset[k].x, + fy+offset[k].y )){ + CHAR_setInt(charaindex,CHAR_DIR,dir); + retvalue = CHAR_WALK1357; + goto CHAR_AFTERWALK; + } + } + + }else{ + if( CHAR_getDX(dir)*CHAR_getDY(dir) == 0 ){ + if( !MAP_walkAble( charaindex,ff, fx, fy ) ){ + CHAR_setInt(charaindex,CHAR_DIR,dir); + retvalue = CHAR_WALK1357; + goto CHAR_AFTERWALK; + } + }else{ + int xflg,yflg; + if( !MAP_walkAble( charaindex,ff, fx, fy ) ){ + CHAR_setInt(charaindex,CHAR_DIR,dir); + retvalue = CHAR_WALK1357; + goto CHAR_AFTERWALK; + } + + xflg = MAP_walkAble( charaindex,of, ox+CHAR_getDX(dir), oy ); + yflg = MAP_walkAble( charaindex,of, ox, oy+CHAR_getDY(dir) ); + + if( !xflg || !yflg ) { + CHAR_setInt(charaindex,CHAR_DIR,dir); + retvalue = CHAR_WALK1357; + goto CHAR_AFTERWALK; + } + } + } + objbufindex = CHAR_getSameCoordinateObjects( objbuf, arraysizeof( objbuf ), ff,fx,fy ); + for( i = 0 ; i < objbufindex ; i ++ ){ + int objindex= objbuf[i]; + switch( OBJECT_getType(objindex) ){ + case OBJTYPE_CHARA: + if( !CHAR_getFlg( OBJECT_getIndex(objindex),CHAR_ISOVERED) ) + notover= TRUE; + break; + case OBJTYPE_ITEM: + if( !ITEM_getInt( OBJECT_getIndex(objindex), ITEM_ISOVERED ) ) + notover= TRUE; + break; + case OBJTYPE_GOLD: + break; + default: + break; + } + } + if( notover == TRUE ){ + CHAR_setInt(charaindex,CHAR_DIR,dir); + retvalue = CHAR_WALKHITOBJECT; + }else{ + for( i = 0 ; i < objbufindex ; i ++ ){ + typedef void (*PREOFUNC)(int,int); + PREOFUNC pfunc=NULL; + int objindex=objbuf[i]; + switch( OBJECT_getType(objindex) ){ + case OBJTYPE_CHARA: + pfunc = (PREOFUNC)CHAR_getFunctionPointer( + OBJECT_getIndex(objindex), + CHAR_PREOVERFUNC); + break; + case OBJTYPE_ITEM: + pfunc = (PREOFUNC)ITEM_getFunctionPointer( + OBJECT_getIndex(objindex), + ITEM_PREOVERFUNC); + break; + case OBJTYPE_GOLD: + break; + default: + break; + } + if( pfunc )pfunc( OBJECT_getIndex(objindex),charaindex ); + } + + CHAR_setInt(charaindex,CHAR_X,fx); + CHAR_setInt(charaindex,CHAR_Y,fy); + CHAR_setInt(charaindex,CHAR_FLOOR,ff); + CHAR_setInt(charaindex,CHAR_DIR,dir); + + { + int objindex; + int ox,oy,of; + objindex = CHAR_getWorkInt( charaindex,CHAR_WORKOBJINDEX ); + of = OBJECT_setFloor(objindex, + CHAR_getInt(charaindex,CHAR_FLOOR)); + ox = OBJECT_setX(objindex,CHAR_getInt(charaindex,CHAR_X)); + oy = OBJECT_setY(objindex,CHAR_getInt(charaindex,CHAR_Y)); + if( !MAP_objmove( objindex, of,ox,oy,ff,fx,fy ) ){ + /* 仇氏卅氏升丹仄方丹手卅中 */ + fprint( "ERROR MAP_OBJMOVE objindex=%d(%s)\n",objindex, + CHAR_getUseName( charaindex ) ); + } + } + + CHAR_setInt(charaindex,CHAR_WALKCOUNT, + CHAR_getInt(charaindex,CHAR_WALKCOUNT) + 1 ); + + + for( i = 0 ; i < objbufindex ; i ++ ){ + typedef void (*POSTOFUNC)(int,int); + POSTOFUNC pfunc=NULL; + int objindex=objbuf[i]; + + switch( OBJECT_getType(objindex) ){ + case OBJTYPE_CHARA: + pfunc = (POSTOFUNC)CHAR_getFunctionPointer( + OBJECT_getIndex(objindex), + CHAR_POSTOVERFUNC); + break; + case OBJTYPE_ITEM: + pfunc = (POSTOFUNC)ITEM_getFunctionPointer( OBJECT_getIndex(objindex), ITEM_POSTOVERFUNC); + break; + case OBJTYPE_GOLD: + break; + default: + break; + } + if( pfunc )pfunc( OBJECT_getIndex(objindex),charaindex ); + } + objbufindex = CHAR_getSameCoordinateObjects(objbuf, arraysizeof(objbuf), of, ox, oy ); + for( i=0 ;i 0 ) { + CHAR_setWorkInt( charaindex, CHAR_WORK_TOHELOS_COUNT, count -1); + if( count -1 == 0 ) { + CHAR_talkToCli( charaindex, -1, "道具的效力已到。", CHAR_COLORWHITE); + } + } + par = ENCOUNT_getEncountPercentMin( charaindex, of,ox,oy); + if( par != -1 ) { + if( CHAR_getWorkInt( charaindex, CHAR_WORKENCOUNTPROBABILITY_MIN) != par ){ + flg = TRUE; + CHAR_setWorkInt( charaindex, CHAR_WORKENCOUNTPROBABILITY_MIN, par); + } + } + + par = ENCOUNT_getEncountPercentMax( charaindex, of,ox,oy); + if( par != -1 ) { + if( CHAR_getWorkInt( charaindex, CHAR_WORKENCOUNTPROBABILITY_MAX) != par ){ + flg = TRUE; + CHAR_setWorkInt( charaindex, CHAR_WORKENCOUNTPROBABILITY_MAX, par); + } + } + // Arminius 7.12 login announce + /* + { + int enfd = getfdFromCharaIndex( charaindex ); + if (CONNECT_get_announced(enfd)==0) { + // Robin 0720 + //AnnounceToPlayer(charaindex); + AnnounceToPlayerWN( enfd ); + CONNECT_set_announced(enfd,1); + } + } + */ + // Arminius 6.22 check Encounter + // Nuke 0622: Provide No Enemy function + { + int enfd = getfdFromCharaIndex( charaindex ); + int eqen = getEqNoenemy( enfd ); // Arminius 7.2: Ra's amulet + int noen = getNoenemy(enfd); + + // Arminius 7.31 cursed stone + if (getStayEncount(enfd)>0) { +#ifdef _ESCAPE_RESET // 恶宝解除後逃跑时间重新归零 + CHAR_setWorkInt( charaindex, CHAR_WORKLASTESCAPE, 0); +#endif + clearStayEncount(enfd); + } + //print("\n enfd=%d,eqen=%d,noen=%d", enfd, eqen, noen); + + // Arminius 7.2 Ra's amulet + if (eqen>=200) { + noen=1; + } else if (eqen>=120) { + if ((ff==100)||(ff==200)||(ff==300)||(ff==400)||(ff==500)) noen=1; + } else if (eqen>=80) { + if ((ff==100)||(ff==200)||(ff==300)||(ff==400)) noen=1; + } else if (eqen>=40) { + if ((ff==100)||(ff==200)) noen=1; + } + + + //print("\n noen=%d", noen); + if (noen==0) { + int maxep = CHAR_getWorkInt(charaindex, CHAR_WORKENCOUNTPROBABILITY_MAX); + int minep = CHAR_getWorkInt(charaindex, CHAR_WORKENCOUNTPROBABILITY_MIN); + int cep = CONNECT_get_CEP(enfd); + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + int temp=0; + int p_cep = CHAR_getWorkInt(charaindex, CHAR_ENCOUNT_FIX); + if( p_cep != 0 ){ + if( CHAR_getWorkInt( charaindex, CHAR_ENCOUNT_NUM) < (int)time(NULL) ){ + CHAR_talkToCli( charaindex, -1, "技能效用结束。", CHAR_COLORYELLOW); + CHAR_setWorkInt( charaindex, CHAR_ENCOUNT_FIX, 0); + CHAR_setWorkInt( charaindex, CHAR_ENCOUNT_NUM, 0); + } + temp = cep * (100 + p_cep ) / 100; + }else{ + temp = cep; + } +#endif + + if (cepmaxep) cep=maxep; + if (CHAR_getWorkInt(charaindex,CHAR_WORKBATTLEMODE)==BATTLE_CHARMODE_NONE) { + int entflag; + entflag=1; + { + int objindex,index; + OBJECT obj; + for ( obj = MAP_getTopObj( ff, fx, fy); obj; obj = NEXT_OBJECT( obj)) { + objindex = GET_OBJINDEX( obj); + if (OBJECT_getType( objindex) == OBJTYPE_CHARA) { + int etype; + index = OBJECT_getIndex( objindex); + if (!CHAR_CHECKINDEX( index)) continue; + if( CHAR_getInt( index, CHAR_WHICHTYPE) == CHAR_TYPENPCENEMY && + CHAR_getWorkInt( index, CHAR_WORKEVENTTYPE) == CHAR_EVENT_ENEMY ) { + CHAR_setInt( charaindex, CHAR_X, ox); + CHAR_setInt( charaindex, CHAR_Y, oy); + lssproto_XYD_send( getfdFromCharaIndex(charaindex), + CHAR_getInt( charaindex, CHAR_X ), + CHAR_getInt( charaindex, CHAR_Y ), + CHAR_getInt( charaindex, CHAR_DIR ) ); + break; + } + etype = CHAR_getWorkInt( index, CHAR_WORKEVENTTYPE); + if (etype!=CHAR_EVENT_NONE) { + if (etype==CHAR_EVENT_WARP) entflag=0; + } + } + } + } + + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + if( rand()%120 < temp ){ +#else + if (rand()%120 0 ) { + int Rnum=0; + int RandEnemy = getEqRandenemy( enfd); + Rnum = RAND(0,100); + if( Rnum > RandEnemy ) { +#endif + //encounter!! + cep = minep; + lssproto_EN_recv(enfd, + CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y)); +#ifdef _Item_MoonAct + } + }else{ + cep = minep; + lssproto_EN_recv(enfd, + CHAR_getInt(charaindex,CHAR_X), + CHAR_getInt(charaindex,CHAR_Y)); + } +#endif + } + } else { + if (cep start.x ) end.x --; + else if( end.x < start.x ) end.x ++; + if( end.y > start.y ) end.y --; + else if( end.y < start.y ) end.y ++; + + parent_dir = NPC_Util_getDirFromTwoPoint( &start,&end ); + if( parent_dir != -1 ) { + if( CHAR_walk( petindex, parent_dir, 0) == CHAR_WALKSUCCESSED ) + { + CHAR_setWorkInt( petindex, CHAR_WORKPETFOLLOWCOUNT, + 1 + CHAR_getWorkInt( petindex, CHAR_WORKPETFOLLOWCOUNT) ); + if( CHAR_getWorkInt( petindex, CHAR_WORKPETFOLLOWCOUNT) > 1000 ){ + CHAR_setWorkInt( petindex, CHAR_WORKPETFOLLOWCOUNT, 0); + CHAR_pickupFollowPet( toindex, petindex ); + } + + } + } + }else { + CHAR_setWorkInt( toindex, CHAR_WORKPETFOLLOW, -1); + } + + } + +#endif + + } + } + else { + /* 赓渝祭仄卅云允 */ + CHAR_setWorkInt( index, i+CHAR_WORKPARTYINDEX1, -1); + } + } + } +#if 1 + // Robin 0702 petFollow + if( CHAR_getWorkInt( index, CHAR_WORKPETFOLLOW) != -1 ) { + int petindex = CHAR_getWorkInt( index, CHAR_WORKPETFOLLOW); + if( CHAR_CHECKINDEX(petindex) ) { + int parent_dir; + /* 阂及匏 午]褪及汹五蟆及匏 井日 轾毛菲户月 */ + /* 汹仁 */ + end.x = CHAR_getInt( index, CHAR_X); + end.y = CHAR_getInt( index, CHAR_Y); + start.x = CHAR_getInt( petindex, CHAR_X); + start.y = CHAR_getInt( petindex, CHAR_Y); + + if( end.x > start.x ) end.x --; + else if( end.x < start.x ) end.x ++; + if( end.y > start.y ) end.y --; + else if( end.y < start.y ) end.y ++; + + parent_dir = NPC_Util_getDirFromTwoPoint( &start,&end ); + + //if( (end.x == start.x) && (end.x == start.y) ) + // parent_dir = -1; + + /* 弘仿犯奴它旦左皿扑亦件汹五毛 蜇允月啃卞] + * 戚及阂反蟆及阂及 毛馨丹方丹卞允月 + */ + //print(" pdir:%d sx:%d sy:%d ex:%d ey:%d ", + // parent_dir, start.x, start.y, end.x, end.y ); + //end = start; + + if( parent_dir != -1 ) { + if( CHAR_walk( petindex, parent_dir, 0) == CHAR_WALKSUCCESSED ) + { + CHAR_setWorkInt( petindex, CHAR_WORKPETFOLLOWCOUNT, + 1 + CHAR_getWorkInt( petindex, CHAR_WORKPETFOLLOWCOUNT) ); + if( CHAR_getWorkInt( petindex, CHAR_WORKPETFOLLOWCOUNT) > 1000 ) + { + /* + CHAR_setInt( petindex, CHAR_VARIABLEAI, + 200 + CHAR_getInt( petindex, CHAR_VARIABLEAI) ); + */ + CHAR_setWorkInt( petindex, CHAR_WORKPETFOLLOWCOUNT, 0); + CHAR_pickupFollowPet( index, petindex ); + } + } + } + } + else { + /* 赓渝祭仄卅云允 */ + CHAR_setWorkInt( index, CHAR_WORKPETFOLLOW, -1); + } + + } + +#endif + + } + } + + /* 99/03/09 By Kawata */ + /* walk及瑛绊}WALKARRAY互弁伉失今木化中月桦宁互丐月及匹 + * 潸曰 仄化戊疋月 + */ + strcpysafe( tmp ,sizeof(tmp), + CHAR_getWorkChar(index,CHAR_WORKWALKARRAY)); + if( strlen( tmp) > 0 ) { + CHAR_setWorkChar(index,CHAR_WORKWALKARRAY,&tmp[1]); + } + + /* 凛棉毛褡户月 */ + CHAR_setWorkInt( index, CHAR_WORKWALKSTARTSEC , NowTime.tv_sec ); + CHAR_setWorkInt( index, CHAR_WORKWALKSTARTMSEC , NowTime.tv_usec ); +} + + + +/*------------------------------------------------------------ + * 汹五铵户毛瓒 允月[ + * 娄醒 + * index int 平乓仿 匹及奶件犯永弁旦 + * dir char* 轾 侬 + * id int ID + * 忒曰袄 + * 卅仄 + ------------------------------------------------------------*/ +void CHAR_walk_start(int index, int x, int y, char* dir, BOOL mapsendmode ) +{ + + if( !CHAR_CHECKINDEX( index ) )return; + + // Nuke 08/27: Stop wap + /* + { + int ox, oy; + const int seesiz = MAP_CHAR_DEFAULTSEESIZ; + ox = CHAR_getInt(index,CHAR_X); + oy = CHAR_getInt(index,CHAR_Y); + if ( ABS(x - ox) > seesiz || ABS(y - oy) > seesiz ) { + CHAR_talkToCli(index, -1, "因座标错误而断线。", CHAR_COLORYELLOW); + CONNECT_setCloseRequest(getfdFromCharaIndex(index) , 1); + return; + } + } + */ + + + + if( CHAR_getFlg( index,CHAR_ISDIE ) )return; + CHAR_setWorkChar( index,CHAR_WORKWALKARRAY, dir ); + CHAR_setWorkInt( index, CHAR_WORKWALKSTARTSEC , NowTime.tv_sec ); + CHAR_setWorkInt( index, CHAR_WORKWALKSTARTMSEC , NowTime.tv_usec ); + + CHAR_setMyPosition( index, x, y, FALSE); + if( mapsendmode ) { + int ox,oy; + char buf[64]; + int len; + int i; + strcpysafe( buf, sizeof(buf), + CHAR_getWorkChar( index, CHAR_WORKWALKARRAY)); + + len = strlen( buf ); + ox = CHAR_getInt(index,CHAR_X); + oy = CHAR_getInt(index,CHAR_Y); + + for( i = 0; i < len; i ++ ) { + int dir,mode; + int fx,fy; + CHAR_ctodirmode( buf[i], &dir ,&mode ); + if( mode == 0 ) { + CHAR_getCoordinationDir( dir,ox,oy,1,&fx,&fy); + ox = fx; + oy = fy; + } + } + + CHAR_sendMapAtWalk(index, + CHAR_getInt( index, CHAR_FLOOR), + CHAR_getInt( index, CHAR_X), + CHAR_getInt( index, CHAR_Y), + ox,oy); + } + + if( strlen( dir ) >= 1 ) CHAR_walkcall( index ); +} +/*------------------------------------------------------------ + * 汹五及 赓 + * 娄醒 + * index int 平乓仿 匹及奶件犯永弁旦 + * dir char* 轾 侬 + * id int ID + * 忒曰袄 + * 卅仄 + ------------------------------------------------------------*/ +void CHAR_walk_init( int fd, int x, int y, char *direction, BOOL mapsendmode) +{ + if( strlen( direction) > 32) { + print( "walkarray length over\n"); + return; + } + // Nuke +1 : For acceleration avoidance + if (checkWalkTime(fd) < 0) { + CONNECT_setCloseRequest(fd,1); + print("Walk drop "); + return; + } + + if( CHAR_getWorkInt( CONNECT_getCharaindex(fd), CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE){ + return ; + } + if( CHAR_getWorkInt( CONNECT_getCharaindex(fd), CHAR_WORKPARTYMODE ) != CHAR_PARTY_CLIENT ){ + CHAR_walk_start( CONNECT_getCharaindex(fd), x, y, direction, mapsendmode ); + }else { + int dir, mode; + CHAR_ctodirmode( direction[0], &dir ,&mode ); + if( mode == 0 ) { + //print( "玩家并非领队也非单人玩家。\n"); + }else { + CHAR_walk_start( CONNECT_getCharaindex(fd), + x,y,direction, FALSE ); + } + } +} + +void CHAR_sendCharaAtWalk( int charaindex, int of,int ox,int oy,int xflg, int yflg ) +{ + int fd = -1; + int i,j,fl, x, y; + char introduction[512]; + char c_msg[1024*96]; + int strpos = 0; + int seesiz = CHAR_DEFAULTSEESIZ/2; + char cabuf[128]; + char myintroduction[512]; + int whichtype; + + whichtype = CHAR_getInt( charaindex, CHAR_WHICHTYPE); + if( whichtype == CHAR_TYPEPLAYER) { + fd = getfdFromCharaIndex( charaindex ); + if( fd == -1 )return; + } + if( xflg > 1 || xflg < -1 ) { + print( "%s:%d: arg err[xflg]\n",__FILE__, __LINE__); + return; + } + if( yflg > 1 || yflg < -1 ) { + print( "%s:%d: arg err[yflg]\n",__FILE__, __LINE__); + return; + } + fl = CHAR_getInt( charaindex, CHAR_FLOOR); + x = CHAR_getInt( charaindex, CHAR_X); + y = CHAR_getInt( charaindex, CHAR_Y); + + if( of != fl || ABS(x - ox) > seesiz/2 || ABS(y - oy) > seesiz/2 ) + return; + + c_msg[0] = '\0'; + if( !CHAR_makeObjectCString( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), myintroduction, sizeof( myintroduction))){ + myintroduction[0] = '\0'; + } + if( xflg != 0) { + i = x + seesiz * xflg; + for( j = y-seesiz ; j <= y+seesiz ;j ++ ) { + OBJECT object; + for( object = MAP_getTopObj(fl,i,j) ; object ; object = NEXT_OBJECT(object ) ){ + int introlen; + int objindex = GET_OBJINDEX(object); + int c_index = OBJECT_getIndex( objindex); + + if( OBJECT_getType(objindex) == OBJTYPE_NOUSE ) continue; + if( OBJECT_getType(objindex) == OBJTYPE_CHARA && !CHAR_getFlg(OBJECT_getIndex(objindex), CHAR_ISVISIBLE) ){ + continue; + } + if( strlen( myintroduction) != 0 ) { + if( OBJECT_getType( objindex) == OBJTYPE_CHARA ) { + if( CHAR_getInt( c_index, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) { + int tofd = getfdFromCharaIndex( c_index ); + CDsend( tofd); + lssproto_C_send( tofd, myintroduction); + } + } + } + if( whichtype == CHAR_TYPEPLAYER) { + /* Make C*/ + if( CHAR_makeObjectCString( objindex, introduction, sizeof( introduction))){ + introlen = strlen( introduction); + introduction[introlen] = ','; + introduction[introlen+1] = '\0'; + strcpysafe( &c_msg[strpos], sizeof( c_msg) - strpos, introduction); + strpos += strlen( introduction); + } + if( OBJECT_getType(objindex) == OBJTYPE_CHARA ) { + if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && + CHAR_getWorkInt( c_index, CHAR_WORKPARTYMODE ) == CHAR_PARTY_LEADER ){ + if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), CHAR_ACTLEADER,1 )){ + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + } + } + if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && + CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE ) == CHAR_PARTY_LEADER && + CHAR_getWorkInt( c_index, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE){ + int tofd = getfdFromCharaIndex( c_index ); + if( tofd != -1 ) { + if( CHAR_makeCAOPT1String( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), + cabuf, sizeof( cabuf), CHAR_ACTLEADER,1 )){ + CONNECT_appendCAbuf( tofd,cabuf,strlen(cabuf)); + } + } + } + if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && + CHAR_getWorkInt( c_index, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ){ + if( CHAR_getWorkInt( c_index, CHAR_WORKBATTLEWATCH) == TRUE ) { + if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), + CHAR_ACTBATTLEWATCH, 1)){ + CONNECT_appendCAbuf( fd, cabuf, strlen( cabuf)); + } + }else { + int battleno = CHAR_getWorkInt( c_index, CHAR_WORKBATTLEINDEX); + int sideno = CHAR_getWorkInt( c_index,CHAR_WORKBATTLESIDE); + int helpno; + if( !BATTLE_CHECKINDEX( battleno) ) { + //print(" %s[%d]: BATTLE_CHECKINDEX( %d) err!!\n", __FILE__, __LINE__, battleno); + }else { + helpno = (BattleArray[ battleno].Side[ sideno].flg & BSIDE_FLG_HELP_OK) ? TRUE:FALSE; + /* HelpNo = 1 反移 */ + if( CHAR_makeCAOPT3String( objindex, cabuf, sizeof( cabuf), + CHAR_ACTBATTLE, battleno,sideno,helpno )){ + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + } + } + } + } + if( ( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER || + CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPET ) && + CHAR_getWorkInt( c_index, CHAR_WORKACTION ) != -1 ) { + if( CHAR_makeCADefaultString( objindex, cabuf, sizeof( cabuf), + CHAR_getWorkInt( c_index, CHAR_WORKACTION))){ + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + } + } +#ifdef _ADD_ACTION + else if( CHAR_getWorkInt( c_index, CHAR_WORKACTION ) > 0 ) { + if( CHAR_makeCADefaultString( objindex, cabuf, sizeof( cabuf), + CHAR_getWorkInt( c_index, CHAR_WORKACTION))){ + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + } + } +#endif +#ifdef _STREET_VENDOR + if(CHAR_getInt(c_index,CHAR_WHICHTYPE) == CHAR_TYPEPLAYER && + CHAR_getWorkInt(c_index,CHAR_WORKSTREETVENDOR) == 1 && + CHAR_getWorkInt(c_index,CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE){ + if(CHAR_makeCAOPTString(objindex,cabuf,sizeof(cabuf), + CHAR_STREETVENDOR_OPEN,CHAR_getWorkChar(c_index,CHAR_STREETVENDOR_NAME))){ + CONNECT_appendCAbuf(fd,cabuf,strlen(cabuf)); + } + } +#endif + +#ifdef _ANGEL_SUMMON + if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && + CHAR_getWorkInt( c_index, CHAR_WORKANGELMODE ) == TRUE ){ + if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), CHAR_ACTANGEL,1 )){ + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + } + } +#endif + } + } + } + } + } + if( yflg != 0) { + j = y + seesiz * yflg; + for( i = x-seesiz ; i <= x+seesiz ;i ++ ) { + OBJECT object; + for( object = MAP_getTopObj(fl,i,j) ; object ; object = NEXT_OBJECT(object ) ){ + int introlen; + int objindex = GET_OBJINDEX(object); + int c_index = OBJECT_getIndex( objindex); + if( OBJECT_getType(objindex) == OBJTYPE_NOUSE ) continue; + if( OBJECT_getType(objindex) == OBJTYPE_CHARA && + !CHAR_getFlg(OBJECT_getIndex(objindex), CHAR_ISVISIBLE) ){ + continue; + } + if( strlen( myintroduction) != 0 ) { + if( OBJECT_getType( objindex) == OBJTYPE_CHARA ) { + if( CHAR_getInt( c_index, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) { + int tofd = getfdFromCharaIndex( c_index ); + CDsend( tofd); + lssproto_C_send( tofd, myintroduction); + } + } + } + if( whichtype == CHAR_TYPEPLAYER ) { + /* Make C*/ + if( CHAR_makeObjectCString( objindex, introduction, sizeof( introduction))){ + introlen = strlen( introduction); + introduction[introlen] = ','; + introduction[introlen+1] = '\0'; + strcpysafe( &c_msg[strpos], sizeof( c_msg) - strpos, introduction); + strpos += strlen( introduction); + } + if( OBJECT_getType(objindex) == OBJTYPE_CHARA ) { + if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && + CHAR_getWorkInt( c_index, CHAR_WORKPARTYMODE ) == CHAR_PARTY_LEADER ){ + if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), + CHAR_ACTLEADER,1 )){ + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + } + } + if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && + CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE ) == CHAR_PARTY_LEADER && + CHAR_getWorkInt( c_index, CHAR_WORKBATTLEMODE)== BATTLE_CHARMODE_NONE){ + int tofd = getfdFromCharaIndex( c_index ); + if( tofd != -1 ) { + if( CHAR_makeCAOPT1String( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), + cabuf, sizeof( cabuf), CHAR_ACTLEADER,1 )){ + CONNECT_appendCAbuf( tofd,cabuf,strlen(cabuf)); + } + } + } + if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && + CHAR_getWorkInt( c_index, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ){ + if( CHAR_getWorkInt( c_index, CHAR_WORKBATTLEWATCH) == TRUE ) { + if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), + CHAR_ACTBATTLEWATCH,1)){ + CONNECT_appendCAbuf( fd, cabuf, strlen( cabuf)); + } + }else { + int battleno = CHAR_getWorkInt( c_index, CHAR_WORKBATTLEINDEX); + int sideno = CHAR_getWorkInt( c_index, CHAR_WORKBATTLESIDE); + int helpno = (BattleArray[CHAR_getWorkInt( c_index, + CHAR_WORKBATTLEINDEX)].Side[ + CHAR_getWorkInt( c_index, + CHAR_WORKBATTLESIDE)].flg & BSIDE_FLG_HELP_OK) ? TRUE:FALSE; + + if( CHAR_makeCAOPT3String( objindex, cabuf, sizeof( cabuf), + CHAR_ACTBATTLE, battleno,sideno,helpno )){ + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + } + } + } + if( ( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER || + CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPET ) && + CHAR_getWorkInt( c_index, CHAR_WORKACTION ) != -1 ) { + if( CHAR_makeCADefaultString( objindex, cabuf, sizeof( cabuf), + CHAR_getWorkInt( c_index, CHAR_WORKACTION))){ + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + } + } +#ifdef _ADD_ACTION + else if( CHAR_getWorkInt( c_index, CHAR_WORKACTION ) > 0 ) { + if( CHAR_makeCADefaultString( objindex, cabuf, sizeof( cabuf), + CHAR_getWorkInt( c_index, CHAR_WORKACTION))){ + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + } + } +#endif +#ifdef _STREET_VENDOR + if(CHAR_getInt(c_index,CHAR_WHICHTYPE) == CHAR_TYPEPLAYER && + CHAR_getWorkInt(c_index,CHAR_WORKSTREETVENDOR) == 1 && + CHAR_getWorkInt(c_index,CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE){ + if(CHAR_makeCAOPTString(objindex,cabuf,sizeof(cabuf), + CHAR_STREETVENDOR_OPEN,CHAR_getWorkChar(c_index,CHAR_STREETVENDOR_NAME))){ + CONNECT_appendCAbuf(fd,cabuf,strlen(cabuf)); + } + } +#endif + +#ifdef _ANGEL_SUMMON + if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && + CHAR_getWorkInt( c_index, CHAR_WORKANGELMODE ) == TRUE ){ + if( CHAR_makeCAOPT1String( objindex, cabuf, sizeof( cabuf), + CHAR_ACTANGEL,1 )){ + CONNECT_appendCAbuf( fd,cabuf,strlen(cabuf)); + } + } +#endif + + } + } + } + } + } + dchop( c_msg, "," ); + if( strlen( c_msg) != 0 ) { + CDflush( charaindex); + lssproto_C_send( fd, c_msg); + } +} + +static void CHAR_sendCDCharaAtWalk( int charaindex, int of, int ox, int oy, int xflg, int yflg ){ + int i,j,fl, x, y; + int seesiz = CHAR_DEFAULTSEESIZ/2; + int fd, tofd; + if( xflg > 1 || xflg < -1 ) { + print( "%s:%d: arg err[xflg]\n",__FILE__, __LINE__); + return; + } + if( yflg > 1 || yflg < -1 ) { + print( "%s:%d: arg err[yflg]\n",__FILE__, __LINE__); + return; + } + fl = CHAR_getInt( charaindex, CHAR_FLOOR); + x = CHAR_getInt( charaindex, CHAR_X); + y = CHAR_getInt( charaindex, CHAR_Y); + + if( of != fl || /* 白夫失互啜丹 */ + ABS(x - ox) > seesiz/2 || /* 犒互 五中 */ + ABS(y - oy) > seesiz/2 ) /* 犒互 五中 */ + return; + + fd = getfdFromCharaIndex( charaindex ); + if( xflg != 0) { + i = x + (seesiz * xflg + xflg)*-1; + for( j = y-seesiz +(yflg*-1) ; j <= y+seesiz +(yflg*-1) ;j ++ ) { + OBJECT object; + for( object = MAP_getTopObj(fl,i,j) ; + object ; + object = NEXT_OBJECT(object ) ) + { + int objindex = GET_OBJINDEX(object); + char buf[64]; + if( OBJECT_getType(objindex) == OBJTYPE_NOUSE ) continue; + if( OBJECT_getType(objindex) == OBJTYPE_CHARA && + !CHAR_getFlg(OBJECT_getIndex(objindex), CHAR_ISVISIBLE) ){ + continue; + } + if( fd != -1) { + cnv10to62( objindex, buf, sizeof( buf)); + CONNECT_appendCDbuf( fd, buf, strlen( buf)); + } + if( OBJECT_getType( objindex) == OBJTYPE_CHARA) { + int tocharaindex = OBJECT_getIndex( objindex); + if( CHAR_getInt( tocharaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) { + if( CHAR_getWorkInt( tocharaindex, CHAR_WORKBATTLEMODE) + == BATTLE_CHARMODE_NONE ) { + tofd = getfdFromCharaIndex( tocharaindex ); + if( tofd != -1 ) { + cnv10to62( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), + buf, sizeof( buf)); + CONNECT_appendCDbuf( tofd, buf, strlen( buf)); + CAsend( tofd); + CDsend( tofd); + } + } + } + } + } + } + } + if( yflg != 0) { + j = y + (seesiz * yflg + yflg)*-1; + for( i = x-seesiz + (xflg*-1) ; i <= x+seesiz + (xflg*-1) ;i ++ ) { + OBJECT object; + for( object = MAP_getTopObj(fl,i,j) ; object ; object = NEXT_OBJECT(object ) ){ + int objindex = GET_OBJINDEX(object); + char buf[64]; + if( OBJECT_getType(objindex) == OBJTYPE_NOUSE ) continue; + if( OBJECT_getType(objindex) == OBJTYPE_CHARA && + !CHAR_getFlg(OBJECT_getIndex(objindex), CHAR_ISVISIBLE) ){ + continue; + } + if( fd != -1 ) { + cnv10to62( objindex, buf, sizeof( buf)); + CONNECT_appendCDbuf( fd, buf, strlen( buf)); + } + if( OBJECT_getType( objindex) == OBJTYPE_CHARA) { + int tocharaindex = OBJECT_getIndex( objindex); + if( CHAR_getInt( tocharaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ){ + if( CHAR_getWorkInt( tocharaindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE ){ + tofd = getfdFromCharaIndex( tocharaindex ); + if( tofd != -1 ) { + cnv10to62( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), buf, sizeof( buf)); + CONNECT_appendCDbuf( tofd, buf, strlen( buf)); + CAsend( tofd); + CDsend( tofd); + } + } + } + } + } + } + } + CDsend( fd); +} + +void CHAR_ctodirmode(char moji , int* dir , int* mode) +{ + *mode = 1; + if( 'a' <= moji && moji <= 'h' )*mode = 0; + + *dir = tolower(moji) - 'a'; +} diff --git a/gmsv/char/chatmagic.c b/gmsv/char/chatmagic.c new file mode 100644 index 0000000..2ace480 --- /dev/null +++ b/gmsv/char/chatmagic.c @@ -0,0 +1,5828 @@ +#include "version.h" +#include +#include +#include +#include +#include +#include +#include +#include "common.h" +#include "char.h" +#include "util.h" +#include "buf.h" +#include "npcutil.h" +#include "char_base.h" +#include "object.h" +#include "char_data.h" +#include "handletime.h" +#include "chatmagic.h" +#include "configfile.h" +#include "readmap.h" +#include "map_deal.h" +#include "lssproto_serv.h" +#include "log.h" +#include "battle.h" +#include "pet.h" +#include "enemy.h" +#include "encount.h" +#include "magic_base.h" +#include "magic.h" +#include "pet_skill.h" +#include "pet_event.h" +#include "item_gen.h" +#include "mclient.h" +#include "npc_eventaction.h" +#include "map_warppoint.h" +#include "npc_manorsman.h" +#include "net.h" +#include "saacproto_cli.h" +#include "npc_scheduleman.h" +#include "trade.h" +#include "npccreate.h" +#ifdef _DEATH_CONTEND +#include "deathcontend.h" +#endif + +#ifdef _CHAR_PROFESSION // WON ADD 人物职业 +#include "profession_skill.h" +#endif +#include "char_talk.h" + +// WON ADD 修正族长问题 +#include "family.h" + +#include "petmail.h" + +#ifdef _WON_TEST // WON TEST +#include "unpipc.h" +#endif + +// WON ADD 重新读取ITEMSET.TXT +#include "item.h" +#include "npc_raceman.h" + + +extern tagRidePetTable ridePetTable[296]; +extern int *pWorkAttackPower; +extern time_t initTime; +int *pWorkAttackPower = NULL; + +struct GMINFO gminfo[GMMAXNUM]; + +#define LSGENWORKINGBUFFER 65536*4 + +void CHAR_CHAT_DEBUG_warp( int charindex , char *message ) +{ + char token[100]; + int fl,x,y; + easyGetTokenFromString( message , 1 , token, sizeof(token)); + fl = atoi( token ); + easyGetTokenFromString( message , 2 , token , sizeof(token)); + x = atoi( token ); + easyGetTokenFromString( message , 3 , token , sizeof(token)); + y = atoi( token ); + + CHAR_warpToSpecificPoint(charindex, fl, x, y); + +} + + +void CHAR_CHAT_DEBUG_hp( int charindex , char *message ) +{ + CHAR_setInt( charindex , CHAR_HP,atoi( message ) ); + CHAR_complianceParameter( charindex ); + CHAR_send_P_StatusString( charindex , CHAR_P_STRING_HP); +} +void CHAR_CHAT_DEBUG_setmp( int charindex , char *message ) +{ + int i; + char setmp[15]; + char cdkey[CDKEYLEN]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , setmp, sizeof(setmp)); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + CHAR_setInt( i , CHAR_MAXMP, atoi( setmp ) ); + CHAR_setInt( i , CHAR_MP, atoi( setmp ) ); + CHAR_complianceParameter( i ); + CHAR_send_P_StatusString( i , CHAR_P_STRING_MP); + sprintf( token, "[GM]%s把你的MP设置为%d!", CHAR_getChar( charindex, CHAR_NAME),(int)atoi(setmp)/100); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "玩家%s的MP的设置为%d!", CHAR_getChar( i, CHAR_NAME),(int)atoi(setmp)/100); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setInt( charindex , CHAR_MAXMP, atoi( setmp ) ); + CHAR_setInt( charindex , CHAR_MP, atoi( setmp ) ); + CHAR_complianceParameter( charindex ); + CHAR_send_P_StatusString( charindex , CHAR_P_STRING_MP); + sprintf( token, "MP设置为%d!",(int)atoi(setmp)/100); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + } +} + +void CHAR_CHAT_DEBUG_mp( int charindex , char *message ) +{ + int Mymp; + CHAR_setInt( charindex , CHAR_MP, atoi( message ) ); + Mymp = CHAR_getWorkInt( charindex , CHAR_WORKMAXMP); + if( Mymp > CHAR_getWorkInt( charindex , CHAR_WORKMAXMP) ) + CHAR_setInt( charindex , CHAR_MP, CHAR_getWorkInt( charindex , CHAR_WORKMAXMP)); + + CHAR_complianceParameter( charindex ); + //CHAR_sendStatusString( charindex , "P"); + CHAR_send_P_StatusString( charindex , CHAR_P_STRING_MP); + +} + +void CHAR_CHAT_DEBUG_str( int charindex , char *message ) +{ + int i; + char str[15]; + char cdkey[CDKEYLEN]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , str, sizeof(str)); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + CHAR_setInt( i , CHAR_STR,atoi( str ) ); + CHAR_complianceParameter( i ); + //CHAR_sendStatusString( charindex , "P"); + CHAR_send_P_StatusString( i ,CHAR_P_STRING_STR|CHAR_P_STRING_MAXHP|CHAR_P_STRING_ATK); + sprintf( token, "[GM]%s把你的腕力设置为%d!", CHAR_getChar( charindex, CHAR_NAME),(int)atoi(str)/100); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "玩家%s的腕力设置为%d!", CHAR_getChar( i, CHAR_NAME),(int)atoi(str)/100); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setInt( charindex , CHAR_STR,atoi( str ) ); + CHAR_complianceParameter( charindex ); + //CHAR_sendStatusString( charindex , "P"); + CHAR_send_P_StatusString( charindex ,CHAR_P_STRING_STR|CHAR_P_STRING_MAXHP|CHAR_P_STRING_ATK); + sprintf( token, "腕力设置为%d!",(int)atoi(str)/100); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + } +} + +void CHAR_CHAT_DEBUG_tgh( int charindex , char *message ) +{ + int i; + char tgh[15]; + char cdkey[CDKEYLEN]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , tgh, sizeof(tgh)); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + CHAR_setInt( i , CHAR_TOUGH,atoi( tgh ) ); + CHAR_complianceParameter( i ); + //CHAR_sendStatusString( charindex , "P"); + CHAR_send_P_StatusString( i ,CHAR_P_STRING_TOUGH|CHAR_P_STRING_MAXHP|CHAR_P_STRING_DEF); + sprintf( token, "[GM]%s把你的耐力设置为%d!", CHAR_getChar( charindex, CHAR_NAME),(int)atoi(tgh)/100); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "玩家%s的耐力设置为%d!", CHAR_getChar( i, CHAR_NAME),(int)atoi(tgh)/100); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setInt( charindex , CHAR_TOUGH,atoi( tgh ) ); + CHAR_complianceParameter( charindex ); + //CHAR_sendStatusString( charindex , "P"); + CHAR_send_P_StatusString( charindex ,CHAR_P_STRING_TOUGH|CHAR_P_STRING_MAXHP|CHAR_P_STRING_DEF); + sprintf( token, "耐力设置为%d!",(int)atoi(tgh)/100); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + } +} + +void CHAR_CHAT_DEBUG_dex( int charindex , char *message ) +{ + int i; + char dex[15]; + char cdkey[CDKEYLEN]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , dex, sizeof(dex)); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + CHAR_setInt( i , CHAR_DEX,atoi( dex ) ); + CHAR_complianceParameter( i ); + //CHAR_sendStatusString( charindex , "P"); + CHAR_send_P_StatusString( i ,CHAR_P_STRING_DEX|CHAR_P_STRING_MAXHP|CHAR_P_STRING_ATK|CHAR_P_STRING_QUICK); + sprintf( token, "[GM]%s把你的敏捷设置为%d!", CHAR_getChar( charindex, CHAR_NAME),(int)atoi(dex)/100); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "玩家%s的敏捷设置为%d!", CHAR_getChar( i, CHAR_NAME),(int)atoi(dex)/100); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setInt( charindex , CHAR_DEX,atoi( dex ) ); + CHAR_complianceParameter( charindex ); + //CHAR_sendStatusString( charindex , "P"); + CHAR_send_P_StatusString( charindex ,CHAR_P_STRING_DEX|CHAR_P_STRING_MAXHP|CHAR_P_STRING_ATK|CHAR_P_STRING_QUICK); + sprintf( token, "敏捷设置为%d!",(int)atoi(dex)/100); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + } +} +void CHAR_CHAT_DEBUG_vital( int charindex , char *message ) +{ + int i; + char vital[15]; + char cdkey[CDKEYLEN]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , vital, sizeof(vital)); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + CHAR_setInt( i , CHAR_VITAL,atoi( vital ) ); + CHAR_complianceParameter( i ); + //CHAR_sendStatusString( charindex , "P"); + CHAR_send_P_StatusString( i ,CHAR_P_STRING_VITAL|CHAR_P_STRING_MAXHP|CHAR_P_STRING_DEF); + sprintf( token, "[GM]%s把你的体力设置为%d!", CHAR_getChar( charindex, CHAR_NAME),(int)atoi(vital)/100); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "玩家%s的体力设置为%d!", CHAR_getChar( i, CHAR_NAME),(int)atoi(vital)/100); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setInt( charindex , CHAR_VITAL,atoi( vital ) ); + CHAR_complianceParameter( charindex ); + //CHAR_sendStatusString( charindex , "P"); + CHAR_send_P_StatusString( charindex ,CHAR_P_STRING_VITAL|CHAR_P_STRING_MAXHP|CHAR_P_STRING_DEF); + sprintf( token, "体力设置为%d!",(int)atoi(vital)/100); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + } +} +void CHAR_CHAT_DEBUG_luck( int charindex , char *message ) +{ + int i; + char buf[64]; + int luck; + char cdkey[CDKEYLEN]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , buf, sizeof(buf)); + luck=atoi(buf); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(luck<1)luck=1; + if(luck>5)luck=5; + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + CHAR_setInt( i , CHAR_LUCK,luck); + CHAR_complianceParameter( i ); + //CHAR_sendStatusString( charindex , "P"); + CHAR_send_P_StatusString( i , CHAR_P_STRING_LUCK); + sprintf( token, "[GM]%s把你的运气设置为%d!", CHAR_getChar( charindex, CHAR_NAME),luck); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "玩家%s的运气设置为%d!", CHAR_getChar( i, CHAR_NAME),luck); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setInt( charindex , CHAR_LUCK,luck); + CHAR_complianceParameter( charindex ); + //CHAR_sendStatusString( charindex , "P"); + CHAR_send_P_StatusString( charindex , CHAR_P_STRING_LUCK); + sprintf( token, "运气设置为%d!",luck); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + } +} + +void CHAR_CHAT_DEBUG_gold( int charindex , char *message ) +{ + int i, MaxGold, money; + char cdkey[CDKEYLEN]; + char buf[64]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , buf, sizeof(buf)); + money = atoi( buf ); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + MaxGold = CHAR_getMaxHaveGold( charindex); + if( money > MaxGold ) + money = MaxGold; + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + CHAR_setInt( i , CHAR_GOLD , money ); + CHAR_complianceParameter( i ); + CHAR_send_P_StatusString( i , CHAR_P_STRING_GOLD); + sprintf( token, "[GM]%s把你的金钱设置为%d!", CHAR_getChar( charindex, CHAR_NAME),money); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "玩家%s的金钱设置为%d!", CHAR_getChar( i, CHAR_NAME),money); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setInt( charindex , CHAR_GOLD , money ); + CHAR_complianceParameter( charindex ); + CHAR_send_P_StatusString( charindex , CHAR_P_STRING_GOLD); + sprintf( token, "金钱设置为%d!",money); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + } +} + +#ifdef _TEST_DROPITEMS +void CHAR_CHAT_DEBUG_dropmypet( int charindex, char *message ) +{ + char buf[256]; + int petID, x, y, floor, objindex, petindex, count=0; + int i, j, k, petarray, cLeve=1; + + if( getStringFromIndexWithDelim( message, " ", 1, buf, sizeof( buf)) == FALSE ) return; + petID = atoi( buf); + if( getStringFromIndexWithDelim( message, " ", 2, buf, sizeof( buf)) != FALSE ){ + cLeve = atoi( buf); + } + + floor = CHAR_getInt( charindex, CHAR_FLOOR); + x = CHAR_getInt( charindex, CHAR_X); + y = CHAR_getInt( charindex, CHAR_Y); + if( getStringFromIndexWithDelim( message, " ", 3, buf, sizeof( buf)) != FALSE ){ + floor = atoi( buf); + } + if( getStringFromIndexWithDelim( message, " ", 4, buf, sizeof( buf)) != FALSE ){ + x = atoi( buf); + } + if( getStringFromIndexWithDelim( message, " ", 5, buf, sizeof( buf)) != FALSE ){ + y = atoi( buf); + } + for( i=(x-3); i<(x+3); i++) { + for( j=(y-3); j<(y+3); j++) { + petarray = ENEMY_getEnemyArrayFromId( petID); + petindex = ENEMY_TEST_createPetIndex( petarray ); + if( !CHAR_CHECKINDEX( petindex) ){ + CHAR_talkToCli( charindex, -1, "err Can't create pet", CHAR_COLORYELLOW); + return; + } + CHAR_complianceParameter( petindex ); + objindex = PET_dropPetAbsolute( petindex, floor, i, j, FALSE ); + if( objindex == -1 ){ + CHAR_talkToCli( charindex, -1, "err Can't Drop", CHAR_COLORYELLOW); + return; + } + for( k = 1; k < cLeve; k ++ ){ //升级 + CHAR_PetLevelUp( petindex ); + CHAR_PetAddVariableAi( petindex, AI_FIX_PETLEVELUP ); + CHAR_setInt( petindex, CHAR_LV, CHAR_getInt( petindex, CHAR_LV) +1 ); + } + CHAR_complianceParameter( petindex ); + CHAR_setInt( petindex , CHAR_HP , CHAR_getWorkInt( petindex , CHAR_WORKMAXHP ) ); + + CHAR_setWorkInt( petindex, CHAR_WORKOBJINDEX, objindex ); + CHAR_setInt( petindex, CHAR_FLOOR, floor); + CHAR_setInt( petindex, CHAR_X, i); + CHAR_setInt( petindex, CHAR_Y, j); + CHAR_sendCToArroundCharacter( objindex); + CHAR_setInt( petindex, CHAR_PUTPETTIME, NowTime.tv_sec); + CHAR_setChar( petindex, CHAR_OWNERCDKEY, "SYSTEM_WAYI" ); + CHAR_setChar( petindex, CHAR_OWNERCHARANAME, "SYSTEM_WAYI" ); + count++; + } + } + sprintf( buf, "总共丢掷 %d只宠物。", count); + CHAR_talkToCli( charindex, -1, buf, CHAR_COLORYELLOW); + + +} + +void CHAR_CHAT_DEBUG_dropmyitem( int charindex, char *message ) +{ + char buf[256]; + int itemID, SitemID, maxflg=0,emptyitemindexinchara, i, j; + int floor, x, y, objindex; + + if( getStringFromIndexWithDelim( message, " ", 1, buf, sizeof( buf)) == FALSE ) return; + SitemID = atoi( buf); + if( getStringFromIndexWithDelim( message, " ", 2, buf, sizeof( buf)) != FALSE ){ + maxflg = atoi( buf); + } + floor = CHAR_getInt( charindex, CHAR_FLOOR); + x = CHAR_getInt( charindex, CHAR_X); + y = CHAR_getInt( charindex, CHAR_Y); + if( getStringFromIndexWithDelim( message, " ", 3, buf, sizeof( buf)) != FALSE ){ + floor = atoi( buf); + } + if( getStringFromIndexWithDelim( message, " ", 4, buf, sizeof( buf)) != FALSE ){ + x = atoi( buf); + } + if( getStringFromIndexWithDelim( message, " ", 5, buf, sizeof( buf)) != FALSE ){ + y = atoi( buf); + } + itemID = SitemID; + + + for( i=(x-3); i<(x+3); i++) { + for( j=(y-3); j<(y+3); j++) { + int ret = 0 , count=0; + int itemindex; + while( count < 10 ){ + count++; + itemindex = ITEM_makeItemAndRegist( itemID ); + if( maxflg == 1 ) itemID++; + if( !ITEM_CHECKINDEX( itemindex)) continue; + break; + } + emptyitemindexinchara = CHAR_findEmptyItemBox( charindex ); + + CHAR_setItemIndex( charindex, emptyitemindexinchara, itemindex ); + ITEM_setWorkInt(itemindex, ITEM_WORKOBJINDEX,-1); + ITEM_setWorkInt(itemindex, ITEM_WORKCHARAINDEX,charindex); + CHAR_sendItemDataOne( charindex, emptyitemindexinchara); + //drop + if( (ret = CHAR_DropItemFXY( charindex, emptyitemindexinchara, + floor, i, j, &objindex )) != 0 ){ + char buf[256]; + sprintf( buf, "错误%d", ret); + CHAR_talkToCli( charindex, -1, buf, CHAR_COLORYELLOW); + } + ITEM_setInt(itemindex,ITEM_PUTTIME,NowTime.tv_sec); + CHAR_sendWatchEvent(objindex,CHAR_ACTSTAND,NULL,0,TRUE); + CHAR_setItemIndex(charindex, emptyitemindexinchara ,-1); + CHAR_sendItemDataOne(charindex, emptyitemindexinchara); + CHAR_sendCToArroundCharacter(CHAR_getWorkInt( charindex, CHAR_WORKOBJINDEX)); + } + } + { + char buf[256]; + sprintf( buf, "最後ID%d", itemID-1); + CHAR_talkToCli( charindex, -1, buf, CHAR_COLORYELLOW); + } +} +#endif + +void CHAR_CHAT_DEBUG_additem( int charindex , char *message ) +{ + + int emptyitemindexinchara, itemindex; + int i; + int num = 0; + int itemid; + char buf[64]; + char msgbuf[128]; + char cdkey[CDKEYLEN]; + easyGetTokenFromString( message , 1 , buf, sizeof(buf)); + itemid = atoi( buf); + easyGetTokenFromString( message , 2 , buf, sizeof(buf)); + num = atoi( buf); + easyGetTokenFromString( message , 3 , cdkey, sizeof(cdkey)); + + if( num <= 0 ) num = 1; + + if(strlen(cdkey)>0){ + int playernum = CHAR_getPlayerMaxNum(); + int j; + for(j=0;j=playernum) + { + CHAR_talkToCli( charindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + for( i = 0; i < num; i ++ ) { + emptyitemindexinchara = CHAR_findEmptyItemBox( j ); + + if( emptyitemindexinchara < 0 ){ + sprintf( msgbuf, "玩家%s物品栏位不足。", CHAR_getChar( j, CHAR_NAME )); + CHAR_talkToCli( charindex, -1, msgbuf, CHAR_COLORYELLOW); + sprintf( msgbuf, "你的%s物品栏位不足。", CHAR_getChar( j, CHAR_NAME )); + CHAR_talkToCli( j, -1, msgbuf, CHAR_COLORYELLOW); + return; + } + + itemindex = ITEM_makeItemAndRegist( itemid ); + + if( itemindex != -1 ){ + CHAR_setItemIndex( j, emptyitemindexinchara, itemindex ); + ITEM_setWorkInt(itemindex, ITEM_WORKOBJINDEX,-1); + ITEM_setWorkInt(itemindex, ITEM_WORKCHARAINDEX,charindex); + CHAR_sendItemDataOne( j, emptyitemindexinchara); + LogItem( + CHAR_getChar( charindex, CHAR_NAME ), + CHAR_getChar( charindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + atoi( message), +#endif + "AddItem(制作道具GM)", + CHAR_getInt( charindex,CHAR_FLOOR), + CHAR_getInt( charindex,CHAR_X ), + CHAR_getInt( charindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + + ); + snprintf( msgbuf, sizeof( msgbuf), "[GM]%s给你制作%s成功\。", + CHAR_getChar( charindex, CHAR_NAME ),ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( j, -1,msgbuf, CHAR_COLORYELLOW); + snprintf( msgbuf, sizeof( msgbuf), "成功为%s制作 %s\。", + CHAR_getChar( j, CHAR_NAME ),ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charindex, -1,msgbuf, CHAR_COLORYELLOW); + }else{ + sprintf( msgbuf, "制作道具失败。" ); + CHAR_talkToCli( charindex, -1,msgbuf, CHAR_COLORYELLOW); + } + } + }else{ + for( i = 0; i < num; i ++ ) { + emptyitemindexinchara = CHAR_findEmptyItemBox( charindex ); + + if( emptyitemindexinchara < 0 ){ + sprintf( msgbuf, "物品栏位不足。" ); + + CHAR_talkToCli( charindex, -1, msgbuf, CHAR_COLORYELLOW); + + return; + } + + itemindex = ITEM_makeItemAndRegist( itemid ); + + if( itemindex != -1 ){ + CHAR_setItemIndex( charindex, emptyitemindexinchara, itemindex ); + ITEM_setWorkInt(itemindex, ITEM_WORKOBJINDEX,-1); + ITEM_setWorkInt(itemindex, ITEM_WORKCHARAINDEX,charindex); + CHAR_sendItemDataOne( charindex, emptyitemindexinchara); + LogItem( + CHAR_getChar( charindex, CHAR_NAME ), + CHAR_getChar( charindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + atoi( message), +#endif + "AddItem(制作道具GM)", + CHAR_getInt( charindex,CHAR_FLOOR), + CHAR_getInt( charindex,CHAR_X ), + CHAR_getInt( charindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + + ); + snprintf( msgbuf, sizeof( msgbuf), "制作%s成功\。", + ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charindex, -1,msgbuf, CHAR_COLORYELLOW); + }else{ + sprintf( msgbuf, "制作道具失败。" ); + CHAR_talkToCli( charindex, -1, msgbuf, CHAR_COLORYELLOW); + } + } + } +} + + +void CHAR_CHAT_DEBUG_metamo( int charindex , char *message ) +{ + char metamoid[7]; + char cdkey[CDKEYLEN]; + char token[128]; + int i=0; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , metamoid, sizeof(metamoid)); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + CHAR_setInt( i , CHAR_BASEIMAGENUMBER , atoi( metamoid ) ); + CHAR_setInt( i , CHAR_BASEBASEIMAGENUMBER , atoi( metamoid ) ); + + CHAR_complianceParameter( i ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( i , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( i , CHAR_P_STRING_BASEBASEIMAGENUMBER); + sprintf( token, "[GM]%s把你的人物形象设置为%d!", CHAR_getChar( charindex, CHAR_NAME),(int)atoi(metamoid)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "玩家%s的人物形象设置为%d!", CHAR_getChar( i, CHAR_NAME),(int)atoi(metamoid)); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setInt( charindex , CHAR_BASEIMAGENUMBER , atoi( metamoid ) ); + CHAR_setInt( charindex , CHAR_BASEBASEIMAGENUMBER , atoi( metamoid ) ); + + CHAR_complianceParameter( charindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( charindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + sprintf( token, "人物形象设置为%d!",(int)atoi(metamoid)); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + } +} + +void CHAR_CHAT_DEBUG_info( int charindex , char *message ) +{ + char line[256]; + int index; + + if( strlen( message) != 0 ) { + index = atoi( message); + } + else { + index = charindex; + } + if( !CHAR_CHECKINDEX( index)) { + CHAR_talkToCli( charindex, -1 , "该index无法使用。" , CHAR_COLORWHITE ); + return; + } + + snprintf( line, sizeof( line), + "name:%s i:%d B:%d BB:%d LV:%d EXP:%d MakeSeq:%d", + CHAR_getChar( index, CHAR_NAME), + charindex, + CHAR_getInt( index, CHAR_BASEIMAGENUMBER ), + CHAR_getInt( index, CHAR_BASEBASEIMAGENUMBER ), + CHAR_getInt( index, CHAR_LV ), + CHAR_getInt( index, CHAR_EXP ), + CHAR_getCharMakeSequenceNumber( index)); + + CHAR_talkToCli( charindex, -1 , line , CHAR_COLORWHITE ); + + snprintf( line, sizeof( line), + "Gold:%d HP:%d MP/MHP:%d/%d" , + CHAR_getInt( index, CHAR_GOLD ), + CHAR_getInt( index, CHAR_HP ), + CHAR_getInt( index, CHAR_MP ), + CHAR_getInt( index, CHAR_MAXMP )); + CHAR_talkToCli( charindex, -1 , line , CHAR_COLORWHITE ); + + + if( CHAR_getInt( index, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + snprintf( line, sizeof(line), + "体:%d 力:%d 丈:%d 早:%d 耐:%d 攻:%d 守:%d 敏:%d 忠修:%d 忠变:%.2f 编码:%s", + CHAR_getInt( index, CHAR_VITAL )/100, + CHAR_getInt( index, CHAR_STR )/100, + CHAR_getInt( index, CHAR_TOUGH )/100, + CHAR_getInt( index, CHAR_DEX )/100, + CHAR_getWorkInt( index, CHAR_WORKFIXVITAL ), + CHAR_getWorkInt( index, CHAR_WORKATTACKPOWER ), + CHAR_getWorkInt( index, CHAR_WORKDEFENCEPOWER ),//CHAR_WORKFIXDEX + CHAR_getWorkInt( index, CHAR_WORKQUICK ), + CHAR_getInt( index, CHAR_MODAI ), + CHAR_getInt( index, CHAR_VARIABLEAI ) * 0.01, + CHAR_getChar( index, CHAR_UNIQUECODE) ); + }else{ + snprintf( line, sizeof(line), + "体:%d 力:%d 丈:%d 早:%d 耐:%d 攻:%d 守:%d 魅:%d 运:%d", + CHAR_getInt( index, CHAR_VITAL )/100, + CHAR_getInt( index, CHAR_STR )/100, + CHAR_getInt( index, CHAR_TOUGH )/100, + CHAR_getInt( index, CHAR_DEX )/100, + CHAR_getWorkInt( index, CHAR_WORKFIXVITAL ), + CHAR_getWorkInt( index, CHAR_WORKATTACKPOWER ), + CHAR_getWorkInt( index, CHAR_WORKDEFENCEPOWER ), + CHAR_getWorkInt( index, CHAR_WORKFIXCHARM ), + CHAR_getWorkInt( index, CHAR_WORKFIXLUCK )); + } + CHAR_talkToCli( charindex, -1 , line , CHAR_COLORWHITE ); + + + snprintf( line, sizeof(line), + "土:%d 水:%d 火:%d 风:%d", + CHAR_getWorkInt( index, CHAR_WORKFIXEARTHAT ), + CHAR_getWorkInt( index, CHAR_WORKFIXWATERAT ), + CHAR_getWorkInt( index, CHAR_WORKFIXFIREAT ), + CHAR_getWorkInt( index, CHAR_WORKFIXWINDAT )); + CHAR_talkToCli( charindex, -1 , line , CHAR_COLORWHITE ); + + snprintf( line, sizeof( line), + "Sk Itm:%d ChV:%d Rad:%d" , + CHAR_MAXITEMHAVE, + CHAR_getInt( index, CHAR_CHATVOLUME ), + CHAR_getInt( index, CHAR_RADARSTRENGTH ) ); + CHAR_talkToCli( charindex, -1 , line , CHAR_COLORWHITE ); + + + snprintf( line, sizeof( line), + "Status 毒:%d 麻:%d 默:%d 石:%d 暗:%d 乱:%d" , + CHAR_getInt( index , CHAR_POISON ), + CHAR_getInt( index , CHAR_PARALYSIS ), + CHAR_getInt( index , CHAR_SLEEP ), + CHAR_getInt( index , CHAR_STONE ), + CHAR_getInt( index , CHAR_DRUNK ), + CHAR_getInt( index , CHAR_CONFUSION ) ); + CHAR_talkToCli( charindex, -1 , line , CHAR_COLORWHITE ); + +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + snprintf( line, sizeof( line), +#ifdef _NEW_MANOR_LAW + "TitInd:%d FL:%d X:%d Y:%d DIR:%d FAME:%d MOMENTUM:%d" , +#else + "TitInd:%d FL:%d X:%d Y:%d DIR:%d FAME:%d" , +#endif + CHAR_getInt( index , CHAR_INDEXOFEQTITLE ), + CHAR_getInt( index , CHAR_FLOOR ), + CHAR_getInt( index , CHAR_X ), + CHAR_getInt( index , CHAR_Y ), + CHAR_getInt( index , CHAR_DIR ), + CHAR_getInt( index , CHAR_FAME) +#ifdef _NEW_MANOR_LAW + ,CHAR_getInt( index , CHAR_MOMENTUM) +#endif + ); +#else + snprintf( line, sizeof( line), + "TitInd:%d FL:%d X:%d Y:%d DIR:%d" , + CHAR_getInt( index , CHAR_INDEXOFEQTITLE ), + CHAR_getInt( index , CHAR_FLOOR ), + CHAR_getInt( index , CHAR_X ), + CHAR_getInt( index , CHAR_Y ), + CHAR_getInt( index , CHAR_DIR ) ); +#endif + CHAR_talkToCli( charindex, -1 , line , CHAR_COLORWHITE ); + + + snprintf( line, sizeof( line), + "walk:%d dead:%d ItemMergecnt:%d" , + CHAR_getInt( index , CHAR_WALKCOUNT ) , + CHAR_getInt( index , CHAR_DEADCOUNT ) , + CHAR_getInt( index, CHAR_MERGEITEMCOUNT) + ); + CHAR_talkToCli( charindex, -1 , line , CHAR_COLORWHITE ); + + if( CHAR_getInt( index, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + snprintf( line, sizeof( line), + "petindex [%d][%d][%d][%d][%d] " , + CHAR_getCharPet( index, 0), + CHAR_getCharPet( index, 1), + CHAR_getCharPet( index, 2), + CHAR_getCharPet( index, 3), + CHAR_getCharPet( index, 4)); + } + else { + snprintf( line, sizeof( line), + "PetskillIndex [%d][%d][%d][%d][%d][%d][%d] " , + CHAR_getPetSkill( index, 0), + CHAR_getPetSkill( index, 1), + CHAR_getPetSkill( index, 2), + CHAR_getPetSkill( index, 3), + CHAR_getPetSkill( index, 4), + CHAR_getPetSkill( index, 5), + CHAR_getPetSkill( index, 6)); + } + + CHAR_talkToCli( charindex, -1 , line , CHAR_COLORWHITE ); + if( CHAR_getInt( index, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + snprintf( line, sizeof( line), + "poolpetindex [%d][%d][%d][%d][%d] " , + CHAR_getCharPoolPet( index, 0), + CHAR_getCharPoolPet( index, 1), + CHAR_getCharPoolPet( index, 2), + CHAR_getCharPoolPet( index, 3), + CHAR_getCharPoolPet( index, 4)); + CHAR_talkToCli( charindex, -1 , line , CHAR_COLORWHITE ); + + snprintf( line, sizeof( line), + "poolpetindex [%d][%d][%d][%d][%d] " , + CHAR_getCharPoolPet( index, 5), + CHAR_getCharPoolPet( index, 6), + CHAR_getCharPoolPet( index, 7), + CHAR_getCharPoolPet( index, 8), + CHAR_getCharPoolPet( index, 9)); + CHAR_talkToCli( charindex, -1 , line , CHAR_COLORWHITE ); + } + + snprintf( line, sizeof( line), + "levelup [%d], 累积 %d 赌场积分[%d]" , + CHAR_getInt( index, CHAR_LEVELUPPOINT), + CHAR_getWorkInt( index, CHAR_WORKULTIMATE), + CHAR_getInt( index, CHAR_GAMBLENUM) ); + CHAR_talkToCli( charindex, -1 , line , CHAR_COLORWHITE ); + +} + +void CHAR_CHAT_DEBUG_sysinfo( int charindex , char *message ) +{ + char msg[1024],name[256]; + int i; + time_t new_t; + int dd,hh,mm,ss; + + int items=0 , chars=0, golds=0, nouses=0; + int players=0,pets=0,others=0; + int whichtype= -1; + int objnum = OBJECT_getNum(); + + + int itemnum = ITEM_getITEM_itemnum(); + int itemuse =0; + + makeEscapeString( getGameserverID(), name, sizeof( name)); + sprintf( msg, "GSID:%s GSNAME:%s", getGameserverID(), name); + CHAR_talkToCli( charindex, -1, msg, CHAR_COLORYELLOW); + + + for( i=0 ; i0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charaindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + CHAR_setInt(i,CHAR_LV, atoi( message )); + CHAR_send_P_StatusString( i , CHAR_P_STRING_LV); + sprintf( token, "[GM]%s把你的等级设置为%d!", CHAR_getChar( charaindex, CHAR_NAME),level); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "玩家%s的等级设置为%d!", CHAR_getChar( i, CHAR_NAME),level); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setInt(charaindex,CHAR_LV, atoi( message )); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_LV); + sprintf( token, "等级设置为%d!",level); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + } +} + + +void CHAR_CHAT_DEBUG_exp( int charaindex, char* message ) +{ + int i; + char exp[15]; + char cdkey[CDKEYLEN]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , exp, sizeof(exp)); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charaindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + CHAR_setMaxExp( i, atoi( exp )); + CHAR_send_P_StatusString( i , CHAR_P_STRING_EXP); + sprintf( token, "[GM]%s把你的经验设置为%d!", CHAR_getChar( charaindex, CHAR_NAME),(int)atoi(exp)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "玩家%s的经验设置为%d!", CHAR_getChar( i, CHAR_NAME),(int)atoi(exp)); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setMaxExp( charaindex, atoi( exp )); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_EXP); + sprintf( token, "经验设置为%d!",(int)atoi(exp)/100); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + } +} + +void CHAR_CHAT_DEBUG_delitem( int charindex , char *message ) +{ + int itemid; + + if( strcmp( message, "all") == 0 ) { + int i; + for( i = CHAR_STARTITEMARRAY; i < CHAR_MAXITEMHAVE; i ++ ) { + itemid = CHAR_getItemIndex(charindex, i); + if( itemid != -1 ) { + { + LogItem( + CHAR_getChar( charindex, CHAR_NAME ), + CHAR_getChar( charindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemid, +#else + ITEM_getInt( itemid, ITEM_ID ), +#endif + "DelItem(删除道具GM)", + CHAR_getInt( charindex,CHAR_FLOOR), + CHAR_getInt( charindex,CHAR_X ), + CHAR_getInt( charindex,CHAR_Y ), + ITEM_getChar( itemid, ITEM_UNIQUECODE), + ITEM_getChar( itemid, ITEM_NAME), + ITEM_getInt( itemid, ITEM_ID) + ); + } + CHAR_DelItem( charindex, i); + } + } + }else { + int equipplace; + equipplace = atoi( message); + if( equipplace < CHAR_STARTITEMARRAY || equipplace > CHAR_MAXITEMHAVE -1 ) { + CHAR_talkToCli( charindex, -1, "号码不正确。", CHAR_COLORWHITE); + return; + } + itemid = CHAR_getItemIndex(charindex, equipplace); + if( itemid == -1 ) return; + { + LogItem( + CHAR_getChar( charindex, CHAR_NAME ), + CHAR_getChar( charindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemid, +#else + ITEM_getInt( itemid, ITEM_ID ), +#endif + "DelItem(删除道具GM)", + CHAR_getInt( charindex,CHAR_FLOOR), + CHAR_getInt( charindex,CHAR_X ), + CHAR_getInt( charindex,CHAR_Y ), + ITEM_getChar( itemid, ITEM_UNIQUECODE), + ITEM_getChar( itemid, ITEM_NAME), + ITEM_getInt( itemid, ITEM_ID) + ); + } + CHAR_DelItem( charindex, equipplace); + } +} + +#ifdef _CHAR_PROFESSION // WON ADD 人物职业 +void CHAR_CHAT_DEBUG_addsk( int charaindex, char* message ) +{ + + CHAR_HaveSkill *pSkil; + int skill, i, level=1; + + char msg1[20], msg2[20]; + + getStringFromIndexWithDelim( message, " ", 1, msg1, sizeof( msg1)); + getStringFromIndexWithDelim( message, " ", 2, msg2, sizeof( msg2)); + + skill = atoi(msg1); + level = atoi(msg2); + + if( level > 100 ){ + CHAR_talkToCli( charaindex, -1, "等级不正确", CHAR_COLORWHITE); + return; + } + if( level < 1 ) level = 1; + + for( i = 0; i < CHAR_SKILLMAXHAVE; i ++ ){ + int skill_id = -1; + + pSkil = CHAR_getCharHaveSkill( charaindex, i ); + skill_id = SKILL_getInt( &pSkil->skill, SKILL_IDENTITY); + if( skill == skill_id && skill_id != -1 ){ + CHAR_talkToCli(charaindex,-1, "你已经学习过此技能", CHAR_COLORYELLOW); + return; + } + + if( pSkil == NULL ) continue; + if( pSkil->use != 0 ) continue; + + break; + } + + if( i >= CHAR_SKILLMAXHAVE ){ + CHAR_talkToCli(charaindex,-1, "技能数量已达上限", CHAR_COLORYELLOW); + return; + }else{ + level *= 100; + SKILL_makeSkillData( &pSkil->skill, skill, level); + pSkil->use = TRUE; + } + + CHAR_sendStatusString( charaindex , "S"); + + return; +} + +void CHAR_CHAT_DEBUG_delsk( int charaindex, char* message ) +{ + int i; + CHAR_HaveSkill *pSkil; + + if( strcmp( message, "all" ) == 0 ){ +// CHAR_talkToCli( charaindex, -1, "清除所有技能", CHAR_COLORWHITE); + for( i = CHAR_SKILLMAXHAVE-1; i >= 0; i -- ){ + pSkil = CHAR_getCharHaveSkill( charaindex, i ); + if( pSkil == NULL )continue; + if( pSkil->use == 0 )continue; + SKILL_makeSkillData( &pSkil->skill, 0, 0 ); + pSkil->use = 0; + } + } + + for( i = CHAR_SKILLMAXHAVE-1; i >= 0; i -- ){ + pSkil = CHAR_getCharHaveSkill( charaindex, i ); + if( pSkil == NULL )continue; + if( pSkil->use == 0 )continue; + print( "SKILUSE %d\n", pSkil->use ); + break; + } + + if( i < 0 ){ +// CHAR_talkToCli( charaindex, -1, "已无法再削减了。", CHAR_COLORWHITE); + ;; + }else{ + SKILL_makeSkillData( &pSkil->skill, 0, 0 ); + pSkil->use = 0; + } + + CHAR_sendStatusString( charaindex , "S"); +} +#endif + +void CHAR_CHAT_Kusabana( int charaindex, char* message ){ + + int dir, ff, fx, fy; + int tile, obj; + + ff = CHAR_getInt( charaindex, CHAR_FLOOR ); + fx = CHAR_getInt( charaindex, CHAR_X ); + fy = CHAR_getInt( charaindex, CHAR_Y ); + dir = CHAR_getInt( charaindex, CHAR_DIR ); + + fx += CHAR_getDX(dir); + fy += CHAR_getDY(dir); + + if( MAP_getTileAndObjData( ff, fx, fy, &tile, &obj) == FALSE )return; + +#if 0 + { char szBuffer[256]; + snprintf( szBuffer, sizeof( szBuffer ), "TILE = %d, OBJ = %d", + tile, obj ); + CHAR_talkToCli( charaindex, -1, szBuffer, CHAR_COLORWHITE); + } +#else + + if( obj != 0 ){ + CHAR_talkToCli( charaindex, -1, "有零件。", CHAR_COLORWHITE); + return; + } + + if( MAP_walkAbleFromPoint( ff, fx, fy, FALSE ) == FALSE ){ + CHAR_talkToCli( charaindex, -1, "无法走了。", CHAR_COLORWHITE); + return; + } + + MAP_setObjData( ff, fx, fy, 3416, 100 ); + + +#if 1 + { + char *stringdata; + RECT seekr , retr; + seekr.x = fx; + seekr.y = fy; + seekr.width = 1; + seekr.height = 1; + stringdata = MAP_getdataFromRECT(ff,&seekr,&retr); + if( stringdata ){ + + if( CHAR_getInt( charaindex , CHAR_WHICHTYPE ) + == CHAR_TYPEPLAYER ){ + int fd = getfdFromCharaIndex( charaindex ); + lssproto_M_send(fd,ff, + retr.x,retr.y, + retr.x+retr.width,retr.y+retr.height, + stringdata ); + } + } else { + } + } +#endif +#endif + + return ; +} + + +void CHAR_CHAT_Fukuwa( int charaindex, char* message ){ + int dir, ff, fx, fy, objindex, vs_index, vs_fd, stringlen; + OBJECT obj; + char szBuffer[2048]; + + stringlen = strlen( message ); + + if( message[0] == '[' && message[stringlen-1] == ']' ){ + CHAR_talkToCli( charaindex, -1, "语言没有转换。", CHAR_COLORWHITE); + return ; + } + + ff = CHAR_getInt( charaindex, CHAR_FLOOR ); + fx = CHAR_getInt( charaindex, CHAR_X ); + fy = CHAR_getInt( charaindex, CHAR_Y ); + dir = CHAR_getInt( charaindex, CHAR_DIR ); + + fx += CHAR_getDX(dir); + fy += CHAR_getDY(dir); + + stringlen = strlen( message ); + + + snprintf( szBuffer, sizeof( szBuffer ), "P|%s", message ); + + for( obj=MAP_getTopObj( ff, fx, fy ); obj; obj=NEXT_OBJECT(obj) ){ + objindex = GET_OBJINDEX(obj); + if( OBJECT_getType(objindex) != OBJTYPE_CHARA )continue; + vs_index = OBJECT_getIndex(objindex); + vs_fd = getfdFromCharaIndex( vs_index ); + CHAR_Talk( vs_fd, vs_index, + szBuffer, CHAR_COLORWHITE, 3 ); + break; + } + +} + +void CHAR_CHAT_DEBUG_superman( int charaindex, char* message ) +{ +#define CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF 100000 + int i; + char hp[15]; + char cdkey[CDKEYLEN]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , hp, sizeof(hp)); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charaindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + CHAR_setInt(charaindex,CHAR_SKILLUPPOINT, 32); + CHAR_Skillupsend(charaindex); + CHAR_setInt( charaindex , CHAR_HP, CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF); + CHAR_setInt( charaindex , CHAR_MP,CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF ); + CHAR_setInt( charaindex , CHAR_MAXMP,CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF ); + CHAR_setInt( charaindex , CHAR_STR,CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF ); + CHAR_setInt( charaindex , CHAR_TOUGH,CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF ); + CHAR_setInt( charaindex , CHAR_DEX , CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF ); + CHAR_setInt( charaindex,CHAR_LV, getMaxLevel()); + + CHAR_complianceParameter( charaindex ); + CHAR_sendStatusString( charaindex , "P"); + + sprintf( token, "[GM]%s把你为超人状态!", CHAR_getChar( charaindex, CHAR_NAME)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "玩家%s设置为超人状态!", CHAR_getChar( i, CHAR_NAME)); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setInt(charaindex,CHAR_SKILLUPPOINT, 32); + CHAR_Skillupsend(charaindex); + CHAR_setInt( charaindex , CHAR_HP, CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF); + CHAR_setInt( charaindex , CHAR_MP,CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF ); + CHAR_setInt( charaindex , CHAR_MAXMP,CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF ); + CHAR_setInt( charaindex , CHAR_STR,CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF ); + CHAR_setInt( charaindex , CHAR_TOUGH,CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF ); + CHAR_setInt( charaindex , CHAR_DEX , CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF ); + CHAR_setInt( charaindex,CHAR_LV, getMaxLevel()); + + CHAR_complianceParameter( charaindex ); + CHAR_sendStatusString( charaindex , "P"); + + CHAR_talkToCli( charaindex, -1,"设置超人状态!", CHAR_COLORYELLOW ); + } +#undef CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF + +} + +void CHAR_CHAT_printcount( int charaindex, char* message ) +{ + char msgbuf[512]; + + snprintf( msgbuf,sizeof( msgbuf), + "你说了 %d 次话,走了 %d 步路,死了 %d 次", + CHAR_getInt( charaindex, CHAR_TALKCOUNT), + CHAR_getInt( charaindex, CHAR_WALKCOUNT), + CHAR_getInt( charaindex, CHAR_DEADCOUNT) + ); + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORWHITE); + +} + +void CHAR_CHAT_DEBUG_battlein( int charaindex, char* message ) +{ + int fd = getfdFromCharaIndex( charaindex ); + if( fd != -1) { + lssproto_EN_recv( fd, + CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y)); + } +} + +void CHAR_CHAT_DEBUG_battleout( int charaindex, char* message ) +{ + + BATTLE_WatchStop( charaindex ); +} + +void CHAR_CHAT_DEBUG_petmake( int charaindex, char* message ) +{ + int ret; + int enemynum; + int enemyid; + int i,j; + int level=-1; + char buf[10]; + char cdkey[CDKEYLEN]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , buf, sizeof(buf)); + enemyid=atoi(buf); + easyGetTokenFromString( message , 2 , buf, sizeof(buf)); + level=atoi(buf); + easyGetTokenFromString( message , 3 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(j=0;j=playernum) + { + CHAR_talkToCli( charaindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == enemyid) { + break; + } + } + if( i == enemynum )return; + + ret = ENEMY_createPetFromEnemyIndex( j, i); + if( !CHAR_CHECKINDEX( ret))return; + snprintf( token,sizeof( token), "宠物制作成功\!",ret); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORWHITE); + sprintf( token, "[GM]%s制作了只宠物给你!index[%d]", CHAR_getChar( charaindex, CHAR_NAME),ret); + CHAR_talkToCli( j, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "给玩家%s的宠物制作成功!index[%d]", CHAR_getChar( j, CHAR_NAME),ret); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + if( CHAR_getCharPet( j, i ) == ret )break; + } + if( i == CHAR_MAXPETHAVE )i = 0; + + if( CHAR_CHECKINDEX( ret ) == TRUE ){ + CHAR_setMaxExpFromLevel( ret, CHAR_getInt( ret, CHAR_LV )); + } + if( level != -1 ){ + if( level > getMaxLevel() ) level = getMaxLevel(); + if( level < 0 ) level = 0; + level = level - CHAR_getInt( ret, CHAR_LV ); + if( level > 0 ){ + int k; + for( k = 1; k <= level; k ++ ){ //升级 + CHAR_PetLevelUp( ret ); + CHAR_PetAddVariableAi( ret, AI_FIX_PETLEVELUP ); + CHAR_setInt( ret, CHAR_LV, CHAR_getInt( ret, CHAR_LV) +1 ); + } + } + } + + snprintf( token, sizeof( token ), "K%d", i ); + CHAR_sendStatusString( j, token ); + snprintf( token, sizeof( token ), "W%d", i ); + CHAR_sendStatusString( j, token ); + }else{ + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == enemyid) { + break; + } + } + if( i == enemynum )return; + + ret = ENEMY_createPetFromEnemyIndex(charaindex, i); + if( !CHAR_CHECKINDEX( ret))return; + snprintf( token,sizeof( token), "宠物制作成功\!index[%d]",ret); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORWHITE); + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + if( CHAR_getCharPet( charaindex, i ) == ret )break; + } + if( i == CHAR_MAXPETHAVE )i = 0; + + if( CHAR_CHECKINDEX( ret ) == TRUE ){ + CHAR_setMaxExpFromLevel( ret, CHAR_getInt( ret, CHAR_LV )); + } + if( level != -1 ){ + if( level > 200 ) level = 200; + if( level < 0 ) level = 0; + level = level - CHAR_getInt( ret, CHAR_LV ); + if( level > 0 ){ + int k; + for( k = 1; k <= level; k ++ ){ //升级 + CHAR_PetLevelUp( ret ); + CHAR_PetAddVariableAi( ret, AI_FIX_PETLEVELUP ); + CHAR_setInt( ret, CHAR_LV, CHAR_getInt( ret, CHAR_LV) +1 ); + } + } } + + + snprintf( token, sizeof( token ), "K%d", i ); + CHAR_sendStatusString( charaindex, token ); + snprintf( token, sizeof( token ), "W%d", i ); + CHAR_sendStatusString( charaindex, token ); + } +} + +void CHAR_CHAT_DEBUG_deletepet( int charaindex, char* message ) +{ + int i, pindex; + char category[12]; + int playernum = CHAR_getPlayerMaxNum(); + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + pindex = CHAR_getCharPet( charaindex, i); + if( CHAR_CHECKINDEX( pindex)) { + CHAR_endCharOneArray( pindex ); + CHAR_setCharPet( charaindex, i, -1); + snprintf( category, sizeof( category), "K%d",i); + CHAR_sendStatusString( charaindex, category ); + snprintf( category, sizeof( category), "W%d",i); + CHAR_sendStatusString( charaindex, category ); + } + } + + CHAR_talkToCli( charaindex, -1, "清除身上所有宠物。", CHAR_COLORWHITE); + +} + +#define MAXMESS_LISTNUM 8 +#define ALLRESET (MAXMESS_LISTNUM - 1) + +void CHAR_CHAT_DEBUG_reset( int charaindex, char* message ) +{ + int i; +// int objindex; +// int objmaxnum = OBJECT_getNum(); + char mess[MAXMESS_LISTNUM][256]={ "enemy", "encount", "magic", "warppoint", "petskill", "pettalk", "npc", "all"}; + + for( i=0; i= MAXMESS_LISTNUM ){ + CHAR_talkToCli( charaindex, -1, "指令错误", CHAR_COLORRED);//CHAR_COLORYELLOW + return; + } + switch( i){ + case ALLRESET: + case 0: + if( !ENEMYTEMP_reinitEnemy() || !ENEMY_reinitEnemy() ){ + CHAR_talkToCli( charaindex, -1, "重新读取敌人基本资料失败。", CHAR_COLORRED); + return; + } + if( i != ALLRESET ) break; + case 1: + if( !GROUP_reinitGroup() || !ENCOUNT_reinitEncount() ){ + CHAR_talkToCli( charaindex, -1, "重新读取遭遇团队资料失败。", CHAR_COLORRED); + } + if( i != ALLRESET ) break; + case 2: + if( !MAGIC_reinitMagic() || !ATTMAGIC_reinitMagic() ) { + CHAR_talkToCli( charaindex, -1, "重新读取咒术资料失败。", CHAR_COLORRED); + } + if( i != ALLRESET ) break; + case 3: + MAPPOINT_resetMapWarpPoint( 1); + if( !MAPPOINT_loadMapWarpPoint() ){ + CHAR_talkToCli( charaindex, -1, "重新读取跳跃点资料失败。", CHAR_COLORRED); + } + if( i != ALLRESET ) break; + case 4: + if( !PETSKILL_reinitPetskill() ) { + CHAR_talkToCli( charaindex, -1, "重新读取宠物技能资料失败。", CHAR_COLORRED); + } + if( i != ALLRESET ) break; + case 5: + LoadPetTalk(); + if( i != ALLRESET ) break; + break; + case 6: + /*for( objindex=0; objindex=event_num ){ + sprintf( token, "错误!!你所设的任务旗标编号已超过 围(0~%d)。",32*event_num-1); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORWHITE); + return; + } + point = CHAR_getInt( charaindex_tmp, CHAR_ENDEVENT+array); + point = point & ~(1<=event_num ){ + sprintf( token, "错误!!你所设的任务旗标编号已超过 围(0~%d)。",32*event_num-1); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORWHITE); + return; + } + point = CHAR_getInt( charaindex_tmp, CHAR_NOWEVENT+array); + point = point | (1<=event_num ){ + sprintf( token, "错误!!你所设的任务旗标编号已超过 围(0~%d)。",32*event_num-1); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORWHITE); + return; + } + point = CHAR_getInt( charaindex_tmp, CHAR_ENDEVENT+array); + point = point | (1<0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + CHAR_setInt( i , CHAR_DUELPOINT, atoi( dp ) ); + CHAR_send_P_StatusString( i ,CHAR_P_STRING_DUELPOINT ); + sprintf( token, "[GM]%s把你的DP设置为%d!", CHAR_getChar( charindex, CHAR_NAME),(int)atoi(dp)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "玩家%s的DP设置为%d!", CHAR_getChar( i, CHAR_NAME),(int)atoi(dp)); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setInt( charindex , CHAR_DUELPOINT, atoi( dp ) ); + CHAR_send_P_StatusString( charindex ,CHAR_P_STRING_DUELPOINT ); + sprintf( token, "DP设置为%d!",(int)atoi(dp)); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + } +} + +#ifdef _EQUIT_ARRANGE +void CHAR_CHAT_DEBUG_arrange( int charindex , char *message ) +{ + CHAR_setWorkInt( charindex, CHAR_WORKFIXARRANGE, atoi( message) ); + CHAR_complianceParameter( charindex ); + CHAR_talkToCli( charindex, -1, "设定挡格", CHAR_COLORYELLOW); +} +#endif + + +#ifdef _EQUIT_SEQUENCE +void CHAR_CHAT_DEBUG_sequence( int charindex , char *message ) +{ + CHAR_setWorkInt( charindex, CHAR_WORKFIXSEQUENCE, atoi( message) ); + CHAR_complianceParameter( charindex ); + CHAR_talkToCli( charindex, -1, "设定顺序", CHAR_COLORYELLOW); +} +#endif + +#define ITEMRESERVESTRING "item" +#define POOLITEMRESERVESTRING "poolitem" + +void CHAR_CHAT_DEBUG_setmerge_main( int charaindex, char* message, int mode ) +{ + int haveitemindex = atoi( message); + int itemindex; + + if( !CHAR_CHECKITEMINDEX( charaindex, haveitemindex) ){ + CHAR_talkToCli( charaindex, -1, "号码很奇怪。", CHAR_COLORWHITE); + return; + } + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX( itemindex)) { + CHAR_talkToCli( charaindex, -1, "该处是否没有任何道具,情报亦很奇怪。", CHAR_COLORWHITE); + return; + } + ITEM_setInt( itemindex, ITEM_MERGEFLG, mode); + + CHAR_talkToCli( charaindex, -1, "宁岳白仿弘及丑综毛仄引仄凶[", CHAR_COLORWHITE); + + CHAR_sendItemDataOne( charaindex, haveitemindex); +} + +void CHAR_CHAT_DEBUG_effect( int charaindex, char* message ) +{ + int floorid=-1, effectid=-1, level=0; + char buf[ 256]; + int i; + int playernum = CHAR_getPlayerMaxNum(); + BOOL flg = FALSE; + + getStringFromIndexWithDelim( message, " ", 1, buf, sizeof( buf)); + if( strcmp( buf, "alloff" ) == 0 ) { + flg = TRUE; + }else { + floorid = atoi( buf); + if( !getStringFromIndexWithDelim( message, " ", 2, buf, sizeof( buf))) { + return; + } + effectid = atoi( buf); + if( !getStringFromIndexWithDelim( message, " ", 3, buf, sizeof( buf))) { + return; + } + level = atoi( buf); + } + for( i = 0 ; i < playernum; i ++) { + if( CHAR_CHECKINDEX( i)) { + if( CHAR_getInt( i, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER){ + if( flg) { + int ef = CHAR_getWorkInt( i, CHAR_WORKEFFECT); + if( ef != 0 ) { + int fd = getfdFromCharaIndex( i); + lssproto_EF_send( fd, 0, 0, ""); + CHAR_setWorkInt( i, CHAR_WORKEFFECT, 0); + } + } + else if( CHAR_getInt( i, CHAR_FLOOR) == floorid ) { + int fd = getfdFromCharaIndex( i); + lssproto_EF_send( fd, effectid, level, ""); + if( level == 0 ) { + CHAR_setWorkInt( i, CHAR_WORKEFFECT, + CHAR_getWorkInt( i, CHAR_WORKEFFECT) & + ~effectid); + } + else { + CHAR_setWorkInt( i, CHAR_WORKEFFECT, + CHAR_getWorkInt( i, CHAR_WORKEFFECT) | + effectid); + } + } + } + } + } +} + +void CHAR_CHAT_DEBUG_setTrans( int charaindex, char *message) +{ + int i; + char setTrans[15]; + char cdkey[CDKEYLEN]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , setTrans, sizeof(setTrans)); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charaindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + CHAR_setInt(i, CHAR_TRANSEQUATION, 0); + CHAR_setInt(i, CHAR_TRANSMIGRATION, atoi( setTrans )); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( i, CHAR_WORKOBJINDEX )); + sprintf( token, "[GM]%s把你转生设置为%d转!", CHAR_getChar( charaindex, CHAR_NAME),(int)atoi(setTrans)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "玩家%s转生设置为%d转!", CHAR_getChar( i, CHAR_NAME),(int)atoi(setTrans)); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setInt(charaindex, CHAR_TRANSEQUATION, 0); + CHAR_setInt(charaindex, CHAR_TRANSMIGRATION, atoi( setTrans )); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX )); + sprintf( token, "转生设置为%d转!",(int)atoi(setTrans)); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + } +} + +void CHAR_CHAT_DEBUG_shutup(int charindex ,char *message) +{ + char token[100]; + char token1[100]; + char cdkey[CDKEYLEN]; + char buf[256]; + char line[256]; + unsigned int MAX_USER=0,i; + BOOL flg; + easyGetTokenFromString( message , 1 , token, sizeof(token)); + easyGetTokenFromString( message , 2 , token1, sizeof(token1)); + if( strlen(message)==0){ + sprintf(buf,"%s","参数不正确"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORYELLOW); + return; + } + if( strlen(token1)==0){ + sprintf(buf,"%s","参数不正确--> ON OFF"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORYELLOW); + return; + } + flg = isstring1or0( token1); + MAX_USER=getFdnum(); + for(i=0;i= 10 )MOREs = TRUE; + } + } + + memset( token, 0, sizeof(token)); + strcpy( token, "MORE:"); + for( i=0; i= sizeof(token) ){ + CHAR_talkToCli( charindex, -1 , token , CHAR_COLORWHITE); + memset( token, 0, sizeof(token)); + strcpy( token, "MORE:"); + } + strcat( token, temp); + continue; + } + } + sprintf( buf1, "NAME:%s UName:%s CDKey:%s Point:[%d,%d,%d]", + CHAR_getChar( userindex, CHAR_NAME), CHAR_getUseName( userindex), + CHAR_getChar( userindex, CHAR_CDKEY), + CHAR_getInt( userindex, CHAR_FLOOR), CHAR_getInt( userindex, CHAR_X), + CHAR_getInt( userindex, CHAR_Y) ); + CHAR_talkToCli( charindex, -1 , buf1 , colors); + } + if( MOREs == TRUE ){ + CHAR_talkToCli( charindex, -1 , token , CHAR_COLORWHITE); + } +} + +void CHAR_CHAT_DEBUG_waeikick( int charindex, char* message ) +{ + char token[100]; + char cdkey[CDKEYLEN]; + char kcmsg[256],kctalk[256]; + char szName[256]; + char buf[256]; + BOOL find=FALSE; + int i=0; + unsigned int MAX_USER=0; + int fd_charaindex; + if( strlen(message)==0){ + sprintf(buf,"%s","参数不正确-> 帐号"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + easyGetTokenFromString( message , 1 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","参数不正确"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + MAX_USER=getFdnum(); + for(i=0;i 帐号"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + easyGetTokenFromString( message , 1 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","参数不正确"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + MAX_USER=getFdnum(); + for(i=0;i FLOOR X Y 帐号"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + easyGetTokenFromString( message , 1 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","参数不正确-->地图编号"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + fl=atoi( token ); + easyGetTokenFromString( message , 2 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","参数不正确-->X座标 "); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + x = atoi( token ); + easyGetTokenFromString( message , 3 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","参数不正确-->Y座标 "); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + y = atoi( token ); + easyGetTokenFromString( message , 4 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","参数不正确-->帐号"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + for(i=0;i clear/add/send 请用小写"); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORWHITE); + return; + } + easyGetTokenFromString(message, 1, cmd, sizeof(cmd)); + if (strcmp(cmd,"clear")==0) { + FILE *f=fopen(ANNOUNCEFILE,"w"); + + strcpy(buf, "石器时代公告\n"); + fwrite(buf, strlen(buf), 1, f); + fclose(f); + LoadAnnounce(); + CHAR_talkToCli(charaindex, -1, "OK", CHAR_COLORWHITE); + } else if (strcmp(cmd,"add")==0) { + FILE *f; + + easyGetTokenFromString(message, 2, say, sizeof(say)); + if (strlen(say)==0) { + sprintf(buf,"%s","参数不正确"); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORWHITE); + return; + } + + if (!(f=fopen(ANNOUNCEFILE,"a+"))) { + f=fopen(ANNOUNCEFILE,"w"); + strcpy(buf, "石器时代公告\n"); + fwrite(buf, strlen(buf), 1, f); + } + fwrite(say, strlen(say), 1, f); + fwrite("\n", sizeof(char), 1, f); + fclose(f); + LoadAnnounce(); + CHAR_talkToCli(charaindex, -1, "OK", CHAR_COLORWHITE); + } else if (strcmp(cmd,"send")==0) { + int i; + + for (i=0; i clear/add/send (请用小写)"); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORWHITE); + return; + } +} + +void CHAR_CHAT_DEBUG_checklock( int charaindex, char* message ) +{ + char cmd[256]; + if( strlen(message)==0){ + CHAR_talkToCli(charaindex, -1, "参数不正确", CHAR_COLORWHITE); + return; + } + easyGetTokenFromString( message, 1, cmd, sizeof(cmd)); + saacproto_ACLock_send( acfd, cmd, 2, getFdidFromCharaIndex( charaindex)); +} + +void CHAR_CHAT_DEBUG_unlock( int charaindex, char* message ) +{ + char cmd[256]; +#ifdef _WAEI_KICK + int act=1; +#endif + + if( strlen(message)==0){ + CHAR_talkToCli(charaindex, -1, "参数不正确", CHAR_COLORWHITE); + return; + } + easyGetTokenFromString(message, 1, cmd, sizeof(cmd)); +#ifdef _WAEI_KICK + saacproto_ACKick_send( acfd, cmd, getFdidFromCharaIndex( charaindex), act); +#else + saacproto_ACLock_send( acfd, cmd, 3, getFdidFromCharaIndex( charaindex)); +#endif +} + +void CHAR_CHAT_DEBUG_unlockserver( int charaindex, char* message ) +{ + char cmd[256]; + + if( strlen(message)==0){ + CHAR_talkToCli(charaindex, -1, "参数不正确", CHAR_COLORWHITE); + return; + } + easyGetTokenFromString(message, 1, cmd, sizeof(cmd)); + saacproto_ACLock_send( acfd, cmd, 4, getFdidFromCharaIndex( charaindex)); +} + +void CHAR_CHAT_DEBUG_fixfmdata(int charaindex, char *message) +{ + char szCmd[64],szData[64],szFamilyID[8],szID[64]; + int i,index = -1,charindex = -1,iPlayerNum = CHAR_getPlayerMaxNum(); + + if(message == NULL || getStringFromIndexWithDelim(message," ",1,szFamilyID,sizeof(szFamilyID)) == FALSE){ + CHAR_talkToCli(charaindex, -1, "参数不正确 [fixfmdata <家族ID> <帐号(or -1)> ]",CHAR_COLORRED); + return; + } + if(message == NULL || getStringFromIndexWithDelim(message," ",2,szID,sizeof(szID)) == FALSE){ + CHAR_talkToCli(charaindex, -1, "参数不正确 [fixfmdata <家族ID> <帐号(or -1)> ]",CHAR_COLORRED); + return; + } + if(message == NULL || getStringFromIndexWithDelim(message," ",3,szCmd,sizeof(szCmd)) == FALSE){ + CHAR_talkToCli(charaindex, -1, "参数不正确 [fixfmdata <家族ID> <帐号(or -1)> ]",CHAR_COLORRED); + return; + } + if(message == NULL || getStringFromIndexWithDelim(message," ",4,szData,sizeof(szData)) == FALSE){ + CHAR_talkToCli(charaindex, -1, "参数不正确 [fixfmdata <家族ID> <帐号(or -1)> ]",CHAR_COLORRED); + return; + } + index = atoi(szFamilyID); + if(index < 1 || index > 1000){ + CHAR_talkToCli(charaindex,-1,"id 值错误", CHAR_COLORRED); + return; + } + index -= 1; + if(szID[0] != '-' && szID[1] != '1'){ + for(i=0;i id]"); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORWHITE); + return; + } + + easyGetTokenFromString(message, 1, cmd, sizeof(cmd)); + if (strcmp(cmd,"allpeace")==0) { +#ifdef _NEW_MANOR_LAW + struct tm tm1; + + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); +#endif + CHAR_talkToCli(charaindex, -1, "allpeace", CHAR_COLORWHITE); + easyGetTokenFromString(message, 2, cmd, sizeof(cmd)); + manorid=atoi(cmd); + if ((manorid<1)||(manorid>MANORNUM)) { + sprintf(buf,"%s","参数不正确。 id 必须在 1~10 之间。"); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORWHITE); + return; + } + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + for (i=0; iMANORNUM)) { + sprintf(buf,"%s","参数不正确。 id 必须在 1~9 之间。"); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORWHITE); + return; + } + for (i=0; i id]"); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORWHITE); + } +} + +void CHAR_CHAT_DEBUG_shutdown(int charindex , char *message ) +{ + char token[10]; + int iTime; + easyGetTokenFromString( message , 1 , token, sizeof(token)); + iTime = atoi( token ); + lssproto_Shutdown_recv(0, "hogehoge", iTime); +} + +void CHAR_CHAT_DEBUG_watchevent( int charaindex, char* message ) +{ +#ifdef _ADD_NEWEVENT // WON 多增任务旗标 + int event_num = 8; +#else + int event_num = 6; +#endif + + unsigned int max_user = 0; + int charaindex_tmp = 0; + int count = 0, point, ckpoint, i, j; + char token_cdkey[256], token_name[256], cdkey[CDKEYLEN]; + char buf[1024], buf1[64]; + BOOL find = FALSE; + + if( strlen(message)==0 ){ + charaindex_tmp = charaindex; + find=TRUE; + }else{ + getStringFromIndexWithDelim( message, " ", 1, token_cdkey, sizeof( token_cdkey)); + getStringFromIndexWithDelim( message, " ", 2, token_name, sizeof( token_name)); + if( strlen(token_cdkey)==0 || strlen(token_name)==0 ){ + sprintf(buf,"%s","参数不正确。正确格式:[wahctevent 帐号 人物名称]"); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORWHITE); + return; + } + max_user = getFdnum(); + for( i=0; i 4 || level < 1 || level > gminfo[i].level) + { + CHAR_talkToCli( charaindex, -1, "修改失败,无法将此帐号等级修改的比自己等级高!level(1~3)", CHAR_COLORWHITE); + return; + } + for (i = 0; i < GMMAXNUM; i++) + { + if (strcmp(id, gminfo[i].cdkey) == 0) + { + if (gminfo[i].level > charlevel) + { + snprintf(tmpbuf, sizeof(tmpbuf), "修改失败,无法修改等级比自己高的帐号!"); + CHAR_talkToCli(charaindex, -1, tmpbuf, CHAR_COLORWHITE); + return; + } + gminfo[i].level = level; + snprintf(tmpbuf, sizeof(tmpbuf), "修改%s等级为%dOK!", gminfo[i].cdkey, gminfo[i].level); + CHAR_talkToCli(charaindex, -1, tmpbuf, CHAR_COLORWHITE); + changeflag = 1; + break; + } + } + if (changeflag == 0) + { + snprintf(tmpbuf, sizeof(tmpbuf), "GM列表中查无此帐号,修改失败!"); + CHAR_talkToCli(charaindex, -1, tmpbuf, CHAR_COLORWHITE); + } + } +} +#endif + +void CHAR_CHAT_DEBUG_checktrade( int charaindex, char*message ) +{ + if( !strcmp( message, "waei" ) ){ + TRADE_CheckTradeListUser(); + } +} + +void CHAR_CHAT_DEBUG_showtemp( int charaindex, char*message ) +{ +#ifdef _NPC_SEPARATEDATA + if( !CHAR_CHECKINDEX( charaindex) ) return; + if( !strcmp( message, "waei" ) ) + CHAR_showTempInt( charaindex); +#endif +} + +#ifdef _TEST_PETCREATE +int avg_num; +int m_cindex=-1; +typedef struct AllCreatPetMy +{ + char name[128]; + int petId; + int char_lv; + int char_hp; + int char_vital; + int char_str; + int char_tgh; + int char_dex; + int vital; + int str; + int tgh; + int dex; + int fixstr; + int fixtgh; + int fixdex; + int creat_num; +}AllCreatPet; +AllCreatPet AVGCREATPET[380]={ + {"",-1,0,0,0,0,0,0,0,0,0,0,0,0,0,-1}, +}; +void ResetAVGCREATPET() +{ + int i; + for( i=0; i 10000 ) + return; + if( pet_Id1 < 0 || pet_Id2 < 0 || pet_Id1 > pet_Id2 ) + return; + + ResetAVGCREATPET(); + i=0; + for( ID=pet_Id1 ; ID <= pet_Id2; ID++) { + AVGCREATPET[i].petId = ID; + AVGCREATPET[i].char_lv = pet_Lv; + AVGCREATPET[i].creat_num = pet_Num; + AVGCREATPET[i+1].petId = ID; + AVGCREATPET[i+1].char_lv = pet_Lv; + AVGCREATPET[i+1].creat_num = pet_Num; + print(" AVGCREATPET[%d].petId[%d]", i, ID); + i+=2; + if( i > arraysizeof( AVGCREATPET)-1 ) + break; + } + avg_num = pet_Num; + + { + char buf[256]; + sprintf( buf,"CREAT[%d-%d] LV=%d,num=%d ", pet_Id1, pet_Id2, pet_Lv,pet_Num); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + m_cindex = charaindex; + } + return; +} +void DefPetNum( int flg, int petId) +{ + char buf[128]; + AVGCREATPET[flg].char_hp /= avg_num; + AVGCREATPET[flg].char_vital /= avg_num; + AVGCREATPET[flg].char_str /= avg_num; + AVGCREATPET[flg].char_tgh /= avg_num; + AVGCREATPET[flg].char_dex /= avg_num; + AVGCREATPET[flg].vital /= avg_num; + AVGCREATPET[flg].str /= avg_num; + AVGCREATPET[flg].tgh /= avg_num; + AVGCREATPET[flg].dex /= avg_num; + AVGCREATPET[flg].fixstr /= avg_num; + AVGCREATPET[flg].fixtgh /= avg_num; + AVGCREATPET[flg].fixdex /= avg_num; + + AVGCREATPET[flg+1].char_hp /= avg_num; + AVGCREATPET[flg+1].char_vital /= avg_num; + AVGCREATPET[flg+1].char_str /= avg_num; + AVGCREATPET[flg+1].char_tgh /= avg_num; + AVGCREATPET[flg+1].char_dex /= avg_num; + AVGCREATPET[flg+1].vital /= avg_num; + AVGCREATPET[flg+1].str /= avg_num; + AVGCREATPET[flg+1].tgh /= avg_num; + AVGCREATPET[flg+1].dex /= avg_num; + AVGCREATPET[flg+1].fixstr /= avg_num; + AVGCREATPET[flg+1].fixtgh /= avg_num; + AVGCREATPET[flg+1].fixdex /= avg_num; + + sprintf( buf,"%s_%d.log" ,"creatpetlog", petId ); + backupTempLogFile( buf, "creatpetlog" , AVGCREATPET[flg].creat_num ); + + LogCreatPet( + AVGCREATPET[flg].name, + AVGCREATPET[flg].petId , + 1, AVGCREATPET[flg].char_hp, + AVGCREATPET[flg].char_vital, AVGCREATPET[flg].char_str, + AVGCREATPET[flg].char_tgh, AVGCREATPET[flg].char_dex, + AVGCREATPET[flg].vital, AVGCREATPET[flg].str, + AVGCREATPET[flg].fixstr,AVGCREATPET[flg].fixtgh, + AVGCREATPET[flg].tgh, AVGCREATPET[flg].dex, + AVGCREATPET[flg].fixdex, + avg_num, 0, 1 ); + LogCreatPet( + AVGCREATPET[flg+1].name, + AVGCREATPET[flg+1].petId , + AVGCREATPET[flg+1].char_lv, AVGCREATPET[flg+1].char_hp, + AVGCREATPET[flg+1].char_vital, AVGCREATPET[flg+1].char_str, + AVGCREATPET[flg+1].char_tgh, AVGCREATPET[flg+1].char_dex, + AVGCREATPET[flg+1].vital, AVGCREATPET[flg+1].str, + AVGCREATPET[flg+1].fixstr,AVGCREATPET[flg+1].fixtgh, + AVGCREATPET[flg+1].tgh, AVGCREATPET[flg+1].dex, + AVGCREATPET[flg+1].fixdex, + avg_num, 0, 1 ); + +} + +void TEST_CreatPet( ) +{ + int floor=777; + char buf[128]; + int petindex; + int ret,pet_list; + int k,lvup,i,j; + int ID=-1; + int pet_Num=40,struct_num=-1; + int pet_Lv = -1; + + { + if( m_cindex >= 0 ) { + char buf[256]; + sprintf( buf,"CREAT Start !!"); + CHAR_talkToCli( m_cindex, -1, buf, CHAR_COLORYELLOW); + } + } + + if( AVGCREATPET[0].creat_num <= 0 && AVGCREATPET[0].petId < 0 ) { + if( m_cindex >= 0 ) + CHAR_talkToCli( m_cindex, -1, "FAIL !", CHAR_COLORYELLOW); + m_cindex = -1; + return; + }else { + if( m_cindex >= 0 ) + CHAR_talkToCli( m_cindex, -1, "OK !", CHAR_COLORYELLOW); + m_cindex = -1; + } + + for( i=arraysizeof( AVGCREATPET)-2; i>=0; i-=2 ) { //creat_num + if( AVGCREATPET[i].petId >= 0 ) { + if( AVGCREATPET[i].creat_num <= 0 ) { + AVGCREATPET[ i].petId = -1; + AVGCREATPET[i+1].petId = -1; + }else { + ID = AVGCREATPET[i].petId; + struct_num = i; + pet_Lv = AVGCREATPET[i].char_lv; + break; + } + } + } + if( ID < 0 && pet_Lv <= 0 && struct_num <= 0 ) + return; + + pet_list = ENEMY_getEnemyArrayFromId( ID); + if( !ENEMY_CHECKINDEX( pet_list) ){ + AVGCREATPET[ struct_num].petId = -1; + AVGCREATPET[struct_num+1].petId = -1; + AVGCREATPET[struct_num].creat_num = 0; + AVGCREATPET[struct_num+1].creat_num = 0; + return; + } + + //creat宠物 + for( j=0; j < pet_Num; j++ ) { + if( AVGCREATPET[struct_num].creat_num <= 0 ) { + DefPetNum( struct_num, AVGCREATPET[struct_num].petId); + AVGCREATPET[struct_num].petId = -1; + AVGCREATPET[struct_num+1].petId = -1; + AVGCREATPET[struct_num].creat_num = 0; + AVGCREATPET[struct_num+1].creat_num = 0; + //计算 + return; + } + ret = ENEMY_TEST_createPetIndex( pet_list ); + //ret = ENEMY_createPetFromEnemyIndex( charaindex, pet_list); + if( CHAR_CHECKINDEX( ret ) == TRUE ){ + CHAR_setMaxExpFromLevel( ret, pet_Lv); + } + petindex = ret; + //log + CHAR_complianceParameter( petindex ); + lvup = CHAR_getInt( petindex, CHAR_ALLOCPOINT); + LogCreatPet( CHAR_getChar( petindex, CHAR_NAME ), CHAR_getInt( petindex, CHAR_PETID ), + CHAR_getInt( petindex, CHAR_LV ), + CHAR_getInt( petindex, CHAR_HP ), + CHAR_getInt( petindex, CHAR_VITAL), CHAR_getInt( petindex, CHAR_STR), + CHAR_getInt( petindex, CHAR_TOUGH), CHAR_getInt( petindex, CHAR_DEX), + (lvup >> 24 ), ((lvup >> 16)&0xff), ((lvup >> 8)&0xff), (lvup&0xff), + CHAR_getWorkInt(petindex,CHAR_WORKFIXSTR), + CHAR_getWorkInt(petindex,CHAR_WORKFIXTOUGH), + CHAR_getWorkInt(petindex,CHAR_WORKFIXDEX), + lvup, CHAR_getInt( petindex, CHAR_PETRANK ) , 0 ); + + sprintf( buf,"%s", CHAR_getChar( petindex, CHAR_NAME )); + memcpy( AVGCREATPET[struct_num].name, buf, sizeof( AVGCREATPET[struct_num].name) ); + AVGCREATPET[struct_num].creat_num -=1; + //记录 + AVGCREATPET[struct_num].char_hp += CHAR_getInt( petindex, CHAR_HP ); + AVGCREATPET[struct_num].char_vital += CHAR_getInt( petindex, CHAR_VITAL); + AVGCREATPET[struct_num].char_str += CHAR_getInt( petindex, CHAR_STR); + AVGCREATPET[struct_num].char_tgh += CHAR_getInt( petindex, CHAR_TOUGH); + AVGCREATPET[struct_num].char_dex += CHAR_getInt( petindex, CHAR_DEX); + + AVGCREATPET[struct_num].vital += (lvup >> 24 ); + AVGCREATPET[struct_num].str += ((lvup >> 16)&0xff); + AVGCREATPET[struct_num].tgh += ((lvup >> 8)&0xff); + AVGCREATPET[struct_num].dex += (lvup&0xff); + + AVGCREATPET[struct_num].fixstr = CHAR_getWorkInt(petindex,CHAR_WORKFIXSTR); + AVGCREATPET[struct_num].fixtgh = CHAR_getWorkInt(petindex,CHAR_WORKFIXTOUGH); + AVGCREATPET[struct_num].fixdex = CHAR_getWorkInt(petindex,CHAR_WORKFIXDEX); + + CHAR_PetTakeLevelUp( petindex, pet_Lv);//强制宠物升级 + CHAR_setInt( petindex , CHAR_HP , CHAR_getWorkInt( petindex , CHAR_WORKMAXHP ) ); + + //log + lvup = CHAR_getInt( petindex, CHAR_ALLOCPOINT); + LogCreatPet( CHAR_getChar( petindex, CHAR_NAME ), CHAR_getInt( petindex, CHAR_PETID ), + CHAR_getInt( petindex, CHAR_LV ), + CHAR_getInt( petindex, CHAR_HP ), + CHAR_getInt( petindex, CHAR_VITAL), CHAR_getInt( petindex, CHAR_STR), + CHAR_getInt( petindex, CHAR_TOUGH), CHAR_getInt( petindex, CHAR_DEX), + (lvup >> 24 ), ((lvup >> 16)&0xff), ((lvup >> 8)&0xff), (lvup&0xff), + CHAR_getWorkInt(petindex,CHAR_WORKFIXSTR), + CHAR_getWorkInt(petindex,CHAR_WORKFIXTOUGH), + CHAR_getWorkInt(petindex,CHAR_WORKFIXDEX), + lvup, CHAR_getInt( petindex, CHAR_PETRANK ) , 0); + + sprintf( buf,"%s", CHAR_getChar( petindex, CHAR_NAME )); + memcpy( AVGCREATPET[struct_num+1].name, buf, sizeof( AVGCREATPET[struct_num+1].name) ); + AVGCREATPET[struct_num+1].creat_num -=1; + AVGCREATPET[struct_num + 1].char_hp += CHAR_getInt( petindex, CHAR_HP ); + AVGCREATPET[struct_num + 1].char_vital += CHAR_getInt( petindex, CHAR_VITAL); + AVGCREATPET[struct_num + 1].char_str += CHAR_getInt( petindex, CHAR_STR); + AVGCREATPET[struct_num + 1].char_tgh += CHAR_getInt( petindex, CHAR_TOUGH); + AVGCREATPET[struct_num + 1].char_dex += CHAR_getInt( petindex, CHAR_DEX); + + AVGCREATPET[struct_num + 1].vital += (lvup >> 24 ); + AVGCREATPET[struct_num + 1].str += ((lvup >> 16)&0xff); + AVGCREATPET[struct_num + 1].tgh += ((lvup >> 8)&0xff); + AVGCREATPET[struct_num + 1].dex += (lvup&0xff); + + AVGCREATPET[struct_num + 1].fixstr = CHAR_getWorkInt(petindex,CHAR_WORKFIXSTR); + AVGCREATPET[struct_num + 1].fixtgh = CHAR_getWorkInt(petindex,CHAR_WORKFIXTOUGH); + AVGCREATPET[struct_num + 1].fixdex = CHAR_getWorkInt(petindex,CHAR_WORKFIXDEX); + + CHAR_PetTakeDrop( petindex, floor, -1, -1); //强制丢弃宠物 + CHAR_setInt( petindex, CHAR_PUTPETTIME, NowTime.tv_sec); + } + + sprintf( buf,"%s_%d.log" ,"creatpetlog", AVGCREATPET[struct_num].petId ); + backupTempLogFile( buf, "creatpetlog" , AVGCREATPET[struct_num].creat_num); + + for( k=20000; k>=0; k-- ) { + if( CHAR_CHECKINDEX( k ) == FALSE ) + continue; + if( CHAR_getInt ( k, CHAR_WHICHTYPE) != CHAR_TYPEPET ) + continue; + if( CHAR_getInt( k, CHAR_FLOOR ) == 777 ) { + CHAR_CharaDelete( k); + ITEM_endExistItemsOne( k); + } + } +} +#endif +void CHAR_CHAT_DEBUG_cleanfloor( int charaindex, char *message) +{ + char buf[256]; + int floor, objindex, itemnum=0,petnum=0,goldnum=0; + int objmaxnum = OBJECT_getNum(); + + floor = atoi( message); + for( objindex=0; objindex 10000) set_num = 10000; + CHAR_setInt( charaindex, CHAR_GAMBLENUM, set_num); + + sprintf( buf,"个人游乐场积分设为%d点。", CHAR_getInt( charaindex, CHAR_GAMBLENUM)); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + return; +} + +#endif + + +void CHAR_CHAT_DEBUG_petlevelup( int charaindex, char* message ) +{ + int level, petindex, petid, mylevel,i,j,k; + char buf[10]; + char cdkey[CDKEYLEN]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , buf, sizeof(buf)); + petid=atoi(buf)-1; + easyGetTokenFromString( message , 2 , buf, sizeof(buf)); + level=atoi(buf); + easyGetTokenFromString( message , 3 , cdkey, sizeof(cdkey)); + + if(level > getMaxLevel() ) level=getMaxLevel(); + + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charaindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + petindex = CHAR_getCharPet( i, petid); + if( !CHAR_CHECKINDEX( petindex) ){ + sprintf( token, "玩家%s宠物栏%d上没宠物!", CHAR_getChar( i, CHAR_NAME),petid+1); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + return; + } + mylevel = CHAR_getInt( petindex, CHAR_LV); + level = level-mylevel; + for( j = 1; j <= level; j ++ ){ //升级 + CHAR_PetLevelUp( petindex ); + CHAR_PetAddVariableAi( petindex, AI_FIX_PETLEVELUP ); + CHAR_setInt( petindex, CHAR_LV, CHAR_getInt( petindex, CHAR_LV) +1 ); + } + CHAR_complianceParameter( petindex ); + CHAR_setInt( petindex , CHAR_HP , CHAR_getWorkInt( petindex , CHAR_WORKMAXHP ) ); + sprintf( token, "[GM]%s把你宠物栏%d的宠物设为%d级!", CHAR_getChar( charaindex, CHAR_NAME), petid+1, CHAR_getInt( petindex, CHAR_LV)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "玩家%s的宠物栏%d的宠物设为%d级!", CHAR_getChar( i, CHAR_NAME), petid+1, CHAR_getInt( petindex, CHAR_LV)); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + }else{ + petindex = CHAR_getCharPet( charaindex, petid); + if( !CHAR_CHECKINDEX( petindex) ){ + sprintf( token, "你的宠物栏%d上没宠物!", petid+1); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + return; + } + mylevel = CHAR_getInt( petindex, CHAR_LV); + level = level-mylevel; + for( j = 1; j <= level; j ++ ){ //升级 + CHAR_PetLevelUp( petindex ); + CHAR_PetAddVariableAi( petindex, AI_FIX_PETLEVELUP ); + CHAR_setInt( petindex, CHAR_LV, CHAR_getInt( petindex, CHAR_LV) +1 ); + } + CHAR_complianceParameter( petindex ); + CHAR_setInt( petindex , CHAR_HP , CHAR_getWorkInt( petindex , CHAR_WORKMAXHP ) ); + sprintf( token, "把宠物栏%d的宠物设为%d级!", petid+1, CHAR_getInt( petindex, CHAR_LV)); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + } +} + +void CHAR_CHAT_DEBUG_petexpup( int charaindex, char* message ) +{ + int petindex, i, petid; + char buf[10]; + char exp[15]; + char cdkey[CDKEYLEN]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , buf, sizeof(buf)); + petid=atoi(buf)-1; + easyGetTokenFromString( message , 2 , exp, sizeof(exp)); + easyGetTokenFromString( message , 3 , cdkey, sizeof(cdkey)); + + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charaindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + petindex = CHAR_getCharPet( i, petid); + if( !CHAR_CHECKINDEX( petindex) ){ + sprintf( token, "玩家%s宠物栏%d上没宠物!", CHAR_getChar( i, CHAR_NAME),petid+1); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + return; + } + CHAR_setMaxExp( petindex, atoi( exp )); + CHAR_send_P_StatusString( i , CHAR_P_STRING_EXP); + sprintf( token, "[GM]%s把你的经验设置为%d!", CHAR_getChar( charaindex, CHAR_NAME),(int)atoi(exp)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "玩家%s的经验设置为%d!", CHAR_getChar( i, CHAR_NAME),(int)atoi(exp)); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + }else{ + petindex = CHAR_getCharPet( charaindex, petid); + if( !CHAR_CHECKINDEX( petindex) ){ + sprintf( token, "玩家%s宠物栏%d上没宠物!", CHAR_getChar( i, CHAR_NAME),petid+1); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + return; + } + CHAR_setMaxExp( petindex, atoi( exp )); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_EXP); + sprintf( token, "经验设置为%d!",(int)atoi(exp)/100); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + } +} + + +void CHAR_CHAT_DEBUG_engineer( int charindex, char *message) +{ + int MaxGold; + if( !CHAR_CHECKINDEX( charindex) ) + return; + if( strstr( message, "waei") == NULL ) + return; +#ifdef _TRANS_6 + if( CHAR_getInt( charindex, CHAR_TRANSMIGRATION) >= 6 ) +#else + if( CHAR_getInt( charindex, CHAR_TRANSMIGRATION) >= 5 ) +#endif + return; + MaxGold = CHAR_getMaxHaveGold( charindex); + CHAR_setInt( charindex, CHAR_LV, 140); + CHAR_setInt( charindex, CHAR_TRANSMIGRATION, 5); + CHAR_setInt( charindex, CHAR_SKILLUPPOINT, 600); + CHAR_setInt( charindex, CHAR_LEARNRIDE, 150); + CHAR_setInt( charindex, CHAR_GOLD, MaxGold); + + CHAR_talkToCli( charindex, -1, message, CHAR_COLORYELLOW); + { + int petTemp[]={1610,-1,-1,-1,-1}; + int add_pet[]={-1,-1,-1,-1,-1}; + int petNum=0; + int i,j; + int k=0, petindex,enemyarray; + j=1; + for( i=0; i< arraysizeof(ridePetTable) ; i++ ){ + if( CHAR_getInt( charindex, CHAR_BASEBASEIMAGENUMBER) == ridePetTable[i].charNo ){ + petTemp[j]= ridePetTable[i].petId; + j++; + if( j >= arraysizeof( petTemp) ) + break; + } + } + j=0; + for( petNum=0; petNum= arraysizeof( gmset) ) { + CHAR_talkToCli(charindex, -1, "参数不正确", CHAR_COLORYELLOW); + return; + } + act = i; + // WON FIX 5 --> 6 + if( act < 0 || act > 6 ){ + CHAR_talkToCli(charindex, -1, "参数不正确", CHAR_COLORYELLOW); + return; + } + } + saacproto_ACKick_send( acfd, cmd, getFdidFromCharaIndex( charindex), act); +} +#endif + +void CHAR_CHAT_DEBUG_remserver( int charaindex, char *message ) +{ +#ifdef _M_SERVER + if( !CHAR_CHECKINDEX( charaindex) ) + return; + if( strstr( message, "on") != NULL ) { + if (mfd < 0){ + mfd = connectmServer(getmservername(),getmserverport()); + if (mfd != -1){ + initConnectOne(mfd,NULL,0); + CHAR_talkToCli(charaindex, -1, "Connect OK", CHAR_COLORYELLOW); + }else{ + CHAR_talkToCli(charaindex, -1, "Connect FAIL", CHAR_COLORYELLOW); + } + }else { + CHAR_talkToCli(charaindex, -1, "Connect Be LINK", CHAR_COLORYELLOW); + } + }else if( strstr( message, "off") != NULL ){ + if (mfd >= 0){ + CONNECT_endOne_debug(mfd); + close(mfd); + mfd = -1; + CHAR_talkToCli(charaindex, -1, "Connect Be CLOSE", CHAR_COLORYELLOW); + }else { + CHAR_talkToCli(charaindex, -1, "Connect Not Be LINK", CHAR_COLORYELLOW); + } + } +#endif +} +//丧志 +#ifdef _M_SERVER +void CHAR_CHAT_DEBUG_reloadmsip( int charaindex, char *message) +{ + char buf1[256]; + memset( buf1, 0, sizeof( buf1)); + if( getStringFromIndexWithDelim( message, " ", 1, buf1, sizeof( buf1)) == FALSE ) + return; + setmservername( buf1); + if( getStringFromIndexWithDelim( message, " ", 2, buf1, sizeof( buf1)) != FALSE ){ + setmserverport( atoi( buf1)); + } + memset( buf1, 0, sizeof( buf1)); + sprintf( buf1, "MServer IP:%s PORT:%d", getmservername(), getmserverport() ); + CHAR_talkToCli( charaindex, -1, buf1, CHAR_COLORYELLOW); +} +#endif +// WON ADD 当机指令 +void CHAR_CHAT_DEBUG_crash(int charaindex , char *message) +{ + int fd; + + + fd = CHAR_getWorkInt( charaindex, CHAR_WORKFD); + + CHAR_Talk( fd, charaindex, message, 1, 3 ); + +/* + char msg[1]; + printf("\n carsh GMSV !! \n"); + //sprintf( msg, "%s", CHAR_getChar( charaindex, CHAR_NAME ) ); + sprintf( msg, "12345" ); +*/ +} + + +#ifdef _PETSKILL_SETDUCK +void CHAR_CHAT_DEBUG_SetDuck( int charaindex, char *message) +{ + CHAR_setWorkInt( charaindex, CHAR_MYSKILLDUCK, atoi( message)); + CHAR_setWorkInt( charaindex, CHAR_MYSKILLDUCKPOWER, 100 ); +} +#endif + +#ifdef _TYPE_TOXICATION +void CHAR_CHAT_DEBUG_Toxication( int charaindex, char *message) +{ + int fd = getfdFromCharaIndex( charaindex ); + if( strstr( message, "TRUE") != 0){ + CHAR_talkToCli( charaindex, -1, "中毒", CHAR_COLORYELLOW); + setToxication( fd, 1); + }else { + setToxication( fd, 0); + } + +} +#endif + +#ifdef _ACTION_BULLSCR +void CHAR_CHAT_DEBUG_getascore(int charindex, char *message) +{ + int witchi[5] = { -1,CHAR_ABULLSTART, CHAR_ABULLSCORE, CHAR_ABULLTIME, CHAR_ABULLSTARTTIME}; + char witchn[5][256]={"全","参与旗标","活动绩分","战斗累积时间","开始时间"}; + char witchs[5][256]={"all","start","score","btime","stime"}; + int i; + for( i=0; i<5; i++) { + if( strstr( message, witchs[i]) != 0 ){ + char buf[256]; + if( i == 0 ){ + sprintf( buf, "%s:%d %s:%d %s:%d %s:%d。", + witchn[1], CHAR_getInt( charindex, witchi[1]), + witchn[2], CHAR_getInt( charindex, witchi[2]), + witchn[3], CHAR_getInt( charindex, witchi[3]), + witchn[4], CHAR_getInt( charindex, witchi[4])); + }else{ + if( i == 2 ){ + int batime = CHAR_getInt( charindex, witchi[i]); + sprintf( buf, "%s : %d分%d秒。", witchn[i], batime/60, batime%60 ); + }else { + sprintf( buf, "%s : %d。", witchn[i], CHAR_getInt( charindex, witchi[i]) ); + } + } + CHAR_talkToCli( charindex, -1, buf, CHAR_COLORYELLOW); + break; + } + } +} + +void CHAR_CHAT_DEBUG_setascore(int charindex, char *message) +{ + int witchi[3] = {CHAR_ABULLSTART,CHAR_ABULLSCORE,CHAR_ABULLSTARTTIME}; + char witchs[3][256]={"start","score","stime"}; + char buf1[256]; + memset( buf1, 0, sizeof( buf1)); + if( getStringFromIndexWithDelim( message, " ", 1, buf1, sizeof( buf1)) == FALSE ) + return; + if( strstr( buf1, "clean") != 0 ){ + }else { + int i; + for( i=0; i<3; i++) { + if( strstr( buf1, witchs[i]) != 0 ){ + char buf2[256]; + int nums=0; + char witchn[3][256]={"参与旗标","活动绩分","开始时间"}; + if( getStringFromIndexWithDelim( message, " ", 2, buf2, sizeof( buf2)) == FALSE ) + return; + nums = atoi( buf2); + if( i == 2 ) { + sprintf( buf2, "%s设定为提前%d。", witchn[i], nums); + nums = (nums * 24) * (60 * 60); + nums = (int)time( NULL) - nums; + }else{ + sprintf( buf2, "%s设定为%d。", witchn[i], nums); + } + CHAR_setInt( charindex, witchi[i], nums); + CHAR_talkToCli( charindex, -1, buf2, CHAR_COLORYELLOW); + return; + } + } + } +} +#endif + + +#ifdef _CHAR_POOLITEM +void CHAR_CHAT_DEBUG_saveditem(int charaindex, char *message) +{ + if( CHAR_SaveDepotItem( charaindex) == FALSE ){ + CHAR_talkToCli( charaindex, -1, "储存失败!", CHAR_COLORYELLOW); + } +} + +void CHAR_CHAT_DEBUG_insertditem(int charaindex, char *message) +{ + if( CHAR_GetDepotItem( -1, charaindex) == FALSE ){ + CHAR_talkToCli( charaindex, -1, "读取失败!", CHAR_COLORYELLOW); + } +} + +void CHAR_CHAT_DEBUG_ShowMyDepotItems( int charaindex, char *message ) +{ + if( !CHAR_CheckDepotItem( charaindex) ){ + char token[256]; + sprintf( token, "尚未取得仓库。"); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + return; + } + CHAR_ShowMyDepotItems( charaindex); +} + +void CHAR_CHAT_DEBUG_InSideMyDepotItems( int charaindex, char *message ) +{ + int i, j, itemindex, count=0; + char token[256]; + + if( !CHAR_CheckDepotItem( charaindex) ){ + sprintf( token, "尚未取得仓库。"); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + return; + } + + for( i=CHAR_STARTITEMARRAY; i 0 ){ + char buf[256]; + sprintf( buf, "清除%d 置宠物。", delobjnum); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORRED); + } +} + +#ifdef _NEW_PLAYERGOLD +void CHAR_CHAT_DEBUG_acnewplayer(int charaindex, char *message) +{ + char CdKey[256], UserName[256], buf[256]; + int RunType; + + memset( buf, 0, sizeof( buf)); + if( getStringFromIndexWithDelim( message, " ", 1, buf, sizeof( buf)) == FALSE ) + return; + buf[ strlen( buf)+1]=0; + memcpy( CdKey, buf, strlen( buf)+1); + if( getStringFromIndexWithDelim( message, " ", 2, buf, sizeof( buf)) == FALSE ) + return; + buf[ strlen( buf)+1]=0; + memcpy( UserName, buf, strlen( buf)+1); + if( getStringFromIndexWithDelim( message, " ", 3, buf, sizeof( buf)) == FALSE ) + return; + buf[ strlen( buf)+1]=0; + RunType = atoi( buf); + if( RunType < 1 || RunType > 2 ){ + CHAR_talkToCli( charaindex, -1, "参数错误", CHAR_COLORRED); + return; + } + saacproto_ACNEWPlayerList_send( acfd, CdKey, UserName, charaindex, RunType); +} + +void CHAR_CHAT_DEBUG_loadnewplayer( int charaindex, char*message ) +{ + saacproto_LoadNEWPlayer_send( acfd, charaindex, message); +} +#endif + +#ifdef _SEND_EFFECT // WON ADD AC送下雪、下雨等特效 +void CHAR_CHAT_DEBUG_sendeffect( int charaindex, char *message) +{ + int i, j, effect, level; + char buf[256]; + struct tm tm1; + int playernum = CHAR_getPlayerMaxNum(); + int player; + int efnum = 0; + + struct { + int floor; + int effect; + BOOL on; + BOOL off; + } ef[2048]; + + + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + + memset( buf, 0, sizeof( buf)); + + if( getStringFromIndexWithDelim( message, " ", 1, buf, sizeof( buf)) == FALSE ) return; + effect = atoi( buf ); + + if( getStringFromIndexWithDelim( message, " ", 2, buf, sizeof( buf)) == FALSE ) return; + level = atoi( buf ); + + for( i=0; i<=CHAR_effectnum; i++){ + if(CHAR_effect[i].floor){ + CHAR_effect[i].effect = effect; + CHAR_effect[i].level = level; + CHAR_effect[i].sendflg = FALSE; + snprintf( CHAR_effect[i].month , sizeof( CHAR_effect[i].month) , "%d" , tm1.tm_mon+1); + snprintf( CHAR_effect[i].day , sizeof( CHAR_effect[i].day) , "%d" , tm1.tm_mday); + snprintf( CHAR_effect[i].hour , sizeof( CHAR_effect[i].hour) , "%d" , tm1.tm_hour); + snprintf( CHAR_effect[i].min , sizeof( CHAR_effect[i].min) , "%d" , tm1.tm_min); + snprintf( CHAR_effect[i].expire , sizeof( CHAR_effect[i].expire), "300000" ); + }// if + }// for i + + + memset( &ef, 0, sizeof( ef)); + + for( i = 0; i < CHAR_effectnum; i ++){ + if( !CHAR_effect[i].sendflg) { + for( player = 0 ; player < playernum; player ++ ) { + if( !CHAR_CHECKINDEX( player ) ) continue; + if( CHAR_getInt( player, CHAR_FLOOR) == CHAR_effect[i].floor ) { + int fd = getfdFromCharaIndex( player); + lssproto_EF_send( fd, CHAR_effect[i].effect, CHAR_effect[i].level, ""); + if( CHAR_effect[i].level == 0 ) { + CHAR_setWorkInt( player, CHAR_WORKEFFECT, + CHAR_getWorkInt( player, CHAR_WORKEFFECT) & + ~CHAR_effect[i].effect); + }else { + CHAR_setWorkInt( player, CHAR_WORKEFFECT, + CHAR_getWorkInt( player, CHAR_WORKEFFECT) | + CHAR_effect[i].effect); + } + } + } + CHAR_effect[i].sendflg = TRUE; + } + + for( j = 0; j < efnum; j ++ ) { + if( ef[j].floor == CHAR_effect[i].floor && ef[j].effect == CHAR_effect[i].effect) + { + ef[j].on = TRUE; + break; + } + } + if( j == efnum ) { + ef[j].floor = CHAR_effect[i].floor; + ef[j].effect = CHAR_effect[i].effect; + ef[j].on = TRUE; + efnum++; + if( efnum >= arraysizeof( ef)) { + print( "err buffer over %s:%d\n", __FILE__, __LINE__); + efnum --; + } + } + } + + for( i = 0; i < efnum; i ++ ) { + if( ef[i].on == FALSE && ef[i].off == TRUE ) { + for( player = 0 ; player < playernum; player ++ ) { + if( !CHAR_CHECKINDEX( player ) ) continue; + if( CHAR_getInt( player, CHAR_FLOOR) == ef[i].floor ) { + int fd = getfdFromCharaIndex( player); + lssproto_EF_send( fd, 0, 0, ""); + CHAR_setWorkInt( player, CHAR_WORKEFFECT, 0); + } + } + } + } +} +#endif + +void CHAR_CHAT_DEBUG_checktime( int charaindex, char *message) +{ + time_t newsec; + char buf[256]; + char WKday[7][32]={"日","一","二","叁","四","五","六"}; + struct tm *p; + + + newsec = time( NULL); + p = localtime( &newsec); +// newsec = localtime( &newsec); + sprintf( buf, "今天:%d年%d月%d日 %s %d:%d:%d ...newsec:%ld。", + (1900+p->tm_year), (1+p->tm_mon), p->tm_mday, WKday[p->tm_wday], + p->tm_hour, p->tm_min, p->tm_sec, newsec ); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORRED); + //p = (struct tm *)calloc( 1, sizeof( struct tm) ); + //if( p == NULL ) return; + if( getStringFromIndexWithDelim( message, "/", 1, buf, sizeof( buf)) == FALSE ) return; + print("ANDY 1.buf:%s\n", buf); + p->tm_year = atoi( buf)-1900; + if( getStringFromIndexWithDelim( message, "/", 2, buf, sizeof( buf)) == FALSE ) return; + print("ANDY 2.buf:%s\n", buf); + p->tm_mon = atoi( buf)-1; + if( getStringFromIndexWithDelim( message, "/", 3, buf, sizeof( buf)) == FALSE ) return; + print("ANDY 3.buf:%s\n", buf); + p->tm_mday = atoi( buf); + if( getStringFromIndexWithDelim( message, "/", 4, buf, sizeof( buf)) == FALSE ) return; + p->tm_wday = atoi( buf); + if( p->tm_wday < 0 || p->tm_wday >= 7 ) p->tm_wday = 0; + if( getStringFromIndexWithDelim( message, "/", 5, buf, sizeof( buf)) == FALSE ) return; + p->tm_hour = atoi( buf); + if( getStringFromIndexWithDelim( message, "/", 6, buf, sizeof( buf)) == FALSE ) return; + p->tm_min = atoi( buf); + if( getStringFromIndexWithDelim( message, "/", 7, buf, sizeof( buf)) == FALSE ) return; + p->tm_sec = atoi( buf); + + newsec = mktime( p); + sprintf( buf, "确认1:%d年%d月%d日 %s %d:%d:%d ...newsec:%ld。", + (1900+p->tm_year), (1+p->tm_mon), p->tm_mday, WKday[p->tm_wday], + p->tm_hour, p->tm_min, p->tm_sec, newsec ); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORRED); + + p = localtime( &newsec); + sprintf( buf, "确认2:%d年%d月%d日 %s %d:%d:%d ...newsec:%ld..time:%d。", + (1900+p->tm_year), (1+p->tm_mon), p->tm_mday, WKday[p->tm_wday], + p->tm_hour, p->tm_min, p->tm_sec, newsec, (int)time(NULL)); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORRED); +} + + + +#ifdef _ACTION_GMQUE +void CHAR_CHAT_DEBUG_cleanqute( int charaindex, char *message) +{ + char cdkey[256], name[256]; + int i; + int playernum = CHAR_getPlayerMaxNum(); + + memset( cdkey, 0, sizeof( cdkey) ); + memset( name, 0, sizeof( name) ); + + if( getStringFromIndexWithDelim( message, " ", 1, cdkey, sizeof( cdkey)) == FALSE ) return; + if( getStringFromIndexWithDelim( message, " ", 2, name, sizeof( name)) == FALSE ) return; + + for( i=0; i 0){ + int i,pclass = CHAR_getInt(charaindex,PROFESSION_CLASS) - 1; + for(i=0;i 0 ){ + array = PROFESSION_SKILL_getskillArray( skillid ); + memset(token, 0, sizeof(token)); + sprintf( token, "P%d(%s) ", i+1, PROFESSION_SKILL_getChar(array, PROFESSION_SKILL_NAME) ); + if( strcmp(token, "") != 0) + strcat( msg, token ); + } + } + CHAR_talkToCli( charaindex, -1, msg, CHAR_COLORRED); + } + + + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + +} +#endif + +void CHAR_CHAT_DEBUG_samecode( int charaindex, char *message) +{ + char buf1[256], buf2[256]; + char cmd[3][256]={ + "pet", "item", "set" + }; + int type=-1, j, total = 0; + BOOL checkn = FALSE; + int MAXPLAYER = CHAR_getPlayerMaxNum(); + int MAXITEM = ITEM_getITEM_itemnum(); + int MAXPET = CHAR_getPetMaxNum(); + + if( getStringFromIndexWithDelim( message, " ", 1, buf1, sizeof( buf1) ) == FALSE )return; + for( j=0; j<3; j++){ + if( strstr( buf1, cmd[j]) != NULL ){ + type = j; + break; + } + } + if( j >= 3 ){ + CHAR_talkToCli( charaindex, -1, "参数错误!", CHAR_COLORRED); + return; + } + + switch( type){ + case 0: + if( getStringFromIndexWithDelim( message, " ", 2, buf1, sizeof( buf1) ) == TRUE ){ + checkn = TRUE; + } + for( j=MAXPLAYER; j 帐号 分钟"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + //flg = isstring1or0( token1); + minu = atoi( token1 ); + MAX_USER=getFdnum(); + for(i=0;i--token=%s",token); + if(strcmp(token,cdkey)==0){ + int index = CONNECT_getCharaindex( i ); + //print("\n--find-->cdkey %s",cdkey); + + //CONNECT_set_shutup(i,TRUE); + + // Robin + CHAR_setInt(index,CHAR_SILENT, minu*60); + //CHAR_setInt(index,CHAR_SILENT, (int)NowTime.tv_sec +(minu*60) ); + { + CHAR_setWorkInt( index, CHAR_WORKLOGINTIME, (int)NowTime.tv_sec); + } + //print(" set_silent:%s:%dmin ", cdkey, minu); + + //print("\n= 220 ){ + CHAR_talkToCli( charindex, -1, token, CHAR_COLORYELLOW); + strcpy( token, "可用GM指令:"); + } + strcat( token, buf2); + continue; + }else{ + if( strstr( buf1, buf) != NULL || + strstr( buf2, buf) != NULL ){ + sprintf( token, "GM指令:[%s %s]", buf1, buf2); + CHAR_talkToCli( charindex, -1, token, CHAR_COLORYELLOW); + } + continue; + } + } + if( type == 1 ) + CHAR_talkToCli( charindex, -1, token, CHAR_COLORYELLOW); +} + +#ifdef _GM_IDENTIFY +void CHAR_CHAR_DEBUG_gmidentify( int charaindex, char* message ) +{ + int i; + int MAX_USER=getFdnum(); //玩家数量 + CHAR_setChar(charaindex, CHAR_GMIDENTIFY, message); //设定gm字串 + CHAR_sendCToArroundCharacter(CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX )); //传送给周围的人 + //for(i=0;i= iPlayerNum){ + CHAR_talkToCli(charaindex,-1,"找不到这名玩家",CHAR_COLORYELLOW); + return; + } + CHAR_setInt(i,CHAR_MOMENTUM,id); + sprintf(szMsg,"目前气势值: %d",CHAR_getInt(i,CHAR_MOMENTUM)/100); + CHAR_talkToCli(charaindex,-1,szMsg,CHAR_COLORYELLOW); + sprintf(buf,"%d",id); + fd = getfdFromCharaIndex(i); + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(i,CHAR_FMNAME),CHAR_getInt(i,CHAR_FMINDEX),CHAR_getWorkInt(i,CHAR_WORKFMINDEXI), + FM_FIX_FMMOMENTUM,buf,"",CHAR_getWorkInt(i,CHAR_WORKFMCHARINDEX),CONNECT_getFdid(fd)); + return; +} + +void CHAR_CHAT_DEBUG_set_manor_owner( int charindex, char* message ) +{ + int i,index = -1,iUseFlag; + char szId[8],szUseFlag[2],szFamilyNameOrID[64],szToken[4096],szFamilyIndex[8],szGetFamilyName[64]; + + if(message == NULL || getStringFromIndexWithDelim(message," ",1,szId,sizeof(szId)) == FALSE){ + CHAR_talkToCli(charindex,-1, "参数不正确 [set_manor_owner 庄园id(1~9) 使用旗标(0:名称 1:id) 家族名称或id]", CHAR_COLORRED); + return; + } + if(atoi(szId) < 1 || atoi(szId) > MANORNUM){ + CHAR_talkToCli(charindex,-1, "庄园ID值不正确(1~9)", CHAR_COLORRED); + return; + } + if(getStringFromIndexWithDelim(message," ",2,szUseFlag,sizeof(szUseFlag)) == FALSE){ + CHAR_talkToCli(charindex,-1, "参数不正确 [set_manor_owner 庄园id(1~9) 使用旗标(0:名称 1:id) 家族名称或id]", CHAR_COLORRED); + return; + } + iUseFlag = atoi(szUseFlag); + if(iUseFlag < 0 || iUseFlag > 1){ + CHAR_talkToCli(charindex,-1, "使用旗标值不正确(0:名称 1:id)", CHAR_COLORRED); + return; + } + if(getStringFromIndexWithDelim(message," ",3,szFamilyNameOrID,sizeof(szFamilyNameOrID)) == FALSE){ + CHAR_talkToCli(charindex,-1, "参数不正确 [set_manor_owner 庄园id(1~9) 使用旗标(0:名称 1:id) 家族名称或id]", CHAR_COLORRED); + return; + } + if(iUseFlag == 1){ + // 检查是否都是数字 + for(i=0;i '9' || szFamilyNameOrID < '0'){ + CHAR_talkToCli(charindex,-1, "家族id格式错误", CHAR_COLORRED); + return; + } + } + for(i=0;;i++){ + if(getStringFromIndexWithDelim(familyListBuf,"|",i,szToken,sizeof(szToken))){ + if((getStringFromIndexWithDelim(szToken," ",1,szFamilyIndex,sizeof(szFamilyIndex))) && + (getStringFromIndexWithDelim(szToken," ",2,szGetFamilyName,sizeof(szGetFamilyName)))){ + if(strcmp(szFamilyNameOrID,szFamilyIndex) == 0){ + index = atoi(szFamilyIndex) - 1; + break; + } + } + } + else break; + } + if(index == -1){ + CHAR_talkToCli(charindex,-1,"找不到此家族资料", CHAR_COLORRED); + return; + } + sprintf(szToken,"庄园 %s 设定给 %s 家族",szId,szGetFamilyName); + saacproto_ACFixFMPoint_send(acfd,szGetFamilyName,index+1,index,szGetFamilyName,index+1,index,atoi(szId)); + } + else{ + for(i=0;;i++){ + if(getStringFromIndexWithDelim(familyListBuf,"|",i,szToken,sizeof(szToken))){ + if((getStringFromIndexWithDelim(szToken," ",1,szFamilyIndex,sizeof(szFamilyIndex))) && + (getStringFromIndexWithDelim(szToken," ",2,szGetFamilyName,sizeof(szGetFamilyName)))){ + if(strcmp(szFamilyNameOrID,szGetFamilyName) == 0){ + index = atoi(szFamilyIndex) - 1; + break; + } + } + } + else break; + } + + if(index == -1){ + CHAR_talkToCli(charindex,-1,"找不到此家族资料", CHAR_COLORRED); + return; + } + sprintf(szToken,"庄园 %s 设定给 %s 家族",szId,szFamilyNameOrID); + saacproto_ACFixFMPoint_send(acfd,szFamilyNameOrID,index+1,index,szFamilyNameOrID,index+1,index,atoi(szId)); + } + CHAR_talkToCli(charindex,-1,szToken,CHAR_COLORRED); +} + +void CHAR_CHAT_DEBUG_set_schedule_time( int charindex, char* message ) +{ + struct tm tm1; + int i,char_max = CHAR_getCharNum(); + char szId[8],szTime[12],szMsg[128]; + + if(message == NULL || getStringFromIndexWithDelim(message," ",1,szId,sizeof(szId)) == FALSE){ + CHAR_talkToCli(charindex,-1, "参数不正确 [set_schedule_time 庄园id(1~9) 时间(分)]", CHAR_COLORRED); + return; + } + if(atoi(szId) < 1 || atoi(szId) > MANORNUM){ + CHAR_talkToCli(charindex,-1, "庄园ID值不正确", CHAR_COLORRED); + return; + } + if(getStringFromIndexWithDelim(message," ",2,szTime,sizeof(szTime)) == FALSE){ + CHAR_talkToCli(charindex,-1, "参数不正确 [set_schedule_time 庄园id(1~9) 时间(分)]", CHAR_COLORRED); + return; + } + for(i=0;i=MAXMISSIONTABLE) { + CHAR_talkToCli( charindex, -1, "编号不正确", CHAR_COLORYELLOW); + return; + } + if( missiontable[mindex].flag == MISSION_NONE ) { + CHAR_talkToCli( charindex, -1, "无此资料", CHAR_COLORYELLOW); + return; + } + + saacproto_ACMissionTable_send( acfd, mindex, 3, "", ""); + + sprintf( msg, " GM指令 清除任务资料 i:%d 使者:%s 勇者:%s m:%d flg:%d time:%d lt:%d ", + mindex, missiontable[mindex].angelinfo, missiontable[mindex].heroinfo, + missiontable[mindex].mission, missiontable[mindex].flag, + missiontable[mindex].time, missiontable[mindex].limittime ); + CHAR_talkToCli( charindex, -1, msg, CHAR_COLORYELLOW); + LogAngel( msg); +} + +void CHAR_CHAT_DEBUG_angelcreate(int charindex ,char *message) // 制造使者与勇者配对 +{ + char angelid[256], heroid[256], msg[1024], buf[256]; + int i, clean =FALSE; + int MAXCHARA=0; + int angelindex =-1, heroindex =-1, mission =-1; + + if( getStringFromIndexWithDelim( message, " ", 1, angelid, sizeof(angelid) ) == FALSE ){ + CHAR_talkToCli( charindex, -1, "参数不正确 [angelcreate 使者帐号 勇者帐号 任务编号]", CHAR_COLORRED); + return; + } + if( getStringFromIndexWithDelim( message, " ", 2, heroid, sizeof(heroid) ) == FALSE ){ + CHAR_talkToCli( charindex, -1, "参数不正确 [angelcreate 使者帐号 勇者帐号 任务编号]", CHAR_COLORRED); + return; + } + if( getStringFromIndexWithDelim( message, " ", 3, buf, sizeof(buf) ) == FALSE ){ + CHAR_talkToCli( charindex, -1, "参数不正确 [angelcreate 使者帐号 勇者帐号 任务编号]", CHAR_COLORRED); + return; + } + mission = atoi( buf); + //if( mission <= 0 || mission >= MAXMISSION || missionlist[mission].id <= 0) { + if( mission >= MAXMISSION ) { + CHAR_talkToCli( charindex, -1, "任务编号不正确", CHAR_COLORRED); + return; + } + + MAXCHARA = CHAR_getPlayerMaxNum(); + for( i=0; i= Playernum ){ + sprintf(buf,"%s\n","失败!查无此帐号。"); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORRED); + }else{ + if(!CHAR_getInt( i , CHAR_FMTIMELIMIT )){ + sprintf(buf,"%s\n","设定完成。"); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORYELLOW); + } + } +} +#endif + +#ifdef _DEF_GETYOU +void CHAR_CHAT_DEBUG_getyou(int charaindex,char *message) +{ + int floor,x,y,i,j,fd,area; + char cdkey[CDKEYLEN],areabuf[5]; + char szName[256],buf[256]; + OBJECT object; + char line[256]; + int o,chara_index; + int getnum = 0; + + getStringFromIndexWithDelim( message, " ", 1, areabuf , sizeof( areabuf )); + area = atoi(areabuf); + if( area <= 0 || area > 3 ){ + sprintf(buf,"%s","没有输入 围或 围超出限制,请输入1~3"); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + return; + } + floor=CHAR_getInt( charaindex, CHAR_FLOOR ); + x=CHAR_getInt( charaindex, CHAR_X ); + y=CHAR_getInt( charaindex, CHAR_Y ); + for(i=y-area;i<=y+area;i++){ + for(j=x-area;j<=x+area;j++){ + for( object = MAP_getTopObj(floor,j,i) ; object ;object = NEXT_OBJECT(object ) ){ + o = GET_OBJINDEX(object); + if( OBJECT_getType(o) == OBJTYPE_CHARA ){ + chara_index=OBJECT_getIndex(o); + if( CHAR_getInt( chara_index, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ) continue; + if( chara_index == charaindex ) continue; //找到自己了 + if( ( fd = getfdFromCharaIndex(chara_index) ) != -1 ){ + getnum++; + CONNECT_getCharname( fd, szName, sizeof( szName ) ); //人物名称 + CONNECT_getCdkey( fd, cdkey, sizeof( cdkey )); //帐号 + //CHAR_getChar( chara_index, CHAR_NAME); + snprintf( line, sizeof( line), "第%d个找到[%s]的帐号是[%s]",getnum,szName,cdkey); + CHAR_talkToCli( charaindex, -1,line, CHAR_COLORRED); + print("第%d个找到[%s]的帐号是[%s]\n",getnum,szName,cdkey); + } + } + } + } + } + if(!getnum) CHAR_talkToCli( charaindex, -1, " 围内没有人", CHAR_COLORYELLOW); +} +#endif + +#ifdef _DEF_NEWSEND +void CHAR_CHAT_DEBUG_newsend(int charindex ,char *message) +{ + char buf[256]; + char token[100]; + char szName[256]; + char cdkey[CDKEYLEN]; + char line[256]; + char say[128]; + int fl,x,y,i; + unsigned int MAX_USER=0; + MAX_USER=getFdnum(); + if( strlen(message)==0){ + sprintf(buf,"%s","参数不正确-> FLOOR X Y 无/要说的话"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + easyGetTokenFromString( message , 1 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","参数不正确-->地图编号"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + fl=atoi( token ); + easyGetTokenFromString( message , 2 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","参数不正确-->X座标 "); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + x = atoi( token ); + easyGetTokenFromString( message , 3 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","参数不正确-->Y座标 "); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + y = atoi( token ); + easyGetTokenFromString( message , 4 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","参数不正确-->帐号"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + easyGetTokenFromString( message , 5 , say , sizeof(say)); + + for(i=0;i FLOOR X Y 帐号 格数 无/要说的话"); + CHAR_talkToCli( charaindex, -1,buf, CHAR_COLORWHITE); + return; + } + easyGetTokenFromString( message , 1 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","参数不正确-->地图编号"); + CHAR_talkToCli( charaindex, -1,buf, CHAR_COLORWHITE); + return; + } + tofl=atoi( token ); + easyGetTokenFromString( message , 2 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","参数不正确-->X座标 "); + CHAR_talkToCli( charaindex, -1,buf, CHAR_COLORWHITE); + return; + } + toX = atoi( token ); + easyGetTokenFromString( message , 3 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","参数不正确-->Y座标 "); + CHAR_talkToCli( charaindex, -1,buf, CHAR_COLORWHITE); + return; + } + toY = atoi( token ); + easyGetTokenFromString( message , 4 , cdkeytoken , sizeof(cdkeytoken)); + if( strlen(cdkeytoken)==0){ + sprintf(buf,"%s","参数不正确-->帐号"); + CHAR_talkToCli( charaindex, -1,buf, CHAR_COLORWHITE); + return; + } + easyGetTokenFromString( message , 5 , token, sizeof(token)); + area = atoi( token ); + if( strlen(token)==0 || area <= 0 || area > 3 ){ + sprintf(buf,"%s","参数不正确-->格数(1~3)"); + CHAR_talkToCli( charaindex, -1,buf, CHAR_COLORWHITE); + return; + } + easyGetTokenFromString( message , 6 , say , sizeof(say)); //说话 + + MAX_USER=getFdnum(); + for(k=0;k0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charaindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + CHAR_setWorkInt( i, CHAR_WORKFONTSIZE, atoi( fsize )); + //CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_LV); + sprintf( token, "[GM]%把你的字体设置为%d!", CHAR_getChar( charaindex, CHAR_NAME),(int)atoi(fsize)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "玩家%s的字体设置为%d!", CHAR_getChar( i, CHAR_NAME),(int)atoi(fsize)); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setWorkInt( charaindex, CHAR_WORKFONTSIZE, atoi( fsize )); + sprintf( token, "字体设置为%d!",(int)atoi(fsize)); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + } +} +#endif + +#ifdef _JOBDAILY +void CHAR_CHAT_DEBUG_rejobdaily(int charaindex ,char *message) +{ + print("Reading Jobdaily File..."); + CHAR_talkToCli( charaindex, -1, "重新读取任务日志列表...", CHAR_COLORYELLOW); + if(!LoadJobdailyfile()){ + CHAR_talkToCli( charaindex, -1, "读取失败", CHAR_COLORYELLOW); + print("fail!!\n"); + return; + } + print("done\n"); + CHAR_talkToCli( charaindex, -1, "读取完成", CHAR_COLORYELLOW); +} +#endif + +#ifdef _RACEMAN +extern int asktotal; + +void CHAR_CHAT_DEBUG_changeask(int charaindex, char *message) +{ + char cdkey[64] , free[64] , buf[256] , item[64]; + int i ,toindex=0, Playernum = CHAR_getPlayerMaxNum(); + int itemindex,itemid; + unsigned int askno,asklv,temp; + int petNo,intNo,shift,base; + + easyGetTokenFromString( message , 1 , cdkey , sizeof(cdkey)); + if( strlen(cdkey)==0){ + sprintf(buf,"%s","没有帐号。正确格式:[changeask 帐号 人物名称 宠证id 0/1]"); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + return; + } + easyGetTokenFromString( message , 2 , item, sizeof(item)); + if( strlen(item)==0){ + sprintf(buf,"%s","没有宠证id。正确格式:[changeask 帐号 宠证id 0/1]"); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + return; + } + easyGetTokenFromString( message , 3 , free , sizeof(free)); + if( strlen(free)==0 ){ + sprintf(buf,"%s","最後的参数错误。正确格式:[changeask 帐号 宠证id 0/1]"); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + return; + } + + + for( i=0;i=Playernum){ + sprintf(buf,"%s","找不到这个人,请确认帐号"); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + return; + } + //找道具 + for( i = 0 ; i < CHAR_MAXITEMHAVE ; i++ ) { + itemindex=CHAR_getItemIndex( toindex , i ); + if( ITEM_CHECKINDEX( itemindex) ) { + itemid=ITEM_getInt( itemindex ,ITEM_ID ); + if(itemid==atoi(item)){ //找到猎宠证 + if(atoi(free)==1){ + //设定解过 + petNo = ( CHAR_getInt( toindex , CHAR_CHECKIN ) & 0x7FC00000 ) >> 22 ; + intNo = petNo / 32 ; + shift = petNo % 32 ; + base = 1 << shift; + CHAR_setInt( toindex , CHAR_KINDCNT1 + intNo , CHAR_getInt( toindex , CHAR_KINDCNT1 + intNo ) | base ); + CHAR_setInt( toindex,CHAR_CATCHCNT5,CHAR_getInt( toindex,CHAR_CATCHCNT5 ) +1 ); + } + //给下一题 + if(CHAR_getInt( toindex,CHAR_CATCHCNT5 ) >= asktotal ){ + sprintf( buf,"恭喜你达到猎宠大赛终极目标,祝您抽中大奖"); + }else{ + askno = Raceman_getokask( toindex , rand() % asktotal ); + asklv = asktable[askno].lowlv + rand()%((asktable[askno].highlv+1)-asktable[askno].lowlv); + temp = (askno << 22) & 0x7FC00000; + temp = temp | ((asklv << 14) & 0x003FC000); + temp = temp | ((asktable[askno].bbi - 100000) & 0x00003FFF); + CHAR_setInt( toindex , CHAR_CHECKIN , temp ); + if( asktable[askno].highlv == 0 ) + sprintf( buf,"请抓给我等级%d『以上』的%s好吗。您目前记录%d种", asktable[askno].lowlv , asktable[askno].petname, CHAR_getInt( toindex,CHAR_CATCHCNT5 ) ); + else + sprintf( buf,"请抓给我『只能』等级%d的%s好吗。您目前记录%d种", asklv , asktable[askno].petname, CHAR_getInt( toindex,CHAR_CATCHCNT5 ) ); + } + ITEM_setChar( itemindex, ITEM_EFFECTSTRING, buf); + CHAR_sendItemDataOne( toindex , i ); + break; + } + } + } + if( i >= CHAR_MAXITEMHAVE ){ + sprintf(buf,"%s","找不到猎宠证!"); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + return; + }else{ + sprintf(buf,"%s","设定完成"); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + } +} +#endif + +#ifdef _CREATE_MM_1_2 +void CHAR_CHAT_DEBUG_MM( int charaindex , char *message ) +{ + int ret; + int enemynum; + int enemyid; + int index; + int i,j; + int work[4]={50,50,50,50}; + int LevelUpPoint; + char buf[10]; + char cdkey[CDKEYLEN]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , buf, sizeof(buf)); + index=atoi(buf); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(index==1)enemyid=1479; + else if(index==2)enemyid=2547; + else{ + CHAR_talkToCli( charaindex, -1, "目前只能制作1/2代玛蕾菲雅!", CHAR_COLORYELLOW ); + return;} + + if(strlen(cdkey)>0){ + for(j=0;j=playernum) + { + CHAR_talkToCli( charaindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == enemyid) { + break; + } + } + if( i == enemynum )return; + + ret = ENEMY_createPetFromEnemyIndex( j, i); + if( !CHAR_CHECKINDEX( ret))return; + snprintf( token,sizeof( token), "制作极品%d代玛蕾菲雅成功\!index[%d]",index,ret); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORWHITE); + sprintf( token, "[GM]%s制作了只极品%d代玛蕾菲雅给你!index[%d]", CHAR_getChar( charaindex, CHAR_NAME),index,ret); + CHAR_talkToCli( j, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "给玩家%s制作了只极品%d代玛蕾菲雅!index[%d]", CHAR_getChar( j, CHAR_NAME),index,ret); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + if( CHAR_getCharPet( j, i ) == ret )break; + } + if( i == CHAR_MAXPETHAVE )i = 0; + + if( CHAR_CHECKINDEX( ret ) == TRUE ){ + CHAR_setMaxExpFromLevel( ret, CHAR_getInt( ret, CHAR_LV )); + } + int k; + LevelUpPoint = ( work[3]<< 24) + ( work[0]<< 16) + ( work[1]<< 8) + ( work[2]<< 0); + CHAR_setInt( ret, CHAR_ALLOCPOINT, LevelUpPoint); + for( k = 1; k < 79; k ++ ){ //升级 + if(k%5==0){ + LevelUpPoint = ( work[3]<< 24) + ( work[0]<< 16) + ( work[1]<< 8) + ( work[2]<< 0); + CHAR_setInt( ret, CHAR_ALLOCPOINT, LevelUpPoint); + } + CHAR_PetLevelUp( ret ); + CHAR_PetAddVariableAi( ret, AI_FIX_PETLEVELUP ); + CHAR_setInt( ret, CHAR_LV, CHAR_getInt( ret, CHAR_LV) +1 ); + } + + snprintf( token, sizeof( token ), "K%d", i ); + CHAR_sendStatusString( j, token ); + snprintf( token, sizeof( token ), "W%d", i ); + CHAR_sendStatusString( j, token ); + }else{ + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == enemyid) { + break; + } + } + if( i == enemynum )return; + + ret = ENEMY_createPetFromEnemyIndex(charaindex, i); + if( !CHAR_CHECKINDEX( ret))return; + snprintf( token,sizeof( token), "制作极品%d代玛蕾菲雅成功\!index[%d]",index,ret); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORWHITE); + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + if( CHAR_getCharPet( charaindex, i ) == ret )break; + } + if( i == CHAR_MAXPETHAVE )i = 0; + + if( CHAR_CHECKINDEX( ret ) == TRUE ){ + CHAR_setMaxExpFromLevel( ret, CHAR_getInt( ret, CHAR_LV )); + } + int k; + LevelUpPoint = ( work[3]<< 24) + ( work[0]<< 16) + ( work[1]<< 8) + ( work[2]<< 0); + CHAR_setInt( ret, CHAR_ALLOCPOINT, LevelUpPoint); + for( k = 1; k < 79; k ++ ){ //升级 + if(k%5==0){ + LevelUpPoint = ( work[3]<< 24) + ( work[0]<< 16) + ( work[1]<< 8) + ( work[2]<< 0); + CHAR_setInt( ret, CHAR_ALLOCPOINT, LevelUpPoint); + } + CHAR_PetLevelUp( ret ); + CHAR_PetAddVariableAi( ret, AI_FIX_PETLEVELUP ); + CHAR_setInt( ret, CHAR_LV, CHAR_getInt( ret, CHAR_LV) +1 ); + } + + snprintf( token, sizeof( token ), "K%d", i ); + CHAR_sendStatusString( charaindex, token ); + snprintf( token, sizeof( token ), "W%d", i ); + CHAR_sendStatusString( charaindex, token ); + } +} +#endif + +#ifdef _SendTo +void CHAR_CHAT_DEBUG_Sendto( int charaindex , char *message ) +{ + char cdkey[CDKEYLEN]; + char token[128]; + int i; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charaindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + if(!strcmp(CHAR_getChar(charaindex,CHAR_CDKEY),cdkey)) + { + CHAR_DischargePartyNoMsg( charaindex);//解散团队 + int floor, x, y; + char token[256]; + floor = CHAR_getInt( i, CHAR_FLOOR); + x = CHAR_getInt( i, CHAR_X); + y = CHAR_getInt( i, CHAR_Y); + + CHAR_warpToSpecificPoint( charaindex, floor, x, y ); + sprintf( token, "已传送到玩家%s身边!", CHAR_getChar( i, CHAR_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW ); + return; + } + } +} +#endif + +#ifdef _GM_ITEM +void CHAR_CHAT_DEBUG_GMFUNCTION( int charindex , char *message ) +{ + int i; + char gmtime[4]; + char gmfunction[16]; + char cdkey[CDKEYLEN]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , gmfunction, sizeof(gmfunction)); + easyGetTokenFromString( message , 2 , gmtime, sizeof(gmtime)); + easyGetTokenFromString( message , 3 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + CHAR_setChar( i , CHAR_GMFUNCTION, gmfunction ); + CHAR_setInt( i , CHAR_GMTIME, atoi( gmtime ) ); + sprintf( token, "[GM]%s给你使用%s权限%d次!",CHAR_getChar( charindex, CHAR_NAME), gmfunction, atoi( gmtime )); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "相关使用请查看[help %s]无需GM密码!",CHAR_getChar( charindex, CHAR_GMFUNCTION), gmfunction); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "给玩家%s使用%s权限%d次!", CHAR_getChar( i, CHAR_NAME), gmfunction, atoi( gmtime )); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setChar( charindex , CHAR_GMFUNCTION, gmfunction ); + CHAR_setInt( charindex , CHAR_GMTIME, atoi( gmtime ) ); + sprintf( token, "设置使用%s权限%d次!", gmfunction,atoi( gmtime ), gmfunction); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + } +} +#endif + +#ifdef _GM_RIDE +void CHAR_CHAT_DEBUG_SETRIDE( int charindex , char *message ) +{ + int i,rideindex; + char buf[16]; + char cdkey[CDKEYLEN]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , buf, sizeof(buf)); + rideindex=atoi(buf); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(rideindex<1 || rideindex>12) + { + CHAR_talkToCli( charindex, -1,"骑宠编号必须为1~12", CHAR_COLORRED ); + return; + } + typedef struct{ + char name[16]; + int Code; + }tagNewRideCode; + tagNewRideCode NewRides[12]={ + { "帖拉所伊朵", RIDE_PET0}, + { "玛恩摩洛斯", RIDE_PET1}, + { "朵拉比斯", RIDE_PET2}, + { "拉奇鲁哥", RIDE_PET3}, + { "扬奇洛斯", RIDE_PET4}, + { "卡达鲁卡斯", RIDE_PET5}, + { "卡卡金宝", RIDE_PET6}, + { "格尔格", RIDE_PET7}, + { "左迪洛斯", RIDE_PET8}, + { "巴朵兰恩", RIDE_PET9}, + { "史卡鲁", RIDE_PET10}, + { "罗多克雷", RIDE_PET11} + }; + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + int LRCode = CHAR_getInt( i, CHAR_LOWRIDEPETS); + + LRCode = LRCode|NewRides[rideindex-1].Code; + CHAR_setInt( i, CHAR_LOWRIDEPETS, LRCode); + + sprintf( token, "[GM]%s给你骑乘骑宠%s的资格!",CHAR_getChar( charindex, CHAR_NAME), NewRides[rideindex-1].name); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "给玩家骑乘骑宠%s的资格!", CHAR_getChar( i, CHAR_NAME), NewRides[rideindex-1].name); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + }else{ + int LRCode = CHAR_getInt( charindex, CHAR_LOWRIDEPETS); + LRCode = LRCode|NewRides[rideindex-1].Code; + CHAR_setInt( charindex, CHAR_LOWRIDEPETS, LRCode); + + sprintf( token, "设置骑乘骑宠%s的资格!", NewRides[rideindex-1].name); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + } + CHAR_sendStatusString( charindex, "x"); +} + +void CHAR_CHAT_DEBUG_MVRIDE( int charindex , char *message ) +{ + int i,rideindex; + char buf[16]; + char cdkey[CDKEYLEN]; + char token[128]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , buf, sizeof(buf)); + rideindex=atoi(buf); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(rideindex<1 || rideindex>12) + { + CHAR_talkToCli( charindex, -1,"骑宠编号必须为1~12", CHAR_COLORRED ); + return; + } + typedef struct{ + char name[16]; + int Code; + }tagNewRideCode; + tagNewRideCode NewRides[12]={ + { "帖拉所伊朵", RIDE_PET0}, + { "玛恩摩洛斯", RIDE_PET1}, + { "朵拉比斯", RIDE_PET2}, + { "拉奇鲁哥", RIDE_PET3}, + { "扬奇洛斯", RIDE_PET4}, + { "卡达鲁卡斯", RIDE_PET5}, + { "卡卡金宝", RIDE_PET6}, + { "格尔格", RIDE_PET7}, + { "左迪洛斯", RIDE_PET8}, + { "巴朵兰恩", RIDE_PET9}, + { "史卡鲁", RIDE_PET10}, + { "罗多克雷", RIDE_PET11} + }; + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + int LRCode = CHAR_getInt( i, CHAR_LOWRIDEPETS); + + LRCode = LRCode^NewRides[rideindex-1].Code; + CHAR_setInt( i, CHAR_LOWRIDEPETS, LRCode); + + sprintf( token, "[GM]%移除你骑乘骑宠%s的资格!",CHAR_getChar( charindex, CHAR_NAME), NewRides[rideindex-1].name); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "移除玩家骑乘骑宠%s的资格!!", CHAR_getChar( i, CHAR_NAME), NewRides[rideindex-1].name); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + }else{ + int LRCode = CHAR_getInt( charindex, CHAR_LOWRIDEPETS); + LRCode = LRCode^NewRides[rideindex-1].Code; + CHAR_setInt( charindex, CHAR_LOWRIDEPETS, LRCode); + + sprintf( token, "移除骑乘骑宠%s的资格!", NewRides[rideindex-1].name); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + } + CHAR_sendStatusString( charindex, "x"); +} +#endif + +#ifdef _LOCK_IP +void CHAR_CHAT_DEBUG_LOCK_IP( int charindex , char *message ) +{ + char buf[4]; + int a,b,c,d,locktime; + char token[128]; + getStringFromIndexWithDelim(message,".", 1, buf, sizeof(buf)); + a=atoi(buf); + getStringFromIndexWithDelim(message,".", 2, buf, sizeof(buf)); + b=atoi(buf); + getStringFromIndexWithDelim(message,".", 3, buf, sizeof(buf)); + c=atoi(buf); + getStringFromIndexWithDelim(message,".", 4, buf, sizeof(buf)); + d=atoi(buf); + getStringFromIndexWithDelim(message," ", 2, buf, sizeof(buf)); + locktime=atoi(buf); + if(setLockip(a,b,c,d,locktime)){ + sprintf( token, "添加锁定IP %d.%d.%d.%d 登陆%d 成功!", a,b,c,d,locktime); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + if(!saveLockip()) + CHAR_talkToCli( charindex, -1,"写入文件失败", CHAR_COLORYELLOW ); + }else{ + sprintf( token, "添加锁定IP %d.%d.%d.%d 登陆%d 失败!", a,b,c,d,locktime); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + CHAR_talkToCli( charindex, -1,"最大锁定100个IP", CHAR_COLORYELLOW ); + } +} + +void CHAR_CHAT_DEBUG_DISPLAY_LOCK_IP( int charindex , char *message ) +{ + int i; + char token[64]; + for(i=0;i +#include +#include +#include +#include +#include +#include +#include "common.h" +#include "char.h" +#include "util.h" +#include "buf.h" +#include "npcutil.h" +#include "char_base.h" +#include "object.h" +#include "char_data.h" +#include "handletime.h" +#include "chatmagic.h" +#include "configfile.h" +#include "readmap.h" +#include "map_deal.h" +#include "lssproto_serv.h" +#include "log.h" +#include "battle.h" +#include "pet.h" +#include "enemy.h" +#include "encount.h" +#include "magic_base.h" +#include "magic.h" +#include "pet_skill.h" +#include "pet_event.h" +#include "item_gen.h" +#include "mclient.h" +#include "npc_eventaction.h" +#include "map_warppoint.h" +#include "npc_manorsman.h" +#include "net.h" +#include "saacproto_cli.h" +#include "npc_scheduleman.h" +#include "trade.h" +#include "npccreate.h" +#ifdef _DEATH_CONTEND +#include "deathcontend.h" +#endif + +#ifdef _CHAR_PROFESSION // WON ADD 人物职业 +#include "profession_skill.h" +#endif +#include "char_talk.h" + +// WON ADD 修正族长问题 +#include "family.h" + +#include "petmail.h" + +#ifdef _WON_TEST // WON TEST +#include "unpipc.h" +#endif + +// WON ADD 重新读取ITEMSET.TXT +#include "item.h" +#include "npc_raceman.h" + + +extern tagRidePetTable ridePetTable[146]; +extern int *pWorkAttackPower; +extern time_t initTime; +int *pWorkAttackPower = NULL; + +struct GMINFO gminfo[GMMAXNUM]; + +#define LSGENWORKINGBUFFER 65536*4 + +void CHAR_CHAT_DEBUG_warp( int charindex , char *message ) +{ + char token[100]; + int fl,x,y; + easyGetTokenFromString( message , 1 , token, sizeof(token)); + fl = atoi( token ); + easyGetTokenFromString( message , 2 , token , sizeof(token)); + x = atoi( token ); + easyGetTokenFromString( message , 3 , token , sizeof(token)); + y = atoi( token ); + + CHAR_warpToSpecificPoint(charindex, fl, x, y); + +} + + +void CHAR_CHAT_DEBUG_hp( int charindex , char *message ) +{ + CHAR_setInt( charindex , CHAR_HP,atoi( message ) ); + CHAR_complianceParameter( charindex ); + CHAR_send_P_StatusString( charindex , CHAR_P_STRING_HP); +} +void CHAR_CHAT_DEBUG_setmp( int charindex , char *message ) +{ + int i; + char setmp[15]; + char cdkey[CDKEYLEN]; + char token[255]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , setmp, sizeof(setmp)); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + CHAR_setInt( i , CHAR_MAXMP, atoi( setmp ) ); + CHAR_setInt( i , CHAR_MP, atoi( setmp ) ); + CHAR_complianceParameter( i ); + CHAR_send_P_StatusString( i , CHAR_P_STRING_MP); + sprintf( token, "[GM]%s把你的MP设置为%d!", CHAR_getChar( charindex, CHAR_NAME),(int)atoi(setmp)/100); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "玩家%s的MP的设置为%d!", CHAR_getChar( i, CHAR_NAME),(int)atoi(setmp)/100); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setInt( charindex , CHAR_MAXMP, atoi( setmp ) ); + CHAR_setInt( charindex , CHAR_MP, atoi( setmp ) ); + CHAR_complianceParameter( charindex ); + CHAR_send_P_StatusString( charindex , CHAR_P_STRING_MP); + sprintf( token, "MP设置为%d!",(int)atoi(setmp)/100); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + } +} + +void CHAR_CHAT_DEBUG_mp( int charindex , char *message ) +{ + int Mymp; + CHAR_setInt( charindex , CHAR_MP, atoi( message ) ); + Mymp = CHAR_getWorkInt( charindex , CHAR_WORKMAXMP); + if( Mymp > CHAR_getWorkInt( charindex , CHAR_WORKMAXMP) ) + CHAR_setInt( charindex , CHAR_MP, CHAR_getWorkInt( charindex , CHAR_WORKMAXMP)); + + CHAR_complianceParameter( charindex ); + //CHAR_sendStatusString( charindex , "P"); + CHAR_send_P_StatusString( charindex , CHAR_P_STRING_MP); + +} + +void CHAR_CHAT_DEBUG_str( int charindex , char *message ) +{ + int i; + char str[15]; + char cdkey[CDKEYLEN]; + char token[255]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , str, sizeof(str)); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + CHAR_setInt( i , CHAR_STR,atoi( str ) ); + CHAR_complianceParameter( i ); + //CHAR_sendStatusString( charindex , "P"); + CHAR_send_P_StatusString( i ,CHAR_P_STRING_STR|CHAR_P_STRING_MAXHP|CHAR_P_STRING_ATK); + sprintf( token, "[GM]%s把你的腕力设置为%d!", CHAR_getChar( charindex, CHAR_NAME),(int)atoi(str)/100); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "玩家%s的腕力设置为%d!", CHAR_getChar( i, CHAR_NAME),(int)atoi(str)/100); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setInt( charindex , CHAR_STR,atoi( str ) ); + CHAR_complianceParameter( charindex ); + //CHAR_sendStatusString( charindex , "P"); + CHAR_send_P_StatusString( charindex ,CHAR_P_STRING_STR|CHAR_P_STRING_MAXHP|CHAR_P_STRING_ATK); + sprintf( token, "腕力设置为%d!",(int)atoi(str)/100); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + } +} + +void CHAR_CHAT_DEBUG_tgh( int charindex , char *message ) +{ + int i; + char tgh[15]; + char cdkey[CDKEYLEN]; + char token[255]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , tgh, sizeof(tgh)); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + CHAR_setInt( i , CHAR_TOUGH,atoi( tgh ) ); + CHAR_complianceParameter( i ); + //CHAR_sendStatusString( charindex , "P"); + CHAR_send_P_StatusString( i ,CHAR_P_STRING_TOUGH|CHAR_P_STRING_MAXHP|CHAR_P_STRING_DEF); + sprintf( token, "[GM]%s把你的耐力设置为%d!", CHAR_getChar( charindex, CHAR_NAME),(int)atoi(tgh)/100); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "玩家%s的耐力设置为%d!", CHAR_getChar( i, CHAR_NAME),(int)atoi(tgh)/100); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setInt( charindex , CHAR_TOUGH,atoi( tgh ) ); + CHAR_complianceParameter( charindex ); + //CHAR_sendStatusString( charindex , "P"); + CHAR_send_P_StatusString( charindex ,CHAR_P_STRING_TOUGH|CHAR_P_STRING_MAXHP|CHAR_P_STRING_DEF); + sprintf( token, "耐力设置为%d!",(int)atoi(tgh)/100); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + } +} + +void CHAR_CHAT_DEBUG_dex( int charindex , char *message ) +{ + int i; + char dex[15]; + char cdkey[CDKEYLEN]; + char token[255]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , dex, sizeof(dex)); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + CHAR_setInt( i , CHAR_DEX,atoi( dex ) ); + CHAR_complianceParameter( i ); + //CHAR_sendStatusString( charindex , "P"); + CHAR_send_P_StatusString( i ,CHAR_P_STRING_DEX|CHAR_P_STRING_MAXHP|CHAR_P_STRING_ATK|CHAR_P_STRING_QUICK); + sprintf( token, "[GM]%s把你的敏捷设置为%d!", CHAR_getChar( charindex, CHAR_NAME),(int)atoi(dex)/100); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "玩家%s的敏捷设置为%d!", CHAR_getChar( i, CHAR_NAME),(int)atoi(dex)/100); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setInt( charindex , CHAR_DEX,atoi( dex ) ); + CHAR_complianceParameter( charindex ); + //CHAR_sendStatusString( charindex , "P"); + CHAR_send_P_StatusString( charindex ,CHAR_P_STRING_DEX|CHAR_P_STRING_MAXHP|CHAR_P_STRING_ATK|CHAR_P_STRING_QUICK); + sprintf( token, "敏捷设置为%d!",(int)atoi(dex)/100); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + } +} +void CHAR_CHAT_DEBUG_vital( int charindex , char *message ) +{ + int i; + char vital[15]; + char cdkey[CDKEYLEN]; + char token[255]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , vital, sizeof(vital)); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + CHAR_setInt( i , CHAR_VITAL,atoi( vital ) ); + CHAR_complianceParameter( i ); + //CHAR_sendStatusString( charindex , "P"); + CHAR_send_P_StatusString( i ,CHAR_P_STRING_VITAL|CHAR_P_STRING_MAXHP|CHAR_P_STRING_DEF); + sprintf( token, "[GM]%s把你的体力设置为%d!", CHAR_getChar( charindex, CHAR_NAME),(int)atoi(vital)/100); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "玩家%s的体力设置为%d!", CHAR_getChar( i, CHAR_NAME),(int)atoi(vital)/100); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setInt( charindex , CHAR_VITAL,atoi( vital ) ); + CHAR_complianceParameter( charindex ); + //CHAR_sendStatusString( charindex , "P"); + CHAR_send_P_StatusString( charindex ,CHAR_P_STRING_VITAL|CHAR_P_STRING_MAXHP|CHAR_P_STRING_DEF); + sprintf( token, "体力设置为%d!",(int)atoi(vital)/100); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + } +} +void CHAR_CHAT_DEBUG_luck( int charindex , char *message ) +{ + int i; + char buf[64]; + int luck; + char cdkey[CDKEYLEN]; + char token[255]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , buf, sizeof(buf)); + luck=atoi(buf); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(luck<1)luck=1; + if(luck>5)luck=5; + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + CHAR_setInt( i , CHAR_LUCK,luck); + CHAR_complianceParameter( i ); + //CHAR_sendStatusString( charindex , "P"); + CHAR_send_P_StatusString( i , CHAR_P_STRING_LUCK); + sprintf( token, "[GM]%s把你的运气设置为%d!", CHAR_getChar( charindex, CHAR_NAME),luck); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "玩家%s的运气设置为%d!", CHAR_getChar( i, CHAR_NAME),luck); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setInt( charindex , CHAR_LUCK,luck); + CHAR_complianceParameter( charindex ); + //CHAR_sendStatusString( charindex , "P"); + CHAR_send_P_StatusString( charindex , CHAR_P_STRING_LUCK); + sprintf( token, "运气设置为%d!",luck); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + } +} + +void CHAR_CHAT_DEBUG_gold( int charindex , char *message ) +{ + int i, MaxGold, money; + char cdkey[CDKEYLEN]; + char buf[64]; + char token[255]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , buf, sizeof(buf)); + money = atoi( buf ); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + MaxGold = CHAR_getMaxHaveGold( charindex); + if( money > MaxGold ) + money = MaxGold; + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + CHAR_setInt( i , CHAR_GOLD , money ); + CHAR_complianceParameter( i ); + CHAR_send_P_StatusString( i , CHAR_P_STRING_GOLD); + sprintf( token, "[GM]%s把你的金钱设置为%d!", CHAR_getChar( charindex, CHAR_NAME),money); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "玩家%s的金钱设置为%d!", CHAR_getChar( i, CHAR_NAME),money); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setInt( charindex , CHAR_GOLD , money ); + CHAR_complianceParameter( charindex ); + CHAR_send_P_StatusString( charindex , CHAR_P_STRING_GOLD); + sprintf( token, "金钱设置为%d!",money); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + } +} + +#ifdef _TEST_DROPITEMS +void CHAR_CHAT_DEBUG_dropmypet( int charindex, char *message ) +{ + char buf[256]; + int petID, x, y, floor, objindex, petindex, count=0; + int i, j, k, petarray, cLeve=1; + + if( getStringFromIndexWithDelim( message, " ", 1, buf, sizeof( buf)) == FALSE ) return; + petID = atoi( buf); + if( getStringFromIndexWithDelim( message, " ", 2, buf, sizeof( buf)) != FALSE ){ + cLeve = atoi( buf); + } + + floor = CHAR_getInt( charindex, CHAR_FLOOR); + x = CHAR_getInt( charindex, CHAR_X); + y = CHAR_getInt( charindex, CHAR_Y); + if( getStringFromIndexWithDelim( message, " ", 3, buf, sizeof( buf)) != FALSE ){ + floor = atoi( buf); + } + if( getStringFromIndexWithDelim( message, " ", 4, buf, sizeof( buf)) != FALSE ){ + x = atoi( buf); + } + if( getStringFromIndexWithDelim( message, " ", 5, buf, sizeof( buf)) != FALSE ){ + y = atoi( buf); + } + for( i=(x-3); i<(x+3); i++) { + for( j=(y-3); j<(y+3); j++) { + petarray = ENEMY_getEnemyArrayFromId( petID); + petindex = ENEMY_TEST_createPetIndex( petarray ); + if( !CHAR_CHECKINDEX( petindex) ){ + CHAR_talkToCli( charindex, -1, "err Can't create pet", CHAR_COLORYELLOW); + return; + } + CHAR_complianceParameter( petindex ); + objindex = PET_dropPetAbsolute( petindex, floor, i, j, FALSE ); + if( objindex == -1 ){ + CHAR_talkToCli( charindex, -1, "err Can't Drop", CHAR_COLORYELLOW); + return; + } + for( k = 1; k < cLeve; k ++ ){ //升级 + CHAR_PetLevelUp( petindex ); + CHAR_PetAddVariableAi( petindex, AI_FIX_PETLEVELUP ); + CHAR_setInt( petindex, CHAR_LV, CHAR_getInt( petindex, CHAR_LV) +1 ); + } + CHAR_complianceParameter( petindex ); + CHAR_setInt( petindex , CHAR_HP , CHAR_getWorkInt( petindex , CHAR_WORKMAXHP ) ); + + CHAR_setWorkInt( petindex, CHAR_WORKOBJINDEX, objindex ); + CHAR_setInt( petindex, CHAR_FLOOR, floor); + CHAR_setInt( petindex, CHAR_X, i); + CHAR_setInt( petindex, CHAR_Y, j); + CHAR_sendCToArroundCharacter( objindex); + CHAR_setInt( petindex, CHAR_PUTPETTIME, NowTime.tv_sec); + CHAR_setChar( petindex, CHAR_OWNERCDKEY, "SYSTEM_WAYI" ); + CHAR_setChar( petindex, CHAR_OWNERCHARANAME, "SYSTEM_WAYI" ); + count++; + } + } + sprintf( buf, "总共丢掷 %d只宠物。", count); + CHAR_talkToCli( charindex, -1, buf, CHAR_COLORYELLOW); + + +} + +void CHAR_CHAT_DEBUG_dropmyitem( int charindex, char *message ) +{ + char buf[256]; + int itemID, SitemID, maxflg=0,emptyitemindexinchara, i, j; + int floor, x, y, objindex; + + if( getStringFromIndexWithDelim( message, " ", 1, buf, sizeof( buf)) == FALSE ) return; + SitemID = atoi( buf); + if( getStringFromIndexWithDelim( message, " ", 2, buf, sizeof( buf)) != FALSE ){ + maxflg = atoi( buf); + } + floor = CHAR_getInt( charindex, CHAR_FLOOR); + x = CHAR_getInt( charindex, CHAR_X); + y = CHAR_getInt( charindex, CHAR_Y); + if( getStringFromIndexWithDelim( message, " ", 3, buf, sizeof( buf)) != FALSE ){ + floor = atoi( buf); + } + if( getStringFromIndexWithDelim( message, " ", 4, buf, sizeof( buf)) != FALSE ){ + x = atoi( buf); + } + if( getStringFromIndexWithDelim( message, " ", 5, buf, sizeof( buf)) != FALSE ){ + y = atoi( buf); + } + itemID = SitemID; + + + for( i=(x-3); i<(x+3); i++) { + for( j=(y-3); j<(y+3); j++) { + int ret = 0 , count=0; + int itemindex; + while( count < 10 ){ + count++; + itemindex = ITEM_makeItemAndRegist( itemID ); + if( maxflg == 1 ) itemID++; + if( !ITEM_CHECKINDEX( itemindex)) continue; + break; + } + emptyitemindexinchara = CHAR_findEmptyItemBox( charindex ); + + CHAR_setItemIndex( charindex, emptyitemindexinchara, itemindex ); + ITEM_setWorkInt(itemindex, ITEM_WORKOBJINDEX,-1); + ITEM_setWorkInt(itemindex, ITEM_WORKCHARAINDEX,charindex); + CHAR_sendItemDataOne( charindex, emptyitemindexinchara); + //drop + if( (ret = CHAR_DropItemFXY( charindex, emptyitemindexinchara, + floor, i, j, &objindex )) != 0 ){ + char buf[256]; + sprintf( buf, "错误%d", ret); + CHAR_talkToCli( charindex, -1, buf, CHAR_COLORYELLOW); + } + ITEM_setInt(itemindex,ITEM_PUTTIME,NowTime.tv_sec); + CHAR_sendWatchEvent(objindex,CHAR_ACTSTAND,NULL,0,TRUE); + CHAR_setItemIndex(charindex, emptyitemindexinchara ,-1); + CHAR_sendItemDataOne(charindex, emptyitemindexinchara); + CHAR_sendCToArroundCharacter(CHAR_getWorkInt( charindex, CHAR_WORKOBJINDEX)); + } + } + { + char buf[256]; + sprintf( buf, "最後ID%d", itemID-1); + CHAR_talkToCli( charindex, -1, buf, CHAR_COLORYELLOW); + } +} +#endif + +void CHAR_CHAT_DEBUG_additem( int charindex , char *message ) +{ + + int emptyitemindexinchara, itemindex; + int i; + int num = 0; + int itemid; + char buf[64]; + char msgbuf[128]; + char cdkey[CDKEYLEN]; + easyGetTokenFromString( message , 1 , buf, sizeof(buf)); + itemid = atoi( buf); + easyGetTokenFromString( message , 2 , buf, sizeof(buf)); + num = atoi( buf); + easyGetTokenFromString( message , 3 , cdkey, sizeof(cdkey)); + + if( num <= 0 ) num = 1; + + if(strlen(cdkey)>0){ + int playernum = CHAR_getPlayerMaxNum(); + int j; + for(j=0;j=playernum) + { + CHAR_talkToCli( charindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + for( i = 0; i < num; i ++ ) { + emptyitemindexinchara = CHAR_findEmptyItemBox( j ); + + if( emptyitemindexinchara < 0 ){ + sprintf( msgbuf, "玩家%s物品栏位不足。", CHAR_getChar( j, CHAR_NAME )); + CHAR_talkToCli( charindex, -1, msgbuf, CHAR_COLORYELLOW); + sprintf( msgbuf, "你的%s物品栏位不足。", CHAR_getChar( j, CHAR_NAME )); + CHAR_talkToCli( j, -1, msgbuf, CHAR_COLORYELLOW); + return; + } + + itemindex = ITEM_makeItemAndRegist( itemid ); + + if( itemindex != -1 ){ + CHAR_setItemIndex( j, emptyitemindexinchara, itemindex ); + ITEM_setWorkInt(itemindex, ITEM_WORKOBJINDEX,-1); + ITEM_setWorkInt(itemindex, ITEM_WORKCHARAINDEX,charindex); + CHAR_sendItemDataOne( j, emptyitemindexinchara); + LogItem( + CHAR_getChar( charindex, CHAR_NAME ), + CHAR_getChar( charindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + atoi( message), +#endif + "AddItem(制作道具GM)", + CHAR_getInt( charindex,CHAR_FLOOR), + CHAR_getInt( charindex,CHAR_X ), + CHAR_getInt( charindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + + ); + snprintf( msgbuf, sizeof( msgbuf), "[GM]%s给你制作%s成功\。", + CHAR_getChar( charindex, CHAR_NAME ),ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( j, -1,msgbuf, CHAR_COLORYELLOW); + snprintf( msgbuf, sizeof( msgbuf), "成功为%s制作 %s\。", + CHAR_getChar( j, CHAR_NAME ),ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charindex, -1,msgbuf, CHAR_COLORYELLOW); + }else{ + sprintf( msgbuf, "制作道具失败。" ); + CHAR_talkToCli( charindex, -1,msgbuf, CHAR_COLORYELLOW); + } + } + }else{ + for( i = 0; i < num; i ++ ) { + emptyitemindexinchara = CHAR_findEmptyItemBox( charindex ); + + if( emptyitemindexinchara < 0 ){ + sprintf( msgbuf, "物品栏位不足。" ); + + CHAR_talkToCli( charindex, -1, msgbuf, CHAR_COLORYELLOW); + + return; + } + + itemindex = ITEM_makeItemAndRegist( itemid ); + + if( itemindex != -1 ){ + CHAR_setItemIndex( charindex, emptyitemindexinchara, itemindex ); + ITEM_setWorkInt(itemindex, ITEM_WORKOBJINDEX,-1); + ITEM_setWorkInt(itemindex, ITEM_WORKCHARAINDEX,charindex); + CHAR_sendItemDataOne( charindex, emptyitemindexinchara); + LogItem( + CHAR_getChar( charindex, CHAR_NAME ), + CHAR_getChar( charindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + atoi( message), +#endif + "AddItem(制作道具GM)", + CHAR_getInt( charindex,CHAR_FLOOR), + CHAR_getInt( charindex,CHAR_X ), + CHAR_getInt( charindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + + ); + snprintf( msgbuf, sizeof( msgbuf), "制作%s成功\。", + ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charindex, -1,msgbuf, CHAR_COLORYELLOW); + }else{ + sprintf( msgbuf, "制作道具失败。" ); + CHAR_talkToCli( charindex, -1, msgbuf, CHAR_COLORYELLOW); + } + } + } +} + + +void CHAR_CHAT_DEBUG_metamo( int charindex , char *message ) +{ + char metamoid[7]; + char cdkey[CDKEYLEN]; + char token[255]; + int i=0; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , metamoid, sizeof(metamoid)); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + CHAR_setInt( i , CHAR_BASEIMAGENUMBER , atoi( metamoid ) ); + CHAR_setInt( i , CHAR_BASEBASEIMAGENUMBER , atoi( metamoid ) ); + + CHAR_complianceParameter( i ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( i , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( i , CHAR_P_STRING_BASEBASEIMAGENUMBER); + sprintf( token, "[GM]%s把你的人物形象设置为%d!", CHAR_getChar( charindex, CHAR_NAME),(int)atoi(metamoid)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "玩家%s的人物形象设置为%d!", CHAR_getChar( i, CHAR_NAME),(int)atoi(metamoid)); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setInt( charindex , CHAR_BASEIMAGENUMBER , atoi( metamoid ) ); + CHAR_setInt( charindex , CHAR_BASEBASEIMAGENUMBER , atoi( metamoid ) ); + + CHAR_complianceParameter( charindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( charindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + sprintf( token, "人物形象设置为%d!",(int)atoi(metamoid)); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + } +} + +void CHAR_CHAT_DEBUG_info( int charindex , char *message ) +{ + char line[256]; + int index; + + if( strlen( message) != 0 ) { + index = atoi( message); + } + else { + index = charindex; + } + if( !CHAR_CHECKINDEX( index)) { + CHAR_talkToCli( charindex, -1 , "该index无法使用。" , CHAR_COLORWHITE ); + return; + } + + snprintf( line, sizeof( line), + "name:%s i:%d B:%d BB:%d LV:%d EXP:%d MakeSeq:%d", + CHAR_getChar( index, CHAR_NAME), + charindex, + CHAR_getInt( index, CHAR_BASEIMAGENUMBER ), + CHAR_getInt( index, CHAR_BASEBASEIMAGENUMBER ), + CHAR_getInt( index, CHAR_LV ), + CHAR_getInt( index, CHAR_EXP ), + CHAR_getCharMakeSequenceNumber( index)); + + CHAR_talkToCli( charindex, -1 , line , CHAR_COLORWHITE ); + + snprintf( line, sizeof( line), + "Gold:%d HP:%d MP/MHP:%d/%d" , + CHAR_getInt( index, CHAR_GOLD ), + CHAR_getInt( index, CHAR_HP ), + CHAR_getInt( index, CHAR_MP ), + CHAR_getInt( index, CHAR_MAXMP )); + CHAR_talkToCli( charindex, -1 , line , CHAR_COLORWHITE ); + + + if( CHAR_getInt( index, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){ + snprintf( line, sizeof(line), + "体:%d 力:%d 丈:%d 早:%d 耐:%d 攻:%d 守:%d 敏:%d 忠修:%d 忠变:%.2f 编码:%s", + CHAR_getInt( index, CHAR_VITAL )/100, + CHAR_getInt( index, CHAR_STR )/100, + CHAR_getInt( index, CHAR_TOUGH )/100, + CHAR_getInt( index, CHAR_DEX )/100, + CHAR_getWorkInt( index, CHAR_WORKFIXVITAL ), + CHAR_getWorkInt( index, CHAR_WORKATTACKPOWER ), + CHAR_getWorkInt( index, CHAR_WORKDEFENCEPOWER ),//CHAR_WORKFIXDEX + CHAR_getWorkInt( index, CHAR_WORKQUICK ), + CHAR_getInt( index, CHAR_MODAI ), + CHAR_getInt( index, CHAR_VARIABLEAI ) * 0.01, + CHAR_getChar( index, CHAR_UNIQUECODE) ); + }else{ + snprintf( line, sizeof(line), + "体:%d 力:%d 丈:%d 早:%d 耐:%d 攻:%d 守:%d 魅:%d 运:%d", + CHAR_getInt( index, CHAR_VITAL )/100, + CHAR_getInt( index, CHAR_STR )/100, + CHAR_getInt( index, CHAR_TOUGH )/100, + CHAR_getInt( index, CHAR_DEX )/100, + CHAR_getWorkInt( index, CHAR_WORKFIXVITAL ), + CHAR_getWorkInt( index, CHAR_WORKATTACKPOWER ), + CHAR_getWorkInt( index, CHAR_WORKDEFENCEPOWER ), + CHAR_getWorkInt( index, CHAR_WORKFIXCHARM ), + CHAR_getWorkInt( index, CHAR_WORKFIXLUCK )); + } + CHAR_talkToCli( charindex, -1 , line , CHAR_COLORWHITE ); + + + snprintf( line, sizeof(line), + "土:%d 水:%d 火:%d 风:%d", + CHAR_getWorkInt( index, CHAR_WORKFIXEARTHAT ), + CHAR_getWorkInt( index, CHAR_WORKFIXWATERAT ), + CHAR_getWorkInt( index, CHAR_WORKFIXFIREAT ), + CHAR_getWorkInt( index, CHAR_WORKFIXWINDAT )); + CHAR_talkToCli( charindex, -1 , line , CHAR_COLORWHITE ); + + snprintf( line, sizeof( line), + "Sk Itm:%d ChV:%d Rad:%d" , + CHAR_MAXITEMHAVE, + CHAR_getInt( index, CHAR_CHATVOLUME ), + CHAR_getInt( index, CHAR_RADARSTRENGTH ) ); + CHAR_talkToCli( charindex, -1 , line , CHAR_COLORWHITE ); + + + snprintf( line, sizeof( line), + "Status 毒:%d 麻:%d 默:%d 石:%d 暗:%d 乱:%d" , + CHAR_getInt( index , CHAR_POISON ), + CHAR_getInt( index , CHAR_PARALYSIS ), + CHAR_getInt( index , CHAR_SLEEP ), + CHAR_getInt( index , CHAR_STONE ), + CHAR_getInt( index , CHAR_DRUNK ), + CHAR_getInt( index , CHAR_CONFUSION ) ); + CHAR_talkToCli( charindex, -1 , line , CHAR_COLORWHITE ); + +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + snprintf( line, sizeof( line), +#ifdef _NEW_MANOR_LAW + "TitInd:%d FL:%d X:%d Y:%d DIR:%d FAME:%d MOMENTUM:%d" , +#else + "TitInd:%d FL:%d X:%d Y:%d DIR:%d FAME:%d" , +#endif + CHAR_getInt( index , CHAR_INDEXOFEQTITLE ), + CHAR_getInt( index , CHAR_FLOOR ), + CHAR_getInt( index , CHAR_X ), + CHAR_getInt( index , CHAR_Y ), + CHAR_getInt( index , CHAR_DIR ), + CHAR_getInt( index , CHAR_FAME) +#ifdef _NEW_MANOR_LAW + ,CHAR_getInt( index , CHAR_MOMENTUM) +#endif + ); +#else + snprintf( line, sizeof( line), + "TitInd:%d FL:%d X:%d Y:%d DIR:%d" , + CHAR_getInt( index , CHAR_INDEXOFEQTITLE ), + CHAR_getInt( index , CHAR_FLOOR ), + CHAR_getInt( index , CHAR_X ), + CHAR_getInt( index , CHAR_Y ), + CHAR_getInt( index , CHAR_DIR ) ); +#endif + CHAR_talkToCli( charindex, -1 , line , CHAR_COLORWHITE ); + + + snprintf( line, sizeof( line), + "walk:%d dead:%d ItemMergecnt:%d" , + CHAR_getInt( index , CHAR_WALKCOUNT ) , + CHAR_getInt( index , CHAR_DEADCOUNT ) , + CHAR_getInt( index, CHAR_MERGEITEMCOUNT) + ); + CHAR_talkToCli( charindex, -1 , line , CHAR_COLORWHITE ); + + if( CHAR_getInt( index, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + snprintf( line, sizeof( line), + "petindex [%d][%d][%d][%d][%d] " , + CHAR_getCharPet( index, 0), + CHAR_getCharPet( index, 1), + CHAR_getCharPet( index, 2), + CHAR_getCharPet( index, 3), + CHAR_getCharPet( index, 4)); + } + else { + snprintf( line, sizeof( line), + "PetskillIndex [%d][%d][%d][%d][%d][%d][%d] " , + CHAR_getPetSkill( index, 0), + CHAR_getPetSkill( index, 1), + CHAR_getPetSkill( index, 2), + CHAR_getPetSkill( index, 3), + CHAR_getPetSkill( index, 4), + CHAR_getPetSkill( index, 5), + CHAR_getPetSkill( index, 6)); + } + + CHAR_talkToCli( charindex, -1 , line , CHAR_COLORWHITE ); + if( CHAR_getInt( index, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + snprintf( line, sizeof( line), + "poolpetindex [%d][%d][%d][%d][%d] " , + CHAR_getCharPoolPet( index, 0), + CHAR_getCharPoolPet( index, 1), + CHAR_getCharPoolPet( index, 2), + CHAR_getCharPoolPet( index, 3), + CHAR_getCharPoolPet( index, 4)); + CHAR_talkToCli( charindex, -1 , line , CHAR_COLORWHITE ); + + snprintf( line, sizeof( line), + "poolpetindex [%d][%d][%d][%d][%d] " , + CHAR_getCharPoolPet( index, 5), + CHAR_getCharPoolPet( index, 6), + CHAR_getCharPoolPet( index, 7), + CHAR_getCharPoolPet( index, 8), + CHAR_getCharPoolPet( index, 9)); + CHAR_talkToCli( charindex, -1 , line , CHAR_COLORWHITE ); + } + + snprintf( line, sizeof( line), + "levelup [%d], 累积 %d 赌场积分[%d]" , + CHAR_getInt( index, CHAR_LEVELUPPOINT), + CHAR_getWorkInt( index, CHAR_WORKULTIMATE), + CHAR_getInt( index, CHAR_GAMBLENUM) ); + CHAR_talkToCli( charindex, -1 , line , CHAR_COLORWHITE ); + +} + +void CHAR_CHAT_DEBUG_sysinfo( int charindex , char *message ) +{ + char msg[1024],name[256]; + int i; + time_t new_t; + int dd,hh,mm,ss; + + int items=0 , chars=0, golds=0, nouses=0; + int players=0,pets=0,others=0; + int whichtype= -1; + int objnum = OBJECT_getNum(); + + + int itemnum = ITEM_getITEM_itemnum(); + int itemuse =0; + + makeEscapeString( getGameserverID(), name, sizeof( name)); + sprintf( msg, "GSID:%s GSNAME:%s", getGameserverID(), name); + CHAR_talkToCli( charindex, -1, msg, CHAR_COLORYELLOW); + + + for( i=0 ; i0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charaindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + CHAR_setInt(i,CHAR_LV, atoi( message )); + CHAR_send_P_StatusString( i , CHAR_P_STRING_LV); + sprintf( token, "[GM]%s把你的等级设置为%d!", CHAR_getChar( charaindex, CHAR_NAME),level); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "玩家%s的等级设置为%d!", CHAR_getChar( i, CHAR_NAME),level); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setInt(charaindex,CHAR_LV, atoi( message )); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_LV); + sprintf( token, "等级设置为%d!",level); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + } +} + + +void CHAR_CHAT_DEBUG_exp( int charaindex, char* message ) +{ + int i; + char exp[15]; + char cdkey[CDKEYLEN]; + char token[255]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , exp, sizeof(exp)); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charaindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + CHAR_setMaxExp( i, atoi( exp )); + CHAR_send_P_StatusString( i , CHAR_P_STRING_EXP); + sprintf( token, "[GM]%s把你的经验设置为%d!", CHAR_getChar( charaindex, CHAR_NAME),(int)atoi(exp)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "玩家%s的经验设置为%d!", CHAR_getChar( i, CHAR_NAME),(int)atoi(exp)); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setMaxExp( charaindex, atoi( exp )); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_EXP); + sprintf( token, "经验设置为%d!",(int)atoi(exp)/100); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + } +} + +void CHAR_CHAT_DEBUG_delitem( int charindex , char *message ) +{ + int itemid; + + if( strcmp( message, "all") == 0 ) { + int i; + for( i = CHAR_STARTITEMARRAY; i < CHAR_MAXITEMHAVE; i ++ ) { + itemid = CHAR_getItemIndex(charindex, i); + if( itemid != -1 ) { + { + LogItem( + CHAR_getChar( charindex, CHAR_NAME ), + CHAR_getChar( charindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemid, +#else + ITEM_getInt( itemid, ITEM_ID ), +#endif + "DelItem(删除道具GM)", + CHAR_getInt( charindex,CHAR_FLOOR), + CHAR_getInt( charindex,CHAR_X ), + CHAR_getInt( charindex,CHAR_Y ), + ITEM_getChar( itemid, ITEM_UNIQUECODE), + ITEM_getChar( itemid, ITEM_NAME), + ITEM_getInt( itemid, ITEM_ID) + ); + } + CHAR_DelItem( charindex, i); + } + } + }else { + int equipplace; + equipplace = atoi( message); + if( equipplace < CHAR_STARTITEMARRAY || equipplace > CHAR_MAXITEMHAVE -1 ) { + CHAR_talkToCli( charindex, -1, "号码不正确。", CHAR_COLORWHITE); + return; + } + itemid = CHAR_getItemIndex(charindex, equipplace); + if( itemid == -1 ) return; + { + LogItem( + CHAR_getChar( charindex, CHAR_NAME ), + CHAR_getChar( charindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemid, +#else + ITEM_getInt( itemid, ITEM_ID ), +#endif + "DelItem(删除道具GM)", + CHAR_getInt( charindex,CHAR_FLOOR), + CHAR_getInt( charindex,CHAR_X ), + CHAR_getInt( charindex,CHAR_Y ), + ITEM_getChar( itemid, ITEM_UNIQUECODE), + ITEM_getChar( itemid, ITEM_NAME), + ITEM_getInt( itemid, ITEM_ID) + ); + } + CHAR_DelItem( charindex, equipplace); + } +} + +#ifdef _CHAR_PROFESSION // WON ADD 人物职业 +void CHAR_CHAT_DEBUG_addsk( int charaindex, char* message ) +{ + + CHAR_HaveSkill *pSkil; + int skill, i, j, level=1; + char cdkey[CDKEYLEN]; + char msg1[20], msg2[20]; + int playernum = CHAR_getPlayerMaxNum(); + + getStringFromIndexWithDelim( message, " ", 1, msg1, sizeof( msg1)); + getStringFromIndexWithDelim( message, " ", 2, msg2, sizeof( msg2)); + getStringFromIndexWithDelim( message, " ", 3, cdkey, sizeof( cdkey)); + skill = atoi(msg1); + level = atoi(msg2); + + if( level > 100 ){ + CHAR_talkToCli( charaindex, -1, "等级不正确", CHAR_COLORWHITE); + return; + } + if( level < 1 ) level = 1; + + if(strlen(cdkey)>0){ + for(j=0;j=playernum) + { + CHAR_talkToCli( charaindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + + for( i = 0; i < CHAR_SKILLMAXHAVE; i ++ ){ + int skill_id = -1; + + pSkil = CHAR_getCharHaveSkill( j, i ); + skill_id = SKILL_getInt( &pSkil->skill, SKILL_IDENTITY); + if( skill == skill_id && skill_id != -1 ){ + CHAR_talkToCli(j,-1, "你已经学习过此技能", CHAR_COLORYELLOW); + CHAR_talkToCli(charaindex,-1, "玩家已经学习过此技能", CHAR_COLORYELLOW); + return; + } + + if( pSkil == NULL ) continue; + if( pSkil->use != 0 ) continue; + + break; + } + + if( i >= CHAR_SKILLMAXHAVE ){ + CHAR_talkToCli(j,-1, "技能数量已达上限", CHAR_COLORYELLOW); + CHAR_talkToCli(charaindex,-1, "玩家技能数量已达上限", CHAR_COLORYELLOW); + return; + }else{ + level *= 100; + SKILL_makeSkillData( &pSkil->skill, skill, level); + pSkil->use = TRUE; + } + + CHAR_sendStatusString( j , "S"); + + return;} + else{ + for( i = 0; i < CHAR_SKILLMAXHAVE; i ++ ){ + int skill_id = -1; + + pSkil = CHAR_getCharHaveSkill( charaindex, i ); + skill_id = SKILL_getInt( &pSkil->skill, SKILL_IDENTITY); + if( skill == skill_id && skill_id != -1 ){ + CHAR_talkToCli(charaindex,-1, "你已经学习过此技能", CHAR_COLORYELLOW); + return; + } + + if( pSkil == NULL ) continue; + if( pSkil->use != 0 ) continue; + + break; + } + + if( i >= CHAR_SKILLMAXHAVE ){ + CHAR_talkToCli(charaindex,-1, "技能数量已达上限", CHAR_COLORYELLOW); + return; + }else{ + level *= 100; + SKILL_makeSkillData( &pSkil->skill, skill, level); + pSkil->use = TRUE; + } + + CHAR_sendStatusString( charaindex , "S"); + + return;} +} + +void CHAR_CHAT_DEBUG_delsk( int charaindex, char* message ) +{ + int i; + CHAR_HaveSkill *pSkil; + + if( strcmp( message, "all" ) == 0 ){ +// CHAR_talkToCli( charaindex, -1, "清除所有技能", CHAR_COLORWHITE); + for( i = CHAR_SKILLMAXHAVE-1; i >= 0; i -- ){ + pSkil = CHAR_getCharHaveSkill( charaindex, i ); + if( pSkil == NULL )continue; + if( pSkil->use == 0 )continue; + SKILL_makeSkillData( &pSkil->skill, 0, 0 ); + pSkil->use = 0; + } + } + + for( i = CHAR_SKILLMAXHAVE-1; i >= 0; i -- ){ + pSkil = CHAR_getCharHaveSkill( charaindex, i ); + if( pSkil == NULL )continue; + if( pSkil->use == 0 )continue; + print( "SKILUSE %d\n", pSkil->use ); + break; + } + + if( i < 0 ){ +// CHAR_talkToCli( charaindex, -1, "已无法再削减了。", CHAR_COLORWHITE); + ;; + }else{ + SKILL_makeSkillData( &pSkil->skill, 0, 0 ); + pSkil->use = 0; + } + + CHAR_sendStatusString( charaindex , "S"); +} +#endif + +void CHAR_CHAT_Kusabana( int charaindex, char* message ){ + + int dir, ff, fx, fy; + int tile, obj; + + ff = CHAR_getInt( charaindex, CHAR_FLOOR ); + fx = CHAR_getInt( charaindex, CHAR_X ); + fy = CHAR_getInt( charaindex, CHAR_Y ); + dir = CHAR_getInt( charaindex, CHAR_DIR ); + + fx += CHAR_getDX(dir); + fy += CHAR_getDY(dir); + + if( MAP_getTileAndObjData( ff, fx, fy, &tile, &obj) == FALSE )return; + +#if 0 + { char szBuffer[256]; + snprintf( szBuffer, sizeof( szBuffer ), "TILE = %d, OBJ = %d", + tile, obj ); + CHAR_talkToCli( charaindex, -1, szBuffer, CHAR_COLORWHITE); + } +#else + + if( obj != 0 ){ + CHAR_talkToCli( charaindex, -1, "有零件。", CHAR_COLORWHITE); + return; + } + + if( MAP_walkAbleFromPoint( ff, fx, fy, FALSE ) == FALSE ){ + CHAR_talkToCli( charaindex, -1, "无法走了。", CHAR_COLORWHITE); + return; + } + + MAP_setObjData( ff, fx, fy, 3416, 100 ); + + +#if 1 + { + char *stringdata; + RECT seekr , retr; + seekr.x = fx; + seekr.y = fy; + seekr.width = 1; + seekr.height = 1; + stringdata = MAP_getdataFromRECT(ff,&seekr,&retr); + if( stringdata ){ + + if( CHAR_getInt( charaindex , CHAR_WHICHTYPE ) + == CHAR_TYPEPLAYER ){ + int fd = getfdFromCharaIndex( charaindex ); + lssproto_M_send(fd,ff, + retr.x,retr.y, + retr.x+retr.width,retr.y+retr.height, + stringdata ); + } + } else { + } + } +#endif +#endif + + return ; +} + + +void CHAR_CHAT_Fukuwa( int charaindex, char* message ){ + int dir, ff, fx, fy, objindex, vs_index, vs_fd, stringlen; + OBJECT obj; + char szBuffer[2048]; + + stringlen = strlen( message ); + + if( message[0] == '[' && message[stringlen-1] == ']' ){ + CHAR_talkToCli( charaindex, -1, "语言没有转换。", CHAR_COLORWHITE); + return ; + } + + ff = CHAR_getInt( charaindex, CHAR_FLOOR ); + fx = CHAR_getInt( charaindex, CHAR_X ); + fy = CHAR_getInt( charaindex, CHAR_Y ); + dir = CHAR_getInt( charaindex, CHAR_DIR ); + + fx += CHAR_getDX(dir); + fy += CHAR_getDY(dir); + + stringlen = strlen( message ); + + + snprintf( szBuffer, sizeof( szBuffer ), "P|%s", message ); + + for( obj=MAP_getTopObj( ff, fx, fy ); obj; obj=NEXT_OBJECT(obj) ){ + objindex = GET_OBJINDEX(obj); + if( OBJECT_getType(objindex) != OBJTYPE_CHARA )continue; + vs_index = OBJECT_getIndex(objindex); + vs_fd = getfdFromCharaIndex( vs_index ); + CHAR_Talk( vs_fd, vs_index, + szBuffer, CHAR_COLORWHITE, 3 ); + break; + } + +} + +void CHAR_CHAT_DEBUG_superman( int charaindex, char* message ) +{ +#define CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF 100000 + int i; + char hp[15]; + char cdkey[CDKEYLEN]; + char token[255]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , hp, sizeof(hp)); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charaindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + CHAR_setInt(charaindex,CHAR_SKILLUPPOINT, 32); + CHAR_Skillupsend(charaindex); + CHAR_setInt( charaindex , CHAR_HP, CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF); + CHAR_setInt( charaindex , CHAR_MP,CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF ); + CHAR_setInt( charaindex , CHAR_MAXMP,CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF ); + CHAR_setInt( charaindex , CHAR_STR,CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF ); + CHAR_setInt( charaindex , CHAR_TOUGH,CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF ); + CHAR_setInt( charaindex , CHAR_DEX , CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF ); + CHAR_setInt( charaindex,CHAR_LV, 200); + + CHAR_complianceParameter( charaindex ); + CHAR_sendStatusString( charaindex , "P"); + + sprintf( token, "[GM]%s把你为超人状态!", CHAR_getChar( charaindex, CHAR_NAME)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "玩家%s设置为超人状态!", CHAR_getChar( i, CHAR_NAME)); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setInt(charaindex,CHAR_SKILLUPPOINT, 32); + CHAR_Skillupsend(charaindex); + CHAR_setInt( charaindex , CHAR_HP, CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF); + CHAR_setInt( charaindex , CHAR_MP,CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF ); + CHAR_setInt( charaindex , CHAR_MAXMP,CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF ); + CHAR_setInt( charaindex , CHAR_STR,CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF ); + CHAR_setInt( charaindex , CHAR_TOUGH,CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF ); + CHAR_setInt( charaindex , CHAR_DEX , CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF ); + CHAR_setInt( charaindex,CHAR_LV, 200); + + CHAR_complianceParameter( charaindex ); + CHAR_sendStatusString( charaindex , "P"); + + CHAR_talkToCli( charaindex, -1,"设置超人状态!", CHAR_COLORYELLOW ); + } +#undef CHAT_CHAT_DEBUG_SUPERMAN_PARAMDEF + +} + +void CHAR_CHAT_printcount( int charaindex, char* message ) +{ + char msgbuf[512]; + + snprintf( msgbuf,sizeof( msgbuf), + "你说了 %d 次话,走了 %d 步路,死了 %d 次", + CHAR_getInt( charaindex, CHAR_TALKCOUNT), + CHAR_getInt( charaindex, CHAR_WALKCOUNT), + CHAR_getInt( charaindex, CHAR_DEADCOUNT) + ); + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORWHITE); + +} + +void CHAR_CHAT_DEBUG_battlein( int charaindex, char* message ) +{ + int fd = getfdFromCharaIndex( charaindex ); + if( fd != -1) { + lssproto_EN_recv( fd, + CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y)); + } +} + +void CHAR_CHAT_DEBUG_battleout( int charaindex, char* message ) +{ + + BATTLE_WatchStop( charaindex ); +} + +void CHAR_CHAT_DEBUG_petmake( int charaindex, char* message ) +{ + int ret; + int enemynum; + int enemyid; + int i,j; + int level=-1; + char buf[10]; + char cdkey[CDKEYLEN]; + char token[255]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , buf, sizeof(buf)); + enemyid=atoi(buf); + easyGetTokenFromString( message , 2 , buf, sizeof(buf)); + level=atoi(buf); + easyGetTokenFromString( message , 3 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(j=0;j=playernum) + { + CHAR_talkToCli( charaindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == enemyid) { + break; + } + } + if( i == enemynum )return; + + ret = ENEMY_createPetFromEnemyIndex( j, i); + if( !CHAR_CHECKINDEX( ret))return; + snprintf( token,sizeof( token), "宠物制作成功\!",ret); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORWHITE); + sprintf( token, "[GM]%s制作了只宠物给你!index[%d]", CHAR_getChar( charaindex, CHAR_NAME),ret); + CHAR_talkToCli( j, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "给玩家%s的宠物制作成功!index[%d]", CHAR_getChar( j, CHAR_NAME),ret); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + if( CHAR_getCharPet( j, i ) == ret )break; + } + if( i == CHAR_MAXPETHAVE )i = 0; + + if( CHAR_CHECKINDEX( ret ) == TRUE ){ + CHAR_setMaxExpFromLevel( ret, CHAR_getInt( ret, CHAR_LV )); + } + if( level != -1 ){ + if( level > 200 ) level = 200; + if( level < 0 ) level = 0; + level = level - CHAR_getInt( ret, CHAR_LV ); + if( level > 0 ){ + int k; + for( k = 1; k <= level; k ++ ){ //升级 + CHAR_PetLevelUp( ret ); + CHAR_PetAddVariableAi( ret, AI_FIX_PETLEVELUP ); + CHAR_setInt( ret, CHAR_LV, CHAR_getInt( ret, CHAR_LV) +1 ); + } + } + } + + snprintf( token, sizeof( token ), "K%d", i ); + CHAR_sendStatusString( j, token ); + snprintf( token, sizeof( token ), "W%d", i ); + CHAR_sendStatusString( j, token ); + }else{ + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == enemyid) { + break; + } + } + if( i == enemynum )return; + + ret = ENEMY_createPetFromEnemyIndex(charaindex, i); + if( !CHAR_CHECKINDEX( ret))return; + snprintf( token,sizeof( token), "宠物制作成功\!index[%d]",ret); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORWHITE); + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + if( CHAR_getCharPet( charaindex, i ) == ret )break; + } + if( i == CHAR_MAXPETHAVE )i = 0; + + if( CHAR_CHECKINDEX( ret ) == TRUE ){ + CHAR_setMaxExpFromLevel( ret, CHAR_getInt( ret, CHAR_LV )); + } + if( level != -1 ){ + if( level > 200 ) level = 200; + if( level < 0 ) level = 0; + level = level - CHAR_getInt( ret, CHAR_LV ); + if( level > 0 ){ + int k; + for( k = 1; k <= level; k ++ ){ //升级 + CHAR_PetLevelUp( ret ); + CHAR_PetAddVariableAi( ret, AI_FIX_PETLEVELUP ); + CHAR_setInt( ret, CHAR_LV, CHAR_getInt( ret, CHAR_LV) +1 ); + } + } } + + + snprintf( token, sizeof( token ), "K%d", i ); + CHAR_sendStatusString( charaindex, token ); + snprintf( token, sizeof( token ), "W%d", i ); + CHAR_sendStatusString( charaindex, token ); + } +} + +void CHAR_CHAT_DEBUG_deletepet( int charaindex, char* message ) +{ + int i, pindex; + char category[12]; + int playernum = CHAR_getPlayerMaxNum(); + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + pindex = CHAR_getCharPet( charaindex, i); + if( CHAR_CHECKINDEX( pindex)) { + CHAR_endCharOneArray( pindex ); + CHAR_setCharPet( charaindex, i, -1); + snprintf( category, sizeof( category), "K%d",i); + CHAR_sendStatusString( charaindex, category ); + snprintf( category, sizeof( category), "W%d",i); + CHAR_sendStatusString( charaindex, category ); + } + } + + CHAR_talkToCli( charaindex, -1, "清除身上所有宠物。", CHAR_COLORWHITE); + +} + +#define MAXMESS_LISTNUM 8 +#define ALLRESET (MAXMESS_LISTNUM - 1) + +void CHAR_CHAT_DEBUG_reset( int charaindex, char* message ) +{ + int i; + char mess[MAXMESS_LISTNUM][256]={ "enemy", "encount", "magic", "warppoint", "petskill", "pettalk", "npc", "all"}; + + for( i=0; i= MAXMESS_LISTNUM ){ + CHAR_talkToCli( charaindex, -1, "指令错误", CHAR_COLORRED);//CHAR_COLORYELLOW + return; + } + switch( i){ + case ALLRESET: + case 0: + if( !ENEMYTEMP_reinitEnemy() || !ENEMY_reinitEnemy() ){ + CHAR_talkToCli( charaindex, -1, "重新读取敌人基本资料失败。", CHAR_COLORRED); + return; + } + if( i != ALLRESET ) break; + case 1: + if( !GROUP_reinitGroup() || !ENCOUNT_reinitEncount() ){ + CHAR_talkToCli( charaindex, -1, "重新读取遭遇团队资料失败。", CHAR_COLORRED); + } + if( i != ALLRESET ) break; + case 2: + if( !MAGIC_reinitMagic() || !ATTMAGIC_reinitMagic() ) { + CHAR_talkToCli( charaindex, -1, "重新读取咒术资料失败。", CHAR_COLORRED); + } + if( i != ALLRESET ) break; + case 3: + MAPPOINT_resetMapWarpPoint( 1); + if( !MAPPOINT_loadMapWarpPoint() ){ + CHAR_talkToCli( charaindex, -1, "重新读取跳跃点资料失败。", CHAR_COLORRED); + } + if( i != ALLRESET ) break; + case 4: + if( !PETSKILL_reinitPetskill() ) { + CHAR_talkToCli( charaindex, -1, "重新读取宠物技能资料失败。", CHAR_COLORRED); + } + if( i != ALLRESET ) break; + case 5: + LoadPetTalk(); + if( i != ALLRESET ) break; + break; + case 6: + CHAR_talkToCli( charaindex, -1, "未开放", CHAR_COLORRED); + return; + if( i != ALLRESET ) break; + break; + } + CHAR_talkToCli( charaindex, -1, "重新读取游戏资料。", CHAR_COLORYELLOW); +} + +void CHAR_CHAT_DEBUG_enemyrestart( int charaindex, char* message ) +{ + if( ENEMYTEMP_reinitEnemy()) { + CHAR_talkToCli( charaindex, -1, "再次读取敌人基本资料。", CHAR_COLORWHITE); + }else { + CHAR_talkToCli( charaindex, -1, "再次读取敌人基本资料失败。", CHAR_COLORWHITE); + } + + if( ENEMY_reinitEnemy()) { + CHAR_talkToCli( charaindex, -1, "再次读取敌人资料。", CHAR_COLORWHITE); + }else { + CHAR_talkToCli( charaindex, -1, "再次读取敌人基本资料失败。", CHAR_COLORWHITE); + } + + if( GROUP_reinitGroup()) { + CHAR_talkToCli( charaindex, -1, "再次读取团队资料。", CHAR_COLORWHITE); + }else { + CHAR_talkToCli( charaindex, -1, "再次读取团队资料失败。", CHAR_COLORWHITE); + } + if( ENCOUNT_reinitEncount()) { + CHAR_talkToCli( charaindex, -1, "再次读取遭遇资料。", CHAR_COLORWHITE); + } + else { + CHAR_talkToCli( charaindex, -1, "再次读取遭遇资料失败。", CHAR_COLORWHITE); + } + + if( MAGIC_reinitMagic()) { + CHAR_talkToCli( charaindex, -1, "再次读取咒术资料。", CHAR_COLORWHITE); + } + else { + CHAR_talkToCli( charaindex, -1, "再次读取咒术资料失败。", CHAR_COLORWHITE); + } + +#ifdef __ATTACK_MAGIC + if( ATTMAGIC_reinitMagic() ) + CHAR_talkToCli( charaindex , -1 , "再次读取咒术资料。" , CHAR_COLORWHITE ); + else + CHAR_talkToCli( charaindex , -1 , "再次读取咒术资料失败。" , CHAR_COLORWHITE ); +#endif + if( PETSKILL_reinitPetskill()) { + CHAR_talkToCli( charaindex, -1, "再次读取宠物技能资料。", CHAR_COLORWHITE); + } + else { + CHAR_talkToCli( charaindex, -1, "再次读取宠物技能资料失败。", CHAR_COLORWHITE); + } + + LoadPetTalk(); // Arminius 8.15 pet talk + CHAR_talkToCli( charaindex, -1, "再次读取宠物讲话资料。", CHAR_COLORWHITE); + +} + +void CHAR_CHAT_DEBUG_battlewatch( int charaindex, char* message ) +{ + int fd = getfdFromCharaIndex( charaindex ); + if( fd != -1) { + lssproto_LB_recv( fd, + CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y)); + } +} + +// shan 2001/12/18 Begin 由於改变过多,故将原先的function注掉 +void CHAR_CHAT_DEBUG_eventclean( int charaindex, char* message ) +{ +#ifdef _ADD_NEWEVENT // WON 多增任务旗标 + int event_num = 8; +#else + int event_num = 6; +#endif + + int point; + int shiftbit; + int eventno=0; + char token[1024]; + int array; + int shift; + char token_cdkey[256]="", token_name[256]="", cdkey[CDKEYLEN], token_flag[256]=""; + unsigned int max_user = 0; + BOOL find = FALSE; + BOOL ret1, ret2; + int charaindex_tmp = 0; + int i; + + getStringFromIndexWithDelim( message, " ", 1, token_flag, sizeof( token)); + ret1 = getStringFromIndexWithDelim( message, " ", 2, token_cdkey, sizeof( token_cdkey)); + ret2 = getStringFromIndexWithDelim( message, " ", 3, token_name, sizeof( token_name)); + shiftbit = atoi(token_flag); + eventno = atoi(token_flag); + + if( shiftbit!=-1 && ret1==FALSE && ret2==FALSE ){ + charaindex_tmp = charaindex; + find=TRUE; + }else{ + if( shiftbit==-1 || strlen(token_cdkey)==0 || strlen(token_name)==0 ){ + sprintf( token, "%s", "参数不正确。正确格式:[eventsetend 任务旗标 帐号 人物名称]"); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORWHITE); + return; + } + max_user = getFdnum(); + for( i=0; i=event_num ){ + sprintf( token, "错误!!你所设的任务旗标编号已超过 围(0~%d)。",32*event_num-1); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORWHITE); + return; + } + point = CHAR_getInt( charaindex_tmp, CHAR_ENDEVENT+array); + point = point & ~(1<=event_num ){ + sprintf( token, "错误!!你所设的任务旗标编号已超过 围(0~%d)。",32*event_num-1); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORWHITE); + return; + } + point = CHAR_getInt( charaindex_tmp, CHAR_NOWEVENT+array); + point = point | (1<=event_num ){ + sprintf( token, "错误!!你所设的任务旗标编号已超过 围(0~%d)。",32*event_num-1); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORWHITE); + return; + } + point = CHAR_getInt( charaindex_tmp, CHAR_ENDEVENT+array); + point = point | (1<0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + CHAR_setInt( i , CHAR_DUELPOINT, atoi( dp ) ); + CHAR_send_P_StatusString( i ,CHAR_P_STRING_DUELPOINT ); + sprintf( token, "[GM]%s把你的DP设置为%d!", CHAR_getChar( charindex, CHAR_NAME),(int)atoi(dp)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "玩家%s的DP设置为%d!", CHAR_getChar( i, CHAR_NAME),(int)atoi(dp)); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setInt( charindex , CHAR_DUELPOINT, atoi( dp ) ); + CHAR_send_P_StatusString( charindex ,CHAR_P_STRING_DUELPOINT ); + sprintf( token, "DP设置为%d!",(int)atoi(dp)); + CHAR_talkToCli( charindex, -1,token, CHAR_COLORYELLOW ); + } +} + +#ifdef _EQUIT_ARRANGE +void CHAR_CHAT_DEBUG_arrange( int charindex , char *message ) +{ + CHAR_setWorkInt( charindex, CHAR_WORKFIXARRANGE, atoi( message) ); + CHAR_complianceParameter( charindex ); + CHAR_talkToCli( charindex, -1, "设定挡格", CHAR_COLORYELLOW); +} +#endif + + +#ifdef _EQUIT_SEQUENCE +void CHAR_CHAT_DEBUG_sequence( int charindex , char *message ) +{ + CHAR_setWorkInt( charindex, CHAR_WORKFIXSEQUENCE, atoi( message) ); + CHAR_complianceParameter( charindex ); + CHAR_talkToCli( charindex, -1, "设定顺序", CHAR_COLORYELLOW); +} +#endif + +#define ITEMRESERVESTRING "item" +#define POOLITEMRESERVESTRING "poolitem" + +void CHAR_CHAT_DEBUG_setmerge_main( int charaindex, char* message, int mode ) +{ + int haveitemindex = atoi( message); + int itemindex; + + if( !CHAR_CHECKITEMINDEX( charaindex, haveitemindex) ){ + CHAR_talkToCli( charaindex, -1, "号码很奇怪。", CHAR_COLORWHITE); + return; + } + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX( itemindex)) { + CHAR_talkToCli( charaindex, -1, "该处是否没有任何道具,情报亦很奇怪。", CHAR_COLORWHITE); + return; + } + ITEM_setInt( itemindex, ITEM_MERGEFLG, mode); + + CHAR_talkToCli( charaindex, -1, "宁岳白仿弘及丑综毛仄引仄凶[", CHAR_COLORWHITE); + + CHAR_sendItemDataOne( charaindex, haveitemindex); +} + +void CHAR_CHAT_DEBUG_effect( int charaindex, char* message ) +{ + int floorid=-1, effectid=-1, level=0; + char buf[ 256]; + int i; + int playernum = CHAR_getPlayerMaxNum(); + BOOL flg = FALSE; + + getStringFromIndexWithDelim( message, " ", 1, buf, sizeof( buf)); + if( strcmp( buf, "alloff" ) == 0 ) { + flg = TRUE; + }else { + floorid = atoi( buf); + if( !getStringFromIndexWithDelim( message, " ", 2, buf, sizeof( buf))) { + return; + } + effectid = atoi( buf); + if( !getStringFromIndexWithDelim( message, " ", 3, buf, sizeof( buf))) { + return; + } + level = atoi( buf); + } + for( i = 0 ; i < playernum; i ++) { + if( CHAR_CHECKINDEX( i)) { + if( CHAR_getInt( i, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER){ + if( flg) { + int ef = CHAR_getWorkInt( i, CHAR_WORKEFFECT); + if( ef != 0 ) { + int fd = getfdFromCharaIndex( i); + lssproto_EF_send( fd, 0, 0, ""); + CHAR_setWorkInt( i, CHAR_WORKEFFECT, 0); + } + } + else if( CHAR_getInt( i, CHAR_FLOOR) == floorid ) { + int fd = getfdFromCharaIndex( i); + lssproto_EF_send( fd, effectid, level, ""); + if( level == 0 ) { + CHAR_setWorkInt( i, CHAR_WORKEFFECT, + CHAR_getWorkInt( i, CHAR_WORKEFFECT) & + ~effectid); + } + else { + CHAR_setWorkInt( i, CHAR_WORKEFFECT, + CHAR_getWorkInt( i, CHAR_WORKEFFECT) | + effectid); + } + } + } + } + } +} + +void CHAR_CHAT_DEBUG_setTrans( int charaindex, char *message) +{ + int i; + char setTrans[15]; + char cdkey[CDKEYLEN]; + char token[255]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , setTrans, sizeof(setTrans)); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charaindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + CHAR_setInt(i, CHAR_TRANSEQUATION, 0); + CHAR_setInt(i, CHAR_TRANSMIGRATION, atoi( setTrans )); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( i, CHAR_WORKOBJINDEX )); + sprintf( token, "[GM]%s把你转生设置为%d转!", CHAR_getChar( charaindex, CHAR_NAME),(int)atoi(setTrans)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "玩家%s转生设置为%d转!", CHAR_getChar( i, CHAR_NAME),(int)atoi(setTrans)); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setInt(charaindex, CHAR_TRANSEQUATION, 0); + CHAR_setInt(charaindex, CHAR_TRANSMIGRATION, atoi( setTrans )); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX )); + sprintf( token, "转生设置为%d转!",(int)atoi(setTrans)); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + } +} + +void CHAR_CHAT_DEBUG_shutup(int charindex ,char *message) +{ + char token[100]; + char token1[100]; + char cdkey[CDKEYLEN]; + char buf[256]; + char line[256]; + unsigned int MAX_USER=0,i; + BOOL flg; + easyGetTokenFromString( message , 1 , token, sizeof(token)); + easyGetTokenFromString( message , 2 , token1, sizeof(token1)); + if( strlen(message)==0){ + sprintf(buf,"%s","参数不正确"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORYELLOW); + return; + } + if( strlen(token1)==0){ + sprintf(buf,"%s","参数不正确--> ON OFF"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORYELLOW); + return; + } + flg = isstring1or0( token1); + MAX_USER=getFdnum(); + for(i=0;i= 10 )MOREs = TRUE; + } + } + + memset( token, 0, sizeof(token)); + strcpy( token, "MORE:"); + for( i=0; i= sizeof(token) ){ + CHAR_talkToCli( charindex, -1 , token , CHAR_COLORWHITE); + memset( token, 0, sizeof(token)); + strcpy( token, "MORE:"); + } + strcat( token, temp); + continue; + } + } + sprintf( buf1, "NAME:%s UName:%s CDKey:%s Point:[%d,%d,%d]", + CHAR_getChar( userindex, CHAR_NAME), CHAR_getUseName( userindex), + CHAR_getChar( userindex, CHAR_CDKEY), + CHAR_getInt( userindex, CHAR_FLOOR), CHAR_getInt( userindex, CHAR_X), + CHAR_getInt( userindex, CHAR_Y) ); + CHAR_talkToCli( charindex, -1 , buf1 , colors); + } + if( MOREs == TRUE ){ + CHAR_talkToCli( charindex, -1 , token , CHAR_COLORWHITE); + } +} + +void CHAR_CHAT_DEBUG_waeikick( int charindex, char* message ) +{ + char token[100]; + char cdkey[CDKEYLEN]; + char kcmsg[256],kctalk[256]; + char szName[256]; + char buf[256]; + BOOL find=FALSE; + int i=0; + unsigned int MAX_USER=0; + int fd_charaindex; + if( strlen(message)==0){ + sprintf(buf,"%s","参数不正确-> 帐号"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + easyGetTokenFromString( message , 1 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","参数不正确"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + MAX_USER=getFdnum(); + for(i=0;i 帐号"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + easyGetTokenFromString( message , 1 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","参数不正确"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + MAX_USER=getFdnum(); + for(i=0;i FLOOR X Y 帐号"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + easyGetTokenFromString( message , 1 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","参数不正确-->地图编号"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + fl=atoi( token ); + easyGetTokenFromString( message , 2 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","参数不正确-->X座标 "); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + x = atoi( token ); + easyGetTokenFromString( message , 3 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","参数不正确-->Y座标 "); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + y = atoi( token ); + easyGetTokenFromString( message , 4 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","参数不正确-->帐号"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + for(i=0;i clear/add/send 请用小写"); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORWHITE); + return; + } + easyGetTokenFromString(message, 1, cmd, sizeof(cmd)); + if (strcmp(cmd,"clear")==0) { + FILE *f=fopen(ANNOUNCEFILE,"w"); + + strcpy(buf, "石器时代公告\n"); + fwrite(buf, strlen(buf), 1, f); + fclose(f); + LoadAnnounce(); + CHAR_talkToCli(charaindex, -1, "OK", CHAR_COLORWHITE); + } else if (strcmp(cmd,"add")==0) { + FILE *f; + + easyGetTokenFromString(message, 2, say, sizeof(say)); + if (strlen(say)==0) { + sprintf(buf,"%s","参数不正确"); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORWHITE); + return; + } + + if (!(f=fopen(ANNOUNCEFILE,"a+"))) { + f=fopen(ANNOUNCEFILE,"w"); + strcpy(buf, "石器时代公告\n"); + fwrite(buf, strlen(buf), 1, f); + } + fwrite(say, strlen(say), 1, f); + fwrite("\n", sizeof(char), 1, f); + fclose(f); + LoadAnnounce(); + CHAR_talkToCli(charaindex, -1, "OK", CHAR_COLORWHITE); + } else if (strcmp(cmd,"send")==0) { + int i; + + for (i=0; i clear/add/send (请用小写)"); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORWHITE); + return; + } +} + +void CHAR_CHAT_DEBUG_checklock( int charaindex, char* message ) +{ + char cmd[256]; + if( strlen(message)==0){ + CHAR_talkToCli(charaindex, -1, "参数不正确", CHAR_COLORWHITE); + return; + } + easyGetTokenFromString( message, 1, cmd, sizeof(cmd)); + saacproto_ACLock_send( acfd, cmd, 2, getFdidFromCharaIndex( charaindex)); +} + +void CHAR_CHAT_DEBUG_unlock( int charaindex, char* message ) +{ + char cmd[256]; +#ifdef _WAEI_KICK + int act=1; +#endif + + if( strlen(message)==0){ + CHAR_talkToCli(charaindex, -1, "参数不正确", CHAR_COLORWHITE); + return; + } + easyGetTokenFromString(message, 1, cmd, sizeof(cmd)); +#ifdef _WAEI_KICK + saacproto_ACKick_send( acfd, cmd, getFdidFromCharaIndex( charaindex), act); +#else + saacproto_ACLock_send( acfd, cmd, 3, getFdidFromCharaIndex( charaindex)); +#endif +} + +void CHAR_CHAT_DEBUG_unlockserver( int charaindex, char* message ) +{ + char cmd[256]; + + if( strlen(message)==0){ + CHAR_talkToCli(charaindex, -1, "参数不正确", CHAR_COLORWHITE); + return; + } + easyGetTokenFromString(message, 1, cmd, sizeof(cmd)); + saacproto_ACLock_send( acfd, cmd, 4, getFdidFromCharaIndex( charaindex)); +} + +void CHAR_CHAT_DEBUG_fixfmdata(int charaindex, char *message) +{ + char szCmd[64],szData[64],szFamilyID[8],szID[64]; + int i,index = -1,charindex = -1,iPlayerNum = CHAR_getPlayerMaxNum(); + + if(message == NULL || getStringFromIndexWithDelim(message," ",1,szFamilyID,sizeof(szFamilyID)) == FALSE){ + CHAR_talkToCli(charaindex, -1, "参数不正确 [fixfmdata <家族ID> <帐号(or -1)> ]",CHAR_COLORRED); + return; + } + if(message == NULL || getStringFromIndexWithDelim(message," ",2,szID,sizeof(szID)) == FALSE){ + CHAR_talkToCli(charaindex, -1, "参数不正确 [fixfmdata <家族ID> <帐号(or -1)> ]",CHAR_COLORRED); + return; + } + if(message == NULL || getStringFromIndexWithDelim(message," ",3,szCmd,sizeof(szCmd)) == FALSE){ + CHAR_talkToCli(charaindex, -1, "参数不正确 [fixfmdata <家族ID> <帐号(or -1)> ]",CHAR_COLORRED); + return; + } + if(message == NULL || getStringFromIndexWithDelim(message," ",4,szData,sizeof(szData)) == FALSE){ + CHAR_talkToCli(charaindex, -1, "参数不正确 [fixfmdata <家族ID> <帐号(or -1)> ]",CHAR_COLORRED); + return; + } + index = atoi(szFamilyID); + if(index < 1 || index > 1000){ + CHAR_talkToCli(charaindex,-1,"id 值错误", CHAR_COLORRED); + return; + } + index -= 1; + if(szID[0] != '-' && szID[1] != '1'){ + for(i=0;i id]"); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORWHITE); + return; + } + + easyGetTokenFromString(message, 1, cmd, sizeof(cmd)); + if (strcmp(cmd,"allpeace")==0) { +#ifdef _NEW_MANOR_LAW + struct tm tm1; + + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); +#endif + CHAR_talkToCli(charaindex, -1, "allpeace", CHAR_COLORWHITE); + easyGetTokenFromString(message, 2, cmd, sizeof(cmd)); + manorid=atoi(cmd); + if ((manorid<1)||(manorid>MANORNUM)) { + sprintf(buf,"%s","参数不正确。 id 必须在 1~9 之间。"); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORWHITE); + return; + } + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + for (i=0; iMANORNUM)) { + sprintf(buf,"%s","参数不正确。 id 必须在 1~9 之间。"); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORWHITE); + return; + } + for (i=0; i id]"); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORWHITE); + } +} + +void CHAR_CHAT_DEBUG_shutdown(int charindex , char *message ) +{ + char token[10]; + int iTime; + easyGetTokenFromString( message , 1 , token, sizeof(token)); + iTime = atoi( token ); + lssproto_Shutdown_recv(0, "hogehoge", iTime); +} + +void CHAR_CHAT_DEBUG_watchevent( int charaindex, char* message ) +{ +#ifdef _ADD_NEWEVENT // WON 多增任务旗标 + int event_num = 8; +#else + int event_num = 6; +#endif + + unsigned int max_user = 0; + int charaindex_tmp = 0; + int count = 0, point, ckpoint, i, j; + char token_cdkey[256], token_name[256], cdkey[CDKEYLEN]; + char buf[1024], buf1[64]; + BOOL find = FALSE; + + if( strlen(message)==0 ){ + charaindex_tmp = charaindex; + find=TRUE; + }else{ + getStringFromIndexWithDelim( message, " ", 1, token_cdkey, sizeof( token_cdkey)); + getStringFromIndexWithDelim( message, " ", 2, token_name, sizeof( token_name)); + if( strlen(token_cdkey)==0 || strlen(token_name)==0 ){ + sprintf(buf,"%s","参数不正确。正确格式:[wahctevent 帐号 人物名称]"); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORWHITE); + return; + } + max_user = getFdnum(); + for( i=0; i 4 || level < 1 || level > gminfo[i].level) + { + CHAR_talkToCli( charaindex, -1, "修改失败,无法将此帐号等级修改的比自己等级高!level(1~3)", CHAR_COLORWHITE); + return; + } + for (i = 0; i < GMMAXNUM; i++) + { + if (strcmp(id, gminfo[i].cdkey) == 0) + { + if (gminfo[i].level > charlevel) + { + snprintf(tmpbuf, sizeof(tmpbuf), "修改失败,无法修改等级比自己高的帐号!"); + CHAR_talkToCli(charaindex, -1, tmpbuf, CHAR_COLORWHITE); + return; + } + gminfo[i].level = level; + snprintf(tmpbuf, sizeof(tmpbuf), "修改%s等级为%dOK!", gminfo[i].cdkey, gminfo[i].level); + CHAR_talkToCli(charaindex, -1, tmpbuf, CHAR_COLORWHITE); + changeflag = 1; + break; + } + } + if (changeflag == 0) + { + snprintf(tmpbuf, sizeof(tmpbuf), "GM列表中查无此帐号,修改失败!"); + CHAR_talkToCli(charaindex, -1, tmpbuf, CHAR_COLORWHITE); + } + } +} +#endif + +void CHAR_CHAT_DEBUG_checktrade( int charaindex, char*message ) +{ + if( !strcmp( message, "waei" ) ){ + TRADE_CheckTradeListUser(); + } +} + +void CHAR_CHAT_DEBUG_showtemp( int charaindex, char*message ) +{ +#ifdef _NPC_SEPARATEDATA + if( !CHAR_CHECKINDEX( charaindex) ) return; + if( !strcmp( message, "waei" ) ) + CHAR_showTempInt( charaindex); +#endif +} + +#ifdef _TEST_PETCREATE +int avg_num; +int m_cindex=-1; +typedef struct AllCreatPetMy +{ + char name[128]; + int petId; + int char_lv; + int char_hp; + int char_vital; + int char_str; + int char_tgh; + int char_dex; + int vital; + int str; + int tgh; + int dex; + int fixstr; + int fixtgh; + int fixdex; + int creat_num; +}AllCreatPet; +AllCreatPet AVGCREATPET[380]={ + {"",-1,0,0,0,0,0,0,0,0,0,0,0,0,0,-1}, +}; +void ResetAVGCREATPET() +{ + int i; + for( i=0; i 10000 ) + return; + if( pet_Id1 < 0 || pet_Id2 < 0 || pet_Id1 > pet_Id2 ) + return; + + ResetAVGCREATPET(); + i=0; + for( ID=pet_Id1 ; ID <= pet_Id2; ID++) { + AVGCREATPET[i].petId = ID; + AVGCREATPET[i].char_lv = pet_Lv; + AVGCREATPET[i].creat_num = pet_Num; + AVGCREATPET[i+1].petId = ID; + AVGCREATPET[i+1].char_lv = pet_Lv; + AVGCREATPET[i+1].creat_num = pet_Num; + print(" AVGCREATPET[%d].petId[%d]", i, ID); + i+=2; + if( i > arraysizeof( AVGCREATPET)-1 ) + break; + } + avg_num = pet_Num; + + { + char buf[256]; + sprintf( buf,"CREAT[%d-%d] LV=%d,num=%d ", pet_Id1, pet_Id2, pet_Lv,pet_Num); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + m_cindex = charaindex; + } + return; +} +void DefPetNum( int flg, int petId) +{ + char buf[128]; + AVGCREATPET[flg].char_hp /= avg_num; + AVGCREATPET[flg].char_vital /= avg_num; + AVGCREATPET[flg].char_str /= avg_num; + AVGCREATPET[flg].char_tgh /= avg_num; + AVGCREATPET[flg].char_dex /= avg_num; + AVGCREATPET[flg].vital /= avg_num; + AVGCREATPET[flg].str /= avg_num; + AVGCREATPET[flg].tgh /= avg_num; + AVGCREATPET[flg].dex /= avg_num; + AVGCREATPET[flg].fixstr /= avg_num; + AVGCREATPET[flg].fixtgh /= avg_num; + AVGCREATPET[flg].fixdex /= avg_num; + + AVGCREATPET[flg+1].char_hp /= avg_num; + AVGCREATPET[flg+1].char_vital /= avg_num; + AVGCREATPET[flg+1].char_str /= avg_num; + AVGCREATPET[flg+1].char_tgh /= avg_num; + AVGCREATPET[flg+1].char_dex /= avg_num; + AVGCREATPET[flg+1].vital /= avg_num; + AVGCREATPET[flg+1].str /= avg_num; + AVGCREATPET[flg+1].tgh /= avg_num; + AVGCREATPET[flg+1].dex /= avg_num; + AVGCREATPET[flg+1].fixstr /= avg_num; + AVGCREATPET[flg+1].fixtgh /= avg_num; + AVGCREATPET[flg+1].fixdex /= avg_num; + + sprintf( buf,"%s_%d.log" ,"creatpetlog", petId ); + backupTempLogFile( buf, "creatpetlog" , AVGCREATPET[flg].creat_num ); + + LogCreatPet( + AVGCREATPET[flg].name, + AVGCREATPET[flg].petId , + 1, AVGCREATPET[flg].char_hp, + AVGCREATPET[flg].char_vital, AVGCREATPET[flg].char_str, + AVGCREATPET[flg].char_tgh, AVGCREATPET[flg].char_dex, + AVGCREATPET[flg].vital, AVGCREATPET[flg].str, + AVGCREATPET[flg].fixstr,AVGCREATPET[flg].fixtgh, + AVGCREATPET[flg].tgh, AVGCREATPET[flg].dex, + AVGCREATPET[flg].fixdex, + avg_num, 0, 1 ); + LogCreatPet( + AVGCREATPET[flg+1].name, + AVGCREATPET[flg+1].petId , + AVGCREATPET[flg+1].char_lv, AVGCREATPET[flg+1].char_hp, + AVGCREATPET[flg+1].char_vital, AVGCREATPET[flg+1].char_str, + AVGCREATPET[flg+1].char_tgh, AVGCREATPET[flg+1].char_dex, + AVGCREATPET[flg+1].vital, AVGCREATPET[flg+1].str, + AVGCREATPET[flg+1].fixstr,AVGCREATPET[flg+1].fixtgh, + AVGCREATPET[flg+1].tgh, AVGCREATPET[flg+1].dex, + AVGCREATPET[flg+1].fixdex, + avg_num, 0, 1 ); + +} + +void TEST_CreatPet( ) +{ + int floor=777; + char buf[128]; + int petindex; + int ret,pet_list; + int k,lvup,i,j; + int ID=-1; + int pet_Num=40,struct_num=-1; + int pet_Lv = -1; + + { + if( m_cindex >= 0 ) { + char buf[256]; + sprintf( buf,"CREAT Start !!"); + CHAR_talkToCli( m_cindex, -1, buf, CHAR_COLORYELLOW); + } + } + + if( AVGCREATPET[0].creat_num <= 0 && AVGCREATPET[0].petId < 0 ) { + if( m_cindex >= 0 ) + CHAR_talkToCli( m_cindex, -1, "FAIL !", CHAR_COLORYELLOW); + m_cindex = -1; + return; + }else { + if( m_cindex >= 0 ) + CHAR_talkToCli( m_cindex, -1, "OK !", CHAR_COLORYELLOW); + m_cindex = -1; + } + + for( i=arraysizeof( AVGCREATPET)-2; i>=0; i-=2 ) { //creat_num + if( AVGCREATPET[i].petId >= 0 ) { + if( AVGCREATPET[i].creat_num <= 0 ) { + AVGCREATPET[ i].petId = -1; + AVGCREATPET[i+1].petId = -1; + }else { + ID = AVGCREATPET[i].petId; + struct_num = i; + pet_Lv = AVGCREATPET[i].char_lv; + break; + } + } + } + if( ID < 0 && pet_Lv <= 0 && struct_num <= 0 ) + return; + + pet_list = ENEMY_getEnemyArrayFromId( ID); + if( !ENEMY_CHECKINDEX( pet_list) ){ + AVGCREATPET[ struct_num].petId = -1; + AVGCREATPET[struct_num+1].petId = -1; + AVGCREATPET[struct_num].creat_num = 0; + AVGCREATPET[struct_num+1].creat_num = 0; + return; + } + + //creat宠物 + for( j=0; j < pet_Num; j++ ) { + if( AVGCREATPET[struct_num].creat_num <= 0 ) { + DefPetNum( struct_num, AVGCREATPET[struct_num].petId); + AVGCREATPET[struct_num].petId = -1; + AVGCREATPET[struct_num+1].petId = -1; + AVGCREATPET[struct_num].creat_num = 0; + AVGCREATPET[struct_num+1].creat_num = 0; + //计算 + return; + } + ret = ENEMY_TEST_createPetIndex( pet_list ); + //ret = ENEMY_createPetFromEnemyIndex( charaindex, pet_list); + if( CHAR_CHECKINDEX( ret ) == TRUE ){ + CHAR_setMaxExpFromLevel( ret, pet_Lv); + } + petindex = ret; + //log + CHAR_complianceParameter( petindex ); + lvup = CHAR_getInt( petindex, CHAR_ALLOCPOINT); + LogCreatPet( CHAR_getChar( petindex, CHAR_NAME ), CHAR_getInt( petindex, CHAR_PETID ), + CHAR_getInt( petindex, CHAR_LV ), + CHAR_getInt( petindex, CHAR_HP ), + CHAR_getInt( petindex, CHAR_VITAL), CHAR_getInt( petindex, CHAR_STR), + CHAR_getInt( petindex, CHAR_TOUGH), CHAR_getInt( petindex, CHAR_DEX), + (lvup >> 24 ), ((lvup >> 16)&0xff), ((lvup >> 8)&0xff), (lvup&0xff), + CHAR_getWorkInt(petindex,CHAR_WORKFIXSTR), + CHAR_getWorkInt(petindex,CHAR_WORKFIXTOUGH), + CHAR_getWorkInt(petindex,CHAR_WORKFIXDEX), + lvup, CHAR_getInt( petindex, CHAR_PETRANK ) , 0 ); + + sprintf( buf,"%s", CHAR_getChar( petindex, CHAR_NAME )); + memcpy( AVGCREATPET[struct_num].name, buf, sizeof( AVGCREATPET[struct_num].name) ); + AVGCREATPET[struct_num].creat_num -=1; + //记录 + AVGCREATPET[struct_num].char_hp += CHAR_getInt( petindex, CHAR_HP ); + AVGCREATPET[struct_num].char_vital += CHAR_getInt( petindex, CHAR_VITAL); + AVGCREATPET[struct_num].char_str += CHAR_getInt( petindex, CHAR_STR); + AVGCREATPET[struct_num].char_tgh += CHAR_getInt( petindex, CHAR_TOUGH); + AVGCREATPET[struct_num].char_dex += CHAR_getInt( petindex, CHAR_DEX); + + AVGCREATPET[struct_num].vital += (lvup >> 24 ); + AVGCREATPET[struct_num].str += ((lvup >> 16)&0xff); + AVGCREATPET[struct_num].tgh += ((lvup >> 8)&0xff); + AVGCREATPET[struct_num].dex += (lvup&0xff); + + AVGCREATPET[struct_num].fixstr = CHAR_getWorkInt(petindex,CHAR_WORKFIXSTR); + AVGCREATPET[struct_num].fixtgh = CHAR_getWorkInt(petindex,CHAR_WORKFIXTOUGH); + AVGCREATPET[struct_num].fixdex = CHAR_getWorkInt(petindex,CHAR_WORKFIXDEX); + + CHAR_PetTakeLevelUp( petindex, pet_Lv);//强制宠物升级 + CHAR_setInt( petindex , CHAR_HP , CHAR_getWorkInt( petindex , CHAR_WORKMAXHP ) ); + + //log + lvup = CHAR_getInt( petindex, CHAR_ALLOCPOINT); + LogCreatPet( CHAR_getChar( petindex, CHAR_NAME ), CHAR_getInt( petindex, CHAR_PETID ), + CHAR_getInt( petindex, CHAR_LV ), + CHAR_getInt( petindex, CHAR_HP ), + CHAR_getInt( petindex, CHAR_VITAL), CHAR_getInt( petindex, CHAR_STR), + CHAR_getInt( petindex, CHAR_TOUGH), CHAR_getInt( petindex, CHAR_DEX), + (lvup >> 24 ), ((lvup >> 16)&0xff), ((lvup >> 8)&0xff), (lvup&0xff), + CHAR_getWorkInt(petindex,CHAR_WORKFIXSTR), + CHAR_getWorkInt(petindex,CHAR_WORKFIXTOUGH), + CHAR_getWorkInt(petindex,CHAR_WORKFIXDEX), + lvup, CHAR_getInt( petindex, CHAR_PETRANK ) , 0); + + sprintf( buf,"%s", CHAR_getChar( petindex, CHAR_NAME )); + memcpy( AVGCREATPET[struct_num+1].name, buf, sizeof( AVGCREATPET[struct_num+1].name) ); + AVGCREATPET[struct_num+1].creat_num -=1; + AVGCREATPET[struct_num + 1].char_hp += CHAR_getInt( petindex, CHAR_HP ); + AVGCREATPET[struct_num + 1].char_vital += CHAR_getInt( petindex, CHAR_VITAL); + AVGCREATPET[struct_num + 1].char_str += CHAR_getInt( petindex, CHAR_STR); + AVGCREATPET[struct_num + 1].char_tgh += CHAR_getInt( petindex, CHAR_TOUGH); + AVGCREATPET[struct_num + 1].char_dex += CHAR_getInt( petindex, CHAR_DEX); + + AVGCREATPET[struct_num + 1].vital += (lvup >> 24 ); + AVGCREATPET[struct_num + 1].str += ((lvup >> 16)&0xff); + AVGCREATPET[struct_num + 1].tgh += ((lvup >> 8)&0xff); + AVGCREATPET[struct_num + 1].dex += (lvup&0xff); + + AVGCREATPET[struct_num + 1].fixstr = CHAR_getWorkInt(petindex,CHAR_WORKFIXSTR); + AVGCREATPET[struct_num + 1].fixtgh = CHAR_getWorkInt(petindex,CHAR_WORKFIXTOUGH); + AVGCREATPET[struct_num + 1].fixdex = CHAR_getWorkInt(petindex,CHAR_WORKFIXDEX); + + CHAR_PetTakeDrop( petindex, floor, -1, -1); //强制丢弃宠物 + CHAR_setInt( petindex, CHAR_PUTPETTIME, NowTime.tv_sec); + } + + sprintf( buf,"%s_%d.log" ,"creatpetlog", AVGCREATPET[struct_num].petId ); + backupTempLogFile( buf, "creatpetlog" , AVGCREATPET[struct_num].creat_num); + + for( k=20000; k>=0; k-- ) { + if( CHAR_CHECKINDEX( k ) == FALSE ) + continue; + if( CHAR_getInt ( k, CHAR_WHICHTYPE) != CHAR_TYPEPET ) + continue; + if( CHAR_getInt( k, CHAR_FLOOR ) == 777 ) { + CHAR_CharaDelete( k); + ITEM_endExistItemsOne( k); + } + } +} +#endif +void CHAR_CHAT_DEBUG_cleanfloor( int charaindex, char *message) +{ + char buf[256]; + int floor, objindex, itemnum=0,petnum=0,goldnum=0; + int objmaxnum = OBJECT_getNum(); + + floor = atoi( message); + for( objindex=0; objindex 10000) set_num = 10000; + CHAR_setInt( charaindex, CHAR_GAMBLENUM, set_num); + + sprintf( buf,"个人游乐场积分设为%d点。", CHAR_getInt( charaindex, CHAR_GAMBLENUM)); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + return; +} + +#endif + + +void CHAR_CHAT_DEBUG_petlevelup( int charaindex, char* message ) +{ + int level, petindex, petid, mylevel,i,j,k; + char buf[10]; + char cdkey[CDKEYLEN]; + char token[255]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , buf, sizeof(buf)); + level=atoi(buf); + easyGetTokenFromString( message , 2 , buf, sizeof(buf)); + petid=atoi(buf)-1; + easyGetTokenFromString( message , 3 , cdkey, sizeof(cdkey)); + + if(level > 200 ) level=200; + + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charaindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + petindex = CHAR_getCharPet( i, petid); + if( !CHAR_CHECKINDEX( petindex) ){ + sprintf( token, "玩家%s宠物栏%d上没宠物!", CHAR_getChar( i, CHAR_NAME),petid); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + return; + } + mylevel = CHAR_getInt( petindex, CHAR_LV); + level = level-mylevel; + for( j = 1; j <= level; j ++ ){ //升级 + CHAR_PetLevelUp( petindex ); + CHAR_PetAddVariableAi( petindex, AI_FIX_PETLEVELUP ); + CHAR_setInt( petindex, CHAR_LV, CHAR_getInt( petindex, CHAR_LV) +1 ); + } + CHAR_complianceParameter( petindex ); + CHAR_setInt( petindex , CHAR_HP , CHAR_getWorkInt( petindex , CHAR_WORKMAXHP ) ); + sprintf( token, "[GM]%s把你宠物栏%d的宠物设为%d级!", CHAR_getChar( charaindex, CHAR_NAME), petid, level); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "玩家%s的宠物栏%d的宠物设为%d级!", CHAR_getChar( i, CHAR_NAME), petid, level); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + }else{ + petindex = CHAR_getCharPet( charaindex, petid); + if( !CHAR_CHECKINDEX( petindex) ){ + sprintf( token, "你的宠物栏%d上没宠物!", petid); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + return; + } + mylevel = CHAR_getInt( petindex, CHAR_LV); + level = level-mylevel; + for( j = 1; j <= level; j ++ ){ //升级 + CHAR_PetLevelUp( petindex ); + CHAR_PetAddVariableAi( petindex, AI_FIX_PETLEVELUP ); + CHAR_setInt( petindex, CHAR_LV, CHAR_getInt( petindex, CHAR_LV) +1 ); + } + CHAR_complianceParameter( petindex ); + CHAR_setInt( petindex , CHAR_HP , CHAR_getWorkInt( petindex , CHAR_WORKMAXHP ) ); + sprintf( token, "把宠物栏%d的宠物设为%d级!", petid, level); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + } +} + + +void CHAR_CHAT_DEBUG_engineer( int charindex, char *message) +{ + int MaxGold; + if( !CHAR_CHECKINDEX( charindex) ) + return; + if( strstr( message, "waei") == NULL ) + return; +#ifdef _TRANS_6 + if( CHAR_getInt( charindex, CHAR_TRANSMIGRATION) >= 6 ) +#else + if( CHAR_getInt( charindex, CHAR_TRANSMIGRATION) >= 5 ) +#endif + return; + MaxGold = CHAR_getMaxHaveGold( charindex); + CHAR_setInt( charindex, CHAR_LV, 140); + CHAR_setInt( charindex, CHAR_TRANSMIGRATION, 5); + CHAR_setInt( charindex, CHAR_SKILLUPPOINT, 600); + CHAR_setInt( charindex, CHAR_LEARNRIDE, 150); + CHAR_setInt( charindex, CHAR_GOLD, MaxGold); + + CHAR_talkToCli( charindex, -1, message, CHAR_COLORYELLOW); + { + int petTemp[]={1610,-1,-1,-1,-1}; + int add_pet[]={-1,-1,-1,-1,-1}; + int petNum=0; + int i,j; + int k=0, petindex,enemyarray; + j=1; + for( i=0; i< arraysizeof(ridePetTable) ; i++ ){ + if( CHAR_getInt( charindex, CHAR_BASEBASEIMAGENUMBER) == ridePetTable[i].charNo ){ + petTemp[j]= ridePetTable[i].petId; + j++; + if( j >= arraysizeof( petTemp) ) + break; + } + } + j=0; + for( petNum=0; petNum= arraysizeof( gmset) ) { + CHAR_talkToCli(charindex, -1, "参数不正确", CHAR_COLORYELLOW); + return; + } + act = i; + // WON FIX 5 --> 6 + if( act < 0 || act > 6 ){ + CHAR_talkToCli(charindex, -1, "参数不正确", CHAR_COLORYELLOW); + return; + } + } + saacproto_ACKick_send( acfd, cmd, getFdidFromCharaIndex( charindex), act); +} +#endif + +void CHAR_CHAT_DEBUG_remserver( int charaindex, char *message ) +{ +#ifdef _M_SERVER + if( !CHAR_CHECKINDEX( charaindex) ) + return; + if( strstr( message, "on") != NULL ) { + if (mfd < 0){ + mfd = connectmServer(getmservername(),getmserverport()); + if (mfd != -1){ + initConnectOne(mfd,NULL,0); + CHAR_talkToCli(charaindex, -1, "Connect OK", CHAR_COLORYELLOW); + }else{ + CHAR_talkToCli(charaindex, -1, "Connect FAIL", CHAR_COLORYELLOW); + } + }else { + CHAR_talkToCli(charaindex, -1, "Connect Be LINK", CHAR_COLORYELLOW); + } + }else if( strstr( message, "off") != NULL ){ + if (mfd >= 0){ + CONNECT_endOne_debug(mfd); + close(mfd); + mfd = -1; + CHAR_talkToCli(charaindex, -1, "Connect Be CLOSE", CHAR_COLORYELLOW); + }else { + CHAR_talkToCli(charaindex, -1, "Connect Not Be LINK", CHAR_COLORYELLOW); + } + } +#endif +} +//丧志 +#ifdef _M_SERVER +void CHAR_CHAT_DEBUG_reloadmsip( int charaindex, char *message) +{ + char buf1[256]; + memset( buf1, 0, sizeof( buf1)); + if( getStringFromIndexWithDelim( message, " ", 1, buf1, sizeof( buf1)) == FALSE ) + return; + setmservername( buf1); + if( getStringFromIndexWithDelim( message, " ", 2, buf1, sizeof( buf1)) != FALSE ){ + setmserverport( atoi( buf1)); + } + memset( buf1, 0, sizeof( buf1)); + sprintf( buf1, "MServer IP:%s PORT:%d", getmservername(), getmserverport() ); + CHAR_talkToCli( charaindex, -1, buf1, CHAR_COLORYELLOW); +} +#endif +// WON ADD 当机指令 +void CHAR_CHAT_DEBUG_crash(int charaindex , char *message) +{ + int fd; + + + fd = CHAR_getWorkInt( charaindex, CHAR_WORKFD); + + CHAR_Talk( fd, charaindex, message, 1, 3 ); + +/* + char msg[1]; + printf("\n carsh GMSV !! \n"); + //sprintf( msg, "%s", CHAR_getChar( charaindex, CHAR_NAME ) ); + sprintf( msg, "12345" ); +*/ +} + + +#ifdef _PETSKILL_SETDUCK +void CHAR_CHAT_DEBUG_SetDuck( int charaindex, char *message) +{ + CHAR_setWorkInt( charaindex, CHAR_MYSKILLDUCK, atoi( message)); + CHAR_setWorkInt( charaindex, CHAR_MYSKILLDUCKPOWER, 100 ); +} +#endif + +#ifdef _TYPE_TOXICATION +void CHAR_CHAT_DEBUG_Toxication( int charaindex, char *message) +{ + int fd = getfdFromCharaIndex( charaindex ); + if( strstr( message, "TRUE") != 0){ + CHAR_talkToCli( charaindex, -1, "中毒", CHAR_COLORYELLOW); + setToxication( fd, 1); + }else { + setToxication( fd, 0); + } + +} +#endif + +#ifdef _ACTION_BULLSCR +void CHAR_CHAT_DEBUG_getascore(int charindex, char *message) +{ + int witchi[5] = { -1,CHAR_ABULLSTART, CHAR_ABULLSCORE, CHAR_ABULLTIME, CHAR_ABULLSTARTTIME}; + char witchn[5][256]={"全","参与旗标","活动绩分","战斗累积时间","开始时间"}; + char witchs[5][256]={"all","start","score","btime","stime"}; + int i; + for( i=0; i<5; i++) { + if( strstr( message, witchs[i]) != 0 ){ + char buf[256]; + if( i == 0 ){ + sprintf( buf, "%s:%d %s:%d %s:%d %s:%d。", + witchn[1], CHAR_getInt( charindex, witchi[1]), + witchn[2], CHAR_getInt( charindex, witchi[2]), + witchn[3], CHAR_getInt( charindex, witchi[3]), + witchn[4], CHAR_getInt( charindex, witchi[4])); + }else{ + if( i == 2 ){ + int batime = CHAR_getInt( charindex, witchi[i]); + sprintf( buf, "%s : %d分%d秒。", witchn[i], batime/60, batime%60 ); + }else { + sprintf( buf, "%s : %d。", witchn[i], CHAR_getInt( charindex, witchi[i]) ); + } + } + CHAR_talkToCli( charindex, -1, buf, CHAR_COLORYELLOW); + break; + } + } +} + +void CHAR_CHAT_DEBUG_setascore(int charindex, char *message) +{ + int witchi[3] = {CHAR_ABULLSTART,CHAR_ABULLSCORE,CHAR_ABULLSTARTTIME}; + char witchs[3][256]={"start","score","stime"}; + char buf1[256]; + memset( buf1, 0, sizeof( buf1)); + if( getStringFromIndexWithDelim( message, " ", 1, buf1, sizeof( buf1)) == FALSE ) + return; + if( strstr( buf1, "clean") != 0 ){ + }else { + int i; + for( i=0; i<3; i++) { + if( strstr( buf1, witchs[i]) != 0 ){ + char buf2[256]; + int nums=0; + char witchn[3][256]={"参与旗标","活动绩分","开始时间"}; + if( getStringFromIndexWithDelim( message, " ", 2, buf2, sizeof( buf2)) == FALSE ) + return; + nums = atoi( buf2); + if( i == 2 ) { + sprintf( buf2, "%s设定为提前%d。", witchn[i], nums); + nums = (nums * 24) * (60 * 60); + nums = (int)time( NULL) - nums; + }else{ + sprintf( buf2, "%s设定为%d。", witchn[i], nums); + } + CHAR_setInt( charindex, witchi[i], nums); + CHAR_talkToCli( charindex, -1, buf2, CHAR_COLORYELLOW); + return; + } + } + } +} +#endif + + +#ifdef _CHAR_POOLITEM +void CHAR_CHAT_DEBUG_saveditem(int charaindex, char *message) +{ + if( CHAR_SaveDepotItem( charaindex) == FALSE ){ + CHAR_talkToCli( charaindex, -1, "储存失败!", CHAR_COLORYELLOW); + } +} + +void CHAR_CHAT_DEBUG_insertditem(int charaindex, char *message) +{ + if( CHAR_GetDepotItem( -1, charaindex) == FALSE ){ + CHAR_talkToCli( charaindex, -1, "读取失败!", CHAR_COLORYELLOW); + } +} + +void CHAR_CHAT_DEBUG_ShowMyDepotItems( int charaindex, char *message ) +{ + if( !CHAR_CheckDepotItem( charaindex) ){ + char token[256]; + sprintf( token, "尚未取得仓库。"); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + return; + } + CHAR_ShowMyDepotItems( charaindex); +} + +void CHAR_CHAT_DEBUG_InSideMyDepotItems( int charaindex, char *message ) +{ + int i, j, itemindex, count=0; + char token[256]; + + if( !CHAR_CheckDepotItem( charaindex) ){ + sprintf( token, "尚未取得仓库。"); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + return; + } + + for( i=CHAR_STARTITEMARRAY; i 0 ){ + char buf[256]; + sprintf( buf, "清除%d 置宠物。", delobjnum); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORRED); + } +} + +#ifdef _NEW_PLAYERGOLD +void CHAR_CHAT_DEBUG_acnewplayer(int charaindex, char *message) +{ + char CdKey[256], UserName[256], buf[256]; + int RunType; + + memset( buf, 0, sizeof( buf)); + if( getStringFromIndexWithDelim( message, " ", 1, buf, sizeof( buf)) == FALSE ) + return; + buf[ strlen( buf)+1]=0; + memcpy( CdKey, buf, strlen( buf)+1); + if( getStringFromIndexWithDelim( message, " ", 2, buf, sizeof( buf)) == FALSE ) + return; + buf[ strlen( buf)+1]=0; + memcpy( UserName, buf, strlen( buf)+1); + if( getStringFromIndexWithDelim( message, " ", 3, buf, sizeof( buf)) == FALSE ) + return; + buf[ strlen( buf)+1]=0; + RunType = atoi( buf); + if( RunType < 1 || RunType > 2 ){ + CHAR_talkToCli( charaindex, -1, "参数错误", CHAR_COLORRED); + return; + } + saacproto_ACNEWPlayerList_send( acfd, CdKey, UserName, charaindex, RunType); +} + +void CHAR_CHAT_DEBUG_loadnewplayer( int charaindex, char*message ) +{ + saacproto_LoadNEWPlayer_send( acfd, charaindex, message); +} +#endif + +#ifdef _SEND_EFFECT // WON ADD AC送下雪、下雨等特效 +void CHAR_CHAT_DEBUG_sendeffect( int charaindex, char *message) +{ + int i, j, effect, level; + char buf[256]; + struct tm tm1; + int playernum = CHAR_getPlayerMaxNum(); + int player; + int efnum = 0; + + struct { + int floor; + int effect; + BOOL on; + BOOL off; + } ef[2048]; + + + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + + memset( buf, 0, sizeof( buf)); + + if( getStringFromIndexWithDelim( message, " ", 1, buf, sizeof( buf)) == FALSE ) return; + effect = atoi( buf ); + + if( getStringFromIndexWithDelim( message, " ", 2, buf, sizeof( buf)) == FALSE ) return; + level = atoi( buf ); + + for( i=0; i<=CHAR_effectnum; i++){ + if(CHAR_effect[i].floor){ + CHAR_effect[i].effect = effect; + CHAR_effect[i].level = level; + CHAR_effect[i].sendflg = FALSE; + snprintf( CHAR_effect[i].month , sizeof( CHAR_effect[i].month) , "%d" , tm1.tm_mon+1); + snprintf( CHAR_effect[i].day , sizeof( CHAR_effect[i].day) , "%d" , tm1.tm_mday); + snprintf( CHAR_effect[i].hour , sizeof( CHAR_effect[i].hour) , "%d" , tm1.tm_hour); + snprintf( CHAR_effect[i].min , sizeof( CHAR_effect[i].min) , "%d" , tm1.tm_min); + snprintf( CHAR_effect[i].expire , sizeof( CHAR_effect[i].expire), "300000" ); + }// if + }// for i + + + memset( &ef, 0, sizeof( ef)); + + for( i = 0; i < CHAR_effectnum; i ++){ + if( !CHAR_effect[i].sendflg) { + for( player = 0 ; player < playernum; player ++ ) { + if( !CHAR_CHECKINDEX( player ) ) continue; + if( CHAR_getInt( player, CHAR_FLOOR) == CHAR_effect[i].floor ) { + int fd = getfdFromCharaIndex( player); + lssproto_EF_send( fd, CHAR_effect[i].effect, CHAR_effect[i].level, ""); + if( CHAR_effect[i].level == 0 ) { + CHAR_setWorkInt( player, CHAR_WORKEFFECT, + CHAR_getWorkInt( player, CHAR_WORKEFFECT) & + ~CHAR_effect[i].effect); + }else { + CHAR_setWorkInt( player, CHAR_WORKEFFECT, + CHAR_getWorkInt( player, CHAR_WORKEFFECT) | + CHAR_effect[i].effect); + } + } + } + CHAR_effect[i].sendflg = TRUE; + } + + for( j = 0; j < efnum; j ++ ) { + if( ef[j].floor == CHAR_effect[i].floor && ef[j].effect == CHAR_effect[i].effect) + { + ef[j].on = TRUE; + break; + } + } + if( j == efnum ) { + ef[j].floor = CHAR_effect[i].floor; + ef[j].effect = CHAR_effect[i].effect; + ef[j].on = TRUE; + efnum++; + if( efnum >= arraysizeof( ef)) { + print( "err buffer over %s:%d\n", __FILE__, __LINE__); + efnum --; + } + } + } + + for( i = 0; i < efnum; i ++ ) { + if( ef[i].on == FALSE && ef[i].off == TRUE ) { + for( player = 0 ; player < playernum; player ++ ) { + if( !CHAR_CHECKINDEX( player ) ) continue; + if( CHAR_getInt( player, CHAR_FLOOR) == ef[i].floor ) { + int fd = getfdFromCharaIndex( player); + lssproto_EF_send( fd, 0, 0, ""); + CHAR_setWorkInt( player, CHAR_WORKEFFECT, 0); + } + } + } + } +} +#endif + +void CHAR_CHAT_DEBUG_checktime( int charaindex, char *message) +{ + time_t newsec; + char buf[256]; + char WKday[7][32]={"日","一","二","叁","四","五","六"}; + struct tm *p; + + + newsec = time( NULL); + p = localtime( &newsec); +// newsec = localtime( &newsec); + sprintf( buf, "今天:%d年%d月%d日 %s %d:%d:%d ...newsec:%ld。", + (1900+p->tm_year), (1+p->tm_mon), p->tm_mday, WKday[p->tm_wday], + p->tm_hour, p->tm_min, p->tm_sec, newsec ); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORRED); + //p = (struct tm *)calloc( 1, sizeof( struct tm) ); + //if( p == NULL ) return; + if( getStringFromIndexWithDelim( message, "/", 1, buf, sizeof( buf)) == FALSE ) return; + print("ANDY 1.buf:%s\n", buf); + p->tm_year = atoi( buf)-1900; + if( getStringFromIndexWithDelim( message, "/", 2, buf, sizeof( buf)) == FALSE ) return; + print("ANDY 2.buf:%s\n", buf); + p->tm_mon = atoi( buf)-1; + if( getStringFromIndexWithDelim( message, "/", 3, buf, sizeof( buf)) == FALSE ) return; + print("ANDY 3.buf:%s\n", buf); + p->tm_mday = atoi( buf); + if( getStringFromIndexWithDelim( message, "/", 4, buf, sizeof( buf)) == FALSE ) return; + p->tm_wday = atoi( buf); + if( p->tm_wday < 0 || p->tm_wday >= 7 ) p->tm_wday = 0; + if( getStringFromIndexWithDelim( message, "/", 5, buf, sizeof( buf)) == FALSE ) return; + p->tm_hour = atoi( buf); + if( getStringFromIndexWithDelim( message, "/", 6, buf, sizeof( buf)) == FALSE ) return; + p->tm_min = atoi( buf); + if( getStringFromIndexWithDelim( message, "/", 7, buf, sizeof( buf)) == FALSE ) return; + p->tm_sec = atoi( buf); + + newsec = mktime( p); + sprintf( buf, "确认1:%d年%d月%d日 %s %d:%d:%d ...newsec:%ld。", + (1900+p->tm_year), (1+p->tm_mon), p->tm_mday, WKday[p->tm_wday], + p->tm_hour, p->tm_min, p->tm_sec, newsec ); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORRED); + + p = localtime( &newsec); + sprintf( buf, "确认2:%d年%d月%d日 %s %d:%d:%d ...newsec:%ld..time:%d。", + (1900+p->tm_year), (1+p->tm_mon), p->tm_mday, WKday[p->tm_wday], + p->tm_hour, p->tm_min, p->tm_sec, newsec, (int)time(NULL)); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORRED); +} + + + +#ifdef _ACTION_GMQUE +void CHAR_CHAT_DEBUG_cleanqute( int charaindex, char *message) +{ + char cdkey[256], name[256]; + int i; + int playernum = CHAR_getPlayerMaxNum(); + + memset( cdkey, 0, sizeof( cdkey) ); + memset( name, 0, sizeof( name) ); + + if( getStringFromIndexWithDelim( message, " ", 1, cdkey, sizeof( cdkey)) == FALSE ) return; + if( getStringFromIndexWithDelim( message, " ", 2, name, sizeof( name)) == FALSE ) return; + + for( i=0; i 0){ + int i,pclass = CHAR_getInt(charaindex,PROFESSION_CLASS) - 1; + for(i=0;i 0 ){ + array = PROFESSION_SKILL_getskillArray( skillid ); + memset(token, 0, sizeof(token)); + sprintf( token, "P%d(%s) ", i+1, PROFESSION_SKILL_getChar(array, PROFESSION_SKILL_NAME) ); + if( strcmp(token, "") != 0) + strcat( msg, token ); + } + } + CHAR_talkToCli( charaindex, -1, msg, CHAR_COLORRED); + } + + + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + +} +#endif + +void CHAR_CHAT_DEBUG_samecode( int charaindex, char *message) +{ + char buf1[256], buf2[256]; + char cmd[3][256]={ + "pet", "item", "set" + }; + int type=-1, j, total = 0; + BOOL checkn = FALSE; + int MAXPLAYER = CHAR_getPlayerMaxNum(); + int MAXITEM = ITEM_getITEM_itemnum(); + int MAXPET = CHAR_getPetMaxNum(); + + if( getStringFromIndexWithDelim( message, " ", 1, buf1, sizeof( buf1) ) == FALSE )return; + for( j=0; j<3; j++){ + if( strstr( buf1, cmd[j]) != NULL ){ + type = j; + break; + } + } + if( j >= 3 ){ + CHAR_talkToCli( charaindex, -1, "参数错误!", CHAR_COLORRED); + return; + } + + switch( type){ + case 0: + if( getStringFromIndexWithDelim( message, " ", 2, buf1, sizeof( buf1) ) == TRUE ){ + checkn = TRUE; + } + for( j=MAXPLAYER; j 帐号 分钟"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + //flg = isstring1or0( token1); + minu = atoi( token1 ); + MAX_USER=getFdnum(); + for(i=0;i--token=%s",token); + if(strcmp(token,cdkey)==0){ + int index = CONNECT_getCharaindex( i ); + //print("\n--find-->cdkey %s",cdkey); + + //CONNECT_set_shutup(i,TRUE); + + // Robin + CHAR_setInt(index,CHAR_SILENT, minu*60); + //CHAR_setInt(index,CHAR_SILENT, (int)NowTime.tv_sec +(minu*60) ); + { + CHAR_setWorkInt( index, CHAR_WORKLOGINTIME, (int)NowTime.tv_sec); + } + //print(" set_silent:%s:%dmin ", cdkey, minu); + + //print("\n= 220 ){ + CHAR_talkToCli( charindex, -1, token, CHAR_COLORYELLOW); + strcpy( token, "可用GM指令:"); + } + strcat( token, buf2); + continue; + }else{ + if( strstr( buf1, buf) != NULL || + strstr( buf2, buf) != NULL ){ + sprintf( token, "GM指令:[%s %s]", buf1, buf2); + CHAR_talkToCli( charindex, -1, token, CHAR_COLORYELLOW); + } + continue; + } + } + if( type == 1 ) + CHAR_talkToCli( charindex, -1, token, CHAR_COLORYELLOW); +} + +#ifdef _GM_IDENTIFY +void CHAR_CHAR_DEBUG_gmidentify( int charaindex, char* message ) +{ + int i; + int MAX_USER=getFdnum(); //玩家数量 + CHAR_setChar(charaindex, CHAR_GMIDENTIFY, message); //设定gm字串 + CHAR_sendCToArroundCharacter(CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX )); //传送给周围的人 + //for(i=0;i= iPlayerNum){ + CHAR_talkToCli(charaindex,-1,"找不到这名玩家",CHAR_COLORYELLOW); + return; + } + CHAR_setInt(i,CHAR_MOMENTUM,id); + sprintf(szMsg,"目前气势值: %d",CHAR_getInt(i,CHAR_MOMENTUM)/100); + CHAR_talkToCli(charaindex,-1,szMsg,CHAR_COLORYELLOW); + sprintf(buf,"%d",id); + fd = getfdFromCharaIndex(i); + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(i,CHAR_FMNAME),CHAR_getInt(i,CHAR_FMINDEX),CHAR_getWorkInt(i,CHAR_WORKFMINDEXI), + FM_FIX_FMMOMENTUM,buf,"",CHAR_getWorkInt(i,CHAR_WORKFMCHARINDEX),CONNECT_getFdid(fd)); + return; +} + +void CHAR_CHAT_DEBUG_set_manor_owner( int charindex, char* message ) +{ + int i,index = -1,iUseFlag; + char szId[8],szUseFlag[2],szFamilyNameOrID[64],szToken[4096],szFamilyIndex[8],szGetFamilyName[64]; + + if(message == NULL || getStringFromIndexWithDelim(message," ",1,szId,sizeof(szId)) == FALSE){ + CHAR_talkToCli(charindex,-1, "参数不正确 [set_manor_owner 庄园id(1~9) 使用旗标(0:名称 1:id) 家族名称或id]", CHAR_COLORRED); + return; + } + if(atoi(szId) < 1 || atoi(szId) > MANORNUM){ + CHAR_talkToCli(charindex,-1, "庄园ID值不正确(1~9)", CHAR_COLORRED); + return; + } + if(getStringFromIndexWithDelim(message," ",2,szUseFlag,sizeof(szUseFlag)) == FALSE){ + CHAR_talkToCli(charindex,-1, "参数不正确 [set_manor_owner 庄园id(1~9) 使用旗标(0:名称 1:id) 家族名称或id]", CHAR_COLORRED); + return; + } + iUseFlag = atoi(szUseFlag); + if(iUseFlag < 0 || iUseFlag > 1){ + CHAR_talkToCli(charindex,-1, "使用旗标值不正确(0:名称 1:id)", CHAR_COLORRED); + return; + } + if(getStringFromIndexWithDelim(message," ",3,szFamilyNameOrID,sizeof(szFamilyNameOrID)) == FALSE){ + CHAR_talkToCli(charindex,-1, "参数不正确 [set_manor_owner 庄园id(1~9) 使用旗标(0:名称 1:id) 家族名称或id]", CHAR_COLORRED); + return; + } + if(iUseFlag == 1){ + // 检查是否都是数字 + for(i=0;i '9' || szFamilyNameOrID < '0'){ + CHAR_talkToCli(charindex,-1, "家族id格式错误", CHAR_COLORRED); + return; + } + } + for(i=0;;i++){ + if(getStringFromIndexWithDelim(familyListBuf,"|",i,szToken,sizeof(szToken))){ + if((getStringFromIndexWithDelim(szToken," ",1,szFamilyIndex,sizeof(szFamilyIndex))) && + (getStringFromIndexWithDelim(szToken," ",2,szGetFamilyName,sizeof(szGetFamilyName)))){ + if(strcmp(szFamilyNameOrID,szFamilyIndex) == 0){ + index = atoi(szFamilyIndex) - 1; + break; + } + } + } + else break; + } + if(index == -1){ + CHAR_talkToCli(charindex,-1,"找不到此家族资料", CHAR_COLORRED); + return; + } + sprintf(szToken,"庄园 %s 设定给 %s 家族",szId,szGetFamilyName); + saacproto_ACFixFMPoint_send(acfd,szGetFamilyName,index+1,index,szGetFamilyName,index+1,index,atoi(szId)); + } + else{ + for(i=0;;i++){ + if(getStringFromIndexWithDelim(familyListBuf,"|",i,szToken,sizeof(szToken))){ + if((getStringFromIndexWithDelim(szToken," ",1,szFamilyIndex,sizeof(szFamilyIndex))) && + (getStringFromIndexWithDelim(szToken," ",2,szGetFamilyName,sizeof(szGetFamilyName)))){ + if(strcmp(szFamilyNameOrID,szGetFamilyName) == 0){ + index = atoi(szFamilyIndex) - 1; + break; + } + } + } + else break; + } + + if(index == -1){ + CHAR_talkToCli(charindex,-1,"找不到此家族资料", CHAR_COLORRED); + return; + } + sprintf(szToken,"庄园 %s 设定给 %s 家族",szId,szFamilyNameOrID); + saacproto_ACFixFMPoint_send(acfd,szFamilyNameOrID,index+1,index,szFamilyNameOrID,index+1,index,atoi(szId)); + } + CHAR_talkToCli(charindex,-1,szToken,CHAR_COLORRED); +} + +void CHAR_CHAT_DEBUG_set_schedule_time( int charindex, char* message ) +{ + struct tm tm1; + int i,char_max = CHAR_getCharNum(); + char szId[8],szTime[12],szMsg[128]; + + if(message == NULL || getStringFromIndexWithDelim(message," ",1,szId,sizeof(szId)) == FALSE){ + CHAR_talkToCli(charindex,-1, "参数不正确 [set_schedule_time 庄园id(1~9) 时间(分)]", CHAR_COLORRED); + return; + } + if(atoi(szId) < 1 || atoi(szId) > MANORNUM){ + CHAR_talkToCli(charindex,-1, "庄园ID值不正确", CHAR_COLORRED); + return; + } + if(getStringFromIndexWithDelim(message," ",2,szTime,sizeof(szTime)) == FALSE){ + CHAR_talkToCli(charindex,-1, "参数不正确 [set_schedule_time 庄园id(1~9) 时间(分)]", CHAR_COLORRED); + return; + } + for(i=0;i=MAXMISSIONTABLE) { + CHAR_talkToCli( charindex, -1, "编号不正确", CHAR_COLORYELLOW); + return; + } + if( missiontable[mindex].flag == MISSION_NONE ) { + CHAR_talkToCli( charindex, -1, "无此资料", CHAR_COLORYELLOW); + return; + } + + saacproto_ACMissionTable_send( acfd, mindex, 3, "", ""); + + sprintf( msg, " GM指令 清除任务资料 i:%d 使者:%s 勇者:%s m:%d flg:%d time:%d lt:%d ", + mindex, missiontable[mindex].angelinfo, missiontable[mindex].heroinfo, + missiontable[mindex].mission, missiontable[mindex].flag, + missiontable[mindex].time, missiontable[mindex].limittime ); + CHAR_talkToCli( charindex, -1, msg, CHAR_COLORYELLOW); + LogAngel( msg); +} + +void CHAR_CHAT_DEBUG_angelcreate(int charindex ,char *message) // 制造使者与勇者配对 +{ + char angelid[256], heroid[256], msg[1024], buf[256]; + int i, clean =FALSE; + int MAXCHARA=0; + int angelindex =-1, heroindex =-1, mission =-1; + + if( getStringFromIndexWithDelim( message, " ", 1, angelid, sizeof(angelid) ) == FALSE ){ + CHAR_talkToCli( charindex, -1, "参数不正确 [angelcreate 使者帐号 勇者帐号 任务编号]", CHAR_COLORRED); + return; + } + if( getStringFromIndexWithDelim( message, " ", 2, heroid, sizeof(heroid) ) == FALSE ){ + CHAR_talkToCli( charindex, -1, "参数不正确 [angelcreate 使者帐号 勇者帐号 任务编号]", CHAR_COLORRED); + return; + } + if( getStringFromIndexWithDelim( message, " ", 3, buf, sizeof(buf) ) == FALSE ){ + CHAR_talkToCli( charindex, -1, "参数不正确 [angelcreate 使者帐号 勇者帐号 任务编号]", CHAR_COLORRED); + return; + } + mission = atoi( buf); + //if( mission <= 0 || mission >= MAXMISSION || missionlist[mission].id <= 0) { + if( mission >= MAXMISSION ) { + CHAR_talkToCli( charindex, -1, "任务编号不正确", CHAR_COLORRED); + return; + } + + MAXCHARA = CHAR_getPlayerMaxNum(); + for( i=0; i= Playernum ){ + sprintf(buf,"%s\n","失败!查无此帐号。"); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORRED); + }else{ + if(!CHAR_getInt( i , CHAR_FMTIMELIMIT )){ + sprintf(buf,"%s\n","设定完成。"); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORYELLOW); + } + } +} +#endif + +#ifdef _DEF_GETYOU +void CHAR_CHAT_DEBUG_getyou(int charaindex,char *message) +{ + int floor,x,y,i,j,fd,area; + char cdkey[CDKEYLEN],areabuf[5]; + char szName[256],buf[256]; + OBJECT object; + char line[256]; + int o,chara_index; + int getnum = 0; + + getStringFromIndexWithDelim( message, " ", 1, areabuf , sizeof( areabuf )); + area = atoi(areabuf); + if( area <= 0 || area > 3 ){ + sprintf(buf,"%s","没有输入 围或 围超出限制,请输入1~3"); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + return; + } + floor=CHAR_getInt( charaindex, CHAR_FLOOR ); + x=CHAR_getInt( charaindex, CHAR_X ); + y=CHAR_getInt( charaindex, CHAR_Y ); + for(i=y-area;i<=y+area;i++){ + for(j=x-area;j<=x+area;j++){ + for( object = MAP_getTopObj(floor,j,i) ; object ;object = NEXT_OBJECT(object ) ){ + o = GET_OBJINDEX(object); + if( OBJECT_getType(o) == OBJTYPE_CHARA ){ + chara_index=OBJECT_getIndex(o); + if( CHAR_getInt( chara_index, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ) continue; + if( chara_index == charaindex ) continue; //找到自己了 + if( ( fd = getfdFromCharaIndex(chara_index) ) != -1 ){ + getnum++; + CONNECT_getCharname( fd, szName, sizeof( szName ) ); //人物名称 + CONNECT_getCdkey( fd, cdkey, sizeof( cdkey )); //帐号 + //CHAR_getChar( chara_index, CHAR_NAME); + snprintf( line, sizeof( line), "第%d个找到[%s]的帐号是[%s]",getnum,szName,cdkey); + CHAR_talkToCli( charaindex, -1,line, CHAR_COLORRED); + print("第%d个找到[%s]的帐号是[%s]\n",getnum,szName,cdkey); + } + } + } + } + } + if(!getnum) CHAR_talkToCli( charaindex, -1, " 围内没有人", CHAR_COLORYELLOW); +} +#endif + +#ifdef _DEF_NEWSEND +void CHAR_CHAT_DEBUG_newsend(int charindex ,char *message) +{ + char buf[256]; + char token[100]; + char szName[256]; + char cdkey[CDKEYLEN]; + char line[256]; + char say[128]; + int fl,x,y,i; + unsigned int MAX_USER=0; + MAX_USER=getFdnum(); + if( strlen(message)==0){ + sprintf(buf,"%s","参数不正确-> FLOOR X Y 无/要说的话"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + easyGetTokenFromString( message , 1 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","参数不正确-->地图编号"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + fl=atoi( token ); + easyGetTokenFromString( message , 2 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","参数不正确-->X座标 "); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + x = atoi( token ); + easyGetTokenFromString( message , 3 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","参数不正确-->Y座标 "); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + y = atoi( token ); + easyGetTokenFromString( message , 4 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","参数不正确-->帐号"); + CHAR_talkToCli( charindex, -1,buf, CHAR_COLORWHITE); + return; + } + easyGetTokenFromString( message , 5 , say , sizeof(say)); + + for(i=0;i FLOOR X Y 帐号 格数 无/要说的话"); + CHAR_talkToCli( charaindex, -1,buf, CHAR_COLORWHITE); + return; + } + easyGetTokenFromString( message , 1 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","参数不正确-->地图编号"); + CHAR_talkToCli( charaindex, -1,buf, CHAR_COLORWHITE); + return; + } + tofl=atoi( token ); + easyGetTokenFromString( message , 2 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","参数不正确-->X座标 "); + CHAR_talkToCli( charaindex, -1,buf, CHAR_COLORWHITE); + return; + } + toX = atoi( token ); + easyGetTokenFromString( message , 3 , token, sizeof(token)); + if( strlen(token)==0){ + sprintf(buf,"%s","参数不正确-->Y座标 "); + CHAR_talkToCli( charaindex, -1,buf, CHAR_COLORWHITE); + return; + } + toY = atoi( token ); + easyGetTokenFromString( message , 4 , cdkeytoken , sizeof(cdkeytoken)); + if( strlen(cdkeytoken)==0){ + sprintf(buf,"%s","参数不正确-->帐号"); + CHAR_talkToCli( charaindex, -1,buf, CHAR_COLORWHITE); + return; + } + easyGetTokenFromString( message , 5 , token, sizeof(token)); + area = atoi( token ); + if( strlen(token)==0 || area <= 0 || area > 3 ){ + sprintf(buf,"%s","参数不正确-->格数(1~3)"); + CHAR_talkToCli( charaindex, -1,buf, CHAR_COLORWHITE); + return; + } + easyGetTokenFromString( message , 6 , say , sizeof(say)); //说话 + + MAX_USER=getFdnum(); + for(k=0;k0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charaindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + CHAR_setWorkInt( i, CHAR_WORKFONTSIZE, atoi( fsize )); + //CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_LV); + sprintf( token, "[GM]%把你的字体设置为%d!", CHAR_getChar( charaindex, CHAR_NAME),(int)atoi(fsize)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "玩家%s的字体设置为%d!", CHAR_getChar( i, CHAR_NAME),(int)atoi(fsize)); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + }else{ + CHAR_setWorkInt( charaindex, CHAR_WORKFONTSIZE, atoi( fsize )); + sprintf( token, "字体设置为%d!",(int)atoi(fsize)); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + } +} +#endif + +#ifdef _JOBDAILY +void CHAR_CHAT_DEBUG_rejobdaily(int charaindex ,char *message) +{ + print("Reading Jobdaily File..."); + CHAR_talkToCli( charaindex, -1, "重新读取任务日志列表...", CHAR_COLORYELLOW); + if(!LoadJobdailyfile()){ + CHAR_talkToCli( charaindex, -1, "读取失败", CHAR_COLORYELLOW); + print("fail!!\n"); + return; + } + print("done\n"); + CHAR_talkToCli( charaindex, -1, "读取完成", CHAR_COLORYELLOW); +} +#endif + +#ifdef _RACEMAN +extern int asktotal; + +void CHAR_CHAT_DEBUG_changeask(int charaindex, char *message) +{ + char cdkey[64] , free[64] , buf[256] , item[64]; + int i ,toindex=0, Playernum = CHAR_getPlayerMaxNum(); + int itemindex,itemid; + unsigned int askno,asklv,temp; + int petNo,intNo,shift,base; + + easyGetTokenFromString( message , 1 , cdkey , sizeof(cdkey)); + if( strlen(cdkey)==0){ + sprintf(buf,"%s","没有帐号。正确格式:[changeask 帐号 人物名称 宠证id 0/1]"); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + return; + } + easyGetTokenFromString( message , 2 , item, sizeof(item)); + if( strlen(item)==0){ + sprintf(buf,"%s","没有宠证id。正确格式:[changeask 帐号 宠证id 0/1]"); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + return; + } + easyGetTokenFromString( message , 3 , free , sizeof(free)); + if( strlen(free)==0 ){ + sprintf(buf,"%s","最後的参数错误。正确格式:[changeask 帐号 宠证id 0/1]"); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + return; + } + + + for( i=0;i=Playernum){ + sprintf(buf,"%s","找不到这个人,请确认帐号"); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + return; + } + //找道具 + for( i = 0 ; i < CHAR_MAXITEMHAVE ; i++ ) { + itemindex=CHAR_getItemIndex( toindex , i ); + if( ITEM_CHECKINDEX( itemindex) ) { + itemid=ITEM_getInt( itemindex ,ITEM_ID ); + if(itemid==atoi(item)){ //找到猎宠证 + if(atoi(free)==1){ + //设定解过 + petNo = ( CHAR_getInt( toindex , CHAR_CHECKIN ) & 0x7FC00000 ) >> 22 ; + intNo = petNo / 32 ; + shift = petNo % 32 ; + base = 1 << shift; + CHAR_setInt( toindex , CHAR_KINDCNT1 + intNo , CHAR_getInt( toindex , CHAR_KINDCNT1 + intNo ) | base ); + CHAR_setInt( toindex,CHAR_CATCHCNT5,CHAR_getInt( toindex,CHAR_CATCHCNT5 ) +1 ); + } + //给下一题 + if(CHAR_getInt( toindex,CHAR_CATCHCNT5 ) >= asktotal ){ + sprintf( buf,"恭喜你达到猎宠大赛终极目标,祝您抽中大奖"); + }else{ + askno = Raceman_getokask( toindex , rand() % asktotal ); + asklv = asktable[askno].lowlv + rand()%((asktable[askno].highlv+1)-asktable[askno].lowlv); + temp = (askno << 22) & 0x7FC00000; + temp = temp | ((asklv << 14) & 0x003FC000); + temp = temp | ((asktable[askno].bbi - 100000) & 0x00003FFF); + CHAR_setInt( toindex , CHAR_CHECKIN , temp ); + if( asktable[askno].highlv == 0 ) + sprintf( buf,"请抓给我等级%d『以上』的%s好吗。您目前记录%d种", asktable[askno].lowlv , asktable[askno].petname, CHAR_getInt( toindex,CHAR_CATCHCNT5 ) ); + else + sprintf( buf,"请抓给我『只能』等级%d的%s好吗。您目前记录%d种", asklv , asktable[askno].petname, CHAR_getInt( toindex,CHAR_CATCHCNT5 ) ); + } + ITEM_setChar( itemindex, ITEM_EFFECTSTRING, buf); + CHAR_sendItemDataOne( toindex , i ); + break; + } + } + } + if( i >= CHAR_MAXITEMHAVE ){ + sprintf(buf,"%s","找不到猎宠证!"); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + return; + }else{ + sprintf(buf,"%s","设定完成"); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + } +} +#endif + +#ifdef _CREATE_MM_1_2 +void CHAR_CHAT_DEBUG_MM( int charaindex , char *message ) +{ + int ret; + int enemynum; + int enemyid; + int index; + int i,j; + int work[4]={50,50,50,50}; + int LevelUpPoint; + char buf[10]; + char cdkey[CDKEYLEN]; + char token[255]; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , buf, sizeof(buf)); + index=atoi(buf); + easyGetTokenFromString( message , 2 , cdkey, sizeof(cdkey)); + if(index==1)enemyid=1479; + else if(index==2)enemyid=2547; + else{ + CHAR_talkToCli( charaindex, -1, "目前只能制作1/2代玛蕾菲雅!", CHAR_COLORYELLOW ); + return;} + + if(strlen(cdkey)>0){ + for(j=0;j=playernum) + { + CHAR_talkToCli( charaindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == enemyid) { + break; + } + } + if( i == enemynum )return; + + ret = ENEMY_createPetFromEnemyIndex( j, i); + if( !CHAR_CHECKINDEX( ret))return; + snprintf( token,sizeof( token), "制作极品%d代玛蕾菲雅成功\!index[%d]",index,ret); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORWHITE); + sprintf( token, "[GM]%s制作了只极品%d代玛蕾菲雅给你!index[%d]", CHAR_getChar( charaindex, CHAR_NAME),index,ret); + CHAR_talkToCli( j, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "给玩家%s制作了只极品%d代玛蕾菲雅!index[%d]", CHAR_getChar( j, CHAR_NAME),index,ret); + CHAR_talkToCli( charaindex, -1,token, CHAR_COLORYELLOW ); + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + if( CHAR_getCharPet( j, i ) == ret )break; + } + if( i == CHAR_MAXPETHAVE )i = 0; + + if( CHAR_CHECKINDEX( ret ) == TRUE ){ + CHAR_setMaxExpFromLevel( ret, CHAR_getInt( ret, CHAR_LV )); + } + int k; + LevelUpPoint = ( work[3]<< 24) + ( work[0]<< 16) + ( work[1]<< 8) + ( work[2]<< 0); + CHAR_setInt( ret, CHAR_ALLOCPOINT, LevelUpPoint); + for( k = 1; k < 79; k ++ ){ //升级 + if(k%5==0){ + LevelUpPoint = ( work[3]<< 24) + ( work[0]<< 16) + ( work[1]<< 8) + ( work[2]<< 0); + CHAR_setInt( ret, CHAR_ALLOCPOINT, LevelUpPoint); + } + CHAR_PetLevelUp( ret ); + CHAR_PetAddVariableAi( ret, AI_FIX_PETLEVELUP ); + CHAR_setInt( ret, CHAR_LV, CHAR_getInt( ret, CHAR_LV) +1 ); + } + + snprintf( token, sizeof( token ), "K%d", i ); + CHAR_sendStatusString( j, token ); + snprintf( token, sizeof( token ), "W%d", i ); + CHAR_sendStatusString( j, token ); + }else{ + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == enemyid) { + break; + } + } + if( i == enemynum )return; + + ret = ENEMY_createPetFromEnemyIndex(charaindex, i); + if( !CHAR_CHECKINDEX( ret))return; + snprintf( token,sizeof( token), "制作极品%d代玛蕾菲雅成功\!index[%d]",index,ret); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORWHITE); + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + if( CHAR_getCharPet( charaindex, i ) == ret )break; + } + if( i == CHAR_MAXPETHAVE )i = 0; + + if( CHAR_CHECKINDEX( ret ) == TRUE ){ + CHAR_setMaxExpFromLevel( ret, CHAR_getInt( ret, CHAR_LV )); + } + int k; + LevelUpPoint = ( work[3]<< 24) + ( work[0]<< 16) + ( work[1]<< 8) + ( work[2]<< 0); + CHAR_setInt( ret, CHAR_ALLOCPOINT, LevelUpPoint); + for( k = 1; k < 79; k ++ ){ //升级 + if(k%5==0){ + LevelUpPoint = ( work[3]<< 24) + ( work[0]<< 16) + ( work[1]<< 8) + ( work[2]<< 0); + CHAR_setInt( ret, CHAR_ALLOCPOINT, LevelUpPoint); + } + CHAR_PetLevelUp( ret ); + CHAR_PetAddVariableAi( ret, AI_FIX_PETLEVELUP ); + CHAR_setInt( ret, CHAR_LV, CHAR_getInt( ret, CHAR_LV) +1 ); + } + + snprintf( token, sizeof( token ), "K%d", i ); + CHAR_sendStatusString( charaindex, token ); + snprintf( token, sizeof( token ), "W%d", i ); + CHAR_sendStatusString( charaindex, token ); + } +} +#endif + +#ifdef _SendTo +void CHAR_CHAT_DEBUG_Sendto( int charaindex , char *message ) +{ + char cdkey[CDKEYLEN]; + char token[255]; + int i; + int playernum = CHAR_getPlayerMaxNum(); + easyGetTokenFromString( message , 1 , cdkey, sizeof(cdkey)); + if(strlen(cdkey)>0){ + for(i=0;i=playernum) + { + CHAR_talkToCli( charaindex, -1, "此账号不在线~", CHAR_COLORYELLOW ); + return; + } + if(!strcmp(CHAR_getChar(charaindex,CHAR_CDKEY),cdkey)) + { + CHAR_DischargePartyNoMsg( charaindex);//解散团队 + int floor, x, y; + char token[256]; + floor = CHAR_getInt( i, CHAR_FLOOR); + x = CHAR_getInt( i, CHAR_X); + y = CHAR_getInt( i, CHAR_Y); + + CHAR_warpToSpecificPoint( charaindex, floor, x, y ); + sprintf( token, "已传送到玩家%s身边!", CHAR_getChar( i, CHAR_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW ); + return; + } + } +} +#endif \ No newline at end of file diff --git a/gmsv/char/chatroom.c b/gmsv/char/chatroom.c new file mode 100644 index 0000000..4a962f4 --- /dev/null +++ b/gmsv/char/chatroom.c @@ -0,0 +1,903 @@ +#include "version.h" +#include +#include +#include +#include "readmap.h" +#include "object.h" +#include "char.h" +#include "char_base.h" +#include "chatmagic.h" +#include "battle.h" +#include "log.h" +#include "configfile.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "family.h" +#include "chatroom.h" +#include "net.h" +#include "util.h" +#ifdef _CHATROOMPROTOCOL // (不可开) Syu ADD 聊天室频道 + + + +#ifdef _UNIVERSE_CHATROOM + +UniChatRoomlist ChatRoom[MAX_CHATROOM]; +BOOL ChatCheck_BeMaster( int myindex, int chatnum) +{ + if( !CHAR_CHECKINDEX ( myindex ) ) + return FALSE; + + if( CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMNUM ) == 0 ) return FALSE; + + if( chatnum != -1 ){ + if( CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMNUM ) != chatnum ) + return FALSE; + } + if( CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMTYPE ) == 1 ) return TRUE; + + return FALSE; +} + +BOOL ChatCheck_Free( int myindex) +{ + int old_gold; + if ( !CHAR_CHECKINDEX ( myindex ) ) + return FALSE; + old_gold = CHAR_getInt( myindex, CHAR_GOLD ); + if( old_gold < 200 ){ + CHAR_talkToCli ( myindex , -1 , "成立聊天室需花费200石币" , CHAR_COLORYELLOW ); + return FALSE; + } + if ( CHAR_getInt ( myindex , CHAR_LV ) < 30 && + CHAR_getInt ( myindex , CHAR_TRANSMIGRATION ) < 1 ) { + CHAR_talkToCli ( myindex , -1 , "成立聊天室需0转30级以上!" , CHAR_COLORYELLOW ); + return FALSE; + } + if ( CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMTYPE ) != 0 ) { + CHAR_talkToCli ( myindex , -1 , "你已经在其他聊天室中!" , CHAR_COLORYELLOW ); + return FALSE; + } + return TRUE; +} + +void resetChat_users( int chat, int ti) +{ + if( chat<0 || chat >= MAX_CHATROOM ) return; + if( ti<0 || ti >= MAX_PPLINROOM ) return; + memset( ChatRoom[chat].charalist[ti].cdkey, 0, sizeof(ChatRoom[chat].charalist[ti].cdkey)); + memset( ChatRoom[chat].charalist[ti].name, 0, sizeof(ChatRoom[chat].charalist[ti].name)); + memset( ChatRoom[chat].charalist[ti].own, 0, sizeof(ChatRoom[chat].charalist[ti].own)); +} + +void InitChatRoom( void ) +{ + int i, j; + for ( i = 0 ; i < MAX_CHATROOM ; i ++ ) { + ChatRoom[ i ].use=0; + ChatRoom[ i ].masindex= -1; + ChatRoom[ i ].charanum= 0; + for ( j = 0 ; j < MAX_PPLINROOM ; j ++ ) + resetChat_users( i, j); + } +} + +int ChatRoom_getfree( void) +{ + int i; + for ( i=0; iMAX_PPLINROOM ) return; + + sprintf ( token , "R|r%d|%s|%d|%s|p%d|" , + Num, ChatRoom[ Num ].chatname, ChatRoom[ Num ].masindex, + ChatRoom[Num].charalist[ChatRoom[Num].masindex].name, ChatRoom[ Num ].charanum ); + + for ( i = 0 ; i < MAX_PPLINROOM ; i ++ ) { + if ( ChatRoom[ Num ].charalist[i].use == 0 ) continue; + sprintf( buf , "I%d|%s|%s|" , + i, ChatRoom[Num].charalist[i].name, ChatRoom[Num].charalist[i].own ); + strncat ( token , buf , sizeof ( buf ) ) ; + } + + for ( j=0; j= MAX_CHATROOM ) return; + + sprintf ( buf , "D|%d", chat); + for ( j=0; j= 32 ) return; + snprintf( token, sizeof( token),"C|%s|%s|%s|%s|", + chatname, CHAR_getChar( charaindex, CHAR_CDKEY), + CHAR_getChar( charaindex, CHAR_NAME), + CHAR_getChar( charaindex, CHAR_OWNTITLE) + ); + }else if ( strcmp ( Head , "D" ) == 0 ) { // 删除频道 + int chat; + + if( CHAR_getWorkInt( charaindex, CHAR_WORKCHATROOMTYPE) != 1 ) return; + if( (chat = CHAR_getWorkInt( charaindex, CHAR_WORKCHATROOMNUM)) < 0 ) return; + if( chat >= MAX_CHATROOM ) return; + snprintf( token, sizeof( token),"D|%d|%s|%s|", + chat, CHAR_getChar( charaindex, CHAR_CDKEY), + CHAR_getChar( charaindex, CHAR_NAME) + ); + //ChatRoom_Destroy( myindex); +/* + }else if ( strcmp ( Head, "A") == 0 ) {// 同意加入频道 + getStringFromIndexWithDelim( data , "|", 2, message, sizeof(message)); + getStringFromIndexWithDelim( data , "|", 3, buf, sizeof(buf)); + ChatRoom_Agree ( myindex , atoi( message ) , atoi( buf ) ) ; +*/ + }else if ( strcmp( Head , "J") == 0 ) {//加入频道 + int chat; + if( getStringFromIndexWithDelim( data , "|", 2, buf, sizeof(buf)) == FALSE ) return; + chat = atoi( buf); + if( chat < 0 || chat >= MAX_CHATROOM ) return; + snprintf( token, sizeof( token),"J|%d|%s|%s|%s|", + chat, CHAR_getChar( charaindex, CHAR_CDKEY), + CHAR_getChar( charaindex, CHAR_NAME), + CHAR_getChar( charaindex, CHAR_OWNTITLE) + ); +// ChatRoom_Join ( myindex , atoi( message ) ) ; + }else if ( strcmp( Head , "L") == 0 ) {// 离开频道 + ChatRoom_Leave( charaindex); + return; + }else if ( strcmp ( Head , "K" ) == 0 ) {//踢出频道 + int ti, chat; + if( getStringFromIndexWithDelim( data , "|", 2, buf, sizeof( buf)) == FALSE ) return; + ti = atoi( buf); + if( ti<0 || ti>=MAX_PPLINROOM ) return; + if( CHAR_getWorkInt( charaindex, CHAR_WORKCHATROOMTYPE) != 1 ) return; + if( (chat = CHAR_getWorkInt( charaindex, CHAR_WORKCHATROOMNUM)) < 0 ) return; + + if( chat >= MAX_CHATROOM ) return; + snprintf( token, sizeof( token),"K|%d|%s|%s|%d|", + chat, + CHAR_getChar( charaindex, CHAR_CDKEY), + CHAR_getChar( charaindex, CHAR_NAME), + ti ); + +// ChatRoom_Kick ( myindex , atoi( message ) ); + }else if ( strcmp ( Head , "M" ) == 0 ) { // 更换室长 + int ti, chat; + if( getStringFromIndexWithDelim( data , "|", 2, buf, sizeof(buf)) == FALSE ) return; + ti = atoi( buf); + if( CHAR_getWorkInt( charaindex, CHAR_WORKCHATROOMTYPE) != 1 ) return; + if( (chat = CHAR_getWorkInt( charaindex, CHAR_WORKCHATROOMNUM)) < 0 ) return; + if( chat >= MAX_CHATROOM ) return; + if( ChatRoom[chat].charalist[ti].use == 0 ) return; + snprintf( token, sizeof( token),"M|%d|%s|%s|%d|", + chat, + CHAR_getChar( charaindex, CHAR_CDKEY), + CHAR_getChar( charaindex, CHAR_NAME), + ti ); +// ChatRoom_Make ( myindex , atoi( message ) ); + }else if ( strcmp ( Head , "T" ) == 0 ) {// 频道讯息 + int chat; + if( getStringFromIndexWithDelim( data , "|", 2, buf, sizeof(buf)) == FALSE ) return; + if( CHAR_getWorkInt( charaindex, CHAR_WORKCHATROOMTYPE) == 0 ) return; + if( (chat = CHAR_getWorkInt( charaindex, CHAR_WORKCHATROOMNUM)) < 0 ) return; + if( chat >= MAX_CHATROOM ) return; + snprintf( token, sizeof( token),"T|%d|%s|", chat, buf); + +// ChatRoom_Message ( myindex , message ) ; + }else if ( strcmp ( Head , "B" ) == 0 ) {// 聊天室清单 + ChatRoom_List ( fd ); + return; + } + + fd = getfdFromCharaIndex( charaindex); + saacproto_ACUniChatroom_send( acfd, charaindex, CONNECT_getFdid(fd), + CHAR_getChar( charaindex, CHAR_CDKEY), token); +} + +void saac_ChatRoom_recvall ( int fd , char *result, char *data, int charaindex, int clifdid) +{ + char Head[4], buf[256]; + int chat; + + charaindex = getCharindexFromFdid(clifdid); + //andy_log + print( "saac CR:%s.\n", data); + if( getStringFromIndexWithDelim( data , "|", 1, Head, sizeof(Head)) == FALSE ) return; + + if( strcmp( Head, "C") == 0 ) { // 成立频道 +// int fd = getfdFromCharaIndex( charaindex); +// if( getStringFromIndexWithDelim( data , "|", 2, result, sizeof(result)) == FALSE ) return; + if( !strcmp( result, SUCCESSFUL) ){ + + if( getStringFromIndexWithDelim( data , "|", 3, buf, sizeof(buf)) == FALSE ) return; + chat = atoi( buf); + if( chat < 0 || chat >= MAX_CHATROOM ) return; + if( getStringFromIndexWithDelim( data , "|", 4, ChatRoom[chat].chatname, + sizeof(ChatRoom[chat].chatname)) == FALSE ) return; + if( getStringFromIndexWithDelim( data , "|", 5, buf, sizeof(buf)) == FALSE ) return; + ChatRoom[chat].masindex = atoi( buf); + if( getStringFromIndexWithDelim( data , "|", 6, + ChatRoom[chat].charalist[0].cdkey, sizeof(ChatRoom[chat].charalist[0].cdkey)) == FALSE ) return; + if( getStringFromIndexWithDelim( data , "|", 7, + ChatRoom[chat].charalist[0].name, sizeof(ChatRoom[chat].charalist[0].name)) == FALSE ) return; + if( getStringFromIndexWithDelim( data , "|", 8, + ChatRoom[chat].charalist[0].own, sizeof(ChatRoom[chat].charalist[0].own)) == FALSE ) return; + ChatRoom[chat].charalist[0].use=1; + if( CHAR_DelGold( charaindex, 200) == 0 ) return; + ChatRoom[chat].use = 1; + CHAR_setWorkInt ( charaindex , CHAR_WORKCHATROOMTYPE , 1 ) ; + CHAR_setWorkInt ( charaindex , CHAR_WORKCHATROOMNUM , chat ) ; + CHAR_talkToCli ( charaindex , -1 , "成立聊天室扣除200石币。" , CHAR_COLORYELLOW ); + + ChatRoom_Refresh( chat); + }else{ + CHAR_talkToCli ( charaindex , -1 , "无法成立聊天室,聊天频道已满或条件不足!" , CHAR_COLORYELLOW ); + } + }else if( strcmp( Head, "U") == 0 ) { + int k=2, ti; + char bufarg[512]; + if( getStringFromIndexWithDelim( data , ",", 1, bufarg, sizeof(bufarg)) == FALSE ) return; + if( getStringFromIndexWithDelim( bufarg , "|", 2, buf, sizeof(buf)) == FALSE ) return; + chat = atoi( buf); + if( chat < 0 || chat >= MAX_CHATROOM ) return; + if( getStringFromIndexWithDelim( bufarg , "|", 3, buf, sizeof(buf)) == FALSE ) return; + ChatRoom[chat].use = atoi( buf); + if( getStringFromIndexWithDelim( bufarg , "|", 4, + ChatRoom[chat].chatname, sizeof(ChatRoom[chat].chatname)) == FALSE ) return; + if( getStringFromIndexWithDelim( bufarg , "|", 5, buf, sizeof(buf)) == FALSE ) return; + ChatRoom[chat].masindex = atoi( buf); + if( getStringFromIndexWithDelim( bufarg , "|", 6, buf, sizeof(buf)) == FALSE ) return; + ChatRoom[chat].charanum = atoi( buf); + + while( getStringFromIndexWithDelim( data , ",", k, bufarg, sizeof( bufarg) ) ){ + k++; + if( bufarg[0] == 0 || strlen( bufarg) <= 0 ) continue; + if( getStringFromIndexWithDelim( bufarg , "|", 1, buf, sizeof(buf)) == FALSE ) return; + ti = atoi( buf); + if( getStringFromIndexWithDelim( bufarg , "|", 2, + ChatRoom[chat].charalist[ti].cdkey, sizeof(ChatRoom[chat].charalist[ti].cdkey)) == FALSE ) return; + if( getStringFromIndexWithDelim( bufarg , "|", 3, + ChatRoom[chat].charalist[ti].name, sizeof(ChatRoom[chat].charalist[ti].name)) == FALSE ) return; + if( getStringFromIndexWithDelim( bufarg , "|", 4, + ChatRoom[chat].charalist[ti].own, sizeof(ChatRoom[chat].charalist[ti].own)) == FALSE ) return; + ChatRoom[chat].charalist[ti].use = 1; + } + ChatRoom_Refresh( chat); + }else if( strcmp( Head, "D") == 0 ) { + ChatRoom_Destroy ( data); + }else if( strcmp( Head, "L") == 0 ) { + int chat, ti; + if( getStringFromIndexWithDelim( data , "|", 2, buf, sizeof( buf)) == FALSE ) return; + chat = atoi(buf); + if( chat < 0 || chat >= MAX_CHATROOM ) return; + if( getStringFromIndexWithDelim( data , "|", 3, buf, sizeof( buf)) == FALSE ) return; + ti = atoi(buf); + if( ti<0||ti>=MAX_PPLINROOM)return; + ChatRoom[chat].charalist[ti].use = 0; + ChatRoom_Refresh( chat); + }else if( strcmp( Head, "M") == 0 ) { + int ti, chat, j; + int playernum = CHAR_getPlayerMaxNum(); + if( getStringFromIndexWithDelim( data , "|", 2, buf, sizeof( buf)) == FALSE ) return; + chat = atoi( buf); + if( chat < 0 || chat >= MAX_CHATROOM ) return; + if( getStringFromIndexWithDelim( data , "|", 3, buf, sizeof( buf)) == FALSE ) return; + ti = atoi( buf); + if( ti<0 || ti>=MAX_PPLINROOM )return; + if( ChatRoom[chat].charalist[ti].use == 0 ) return; + for ( j=0; j= MAX_CHATROOM ) return; + if( getStringFromIndexWithDelim( data , "|", 3, buf, sizeof( buf)) == FALSE ) return; + ti = atoi( buf); + if( ti<0 || ti>=MAX_PPLINROOM ) return; +//andy_log +print( "\nK|%d|%d|\n", chat, ti); + + for ( j=0; j= MAX_CHATROOM ) return; + if( getStringFromIndexWithDelim( data , "|", 3, result, sizeof( result)) == FALSE ) return; + if( !strcmp( result, "FULL") ){ + CHAR_talkToCli( charaindex, -1, "该频道已满!", CHAR_COLORYELLOW); + }else if( !strcmp( result, "OK") ){ + CHAR_talkToCli( charaindex, -1, "加入聊天频道!", CHAR_COLORYELLOW); + CHAR_setWorkInt( charaindex, CHAR_WORKCHATROOMNUM, chat); + CHAR_setWorkInt( charaindex, CHAR_WORKCHATROOMTYPE, 2); + } + ChatRoom_Refresh( chat); + }else if( !strcmp( Head, "T") ) {//频道讯息 + int j; + char message[256]; + int playernum = CHAR_getPlayerMaxNum(); + if( getStringFromIndexWithDelim( data , "|", 2, buf, sizeof( buf)) == FALSE ) return; + chat = atoi( buf); + if( chat < 0 || chat >= MAX_CHATROOM ) return; + if( getStringFromIndexWithDelim( data , "|", 3, buf, sizeof( buf)) == FALSE ) return; + snprintf ( message, sizeof ( message ) , "T|%s" , buf ); + for ( j=0; j 0 ) { + i = CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMNUM ) ; + + // WON FIX + if( i < 0 ) return; + + for ( j = 0 ; j < MAX_PPLINROOM ; j ++ ) { + if ( !CHAR_CHECKINDEX ( ChatRoom[ i ].MemberList[ j ] ) ) + continue; + snprintf ( buf , sizeof ( buf ) , "T|%s" , message ) ; + fd = getfdFromCharaIndex ( ChatRoom[ i ].MemberList[ j ] ); + lssproto_CHATROOM_send ( fd , buf ) ; + } + } +} + +void ChatRoom_Kick ( int myindex , int toindex ) +{ + int i , fd ; + int Num = CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMNUM ); + if ( !CHAR_CHECKINDEX ( myindex ) ) + return ; + if ( !CHAR_CHECKINDEX ( toindex ) ) + return ; + if ( myindex == toindex ) return; + if ( CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMTYPE ) == 1 ) { + if ( Num != CHAR_getWorkInt ( toindex , CHAR_WORKCHATROOMNUM ) ) + return; + else { + CHAR_setWorkInt ( toindex , CHAR_WORKCHATROOMTYPE , 0 ) ; + CHAR_setWorkInt ( toindex , CHAR_WORKCHATROOMNUM , -1) ; + //CHAR_talkToCli ( toindex , -1 , "室长将你踢出聊天室!" , CHAR_COLORRED ) ; + fd = getfdFromCharaIndex( toindex ); + lssproto_CHATROOM_send ( fd , "K|" ) ; + ChatRoom[ Num ].NowPeople --; + for ( i = 0 ; i < MAX_PPLINROOM ; i ++ ) { + if ( ChatRoom[ Num ].MemberList[ i ] == toindex ) { + ChatRoom[ Num ].MemberList[ i ] = -1 ; + break; + } + } + } + } + ChatRoom_Refresh ( Num ) ; +} + +void ChatRoom_Make ( int myindex , int toindex ) +{ + int Num = CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMNUM ); + if ( !CHAR_CHECKINDEX ( myindex ) ) + return ; + if ( !CHAR_CHECKINDEX ( toindex ) ) + return ; + if ( CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMTYPE ) == 1 ) { + if ( Num != CHAR_getWorkInt ( toindex , CHAR_WORKCHATROOMNUM ) ) + return; + else if ( CHAR_getInt ( toindex , CHAR_LV ) >= 30 || + CHAR_getInt ( toindex , CHAR_TRANSMIGRATION ) >= 1 ) { + CHAR_setWorkInt ( myindex , CHAR_WORKCHATROOMTYPE , 2 ) ; + CHAR_setWorkInt ( toindex , CHAR_WORKCHATROOMTYPE , 1 ) ; + CHAR_talkToCli ( toindex , -1 , "你现在是聊天室的室长!" , CHAR_COLORRED ) ; + + ChatRoom[ Num ].Maker = toindex ; + } + else { + CHAR_talkToCli ( myindex , -1 , "您选择的继任人物等级不足以担任室长!" , CHAR_COLORRED ) ; + } + } + ChatRoom_Refresh ( Num ) ; +} + +void ChatRoom_Leave ( int myindex ) +{ + int i , NextMaker = -1 ; + int Num = CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMNUM ); + if ( !CHAR_CHECKINDEX ( myindex ) ) + return ; + if ( CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMTYPE ) == 1 ) { + for ( i = 0 ; i < MAX_PPLINROOM ; i ++ ) { + if ( ChatRoom[ Num ].MemberList[ i ] != myindex && + ChatRoom[ Num ].MemberList[ i ] != -1 ) { + if ( CHAR_CHECKINDEX ( ChatRoom[ Num ].MemberList[ i ] ) ) { + if ( CHAR_getInt ( ChatRoom[ Num ].MemberList[ i ] , CHAR_LV ) >= 30 || + CHAR_getInt ( ChatRoom[ Num ].MemberList[ i ] , CHAR_TRANSMIGRATION ) >= 1 ) { + NextMaker = ChatRoom[ Num ].MemberList[ i ] ; + break; + } + } + } + } + if ( NextMaker != -1 ) { + ChatRoom_Make( myindex , NextMaker ) ; + CHAR_setWorkInt ( myindex , CHAR_WORKCHATROOMTYPE , 0) ; + CHAR_setWorkInt ( myindex , CHAR_WORKCHATROOMNUM, -1) ; + ChatRoom[ Num ].NowPeople --; + for ( i = 0 ; i < MAX_PPLINROOM ; i ++ ) { + if ( ChatRoom[ Num ].MemberList[ i ] == myindex ) { + ChatRoom[ Num ].MemberList[ i ] = -1 ; + break; + } + } + }else{ + ChatRoom_Destroy( myindex ) ; + return ; + } + + }else if ( CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMTYPE ) == 2 ) { + CHAR_setWorkInt ( myindex, CHAR_WORKCHATROOMTYPE, 0) ; + CHAR_setWorkInt ( myindex, CHAR_WORKCHATROOMNUM, -1) ; + ChatRoom[ Num ].NowPeople --; + for ( i = 0 ; i < MAX_PPLINROOM ; i ++ ) { + if ( ChatRoom[ Num ].MemberList[ i ] == myindex ) { + ChatRoom[ Num ].MemberList[ i ] = -1 ; + break; + } + } + } + ChatRoom_Refresh ( Num ) ; +} + +void ChatRoom_Join ( int myindex , int num ) +{ + int fd ; + char buf[64]; + if ( !CHAR_CHECKINDEX ( myindex ) ) + return ; + if ( CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMTYPE ) != 0 ) + return ; + if ( ChatRoom[ num ].useFlag == TRUE && ChatRoom[ num ].NowPeople < MAX_PPLINROOM ) { + sprintf ( buf , "J|%s|%d" , CHAR_getChar( myindex , CHAR_NAME ) , myindex ) ; + fd = getfdFromCharaIndex( ChatRoom[ num ].Maker ); + lssproto_CHATROOM_send ( fd , buf ); + }else if ( ChatRoom[ num ].NowPeople >= MAX_PPLINROOM ) + CHAR_talkToCli ( myindex , -1 , "聊天室人数已满!" , CHAR_COLORRED ) ; + +} + +void ChatRoom_Agree ( int myindex , int toindex , int YesNo ) { + int i ; + int Num = CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMNUM ); + if ( !CHAR_CHECKINDEX ( myindex ) ) + return ; + if ( !CHAR_CHECKINDEX ( toindex ) ) + return ; + if ( CHAR_getWorkInt ( toindex , CHAR_WORKCHATROOMTYPE ) != 0 ) + return; + if ( CHAR_getWorkInt ( myindex , CHAR_WORKCHATROOMTYPE ) == 1 ) { + if ( ChatRoom[ Num ].NowPeople < MAX_PPLINROOM && YesNo == 1 ) { + CHAR_setWorkInt ( toindex , CHAR_WORKCHATROOMTYPE , 2 ) ; + CHAR_setWorkInt ( toindex , CHAR_WORKCHATROOMNUM , Num ) ; + ChatRoom[ Num ].NowPeople ++ ; + for ( i = 0 ; i < MAX_PPLINROOM ; i ++ ) { + if ( ChatRoom[ Num ].MemberList[ i ] == -1 ) { + ChatRoom[ Num ].MemberList[ i ] = toindex ; + break; + } + } + }else if ( YesNo == 0 ) { + CHAR_talkToCli ( toindex , -1 , "您申请的聊天室室长拒绝您的加入!" , CHAR_COLORRED ) ; + }else if ( ChatRoom[ Num ].NowPeople >= MAX_PPLINROOM ) { + CHAR_talkToCli ( toindex , -1 , "您申请的聊天室人数已满!" , CHAR_COLORRED ) ; + CHAR_talkToCli ( myindex , -1 , "聊天室人数已满!" , CHAR_COLORRED ) ; + } + } + ChatRoom_Refresh ( Num ) ; +} + +void ChatRoom_List ( int fd ) +{ + int i ; + char buf[128]; + char token[2048] = "B|"; + for ( i = 0 ; i < MAX_CHATROOM ; i ++ ) { + if ( ChatRoom[ i ].useFlag == TRUE ) { + sprintf ( buf , "聊天室%2d资讯:室名=>%20s , 室长=>%16s , 人数=>%2d" , + i , + ChatRoom[ i ].RoomName , + CHAR_getChar ( ChatRoom[ i ].Maker , CHAR_NAME ) , + ChatRoom[ i ].NowPeople ); + + sprintf ( buf , "r%d|%s|%d|%s|p%d|" , + i , + ChatRoom[ i ].RoomName , + ChatRoom[ i ].Maker , + CHAR_getChar ( ChatRoom[ i ].Maker , CHAR_NAME ) , + ChatRoom[ i ].NowPeople ); + strncat ( token , buf , sizeof ( buf ) ) ; + } + } + lssproto_CHATROOM_send ( fd , token ) ; +} + +void ChatRoom_Refresh ( int Num ) +{ + int fd , i , RoomLeader = -1 ; + char token[2048] ; + char token2[2096] ; + char buf[64] ; + if ( ChatRoom[ Num ].useFlag == TRUE ) { + sprintf ( token , "R|r%d|%s|%d|%s|p%d|" , + Num , + ChatRoom[ Num ].RoomName , + ChatRoom[ Num ].Maker , + CHAR_getChar ( ChatRoom[ Num ].Maker , CHAR_NAME ) , + ChatRoom[ Num ].NowPeople ); + for ( i = 0 ; i < MAX_PPLINROOM ; i ++ ) { + if ( ChatRoom[ Num ].MemberList[ i ] != -1 ) { + sprintf( buf , "I%d|%s|%s|" , + ChatRoom[ Num ].MemberList[ i ] , + CHAR_getChar ( ChatRoom[ Num ].MemberList[ i ] , CHAR_NAME ) , + CHAR_getChar ( ChatRoom[ Num ].MemberList[ i ] , CHAR_OWNTITLE ) + ); + strncat ( token , buf , sizeof ( buf ) ) ; + } + } + } + for ( i = 0 ; i < MAX_PPLINROOM ; i ++ ) { + if ( ChatRoom[ Num ].MemberList[ i ] != -1 ) { + if ( CHAR_getWorkInt ( ChatRoom[ Num ].MemberList[ i ] , CHAR_WORKCHATROOMTYPE ) == 1 ) RoomLeader = 1; + else RoomLeader = 0 ; + sprintf ( token2 , "%s%d|" , token , RoomLeader ) ; + fd= getfdFromCharaIndex ( ChatRoom[ Num ].MemberList[ i ] ); + lssproto_CHATROOM_send ( fd , token2 ) ; + } + } +} + +void ChatRoom_recvall ( int fd , char *data ) +{ + char Head[4]; + char message[1024]; + char buf[16]; + int myindex ; + + myindex = CONNECT_getCharaindex(fd); + if ( !CHAR_CHECKINDEX ( myindex ) )return ; + getStringFromIndexWithDelim( data , "|", 1, Head, sizeof(Head)); + getStringFromIndexWithDelim( data , "|", 2, message, sizeof(message)); + + if ( strcmp ( Head , "C" ) == 0 ) { // 成立频道 + if ( !ChatRoom_Create ( myindex , message ) ) + print("\nSyu log Create Channel Error" ); + }else if ( strcmp ( Head , "D" ) == 0 ) { // 删除频道 + if ( !ChatRoom_Destroy ( myindex ) ) + print("\nSyu log Destroy Channel Error" ) ; + }else if ( strcmp ( Head , "A" ) == 0 ) {// 同意加入频道 + getStringFromIndexWithDelim( data , "|", 2, message, sizeof(message)); + getStringFromIndexWithDelim( data , "|", 3, buf, sizeof(buf)); + ChatRoom_Agree ( myindex , atoi( message ) , atoi( buf ) ) ; + }else if ( strcmp ( Head , "J" ) == 0 ) {// 申请频道 + getStringFromIndexWithDelim( data , "|", 2, message, sizeof(message)); + ChatRoom_Join ( myindex , atoi( message ) ) ; + }else if ( strcmp ( Head , "L" ) == 0 ) {// 离开频道 + ChatRoom_Leave ( myindex ) ; + }else if ( strcmp ( Head , "K" ) == 0 ) {//踢出频道 + getStringFromIndexWithDelim( data , "|", 2, message, sizeof(message)); + ChatRoom_Kick ( myindex , atoi( message ) ); + }else if ( strcmp ( Head , "M" ) == 0 ) { // 更换室长 + getStringFromIndexWithDelim( data , "|", 2, message, sizeof(message)); + ChatRoom_Make ( myindex , atoi( message ) ); + }else if ( strcmp ( Head , "T" ) == 0 ) {// 频道讯息 + getStringFromIndexWithDelim( data , "|", 2, message, sizeof(message)); + ChatRoom_Message ( myindex , message ) ; + }else if ( strcmp ( Head , "B" ) == 0 ) {// 聊天室清单 + ChatRoom_List ( fd ); + }else + print("\nSyu log None"); +} + +#endif +#endif diff --git a/gmsv/char/deathcontend.c b/gmsv/char/deathcontend.c new file mode 100644 index 0000000..8162754 --- /dev/null +++ b/gmsv/char/deathcontend.c @@ -0,0 +1,2022 @@ +#include "version.h" +#include +#include +#include "util.h" +#include "char.h" +#include "char_data.h" +#include "char_base.h" +#include "battle.h" +#include "configfile.h" +#include "saacproto_cli.h" +#include "buf.h" +#include "log.h" + +#ifdef _DEATH_CONTEND + +#include "deathcontend.h" + +PkTeamLists *PkTeamList=NULL; + +PKProcedures PKProcedure[MAXJOINTEAM]; + +static char chartslist[65536*3]; + +static char ABattlelist[65536*2]; +static char ABLevelup[65536*2]; + +static int maxteam = 0; + +static int PKListSort[550]; + +//正式赛 +ArrangeBattleC *NowABattle[MAXBAHEAD][MAXBAFLOOR][MAXNOWBATTLE]; +ArrangeBattleC *headABattle[MAXBAHEAD]; +ArrangeBattleC *InBattle[MAXBATTLEPAGE]; + +static int maxfloor=0; +static int maxbati=0; +int ABFloor[MAXBAHEAD]; + +/* +struct { + int floor; + int x; + int y; + int use; +}PK_WATCHMAP[MAXJOINTEAM][MAXWATCHMAP]={ + {}, + + +}; +*/ +struct { + int floor; + int x; + int y; + int use; +}PK_BATTLEMAP[MAXJOINTEAM]={ +// { 8240, 13, 14, 0}, { 8240, 13, 27, 0}, { 8240, 26, 14, 0}, { 8240, 26, 27, 0}, + + { 8240, 13, 14, 0}, { 8240, 13, 27, 0}, { 8240, 26, 14, 0}, { 8240, 26, 27, 0}, + { 8241, 13, 14, 0}, { 8241, 13, 27, 0}, { 8241, 26, 14, 0}, { 8241, 26, 27, 0}, + { 8242, 13, 14, 0}, { 8242, 13, 27, 0}, { 8242, 26, 14, 0}, { 8242, 26, 27, 0}, + { 8243, 13, 14, 0}, { 8243, 13, 27, 0}, { 8243, 26, 14, 0}, { 8243, 26, 27, 0}, + { 8244, 13, 14, 0}, { 8244, 13, 27, 0}, { 8244, 26, 14, 0}, { 8244, 26, 27, 0}, + + { 8245, 13, 14, 0}, { 8245, 13, 27, 0}, { 8245, 26, 14, 0}, { 8245, 26, 27, 0}, + { 8246, 13, 14, 0}, { 8246, 13, 27, 0}, { 8246, 26, 14, 0}, { 8246, 26, 27, 0}, + { 8247, 13, 14, 0}, { 8247, 13, 27, 0}, { 8247, 26, 14, 0}, { 8247, 26, 27, 0}, + { 8248, 13, 14, 0}, { 8248, 13, 27, 0}, { 8248, 26, 14, 0}, { 8248, 26, 27, 0}, + { 8249, 13, 14, 0}, { 8249, 13, 27, 0}, { 8249, 26, 14, 0}, { 8249, 26, 27, 0}, + +}; + +void PKLIST_shoutToAll( char *token, int teamnum, int floor) +{ + int i; + int playernum = CHAR_getPlayerMaxNum(); + + LogPkContend( token, "shoutToAll", 0, 0, 0, 1); + + for( i=0 ; i= maxteam ) return; + for( k=0;k= maxteam ) return; + PkTeamList[ti].use = 0; + PkTeamList[ti].teamnum = -1; + memset( PkTeamList[ti].teamname, 0, sizeof( PkTeamList[ti].teamname ) ); + memset( PkTeamList[ti].pathdir, 0, sizeof( PkTeamList[ti].pathdir) ); + memset( PkTeamList[ti].leadercdkey, 0, sizeof( PkTeamList[ti].leadercdkey ) ); + PkTeamList[ti].win = 0; + PkTeamList[ti].lost = 0; + PkTeamList[ti].battleplay = 0; + PkTeamList[ti].score = 0; + PkTeamList[ti].inside = 1; + PkTeamList[ti].read = 1; +} +//----------------------------------------------------------- + +int PKLIST_InitPkTeamList( int teamnum ) +{ + int i; + if( PkTeamList != NULL || teamnum <= 0 ) return -1; + maxteam = teamnum; + PkTeamList = (PkTeamLists *)calloc( 1, sizeof( struct _tagPkTeamLists) * maxteam ); + if( PkTeamList == NULL ){ + print( "ANDY err Can't calloc PkTeamList :%d !!\n", + sizeof( struct _tagPkTeamLists) * maxteam ); + return -1; + } + print( "PkTeamList calloc size :%d ..\n", + sizeof( struct _tagPkTeamLists) * maxteam ); + + for( i=0; i= DEFMAXBATTLENUM ){ + CHAR_talkToCli( charaindex, -1, "对战场次已满!", CHAR_COLORYELLOW); + return FALSE; + } + if( PkTeamList[array].BHistory[k].use == 0 ) continue; + if( PkTeamList[array].BHistory[k].teamnum == toteamnum ) return FALSE; + } + return TRUE; +} + +int PKLIST_CHECKPkTeamNew( int teamnum, int charaindex, char *cdkey ) +{ + int k; + int array; + array = PKLIST_GetPkTeamListArray( teamnum, cdkey); + if( array == -1 ){ + CHAR_talkToCli( charaindex, -1, "无法取得队伍资料!", CHAR_COLORYELLOW); + return -1; + } + for( k=0; k= DEFMAXBATTLENUM ){ + CHAR_talkToCli( charaindex, -1, "对战场次已满!", CHAR_COLORYELLOW); + return -1; + } + return k; +} + +BOOL PKLIST_LoadPkTeamListDataSub( int ti, char *data) +{ + int oldinside = -1; + char buf[512]; + if( getStringFromIndexWithDelim( data, "|", 1, buf, sizeof( buf)) == FALSE ) return FALSE; + PkTeamList[ti].teamnum = atoi( buf); + if( getStringFromIndexWithDelim( data, "|", 2, buf, sizeof( buf)) == FALSE ) return FALSE; + sprintf( PkTeamList[ti].pathdir, "%s", buf); + if( getStringFromIndexWithDelim( data, "|", 3, buf, sizeof( buf)) == FALSE ) return FALSE; + sprintf( PkTeamList[ti].teamname, "%s", buf); + if( getStringFromIndexWithDelim( data, "|", 4, buf, sizeof( buf)) == FALSE ) return FALSE; + sprintf( PkTeamList[ti].leadercdkey, "%s", buf); + if( getStringFromIndexWithDelim( data, "|", 5, buf, sizeof( buf)) == FALSE ) return FALSE; + PkTeamList[ti].win = atoi( buf); + if( getStringFromIndexWithDelim( data, "|", 6, buf, sizeof( buf)) == FALSE ) return FALSE; + PkTeamList[ti].lost = atoi( buf); + if( getStringFromIndexWithDelim( data, "|", 7, buf, sizeof( buf)) == FALSE ) return FALSE; + PkTeamList[ti].battleplay = atoi( buf); + if( getStringFromIndexWithDelim( data, "|", 8, buf, sizeof( buf)) == FALSE ) return FALSE; + PkTeamList[ti].score = atoi( buf); + + oldinside = PkTeamList[ti].inside; + if( getStringFromIndexWithDelim( data, "|", 9, buf, sizeof( buf)) == FALSE ) return FALSE; + PkTeamList[ti].inside = atoi( buf); + + if( PkTeamList[ti].inside == 2 && PkTeamList[ti].inside != oldinside ){//广播 + char token[256]; + int i; + int playernum = CHAR_getPlayerMaxNum(); + sprintf( token, "%s 队,达成比赛规定积分,积分:%d。", + PkTeamList[ti].teamname, PkTeamList[ti].score ); + + for( i=0; i= MAXTEAMMANNUM ) break; + } + if( count <= 0 ) return FALSE; + + return TRUE; +} + +BOOL PKLIST_LoadPkTeamListDataBHistory( int ti, char *data) +{ + int k=1, count=0; + char buf[256], buf1[64]; + while( getStringFromIndexWithDelim( data, "|", k, buf, sizeof( buf)) !=FALSE ) { + k++; + if( getStringFromIndexWithDelim( buf, ",", 1, buf1, sizeof( buf1)) == FALSE ) continue; + PkTeamList[ti].BHistory[count].teamnum = atoi( buf1); + if( getStringFromIndexWithDelim( buf, ",", 2, buf1, sizeof( buf1)) == FALSE ) continue; + PkTeamList[ti].BHistory[count].flg = atoi( buf1); + + PkTeamList[ti].BHistory[count].use = 1; + count++; + if( count >= MAXBATTLENUM ) break; + } + return TRUE; +} + +// teamlist.ini 内容 +// teamnum|teamname|leadercdkeky|leadername|cdkey|name|cdkey|name|cdkey|name|cdkey|name + +void PKLIST_LoadInitPkTeamListData(void) +{ + FILE *fp = NULL; + int count = 0,i; + char szReadData[1024],buf[1024],buf1[1024]; + + if((fp = fopen("data//pkdata//teamlist.txt","r")) != NULL){ + fclose(fp); + return; + } + if((fp = fopen("data//pkdata//teamlist.ini","r")) == NULL){ + print("can't find data/pkdata/teamlist.ini\n"); + return; + } + while(1){ + memset(szReadData,0,sizeof(szReadData)); + memset(buf,0,sizeof(buf)); + if(fgets(szReadData,1024,fp) == NULL) break; + if(getStringFromIndexWithDelim(szReadData,"|",1,buf,sizeof(buf)) == FALSE){ + print("err get teamindex data:%s\n",szReadData); + continue; + } + PkTeamList[count].teamnum = atoi(buf); + sprintf(PkTeamList[count].pathdir,"NOUSE"); + if(getStringFromIndexWithDelim(szReadData,"|",2,buf,sizeof(buf)) == FALSE){ + print("err get teamindex data:%s\n",szReadData); + continue; + } + sprintf(PkTeamList[count].teamname,"%s",buf); + if(getStringFromIndexWithDelim(szReadData,"|",3,buf,sizeof(buf)) == FALSE){ + print("err get leadercdkey data:%s\n",szReadData); + continue; + } + sprintf(PkTeamList[count].leadercdkey,"%s",buf); + for(i=0;i=maxteam ){ + print("err 1 buf:%s\n", buf); + continue; + } + if( getStringFromIndexWithDelim( buf, "_", 2, buf1, sizeof( buf1)) == FALSE ){ + print("err 2 buf:%s\n", buf); + continue; + } + if( PKLIST_LoadPkTeamListDataSub( array, buf1 ) == FALSE ){ + print("err 3 buf:%s\n", buf); + continue; + } + if( getStringFromIndexWithDelim( buf, "_", 3, buf1, sizeof( buf1)) == FALSE ){ + print("err 4 buf:%s\n", buf); + continue; + } + if( PKLIST_LoadPkTeamListDataMyTeamMans( array, buf1) == FALSE ){ + print("err 5 buf:%s\n", buf); + continue; + } + if( getStringFromIndexWithDelim( buf, "_", 4, buf1, sizeof( buf1)) != FALSE ){ + if( PKLIST_LoadPkTeamListDataBHistory( array, buf1) == FALSE ){ + print("err 7 buf:%s\n", buf); + continue; + } + } + + teamcount++; + } + //andy_log + print("\nteamcount:%d \n", teamcount); + if( teamcount <= 0 ) return TRUE; + return TRUE; +} +*/ + +void PKLIST_InsertTeamNum( int charaindex ) +{ + int i, k; + char *cdkey, *name; + if( !CHAR_CHECKINDEX( charaindex) ) return; + cdkey = CHAR_getChar( charaindex, CHAR_CDKEY); + name = CHAR_getChar( charaindex, CHAR_NAME); + + for( i=0; i= (int)time(NULL) ) return; + side = (j+1)%2; + + if( PKProcedure[battlearray].Team[side].use == 0 ) return; + if( (tonum = PKProcedure[battlearray].Team[side].teamnum ) < 0 ) return; + + if( (toarray = PKLIST_GetPkTeamListArrayFromNum( tonum)) == -1 || + PKLIST_GetTeamLeaderCdkey( tonum, tocdkey ) == FALSE ){ + print("Can't Get Data tonum:%d err !!\n", tonum); + return; + } + break; + } + //andy_log + print("NPC_PKLIST_PlayerLogout_Exit( %d) \n", charaindex); + if( (menum=CHAR_getInt( charaindex, CHAR_PKLISTTEAMNUM)) < 0 ) return; + + if( (aB1=ABATTLE_getInBattle( menum))==NULL ) return; + if( (aBo=aB1->top) == NULL ) return; + if( (aB1=aBo->next[0]) == NULL || (aB2=aBo->next[1]) == NULL ) return; + + if( aB1->teamnum == menum ){ + sprintf( token, "%s 队 胜 %s 队。", aB2->teamname, aB1->teamname ); + LogPkContend( aB2->teamname , aB1->teamname, 0, 0, 0, 0); + ABATTLE_RecordBattle( -1, aB1->teamname, "", aB2->teamname, "胜"); + tonum = aB2->teamnum; + ABATTLE_EnterBattle( aB2); + }else{ + sprintf( token, "%s 队 胜 %s 队。", aB1->teamname, aB2->teamname ); + LogPkContend( aB1->teamname , aB2->teamname, 0, 0, 0, 0); + ABATTLE_RecordBattle( -1, aB1->teamname, "胜", aB2->teamname, ""); + tonum = aB1->teamnum; + ABATTLE_EnterBattle( aB1); + } + for( i=0; i= (int)time(NULL) ) return; + side = (j+1)%2; + + if( PKProcedure[battlearray].Team[side].use == 0 ) return; + if( (tonum = PKProcedure[battlearray].Team[side].teamnum ) < 0 ) return; + + if( (toarray = PKLIST_GetPkTeamListArrayFromNum( tonum)) == -1 || + PKLIST_GetTeamLeaderCdkey( tonum, tocdkey ) == FALSE ){ + print("Can't Get Data tonum:%d err !!\n", tonum); + return; + } + + PKLIST_LOCKTeam( menum); + PKLIST_LOCKTeam( tonum); + //saacproto_PkListUpDate_send( acfd , tocdkey, mecdkey,tonum, menum, 0, 0); + PKLIST_UpData(tocdkey,mecdkey,tonum,menum,0,0); + + sprintf( token, "%s 队 胜 %s 队。", + PkTeamList[toarray].teamname, PkTeamList[mearray].teamname); + + LogPkContend( PkTeamList[toarray].teamname, PkTeamList[mearray].teamname, + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X), CHAR_getInt( charaindex, CHAR_Y), 0); + + PKLIST_DelPKProcedures( battlearray, 0, PKTYPE_WAIT); + PKLIST_DelPKProcedures( battlearray, 1, PKTYPE_WAIT); + + { //广播胜负 + int i; + int playernum = CHAR_getPlayerMaxNum(); + for( i=0; itop == NULL || aB2->top == NULL || + aB1->top != aB2->top ) return 0; + + if( winside == 0 ){ + sprintf( token, "%s 队 胜 %s 队。", aB1->teamname, aB2->teamname ); + LogPkContend( aB1->teamname , aB2->teamname, 0, 0, 0, 0); + ABATTLE_RecordBattle( -1, aB1->teamname, "胜", aB2->teamname, ""); + ABATTLE_EnterBattle( aB1); + }else{ + sprintf( token, "%s 队 胜 %s 队。", aB2->teamname, aB1->teamname ); + LogPkContend( aB2->teamname , aB1->teamname, 0, 0, 0, 0); + ABATTLE_RecordBattle( -1, aB1->teamname, "", aB2->teamname, "胜"); + ABATTLE_EnterBattle( aB2); + } + + for( i=0; itop ) InBattle[i] = NULL; + } + + { //广播胜负 + int i; + int playernum = CHAR_getPlayerMaxNum(); + for( i=0; i=40 ) return; + if( side<0 || side >1 ) return; + + PKProcedure[ti].use = 0; + PKProcedure[ti].type = type; + PKProcedure[ti].Team[side].use = 0; + PKProcedure[ti].Team[side].teamnum = -1; + PKProcedure[ti].Team[side].fd = -1; + +} + +BOOL PKLIST_CheckPklistInServerMap( int ti, int side) +{ + if( !CHAR_CHECKINDEX( PKProcedure[ti].Team[side].toindex) || + PKLIST_GetPkTeamListArrayFromNum( PKProcedure[ti].Team[side].teamnum ) == -1 || + PKProcedure[ti].Team[side].fd != getfdFromCharaIndex( PKProcedure[ti].Team[side].toindex) || + CHAR_getInt( PKProcedure[ti].Team[side].toindex, CHAR_FLOOR ) == 8250 ){ + return FALSE; + } + return TRUE; +} + +BOOL PKLIST_CheckPKSameTeam( int charaindex ) +{ + int teamnum, i, meti; + char szMsg[128]; + + if( !CHAR_CHECKINDEX( charaindex) ){ + print( "CHAR_CHECKINDEX err !!\n"); + return FALSE; + } + + if( (teamnum=CHAR_getInt( charaindex, CHAR_PKLISTTEAMNUM)) < 0 ){ + print( "CHAR_PKLISTTEAMNUM err !!\n"); + return FALSE; + } + if( (meti=PKLIST_GetPkTeamListArrayFromNum( teamnum )) == -1 ){ + print( "GetPkTeamListArray err !!\n"); + return FALSE; + } +#ifdef _DEATH_CONTENDAB + if( CHAR_getInt( charaindex, CHAR_PKLISTLEADER) != 1 ){ + return FALSE; + } +#else + if( PkTeamList[meti].battleplay >= DEFMAXBATTLENUM ){ + CHAR_talkToCli( charaindex, -1, "对战场数已满!", CHAR_COLORYELLOW); + return FALSE; + } + + if( CHAR_getInt( charaindex, CHAR_PKLISTLEADER) != 1 ){ + CHAR_talkToCli( charaindex, -1, "只有参赛队伍的队长才能加入赛程喔!", CHAR_COLORYELLOW); + return FALSE; + } +#endif + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_LEADER ){ + return TRUE; + } + + for( i=0; i<5; i++){ + int pindex = CHAR_getWorkInt( charaindex, CHAR_WORKPARTYINDEX1+i); + if( !CHAR_CHECKINDEX( pindex) ) continue; + if( teamnum != CHAR_getInt( pindex, CHAR_PKLISTTEAMNUM) ){ + CHAR_talkToCli( charaindex, -1, "你的队里怎会有不同队伍的人呢?", CHAR_COLORYELLOW); + return FALSE; + } + } + for( i=0; i<5; i++){ + int pindex = CHAR_getWorkInt( charaindex, CHAR_WORKPARTYINDEX1+i); + if(!CHAR_CHECKINDEX(pindex)) continue; + if(CHAR_getInt(pindex,CHAR_LV) < 120){ + sprintf(szMsg,"你的队里 %s 等级 %d 未达比赛标准喔!",CHAR_getChar(pindex,CHAR_NAME),CHAR_getInt(pindex,CHAR_LV)); + CHAR_talkToCli(charaindex,-1,szMsg,CHAR_COLORYELLOW); + return FALSE; + } + if(CHAR_getInt(pindex,CHAR_TRANSMIGRATION) < 3){ + sprintf(szMsg,"你的队里 %s 转生数 %d 转,未达比赛标准喔!",CHAR_getChar(pindex,CHAR_NAME),CHAR_getInt(pindex,CHAR_TRANSMIGRATION)); + CHAR_talkToCli(charaindex,-1,szMsg,CHAR_COLORYELLOW); + return FALSE; + } + } + return TRUE; +} + + +BOOL PKLIST_CheckPKReapetTeam( int menum, int tonum) +{ + int meti, k, toti; + if( (meti=PKLIST_GetPkTeamListArrayFromNum( menum )) == -1 ){ + return FALSE; + } + for( k=0; k (int)time(NULL) ){ + return FALSE; + } + return TRUE; + +} + +void PKLIST_LOCKTeam( int menum) +{ + int meti=-1; + if( (meti=PKLIST_GetPkTeamListArrayFromNum( menum )) == -1 ){ + return; + } + PkTeamList[meti].read = (int)time(NULL)+60; +} + +void PKLIST_UNLOCKTeam( int menum) +{ + int meti=-1; + if( (meti=PKLIST_GetPkTeamListArrayFromNum( menum )) == -1 ){ + return; + } + PkTeamList[meti].read = 0; +} + +void PKLIST_Sort_PKListSort( void) +{ + int i, j, k, last=-1; + char data[65535*3], buf[512]; + for( i=0; i=0; k-- ){ + if( PkTeamList[i].score <= 0 ) continue; + if( PKListSort[k] == -1 ){ + last = k; + continue; + } + if( PkTeamList[i].score > PkTeamList[PKListSort[k]].score ){ + last = k; + continue; + } + break; + } + if( last == -1 ) continue; + for( j=548; j>=last; j-- ){ + PKListSort[j+1] = PKListSort[j]; + } + PKListSort[last]=i; + } + memset(data,0,sizeof(data)); + for(i=0;i<550;i++){ + if(PKListSort[i] == -1) continue; + + sprintf(buf, "%s|%d|%d|%d|%d ", + PkTeamList[PKListSort[i]].teamname, + PkTeamList[PKListSort[i]].win, PkTeamList[PKListSort[i]].lost, + PkTeamList[PKListSort[i]].battleplay, PkTeamList[PKListSort[i]].score ); + strcat(data,buf); + } + PKLIST_HandleChartsMess(0,data,2,0); +} + +//正式赛 + +void ABATTLE_InitABattle( int maxnums ) +{ + int i,j,k; + if( maxnums<1 || maxnums >= MAXBAFLOOR) return; + memset( ABLevelup, 0, sizeof(ABLevelup)); + for( k=0; ktop = NULL; + for( j=0; jfl = 0; + headABattle[i]->code = j; + break; + } + if( j >= MAXNOWBATTLE ) return; + ABATTLE_CreateNet( headABattle[i], i, 0, maxnums); + } + { + FILE *fp=NULL; + int count=0; + char buf[256], buf1[256], buf2[256], filename[256]; + + for( i=0; iteamnum = atoi( buf1); + snprintf( NowABattle[i][maxnums][count]->teamname, + sizeof( NowABattle[i][maxnums][count]->teamname),"%s", buf2); + if( NowABattle[i][maxnums][count]->teamnum >= 0 ) + NowABattle[i][maxnums][count]->use = 1; + + //andy_log + print("NowABattle[%d][%d][%d]. %x[%d,%d,%s]\n", + i, maxnums, count, + NowABattle[i][maxnums][count], + NowABattle[i][maxnums][count]->use, + NowABattle[i][maxnums][count]->teamnum, + NowABattle[i][maxnums][count]->teamname ); + + count++; + } + fclose( fp); + //remove( filename); + } + } + + maxbati = MAXBAHEAD; + maxfloor = maxnums; +} + +int ABATTLE_CreateNet( ArrangeBattleC *now, int ti, int fl, int maxfl) +{ + int i,j; + ArrangeBattleC *news=NULL; + //andy_log + print( "CreateNet( %d,%d)\n", ti, fl); + + if( fl != 0 ){ + for( j=0; j NowABattle[%d][%d][%d]\n", ti, fl, j); + NowABattle[ti][fl][j] = now; + now->fl = fl; + now->code = j; + break; + } + if( j >= MAXNOWBATTLE ) return 0; + } + if( fl < maxfl ){ + for( i=0; i<2; i++){ + + news=NULL; + if( (news = ArrangeBattleC_getNew()) == NULL ){ + //andy_log + print("err can't get news NULL\n"); + return 0; + } + now->next[i] = news; + news->top = now; + if( ABATTLE_CreateNet( news, ti, fl+1, maxfl) == 0 ){ + //andy_log + print("err net free %x \n", news); + free( news ); + now->next[i] = NULL; + return 0; + } + } + } + + return 1; +} + +void ABATTLE_ShowNet( ArrangeBattleC *now, int fl) +{ + int i; + if( now == NULL ) return; + + if( now->fl == fl ){ + print(" [%d,%d,%s] %x,top:%x\n", now->use, now->teamnum, now->teamname, now, + now->top ); + } + + for( i=0; i<2; i++){ + if( now->next[i] == NULL )continue; + ABATTLE_ShowNet( now->next[i], fl); + } +} + +void ABATTLE_ShowBattlefromFl( int ti, int fl) +{ + int j, total=0; + if( fl<0 ) return; + if( ti<0 || ti >= MAXBAHEAD ) return; + print("headABattle:%x\n", headABattle); + ABATTLE_ShowNet( headABattle[ti], fl); + print("\nNOWBATTLE:\n"); + if( fl<0 || fl >= MAXBAFLOOR) return; + + + for( j=0; juse, NowABattle[ti][fl][j]->teamnum, + NowABattle[ti][fl][j]->teamname, NowABattle[ti][fl][j], + NowABattle[ti][fl][j]->top ); + total++; + } + print("\ntotal:%d\n", total); +} + +BOOL ABATTLE_InsertBattle( ArrangeBattleC *aB) +{ + ArrangeBattleC *aBo=NULL; + int i; + if( aB == NULL ) return FALSE; + for( i=0; inext[0])==NULL || aBo->use == 0 || aBo->type > 0 ) return FALSE; + if( (aBo=aB->next[1])==NULL || aBo->use == 0 || aBo->type > 0 ) return FALSE; + InBattle[i] = aB; + InBattle[i]->next[0]->type =1; + InBattle[i]->next[1]->type =1; + + print("InsertBattle[%d,%s vs %d,%s]\n", + InBattle[i]->next[0]->teamnum, InBattle[i]->next[0]->teamname, + InBattle[i]->next[1]->teamnum, InBattle[i]->next[1]->teamname ); +#ifdef _DEATH_CONTENDTEST + aB->time = (int)time(NULL)+30; //战斗时间 +#else + aB->time = (int)time(NULL)+(5*60); //战斗时间 +#endif + aB->type = 1; // 战斗旗标 + return TRUE; + } + return FALSE; +} + +void ABATTLE_EnterBattle( ArrangeBattleC *aB) +{ + ArrangeBattleC *aBtop=NULL; + ArrangeBattleC *aBo=NULL; + + if( (aBtop=aB->top) == NULL ){ + //andy_log + print("del (aBtop=aB->top) NULL !\n"); + return; + } + + aBtop->teamnum = aB->teamnum; + snprintf( aBtop->teamname, sizeof(aBtop->teamname),"%s", aB->teamname); + aBtop->type = 0; + aBtop->use = 1; + + if( (aBo=aBtop->next[0]) != NULL ){ + aBo->use=0; + aBo->teamnum=-1; + } + if( (aBo=aBtop->next[1]) != NULL ){ + aBo->use=0; + aBo->teamnum=-1; + } +} + +void ABATTLE_EliminateBattlefromFl( ArrangeBattleC *aB) +{ + ArrangeBattleC *aBtop=NULL; + if( aB == NULL ) return; + aB->use=0; + aB->type = 0; + aB->teamnum = -1; + free( aB); +} + +int ABATTLE_FindBattlefromFl( int ti, int fl) +{ + int i, j, side=0, count=0; + ArrangeBattleC *aBo=NULL; + ArrangeBattleC *aB1=NULL; + ArrangeBattleC *aB2=NULL; + + //andy_log + print( "FindBattlefromFl(%d,%d)\n", ti, fl); + for( i=0; inext[j]) == NULL || aB1->use == 0 || aB1->type > 0 )continue; + + side = (j+1)%2; + aB2=aBo->next[side]; + + if( aB2 == NULL || aB2->use == 0 || aB2->teamnum == -1 ){ //没有对手 + }else{ + if( ABATTLE_InsertBattle( aBo) == FALSE ){ + return -1; + }else{ + char token[256]; + int playernum = CHAR_getPlayerMaxNum(); + sprintf( token, "%s队 VS %s队 5分钟後决斗。", aB1->teamname, aB2->teamname ); + PKLIST_shoutToAll( token, -1, -1); + count++; + // 把排入赛程的人员传入地图 8250 + for(i=0;iteamnum || CHAR_getInt(i,CHAR_PKLISTTEAMNUM) == aB2->teamnum) && + CHAR_getInt(i,CHAR_FLOOR) != 8250){ + printf("send!!\n"); + CHAR_warpToSpecificPoint(i,8250,15,15); + } + else printf("has not send!!(teamnum:%d,floor:%d)\n",CHAR_getInt(i,CHAR_PKLISTTEAMNUM),CHAR_getInt(i,CHAR_FLOOR)); + } + //if( count >= 2) return count; + return count; + } + } + } + } + return count; +} + +void ABATTLE_CheckBattlefromFl(int charindex, int ti,int battleindex) +{ + int i = ti, count = 0,floor=0; + //ABFloor[MAXBAHEAD]; + //andy_log + print("ABATTLE_CheckBattlefromFl(%d,%d )..\n",ti,battleindex); + //for( i=0; iuse == 1 && headABattle[i]->teamnum != -1 ){ + char token[256]; + sprintf( token, "恭喜 %s 队,取得分组优胜,晋级下一阶段。", headABattle[i]->teamname ); + PKLIST_shoutToAll( token, -1, 8250); + ABATTLE_RecordBattle( i, headABattle[i]->teamname, "晋级8强", "NULL", ""); + + } + if( (fp=fopen( "nbattle.txt", "a+")) != NULL ){ + fprintf( fp, "%d %d|%s|\n", + i, headABattle[i]->teamnum, headABattle[i]->teamname); + fclose( fp); + } + } + } + +} + +int ABATTLE_CheckBattlefromFl_sub(int charindex, int ti, int fl, int battleindex) +{ + int i = battleindex; + char token[256]; + ArrangeBattleC *aBo=NULL; + ArrangeBattleC *aB1=NULL; + ArrangeBattleC *aB2=NULL; + + //andy_log + print("CheckBattlefromFl_sub( %d, %d, %d)\n", ti, fl, battleindex); + + for( i=0; inext[0]; + aB2=aBo->next[1]; + if( (aB1 == NULL || aB1->use == 0 ) && + (aB2 == NULL || aB2->use == 0 ) ){//两队都不成立 + if( aB1 != NULL ) free( aB1); + if( aB2 != NULL ) free( aB2); + aBo->next[0] = NULL; + aBo->next[1] = NULL; + continue; + }else if( aB1 == NULL || aB1->use == 0 || aB1->teamnum == -1 ){ //0不成立 + ABATTLE_EliminateBattlefromFl( aB1); + aBo->next[0] = NULL; + if( aB2 != NULL && aB2->use != 0 && aB2->type == 0 ){ + ABATTLE_EnterBattle( aB2); + } + return fl; + }else if( aB2 == NULL || aB2->use == 0 || aB2->teamnum == -1 ){ //1不成立 + ABATTLE_EliminateBattlefromFl( aB2); + aBo->next[1] = NULL; + if( aB1 != NULL && aB1->use != 0 && aB1->type == 0 ){ + ABATTLE_EnterBattle( aB1); + } + return fl; + }else{ + //andy_log + print("两者成立!.%d.%x[%d,%s] %x[%d,%s]\n", i, + aB1, aB1->teamnum, aB1->teamname, + aB2, aB2->teamnum, aB2->teamname ); + return fl; + } + } + + return (fl-1); +} + +//确认赛程战斗状态 包含时间 +BOOL ABATTLE_CheckInABattle( int ti) +{ + ArrangeBattleC *aB=NULL; + ArrangeBattleC *aB1=NULL; + ArrangeBattleC *aB2=NULL; + int i; + int playernum = CHAR_getPlayerMaxNum(); + char token[256]; + + if( ti<0 || ti>MAXBATTLEPAGE ) return FALSE; + if( (aB=InBattle[ti]) == NULL ) return FALSE; + + aB1=aB->next[0]; + aB2=aB->next[1]; + + switch( aB->type){ + case 0: + break; + case 1: //已排入赛程 5分钟後进场 + if( aB->time < (int)time(NULL) ){ + if( aB1 == NULL || aB1->use == 0 || + aB2 == NULL || aB2->use == 0 ) return FALSE; + sprintf( token, "%s队 VS %s队,赛程即将开始,请两队做好准备。", + aB1->teamname, aB2->teamname ); + //PKLIST_shoutToAll( token, aB1->teamnum, 8250); + PKLIST_shoutToAll( token, aB2->teamnum, 8250); +#ifdef _DEATH_CONTENDTEST + aB->time=(int)time(NULL)+30; +#else + aB->time=(int)time(NULL)+(2*60); +#endif + aB->type=2; + // 把排入赛程的人员传入地图 8250 + for(i=0;iteamnum || CHAR_getInt(i,CHAR_PKLISTTEAMNUM) == aB2->teamnum) && + CHAR_getInt(i,CHAR_FLOOR) != 8250){ + printf("send!!\n"); + CHAR_warpToSpecificPoint(i,8250,15,15); + } + else printf("has not send!!(teamnum:%d,floor:%d)\n",CHAR_getInt(i,CHAR_PKLISTTEAMNUM),CHAR_getInt(i,CHAR_FLOOR)); + } + } + break; + case 2: //已排入赛程 进场3分钟 并判断队长是否存在 并广播 + { + int playernum = CHAR_getPlayerMaxNum(); + for( i=0 ; itoindex) && + aB1->teamnum == CHAR_getInt( i, CHAR_PKLISTTEAMNUM) && + CHAR_getInt( i, CHAR_PKLISTLEADER) == 1 && + PKLIST_CheckPKSameTeam( i) == TRUE ){ + + int stime = ((aB->time)-(int)time(NULL)); + sprintf( token, "请快找齐你的所有队员,并组好队,%d秒後将进行传送。", (stime<0)?0:stime); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW); + aB1->toindex = i; + continue; + + } + if( aB2!=NULL && !CHAR_CHECKINDEX( aB2->toindex) && + aB2->teamnum == CHAR_getInt( i, CHAR_PKLISTTEAMNUM) && + CHAR_getInt( i, CHAR_PKLISTLEADER) == 1 && + PKLIST_CheckPKSameTeam( i) == TRUE ){ + int stime = ((aB->time)-(int)time(NULL)); + sprintf( token, "请快找齐你的所有队员,并组好队,%d秒後将进行传送。", (stime<0)?0:stime); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW); + aB2->toindex = i; + continue; + } + } + } + // 把排入赛程的人员传入地图 8250 + for(i=0;iteamnum || CHAR_getInt(i,CHAR_PKLISTTEAMNUM) == aB2->teamnum) && + CHAR_getInt(i,CHAR_FLOOR) != 8250) CHAR_warpToSpecificPoint(i,8250,15,15); + } + + if( aB->time < (int)time(NULL) ){ + char token[256]; + + sprintf( token, "%s队 VS %s队,赛程开始。", aB1->teamname, aB2->teamname ); + PKLIST_shoutToAll( token, -1, 8250); + + if( CHAR_CHECKINDEX( aB1->toindex) && CHAR_CHECKINDEX( aB2->toindex) ){ + PKLIST_warpOne( aB2->toindex, PK_BATTLEMAP[ti].floor, PK_BATTLEMAP[ti].x+1, PK_BATTLEMAP[ti].y); + PKLIST_warpOne( aB1->toindex, PK_BATTLEMAP[ti].floor, PK_BATTLEMAP[ti].x, PK_BATTLEMAP[ti].y); +#ifdef _DEATH_CONTENDTEST + aB->time=(int)time(NULL)+5; +#else + aB->time=(int)time(NULL)+(20); +#endif + aB->type=3; + return TRUE; + }else if( !CHAR_CHECKINDEX( aB1->toindex) && !CHAR_CHECKINDEX( aB2->toindex) ){ + sprintf( token, "%s队(%d),%s队(%d),因队长未在时间内到场,视为弃权。",aB1->teamname,aB1->toindex, + aB2->teamname,aB2->toindex); + ABATTLE_RecordBattle( ti, aB1->teamname, "未", aB2->teamname, "未"); + aB1->use = 0; + aB2->use = 0; + }else if( !CHAR_CHECKINDEX( aB1->toindex) ) { + sprintf( token, "%s队(%d),因队长未在时间内到场,视为弃权。",aB1->teamname,aB1->toindex); + aB1->use = 0; + ABATTLE_RecordBattle( ti, aB1->teamname, "未", "NULL", ""); + ABATTLE_EnterBattle( aB2); + }else if( !CHAR_CHECKINDEX( aB2->toindex) ){ + sprintf( token, "%s队(%d),因队长未在时间内到场,视为弃权。",aB2->teamname,aB2->toindex); + aB2->use = 0; + ABATTLE_RecordBattle( ti, aB2->teamname, "未", "NULL", ""); + ABATTLE_EnterBattle( aB1); + } + PKLIST_shoutToAll( token, -1, 8250); + InBattle[ti] = NULL; + return FALSE; + } + break; + case 3: //已排入赛程 队伍到齐 5分钟内 强制战斗 + aB->type=4; + aB->time=(int)time(NULL)+(2*60); + break; + case 4: + if( aB->time < (int)time(NULL) ){//强制战斗 + if( CHAR_getWorkInt( aB1->toindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE ){ + //andy_log + print("强制战斗 %s vs %s \n", aB1->teamname, aB2->teamname); + BATTLE_CreateVsPlayer( aB1->toindex, aB2->toindex ); + aB->type = 5; + } + } + break; + } + + return TRUE; +} + +void ABATTLE_MakeInABattleString( void) +{ + ArrangeBattleC *aB=NULL; + ArrangeBattleC *aB1=NULL; + ArrangeBattleC *aB2=NULL; + char buf1[256], buf[256]; + int i, fir=1; + + memset( ABattlelist, 0, sizeof(ABattlelist)); + + for( i=0; inext[0]) == NULL || aB1->use == 0 )continue; + if( (aB2=aB->next[1]) == NULL || aB2->use == 0 )continue; + + switch( aB->type){ + case 0: continue; + break; + case 1://预定 + strcpy( buf, "预定"); + break; + case 2://准备 + strcpy( buf, "准备"); + break; + case 3://开始 + case 4: + strcpy( buf, "开始"); + break; + } + + sprintf( buf1, "%d|%s|%s|%d|%s", + i, aB1->teamname, aB2->teamname, aB->time, buf); + if( fir != 1 ) strcat( ABattlelist, " "); + fir=0; + strcat( ABattlelist, buf1); + } +} + +BOOL PKLIST_GetABattlelistDataString( int ti, int *tindex, int *stimes, + char *buf1, char *buf2, char *buf3, int flg) +{ + char data[1024], buf[256], buff[256]; + switch( flg){ + case 3: + { + memset( data, 0, sizeof(data)); + if( getStringFromIndexWithDelim( ABattlelist, " ", ti, data, sizeof(data)) == FALSE ) + return FALSE; + if( getStringFromIndexWithDelim( data, "|", 1, buf, sizeof( buf)) == FALSE ) return FALSE; + *tindex=atoi( buf); + if( getStringFromIndexWithDelim( data, "|", 2, buf, sizeof( buf))== FALSE) return FALSE; + strcpy( buf1, buf); + if( getStringFromIndexWithDelim( data, "|", 3, buf, sizeof( buf))== FALSE) return FALSE; + strcpy( buf2, buf); + if( getStringFromIndexWithDelim( data, "|", 4, buf, sizeof( buf))== FALSE) return FALSE; + *stimes = atoi( buf); + if( getStringFromIndexWithDelim( data, "|", 5, buf, sizeof( buf))== FALSE ) return FALSE; + strcpy( buf3, buf); + } + break; + case 5: + { + if( getStringFromIndexWithDelim( ABLevelup, " ", ti, data, sizeof(data)) == FALSE ) + return FALSE; + if( getStringFromIndexWithDelim( data, "|", 1, buf, sizeof( buf)) == FALSE ) return FALSE; + *tindex=atoi( buf); + if( getStringFromIndexWithDelim( data, "|", 2, buff, sizeof( buff)) == FALSE ) return FALSE; + if( getStringFromIndexWithDelim( data, "|", 3, buf, sizeof( buf)) == FALSE ) return FALSE; + sprintf( buf1, "[%s]%s ", buff, buf); + if( getStringFromIndexWithDelim( data, "|", 4, buff, sizeof( buff)) == FALSE ) return FALSE; + if( getStringFromIndexWithDelim( data, "|", 5, buf, sizeof( buf)) == FALSE ) return FALSE; + sprintf( buf2, "[%s]%s ", buff, buf); + } + break; + } + return TRUE; +} + +ArrangeBattleC *ABATTLE_getInBattle( int teamnum) +{ + ArrangeBattleC *aB=NULL; + ArrangeBattleC *aBx=NULL; + int i; + + for( i=0; inext[0]) != NULL && aBx->use == 1 && aBx->teamnum != -1 ){ + if( aBx->teamnum == teamnum ) + return aBx; + } + if( (aBx=aB->next[1]) != NULL && aBx->use == 1 && aBx->teamnum != -1 ){ + if( aBx->teamnum == teamnum ) + return aBx; + } + } + return NULL; +} + +ArrangeBattleC *ArrangeBattleC_getNew( void) +{ + ArrangeBattleC *MBUF=NULL; + MBUF = (ArrangeBattleC *) calloc( 1, sizeof( struct _tagArrangeBattle) ); + if( MBUF == NULL ) return NULL; + + MBUF->use = 0; + MBUF->fl = -1; + MBUF->code = -1; + MBUF->teamnum = -1; + MBUF->toindex = -1; + MBUF->type=0; + MBUF->teamname[0]=0; + MBUF->next[0] = NULL; + MBUF->next[1] = NULL; + MBUF->top = NULL; + + return MBUF; +} + +ArrangeBattleC *ArrangeBattleC_getInBattleArray( int ti) +{ + if( ti<0 || ti>MAXBATTLEPAGE ) return NULL; + return InBattle[ti]; +} + +void ABATTLE_RecordBattle( int ti, char *buf1, char *tstr1,char *buf2, char *tstr2) +{//ABLevelup + char strlog[512]; + FILE *fp=NULL; + + if( (fp=fopen( "battle.rec", "a+") )==NULL )return; + sprintf( strlog, "%d|%s|%s|%s|%s", ti, tstr1, buf1, tstr2, buf2); + fprintf( fp, "%s\n", strlog); + fclose( fp); + + ABATTLE_GetRecordBattle(); +} + +void remove_r( char *s ) +{ + int i; + for(i=0;;i++){ + if( s[i]=='\r' || s[i]=='\n' )s[i] =0; + if( s[i]==0)break; + } +} + +void ABATTLE_GetRecordBattle( void) +{//ABLevelup + char data[512]; + FILE *fp=NULL; + memset( ABLevelup, 0, sizeof(ABLevelup)); + + if( (fp=fopen( "battle.rec", "r") )==NULL )return; + while( fgets( data, sizeof(data)-1, fp) ){ + if( strlen( data) <= 0 ) continue; + remove_r( data); + if( strlen( ABLevelup) > 0 ) strcat( ABLevelup, " "); + strcat( ABLevelup, data); + } + fclose( fp); +} + +void PKLIST_UpData(char *mycdkey,char *tocdkey,int menum,int tonum,int winer,int flg) +{ + int k,meti,toti; + + if((meti = PKLIST_GetPkTeamListArray(menum,mycdkey)) == -1){ + printf("can't find meteam.teamnum(%d),cdkey(%s)\n",menum,mycdkey); + return; + } + if((toti = PKLIST_GetPkTeamListArray(tonum,tocdkey)) == -1){ + printf("can't find toteam.teamnum(%d),cdkey(%s)\n",tonum,tocdkey); + return; + } + + if(PkTeamList[meti].use != 1){ + printf("meteam not in use.teamnum(%d),cdkey(%s)\n",menum,mycdkey); + return; + } + /*for(k=0;k= 90 ){ + PkTeamList[ti].inside = 2; //录取 + }else if( PkTeamList[ti].lost > 50*0.4){// 0.7 = (1-胜率3成)*最高场次 + PkTeamList[ti].inside = 0; + }else { + PkTeamList[ti].inside = 1; + } + + if( PkTeamList[ti].score < 0 ) PkTeamList[ti].score = 0; + + ret = PKLIST_SetOneBHistory( ti, battleTi, 1, forti, winerflg); + //PKLIST_SortTheCharts( ti); + return ret; +} + +int PKLIST_GetOneBHistory( int ti ) +{ + int i; + if( ti < 0 || ti >= maxteam ){ + printf( "GetOneBHistory(ti:%d) err return -1 !!\n", ti); + return -1; + } + for( i=0; i=DEFMAXBATTLENUM ) break; + if( PkTeamList[ti].BHistory[i].use == 0 ){ + printf("return BHistory[%d] \n", i) ; + return i; + } + } + + printf("BATTLEFULL err !! \n") ; + return -1; +} + +int PKLIST_SetOneBHistory( int ti, int hi, int use, int teamnum, int flg ) +{ + if( ti < 0 || ti >= maxteam ) return -1; + if( hi < 0 || hi >= MAXBATTLENUM ) return -1; + if( PkTeamList[ti].BHistory[hi].use == use ) return -1; + + PkTeamList[ti].BHistory[hi].teamnum = teamnum; + PkTeamList[ti].BHistory[hi].flg = flg; + PkTeamList[ti].BHistory[hi].use = use; + return 1; +} + +#endif diff --git a/gmsv/char/defaultGroundEnemy.h b/gmsv/char/defaultGroundEnemy.h new file mode 100644 index 0000000..757b28d --- /dev/null +++ b/gmsv/char/defaultGroundEnemy.h @@ -0,0 +1,158 @@ +#if 0 +static Char slime= +{ + FALSE, /* use どうでもいい*/ + + /* data */ + { + 0, /* CHAR_DATAPLACENUMBER */ + 0, /* CHAR_BASEIMAGENUMBER */ + 0, /* CHAR_BASEBASEIMAGENUMBER */ + 0, /* CHAR_FACEIMAGENUMBER */ + 0, /* CHAR_FLOOR */ + 0, /* CHAR_X */ + 0, /* CHAR_Y */ + 0, /* CHAR_DIR 12箕を0に箕纷件りに */ + 0, /* CHAR_LV */ + 0, /* CHAR_GOLD */ + 1, /* CHAR_HP */ + 0, /* CHAR_MP */ + 0, /* CHAR_MAXMP */ + + 0, /* CHAR_VITAL */ + 0, /* CHAR_STR */ + 0, /* CHAR_TOUGH */ + 0, /* CHAR_DEX */ + + 0, /* CHAR_CHARM */ + 0, /* CHAR_LUCK */ + + 0, /* 孟掳拉 */ + 0, /* 垮掳拉 */ + 0, /* 残掳拉 */ + 0, /* 慎掳拉 */ + + 0, /* CHAR_SLOT */ + 0, /* CHAR_CRITIAL */ + 0, /* CHAR_COUNTER */ + 0, /* CHAR_RARE */ + 0, /* CHAR_RADARSTRLENGTH */ + 0, /* CHAR_CHATVOLUME */ + MAKE2VALUE(100,20), /* CHAR_MERCHANTLEVEL */ + 0, /* CHAR_HEALERLEVEL */ + 0, /* CHAR_DETERMINEITEM */ + + -1, /* CHAR_INDEXOFEQTITLE */ + + 0, /* CHAR_POISON */ + 0, /* CHAR_PARALYSIS */ + 0, /* CHAR_SILENCE */ + 0, /* CHAR_STONE */ + 0, /* CHAR_DARKNESS */ + 0, /* CHAR_CONFUSION */ + + 0, /* CHAR_LOGINCOUNT */ + 0, /* CHAR_DEADCOUNT */ + 0, /* CHAR_WALKCOUNT */ + 0, /* CHAR_TALKCOUNT */ + 0, /* CHAR_DAMAGECOUNT */ + 0, /* CHAR_GETPETCOUNT */ + 0, /* CHAR_KILLPETCOUNT */ + 0, /* CHAR_DEADPETCOUNT */ + 0, /* CHAR_SENDMAILCOUNT */ + 0, /* CHAR_MERGEITEMCOUNT */ + 0, /* CHAR_DUELBATTLECOUNT */ + 0, /* CHAR_DUELWINCOUNT */ + 0, /* CHAR_DUELLOSECOUNT */ + 0, /* CHAR_DUELSTWINCOUNT */ + 0, /* CHAR_DUELMAXSTWINCOUNT */ + + CHAR_TYPEENEMY, /* CHAR_WHICHPLAYER */ + 1000, /* CHAR_WALKINTERVAL */ + 1000, /* CHAR_LOOPINTERVAL */ + + 0, /* CHAR_LEVELEXP */ + + -1, /*CHAR_LASTTALKELDER*/ + 0, /*CHAR_SKILLUPPOINT */ + 0, /* CHAR_LEVELUPPOINT */ + + 0, /*CHAR_IMAGETYPE */ + CHAR_COLORYELLOW, /* CHAR_NAMECOLOR */ + CHAR_COLORYELLOW, /* CHAR_POPUPNAMECOLOR */ + 0, /* CHAR_LASTTIMESETLUCK */ + 0, /* CHAR_DUELPOINT */ + 0, /* CHAR_EVENT */ + 0, /* CHAR_EVENT2 */ + 0, /* CHAR_EVENT3 */ +#ifdef _NEWEVENT + 0, /* CHAR_EVENT4 */ + 0, /* CHAR_EVENT5 */ + 0, /* CHAR_EVENT6 */ +#endif + 0, /* CHAR_NOWEVENT */ + 0, /* CHAR_NOWEVENT2 */ + 0, /* CHAR_NOWEVENT3 */ +#ifdef _NEWEVENT + 0, /* CHAR_NOWEVENT4 */ + 0, /* CHAR_NOWEVENT5 */ + 0, /* CHAR_NOWEVENT6 */ +#endif + 0, /* CHAR_TRANSMIGRATION */ + 0, /* CHAR_TRANSEQUATION */ + + 0, /*CHAR_INITDATA */ + }, + { + {""}, /* CHAR_NAME */ + {""}, /* CHAR_OWNTITLE */ + {""}, /* CHAR_ARGUMENT */ + {""}, /* CHAR_OWNERCDKEY */ + {""}, /* CHAR_OWNERCHARANAME */ +#if 0 + {""}, /* CHAR_INITFUNC */ + {""}, /* CHAR_WALKPREFUNC */ + {""}, /* CHAR_WALKPOSTFUNC */ + {""}, /* CHAR_PREOVERFUNC */ + {""}, /* CHAR_PREOVERFUNC */ + {""}, /* CHAR_WATCHFUNC */ + {""}, /* CHAR_LOOPFUNC */ + {""}, /* CHAR_DYINGFUNC */ + {""}, /* CHAR_TALKEDFUNC */ + {""}, /* CHAR_PREATTACKEDFUNC */ + {""}, /* CHAR_POSTATTACKEDFUNC */ + {""}, /* CHAR_OFFFUNC */ + {""}, /* CHAR_LOOKEDFUNC */ + {""}, /* CHAR_ITEMPUTFUNC */ + {""}, /* CHAR_SPECIALTALKEDFUNC */ + {""}, /* CHAR_WINDOWTALKEDFUNC */ +#endif + }, + { + /* CHAR_ISATTACK */ + /* CHAR_ISATTACKED */ + /* CHAR_ISOVER */ + /* CHAR_ISOVERED */ + /* CHAR_HAVEHEIGHT */ + /* CHAR_ISVISIBLE */ + /* CHAR_ISTRANSPARENT */ + /* CHAR_ISFLYING */ + + SETFLG(1,1,1,1,1,1,0,0 ), + + /* CHAR_ISDIE */ + /* CHAR_ISBIG */ + /* CHAR_ISSHOWDAMAGE */ + /* CHAR_ISPARTY */ + /* CHAR_ISWARP */ + /* CHAR_ISDUEL */ + /* CHAR_ISPARTYCHAT */ + /* CHAR_ISTRADECARD */ + + SETFLG(0,0,1,0,0,0,0,0 ), + } +}; +#endif + + + diff --git a/gmsv/char/defaultPlayer.h b/gmsv/char/defaultPlayer.h new file mode 100644 index 0000000..a1730a3 --- /dev/null +++ b/gmsv/char/defaultPlayer.h @@ -0,0 +1,372 @@ +#include "version.h" + +static Char player= +{ + FALSE, /* use どうでもいい*/ + { + 0, /* CHAR_DATAPLACENUMBER */ + 0, /* CHAR_BASEIMAGENUMBER */ + 0, /* CHAR_BASEBASEIMAGENUMBER */ + 0, /* CHAR_FACEIMAGENUMBER */ + 0, /* CHAR_FLOOR */ + 0, /* CHAR_X */ + 0, /* CHAR_Y */ + 5, /* CHAR_DIR 12箕を0に箕纷件りに */ + 1, /* CHAR_LV */ + 0, /* CHAR_GOLD */ + 1, /* CHAR_HP */ + 0, /* CHAR_MP */ + + 0, /* CHAR_MAXMP */ + + 0, /* CHAR_VITAL */ + 0, /* CHAR_STR */ + 0, /* CHAR_TOUGH */ + 0, /* CHAR_DEX */ + + 0, /* CHAR_CHARM */ + 0, /* CHAR_LUCK */ + + 0, /* 孟掳拉 */ + 0, /* 垮掳拉 */ + 0, /* 残掳拉 */ + 0, /* 慎掳拉 */ + + 0, /* CHAR_SLOT*/ + 0, /* CHAR_CRITIAL */ + 0, /* CHAR_COUNTER */ + 0, /* CHAR_RARE */ + 0, /* CHAR_RADARSTRLENGTH */ + 0, /* CHAR_CHATVOLUME */ + MAKE2VALUE(100,20), /* CHAR_MERCHANTLEVEL */ + 0, /* CHAR_HEALERLEVEL */ + 0, /* CHAR_DETERMINEITEM */ + + -1, /* CHAR_INDEXOFEQTITLE */ + + + 0, /* CHAR_POISON */ + 0, /* CHAR_PARALYSIS */ + 0, /* CHAR_SILENCE */ + 0, /* CHAR_STONE */ + 0, /* CHAR_DARKNESS */ + 0, /* CHAR_CONFUSION */ + + 0, /* CHAR_LOGINCOUNT */ + 0, /* CHAR_DEADCOUNT */ + 0, /* CHAR_WALKCOUNT */ + 0, /* CHAR_TALKCOUNT */ + + 0, /* CHAR_DAMAGECOUNT */ + 0, /* CHAR_GETPETCOUNT */ + 0, /* CHAR_KILLPETCOUNT */ + 0, /* CHAR_DEADPETCOUNT */ + 0, /* CHAR_SENDMAILCOUNT */ + 0, /* CHAR_MERGEITEMCOUNT */ + + 0, /* CHAR_DUELBATTLECOUNT */ + 0, /* CHAR_DUELWINCOUNT */ + 0, /* CHAR_DUELLOSECOUNT */ + 0, /* CHAR_DUELSTWINCOUNT */ + 0, /* CHAR_DUELMAXSTWINCOUNT */ + + CHAR_TYPEPLAYER, /* CHAR_WHICHTYPE */ + 1000, /* CHAR_WALKINTERVAL */ + 1000, /* CHAR_LOOPINTERVAL */ +#ifdef _NEWOPEN_MAXEXP + 0, // CHAR_OLDEXP, +#endif + 0, // CHAR_EXP, + -1, /* CHAR_LASTTALKELDER*/ + 0, /* CHAR_SKILLUPPOINT */ + 0, /* CHAR_LEVELUPPOINT */ + + 0, /* CHAR_IMAGETYPE */ + CHAR_COLORWHITE, /* CHAR_NAMECOLOR */ + CHAR_COLORWHITE, /* CHAR_POPUPNAMECOLOR */ + 0, /* CHAR_LASTTIMESETLUCK */ + 100, /* CHAR_DUELPOINT */ + 0, /* CHAR_EVENT */ + 0, /* CHAR_EVENT2 */ + 0, /* CHAR_EVENT3 */ +#ifdef _NEWEVENT + 0, /* CHAR_EVENT4 */ + 0, /* CHAR_EVENT5 */ + 0, /* CHAR_EVENT6 */ +#endif +#ifdef _ADD_NEWEVENT + 0, /* CHAR_EVENT7 */ + 0, /* CHAR_EVENT8 */ +#endif + + 0, /* CHAR_NOWEVENT */ + 0, /* CHAR_NOWEVENT2 */ + 0, /* CHAR_NOWEVENT3 */ +#ifdef _NEWEVENT + 0, /* CHAR_NOWEVENT4 */ + 0, /* CHAR_NOWEVENT5 */ + 0, /* CHAR_NOWEVENT6 */ +#endif +#ifdef _ADD_NEWEVENT + 0, /* CHAR_NOWEVENT7 */ + 0, /* CHAR_NOWEVENT8 */ +#endif + + 0, /* CHAR_TRANSMIGRATION */ + 0, /* CHAR_TRANSEQUATION */ + + 0, /* CHAR_INITDATA */ + +//#ifdef _PETSKILL_BECOMEPIG +// -1, +//#endif + + 0, //CHAR_SILENT, /* char shutup time */ + 0, // CHAR_FMINDEX, // 產壁 index + 0, // CHAR_FMLEADERFLAG, + /* 產壁Θ贺摸 + * FMMEMBER_NONE :⊿Τヴ產壁 + * FMMEMBER_APPLY :ビ叫產壁い + * FMMEMBER_LEADER :壁 + * FMMEMBER_MEMBER :Θ + * FMMEMBER_ELDER :ρ + * FMMEMBER_INVITE :步 // 既ぃノ + * FMMEMBER_BAILEE :癩叭 // 既ぃノ + * FMMEMBER_VICELEADER :捌壁 // 既ぃノ + */ + 0, // CHAR_FMSPRITE, // 產壁臔弘艶 + + 0, // CHAR_BANKGOLD, + 0, // CHAR_RIDEPET, + 0, // CHAR_LEARNRIDE, +#ifdef _NEW_RIDEPETS + 0, // CHAR_LOWRIDEPETS, +#endif + 0, // CHAR_LIMITLEVEL, +#ifdef _PET_FUSION + 0, // CHAR_FUSIONCODE, //贺絪絏 + 0, // CHAR_FUSIONINDEX, //瑰て胐絪腹 + 0, // CHAR_FUSIONRAISE, //笼緄Ω计 + 0, // CHAR_FUSIONBEIT, //胐矹篨夹 + 0, // CHAR_FUSIONTIMELIMIT, //笼緄丁 +#endif + +#ifdef _DEATH_CONTEND + 0, // CHAR_PKLISTTEAMNUM, + 0, // CHAR_PKLISTLEADER, +#endif + +#ifdef _PERSONAL_FAME // Arminius 8.30: 產壁羘辨 + 0, // CHAR_FAME, +#endif + +#ifdef _NEWSAVE + 0, // CHAR_SAVEINDEXNUMBER, /* SaveFile .0.char or .1.char */ +#endif + +#ifdef __ATTACK_MAGIC + 0, // CHAR_EARTH_EXP, // 產臸猭剪絤 + 0, // CHAR_WATER_EXP, // 產臸猭剪絤 + 0, // CHAR_FIRE_EXP, // 產臸猭剪絤 + 0, // CHAR_WIND_EXP, // 產臸猭剪絤 + 0, // CHAR_EARTH_RESIST, // 產臸猭к┦ + 0, // CHAR_WATER_RESIST, // 產臸猭к┦ + 0, // CHAR_FIRE_RESIST, // 產臸猭к┦ + 0, // CHAR_WIND_RESIST, // 產臸猭к┦ + 0, // CHAR_EARTH_ATTMAGIC_EXP, // 產臸猭剪絤竒喷 + 0, // CHAR_WATER_ATTMAGIC_EXP, // 產臸猭剪絤竒喷 + 0, // CHAR_FIRE_ATTMAGIC_EXP, // 產臸猭剪絤竒喷 + 0, // CHAR_WIND_ATTMAGIC_EXP, // 產臸猭剪絤竒喷 + 0, // CHAR_EARTH_DEFMAGIC_EXP, // 產臸猭к┦竒喷 + 0, // CHAR_WATER_DEFMAGIC_EXP, // 產臸猭к┦竒喷 + 0, // CHAR_FIRE_DEFMAGIC_EXP, // 產臸猭к┦竒喷 + 0, // CHAR_WIND_DEFMAGIC_EXP, // 產臸猭к┦竒喷 +#endif + + +#ifdef _GAMBLE_BANK + 0, // CHAR_PERSONAGOLD, //戒初蝗︽ +#endif +#ifdef _DROPSTAKENEW + 0, // CHAR_GAMBLENUM, //戒初縩だ +#endif +#ifdef _ADD_ACTION //npc笆 + 0, // CHAR_ACTIONSTYLE, +#endif +#ifdef _AUCTIONEER + 0, // CHAR_AUCGOLD, // ╃芥┮眔 +#endif +#ifdef _PET_EVOLUTION + 0, // CHAR_EVOLUTIONBASEVTL, + 0, // CHAR_EVOLUTIONBASESTR, + 0, // CHAR_EVOLUTIONBASETGH, + 0, // CHAR_EVOLUTIONBASEDEX, +#endif +#ifdef _ACTION_BULLSCR + 0, // CHAR_ABULLSTART, + 0, // CHAR_ABULLSCORE, + 0, // CHAR_ABULLTIME, + 0, // CHAR_ABULLSTARTTIME, +#endif + +#ifdef _ACTION_GMQUE + 0, // CHAR_GMQUEFLG, + 0, // CHAR_GMQUENUMS, +#endif + +#ifdef _FAMILYBANKSTONELOG + 0, // CHAR_FMBANKGOLD, //產壁蝗︽蹿 +#endif + +#ifdef _FM_JOINLIMIT + 0, // CHAR_FMTIMELIMIT, +#endif + +#ifdef _CHAR_PROFESSION // WON ADD 戮穨 + 0, // PROFESSION_CLASS, // 戮穨 + 0, // PROFESSION_LEVEL, // 戮穨单 +// 0, // PROFESSION_EXP, // 戮穨竒喷 + 0, // PROFESSION_SKILL_POINT, // м翴计 + 0, // ATTACHPILE, // 糤帮舼 + 0, // PROFESSION_FIRE_P, // 剪絤 + 0, // PROFESSION_ICE_P, // 剪絤 + 0, // PROFESSION_THUNDER_P, // 筽剪絤 + 0, // PROFESSION_FIRE_R, // к┦ + 0, // PROFESSION_ICE_R, // к┦ + 0, // PROFESSION_THUNDER_R, // 筽к┦ +#endif +#ifdef _ALLDOMAN // (ぃ秨) Syu ADD 逼︽篯NPC + 0, // CHAR_HEROFLOOR, +#endif +#ifdef _PETSKILL_BECOMEPIG + -1, // CHAR_BECOMEPIG, + 100250, //CHAR_BECOMEPIG_BBI +#endif + 0, // CHAR_LASTLEAVETIME, // Robin add 程瞒絬丁 + +#ifdef _NEW_MANOR_LAW + 0, // CHAR_MOMENTUM, +#endif + +#ifdef _ITEM_ADDEXP2 + 0, // CHAR_ADDEXPPOWER, + 0, // CHAR_ADDEXPTIME, +#endif + +#ifdef _ANGEL_SUMMON + 0, // CHAR_HEROCNT, // ЧΘ玦ヴ叭Ω计 +#endif + +#ifdef _RACEMAN + 0, // CHAR_CHECKIN, //胐琌祅癘 + 0, // CHAR_CATCHCNT, //聐胐Ω计 + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, +#endif + + }, + + { + {""}, /* CHAR_NAME */ + {""}, /* CHAR_OWNTITLE */ + {""}, /* CHAR_ARGUMENT */ + {""}, /* CHAR_OWNERCDKEY */ + {""}, /* CHAR_OWNERCHARANAME */ +#if 0 + {""}, /* CHAR_INITFUNC */ + {"core_PreWalk"}, /* CHAR_WALKPREFUNC */ + {"core_PostWalk"}, /* CHAR_WALKPOSTFUNC */ + {""}, /* CHAR_PREOVERFUNC */ + {""}, /* CHAR_PREOVERFUNC */ + {"core_PlayerWatch"}, /* CHAR_WATCHFUNC */ + {"core_Loop"}, /* CHAR_LOOPFUNC */ + {"core_Dying"}, /* CHAR_DYINGFUNC */ + {"core_PlayerTalked"}, /* CHAR_TALKEDFUNC */ + {""}, /* CHAR_PREATTACKEDFUNC */ + {""}, /* CHAR_POSTATTACKEDFUNC */ + {""}, /* CHAR_OFFFUNC */ + {""}, /* CHAR_LOOKEDFUNC */ + {""}, /* CHAR_ITEMPUTFUNC */ + {""}, /* CHAR_SPECIALTALKEDFUNC */ + {""}, /* CHAR_WINDOWTALKEDFUNC */ +#endif + }, + { + SETFLG(1,1,1,1,1,1,0,0 ), + SETFLG(0,0,0,0,0,0,0,1 ), + } +}; + +LevelUpPattern lvplayer00={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer10={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer20={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer30={ {{100,10},{200,10},{50,8}},9,11,10}; + +LevelUpPattern lvplayer01={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer11={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer21={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer31={ {{100,10},{200,10},{50,8}},9,11,10}; + +LevelUpPattern lvplayer02={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer12={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer22={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer32={ {{100,10},{200,10},{50,8}},9,11,10}; + +LevelUpPattern lvplayer03={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer13={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer23={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer33={ {{100,10},{200,10},{50,8}},9,11,10}; + +LevelUpPattern lvplayer04={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer14={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer24={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer34={ {{100,10},{200,10},{50,8}},9,11,10}; + +LevelUpPattern lvplayer05={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer15={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer25={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer35={ {{100,10},{200,10},{50,8}},9,11,10}; + +LevelUpPattern lvplayer06={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer16={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer26={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer36={ {{100,10},{200,10},{50,8}},9,11,10}; + +LevelUpPattern lvplayer07={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer17={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer27={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer37={ {{100,10},{200,10},{50,8}},9,11,10}; + +LevelUpPattern lvplayer08={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer18={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer28={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer38={ {{100,10},{200,10},{50,8}},9,11,10}; + +LevelUpPattern lvplayer09={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer19={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer29={ {{100,10},{200,10},{50,8}},9,11,10}; +LevelUpPattern lvplayer39={ {{100,10},{200,10},{50,8}},9,11,10}; + + diff --git a/gmsv/char/defend.c b/gmsv/char/defend.c new file mode 100644 index 0000000..98aa369 --- /dev/null +++ b/gmsv/char/defend.c @@ -0,0 +1,29 @@ +#include "version.h" +#include +#include +#include +#include + +#include "readmap.h" +#include "object.h" +#include "char.h" +#include "char_base.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "npcutil.h" +#include "family.h" +#include "log.h" +#include "handletime.h" +#include "buf.h" +#include "net.h" +#include "char_base.h" +#include "battle.h" +#include "npc_bus.h" +#include "char_talk.h" +#include "npc_scheduleman.h" +#include "defend.h" + + + + + diff --git a/gmsv/char/encount.c b/gmsv/char/encount.c new file mode 100644 index 0000000..000213c --- /dev/null +++ b/gmsv/char/encount.c @@ -0,0 +1,597 @@ +#include "version.h" +#include +#include +#include +#ifdef _REDHAT_V9 +#include +#endif + +#include "common.h" +#include "util.h" +#include "buf.h" +#include "char_base.h" +#include "char.h" +#include "configfile.h" +#include "encount.h" +#include "enemy.h" + +#ifdef _ADD_ENCOUNT // WON ADD 增加敌遭遇触发修件 +#include "encount.h" +#endif + +/* 巨件市它件玄楮 及末□旦 */ + +#ifndef _ADD_ENCOUNT // WON ADD 增加敌遭遇触发修件 +typedef struct tagENCOUNT_Table +{ + int index; + int floor; + int encountprob_min; /* 巨件市它件玄割 */ + int encountprob_max; /* 巨件市它件玄割 */ + int enemymaxnum; /* 升木分仃衬毛综月井 */ + int zorder; + int groupid[ENCOUNT_GROUPMAXNUM]; /* 弘伙□皿No */ + int createprob[ENCOUNT_GROUPMAXNUM]; /* 公及弘伙□皿及请蜇 */ + RECT rect; +}ENCOUNT_Table; +ENCOUNT_Table *ENCOUNT_table; +#endif + +int ENCOUNT_encountnum; +#define ENCOUNT_ENEMYMAXCREATENUM 10 + +static INLINE BOOL ENCOUNT_CHECKENCOUNTTABLEARRAY( int array) +{ + if( array < 0 || array > ENCOUNT_encountnum-1) return FALSE; + return TRUE; +} + +/*------------------------------------------------------------ + * 巨件市它件玄涩烂及赓渝祭毛允月[ + * 娄醒 + * filename char* 涩烂白央奶伙 + * 忒曰袄 + * 岳 TRUE(1) + * 撩 FALSE(0) + *------------------------------------------------------------*/ +BOOL ENCOUNT_initEncount( char* filename ) +{ + FILE* f; + char line[256]; + int linenum=0; + int encount_readlen=0; + + f = fopen(filename,"r"); + if( f == NULL ){ + errorprint; + return FALSE; + } + + ENCOUNT_encountnum=0; + + /* 引内 躲卅垫互窒垫丐月井升丹井譬屯月 */ + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + + ENCOUNT_encountnum++; + } + + if( fseek( f, 0, SEEK_SET ) == -1 ){ + fprint( "寻找错误\n" ); + fclose(f); + return FALSE; + } + + ENCOUNT_table = allocateMemory( sizeof(struct tagENCOUNT_Table) + * ENCOUNT_encountnum ); + if( ENCOUNT_table == NULL ){ + fprint( "无法分配内存 %d\n" , + sizeof(ENCOUNT_table)*ENCOUNT_encountnum); + fclose( f ); + return FALSE; + } + + /* 赓渝祭 */ +{ + int i,j; + for( i = 0; i < ENCOUNT_encountnum; i ++ ) { + ENCOUNT_table[i].index = -1; + ENCOUNT_table[i].floor = 0; + ENCOUNT_table[i].encountprob_min = 1; + ENCOUNT_table[i].encountprob_min = 50; + ENCOUNT_table[i].enemymaxnum = 4; + ENCOUNT_table[i].rect.x = 0; + ENCOUNT_table[i].rect.y = 0; + ENCOUNT_table[i].rect.height = 0; + ENCOUNT_table[i].rect.width = 0; + ENCOUNT_table[i].zorder = 0; + for( j = 0; j < ENCOUNT_GROUPMAXNUM; j ++ ) { + ENCOUNT_table[i].groupid[j] = -1; + ENCOUNT_table[i].createprob[j] = -1; + } +#ifdef _ADD_ENCOUNT // WON ADD 增加敌遭遇触发修件 + ENCOUNT_table[i].event_now = -1; + ENCOUNT_table[i].event_end = -1; + ENCOUNT_table[i].enemy_group = -1; +#endif + } +} + + /* 引凶 心 允 */ + linenum = 0; + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + + /* 垫毛帮溥允月 */ + /* 引内 tab 毛 " " 卞 五晶尹月 */ + replaceString( line, '\t' , ' ' ); + /* 燮 及旦矢□旦毛潸月[*/ +{ + int i; + char buf[256]; + for( i = 0; i < strlen( line); i ++) { + if( line[i] != ' ' ) { + break; + } + strcpy( buf, &line[i]); + } + if( i != 0 ) { + strcpy( line, buf); + } +} +{ + char token[256]; + int ret; + int x1,x2,y1,y2; + int j; + + /* 蘸户及伙□皿卞 匀凶凛及啃及赓渝祭 */ + ENCOUNT_table[encount_readlen].index = -1; + ENCOUNT_table[encount_readlen].floor = 0; + ENCOUNT_table[encount_readlen].encountprob_min = 1; + ENCOUNT_table[encount_readlen].encountprob_min = 50; + ENCOUNT_table[encount_readlen].enemymaxnum = 4; + ENCOUNT_table[encount_readlen].rect.x = 0; + ENCOUNT_table[encount_readlen].rect.y = 0; + ENCOUNT_table[encount_readlen].rect.height = 0; + ENCOUNT_table[encount_readlen].rect.width = 0; + ENCOUNT_table[encount_readlen].zorder = 0; + for( j = 0; j < ENCOUNT_GROUPMAXNUM; j ++ ) { + ENCOUNT_table[encount_readlen].groupid[j] = -1; + ENCOUNT_table[encount_readlen].createprob[j] = -1; + } +#ifdef _ADD_ENCOUNT // WON ADD 增加敌遭遇触发修件 + ENCOUNT_table[encount_readlen].event_now = -1; + ENCOUNT_table[encount_readlen].event_end = -1; + ENCOUNT_table[encount_readlen].enemy_group = -1; +#endif + + + /* 夫午勾户及玄□弁件毛苇月 */ + ret = getStringFromIndexWithDelim( line,",",1,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + continue; + } + ENCOUNT_table[encount_readlen].index = atoi(token); + + /* 2勾户及玄□弁件毛苇月 */ + ret = getStringFromIndexWithDelim( line,",",2,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + continue; + } + ENCOUNT_table[encount_readlen].floor = atoi(token); + + /* 3勾户及玄□弁件毛苇月 */ + ret = getStringFromIndexWithDelim( line,",",3,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + continue; + } + x1 = atoi(token); + + /* 4勾户及玄□弁件毛苇月 */ + ret = getStringFromIndexWithDelim( line,",",4,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + continue; + } + y1= atoi(token); + + /* 5勾户及玄□弁件毛苇月 */ + ret = getStringFromIndexWithDelim( line,",",5,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + continue; + } + + x2 = atoi(token); + + /* 6勾户及玄□弁件毛苇月 */ + ret = getStringFromIndexWithDelim( line,",",6,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + continue; + } + y2= atoi(token); + + ENCOUNT_table[encount_readlen].rect.x = min(x1,x2); + ENCOUNT_table[encount_readlen].rect.width = max(x1,x2) - min(x1,x2); + ENCOUNT_table[encount_readlen].rect.y = min(y1,y2); + ENCOUNT_table[encount_readlen].rect.height = max(y1,y2) - min(y1,y2); + + /* 7户及玄□弁件毛苇月 */ + ret = getStringFromIndexWithDelim( line,",",7,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + continue; + } + ENCOUNT_table[encount_readlen].encountprob_min = atoi(token); + + /* 8户及玄□弁件毛苇月 */ + ret = getStringFromIndexWithDelim( line,",",8,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + continue; + } + ENCOUNT_table[encount_readlen].encountprob_max = atoi(token); + +{ + int a,b; + a = ENCOUNT_table[encount_readlen].encountprob_min; + b = ENCOUNT_table[encount_readlen].encountprob_max; + /* 凝及譬帮 */ + ENCOUNT_table[encount_readlen].encountprob_min + = min( a,b); + ENCOUNT_table[encount_readlen].encountprob_max + = max( a,b); +} + /* 9勾户及玄□弁件毛苇月 */ + ret = getStringFromIndexWithDelim( line,",",9,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + continue; + } + { + int maxnum = atoi( token); + /* 醒及恳癫岭及民尼永弁 */ + if( maxnum < 1 || maxnum > ENCOUNT_ENEMYMAXCREATENUM ) { + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + continue; + } + ENCOUNT_table[encount_readlen].enemymaxnum = maxnum; + } + /* 10户及玄□弁件毛苇月 */ + ret = getStringFromIndexWithDelim( line,",",10,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + continue; + } + ENCOUNT_table[encount_readlen].zorder = atoi(token); + #define CREATEPROB_TOKEN 11 + + /* 11 31户及玄□弁件毛苇月 */ + { + int i; + + for( i = CREATEPROB_TOKEN; i < CREATEPROB_TOKEN +ENCOUNT_GROUPMAXNUM*2; i ++) { + ret = getStringFromIndexWithDelim( line,",",i,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + continue; + } + if( strlen( token) != 0 ) { + if( i < CREATEPROB_TOKEN + ENCOUNT_GROUPMAXNUM ) { + ENCOUNT_table[encount_readlen].groupid[i-CREATEPROB_TOKEN] + = atoi(token); + } + else { + ENCOUNT_table[encount_readlen].createprob[i-(CREATEPROB_TOKEN + ENCOUNT_GROUPMAXNUM)] + = atoi(token); + } + } + } + + /* 褐 民尼永弁 */ + if( checkRedundancy( ENCOUNT_table[encount_readlen].groupid, + arraysizeof( ENCOUNT_table[encount_readlen].groupid))) + { + fprint( "文件语法错误:%s 第%d行\n", + filename,linenum); + continue; + } + } + + +#ifdef _ADD_ENCOUNT // WON ADD 增加敌遭遇触发修件 + ret = getStringFromIndexWithDelim( line,",",31,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + continue; + } + ENCOUNT_table[encount_readlen].event_now = atoi(token); + + ret = getStringFromIndexWithDelim( line,",",32,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + continue; + } + ENCOUNT_table[encount_readlen].event_end = atoi(token); + + ret = getStringFromIndexWithDelim( line,",",33,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + continue; + } + ENCOUNT_table[encount_readlen].enemy_group = atoi(token); +#endif + + encount_readlen ++; +} + } + fclose(f); + + ENCOUNT_encountnum = encount_readlen; + + print( "有效的遇敌坐标数是 %d..", ENCOUNT_encountnum ); + +#if 0 + + { + int i; + for( i=0; i 0) { + if( index != -1 ) { + /* 穸燮赐匏毛譬屯月 */ + /* 五中 穸燮 */ + if( curZorder > ENCOUNT_getZorderFromArray(index)) { + index = i; + } + } + else { + index = i; + } + } + } + } + } + return index; +} + +/*------------------------------------------------------------ + * 隙烂今木凶甄 及巨件市它件玄割 毛譬屯月[ + * 娄醒 + * floor int 白夫失ID + * x int x甄 + * y int y甄 + * 忒曰袄 + * 恳橘 ㄟ动晓及割 + * 潸 撩 -1 + ------------------------------------------------------------*/ +int ENCOUNT_getEncountPercentMin( int charaindex, int floor , int x, int y ) +{ + int ret; + + ret = ENCOUNT_getEncountAreaArray( floor, x, y); + if( ret != -1 ) { + ret = ENCOUNT_table[ret].encountprob_min; + /* 玄目夫旦躲绊毛勾仃月 */ + if( CHAR_getWorkInt( charaindex, CHAR_WORK_TOHELOS_COUNT) > 0 ) { + ret = ceil( ret * + ((100 + CHAR_getWorkInt( charaindex, CHAR_WORK_TOHELOS_CUTRATE)) + / 100.0)); + } + if( ret < 0 ) ret = 0; + if( ret > 100 ) ret = 100; + } + return ret; +} +/*------------------------------------------------------------ + * 隙烂今木凶甄 及巨件市它件玄割 毛譬屯月[ + * 娄醒 + * floor int 白夫失ID + * x int x甄 + * y int y甄 + * 忒曰袄 + * 恳橘 ㄟ动晓及割 + * 潸 撩 -1 + ------------------------------------------------------------*/ +int ENCOUNT_getEncountPercentMax( int charaindex, int floor , int x, int y ) +{ + int ret; + + ret = ENCOUNT_getEncountAreaArray( floor, x, y); + if( ret != -1 ) { + ret = ENCOUNT_table[ret].encountprob_max; + /* 玄目夫旦躲绊毛勾仃月 */ + if( CHAR_getWorkInt( charaindex, CHAR_WORK_TOHELOS_COUNT) > 0 ) { + ret = ceil( ret * + ((100 + CHAR_getWorkInt( charaindex, CHAR_WORK_TOHELOS_CUTRATE)) + / 100.0)); + } + if( ret < 0 ) ret = 0; + if( ret > 100 ) ret = 100; + } + return ret; +} +/*------------------------------------------------------------ + * 隙烂今木凶甄 及衬戏岳MAX醒毛譬屯月[ + * 娄醒 + * floor int 白夫失ID + * x int x甄 + * y int y甄 + * 忒曰袄 + * 恳橘 ㄟ动晓及割 + * 潸 撩 -1 + ------------------------------------------------------------*/ +int ENCOUNT_getCreateEnemyMaxNum( int floor , int x, int y ) +{ + int ret; + + ret = ENCOUNT_getEncountAreaArray( floor, x, y); + if( ret != -1 ) { + ret = ENCOUNT_table[ret].enemymaxnum; + } + return ret; +} +/*------------------------------------------------------------ + * 隙烂今木凶甄 及巨件市它件玄白奴□伙玉及index毛譬屯月[ + * 娄醒 + * floor int 白夫失ID + * x int x甄 + * y int y甄 + * 忒曰袄 + * 恳橘 ㄟ动晓 + * 潸 撩 -1 + ------------------------------------------------------------*/ +int ENCOUNT_getEncountIndex( int floor , int x, int y ) +{ + int ret; + + ret = ENCOUNT_getEncountAreaArray( floor, x, y); + if( ret != -1 ) { + ret = ENCOUNT_table[ret].index; + } + return ret; +} +/*------------------------------------------------------------ + * 隙烂今木凶甄 及巨件市它件玄白奴□伙玉及index毛譬屯月[ + * 娄醒 + * array int ENCOUNTTABLE及骄侬 + * 忒曰袄 + * 恳橘 ㄟ动晓 + * 潸 撩 -1 + ------------------------------------------------------------*/ +int ENCOUNT_getEncountIndexFromArray( int array ) +{ + if( !ENCOUNT_CHECKENCOUNTTABLEARRAY( array)) return -1; + return ENCOUNT_table[array].index; +} +/*------------------------------------------------------------ + * 隙烂今木凶甄 及巨件市它件玄割 毛譬屯月[ + * 娄醒 + * array int ENCOUNTTABLE及骄侬 + * 忒曰袄 + * 恳橘 ㄟ动晓 + * 潸 撩 -1 + ------------------------------------------------------------*/ +int ENCOUNT_getEncountPercentFromArray( int array ) +{ + if( !ENCOUNT_CHECKENCOUNTTABLEARRAY( array)) return -1; + return ENCOUNT_table[array].encountprob_min; +} +/*------------------------------------------------------------ + * 隙烂今木凶甄 及衬戏岳MAX醒毛譬屯月[ + * 娄醒 + * array int ENCOUNTTABLE及骄侬 + * 忒曰袄 + * 恳橘 ㄟ动晓 + * 潸 撩 -1 + ------------------------------------------------------------*/ +int ENCOUNT_getCreateEnemyMaxNumFromArray( int array ) +{ + if( !ENCOUNT_CHECKENCOUNTTABLEARRAY( array)) return -1; + return ENCOUNT_table[array].enemymaxnum; +} +/*------------------------------------------------------------ + * 隙烂今木凶骄侬及弘伙□皿 寞毛譬屯月[ + * 娄醒 + * array int ENCOUNTTABLE及骄侬 + * 忒曰袄 + * 恳橘 ㄟ动晓 + * 潸 撩 -1 + ------------------------------------------------------------*/ +int ENCOUNT_getGroupIdFromArray( int array, int grouparray ) +{ + if( !ENCOUNT_CHECKENCOUNTTABLEARRAY( array)) return -1; + return ENCOUNT_table[array].groupid[grouparray]; +} +/*------------------------------------------------------------ + * 隙烂今木凶骄侬及弘伙□皿及请蜇 毛譬屯月[ + * 娄醒 + * array int ENCOUNTTABLE及骄侬 + * 忒曰袄 + * 恳橘 ㄟ动晓 + * 潸 撩 -1 + ------------------------------------------------------------*/ +int ENCOUNT_getGroupProbFromArray( int array, int grouparray ) +{ + if( !ENCOUNT_CHECKENCOUNTTABLEARRAY( array)) return -1; + return ENCOUNT_table[array].createprob[grouparray]; +} +/*------------------------------------------------------------ + * 隙烂今木凶骄侬及穸燮赐匏毛譬屯月[ + * 娄醒 + * array int ENCOUNTTABLE及骄侬 + * 忒曰袄 + * 恳橘 ㄟ动晓 + * 潸 撩 -1 + ------------------------------------------------------------*/ +int ENCOUNT_getZorderFromArray( int array ) +{ + if( !ENCOUNT_CHECKENCOUNTTABLEARRAY( array)) return -1; + return ENCOUNT_table[array].zorder; +} diff --git a/gmsv/char/enemy.c b/gmsv/char/enemy.c new file mode 100644 index 0000000..d61e3da --- /dev/null +++ b/gmsv/char/enemy.c @@ -0,0 +1,2567 @@ +/* 衬涩烂楮 */ +#include "version.h" +#include +#include +#include "common.h" +#include "util.h" +#include "buf.h" +#include "char_base.h" +#include "char.h" +#include "configfile.h" +#include "encount.h" +#include "enemy.h" +#include "pet.h" +#include "enemyexptbl.h" +#include "petmail.h" +#include "battle.h" +#include "pet_skillinfo.h" +#include "anim_tbl.h" +#include "log.h" + +#ifdef _ADD_ENCOUNT // WON ADD 增加敌遭遇触发修件 +#include "encount.h" +#include "npcutil.h" +#endif + +#define ENEMY_INDEXTABLEMAXSIZE 16 +static ENEMY_EnemyTable *ENEMY_enemy; +static int ENEMY_enemynum; + +static ENEMYTEMP_Table *ENEMYTEMP_enemy; +static int ENEMYTEMP_enemynum; + +static GROUP_Table *GROUP_group; +static int GROUP_groupnum; + +int ENEMY_indextable[ENEMY_INDEXTABLEMAXSIZE]; + +#ifdef _ENEMY_FALLGROUND +extern tagRidePetTable ridePetTable[296]; +#endif + +INLINE BOOL ENEMY_CHECKINDEX( int index) +{ + if( index < 0 || index >= ENEMY_enemynum) return FALSE; + return TRUE; +} + +static INLINE BOOL ENEMY_CHECKINTDATAINDEX( int index) +{ + if( index< 0 || index >= ENEMY_DATAINTNUM) return FALSE; + return TRUE; +} + +static INLINE BOOL ENEMY_CHECKCHARDATAINDEX( int index) +{ + if( index< 0 || index >= ENEMY_DATACHARNUM) return FALSE; + return TRUE; +} + +INLINE int ENEMY_getInt( int index, ENEMY_DATAINT element) +{ + return ENEMY_enemy[index].intdata[element]; +} + +INLINE int *ENEMY_getIntdata( int index) +{ + return ENEMY_enemy[index].intdata; +} + +INLINE int ENEMY_setInt( int index, ENEMY_DATAINT element, int data) +{ + int buf; + buf = ENEMY_enemy[index].intdata[element]; + ENEMY_enemy[index].intdata[element] = data; + return buf; +} + +INLINE char *ENEMY_getChar( int index, ENEMY_DATACHAR element) +{ + if(!ENEMY_CHECKINDEX(index))return NULL; + if(!ENEMY_CHECKCHARDATAINDEX(element))return NULL; + + return ENEMY_enemy[index].chardata[element].string; +} + +INLINE BOOL ENEMY_setChar( int index ,ENEMY_DATACHAR element, char* new ) +{ + if(!ENEMY_CHECKINDEX(index))return FALSE; + if(!ENEMY_CHECKCHARDATAINDEX(element))return FALSE; + strcpysafe( ENEMY_enemy[index].chardata[element].string, + sizeof(ENEMY_enemy[index].chardata[element].string), + new ); + return TRUE; +} + +int ENEMY_getEnemyNum( void) +{ + return ENEMY_enemynum; +} + +INLINE BOOL ENEMYTEMP_CHECKINDEX( int index) +{ + if( index < 0 || index >= ENEMYTEMP_enemynum) return FALSE; + return TRUE; +} + +static INLINE BOOL ENEMYTEMP_CHECKINTDATAINDEX( int index) +{ + if( index< 0 || index >= E_T_DATAINTNUM) return FALSE; + return TRUE; +} + +static INLINE BOOL ENEMYTEMP_CHECKCHARDATAINDEX( int index) +{ + if( index< 0 || index >= E_T_DATACHARNUM) return FALSE; + return TRUE; +} + +INLINE int ENEMYTEMP_getInt( int index, ENEMYTEMP_DATAINT element) +{ + return ENEMYTEMP_enemy[index].intdata[element]; +} + +INLINE int ENEMYTEMP_setInt( int index, ENEMYTEMP_DATAINT element, int data) +{ + int buf; + buf = ENEMYTEMP_enemy[index].intdata[element]; + ENEMYTEMP_enemy[index].intdata[element] = data; + return buf; +} + +INLINE char *ENEMYTEMP_getChar( int index, ENEMYTEMP_DATACHAR element) +{ + if(!ENEMYTEMP_CHECKINDEX(index))return NULL; + if(!ENEMYTEMP_CHECKCHARDATAINDEX(element))return NULL; + + return ENEMYTEMP_enemy[index].chardata[element].string; +} + +INLINE BOOL ENEMYTEMP_setChar( int index ,ENEMYTEMP_DATACHAR element, char* new ) +{ + if(!ENEMYTEMP_CHECKINDEX(index))return FALSE; + if(!ENEMYTEMP_CHECKCHARDATAINDEX(element))return FALSE; + strcpysafe( ENEMYTEMP_enemy[index].chardata[element].string, + sizeof(ENEMYTEMP_enemy[index].chardata[element].string), + new ); + return TRUE; +} + +int ENEMYTEMP_getEnemyNum( void) +{ + return ENEMYTEMP_enemynum; +} + +INLINE BOOL GROUP_CHECKINDEX( int index) +{ + if( index < 0 || index >= GROUP_groupnum) return FALSE; + return TRUE; +} + +static INLINE BOOL GROUP_CHECKINTDATAINDEX( int index) +{ + if( index< 0 || index >= GROUP_DATAINTNUM) return FALSE; + return TRUE; +} + +static INLINE BOOL GROUP_CHECKCHARDATAINDEX( int index) +{ + if( index< 0 || index >= GROUP_DATACHARNUM) return FALSE; + return TRUE; +} + +INLINE int GROUP_getInt( int index, GROUP_DATAINT element) +{ + return GROUP_group[index].intdata[element]; +} + +INLINE int GROUP_setInt( int index, GROUP_DATAINT element, int data) +{ + int buf; + buf = GROUP_group[index].intdata[element]; + GROUP_group[index].intdata[element] = data; + return buf; +} + +INLINE char *GROUP_getChar( int index, GROUP_DATACHAR element) +{ + if(!GROUP_CHECKINDEX(index))return NULL; + if(!GROUP_CHECKCHARDATAINDEX(element))return NULL; + + return GROUP_group[index].chardata[element].string; +} + +INLINE BOOL GROUP_setChar( int index ,GROUP_DATACHAR element, char* new ) +{ + if(!GROUP_CHECKINDEX(index))return FALSE; + if(!GROUP_CHECKCHARDATAINDEX(element))return FALSE; + strcpysafe( GROUP_group[index].chardata[element].string, + sizeof(GROUP_group[index].chardata[element].string), + new ); + return TRUE; +} + +int GROUP_getEnemyNum( void) +{ + return GROUP_groupnum; +} + +BOOL ENEMYTEMP_initEnemy( char* filename ) +{ + FILE* f; + char line[256]; + int linenum=0; + int enemytemp_readlen=0; + int i,j; + +#ifdef _ENEMYTEMP_OPTIMUM + int max_enemytempid =0; + char token[256]; +#endif + f = fopen(filename,"r"); + if( f == NULL ){ + print( "文件打开失败\n"); + return FALSE; + } + + ENEMYTEMP_enemynum=0; + + /* 引内 躲卅垫互窒垫丐月井升丹井譬屯月 */ + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + +#ifdef _ENEMYTEMP_OPTIMUM // Robin 取出最大ENEMYTEMP ID + if( getStringFromIndexWithDelim( line, ",", E_T_DATACHARNUM+E_T_TEMPNO+1, + token, sizeof(token)) == FALSE ) + continue; + max_enemytempid = max( atoi( token), max_enemytempid); +#endif + + ENEMYTEMP_enemynum++; + } + + if( fseek( f, 0, SEEK_SET ) == -1 ){ + fprint( "Seek Error\n" ); + fclose(f); + return FALSE; + } + +#ifdef _ENEMYTEMP_OPTIMUM + print("\n 有效EBT:%d 最大EBT:%d \n", ENEMYTEMP_enemynum, max_enemytempid); + ENEMYTEMP_enemynum = max_enemytempid +1; +#endif + + ENEMYTEMP_enemy = allocateMemory( sizeof(struct tagENEMYTEMP_Table) + * ENEMYTEMP_enemynum ); + if( ENEMYTEMP_enemy == NULL ){ + fprint( "无法分配内存 %d\n" , + sizeof(struct tagENEMYTEMP_Table)*ENEMYTEMP_enemynum); + fclose( f ); + return FALSE; + } + + /* 赓渝祭 */ + for( i = 0; i < ENEMYTEMP_enemynum; i ++ ) { + for( j = 0; j < E_T_DATAINTNUM; j ++ ) { + ENEMYTEMP_setInt( i,j,-1); + } + } + linenum = 0; + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + replaceString( line, '\t' , ' ' ); +{ + char buf[256]; + for( i = 0; i < strlen( line); i ++) { + if( line[i] != ' ' ) { + break; + } + strcpy( buf, &line[i]); + } + if( i != 0 ) { + strcpy( line, buf); + } +} +{ + char token[256]; + int ret; + +#ifdef _ENEMYTEMP_OPTIMUM + if( getStringFromIndexWithDelim( line, ",", E_T_DATACHARNUM+E_T_TEMPNO+1, + token, sizeof(token)) == FALSE ) + continue; + enemytemp_readlen = atoi(token); +#endif + +#if 0 + ret = getStringFromIndexWithDelim( line,",",1,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("文件语法错误:%s 第%行\n",filename,linenum); + continue; + } + ENEMYTEMP_setChar( enemytemp_readlen, E_T_NAME, token); +#endif + for( i = 0; i < E_T_DATACHARNUM; i ++ ) { + ret = getStringFromIndexWithDelim( line,",",i+1,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + continue; + } + ENEMYTEMP_setChar( enemytemp_readlen, E_T_NAME + i, token); + + } +#define ENEMYTEMP_STARTINTNUM (E_T_DATACHARNUM+1) + for( i = ENEMYTEMP_STARTINTNUM; i < E_T_DATAINTNUM+ENEMYTEMP_STARTINTNUM; i ++ ) { + ret = getStringFromIndexWithDelim( line,",",i,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + break; + } + if( strlen( token) != 0 ) { + ENEMYTEMP_setInt( enemytemp_readlen, i - ENEMYTEMP_STARTINTNUM, atoi( token)); + } + } + if( i < E_T_DATAINTNUM+ENEMYTEMP_STARTINTNUM ) continue; + + + enemytemp_readlen ++; +} + } + fclose(f); + + ENEMYTEMP_enemynum = enemytemp_readlen; + + print( "有效宠物基本状态数是 %d...", ENEMYTEMP_enemynum ); + +#if 0 + + for( i=0; i = 0 && EnemyTempNo < ENEMYTEMP_enemynum ) + return EnemyTempNo; +#else + int i; + for( i = 0; i < ENEMYTEMP_enemynum; i ++ ) { + if( ENEMYTEMP_getInt( i, E_T_TEMPNO) == EnemyTempNo) { + return i; + } + } +#endif + return -1; +} + +int ENEMYTEMP_getEnemyTempArrayFromInitnum( int EnemyTempNo) +{ + int i; + for( i = 0; i < ENEMYTEMP_enemynum; i ++ ) { + if( ENEMYTEMP_getInt( i, E_T_INITNUM) == EnemyTempNo) { + return i; + } + } + return -1; +} + +BOOL ENEMY_initEnemy( char* filename ) +{ + FILE* f; + char line[256]; + int linenum=0; + int enemy_readlen=0; + int i,j; +#ifdef _ENEMY_OPTIMUM + int max_enemyid =0; + char token[256]; +#endif + + f = fopen(filename,"r"); + if( f == NULL ){ + print( "文件打开失败\n"); + return FALSE; + } + + ENEMY_enemynum=0; + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + +#ifdef _ENEMY_OPTIMUM // Robin 取出最大ENEMY ID + if( getStringFromIndexWithDelim( line, ",", ENEMY_DATACHARNUM+ENEMY_ID+1, + token, sizeof(token)) == FALSE ) + continue; + max_enemyid = max( atoi( token), max_enemyid); +#endif + + ENEMY_enemynum++; + } + + if( fseek( f, 0, SEEK_SET ) == -1 ){ + fprint( "寻找失败\n" ); + fclose(f); + return FALSE; + } + +#ifdef _ENEMY_OPTIMUM + print("\n 有效ET:%d 最大ET:%d \n", ENEMY_enemynum, max_enemyid); + ENEMY_enemynum = max_enemyid +1; +#endif + + ENEMY_enemy = allocateMemory( sizeof(struct tagENEMY_EnemyTable) + * ENEMY_enemynum ); + if( ENEMY_enemy == NULL ){ + fprint( "无法分配内存 %d\n" , + sizeof(struct tagENEMY_EnemyTable)*ENEMY_enemynum); + fclose( f ); + return FALSE; + } + for( i = 0; i < ENEMY_enemynum; i ++ ) { + for( j = 0; j < ENEMY_DATAINTNUM; j ++ ) { + ENEMY_setInt( i,j,-1); + } + } + linenum = 0; + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + replaceString( line, '\t' , ' ' ); +{ + char buf[256]; + for( i = 0; i < strlen( line); i ++) { + if( line[i] != ' ' ) { + break; + } + strcpy( buf, &line[i]); + } + if( i != 0 ) { + strcpy( line, buf); + } +} +{ + char token[256]; + int ret; + +#ifdef _ENEMY_OPTIMUM + if( getStringFromIndexWithDelim( line, ",", ENEMY_DATACHARNUM+ENEMY_ID+1, + token, sizeof(token)) == FALSE ) + continue; + enemy_readlen = atoi(token); +#endif + + ret = getStringFromIndexWithDelim( line,",",1,token,sizeof(token)); + if( ret==FALSE ){ + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + continue; + } + ENEMY_setChar( enemy_readlen, ENEMY_NAME, token); + ret = getStringFromIndexWithDelim( line,",",2,token,sizeof(token)); + if( ret==FALSE ){ + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + continue; + } + ENEMY_setChar( enemy_readlen, ENEMY_TACTICSOPTION, token); +#ifdef _BATTLENPC_WARP_PLAYER + ret = getStringFromIndexWithDelim( line, ",", 3, token, sizeof(token)); + if(ret==FALSE){ + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + continue; + } + ENEMY_setChar( enemy_readlen, ENEMY_ACT_CONDITION, token); +#endif + +#ifdef _BATTLENPC_WARP_PLAYER +#define ENEMY_STARTINTNUM 4 +#else +#define ENEMY_STARTINTNUM 3 +#endif + + for( i = ENEMY_STARTINTNUM; i < ENEMY_DATAINTNUM+ENEMY_STARTINTNUM; i ++ ) { + ret = getStringFromIndexWithDelim( line,",",i,token,sizeof(token)); + if( ret==FALSE ){ + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + break; + } + ENEMY_setInt( enemy_readlen, i - ENEMY_STARTINTNUM, atoi( token)); + } + if( i < ENEMY_DATAINTNUM+ENEMY_STARTINTNUM ) continue; + for( i = 0; i < ENEMYTEMP_enemynum; i ++ ) { + if( ENEMYTEMP_getInt( i, E_T_TEMPNO)== ENEMY_getInt( enemy_readlen, ENEMY_TEMPNO)){ + break; + } + } + if( i == ENEMYTEMP_enemynum) { + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + continue; + } + ENEMY_enemy[enemy_readlen].enemytemparray = i; +{ + int lv_min, lv_max; + lv_min = ENEMY_getInt( enemy_readlen, ENEMY_LV_MIN); + lv_max = ENEMY_getInt( enemy_readlen, ENEMY_LV_MAX); + if( lv_min == 0 ) lv_min = lv_max; + ENEMY_setInt( enemy_readlen, ENEMY_LV_MIN, min( lv_min, lv_max)); + ENEMY_setInt( enemy_readlen, ENEMY_LV_MAX, max( lv_min, lv_max)); + +} + + enemy_readlen ++; +} + } + fclose(f); + ENEMY_enemynum = enemy_readlen; + print( "有效宠物数是 %d..", ENEMY_enemynum ); + +#if 0 + { + for( i=0; i = CREATEPROB1 - ENEMY_ID1) return -1; + return GROUP_group[groupindex].enemyarray[index]; +} +/*------------------------------------------------------------------------ + * ENEMY_ID 井日ENEMY_Enemy及骄侬毛襞月 + *-----------------------------------------------------------------------*/ +int ENEMY_getEnemyArrayFromId( int EnemyId) +{ +#ifdef _ENEMY_OPTIMUM + if( EnemyId >= 0 && EnemyId < ENEMY_enemynum ) + return EnemyId; +#else + int i; + for( i = 0; i < ENEMY_enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == EnemyId) { + return i; + } + } +#endif + return -1; +} + +int ENEMY_getEnemyArrayFromTempNo( int EnemyTempNo) +{ + int i; + for( i = 0; i < ENEMY_enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_TEMPNO) == EnemyTempNo) { + return i; + } + } + return -1; +} + +int ENEMY_getEnemyIdFromTempNo( int EnemyTempNo) +{ + int i; + for( i = 0; i < ENEMY_enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_TEMPNO) == EnemyTempNo) { + return ENEMY_getInt( i, ENEMY_ID); + } + } + return -1; +} + +int ENEMY_getEnemyTempNoFromId( int EnemyId) +{ +#ifdef _ENEMY_OPTIMUM + if( EnemyId >= 0 && EnemyId < ENEMY_enemynum) + return ENEMY_getInt( EnemyId, ENEMY_TEMPNO); +#else + int i; + for( i = 0; i < ENEMY_enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == EnemyId) { + return ENEMY_getInt( i, ENEMY_TEMPNO); + } + } +#endif + return -1; +} + +/*------------------------------------------------------------------------ + * 弘伙□皿涩烂白央奶伙毛 戈 + *-----------------------------------------------------------------------*/ +BOOL GROUP_initGroup( char* filename ) +{ + FILE* f; + char line[256]; + int linenum=0; + int group_readlen=0; + int i,j; + + f = fopen(filename,"r"); + if( f == NULL ){ + print( "文件打开失败\n"); + return FALSE; + } + + GROUP_groupnum=0; + + /* 引内 躲卅垫互窒垫丐月井升丹井譬屯月 */ + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + + GROUP_groupnum++; + } + + if( fseek( f, 0, SEEK_SET ) == -1 ){ + fprint( "寻找失败\n" ); + fclose(f); + return FALSE; + } + + GROUP_group = allocateMemory( sizeof(struct tagGROUP_Table) + * GROUP_groupnum ); + if( GROUP_group == NULL ){ + fprint( "无法分配内存 %d\n" , + sizeof(struct tagGROUP_Table)*GROUP_groupnum); + fclose( f ); + return FALSE; + } + /* 赓渝祭 */ + for( i = 0; i < GROUP_groupnum; i ++ ) { + for( j = 0; j < GROUP_DATAINTNUM; j ++ ) { + GROUP_setInt( i,j,-1); + } + for( j = 0; j < CREATEPROB1 - ENEMY_ID1; j ++ ) { + GROUP_group[i].enemyarray[j] = -1; + } + } + + /* 引凶 心 允 */ + linenum = 0; + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + + /* 垫毛帮溥允月 */ + /* 引内 tab 毛 " " 卞 五晶尹月 */ + replaceString( line, '\t' , ' ' ); + /* 燮 及旦矢□旦毛潸月[*/ +{ + char buf[256]; + for( i = 0; i < strlen( line); i ++) { + if( line[i] != ' ' ) { + break; + } + strcpy( buf, &line[i]); + } + if( i != 0 ) { + strcpy( line, buf); + } +} +{ + char token[256]; + int ret; + int loop; + + /* 手仄手ㄡ蘸户及伙□皿卞 匀凶凛及凶户卞赓渝祭仄化云仁 */ + for( j = 0; j < GROUP_DATAINTNUM; j ++ ) { + GROUP_setInt( group_readlen,j,-1); + } + for( j = 0; j < CREATEPROB1 - ENEMY_ID1; j ++ ) { + GROUP_group[group_readlen].enemyarray[j] = -1; + } + + /* 夫午勾户及玄□弁件毛苇月 */ + ret = getStringFromIndexWithDelim( line,",",1,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + continue; + } + GROUP_setChar( group_readlen, GROUP_NAME, token); + + /* 2勾 动嫦反醒袄犯□正 */ +#define GROUP_STARTINTNUM 2 + for( i = GROUP_STARTINTNUM; i < GROUP_DATAINTNUM+GROUP_STARTINTNUM; i ++ ) { + ret = getStringFromIndexWithDelim( line,",",i,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + break; + } + if( strlen( token) != 0 ) { + GROUP_setInt( group_readlen, i - GROUP_STARTINTNUM, atoi( token)); + } + } + if( i < GROUP_DATAINTNUM+GROUP_STARTINTNUM ) continue; + + { + int enemycnt = 0; + for( loop = ENEMY_ID1; loop < CREATEPROB1; loop ++ ) { + if( GROUP_getInt( group_readlen, loop) != -1 ) { + for( i = 0; i < ENEMY_enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) + == GROUP_getInt( group_readlen, loop)) + { + break; + } + } + if( i == ENEMY_enemynum) { + i = -1; + GROUP_setInt( group_readlen, loop, -1); + } + else { + enemycnt ++; + } + GROUP_group[group_readlen].enemyarray[loop - ENEMY_ID1] = i; + } + } + if( enemycnt == 0 ) { + fprint("团队设定中敌人尚未设定 文件:%s 第%d行\n",filename,linenum); + continue;; + } + if( checkRedundancy( &GROUP_group[group_readlen].intdata[ENEMY_ID1], + CREATEPROB1 - ENEMY_ID1)) + { + fprint("团队设定中敌人重复设定 文件:%s 第%d行\n",filename,linenum); + continue;; + } + + } + + + group_readlen ++; +} + } + fclose(f); + + GROUP_groupnum = group_readlen; + + print( "有效遇敌组群数是 %d...", GROUP_groupnum ); + +#if 0 + + for( i=0; i = arraysizeof( enemybaseexptbl)) return 0; + + p = ENEMY_enemy[array].intdata; + tp = ENEMYTEMP_enemy[tarray].intdata; + + // 仿件弁井日 毛潸 + if( rank < 0 || rank > 5 ) rank = 0; + ranknum = ranktbl[rank].rank; + + alpha = ( *( tp + E_T_CRITICAL) + *( tp + E_T_COUNTER) + *(tp + E_T_GET) + + *( tp + E_T_POISON) + *( tp + E_T_PARALYSIS) + *(tp + E_T_SLEEP) + + *( tp + E_T_STONE) + *( tp + E_T_DRUNK) + *(tp + E_T_CONFUSION) + ) / 100.0 + + *( tp + E_T_RARE); + /* EXP>湘 EXP≈- 仿件弁≈汐 ←伊矛伙×*/ + //return enemybaseexptbl[*(p+ENEMY_LV)] + (ranknum + alpha)*(*(tp+ENEMY_LV)); + ret = enemybaseexptbl[level] + (ranknum + alpha)*(level+1); + return ( ret < 1 ) ? 1 : ret; + +} + + +int ENEMY_getRank( int array, int tarray ){ + int *p; + int *tp; + int paramsum; + int i; + int ranknum; + + struct { + int num; + float rank; + }ranktbl[] = { + { 100, 2.5}, //总成长率 >= 100 petrank=0 + { 95, 2.0}, + { 90, 1.5}, + { 85, 1.0}, + { 80, 0.5}, + { 0, 0.0}, + }; + + p = ENEMY_enemy[array].intdata; + tp = ENEMYTEMP_enemy[tarray].intdata; + /* 仿件弁毛煌遥允月 */ + /* 仇及 及酷 反酷 踏毛辅哔及仪[ */ + paramsum = *( tp + E_T_BASEVITAL) + + *( tp + E_T_BASESTR) + + *( tp + E_T_BASETGH) + + *( tp + E_T_BASEDEX); + + ranknum = 0; // 犯白巧伙玄反ㄟ + for( i = 0; i < arraysizeof( ranktbl); i ++ ) { + if( paramsum >= ranktbl[i].num ) { + ranknum = i; + break; + } + } + + return ranknum; + +} + + +//********************************************************* +// 仿件母丞卅 +//********************************************************* +static int EnemyGymSkill[] = { + PETSKILL_GUARDBREAK, // ㄢ“布□玉旰仄(3) + PETSKILL_CONTINUATIONATTACK1, // ㄠㄟ“ 粮 猾(10) + PETSKILL_CONTINUATIONATTACK2, // ㄠㄠ“ 粮 猾(11) + PETSKILL_CONTINUATIONATTACK3, // ㄠㄡ“ 粮 猾(12) + PETSKILL_CHARGE1, // ㄢㄟ“民乓□斥ㄠ(30) + PETSKILL_CHARGE2, // ㄢㄠ“民乓□斥ㄡ(31) + PETSKILL_MIGHTY1, // ㄣㄟ“域猾 诮(40) + PETSKILL_MIGHTY2, // ㄣㄠ“域猾 诮(41) + PETSKILL_POWERBALANCE1, // ㄤㄟ“ 及讽ㄠ(50) + PETSKILL_POWERBALANCE2, // ㄤㄠ“ 及讽ㄡ(51) + PETSKILL_POWERBALANCE3, // ㄤㄡ“ 及讽ㄢ(52) + PETSKILL_POISON_ATTACK1, // ㄥㄟ“ 猾(60) + PETSKILL_POISON_ATTACK2, // ㄥㄠ“ 猾(61) + PETSKILL_STONE, // ㄧㄟ“檗祭 猾(80) + PETSKILL_CONFUSION_ATTACK, // ㄨㄟ“渔刭 猾(90) + PETSKILL_DRUNK_ATTACK, // ㄠㄟㄟ“听办 猾(100) + PETSKILL_SLEEP_ATTACK, // ㄠㄠㄟ“戽曰 猾(110) + PETSKILL_NOGUARD1, // ㄠㄤㄟ“用□布□玉ㄠ(150) + PETSKILL_NOGUARD2, // ㄠㄤㄠ“用□布□玉ㄡ(151) + PETSKILL_NOGUARD3, // ㄠㄤㄡ“用□布□玉ㄢ(152) +#ifdef _PSKILL_FALLGROUND + PETSKILL_FALLGROUND, //落马术 +#endif +#ifdef _SKILL_DAMAGETOHP + PETSKILL_DAMAGETOHP, //嗜血技 +#endif +#ifdef _Skill_MPDAMAGE + PETSKILL_MPDAMAGE, //MP伤害 +#endif + +#ifdef _SKILL_WILDVIOLENT_ATT + PETSKILL_WILDVIOLENTATTACK, //(540)狂暴攻击 vincent add 2002/05/16 +#endif +#ifdef _SKILL_SPEEDY_ATT + PETSKILL_SPEEDYATTACK, //(541)疾速攻击 vincent add 2002/05/16 +#endif +#ifdef _SKILL_GUARDBREAK2 + PETSKILL_GUARDBREAK2, //(542)破除防御2 vincent add 2002/05/20 +#endif +#ifdef _SKILL_SACRIFICE + PETSKILL_SACRIFICE, //(543)救援 vincent add 2002/05/30 +#endif +#ifdef _SKILL_WEAKEN + PETSKILL_WEAKEN, //(544)救援 vincent add 2002/07/11 +#endif +#ifdef _SKILL_DEEPPOISON + PETSKILL_DEEPPOISON, //(545)救援 vincent add 2002/07/16 +#endif +#ifdef _SKILL_BARRIER + PETSKILL_BARRIER, //(546)魔障 vincent add 2002/07/16 +#endif +#ifdef _SKILL_NOCAST + PETSKILL_NOCAST, //(547)沉默 vincent add 2002/07/16 +#endif +#ifdef _SKILL_ROAR + PETSKILL_ROAR, //(548)大吼 vincent add 2002/07/11 +#endif + +#ifdef _SKILL_REFRESH + PETSKILL_REFRESH, //(550)救援 vincent add 2002/08/08 +#endif +#ifdef _VARY_WOLF + PETSKILL_VARY, +#endif +#ifdef _PETSKILL_SETDUCK + PETSKILL_SETDUCK, +#endif + +#ifdef _MAGICPET_SKILL + PETSKILL_SETMAGICPET, +#endif +#ifdef _PETSKILL_BECOMEPIG + PETSKILL_BECOMEPIG, +#endif +#ifdef _PETSKILL_LER + PETSKILL_BATFLY, + PETSKILL_DIVIDEATTACK, +#endif +#ifdef _PETSKILL_BATTLE_MODEL + PETSKILL_BATTLE_MODEL, +#endif +}; + +static int gymbody[] = { + SPR_001em,SPR_011em,SPR_021em,SPR_031em,SPR_041em,SPR_051em, + SPR_061em,SPR_071em,SPR_081em,SPR_091em,SPR_101em,SPR_111em, + + SPR_002em,SPR_012em,SPR_022em,SPR_032em,SPR_042em,SPR_052em, + SPR_062em,SPR_072em,SPR_082em,SPR_092em,SPR_102em,SPR_112em, + + SPR_003em,SPR_013em,SPR_023em,SPR_033em,SPR_043em,SPR_053em, + SPR_063em,SPR_073em,SPR_083em,SPR_093em,SPR_103em,SPR_113em, + + SPR_004em,SPR_014em,SPR_024em,SPR_034em,SPR_044em,SPR_054em, + SPR_064em,SPR_074em,SPR_084em,SPR_094em,SPR_104em,SPR_114em, +}; + + +/*------------------------------------------------------------------------ + * ENEMY{卞仿件母丞卅 毛芨尹月 + *-----------------------------------------------------------------------*/ +int ENEMY_RandomChange( int enemyindex, int tempno ) +{ + int work, work2, iRet = 0; + + // 仿件母丞平乓仿井升丹井民尼永弁 + if( ( 564 <= tempno && tempno <= 580 ) + || ( 739 <= tempno && tempno <= 750 ) + || ( 895 <= tempno && tempno <= 906 ) + ){ + //******************************************** + // 皿伊奶乩□及涌 + //******************************************** + iRet = 1; + }else + // 仿件母丞平乓仿井升丹井民尼永弁 + if( ( 655 <= tempno && tempno <= 720 ) + || ( 859 <= tempno && tempno <= 894 ) + || ( 907 <= tempno && tempno <= 940 ) + ){ + //******************************************** + // 矢永玄及涌 + //******************************************** + iRet = 2; + }else{ + return 0; + } + + + if( iRet == 1 ){ + //******************************************** + // + // 皿伊奶乩□及涌仄凶衬卅及匹}箪岭手仿件母丞 + // + //******************************************** + // 铣手仿件母丞 + CHAR_setInt( enemyindex, CHAR_BASEBASEIMAGENUMBER, + gymbody[RAND( 0, arraysizeof( gymbody ) - 1)] ); + CHAR_setInt( enemyindex, CHAR_BASEIMAGENUMBER, + CHAR_getInt( enemyindex, CHAR_BASEBASEIMAGENUMBER ) ); + // 箪岭反赝癫 + work = ( RAND( 0, 20 ) - 10 ) * 10; + work2 = 100 - ABS( work ); + CHAR_setInt( enemyindex, CHAR_EARTHAT, work ); + CHAR_setInt( enemyindex, CHAR_FIREAT, -work ); + if( RAND( 0, 1 ) ){ + work2 *= -1; + } + CHAR_setInt( enemyindex, CHAR_WATERAT, work2 ); + CHAR_setInt( enemyindex, CHAR_WINDAT, -work2 ); + + // 仿件母丞卅 湛毛 凶六月 + if( DoujyouRandomWeponSet( enemyindex ) ){ + // 溃 湛及桦宁反骚橘 猾毛勾仃月 + CHAR_setPetSkill( enemyindex, 0, PETSKILL_NORMALATTACK ); + CHAR_setPetSkill( enemyindex, 1, PETSKILL_NORMALATTACK ); + }else{ + // 溃 湛元扎卅中及匹 勾仃月 + // 毛尥仃月 + CHAR_setPetSkill( enemyindex, 0, + EnemyGymSkill[RAND( 0, arraysizeof( EnemyGymSkill ) - 1 )] ); + // 毛尥仃月 + CHAR_setPetSkill( enemyindex, 1, + EnemyGymSkill[RAND( 0, arraysizeof( EnemyGymSkill ) - 1 )] ); + } + + }else + if( iRet == 2 ){ + // 溃 湛元扎卅中及匹 勾仃月 + // 毛尥仃月 + CHAR_setPetSkill( enemyindex, 0, + EnemyGymSkill[RAND( 0, arraysizeof( EnemyGymSkill ) - 1 )] ); + // 毛尥仃月 + CHAR_setPetSkill( enemyindex, 1, + EnemyGymSkill[RAND( 0, arraysizeof( EnemyGymSkill ) - 1 )] ); + } + + return 1; + +} + + +/*------------------------------------------------------------------------ + * ENEMY_enemy井日平乓仿弁正□毛综岳允月[ + *-----------------------------------------------------------------------*/ +int ENEMY_createEnemy( int array, int baselevel ) +{ + Char CharNew; + int newindex; + int *p; + int tp[E_T_DATAINTNUM]; + int tarray, i; + int itemindex,iloop; + int level; + int enemyrank; + + if( !ENEMY_CHECKINDEX( array)) return -1; + + p = ENEMY_enemy[array].intdata; + tarray = ENEMYTEMP_getEnemyTempArray( array); + if( !ENEMYTEMP_CHECKINDEX( tarray)) return -1; +// tp = ENEMYTEMP_enemy[tarray].intdata; + // 犯□正戊疋□ + for( i = 0; i < E_T_DATAINTNUM; i ++ ){ + tp[i] = ENEMYTEMP_enemy[tarray].intdata[i]; + } + + // 赓渝祭 + memset( &CharNew, 0, sizeof( Char ) ); + + if( !CHAR_getDefaultChar( &CharNew,31010 ) )return -1; + + /* 飓 寞 */ + CharNew.data[CHAR_BASEBASEIMAGENUMBER] + = CharNew.data[CHAR_BASEIMAGENUMBER] = *(tp+E_T_IMGNUMBER); + /* 衬匹丐月午涩烂允月 */ + CharNew.data[CHAR_WHICHTYPE] = CHAR_TYPEENEMY; + /* 毛壅允 */ + CharNew.data[CHAR_DUELPOINT] = 0; + + /* 伊矛伙毛瑁烂允月[ */ + if( baselevel > 0 ){ + level = baselevel; // 伊矛伙裔烂 + }else{ + level = RAND( (*(p + ENEMY_LV_MIN)), (*(p+ ENEMY_LV_MAX))); + } +#define E_PAR( a) (*(p + (a))) +#define ET_PAR( a) (*(tp + (a))) +/* 由仿丢□正隙醒井日 端及湘 由仿丢□正尺及煌遥挚 */ +#if 1 +#define PARAM_CAL( l) ( ( level -1)*ET_PAR( E_T_LVUPPOINT)+ ET_PAR(E_T_INITNUM)) * ET_PAR( (l)) +#else +#define PARAM_CAL( l) ( (E_PAR(ENEMY_LV) -1)*ET_PAR( E_T_LVUPPOINT)+ ET_PAR(E_T_INITNUM)) * ET_PAR( (l)) +#endif + /* 燮内湘 喃曰蕊曰禾奶件玄卞+ㄡ毛仿件母丞匹垫丹 */ + tp[E_T_BASEVITAL] += RAND( 0, 4 ) - 2; + tp[E_T_BASESTR] += RAND( 0, 4 ) - 2; + tp[E_T_BASETGH] += RAND( 0, 4 ) - 2; + tp[E_T_BASEDEX] += RAND( 0, 4 ) - 2; + /* 仇及凛鳔匹喃曰蕊曰禾奶件玄毛忡绣仄化云仁 */ + CharNew.data[CHAR_ALLOCPOINT] + = ( tp[E_T_BASEVITAL] << 24 ) + + ( tp[E_T_BASESTR] << 16 ) + + ( tp[E_T_BASETGH] << 8 ) + + ( tp[E_T_BASEDEX] << 0 ); + /* 公及 }仿件母丞匹禾奶件玄毛ㄠ勿勾笛遥[仇木毛ㄠㄟ荚楞曰忒允[*/ + for( i = 0; i < 10; i ++ ){ + int work = RAND( 0, 3 ); + if( work == 0 )tp[E_T_BASEVITAL]++; + if( work == 1 )tp[E_T_BASESTR]++; + if( work == 2 )tp[E_T_BASETGH]++; + if( work == 3 )tp[E_T_BASEDEX]++; + } + + /* 由仿丢□正本永玄 */ + CharNew.data[CHAR_VITAL] = PARAM_CAL(E_T_BASEVITAL); + CharNew.data[CHAR_STR] = PARAM_CAL(E_T_BASESTR); + CharNew.data[CHAR_TOUGH] = PARAM_CAL(E_T_BASETGH); + CharNew.data[CHAR_DEX] = PARAM_CAL(E_T_BASEDEX); + CharNew.data[CHAR_FIREAT] = *(tp+ E_T_FIREAT); + CharNew.data[CHAR_WATERAT] = *(tp+ E_T_WATERAT); + CharNew.data[CHAR_EARTHAT] = *(tp+ E_T_EARTHAT); + CharNew.data[CHAR_WINDAT] = *(tp+ E_T_WINDAT); + CharNew.data[CHAR_MODAI] = *(tp+ E_T_MODAI); + CharNew.data[CHAR_VARIABLEAI] = 0; + CharNew.data[CHAR_LV] = level; + //CharNew.data[CHAR_LV] = *(p+ ENEMY_LV); + CharNew.data[CHAR_SLOT] = *(tp+ E_T_SLOT); + CharNew.data[CHAR_POISON] = *(tp+ E_T_POISON); + CharNew.data[CHAR_PARALYSIS]= *(tp+ E_T_PARALYSIS); + CharNew.data[CHAR_SLEEP] = *(tp+ E_T_SLEEP); + CharNew.data[CHAR_STONE] = *(tp+ E_T_STONE); + CharNew.data[CHAR_DRUNK] = *(tp+ E_T_DRUNK); + CharNew.data[CHAR_CONFUSION]= *(tp+ E_T_CONFUSION); + CharNew.data[CHAR_RARE] = *(tp+ E_T_RARE); + CharNew.data[CHAR_PETID] = *(tp + E_T_TEMPNO); + CharNew.data[CHAR_CRITIAL] = *(tp + E_T_CRITICAL); + CharNew.data[CHAR_COUNTER] = *(tp + E_T_COUNTER); + + for( i = 0; i < CHAR_MAXPETSKILLHAVE; i ++ ) { + CharNew.unionTable.indexOfPetskill[i] = *(tp + E_T_PETSKILL1 + i); + } + enemyrank = ENEMY_getRank( array, tarray ); + CharNew.data[CHAR_PETRANK] = enemyrank; +#undef E_PAR +#undef ET_PAR +#undef PARAM_CAL + CharNew.data[CHAR_DUELPOINT] = *( p + ENEMY_DUELPOINT); + if( *( p + ENEMY_DUELPOINT) <= 0 ) { + if( *(p + ENEMY_EXP) != -1 ) { + CharNew.data[CHAR_EXP] = *( p+ENEMY_EXP); + }else { + CharNew.data[CHAR_EXP] = ENEMY_getExp( array,tarray,level, enemyrank); + } + } + strcpysafe( CharNew.string[CHAR_NAME].string, + sizeof(CharNew.string[CHAR_NAME].string), + (char *)ENEMYTEMP_enemy[tarray].chardata[E_T_NAME].string ); + + newindex = CHAR_initCharOneArray( &CharNew ); + if( newindex < 0 ){ + return -1; + } + for( iloop=0; iloop< (ENEMY_ITEMPROB10 - ENEMY_ITEM1+1)/2; iloop++){ + if( *(p+ENEMY_ITEMPROB1+iloop) != 0) { +#ifdef _FIX_ITEMPROB + if( RAND( 0,999) < *(p+ENEMY_ITEMPROB1+iloop)){ +#else + if( RAND( 0,99) < *(p+ENEMY_ITEMPROB1+iloop)){ +#endif + itemindex = ITEM_makeItemAndRegist( *(p+ENEMY_ITEM1+iloop) ); + CHAR_setItemIndex( newindex, CHAR_STARTITEMARRAY +iloop, itemindex); + ITEM_setWorkInt( itemindex, ITEM_WORKCHARAINDEX, newindex ); + ITEM_setWorkInt( itemindex, ITEM_WORKOBJINDEX,-1); + + } + } + } + + { int style, wepon = -1; + style = (*(p + ENEMY_STYLE)); + switch( style ){ + case 1: wepon = 0;break; // + case 2: wepon = 100;break; // 轺徇 + case 3: wepon = 200;break; // 键 + case 4: wepon = 400;break; // 菰 + case 5: wepon = 500;break; // 皮□丢仿件 + case 6: wepon = 700;break; // 髑仆檗 + case 7: wepon = 600;break; // 髑仆 + default:break; + } + if( wepon >= 0 ){ + itemindex = ITEM_makeItemAndRegist( wepon ) ; + CHAR_setItemIndex( newindex, CHAR_ARM, itemindex ); + ITEM_setWorkInt( itemindex, ITEM_WORKCHARAINDEX, newindex ); + ITEM_setWorkInt( itemindex, ITEM_WORKOBJINDEX,-1); + } + } + + ENEMY_RandomChange( newindex, *( p+ENEMY_ID) ); + CHAR_complianceParameter( newindex ); + + CHAR_setInt( newindex, CHAR_HP, CHAR_getWorkInt( newindex, CHAR_WORKMAXHP)); + CHAR_setWorkInt( newindex, CHAR_WORKTACTICS, *(p+ENEMY_TACTICS)); + CHAR_setWorkChar( newindex, CHAR_WORKBATTLE_TACTICSOPTION, + ENEMY_enemy[array].chardata[ENEMY_TACTICSOPTION].string ); +#ifdef _BATTLENPC_WARP_PLAYER + CHAR_setWorkChar( newindex, CHAR_WORKBATTLE_ACT_CONDITION, + ENEMY_enemy[array].chardata[ENEMY_ACT_CONDITION].string ); +#endif + CHAR_setWorkInt( newindex, CHAR_WORK_PETFLG, *(p+ENEMY_PETFLG)); + CHAR_setWorkInt( newindex, CHAR_WORKMODCAPTUREDEFAULT, *(tp + E_T_GET)); +#ifdef _ENEMY_FALLGROUND + { + int i=0; + for( i=0;i= arraysizeof( RandomEnemyTbl ) ) return 0; + + // 仿件母丞涩烂 + randwork = RAND( 0, RandomEnemyTbl[i].arraysize - 1 ); + // 井日蕙仄中 寞毛潸 + work = RandomEnemyTbl[i].pTbl[randwork]; + *pNew = ENEMY_getEnemyArrayFromId( work ); + return 1; + }else{ + // 窒仪手卅中 + return 0; + } +} + +int *ENEMY_getEnemy( int charaindex, int x, int y) +{ + int i; + int array; + int g_array; + int e_array; + int found = 0; + int work[ENEMY_INDEXTABLEMAXSIZE]; + int wr[ENEMY_INDEXTABLEMAXSIZE]; + int createenemynum; + int enemyentrymax; + int entrymax; + int r_max; + int groupid; + int bigcnt; + int loopcounter; + array = ENCOUNT_getEncountAreaArray( CHAR_getInt( charaindex, CHAR_FLOOR),x,y); + if( array == -1 ) return NULL; + enemyentrymax = ENCOUNT_getCreateEnemyMaxNumFromArray( array); + if( enemyentrymax == -1 ) { + return NULL; + } + for( i = 0 ; i < ENEMY_INDEXTABLEMAXSIZE; i ++ ) { + work[i] = -1; + wr[i] = -1; + ENEMY_indextable[i] = -1; + } + + r_max= 0; + for( i = 0; i < ENCOUNT_GROUPMAXNUM; i ++ ){ + if( ENCOUNT_getGroupIdFromArray( array, i ) != - 1 ) { + int itemid; + groupid = ENCOUNT_getGroupIdFromArray( array, i); + g_array = GROUP_getGroupArray( groupid); + itemid = GROUP_getInt( g_array, GROUP_APPEARBYITEMID); + if( itemid != -1 ) { + int j; + for( j = 0; j < CHAR_MAXITEMHAVE; j ++ ) { + int itemindex = CHAR_getItemIndex( charaindex, j); + if( ITEM_CHECKINDEX( itemindex)) { + if( ITEM_getInt( itemindex, ITEM_ID) == itemid){ + break; + } + } + } + if( j == CHAR_MAXITEMHAVE ) continue; + } + itemid = GROUP_getInt( g_array, GROUP_NOTAPPEARBYITEMID); + if( itemid != -1 ) { + int j; + for( j = 0; j < CHAR_MAXITEMHAVE; j ++ ) { + int itemindex = CHAR_getItemIndex( charaindex, j); + if( ITEM_CHECKINDEX( itemindex)) { + if( ITEM_getInt( itemindex, ITEM_ID) == itemid){ + break; + } + } + } + if( j != CHAR_MAXITEMHAVE ) continue; + } + + work[found] = i; + wr[found] = ENCOUNT_getGroupProbFromArray( array, i); + r_max += wr[found]; + found ++; + } + } + r_max --; + + if( found <= 0 ) return NULL; + { + int aaa = 0; + int r; + r = RAND( 0, r_max); + for( i = 0; i < found-1; i ++ ) { + aaa += wr[i]; + if( wr[i] != 0 && r < aaa ) break; + } + r = i; + + groupid = ENCOUNT_getGroupIdFromArray( array, work[r]); + g_array = GROUP_getGroupArray( groupid); + } + for( i = 0 ; i < ENEMY_INDEXTABLEMAXSIZE; i ++ ) { + work[i] = -1; + wr[i] = -1; + } + createenemynum = 0; + found = 0; + r_max = 0; + for( i = ENEMY_ID1; i < CREATEPROB1; i ++ ) { + int newarray, enemywork; + e_array = ENEMY_getEnemyArrayFromIndex( g_array, i - ENEMY_ID1 ); + +#ifdef _ADD_ENCOUNT // WON ADD 增加敌遭遇触发修件 + { + int char_event_now = -1, char_event_end = -1; + if(ENCOUNT_table[array].event_now != -1){ + char_event_now = ENCOUNT_table[array].event_now; + } + else if(ENCOUNT_table[array].event_end != -1){ + char_event_end = ENCOUNT_table[array].event_end; + } + if( (char_event_now > 0) || ( char_event_end > 0 ) ) { + if( (NPC_NowEventCheckFlg( charaindex, char_event_now) == TRUE ) || + (NPC_EventCheckFlg( charaindex, char_event_end) == TRUE ) ){ + + e_array = ENEMY_getEnemyArrayFromIndex( + GROUP_getGroupArray( ENCOUNT_table[array].enemy_group ),i - ENEMY_ID1 ); + } + } + } +#endif + enemywork = ENEMY_getInt( e_array, ENEMY_ID ); + if( ENEMY_RandomEnemyArray( enemywork, &newarray ) ){ + e_array = newarray; + } + + if( e_array != -1 ) { + work[found] = e_array; + wr[found] = GROUP_getInt( g_array, i + (CREATEPROB1 - ENEMY_ID1)); + r_max += wr[found]; + found ++; + createenemynum += ENEMY_getInt( e_array, ENEMY_CREATEMAXNUM); + } + } + r_max --; + + if( found <= 0 ) return NULL; + enemyentrymax= min( enemyentrymax, createenemynum ); + entrymax = RAND( 1, enemyentrymax); + bigcnt = 0; + for( i = 0,loopcounter = 0; i < entrymax && loopcounter < 100; loopcounter ++) { + int cnt; + int j,r; + int aaa = 0; + int et_array; + int k,samecount; + r = RAND( 0, r_max); + for( j = 0; j < found-1; j ++ ) { + aaa += wr[j]; + if( wr[j] != 0 && r < aaa ) break; + } + r = j; + cnt = 0; + for( j = 0; j < ENEMY_INDEXTABLEMAXSIZE && ENEMY_indextable[j] != -1; j ++ ) { + if( ENEMY_indextable[j] == work[r] ) cnt ++; + } + samecount = 0; + for( k = 0; k < found; k ++ ) { + if( work[r] == work[k] ) samecount ++; + } + if( cnt >= ENEMY_getInt( work[r], ENEMY_CREATEMAXNUM) * samecount ) { + continue; + } + + et_array = ENEMYTEMP_getEnemyTempArray( work[r]); + if( ENEMYTEMP_CHECKINDEX( et_array)) { + if( ENEMYTEMP_getInt( et_array, E_T_SIZE) == E_T_SIZE_BIG ) { + if( bigcnt >= 5 ) { + entrymax --; + continue; + } + if( i > 4 ) { + int target_et_array; + int flg = FALSE; + for( j = 0; j < 5; j ++ ) { + if( !ENEMY_CHECKINDEX( ENEMY_indextable[j])) break; + + target_et_array = ENEMYTEMP_getEnemyTempArray( + ENEMY_indextable[j]); + if( !ENEMYTEMP_CHECKINDEX( target_et_array)) break; + if( ENEMYTEMP_getInt( target_et_array, E_T_SIZE) == E_T_SIZE_NORMAL ){ + flg = TRUE; + break; + } + } + if( !flg) continue; + ENEMY_indextable[i] = ENEMY_indextable[j]; + ENEMY_indextable[j] = work[r]; + } + else { + ENEMY_indextable[i] = work[r]; + } + bigcnt ++; + }else { + ENEMY_indextable[i] = work[r]; + } + + i++; + } + } + return found > 0 ? ENEMY_indextable : NULL; +} +int ENEMY_createPetFromEnemyIndex( int charaindex, int array) +{ + Char CharNew; + int newindex; + int *p; + int tp[E_T_DATAINTNUM]; + int tarray, i; + int havepetelement; + int level; + int enemyrank; + if( !ENEMY_CHECKINDEX( array)) return -1; + havepetelement = CHAR_getCharPetElement( charaindex); + if( havepetelement < 0 ) return -1; + + p = ENEMY_enemy[array].intdata; + tarray = ENEMYTEMP_getEnemyTempArray( array); + if( !ENEMYTEMP_CHECKINDEX( tarray)) return -1; +// tp = ENEMYTEMP_enemy[tarray].intdata; + for( i = 0; i < E_T_DATAINTNUM; i ++ ){ + tp[i] = ENEMYTEMP_enemy[tarray].intdata[i]; + } + memset( &CharNew, 0, sizeof( Char ) ); + if( !CHAR_getDefaultChar( &CharNew,31010 ) )return -1; + CharNew.data[CHAR_BASEBASEIMAGENUMBER] + = CharNew.data[CHAR_BASEIMAGENUMBER] = *(tp+E_T_IMGNUMBER); + CharNew.data[CHAR_WHICHTYPE] = CHAR_TYPEPET; + level = RAND( (*(p + ENEMY_LV_MIN)), ( *(p+ ENEMY_LV_MAX))); + +#define E_PAR( a) (*(p + (a))) +#define ET_PAR( a) (*(tp + (a))) +#if 1 +#define PARAM_CAL( l) (( level -1)*ET_PAR( E_T_LVUPPOINT)+ ET_PAR(E_T_INITNUM)) * ET_PAR( (l)) +#else +#define PARAM_CAL( l) ( (E_PAR(ENEMY_LV) -1)*ET_PAR( E_T_LVUPPOINT)+ ET_PAR(E_T_INITNUM)) * ET_PAR( (l)) +#endif + tp[E_T_BASEVITAL] += RAND( 0, 4 ) - 2; + tp[E_T_BASESTR] += RAND( 0, 4 ) - 2; + tp[E_T_BASETGH] += RAND( 0, 4 ) - 2; + tp[E_T_BASEDEX] += RAND( 0, 4 ) - 2; + CharNew.data[CHAR_ALLOCPOINT] + = ( tp[E_T_BASEVITAL] << 24 ) + + ( tp[E_T_BASESTR] << 16 ) + + ( tp[E_T_BASETGH] << 8 ) + + ( tp[E_T_BASEDEX] << 0 ); + + for( i = 0; i < 10; i ++ ){ + int work = RAND( 0, 3 ); + if( work == 0 )tp[E_T_BASEVITAL]++; + if( work == 1 )tp[E_T_BASESTR]++; + if( work == 2 )tp[E_T_BASETGH]++; + if( work == 3 )tp[E_T_BASEDEX]++; + } + /* 由仿丢□正本永玄 */ + CharNew.data[CHAR_VITAL] = PARAM_CAL(E_T_BASEVITAL); + CharNew.data[CHAR_STR] = PARAM_CAL(E_T_BASESTR); + CharNew.data[CHAR_TOUGH] = PARAM_CAL(E_T_BASETGH); + CharNew.data[CHAR_DEX] = PARAM_CAL(E_T_BASEDEX); + + CharNew.data[CHAR_FIREAT] = *(tp+ E_T_FIREAT); + CharNew.data[CHAR_WATERAT] = *(tp+ E_T_WATERAT); + CharNew.data[CHAR_EARTHAT] = *(tp+ E_T_EARTHAT); + CharNew.data[CHAR_WINDAT] = *(tp+ E_T_WINDAT); + + CharNew.data[CHAR_SLOT] = *(tp+ E_T_SLOT); + CharNew.data[CHAR_MODAI] = *(tp+ E_T_MODAI); + CharNew.data[CHAR_VARIABLEAI] = 0; + CharNew.data[CHAR_LV] = level; + //CharNew.data[CHAR_LV] = *(p+ ENEMY_LV); + CharNew.data[CHAR_POISON] = *(tp+ E_T_POISON); + CharNew.data[CHAR_PARALYSIS]= *(tp+ E_T_PARALYSIS); + CharNew.data[CHAR_SLEEP] = *(tp+ E_T_SLEEP); + CharNew.data[CHAR_STONE] = *(tp+ E_T_STONE); + CharNew.data[CHAR_DRUNK] = *(tp+ E_T_DRUNK); + CharNew.data[CHAR_CONFUSION]= *(tp+ E_T_CONFUSION); + CharNew.data[CHAR_RARE] = *(tp+ E_T_RARE); + CharNew.data[CHAR_PETID] = *(tp + E_T_TEMPNO); + CharNew.data[CHAR_CRITIAL] = *(tp + E_T_CRITICAL); + CharNew.data[CHAR_COUNTER] = *(tp + E_T_COUNTER); + // Arminius 8.6 limit lv + CharNew.data[CHAR_LIMITLEVEL] = *(tp + E_T_LIMITLEVEL); +#ifdef _PET_FUSION + CharNew.data[CHAR_FUSIONCODE] = *(tp + E_T_FUSIONCODE); +#endif + CharNew.data[CHAR_PETMAILEFFECT] = RAND(0, PETMAIL_EFFECTMAX); + for( i = 0; i < CHAR_MAXPETSKILLHAVE; i ++ ) { + CharNew.unionTable.indexOfPetskill[i] = *(tp + E_T_PETSKILL1 + i); + } + enemyrank = ENEMY_getRank( array, tarray ); + CharNew.data[CHAR_PETRANK] = enemyrank; +#undef E_PAR +#undef ET_PAR +#undef PARAM_CAL + strcpysafe( CharNew.string[CHAR_NAME].string, + sizeof(CharNew.string[CHAR_NAME].string), + (char *)ENEMYTEMP_enemy[tarray].chardata[E_T_NAME].string ); + newindex = PET_initCharOneArray( &CharNew ); + if( newindex < 0 ){ + return -1; + } + CHAR_complianceParameter( newindex ); + CHAR_setInt( newindex, CHAR_HP, CHAR_getWorkInt( newindex, CHAR_WORKMAXHP)); + CHAR_setWorkInt( newindex, CHAR_WORKPLAYERINDEX, charaindex); + CHAR_setCharPet( charaindex, havepetelement, newindex); + CHAR_setChar( newindex, CHAR_OWNERCDKEY, + CHAR_getChar( charaindex, CHAR_CDKEY)); + CHAR_setChar( newindex, CHAR_OWNERCHARANAME, + CHAR_getChar( charaindex, CHAR_NAME)); + return newindex; +} + +#ifdef _TEST_PETCREATE +int ENEMY_TEST_createPetIndex( int array) +{ + Char CharNew; + int newindex; + int *p; + int tp[E_T_DATAINTNUM]; + int tarray, i; + //int havepetelement; + int level; + int enemyrank; + if( !ENEMY_CHECKINDEX( array)) return -1; + + //havepetelement = CHAR_getCharPetElement( charaindex); + //if( havepetelement < 0 ) return -1; + p = ENEMY_enemy[array].intdata; + tarray = ENEMYTEMP_getEnemyTempArray( array); + if( !ENEMYTEMP_CHECKINDEX( tarray)) return -1; + for( i = 0; i < E_T_DATAINTNUM; i ++ ){ + tp[i] = ENEMYTEMP_enemy[tarray].intdata[i]; + } + memset( &CharNew, 0, sizeof( Char ) ); + if( !CHAR_getDefaultChar( &CharNew,31010 ) )return -1; + CharNew.data[CHAR_BASEBASEIMAGENUMBER] + = CharNew.data[CHAR_BASEIMAGENUMBER] = *(tp+E_T_IMGNUMBER); + CharNew.data[CHAR_WHICHTYPE] = CHAR_TYPEPET; + level = RAND( (*(p + ENEMY_LV_MIN)), ( *(p+ ENEMY_LV_MAX))); + +#define E_PAR( a) (*(p + (a))) +#define ET_PAR( a) (*(tp + (a))) + +#if 1 +#define PARAM_CAL( l) (( level -1)*ET_PAR( E_T_LVUPPOINT)+ ET_PAR(E_T_INITNUM)) * ET_PAR( (l)) +#else +#define PARAM_CAL( l) ( (E_PAR(ENEMY_LV) -1)*ET_PAR( E_T_LVUPPOINT)+ ET_PAR(E_T_INITNUM)) * ET_PAR( (l)) +#endif + tp[E_T_BASEVITAL] += RAND( 0, 4 ) - 2; + tp[E_T_BASESTR] += RAND( 0, 4 ) - 2; + tp[E_T_BASETGH] += RAND( 0, 4 ) - 2; + tp[E_T_BASEDEX] += RAND( 0, 4 ) - 2; + CharNew.data[CHAR_ALLOCPOINT] + = ( tp[E_T_BASEVITAL] << 24 ) + + ( tp[E_T_BASESTR] << 16 ) + + ( tp[E_T_BASETGH] << 8 ) + + ( tp[E_T_BASEDEX] << 0 ); + for( i = 0; i < 10; i ++ ){ + int work = RAND( 0, 3 ); + if( work == 0 )tp[E_T_BASEVITAL]++; + if( work == 1 )tp[E_T_BASESTR]++; + if( work == 2 )tp[E_T_BASETGH]++; + if( work == 3 )tp[E_T_BASEDEX]++; + } + CharNew.data[CHAR_VITAL] = PARAM_CAL(E_T_BASEVITAL); + CharNew.data[CHAR_STR] = PARAM_CAL(E_T_BASESTR); + CharNew.data[CHAR_TOUGH] = PARAM_CAL(E_T_BASETGH); + CharNew.data[CHAR_DEX] = PARAM_CAL(E_T_BASEDEX); + CharNew.data[CHAR_FIREAT] = *(tp+ E_T_FIREAT); + CharNew.data[CHAR_WATERAT] = *(tp+ E_T_WATERAT); + CharNew.data[CHAR_EARTHAT] = *(tp+ E_T_EARTHAT); + CharNew.data[CHAR_WINDAT] = *(tp+ E_T_WINDAT); + + CharNew.data[CHAR_SLOT] = *(tp+ E_T_SLOT); + CharNew.data[CHAR_MODAI] = *(tp+ E_T_MODAI); + CharNew.data[CHAR_VARIABLEAI] = 0; + CharNew.data[CHAR_LV] = level; + CharNew.data[CHAR_POISON] = *(tp+ E_T_POISON); + CharNew.data[CHAR_PARALYSIS]= *(tp+ E_T_PARALYSIS); + CharNew.data[CHAR_SLEEP] = *(tp+ E_T_SLEEP); + CharNew.data[CHAR_STONE] = *(tp+ E_T_STONE); + CharNew.data[CHAR_DRUNK] = *(tp+ E_T_DRUNK); + CharNew.data[CHAR_CONFUSION]= *(tp+ E_T_CONFUSION); + CharNew.data[CHAR_RARE] = *(tp+ E_T_RARE); + CharNew.data[CHAR_PETID] = *(tp + E_T_TEMPNO); + CharNew.data[CHAR_CRITIAL] = *(tp + E_T_CRITICAL); + CharNew.data[CHAR_COUNTER] = *(tp + E_T_COUNTER); + // Arminius 8.6 limit lv + CharNew.data[CHAR_LIMITLEVEL] = *(tp + E_T_LIMITLEVEL); +#ifdef _PET_FUSION + CharNew.data[CHAR_FUSIONCODE] = *(tp + E_T_FUSIONCODE); +#endif + CharNew.data[CHAR_PETMAILEFFECT] = RAND(0, PETMAIL_EFFECTMAX); + for( i = 0; i < CHAR_MAXPETSKILLHAVE; i ++ ) { + CharNew.unionTable.indexOfPetskill[i] = *(tp + E_T_PETSKILL1 + i); + } + enemyrank = ENEMY_getRank( array, tarray ); + CharNew.data[CHAR_PETRANK] = enemyrank; +#undef E_PAR +#undef ET_PAR +#undef PARAM_CAL + strcpysafe( CharNew.string[CHAR_NAME].string, + sizeof(CharNew.string[CHAR_NAME].string), + (char *)ENEMYTEMP_enemy[tarray].chardata[E_T_NAME].string ); + newindex = PET_initCharOneArray( &CharNew ); + if( newindex < 0 ){ + return -1; + } + CHAR_complianceParameter( newindex ); + CHAR_setInt( newindex, CHAR_HP, CHAR_getWorkInt( newindex, CHAR_WORKMAXHP)); +// CHAR_setWorkInt( newindex, CHAR_WORKPLAYERINDEX, charaindex); +// CHAR_setCharPet( charaindex, havepetelement, newindex); +// CHAR_setChar( newindex, CHAR_OWNERCDKEY, +// CHAR_getChar( charaindex, CHAR_CDKEY)); +// CHAR_setChar( newindex, CHAR_OWNERCHARANAME, +// CHAR_getChar( charaindex, CHAR_NAME)); + return newindex; +} +#endif + +#ifdef _PET_EVOLUTION + +BOOL PETFUSION_getIndexForChar( int toindex, int *MainIndex, int *Subindex1, int *Subindex2, char *data) +{ + char buf1[256]; + int pindex[3]={-1,-1,-1}; + int i; + if( getStringFromIndexWithDelim( data, "|", 1, buf1, sizeof(buf1)) == FALSE ) + return FALSE; + pindex[0] = atoi( buf1)-1; + if( getStringFromIndexWithDelim( data, "|", 2, buf1, sizeof(buf1)) == FALSE ) + return FALSE; + pindex[1] = atoi( buf1)-1; + if( getStringFromIndexWithDelim( data, "|", 3, buf1, sizeof(buf1)) == FALSE ) + return FALSE; + pindex[2] = atoi( buf1)-1; + for( i=0; i<3; i++) { + int petindex; + if( pindex[i] < 0 ) continue; + petindex = CHAR_getCharPet( toindex, pindex[i]); + if( !CHAR_CHECKINDEX( petindex) ) continue; +#ifdef _PET_2TRANS + if( CHAR_getInt( petindex, CHAR_TRANSMIGRATION ) > 1 ) { + CHAR_talkToCli( toindex, -1, "二转宠物不能融合。", CHAR_COLORYELLOW); + return FALSE; + } +#endif + if( i == 0 ) { + *MainIndex = petindex; + }else if( i == 1) { + *Subindex1 = petindex; + }else if( i == 2) { + *Subindex2 = petindex; + } + } + return TRUE; +} +int NPC_getPetArrayForNo( int PetCode) +{ + int i; + int enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) {//PetCode + if( ENEMY_getInt( i, ENEMY_TEMPNO ) == PetCode ) + break; + } + + if( i == enemynum ){ + print("ANDY 2.err i == enemynum \n"); + return -1; + } + return i; +} +int NPC_getFusionTableForBase( int charaindex, int petindex1, int petindex2 ) +{ + int base1, base2;// 属性,PETCODE + if( !CHAR_CHECKINDEX( petindex1) ) return -1; + if( !CHAR_CHECKINDEX( petindex2) ) return -1; +#ifdef _PET_EVOLUTION + if( (base2 = EVOLUTION_getPetTable( charaindex, petindex1, petindex2)) < 0 ){ + print("ANDY err base2=%d\n", base2); + return -1; + } + if( (base1 = EVOLUTION_getPropertyTable( charaindex, petindex1, petindex2)) < 0 ){ + print("ANDY err base1=%d\n", base1); + return -1; + } + return EVOLUTION_getFusionTable( charaindex, base2, base1); // get new pet IDNO +#else + return -1; +#endif +} + +BOOL PET_getEvolutionAns( int petindex, int *base) +{ + int i, total1, total2, total; + int defwork = 50, defbase = 150; + int work[4]={0,0,0,0}; + + work[0] = CHAR_getInt( petindex, CHAR_EVOLUTIONBASEVTL); + work[1] = CHAR_getInt( petindex, CHAR_EVOLUTIONBASESTR); + work[2] = CHAR_getInt( petindex, CHAR_EVOLUTIONBASETGH); + work[3] = CHAR_getInt( petindex, CHAR_EVOLUTIONBASEDEX); + for( i=0; i<4; i++) { + work[i] = (work[i]*0.7)/100; + if( work[i]<0 ) work[i] = 0; + if( work[i]>60 ) work[i] = 60; + } + total1 = work[0] + work[1] + work[2] + work[3]; + for( i=0; i<4; i++) { + if( base[i] < 0 ) base[i] = 5; + if( base[i] > 60 ) base[i] = 60; + } + total2 = base[0] + base[1] + base[2] + base[3]; + if( total1 > defwork ) { + for( i=0; i<4; i++) { + work[i] = ((work[i]*defwork)/total1); + if( work[i]<0 ) work[i] = 0; + if( work[i]>60 ) work[i] = 60; + } + } + + total1 = work[0] + work[1] + work[2] + work[3]; + total = (total1/2) + total2; + + if( total > 0 ){ + for( i=0; i<4; i++) { + float fixwork=0.0; + fixwork = (base[i])+(float)(work[i]/2); + base[i] += (int)((fixwork/total) * total1); + if( base[i] < 1 ) base[i] = 1; + if( base[i] > 60 ) base[i] = 60; + } + } + total2 = base[0] + base[1] + base[2] + base[3]; + if( total2 > defbase ){ + for( i=0; i<4; i++) { + base[i] = (base[i]*defbase)/total2; + if( base[i] < 1 ) base[i] = 1; + if( base[i] > 60 ) base[i] = 60; + } + } + total2 = base[0] + base[1] + base[2] + base[3]; + if( base[0]<0 || base[1]<0 || base[2]<0 || base[3]<0 ){ + print("ANDY err EVOLUTION base someone < 0 !!\n"); + } + return TRUE; +} + +int EVOLUTION_createPetFromEnemyIndex( int charaindex, int baseindex, int flg) +{ + Char CharNew; + int newindex; + int *p; + int tp[E_T_DATAINTNUM]; + int tarray, i, havepetelement, enemynum, petID; + int level, enemyrank, array; + int petskill[7]={-1,-1,-1,-1,-1,-1,-1}; + int base[4]={0,0,0,0}; + int illegalpetskill[15] = {41,52,600,601,602,603,604,614,617,628,630,631,635,638,641};//不可遗传的宠技 +#define E_PAR( a) (*(p + (a))) +#define ET_PAR( a) (*(tp + (a))) +#define PARAM_CAL( l) (( level -1)*ET_PAR( E_T_LVUPPOINT)+ ET_PAR(E_T_INITNUM)) * ET_PAR( (l)) + havepetelement=-1; + petID = CHAR_getInt( baseindex, CHAR_FUSIONINDEX); + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_TEMPNO ) == petID ){ + break; + } + } + if( i >= enemynum ) return -1; + array = i; + if( !ENEMY_CHECKINDEX( array)) return -1; +//-------------------------------------------------------------------------- + p = ENEMY_enemy[array].intdata; + tarray = ENEMYTEMP_getEnemyTempArray( array); + if( !ENEMYTEMP_CHECKINDEX( tarray)){ + print( "ANDY !tarray\n"); + return -1; + } + for( i = 0; i < E_T_DATAINTNUM; i ++ ){ + tp[i] = ENEMYTEMP_enemy[tarray].intdata[i]; + } + memset( &CharNew, 0, sizeof( Char ) ); + if( !CHAR_getDefaultChar( &CharNew,31010 ) ){ + print( "ANDY !CHAR_getDefaultChar( &CharNew,31010 )\n"); + return -1; + } + CharNew.data[CHAR_BASEBASEIMAGENUMBER] + = CharNew.data[CHAR_BASEIMAGENUMBER] = *(tp+E_T_IMGNUMBER); + CharNew.data[CHAR_WHICHTYPE] = CHAR_TYPEPET; + level = RAND( (*(p + ENEMY_LV_MIN)), ( *(p+ ENEMY_LV_MAX))); +//------------------------------------------------------ + { + if( PET_getBaseAndSkill( charaindex, baseindex, base, petskill, 1) == FALSE ){ + print( "ANDY err PET_getBaseAndSkill(%d) == FALSE \n", baseindex); + return -1; + } + if( PET_getEvolutionAns( baseindex, base) == FALSE ) return -1; + for( i=0; i < CHAR_MAXPETSKILLHAVE; i ++ ) {//宠技 + int j; + for( j=0; j<15; j++) { //检查非法技能 + if( illegalpetskill[j] == petskill[i] ){ + petskill[i] = -1; + break; + } + } + CharNew.unionTable.indexOfPetskill[i] = petskill[i]; + } + if( flg == 1 ){ + if( CHAR_DelPetForIndex( charaindex, baseindex) == FALSE ) return FALSE; + } + } + if( flg == 1 ){ + havepetelement = CHAR_getCharPetElement( charaindex);//找出宠物空位 + if( havepetelement < 0 ) return -1; + } +//------------------------------------------------------ + tp[E_T_BASEVITAL] = base[0]; + tp[E_T_BASESTR] = base[1]; + tp[E_T_BASETGH] = base[2]; + tp[E_T_BASEDEX] = base[3]; + CharNew.data[CHAR_ALLOCPOINT] = (base[0]<<24)+(base[1]<<16)+(base[2]<<8)+(base[3]<<0); + + for( i = 0; i < 10; i ++ ){ + int work = RAND( 0, 3 ); + if( work == 0 )tp[E_T_BASEVITAL]++; + if( work == 1 )tp[E_T_BASESTR]++; + if( work == 2 )tp[E_T_BASETGH]++; + if( work == 3 )tp[E_T_BASEDEX]++; + } +//------------------------------------------------------ + CharNew.data[CHAR_VITAL] = PARAM_CAL(E_T_BASEVITAL); + CharNew.data[CHAR_STR] = PARAM_CAL(E_T_BASESTR); + CharNew.data[CHAR_TOUGH] = PARAM_CAL(E_T_BASETGH); + CharNew.data[CHAR_DEX] = PARAM_CAL(E_T_BASEDEX); + CharNew.data[CHAR_FIREAT] = *(tp+ E_T_FIREAT); + CharNew.data[CHAR_WATERAT] = *(tp+ E_T_WATERAT); + CharNew.data[CHAR_EARTHAT] = *(tp+ E_T_EARTHAT); + CharNew.data[CHAR_WINDAT] = *(tp+ E_T_WINDAT); + CharNew.data[CHAR_SLOT] = *(tp+ E_T_SLOT); + CharNew.data[CHAR_MODAI] = *(tp+ E_T_MODAI); + CharNew.data[CHAR_VARIABLEAI] = 0; + CharNew.data[CHAR_LV] = level; + CharNew.data[CHAR_POISON] = *(tp+ E_T_POISON); + CharNew.data[CHAR_PARALYSIS]= *(tp+ E_T_PARALYSIS); + CharNew.data[CHAR_SLEEP] = *(tp+ E_T_SLEEP); + CharNew.data[CHAR_STONE] = *(tp+ E_T_STONE); + CharNew.data[CHAR_DRUNK] = *(tp+ E_T_DRUNK); + CharNew.data[CHAR_CONFUSION]= *(tp+ E_T_CONFUSION); + CharNew.data[CHAR_RARE] = *(tp+ E_T_RARE); + CharNew.data[CHAR_PETID] = *(tp + E_T_TEMPNO); + CharNew.data[CHAR_CRITIAL] = *(tp + E_T_CRITICAL); + CharNew.data[CHAR_COUNTER] = *(tp + E_T_COUNTER); + CharNew.data[CHAR_LIMITLEVEL] = *(tp + E_T_LIMITLEVEL); + CharNew.data[CHAR_FUSIONCODE] = *(tp + E_T_FUSIONCODE); + CharNew.data[CHAR_PETMAILEFFECT] = RAND(0, PETMAIL_EFFECTMAX); +//------------------------------------------------------ + + enemyrank = ENEMY_getRank( array, tarray ); + CharNew.data[CHAR_PETRANK] = enemyrank; +#undef E_PAR +#undef ET_PAR +#undef PARAM_CAL + strcpysafe( CharNew.string[CHAR_NAME].string, + sizeof(CharNew.string[CHAR_NAME].string), + (char *)ENEMYTEMP_enemy[tarray].chardata[E_T_NAME].string ); + newindex = PET_initCharOneArray( &CharNew ); + if( newindex < 0 ){ + print( "ANDY err newindex=%d\n", newindex); + return -1; + } +//------------------------------------------------------ + CHAR_complianceParameter( newindex ); + CHAR_setInt( newindex, CHAR_HP, CHAR_getWorkInt( newindex, CHAR_WORKMAXHP)); + CHAR_setInt ( newindex, CHAR_WHICHTYPE , CHAR_TYPEPET); +#ifdef _PET_2TRANS + CHAR_setInt ( newindex, CHAR_TRANSMIGRATION, 2); +#else + CHAR_setInt ( newindex, CHAR_TRANSMIGRATION, 1); +#endif + CHAR_setInt ( newindex, CHAR_FUSIONBEIT, 1); + CHAR_setInt ( newindex, CHAR_FUSIONRAISE, 0); + if( flg == 1 ){ + CHAR_setWorkInt( newindex, CHAR_WORKPLAYERINDEX, charaindex); + CHAR_setCharPet( charaindex, havepetelement, newindex); + CHAR_setChar( newindex, CHAR_OWNERCDKEY, CHAR_getChar( charaindex, CHAR_CDKEY)); + CHAR_setChar( newindex, CHAR_OWNERCHARANAME, CHAR_getChar( charaindex, CHAR_NAME)); + { + char msgbuf[256]; + snprintf( msgbuf, sizeof( msgbuf ), "K%d", havepetelement ); + CHAR_sendStatusString( charaindex, msgbuf ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d", havepetelement ); + CHAR_sendStatusString( charaindex, msgbuf ); + } + } + return newindex; +} + +int PET_CheckIncubate( int charaindex) +{ +#ifndef _USER_CHARLOOPS + int i; + static time_t checkeage; + int anhour = PETFEEDTIME; + checkeage = (int)time( NULL); + if( !CHAR_CHECKINDEX( charaindex) )return 0; + + for(i=0 ; i < CHAR_MAXPETHAVE ; i++) { + int time_l=0; + int petindex = CHAR_getCharPet( charaindex, i); + if( !CHAR_CHECKINDEX( petindex) ) continue; + if( CHAR_getInt( petindex, CHAR_FUSIONBEIT) != 1 || + CHAR_getInt( petindex, CHAR_FUSIONRAISE) <= 0 )return;//检查是否为融合宠 + + time_l = CHAR_getInt( petindex, CHAR_FUSIONTIMELIMIT); + if( time_l < 0 || time_l > checkeage ){ + CHAR_setInt( petindex, CHAR_FUSIONTIMELIMIT, checkeage); + continue; + } + + if( (int)checkeage > (time_l+(anhour*2)) ){ + char buf[256]; + int levelup, vital, str, tgh, dex; + int raise = CHAR_getInt( petindex, CHAR_FUSIONRAISE); + // 养次数 + raise++; + CHAR_setInt( petindex, CHAR_FUSIONTIMELIMIT, (int)time(NULL)+anhour-1); + if( raise < 0 ) raise = 0; + if( raise >= 40 ) raise = 30; + CHAR_setInt( petindex, CHAR_FUSIONRAISE, raise); + levelup = CHAR_getInt( petindex, CHAR_ALLOCPOINT); + vital = ((levelup>>24) & 0xFF) - 5; + str = ((levelup>>16) & 0xFF) - 5; + tgh = ((levelup>> 8) & 0xFF) - 5; + dex = ((levelup>> 0) & 0xFF) - 5; + if( vital < 0 ) vital = 0; + if( str < 0 ) str = 0; + if( tgh < 0 ) tgh = 0; + if( dex < 0 ) dex = 0; + //扣属性 + levelup = (vital<<24) + (str<<16) + (tgh<<8) + (dex<<0); + CHAR_setInt( petindex, CHAR_ALLOCPOINT, levelup); + sprintf( buf, "蛋〈%s〉的品质变差了。", CHAR_getUseName( petindex )); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + + LogPetFeed( + CHAR_getChar( charaindex, CHAR_NAME), + CHAR_getChar( charaindex, CHAR_CDKEY), + CHAR_getChar( petindex, CHAR_NAME), + petindex, + CHAR_getInt( petindex, CHAR_LV), + "品质变差", // Key + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y), + CHAR_getChar( petindex, CHAR_UNIQUECODE) ); + + }else if( (int)checkeage > (time_l+anhour) ){ + + char buf[256]; + sprintf( buf, "蛋〈%s〉呈现可 食状态。", CHAR_getUseName( petindex )); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + } + } + return 1; +#else + int masterindex, time_l=0; + static time_t checkeage; + int anhour = PETFEEDTIME, i; + + if( !CHAR_CHECKINDEX( charaindex) )return 0; + masterindex = CHAR_getWorkInt( charaindex, CHAR_WORKPLAYERINDEX); + if( !CHAR_CHECKINDEX( masterindex) )return 0; + + if( CHAR_getInt( charaindex, CHAR_FUSIONBEIT) != 1 || + CHAR_getInt( charaindex, CHAR_FUSIONRAISE) <= 0 ) return 0;//检查是否为融合宠 + + for(i=0 ; i < CHAR_MAXPETHAVE ; i++) { + if( charaindex != CHAR_getCharPet( masterindex, i) ) continue; + break; + } + if( i >= CHAR_MAXPETHAVE ) return 0; + +#ifdef _PET_FUSIONSHOWTIME + { + + char caname[256], msgbuf[64]; + int deftime; + int oldtime = CHAR_getInt( charaindex, CHAR_FUSIONTIMELIMIT); + + for(i=0 ; i < CHAR_MAXPETHAVE ; i++) { + if( charaindex != CHAR_getCharPet( masterindex, i) ) continue; + deftime = anhour - ( checkeage - oldtime); + if( deftime >= 0 ){ + sprintf( caname, "宠物蛋(%d)", (int)(deftime/60)); + }else{ + deftime = ( checkeage - oldtime) - anhour; + sprintf( caname, "宠物蛋(饿%d)", (int)(deftime/60)); + } + CHAR_setChar( charaindex, CHAR_USERPETNAME, caname); + snprintf( msgbuf, sizeof( msgbuf ), "K%d", i ); + CHAR_sendStatusString( masterindex, msgbuf ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d", i ); + CHAR_sendStatusString( masterindex, msgbuf ); + break; + } + } +#endif + checkeage = (int)time( NULL); + + time_l = CHAR_getInt( charaindex, CHAR_FUSIONTIMELIMIT); + if( time_l < 0 || time_l > checkeage ){ + CHAR_setInt( charaindex, CHAR_FUSIONTIMELIMIT, checkeage); + return 0; + } + if( (int)checkeage > (time_l+(anhour*2.5)) ){ + char buf[256]; + int levelup, vital, str, tgh, dex; + int raise = CHAR_getInt( charaindex, CHAR_FUSIONRAISE); + raise++; + CHAR_setInt( charaindex, CHAR_FUSIONTIMELIMIT, (int)time(NULL)+anhour-1); + if( raise < 0 ) raise = 0; + if( raise >= 40 ) raise = 30; + CHAR_setInt( charaindex, CHAR_FUSIONRAISE, raise); + levelup = CHAR_getInt( charaindex, CHAR_ALLOCPOINT); + vital = ((levelup>>24) & 0xFF) - 6; + str = ((levelup>>16) & 0xFF) - 6; + tgh = ((levelup>> 8) & 0xFF) - 6; + dex = ((levelup>> 0) & 0xFF) - 6; + if( vital < 0 ) vital = 0; + if( str < 0 ) str = 0; + if( tgh < 0 ) tgh = 0; + if( dex < 0 ) dex = 0; + //扣属性 + levelup = (vital<<24) + (str<<16) + (tgh<<8) + (dex<<0); + CHAR_setInt( charaindex, CHAR_ALLOCPOINT, levelup); + sprintf( buf, "蛋〈%s〉的品质变差了。", CHAR_getUseName( charaindex )); + CHAR_talkToCli( masterindex, -1, buf, CHAR_COLORYELLOW); + + LogPetFeed( + CHAR_getChar( masterindex, CHAR_NAME), + CHAR_getChar( masterindex, CHAR_CDKEY), + CHAR_getChar( charaindex, CHAR_NAME), + charaindex, + CHAR_getInt( charaindex, CHAR_LV), + "品质变差", // Key + CHAR_getInt( masterindex, CHAR_FLOOR), + CHAR_getInt( masterindex, CHAR_X), + CHAR_getInt( masterindex, CHAR_Y), + CHAR_getChar( charaindex, CHAR_UNIQUECODE) ); + + }else if( (int)checkeage > (time_l+anhour) ){ + char buf[256]; + sprintf( buf, "蛋〈%s〉呈现可 食状态。", CHAR_getUseName( charaindex )); + CHAR_talkToCli( masterindex, -1, buf, CHAR_COLORYELLOW); + } + return 1; +#endif +} +#endif + +#ifdef _NPC_FUSION +int PETFUSION_SetNewEgg( int toindex , int petindex, int array, int *work, int *skill1, int *skill2) +{ + int *p; + int tp[E_T_DATAINTNUM]; + int tarray, i; + int level, workrank, petrank=0; + int LevelUpPoint; + struct { + int num; + float rank; + }ranktbl[] = { + { 130, 2.5}, + { 100, 2.0}, + { 95, 1.5}, + { 85, 1.0}, + { 80, 0.5}, + { 0, 0.0}, + }; + if( !ENEMY_CHECKINDEX( array)) + return -1; + p = ENEMY_getIntdata( array); + if( p == NULL ) { + print("\n p = NULL" ); + return -1; + } + tarray = ENEMYTEMP_getEnemyTempArray( array); + if( !ENEMYTEMP_CHECKINDEX( tarray)) + return -1; + //print( "ANDY tarray/array=%d/%d-->%s \n", tarray, array, + // ENEMYTEMP_getChar( tarray, E_T_NAME)); + for( i = 0; i < E_T_DATAINTNUM; i ++ ){ + tp[i] = ENEMYTEMP_getInt( tarray, i); + } + level = 1; +#define RAND(x,y) ((x-1)+1+ (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) ) +#define E_PAR( a) (*(p + (a))) +#define ET_PAR( a) (*(tp + (a))) +#define PARAM_CAL( l) ( ( level -1) * ET_PAR( E_T_LVUPPOINT) + ET_PAR( E_T_INITNUM) ) + work[0] += ( RAND(0,4) - 2 ); + work[1] += ( RAND(0,4) - 2 ); + work[2] += ( RAND(0,4) - 2 ); + work[3] += ( RAND(0,4) - 2 ); + LevelUpPoint = ( work[0] << 24 ) + + (work[1] << 16) + + (work[2] << 8 ) + + (work[3] << 0 ); + + CHAR_setInt( petindex, CHAR_ALLOCPOINT, LevelUpPoint); + workrank = work[0]+work[1]+work[2]+work[3]; + for( i = 0; i < arraysizeof( ranktbl); i ++ ) { + if( workrank >= ranktbl[i].num ) { + petrank = i; + break; + } + } + if( i>= arraysizeof( ranktbl)) i = arraysizeof( ranktbl); + CHAR_setInt( petindex, CHAR_PETRANK, petrank); + for( i = 0; i < 10; i ++ ){ + int rnt = RAND( 0, 3 ); + if( rnt == 0 ) work[0]++; + if( rnt == 1 ) work[1]++; + if( rnt == 2 ) work[2]++; + if( rnt == 3 ) work[3]++; + } + + CHAR_setInt( petindex, CHAR_VITAL, ( PARAM_CAL(E_T_BASEVITAL) * work[0] )); + CHAR_setInt( petindex, CHAR_STR , ( PARAM_CAL(E_T_BASESTR) * work[1] )); + CHAR_setInt( petindex, CHAR_TOUGH , ( PARAM_CAL(E_T_BASETGH) * work[2] )); + CHAR_setInt( petindex, CHAR_DEX , ( PARAM_CAL(E_T_BASEDEX) * work[3] )); + CHAR_setMaxExp( petindex, 0); + CHAR_setInt( petindex, CHAR_LV, level); + + //宠物技能设为七技 + CHAR_setInt( petindex, CHAR_SLOT, 7); + { + int j; + int illegalpetskill[15] = {41,52,600,601,602,603,604,614,617,628,630,631,635,638,641}; + for( i=0; icharfunctable[CHAR_LOOPFUNCTEMP1].string, + sizeof( ch->charfunctable[CHAR_LOOPFUNCTEMP1]), "PET_CheckIncubateLoop"); + ch->data[CHAR_LOOPINTERVAL] = 60000; + CHAR_constructFunctable( petindex); + } +#endif + if( CHAR_CHECKINDEX( toindex) ){ + for(i = 0; i < CHAR_MAXPETHAVE; i++){ + char msgbuf[256]; + int pindex = CHAR_getCharPet(toindex, i); + if( !CHAR_CHECKINDEX( pindex) ) + continue; + memset( msgbuf, 0, sizeof( msgbuf)); + snprintf( msgbuf, sizeof( msgbuf ), "K%d", i ); + CHAR_sendStatusString( toindex, msgbuf ); + + CHAR_send_K_StatusString(toindex, i,CHAR_K_STRING_HP|CHAR_K_STRING_AI); + } + } + return petindex; +} + +BOOL PETFUSION_AddEgg( int toindex, int petID, int PetCode) +{ + int ret; + char msgbuf[64]; + int enemynum; + int i,j; + int petindex, petindex2; + + //检查宠物栏是否有空位 + for( i = 0 ;i < CHAR_MAXPETHAVE ; i++) { + petindex = CHAR_getCharPet( toindex, i); + if( petindex == -1 ) + break; + } + if( i == CHAR_MAXPETHAVE ) { + snprintf( msgbuf,sizeof( msgbuf), "宠物已满!!"); + CHAR_talkToCli( toindex, -1, msgbuf, CHAR_COLORYELLOW); + return -1; + } + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) {//PetCode + if( ENEMY_getInt( i, ENEMY_ID ) == petID ) + //if( ENEMY_getInt( i, ENEMY_TEMPNO ) == PetCode ) + break; + } + if( i == enemynum ){ + print("ANDY err i == enemynum \n"); + return -1; + } + ret = ENEMY_createPetFromEnemyIndex( toindex, i); + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + if( CHAR_getCharPet( toindex, i ) == ret ) + break; + } + if( i == CHAR_MAXPETHAVE ) + i = 0; + if( CHAR_CHECKINDEX( ret ) == TRUE ){ + CHAR_setMaxExpFromLevel( ret, CHAR_getInt( ret, CHAR_LV )); + } + petindex2 = CHAR_getCharPet( toindex, i); + if( !CHAR_CHECKINDEX( petindex2) ){ + print("ANDY petindex2=%d\n", petindex2); + return -1; + } + CHAR_setInt( petindex2, CHAR_FUSIONINDEX, PetCode); + snprintf( msgbuf,sizeof( msgbuf), "拿到%s。", CHAR_getChar(petindex2,CHAR_NAME)); + CHAR_talkToCli( toindex, -1, msgbuf, CHAR_COLORYELLOW); + for(j = 0; j < CHAR_MAXPETHAVE; j++){ + petindex = CHAR_getCharPet(toindex, j); + if( !CHAR_CHECKINDEX( petindex) ) + continue; + CHAR_complianceParameter( petindex ); + snprintf( msgbuf, sizeof( msgbuf ), "K%d", j ); + CHAR_sendStatusString( toindex, msgbuf ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d", j ); + CHAR_sendStatusString( toindex, msgbuf ); + } + LogPet( + CHAR_getChar( toindex, CHAR_NAME ), + CHAR_getChar( toindex, CHAR_CDKEY ), + CHAR_getChar( petindex2, CHAR_NAME), + CHAR_getInt( petindex2, CHAR_LV), + "TenseiGet", + CHAR_getInt( toindex,CHAR_FLOOR), + CHAR_getInt( toindex,CHAR_X ), + CHAR_getInt( toindex,CHAR_Y ), + CHAR_getChar( petindex2, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + + return petindex2; +} +#endif + +#ifdef _PET_TRANS +int GetNewPet( int toindex , int petindex, int array, int *work) +{ + int *p; + int tp[E_T_DATAINTNUM]; + int tarray, i; + int level, workrank, petrank=0; + int LevelUpPoint; + + struct { + int num; + float rank; + }ranktbl[] = { + { 130, 2.5}, + { 100, 2.0}, + { 95, 1.5}, + { 85, 1.0}, + { 80, 0.5}, + { 0, 0.0}, + }; + + if( !ENEMY_CHECKINDEX( array)) + return -1; + p = ENEMY_getIntdata( array); + if( p == NULL ) { + print("\n p = NULL" ); + return -1; + } + tarray = ENEMYTEMP_getEnemyTempArray( array); + if( !ENEMYTEMP_CHECKINDEX( tarray)) + return -1; + for( i = 0; i < E_T_DATAINTNUM; i ++ ){ + tp[i] = ENEMYTEMP_getInt( tarray, i); + } + level = 1; +#define RAND(x,y) ((x-1)+1+ (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) ) +#define E_PAR( a) (*(p + (a))) +#define ET_PAR( a) (*(tp + (a))) +#define PARAM_CAL( l) ( ( level -1) * ET_PAR( E_T_LVUPPOINT) + ET_PAR( E_T_INITNUM) ) + work[0] += ( RAND(0,4) - 2 ); + work[1] += ( RAND(0,4) - 2 ); + work[2] += ( RAND(0,4) - 2 ); + work[3] += ( RAND(0,4) - 2 ); + + LevelUpPoint = ( work[0] << 24 ) + + (work[1] << 16) + + (work[2] << 8 ) + + (work[3] << 0 ); + CHAR_setInt( petindex, CHAR_ALLOCPOINT, LevelUpPoint); + workrank = work[0]+work[1]+work[2]+work[3]; + for( i = 0; i < arraysizeof( ranktbl); i ++ ) { + if( workrank >= ranktbl[i].num ) { + petrank = i; + break; + } + } + + if( i>= arraysizeof( ranktbl)) i = arraysizeof( ranktbl); + CHAR_setInt( petindex, CHAR_PETRANK, petrank); + + for( i = 0; i < 10; i ++ ){ + int rnt = RAND( 0, 3 ); + if( rnt == 0 ) work[0]++; + if( rnt == 1 ) work[1]++; + if( rnt == 2 ) work[2]++; + if( rnt == 3 ) work[3]++; + } + + CHAR_setInt( petindex, CHAR_VITAL, ( PARAM_CAL(E_T_BASEVITAL) * work[0] )); + CHAR_setInt( petindex, CHAR_STR , ( PARAM_CAL(E_T_BASESTR) * work[1] )); + CHAR_setInt( petindex, CHAR_TOUGH , ( PARAM_CAL(E_T_BASETGH) * work[2] )); + CHAR_setInt( petindex, CHAR_DEX , ( PARAM_CAL(E_T_BASEDEX) * work[3] )); + CHAR_setMaxExp( petindex, 0); + CHAR_setInt( petindex, CHAR_LV, level); + //宠物技能设为七技 + CHAR_setInt( petindex, CHAR_SLOT, 7); +/* for( i=0; i + +#include "object.h" +#include "char_base.h" +#include "char.h" +#include "readmap.h" +#include "map_warppoint.h" +#include "event.h" +#include "npc_warp.h" +#include "npc_npcenemy.h" + + +static int EVENT_onWarpNPC( int charaindex,int echaraindex,int fl,int x, int y ); +static int EVENY_npcEncount( int charaindex,int echaraindex,int fl,int x, int y ); + + +typedef int (*FUNC)( int charaindex,int echaraindex,int fl,int x, int y ); +static FUNC functbl[] = { + NULL, + NULL, /* 裔烂NPC */ + EVENY_npcEncount, /* 裔烂衬巨件市它件玄 */ + EVENT_onWarpNPC, /* warp*/ + NULL, /* 裔烂NPC */ + NULL, /* 裔烂NPC */ + EVENT_onWarpNPC, /* warp*/ + EVENT_onWarpNPC, /* warp*/ + EVENT_onWarpNPC, /* warp*/ +}; + +INLINE BOOL EVENT_CHECKEVENTINDEX( int event) +{ + if( event < 0 || event >= CHAR_EVENTNUM) return FALSE; + return TRUE; +} + +int EVENT_main( int charaindex,int event, int x, int y) +{ + OBJECT object; + BOOL found = FALSE; + int rc = FALSE; + int fl = CHAR_getInt( charaindex, CHAR_FLOOR); + if( !EVENT_CHECKEVENTINDEX( event)) return FALSE; + + for( object = MAP_getTopObj(fl,x,y) ; object ; + object = NEXT_OBJECT(object) ){ + int o = GET_OBJINDEX(object); + if( OBJECT_getType(o) == OBJTYPE_CHARA ){ + int etype; + int echaraindex=OBJECT_getIndex(o); + if( !CHAR_CHECKINDEX(echaraindex) )continue; + if( CHAR_getInt( echaraindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) continue; + etype = CHAR_getWorkInt( echaraindex, CHAR_WORKEVENTTYPE); + if( etype != CHAR_EVENT_NONE ) { + if( etype == event) { + if( functbl[event] != NULL ) { + rc = functbl[event]( charaindex, echaraindex, fl,x,y); + } + found = TRUE; + break; + } + } + } +#ifdef _MAP_WARPPOINT + else if( OBJECT_getType(o) == OBJTYPE_WARPPOINT){ + if( !MAPPOINT_CHECKINDEX( OBJECT_getIndex( o)) ) continue; + if( OBJECT_getchartype( o) != event ) continue; + MAPPOINT_MapWarpHandle( charaindex, OBJECT_getIndex( o), fl, x, y ); + found = TRUE; + break; + } +#endif + } + if( !found ) { + print( "not found eventobject : cind [%d] event [%d] fl[%d] x[%d] y[%d]\n", + charaindex, event, fl,x,y); + } + return rc; +} + +static int EVENT_onWarpNPC( int charaindex,int echaraindex,int fl,int x, int y ) +{ + NPC_WarpWarpCharacter( echaraindex, charaindex); + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE ) == CHAR_PARTY_LEADER ) { + int i; + for( i = 1; i < CHAR_PARTYMAX; i ++ ) { + int index = CHAR_getWorkInt( charaindex, i + CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX(index) ) { + NPC_WarpWarpCharacter( echaraindex, index); + } + } + } + + return TRUE; +} +static int EVENY_npcEncount( int charaindex,int echaraindex,int fl,int x, int y ) +{ + return NPC_NPCEnemy_Encount( echaraindex, charaindex, 0); +} + diff --git a/gmsv/char/family.c b/gmsv/char/family.c new file mode 100644 index 0000000..27143b0 --- /dev/null +++ b/gmsv/char/family.c @@ -0,0 +1,3012 @@ +#include "version.h" +#include +#include +#include +#include + +#include "readmap.h" +#include "object.h" +#include "char.h" +#include "char_base.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "npcutil.h" +#include "family.h" +#include "log.h" +#include "handletime.h" +#include "buf.h" +#include "net.h" +#include "char_base.h" +#include "battle.h" +#include "npc_bus.h" +#include "char_talk.h" +#include "npc_scheduleman.h" +#ifdef _FM_MODIFY +#include "npc_fmdengon.h" +#endif + +#define CHAR_MAXNAME 20 +#define CHAR_MAXID 20 +#define MINFMLEVLEFORPOINT 3 // 3 申请庄园最低等级 +#ifdef _FAMILY_MANORNUM_CHANGE +#else +#define MANORNUM 4 +#endif + +struct FAMILY +{ + int fmindex; + char name[CHAR_MAXNAME]; + char leadername[CHAR_MAXNAME]; + char leaderid[CHAR_MAXID]; + int leadergraph; + char petname[CHAR_MAXNAME]; + char petattr[256]; + int fmnum; + int acceptflag; + char rule[256]; + int village; + int pointindex; + int dp; + char memolist[35][100]; +}; + +int familyNumTotal = 0; +char familyListBuf[MAXFAMILYLIST]; + +int channelMember[FAMILY_MAXNUM][FAMILY_MAXCHANNEL][FAMILY_MAXMEMBER]; +int familyMemberIndex[FAMILY_MAXNUM][FAMILY_MAXMEMBER]; + +int familyTax[FAMILY_MAXNUM]; + +extern tagRidePetTable ridePetTable[296]; + +void LeaveMemberIndex( int charaindex, int fmindexi); + + +// Arminius: 取得家族 pk dp 增加/损失值 +// getFMdpAward +// arg: windp=winner's fmdp losedp=loser's fmdp +// ret: dp award +// +#ifdef _MERGE_NEW_8 +int fmdplevelexp[]={0, // 0 + 150000, // 1 + 500000, // 2 + 1000000, // 3 + 1500000, // 4 + 2000000, // 5 + 2500000, // 6 + 3500000, // 7 + 4500000, // 8 + 5000000, // 9 + 7000000 //10 + }; +#else +int fmdplevelexp[]={0, // 0 + 10000, // 1 + 30000, // 2 + 100000, // 3 + 500000, // 4 + 1500000, // 5 + 5000000, // 6 + 15000000, // 7 + 50000000, // 8 + 200000000, // 9 + 500000000 //10 + }; +#endif +// Arminius end + +// shan begin +int getFmLv(int playerindex) // 合成时专用 +{ + int i, dp; + dp = CHAR_getWorkInt(playerindex, CHAR_WORKFMDP); + if( dp > fmdplevelexp[10] ){ +// print("\n player DP->%d",dp); + return 10; + } + for(i=0; i<=10; i++) + if( dp <= fmdplevelexp[i+1] ) break; + // Nuke 20040217: Open the merge limit + //if(i>=9) i = 8; + if (i>=10) i=10; + + return i; +} + +#ifdef _MERGE_NEW_8 // 查询个人声望等级 +int famelevelexp[]={0, // 0 + 1500, // 1 + 3000, // 2 + 4500, // 3 + 7500, // 4 + 11000, // 5 + 14500, // 6 + 18000, // 7 + 25000, // 8 + 32000, // 9 + 39000 //10 + }; + +int getFameLv(int playerindex) // 合成时专用 +{ + int i, dp; + dp = CHAR_getWorkInt(playerindex, CHAR_FAME); + if( dp > famelevelexp[10] ){ + return 10; + } + for(i=0; i<=10; i++) + if( dp <= famelevelexp[i+1] ) break; + if (i>=10) i=10; + + return i; +} +#endif + +struct FMMEMBER_LIST memberlist[FAMILY_MAXNUM]; +struct FMS_MEMO fmsmemo; +struct FM_POINTLIST fmpointlist; +#ifdef _NEW_MANOR_LAW +ManorSchedule_t ManorSchedule[MANORNUM]; +#endif +struct FMS_DPTOP fmdptop; +struct FM_PKFLOOR fmpkflnum[FAMILY_FMPKFLOOR]= +{ + {142}, + {143}, + {144}, + {145}, + {146}, + {1042}, + {2032}, + {3032}, + {4032}, +#ifdef _FAMILY_MANORNUM_CHANGE // CoolFish 用来修改装园数量 + {5032}, + {6032}, + {7032}, + {8032}, + {9032}, + {10032}, +#endif +}; +int leaderdengonindex = 0; +// shan end 新增图层需到 family.h 增加 FAMILY_FMPKFLOOR 数量 + +void SetFMPetVarInit(int meindex) +{ + int i = 0, petindex = 0; +#ifdef _FMVER21 + if (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER) +#else + if (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != 1) +#endif + { + for (i = 0; i < CHAR_MAXPETHAVE; i++) + { + petindex = CHAR_getCharPet(meindex, i); + if (!CHAR_CHECKINDEX(petindex)) continue; + CHAR_setInt(petindex, CHAR_PETFAMILY, -1); + } + } +} + +void SetFMVarInit(int meindex) +{ + SetFMPetVarInit(meindex); // 清除守护兽 Flag + CHAR_setInt(meindex, CHAR_FMINDEX, -1); + CHAR_setChar(meindex, CHAR_FMNAME, ""); + CHAR_setInt(meindex, CHAR_FMSPRITE, -1); +#ifdef _FMVER21 + CHAR_setInt(meindex, CHAR_FMLEADERFLAG, FMMEMBER_NONE); +#else + CHAR_setInt(meindex, CHAR_FMLEADERFLAG, -1); +#endif + CHAR_setWorkInt(meindex, CHAR_WORKFMSETUPFLAG, -1); + CHAR_setWorkInt(meindex, CHAR_WORKFMINDEXI, -1); + CHAR_setWorkInt(meindex, CHAR_WORKFMCHARINDEX, -1); +} + +void FAMILY_Init( void ) +{ + int i, j ,k; + + for( i=0; i 0) return -1; + if (strcmp(CHAR_getChar(meindex, CHAR_FMNAME), "") != 0) return -1; +#ifdef _FMVER21 + if (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) == FMMEMBER_LEADER) return -1; +#else + if (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) == 1) return -1; +#endif + return 1; +} + +int CheckFMMember(int meindex) +{ + if (CHAR_getInt(meindex, CHAR_FMINDEX) > 0) return -1; + if (strcmp(CHAR_getChar(meindex, CHAR_FMNAME), "") != 0) return -1; +#ifdef _FMVER21 + if (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) > 0 && + CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_APPLY ) return -1; +#else + if (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) > 0 ) return -1; +#endif + return 1; +} + +int CheckLeaderQ(int meindex) +{ + if (CHAR_getInt(meindex, CHAR_LV) < FMLEADERLV + && CHAR_getInt(meindex, CHAR_TRANSMIGRATION) <= 0) + return -1; + if (!NPC_EventCheckFlg(meindex, 4)) + return -2; + return 0; +} + +void FAMILY_Add(int fd, int meindex, char* message) +{ + char token[128], fmname[128], charname[128], charid[128]; + char petname[128], fmrule[256], petattr[256], buf[1024]; + int charlv, havepetindex, petindex, fmsprite = 0, chargrano; + int gold, tmpflag; + + if (!CHAR_CHECKINDEX(meindex)) return; + + if (CHAR_getWorkInt(meindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) + return; + if (CHAR_getInt(meindex, CHAR_FMINDEX) >= 0 + && strcmp(CHAR_getChar(meindex, CHAR_FMNAME), "") != 0) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n你已经加入家族罗~无法再成立家族!", buf, sizeof(buf))); + return; + } + tmpflag = CheckLeaderQ(meindex); + if(tmpflag == -1) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n很抱歉喔!你的等级不足!", buf, sizeof(buf))); + return; + } + + if(tmpflag == -2) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n很抱歉喔!你必须先完成成人礼才行!", buf, sizeof(buf))); + return; + } + + gold = CHAR_getInt(meindex, CHAR_GOLD); + if( gold < 10000 ) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n很抱歉喔!成立家族需要一万元石币的手续费!", buf, sizeof(buf))); + return; + } + else { + CHAR_setInt( meindex, CHAR_GOLD, gold-10000 ); + CHAR_send_P_StatusString( meindex , CHAR_P_STRING_GOLD); + } + + if (getStringFromIndexWithDelim(message, "|", 2, token, + sizeof(token)) == FALSE) return; + sprintf(fmname, "%s", token); + if ((strstr(fmname, " ")) || (strcmp(fmname, "") == 0) || (strstr(fmname, " "))) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n家族的名称请勿输入空格!", buf, sizeof(buf))); + return; + } + if (getStringFromIndexWithDelim(message, "|", 3, token, + sizeof(token)) == FALSE) return; + havepetindex = atoi(token); + petindex = CHAR_getCharPet(meindex, havepetindex); + if (!CHAR_CHECKINDEX(petindex)) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n请选择一只宠物作为家族守护兽!", buf, sizeof(buf))); + return; + } + if (getStringFromIndexWithDelim(message, "|", 4, token, + sizeof(token)) == FALSE) return; + fmsprite = atoi(token); + if (getStringFromIndexWithDelim(message, "|", 5, token, + sizeof(token)) == FALSE) return; + if (strcmp(token, "") == 0) + sprintf(fmrule, "无"); + else + sprintf(fmrule, "%s", token); + sprintf(charname, "%s", CHAR_getChar(meindex, CHAR_NAME)); + sprintf(charid, "%s", CHAR_getChar(meindex, CHAR_CDKEY)); + charlv = CHAR_getInt(meindex, CHAR_LV); + chargrano = CHAR_getInt(meindex, CHAR_FACEIMAGENUMBER); + if (strlen(CHAR_getChar(petindex, CHAR_USERPETNAME)) == 0) + sprintf(petname, "%s", CHAR_getChar(petindex, CHAR_NAME)); + else + sprintf(petname, "%s", CHAR_getChar(petindex, CHAR_USERPETNAME)); + sprintf(petattr, "%d %d %d %d", + CHAR_getInt(petindex, CHAR_BASEIMAGENUMBER), + CHAR_getWorkInt(petindex, CHAR_WORKATTACKPOWER), + CHAR_getWorkInt(petindex, CHAR_WORKDEFENCEPOWER), + CHAR_getWorkInt(petindex, CHAR_WORKQUICK)); + CHAR_setInt(petindex, CHAR_PETFAMILY, 1); + CHAR_setChar(meindex, CHAR_FMNAME, fmname); +#ifdef _FMVER21 + CHAR_setInt(meindex, CHAR_FMLEADERFLAG, FMMEMBER_LEADER); +#else + CHAR_setInt(meindex, CHAR_FMLEADERFLAG, 1); +#endif + CHAR_setInt(meindex, CHAR_FMSPRITE, fmsprite); + + // print("%s %s %s %d %s %s %s %d %d\n", fmname, charname, charid, charlv, petname, + // petattr, fmrule, fmsprite, chargrano); +#ifdef _PERSONAL_FAME + saacproto_ACAddFM_send(acfd, fmname, charname, charid, charlv, + petname, petattr, fmrule, fmsprite, chargrano, + CHAR_getInt(meindex, CHAR_FAME), CONNECT_getFdid(fd)); + // print("ACAddFM acfd:%d meindex:%d fmname:%s charname:%s fame:%d Connectfd:%d fd:%d\n", + // acfd, meindex, fmname, charname, CHAR_getInt(meindex, CHAR_FAME), CONNECT_getFdid(fd), fd); +#else + saacproto_ACAddFM_send(acfd, fmname, charname, charid, charlv, + petname, petattr, fmrule, fmsprite, chargrano, CONNECT_getFdid(fd)); +#endif + + // 要求最新家族列表 + //saacproto_ACShowFMList_send( acfd ); + +} + +/* + ┐┌ + ┘└┘└ +└┐..┌┘─ + ┴──┤★~~├ +│o o│  │●   + ┬──   │ ~~~~~~~~~哞 +▲△▲△▲△▲△▲△▲△▲△▲△ + +*/ + +void ACAddFM(int fd, int result, int fmindex, int index) +{ + int meindex = CONNECT_getCharaindex(fd); + char buf[1024]; + +// print("ACAddFM result:%d fmindex:%d meindex:%d\n", result, fmindex, meindex); // test + + if (!CHAR_CHECKINDEX(meindex)) return; + +// print("ACAddFM_2!\n"); + + if (CHAR_getWorkInt(meindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) + return; + +// print("ACAddFM_3!\n"); + + if(result == 1) + { + CHAR_setInt(meindex, CHAR_FMINDEX, fmindex); + CHAR_setWorkInt(meindex, CHAR_WORKFMINDEXI, index); + CHAR_setWorkInt(meindex, CHAR_WORKFMSETUPFLAG, 0); +#ifdef _NEW_MANOR_LAW + CHAR_setInt(meindex,CHAR_MOMENTUM,0); + CHAR_talkToCli(meindex,-1,"成立家族个人气势归零",CHAR_COLORYELLOW); +#endif + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n恭喜你成立了新的家族!但请在7天之内召集到10名族人加入,不然会取消家族资格喔。", buf, sizeof(buf))); + JoinMemberIndex( meindex, index); + CHAR_charSaveFromConnect(fd, FALSE); + + // 要求最新家族资料 + saacproto_ACShowFMList_send( acfd ); + saacproto_ACShowMemberList_send( acfd, index ); + saacproto_ACShowTopFMList_send(acfd, FM_TOP_INTEGRATE); + + LogFamily( + CHAR_getChar( meindex, CHAR_FMNAME), + CHAR_getInt( meindex, CHAR_FMINDEX), + CHAR_getChar( meindex, CHAR_NAME), + CHAR_getChar( meindex, CHAR_CDKEY), + "ADDFAMILY(成立家族)", + "" + ); + } + else + { + int i = 0, petindex = 0; + char tmpbuf[256]; + int gold = CHAR_getInt(meindex, CHAR_GOLD); + CHAR_setInt(meindex, CHAR_GOLD, gold + 10000); + CHAR_send_P_StatusString( meindex , CHAR_P_STRING_GOLD); + SetFMVarInit(meindex); + + for (i = 0; i < CHAR_MAXPETHAVE; i++) + { + petindex = CHAR_getCharPet(meindex, i); + if (!CHAR_CHECKINDEX(petindex)) continue; + CHAR_setInt(petindex, CHAR_PETFAMILY, -1); + } + if (fmindex == -2) + sprintf(tmpbuf, "\n已经有相同名字的家族成立了!"); + else + sprintf(tmpbuf, "\n申请成立家族失败!"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString(tmpbuf, buf, sizeof(buf))); + } + CHAR_sendStatusString( meindex, "F"); +} + +void FAMILY_Join(int fd, int meindex, char *message) +{ + int fmindex, charlv, index, fmsprite; + char token[128], fmname[128], charname[128], charid[128], buf[1024]; + + if (!CHAR_CHECKINDEX(meindex)) return; + + if ((CHAR_getWorkInt(meindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE) + || (CHAR_getWorkInt(meindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE)) + return; + + if (CheckFMMember(meindex) < 0){ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n你已经加入其他家族了喔!", buf, sizeof(buf))); + return; + } + + + if (getStringFromIndexWithDelim(message, "|", 2, token, + sizeof(token)) == FALSE) return; + index = atoi(token); + if (getStringFromIndexWithDelim(message, "|", 3, token, + sizeof(token)) == FALSE) return; + fmindex = atoi(token); + if (getStringFromIndexWithDelim(message, "|", 4, token, + sizeof(token)) == FALSE) return; + sprintf(fmname, "%s", token); + if (getStringFromIndexWithDelim(message, "|", 5, token, + sizeof(token)) == FALSE) return; + fmsprite = atoi(token); + sprintf(charname, "%s", CHAR_getChar(meindex, CHAR_NAME)); + sprintf(charid, "%s", CHAR_getChar(meindex, CHAR_CDKEY)); + charlv = CHAR_getInt(meindex, CHAR_LV); + CHAR_setInt(meindex, CHAR_FMINDEX, fmindex); + CHAR_setChar(meindex, CHAR_FMNAME, fmname); +#ifdef _FMVER21 + CHAR_setInt(meindex, CHAR_FMLEADERFLAG, FMMEMBER_APPLY); +#else + CHAR_setInt(meindex, CHAR_FMLEADERFLAG, 0); +#endif + CHAR_setInt(meindex, CHAR_FMSPRITE, fmsprite); + CHAR_setWorkInt(meindex, CHAR_WORKFMINDEXI, index); + +// print("JoinFM index:%d fmindex:%d fmname:%s charname:%s charid:%s charlv:%d sprite:%d\n", +// index, fmindex, fmname, charname, charid, charlv, fmsprite); +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 +// print("fame:%d charfdid:%d\n", CHAR_getInt(meindex, CHAR_FAME), +// CONNECT_getFdid(fd)); + saacproto_ACJoinFM_send(acfd, fmname, fmindex, charname, charid, charlv, + index, CHAR_getInt(meindex, CHAR_FAME), CONNECT_getFdid(fd)); +#else +// print("charfdid:%d\n", CONNECT_getFdid(fd)); + saacproto_ACJoinFM_send(acfd, fmname, fmindex, charname, charid, charlv, + index, CONNECT_getFdid(fd)); +#endif +} + +void ACJoinFM(int fd, int result, int recv) +{ + int meindex = CONNECT_getCharaindex(fd); + char buf[1024]; + + if(!CHAR_CHECKINDEX(meindex)) return; + + if ((CHAR_getWorkInt(meindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE) + || (CHAR_getWorkInt(meindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE)) + return; + + if (result == 1) { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n谢谢你的加入申请!请先等族长对你的审核通过之後,才算正式加入。", buf, sizeof(buf))); + + JoinMemberIndex( meindex, CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI) ); +#ifdef _NEW_MANOR_LAW + CHAR_setInt(meindex,CHAR_MOMENTUM,0); + CHAR_talkToCli(meindex,-1,"加入家族个人气势归零",CHAR_COLORYELLOW); +#endif + + sprintf(buf,"fame:%d",CHAR_getInt(meindex,CHAR_FAME)); + + LogFamily( + CHAR_getChar( meindex, CHAR_FMNAME), + CHAR_getInt( meindex, CHAR_FMINDEX), + CHAR_getChar( meindex, CHAR_NAME), + CHAR_getChar( meindex, CHAR_CDKEY), + "JOINFAMILY(申请加入家族)", + buf + ); + + } + else + { + SetFMVarInit(meindex); + if (recv == -2) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n此家族目前不愿意招收成员!", buf, sizeof(buf))); + } + else if (recv == -3) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n此家族目前无法招收成员,家族成员人数已到达上限!", buf, sizeof(buf))); + } + else + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n申请加入家族失败!", buf, sizeof(buf))); + } + + CHAR_sendStatusString( meindex, "F"); +} + +void FAMILY_Leave(int fd, int meindex, char *message) +{ + int result, fmindex, index; + char token[128], fmname[128], charname[128], charid[128], buf[1024]; + + if (!CHAR_CHECKINDEX(meindex)) return; + + if (CHAR_getWorkInt(meindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) + return; + + if ((CHAR_getInt(meindex, CHAR_FMINDEX) == -1) + || (strcmp(CHAR_getChar(meindex, CHAR_FMNAME), "") == 0) +#ifdef _FMVER21 + || (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) == FMMEMBER_NONE)) +#else + || (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) == -1)) +#endif + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n你并没有加入家族喔!", buf, sizeof(buf))); + return; + } + + { + int i, fmpks_pos; + for( i=1; i<=MANORNUM; i++){ // CoolFish 4->MANORNUM 2002/2/25 + fmpks_pos = i * MAX_SCHEDULE; +#ifdef _FMVER21 + if (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) == FMMEMBER_LEADER){ +#else + if (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) == 1){ +#endif + if( (fmpks[fmpks_pos+1].host_index+1) == CHAR_getInt(meindex, CHAR_FMINDEX) || + (fmpks[fmpks_pos+1].guest_index+1) == CHAR_getInt(meindex, CHAR_FMINDEX) ){ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n你目前的家族正约战中,因此无法解散家族!", buf, sizeof(buf))); + return; + } + } + } + } + + if (getStringFromIndexWithDelim(message, "|", 2, token, + sizeof(token)) == FALSE) return; + result = atoi(token); + if (result == 1) + { + fmindex = CHAR_getInt(meindex, CHAR_FMINDEX); + index = CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI); + sprintf(fmname, "%s", CHAR_getChar(meindex, CHAR_FMNAME)); + sprintf(charname, "%s", CHAR_getChar(meindex, CHAR_NAME)); + sprintf(charid, "%s", CHAR_getChar(meindex, CHAR_CDKEY)); +#ifdef _FMVER21 + if (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) == FMMEMBER_LEADER) { +#else + if (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) == 1) { +#endif +// print("DelFM index:%d fmindex:%d fmname:%s\n", index, fmindex, fmname); + saacproto_ACDelFM_send(acfd, fmname, fmindex, index, charname, charid, + CONNECT_getFdid(fd)); + + // 要求最新家族列表 + //saacproto_ACShowFMList_send( acfd ); + } + else { +// print("LeaveFM index:%d fmindex:%d fmname:%s charname:%s charid:%s\n", +// index, fmindex, fmname, charname, charid); + saacproto_ACLeaveFM_send(acfd, fmname, fmindex, charname, charid, index, + CONNECT_getFdid(fd)); + } + + + } +} + +void ACLeaveFM( int fd, int result, int resultflag) +{ + int meindex = CONNECT_getCharaindex(fd); + char buf[1024]; + + if (!CHAR_CHECKINDEX(meindex)) return; + if (result == 1){ + // won 2002/01/05 + LogFamily( + CHAR_getChar( meindex, CHAR_FMNAME), + CHAR_getInt( meindex, CHAR_FMINDEX), + CHAR_getChar( meindex, CHAR_NAME), + CHAR_getChar( meindex, CHAR_CDKEY), + "LEAVEFAMILY(离开家族)", + "" + ); + if( CHAR_getWorkInt( meindex, CHAR_WORKFMCHANNEL) != -1 ) + CHAR_setWorkInt( meindex, CHAR_WORKFMCHANNEL, -1 ); + LeaveMemberIndex( meindex, CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI) ); + SetFMVarInit(meindex); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\n申请退出家族OK!", buf, sizeof(buf))); + CHAR_setWorkInt( meindex, CHAR_WORKFMFLOOR, -1); +#ifdef _FM_JOINLIMIT + CHAR_setInt( meindex, CHAR_FMTIMELIMIT, (int)time(NULL)+(7*24)*(60*60) ); +#endif +#ifdef _NEW_MANOR_LAW + CHAR_setInt(meindex,CHAR_MOMENTUM,0); + CHAR_talkToCli(meindex,-1,"退出家族个人气势归零",CHAR_COLORYELLOW); +#endif + + }else + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\n申请退出家族失败!", buf, sizeof(buf))); + + CHAR_sendStatusString( meindex, "F" ); +} + +void ACDelFM(int fd, int result) +{ + char buf[1024]; + int meindex = CONNECT_getCharaindex(fd); + if (!CHAR_CHECKINDEX(meindex)) return; + + //if ((CHAR_getWorkInt(meindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE) + // || (CHAR_getWorkInt(meindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE)) + // return; + + if (result == 1) + { +// WON ADD + LogFamily( + CHAR_getChar( meindex, CHAR_FMNAME), + CHAR_getInt( meindex, CHAR_FMINDEX), + CHAR_getChar( meindex, CHAR_NAME), + CHAR_getChar( meindex, CHAR_CDKEY), + "DELFAMILY(家族解散)", + "" + ); + + LeaveMemberIndex( meindex, CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI) ); + /* + for( i=0; i familyNumTotal ) break; + if( getStringFromIndexWithDelim( familyListBuf, "|", i, subbuf, + sizeof(subbuf) ) == FALSE) break; + strcat( buf, "|" ); + strcat( buf, subbuf ); + j++; + + // print(" |%s| ", subbuf); + } + + sprintf( sendbuf, "S|F|%d|%d|%d%s", familyNumTotal, atoi(token2), j, buf ); + lssproto_FM_send( fd, sendbuf ); + + return; + + } + + // shan add + if (strcmp(token, "P") == 0 ){ + int personfame; + char sendbuf[512]; +#ifdef _PERSONAL_FAME + personfame = (CHAR_getInt( meindex, CHAR_FAME)/100); +#else + personfame = CHAR_getWorkInt( meindex, CHAR_WORKFMDP); +#endif + sprintf( sendbuf, "你目前的个人声望点数为:%d", personfame); + CHAR_talkToCli(meindex, -1, sendbuf, CHAR_COLORYELLOW); +#ifdef _NEW_MANOR_LAW + sprintf(sendbuf,"你目前的个人气势点数为:%d",CHAR_getInt(meindex,CHAR_MOMENTUM)/100); + CHAR_talkToCli(meindex, -1, sendbuf, CHAR_COLORYELLOW); +#endif + } + + if(strcmp(token,"D") == 0){ + if(getStringFromIndexWithDelim(message, "|", 3, fmname, sizeof(fmname)) == FALSE) return; + if(getStringFromIndexWithDelim(message, "|", 4, token2, sizeof(token2)) == FALSE) return; + fmindex = atoi( token2 ); + if(getStringFromIndexWithDelim(message, "|", 5, token2, sizeof(token2)) == FALSE) return; + tempindex = atoi( token2 ); + + //print(" send_fmname_ac:%s ", fmname); + saacproto_ACFMDetail_send( acfd, fmname, fmindex, tempindex, CONNECT_getFdid(fd) ); + } + + // shan begin + else if (strcmp(token, "D2") ==0 ) { + char sendbuf[2048], tmpbuf[1024], leadernamebuf[64]; + int h, i = 0; + int meindex = CONNECT_getCharaindex(fd); + int fmindex_wk = CHAR_getWorkInt( meindex, CHAR_WORKFMINDEXI); + if( fmindex_wk < 0 || fmindex_wk >= FAMILY_MAXNUM) return; + + for( h=0; h 家族名称|人数|族长名称|家族排行|家族声望|个人声望|个人职位|家族精灵|PK +#ifdef _NEW_MANOR_LAW + sprintf( sendbuf, "%s|%d|%s|%d|%d|%d|%d|%d|%s|%d|%d", +#else + sprintf( sendbuf, "%s|%d|%s|%d|%d|%d|%d|%d|%s", +#endif + CHAR_getChar(meindex, CHAR_FMNAME), + memberlist[fmindex_wk].fmjoinnum, + leadernamebuf, + h+1, +#ifdef _FMVER21 + fmdptop.fmtopdp[h], +#else + (CHAR_getWorkInt( meindex, CHAR_WORKFMDP)/100), +#endif +#ifdef _PERSONAL_FAME + (CHAR_getInt( meindex, CHAR_FAME)/100), +#else + (CHAR_getWorkInt( meindex, CHAR_WORKFMDP)/100), +#endif + CHAR_getInt( meindex, CHAR_FMLEADERFLAG), + CHAR_getInt( meindex, CHAR_FMSPRITE ), + tmpbuf +#ifdef _NEW_MANOR_LAW + ,fmdptop.fmMomentum[h]/100 // 家族气势 + ,CHAR_getInt(meindex,CHAR_MOMENTUM)/100 // 个人气势 +#endif + ); + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_FAMILYDETAIL, + WINDOW_BUTTONTYPE_OK, + -1, + -1, + makeEscapeString( sendbuf, buf, sizeof(buf))); + } + // shan end +} + +void ACFMDetail(int ret, char *data, int clifd) +{ + char sendbuf[1024]; + + //print(" Detail:%s ", data); + + if( ret != 1 ) + { + print(" ACFMDetailError!:%d ", clifd ); + return; + } + //print(" ACFMDetail:%d:%s ", clifd, data ); + + /* + len = strlen(data); + strcpy( buf, data ); + + for( i=0 ; i 人物名称:%s 人物索引 (设该人物为族员):%d\n", CHAR_getInt(meindex, CHAR_FMLEADERFLAG), charname, charindex); + LogFamily( + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), + CHAR_getChar(meindex, CHAR_NAME), + CHAR_getChar(meindex, CHAR_CDKEY), + "CheckMember", + sbuf + ); + // shan end + + saacproto_ACMemberJoinFM_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), charname, charindex, + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), result, + CHAR_getWorkInt(meindex, CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(fd)); + } +#else + { + saacproto_ACMemberJoinFM_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), charname, charindex, + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), result, + CONNECT_getFdid(fd)); + } +#endif +#ifdef _FMVER21 + else if (result == FMMEMBER_NONE) +#else + else if (result == 4) +#endif + { + for (i = 0 + 1; i < FAMILY_MAXHOME + 1; i++) + { + int fmpks_pos = i * MAX_SCHEDULE; + if ((fmpks[fmpks_pos].host_index == index + && strcmp(fmname, fmpks[fmpks_pos].host_name) == 0) + || (fmpks[fmpks_pos].guest_index == index + && strcmp(fmname, fmpks[fmpks_pos].guest_name) == 0)) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n家族目前正在战斗中,所以无法审核成员。", buf, sizeof(buf))); +// print("fmpks_pos:%d index:%d host:%d guest:%d\n", fmpks_pos, +// index, fmpks[fmpks_pos].host_index, fmpks[fmpks_pos].guest_index); + return; + } + } +#ifdef _FMVER21 + { + // shan begin + char sbuf[1024]; + sprintf( sbuf, "族长代号:%d -> 人物名称:%s 人物索引:%d (将该人物退出家族)\n", CHAR_getInt(meindex, CHAR_FMLEADERFLAG), charname, charindex); + + LogFamily( + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), + CHAR_getChar(meindex, CHAR_NAME), + CHAR_getChar(meindex, CHAR_CDKEY), + "CheckMember", + sbuf + ); + // shan end + saacproto_ACMemberLeaveFM_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), charname, charindex, + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), + CHAR_getWorkInt(meindex, CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(fd)); + } +#else + { + saacproto_ACMemberLeaveFM_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), charname, charindex, + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), + CONNECT_getFdid(fd)); + } +#endif + } +#ifdef _FMVER21 +// else if (result == FMMEMBER_ELDER || result == FMMEMBER_INVITE +// || result == FMMEMBER_BAILEE || result == FMMEMBER_VICELEADER ) + else if (result == FMMEMBER_ELDER ) + { + if (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER) + return; +#ifdef _FMVER21 + { + // shan begin + char sbuf[1024]; + sprintf( sbuf, "族长代号:%d -> 人物名称:%s 人物索引:%d (设该人物为长老)\n", CHAR_getInt(meindex, CHAR_FMLEADERFLAG), charname, charindex); + LogFamily( + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), + CHAR_getChar(meindex, CHAR_NAME), + CHAR_getChar(meindex, CHAR_CDKEY), + "CheckMember", + sbuf + ); + // shan end + saacproto_ACMemberJoinFM_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), charname, charindex, + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), result, + CHAR_getWorkInt(meindex, CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(fd)); + } +#else + { + saacproto_ACMemberJoinFM_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), charname, charindex, + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), result, + CONNECT_getFdid(fd)); + } +#endif + } +#endif + // 要求最新家族列表 + saacproto_ACShowFMList_send( acfd ); +} + +void FAMILY_Channel(int fd, int meindex, char *message) +{ + char token[128], token2[128]; + char buf[4096], subbuf[4096], sendbuf[4096]; + int i, tempindex, fmindexi, channel, nowchannel, num; + + fmindexi = CHAR_getWorkInt( meindex, CHAR_WORKFMINDEXI); + nowchannel = CHAR_getWorkInt( meindex, CHAR_WORKFMCHANNEL ); + + // print(" channelFM:%d ", fmindexi); + if( fmindexi < 0 ) { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n你还没有加入任何家族!", buf, sizeof(buf))); + return; + } + + if (getStringFromIndexWithDelim(message, "|", 2, token, + sizeof(token)) == FALSE) return; + + if (getStringFromIndexWithDelim(message, "|", 3, token2, + sizeof(token2)) == FALSE) return; + + channel = atoi( token2 ); + + if( strcmp( token, "J") == 0) { + if( channel < -1 || channel > FAMILY_MAXCHANNEL )return; + if( nowchannel >= 0 && nowchannel < FAMILY_MAXCHANNEL ) { + i = 0; + while( i < FAMILY_MAXMEMBER ) { + if( channelMember[fmindexi][nowchannel][i] == meindex ) { + channelMember[fmindexi][nowchannel][i] = -1; + break; + } + i++; + } + } + + if( channel > 0 && channel < FAMILY_MAXCHANNEL ) { + i = 0; + while( i < FAMILY_MAXCHANNELMEMBER ) { + if( channelMember[fmindexi][channel][i] < 0 ) { + channelMember[fmindexi][channel][i] = meindex; + break; + } + i++; + } + if( i >= FAMILY_MAXCHANNELMEMBER ) { + CHAR_talkToCli( meindex, -1, "此频道人数已满。", CHAR_COLORWHITE); + return; + } + sprintf( buf, "加入家族频道 [%d]。", channel ); + CHAR_talkToCli( meindex, -1, buf, CHAR_COLORWHITE); + + if( nowchannel >=0 && nowchannel < FAMILY_MAXCHANNEL ) { + sprintf( buf, "%s 退出频道。", CHAR_getChar( meindex, CHAR_NAME) ); + for( i=0; i < FAMILY_MAXCHANNELMEMBER; i++ ) { + if( CHAR_CHECKINDEX(channelMember[fmindexi][nowchannel][i]) + && channelMember[fmindexi][nowchannel][i] != meindex ) { + CHAR_talkToCli( channelMember[fmindexi][nowchannel][i], -1, buf, CHAR_COLORWHITE); + } + } + } + sprintf( buf, "%s 加入频道。", CHAR_getChar( meindex, CHAR_NAME) ); + for( i=0; i < FAMILY_MAXCHANNELMEMBER; i++ ) { + if( CHAR_CHECKINDEX(channelMember[fmindexi][channel][i]) + && channelMember[fmindexi][channel][i] != meindex ) { + CHAR_talkToCli( channelMember[fmindexi][channel][i], -1, buf, CHAR_COLORWHITE); + } + } + + } + else if( channel == 0 ) { + i = 0; + while( i < FAMILY_MAXMEMBER ) { + if( channelMember[fmindexi][0][i] < 0 ) { + channelMember[fmindexi][0][i] = meindex; + break; + } + i++; + } + if( i >= FAMILY_MAXMEMBER ) { +#ifndef _CHANNEL_MODIFY + CHAR_talkToCli( meindex, -1, "此频道人数已满。", CHAR_COLORWHITE); +#endif + return; + } +#ifndef _CHANNEL_MODIFY + sprintf( buf, "加入家族频道 [全]。"); + CHAR_talkToCli( meindex, -1, buf, CHAR_COLORWHITE); + if( nowchannel >=0 && nowchannel < FAMILY_MAXCHANNEL ) { + sprintf( buf, "%s 退出频道。", CHAR_getChar( meindex, CHAR_NAME) ); + for( i=0; i < FAMILY_MAXCHANNELMEMBER; i++ ) { + if( CHAR_CHECKINDEX(channelMember[fmindexi][nowchannel][i]) + && channelMember[fmindexi][nowchannel][i] != meindex ) { + CHAR_talkToCli( channelMember[fmindexi][nowchannel][i], -1, buf, CHAR_COLORWHITE); + } + } + } + sprintf( buf, "%s 加入频道。", CHAR_getChar( meindex, CHAR_NAME) ); + for( i=0; i < FAMILY_MAXCHANNELMEMBER; i++ ) { + if( CHAR_CHECKINDEX(channelMember[fmindexi][channel][i]) + && channelMember[fmindexi][channel][i] != meindex ) { + CHAR_talkToCli( channelMember[fmindexi][channel][i], -1, buf, CHAR_COLORWHITE); + } + } +#endif + } +#ifdef _FMVER21 + else if( channel == FAMILY_MAXCHANNEL && CHAR_getInt( meindex, CHAR_FMLEADERFLAG ) == FMMEMBER_LEADER ) +#else + else if( channel == FAMILY_MAXCHANNEL && CHAR_getInt( meindex, CHAR_FMLEADERFLAG ) == 1 ) +#endif + { + CHAR_talkToCli( meindex, -1, "启动族长广播。", CHAR_COLORWHITE); + } + else { + channel = -1; +#ifndef _CHANNEL_MODIFY + CHAR_talkToCli( meindex, -1, "退出家族频道。", CHAR_COLORWHITE); +#else + CHAR_talkToCli( meindex, -1, "关闭族长广播。", CHAR_COLORWHITE); + channel = 0; + i = 0; + while(i < FAMILY_MAXMEMBER){ + if( channelMember[fmindexi][0][i] < 0 ) { + channelMember[fmindexi][0][i] = meindex; + break; + } + i++; + } +#endif + + sprintf( buf, "%s 退出频道。", CHAR_getChar( meindex, CHAR_NAME) ); + for( i=0; i < FAMILY_MAXCHANNELMEMBER; i++ ) { + if( CHAR_CHECKINDEX(channelMember[fmindexi][nowchannel][i]) + && channelMember[fmindexi][nowchannel][i] != meindex ) { + CHAR_talkToCli( channelMember[fmindexi][nowchannel][i], -1, buf, CHAR_COLORWHITE); + } + } + } + + CHAR_setWorkInt( meindex, CHAR_WORKFMCHANNEL, channel); + if( channel != -1 ) CHAR_setWorkInt( meindex, CHAR_WORKFMCHANNELQUICK, channel); + + sprintf( sendbuf, "C|J|%d", channel); + lssproto_FM_send( fd, sendbuf); + + } + else if( strcmp( token, "L") == 0) { + + int j, membernum, bFind = 0; + if( channel < 0 || channel >= FAMILY_MAXCHANNEL ) return; + + subbuf[0] = '\0'; + num = 0; + if( channel != 0 ) + membernum = FAMILY_MAXCHANNELMEMBER; + else + membernum = FAMILY_MAXMEMBER; + + for( j = 0 ; j < FAMILY_MAXMEMBER ; j++ ) { + bFind = 0; + tempindex = familyMemberIndex[fmindexi][j]; + //if( tempindex >= 0 ) { + if( CHAR_CHECKINDEX(tempindex) ) { + for( i=0; i< membernum ; i++) { + if( tempindex == channelMember[fmindexi][channel][i] ) { + //if( CHAR_getChar( tempindex, CHAR_NAME ) == NULL ) { + // familyMemberIndex[fmindexi][j] = -1; + // channelMember[fmindexi][channel][i] = -1; + // continue; + //} + bFind = 1; + break; + } + } + if( bFind ) + strcat( subbuf, "|1|" ); + else + strcat( subbuf, "|0|" ); + makeEscapeString( CHAR_getChar( tempindex, CHAR_NAME ), buf, sizeof(buf)); + strcat( subbuf, buf ); + num++; + } + } + sprintf( sendbuf, "C|L|%d|%d%s", channel, num, subbuf); + lssproto_FM_send( fd, sendbuf); + //print(" CList:%s ", sendbuf); + } +} + +void FAMILY_Bank(int fd, int meindex, char *message) +{ + char token[128], token2[128], buf[1024]; + int fmindex, cash, bank, toBank; + int MaxGold; + MaxGold = CHAR_getMaxHaveGold( meindex); + fmindex = CHAR_getInt( meindex, CHAR_FMINDEX); + // add shan + if( fmindex <= 0 && CHAR_getInt( meindex, CHAR_BANKGOLD) < 1) { + CHAR_talkToCli( meindex, -1, "你必须先加入家族。", CHAR_COLORWHITE); + return; + } + + if (getStringFromIndexWithDelim(message, "|", 2, token, sizeof(token)) == FALSE) + return; + + if( strcmp(token, "G" )==0 ) { + if (getStringFromIndexWithDelim(message, "|", 3, token2, sizeof(token)) == FALSE) + return; + + toBank = atoi( token2 ); + cash = CHAR_getInt( meindex, CHAR_GOLD); + bank = CHAR_getInt( meindex, CHAR_BANKGOLD); + if( ((cash - toBank) >= 0) && ((cash - toBank) <= MaxGold ) + &&((bank + toBank) >= 0)&&((bank + toBank) <= CHAR_MAXBANKGOLDHAVE) ) { + // shan add + if( toBank > 0 && CHAR_getInt( meindex, CHAR_FMINDEX ) < 1 ) { + sprintf(buf, "抱歉!你没有加入任何家族,所以仅能领取存款"); + CHAR_talkToCli( meindex, -1, buf, CHAR_COLORWHITE); + return; + } + + CHAR_setInt( meindex, CHAR_GOLD, cash - toBank); + CHAR_setInt( meindex, CHAR_BANKGOLD, bank + toBank); + CHAR_send_P_StatusString( meindex , CHAR_P_STRING_GOLD); + + if( toBank >= 0 ) { + sprintf(buf, "存入%d到家族银行个人帐户。", toBank); + CHAR_talkToCli( meindex, -1, buf, CHAR_COLORWHITE); + // Syu ADD 新增家族个人银行存取Log (不含家族银行) + LogFamilyBankStone( + CHAR_getChar( meindex, CHAR_NAME ), + CHAR_getChar( meindex, CHAR_CDKEY ), + toBank, + CHAR_getInt( meindex, CHAR_GOLD ), + "myBank(存款)(家族个人银行)", + CHAR_getInt( meindex,CHAR_FLOOR), + CHAR_getInt( meindex,CHAR_X ), + CHAR_getInt( meindex,CHAR_Y ), + CHAR_getInt( meindex,CHAR_BANKGOLD) + ); + + } + else { + sprintf(buf, "从家族银行个人帐户取出%d。", -toBank); + CHAR_talkToCli( meindex, -1, buf, CHAR_COLORWHITE); + // Syu ADD 新增家族个人银行存取Log (不含家族银行) + LogFamilyBankStone( + CHAR_getChar( meindex, CHAR_NAME ), + CHAR_getChar( meindex, CHAR_CDKEY ), + toBank, + CHAR_getInt( meindex, CHAR_GOLD ), + "myBank(提款)(家族个人银行)", + CHAR_getInt( meindex,CHAR_FLOOR), + CHAR_getInt( meindex,CHAR_X ), + CHAR_getInt( meindex,CHAR_Y ), + CHAR_getInt( meindex,CHAR_BANKGOLD) + ); + + } + // Syu ADD 新增家族个人银行存取Log (不含家族银行) + LogStone( + -1, + CHAR_getChar( meindex, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( meindex, CHAR_CDKEY ), /* 交□扒□ID */ + -toBank, /* 嗯喊 */ + CHAR_getInt( meindex, CHAR_GOLD ), + "myBank(家族个人银行)", + CHAR_getInt( meindex,CHAR_FLOOR), + CHAR_getInt( meindex,CHAR_X ), + CHAR_getInt( meindex,CHAR_Y ) + ); + + } + else + print(" bank_error "); + + } + if( strcmp(token, "I" )==0 ) { + + } + if( strcmp(token, "T" )==0 ) { + int toTax; + int mygold; + int FMindex; + + if (getStringFromIndexWithDelim(message, "|", 3, token2, sizeof(token)) == FALSE) + return; + toTax = atoi( token2 ); + +#ifdef _FMVER21 + if( CHAR_getInt( meindex, CHAR_FMLEADERFLAG ) != FMMEMBER_LEADER && + CHAR_getInt( meindex, CHAR_FMLEADERFLAG ) != FMMEMBER_ELDER && toTax < 0 ) + return; +#endif + + + FMindex = CHAR_getWorkInt( meindex, CHAR_WORKFMINDEXI ); + mygold = CHAR_getInt( meindex, CHAR_GOLD); + if( mygold < 0 || mygold > MaxGold || toTax == 0 ) return; + if( toTax > 0 ) {//+存款 + if( ((mygold-toTax) < 0) || (familyTax[ FMindex] + toTax) > CHAR_MAXFMBANKGOLDHAVE ) { + return; + } + }else if( toTax < 0 ){ //-取款 + if( ((mygold-toTax)>MaxGold) || (familyTax[ FMindex] + toTax) < 0 ) { + return; + } + } + + + if( toTax>0 ) { //存款预先扣款 + CHAR_setInt( meindex, CHAR_GOLD, CHAR_getInt( meindex, CHAR_GOLD)-toTax ); + } + sprintf( buf, "家族银行%s处理中....", (toTax>0)?"存款":"取款"); + CHAR_talkToCli( meindex , -1, buf, CHAR_COLORYELLOW); + + CHAR_send_P_StatusString( meindex , CHAR_P_STRING_GOLD); + sprintf( buf, "%d", toTax ); + + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), FM_FIX_FMGOLD, buf, + "", CHAR_getWorkInt(meindex, CHAR_WORKFMCHARINDEX), CONNECT_getFdid(fd)); +#ifdef _FAMILYBANKSTONELOG + saacproto_ACgetFMBankgold_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), + CHAR_getWorkInt(meindex, CHAR_WORKFMCHARINDEX), CONNECT_getFdid(fd)); +#endif + //print(" getTax:%s=%d ", CHAR_getChar(meindex, CHAR_FMNAME), toTax ); + } +} + +void ACFMPointList(int ret, char *data) +{ +} + + +#ifdef _CK_ONLINE_PLAYER_COUNT // WON ADD 计算线上人数 +void GS_SEND_PLAYER_COUNT(void) +{ + int i, count = 0; + int playernum = CHAR_getPlayerMaxNum(); + + for( i = 0 ; i < playernum ; i++) { + if( CHAR_getCharUse(i) != FALSE ) count++; + } + + saacproto_GS_PLAYER_COUNT_SEND(acfd, count); +} +#endif + + + + + +void FAMILY_SetPoint(int fd, int meindex, char *message) +{ + int i, fmpointindex, fl, x, y, fmdp, fmlevel = 0; + char token[128], buf[1024]; + + if (!CHAR_CHECKINDEX(meindex)) return; + + if (CHAR_getWorkInt(meindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) + return; + + if ((CHAR_getInt(meindex, CHAR_FMINDEX) == -1) + || (strcmp(CHAR_getChar(meindex, CHAR_FMNAME), "") == 0) +#ifdef _FMVER21 + || (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER)) +#else + || (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != 1)) +#endif + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n你不是族长,所以没有修改的权力唷!", buf, sizeof(buf))); + return; + } + fmdp = CHAR_getWorkInt(meindex, CHAR_WORKFMDP); + for (i = 0; i < arraysizeof(fmdplevelexp); i++){ + if (fmdp < fmdplevelexp[i + 1] && fmdp >= fmdplevelexp[i]){ + fmlevel = i; + } + } +#ifndef _ACFMPK_NOFREE + if (fmlevel < MINFMLEVLEFORPOINT){// or 人数小於30人 + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n家族等级尚未到达申请家族据点的条件!", buf, sizeof(buf))); + return; + } +#endif + for (i = 1; i <= MANORNUM; i++) { + if (((strcmp(fmpks[i * MAX_SCHEDULE + 1].guest_name, + CHAR_getChar(meindex, CHAR_FMNAME)) == 0)) + && ((fmpks[i * MAX_SCHEDULE + 1].flag = FMPKS_FLAG_MANOR_BATTLEBEGIN) + || (fmpks[i * MAX_SCHEDULE + 1].flag == FMPKS_FLAG_MANOR_PREPARE))){ + char tmpbuf[256]; + sprintf(tmpbuf, "\n你跟%s已经有预约庄园争夺赛了~\n无法再申请庄园了喔!", + fmpks[i * MAX_SCHEDULE + 1].host_name); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString(tmpbuf, buf, sizeof(buf))); + return; + } + } + if (getStringFromIndexWithDelim(message, "|", 2, token, + sizeof(token)) == FALSE) return; + fmpointindex = atoi(token); + if (getStringFromIndexWithDelim(message, "|", 3, token, + sizeof(token)) == FALSE) return; + fl = atoi(token); + if (getStringFromIndexWithDelim(message, "|", 4, token, + sizeof(token)) == FALSE) return; + x = atoi(token); + if (getStringFromIndexWithDelim(message, "|", 5, token, + sizeof(token)) == FALSE) return; + y = atoi(token); +/* + print("SetFMPoint charname:%s fmindex:%d index:%d pointindex:%d fl:%d x:%d y:%d\n", + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), + fmpointindex, fl, x, y); +*/ + saacproto_ACSetFMPoint_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), + fmpointindex, fl, x, y, CONNECT_getFdid(fd)); +} + +void ACSetFMPoint(int ret, int r, int clifd) +{ + int meindex = CONNECT_getCharaindex(clifd); + char message[256], buf[512]; + + if (!CHAR_CHECKINDEX(meindex)) return; + + if ((CHAR_getWorkInt(meindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE) + || (CHAR_getWorkInt(meindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE)) + return; + if (ret == 0){ + if (r == -1) + sprintf(message, "申请家族失败!"); + else if (r == -2) + sprintf(message, "你已经有家族据点了~不得重复申请!"); + else if (r == -3) + sprintf(message, "尚未到达申请家族据点的资格!"); + else if (r == -4) + sprintf(message, "家族据点已经有家族在使用中罗!"); + else if (r == -5) + sprintf(message, "您的家族人数未达申请标准唷!"); + } + else if (ret == 1) + sprintf(message, "申请家族据点OK!"); + + lssproto_WN_send( clifd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString(message, buf, sizeof(buf))); +} + +void ACFMAnnounce(int ret, char *fmname, int fmindex, int index, + int kindflag, char *data, int color) +{ + // kindflag 1:族长广播 2:系统公告家族被删除 3:系统通知讯息 + int i, chindex; + if( ret != 1 ) return; +// print("fmname:%s fmindex:%d index:%d kindflag:%d data:%s color:%d\n", +// fmname, fmindex, index, kindflag, data, color); + for( i=0; i < FAMILY_MAXMEMBER; i++) + { + chindex = familyMemberIndex[index][i]; + if( chindex >= 0 ) { + if( CHAR_getCharUse(chindex) ) + { + if (kindflag == 1) + { +#ifdef _FMVER21 + // shan 2001/12/13 + //if( CHAR_getInt( chindex, CHAR_FMLEADERFLAG ) == FMMEMBER_MEMBER ) + if( CHAR_getInt( chindex, CHAR_FMLEADERFLAG ) == FMMEMBER_MEMBER || + CHAR_getInt( chindex, CHAR_FMLEADERFLAG ) == FMMEMBER_ELDER ) +#else + if( CHAR_getInt( chindex, CHAR_FMLEADERFLAG ) == 2 ) +#endif + CHAR_talkToCli( chindex, -1, data, color ); + } + else if (kindflag == 2) + { + int fd = getfdFromCharaIndex( chindex ); + if (fd == -1) return; + SetFMVarInit( chindex ); + CHAR_talkToCli( chindex , -1, "由於您的家族在七天之内没有召收到10名家族成员,所以被迫解散了!", + CHAR_COLORRED); + } + } + else + familyMemberIndex[index][i] = -1; + } + } + if (kindflag == 3) + { + int meindex = 0; + int clifd = getfdFromFdid(color); + if (CONNECT_checkfd(clifd) == FALSE) return; + meindex = CONNECT_getCharaindex(clifd); + if (!CHAR_CHECKINDEX(meindex)) return; + CHAR_talkToCli(meindex, -1, data, CHAR_COLORRED); + } + if (kindflag == 4) + { + int meindex = 0; + char buf[1024]; + int clifd = getfdFromFdid(color); +// print("Here1\n"); + if (CONNECT_checkfd(clifd) == FALSE) return; + meindex = CONNECT_getCharaindex(clifd); + if (!CHAR_CHECKINDEX(meindex)) return; +// print("Here2\n"); + lssproto_WN_send(clifd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString(data, buf, sizeof(buf))); + } +} + +void FAMILY_SetAcceptFlag(int fd, int meindex, char *message) +{ + int result; + char token[128], buf[1024]; + + if (!CHAR_CHECKINDEX(meindex)) return; + + if ((CHAR_getWorkInt(meindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE) + || (CHAR_getWorkInt(meindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE)) + return; + + if ((CHAR_getInt(meindex, CHAR_FMINDEX) == -1) + || (strcmp(CHAR_getChar(meindex, CHAR_FMNAME), "") == 0) +#ifdef _FMVER21 +// || ((CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER) +// && (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_ELDER) +// && (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_VICELEADER))) + || ((CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER) + && (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_ELDER))) +#else + || (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != 1)) +#endif + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n你不是族长,所以没有修改的权力唷!", buf, sizeof(buf))); + return; + } + + if (getStringFromIndexWithDelim(message, "|", 2, token, + sizeof(token)) == FALSE) return; + result = atoi(token); + if ((result == 0) || (result == 1)) + { + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), FM_FIX_ACCEPTFLAG, + token, "", CHAR_getWorkInt(meindex, CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(fd)); + } +} + +void FAMILY_FixRule( int fd, int meindex, char* message ) +{ + + char token[1024], buf[1024]; + + if (!CHAR_CHECKINDEX(meindex))return; + + if ((CHAR_getInt(meindex, CHAR_FMINDEX) == -1) + || (strcmp(CHAR_getChar(meindex, CHAR_FMNAME), "") == 0) +#ifdef _FMVER21 + || (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER)) +#else + || (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != 1)) +#endif + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n你不是族长,所以没有修改的权力唷!", buf, sizeof(buf))); + return; + } + + if (getStringFromIndexWithDelim(message, "|", 2, token, + sizeof(token)) == FALSE) return; + + if( strcmp( token, "R") == 0 ) + { + if (getStringFromIndexWithDelim(message, "|", 3, buf, + sizeof( buf ) ) == FALSE)return; + + if (strcmp( buf, "") == 0) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n家族主旨不可为空白唷!", buf, sizeof(buf))); + return; + } + +// print(" new_rule:%s ", buf); + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), FM_FIX_FMRULE, + buf, "", CHAR_getWorkInt(meindex, CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(fd)); + return; + } + if( strcmp( token, "P") == 0 ) + { + int havepetindex, petindex, i; + char petname[20], petattr[512]; + + // 检查是否已有守护兽 + for( i =0; i< CHAR_MAXPETHAVE; i++ ) + { + int petindex = CHAR_getCharPet(meindex, i); + if (!CHAR_CHECKINDEX(petindex)) continue; + if( CHAR_getInt( petindex , CHAR_PETFAMILY ) ==1 ) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n原本的守护兽还在唷。", buf, sizeof(buf))); + return; + } + } + // 检查是否已有守护兽(寄宠) + for( i =0; i< CHAR_MAXPOOLPETHAVE; i++ ) + { + int petindex = CHAR_getCharPoolPet(meindex, i); + if (!CHAR_CHECKINDEX(petindex)) continue; + if( CHAR_getInt( petindex , CHAR_PETFAMILY ) ==1 ) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n原本的守护兽还在唷。", buf, sizeof(buf))); + return; + } + } + + if (getStringFromIndexWithDelim(message, "|", 3, buf, + sizeof( buf ) ) == FALSE) return; + havepetindex = atoi( buf ); + + petindex = CHAR_getCharPet(meindex, havepetindex); + + if (!CHAR_CHECKINDEX(petindex)) return; + + if (strlen(CHAR_getChar(petindex, CHAR_USERPETNAME)) == 0) + sprintf(petname, "%s", CHAR_getChar(petindex, CHAR_NAME)); + else + sprintf(petname, "%s", CHAR_getChar(petindex, CHAR_USERPETNAME)); + sprintf(petattr, "%d %d %d %d", + CHAR_getInt(petindex, CHAR_BASEIMAGENUMBER), + CHAR_getWorkInt(petindex, CHAR_WORKATTACKPOWER), + CHAR_getWorkInt(petindex, CHAR_WORKDEFENCEPOWER), + CHAR_getWorkInt(petindex, CHAR_WORKQUICK)); + + CHAR_setInt(petindex, CHAR_PETFAMILY, 1); + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), FM_FIX_FMPET, + petname, petattr, CHAR_getWorkInt(meindex, CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(fd)); + return; + + } + +} + +void JoinMemberIndex( int meindex, int fmindexi ) +{ + int i; + + for( i = 0 ; i < FAMILY_MAXMEMBER; i++){ + if( familyMemberIndex[fmindexi][i] == meindex ) familyMemberIndex[fmindexi][i] = -1; + } + + for( i = 0 ; i < FAMILY_MAXMEMBER; i++){ + if( familyMemberIndex[fmindexi][i] < 0 ){ + familyMemberIndex[fmindexi][i] = meindex; + break; + } + } +#ifdef _CHANNEL_MODIFY + i = 0; + // 先清掉旧的频道记录 + while(i < FAMILY_MAXMEMBER){ + if(channelMember[fmindexi][0][i] == meindex){ + channelMember[fmindexi][0][i] = -1; + } + i++; + } + i = 0; + // 加入频道 + while(i < FAMILY_MAXMEMBER){ + if(channelMember[fmindexi][0][i] == -1){ + channelMember[fmindexi][0][i] = meindex; + CHAR_setWorkInt(meindex,CHAR_WORKFMCHANNEL,0); + break; + } + i++; + } +#endif +} + +void LeaveMemberIndex( int meindex, int fmindexi ) +{ + int i; + + for( i = 0 ; i < FAMILY_MAXMEMBER; i++){ + if( familyMemberIndex[fmindexi][i] == meindex ) familyMemberIndex[fmindexi][i] = -1; + } +#ifdef _CHANNEL_MODIFY + i = 0; + // 清掉旧的频道记录 + while(i < FAMILY_MAXMEMBER){ + if(channelMember[fmindexi][0][i] == meindex){ + channelMember[fmindexi][0][i] = -1; + } + i++; + } +#endif +} + +void FAMILY_RidePet( int fd, int meindex, char* message ) +{ + char token[64], token2[64]; + int petindex, rideGraNo = 0, leaderimageNo; + // Arminius 8.25 recover + int i; +#ifndef _NEW_RIDEPETS + int big4fm = 0; +#endif + if (!CHAR_CHECKINDEX(meindex))return; + + // Robin fix 战斗中不可骑 + if( CHAR_getWorkInt( meindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE ) return; + +#ifdef _PETSKILL_BECOMEPIG + if( CHAR_getInt( meindex, CHAR_BECOMEPIG) > -1 ){ //处於乌力化状态 + CHAR_setInt( meindex, CHAR_RIDEPET, -1 ); + //宠物选项的状态依然为"骑乘",这里修正过来 + CHAR_complianceParameter( meindex ); + CHAR_send_P_StatusString( meindex, CHAR_P_STRING_RIDEPET); + return; + } +#endif + + if( CHAR_getWorkInt( meindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) return; + + if (getStringFromIndexWithDelim(message, "|", 2, token, sizeof(token)) == FALSE) return; + + if( strcmp( token, "P") == 0) { + if (getStringFromIndexWithDelim(message, "|", 3, token2, sizeof(token2)) == FALSE) + return; + + if( atoi(token2) != -1 ) { + petindex = CHAR_getCharPet( meindex, atoi( token2 ) ); + if(!CHAR_CHECKINDEX(petindex))return; + + if( CHAR_getInt( meindex, CHAR_DEFAULTPET ) == atoi( token2 ) ) return; + if( CHAR_getInt( meindex, CHAR_RIDEPET) != -1 ) return; + if( CHAR_getInt( meindex, CHAR_LEARNRIDE) < CHAR_getInt( petindex, CHAR_LV ) ) return; + if( CHAR_getWorkInt( petindex, CHAR_WORKFIXAI ) < 100 )return; + if( CHAR_getInt( meindex, CHAR_LV)+5 < CHAR_getInt( petindex, CHAR_LV ) ) return; +#ifdef _PET_2TRANS + if( CHAR_getInt( petindex, CHAR_TRANSMIGRATION) > 2 ) return; +#endif + leaderimageNo = 100700 + + ((CHAR_getInt( meindex, CHAR_BASEBASEIMAGENUMBER)-100000)/20)*10 + + CHAR_getInt( meindex, CHAR_FMSPRITE)*5; +#ifndef _NEW_RIDEPETS + switch( CHAR_getWorkInt( meindex, CHAR_WORKFMFLOOR) ){ + case 1041: + big4fm = 1; + break; + case 2031: + big4fm = 2; + break; + case 3031: + big4fm = 3; + break; + case 4031: + big4fm = 4; + break; + default: + big4fm = 0; + } +#endif + // Arminius 8.25 recover + for( i=0; i< arraysizeof(ridePetTable) ; i++ ){ +#ifdef _NEW_RIDEPETS + if( (( CHAR_getInt( meindex, CHAR_BASEIMAGENUMBER) == ridePetTable[i].charNo ) || + ( CHAR_getInt( meindex, CHAR_BASEBASEIMAGENUMBER) == ridePetTable[i].charNo )) +#else + if( ( CHAR_getInt( meindex, CHAR_BASEBASEIMAGENUMBER) == ridePetTable[i].charNo ) +#endif + && ( CHAR_getInt( petindex, CHAR_BASEBASEIMAGENUMBER) == ridePetTable[i].petNo ) ){ + rideGraNo = ridePetTable[i].rideNo; + break; + } +#ifndef _NEW_RIDEPETS + if( ( leaderimageNo == ridePetTable[i].charNo ) + && ( CHAR_getInt( petindex, CHAR_BASEBASEIMAGENUMBER) == ridePetTable[i].petNo ) +#ifdef _EVERYONE_RIDE + && big4fm != 0 + && CHAR_getInt( meindex, CHAR_FMLEADERFLAG ) != FMMEMBER_NONE + && CHAR_getInt( meindex, CHAR_FMLEADERFLAG ) != FMMEMBER_APPLY ){ +#else + && CHAR_getInt( meindex, CHAR_FMLEADERFLAG ) == FMMEMBER_LEADER ){ +#endif + rideGraNo = ridePetTable[i].rideNo; + break; + } +#endif + } + +#ifdef _NEW_RIDEPETS + if( rideGraNo == 0 ) { + int ti=-1, index, image=-1; + int petNo = CHAR_getInt( petindex, CHAR_BASEBASEIMAGENUMBER); + int playerNo = CHAR_getInt( meindex, CHAR_BASEBASEIMAGENUMBER); + + int playerlowsride = CHAR_getInt( meindex, CHAR_LOWRIDEPETS); + if( (ti = RIDEPET_getPETindex( petNo, playerlowsride )) >= 0 ) { + if( (index = RIDEPET_getNOindex( playerNo)) >= 0 ){ + if( (image = RIDEPET_getRIDEno( index,ti)) >= 0 ) { + rideGraNo = image; + } + } + } + } +#endif + + if( rideGraNo != 0 ){ +#ifdef _ITEM_METAMO + // CHAR_setWorkInt( meindex, CHAR_WORKITEMMETAMO, 0); +#endif + CHAR_setInt( meindex , CHAR_RIDEPET, atoi( token2 ) ); + CHAR_setInt( meindex , CHAR_BASEIMAGENUMBER , rideGraNo ); + CHAR_complianceParameter( meindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( meindex, CHAR_P_STRING_RIDEPET ); + }else + return; + }else { //还原人物 basebaseimage + CHAR_setInt( meindex , CHAR_RIDEPET, -1 ); + CHAR_setInt( meindex , CHAR_BASEIMAGENUMBER , CHAR_getInt( meindex , CHAR_BASEBASEIMAGENUMBER) ); + CHAR_complianceParameter( meindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( meindex , CHAR_P_STRING_RIDEPET); + } + } + +} + +void ACFixFMPK(int winindex, int loseindex, int data) +{ + int i = 0, charindex = 0; + char msg1[256], msg2[256]; + + sprintf(msg1, "恭喜您!家族声望提高了%8d点!", (data / 100)); + sprintf(msg2, "家族声望减少了%8d点!", (data / 100)); + for (i = 0; i < FAMILY_MAXMEMBER; i++) + { + charindex = familyMemberIndex[winindex][i]; + if( charindex >= 0 ) { + if( CHAR_getCharUse(charindex) ) + CHAR_talkToCli( charindex , -1, msg1, CHAR_COLORYELLOW); + else + familyMemberIndex[winindex][i] = -1; + } + charindex = familyMemberIndex[loseindex][i]; + if( charindex >= 0 ) { + if( CHAR_getCharUse(charindex) ) + CHAR_talkToCli( charindex , -1, msg2, CHAR_COLORRED); + else + familyMemberIndex[loseindex][i] = -1; + } + } +} + +void getNewFMList() +{ + saacproto_ACShowFMList_send( acfd ); +} + +//int channelMember[FAMILY_MAXNUM][FAMILY_MAXCHANNEL][FAMILY_MAXMEMBER]; +//int familyMemberIndex[FAMILY_MAXNUM][FAMILY_MAXMEMBER]; + + +#ifdef _DEATH_FAMILY_GM_COMMAND // WON ADD 家族战GM指令 +int get_fm_leader_index( int fm1 ) +{ + int charindex = -1; + + charindex = familyMemberIndex[fm1][0]; + + return charindex; + +} +#endif + + +void checkFamilyIndex( void ) +{ + int i, j, k, charaindex, err1=0, err2=0; +// print(" checkFamilyIndex! "); + + for( i=0; i 0 ){ + if( fmindex_wk < 0 || fmindex_wk >= FAMILY_MAXNUM){ + print("FamilyNumber Data Error!!"); + return; + } + } + saacproto_ACShowMemberList_send( acfd, fmindex_wk); + + sprintf( sendbuf, " 『族 长 需 知』\n请小心处理族员的资料,一经修改後就无法回复原态,敬请小心。"); + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_FM_MESSAGE2, + CHAR_getWorkInt( leaderdengonindex, CHAR_WORKOBJINDEX), + makeEscapeString( sendbuf, buf, sizeof(buf))); + } + if( strcmp( token, "L") == 0 ){ + int i, kind, letterNo = 0; + char subtoken[256]; + +#ifdef _FMVER21 +// if( CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER && +// CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_INVITE && +// CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_VICELEADER) return; + if( CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER && + CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_ELDER ) return; +#else + if( CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != 1) return; +#endif + + if (getStringFromIndexWithDelim(message, "|", 3, token2, + sizeof(token2)) == FALSE) return; + kind = atoi( token2 ); + + for( i=0 ; i= 0 && tempindex != meindex ) + { + char tmpbuf[1024]; + sprintf(tmpbuf, "%s", CHAR_getChar(tempindex, CHAR_NAME)); + makeEscapeString( tmpbuf, buf, sizeof(buf)); + sprintf( subsub, "|%d|%s", j, buf ); + strcat( subbuf, subsub ); + num++; + } + } + sprintf( sendbuf, "L|CHANGE|L|%d%s", num, subbuf ); + //lssproto_FM_send( fd, sendbuf); + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_LEADERSELECT, + WINDOW_BUTTONTYPE_OK, + -1, -1, + sendbuf ); + + } + // 询问族长候选人是否愿意接受 + if( strcmp( token2, "Q") == 0 ) + { + char token3[64], token4[64]; + int toindex; + +#ifdef _FMVER21 + if( CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER) return; +#else + if( CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != 1) return; +#endif + if (getStringFromIndexWithDelim(message, "|", 4, token3, + sizeof(token3)) == FALSE)return; + if (getStringFromIndexWithDelim(message, "|", 5, token4, + sizeof(token4)) == FALSE)return; + makeStringFromEscaped( token4 ); + + if( atoi(token3) < 0 || atoi(token3) > FAMILY_MAXMEMBER ) return; + + toindex = familyMemberIndex[fmindexi][atoi(token3)]; + if( !CHAR_CHECKINDEX( toindex ) ) return; + if( strcmp( token4, CHAR_getChar( toindex, CHAR_NAME)) != 0 ) return; + if( CheckLeaderQ(toindex) < 0 ) return; + + // 双方都决定让位时,CHAR_WORKLEADERCHANGE存放对方的charaindex + CHAR_setWorkInt( toindex, CHAR_WORKLEADERCHANGE, meindex); + CHAR_setWorkInt( meindex, CHAR_WORKLEADERCHANGE, toindex); + + sprintf( sendbuf, "%s|%d", makeEscapeString( CHAR_getChar( meindex, CHAR_NAME ), buf, sizeof(buf)), meindex ); + + lssproto_WN_send( CHAR_getWorkInt( toindex, CHAR_WORKFD ), WINDOW_MESSAGETYPE_LEADERSELECTA, + WINDOW_BUTTONTYPE_OK, + -1, -1, + sendbuf ); + + } + // 候选人的答覆 + if( strcmp( token2, "A") == 0 ) + { + int leaderindex, answerflag; + char leadername[64], token3[64], token4[64]; + +// print( "%s", message ); + + if (getStringFromIndexWithDelim(message, "|", 4, token3, + sizeof(token3)) == FALSE) return; + answerflag = atoi( token3 ); + + if (getStringFromIndexWithDelim(message, "|", 5, leadername, + sizeof( leadername )) == FALSE)return; + makeStringFromEscaped( leadername ); + + if (getStringFromIndexWithDelim(message, "|", 6, token4, + sizeof(token4)) == FALSE)return; + + //if( atoi(token4) < 0 || atoi(token4) > FAMILY_MAXMEMBER ) return; + + leaderindex = atoi( token4 ); + + // 检查双方的CHAR_WORKLEADERCHANGE是否相符 + if( CHAR_getWorkInt( meindex, CHAR_WORKLEADERCHANGE ) != leaderindex ) return; + if( !CHAR_CHECKINDEX(leaderindex) ) return; + if( strcmp( leadername, CHAR_getChar( leaderindex, CHAR_NAME) ) != 0 ) return; + if( CHAR_getWorkInt( leaderindex, CHAR_WORKLEADERCHANGE ) != meindex ) return; + CHAR_setWorkInt( leaderindex, CHAR_WORKLEADERCHANGE, -1 ); +#ifdef _FMVER21 + if( CHAR_getInt(leaderindex, CHAR_FMLEADERFLAG ) != FMMEMBER_LEADER ) return; +#else + if( CHAR_getInt(leaderindex, CHAR_FMLEADERFLAG ) != 1 ) return; +#endif + if( CHAR_getInt(meindex, CHAR_FMINDEX) != CHAR_getInt(leaderindex, CHAR_FMINDEX) ) return; + + if( answerflag == 0 ) + { + CHAR_setWorkInt( meindex, CHAR_WORKLEADERCHANGE, 0); + CHAR_setWorkInt( leaderindex, CHAR_WORKLEADERCHANGE, 0); + lssproto_WN_send( CHAR_getWorkInt( leaderindex, CHAR_WORKFD) , WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n对不起!对方不愿意接受!", buf, sizeof(buf)) ); + return; + } + + if( answerflag == 1 ) + { + char tmpbuf[1024]; + sprintf( buf, "%d", CHAR_getInt( meindex, CHAR_FACEIMAGENUMBER ) ); + // CoolFish: add charname 2001/9/27 + sprintf( tmpbuf, "%s", CHAR_getChar( meindex, CHAR_NAME ) ); + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), FM_FIX_FMLEADERCHANGE , buf, + tmpbuf, CHAR_getWorkInt(meindex, CHAR_WORKFMCHARINDEX), CONNECT_getFdid(fd)); + // "", CHAR_getWorkInt(meindex, CHAR_WORKFMCHARINDEX), CONNECT_getFdid(fd)); + return; + } + } + } +} + +void ACFMJob( int fd, int ret, char* data1, char* data2 ) +{ + + int charaindex = CONNECT_getCharaindex( fd ); + if( !CHAR_CHECKINDEX(charaindex) ) return; + + + if( 1 ){ + + int leaderindex = CHAR_getWorkInt( charaindex, CHAR_WORKLEADERCHANGE ); + char buf[256], buf2[256]; + + CHAR_setWorkInt( charaindex, CHAR_WORKLEADERCHANGE, 0 ); + print("leaderindex:%d:%s\n", leaderindex,CHAR_getChar(leaderindex,CHAR_NAME) ); + + if( !CHAR_CHECKINDEX(leaderindex) ) return; + //if( CHAR_getWorkInt( leaderindex, CHAR_WORKLEADERCHANGE ) != charaindex ) return; + CHAR_setWorkInt( leaderindex, CHAR_WORKLEADERCHANGE, 0 ); + + if( ret == 0 ){ + CHAR_talkToCli( charaindex, -1, "族长让位失败!", CHAR_COLORYELLOW ); + CHAR_talkToCli( leaderindex, -1, "族长让位失败!", CHAR_COLORYELLOW ); + return; + } + + // Robin 10/02 debug + if( CHAR_getInt( leaderindex, CHAR_FMINDEX) != CHAR_getInt( charaindex, CHAR_FMINDEX) +#ifdef _FMVER21 + // || CHAR_getInt( leaderindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER ) +#else + // || CHAR_getInt( leaderindex, CHAR_FMLEADERFLAG) != 1 +#endif + ) + { + sprintf( buf, "leaderindex:%d:%s\n", leaderindex, CHAR_getChar( leaderindex, CHAR_NAME) ); + LogFamily( + CHAR_getChar(charaindex, CHAR_FMNAME), + CHAR_getInt(charaindex, CHAR_FMINDEX), + CHAR_getChar(charaindex, CHAR_NAME), + CHAR_getChar(charaindex, CHAR_CDKEY), + "LEADERCHANGE_ERROR(族长让位失败)", + buf + ); + return; + } + + //CHAR_setInt( leaderindex, CHAR_FMLEADERFLAG, FMMEMBER_MEMBER); + //CHAR_setInt( charaindex, CHAR_FMLEADERFLAG, FMMEMBER_LEADER); + SetFMPetVarInit( leaderindex ); + SetFMPetVarInit( charaindex ); + CHAR_sendStatusString( leaderindex, "F"); + CHAR_sendStatusString( charaindex, "F"); + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n恭喜你!你已经是新任的族长了。\n请好好的努力吧!\n对了~记得请先到村长家的家族管理员选择\n新的家族守护兽,否则家族将会被解散唷!", buf, sizeof(buf))); + + sprintf( buf2, "\n辛苦你了!你已经将族长的位子交给%s了。", CHAR_getChar( charaindex, CHAR_NAME) ); + lssproto_WN_send( CHAR_getWorkInt( leaderindex, CHAR_WORKFD) , WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( buf2, buf, sizeof(buf))); + +// print(" LeaderChange!! [%s]->[%s] ", CHAR_getChar(leaderindex, CHAR_CDKEY), CHAR_getChar(charaindex, CHAR_CDKEY) ); + + sprintf( buf, "%s\t%s\t%s", + CHAR_getChar(leaderindex, CHAR_FMNAME), + CHAR_getChar(leaderindex, CHAR_NAME), + CHAR_getChar(leaderindex, CHAR_CDKEY) + ); + + LogFamily( + CHAR_getChar(charaindex, CHAR_FMNAME), + CHAR_getInt(charaindex, CHAR_FMINDEX), + CHAR_getChar(charaindex, CHAR_NAME), + CHAR_getChar(charaindex, CHAR_CDKEY), + "LEADERCHANGE(族长让位)", + buf + ); + + } + +} + + +#ifdef _DEATH_FAMILY_GM_COMMAND // WON ADD 家族战GM指令 + +FM_PK_STRUCT fm_pk_struct; + +void setInt_fm_pk_struct( int index, int type, int num ) +{ + switch( type ){ + case FM_INDEX: + fm_pk_struct.fm_index[index] = num; + break; + case FM_WIN: + fm_pk_struct.fm_win[index] = num; + break; + case FM_LOSE: + fm_pk_struct.fm_lose[index] = num; + break; + case FM_SCORE: + fm_pk_struct.fm_score[index] = num; + break; + } +} + +void setChar_fm_pk_struct( int index, int type, char *msg ) +{ + switch( type ){ + case FM_NAME: + strcpy( fm_pk_struct.fm_name[index], msg ); + break; + } +} + +int getInt_fm_pk_struct( int index, int type ) +{ + switch( type ){ + case FM_INDEX: + return fm_pk_struct.fm_index[index]; + case FM_WIN: + return fm_pk_struct.fm_win[index]; + case FM_LOSE: + return fm_pk_struct.fm_lose[index]; + case FM_SCORE: + return fm_pk_struct.fm_score[index]; + } + + return -1; +} + +char *getChar_fm_pk_struct( int index, int type ) +{ + switch( type ){ + case FM_NAME: + return fm_pk_struct.fm_name[index]; + } + + return NULL; +} + +#endif diff --git a/gmsv/char/family.c.bak b/gmsv/char/family.c.bak new file mode 100644 index 0000000..c3b3f4e --- /dev/null +++ b/gmsv/char/family.c.bak @@ -0,0 +1,3048 @@ +#include "version.h" +#include +#include +#include +#include + +#include "readmap.h" +#include "object.h" +#include "char.h" +#include "char_base.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "npcutil.h" +#include "family.h" +#include "log.h" +#include "handletime.h" +#include "buf.h" +#include "net.h" +#include "char_base.h" +#include "battle.h" +#include "npc_bus.h" +#include "char_talk.h" +#include "npc_scheduleman.h" +#ifdef _FM_MODIFY +#include "npc_fmdengon.h" +#endif + +#define CHAR_MAXNAME 20 +#define CHAR_MAXID 20 +#define MINFMLEVLEFORPOINT 3 // 3 申请庄园最低等级 +#ifdef _FAMILY_MANORNUM_CHANGE +#else +#define MANORNUM 4 +#endif + +struct FAMILY +{ + int fmindex; + char name[CHAR_MAXNAME]; + char leadername[CHAR_MAXNAME]; + char leaderid[CHAR_MAXID]; + int leadergraph; + char petname[CHAR_MAXNAME]; + char petattr[256]; + int fmnum; + int acceptflag; + char rule[256]; + int village; + int pointindex; + int dp; + char memolist[35][100]; +}; + +int familyNumTotal = 0; +char familyListBuf[MAXFAMILYLIST]; + +int channelMember[FAMILY_MAXNUM][FAMILY_MAXCHANNEL][FAMILY_MAXMEMBER]; +int familyMemberIndex[FAMILY_MAXNUM][FAMILY_MAXMEMBER]; + +int familyTax[FAMILY_MAXNUM]; + +extern tagRidePetTable ridePetTable[146]; + +void LeaveMemberIndex( int charaindex, int fmindexi); + + +// Arminius: 取得家族 pk dp 增加/损失值 +// getFMdpAward +// arg: windp=winner's fmdp losedp=loser's fmdp +// ret: dp award +// +#ifdef _MERGE_NEW_8 +int fmdplevelexp[]={0, // 0 + 150000, // 1 + 500000, // 2 + 1000000, // 3 + 1500000, // 4 + 2000000, // 5 + 2500000, // 6 + 3500000, // 7 + 4500000, // 8 + 5000000, // 9 + 7000000 //10 + }; +#else +int fmdplevelexp[]={0, // 0 + 10000, // 1 + 30000, // 2 + 100000, // 3 + 500000, // 4 + 1500000, // 5 + 5000000, // 6 + 15000000, // 7 + 50000000, // 8 + 200000000, // 9 + 500000000 //10 + }; +#endif +// Arminius end + +// shan begin +int getFmLv(int playerindex) // 合成时专用 +{ + int i, dp; + dp = CHAR_getWorkInt(playerindex, CHAR_WORKFMDP); + if( dp > fmdplevelexp[10] ){ +// print("\n player DP->%d",dp); + return 10; + } + for(i=0; i<=10; i++) + if( dp <= fmdplevelexp[i+1] ) break; + // Nuke 20040217: Open the merge limit + //if(i>=9) i = 8; + if (i>=10) i=10; + + return i; +} + +#ifdef _MERGE_NEW_8 // 查询个人声望等级 +int famelevelexp[]={0, // 0 + 1500, // 1 + 3000, // 2 + 4500, // 3 + 7500, // 4 + 11000, // 5 + 14500, // 6 + 18000, // 7 + 25000, // 8 + 32000, // 9 + 39000 //10 + }; + +int getFameLv(int playerindex) // 合成时专用 +{ + int i, dp; + dp = CHAR_getWorkInt(playerindex, CHAR_FAME); + if( dp > famelevelexp[10] ){ + return 10; + } + for(i=0; i<=10; i++) + if( dp <= famelevelexp[i+1] ) break; + if (i>=10) i=10; + + return i; +} +#endif + +struct FMMEMBER_LIST memberlist[FAMILY_MAXNUM]; +struct FMS_MEMO fmsmemo; +struct FM_POINTLIST fmpointlist; +#ifdef _NEW_MANOR_LAW +ManorSchedule_t ManorSchedule[MANORNUM]; +#endif +struct FMS_DPTOP fmdptop; +struct FM_PKFLOOR fmpkflnum[FAMILY_FMPKFLOOR]= +{ + {142}, + {143}, + {144}, + {145}, + {146}, + {1042}, + {2032}, + {3032}, + {4032}, +#ifdef _FAMILY_MANORNUM_CHANGE // CoolFish 用来修改装园数量 + {5032}, + {6032}, + {7032}, + {8032}, + {9032}, +#endif +}; +int leaderdengonindex = 0; +// shan end 新增图层需到 family.h 增加 FAMILY_FMPKFLOOR 数量 + +void SetFMPetVarInit(int meindex) +{ + int i = 0, petindex = 0; +#ifdef _FMVER21 + if (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER) +#else + if (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != 1) +#endif + { + for (i = 0; i < CHAR_MAXPETHAVE; i++) + { + petindex = CHAR_getCharPet(meindex, i); + if (!CHAR_CHECKINDEX(petindex)) continue; + CHAR_setInt(petindex, CHAR_PETFAMILY, -1); + } + } +} + +void SetFMVarInit(int meindex) +{ + SetFMPetVarInit(meindex); // 清除守护兽 Flag + CHAR_setInt(meindex, CHAR_FMINDEX, -1); + CHAR_setChar(meindex, CHAR_FMNAME, ""); + CHAR_setInt(meindex, CHAR_FMSPRITE, -1); +#ifdef _FMVER21 + CHAR_setInt(meindex, CHAR_FMLEADERFLAG, FMMEMBER_NONE); +#else + CHAR_setInt(meindex, CHAR_FMLEADERFLAG, -1); +#endif + CHAR_setWorkInt(meindex, CHAR_WORKFMSETUPFLAG, -1); + CHAR_setWorkInt(meindex, CHAR_WORKFMINDEXI, -1); + CHAR_setWorkInt(meindex, CHAR_WORKFMCHARINDEX, -1); +} + +void FAMILY_Init( void ) +{ + int i, j ,k; + + for( i=0; i 0) return -1; + if (strcmp(CHAR_getChar(meindex, CHAR_FMNAME), "") != 0) return -1; +#ifdef _FMVER21 + if (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) == FMMEMBER_LEADER) return -1; +#else + if (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) == 1) return -1; +#endif + return 1; +} + +int CheckFMMember(int meindex) +{ + if (CHAR_getInt(meindex, CHAR_FMINDEX) > 0) return -1; + if (strcmp(CHAR_getChar(meindex, CHAR_FMNAME), "") != 0) return -1; +#ifdef _FMVER21 + if (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) > 0 && + CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_APPLY ) return -1; +#else + if (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) > 0 ) return -1; +#endif + return 1; +} + +int CheckLeaderQ(int meindex) +{ + if (CHAR_getInt(meindex, CHAR_LV) < FMLEADERLV + && CHAR_getInt(meindex, CHAR_TRANSMIGRATION) <= 0) + return -1; + if (!NPC_EventCheckFlg(meindex, 4)) + return -2; + return 0; +} + +void FAMILY_Add(int fd, int meindex, char* message) +{ + char token[128], fmname[128], charname[128], charid[128]; + char petname[128], fmrule[256], petattr[256], buf[1024]; + int charlv, havepetindex, petindex, fmsprite = 0, chargrano; + int gold, tmpflag; + + if (!CHAR_CHECKINDEX(meindex)) return; + + if (CHAR_getWorkInt(meindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) + return; + if (CHAR_getInt(meindex, CHAR_FMINDEX) >= 0 + && strcmp(CHAR_getChar(meindex, CHAR_FMNAME), "") != 0) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n你已经加入家族罗~无法再成立家族!", buf, sizeof(buf))); + return; + } + tmpflag = CheckLeaderQ(meindex); + if(tmpflag == -1) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n很抱歉喔!你的等级不足!", buf, sizeof(buf))); + return; + } + + if(tmpflag == -2) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n很抱歉喔!你必须先完成成人礼才行!", buf, sizeof(buf))); + return; + } + + gold = CHAR_getInt(meindex, CHAR_GOLD); + if( gold < 10000 ) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n很抱歉喔!成立家族需要一万元石币的手续费!", buf, sizeof(buf))); + return; + } + else { + CHAR_setInt( meindex, CHAR_GOLD, gold-10000 ); + CHAR_send_P_StatusString( meindex , CHAR_P_STRING_GOLD); + } + + if (getStringFromIndexWithDelim(message, "|", 2, token, + sizeof(token)) == FALSE) return; + sprintf(fmname, "%s", token); + if ((strstr(fmname, " ")) || (strcmp(fmname, "") == 0) || (strstr(fmname, " "))) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n家族的名称请勿输入空格!", buf, sizeof(buf))); + return; + } + if (getStringFromIndexWithDelim(message, "|", 3, token, + sizeof(token)) == FALSE) return; + havepetindex = atoi(token); + petindex = CHAR_getCharPet(meindex, havepetindex); + if (!CHAR_CHECKINDEX(petindex)) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n请选择一只宠物作为家族守护兽!", buf, sizeof(buf))); + return; + } + if (getStringFromIndexWithDelim(message, "|", 4, token, + sizeof(token)) == FALSE) return; + fmsprite = atoi(token); + if (getStringFromIndexWithDelim(message, "|", 5, token, + sizeof(token)) == FALSE) return; + if (strcmp(token, "") == 0) + sprintf(fmrule, "无"); + else + sprintf(fmrule, "%s", token); + sprintf(charname, "%s", CHAR_getChar(meindex, CHAR_NAME)); + sprintf(charid, "%s", CHAR_getChar(meindex, CHAR_CDKEY)); + charlv = CHAR_getInt(meindex, CHAR_LV); + chargrano = CHAR_getInt(meindex, CHAR_FACEIMAGENUMBER); + if (strlen(CHAR_getChar(petindex, CHAR_USERPETNAME)) == 0) + sprintf(petname, "%s", CHAR_getChar(petindex, CHAR_NAME)); + else + sprintf(petname, "%s", CHAR_getChar(petindex, CHAR_USERPETNAME)); + sprintf(petattr, "%d %d %d %d", + CHAR_getInt(petindex, CHAR_BASEIMAGENUMBER), + CHAR_getWorkInt(petindex, CHAR_WORKATTACKPOWER), + CHAR_getWorkInt(petindex, CHAR_WORKDEFENCEPOWER), + CHAR_getWorkInt(petindex, CHAR_WORKQUICK)); + CHAR_setInt(petindex, CHAR_PETFAMILY, 1); + CHAR_setChar(meindex, CHAR_FMNAME, fmname); +#ifdef _FMVER21 + CHAR_setInt(meindex, CHAR_FMLEADERFLAG, FMMEMBER_LEADER); +#else + CHAR_setInt(meindex, CHAR_FMLEADERFLAG, 1); +#endif + CHAR_setInt(meindex, CHAR_FMSPRITE, fmsprite); + + // print("%s %s %s %d %s %s %s %d %d\n", fmname, charname, charid, charlv, petname, + // petattr, fmrule, fmsprite, chargrano); +#ifdef _PERSONAL_FAME + saacproto_ACAddFM_send(acfd, fmname, charname, charid, charlv, + petname, petattr, fmrule, fmsprite, chargrano, + CHAR_getInt(meindex, CHAR_FAME), CONNECT_getFdid(fd)); + // print("ACAddFM acfd:%d meindex:%d fmname:%s charname:%s fame:%d Connectfd:%d fd:%d\n", + // acfd, meindex, fmname, charname, CHAR_getInt(meindex, CHAR_FAME), CONNECT_getFdid(fd), fd); +#else + saacproto_ACAddFM_send(acfd, fmname, charname, charid, charlv, + petname, petattr, fmrule, fmsprite, chargrano, CONNECT_getFdid(fd)); +#endif + + // 要求最新家族列表 + //saacproto_ACShowFMList_send( acfd ); + +} + +/* + ┐┌ + ┘└┘└ +└┐..┌┘─ + ┴──┤★~~├ +│o o│  │●   + ┬──   │ ~~~~~~~~~哞 +▲△▲△▲△▲△▲△▲△▲△▲△ + +*/ + +void ACAddFM(int fd, int result, int fmindex, int index) +{ + int meindex = CONNECT_getCharaindex(fd); + char buf[1024]; + +// print("ACAddFM result:%d fmindex:%d meindex:%d\n", result, fmindex, meindex); // test + + if (!CHAR_CHECKINDEX(meindex)) return; + +// print("ACAddFM_2!\n"); + + if (CHAR_getWorkInt(meindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) + return; + +// print("ACAddFM_3!\n"); + + if(result == 1) + { + CHAR_setInt(meindex, CHAR_FMINDEX, fmindex); + CHAR_setWorkInt(meindex, CHAR_WORKFMINDEXI, index); + CHAR_setWorkInt(meindex, CHAR_WORKFMSETUPFLAG, 0); +#ifdef _NEW_MANOR_LAW + CHAR_setInt(meindex,CHAR_MOMENTUM,0); + CHAR_talkToCli(meindex,-1,"成立家族个人气势归零",CHAR_COLORYELLOW); +#endif + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n恭喜你成立了新的家族!但请在7天之内召集到10名族人加入,不然会取消家族资格喔。", buf, sizeof(buf))); + JoinMemberIndex( meindex, index); + CHAR_charSaveFromConnect(fd, FALSE); + + // 要求最新家族资料 + saacproto_ACShowFMList_send( acfd ); + saacproto_ACShowMemberList_send( acfd, index ); + saacproto_ACShowTopFMList_send(acfd, FM_TOP_INTEGRATE); + + LogFamily( + CHAR_getChar( meindex, CHAR_FMNAME), + CHAR_getInt( meindex, CHAR_FMINDEX), + CHAR_getChar( meindex, CHAR_NAME), + CHAR_getChar( meindex, CHAR_CDKEY), + "ADDFAMILY(成立家族)", + "" + ); + } + else + { + int i = 0, petindex = 0; + char tmpbuf[256]; + int gold = CHAR_getInt(meindex, CHAR_GOLD); + CHAR_setInt(meindex, CHAR_GOLD, gold + 10000); + CHAR_send_P_StatusString( meindex , CHAR_P_STRING_GOLD); + SetFMVarInit(meindex); + + for (i = 0; i < CHAR_MAXPETHAVE; i++) + { + petindex = CHAR_getCharPet(meindex, i); + if (!CHAR_CHECKINDEX(petindex)) continue; + CHAR_setInt(petindex, CHAR_PETFAMILY, -1); + } + if (fmindex == -2) + sprintf(tmpbuf, "\n已经有相同名字的家族成立了!"); + else + sprintf(tmpbuf, "\n申请成立家族失败!"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString(tmpbuf, buf, sizeof(buf))); + } + CHAR_sendStatusString( meindex, "F"); +} + +void FAMILY_Join(int fd, int meindex, char *message) +{ + int fmindex, charlv, index, fmsprite; + char token[128], fmname[128], charname[128], charid[128], buf[1024]; + + if (!CHAR_CHECKINDEX(meindex)) return; + + if ((CHAR_getWorkInt(meindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE) + || (CHAR_getWorkInt(meindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE)) + return; + + if (CheckFMMember(meindex) < 0){ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n你已经加入其他家族了喔!", buf, sizeof(buf))); + return; + } + + + if (getStringFromIndexWithDelim(message, "|", 2, token, + sizeof(token)) == FALSE) return; + index = atoi(token); + if (getStringFromIndexWithDelim(message, "|", 3, token, + sizeof(token)) == FALSE) return; + fmindex = atoi(token); + if (getStringFromIndexWithDelim(message, "|", 4, token, + sizeof(token)) == FALSE) return; + sprintf(fmname, "%s", token); + if (getStringFromIndexWithDelim(message, "|", 5, token, + sizeof(token)) == FALSE) return; + fmsprite = atoi(token); + sprintf(charname, "%s", CHAR_getChar(meindex, CHAR_NAME)); + sprintf(charid, "%s", CHAR_getChar(meindex, CHAR_CDKEY)); + charlv = CHAR_getInt(meindex, CHAR_LV); + CHAR_setInt(meindex, CHAR_FMINDEX, fmindex); + CHAR_setChar(meindex, CHAR_FMNAME, fmname); +#ifdef _FMVER21 + CHAR_setInt(meindex, CHAR_FMLEADERFLAG, FMMEMBER_APPLY); +#else + CHAR_setInt(meindex, CHAR_FMLEADERFLAG, 0); +#endif + CHAR_setInt(meindex, CHAR_FMSPRITE, fmsprite); + CHAR_setWorkInt(meindex, CHAR_WORKFMINDEXI, index); + +// print("JoinFM index:%d fmindex:%d fmname:%s charname:%s charid:%s charlv:%d sprite:%d\n", +// index, fmindex, fmname, charname, charid, charlv, fmsprite); +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 +// print("fame:%d charfdid:%d\n", CHAR_getInt(meindex, CHAR_FAME), +// CONNECT_getFdid(fd)); + saacproto_ACJoinFM_send(acfd, fmname, fmindex, charname, charid, charlv, + index, CHAR_getInt(meindex, CHAR_FAME), CONNECT_getFdid(fd)); +#else +// print("charfdid:%d\n", CONNECT_getFdid(fd)); + saacproto_ACJoinFM_send(acfd, fmname, fmindex, charname, charid, charlv, + index, CONNECT_getFdid(fd)); +#endif +} + +void ACJoinFM(int fd, int result, int recv) +{ + int meindex = CONNECT_getCharaindex(fd); + char buf[1024]; + + if(!CHAR_CHECKINDEX(meindex)) return; + + if ((CHAR_getWorkInt(meindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE) + || (CHAR_getWorkInt(meindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE)) + return; + + if (result == 1) { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n谢谢你的加入申请!请先等族长对你的审核通过之後,才算正式加入。", buf, sizeof(buf))); + + JoinMemberIndex( meindex, CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI) ); +#ifdef _NEW_MANOR_LAW + CHAR_setInt(meindex,CHAR_MOMENTUM,0); + CHAR_talkToCli(meindex,-1,"加入家族个人气势归零",CHAR_COLORYELLOW); +#endif + + sprintf(buf,"fame:%d",CHAR_getInt(meindex,CHAR_FAME)); + + LogFamily( + CHAR_getChar( meindex, CHAR_FMNAME), + CHAR_getInt( meindex, CHAR_FMINDEX), + CHAR_getChar( meindex, CHAR_NAME), + CHAR_getChar( meindex, CHAR_CDKEY), + "JOINFAMILY(申请加入家族)", + buf + ); + + } + else + { + SetFMVarInit(meindex); + if (recv == -2) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n此家族目前不愿意招收成员!", buf, sizeof(buf))); + } + else if (recv == -3) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n此家族目前无法招收成员,家族成员人数已到达上限!", buf, sizeof(buf))); + } + else + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n申请加入家族失败!", buf, sizeof(buf))); + } + + CHAR_sendStatusString( meindex, "F"); +} + +void FAMILY_Leave(int fd, int meindex, char *message) +{ + int result, fmindex, index; + char token[128], fmname[128], charname[128], charid[128], buf[1024]; + + if (!CHAR_CHECKINDEX(meindex)) return; + + if (CHAR_getWorkInt(meindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) + return; + + if ((CHAR_getInt(meindex, CHAR_FMINDEX) == -1) + || (strcmp(CHAR_getChar(meindex, CHAR_FMNAME), "") == 0) +#ifdef _FMVER21 + || (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) == FMMEMBER_NONE)) +#else + || (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) == -1)) +#endif + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n你并没有加入家族喔!", buf, sizeof(buf))); + return; + } + + { + int i, fmpks_pos; + for( i=1; i<=MANORNUM; i++){ // CoolFish 4->MANORNUM 2002/2/25 + fmpks_pos = i * MAX_SCHEDULE; +#ifdef _FMVER21 + if (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) == FMMEMBER_LEADER){ +#else + if (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) == 1){ +#endif + if( (fmpks[fmpks_pos+1].host_index+1) == CHAR_getInt(meindex, CHAR_FMINDEX) || + (fmpks[fmpks_pos+1].guest_index+1) == CHAR_getInt(meindex, CHAR_FMINDEX) ){ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n你目前的家族正约战中,因此无法解散家族!", buf, sizeof(buf))); + return; + } + } + } + } + + if (getStringFromIndexWithDelim(message, "|", 2, token, + sizeof(token)) == FALSE) return; + result = atoi(token); + if (result == 1) + { + fmindex = CHAR_getInt(meindex, CHAR_FMINDEX); + index = CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI); + sprintf(fmname, "%s", CHAR_getChar(meindex, CHAR_FMNAME)); + sprintf(charname, "%s", CHAR_getChar(meindex, CHAR_NAME)); + sprintf(charid, "%s", CHAR_getChar(meindex, CHAR_CDKEY)); +#ifdef _FMVER21 + if (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) == FMMEMBER_LEADER) { +#else + if (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) == 1) { +#endif +// print("DelFM index:%d fmindex:%d fmname:%s\n", index, fmindex, fmname); + saacproto_ACDelFM_send(acfd, fmname, fmindex, index, charname, charid, + CONNECT_getFdid(fd)); + + // 要求最新家族列表 + //saacproto_ACShowFMList_send( acfd ); + } + else { +// print("LeaveFM index:%d fmindex:%d fmname:%s charname:%s charid:%s\n", +// index, fmindex, fmname, charname, charid); + saacproto_ACLeaveFM_send(acfd, fmname, fmindex, charname, charid, index, + CONNECT_getFdid(fd)); + } + + + } +} + +void ACLeaveFM( int fd, int result, int resultflag) +{ + int meindex = CONNECT_getCharaindex(fd); + char buf[1024]; + + if (!CHAR_CHECKINDEX(meindex)) return; + if (result == 1){ + // won 2002/01/05 + LogFamily( + CHAR_getChar( meindex, CHAR_FMNAME), + CHAR_getInt( meindex, CHAR_FMINDEX), + CHAR_getChar( meindex, CHAR_NAME), + CHAR_getChar( meindex, CHAR_CDKEY), + "LEAVEFAMILY(离开家族)", + "" + ); + if( CHAR_getWorkInt( meindex, CHAR_WORKFMCHANNEL) != -1 ) + CHAR_setWorkInt( meindex, CHAR_WORKFMCHANNEL, -1 ); + LeaveMemberIndex( meindex, CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI) ); + SetFMVarInit(meindex); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\n申请退出家族OK!", buf, sizeof(buf))); +#ifdef _FM_RIDE_PET + if(getFmridepet()==1) + { + int fmRides = CHAR_getInt( index, CHAR_LOWRIDEPETS); + switch( CHAR_getWorkInt( index, CHAR_WORKFMFLOOR) ) + { + case 1041: + fmRides=fmRides^RIDE_PET9; + break; + case 2031: + fmRides=fmRides^RIDE_PET8|RIDE_PET0|RIDE_PET10|RIDE_PET11); + break; + case 3031: + fmRides=fmRides^RIDE_PET7|RIDE_PET0|RIDE_PET10|RIDE_PET11); + break; + case 4031: + fmRides=fmRides^RIDE_PET1|RIDE_PET0|RIDE_PET10|RIDE_PET11); + break; + case 5031: + fmRides=fmRides^RIDE_PET3|RIDE_PET0|RIDE_PET10|RIDE_PET11); + break; + case 6031: + fmRides=fmRides^RIDE_PET5|RIDE_PET0|RIDE_PET10|RIDE_PET11); + break; + case 7031: + fmRides=fmRides^RIDE_PET4|RIDE_PET0|RIDE_PET10|RIDE_PET11); + break; + case 8031: + fmRides=fmRides^RIDE_PET6|RIDE_PET0|RIDE_PET10|RIDE_PET11); + break; + case 9031: + fmRides=fmRides^RIDE_PET2|RIDE_PET0|RIDE_PET10|RIDE_PET11); + break; + default: + fmRides=fmRides^RIDE_PET0|RIDE_PET10|RIDE_PET11); + } + CHAR_setInt( index, CHAR_LOWRIDEPETS, fmRides ); + CHAR_sendStatusString( index, "x"); + } +#endif + + CHAR_setWorkInt( meindex, CHAR_WORKFMFLOOR, -1); +#ifdef _FM_JOINLIMIT + CHAR_setInt( meindex, CHAR_FMTIMELIMIT, (int)time(NULL)+(7*24)*(60*60) ); +#endif +#ifdef _NEW_MANOR_LAW + CHAR_setInt(meindex,CHAR_MOMENTUM,0); + CHAR_talkToCli(meindex,-1,"退出家族个人气势归零",CHAR_COLORYELLOW); +#endif + + }else + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\n申请退出家族失败!", buf, sizeof(buf))); + + CHAR_sendStatusString( meindex, "F" ); +} + +void ACDelFM(int fd, int result) +{ + char buf[1024]; + int meindex = CONNECT_getCharaindex(fd); + if (!CHAR_CHECKINDEX(meindex)) return; + + //if ((CHAR_getWorkInt(meindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE) + // || (CHAR_getWorkInt(meindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE)) + // return; + + if (result == 1) + { +// WON ADD + LogFamily( + CHAR_getChar( meindex, CHAR_FMNAME), + CHAR_getInt( meindex, CHAR_FMINDEX), + CHAR_getChar( meindex, CHAR_NAME), + CHAR_getChar( meindex, CHAR_CDKEY), + "DELFAMILY(家族解散)", + "" + ); + + LeaveMemberIndex( meindex, CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI) ); + /* + for( i=0; i familyNumTotal ) break; + if( getStringFromIndexWithDelim( familyListBuf, "|", i, subbuf, + sizeof(subbuf) ) == FALSE) break; + strcat( buf, "|" ); + strcat( buf, subbuf ); + j++; + + // print(" |%s| ", subbuf); + } + + sprintf( sendbuf, "S|F|%d|%d|%d%s", familyNumTotal, atoi(token2), j, buf ); + lssproto_FM_send( fd, sendbuf ); + + return; + + } + + // shan add + if (strcmp(token, "P") == 0 ){ + int personfame; + char sendbuf[512]; +#ifdef _PERSONAL_FAME + personfame = (CHAR_getInt( meindex, CHAR_FAME)/100); +#else + personfame = CHAR_getWorkInt( meindex, CHAR_WORKFMDP); +#endif + sprintf( sendbuf, "你目前的个人声望点数为:%d", personfame); + CHAR_talkToCli(meindex, -1, sendbuf, CHAR_COLORYELLOW); +#ifdef _NEW_MANOR_LAW + sprintf(sendbuf,"你目前的个人气势点数为:%d",CHAR_getInt(meindex,CHAR_MOMENTUM)/100); + CHAR_talkToCli(meindex, -1, sendbuf, CHAR_COLORYELLOW); +#endif + } + + if(strcmp(token,"D") == 0){ + if(getStringFromIndexWithDelim(message, "|", 3, fmname, sizeof(fmname)) == FALSE) return; + if(getStringFromIndexWithDelim(message, "|", 4, token2, sizeof(token2)) == FALSE) return; + fmindex = atoi( token2 ); + if(getStringFromIndexWithDelim(message, "|", 5, token2, sizeof(token2)) == FALSE) return; + tempindex = atoi( token2 ); + + //print(" send_fmname_ac:%s ", fmname); + saacproto_ACFMDetail_send( acfd, fmname, fmindex, tempindex, CONNECT_getFdid(fd) ); + } + + // shan begin + else if (strcmp(token, "D2") ==0 ) { + char sendbuf[2048], tmpbuf[1024], leadernamebuf[64]; + int h, i = 0; + int meindex = CONNECT_getCharaindex(fd); + int fmindex_wk = CHAR_getWorkInt( meindex, CHAR_WORKFMINDEXI); + if( fmindex_wk < 0 || fmindex_wk >= FAMILY_MAXNUM) return; + + for( h=0; h 家族名称|人数|族长名称|家族排行|家族声望|个人声望|个人职位|家族精灵|PK +#ifdef _NEW_MANOR_LAW + sprintf( sendbuf, "%s|%d|%s|%d|%d|%d|%d|%d|%s|%d|%d", +#else + sprintf( sendbuf, "%s|%d|%s|%d|%d|%d|%d|%d|%s", +#endif + CHAR_getChar(meindex, CHAR_FMNAME), + memberlist[fmindex_wk].fmjoinnum, + leadernamebuf, + h+1, +#ifdef _FMVER21 + fmdptop.fmtopdp[h], +#else + (CHAR_getWorkInt( meindex, CHAR_WORKFMDP)/100), +#endif +#ifdef _PERSONAL_FAME + (CHAR_getInt( meindex, CHAR_FAME)/100), +#else + (CHAR_getWorkInt( meindex, CHAR_WORKFMDP)/100), +#endif + CHAR_getInt( meindex, CHAR_FMLEADERFLAG), + CHAR_getInt( meindex, CHAR_FMSPRITE ), + tmpbuf +#ifdef _NEW_MANOR_LAW + ,fmdptop.fmMomentum[h]/100 // 家族气势 + ,CHAR_getInt(meindex,CHAR_MOMENTUM)/100 // 个人气势 +#endif + ); + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_FAMILYDETAIL, + WINDOW_BUTTONTYPE_OK, + -1, + -1, + makeEscapeString( sendbuf, buf, sizeof(buf))); + } + // shan end +} + +void ACFMDetail(int ret, char *data, int clifd) +{ + char sendbuf[1024]; + + //print(" Detail:%s ", data); + + if( ret != 1 ) + { + print(" ACFMDetailError!:%d ", clifd ); + return; + } + //print(" ACFMDetail:%d:%s ", clifd, data ); + + /* + len = strlen(data); + strcpy( buf, data ); + + for( i=0 ; i 人物名称:%s 人物索引 (设该人物为族员):%d\n", CHAR_getInt(meindex, CHAR_FMLEADERFLAG), charname, charindex); + LogFamily( + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), + CHAR_getChar(meindex, CHAR_NAME), + CHAR_getChar(meindex, CHAR_CDKEY), + "CheckMember", + sbuf + ); + // shan end + + saacproto_ACMemberJoinFM_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), charname, charindex, + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), result, + CHAR_getWorkInt(meindex, CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(fd)); + } +#else + { + saacproto_ACMemberJoinFM_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), charname, charindex, + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), result, + CONNECT_getFdid(fd)); + } +#endif +#ifdef _FMVER21 + else if (result == FMMEMBER_NONE) +#else + else if (result == 4) +#endif + { + for (i = 0 + 1; i < FAMILY_MAXHOME + 1; i++) + { + int fmpks_pos = i * MAX_SCHEDULE; + if ((fmpks[fmpks_pos].host_index == index + && strcmp(fmname, fmpks[fmpks_pos].host_name) == 0) + || (fmpks[fmpks_pos].guest_index == index + && strcmp(fmname, fmpks[fmpks_pos].guest_name) == 0)) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n家族目前正在战斗中,所以无法审核成员。", buf, sizeof(buf))); +// print("fmpks_pos:%d index:%d host:%d guest:%d\n", fmpks_pos, +// index, fmpks[fmpks_pos].host_index, fmpks[fmpks_pos].guest_index); + return; + } + } +#ifdef _FMVER21 + { + // shan begin + char sbuf[1024]; + sprintf( sbuf, "族长代号:%d -> 人物名称:%s 人物索引:%d (将该人物退出家族)\n", CHAR_getInt(meindex, CHAR_FMLEADERFLAG), charname, charindex); + + LogFamily( + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), + CHAR_getChar(meindex, CHAR_NAME), + CHAR_getChar(meindex, CHAR_CDKEY), + "CheckMember", + sbuf + ); + // shan end + saacproto_ACMemberLeaveFM_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), charname, charindex, + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), + CHAR_getWorkInt(meindex, CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(fd)); + } +#else + { + saacproto_ACMemberLeaveFM_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), charname, charindex, + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), + CONNECT_getFdid(fd)); + } +#endif + } +#ifdef _FMVER21 +// else if (result == FMMEMBER_ELDER || result == FMMEMBER_INVITE +// || result == FMMEMBER_BAILEE || result == FMMEMBER_VICELEADER ) + else if (result == FMMEMBER_ELDER ) + { + if (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER) + return; +#ifdef _FMVER21 + { + // shan begin + char sbuf[1024]; + sprintf( sbuf, "族长代号:%d -> 人物名称:%s 人物索引:%d (设该人物为长老)\n", CHAR_getInt(meindex, CHAR_FMLEADERFLAG), charname, charindex); + LogFamily( + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), + CHAR_getChar(meindex, CHAR_NAME), + CHAR_getChar(meindex, CHAR_CDKEY), + "CheckMember", + sbuf + ); + // shan end + saacproto_ACMemberJoinFM_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), charname, charindex, + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), result, + CHAR_getWorkInt(meindex, CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(fd)); + } +#else + { + saacproto_ACMemberJoinFM_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), charname, charindex, + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), result, + CONNECT_getFdid(fd)); + } +#endif + } +#endif + // 要求最新家族列表 + saacproto_ACShowFMList_send( acfd ); +} + +void FAMILY_Channel(int fd, int meindex, char *message) +{ + char token[128], token2[128]; + char buf[4096], subbuf[4096], sendbuf[4096]; + int i, tempindex, fmindexi, channel, nowchannel, num; + + fmindexi = CHAR_getWorkInt( meindex, CHAR_WORKFMINDEXI); + nowchannel = CHAR_getWorkInt( meindex, CHAR_WORKFMCHANNEL ); + + // print(" channelFM:%d ", fmindexi); + if( fmindexi < 0 ) { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n你还没有加入任何家族!", buf, sizeof(buf))); + return; + } + + if (getStringFromIndexWithDelim(message, "|", 2, token, + sizeof(token)) == FALSE) return; + + if (getStringFromIndexWithDelim(message, "|", 3, token2, + sizeof(token2)) == FALSE) return; + + channel = atoi( token2 ); + + if( strcmp( token, "J") == 0) { + if( channel < -1 || channel > FAMILY_MAXCHANNEL )return; + if( nowchannel >= 0 && nowchannel < FAMILY_MAXCHANNEL ) { + i = 0; + while( i < FAMILY_MAXMEMBER ) { + if( channelMember[fmindexi][nowchannel][i] == meindex ) { + channelMember[fmindexi][nowchannel][i] = -1; + break; + } + i++; + } + } + + if( channel > 0 && channel < FAMILY_MAXCHANNEL ) { + i = 0; + while( i < FAMILY_MAXCHANNELMEMBER ) { + if( channelMember[fmindexi][channel][i] < 0 ) { + channelMember[fmindexi][channel][i] = meindex; + break; + } + i++; + } + if( i >= FAMILY_MAXCHANNELMEMBER ) { + CHAR_talkToCli( meindex, -1, "此频道人数已满。", CHAR_COLORWHITE); + return; + } + sprintf( buf, "加入家族频道 [%d]。", channel ); + CHAR_talkToCli( meindex, -1, buf, CHAR_COLORWHITE); + + if( nowchannel >=0 && nowchannel < FAMILY_MAXCHANNEL ) { + sprintf( buf, "%s 退出频道。", CHAR_getChar( meindex, CHAR_NAME) ); + for( i=0; i < FAMILY_MAXCHANNELMEMBER; i++ ) { + if( CHAR_CHECKINDEX(channelMember[fmindexi][nowchannel][i]) + && channelMember[fmindexi][nowchannel][i] != meindex ) { + CHAR_talkToCli( channelMember[fmindexi][nowchannel][i], -1, buf, CHAR_COLORWHITE); + } + } + } + sprintf( buf, "%s 加入频道。", CHAR_getChar( meindex, CHAR_NAME) ); + for( i=0; i < FAMILY_MAXCHANNELMEMBER; i++ ) { + if( CHAR_CHECKINDEX(channelMember[fmindexi][channel][i]) + && channelMember[fmindexi][channel][i] != meindex ) { + CHAR_talkToCli( channelMember[fmindexi][channel][i], -1, buf, CHAR_COLORWHITE); + } + } + + } + else if( channel == 0 ) { + i = 0; + while( i < FAMILY_MAXMEMBER ) { + if( channelMember[fmindexi][0][i] < 0 ) { + channelMember[fmindexi][0][i] = meindex; + break; + } + i++; + } + if( i >= FAMILY_MAXMEMBER ) { +#ifndef _CHANNEL_MODIFY + CHAR_talkToCli( meindex, -1, "此频道人数已满。", CHAR_COLORWHITE); +#endif + return; + } +#ifndef _CHANNEL_MODIFY + sprintf( buf, "加入家族频道 [全]。"); + CHAR_talkToCli( meindex, -1, buf, CHAR_COLORWHITE); + if( nowchannel >=0 && nowchannel < FAMILY_MAXCHANNEL ) { + sprintf( buf, "%s 退出频道。", CHAR_getChar( meindex, CHAR_NAME) ); + for( i=0; i < FAMILY_MAXCHANNELMEMBER; i++ ) { + if( CHAR_CHECKINDEX(channelMember[fmindexi][nowchannel][i]) + && channelMember[fmindexi][nowchannel][i] != meindex ) { + CHAR_talkToCli( channelMember[fmindexi][nowchannel][i], -1, buf, CHAR_COLORWHITE); + } + } + } + sprintf( buf, "%s 加入频道。", CHAR_getChar( meindex, CHAR_NAME) ); + for( i=0; i < FAMILY_MAXCHANNELMEMBER; i++ ) { + if( CHAR_CHECKINDEX(channelMember[fmindexi][channel][i]) + && channelMember[fmindexi][channel][i] != meindex ) { + CHAR_talkToCli( channelMember[fmindexi][channel][i], -1, buf, CHAR_COLORWHITE); + } + } +#endif + } +#ifdef _FMVER21 + else if( channel == FAMILY_MAXCHANNEL && CHAR_getInt( meindex, CHAR_FMLEADERFLAG ) == FMMEMBER_LEADER ) +#else + else if( channel == FAMILY_MAXCHANNEL && CHAR_getInt( meindex, CHAR_FMLEADERFLAG ) == 1 ) +#endif + { + CHAR_talkToCli( meindex, -1, "启动族长广播。", CHAR_COLORWHITE); + } + else { + channel = -1; +#ifndef _CHANNEL_MODIFY + CHAR_talkToCli( meindex, -1, "退出家族频道。", CHAR_COLORWHITE); +#else + CHAR_talkToCli( meindex, -1, "关闭族长广播。", CHAR_COLORWHITE); + channel = 0; + i = 0; + while(i < FAMILY_MAXMEMBER){ + if( channelMember[fmindexi][0][i] < 0 ) { + channelMember[fmindexi][0][i] = meindex; + break; + } + i++; + } +#endif + + sprintf( buf, "%s 退出频道。", CHAR_getChar( meindex, CHAR_NAME) ); + for( i=0; i < FAMILY_MAXCHANNELMEMBER; i++ ) { + if( CHAR_CHECKINDEX(channelMember[fmindexi][nowchannel][i]) + && channelMember[fmindexi][nowchannel][i] != meindex ) { + CHAR_talkToCli( channelMember[fmindexi][nowchannel][i], -1, buf, CHAR_COLORWHITE); + } + } + } + + CHAR_setWorkInt( meindex, CHAR_WORKFMCHANNEL, channel); + if( channel != -1 ) CHAR_setWorkInt( meindex, CHAR_WORKFMCHANNELQUICK, channel); + + sprintf( sendbuf, "C|J|%d", channel); + lssproto_FM_send( fd, sendbuf); + + } + else if( strcmp( token, "L") == 0) { + + int j, membernum, bFind = 0; + if( channel < 0 || channel >= FAMILY_MAXCHANNEL ) return; + + subbuf[0] = '\0'; + num = 0; + if( channel != 0 ) + membernum = FAMILY_MAXCHANNELMEMBER; + else + membernum = FAMILY_MAXMEMBER; + + for( j = 0 ; j < FAMILY_MAXMEMBER ; j++ ) { + bFind = 0; + tempindex = familyMemberIndex[fmindexi][j]; + //if( tempindex >= 0 ) { + if( CHAR_CHECKINDEX(tempindex) ) { + for( i=0; i< membernum ; i++) { + if( tempindex == channelMember[fmindexi][channel][i] ) { + //if( CHAR_getChar( tempindex, CHAR_NAME ) == NULL ) { + // familyMemberIndex[fmindexi][j] = -1; + // channelMember[fmindexi][channel][i] = -1; + // continue; + //} + bFind = 1; + break; + } + } + if( bFind ) + strcat( subbuf, "|1|" ); + else + strcat( subbuf, "|0|" ); + makeEscapeString( CHAR_getChar( tempindex, CHAR_NAME ), buf, sizeof(buf)); + strcat( subbuf, buf ); + num++; + } + } + sprintf( sendbuf, "C|L|%d|%d%s", channel, num, subbuf); + lssproto_FM_send( fd, sendbuf); + //print(" CList:%s ", sendbuf); + } +} + +void FAMILY_Bank(int fd, int meindex, char *message) +{ + char token[128], token2[128], buf[1024]; + int fmindex, cash, bank, toBank; + int MaxGold; + MaxGold = CHAR_getMaxHaveGold( meindex); + fmindex = CHAR_getInt( meindex, CHAR_FMINDEX); + // add shan + if( fmindex <= 0 && CHAR_getInt( meindex, CHAR_BANKGOLD) < 1) { + CHAR_talkToCli( meindex, -1, "你必须先加入家族。", CHAR_COLORWHITE); + return; + } + + if (getStringFromIndexWithDelim(message, "|", 2, token, sizeof(token)) == FALSE) + return; + + if( strcmp(token, "G" )==0 ) { + if (getStringFromIndexWithDelim(message, "|", 3, token2, sizeof(token)) == FALSE) + return; + + toBank = atoi( token2 ); + cash = CHAR_getInt( meindex, CHAR_GOLD); + bank = CHAR_getInt( meindex, CHAR_BANKGOLD); + if( ((cash - toBank) >= 0) && ((cash - toBank) <= MaxGold ) + &&((bank + toBank) >= 0)&&((bank + toBank) <= CHAR_MAXBANKGOLDHAVE) ) { + // shan add + if( toBank > 0 && CHAR_getInt( meindex, CHAR_FMINDEX ) < 1 ) { + sprintf(buf, "抱歉!你没有加入任何家族,所以仅能领取存款"); + CHAR_talkToCli( meindex, -1, buf, CHAR_COLORWHITE); + return; + } + + CHAR_setInt( meindex, CHAR_GOLD, cash - toBank); + CHAR_setInt( meindex, CHAR_BANKGOLD, bank + toBank); + CHAR_send_P_StatusString( meindex , CHAR_P_STRING_GOLD); + + if( toBank >= 0 ) { + sprintf(buf, "存入%d到家族银行个人帐户。", toBank); + CHAR_talkToCli( meindex, -1, buf, CHAR_COLORWHITE); + // Syu ADD 新增家族个人银行存取Log (不含家族银行) + LogFamilyBankStone( + CHAR_getChar( meindex, CHAR_NAME ), + CHAR_getChar( meindex, CHAR_CDKEY ), + toBank, + CHAR_getInt( meindex, CHAR_GOLD ), + "myBank(存款)(家族个人银行)", + CHAR_getInt( meindex,CHAR_FLOOR), + CHAR_getInt( meindex,CHAR_X ), + CHAR_getInt( meindex,CHAR_Y ), + CHAR_getInt( meindex,CHAR_BANKGOLD) + ); + + } + else { + sprintf(buf, "从家族银行个人帐户取出%d。", -toBank); + CHAR_talkToCli( meindex, -1, buf, CHAR_COLORWHITE); + // Syu ADD 新增家族个人银行存取Log (不含家族银行) + LogFamilyBankStone( + CHAR_getChar( meindex, CHAR_NAME ), + CHAR_getChar( meindex, CHAR_CDKEY ), + toBank, + CHAR_getInt( meindex, CHAR_GOLD ), + "myBank(提款)(家族个人银行)", + CHAR_getInt( meindex,CHAR_FLOOR), + CHAR_getInt( meindex,CHAR_X ), + CHAR_getInt( meindex,CHAR_Y ), + CHAR_getInt( meindex,CHAR_BANKGOLD) + ); + + } + // Syu ADD 新增家族个人银行存取Log (不含家族银行) + LogStone( + -1, + CHAR_getChar( meindex, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( meindex, CHAR_CDKEY ), /* 交□扒□ID */ + -toBank, /* 嗯喊 */ + CHAR_getInt( meindex, CHAR_GOLD ), + "myBank(家族个人银行)", + CHAR_getInt( meindex,CHAR_FLOOR), + CHAR_getInt( meindex,CHAR_X ), + CHAR_getInt( meindex,CHAR_Y ) + ); + + } + else + print(" bank_error "); + + } + if( strcmp(token, "I" )==0 ) { + + } + if( strcmp(token, "T" )==0 ) { + int toTax; + int mygold; + int FMindex; + + if (getStringFromIndexWithDelim(message, "|", 3, token2, sizeof(token)) == FALSE) + return; + toTax = atoi( token2 ); + +#ifdef _FMVER21 + if( CHAR_getInt( meindex, CHAR_FMLEADERFLAG ) != FMMEMBER_LEADER && + CHAR_getInt( meindex, CHAR_FMLEADERFLAG ) != FMMEMBER_ELDER && toTax < 0 ) + return; +#endif + + + FMindex = CHAR_getWorkInt( meindex, CHAR_WORKFMINDEXI ); + mygold = CHAR_getInt( meindex, CHAR_GOLD); + if( mygold < 0 || mygold > MaxGold || toTax == 0 ) return; + if( toTax > 0 ) {//+存款 + if( ((mygold-toTax) < 0) || (familyTax[ FMindex] + toTax) > CHAR_MAXFMBANKGOLDHAVE ) { + return; + } + }else if( toTax < 0 ){ //-取款 + if( ((mygold-toTax)>MaxGold) || (familyTax[ FMindex] + toTax) < 0 ) { + return; + } + } + + + if( toTax>0 ) { //存款预先扣款 + CHAR_setInt( meindex, CHAR_GOLD, CHAR_getInt( meindex, CHAR_GOLD)-toTax ); + } + sprintf( buf, "家族银行%s处理中....", (toTax>0)?"存款":"取款"); + CHAR_talkToCli( meindex , -1, buf, CHAR_COLORYELLOW); + + CHAR_send_P_StatusString( meindex , CHAR_P_STRING_GOLD); + sprintf( buf, "%d", toTax ); + + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), FM_FIX_FMGOLD, buf, + "", CHAR_getWorkInt(meindex, CHAR_WORKFMCHARINDEX), CONNECT_getFdid(fd)); +#ifdef _FAMILYBANKSTONELOG + saacproto_ACgetFMBankgold_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), + CHAR_getWorkInt(meindex, CHAR_WORKFMCHARINDEX), CONNECT_getFdid(fd)); +#endif + //print(" getTax:%s=%d ", CHAR_getChar(meindex, CHAR_FMNAME), toTax ); + } +} + +void ACFMPointList(int ret, char *data) +{ +} + + +#ifdef _CK_ONLINE_PLAYER_COUNT // WON ADD 计算线上人数 +void GS_SEND_PLAYER_COUNT(void) +{ + int i, count = 0; + int playernum = CHAR_getPlayerMaxNum(); + + for( i = 0 ; i < playernum ; i++) { + if( CHAR_getCharUse(i) != FALSE ) count++; + } + + saacproto_GS_PLAYER_COUNT_SEND(acfd, count); +} +#endif + + + + + +void FAMILY_SetPoint(int fd, int meindex, char *message) +{ + int i, fmpointindex, fl, x, y, fmdp, fmlevel = 0; + char token[128], buf[1024]; + + if (!CHAR_CHECKINDEX(meindex)) return; + + if (CHAR_getWorkInt(meindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) + return; + + if ((CHAR_getInt(meindex, CHAR_FMINDEX) == -1) + || (strcmp(CHAR_getChar(meindex, CHAR_FMNAME), "") == 0) +#ifdef _FMVER21 + || (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER)) +#else + || (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != 1)) +#endif + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n你不是族长,所以没有修改的权力唷!", buf, sizeof(buf))); + return; + } + fmdp = CHAR_getWorkInt(meindex, CHAR_WORKFMDP); + for (i = 0; i < arraysizeof(fmdplevelexp); i++){ + if (fmdp < fmdplevelexp[i + 1] && fmdp >= fmdplevelexp[i]){ + fmlevel = i; + } + } +#ifndef _ACFMPK_NOFREE + if (fmlevel < MINFMLEVLEFORPOINT){// or 人数小於30人 + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n家族等级尚未到达申请家族据点的条件!", buf, sizeof(buf))); + return; + } +#endif + for (i = 1; i <= MANORNUM; i++) { + if (((strcmp(fmpks[i * MAX_SCHEDULE + 1].guest_name, + CHAR_getChar(meindex, CHAR_FMNAME)) == 0)) + && ((fmpks[i * MAX_SCHEDULE + 1].flag = FMPKS_FLAG_MANOR_BATTLEBEGIN) + || (fmpks[i * MAX_SCHEDULE + 1].flag == FMPKS_FLAG_MANOR_PREPARE))){ + char tmpbuf[256]; + sprintf(tmpbuf, "\n你跟%s已经有预约庄园争夺赛了~\n无法再申请庄园了喔!", + fmpks[i * MAX_SCHEDULE + 1].host_name); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString(tmpbuf, buf, sizeof(buf))); + return; + } + } + if (getStringFromIndexWithDelim(message, "|", 2, token, + sizeof(token)) == FALSE) return; + fmpointindex = atoi(token); + if (getStringFromIndexWithDelim(message, "|", 3, token, + sizeof(token)) == FALSE) return; + fl = atoi(token); + if (getStringFromIndexWithDelim(message, "|", 4, token, + sizeof(token)) == FALSE) return; + x = atoi(token); + if (getStringFromIndexWithDelim(message, "|", 5, token, + sizeof(token)) == FALSE) return; + y = atoi(token); +/* + print("SetFMPoint charname:%s fmindex:%d index:%d pointindex:%d fl:%d x:%d y:%d\n", + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), + fmpointindex, fl, x, y); +*/ + saacproto_ACSetFMPoint_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), + fmpointindex, fl, x, y, CONNECT_getFdid(fd)); +} + +void ACSetFMPoint(int ret, int r, int clifd) +{ + int meindex = CONNECT_getCharaindex(clifd); + char message[256], buf[512]; + + if (!CHAR_CHECKINDEX(meindex)) return; + + if ((CHAR_getWorkInt(meindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE) + || (CHAR_getWorkInt(meindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE)) + return; + if (ret == 0){ + if (r == -1) + sprintf(message, "申请家族失败!"); + else if (r == -2) + sprintf(message, "你已经有家族据点了~不得重复申请!"); + else if (r == -3) + sprintf(message, "尚未到达申请家族据点的资格!"); + else if (r == -4) + sprintf(message, "家族据点已经有家族在使用中罗!"); + else if (r == -5) + sprintf(message, "您的家族人数未达申请标准唷!"); + } + else if (ret == 1) + sprintf(message, "申请家族据点OK!"); + + lssproto_WN_send( clifd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString(message, buf, sizeof(buf))); +} + +void ACFMAnnounce(int ret, char *fmname, int fmindex, int index, + int kindflag, char *data, int color) +{ + // kindflag 1:族长广播 2:系统公告家族被删除 3:系统通知讯息 + int i, chindex; + if( ret != 1 ) return; +// print("fmname:%s fmindex:%d index:%d kindflag:%d data:%s color:%d\n", +// fmname, fmindex, index, kindflag, data, color); + for( i=0; i < FAMILY_MAXMEMBER; i++) + { + chindex = familyMemberIndex[index][i]; + if( chindex >= 0 ) { + if( CHAR_getCharUse(chindex) ) + { + if (kindflag == 1) + { +#ifdef _FMVER21 + // shan 2001/12/13 + //if( CHAR_getInt( chindex, CHAR_FMLEADERFLAG ) == FMMEMBER_MEMBER ) + if( CHAR_getInt( chindex, CHAR_FMLEADERFLAG ) == FMMEMBER_MEMBER || + CHAR_getInt( chindex, CHAR_FMLEADERFLAG ) == FMMEMBER_ELDER ) +#else + if( CHAR_getInt( chindex, CHAR_FMLEADERFLAG ) == 2 ) +#endif + CHAR_talkToCli( chindex, -1, data, color ); + } + else if (kindflag == 2) + { + int fd = getfdFromCharaIndex( chindex ); + if (fd == -1) return; + SetFMVarInit( chindex ); + CHAR_talkToCli( chindex , -1, "由於您的家族在七天之内没有召收到10名家族成员,所以被迫解散了!", + CHAR_COLORRED); + } + } + else + familyMemberIndex[index][i] = -1; + } + } + if (kindflag == 3) + { + int meindex = 0; + int clifd = getfdFromFdid(color); + if (CONNECT_checkfd(clifd) == FALSE) return; + meindex = CONNECT_getCharaindex(clifd); + if (!CHAR_CHECKINDEX(meindex)) return; + CHAR_talkToCli(meindex, -1, data, CHAR_COLORRED); + } + if (kindflag == 4) + { + int meindex = 0; + char buf[1024]; + int clifd = getfdFromFdid(color); +// print("Here1\n"); + if (CONNECT_checkfd(clifd) == FALSE) return; + meindex = CONNECT_getCharaindex(clifd); + if (!CHAR_CHECKINDEX(meindex)) return; +// print("Here2\n"); + lssproto_WN_send(clifd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString(data, buf, sizeof(buf))); + } +} + +void FAMILY_SetAcceptFlag(int fd, int meindex, char *message) +{ + int result; + char token[128], buf[1024]; + + if (!CHAR_CHECKINDEX(meindex)) return; + + if ((CHAR_getWorkInt(meindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE) + || (CHAR_getWorkInt(meindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE)) + return; + + if ((CHAR_getInt(meindex, CHAR_FMINDEX) == -1) + || (strcmp(CHAR_getChar(meindex, CHAR_FMNAME), "") == 0) +#ifdef _FMVER21 +// || ((CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER) +// && (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_ELDER) +// && (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_VICELEADER))) + || ((CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER) + && (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_ELDER))) +#else + || (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != 1)) +#endif + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n你不是族长,所以没有修改的权力唷!", buf, sizeof(buf))); + return; + } + + if (getStringFromIndexWithDelim(message, "|", 2, token, + sizeof(token)) == FALSE) return; + result = atoi(token); + if ((result == 0) || (result == 1)) + { + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), FM_FIX_ACCEPTFLAG, + token, "", CHAR_getWorkInt(meindex, CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(fd)); + } +} + +void FAMILY_FixRule( int fd, int meindex, char* message ) +{ + + char token[1024], buf[1024]; + + if (!CHAR_CHECKINDEX(meindex))return; + + if ((CHAR_getInt(meindex, CHAR_FMINDEX) == -1) + || (strcmp(CHAR_getChar(meindex, CHAR_FMNAME), "") == 0) +#ifdef _FMVER21 + || (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER)) +#else + || (CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != 1)) +#endif + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n你不是族长,所以没有修改的权力唷!", buf, sizeof(buf))); + return; + } + + if (getStringFromIndexWithDelim(message, "|", 2, token, + sizeof(token)) == FALSE) return; + + if( strcmp( token, "R") == 0 ) + { + if (getStringFromIndexWithDelim(message, "|", 3, buf, + sizeof( buf ) ) == FALSE)return; + + if (strcmp( buf, "") == 0) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n家族主旨不可为空白唷!", buf, sizeof(buf))); + return; + } + +// print(" new_rule:%s ", buf); + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), FM_FIX_FMRULE, + buf, "", CHAR_getWorkInt(meindex, CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(fd)); + return; + } + if( strcmp( token, "P") == 0 ) + { + int havepetindex, petindex, i; + char petname[20], petattr[512]; + + // 检查是否已有守护兽 + for( i =0; i< CHAR_MAXPETHAVE; i++ ) + { + int petindex = CHAR_getCharPet(meindex, i); + if (!CHAR_CHECKINDEX(petindex)) continue; + if( CHAR_getInt( petindex , CHAR_PETFAMILY ) ==1 ) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n原本的守护兽还在唷。", buf, sizeof(buf))); + return; + } + } + // 检查是否已有守护兽(寄宠) + for( i =0; i< CHAR_MAXPOOLPETHAVE; i++ ) + { + int petindex = CHAR_getCharPoolPet(meindex, i); + if (!CHAR_CHECKINDEX(petindex)) continue; + if( CHAR_getInt( petindex , CHAR_PETFAMILY ) ==1 ) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n原本的守护兽还在唷。", buf, sizeof(buf))); + return; + } + } + + if (getStringFromIndexWithDelim(message, "|", 3, buf, + sizeof( buf ) ) == FALSE) return; + havepetindex = atoi( buf ); + + petindex = CHAR_getCharPet(meindex, havepetindex); + + if (!CHAR_CHECKINDEX(petindex)) return; + + if (strlen(CHAR_getChar(petindex, CHAR_USERPETNAME)) == 0) + sprintf(petname, "%s", CHAR_getChar(petindex, CHAR_NAME)); + else + sprintf(petname, "%s", CHAR_getChar(petindex, CHAR_USERPETNAME)); + sprintf(petattr, "%d %d %d %d", + CHAR_getInt(petindex, CHAR_BASEIMAGENUMBER), + CHAR_getWorkInt(petindex, CHAR_WORKATTACKPOWER), + CHAR_getWorkInt(petindex, CHAR_WORKDEFENCEPOWER), + CHAR_getWorkInt(petindex, CHAR_WORKQUICK)); + + CHAR_setInt(petindex, CHAR_PETFAMILY, 1); + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), FM_FIX_FMPET, + petname, petattr, CHAR_getWorkInt(meindex, CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(fd)); + return; + + } + +} + +void JoinMemberIndex( int meindex, int fmindexi ) +{ + int i; + + for( i = 0 ; i < FAMILY_MAXMEMBER; i++){ + if( familyMemberIndex[fmindexi][i] == meindex ) familyMemberIndex[fmindexi][i] = -1; + } + + for( i = 0 ; i < FAMILY_MAXMEMBER; i++){ + if( familyMemberIndex[fmindexi][i] < 0 ){ + familyMemberIndex[fmindexi][i] = meindex; + break; + } + } +#ifdef _CHANNEL_MODIFY + i = 0; + // 先清掉旧的频道记录 + while(i < FAMILY_MAXMEMBER){ + if(channelMember[fmindexi][0][i] == meindex){ + channelMember[fmindexi][0][i] = -1; + } + i++; + } + i = 0; + // 加入频道 + while(i < FAMILY_MAXMEMBER){ + if(channelMember[fmindexi][0][i] == -1){ + channelMember[fmindexi][0][i] = meindex; + CHAR_setWorkInt(meindex,CHAR_WORKFMCHANNEL,0); + break; + } + i++; + } +#endif +} + +void LeaveMemberIndex( int meindex, int fmindexi ) +{ + int i; + + for( i = 0 ; i < FAMILY_MAXMEMBER; i++){ + if( familyMemberIndex[fmindexi][i] == meindex ) familyMemberIndex[fmindexi][i] = -1; + } +#ifdef _CHANNEL_MODIFY + i = 0; + // 清掉旧的频道记录 + while(i < FAMILY_MAXMEMBER){ + if(channelMember[fmindexi][0][i] == meindex){ + channelMember[fmindexi][0][i] = -1; + } + i++; + } +#endif +} + +void FAMILY_RidePet( int fd, int meindex, char* message ) +{ + char token[64], token2[64]; + int petindex, rideGraNo = 0, leaderimageNo; + // Arminius 8.25 recover + int i; +#ifndef _NEW_RIDEPETS + int big4fm = 0; +#endif + if (!CHAR_CHECKINDEX(meindex))return; + + // Robin fix 战斗中不可骑 + if( CHAR_getWorkInt( meindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE ) return; + +#ifdef _PETSKILL_BECOMEPIG + if( CHAR_getInt( meindex, CHAR_BECOMEPIG) > -1 ){ //处於乌力化状态 + CHAR_setInt( meindex, CHAR_RIDEPET, -1 ); + //宠物选项的状态依然为"骑乘",这里修正过来 + CHAR_complianceParameter( meindex ); + CHAR_send_P_StatusString( meindex, CHAR_P_STRING_RIDEPET); + return; + } +#endif + + if( CHAR_getWorkInt( meindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) return; + + if (getStringFromIndexWithDelim(message, "|", 2, token, sizeof(token)) == FALSE) return; + + if( strcmp( token, "P") == 0) { + if (getStringFromIndexWithDelim(message, "|", 3, token2, sizeof(token2)) == FALSE) + return; + + if( atoi(token2) != -1 ) { + petindex = CHAR_getCharPet( meindex, atoi( token2 ) ); + if(!CHAR_CHECKINDEX(petindex))return; + + if( CHAR_getInt( meindex, CHAR_DEFAULTPET ) == atoi( token2 ) ) return; + if( CHAR_getInt( meindex, CHAR_RIDEPET) != -1 ) return; + if( CHAR_getInt( meindex, CHAR_LEARNRIDE) < CHAR_getInt( petindex, CHAR_LV ) ) return; + if( CHAR_getWorkInt( petindex, CHAR_WORKFIXAI ) < 100 )return; + if( CHAR_getInt( meindex, CHAR_LV)+5 < CHAR_getInt( petindex, CHAR_LV ) ) return; +#ifdef _PET_2TRANS + if( CHAR_getInt( petindex, CHAR_TRANSMIGRATION) > 2 ) return; +#endif + leaderimageNo = 100700 + + ((CHAR_getInt( meindex, CHAR_BASEBASEIMAGENUMBER)-100000)/20)*10 + + CHAR_getInt( meindex, CHAR_FMSPRITE)*5; +#ifndef _NEW_RIDEPETS + switch( CHAR_getWorkInt( meindex, CHAR_WORKFMFLOOR) ){ + case 1041: + big4fm = 1; + break; + case 2031: + big4fm = 2; + break; + case 3031: + big4fm = 3; + break; + case 4031: + big4fm = 4; + break; + default: + big4fm = 0; + } +#endif + // Arminius 8.25 recover + for( i=0; i< arraysizeof(ridePetTable) ; i++ ){ +#ifdef _NEW_RIDEPETS + if( (( CHAR_getInt( meindex, CHAR_BASEIMAGENUMBER) == ridePetTable[i].charNo ) || + ( CHAR_getInt( meindex, CHAR_BASEBASEIMAGENUMBER) == ridePetTable[i].charNo )) +#else + if( ( CHAR_getInt( meindex, CHAR_BASEBASEIMAGENUMBER) == ridePetTable[i].charNo ) +#endif + && ( CHAR_getInt( petindex, CHAR_BASEBASEIMAGENUMBER) == ridePetTable[i].petNo ) ){ + rideGraNo = ridePetTable[i].rideNo; + break; + } +#ifndef _NEW_RIDEPETS + if( ( leaderimageNo == ridePetTable[i].charNo ) + && ( CHAR_getInt( petindex, CHAR_BASEBASEIMAGENUMBER) == ridePetTable[i].petNo ) +#ifdef _EVERYONE_RIDE + && big4fm != 0 + && CHAR_getInt( meindex, CHAR_FMLEADERFLAG ) != FMMEMBER_NONE + && CHAR_getInt( meindex, CHAR_FMLEADERFLAG ) != FMMEMBER_APPLY ){ +#else + && CHAR_getInt( meindex, CHAR_FMLEADERFLAG ) == FMMEMBER_LEADER ){ +#endif + rideGraNo = ridePetTable[i].rideNo; + break; + } +#endif + } + +#ifdef _NEW_RIDEPETS + if( rideGraNo == 0 ) { + int ti=-1, index, image=-1; + int petNo = CHAR_getInt( petindex, CHAR_BASEBASEIMAGENUMBER); + int playerNo = CHAR_getInt( meindex, CHAR_BASEBASEIMAGENUMBER); + + int playerlowsride = CHAR_getInt( meindex, CHAR_LOWRIDEPETS); + if( (ti = RIDEPET_getPETindex( petNo, playerlowsride )) >= 0 ) { + if( (index = RIDEPET_getNOindex( playerNo)) >= 0 ){ + if( (image = RIDEPET_getRIDEno( index,ti)) >= 0 ) { + rideGraNo = image; + } + } + } + } +#endif + + if( rideGraNo != 0 ){ +#ifdef _ITEM_METAMO + // CHAR_setWorkInt( meindex, CHAR_WORKITEMMETAMO, 0); +#endif + CHAR_setInt( meindex , CHAR_RIDEPET, atoi( token2 ) ); + CHAR_setInt( meindex , CHAR_BASEIMAGENUMBER , rideGraNo ); + CHAR_complianceParameter( meindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( meindex, CHAR_P_STRING_RIDEPET ); + }else + return; + }else { //还原人物 basebaseimage + CHAR_setInt( meindex , CHAR_RIDEPET, -1 ); + CHAR_setInt( meindex , CHAR_BASEIMAGENUMBER , CHAR_getInt( meindex , CHAR_BASEBASEIMAGENUMBER) ); + CHAR_complianceParameter( meindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( meindex , CHAR_P_STRING_RIDEPET); + } + } + +} + +void ACFixFMPK(int winindex, int loseindex, int data) +{ + int i = 0, charindex = 0; + char msg1[256], msg2[256]; + + sprintf(msg1, "恭喜您!家族声望提高了%8d点!", (data / 100)); + sprintf(msg2, "家族声望减少了%8d点!", (data / 100)); + for (i = 0; i < FAMILY_MAXMEMBER; i++) + { + charindex = familyMemberIndex[winindex][i]; + if( charindex >= 0 ) { + if( CHAR_getCharUse(charindex) ) + CHAR_talkToCli( charindex , -1, msg1, CHAR_COLORYELLOW); + else + familyMemberIndex[winindex][i] = -1; + } + charindex = familyMemberIndex[loseindex][i]; + if( charindex >= 0 ) { + if( CHAR_getCharUse(charindex) ) + CHAR_talkToCli( charindex , -1, msg2, CHAR_COLORRED); + else + familyMemberIndex[loseindex][i] = -1; + } + } +} + +void getNewFMList() +{ + saacproto_ACShowFMList_send( acfd ); +} + +//int channelMember[FAMILY_MAXNUM][FAMILY_MAXCHANNEL][FAMILY_MAXMEMBER]; +//int familyMemberIndex[FAMILY_MAXNUM][FAMILY_MAXMEMBER]; + + +#ifdef _DEATH_FAMILY_GM_COMMAND // WON ADD 家族战GM指令 +int get_fm_leader_index( int fm1 ) +{ + int charindex = -1; + + charindex = familyMemberIndex[fm1][0]; + + return charindex; + +} +#endif + + +void checkFamilyIndex( void ) +{ + int i, j, k, charaindex, err1=0, err2=0; +// print(" checkFamilyIndex! "); + + for( i=0; i 0 ){ + if( fmindex_wk < 0 || fmindex_wk >= FAMILY_MAXNUM){ + print("FamilyNumber Data Error!!"); + return; + } + } + saacproto_ACShowMemberList_send( acfd, fmindex_wk); + + sprintf( sendbuf, " 『族 长 需 知』\n请小心处理族员的资料,一经修改後就无法回复原态,敬请小心。"); + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_FM_MESSAGE2, + CHAR_getWorkInt( leaderdengonindex, CHAR_WORKOBJINDEX), + makeEscapeString( sendbuf, buf, sizeof(buf))); + } + if( strcmp( token, "L") == 0 ){ + int i, kind, letterNo = 0; + char subtoken[256]; + +#ifdef _FMVER21 +// if( CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER && +// CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_INVITE && +// CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_VICELEADER) return; + if( CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER && + CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_ELDER ) return; +#else + if( CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != 1) return; +#endif + + if (getStringFromIndexWithDelim(message, "|", 3, token2, + sizeof(token2)) == FALSE) return; + kind = atoi( token2 ); + + for( i=0 ; i= 0 && tempindex != meindex ) + { + char tmpbuf[1024]; + sprintf(tmpbuf, "%s", CHAR_getChar(tempindex, CHAR_NAME)); + makeEscapeString( tmpbuf, buf, sizeof(buf)); + sprintf( subsub, "|%d|%s", j, buf ); + strcat( subbuf, subsub ); + num++; + } + } + sprintf( sendbuf, "L|CHANGE|L|%d%s", num, subbuf ); + //lssproto_FM_send( fd, sendbuf); + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_LEADERSELECT, + WINDOW_BUTTONTYPE_OK, + -1, -1, + sendbuf ); + + } + // 询问族长候选人是否愿意接受 + if( strcmp( token2, "Q") == 0 ) + { + char token3[64], token4[64]; + int toindex; + +#ifdef _FMVER21 + if( CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER) return; +#else + if( CHAR_getInt(meindex, CHAR_FMLEADERFLAG) != 1) return; +#endif + if (getStringFromIndexWithDelim(message, "|", 4, token3, + sizeof(token3)) == FALSE)return; + if (getStringFromIndexWithDelim(message, "|", 5, token4, + sizeof(token4)) == FALSE)return; + makeStringFromEscaped( token4 ); + + if( atoi(token3) < 0 || atoi(token3) > FAMILY_MAXMEMBER ) return; + + toindex = familyMemberIndex[fmindexi][atoi(token3)]; + if( !CHAR_CHECKINDEX( toindex ) ) return; + if( strcmp( token4, CHAR_getChar( toindex, CHAR_NAME)) != 0 ) return; + if( CheckLeaderQ(toindex) < 0 ) return; + + // 双方都决定让位时,CHAR_WORKLEADERCHANGE存放对方的charaindex + CHAR_setWorkInt( toindex, CHAR_WORKLEADERCHANGE, meindex); + CHAR_setWorkInt( meindex, CHAR_WORKLEADERCHANGE, toindex); + + sprintf( sendbuf, "%s|%d", makeEscapeString( CHAR_getChar( meindex, CHAR_NAME ), buf, sizeof(buf)), meindex ); + + lssproto_WN_send( CHAR_getWorkInt( toindex, CHAR_WORKFD ), WINDOW_MESSAGETYPE_LEADERSELECTA, + WINDOW_BUTTONTYPE_OK, + -1, -1, + sendbuf ); + + } + // 候选人的答覆 + if( strcmp( token2, "A") == 0 ) + { + int leaderindex, answerflag; + char leadername[64], token3[64], token4[64]; + +// print( "%s", message ); + + if (getStringFromIndexWithDelim(message, "|", 4, token3, + sizeof(token3)) == FALSE) return; + answerflag = atoi( token3 ); + + if (getStringFromIndexWithDelim(message, "|", 5, leadername, + sizeof( leadername )) == FALSE)return; + makeStringFromEscaped( leadername ); + + if (getStringFromIndexWithDelim(message, "|", 6, token4, + sizeof(token4)) == FALSE)return; + + //if( atoi(token4) < 0 || atoi(token4) > FAMILY_MAXMEMBER ) return; + + leaderindex = atoi( token4 ); + + // 检查双方的CHAR_WORKLEADERCHANGE是否相符 + if( CHAR_getWorkInt( meindex, CHAR_WORKLEADERCHANGE ) != leaderindex ) return; + if( !CHAR_CHECKINDEX(leaderindex) ) return; + if( strcmp( leadername, CHAR_getChar( leaderindex, CHAR_NAME) ) != 0 ) return; + if( CHAR_getWorkInt( leaderindex, CHAR_WORKLEADERCHANGE ) != meindex ) return; + CHAR_setWorkInt( leaderindex, CHAR_WORKLEADERCHANGE, -1 ); +#ifdef _FMVER21 + if( CHAR_getInt(leaderindex, CHAR_FMLEADERFLAG ) != FMMEMBER_LEADER ) return; +#else + if( CHAR_getInt(leaderindex, CHAR_FMLEADERFLAG ) != 1 ) return; +#endif + if( CHAR_getInt(meindex, CHAR_FMINDEX) != CHAR_getInt(leaderindex, CHAR_FMINDEX) ) return; + + if( answerflag == 0 ) + { + CHAR_setWorkInt( meindex, CHAR_WORKLEADERCHANGE, 0); + CHAR_setWorkInt( leaderindex, CHAR_WORKLEADERCHANGE, 0); + lssproto_WN_send( CHAR_getWorkInt( leaderindex, CHAR_WORKFD) , WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n对不起!对方不愿意接受!", buf, sizeof(buf)) ); + return; + } + + if( answerflag == 1 ) + { + char tmpbuf[1024]; + sprintf( buf, "%d", CHAR_getInt( meindex, CHAR_FACEIMAGENUMBER ) ); + // CoolFish: add charname 2001/9/27 + sprintf( tmpbuf, "%s", CHAR_getChar( meindex, CHAR_NAME ) ); + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(meindex, CHAR_FMNAME), + CHAR_getInt(meindex, CHAR_FMINDEX), + CHAR_getWorkInt(meindex, CHAR_WORKFMINDEXI), FM_FIX_FMLEADERCHANGE , buf, + tmpbuf, CHAR_getWorkInt(meindex, CHAR_WORKFMCHARINDEX), CONNECT_getFdid(fd)); + // "", CHAR_getWorkInt(meindex, CHAR_WORKFMCHARINDEX), CONNECT_getFdid(fd)); + return; + } + } + } +} + +void ACFMJob( int fd, int ret, char* data1, char* data2 ) +{ + + int charaindex = CONNECT_getCharaindex( fd ); + if( !CHAR_CHECKINDEX(charaindex) ) return; + + + if( 1 ){ + + int leaderindex = CHAR_getWorkInt( charaindex, CHAR_WORKLEADERCHANGE ); + char buf[256], buf2[256]; + + CHAR_setWorkInt( charaindex, CHAR_WORKLEADERCHANGE, 0 ); + print("leaderindex:%d:%s\n", leaderindex,CHAR_getChar(leaderindex,CHAR_NAME) ); + + if( !CHAR_CHECKINDEX(leaderindex) ) return; + //if( CHAR_getWorkInt( leaderindex, CHAR_WORKLEADERCHANGE ) != charaindex ) return; + CHAR_setWorkInt( leaderindex, CHAR_WORKLEADERCHANGE, 0 ); + + if( ret == 0 ){ + CHAR_talkToCli( charaindex, -1, "族长让位失败!", CHAR_COLORYELLOW ); + CHAR_talkToCli( leaderindex, -1, "族长让位失败!", CHAR_COLORYELLOW ); + return; + } + + // Robin 10/02 debug + if( CHAR_getInt( leaderindex, CHAR_FMINDEX) != CHAR_getInt( charaindex, CHAR_FMINDEX) +#ifdef _FMVER21 + // || CHAR_getInt( leaderindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER ) +#else + // || CHAR_getInt( leaderindex, CHAR_FMLEADERFLAG) != 1 +#endif + ) + { + sprintf( buf, "leaderindex:%d:%s\n", leaderindex, CHAR_getChar( leaderindex, CHAR_NAME) ); + LogFamily( + CHAR_getChar(charaindex, CHAR_FMNAME), + CHAR_getInt(charaindex, CHAR_FMINDEX), + CHAR_getChar(charaindex, CHAR_NAME), + CHAR_getChar(charaindex, CHAR_CDKEY), + "LEADERCHANGE_ERROR(族长让位失败)", + buf + ); + return; + } + + //CHAR_setInt( leaderindex, CHAR_FMLEADERFLAG, FMMEMBER_MEMBER); + //CHAR_setInt( charaindex, CHAR_FMLEADERFLAG, FMMEMBER_LEADER); + SetFMPetVarInit( leaderindex ); + SetFMPetVarInit( charaindex ); + CHAR_sendStatusString( leaderindex, "F"); + CHAR_sendStatusString( charaindex, "F"); + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( "\n恭喜你!你已经是新任的族长了。\n请好好的努力吧!\n对了~记得请先到村长家的家族管理员选择\n新的家族守护兽,否则家族将会被解散唷!", buf, sizeof(buf))); + + sprintf( buf2, "\n辛苦你了!你已经将族长的位子交给%s了。", CHAR_getChar( charaindex, CHAR_NAME) ); + lssproto_WN_send( CHAR_getWorkInt( leaderindex, CHAR_WORKFD) , WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( buf2, buf, sizeof(buf))); + +// print(" LeaderChange!! [%s]->[%s] ", CHAR_getChar(leaderindex, CHAR_CDKEY), CHAR_getChar(charaindex, CHAR_CDKEY) ); + + sprintf( buf, "%s\t%s\t%s", + CHAR_getChar(leaderindex, CHAR_FMNAME), + CHAR_getChar(leaderindex, CHAR_NAME), + CHAR_getChar(leaderindex, CHAR_CDKEY) + ); + + LogFamily( + CHAR_getChar(charaindex, CHAR_FMNAME), + CHAR_getInt(charaindex, CHAR_FMINDEX), + CHAR_getChar(charaindex, CHAR_NAME), + CHAR_getChar(charaindex, CHAR_CDKEY), + "LEADERCHANGE(族长让位)", + buf + ); + + } + +} + + +#ifdef _DEATH_FAMILY_GM_COMMAND // WON ADD 家族战GM指令 + +FM_PK_STRUCT fm_pk_struct; + +void setInt_fm_pk_struct( int index, int type, int num ) +{ + switch( type ){ + case FM_INDEX: + fm_pk_struct.fm_index[index] = num; + break; + case FM_WIN: + fm_pk_struct.fm_win[index] = num; + break; + case FM_LOSE: + fm_pk_struct.fm_lose[index] = num; + break; + case FM_SCORE: + fm_pk_struct.fm_score[index] = num; + break; + } +} + +void setChar_fm_pk_struct( int index, int type, char *msg ) +{ + switch( type ){ + case FM_NAME: + strcpy( fm_pk_struct.fm_name[index], msg ); + break; + } +} + +int getInt_fm_pk_struct( int index, int type ) +{ + switch( type ){ + case FM_INDEX: + return fm_pk_struct.fm_index[index]; + case FM_WIN: + return fm_pk_struct.fm_win[index]; + case FM_LOSE: + return fm_pk_struct.fm_lose[index]; + case FM_SCORE: + return fm_pk_struct.fm_score[index]; + } + + return -1; +} + +char *getChar_fm_pk_struct( int index, int type ) +{ + switch( type ){ + case FM_NAME: + return fm_pk_struct.fm_name[index]; + } + + return NULL; +} + +#endif diff --git a/gmsv/char/ls2data.h b/gmsv/char/ls2data.h new file mode 100644 index 0000000..b2a4104 --- /dev/null +++ b/gmsv/char/ls2data.h @@ -0,0 +1,13 @@ +#ifndef LS2DATA_DAT +#define LS2DATA_DAT + +typedef struct { + int hash; + char *name; + int graphicnumber; +} CconvertStringNumber; + +CconvertStringNumber *convertStringNumber; +int cconvertStringNumber; + +#endif // LS2DATA_DAT ///:~ \ No newline at end of file diff --git a/gmsv/char/makefile b/gmsv/char/makefile new file mode 100644 index 0000000..4001a19 --- /dev/null +++ b/gmsv/char/makefile @@ -0,0 +1,1043 @@ +INCFLAGS=-I.. -I../include + + +CFLAGS=-w -O3 $(INCFLAGS) + +PROG=libchar.a + +SRC=char_base.c char.c char_event.c char_data.c skill.c title.c\ +addressbook.c chatmagic.c event.c char_walk.c encount.c pet.c \ +enemy.c pet_event.c char_talk.c char_party.c char_item.c deathcontend.c \ +chatroom.c petmail.c trade.c family.c defend.c char_angel.c + +OBJ=$(SRC:.c=.o) + +ifeq (0,$(MAKELEVEL)) +CC=gcc +RM=rm -f +AR=ar cr +MV=mv +RANLIB=ranlib +SED=sed +SHELL=/bin/sh +endif + +all: $(PROG) + +$(PROG): $(OBJ) + $(RM) $(PROG) + $(AR) $(PROG) $(OBJ) + $(RANLIB) $(PROG) + +depend: + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(CC) $(INCFLAGS) -M $(SRC) >> makefile + +clean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + +distclean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(RM) makefile.bak + +# DO NOT DELETE THIS LINE +char_base.o: char_base.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/time.h /usr/include/bits/time.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + ../include/char_base.h ../include/skill.h ../include/common.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/char.h ../include/buf.h ../include/magic.h \ + ../include/function.h ../include/npccreate.h ../include/configfile.h \ + ../include/pet.h ../include/pet_skill.h ../include/anim_tbl.h \ + ../include/enemy.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h ../include/log.h +char.o: char.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h /usr/include/string.h \ + /usr/include/sys/stat.h /usr/include/bits/stat.h /usr/include/ctype.h \ + /usr/include/sys/time.h /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h ../include/common.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/char.h ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/item_event.h ../include/buf.h \ + ../include/object.h ../include/map_deal.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/readmap.h \ + ../include/handletime.h ../include/char_event.h ../include/npccreate.h \ + ../include/magic_base.h ../include/magic.h ../include/chatmagic.h \ + ../include/configfile.h ../include/log.h ../include/anim_tbl.h \ + ../include/encount.h ../include/battle.h ../include/pet_skill.h \ + ../include/enemy.h ../include/npcutil.h ../include/pet.h \ + ../include/family.h ../include/defend.h ../include/profession_skill.h \ + ../include/chatroom.h +char_event.o: char_event.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/ctype.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/typesizes.h /usr/include/endian.h \ + /usr/include/bits/endian.h ../include/common.h /usr/include/stdio.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/item_event.h ../include/object.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/string.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h ../include/readmap.h \ + ../include/map_deal.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npccreate.h \ + ../include/handletime.h ../include/anim_tbl.h ../include/family.h +char_data.o: char_data.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/math.h /usr/include/bits/huge_val.h \ + /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/readmap.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + ../include/util.h /usr/include/sys/time.h /usr/include/time.h \ + /usr/include/bits/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/anim_tbl.h ../include/battle.h \ + ../include/char.h ../include/char_base.h ../include/skill.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/buf.h ../include/log.h ../include/pet.h ../include/enemy.h \ + ../include/configfile.h defaultPlayer.h defaultGroundEnemy.h \ + ../ls2data.dat ../include/family.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h +skill.o: skill.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h /usr/include/string.h \ + ../include/skill.h ../include/common.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h ../include/util.h /usr/include/sys/time.h \ + ../include/char.h ../include/char_base.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/netinet/in.h \ + /usr/include/stdint.h /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/battle.h ../include/profession_skill.h +title.o: title.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h /usr/include/string.h \ + /usr/include/ctype.h /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h ../include/title.h \ + ../include/common.h ../include/util.h /usr/include/sys/time.h \ + ../include/char.h ../include/char_base.h ../include/skill.h \ + ../include/addressbook.h ../include/net.h /usr/include/netinet/in.h \ + /usr/include/stdint.h /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/buf.h ../include/configfile.h +addressbook.o: addressbook.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h /usr/include/string.h \ + /usr/include/strings.h ../include/addressbook.h ../include/common.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h ../include/util.h \ + /usr/include/sys/time.h ../include/net.h /usr/include/netinet/in.h \ + /usr/include/stdint.h /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char.h ../include/char_base.h \ + ../include/skill.h ../include/title.h ../include/char_data.h \ + ../include/item.h ../include/handletime.h ../include/buf.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/saacproto_cli.h ../include/saacproto_util.h \ + ../include/object.h ../include/battle.h ../include/configfile.h \ + ../include/npcutil.h ../include/pet.h ../include/petmail.h \ + ../include/log.h +chatmagic.o: chatmagic.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/string.h /usr/include/ctype.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/math.h \ + /usr/include/bits/huge_val.h /usr/include/bits/mathdef.h \ + /usr/include/bits/mathcalls.h /usr/include/malloc.h /usr/include/time.h \ + /usr/include/bits/time.h /usr/include/stdlib.h /usr/include/sys/types.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/common.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h ../include/char.h ../include/char_base.h \ + ../include/skill.h ../include/util.h /usr/include/sys/time.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/buf.h ../include/npcutil.h ../include/object.h \ + ../include/handletime.h ../include/chatmagic.h ../include/configfile.h \ + ../include/readmap.h ../include/map_deal.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/log.h ../include/battle.h \ + ../include/pet.h ../include/enemy.h ../include/encount.h \ + ../include/magic_base.h ../include/magic.h ../include/pet_skill.h \ + ../include/pet_event.h ../include/item_gen.h ../include/mclient.h \ + ../include/npc_eventaction.h ../include/map_warppoint.h \ + ../include/npc_manorsman.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npc_scheduleman.h \ + ../include/trade.h ../include/npccreate.h ../include/profession_skill.h \ + ../include/char_talk.h ../include/family.h ../include/petmail.h \ + ../include/npc_raceman.h +event.o: event.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + ../include/object.h ../include/common.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h ../include/char_base.h ../include/skill.h \ + ../include/util.h /usr/include/sys/time.h /usr/include/time.h \ + /usr/include/bits/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/readmap.h ../include/map_warppoint.h \ + ../include/event.h ../include/npc_warp.h ../include/npc_npcenemy.h +char_walk.o: char_walk.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/ctype.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/time.h /usr/include/bits/time.h ../include/common.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/handletime.h /usr/include/sys/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h ../include/object.h ../include/char_base.h \ + ../include/skill.h ../include/util.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/char_event.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/string.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h ../include/readmap.h \ + ../include/map_deal.h ../include/npccreate.h ../include/encount.h \ + ../include/npcutil.h ../include/battle.h ../include/configfile.h \ + ../include/npc_npcenemy.h +encount.o: encount.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/string.h /usr/include/math.h /usr/include/bits/huge_val.h \ + /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h ../include/common.h \ + ../include/util.h /usr/include/sys/time.h /usr/include/time.h \ + /usr/include/bits/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/buf.h ../include/char_base.h \ + ../include/skill.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/configfile.h ../include/encount.h \ + ../include/enemy.h +pet.o: pet.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + ../include/char_base.h ../include/skill.h ../include/common.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/object.h ../include/readmap.h \ + ../include/map_deal.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/string.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/handletime.h ../include/pet.h ../include/battle.h \ + ../include/petmail.h ../include/log.h ../include/function.h +enemy.o: enemy.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/string.h ../include/common.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h ../include/util.h /usr/include/sys/time.h \ + /usr/include/time.h /usr/include/bits/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/buf.h ../include/char_base.h \ + ../include/skill.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/configfile.h ../include/encount.h \ + ../include/enemy.h ../include/pet.h ../include/enemyexptbl.h \ + ../include/petmail.h ../include/battle.h ../include/pet_skillinfo.h \ + ../include/anim_tbl.h ../include/log.h ../include/npcutil.h +pet_event.o: pet_event.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h ../include/common.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h ../include/object.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/configfile.h ../include/handletime.h \ + ../include/pet_event.h ../include/npcutil.h ../include/log.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/string.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/npc_exchangeman.h \ + ../include/npc_eventaction.h +char_talk.o: char_talk.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/ctype.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/string.h ../include/readmap.h ../include/common.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/object.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/netinet/in.h \ + /usr/include/stdint.h /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/chatmagic.h ../include/battle.h ../include/log.h \ + ../include/configfile.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/family.h \ + ../include/profession_skill.h +char_party.o: char_party.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + ../include/readmap.h ../include/common.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h ../include/util.h /usr/include/sys/time.h \ + /usr/include/time.h /usr/include/bits/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/object.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/netinet/in.h \ + /usr/include/stdint.h /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/battle.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/string.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h ../include/npcutil.h \ + ../include/npc_bus.h ../include/npc_airplane.h ../include/family.h \ + ../include/init.h +char_item.o: char_item.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + ../include/readmap.h ../include/common.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h ../include/util.h /usr/include/sys/time.h \ + /usr/include/time.h /usr/include/bits/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/map_deal.h ../include/object.h \ + ../include/char.h ../include/char_base.h ../include/skill.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/string.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/handletime.h ../include/log.h \ + ../include/item_event.h ../include/battle.h ../include/petmail.h +deathcontend.o: deathcontend.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/math.h /usr/include/bits/huge_val.h \ + /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h \ + ../include/util.h /usr/include/sys/time.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/include/bits/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/common.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h ../include/char.h ../include/char_base.h \ + ../include/skill.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/battle.h ../include/configfile.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h ../include/buf.h \ + ../include/log.h +chatroom.o: chatroom.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/ctype.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/string.h ../include/readmap.h ../include/common.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/object.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/netinet/in.h \ + /usr/include/stdint.h /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/chatmagic.h ../include/battle.h ../include/log.h \ + ../include/configfile.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/family.h ../include/chatroom.h +petmail.o: petmail.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + ../include/configfile.h ../include/common.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h ../include/buf.h ../include/char_base.h \ + ../include/skill.h ../include/util.h /usr/include/sys/time.h \ + /usr/include/time.h /usr/include/bits/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/battle.h ../include/handletime.h \ + ../include/map_deal.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/string.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h ../include/pet.h \ + ../include/petmail.h ../include/npcutil.h ../include/log.h +trade.o: trade.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/string.h /usr/include/ctype.h /usr/include/endian.h \ + /usr/include/bits/endian.h ../include/readmap.h ../include/common.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/object.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/netinet/in.h \ + /usr/include/stdint.h /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/npcutil.h ../include/trade.h \ + ../include/log.h ../include/handletime.h ../include/buf.h \ + ../include/battle.h ../include/npc_bus.h ../include/char_talk.h \ + ../include/pet_skill.h +family.o: family.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/string.h /usr/include/ctype.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/time.h /usr/include/bits/time.h \ + ../include/readmap.h ../include/common.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h ../include/util.h /usr/include/sys/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/object.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/netinet/in.h \ + /usr/include/stdint.h /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npcutil.h ../include/family.h \ + ../include/log.h ../include/handletime.h ../include/buf.h \ + ../include/battle.h ../include/npc_bus.h ../include/char_talk.h \ + ../include/npc_scheduleman.h ../include/npc_fmdengon.h +defend.o: defend.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/string.h /usr/include/ctype.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/time.h /usr/include/bits/time.h \ + ../include/readmap.h ../include/common.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h ../include/util.h /usr/include/sys/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/object.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/netinet/in.h \ + /usr/include/stdint.h /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npcutil.h ../include/family.h \ + ../include/log.h ../include/handletime.h ../include/buf.h \ + ../include/battle.h ../include/npc_bus.h ../include/char_talk.h \ + ../include/npc_scheduleman.h ../include/defend.h +char_angel.o: char_angel.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h /usr/include/string.h \ + /usr/include/sys/stat.h /usr/include/bits/stat.h /usr/include/ctype.h \ + /usr/include/sys/time.h /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h ../include/common.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/char.h ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/item_event.h ../include/buf.h \ + ../include/object.h ../include/map_deal.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/readmap.h \ + ../include/handletime.h ../include/char_event.h ../include/npccreate.h \ + ../include/magic_base.h ../include/magic.h ../include/chatmagic.h \ + ../include/configfile.h ../include/log.h ../include/anim_tbl.h \ + ../include/encount.h ../include/battle.h ../include/pet_skill.h \ + ../include/enemy.h ../include/npcutil.h ../include/pet.h \ + ../include/family.h ../include/defend.h ../include/npcserver.h diff --git a/gmsv/char/makefile.bak b/gmsv/char/makefile.bak new file mode 100644 index 0000000..32d36d4 --- /dev/null +++ b/gmsv/char/makefile.bak @@ -0,0 +1,727 @@ +INCFLAGS=-I.. -I../include + + +CFLAGS=-w -O3 $(INCFLAGS) + +PROG=libchar.a + +SRC=char_base.c char.c char_event.c char_data.c skill.c title.c\ +addressbook.c chatmagic.c event.c char_walk.c encount.c pet.c \ +enemy.c pet_event.c char_talk.c char_party.c char_item.c deathcontend.c \ +chatroom.c petmail.c trade.c family.c defend.c char_angel.c + +OBJ=$(SRC:.c=.o) + +ifeq (0,$(MAKELEVEL)) +CC=gcc +RM=rm -f +AR=ar cr +MV=mv +RANLIB=ranlib +SED=sed +SHELL=/bin/sh +endif + +all: $(PROG) + +$(PROG): $(OBJ) + $(RM) $(PROG) + $(AR) $(PROG) $(OBJ) + $(RANLIB) $(PROG) + +depend: + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(CC) $(INCFLAGS) -M $(SRC) >> makefile + +clean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + +distclean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(RM) makefile.bak + +# DO NOT DELETE THIS LINE +char_base.o: char_base.c /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char_base.h ../include/skill.h ../include/common.h \ + /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/util.h /usr/include/sys/time.h /usr/include/time.h \ + /usr/include/bits/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/char.h ../include/buf.h ../include/magic.h \ + ../include/function.h ../include/npccreate.h ../include/configfile.h \ + ../include/pet.h ../include/pet_skill.h +char.o: char.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h /usr/include/string.h /usr/include/ctype.h \ + /usr/include/sys/time.h /usr/include/bits/time.h ../include/common.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/char.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/item_event.h ../include/buf.h ../include/object.h \ + ../include/map_deal.h ../include/saacproto_cli.h ../include/map_warppoint.h \ + ../include/saacproto_util.h ../include/readmap.h \ + ../include/handletime.h ../include/char_event.h \ + ../include/npccreate.h ../include/magic_base.h ../include/magic.h \ + ../include/chatmagic.h ../include/configfile.h ../include/log.h \ + ../include/anim_tbl.h ../include/encount.h ../include/battle.h \ + ../include/pet_skill.h ../include/enemy.h ../include/npcutil.h \ + ../include/pet.h ../include/family.h +char_event.o: char_event.c /usr/include/ctype.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h /usr/include/bits/types.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/endian.h /usr/include/bits/endian.h ../include/common.h \ + /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/bits/stdio_lim.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/item_event.h ../include/object.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/string.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/readmap.h ../include/map_deal.h \ + ../include/saacproto_cli.h ../include/saacproto_util.h \ + ../include/npccreate.h ../include/handletime.h ../include/anim_tbl.h +char_data.o: char_data.c /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/math.h /usr/include/bits/huge_val.h \ + /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/float.h \ + ../include/readmap.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/util.h /usr/include/sys/time.h /usr/include/time.h \ + /usr/include/bits/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/anim_tbl.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/buf.h defaultPlayer.h defaultGroundEnemy.h ls2data.h +skill.o: skill.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h /usr/include/string.h ../include/skill.h \ + ../include/common.h ../include/util.h /usr/include/sys/time.h \ + /usr/include/bits/time.h ../include/char.h ../include/char_base.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h +title.o: title.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h /usr/include/string.h /usr/include/ctype.h \ + ../include/title.h ../include/common.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/bits/time.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/buf.h ../include/configfile.h +addressbook.o: addressbook.c /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h /usr/include/string.h /usr/include/strings.h \ + ../include/addressbook.h ../include/common.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/bits/time.h ../include/net.h \ + /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char.h ../include/char_base.h \ + ../include/skill.h ../include/title.h ../include/char_data.h \ + ../include/item.h ../include/handletime.h ../include/buf.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/saacproto_cli.h ../include/saacproto_util.h \ + ../include/object.h ../include/battle.h ../include/configfile.h \ + ../include/npcutil.h ../include/pet.h ../include/petmail.h \ + ../include/log.h +chatmagic.o: chatmagic.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + /usr/include/time.h /usr/include/bits/time.h /usr/include/string.h \ + /usr/include/ctype.h /usr/include/endian.h /usr/include/bits/endian.h \ + ../include/common.h ../include/char.h ../include/char_base.h \ + ../include/skill.h ../include/util.h /usr/include/sys/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/buf.h ../include/npcutil.h ../include/object.h \ + ../include/handletime.h ../include/chatmagic.h \ + ../include/configfile.h ../include/readmap.h ../include/map_deal.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/log.h ../include/battle.h \ + ../include/pet.h ../include/enemy.h ../include/encount.h \ + ../include/magic_base.h ../include/magic.h ../include/pet_skill.h \ + ../include/item_gen.h +event.o: event.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/object.h ../include/common.h ../include/char_base.h \ + ../include/skill.h ../include/util.h /usr/include/sys/time.h \ + /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/map_warppoint.h \ + ../include/item.h ../include/readmap.h ../include/event.h \ + ../include/npc_warp.h ../include/npc_npcenemy.h +char_walk.o: char_walk.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + /usr/include/ctype.h /usr/include/endian.h /usr/include/bits/endian.h \ + ../include/common.h ../include/handletime.h /usr/include/sys/time.h \ + /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h ../include/object.h ../include/char_base.h \ + ../include/skill.h ../include/util.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/char_event.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/string.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/readmap.h ../include/map_deal.h \ + ../include/npccreate.h ../include/encount.h ../include/npcutil.h \ + ../include/battle.h +encount.o: encount.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + /usr/include/string.h /usr/include/math.h \ + /usr/include/bits/huge_val.h /usr/include/bits/mathdef.h \ + /usr/include/bits/mathcalls.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/float.h \ + ../include/common.h ../include/util.h /usr/include/sys/time.h \ + /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/buf.h ../include/char_base.h \ + ../include/skill.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/configfile.h ../include/encount.h \ + ../include/enemy.h +pet.o: pet.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/common.h \ + ../include/util.h /usr/include/sys/time.h /usr/include/time.h \ + /usr/include/bits/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/object.h ../include/readmap.h \ + ../include/map_deal.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/string.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/handletime.h ../include/pet.h \ + ../include/battle.h ../include/petmail.h ../include/log.h +enemy.o: enemy.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + /usr/include/string.h ../include/common.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/buf.h ../include/char_base.h \ + ../include/skill.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/configfile.h ../include/encount.h \ + ../include/enemy.h ../include/pet.h ../include/enemyexptbl.h \ + ../include/petmail.h ../include/battle.h ../include/pet_skillinfo.h \ + ../include/anim_tbl.h +pet_event.o: pet_event.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/common.h ../include/object.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/bits/time.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/configfile.h ../include/handletime.h \ + ../include/pet_event.h ../include/npcutil.h ../include/log.h +char_talk.o: char_talk.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + /usr/include/ctype.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/string.h ../include/readmap.h ../include/common.h \ + ../include/util.h /usr/include/sys/time.h /usr/include/time.h \ + /usr/include/bits/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h \ + /usr/include/sys/sysmacros.h /usr/include/alloca.h \ + ../include/object.h ../include/char.h ../include/char_base.h \ + ../include/skill.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/chatmagic.h ../include/battle.h ../include/log.h \ + ../include/configfile.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/family.h +char_party.o: char_party.c /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/readmap.h ../include/common.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/object.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/battle.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/string.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/npcutil.h ../include/npc_bus.h \ + ../include/init.h +char_item.o: char_item.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/readmap.h ../include/common.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/map_deal.h ../include/object.h \ + ../include/char.h ../include/char_base.h ../include/skill.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/string.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/handletime.h ../include/log.h \ + ../include/item_event.h ../include/battle.h +petmail.o: petmail.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/configfile.h ../include/common.h ../include/buf.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/battle.h ../include/handletime.h \ + ../include/map_deal.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/string.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/pet.h ../include/petmail.h \ + ../include/npcutil.h ../include/log.h +trade.o: trade.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + /usr/include/string.h /usr/include/ctype.h /usr/include/endian.h \ + /usr/include/bits/endian.h ../include/readmap.h ../include/common.h \ + ../include/util.h /usr/include/sys/time.h /usr/include/time.h \ + /usr/include/bits/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h \ + /usr/include/sys/sysmacros.h /usr/include/alloca.h \ + ../include/object.h ../include/char.h ../include/char_base.h \ + ../include/skill.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/npcutil.h ../include/trade.h \ + ../include/log.h ../include/handletime.h ../include/buf.h \ + ../include/battle.h ../include/npc_bus.h ../include/char_talk.h +family.o: family.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + /usr/include/string.h /usr/include/ctype.h /usr/include/endian.h \ + /usr/include/bits/endian.h ../include/readmap.h ../include/common.h \ + ../include/util.h /usr/include/sys/time.h /usr/include/time.h \ + /usr/include/bits/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h \ + /usr/include/sys/sysmacros.h /usr/include/alloca.h \ + ../include/object.h ../include/char.h ../include/char_base.h \ + ../include/skill.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npcutil.h ../include/family.h \ + ../include/log.h ../include/handletime.h ../include/buf.h \ + ../include/battle.h ../include/npc_bus.h ../include/char_talk.h diff --git a/gmsv/char/pet.c b/gmsv/char/pet.c new file mode 100644 index 0000000..8d884ca --- /dev/null +++ b/gmsv/char/pet.c @@ -0,0 +1,627 @@ +#include "version.h" +#include + +#include "char_base.h" +#include "char.h" +#include "object.h" +#include "readmap.h" +#include "map_deal.h" +#include "lssproto_serv.h" +#include "handletime.h" +#include "pet.h" +#include "battle.h" +#include "petmail.h" +#include "log.h" +#ifdef _MARKET_TRADE +#include "item_trade.h" +#endif +#include "function.h" +/* + * 矢永玄质 卞楮允月末□旦 + */ +/*------------------------------------------------------------------------ + * 矢永玄毛ㄠ勾喃曰癫化月[犯田永弘迕[ + * CHAR厌瞻 卞及心综岳今木月[ + * 曰袄“综岳今木凶平乓仿index 撩 “-1 + *-----------------------------------------------------------------------*/ +int PET_DEBUG_initPetOne( int charaindex) +{ + Char ch; + int havepetindex; + int index; + /* 矢永玄毛 化月井譬屯月 */ + havepetindex = CHAR_getCharPetElement( charaindex) ; + + memset( &ch, 0, sizeof( ch)); + if( !CHAR_getDefaultChar( &ch,31010 ) )return -1; + + /* 飓 寞 */ + ch.data[CHAR_BASEBASEIMAGENUMBER] + = ch.data[CHAR_BASEIMAGENUMBER] = 30008; + ch.data[CHAR_WHICHTYPE] = CHAR_TYPEPET; + /* 猾 */ + ch.workint[CHAR_WORKATTACKPOWER] = 100; + /* 潮 */ + ch.workint[CHAR_WORKDEFENCEPOWER] = 50; + /* HP */ + ch.data[CHAR_HP] = 100; + /* 蟆 */ + strcpysafe( ch.string[CHAR_NAME].string, 32, "宠物1" ); + + /* CHAR卞喃曰癫化月 */ + index = PET_initCharOneArray( &ch); + + if( index < 0 ) return -1; + + /* 仍潜谛本永玄 */ + CHAR_setWorkInt( index, CHAR_WORKPLAYERINDEX, charaindex); + CHAR_setWorkInt( index,CHAR_WORKOBJINDEX,-1); + CHAR_setCharPet( charaindex, havepetindex, index); + CHAR_setInt( index, CHAR_SLOT, 2); + return havepetindex; +} + +static int _PET_dropPet( int charaindex, int havepetindex, int tofl, int tox, int toy) +{ + char szPet[128]; + int dirx[9],diry[9]; + int i, j; + int objindex=-1; + int floor,x,y; + int petindex; + int count_chara =0, count_item =0; + + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) return FALSE; + petindex = CHAR_getCharPet(charaindex,havepetindex); + if( !CHAR_CHECKINDEX( petindex )) return FALSE; + if( !CHAR_CHECKINDEX( charaindex ) )return FALSE; + if( CHAR_CHECKINDEX( petindex) == FALSE ) return FALSE; + +#ifdef _AVID_TRADETRYBUG //丢出宠物 + if( CHAR_getWorkInt( charaindex, CHAR_WORKTRADEMODE) == CHAR_TRADE_TRADING ){ + CHAR_talkToCli( charaindex, -1, "交易状态中无法丢出宠物。", CHAR_COLORYELLOW ); + return FALSE; + } +#endif + // CoolFish: Family 2001/6/13 + if (CHAR_getInt(petindex, CHAR_PETFAMILY) == 1){ + CHAR_talkToCli(charaindex, -1, "家族守护兽无法丢出!", CHAR_COLORYELLOW); + return FALSE; + } + if (CHAR_getInt(charaindex, CHAR_RIDEPET) == havepetindex ){ + CHAR_talkToCli(charaindex, -1, "骑乘中的宠物无法丢出!", CHAR_COLORYELLOW); + return FALSE; + } + +#ifdef _DROPCHECK2 + + floor = CHAR_getInt( charaindex, CHAR_FLOOR); + x = CHAR_getInt( charaindex, CHAR_X); + y = CHAR_getInt( charaindex, CHAR_Y); + + for( i = x-CHAR_DEFAULTSEESIZ/2 ; i <= x+CHAR_DEFAULTSEESIZ/2 ; i++ ){ + for( j = y-CHAR_DEFAULTSEESIZ/2 ; j <= y+CHAR_DEFAULTSEESIZ/2 ; j ++ ){ + OBJECT object; + for( object = MAP_getTopObj(floor,i,j); object ; object = NEXT_OBJECT(object ) ) { + int objindex = GET_OBJINDEX(object); + if( OBJECT_getType(objindex) == OBJTYPE_NOUSE ) continue; + + if( OBJECT_getType(objindex) == OBJTYPE_CHARA ) { + count_chara++; + } + if( OBJECT_getType(objindex) == OBJTYPE_ITEM || OBJECT_getType(objindex) == OBJTYPE_GOLD ) { + count_item++; + } + } + } + if( count_item > 80 || count_chara > 80 ) { + CHAR_talkToCli( charaindex, -1, "这里已经太拥挤了,不能再丢了。", CHAR_COLORYELLOW ); + return FALSE; + } + } + +#endif + if( tofl == -1 ) { + for( i = 0 ; i < 7 ; i ++ ){ + dirx[i+2] = CHAR_getDX(CHAR_getInt(charaindex,CHAR_DIR) + i+1); + diry[i+2] = CHAR_getDY(CHAR_getInt(charaindex,CHAR_DIR) + i+1); + } + dirx[0] = CHAR_getDX(CHAR_getInt(charaindex,CHAR_DIR)); + diry[0] = CHAR_getDY(CHAR_getInt(charaindex,CHAR_DIR)); + dirx[1] = 0; + diry[1] = 0; + floor = CHAR_getInt( charaindex,CHAR_FLOOR ); + for( i = 0 ; i < 9 ; i ++ ){ + int x=CHAR_getInt(charaindex,CHAR_X)+dirx[i]; + int y=CHAR_getInt(charaindex,CHAR_Y)+diry[i]; + if( PET_isPutPoint( floor, x, y ) == TRUE ) { + break; + } + } + if( i == 9 ) i = 1; + x=CHAR_getInt(charaindex,CHAR_X)+dirx[i]; + y=CHAR_getInt(charaindex,CHAR_Y)+diry[i]; + }else { + if( MAP_walkAbleFromPoint( tofl,tox,toy, FALSE ) == FALSE ) { + print( "map walkable err %s:%d\n", __FILE__,__LINE__); + return FALSE; + } + floor = tofl; + x = tox; + y = toy; + } +#ifdef _MARKET_TRADE + if( MAP_TRADEPETDROP( charaindex, petindex, floor, x, y) == TRUE ) + return TRUE; +#endif + objindex = PET_dropPetAbsolute( petindex,floor,x,y, FALSE ); + if( objindex == -1 ) return FALSE; + + CHAR_setWorkInt( petindex,CHAR_WORKOBJINDEX,objindex ); + CHAR_setCharPet( charaindex, havepetindex, -1); + CHAR_setInt( petindex, CHAR_FLOOR, floor); + CHAR_setInt( petindex, CHAR_X, x); + CHAR_setInt( petindex, CHAR_Y, y); + CHAR_setInt( petindex, CHAR_PUTPETTIME, NowTime.tv_sec); + if( havepetindex == CHAR_getInt( charaindex, CHAR_DEFAULTPET)) { + int fd; + CHAR_setInt( charaindex, CHAR_DEFAULTPET, -1); + fd = getfdFromCharaIndex( charaindex); + lssproto_KS_send( fd, havepetindex, 0); + + } + CHAR_sendCToArroundCharacter( objindex); + + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + snprintf( szPet, sizeof( szPet ), "K%d", havepetindex ); + CHAR_sendStatusString( charaindex, szPet ); + } + return TRUE; +} + + +/*------------------------------------------------------------ + * 泫 矢永玄毛 仁 + * 娄醒 + * itemindex int 失奶 丞奶件犯永弁旦 + * floor int 白夫失ID + * x int x甄 + * y int y甄 + * net BOOL 生永玄伐□弁及仇午毛允月井升丹井 + * 忒曰袄 + * 岳 objindex + * 撩 -1 + ------------------------------------------------------------*/ +int PET_dropPetAbsolute( int petindex, int floor, int x, int y,BOOL net) +{ + Object object; + int objindex; + + if( !CHAR_CHECKINDEX(petindex) )return FALSE; + + object.type = OBJTYPE_CHARA; + object.index = petindex; + object.x = x; + object.y = y; + object.floor = floor; + + /* 左皮斥尼弁玄瓒 允月 */ + objindex = initObjectOne( &object ); + + /* 生永玄伐□弁白仿弘互凶匀化中月午五反允月 by ringo*/ + if( net ) + CHAR_sendWatchEvent( objindex,CHAR_ACTSTAND,NULL,0,TRUE); + + return objindex; +} + +BOOL PET_isPutPoint( int fl,int x, int y) +{ + OBJECT object; + if( MAP_walkAbleFromPoint( fl,x,y, FALSE ) == FALSE ) + return FALSE; + for( object=MAP_getTopObj(fl,x,y) ; + object ; + object = NEXT_OBJECT(object ) ) + { + int objindex = GET_OBJINDEX(object); + switch( OBJECT_getType(objindex) ){ + case OBJTYPE_NOUSE: + break; + case OBJTYPE_ITEM: + case OBJTYPE_GOLD: + case OBJTYPE_CHARA: + return FALSE; + break; + default: + break; + } + } + return TRUE; +} + +int PET_dropPet( int charaindex, int havepetindex) +{ + int petindex; + petindex = CHAR_getCharPet(charaindex,havepetindex); + if( !CHAR_CHECKINDEX( petindex )) return FALSE; + + if( _PET_dropPet( charaindex, havepetindex, -1,-1,-1) == TRUE ){ + LogPet( + CHAR_getChar( charaindex, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( charaindex, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "Drop(丢宠)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + return 1; + } + return 0; +} + +int PET_dropPetFLXY( int charaindex, int havepetindex, int fl, int x, int y) +{ + return _PET_dropPet( charaindex, havepetindex, fl,x,y); +} + +/*------------------------------------------------------------ + * 矢永玄迕及奶矛件玄楮醒毛本永玄仄化支月 + ------------------------------------------------------------*/ +int PET_initCharOneArray( Char *ch) +{ + int i; + char *tmp[CHAR_FUNCTABLENUM] = { + "", /* CHAR_INITFUNC */ + "", /* CHAR_WALKPREFUNC */ + "", /* CHAR_WALKPOSTFUNC */ + "", /* CHAR_PREOVERFUNC */ + "", /* CHAR_PREOVERFUNC */ + "core_PetWatch", /* CHAR_WATCHFUNC */ + "", /* CHAR_LOOPFUNC */ + "", /* CHAR_DYINGFUNC */ + "core_PetTalk", /* CHAR_TALKEDFUNC */ + "", /* CHAR_PREATTACKEDFUNC */ + "", /* CHAR_POSTATTACKEDFUNC */ + "", /* CHAR_OFFFUNC */ + "", /* CHAR_LOOKEDFUNC */ + "", /* CHAR_ITEMPUTFUNC */ + "", /* CHAR_SPECIALTALKEDFUNC */ + "", /* CHAR_WINDOWTALKEDFUNC */ +#ifdef _USER_CHARLOOPS + "", // CHAR_LOOPFUNCTEMP1, + "", // CHAR_LOOPFUNCTEMP2, + "", //CHAR_BATTLEPROPERTY, +#endif + }; + for( i = 0; i < CHAR_FUNCTABLENUM; i ++ ) { + strcpysafe( ch->charfunctable[i].string, + sizeof( ch->charfunctable[i]), + tmp[i]); + } + if( ch->data[CHAR_MAILMODE] != CHAR_PETMAIL_NONE ) { + strcpysafe( ch->charfunctable[CHAR_LOOPFUNC].string, + sizeof( ch->charfunctable[CHAR_LOOPFUNC]), "PETMAIL_Loop"); + + } +#ifdef _USER_CHARLOOPS + if( ch->data[CHAR_FUSIONBEIT] == 1 && + ch->data[CHAR_FUSIONRAISE] > 0 ) { + //andy_log +// print("init CHAR_LOOPFUNCTEMP1:%s \n", "PET_CheckIncubateLoop"); + + strcpysafe( ch->charfunctable[CHAR_LOOPFUNCTEMP1].string, + sizeof( ch->charfunctable[CHAR_LOOPFUNCTEMP1]), "PET_CheckIncubateLoop"); + ch->data[CHAR_LOOPINTERVAL] = 60000; + + ch->functable[CHAR_LOOPFUNCTEMP1] + = getFunctionPointerFromName( "PET_CheckIncubateLoop"); + +// CHAR_constructFunctable( petindex); + } +#endif + return( CHAR_initCharOneArray( ch)); +} + +int PET_createPetFromCharaIndex( int charaindex, int enemyindex) +{ + Char CharNew; + int newindex; + int havepetelement; + char szPet[128]; + int i; + + havepetelement = CHAR_getCharPetElement( charaindex); + if( havepetelement < 0 ) return -1; + memset( &CharNew, 0, sizeof( Char ) ); + if( !CHAR_getDefaultChar( &CharNew,31010 ) )return -1; + CharNew.data[CHAR_BASEBASEIMAGENUMBER] + = CharNew.data[CHAR_BASEIMAGENUMBER] = CHAR_getInt(enemyindex,CHAR_BASEIMAGENUMBER); + CharNew.data[CHAR_WHICHTYPE] = CHAR_TYPEPET; + CharNew.data[CHAR_HP] = CHAR_getInt(enemyindex, CHAR_HP); + CharNew.data[CHAR_MP] = CHAR_getInt(enemyindex, CHAR_MP); + CharNew.data[CHAR_MAXMP] = CHAR_getInt(enemyindex, CHAR_MAXMP); + CharNew.data[CHAR_VITAL] = CHAR_getInt(enemyindex, CHAR_VITAL); + CharNew.data[CHAR_STR] = CHAR_getInt(enemyindex, CHAR_STR); + CharNew.data[CHAR_TOUGH] = CHAR_getInt(enemyindex, CHAR_TOUGH); + CharNew.data[CHAR_DEX] = CHAR_getInt(enemyindex, CHAR_DEX); + CharNew.data[CHAR_LUCK] = CHAR_getInt(enemyindex, CHAR_LUCK); + CharNew.data[CHAR_FIREAT] = CHAR_getInt(enemyindex, CHAR_FIREAT); + CharNew.data[CHAR_WATERAT] = CHAR_getInt(enemyindex, CHAR_WATERAT); + CharNew.data[CHAR_EARTHAT] = CHAR_getInt(enemyindex, CHAR_EARTHAT); + CharNew.data[CHAR_WINDAT] = CHAR_getInt(enemyindex, CHAR_WINDAT); + //CharNew.data[CHAR_EXP] = CHAR_getInt(enemyindex, CHAR_EXP); + + CharNew.data[CHAR_SLOT] = CHAR_getInt(enemyindex, CHAR_SLOT); + CharNew.data[CHAR_MODAI] = CHAR_getInt(enemyindex, CHAR_MODAI); + CharNew.data[CHAR_LV] = CHAR_getInt(enemyindex, CHAR_LV); + CharNew.data[CHAR_POISON] = CHAR_getInt(enemyindex, CHAR_POISON); + CharNew.data[CHAR_PARALYSIS]= CHAR_getInt(enemyindex, CHAR_PARALYSIS); + CharNew.data[CHAR_SLEEP] = CHAR_getInt(enemyindex, CHAR_SLEEP); + CharNew.data[CHAR_STONE] = CHAR_getInt(enemyindex, CHAR_STONE); + CharNew.data[CHAR_DRUNK] = CHAR_getInt(enemyindex, CHAR_DRUNK); + CharNew.data[CHAR_CONFUSION]= CHAR_getInt(enemyindex, CHAR_CONFUSION); + CharNew.data[CHAR_RARE] = CHAR_getInt(enemyindex, CHAR_RARE); + CharNew.data[CHAR_PETRANK] = CHAR_getInt(enemyindex, CHAR_PETRANK); + CharNew.data[CHAR_PETID] = CHAR_getInt(enemyindex, CHAR_PETID); + CharNew.data[CHAR_CRITIAL] = CHAR_getInt(enemyindex, CHAR_CRITIAL); + CharNew.data[CHAR_COUNTER] = CHAR_getInt(enemyindex, CHAR_COUNTER); + CharNew.data[CHAR_PETMAILEFFECT] = RAND(0, PETMAIL_EFFECTMAX); + + for( i = 0; i < CHAR_MAXPETSKILLHAVE; i ++ ) { + CharNew.unionTable.indexOfPetskill[i] = CHAR_getPetSkill( enemyindex, i); + } + CharNew.data[CHAR_ALLOCPOINT] = CHAR_getInt(enemyindex, CHAR_ALLOCPOINT); + strcpysafe( CharNew.string[CHAR_NAME].string, + sizeof(CharNew.string[CHAR_NAME].string), + CHAR_getChar( enemyindex, CHAR_NAME) ); + newindex = PET_initCharOneArray( &CharNew ); + if( newindex < 0 ){ + return -1; + } + + CHAR_setMaxExpFromLevel( newindex, CHAR_getInt( enemyindex, CHAR_LV )); + CHAR_complianceParameter( newindex ); + CHAR_setWorkInt( newindex, CHAR_WORKPLAYERINDEX, charaindex); + CHAR_setCharPet( charaindex, havepetelement, newindex); + CHAR_setChar( newindex, CHAR_OWNERCDKEY, + CHAR_getChar( charaindex, CHAR_CDKEY)); + CHAR_setChar( newindex, CHAR_OWNERCHARANAME, + CHAR_getChar( charaindex, CHAR_NAME)); + snprintf( szPet, sizeof( szPet ), "K%d", havepetelement ); + CHAR_sendStatusString( charaindex, szPet ); + snprintf( szPet, sizeof( szPet ), "W%d", havepetelement ); + CHAR_sendStatusString( charaindex, szPet ); + + return newindex; + +} +BOOL PET_SelectBattleEntryPet( int charaindex, int petarray) +{ + int pindex; + /* 爵 反轮仁 仿弘匹仇木卞娄匀井井月第 岭丐曰 */ + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) return FALSE; + /* -1及桦宁反]-1卞仄化本永玄仄化蔽歹曰[*/ + if( petarray == -1 ) { + CHAR_setInt( charaindex, CHAR_DEFAULTPET, -1 ); + return TRUE; + } + if( !CHAR_CHECKPETINDEX( petarray)) return FALSE; + pindex = CHAR_getCharPet( charaindex, petarray ); + if( !CHAR_CHECKINDEX( pindex)) return FALSE; + + if( CHAR_getFlg( pindex, CHAR_ISDIE )) return FALSE; + + CHAR_setInt( charaindex, CHAR_DEFAULTPET, petarray ); + + return TRUE; +} + +// Robin 0707 petFollow +#if 1 +int PET_dropPetFollow( int charaindex, int havepetindex, int tofl, int tox, int toy) +{ + char szPet[128]; + int dirx[9],diry[9]; + int i; + int objindex=-1; + int floor,x,y; + int petindex; + + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) return FALSE; + petindex = CHAR_getCharPet(charaindex,havepetindex); + if( petindex == -1 ) return FALSE; + if( !CHAR_CHECKINDEX( charaindex ) )return FALSE; + if( CHAR_CHECKINDEX( petindex) == FALSE ) return FALSE; + + if (CHAR_getInt(petindex, CHAR_PETFAMILY) == 1){ + CHAR_talkToCli(charaindex, -1, "家族守护兽无法丢出!", CHAR_COLORYELLOW); + return FALSE; + } + if (CHAR_getInt(charaindex, CHAR_RIDEPET) == havepetindex){ + CHAR_talkToCli(charaindex, -1, "骑乘中的宠物无法跟随!", CHAR_COLORYELLOW); + return FALSE; + } + if( tofl == -1 ) { + for( i = 0 ; i < 7 ; i ++ ){ + dirx[i+2] = CHAR_getDX(CHAR_getInt(charaindex,CHAR_DIR) + i+1); + diry[i+2] = CHAR_getDY(CHAR_getInt(charaindex,CHAR_DIR) + i+1); + } + dirx[0] = CHAR_getDX(CHAR_getInt(charaindex,CHAR_DIR)); + diry[0] = CHAR_getDY(CHAR_getInt(charaindex,CHAR_DIR)); + dirx[1] = 0; + diry[1] = 0; + + floor = CHAR_getInt( charaindex,CHAR_FLOOR ); + for( i = 0 ; i < 9 ; i ++ ){ + int x=CHAR_getInt(charaindex,CHAR_X)+dirx[i]; + int y=CHAR_getInt(charaindex,CHAR_Y)+diry[i]; + if( PET_isPutPoint( floor, x, y ) == TRUE ) { + break; + } + } + if( i == 9 ) i = 1; + + x=CHAR_getInt(charaindex,CHAR_X)+dirx[i]; + y=CHAR_getInt(charaindex,CHAR_Y)+diry[i]; + } + else { + if( MAP_walkAbleFromPoint( tofl,tox,toy, FALSE ) == FALSE ) { + print( "map walkable err %s:%d\n", __FILE__,__LINE__); + return FALSE; + } + floor = tofl; + x = tox; + y = toy; + } + + objindex = PET_dropPetAbsolute( petindex,floor,x,y, FALSE ); + if( objindex == -1 ) return FALSE; + + CHAR_setWorkInt( petindex,CHAR_WORKOBJINDEX,objindex ); + CHAR_setCharPet( charaindex, havepetindex, -1); + CHAR_setInt( petindex, CHAR_FLOOR, floor); + CHAR_setInt( petindex, CHAR_X, x); + CHAR_setInt( petindex, CHAR_Y, y); + CHAR_setInt( petindex, CHAR_PUTPETTIME, NowTime.tv_sec); + if( havepetindex == CHAR_getInt( charaindex, CHAR_DEFAULTPET)) { + int fd; + CHAR_setInt( charaindex, CHAR_DEFAULTPET, -1); + fd = getfdFromCharaIndex( charaindex); + lssproto_KS_send( fd, havepetindex, 0); + + } + CHAR_sendCToArroundCharacter( objindex); + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + snprintf( szPet, sizeof( szPet ), "K%d", havepetindex ); + CHAR_sendStatusString( charaindex, szPet ); + } + + CHAR_setWorkInt( charaindex, CHAR_WORKPETFOLLOW, petindex); + CHAR_setWorkInt( petindex, CHAR_WORKPETFOLLOWMODE, CHAR_PETFOLLOW_NOW); + CHAR_setWorkInt( petindex, CHAR_WORKPETFOLLOWCOUNT, 0); + CHAR_setInt( petindex, CHAR_PUTPETTIME, (int)(NowTime.tv_sec)); + CHAR_setInt( petindex, CHAR_WORKPLAYERINDEX, charaindex); + LogPet( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "Follow(溜宠)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) + ); + return 1; +} +#endif + +BOOL PET_getBaseForAllocpoint( int toindex, int *work) +{ + int LevelUpPoint=0; + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPET) + return FALSE; + LevelUpPoint = CHAR_getInt( toindex, CHAR_ALLOCPOINT ); + work[3] =(( LevelUpPoint >> 24 ) & 0xFF); + work[0] = (( LevelUpPoint >> 16 ) & 0xFF); + work[1] = (( LevelUpPoint >> 8 ) & 0xFF); + work[2] = (( LevelUpPoint >> 0 ) & 0xFF); + return TRUE; +} + +void PET_showEditBaseMsg( int charaindex, int toindex, int itemindex, int *work) +{ + int i, maxnums = 6000; + char buf1[256]; + char buf2[][32]={"腕力成长率","耐久力成长率","速度成长率","体力成长率","能力"}; + char buf3[][32]={"大幅提高","略为提高","略为减少"}; + + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPET) + return; + memset( buf1, 0, sizeof( buf1)); + + for( i=0; i<4; i++) { + int type = ITEM_getInt( itemindex, (ITEM_MODIFYATTACK + i)); + print(" [%d]%d+%d ", i, work[i], type); + work[i] += type; + strcpy( buf1,"\0"); + if( work[i] > maxnums ) { + sprintf(buf1,"%s 已经达到最高了。", buf2[i]); + work[i] = maxnums; + }else if( work[i] < 0 ) { + sprintf(buf1,"%s 已经为零了。", buf2[i]); + work[i] = 0; + }else { + if( type > 0 ) { + if( type > 2 ) { + sprintf(buf1,"%s %s %s", buf2[i], buf3[0], "。"); + }else { + sprintf(buf1,"%s %s %s", buf2[i], buf3[1], "。"); + } + }else if( type < 0 ){ + sprintf(buf1,"%s %s %s", buf2[i], buf3[2], "。"); + } + } + if( strcmp( buf1, "\0")) { + CHAR_talkToCli( charaindex, toindex, buf1, CHAR_COLORYELLOW); + } + } +} + +#ifdef _PET_EVOLUTION +BOOL PET_getBaseAndSkill( int charaindex, int baseindex, int *base, int *skill, int flg) +{ + int i; + if( !CHAR_CHECKINDEX( baseindex)) return FALSE; + if( base != NULL ) { + int levelup = CHAR_getInt( baseindex, CHAR_ALLOCPOINT); + base[0] = ((levelup>>24) & 0xFF); + base[1] = ((levelup>>16) & 0xFF); + base[2] = ((levelup>> 8) & 0xFF); + base[3] = ((levelup>> 0) & 0xFF); + } + + if( skill != NULL ) { + for( i=0; i= CHAR_MAXPETHAVE){ + return FALSE; + }else { + char szPet[256]; + char msgbuf[256]; + CHAR_setCharPet( charaindex, i, -1); + snprintf( szPet, sizeof( szPet ), "K%d", i); + CHAR_sendStatusString( charaindex, szPet ); + + snprintf( msgbuf,sizeof( msgbuf), "交出%s。", CHAR_getChar( petindex, CHAR_NAME)); + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORYELLOW); + CHAR_endCharOneArray( petindex ); + } + return TRUE; +} + + diff --git a/gmsv/char/pet_event.c b/gmsv/char/pet_event.c new file mode 100644 index 0000000..6bc80c1 --- /dev/null +++ b/gmsv/char/pet_event.c @@ -0,0 +1,938 @@ +#include "version.h" +#include +#include + +#include "common.h" +#include "object.h" +#include "char_base.h" +#include "char.h" +#include "configfile.h" +#include "handletime.h" +#include "pet_event.h" +#include "npcutil.h" +#include "log.h" +#include "lssproto_serv.h" +// Arminius 8.14 pet talk +#include +#include "npc_exchangeman.h" +#include "npc_eventaction.h" + +#ifdef _MARKET_TRADE +#include "item_trade.h" +#endif + + + + + +#ifdef _PET_TALK +//BOOL PetTalk_CheckFree( int meindex, int toindex, char *buf); +BOOL PetTalk_CheckFree( int meindex, int talker, char *buf); + +BOOL PetTalk_BSCheck(int meindex,int talker,char* buf); +BOOL PetTalk_FreeIfCheck(int meindex,int talker,char* buf,int kosuu,int flg, int temp); +BOOL PetTalk_WarpManReduce(int meindex,int talker,char *buf); +BOOL PetTalk_BigSmallLastCheck(int point1,int mypoint,int flg); +BOOL PetTalk_CheckTrans(int meindex,int talker,int trans,int flg); +BOOL PetTalk_LevelCheck(int meindex,int talker,int level,int flg); +BOOL PetTalk_CheckMyPet( int meindex, int talker, int petLv, int flg, int petid); +BOOL PetTalk_ItemCheck(int meindex,int talker,int itemNo,int flg); +BOOL PetTalk_CheckMyType( int meindex, int toindex, int kosuu, int flg, int Type ); +BOOL PetTalk_CheckPetEvent( int meindex, int toindex, char *buf); +void PetTalk_RequestMain(int meindex,int talker,char *buf); +BOOL PetTalk_AddItem(int meindex, int talker, char *buf); +BOOL PetTalk_DelItem(int meindex,int talker,char *buf); +BOOL PetTalk_RunEvent( int meindex, int talker, char *buf); +BOOL PetTalk_CheckMyFloor( int meindex, int talker, char *buf, int flg); +#ifdef _PET_TALKBBI +BOOL PET_CheckPlayerBBI( int meindex, int charindex, int BBI, int flg); +#endif +#ifdef _PET_TALKPRO +#else +char *Pet_TalkGetFunStr( char *temp , char *buf, int len) +{ + char filename[56]; + char pathfile[128]; + char talkfun[ 10240]; + char buf1[256],buf2[256],buf3[256]; + FILE *petarg; + char *cStr=NULL; + int talkNo=1,mark=1; + char line[4096]; + BOOL find=FALSE; + talkfun[0] ='\0'; + + while( getStringFromIndexWithDelim( pettalktext,"&",talkNo, buf1, sizeof( buf1) ) != FALSE){ + talkNo++; + if( NPC_Util_GetStrFromStrWithDelim( buf1, "PETTEMPNO", buf2, sizeof( buf2)) == NULL ) + continue; + mark=2; + strcpy( filename,"\0"); + while( getStringFromIndexWithDelim( buf2,",", mark,buf3,sizeof( buf3)) != FALSE ) { + mark ++; + if( !strcmp( buf3, temp)) { + print("\n buf2=%s",buf2); + if( getStringFromIndexWithDelim( buf2,",", 1,filename,sizeof( filename)) == FALSE ) + return NULL; + find = TRUE; + break; + } + } + if( find == TRUE ) + break; + } + if( !strcmp( filename, "\0") ) + return NULL; + + sprintf( pathfile, "%s/pettalk/%s", getNpcdir(), filename); + petarg = fopen( pathfile , "r" ); + if( petarg != NULL ) { + while( fgets( line, sizeof( line), petarg ) ) { + if( strlen( talkfun) != 0 ) { + if( talkfun[strlen( talkfun) -1] != '|' ) { + strcatsafe( talkfun, sizeof( talkfun), "|"); + } + } + chompex( line); + strcatsafe( talkfun, sizeof( talkfun ), line); + } + fclose( petarg); + }else { + return NULL; + } + talkNo = 1; + while( getStringFromIndexWithDelim( talkfun,"}",talkNo, buf, len) != FALSE) { + talkNo++; + if( NPC_Util_GetStrFromStrWithDelim( buf, "PETTEMPNO", buf2, sizeof( buf2)) == NULL ) + continue; + if( !strcmp( temp, buf2) ) { + cStr = buf; + break; + } + } + return( cStr); +} +#endif +void PET_Talkfunc( int meindex, int talkerindex, char *msg, int color) +{ + char buf2[1024], buf3[256]; + + char TalkType[][16]={"TALKRUN","EVENTRUN","BOTH"}; + char AllTalk[PETTALK_MAXID][1024]; + int Type=0,j,i; + int talkNo=0; + BOOL FREEs=FALSE; + int buttontype = 0; + int windowtype = 0; +#ifdef _PET_TALKPRO + int tPage=-1; +#else + int petid=-1; + char tempNo[32], buf1[10240]; +#endif + + int fd = getfdFromCharaIndex( talkerindex); +#define RAND(x,y) ((x-1)+1+ (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) ) + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + buttontype = WINDOW_BUTTONTYPE_OK; + + if( NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) { + if( NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) + return; + } + for( i = 0 ; i < 5 ; i++ ) { + strcpy( AllTalk[i], "\0" ); + } + +#ifdef _PET_TALKPRO + for( i=0;i=0 && pettalktext[i].ID == CHAR_getInt(meindex, CHAR_PETID) ) { + if( strcmp( pettalktext[i].DATA, "\0") && strlen( pettalktext[i].DATA) > 0 ) { + //snprintf( buf1, sizeof(buf1), pettalktext[i].DATA); + tPage=i; + break; + } + } + } + if( i == PETTALK_MAXID ) + return; +#else + sprintf(tempNo,"%d", CHAR_getInt(meindex, CHAR_PETID)); + petid = CHAR_getInt(meindex, CHAR_PETID); + if( Pet_TalkGetFunStr( tempNo , buf1 , sizeof( buf1) ) == NULL ) { + return; + } +#endif + if( CHAR_getInt( meindex, CHAR_LV ) >= CHAR_getInt( meindex, CHAR_LIMITLEVEL) ) { + Type = 1; + } + //设定为非主人不得与PET互动 + if( strcmp( CHAR_getChar( meindex, CHAR_OWNERCDKEY), CHAR_getChar( talkerindex, CHAR_CDKEY) ) || + strcmp( CHAR_getChar( meindex, CHAR_OWNERCHARANAME), CHAR_getChar( talkerindex, CHAR_NAME) )){ +#ifdef _PET_TALKPRO + if( NPC_Util_GetStrFromStrWithDelim( pettalktext[tPage].DATA, "NoPlayerMsg", buf3, sizeof( buf3)) != NULL ) { +#else + if( NPC_Util_GetStrFromStrWithDelim( buf1, "NoPlayerMsg", buf3, sizeof( buf3)) != NULL ) { +#endif + }else { + sprintf(buf3,"陌生人?我不认识你呀!你是坏人!"); + } + CHAR_talkToCli( talkerindex, meindex, buf3, color); + return; + } + j=0; + +#ifdef _PET_TALKPRO + while( getStringFromIndexWithDelim( pettalktext[tPage].DATA,"OVER",talkNo, buf2, sizeof( buf2) ) != FALSE){ +#else + while( getStringFromIndexWithDelim( buf1,"OVER",talkNo, buf2, sizeof( buf2) ) != FALSE){ +#endif + talkNo++; + if( ( strstr( buf2, TalkType[Type]) == NULL ) && ( strstr( buf2, TalkType[2]) == NULL ) )continue; + if( NPC_Util_GetStrFromStrWithDelim( buf2, "FLOOR", buf3, sizeof( buf3)) != NULL ) {//判断房间号 + if( PetTalk_CheckMyFloor( meindex, talkerindex, buf3, 0) == FALSE )continue; + } + if( NPC_Util_GetStrFromStrWithDelim( buf2, "PET", buf3, sizeof( buf3)) != NULL ) {//判断宠物FREE条件 + if( PetTalk_CheckFree( meindex, meindex, buf3) != TRUE ) continue; + } + if( NPC_Util_GetStrFromStrWithDelim( buf2, "FREE", buf3, sizeof( buf3) ) == NULL)continue; + if( NPC_ActionPassCheck( meindex, talkerindex, buf3) == FALSE ) continue;//判断玩家FREE条件 + +// if( ActionNpc_CheckFree( meindex, talkerindex, buf2, 0) == FALSE ) continue; + + if( PetTalk_CheckPetEvent( meindex, talkerindex, buf2) == FALSE )continue; + FREEs = TRUE; //条件成立 + strcpy( AllTalk[j++], buf2 ); + if( j > PETTALK_MAXID-1 ) break; + } + talkNo = 0; + + if( FREEs == FALSE) { //如果全部条件都不成立 + j=0; +#ifdef _PET_TALKPRO + while( getStringFromIndexWithDelim( pettalktext[tPage].DATA,"OVER",talkNo, buf2, sizeof( buf2) ) != FALSE ){ +#else + while( getStringFromIndexWithDelim( buf1,"OVER",talkNo, buf2, sizeof( buf2) ) != FALSE ){ +#endif + talkNo ++; + if( strstr( buf2, "OTHER") == NULL ) continue; + if( NPC_Util_GetStrFromStrWithDelim( buf2, "TalkMsg", buf3, sizeof( buf3)) == NULL) continue; + while( getStringFromIndexWithDelim( buf3,",",j+1, AllTalk[j], sizeof( AllTalk[j]) ) != FALSE ){ + j++; + } + break; + } + } + + if( j > 0 ) { + strcpy( buf2, AllTalk[ RAND( 0, (j-1) ) ] ); + if( PetTalk_RunEvent( meindex, talkerindex, buf2) == FALSE ) { + sprintf( buf3,"....!"); + CHAR_talkToCli( talkerindex, meindex, buf3, color); + return; + } + if( NPC_Util_GetStrFromStrWithDelim( buf2, "TalkMsg", buf3, sizeof( buf3)) == NULL) { + //sprintf( buf3,"主人,我们去逛逛吧!"); + strcpy( buf3, buf2); + } + + lssproto_WN_send( fd, windowtype, buttontype, 0, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), buf3 ); + } + +} + +BOOL PetTalk_CheckMyFloor( int meindex, int talker, char *buf, int flg) { + char buf1[16]; + int Myfloor=-1; + Myfloor = CHAR_getInt( talker, CHAR_FLOOR); + if( strstr( buf, "!") != NULL ) { + getStringFromIndexWithDelim( buf,"!", 2, buf1, sizeof( buf1) ); + if( Myfloor == atoi( buf1) ) { + return FALSE; + } + }else { + if( Myfloor != atoi( buf) ) { + return FALSE; + } + } + return TRUE; +} + +BOOL PetTalk_RunEvent( int meindex, int talker, char *buf) +{ + char buf1[256]; + int LimitLevel = -1; + + if( Action_RunDoEventAction( meindex, talker, buf) == FALSE ) + return FALSE; + + if( NPC_Util_GetStrFromStrWithDelim( buf, "RandItem", buf1, sizeof( buf1)) != NULL ){ + if( RAND( 0, 10) > 9 ) { + PetTalk_AddItem( meindex, talker, buf1); + }else { + return FALSE; + } + } + if( NPC_Util_GetStrFromStrWithDelim( buf, "LimitLevel", buf1, sizeof( buf1)) != NULL ){ + LimitLevel = atoi( buf1); + CHAR_setInt( meindex, CHAR_LIMITLEVEL, LimitLevel); + } + return TRUE; + +} + +BOOL PetTalk_DelItem(int meindex,int talker,char *buf) +{ + + int i = 1, j = 1,k = 1; + char buff3[128]; + char buf2[32]; + int itemindex; + + while( getStringFromIndexWithDelim(buf , "," , k, buff3, sizeof(buff3)) !=FALSE ) { + k++; + if(strstr(buff3,"*")!=NULL){ + int itemno; + int kosuu; + int id; + int cnt=0; + + getStringFromIndexWithDelim(buff3,"*",1,buf2,sizeof(buf2)); + itemno = atoi(buf2); + getStringFromIndexWithDelim(buff3,"*",2,buf2,sizeof(buf2)); + kosuu = atoi(buf2); + + for( i =0 ; i < CHAR_MAXITEMHAVE ; i++ ){ + itemindex=CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX(itemindex) ){ + id=ITEM_getInt(itemindex ,ITEM_ID ); + if(itemno==id){ + cnt++; + + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), /* 失奶 丞 寞 */ +#endif + "WarpManDelItem(NPC收道具後传至某点)", + CHAR_getInt( talker, CHAR_FLOOR), + CHAR_getInt( talker, CHAR_X ), + CHAR_getInt( talker, CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + + ); + + CHAR_DelItem( talker, i); + if(cnt == kosuu){ + break; + } + } + } + } + }else{ + /*--蓟氏分 寞及失奶 丞毛蓟请---*/ + for( j = 0 ; j < CHAR_MAXITEMHAVE ; j++){ + itemindex = CHAR_getItemIndex( talker ,j); + + if( ITEM_CHECKINDEX(itemindex) ){ + if( atoi( buff3) == ITEM_getInt(itemindex,ITEM_ID)){ + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), /* 失奶 丞 寞 */ +#endif + "WarpManDelItem(NPC收道具後传至某点)", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + CHAR_DelItem( talker, j); + } + } + } + } + } + + return TRUE; +} + +BOOL PetTalk_AddItem(int meindex, int talker, char *buf) +{ + int itemID,k=1,itemindex=-1; + int spaceNum=5,i; + char buff3[256], msgbuf[64], token[256]; + int ret; + + while( getStringFromIndexWithDelim(buf , "," , k, buff3, sizeof(buff3)) !=FALSE ){ + k++; + for( i = spaceNum ; i < CHAR_MAXITEMHAVE ; i++ ){ + itemindex=CHAR_getItemIndex( talker , i ); + if( itemindex == -1 ) { + spaceNum = i+1; + break; + } + } + if( i == CHAR_MAXITEMHAVE ) { + snprintf( msgbuf,sizeof( msgbuf), "主人,你的物品栏已经满了!!"); + CHAR_talkToCli( talker, meindex, msgbuf, CHAR_COLORWHITE); + return FALSE; + } + } + k=1; + while( getStringFromIndexWithDelim(buf , "," , k, buff3, sizeof(buff3)) !=FALSE ){ + k++; + itemID = atoi( buff3); + if( itemID ) + itemindex = ITEM_makeItemAndRegist( itemID); + if(itemindex == -1) + continue; + ret = CHAR_addItemSpecificItemIndex( talker, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + ITEM_endExistItemsOne( itemindex); + print ("\n ret error!!"); + return FALSE; + } + sprintf( token,"拿到%s",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1,token,CHAR_COLORWHITE); + + CHAR_sendItemDataOne( talker, ret); + + } + return TRUE; +} + +BOOL PetTalk_CheckPetEvent( int meindex, int toindex, char *buf) +{ + char buf1[256],buf2[256]; + int k = 0; + + if( NPC_Util_GetStrFromStrWithDelim( buf, "EndSetFlg", buf1,sizeof( buf1) ) != NULL ) { + k=1; + while( getStringFromIndexWithDelim(buf1 , "," ,k, buf2, sizeof(buf2) ) != FALSE ){ + k++; + NPC_EventSetFlg( toindex, atoi( buf2)); + } + } + if( NPC_Util_GetStrFromStrWithDelim( buf, "NowSetFlg", buf1, sizeof( buf1)) != NULL) { + k=1 ; + while(getStringFromIndexWithDelim(buf1 , "," , k, buf2, sizeof(buf2))!= FALSE ){ + k++; + NPC_NowEventSetFlg( toindex, atoi( buf2)); + } + } + return TRUE; +} + +void PetTalk_RequestMain(int meindex,int talker,char *buf) +{ + int shiftbit; + char buf2[128]; + if( NPC_Util_GetStrFromStrWithDelim( buf,"EventNo", buf2,sizeof( buf2) ) == NULL ) { + print("\n pet_event.c err:NOT FIND [EventNo] !!"); + return; + } + shiftbit = atoi( buf2); + if( NPC_NowEventCheckFlg( talker, shiftbit) != TRUE ) { + NPC_NowEventSetFlg( talker, shiftbit); + } +} + +BOOL PetTalk_CheckFree( int meindex, int talker, 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(PetTalk_BSCheck(meindex,talker,buff3)==FALSE) { + loop=1; + break; + } + } + if(loop==0) { + CHAR_setWorkInt( talker, CHAR_WORKWARPCHECK, TRUE ); + return TRUE; + } + }else{ + if( PetTalk_BSCheck( meindex, talker, buff2) == TRUE ){ + CHAR_setWorkInt( talker, CHAR_WORKWARPCHECK, TRUE ); + return TRUE; + } + } + } + CHAR_setWorkInt( talker, CHAR_WORKWARPCHECK, FALSE ); + return FALSE; +} + +BOOL PetTalk_BSCheck(int meindex,int talker,char* buf) +{ + char buff2[128]; + int kosuu,temp=-1,flg=0; + char buff1[128],buff3[128]; + if(strstr( buf, "-") != NULL) { + //buff3为抓宠物ID + getStringFromIndexWithDelim( buf, "-", 2, buff3, sizeof(buff3)); + temp = atoi( buff3); + getStringFromIndexWithDelim( buf, "-", 1, buff1, sizeof(buff1)); + strcpy( buf, buff1); + } + if(strstr( buf, "<") != NULL){ + getStringFromIndexWithDelim( buf, "<", 2, buff2, sizeof(buff2)); + kosuu = atoi( buff2); + getStringFromIndexWithDelim( buf, "<", 1, buff2, sizeof(buff2)); + + if(PetTalk_FreeIfCheck( meindex, talker, buff2, kosuu, 1, temp)==TRUE){ + return TRUE; + } + }else if(strstr( buf, ">") != NULL){ + getStringFromIndexWithDelim( buf, ">", 2, buff2, sizeof(buff2)); + kosuu = atoi(buff2); + getStringFromIndexWithDelim( buf, ">" ,1, buff2, sizeof(buff2)); + + if(PetTalk_FreeIfCheck( meindex, talker, buff2, kosuu, 2, temp)==TRUE){ + return TRUE; + } + }else if(strstr( buf, "!" ) != NULL){ + getStringFromIndexWithDelim( buf, "!=", 2, buff2, sizeof(buff2)); + kosuu = atoi( buff2); + getStringFromIndexWithDelim( buf, "!=", 1, buff2, sizeof(buff2)); + if(PetTalk_FreeIfCheck( meindex, talker, buff2, kosuu, 0, temp) == TRUE){ + return FALSE; + }else{ + return TRUE; + } + + }else if(strstr( buf, "=") != NULL){ + getStringFromIndexWithDelim( buf, "=", 2, buff2, sizeof(buff2)); + kosuu = atoi( buff2); + getStringFromIndexWithDelim( buf, "=", 1, buff2, sizeof(buff2)); + + if( strstr( buf, "PET")) { + flg = 3; + } + if(strstr( buf, "*") != NULL){ + if( PetTalk_WarpManReduce( meindex, talker, buf)==TRUE){ + return TRUE; + } + }else if(PetTalk_FreeIfCheck( meindex, talker, buff2, kosuu, flg, temp)==TRUE){ + return TRUE; + } + } + return FALSE; +} + +BOOL PetTalk_FreeIfCheck(int meindex,int talker,char* buf,int kosuu,int flg, int temp) +{ + int Type = -1; + if(strcmp(buf,"LV")==0){ + if(PetTalk_LevelCheck(meindex,talker,kosuu,flg)==TRUE){ + return TRUE; + } + } + + if( strcmp( buf, "TRANS") == 0 ) { + if( PetTalk_CheckTrans( meindex, talker, kosuu, flg) == TRUE ) + return TRUE; + } + if( strcmp( buf, "PET") == 0 ) { + if( temp > 0 ) { + if( PetTalk_CheckMyPet( meindex, talker, kosuu, flg, temp) == TRUE ) + return TRUE; + }else + return FALSE; + } + if(strcmp( buf, "ITEM")==0){ + if(PetTalk_ItemCheck(meindex,talker,kosuu,flg)==TRUE){ + return TRUE; + } + } + if(strcmp( buf, "ENDEV")==0){ + if(NPC_EventCheckFlg( talker, kosuu)==TRUE){ + return TRUE; + } + } + if(strcmp( buf, "NOWEV")==0){ + if(NPC_NowEventCheckFlg( talker, kosuu)==TRUE){ + return TRUE; + } + } + if(strcmp( buf, "HP" ) == 0 ) { + Type = 0; + if( PetTalk_CheckMyType( meindex, talker, kosuu, flg, Type ) == TRUE ) { + return TRUE; + } + } +#ifdef _PET_TALKBBI + if(strcmp( buf, "BBI" ) == 0 ) { + if( PET_CheckPlayerBBI( meindex, talker, kosuu, flg)== TRUE) { + return TRUE; + } + } +#endif + return FALSE; +} +BOOL PetTalk_CheckMyType( int meindex, int toindex, int kosuu, int flg, int Type ) { + int MyType=0,MyMaxType=0; + switch( Type ) { + case 0: //HP + MyType = CHAR_getInt( toindex, CHAR_HP); + MyMaxType = CHAR_getWorkInt( toindex, CHAR_WORKMAXHP); + MyMaxType = (MyMaxType * kosuu )/ 100; + if( PetTalk_BigSmallLastCheck( MyMaxType, MyType , flg ) == TRUE ) { + return TRUE; + } + break; + } + return FALSE; +} + +BOOL PetTalk_WarpManReduce(int meindex,int talker,char *buf) +{ + char buf2[512]; + char buf3[256]; + int id=0; + int i; + int itemindex; + int itemno; + int kosuu; + int cnt=0; + + getStringFromIndexWithDelim(buf,"=",2,buf2,sizeof(buf2)); + getStringFromIndexWithDelim(buf2,"*",1,buf3,sizeof(buf3)); + itemno = atoi(buf3); + getStringFromIndexWithDelim(buf2,"*",2,buf3,sizeof(buf3)); + kosuu = atoi(buf3); + for( i=0 ; i < CHAR_MAXITEMHAVE;i++ ){ + itemindex=CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX(itemindex) ){ + id=ITEM_getInt(itemindex ,ITEM_ID ); + if(itemno==id){ + cnt++; + if(cnt==kosuu){ + return TRUE; + } + } + } + } + return FALSE; +} + +BOOL PetTalk_LevelCheck(int meindex,int talker,int level,int flg) +{ + int mylevel; + mylevel=CHAR_getInt(talker,CHAR_LV); + if(PetTalk_BigSmallLastCheck(level,mylevel,flg)==TRUE) { + return TRUE; + } + return FALSE; +} + +BOOL PetTalk_CheckTrans(int meindex,int talker,int trans,int flg) +{ + int myTrans; + myTrans=CHAR_getInt(talker, CHAR_TRANSMIGRATION); + if( PetTalk_BigSmallLastCheck( trans, myTrans, flg ) == TRUE ) { + return TRUE; + } + return FALSE; +} + +BOOL PetTalk_CheckMyPet( int meindex, int talker, int petLv, int flg, int petid) +{ + int petsel,petindex=-1; + + for(petsel=0 ; petsel < CHAR_MAXPETHAVE ; petsel++) { + petindex = CHAR_getCharPet( talker, petsel); + if( petindex == -1 ) + continue; + if(CHAR_getInt( petindex, CHAR_PETID) != petid ) + continue; + break; + } + if( petsel == CHAR_MAXPETHAVE ) { + return FALSE; + }else { //找到条件宠 + if( PetTalk_BigSmallLastCheck( petLv, CHAR_getInt( petindex, CHAR_LV), flg ) == TRUE ) + return TRUE; + } + return FALSE; +} + +BOOL PetTalk_ItemCheck(int meindex,int talker,int itemNo,int flg) +{ + int i; + int itemindex=-1; + int id; + for( i=0;i point1) { + return TRUE; + } + } + return FALSE; +} +#else +void PET_Talkfunc( int meindex, int talkerindex, char *msg, int color) +{ + print("\n PET_Talkfunc(...) return; "); + return; +} +#endif + +void PET_CleanFreePetAll() +{ + int objindex; + int objmaxnum = OBJECT_getNum(); + + for( objindex=0; objindex= (petputtime + 60*60) ) { + int ownerindex = CHAR_getWorkInt( petindex, CHAR_WORKPLAYERINDEX); + if( CHAR_CHECKINDEX( ownerindex) ){ + if( CHAR_pickupFollowPet( ownerindex, petindex ) ) { + return; + } + CHAR_talkToCli( ownerindex, -1, "溜宠太久,宠物走失了!!", CHAR_COLORYELLOW ); + } +#ifdef _PET_LOSTPET + CHAR_CharSaveLostPet( petindex, 1); + LogPet( + "系统", + "Watchfunc", + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "timeout_lost(系统扣留-溜宠自由宠)", + CHAR_getInt( petindex, CHAR_FLOOR), + CHAR_getInt( petindex,CHAR_X ), + CHAR_getInt( petindex,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + print("系统扣留-溜宠自由宠:%s\n", CHAR_getUseName( petindex)); + CHAR_CharaDelete( petindex); +#else + CHAR_setInt( petindex, CHAR_PUTPETTIME, NowTime.tv_sec); + CHAR_setWorkInt( petindex, CHAR_WORKPETFOLLOWMODE, CHAR_PETFOLLOW_NONE); + LogPet( + CHAR_getChar( pindex, CHAR_NAME ), + CHAR_getChar( pindex, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "timeout_lost(溜宠太久,宠物走失))", + CHAR_getInt( pindex,CHAR_FLOOR), + CHAR_getInt( pindex,CHAR_X ), + CHAR_getInt( pindex,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14 + + ); +#endif + return; + } + + }else{ + PET_CHECKFreePetIsIt( petindex); + } +#ifdef _MARKET_TRADE + } +#endif + if( CHAR_getInt( petindex, CHAR_MAILMODE) == CHAR_PETMAIL_IDLE3 || + CHAR_getInt( petindex, CHAR_MAILMODE) == CHAR_PETMAIL_IDLE2){ + if( act == CHAR_ACTATTACK) { + if( NPC_Util_isFaceToChara( pindex,petindex,1 ) == TRUE ) { + int action[2] = { CHAR_ACTDAMAGE, CHAR_ACTGUARD}; + CHAR_sendWatchEvent( objmeindex, action[RAND(0,1)], NULL,0,FALSE); + CHAR_setWorkInt( petindex, CHAR_WORKACTION, act); + } + } + }else if( CHAR_getInt( petindex, CHAR_MAILMODE) != CHAR_PETMAIL_NONE) { + ; + }else if( CHAR_getWorkInt( petindex, CHAR_WORKFIXAI) >= 100 ) { + int workpindex = CHAR_getWorkInt( petindex, CHAR_WORKPLAYERINDEX); + if( act == CHAR_ACTWALK && CHAR_CHECKINDEX( workpindex) && workpindex == pindex ){ + dir = NPC_Util_GetDirCharToChar( petindex, pindex, 0); + if( dir != -1 ) { + if( CHAR_getInt( petindex, CHAR_DIR) != dir ) { + CHAR_setInt( petindex, CHAR_DIR, dir); + CHAR_sendWatchEvent( CHAR_getWorkInt( petindex, CHAR_WORKOBJINDEX), + CHAR_ACTTURN,NULL,0,TRUE); + } + } + }else if( NPC_Util_isFaceToFace( petindex, pindex, 2 ) == TRUE ) { + switch( act) { + case CHAR_ACTATTACK: + case CHAR_ACTDAMAGE: + case CHAR_ACTDOWN: + case CHAR_ACTSTAND: + case CHAR_ACTACTIONWALK: + case CHAR_ACTGUARD: + case CHAR_ACTACTIONSTAND: + CHAR_sendWatchEvent( objmeindex, act, NULL,0,FALSE); + CHAR_setWorkInt( petindex, CHAR_WORKACTION, act); + break; + default: + break; + } + } + }else { +/* +#ifdef _MARKET_TRADE + if( CHAR_getWorkInt( petindex, CHAR_WORKTRADETYP) != TRADETYPE_SELL) { +#endif + if( CHAR_getWorkInt( petindex, CHAR_WORKPETFOLLOWMODE) != CHAR_PETFOLLOW_NOW ){ + if( RAND(0,30) == 1 ) { + CHAR_walk( petindex,RAND( 0,7),0); + } + } +#ifdef _MARKET_TRADE + } +#endif +*/ + } + return; +} + +#ifdef _PET_TALKBBI +BOOL PET_CheckPlayerBBI( int meindex, int charindex, int BBI, int flg) +{ + int MyBBI; + if( !CHAR_CHECKINDEX( charindex)) + return FALSE; + if( BBI < 0 ) + return FALSE; + MyBBI = CHAR_getInt( charindex, CHAR_BASEIMAGENUMBER); + + if(flg==0){ + if(BBI==MyBBI) + return TRUE; + }else if(flg==1){ + if(BBI < MyBBI) + return TRUE; + }else if(flg==2){ + if(BBI > MyBBI) + return TRUE; + } + + return FALSE; +} +#endif diff --git a/gmsv/char/petmail.c b/gmsv/char/petmail.c new file mode 100644 index 0000000..92b2b79 --- /dev/null +++ b/gmsv/char/petmail.c @@ -0,0 +1,1125 @@ +#include "version.h" +#include + +#include "configfile.h" +#include "buf.h" +#include "char_base.h" +#include "char.h" +#include "battle.h" +#include "handletime.h" +#include "map_deal.h" +#include "addressbook.h" +#include "lssproto_serv.h" +#include "pet.h" +#include "petmail.h" +#include "npcutil.h" +#include "log.h" + +#define PETMAIL_BATTLETIMEOUT 660 +#define PETMAIL_IDLETIMEOUT 30 +#define PETMAIL_IDLETIME 10 + +#define PETMAIL_IDLE_RETURNOWNER (60*30) +//andy_edit +//#define PETMAIL_IDLEDISCARD (60*60) //Syu 修正宠邮等待时间为一小时 +#define PETMAIL_IDLEDISCARD (60*3) + +/* petmail 跨星系的等待时间 shan add */ +#define PETMAIL_JS_TIMEOUT (2*60) + +static int PETMAIL_getIdleTime( int index); +static void PETMAIL_sendPetmail( int index, int tocharaindex); +static void PETMAIL_IdleProc1( int index); +static void PETMAIL_IdleProc2( int index); +static void PETMAIL_IdleProc3( int index); +static void PETMAIL_IdleProc4( int index); +static void PETMAIL_IdleProc5( int index); + +static void PETMAIL_ReturnWait( int index); +static void PETMAIL_returnMail( int index, int tocharaindex); +static int PETMAIL_offmsg_max; +#define PETMAILOFFMSGFILE "petmail.txt" + +#define PETMAIL_DEFTOTALNUM 1000 +static int PetMailTotalnums = 0; + +BOOL PETMAIL_sendPetMail( int cindex, int aindex, + int havepetindex, int haveitemindex, char* text , int color ) +{ + char textbuffer[2048]; + struct tm tm1; + Char *ch; + ADDRESSBOOK_entry *ae; + int petindex; + int itemindex =-1; + int tocharaindex,playernum,i; + + //判断 人物 宠物 道具 对象名片 + if( !CHAR_CHECKINDEX( cindex) )return FALSE; + if( haveitemindex != -1 ) { + itemindex = CHAR_getItemIndex( cindex, haveitemindex); + if( ITEM_CHECKINDEX( itemindex)) { + if( ITEM_getInt( itemindex, ITEM_CANPETMAIL) == 0 ) { + print( "err? crack?\n"); + return FALSE; + } + } + } + petindex = CHAR_getCharPet( cindex, havepetindex); + if( petindex == -1 ) return FALSE; + ch = CHAR_getCharPointer( petindex); + if( ch == NULL ) return FALSE; + ae = CHAR_getAddressbookEntry( cindex , aindex ); + if( ae == NULL )return FALSE; + +#ifdef _AVID_TRADETRYBUG //宠物邮件 + if( CHAR_getWorkInt( cindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE ){ + CHAR_talkToCli( cindex, -1, "交易状态中无法传递宠物邮件。", CHAR_COLORYELLOW ); + return FALSE; + } +#endif + //骑乘 + if (CHAR_getInt( cindex, CHAR_RIDEPET) == havepetindex ){ + CHAR_talkToCli(cindex, -1, "骑乘中的宠物无法传递宠物邮件!", CHAR_COLORYELLOW); + return FALSE; + } + if( CHAR_getWorkInt( cindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE){ + CHAR_talkToCli( cindex, -1, "战斗状态中无法传递宠物邮件。", CHAR_COLORYELLOW ); + return FALSE; + } + if (CHAR_getInt(petindex, CHAR_PETFAMILY) == 1){ + CHAR_talkToCli(cindex, -1, "家族守护兽无法传递邮件喔!", CHAR_COLORYELLOW); + return FALSE; + } +// Terry add fix can send mail to offline character 2004/2/5 + if(ae->online == 0){ + CHAR_talkToCli(cindex, -1, "该玩家不在线上!", CHAR_COLORYELLOW); + return FALSE; + } + playernum = CHAR_getPlayerMaxNum(); + for(i = 0;icdkey) == 0 && + strcmp(CHAR_getChar(i,CHAR_NAME),ae->charname) == 0 ) break; + } + if(i == playernum){ + CHAR_talkToCli(cindex, -1, "该玩家不在此星球上!", CHAR_COLORYELLOW); + return FALSE; + } +// end +#ifdef _MAP_TIME + if((CHAR_getInt(cindex,CHAR_FLOOR) >= 30017 && CHAR_getInt(cindex,CHAR_FLOOR) <= 30021)){ + char msgbuf[512]; + snprintf(msgbuf,sizeof(msgbuf),"此地区不得寄送道具!"); + CHAR_talkToCli(cindex,-1,msgbuf,CHAR_COLORWHITE); + return FALSE; + } + if((CHAR_getInt(i,CHAR_FLOOR) >= 30017 && CHAR_getInt(i,CHAR_FLOOR) <= 30021)){ + char msgbuf[512]; + snprintf(msgbuf,sizeof(msgbuf),"对方所在地区不得收寄送道具!"); + CHAR_talkToCli(cindex,-1,msgbuf,CHAR_COLORWHITE); + return FALSE; + } +#endif + +#ifdef _BAD_PLAYER // WON ADD 送坏玩家去关 + if( CHAR_getInt(cindex,CHAR_FLOOR)==887 ){ + char msgbuf[512]; + snprintf( msgbuf, sizeof( msgbuf), "对不起,您在招待室中,无法寄送信件。"); + CHAR_talkToCli( cindex, -1, msgbuf, CHAR_COLORWHITE); + return FALSE; + } +#endif + +#ifdef _DEATH_FAMILY_GM_COMMAND // WON ADD 家族战GM指令 + { + char msgbuf[512]; + snprintf( msgbuf, sizeof( msgbuf), "跨星系家族PK,无法寄送信件。"); + CHAR_talkToCli( cindex, -1, msgbuf, CHAR_COLORWHITE); + return FALSE; + } +#endif + + // Syu Add 2003/05/30 + if( ( CHAR_getInt(cindex,CHAR_FLOOR) >= 8200 && CHAR_getInt(cindex,CHAR_FLOOR) <= 8213 ) ) + { + char msgbuf[512]; + snprintf( msgbuf, sizeof( msgbuf), "英雄战场不得寄送道具!"); + CHAR_talkToCli( cindex, -1, msgbuf, CHAR_COLORWHITE); + return FALSE; + } + +#ifdef _PET_LIMITLEVEL + if( CHAR_getInt( petindex, CHAR_LIMITLEVEL) > 0 ) { + CHAR_talkToCli(cindex, -1, "特殊宠物不能传递邮件喔!", CHAR_COLORYELLOW); + return FALSE; + } +#endif + +#ifdef _PETMAIL_DEFNUMS + if( CHAR_getWorkInt( cindex, CHAR_PETMAILNUMS) > 6 ){ + CHAR_talkToCli(cindex, -1, "邮件中宠物过多,暂时无法传递宠物邮件!", CHAR_COLORYELLOW); + return FALSE; + }else if( PETMAIL_CheckIsMyOffmsg( cindex, ae->cdkey, ae->charname) > 5 ){ + CHAR_talkToCli(cindex, -1, "收件者目前邮件宠物超过5封,暂时无法传递宠物邮件!", CHAR_COLORYELLOW); + return FALSE; + }else if( CHAR_getWorkInt( cindex, CHAR_PETMAILSENDTIME) > (int)time( NULL)){ + char Mess1[256]; + sprintf( Mess1,"需等待%d秒才能再次寄送宠物邮件!", + (int)time( NULL) - CHAR_getWorkInt( cindex, CHAR_PETMAILSENDTIME)); + CHAR_talkToCli( cindex, -1, Mess1, CHAR_COLORYELLOW); + return FALSE; + }else if( PetMailTotalnums >= PETMAIL_DEFTOTALNUM ){ + CHAR_talkToCli(cindex, -1, "目前系统邮件过多,请稍後再寄。", CHAR_COLORYELLOW); + return FALSE; + }else{ + int nums = CHAR_getWorkInt( cindex, CHAR_PETMAILNUMS); + nums ++; + CHAR_setWorkInt( cindex, CHAR_PETMAILNUMS, nums); + CHAR_setWorkInt( cindex, CHAR_PETMAILSENDTIME, (int)time( NULL)+6); + PetMailTotalnums ++; + } +#endif + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + snprintf( textbuffer, sizeof( textbuffer), + "%2d/%02d %2d:%02d|%s", tm1.tm_mon +1, tm1.tm_mday, tm1.tm_hour, tm1.tm_min, text); + { + int offmsgindex; + offmsgindex = PETMAIL_addOffmsg( cindex, ae->cdkey, ae->charname, text, color); + if( offmsgindex == -1 ) { + print( "offmsg buffer over\n"); + return FALSE; + } + +#ifdef _FIX_PETMAIL2 // WON ADD 修正宠邮2 + if( !PET_dropPetFLXY( cindex, havepetindex, PETMAIL_SPOOLFLOOR, PETMAIL_SPOOLX,PETMAIL_SPOOLY) ){ + CHAR_talkToCli( cindex, -1, "宠物邮件失败", CHAR_COLORYELLOW); + return FALSE; + } +#endif + CHAR_setInt( petindex, CHAR_FLOOR, CHAR_getInt( cindex, CHAR_FLOOR)); + CHAR_setInt( petindex, CHAR_X, CHAR_getInt( cindex, CHAR_X)); + CHAR_setInt( petindex, CHAR_Y, CHAR_getInt( cindex, CHAR_Y)); + CHAR_sendPMEToArroundCharacter( cindex, petindex, 0, CHAR_getInt( petindex, CHAR_PETMAILEFFECT)); + CHAR_setInt( petindex, CHAR_MAILMODE,CHAR_PETMAIL_IDLE2); + CHAR_setInt( petindex, CHAR_LOOPINTERVAL, PETMAIL_LOOPINTERVAL2); + strcpysafe( ch->charfunctable[CHAR_LOOPFUNC].string, + sizeof( ch->charfunctable[CHAR_LOOPFUNC]), "PETMAIL_Loop"); + CHAR_constructFunctable( petindex); + CHAR_setInt( petindex, CHAR_PETMAILBUFINDEX, offmsgindex); + CHAR_setInt( petindex, CHAR_PETMAILIDLETIME, NowTime.tv_sec); + CHAR_setInt( petindex, CHAR_PETMAILFROMFLOOR, CHAR_getInt( cindex, CHAR_FLOOR)); + CHAR_setInt( petindex, CHAR_PETMAILFROMX, CHAR_getInt( cindex, CHAR_X)); + CHAR_setInt( petindex, CHAR_PETMAILFROMY,CHAR_getInt( cindex, CHAR_Y)); + +#ifdef _WON_PET_MAIL_LOG // WON ADD 增加寄宠邮的 LOG + LogPet( + CHAR_getChar( cindex, CHAR_NAME ), + CHAR_getChar( cindex, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "Pet_Send_Mail(寄宠邮)", + CHAR_getInt( cindex,CHAR_FLOOR), + CHAR_getInt( cindex,CHAR_X ), + CHAR_getInt( cindex,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) + ); +#endif + if( haveitemindex != -1 ) { + CHAR_setItemIndex( cindex, haveitemindex, -1); + CHAR_setItemIndex( petindex, CHAR_STARTITEMARRAY, itemindex); + CHAR_sendItemDataOne( cindex, haveitemindex); + LogItem( + CHAR_getChar( cindex, CHAR_NAME ), + CHAR_getChar( cindex, CHAR_CDKEY ), + itemindex, + "pm_have(宠邮->寄送的道具)", + CHAR_getInt( cindex,CHAR_FLOOR), + CHAR_getInt( cindex,CHAR_X ), + CHAR_getInt( cindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + + ); + } + { + char token[256]; + tocharaindex = PETMAIL_CheckPlayerExist( petindex, 0); + sprintf( token, "寄送宠物邮件(%s)给%s。", + CHAR_getUseName( petindex), CHAR_getUseName( tocharaindex) ); + CHAR_talkToCli( cindex, -1, token, CHAR_COLORYELLOW); + } + return TRUE; + } + return FALSE; +} + +static PETMAIL_offmsg * PETMAIL_offmsgbuf; +BOOL PETMAIL_initOffmsgBuffer( int count ) +{ + int size = sizeof( PETMAIL_offmsg )*count ; + FILE *fp; + char filename[256]; + char line[2048]; + int linenum = 0; + + PETMAIL_offmsgbuf = (PETMAIL_offmsg*)allocateMemory( size ); + + if( PETMAIL_offmsgbuf == NULL ) return FALSE; + + PetMailTotalnums = 0; + + memset( PETMAIL_offmsgbuf, 0,size ); + + PETMAIL_offmsg_max = count; + snprintf( filename ,sizeof( filename ) ,"%s/%s", getStoredir(), PETMAILOFFMSGFILE); + fp = fopen( filename , "rt" ); + if( fp == NULL ) return TRUE; + + while( fgets( line, sizeof( line ), fp ) != NULL ){ + char buf[1024]; + int index; + if( !getStringFromIndexWithDelim( line, "|", 1, buf, sizeof( buf))) { + print( "read error line[%d]\n", linenum); + continue; + } + index = atoi( buf); + if( index >= PETMAIL_offmsg_max ) { + print( "index over offmsg_max [%d]\n", index); + continue; + } + if( PETMAIL_offmsgbuf[index].use == TRUE) { + print( "offmsg already use index[%d]\n", index); + continue; + } + + if( !getStringFromIndexWithDelim( line, "|", 2, buf, sizeof( buf))) { + print( "read error line[%d]\n", linenum); + continue; + } + PETMAIL_offmsgbuf[index].send_tm = atoi( buf); + + if( !getStringFromIndexWithDelim( line, "|", 3, buf, sizeof( buf))) { + print( "read error line[%d]\n", linenum); + continue; + } + PETMAIL_offmsgbuf[index].color = atoi( buf); + + if( !getStringFromIndexWithDelim( line, "|", 4, buf, sizeof( buf))) { + print( "read error line[%d]\n", linenum); + continue; + } + strcpysafe( PETMAIL_offmsgbuf[index].text, + sizeof( PETMAIL_offmsgbuf[index].text), + buf); + + if( !getStringFromIndexWithDelim( line, "|", 5, buf, sizeof( buf))) { + print( "read error line[%d]\n", linenum); + continue; + } + strcpysafe( PETMAIL_offmsgbuf[index].destcd, + sizeof( PETMAIL_offmsgbuf[index].destcd), + buf); + + if( !getStringFromIndexWithDelim( line, "|", 6, buf, sizeof( buf))) { + print( "read error line[%d]\n", linenum); + continue; + } + makeStringFromEscaped(buf); + strcpysafe( PETMAIL_offmsgbuf[index].destcharname, + sizeof( PETMAIL_offmsgbuf[index].destcharname), + buf); + if( !getStringFromIndexWithDelim( line, "|", 7, buf, sizeof( buf))) { + print( "read error line[%d]\n", linenum); + continue; + } + strcpysafe( PETMAIL_offmsgbuf[index].srccd, + sizeof( PETMAIL_offmsgbuf[index].srccd), + buf); + if( !getStringFromIndexWithDelim( line, "|", 8, buf, sizeof( buf))) { + print( "read error line[%d]\n", linenum); + continue; + } + makeStringFromEscaped(buf); + strcpysafe( PETMAIL_offmsgbuf[index].srccharname, + sizeof( PETMAIL_offmsgbuf[index].srccharname), + buf); + linenum ++; + } + fclose( fp); + return TRUE; + +} + +BOOL PETMAIL_addOffmsg( int fromindex, char *tocdkey, char *tocharaname, + char *text , int color ) +{ + + int i; + + for( i = 0 ; i < PETMAIL_offmsg_max; i++ ) { + if( PETMAIL_offmsgbuf[i].use == 0 ) { + PETMAIL_offmsg *om = & PETMAIL_offmsgbuf[i]; + om->use = 1; + time( & om->send_tm ); + + strcpysafe( om->srccd , sizeof( om->srccd ), + CHAR_getChar( fromindex, CHAR_CDKEY)); + strcpysafe( om->srccharname , sizeof( om->srccharname ), + CHAR_getChar( fromindex, CHAR_NAME)); + strcpysafe( om->destcd , sizeof( om->destcd ), tocdkey ); + strcpysafe( om->destcharname , sizeof(om->destcharname), tocharaname); + strcpysafe( om->text , sizeof(om->text), text ); + om->color = color; + return i; + } + } + return -1; +} + +PETMAIL_offmsg *PETMAIL_getOffmsg( int offmsgindex) +{ + if( offmsgindex < 0 || offmsgindex >= PETMAIL_offmsg_max ) return NULL; + return &PETMAIL_offmsgbuf[offmsgindex]; +} + +BOOL PETMAIL_deleteOffmsg( int offmsgindex) +{ + if( offmsgindex < 0 || offmsgindex >= PETMAIL_offmsg_max ) return FALSE; + PETMAIL_offmsgbuf[offmsgindex].use = FALSE; + return TRUE; +} + +void PETMAIL_proc( void ) +{ + int i; + static time_t PETMAIL_check_time_store = 0; + time_t t; + time( &t ); + if( t < PETMAIL_check_time_store) return; + PETMAIL_check_time_store = t + PETMAIL_CHECK_OFFMSG_EXPIRE_INTERVAL; + for(i = 0; i < PETMAIL_offmsg_max ; i++){ + if( PETMAIL_offmsgbuf[i].use && PETMAIL_offmsgbuf[i].send_tm < ( t - PETMAIL_OFFMSG_TIMEOUT )){ + PETMAIL_offmsgbuf[i].use = FALSE; + } + } +} + +BOOL storePetmail( void) +{ + FILE *fp; + char filename[256]; + char escapebuf1[ 64],escapebuf2[ 64]; + int i; + + /* 白央奶伙 毛菲户月 */ + snprintf( filename ,sizeof( filename ) ,"%s/%s" , + getStoredir(), PETMAILOFFMSGFILE); + fp = fopen( filename , "wt" ); + if( fp == NULL ) return FALSE; + for(i = 0; i < PETMAIL_offmsg_max ; i++){ + if( PETMAIL_offmsgbuf[i].use ){ + fprintf( fp, "%d|%ud|%d|%s|%s|%s|%s|%s|", + i, (unsigned int)PETMAIL_offmsgbuf[i].send_tm, + PETMAIL_offmsgbuf[i].color, + PETMAIL_offmsgbuf[i].text, + PETMAIL_offmsgbuf[i].destcd, + makeEscapeString( PETMAIL_offmsgbuf[i].destcharname, + escapebuf1, sizeof( escapebuf1)), + PETMAIL_offmsgbuf[i].srccd, + makeEscapeString( PETMAIL_offmsgbuf[i].srccharname, + escapebuf2, sizeof( escapebuf2))); + } + } + fclose( fp); + return TRUE; +} + +BOOL PETMAIL_CheckPlayerExist( int index, int mode) +{ + int i; + char *searchcd = NULL; + char *searchname = NULL; + PETMAIL_offmsg *adof; + int playernum = CHAR_getPlayerMaxNum(); + + if( mode == 0 ) { + adof = PETMAIL_getOffmsg( CHAR_getInt( index, CHAR_PETMAILBUFINDEX)); + if( adof == NULL ) return FALSE; + searchcd = adof->destcd; + searchname = adof->destcharname; + } + else if( mode == 1 ) { + searchcd = CHAR_getChar( index, CHAR_OWNERCDKEY); + searchname = CHAR_getChar( index, CHAR_OWNERCHARANAME); + if( searchcd == NULL || searchname == NULL ) return FALSE; + } + for( i = 0 ; i < playernum ; i ++) { + if( CHAR_CHECKINDEX( i) && + strcmp( CHAR_getChar( i, CHAR_CDKEY), searchcd ) == 0 && + strcmp( CHAR_getChar( i, CHAR_NAME), searchname) == 0 ) { + return i; + } + } + return -1; +} + +void PETMAIL_Loopfunc( int index) +{ + int mode = CHAR_getInt( index, CHAR_MAILMODE); + switch( mode ){ + case CHAR_PETMAIL_IDLE1: + PETMAIL_IdleProc1( index); + break; + case CHAR_PETMAIL_IDLE2: + PETMAIL_IdleProc2( index); + break; + case CHAR_PETMAIL_RETURNWAIT://回来等待 + PETMAIL_ReturnWait( index); + break; + case CHAR_PETMAIL_IDLE3: + PETMAIL_IdleProc3( index); + break; + case CHAR_PETMAIL_IDLE4://寻找主人 + PETMAIL_IdleProc4( index); + break; + case CHAR_PETMAIL_IDLE5: //超过时间无法找到主人 + PETMAIL_IdleProc5( index); + break; + default: + break; + } +} + +static int PETMAIL_getIdleTime( int index) +{ +#define PETMAIL_DIVRANGE 25 // 坌喃允月汹 +#define PETMAIL_IDLELEVELRANGE 10 // 坌喃允月 区 +#define PETMAIL_IDLEUNITTIME 3 // 棉厥 + int d; + int dex = CHAR_getWorkInt( index, CHAR_WORKQUICK) ; + + d = dex / PETMAIL_DIVRANGE; + if( d < 0 ) d = 0; + if( d > PETMAIL_IDLELEVELRANGE ) d = PETMAIL_IDLELEVELRANGE; + d = PETMAIL_IDLELEVELRANGE - d ; + + return d * PETMAIL_IDLEUNITTIME; + +#undef PETMAIL_DIVRANGE +#undef PETMAIL_IDLELEVELRANGE +#undef PETMAIL_IDLEUNITTIME +} + +static void PETMAIL_sendPetmail( int index, int tocharaindex) +{ + int index_to_my_info; + int itemindex,ret; + index_to_my_info = ADDRESSBOOK_getIndexInAddressbook( tocharaindex, + CHAR_getChar( index, CHAR_OWNERCDKEY), + CHAR_getChar( index, CHAR_OWNERCHARANAME)); +#ifdef _DEATH_FAMILY_GM_COMMAND // WON ADD 家族战GM指令 + { + char msgbuf[512]; + snprintf( msgbuf, sizeof( msgbuf), "跨星系家族PK,无法寄送信件。"); + CHAR_talkToCli( index, -1, msgbuf, CHAR_COLORWHITE); + return ; + } +#endif + + + if( index_to_my_info < 0 ) { + char msgbuf[512]; + + snprintf( msgbuf, sizeof( msgbuf), + "%s的%s 终於来了!" + "由於对方没有您的名片,所以信件被退回了。", + CHAR_getChar( index, CHAR_OWNERCHARANAME), + CHAR_getUseName( index)); + CHAR_talkToCli( tocharaindex, -1, msgbuf, CHAR_COLORWHITE); + } + +#ifdef _BAD_PLAYER // WON ADD 送坏玩家去关 + else if( CHAR_getInt(tocharaindex,CHAR_FLOOR)==887 ){ + char msgbuf[512]; + snprintf( msgbuf, sizeof( msgbuf), + "由於您在招待室中,无法接收信件,所以信件被退回了。" ); + CHAR_talkToCli( tocharaindex, -1, msgbuf, CHAR_COLORWHITE); + } +#endif + + //Syu Add 06/16 + else if( CHAR_getInt(tocharaindex,CHAR_FLOOR) >=8200 && + CHAR_getInt(tocharaindex,CHAR_FLOOR) <= 8213 ){ + char msgbuf[512]; + snprintf( msgbuf, sizeof( msgbuf), + "英雄战场不得寄送道具!" ); + CHAR_talkToCli( tocharaindex, -1, msgbuf, CHAR_COLORWHITE); + } + else { + struct tm tm1; + char textbuffer[2048]; + char escapebuf[128]; + int fd; + PETMAIL_offmsg *offmsg; + itemindex = CHAR_getItemIndex( index, CHAR_STARTITEMARRAY); + ret = CHAR_addItemSpecificItemIndex( tocharaindex, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE){ + CHAR_DropItem( index, CHAR_STARTITEMARRAY); + LogItem( + CHAR_getChar( tocharaindex, CHAR_NAME ), + CHAR_getChar( tocharaindex, CHAR_CDKEY ), + itemindex, + "pm_putground(宠邮->道具栏已满,放置地上)", + CHAR_getInt( index,CHAR_FLOOR), + CHAR_getInt( index,CHAR_X ), + CHAR_getInt( index,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + + ); + } + else { + CHAR_setItemIndex( index, CHAR_STARTITEMARRAY, -1); + CHAR_sendItemDataOne( tocharaindex, ret); + LogItem( + CHAR_getChar( tocharaindex, CHAR_NAME ), + CHAR_getChar( tocharaindex, CHAR_CDKEY ), + itemindex, + "pm_getitem(宠邮->收到的道具)", + CHAR_getInt( index,CHAR_FLOOR), + CHAR_getInt( index,CHAR_X ), + CHAR_getInt( index,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + offmsg = PETMAIL_getOffmsg( + CHAR_getInt( index, CHAR_PETMAILBUFINDEX)); + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), + sizeof( tm1)); + snprintf( textbuffer, sizeof( textbuffer), + "%2d/%02d %2d:%02d|%s|%d|%d|%s|%d", + tm1.tm_mon +1, tm1.tm_mday, tm1.tm_hour, tm1.tm_min, + offmsg->text, + CHAR_getInt( index, CHAR_BASEIMAGENUMBER), + CHAR_getInt( index, CHAR_LV), + makeEscapeString( CHAR_getUseName( index), escapebuf, + sizeof( escapebuf)), + ITEM_getInt( itemindex, ITEM_BASEIMAGENUMBER) + ); + fd = getfdFromCharaIndex( tocharaindex); + if( fd != -1 ) lssproto_MSG_send( fd , index_to_my_info , + textbuffer , offmsg->color ); + PETMAIL_deleteOffmsg( CHAR_getInt( index, CHAR_PETMAILBUFINDEX)); + CHAR_setInt( index, CHAR_PETMAILBUFINDEX, -1); + CHAR_setInt( index, CHAR_PETSENDMAILCOUNT, + CHAR_getInt( index, CHAR_PETSENDMAILCOUNT) +1); + { + char *cdkey = CHAR_getChar( index, CHAR_CDKEY); + if( cdkey) printl( LOG_TALK, "CDKEY=%s\tTEXT=%s" , cdkey, offmsg->text ); + else printl( LOG_TALK, "CDKEY=(null)\tTEXT=%s" , offmsg->text ); + } + } +} + +static void PETMAIL_IdleProc1( int index) +{ + + int tocharaindex; + int warp = FALSE; + + tocharaindex = PETMAIL_CheckPlayerExist( index, 0); + if( !CHAR_CHECKINDEX( tocharaindex) ) { + warp = TRUE; + }else { + if( CHAR_getInt( tocharaindex, CHAR_FLOOR) == 8215 ){//客服活动 andy + warp = TRUE; + }else if( CHAR_getWorkInt( tocharaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE ){//交易中不收邮件 + warp = TRUE; + }else if( CHAR_getWorkInt( tocharaindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE ){ + int battleindex = CHAR_getWorkInt( tocharaindex, CHAR_WORKBATTLEINDEX ); + if( !BATTLE_CHECKINDEX( battleindex ) || BattleArray[battleindex].flgTime > 60 ){ + warp = TRUE; + } + }else { + int ret; + int distance; + distance = NPC_Util_CharDistance( tocharaindex, index); + if( distance > CHAR_DEFAULTSEESIZ /2 ) { + warp = TRUE; + }else if( distance > 1 ){ + int dir = NPC_Util_GetDirCharToChar( index, tocharaindex, 0); + if( dir != -1 ) { + dir = NPC_Util_SuberiWalk( index, dir); + } + if( dir != -1 ) { + ret = CHAR_walk( index, dir, 0); + if( ret != CHAR_WALKSUCCESSED) { + dir = -1; + } + } + if( dir == -1 ) { + warp = TRUE; + } + }else { + PETMAIL_sendPetmail( index, tocharaindex); + CHAR_setInt( index, CHAR_MAILMODE,CHAR_PETMAIL_RETURNWAIT); + CHAR_setInt( index, CHAR_PETMAILIDLETIME, NowTime.tv_sec); + CHAR_setInt( index, CHAR_LOOPINTERVAL, PETMAIL_LOOPINTERVAL2); + } + } + } + if( warp) { + if( CHAR_getInt( index, CHAR_FLOOR) != PETMAIL_SPOOLFLOOR) { + CHAR_warpToSpecificPoint( index, + PETMAIL_SPOOLFLOOR, + PETMAIL_SPOOLX,PETMAIL_SPOOLX); + CHAR_setInt( index, CHAR_MAILMODE,CHAR_PETMAIL_IDLE2); + CHAR_setInt( index, CHAR_PETMAILIDLETIME, NowTime.tv_sec); + CHAR_setInt( index, CHAR_LOOPINTERVAL, PETMAIL_LOOPINTERVAL2); + } + } +} + +static void PETMAIL_IdleProc2( int index) +{ + unsigned int t = CHAR_getInt( index, CHAR_PETMAILIDLETIME); + if( NowTime.tv_sec > t + PETMAIL_getIdleTime( index)) { + int tocharaindex; + int cnt; + tocharaindex = PETMAIL_CheckPlayerExist( index, 0); + if( tocharaindex != -1 ) { + if( CHAR_getInt( tocharaindex, CHAR_FLOOR) == 8215 ){//客服活动 andy + }else if( CHAR_getWorkInt( tocharaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE ){//交易中不收邮件 + }else if( CHAR_getWorkInt( tocharaindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE){ + }else { + int fl, x, y, ch_x, ch_y; + fl = CHAR_getInt( tocharaindex, CHAR_FLOOR); + ch_x = CHAR_getInt( tocharaindex, CHAR_X); + ch_y = CHAR_getInt( tocharaindex, CHAR_Y); + for( cnt = 0; cnt < 10; cnt ++ ) { + x = RAND( ch_x -1, ch_x + 1); + y = RAND( ch_y -1, ch_y + 1); + if( MAP_walkAble( tocharaindex, fl,x,y)) { + break; + } + } + if( cnt == 10 ) { + x = ch_x; y = ch_y; + } + CHAR_setInt( index, CHAR_MAILMODE,CHAR_PETMAIL_RETURNWAIT); + CHAR_setInt( index, CHAR_PETMAILIDLETIME, NowTime.tv_sec); + CHAR_warpToSpecificPoint( index,fl, x,y); + PETMAIL_sendPetmail( index, tocharaindex); + return; + } + }else{ + if( NowTime.tv_sec > t + PETMAIL_IDLETIMEOUT ) { + PETMAIL_deleteOffmsg( CHAR_getInt( index, CHAR_PETMAILBUFINDEX)); + CHAR_setInt( index, CHAR_MAILMODE, CHAR_PETMAIL_IDLE3); + CHAR_setInt( index, CHAR_PETMAILIDLETIME, NowTime.tv_sec); + CHAR_setInt( index, CHAR_LOOPINTERVAL, PETMAIL_LOOPINTERVAL1); + } + return; + } + if( NowTime.tv_sec > t + PETMAIL_BATTLETIMEOUT ) { + PETMAIL_deleteOffmsg( CHAR_getInt( index, CHAR_PETMAILBUFINDEX)); + CHAR_setInt( index, CHAR_MAILMODE, CHAR_PETMAIL_IDLE3); + CHAR_setInt( index, CHAR_PETMAILIDLETIME, NowTime.tv_sec); + CHAR_setInt( index, CHAR_LOOPINTERVAL, PETMAIL_LOOPINTERVAL1); + } + } +} + +static void PETMAIL_ReturnWait( int index) +{ + unsigned int t = CHAR_getInt( index, CHAR_PETMAILIDLETIME); + if( NowTime.tv_sec > t + PETMAIL_IDLETIME) { + CHAR_setInt( index, CHAR_MAILMODE, CHAR_PETMAIL_IDLE3); + CHAR_setInt( index, CHAR_PETMAILIDLETIME, NowTime.tv_sec); + CHAR_setInt( index, CHAR_LOOPINTERVAL, PETMAIL_LOOPINTERVAL1); + } +} + +static void PETMAIL_IdleProc3( int index) +{ + + int tocharaindex; + int warp = FALSE; + + tocharaindex = PETMAIL_CheckPlayerExist( index, 1); + if( tocharaindex == -1 ) { + warp = TRUE; + }else { + if( CHAR_getWorkInt( tocharaindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE) { + int ret ; + int distance; + distance = NPC_Util_CharDistance( tocharaindex, index); + if( distance > CHAR_DEFAULTSEESIZ /2 ) { + warp = TRUE; + + }else if( distance > 1 ){ + int dir = NPC_Util_GetDirCharToChar( index, tocharaindex, 0); + if( dir != -1 ) { + dir = NPC_Util_SuberiWalk( index, dir); + } + if( dir != -1 ) { + ret = CHAR_walk( index, dir, 0); + if( ret != CHAR_WALKSUCCESSED) { + dir = -1; + } + } + if( dir == -1 ) { + warp = TRUE; + } + }else { + //andy_reEdit 2003/05/30 + warp = TRUE; +/* CHAR_setInt( index, CHAR_MAILMODE,CHAR_PETMAIL_IDLE5); + CHAR_setInt( index, CHAR_PETMAILIDLETIME, NowTime.tv_sec); + CHAR_setInt( index, CHAR_LOOPINTERVAL, PETMAIL_LOOPINTERVAL2); + PETMAIL_returnMail( index, tocharaindex); +*/ + } + } + } + if( warp) { + CHAR_warpToSpecificPoint( index, + PETMAIL_SPOOLFLOOR, + PETMAIL_SPOOLX,PETMAIL_SPOOLX); + CHAR_setInt( index, CHAR_MAILMODE,CHAR_PETMAIL_IDLE4); + CHAR_setInt( index, CHAR_PETMAILIDLETIME, NowTime.tv_sec); + CHAR_setInt( index, CHAR_LOOPINTERVAL, PETMAIL_LOOPINTERVAL2); + } +} +static void PETMAIL_IdleProc4( int index) +{ + unsigned int t = CHAR_getInt( index, CHAR_PETMAILIDLETIME); + { + int tocharaindex; + int cnt; + tocharaindex = PETMAIL_CheckPlayerExist( index, 1);//寻找主人 + if( tocharaindex != -1 ) { + if( CHAR_getWorkInt( tocharaindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE && + CHAR_getWorkInt( tocharaindex, CHAR_WORKTRADEMODE) == CHAR_TRADE_FREE ){ + + int fl, x, y, ch_x, ch_y;//回到主人身边 + + fl = CHAR_getInt( tocharaindex, CHAR_FLOOR); + ch_x = CHAR_getInt( tocharaindex, CHAR_X); + ch_y = CHAR_getInt( tocharaindex, CHAR_Y); + for( cnt = 0; cnt < 10; cnt ++ ) { + x = RAND( ch_x -1, ch_x + 1); + y = RAND( ch_y -1, ch_y + 1); + if( MAP_walkAble( index, fl,x,y)) { + break; + } + } + if( cnt == 10 ) { + x = ch_x; y = ch_y; + } + CHAR_setInt( index, CHAR_MAILMODE,CHAR_PETMAIL_IDLE5); + CHAR_setInt( index, CHAR_PETMAILIDLETIME, NowTime.tv_sec); + CHAR_warpToSpecificPoint( index,fl, x,y); + PETMAIL_returnMail( index, tocharaindex); + } + }else { + if( NowTime.tv_sec > t + PETMAIL_IDLE_RETURNOWNER ) {//检查等待主人时间 + int itemindex; + CHAR_warpToSpecificPoint( index, //回到原先主人所在座标 + CHAR_getInt( index, CHAR_PETMAILFROMFLOOR), + CHAR_getInt( index, CHAR_PETMAILFROMX), + CHAR_getInt( index, CHAR_PETMAILFROMY)); + + CHAR_setInt( index, CHAR_MAILMODE, CHAR_PETMAIL_IDLE5);//改变宠邮状态 + CHAR_setInt( index, CHAR_LOOPINTERVAL, PETMAIL_LOOPINTERVAL2); + CHAR_setInt( index, CHAR_PETMAILIDLETIME, NowTime.tv_sec); + if( CHAR_getInt( index, CHAR_PETMAILIDLETIME) != -1 ) { + PETMAIL_deleteOffmsg( CHAR_getInt( index, CHAR_PETMAILBUFINDEX)); + } + itemindex = CHAR_getItemIndex( index, CHAR_STARTITEMARRAY);//删除附带道具 + if( ITEM_CHECKINDEX( itemindex ) ) { + CHAR_DropItem( index, CHAR_STARTITEMARRAY); + + LogItem( + CHAR_getChar( index, CHAR_OWNERCHARANAME ), + CHAR_getChar( index, CHAR_OWNERCDKEY ), + itemindex, + "pm_returntimeout(宠邮->逾时删除道具)", + CHAR_getInt( index,CHAR_FLOOR), + CHAR_getInt( index,CHAR_X ), + CHAR_getInt( index,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + } + } + } + +} + +static void PETMAIL_IdleProc5( int index) +{ + unsigned int t = CHAR_getInt( index, CHAR_PETMAILIDLETIME); + if( NowTime.tv_sec > t + PETMAIL_IDLEDISCARD) { + Char *ch; + CHAR_setInt( index, CHAR_MAILMODE, CHAR_PETMAIL_NONE); + CHAR_setInt( index, CHAR_PETMAILIDLETIME, 0); + +#ifdef _FIX_PETMAIL // WON ADD 修正宠邮 + CHAR_setInt( index, CHAR_PUTPETTIME, NowTime.tv_sec ); +#endif +#ifdef _PETMAIL_DEFNUMS + PETMAIL_delPetMailTotalnums( 1); //M PET 变自由宠 + if( PetMailTotalnums < 0 ) PetMailTotalnums = 0; +#endif + ch = CHAR_getCharPointer( index); + if( ch != NULL ) { + strcpysafe( ch->charfunctable[CHAR_LOOPFUNC].string, + sizeof( ch->charfunctable[CHAR_LOOPFUNC]), "" ); + CHAR_constructFunctable( index); + } +#ifdef _PET_LOSTPET + CHAR_CharSaveLostPet( index, 2); + LogPet( + "系统", + "Watchfunc", + CHAR_getChar( index, CHAR_NAME), + CHAR_getInt( index, CHAR_LV), + "timeout_lost(系统扣留-宠邮自由宠)", + CHAR_getInt( index, CHAR_FLOOR), + CHAR_getInt( index,CHAR_X ), + CHAR_getInt( index,CHAR_Y ), + CHAR_getChar( index, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + print("系统扣留-宠邮自由宠:%s\n", CHAR_getUseName( index)); + CHAR_CharaDelete( index); +#else + LogPet( + CHAR_getChar( index, CHAR_OWNERCHARANAME ), + CHAR_getChar( index, CHAR_OWNERCDKEY ), + CHAR_getChar( index, CHAR_NAME), + CHAR_getInt( index, CHAR_LV), + "FreePet(宠邮变回自由宠)", + CHAR_getInt( index,CHAR_FLOOR), + CHAR_getInt( index,CHAR_X ), + CHAR_getInt( index,CHAR_Y ), + CHAR_getChar( index, CHAR_UNIQUECODE) + ); +#endif + + }else { + int tocharaindex = PETMAIL_CheckPlayerExist( index, 1); + if( tocharaindex != -1 ) { + if( NPC_Util_CharDistance( tocharaindex, index ) > CHAR_DEFAULTSEESIZ/2) { + int fl, x, y, ch_x, ch_y; + int cnt; + fl = CHAR_getInt( tocharaindex, CHAR_FLOOR); + ch_x = CHAR_getInt( tocharaindex, CHAR_X); + ch_y = CHAR_getInt( tocharaindex, CHAR_Y); + for( cnt = 0; cnt < 10; cnt ++ ) { + x = RAND( ch_x -1, ch_x + 1); + y = RAND( ch_y -1, ch_y + 1); + if( MAP_walkAble( index, fl,x,y)) { + break; + } + } + if( cnt == 10 ) { + x = ch_x; y = ch_y; + } + CHAR_warpToSpecificPoint( index,fl, x,y); + } + } + } +} + +static void PETMAIL_returnMail( int index, int tocharaindex) +{ + char msgbuf[512]; + int itemindex = CHAR_getItemIndex( index, CHAR_STARTITEMARRAY); + if( ITEM_CHECKINDEX( itemindex ) ) { + int ret = CHAR_addItemSpecificItemIndex( tocharaindex, itemindex); + + if( ret < 0 || ret >= CHAR_MAXITEMHAVE){ + CHAR_DropItem( index, CHAR_STARTITEMARRAY); + + LogItem( + CHAR_getChar( tocharaindex, CHAR_NAME ), + CHAR_getChar( tocharaindex, CHAR_CDKEY ), + itemindex, + "pm_returnputground(宠邮->道具已满将道具放置地上)", + CHAR_getInt( index,CHAR_FLOOR), + CHAR_getInt( index,CHAR_X ), + CHAR_getInt( index,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + }else { + CHAR_setItemIndex( index, CHAR_STARTITEMARRAY, -1); + CHAR_sendItemDataOne( tocharaindex, ret); + } + } + +#ifdef _PETMAIL_DEFNUMS + { + int petmailnums = CHAR_getWorkInt( tocharaindex, CHAR_PETMAILNUMS); + petmailnums--; + if( petmailnums < 0 ) petmailnums = 0; + CHAR_setWorkInt( tocharaindex, CHAR_PETMAILNUMS, petmailnums); + } +#endif + if( CHAR_getInt( index, CHAR_PETMAILBUFINDEX) != -1 ) { + snprintf( msgbuf, sizeof( msgbuf), + "%s 回来了!" + "似乎无法寄送信件。", + CHAR_getUseName( index)); + CHAR_talkToCli( tocharaindex, -1, msgbuf, CHAR_COLORWHITE); + PETMAIL_deleteOffmsg( CHAR_getInt( index, CHAR_PETMAILBUFINDEX)); + }else { + snprintf( msgbuf, sizeof( msgbuf), + "%s 回来了!", CHAR_getUseName( index)); + CHAR_talkToCli( tocharaindex, -1, msgbuf, CHAR_COLORWHITE); + } + +#ifdef _PETMAIL_DEFNUMS + CHAR_AutoPickupMailPet( tocharaindex, index); +#endif + +} + + +#ifdef _PETMAIL_DEFNUMS +void CHAR_AutoPickupMailPet( int charaindex, int petindex ) +{ + int objindex; + int havepetindex; + char category[3]; + Char *ch; + if( !CHAR_CHECKINDEX( charaindex ) ) return; +#ifdef _AVID_TRADETRYBUG //丢出宠物 + if( CHAR_getWorkInt( charaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE ){ + CHAR_talkToCli( charaindex, -1, "交易状态中无法自动拾回邮件宠物!", CHAR_COLORYELLOW ); + return; + } +#endif + if( !CHAR_CHECKINDEX( petindex ) ) return; + havepetindex = CHAR_getCharPetElement( charaindex); + if( havepetindex == -1 ) { + + CHAR_talkToCli(charaindex,-1,"宠物栏已满!无法自动拾回邮件宠物!",CHAR_COLORYELLOW); + // WON ADD + LogPet( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "Pet_Full(宠物栏已满,无法拾起宠物)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) + ); + return; + } + ch = CHAR_getCharPointer( petindex); + if( ch == NULL ) return; + + objindex = CHAR_getWorkInt( petindex, CHAR_WORKOBJINDEX ); + CHAR_ObjectDelete(objindex); + CHAR_setWorkInt( petindex, CHAR_WORKPLAYERINDEX, charaindex); + CHAR_setCharPet( charaindex, havepetindex, petindex); + + CHAR_setChar( petindex, CHAR_OWNERCDKEY, CHAR_getChar( charaindex, CHAR_CDKEY)); + CHAR_setChar( petindex, CHAR_OWNERCHARANAME, CHAR_getChar( charaindex, CHAR_NAME)); + + snprintf( category,sizeof( category),"K%d",havepetindex); + CHAR_sendStatusString( charaindex, category); + snprintf( category,sizeof( category),"W%d",havepetindex); + CHAR_sendStatusString( charaindex, category); + + CHAR_setInt( petindex, CHAR_PUTPETTIME, 0); + CHAR_setWorkInt( petindex, CHAR_WORKOBJINDEX, -1); + CHAR_setInt( petindex, CHAR_MAILMODE, CHAR_PETMAIL_NONE); + PETMAIL_delPetMailTotalnums( 1); // M PET 自动捡起 + + strcpysafe( ch->charfunctable[CHAR_LOOPFUNC].string, + sizeof( ch->charfunctable[CHAR_LOOPFUNC]),""); + CHAR_setInt( petindex, CHAR_LOOPINTERVAL, 0); + CHAR_constructFunctable( petindex); + CHAR_complianceParameter( petindex ); + + if( PetMailTotalnums < 0 ) PetMailTotalnums = 0; + { + char mesg[256]; + char *p = NULL; + p = CHAR_getChar( petindex, CHAR_USERPETNAME); + if( strlen( p) == 0 ) { + p = CHAR_getChar( petindex, CHAR_NAME); + } + snprintf( mesg,sizeof(mesg), "拾回邮件宠物 %s", p); + CHAR_talkToCli(charaindex,-1,mesg,CHAR_COLORYELLOW); + } + LogPet( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "PickupMailPet(自动收回邮宠)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) + ); + return; +} +#endif + +int PETMAIL_getPetMailTotalnums() +{ +#ifdef _PETMAIL_DEFNUMS + if( PetMailTotalnums < 0 ) PetMailTotalnums = 0; + if( PetMailTotalnums >= PETMAIL_DEFTOTALNUM ) PetMailTotalnums = PETMAIL_DEFTOTALNUM; + return PetMailTotalnums; +#else + return 0; +#endif +} + +void PETMAIL_delPetMailTotalnums( int numflg) +{ +#ifdef _PETMAIL_DEFNUMS + PetMailTotalnums = PetMailTotalnums - numflg; + if( PetMailTotalnums < 0 ) PetMailTotalnums = 0; +#endif +} + +void PETMAIL_setPetMailTotalnums( int numflg) +{ + PetMailTotalnums = numflg; + if( PetMailTotalnums < 0 ) PetMailTotalnums = 0; + if( PetMailTotalnums > PETMAIL_DEFTOTALNUM+10 ) PetMailTotalnums = PETMAIL_DEFTOTALNUM + 5; +} + + +int PETMAIL_CheckIsMyOffmsg( int fromindex, char *tocdkey, char *tocharaname) +{ + int i, nums=0; + for( i = 0 ; i < PETMAIL_offmsg_max; i++ ) { + if( PETMAIL_offmsgbuf[i].use == 0 ) continue; + if( !strcmp( tocdkey, PETMAIL_offmsgbuf[i].destcd) && + !strcmp( tocharaname, PETMAIL_offmsgbuf[i].destcharname) ){ + nums++; + } + } + return nums; +} + + + diff --git a/gmsv/char/skill.c b/gmsv/char/skill.c new file mode 100644 index 0000000..61eee63 --- /dev/null +++ b/gmsv/char/skill.c @@ -0,0 +1,645 @@ +#include "version.h" +#include +#include +#include + +#include "skill.h" +#include "util.h" +#include "char.h" + +#ifdef _CHAR_PROFESSION // WON ADD 人物职业 +#include "battle.h" +#include "profession_skill.h" +#endif + + +static SKILL_intDataSetting SKILL_setint[SKILL_DATAINTNUM]={ + {"lv"}, /* SKILL_LEVEL */ + {"id"}, /* SKILL_ID */ +}; + +static SKILL_charDataSetting SKILL_setchar[SKILL_DATACHARNUM]={ +}; + + + + +static char SKILL_dataString[STRINGBUFSIZ]; + +char* SKILL_makeStringFromSkillData( Skill* sk ) +{ + int i; + int strlength=0; + + for( i = 0 ; i < SKILL_DATAINTNUM ; i ++ ){ + char linedata[128]; + snprintf( linedata , sizeof(linedata), + "%s=%d" NONCHAR_DELIMITER, + SKILL_setint[i].dumpskill, sk->data[i] ); + + strcpysafe( &SKILL_dataString[strlength], + sizeof( SKILL_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( SKILL_dataString ) )goto RETURN; + } + + for( i = 0 ; i < SKILL_DATACHARNUM ; i ++ ){ + char linedata[128]; + char escapebuffer[128]; + snprintf( linedata, sizeof(linedata), + "%s=%s" NONCHAR_DELIMITER, + SKILL_setchar[i].dumpskill, + makeEscapeString(sk->string[i].string,escapebuffer, + sizeof(escapebuffer))); + + strcpysafe( &SKILL_dataString[strlength], + sizeof( SKILL_dataString ) - strlength, + linedata ); + strlength += strlen( linedata ); + if( strlength > sizeof( SKILL_dataString ) )goto RETURN; + } + +RETURN: + dchop( SKILL_dataString , NONCHAR_DELIMITER ); + + return SKILL_dataString; +} + + +BOOL SKILL_makeSkillFromStringToArg( char* src, Skill* sk ) +{ + int readindex=1; + while( 1 ){ + BOOL ret; + char linebuf[512]; + char first[256]; + char second[256]; + int i; + + + ret = getStringFromIndexWithDelim( src ,NONCHAR_DELIMITER , + readindex, + linebuf, sizeof( linebuf ) ); + if( ret == FALSE ) + break; + + ret = getStringFromIndexWithDelim( linebuf ,"=", 1, + first, sizeof( first ) ); + if( ret == FALSE ) return FALSE; + strcpysafe( second , sizeof( second ), + linebuf + strlen(first) + strlen("=") ); + + for( i = 0 ; i < SKILL_DATAINTNUM ; i ++ ){ + if( strcmp(first ,SKILL_setint[i].dumpskill) == 0 ){ + sk->data[i] = atoi( second ); + goto NEXT; + } + } + + for( i = 0 ; i < SKILL_DATACHARNUM ; i ++ ){ + if( strcmp(first ,SKILL_setchar[i].dumpskill) == 0 ){ + strcpysafe( sk->string[i].string, + sizeof(sk->string[i].string), + makeStringFromEscaped(second) ); + goto NEXT; + } + } + + fprint( "??? : %s[%s]\n" , linebuf, first ); + + NEXT: + readindex++; + } + + return TRUE; +} + +#ifdef _CHAR_PROFESSION // WON ADD 人物职业 +INLINE int SKILL_getRealInt( Skill* skill, int element) +{ + return skill->data[element]; +} +#endif + +INLINE int SKILL_getInt( Skill* skill, int element) +{ + int value = skill->data[element]; + + if( element == SKILL_LEVEL ) value /= 100; + + return value; +} + + +INLINE int SKILL_setInt( Skill* skill, int element, int new) +{ + int buf = SKILL_getInt( skill, element ); + skill->data[element] = new; + return buf; +} + +#ifndef _PROFESSION_SKILL // WON ADD 人物职业技能 +static void SKILL_setitemlimit( int charaindex, Skill* sk ); +static void SKILL_setmerchant( int charaindex, Skill* sk ); +static void SKILL_setlevel( int charaindex, Skill* sk ); +#endif + +static SKILL_table SKILL_tbl[]={ + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + { 100, NULL}, // 1 + { 100, NULL}, + { 100, NULL}, + { 100, NULL}, + { 100, NULL}, + { 100, NULL}, + { 100, NULL}, + { 100, NULL}, + { 100, NULL}, + { 100, NULL}, + { 100, NULL}, + { 100, NULL}, + { 100, NULL}, + { 100, NULL}, + { 100, NULL}, + { 100, NULL}, // 16 +#else + {8,SKILL_setlevel}, /* SKILL_FIRE */ + {4,NULL}, /* SKILL_MAGICIAN */ + {4,NULL}, /* SKILL_PREIST */ + {8,SKILL_setitemlimit}, /* SKILL_ALOTOFTHINGS */ + {8,NULL}, /* SKILL_AVOIDRATEUP */ + {4,SKILL_setlevel}, /* SKILL_DETERMINEITEM */ + {5,SKILL_setlevel}, /* SKILL_DETERMINEOTHERS */ + {8,SKILL_setmerchant}, /* SKILL_MERCHANT */ + {8,SKILL_setlevel}, /* SKILL_HEALER */ + {8,SKILL_setlevel}, /* SKILL_LARGEVOICE */ +#endif +}; + + +#ifndef _PROFESSION_SKILL // WON ADD 人物职业技能 +static void SKILL_setitemlimit( int charaindex, Skill* sk ) +{ + static int itemlimit[9]={ + 7 + 8 + 4*0, + 7 + 8 + 4*1, + 7 + 8 + 4*2, + 7 + 8 + 4*3, + 7 + 8 + 4*4, + 7 + 8 + 4*5, + 7 + 8 + 4*6, + 7 + 8 + 4*7, + 7 + 8 + 4*8, + }; + int level; + if( !CHAR_CHECKINDEX(charaindex) )return; + if( sk->data[SKILL_IDENTITY] != SKILL_ALOTOFTHINGS )return; + level = sk->data[SKILL_LEVEL]; + if( level < 0 )level = 0; + if( level>=arraysizeof(itemlimit) ) level=arraysizeof(itemlimit) - 1; +} + + +static void SKILL_setmerchant( int charaindex, Skill* sk ) +{ + int level; + int merchantlevel=0; + + if( !CHAR_CHECKINDEX(charaindex) )return; + if( sk->data[SKILL_IDENTITY] != SKILL_MERCHANT )return; + + level = sk->data[SKILL_LEVEL]; + if( level < 0 )level = 0; + if( level >= SKILL_tbl[sk->data[SKILL_IDENTITY]].maxlevel ) + level = SKILL_tbl[sk->data[SKILL_IDENTITY]].maxlevel; + + SETHIGHVALUE(merchantlevel,(100 - level*5)); + SETLOWVALUE(merchantlevel,(20 + level*5)); + + CHAR_setInt( charaindex,CHAR_MERCHANTLEVEL,merchantlevel ); +} + + +static void SKILL_setlevel( int charaindex, Skill* sk ) +{ + static struct skillvalset + { + SKILL_ID id; + CHAR_DATAINT charadataindex; + } skvalset[] = { + { SKILL_DETERMINEITEM, CHAR_DETERMINEITEM }, + { SKILL_DETERMINEOTHERS, CHAR_RADARSTRENGTH }, + { SKILL_HEALER, CHAR_HEALERLEVEL }, + { SKILL_LARGEVOICE, CHAR_CHATVOLUME }, + }; + int id; + int i; + int index=-1; + int level; + + if( !CHAR_CHECKINDEX(charaindex) )return; + id = sk->data[SKILL_IDENTITY]; + for( i=0 ; idata[SKILL_LEVEL]; + if( level < 0 )level = 0; + if( level >= SKILL_tbl[id].maxlevel ) + level = SKILL_tbl[id].maxlevel; + + CHAR_setInt(charaindex,skvalset[index].charadataindex,level ); +} +#endif + + + + + +#define SKILLSTRINGBUFSIZ 256 + +static char ITEM_statusStringBuffer[SKILLSTRINGBUFSIZ]; + + +#ifdef _CHAR_PROFESSION // WON ADD 人物职业 +char* SKILL_makeSkillStatusString( Skill* skill, int charaindex, int skill_num ) +{ + int skillindex=SKILL_getInt( skill,SKILL_IDENTITY); + int Pskill=PROFESSION_SKILL_getskillArray( skillindex); + int skill_level=0, cost_mp=0; + + // 人物技能等级 + skill_level = SKILL_getInt( skill, SKILL_LEVEL); + + // 耗费MP + if( (cost_mp = PROFESSION_MAGIC_COST_MP( charaindex, skill_num )) == -1 ) + cost_mp = PROFESSION_SKILL_getInt( Pskill, PROFESSION_SKILL_COST_MP); + + snprintf( ITEM_statusStringBuffer, sizeof( ITEM_statusStringBuffer ), + "%d|%d|%d|%d|%d|%d|%d|%s|%s", + PROFESSION_SKILL_getInt( Pskill, PROFESSION_SKILL_USE_FLAG), + SKILL_getInt(skill,SKILL_IDENTITY), + PROFESSION_SKILL_getInt( Pskill, PROFESSION_SKILL_TARGET), + PROFESSION_SKILL_getInt( Pskill, PROFESSION_SKILL_KIND), + PROFESSION_SKILL_getInt( Pskill, PROFESSION_SKILL_ICON), + cost_mp, + skill_level, + PROFESSION_SKILL_getChar( Pskill, PROFESSION_SKILL_NAME), + PROFESSION_SKILL_getChar( Pskill, PROFESSION_SKILL_TXT) ); + + + return ITEM_statusStringBuffer; +} +#else +char* SKILL_makeSkillStatusString( Skill* skill ) +{ + snprintf( ITEM_statusStringBuffer, + sizeof( ITEM_statusStringBuffer ), + "%d|%d", + SKILL_getInt(skill,SKILL_IDENTITY), + SKILL_getInt(skill,SKILL_LEVEL) ); + + + return ITEM_statusStringBuffer; +} +#endif + + + +char* SKILL_makeSkillFalseString( void ) +{ + snprintf( ITEM_statusStringBuffer, + sizeof( ITEM_statusStringBuffer ), + "|" ); + return ITEM_statusStringBuffer; +} + + +BOOL SKILL_CHECKID( int skillid ) +{ + if( SKILL_NUM <= skillid && skillid > 0 )return FALSE; + return TRUE; +} + +BOOL SKILL_makeSkillData( Skill* sk ,int skid, int lev ) +{ + sk->data[SKILL_LEVEL] = lev; + sk->data[SKILL_IDENTITY] = skid; + + return TRUE; +} + +int SKILL_levelup( Skill* sk ) +{ + int id = sk->data[SKILL_IDENTITY]; + if( !SKILL_CHECKID(id) )return -1; + sk->data[SKILL_LEVEL] ++; + sk->data[SKILL_LEVEL] = min( sk->data[SKILL_LEVEL], + SKILL_tbl[id].maxlevel ); + return TRUE; +} + +int SKILL_getLevelFromSkillID( int charaindex, SKILL_ID id ) +{ + int i; + if( !CHAR_CHECKINDEX(charaindex) )return -1; + for( i=0 ; iuse && sk->skill.data[SKILL_IDENTITY] == id ) + return sk->skill.data[SKILL_LEVEL]; + + } + return -1; +} + +BOOL SKILL_getUpableSkillID( int charaindex,char* buf, int buflen ) +{ + int i; + if( !CHAR_CHECKINDEX(charaindex)) return FALSE; + if( buflen <= 0 )return FALSE; + buf[0] = '\0'; + for( i=0 ; iuse + && SKILL_CHECKID(chsk->skill.data[SKILL_IDENTITY]) + && chsk->skill.data[SKILL_LEVEL] + < SKILL_tbl[chsk->skill.data[SKILL_IDENTITY]].maxlevel ){ + char tmpbuf[512]; + snprintf( tmpbuf,sizeof(tmpbuf),"%d|", + chsk->skill.data[SKILL_IDENTITY] ); + strcatsafe( buf, buflen,tmpbuf ); + } + } + dchop(buf,"|"); + return TRUE; +} + +void SKILL_skillEffect( int charaindex ) +{ + int i; + if( !CHAR_CHECKINDEX(charaindex) )return; + + if( CHAR_getInt(charaindex,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER) + return; + + for( i=0 ; iuse == FALSE )continue; + + skill = &cskill->skill; + id = skill->data[SKILL_IDENTITY]; + if( !SKILL_CHECKID(id) )continue; + + skfunc = (SKILLEFFECTFUNC)SKILL_tbl[id].effectfunc; + if( skfunc )skfunc(charaindex,skill); + } +} + + + +#ifdef _CHAR_PROFESSION // WON ADD 人物职业 +// 取使用魔法耗费MP +int PROFESSION_MAGIC_COST_MP( int charaindex, int skill_num ) +{ + int skill_level=0, dec_mp=0; + int Pskillid, skillid; + char *skill_name; + CHAR_HaveSkill* hskill; + + // 人物技能 + skillid = CHAR_getCharSkill( charaindex, skill_num); + Pskillid = PROFESSION_SKILL_getskillArray( skillid); + if( Pskillid == -1 ) return FALSE; + + // 技能名称 + skill_name = PROFESSION_SKILL_getChar( Pskillid, PROFESSION_SKILL_FUNCNAME); + + // 技能等级 + hskill = CHAR_getCharHaveSkill( charaindex, skill_num ); + skill_level = SKILL_getInt( &hskill->skill, SKILL_LEVEL); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_M( skill_level ); + + if( (strcmp( skill_name, "PROFESSION_VOLCANO_SPRINGS" )) == 0 ){ // 火山泉 + if( skill_level >= 10 ) dec_mp = 35; + else if( skill_level >= 7 ) dec_mp = 30; + else if( skill_level >= 5 ) dec_mp = 20; + else if( skill_level >= 3 ) dec_mp = 15; + else dec_mp = 10; + }else + if( (strcmp( skill_name, "PROFESSION_FIRE_BALL" )) == 0 ){ // 火星球 + if( skill_level >= 9 ) dec_mp = 50; + else if( skill_level >= 7 ) dec_mp = 45; + else if( skill_level >= 5 ) dec_mp = 40; + else if( skill_level >= 3 ) dec_mp = 35; + else dec_mp = 30; + }else + if( (strcmp( skill_name, "PROFESSION_SUMMON_THUNDER" )) == 0 ){ // 召雷术 + if( skill_level >= 8 ) dec_mp = 30; + else if( skill_level >= 5 ) dec_mp = 25; + else if( skill_level >= 3) dec_mp = 20; + else dec_mp = 10; + }else + if( (strcmp( skill_name, "PROFESSION_CURRENT" )) == 0 ){ // 电流术 +#ifdef _PROFESSION_ADDSKILL + if( skill_level >= 10 ) dec_mp = 100; + else if( skill_level > 9 ) dec_mp = 90; + else if( skill_level > 8 ) dec_mp = 80; + else if( skill_level > 7 ) dec_mp = 70; + else if( skill_level > 6 ) dec_mp = 60; + else if( skill_level > 4 ) dec_mp = 50; + else if( skill_level > 2 ) dec_mp = 40; + else dec_mp = 30; +#else + if( skill_level >= 9 ) dec_mp = 80; + else if( skill_level >= 7 ) dec_mp = 60; + else if( skill_level >= 5 ) dec_mp = 50; + else if( skill_level >= 3 ) dec_mp = 40; + else dec_mp = 30; +#endif + }else + if( (strcmp( skill_name, "PROFESSION_STORM" )) == 0 ){ // 暴风雨 +#ifdef _PROFESSION_ADDSKILL + if( skill_level > 8 ) dec_mp = 50; + else if( skill_level > 6 ) dec_mp = 45; + else if( skill_level > 4 ) dec_mp = 40; + else if( skill_level > 2 ) dec_mp = 35; + else dec_mp = 30; +#else + if( skill_level >= 10 ) dec_mp = 80; + else if( skill_level >= 6 ) dec_mp = 70; + else if( skill_level >= 5 ) dec_mp = 60; + else dec_mp = 50; +#endif + }else + if( (strcmp( skill_name, "PROFESSION_ICE_ARROW" )) == 0 ){ // 冰箭术 + if( skill_level >= 8) dec_mp = 20; + else if( skill_level >= 4 ) dec_mp = 15; + else dec_mp = 10; + }else + if( (strcmp( skill_name, "PROFESSION_ICE_CRACK" )) == 0 ){ // 冰爆术 +#ifdef _PROFESSION_ADDSKILL + if( skill_level >= 10 ) dec_mp = 80; + else if( skill_level > 8 ) dec_mp = 70; + else if( skill_level > 6 ) dec_mp = 60; + else if( skill_level > 4 ) dec_mp = 50; + else if( skill_level > 2 ) dec_mp = 40; + else dec_mp = 30; +#else + if( skill_level >= 9 ) dec_mp = 70; + else if( skill_level >= 7 ) dec_mp = 60; + else if( skill_level >= 5 ) dec_mp = 50; + else if( skill_level >= 3 ) dec_mp = 40; + else dec_mp = 30; +#endif + }else + if( (strcmp( skill_name, "PROFESSION_DOOM" )) == 0 ){ // 世界末日 + if( skill_level > 8 ) dec_mp = 150; + else if( skill_level > 4 ) dec_mp = 100; + else dec_mp = 50; + }else + if( (strcmp( skill_name, "PROFESSION_FIRE_SPEAR" )) == 0 ){ // 火龙枪 + if( skill_level > 8 ) dec_mp = 80; + else if( skill_level > 6 ) dec_mp = 70; + else if( skill_level > 4 ) dec_mp = 60; + else if( skill_level > 2 ) dec_mp = 40; + else dec_mp = 30; + }else + if( (strcmp( skill_name, "PROFESSION_BLOOD_WORMS" )) == 0 ){ // 嗜血蛊 + if( skill_level >= 10 ) dec_mp = 15; + else if( skill_level >= 5 ) dec_mp = 10; + else dec_mp = 5; + }else + if( (strcmp( skill_name, "PROFESSION_SIGN" )) == 0 ){ // 一针见血 + + if( skill_level >= 8 ) dec_mp = 10; + else dec_mp = 5; + + }else + if( (strcmp( skill_name, "PROFESSION_ENCLOSE" )) == 0 ){ // 附身术 + if( skill_level >= 10 ) dec_mp = 80; + else if( skill_level >= 8 ) dec_mp = 70; + else if( skill_level >= 5) dec_mp = 60; + else dec_mp = 50; + }else + if( (strcmp( skill_name, "PROFESSION_ICE_MIRROR" )) == 0 ){ // 冰镜术 + if( skill_level >= 9 ) dec_mp = 40; + else if( skill_level >= 7 ) dec_mp = 35; + else if( skill_level >= 5 ) dec_mp = 30; + else if( skill_level >= 3 ) dec_mp = 25; + else dec_mp = 20; + }else + if( (strcmp( skill_name, "PROFESSION_FIRE_ENCLOSE" )) == 0 ){ // 火附体 + if( skill_level >= 10 ) dec_mp = 50; + else if( skill_level >= 7 ) dec_mp = 40; + else if( skill_level >= 4 ) dec_mp = 30; + else dec_mp = 20; + }else + if( (strcmp( skill_name, "PROFESSION_ICE_ENCLOSE" )) == 0 ){ // 冰附体 + if( skill_level >= 10 ) dec_mp = 50; + else if( skill_level >= 7 ) dec_mp = 40; + else if( skill_level >= 4 ) dec_mp = 30; + else dec_mp = 20; + }else + if( (strcmp( skill_name, "PROFESSION_THUNDER_ENCLOSE" )) == 0 ){ // 雷附体 + if( skill_level >= 10 ) dec_mp = 50; + else if( skill_level >= 7 ) dec_mp = 40; + else if( skill_level >= 4 ) dec_mp = 30; + else dec_mp = 20; + }else + if( (strcmp( skill_name, "PROFESSION_TRANSPOSE" )) == 0 ){ // 移形换位 + if( skill_level >= 10 ) dec_mp = 50; + else if( skill_level >= 9 ) dec_mp = 40; + else if( skill_level >= 7 ) dec_mp = 30; + else if( skill_level >= 4 ) dec_mp = 20; + else dec_mp = 10; + }else +#ifdef _PROFESSION_ADDSKILL + if( (strcmp( skill_name, "PROFESSION_RESIST_F_I_T" )) == 0 ){ // 自然威能 + if( skill_level >= 10 ) dec_mp = 20; + else if( skill_level >= 9 ) dec_mp = 15; + else if( skill_level >= 6 ) dec_mp = 10; + else dec_mp = 5; + }else + if( (strcmp( skill_name, "PROFESSION_CALL_NATURE" )) == 0 ){ // 号召自然 + + /*skill_level = SKILL_getInt( &hskill->skill, SKILL_LEVEL); + if( skill_level >= 100 ) dec_mp = 50; + else if( skill_level > 95 ) dec_mp = 50; + else if( skill_level > 90 ) dec_mp = 50; + else if( skill_level > 85 ) dec_mp = 50; + else if( skill_level > 80 ) dec_mp = 50; + else if( skill_level > 60 ) dec_mp = 50; + else if( skill_level > 40 ) dec_mp = 50; + else if( skill_level > 20 ) dec_mp = 50; + else dec_mp = 50;*/ + dec_mp = 50; + }else + if( (strcmp( skill_name, "PROFESSION_BOUNDARY" )) == 0 ){ // 四属性结界 + char *pszP=NULL; + if( skill_level > 9 ) dec_mp = 20; + else if( skill_level > 6 ) dec_mp = 15; + else dec_mp = 10; + //破除结界耗损mp与其他结界不同 + if( (pszP = strstr( PROFESSION_SKILL_getChar( Pskillid, PROFESSION_SKILL_OPTION), "破结界" ) ) != NULL ){// 技能的参数 + if( skill_level >= 9 ) dec_mp = 20; + else if( skill_level > 4 ) dec_mp = 15; + else if( skill_level > 2 ) dec_mp = 10; + else dec_mp = 5; + } + }else +#endif + { + return -1; + } + + return dec_mp; +} + + +INLINE int PROFESSION_CHANGE_SKILL_LEVEL_M( int skill_level ) +{ + if( skill_level > 90 )skill_level = 10; + else if( skill_level > 80 ) skill_level = 9; + else if( skill_level > 70 ) skill_level = 8; + else if( skill_level > 60 ) skill_level = 7; + else if( skill_level > 50 ) skill_level = 6; + else if( skill_level > 40 ) skill_level = 5; + else if( skill_level > 30 ) skill_level = 4; + else if( skill_level > 20 ) skill_level = 3; + else if( skill_level > 10 ) skill_level = 2; + else skill_level = 1; + + return skill_level; +} + + +INLINE int PROFESSION_CHANGE_SKILL_LEVEL_A( int skill_level ) +{ + if( skill_level >= 100 ) skill_level = 10; + else if( skill_level > 90 ) skill_level = 9; + else if( skill_level > 80 ) skill_level = 8; + else if( skill_level > 70 ) skill_level = 7; + else if( skill_level > 60 ) skill_level = 6; + else if( skill_level > 50 ) skill_level = 5; + else if( skill_level > 40 ) skill_level = 4; + else if( skill_level > 30 ) skill_level = 3; + else if( skill_level > 20 ) skill_level = 2; + else if( skill_level > 10 ) skill_level = 1; + else skill_level = 0; + + return skill_level; +} +#endif + diff --git a/gmsv/char/title.c b/gmsv/char/title.c new file mode 100644 index 0000000..ce08969 --- /dev/null +++ b/gmsv/char/title.c @@ -0,0 +1,1083 @@ +#include "version.h" +#include +#include +#include +#include +#ifdef _REDHAT_V9 +#include +#endif + +#include "title.h" +#include "char.h" +#include "char_base.h" +#include "item.h" +#include "skill.h" +#include "buf.h" +#include "util.h" +#include "configfile.h" + + +/*====================惫寞 ====================*/ +static int TITLE_IntCheck( int charaindex,int elem, int *data, int flg); +static int TITLE_WorkIntCheck( int charaindex,int elem, int *data, int flg); +static int TITLE_ItemCheck( int charaindex,int elem, int *data, int flg); +static int TITLE_ItemEquipCheck( int charaindex,int elem, int *data, int flg); +static int TITLE_SkillCheck( int charaindex,int elem, int *data, int flg); +static int TITLE_SexCheck( int charaindex,int elem, int *data, int flg); + +typedef enum +{ + TITLE_FUNCTYPENONE, /* 楮醒戏岳仄卅中 */ + TITLE_FUNCTYPEUSERFUNC, /* definefunction 毛银匀化 蟆毛综月 + * 楮醒及娄醒反 + * int 平乓仿奶件犯永弁旦 + * buf 蟆尺及田永白央 + * buflen 公及田永白央及赢今 + */ + TITLE_USEFUNCTYPENUM +}TITLE_USEFUNCTYPE; + +typedef struct tagTITLE_Table +{ + int index; /* 蛙犯□正午询晶毛潸月凶户[ + * 仇及 寞匹手匀化addtitle午井支月 + */ + char name[32]; + TITLE_USEFUNCTYPE functype; + void (*definefunction)(int,char* buf,int buflen); +}TITLE_Table; + +/* 银尹月由仿丢□正 + * STR,TGH,MAXMP]ATK,DEF + * LEVEL,CLASS,SKILL,ITEM,FIREREG,ICEREG,THUNDERREG + * KANJILV,TALKCNT,WALKCNT,DEADCNT,LOGINCNT,BASEIMAGENUMBER + * GOLD +*/ +typedef struct tagTITLE_Compare { + char compare[8];; +} TITLE_COMPARE; + +TITLE_COMPARE TITLE_compare[] = { {"<="}, {">="},{"<>"}, {">"},{"<"},{"="}}; + +typedef struct tagTITLE_PARAM +{ + int element; + int (*checkfunc)( int charaindex,int elem, int *data, int flg ); + char *paramname; +}TITLE_PARAM; + +TITLE_PARAM TITLE_param[] = +{ + /**** 仇仇井日 ****/ + { -1, TITLE_ItemCheck, "ITEM" }, + { -1, TITLE_ItemEquipCheck,"EQUIPITEM" }, + { -1, NULL, "EQUIPEVENT" }, + /**** 仇仇引匹反 凳仄卅中匹仁分今中[ ****/ + { -1, TITLE_SkillCheck, "SKILL" }, + { CHAR_STR, TITLE_IntCheck, "STR" }, + { CHAR_TOUGH, TITLE_IntCheck, "TGH" }, + { CHAR_MAXMP, TITLE_IntCheck, "MAXMP" }, + { CHAR_WORKFIXSTR, TITLE_WorkIntCheck, "ATK" }, + { CHAR_WORKFIXTOUGH, TITLE_WorkIntCheck, "DEF" }, + { CHAR_LV, TITLE_IntCheck, "LEVEL" }, + { CHAR_TALKCOUNT, TITLE_IntCheck, "TALKCNT" }, + { CHAR_WALKCOUNT, TITLE_IntCheck, "WALKCNT" }, + { CHAR_DEADCOUNT, TITLE_IntCheck, "DEADCNT" }, + { CHAR_LOGINCOUNT, TITLE_IntCheck, "LOGINCNT" }, + { CHAR_BASEBASEIMAGENUMBER,TITLE_IntCheck, "BASEIMAGENUMBER" }, + { CHAR_GOLD, TITLE_IntCheck, "GOLD" }, + { -1, TITLE_SexCheck, "SEX" }, +}; + +#define TITLE_PARAMSIZE 20 +typedef struct tagTITLE_configTable +{ + int paramindex[20]; /* TITLE_param尺及骄侬 */ + int param[20][TITLE_PARAMSIZE]; /* 笠袄 */ + int compareflg[20]; /* ><=羁升丹允月井 */ + int title; + BOOL equipcheckflg; /* + * 失奶 丞啖 奶矛件玄匹反仇及白仿弘及 匀化中月 + * 手及仄井腹绸仄卅中[ + */ +}TITLE_CONFIGTABLE; + +typedef struct tagTITLE_configbuf +{ + int title; + int flg; +}TITLE_CONFIGBUF; + +static TITLE_CONFIGTABLE *TITLE_ConfigTable; +static TITLE_Table *TITLE_table; +static TITLE_CONFIGBUF *TITLE_configbuf; +static int TITLE_titlenum; +static int TITLE_titlecfgnum; + +/*------------------------------------------------------------ + * index 寞井日TITLE_table及骄侬毛 月 + ------------------------------------------------------------*/ +int TITLE_getTitleIndex( int index) +{ + int i; + if( index < 0 ) return -1; + for( i = 0; i < TITLE_titlenum; i ++ ) { + if( TITLE_table[i].index == index ) { + return( i); + } + } + return -1; +} + +/* 田永白央及扔奶术 */ +#define TITLESTRINGBUFSIZ 256 +/* 弁仿奶失件玄卞苇六月旦平伙犯□正及 侬 及田永白央 */ +static char TITLE_statusStringBuffer[TITLESTRINGBUFSIZ]; +/*------------------------------------------------------------ + * 弁仿奶失件玄卞苇六月惫寞及 侬 毛综月 + * 娄醒 + * title Title* 旦平伙 + * charaindex int 仇及惫寞毛 匀化中月平乓仿及奶件犯永弁旦 + * 忒曰袄 + * char* + ------------------------------------------------------------*/ +char* TITLE_makeTitleStatusString( int charaindex,int havetitleindex ) +{ + int attach; + int index; + /* 楮醒 尺及奶件犯永弁旦井日犯□正毛综岳允月 */ + index = CHAR_getCharHaveTitle( charaindex,havetitleindex ); +#if 0 + if( TITLE_CHECKTABLEINDEX( index ) == FALSE ){ + TITLE_statusStringBuffer[0] = '\0'; + return TITLE_statusStringBuffer; + } +#endif + attach = TITLE_getTitleIndex( index); + if( attach == -1 ) { + TITLE_statusStringBuffer[0] = '\0'; + return TITLE_statusStringBuffer; + } + switch( TITLE_table[attach].functype ){ + case TITLE_FUNCTYPENONE: + snprintf( TITLE_statusStringBuffer, + sizeof(TITLE_statusStringBuffer ),"%s" , + TITLE_table[attach].name ); + break; + + case TITLE_FUNCTYPEUSERFUNC: + { + char string[256]={""}; + void (*function)(int,char* buf,int buflen); + function = TITLE_table[attach].definefunction; + if( function ) + function( charaindex,string,sizeof(string) ); + + strcpysafe( TITLE_statusStringBuffer, + sizeof(TITLE_statusStringBuffer ),string ); + } + break; + default: + TITLE_statusStringBuffer[0] = '\0'; + return TITLE_statusStringBuffer; + break; + } + return TITLE_statusStringBuffer; +} + +/*------------------------------------------------------------ + * 卅中惫寞及 侬 犯□正毛忒允 + * 娄醒 + * 卅仄 + * 忒曰袄 + * char* + ------------------------------------------------------------*/ +char* TITLE_makeSkillFalseString( void ) +{ + TITLE_statusStringBuffer[0]= '\0'; + return TITLE_statusStringBuffer; +} + + +/*------------------------------------------------------------ + * 隙烂今木凶 寞及惫寞毛馨笛允月[褐今卅匀化中凶日}馨笛仄卅中 + * 娄醒 + * charaindex int 平乓仿奶件犯永弁旦 + * titleindex int 惫寞奶件犯永弁旦 + * 忒曰袄 + * 馨笛仄凶index + * 馨笛仄卅井匀凶 FALSE(0) + ------------------------------------------------------------*/ +BOOL TITLE_addtitle( int charaindex, int titleindex ) +{ + int i; + int firstfindempty=-1; + + if( CHAR_CHECKINDEX(charaindex) == FALSE )return FALSE; + /*if( TITLE_CHECKTABLEINDEX(titleindex) == FALSE )return FALSE;*/ + if( TITLE_getTitleIndex( titleindex) == -1 ) return FALSE; + + for( i=0 ; i < CHAR_TITLEMAXHAVE ; i++ ){ + if( CHAR_getCharHaveTitle( charaindex,i ) == titleindex ) + /* 允匹卞 匀化中月井日窒手仄卅中 */ + return FALSE; + if( firstfindempty == -1 + && CHAR_getCharHaveTitle(charaindex,i) == -1 ){ + firstfindempty = i; + } + } + return CHAR_setCharHaveTitle( charaindex,firstfindempty,titleindex ); +} + + +/*------------------------------------------------------------ + * 隙烂今木凶 寞及惫寞互丐匀凶日绰轮允月[卅井匀凶日窒手仄卅中[ + * 醒蜊丐匀凶日蝈 壅允[ + * 娄醒 + * charaindex int 平乓仿奶件犯永弁旦 + * titleindex int 惫寞奶件犯永弁旦 + * 忒曰袄 + * 绰轮仄凶 TRUE(1) + * 绰轮仄卅井匀凶 FALSE(0) + ------------------------------------------------------------*/ +BOOL TITLE_deltitle( int charaindex, int titleindex ) +{ + int i; + BOOL del=FALSE; + int index; + if( CHAR_CHECKINDEX(charaindex) == FALSE )return FALSE; + /*if( TITLE_CHECKTABLEINDEX(titleindex) == FALSE )return FALSE;*/ + index = TITLE_getTitleIndex( titleindex); + if( index == -1 ) return FALSE; + + for( i=0 ; i < CHAR_TITLEMAXHAVE ; i++ ) + if( CHAR_getCharHaveTitle( charaindex,i ) == titleindex ){ + /* 愤坌互银匀化中凶支勾卅日壬}公木手卅仄卞允月 */ + if( CHAR_getInt(charaindex, CHAR_INDEXOFEQTITLE) == i ){ + CHAR_setInt(charaindex, CHAR_INDEXOFEQTITLE, -1 ); + } + /* 匀化中月井日壅允 */ + CHAR_setCharHaveTitle( charaindex,i,-1); + + del = TRUE; + } + + return del; +} +/*------------------------------------------------------------ + * 惫寞及赓渝祭毛允月[ + * 娄醒 + * filename char* 涩烂白央奶伙 + * 忒曰袄 + * 岳 TRUE(1) + * 撩 FALSE(0) + *------------------------------------------------------------*/ +BOOL TITLE_initTitleName( char* filename ) +{ + FILE* f; + char line[256]; + int linenum=0; + int title_readlen=0; + + f = fopen(filename,"r"); + if( f == NULL ){ + errorprint; + return FALSE; + } + + TITLE_titlenum=0; + + /* 引内 躲卅垫互窒垫丐月井升丹井譬屯月 */ + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + + TITLE_titlenum++; + } + + if( fseek( f, 0, SEEK_SET ) == -1 ){ + fprint( "寻找错误\n" ); + fclose(f); + return FALSE; + } + + TITLE_table = allocateMemory( sizeof(struct tagTITLE_Table) + * TITLE_titlenum ); + if( TITLE_table == NULL ){ + fprint( "无法分配内存 %d\n" , + sizeof(TITLE_table)*TITLE_titlenum); + fclose( f ); + return FALSE; + } + /* 赓渝祭 */ +{ + int i; + for( i = 0; i < TITLE_titlenum; i ++ ) { + TITLE_table[i].index = -1; + TITLE_table[i].name[0] = '\0'; + TITLE_table[i].functype = TITLE_FUNCTYPENONE; + TITLE_table[i].definefunction = NULL; + } + +} + + /* 引凶 心 允 */ + linenum = 0; + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + + /* 垫毛帮溥允月 */ + /* 引内 tab 毛 " " 卞 五晶尹月 */ + replaceString( line, '\t' , ' ' ); + /* 燮 及旦矢□旦毛潸月[*/ +{ + int i; + char buf[256]; + for( i = 0; i < strlen( line); i ++) { + if( line[i] != ' ' ) { + break; + } + strcpy( buf, &line[i]); + } + if( i != 0 ) { + strcpy( line, buf); + } +} +{ + char token[256]; + int ret; + + /* 夫午勾户及玄□弁件毛苇月 */ + ret = getStringFromIndexWithDelim( line,",",1,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + continue; + } + TITLE_table[title_readlen].index = atoi(token); + + /* 2勾户及玄□弁件毛苇月 */ + ret = getStringFromIndexWithDelim( line,",",2,token, + sizeof(token)); + if( ret==FALSE ){ + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + continue; + } + if( strlen( token) > sizeof( TITLE_table[title_readlen].name)-1) { + fprint("警告! 头衔名称结束文件:%s 第%d行\n", + filename, linenum); + } + strcpysafe( TITLE_table[title_readlen].name, + sizeof( TITLE_table[title_readlen].name), + token); + + title_readlen ++; +} + } + fclose(f); + + TITLE_titlenum = title_readlen; + + print( "有效头衔名称数是 %d...", TITLE_titlenum ); + +#ifdef DEBUG + + { + int i; + for( i=0; i ="); + if( comppos == -1 ) { + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + TITLE_initTitleData( titlecfg_readlen); + errflg = TRUE; + break;; + } + /* 羁寞]尕羁寞互ㄡ勾动晓 月午五 */ + if( charInclude( &token[comppos+1], "<>=") != -1 ) { + /* 升氏卅 胜井毛 戈 */ + for( j = 0; j < 3; j ++ ) { + if( memcmp( TITLE_compare[j].compare, &token[comppos], 2 ) == 0 ) { + break; + } + } + if( j == 3 ) { + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + TITLE_initTitleData( titlecfg_readlen); + errflg = TRUE; + break; + } + else { + ret = TITLE_getParamData( titlecfg_readlen,i-1,&token[comppos+2]); + if( !ret ) { + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + TITLE_initTitleData( titlecfg_readlen); + errflg = TRUE; + break; + } + + /*TITLE_ConfigTable[titlecfg_readlen].param[i-1] + = atoi( &token[comppos+2]);*/ + TITLE_ConfigTable[titlecfg_readlen].compareflg[i-1] = j; + } + } + else { + ret = TITLE_getParamData( titlecfg_readlen,i-1,&token[comppos+1]); + if( !ret ) { + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + TITLE_initTitleData( titlecfg_readlen); + errflg = TRUE; + break; + } + /*TITLE_ConfigTable[titlecfg_readlen].param[i-1] + = atoi( &token[comppos+1]);*/ + /* 升氏卅 胜井毛 戈 */ + for( j = 3; j < 6; j ++ ) { + if( memcmp( TITLE_compare[j].compare, &token[comppos], 1 ) == 0 ) { + TITLE_ConfigTable[titlecfg_readlen].compareflg[i-1] = j; + break; + } + } + } + } + } + /* 惫寞 隙烂互 井匀凶 or 卅氏井仄日及巨仿□*/ + if( errflg || TITLE_ConfigTable[titlecfg_readlen].title == -1 ) { + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + TITLE_initTitleData( titlecfg_readlen); + } + else { + titlecfg_readlen ++; + } +} + } + fclose(f); + + TITLE_titlecfgnum = titlecfg_readlen; + + print( "有效头衔配置数是 %d...", TITLE_titlecfgnum ); + +#if 0 + + { + int i, j; + for( i=0; i < TITLE_titlecfgnum ; i++ ) { + print( "头衔队列[%d]\n", i); + for( j = 0; + j < arraysizeof( TITLE_ConfigTable[i].param) && + TITLE_ConfigTable[i].param[j] != -1 ; + j ++ ) + { + print( "name[%s] data[%d] flg[%s] ", + TITLE_param[TITLE_ConfigTable[i].paramindex[j]].paramname, + TITLE_ConfigTable[i].param[j], + TITLE_compare[TITLE_ConfigTable[i].compareflg[j]].compare + ); + if( j %2 ==0 ) print( "\n"); + } + print( "\nTitleindex [%d] ",TITLE_ConfigTable[i].title); + print( "equipcheckflg [%d]\n",TITLE_ConfigTable[i].equipcheckflg); + } + } +#endif + return TRUE; +} +/*------------------------------------------------------------ + * 惫寞涩烂卞宁丹井譬屯化惫寞毛芨尹月[ + * 娄醒 + * charaindex int 平乓仿奶件犯永弁旦 + * mode BOOL TRUE:item=及手及及心譬屯月 FALSE:蝈 + * 忒曰袄 + * TRUE: 惫寞卞 祭 曰[ + * FALSE:窒手 井匀凶[ + *------------------------------------------------------------*/ +static BOOL TITLE_TitleCheck_Main( int charaindex, BOOL mode, int *addcnt, int *delcnt) +{ + int i, j,k, ret; + + /* 赓渝祭 */ +{ + int i; + for( i = 0; i < TITLE_titlecfgnum && TITLE_configbuf[i].title != -1; i ++ ) { + TITLE_configbuf[i].title = -1; + TITLE_configbuf[i].flg = 0; + } +} + *addcnt = 0; + *delcnt = 0; + + for( i = 0; i < TITLE_titlecfgnum; i ++ ) { + int rc = TRUE; + int title = TITLE_ConfigTable[i].title; + if( mode == TRUE ) { + if( TITLE_ConfigTable[i].equipcheckflg != TRUE ) { + continue; + } + } + for( j = 0; + j < arraysizeof( TITLE_ConfigTable[i].param) && + TITLE_ConfigTable[i].param[j][0] != -1 ; + j ++ ) + { + int index = TITLE_ConfigTable[i].paramindex[j]; + if( TITLE_param[index].checkfunc != NULL ) { + rc = TITLE_param[index].checkfunc( + charaindex, + TITLE_param[index].element, + TITLE_ConfigTable[i].param[j], + TITLE_ConfigTable[i].compareflg[j] + ); + if( rc != TRUE ) break; + } + } + /* 醒椭瘀卞 元惫寞互喃曰癫化日木化中月凛及啃卞] + * 域绎田永白央卞霪户化公及瑛绊井日add,deltile允月 + */ + for( k = 0; k < TITLE_titlecfgnum; k ++ ) { + if( TITLE_configbuf[k].title == title ) { + if( rc ) { + TITLE_configbuf[k].flg = 1; + } + break; + } + else if( TITLE_configbuf[k].title == -1 ) { + TITLE_configbuf[k].title = title; + TITLE_configbuf[k].flg = rc ? 1: -1; + break; + } + } + } + ret = FALSE; + for( i = 0; i < TITLE_titlecfgnum && TITLE_configbuf[i].title != -1; i ++ ) { + if( TITLE_configbuf[i].flg == -1 ) { + *delcnt += TITLE_deltitle( charaindex, TITLE_configbuf[i].title); + } + else { + *addcnt += TITLE_addtitle( charaindex, TITLE_configbuf[i].title) ? 1:0; + } + } + if( *delcnt > 0 || *addcnt > 0) { + ret = TRUE; + } + return ret; + +} +/*------------------------------------------------------------ + * 惫寞涩烂卞宁丹井譬屯化惫寞毛芨尹月[ + * 娄醒 + * charaindex int 平乓仿奶件犯永弁旦 + * mode BOOL TRUE:item=及手及及心譬屯月 FALSE:蝈 + * 忒曰袄 + * TRUE: 惫寞卞 祭 曰[ + * FALSE:窒手 井匀凶[ + *------------------------------------------------------------*/ +BOOL TITLE_TitleCheck( int charaindex, BOOL mode) +{ +#define TITLE_MSGUNIT1 "TSU" +#define TITLE_MSGUNIT2 "KO" + int addcnt,delcnt; + BOOL rc; + char msgbuf[64]; + rc = TITLE_TitleCheck_Main( charaindex, mode, &addcnt,&delcnt); + if( rc ) { + if( delcnt > 0 ) { + snprintf( msgbuf, sizeof( msgbuf), + "失去%d%s 称号!", delcnt, + delcnt < 10 ? TITLE_MSGUNIT1:TITLE_MSGUNIT2); + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORYELLOW); + } + if( addcnt > 0 ) { + snprintf( msgbuf, sizeof( msgbuf), + "获得%d%s 称号!", addcnt, + addcnt < 10 ? TITLE_MSGUNIT1:TITLE_MSGUNIT2); + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORYELLOW); + } + } + return rc; +} +/*------------------------------------------------------------ + * 惫寞涩烂卞宁丹井譬屯化惫寞毛芨尹月[ + * 娄醒 + * charaindex int 平乓仿奶件犯永弁旦 + * mode BOOL TRUE:item=及手及及心譬屯月 FALSE:蝈 + * 忒曰袄 + * TRUE: 惫寞卞 祭 曰[ + * FALSE:窒手 井匀凶[ + *------------------------------------------------------------*/ +BOOL TITLE_TitleCheck_Nomsg( int charaindex, BOOL mode, int *addcnt, int *delcnt) +{ + return( TITLE_TitleCheck_Main( charaindex, mode, addcnt,delcnt)); +} + + +static int TITLE_IntCheck( int charaindex, int elem, int *data, int flg) +{ + int rc = FALSE; + int i; + for( i = 0; i < TITLE_PARAMSIZE && *(data+i) != -1; i ++ ) { + switch( flg) { + case 0: /* "<=" */ + if( CHAR_getInt( charaindex, elem) <= *(data+i) ) rc = TRUE; + break; + case 1: /* ">=" */ + if( CHAR_getInt( charaindex, elem) >= *(data+i) ) rc = TRUE; + break; + case 2: /* "<>" */ + if( CHAR_getInt( charaindex, elem) != *(data+i) ) rc = TRUE; + break; + case 3: /* ">" */ + if( CHAR_getInt( charaindex, elem) > *(data+i) ) rc = TRUE; + break; + case 4: /* "<" */ + if( CHAR_getInt( charaindex, elem) < *(data+i) ) rc = TRUE; + break; + case 5: /* "=" */ + if( CHAR_getInt( charaindex, elem) == *(data+i) ) rc = TRUE; + break; + default: + rc= FALSE; + break; + } + if( rc) break; + } + return rc; +} +static int TITLE_WorkIntCheck( int charaindex,int elem, int *data, int flg) +{ + int rc = FALSE; + int i; + for( i = 0; i < TITLE_PARAMSIZE && *(data+i) != -1; i ++ ) { + switch( flg) { + case 0: /* "<=" */ + if( CHAR_getWorkInt( charaindex, elem) <= *(data+i) ) rc = TRUE; + break; + case 1: /* ">=" */ + if( CHAR_getWorkInt( charaindex, elem) >= *(data+i) ) rc = TRUE; + break; + case 2: /* "<>" */ + if( CHAR_getWorkInt( charaindex, elem) != *(data+i) ) rc = TRUE; + break; + case 3: /* ">" */ + if( CHAR_getWorkInt( charaindex, elem) > *(data +i)) rc = TRUE; + break; + case 4: /* "<" */ + if( CHAR_getWorkInt( charaindex, elem) < *(data+i) ) rc = TRUE; + break; + case 5: /* "=" */ + if( CHAR_getWorkInt( charaindex, elem) == *(data+i) ) rc = TRUE; + break; + default: + rc= FALSE; + break; + } + if( rc ) break; + } + return rc; +} +/* -------------------------------------- + * 隙烂今木凶data午 匀化中月失奶 丞毛 胜允月[ + * -------------------------------------*/ +static int TITLE_ItemCheckMain( int charaindex, int itemhaveindex, int *data, int flg) +{ + int i,j; + int rc = FALSE; + + if( flg == 2 ) rc = TRUE; + + for( j = 0; j < TITLE_PARAMSIZE && *(data+j) != -1; j ++ ) { + for( i =0; i < itemhaveindex; i ++ ) { + int itemindex = CHAR_getItemIndex(charaindex,i); + if( ITEM_CHECKINDEX(itemindex) ) { + switch( flg) { + case 0: /* "<=" */ + if( ITEM_getInt( itemindex, ITEM_ID) <= *(data+j) ) rc = TRUE; + break; + case 1: /* ">=" */ + if( ITEM_getInt( itemindex, ITEM_ID) >= *(data+j) ) rc = TRUE; + break; + case 3: /* ">" */ + if( ITEM_getInt( itemindex, ITEM_ID) > *(data +j)) rc = TRUE; + break; + case 4: /* "<" */ + if( ITEM_getInt( itemindex, ITEM_ID) < *(data +j)) rc = TRUE; + break; + case 5: /* "=" */ + if( ITEM_getInt( itemindex, ITEM_ID) == *(data +j)) rc = TRUE; + break; + /* 仇木分仃 健中[ + * 失奶 丞蝈 毛苇化公木毛 匀化中卅井匀凶日蕞午允月[ + * 仇仇匹反 匀化中月仪毛絮午仄化民尼永弁 + */ + case 2: /* "<>" */ + if( ITEM_getInt( itemindex, ITEM_ID) == *(data +j)) rc = FALSE; + break; + default: + rc= FALSE; + break; + } + if( rc && flg != 2) break; + } + } + if( rc) break; + } + return rc; +} + + +static int TITLE_ItemCheck( int charaindex,int elem, int *data, int flg) +{ + return( TITLE_ItemCheckMain( charaindex, CHAR_MAXITEMHAVE,data,flg)); +} + +static int TITLE_ItemEquipCheck( int charaindex,int elem, int *data, int flg) +{ + return( TITLE_ItemCheckMain( charaindex, CHAR_EQUIPPLACENUM,data,flg)); +} + +static int TITLE_SkillCheck( int charaindex,int elem, int *data, int flg) +{ + int i; + int rc = FALSE; + CHAR_HaveSkill* hskill; + + for( i = 0 ; i < CHAR_SKILLMAXHAVE ; i ++ ){ + hskill = CHAR_getCharHaveSkill( charaindex, i ); + if( hskill != NULL && hskill->use == TRUE ) { + + if( *(data + 1) != -2 ) { + if( SKILL_getInt( &hskill->skill, SKILL_IDENTITY) == *data) { + rc = TRUE; + break; + } + } + + else { + if( SKILL_getInt( &hskill->skill, SKILL_IDENTITY) == *data) { + rc = FALSE; + break; + } + else { + rc = TRUE; + } + } + } + } + if( rc ) { + + if( *(data+1) != -1 && *(data+1) != -2) { + rc = FALSE; + switch( flg) { + case 0: /* "<=" */ + if( SKILL_getInt( &hskill->skill, SKILL_LEVEL) <= *(data+1) ) rc = TRUE; + break; + case 1: /* ">=" */ + if( SKILL_getInt( &hskill->skill, SKILL_LEVEL) >= *(data+1) ) rc = TRUE; + break; + case 2: /* "<>" */ + if( SKILL_getInt( &hskill->skill, SKILL_LEVEL) != *(data+1) ) rc = TRUE; + break; + case 3: /* ">" */ + if( SKILL_getInt( &hskill->skill, SKILL_LEVEL) > *(data +1)) rc = TRUE; + break; + case 4: /* "<" */ + if( SKILL_getInt( &hskill->skill, SKILL_LEVEL) < *(data+1) ) rc = TRUE; + break; + case 5: /* "=" */ + if( SKILL_getInt( &hskill->skill, SKILL_LEVEL) == *(data+1) ) rc = TRUE; + break; + default: + rc= FALSE; + break; + } + } + } + return rc; +} +/* -------------------------------------- + * 裆平乓仿井辉平乓仿井民尼永弁允月[ + * -------------------------------------*/ +static int TITLE_SexCheck( int charaindex,int elem, int *data, int flg) +{ + int i,j; + struct { + int sex[25]; + }s_sex[] = + { { { 30008,30009,30010,30011,30012,30013,30014,30015, + 30020,30021,30022,30023,30024,30025,30026,30027, + 30028,30029,30030,30031,30032,30033,30034,30035,-1} + }, + { {30000,30001,30002,30003,30004,30005,30006,30007, + 30016,30017,30018,30019,30036,30037,30038,30039, + -1, -1, -1, -1, -1, -1, -1, -1, -1} + } + }; + for( i = 0; i < 2; i ++ ) { + for( j = 0; s_sex[i].sex[j] != -1 ; j ++ ) { + if( CHAR_getInt( charaindex, CHAR_BASEBASEIMAGENUMBER ) + == s_sex[i].sex[j] ) + { + if( i == *data ) return TRUE; + else return FALSE; + } + } + } + return FALSE; +} + + diff --git a/gmsv/char/trade.c b/gmsv/char/trade.c new file mode 100644 index 0000000..de5a584 --- /dev/null +++ b/gmsv/char/trade.c @@ -0,0 +1,1942 @@ +#include "version.h" +#include "correct_bug.h" +#include +#include +#include + +#include "readmap.h" +#include "object.h" +#include "char.h" +#include "char_base.h" +#include "lssproto_serv.h" +#include "npcutil.h" +#include "trade.h" +#include "log.h" +#include "handletime.h" +#include "buf.h" +#include "net.h" +#include "char_base.h" +#include "battle.h" +#include "npc_bus.h" +#include "char_talk.h" +#ifdef _TRADESYSTEM2 // (不可开) Syu ADD 新交易系统 +#include "pet_skill.h" +#endif + +#define TRADE_WAIT "请稍候,连络%s中···" +#define TRADE_NONE "前方什麽人也没有!" +#define TRADE_OVERPLAYER "前方不只一位玩家喔!" +#define TRADE_NOWILL "真是抱歉,对方不愿意跟你交易!" +#define TRADE_TRADING "%s正在与其他人交易···" +#define TRADE_VANISHITEM "丢在地上会消失的物品无法交易!" +#define TRADE_PETFULL "%s宠物栏已满,交易取消!" +#define TRADE_ITEMFULL "%s物品栏已满,请整理後再交易~" +#define TRADE_CANCEL "%s将交易取消了!" +#define TRADE_POOR "%s钱不够,无法交易!" +#define TRADE_RICH "%s金钱交易请勿超过一百万!" +#define TRADE_TOORICH "%s金钱将会超过一百万!" +#define TRADE_POORLV "%s等级不够,无法照顾交易後的宠物!" +#define TRADE_LOCK "交易锁定···" +#define TRADE_SUCCESS "交易OK!" +#define TRADE_FAILED "交易失败!" +#define TRADE_FMPET "家族守护兽无法交易!" + +#define TRADE_RDCANCEL "交易取消!" + + + +#ifdef _ITEM_PILEFORTRADE +enum{ + TRADE_ITEM=0, + TRADE_PET, + TRADE_GOLD, +}; + +#define MAX_TRADELISTNUM 100 +typedef struct _tagTradeList{ + int charaindex; + int fd; + int PetTi[5]; + int ItemTi[15]; + int ItemNum[15]; + int Golds; + int use; +}STradeList; + +STradeList TradeList[MAX_TRADELISTNUM][2]; + +void TRADE_ResetTradeList( int ti); +int TRADE_getTradeListIndex( void); +int TRADE_getMyTarget( int meindex ); +BOOL TRADE_setTradeListIndex( int ti, int meindex, int toindex); +BOOL TRADE_addSomeTradeList( int meindex, int usTi, int *num, int type); +BOOL TRADE_getSomeTradeList( int meindex, STradeList *temp); + +void TRADE_InitTradeList( void) +{ + int i; + print("初始化交易系统..."); + for( i=0; i= MAX_TRADELISTNUM )return; + for( i=0; i<5; i++){ + TradeList[ti][0].PetTi[i] = -1; + TradeList[ti][1].PetTi[i] = -1; + } + for( i=0; i<15; i++){ + TradeList[ti][0].ItemTi[i] = -1; + TradeList[ti][0].ItemNum[i] = -1; + TradeList[ti][1].ItemTi[i] = -1; + TradeList[ti][1].ItemNum[i] = -1; + } + + TradeList[ti][0].Golds = 0; + TradeList[ti][1].Golds = 0; + + + if( CHAR_CHECKINDEX(TradeList[ti][0].charaindex)){ + fd = getfdFromCharaIndex( TradeList[ti][0].charaindex); + CONNECT_setTradeList( fd, -1); + } + if( CHAR_CHECKINDEX(TradeList[ti][1].charaindex)){ + fd = getfdFromCharaIndex( TradeList[ti][1].charaindex); + CONNECT_setTradeList( fd, -1); + } + + TradeList[ti][0].charaindex = -1; + TradeList[ti][1].charaindex = -1; + TradeList[ti][0].fd = -1; + TradeList[ti][1].fd = -1; + + TradeList[ti][0].use = 0; + TradeList[ti][1].use = 0; + +} + +int TRADE_getTradeListIndex( void) +{ + int i; + static int tradeTi=0; + if( tradeTi < 0 ) tradeTi = 0; + for( i=0; i= MAX_TRADELISTNUM ) tradeTi = 0; + + } + return -1; +} + +BOOL TRADE_setTradeListIndex( int ti, int meindex, int toindex) +{ + int fd; + if( ti<0 || ti >= MAX_TRADELISTNUM ) return FALSE; + if( TradeList[ti][0].use == 1 || TradeList[ti][1].use == 1 ) return FALSE; + TRADE_ResetTradeList( ti); + TradeList[ti][0].charaindex = meindex; + TradeList[ti][1].charaindex = toindex; + TradeList[ti][0].use = 1; + TradeList[ti][1].use = 1; + + fd = getfdFromCharaIndex( meindex); + TradeList[ti][0].fd = fd; + CONNECT_setTradeList( fd, ti); + + fd = getfdFromCharaIndex( toindex); + TradeList[ti][1].fd = fd; + CONNECT_setTradeList( fd, ti); + return TRUE; +} + +void TRADE_CheckTradeListUser( void) +{ + int i, usenum=0, replace=0, freenum=0; + for( i=0; i= MAX_TRADELISTNUM ) return -1; + if( TradeList[ti][0].use == 0 || TradeList[ti][1].use == 0 ) return -1; + + for( i=0; i<2; i++){ + if( TradeList[ti][i].charaindex == meindex && + TradeList[ti][i].fd == fd ){ + side = (i+1)%2; + if( !CHAR_CHECKINDEX( TradeList[ti][side].charaindex) ) return -1; + if( TradeList[ti][side].charaindex == meindex ) return -1; + if( TradeList[ti][side].fd != getfdFromCharaIndex( TradeList[ti][side].charaindex) ) return -1; + + return TradeList[ti][side].charaindex; + } + } + return -1; +} + +BOOL TRADE_addSomeTradeList( int meindex, int usTi, int *num, int type) +{ + int i, fd, ti, side=-1, toindex=-1; + fd = getfdFromCharaIndex( meindex); + ti = CONNECT_getTradeList( fd); + if( ti <0 || ti >= MAX_TRADELISTNUM ) return FALSE; + toindex =-1; + if( TradeList[ti][0].use != 1 || TradeList[ti][1].use != 1 ) return FALSE; + for( i=0; i<2; i++){ + if( TradeList[ti][i].charaindex != meindex ){ + continue; + } + side = i; + toindex = TradeList[ti][((side+1)%2)].charaindex; + if( !CHAR_CHECKINDEX( toindex) ) return FALSE; + break; + } + if( side == -1 ) return FALSE; + switch( type){ + case TRADE_ITEM: + { + int itemindex, MeMaxPile; + MeMaxPile = CHAR_getMyMaxPilenum( meindex);//最大堆叠数 + if( usTi < CHAR_STARTITEMARRAY || usTi >= CHAR_MAXITEMHAVE ) return FALSE; + itemindex = CHAR_getItemIndex( meindex, usTi ); + if( !ITEM_CHECKINDEX( itemindex)) return FALSE; + + if( ITEM_getInt( itemindex, ITEM_VANISHATDROP) == 1 ){ + char buf[256]; + sprintf( buf, "%s无法交易。", ITEM_getChar( itemindex, ITEM_NAME) ); + CHAR_talkToCli( meindex, -1, buf, CHAR_COLORYELLOW); + return FALSE; + } + + if( ITEM_getInt( itemindex, ITEM_CANBEPILE) == 1 ){//可堆叠 + int itemMaxPile = ITEM_getInt( itemindex, ITEM_USEPILENUMS); + if( itemMaxPile < 0 ) return FALSE; + //ITEM_USEPILENUMS + for( i=0; i<15; i++){ + if( TradeList[ti][side].ItemTi[i] != usTi ) continue; + if( TradeList[ti][side].ItemNum[i] >= MeMaxPile || + TradeList[ti][side].ItemNum[i] >= itemMaxPile ) return FALSE; + + TradeList[ti][side].ItemNum[i] += 1; + if( num != NULL ) *num = TradeList[ti][side].ItemNum[i]; + return TRUE; + } + } + for( i=0; i<15; i++){ + if( TradeList[ti][side].ItemTi[i] != -1 ) continue; + TradeList[ti][side].ItemTi[i] = usTi; + TradeList[ti][side].ItemNum[i] = 1; + if( num != NULL ) *num = TradeList[ti][side].ItemNum[i]; + return TRUE; + } + } + break; + case TRADE_PET: + { + int petindex; + if( usTi < 0 || usTi >= CHAR_MAXPETHAVE ) return FALSE; + petindex = CHAR_getCharPet( meindex, usTi ); + if( !CHAR_CHECKINDEX(petindex)) return FALSE; + if( CHAR_getInt( petindex, CHAR_PETFAMILY) == 1 ){ + CHAR_talkToCli( meindex, -1, "家族守护兽无法交易。", CHAR_COLORYELLOW); + return FALSE;//家族守护兽 + } + if( CHAR_getWorkInt( toindex, CHAR_PickAllPet) != TRUE ){ + if( CHAR_getInt( petindex, CHAR_LV) > (CHAR_getInt( toindex, CHAR_LV)+5) && + (CHAR_getInt( toindex, CHAR_TRANSMIGRATION ) <= 0 ) ){ + CHAR_talkToCli( meindex, -1, "对方无法照顾该宠物。", CHAR_COLORYELLOW); + return FALSE; + } + } + for( i=0; i<5; i++){ + if( TradeList[ti][side].PetTi[i] == usTi ) return FALSE; + } + for( i=0; i<5; i++){ + if( TradeList[ti][side].PetTi[i] != -1 ) continue; + TradeList[ti][side].PetTi[i] = usTi; + return TRUE; + } + } + break; + case TRADE_GOLD: + TradeList[ti][side].Golds = usTi; + return TRUE; + break; + } + + return FALSE; +} + +BOOL TRADE_getSomeTradeList( int meindex, STradeList *temp) +{ + int i, fd, ti, side=-1; + fd = getfdFromCharaIndex( meindex); + ti = CONNECT_getTradeList( fd); + if( ti <0 || ti >= MAX_TRADELISTNUM ) return FALSE; + if( TradeList[ti][0].use != 1 || TradeList[ti][1].use != 1 ) return FALSE; + for( i=0; i<2; i++){ + if( TradeList[ti][i].charaindex != meindex ) continue; + side = i; + break; + } + if( side == -1 ) return FALSE; + + memcpy( temp, &TradeList[ti][side], sizeof( STradeList) ); + return TRUE; +} +BOOL TRADE_CheckTradeList( int meindex, STradeList *temp1, int toindex, STradeList *temp2); +#endif + +void TRADE_Will(int fd, int meindex, char* message); +void TRADE_ShowItem(int fd, int meindex, char* message); +void TRADE_Close(int fd, int meindex, char* message); + +void TRADE_SwapItem(int meindex, int toindex, char* message, int fd, char* mycharaname, int tofd, char* tocharaname); + +int TRADE_CheckItembuf(int fd, int meindex, int toindex, int tofd, char* mycharaname, char* tocharaname); +//BOOL TRADE_ChangeItem(int meindex, int toindex, char *a, char *b, int item1, int item2, int itemindex1, int itemindex2); +BOOL TRADE_HandleItem( int meindex, int showindex, char *message, char *outmess); +BOOL TRADE_HandleGold( int meindex, int showindex, char *message, char *outmess); +BOOL TRADE_HandlePet( int meindex, int showindex, char *message, char *outmess); + + + +void CHAR_Trade(int fd, int index, char* message) +{ + char firstToken[64]; + // shan 以下注掉是不必要的动作 2002/03/05 + //char messageeraseescape[512]; + char* messagebody; + + { + if (*message == 0) return; + if (!CHAR_CHECKINDEX(index)) return; + + CHAR_getMessageBody( message, firstToken, sizeof(firstToken), &messagebody); + + switch( tolower( firstToken[0]) ){ + case 'd': // 寻找前方玩家 + + TRADE_Search(fd, index, message); + break; +/* case 'c': + TRADE_Will(fd, index, message); + break; +*/ case 't': // 显示交易的物品、金钱、宠物 + TRADE_ShowItem(fd, index, message); + break; + case 'w': // 关闭交易 + print(" TRADE_Close:%d ", index); + TRADE_Close(fd, index, message); + break; + default: + break; + } + } +} + +BOOL TRADE_Search(int fd, int meindex, char* message) +{ + int objbuf[16]; + int front_x, front_y, i, found_count; + BOOL found = FALSE, searchflg = FALSE; + int cnt = 0, tofd = -1, checkfd = -1; + char msgbuf[1024], mycharaname[256], tocharaname[256]; + char token[256]; + + if (!CHAR_CHECKINDEX(meindex)) return FALSE; + +#if 0 // Robin fix +//#ifdef _DEATH_FAMILY_GM_COMMAND // WON ADD 家族战GM指令 + { + char msgbuf[512]; + snprintf( msgbuf, sizeof( msgbuf), "跨星系家族PK,无法交易"); + CHAR_talkToCli( meindex, -1, msgbuf, CHAR_COLORWHITE); + return FALSE; + } +#endif + + // 若玩家状态为交易中或交易锁定中则不予处理 + if (CHAR_getWorkInt(meindex, CHAR_WORKTRADEMODE) == CHAR_TRADE_TRADING + || CHAR_getWorkInt(meindex, CHAR_WORKTRADEMODE) == CHAR_TRADE_LOCK) + return FALSE; + + // 若玩家状态为组队或战斗中则不予处理 + if ((CHAR_getWorkInt(meindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE) + || (CHAR_getWorkInt(meindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE)) + return FALSE; + +#ifdef _STREET_VENDOR + // 若玩家在摆摊中不处理交易 + if(CHAR_getWorkInt(meindex,CHAR_WORKSTREETVENDOR) > -1) return FALSE; +#endif + + strcpy(mycharaname, CHAR_getChar(meindex, CHAR_NAME)); + + if (getStringFromIndexWithDelim(message, "|", 2, token, + sizeof(token)) == FALSE) return FALSE; + // 设定状态交易请求中 +// CHAR_setWorkInt(meindex, CHAR_WORKTRADEMODE, CHAR_TRADE_SENDING); + +#ifndef _ITEM_PILEFORTRADE + for (i = 0; i < CONNECT_WINDOWBUFSIZE; i++) + CONNECT_setTradecharaindex(fd, i, -1); +#endif + CHAR_getCoordinationDir(CHAR_getInt(meindex, CHAR_DIR), + CHAR_getInt(meindex, CHAR_X), + CHAR_getInt(meindex, CHAR_Y), + 1, &front_x, &front_y); + + found_count = CHAR_getSameCoordinateObjects( objbuf, arraysizeof(objbuf), + CHAR_getInt(meindex, CHAR_FLOOR),front_x, front_y); + // 前方没有玩家或对方关闭交易选项 + if (found_count == 0){ + CHAR_talkToCli(meindex, -1, TRADE_NONE, CHAR_COLORYELLOW); + CHAR_setWorkInt(meindex, CHAR_WORKTRADEMODE, CHAR_TRADE_FREE); + return FALSE; + } + + for (i = 0; i < found_count; i++){ + int objindex = objbuf[i]; + int index = OBJECT_getIndex(objindex); + + if (OBJECT_getType(objindex) != OBJTYPE_CHARA) continue; + if (CHAR_getInt(index, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER) continue; + if (index == meindex) continue; + found = TRUE; + if (CHAR_getWorkInt(index, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) continue; + if (CHAR_getWorkInt(index, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE) continue; + if (CHAR_getFlg(index, CHAR_ISTRADE) == FALSE) continue; + if (CHAR_getWorkInt(index, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE) continue; + strcpy(tocharaname, CHAR_getChar(index, CHAR_NAME)); + tofd = getfdFromCharaIndex(index); + if (tofd == -1){ + CHAR_setWorkInt(meindex, CHAR_WORKTRADEMODE, CHAR_TRADE_FREE); + return FALSE; + } + if (searchflg){ + if (tofd != checkfd) continue; + if (strcmp(token, tocharaname) != 0) continue; + } +#ifndef _ITEM_PILEFORTRADE + CONNECT_setTradecharaindex(fd, cnt, index); +#endif + cnt ++; + if (cnt == CONNECT_WINDOWBUFSIZE) break; + } + + if (cnt == 0){ + // 前方没有玩家或对方关闭交易选项 + if (found){ + CHAR_talkToCli(meindex, -1, TRADE_NOWILL, CHAR_COLORYELLOW); + }else + CHAR_talkToCli(meindex, -1, TRADE_NONE, CHAR_COLORYELLOW); + + sprintf(msgbuf, "C|%d|%s|0", tofd, tocharaname); + CHAR_setWorkInt(meindex, CHAR_WORKTRADEMODE, CHAR_TRADE_FREE); + return FALSE; + } + // 前方有一位玩家 + if (cnt == 1){ +#ifdef _ITEM_PILEFORTRADE + int ti; +#endif + int toindex; + toindex = CONNECT_getCharaindex(tofd); + if( !CHAR_CHECKINDEX(toindex)) return FALSE; +#ifdef _ITEM_PILEFORTRADE + + if( (ti = TRADE_getTradeListIndex()) < 0 || + TRADE_setTradeListIndex( ti, meindex, toindex) == FALSE ){ + + CHAR_talkToCli( meindex, -1, "系统忙碌中。", CHAR_COLORYELLOW); + CHAR_setWorkInt( meindex, CHAR_WORKTRADEMODE, CHAR_TRADE_FREE); + TRADE_CheckTradeListUser(); + + return FALSE; + } + TRADE_setTradeListIndex( ti, meindex, toindex); +#endif + snprintf(msgbuf, sizeof(msgbuf), TRADE_WAIT, tocharaname); + CHAR_talkToCli(meindex, -1, msgbuf, CHAR_COLORYELLOW); + + sprintf(msgbuf, "C|%d|%s|1", fd, mycharaname); + lssproto_TD_send( tofd, -1, msgbuf); + sprintf(msgbuf, "C|%d|%s|1", tofd, tocharaname); + lssproto_TD_send(fd, -1, msgbuf); + + CHAR_setWorkInt(meindex, CHAR_WORKTRADEMODE, CHAR_TRADE_TRADING); + CHAR_setWorkInt(toindex, CHAR_WORKTRADEMODE, CHAR_TRADE_TRADING); + + CONNECT_set_confirm(fd, FALSE); + CONNECT_set_confirm(tofd, FALSE); + + CHAR_sendTradeEffect(meindex, 1); + CHAR_sendTradeEffect(toindex, 1); + return TRUE; + }else if (cnt > 1){ // 前方不只一位玩家 + CHAR_talkToCli(meindex, -1, TRADE_OVERPLAYER, CHAR_COLORYELLOW); +// sprintf(msgbuf, "C|%d|%s|0", tofd, tocharaname); + CHAR_setWorkInt(meindex, CHAR_WORKTRADEMODE, CHAR_TRADE_FREE); + return FALSE; + } + + CHAR_setWorkInt(meindex, CHAR_WORKTRADEMODE, CHAR_TRADE_FREE); + return FALSE; +} + +void TRADE_Close(int fd, int meindex, char* message) +{ + char msg[128], mycharaname[256]; + int tofd=-1, toindex=-1; + int j; +#ifndef _ITEM_PILEFORTRADE + char token[256]; +#endif + if (!CHAR_CHECKINDEX(meindex)) return; + if (*message == 0) return; + strcpy(mycharaname, CHAR_getChar(meindex, CHAR_NAME)); +#ifdef _ITEM_PILEFORTRADE + toindex = TRADE_getMyTarget( meindex); + + if( CHAR_CHECKINDEX( toindex) ){ + tofd = getfdFromCharaIndex( toindex); + snprintf( msg, sizeof(msg), TRADE_CANCEL, mycharaname); + CHAR_talkToCli(toindex, -1, msg, CHAR_COLORYELLOW); + snprintf( msg, sizeof(msg), "W|%d|%s", fd, mycharaname); + lssproto_TD_send( tofd, -1, msg); + + CHAR_setWorkInt( toindex, CHAR_WORKTRADEMODE, CHAR_TRADE_FREE); + CONNECT_setTradeTmp( tofd, ""); + CHAR_sendStatusString( toindex, "i"); + CHAR_sendStatusString( toindex, "P"); + CHAR_sendTradeEffect( toindex, 0); + CONNECT_set_confirm( tofd, FALSE); + + for(j = 0; j < CHAR_MAXPETHAVE; j++){ + char msgbuf[256]; + int petindex = CHAR_getCharPet( toindex, j); + if( !CHAR_CHECKINDEX( petindex) ) continue; + CHAR_complianceParameter( petindex ); + snprintf( msgbuf, sizeof( msgbuf ), "K%d", j ); + CHAR_sendStatusString( toindex, msgbuf ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d", j ); + CHAR_sendStatusString( toindex, msgbuf ); + } + } + +#else + if (getStringFromIndexWithDelim(message, "|", 2, token, sizeof(token)) == FALSE) return; + tofd = atoi(token); + toindex = CONNECT_getCharaindex(tofd); + if (!CHAR_CHECKINDEX(toindex)) return; + if (getStringFromIndexWithDelim(message, "|", 3, token, sizeof(token)) == FALSE) return; + + + snprintf(msg, sizeof(msg), TRADE_CANCEL, mycharaname); + CHAR_talkToCli(toindex, -1, msg, CHAR_COLORYELLOW); + snprintf( msg, sizeof(msg), "W|%d|%s", fd, mycharaname); + lssproto_TD_send( tofd, -1, msg); + + CHAR_setWorkInt(toindex, CHAR_WORKTRADEMODE, CHAR_TRADE_FREE); + CONNECT_setTradeTmp(tofd, ""); + CHAR_sendStatusString( CONNECT_getCharaindex(tofd), "i"); + CHAR_sendStatusString( CONNECT_getCharaindex(tofd), "P"); + CHAR_sendTradeEffect( toindex, 0); + CONNECT_set_confirm(tofd, FALSE); +#endif + + if( !CHAR_CHECKINDEX( toindex) ){ + char buf[256]; + if( getStringFromIndexWithDelim( message, "|", 2, buf, sizeof(buf)) == FALSE) return; + tofd = atoi( buf); + toindex = CONNECT_getCharaindex( tofd); + if (!CHAR_CHECKINDEX(toindex) )return; + } + + + snprintf( msg, sizeof(msg), TRADE_RDCANCEL); + CHAR_talkToCli(meindex, -1, msg, CHAR_COLORYELLOW); + snprintf( msg, sizeof(msg), "W|%d|%s", tofd, CHAR_getChar( toindex, CHAR_NAME) ); + lssproto_TD_send( fd, -1, msg); + + CHAR_setWorkInt( meindex, CHAR_WORKTRADEMODE, CHAR_TRADE_FREE); + CONNECT_setTradeTmp(fd, ""); + CHAR_sendStatusString(meindex, "i"); + CHAR_sendStatusString(meindex, "P"); + CHAR_sendTradeEffect( meindex, 0); + CONNECT_set_confirm(fd, FALSE); +// end + for(j = 0; j < CHAR_MAXPETHAVE; j++){ + char msgbuf[256]; + int petindex = CHAR_getCharPet( meindex, j); + if( !CHAR_CHECKINDEX( petindex) ) continue; + CHAR_complianceParameter( petindex ); + snprintf( msgbuf, sizeof( msgbuf ), "K%d", j ); + CHAR_sendStatusString( meindex, msgbuf ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d", j ); + CHAR_sendStatusString( meindex, msgbuf ); + } + +#ifdef _ITEM_PILEFORTRADE + { + int ti=0; + ti = CONNECT_getTradeList( fd); + if( ti <0 || ti >= MAX_TRADELISTNUM ) return; + TRADE_ResetTradeList( ti); + } +#endif + +} + +void TRADE_ShowItem(int fd, int meindex, char* message) +{ + char token[128], mycharaname[256], tocharaname[256], msg[2048]; + int tofd, showindex, toindex;// itemindex, gold, tmpgold, item; + + int MaxGold; + + MaxGold = CHAR_getMaxHaveGold( meindex); + strcpy( mycharaname, CHAR_getChar(meindex, CHAR_NAME)); +#ifdef _ITEM_PILEFORTRADE + toindex = TRADE_getMyTarget( meindex); + if( !CHAR_CHECKINDEX( toindex) ){ + print(" TRADE_Close_Err1:%d ", toindex); + TRADE_Close(fd, meindex, message); + return; + } + if( meindex != TRADE_getMyTarget( toindex) ){ + print(" TRADE_Close_Err2:%d->%d ", meindex, toindex); + TRADE_Close(fd, meindex, message); + return; + } + tofd = getfdFromCharaIndex(toindex); +#else + if (getStringFromIndexWithDelim(message, "|", 2, token, sizeof(token)) == FALSE) return; + tofd = atoi(token); + toindex = CONNECT_getCharaindex(tofd); +#endif + + if (!CHAR_CHECKINDEX(toindex)) return; + // 若玩家状态为组队或战斗中则不予处理 + if ((CHAR_getWorkInt(meindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE) + || (CHAR_getWorkInt(meindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE)) + return; + + if ((CHAR_getWorkInt(toindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE) + || (CHAR_getWorkInt(toindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE)) + return; + + if (getStringFromIndexWithDelim(message, "|", 3, tocharaname, sizeof(tocharaname)) == FALSE) return; + if (getStringFromIndexWithDelim(message, "|", 5, token, sizeof(token)) == FALSE) return; + showindex = atoi(token); + if (getStringFromIndexWithDelim(message, "|", 4, token, sizeof(token)) == FALSE) return; + + showindex = toindex; + strcpy( tocharaname, CHAR_getChar(toindex, CHAR_NAME)); + + switch(tolower(token[0])){ + case 'i': + { + char buf1[2048]; + if( TRADE_HandleItem( meindex, showindex, message, buf1) == FALSE ){ + print(" TRADE_Close_Err3:%d,%d,%s,%s ", meindex, showindex, message, buf1); + TRADE_Close(fd, meindex, message); + return; + }else{ + snprintf(msg, sizeof(msg), "T|%d|%s|I|%d|%s", fd, mycharaname, showindex, buf1 ); + lssproto_TD_send(tofd, -1, msg); + } + } + break; + case 'g': + { + char buf1[2048]; + if( TRADE_HandleGold( meindex, showindex, message, buf1) == FALSE ){ + print(" TRADE_Close_Err4:%d,%d,%s,%s ", meindex, showindex, message, buf1); + TRADE_Close(fd, meindex, message); + return; + }else{// 将欲交易之金钱传给对方 + snprintf(msg, sizeof(msg), "T|%d|%s|G|%d|%s", fd, mycharaname, showindex, buf1); + lssproto_TD_send( tofd, -1, msg); + } + } + break; + case 'p': + { + char buf1[2048]; + if( TRADE_HandlePet( meindex, showindex, message, buf1) == FALSE ){ + print(" TRADE_Close_Err5:%d,%d,%s,%s ", meindex, showindex, message, buf1); + TRADE_Close(fd, meindex, message); + return; + }else{ + snprintf(msg, sizeof(msg), "T|%d|%s|P|%d|%s", + fd, mycharaname, showindex, buf1); + lssproto_TD_send(tofd, -1, msg); + } + } + break; + case 'k': + if((CONNECT_get_confirm(fd)==TRUE) && + (CONNECT_get_confirm(tofd)==TRUE) ){//当双方都按下 lock + if( CHAR_getWorkInt(meindex, CHAR_WORKTRADEMODE) == CHAR_TRADE_LOCK ){ + //andy_log + print("ANDY err 防止第二次进入!!\n"); + return;//防止第二次进入 + } + CHAR_setWorkInt(meindex, CHAR_WORKTRADEMODE, CHAR_TRADE_LOCK); + //检查对方是否按下 ok + if( CHAR_getWorkInt( toindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_LOCK )return; + + snprintf(msg, sizeof(msg), "T|%d|%s|A", fd, mycharaname); + lssproto_TD_send( tofd, -1, msg); + TRADE_SwapItem(meindex, toindex, message, fd, mycharaname, tofd, tocharaname); + } + break; + case 'c': + if( CONNECT_get_confirm( fd) == TRUE ) return; + CONNECT_set_confirm(fd, TRUE); + snprintf( msg, sizeof(msg), "T|%d|%s|C", fd, mycharaname); + lssproto_TD_send( tofd, -1, msg); + break; + } + return; +} + +void TRADE_SwapItem( int meindex, int toindex, char* message, int fd, char* mycharaname, int tofd, char* tocharaname) +{ + int result; + char msg[128], tmpmsg[128]; + +#ifndef _ITEM_PILEFORTRADE + CONNECT_setTradeTmp(fd, message); +#endif + + result = TRADE_CheckItembuf(fd, meindex, toindex, tofd, mycharaname, tocharaname); +#ifndef _ITEM_PILEFORTRADE + toindex = CONNECT_getCharaindex(tofd); +#endif + + if (!CHAR_CHECKINDEX(toindex)) return; + if (result == -1) + strcpy(msg, TRADE_FAILED); + else if (result == -2) + sprintf(msg, TRADE_ITEMFULL, mycharaname); + else if (result == -3) + sprintf(msg, TRADE_ITEMFULL, tocharaname); + else if (result == -4) + sprintf(msg, TRADE_RICH, mycharaname); + else if (result == -5) + sprintf(msg, TRADE_POOR, mycharaname); + else if (result == -6) + sprintf(msg, TRADE_RICH, tocharaname); + else if (result == -7) + sprintf(msg, TRADE_POOR, tocharaname); + else if (result == -8) + sprintf(msg, TRADE_TOORICH, mycharaname); + else if (result == -9) + sprintf(msg, TRADE_TOORICH, tocharaname); + else if (result == -10) + sprintf(msg, TRADE_PETFULL, mycharaname); + else if (result == -11) + sprintf(msg, TRADE_PETFULL, tocharaname); + else if (result == -12) + strcpy(msg, TRADE_VANISHITEM); + else if (result == -13) + sprintf(msg, TRADE_POORLV, mycharaname); + else if (result == -14) + sprintf(msg, TRADE_POORLV, tocharaname); + else if (result == -15) + strcpy(msg, TRADE_FMPET); + else if (result == 1) + strcpy(msg, TRADE_SUCCESS); + else if (result == 2) + strcpy(msg, TRADE_LOCK); + + if (result != 2){ + snprintf(tmpmsg, sizeof(tmpmsg), "W|%d|%s", fd, mycharaname); + lssproto_TD_send(tofd, -1, tmpmsg); + snprintf(tmpmsg, sizeof(tmpmsg), "W|%d|%s", tofd, tocharaname); + lssproto_TD_send(fd, -1, tmpmsg); + + CHAR_setWorkInt(meindex, CHAR_WORKTRADEMODE, CHAR_TRADE_FREE); + CHAR_setWorkInt(toindex, CHAR_WORKTRADEMODE, CHAR_TRADE_FREE); + CONNECT_setTradeTmp(fd, ""); + CONNECT_setTradeTmp(tofd, ""); + CHAR_sendTradeEffect( meindex, 0); + CHAR_sendTradeEffect( toindex, 0); + } + CHAR_sendStatusString(meindex, "i"); + CHAR_sendStatusString(toindex, "i"); + CHAR_sendStatusString(meindex, "P"); + CHAR_sendStatusString(toindex, "P"); + { + int j, petindex; + char msgbuf[256]; + for(j = 0; j < CHAR_MAXPETHAVE; j++){ + petindex = CHAR_getCharPet( meindex, j); + if( !CHAR_CHECKINDEX( petindex) ) continue; + CHAR_complianceParameter( petindex ); + snprintf( msgbuf, sizeof( msgbuf ), "K%d", j ); + CHAR_sendStatusString( meindex, msgbuf ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d", j ); + CHAR_sendStatusString( meindex, msgbuf ); + } + for(j = 0; j < CHAR_MAXPETHAVE; j++){ + petindex = CHAR_getCharPet( toindex, j); + if( !CHAR_CHECKINDEX( petindex) ) continue; + CHAR_complianceParameter( petindex ); + snprintf( msgbuf, sizeof( msgbuf ), "K%d", j ); + CHAR_sendStatusString( toindex, msgbuf ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d", j ); + CHAR_sendStatusString( toindex, msgbuf ); + } + } + + CHAR_talkToCli(meindex, -1, msg, CHAR_COLORYELLOW); + CHAR_talkToCli(toindex, -1, msg, CHAR_COLORYELLOW); +} + +#ifdef _ITEM_PILEFORTRADE + +int TRADE_HandleTrade_DelItem( int charaindex, int MyMaxPile, int MaxPile, int *Item, int *nums, int *indexlist) +{ + int i, k; + + for( i=0; i<50; i++){ + indexlist[i] = -1; + } + k=0; + for( i=0; i<15; i++ ){ + int pilenum, itemindex, totalnums, newindex; + if( Item[i] == -1 ) continue; + itemindex = CHAR_getItemIndex( charaindex, Item[i] ); + if( !ITEM_CHECKINDEX( itemindex)) return -1; + pilenum = ITEM_getInt( itemindex, ITEM_USEPILENUMS); + pilenum -= nums[i]; + if( pilenum < 0 ) return -1; + if( pilenum == 0 ){ + CHAR_setItemIndex( charaindex, Item[i], -1); + indexlist[k] = itemindex; + k++; + totalnums = ITEM_getInt( itemindex, ITEM_USEPILENUMS); + newindex = itemindex; + }else{ + ITEM_setInt( itemindex, ITEM_USEPILENUMS, pilenum); + newindex = ITEM_makeItemAndRegist( ITEM_getInt( itemindex, ITEM_ID)); + if( !ITEM_CHECKINDEX( newindex) ) return -1; + indexlist[k] = newindex; + k++; + totalnums = nums[i]; + } + if( totalnums > MaxPile ){ + totalnums -= MaxPile; + ITEM_setInt( newindex, ITEM_USEPILENUMS, MaxPile); + }else{ + ITEM_setInt( newindex, ITEM_USEPILENUMS, totalnums); + totalnums = 0; + } + + while( totalnums > 0 ){ + newindex = ITEM_makeItemAndRegist( ITEM_getInt( itemindex, ITEM_ID)); + if( !ITEM_CHECKINDEX( newindex) ) return -1; + indexlist[k] = newindex; + k++; + if( totalnums > MaxPile ){ + totalnums -= MaxPile; + ITEM_setInt( newindex, ITEM_USEPILENUMS, MaxPile); + }else{ + ITEM_setInt( newindex, ITEM_USEPILENUMS, totalnums); + totalnums = 0; + } + } + } + return k; +} + +int TRADE_HandleTrade_DelPet( int charaindex, int *Pet, int *indexlist) +{ + int i, k, petindex; + k=0; + for( i=0; i<5; i++){ + indexlist[i] = -1; + } + for( i=0; i<5; i++ ){ + if( Pet[i] == -1 ) continue; + petindex = CHAR_getCharPet( charaindex, Pet[i] ); + if( !CHAR_CHECKINDEX( petindex)) return -1; + CHAR_setCharPet( charaindex, Pet[i], -1); + indexlist[k] = petindex; + k++; + } + return k; +} + +BOOL TRADE_HandleTrade_DelGold( int charaindex, int sGold, int *Gold) +{ + int MyGold, MyMaxGold; + + MyGold = CHAR_getInt( charaindex, CHAR_GOLD); + MyMaxGold = CHAR_getMaxHaveGold( charaindex); + + MyGold -= sGold; + if( MyGold < 0 || MyGold > MyMaxGold ){ + MyGold = (MyGold<0)?0:MyGold; + MyGold = (MyGold>MyMaxGold)?MyMaxGold:MyGold; + CHAR_setInt( charaindex, CHAR_GOLD, MyGold); + return FALSE; + } + CHAR_setInt( charaindex, CHAR_GOLD, MyGold); + *Gold = sGold; + return TRUE; +} + +BOOL TRADE_HandleTrade_AddItem( int charaindex, int *Item) +{ + int ret, i; + for( i=0; i<50; i++){ + if( Item[i] == -1 )break; + ret = CHAR_addItemSpecificItemIndex( charaindex, Item[i]); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + int j; + for( j=i; j< 50; j++) + ITEM_endExistItemsOne( Item[j]); + return FALSE; + } + } + return TRUE; +} + +BOOL TRADE_HandleTrade_AddPet( int charaindex, int *Pet) +{ + int havepetelement, i; + for( i=0; i<5; i++){ + havepetelement = CHAR_getCharPetElement( charaindex); + if( Pet[i] == -1 ) break; + if( havepetelement < 0 ){ + int j; + for( j=i; j<5; j++){ + CHAR_endCharOneArray( Pet[j] ); + } + return FALSE; + + } + CHAR_setCharPet( charaindex, havepetelement, Pet[i]); + CHAR_setWorkInt( Pet[i], CHAR_WORKPLAYERINDEX, charaindex); + CHAR_setChar( Pet[i], CHAR_OWNERCDKEY, CHAR_getChar( charaindex, CHAR_CDKEY)); + CHAR_setChar( Pet[i], CHAR_OWNERCHARANAME, CHAR_getChar( charaindex, CHAR_NAME)); + CHAR_complianceParameter( Pet[i]); + } + return TRUE; +} + +BOOL TRADE_HandleTrade_AddGold( int charaindex, int sGold) +{ + int MyGold, MyMaxGold; + MyGold = CHAR_getInt( charaindex, CHAR_GOLD); + MyMaxGold = CHAR_getMaxHaveGold( charaindex); + + MyGold += sGold; + + MyGold = (MyGold<0)?0:MyGold; + MyGold = (MyGold>MyMaxGold)?MyMaxGold:MyGold; + + CHAR_setInt( charaindex, CHAR_GOLD, MyGold); + return TRUE; +} + +BOOL TRADE_HandleTrade( int meindex, STradeList *temp1, int toindex, STradeList *temp2 ) +{ + int MeMaxPile, ToMaxPile, ret; + int MeItem[50], ToItem[50]; + int MePet[5], ToPet[5]; + int MeGold=0, ToGold=0; + + MeMaxPile = CHAR_getMyMaxPilenum( meindex);//最大堆叠数 + ToMaxPile = CHAR_getMyMaxPilenum( toindex); + //移除meindex + //移除toindex + { + char buf[256]; + + memset( buf, 0, sizeof( buf)); + sprintf( buf, "A.%s[%s] trade B.%s[%s] FXY[%d,%d,%d]", + CHAR_getChar( meindex, CHAR_NAME), CHAR_getChar(meindex, CHAR_CDKEY), + CHAR_getChar( toindex, CHAR_NAME), CHAR_getChar(toindex, CHAR_CDKEY), + CHAR_getInt( meindex, CHAR_FLOOR), CHAR_getInt( meindex, CHAR_X), CHAR_getInt( meindex, CHAR_Y) ); + LogTrade(buf); + } + + //移除 + if( (ret=TRADE_HandleTrade_DelItem( meindex, MeMaxPile, ToMaxPile, temp1->ItemTi, temp1->ItemNum, ToItem ))== -1 ) return FALSE; + if( (ret=TRADE_HandleTrade_DelItem( toindex, ToMaxPile, MeMaxPile, temp2->ItemTi, temp2->ItemNum, MeItem ))== -1 ) return FALSE; + + if( (ret=TRADE_HandleTrade_DelPet( meindex, temp1->PetTi, ToPet)) == -1 ) return FALSE; + if( (ret=TRADE_HandleTrade_DelPet( toindex, temp2->PetTi, MePet)) == -1 ) return FALSE; + if( TRADE_HandleTrade_DelGold( meindex, temp1->Golds, &ToGold) == FALSE ) return FALSE; + if( TRADE_HandleTrade_DelGold( toindex, temp2->Golds, &MeGold) == FALSE ) return FALSE; + //加入 + if( TRADE_HandleTrade_AddItem( meindex, MeItem) == FALSE ) return FALSE; + if( TRADE_HandleTrade_AddItem( toindex, ToItem) == FALSE ) return FALSE; + if( TRADE_HandleTrade_AddPet( meindex, MePet) == FALSE) return FALSE; + if( TRADE_HandleTrade_AddPet( toindex, ToPet) == FALSE) return FALSE; + + TRADE_HandleTrade_AddGold( meindex, MeGold); + TRADE_HandleTrade_AddGold( toindex, ToGold); + + { + char buf1[4096], buf2[4096], buf[256]; + int i; + sprintf( buf1, "A.ITEM."); + sprintf( buf2, "B.ITEM."); + for( i=0; i<50; i++){ + if( ITEM_CHECKINDEX( ToItem[i]) ){ + sprintf( buf, "%s[%s]*%d,", + ITEM_getChar( ToItem[i], ITEM_NAME), ITEM_getChar( ToItem[i], ITEM_UNIQUECODE), + ITEM_getInt( ToItem[i], ITEM_USEPILENUMS) ); + strcat( buf1, buf); + } + if( ITEM_CHECKINDEX( MeItem[i]) ){ + sprintf( buf, "%s[%s]*%d,", + ITEM_getChar( MeItem[i], ITEM_NAME), ITEM_getChar( MeItem[i], ITEM_UNIQUECODE), + ITEM_getInt( MeItem[i], ITEM_USEPILENUMS) ); + strcat( buf2, buf); + } + } + strcat( buf1, "PET."); + strcat( buf2, "PET."); + for( i=0; i<5; i++){ + if( CHAR_CHECKINDEX( ToPet[i]) ){ + sprintf( buf, "%s[%s]%s-%d", + CHAR_getUseName( ToPet[i]), CHAR_getChar( ToPet[i], CHAR_UNIQUECODE), + CHAR_getChar( ToPet[i], CHAR_NAME), CHAR_getInt( ToPet[i], CHAR_LV) ); + strcat( buf1, buf); + } + if( CHAR_CHECKINDEX( MePet[i]) ){ + sprintf( buf, "%s[%s]%s-%d", + CHAR_getUseName( MePet[i]), CHAR_getChar( MePet[i], CHAR_UNIQUECODE), + CHAR_getChar( MePet[i], CHAR_NAME), CHAR_getInt( MePet[i], CHAR_LV) ); + strcat( buf2, buf); + } + } + sprintf( buf, "GOLD:%d", ToGold); + strcat( buf1, buf); + sprintf( buf, "GOLD:%d", MeGold); + strcat( buf2, buf); + LogTrade( buf1); + LogTrade( buf2); + } + + return TRUE; +} + +int TRADE_CheckItembuf(int fd, int meindex, int toindex, int tofd, char* mycharaname, char* tocharaname) +{ + int Tradeti; + STradeList TradeListTemp[2]; + if( TRADE_getMyTarget( meindex) != toindex ) return -1; + Tradeti = CONNECT_getTradeList( fd); + if( Tradeti <0 || Tradeti >= MAX_TRADELISTNUM ) return -1; + if( TradeList[Tradeti][0].use != 1 || TradeList[Tradeti][1].use != 1 ) return -1; + if( TRADE_getSomeTradeList( meindex, &TradeListTemp[0]) == FALSE ) return -1; + if( TRADE_getSomeTradeList( toindex, &TradeListTemp[1]) == FALSE ) return -1; + //确定空位 + if( TRADE_CheckTradeList( meindex, &TradeListTemp[0], toindex, &TradeListTemp[1]) == FALSE ) return -1; + //移除人物身上 + //加入人物身上 + if( TRADE_HandleTrade( meindex, &TradeListTemp[0], toindex, &TradeListTemp[1] ) == FALSE ) return -1; + //交易结束动作 + return 1; +} + +#else +/* +int TRADE_CheckItembuf(int fd, int meindex, int toindex, int tofd, char* mycharaname, char* tocharaname) +{ +#ifdef _TRADESYSTEM2 // (不可开) Syu ADD 新交易系统 + int myItem[42] = { -1 } ; //我方所有的交易内容编号 + int oppItem[42] = { -1 }; //对方所有的交易内容编号 + int ii , jj; + int Iitem1[15] = { 0 } ; //我方道具的index + int Iitem2[15] = { 0 } ; //对方道具的index + int ppet1[5] = { 0 } ; //我方宠物的index + int ppet2[5] = { 0 } ; //对方宠物的index + BOOL tradeflag = TRUE ; + int count = 0 ; +#endif + + char a[16], b[16], c[16], d[16], e[16], f[16]; + char g[16], h[16], i[16], j[16], k[16], l[16], token[16]; + int itemindex1 = 0, itemindex2 = 0, itemindex3 = 0; + int itemindex4 = 0, itemindex5 = 0, itemindex6 = 0; + int toitemindex1 = 0, toitemindex2 = 0, toitemindex3 = 0; + int toitemindex4 = 0, toitemindex5 = 0, toitemindex6 = 0; + int item1 = 0, item2 = 0, item4 = 0, item5 = 0, pet3 = 0, pet6 = 0; + int pet1 = 0, pet2 = 0; + int swapitem1 = 0, swapitem2 = 0, gold1 = 0, gold2 = 0; + char itembuf[256], toitembuf[256], buf[4048]; + + CONNECT_getTradeTmp(fd, itembuf, sizeof(itembuf)); + CONNECT_getTradeTmp(tofd, toitembuf, sizeof(toitembuf)); + + +#ifdef _TRADESYSTEM2 // (不可开) Syu ADD 新交易系统 + //取得我方所有交易内容编号 + for ( ii = 0 ; ii < 42 ; ii ++ ) { + if (getStringFromIndexWithDelim(itembuf, "|", 6 + ii * 2 , token, sizeof(token)) == TRUE) + myItem[ii] = atoi(token); + } + //取得对方所有交易内容编号 + for ( ii = 0 ; ii < 42 ; ii ++ ) { + if (getStringFromIndexWithDelim(toitembuf, "|", 6 + ii * 2 , token, sizeof(token)) == TRUE) + oppItem[ii] = atoi(token); + } +#else + // 比对双方之最後交易协定 + if (getStringFromIndexWithDelim(itembuf, "|", 5, token, sizeof(token)) == TRUE) + strcpy(a, token); + if (getStringFromIndexWithDelim(itembuf, "|", 6, token, sizeof(token)) == TRUE) + itemindex1 = atoi(token); + if (getStringFromIndexWithDelim(itembuf, "|", 7, token, sizeof(token)) == TRUE) + strcpy(b, token); + if (getStringFromIndexWithDelim(itembuf, "|", 8, token, sizeof(token)) == TRUE) + itemindex2 = atoi(token); + if (getStringFromIndexWithDelim(itembuf, "|", 9, token, sizeof(token)) == TRUE) + strcpy(c, token); + if (getStringFromIndexWithDelim(itembuf, "|", 10, token, sizeof(token)) == TRUE) + itemindex3 = atoi(token); + if (getStringFromIndexWithDelim(itembuf, "|", 11, token, sizeof(token)) == TRUE) + strcpy(d, token); + if (getStringFromIndexWithDelim(itembuf, "|", 12, token, sizeof(token)) == TRUE) + itemindex4 = atoi(token); + if (getStringFromIndexWithDelim(itembuf, "|", 13, token, sizeof(token)) == TRUE) + strcpy(e, token); + if (getStringFromIndexWithDelim(itembuf, "|", 14, token, sizeof(token)) == TRUE) + itemindex5 = atoi(token); + if (getStringFromIndexWithDelim(itembuf, "|", 15, token, sizeof(token)) == TRUE) + strcpy(f, token); + if (getStringFromIndexWithDelim(itembuf, "|", 16, token, sizeof(token)) == TRUE) + itemindex6 = atoi(token); + + if (getStringFromIndexWithDelim(toitembuf, "|", 5, token, sizeof(token)) == TRUE) + strcpy(g, token); + if (getStringFromIndexWithDelim(toitembuf, "|", 6, token, sizeof(token)) == TRUE) + toitemindex1 = atoi(token); + if (getStringFromIndexWithDelim(toitembuf, "|", 7, token, sizeof(token)) == TRUE) + strcpy(h, token); + if (getStringFromIndexWithDelim(toitembuf, "|", 8, token, sizeof(token)) == TRUE) + toitemindex2 = atoi(token); + if (getStringFromIndexWithDelim(toitembuf, "|", 9, token, sizeof(token)) == TRUE) + strcpy(i, token); + if (getStringFromIndexWithDelim(toitembuf, "|", 10, token, sizeof(token)) == TRUE) + toitemindex3 = atoi(token); + if (getStringFromIndexWithDelim(toitembuf, "|", 11, token, sizeof(token)) == TRUE) + strcpy(j, token); + if (getStringFromIndexWithDelim(toitembuf, "|", 12, token, sizeof(token)) == TRUE) + toitemindex4 = atoi(token); + if (getStringFromIndexWithDelim(toitembuf, "|", 13, token, sizeof(token)) == TRUE) + strcpy(k, token); + if (getStringFromIndexWithDelim(toitembuf, "|", 14, token, sizeof(token)) == TRUE) + toitemindex5 = atoi(token); + if (getStringFromIndexWithDelim(toitembuf, "|", 15, token, sizeof(token)) == TRUE) + strcpy(l, token); + if (getStringFromIndexWithDelim(toitembuf, "|", 16, token, sizeof(token)) == TRUE) + toitemindex6 = atoi(token); +#endif + +#ifdef _TRADESYSTEM2 // (不可开) Syu ADD 新交易系统 + //检查有无重复交易的道具 + for ( ii = 0 ; ii < 15 ; ii ++ ) { + for ( jj = ii + 1 ; jj < 15 ; jj ++ ) { + if ( myItem[ii] == myItem[jj] ) + if ( myItem[ii] != -1 ) + return -1 ; + } + } + for ( ii = 21 ; ii < 36 ; ii ++ ) { + for ( jj = ii + 1 ; jj < 36 ; jj++ ) { + if ( myItem[ii] == myItem[jj] ) + if ( myItem[ii] != -1 ) + return -1 ; + } + } +#else + // shan hjj add 洗道具 + if (itemindex1==itemindex2){ + if (itemindex1!=-1){ + return -1; + } + } + if (itemindex4==itemindex5){ + if (itemindex4!=-1){ + return -1; + } + } + // End +#endif + +#ifdef _TRADESYSTEM2 // (不可开) Syu ADD 新交易系统 + //比对双方交易的物品是否都正确 + for ( ii = 0 ; ii < 21 ; ii ++ ) { + if ( myItem[ii] != oppItem[ii+21] ) { + tradeflag = FALSE ; + break; + } + } + for ( ii = 21 ; ii < 42 ; ii ++ ){ + if ( myItem[ii] != oppItem[ii-21]) { + tradeflag = FALSE; + break; + } + } + //双方内容正确开始进行处理 + if ( tradeflag == TRUE ) { + //计算双方道具的加减 + for ( ii = 0 ; ii < 15 ; ii ++ ) { + if ( myItem[ii] != -1 ) { + swapitem1--; + swapitem2++; + } + } + for ( ii = 21 ; ii < 36 ; ii ++ ) { + if ( myItem[ii] != -1 ) { + swapitem1++; + swapitem2--; + } + } +#else + if ((strcmp(a, j) == 0) && (strcmp(b, k) == 0) && (strcmp(c,l) == 0) + && (strcmp(d, g) == 0) && (strcmp(e, h) == 0) && (strcmp(f, i) == 0) + && (itemindex1 == toitemindex4) && (itemindex2 == toitemindex5) + && (itemindex3 == toitemindex6) && (itemindex4 == toitemindex1) + && (itemindex5 == toitemindex2) && (itemindex6 == toitemindex3)) + { + // 检验双方物品栏是否有空位 + if ((strcmp(a, "I") == 0) && (itemindex1 != -1)){ + swapitem1--; + swapitem2++; + } + if ((strcmp(b, "I") == 0) && (itemindex2 != -1)){ + swapitem1--; + swapitem2++; + } + if ((strcmp(d, "I") == 0) && (itemindex4 != -1)){ + swapitem1++; + swapitem2--; + } + if ((strcmp(e, "I") == 0) && (itemindex5 != -1)){ + swapitem1++; + swapitem2--; + } +#endif + if (swapitem1 > CHAR_findTotalEmptyItem(meindex)) + return -2; + toindex = CONNECT_getCharaindex(tofd); + if (!CHAR_CHECKINDEX(toindex)) return -1; + if (swapitem2 > CHAR_findTotalEmptyItem(toindex)) + return -3; +#ifdef _TRADESYSTEM2 // (不可开) Syu ADD 新交易系统 + //取得交换的金钱 + if ( myItem[20] != -1 ) gold1 += myItem[20] ; + if ( myItem[41] != -1 ) gold2 += myItem[41] ; +#else + // 检查双方金钱 + if ((strcmp(a, "G") == 0) && (itemindex1 != -1)) gold1 += itemindex1; + if ((strcmp(b, "G") == 0) && (itemindex2 != -1)) gold1 += itemindex2; + if ((strcmp(d, "G") == 0) && (itemindex4 != -1)) gold2 += itemindex4; + if ((strcmp(e, "G") == 0) && (itemindex5 != -1)) gold2 += itemindex5; +#endif + if (gold1 > CHAR_getMaxHaveGold( meindex) ) return -4; + if (gold1 > CHAR_getInt(meindex, CHAR_GOLD)) return -5; + if (gold2 > CHAR_getMaxHaveGold( toindex)) return -6; + if (gold2 > CHAR_getInt(toindex, CHAR_GOLD)) return -7; + if ((gold2 + CHAR_getInt(meindex, CHAR_GOLD) - gold1) > CHAR_getMaxHaveGold( meindex) ) return -8; + if ((gold1 + CHAR_getInt(toindex, CHAR_GOLD) - gold2) > CHAR_getMaxHaveGold( toindex)) return -9; + +#ifdef _TRADESYSTEM2 // (不可开) Syu ADD 新交易系统 + //计算双方宠物的加减 + for ( ii = 15 ; ii < 20 ; ii ++ ) { + if ( myItem[ii] != -1 ) { + pet1--; + pet2++; + } + } + for ( ii = 36 ; ii < 41 ; ii ++ ) { + if ( myItem[ii] != -1 ) { + pet1++; + pet2--; + } + } +#else + // 检查双方宠物 + if ((strcmp(c, "P") == 0) && (itemindex3 != -1)) + { + pet1--; pet2++; + } + if ((strcmp(f, "P") == 0) && (itemindex6 != -1)) + { + pet1++; pet2--; + } +#endif + +#ifdef _TRADESYSTEM2 // (不可开) Syu ADD 新交易系统 + if ((pet1 > 5) || (pet2 > 5)) return -10; + //取得双方身上能放的宠物数量 + for( ii = 0; ii < CHAR_MAXPETHAVE; ii ++ ) { + if( CHAR_getCharPet( meindex , ii ) == -1 ) count ++ ; + } + if ( pet1 > count ) return -10; + count = 0 ; + for( ii = 0; ii < CHAR_MAXPETHAVE; ii ++ ) { + if( CHAR_getCharPet( toindex , ii ) == -1 ) count ++ ; + } + if ( pet2 > count ) return -11; +#else + if ((pet1 > 1) || (pet2 > 1)) return -10; + if ((pet1 == 1) && (CHAR_getCharPetElement( meindex) == -1)) return -10; + if ((pet2 == 1) && (CHAR_getCharPetElement( toindex) == -1)) return -11; +#endif +#ifdef _TRADESYSTEM2 // (不可开) Syu ADD 新交易系统 + //取得所有欲交易的道具index + for ( ii = 0 ; ii < 15 ; ii ++ ) { + if ( myItem[ii] != -1 ) + Iitem1[ii] = CHAR_getItemIndex(meindex, myItem[ii]); + else + Iitem1[ii] = -1 ; + if ( myItem[ii + 21 ] != -1 ) + Iitem2[ii] = CHAR_getItemIndex(toindex, myItem[ii + 21]); + else + Iitem2[ii] = -1 ; + } +#else + if ((strcmp(a, "I") == 0) && (itemindex1 != -1)) + item1 = CHAR_getItemIndex(meindex, itemindex1); + else item1 = -1; + if ((strcmp(b, "I") == 0) && (itemindex2 != -1)) + item2 = CHAR_getItemIndex(meindex, itemindex2); + else item2 = -1; + if ((strcmp(d, "I") == 0) && (itemindex4 != -1)) + item4 = CHAR_getItemIndex(toindex, itemindex4); + else item4 = -1; + if ((strcmp(e, "I") == 0) && (itemindex5 != -1)) + item5 = CHAR_getItemIndex(toindex, itemindex5); + else item5 = -1; +#endif +#ifdef _TRADESYSTEM2 // (不可开) Syu ADD 新交易系统 + //取得欲交易宠物的index + for ( ii = 15 ; ii < 20 ; ii ++ ) { + if ( myItem[ii] != -1 ) { + if ( CHAR_getInt( meindex , CHAR_RIDEPET) == myItem[ii] ) + return -1 ; + ppet1[ii - 15 ] = CHAR_getCharPet( meindex , myItem[ii] ) ; + } + else + ppet1[ii - 15 ] = -1 ; + } + for ( ii = 36 ; ii < 41 ; ii ++ ) { + if ( myItem[ii] != -1 ) { + if ( CHAR_getInt( toindex , CHAR_RIDEPET) == myItem[ii] ) + return -1 ; + ppet2[ ii - 36 ] = CHAR_getCharPet( toindex , myItem[ii] ) ; + } + else + ppet2[ ii - 36 ] = -1 ; + } +#else + if (itemindex3 != -1) + { + if( CHAR_getInt( meindex, CHAR_RIDEPET) == itemindex3 ) + return -1; + pet3 = CHAR_getCharPet(meindex, itemindex3); + } + else pet3 = -1; + if (itemindex6 != -1) + { + if( CHAR_getInt( toindex, CHAR_RIDEPET) == itemindex6 ) + return -1; + pet6 = CHAR_getCharPet(toindex, itemindex6); + } + else pet6 = -1; +#endif + + + +#ifdef _TRADESYSTEM2 // (不可开) Syu ADD 新交易系统 + for ( ii = 0 ; ii < 15 ; ii ++ ) { + if ( ITEM_getInt( Iitem1[ii] , ITEM_VANISHATDROP ) == 1 ) + return -12 ; + if ( ITEM_getInt( Iitem2[ii] , ITEM_VANISHATDROP ) == 1 ) + return -12 ; + } +#else + if ((ITEM_getInt(item1, ITEM_VANISHATDROP) == 1)|| + (ITEM_getInt(item2, ITEM_VANISHATDROP) == 1)|| + (ITEM_getInt(item4, ITEM_VANISHATDROP) == 1)|| + (ITEM_getInt(item5, ITEM_VANISHATDROP) ==1)) + return -12; +#endif + + +#ifdef _TRADESYSTEM2 // (不可开) Syu ADD 新交易系统 + //宠物等级能否交易判断 + if( CHAR_getWorkInt( meindex, CHAR_PickAllPet) != TRUE ) { + for ( ii = 0 ; ii < 5 ; ii ++ ) { + if ( (ppet2[ii] != -1 ) && ( CHAR_getInt( ppet2[ii] , CHAR_LV ) + - CHAR_getInt(meindex, CHAR_LV) > 5) + && (CHAR_getInt(meindex,CHAR_TRANSMIGRATION) <= 0)) + return -13 ; + } + } + if( CHAR_getWorkInt( toindex, CHAR_PickAllPet) != TRUE ) { + for ( ii = 0 ; ii < 5 ; ii ++ ) { + if ( (ppet1[ii] != -1 ) && ( CHAR_getInt( ppet1[ii] , CHAR_LV ) + - CHAR_getInt(toindex, CHAR_LV) > 5) + && (CHAR_getInt(toindex,CHAR_TRANSMIGRATION) <= 0)) + return -13 ; + } + } +#else + if( CHAR_getWorkInt( meindex, CHAR_PickAllPet) != TRUE ) { + if ((pet6 != -1) && (CHAR_getInt(pet6, CHAR_LV) + - CHAR_getInt(meindex, CHAR_LV) > 5) + && (CHAR_getInt(meindex,CHAR_TRANSMIGRATION) <= 0)) + return -13; + + } + if( CHAR_getWorkInt( toindex, CHAR_PickAllPet) != TRUE ) { + + if ((pet3 != -1) && (CHAR_getInt(pet3, CHAR_LV) + - CHAR_getInt(toindex, CHAR_LV) > 5) + && (CHAR_getInt(toindex,CHAR_TRANSMIGRATION) <= 0)) + return -14; + } +#endif +#ifdef _TRADESYSTEM2 // (不可开) Syu ADD 新交易系统 + //是否为家族守护兽 + for ( ii = 0 ; ii < 5 ; ii ++ ) { + if ( ( ppet1[ii] != -1 ) && (CHAR_getInt(ppet1[ii], CHAR_PETFAMILY) == 1)) + return -15; + if ( ( ppet2[ii] != -1 ) && (CHAR_getInt(ppet2[ii], CHAR_PETFAMILY) == 1)) + return -15; + } +#else + if ((pet6 != -1) && (CHAR_getInt(pet6, CHAR_PETFAMILY) == 1)) + return -15; + if ((pet3 != -1) && (CHAR_getInt(pet3, CHAR_PETFAMILY) == 1)) + return -15; +#endif + +#ifdef _TRADESYSTEM2 // (不可开) Syu ADD 新交易系统 + // 交换玩家道具、金钱、宠物 + for ( ii = 0 ; ii < 15 ; ii ++ ) { + TRADE_ChangeItem(meindex, toindex, "I", "I", Iitem1[ii], Iitem2[ii], + myItem[ii], oppItem[ii]); + } + for ( ii = 15 ; ii < 20 ; ii ++ ) { + TRADE_ChangeItem(meindex, toindex, "P", "P", ppet1[ii - 15 ], ppet2[ii-15], + myItem[ii], oppItem[ii]); + } + TRADE_ChangeItem(meindex, toindex, "G", "G", Iitem1[20], Iitem2[41], + myItem[20], oppItem[20]); +#else + TRADE_ChangeItem(meindex, toindex, a, d, item1, item4, + itemindex1, itemindex4); + TRADE_ChangeItem(meindex, toindex, b, e, item2, item5, + itemindex2, itemindex5); + TRADE_ChangeItem(meindex, toindex, c, f, pet3, pet6, + itemindex3, itemindex6); +#endif + + // 写入 trade.log + { + char petname1[256], petname2[256]; + int pet1lv, pet2lv; + int logitem1 = 0, logitem2 = 0, logitem4 = 0, logitem5 = 0; + + if ((strcmp(a, "I") == 0) && (item1 != -1)) logitem1 = ITEM_getInt(item1, ITEM_ID); + if ((strcmp(b, "I") == 0) && (item2 != -1)) logitem2 = ITEM_getInt(item2, ITEM_ID); + if ((strcmp(a, "G") == 0) && (item1 == -1)) logitem1 = itemindex1; + if ((strcmp(b, "G") == 0) && (item2 == -1)) logitem2 = itemindex2; + if ((strcmp(c, "P") == 0) && (pet3 == -1)) + { + sprintf(petname1, "NONE"); + pet1lv = 0; + } + else + { + sprintf(petname1, "%s", CHAR_getChar(pet3, CHAR_NAME)); + pet1lv = CHAR_getInt(pet3, CHAR_LV); + } + if ((strcmp(f, "P") == 0) && (pet6 == -1)) + { + sprintf(petname2, "NONE"); + pet2lv = 0; + } + else + { + sprintf(petname2, "%s", CHAR_getChar(pet6, CHAR_NAME)); + pet2lv = CHAR_getInt(pet6, CHAR_LV); + } + if ((strcmp(d, "I") == 0) && (item4 != -1)) logitem4 = ITEM_getInt(item4, ITEM_ID); + if ((strcmp(e, "I") == 0) && (item5 != -1)) logitem5 = ITEM_getInt(item5, ITEM_ID); + if ((strcmp(d, "G") == 0) && (item4 == -1)) logitem4 = itemindex4; + if ((strcmp(e, "G") == 0) && (item5 == -1)) logitem5 = itemindex5; + sprintf(buf, "%s\t%s\t(%s[%d,%s],%s[%d,%s],%s[%s,%d,%s]) <-> %s\t%s\t(%s[%d,%s],%s[%d,%s],%s[%s,%d,%s])", + CHAR_getChar(meindex, CHAR_CDKEY), mycharaname, + a, logitem1, ITEM_getChar( item1, ITEM_UNIQUECODE), b, logitem2, ITEM_getChar( item2, ITEM_UNIQUECODE), + c, petname1, pet1lv, CHAR_getChar( pet3, CHAR_UNIQUECODE), + CHAR_getChar(toindex, CHAR_CDKEY), tocharaname, + d, logitem4, ITEM_getChar( item4, ITEM_UNIQUECODE), e, logitem5, ITEM_getChar( item5, ITEM_UNIQUECODE), + f, petname2, pet2lv, CHAR_getChar( pet6, CHAR_UNIQUECODE)); + LogTrade(buf); + } + + return 1; + }// if + else + return 2; +} +*/ +#endif +/* +BOOL TRADE_ChangeItem(int meindex, int toindex, char *a, char *b, + int item1, int item2, int itemindex1, int itemindex2) +{ + int gold1 = 0, gold2 = 0, eptitem = -1; + if (CHAR_CHECKINDEX(meindex) == FALSE) return FALSE; + if (CHAR_CHECKINDEX(toindex) == FALSE) return FALSE; + // 道具 <-> 道具 + if ((strcmp(a, "I") == 0) && (strcmp(b, "I") == 0)) + { + // 无 <-> 道具 + if ((itemindex1 == -1) && (itemindex2 > 0)) + { + if (ITEM_CHECKINDEX(item2) == FALSE) return FALSE; + eptitem = CHAR_findEmptyItemBox(meindex); + if (eptitem < 0) return FALSE; + CHAR_setItemIndex(meindex, eptitem, item2); + ITEM_setWorkInt(item2, ITEM_WORKCHARAINDEX, meindex); + ITEM_setWorkInt(item2, ITEM_WORKOBJINDEX, -1); + CHAR_setItemIndex(toindex, itemindex2, -1); + } + // 道具 <-> 无 + else if ((itemindex1 > 0) && (itemindex2 == -1)) + { + if (ITEM_CHECKINDEX(item1) == FALSE) return FALSE; + eptitem = CHAR_findEmptyItemBox(toindex); + if (eptitem < 0) return FALSE; + CHAR_setItemIndex(toindex, eptitem, item1); + ITEM_setWorkInt(item1, ITEM_WORKCHARAINDEX, toindex); + ITEM_setWorkInt(item1, ITEM_WORKOBJINDEX, -1); + CHAR_setItemIndex(meindex, itemindex1, -1); + } + // 道具 <-> 道具 + else if (itemindex1 > 0 && itemindex2 > 0) + { + if (ITEM_CHECKINDEX(item1) == FALSE) return FALSE; + if (ITEM_CHECKINDEX(item2) == FALSE) return FALSE; + ITEM_setWorkInt(item1, ITEM_WORKCHARAINDEX, toindex); + ITEM_setWorkInt(item1, ITEM_WORKOBJINDEX, -1); + ITEM_setWorkInt(item2, ITEM_WORKCHARAINDEX, meindex); + ITEM_setWorkInt(item2, ITEM_WORKOBJINDEX, -1); + CHAR_setItemIndex(toindex, itemindex2, item1); + CHAR_setItemIndex(meindex, itemindex1, item2); + } + } + // 道具 <-> 金钱 + else if ((strcmp(a, "I") == 0) && (strcmp(b, "G") == 0)) + { + if (itemindex1 > 0) + { + if (ITEM_CHECKINDEX(item1) == FALSE) return FALSE; + eptitem = CHAR_findEmptyItemBox(toindex); + if (eptitem < 0) return FALSE; + ITEM_setWorkInt(item1, ITEM_WORKCHARAINDEX, toindex); + ITEM_setWorkInt(item1, ITEM_WORKOBJINDEX, -1); + CHAR_setItemIndex(toindex, eptitem, item1); + CHAR_setItemIndex(meindex, itemindex1, -1); + } + if (itemindex2 < 0) itemindex2 = 0; + gold1 = CHAR_getInt(meindex, CHAR_GOLD); + gold1 += itemindex2; + CHAR_setInt(meindex, CHAR_GOLD, gold1); + gold2 = CHAR_getInt(toindex, CHAR_GOLD); + gold2 -= itemindex2; + CHAR_setInt(toindex, CHAR_GOLD, gold2); + } + // 金钱 <-> 道具 + else if ((strcmp(a, "G") == 0) && (strcmp(b, "I") == 0)) + { + if (itemindex2 > 0) + { + if (ITEM_CHECKINDEX(item2) == FALSE) return FALSE; + eptitem = CHAR_findEmptyItemBox(meindex); + if (eptitem < 0) return FALSE; + ITEM_setWorkInt(item2, ITEM_WORKCHARAINDEX, meindex); + ITEM_setWorkInt(item2, ITEM_WORKOBJINDEX, -1); + CHAR_setItemIndex(meindex, eptitem, item2); + CHAR_setItemIndex(toindex, itemindex2, -1); + } + if (itemindex1 < 0) itemindex1 = 0; + gold1 = CHAR_getInt(meindex, CHAR_GOLD); + gold1 -= itemindex1; + CHAR_setInt(meindex, CHAR_GOLD, gold1); + gold2 = CHAR_getInt(toindex, CHAR_GOLD); + gold2 += itemindex1; + CHAR_setInt(toindex, CHAR_GOLD, gold2); + } + // 金钱 <-> 金钱 + else if ((strcmp(a, "G") == 0) && (strcmp(b, "G") == 0)) + { + if (itemindex1 < 0) itemindex1 = 0; + if (itemindex2 < 0) itemindex2 = 0; + gold1 = CHAR_getInt(toindex, CHAR_GOLD); + gold1 = gold1 + itemindex1 - itemindex2; + CHAR_setInt(toindex, CHAR_GOLD, gold1); + gold2 = CHAR_getInt(meindex, CHAR_GOLD); + gold2 = gold2 + itemindex2 - itemindex1; + CHAR_setInt(meindex, CHAR_GOLD, gold2); + } + // 宠物 <-> 宠物 + else if ((strcmp(a, "P") == 0) && (strcmp(b, "P") == 0)) + { + char category[8]; + if ((item1 != -1) && (CHAR_CHECKINDEX(item1) == FALSE)) return FALSE; + if ((item2 != -1) && (CHAR_CHECKINDEX(item2) == FALSE)) return FALSE; + + if ((itemindex1 != -1) && (itemindex1 == CHAR_getInt(meindex, CHAR_DEFAULTPET))) + { + int fd; + CHAR_setInt(meindex, CHAR_DEFAULTPET, -1); + fd = getfdFromCharaIndex(meindex); + if (fd != -1){ + CHAR_setWorkInt( meindex, CHAR_WORK_PET0_STAT+itemindex1-1, 0); + lssproto_KS_send(fd, itemindex1, 0); + } + } + if ((itemindex2 != -1)&& (itemindex2 == CHAR_getInt(toindex, CHAR_DEFAULTPET))) + { + int tofd; + CHAR_setInt(toindex, CHAR_DEFAULTPET, -1); + tofd = getfdFromCharaIndex(toindex); + if (tofd != -1){ + CHAR_setWorkInt( toindex, CHAR_WORK_PET0_STAT+itemindex1-1, 0); + lssproto_KS_send(tofd, itemindex2, 0); + } + } + + if (item1 != -1) + CHAR_setWorkInt(item1, CHAR_WORKPLAYERINDEX, toindex); + if (item2 != -1) + CHAR_setWorkInt(item2, CHAR_WORKPLAYERINDEX, meindex); + if (itemindex1 == -1) + itemindex1 = CHAR_getCharPetElement( meindex); + if (itemindex2 == -1) + itemindex2 = CHAR_getCharPetElement( toindex); + CHAR_setCharPet(meindex, itemindex1, item2); + CHAR_setCharPet(toindex, itemindex2, item1); + if ((itemindex1 != -1) && (item1 != -1)) { + + CHAR_setChar(item1, CHAR_OWNERCDKEY, + CHAR_getChar(toindex, CHAR_CDKEY)); + CHAR_setChar(item1, CHAR_OWNERCHARANAME, + CHAR_getChar(toindex, CHAR_NAME)); + + CHAR_complianceParameter(item1); + CHAR_setInt(item1, CHAR_PUTPETTIME, 0); + } + if ((itemindex2 != -1) && (item2 != -1)) { + + CHAR_setChar(item2, CHAR_OWNERCDKEY, + CHAR_getChar(meindex, CHAR_CDKEY)); + CHAR_setChar(item2, CHAR_OWNERCHARANAME, + CHAR_getChar(meindex, CHAR_NAME)); + + CHAR_complianceParameter(item2); + CHAR_setInt(item2, CHAR_PUTPETTIME, 0); + } + snprintf(category, sizeof(category), "K%d", itemindex1); + CHAR_sendStatusString(meindex, category); + snprintf(category, sizeof(category), "W%d", itemindex1); + CHAR_sendStatusString(meindex, category); + snprintf(category, sizeof(category), "K%d", itemindex2); + CHAR_sendStatusString(toindex, category); + snprintf(category, sizeof(category), "W%d", itemindex2); + CHAR_sendStatusString(toindex, category); + } + return TRUE; +} +*/ +BOOL TRADE_HandleItem( int meindex, int showindex, char *message, char *outmess) +{ + char token[256]; + int item, itemindex; + int fd = getfdFromCharaIndex( meindex ); + + if( CONNECT_get_confirm( fd) == TRUE ) return FALSE; + + if( CHAR_getWorkInt( meindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_TRADING + || CHAR_getWorkInt( meindex, CHAR_WORKTRADEMODE) == CHAR_TRADE_LOCK ) + return FALSE; + + if( getStringFromIndexWithDelim( message, "|", 6, token, sizeof( token)) == FALSE) return FALSE; + item = atoi( token); + if( item < CHAR_STARTITEMARRAY || item > CHAR_MAXITEMHAVE ){ + return FALSE; + } + itemindex = CHAR_getItemIndex(meindex, item); + if( !ITEM_CHECKINDEX( itemindex)) return FALSE; + + { + char itemname[256], tmpbuf[256], tmpbuf1[256]; + int crushe; + +#ifdef _ITEM_PILEFORTRADE + int nums = 0; + if( TRADE_addSomeTradeList( meindex, item, &nums, TRADE_ITEM) == FALSE ){ + return FALSE; + } +#endif + strcpy( itemname, ITEM_getChar(itemindex, ITEM_SECRETNAME));//ITEM_NAME + crushe = ITEM_getItemDamageCrusheED( itemindex); + sprintf( token, "不会损坏"); + + if( crushe >= 0 ) snprintf( token, sizeof(token), "%d%%", crushe ); +#ifdef _ITEM_PILENUMS + sprintf( outmess, "%d|%s|%s|%s|%d|%s|%d", +#else + sprintf( outmess, "%d|%s|%s|%d|%s", +#endif + ITEM_getInt( itemindex, ITEM_BASEIMAGENUMBER), + makeEscapeString( ITEM_getChar( itemindex, ITEM_NAME), tmpbuf1, sizeof(tmpbuf1)), + makeEscapeString( itemname, tmpbuf, sizeof(tmpbuf)), + ITEM_getChar(itemindex,ITEM_EFFECTSTRING), item, token +#ifdef _ITEM_PILEFORTRADE + ,nums +#endif + ); + } + return TRUE; +} + +BOOL TRADE_HandleGold( int meindex, int showindex, char *message, char *outmess) +{ + int gold, tmpgold; + char token[256]; + int fd = getfdFromCharaIndex( meindex ); + if(CONNECT_get_confirm( fd)==TRUE)return FALSE; + if (CHAR_getWorkInt(meindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_TRADING + || CHAR_getWorkInt(meindex, CHAR_WORKTRADEMODE) == CHAR_TRADE_LOCK) + return FALSE; + tmpgold = CHAR_getInt(meindex, CHAR_GOLD); + if (getStringFromIndexWithDelim(message, "|", 6, token, sizeof(token)) == FALSE) return FALSE; + if( (gold = atoi(token)) < 0 ) return FALSE; + if( gold > tmpgold )return FALSE; +#ifdef _ITEM_PILEFORTRADE + if( TRADE_addSomeTradeList( meindex, gold, NULL, TRADE_GOLD) == FALSE ) return FALSE; +#endif + sprintf( outmess, "%d", gold); + return TRUE; +} + +BOOL TRADE_HandlePet( int meindex, int showindex, char *message, char *outmess) +{ + int havepetindex, petindex; + char token[256], buf[256]; + int fd = getfdFromCharaIndex( meindex ); + if(CONNECT_get_confirm( fd)==TRUE)return FALSE; + if (CHAR_getWorkInt(meindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_TRADING + || CHAR_getWorkInt(meindex, CHAR_WORKTRADEMODE) == CHAR_TRADE_LOCK) + return FALSE; + if (getStringFromIndexWithDelim(message, "|", 6, token, sizeof(token)) == FALSE) return FALSE; + if( (havepetindex = atoi(token)) < 0 ) return FALSE; + petindex = CHAR_getCharPet(meindex, havepetindex); + if( !CHAR_CHECKINDEX(petindex)) return FALSE; + +#ifdef _ITEM_PILEFORTRADE + if( TRADE_addSomeTradeList( meindex, havepetindex, NULL, TRADE_PET) == FALSE ) return FALSE; +#endif + sprintf( token, "%d|%s|%d|%d|%d|%d|%d|%d", + CHAR_getInt( petindex, CHAR_BASEIMAGENUMBER), + makeEscapeString( CHAR_getUseName(petindex), buf, sizeof(buf)), + CHAR_getInt( petindex, CHAR_LV), + CHAR_getWorkInt( petindex, CHAR_WORKATTACKPOWER), + CHAR_getWorkInt( petindex, CHAR_WORKDEFENCEPOWER), + CHAR_getWorkInt( petindex, CHAR_WORKQUICK), + havepetindex, + CHAR_getInt( petindex , CHAR_TRANSMIGRATION)); + +#ifdef _TRADESYSTEM2 + { + int i; + char skillname[7][256]; + char buf1[256],buf2[256]; + for( i=0; i<7; i++){ + int skillarray, skillID; + memset( skillname[i], 0, sizeof(skillname[i])); + skillID = CHAR_getPetSkill( petindex, i); + skillarray = PETSKILL_getPetskillArray( skillID); + if( !PETSKILL_CHECKINDEX( skillarray)) continue; + sprintf( skillname[i], "%s", PETSKILL_getChar( skillarray, PETSKILL_NAME) ); + } +#ifdef _SHOW_FUSION + sprintf( outmess , "%s|%d|%d|%s|%s|%s|%s|%s|%s|%s|%s|%s|%d", +#else + sprintf( outmess , "%s|%d|%d|%s|%s|%s|%s|%s|%s|%s|%s|%s", +#endif + token , CHAR_getWorkInt(petindex , CHAR_WORKMAXHP) , CHAR_getInt(petindex , CHAR_SLOT), + skillname[0] , skillname[1] , skillname[2] , skillname[3] , + skillname[4] , skillname[5] , skillname[6] , + makeEscapeString( CHAR_getChar( petindex, CHAR_NAME ), buf1, sizeof(buf1)), + makeEscapeString( CHAR_getUseName( petindex), buf2, sizeof(buf2)) +#ifdef _SHOW_FUSION + ,CHAR_getInt ( petindex, CHAR_FUSIONBEIT) ) ; +#else + ); +#endif + } +#else + sprintf( outmess , "%s|%d", token , CHAR_getWorkInt(petindex , CHAR_WORKMAXHP) ); +#endif //_TRADESYSTEM2 + return TRUE; +} + +#ifdef _ITEM_PILEFORTRADE +BOOL TRADE_CheckTradeList( int meindex, STradeList *temp1, int toindex, STradeList *temp2) +{ + int i; + int MeSurplus=0, MeNeeds=0, MeMaxPile; + int ToSurplus=0, ToNeeds=0, ToMaxPile; + + + MeMaxPile = CHAR_getMyMaxPilenum( meindex);//最大堆叠数 + ToMaxPile = CHAR_getMyMaxPilenum( toindex); + + MeSurplus = CHAR_findSurplusItemBox( meindex); + ToSurplus = CHAR_findSurplusItemBox( toindex); + //道具 + ToNeeds=0; MeNeeds=0; + for( i=0; i<15; i++ ){ + int pilenum, itemindex; + if( temp1->ItemTi[i] == -1 ) continue; + itemindex = CHAR_getItemIndex( meindex, temp1->ItemTi[i] ); + if( !ITEM_CHECKINDEX( itemindex)) return FALSE; + pilenum = ITEM_getInt( itemindex, ITEM_USEPILENUMS); + if( temp1->ItemNum[i] == pilenum ){ + MeSurplus++; + } + if( temp1->ItemNum[i] > ToMaxPile ){ + ToNeeds += (temp1->ItemNum[i]/ToMaxPile) + 1; + }else{ + ToNeeds++; + } + } + for( i=0; i<15; i++ ){ + int pilenum, itemindex; + if( temp2->ItemTi[i] == -1 ) continue; + itemindex = CHAR_getItemIndex( toindex, temp2->ItemTi[i] ); + if( !ITEM_CHECKINDEX( itemindex)) return FALSE; + pilenum = ITEM_getInt( itemindex, ITEM_USEPILENUMS); + if( temp2->ItemNum[i] == pilenum){ + ToSurplus++; + } + if( temp2->ItemNum[i] > MeMaxPile ){ + MeNeeds += (temp2->ItemNum[i]/MeMaxPile) + 1; + }else { + MeNeeds++; + } + } + + if( MeSurplus < MeNeeds ){ + CHAR_talkToCli( meindex, -1, "交易後物品栏位不足。", CHAR_COLORYELLOW); + CHAR_talkToCli( toindex, -1, "对方交易後物品栏位不足。", CHAR_COLORYELLOW); + return FALSE; + } + if( ToSurplus < ToNeeds ){ + CHAR_talkToCli( toindex, -1, "交易後物品栏位不足。", CHAR_COLORYELLOW); + CHAR_talkToCli( meindex, -1, "对方交易後物品栏位不足。", CHAR_COLORYELLOW); + return FALSE; + } + + //宠物 + MeSurplus = CHAR_findSurplusPetBox( meindex); + ToSurplus = CHAR_findSurplusPetBox( toindex); + ToNeeds=0; MeNeeds=0; + for( i=0; i<5; i++ ){ + int petindex; + if( temp1->PetTi[i] == -1 ) continue; + petindex = CHAR_getCharPet( meindex, temp1->PetTi[i] ); + if( !CHAR_CHECKINDEX( petindex)) return FALSE; + MeSurplus++; + ToNeeds++; + } + for( i=0; i<5; i++ ){ + int petindex; + if( temp2->PetTi[i] == -1 ) continue; + petindex = CHAR_getCharPet( toindex, temp2->PetTi[i] ); + if( !CHAR_CHECKINDEX( petindex)) return FALSE; + ToSurplus++; + MeNeeds++; + } + + if( MeSurplus < MeNeeds ){ + CHAR_talkToCli( meindex, -1, "交易後宠物栏位不足。", CHAR_COLORYELLOW); + CHAR_talkToCli( toindex, -1, "对方交易後宠物栏位不足。", CHAR_COLORYELLOW); + return FALSE; + } + if( ToSurplus < ToNeeds ){ + CHAR_talkToCli( meindex, -1, "对方交易後宠物栏位不足。", CHAR_COLORYELLOW); + CHAR_talkToCli( toindex, -1, "交易後宠物栏位不足。", CHAR_COLORYELLOW); + return FALSE; + } + + //金钱 + MeMaxPile = CHAR_getMaxHaveGold( meindex); + ToMaxPile = CHAR_getMaxHaveGold( toindex); + MeSurplus = MeMaxPile - CHAR_getInt( meindex, CHAR_GOLD); + ToSurplus = ToMaxPile - CHAR_getInt( toindex, CHAR_GOLD); + ToNeeds=0; MeNeeds=0; + MeSurplus += temp1->Golds; + ToSurplus += temp2->Golds; + ToNeeds = temp1->Golds; + MeNeeds = temp2->Golds; + if( MeSurplus < MeNeeds ){ + CHAR_talkToCli( meindex, -1, "交易後石币超过上限。", CHAR_COLORYELLOW); + CHAR_talkToCli( toindex, -1, "对方交易後石币超过上限。", CHAR_COLORYELLOW); + return FALSE; + } + if( ToSurplus < ToNeeds ){ + CHAR_talkToCli( meindex, -1, "对方交易後石币超过上限。", CHAR_COLORYELLOW); + CHAR_talkToCli( toindex, -1, "交易後石币超过上限。", CHAR_COLORYELLOW); + return FALSE; + } + return TRUE; +} +#endif diff --git a/gmsv/configfile.c b/gmsv/configfile.c new file mode 100644 index 0000000..8f4c1f2 --- /dev/null +++ b/gmsv/configfile.c @@ -0,0 +1,2676 @@ +#define __CONFIGFILE_C__ +#include "version.h" +#include +#include +#include +#include + +#include "util.h" +//#include "configfile.h" +//ttom +#include "lssproto_util.h" +#include "configfile.h" +#include "net.h" +//ttom end +#include "npcutil.h" +// Arminius 7.12 login announce +#include "char.h" +#include "char_data.h" +// CoolFish: add +#include "lssproto_serv.h" + +#include "npc_raceman.h" + +/* 涩烂毛忡 允月厌瞻 */ +typedef struct tagConfig +{ + /*皿夫弘仿丞 (愤 读卞菲户凶中仃升引分蛲 */ + char progname[8]; + + char configfilename[32]; /* config白央奶伙 */ + unsigned char debuglevel; /* 犯田永弘伊矛伙 */ + + unsigned int usememoryunit; /*丢乒伉及交瓦永玄扔奶术 */ + unsigned int usememoryunitnum; /*丢乒伉及交瓦永玄醒 */ + + char asname[32]; /*失市它件玄扔□田及 蟆*/ + unsigned short acservport; /*失市它件玄扔□田及禾□玄 */ + char acpasswd[32]; /*失市它件玄扔□田尺及由旦伐□玉*/ + char gsnamefromas[32]; /* + * 失市它件玄扔□田井日苇尹月 + * 必□丞扔□田午仄化及 蟆 + */ + + // Arminius 7.24 manor pk + char gsid[32]; // game server chinese id +#ifdef _SERVICE + // Terry 2001/10/03 + char apid[32]; // service ap id + unsigned short apport; //service ap port + int looptime; // 几秒後设定离开 + int enableservice; // 是否使用石器服务员功能 +#endif + unsigned short allowmanorpk; // is this server allow manor pk + + unsigned short port; /* 扔□田及谨切熬仃禾□玄 */ + + int servernumber; /* 必□丞扔□田及 寞 */ + int reuseaddr; /* Address already used... 互鞅引日卅中凛及凶户卞 */ + int do_nodelay; /* TCP_NODELAY 卞允月井升丹井 */ + int log_write_time; /* 踏五仇心夫弘毛允月井升丹井[ */ + int log_io_time; /* I/O蝈 及凛棉反井月井升丹井[ */ + int log_game_time; /* 必□丞及质 蝈 及凛棉毛反井月 */ + int log_netloop_faster; /* netloop_faster 及夫弘 */ + int saacwritenum; /* 失市它件玄扔□田尺及窒谛 卞write允月井 */ + int saacreadnum; /* 失市它件玄扔□田井日及dispatch 毛窒荚允月井 */ + + unsigned short fdnum; /*升木分仃戊生弁扑亦件毛忡 允月井 */ + unsigned int othercharnum; /* 公及职及平乓仿及醒 */ + + unsigned int objnum; /* 左皮斥尼弁玄及 醒*/ + unsigned int petcharnum; /* 矢永玄及醒 */ + unsigned int itemnum; /* 失奶 丞及 醒*/ + unsigned int battlenum; /* 田玄伙及 */ + unsigned int battleexp; /* 田玄伙及 */ + + char topdir[64]; /* 玄永皿犯奴伊弁玄伉 */ + + char mapdir[64]; /* 穴永皿犯奴伊弁玄伉 */ + char maptilefile[64]; /* 穴永皿涩烂白央奶伙 */ + char battlemapfile[64]; /* 田玄伙穴永皿涩烂白央奶伙 */ + char itemfile[64]; /* 失奶 丞涩烂白央奶伙 */ + char invfile[64]; /* 衬涩烂白央奶伙 */ + char appearfile[64]; /* 请蜇匏 涩烂白央奶伙 */ + char titlenamefile[64]; /* 惫寞白央奶伙 */ + char titleconfigfile[64]; /* 惫寞涩烂白央奶伙 */ + char encountfile[64]; /* 巨件市它件玄涩烂白央奶伙 */ + char enemybasefile[64]; /* 衬湘 涩烂白央奶伙 */ + char enemyfile[64]; /* 衬涩烂白央奶伙 */ + char groupfile[64]; /* 弘伙□皿涩烂白央奶伙 */ + char magicfile[64]; /* 热诸涩烂白央奶伙 */ + #ifdef __ATTACK_MAGIC + + + char attmagicfile[64]; // 攻击性咒术 + + #endif + + char petskillfile[64]; /* 矢永玄 热诸涩烂白央奶伙 */ + char itematomfile[64]; /* 失奶 丞及笺 白央奶伙 */ + char effectfile[64]; /* 梢请涩烂白央奶伙 */ + char quizfile[64]; /* 弁奶术涩烂白央奶伙 */ + + + char lsgenlog[64]; /*扔□田及lsgen 失它玄皿永玄白央奶伙 */ + + char storedir[64]; /*旦玄失犯奴伊弁玄伉 */ + char npcdir[64]; /*NPC及涩烂白央奶伙毛 仁犯奴伊弁玄伉 */ + + char logdir[64]; /* + * 夫弘犯奴伊弁玄伉 + */ + char logconfname[64]; /* + * 夫弘涩烂白央奶伙 + */ + char chatmagicpasswd[64]; /* 民乓永玄 芊由旦伐□玉 */ + +#ifdef _STORECHAR + char storechar[64]; +#endif + + unsigned int chatmagiccdkeycheck; /* 民乓永玄 芊匹CDKEY毛民尼永弁允月井 */ + + unsigned int filesearchnum; /*白央奶伙毛腹绸匹五月白央奶伙及醒*/ + unsigned int npctemplatenum; /*NPC及 件皿伊□玄白央奶伙及醒*/ + unsigned int npccreatenum; /*NPC及戏遣白央奶伙及醒*/ + unsigned int walksendinterval; /* 汹仁及毛霜月棉厥 */ + unsigned int CAsendinterval_ms; /* CA毛霜月棉厥 (ms)*/ + unsigned int CDsendinterval_ms; /* CD毛霜月棉厥 (ms)*/ + unsigned int Onelooptime_ms; /* 1伙□皿卞井仃月凛棉 */ + unsigned int Petdeletetime; /* 矢永玄互壅 允月凛棉 */ + unsigned int Itemdeletetime; /* 失奶 丞互壅 允月凛棉 */ + /* 夫弘奶件 及平乓仿及本□皮毛允月棉厥 */ + unsigned int CharSavesendinterval; + unsigned int addressbookoffmsgnum; /* + * 失玉伊旦皮永弁卞左白仿奶件 + * 丢永本□斥毛 + * 窒丢永本□斥酸六月井 + */ + + unsigned int protocolreadfrequency; /* + * 皿夫玄戊伙毛窒立伉 + * 卞 戈井 + */ + unsigned int allowerrornum; /* + * 巨仿□毛窒蜊引匹袱允井 + */ + unsigned int loghour; /* + * 夫弘毛忡绣允月凛对 "凛 + */ + unsigned int battledebugmsg; /* + * 田玄伙 及犯田永弘丢永本□斥毛请允井[ㄟ卅日请今卅中 + */ + //ttom add this because the second had this + unsigned int encodekey; + unsigned int acwbsize; + unsigned int acwritesize; + unsigned int ErrUserDownFlg; + //ttom end +#ifdef _GMRELOAD + char gmsetfile[64]; /* GM帐号、权限设定档 */ +#endif + +#ifdef _AUCTIONEER + char auctiondir[256]; // 拍卖资料目录 +#endif +#ifdef _BLACK_MARKET + char blackmarketfile[256]; +#endif +#ifdef _M_SERVER + char msname[32]; + unsigned short msport; +#endif +#ifdef _NPCSERVER_NEW + char nsaddress[64]; + unsigned short nsport; +#endif + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + char profession[64]; +#endif + +#ifdef _ITEM_QUITPARTY + char itemquitparty[64]; +#endif + +#ifdef _MUSEUM + int museum; +#endif + +#ifdef _DEL_DROP_GOLD + unsigned int Golddeletetime; +#endif + +#ifdef _NEW_PLAYER_CF +int newplayertrans; +int newplayerlv; +int newplayergivepet[5]; +int newplayergiveitem[15]; +int newplayerpetlv; +unsigned int newplayergivegold; +#endif + +#ifdef _USER_EXP_CF +char expfile[64]; +#endif + +#ifdef _UNLAW_WARP_FLOOR +int unlawwarpfloor[5]; +#endif + +#ifdef _UNREG_NEMA +char unregname[5][16]; +#endif + +#ifdef _TRANS_LEVEL_CF +int chartrans; +int pettrans; +int yblevel; +#endif + +#ifdef _LOCK_IP +char lockip[64]; +#endif +}Config; +Config config; + +#ifdef _USER_EXP_CF +int NeedLevelUpTbls[160]; +int MaxLevel=0; +#endif + +#ifdef _LOCK_IP +typedef struct slockip +{ + int a,b,c,d; + int locktime; + int logintime; +}sLockip; +sLockip lockip[100]; + +int maxlockip=0; +#endif +/* + * 戊件白奴弘白央奶伙毛 戈凛卞银丹厌瞻 + * xxxx=yyyy 心凶中卅及毛 戈 + */ + +typedef struct tagReadConf +{ + char name[32]; /*xxxx卞丐凶月袄*/ + + /*戚及2勾反NULL毛 木月午窒手质 仄卅中*/ + char *charvalue; /*yyyy毛公及引引医 允月凛及医 燮*/ + size_t charsize; /*charvalue及扔奶术*/ + + /* + * 酷 午仄化=及 互 "ON"分匀凶日 intvalue 卞反1毛医 允月 + * 公木动陆反 atoi 及瑛绊 + */ + void* value; /*yyyy毛 晶允月医 允月凛及医 燮*/ + CTYPE valuetype; +}ReadConf; + +ReadConf readconf[]= +{ + { "debuglevel" , NULL ,0 , (void*)&config.debuglevel ,CHAR}, + + { "usememoryunit" , NULL ,0 , (void*)&config.usememoryunit ,INT}, + { "usememoryunitnum", NULL ,0 , (void*)&config.usememoryunitnum,INT}, + + { "acserv", config.asname,sizeof(config.asname) ,NULL , 0}, + { "acservport", NULL ,0 , (void*)&config.acservport ,SHORT}, + { "acpasswd", config.acpasswd,sizeof( config.acpasswd),NULL,0}, + { "gameservname", config.gsnamefromas,sizeof(config.gsnamefromas), + NULL,0}, + + // Arminius 7.24 manor pk + { "gameservid", config.gsid, sizeof(config.gsid), NULL, 0}, +#ifdef _SERVICE + // Terry 2001/10/03 service ap + { "apid", config.apid, sizeof(config.apid), NULL, 0}, + { "apport", NULL ,0 ,(void*)&config.apport ,SHORT}, + { "looptime",NULL,0,(void*)&config.looptime,INT}, + { "enableservice",NULL,0,(void*)&config.enableservice,INT}, +#endif + { "allowmanorpk", NULL, 0, (void*)&config.allowmanorpk, SHORT}, + + { "port", NULL ,0 , (void*)&config.port ,SHORT}, + { "servernumber", NULL ,0 , (void*)&config.servernumber ,INT}, + + { "reuseaddr", NULL ,0 , (void*)&config.reuseaddr , INT}, + { "nodelay", NULL , 0 , (void*)&config.do_nodelay , INT}, + { "log_write_time", NULL, 0 , (void*)&config.log_write_time, INT}, + { "log_io_time", NULL, 0 , (void*)&config.log_io_time, INT}, + { "log_game_time", NULL, 0 , (void*)&config.log_game_time, INT}, + { "log_netloop_faster", NULL,0,(void*)&config.log_netloop_faster, INT}, + { "saacwritenum", NULL,0,(void*)&config.saacwritenum, INT}, + { "saacreadnum", NULL,0,(void*)&config.saacreadnum, INT}, + { "fdnum", NULL ,0 , (void*)&config.fdnum, SHORT}, + { "petnum", NULL ,0 , (void*)&config.petcharnum, INT}, + { "othercharnum", NULL ,0 , (void*)&config.othercharnum, INT}, + + { "objnum", NULL ,0 , (void*)&config.objnum, INT}, + { "itemnum", NULL ,0 , (void*)&config.itemnum, INT}, + { "battlenum", NULL ,0 , (void*)&config.battlenum, INT}, + { "battleexp", NULL ,0 , (void*)&config.battleexp, INT}, + { "topdir" , config.topdir,sizeof(config.topdir),NULL,0}, + { "mapdir" , config.mapdir,sizeof(config.mapdir),NULL,0}, + { "maptilefile" , config.maptilefile,sizeof(config.maptilefile),NULL,0}, + { "battlemapfile" , config.battlemapfile,sizeof(config.battlemapfile),NULL,0}, + +#ifdef _ITEMSET6_TXT + { "itemset6file", config.itemfile, sizeof(config.invfile), NULL, 0}, +#else +#ifdef _ITEMSET5_TXT + { "itemset5file", config.itemfile, sizeof(config.invfile), NULL, 0}, +#else +#ifdef _ITEMSET4_TXT + { "itemset4file" , config.itemfile,sizeof(config.invfile),NULL,0}, +#else +#ifdef _ITEMSET3_ITEM + { "itemset3file" , config.itemfile,sizeof(config.invfile),NULL,0}, +#endif +#endif +#endif +#endif + { "invinciblefile" , config.invfile,sizeof(config.invfile),NULL,0}, + { "appearpositionfile" , config.appearfile,sizeof(config.appearfile),NULL,0}, + { "titlenamefile", config.titlenamefile, sizeof( config.titlenamefile),NULL,0}, + { "titleconfigfile", config.titleconfigfile, sizeof( config.titleconfigfile),NULL,0}, + { "encountfile", config.encountfile, sizeof( config.encountfile),NULL,0}, + { "enemyfile", config.enemyfile, sizeof( config.enemyfile),NULL,0}, + { "enemybasefile", config.enemybasefile, sizeof( config.enemybasefile),NULL,0}, + { "groupfile", config.groupfile, sizeof( config.groupfile),NULL,0}, + { "magicfile", config.magicfile, sizeof( config.magicfile),NULL,0}, +#ifdef __ATTACK_MAGIC + { "attmagicfile" , config.attmagicfile , sizeof( config.attmagicfile ) , NULL , 0 }, +#endif + +#ifdef _PETSKILL2_TXT + { "petskillfile2", config.petskillfile, sizeof( config.petskillfile),NULL,0}, +#else + { "petskillfile1", config.petskillfile, sizeof( config.petskillfile),NULL,0}, +#endif + + { "itematomfile" , config.itematomfile, sizeof( config.itematomfile),NULL,0}, + { "effectfile" , config.effectfile,sizeof(config.effectfile),NULL,0}, + { "quizfile" , config.quizfile,sizeof(config.quizfile),NULL,0}, + + { "lsgenlogfilename", config.lsgenlog,sizeof(config.lsgenlog),NULL,0}, +#ifdef _GMRELOAD + { "gmsetfile", config.gmsetfile, sizeof( config.gmsetfile),NULL,0}, +#endif + + { "storedir" ,config.storedir,sizeof(config.storedir),NULL,0}, + { "npcdir" ,config.npcdir,sizeof(config.npcdir),NULL,0}, + { "logdir" ,config.logdir,sizeof(config.logdir),NULL,0}, + { "logconfname" ,config.logconfname,sizeof(config.logconfname),NULL,0}, + { "chatmagicpasswd", config.chatmagicpasswd, sizeof( config.chatmagicpasswd),NULL,0}, +#ifdef _STORECHAR + { "storechar", config.storechar, sizeof( config.storechar),NULL,0}, +#endif + { "chatmagiccdkeycheck", NULL,0, &config.chatmagiccdkeycheck,INT}, + { "filesearchnum", NULL,0, &config.filesearchnum,INT}, + { "npctemplatenum", NULL,0, &config.npctemplatenum,INT}, + { "npccreatenum", NULL,0, &config.npccreatenum,INT}, + { "walkinterval" ,NULL,0,(void*)&config.walksendinterval,INT}, + { "CAinterval" ,NULL,0,(void*)&config.CAsendinterval_ms,INT}, + { "CDinterval" ,NULL,0,(void*)&config.CDsendinterval_ms,INT}, + { "CharSaveinterval" ,NULL,0,(void*)&config.CharSavesendinterval,INT}, + { "Onelooptime" ,NULL,0,(void*)&config.Onelooptime_ms,INT}, + { "Petdeletetime" ,NULL,0,(void*)&config.Petdeletetime,INT}, + { "Itemdeletetime" ,NULL,0,(void*)&config.Itemdeletetime,INT}, + { "addressbookoffmesgnum" ,NULL,0, + (void*)&config.addressbookoffmsgnum,INT}, + + { "protocolreadfrequency" ,NULL,0, + (void*)&config.protocolreadfrequency,INT}, + + { "allowerrornum" ,NULL,0,(void*)&config.allowerrornum,INT}, + { "loghour" ,NULL,0,(void*)&config.loghour,INT}, + { "battledebugmsg" ,NULL,0,(void*)&config.battledebugmsg,INT}, + //ttom add because the second had + { "encodekey" ,NULL,0,(void*)&config.encodekey,INT}, + { "acwritesize" ,NULL,0,(void*)&config.acwritesize,INT}, + { "acwbsize" ,NULL,0,(void*)&config.acwbsize,INT}, + { "erruser_down" ,NULL,0,(void*)&config.ErrUserDownFlg,INT}, + //ttom end +#ifdef _AUCTIONEER + { "auctiondir" , config.auctiondir, sizeof(config.auctiondir),NULL,0}, +#endif +#ifdef _BLACK_MARKET + { "blackmarketfile", config.blackmarketfile, sizeof(config.blackmarketfile), NULL, 0}, +#endif +#ifdef _M_SERVER + { "msname", config.msname,sizeof(config.msname) ,NULL , 0}, + { "msport", NULL ,0 , (void*)&config.msport ,SHORT}, +#endif +#ifdef _NPCSERVER_NEW + { "npcaddress", config.nsaddress, sizeof(config.nsaddress) ,NULL , 0}, + { "nsport", NULL, 0 , (void*)&config.nsport ,SHORT}, +#endif + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + { "profession", config.profession, sizeof(config.profession) ,NULL , 0}, +#endif + +#ifdef _ITEM_QUITPARTY + { "itemquitparty", config.itemquitparty, sizeof(config.itemquitparty) ,NULL , 0}, +#endif + +#ifdef _MUSEUM + { "museum", NULL , 0 , (void*)&config.museum , INT}, +#endif + +#ifdef _DEL_DROP_GOLD + { "Golddeletetime" ,NULL,0,(void*)&config.Golddeletetime, INT}, +#endif + +#ifdef _NEW_PLAYER_CF + { "TRANS" ,NULL,0,(void*)&config.newplayertrans, INT}, + { "LV" ,NULL,0,(void*)&config.newplayerlv, INT}, + { "PET1" ,NULL,0,(void*)&config.newplayergivepet[1], INT}, + { "PET2" ,NULL,0,(void*)&config.newplayergivepet[2], INT}, + { "PET3" ,NULL,0,(void*)&config.newplayergivepet[3], INT}, + { "PET4" ,NULL,0,(void*)&config.newplayergivepet[4], INT}, + { "ITEM1" ,NULL,0,(void*)&config.newplayergiveitem[0], INT}, + { "ITEM2" ,NULL,0,(void*)&config.newplayergiveitem[1], INT}, + { "ITEM3" ,NULL,0,(void*)&config.newplayergiveitem[2], INT}, + { "ITEM4" ,NULL,0,(void*)&config.newplayergiveitem[3], INT}, + { "ITEM5" ,NULL,0,(void*)&config.newplayergiveitem[4], INT}, + { "ITEM6" ,NULL,0,(void*)&config.newplayergiveitem[5], INT}, + { "ITEM7" ,NULL,0,(void*)&config.newplayergiveitem[6], INT}, + { "ITEM8" ,NULL,0,(void*)&config.newplayergiveitem[7], INT}, + { "ITEM9" ,NULL,0,(void*)&config.newplayergiveitem[8], INT}, + { "ITEM10" ,NULL,0,(void*)&config.newplayergiveitem[9], INT}, + { "ITEM11" ,NULL,0,(void*)&config.newplayergiveitem[10], INT}, + { "ITEM12" ,NULL,0,(void*)&config.newplayergiveitem[11], INT}, + { "ITEM13" ,NULL,0,(void*)&config.newplayergiveitem[12], INT}, + { "ITEM14" ,NULL,0,(void*)&config.newplayergiveitem[13], INT}, + { "ITEM15" ,NULL,0,(void*)&config.newplayergiveitem[14], INT}, + { "PETLV" ,NULL,0,(void*)&config.newplayerpetlv, INT}, + { "GOLD" ,NULL,0,(void*)&config.newplayergivegold, INT}, +#endif + +#ifdef _USER_EXP_CF + { "USEREXP", config.expfile, sizeof( config.expfile),NULL,0}, +#endif + +#ifdef _UNLAW_WARP_FLOOR + { "FLOOR1" ,NULL,0,(void*)&config.unlawwarpfloor[0], INT}, + { "FLOOR2" ,NULL,0,(void*)&config.unlawwarpfloor[1], INT}, + { "FLOOR3" ,NULL,0,(void*)&config.unlawwarpfloor[2], INT}, + { "FLOOR4" ,NULL,0,(void*)&config.unlawwarpfloor[3], INT}, + { "FLOOR5" ,NULL,0,(void*)&config.unlawwarpfloor[4], INT}, +#endif +#ifdef _UNREG_NEMA + { "NAME1" ,config.unregname[0], sizeof( config.unregname[0]),NULL,0}, + { "NAME2" ,config.unregname[1], sizeof( config.unregname[1]),NULL,0}, + { "NAME3" ,config.unregname[2], sizeof( config.unregname[2]),NULL,0}, + { "NAME4" ,config.unregname[3], sizeof( config.unregname[3]),NULL,0}, + { "NAME5" ,config.unregname[4], sizeof( config.unregname[4]),NULL,0}, +#endif +#ifdef _TRANS_LEVEL_CF + { "CHARTRANS" ,NULL,0,(void*)&config.chartrans, INT}, + { "PETTRANS" ,NULL,0,(void*)&config.pettrans, INT}, + { "LEVEL" ,NULL,0,(void*)&config.yblevel, INT}, +#endif +#ifdef _LOCK_IP + { "LOCKIP" ,config.lockip, sizeof( config.lockip),NULL,0}, +#endif + +}; + +// Arminius 7.12 login announce +char announcetext[8192]; +void AnnounceToPlayer(int charaindex) +{ + char *ptr,*qtr; + + ptr=announcetext; + while ((qtr=strstr(ptr,"\n"))!=NULL) { + qtr[0]='\0'; +// printf("ptr=%s\n",ptr); + CHAR_talkToCli(charaindex, -1, ptr, CHAR_COLORYELLOW); + qtr[0]='\n'; + ptr=qtr+1; + } + CHAR_talkToCli(charaindex, -1, ptr, CHAR_COLORYELLOW); + +} + +// Robin 0720 +void AnnounceToPlayerWN(int fd) +{ + char buf[8192]; + lssproto_WN_send( fd , WINDOW_MESSAGETYPE_LOGINMESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString( announcetext, buf, sizeof(buf)) + ); +} + + +void LoadAnnounce(void) +{ + FILE *f; + + memset(announcetext, 0, sizeof(announcetext)); + if ((f=fopen("./announce.txt","r"))!=NULL) { + fread(announcetext, sizeof(announcetext), 1, f); + announcetext[sizeof(announcetext)-1]='\0'; + fclose(f); + } +} +#ifdef _PET_TALKPRO +PTALK pettalktext[PETTALK_MAXID]; + +void LoadPetTalk(void) +{ + FILE *fp; + char fn[256]; + char line[ 4096]; + char talkmem[4096]; + int maxid=0; + char buf1[256], buf2[256], buf3[256]; + int talkNO=-1, mark=-1, i; + int len = sizeof( talkmem); + + memset(talkmem, 0, sizeof(talkmem)); + sprintf(fn, "%s/pettalk/pettalk.menu", getNpcdir()); + + for( i=0;i= PETTALK_MAXID ) + break; + } + print("最大ID=%d...", maxid); + { + int haveid=0; + for( i=0;i= 0 ) { + haveid++; + } + } + print("载入总数=%d", haveid); + } + +} + +#else +char pettalktext[4096]; +void LoadPetTalk(void) +{ + FILE *fp; + char fn[256]; + char line[ 4096]; + int len = sizeof( pettalktext); + + memset(pettalktext, 0, sizeof(pettalktext)); + sprintf(fn, "%s/pettalk/pettalk.mem", getNpcdir()); + + fp = fopen( fn, "r"); + if( fp != NULL ) { + print("\n\n 读取 pettalk.mem"); + while( fgets( line, sizeof( line), fp)) { + if( strlen( pettalktext) != 0 ) { + if( pettalktext[strlen( pettalktext) -1] != '|' ) { + strcatsafe( pettalktext, len, "|"); + } + } + chompex( line); + strcatsafe( pettalktext,len, line); + } + fclose( fp); + print("\n %s", pettalktext); + }else { + print("\n 不能找到 pettalk.mem"); + } +} +#endif + +#ifdef _GAMBLE_BANK +GAMBLEBANK_ITEMS GB_ITEMS[GAMBLEBANK_ITEMSMAX]; + +void Load_GambleBankItems( void) +{ + + FILE *fp; + char filename[256]; + char buf1[256]; + char name[128]; + int num,ID,type; + int i=0; + sprintf(filename, "./data/gambleitems.txt" ); + print("\n加载赌博物品文件 %s ...", filename); + fp = fopen( filename, "r"); + if( fp != NULL ) { + while( fgets( buf1, sizeof( buf1), fp) != NULL ) { + if( strstr( buf1, "#") != 0 ) continue; + sscanf( buf1,"%s %d %d %d", name, &ID, &num , &type); + strcpy( GB_ITEMS[i].name, name); + GB_ITEMS[i].Gnum = num; + GB_ITEMS[i].ItemId = ID; + GB_ITEMS[i].type = type; + i++; + } + print("最大ID: %d ", i); + fclose( fp); + }else { + print("错误 找不到文件 %s", filename); + } + +} +#endif + + +#ifdef _CFREE_petskill +PETSKILL_CODES Code_skill[PETSKILL_CODE]; +void Load_PetSkillCodes( void) +{ + FILE *fp; + char filename[256]; + char buf1[256]; + char name[128]; + char type[256]; + int num,ID; + int i=0; + sprintf(filename, "./data/skillcode.txt" ); + print("\n加载宠物技能编码文件:%s...", filename); + fp = fopen( filename, "r"); + if( fp != NULL ) { + while( fgets( buf1, sizeof( buf1), fp) != NULL ) { + sscanf( buf1,"%s %d %d %s", name, &num, &ID, type); + strcpy( Code_skill[i].name, name); + Code_skill[i].TempNo = num; + Code_skill[i].PetId = ID; + strcpy( Code_skill[i].Code, type); + //print("\n %s|%d|%d|%s|", Code_skill[i].name, Code_skill[i].TempNo, + // Code_skill[i].PetId, Code_skill[i].Code); + i++; + if( i >= PETSKILL_CODE ) break; + } + fclose( fp); + }else { + print("打不到文件 %s", filename); + } + print("完成\n"); +} +#endif + +#ifdef _BLACK_MARKET +BOOL LoadBMItem( char* filename) +{ + FILE *fp; + int i, j, k; + char line[512]="", cTmp[256]=""; + char *ip=NULL, *gp=NULL; + + for(i=0; i=BMIMAX){ + print("\n警告!! 物口数目超越范围(%d).", BMIMAX); + break; + } + sscanf( line, "%s %d %s %s %s %s %s", + BMItem[BMINum].iName, + &BMItem[BMINum].iGraphicsNum, + iTmp1, iTmp2, iTmp3, iTmp4, cTmp); + + for(i=0; i<3; i++){ + if(getStringFromIndexWithDelim( iTmp1, ",", i+1, iTmp5, sizeof( iTmp5))!=FALSE) + BMItem[BMINum].iId[0][i] = atoi(iTmp5); + if(getStringFromIndexWithDelim( iTmp2, ",", i+1, iTmp5, sizeof( iTmp5))!=FALSE) + BMItem[BMINum].iId[1][i] = atoi(iTmp5); + if(getStringFromIndexWithDelim( iTmp3, ",", i+1, iTmp5, sizeof( iTmp5))!=FALSE) + BMItem[BMINum].iId[2][i] = atoi(iTmp5); + if(getStringFromIndexWithDelim( iTmp4, ",", i+1, iTmp5, sizeof( iTmp5))!=FALSE) + BMItem[BMINum].iId[3][i] = atoi(iTmp5); + } + + ip = strstr( cTmp, "I"); + gp = strstr( cTmp, "G"); + + if( ip && gp && gp>ip){ + strncpy( cTmp1, ip+1, gp-ip-1); + for(i=0; i<4; i++) + if(getStringFromIndexWithDelim( cTmp1, ",", i+1, cTmp3, sizeof( cTmp3))!=FALSE) + BMItem[BMINum].iCondition[i] = atoi(cTmp3); + strcpy( cTmp2, gp+1); + BMItem[BMINum].GCondition = atoi(cTmp2); + }else if( ip && gp && gp GMMAXNUM) break; + easyGetTokenFromString(line, 1, cdkey, sizeof(cdkey)); + if (strcmp(cdkey, "") == 0) break; + strncpy(gminfo[gm_num].cdkey, cdkey, sizeof(gminfo[gm_num].cdkey)); + easyGetTokenFromString(line, 2, level, sizeof(level)); + if (strcmp(level, "") == 0) break; + gminfo[gm_num].level = atoi(level); +// print("\ncdkey:%s, level:%d", gminfo[gm_num].cdkey, gminfo[gm_num].level); + } + fclose(fp); + return TRUE; +} +#endif + +/*------------------------------------------------------------ + * 皿夫弘仿丞 毛 月 + * 娄醒 + * 卅仄 + * 忒曰袄 + * cahr* + ------------------------------------------------------------*/ +char* getProgname( void ) +{ + return config.progname; +} +/*------------------------------------------------------------ + * configfilename 毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * char* + ------------------------------------------------------------*/ +char* getConfigfilename( void ) +{ + return config.configfilename; +} +/*------------------------------------------------------------ + * configfilename 毛涩烂允月[ + * 娄醒 + * newv char* 蕙仄中袄 + * 忒曰袄 + * 卅仄 + ------------------------------------------------------------*/ +void setConfigfilename( char* newv ) +{ + strcpysafe( config.configfilename, sizeof( config.configfilename ), + newv ); +} + +/*------------------------------------------------------------ + * 犯田永弘伊矛伙毛 月 + * 娄醒 + * 卅仄 + * 忒曰袄 + * unsigned int + ------------------------------------------------------------*/ +unsigned int getDebuglevel( void ) +{ + return config.debuglevel; +} +/*------------------------------------------------------------ + * 犯田永弘伊矛伙毛涩烂允月 + * 娄醒 + * newv int 蕙仄中袄 + * 忒曰袄 + * unsigned int 樯及袄 + ------------------------------------------------------------*/ +unsigned int setDebuglevel( unsigned int newv ) +{ + int old; + old = config.debuglevel; + config.debuglevel = newv; + return old; +} +/*------------------------------------------------------------ + * memoryunit 毛 月 + * 娄醒 + * 卅仄 + * 忒曰袄 + * unsigned int + ------------------------------------------------------------*/ +unsigned int getMemoryunit( void ) +{ + return config.usememoryunit; +} +/*------------------------------------------------------------ + * memoryunitnum 毛 月 + * 娄醒 + * 卅仄 + * 忒曰袄 + * unsigned int + ------------------------------------------------------------*/ +unsigned int getMemoryunitnum( void ) +{ + return config.usememoryunitnum; +} + +/*------------------------------------------------------------ + * 失市它件玄扔□田及失玉伊旦毛 月 + * 娄醒 + * 卅仄 + * 忒曰袄 + * char* + ------------------------------------------------------------*/ +char* getAccountservername( void ) +{ + return config.asname; +} +/*------------------------------------------------------------ + * 失市它件玄扔□田及禾□玄毛 月 + * 娄醒 + * 卅仄 + * 忒曰袄 + * unsigned short + ------------------------------------------------------------*/ +unsigned short getAccountserverport( void ) +{ + return config.acservport; +} +/*------------------------------------------------------------ + * 失市它件玄扔□田尺及由旦伐□玉毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * unsigned short + ------------------------------------------------------------*/ +char* getAccountserverpasswd( void ) +{ + return config.acpasswd; +} +/*------------------------------------------------------------ + * 失市它件玄扔□田井日苇尹月必□丞扔□田午仄化及 蟆毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * unsigned short + ------------------------------------------------------------*/ +char* getGameservername( void ) +{ + return config.gsnamefromas; +} + +// Arminius 7.24 manor pk +char* getGameserverID( void ) +{ + if (config.gsid[strlen(config.gsid)-1]=='\n') + config.gsid[strlen(config.gsid)-1]='\0'; + + return config.gsid; +} + +#ifdef _SERVICE +// Terry 2001/10/03 +char* getApID(void) +{ + return config.apid; +} + +unsigned short getApPort(void) +{ + return config.apport; +} + +int getLoopTime(void) +{ + return config.looptime; +} + +int getEnableService(void) +{ + return config.enableservice; +} +#endif + +unsigned short getAllowManorPK( void ) +{ + return config.allowmanorpk; +} + +unsigned short getPortnumber( void ) +{ + return config.port; +} +/*------------------------------------------------------------ + * 必□丞扔□田及 寞 寞毛 月 + * 娄醒 + * 卅仄 + * 忒曰袄 + * unsigned short + ------------------------------------------------------------*/ +int getServernumber( void ) +{ + return config.servernumber; +} +/*------------------------------------------------------------ + * reuseaddr 及袄毛 月 + * 娄醒 + * 卅仄 + * 忒曰袄 + * unsigned short + ------------------------------------------------------------*/ +int getReuseaddr( void ) +{ + return config.reuseaddr; +} + +int getNodelay( void ) +{ + return config.do_nodelay; +} +int getLogWriteTime(void) +{ + return config.log_write_time; +} +int getLogIOTime( void) +{ + return config.log_io_time; +} +int getLogGameTime(void) +{ + return config.log_game_time; +} +int getLogNetloopFaster(void) +{ + return config.log_netloop_faster; +} + +/*------------------------------------------------------------ + * saacwritenum 毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * int + ------------------------------------------------------------*/ +int getSaacwritenum( void ) +{ + return config.saacwritenum; +} +/*------------------------------------------------------------ + * saacwritenum 毛涩烂允月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * int + ------------------------------------------------------------*/ +void setSaacwritenum( int num ) +{ + config.saacwritenum = num; +} +/*------------------------------------------------------------ + * saacreadnum 毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * int + ------------------------------------------------------------*/ +int getSaacreadnum( void ) +{ + return config.saacreadnum; +} +/*------------------------------------------------------------ + * saacreadnum 毛涩烂允月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * int + ------------------------------------------------------------*/ +void setSaacreadnum( int num ) +{ + config.saacreadnum = num; +} +/*------------------------------------------------------------ + * fdnum 毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * unsigned int + ------------------------------------------------------------*/ +unsigned int getFdnum( void ) +{ + return config.fdnum; +} +/*------------------------------------------------------------ + * petcharanum 毛 月 + * 娄醒 + * 卅仄 + * 忒曰袄 + * unsigned int + ------------------------------------------------------------*/ +unsigned int getPetcharnum( void ) +{ + return config.petcharnum; +} + + +/*------------------------------------------------------------ + * othercharnum 毛 月 + * 娄醒 + * 卅仄 + * 忒曰袄 + * unsigned int + ------------------------------------------------------------*/ +unsigned int getOtherscharnum( void ) +{ + return config.othercharnum; +} + +/*------------------------------------------------------------ + * objnum 毛 月 + * 娄醒 + * 卅仄 + * 忒曰袄 + * unsigned int + ------------------------------------------------------------*/ +unsigned int getObjnum( void ) +{ + return config.objnum; +} + +/*------------------------------------------------------------ + * itemnum 毛 月 + * 娄醒 + * 卅仄 + * 忒曰袄 + * unsigned int + ------------------------------------------------------------*/ +unsigned int getItemnum( void ) +{ + return config.itemnum; +} + + +/*------------------------------------------------------------ + * battlenum 毛 月 + * 娄醒 + * 卅仄 + * 忒曰袄 + * unsigned int + ------------------------------------------------------------*/ +unsigned int getBattlenum( void ) +{ + return config.battlenum; +} + +#ifdef _GET_BATTLE_EXP +unsigned int getBattleexp( void ) +{ + return config.battleexp; +} +#endif +/*------------------------------------------------------------ + * topdir 毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * char* + ------------------------------------------------------------*/ +char* getTopdir( void ) +{ + return config.topdir; +} +/*------------------------------------------------------------ + * mapdir 毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * char* + ------------------------------------------------------------*/ +char* getMapdir( void ) +{ + return config.mapdir; +} +/*------------------------------------------------------------ + * maptilefile 毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * char* + ------------------------------------------------------------*/ +char* getMaptilefile( void ) +{ + return config.maptilefile; +} +/*------------------------------------------------------------ + * battlemapfile 毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * char* + ------------------------------------------------------------*/ +char* getBattleMapfile( void ) +{ + return config.battlemapfile; +} +/*------------------------------------------------------------ + * itemfile 毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * char* + ------------------------------------------------------------*/ +char* getItemfile( void ) +{ + return config.itemfile; +} +/*------------------------------------------------------------ + * invfile 毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * char* + ------------------------------------------------------------*/ +char* getInvfile( void ) +{ + return config.invfile; +} +/*------------------------------------------------------------ + * appearfile 毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * char* + ------------------------------------------------------------*/ +char* getAppearfile( void ) +{ + return config.appearfile; +} +/*------------------------------------------------------------ + * effectfile 毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * char* + ------------------------------------------------------------*/ +char* getEffectfile( void ) +{ + return config.effectfile; +} +/*------------------------------------------------------------ + * titlenamefile 毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * char* + ------------------------------------------------------------*/ +char* getTitleNamefile( void ) +{ + return config.titlenamefile; +} +/*------------------------------------------------------------ + * titleconfigfile 毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * char* + ------------------------------------------------------------*/ +char* getTitleConfigfile( void ) +{ + return config.titleconfigfile; +} +/*------------------------------------------------------------ + * encountfile 毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * char* + ------------------------------------------------------------*/ +char* getEncountfile( void ) +{ + return config.encountfile; +} +/*------------------------------------------------------------ + * enemyfile 毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * char* + ------------------------------------------------------------*/ +char* getEnemyfile( void ) +{ + return config.enemyfile; +} +/*------------------------------------------------------------ + * enemybasefile 毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * char* + ------------------------------------------------------------*/ +char* getEnemyBasefile( void ) +{ + return config.enemybasefile; +} +/*------------------------------------------------------------ + * groupfile 毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * char* + ------------------------------------------------------------*/ +char* getGroupfile( void ) +{ + return config.groupfile; +} +/*------------------------------------------------------------ + * magicfile 毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * char* + ------------------------------------------------------------*/ +char* getMagicfile( void ) +{ + return config.magicfile; +} + +#ifdef __ATTACK_MAGIC + +/*------------------------------------------------------------ + * 取得攻击性的咒术 + * 参数 + * None + * 返回值 + * char* + ------------------------------------------------------------*/ +char* getAttMagicfileName( void ) +{ + return config.attmagicfile; +} + +#endif + + +char* getPetskillfile( void ) +{ + return config.petskillfile; +} + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 +char* getProfession( void ) +{ + return config.profession; +} +#endif + +#ifdef _ITEM_QUITPARTY +char* getitemquitparty( void ) +{ + return config.itemquitparty; +} +#endif + +char *getItematomfile( void ) +{ + return config.itematomfile; +} + + +char* getQuizfile( void ) +{ + return config.quizfile; +} + +/*------------------------------------------------------------ + * lsgenlogfile 毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * char* + ------------------------------------------------------------*/ +char* getLsgenlogfilename( void ) +{ + return config.lsgenlog; +} + +#ifdef _BLACK_MARKET +char* getBMItemFile(void){ + return config.blackmarketfile; +} +#endif + +#ifdef _GMRELOAD +char* getGMSetfile( void ) +{ + return config.gmsetfile; +} +#endif + +/*------------------------------------------------------------ + * storedir 毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * char* + ------------------------------------------------------------*/ +char* getStoredir( void ) +{ + return config.storedir; +} +#ifdef _STORECHAR +/*------------------------------------------------------------ + ------------------------------------------------------------*/ +char* getStorechar( void ) +{ + return config.storechar; +} +#endif + +#ifdef _AUCTIONEER +char* getAuctiondir(void) +{ + return config.auctiondir; +} +#endif + +/*------------------------------------------------------------ + * NPC 迕及犯奴伊弁玄伉毛 化仁月楮醒 + * 娄醒 + * 卅仄 + * 忒曰袄 + * char* + ------------------------------------------------------------*/ +char* getNpcdir( void ) +{ + return config.npcdir; +} +/*------------------------------------------------------------ + * 夫弘犯奴伊弁玄伉毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * char* + ------------------------------------------------------------*/ +char* getLogdir( void ) +{ + return config.logdir; +} + +/*------------------------------------------------------------ + * 夫弘涩烂白央奶伙 毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * char* + ------------------------------------------------------------*/ +char* getLogconffile( void ) +{ + return config.logconfname; +} +/*------------------------------------------------------------ + * 民乓永玄 芊由旦伐□玉 毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * char* + ------------------------------------------------------------*/ +char* getChatMagicPasswd( void ) +{ + return config.chatmagicpasswd; +} +/*------------------------------------------------------------ + * 犯田永弘民乓永玄 芊匹及CDKEY民尼永弁毛允月井升丹井毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * char* + ------------------------------------------------------------*/ +unsigned getChatMagicCDKeyCheck( void ) +{ + return config.chatmagiccdkeycheck; +} + +/*------------------------------------------------------------ + * filesearchnum毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * unsigned int + ------------------------------------------------------------*/ +unsigned int getFilesearchnum( void ) +{ + return config.filesearchnum; +} +/*------------------------------------------------------------ + * npctemplatenum毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * unsigned int + ------------------------------------------------------------*/ +unsigned int getNpctemplatenum( void ) +{ + return config.npctemplatenum; +} +/*------------------------------------------------------------ + * npccreatenum毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * unsigned int + ------------------------------------------------------------*/ +unsigned int getNpccreatenum( void ) +{ + return config.npccreatenum; +} + +/*------------------------------------------------------------ + * walksendinterval毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * unsigned int + ------------------------------------------------------------*/ +unsigned int getWalksendinterval( void ) +{ + return config.walksendinterval; +} +/*------------------------------------------------------------ + * walksendinterval毛本永玄允月[ + * 娄醒 + * unsigned int interval 凛棉 立伉 + * 忒曰袄 + * void + ------------------------------------------------------------*/ +void setWalksendinterval( unsigned int interval ) +{ + config.walksendinterval = interval; +} +/*------------------------------------------------------------ + * CAsendinterval毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * unsigned int + ------------------------------------------------------------*/ +unsigned int getCAsendinterval_ms( void ) +{ + return config.CAsendinterval_ms; +} +/*------------------------------------------------------------ + * CAsendinterval毛本永玄允月[ + * 娄醒 + * unsigned int interval + * 忒曰袄 + * unsigned int + ------------------------------------------------------------*/ +void setCAsendinterval_ms( unsigned int interval_ms ) +{ + config.CAsendinterval_ms = interval_ms; +} +/*------------------------------------------------------------ + * CDsendinterval毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * unsigned int + ------------------------------------------------------------*/ +unsigned int getCDsendinterval_ms( void ) +{ + return config.CDsendinterval_ms; +} +/*------------------------------------------------------------ + * CDsendinterval毛本永玄允月[ + * 娄醒 + * interval unsigned int + * 忒曰袄 + * void + ------------------------------------------------------------*/ +void setCDsendinterval_ms( unsigned int interval_ms ) +{ + config.CDsendinterval_ms = interval_ms; +} +/*------------------------------------------------------------ + * Onelooptime毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * unsigned int + ------------------------------------------------------------*/ +unsigned int getOnelooptime_ms( void ) +{ + return config.Onelooptime_ms; +} +/*------------------------------------------------------------ + * Onelooptime毛本永玄允月[ + * 娄醒 + * interval unsigned int + * 忒曰袄 + * void + ------------------------------------------------------------*/ +void setOnelooptime_ms( unsigned int interval_ms ) +{ + config.Onelooptime_ms = interval_ms; +} +/*------------------------------------------------------------ + * Petdeletetime毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * unsigned int + ------------------------------------------------------------*/ +unsigned int getPetdeletetime( void ) +{ + return config.Petdeletetime; +} +/*------------------------------------------------------------ + * Petdeletetime毛本永玄允月[ + * 娄醒 + * interval unsigned int + * 忒曰袄 + * void + ------------------------------------------------------------*/ +void setPetdeletetime( unsigned int interval ) +{ + config.Petdeletetime = interval; +} +/*------------------------------------------------------------ + * Itemdeletetime毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * unsigned int + ------------------------------------------------------------*/ +unsigned int getItemdeletetime( void ) +{ + return config.Itemdeletetime; +} +/*------------------------------------------------------------ + * Itemdeletetime毛本永玄允月[ + * 娄醒 + * interval unsigned int + * 忒曰袄 + * void + ------------------------------------------------------------*/ +void setItemdeletetime( unsigned int interval ) +{ + config.Itemdeletetime = interval; +} + +/*------------------------------------------------------------ + * CharSavesendinterval毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * unsigned int + ------------------------------------------------------------*/ +unsigned int getCharSavesendinterval( void ) +{ + return config.CharSavesendinterval; +} +/*------------------------------------------------------------ + * CharSavesendinterval毛本永玄允月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * unsigned int + ------------------------------------------------------------*/ +void setCharSavesendinterval( unsigned int interval) +{ + config.CharSavesendinterval = interval; +} + +/*------------------------------------------------------------ + * Addressbookoffmsgnum 毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * unsigned int + ------------------------------------------------------------*/ +unsigned int getAddressbookoffmsgnum( void ) +{ + return config.addressbookoffmsgnum; +} +/*------------------------------------------------------------ + * Protocolreadfrequency 毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * unsigned int + ------------------------------------------------------------*/ +unsigned int getProtocolreadfrequency( void ) +{ + return config.protocolreadfrequency; +} + +/*------------------------------------------------------------ + * Allowerrornum 毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * unsigned int + ------------------------------------------------------------*/ +unsigned int getAllowerrornum( void ) +{ + return config.allowerrornum; +} + +/*------------------------------------------------------------ + * 夫弘毛潸 允月凛对毛 月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * unsigned int + ------------------------------------------------------------*/ +unsigned int getLogHour( void ) +{ + return config.loghour; +} + +/*------------------------------------------------------------ + * 田玄伙 及犯田永弘丢永本□斥毛请允井[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * unsigned int 1卅日请允 + ------------------------------------------------------------*/ +unsigned int getBattleDebugMsg( void ) +{ + return config.battledebugmsg; +} +/*------------------------------------------------------------ + * 田玄伙 及犯田永弘丢永本□斥毛请允井[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * unsigned int 1卅日请允 + ------------------------------------------------------------*/ +void setBattleDebugMsg( unsigned int num ) +{ + config.battledebugmsg = num; +} + + + +/* + * Config及犯白巧伙玄袄毛瑁户月楮醒 + * 娄醒 + * argv0 char* 戊穴件玉仿奶件娄醒及 赓 + */ +void defaultConfig( char* argv0 ) +{ + char* program; /* program 毛菲户月及卞银丹 */ + + /* 犯白巧伙玄袄毛 木月 */ + + /*皿夫弘仿丞 */ + program = rindex(argv0, '/'); + if (program == NULL) + program = argv0; + else + program++; /* "/"及戚井日卞仄凶中及匹++允月*/ + strcpysafe( config.progname , sizeof( config.progname ) ,program ); + + /*涩烂白央奶伙 */ + strcpysafe( config.configfilename, + sizeof( config.configfilename ),"setup.cf" ); + +} + +/* + * 涩烂白央奶伙 毛 氏分 匹及质 毛垫丹[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * 卅仄 + */ +void lastConfig( void ) +{ + char entry[256]; + /* 穴永皿犯奴伊弁玄伉及涩烂 */ + snprintf(entry, sizeof(entry), "%s/%s", config.topdir, config.mapdir); + strcpysafe(config.mapdir, sizeof(config.mapdir), entry); + + /* 穴永皿涩烂白央奶伙 及涩烂 */ + snprintf(entry,sizeof(entry),"%s/%s", + config.topdir,config.maptilefile); + strcpysafe(config.maptilefile, sizeof(config.maptilefile), entry); + + /* 田玄伙穴永皿涩烂白央奶伙 及涩烂 */ + snprintf(entry,sizeof(entry),"%s/%s", + config.topdir,config.battlemapfile); + strcpysafe(config.battlemapfile, sizeof(config.battlemapfile), entry); + + /* 失奶 丞涩烂白央奶伙 及涩烂 */ + snprintf(entry,sizeof(entry), "%s/%s", config.topdir,config.itemfile); + strcpysafe(config.itemfile, sizeof(config.itemfile), entry); + + /* 衬涩烂白央奶伙 及涩烂 */ + snprintf(entry,sizeof(entry), "%s/%s", config.topdir,config.invfile); + strcpysafe(config.invfile, sizeof(config.invfile), entry); + + /* 请蜇匏 涩烂白央奶伙 及涩烂 */ + snprintf(entry,sizeof(entry), "%s/%s", config.topdir,config.appearfile); + strcpysafe(config.appearfile, sizeof(config.appearfile), entry); + + /* 梢请涩烂白央奶伙 及涩烂 */ + snprintf(entry,sizeof(entry), "%s/%s", config.topdir,config.effectfile); + strcpysafe(config.effectfile, sizeof(config.effectfile), entry); + + /* 弁奶术涩烂白央奶伙 及涩烂 */ + snprintf(entry,sizeof(entry), "%s/%s", config.topdir,config.quizfile); + strcpysafe(config.quizfile, sizeof(config.quizfile), entry); + + /* 惫寞 白央奶伙 及涩烂 */ + snprintf(entry,sizeof(entry), "%s/%s", config.topdir,config.titlenamefile); + strcpysafe(config.titlenamefile, sizeof(config.titlenamefile), entry); + + /* lsgen 失它玄皿永玄白央奶伙 */ + snprintf(entry,sizeof(entry),"%s/%s", config.topdir,config.lsgenlog); + strcpysafe(config.lsgenlog, sizeof(config.lsgenlog), entry); + + /* 旦玄失犯奴伊弁玄伉及涩烂 */ +/* + snprintf(entry,sizeof(entry), "%s/%s",config.topdir,config.storedir); + strcpysafe(config.storedir, sizeof(config.storedir), entry); +*/ + /* NPC涩烂玄永皿犯奴伊弁玄伉及涩烂 */ + snprintf(entry,sizeof(entry), "%s/%s",config.topdir,config.npcdir); + strcpysafe(config.npcdir, sizeof(config.npcdir), entry); + +#ifdef _STORECHAR + /* */ + snprintf(entry,sizeof(entry), "%s/%s",config.topdir,config.storechar); + strcpysafe(config.storechar, sizeof(config.storechar), entry); +#endif + +} + + +/* + * 禾奶件正□午赝濠卅滇树 毛 匀化医 毛允月楮醒 + * 娄醒 + * to void* 袄毛医 允月禾奶件正 + * type CTYPE to及滇毛瑁户月 + * value double to卞医 允月袄 + * 忒曰袄 + * 卅仄 + */ +void substitutePointerFromType( void* to , CTYPE type ,double value) +{ + switch( type ){ + case CHAR: + *(char*)to = (char)value; + break; + case SHORT: + *(short*)to = (short)value; + break; + case INT: + *(int*)to = (int)value; + break; + case DOUBLE: + *(double*)to = (double)value; + break; + } +} + + +/*------------------------------------------------------------ + * 涩烂白央奶伙毛 戈 + * 娄醒 + * filename 白央奶伙 + * 忒曰袄 + * TRUE(1) 岳 + * FALSE(0) 撩 -> 白央奶伙及左□皿件卞撩 仄凶 + ------------------------------------------------------------*/ +BOOL readconfigfile( char* filename ) +{ + FILE* f=NULL; + char linebuf[256]; /* 域垫 心 戈田永白央 */ + int linenum=0; /* 垫醒毛醒尹月 */ + char realopenfilename[256]; /* 端卞open 允月白央奶伙 */ + + char hostname[128]; + + /* 石旦玄 毛菲户月 */ + if( gethostname( hostname, sizeof(hostname) ) != -1 ){ + char* initdot; + initdot = index( hostname, '.' ); + if( initdot != NULL ) + *initdot = '\0'; + snprintf( realopenfilename, sizeof(realopenfilename), + "%s.%s" , filename, hostname); + + /* 白央奶伙及左□皿件 */ + f=fopen( realopenfilename, "r" ); + if( f == NULL ) + print( "Can't open %s. use %s instead\n", realopenfilename, + filename ); + } + if( f == NULL ){ + f=fopen( filename , "r" ); /* 白央奶伙及左□皿件 */ + if( f == NULL ){ + print( "Can't open %s\n", filename ); + return FALSE; + } + } + + /* 域垫勿勾 心 戈 */ + while( fgets( linebuf , sizeof( linebuf ), f ) ){ + char firstToken[256]; /*1 及 侬 */ + int i; /*伙□皿 醒*/ + int ret; /*伉正□件戊□玉*/ + + linenum ++; + + deleteWhiteSpace(linebuf); /* remove whitespace */ + + if( linebuf[0] == '#' )continue; /* comment */ + if( linebuf[0] == '\n' )continue; /* none */ + + chomp( linebuf ); /* remove tail newline */ + + /* delim "=" 匹 赓(1)及玄□弁件毛 月*/ + ret = getStringFromIndexWithDelim( linebuf , "=", 1, firstToken, + sizeof(firstToken) ); + if( ret == FALSE ){ + print( "Find error at %s in line %d. Ignore\n", + filename , linenum); + continue; + } + + /* readconf 及扔奶术匹伙□皿 */ + for( i = 0 ; i < arraysizeof( readconf ) ; i ++ ){ + if( strcmp( readconf[i].name ,firstToken ) == 0 ){ + /* match */ + char secondToken[256]; /*2 及 侬 */ + /* delim "=" 匹2 及玄□弁件毛 月*/ + ret = getStringFromIndexWithDelim( linebuf , "=" , 2 + , secondToken , + sizeof(secondToken) ); + + /* NULL 侬井升丹井毛譬屯月 */ + if( ret == FALSE ){ + print( "Find error at %s in line %d. Ignore", + filename , linenum); + break; + } + + + /*NULL分匀凶日医 仄卅中*/ + if( readconf[i].charvalue != NULL ) + strcpysafe( readconf[i].charvalue + ,readconf[i].charsize, secondToken); + + /*NULL分匀凶日医 仄卅中*/ + if( readconf[i].value != NULL ) { + if( strcmp( "ON" ,secondToken ) == 0 ) { + /*ON分匀凶日1毛 木月*/ + substitutePointerFromType( readconf[i].value, + readconf[i].valuetype, + 1.0); + + }else if( strcmp( "OFF" ,secondToken ) == 0 ) { + /*OFF分匀凶日1毛 木月*/ + substitutePointerFromType( readconf[i].value, + readconf[i].valuetype, + 1.0); + }else { + strtolchecknum(secondToken, + (int*)readconf[i].value, + 10, readconf[i].valuetype); + } + } + break; + } + } + } + fclose( f ); + lastConfig(); + return TRUE; +} +//ttom add this becaus the second had this function +/*------------------------------------------------------------ + * 巨件戊□玉平□毛涩烂允月 + * 娄醒 + * 卅仄 + * 忒曰袄 + * unsigned int 平□毛忒允 +------------------------------------------------------------*/ +unsigned int setEncodeKey( void ) +{ + JENCODE_KEY = config.encodekey; + return JENCODE_KEY; +} +/*------------------------------------------------------------ +* 失市它件玄扔□田□卞踏五 戈田永白央及扔奶术毛涩烂允月 +* 娄醒 +* 卅仄 +* 忒曰袄 +* unsigned int 平□毛忒允 +------------------------------------------------------------*/ +unsigned int setAcWBSize( void ) +{ + AC_WBSIZE = config.acwbsize; + return AC_WBSIZE; +} +unsigned int getAcwriteSize( void ) +{ + return config.acwritesize; +} +unsigned int getErrUserDownFlg( void ) +{ + return config.ErrUserDownFlg; +} + + +//tom end + + +#ifdef _M_SERVER +char* getmservername(void) +{ + return config.msname; +} +void setmservername( char *msname) +{ + sprintf( config.msname, "%s", msname); +} +unsigned int getmserverport(void) +{ + return config.msport; +} +void setmserverport( int port) +{ + config.msport = port; +} +#endif + +#ifdef _NPCSERVER_NEW +char *getnpcserveraddr(void) +{ + return config.nsaddress; +} + +unsigned int getnpcserverport(void) +{ + return config.nsport; +} +void NS_setAddressAndPort( char *address, int nport) +{ + sprintf( config.nsaddress, "%s", address); + config.nsport = nport; +} +#endif + +#ifdef _MUSEUM +int getMuseum( void ) +{ + return config.museum; +} +#endif + +#ifdef _DEL_DROP_GOLD +unsigned int getGolddeletetime( void ) +{ + if( config.Golddeletetime > 0 ) + return config.Golddeletetime; + else + return config.Itemdeletetime; +} +void setIGolddeletetime( unsigned int interval ) +{ + config.Golddeletetime = interval; +} +#endif + +#ifdef _NEW_PLAYER_CF +int getNewplayertrans( void ) +{ + if(config.newplayertrans > 7) + return 7; + else if(config.newplayertrans >= 0) + return config.newplayertrans; + else + return 0; +} +int getNewplayerlv( void ) +{ + if(config.newplayerlv > 160) + return 160; + else if(config.newplayerlv >0) + return config.newplayerlv; + else + return 0; +} +int getNewplayerpetlv( void ) +{ + if(config.newplayerpetlv > 160) + return 160; + else if(config.newplayerpetlv > 0) + return config.newplayerpetlv; + else + return 0; +} + +int getNewplayergivepet( unsigned int index ) +{ + if(config.newplayergivepet[index] > 0 ) + return config.newplayergivepet[index]; + else + return -1; +} + +int getNewplayergiveitem( unsigned int index ) +{ + if(config.newplayergiveitem[index] > 0 ) + return config.newplayergiveitem[index]; + else + return -1; +} + +void setNewplayergivepet( unsigned int index ,unsigned int interval) +{ + config.newplayergivepet[index] = interval; +} + +unsigned int getNewplayergivegold( void ) +{ + if(config.newplayergivegold > 1000000) + return 1000000; + else if(config.newplayergivegold >= 0) + return config.newplayergivegold; + else + return 0; +} + +#endif + +#ifdef _UNLAW_WARP_FLOOR +int getUnlawwarpfloor( unsigned int index ) +{ + if(config.unlawwarpfloor[index] > 0 ) + return config.unlawwarpfloor[index]; + else + return -1; +} +#endif + + +#ifdef _ANGEL_SUMMON + +extern int mission_num; + +BOOL LoadMissionList( ) +{ + FILE* fp; + int i = 0; + + mission_num = 0; + + fp = fopen("./data/mission.txt", "r"); + if (fp == NULL) + { + print("任务文件打开错误\n"); + return FALSE; + } + + memset( missionlist, 0, sizeof(missionlist)); + + while(1){ + char line[1024], level[64]; + char token[1024]; + int mindex; + if (fgets(line, sizeof(line), fp) == NULL) break; + print("\n %s ", line); + chop(line); + // 以#为注解******* + if( line[0] == '#' ) + continue; + for( i=0; i= MAXMISSION) + break; + + missionlist[mindex].id = mindex; + + getStringFromIndexWithDelim(line, ",", 2, token, sizeof(token)); + if (strcmp(token, "") == 0) break; + missionlist[mindex].level = atoi( token); + + getStringFromIndexWithDelim(line, ",", 3, token, sizeof(token)); + if (strcmp(token, "") == 0) break; + strcpy( missionlist[mindex].eventflag, token); + + getStringFromIndexWithDelim(line, ",", 4, token, sizeof(token)); + if (strcmp(token, "") == 0) break; + strcpy( missionlist[mindex].detail, token); + + //getStringFromIndexWithDelim(line, ",", 4, token, sizeof(token)); + //if (strcmp(token, "") == 0) break; + //strcpy( missionlist[mindex].bonus, token); + + getStringFromIndexWithDelim(line, ",", 5, token, sizeof(token)); + if (strcmp(token, "") == 0) break; + missionlist[mindex].limittime = atoi( token); + + /*print("\nMISSION[%d] lv:%d ef:%s detail:%s limit:%d ", mindex, + missionlist[mindex].level, missionlist[mindex].eventflag, + missionlist[mindex].detail, missionlist[mindex].limittime ); + */ + mission_num++; + //if (mission_num > MAXMISSION) break; + } + fclose(fp); + return TRUE; +} + + + +BOOL LoadMissionCleanList( ) +{ + // 格式... 使者,勇者,任务,奖赏 + FILE* fp; + int listindex =0; + int i = 0; + + memset( missiontable, 0, sizeof(missiontable)); + fp = fopen("./data/missionclean.txt", "r"); + if (fp == NULL) + { + print("清除任务文件打开错误\n"); + return FALSE; + } + + while(1){ + char line[1024], angelinfo[128], heroinfo[128]; + char token[1024]; + + if (fgets(line, sizeof(line), fp) == NULL) break; + print("\n %s ", line); + chop(line); + // 以#为注解******* + if( line[0] == '#' ) + continue; + for( i=0; i= MAXMISSIONTABLE) break; + } + fclose(fp); + return TRUE; +} + + +#endif + +#ifdef _JOBDAILY +extern DailyFileType dailyfile[MAXDAILYLIST]; +BOOL LoadJobdailyfile(void) +{ + char line[20000]; + char token[16384]; + int listindex =0; + int i; + FILE* fp; + + fp = fopen("./data/jobdaily.txt", "r"); + if (fp == NULL) + { + print("日常工作文件打开错误\n"); + return FALSE; + } + + memset( dailyfile, 0, sizeof(dailyfile)); + + while(1){ + line[0]='\0'; + if (fgets(line, sizeof(line), fp) == NULL) break; + //print("\n %s ", line); + chop(line); + + // #为注解 + if( line[0] == '#' ) + continue; + for( i=0; i96){ + print("任务说明过长:%d",strlen(token)); + return FALSE; + } + strcpy( dailyfile[listindex].explain, token); + + getStringFromIndexWithDelim(line, "|", 4, token, sizeof(token)); + if (strcmp(token, "") == 0) break; + strcpy( dailyfile[listindex].state, token); + + /*print("\ndailyfile[%d] %s %s %s %s", listindex, + dailyfile[listindex].jobid, + dailyfile[listindex].rule, + dailyfile[listindex].explain, + dailyfile[listindex].state); + */ + listindex++; + if ( listindex >= MAXDAILYLIST) break; + } + fclose(fp); + return TRUE; +} +#endif + +#ifdef _RACEMAN +//extern int petflgtable[640]; +//extern struct ASKTABLE asktable[400]; +extern int asktotal; +BOOL LoadRacepetfile(void) +{ + char line[1000]; + char token[64]; + int i; + FILE* fp; + + asktotal = 0; + memset(asktable,0,sizeof(asktable)); + + fp = fopen("./data/raceman.txt", "r"); + if (fp == NULL) + { + print("宠物赛跑文件打开错误\n"); + return FALSE; + } + + while(1){ + line[0]='\0'; + if (fgets(line, sizeof(line), fp) == NULL) break; + chop(line); + + // #为注解 + if( line[0] == '#' ) + continue; + for( i=0; i 140 ) return FALSE; + asktable[asktotal].highlv = atoi(token); + asktotal++; + } + fclose(fp); + return TRUE; + + /* + for( k=0,j=0;j=640) { + print( "Valid petflag Num is %d...", k ); + break; + } + } + //if( CHAR_getInt( petindex, CHAR_PETID) == ENEMYTEMP_getInt( j, E_T_TEMPNO ) ) {//ENEMY_getInt( j, ENEMY_TEMPNO) + } + */ +} + +#endif + + +#ifdef _USER_EXP_CF +BOOL LoadEXP( char* filename ) +{ + FILE* fp; + int i = 0; + + fp = fopen(filename, "r"); + if (fp == NULL) + { + print("无法打开文件\n"); + return FALSE; + } + + while(1){ + char line[64], exp[64]; + if (fgets(line, sizeof(line), fp) == NULL) break; + chop(line); + + if( line[0] == '#' ) + continue; + for( i=0; i 160) break; + easyGetTokenFromString(line, 2, exp, sizeof(exp)); + NeedLevelUpTbls[MaxLevel]=atoi(exp); + } + fclose(fp); + return TRUE; +} + +char* getEXPfile( void ) +{ + return config.expfile; +} + +int getNeedLevelUpTbls( int level ) +{ + return NeedLevelUpTbls[level]; +} + +int getMaxLevel( void ) +{ + if(MaxLevel>160) + MaxLevel=160; + return MaxLevel; +} +#endif + +#ifdef _UNREG_NEMA +char* getUnregname( int index ) +{ + return config.unregname[index]; +} +#endif + +#ifdef _TRANS_LEVEL_CF +int getChartrans( void ) +{ + if(config.chartrans>6) + config.chartrans=6; + return config.chartrans; +} +int getPettrans( void ) +{ + if(config.pettrans>2) + config.pettrans=2; + return config.pettrans; +} +int getYBLevel( void ) +{ + if(config.yblevel>MaxLevel) + config.yblevel=MaxLevel; + return config.yblevel; +} +#endif + +#ifdef _LOCK_IP +char* getLockipPath( void ) +{ + return config.lockip; +} +int loadLockip( char* filename ) +{ + FILE* fp; + int i = 0; + fp = fopen(filename, "r"); + if (fp == NULL) + { + print("无法打开文件\n"); + return FALSE; + } + while(1){ + char line[64], buf[16]; + if (fgets(line, sizeof(line), fp) == NULL) break; + chop(line); + + if( line[0] == '#' ) + continue; + for( i=0; i99)return FALSE; + int i; + for(i=0;ilockip[index].locktime) + return TRUE; + else + return FALSE; + }else + return FALSE; + else + return FALSE; + else + return FALSE; + else + return FALSE; +} + +#endif \ No newline at end of file diff --git a/gmsv/function.c b/gmsv/function.c new file mode 100644 index 0000000..9754921 --- /dev/null +++ b/gmsv/function.c @@ -0,0 +1,793 @@ +#include "version.h" +#include +#include "common.h" +#include "util.h" +#include "char_event.h" +#include "char.h" +#include "item_event.h" +#include "magic.h" +#include "pet_event.h" +#include "npc_townpeople.h" +#include "npc_Dengon.h" +#include "npc_door.h" +#include "npc_healer.h" +#include "npc_oldman.h" +#include "npc_warp.h" +#include "npc_storyteller.h" +#include "npc_msg.h" +#include "npc_npcenemy.h" +#include "npc_action.h" +#include "npc_windowman.h" +#include "npc_savepoint.h" +#include "npc_windowhealer.h" +#include "npc_itemshop.h" +#include "npc_sysinfo.h" +#include "npc_duelranking.h" +#include "npc_petskillshop.h" +#include "npc_petshop.h" +#include "npc_signboard.h" +#include "npc_warpman.h" +#include "npc_exchangeman.h" +#include "petmail.h" +#include "npc_timeman.h" +#include "npc_bodylan.h" +#include "npc_mic.h" +#include "npc_luckyman.h" +#include "npc_bus.h" +#include "npc_charm.h" +#include "npc_poolitemshop.h" +#include "npc_quiz.h" +#include "npc_checkman.h" +#include "npc_janken.h" +#include "npc_transmigration.h" +#include "battle_event.h" +#include "enemy.h" +// Robin 0517 +#include "npc_familyman.h" +#include "npc_bankman.h" +// add code by shan +#include "npc_fmdengon.h" +#include "npc_fmhealer.h" +#include "npc_petmaker.h" + +// CoolFish: Family 2001/6/4 +#include "npc_fmwarpman.h" +#include "npc_fmpkman.h" +#include "npc_fmpkcallman.h" + +// Arminius 7.7 Airplane +#include "npc_airplane.h" + +// Arminius 7.13 Scheduleman +#include "npc_scheduleman.h" + +// Arminius 7.24 manor scheduleman +#include "npc_manorsman.h" + +// Robin 0725 +#include "npc_riderman.h" +#include "npc_fmletter.h" + +#ifdef _SERVICE +// Terry 2001/09/01 +#include "npc_stoneserviceman.h" +#endif + +#ifdef _NPC_SELLSTH +#include "npc_sellsthman.h" +#endif + +//andy +#ifdef _GAMBLE_BANK +#include "npc_gamblebank.h" +#endif + +#ifdef _NEW_WARPMAN +#include "npc_newnpcman.h" +#endif + +#ifdef _MARKET_TRADE +#include "npc_mtradenpcman.h" +#endif + +#ifdef _GAMBLE_ROULETTE +#include "npc_gambleroulette.h" +#include "npc_gamblemaster.h" +#endif + +#ifdef _TRANSER_MAN +#include "npc_transerman.h" +#endif + +#ifdef _PAUCTION_MAN +#include "npc_pauctionman.h" +#endif + +#ifdef _CFREE_petskill +#include "npc_freepetskillshop.h" +#endif + +#ifdef _PETRACE +#include "npc_petracemaster.h" +#include "npc_petracepet.h" +#endif + +#ifdef _AUCTIONEER +#include "npc_auctioneer.h" +#endif + +#ifdef _BLACK_MARKET +#include "npc_blackmarket.h" +#endif + +#ifdef _ITEM_NPCCHANGE +#include "npc_itemchange.h" +#endif + +#ifdef _NPC_MAKEPAIR +#include "npc_makepair.h" +#endif + +#ifdef _NPC_FUSION +#include "npc_petfusion.h" +#endif + +#ifdef _ALLDOMAN // (不可开) Syu ADD 排行榜NPC +#include "npc_alldoman.h" +#endif + +#ifdef _NPC_WELFARE +#include "npc_welfare.h" +#endif + +#ifdef _NPC_WELFARE_2 // WON ADD 职业NPC-2 +#include "npc_welfare2.h" +#endif + +#ifdef _NPC_VERYWELFARE +#include "npc_verywelfare.h" +#endif + +#ifdef _RACEMAN +#include "npc_raceman.h" +#endif + +#define DEBUG + +typedef struct tagCorrespondStringAndFunctionTable +{ + STRING32 functionName; + void* functionPointer; + int hashcode; +}CorrespondStringAndFunctionTable; + +static CorrespondStringAndFunctionTable +correspondStringAndFunctionTable[]= +{ + /* 动票反扔□田□ 戊□玉匹烂聒今木化中月楮醒分[NPC手仇木 + 毛勾井丹午五互丐月*/ + { {"core_PreWalk"}, CHAR_allprewalk, 0 }, + { {"core_PostWalk"}, CHAR_allpostwalk, 0 }, + { {"core_Loop"}, CHAR_loopFunc, 0 }, + { {"core_Dying"}, CHAR_die, 0 }, + { {"core_PlayerWatch"}, CHAR_playerWatchfunc, 0 }, + { {"core_PlayerTalked"}, CHAR_playerTalkedfunc, 0 }, + + + /* 动票反失奶 丞毛银丹午五迕及楮醒分[ */ + { {"MedicineInit"}, ITEM_MedicineInit, 0 }, + { {"MedicineUsed"}, ITEM_MedicineUsed, 0 }, + { {"SandClockDetach"}, ITEM_SandClockDetach, 0 }, + { {"addTitleAttach"}, ITEM_addTitleAttach, 0 }, + { {"delTitleDetach"}, ITEM_delTitleDetach, 0 }, + { {"ITEM_DeleteByWatched"}, ITEM_DeleteByWatched, 0 }, + { {"ITEM_DeleteTimeWatched"}, ITEM_DeleteTimeWatched, 0 }, + { {"ITEM_useEffectTohelos"}, ITEM_useEffectTohelos, 0 }, + +// { {"ITEM_useHpRecovery"}, ITEM_useHpRecovery, 0 }, + { {"ITEM_useRecovery"}, ITEM_useRecovery, 0 }, +#ifdef _ITEM_MAGICRECOVERY + { {"ITEM_useMRecovery"}, ITEM_useMRecovery, 0 }, +#endif +#ifdef _ITEM_USEMAGIC + { {"ITEM_useMagic"}, ITEM_useMagic, 0 }, +#endif + { {"ITEM_useStatusChange"}, ITEM_useStatusChange, 0 }, + { {"ITEM_useStatusRecovery"}, ITEM_useStatusRecovery, 0 }, + { {"ITEM_useMagicDef"}, ITEM_useMagicDef, 0 }, + { {"ITEM_useParamChange"}, ITEM_useParamChange, 0 }, + { {"ITEM_useFieldChange"}, ITEM_useFieldChange, 0 }, + { {"ITEM_useAttReverse"}, ITEM_useAttReverse, 0 }, + { {"ITEM_useRessurect"}, ITEM_useRessurect, 0 }, + { {"ITEM_useMic"}, ITEM_useMic, 0 }, + { {"ITEM_dropMic"}, ITEM_dropMic, 0 }, + { {"ITEM_useCaptureUp"}, ITEM_useCaptureUp, 0 }, + { {"ITEM_useRenameItem"}, ITEM_useRenameItem, 0 }, + { {"ITEM_pickupDice"}, ITEM_pickupDice, 0 }, + { {"ITEM_dropDice"}, ITEM_dropDice, 0 }, + { {"ITEM_initLottery"}, ITEM_initLottery, 0 }, + { {"ITEM_useLottery"}, ITEM_useLottery, 0 }, + { {"ITEM_useWarp"}, ITEM_useWarp, 0 }, + { {"ITEM_petFollow"}, ITEM_petFollow, 0 }, + { {"ITEM_useSkup"}, ITEM_useSkup, 0 }, // Nuke 0624: Hero's bless + { {"ITEM_useNoenemy"}, ITEM_useNoenemy, 0 }, // Nuke 0626: Dragon's help + { {"ITEM_equipNoenemy"},ITEM_equipNoenemy, 0 }, // Arminius 7.2 Ra's amulet + { {"ITEM_remNoenemy"}, ITEM_remNoenemy, 0 }, // Arminius 7.2 Ra's amulet + { {"ITEM_useEncounter"}, ITEM_useEncounter, 0}, // Arminius 7.31 cursed stone + + { {"ITEM_AddPRSkillPoint"}, ITEM_AddPRSkillPoint, 0}, + { {"ITEM_AddPRSkillPercent"}, ITEM_AddPRSkillPercent, 0}, + +#ifdef _ITEM_METAMO + { {"ITEM_metamo"}, ITEM_metamo, 0 }, + { {"ITEM_ColorMetamo"}, ITEM_ColorMetamo, 0 }, + { {"ITEM_CharaMetamo"}, ITEM_CharaMetamo, 0 }, + { {"ITEM_SexMetamo"}, ITEM_SexMetamo, 0 }, +#endif + +#ifdef _USEWARP_FORNUM + { {"ITEM_useWarpForNum"}, ITEM_useWarpForNum, 0 }, +#endif + +#ifdef _IMPRECATE_ITEM + { {"ITEM_useImprecate"}, ITEM_useImprecate, 0 }, +#endif +#ifdef _ITEM_FIRECRACKER //Terry add 2001/12/21 + { {"ITEM_firecracker"}, ITEM_firecracker, 0 }, +#endif +#ifdef _ITEM_CRACKER //vincent 拉炮 + { {"ITEM_Cracker"}, ITEM_Cracker, 0 }, +#endif +#ifdef _ITEM_ADDEXP //vincent 经验提升 + { {"ITEM_Addexp"}, ITEM_Addexp, 0 }, +#endif +#ifdef _ITEM_REFRESH //vincent 解除异常状态道具 + { {"ITEM_Refresh"}, ITEM_Refresh, 0 }, +#endif + + { {"ITEM_WearEquip"}, ITEM_WearEquip, 0 }, + { {"ITEM_ReWearEquip"}, ITEM_ReWearEquip, 0 }, + +#ifdef _ITEM_CONSTITUTION + { {"ITEM_Constitution"}, ITEM_Constitution, 0 }, +#endif + +#ifdef _Item_ReLifeAct + { {"ITEM_DIErelife"}, ITEM_DIErelife, 0 }, +#endif + +#ifdef _ITEM_ORNAMENTS + { {"ITEM_PutOrnaments"}, ITEM_PutOrnaments, 0}, +#endif +#ifdef _CHIKULA_STONE + { {"ITEM_ChikulaStone"}, ITEM_ChikulaStone, 0}, +#endif + +#ifdef _THROWITEM_ITEMS + { {"ITEM_ThrowItemBox"}, ITEM_ThrowItemBox, 0}, +#endif + +#ifdef _ITEM_WATERWORDSTATUS + { {"ITEM_WaterWordStatus"}, ITEM_WaterWordStatus, 0}, +#endif + +#ifdef _ITEM_LOVERPARTY + { {"ITEM_LoverSelectUser"}, ITEM_LoverSelectUser, 0}, +#endif + +#ifdef _Item_MoonAct + { {"ITEM_randEnemyEquipOne"}, ITEM_randEnemyEquipOne, 0 }, + + { {"ITEM_randEnemyEquip"}, ITEM_randEnemyEquip, 0 }, + { {"ITEM_RerandEnemyEquip"}, ITEM_RerandEnemyEquip, 0}, +#endif + +#ifdef _SUIT_ITEM + { {"ITEM_suitEquip"}, ITEM_suitEquip, 0 }, + { {"ITEM_ResuitEquip"}, ITEM_ResuitEquip, 0 }, +#endif + +#ifdef _Item_DeathAct + { {"ITEM_useDeathcounter"}, ITEM_UseDeathCounter, 0 }, +#endif +#ifdef _DEATH_CONTENDWATCH + { {"ITEM_useWatchBattle"}, ITEM_useWatchBattle, 0 }, +#endif +#ifdef _FEV_ADD_NEW_ITEM // FEV ADD 增加复活守精 + { {"ITEM_ResAndDef"} , ITEM_ResAndDef, 0 }, +#endif + +#ifdef _CHRISTMAS_REDSOCKS + { {"ITEM_useMaxRedSocks"}, ITEM_useMaxRedSocks, 0 }, +#endif + +#ifdef _CHRISTMAS_REDSOCKS_NEW + { {"ITEM_useMaxRedSocksNew"}, ITEM_useMaxRedSocksNew, 0 }, +#endif + +#ifdef _PETSKILL_CANNEDFOOD + { {"ITEM_useSkillCanned"}, ITEM_useSkillCanned, 0}, +#endif + +#ifdef _NEW_RIDEPETS + { {"ITEM_useLearnRideCode"}, ITEM_useLearnRideCode, 0 }, +#endif + +#ifdef _EQUIT_DEFMAGIC + { {"ITEM_MagicEquitWear"}, ITEM_MagicEquitWear, 0 }, + { {"ITEM_MagicEquitReWear"}, ITEM_MagicEquitReWear, 0 }, +#endif +#ifdef _EQUIT_RESIST + { {"ITEM_MagicResist"}, ITEM_MagicResist, 0 }, + { {"ITEM_MagicReResist"}, ITEM_MagicReResist, 0 }, +#endif + +#ifdef _MAGIC_RESIST_EQUIT // WON ADD 职业抗性装备 + { {"ITEM_P_MagicEquitWear"}, ITEM_P_MagicEquitWear, 0 }, + { {"ITEM_P_MagicEquitReWear"}, ITEM_P_MagicEquitReWear, 0 }, +#endif + +#ifdef _ANGEL_SUMMON + { {"ITEM_AngelToken"}, ITEM_AngelToken, 0 }, + { {"ITEM_HeroToken"}, ITEM_HeroToken, 0 }, +#endif +#ifdef _HALLOWEEN_EFFECT + { {"ITEM_MapEffect"}, ITEM_MapEffect, 0 }, +#endif + + { {"ITEM_changePetOwner"}, ITEM_changePetOwner, 0 }, + + { {"core_PetWatch"}, PET_Watchfunc, 0 }, + { {"PETMAIL_Loop"}, PETMAIL_Loopfunc, 0 }, +#ifdef _USER_CHARLOOPS + { {"CHAR_BattleStayLoop"}, CHAR_BattleStayLoop, 0 }, + { {"PET_CheckIncubateLoop"}, PET_CheckIncubate, 0 }, +#endif + +#ifdef _PETSKILL_PROPERTY + { {"PET_PetskillPropertyEvent"}, PET_PetskillPropertyEvent, 0 }, +#endif + { {"core_PetTalk"}, PET_Talkfunc, 0}, // Arminius 8.14 pet talk + + + /* warp */ + { {"WarpInit"}, NPC_WarpInit, 0 }, + { {"WarpPostOver"}, NPC_WarpPostOver, 0 }, + { {"WarpWatch"}, NPC_WarpWatch, 0 }, + + /* Dengon */ + { {"DengonInit"}, NPC_DengonInit, 0 }, + { {"DengonWindowTalked"}, NPC_DengonWindowTalked, 0 }, + { {"DengonLooked"}, NPC_DengonLooked, 0 }, + + /* FmDengon add code by shan */ + { {"FmDengonInit"}, NPC_FmDengonInit, 0 }, + { {"FmDengonWindowTalked"}, NPC_FmDengonWindowTalked, 0 }, + { {"FmDengonLooked"}, NPC_FmDengonLooked, 0 }, + + /* Healer */ + { {"HealerInit"} , NPC_HealerInit, 0 }, + { {"HealerTalked"} , NPC_HealerTalked , 0 }, + + /* FMHealer add code by shan */ + { {"FmHealerInit"} , NPC_FmHealerInit, 0 }, + { {"FmHealerTalked"} , NPC_FmHealerTalked , 0 }, + + /* petmaker add code by shan */ + { {"PetMakerInit"} , NPC_PetMakerInit, 0 }, + { {"PetMakerTalked"} , NPC_PetMakerTalked , 0 }, + + /* TownPeople */ + { {"TownPeopleTalked"}, NPC_TownPeopleTalked, 0 }, + { {"TownPeopleInit"}, NPC_TownPeopleInit, 0 }, + + /* TownPeople */ + { {"MsgLooked"}, NPC_MsgLooked , 0 }, + { {"MsgInit"}, NPC_MsgInit, 0 }, + + /* Oldman */ + { {"OldmanInit"} , NPC_OldmanInit , 0 }, + { {"OldmanTalked"} , NPC_OldmanTalked , 0 }, + + /* SavePOint */ + { {"SavePointInit"} , NPC_SavePointInit , 0 }, + { {"SavePointTalked"} , NPC_SavePointTalked , 0 }, + { {"SavePointWindowTalked"}, NPC_SavePointWindowTalked, 0 }, + + /* StoryTeller */ + { {"StoryTellerInit"} , NPC_StoryTellerInit , 0 }, + { {"StoryTellerTalked"} , NPC_StoryTellerTalked , 0 }, + + /* NPCEnemy */ + { {"NPCEnemyInit"} , NPC_NPCEnemyInit , 0 }, + { {"NPCEnemyTalked"} , NPC_NPCEnemyTalked , 0 }, + { {"NPCEnemyWatch"} , NPC_NPCEnemyWatch , 0 }, + { {"NPCEnemyLoop"}, NPC_NPCEnemyLoop, 0 }, + { {"NPCEnemyWindowTalked"}, NPC_NPCEnemyWindowTalked, 0 }, + + /* 失弁扑亦件楝 */ + { {"ActionInit"} , NPC_ActionInit , 0 }, + { {"ActionTalked"} , NPC_ActionTalked , 0 }, + { {"ActionWatch"} , NPC_ActionWatch , 0 }, + + /* 它奴件玉它楝 */ + { {"WindowmanInit"} , NPC_WindowmanInit , 0 }, + { {"WindowmanTalked"} , NPC_WindowmanTalked , 0 }, + { {"WindowmanLooked"}, NPC_WindowmanLooked, 0 }, + { {"WindowmanWindowTalked"}, NPC_WindowmanWindowTalked, 0 }, + + /* 它奴件玉它甲□仿□ */ + { {"WindowHealerInit"} , NPC_WindowHealerInit , 0 }, + { {"WindowHealerTalked"} , NPC_WindowHealerTalked, 0 }, + { {"WindowHealerLooked"} , NPC_WindowHealerLooked, 0 }, + { {"WindowHealerWindowTalked"}, NPC_WindowHealerWindowTalked, 0 }, + + /* 失奶 丞盒 */ + { {"ItemShopInit"} , NPC_ItemShopInit , 0 }, + { {"ItemShopTalked"} , NPC_ItemShopTalked , 0 }, + { {"ItemShopWindowTalked"}, NPC_ItemShopWindowTalked, 0 }, + + /* Sysinfo */ + { {"SysinfoInit"}, NPC_SysinfoInit, 0 }, + { {"SysinfoLoop"}, NPC_SysinfoLoop, 0 }, + { {"SysinfoTalked"} , NPC_SysinfoTalked , 0 }, + + /* Duel仿件平件弘 憎NPC */ + { {"DuelrankingInit"} , NPC_DuelrankingInit , 0 }, + { {"DuelrankingLooked"}, NPC_DuelrankingLooked, 0 }, + { {"DuelrankingWindowTalked"}, NPC_DuelrankingWindowTalked, 0 }, +#ifdef _DEATH_CONTEND + { {"Duelrankingloop"}, NPC_Duelrankingloop, 0 }, +#endif + /* 它奴件玉它矢永玄及 盒 */ + { {"PetSkillShopInit"} , NPC_PetSkillShopInit , 0 }, + { {"PetSkillShopTalked"} , NPC_PetSkillShopTalked, 0 }, + { {"PetSkillShopLooked"} , NPC_PetSkillShopLooked, 0 }, + { {"PetSkillShopWindowTalked"}, NPC_PetSkillShopWindowTalked, 0 }, + + /* 它奴件玉它矢永玄 中潸曰盒 */ + { {"PetShopInit"} , NPC_PetShopInit, 0 }, + { {"PetShopTalked"} , NPC_PetShopTalked, 0 }, + { {"PetShopLooked"} , NPC_PetShopLooked, 0 }, + { {"PetShopWindowTalked"}, NPC_PetShopWindowTalked,0 }, + + /* 枣 */ + { {"SignBoardInit"} , NPC_SignBoardInit, 0 }, + { {"SignBoardLooked"} , NPC_SignBoardLooked, 0 }, + { {"SignBoardWindowTalked"}, NPC_SignBoardWindowTalked, 0 }, + + /*伐□皿穴件 */ + { {"WarpManInit"}, NPC_WarpManInit, 0 }, + { {"WarpManTalked"}, NPC_WarpManTalked, 0 }, + { {"WarpManWatch"}, NPC_WarpManWatch, 0 }, + { {"WarpManLoop"} , NPC_WarpManLoop, 0 }, + { {"WarpManWindowTalked"}, NPC_WarpManWindowTalked,0 }, + + + /*奶矛件玄楝 exchangeman) */ + { {"ExChangeManInit"}, NPC_ExChangeManInit, 0 }, + { {"ExChangeManTalked"}, NPC_ExChangeManTalked, 0 }, + { {"ExChangeManWindowTalked"}, NPC_ExChangeManWindowTalked,0 }, + + /*正奶丞穴件 */ + { {"TimeManInit"}, NPC_TimeManInit, 0 }, + { {"TimeManTalked"}, NPC_TimeManTalked, 0 }, + { {"TimeManWatch"} , NPC_TimeManWatch , 0 }, + + /* 示犯奴仿件必□斥 */ + { {"BodyLanInit"}, NPC_BodyLanInit, 0 }, + { {"BodyLanTalked"}, NPC_BodyLanTalked, 0 }, + { {"BodyLanWatch"} , NPC_BodyLanWatch , 0 }, + { {"BodyLanWindowTalked"} , NPC_BodyLanWindowTalked,0 }, + + /* 穴奶弁 */ + { {"MicInit"}, NPC_MicInit, 0 }, + { {"MicTalked"}, NPC_MicTalked, 0 }, + + /* 仿永平□穴件 */ + { {"LuckyManInit"} , NPC_LuckyManInit , 0 }, + { {"LuckyManTalked"} , NPC_LuckyManTalked, 0 }, + { {"LuckyManWindowTalked"}, NPC_LuckyManWindowTalked, 0 }, + + /* 楝 */ + { {"BusInit"} , NPC_BusInit , 0 }, + { {"BusTalked"} , NPC_BusTalked , 0 }, + { {"BusLoop"} , NPC_BusLoop , 0 }, + + /* 加美航空 */ // Arminius 7.7 Airplane + { {"AirInit"} , NPC_AirInit , 0 }, + { {"AirTalked"} , NPC_AirTalked , 0 }, + { {"AirLoop"} , NPC_AirLoop , 0 }, + + /* 楝 */ + { {"CharmInit"} , NPC_CharmInit , 0 }, + { {"CharmTalked"} , NPC_CharmTalked, 0 }, + { {"CharmWindowTalked"}, NPC_CharmWindowTalked, 0 }, + + { {"PoolItemShopInit"} , NPC_PoolItemShopInit , 0 }, + { {"PoolItemShopLoop"} , NPC_PoolItemShopLoop , 0 }, + { {"PoolItemShopTalked"} , NPC_PoolItemShopTalked , 0 }, + { {"PoolItemShopWindowTalked"}, NPC_PoolItemShopWindowTalked, 0 }, + + { {"QuizInit"} , NPC_QuizInit , 0 }, + { {"QuizTalked"} , NPC_QuizTalked, 0 }, + { {"QuizWindowTalked"}, NPC_QuizWindowTalked, 0 }, + + + /* 切之匀仁引氏 */ + { {"CheckManInit"} , NPC_CheckManInit , 0 }, + { {"CheckManTalked"} , NPC_CheckManTalked, 0 }, + { {"CheckManWindowTalked"}, NPC_CheckManWindowTalked, 0 }, + + /* 元扎氏仃氏楝 */ + { {"JankenInit"} , NPC_JankenInit , 0 }, + { {"JankenTalked"} , NPC_JankenTalked, 0 }, + { {"JankenWindowTalked"}, NPC_JankenWindowTalked, 0 }, + + /* 鳖戏谛 */ + { {"TransmigrationInit"} , NPC_TransmigrationInit , 0 }, + { {"TransmigrationTalked"} , NPC_TransmigrationTalked, 0 }, + { {"TransmigrationWindowTalked"}, NPC_TransmigrationWindowTalked, 0 }, + + /* Family man */ + { {"FamilymanInit"} , NPC_FamilymanInit , 0 }, + { {"FamilymanTalked"} , NPC_FamilymanTalked, 0 }, + { {"FamilymanLooked"}, NPC_FamilymanLooked,0 }, + { {"FamilymanWindowTalked"}, NPC_FamilymanWindowTalked, 0 }, + + /* CoolFish: Family WarpMan 2001/6/6 */ + { {"FMWarpManInit"}, NPC_FMWarpManInit, 0 }, + { {"FMWarpManTalked"}, NPC_FMWarpManTalked, 0 }, + { {"FMWarpManLoop"} , NPC_FMWarpManLoop, 0 }, + { {"FMWarpManWindowTalked"}, NPC_FMWarpManWindowTalked, 0 }, + + /* CoolFish: Family PKMan 2001/7/4 */ + { {"FMPKManInit"}, NPC_FMPKManInit, 0 }, + { {"FMPKManTalked"}, NPC_FMPKManTalked, 0 }, + { {"FMPKManWindowTalked"}, NPC_FMPKManWindowTalked, 0 }, + + /* CoolFish: Family PKCallMan 2001/7/13 */ + { {"FMPKCallManInit"}, NPC_FMPKCallManInit, 0 }, + { {"FMPKCallManTalked"}, NPC_FMPKCallManTalked, 0 }, + { {"FMPKCallManWindowTalked"}, NPC_FMPKCallManWindowTalked, 0 }, + + /* Bank man */ + { {"BankmanInit"} , NPC_BankmanInit , 0 }, + { {"BankmanTalked"} , NPC_BankmanTalked, 0 }, + { {"BankmanLooked"}, NPC_BankmanLooked,0 }, + { {"BankmanWindowTalked"}, NPC_BankmanWindowTalked, 0 }, + + /* Arminius 7.13 scheduleman */ + { {"SchedulemanInit"}, NPC_SchedulemanInit, 0}, + { {"SchedulemanTalked"}, NPC_SchedulemanTalked, 0}, + { {"SchedulemanWindowTalked"}, NPC_SchedulemanWindowTalked, 0}, + { {"SchedulemanLoop"}, NPC_SchedulemanLoop, 0}, + + /* Arminius 7.24 manor scheduleman */ + { {"ManorSmanInit"}, NPC_ManorSmanInit, 0}, + { {"ManorSmanTalked"}, NPC_ManorSmanTalked, 0}, + { {"ManorSmanWindowTalked"}, NPC_ManorSmanWindowTalked, 0}, + { {"ManorSmanLoop"}, NPC_ManorSmanLoop, 0}, + + /* Rider man */ + { {"RidermanInit"} , NPC_RidermanInit , 0 }, + { {"RidermanTalked"} , NPC_RidermanTalked, 0 }, + { {"RidermanLooked"}, NPC_RidermanLooked,0 }, + { {"RidermanWindowTalked"}, NPC_RidermanWindowTalked, 0 }, + + /* FmLetter man */ + { {"FmLetterInit"} , NPC_FmLetterInit , 0 }, + { {"FmLetterTalked"} , NPC_FmLetterTalked, 0 }, + { {"FmLetterLooked"}, NPC_FmLetterLooked,0 }, + { {"FmLetterWindowTalked"}, NPC_FmLetterWindowTalked, 0 }, +#ifdef _SERVICE + // Terry 2001/08/31 + // 石器服务员 StoneServiceMan + { {"StoneServiceManInit"}, NPC_StoneServiceManInit,0}, + { {"StoneServiceManLoop"}, NPC_StoneServiceManLoop,0}, + { {"StoneServiceManTalked"}, NPC_StoneServiceManTalked,0}, + { {"StoneServiceManWindowTalked"}, NPC_StoneServiceManWindowTalked,0}, +#endif + +#ifdef _GAMBLE_BANK //银行 + { {"GambleBankInit"}, NPC_GambleBankInit, 0}, + { {"GambleBankLoop"}, NPC_GambleBankLoop,0}, + { {"GambleBankTalked"}, NPC_GambleBankTalked,0}, + { {"GambleBankWindowTalked"}, NPC_GambleBankWindowTalked,0}, +#endif + +#ifdef _PET_LIMITLEVEL + { {"ITEM_useOtherEditBase"}, ITEM_useOtherEditBase, 0}, +#endif +#ifdef _ITEM_EDITBASES + { {"ITEM_useFusionEditBase"}, ITEM_useFusionEditBase, 0}, +#endif +#ifdef _GAMBLE_ROULETTE //赌场轮盘 + { {"GambleRouletteInit"}, NPC_Gamble_RouletteInit, 0}, + { {"GambleRouletteLoop"}, NPC_Gamble_RouletteLoop, 0}, + { {"GambleRouletteTalked"}, NPC_Gamble_RouletteTalked, 0}, + { {"GambleRouletteWindowTalked"}, NPC_Gamble_RouletteWindowTalked, 0}, + + { {"GambleMasterInit"}, NPC_Gamble_MasterInit, 0}, + { {"GambleMasterLoop"}, NPC_Gamble_MasterLoop, 0}, + { {"GambleMasterTalked"}, NPC_Gamble_MasterTalked, 0}, + { {"GambleMasterWindowTalked"}, NPC_Gamble_MasterWindowTalked, 0}, +#endif + +#ifdef _TRANSER_MAN + { {"TranserManInit"}, NPC_TranserManInit, 0 }, + { {"TranserManTalked"}, NPC_TranserManTalked, 0 }, + { {"TranserManLoop"} , NPC_TranserManLoop, 0 }, + { {"TranserManWindowTalked"}, NPC_TranserManWindowTalked, 0 }, +#endif + +#ifdef _NPC_SELLSTH + { {"SellsthManInit"}, NPC_SellsthManInit, 0 }, + { {"SellsthManTalked"}, NPC_SellsthManTalked, 0 }, + { {"SellsthManLoop"} , NPC_SellsthManLoop, 0 }, + { {"SellsthManWindowTalked"}, NPC_SellsthManWindowTalked, 0 }, +#endif + +#ifdef _NPC_MAKEPAIR + { {"MakePairManInit"}, NPC_MakePairManInit, 0 }, + { {"MakePairManTalked"}, NPC_MakePairManTalked, 0 }, + { {"MakePairManLoop"} , NPC_MakePairManLoop, 0 }, + { {"MakePairManWindowTalked"}, NPC_MakePairManWindowTalked,0 }, +#endif +#ifdef _NPC_FUSION + { {"PetFusionManInit"}, NPC_PetFusionManInit, 0 }, + { {"PetFusionManTalked"}, NPC_PetFusionManTalked, 0 }, + { {"PetFusionManLoop"} , NPC_PetFusionManLoop, 0 }, + { {"PetFusionManWindowTalked"}, NPC_PetFusionManWindowTalked,0 }, +#endif +#ifdef _PAUCTION_MAN + { {"PauctionManInit"}, NPC_PauctionManInit, 0 }, + { {"PauctionManTalked"}, NPC_PauctionManTalked, 0 }, + { {"PauctionManLoop"} , NPC_PauctionManLoop, 0 }, + { {"PauctionManWindowTalked"}, NPC_PauctionManWindowTalked, 0 }, +#endif +#ifdef _ITEM_NPCCHANGE + { {"ItemchangeManInit"}, NPC_ItemchangeManInit, 0 }, + { {"ItemchangeManTalked"}, NPC_ItemchangeManTalked, 0 }, + { {"ItemchangeManLoop"} , NPC_ItemchangeManLoop, 0 }, + { {"ItemchangeManWindowTalked"}, NPC_ItemchangeManWindowTalked, 0 }, +#endif + +#ifdef _CFREE_petskill + { {"FreePetSkillInit"} , NPC_FreePetSkillShopInit, 0 }, + { {"FreePetSkillTalked"} , NPC_FreePetSkillShopTalked, 0 }, + { {"FreePetSkillWindowTalked"}, NPC_FreePetSkillShopWindowTalked, 0 }, +#endif + +#ifdef _PETRACE // 宠物竞速 + { {"PetRaceMasterInit"}, NPC_PetRaceMasterInit, 0}, + { {"PetRaceMasterLoop"}, NPC_PetRaceMasterLoop, 0}, + { {"PetRaceMasterTalked"}, NPC_PetRaceMasterTalked, 0}, + { {"PetRaceMasterWindowTalked"}, NPC_PetRaceMasterWindowTalked, 0}, + + { {"PetRacePetInit"}, NPC_PetRacePetInit, 0}, + { {"PetRacePetLoop"}, NPC_PetRacePetLoop, 0}, + { {"PetRacePetTalked"}, NPC_PetRacePetTalked, 0}, +#endif + +#ifdef _NEW_WARPMAN + { {"NewNpcManInit"}, NPC_NewNpcManInit, 0}, + { {"NewNpcManLoop"}, NPC_NewNpcManLoop, 0}, + { {"NewNpcManTalked"}, NPC_NewNpcManTalked, 0}, + { {"NewNpcManWindowTalked"}, NPC_NewNpcManWindowTalked, 0}, +#endif + +#ifdef _MARKET_TRADE + { {"MapTradeManInit"}, MapTradeManInit, 0}, + { {"MapTradeManLoop"}, MapTradeManLoop, 0}, + { {"MapTradeManTalked"}, MapTradeManTalked, 0}, + { {"MapTradeManWindowTalked"}, MapTradeManWindowTalked, 0}, +#endif + +#ifdef _AUCTIONEER + { {"AuctioneerInit"}, NPC_AuctioneerInit, 0}, + { {"AuctioneerTalked"}, NPC_AuctioneerTalked, 0}, + { {"AuctioneerWindowTalked"}, NPC_AuctioneerWindowTalked, 0}, + { {"AuctioneerLoop"}, NPC_AuctioneerLoop, 0}, +#endif + +#ifdef _BLACK_MARKET + { {"BlackMarketInit"}, NPC_BlackMarketInit, 0}, + { {"BlackMarketTalked"}, NPC_BlackMarketTalked, 0}, + { {"BlackMarketWindowTalked"}, NPC_BlackMarketWindowTalked, 0}, +#endif + +#ifdef _ALLDOMAN // (不可开) Syu ADD 排行榜NPC + { {"AlldomanInit"} , NPC_AlldomanInit, 0 }, + { {"AlldomanTalked"} , NPC_AlldomanTalked , 0 }, + { {"AlldomanWindowTalked"}, NPC_AlldomanWindowTalked , 0}, +#endif + +#ifdef _NPC_WELFARE + { {"WelfareInit"} , NPC_WelfareInit, 0 }, + { {"WelfareTalked"} , NPC_WelfareTalked , 0 }, + { {"WelfareWindowTalked"}, NPC_WelfareWindowTalked , 0}, +#endif + +#ifdef _NPC_WELFARE_2 // WON ADD 职业NPC-2 + { {"WelfareInit2"} , NPC_WelfareInit2, 0 }, + { {"WelfareTalked2"} , NPC_WelfareTalked2, 0 }, + { {"WelfareWindowTalked2"}, NPC_WelfareWindowTalked2, 0}, +#endif + +#ifdef _NPC_VERYWELFARE + { {"VeryWelfareInit"} , NPC_VeryWelfareInit, 0 }, + { {"VeryWelfareTalked"} , NPC_VeryWelfareTalked , 0 }, + { {"VeryWelfareWindowTalked"}, NPC_VeryWelfareWindowTalked , 0}, +#endif + +#ifdef _CONTRACT + { {"ITEM_contract"}, ITEM_contract, 0}, +#endif + +#ifdef _TIME_TICKET + { {"ITEM_timeticket"}, ITEM_timeticket, 0}, +#endif + +#ifdef _RACEMAN + { {"RacemanInit"} ,NPC_RacemanInit, 0 }, + { {"RacemanTalked"} ,NPC_RacemanTalked, 0 }, + { {"RacemanWindowTalked"},NPC_RacemanWindowTalked ,0 }, +#endif + +#ifdef _ITEM_SETLOVER // 结婚物品 + { {"ITEM_SetLoverUser"}, ITEM_SetLoverUser, 0 }, + { {"ITEM_LoverWarp"}, ITEM_LoverWarp, 0 }, + { {"ITEM_LoverUnmarry"}, ITEM_LoverUnmarry, 0 }, +#endif + +#ifdef _GM_ITEM // GM命令物品 + { {"ITEM_GMFUNCTION"}, ITEM_GMFUNCTION, 0 }, +#endif +}; + +BOOL initFunctionTable( void ) +{ + + int i; + { + char* strings[arraysizeof(correspondStringAndFunctionTable)]; + int stringnum=0; + for( i=0 ; i $OUT +cat $IN | grep -e "^#define" | cut -b 9- | sed "s/\"/\'/g" | \ + sed 's/\\/\\\\/g' >> $OUT +echo "<>" >> $OUT +echo "by : 龙zoro工作室\n\";" >> $OUT \ No newline at end of file diff --git a/gmsv/handletime.c b/gmsv/handletime.c new file mode 100644 index 0000000..2af72cd --- /dev/null +++ b/gmsv/handletime.c @@ -0,0 +1,381 @@ +#define __HANDLETIME_C__ +#include "version.h" +#include +#include + +#include "common.h" +#include "handletime.h" + +#define LSTIME_SECONDS_PER_DAY 5400 /* LSTIME域 少氏及蜇 及 醒 */ + +/* + LSTIME_SECONDS_PER_DAY 毛 尹月午}凛棉及褡心填宁毛 尹月仇午互匹五月[ + + 袄 LS凛棉匹域 丐凶曰及蜇 及凛棉醒 + 9000 ( 赏) 2.5 [hour] + 900 0.25[hour] = 15[min] + 90 0.025[hour] = 1.5[min] = 90[sec] + 9 9[sec] + +*/ + +#define LSTIME_HOURS_PER_DAY 1024 /* LSTIME域 少氏及LSTIME及凛棉醒 */ +#define LSTIME_DAYS_PER_YEAR 100 /* LSTIME域 少氏及LSTIME及 醒 */ + + +// WON REM +/* +// Nuke 0701: localtime + + struct timeval NowTime; +#ifdef localtime +#undef localtime +#endif + +struct tm *localtime(const time_t *timep) +{ + static struct tm lt; + memset(<,0,sizeof(lt)); + lt.tm_sec=*timep %60; + lt.tm_min=(*timep %3600) / 60; + lt.tm_hour=(*timep % 86400) / 3600; + return < +} +*/ + +/*------------------------------------------------------------ + * 域伙□皿卞域荚裟壬木化}凛棉毛褡户月[ + * 娄醒 + * 卅仄 + * 忒曰袄 + * 岳 TRUE(1) + * 撩 FALSE(0) + ------------------------------------------------------------*/ +BOOL setNewTime( void ) +{ + if( gettimeofday( &NowTime, (struct timezone*)NULL) != 0 ) { + NowTime.tv_sec = time(0); + // Nuke 0701: Localtime down + print("\n time err !! \n"); + return FALSE; + } + NowTime.tv_sec += DEBUG_ADJUSTTIME; + return TRUE; +} + + +/******************************************************************* +漆葭绎卞仄凶[byHiO 1998/12/4 18:37 +*******************************************************************/ +static long era = (long)912766409 + 5400; + /* SA及啃卞内日仄凶 */ + /* LS葭 毛烂聒允月化五午□卅醒袄[ + 弁仿奶失件玄午 元元扎卅中午分户[*/ + +/******************************************************************* + 穴扑件凛棉井日LS凛棉卞允月 + long t : time匹请月 + LSTIME *lstime : LSTIME厌瞻 尺及禾奶件正 +*******************************************************************/ +void RealTimeToLSTime(long t , LSTIME *lstime) +{ + long lsseconds = t - era; /* LS葭 井日及 醒 */ + long lsdays; /* LS葭 井日及 醒 */ + + /* 葭 井日及 醒毛1 癫曰及 醒匹喃月午} 卞卅月 */ + lstime->year = (int)( lsseconds/(LSTIME_SECONDS_PER_DAY*LSTIME_DAYS_PER_YEAR) ); + + lsdays = lsseconds/LSTIME_SECONDS_PER_DAY;/* 引内葭 井日及 醒毛煌遥仄化 */ + lstime->day = lsdays % LSTIME_DAYS_PER_YEAR;/* 癫凶曰及 醒匹喃匀凶丐引曰互 */ + + + /*(450*12) 匹1 */ + lstime->hour = (int)(lsseconds % LSTIME_SECONDS_PER_DAY ) +/* 仇仇引匹匹}域 互铵引匀化井日窒 凶匀凶井[ */ + * LSTIME_HOURS_PER_DAY / LSTIME_SECONDS_PER_DAY; + /* 域 丐凶曰及 醒匹喃匀化井日域 丐凶曰及凛棉醒毛井仃月午蜇箕窒凛 + 卅及井互歹井月[*/ + + return; +} + +/******************************************************************* + LS凛棉井日穴扑件凛棉卞允月 + LSTIME *lstime : LSTIME厌瞻 尺及禾奶件正 + long *t : 凛棉尺及禾奶件正 +*******************************************************************/ +void LSTimeToRealTime( LSTIME *lstime, long *t) +{ + *t=(long)( + ( lstime->hour*LSTIME_DAYS_PER_YEAR+lstime->day) /* 凛棉 */ + *LSTIME_HOURS_PER_DAY + + + lstime->year) + /*仇及楮醒反壬什匀化中月方丹卞苇尹月[nakamura */ + + + *450; + return; +} + +/******************************************************************* + LS凛棉匹漆及凛棉嗉坌毛 月 + 曰袄 int : 0}苹1}镞2} 3 + LSTIME *lstime : LSTIME厌瞻 尺及禾奶件正 +*******************************************************************/ +LSTIME_SECTION getLSTime (LSTIME *lstime) +{ + if (NIGHT_TO_MORNING < lstime->hour + && lstime->hour <= MORNING_TO_NOON) + return LS_MORNING; + else if(NOON_TO_EVENING < lstime->hour + && lstime->hour <= EVENING_TO_NIGHT) + return LS_EVENING; + else if(EVENING_TO_NIGHT < lstime->hour + && lstime->hour <= NIGHT_TO_MORNING) + return LS_NIGHT; + else + return LS_NOON; +} + + +#ifdef _ASSESS_SYSEFFICACY +static clock_t TotalClock = 0; +static clock_t StartClock = 0; +//static int EndClock = 0; +//static float SysTime=0.0; +static clock_t EndClock = 0; +static double SysTime=0.0; +static int Cnum = 0; + +#ifdef _ASSESS_SYSEFFICACY_SUB +static clock_t Net_TotalClock = 0; +static clock_t NPCGEN_TotalClock = 0; +static clock_t Battle_TotalClock = 0; +static clock_t Char_TotalClock = 0; +static clock_t Petmail_TotalClock = 0; +static clock_t Family_TotalClock = 0; +static clock_t SaveCheck_TotalClock = 0; +static clock_t GMBroadCast_TotalClock = 0; +static double Net_SysTime=0.0; +static double NPCGEN_SysTime=0.0; +static double Battle_SysTime=0.0; +static double Char_SysTime=0.0; +static double Petmail_SysTime=0.0; +static double Family_SysTime=0.0; +static double SaveCheck_SysTime=0.0; +static double GMBroadCast_SysTime=0.0; +static clock_t SubStartClock = 0; +#endif + +void Assess_InitSysEfficacy() +{ + TotalClock = 0; + StartClock = 0; + EndClock = 0; +#ifdef _ASSESS_SYSEFFICACY_SUB + Net_TotalClock = 0; + NPCGEN_TotalClock = 0; + Battle_TotalClock = 0; + Char_TotalClock = 0; + Petmail_TotalClock = 0; + Family_TotalClock = 0; + SaveCheck_TotalClock = 0; + GMBroadCast_TotalClock = 0; + + SubStartClock = 0; +#endif +} + +void Assess_SysEfficacy( int flg) +{ + if( flg == 0 ){ + StartClock=clock(); + }else if( flg == 1 ){ + EndClock = clock(); + if( EndClock < StartClock ) return; + TotalClock += (int)(EndClock-StartClock); + Cnum++; + if( Cnum%500 == 0 ){ + SysTime = (float)(TotalClock/Cnum)/CLOCKS_PER_SEC; + TotalClock = 0; +#ifdef _ASSESS_SYSEFFICACY_SUB + Net_SysTime = (float)(Net_TotalClock/Cnum)/CLOCKS_PER_SEC; + Net_TotalClock = 0; + NPCGEN_SysTime = (float)(NPCGEN_TotalClock/Cnum)/CLOCKS_PER_SEC; + NPCGEN_TotalClock = 0; + Battle_SysTime = (float)(Battle_TotalClock/Cnum)/CLOCKS_PER_SEC; + Battle_TotalClock = 0; + Char_SysTime = (float)(Char_TotalClock/Cnum)/CLOCKS_PER_SEC; + Char_TotalClock = 0; + Petmail_SysTime = (float)(Petmail_TotalClock/Cnum)/CLOCKS_PER_SEC; + Petmail_TotalClock = 0; + Family_SysTime = (float)(Family_TotalClock/Cnum)/CLOCKS_PER_SEC; + Family_TotalClock = 0; + SaveCheck_SysTime = (float)(SaveCheck_TotalClock/Cnum)/CLOCKS_PER_SEC; + SaveCheck_TotalClock = 0; + GMBroadCast_SysTime = (float)(GMBroadCast_TotalClock/Cnum)/CLOCKS_PER_SEC; + GMBroadCast_TotalClock = 0; +#endif + Cnum = 0; + } + } + /* + EndClock = clock(); + if( StartClock != 0 ){ + if( EndClock < StartClock ) return; + TotalClock += (int)(EndClock-StartClock); + Cnum++; + if( Cnum%500 == 0 ){ + SysTime = (float)TotalClock/Cnum; + TotalClock = 0; + } + } + StartClock = EndClock; + */ +} + +void ASSESS_getSysEfficacy( float *TVsec) +{ + *TVsec = SysTime; +} + +#ifdef _ASSESS_SYSEFFICACY_SUB +void Assess_SysEfficacy_sub( int flg, int loop) +{ + + if( flg == 0 ){ + SubStartClock = clock(); + }else if( flg == 1 ){ + EndClock = clock(); + if( EndClock < SubStartClock ) return; + + switch( loop) { + case 1: // Net_TotalClock + Net_TotalClock += (int)(EndClock-SubStartClock); + break; + case 2: // NPCGEN_TotalClock + NPCGEN_TotalClock += (int)(EndClock-SubStartClock); + break; + case 3: // Battle_TotalClock + Battle_TotalClock += (int)(EndClock-SubStartClock); + break; + case 4: // Char_TotalClock + Char_TotalClock += (int)(EndClock-SubStartClock); + break; + case 5: // Petmail_TotalClock + Petmail_TotalClock += (int)(EndClock-SubStartClock); + break; + case 6: // Family_TotalClock + Family_TotalClock += (int)(EndClock-SubStartClock); + break; + case 7: // SaveCheck_TotalClock + SaveCheck_TotalClock += (int)(EndClock-SubStartClock); + break; + case 8: // GMBroadCast_TotalClock + GMBroadCast_TotalClock += (int)(EndClock-SubStartClock); + break; + } + } +} + +void ASSESS_getSysEfficacy_sub( float *TVsec, int loop_index) +{ + switch( loop_index) { + case 1: + *TVsec = Net_SysTime; + break; + case 2: + *TVsec = NPCGEN_SysTime; + break; + case 3: + *TVsec = Battle_SysTime; + break; + case 4: + *TVsec = Char_SysTime; + break; + case 5: + *TVsec = Petmail_SysTime; + break; + case 6: + *TVsec = Family_SysTime; + break; + case 7: + *TVsec = SaveCheck_SysTime; + break; + case 8: + *TVsec = GMBroadCast_SysTime; + break; + } +} + +#endif + +#endif + +#ifdef _CHECK_BATTLETIME + +#include "battle.h" +static clock_t battleComClock = 0; +double battleComTotalTime[BATTLE_COM_END]; +long battleComTotalUse[BATTLE_COM_END]; + +void check_battle_com_init( void) +{ + print("\n check_battle_com_init... "); + print("\n BATTLE_COM_END = %d ", BATTLE_COM_END); + memset( battleComTotalTime, 0, sizeof(double)*BATTLE_COM_END); + memset( battleComTotalUse, 0, sizeof(long)*BATTLE_COM_END); +} + +void check_battle_com_begin( void) +{ + print(" bi "); + battleComClock = clock(); +} + +void check_battle_com_end( int b_com) +{ + clock_t endClock; + double usedClock; + + endClock = clock(); + usedClock = (double)(endClock - battleComClock)/CLOCKS_PER_SEC; + + print(" BC[%d,%0.10f] ", b_com, usedClock); + battleComTotalTime[b_com] += usedClock; + battleComTotalUse[b_com] ++; + + print(" bo "); + +} + +void check_battle_com_show( void) +{ + FILE *outfile; + int i; + char outstr[1024]; + + outfile = fopen( "battle_com_time.txt", "w"); + if( !outfile) + { + print("\n OPEN battle_com_time.txt ERROR!!! \n"); + return; + } + + for( i =0; i =BATTLE_battlenum || (a)<0 )?(FALSE):(TRUE) ) +#define BATTLE_CHECKSIDE( a ) ( ((a)>=2 || (a)<0)?(FALSE):( TRUE) ) +#define BATTLE_CHECKNO( a ) ( ((a)>=20 || (a)<0 )?(FALSE):(TRUE) ) +#define BATTLE_CHECKADDRESS( a ) ((&BattleArray[0])<=(a) && (a)<=(&BattleArray[BATTLE_battlenum-1] )?(TRUE):(FALSE) ) + +#define IsBATTLING( a ) (CHAR_getWorkInt((a),CHAR_WORKBATTLEMODE)?(TRUE):(FALSE)) + +#define STRCPY_TAIL( _pszTop, _pszLast, _szBuffer) { int _len = strlen( _szBuffer ); ( _pszTop + _len < (_pszLast)-1 )?( memcpy( _pszTop, _szBuffer, _len ), _pszTop += _len, _pszTop[0] = 0):(0); } + +#define BATTLESTR_ADD( _szBuffer ){ int _len = strlen( _szBuffer ); ( pszBattleTop + _len < ( pszBattleLast)-1 )?( memcpy( pszBattleTop, _szBuffer, _len ), pszBattleTop += _len, pszBattleTop[0] = 0):(0); } + +#define BATTLE_MAP_MAX 219 + +#define CH_FIX_PLAYERLEVELUP (+2) // 皿伊奶乩□及伊矛伙互失永皿 +#define CH_FIX_PLAYERDEAD (-2) // 皿伊奶乩□互骚橘韶 +#define CH_FIX_PLAYEULTIMATE (-4) // 皿伊奶乩□互失伙 奴丢永玄韶 +#define CH_FIX_PETESCAPE (-1) // 矢永玄互 仆凶 + +#define AI_FIX_PETLEVELUP (+5*100) // 矢永玄互伊矛伙失永皿 +#define AI_FIX_PETWIN (+1) // 矢永玄互衬毛逦仄凶 +#define AI_FIX_PETGOLDWIN (+2*10) // 矢永玄互伊矛伙及嫖中衬毛逦仄凶 +#define AI_FIX_PETRECOVERY (+10) // 爵 卞荚汊仄化手日匀凶 +#define AI_FIX_PETRESSURECT (+3*100) // 爵 卞汊唾仄化手日匀凶 +//#define AI_FIX_PETRECOVERY (+50) // 爵 卞荚汊仄化手日匀凶 + +#define AI_FIX_SEKKAN (-2*100) // 愤坌及矢永玄毛 猾 +#define AI_FIX_PLAYERULTIMATE (-10*100) // 愤坌及潜谛互失伙 奴丢永玄韶 +#define AI_FIX_PETULTIMATE (-10*100) // 矢永玄互失伙 奴丢永玄韶 +#define AI_FIX_PLAYERDEAD (-1*100) // 愤坌及潜谛互竣濮 +#define AI_FIX_PETDEAD (-5*100) // 矢永玄互竣濮 + + +#ifdef _Item_ReLifeAct +int BATTLE_getBattleDieIndex( int battleindex, int bid ); +#endif + +int BATTLE_No2Index( int battleindex, int No); + +int BATTLE_Index2No( int battleindex, int charaindex); + +BOOL BATTLE_initBattleArray( int battlenum); + +int BATTLE_CreateBattle( void ); +int BATTLE_DeleteBattle( int battleindex); + +int BATTLE_NewEntry( int charaindex, int battleindex, int side); + +#define BATTLE_Exit( charaindex, battleindex) _BATTLE_Exit( __FILE__, __LINE__, charaindex, battleindex) +INLINE int _BATTLE_Exit( char *file, int line, int charaindex ,int battleindex); + +#define BATTLE_ExitAll( battleindex) _BATTLE_ExitAll( __FILE__, __LINE__, battleindex) +INLINE void _BATTLE_ExitAll( char *file, int line, int battleindex); + +int BATTLE_CreateVsPlayer( int charaindex0, int charaindex1); + +int BATTLE_CreateVsEnemy( int charaindex, int mode, int npcindex); + +int BATTLE_CountEntry( int battleindex, int side); + +int BATTLE_Loop( void ); + +int BATTLE_FinishSet( int battleindex ); +int BATTLE_StopSet( int battleindex ); +int BATTLE_RescueEntry( int charaindex, int toindex); + +int BATTLE_PetDefaultExit( int charaindex, int battleindex); + +int BATTLE_PetDefaultEntry( + int charaindex, // 矢永玄毛 匀化中月皿伊奶乩□及 + int battleindex,// 田玄伙奶件犯永弁旦 + int side +); + +BOOL BATTLE_RescueTry( int charaindex); + +BOOL BATTLE_RescueParentTry( + int charaindex, + int pindex + ); + +int BATTLE_DefaultAttacker( int battleindex, int side); + +BOOL BATTLE_IsThrowWepon( int itemindex); + +void BATTLE_BadStatusString( int defNo, int status ); +int BATTLE_MultiList( int battleindex, int toNo, int ToList[] ); +BOOL BATTLE_IsCharge( int com ); +BOOL BATTLE_CanMoveCheck( int charaindex ); +int BATTLE_TargetCheck( int battleindex, int defNo); +char *BATTLE_CharTitle( int charaindex ); +void BATTLE_EscapeDpSend( int battleindex, int charaindex ); +int BATTLE_GetDuelPoint( int battleindex, int side, int num); +int BATTLE_TargetCheckDead( int battleindex, int defNo); + +void BATTLE_MultiListDead( int battleindex, int toNo, int ToList[] ); +BOOL BATTLE_WatchTry( int charaindex); +int BATTLE_WatchEntry( int charaindex, int toindex); +void BATTLE_WatchStop( int charaindex ); +int BATTLE_WatchUnLink( int battleindex ); +void BATTLE_BpSendToWatch( BATTLE *pBattle, char *pszBcString); + +int BATTLE_GetWepon( int charaindex ); + +#ifdef _ITEM_EQUITSPACE +int BATTLE_GetEqShield( int charaindex ); +#endif + +int BATTLE_GetAttackCount( int charaindex ); +int DoujyouRandomWeponSet( int charaindex ); +void BATTLE_AttReverse( int charaindex ); +void BATTLE_BadStatusAllClr( int charaindex ); +#define CHAR_GETWORKINT_HIGH( index, pos ) ( CHAR_getWorkInt( (index), (pos) ) >> 16 ) +#define CHAR_SETWORKINT_HIGH( index, pos, set ) { int iTmp = CHAR_getWorkInt( (index), (pos) ) & 0xFFFF, work = (set); CHAR_setWorkInt( (index), (pos), (work << 16)|iTmp ); } +#define CHAR_GETWORKINT_LOW( index, pos ) ( CHAR_getWorkInt( (index), (pos) ) & 0xFFFF ) +#define CHAR_SETWORKINT_LOW( index, pos, set ) { int iTmp = CHAR_getWorkInt( index, pos ) & 0xFFFF0000, work = (set); CHAR_setWorkInt( (index), (pos), (work & 0x0000FFFF) | iTmp ); } + +int Battle_getTotalBattleNum(); + +#ifdef _TYPE_TOXICATION +void CHAR_ComToxicationHp( int charaindex); +#endif + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 +void BATTLE_ProfessionStatus_init( int battleindex, int charaindex ); +void BATTLE_ProfessionStatusSeq( int battleindex, int charaindex); +#endif + + +#endif diff --git a/gmsv/include/battle_ai.h b/gmsv/include/battle_ai.h new file mode 100644 index 0000000..a7fc394 --- /dev/null +++ b/gmsv/include/battle_ai.h @@ -0,0 +1,10 @@ +#ifndef __BATTLE_AI_H__ +#define __BATTLE_AI_H__ + +/* 曰轼 */ +int BATTLE_ai_all( int battleindex, int side, int turn); +int BATTLE_ai_one( int charaindex, int battleindex, int side, int turn); +#ifdef _ENEMY_ATTACK_AI +int GetSubdueAtt(int index); +#endif +#endif diff --git a/gmsv/include/battle_command.h b/gmsv/include/battle_command.h new file mode 100644 index 0000000..c98b697 --- /dev/null +++ b/gmsv/include/battle_command.h @@ -0,0 +1,27 @@ +#ifndef __BATTLE_COMMAND_H__ +#define __BATTLE_COMMAND_H__ + +void BattleCommandDispach( + int fd, + char *command +); + +void BattleEncountOut( + int charaindex +); + +BOOL BATTLE_CommandSend( int charaindex, char *pszCommand ); + +BOOL BATTLE_MakeCharaString( + int battleindex, + char *pszCommand, // 平乓仿弁正□树 请 燮 + int size // 扔奶术 +); + +void BATTLE_CharSendAll( int battleindex ); + +BOOL BATTLE_PetDefaultCommand( int petindex ); + +void BATTLE_ActSettingSend( int battleindex ); + +#endif diff --git a/gmsv/include/battle_event.h b/gmsv/include/battle_event.h new file mode 100644 index 0000000..3571cf9 --- /dev/null +++ b/gmsv/include/battle_event.h @@ -0,0 +1,383 @@ +#ifndef __BATTLE_EVENT_H__ +#define __BATTLE_EVENT_H__ + +#define BCC_HIT 'H' +#define BCC_FIRE 'F' + +#define BCF_DEATH (1 << 0) +#define BCF_NORMAL (1 << 1) +#define BCF_KAISHIN (1 << 2) +#define BCF_GUARD (1 << 3) +#define BCF_COUNTER (1 << 4) +#define BCF_DODGE (1 << 5) +#define BCF_ULTIMATE_1 (1 << 6) +#define BCF_ULTIMATE_2 (1 << 7) +#define BCF_GBREAK (1 << 8) +#define BCF_GUARDIAN (1 << 9) +#define BCF_REFRECT (1 << 10) +#define BCF_ABSORB (1 << 11) +#define BCF_VANISH (1 << 12) +#define BCF_CRUSH (1 << 13) +#define BCF_FALL (1 << 14) //落马术 +#ifdef _SKILL_TOOTH +#define BCF_TOOTH (1 << 15) // 齿 +#endif +#ifdef _PSKILL_MODIFY +#define BCF_ATTDOUBLE (1 << 16) //属性强化 +#endif +#ifdef _SKILL_ROAR +#define BCF_ROAR (1 << 17) //宠技:大吼(克年兽) +#endif + +#ifdef _MAGIC_DEFMAGICATT +#define BCF_DEFMAGICATT (1 << 19) +#endif +#ifdef _MAGIC_SUPERWALL +#define BCF_SUPERWALL (1 << 20) +#endif +#ifdef _PSKILL_MDFYATTACK +#define BCF_MODIFY (1 << 21) +#endif + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 +#define BCF_F_SKILLACT (1 << 22) //击中前秀图 +#define BCF_TRAP (1 << 25) //陷阱 +#define BCF_NO_DAMAGE (1 << 26) //双重攻击 +#endif +#define BCF_B_SKILLACT (1 << 23) //击中後秀图 + + + +#ifdef _EQUIT_ARRANGE +#define BCF_B_ARRANGE (1 << 24) //格挡秀图 +#endif + +#ifdef _PETSKILL_ACUPUNCTURE +#define BCF_ACUPUNCTURE (1 << 27) +#endif + +#ifdef _PETSKILL_ANTINTER +#define BCF_ANTINTER (1 << 28) +#endif +#ifdef _PETSKILL_EXPLODE +#define BCF_EXPLODE (1 << 29) +#endif + +#ifdef _OTHER_MAGICSTAUTS +#ifdef _MAGICSTAUTS_RESIST +#define MAXSTATUSTYPE 6 +#else +#define MAXSTATUSTYPE 3 +#endif //_MAGICSTAUTS_RESIST +extern char MagicStatus[MAXSTATUSTYPE][36]; +extern int MagicTbl[]; +extern int MagicTypeTbl[]; +#endif + +extern char *aszStatus[]; +extern char *aszStatusFull[]; +extern int StatusTbl[]; +extern int RegTbl[]; +extern int MagicDefTbl[]; +extern char *aszMagicDefFull[]; +extern char *aszMagicDef[]; + +extern char *aszParamChange[]; +extern char *aszParamChangeFull[]; +extern int aParamChangeTbl[]; + +extern float gBattleDamageModyfy; +extern int gBattleDuckModyfy; +extern int gBattleStausChange; +extern int gBattleStausTurn; + +enum{ + BATTLE_ST_NONE, // 0 "正常", + BATTLE_ST_POISON, // 1 "毒", + BATTLE_ST_PARALYSIS, // 2 "麻", + BATTLE_ST_SLEEP, // 3 "眠", + BATTLE_ST_STONE, // 4 "石", + BATTLE_ST_DRUNK, // 5 "醉", + BATTLE_ST_CONFUSION, // 6 "乱", + BATTLE_ST_WEAKEN, // 7 "虚" + BATTLE_ST_DEEPPOISON,// 8 "剧毒" + BATTLE_ST_BARRIER, // 9 "魔障" + BATTLE_ST_NOCAST, // 10 "沉默" +#ifdef _PET_SKILL_SARS // WON ADD 毒煞蔓延 + BATTLE_ST_SARS, // 11 "煞" +#endif +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + BATTLE_ST_DIZZY, // 12 "晕" + BATTLE_ST_ENTWINE, // 13 "缠" + BATTLE_ST_DRAGNET, // 14 "天罗地网" + BATTLE_ST_ICECRACK, // 15 "冰爆术" + BATTLE_ST_OBLIVION, // 16 "遗忘" + BATTLE_ST_ICEARROW, // 17 "冰箭" + BATTLE_ST_BLOODWORMS,// 18 "嗜血蛊" + BATTLE_ST_SIGN, // 19 "一针见血" + BATTLE_ST_INSTIGATE, // 20 "挑拨" + BATTLE_ST_F_ENCLOSE, // 21 "火附体" + BATTLE_ST_I_ENCLOSE, // 22 "冰附体" + BATTLE_ST_T_ENCLOSE, // 23 "雷附体" + BATTLE_ST_FOCUS, // 24 "专注战斗" + BATTLE_ST_RESIST_F, // 25 "火抗" + BATTLE_ST_RESIST_I, // 26 "冰抗" + BATTLE_ST_RESIST_T, // 27 "雷抗" + BATTLE_ST_F_ENCLOSE2, // 28 "火附" + BATTLE_ST_I_ENCLOSE2, // 29 "冰附" + BATTLE_ST_T_ENCLOSE2, // 30 "雷附" +#ifdef _PROFESSION_ADDSKILL + BATTLE_ST_RESIST_F_I_T, //31 "火冰雷抗" + //BATTLE_ST_BOUNDARY_F, //32 "火结界 + BATTLE_ST_WATER, //32 "水附体" + BATTLE_ST_WORKANNEX, //33 "附身" + BATTLE_ST_FEAR, //34 "恐惧" + BATTLE_ST_ICECRACK2, // 35 "冰爆术" + BATTLE_ST_ICECRACK3, // 36 + BATTLE_ST_ICECRACK4, // 37 + BATTLE_ST_ICECRACK5, // 38 + BATTLE_ST_ICECRACK6, // 39 + BATTLE_ST_ICECRACK7, // 40 + BATTLE_ST_ICECRACK8, // 41 + BATTLE_ST_ICECRACK9, // 42 + BATTLE_ST_ICECRACK10, // 43 +#endif + +#endif + + BATTLE_ST_END +}; + +#ifdef _OTHER_MAGICSTAUTS +enum{ + BATTLE_MST_NONE, + BATTLE_MST_DEFMAGIC, + BATTLE_MST_SUPERWALL, +#ifdef _MAGICSTAUTS_RESIST + BATTLE_MST_MAGICFIRE, + BATTLE_MST_MAGICTHUNDER, + BATTLE_MST_MAGICICE, +#endif + BATTLE_MST_END +}; +#endif + +enum{ + BATTLE_MD_NONE, + BATTLE_MD_ABSROB, + BATTLE_MD_REFLEC, + BATTLE_MD_VANISH, + BATTLE_MD_TRAP, +#ifdef _PETSKILL_ACUPUNCTURE + BATTLE_MD_ACUPUNCTURE, //针刺外皮 +#endif + BATTLE_MD_END +}; + +#ifdef _PETSKILL_RETRACE + //存放BATTLE_Attack函式执行後的攻击模式 +typedef struct tagBattle_Attack_ReturnData_x1 +{ + int Battle_Attack_ReturnData; +}Battle_Attack_ReturnData_x1; +Battle_Attack_ReturnData_x1 Battle_Attack_ReturnData_x; + +#endif + +int BATTLE_DamageCalc( int attackindex, int defindex ); + +BOOL BATTLE_Attack( int battleindex, int attackNo, int defNo ); + +BOOL BATTLE_Counter( int battleindex, int attackNo, int defNo ); + +BOOL BATTLE_Capture( int battleindex, int attackNo, int defNo ); + +void BATTLE_Guard( int battleindex, int attackNo ); + +// Nuke 20040112 fix for performance +#define BATTLE_BroadCast(A,B,C) 0 +#define BATTLE_BroadCastOn(A,B,C) 0 +//int BATTLE_BroadCast( int battleindex, char *pszBuffer, int color ); +//int BATTLE_BroadCastOn( int battleindex, char *pszBuffer, int color ); + +BOOL BATTLE_Escape( int battleindex, int attackNo, int flag); + +int BATTLE_NoAction( int battleindex, int attackNo ); + +int BATTLE_PetIn( int battleindex, int attackNo ); + +int BATTLE_PetOut( int battleindex, int attackNo ); + +int BATTLE_SurpriseCheck( int battleindex ); + +int BATTLE_Magic( int battleindex, int attackNo ); + +int BATTLE_S_GBreak( int battleindex, int attackNo, int defNo ); + +#ifdef _SKILL_GUARDBREAK2//破除防御2 vincent add 2002/05/20 +int BATTLE_S_GBreak2( int battleindex, int attackNo, int defNo ); +#endif + +#ifdef _SKILL_SACRIFICE +int BATTLE_S_Sacrifice( int battleindex, int attackNo, int defNo ); +#endif + +#ifdef _SKILL_REFRESH +int BATTLE_S_Refresh( int battleindex, int attackNo, int defNo, int marray ); +#endif + +#ifdef _SKILL_WEAKEN //vincent宠技:虚弱 +int BATTLE_S_Weaken( int battleindex, int attackNo, int defNo, int marray ); +#endif + +#ifdef _SKILL_DEEPPOISON //vincent宠技:剧毒 +int BATTLE_S_Deeppoison( int battleindex, int attackNo, int defNo, int marray ); +#endif + +#ifdef _SKILL_BARRIER //vincent宠技:魔障 +int BATTLE_S_Barrier( int battleindex, int attackNo, int defNo, int marray ); +#endif + +#ifdef _SKILL_NOCAST //vincent宠技:沉默 +int BATTLE_S_Nocast( int battleindex, int attackNo, int defNo, int marray ); +#endif + +#ifdef _SKILL_ROAR //vincent宠技:大吼 +int BATTLE_S_Roar( int battleindex, int attackNo, int defNo, int marray ); +#endif + +int BATTLE_Charge( int battleindex, int attackNo ); + + +int BATTLE_StatusAttackCheck( + + int attackindex, + int defindex, + int status, + //BATTLE_ST_POISON, 1 "毒", + //BATTLE_ST_PARALYSIS, 2 "麻", + //BATTLE_ST_SLEEP, 3 "眠", + //BATTLE_ST_STONE, 4 "石", + //BATTLE_ST_DRUNK, 5 "醉", + //BATTLE_ST_CONFUSION, 6 "乱" + int PerOffset, + int Range, + float Bai, + int *pPer +); + +int BATTLE_Combo( int battleindex, int *pAttackList, int defNo ); + +int BATTLE_EarthRoundHide( int battleindex, int attackNo ); + +int BATTLE_GetDamageReact( int charaindex ); + +void BATTLE_talkToCli( int charaindex, char *pszBuffer, int color ); + +#ifdef _PETSKILL_SETDUCK +BOOL BATTLE_CheckMySkillDuck( int charaindex ); +#endif + +BOOL BATTLE_LostEscape( int battleindex, int attackNo ); + +BOOL BATTLE_Abduct( int battleindex, int attackNo, int defNo, int array ); + +void BATTLE_Steal( int battleindex, int attackNo, int defNo ); + +int BATTLE_getReactFlg( int index, int react); + +#ifdef _BATTLESTEAL_FIX +void BATTLE_StealMoney( int battleindex, int attackNo, int defNo) ; +#endif + +#ifdef _PETSKILL_LER +void BATTLE_BatFly(int battleindex,int attackNo,int myside); +void BATTLE_DivideAttack(int battleindex,int attackNo,int myside); +void BATTLE_LerChange(int battleindex,int charaindex,int no); +#endif + +#ifdef _PETSKILL_BATTLE_MODEL +void BATTLE_BattleModel(int battleindex,int attackNo,int myside); +#endif + +// Robin 0727 Ride Pet +#define ATTACKSIDE 1 +#define DEFFENCESIDE 2 + +float BATTLE_adjustRidePet3A( int charaindex, int petindex, int workindex, int action ); + +int BATTLE_getRidePet( int charaindex ); + +#ifdef _PSKILL_FALLGROUND //落马术 +int BATTLE_S_FallGround( int battleindex, int attackNo, int defNo, int skill_type ); +#endif +#ifdef _PETSKILL_EXPLODE +int BATTLE_S_Explode( int battleindex, int attackNo, int defNo, int skill_type ); +#endif + +#ifdef _PETSKILL_PROPERTY +int BATTLE_S_PetSkillProperty( int battleindex, int attackNo, int skill_type, int skill); +#endif + +int BATTLE_S_AttackDamage( int battleindex, int attackNo, int defNo, int skill_type, int skill); + +#ifdef _MAGIC_SUPERWALL +int PETSKILL_MagicStatusChange_Battle( int battleindex, int attackNo, int toNo, int marray); +#endif + +#ifdef _PETSKILL_SETDUCK +int PETSKILL_SetDuckChange_Battle( int battleindex, int attackNo, int toNo, int marray); +#endif + +#ifdef _MAGICPET_SKILL +int PETSKILL_SetMagicPet_Battle( int battleindex, int attackNo, int toNo, int marray); +#endif + +#ifdef _TAKE_ITEMDAMAGE +int BATTLE_ItemCrushCheck( int charaindex , int flg); +int BATTLE_ItemCrush( int charaindex, int ItemEquip, int Damages, int flg); +#endif + +#ifdef _PRO_BATTLEENEMYSKILL +int BATTLE_E_ENEMYREFILE( int battleindex, int attackNo, int defNo, int skill_type ); + +int BATTLE_E_ENEMYREHP( int battleindex, int attackNo, int defNo, int skill_type ); + +int BATTLE_E_ENEMYHELP( int battleindex, int attackNo, int defNo, int skill_type ); +#endif + + +#ifdef _PREVENT_TEAMATTACK +int BATTLE_CheckSameSide( int charaindex, int toNo); +#endif + +#ifdef _USER_CHARLOOPS +int CHAR_BattleStayLoop( int charaindex);//原地遇敌 +#endif + +#ifdef _PETSKILL_PROPERTY +int PET_PetskillPropertyEvent( int Myindex, int defindex, int *damage, int *T_Pow, int size); +#endif + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 +int battle_profession_attack_fun(int battleindex, int attackNo, int defNo, int charaindex); +int battle_profession_attack_magic_fun(int battleindex, int attackNo, int defNo, int charaindex); +int battle_profession_assist_fun(int battleindex, int attackNo, int defNo, int charaindex); +int battle_profession_status_chang_fun(int battleindex, int attackNo, int defNo, int charaindex); +int BATTLE_check_profession_duck( int charaindex, int per ); +int BATTLE_PROFESSION_ATK_PET_DamageSub( int attackindex, int defindex, int *pDamage, int *pPetDamage, int *pRefrect, int skill_level ); +int PROFESSION_BATTLE_StatusAttackCheck( int charaindex, int toindex, int status, int Success ); +int BATTLE_PROFESSION_CONVOLUTE_GET_DAMAGE( int attackindex, int defindex, int skill_level ); +int BATTLE_PROFESSION_THROUGH_ATTACK_GET_DAMAGE( int attackindex, int defindex ); +int BATTLE_PROFESSION_RANG_ATTACK_DAMAGE( int charaindex, int attackNo, int defNo, int skill_type, int status, int turn, int perStatus, int effect, int img1, int img2 ); + +#endif + +#ifdef _PETSKILL_FIREKILL //火线猎杀专用 +int BATTLE_Attack_FIREKILL( int battleindex, int attackNo, int defNo ); +#endif +#ifdef _PROFESSION_ADDSKILL +BOOL BATTLE_BattleUltimate( int battleindex, int bid ); //检查此位 上是否被打飞 +#endif + +#endif diff --git a/gmsv/include/battle_item.h b/gmsv/include/battle_item.h new file mode 100644 index 0000000..483fa73 --- /dev/null +++ b/gmsv/include/battle_item.h @@ -0,0 +1,36 @@ +#ifndef _BATTLE_ITEM_H_ +#define _BATTLE_ITEM_H_ +//-------------------------------------------------------------- +// 荚汊失奶 丞毛银匀凶桦宁及质 +//-------------------------------------------------------------- +// 爵 及桦宁 +void ITEM_useRecovery_Battle( int charaindex, int toindex, int itemindex ); +void ITEM_useStatusChange_Battle( int charaindex, int toindex, int itemindex ); +void ITEM_useMagicDef_Battle( int charaindex, int toindex, int itemindex ); +void ITEM_useParamChange_Battle( int charaindex, int toindex, int itemindex ); +void ITEM_useFieldChange_Battle( int charaindex, int toindex, int itemindex ); +void ITEM_useAttReverse_Battle( int charaindex, int toindex, int itemindex ); +void ITEM_useStatusRecovery_Battle( int charaindex, int toindex, int itemindex ); +void ITEM_useCaptureUp_Battle( int charaindex, int toindex, int itemindex ); +#ifdef _ITEM_CRACKER +void ITEM_useCracker_Effect( int charaindex, int toindex, int haveitemindex); +#endif +#ifdef _ITEM_ADDEXP //vincent 经验提升 +void ITEM_useAddexp_Effect( int charaindex, int toindex, int haveitemindex); +#endif +#ifdef _ITEM_REFRESH //vincent 解除异常状态道具 +void ITEM_useRefresh_Effect( int charaindex, int toindex, int haveitemindex); +#endif +//Terry add 2001/12/24 +#ifdef _ITEM_FIRECRACKER +void ITEM_useFirecracker_Battle(int charaindex,int toindex,int itemindex); +#endif +//Terry end + +#ifdef _ITEM_MAGICRECOVERY +void ITEM_useMRecovery_Battle( int charaindex, int toNo, int haveitemindex ); +#endif +#ifdef _ITEM_USEMAGIC +void ITEM_useMagic_Battle( int charaindex, int toNo, int haveitemindex ); +#endif +#endif diff --git a/gmsv/include/battle_magic.h b/gmsv/include/battle_magic.h new file mode 100644 index 0000000..eb6938f --- /dev/null +++ b/gmsv/include/battle_magic.h @@ -0,0 +1,341 @@ +#ifndef _BATTLE_MAGIC_H_ +#define _BATTLE_MAGIC_H_ + +#define MAGIC_EFFECT_USER 100600 +#define SPR_heal 100601 +#define SPR_heal2 100602 +#define SPR_heal3 100603 +#define SPR_tyusya 100604 +#define SPR_hoshi 100605 + + +#define MAGIC_ID_RECOVERY 1 +#define MAGIC_ID_STATUS_RECOVERY 3 +#define MAGIC_ID_FIELD_CHANGE 4 +#define MAGIC_ID_BADSTATUS 5 + +enum{ + BFUKI_CAPTUREUP, + BFUKI_END +}; + + +enum{ + PC_KIND_NONE, + PC_KIND_ATTACK, + PC_KIND_DEFENSE, + PC_KIND_QUICK, + PC_KIND_CHARM, + PC_KIND_CAPTURE, + PC_KIND_END +}; + +int MAGIC_Recovery_Battle( + int charaindex, + int toindex, + int magicindex, + int mp +); + +int MAGIC_FieldAttChange_Battle( + int charaindex, + int toindex, + int marray, + int mp +); + +int MAGIC_StatusChange_Battle( + int charaindex, + int toindex, + int marray, + int mp +); + +#ifdef _MAGIC_DEEPPOISON +int MAGIC_StatusChange_Battle2( + int charaindex, + int toindex, + int marray, + int mp +); +#endif + +#ifdef _OTHER_MAGICSTAUTS +int MAGIC_MagicStatusChange_Battle( int charaindex, int toNo, int marray, int mp ); + +#endif + +int MAGIC_MagicDef_Battle( + int charaindex, + int toNo, + int marray, + int mp +); + +void BATTLE_MultiRecovery( + int battleindex, + int attackNo, + int toNo, + int kind, + int power, + int per, + int UseEffect, +#ifdef _CHANGEITEMUSE // Syu ADD 调整战斗中使用料理设定 + int RecevEffect, + int power1 +#else + int RecevEffect +#endif + +); + +#ifdef _IMPRECATE_ITEM +void BATTLE_ImprecateRecovery( + int battleindex, + int attackNo, + int toNo, + int kind, + int powers, + int rounds, + int UseEffect, + int RecevEffect +); +#endif +void BATTLE_MultiStatusChange( + int battleindex, + int attackNo, + int toNo, + int status, + int turn, + int UseEffect, + int RecevEffect, + int Success +); + +#ifdef _OTHER_MAGICSTAUTS +void BATTLE_MultiMagicStatusChange( + int battleindex, + int attackNo, + int toNo, + int status, + int turn, + int UseEffect, + int RecevEffect, + int nums +); +#endif + +void BATTLE_MultiMagicDef( + int battleindex, + int attackNo, + int toNo, + int kind, + int count, + int UseEffect, + int RecevEffect +); + +void BATTLE_MultiParamChange( + int battleindex, + int attackNo, + int toNo, + int kind, + int power, + int par, + int UseEffect, + int RecevEffect +); + +int MAGIC_FieldAttChange_Battle( + int charaindex, + int toNo, + int marray, + int mp +); + +int BATTLE_FieldAttChange( + int charaindex, + char *pArg +); + +void BATTLE_MultiAttReverse( + int battleindex, + int attackNo, + int toNo, + int UseEffect, + int RecevEffect +); + + +void BATTLE_MultiStatusRecovery( + int battleindex, + int attackNo, + int toNo, + int status, + int UseEffect, + int RecevEffect +); + +int MAGIC_StatusRecovery_Battle( + int charaindex, + int toNo, + int marray, + int mp +); + +void BATTLE_MultiRessurect( + int battleindex, + int attackNo, + int toNo, + int power, + int per, + int UseEffect, + int RecevEffect +); + +void BATTLE_MultiCaptureUp( + int battleindex, + int attackNo, + int toNo, + int power, + int UseEffect, + int RecevEffect +); +// +//*********************************************************** + +//**************************************************************** +// +// 竣濮井日汊唾允月热诸 +// +int MAGIC_Ressurect_Battle( + int charaindex, // 井仃月谛及奶件犯永弁旦 + int toNo, // 井仃日木月谛及奶件犯永弁旦 + int marray, // magicindex + int mp // MP +); +// 岳 仄凶日 TRUE +// 撩 仄凶日 FALSE +//**************************************************************** + +//**************************************************************** +// +// 箪岭及 鳖毛允月热诸 +// +int MAGIC_AttReverse_Battle( + int charaindex, // 井仃月谛及奶件犯永弁旦 + int toNo, // 井仃日木月谛及奶件犯永弁旦 + int marray, // magicindex + int mp // MP +); +// 岳 仄凶日 TRUE +// 撩 仄凶日 FALSE +//**************************************************************** +//**************************************************************** +// +// 凯 祭允月热诸 +// +int MAGIC_CaptureUp_Battle( + int charaindex, // 井仃月谛及奶件犯永弁旦 + int toNo, // 井仃日木月谛及奶件犯永弁旦 + int marray, // magicindex + int mp // MP +); +// 岳 仄凶日 TRUE +// 撩 仄凶日 FALSE +//**************************************************************** + +//*********************************************************** +// +// 芊羁匹 醒及平乓仿弁正□毛汊唾今六月今日卞 芊 豢毛馨笛 +// +void BATTLE_MultiResAndDef( + int battleindex, // 田玄伙奶件犯永弁旦 + int attackNo, // 井仃月谛 寞 + int toNo, // 井仃日木月谛 寞 + int power, // 湘 荚汊袄 + int per, // ⊙井" + int kind, // 芊 豢及潘 + int count, // 窒荚 什井 + int UseEffect, // 银丹谛及巨白尼弁玄 + int RecevEffect // 井仃日木月谛及巨白尼弁玄 +); +// +//*********************************************************** +//**************************************************************** +// +// 汊唾≈ 芊 豢毛芨尹月热诸 +// +int MAGIC_ResAndDef_Battle( + int charaindex, // 井仃月谛及奶件犯永弁旦 + int toNo, // 井仃日木月谛及奶件犯永弁旦 + int marray, // magicindex + int mp // MP +); +// 岳 仄凶日 TRUE +// 撩 仄凶日 FALSE +//**************************************************************** + +#ifdef __ATTACK_MAGIC +int MAGIC_AttMagic_Battle( int charaindex , int toNo , int marray , int mp ); +#ifdef _FIX_MAGICDAMAGE +void BATTLE_MultiAttMagic( int battleindex, int attackNo, int toNo, + int attIdx ,int FieldAttr ,int Power, int MagicLv); + +#else +void BATTLE_MultiAttMagic( int battleindex , int attackNo , int toNo , int attIdx , int FieldAttr , int Power ); +#endif +int MAGIC_AttMagic_Battle( int charaindex , int toNo , int marray , int mp ); + +#endif + + + +#ifdef _MAGIC_TOCALL +int MAGIC_ToCallDragon_Battle( int charaindex , int toNo , int marray , int mp ); + +void BATTLE_MultiToCallDragonMagic( int battleindex, int attackNo, int toNo, + int attIdx ,int FieldAttr ,int Power, int ImageNo); + +#endif + +#ifdef _Item_ReLifeAct +void BATTLE_MultiReLife( int battleindex, int attackNo, int toNo, int power, int RecevEffect ); +#endif +#ifdef _MAGIC_WEAKEN +int MAGIC_ParamChange_Turn_Battle(int charaindex,int toNo,int marray,int mp); +void BATTLE_MultiParamChangeTurn( int battleindex,int attackNo,int toNo,int status,int UseEffect,int RecevEffect,int turn, int Success); +#endif +int BATTLE_MagicEffect( int battleindex,int attackNo,int ToList[],int MyEffect,int ToEffect ); + + + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 +void PROFESSION_MAGIC_ATTAIC( int battleindex, int attackNo, int toNo, int attIdx, int FieldAttr, int skill); +int PROFESSION_MAGIC_ATTAIC_Effect( int battleindex, int attackNo, int ToList[], int AttackMgcNo ); +int analysis_profession_parameter( int attIdx, int skill, int toNo, int charaindex ); +void PROFESSION_MAGIC_GET_PRACTICE( float *hp_power, float *mp_power, float *dec_hp, float *dec_mp, int charaindex ); +void PROFESSION_MAGIC_TOLIST_SORT( int *list, int *listidx, int charaindex ); +void PROFESSION_MAGIC_CHANGE_STATUS( int charaindex, int hp_power, float mp_power, float *add_hp, float *add_mp ); +void PROFESSION_MAGIC_GET_IMG2( int toNo, int charaindex, int attIdx, char *pszOption ); +#ifdef _PROFESSION_ADDSKILL +int PROFESSION_MAGIC_GET_DAMAGE( int attackindex, int defindex, int magic_type, int power, int command ); +#else +int PROFESSION_MAGIC_GET_DAMAGE( int attackindex, int defindex, int magic_type, int power ); +#endif +int PROFESSION_MAGIC_DODGE( int atk_index, int def_index, int magic_type ); +void PROFESSION_MAGIC_CHANG_IMG2( int img2, char *pszOption, int attIdx ); +int PROFESSION_MAGIC_CHANG_STATUS(int command,int battleindex, int charaindex, int charaidx, int power, int no); +int PROFESSION_MAGIC_GET_ICE_MIRROR_DAMAGE( int attackindex, int defindex, int command, int power ); +#endif + +#ifdef _PETSKILL_FIREKILL +void BATTLE_MultiAttMagic_Fire( int battleindex, int attackNo, int defNo, + int FieldAttr , int Power); +#endif + +#ifdef _PROFESSION_ADDSKILL +unsigned int GET_PROFESSION_magic_uiSpriteNum(int idx); +#endif + +#endif diff --git a/gmsv/include/buf.h b/gmsv/include/buf.h new file mode 100644 index 0000000..78665f0 --- /dev/null +++ b/gmsv/include/buf.h @@ -0,0 +1,11 @@ +#ifndef __BUF_H__ +#define __BUF_H__ + +#include "common.h" +void memEnd( void ); +BOOL configmem( int unit , int unitnumber ); +BOOL memInit( void ); +void* allocateMemory( const unsigned int nbyte ); +void freeMemory( void* freepointer ); +void showMem( char *buf); +#endif diff --git a/gmsv/include/char.h b/gmsv/include/char.h new file mode 100644 index 0000000..9ab6ce8 --- /dev/null +++ b/gmsv/include/char.h @@ -0,0 +1,771 @@ +#ifndef __CHAR_H__ +#define __CHAR_H__ + +#include "common.h" +#include "char_base.h" +#include "net.h" +#include "char_data.h" + + +/*------------------------------------------------------------ + *白巧件玄及缙及烂聒 + *------------------------------------------------------------*/ +typedef enum +{ + CHAR_COLORWHITE, + CHAR_COLORCYAN, + CHAR_COLORPURPLE, + CHAR_COLORBLUE, + CHAR_COLORYELLOW, + CHAR_COLORGREEN, + CHAR_COLORRED, + CHAR_COLORGRAY, + CHAR_COLORBLUE2, + CHAR_COLORGREEN2, + +}CHAR_COLOR; +/*====================平乓仿及综岳卞楮允月楮醒====================*/ +void CHAR_createNewChar( int clifd, int dataplacenum,char* charname , + int imgno,int faceimgno, + int vital,int str,int tgh,int dex, + int earth,int water,int fire,int wind, + int hometown , char *cdkey ); + +/*====================平乓仿及夫弘奶件====================*/ + +#ifdef _BAD_PLAYER // WON ADD 送坏玩家去关 +void CHAR_login( int clifd, char* data, int saveindex, int badplayer ); +#else +void CHAR_login( int clifd, char* data, int saveindex ); +#endif + +#define CHAR_warpToSpecificPoint( cindex, fl, x, y) _CHAR_warpToSpecificPoint( __FILE__, __LINE__, cindex, fl, x, y) +BOOL _CHAR_warpToSpecificPoint( char *file, int line, + int charaindex, int fl, int x, int y); + + +/*====================平乓仿及本□皮====================*/ +/*====================平乓仿及夫弘失它玄====================*/ +BOOL CHAR_charSaveFromConnectAndChar( int fd,Char* ch, int unlock ); +BOOL CHAR_charSaveFromConnect( int fd,int unlock ); +#define CHAR_logout( clifd, save) _CHAR_logout( __FILE__, __LINE__, clifd, save) +BOOL _CHAR_logout( char *file, int line, int clifd, BOOL save); + +/*====================watch event ====================*/ +void CHAR_sendWatchEvent( int objindex, int chac, int* opt,int optlen,BOOL myflg ); + +/*====================旦平伙====================*/ +BOOL CHAR_Skillupsend(int charaindex ); +void CHAR_SkillUp( int charaindex, int skillid ); +void CHAR_useSkill( int charaindex, int dir ,int skindex ); + +typedef enum +{ + CHAR_WALKSUCCESSED, /* 岳 */ + CHAR_WALKSYSTEMERROR, /* 扑旦 丞巨仿□ 及index民尼永弁卞 + * 夫匀井井匀凶午井 */ + CHAR_WALKEXTEND, /* 区左□田□仄化汹仇丹午仄凶[NPC卞及心*/ + CHAR_WALKHITOBJECT, /* 窒井 卞癫匀化}汹仃卅井匀凶 */ + CHAR_WALKPREWALK, /* prewalk奶矛件玄匹汹仃卅井匀凶( 檗祭 ) */ + CHAR_WALKDIE, /* 韶氏匹中化汹仃卅中 */ + CHAR_WALK1357, /* 标户 轾卞汹仇丹午仄化汹仃卅井匀凶 */ +}CHAR_WALKRET; + +/*====================平乓仿及啖 卞楮允月楮醒====================*/ +void CHAR_ctodirmode(char moji , int* dir , int* mode); +INLINE void CHAR_getDXDY( int dir , int* dx, int* dy ); +INLINE int CHAR_getDX( int dir ); +INLINE int CHAR_getDY( int dir ); +int CHAR_getSameCoordinateObjects(int* objbuf, int siz,int ff, int fx, int fy); +void CHAR_walkcall( int index ); +void CHAR_walk_start(int index, int x, int y, char* dir, BOOL mapsendmode); +void CHAR_walk_init( int fd, int x, int y, char *direction, BOOL mapsendmode); + +CHAR_WALKRET CHAR_walk(int index, int dir, int mode); + +char* CHAR_makeOptionString( Char* ch ); +char* CHAR_makeStatusString( int index, char* category ); + +#define CHAR_makeObjectCString( objindex, buf, buflen) _CHAR_makeObjectCString( __FILE__, __LINE__, objindex, buf, buflen) +BOOL _CHAR_makeObjectCString( char *file, int line, int objindex, char* buf, int buflen ); + +//BOOL CHAR_sendStatusString( int charaindex, char* category ); +#define CHAR_sendStatusString( A, B) _CHAR_sendStatusString( A, B, __FILE__, __LINE__ ) +BOOL _CHAR_sendStatusString( int charaindex, char* category, char* file, int line ); +BOOL CHAR_sendItemData( int charaindex, int *itemgroup, int num); +BOOL CHAR_sendItemDataOne( int charaindex, int haveitemindex); +BOOL CHAR_send_P_StatusString( int charaindex, unsigned int indextable ); +BOOL CHAR_send_N_StatusString( int charaindex, int num, unsigned int indextable ); +BOOL CHAR_send_K_StatusString( int charaindex, int num, unsigned int indextable ); + +void CHAR_inputOwnTitle( int index ,char* name ); + +void CHAR_selectTitle( int index, int titleindex ); +void CHAR_deleteTitle( int index, int titleindex ); + +#define CHAR_complianceParameter( index) _CHAR_complianceParameter( index, __FILE__, __LINE__) +int _CHAR_complianceParameter( int index, char *FILE, int LINE); + +int CHAR_findSurplusItemBox( int index ); +int CHAR_findEmptyItemBox( int index ); +int CHAR_findEmptyPoolItemBox( int index ); +int CHAR_findEmptyItemBoxNo( int index ); + +void CHAR_moveEquipItem( int index, int fromindex, int toindex ); +void CHAR_ItemUse( int charaindex, int to_charaindex, int haveitemindex ); +void CHAR_DropItem( int charaindex, int itemindex ); +int CHAR_DropItemAbsolute( int itemindex, int floor, int x, int y,BOOL net); +BOOL CHAR_DropItemFXY( int charaindex, int itemcharaindex, int fl, + int x, int y, int* objindex ); +int CHAR_addItemSpecificItemIndex( int charaindex, int itemindex ); + +void CHAR_PickUpItem( int charaindex, int dir ); +void CHAR_DropMoney( int charaindex, int amount ); +int CHAR_addItem( int charaindex, int itemid ); +int CHAR_addItemToChar( Char* ch, int itemid ); + +int CHAR_pickupFollowPet( int charaindex, int petindex ); + +#ifdef _GAMBLE_ROULETTE +int NPC_MAPCLEANGOLD( int meindex , int floor); +#endif + +#ifdef _DROPSTAKENEW +#define MAXSTAKENUM 5 +int CasinoAccumulation(int charindex, int npcindex, int floor, int wincasinotype); +void CHAR_talkToFloor(int floor, int talkindex, char* message, CHAR_COLOR color); +int SetCasinoMap(int npcindex, int casinotype, int mapdropflag); +int CasinoPay(int npcindex, int wincasinotype); +#endif + +void CHAR_sendCSpecifiedObjindex( int fd, int index); +void CHAR_sendSpecifiedobjindexCToCharaindex(int charaindex,int objindex); + +void CHAR_sendCToArroundCharacter( int charaindex ); + +void CHAR_sendArroundCharaData( int charaindex ); + +void CHAR_sendCDArroundChar( int fl, int x, int y, int objindex ); +void CHAR_sendCDArroundChar_Main( int fl, int x, int y, int objindex, BOOL mode ); + + +void CHAR_Look( int charaindex, int dir ); + +void CHAR_initChatMagic(void); + +char* CHAR_appendNameAndTitle( int charaindex, char* src, char* buf, + int buflen ); +void CHAR_Talk( int fd, int index,char* message,int color, int area ); + +void CHAR_Loop( void ); + +#define WINDOW_BUTTONTYPE_NONE (0) +#define WINDOW_BUTTONTYPE_OK (1 << 0) +#define WINDOW_BUTTONTYPE_CANCEL (1 << 1) +#define WINDOW_BUTTONTYPE_YES (1 << 2) +#define WINDOW_BUTTONTYPE_NO (1 << 3) +#define WINDOW_BUTTONTYPE_PREV (1 << 4) +#define WINDOW_BUTTONTYPE_NEXT (1 << 5) + +#define WINDOW_BUTTONTYPE_OKCANCEL (WINDOW_BUTTONTYPE_OK | WINDOW_BUTTONTYPE_CANCEL) +#define WINDOW_BUTTONTYPE_YESNO (WINDOW_BUTTONTYPE_YES | WINDOW_BUTTONTYPE_NO) + + +typedef enum +{ + WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT, + WINDOW_MESSAGETYPE_SELECT, + WINDOW_MESSAGETYPE_PETSELECT, + WINDOW_MESSAGETYPE_PARTYSELECT, + WINDOW_MESSAGETYPE_PETANDPARTYSELECT, + WINDOW_MESSAGETYPE_ITEMSHOPMENU, + WINDOW_MESSAGETYPE_ITEMSHOPMAIN, + WINDOW_MESSAGETYPE_LIMITITEMSHOPMAIN, + WINDOW_MESSAGETYPE_PETSKILLSHOP, + WINDOW_MESSAGETYPE_WIDEMESSAGE, + WINDOW_MESSAGETYPE_WIDEMESSAGEANDLINEINPUT, + WINDOW_MESSAGETYPE_POOLITEMSHOPMENU, + WINDOW_MESSAGETYPE_POOLITEMSHOPMAIN, + + WINDOW_MESSAGETYPE_FAMILYADD, + WINDOW_MESSAGETYPE_FAMILYJOIN, + WINDOW_MESSAGETYPE_FAMILYOUT, + WINDOW_MESSAGETYPE_FAMILYEND, +//======================================= + // shan add + WINDOW_FMMESSAGETYPE_SELECT, + WINDOW_FMMESSAGETYPE_DENGON, + WINDOW_FMMESSAGETYPE_FMSDENGON, + WINDOW_FMMESSAGETYPE_POINTLIST, +#ifdef _FMVER21 + WINDOW_FMMESSAGETYPE_TOP30DP, +#endif + WINDOW_FMMESSAGETYPE_DP, + WINDOW_MESSAGETYPE_BANK, + + // Arminius 7.12 scheduleman + WINDOW_MESSAGETYPE_PKSCHEDULELIST, + WINDOW_MESSAGETYPE_PKSCHEDULESELECTFAMILY, + WINDOW_MESSAGETYPE_PKSCHEDULEDETAIL, + + // Robin + WINDOW_MESSAGETYPE_LOGINMESSAGE, + WINDOW_MESSAGETYPE_FAMILYTAX, + WINDOW_MESSAGETYPE_SHOWRIDEPET, + WINDOW_MESSAGETYPE_FAMILYDETAIL, + + WINDOW_MESSAGETYPE_LEADERSELECT, + WINDOW_MESSAGETYPE_LEADERSELECTQ, + WINDOW_MESSAGETYPE_LEADERSELECTA, + + // Arminius 1.3 Auctioneer + WINDOW_MESSAGETYPE_AUCTIONNEW, + WINDOW_MESSAGETYPE_AUCTIONLIST_BUY, + WINDOW_MESSAGETYPE_AUCTIONSURVEY, + WINDOW_MESSAGETYPE_AUCTIONMODIFY, + WINDOW_MESSAGETYPE_AUCTIONLIST_MODIFY, +#ifdef _BLACK_MARKET + WINDOW_MESSAGETYPE_BLACKMARKET, +#endif + +#ifdef _NPC_FUSION + WINDOWS_MESSAGETYPE_PETFUSION, +#endif + +#ifdef _PETSKILL_CANNEDFOOD + WINDOWS_MESSAGETYPE_PETSKILLSHOW, +#endif + +#ifdef _NPC_SELLSTH + WINDOWS_MESSAGETYPE_SELLSTHMENU, + WINDOWS_MESSAGETYPE_SELLSTHVIEW, + WINDOWS_MESSAGETYPE_SELLSTHSELL, +#endif + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + WINDOW_MESSAGETYPE_PROFESSIONSHOP, +#endif +#ifdef _NPC_WELFARE_2 // WON ADD 职业NPC-2 + WINDOW_MESSAGETYPE_PROFESSIONSHOP2, +#endif +#ifdef _NEW_MANOR_LAW + WINDOW_FMMESSAGETYPE_10_MEMONTUM, // 十大气势家族 + WINDOW_FMMESSAGETYPE_FM_MEMONTUM, // 自己家族气势排名 + WINDOW_FMMESSAGETYPE_MANOR_SCHEDULE, // 挑战庄园排行 +#endif + +#ifdef _ANGEL_SUMMON + WINDOW_MESSAGETYPE_ANGELMESSAGE = 101, + WINDOW_MESSAGETYPE_ANGELASK, +#endif + +#ifdef _MOUSE_DBL_CLICK + WINDOW_MESSAGETYPE_MOUSEGETNAME, +#endif + +#ifdef _CONTRACT + WINDOW_MESSAGETYPE_CONTRACT, +#endif + +#ifdef _RACEMAN + WINDOW_MESSAGETYPE_RACEMAN_RANK, +#endif + +}WINDOW_MESSAGETYPE; + +typedef enum +{ + CHAR_WINDOWTYPE_RETURNTOELDER=-1, /* 赢 尺 月它奴件玉它 */ + CHAR_WINDOWTYPE_RESURRECTION=-2, /* 汊唾允月它奴件玉它 */ + + CHAR_WINDOWTYPE_SELECTBATTLE = 1, /* 月爵 毛蓟 允月它奴件玉它 */ + CHAR_WINDOWTYPE_SELECTDUEL = 2, /* 月DUEL毛蓟 允月它奴件玉它 */ + CHAR_WINDOWTYPE_SELECTTRADECARD = 3, /* 铜跟晶毛蓟 允月它奴件玉它 */ + CHAR_WINDOWTYPE_SELECTPARTY = 4, /* 由□ 奴毛蓟 允月它奴件玉它 */ + CHAR_WINDOWTYPE_SELECTBATTLEWATCH = 5, /* 棋爵毛蓟 允月它奴件玉它 */ + CHAR_WINDOWTYPE_MICMESSAGE = 6, /* MICNPC毛银匀化请月它奴件玉它 */ + + // CoolFish: Trade 2001/4/18 + CHAR_WINDOWTYPE_SELECTTRADE = 7, /* 交易 Window */ + + CHAR_WINDOWTYPE_SELECTRENAMEITEM_PAGE1 = 10, /* 蟆毛 凳允月失奶 丞毛蓟 允月它奴件玉它 */ + CHAR_WINDOWTYPE_SELECTRENAMEITEM_PAGE2 = 11, /* 蟆毛 凳允月失奶 丞毛蓟 允月它奴件玉它 */ + CHAR_WINDOWTYPE_SELECTRENAMEITEM_PAGE3 = 12, /* 蟆毛 凳允月失奶 丞毛蓟 允月它奴件玉它 */ + CHAR_WINDOWTYPE_SELECTRENAMEITEM_PAGE4 = 13, /* 蟆毛 凳允月失奶 丞毛蓟 允月它奴件玉它 */ + CHAR_WINDOWTYPE_SELECTRENAMEITEM_RENAME = 14, /* 蟆毛 允月它奴件玉它 */ + CHAR_WINDOWTYPE_SELECTRENAMEITEM_RENAME_ATTENTION = 15, /* 蟆毛 允月它奴件玉它 */ + + CHAR_WINDOWTYPE_DENGON = 50, /* 鳗蜕 */ + + CHAR_WINDOWTYPE_WINDOWMAN_START = 100, + CHAR_WINDOWTYPE_WINDOWMAN_STARTMSG = CHAR_WINDOWTYPE_WINDOWMAN_START, + CHAR_WINDOWTYPE_WINDOWMAN_END = 200, + + CHAR_WINDOWTYPE_JANKEN_START = 210, + CHAR_WINDOWTYPE_JANKEN_MAIN = 211, + CHAR_WINDOWTYPE_JANKEN_END = 212, + + CHAR_WINDOWTYPE_TRANSMIGRATION_START = 213, + CHAR_WINDOWTYPE_TRANSMIGRATION_MAIN = 214, + CHAR_WINDOWTYPE_TRANSMIGRATION_END = 215, + CHAR_WINDOWTYPE_TRANSMIGRATION_NONE = 216, + + + CHAR_WINDOWTYPE_WINDOWHEALER_START = 220, + CHAR_WINDOWTYPE_WINDOWHEALER_STARTMSG = CHAR_WINDOWTYPE_WINDOWHEALER_START, + CHAR_WINDOWTYPE_WINDOWHEALER_HPMSG = 221, + CHAR_WINDOWTYPE_WINDOWHEALER_OKHPMSG = 222, + CHAR_WINDOWTYPE_WINDOWHEALER_SPIRITMSG = 223, + CHAR_WINDOWTYPE_WINDOWHEALER_OKSPIRITMSG = 224, + CHAR_WINDOWTYPE_WINDOWHEALER_ALLMSG = 225, + CHAR_WINDOWTYPE_WINDOWHEALER_OKALLMSG = 226, + CHAR_WINDOWTYPE_WINDOWHEALER_END = 227, + + CHAR_WINDOWTYPE_WINDOWSAVEPOINT_START = 230, + + CHAR_WINDOWTYPE_WINDOWEVENT_STARTMSG = 231, + CHAR_WINDOWTYPE_WINDOWEVENT_NOWEVENT = 232, + CHAR_WINDOWTYPE_WINDOWEVENT_ENDEVENT = 233, + CHAR_WINDOWTYPE_WINDOWEVENT_REQMAINMSG = 234, + CHAR_WINDOWTYPE_WINDOWEVENT_ACCMAINMSG = 235, + CHAR_WINDOWTYPE_WINDOWEVENT_NOMALMSG = 236, + CHAR_WINDOWTYPE_WINDOWEVENT_CLEANMSG = 237, + CHAR_WINDOWTYPE_WINDOWEVENT_REQTHANK = 238, + CHAR_WINDOWTYPE_WINDOWEVENT_ACCTHANK = 239, + + + CHAR_WINDOWTYPE_WINDOWITEMSHOP_START = 240, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_STARTMSG = CHAR_WINDOWTYPE_WINDOWITEMSHOP_START, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_MENU = 241, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_BUY_MSG = 242, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_SELL_MSG = 243, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_END = 244, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_LIMIT = 245, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_EXPRESS = 246, + + CHAR_WINDOWTYPE_DUELRANKING_START = 250, + CHAR_WINDOWTYPE_DUELRANKING_TOPRANKING = 251, + CHAR_WINDOWTYPE_DUELRANKING_MYRANKING = 252, + CHAR_WINDOWTYPE_DUELRANKING_WAIT = 253, + CHAR_WINDOWTYPE_DEFEND_BILLDBOARD = 254, + + CHAR_WINDOWTYPE_WINDOWPETSKILLSHOP = 260, + + CHAR_WINDOWTYPE_WINDOWPETSHOP_START = 261, + CHAR_WINDOWTYPE_WINDOWPETSHOP_PETSELECT = 262, + CHAR_WINDOWTYPE_WINDOWPETSHOP_MAIN = 263, + CHAR_WINDOWTYPE_WINDOWPETSHOP_GOLDOVER = 264, + CHAR_WINDOWTYPE_WINDOWPETSHOP_PETSELECT2 = 265, + CHAR_WINDOWTYPE_WINDOWPETSHOP_MAIN2 = 266, + CHAR_WINDOWTYPE_WINDOWPETSHOP_DRAWSELECT = 267, + CHAR_WINDOWTYPE_WINDOWPETSHOP_ASKDRAW = 268, + CHAR_WINDOWTYPE_WINDOWPETSHOP_END = 269, + + CHAR_WINDOWTYPE_WINDOWWARPMAN_MAIN = 271, + CHAR_WINDOWTYPE_WINDOWWARPMAN_ERR = 272, + CHAR_WINDOWTYPE_WINDOWWARPMAN_END = 273, + + CHAR_WINDOWTYPE_NPCENEMY_START = 281, + + CHAR_WINDOWTYPE_CHARM_START = 282, + CHAR_WINDOWTYPE_CHARM_END = 283, + + CHAR_WINDOWTYPE_QUIZ_START = 284, + CHAR_WINDOWTYPE_QUIZ_MAIN = 285, + CHAR_WINDOWTYPE_QUIZ_END = 286, + + CHAR_WINDOWTYPE_CHECKMAN_START = 287, + CHAR_WINDOWTYPE_CHECKMAN_MAIN = 288, + CHAR_WINDOWTYPE_CHECKMAN_END = 289, + + CHAR_WINDOWTYPE_FAMILYMAN_START = 320, + CHAR_WINDOWTYPE_FAMILYMAN_ADD = 321, + CHAR_WINDOWTYPE_FAMILYMAN_JOIN = 322, + CHAR_WINDOWTYPE_FAMILYMAN_OUT = 323, + CHAR_WINDOWTYPE_FAMILYMAN_BROKEN = 324, + + CHAR_WINDOWTYPE_BANKMAN = 330, + + // CoolFish: FMPKMan 2001/7/4 + CHAR_WINDOWTYPE_FMPKMAN_START = 340, + CHAR_WINDOWTYPE_FMPKMAN_VIEW = 341, + CHAR_WINDOWTYPE_FMPKMAN_LEAVEPK = 342, + CHAR_WINDOWTYPE_FMPKCALLMAN_START = 345, + CHAR_WINDOWTYPE_FMPKCALLMAN_CALL = 346, + CHAR_WINDOWTYPE_FMPKCALLMAN_COME = 347, + CHAR_WINDOWTYPE_FMPKCALLMAN_LEAVE = 348, + + // Arminius 7.13 scheduleman + CHAR_WINDOWTYPE_SCHEDULEMAN_START = 350, + CHAR_WINDOWTYPE_SCHEDULEMAN_SELECT = 351, + CHAR_WINDOWTYPE_SCHEDULEMAN_DETAIL = 352, + + // Arminius 7.27 + CHAR_WINDOWTYPE_MANORPK_START = 360, + CHAR_WINDOWTYPE_MANORPK_ASK = 361, + CHAR_WINDOWTYPE_MANORPK_END = 362, + + // shan + CHAR_WINDOWTYPE_FM_DENGON = 370, // 家族留言板 + CHAR_WINDOWTYPE_FM_FMSDENGON = 371, // 家族之间留言板 + CHAR_WINDOWTYPE_FM_MESSAGE1 = 372, // 说明视窗(据点) + CHAR_WINDOWTYPE_FM_MESSAGE2 = 373, // 说明视窗(成员) + CHAR_WINDOWTYPE_FM_SELECT = 374, // 选项视窗 + CHAR_WINDOWTYPE_FM_MEMBERLIST = 375, // 成员列表 + CHAR_WINDOWTYPE_FM_POINTLIST = 376, // 据点列表 + CHAR_WINDOWTYPE_FM_DPTOP = 377, // 强者表(前叁十大列榜) + CHAR_WINDOWTYPE_FM_DPME = 378, // 强者表(自己的列榜) + CHAR_WINDOWTYPE_FM_DPSELECT = 379, // 强者表的选项视窗 + +// Terry 2001/08/31 +#ifdef _SERVICE + CHAR_WINDOWTYPE_SERVICE_START = 380, // 石器服务员确定视窗 + CHAR_WINDOWTYPE_SERVICE_EXIT = 381, // 石器服务员取消视窗 + CHAR_WINDOWTYPE_SERVICE_CONTINUE = 382, // 石器服务员继续视窗 + CHAR_WINDOWTYPE_SERVICE_WAIT = 383, // 石器服务员等待视窗 +#endif + +#ifdef _PET_TRANS + CHAR_WINDOWTYPE_PETTRANS_START = 384, + CHAR_WINDOWTYPE_PETTRANS_SELECT = 385, + CHAR_WINDOWTYPE_PETTRANS_SELPET = 386, + CHAR_WINDOWTYPE_PETTRANS_MAIN1 = 387, + CHAR_WINDOWTYPE_PETTRANS_END = 389, +#endif + +#ifdef _GAMBLE_BANK + NPC_GambleBank_START = 390, + NPC_GambleBank_SELECT, + NPC_GambleBank_BANK, + NPC_GambleBank_CHANG1, + NPC_GambleBank_CHANG2, + NPC_GambleBank_END, +#endif + +#ifdef _PETRACE + CHAR_WINDOWTYPE_PETRACEMASTER_START = 410, + CHAR_WINDOWTYPE_PETRACEMASTER_RULE, + CHAR_WINDOWTYPE_PETRACEMASTER_PET, + CHAR_WINDOWTYPE_PETRACEMASTER_LEAVE, +#endif + +#ifdef _GAMBLE_ROULETTE + WINDOWTYPE_GAMBLEROULETTE_START = 415, + WINDOWTYPE_GAMBLEROULETTE_SELECT, + WINDOWTYPE_GAMBLEROULETTE_END, +#endif + +#ifdef _AUCTIONEER + CHAR_WINDOWTYPE_AUCTIONEER_START = 420, + CHAR_WINDOWTYPE_AUCTIONEER_NEW, + CHAR_WINDOWTYPE_AUCTIONEER_LIST_BUY, + CHAR_WINDOWTYPE_AUCTIONEER_SURVEY, + CHAR_WINDOWTYPE_AUCTIONEER_MODIFY, + CHAR_WINDOWTYPE_AUCTIONEER_LIST_MODIFY, + CHAR_WINDOWTYPE_AUCTIONEER_END, +#endif + +#ifdef _NEWEVENT + CHAR_WINDOWTYPE_WINDOWEVENT_ACCTHANKNEW = 430, +#endif + +#ifdef _BLACK_MARKET + CHAR_WINDOWTYPE_BLACKMARKET = 435, +#endif + +#ifdef _TRANSER_MAN + NPC_TRANSERMAN_START = 440, + NPC_TRANSERMAN_SELECT, + NPC_TRANSERMAN_WARP, + NPC_TRANSERMAN_END, +#endif +#ifdef _ITEM_NPCCHANGE + NPC_ITEMCHANGE_START = 445, + NPC_ITEMCHANGE_SELECT, + NPC_ITEMCHANGE_MESSAGE, + NPC_ITEMCHANGE_END, +#endif + +#ifdef _PAUCTION_MAN + NPC_PAUCTION_START, + NPC_PAUCTION_SELECT, + NPC_PAUCTION_BUY, + NPC_PAUCTION_SELL, + NPC_PAUCTION_WARP, + NPC_PAUCTION_END, +#endif +#ifdef _ALLDOMAN // (不可开) Syu ADD 排行榜NPC + NPC_ALLDOMAN_START = 460, + NPC_ALLDOMAN_START2, + NPC_ALLDOMAN_START3, + NPC_ALLDOMAN_HEAL, + NPC_ALLDOMAN_GIVEMONEY, + NPC_ALLDOMAN_MAIN_WND , + NPC_ALLDOMAN_SELECT_WND , + NPC_ALLDOMAN_LIST_WND , +#endif + +#ifdef _PETSKILL_CANNEDFOOD + ITEM_WINDOWTYPE_SELECTPETSKILL_SELECT = 470, + ITEM_WINDOWTYPE_SELECTPETSKILL_END, +#endif + +#ifdef _NPC_WELFARE + NPC_WELFARE_START = 480, + NPC_WELFARE_END, +#endif + +#ifdef _NPC_VERYWELFARE + NPC_VERYWELFARE_START = 490, + NPC_VERYWELFARE_NO1, + NPC_VERYWELFARE_NO2, + NPC_VERYWELFARE_NO3, + NPC_VERYWELFARE_END, +#endif + +#ifdef _NPC_WELFARE_2 // WON ADD 职业NPC-2 + NPC_WELFARE_START2 = 495, + NPC_WELFARE_END2, +#endif + +#ifdef _NPC_DEPOTPET + CHAR_WINDOWTYPE_DEPOTPETSHOP_MENU = 510, + CHAR_WINDOWTYPE_DEPOTPETSHOP_HANDLE, + CHAR_WINDOWTYPE_DEPOTPETSHOP_ADD, + CHAR_WINDOWTYPE_DEPOTPETSHOP_GET, + CHAR_WINDOWTYPE_DEPOTPETSHOP_ASKADD, + CHAR_WINDOWTYPE_DEPOTPETSHOP_ASKGET, +#endif + +#ifdef _ANGEL_SUMMON + CHAR_WINDOWTYPE_ANGEL_ASK = 520, + CHAR_WINDOWTYPE_ANGEL_CLEAN, +#endif + +#ifdef _CONTRACT + CHAR_WINDOWTYPE_CONTRACT_ANSWER = 530, +#endif + +#ifdef _RACEMAN //猎宠大会 + CHAR_WINDOWTYPE_RACE_START = 540, // 开始 + CHAR_WINDOWTYPE_RACE_SUBJECT, // 猎宠比赛题目 + CHAR_WINDOWTYPE_RACE_TICKET, // 领取猎宠证 + CHAR_WINDOWTYPE_RACE_PETSELECT, // 宠物选择 + CHAR_WINDOWTYPE_RACE_CHECKIN, // 猎宠登记 + CHAR_WINDOWTYPE_RACE_RANK, // 猎宠排行榜 + CHAR_WINDOWTYPE_RACE_PRIZE, // 兑奖 + CHAR_WINDOWTYPE_RACE_NORMAL, // 无标题视窗 + CHAR_WINDOWTYPE_RACE_SHOWRANK1, // 新手排行榜 + CHAR_WINDOWTYPE_RACE_SHOWRANK2, // 排行榜 + CHAR_WINDOWTYPE_RACE_SHOWRANK3, // 排行榜 + CHAR_WINDOWTYPE_RACE_SHOWRANK4, // 排行榜 + CHAR_WINDOWTYPE_RACE_SHOWRANK5, // 排行榜 + CHAR_WINDOWTYPE_RACE_SHOWRANK11, // 显示历史记录 + CHAR_WINDOWTYPE_RACE_SHOWRANK12, // 显示历史记录 + CHAR_WINDOWTYPE_RACE_SHOWRANK13, // 显示历史记录 + CHAR_WINDOWTYPE_RACE_SHOWRANK14, // 显示历史记录 + CHAR_WINDOWTYPE_RACE_SHOWRANK15, // 显示历史记录 + CHAR_WINDOWTYPE_RACE_QUIZ, // 通关密语 +#endif + +}CHAR_WINDOWTYPE; + +#ifdef _GMRELOAD +typedef struct tagGMInfo +{ + char cdkey[24]; + int level; +}GMInfo; +#endif + + +#ifdef _ANGEL_SUMMON + +#define MAXMISSION 100 +#define MAXMISSIONTABLE 1000 + +struct MissionInfo +{ + int id; + char detail[1024]; + int level; + char eventflag[1024]; + //char bonus[1024]; + int limittime; +}; + +struct MissionTable +{ + char angelinfo[128]; + char heroinfo[128]; + int mission; + int flag; + int time; + int limittime; +}; + +extern struct MissionInfo missionlist[MAXMISSION]; +extern struct MissionTable missiontable[MAXMISSIONTABLE]; + +#endif + +#ifdef _JOBDAILY + +#define MAXDAILYLIST 1000 +#define MAXMISSIONFLAG 1000 +typedef struct _DailyFileType +{ + char jobid[10]; //任务编号 + char rule[16384]; //条件判断 + char explain[200]; //任务说明 + char state[20]; //状态说明 +}DailyFileType; +//extern struct DailyFileType dailyfile[MAXDAILYLIST]; + +#endif + +BOOL CHAR_talkToCli( int talkedcharaindex,int talkcharaindex, char* message, CHAR_COLOR color ); +void CHAR_talkToCliAndParty( int talkedcharaindex,int talkcharaindex,char* message, CHAR_COLOR color ); + +BOOL CHAR_talkToCharacter( int talkedcharaindex,int talkcharaindex, char* message ); +void CHAR_getCoordinationDir( int dir , int x, int y ,int c, + int *xout , int *yout ); +BOOL CHAR_createCharacter( int type, int floor, int x, int y, int dir, + int* charaindex, int* objindex, BOOL seemap ); +void CHAR_CharaDelete( int charaindex ); +void CHAR_ObjectDelete( int objindex ); +int CHAR_makeDBKey( int charaindex, char *pszBuffer, int size ); +int CHAR_getEmptyPartyArray( int charaindex); +BOOL CHAR_JoinParty( int charaindex ); +void CHAR_JoinParty_Main( int charaindex, int targetindex); +BOOL CHAR_DischargeParty( int charaindex, int flg); +BOOL CHAR_DischargePartyNoMsg( int charaindex); +BOOL CHAR_setMyPosition_main( int index, int x, int y, int setdir, BOOL CAFlg); +BOOL CHAR_setMyPosition( int index, int x, int y, BOOL CAFlg); + +void CHAR_CharaDeleteHavePet( int charaindex); +int CHAR_sendAction( int charaindex, int action, int mode); +void CHAR_sendLeader( int objindex, int leader); +void CHAR_sendBattleWatch( int objindex, int onoff); +void CHAR_sendBattleEffect( int charaindex, int onoff); + +// shan +void CHAR_sendTradeEffect( int charaindex, int onoff); +#ifdef _MIND_ICON +void CHAR_sendMindEffect( int charaindex, int onoff); +#endif +#ifdef _ITEM_CRACKER +void CHAR_sendCrackerEffect( int charaindex, int onoff); +#endif + +void CHAR_inputUserPetName( int index , int havepetindex, char* name ); +int CHAR_getPartyIndex( int index, int num); +void CHAR_processWindow(int charaindex, int seqno, int select, + int objindex, char* data ); +void CHAR_AddCharm( int charaindex, int iValue ); +void CHAR_PetAddVariableAi( int petindex, int iValue ); +void CHAR_PartyUpdate( int charaindex, int senddata ); +char *CHAR_getUseName( int charaindex ); +char *CHAR_getUseID( int charaindex ); +EXTERN int EnemyMoveNum; /* 凛卞 嫖 仃月衬及醒 */ +extern char *DebugFunctionName; +extern int DebugPoint; + +#define DB_DUELPOINT "db_duel" // 犯亘巨伙禾奶件玄犯□正矛□旦 +#define DB_ADDRESSBOOK "db_addressbook" // 失玉伊旦皮永弁犯□正矛□旦 + +BOOL CHAR_send_DpDBUpdate( int charaindex ); +BOOL CHAR_send_DpDBUpdate_AddressBook( int charaindex, int mode ); + + +void CHAR_sendPMEToArroundCharacter( int charaindex, int petindex, int flg, int no ); +void CHAR_sendPMEToArroundCharacterFLXY( int petindex, + int fl, int x, int y, int dir, int flg, int no ); + +void CHAR_sendSEoArroundCharacter( int fl, int x, int y, int senumber, int sw ); + +BOOL CHAR_initEffectSetting( char* filename ); +void CHAR_checkEffect( int charaindex); +void CHAR_checkEffectLoop( void); +void CHAR_initDebugChatCdkey( void); +int CHAR_setChatMagicCDKey( int mode, char *cdkey); + + +float GetRecoveryRate( int charaindex ); +int storeCharaData( void ); +#ifdef _MAGIC_REHPAI //补血AI +int Magic_RideGetHP( int toindex, int petindex, int flg); +#endif +// CoolFish: Trade 2001/4/18 +int CHAR_findTotalEmptyItem(int index); + + +#ifdef _FIX_METAMORIDE +int CHAR_CHECKJOINENEMY( int index); +#endif + +#ifdef _NPCSERVER_NEW +BOOL NPCSERVER_CreateObjindexFromServer( int fd, int npcindex, char *Name, int image, + int dir, int floor, int x, int y); +#endif + + +#ifdef _SEND_EFFECT // WON ADD AC送下雪、下雨等特效 +#define CHAR_EFFECT_SETTINGBUFFER 256 +typedef struct tagCHAR_effectsetting +{ + int floor; // 白夫失 + int effect; // 梢请 寞 + int level; // 梢请及伊矛伙[ 蜇及雄今[ + int sendflg; // 憎巨白尼弁玄毛霜匀凶井升丹井[ + char month[CHAR_EFFECT_SETTINGBUFFER]; // 垫允月畸 + char day[CHAR_EFFECT_SETTINGBUFFER]; // 垫允月 + char hour[CHAR_EFFECT_SETTINGBUFFER]; // 垫允月凛棉 + char min[CHAR_EFFECT_SETTINGBUFFER]; // 垫允月坌 + char expire[CHAR_EFFECT_SETTINGBUFFER]; // 垫仄化中月赢今[( + +}CHAR_effectsetting; + +CHAR_effectsetting* CHAR_effect; +int CHAR_effectnum; +#endif + +#ifdef _ITEM_PILENUMS +int CHAR_getMyMaxPilenum( int charaindex); +#endif + +#ifdef _PET_LOSTPET +BOOL CHAR_CharSaveLostPet( int petindex, int type); +#endif +#ifdef _ALLDOMAN +void InitHeroList( void); +#endif +#endif + +#ifdef _STREET_VENDOR +void CHAR_sendStreetVendor(int charaindex,char *message); +void CHAR_sendStreetVendorDataToCli(int charaindex,int toindex); +void CHAR_sendStreetVendorOneDataToCli(int charaindex,int toindex,int sendindex); +#endif + +BOOL checkUnlawWarpFloor( int floor); + +#ifdef _HELP_NEWHAND +void CHAR_loginAddItemForNew( int charaindex ); +#endif + +#ifdef _JOBDAILY +void CHAR_JobDaily(int charaindex,char *data); +#endif + +#ifdef _TEACHER_SYSTEM +void CHAR_Teacher_system(int charaindex,char *data); +void CHAR_Teacher_system_View(int charaindex,int iOnLine,char *data); +#endif + +#ifdef _TIME_TICKET +void check_TimeTicket(); +int check_TimeTicketMap(int floor); +#endif + diff --git a/gmsv/include/char_base.h b/gmsv/include/char_base.h new file mode 100644 index 0000000..38a8a4d --- /dev/null +++ b/gmsv/include/char_base.h @@ -0,0 +1,1783 @@ +#ifndef __CHAR_BASE_H__ +#define __CHAR_BASE_H__ + +#include "version.h" +#include "skill.h" +#include "title.h" +/*#include "magicinfo.h"*/ +#include "addressbook.h" + +#define CHAR_DELIMITER "\n" + +#define NONCHAR_DELIMITER "|" + +#define STATUSSENDDELIMITER "|" + +#define CHAR_MAXGOLDHAVE (100*10000) +#define CHAR_MAXBANKGOLDHAVE (1000*10000) +#define CHAR_MAXFMBANKGOLDHAVE (10000*10000) + +#ifdef _NEW_MANOR_LAW +#define MAX_PERSONAL_MOMENTUM 10000000 +#endif +#ifdef _PERSONAL_FAME // Arminius 8.30: 家族个人声望 +#define MAX_PERSONALFAME 100000000 +#endif +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 +#define CHAR_SKILLMAXHAVE 26 // 职业技能上限 +#else +#define CHAR_SKILLMAXHAVE 5 +#endif + +#ifdef _STREET_VENDOR +#define MAX_SELL_ITEM 20 // 道具加宠物共可卖二十个 +#endif +#define CHAR_TITLEMAXHAVE 30 + +#define NULLSKILL "0" + +#define CHAR_MAXPETHAVE 5 +#define CHAR_MAXPERSONAGOLD 50000000 + +#ifdef _ADD_POOL_ITEM // WON ADD 增加可寄放的道具 +#define CHAR_MAXPOOLPETHAVE 15 +#else +#define CHAR_MAXPOOLPETHAVE 10 +#endif + +#define CHAR_MAXPETSKILLHAVE 7 +#define CHAR_PARTYMAX 5 +#define CHAR_MAXATTRIB 100 +#define CHAR_MAXUPLEVEL 200 +#define CHAR_MAXDUELPOINT 100000000 +#define CHAR_DEFAULTMAXAI (60) +#define CHAR_MAXVARIABLEAI (100*100) +#define CHAR_MINVARIABLEAI (-100*100) +#define CHAR_POISONSTRING "中毒" +#define CHAR_RECOVERPOISONSTRING "解毒了" +#define CHAR_PARALYSISSTRING "麻痹了" +#define CHAR_RECOVERPARALYSISSTRING "麻醉退了" +#define CHAR_SILENCESTRING "无法念魔法了" +#define CHAR_RECOVERSILENCESTRING "可以念魔法了" +#define CHAR_STONESTRING "石化了" +#define CHAR_RECOVERSTONESTRING "变灵活了" +#define CHAR_DARKNESSSTRING "四周不见了" +#define CHAR_RECOVERDARKNESSSTRING "四周出现了" +#define CHAR_CONFUSIONSTRING "陷入恐慌" +#define CHAR_RECOVERCONFUSIONSTRING "恢复正常" + +#define CHAR_DEFAULTSEESIZ 23 +#define MAP_CHAR_DEFAULTSEESIZ (CHAR_DEFAULTSEESIZ+4) + +typedef enum +{ + CHAR_HEAD, + CHAR_BODY, + CHAR_ARM, + CHAR_DECORATION1, + CHAR_DECORATION2, +#ifdef _ITEM_EQUITSPACE + CHAR_EQBELT, //腰带 + CHAR_EQSHIELD, //盾 + CHAR_EQSHOES, //鞋子 +#endif +#ifdef _EQUIT_NEWGLOVE + CHAR_EQGLOVE, +#endif + CHAR_EQUIPPLACENUM, +}CHAR_EquipPlace; + +typedef struct tagCharHaveSkill +{ + int use; + Skill skill; +}CHAR_HaveSkill; + +#ifdef _STREET_VENDOR +typedef struct STREET_VENDDOR_t{ + int pile; // 数量 + int price; // 价格 + int index; // 索引 + int kind; // 道具或是宠物 0:道具 1:宠物 + BOOL usage; // 是否使用中 +}StreetVendor_t; + +enum{ + SV_PILE, + SV_PRICE, + SV_INDEX, + SV_KIND, + SV_USAGE, + MAX_SV +}; +#endif + +typedef enum +{ + CHAR_ACTSTAND, + CHAR_ACTWALK, + CHAR_ACTATTACK, + CHAR_ACTTHROW, + CHAR_ACTDAMAGE, + CHAR_ACTDEAD, + CHAR_ACTMAGIC, + CHAR_ACTITEM, + CHAR_ACTEFFECT, + CHAR_ACTDOWN = 10, + CHAR_ACTSIT, + CHAR_ACTHAND, + CHAR_ACTPLEASURE, + CHAR_ACTANGRY, + CHAR_ACTSAD, + CHAR_ACTGUARD, + CHAR_ACTACTIONWALK, + CHAR_ACTNOD, + CHAR_ACTACTIONSTAND, + CHAR_ACTBATTLE = 20, + CHAR_ACTLEADER, + CHAR_ACTBATTLEWATCH, + CHAR_ACTPOPUPNAME, + CHAR_ACTTURN = 30, + CHAR_ACTWARP, + CHAR_ACTTRADE, +#ifdef _ANGEL_SUMMON + CHAR_ACTANGEL = 34, +#endif + +#ifdef _MIND_ICON + CHAR_MIND = 40, +#endif +#ifdef _STREET_VENDOR + CHAR_STREETVENDOR_OPEN, + CHAR_STREETVENDOR_CLOSE, +#endif +#ifdef _ITEM_CRACKER + CHAR_ITEM_CRACKER = 50, +#endif +}CHAR_ACTION; + +typedef enum +{ + CHAR_CLIACTATTACK, + CHAR_CLIACTDAMAGE, + CHAR_CLIACTDOWN, + CHAR_CLIACTSTAND, + CHAR_CLIACTWALK, + CHAR_CLIACTSIT, + CHAR_CLIACTHAND, + CHAR_CLIACTPLEASURE, + CHAR_CLIACTANGRY, + CHAR_CLIACTSAD, + CHAR_CLIACTGUARD, + CHAR_CLIACTNOD, + CHAR_CLIACTTHROW, + +}CHAR_CLIENTACTION; + +typedef enum +{ + CHAR_TYPENONE, + CHAR_TYPEPLAYER, + CHAR_TYPEENEMY, + CHAR_TYPEPET, + CHAR_TYPEDOOR, + CHAR_TYPEBOX, + CHAR_TYPEMSG, + CHAR_TYPEWARP, + CHAR_TYPESHOP, + CHAR_TYPEHEALER, + CHAR_TYPEOLDMAN, + CHAR_TYPEROOMADMIN, + CHAR_TYPETOWNPEOPLE, + CHAR_TYPEDENGON, + CHAR_TYPEADM, + CHAR_TYPETEMPLE, + CHAR_TYPESTORYTELLER, + CHAR_TYPERANKING, + CHAR_TYPEOTHERNPC, + CHAR_TYPEPRINTPASSMAN, + CHAR_TYPENPCENEMY, + CHAR_TYPEACTION, + CHAR_TYPEWINDOWMAN, + CHAR_TYPESAVEPOINT, + CHAR_TYPEWINDOWHEALER, + CHAR_TYPEITEMSHOP, + CHAR_TYPESTONESHOP, + CHAR_TYPEDUELRANKING, + CHAR_TYPEWARPMAN, + CHAR_TYPEEVENT, + CHAR_TYPEMIC, + CHAR_TYPELUCKYMAN, + CHAR_TYPEBUS, + CHAR_TYPECHARM, + CHAR_TYPECHECKMAN, + CHAR_TYPEJANKEN, + CHAR_TYPETRANSMIGRATION, + CHAR_TYPEFMWARPMAN, // 家族PK场管理员 + CHAR_TYPEFMSCHEDULEMAN, // 家族PK场登记员 + CHAR_TYPEMANORSCHEDULEMAN, // 庄园PK场预约人 +#ifdef _SERVICE + CHAR_TYPESTONESERVICEMAN, // 石器服务员 +#endif +#ifdef _GAMBLE_BANK + CHAR_GAMBLEBANK, +#endif +#ifdef _NEW_WARPMAN + CHAR_NEWNPCMAN, +#endif +#ifdef _MARKET_TRADE + CHAR_MAPTRADEMAN, +#endif +#ifdef _GAMBLE_ROULETTE + CHAR_GAMBLEROULETTE, + CHAR_GAMBLEMASTER, +#endif +#ifdef _TRANSER_MAN + CHAR_TRANSERMANS, +#endif + +#ifdef _NPC_SELLSTH + CHAR_SELLSTHMAN, +#endif + +#ifdef _NPC_MAKEPAIR + CHAR_MAKEPAIR, +#endif +#ifdef _NPC_FUSION + CHAR_PETFUSIONMAN, +#endif +#ifdef _PAUCTION_MAN + CHAR_PAUCTIONMAN, +#endif +#ifdef _ITEM_NPCCHANGE + CHAR_ITEMCHANGENPC, +#endif +#ifdef _CFREE_petskill + CHAR_FREESKILLSHOP, +#endif +#ifdef _PETRACE + CHAR_PETRACEMASTER, // 宠物竞速 + CHAR_PETRACEPET, +#endif + +#ifdef _AUCTIONEER + CHAR_TYPEAUCTIONEER, +#endif + +#ifdef _ALLDOMAN // (不可开) Syu ADD 排行榜NPC + CHAR_TYPEALLDOMAN, +#endif + + CHAR_TYPEPETMAKER, // petmaker + +#ifdef _NPC_WELFARE + CHAR_TYPEWELFARE, +#endif + +#ifdef _NPC_VERYWELFARE + CHAR_TYPEVERYWELFARE, +#endif + +#ifdef _NPC_WELFARE_2 // WON ADD 职业NPC-2 + CHAR_TYPEWELFARE2, +#endif + +#ifdef _RACEMAN + CHAR_RACEMAN, // CYG 猎宠大会 +#endif + + CHAR_TYPENUM, +}CHAR_TYPE; + +typedef enum +{ + CHAR_EVENT_NONE, + CHAR_EVENT_NPC, + CHAR_EVENT_ENEMY, + CHAR_EVENT_WARP, + CHAR_EVENT_DOOR, + CHAR_EVENT_ALTERRATIVE, + CHAR_EVENT_WARP_MORNING, + CHAR_EVENT_WARP_NOON, + CHAR_EVENT_WARP_NIGHT, + CHAR_EVENTNUM, +}CHAR_EVENT; + +typedef enum +{ + CHAR_PARTY_NONE, + CHAR_PARTY_LEADER, + CHAR_PARTY_CLIENT, +}CHAR_PARTY_MODE; + +typedef enum +{ + CHAR_TRADE_FREE, /* 可交易 */ + CHAR_TRADE_SENDING, /* 交易请求中 */ + CHAR_TRADE_TRADING, /* 交易中 */ + CHAR_TRADE_LOCK, /* 交易锁定中 */ +}CHAR_TRADE_MODE; + +typedef enum +{ + CHAR_PETMAIL_NONE, + CHAR_PETMAIL_IDLE1, + CHAR_PETMAIL_IDLE2, + CHAR_PETMAIL_RETURNWAIT, + CHAR_PETMAIL_IDLE3, + CHAR_PETMAIL_IDLE4, + CHAR_PETMAIL_IDLE5, +}CHAR_PETMAIL_MODE; + +typedef enum +{ + CHAR_PETFOLLOW_NONE, + CHAR_PETFOLLOW_NOW, +}CHAR_PETFOLLOW_MODE; + +#ifdef _DROPSTAKENEW +typedef enum +{ + DICE_BIG = 1, // 骰子_大 + DICE_SMALL, // 骰子_小 + DICE_ALLEAT, // 骰子_通吃 + PET_RACE1 = 5, // 竞速场_宠物1 + PET_RACE2, // 竞速场_宠物2 + PET_RACE3, // 竞速场_宠物3 + ROULETTE1 = 11, ROULETTE2, ROULETTE3, ROULETTE4, ROULETTE5, ROULETTE6, ROULETTE7, + ROULETTE8, ROULETTE9, ROULETTE10, ROULETTE11, ROULETTE12, ROULETTE13, ROULETTE14, + ROULETTE15, ROULETTE16, ROULETTE17, ROULETTE18, ROULETTE19, ROULETTE20, + ROULETTE21 = 41, ROULETTE22, ROULETTE23, ROULETTE24, ROULETTE25, ROULETTE26, + ROULETTE27, ROULETTE28, ROULETTE29, ROULETTE30, ROULETTE31, ROULETTE32, + ROULETTE33, ROULETTE34, ROULETTE35, ROULETTE36, ROULETTE37, ROULETTE38, + ROULETTE39, ROULETTE40, + ROULETTE41 = 71, ROULETTE42, ROULETTE43, ROULETTE44, ROULETTE45, + ROULETTE51 = 101, ROULETTE52, ROULETTE53, //横列 + ROULETTE61 = 111, ROULETTE62, //1到10 10到11 + PETFIGHT_WIN1 = 120, + PETFIGHT_WIN2, + PETFIGHT_DUEL, +}GAMBLE_TYPE; +#endif + +#ifdef _CHAR_POOLITEM +#ifdef _NPC_DEPOTPET // 开放宠物仓库同时增加道具仓库容量 +#define CHAR_MAXDEPOTITEMHAVE 100 +#else +#define CHAR_MAXDEPOTITEMHAVE 60 +#endif +#endif + +#ifdef _CHAR_POOLPET +#define CHAR_MAXDEPOTPETHAVE 30 +#endif + + +#ifdef _ADD_POOL_ITEM // (不可开) WON ADD 增加可寄放的道具 +#define CHAR_MAXPOOLITEMHAVE 30 +#else +#define CHAR_MAXPOOLITEMHAVE 20 +#endif + +#define CHAR_MAXITEMNUM 15 +#define CHAR_STARTITEMARRAY CHAR_EQUIPPLACENUM +#define CHAR_MAXITEMHAVE (CHAR_STARTITEMARRAY+CHAR_MAXITEMNUM) + +typedef enum +{ + CHAR_DATAPLACENUMBER, + CHAR_BASEIMAGENUMBER, + CHAR_BASEBASEIMAGENUMBER, + CHAR_FACEIMAGENUMBER, + CHAR_FLOOR, + CHAR_X, + CHAR_Y, + CHAR_DIR, + CHAR_LV, + CHAR_GOLD, + CHAR_HP, + CHAR_MP, + CHAR_MAXMP, + CHAR_VITAL, + CHAR_STR, + CHAR_TOUGH, + CHAR_DEX, + CHAR_CHARM, + CHAR_LUCK, + CHAR_EARTHAT, + CHAR_WATERAT, + CHAR_FIREAT, + CHAR_WINDAT, + CHAR_DEFAULTPET, + CHAR_CRITIAL, + CHAR_COUNTER, + CHAR_RARE, + CHAR_RADARSTRENGTH, + CHAR_CHATVOLUME, + CHAR_MERCHANTLEVEL, + CHAR_HEALERLEVEL, + CHAR_SAVEPOINT = CHAR_HEALERLEVEL, + CHAR_DETERMINEITEM, + CHAR_INDEXOFEQTITLE, + CHAR_POISON, + CHAR_PARALYSIS, + CHAR_SLEEP, + CHAR_STONE, + CHAR_DRUNK, + CHAR_CONFUSION, + CHAR_LOGINCOUNT, + CHAR_NPCCREATEINDEX=CHAR_LOGINCOUNT, + CHAR_DEADCOUNT, + CHAR_WALKCOUNT, + CHAR_TALKCOUNT, + CHAR_DAMAGECOUNT, + CHAR_GETPETCOUNT, + CHAR_KILLPETCOUNT, + CHAR_DEADPETCOUNT, + CHAR_SENDMAILCOUNT, + CHAR_MERGEITEMCOUNT, + CHAR_DUELBATTLECOUNT, + CHAR_DUELWINCOUNT, + CHAR_DUELLOSECOUNT, + CHAR_DUELSTWINCOUNT, + CHAR_DUELMAXSTWINCOUNT, + CHAR_WHICHTYPE, + CHAR_WALKINTERVAL, + CHAR_LOOPINTERVAL, +#ifdef _NEWOPEN_MAXEXP + CHAR_OLDEXP, + CHAR_EXP, +#else + CHAR_EXP, +#endif + CHAR_LASTTALKELDER, + CHAR_SKILLUPPOINT, + CHAR_LEVELUPPOINT, + CHAR_IMAGETYPE, + CHAR_NAMECOLOR, + CHAR_POPUPNAMECOLOR, + CHAR_LASTTIMESETLUCK, + CHAR_DUELPOINT, + CHAR_ENDEVENT, /* (0~31) */ + CHAR_ENDEVENT2, /* (32~63) */ + CHAR_ENDEVENT3, /* (64~96) */ +#ifdef _NEWEVENT + CHAR_ENDEVENT4, /* (96~127) */ + CHAR_ENDEVENT5, /* (128~159) */ + CHAR_ENDEVENT6, /* (160~191) */ +#endif +#ifdef _ADD_NEWEVENT // WON 多增任务旗标 + CHAR_ENDEVENT7, + CHAR_ENDEVENT8, +#endif + + CHAR_NOWEVENT, /* (0~31) */ + CHAR_NOWEVENT2, /* (32~63) */ + CHAR_NOWEVENT3, /* (64~96) */ +#ifdef _NEWEVENT + CHAR_NOWEVENT4, /* (96~127) */ + CHAR_NOWEVENT5, /* (128~159) */ + CHAR_NOWEVENT6, /* (160~191) */ +#endif +#ifdef _ADD_NEWEVENT // WON 多增任务旗标 + CHAR_NOWEVENT7, + CHAR_NOWEVENT8, // 224~255 精灵召唤专用 +#endif + + CHAR_TRANSMIGRATION, + CHAR_TRANSEQUATION, + CHAR_INITDATA, + CHAR_SILENT, /* char shutup time */ + CHAR_FMINDEX, // 家族 index + CHAR_FMLEADERFLAG, /* 家族成员种类 + * FMMEMBER_NONE :没有加入任何家族 + * FMMEMBER_APPLY :申请加入家族中 + * FMMEMBER_LEADER :族长 + * FMMEMBER_MEMBER :一般成员 + * FMMEMBER_ELDER :长老 + * FMMEMBER_INVITE :祭司 // 暂时不用 + * FMMEMBER_BAILEE :财务长 // 暂时不用 + * FMMEMBER_VICELEADER :副族长 // 暂时不用 + */ + CHAR_FMSPRITE, // 家族守护精灵 + + CHAR_BANKGOLD, + CHAR_RIDEPET, + CHAR_LEARNRIDE, +#ifdef _NEW_RIDEPETS + CHAR_LOWRIDEPETS, +#endif + CHAR_LIMITLEVEL, +#ifdef _PET_FUSION + CHAR_FUSIONCODE, //物种编码 + CHAR_FUSIONINDEX, //孵化宠物编号 + CHAR_FUSIONRAISE, // 养次数 + CHAR_FUSIONBEIT, //宠蛋旗标 + CHAR_FUSIONTIMELIMIT, // 养时间 +#endif + +#ifdef _DEATH_CONTEND + CHAR_PKLISTTEAMNUM, + CHAR_PKLISTLEADER, +#endif + +#ifdef _PERSONAL_FAME // Arminius 8.30: 家族个人声望 + CHAR_FAME, +#endif + +#ifdef _NEWSAVE + CHAR_SAVEINDEXNUMBER, /* SaveFile .0.char or .1.char */ +#endif + +#ifdef __ATTACK_MAGIC + CHAR_EARTH_EXP, // 玩家的地魔法熟练度 + CHAR_WATER_EXP, // 玩家的水魔法熟练度 + CHAR_FIRE_EXP, // 玩家的火魔法熟练度 + CHAR_WIND_EXP, // 玩家的风魔法熟练度 + CHAR_EARTH_RESIST, // 玩家的地魔法抗性 + CHAR_WATER_RESIST, // 玩家的水魔法抗性 + CHAR_FIRE_RESIST, // 玩家的火魔法抗性 + CHAR_WIND_RESIST, // 玩家的风魔法抗性 + CHAR_EARTH_ATTMAGIC_EXP, // 玩家的地魔法熟练度经验值 + CHAR_WATER_ATTMAGIC_EXP, // 玩家的水魔法熟练度经验值 + CHAR_FIRE_ATTMAGIC_EXP, // 玩家的火魔法熟练度经验值 + CHAR_WIND_ATTMAGIC_EXP, // 玩家的风魔法熟练度经验值 + CHAR_EARTH_DEFMAGIC_EXP, // 玩家的地魔法抗性经验值 + CHAR_WATER_DEFMAGIC_EXP, // 玩家的水魔法抗性经验值 + CHAR_FIRE_DEFMAGIC_EXP, // 玩家的火魔法抗性经验值 + CHAR_WIND_DEFMAGIC_EXP, // 玩家的风魔法抗性经验值 +#endif + + +#ifdef _GAMBLE_BANK + CHAR_PERSONAGOLD, //赌场个人银行 +#endif +#ifdef _DROPSTAKENEW + CHAR_GAMBLENUM, //赌场积分 +#endif +#ifdef _ADD_ACTION //npc动作 + CHAR_ACTIONSTYLE, +#endif +#ifdef _AUCTIONEER + CHAR_AUCGOLD, // 拍卖所得 +#endif +#ifdef _PET_EVOLUTION + CHAR_EVOLUTIONBASEVTL, + CHAR_EVOLUTIONBASESTR, + CHAR_EVOLUTIONBASETGH, + CHAR_EVOLUTIONBASEDEX, +#endif +#ifdef _ACTION_BULLSCR + CHAR_ABULLSTART, + CHAR_ABULLSCORE, + CHAR_ABULLTIME, + CHAR_ABULLSTARTTIME, +#endif + +#ifdef _ACTION_GMQUE + CHAR_GMQUEFLG, + CHAR_GMQUENUMS, +#endif + +#ifdef _FAMILYBANKSTONELOG + CHAR_FMBANKGOLD, //家族银行存款 +#endif + +#ifdef _FM_JOINLIMIT + CHAR_FMTIMELIMIT, +#endif + +#ifdef _CHAR_PROFESSION // WON ADD 人物职业 + PROFESSION_CLASS, // 职业别 + PROFESSION_LEVEL, // 职业等级 +// PROFESSION_EXP, // 职业经验值 + PROFESSION_SKILL_POINT, // 技能点数 + ATTACHPILE, // 增加堆叠 + PROFESSION_FIRE_P, // 火熟练度 + PROFESSION_ICE_P, // 冰熟练度 + PROFESSION_THUNDER_P, // 雷熟练度 + PROFESSION_FIRE_R, // 火抗性 + PROFESSION_ICE_R, // 冰抗性 + PROFESSION_THUNDER_R, // 雷抗性 +#endif +#ifdef _ALLDOMAN // (不可开) Syu ADD 排行榜NPC + CHAR_HEROFLOOR, +#endif +#ifdef _PETSKILL_BECOMEPIG + CHAR_BECOMEPIG, + CHAR_BECOMEPIG_BBI,//要变成的图号 +#endif + CHAR_LASTLEAVETIME, // Robin add 最後离线时间 + +#ifdef _NEW_MANOR_LAW + CHAR_MOMENTUM, +#endif + +#ifdef _ITEM_ADDEXP2 + CHAR_ADDEXPPOWER, + CHAR_ADDEXPTIME, +#endif + +#ifdef _ANGEL_SUMMON + CHAR_HEROCNT, // 完成勇者任务的次数 +#endif + +#ifdef _TEACHER_SYSTEM + CHAR_TEACHER_FAME, // 导师领导声望 +#endif + +#ifdef _RACEMAN + CHAR_CHECKIN, //宠物是否登记 + CHAR_CATCHCNT1, //新手限 猎宠次数 + CHAR_CATCHCNT2, //老手限 猎宠次数 + CHAR_CATCHCNT3, //家族限 猎宠次数 + CHAR_CATCHCNT4, //老手不限 猎宠次数 + CHAR_CATCHCNT5, //老手不限 猎宠次数 + CHAR_KINDCNT1, /* (0~31) */ + CHAR_KINDCNT2, /* (32~63) */ + CHAR_KINDCNT3, /* (64~95) */ + CHAR_KINDCNT4, /* (96~127) */ + CHAR_KINDCNT5, /* (128~159) */ + CHAR_KINDCNT6, /* (160~191) */ + CHAR_KINDCNT7, /* (192~223) */ + CHAR_KINDCNT8, /* (224~255) */ + CHAR_KINDCNT9, /* (256~287) */ + CHAR_KINDCNT10, /* (288~319) */ +#endif + +#ifdef _GM_ITEM + CHAR_GMTIME, // 玩家GM命令次数 +#endif + + CHAR_DATAINTNUM, + +}CHAR_DATAINT; + +typedef enum { + CHAR_MODAI = CHAR_CHARM, /* 矢永玄 及及镝擦艘膜恳袄 */ + CHAR_VARIABLEAI = CHAR_LUCK, /* 矢永玄及镝擦艘 祭袄 ㄠㄟㄟ 仄凶袄匹 匀化云仁 */ + CHAR_SLOT = CHAR_DEFAULTPET, /* 檗 毛本永玄请 月旦夫永玄醒 矢永玄互银迕 */ + CHAR_PETGETLV = CHAR_CHATVOLUME, /* 必永玄今木凶伊矛伙 矢永玄及心银迕 */ + CHAR_PUTPETTIME = CHAR_LOGINCOUNT, /* 矢永玄互哗 卞 井木凶凛棉 */ + CHAR_MAILMODE = CHAR_RADARSTRENGTH, /* 矢永玄及心银迕 丢□伙霜耨橇谪 */ + CHAR_ALLOCPOINT = CHAR_LEVELUPPOINT, /* 伊矛伙失永皿凛及喃曰蕊曰禾奶件玄(矢永玄迕) */ + CHAR_PETMAILBUFINDEX = CHAR_GETPETCOUNT, /* 矢永玄丢□伙(offmsg)尺及index */ + CHAR_PETMAILIDLETIME = CHAR_SENDMAILCOUNT, /* 矢永玄丢□伙及啃及凛棉卅升 */ + CHAR_PETMAILFROMFLOOR = CHAR_DUELBATTLECOUNT, /* 丢□伙毛霜匀凶凛及白夫失 */ + CHAR_PETMAILFROMX = CHAR_DUELWINCOUNT, /* 丢□伙毛霜匀凶凛及 甄 */ + CHAR_PETMAILFROMY = CHAR_DUELLOSECOUNT, /* 丢□伙毛霜匀凶凛及 甄 */ + CHAR_PETMAILEFFECT = CHAR_DUELSTWINCOUNT, /* 矢永玄丢□伙及请蜇及巨白尼弁玄 寞 */ + CHAR_PETSENDMAILCOUNT = CHAR_TALKCOUNT, /* 矢永玄互丢□伙毛扪氏分荚醒 */ + CHAR_PETRANK = CHAR_LASTTIMESETLUCK, /* 矢永玄及仿件弁(矢永玄迕 ㄠ ㄥ[ㄟ反巨仿□迕 */ + CHAR_PETID = CHAR_DUELMAXSTWINCOUNT,/* 矢永玄及 件皿伊□玄及 */ + CHAR_PETFAMILY = CHAR_FMLEADERFLAG, // CoolFish: Family 判断是否为家族守护兽 +}CHAR_PET; + + +typedef enum +{ + CHAR_NAME, + CHAR_OWNTITLE, + CHAR_USERPETNAME = CHAR_OWNTITLE, + CHAR_NPCARGUMENT, + CHAR_CDKEY = CHAR_NPCARGUMENT, + CHAR_OWNERCDKEY, + CHAR_OWNERCHARANAME, + CHAR_FMNAME, +#ifdef _UNIQUE_P_I + CHAR_UNIQUECODE, +#endif +#ifdef _ACTION_GMQUE + CHAR_GMQUESTR1, +#endif +#ifdef _GM_IDENTIFY + CHAR_GMIDENTIFY, +#endif +#ifdef _TEACHER_SYSTEM + CHAR_TEACHER_ID, // 导师帐号 + CHAR_TEACHER_NAME, // 导师名字 +#endif +#ifdef _ITEM_SETLOVER + CHAR_LOVE, // 结婚判断 + CHAR_LOVERID, // 爱人帐号 + CHAR_LOVERNAME, // 爱人名字 +#endif + +#ifdef _GM_ITEM + CHAR_GMFUNCTION, // 玩家GM命令 +#endif + + CHAR_DATACHARNUM, +}CHAR_DATACHAR; + +typedef enum +{ + CHAR_ISATTACK, + CHAR_ISATTACKED, + CHAR_ISOVER, + CHAR_ISOVERED, + CHAR_HAVEHEIGHT, + CHAR_ISVISIBLE, + CHAR_ISTRANSPARENT, + CHAR_ISFLYING, + CHAR_ISDIE, + CHAR_ISBIG, + CHAR_ISSHOWBATTLEMSG, + CHAR_ISPARTY, + CHAR_ISWARP, + CHAR_ISDUEL, + CHAR_ISPARTYCHAT, + CHAR_ISTRADECARD, + CHAR_ISTRADE, +#ifdef _CHANNEL_MODIFY + CHAR_ISTELL, //密语频道开关 + CHAR_ISFM, //家族频道开关 + CHAR_ISOCC, //职业频道开关 + CHAR_ISSAVE, //对话储存开关 + CHAR_ISCHAT, //聊天室 +#endif +#ifdef _AUCPROTOCOL // (不可开) Syu ADD 拍卖频道开关Protocol + CHAR_ISAUC, +#endif + CHAR_FLGNUM, +}CHAR_DATAFLG; + +#define CHAR_FS_PARTY (1 << 0) +#define CHAR_FS_BATTLE (1 << 1) +#define CHAR_FS_DUEL (1 << 2) +#define CHAR_FS_PARTYCHAT (1 << 3) //队伍频道开关 +#define CHAR_FS_TRADECARD (1 << 4) +#define CHAR_FS_TRADE (1 << 5) +#ifdef _CHANNEL_MODIFY +#define CHAR_FS_TELL (1 << 6) //密语频道开关 +#define CHAR_FS_FM (1 << 7) //家族频道开关 +#define CHAR_FS_OCC (1 << 8) //职业频道开关 +#define CHAR_FS_SAVE (1 << 9) //对话储存开关 +#define CHAR_FS_CHAT (1 << 10) //聊天室开关 +#endif +#ifdef _AUCPROTOCOL // (不可开) Syu ADD 拍卖频道开关Protocol +#define CHAR_FS_AUC (1 << 6) +#endif + +typedef enum +{ + CHAR_WORKBATTLEMODE, + CHAR_WORKBATTLEINDEX, + CHAR_WORKBATTLESIDE, + CHAR_WORKBATTLECOM1, + CHAR_WORKBATTLECOM2, + CHAR_WORKBATTLECOM3, +#ifdef _PSKILL_MDFYATTACK + CHAR_WORKBATTLECOM4, +#endif + CHAR_WORKBATTLEFLG, + CHAR_WORKBATTLEWATCH, + + CHAR_WORKFIXEARTHAT, + CHAR_WORKFIXWATERAT, + CHAR_WORKFIXFIREAT, + CHAR_WORKFIXWINDAT, +#ifdef _PROFESSION_ADDSKILL + CHAR_WORKFIXEARTHAT_BOUNDARY, //地结界 左16位元存放加强百分比 右16位元存放回合数 + CHAR_WORKFIXWATERAT_BOUNDARY, //水结界 + CHAR_WORKFIXFIREAT_BOUNDARY, //火结界 + CHAR_WORKFIXWINDAT_BOUNDARY, //风结界 +#endif + CHAR_WORKMAXHP, + CHAR_WORKMAXMP, + + CHAR_WORKATTACKPOWER, + CHAR_WORKDEFENCEPOWER, + CHAR_WORKQUICK, + + CHAR_WORKFIXVITAL, + CHAR_WORKFIXSTR, + CHAR_WORKFIXTOUGH, + CHAR_WORKFIXDEX, + +#ifdef _ITEMSET5_TXT + CHAR_WORKFIXARRANGE, + CHAR_WORKARRANGEPOWER, + CHAR_WORKFIXSEQUENCE, + CHAR_WORKSEQUENCEPOWER, + CHAR_WORKATTACHPILE, + CHAR_WORKHITRIGHT, //额外命中 +#endif +#ifdef _ITEMSET6_TXT + CHAR_WORKNEGLECTGUARD, +#endif + CHAR_WORKMODATTACK, + CHAR_WORKMODDEFENCE, + CHAR_WORKMODQUICK, + + CHAR_WORKMODCAPTURE, + CHAR_WORKMODCHARM, + + CHAR_WORKFIXCHARM, + CHAR_WORKFIXLUCK, + CHAR_WORKFIXAI, + CHAR_WORKFIXAVOID, + + CHAR_WORKDAMAGEABSROB, + CHAR_WORKDAMAGEREFLEC, + CHAR_WORKDAMAGEVANISH, + CHAR_WORKPOISON, + CHAR_WORKPARALYSIS, + CHAR_WORKSLEEP, + CHAR_WORKSTONE, + CHAR_WORKDRUNK, + CHAR_WORKCONFUSION, + CHAR_WORKWEAKEN, //虚弱 vincent add _MAGIC_WEAKEN + CHAR_WORKDEEPPOISON, //剧毒 vincent add _MAGIC_DEEPPOISON + CHAR_WORKBARRIER, //魔障 vincent add _MAGIC_BARRIER + CHAR_WORKNOCAST, //沉默 vincent add _MAGIC_NOCAST + CHAR_WORKMODPOISON, + CHAR_WORKMODPARALYSIS, + CHAR_WORKMODSLEEP, + CHAR_WORKMODSTONE, + CHAR_WORKMODDRUNK, + CHAR_WORKMODCONFUSION, + CHAR_WORKMODWEAKEN, + CHAR_WORKMODDEEPPOISON, + CHAR_WORKMODBARRIER, //魔障 + CHAR_WORKMODNOCAST, //沉默 + CHAR_WORKMODCRITICAL, //一击必杀 + CHAR_WORKULTIMATE, + CHAR_WORKPARTYMODE, + CHAR_WORKTRADEMODE, /* 交易模式 + * 0: CHAR_TRADE_FREE :可交易 + * 1: CHAR_TRADE_SENDING:交易请求中 + * 2: CHAR_TRADE_TRADING:交易中 + * 3: CHAR_TRADE_LOCK :交易锁定中 + */ + CHAR_WORKPARTYINDEX1, + CHAR_WORKPARTYINDEX2, + CHAR_WORKPARTYINDEX3, + CHAR_WORKPARTYINDEX4, + CHAR_WORKPARTYINDEX5, + CHAR_WORKOBJINDEX, + CHAR_WORKWALKSTARTSEC, + CHAR_WORKWALKSTARTMSEC, + CHAR_WORKLOOPSTARTSEC, + CHAR_WORKLOOPSTARTMSEC, + CHAR_WORKLASTATTACKCHARAINDEX, + CHAR_WORKEVENTTYPE, + CHAR_WORKGETEXP, + CHAR_WORKMODCAPTUREDEFAULT, + CHAR_WORKACTION, + CHAR_WORKFD, + CHAR_WORKFLG, + CHAR_WORKGMLEVEL, + CHAR_NPCWORKINT1, + CHAR_NPCWORKINT2, + CHAR_NPCWORKINT3, + CHAR_NPCWORKINT4, + CHAR_NPCWORKINT5, + CHAR_NPCWORKINT6, + CHAR_NPCWORKINT7, + CHAR_NPCWORKINT8, + CHAR_NPCWORKINT9, + CHAR_NPCWORKINT10, + CHAR_NPCWORKINT11, +#ifdef _PETRACE + CHAR_NPCWORKINT12, +#endif + CHAR_NPCWORKINT13, + CHAR_WORKWARPCHECK, + CHAR_TENSEICHECKED, + CHAR_WORKFMINDEXI, // 家族索引 index + CHAR_WORKFMCHANNEL, // 家族频道 + CHAR_WORKFMCHANNELQUICK, + CHAR_WORKFMFLOOR, // 家族据点图层 + CHAR_WORKFMDP, // 家族DP值 + CHAR_WORKFMPKFLAG, // 是否正参与家族PK 1:Yes + CHAR_WORKFMSETUPFLAG, // 家族是否已正式成立 + CHAR_WORKFMMANINDEX, // FMWARPMAN Index + CHAR_WORKFMCHARINDEX, // 家族成员索引 index + CHAR_WORKBATTLEFLAG, // -1(战斗不能),1(可战斗) + + CHAR_WORK_PET0_STAT, + CHAR_WORK_PET1_STAT, + CHAR_WORK_PET2_STAT, + CHAR_WORK_PET3_STAT, + CHAR_WORK_PET4_STAT, + + CHAR_WORKLOGINTIME, // 玩家登入时间 + CHAR_WORKTALKCOUNT, + CHAR_WORKTALKTIME, + CHAR_WORKPETFOLLOW, // 宠物跟随 + CHAR_WORKPETFALL, // 战斗落马 + CHAR_WORKLEADERCHANGE, // 族长换位index +#ifdef _EQUIT_DEFMAGIC + CHAR_EQUITDEFMAGIC_E, + CHAR_EQUITDEFMAGIC_WA, + CHAR_EQUITDEFMAGIC_F, + CHAR_EQUITDEFMAGIC_WI, + CHAR_EQUITQUIMAGIC, +#endif +#ifdef _EQUIT_RESIST + CHAR_WORKEQUITFIRE, //装备抗火 + CHAR_WORKEQUITTHUNDER,//装备抗雷 + CHAR_WORKEQUITICE,//装备抗冰 + CHAR_WORKEQUITWEAKEN,//装备抗虚弱 + CHAR_WORKEQUITBARRIER,//装备抗魔障 + CHAR_WORKEQUITNOCAST,//装备抗沉默 + CHAR_WORKEQUITFALLRIDE,//装备抗落马 +#endif +#ifdef _PETMAIL_DEFNUMS + CHAR_PETMAILNUMS, + CHAR_PETMAILSENDTIME, +#endif +#ifdef _ACTION_BULLSCR + CHAR_BULLSHOWCOUNT, +#endif +#ifdef _ITEM_METAMO + CHAR_WORKITEMMETAMO, +#endif +#ifdef _ADD_DEAMGEDEFC + CHAR_WORKOTHERDMAGE, + CHAR_WORKOTHERDEFC, +#endif + +#ifdef _NPC_SELLSTH + CHAR_WORKSELLSTHNUM, +#endif + +#ifdef _LOSE_FINCH_ + CHAR_WORKSPETRELIFE, //宠物复活特性 +#endif + +#ifdef _CHIKULA_STONE + CHAR_WORKCHIKULAHP, + CHAR_WORKCHIKULAMP, +#endif +#ifdef _PETSKILL_SETDUCK + CHAR_MYSKILLDUCKPOWER, + CHAR_MYSKILLDUCK, + CHAR_MYSKILLSTRPOWER, + CHAR_MYSKILLSTR, + CHAR_MYSKILLTGHPOWER, + CHAR_MYSKILLTGH, + CHAR_MYSKILLDEXPOWER, + CHAR_MYSKILLDEX, + CHAR_MAGICPETMP, +#endif + CHAR_SKILLSTRPOWER, + CHAR_SKILLDEXPOWER, +#ifdef _NPC_MAKEPAIR + CHAR_MYPAIRINDEX, + CHAR_MYPAIRFLG, + CHAR_MYPAIRCODE, +#endif +#ifdef _OTHER_MAGICSTAUTS + CHAR_DEFMAGICSTATUS, +#ifdef _MAGIC_SUPERWALL + CHAR_MAGICSUPERWALL, +#endif + CHAR_OTHERSTATUSNUMS, +#endif +#ifdef _NPCCHANGE_PLAYERIMG + CHAR_WORKNPCMETAMO, +#endif + CHAR_PickAllPet, +#ifdef _DROPSTAKENEW + CHAR_WORKSTAKEFLAG, + CHAR_WORKSTAKETYPE1, + CHAR_WORKSTAKETYPE2, + CHAR_WORKSTAKETYPE3, + CHAR_WORKSTAKETYPE4, + CHAR_WORKSTAKETYPE5, +#endif + +#ifdef _MARKET_TRADE + CHAR_MAPTRADETYPE, //市集摊位 + CHAR_WORKTRADETYP, + CHAR_WORKTRADESELLINDEX, +#endif + CHAR_WORKTOXICATION, + +#ifdef _SUIT_ITEM + CHAR_WORKSUITITEM, + CHAR_WORKROUNDHP, + CHAR_WORKROUNDMP, + CHAR_WORKSUITVIT, + CHAR_WORKSUITSTR, + CHAR_WORKSUITTGH, + CHAR_WORKSUITDEX, + CHAR_WORKSUITMODSTR, +#ifdef _SUIT_ADDENDUM + CHAR_WORKRESIST, //异常抗性率 + CHAR_WORKCOUNTER,//反击率 + CHAR_WORKMPOWER, //加强法师的魔法( 受影响的法术:火山泉 火星球 召雷术 电流术 暴风雨 冰箭术 冰爆术 世界末日 火龙枪 嗜血成性 嗜血蛊 一针见血 附身术 ) +#endif +#ifdef _SUIT_TWFWENDUM + CHAR_WORK_EA,//地 + CHAR_WORK_WR,//水 + CHAR_WORK_FI,//火 + CHAR_WORK_WI,//风 +#endif +#ifdef _SUIT_ADDPART3 + CHAR_WORKDUCKPOWER,//套装回避 + CHAR_WORKRENOCAST, //沉默抗性率 + CHAR_WORKSUITSTR_P,//攻提升 单位为% + CHAR_WORKSUITTGH_P,//防提升 单位为% + CHAR_WORKSUITDEX_P,//敏提升 单位为% +#endif +#ifdef _SUIT_ADDPART4 + CHAR_SUITPOISON, //装备带毒 + CHAR_WORKMPOWER2, //与CHAR_WORKMPOWER相同 + CHAR_WORKUNMPOWER, //抵抗法师的魔法( 受影响的法术:火山泉 火星球 召雷术 电流术 暴风雨 冰箭术 冰爆术 世界末日 火龙枪 嗜血成性 嗜血蛊 一针见血 附身术 ) +#endif +#endif//_SUIT_ITEM + +#ifdef _IMPRECATE_ITEM + CHAR_WORKHURTMP, //伤害 MP + CHAR_WORKWISHESHP, //祝福 hp + CHAR_WORKWISHESMP, //祝福 MP + CHAR_WORKIMPRECATENUM1, + CHAR_WORKIMPRECATENUM2, + CHAR_WORKIMPRECATENUM3, +#endif +#ifdef _DEATH_CONTEND + CHAR_WORKLASTBATTLE, +#endif +#ifdef _STATUS_WATERWORD + CHAR_WORKMAPFLOORTYPE, + CHAR_WORKSTATUSWATER, +#endif +#ifdef _BATTLENPC_WARP_PLAYER + CHAR_WORKTURN, +#endif +#ifdef _MIND_ICON + CHAR_MIND_NUM, +#endif +#ifdef _ITEM_CRACKER + CHAR_WORKITEM_CRACKER, +#endif +#ifdef _ITEM_ADDEXP //vincent 经验提升 + CHAR_WORKITEM_ADDEXP, + CHAR_WORKITEM_ADDEXPTIME, +#endif +#ifdef _ALLDOMAN // (不可开) Syu ADD 排行榜NPC + CHAR_WORKHEROFLOOR, +#endif + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + CHAR_ENCOUNT_FIX, // 遇敌率 + CHAR_ENCOUNT_NUM, + CHAR_WORK_F_PROFICIENCY,// 火熟练度 + CHAR_WORK_I_PROFICIENCY,// 冰熟练度 + CHAR_WORK_T_PROFICIENCY,// 电熟练度 + CHAR_WORK_F_RESIST, // 火抗 + CHAR_WORK_I_RESIST, // 冰抗 + CHAR_WORK_T_RESIST, // 电抗 + CHAR_MYSKILLHIT, // 命中率 + CHAR_MYSKILLHIT_NUM, + CHAR_WORKDIZZY, // 晕眩 + CHAR_WORKMODDIZZY, + CHAR_WORKENTWINE, // 树根缠绕 + CHAR_WORKMODENTWINE, + CHAR_WORKTRAP, // 陷阱 + CHAR_WORKMODTRAP, + CHAR_WORKDRAGNET, // 天罗地网 + CHAR_WORKMODDRAGNET, +#ifdef _PROFESSION_ADDSKILL + //***********注意:这里的位置不可更动************* + CHAR_WORKICECRACK, // 冰爆术 + CHAR_WORKICECRACK2, // 冰爆术存放处2 + CHAR_WORKICECRACK3, // 冰爆术存放处3 + CHAR_WORKICECRACK4, // 冰爆术存放处4 + CHAR_WORKICECRACK5, // 冰爆术存放处5 + CHAR_WORKICECRACK6, // 冰爆术存放处6 + CHAR_WORKICECRACK7, // 冰爆术存放处7 + CHAR_WORKICECRACK8, // 冰爆术存放处8 + CHAR_WORKICECRACK9, // 冰爆术存放处9 + CHAR_WORKICECRACK10, // 冰爆术存放处10 + CHAR_WORKMODICECRACK, + CHAR_WORKMODICECRACK2, + CHAR_WORKMODICECRACK3, + CHAR_WORKMODICECRACK4, + CHAR_WORKMODICECRACK5, + CHAR_WORKMODICECRACK6, + CHAR_WORKMODICECRACK7, + CHAR_WORKMODICECRACK8, + CHAR_WORKMODICECRACK9, + CHAR_WORKMODICECRACK10, + //***************************************** +#else + CHAR_WORKICECRACK, // 冰爆术 + CHAR_WORKMODICECRACK, +#endif //_PROFESSION_ADDSKILL + + CHAR_WORKOBLIVION, // 遗忘 + CHAR_WORKMODOBLIVION, + CHAR_WORKICEARROW, // 冰箭 + CHAR_WORKMODICEARROW, + CHAR_WORKBLOODWORMS, // 嗜血蛊 + CHAR_WORKMODBLOODWORMS, + CHAR_WORKBLOODWORMSID, + CHAR_WORKSIGN, // 一针见血 + CHAR_WORKMODSIGN, + CHAR_WORKSIGNID, + CHAR_WORK_P_DUCK, // 回避 + CHAR_WORKMOD_P_DUCK, + CHAR_WORK_WEAPON, // 武器专精 + CHAR_WORKMOD_WEAPON, + CHAR_WORK_FOCUS, // 专注战斗 + CHAR_WORKMOD_FOCUS, + CHAR_WORKINSTIGATE, // 挑拨 + CHAR_WORKMODINSTIGATE, + CHAR_WORK_F_ENCLOSE, // 火附体 + CHAR_WORK_I_ENCLOSE, // 冰附体 + CHAR_WORK_T_ENCLOSE, // 雷附体 + CHAR_WORKMOD_F_ENCLOSE, + CHAR_WORKMOD_I_ENCLOSE, + CHAR_WORKMOD_T_ENCLOSE, + CHAR_WORK_F_ENCLOSE_2, // 火附 + CHAR_WORK_I_ENCLOSE_2, // 冰附 + CHAR_WORK_T_ENCLOSE_2, // 雷附 + CHAR_WORKMOD_F_ENCLOSE_2, + CHAR_WORKMOD_I_ENCLOSE_2, + CHAR_WORKMOD_T_ENCLOSE_2, + CHAR_WORKRESIST_F, // 提升火抗性 + CHAR_WORKRESIST_I, // 提升冰抗性 + CHAR_WORKRESIST_T, // 提升雷抗性 +#ifdef _PROFESSION_ADDSKILL + CHAR_WORKERSIST_F_I_T, // 提升火冰雷抗性 + CHAR_WORKANNEX, //附身 + CHAR_WORKWATER, //水附体 + CHAR_WORKFEAR, //恐惧 + CHAR_DOOMTIME, //世界末日集气(与火龙枪共用) + CHAR_WORK_com1, + CHAR_WORK_toNo, + CHAR_WORK_mode, + CHAR_WORK_skill_level, + CHAR_WORK_array, +#endif + CHAR_WORKMODRESIST_F, // 提升火抗性百分比数值 + CHAR_WORKMODRESIST_I, // 提升冰抗性百分比数值 + CHAR_WORKMODRESIST_T, // 提升雷抗性百分比数值 +#endif + +#ifdef _MAGICSTAUTS_RESIST + CHAR_MAGICFIRE, //火抗精灵 + CHAR_MAGICTHUNDER,//电抗精灵 + CHAR_MAGICICE,//冰抗精灵 +#endif + +#ifdef _PET_SKILL_SARS // WON ADD 毒煞蔓延 + CHAR_WORKSARS, + CHAR_WORKMODSARS, +#endif + +#ifdef _PETSKILL_ACUPUNCTURE + CHAR_WORKACUPUNCTURE, +#endif +#ifdef _PETSKILL_RETRACE + CHAR_WORKRETRACE, +#endif + +#ifdef _CHATROOMPROTOCOL // (不可开) Syu ADD 聊天室频道 + CHAR_WORKCHATROOMTYPE , + CHAR_WORKCHATROOMNUM , +#endif + +#ifdef _MAGIC_RESIST_EQUIT // WON ADD 职业抗性装备 + CHAR_WORK_F_SUIT, + CHAR_WORK_I_SUIT, + CHAR_WORK_T_SUIT, +#endif + +#ifdef _PETSKILL_BECOMEFOX + CHAR_WORKFOXROUND, //计算狐狸变身回合数 +#endif + + CHAR_WORKSTANDBYPET, // Robin add 待机宠 +#ifdef _STREET_VENDOR + CHAR_WORKSTREETVENDOR, // 摆摊状态 -1:没在摆摊,也没在摆摊交易;1:摆摊中;2:卖方在交易中;3:摆摊的买方 + CHAR_WORKSTREETVENDOR_WHO, // 谁和我交易 +#endif + +#ifdef _ANGEL_SUMMON + CHAR_WORKMISSION, + CHAR_WORKANGELMODE, +#endif +#ifdef _MAP_TIME + CHAR_WORK_MAP_TIME, // 特殊地图倒数 +#endif +#ifdef _PETSKILL_LER + CHAR_WORK_RELIFE, // 雷尔复活 +#endif +#ifdef _TEACHER_SYSTEM + CHAR_WORK_GET_TEACHER_FAME, // 导师领导声望 +#endif + + CHAR_WORKSKYWALKER, // GM天行者?? + + CHAR_WORKLASTMERGETIME, // 最後合成时间 + +#ifdef _ESCAPE_RESET // 恶宝逃跑後暂时不可组队 + CHAR_WORKLASTESCAPE, +#endif + +#ifdef _FONT_SIZE + CHAR_WORKFONTSIZE, // +#endif + +#ifdef _TIME_TICKET + CHAR_WORKTICKETTIME, + CHAR_WORKTICKETTIMESTART, +#endif + + CHAR_WORKDEBUGMODE, // 除错模式中 + + CHAR_WORKDATAINTNUM, + + + CHAR_WORKENCOUNTPROBABILITY_MIN = CHAR_NPCWORKINT1, + CHAR_WORKENCOUNTPROBABILITY_MAX = CHAR_NPCWORKINT2, + CHAR_WORK_TOHELOS_CUTRATE = CHAR_NPCWORKINT3, + CHAR_WORK_TOHELOS_COUNT = CHAR_NPCWORKINT4, + CHAR_WORKSHOPRELEVANT = CHAR_NPCWORKINT5, + CHAR_WORKSHOPRELEVANTSEC = CHAR_NPCWORKINT6, + CHAR_WORKSHOPRELEVANTTRD = CHAR_NPCWORKINT7, + CHAR_WORKTRADER = CHAR_NPCWORKINT8, + CHAR_WORKEFFECT = CHAR_NPCWORKINT9, + CHAR_WORKRENAMEITEMNUM = CHAR_NPCWORKINT10, + CHAR_WORKRENAMEITEMINDEX = CHAR_NPCWORKINT5, + CHAR_WORKPLAYERINDEX = CHAR_NPCWORKINT1, + CHAR_WORKTACTICS = CHAR_NPCWORKINT2, + CHAR_WORKPETFOLLOWMODE = CHAR_NPCWORKINT3, + CHAR_WORKPETFOLLOWCOUNT = CHAR_NPCWORKINT4, + CHAR_WORK_PETFLG = CHAR_NPCWORKINT1, + CHAR_WORKGENERATEINDEX = CHAR_NPCWORKINT1, + CHAR_WORKDOORCLOSETIME = CHAR_NPCWORKINT1, + CHAR_WORKDOORSWITCHCOUNT = CHAR_NPCWORKINT2, + CHAR_WORKDOOROPENG = CHAR_NPCWORKINT3, + CHAR_WORKDOORCLOSEG = CHAR_NPCWORKINT4, + CHAR_WORKDOORSOONFLG = CHAR_NPCWORKINT5, + CHAR_WORKDOORPASSFLG = CHAR_NPCWORKINT6, + CHAR_WORKDOORKEYITEMID = CHAR_NPCWORKINT7, + CHAR_WORKDOORSWITCHCURRENT = CHAR_NPCWORKINT8, + CHAR_WORKDOORORIGINALGRAPHIC = CHAR_NPCWORKINT9, + CHAR_WORKDOOREXPIRETIME = CHAR_NPCWORKINT10, + CHAR_WORKOLDMANID = CHAR_NPCWORKINT1, + CHAR_WORKSHOPCLIENTINDEX = CHAR_NPCWORKINT1, + CHAR_WORKDENGONMAXID = CHAR_NPCWORKINT1, +}CHAR_WORKDATAINT; + + +enum{ + WORKFLG_DEBUGMODE = ( 1 << 0 ), + WORKFLG_MICMODE = ( 2 << 0 ), +}; + +typedef enum +{ + CHAR_INITFUNC, + CHAR_FIRSTFUNCTION = CHAR_INITFUNC, + CHAR_WALKPREFUNC, + CHAR_WALKPOSTFUNC, + CHAR_PREOVERFUNC, + CHAR_POSTOVERFUNC, + CHAR_WATCHFUNC, + CHAR_LOOPFUNC, + CHAR_DYINGFUNC, + CHAR_TALKEDFUNC, + CHAR_PREATTACKEDFUNC, + CHAR_POSTATTACKEDFUNC, + CHAR_OFFFUNC, + CHAR_LOOKEDFUNC, + CHAR_ITEMPUTFUNC, + CHAR_SPECIALTALKEDFUNC, + CHAR_WINDOWTALKEDFUNC, +#ifdef _USER_CHARLOOPS + CHAR_LOOPFUNCTEMP1, + CHAR_LOOPFUNCTEMP2, + CHAR_BATTLEPROPERTY, +#endif + CHAR_LASTFUNCTION, + CHAR_FUNCTABLENUM = CHAR_LASTFUNCTION, +}CHAR_FUNCTABLE; + +typedef enum +{ + CHAR_WORKWALKARRAY, + CHAR_NPCWORKCHAR1, + CHAR_NPCWORKCHAR2, + CHAR_NPCWORKCHAR3, + CHAR_NPCWORKCHAR4, + CHAR_NPCWORKCHAR5, + CHAR_NPCWORKCHAR6, +#ifdef _ANGEL_SUMMON + CHAR_WORKHEROINFO, +#endif +#ifdef _STREET_VENDOR + CHAR_STREETVENDOR_NAME, +#endif + CHAR_WORKDATACHARNUM, + CHAR_WORKBATTLE_TACTICSOPTION = CHAR_NPCWORKCHAR1, +#ifdef _BATTLENPC_WARP_PLAYER + CHAR_WORKBATTLE_ACT_CONDITION = CHAR_NPCWORKCHAR2, +#endif + CHAR_WORKDOORPASSWD = CHAR_NPCWORKCHAR1, + CHAR_WORKDOORNAME = CHAR_NPCWORKCHAR2, + CHAR_WORKDOORGOLDLIMIT = CHAR_NPCWORKCHAR3, + CHAR_WORKDOORWEEK = CHAR_NPCWORKCHAR4, + CHAR_WORKDOORHOUR = CHAR_NPCWORKCHAR5, + CHAR_WORKDOORMINUTE = CHAR_NPCWORKCHAR6, + CHAR_WORKDOORTITLE = CHAR_NPCWORKCHAR6, + CHAR_WORKDOORMANDOORNAME = CHAR_NPCWORKCHAR1, + CHAR_TIME1, + CHAR_TIME2 = CHAR_NPCWORKCHAR6, + +}CHAR_WORKDATACHAR; + + +typedef enum +{ + CHAR_IMAGETYPE_GIRL, + CHAR_IMAGETYPE_BOY, + CHAR_IMAGETYPE_CHILDBOY, + CHAR_IMAGETYPE_CHILDGIRL, + CHAR_IMAGETYPE_MAN, + CHAR_IMAGETYPE_WOMAN, + CHAR_IMAGETYPE_OLDMAN, + CHAR_IMAGETYPE_DOG, + CHAR_IMAGETYPENUM +}CHAR_ImageType; + + +#define CHAR_P_STRING_HP ( 1 << 1 ) // 0x00000002 +#define CHAR_P_STRING_MAXHP ( 1 << 2 ) // 0x00000004 +#define CHAR_P_STRING_MP ( 1 << 3 ) // 0x00000008 +#define CHAR_P_STRING_MAXMP ( 1 << 4 ) // 0x00000010 +#define CHAR_P_STRING_VITAL ( 1 << 5 ) +#define CHAR_P_STRING_STR ( 1 << 6 ) +#define CHAR_P_STRING_TOUGH ( 1 << 7 ) +#define CHAR_P_STRING_DEX ( 1 << 8 ) +#define CHAR_P_STRING_EXP ( 1 << 9 ) +#define CHAR_P_STRING_NEXTEXP ( 1 << 10 ) +#define CHAR_P_STRING_LV ( 1 << 11 ) +#define CHAR_P_STRING_ATK ( 1 << 12 ) +#define CHAR_P_STRING_DEF ( 1 << 13 ) +#define CHAR_P_STRING_QUICK ( 1 << 14 ) +#define CHAR_P_STRING_CHARM ( 1 << 15 ) +#define CHAR_P_STRING_LUCK ( 1 << 16 ) +#define CHAR_P_STRING_EARTH ( 1 << 17 ) +#define CHAR_P_STRING_WATER ( 1 << 18 ) +#define CHAR_P_STRING_FIRE ( 1 << 19 ) +#define CHAR_P_STRING_WIND ( 1 << 20 ) +#define CHAR_P_STRING_GOLD ( 1 << 21 ) +#define CHAR_P_STRING_TITLE ( 1 << 22 ) +#define CHAR_P_STRING_DUELPOINT ( 1 << 23 ) +#define CHAR_P_STRING_TRANSMIGRATION ( 1 << 24 ) +#define CHAR_P_STRING_NAME ( 1 << 25 ) +#define CHAR_P_STRING_OWNTITLE ( 1 << 26 ) +#define CHAR_P_STRING_RIDEPET ( 1 << 27 ) // 0x08000000 +#define CHAR_P_STRING_LEARNRIDE ( 1 << 28 ) // 0x10000000 +#define CHAR_P_STRING_BASEBASEIMAGENUMBER ( 1 << 29 ) // 0x20000000 +//#define CHAR_P_STRING_PKDP ( 1 << 30 ) +//#ifdef _CHAR_PROFESSION +//#define CHAR_P_STRING_PROFESSION ( 1 << 30 ) +//#endif +#define CHAR_P_STRING_SKYWALKER ( 1 << 30 ) // 0x40000000 +#define CHAR_P_STRING_DEBUGMODE ( 1 << 31 ) // 0x80000000 + + + +#define CHAR_N_STRING_OBJINDEX ( 1 << 1 ) +#define CHAR_N_STRING_LV ( 1 << 2 ) +#define CHAR_N_STRING_MAXHP ( 1 << 3 ) +#define CHAR_N_STRING_HP ( 1 << 4 ) +#define CHAR_N_STRING_MP ( 1 << 5 ) +#define CHAR_N_STRING_NAME ( 1 << 6 ) + +#define CHAR_K_STRING_BASEIMAGENUMBER ( 1 << 1 ) +#define CHAR_K_STRING_HP ( 1 << 2 ) +#define CHAR_K_STRING_MAXHP ( 1 << 3 ) +#define CHAR_K_STRING_MP ( 1 << 4 ) +#define CHAR_K_STRING_MAXMP ( 1 << 5 ) +#define CHAR_K_STRING_EXP ( 1 << 6 ) +#define CHAR_K_STRING_NEXTEXP ( 1 << 7 ) +#define CHAR_K_STRING_LV ( 1 << 8 ) +#define CHAR_K_STRING_ATK ( 1 << 9 ) +#define CHAR_K_STRING_DEF ( 1 << 10 ) +#define CHAR_K_STRING_QUICK ( 1 << 11 ) +#define CHAR_K_STRING_AI ( 1 << 12 ) +#define CHAR_K_STRING_EARTH ( 1 << 13 ) +#define CHAR_K_STRING_WATER ( 1 << 14 ) +#define CHAR_K_STRING_FIRE ( 1 << 15 ) +#define CHAR_K_STRING_WIND ( 1 << 16 ) +#define CHAR_K_STRING_SLOT ( 1 << 17 ) +#define CHAR_K_STRING_CHANGENAMEFLG ( 1 << 18 ) +#define CHAR_K_STRING_NAME ( 1 << 19 ) +#define CHAR_K_STRING_USERPETNAME ( 1 << 20 ) + +typedef union { + int indexOfPet[CHAR_MAXPETHAVE]; + int indexOfPetskill[CHAR_MAXPETSKILLHAVE]; +}CHAR_UNIONTABLE; + +typedef struct tagChar +{ + BOOL use; + + int data[CHAR_DATAINTNUM]; + STRING128 string[CHAR_DATACHARNUM]; + char flg[(CHAR_FLGNUM%(sizeof(char)*8)) + ? (CHAR_FLGNUM/(sizeof(char)*8))+1 + : (CHAR_FLGNUM/(sizeof(char)*8))]; + int indexOfExistItems[CHAR_MAXITEMHAVE]; + int indexOfExistPoolItems[CHAR_MAXPOOLITEMHAVE]; + +#ifdef _CHAR_POOLITEM + int *indexOfExistDepotItems; +#endif +#ifdef _CHAR_POOLPET + int *indexOfExistDepotPets; +#endif + + CHAR_HaveSkill haveSkill[CHAR_SKILLMAXHAVE]; + int indexOfHaveTitle[CHAR_TITLEMAXHAVE]; + ADDRESSBOOK_entry addressBook[ADDRESSBOOK_MAX]; + CHAR_UNIONTABLE unionTable; + int indexOfPoolPet[CHAR_MAXPOOLPETHAVE]; + STRING32 charfunctable[CHAR_FUNCTABLENUM]; + int workint[CHAR_WORKDATAINTNUM]; + STRING64 workchar[CHAR_WORKDATACHARNUM]; +#ifdef _NPC_SEPARATEDATA + int *tempint; +#endif + int CharMakeSequenceNumber; + void* functable[CHAR_FUNCTABLENUM]; +#ifdef _STREET_VENDOR + StreetVendor_t StreetVendor[MAX_SELL_ITEM]; +#endif +}Char; + + +#define CHAR_CHECKINDEX( index) _CHAR_CHECKINDEX( __FILE__, __LINE__, index) +INLINE BOOL _CHAR_CHECKINDEX( char *file, int line, int index); +#define CHAR_CHECKITEMINDEX( charaindex, iindex) _CHAR_CHECKITEMINDEX( __FILE__, __LINE__, charaindex, iindex) +INLINE BOOL _CHAR_CHECKITEMINDEX( char *file, int line, int charaindex, int iindex ); +#define CHAR_CHECKPETINDEX( petindex) _CHAR_CHECKPETINDEX( __FILE__, __LINE__, petindex ) +INLINE BOOL _CHAR_CHECKPETINDEX( char *file, int line, int petindex ); +#define CHAR_CHECKPOOLPETINDEX( petindex) _CHAR_CHECKPOOLPETINDEX( __FILE__, __LINE__, petindex ) +INLINE BOOL _CHAR_CHECKPOOLPETINDEX( char *file, int line, int petindex ); +#define CHAR_CHECKPETSKILLINDEX( havepetskillindex) _CHAR_CHECKPETSKILLINDEX( __FILE__, __LINE__, havepetskillindex) +INLINE BOOL _CHAR_CHECKPETSKILLINDEX( char *file, int line, int havepetskillindex ); + +INLINE int CHAR_getInt( int index , CHAR_DATAINT element); +#define CHAR_setInt( index , element, data) _CHAR_setInt( __FILE__, __LINE__, index , element, data) +INLINE int _CHAR_setInt( char *file, int line, int index ,CHAR_DATAINT element, int data); +#ifdef _FIX_SETWORKINT +#define CHAR_getWorkInt( index , element) _CHAR_getWorkInt( __FILE__, __LINE__, index , element) +INLINE int _CHAR_getWorkInt( char *file, int line, int index ,CHAR_WORKDATAINT element); +#define CHAR_setWorkInt( index, element, data) _CHAR_setWorkInt( __FILE__, __LINE__, index , element, data) +INLINE int _CHAR_setWorkInt( char *file, int line, int index ,CHAR_WORKDATAINT element, int data); +#else +INLINE int CHAR_setWorkInt( int index ,CHAR_WORKDATAINT element, int data); +#endif +#define CHAR_getChar( index, elem) _CHAR_getChar( __FILE__, __LINE__, index, elem) +INLINE char* _CHAR_getChar( char *file, int line, int index ,CHAR_DATACHAR element ); +#define CHAR_setChar( index, elem, n) _CHAR_setChar( __FILE__, __LINE__, index, elem, n) +INLINE BOOL _CHAR_setChar( char *file, int line, int index ,CHAR_DATACHAR element, char* new ); +#define CHAR_getFlg( index, elem) _CHAR_getFlg( __FILE__, __LINE__, index, elem) +INLINE BOOL _CHAR_getFlg( char *file, int line, int index ,CHAR_DATAFLG element ); +#define CHAR_setFlg( index, elem, n) _CHAR_setFlg( __FILE__, __LINE__, index, elem, n) +INLINE char _CHAR_setFlg( char *file, int line, int index , CHAR_DATACHAR element, int newdata ); +#define CHAR_getWorkChar( index, elem) _CHAR_getWorkChar( __FILE__, __LINE__, index, elem) +INLINE char * _CHAR_getWorkChar( char *file, int line, int index, CHAR_WORKDATACHAR element ); +#define CHAR_setWorkChar( index, elem, n) _CHAR_setWorkChar( __FILE__, __LINE__, index, elem, n) +INLINE BOOL _CHAR_setWorkChar( char *file, int line, int index, CHAR_WORKDATACHAR element, char * new); + +#define CHAR_getItemIndex( index, iindex) _CHAR_getItemIndex( __FILE__, __LINE__, index, iindex) +INLINE int _CHAR_getItemIndex( char *file, int line, int charaindex, int ti); +#define CHAR_setItemIndex( index, iindex,id) _CHAR_setItemIndex( __FILE__, __LINE__, index, iindex, id) +INLINE int _CHAR_setItemIndex( char *file, int line, int index ,int iindex,int id ); +#define CHAR_getPoolItemIndex( index, iindex) _CHAR_getPoolItemIndex( __FILE__, __LINE__, index, iindex) +INLINE int _CHAR_getPoolItemIndex( char *file, int line, int index, int iindex); +#define CHAR_setPoolItemIndex( index, iindex,id) _CHAR_setPoolItemIndex( __FILE__, __LINE__, index, iindex, id) +INLINE int _CHAR_setPoolItemIndex( char *file, int line, int index ,int iindex,int id ); +INLINE BOOL CHAR_setAddressbookEntry( int index , int aindex , ADDRESSBOOK_entry *a ); +INLINE ADDRESSBOOK_entry* CHAR_getAddressbookEntry( int index , int aindex); +INLINE Char* CHAR_getCharPointer( int index ); +INLINE int CHAR_getCharNum( void ); +INLINE int CHAR_getPlayerMaxNum( void ); +INLINE int CHAR_getPetMaxNum( void ); +INLINE int CHAR_getOthersMaxNum( void ); +INLINE BOOL CHAR_getCharUse( int index ); +INLINE CHAR_HaveSkill* CHAR_getCharHaveSkill( int index,int sindex ); +INLINE int CHAR_getCharHaveTitle( int index,int tindex ); +INLINE int CHAR_setCharHaveTitle( int charaindex,int tindex, int new ); +INLINE int CHAR_getCharPet( int charaindex,int petindex ); +INLINE int CHAR_setCharPet( int charaindex,int petindex, int new ); +INLINE int CHAR_getCharPoolPet( int charaindex,int petindex ); +INLINE int CHAR_setCharPoolPet( int charaindex,int petindex, int new ); +int CHAR_getCharPetElement( int charaindex ); +int CHAR_getCharPoolPetElement( int charaindex ); +int CHAR_getCharPoolItemIndexElement( int charaindex ); +int CHAR_getEmptyCharPoolItemIndexNum( int charaindex); +#ifdef _CHAR_POOLPET +int CHAR_getCharDepotPetElement( int charaindex ); +#endif +#define CHAR_getIntPSkill( index, skillti, ti) _CHAR_getIntPSkill( __FILE__, __LINE__, index, skillti, ti) +INLINE int _CHAR_getIntPSkill( char *file, int line, int index, int skillti, SKILL_DATAINT ti); + +#define CHAR_setIntPSkill( index, skillti, ti, data) _CHAR_setIntPSkill( __FILE__, __LINE__, index, skillti, ti, data) +INLINE void _CHAR_setIntPSkill( char *file, int line, int index, int skillti, SKILL_DATAINT ti, int data); + + +extern Char *CHAR_chara; + + +INLINE int CHAR_getCharMakeSequenceNumber( int charaindex ); +void CHAR_constructFunctable( int charaindex ); +void* CHAR_getFunctionPointer( int charaindex, int functype ); +BOOL CHAR_initCharArray( int pnum, int petnum,int onum ); +BOOL CHAR_endCharArray( void ); +int CHAR_initCharOneArray( Char* ch ); +void CHAR_endCharOneArray( int index ); +void CHAR_removeHaveItem( Char* ch ); +void CHAR_endCharData( Char* ch ); +char* CHAR_makeStringFromCharData( Char* one ); +char* CHAR_makeStringFromCharIndex( int index ); +BOOL CHAR_makeCharFromStringToArg( char* data, Char* one); +int CHAR_makePetFromStringToArg( char *src, Char *ch, int ti); +char *CHAR_makePetStringFromPetIndex( int petindex); +#define CHAR_getPetSkillElement( petindex) _CHAR_getPetSkillElement( __FILE__, __LINE__, petindex) +int _CHAR_getPetSkillElement( char *file, int line, int petindex ); +#define CHAR_setPetSkill( petindex, havepetskillindex, n) _CHAR_setPetSkill( __FILE__, __LINE__, petindex, havepetskillindex, n) +INLINE int _CHAR_setPetSkill( char *file, int line, int petindex,int havepetskillindex, int new ); +#define CHAR_getPetSkill( petindex, havepetskillindex) _CHAR_getPetSkill( __FILE__, __LINE__, petindex, havepetskillindex) +INLINE int _CHAR_getPetSkill( char *file, int line, int petindex,int havepetskillindex ); +#define SETFLG(a,b,c,d,e,f,g,h) (((a)<<0)+((b)<<1)+((c)<<2)+((d)<<3)+((e)<<4)+((f)<<5)+((g)<<6)+((h)<<7)) + +INLINE int CHAR_AddMaxExp( int charaindex, int addexp); +INLINE int CHAR_setMaxExpFromLevel( int charaindex, int level); +INLINE int CHAR_setMaxExp( int charaindex, unsigned long int Setexp); +#ifdef _NEWOPEN_MAXEXP +INLINE int CHAR_ChangeExp( int charaindex ); +INLINE int CHAR_HandleExp( int charaindex ); + +#endif + +// ride Pet table +typedef struct tagtagRidePetTable +{ + int rideNo; + int charNo; + int petNo; + int petId; + +} tagRidePetTable; + + +// CoolFish: Family Member Kind 2001/8/28 +typedef enum +{ + FMMEMBER_NONE = -1, + FMMEMBER_MEMBER = 1, + FMMEMBER_APPLY, + FMMEMBER_LEADER, + FMMEMBER_ELDER, +} CHAR_FM_MEMBERKIND; + +// shan 2002/01/10 +typedef enum +{ + PET_STAT_NONE = 0, + PET_STAT_SELECT, + PET_STAT_MAIL = 4, +} CHAR_PET_STAT; + + +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 +void CHAR_earnFame(int index, int fame); +#endif + +// CoolFish: 2001/10/11 +#ifdef _UNIQUE_P_I +void CHAR_setPetUniCode(int petindex); +void ITEM_setItemUniCode(int itemindex); +void Check_P_I_UniCode(int charindex); +#endif + +// Arminius 12.15 判断是否是男士 +int IsMale(int charindex); + +// Arminius 12.15 判断是否是女士 +int IsFemale(int charindex); + + +#ifdef _NEW_RIDEPETS +#define RIDE_PET0 1 +#define RIDE_PET1 ( 1 << 1 ) +#define RIDE_PET2 ( 1 << 2 ) +#define RIDE_PET3 ( 1 << 3 ) +#define RIDE_PET4 ( 1 << 4 ) +#define RIDE_PET5 ( 1 << 5 ) +#define RIDE_PET6 ( 1 << 6 ) +#define RIDE_PET7 ( 1 << 7 ) +#define RIDE_PET8 ( 1 << 8 ) +#define RIDE_PET9 ( 1 << 9 ) +#define RIDE_PET10 ( 1 << 10 ) +#define RIDE_PET11 ( 1 << 11 ) +#define MAXNOINDEX 12 +typedef struct { + int petNo; + int learnCode; +}tagRideCodeMode; + +typedef struct { + int RideNo[MAXNOINDEX]; + int flg; +}tagRideNoList; + +typedef struct { + int charNo; + int Noindex; + int sex; +}tagRidePetList; + +int RIDEPET_getNOindex( int baseNo); +int RIDEPET_getPETindex( int PetNo, int learnCode); +int RIDEPET_getRIDEno( int index, int ti); +#endif + +#ifdef _PET_EVOLUTION +int EVOLUTION_getPetTable( int charaindex, int petindex1, int petindex2); +int EVOLUTION_getPropertyTable( int charaindex, int petindex1, int petindex2); +int EVOLUTION_getFusionTable( int charaindex, int px, int py); +int EVOLUTION_getPetFusionCode( int petid); +#endif + +#ifdef _EMENY_CHANCEMAN +int CHAR_getSexInt( int baseNo ); +#endif +#ifdef _TYPE_TOXICATION +BOOL CHAR_CanCureFlg( int charaindex, char *arg); +#endif + +#ifdef _FIX_TSKILLCAN +BOOL CHAR_PETSKILLCAN( int toindex); +#endif + +BOOL CHAR_getCharOnArrayPercentage( int mode, int *max, int *min, int *cnt); + + +#define CHAR_DelItemMess( index, ti, flg) _CHAR_DelItem( __FILE__, __LINE__, index, ti, 1, flg) +#define CHAR_DelItem( index, ti) _CHAR_DelItem( __FILE__, __LINE__, index, ti, 1, 1) +#define CHAR_DelPileItemMess( index, ti, num, flg) _CHAR_DelItem( __FILE__, __LINE__, index, ti, num, flg) + +#define CHAR_AddPileItem( index, itemindex) _CHAR_AddPileItem( __FILE__, __LINE__, index, itemindex) +INLINE int _CHAR_AddPileItem( char *file, int line, int charaindex, int itemindex); + +INLINE int _CHAR_DelItem( char *file, int line, int charaindex, int ti, int num, int flg); + +#define CHAR_AddGold( index, ti) _CHAR_AddGold( __FILE__, __LINE__, index, ti) +INLINE int _CHAR_AddGold( char *file, int line, int charaindex, int gold); +#define CHAR_DelGold( index, ti) _CHAR_DelGold( __FILE__, __LINE__, index, ti) +INLINE int _CHAR_DelGold( char *file, int line, int charaindex, int gold); +int CHAR_getMaxHaveGold( int charaindex); + + +#ifdef _CHAR_PROFESSION // WON ADD 人物职业 + +int CHAR_getCharSkill( int index,int sindex ); +int CHAR_setCharSkill( int index,int sindex,int new ); +#define CHAR_CHECK_PROFESSION_SKILLINDEX( skillindex) _CHAR_CHECK_PROFESSION_SKILLINDEX( __FILE__, __LINE__, skillindex) +INLINE BOOL _CHAR_CHECK_PROFESSION_SKILLINDEX( char *file, int line, int skillindex ); +#define PROFESSION_SKILL_getSkill( charaindex, skillindex) _PROFESSION_SKILL_getSkill( __FILE__, __LINE__, charaindex, skillindex) +INLINE int _PROFESSION_SKILL_getSkill( char *file, int line, int charaindex, int skillindex ); +#define PROFESSION_SKILL_setSkill( charaindex, skillindex, n) _PROFESSION_SKILL_setSkill( __FILE__, __LINE__, charaindex, skillindex, n) +INLINE int _PROFESSION_SKILL_setSkill( char *file, int line, int charaindex,int skillindex, int new ); +#define PROFESSION_SKILL_getSkillElement(charaindex) _PROFESSION_SKILL_getSkillElement( __FILE__, __LINE__, charaindex) +int _PROFESSION_SKILL_getSkillElement( char *file, int line, int charaindex ); + +#endif + +#ifdef _NPC_SEPARATEDATA +void CHAR_showTempInt( int index); +BOOL CHAR_InitCharTempNum( Char* ch ); +void CHAR_EndCharTempNum( void); +void CHAR_getDefaultCharTempNum( Char* ch ); +#endif + +#ifdef _CHAR_POOLITEM + +#define CHAR_getDepotItemIndex( index, iindex) _CHAR_getDepotItemIndex( __FILE__, __LINE__, index, iindex) +INLINE int _CHAR_getDepotItemIndex( char *file, int line, int index ,int iindex); +#define CHAR_setDepotItemIndex( index, iindex,id) _CHAR_setDepotItemIndex( __FILE__, __LINE__, index, iindex, id) +INLINE int _CHAR_setDepotItemIndex( char *file, int line, int index ,int iindex,int id ); + +void CHAR_removeHaveDepotItem( Char* ch); +void CHAR_removeDepotItem( int charaindex); + +char *CHAR_makeDepotItemFromCharIndex( int charaindex); +BOOL CHAR_makeDepotItemStringToChar( int charaindex, char* data); + +BOOL CHAR_SaveDepotItem( int charaindex); +BOOL CHAR_GetDepotItem( int meindex, int charaindex); +void CHAR_ShowMyDepotItems( int charaindex); + +int CHAR_findEmptyDepotItem( int charaindex); +int CHAR_getfindEmptyDepotItem( int charaindex); +BOOL CHAR_CheckDepotItem( int charaindex); +#endif + +#ifdef _CHAR_POOLPET + +#define CHAR_getDepotPetIndex( index, iindex) _CHAR_getDepotPetIndex( __FILE__, __LINE__, index, iindex) +INLINE int _CHAR_getDepotPetIndex( char *file, int line, int index ,int iindex); +#define CHAR_setDepotPetIndex( index, iindex,id) _CHAR_setDepotPetIndex( __FILE__, __LINE__, index, iindex, id) +INLINE int _CHAR_setDepotPetIndex( char *file, int line, int index ,int iindex,int id ); + +void CHAR_removeHaveDepotPet( Char* ch); +void CHAR_removeDepotPet( int charaindex); + +char *CHAR_makeDepotPetFromCharIndex( int charaindex); +BOOL CHAR_makeDepotPetStringToChar( int charaindex, char* data); + +BOOL CHAR_SaveDepotPet( int charaindex); +BOOL CHAR_GetDepotPet( int meindex, int charaindex); +void CHAR_ShowMyDepotPets( int charaindex); + +int CHAR_findEmptyDepotPet( int charaindex); +int CHAR_getfindEmptyDepotPet( int charaindex); +BOOL CHAR_CheckDepotPet( int charaindex); +#endif + + +void LodBadPetString( char *data, char *err, int ti); + +#ifdef _STREET_VENDOR +BOOL CHAR_setStreetVendor(int charindex,int index,int set,int num); +INLINE void CHAR_clearStreetVendor(int charindex,int index); +int CHAR_getStreetVendor(int charindex,int index,int set); +#endif + +#ifdef _ANGEL_SUMMON + +#define ANGELITEM 2884 //20701 //使者的信物 道具编号 +#define HEROITEM 2885 //20702 //勇者的信物 道具编号 + +typedef enum +{ + ANGEL_NONE =0, + ANGEL_ANGEL, + ANGEL_HERO, +}ANGEL_TYPE; + +typedef enum +{ + MISSION_NONE =0, + MISSION_WAIT_ANSWER, + MISSION_DOING, + MISSION_HERO_COMPLETE, + MISSION_TIMEOVER, +}ANGEL_MISSIONFLAG; +#endif + +#endif diff --git a/gmsv/include/char_data.h b/gmsv/include/char_data.h new file mode 100644 index 0000000..1085a8c --- /dev/null +++ b/gmsv/include/char_data.h @@ -0,0 +1,120 @@ +#ifndef __CHAR_DATA_H__ +#define __CHAR_DATA_H__ + +#include "item.h" +#include "char.h" + + +#define CHAR_CLASS01_PASSLV 20 + +#define BATEBAN 2 +#define FIRSTPOSITIONMAXINDEX 1 +#define ELDERINDEXSTART FIRSTPOSITIONMAXINDEX+BATEBAN+1 + +typedef struct tagLevelUpPattern +{ +#if 1 + struct Exptbl{ + int origin; + int multi; + }exptbl[3]; + int hpupminpoint; /* hp 及丐互月 斓袄*/ + int hpupmaxpoint; /* hp 及丐互月 斓袄*/ + + int needexp; /* 邰卅烦董袄 */ +#else + int uppoint[5]; +#endif +}LevelUpPattern; + +/*====================赓渝袄}伊皮伙失永皿楮溢====================*/ +BOOL CHAR_getDefaultChar( Char* nc, int imagenumber ); + +/*====================隶 } 飓 寞赘尹楮溢====================*/ +int CHAR_getNewImagenumberFromEquip( int basebaseimagenumber, + ITEM_CATEGORY category ); +/*==================== 飓 寞 侬 -> 寞楮溢====================*/ +void CHAR_initSeekGraphicNumberFromString(); +int CHAR_seekGraphicNumberFromString( char* string ); + + + +/*====================平乓仿及赓渝袄楮溢====================*/ +BOOL CHAR_getInitElderPosition( Char* ch,int hometown); +BOOL CHAR_getElderPosition( int elderindex, int* fl, int* x, int* y ); + +void CHAR_setInitValues( Char* ch ); + + +/*==================== 衬匏 楮溢====================*/ +typedef enum +{ + CHAR_INVAREA, + CHAR_CANNOTDROPAREA, + CHAR_CANNOTMAGICAREA, + CHAR_AREAKIND_NONE, +}CHAR_AREAKIND; + +BOOL CHAR_initInvinciblePlace( char* filename ); +BOOL CHAR_isCannotMagicArea( int floor , int x, int y, int magicnum ); +BOOL CHAR_initAppearPosition( char* filename ); +BOOL CHAR_isInvincibleArea( int floor , int x, int y ); +BOOL CHAR_isAppearPosition( int floor, int *x, int *y); +BOOL CHAR_isCannotDropArea( int floor , int x, int y ); + + +/* 赢 楮溢 */ +BOOL CHAR_ElderSetPosition( int elderindex ,int fl,int x ,int y); + + + +/************************************************* +酵烂伊矛伙失永皿质 +*************************************************/ + + +int GetEnemyExp( int level ); + +int CHAR_GetLevel(); +int CHAR_GetLevelExp( int charaindex, int level ); +int CHAR_GetOldLevelExp( int level); + +int CHAR_LevelUpCheck( int charaindex , int toindex); + +int CHAR_PetLevelUp( int petindex ); + +BOOL CHAR_checkFaceImageNumber( int imagenumber, int faceimagenumber); +BOOL CHAR_checkPlayerImageNumber( int imagenumber); + +int CHAR_PetTakeLevelUp( int petindex, int lv); //强制宠物升级 +int CHAR_PetTakeDrop( int petindex, int floor, int ox, int oy); //强制丢弃宠物升级 + +#ifdef _NPC_FUSION +int PETFUSION_FusionPetSub( int charaindex, int Subindex1, int Subindex2, int *work, int *skill); +BOOL PETFUSION_FusionPetMain( int charaindex, int Mainindex, int *work, int *skill); +BOOL PETFUSION_DelPet( int toindex, int Mainindex, int Subindex1, int Subindex2, int flg); +int PETFUSION_Evolution( int charaindex, int petindex); +#endif +int PETTRANS_PetTransManStatus( int toindex, int petindex1, int petindex2); +#ifdef _PET_2TRANS +int NPC_PetTransManGetAns( int total1, int total2, int LV, int rank, int tran); +#else +int NPC_PetTransManGetAns( int total1, int total2, int LV, int rank); +#endif //_PET_2TRANS + +#ifdef _CHIKULA_STONE +void CHAR_AutoChikulaStone( int charaindex, int Dflg); +#endif + +#ifdef _STATUS_WATERWORD //水世界状态 +void CHAR_CheckWaterStatus( int charaindex); +#endif + +int CHAR_findSurplusPetBox( int charaindex ); + +#ifdef _USER_EXP_CF +void setNeedLevelUpTbls(int level,int exp); +void setMaxLevel(int level); +#endif + +#endif \ No newline at end of file diff --git a/gmsv/include/char_event.h b/gmsv/include/char_event.h new file mode 100644 index 0000000..e48e1d3 --- /dev/null +++ b/gmsv/include/char_event.h @@ -0,0 +1,31 @@ +#ifndef __CHAR_EVENT_H__ +#define __CHAR_EVENT_H__ + +#include "char_base.h" + +void CHAR_allpostwalk( int index ); +BOOL CHAR_allprewalk( int index,int* dir,int* mode); + +void CHAR_recoveryStatus( int charaindex ); +void CHAR_loopFunc( int index ); +void CHAR_playerWatchfunc( int meindex, int moveindex, CHAR_ACTION act, + int x, int y, int dir, int* opt, int optlen ); + +void CHAR_sendWallDamage( int charaindex,int x, int y, int damage ); +void CHAR_playerresurrect( int charaindex, int hp ); + +int CHAR_die( int charaindex ); +void CHAR_playerTalkedfunc( int charaindex, int talkindex,char* message, + int color, int channel ); + +void CHAR_recoveryStatus( int charaindex ); +BOOL CHAR_makeCADefaultString( int objindex,char* buf,int buflen, int act ); +BOOL CHAR_makeCAOPT1String( int objindex,char* buf, + int buflen, int act,int opt1 ); +BOOL CHAR_makeCAOPT3String( int objindex,char* buf, + int buflen, int act,int opt1,int opt2,int opt3 ); +#ifdef _STREET_VENDOR +BOOL CHAR_makeCAOPTString(int objindex,char* buf,int buflen,int act,char *string); +#endif + +#endif diff --git a/gmsv/include/char_talk.h b/gmsv/include/char_talk.h new file mode 100644 index 0000000..bd51d58 --- /dev/null +++ b/gmsv/include/char_talk.h @@ -0,0 +1,24 @@ +#ifndef __CHAR_TALK_H__ +#define __CHAR_TALK_H__ + +#include "common.h" +#include "util.h" +#include "net.h" + + +void CHAR_getMessageBody(char* message, char* kind, int kindlen, + char** body); + +#ifdef _GM_SIGUSR2 + typedef void (*CHATMAGICFUNC2)(int,char*);//功能相同typedef void (*CHATMAGICFUNC)(int,char*); + CHATMAGICFUNC2 gm_CHAR_getChatMagicFuncPointer(char* name,BOOL isDebug); +#endif + +int CHAR_getChatMagicFuncLevel(char* name,BOOL isDebug); +int CHAR_getChatMagicFuncNameAndString( int ti, char* name, char *usestring, int level, BOOL isDebug); +int CHAR_getChatMagicFuncMaxNum( void); + +void OneByOneTkChannel ( int fd , char *tmp1 , char *tmp2 , int color) ; + + +#endif diff --git a/gmsv/include/chatmagic.h b/gmsv/include/chatmagic.h new file mode 100644 index 0000000..36a384c --- /dev/null +++ b/gmsv/include/chatmagic.h @@ -0,0 +1,256 @@ +#ifndef __CHATMAGIC_H__ +#define __CHATMAGIC_H__ +#include "version.h" + +void CHAR_CHAT_DEBUG_hp( int charindex , char *message ); +void CHAR_CHAT_DEBUG_mp( int charindex , char *message ); +void CHAR_CHAT_DEBUG_setmp( int charindex , char *message ); +void CHAR_CHAT_DEBUG_str( int charindex , char *message ); +void CHAR_CHAT_DEBUG_dex( int charindex , char *message ); +void CHAR_CHAT_DEBUG_tgh( int charindex , char *message ); +void CHAR_CHAT_DEBUG_vital( int charindex , char *message ); +void CHAR_CHAT_DEBUG_luck( int charindex , char *message ); +void CHAR_CHAT_DEBUG_gold( int charindex , char *message ); +void CHAR_CHAT_DEBUG_additem( int charindex , char *message ); +void CHAR_CHAT_DEBUG_metamo( int charindex , char *message ); +void CHAR_CHAT_DEBUG_warp( int charindex , char *message ); +void CHAR_CHAT_DEBUG_info( int charindex , char *message ); +void CHAR_CHAT_DEBUG_sysinfo( int charindex , char *message ); +void CHAR_CHAT_DEBUG_announce(int charindex , char *message ); +void CHAR_CHAT_DEBUG_level( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_delitem( int charindex , char *message ); +void CHAR_CHAT_DEBUG_superman( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_battlein( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_battleout( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_petmake( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_enemyrestart( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_s_gb( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_s_gu( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_s_tame( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_fieldatt( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_s_ren( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_s_geki( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_s_hai( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_j_state( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_battlewatch( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_eventclean( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_eventsetend( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_eventsetnow( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_debug( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_exp( int charindex , char *message ); +void CHAR_CHAT_DEBUG_dp( int charindex , char *message ); +void CHAR_CHAT_DEBUG_setTrans( int charaindex, char *message); +void CHAR_CHAT_DEBUG_getuser(int charindex ,char *message);//ttom +1 14/11/2000 +void CHAR_CHAT_DEBUG_shutup(int charindex ,char *message);//ttom 22/11/2000 +void CHAR_CHAT_DEBUG_waeikick( int charindex, char* message );//ttom 12/02/2000 +void CHAR_CHAT_DEBUG_effect( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_jail( int charindex, char* message );//ttom 01/11/2001 +void CHAR_CHAT_DEBUG_shutupall(int charindex ,char *message);//ttom 02/01/2001 +void CHAR_CHAT_DEBUG_send(int charindex ,char *message);//ttom 02/01/2001 +void CHAR_CHAT_DEBUG_noenemy(int charaindex, char *message); +void CHAR_CHAT_DEBUG_loginannounce(int charaindex, char* message); // Arminius 7.12 login announce +void CHAR_CHAT_DEBUG_deletepet(int charaindex, char* message); // Robin 0720 +void CHAR_CHAT_DEBUG_deleteitem(int charaindex, char* message); // Robin 0720 +void CHAR_CHAT_DEBUG_checklock(int charaindex, char* message); // Arminius 7.25 +void CHAR_CHAT_DEBUG_unlock(int charaindex, char* message); +void CHAR_CHAT_DEBUG_unlockserver(int charaindex, char* message); +void CHAR_CHAT_DEBUG_fixfmdata(int charaindex, char* message); // CoolFish: GM Family 2001/7/31 +void CHAR_CHAT_DEBUG_shutdown(int charaindex, char* message); // Robin 1008 +void CHAR_CHAT_DEBUG_manorpk(int charaindex, char *message); + +void CHAR_CHAT_DEBUG_watchevent( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_fixfmpk(int charaindex, char *message); +void CHAR_CHAT_DEBUG_reloadmsip( int charaindex, char *message); +void CHAR_CHAT_DEBUG_cleanfreepet(int charaindex, char *message); +void CHAR_CHAT_DEBUG_engineer( int charindex, char *message); +void CHAR_CHAT_DEBUG_waeikickall( int charindex, char* message ); +void CHAR_CHAT_DEBUG_remserver( int charaindex, char *message ); +void CHAR_CHAT_DEBUG_showMem(int charaindex, char *message); +void CHAR_CHAT_DEBUG_playerspread( int charaindex, char *message); +void CHAR_CHAT_DEBUG_reset( int charaindex, char* message ); + +#ifdef _GMRELOAD +void CHAR_CHAT_DEBUG_gmreload(int charaindex, char *message); +#endif +#ifdef _CHAR_PROFESSION // WON ADD 人物职业 +void CHAR_CHAT_DEBUG_addsk( int charaindex, char *message ); +void CHAR_CHAT_DEBUG_delsk( int charaindex, char *message ); +#endif +#ifdef _TEST_PETCREATE +void CHAR_CHAT_DEBUG_createpet( int charaindex, char *message ); +void TEST_CreatPet( ); +#endif +void CHAR_CHAT_DEBUG_cleanfloor( int charaindex, char *message); + +#ifdef _GAMBLE_BANK +void CHAR_CHAT_DEBUG_setgamblenum( int charaindex, char *message ); +#endif +#ifdef _WAEI_KICK +void CHAR_CHAT_DEBUG_gmkick( int charindex, char* message); +#endif +// WON ADD 修正族长问题 +void CHAR_CHAT_DEBUG_fixfmleader(int charaindex, char *message); + +// WON ADD 当机指令 +void CHAR_CHAT_DEBUG_crash(int charaindex, char *message); + +#ifdef _PETSKILL_SETDUCK +void CHAR_CHAT_DEBUG_SetDuck( int charaindex, char *message); +#endif +#ifdef _TYPE_TOXICATION +void CHAR_CHAT_DEBUG_Toxication( int charaindex, char *message); +#endif +#ifdef _ACTION_BULLSCR +void CHAR_CHAT_DEBUG_setascore(int charindex, char *message); +void CHAR_CHAT_DEBUG_getascore(int charindex, char *message); +#endif +#ifdef _NEW_PLAYERGOLD +void CHAR_CHAT_DEBUG_acnewplayer(int charaindex, char *message); +void CHAR_CHAT_DEBUG_loadnewplayer( int charaindex, char*message ); +#endif +#ifdef _SEND_EFFECT // WON ADD AC送下雪、下雨等特效 +void CHAR_CHAT_DEBUG_sendeffect(int charaindex, char *message); +#endif +#ifdef _TEST_DROPITEMS +void CHAR_CHAT_DEBUG_dropmypet( int charindex, char *message ); +void CHAR_CHAT_DEBUG_dropmyitem( int charindex , char *message ); +#endif + +#ifdef _ACTION_GMQUE +void CHAR_CHAT_DEBUG_cleanqute( int charaindex, char *message); +#endif + +#ifdef _CHAR_PROFESSION // WON ADD 人物职业 +void CHAR_CHAT_DEBUG_show_profession( int charaindex, char*message ); +void CHAR_CHAT_DEBUG_set_regist( int charaindex, char*message ); +#endif + +void CHAR_CHAT_DEBUG_checktrade( int charaindex, char*message); + +void CHAR_CHAT_DEBUG_checktime( int charaindex, char *message); +void CHAR_CHAT_DEBUG_samecode( int charaindex, char *message); +void CHAR_CHAT_DEBUG_silent(int charindex ,char *message); +void CHAR_CHAT_DEBUG_help( int charindex, char *message); +#ifdef _EQUIT_ARRANGE +void CHAR_CHAT_DEBUG_arrange( int charindex , char *message ); +#endif + +#ifdef _EQUIT_SEQUENCE +void CHAR_CHAT_DEBUG_sequence( int charindex , char *message ); +#endif + +#ifdef _GM_IDENTIFY +void CHAR_CHAR_DEBUG_gmidentify( int charindex , char *message ); +#endif + +void CHAR_CHAT_DEBUG_showtemp( int charaindex, char*message ); + +#ifdef _EQUIT_NEGLECTGUARD +void CHAR_CHAT_DEBUG_setneguard( int charaindex, char* message ); +#endif + +#ifdef _DEATH_CONTEND +void CHAR_CHAT_DEBUG_updatepklist( int charaindex, char* message ); +#endif + +void CHAR_CHAT_DEBUG_petlevelup( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_petexpup( int charaindex, char* message ); + +void CHAR_CHAT_DEBUG_reloadpkteamlist( int charaindex, char *message); +void CHAR_CHAT_DEBUG_setBattle( int charaindex, char *message ); + + +#ifdef _CHAR_POOLITEM +void CHAR_CHAT_DEBUG_saveditem(int charaindex, char *message); +void CHAR_CHAT_DEBUG_insertditem(int charaindex, char *message); +void CHAR_CHAT_DEBUG_ShowMyDepotItems( int charaindex, char *message ); +void CHAR_CHAT_DEBUG_InSideMyDepotItems( int charaindex, char *message ); +#endif + +#ifdef _CHAR_POOLPET +void CHAR_CHAT_DEBUG_savedpet(int charaindex, char *message); +void CHAR_CHAT_DEBUG_insertdpet(int charaindex, char *message); +void CHAR_CHAT_DEBUG_ShowMyDepotPets( int charaindex, char *message ); +void CHAR_CHAT_DEBUG_InSideMyDepotPets( int charaindex, char *message ); +#endif + +#ifdef _DEATH_FAMILY_GM_COMMAND // WON ADD 家族战GM指令 +void CHAR_CHAR_DEBUG_reloadfm( int charaindex, char* message ); +void CHAR_CHAR_DEBUG_fmpk( int charaindex, char* message ); +void CHAR_CHAR_DEBUG_fmpk_clean( int charaindex, char* message ); +#endif + +#ifdef _NEW_MANOR_LAW +void CHAR_CHAT_DEBUG_set_momentum( int charaindex, char* message ); +void CHAR_CHAT_DEBUG_set_manor_owner( int charindex, char* message ); +void CHAR_CHAT_DEBUG_set_schedule_time( int charindex, char* message ); +#endif + +#ifdef _ANGEL_SUMMON +void CHAR_CHAT_DEBUG_angelinfo(int charindex ,char *message); +void CHAR_CHAT_DEBUG_angelclean(int charindex ,char *message); +void CHAR_CHAT_DEBUG_angelcreate(int charindex ,char *message); +void CHAR_CHAT_DEBUG_missionreload(int charindex ,char *message); +#endif + +void CHAR_CHAT_DEBUG_itemreload(int charindex ,char *message); + +void CHAR_CHAT_DEBUG_skywalker(int charaindex ,char *message); + +#ifdef _ITEM_ADDEXP +void CHAR_CHAT_DEBUG_itemaddexp(int charaindex ,char *message); +#endif + +#ifdef _DEF_FMFREETIME +void CHAR_CHAT_DEBUG_fmfreetime(int charaindex,char *message); +#endif + +#ifdef _DEF_GETYOU +void CHAR_CHAT_DEBUG_getyou(int charaindex,char *message); +#endif + +#ifdef _DEF_NEWSEND +void CHAR_CHAT_DEBUG_newsend(int charindex ,char *message); +#endif + +#ifdef _DEF_SUPERSEND +void CHAR_CHAT_DEBUG_supersend(int charindex ,char *message); +#endif + +#ifdef _FONT_SIZE +void CHAR_CHAT_DEBUG_fsize(int charindex ,char *message); +#endif + +#ifdef _JOBDAILY +void CHAR_CHAT_DEBUG_rejobdaily(int charindex ,char *message); +#endif + +#ifdef _RACEMAN +void CHAR_CHAT_DEBUG_changeask(int charindex ,char *message); +#endif + +#ifdef _CREATE_MM_1_2 +void CHAR_CHAT_DEBUG_MM(int charaindex , char *message ); +#endif + +#ifdef _SendTo +void CHAR_CHAT_DEBUG_Sendto( int charaindex , char *message ); +#endif + +void CHAR_CHAT_printcount( int charaindex, char* message ); + +#ifdef _GM_ITEM +void CHAR_CHAT_DEBUG_GMFUNCTION( int charindex , char *message ); +#endif + +#ifdef _GM_RIDE +void CHAR_CHAT_DEBUG_SETRIDE( int charindex , char *message ); +void CHAR_CHAT_DEBUG_MVRIDE( int charindex , char *message ); +#endif + +#ifdef _LOCK_IP +void CHAR_CHAT_DEBUG_LOCK_IP( int charindex , char *message ); +void CHAR_CHAT_DEBUG_DISPLAY_LOCK_IP( int charindex , char *message ); +#endif + +#endif \ No newline at end of file diff --git a/gmsv/include/chatroom.h b/gmsv/include/chatroom.h new file mode 100644 index 0000000..b2ecc65 --- /dev/null +++ b/gmsv/include/chatroom.h @@ -0,0 +1,57 @@ +#ifndef __CHATROOM_H__ +#define __CHATROOM_H__ +#include "version.h" + +#define MAX_CHATROOM 10 +#define MAX_PPLINROOM 100 + +#ifdef _UNIVERSE_CHATROOM + +typedef struct _tagChatRoomCharaList{ + char cdkey[256]; + char name[256]; + char own[256]; + int fd; + int use; +}CRCharaList; + +typedef struct _tagUniChatRoom +{ + int use; + int charanum; + int masindex; + int masfd; + CRCharaList charalist[MAX_PPLINROOM]; + char chatname[32]; +}UniChatRoomlist; + +void resetChat_users( int chat, int ti); +void InitChatRoom( void ); +void ChatRoom_List ( int fd ); +int ChatRoom_getfree( void); +void saac_ChatRoom_recvall ( int fd , char *result, char *data, int charaindex, int clifdid); +void ChatRoom_Leave( int charaindex); +void ChatRoom_Destroy ( char *data); +void ChatRoom_recvall( int fd, char *data); +void CHATROOM_getChatRoomList( void); + +#else + +void InitChatRoom ( void ) ; +void ChatRoom_List ( int fd ); +BOOL ChatCheck_BeMaster( int myindex, int chatnum); +BOOL ChatCheck_Free( int myindex); +BOOL ChatRoom_Create ( int myindex , char *message); +BOOL ChatRoom_Destroy ( int myindex ) ; +void ChatRoom_Kick ( int myindex , int toindex ) ; +void ChatRoom_Make ( int myindex , int toindex ) ; +void ChatRoom_Leave ( int myindex ) ; +void ChatRoom_Join ( int myindex , int num ) ; +void ChatRoom_Agree ( int myindex , int toindex , int YesNo ) ; +void ChatRoom_Message ( int myindex , char *message ) ; +void ChatRoom_Refresh ( int Num ) ; +void ChatRoom_recvall ( int fd , char *data ) ; + +#endif + +#endif diff --git a/gmsv/include/common.h b/gmsv/include/common.h new file mode 100644 index 0000000..7a9725d --- /dev/null +++ b/gmsv/include/common.h @@ -0,0 +1,65 @@ +#ifndef __COMMON_H__ +#define __COMMON_H__ + +#include +#include + +/* MACROS */ +#define RETURNFALSEIFFALSE(x) if(!x)return FALSE; +#define EXITWITHEXITCODEIFFALSE(x,code) if(!x)exit(code); +#ifdef __GNUC__ +#define print(format,arg...) fprintf( stderr, format ,##arg) +#define fprint(format,arg...) fprintf( stderr, "%s:%d " format , __FILE__ , __LINE__ , ##arg) +#endif +#define debug(x,y) fprintf( stderr, #x " = %" #y "\n" , x) +#define arraysizeof( x ) (sizeof(x)/sizeof(x[0])) + +#define errorprint {extern int errno;fprint( "%s\n" ,strerror(errno));} + +#define BACKSLASH '\\' +#define NEWLINE '\n' +#define TAB '\t' +#define SPACE ' ' + +/*绁ㄥ強 define 鏂规洶鍏滆潏鍗炲厑鏈 */ +/*#define min( x,y ) ((x)>(y)?(y):(x)) + #define max( x,y ) ((x)>(y)?(x):(y))*/ +#define min( x,y ) ({typeof(x) __x=(x),__y=(y);(__x < __y) ? __x : __y; }) +#define max( x,y ) ({typeof(x) __x=(x),__y=(y);(__x < __y) ? __y : __x; }) +#define swap( x,y )({typeof(x) __x=(y);(y)=(x);(x)=__x;}) +#define SUCCESSFUL "successful" +#define FAILED "failed" + +#ifdef _BAD_PLAYER // WON ADD 閫佸潖鐜╁鍘诲叧 +#define BADPLAYER "badplayer" +#endif + +#define LOCK 1 +#define UNLOCK 0 + +#define STRINGBUFSIZ 4096 + +#define OPEN {FILE* f;f=fopen("a.txt","a"); +#define CLOSE fclose(f);} + +#define time_diff_us(new,old) ((unsigned)( (new.tv_sec - old.tv_sec)*1000000 + ( new.tv_usec - old.tv_usec ) )) + + + + +extern int snprintf (char* , size_t, const char* , ...) +#ifdef __GNUC__ + __attribute__ ((format (printf,3,4))); +#else + ; +#endif + +#define ON 1 +#define OFF 0 +#define BOOL int +#define FALSE 0 +#define TRUE 1 +#define INLINE inline +#define USE_MTIO 0 + +#endif diff --git a/gmsv/include/configfile.h b/gmsv/include/configfile.h new file mode 100644 index 0000000..a5e9ea4 --- /dev/null +++ b/gmsv/include/configfile.h @@ -0,0 +1,276 @@ +#ifndef __CONFIGFILE_H__ +#define __CONFIGFILE_H__ + +#include "common.h" + +#undef EXTERN +#ifdef __CONFIGFILE_C__ +#define EXTERN +#else /* __CONFIGFILE_C__ */ +#define EXTERN extern +#endif /* __CONFIGFILE_C__ */ + +// Arminius 7.12 login announce +extern char announcetext[8192]; +void AnnounceToPlayer(int charaindex); +// Robin 0720 +void AnnounceToPlayerWN(int fd); +void LoadAnnounce(void); + +#ifdef _PET_TALKPRO + #define PETTALK_MAXID 8 + typedef struct { + int ID; + char DATA[10240*10]; //1M + }PTALK; + extern PTALK pettalktext[PETTALK_MAXID]; + void LoadPetTalk(void); +#else + +extern char pettalktext[4096]; +void LoadPetTalk(void); +#endif + +#ifdef _GAMBLE_BANK +#define GAMBLEBANK_ITEMSMAX 100 +#define DEFEND_ITEMSMAX 40 +typedef struct REGAMBLEBANKITEMS { + char name[128]; + int Gnum; + int ItemId; + int type; +}GAMBLEBANK_ITEMS; + +extern GAMBLEBANK_ITEMS GB_ITEMS[GAMBLEBANK_ITEMSMAX]; + +void Load_GambleBankItems( void); +#endif + +#ifdef _CFREE_petskill +#define PETSKILL_CODE 300 +typedef struct REPETSKILL_CODES { + char name[128]; + int TempNo; + int PetId; + char Code[256]; +}PETSKILL_CODES; + +extern PETSKILL_CODES Code_skill[PETSKILL_CODE]; +void Load_PetSkillCodes( void); +#endif + +#ifdef _BLACK_MARKET +struct BlackMarketItem { + char iName[128]; + int iGraphicsNum; + int iId[4][3]; + int iCondition[4]; + int GCondition; +}; +#define BMIMAX 1000 +struct BlackMarketItem BMItem[BMIMAX]; +int BMINum; +int BMSellList[12]; +#endif + +#ifdef _GMRELOAD +#define GMMAXNUM 100 +struct GMINFO +{ + char cdkey[24]; + int level; +}; +extern struct GMINFO gminfo[GMMAXNUM]; +#endif + +BOOL readconfigfile( char* filename ); + +void defaultConfig( char* argv0 ); +char* getProgname( void ); +char* getConfigfilename( void ); +void setConfigfilename( char* newv ); + +unsigned int getDebuglevel( void ); +unsigned int setDebuglevel( unsigned int newv ); +unsigned int getMemoryunit( void ); +unsigned int getMemoryunitnum( void ); +char* getAccountservername( void ); +unsigned short getAccountserverport( void ); +char* getAccountserverpasswd( void ); +char* getGameservername( void ); + +#ifdef _M_SERVER +char* getmservername(void); +void setmservername( char *msname); +unsigned int getmserverport(void); +void setmserverport( int port); +#endif + +#ifdef _NPCSERVER_NEW +char *getnpcserveraddr(void); +unsigned int getnpcserverport(void); +void NS_setAddressAndPort( char *address, int nport); +#endif + +unsigned short getPortnumber( void ); + +int getServernumber( void ); +int getReuseaddr( void ); +int getNodelay( void ); +int getLogWriteTime(void); +int getLogIOTime( void); +int getLogGameTime(void); +int getLogNetloopFaster(void); +int getSaacwritenum( void ); +void setSaacwritenum( int num ); +int getSaacreadnum( void ); +void setSaacreadnum( int num ); + +unsigned int getFdnum( void ); +unsigned int getPetcharnum( void ); +unsigned int getOtherscharnum( void ); +unsigned int getObjnum( void ); +unsigned int getItemnum( void ); +unsigned int getBattlenum( void ); + +char* getTopdir( void ); +char* getMapdir( void ); +char* getMaptilefile( void ); +char* getBattleMapfile( void ); +char* getItemfile( void ); +char* getInvfile( void ); +char* getAppearfile( void ); +char* getEffectfile( void ); +char* getTitleNamefile( void ); +char* getTitleConfigfile( void ); +char* getLsgenlogfilename( void ); +char* getStoredir( void ); +#ifdef _STORECHAR +char* getStorechar( void ); +#endif +char* getNpcdir( void ); +char* getLogdir( void ); +char* getLogconffile( void ); +char* getChatMagicPasswd( void ); +unsigned int getChatMagicCDKeyCheck( void ); + + +unsigned int getFilesearchnum( void ); +unsigned int getNpctemplatenum( void ); +unsigned int getNpccreatenum( void ); +unsigned int getWalksendinterval( void ); +void setWalksendinterval( unsigned int ); +unsigned int getCAsendinterval_ms( void ); +void setCAsendinterval_ms( unsigned int ); +unsigned int getCDsendinterval_ms( void ); +void setCDsendinterval_ms( unsigned int ); +unsigned int getOnelooptime_ms( void ); +void setOnelooptime_ms( unsigned int ); +unsigned int getCharSavesendinterval( void ); +void setCharSavesendinterval( unsigned int interval); +unsigned int getAddressbookoffmsgnum( void ); +unsigned int getProtocolreadfrequency( void ); +unsigned int getAllowerrornum( void ); +unsigned int getLogHour( void ); +unsigned int getBattleDebugMsg( void ); +void setBattleDebugMsg( unsigned int ); + +char* getEncountfile( void ); +char* getEnemyfile( void ); +char* getGroupfile( void ); +char* getEnemyBasefile( void ); +char* getMagicfile( void ); +#ifdef __ATTACK_MAGIC + +char* getAttMagicfileName( void ); + +#endif + +char* getPetskillfile( void ); +char *getItematomfile( void ); +char *getQuizfile( void ); + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 +char* getProfession( void ); +#endif + +unsigned int getPetdeletetime( void ); +void setPetdeletetime( unsigned int interval ); + +unsigned int getItemdeletetime( void ); +void setItemdeletetime( unsigned int interval ); +//ttom add this because the second have this function +//unsigned int getAcwriteSize( void ); + +#ifdef _DEL_DROP_GOLD +unsigned int getGolddeletetime( void ); +void setGolddeletetime( unsigned int interval ); +#endif + +unsigned int setEncodeKey( void ); +unsigned int setAcWBSize( void ); +//ttom end + +// CoolFish: +2 2001/4/18 +unsigned int getAcwriteSize( void ); +unsigned int getErrUserDownFlg( void ); + +// Arminius 7.24 manor pk +char* getGameserverID( void ); +unsigned short getAllowManorPK( void ); + +// Terry 2001/10/03 service ap +char* getApID(void); +unsigned short getApPort(void); +int getLoopTime(void); +int getEnableService(void); + +#ifdef _GMRELOAD +char* getGMSetfile(void); +BOOL LoadGMSet(char *filename); +#endif + +#ifdef _ITEM_QUITPARTY +char* getitemquitparty( void ); +#endif +#ifdef _BLACK_MARKET +char* getBMItemFile(void); +BOOL LoadBMItem( char* filename ); +#endif + +#ifdef _AUCTIONEER +char* getAuctiondir(void); +#endif + +#ifdef _MUSEUM +int getMuseum(void); +#endif + +#endif + +#ifdef _NEW_PLAYER_CF +int getNewplayertrans( void ); +int getNewplayerlv( void ); +int getNewplayergivepet( unsigned int index ); +void setNewplayergivepet( unsigned int index ,unsigned int interval); +int getNewplayerpetlv( void ); +unsigned int getNewplayergivegold( void ); +#endif + +#ifdef _USER_EXP_CF +BOOL LoadEXP( char* filename ); +char* getEXPfile( void ); +int getNeedLevelUpTbls( int level ); +int getMaxLevel( void ); +int getYBLevel( void ); +#endif + +#ifdef _LOCK_IP +char* getLockipPath( void ); +int loadLockip( char* filename ); +int saveLockip( void ); +int getMaxLockip( void ); +int cmpLockip( int index, int a, int b, int c, int d, int login ); +int addLockip( int a, int b ,int c ,int d, int locktime ); +char *dispalyLockip( int index ); +#endif diff --git a/gmsv/include/correct_bug.h b/gmsv/include/correct_bug.h new file mode 100644 index 0000000..8c50976 --- /dev/null +++ b/gmsv/include/correct_bug.h @@ -0,0 +1,31 @@ +#ifndef __CORRECT_BUG_H__ +#define __CORRECT_BUG_H__ + +/* ---------------------- (未开放区) ---------------------------*/ +//#define _NO_WARP // 阻档进入英雄岛不限等及随意进出入四大村庄 code:建军 (不可开放) +//#define _FAMILYBANKSTONELOG // Syu ADD 新增家族银行存取Log (SAAC的要一起开) +#define _kr_ip // WON ADD 不锁gm指令ip +//#define _WON_TEST // WON TEST +//#define _CHANGEITEMUSE // Syu ADD 调整战斗中使用料理设定 +/* ----------------------- (待测区) ---------------------------*/ +//#define _CRASHSTOREPETMAIL // Syu ADD 修正宠物邮件 +//#define _SYUTESTBATTLE // Syu ADD + +/* ----------------------- (开放区) ---------------------------*/ +#define _add_item_log_name // WON ADD 在item的log中增加item名称 +#define _PETSKILLBUG // Syu ADD 修正宠物问题 +#define _FIXWOLF // Syu ADD 修正狼人变身Bug +#define _FIXMAGICBUG // Syu ADD 修正魔法熟练、抗性暴掉问题 +#define _FIXPETFALL // Syu ADD 修正落马术 +#define _FIX_ITEMRELIFE // WON ADD 修正替身娃娃问题 +#define _FIX_SPEED_UPLEVEL // WON ADD 修正加速 +#define _FIX_PETMAIL // WON ADD 修正宠邮 +#define _FIX_EQUIP_ITEM // WON ADD 修正道具需重新装备 +#define _ADD_PETMAIL_NUM // WON ADD 宠邮数量GM指令 +#define _FIX_equipNoenemy // WON ADD 修正太阳神首饰 +#define _FIX_PETMAIL2 // WON ADD 修正宠邮2 +#define _FIXITEMANISHOW // Syu ADD 修正回合性补血装备道具骑宠时宠物不显示动画问题 +#define _FIX_GP_PET_SKILL // WON ADD 修正gp宠会落马术 + + +#endif diff --git a/gmsv/include/deathcontend.h b/gmsv/include/deathcontend.h new file mode 100644 index 0000000..672b024 --- /dev/null +++ b/gmsv/include/deathcontend.h @@ -0,0 +1,192 @@ +#include "version.h" + +#ifdef _DEATH_CONTEND + +//团队人物名单 +typedef struct +{ + int use; + char cdkey[64]; + char name[64]; +}PkTeamMans; +//战斗纪录 +typedef struct +{ + int use; + int teamnum; + int flg; //0 1 +}BattleHistorys; + +#define MAXTEAMMANNUM 5 //队伍最高人数 +#define MAXBATTLENUM 100 //队伍最高战斗纪录 +#define MAXTEAMNUM 1000 + +#define DEFMAXBATTLENUM 50 //最高决斗场次 +#define DEFWINSCORE 90 +#define DEFLOSERATE 0.4 +//决斗参赛队伍info +typedef struct _tagPkTeamLists +{ + int use; //flg + int teamnum; //队伍序号 + char teamname[64]; //队伍名称 + char pathdir[64]; //队伍资料目录 + char leadercdkey[64]; //队长CDKEY + int win; //胜 + int lost; //负 + int battleplay; //总场次 + int score; + int inside; //录取旗标 + int read; + PkTeamMans MyTeamMans[MAXTEAMMANNUM]; + BattleHistorys BHistory[MAXBATTLENUM]; +}PkTeamLists; + +#define MAXJOINTEAM 40 +#define MAXWATCHMAP 16 +typedef struct +{ + int use; + int teamnum; + char cdkey[256]; + char name[256]; + int toindex; + int fd; +}JoinTeamList; + +typedef struct _tagPKProcedureRow +{ + int use; + int time; + int type; + JoinTeamList Team[2]; +}PKProcedures; + +enum{ + PKTYPE_NONE=0, //无 + PKTYPE_WAIT, //等待其他队伍加入 + PKTYPE_STANDBY, //准备对战等待时间 + PKTYPE_PK, //对战中 +}; + +void del_rn( char *s ); +void PKLIST_ResetOneTeamMan( int ti ); //重置队员名单 +void PKLIST_ResetOneBHistory( int ti ); //重置对战名单 +void PKLIST_ResetOnePkTeamList( int ti ); //重置参赛队伍资料 +int PKLIST_InitPkTeamList( int teamnum ); //重置 + +int PKLIST_GetPkTeamListArray( int teamnum, char *cdkey); +int PKLIST_GetPkTeamListArrayFromNum( int teamnum); +//确认重复约战 +BOOL PKLIST_CHECKPkTeamSame( int teamnum, int charaindex, char *cdkey, int toteamnum ); +//确认对战场数 +int PKLIST_CHECKPkTeamNew( int teamnum, int charaindex, char *cdkey ); + +//LOAD DATA +BOOL PKLIST_LoadPkTeamListDataSub( int ti, char *data); +BOOL PKLIST_LoadPkTeamListDataMyTeamMans( int ti, char *data); +BOOL PKLIST_LoadPkTeamListDataBHistory( int ti, char *data); +//BOOL PKLIST_LoadPkTeamListData( char *data); //处理ac送来的 pklist +BOOL PKLIST_LoadPkTeamListData(void); // 改成读档 +void PKLIST_SavePkTeamListData(void); +void PKLIST_LoadInitPkTeamListData(void); // 读取最原始的参赛名单 +void PKLIST_UpData(char *mycdkey,char *tocdkey,int menum,int tonum,int winer,int flg); +int PKLIST_GetOneBHistory( int ti ); +int PKLIST_SetOneBHistory( int ti, int hi, int use, int teamnum, int flg ); +int PKLIST_UpdateOnePkTeamData( int ti, int forti, int winerflg); + +void PKLIST_InsertTeamNum( int charaindex ); +BOOL PKLIST_GetTeamLeaderCdkey( int teamnum, char *buf); +void PKLIST_ShowPkListTeamData( void); + +int NPC_PKLIST_Finish_Exit( int menum, int tonum, int winside, int battlemap); + + +BOOL PKLIST_HandleChartsMess( int fd, char *data, int type, int flg); +BOOL PKLIST_GetChartsListData( int ti, char *data, int sizes ); +BOOL PKLIST_GetMyPKListTeamData( int teamnum, char *data, int sizes ); + + +/* +BOOL PKLIST_CheckPKSameTeam( int charaindex ); +BOOL PKLIST_JoinPKProcedures( int charaindex ); +void PKLIST_DelPKProcedures( int ti, int side ); +void PKLIST_CheckPKProcedures( void ); + +void PKLIST_CheckPKProcedures_PKTYPEWAIT( int ti); +void PKLIST_CheckPKProcedures_PKTYPESTANDBY( int ti); +*/ + +//赛程 +void PKLIST_DelPKProcedures( int ti, int side, int type); +BOOL PKLIST_CheckPklistInServerMap( int ti, int side); +BOOL PKLIST_CheckPKSameTeam( int charaindex ); +BOOL PKLIST_CheckPKReapetTeam( int menum, int tonum); +BOOL PKLIST_JoinPKProcedures( int charaindex ); +void PKLIST_CheckTeamBeEnable( void); +void PKLIST_warp( int ti, int side, int fl, int x, int y ); +void NPC_PKLIST_PlayerLogout_Exit( int charaindex ); +int PKLIST_GetPKProcedureArray( int menum ); + +BOOL PKLIST_CheckLOCKTeam( int menum); +void PKLIST_LOCKTeam( int menum); +void PKLIST_UNLOCKTeam( int menum); +void PKLIST_Sort_PKListSort( void); + +//正式赛 +typedef struct _tagArrangeBattle +{ + int use; + int fl; + int code; + int teamnum; + int type; //0 NULL // 1 in battle + int time; + char teamname[256]; + int toindex; + + struct _tagArrangeBattle *next[2]; + struct _tagArrangeBattle *top; +}ArrangeBattleC; + +#define MAXBAFLOOR 20 +#define MAXNOWBATTLE 128 + +#define MAXBAHEAD 16 +#define MAXBATTLEPAGE MAXJOINTEAM + +void ABATTLE_InitABattle( int maxnums ); +int ABATTLE_CreateNet( ArrangeBattleC *now, int ti, int fl, int maxfl); +void ABATTLE_ShowNet( ArrangeBattleC *now, int fl); +void ABATTLE_ShowBattlefromFl( int ti, int fl); +ArrangeBattleC *ArrangeBattleC_getNew( void); + + +BOOL ABATTLE_InsertBattle( ArrangeBattleC *aB); //排入赛程 +void ABATTLE_EnterBattle( ArrangeBattleC *aB); //入围 +void ABATTLE_EliminateBattlefromFl( ArrangeBattleC *aB);//剔除 + +BOOL ABATTLE_CheckInABattle( int ti);//确认赛程战斗状态 包含时间 +int ABATTLE_FindBattlefromFl( int ti, int fl); //找寻可加入赛程队伍组合 + +void ABATTLE_CheckBattlefromFl(int charindex, int ti,int battleindex); //确认层次是否完成 且 排置赛程 +int ABATTLE_CheckBattlefromFl_sub(int charindex, int ti, int fl,int battleindex); //确认层次是否完成 + + +ArrangeBattleC *ABATTLE_getInBattle( int teamnum); //取得赛程head form teamnum + +void ABATTLE_MakeInABattleString( void); //制作赛程字串 + +BOOL PKLIST_GetABattlelistDataString( int ti, int *tindex, int *stime, + char *buf1, char *buf2, char *buf3, int flg);//取得赛程字串 + +ArrangeBattleC *ArrangeBattleC_getInBattleArray( int ti); + + + + +void ABATTLE_RecordBattle( int ti, char *buf1, char *tstr1,char *buf2, char *tstr2); +void remove_r( char *s ); +void ABATTLE_GetRecordBattle( void); + +#endif diff --git a/gmsv/include/defend.h b/gmsv/include/defend.h new file mode 100644 index 0000000..7c701c0 --- /dev/null +++ b/gmsv/include/defend.h @@ -0,0 +1,4 @@ +#ifndef __DEFEND_H__ +#define __DEFEND_H__ + +#endif diff --git a/gmsv/include/encount.h b/gmsv/include/encount.h new file mode 100644 index 0000000..e3762f8 --- /dev/null +++ b/gmsv/include/encount.h @@ -0,0 +1,40 @@ +#ifndef __ENCOUNT_H__ +#define __ENCOUNT_H__ + +#define ENCOUNT_GROUPMAXNUM 10 + +BOOL ENCOUNT_initEncount( char* filename ); +BOOL ENCOUNT_reinitEncount( void ); +int ENCOUNT_getEncountAreaArray( int floor, int x, int y); +int ENCOUNT_getEncountPercentMin( int charaindex, int floor , int x, int y ); +int ENCOUNT_getEncountPercentMax( int charaindex, int floor , int x, int y ); +int ENCOUNT_getCreateEnemyMaxNum( int floor , int x, int y ); +int ENCOUNT_getEncountIndex( int floor , int x, int y ); +int ENCOUNT_getEncountIndexFromArray( int array ); +int ENCOUNT_getEncountPercentFromArray( int array ); +int ENCOUNT_getCreateEnemyMaxNumFromArray( int array ); +int ENCOUNT_getGroupIdFromArray( int array, int grouparray ); +int ENCOUNT_getGroupProbFromArray( int array, int grouparray ); +int ENCOUNT_getZorderFromArray( int array ); + +#ifdef _ADD_ENCOUNT // WON ADD 增加敌遭遇触发修件 +typedef struct tagENCOUNT_Table +{ + int index; + int floor; + int encountprob_min; /* 巨件市它件玄割 */ + int encountprob_max; /* 巨件市它件玄割 */ + int enemymaxnum; /* 升木分仃衬毛综月井 */ + int zorder; + int groupid[ENCOUNT_GROUPMAXNUM]; /* 弘伙□皿No */ + int createprob[ENCOUNT_GROUPMAXNUM]; /* 公及弘伙□皿及请蜇 */ + int event_now; + int event_end; + int enemy_group; // 怪物的group 编号 + RECT rect; +}ENCOUNT_Table; + +ENCOUNT_Table *ENCOUNT_table; +#endif + +#endif diff --git a/gmsv/include/enemy.h b/gmsv/include/enemy.h new file mode 100644 index 0000000..a0253f6 --- /dev/null +++ b/gmsv/include/enemy.h @@ -0,0 +1,253 @@ +#ifndef __ENEMY_H__ +#define __ENEMY_H__ + +enum +{ + E_T_SIZE_NORMAL, + E_T_SIZE_BIG, +}; + +typedef enum +{ + E_T_TEMPNO, + E_T_INITNUM, + E_T_LVUPPOINT, + E_T_BASEVITAL, + E_T_BASESTR, + E_T_BASETGH, + E_T_BASEDEX, + E_T_MODAI, + E_T_GET, + E_T_EARTHAT, + E_T_WATERAT, + E_T_FIREAT, + E_T_WINDAT, + E_T_POISON, /* 汹仁凶太卞母丢□斥 */ + E_T_PARALYSIS, /* 仄太木}1 及垫 互匹五卅中[ */ + E_T_SLEEP, /* 戽曰[垫 匹五卅中 */ + E_T_STONE, /* 檗[垫 匹五卅中 */ + E_T_DRUNK, /* 办丹[ 互票互月 */ + E_T_CONFUSION, /* 渔刭[ 猾 毛赀月 */ + E_T_PETSKILL1, + E_T_PETSKILL2, + E_T_PETSKILL3, + E_T_PETSKILL4, + E_T_PETSKILL5, + E_T_PETSKILL6, + E_T_PETSKILL7, + E_T_RARE, + E_T_CRITICAL, + E_T_COUNTER, + E_T_SLOT, + E_T_IMGNUMBER, + E_T_PETFLG, + E_T_SIZE, + E_T_ATOMBASEADD1, + E_T_ATOMFIXMIN1, + E_T_ATOMFIXMAX1, + E_T_ATOMBASEADD2, + E_T_ATOMFIXMIN2, + E_T_ATOMFIXMAX2, + E_T_ATOMBASEADD3, + E_T_ATOMFIXMIN3, + E_T_ATOMFIXMAX3, + E_T_ATOMBASEADD4, + E_T_ATOMFIXMIN4, + E_T_ATOMFIXMAX4, + E_T_ATOMBASEADD5, + E_T_ATOMFIXMIN5, + E_T_ATOMFIXMAX5, + E_T_LIMITLEVEL, // Arminius 7.30 limit level +#ifdef _PET_FUSION + E_T_FUSIONCODE, +#endif + E_T_DATAINTNUM, +}ENEMYTEMP_DATAINT; + +typedef enum +{ + E_T_NAME, + E_T_ATOMFIXNAME1, + E_T_ATOMFIXNAME2, + E_T_ATOMFIXNAME3, + E_T_ATOMFIXNAME4, + E_T_ATOMFIXNAME5, + E_T_DATACHARNUM, + +}ENEMYTEMP_DATACHAR; + +typedef enum +{ + ENEMY_ID, + ENEMY_TEMPNO, + ENEMY_LV_MIN, + ENEMY_LV_MAX, + ENEMY_CREATEMAXNUM, + ENEMY_CREATEMINNUM, + ENEMY_TACTICS, + ENEMY_EXP, + ENEMY_DUELPOINT, + ENEMY_STYLE, + ENEMY_PETFLG, /* 矢永玄卞卅月井升丹井 */ + + ENEMY_ITEM1, + ENEMY_ITEM2, + ENEMY_ITEM3, + ENEMY_ITEM4, + ENEMY_ITEM5, + ENEMY_ITEM6, + ENEMY_ITEM7, + ENEMY_ITEM8, + ENEMY_ITEM9, + ENEMY_ITEM10, + ENEMY_ITEMPROB1, + ENEMY_ITEMPROB2, + ENEMY_ITEMPROB3, + ENEMY_ITEMPROB4, + ENEMY_ITEMPROB5, + ENEMY_ITEMPROB6, + ENEMY_ITEMPROB7, + ENEMY_ITEMPROB8, + ENEMY_ITEMPROB9, + ENEMY_ITEMPROB10, + + ENEMY_DATAINTNUM, + +}ENEMY_DATAINT; + +typedef enum +{ + ENEMY_NAME, + ENEMY_TACTICSOPTION, +#ifdef _BATTLENPC_WARP_PLAYER + ENEMY_ACT_CONDITION, +#endif + ENEMY_DATACHARNUM, +}ENEMY_DATACHAR; + +typedef enum +{ + GROUP_ID, + GROUP_APPEARBYITEMID, /* 仇及失奶 丞毛 匀化中凶日请蜇允月 -1 反 骰*/ + GROUP_NOTAPPEARBYITEMID, /* 仇及失奶 丞毛 匀化中凶日请蜇仄卅中 -1 反 骰*/ + ENEMY_ID1, + ENEMY_ID2, + ENEMY_ID3, + ENEMY_ID4, + ENEMY_ID5, + ENEMY_ID6, + ENEMY_ID7, + ENEMY_ID8, + ENEMY_ID9, + ENEMY_ID10, + CREATEPROB1, + CREATEPROB2, + CREATEPROB3, + CREATEPROB4, + CREATEPROB5, + CREATEPROB6, + CREATEPROB7, + CREATEPROB8, + CREATEPROB9, + CREATEPROB10, + GROUP_DATAINTNUM, +}GROUP_DATAINT; + +typedef enum +{ + GROUP_NAME, + GROUP_DATACHARNUM, + +}GROUP_DATACHAR; + + +typedef struct tagENEMY_EnemyTable +{ + int intdata[ENEMY_DATAINTNUM]; + STRING64 chardata[ENEMY_DATACHARNUM]; + int enemytemparray; +}ENEMY_EnemyTable; + +typedef struct tagENEMYTEMP_Table +{ + int intdata[E_T_DATAINTNUM]; + //ANDY_EDIT + STRING64 chardata[E_T_DATACHARNUM]; + +}ENEMYTEMP_Table; + +typedef struct tagGROUP_Table +{ + int intdata[GROUP_DATAINTNUM]; + STRING32 chardata[GROUP_DATACHARNUM]; + int enemyarray[CREATEPROB1 - ENEMY_ID1]; +}GROUP_Table; + + + +INLINE BOOL ENEMY_CHECKINDEX( int index); +INLINE int ENEMY_setInt( int index, ENEMY_DATAINT element, int data); +INLINE int ENEMY_getInt( int index, ENEMY_DATAINT element); + +INLINE int *ENEMY_getIntdata( int index); + +INLINE BOOL ENEMY_setChar( int index ,ENEMY_DATACHAR element, char* new ); +INLINE char *ENEMY_getChar( int index, ENEMY_DATACHAR element); +int ENEMY_getEnemyNum( void); +BOOL ENEMY_initEnemy( char* filename ); +BOOL ENEMY_reinitEnemy( void ); +int ENEMY_createEnemy( int array, int baselevel ); +int *ENEMY_getEnemy( int charaindex, int x, int y); +int ENEMY_createPetFromEnemyIndex( int charaindex, int array); + +int ENEMY_getEnemyArrayFromId( int EnemyId); +int ENEMY_getEnemyArrayFromTempNo( int EnemyTempNo); +int ENEMY_getEnemyIdFromTempNo( int EnemyTempNo); +int ENEMY_getEnemyTempNoFromId( int EnemyId); + +#ifdef _TEST_PETCREATE +int ENEMY_TEST_createPetIndex( int array); +#endif + +int ENEMYTEMP_getEnemyNum( void);//krynn 2001/12/13 +INLINE BOOL ENEMYTEMP_CHECKINDEX( int index); +INLINE int ENEMYTEMP_setInt( int index, ENEMYTEMP_DATAINT element, int data); +INLINE int ENEMYTEMP_getInt( int index, ENEMYTEMP_DATAINT element); +INLINE char *ENEMYTEMP_getChar( int index, ENEMYTEMP_DATACHAR element); +INLINE BOOL ENEMYTEMP_getInt_setChar( int index ,ENEMYTEMP_DATACHAR element, char* new ); +INLINE char *ENEMYTEMP_getInt_getChar( int index, ENEMYTEMP_DATACHAR element); +int ENEMYTEMP_getInt_getEnemyNum( void); +BOOL ENEMYTEMP_getInt_initEnemy( char* filename ); +BOOL ENEMYTEMP_getInt_reinitEnemy( void ); +int ENEMYTEMP_getEnemyTempArray( int enemyindex); +int ENEMYTEMP_getEnemyTempArrayFromTempNo( int EnemyTempNo); +int ENEMYTEMP_getEnemyTempArrayFromInitnum( int EnemyTempNo); + +INLINE int GROUP_setInt( int index, GROUP_DATAINT element, int data); +INLINE int GROUP_getInt( int index, GROUP_DATAINT element); +INLINE BOOL GROUP_setChar( int index ,GROUP_DATACHAR element, char* new ); +INLINE char *GROUP_getChar( int index, GROUP_DATACHAR element); +int GROUP_getEnemyNum( void); + +BOOL ENEMYTEMP_initEnemy( char* filename ); +BOOL ENEMYTEMP_reinitEnemy( void ); +BOOL GROUP_initGroup( char* filename ); +BOOL GROUP_reinitGroup( void ); + +#ifdef _PET_EVOLUTION +int EVOLUTION_createPetFromEnemyIndex( int charaindex, int baseindex, int flg); +int PET_CheckIncubate( int charaindex); +BOOL PETFUSION_getIndexForChar( int toindex, int *MainIndex, int *Subindex1,int *Subindex2, char *data); +int NPC_getFusionTableForBase( int charaindex, int petindex1, int petindex2 ); +int NPC_getPetArrayForNo( int PetCode); +BOOL PET_getEvolutionAns( int petindex, int *base); +#endif + +int PETFUSION_SetNewEgg( int toindex , int petindex, int array, int *work, int *skill1, int *skill2); +BOOL PETFUSION_AddEgg(int toindex, int petID, int PetCode); + +#ifdef _PET_TRANS +int GetNewPet( int toindex , int petindex, int array, int *work); +#endif + +#endif diff --git a/gmsv/include/enemyexptbl.h b/gmsv/include/enemyexptbl.h new file mode 100644 index 0000000..5113dd4 --- /dev/null +++ b/gmsv/include/enemyexptbl.h @@ -0,0 +1,207 @@ +#ifndef __ENEMY_EXPTBL_H__ +#define __ENEMY_EXPTBL_H__ + + +static int enemybaseexptbl[] = { +1, +2, +3, +4, +5, +6, +9, +12, +15, +18, +22, +26, +30, +35, +40, +46, +52, +58, +65, +72, +79, +87, +95, +104, +113, +122, +131, +141, +151, +162, +173, +184, +196, +208, +220, +233, +246, +260, +274, +288, +303, +318, +333, +348, +365, +381, +398, +415, +432, +450, +468, +486, +506, +525, +545, +564, +585, +606, +627, +648, +670, +692, +714, +737, +760, +784, +808, +832, +857, +882, +907, +933, +959, +956, +1012, +1040, +1067, +1095, +1123, +1152, +1181, +1210, +1240, +1270, +1300, +1331, +1362, +1394, +1426, +1458, +1490, +1524, +1557, +1590, +1625, +1659, +1694, +1729, +1764, +1800, // level 100 +1836, +1872, +1909, +1946, +1983, +2021, +2059, +2097, +2136, +2175, // level 110 +2214, +2254, +2294, +2334, +2374, +2414, +2455, +2496, +2537, +2578, // level 120 +2619, +2661, +2703, +2745, +2787, +2829, +2872, +2915, +2958, +3000, // level 130 +3043, +3088, +3132, +3176, +3220, +3264, +3309, +3354, +3399, +3444, // level 140 +3489, +3535, +3581, +3627, +3673, +3719, +3765, +3812, +3859, +3906, // level 150 +3953, +4000, +4047, +4095, +4143, +4191, +4239, +4287, +4335, +4384, // level 160 +4433, +4482, +4531, +4580, +4629, +4679, +4729, +4779, +4829, +4879, // level 170 +4929, +4980, +5031, +5082, +5133, +5184, +5235, +5287, +5339, +5391, // level 180 +5443, +5495, +5547, +5599, +5652, +5705, +5758, +5811, +5864, +5917, // level 190 +5970, +6024, +6078, +6132, +6186, +6240, +6295, +6350, +6405, +6460, // level 200 +}; +#endif diff --git a/gmsv/include/event.h b/gmsv/include/event.h new file mode 100644 index 0000000..17dec66 --- /dev/null +++ b/gmsv/include/event.h @@ -0,0 +1,9 @@ +#ifndef __EVENT_H__ +#define __EVENT_H__ + +INLINE BOOL EVENT_CHECKEVENTINDEX( int event); +int EVENT_main( int charaindex,int event, int x, int y); + + +#endif + diff --git a/gmsv/include/family.h b/gmsv/include/family.h new file mode 100644 index 0000000..dfe6456 --- /dev/null +++ b/gmsv/include/family.h @@ -0,0 +1,255 @@ +#ifndef __FAMILY_H__ +#define __FAMILY_H__ + +#include "version.h" +#include "common.h" +#include "util.h" +#include "net.h" +#include "time.h" + +#define FAMILY_MAXNUM 1000 // 家族数量 +#ifdef _FMVER21 +#define FAMILY_MAXMEMBER 100 // 家族人数 +#define FAMILY_MAXCHANNELMEMBER 50 // 频道人数 +#else +#define FAMILY_MAXMEMBER 50 // 家族人数 +#define FAMILY_MAXCHANNELMEMBER 10 // 频道人数 +#endif +#define FAMILY_MAXCHANNEL 5 // 家族频道 + +#define CHAR_MAXNAME 20 +#define CHAR_MAXID 20 +#define MINFMLEVLEFORPOINT 3 // 3 申请庄园最低等级 +#define FMLEADERLV 30 // 族长等级 + +#ifdef _FAMILY_MANORNUM_CHANGE +#define FAMILY_FMPKFLOOR 15 // 家族PK图层 +#else +#define FAMILY_FMPKFLOOR 9 // 家族PK图层 +#define FMPOINTNUM 4 // 有据点家族的最大数量 +#define MANORNUM 4 +#define FAMILY_MAXHOME 4 // 家族据点 +#endif + +enum +{ + FM_TOP_INTEGRATE = 1, // DPTOP 综合 + FM_TOP_ADV, // DPTOP 冒险 + FM_TOP_FEED, // DPTOP 饲育 + FM_TOP_SYNTHESIZE, // DPTOP 合成 + FM_TOP_DEALFOOD, // DPTOP 料理 + FM_TOP_PK, // DPTOP PK +#ifdef _NEW_MANOR_LAW + FM_TOP_MOMENTUM = 8, // DPTOP 气势 +#endif + FM_TOP_NUM, // DPTOP 数量 +}; + +enum +{ + FM_FIX_ACCEPTFLAG = 1, + FM_FIX_FMPK, + FM_FIX_FMPET, + FM_FIX_FMRULE, + FM_FIX_DELFMTIME, + FM_FIX_FMGOLD, + FM_FIX_FMADV, + FM_FIX_FMFEED, + FM_FIX_FMSYNTHESIZE, + FM_FIX_FMDEALFOOD, + FM_FIX_FMLEADERCHANGE, +#ifdef _NEW_MANOR_LAW + FM_FIX_FMMOMENTUM, + FM_FIX_FAME, +#endif +}; + +/* + * 扔□田 及职及桦赭午及 cdkey charname 及赢今毛宁六月凶户卞 + * CHEKEYLEN, CHARNAMELEN + * 毛银丹方丹卞 凳[ + */ + +void CHAR_Family(int fd, int index, char* message); +void ACAddFM(int fd, int result, int fmindex, int index); +void ACJoinFM(int fd, int result, int recv); +void ACLeaveFM(int fd, int result, int resultflag); +void ACDelFM(int fd, int result); +void ACShowFMList(int ret, int fmnum, char *data); +void ACFMDetail(int ret, char *data, int charfdid); +void ACShowMemberList(int result, int index, int fmnumm, +int fmacceptflag, int fmjoinnum, char *data); +void ACShowDpTop(int result,int num, char *data, int kindflag); +void ACShowPointList(int result, char *data); +void ACShowFMMemo(int result, int index, int num, int dataindex, char *data); + +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 +void ACFMCharLogin(int fd, int ret, int index, int floor, int fmdp, + int joinflag, int fmsetupflag, int flag, int charindex, int charfame + #ifdef _NEW_MANOR_LAW + ,int momentum + #endif + ); +#else +void ACFMCharLogin(int fd, int ret, int index, int floor, int fmdp, + int joinflag, int fmsetupflag, int flag, int charindex); +#endif + +void ACFMPointList(int ret, char *data); +void ACSetFMPoint(int ret, int r, int clifd); +void ACFMAnnounce(int ret, char *fmname, int fmindex, int index, int kindflag, + char *data, int color); +void ACFixFMPK(int winindex, int loseindex, int data); +void ACFMJob( int fd, int ret, char* data1, char* data2 ); + +void FAMILY_Add(int fd, int meindex, char *message); +void FAMILY_Join(int fd, int meindex, char *message); +void FAMILY_Leave(int fd, int meindex, char *message); +void FAMILY_Detail(int fd, int meindex, char *message); +void FAMILY_CheckMember(int fd, int meindex, char *message); +void FAMILY_Channel(int fd, int meindex, char *message); +void FAMILY_Bank(int fd, int meindex, char *message); +void FAMILY_SetPoint(int fd, int meindex, char *message); +void FAMILY_Init(void); +void FAMILY_SetAcceptFlag(int fd, int meindex, char *message); +void FAMILY_FixRule( int fd, int meindex, char* message ); +void FAMILY_RidePet( int fd, int meindex, char* message ); +void FAMILY_LeaderFunc( int fd, int meindex, char* message ); + + + +#ifdef _CK_ONLINE_PLAYER_COUNT // WON ADD 计算线上人数 +void GS_SEND_PLAYER_COUNT(void); +#endif + +void SetFMPetVarInit(int meindex); +void SetFMVarInit(int meindex); + + +int CheckFMLeader(int meindex); +int getFmLv(int playerindex); + +void getNewFMList( void ); +void checkFamilyIndex( void ); + +int CheckLeaderQ(int meindex); + + +// shan add Begin +struct FMMEMBER_LIST +{ +// int fmindex; + int fmnum; + int fmjoinnum; +// BOOL use; // 0->没使用 1->使用 + int memberindex[FAMILY_MAXMEMBER]; + char numberlistarray[FAMILY_MAXMEMBER][64]; + char memo[35][220]; // family dengon + int accept; // 召募成员与否 + int memonum; + int memoindex; +}; +// 家族之间的留言板 +struct FMS_MEMO +{ + char memo[140][220]; + int memonum; + int memoindex; +}; +// 家族强者表 +struct FMS_DPTOP +{ + int num; // 记录有多少个家族(综合) + char topmemo[FAMILY_MAXNUM][128]; + int fmtopid[FAMILY_MAXNUM]; // 家族索引 +#ifdef _FMVER21 + int fmtopdp[FAMILY_MAXNUM]; // 家族综合声望 +#endif +#ifdef _NEW_MANOR_LAW + int fmMomentum[FAMILY_MAXNUM]; // 家族气势 + char momentum_topmemo[30][96]; // 家族气势 top + int momentum_topid[FAMILY_MAXNUM]; // 家族气势 top id 索引 +#endif + int adv_num; // 冒险 + char adv_topmemo[30][96]; + int feed_num; // 伺育 + char feed_topmemo[30][96]; + int syn_num; // 合成 + char syn_topmemo[30][96]; + int food_num; // 料理 + char food_topmemo[30][96]; + int pk_num; // PK + char pk_topmemo[30][96]; +}; +// 家族据点 +struct FM_POINTLIST +{ + char pointlistarray[FAMILY_MAXHOME][1024]; // Arminius: 32->1024 + +#ifdef _NEW_MANOR_LAW + int fm_momentum[FAMILY_MAXHOME]; // 记录挑战时期开始时的守庄家族气势值 + BOOL fm_inwar[FAMILY_MAXHOME]; // 此庄园是否进行庄园排程中 +#endif +}; +// 家族PK图层 +struct FM_PKFLOOR +{ + int fl; +}; +// End + +#ifdef _NEW_MANOR_LAW +typedef struct _ManorSchedule_t{ + int iFmIndex[10]; // 排入挑战排程的家族索引 + int iFmMomentum[10]; // 家族气势 + int iSort[10]; // 排名用 + char szMemo[10][256]; // 记录: 家族名称|约战时间|家族气势 + char szFmName[10][32]; // 家族名称 + struct tm tm1[10]; // 记录挑战时间 +}ManorSchedule_t; + +extern ManorSchedule_t ManorSchedule[MANORNUM]; +#endif + +#define MAXFAMILYLIST 120000 +extern char familyListBuf[MAXFAMILYLIST]; + +void JoinMemberIndex( int charaindex, int fmindexi); + + +#ifdef _DEATH_FAMILY_GM_COMMAND // WON ADD 家族战GM指令 + + +#define fm_pk_max 200 + +typedef struct _fm_pk_struct +{ + int fm_index[fm_pk_max]; + int fm_win[fm_pk_max]; + int fm_lose[fm_pk_max]; + int fm_score[fm_pk_max]; + char fm_name[fm_pk_max][30]; +}FM_PK_STRUCT; + + +enum{ + FM_INDEX =0, + FM_WIN, + FM_LOSE, + FM_SCORE, + FM_NAME, +}; + + +void setInt_fm_pk_struct( int index, int type, int num ); +void setChar_fm_pk_struct( int index, int type, char *msg ); +int getInt_fm_pk_struct( int index, int type ); +char *getChar_fm_pk_struct( int index, int type ); +int get_fm_leader_index( int fm1 ); + + +#endif + + + +#endif diff --git a/gmsv/include/function.h b/gmsv/include/function.h new file mode 100644 index 0000000..cd8d34d --- /dev/null +++ b/gmsv/include/function.h @@ -0,0 +1,5 @@ +#ifndef __FUNCTION_H__ +#define __FUNCTION_H__ +BOOL initFunctionTable( void ); +void* getFunctionPointerFromName( char* funcname ); +#endif diff --git a/gmsv/include/handletime.h b/gmsv/include/handletime.h new file mode 100644 index 0000000..80e9e73 --- /dev/null +++ b/gmsv/include/handletime.h @@ -0,0 +1,57 @@ +#ifndef __HANDLETIME_H__ +#define __HANDLETIME_H__ + +#include + +#undef EXTERN +#ifdef __HANDLETIME_C__ +#define EXTERN +#else /*__HANDLETIME_C__*/ +#define EXTERN extern +#endif + +EXTERN struct timeval NowTime; +EXTERN int DEBUG_ADJUSTTIME; + +BOOL setNewTime( void ); +#ifdef _ASSESS_SYSEFFICACY +void Assess_InitSysEfficacy( void); +void Assess_SysEfficacy( int flg); +void ASSESS_getSysEfficacy( float *TVsec); +#ifdef _ASSESS_SYSEFFICACY_SUB +void Assess_SysEfficacy_sub( int flg, int loop); +void ASSESS_getSysEfficacy_sub( float *TVsec, int loop); +#endif +#endif +// WON REM +//struct tm *localtime(const time_t *timep); + +/*仇仇井日票}HiO[LS凛棉楮溢[*/ +/* 凛棉150(坌)*60=9000 =750*12 匹 LS1 */ +/* LS1200凛棉 LS1 */ +/* LS100 匹 LS1 */ +typedef struct tagLSTIME +{ + int year; + int day; + int hour; +}LSTIME; + +#define NIGHT_TO_MORNING 700 +#define MORNING_TO_NOON 930 +#define NOON_TO_EVENING 200 +#define EVENING_TO_NIGHT 300 + +typedef enum +{ + LS_NIGHT = 0, + LS_MORNING , + LS_NOON , + LS_EVENING , +}LSTIME_SECTION; + +void RealTimeToLSTime(long t , LSTIME *lstime); +/*void LSTimeToRealTime( LSTIME *lstime, long *t);*/ +LSTIME_SECTION getLSTime (LSTIME *lstime); + +#endif diff --git a/gmsv/include/init.h b/gmsv/include/init.h new file mode 100644 index 0000000..bb786b5 --- /dev/null +++ b/gmsv/include/init.h @@ -0,0 +1,17 @@ +#ifndef __INIT_H__ +#define __INIT_H__ +#include "common.h" +BOOL init( int argc , char** argv, char** env ); + +#ifdef _ITEM_QUITPARTY + +typedef struct tagDisappearItem +{ + char string[64]; +}DisappearItem; +DisappearItem *Disappear_Item; +int itemquitparty_num; + +#endif + +#endif diff --git a/gmsv/include/item.h b/gmsv/include/item.h new file mode 100644 index 0000000..a6b517c --- /dev/null +++ b/gmsv/include/item.h @@ -0,0 +1,443 @@ + +#ifndef __ITEM_H__ +#define __ITEM_H__ + +#include "char.h" + +#define NULLITEM "0" + +typedef enum +{ + ITEM_FIST =0, + ITEM_AXE, + ITEM_CLUB, + ITEM_SPEAR, + ITEM_BOW, + ITEM_SHIELD, + ITEM_HELM, + ITEM_ARMOUR, + + ITEM_BRACELET =8, + ITEM_MUSIC, + ITEM_NECKLACE, + ITEM_RING, + ITEM_BELT, + ITEM_EARRING, + ITEM_NOSERING, + ITEM_AMULET, + /* ****** */ + ITEM_OTHER =16, + ITEM_BOOMERANG, // 回旋标 + ITEM_BOUNDTHROW, // 投掷斧头 + ITEM_BREAKTHROW, // 投掷石 + ITEM_DISH =20, +#ifdef _ITEM_INSLAY + ITEM_METAL, + ITEM_JEWEL, +#endif +#ifdef _ITEM_CHECKWARES + ITEM_WARES, //货物 +#endif + +#ifdef _ITEM_EQUITSPACE + ITEM_WBELT, //腰带 + ITEM_WSHIELD, //盾 + ITEM_WSHOES, //鞋子 +#endif +#ifdef _EQUIT_NEWGLOVE + ITEM_WGLOVE, //手套 +#endif + +#ifdef _ALCHEMIST + ITEM_ALCHEMIST =30, +#endif + +#ifdef _ANGEL_SUMMON + //ITEM_ANGELTOKEN, + //ITEM_HEROTOKEN, +#endif + + ITEM_CATEGORYNUM, + +}ITEM_CATEGORY; + +typedef enum +{ + ITEM_FIELD_ALL, + ITEM_FIELD_BATTLE, + ITEM_FIELD_MAP, +}ITEM_FIELDTYPE; + +typedef enum +{ + ITEM_TARGET_MYSELF, + ITEM_TARGET_OTHER, + ITEM_TARGET_ALLMYSIDE, + ITEM_TARGET_ALLOTHERSIDE, + ITEM_TARGET_ALL, +}ITEM_TARGETTYPE; + +typedef enum +{ + ITEM_ID, + ITEM_BASEIMAGENUMBER, + ITEM_COST, + ITEM_TYPE, + ITEM_ABLEUSEFIELD, + ITEM_TARGET, + ITEM_LEVEL, /* LEVEL */ +#ifdef _ITEM_MAXUSERNUM + ITEM_DAMAGEBREAK, //物品使用次数 +#endif + +#ifdef _ITEMSET4_TXT + ITEM_USEPILENUMS, //物品堆叠次数 + ITEM_CANBEPILE, //是否可堆叠 + + ITEM_NEEDSTR, + ITEM_NEEDDEX, + ITEM_NEEDTRANS, + ITEM_NEEDPROFESSION, +#endif + +#ifdef _TAKE_ITEMDAMAGE + ITEM_DAMAGECRUSHE, + ITEM_MAXDAMAGECRUSHE, +#endif + +#ifdef _ADD_DEAMGEDEFC + ITEM_OTHERDAMAGE, + ITEM_OTHERDEFC, +#endif + +#ifdef _SUIT_ITEM + ITEM_SUITCODE, +#endif + + ITEM_ATTACKNUM_MIN, /* 斓 猾荚醒 */ + ITEM_ATTACKNUM_MAX, /* 嫖 猾荚醒 */ + ITEM_MODIFYATTACK, /* 猾 祭汹 */ + ITEM_MODIFYDEFENCE, /* 豢 祭汹 */ + ITEM_MODIFYQUICK, /* QUICK 祭汹 */ + + ITEM_MODIFYHP, /* HP 祭汹 */ + ITEM_MODIFYMP, /* MP 祭汹 */ + ITEM_MODIFYLUCK, /* LUCK 祭汹 */ + ITEM_MODIFYCHARM, /* CHARM 祭汹 */ + ITEM_MODIFYAVOID, /* 荚 膜恳 */ + ITEM_MODIFYATTRIB, /* 箪岭膜恳 */ + ITEM_MODIFYATTRIBVALUE, /* 箪岭膜恳袄 */ + ITEM_MAGICID, /* 热诸 寞 */ + ITEM_MAGICPROB, /* 热诸 */ + ITEM_MAGICUSEMP, /* 壅 MP */ + +#ifdef _ITEMSET5_TXT + ITEM_MODIFYARRANGE, + ITEM_MODIFYSEQUENCE, + + ITEM_ATTACHPILE, + ITEM_HITRIGHT, //额外命中 +#endif +#ifdef _ITEMSET6_TXT + ITEM_NEGLECTGUARD, +// ITEM_BEMERGE, +#endif + /* 旦 □正旦膜恳袄[*/ + ITEM_POISON, /* 汹仁凶太卞母丢□斥 */ + ITEM_PARALYSIS, /* 仄太木}1 及垫 互匹五卅中[ */ + ITEM_SLEEP, /* 戽曰[垫 匹五卅中 */ + ITEM_STONE, /* 檗[垫 匹五卅中 */ + ITEM_DRUNK, /* 办丹[ 互票互月 */ + ITEM_CONFUSION, /* 渔刭[ 猾 毛赀月 */ + + ITEM_CRITICAL, /* 弁伉 奴市伙 膜恳 */ + + ITEM_USEACTION, /* 银匀凶凛及失弁扑亦件 */ + ITEM_DROPATLOGOUT, /* 夫弘失它玄允月凛卞 允井升丹井 */ + ITEM_VANISHATDROP, /* 仄凶凛卞壅尹月井升丹井 */ + ITEM_ISOVERED, /* 晓卞昙匀井日日木月井升丹井[*/ + ITEM_CANPETMAIL, /* 矢永玄丢□伙匹霜木月井 */ + ITEM_CANMERGEFROM, /* 宁岳葭卞卅木月井 */ + ITEM_CANMERGETO, /* 宁岳燮卞卅木月井 */ + + ITEM_INGVALUE0, /* 岳坌(5蜊坌) */ + ITEM_INGVALUE1, + ITEM_INGVALUE2, + ITEM_INGVALUE3, + ITEM_INGVALUE4, + + ITEM_PUTTIME, /* 失奶 丞互 井木凶凛棉 */ + ITEM_LEAKLEVEL, /* 怍互升木分仃壬木凶井 */ + ITEM_MERGEFLG, /* 宁岳今木凶失奶 丞井升丹井 */ + ITEM_CRUSHLEVEL, /* 莽木蘸宁中 0 2 ㄟ反莽木化卅中 2反蝈莽 */ + + ITEM_VAR1, /* 迕综仅 */ + ITEM_VAR2, /* 迕综仅 */ + ITEM_VAR3, /* 迕综仅 */ + ITEM_VAR4, /* 迕综仅 */ + + ITEM_DATAINTNUM, + +}ITEM_DATAINT; + +typedef enum +{ + ITEM_NAME, /* 蟆 癫及 蟆 */ + ITEM_SECRETNAME, /* 蟆 凳今木月第 岭 曰 */ + ITEM_EFFECTSTRING, /* 躲绊 侬 */ + ITEM_ARGUMENT, /* 失奶 丞及娄醒 */ +#ifdef _ITEM_INSLAY + ITEM_TYPECODE, + ITEM_INLAYCODE, +#endif + ITEM_CDKEY, /* 失奶 丞及 蟆毛 赓卞 凳仄凶谛及 */ +#ifdef _ITEM_FORUSERNAMES + ITEM_FORUSERNAME, + ITEM_FORUSERCDKEY, +#endif +// CoolFish: 2001/10/11 +#ifdef _UNIQUE_P_I + ITEM_UNIQUECODE, /* 物品编码 */ +#endif + + ITEM_INGNAME0, /* 岳坌及 蟆(5蜊坌) */ + ITEM_INGNAME1, + ITEM_INGNAME2, + ITEM_INGNAME3, + ITEM_INGNAME4, + + + ITEM_INITFUNC, /* 娄醒 + * ITEM_Item* + * 忒曰袄 BOOL + * 忒曰袄及啦 反 CHAR_INITFUNC + * 午 元 */ + ITEM_FIRSTFUNCTION = ITEM_INITFUNC, + ITEM_PREOVERFUNC, /* CHAR_PREOVERFUNC 毛辅寰 */ + ITEM_POSTOVERFUNC, /* CHAR_POSTOVERFUNC 毛辅寰*/ + ITEM_WATCHFUNC, /* CHAR_WATCHFUNC 毛辅寰 */ + ITEM_USEFUNC, /* 娄醒反} + * int charaindex 平乓仿奶件犯永弁旦 + * int charitemindex 愤坌及 + * 失奶 丞 及窒 + * 毛银匀凶井 + */ + ITEM_ATTACHFUNC, /* 娄醒反} + * int charaindex 平乓仿奶件犯永弁旦 + * int itemindex 失奶 丞奶件犯永弁旦 + * 平乓仿弁正及 匀化中月失奶 丞 + * 及失奶 丞 匹及奶件犯永弁旦 + * 匹反卅中仪卞镗啦[ + */ + ITEM_DETACHFUNC, /* 娄醒反} + * int charaindex 平乓仿奶件犯永弁旦 + * int itemindex 失奶 丞奶件犯永弁旦 + * 平乓仿弁正及 匀化中月失奶 丞 + * 及失奶 丞 匹及奶件犯永弁旦 + * 匹反卅中仪卞镗啦[ + */ + ITEM_DROPFUNC, /* 午仄凶午五 + * 娄醒反 + * int charaindex 午仄凶平乓仿 + * int itemindex 失奶 丞奶件犯永弁旦 + */ + ITEM_PICKUPFUNC, /* 失奶 丞毛胶匀凶凛 + * 娄醒反 + * int charaindex 胶匀凶平乓仿index + * int itemindex 失奶 丞奶件犯永弁旦 + */ +#ifdef _Item_ReLifeAct + ITEM_DIERELIFEFUNC, /*ANDY_ADD + 复活道具 + */ +#endif + +#ifdef _CONTRACT + ITEM_CONTRACTTIME, + ITEM_CONTRACTARG, +#endif + + ITEM_LASTFUNCTION, + + ITEM_DATACHARNUM = ITEM_LASTFUNCTION, + +#ifdef _ANGEL_SUMMON + ITEM_ANGELMISSION = ITEM_INGNAME0, + ITEM_ANGELINFO = ITEM_INGNAME1, + ITEM_HEROINFO = ITEM_INGNAME2, +#endif + +}ITEM_DATACHAR; + +typedef enum +{ + ITEM_WORKOBJINDEX, + ITEM_WORKCHARAINDEX, +#ifdef _MARKET_TRADE + ITEM_WORKTRADEINDEX, + ITEM_WORKTRADETYPE, + ITEM_WORKTRADESELLINDEX, +#endif +#ifdef _ITEM_ORNAMENTS + ITEM_CANPICKUP, +#endif +#ifdef _ITEM_TIME_LIMIT + ITEM_WORKTIMELIMIT, +#endif + ITEM_WORKDATAINTNUM, +}ITEM_WORKDATAINT; + + + +typedef struct tagItem +{ + int data[ITEM_DATAINTNUM]; + STRING64 string[ITEM_DATACHARNUM]; + int workint[ITEM_WORKDATAINTNUM]; + + void* functable[ITEM_LASTFUNCTION-ITEM_FIRSTFUNCTION]; +}ITEM_Item; + +typedef struct tagITEM_table +{ + int use; + ITEM_Item itm; + int randomdata[ITEM_DATAINTNUM]; +}ITEM_table; + + +typedef struct tagITEM_exists +{ + BOOL use; + ITEM_Item itm; +}ITEM_exists; + +#ifdef _CONTRACT +#define MAX_CONTRACTTABLE 10 +typedef struct tagITEM_contract +{ + int used; + char detail[2048]; + int argnum; +}ITEM_contractTable; +#endif + + +#define ITEM_CHECKINDEX(index) \ + _ITEM_CHECKINDEX( __FILE__, __LINE__, index) +INLINE BOOL _ITEM_CHECKINDEX( char *file, int line, int index); + + +BOOL ITEM_initExistItemsArray( int num ); +BOOL ITEM_endExistItemsArray( void ); +#define ITEM_initExistItemsOne( itm) \ + _ITEM_initExistItemsOne( __FILE__, __LINE__, itm) +int _ITEM_initExistItemsOne( char *file, int line, ITEM_Item* itm ); + +#define ITEM_endExistItemsOne( index ) \ + _ITEM_endExistItemsOne( index, __FILE__, __LINE__) + +void _ITEM_endExistItemsOne( int index , char *file, int line); + +#define ITEM_getInt( Index, element) _ITEM_getInt( __FILE__, __LINE__, Index, element ) +INLINE int _ITEM_getInt( char *file, int line, int index ,ITEM_DATAINT element); + + +#define ITEM_setInt( Index, element, data) _ITEM_setInt( __FILE__, __LINE__, Index, element, data) +INLINE int _ITEM_setInt( char *file, int line, int index ,ITEM_DATAINT element, int data); + + +INLINE char* ITEM_getChar( int index ,ITEM_DATACHAR element ); +INLINE BOOL ITEM_setChar( int index ,ITEM_DATACHAR element , char* new); + +INLINE int ITEM_getWorkInt( int index ,ITEM_WORKDATAINT element); +INLINE int ITEM_setWorkInt( int index ,ITEM_WORKDATAINT element, int data); +INLINE int ITEM_getITEM_itemnum( void ); +INLINE int ITEM_getITEM_UseItemnum( void ); +INLINE BOOL ITEM_getITEM_use( int index ); +void ITEM_constructFunctable( int itemindex ); +void* ITEM_getFunctionPointer( int itemindex, int functype ); +INLINE ITEM_Item *ITEM_getItemPointer( int index ); +int ITEM_getItemMaxIdNum( void); + + +char* ITEM_makeStringFromItemData( ITEM_Item* one, int mode ); +char* ITEM_makeStringFromItemIndex( int index, int mode ); + +BOOL ITEM_makeExistItemsFromStringToArg( char* src , ITEM_Item* item, int mode ); +void ITEM_getDefaultItemSetting( ITEM_Item* itm); + + +INLINE BOOL ITEM_CHECKITEMTABLE( int number ); +BOOL ITEM_readItemConfFile( char* filename ); + + +CHAR_EquipPlace ITEM_getEquipPlace( int charaindex, int itmid ); + + +char* ITEM_makeItemStatusString( int haveitemindex, int itemindex ); +char* ITEM_makeItemFalseString( void ); +char* ITEM_makeItemFalseStringWithNum( int haveitemindex ); + + +BOOL ITEM_makeItem( ITEM_Item* itm, int number ); +int ITEM_makeItemAndRegist( int number ); + + +void ITEM_equipEffect( int index ); + +void Other_DefcharWorkInt( int index); + +char* ITEM_getAppropriateName(int itemindex); +char* ITEM_getEffectString( int itemindex ); + + +int ITEM_getcostFromITEMtabl( int itemid ); + +#define ITEM_getNameFromNumber( id) _ITEM_getNameFromNumber( __FILE__, __LINE__, id) +INLINE char* _ITEM_getNameFromNumber( char *file, int line, int itemid ); + + +int ITEM_getlevelFromITEMtabl( int itemid ); +int ITEM_getgraNoFromITEMtabl( int itemid ); +char *ITEM_getItemInfoFromNumber( int itemid ); + +int ITEM_getdropatlogoutFromITEMtabl( int itemid ); +int ITEM_getvanishatdropFromITEMtabl( int itemid ); +int ITEM_getcanpetmailFromITEMtabl( int itemid ); +int ITEM_getmergeItemFromFromITEMtabl( int itemid ); + +#ifdef _ITEM_CHECKWARES +BOOL CHAR_CheckInItemForWares( int charaindex, int flg); +#endif + +BOOL ITEM_canuseMagic( int itemindex); +// Nuke +1 08/23 : For checking the validity of item target +int ITEM_isTargetValid( int charaindex, int itemindex, int toindex); + + +#ifdef _IMPOROVE_ITEMTABLE +BOOL ITEMTBL_CHECKINDEX( int ItemID); +int ITEM_getSIndexFromTransList( int ItemID); +int ITEM_getMaxitemtblsFromTransList( void); +int ITEM_getTotalitemtblsFromTransList( void); +#endif + +int ITEMTBL_getInt( int ItemID, ITEM_DATAINT datatype); +char *ITEMTBL_getChar( int ItemID, ITEM_DATACHAR datatype); + +int ITEM_getItemDamageCrusheED( int itemindex); +void ITEM_RsetEquit( int charaindex);//自动卸除装备位置错误之物品 +void ITEM_reChangeItemToPile( int itemindex); +void ITEM_reChangeItemName( int itemindex); + + +#ifdef _SIMPLIFY_ITEMSTRING +void ITEM_getDefaultItemData( int itemID, ITEM_Item* itm); +#endif + +#ifdef _CONTRACT +BOOL ITEM_initContractTable( ); +#endif + +#endif diff --git a/gmsv/include/item_event.h b/gmsv/include/item_event.h new file mode 100644 index 0000000..16a2f54 --- /dev/null +++ b/gmsv/include/item_event.h @@ -0,0 +1,241 @@ +#ifndef __ITEM_EVENT_H__ +#define __ITEM_EVENT_H__ +#include "item.h" +int ITEM_eventDrop( int itemindex, int charaindex, int itemcharaindex ); +BOOL ITEM_MedicineInit( ITEM_Item* itm ); +void ITEM_MedicineUsed( int charaindex, int to_charaindex, int itemindex ); +void ITEM_SandClockDetach( int charindex , int itemindex ); +void ITEM_SandClockLogin( int charaindex ); +void ITEM_SandClockLogout( int charaindex ); +void ITEM_chantMagicAttack( int charaindex, int itemindex, int toindex, float* damage ); +void ITEM_addTitleAttach( int charaindex, int itemindex ); +void ITEM_delTitleDetach( int charaindex, int itemindex ); +void ITEM_DeleteByWatched( int myobjindex, int moveobjindex, CHAR_ACTION act, + int x, int y, int dir, int* opt, int optlen ); +void ITEM_DeleteTimeWatched( int myobjindex, int moveobjindex, CHAR_ACTION act, + int x, int y, int dir, int* opt, int optlen ); +void ITEM_useEffectTohelos( int charaindex, int to_charaindex, int haveitemindex); +void ITEM_useRecovery( int charaindex, int toindex, int haveitemindex); + +void ITEM_useStatusChange( int charaindex, int toindex, int haveitemindex); +void ITEM_useMagicDef( int charaindex, int toindex, int haveitemindex); +void ITEM_useParamChange( int charaindex, int toindex, int haveitemindex); +void ITEM_useFieldChange( int charaindex, int toindex, int haveitemindex); +void ITEM_useAttReverse( int charaindex, int toindex, int haveitemindex); +void ITEM_useStatusRecovery( int charaindex, int toindex, int haveitemindex); +void ITEM_useRessurect( int charaindex, int toindex, int haveitemindex); +void ITEM_useMic( int charaindex, int to_charaindex, int haveitemindex ); +void ITEM_dropMic( int charaindex, int itemindex ); +void ITEM_useCaptureUp( int charaindex, int toindex, int haveitemindex); +void ITEM_useRenameItem( int charaindex, int toindex, int haveitemindex); +void ITEM_useRenameItem_WindowResult( int charaindex, int seqno, int select, char *data); +void ITEM_dropDice( int charaindex, int itemindex); +void ITEM_pickupDice( int charaindex, int itemindex); +void ITEM_useLottery( int charaindex, int toindex, int haveitemindex); +void ITEM_useWarp( int charaindex, int toindex, int haveitemindex ); +void ITEM_petFollow( int charaindex, int toindex, int haveitemindex ); +BOOL ITEM_initLottery(ITEM_Item* itm); +void ITEM_useSkup( int charaindex, int toindex, int haveitemindex ); // Nuke 0624 +void ITEM_useNoenemy( int charaindex, int toindex, int haveitemindex ); // Nuke 0626 +void ITEM_equipNoenemy( int charaindex, int itemindex ); // Arminius 7.2: Ra's amulet +void ITEM_remNoenemy( int charaindex, int itemindex ); // Arminius 7.2: Ra's amulet +BOOL ITEM_getArgument( char* argument , char* entryname , char* buf , int buflen ); // Arminius 7.2: Ra's amulet +void ITEM_useEncounter( int charaindex, int toindex, int haveitemindex); // Arminius 7.31 cursed stone +#ifdef _ITEM_METAMO +void ITEM_metamo( int charaindex, int toindex, int haveitemindex ); +void ITEM_ColorMetamo( int charaindex, int toindex, int haveitemindex); +void ITEM_CharaMetamo( int charaindex, int toindex, int haveitemindex); +void ITEM_SexMetamo( int charaindex, int toindex, int haveitemindex); +#endif +#ifdef _ITEM_CRACKER +void ITEM_Cracker(int charaindex,int toindex,int haveitemindex); +#endif +#ifdef _ITEM_ADDEXP //vincent 经验提升 +void ITEM_Addexp(int charaindex,int toindex,int haveitemindex); +#endif +#ifdef _ITEM_REFRESH //vincent 解除异常状态道具 +void ITEM_Refresh(int charaindex,int toindex,int haveitemindex); +#endif +//Terry 2001/12/21 +#ifdef _ITEM_FIRECRACKER +void ITEM_firecracker(int charaindex,int toindex,int haveitemindex); +#endif +//Terry end + +#ifdef _PET_LIMITLEVEL +void ITEM_useOtherEditBase( int charaindex, int toindex, int haveitemindex); +#endif + +#ifdef _ITEM_EDITBASES +void ITEM_useFusionEditBase( int charaindex, int toindex, int haveitemindex); +#endif + +void ITEM_WearEquip( int charaindex, int itemindex); +void ITEM_ReWearEquip( int charaindex, int itemindex); + + +#ifdef _ITEM_CONSTITUTION +void ITEM_Constitution( int charaindex, int toindex, int haveitemindex); +#endif + +#ifdef _Item_ReLifeAct +void ITEM_DIErelife( int charaindex, int itemindex, int eqw ); +#endif + +#ifdef _Item_MoonAct +void ITEM_randEnemyEquipOne( int charaindex, int toindex, int haveitemindex); +void ITEM_randEnemyEquip( int charaindex, int itemindex); +void ITEM_RerandEnemyEquip( int charaindex, int itemindex); +#endif + +#ifdef _ITEM_ORNAMENTS +void ITEM_PutOrnaments( int charaindex, int itemindex); +#endif + +#ifdef _CHIKULA_STONE +void ITEM_ChikulaStone( int charaindex, int toindex, int haveitemindex); +#endif + +#ifdef _SUIT_ITEM +void ITEM_suitEquip( int charaindex, int itemindex); +void ITEM_ResuitEquip( int charaindex, int itemindex); +#endif + +#ifdef _EQUIT_DEFMAGIC +void ITEM_MagicEquitWear( int charaindex, int itemindex); +void ITEM_MagicEquitReWear( int charaindex, int itemindex); +#endif + +#ifdef _EQUIT_RESIST +void ITEM_MagicResist( int charaindex, int itemindex); +void ITEM_MagicReResist( int charaindex, int itemindex); +#endif + +#ifdef _MAGIC_RESIST_EQUIT // WON ADD 职业抗性装备 +void ITEM_P_MagicEquitWear( int charaindex, int itemindex ); +void ITEM_P_MagicEquitReWear( int charaindex, int itemindex ); +#endif + + +#ifdef _Item_DeathAct +void ITEM_UseDeathCounter( int charaindex, int toindex, int haveitemindex); +#endif + +#ifdef _DEATH_CONTENDWATCH +void ITEM_useWatchBattle( int charaindex, int toindex, int haveitemindex); +#endif + +#ifdef _FEV_ADD_NEW_ITEM // FEV ADD 增加复活守精 +void ITEM_ResAndDef( int charaindex, int toindex, int haveitemindex ); +#endif + +#ifdef _CHRISTMAS_REDSOCKS +void ITEM_useMaxRedSocks( int charaindex, int toindex, int haveitemindex); +#endif + +#ifdef _CHRISTMAS_REDSOCKS_NEW +void ITEM_useMaxRedSocksNew( int charaindex, int toindex, int haveitemindex); +#endif + +#ifdef _PETSKILL_CANNEDFOOD +void ITEM_useSkillCanned( int charaindex, int toindex, int itemNo); +#endif + +#ifdef _NEW_RIDEPETS +void ITEM_useLearnRideCode( int charaindex, int toindex, int haveitemindex); +#endif + +#ifdef _ITEM_WARP_FIX_BI +void recoverbi(int index); +#endif + +#ifdef _ITEM_TIME_LIMIT +void ITEM_TimeLimit( int charaindex); +#endif + +#ifdef _USEWARP_FORNUM +void ITEM_useWarpForNum( int charaindex, int toindex, int haveitemindex ); +#endif + +#ifdef _IMPRECATE_ITEM +void ITEM_useImprecate( int charaindex, int toNo, int haveitemindex ); +#endif +#ifdef _BLACK_MARKET +void ITEM_BM_Exchange( int charaindex, int iindex); +#endif + +#ifdef _THROWITEM_ITEMS +void ITEM_ThrowItemBox( int charaindex, int toindex, int haveitemindex); +#endif + +#ifdef _ITEM_WATERWORDSTATUS +void ITEM_WaterWordStatus( int charaindex, int toindex, int haveitemindex); +#endif + +#ifdef _ITEM_LOVERPARTY +void ITEM_LoverSelectUser( int charaindex, int toindex, int haveitemindex); +#endif + +#ifdef _ITEM_MAGICRECOVERY +void ITEM_useMRecovery( int charaindex, int toindex, int haveitemindex); +#endif + +#ifdef _ITEM_USEMAGIC +void ITEM_useMagic( int charaindex, int toindex, int haveitemindex); +#endif + +#ifdef _PETSKILL_CANNEDFOOD +void ITEM_usePetSkillCanned_WindowResult( int charaindex, int seqno, int select, char *data); +#endif + +void ITEM_AddPRSkillPoint(int charaindex,int toindex,int haveitemindex); +void ITEM_AddPRSkillPercent( int charaindex,int toindex,int haveitemindex); + +#ifdef _ANGEL_SUMMON +void ITEM_AngelToken( int charaindex, int toindex, int haveitemindex ); +void ITEM_HeroToken( int charaindex, int toindex, int haveitemindex ); +#endif +#ifdef _HALLOWEEN_EFFECT +void ITEM_MapEffect(int charaindex,int toindex,int haveitemindex); +#endif +void ITEM_changePetOwner( int charaindex, int toindex, int haveitemindex); + +#ifdef _CONTRACT +void ITEM_contract( int charaindex, int toindex, int haveitemindex); +#endif + +#ifdef _TIME_TICKET +void ITEM_timeticket( int charaindex, int toindex, int haveitemindex); +#endif + +#ifdef _ITEM_SETLOVER +void ITEM_SetLoverUser( int charaindex, int toindex, int haveitemindex); +void ITEM_LoverWarp( int charaindex, int toindex, int haveitemindex); +void ITEM_LoverUnmarry( int charaindex, int toindex, int haveitemindex); +#endif + +#ifdef _GM_ITEM +void ITEM_GMFUNCTION( int charaindex, int toindex, int haveitemindex); +#endif + +enum{ + BD_KIND_HP, + BD_KIND_MP, + BD_KIND_CHARM, + BD_KIND_AI, + BD_KIND_CURSE, + BD_KIND_BESTOW, + BD_KIND_WISHES, +#ifdef _CHANGEITEMUSE // Syu ADD 调整战斗中使用料理设定 + BD_KIND_HP_MP, +#endif +#ifdef _ITEM_UNBECOMEPIG + BD_KIND_UNBECOMEPIG, +#endif +#ifdef _ITEM_PROPERTY + BD_KIND_PROPERTY, +#endif + BD_KIND_END +}; + +#endif diff --git a/gmsv/include/item_gen.h b/gmsv/include/item_gen.h new file mode 100644 index 0000000..7174c87 --- /dev/null +++ b/gmsv/include/item_gen.h @@ -0,0 +1,22 @@ +#ifndef __ITEM_GEN_H__ +#define __ITEM_GEN_H__ + + +int ITEM_initItemIngCache( void ); +int ITEM_initItemAtom( char *fn ); +int ITEM_initRandTable( void); +int ITEM_mergeItem( int charaindex, ITEM_Item *items, int num , int money, int petid, int searchtable, int petindex, int alchemist); +int ITEM_canDigest( ITEM_Item *t ); +int ITEM_mergeItem_merge( int charaindex,int petid, char *data, int petindex, int alchemist); + +#ifdef _ITEM_INSLAY +int PETSKILL_ITEM_inslay( int charindex, int inslayindex, int itemindex); +#endif + +#ifdef _PETSKILL_FIXITEM +int PETSKILL_ITEM_FixItem( int charindex, int fixindex, int *itemindex); +#endif + +#endif + + diff --git a/gmsv/include/item_trade.h b/gmsv/include/item_trade.h new file mode 100644 index 0000000..b389cdb --- /dev/null +++ b/gmsv/include/item_trade.h @@ -0,0 +1,52 @@ +#ifndef __MAPTRADE_H__ +#define __MAPTRADE_H__ +#include "char.h" + +typedef struct tagMapTrade { + int masterindex; + int x; + int y; + int Ttime; + int Goodindex; + char Goodname[256]; +}MapTrade; + +#define TRADEMAP 1090 +#define TRADEXSIZE 4 +#define TRADEYSIZE 4 + +BOOL CHECKMAP_TRADE( int charindex, int floor, int x, int y); +int CHECKMAP_TRADEXY( int charindex, int floor, int x, int y); +BOOL MAP_TRADEDROP( int charindex, int itemindex,int floor, int x, int y); +BOOL MAP_TRADEPICKUP( int charindex, int itemindex, int floor, int x, int y, int flg); + +void InitMapTradeData( int index, int Stime); + +int TRADE_getMasterInt( int index); +int TRADE_getTimeInt( int index); +BOOL TRADE_setMasterInt( int index, int Num); +BOOL TRADE_setTimeInt( int index, int Num); +int TRADE_AddMasrerTrade( int toindex); //设定摊位主人 +int TRADE_getMaxNumInt(); +void MAPTRADE_CLEANGOLD( int floor, int num); +BOOL MAPTRADE_CHECKMASTERIN( int masterindex , int toindex, int num); +BOOL MAPTRADE_CHECKMAPFULL(int fl, int x, int y); +BOOL MAP_TRADEPETDROP( int charindex, int petindex,int floor, int x, int y); +int MAPTRADE_getItemSpace( int meindex, int itemindex); +int MAPTRADE_getPetSpace( int masterindex, int petindex); + +int MAPTRADE_getSellIndex( int index); +BOOL MAPTRADE_setSellIndex( int index, int num); +void MAPTRADE_setCharSellName( int index, char *buf); +char* MAPTRADE_getCharSellName( int index ); + +#define TRADESTARTNUM 1 +#define TRADETYPE_SELL (1<<3) +#define TRADEITEMID 0 +#define TRADEPETID 0 +#define TRADEPETUPLV ((1<<24)+(1<<16)+(1<<8)+1) +#define TRADEPETTYPE (1<<4) +#define TRADEITEMTYPE (1<<8) +#endif + + diff --git a/gmsv/include/levelup.h b/gmsv/include/levelup.h new file mode 100644 index 0000000..eb4b161 --- /dev/null +++ b/gmsv/include/levelup.h @@ -0,0 +1,17 @@ +#ifndef _LEVELUP_H +#define _LEVELUP_H + +int GetEnemyExp( int level ); + +int BATTLE_GetLevelExp( + int charaindex, + int level +); + +int BATTLE_LevelUpCheck( + int charaindex +); + + +#endif + diff --git a/gmsv/include/link.h b/gmsv/include/link.h new file mode 100644 index 0000000..f9f6ba2 --- /dev/null +++ b/gmsv/include/link.h @@ -0,0 +1,22 @@ +#ifndef __LINK_H__ +#define __LINK_H__ + +#include "common.h" + +/* + * 伉旦玄厌瞻毛烂聒允月 [ + * 仇及伉旦玄反val反 读卞反窒手仄卅中[勾引曰禾奶件正□及戊疋□及心 + * 垫丹[ + */ +typedef struct tagNode +{ + struct tagNode* next; /*戚及用□玉尺及禾奶件正□*/ + char* val; /*忡 允月 侬 */ + int size; /*val及扔奶术*/ +}Node; + +BOOL Nodeappendhead( Node** top , Node* add ); +BOOL Nodeappendtail( Node** top , Node* add ); +BOOL Noderemovehead( Node** top , Node* ret); +BOOL Noderemovetail( Node** top , Node* ret); +#endif diff --git a/gmsv/include/log.h b/gmsv/include/log.h new file mode 100644 index 0000000..b8dee6d --- /dev/null +++ b/gmsv/include/log.h @@ -0,0 +1,353 @@ +#ifndef __LOG_H__ +#define __LOG_H__ +#include +typedef enum +{ + LOG_TALK, + LOG_PROC, + LOG_ITEM, + LOG_STONE, + LOG_PET, + LOG_TENSEI, + LOG_KILL, //ttom 12/26/2000 kill the pet & items + LOG_TRADE, // CoolFish: 2001/4/19 + LOG_HACK, // Arminius 2001/6/14 + LOG_SPEED, // Nuke 0626 + LOG_FMPOP, // CoolFish: 2001/9/12 + LOG_FAMILY, // Robin 10/02 + LOG_GM, // Shan +#ifdef _SERVICE + LOG_SERVICE, // Terry 2001/09/28 +#endif +#ifdef _GAMBLE_ROULETTE + LOG_GAMBLE, +#endif +#ifdef _TEST_PETCREATE + LOG_CREATPET, + LOG_AVGCREATPET, +#endif + + LOG_LOGIN, + PETTRANS, +//Syu 增加庄园战胜负Log + LOG_FMPKRESULT, + +// Syu ADD 新增家族个人银行存取Log (不含家族银行) + LOG_BANKSTONELOG, + + LOG_ACMESS, + LOG_PKCONTEND, +#ifdef _STREET_VENDOR + LOG_STREET_VENDOR, +#endif + +#ifdef _ANGEL_SUMMON + LOG_ANGEL, +#endif + +#ifdef _LOG_OTHER + LOG_OTHER, +#endif +#ifdef _NEW_MANOR_LAW + LOG_FMPK_GETMONEY, + LOG_FM_FAME_SHOP, +#endif + + LOG_TYPE_NUM, +}LOG_TYPE; + +void closeAllLogFile( void ); +BOOL initLog( char* filename ); +void printl( LOG_TYPE logtype, char* format , ... ); + + +void LogAcMess( int fd, char *type, char *mess ); + +void LogItem( + char *CharName, /* 平乓仿弁正 */ + char *CharID, + int ItemNo, /* 失奶 丞 寞 */ + char *Key, /* 平□伐□玉 */ + int floor, /* 甄 */ + int x, + int y, + char *uniquecode, // shan 2001/12/14 + char *itemname, int itemID +); +void LogPkContend( char *teamname1, char *teamname2, + int floor, int x, int y, int flg ); + +void LogPetTrans( + char *cdkey, char *uniwuecde, char *uniwuecde2, char *CharName, int floor, int x, int y, + int petID1, char *PetName1, int petLV, int petrank, int vital1, int str1, int tgh1, int dex1, int total1, + int petID2, char *PetName2, int vital2, int str2, int tgh2, int dex2, int total2, + int work0, int work1, int work2, int work3, int ans, int trans +); + +void LogPet( + char *CharName, /* 平乓仿弁正 */ + char *CharID, + char *PetName, + int PetLv, + char *Key, /* 平□伐□玉 */ + int floor, /* 甄 */ + int x, + int y, + char *uniquecode // shan 2001/12/14 +); + +#ifdef _STREET_VENDOR +void LogStreetVendor( + char *SellName, + char *SellID, + char *BuyName, + char *BuyID, + char *ItemPetName, + int PetLv, //若是道具此值为 -1 + int iPrice, + char *Key, + int Sfloor, + int Sx, + int Sy, + int Bfloor, + int Bx, + int By, + char *uniquecode +); +#endif + +void LogTensei( + char *CharName, /* 平乓仿弁正 */ + char *CharID, + char *Key, /* 平□伐□玉 */ + int level, //伊矛伙 + int transNum, //鳖戏荚醒 + int quest, //弁巨旦玄醒 + int home, //请褥哗 + int item, // 笛失奶 丞 井曰醒 + int pet, // 笛矢永玄 井曰醒 + int vital, // 祭蟆Vital + int b_vital, // 祭 vital + int str, // 祭蟆str + int b_str, // 祭 str + int tgh, // 祭蟆 + int b_tgh, // 祭 + int dex, // 祭蟆 + int b_dex // 祭 +); +// Syu ADD 新增家族个人银行存取Log (不含家族银行) +void LogFamilyBankStone( + char *CharName, + char *CharId, + int Gold, + int MyGold, + char *Key, + int floor, + int x, + int y, + int banksum +); + +void LogStone( + int TotalGold, + char *CharName, /* 平乓仿弁正 */ + char *CharId, /* 交□扒□ID */ + int Gold, /* 嗯喊 */ + int MyGold, + char *Key, /* 平□伐□玉 */ + int floor, /* 甄 */ + int x, + int y +); + +void LogTalk( + char *CharName, /* 平乓仿弁正 */ + char *CharID, + int floor, /* 甄 */ + int x, + int y, + char *message +); + +// Terry 2001/09/28 +#ifdef _SERVICE +void LogService( + char *CharName, //角色名称 + char *CharID, //玩家ID + int itemid, //物品ID + char *Key, //说明 + int floor, + int x, + int y +); +#endif +//ttom 12/26/2000 kill pet & items +void LogKill( + char *CharName, + char *CharId, + char *CharPet_Item +); +//ttom + +// CoolFish: 2001/4/19 +void LogTrade(char *message); +// CoolFish: 2001/9/12 +void LogFMPOP(char *message); + +// Arminius 2001/6/14 +enum +{ + HACK_NOTHING, + HACK_GETFUNCFAIL, + HACK_NOTDISPATCHED, + HACK_CHECKSUMERROR, + HACK_HP, + HACK_TYPE_NUM, +}HACK_TYPE; +void logHack(int fd, int errcode); +// Nuke 0626 +void logSpeed(int fd); + +void closeAllLogFile( void ); +int openAllLogFile( void ); + +// Robin 10/02 +void LogFamily( + char *FMName, + int fmindex, + char *charName, + char *charId, + char *keyWord, + char *data +); + +// Shan 11/02 +void LogGM( + char *CharName, //角色名称 + char *CharID, //玩家ID + char *Message, //指令内容 + int floor, + int x, + int y +); + +void LogLogin( + char *CharID, //玩家ID + char *CharName, //角色名称 + int saveIndex, + char *ipadress +); + +#ifdef _TEST_PETCREATE +void LogCreatPet( + char *PetName, int petid, int lv,int hp, int char_vital, int char_str, int char_tgh, int char_dex, + int vital, int str, int tgh, int dex, int fixstr, int fixtgh, int fixdex, + int lvup, int petrank, int flg + ); +#endif + +void LogCreatFUPet( + char *PetName, int petid, int lv, int hp, + int vital, int str, int tgh, int dex, + int fixstr, int fixtgh, int fixdex, int trans, int flg); + +#ifdef _GAMBLE_ROULETTE + +void LogGamble( + char *CharName, //角色名称 + char *CharID, //玩家ID + char *Key, //说明 + int floor, + int x, + int y, + int player_stone, //所拥有金钱 + int Gamble_stone, //下注本金 + int get_stone, //获得 + int Gamble_num, + int flg //flg = 1 玩家 2 庄家 +); +#endif + +void LogBankStone( + char *CharName, /* 平乓仿弁正 */ + char *CharId, /* 交□扒□ID */ + int meindex, + int Gold, /* 嗯喊 */ + char *Key, /* 平□伐□玉 */ + int floor, /* 甄 */ + int x, + int y, + int my_gold, + int my_personagold +); + +//Syu 增加庄园战胜负Log +void Logfmpk( + char *winner, int winnerindex, int num1, + char *loser, int loserindex, int num2, char *date, char *buf1, char *buf2, int flg); + +#ifdef _NEW_MANOR_LAW +void LogFMPKGetMomey( + char *szFMName, + char *szID, + char *szCharName, + int iMomentum, + int iGetMoney, + int iDest +); +void LogFMFameShop( + char *szFMName, + char *szID, + char *szCharName, + int iFame, + int iCostFame +); +#endif + +void backupAllLogFile( struct tm *ptm ); + + +#ifdef _TEST_PETCREATE +void backupTempLogFile( char *buf, char *entryname, int Num); +#endif + +void LogPetPointChange( + char * CharName, char *CharID, char *PetName, int petindex, int errtype, + int PetLv, char *Key,int floor, int x, int y); + +void LogPetFeed( + char * CharName, char *CharID, char *PetName, int petindex, + int PetLv, char *Key,int floor, int x, int y, char *ucode); + +#ifdef _ANGEL_SUMMON +void LogAngel( char *msg); +#endif + +void warplog_to_file( void ); +void warplog_from_file( void ); + +typedef struct { + int floor; + int incount; + int outcount; +}tagWarplog; +#define MAXMAPNUM 700 +extern tagWarplog warplog[MAXMAPNUM]; + +typedef struct { + int floor1; + int floor2; + int count; +}tagWarpCount; +#define MAXMAPLINK 1000 +extern tagWarpCount warpCount[MAXMAPLINK]; + +#ifdef _LOG_OTHER +void LogOther( + char *CharName, + char *CharID, + char *message +); +#endif + +#endif diff --git a/gmsv/include/lssproto_serv.h b/gmsv/include/lssproto_serv.h new file mode 100644 index 0000000..7901117 --- /dev/null +++ b/gmsv/include/lssproto_serv.h @@ -0,0 +1,375 @@ +#ifndef _PROTOCOL_H_ +#define _PROTOCOL_H_ + +#include "lssproto_util.h" // for StoneAge + +#ifdef MAXLSRPCARGS +#if ( MAXLSRPCARGS <= ( 13 + 1 ) ) +#undef MAXLSRPCARGS +#define MAXLSRPCARGS ( 13 + 1 ) +#endif +#else +#define MAXLSRPCARGS ( 13 + 1 ) +#endif + +int lssproto_InitServer(int (*writefunc)(int,char*,int) , int worksiz ); +void lssproto_SetServerLogFiles( char *read , char *write ); +void lssproto_CleanupServer( void ); +int lssproto_ServerDispatchMessage(int fd, char *encoded); + +#define SEPARATOR ";" + +#define LSSPROTO_W_RECV 0 +#define LSSPROTO_W2_RECV 1 +#define LSSPROTO_XYD_SEND 2 +#define LSSPROTO_EV_RECV 3 +#define LSSPROTO_EV_SEND 4 +#define LSSPROTO_EN_RECV 5 +#define LSSPROTO_DU_RECV 6 +#define LSSPROTO_EN_SEND 7 +#define LSSPROTO_EO_RECV 8 +#define LSSPROTO_BU_RECV 9 +#define LSSPROTO_JB_RECV 10 +#define LSSPROTO_LB_RECV 11 +#define LSSPROTO_RS_SEND 12 +#define LSSPROTO_RD_SEND 13 +#define LSSPROTO_B_RECV 14 +#define LSSPROTO_B_SEND 15 +#define LSSPROTO_SKD_RECV 16 +#define LSSPROTO_ID_RECV 17 +#define LSSPROTO_PI_RECV 18 +#define LSSPROTO_DI_RECV 19 +#define LSSPROTO_DG_RECV 20 +#define LSSPROTO_DP_RECV 21 +#define LSSPROTO_I_SEND 22 +#define LSSPROTO_MI_RECV 23 +#define LSSPROTO_SI_SEND 24 +#define LSSPROTO_MSG_RECV 25 +#define LSSPROTO_MSG_SEND 26 +#define LSSPROTO_PMSG_RECV 27 +#define LSSPROTO_PME_SEND 28 +#define LSSPROTO_AB_RECV 29 +#define LSSPROTO_AB_SEND 30 +#define LSSPROTO_ABI_SEND 31 +#define LSSPROTO_DAB_RECV 32 +#define LSSPROTO_AAB_RECV 33 +#define LSSPROTO_L_RECV 34 +#define LSSPROTO_TK_RECV 35 +#define LSSPROTO_TK_SEND 36 +#define LSSPROTO_MC_SEND 37 +#define LSSPROTO_M_RECV 38 +#define LSSPROTO_M_SEND 39 +#define LSSPROTO_C_RECV 40 +#define LSSPROTO_C_SEND 41 +#define LSSPROTO_CA_SEND 42 +#define LSSPROTO_CD_SEND 43 +#define LSSPROTO_R_SEND 44 +#define LSSPROTO_S_RECV 45 +#define LSSPROTO_S_SEND 46 +#define LSSPROTO_D_SEND 47 +#define LSSPROTO_FS_RECV 48 +#define LSSPROTO_FS_SEND 49 +#define LSSPROTO_HL_RECV 50 +#define LSSPROTO_HL_SEND 51 +#define LSSPROTO_PR_RECV 52 +#define LSSPROTO_PR_SEND 53 +#define LSSPROTO_KS_RECV 54 +#define LSSPROTO_KS_SEND 55 +#define LSSPROTO_AC_RECV 56 +#define LSSPROTO_MU_RECV 57 +#define LSSPROTO_PS_RECV 58 +#define LSSPROTO_PS_SEND 59 +#define LSSPROTO_ST_RECV 60 +#define LSSPROTO_DT_RECV 61 +#define LSSPROTO_FT_RECV 62 +#define LSSPROTO_SKUP_SEND 63 +#define LSSPROTO_SKUP_RECV 64 +#define LSSPROTO_KN_RECV 65 +#define LSSPROTO_WN_SEND 66 +#define LSSPROTO_WN_RECV 67 +#define LSSPROTO_EF_SEND 68 +#define LSSPROTO_SE_SEND 69 +#define LSSPROTO_SP_RECV 70 +#define LSSPROTO_CLIENTLOGIN_RECV 71 +#define LSSPROTO_CLIENTLOGIN_SEND 72 +#define LSSPROTO_CREATENEWCHAR_RECV 73 +#define LSSPROTO_CREATENEWCHAR_SEND 74 +#define LSSPROTO_CHARDELETE_RECV 75 +#define LSSPROTO_CHARDELETE_SEND 76 +#define LSSPROTO_CHARLOGIN_RECV 77 +#define LSSPROTO_CHARLOGIN_SEND 78 +#define LSSPROTO_CHARLIST_RECV 79 +#define LSSPROTO_CHARLIST_SEND 80 +#define LSSPROTO_CHARLOGOUT_RECV 81 +#define LSSPROTO_CHARLOGOUT_SEND 82 +#define LSSPROTO_PROCGET_RECV 83 +#define LSSPROTO_PROCGET_SEND 84 +#define LSSPROTO_PLAYERNUMGET_RECV 85 +#define LSSPROTO_PLAYERNUMGET_SEND 86 +#define LSSPROTO_ECHO_RECV 87 +#define LSSPROTO_ECHO_SEND 88 +#define LSSPROTO_SHUTDOWN_RECV 89 +#define LSSPROTO_NU_SEND 90 +#define LSSPROTO_TD_RECV 91 +#define LSSPROTO_TD_SEND 92 +#define LSSPROTO_FM_SEND 93 +#define LSSPROTO_FM_RECV 94 +#define LSSPROTO_WO_SEND 95 +#define LSSPROTO_PETST_RECV 96 +#define LSSPROTO_BM_RECV 97 // _BLACK_MARKET + +#ifdef _MIND_ICON +#define LSSPROTO_MA_RECV 98 +#endif + +#ifdef _FIX_DEL_MAP // WON ADD 玩家抽地图送监狱 +#define LSSPROTO_DM_RECV 99 +#endif + +#ifdef _ITEM_CRACKER +#define LSSPROTO_IC_SEND 100 +#endif + +#ifdef _MAGIC_NOCAST // 精灵:沉默 +#define LSSPROTO_NC_SEND 101 +#endif +#ifdef _CHECK_GAMESPEED +#define LSSPROTO_CS_RECV 103 //加速探针 +#define LSSPROTO_CS_SEND 104 //加速探针 +#endif + +#ifdef _TEAM_KICKPARTY +#define LSSPROTO_KTEAM_RECV 106 +#endif +#ifdef _PETS_SELECTCON +#define LSSPROTO_PETST_SEND 107 +#endif +#ifdef _NEWREQUESTPROTOCOL // (不可开) Syu ADD 新增Protocol要求细项 +#define LSSPROTO_RESIST_RECV 108 +#define LSSPROTO_RESIST_SEND 109 +#endif +#ifdef _OUTOFBATTLESKILL // (不可开) Syu ADD 非战斗时技能Protocol +#define LSSPROTO_BATTLESKILL_RECV 110 +#define LSSPROTO_BATTLESKILL_SEND 111 +#endif +#ifdef _CHATROOMPROTOCOL // (不可开) Syu ADD 聊天室频道 +#define LSSPROTO_CHATROOM_RECV 112 +#define LSSPROTO_CHATROOM_SEND 113 +#endif + +#define LSSPROTO_SPET_RECV 114 // Robin 待机宠 +#define LSSPROTO_SPET_SEND 115 + +#ifdef _STREET_VENDOR +#define LSSPROTO_STREET_VENDOR_RECV 116 // 摆摊功能 +#define LSSPROTO_STREET_VENDOR_SEND 117 +#endif + +#ifdef _RIGHTCLICK +#define LSSPROTO_RCLICK_RECV 118 +#define LSSPROTO_RCLICK_SEND 119 +#endif + +#ifdef _JOBDAILY +#define LSSPROTO_JOBDAILY_SEND 120 // CYG 任务日志功能 +#define LSSPROTO_JOBDAILY_RECV 121 +#endif + +#ifdef _TEACHER_SYSTEM +#define LSSPROTO_TEACHER_SYSTEM_RECV 122 // 导师功能 +#define LSSPROTO_TEACHER_SYSTEM_SEND 123 +#endif + +#ifdef _ADD_STATUS_2 +#define LSSPROTO_S2_RECV 124 +#define LSSPROTO_S2_SEND 125 +#endif + +void lssproto_W_recv(int fd,int x,int y,char* direction); +void lssproto_W2_recv(int fd,int x,int y,char* direction); +void lssproto_XYD_send(int fd,int x,int y,int dir); +void lssproto_EV_recv(int fd,int event,int seqno,int x,int y,int dir); +void lssproto_EV_send(int fd,int seqno,int result); +void lssproto_EN_recv(int fd,int x,int y); +void lssproto_DU_recv(int fd,int x,int y); +void lssproto_EN_send(int fd,int result,int field); +void lssproto_EO_recv(int fd,int dummy); +void lssproto_BU_recv(int fd,int dummy); +void lssproto_JB_recv(int fd,int x,int y); +void lssproto_LB_recv(int fd,int x,int y); +void lssproto_RS_send(int fd,char* data); +void lssproto_RD_send(int fd,char* data); +void lssproto_B_recv(int fd,char* command); +void lssproto_B_send(int fd,char* command); +void lssproto_SKD_recv(int fd,int dir,int index); +void lssproto_ID_recv(int fd,int x,int y,int haveitemindex,int toindex); +void lssproto_PI_recv(int fd,int x,int y,int dir); +void lssproto_DI_recv(int fd,int x,int y,int itemindex); +void lssproto_DG_recv(int fd,int x,int y,int amount); +void lssproto_DP_recv(int fd,int x,int y,int petindex); +void lssproto_I_send(int fd,char* data); +void lssproto_MI_recv(int fd,int fromindex,int toindex); +void lssproto_SI_send(int fd,int fromindex,int toindex); +void lssproto_MSG_recv(int fd,int index,char* message,int color); +void lssproto_MSG_send(int fd,int aindex,char* text,int color); +void lssproto_PMSG_recv(int fd,int index,int petindex,int itemindex,char* message,int color); +void lssproto_PME_send(int fd,int objindex,int graphicsno,int x,int y,int dir,int flg,int no,char* cdata); +void lssproto_AB_recv(int fd); +void lssproto_AB_send(int fd,char* data); +void lssproto_ABI_send(int fd,int num,char* data); +void lssproto_DAB_recv(int fd,int index); +void lssproto_AAB_recv(int fd,int x,int y); +void lssproto_L_recv(int fd,int dir); +void lssproto_TK_recv(int fd,int x,int y,char* message,int color,int area); +void lssproto_TK_send(int fd,int index,char* message,int color); +void lssproto_MC_send(int fd,int fl,int x1,int y1,int x2,int y2,int tilesum,int objsum,int eventsum,char* data); +void lssproto_M_recv(int fd,int fl,int x1,int y1,int x2,int y2); +void lssproto_M_send(int fd,int fl,int x1,int y1,int x2,int y2,char* data); +void lssproto_C_recv(int fd,int index); +void lssproto_C_send(int fd,char* data); +void lssproto_CA_send(int fd,char* data); +void lssproto_CD_send(int fd,char* data); +void lssproto_R_send(int fd,char* data); +void lssproto_S_recv(int fd,char* category); +void lssproto_S_send(int fd,char* data); +void lssproto_D_send(int fd,int category,int dx,int dy,char* data); +void lssproto_FS_recv(int fd,int flg); +void lssproto_FS_send(int fd,int flg); +void lssproto_HL_recv(int fd,int flg); +void lssproto_HL_send(int fd,int flg); +void lssproto_PR_recv(int fd,int x,int y,int request); +void lssproto_PR_send(int fd,int request,int result); +void lssproto_KS_recv(int fd,int petarray); +void lssproto_KS_send(int fd,int petarray,int result); + +#ifdef _STANDBYPET +void lssproto_SPET_recv(int fd,int standbypet); +void lssproto_SPET_send(int fd,int standbypet,int result); +#endif + +void lssproto_AC_recv(int fd,int x,int y,int actionno); +void lssproto_MU_recv(int fd,int x,int y,int array,int toindex); +void lssproto_PS_recv(int fd,int havepetindex,int havepetskill,int toindex,char* data); +void lssproto_PS_send(int fd,int result,int havepetindex,int havepetskill,int toindex); +void lssproto_ST_recv(int fd,int titleindex); +void lssproto_DT_recv(int fd,int titleindex); +void lssproto_FT_recv(int fd,char* data); +void lssproto_SKUP_send(int fd,int point); +void lssproto_SKUP_recv(int fd,int skillid); +void lssproto_KN_recv(int fd,int havepetindex,char* data); +void lssproto_WN_send(int fd,int windowtype,int buttontype,int seqno,int objindex,char* data); +void lssproto_WN_recv(int fd,int x,int y,int seqno,int objindex,int select,char* data); +void lssproto_EF_send(int fd,int effect,int level,char* option); +void lssproto_SE_send(int fd,int x,int y,int senumber,int sw); +void lssproto_SP_recv(int fd,int x,int y,int dir); +void lssproto_ClientLogin_recv(int fd,char* cdkey,char* passwd); +void lssproto_ClientLogin_send(int fd,char* result); +void lssproto_CreateNewChar_recv(int fd,int dataplacenum,char* charname,int imgno,int faceimgno,int vital,int str,int tgh,int dex,int earth,int water,int fire,int wind,int hometown); +void lssproto_CreateNewChar_send(int fd,char* result,char* data); +void lssproto_CharDelete_recv(int fd,char* charname); +void lssproto_CharDelete_send(int fd,char* result,char* data); +void lssproto_CharLogin_recv(int fd,char* charname); +void lssproto_CharLogin_send(int fd,char* result,char* data); + +#ifdef _PKSEVER_VER +void lssproto_CharList_recv( int fd, int star); +#else +void lssproto_CharList_recv(int fd); +#endif + +void lssproto_CharList_send(int fd,char* result,char* data); +void lssproto_CharLogout_recv(int fd, int flg); +void lssproto_CharLogout_send(int fd,char* result,char* data); +void lssproto_ProcGet_recv(int fd); +void lssproto_ProcGet_send(int fd,char* data); +void lssproto_PlayerNumGet_recv(int fd); +void lssproto_PlayerNumGet_send(int fd,int logincount,int player); +void lssproto_Echo_recv(int fd,char* test); +void lssproto_Echo_send(int fd,char* test); +void lssproto_Shutdown_recv(int fd,char* passwd,int min); + +void lssproto_TD_send(int fd, int index, char* message); +void lssproto_TD_recv(int fd, char* message); + +#ifdef _CHATROOMPROTOCOL // (不可开) Syu ADD 聊天室频道 +void lssproto_CHATROOM_recv(int fd , char *data) ; +void lssproto_CHATROOM_send(int fd , char* message ) ; +#endif + +#ifdef _NEWREQUESTPROTOCOL // (不可开) Syu ADD 新增Protocol要求细项 +void lssproto_RESIST_recv(int fd ) ; +void lssproto_RESIST_send(int fd , char* message ) ; +#endif +#ifdef _OUTOFBATTLESKILL // (不可开) Syu ADD 非战斗时技能Protocol +void lssproto_BATTLESKILL_recv(int fd, int iNum) ; +void lssproto_BATTLESKILL_send(int fd , char* message ) ; +#endif + +void lssproto_NU_send(int fd, int nu); + +void lssproto_FM_send(int fd, char* message); +void lssproto_FM_recv(int fd, char* message); + +void lssproto_WO_send(int fd,int effect); +void lssproto_PETST_recv( int fd, int nPet, int sPet); +void lssproto_BM_recv(int fd, int iindex); + +#ifdef _FIX_DEL_MAP // WON ADD 玩家抽地图送监狱 +void lssproto_DM_recv( int fd ); +#endif + +#ifdef _MIND_ICON +void lssproto_MA_recv(int fd, int x, int y, int nMind); +#endif + +#ifdef _ITEM_CRACKER +void lssproto_IC_send(int fd, int x, int y); +#endif + +#ifdef _ITEM_CRACKER +void lssproto_NC_send(int fd,int flg); +#endif + +#ifdef _CHECK_GAMESPEED +void lssproto_CS_recv( int fd ); +void lssproto_CS_send( int fd, int deltimes); +#endif + +#ifdef _TEAM_KICKPARTY +void lssproto_KTEAM_recv( int fd, int si); +#endif + +#ifdef _PETS_SELECTCON +void lssproto_PETS_send(int fd,int petarray,int result); +//#define LSSPROTO_PETST_SEND 107 +#endif + +#ifdef _STREET_VENDOR +void lssproto_STREET_VENDOR_recv(int fd,char *message); +void lssproto_STREET_VENDOR_send(int fd,char *message); +#endif + +#ifdef _RCLICK +void lssproto_RCLICK_recv(int fd, int type, char* data); +void lssproto_RCLICK_send(int fd, int type, char* data); +#endif + +#ifdef _JOBDAILY +void lssproto_JOBDAILY_recv(int fd,char *data); +void lssproto_JOBDAILY_send(int fd,char *data); +#endif + +#ifdef _TEACHER_SYSTEM +void lssproto_TEACHER_SYSTEM_recv(int fd,char *data); +void lssproto_TEACHER_SYSTEM_send(int fd,char *data); +#endif + +#ifdef _ADD_STATUS_2 +void lssproto_S2_recv(int fd,char *data); +void lssproto_S2_send(int fd,char *data); +#endif + +#endif + + + diff --git a/gmsv/include/lssproto_util.h b/gmsv/include/lssproto_util.h new file mode 100644 index 0000000..c06730c --- /dev/null +++ b/gmsv/include/lssproto_util.h @@ -0,0 +1,110 @@ +#ifndef _LSSPROTOUTIL_H_ +#define _LSSPROTOUTIL_H_ +#include +#include +#ifndef WIN32 +#include +#include +#endif +//#define lssproto__ENCRYPT +#define lssproto__NODEBUG +struct lssproto_ { + int (*write_func)(int,char*,int) ; /* write function */ + size_t workbufsize; /* size of work area */ + char *work,*arraywork,*escapework,*val_str,*ret_work; /* work areas which have same size */ + char *cryptwork,*jencodecopy,*jencodeout,*compresswork; /* these work has bigger size (3times)*/ + char** token_list; /* token list */ + unsigned long message_id; /*= 1, */ /* for generating message IDs */ +}; +#ifdef _LSSPROTOUTIL_C_ +struct lssproto_ lssproto = { + NULL, + 0, + NULL,NULL,NULL,NULL,NULL, + NULL,NULL,NULL,NULL, + NULL, + 1, +}; +char **lssproto_stringwrapper; +char lssproto_readlogfilename[1024]; +char lssproto_writelogfilename[1024]; +#else +extern char **lssproto_stringwrapper; +extern struct lssproto_ lssproto; +extern char lssproto_readlogfilename[1024]; +extern char lssproto_writelogfilename[1024]; +#endif + +char* lssproto_escapeString( char*a ); +char* lssproto_descapeString( char*a ); +void lssproto_splitString( char *src ); +void lssproto_strcpysafe( char *dest, char *src, int len ); +void lssproto_strcatsafe( char *dest , char *src , int maxlen ); +char*lssproto_mkstr_int( int i ); +char*lssproto_mkstr_u_int( unsigned int i ); +char*lssproto_mkstr_long( long l ); +char*lssproto_mkstr_u_long( unsigned long l ); +char*lssproto_mkstr_short( short s ); +char*lssproto_mkstr_u_short( short s ); +char*lssproto_mkstr_char( char c ); +char*lssproto_mkstr_u_char( char c); +char*lssproto_mkstr_string( char*a ); +char*lssproto_mkstr_float( float f ); +char*lssproto_mkstr_double( double d ); +char*lssproto_mkstr_int_array( int size , int *array ); +char*lssproto_mkstr_u_int_array( int size , int *array ); +char*lssproto_mkstr_short_array( int size , short *array ); +char*lssproto_mkstr_u_short_array(int size , short *array ); +char *lssproto_mkstr_char_array( int size , char *array ); +char *lssproto_mkstr_u_char_array( int size , unsigned char *array ); +char *lssproto_mkstr_float_array( int size , float *array ); +char *lssproto_mkstr_double_array( int size , double *array ); +int lssproto_demkstr_int( char*a ); +unsigned int lssproto_demkstr_u_int( char*a ); +long lssproto_demkstr_long( char*a ); +unsigned long lssproto_demkstr_u_long(char*a ); +short lssproto_demkstr_short( char*a ); +unsigned short lssproto_demkstr_u_short( char*a ); +char lssproto_demkstr_char( char*a ); +unsigned char lssproto_demkstr_u_char( char*a ); +float lssproto_demkstr_float( char*a ); +double lssproto_demkstr_double(char*a ); +char* lssproto_demkstr_string( char*a); +int *lssproto_demkstr_int_array( char**tk ,int *buf ,int start , int size ); +int *lssproto_demkstr_u_int_array( char **tk , int *buf , int start , int size ); +unsigned int *lssproto_demkstr_long_array( + char **tk , unsigned int *buf , int start , int size ); +unsigned long *lssproto_demkstr_u_long_array( + char **tk , unsigned long *buf , int start , int size ); +short *lssproto_demkstr_short_array( char **tk , short *buf , int start , int size ); +unsigned short*lssproto_demkstr_u_short_array( + char **tk , unsigned short *buf , int start , int size ); +char *lssproto_demkstr_char_array( char **tk , char *buf , int start , int size ); +unsigned char *lssproto_demkstr_u_char_array( + char **tk , unsigned char*buf , int start , int size ); +float *lssproto_demkstr_float_array( char **tk , float *buf , int start , int size ); +double *lssproto_demkstr_u_double_array( char **tk , double *buf , int start , int size ); +char *lssproto_wrapStringAddr( char *copy , int maxcopylen , char*src ); + +void lssproto_GetMessageInfo( int *id , char *funcname , int len,char **tk ); +int lssproto_ClientRead(void); +void lssproto_consumeLine(char *buf , int ofs ); +void lssproto_copyLine( char*src , char *out , int maxoutlen ); +void lssproto_Send( int fd , char *msg ); +int lssproto_AllocateCommonWork(int bufsiz); +unsigned int lssproto_GetNewMessageID(void); +void lssproto_CreateHeader(char*out, char *fname ); +void lssproto_CreateHeaderID( char *out,unsigned long msgid , char *fname ); +int lssproto_default_write_wrap( int fd , char *buf , int size ); +void lssproto_bzero( char *b , int siz ); +void lssproto_bcopy(char*s , char *d , int siz ); +char *lssproto_Ltoa( long v ); +char *lssproto_Ultoa( unsigned long v ); +void lssproto_DebugSend( int fd , char *msg ); +/* Modified by ringo to fasten int type transfer */ +char *lssproto_cnv10to62( int a, char *out, int outlen ); +int lssproto_a62toi( char *a ); +extern int JENCODE_KEY; +#endif + + diff --git a/gmsv/include/magic.h b/gmsv/include/magic.h new file mode 100644 index 0000000..07d957b --- /dev/null +++ b/gmsv/include/magic.h @@ -0,0 +1,67 @@ +#ifndef __MAGIC_H__ +#define __MAGIC_H__ + +/* 热诸 */ +int MAGIC_Use( int charaindex, int haveitemindex, int toindex); +int MAGIC_Recovery( int charaindex, int toindex,int marray, int mp ); +int MAGIC_OtherRecovery( int charaindex, int toindex, int marray, int mp ); +int MAGIC_FieldAttChange( int charaindex, int toindex, int marray, int mp ); +int MAGIC_StatusChange( int charaindex, int toindex, int marray, int mp ); +#ifdef _MAGIC_DEEPPOISON +int MAGIC_StatusChange2( int charaindex, int toindex, int marray, int mp ); +#endif +int MAGIC_StatusRecovery( int charaindex, int toindex, int marray, int mp ); +int MAGIC_MagicDef( int charaindex, int toindex, int marray, int mp ); +int MAGIC_Ressurect( int charaindex, int toindex, int marray, int mp ); +int MAGIC_AttReverse( int charaindex, int toindex, int marray, int mp ); +int MAGIC_ResAndDef( int charaindex, int toindex, int marray, int mp ); +#ifdef _OTHER_MAGICSTAUTS +int MAGIC_MagicStatusChange( int charaindex, int toindex, int marray, int mp ); +#endif +#ifdef __ATTACK_MAGIC +int MAGIC_AttMagic( int charaindex , int toindex , int marray , int mp ); +#endif +#ifdef _ITEM_METAMO +int MAGIC_Metamo( int charaindex, int toindex,int marray, int mp ); +#endif + +#ifdef _ITEM_ATTSKILLMAGIC +int MAGIC_AttSkill( int charaindex, int toindex,int marray, int mp ); +#endif +#ifdef _MAGIC_WEAKEN// vincent 精灵:虚弱 +int MAGIC_Weaken( int charaindex, int toindex, int marray, int mp ); +#endif +#ifdef _MAGIC_BARRIER// vincent 精灵:魔障 +int MAGIC_Barrier( int charaindex, int toindex, int marray, int mp ); +#endif +#ifdef _MAGIC_NOCAST// vincent 精灵:沉默 +int MAGIC_Nocast( int charaindex, int toindex, int marray, int mp ); +#endif +#ifdef _MAGIC_TOCALL +int MAGIC_ToCallDragon( int charaindex, int toindex,int marray, int mp ); +#endif + +//---------------------------------------------------------------------- +// 失奶 丞及匏 井日热诸 寞毛忒允 +// +int MAGIC_GetArrayNo( + int charaindex, // 平乓仿弁正奶件犯永弁旦 + int haveitemindex // 匀化月失奶 丞及匏 +); +// +//---------------------------------------------------------------------- +//------------------------------------------------------------------- +// +// 热诸毛 涛银丹 +// +int MAGIC_DirectUse( + int charaindex, // 银丹平乓仿及奶件犯永弁旦 + int marray, // 银丹热诸及奶件犯永弁旦 + int toindex, // 簿卞银丹" + int itemnum +); +// +//------------------------------------------------------------------- + +#endif + diff --git a/gmsv/include/magic_base.h b/gmsv/include/magic_base.h new file mode 100644 index 0000000..69d3f06 --- /dev/null +++ b/gmsv/include/magic_base.h @@ -0,0 +1,142 @@ +#ifndef __MAGIC_BASE_H__ +#define __MAGIC_BASE_H__ + +#include "util.h" + +typedef enum +{ + MAGIC_FIELD_ALL, /* 允屯化及桦赭匹银尹月 */ + MAGIC_FIELD_BATTLE, /* 爵 及心 */ + MAGIC_FIELD_MAP, /* 骚橘穴永皿晓及心 */ + +}MAGIC_FIELDTYPE; + +typedef enum +{ + MAGIC_TARGET_MYSELF, /* 愤坌及心 */ + MAGIC_TARGET_OTHER, /* 职及谛 愤坌殖戈) */ + MAGIC_TARGET_ALLMYSIDE, /* 蝈 */ + MAGIC_TARGET_ALLOTHERSIDE, /* 锹澎础蝈 */ + MAGIC_TARGET_ALL, /* 蝈化 */ + MAGIC_TARGET_NONE, /* 簿手蓟 请 卅中[ 豢支凶户及凛 */ + MAGIC_TARGET_OTHERWITHOUTMYSELF,/* 职及谛 愤坌殖引卅中) */ + MAGIC_TARGET_WITHOUTMYSELFANDPET, /* 愤坌午矢永玄动陆 */ + MAGIC_TARGET_WHOLEOTHERSIDE,/* 及扔奶玉蝈 */ + +#ifdef __ATTACK_MAGIC + + MAGIC_TARGET_SINGLE, // 针对敌方的某一人 + MAGIC_TARGET_ONE_ROW, // 针对敌方的某一列 + MAGIC_TARGET_ALL_ROWS, // 针对敌方的所有人 + +#endif +}MAGIC_TARGETTYPE; + +typedef enum +{ + MAGIC_ID, /* 栋 寞 */ + MAGIC_FIELD, /* 银尹月桦赭 */ + MAGIC_TARGET, /* 覆擂 */ + MAGIC_TARGET_DEADFLG, /* 韶氏分樊手覆擂卞殖户月井 */ +#ifdef __ATTACK_MAGIC + MAGIC_IDX , +#endif + MAGIC_DATAINTNUM, +}MAGIC_DATAINT; + +typedef enum +{ + MAGIC_NAME, /* 热诸 */ + MAGIC_COMMENT, /* 戊丢件玄*/ + MAGIC_FUNCNAME, /* 楮醒 */ + MAGIC_OPTION, /* 左皿扑亦件 */ + MAGIC_DATACHARNUM, +}MAGIC_DATACHAR; + +typedef struct tagMagic +{ + int data[MAGIC_DATAINTNUM]; + STRING64 string[MAGIC_DATACHARNUM]; + +}Magic; + +#ifdef __ATTACK_MAGIC + +typedef struct tagAttMagic +{ + unsigned int uiSpriteNum;// 此咒术在Spr_x.bin的编号 + unsigned int uiAttackType;// 攻击的方式:单人,整排( 轮流 ) , 整排( 轮流 ) , 整排( 同时 ) , 全体( 轮流 ) , 全体( 同时 ) + unsigned int uiSliceTime;// 轮流攻击时的时间差 + unsigned int uiShowType; // 显示的位置方式:中央、指定 + int siSx; // 显示的位置 - X轴 + int siSy; // 显示的位置 - Y轴 + unsigned int uiShowBehindChar; // 显示在人物的前方或下方 + unsigned int uiShakeScreen; // 是否震动画面 + unsigned int uiShakeFrom; // 震动画面的起始时间( 毫秒 ) + unsigned int uiShakeTo; // 震动画面的结束时间( 毫秒 _ + unsigned int uiPrevMagicNum; // 前置咒术的索引号( 0XFFFFFFFFFF 表示无前置咒术 ) + int siPrevMagicSx; // 前置咒术的显示位置 - X轴 + int siPrevMagicSy; // 前置咒术的显示位置 - Y轴 + int siPrevMagicOnChar; // 前置咒术显示在人物的前方或下方 + unsigned int uiPostMagicNum; // 後置咒术的索引号( 0XFFFFFFFF 表示无後置咒术 ) + int siPostMagicSx; // 後置咒术的显示位置 - X轴 + int siPostMagicSy; // 後置咒术的显示位置 - Y轴 + int siPostMagicOnChar; // 後置咒术显示在人物的前方或下方 + int siField[3][5]; // 攻击索引 +}AttMagic; + +#endif + +#ifdef _MAGIC_TOCALL + +typedef struct tagToCallMagic +{ + unsigned int uiSpriteNum;// 此咒术在Spr_x.bin的编号 + unsigned int uiAttackType;// 攻击的方式:单人,整排( 轮流 ) , 整排( 轮流 ) , 整排( 同时 ) , 全体( 轮流 ) , 全体( 同时 ) + unsigned int uiSliceTime;// 轮流攻击时的时间差 + unsigned int uiShowType; // 显示的位置方式:中央、指定 + int siSx; // 显示的位置 - X轴 + int siSy; // 显示的位置 - Y轴 + unsigned int uiShowBehindChar; // 显示在人物的前方或下方 + unsigned int uiShakeScreen; // 是否震动画面 + unsigned int uiShakeFrom; // 震动画面的起始时间( 毫秒 ) + unsigned int uiShakeTo; // 震动画面的结束时间( 毫秒 _ + unsigned int uiPrevMagicNum; // 前置咒术的索引号( 0XFFFFFFFFFF 表示无前置咒术 ) + int siPrevMagicSx; // 前置咒术的显示位置 - X轴 + int siPrevMagicSy; // 前置咒术的显示位置 - Y轴 + int siPrevMagicOnChar; // 前置咒术显示在人物的前方或下方 + unsigned int uiPostMagicNum; // 後置咒术的索引号( 0XFFFFFFFF 表示无後置咒术 ) + int siPostMagicSx; // 後置咒术的显示位置 - X轴 + int siPostMagicSy; // 後置咒术的显示位置 - Y轴 + int siPostMagicOnChar; // 後置咒术显示在人物的前方或下方 + int isPostDisappear; // 咒术一般攻击完时是否马上消失 + int ToCallMagicNo; // 召唤术的编号 +}ToCallMagic; + +#endif + +typedef int (*MAGIC_CALLFUNC)( int, int, int, int ); + +INLINE BOOL MAGIC_CHECKINDEX( int index ); +INLINE int MAGIC_getInt( int index, MAGIC_DATAINT element); +INLINE int MAGIC_setInt( int index, MAGIC_DATAINT element, int data); +INLINE char* MAGIC_getChar( int index, MAGIC_DATACHAR element); +INLINE BOOL MAGIC_setChar( int index ,MAGIC_DATACHAR element, char* new ); +int MAGIC_getMagicNum( void); +BOOL MAGIC_initMagic( char *filename); +BOOL MAGIC_reinitMagic( void ); + +#ifdef __ATTACK_MAGIC + +BOOL ATTMAGIC_initMagic( char *filename ); +BOOL ATTMAGIC_reinitMagic( void ); + +#endif + +int MAGIC_getMagicArray( int magicid); +MAGIC_CALLFUNC MAGIC_getMagicFuncPointer(char* name); +// Nuke +1 08/23 : For checking the validity of magic target +int MAGIC_isTargetValid( int magicid, int toindex); + +#endif + diff --git a/gmsv/include/magic_field.h b/gmsv/include/magic_field.h new file mode 100644 index 0000000..414195f --- /dev/null +++ b/gmsv/include/magic_field.h @@ -0,0 +1,10 @@ +#ifndef __MAGIC_FIELD_H__ +#define __MAGIC_FIELD_H__ + +/* 白奴□伙玉匹银迕允月热诸 */ + +int MAGIC_Recovery_Field( int charaindex, int magicindex); +int MAGIC_OtherRecovery_Field( int charaindex, int toindex, int magicindex); + +#endif + diff --git a/gmsv/include/map_deal.h b/gmsv/include/map_deal.h new file mode 100644 index 0000000..33281ce --- /dev/null +++ b/gmsv/include/map_deal.h @@ -0,0 +1,11 @@ +#ifndef __MAP_DEAL_H__ +#define __MAP_DEAL_H__ +BOOL MAP_walkAbleFromPoint( int ff, int fx, int fy, BOOL isfly ); +BOOL MAP_walkAble( int index,int ff, int fx, int fy); +void MAP_preovered( int index ); +void MAP_postovered( int index ); +BOOL MAP_sendArroundCharNeedFD( int fd,int charaindex ); +BOOL MAP_sendArroundChar(int charaindex); + +#endif + diff --git a/gmsv/include/map_util.h b/gmsv/include/map_util.h new file mode 100644 index 0000000..77e4b7a --- /dev/null +++ b/gmsv/include/map_util.h @@ -0,0 +1,7 @@ +#ifndef __MAP_UTIL_H__ +#define __MAP_UTIL_H__ + +BOOL MAP_getMapDataFromCharIndex( int index , int* map ); +BOOL MAP_getMapDataFromFXY( int f , int x , int y, int* map ); + +#endif diff --git a/gmsv/include/map_warppoint.h b/gmsv/include/map_warppoint.h new file mode 100644 index 0000000..ecbd39a --- /dev/null +++ b/gmsv/include/map_warppoint.h @@ -0,0 +1,21 @@ +#ifndef __MAPWARPPOINT_H__ +#define __MAPWARPPOINT_H__ + +#include "common.h" +#include "util.h" + +int MAPPOINT_InitMapWarpPoint( void); +void MAPPOINT_resetMapWarpPoint( int flg); +int MAPPOINT_loadMapWarpPoint( void); + +BOOL MAPPOINT_CHECKINDEX( int ps); +int MAPPOINT_getMPointEVType( int ps); + +int MAPPOINT_creatMapWarpObj( int pointindex, char *buf, int objtype); +int MAPPOINT_setMapWarpGoal( int ps, char *buf); +int MAPPOINT_setMapWarpFrom( int ps, char *buf); +int MAPPOINT_getMapWarpGoal( int ps, int ofl, int ox, int oy, int *fl, int *x, int *y); + +void MAPPOINT_MapWarpHandle( int charaindex, int ps, int ofl, int ox, int oy ); + +#endif diff --git a/gmsv/include/mclient.h b/gmsv/include/mclient.h new file mode 100644 index 0000000..f19c131 --- /dev/null +++ b/gmsv/include/mclient.h @@ -0,0 +1,82 @@ +#ifndef __MCLIENT_H__ +#define __MCLIENT_H__ + +#define MSPERSIONALKEY "20020729" + + +#define MPROTO_QUE_SEND 1001 +#define MPROTO_QUE_RECV 1002 + +#define MPROTO_NOTALK_RECV 1004 +#define MPROTO_GMTALK_SEND 1005 +#define MPROTO_GMTALK_RECV 1006 +#define MPROTO_HELLO_SEND 1007 +#define MPROTO_HELLO_RECV 1008 +#define MPROTO_WAEIKICK_SEND 1009 +#define MPROTO_WAEIKICK_RECV 1010 + +#define MPROTO_JAIL_RECV 1012 +#define MPROTO_MESSAGE_RECV 1014 + +#define MPROTO_TYPE_SEND 1016 + +#ifdef _GM_WARP_PLAYER // WON 传送玩家 +#define MPROTO_WARP_RECV 1017 +#endif + +#ifdef _RECAL_ASK_PLAYER // WON 要求人物资料 +#define MPROTO_RECALL_PLAYER_RECV 1018 +#define MPROTO_RECALL_PLAYER_SEND 1019 +#define MPROTO_RECALL_BACKUP_RECV 1020 +#define MPROTO_RECALL_BACKUP_SEND 1021 +#define MPROTO_RECALL_BACKUP_DATE_SEND 1022 +#define MPROTO_RECALL_BACKUP_OK_SEND 1023 +#endif + +#ifdef _RECAL_SEND_COUNT // WON 传送GS资讯 +#define MPROTO_RECALL_COUNT_SEND 1024 +#endif + +#ifdef _RECAL_SERVER_OFF // WON MSERVER 关闭 GS +#define MPROTO_RECALL_SERVER_OFF_RECV 1025 +#endif + +#ifdef _GSERVER_RUNTIME //传送GSERVER执行多少时间给MSERVER +#define MPROTO_RECALL_GSERVER_RUNTIME 1026 +#endif + +int mproto_ClientDispatchMessage(int fd,char* data); + +void mproto_Que_Recv(int fd,char* uid,int userfdid,char* ans); +void mproto_Que_Send( int fd, int uid, int index, char* question); + +void mproto_NoTalk_Recv(int fd,char* uid,int userfdid,int nTime); +void mproto_GMTalk_Recv(int fd,char* uid,int ntime,char* data); +void mproto_WaeiKick_Recv(int fd,char* uid,int userfdid); +void mproto_Jail_Recv(int fd,char* uid,int userfdid); + +void mproto_Message_Recv(int fd,char* uid,int userfdid,char* ans); + +int connectmServer(char* hostname,unsigned short port); +void mproto_Type_Send( int fd, int playernum, int itemuse); + + +#ifdef _GM_WARP_PLAYER // WON 传送玩家 +void mproto_WARP_Recv(int fd,char* uid,int userfdid,int floor, int x, int y); +#endif + +#ifdef _RECAL_ASK_PLAYER // WON 要求人物资料 +void mproto_RECALL_ASK_PLAYER_Recv(int fd, char *uid, int userfdid, int GmCliId, char *id, int char_num, int date, int backup_flag); +void mproto_RECALL_BACKUP_PLAYER_Recv(int fd, char *uid, int userfdid, int GmCliId, char *id, int char_num, int date, char *char_data, int backup_flag); +#endif + + +#ifdef _RECAL_SEND_COUNT // WON 传送GS资讯 +void recal_get_count(); +#endif + +#ifdef _GSERVER_RUNTIME +void gserver_runtime(); +#endif + +#endif diff --git a/gmsv/include/msignal.h b/gmsv/include/msignal.h new file mode 100644 index 0000000..452994b --- /dev/null +++ b/gmsv/include/msignal.h @@ -0,0 +1,8 @@ +#ifndef __SIGNAL_H__ +#define __SIGNAL_H__ + +void signalset( void ); +void shutdownProgram( void ); +void sigshutdown( int number ); + +#endif diff --git a/gmsv/include/net.h b/gmsv/include/net.h new file mode 100644 index 0000000..8be58d1 --- /dev/null +++ b/gmsv/include/net.h @@ -0,0 +1,346 @@ +#ifndef __NET_H__ +#define __NET_H__ + +#include "common.h" + +#include +#include +// Nuke +1 0902: For queuing control +#include + +#if USE_MTIO +#include +#endif + +#include "link.h" + + +#undef EXTERN +#ifdef __NET_C__ +#define EXTERN +#else +#define EXTERN extern +#endif + + + +/* + * 夫弘奶件仄化中卅中} 夫弘奶件仄化中月} 夫弘奶件 平乓仿综曰 + * 夫弘失它玄 ( 本□皮 ) , 夫弘失它玄 ( 失件夫永弁 ) + * N 反 NOT } W 反 WHILE , UL 反 UNLOCK 及仪 + */ +typedef enum +{ + NOTLOGIN, /* 夫弘奶件仄化中卅中 */ + LOGIN, /* 夫弘奶件 */ + WHILELOGIN, /* 夫弘奶件仄化中月 */ + WHILECREATE, /* 综匀化中月 */ + WHILELOGOUTSAVE, /* 夫弘失它玄及本□皮 */ + WHILECANNOTLOGIN, /* 夫弘奶件匹五卅井匀凶凛及失件夫永弁质 */ + WHILECHARDELETE, /* 平乓仿绰轮 */ + WHILEDOWNLOADCHARLIST, /* 平乓仿伉旦玄母它件夫□玉 */ + WHILECHANGEPASSWD, /* 由旦伐□玉 凳 */ + + WHILELOSTCHARSAVE, /* 夫旦玄匹平乓仿本□皮仄 */ + WHILELOSTCHARDELETE,/* 夫旦玄匹平乓仿壅仄 */ + + WHILECLOSEALLSOCKETSSAVE, /* closeallsockets 匹平乓仿本□皮仄 */ + WHILESAVEWAIT, /* 夫弘失它玄及本□皮卞垫仁蟆及赐 谨切 */ +}LoginType; + +/* 仄化中卅中}失市它件玄扔□田}弁仿奶失件玄}失玉丞 */ +typedef enum +{ + NOTDETECTED,AC,CLI,ADM +}ConnectType; + + +/* 扔□田互忡绣仄化云仁赢今 */ +#define CDKEYLEN 16 +#define PASSWDLEN 16 +/* 仇木及 凳反尕第(允月卅日 Char 及STRING64 手赝濠卅袄卞濠曰晶月仇午*/ +#define CHARNAMELEN 32 + +#define CLITIMEOUT_SEC 120 /* 弁仿奶失件玄井日read仄卅井匀凶日} + 仇及凛棉匹正奶丞失它玄}夫弘失它玄[ */ + +#define NET_STRING_SUCCESSFULL "successful" +#define NET_STRING_FAILED "failed" + +// 孔勾丹及 及伉□玉]仿奶玄田永白央扔奶术 +#define RBSIZE 65536 +#define WBSIZE (65536*6) +// 失市它件玄扔□田□迕 + +#define AC_RBSIZE (65536*48) +//#define AC_RBSIZE (65536*32) +//ttom modify because the second version had this +//#define AC_WBSIZE (65536*16) +extern int AC_WBSIZE; + +EXTERN int bindedfd; /*夫□市伙失玉伊旦卞田奶件玉仄凶末弗永玄*/ +EXTERN int acfd; /*失市它件玄扔□田卞戊生弁玄扑正末弗永玄*/ +EXTERN int ConnectLen; /*票及袄及赢今*/ +#define CONNECT_WINDOWBUFSIZE 7 + +//#ifdef _M_SERVER +EXTERN int mfd; +//#endif + +#ifdef _NPCSERVER_NEW +EXTERN int npcfd; +#endif + +/* 湘 凶切 */ +BOOL initConnect( int size ); +void endConnect( void ); +#define CONNECT_endOne( sockfd, lin) \ + _CONNECT_endOne( __FILE__, __LINE__, sockfd, lin) +BOOL _CONNECT_endOne( char *file, int fromline, int sockfd , int lin); +BOOL netloop( void ); +BOOL netloop_faster( void ); +int lsrpcClientWriteFunc( int fd , char* buf , int size ); +char* GetOneLine( int fd ); +BOOL initConnectOne( int sockfd, struct sockaddr_in* sin ,int len ); + + + +/* CA , CD */ +void CAcheck( void ); +void CAflush( int charaindex ); +void CAsend( int fd ); +void CDcheck( void ); +void CDflush( int charaindex ); +void CDsend( int fd ); +BOOL CONNECT_appendCAbuf( int fd , char* data, int size ); +BOOL CONNECT_appendCDbuf( int fd , char* data, int size ); + +/* Serverstate */ +void SERVSTATE_decrementCloseallsocketnum(void); +int SERVSTATE_getCloseallsocketnum( void ); +int SERVSTATE_SetAcceptMore( int nvalue ); +int SERVSTATE_getShutdown(void); +void SERVSTATE_setShutdown(int a); +int SERVSTATE_getLimittime(void); +int SERVSTATE_getDsptime(void); +void SERVSTATE_setDsptime(int a); +void SERVSTATE_setLimittime(int a); + + +/* 公及幻井 */ +void outputNetProcLog( int fd, int mode); +void chardatasavecheck( void ); +void closeAllConnectionandSaveData( void ); +BOOL SetShutdown( BOOL nvalue ); +int GetShutdown( void ); + +/* 伙□皿仄化腹绸楮醒 */ +int getfdFromCdkey( char* cd ); +int getfdFromCharaIndex( int charaindex ); +int getcdkeyFromCharaIndex( int charaindex , char *out, int outlen ); +int getCharindexFromFdid( int fdid ); +int getFdidFromCharaIndex( int charind ); +int getfdFromFdid( int fdid ); +int getfdFromCdkeyWithLogin( char* cd ); + + +/* 仄日屯 */ +INLINE int CONNECT_checkfd( int fd ); +BOOL CONNECT_isCLI( int fd ); +BOOL CONNECT_isAC( int fd ); +BOOL CONNECT_isUnderLogin( int fd ); +BOOL CONNECT_isWhileLogout( int fd ); +BOOL CONNECT_isWhileLogin( int fd ); +BOOL CONNECT_isNOTLOGIN( int fd ); +BOOL CONNECT_isLOGIN( int fd ); + +int CONNECT_getUse( int fd ); +int CONNECT_getUse_debug( int fd, int i ); + +void CONNECT_setCharaindex( int fd, int a ); +int CONNECT_getCharaindex( int fd ); +void CONNECT_getCdkey( int fd , char *out, int outlen ); +void CONNECT_setCdkey( int fd , char *in); +void CONNECT_getPasswd( int fd , char *out, int outlen ); +void CONNECT_setPasswd( int fd, char *in ); +void CONNECT_getCharname( int fd , char *out, int outlen ); +void CONNECT_setCharname( int fd, char *in ); +int CONNECT_getFdid( int fd ); +int CONNECT_getCtype( int fd ); +void CONNECT_setCtype( int fd , int a ); +void CONNECT_setDuelcharaindex( int fd, int i , int a ); +int CONNECT_getDuelcharaindex( int fd, int i ); +void CONNECT_setBattlecharaindex( int fd, int i , int a ); +int CONNECT_getBattlecharaindex( int fd, int i ); +void CONNECT_setJoinpartycharaindex( int fd, int i , int a); +int CONNECT_getJoinpartycharaindex( int fd, int i ); +void CONNECT_setTradecardcharaindex( int fd, int i , int a ); +int CONNECT_getTradecardcharaindex( int fd, int i ); +int CONNECT_getClosed( int fd ); +void CONNECT_setClosed( int fd, int a ); + +/* MT犯田永弘迕穴弁夫 */ +#define CONNECT_endOne_debug(a) CONNECT_endOne( (a) , __LINE__ ) + +/* 犯□正丑综楮醒(引月切允木匀升覆杀迕) */ +void CONNECT_setCDKEY( int sockfd, char *cd ); +void CONNECT_getCDKEY( int sockfd , char *out, int outlen ); +void CONNECT_setState( int fd, int s ); +int CONNECT_getState( int fd ); +void CONNECT_checkStatecount( int a ); +int CONNECT_checkStateSomeOne( int a, int maxcount); + +#if USE_MTIO +int MTIO_setup( void ); +void MTIO_join( void ); +#endif /* USE_MTIO */ + +BOOL CONNECT_acfdInitRB( int fd ); +BOOL CONNECT_acfdInitWB( int fd ); + +// Nuke +3 +int checkWalkTime(int fd); +int setBtime(int fd); + +#ifdef _BATTLE_TIMESPEED +//void setDefBTime( int fd, unsigned int times); +//unsigned int getDefBTime( int fd); +BOOL CheckDefBTime( int charaindex, int fd, unsigned int lowTime, unsigned int battletime, unsigned int addTime); +#endif + +#ifdef _CHECK_GAMESPEED +int getGameSpeedTime( int fd); +void setGameSpeedTime( int fd, int times); +#endif + +#ifdef _TYPE_TOXICATION +void setToxication( int fd, int flg); +int getToxication( int fd); +#endif +int checkBEOTime(int fd); +void sigusr1(int i); +void sigusr2(int i); // Arminius 6.26 signal +//ttom start +void CONNECT_set_watchmode(int fd, BOOL B_Watch); +BOOL CONNECT_get_watchmode(int fd); +void CONNECT_set_shutup(int fd,BOOL b_shut);//the avoid the user wash the screen +BOOL CONNECT_get_shutup(int fd); +unsigned long CONNECT_get_userip(int fd); +void CONNECT_set_pass(int fd,BOOL b_ps); +BOOL CONNECT_get_pass(int fd); +void CONNECT_set_state_trans(int fd,int a); +int CONNECT_get_state_trans(int fd); +//ttom end + +// CoolFish: +9 2001/4/18 +void CONNECT_setCloseRequest(int fd, int count); +void CONNECT_set_first_warp(int fd, BOOL b_ps); +BOOL CONNECT_get_first_warp(int fd); +int isDie(int fd); +void setDie(int fd); + +// Arminius 6/22 encounter +int CONNECT_get_CEP(int fd); +void CONNECT_set_CEP(int fd, int cep); + +// Arminius 7.12 login announce +int CONNECT_get_announced(int fd); +void CONNECT_set_announced(int fd, int a); + +// shan trade(DoubleCheck) begin +int CONNECT_get_confirm(int fd); +void CONNECT_set_confirm(int fd, BOOL b); +// end + +#ifdef _BLACK_MARKET +int CONNECT_get_BMList(int fd, int i); +void CONNECT_set_BMList(int fd,int i, int b); +#endif + +#ifdef _NO_WARP +// shan hjj add Begin +int CONNECT_get_seqno(int fd); +void CONNECT_set_seqno(int fd,int a); +int CONNECT_get_selectbutton(int fd); +void CONNECT_set_selectbutton(int fd, int a); +// shan End +#endif + +void CONNECT_setTradecharaindex( int fd, int i , int a); + +void CONNECT_setLastrecvtime( int fd, struct timeval *a ); +void CONNECT_getLastrecvtime( int fd, struct timeval *a ); +void CONNECT_setLastrecvtime_D( int fd, struct timeval *a ); +void CONNECT_getLastrecvtime_D( int fd, struct timeval *a ); +void CONNECT_SetBattleRecvTime( int fd, struct timeval *a ); +void CONNECT_GetBattleRecvTime( int fd, struct timeval *a ); +void CONNECT_setTradeTmp(int fd, char* a); +void CONNECT_getTradeTmp(int fd, char *trademsg, int trademsglen); +int checkNu(int fd); + +// Arminius 7.2 Ra's amulet +void setNoenemy(int fd); +void clearNoenemy(int fd); +int getNoenemy(int fd); +void setEqNoenemy(int fd, int level); +void clearEqNoenemy(int fd); +int getEqNoenemy(int fd); + +#ifdef _Item_MoonAct +void setEqRandenemy(int fd, int level); +void clearEqRandenemy(int fd); +int getEqRandenemy(int fd); +#endif + +#ifdef _CHIKULA_STONE +void setChiStone(int fd, int nums); +int getChiStone(int fd); +#endif + +// Arminius 7.31 cursed stone +void setStayEncount(int fd); +void clearStayEncount(int fd); +int getStayEncount(int fd); +void CONNECT_setBDTime( int fd, int nums); +int CONNECT_getBDTime( int fd); + +// Arminius debug +void CONNECT_setUse( int fd , int a); + +#ifdef _ITEM_PILEFORTRADE +void CONNECT_setTradeList( int fd, int num); +int CONNECT_getTradeList(int fd); +#endif + +#define QUEUE_LENGTH1 6 +#define QUEUE_LENGTH2 7 + +BOOL MSBUF_CHECKbuflen( int size, float defp); + + +#ifdef _GM_BROADCAST // WON ADD 客服公告系统 + + +typedef struct tag_broadcast_struct +{ + int time; // 讯息间隔时间 + int loop; // 执行次数 + int wait; // 公告完休息时间 + int next_msg; + int max_msg_line; // 讯息数 + char msg[10][128]; // 公告讯息 +}broadcast_struct; + +broadcast_struct BS; + +void Init_GM_BROADCAST( int loop, int time, int wait, char *msg ); +void GM_BROADCAST(); +#endif + + +#ifdef _DEATH_FAMILY_STRUCT // WON ADD 家族战存放胜负资料 +void Init_FM_PK_STRUCT(); +#endif + + +#endif diff --git a/gmsv/include/npc_Dengon.h b/gmsv/include/npc_Dengon.h new file mode 100644 index 0000000..b8835a1 --- /dev/null +++ b/gmsv/include/npc_Dengon.h @@ -0,0 +1,10 @@ +#ifndef __NPC_DENGON_H__ +#define __NPC_DENGON_H__ +BOOL NPC_DengonInit( int meindex ); +//void NPC_DengonSpecialTalked( int index, int talker, char *msg, int color ); +void NPC_DengonLooked( int meindex, int lookedindex ); +void NPC_DengonWindowTalked( int index, int talker, + int seqno, int select, char *data); + +#endif + diff --git a/gmsv/include/npc_action.h b/gmsv/include/npc_action.h new file mode 100644 index 0000000..f19d6df --- /dev/null +++ b/gmsv/include/npc_action.h @@ -0,0 +1,12 @@ +#ifndef __NPC_ACTION_H__ +#define __NPC_ACTION_H__ + +void NPC_ActionTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_ActionInit( int meindex ); +void NPC_ActionWatch( int meobjindex, int objindex, CHAR_ACTION act, + int x,int y,int dir, int* opt,int optlen ); + +#endif + diff --git a/gmsv/include/npc_airplane.h b/gmsv/include/npc_airplane.h new file mode 100644 index 0000000..6e02872 --- /dev/null +++ b/gmsv/include/npc_airplane.h @@ -0,0 +1,12 @@ +#ifndef __NPC_AIRPLANE_H__ +#define __NPC_AIRPLANE_H__ + +BOOL NPC_AirInit( int meindex ); +void NPC_AirLoop( int meindex ); +void NPC_AirTalked( int meindex , int talkerindex , char *szMes , + int color ); +BOOL NPC_AirCheckAllowItem( int meindex, int charaindex, BOOL pickupmode); +BOOL NPC_AirCheckJoinParty( int meindex, int charaindex, BOOL msgflg); + +#endif +/*__NPC_AIRPLANE_H__*/ diff --git a/gmsv/include/npc_alldoman.h b/gmsv/include/npc_alldoman.h new file mode 100644 index 0000000..bc879a1 --- /dev/null +++ b/gmsv/include/npc_alldoman.h @@ -0,0 +1,10 @@ +#ifndef __NPC_ALLDOMAN_H__ +#define __NPC_ALLDOMAN_H__ + +BOOL NPC_AlldomanInit( int meindex ); +void NPC_AlldomanTalked( int meindex , int talker , char *msg ,int color ); +void NPC_AlldomanWindowTalked(int meindex, int talkerindex, int seqno, int select,char *data); +void NPC_AlldomanWriteStele( char *token ) ; +void NPC_Alldoman_S_WriteStele( char *ocdkey , char *oname , char *ncdkey , + char *nname , char *title , int level , int trns , int floor ) ; +#endif diff --git a/gmsv/include/npc_auctioneer.h b/gmsv/include/npc_auctioneer.h new file mode 100644 index 0000000..9499728 --- /dev/null +++ b/gmsv/include/npc_auctioneer.h @@ -0,0 +1,35 @@ +#ifndef __NPC_AUCTIONEER_H__ +#define __NPC_AUCTIONEER_H__ + +#ifdef _AUCTIONEER + +// 以下这两个常数要跟 saac/auction.h 里面的定义一致 +#define MAX_AUCTION 100 // 最大的委托数 +#define MAX_OVERDUE 500 // 过期的委托单保留数 (最小设定=过期保留天数*最大委托数) +#define AUC_PET 1 +#define AUC_ITEM 2 + +typedef struct tagAuctionTable { + int flag; // 0=(null) 1=使用中 2=过期 + char cdkey[32]; // 委托人 cdkey + char customer[32]; // 委托人人物名称 + int itemtype; // 1=宠物 2=道具 otherwise=error + char goods[4096]; // 物品 (宠物 or 道具) + char description[256]; // 叙述 + char listdata[512]; // 显示在表单的资料 + int price; // 标价 + int onsaletime; + int overduetime; +} AuctionTable; + +extern AuctionTable onsale[MAX_AUCTION]; // 拍卖中的道具、宠物 +//extern AuctionTable overdue[MAX_OVERDUE]; // 过期的道具、宠物 + +BOOL NPC_AuctioneerInit(int meindex); +void NPC_AuctioneerTalked(int meindex, int talkerindex, char *msg, int color); +void NPC_AuctioneerWindowTalked(int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_AuctioneerLoop(int meindex); + +#endif /* _AUCTIONEER */ + +#endif diff --git a/gmsv/include/npc_bankman.h b/gmsv/include/npc_bankman.h new file mode 100644 index 0000000..8cd40c7 --- /dev/null +++ b/gmsv/include/npc_bankman.h @@ -0,0 +1,12 @@ +#ifndef __NPC_BANKMAN_H__ +#define __NPC_BANKMAN_H__ + +void NPC_BankmanTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_BankmanInit( int meindex ); +void NPC_BankmanLooked( int meindex, int lookedindex ); +void NPC_BankmanWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +#endif + diff --git a/gmsv/include/npc_bigsmallmaster.h b/gmsv/include/npc_bigsmallmaster.h new file mode 100644 index 0000000..bd2a3b2 --- /dev/null +++ b/gmsv/include/npc_bigsmallmaster.h @@ -0,0 +1,4 @@ +#ifndef __NPC_BIGSMALLMASTER_H__ +#define __NPC_BIGSMALLMASTER_H__ + +#endif diff --git a/gmsv/include/npc_bigsmallpet.h b/gmsv/include/npc_bigsmallpet.h new file mode 100644 index 0000000..5fff2cf --- /dev/null +++ b/gmsv/include/npc_bigsmallpet.h @@ -0,0 +1,4 @@ +#ifndef __NPC_BIGSMALLPET_H__ +#define __NPC_BIGSMALLPET_H__ + +#endif diff --git a/gmsv/include/npc_blackmarket.h b/gmsv/include/npc_blackmarket.h new file mode 100644 index 0000000..3f44a03 --- /dev/null +++ b/gmsv/include/npc_blackmarket.h @@ -0,0 +1,11 @@ +#ifndef __NPC_BLACKMARKET_H__ +#define __NPC_BLACKMARKET_H__ + +#ifdef _BLACK_MARKET +void NPC_BlackMarketTalked( int meindex, int talker, char *msg, int color); +BOOL NPC_BlackMarketInit( int meindex); +void NPC_BlackMarketWindowTalked( int index, int talker, int seqno, int select, char *data); + +#endif + +#endif diff --git a/gmsv/include/npc_bodylan.h b/gmsv/include/npc_bodylan.h new file mode 100644 index 0000000..57f2e30 --- /dev/null +++ b/gmsv/include/npc_bodylan.h @@ -0,0 +1,16 @@ +#ifndef __NPC_BODYLAN_H__ +#define __NPC_BODYLAN_H__ + +void NPC_BodyLanTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_BodyLanInit( int meindex ); +void NPC_BodyLanWatch( int meindex , int lookedindex); +void NPC_BodyLanWindowTalked( + int meindex, + int talkerindex, + int seqno, + int select, + char *data +); + +#endif diff --git a/gmsv/include/npc_bus.h b/gmsv/include/npc_bus.h new file mode 100644 index 0000000..98d5d6a --- /dev/null +++ b/gmsv/include/npc_bus.h @@ -0,0 +1,12 @@ +#ifndef __NPC_BUS_H__ +#define __NPC_BUS_H__ + +BOOL NPC_BusInit( int meindex ); +void NPC_BusLoop( int meindex ); +void NPC_BusTalked( int meindex , int talkerindex , char *szMes , + int color ); +BOOL NPC_BusCheckAllowItem( int meindex, int charaindex, BOOL pickupmode); +BOOL NPC_BusCheckJoinParty( int meindex, int charaindex, BOOL msgflg); + +#endif + diff --git a/gmsv/include/npc_charm.h b/gmsv/include/npc_charm.h new file mode 100644 index 0000000..73785a7 --- /dev/null +++ b/gmsv/include/npc_charm.h @@ -0,0 +1,11 @@ +#ifndef __NPC_CHARM_H__ +#define __NPC_CHARM_H__ + +void NPC_CharmTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_CharmInit( int meindex ); +void NPC_CharmWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_CharmLooked( int meindex , int lookedindex); + +#endif + diff --git a/gmsv/include/npc_checkman.h b/gmsv/include/npc_checkman.h new file mode 100644 index 0000000..77fbf31 --- /dev/null +++ b/gmsv/include/npc_checkman.h @@ -0,0 +1,11 @@ +#ifndef __NPC_CHECKMAN_H__ +#define __NPC_CHECKMAN_H__ + +void NPC_CheckManTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_CheckManInit( int meindex ); +void NPC_CheckManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_CheckManLooked( int meindex , int lookedindex); + +#endif + diff --git a/gmsv/include/npc_door.h b/gmsv/include/npc_door.h new file mode 100644 index 0000000..003c71a --- /dev/null +++ b/gmsv/include/npc_door.h @@ -0,0 +1,31 @@ +#ifndef __NPC_DOOR_H__ +#define __NPC_DOOR_H__ + +BOOL NPC_DoorInit(int meindex ); +void NPC_DoorTalked( int meindex , int talkerindex , char *msg , int color ); +void NPC_DoorPreAttacked(int meindex , int attacker , float *dm); +void NPC_DoorPostOver( int meindex , int movedindex ); +void NPC_DoorOff( int meindex , int movedindex ); +void NPC_DoorWatch( int meindex, int moveindex, CHAR_ACTION act, + int x, int y, int dir, int* opt, int optlen ); +int NPC_DoorSearchByName( char *name ); +int NPC_DoorSearchByPosition( int fl , int x, int y ); +void NPC_DoorLooked( int meindex , int lookedindex ); +BOOL NPC_DoorRefreshOverFlg( int meind ); + + +/* 职及NPC井日丑综今木月迕[NPC棉皿夫玄戊伙卞勾中化反 npc_stepswitch.c毛心欠 */ +int NPC_DoorSetPasswd( int meindex, char *pas ); +int NPC_DoorGetPasswd( int meindex, char *out , int len ); +void NPC_DoorFlip(int meindex , int doindex); +void NPC_DoorClose(int meindex , int doindex); +void NPC_DoorOpen(int meindex , int doindex ); +void NPC_DoorAddSwitchCounter( int meindex , int i , int talker ); +void NPC_DoorSetSwitchCounter( int meindex, int i , int doindex ); + +#endif + + + + + diff --git a/gmsv/include/npc_doorman.h b/gmsv/include/npc_doorman.h new file mode 100644 index 0000000..52e32de --- /dev/null +++ b/gmsv/include/npc_doorman.h @@ -0,0 +1,9 @@ +#ifndef __NPC_DOORMAN_H__ +#define __NPC_DOORMAN_H__ + +BOOL NPC_DoormanInit( int meindex ); +void NPC_DoormanTalked( int meindex , int talkerindex , char *msg , + int color ); + +#endif + diff --git a/gmsv/include/npc_duelranking.h b/gmsv/include/npc_duelranking.h new file mode 100644 index 0000000..3c7f5d2 --- /dev/null +++ b/gmsv/include/npc_duelranking.h @@ -0,0 +1,15 @@ +#ifndef __NPC_DUELRANKING_H__ +#define __NPC_DUELRANKING_H__ + +BOOL NPC_DuelrankingInit( int meindex ); +void NPC_DuelrankingLooked( int meindex, int lookedindex ); +void NPC_DuelrankingWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_Duelranking_PrintRanking( char *data, int count_start, int fdid, int msgid2); +void NPC_Duelranking_CallMyRanking( int count, int msgid, int msgid2); + +#ifdef _DEATH_CONTEND +void NPC_Duelrankingloop( int meindex); +#endif + +#endif + diff --git a/gmsv/include/npc_eventaction.h b/gmsv/include/npc_eventaction.h new file mode 100644 index 0000000..5853fff --- /dev/null +++ b/gmsv/include/npc_eventaction.h @@ -0,0 +1,123 @@ +#ifndef _PRO_NPCFIX_H +#define _PRO_NPCFIX_H +//ANDY_Edit +BOOL ActionNpc_CheckMenuFree( int meindex, int toindex, char *npcarg, int nums); +BOOL ActionNpc_CheckFree( int meindex, int toindex, char *npcarg); +BOOL Action_RunDoEventAction( int meindex, int toindex, char *buf1); +BOOL ActionNpc_WarpPoint(int meindex,int talker,char *npcarg); +BOOL Action_PartyCheck( int meindex, int talker); +BOOL NPC_ActionAddGold( int talker, int Golds); +BOOL NPC_ActionDelGold( int talker,char *buf); +// WON ADD +BOOL NPC_ActionAddGold2( int talker,char *buf); +BOOL NPC_ActionDelPet( int toindex,char *buf); +#ifdef _NPC_NewDelPet +BOOL NPC_ActionNewDelPet( int talker,char *msg); +#endif +BOOL NPC_ActionAddPet( int talker, char *buf); +BOOL NPC_ActionDelItem( int talker,char *buf); +BOOL NPC_ActionAddItem( int talker, char *buf); +BOOL NPC_ActionSetEend( int talkerindex, char * buf); +BOOL NPC_ActionSetNow( int toindex, char * buf); +BOOL NPC_ActionClearEvent( int toindex, char * buf); + +BOOL NPC_ActionCheckTrans(int meindex,int talker,int trans,int flg); +BOOL NPC_ActionLevelCheck(int meindex,int talker,int level,int flg); + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 +BOOL NPC_ActionClassCheck( int meindex,int talker,int p_class,int flg); + +BOOL NPC_ActionSkillCheck( int meindex,int talker,int skillId,int flg); +BOOL NPC_ActionSkillNumCheck( int meindex,int talker,int sknum,int flg); + +BOOL NPC_ActionSkillPointAndSkillCheck( int meindex,int talker,int sknum,int flg); + + +BOOL NPC_ActionCleanProfession( int toindex, char *buf); +BOOL NPC_ActionAddProfessionSkillPoint( int toindex, char *buf ); +#endif + +BOOL NPC_ActionGoldCheck(int meindex,int talker,int Golds,int flg); +BOOL NPC_ActionPartyCheck( int toindex, int nums, int flg); +BOOL NPC_ActionReItemCheck( int toindex, int nums, int flg); +BOOL NPC_ActionRePetCheck( int toindex, int nums, int flg); +BOOL ActionCheckMyPet( int meindex, int talker, int petLv, int flg, int petid); +BOOL NPC_ActionBigSmallLastCheck(int point1,int mypoint,int flg); + +BOOL NPC_ActionItemCheck(int meindex,int talker,int itemNo, int flg); +BOOL NPC_ActioneEquitCheck(int meindex,int talker,int itemNo, int flg); + +BOOL NPC_ActionFreeIfCheck(int meindex,int talker, char* buf, char *opt, int kosuu,int flg, int temp); + +BOOL NPC_ActionBigSmallCheck(int meindex,int talker,char* buf); +BOOL NPC_ActionPassCheck( int meindex, int talker, char *buf); +BOOL NPC_ActionWarpManReduce(int meindex,int talker,char *buf); +#ifdef _NPC_ActionFreeCmp +BOOL NPC_ActionWarpManReduce2(int meindex,int talker,char *buf); +#endif +#ifdef _NPCCHANGE_PLAYERIMG //andy +BOOL NPC_ActionChangePlayerBBI( int meindex, int charindex, char *Img); +BOOL NPC_CheckPlayerBBI( int meindex, int charindex, int BBI, int flg); +#endif + +BOOL showString( int meindex, char *showstr,int flg); +BOOL NPC_getTimeXYPoint( int meindex, int Mode); +BOOL NPC_getTimeData( int meindex, char *npcarg, int *born, int *dead, int loopspeed); +void NPC_TimeDefineDo( int meindex, int born, int dead, int typeMode); +BOOL NPC_CheckTimeDefine( char *timetype); + +void GetRand_WarpPoint( char *buf, int *fl, int *x, int *y ); +#ifdef _EMENY_CHANCEMAN +int NPC_EmenyChanceCheck( int meindex, int charaindex, char *arg); +int NPC_DischargePartyForSex( int meindex, int charaindex, int fl, int x, int y, int fsex); +#endif + + +#ifdef _ACTION_GMQUE +BOOL CheckGmQueflg( int talker,int nCount,int flg); +BOOL GMQUE_InSertQue( int meindex, int charaindex); +BOOL GMQUE_getQueStr( int meindex, int charaindex); +void GMQUE_cleanQueStr( int nindex); +void GMQUE_showQueStr( int meindex, int charaindex); +BOOL GMQUE_CheckQueStr( int meindex, int charaindex, int count); +BOOL GMQUE_DelQueStrPet( int meindex, int charaindex, int count); +BOOL GMQUE_AddQueStrTrophy( int meindex, int charaindex); +#endif + +BOOL NPC_ActionDuelRankCheck(int meindex,int talker,int rank,int flg); +BOOL NPC_ActionDuelPointCheck(int meindex,int talker,int rank,int flg); + + +#ifdef _ACTION_BULLSCR +BOOL NPC_ActionCheckABulltime( int meindex,int talker,int nCount,int flg); +BOOL NPC_ActionCheckABullstart( int meindex,int talker,int start,int flg); +BOOL NPC_ActionCheckABullscore( int meindex,int talker,int score,int flg); +BOOL NPC_ActionCheckABullEvent( int meindex,int talker); + +#endif + +#ifdef _TREASURE_BOX +BOOL NPC_ActionTreasureTypeCheck( int meindex, int level, int type, int flg); +#endif +BOOL NPC_ActionTreasureRandItemGet(int meidex,int talker,int rand_j,char *buf); +void NPC_ActionLevelAndTransUp( int meindex, int charindex, int level, + int skillpoint, int exp, int ridepet); +#ifdef _ITEM_PILENUMS +BOOL NPC_ActionDoPileDelItem( int toindex, int itemID, int num); +BOOL NPC_DelItem( int toindex, int ti, int num); +#endif +void NPC_ActionDoPileClearItem( int toindex, int itemID); + + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 +int PROFESSION_RESTORE_POINT( int charaindex ); +#endif + + +#ifdef _NPC_ADDWARPMAN1 +BOOL NPC_ActionPartyCountCheck( int toindex, int nums, int flg); +BOOL NPC_ActionManCountCheck( int toindex, int nums, int flg);//检查男生人数 +BOOL NPC_ActionWomanCountCheck( int toindex, int nums, int flg);//检查女生人数 +#endif + +#endif diff --git a/gmsv/include/npc_exchangeman.h b/gmsv/include/npc_exchangeman.h new file mode 100644 index 0000000..aa78b7f --- /dev/null +++ b/gmsv/include/npc_exchangeman.h @@ -0,0 +1,22 @@ +#ifndef __NPC_EXCHANGEMAN_H__ +#define __NPC_EXCHANGEMAN_H__ + +void NPC_ExChangeManTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_ExChangeManInit( int meindex ); +void NPC_ExChangeManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + + + +BOOL NPC_EventCheckFlg( int talker, int shiftbit); +BOOL NPC_NowEventCheckFlg( int talker, int shiftbit); + +// Arminius 8.14 move from .c (for pet talk) +BOOL NPC_EventBigSmallCheck(int meindex,int talker,char* buf); + +#endif + + + /*__NPC_EXCHANGEMAN_H__*/ + + diff --git a/gmsv/include/npc_familyman.h b/gmsv/include/npc_familyman.h new file mode 100644 index 0000000..57e08d4 --- /dev/null +++ b/gmsv/include/npc_familyman.h @@ -0,0 +1,13 @@ +#ifndef __NPC_FAMILYMAN_H__ +#define __NPC_FAMILYMAN_H__ + +void NPC_FamilymanTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_FamilymanInit( int meindex ); +void NPC_FamilymanLooked( int meindex, int lookedindex ); +void NPC_FamilymanWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +#endif + +/*__NPC_FAMILYMAN_H__*/ diff --git a/gmsv/include/npc_fmdengon.h b/gmsv/include/npc_fmdengon.h new file mode 100644 index 0000000..858f170 --- /dev/null +++ b/gmsv/include/npc_fmdengon.h @@ -0,0 +1,10 @@ +#ifndef __NPC_FMDENGON_H__ +#define __NPC_FMDENGON_H__ + +BOOL NPC_FmDengonInit( int meindex ); +void NPC_FmDengonLooked( int meindex, int lookedindex ); +void NPC_FmDengonWindowTalked( int index, int talker, int seqno, int select, char *data); + +#endif + +/*__NPC_FMDENGON_H__*/ diff --git a/gmsv/include/npc_fmhealer.h b/gmsv/include/npc_fmhealer.h new file mode 100644 index 0000000..2c62fce --- /dev/null +++ b/gmsv/include/npc_fmhealer.h @@ -0,0 +1,9 @@ +#ifndef __NPC_FMHEALER_H__ +#define __NPC_FMHEALER_H__ + +void NPC_FmHealerTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_FmHealerInit( int meindex ); + +#endif +/*__NPC_FMHEALER_H__*/ diff --git a/gmsv/include/npc_fmletter.h b/gmsv/include/npc_fmletter.h new file mode 100644 index 0000000..f60aef5 --- /dev/null +++ b/gmsv/include/npc_fmletter.h @@ -0,0 +1,13 @@ +#ifndef __NPC_FMLETTER_H__ +#define __NPC_FMLETTER_H__ + +void NPC_FmLetterTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_FmLetterInit( int meindex ); +void NPC_FmLetterLooked( int meindex, int lookedindex ); +void NPC_FmLetterWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +#endif + +/*__NPC_FMLETTER_H__*/ diff --git a/gmsv/include/npc_fmpkcallman.h b/gmsv/include/npc_fmpkcallman.h new file mode 100644 index 0000000..8702b1c --- /dev/null +++ b/gmsv/include/npc_fmpkcallman.h @@ -0,0 +1,10 @@ +#ifndef __NPC_FMPKCALLMAN_H__ +#define __NPC_FMPKCALLMAN_H__ + +void NPC_FMPKCallManTalked(int meindex, int talkerindex, char *msg, int color); +BOOL NPC_FMPKCallManInit(int meindex); +void NPC_FMPKCallManWindowTalked(int meindex, int talkerindex, int seqno, + int select, char *data); + +#endif +/*__NPC_FMPKCALLMAN_H__*/ diff --git a/gmsv/include/npc_fmpkman.h b/gmsv/include/npc_fmpkman.h new file mode 100644 index 0000000..2053f02 --- /dev/null +++ b/gmsv/include/npc_fmpkman.h @@ -0,0 +1,10 @@ +#ifndef __NPC_FMPKMAN_H__ +#define __NPC_FMPKMAN_H__ + +void NPC_FMPKManTalked(int meindex, int talkerindex, char *msg, int color); +BOOL NPC_FMPKManInit(int meindex); +void NPC_FMPKManWindowTalked(int meindex, int talkerindex, int seqno, + int select, char *data); + +#endif +/*__NPC_FMPKMAN_H__*/ diff --git a/gmsv/include/npc_fmwarpman.h b/gmsv/include/npc_fmwarpman.h new file mode 100644 index 0000000..4bb0b60 --- /dev/null +++ b/gmsv/include/npc_fmwarpman.h @@ -0,0 +1,30 @@ +#ifndef __NPC_FMWARPMAN_H__ +#define __NPC_FMWARPMAN_H__ + +void NPC_FMWarpManTalked(int meindex, int talkerindex, char *msg, int color); +BOOL NPC_FMWarpManInit(int meindex); +void NPC_FMWarpManWindowTalked(int meindex, int talkerindex, int seqno, + int select, char *data); +void NPC_FMWarpManLoop(int meindex); +void NPC_GetPKFMNum(int floor, int fmindex1, int fmindex2, int *num1, int *num2); + + + +#ifdef _DEATH_FAMILY_GM_COMMAND // WON ADD 家族战GM指令 +void set_fm_pk_score( int win_index, int loser_index, char *win_name, char *loser_name ); +void swap_fm_pk_struct( int no1, int no2 ); +int get_fm_pk_index( int win_index ); +void read_fm_pk_score(); +void save_fm_pk_score(); + +#endif + + + + + + + + +#endif +/*__NPC_FMWARPMAN_H__*/ diff --git a/gmsv/include/npc_freepetskillshop.h b/gmsv/include/npc_freepetskillshop.h new file mode 100644 index 0000000..73bc822 --- /dev/null +++ b/gmsv/include/npc_freepetskillshop.h @@ -0,0 +1,10 @@ +#ifndef __NPC_FREEPETSKILLSHOP_H__ +#define __NPC_FREEPETSKILLSHOP_H__ + +BOOL NPC_FreePetSkillShopInit( int meindex ); +void NPC_FreePetSkillShopTalked( int meindex , int talkerindex , char *msg , int color ); +void NPC_FreePetSkillShopWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +//void NPC_PetSkillShopLooked( int meindex , int lookedindex); +BOOL NPC_CHECKFREEPETSKILL( int toindex, int petindex, int skillID); +#endif + diff --git a/gmsv/include/npc_gamblebank.h b/gmsv/include/npc_gamblebank.h new file mode 100644 index 0000000..017f2c1 --- /dev/null +++ b/gmsv/include/npc_gamblebank.h @@ -0,0 +1,9 @@ +#ifndef __NPC_GAMBLEBANK_H__ +#define __NPC_GAMBLEBANK_H__ +BOOL NPC_GambleBankInit( int meindex ); +void NPC_GambleBankLoop( int meindex); +void NPC_GambleBankTalked( int meindex , int talkerindex , char *msg , int color ); +void NPC_GambleBankWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +#endif + + diff --git a/gmsv/include/npc_gamblemaster.h b/gmsv/include/npc_gamblemaster.h new file mode 100644 index 0000000..9c28474 --- /dev/null +++ b/gmsv/include/npc_gamblemaster.h @@ -0,0 +1,9 @@ +#ifndef NPC_Gamble_Master_ +#define NPC_Gamble_Master_ + +BOOL NPC_Gamble_MasterInit( int meindex ); +void NPC_Gamble_MasterLoop( int meindex ); +void NPC_Gamble_MasterWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_Gamble_MasterTalked( int meindex , int talkerindex , char *szMes , int color ); +#endif + diff --git a/gmsv/include/npc_gambleroulette.h b/gmsv/include/npc_gambleroulette.h new file mode 100644 index 0000000..0dacc59 --- /dev/null +++ b/gmsv/include/npc_gambleroulette.h @@ -0,0 +1,9 @@ +#ifndef NPC_Gamble_Roulette_ +#define NPC_Gamble_Roulette_ + +BOOL NPC_Gamble_RouletteInit( int meindex ); +void NPC_Gamble_RouletteLoop( int meindex ); +void NPC_Gamble_RouletteWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_Gamble_RouletteTalked( int meindex , int talkerindex , char *szMes , int color ); +#endif + diff --git a/gmsv/include/npc_healer.h b/gmsv/include/npc_healer.h new file mode 100644 index 0000000..70ff815 --- /dev/null +++ b/gmsv/include/npc_healer.h @@ -0,0 +1,10 @@ +#ifndef __NPC_HEALER_H__ +#define __NPC_HEALER_H__ + +void NPC_HealerTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_HealerInit( int meindex ); + +#endif + /*__NPC_HEALER_H__*/ diff --git a/gmsv/include/npc_itemchange.h b/gmsv/include/npc_itemchange.h new file mode 100644 index 0000000..63ac849 --- /dev/null +++ b/gmsv/include/npc_itemchange.h @@ -0,0 +1,12 @@ +#ifndef _ITEM_CHANGE_ +#define _ITEM_CHANGE_ + +//#ifdef _CFREE_petskill +BOOL NPC_ItemchangeManInit( int meindex ); +void NPC_ItemchangeManTalked( int meindex, int talkerindex, char *msg, int color ); +void NPC_ItemchangeManWindowTalked( int meindex, int talkerindex, int seqno, + int select, char *data); +void NPC_ItemchangeManLoop( int meindex); + +#endif + diff --git a/gmsv/include/npc_itemshop.h b/gmsv/include/npc_itemshop.h new file mode 100644 index 0000000..f6d757b --- /dev/null +++ b/gmsv/include/npc_itemshop.h @@ -0,0 +1,12 @@ +#ifndef __NPC_ITEMSHOP_H__ +#define __NPC_ITEMSHOP_H__ + +void NPC_ItemShopTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_ItemShopInit( int meindex ); +void NPC_ItemShopWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_ItemShopLooked( int meindex , int lookedindex); + + +#endif + /*__NPC_ITEMSHOP_H__*/ diff --git a/gmsv/include/npc_janken.h b/gmsv/include/npc_janken.h new file mode 100644 index 0000000..411abb8 --- /dev/null +++ b/gmsv/include/npc_janken.h @@ -0,0 +1,10 @@ +#ifndef __NPC_JANKEN_H__ +#define __NPC_JANKEN_H__ + +void NPC_JankenTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_JankenInit( int meindex ); +void NPC_JankenWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +#endif + /*__NPC_JANKEN_H__*/ diff --git a/gmsv/include/npc_luckyman.h b/gmsv/include/npc_luckyman.h new file mode 100644 index 0000000..36c4db4 --- /dev/null +++ b/gmsv/include/npc_luckyman.h @@ -0,0 +1,10 @@ +#ifndef __NPC_LUCKYMAN_H__ +#define __NPC_LUCKYMAN_H__ + +void NPC_LuckyManTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_LuckyManInit( int meindex ); +void NPC_LuckyManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +#endif +/*__NPC_LUCKYMAN_H__*/ diff --git a/gmsv/include/npc_makepair.h b/gmsv/include/npc_makepair.h new file mode 100644 index 0000000..f0d775d --- /dev/null +++ b/gmsv/include/npc_makepair.h @@ -0,0 +1,22 @@ +#ifndef _MAKEPAIR_MAN_H +#define _MAKEPAIR_MAN_H + +void NPC_MakePairManTalked( int meindex, int talkerindex, char *msg, int color ); +BOOL NPC_MakePairManInit( int meindex ); +void NPC_MakePairManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_MakePairManLoop( int meindex); + +typedef struct _tagPairMenu{ + char cdKey[256]; + char name[256]; + int pindex; + int forindex; + int code; + int use; +}PairMenu; + + + +#endif + + diff --git a/gmsv/include/npc_manorsman.h b/gmsv/include/npc_manorsman.h new file mode 100644 index 0000000..284d937 --- /dev/null +++ b/gmsv/include/npc_manorsman.h @@ -0,0 +1,19 @@ +#ifndef __NPC_MANORSMAN_H__ +#define __NPC_MANORSMAN_H__ + +BOOL NPC_ManorSmanInit(int meindex); +void NPC_ManorSmanTalked(int meindex, int talkerindex, char *msg, int color); +void NPC_ManorSmanWindowTalked(int meindex, int talkerindex, + int seqno, int select, char *data); +void NPC_ManorSmanLoop(int meindex); +//andy_123 +int NPC_getManorsmanListIndex( int ID); +#ifndef _NEW_MANOR_LAW +void NPC_ManorSavePKSchedule(int meindex, int toindex, int flg); +#else +void NPC_ManorSavePKSchedule(int meindex, int toindex, int flg,int setTime,struct tm tm1); +void NPC_ManorAddToSchedule(int meindex,int charaindex); +#endif + +#endif +/*__NPC_MANORSMAN_H__*/ diff --git a/gmsv/include/npc_mic.h b/gmsv/include/npc_mic.h new file mode 100644 index 0000000..501e0d4 --- /dev/null +++ b/gmsv/include/npc_mic.h @@ -0,0 +1,9 @@ +#ifndef __NPC_MIC_H__ +#define __NPC_MIC_H__ + +BOOL NPC_MicInit(int meindex ); +void NPC_MicTalked( int meindex , int talkerindex , char *msg , int color ); + +#endif + /*__NPC_MIC_H__*/ + diff --git a/gmsv/include/npc_msg.h b/gmsv/include/npc_msg.h new file mode 100644 index 0000000..f0f875b --- /dev/null +++ b/gmsv/include/npc_msg.h @@ -0,0 +1,9 @@ +#ifndef _NPC_MSG_H_ +#define _NPC_MSG_H_ + +BOOL NPC_MsgInit( int meindex ); +void NPC_MsgLooked( int meindex , int lookedindex ); + + +#endif + diff --git a/gmsv/include/npc_mtradenpcman.h b/gmsv/include/npc_mtradenpcman.h new file mode 100644 index 0000000..93135bf --- /dev/null +++ b/gmsv/include/npc_mtradenpcman.h @@ -0,0 +1,10 @@ +#ifndef __NPC_MAPTRADEMAN_H__ +#define __NPC_MAPTRADEMAN_H__ + +BOOL MapTradeManInit( int meindex ); +void MapTradeManLoop( int meindex); +void MapTradeManTalked( int meindex , int talkerindex , char *msg , int color ); +void MapTradeManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +#endif + diff --git a/gmsv/include/npc_newnpcman.h b/gmsv/include/npc_newnpcman.h new file mode 100644 index 0000000..9ad31b7 --- /dev/null +++ b/gmsv/include/npc_newnpcman.h @@ -0,0 +1,8 @@ +#ifndef __NPC_NEWNPCMAN_H__ +#define __NPC_NEWNPCMAN_H__ +BOOL NPC_NewNpcManInit( int meindex ); +void NPC_NewNpcManLoop( int meindex); +void NPC_NewNpcManTalked( int meindex , int talkerindex , char *msg , int color ); +void NPC_NewNpcManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +#endif + diff --git a/gmsv/include/npc_npcenemy.h b/gmsv/include/npc_npcenemy.h new file mode 100644 index 0000000..62134e4 --- /dev/null +++ b/gmsv/include/npc_npcenemy.h @@ -0,0 +1,17 @@ +#ifndef __NPC_NPCENEMY_H__ +#define __NPC_NPCENEMY_H__ + +void NPC_NPCEnemyTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_NPCEnemyInit( int meindex ); +int NPC_NPCEnemy_Dying( int battleindex, int meindex ); +int NPC_NPCEnemy_Encount( int meindex, int charaindex, int mode); +void NPC_NPCEnemyWatch( int meobjindex, int objindex, CHAR_ACTION act, + int x,int y,int dir, int* opt,int optlen ); +void NPC_NPCEnemyLoop( int meindex ); +BOOL NPC_NPCEnemy_BattleIn( int meindex, int charaindex); +void NPC_NPCEnemyWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +#endif + /*__NPC_NPCENEMY_H__*/ diff --git a/gmsv/include/npc_oldman.h b/gmsv/include/npc_oldman.h new file mode 100644 index 0000000..2b457b9 --- /dev/null +++ b/gmsv/include/npc_oldman.h @@ -0,0 +1,12 @@ +#ifndef __NPC_OLDMAN_H__ +#define __NPC_OLDMAN_H__ + + +void NPC_OldmanTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_OldmanInit( int meindex ); + + +#endif +/*__NPC_OLDMAN_H__*/ diff --git a/gmsv/include/npc_pauctionman.h b/gmsv/include/npc_pauctionman.h new file mode 100644 index 0000000..f48b0fe --- /dev/null +++ b/gmsv/include/npc_pauctionman.h @@ -0,0 +1,17 @@ +#ifndef _PAUCTION_MAN_H +#define _PAUCTION_MAN_H + + +BOOL NPC_PauctionManInit( int meindex ); +void NPC_PauctionManTalked( int meindex, int talkerindex, char *msg, int color ); +void NPC_PauctionManWindowTalked( int meindex, int talkerindex, int seqno, + int select, char *data); +void NPC_PauctionManLoop( int meindex); + +int NPC_PAItemShop_AddItem( int itemID, int ret); +BOOL NPC_PAItemShop_DelItem( int ti, int index); +BOOL NPC_PAItemShop_reItem( int itemindex, char *Data); + +#endif + + diff --git a/gmsv/include/npc_petfusion.h b/gmsv/include/npc_petfusion.h new file mode 100644 index 0000000..3fbe665 --- /dev/null +++ b/gmsv/include/npc_petfusion.h @@ -0,0 +1,11 @@ +#ifndef __NPC_PETFUSION_H__ +#define __NPC_PETFUSION_H__ + + +void NPC_PetFusionManTalked( int meindex, int talkerindex, char *msg, int color ); +BOOL NPC_PetFusionManInit( int meindex ); +void NPC_PetFusionManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_PetFusionManLoop( int meindex); + +#endif + diff --git a/gmsv/include/npc_petmaker.h b/gmsv/include/npc_petmaker.h new file mode 100644 index 0000000..2754e9b --- /dev/null +++ b/gmsv/include/npc_petmaker.h @@ -0,0 +1,9 @@ +#ifndef __NPC_PETMAKER_H__ +#define __NPC_PETMAKER_H__ + +void NPC_PetMakerTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_PetMakerInit( int meindex ); + +#endif + /*__NPC_PETMAKER_H__*/ diff --git a/gmsv/include/npc_petracemaster.h b/gmsv/include/npc_petracemaster.h new file mode 100644 index 0000000..c8caa27 --- /dev/null +++ b/gmsv/include/npc_petracemaster.h @@ -0,0 +1,10 @@ +#ifndef NPC_PetRace_Master_ +#define NPC_PetRace_Master_ + +BOOL NPC_PetRaceMasterInit( int meindex ); +void NPC_PetRaceMasterLoop( int meindex ); +void NPC_PetRaceMasterTalked( int meindex , int talkerindex , char *szMes , int color ); +void NPC_PetRaceMasterWindowTalked(int meindex, int talkerindex, int seqno, int select, char *data); + +#endif + diff --git a/gmsv/include/npc_petracepet.h b/gmsv/include/npc_petracepet.h new file mode 100644 index 0000000..f421126 --- /dev/null +++ b/gmsv/include/npc_petracepet.h @@ -0,0 +1,9 @@ +#ifndef NPC_PetRace_Pet_ +#define NPC_PetRace_Pet_ + +BOOL NPC_PetRacePetInit( int meindex ); +void NPC_PetRacePetLoop( int meindex ); +void NPC_PetRacePetTalked( int meindex , int talkerindex , char *szMes , int color ); + +#endif + diff --git a/gmsv/include/npc_petshop.h b/gmsv/include/npc_petshop.h new file mode 100644 index 0000000..7b985ca --- /dev/null +++ b/gmsv/include/npc_petshop.h @@ -0,0 +1,12 @@ +#ifndef __NPC_PETSHOP_H__ +#define __NPC_PETSHOP_H__ + +void NPC_PetShopTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_PetShopInit( int meindex ); +void NPC_PetShopWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_PetShopLooked( int meindex , int lookedindex); + + +#endif +/*__NPC_PETSHOP_H__*/ diff --git a/gmsv/include/npc_petskillshop.h b/gmsv/include/npc_petskillshop.h new file mode 100644 index 0000000..ca603bb --- /dev/null +++ b/gmsv/include/npc_petskillshop.h @@ -0,0 +1,13 @@ +#ifndef __NPC_PETSKILLSHOP_H__ +#define __NPC_PETSKILLSHOP_H__ + +void NPC_PetSkillShopTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_PetSkillShopInit( int meindex ); +void NPC_PetSkillShopWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_PetSkillShopLooked( int meindex , int lookedindex); + +void NPC_PetSkillMakeStr(int meindex,int toindex,int select); + +#endif + /*__NPC_WINDOWPETSKILLSHOP_H__*/ diff --git a/gmsv/include/npc_pettransman.h b/gmsv/include/npc_pettransman.h new file mode 100644 index 0000000..c840706 --- /dev/null +++ b/gmsv/include/npc_pettransman.h @@ -0,0 +1,11 @@ +#ifndef __NPC_PETTRANSMAN_H__ +#define __NPC_PETTRANSMAN_H__ + +BOOL NPC_PetTransManInit(int meindex); +void NPC_PetTransMan_selectWindow(int meindex,int toindex,int num,int select); +void NPC_PetTransManWindowTalked(int meindex,int talkerindex,int seqno,int select,char *data); +void NPC_PetTransManTalked(int meindex,int talkerindex,char *szMes,int color); +int NPC_PetTransManCheck( int meindex, int toindex, int select); +BOOL NPC_PetTransManStatus( int meindex, int toindex, int petNo); +#endif + /*__NPC_PETTRANSMAN_H__*/ diff --git a/gmsv/include/npc_pkpetshop.h b/gmsv/include/npc_pkpetshop.h new file mode 100644 index 0000000..f4d785c --- /dev/null +++ b/gmsv/include/npc_pkpetshop.h @@ -0,0 +1,16 @@ +//krynn 2001/12/6 +//PKPetShop + +#ifndef __NPC_PKPetShop_H__ +#define __NPC_PKPetShop_H__ + +void NPC_PKPetShopTalked( int meindex , int talkerindex , char *msg , int color ); +BOOL NPC_PKPetShopInit( int meindex ); +void NPC_PKPetShopWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_PKPetShopLooked( int meindex , int lookedindex); + +#endif + + +//krynn end + diff --git a/gmsv/include/npc_poolitemshop.h b/gmsv/include/npc_poolitemshop.h new file mode 100644 index 0000000..11d7e43 --- /dev/null +++ b/gmsv/include/npc_poolitemshop.h @@ -0,0 +1,14 @@ +#ifndef __NPC_POOLITEMSHOP_H__ +#define __NPC_POOLITEMSHOP_H__ + + +void NPC_PoolItemShopLoop( int meindex); +BOOL NPC_PoolItemShopInit( int meindex); +void NPC_PoolItemShopTalked( int meindex , int talkerindex , + char *szMes ,int color ); +void NPC_PoolItemShopWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data); + + +#endif + /*__NPC_POOLITEMSHOP_H__*/ diff --git a/gmsv/include/npc_quiz.h b/gmsv/include/npc_quiz.h new file mode 100644 index 0000000..31290c1 --- /dev/null +++ b/gmsv/include/npc_quiz.h @@ -0,0 +1,29 @@ +#ifndef __NPC_QUIZ_H__ +#define __NPC_QUIZ_H__ + +typedef struct NPC_Quiz{ + + int no; // 锁及 寞 + int type; // 锁及正奶皿 必□丞 }旦禾□汁) + int level; // 锁及伊矛伙 + int answertype; //蚕尹及蓟太井凶(ㄡ }ㄢ }签贿穴永民 + int answerNo; // 锁及蚕尹 + char question[512]; // 锁 + char select1[128]; //蓟 靼1 + char select2[128]; //蓟 靼2 + char select3[128]; //蓟 靼3 + +}NPC_QUIZ; + + +void NPC_QuizTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_QuizInit( int meindex ); +void NPC_QuizWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +BOOL QUIZ_initQuiz( char *filename); + + +#endif + +/*__NPC_QUIZ_H__*/ diff --git a/gmsv/include/npc_raceman.h b/gmsv/include/npc_raceman.h new file mode 100644 index 0000000..4ae29e8 --- /dev/null +++ b/gmsv/include/npc_raceman.h @@ -0,0 +1,45 @@ +#ifndef __NPC_RACEMAN_H__ +#define __NPC_RACEMAN_H__ + +#define DEFMAXRANK 100 + +struct RANKTABLE +{ + char id[20]; + char name[256]; + int catchcnt; + char kindcnt[10000]; + int rank; +}*LPRANKTABLE; + +struct ASKTABLE +{ + int no; + char petname[32]; + int bbi; + int lowlv; + int highlv; +}; + +extern struct RANKTABLE ranktable1[DEFMAXRANK]; +extern struct RANKTABLE ranktable2[DEFMAXRANK]; +extern struct RANKTABLE ranktable3[DEFMAXRANK]; +extern struct RANKTABLE ranktable4[DEFMAXRANK]; +extern struct RANKTABLE ranktable5[DEFMAXRANK]; + +extern struct RANKTABLE history1[DEFMAXRANK]; +extern struct RANKTABLE history2[DEFMAXRANK]; +extern struct RANKTABLE history3[DEFMAXRANK]; +extern struct RANKTABLE history4[DEFMAXRANK]; +extern struct RANKTABLE history5[DEFMAXRANK]; + +extern struct ASKTABLE asktable[400]; + +BOOL NPC_RacemanInit( int meindex); +void NPC_RacemanTalked( int meindex , int talkerindex , char *szMes ,int color ); +void NPC_RacemanWindowTalked( int meindex , int talkerindex , int seqno, int select, char *data); +int Raceman_getokask( int talker , int random ); +//void Raceman_awardprize( int meindex , int talker ); + + +#endif diff --git a/gmsv/include/npc_riderman.h b/gmsv/include/npc_riderman.h new file mode 100644 index 0000000..bfaa48f --- /dev/null +++ b/gmsv/include/npc_riderman.h @@ -0,0 +1,12 @@ +#ifndef __NPC_RIDERMAN_H__ +#define __NPC_RIDERMAN_H__ + +void NPC_RidermanTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_RidermanInit( int meindex ); +void NPC_RidermanLooked( int meindex, int lookedindex ); +void NPC_RidermanWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +#endif + /*__NPC_RIDERMAN_H__*/ diff --git a/gmsv/include/npc_roomadminnew.h b/gmsv/include/npc_roomadminnew.h new file mode 100644 index 0000000..2cee346 --- /dev/null +++ b/gmsv/include/npc_roomadminnew.h @@ -0,0 +1,48 @@ +#ifndef __NPC_ROOMADMINNEW_H__ +#define __NPC_ROOMADMINNEW_H__ + + +void NPC_RoomAdminNewTalked( int meindex , int talkerindex , char *msg , int color ); +void NPC_RoomAdminNewLoop( int meindex ); +BOOL NPC_RoomAdminNewInit( int meindex ); + +BOOL NPC_RankingInit( int meindex ); +void NPC_RankingTalked( int meindex , int talkerindex , char *msg ,int color ); + +BOOL NPC_PrintpassmanInit( int meindex ); +void NPC_PrintpassmanTalked( int meindex , int talkerindex , char *msg ,int color ); + +#if 0 +typedef struct roomadmin_tag +{ + int index; /* 盒及index */ + + char doorname[256]; /* 公及 盒及玉失及 蟆 */ + char explanation[256]; /* */ + char passwd[256]; /* 由旦伐□玉 */ + int expire_time_mod; /* 匏锹 */ + time_t expire_time; /* 渝蜃濠木及凛棉 */ + int least_cost; /* 斓嗯喊 */ + +}NPC_ROOMINFO; +#endif + +typedef struct npc_roomadminnew_tag { + int expire; + char cdkey[CDKEYLEN]; + char charaname[32]; + char passwd[9]; +}NPC_ROOMINFO; + +typedef struct npc_roomadminnew_ranking_tag { + int gold; /* 诳嗯喊 */ + int biddate; /* 诳凛棉 */ + char cdkey[CDKEYLEN]; /* 午仄凶谛及 平□ */ + char charaname[32]; /* 午仄凶谛及 蟆 */ + char owntitle[32]; /* 惫寞*/ + +}NPC_RANKING_INFO; + +#endif /*__NPC_ROOMADMINNEW_H__*/ + +BOOL NPC_RoomAdminNew_ReadFile( char *roomname, NPC_ROOMINFO *data); diff --git a/gmsv/include/npc_sample.h b/gmsv/include/npc_sample.h new file mode 100644 index 0000000..b648598 --- /dev/null +++ b/gmsv/include/npc_sample.h @@ -0,0 +1,8 @@ +#ifndef __NPC_SAMPLE_H__ +#define __NPC_SAMPLE_H__ + +void NPC_SampleLoop( int index ); + +#endif + + /*__NPC_SAMPLE_H__*/ diff --git a/gmsv/include/npc_savepoint.h b/gmsv/include/npc_savepoint.h new file mode 100644 index 0000000..80edab6 --- /dev/null +++ b/gmsv/include/npc_savepoint.h @@ -0,0 +1,14 @@ +#ifndef __NPC_SAVEPOINT_H__ +#define __NPC_SAVEPOINT_H__ + + +void NPC_SavePointTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_SavePointInit( int meindex ); +void NPC_SavePointWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + + +#endif + +/*__NPC_SAVEPOINT_H__*/ diff --git a/gmsv/include/npc_scheduleman.h b/gmsv/include/npc_scheduleman.h new file mode 100644 index 0000000..fd23c3a --- /dev/null +++ b/gmsv/include/npc_scheduleman.h @@ -0,0 +1,82 @@ +#ifndef __NPC_SCHEDULEMAN_H__ +#define __NPC_SCHEDULEMAN_H__ + +#define CHARNAME_MAX 32 + +// 最大 scheduleman 数量 +#ifdef _FAMILY_MANORNUM_CHANGE +#define MAX_SCHEDULEMAN 20 +#else +#define MAX_SCHEDULEMAN 12 +#endif + +// 每一个 scheduleman 控管的 schedule 数量 +#define MAX_SCHEDULE 24 + +// schedule 列表的一页所能列出的最大数量 +#define MAXSCHEDULEINONEWINDOW 10 + +// family 列表的一页所能列出的最大数量 +#define MAXFAMILYINONEWINDOW 10 + +// 每一个 scheduleman 所使用的 schedule 储存位置 +// 对应在 fmpks 的 ID*MAX_SCHEDULE 上 (ID=0~MAX_SCHEDULEMAN-1) +// ID 是写在 data/npc 中指定给 "id:" 的值 + +// dueltime = (隔天?10000:0) + (小时*100) + +typedef struct tagFamilyPKSchedule { + int dueltime; // 比赛时刻 + int host_index; // 主队家族 + char host_name[CHARNAME_MAX]; // 主队家族名称 + int guest_index; // 客队家族 + char guest_name[CHARNAME_MAX]; // 客队家族名称 + int prepare_time; // 准备时间 (1~40 分钟) + int max_player; // 最大出场人数 (1~家族人数上限) + int flag; // 状态 + int win; // 胜利条件设定 + int challenge_timeout; // 挑战时限 + int setting_timeout; // 设定状态的 timeout + char gmsv_name[256]; +} FamilyPKSchedule; + +// 纪录在 FamilyPKSchedule (fmpks) 的 flag 值 +#define FMPKS_FLAG_NONE -1 // 没有任何排程 +#define FMPKS_FLAG_CHALLENGE 0 // 等待客队同意中 +#define FMPKS_FLAG_SETTING 1 // 主队正在设定排程 (取消时变成 NONE) +#define FMPKS_FLAG_CONFIRMING 2 // 客队正在同意中 +#define FMPKS_FLAG_SCHEDULED 3 // 已经排好排程,尚未开打 +#define FMPKS_FLAG_DUEL 4 // 开打中 +#define FMPKS_FLAG_HOSTWIN 5 // 主队胜 +#define FMPKS_FLAG_GUESTWIN 6 // 客队胜 +#define FMPKS_FLAG_MANOR_BATTLEBEGIN 7 // 庄园挑战 战斗中 +#define FMPKS_FLAG_MANOR_PREPARE 8 // 庄园挑战 准备中 +#define FMPKS_FLAG_MANOR_PEACE 9 // 庄园挑战 休战中 +#define FMPKS_FLAG_MANOR_OTHERPLANET 10 // 庄园挑战 在别的星球决战 +#define FMPKS_FLAG_MANOR_BATTLEEND 11 // 庄园挑战 战斗结束 +#define FMPKS_FLAG_MANOR_PEACE_SAVE 12 // 将庄园挑战存档 +#define FMPKS_FLAG_MANOR_READYTOFIGHT 13 // (GM: manorpk) 全星系变成可约战状态 +#define FMPKS_FLAG_MANOR_CLEANFLAG 14 // (GM: manorpk) 本星球清除状态 +#ifdef _NEW_MANOR_LAW +#define FMPKS_FLAG_WAIT 15 // 进入挑战期,已记录家族气势,等待挑战排程 +#endif + +// 传给 client 的 flag +#define FLAG_NONE -1 +#define FLAG_MODIFY 0 +#define FLAG_ACCEPT 1 +#define FLAG_SETTING 2 +#define FLAG_CONFIRM 3 +#define FLAG_SCHEDULED 4 + +extern FamilyPKSchedule fmpks[MAX_SCHEDULE*MAX_SCHEDULEMAN]; + +BOOL NPC_SchedulemanInit(int meindex); +void NPC_SchedulemanTalked(int meindex, int talkerindex, char *msg, int color); +void NPC_SchedulemanWindowTalked(int meindex, int talkerindex, + int seqno, int select, char *data); +void NPC_SchedulemanLoop(int meindex); + +#endif + +/*__NPC_SCHEDULEMAN_H__*/ diff --git a/gmsv/include/npc_scheduleman.h.bak b/gmsv/include/npc_scheduleman.h.bak new file mode 100644 index 0000000..da9637b --- /dev/null +++ b/gmsv/include/npc_scheduleman.h.bak @@ -0,0 +1,82 @@ +#ifndef __NPC_SCHEDULEMAN_H__ +#define __NPC_SCHEDULEMAN_H__ + +#define CHARNAME_MAX 32 + +// 最大 scheduleman 数量 +#ifdef _FAMILY_MANORNUM_CHANGE +#define MAX_SCHEDULEMAN 20 +#else +#define MAX_SCHEDULEMAN 12 +#endif + +// 每一个 scheduleman 控管的 schedule 数量 +#define MAX_SCHEDULE 24 + +// schedule 列表的一页所能列出的最大数量 +#define MAXSCHEDULEINONEWINDOW 4 + +// family 列表的一页所能列出的最大数量 +#define MAXFAMILYINONEWINDOW 8 + +// 每一个 scheduleman 所使用的 schedule 储存位置 +// 对应在 fmpks 的 ID*MAX_SCHEDULE 上 (ID=0~MAX_SCHEDULEMAN-1) +// ID 是写在 data/npc 中指定给 "id:" 的值 + +// dueltime = (隔天?10000:0) + (小时*100) + +typedef struct tagFamilyPKSchedule { + int dueltime; // 比赛时刻 + int host_index; // 主队家族 + char host_name[CHARNAME_MAX]; // 主队家族名称 + int guest_index; // 客队家族 + char guest_name[CHARNAME_MAX]; // 客队家族名称 + int prepare_time; // 准备时间 (1~40 分钟) + int max_player; // 最大出场人数 (1~家族人数上限) + int flag; // 状态 + int win; // 胜利条件设定 + int challenge_timeout; // 挑战时限 + int setting_timeout; // 设定状态的 timeout + char gmsv_name[256]; +} FamilyPKSchedule; + +// 纪录在 FamilyPKSchedule (fmpks) 的 flag 值 +#define FMPKS_FLAG_NONE -1 // 没有任何排程 +#define FMPKS_FLAG_CHALLENGE 0 // 等待客队同意中 +#define FMPKS_FLAG_SETTING 1 // 主队正在设定排程 (取消时变成 NONE) +#define FMPKS_FLAG_CONFIRMING 2 // 客队正在同意中 +#define FMPKS_FLAG_SCHEDULED 3 // 已经排好排程,尚未开打 +#define FMPKS_FLAG_DUEL 4 // 开打中 +#define FMPKS_FLAG_HOSTWIN 5 // 主队胜 +#define FMPKS_FLAG_GUESTWIN 6 // 客队胜 +#define FMPKS_FLAG_MANOR_BATTLEBEGIN 7 // 庄园挑战 战斗中 +#define FMPKS_FLAG_MANOR_PREPARE 8 // 庄园挑战 准备中 +#define FMPKS_FLAG_MANOR_PEACE 9 // 庄园挑战 休战中 +#define FMPKS_FLAG_MANOR_OTHERPLANET 10 // 庄园挑战 在别的星球决战 +#define FMPKS_FLAG_MANOR_BATTLEEND 11 // 庄园挑战 战斗结束 +#define FMPKS_FLAG_MANOR_PEACE_SAVE 12 // 将庄园挑战存档 +#define FMPKS_FLAG_MANOR_READYTOFIGHT 13 // (GM: manorpk) 全星系变成可约战状态 +#define FMPKS_FLAG_MANOR_CLEANFLAG 14 // (GM: manorpk) 本星球清除状态 +#ifdef _NEW_MANOR_LAW +#define FMPKS_FLAG_WAIT 15 // 进入挑战期,已记录家族气势,等待挑战排程 +#endif + +// 传给 client 的 flag +#define FLAG_NONE -1 +#define FLAG_MODIFY 0 +#define FLAG_ACCEPT 1 +#define FLAG_SETTING 2 +#define FLAG_CONFIRM 3 +#define FLAG_SCHEDULED 4 + +extern FamilyPKSchedule fmpks[MAX_SCHEDULE*MAX_SCHEDULEMAN]; + +BOOL NPC_SchedulemanInit(int meindex); +void NPC_SchedulemanTalked(int meindex, int talkerindex, char *msg, int color); +void NPC_SchedulemanWindowTalked(int meindex, int talkerindex, + int seqno, int select, char *data); +void NPC_SchedulemanLoop(int meindex); + +#endif + +/*__NPC_SCHEDULEMAN_H__*/ diff --git a/gmsv/include/npc_sellsthman.h b/gmsv/include/npc_sellsthman.h new file mode 100644 index 0000000..6ce6165 --- /dev/null +++ b/gmsv/include/npc_sellsthman.h @@ -0,0 +1,9 @@ +#ifndef _SELLSTH_MAN_H +#define _SELLSTH_MAN_H + +void NPC_SellsthManTalked( int meindex, int talkerindex, char *msg, int color ); +BOOL NPC_SellsthManInit( int meindex ); +void NPC_SellsthManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_SellsthManLoop( int meindex); + +#endif diff --git a/gmsv/include/npc_signboard.h b/gmsv/include/npc_signboard.h new file mode 100644 index 0000000..ed96680 --- /dev/null +++ b/gmsv/include/npc_signboard.h @@ -0,0 +1,11 @@ +#ifndef __NPC_SIGNBOARD_H__ +#define __NPC_SIGNBOARD_H__ + + +BOOL NPC_SignBoardInit( int meindex ); +void NPC_SignBoardWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_SignBoardLooked( int meindex , int lookedindex); + + +#endif + /*__NPC_WINDOWSIGNBOAD_H__*/ diff --git a/gmsv/include/npc_simpleshop.h b/gmsv/include/npc_simpleshop.h new file mode 100644 index 0000000..3b0da80 --- /dev/null +++ b/gmsv/include/npc_simpleshop.h @@ -0,0 +1,10 @@ +#ifndef __NPC_SIMPLESHOP_H__ +#define __NPC_SIMPLESHOP_H__ + +void NPC_SimpleShopTalked( int index, int talker, char *msg, int color ); +void NPC_SimpleShopSpecialTalked( int index, int talker, char *msg, int color ); +void NPC_LimitBuyInShopSpecialTalked( int index, int talker, char *msg, int color ); +void NPC_SimpleShopInit( int meindex ); + +#endif + /*__NPC_SIMPLESHOP_H__*/ diff --git a/gmsv/include/npc_stoneserviceman.h b/gmsv/include/npc_stoneserviceman.h new file mode 100644 index 0000000..9d9feb1 --- /dev/null +++ b/gmsv/include/npc_stoneserviceman.h @@ -0,0 +1,20 @@ +#ifndef __NPC_STONESERVICEMAN_H__ +#define __NPC_STONESERVICEMAN_H__ + +// 资料串列 +typedef struct _List +{ + char Data[32]; // 资料 + struct _List *Next; // 指向下一个List +}List,*LPList; + +BOOL NPC_StoneServiceManInit(int meindex); +void NPC_StoneServiceManLoop(int meindex); +void NPC_StoneServiceManTalked(int meindex,int talkerindex,char *msg,int color); +void NPC_StoneServiceManWindowTalked(int meindex,int talkerindex,int seqno, + int select,char *data); +int SendToAP(int nAid,int nIndex,int nLen,void *Data1,void *Data2); +int RecvFromAP(int *nAid,int nIndex,int *nLen,LPList *Data); +int GetMsg(int meindex); +int ConnectToAP(void); +#endif diff --git a/gmsv/include/npc_storyteller.h b/gmsv/include/npc_storyteller.h new file mode 100644 index 0000000..a8a17cf --- /dev/null +++ b/gmsv/include/npc_storyteller.h @@ -0,0 +1,8 @@ +#ifndef _NPC_STORYTELLER_H_ +#define _NPC_STORYTELLER_H_ + +BOOL NPC_StoryTellerInit( int meindex ); +void NPC_StoryTellerTalked( int meindex , int talker , char *msg , int col ); + +#endif + diff --git a/gmsv/include/npc_sysinfo.h b/gmsv/include/npc_sysinfo.h new file mode 100644 index 0000000..37b6b4b --- /dev/null +++ b/gmsv/include/npc_sysinfo.h @@ -0,0 +1,7 @@ +#ifndef __NPC_SYSINFO_H__ +#define __NPC_SYSINFO_H__ + +BOOL NPC_SysinfoInit( int meindex ); +void NPC_SysinfoLoop( int meindex ); +void NPC_SysinfoTalked( int meindex, int tindex, char *msg, int color); +#endif /*__NPC_SYSINFO_H__*/ diff --git a/gmsv/include/npc_timeman.h b/gmsv/include/npc_timeman.h new file mode 100644 index 0000000..0611141 --- /dev/null +++ b/gmsv/include/npc_timeman.h @@ -0,0 +1,13 @@ +#ifndef __NPC_TIMEMAN_H__ +#define __NPC_TIMEMAN_H__ + + +void NPC_TimeManTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_TimeManInit( int meindex ); + +void NPC_TimeManWatch( int meobjindex, int objindex, CHAR_ACTION act, + int x,int y,int dir, int* opt,int optlen ); + +#endif /*__NPC_TIMEMAN_H__*/ diff --git a/gmsv/include/npc_townpeople.h b/gmsv/include/npc_townpeople.h new file mode 100644 index 0000000..745317b --- /dev/null +++ b/gmsv/include/npc_townpeople.h @@ -0,0 +1,7 @@ +#ifndef __NPC_TOWNPEOPLE_H__ +#define __NPC_TOWNPEOPLE_H__ + +void NPC_TownPeopleTalked( int index, int talker, char *msg, int color ); +void NPC_TownPeopleInit( int meindex ); + +#endif /* __NPC_TOWNPEOPLE_H__ */ diff --git a/gmsv/include/npc_transerman.h b/gmsv/include/npc_transerman.h new file mode 100644 index 0000000..2acca4e --- /dev/null +++ b/gmsv/include/npc_transerman.h @@ -0,0 +1,9 @@ +#ifndef _TRANSER_MAN_H +#define _TRANSER_MAN_H + +void NPC_TranserManTalked( int meindex, int talkerindex, char *msg, int color ); +BOOL NPC_TranserManInit( int meindex ); +void NPC_TranserManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_TranserManLoop( int meindex); + +#endif diff --git a/gmsv/include/npc_transmigration.h b/gmsv/include/npc_transmigration.h new file mode 100644 index 0000000..b5040fe --- /dev/null +++ b/gmsv/include/npc_transmigration.h @@ -0,0 +1,11 @@ +#ifndef __NPC_TRANSMIGRATION_H__ +#define __NPC_TRANSMIGRATION_H__ + +void NPC_TransmigrationTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_TransmigrationInit( int meindex ); +void NPC_TransmigrationWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +#endif + +/*__NPC_TRANSMIGRATION_H__*/ diff --git a/gmsv/include/npc_verywelfare.h b/gmsv/include/npc_verywelfare.h new file mode 100644 index 0000000..7b98446 --- /dev/null +++ b/gmsv/include/npc_verywelfare.h @@ -0,0 +1,8 @@ +#ifndef __NPC_VERYWELFARE_H__ +#define __NPC_VERYWELFARE_H__ + +BOOL NPC_VeryWelfareInit( int meindex ); +void NPC_VeryWelfareTalked( int meindex , int talker , char *msg ,int color ); +void NPC_VeryWelfareWindowTalked(int meindex, int talkerindex, int seqno, int select,char *data); + +#endif diff --git a/gmsv/include/npc_warp.h b/gmsv/include/npc_warp.h new file mode 100644 index 0000000..4caafbc --- /dev/null +++ b/gmsv/include/npc_warp.h @@ -0,0 +1,10 @@ +#ifndef __NPC_WARP_H__ +#define __NPC_WARP_H__ +BOOL NPC_WarpInit( int charaindex ); +void NPC_WarpPostOver( int meindex,int charaindex ); +void NPC_WarpWatch( int meobjindex, int objindex, CHAR_ACTION act, + int x,int y,int dir, int* opt,int optlen ); +int NPC_WarpSearchByPosition( int fl , int x, int y); +void NPC_WarpWarpCharacter( int warpnpcindex, int charaindex ); +#endif + /*__NPC_WARP_H__*/ diff --git a/gmsv/include/npc_warpman.h b/gmsv/include/npc_warpman.h new file mode 100644 index 0000000..ee48e0a --- /dev/null +++ b/gmsv/include/npc_warpman.h @@ -0,0 +1,13 @@ +#ifndef __NPC_WARPMAN_H__ +#define __NPC_WARPMAN_H__ + +void NPC_WarpManTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_WarpManInit( int meindex ); +void NPC_WarpManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_GetDuelRank(int rank,int msgid,int msgid2); +void NPC_WarpManLoop( int meindex); +void NPC_WarpManWatch( int meobjindex, int objindex, CHAR_ACTION act, + int x,int y,int dir, int* opt,int optlen ); +#endif +/*__NPC_WARPMAN_H__*/ diff --git a/gmsv/include/npc_welfare.h b/gmsv/include/npc_welfare.h new file mode 100644 index 0000000..4aa9037 --- /dev/null +++ b/gmsv/include/npc_welfare.h @@ -0,0 +1,10 @@ +#ifndef __NPC_WELFARE_H__ +#define __NPC_WELFARE_H__ + +BOOL NPC_WelfareInit( int meindex ); +void NPC_WelfareTalked( int meindex , int talker , char *msg ,int color ); +void NPC_WelfareWindowTalked(int meindex, int talkerindex, int seqno, int select,char *data); +void NPC_WelfareMakeStr(int meindex,int toindex,int select); + + +#endif diff --git a/gmsv/include/npc_welfare2.h b/gmsv/include/npc_welfare2.h new file mode 100644 index 0000000..0bbb309 --- /dev/null +++ b/gmsv/include/npc_welfare2.h @@ -0,0 +1,9 @@ +#ifndef __NPC_WELFARE2_H__ +#define __NPC_WELFARE2_H__ + +BOOL NPC_WelfareInit2( int meindex ); +void NPC_WelfareTalked2( int meindex , int talker , char *msg ,int color ); +void NPC_WelfareWindowTalked2(int meindex, int talkerindex, int seqno, int select,char *data); +void NPC_WelfareMakeStr2(int meindex,int toindex,int select); + +#endif diff --git a/gmsv/include/npc_windowhealer.h b/gmsv/include/npc_windowhealer.h new file mode 100644 index 0000000..2c8f62a --- /dev/null +++ b/gmsv/include/npc_windowhealer.h @@ -0,0 +1,11 @@ +#ifndef __NPC_WINDOWHEALER_H__ +#define __NPC_WINDOWHEALER_H__ + +void NPC_WindowHealerTalked( int meindex , int talkerindex , char *msg , + int color ); +BOOL NPC_WindowHealerInit( int meindex ); +void NPC_WindowHealerWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); +void NPC_WindowHealerLooked( int meindex , int lookedindex); + +#endif + /*__NPC_WINDOWHEALER_H__*/ diff --git a/gmsv/include/npc_windowman.h b/gmsv/include/npc_windowman.h new file mode 100644 index 0000000..3cf1dde --- /dev/null +++ b/gmsv/include/npc_windowman.h @@ -0,0 +1,16 @@ +#ifndef __NPC_WINDOWMAN_H__ +#define __NPC_WINDOWMAN_H__ + +void NPC_WindowmanTalked( int meindex , int talkerindex , char *msg , + int color ); + +BOOL NPC_WindowmanInit( int meindex ); +void NPC_WindowmanLooked( int meindex, int lookedindex ); +void NPC_WindowmanWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data); + +void NPC_Windowman_selectWindow( int meindex, int toindex, int num); +BOOL NPC_Windowman_readData( int meindex, int windowno, BOOL chkflg); +int NPC_Windowman_restoreButtontype( char *data ); + +#endif +/*__NPC_WINDOWMAN_H__*/ diff --git a/gmsv/include/npccreate.h b/gmsv/include/npccreate.h new file mode 100644 index 0000000..7109410 --- /dev/null +++ b/gmsv/include/npccreate.h @@ -0,0 +1,93 @@ +#ifndef __READNPCCREATE_H__ +#define __READNPCCREATE_H__ + +#include "util.h" + +#define NPC_CREATEFILEMAGIC "NPCCREATE\n" + + +#undef EXTERN +#ifdef __NPCCREATE__ +#define EXTERN +#else +#define EXTERN extern +#endif /*__NPCCREATE__*/ + + +typedef enum +{ + NPC_CREATEFLOORID, /* 白夫失ID */ + NPC_CREATEBORNLEFTUPX, /* 尔晓及X甄 */ + NPC_CREATEBORNLEFTUPY, /* 尔晓及Y甄 */ + NPC_CREATEBORNRIGHTDOWNX, /* 惘票及X甄 */ + NPC_CREATEBORNRIGHTDOWNY, /* 惘票及Y甄 */ + + NPC_CREATEMOVELEFTUPX, /* 尔晓及X甄 */ + NPC_CREATEMOVELEFTUPY, /* 尔晓及Y甄 */ + NPC_CREATEMOVERIGHTDOWNX, /* 惘票及X甄 */ + NPC_CREATEMOVERIGHTDOWNY, /* 惘票及Y甄 */ + + NPC_CREATEDIR, /* 综月凛及 轾 */ + NPC_CREATEBASEIMAGENUMBER, /* template 及涩烂毛晓踏五允月 + 飓 寞 */ + NPC_CREATETIME, /* 凛棉 */ + NPC_CREATEBORNNUM, /* 公及哗 卞请蜇今六月醒 */ + + NPC_CREATEENEMYNUM, /* 衬及潘 醒 */ + NPC_CREATEBOUNDARY, + NPC_CREATEDATE, + NPC_CREATEIGNOREINVINCIBLE, + NPC_CREATEFAMILY, // Robin 0731 Family +#ifdef _ADD_ACTION //jeffrey 1231 npcaction + NPC_CREATEACTION, +#endif + NPC_CREATEINTNUM, + +}NPC_CREATEINT; + +typedef enum +{ + NPC_CREATENAME, /* template毛晓踏五允月井手仄木卅中 蟆*/ + NPC_CREATECHARNUM, +}NPC_CREATECHAR; + + +typedef enum +{ + NPC_CREATEWORKENEMYNUM, + NPC_CREATEWORKMAKESTARTSEC, + NPC_CREATEWORKMAKESTARTUSEC, + NPC_CREATEWORKNEVERMAKE, + NPC_CREATEWORKNUM, + +}NPC_CREATEWORK; + +typedef struct tagNPC_Create +{ + int intdata[NPC_CREATEINTNUM]; + STRING64 chardata[NPC_CREATECHARNUM]; + int workdata[NPC_CREATEWORKNUM]; + int templateindex[8]; + STRING64 arg[8]; +}NPC_Create; + + +EXTERN NPC_Create* NPC_create; +EXTERN int NPC_createnum; +EXTERN int NPC_create_readindex; + +INLINE int NPC_CHECKCREATEINDEX(int index); + +BOOL NPC_isBoundarySet( int createindex ); +BOOL NPC_createGetRECT( int createindex,RECT* r ); +BOOL NPC_readNPCCreateFiles( char* topdirectory ,int createsize); +int NPC_getCreateInt( int index , NPC_CREATEINT element ); + +BOOL NPC_createCheckGenerateFromTime( int tindex ); +void NPC_createInitTime( int index ); +void NPC_createIncreaseEnemynum( int index ); +void NPC_createDecreaseEnemynum( int index ); +BOOL NPC_createCheckMaxEnemynum( int index ); + +#endif +/*__READNPCCREATE_H__*/ diff --git a/gmsv/include/npcgen.h b/gmsv/include/npcgen.h new file mode 100644 index 0000000..f7ab71a --- /dev/null +++ b/gmsv/include/npcgen.h @@ -0,0 +1,13 @@ +#ifndef __NPCGEN_H__ +#define __NPCGEN_H__ + + +void NPC_generateLoop( BOOL FlgInit ); + +EXTERN int all_nosee; /* ㄠ及凛{蝈化及衬毛 no_see 卞 */ +EXTERN int all_nobody; /* ㄠ及凛{蝈化及衬毛 no_body 卞 */ +EXTERN int one_loop_born; /* ㄠ伙□皿匹 嫖戏心请允醒 oneloop_born */ + + +#endif +/*__NPCGEN_H__*/ diff --git a/gmsv/include/npcserver.h b/gmsv/include/npcserver.h new file mode 100644 index 0000000..2798a55 --- /dev/null +++ b/gmsv/include/npcserver.h @@ -0,0 +1,38 @@ +#ifndef _NPCSERVER_H +#define _NPCSERVER_H + + +int NSproto_DispatchMessage(int fd,char* encoded); +int connectNpcServer(char* hostname,unsigned short port); +void NPCS_SendProbe( int fd); + +typedef struct _NPCMessCommand +{ + char buf[4096]; + int len; + struct _NPCMessCommand *next; +}NPCMessC; + +BOOL NPCMESS_setChar( char *buf); +BOOL NPCMESS_getChar( char *buf, int len); +NPCMessC *MESS_getNew(); + + +void NPCS_AskNpcList_recv( int fd, char *Nlist); +void NPCS_AskNpcList_send( int fd); + +void NPCS_NpcSLogin_recv( int fd, char *Mess); +void NPCS_NpcSLogin_send( int fd); + +void NPCS_AskNpcTalk_send( int objindex, int npcsindex, int charaindex, char *Nlist); + +void NPCS_NpcTalkMess_recv( int npcobjindex, int charaindex, int charobjindex, char *TalkMess, int Color); +void NPCS_NpcWinMess_recv( int npcobjindex, int charaindex, int charobjindex, char *WinMess, + int seqno, int windowtype, int buttontype, int page); +void NPCS_NpcWinMess_send( int npcobjindex, int npcindex, int charaindex, char *WinMess, + int seqno, int select); +void NPCS_NpcCheckFreeMess_recv( int npcobjindex, int charaindex, int charobjindex, + char *CheckfreeMess); + +#endif + diff --git a/gmsv/include/npcshandle.h b/gmsv/include/npcshandle.h new file mode 100644 index 0000000..87918c7 --- /dev/null +++ b/gmsv/include/npcshandle.h @@ -0,0 +1,29 @@ +#ifndef _NPCS_HANDLE_H +#define _NPCS_HANDLE_H +#include "version.h" +#include "util.h" + +#ifdef _NPCSERVER_NEW +//条件判断 +BOOL NPCS_HandleCheckFreeMess( int npcobjindex, int charaindex, int charobjindex, + char *CheckfreeMess); + +BOOL NPCS_FreePassCheck( int charaindex, char *buf); + +//比较判断 +BOOL NPCS_FreeBigSmallCheck( int charaindex,char* buf); +//参数判断 +BOOL NPCS_ArgumentFreeCheck( int charaindex, char* Argument, int amount, int temp, int probjID); +//参数大小判断 +BOOL NPCS_ArgumentBigSmallCheck( int point, int mypoint, int flg); +//取得指定ID宠物数 *reAmount 剩馀栏位 +int NPCS_getUserPetAmount( int charaindex, int objID, int flg); +//取得指定ID道具数 *reAmount 剩馀栏位 +int NPCS_getUserItemAmount( int charaindex, int objID, int flg); +//取得团队人数 +int NPCS_getUserPartyAmount( int charaindex ); +BOOL NPCS_NpcstalkToCli( int charaindex,int npcobjindex, char* message, CHAR_COLOR color ); +//事件处理 +BOOL NPCS_RunDoEventAction( int charaindex, char *buf1); +#endif +#endif diff --git a/gmsv/include/npctemplate.h b/gmsv/include/npctemplate.h new file mode 100644 index 0000000..48aa0f8 --- /dev/null +++ b/gmsv/include/npctemplate.h @@ -0,0 +1,111 @@ +#ifndef __READNPCTEMPLATE_H__ +#define __READNPCTEMPLATE_H__ + +#include "util.h" +#include "char_base.h" + +#define NPC_TEMPLATEFILEMAGIC "NPCTEMPLATE\n" + +#undef EXTERN +#ifdef __NPCTEMPLATE__ +#define EXTERN +#else +#define EXTERN extern +#endif /*__NPCTEMPLATE__*/ + + + +typedef struct tagNPC_haveItem +{ + int itemnumber; + int haverate; + int havenum; +}NPC_haveItem; + +typedef enum +{ + NPC_TEMPLATENAME, /* 件皿伊□玄及 蟆 */ + NPC_TEMPLATECHARNAME, /* 蟆 */ + + NPC_TEMPLATEINITFUNC, /* CHAR_INITFUNC卞垫仁 */ + NPC_TEMPLATEWALKPREFUNC, /* CHAR_WALKPREFUNC */ + NPC_TEMPLATEWALKPOSTFUNC, /* CHAR_WALKPOSTFUNC */ + NPC_TEMPLATEPREOVERFUNC, /* CHAR_PREOVERFUNC */ + NPC_TEMPLATEPOSTOVERFUNC, /* CHAR_POSTOVERFUNC */ + NPC_TEMPLATEWATCHFUNC, /* CHAR_WATCHFUNC */ + NPC_TEMPLATELOOPFUNC, /* CHAR_LOOPFUNC */ + NPC_TEMPLATEDYINGFUNC, /* CHAR_DYINGFUNC */ + NPC_TEMPLATETALKEDFUNC, /* CHAR_TALKEDFUNC */ + + NPC_TEMPLATEPREATTACKEDFUNC, /* CHAR_PREATTACKEDFUNC */ + NPC_TEMPLATEPOSTATTACKEDFUNC, /* CHAR_POSTATTACKEDFUNC */ + + NPC_TEMPLATEOFFFUNC, /* CHAR_OFFFUNC */ + NPC_TEMPLATELOOKEDFUNC, /* CHAR_LOOKEDFUNC */ + NPC_TEMPLATEITEMPUTFUNC, /* CHAR_ITEMPUTFUNC */ + + NPC_TEMPLATESPECIALTALKEDFUNC, /* CHAR_SPECIALTALKEDFUNC */ + NPC_TEMPLATEWINDOWTALKEDFUNC, /* CHAR_WINDOWTALKEDFUNC */ +#ifdef _USER_CHARLOOPS + NPC_TEMPLATELOOPFUNCTEMP1, //CHAR_LOOPFUNCTEMP1, + NPC_TEMPLATELOOPFUNCTEMP2, //CHAR_LOOPFUNCTEMP2, + NPC_TEMPLATEBATTLEPROPERTY, //CHAR_BATTLEPROPERTY, +#endif + NPC_TEMPLATECHARNUM, +}NPC_TEMPLATECHAR; + +typedef enum +{ + NPC_TEMPLATEMAKEATNOBODY, /* 簿手中卅中凛卞手综月井升丹井 */ + NPC_TEMPLATEMAKEATNOSEE, /* 苇尹卅中赭匹综月井升丹井 */ + NPC_TEMPLATEIMAGENUMBER, /* 飓 寞 */ + NPC_TEMPLATETYPE, /* 瑁户月凛卞瑁户月 */ + + NPC_TEMPLATEMINHP, /* HP */ + + NPC_TEMPLATEMINMP, /* MP */ + + NPC_TEMPLATEMINSTR, /* STR */ + + NPC_TEMPLATEMINTOUGH, /* TOUGH */ + + NPC_TEMPLATEISFLYING, /* 氏匹月井升丹井 */ + + NPC_TEMPLATEITEMNUM, /* 切丹月失奶 丞及 醒 */ + + NPC_TEMPLATELOOPFUNCTIME, /* + * 窒立伉 仍午卞伙□皿楮醒 + * 毛裟少井 + */ + NPC_TEMPLATEFUNCTIONINDEX, /* + * fucntionSet 及窒 及 + * 奶件犯永弁旦井 + */ + + NPC_TEMPLATEINTNUM, +}NPC_TEMPLATEINT; + +typedef struct tagNPC_Template +{ + STRING64 chardata[NPC_TEMPLATECHARNUM]; + int intdata[NPC_TEMPLATEINTNUM]; + int randomdata[NPC_TEMPLATEINTNUM]; /* 仿件母丞及 五今 + 互 匀化中月 */ + int hash; + NPC_haveItem* haveitem; +}NPC_Template; + + +EXTERN NPC_Template* NPC_template; +EXTERN int NPC_templatenum; +EXTERN int NPC_template_readindex; + +INLINE int NPC_CHECKTEMPLATEINDEX(int index); + +BOOL NPC_copyFunctionSetToChar( int id, Char* ch ); + +BOOL NPC_readNPCTemplateFiles( char* topdirectory ,int templatesize); +int NPC_templateGetTemplateIndex( char* templatename ); + +#endif + /*__READNPCTEMPLATE_H__*/ diff --git a/gmsv/include/npcutil.h b/gmsv/include/npcutil.h new file mode 100644 index 0000000..191f68d --- /dev/null +++ b/gmsv/include/npcutil.h @@ -0,0 +1,89 @@ +#ifndef _NPCUTIL_H_ +#define _NPCUTIL_H_ + +BOOL NPC_Util_AddOneTitle( int charindex, int titleindex ); +BOOL NPC_Util_HaveTitle( int charindex , int titleindex ); +BOOL NPC_Util_Nearby( int x1 , int y1, int x2 , int y2 ); +BOOL NPC_Util_CharNearby(int ind1,int ind2); +int NPC_Util_YN(char *input ); +int NPC_Util_getDirFromTwoPoint( POINT* pstart, POINT* pend ); +int NPC_Util_countHaveItem( int meindex , int itemid ); +BOOL NPC_Util_isBackContact( int frontindex , int backindex ); + +void NPC_Util_AnnounceFloor( int floorid , char *msg ); + + +BOOL NPC_Util_moveItemToChar( int charindex, int itemindex,BOOL net ); +BOOL NPC_Util_createItemToChar( int charindex, int itemid , BOOL net); +int NPC_Util_CharDistance( int index1, int index2 ); +int NPC_Util_SearchNear( int meindex, int maxlen, int type ); +int NPC_Util_SearchNearPlayer( int meindex, int maxlen ); +int NPC_Util_SearchNearEnemy( int meindex, int maxlen ); +int NPC_Util_SuberiWalk( int index, int dir ); +int NPC_Util_GetNumFromArg( int meindex, char* in); + +int NPC_Util_GetDirCharToChar( int fromindex, int toindex, int mode); +int NPC_Util_WalkCharToChar( int fromindex, int toindex, int mode, int suberi); +BOOL NPC_Util_isFaceToFace( int index1, int index2, int distance ); +BOOL NPC_Util_isFaceToChara( int index1, int index2, int distance ); +BOOL NPC_Util_charIsInFrontOfChar( int index1, int index2, int distance ); + +int NPC_Util_SearchItemInChar( int charindex , int itemindex); +int NPC_Util_GiveAllItemToChar( int give , int take ); + +#ifdef _NPCSERVER_NEW +BOOL NPC_UtilObj_isFaceToFace( int npcobjindex, int charaindex, int distance ); +#endif + +/* +int NPC_Util_ControlOtherNPC( CHAR_TYPE chartype , + char *npcname, + char *command ); +*/ +void NPC_Util_NPCDelete( int srcindex ); +BOOL NPC_Util_moveItemToMap( int itemindex , int fl , int x , int y, + BOOL net ); +char *NPC_Util_GetArgStr( int index, char *argstr, int len); +int NPC_Util_GetNumFromStrWithDelim( char *srcstr, char* in); +char *NPC_Util_GetStrFromStrWithDelim( char *srcstr, char *srhstr, + char *buf, int len); +inline double NPC_Util_sellRate( int seller ); +inline double NPC_Util_buyRate( int buyer ); +BOOL NPC_Util_IsVisiblePlayer( int meindex); +BOOL NPC_Util_WordInclude( char *text , char *word ); +void NPC_Util_RandomToken(char *in, char *out, int outbufsize ); + +void cutDotsTail( char *s ); +int NPC_Util_FrontItem( int meindex ); +void NPC_Util_Boss2KingStart( int bossindex ); +int NPC_Util_FrontChar( int meindex ); +int *NPC_Util_getEnemy( int meindex, int charaindex); + +void NPC_NowEndEventSetFlgCls(int talker,int shiftbit); +void NPC_EventSetFlg(int talker,int shiftbit); +BOOL NPC_EventCheckFlg(int point,int shiftbit); +void NPC_NowEventSetFlg(int talker,int shiftbit); +void NPC_NowEventSetFlgCls(int talker,int shiftbit); +BOOL NPC_NowEventCheckFlg(int point,int shiftbit); +char *NPC_Util_CheckAssignArgFile( int index, char *filename); + +// CoolFish: Family Adv 2001/8/4 +void AddFMAdv(int talker, int shiftbit); + +// Robin 0817 family income +int addNpcFamilyTax( int meindex, int talkerindex, int income ); + +#define NPC_ENEMY_ENEMYNUMBER 10 /* 请蜇衬 醒 */ + +/* 娄醒白央奶伙 心 心及ㄠ垫及 侬醒晓蜃 */ +#define NPC_UTIL_GETARGSTR_LINEMAX 4096 +/* 娄醒白央奶伙及 心 心田永白央扔奶术*/ +#ifdef _NEWEVENT +#define NPC_UTIL_GETARGSTR_BUFSIZE 1024*1200 +#else +#define NPC_UTIL_GETARGSTR_BUFSIZE 1024*12 +#endif +#endif + + + diff --git a/gmsv/include/object.h b/gmsv/include/object.h new file mode 100644 index 0000000..fed25a5 --- /dev/null +++ b/gmsv/include/object.h @@ -0,0 +1,80 @@ +#ifndef __OBJECT_h__ +#define __OBJECT_h__ + +#include "common.h" + +typedef enum +{ + OBJTYPE_NOUSE, /* 仇及奶件犯永弁旦反银匀化中卅中午中丹仪毛憎允*/ + OBJTYPE_CHARA, /* 平乓仿弁正 CHAR_chara尺及奶件犯永弁旦 */ + OBJTYPE_ITEM, /* 失奶 丞 ITEM_item 尺及奶件犯永弁旦 */ + OBJTYPE_GOLD, /* 打□伙玉 云嗯及汹互index卞 匀化中月 */ +#ifdef _NPCSERVER_NEW + OBJTYPE_NPCSCHARA, +#endif +#ifdef _MAP_WARPPOINT + OBJTYPE_WARPPOINT, +#endif + OBJTYPE_NUM +}OBJTYPE; + +typedef struct tagObject +{ + OBJTYPE type; + + char objname[256]; + int npcsindex; + int dir; + int imagenum; + + int chartype; + int index; + int x; + int y; + int floor; +#ifdef _DEL_DROP_GOLD + int time; +#endif +}Object; + +BOOL CHECKOBJECT( int index ); +BOOL CHECKOBJECTUSE( int index ); +BOOL initObjectArray( int num ); +BOOL endObjectArray( void ); + +INLINE int _initObjectOne( char *file, int line, Object* ob ); +#define initObjectOne( ob ) _initObjectOne( __FILE__, __LINE__, ob) + +void endObjectOne( int index ); +int initObjectFromObjectMember(OBJTYPE type, int index, int x, int y , int floor ); + +INLINE int OBJECT_getType( int index ); +INLINE int OBJECT_setType( int index, int newvalue ); +INLINE int OBJECT_getFloor( int index ); +INLINE int OBJECT_setFloor( int index, int newvalue ); +INLINE int OBJECT_getX( int index ); +INLINE int OBJECT_setX( int index, int newvalue ); +INLINE int OBJECT_getY( int index ); +INLINE int OBJECT_setY( int index, int newvalue ); +INLINE int OBJECT_getIndex( int index ); +INLINE int OBJECT_setIndex( int index, int newvalue ); +INLINE int OBJECT_getNum( void ); + +#ifdef _NPCSERVER_NEW +INLINE int OBJECT_getNpcIndex( int index ); +INLINE char* OBJECT_getName( int index ); +INLINE int OBJECT_getNpcImage( int index ); +INLINE int OBJECT_getNpcdir( int index ); +#endif +INLINE int OBJECT_getchartype( int index ); +INLINE void OBJECT_setchartype( int index, int flg); + +#ifndef _SIMPLIFY_ITEMSTRING +BOOL storeObjects( char* dirname ); +BOOL restoreObjects( char* dirname ); +#endif + +int searchObjectFromCharaIndex( int index ); + +#endif +/*__OBJECT_h__*/ diff --git a/gmsv/include/pet.h b/gmsv/include/pet.h new file mode 100644 index 0000000..e250e51 --- /dev/null +++ b/gmsv/include/pet.h @@ -0,0 +1,32 @@ +#ifndef __PET_H__ +#define __PET_H__ + +/* + * 矢永玄楮 及涩烂匹允[ + */ +#include "version.h" +#include "common.h" + +#define PETFEEDTIME 60*60 // 宠物蛋 养时间(秒) +//#define PETFEEDTIME 5 // 宠物蛋 养时间(秒) + +int PET_DEBUG_initPetOne( int charaindex); +int PET_dropPet( int charaindex, int havepetindex); +int PET_dropPetFollow( int charaindex, int havepetindex, int fl, int x, int y); +int PET_dropPetFLXY( int charaindex, int havepetindex, int fl, int x, int y); +int PET_dropPetAbsolute( int petindex, int floor, int x, int y,BOOL net); +int PET_createPetFromCharaIndex( int charaindex, int enemyindex); +BOOL PET_SelectBattleEntryPet( int charaindex, int petarray); +int PET_initCharOneArray( Char *ch); +BOOL PET_isPutPoint( int fl,int x, int y); + + +BOOL PET_getBaseForAllocpoint( int toindex, int *work); +void PET_showEditBaseMsg( int charaindex, int toindex, int itemindex, int *work); + +#ifdef _PET_EVOLUTION +BOOL PET_getBaseAndSkill( int charaindex, int baseindex, int *base, int *skill, int flg); +#endif +BOOL CHAR_DelPetForIndex( int charaindex, int petindex); + +#endif diff --git a/gmsv/include/pet_event.h b/gmsv/include/pet_event.h new file mode 100644 index 0000000..bce25ff --- /dev/null +++ b/gmsv/include/pet_event.h @@ -0,0 +1,18 @@ +#ifndef __PET_EVENT_H__ +#define __PET_EVENT_H__ + +/* + * 矢永玄楮 及涩烂匹允[ + * 矢永玄奶矛件玄楮 + */ + +void PET_Talkfunc( int meindex, int talkerindex, char *msg, int color); + +void PET_Watchfunc( int objmeindex, int objmoveindex, + CHAR_ACTION act, int x, int y, int dir, + int* opt, int optlen ); +int PET_CleanPetdeletetime( int objmeindex); +void PET_CleanFreePetAll(); + + +#endif diff --git a/gmsv/include/pet_skill.h b/gmsv/include/pet_skill.h new file mode 100644 index 0000000..e59187f --- /dev/null +++ b/gmsv/include/pet_skill.h @@ -0,0 +1,546 @@ +#ifndef __PET_SKILL_H__ +#define __PET_SKILL_H__ + +#include "util.h" + +typedef enum +{ + PETSKILL_FIELD_ALL, /* 允屯化及桦赭匹银尹月 */ + PETSKILL_FIELD_BATTLE, /* 爵 及心 */ + PETSKILL_FIELD_MAP, /* 骚橘穴永皿晓及心 */ + +}PETSKILL_FIELDTYPE; + +typedef enum +{ + PETSKILL_TARGET_MYSELF, /* 愤坌及心 */ + PETSKILL_TARGET_OTHER, /* 职及谛 愤坌殖戈) */ + PETSKILL_TARGET_ALLMYSIDE, /* 蝈 */ + PETSKILL_TARGET_ALLOTHERSIDE, /* 锹澎础蝈 */ + PETSKILL_TARGET_ALL, /* 蝈化 */ + PETSKILL_TARGET_NONE, /* 簿手蓟 请 卅中[ 豢支凶户及凛 */ + PETSKILL_TARGET_OTHERWITHOUTMYSELF,/* 职及谛 愤坌殖引卅中) */ + PETSKILL_TARGET_WITHOUTMYSELFANDPET, /* 愤坌午矢永玄动陆 */ +}PETSKILL_TARGETTYPE; + +typedef enum +{ + PETSKILL_ID, + PETSKILL_FIELD, + PETSKILL_TARGET, +#ifdef _PETSKILL2_TXT + PETSKILL_USETYPE, +#endif + PETSKILL_COST, + PETSKILL_ILLEGAL, + PETSKILL_DATAINTNUM, +}PETSKILL_DATAINT; + +typedef enum +{ + PETSKILL_NAME, /* */ + PETSKILL_COMMENT, /* 戊丢件玄*/ + PETSKILL_FUNCNAME, /* 楮醒 */ + PETSKILL_OPTION, /* 左皿扑亦件 */ +#ifdef _CFREE_petskill + PETSKILL_FREE, /*条件*/ + PETSKILL_KINDCODE, /*种类码*/ +#endif + + PETSKILL_DATACHARNUM, +}PETSKILL_DATACHAR; + +typedef struct tagPetskill +{ + int data[PETSKILL_DATAINTNUM]; + STRING64 string[PETSKILL_DATACHARNUM]; + +}Petskill; + +typedef int (*PETSKILL_CALLFUNC)( int, int, int, char * ); + +INLINE BOOL PETSKILL_CHECKINDEX( int index ); +INLINE int PETSKILL_getInt( int index, PETSKILL_DATAINT element); +INLINE int PETSKILL_setInt( int index, PETSKILL_DATAINT element, int data); +INLINE char* PETSKILL_getChar( int index, PETSKILL_DATACHAR element); +INLINE BOOL PETSKILL_setChar( int index ,PETSKILL_DATACHAR element, char* new ); +int PETSKILL_getPetskillNum( void); + +#define PETSKILL_GetArray( charaindex, havepetskill) _PETSKILL_GetArray( __FILE__, __LINE__, charaindex, havepetskill) +int _PETSKILL_GetArray( char *file, int line, int charaindex, int havepetskill ); + +BOOL PETSKILL_initPetskill( char *filename); +BOOL PETSKILL_reinitPetskill( void ); +int PETSKILL_getPetskillArray( int petskillid); +PETSKILL_CALLFUNC PETSKILL_getPetskillFuncPointer(char* name); + +int PETSKILL_Use( + int charaindex, + int toindex, + int array, + char *data + //BOOL isCLI // Robin 2001/02/26 if owner is player +); + +int PETSKILL_ContinuationAttack( + int charaindex, + int toindex, + int array, + char *data +); +int PETSKILL_ChargeAttack( + int charaindex, + int toindex, + int array, + char *data +); + + +#define PETSKILL_ID_GBREAK 0 // 布□玉皮伊奶弁 +#define PETSKILL_ID_RENZOKU 1 // 粮 猾 +#define PETSKILL_ID_GUARDIAN 2 // 镝舅甩民跤 +#define PETSKILL_ID_CHARGE 3 // 民乓□斥 猾 +#define PETSKILL_ID_ICHIGEKI 100 // 域猾 诮 +#define PETSKILL_ID_POWERBALANCE 110 // 及讽 + +//********************************************************************** +// +// 檗 -- 职谛毛潮曰卅互日 猾 +// +int PETSKILL_Guardian( + int charaindex, + int toindex, + int array, + char *data +); +// +//********************************************************************** + +int PETSKILL_PowerBalance( + int charaindex, + int toindex, + int array, + char *data +); + +//********************************************************************** +// +// 檗 -- 雄 分互荚 今木月割 互嫖中 +// +int PETSKILL_Mighty( + int charaindex, + int toindex, + int array, + char *data +); +// +//********************************************************************** + + +//********************************************************************** +// +// 檗 -- 旦 □正旦唱橘 猾 +// +int PETSKILL_StatusChange( + int charaindex, + int toindex, + int array, + char *data + +); +// +//********************************************************************** + + +//******************************************************* +// +// 檗 -- 骚橘 猾 +// +int PETSKILL_NormalAttack( + int charaindex, + int toindex, + int array, + char *data + +); +// +//******************************************************* + +//******************************************************* +// +// 檗 -- 骚橘 豢 +// +int PETSKILL_NormalGuard( + int charaindex, + int toindex, + int array, + char *data + +); +// +//******************************************************* + +//******************************************************* +// 檗 -- 谨窗(窒手仄卅中) +// +int PETSKILL_None( + int charaindex, + int toindex, + int array, + char *data + +); +// +//******************************************************* + +//******************************************************* +// 檗 -- 哗萄域葱(怅木化ㄠ正□件 卞锹澎及 井日 猾) +// +int PETSKILL_EarthRound( + int charaindex, + int toNo, + int array, + char *data + +); +// +//******************************************************* + +//******************************************************* +// 檗 -- 布□玉皮伊奶弁 +// +int PETSKILL_GuardBreak( + int charaindex, + int toNo, + int array, + char *data + +); +/////////////////////////////////////////// +#ifdef _SKILL_GUARDBREAK2//破除防御2 vincent add 2002/05/20 +int PETSKILL_GuardBreak2( + int charaindex, + int toNo, + int array, + char *data + +); +#endif +// +//******************************************************* +//******************************************************* +// 檗 -- 木 +// +int PETSKILL_Abduct( + int charaindex, + int toNo, + int array, + char *data + +); +// +//******************************************************* +//******************************************************* +// 檗 -- 戈 +int PETSKILL_Steal( + int charaindex, + int toNo, + int array, + char *data + +); +//******************************************************* +#ifdef _BATTLESTEAL_FIX +int PETSKILL_StealMoney( + int charaindex, + int toNo, + int array, + char *data + +); +#endif + +#ifdef _ITEM_INSLAY +int PETSKILL_Inslay( + int index, + int toNo, + int array, + char *data + +); +#endif + +#ifdef _PETSKILL_FIXITEM +int PETSKILL_Fixitem( + int index, + int toNo, + int array, + char *data + +); +#endif + +// 檗 -- 失奶 丞宁岳 +// +int PETSKILL_Merge( + int charaindex, + int toNo, + int array, + char *data + +); +// +//******************************************************* + +//******************************************************* +// 檗 -- 用□布□玉 +// +int PETSKILL_NoGuard( + int charaindex, + int toNo, + int array, + char *data + +); +// +//******************************************************* + + + +// Terry add 2001/11/05 +#ifdef __ATTACK_MAGIC +int PETSKILL_AttackMagic( + int charaindex, + int toindex, + int array, + char *data +); +#endif + +#ifdef _VARY_WOLF +int PETSKILL_Vary( int cindex, int tindex, int id, char* data); +#endif + +#ifdef _SKILL_WILDVIOLENT_ATT +//vincent add 2002/05/16 +int PETSKILL_WildViolentAttack( + int charaindex, + int toindex, + int array, + char *data +); +#endif + +#ifdef _SKILL_SPEEDY_ATT +//vincent add 2002/05/16 +int PETSKILL_SpeedyAttack( + int charaindex, + int toindex, + int array, + char *data +); +#endif + +#ifdef _SKILL_SACRIFICE +//vincent add 2002/05/30 +int PETSKILL_Sacrifice( + int charaindex, + int toindex, + int array, + char *data +); +#endif + +#ifdef _SKILL_REFRESH +//vincent add 2002/08/08 +int PETSKILL_Refresh( + int charaindex, + int toindex, + int array, + char *data +); +#endif + +#ifdef _SKILL_WEAKEN //vincent宠技:虚弱 +int PETSKILL_Weaken( + int charaindex, + int toindex, + int array, + char *data +); +#endif + +#ifdef _SKILL_DEEPPOISON //vincent宠技:剧毒 +int PETSKILL_Deeppoison( + int charaindex, + int toindex, + int array, + char *data +); +#endif + +#ifdef _SKILL_BARRIER //vincent宠技:魔障 +int PETSKILL_Barrier( + int charaindex, + int toindex, + int array, + char *data +); +#endif + +#ifdef _SKILL_NOCAST //vincent宠技:沉默 +int PETSKILL_Nocast( + int charaindex, + int toindex, + int array, + char *data +); +#endif + +#ifdef _SKILL_ROAR //vincent宠技:大吼 +int PETSKILL_Roar( + int charaindex, + int toindex, + int array, + char *data +); +#endif + +#ifdef _PSKILL_FALLGROUND +int PETSKILL_FallGround( int charaindex, int toNo, int array, char *data ); +#endif +#ifdef _PETSKILL_EXPLODE +int PETSKILL_Explode( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _PRO_BATTLEENEMYSKILL +int ENEMYSKILL_ReLife( int enemyindex, int toNo, int array, char *data ); +int ENEMYSKILL_ReHP( int enemyindex, int toNo, int array, char *data ); + +int ENEMYSKILL_EnemyHelp( int enemyindex, int toNo, int array, char *data ); +#endif + +#ifdef _SKILL_DAMAGETOHP +int PETSKILL_DamageToHp( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _PETSKILL_TIMID +int PETSKILL_BattleTimid( int charaindex, int toNo, int array, char *data ); +#endif +#ifdef _PETSKILL_2TIMID +int PETSKILL_2BattleTimid( int charaindex, int toNo, int array, char *data ); +#endif +#ifdef _PETSKILL_ANTINTER +int PETSKILL_AntInter(int charaindex, int toindex, int array, char* data); // 宠物技能战斗模组 +#endif + +#ifdef _PETSKILL_PROPERTY +int PETSKILL_BattleProperty( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _PETSKILL_TEAR +int PETSKILL_BattleTearDamage( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _BATTLE_LIGHTTAKE +int PETSKILL_Lighttakeed( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _BATTLE_ATTCRAZED +int PETSKILL_AttackCrazed( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _SHOOTCHESTNUT // Syu ADD 宠技:丢栗子 +int PETSKILL_AttackShoot( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _Skill_MPDAMAGE +int PETSKILL_MpDamage( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _PETSKILL_SETDUCK +int PETSKILL_SetDuck( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _MAGICPET_SKILL +int PETSKILL_SetMagicPet( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _SKILL_TOOTH +int PETSKILL_ToothCrushe( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _PSKILL_MODIFY +int PETSKILL_Modifyattack( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _PSKILL_MDFYATTACK +int PETSKILL_Mdfyattack( int charaindex, int toNo, int array, char *data ); +#endif + + +#ifdef _MAGIC_SUPERWALL +int PETSKILL_MagicStatusChange( int charaindex, int toindex, int array, char *data ); +#endif + +#ifdef _PET_SKILL_SARS // WON ADD 毒煞蔓延 +int PETSKILL_Sars( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _SONIC_ATTACK // WON ADD 音波攻击 +int PETSKILL_Sonic( int charaindex, int toNo, int array, char *data ); +#endif +#ifdef _PETSKILL_REGRET +int PETSKILL_Regret( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _PETSKILL_GYRATE +int PETSKILL_Gyrate( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _PETSKILL_ACUPUNCTURE //针刺外皮 +int PETSKILL_Acupuncture( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _PETSKILL_RETRACE +int PETSKILL_Retrace( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _PETSKILL_HECTOR +int PETSKILL_Hector( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _PETSKILL_FIREKILL +int PETSKILL_Firekill( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _PETSKILL_DAMAGETOHP //暗月狂狼(嗜血技的变体) +int PETSKILL_DamageToHp2( int charaindex, int toNo, int array, char *data ); +#endif + +#ifdef _PETSKILL_BECOMEFOX +int PETSKILL_BecomeFox( int charaindex, int toNo, int array, char* data); +#endif + +#ifdef _PETSKILL_BECOMEPIG +int PETSKILL_BecomePig( int charaindex, int toNo, int array, char* data); +#endif + +#ifdef _PETSKILL_SHOWMERCY +int PETSKILL_ShowMercy(int charaindex, int toNo, int array, char* data); +#endif + +#ifdef _PETSKILL_COMBINED +int PETSKILL_Combined(int charaindex, int toNo, int array, char* data); +#endif + +#ifdef _PETSKILL_LER +int PETSKILL_BatFly(int charaindex, int toNo, int array, char* data); // 雷尔技 - 群蝠四窜 +int PETSKILL_DivideAttack(int charaindex, int toNo, int array, char* data); // 雷尔技 - 分身地裂 +#endif + +#ifdef _PETSKILL_BATTLE_MODEL +int PETSKILL_BattleModel(int charaindex, int toindex, int array, char* data); // 宠物技能战斗模组 +#endif + +#endif diff --git a/gmsv/include/pet_skillinfo.h b/gmsv/include/pet_skillinfo.h new file mode 100644 index 0000000..db735e1 --- /dev/null +++ b/gmsv/include/pet_skillinfo.h @@ -0,0 +1,139 @@ +/* generated by makedefs.perl */ +#include "version.h" + +#define PETSKILL_NONE ( 0 ) +#define PETSKILL_NORMALATTACK ( 1 ) +#define PETSKILL_NORMALGUARD ( 2 ) +#define PETSKILL_GUARDBREAK ( 3 ) +#define PETSKILL_CONTINUATIONATTACK1 ( 10 ) +#define PETSKILL_CONTINUATIONATTACK2 ( 11 ) +#define PETSKILL_CONTINUATIONATTACK3 ( 12 ) +#define PETSKILL_CONTINUATIONATTACK4 ( 13 ) +#define PETSKILL_GUARDIAN ( 25 ) +#define PETSKILL_CHARGE1 ( 30 ) +#define PETSKILL_CHARGE2 ( 31 ) +#define PETSKILL_MIGHTY1 ( 40 ) +#define PETSKILL_MIGHTY2 ( 41 ) +#define PETSKILL_POWERBALANCE1 ( 50 ) +#define PETSKILL_POWERBALANCE2 ( 51 ) +#define PETSKILL_POWERBALANCE3 ( 52 ) +#define PETSKILL_POISON_ATTACK1 ( 60 ) +#define PETSKILL_POISON_ATTACK2 ( 61 ) +#define PETSKILL_STONE ( 80 ) +#define PETSKILL_CONFUSION_ATTACK ( 90 ) +#define PETSKILL_DRUNK_ATTACK ( 100 ) +#define PETSKILL_SLEEP_ATTACK ( 110 ) +#define PETSKILL_EARTHROUND1 ( 120 ) +#define PETSKILL_Abduct ( 130 ) +#define PETSKILL_STEAL ( 140 ) +#define PETSKILL_NOGUARD1 ( 150 ) +#define PETSKILL_NOGUARD2 ( 151 ) +#define PETSKILL_NOGUARD3 ( 152 ) +#define PETSKILL_MERGE ( 200 ) +#define PETSKILL_MERGE2 ( 201 ) +#ifdef _ALCHEMIST +#define PETSKILL_ALCHEMIST ( 202 ) +#endif +#ifdef _PSKILL_FALLGROUND +#define PETSKILL_FALLGROUND ( 210 ) +#endif +#ifdef _BATTLESTEAL_FIX +#define PETSKILL_STEALMONEY ( 211 ) +#endif +#ifdef _PRO_BATTLEENEMYSKILL +#define ENEMYSKILL_RELIFES ( 500 ) +#define ENEMYSKILL_RELIFHP ( 501 ) +#define ENEMYSKILL_HELP ( 502 ) +#endif +#ifdef _SKILL_DAMAGETOHP +#define PETSKILL_DAMAGETOHP ( 503) +#endif +#ifdef _Skill_MPDAMAGE +#define PETSKILL_MPDAMAGE ( 504) +#endif +#ifdef _SKILL_WILDVIOLENT_ATT +#define PETSKILL_WILDVIOLENTATTACK ( 540)//狂暴 vincent add 2002/05/16 +#endif +#ifdef _SKILL_SPEEDY_ATT +#define PETSKILL_SPEEDYATTACK ( 541) //疾速 vincent add 2002/05/16 +#endif +#ifdef _SKILL_GUARDBREAK2 +#define PETSKILL_GUARDBREAK2 ( 542) //破除防御2 vincent add 2002/05/20 +#endif +#ifdef _SKILL_SACRIFICE +#define PETSKILL_SACRIFICE ( 543) //救援 vincent add 2002/05/30 +#endif + +#ifdef _SKILL_WEAKEN +#define PETSKILL_WEAKEN ( 544) //虚弱 vincent add 2002/07/11 +#endif + +#ifdef _SKILL_DEEPPOISON +#define PETSKILL_DEEPPOISON ( 545) //剧毒 vincent add 2002/07/16 +#endif + +#ifdef _SKILL_BARRIER +#define PETSKILL_BARRIER ( 546) //魔障 vincent add 2002/07/16 +#endif + +#ifdef _SKILL_NOCAST +#define PETSKILL_NOCAST ( 547) //沉默 vincent add 2002/07/16 +#endif + + +#ifdef _SKILL_ROAR +#define PETSKILL_ROAR ( 548) //大吼 vincent add 2002/07/11 +#endif + +#ifdef _ITEM_INSLAY +#define PETSKILL_INSLAY (572) +#endif + +#ifdef _PETSKILL_FIXITEM +#define PETSKILL_FIXITEM (573) +#endif + +#ifdef _SKILL_TOOTH +#define PETSKILL_TOOTHCRUSHE (574) +#endif + +#ifdef _SKILL_REFRESH +#define PETSKILL_REFRESH ( 575) //vincent add 2002/08/08 +#endif + +#ifdef _VARY_WOLF +#define PETSKILL_VARY ( 600 ) +#endif + +#ifdef _PETSKILL_SETDUCK +#define PETSKILL_SETDUCK ( 600 ) +#endif + +#ifdef _MAGICPET_SKILL +#define PETSKILL_SETMAGICPET ( 601 ) +#endif + +#ifdef _BATTLE_LIGHTTAKE +#define PETSKILL_Light ( 608) +#endif + +#ifdef _BATTLE_ATTCRAZED +#define PETSKILL_AttCrazed ( 608) +#endif + +#ifdef _SHOOTCHESTNUT // Syu ADD 宠技:丢栗子 +#define PETSKILL_AttShoot ( 609 ) +#endif + +#ifdef _PETSKILL_BECOMEPIG +#define PETSKILL_BECOMEPIG ( 628 ) +#endif + +#ifdef _PETSKILL_LER +#define PETSKILL_BATFLY ( 633 ) +#define PETSKILL_DIVIDEATTACK ( 634 ) +#endif + +#ifdef _PETSKILL_BATTLE_MODEL +#define PETSKILL_BATTLE_MODEL ( 635 ) +#endif diff --git a/gmsv/include/petmail.h b/gmsv/include/petmail.h new file mode 100644 index 0000000..8a18fab --- /dev/null +++ b/gmsv/include/petmail.h @@ -0,0 +1,57 @@ +#ifndef __PETMAIL_H__ +#define __PETMAIL_H__ +#include "version.h" +/* + * 矢永玄楮 及涩烂匹允[ + */ +#define PETMAIL_OFFMSG_MAX 10000 +#define PETMAIL_OFFMSG_TIMEOUT ( 3 * 24 * 3600 ) +#define PETMAIL_CHECK_OFFMSG_EXPIRE_INTERVAL 3600 +#define PETMAIL_OFFMSG_TEXTLEN 512 + +/* 矢永玄丢□伙及请蜇躲绊及醒[ 端及醒方曰ㄠ剂卅仁允月仇午 */ +#define PETMAIL_EFFECTMAX 1 + +#define PETMAIL_SPOOLFLOOR 777 +#define PETMAIL_SPOOLX 30 +#define PETMAIL_SPOOLY 30 + +#define PETMAIL_LOOPINTERVAL1 500 +#define PETMAIL_LOOPINTERVAL2 5000 + +/* 左白仿奶件及平乓仿尺及丢永本□斥毛创尹月 */ +typedef struct +{ + int use; + time_t send_tm; /* 交□扒互丢永本□斥毛霜耨仄凶凛棉+TIMEOUT[ */ + int color; /* 平旦玄及缙 */ + char text[PETMAIL_OFFMSG_TEXTLEN]; /* 平旦玄及 */ + char destcd[CDKEYLEN]; /* 霜耨燮CDKEY */ + char destcharname[CHARNAMELEN]; /* 霜耨燮及平乓仿 */ + char srccd[CDKEYLEN]; /* 霜耨葭及cdkey */ + char srccharname[CHARNAMELEN]; /* 霜耨葭及平乓仿 */ + +} PETMAIL_offmsg; + +void PETMAIL_Loopfunc( int index); +BOOL PETMAIL_CheckPlayerExist( int index, int mode); + +BOOL PETMAIL_initOffmsgBuffer( int count ); +BOOL PETMAIL_addOffmsg( int fromindex, char *tocdkey, char *tocharaname, + char *text, int color ); +PETMAIL_offmsg *PETMAIL_getOffmsg( int offmsgindex); +BOOL PETMAIL_deleteOffmsg( int offmsgindex); +void PETMAIL_proc( void ); +BOOL storePetmail( void); +BOOL PETMAIL_sendPetMail( int cindex, int aindex, + int havepetindex, int haveitemindex, char* text , int color ); + +#ifdef _PETMAIL_DEFNUMS +void CHAR_AutoPickupMailPet( int charaindex, int petindex ); +#endif +int PETMAIL_getPetMailTotalnums( void); +void PETMAIL_delPetMailTotalnums( int numflg); +void PETMAIL_setPetMailTotalnums( int numflg); +int PETMAIL_CheckIsMyOffmsg( int fromindex, char *tocdkey, char *tocharaname); + +#endif diff --git a/gmsv/include/profession_skill.h b/gmsv/include/profession_skill.h new file mode 100644 index 0000000..cc534fd --- /dev/null +++ b/gmsv/include/profession_skill.h @@ -0,0 +1,169 @@ +#include "version.h" + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 +#include "common.h" +#include "util.h" +#include "skill.h" + +#define PROFESSION_MAX_LEVEL 26 // 职业等级上限 26级 +#define PROFESSION_SKILL_MAX_LEVEL 100 // 技能等级上限 100级 +#ifdef _75_TEST +#define PROFESSION_SKILL_ADD_POINT 100 // 升级检定通过,增加经验值 +#else +#define PROFESSION_SKILL_ADD_POINT 1 // 升级检定通过,增加经验值 +#endif +// 职业别 +typedef enum +{ + PROFESSION_CLASS_NONE=0, // 无职业 + PROFESSION_CLASS_FIGHTER, // 勇士 + PROFESSION_CLASS_WIZARD, // 巫师 + PROFESSION_CLASS_HUNTER, // 猎人 + PROFESSION_CLASS_NUM, +}PROFESSION_CLASS_TYPE; + +typedef enum +{ + PROFESSION_SKILL_NAME, // 技能名称 + PROFESSION_SKILL_TXT, // 说明 + PROFESSION_SKILL_FUNCNAME, // 使用函数 + PROFESSION_SKILL_OPTION, // 函数参数 + PROFESSION_SKILL_DATACHARNUM, +}PROFESSION_SKILL_DATACHAR; + + +typedef enum +{ + PROFESSION_SKILL_ID, // 技能编号 + PROFESSION_SKILL_PROFESSION_CLASS, // 职业 + PROFESSION_SKILL_TARGET, // 目标种类 + PROFESSION_SKILL_COST_MP, // 耗费MP + PROFESSION_SKILL_USE_FLAG, // 使用旗标 + PROFESSION_SKILL_KIND, // 技能种类 + PROFESSION_SKILL_ICON, // ICON图号 + PROFESSION_SKILL_IMG_1, // 攻击前图号(集气状态) + PROFESSION_SKILL_IMG_2, // 攻击图号(攻击中) + PROFESSION_SKILL_COST, // 购买金额 + PROFESSION_SKILL_FIX_VALUE, // 升级修正数值 + + //角色先学习以下所设定技能与熟练度均达到时才可以学习本技能 + PROFESSION_SKILL_LIMIT1, // 必修技能 1 编号 + PROFESSION_SKILL_PERCENT1, // 必修技能应有熟练度% 1 + PROFESSION_SKILL_LIMIT2, // 必修技能 2 编号 + PROFESSION_SKILL_PERCENT2, // 必修技能应有熟练度% 2 + PROFESSION_SKILL_LIMIT3, // 必修技能 3 编号 + PROFESSION_SKILL_PERCENT3, // 必修技能应有熟练度% 3 + PROFESSION_SKILL_LIMIT4, // 必修技能 4 编号 + PROFESSION_SKILL_PERCENT4, // 必修技能应有熟练度% 4 + PROFESSION_SKILL_DATAINTNUM, +}PROFESSION_SKILL_DATAINT; + + +typedef struct tagProfessionkill +{ + STRING64 string[PROFESSION_SKILL_DATACHARNUM]; + int data[PROFESSION_SKILL_DATAINTNUM]; +}Professionskill; + + +//---------------------------------------------------------------------------- +typedef int (*PROFESSION_SKILL_CALLFUNC)( int, int, int, char *, int ); +BOOL PROFESSION_initSkill( char *filename); +void rePROFESSION_initSkill(); + +//---------------------------------------------------------------------------- +INLINE BOOL PROFESSION_SKILL_CHECKINDEX( int index ); +INLINE int PROFESSION_SKILL_getInt( int index, PROFESSION_SKILL_DATAINT element); +INLINE int PROFESSION_SKILL_setInt( int index, PROFESSION_SKILL_DATAINT element, int data); +INLINE char* PROFESSION_SKILL_getChar( int index, PROFESSION_SKILL_DATACHAR element); +INLINE BOOL PROFESSION_SKILL_setChar( int index ,PROFESSION_SKILL_DATACHAR element, char* new ); +int PROFESSION_SKILL_getskillNum( void ); + +//---------------------------------------------------------------------------- +int PROFESSION_SKILL_getskillArray( int skillid); +PROFESSION_SKILL_CALLFUNC PROFESSION_SKILL_getskillFuncPointer(char* name ); +#define PROFESSION_SKILL_GetArray( charaindex, skill) _PROFESSION_SKILL_GetArray( __FILE__, __LINE__, charaindex, skill) +int _PROFESSION_SKILL_GetArray( char *file, int line, int charaindex, int skill ); +int PROFESSION_SKILL_Use( int charaindex, int skill, int toNo, char *data ); +void PROFESSION_SKILL_LVEVEL_UP( int charaindex, char *name ); +void PROFESSION_LEVEL_CHECK_UP( int charaindex ); +void PROFESSION_NORMAL_SKILL_LEVLE_UP(Skill* skill, int Pskillid, int charaindex ); +void PROFESSION_SKILL_WEAPON_FOCUS_LVEVEL_UP( int charaindex, char *name ); +void PROFESSION_SKILL_DUAL_WEAPON_LVEVEL_UP( int charaindex, char *name ); +int PROFESSION_SKILL_DEC_COST_MP( int charaindex, int skill, int Pskillid, int skill_level ); +int PROFESSION_SKILL_ADDSK( int charaindex, int skill, int level ); + +//---------------------------------------------------------------------------- +// 职业技能 +void profession_common_fun( int charaindex, int toNo, int skill_level, int array, int com1 ); +int PROFESSION_brust( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_chain_atk( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_avoid( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_recovery( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_weapon_focus( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_volcano_springs( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_fire_ball( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_fire_spear( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_summon_thunder( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_current( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_storm( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_ice_arrow( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_ice_crack( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_ice_mirror( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_doom( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_blood( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_blood_worms( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_sign( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_fire_enclose( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_ice_eclose( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_thunder_enclose( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_fire_practice( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_ice_practice( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_thunder_practice( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_enclose( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_transpose( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_reback( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_chain_atk_2( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_scapegoat( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_enrage( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_energy_collect( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_focus( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_shield_attack( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_dual_weapon( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_deflect( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_through_attack( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_cavalry( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_dead_attack( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_convolute( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_chaos( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_docile( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_trap( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_enrage_pet( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_dragnet( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_entwine( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_autarky( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_plunder( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_toxin_weapon( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_resist_fire( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_resist_ice( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_resist_thunder( int charaindex, int toindex, int array, char *data, int skill_level ); +#ifdef _PROFESSION_ADDSKILL +int PROFESSION_resist_f_i_t( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_call_nature( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_boundary( int charaindex, int toindex, int array, char *data, int skill_level ); +#endif +int PROFESSION_attack_weak( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_instigate( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_track( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_oblivion( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_full_mp( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_strong_back( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_strengthen( int charaindex, int toindex, int array, char *data, int skill_level ); +int PROFESSION_escape( int charaindex, int toNo, int array, char *data, int skill_level ); +int PROFESSION_g_resist_fire( int charaindex, int toNo, int array, char *data, int skill_level ); +int PROFESSION_g_resist_ice( int charaindex, int toNo, int array, char *data, int skill_level ); +int PROFESSION_g_resist_thunder( int charaindex, int toNo, int array, char *data, int skill_level ); + +//---------------------------------------------------------------------------- + +#endif diff --git a/gmsv/include/readmap.h b/gmsv/include/readmap.h new file mode 100644 index 0000000..7dfbf26 --- /dev/null +++ b/gmsv/include/readmap.h @@ -0,0 +1,130 @@ +#ifndef __MAP_H__ +#define __MAP_H__ +#include "common.h" +#include "util.h" + +typedef struct tagMAP_Objlink +{ + int objindex; + struct tagMAP_Objlink* next; +}MAP_Objlink, *OBJECT; + +#define GET_OBJINDEX(x) ((x)->objindex) +#define NEXT_OBJECT(x) ((x)->next) + +typedef struct tagMAP_Map +{ + int id; /* ID */ + int xsiz,ysiz; /* */ + char string[64]; /* 表示 */ + unsigned short* tile; /* */ + unsigned short* obj; /* */ + MAP_Objlink** olink; +#ifdef _MAP_NOEXIT + unsigned int startpoint; + int MapType; +#endif +}MAP_Map; + + +typedef enum +{ + MAP_WALKABLE, /* + * 场合 + * 擌 Q 见 0 + * 擌 M 见 1 + * 擌 M 见 2 + */ + MAP_HAVEHEIGHT, /* 高 非0 0 */ + MAP_DEFENCE, /* 抃 、守备力、0 以下 抃 */ + + MAP_INTODAMAGE, /* 入 时 HP 足 */ + MAP_OUTOFDAMAGE, /* 出 时 HP 足 */ + + MAP_SETED_BATTLEMAP, /* 设定 */ + MAP_BATTLEMAP, /* 番咥 1*/ + MAP_BATTLEMAP2, /* 番咥 2*/ + MAP_BATTLEMAP3, /* 番咥 3*/ + +/* 以下 LS2 使 SA 使 ( X @) */ + + MAP_INTODARKNESS, /* 入 时 暗 */ + MAP_INTOCONFUSION, /* 入 时 混 */ + + MAP_OUTOFPOISON, /* 入 时 毒 */ + MAP_OUTOFPARALYSIS, /* 入 时 */ + MAP_OUTOFSILENCE, /* 入 时 沈 */ + MAP_OUTOFSTONE, /* 入 时 石 */ + MAP_OUTOFDARKNESS, /* 入 时 暗 */ + MAP_OUTOFCONFUSION, /* 入 时 混 */ + + MAP_DATAINT_NUM, +}MAP_DATAINT; +typedef enum +{ + MAP_DATACHAR_NUM, +}MAP_DATACHAR; +typedef struct tagMAP_ImageData +{ + int data[MAP_DATAINT_NUM]; + STRING32 string[MAP_DATACHAR_NUM]; +}MAP_ImageData; + +typedef enum +{ + MAP_KINDWALKABLE, /* 擌 F 1 入 */ + + MAP_KINDNUM, +}MAP_kind; + + +INLINE int MAP_getfloorIndex( int floorid ); +int MAP_getfloorX( int floorid ); +int MAP_getfloorY( int floorid ); + +BOOL MAP_initReadMap( char* maptilefile , char* mapdir ); +BOOL MAP_initMapArray( int num ); +void MAP_endMapArray( void ); + +char* MAP_getdataFromRECT( int floor, RECT* seekr, RECT* realr ); +char *MAP_getChecksumFromRECT( int floor, RECT* seekr, RECT* realr, + int *tilesum, int *objsum, int *eventsum ); + +BOOL MAP_checkCoordinates( int mapid, int x, int y ); + +BOOL MAP_setTileAndObjData( int ff ,int fx, int fy, int tile, int obj); +BOOL MAP_getTileAndObjData( int ff ,int fx, int fy, int* tile, int* obj); +void MAP_sendAroundMapdata( int fl, int x, int y); +int MAP_getImageInt( int imagenumber, int element ); +BOOL MAP_setImageInt( int imagenumber, int element, int value ); +BOOL IsValidImagenumber( int imagenumber ); + +char* MAP_getfloorShowstring( int floorid ); +BOOL MAP_makeVariousMap(char* atile, char* aobj, int floor, int startx, int starty, int xsiz, int ysiz, MAP_kind kind ); +BOOL MAP_makeWalkableMap( char* data, int floor, int startx, int starty,int xsiz, int ysiz ); +BOOL MAP_IsThereSpecificFloorid( int floorid ); +BOOL MAP_IsValidCoordinate( int floorid, int x, int y ); +int MAP_attackSpecificPoint( int floor, int x, int y, int damage , + int charaindex ); + +BOOL MAP_addNewObj( int floor, int x, int y, int objindex ); +BOOL MAP_removeObj( int floor, int x, int y, int objindex ); +#define MAP_getTopObj( fl, x, y) _MAP_getTopObj( __FILE__, __LINE__, fl, x, y) +MAP_Objlink* _MAP_getTopObj( char *file, int line, int floor, int x, int y ); +#define MAP_objmove( objindex, of, ox, oy, nfl, nx, ny) _MAP_objmove( __FILE__, __LINE__, objindex, of, ox, oy, nfl, nx, ny) +BOOL _MAP_objmove( char *file, int line, int objindex, int ofloor, int ox, int oy, int nfloor, + int nx, int ny ); +char *MAP_getFloorName( int floor); +BOOL MAP_setObjData( int ff ,int fx, int fy, int obj, int objhp ); + +#ifdef _STATUS_WATERWORD //水世界状态 +int MAP_getMapFloorType( int floor); +#endif + +#ifdef _MAP_NOEXIT +unsigned int MAP_getExFloor_XY( int floor , int *map_type); +BOOL CHECKFLOORID( int id); +#endif + +#endif +/*__MAP_H__*/ diff --git a/gmsv/include/readnpc.h b/gmsv/include/readnpc.h new file mode 100644 index 0000000..b3e26d9 --- /dev/null +++ b/gmsv/include/readnpc.h @@ -0,0 +1,6 @@ +#ifndef __READNPC_H__ +#define __READNPC_H__ +BOOL NPC_readNPCSettingFiles( char* topdirectory ,int templatesize,int createsize); + +#endif + /*__READNPC_H__*/ diff --git a/gmsv/include/saacproto_cli.h b/gmsv/include/saacproto_cli.h new file mode 100644 index 0000000..33777b0 --- /dev/null +++ b/gmsv/include/saacproto_cli.h @@ -0,0 +1,383 @@ +/* output by ../../bin/lsgen.perl 0.41 ( 1998 May) + * made Mon Oct 9 10:21:40 2000 + * user ttom + * host proxy1 + * file /home/ttom/gmsv2/src/gmsv/include/saacproto_cli.h + * util ./saacproto_util.c , include/saacproto_util.h + * src /home/ttom/gmsv2/src/gmsv/../../doc/saacproto.html + */ +#ifndef _SAACPROTOCLI_H_ +#define _SAACPROTOCLI_H_ +#include "version.h" +#include "saacproto_util.h" + +#ifdef MAXLSRPCARGS +#if ( MAXLSRPCARGS <= ( 7 + 1 ) ) +#undef MAXLSRPCARGS +#define MAXLSRPCARGS ( 7 + 1 ) +#endif +#else +#define MAXLSRPCARGS ( 7 + 1 ) +#endif + +#ifdef _ALLDOMAN // (不可开) Syu ADD 排行榜NPC +void saacproto_UpdataStele_send( int fd , char *cdkey , char *name , char *title , int level , int trns , int time , int floor) ; +void saacproto_UpdataStele_recv( int fd , char *token) ; +void saacproto_S_UpdataStele_recv( int i , char *ocdkey , char *oname , char *ncdkey , + char *nname , char *title , int level , int trns , int floor ); +#endif + +void saacproto_ACGmsvDownRequest_recv( int fd,int min ) ; /* ../../doc/saacproto.html line 80 */ +void saacproto_ACServerLogin_send( int fd,char* servername,char* serverpas ) ; /* ../../doc/saacproto.html line 90 */ +void saacproto_ACServerLogin_recv( int fd,char* result,char* data ) ; /* ../../doc/saacproto.html line 101 */ +void saacproto_ACServerLogout_send( int fd ) ; /* ../../doc/saacproto.html line 114 */ + +#ifdef _PKSEVER_VER +void saacproto_ACCharList_send( int fd,char* id,char* pas,int mesgid, int star); +#else +void saacproto_ACCharList_send( int fd,char* id,char* pas,int mesgid ) ; /* ../../doc/saacproto.html line 123 */ +#endif + +void saacproto_ACCharList_recv( int fd,char* result,char* output,int id ) ; /* ../../doc/saacproto.html line 135 */ +void saacproto_ACCharLoad_send( int fd,char* id,char* pas,char* charname,int lock,char* opt,int mesgid ) ; /* ../../doc/saacproto.html line 158 */ +void saacproto_ACCharLoad_recv( int fd,char* result,char* data,int id,int saveindex ) ; /* ../../doc/saacproto.html line 185 */ +#ifdef _NEWSAVE +void saacproto_ACCharSave_send( int fd,char* id,char* charname,char* opt,char* charinfo,int unlock,int mesgid,int saveindex ) ; /* ../../doc/saacproto.html line 201 */ +#else +void saacproto_ACCharSave_send( int fd,char* id,char* charname,char* opt,char* charinfo,int unlock,int mesgid ) ; /* ../../doc/saacproto.html line 201 */ +#endif +void saacproto_ACCharSave_recv( int fd,char* result,char* data,int id ) ; /* ../../doc/saacproto.html line 224 */ +void saacproto_ACCharDelete_send( int fd,char* id,char* passwd,char* charname,char* option,int mesgid ) ; /* ../../doc/saacproto.html line 241 */ +void saacproto_ACCharDelete_recv( int fd,char* result,char* data,int id ) ; /* ../../doc/saacproto.html line 266 */ +void saacproto_ACLock_send( int fd,char* id,int lock,int mesgid ) ; /* ../../doc/saacproto.html line 281 */ +void saacproto_ACLock_recv( int fd,char* result,char* data,int id ) ; /* ../../doc/saacproto.html line 300 */ +void saacproto_ACUCheck_send( int fd,char* mem_id,int status ) ; /* ../../doc/saacproto.html line 314 */ +void saacproto_ACUCheck_recv( int fd,char* mem_id ) ; /* ../../doc/saacproto.html line 328 */ +void saacproto_DBUpdateEntryString_send( int fd,char* table,char* key,char* value,int msgid,int msgid2 ) ; /* ../../doc/saacproto.html line 339 */ +void saacproto_DBUpdateEntryString_recv( int fd,char* result,char* table,char* key,int msgid,int msgid2 ) ; /* ../../doc/saacproto.html line 354 */ +void saacproto_DBDeleteEntryString_send( int fd,char* table,char* key,int msgid,int msgid2 ) ; /* ../../doc/saacproto.html line 367 */ +void saacproto_DBDeleteEntryString_recv( int fd,char* result,char* table,char* key,int msgid,int msgid2 ) ; /* ../../doc/saacproto.html line 379 */ +void saacproto_DBGetEntryString_send( int fd,char* table,char* key,int msgid,int msgid2 ) ; /* ../../doc/saacproto.html line 394 */ +void saacproto_DBGetEntryString_recv( int fd,char* result,char* value,char* table,char* key,int msgid,int msgid2 ) ; /* ../../doc/saacproto.html line 406 */ +void saacproto_DBUpdateEntryInt_send( int fd,char* table,char* key,int value,char* info,int msgid,int msgid2 ) ; /* ../../doc/saacproto.html line 423 */ +void saacproto_DBUpdateEntryInt_recv( int fd,char* result,char* table,char* key,int msgid,int msgid2 ) ; /* ../../doc/saacproto.html line 445 */ +void saacproto_DBGetEntryRank_send( int fd,char* table,char* key,int msgid,int msgid2 ) ; /* ../../doc/saacproto.html line 459 */ +void saacproto_DBGetEntryRank_recv( int fd,char* result,int rank,int count,char* table,char* key,int msgid,int msgid2 ) ; /* ../../doc/saacproto.html line 473 */ +void saacproto_DBDeleteEntryInt_send( int fd,char* table,char* key,int msgid,int msgid2 ) ; /* ../../doc/saacproto.html line 492 */ +void saacproto_DBDeleteEntryInt_recv( int fd,char* result,char* table,char* key,int msgid,int msgid2 ) ; /* ../../doc/saacproto.html line 504 */ +void saacproto_DBGetEntryInt_send( int fd,char* table,char* key,int msgid,int msgid2 ) ; /* ../../doc/saacproto.html line 518 */ +void saacproto_DBGetEntryInt_recv( int fd,char* result,int value,char* table,char* key,int msgid,int msgid2 ) ; /* ../../doc/saacproto.html line 530 */ +void saacproto_DBGetEntryByRank_send( int fd,char* table,int rank_start,int rank_end,int msgid,int msgid2 ) ; /* ../../doc/saacproto.html line 547 */ +void saacproto_DBGetEntryByRank_recv( int fd,char* result,char* list,char* table,int msgid,int msgid2 ) ; /* ../../doc/saacproto.html line 562 */ +void saacproto_DBGetEntryByCount_send( int fd,char* table,int count_start,int num,int msgid,int msgid2 ) ; /* ../../doc/saacproto.html line 581 */ +void saacproto_DBGetEntryByCount_recv( int fd,char* result,char* list,char* table,int count_start,int msgid,int msgid2 ) ; /* ../../doc/saacproto.html line 593 */ +void saacproto_Broadcast_send( int fd,char* id,char* charname,char* message,int flag ) ; /* ../../doc/saacproto.html line 608 */ +void saacproto_Broadcast_recv( int fd,char* id,char* charname,char* message ) ; /* ../../doc/saacproto.html line 621 */ +void saacproto_Message_send( int fd,char* id_from,char* charname_from,char* id_to,char* charname_to,char* message,int option ) ; /* ../../doc/saacproto.html line 634 */ +void saacproto_Message_recv( int fd,char* id_from,char* charname_from,char* id_to,char* charname_to,char* message,int option,int mesgid ) ; /* ../../doc/saacproto.html line 652 */ +void saacproto_MessageAck_send( int fd,char* id,char* charname,char* result,int mesgid ) ; /* ../../doc/saacproto.html line 671 */ +void saacproto_MessageFlush_send( int fd,char* id,char* charname ) ; /* ../../doc/saacproto.html line 690 */ +int saacproto_InitClient( int(*)(int,char*,int) , int bufsiz , int fd); +void saacproto_SetClientLogFiles( char *read , char *write); +void saacproto_CleanupClient(void); +int saacproto_ClientDispatchMessage(int fd ,char*line); + +// 成立家族 +#ifdef _PERSONAL_FAME +void saacproto_ACAddFM_send(int fd, char *fmname, char *fmleadername, + char *fmleaderid, int fmleaderlv, char *petname, char *petarrt, + char *fmrule, int fmsprite, int fmleadergrano, int fame, int charfdid); +#else +void saacproto_ACAddFM_send(int fd, char *fmname, char *fmleadername, + char *fmleaderid, int fmleaderlv, char *petname, char *petarrt, + char *fmrule, int fmsprite, int fmleadergrano, int charfdid); +#endif +void saacproto_ACAddFM_recv(int fd, char *result, int fmindex, int index, + int charfdid); +// 加入家族 +// #ifdef _PERSONAL_FAME // Arminius: 家族个人声望 +void saacproto_ACJoinFM_send(int fd, char *fmname, int fmindex, char *charname, + char *charid, int charlv, int index, int fame, int charfdid); +// #else +// void saacproto_ACJoinFM_send(int fd, char *fmname, int fmindex, char *charname, +// char *charid, int charlv, int index, int charfdid); +// #endif +void saacproto_ACJoinFM_recv(int fd, char *result, int recv, int charfdid); +// 退出家族 +void saacproto_ACLeaveFM_send(int fd, char *fmname, int fmindex, char *charname, + char *charid, int index, int charfdid); +void saacproto_ACLeaveFM_recv(int fd, char *result, int resultflag, int charfdid); +// 解散家族 +void saacproto_ACDelFM_send(int fd, char *fmname, int fmindex, int index, + char *charname, char *charid, int charfdid); + +void saacproto_ACDelFM_recv(int fd, char *result, int charfdid); +// 列出家族列表 +void saacproto_ACShowFMList_send(int fd); +void saacproto_ACShowFMList_recv(int fd, char *result, int num, char *data); +// 列出成员列表 +void saacproto_ACShowMemberList_send(int fd, int index); +void saacproto_ACShowMemberList_recv(int fd, char *result, int index, int num, + int fmacceptflag, int fmjoinnum, char *data); +// 列出家族详细资料 +void saacproto_ACFMDetail_send(int fd, char *fmname, int fmindex, + int index, int charfdid); +void saacproto_ACFMDetail_recv(int fd, char *result, char *data, int charfdid); +//族长审核成员加入家族、修改家族成员职位 +#ifdef _FMVER21 +void saacproto_ACMemberJoinFM_send(int fd, char *fmname, int fmindex, char *charname, + int charindex, int index, int result, int meindex, int charfdid); +#else +void saacproto_ACMemberJoinFM_send(int fd, char *fmname, int fmindex, char *charname, + int charindex, int index, int result, int charfdid); +#endif +void saacproto_ACMemberJoinFM_recv(int fd, char *result, char *data, int charfdid); +//族长审核成员离开家族 +#ifdef _FMVER21 +void saacproto_ACMemberLeaveFM_send(int fd, char *fmname, int fmindex, char *charname, + int charindex, int index, int meindex, int charfdid); +#else +void saacproto_ACMemberLeaveFM_send(int fd, char *fmname, int fmindex, char *charname, + int charindex, int index, int charfdid); +#endif +void saacproto_ACMemberLeaveFM_recv(int fd, char *result, char *data, int charfdid); +//玩家 Login +#ifdef _FM_MODIFY +void saacproto_ACFMCharLogin_send(int fd, char *fmname, int fmindex, char *charname, + char *charid, int charlv, int eventflag, int charfdid,int gsnum); +#else + #ifdef _FMVER21 + void saacproto_ACFMCharLogin_send(int fd, char *fmname, int fmindex, char *charname, + char *charid, int result, int eventflag, int charfdid); + #else + void saacproto_ACFMCharLogin_send(int fd, char *fmname, int fmindex, char *charname, + char *charid, int result, int charfdid); + #endif +#endif +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 +void saacproto_ACFMCharLogin_recv(int fd, char *result, int index, int floor, + int fmdp, int joinflag, int fmsetupflag, int flag, int charindex, + int charfame, int charfdid +#ifdef _NEW_MANOR_LAW + ,int momentum +#endif + ); +#else +void saacproto_ACFMCharLogin_recv(int fd, char *result, int index, int floor, + int fmdp, int joinflag, int fmsetupflag, int flag, int charindex, + int charfdid); +#endif +// 玩家 Logout +void saacproto_ACFMCharLogout_send(int fd, char *fmname, int fmindex, char *charname, + char *charid, int result, int index, int charfdid); +void saacproto_ACFMCharLogout_recv(int fd, char *result, int charfdid); +// 列出家族留言板 +void saacproto_ACFMReadMemo_send(int fd, int index); +void saacproto_ACFMReadMemo_recv(int fd, char *result, int index, int num, + int dataindex, char *data); +// 写入家族留言板 +void saacproto_ACFMWriteMemo_send(int fd, char *fmname, int fmindex, + char *data, int index); +void saacproto_ACFMWriteMemo_recv(int fd, char *result, int index); +// 列出家族据点 +void saacproto_ACFMPointList_send(int fd); +void saacproto_ACFMPointList_recv(int fd, char *result, char *data); + + + +#ifdef _CK_ONLINE_PLAYER_COUNT // WON ADD 计算线上人数 +void saacproto_GS_PLAYER_COUNT_SEND( int acfd, int num ); +#endif + +// 申请家族据点 +void saacproto_ACSetFMPoint_send(int fd, char* fmname, int fmindex, int index, + int fmpointindex, int fl, int x, int y, int charfdid); +void saacproto_ACSetFMPoint_recv(int fd, char *result, int r, int charfdid); +// 设定家族据点 +void saacproto_ACFixFMPoint_send(int fd, char *winfmname, int winfmindex, + int winindex, char *losefmname, int losefmindex, int loseindex, + int village); +void saacproto_ACFixFMPoint_recv(int fd, char *result, int r); +// 族长对星系家族成员广播 +// kindflag 1:族长广播 2:家族被系统删除 3:系统通知讯息 +void saacproto_ACFMAnnounce_send(int fd, char *fmname, int fmindex, int index, + char *data, int color); +void saacproto_ACFMAnnounce_recv(int fd, char *result, char *fmname, + int fmindex, int index, int kindflag, char *data, int color); +// 列出 TOP 50 家族列表 +void saacproto_ACShowTopFMList_send(int fd, int kindflag); +void saacproto_ACShowTopFMList_recv(int fd, char *result, int kindflag, + int num, char *data); +// 修正家族资料(是否招收成员) +// flag 1:acceptjoinflag 2:dpchanged 3:change fmpet 4:change fminfo 5:predel FM Time +void saacproto_ACFixFMData_send(int fd, char *fmname, int fmindex, int index, + int kindflag,char *data1,char *data2,int charindex, int charfdid); + +#ifdef _FAMILYBANKSTONELOG +void saacproto_ACgetFMBankgold_send(int fd, char *fmname, int fmindex, int index, + int charindex, int charfdid); +void saacproto_ACgetFMBankgold_recv(int fd,int charfdid,int r); +#endif + +void saacproto_ACFixFMData_recv(int fd, char *result, int kindflag, char *data1, + char *data2, int charfdid); + +// PK後更新家族声望 +void saacproto_ACFixFMPK_send(int fd, char *winfmname, int winfmindex, + int winindex, char *losefmname, int losefmindex, int loseindex); +void saacproto_ACFixFMPK_recv(int fd, char *result, int data, int winindex, + int loseindex); +// 取得家族资料 +// kindflag 1:家族银行 +void saacproto_ACGetFMData_send(int fd, char *fmname, int fmindex, int index, + int kindflag, int charfdid); +void saacproto_ACGetFMData_recv(int fd, char *result, int kindflag, int data, + int charfdid); +// GM修正家族资料 +void saacproto_ACGMFixFMData_send(int fd, int index, char *charid, char *cmd, + char *data, int charfdid); +void saacproto_ACGMFixFMData_recv(int fd, char *result, char *fmindex, int charfdid); +// 删除家族後清除对战排程 +void saacproto_ACFMClearPK_recv(int fd, char *result, char *fmname, int fmindex, + int index); + +// Arminius 7.26 manor pk acknowledge +void saacproto_ACManorPKAck_send(int fd, char *data); +void saacproto_ACManorPKAck_recv(int fd, char *data); + +void saacproto_ACreLoadFmData_send( int fd, int type, int data); + +#ifdef _ACFMPK_LIST +void saacproto_ACLoadFmPk_recv(int fd, char *data); +void saacproto_ACLoadFmPk_send(int fd, int fmpks_pos); +void saacproto_ACSendFmPk_recv( int fd, int toindex, int flg); +void saacproto_ACSendFmPk_send(int fd, int toindex, int PkFlg, int fmpks_pos, char *msg); +#endif + +#ifdef _RECAL_ASK_PLAYER // WON 要求人物资料 +void saacproto_Recal_Player_send(int acfd, char *uid, int userfdid, int GmCliId, char *id, int char_num, int date, int backup_flag); +void saacproto_ACRecalPlayer_recv(char *uid, int userfdid, int GmCliId, char *id, int char_num, int date, char *char_data); +void saacproto_ACRecalBackupPlayer_recv(char *uid, int userfdid, int GmCliId, char *id, int char_num, int date, char *char_data); +void saacproto_ACRecalAllBackupOK_recv(char *uid, int userfdid, int GmCliId, char *id, int char_num, int date, char *char_data); +void saacproto_ACRecalBackupDate_recv(char *uid, int userfdid, int GmCliId, char *id, int char_num, int date, char *char_data); +void saacproto_Recal_Backup_send(int acfd, char *uid, int userfdid, int GmCliId, char *id, int char_num, int date, char *char_data, int backup_flag); +#endif // end RECAL_ASK_PLAYER + + +void saacproto_ACAuctionSold_send(int fd, char *data); +void saacproto_ACAuctionSold_recv(int fd, char *data); + +#ifdef _WAEI_KICK //跨星球踢人 +void saacproto_ACKick_send( int fd, char* kickid,int kickfd, int flg); +void saacproto_ACKick_recv(int fd , int act, char* data ,int retfd); +#endif + +#ifdef _NEW_PLAYERGOLD +void saacproto_LoadNEWPlayer_recv(int fd , int charaindex, char *data); +void saacproto_LoadNEWPlayer_send( int fd, int charaindex, char *filename); +#endif + +#ifdef _PAUCTION_MAN +void saacproto_ACItemAuction_recv( int fd, char *ITEMNAME, char *data, int itemID, int ret, int flg); +void saacproto_ACItemAuction_send( int fd, char *ITEMNAME, char *data, int itemID, int ret, int flg); +//ACAddItemAuction_send( int fd, int itemID, char *ITEMNAME, char* SECRETNAME, char *EFFECTSTRING); +#endif + +#ifdef _NEW_PLAYERGOLD +enum{ + NEW_ERR=0, + NEW_DELOK, + NEW_DELERR, + NEW_ADDOK=11, + NEW_ADDERR, + NEW_LISTFULL, +}; +void saacproto_ACNEWPlayerList_recv( int fd, char *CdKey, char *UserName, int charaindex, int RunType); +void saacproto_ACNEWPlayerList_send( int fd, char *CdKey, char *UserName, int charaindex, int RunType); +#endif + +#ifdef _DEATH_CONTEND +void saacproto_LoadPkTeamListData_recv(int fd , char* result, char* data, int ti ); +void saacproto_LoadPkTeamListData_send(int fd , int start, int count ); + +void saacproto_PkListUpDate_send( int fd , char *mycdkey, char *tocdkey, + int mynum, int tonum, int winer, int flg ); + +void saacproto_PKLISTCHARTS_recv( int fd, char *data, int type, int flg); +void saacproto_PKLISTCHARTS_send( int fd, int type, int flg ); +#endif + + + +#ifdef _CHAR_POOLITEM +void saacproto_ACCharInsertPoolItem_send( int acfd, int charaindex, int clifdid, char *CdKey, char *Pooldataarg, int TYPE); + +void saacproto_ACCharSavePoolItem_recv(int fd ,char* result, char* data,int retfd); +void saacproto_ACCharSavePoolItem_send( int acfd, int charaindex, int clifdid, char *CdKey, char *Pooldataarg); + +void saacproto_ACCharGetPoolItem_recv(int fd ,char* result, char* data,int retfd, int meindex); +void saacproto_ACCharGetPoolItem_send( int acfd, int meindex, int charaindex, int clifdid, char * CdKey); +#endif + +#ifdef _CHAR_POOLPET +void saacproto_ACCharInsertPoolPet_send( int acfd, int charaindex, int clifdid, char *CdKey, char *Pooldataarg, int TYPE); + +void saacproto_ACCharSavePoolPet_recv(int fd ,char* result, char* data,int retfd); +void saacproto_ACCharSavePoolPet_send( int acfd, int charaindex, int clifdid, char *CdKey, char *Pooldataarg); + +void saacproto_ACCharGetPoolPet_recv(int fd ,char* result, char* data,int retfd, int meindex); +void saacproto_ACCharGetPoolPet_send( int acfd, int meindex, int charaindex, int clifdid, char * CdKey); +#endif + + + +#ifdef _DEATH_FAMILY_LOGIN_CHECK // WON ADD 家族战登入检查 +void saacproto_new_ACFM_Login_send( int acfd, int charaindex, char *char_id, char *char_name ); +void saacproto_ACSendMember_recv(int fd, char *result, char *data, int charindex ); +#endif + +#ifdef _DEATH_FAMILY_GM_COMMAND // WON ADD 家族战GM指令 +void saacproto_ReloadFamily_send( int acfd, int charaindex ); +void saacproto_ACRELOADFMOK_recv( int fd, int charindex ); +void saacproto_ACShowMemberList_2_send( int fd, int charaindex, int fm1, int fm2, int time, int id ); +void saacproto_ACSHOWMEMBERLIST2_recv( int fd, int charaindex, int fm1, char *fm1_id, int fm2, char *fm2_id, int time, int id ); +#endif + +#ifdef _DEATH_FAMILY_STRUCT // WON ADD 家族战存放胜负资料 +void saacproto_Init_FM_PK_STRUC_send( int fd ); +void saacproto_FM_PK_STRUCT_send( int fd, char *msg ); +void saacproto_ACSendFmPkStruct_recv( int fd, char *data ); +#endif + +#ifdef _UNIVERSE_CHATROOM +void saacproto_ACUniChatroom_recv( int acfd, int charaindex, int clifdid, char *result, + char *CdKey, char *data); +void saacproto_ACUniChatroom_send( int acfd, int charaindex, int clifdid, char *CdKey, char *data); +#endif + + +#ifdef _ANGEL_SUMMON +void saacproto_ACMissionTable_recv( int fd, int num, int type, char *data, char* angelinfo); +void saacproto_ACMissionTable_send( int fd, int num, int type, char *data, char* angelinfo); +#endif + +#ifdef _TEACHER_SYSTEM +// RETURN_FUNCTION -> R_F_XXXXXXX +enum{ + R_F_TEACHER_SYSTEM, + R_F_END +}; +void saacproto_ACCheckCharacterOnLine_recv( int acfd, int charaindex, int iOnline,char *data,int flag); +void saacproto_ACCheckCharacterOnLine_send( int acfd, int charaindex, char *id, char *name, int flag); +#endif + +#ifdef _RACEMAN +void saacproto_ACRaceRecordandSort_recv(int fd,int charaindex,int racetype,char *data); +void saacproto_ACRaceRecordandSort_send(int fd,int charaindex,char *code ,char *id,char *name,int racetype,int catchcnt,int ranknum ); +void saacproto_ACRaceRecordfmdo_send(int fd,int charaindex, int fmid , int bbi , char *unicode, char *petname ); +#endif + +#endif +/* end of the generated client header code */ + + diff --git a/gmsv/include/saacproto_util.h b/gmsv/include/saacproto_util.h new file mode 100644 index 0000000..e65a2e2 --- /dev/null +++ b/gmsv/include/saacproto_util.h @@ -0,0 +1,114 @@ +#ifndef _SAACPROTOUTIL_H_ +#define _SAACPROTOUTIL_H_ +#include +#include +#ifndef WIN32 +#include +#include +#endif +#define saacproto__NOENCRYPT +#define saacproto__NODEBUG +struct saacproto_ { + int (*write_func)(int,char*,int) ; /* write function */ + size_t workbufsize; /* size of work area */ + char *work,*arraywork,*escapework,*val_str,*ret_work; /* work areas which have same size */ + char *cryptwork,*jencodecopy,*jencodeout,*compresswork; /* these work has bigger size (3times)*/ + char** token_list; /* token list */ + unsigned long message_id; /*= 1, */ /* for generating message IDs */ + +}; +#ifdef _SAACPROTOUTIL_C_ +struct saacproto_ saacproto = { + NULL, + 0, + NULL,NULL,NULL,NULL,NULL, + NULL,NULL,NULL,NULL, + NULL, + 1, +}; +char **saacproto_stringwrapper; +char saacproto_readlogfilename[1024]; +char saacproto_writelogfilename[1024]; +#else +extern char **saacproto_stringwrapper; +extern struct saacproto_ saacproto; +extern char saacproto_readlogfilename[1024]; +extern char saacproto_writelogfilename[1024]; +#endif +char* saacproto_escapeString( char*a ); +char* saacproto_descapeString( char*a ); +void saacproto_splitString( char *src ); +void saacproto_strcpysafe( char *dest, char *src, int len ); +void saacproto_strcatsafe( char *dest , char *src , int maxlen ); +char*saacproto_mkstr_int( int i ); +char*saacproto_mkstr_u_int( unsigned int i ); +char*saacproto_mkstr_long( long l ); +char*saacproto_mkstr_u_long( unsigned long l ); +char*saacproto_mkstr_short( short s ); +char*saacproto_mkstr_u_short( short s ); +char*saacproto_mkstr_char( char c ); +char*saacproto_mkstr_u_char( char c); +char*saacproto_mkstr_string( char*a ); +char*saacproto_mkstr_float( float f ); +char*saacproto_mkstr_double( double d ); +char*saacproto_mkstr_int_array( int size , int *array ); +char*saacproto_mkstr_u_int_array( int size , int *array ); +char*saacproto_mkstr_short_array( int size , short *array ); +char*saacproto_mkstr_u_short_array(int size , short *array ); +char *saacproto_mkstr_char_array( int size , char *array ); +char *saacproto_mkstr_u_char_array( int size , unsigned char *array ); +char *saacproto_mkstr_float_array( int size , float *array ); +char *saacproto_mkstr_double_array( int size , double *array ); +int saacproto_demkstr_int( char*a ); +unsigned int saacproto_demkstr_u_int( char*a ); +long saacproto_demkstr_long( char*a ); +unsigned long saacproto_demkstr_u_long(char*a ); +short saacproto_demkstr_short( char*a ); +unsigned short saacproto_demkstr_u_short( char*a ); +char saacproto_demkstr_char( char*a ); +unsigned char saacproto_demkstr_u_char( char*a ); +float saacproto_demkstr_float( char*a ); +double saacproto_demkstr_double(char*a ); +char* saacproto_demkstr_string( char*a); +int *saacproto_demkstr_int_array( char**tk ,int *buf ,int start , int size ); +int *saacproto_demkstr_u_int_array( char **tk , int *buf , int start , int size ); +unsigned int *saacproto_demkstr_long_array( + char **tk , unsigned int *buf , int start , int size ); +unsigned long *saacproto_demkstr_u_long_array( + char **tk , unsigned long *buf , int start , int size ); +short *saacproto_demkstr_short_array( char **tk , short *buf , int start , int size ); +unsigned short*saacproto_demkstr_u_short_array( + char **tk , unsigned short *buf , int start , int size ); +char *saacproto_demkstr_char_array( char **tk , char *buf , int start , int size ); +unsigned char *saacproto_demkstr_u_char_array( + char **tk , unsigned char*buf , int start , int size ); +float *saacproto_demkstr_float_array( char **tk , float *buf , int start , int size ); +double *saacproto_demkstr_u_double_array( char **tk , double *buf , int start , int size ); +char *saacproto_wrapStringAddr( char *copy , int maxcopylen , char*src ); + +void saacproto_GetMessageInfo( int *id , char *funcname , int len,char **tk ); +int saacproto_ClientRead(void); +void saacproto_consumeLine(char *buf , int ofs ); +void saacproto_copyLine( char*src , char *out , int maxoutlen ); +void saacproto_Send( int fd , char *msg ); +int saacproto_AllocateCommonWork(int bufsiz); +int saacproto_StringRest(); + +// WON ADD +unsigned long saacproto_GetNewMessageID(void); + + +void saacproto_CreateHeader(char*out, char *fname ); +void saacproto_CreateHeaderID( char *out,unsigned long msgid , char *fname ); +int saacproto_default_write_wrap( int fd , char *buf , int size ); +void saacproto_bzero( char *b , int siz ); +void saacproto_bcopy(char*s , char *d , int siz ); +char *saacproto_Ltoa( long v ); +char *saacproto_Ultoa( unsigned long v ); +void saacproto_DebugSend( int fd , char *msg ); +/* Modified by ringo to fasten int type transfer */ +char *saacproto_cnv10to62( int a, char *out, int outlen ); +int saacproto_a62toi( char *a ); +extern int JENCODE_KEY; +#endif + diff --git a/gmsv/include/skill.h b/gmsv/include/skill.h new file mode 100644 index 0000000..9d41159 --- /dev/null +++ b/gmsv/include/skill.h @@ -0,0 +1,121 @@ +#ifndef __SKILL_H__ +#define __SKILL_H__ + +#include "common.h" +#include "util.h" + +typedef struct tagSKILL_intDataSetting +{ + char *dumpskill; +}SKILL_intDataSetting; + +typedef struct tagSKILL_charDataSetting +{ + char *dumpskill; +}SKILL_charDataSetting; + + +typedef enum +{ +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + SKILL_1, + SKILL_2, + SKILL_3, + SKILL_4, + SKILL_5, + SKILL_6, + SKILL_7, + SKILL_8, + SKILL_9, + SKILL_10, + SKILL_11, + SKILL_12, + SKILL_13, + SKILL_14, + SKILL_15, + SKILL_16, + SKILL_NUM +#else + SKILL_FIRE, + SKILL_MAGICIAN, + SKILL_PRIEST, + SKILL_ALOTOFTHINGS, + SKILL_AVOIDRATEUP, + SKILL_DETERMINEITEM, + SKILL_DETERMINEOTHERS, + SKILL_FIRECUT, + SKILL_THUNDERCUT, + SKILL_ICECUT, + SKILL_MERCHANT, + SKILL_HEALER, + SKILL_FIST, + SKILL_SWORD, + SKILL_AXE, + SKILL_SPEAR, + SKILL_BOW, + SKILL_CANE, + SKILL_LARGEVOICE, + SKILL_NUM +#endif +}SKILL_ID; + + +typedef struct tagSkillTable +{ + const int maxlevel; + void* effectfunc; +}SKILL_table; + + +typedef enum +{ + SKILL_LEVEL, // 技能等级 + SKILL_IDENTITY, // 技能编号 + SKILL_DATAINTNUM, +}SKILL_DATAINT; + +typedef enum +{ + SKILL_DATACHARNUM, +}SKILL_DATACHAR; + + +typedef struct tagSkill +{ + int data[SKILL_DATAINTNUM]; + STRING32 string[SKILL_DATACHARNUM]; +}Skill; + +char* SKILL_makeStringFromSkillData( Skill* sk ); +BOOL SKILL_makeSkillFromStringToArg( char* src, Skill* sk ); + +int SKILL_getInt( Skill* skill, int element); +int SKILL_setInt( Skill* skill, int element, int new); + +#ifdef _CHAR_PROFESSION // WON ADD 人物职业 +char* SKILL_makeSkillStatusString( Skill* skill, int charaindex, int skill_num ); +#else +char* SKILL_makeSkillStatusString( Skill* skill ); +#endif + +char* SKILL_makeSkillFalseString( void ); + +BOOL SKILL_makeSkillData( Skill* sk ,int skid, int lev ); + +int SKILL_levelup( Skill* sk ); +int SKILL_getLevelFromSkillID( int charaindex, SKILL_ID id ); +BOOL SKILL_getUpableSkillID( int charaindex,char* buf, int buflen ); +void SKILL_skillEffect( int charaindex ); + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 +int PROFESSION_MAGIC_COST_MP( int charaindex, int skill_num ); +INLINE int PROFESSION_CHANGE_SKILL_LEVEL_M( int skill_level ); +INLINE int PROFESSION_CHANGE_SKILL_LEVEL_A( int skill_level ); +INLINE int SKILL_getRealInt( Skill* skill, int element); +#endif + + +#endif +/*__SKILL_H__*/ + + diff --git a/gmsv/include/sndcnf.h b/gmsv/include/sndcnf.h new file mode 100644 index 0000000..c9d462d --- /dev/null +++ b/gmsv/include/sndcnf.h @@ -0,0 +1,147 @@ +// 寞}白央奶伙 }示伉亘□丞}疋永民 祥签匏 }伙□皿白仿弘 棕雁祥 }穴永皿巨犯奴正羁匹苇月戊丢件玄 +// SA Server匹反银迕仄化中引六氏[ +// SE 寞及辅寰迕卞升丹冗[ + +SNDCONFIG sndconfig[] = +{ + // 皿伊奶乩□ + { 1, "data\\se\\sap_01.wav", 85, 0, 0 /*, "a攻击音(赤手空拳)"*/ }, + { 2, "data\\se\\sap_02.wav", 85, 0, 0 /*, "a攻击音(棍棒)"*/ }, + { 3, "data\\se\\sap_03.wav", 85, 0, 0 /*, "a攻击音(斧)"*/ }, + { 4, "data\\se\\sap_04.wav", 100, 0, 0 /*, "a丢东西"*/ }, + { 5, "data\\se\\sap_05.wav", 85, 0, 0 /*, "a防御声"*/ }, + { 6, "data\\se\\sap_06.wav", 60, 0, 0 /*, "a死亡"*/ }, + { 7, "data\\se\\sap_07.wav", 123, 0, 0 /*, "a传送空间"*/ }, + { 8, "data\\se\\sap_08.wav", 80, 0, 0 /*, "回旋标"*/ }, + { 9, "data\\se\\sap_09.wav", 80, 0, 0 /*, "a攻击声(枪)"*/ }, + { 10, "data\\se\\sap_10.wav", 80, 0, 0 /*, "a攻击声(弓矢)"*/ }, +//x { 11, "data\\se\\sap_11.wav", 105, 7, 0 /*, "飞行声"*/ }, + { 11, "data\\se\\sap_11.wav", 105, 0, 0 /*, "飞行声"*/ }, + { 12, "data\\se\\sap_14.wav", 100, 0, 0 /*, "刺音"*/ }, + { 13, "data\\se\\sap_12.wav", 90, 0, 0 /*, "捕获的声音"*/ }, + { 14, "data\\se\\sap_13.wav", 105, 0, 0 /*, "捕获的声音2"*/ }, + + // 乒件旦正□ + { 51, "data\\se\\sae_01.wav", 123, 0, 0 /*, ""*/ }, + { 52, "data\\se\\sae_02.wav", 123, 0, 0 /*, ""*/ }, + { 53, "data\\se\\sae_03.wav", 123, 0, 0 /*, ""*/ }, + { 54, "data\\se\\sae_04.wav", 123, 0, 0 /*, ""*/ }, + { 55, "data\\se\\sae_05.wav", 123, 0, 0 /*, ""*/ }, + { 56, "data\\se\\sae_06.wav", 105, 0, 0 /*, "邦洛洛克斯"*/ }, + { 57, "data\\se\\sae_07.wav", 80, 0, 0 /*, "邦洛洛克斯(红色)"*/ }, + { 58, "data\\se\\sae_08.wav", 123, 0, 0 /*, ""*/ }, + { 59, "data\\se\\sae_09.wav", 123, 0, 0 /*, ""*/ }, + { 60, "data\\se\\sae_10.wav", 80, 0, 0 /*, "玛摩那斯"*/ }, + { 61, "data\\se\\sae_11.wav", 123, 0, 0 /*, ""*/ }, + { 62, "data\\se\\sae_12.wav", 95, 0, 0 /*, "奇卡洛斯"*/ }, + { 63, "data\\se\\sae_13.wav", 80, 0, 0 /*, "斯坦多斯"*/ }, + { 64, "data\\se\\sae_14.wav", 90, 0, 0 /*, "西朵拉"*/ }, + { 65, "data\\se\\sae_15.wav", 95, 0, 0 /*, "乌力美达鲁"*/ }, + { 66, "data\\se\\sae_16.wav", 95, 0, 0 /*, "弹回的声音"*/ }, + { 67, "data\\se\\sae_17.wav", 123, 0, 0 /*, ""*/ }, + { 68, "data\\se\\sae_18.wav", 123, 0, 0 /*, ""*/ }, + { 69, "data\\se\\sae_19.wav", 123, 0, 0 /*, ""*/ }, + { 70, "data\\se\\sae_20.wav", 123, 0, 0 /*, ""*/ }, + { 71, "data\\se\\sae_21.wav", 123, 0, 0 /*, ""*/ }, + { 72, "data\\se\\sae_22.wav", 123, 0, 0 /*, ""*/ }, + { 73, "data\\se\\sae_23.wav", 90, 0, 0 /*, "卖东西者"*/ }, + { 74, "data\\se\\sae_24.wav", 90, 0, 0 /*, "野猪"*/ }, + { 75, "data\\se\\sae_25.wav", 100, 0, 0 /*, "愿藏"*/ }, + { 76, "data\\se\\sae_26.wav", 123, 0, 0 /*, ""*/ }, + { 77, "data\\se\\sae_27.wav", 123, 0, 0 /*, ""*/ }, + { 78, "data\\se\\sae_28.wav", 90, 0, 0 /*, "卡比特"*/ }, + { 79, "data\\se\\sae_29.wav", 123, 0, 0 /*, ""*/ }, + { 80, "data\\se\\sae_30.wav", 100, 0, 0 /*, "龟之盾"*/ }, + { 81, "data\\se\\sae_31.wav", 123, 0, 0 /*, ""*/ }, + { 82, "data\\se\\sae_32.wav", 123, 0, 0 /*, ""*/ }, + + // 芊 + { 100, "data\\se\\sam_01.wav", 75, 0, 0 /*, "领域上使用咒术"*/ }, + { 101, "data\\se\\sam_02.wav", 75, 0, 0 /*, "传送信件"*/ }, + { 102, "data\\se\\sam_03.wav", 75, 0, 0 /*, "恢复"*/ }, + { 103, "data\\se\\sam_04.wav", 123, 0, 0 /*, "火 (小)"*/ }, + { 104, "data\\se\\sam_05.wav", 123, 0, 0 /*, "火 (中)"*/ }, + { 105, "data\\se\\sam_06.wav", 123, 0, 0 /*, "火 (大)"*/ }, + { 106, "data\\se\\sam_07.wav", 123, 0, 0 /*, "火柱(小)"*/ }, + { 107, "data\\se\\sam_08.wav", 123, 0, 0 /*, "火柱(中)"*/ }, + { 108, "data\\se\\sam_09.wav", 123, 0, 0 /*, "火柱(大)"*/ }, + { 109, "data\\se\\sam_10.wav", 123, 0, 0 /*, "冻气(小)"*/ }, + { 110, "data\\se\\sam_11.wav", 123, 0, 0 /*, "冻气(中)"*/ }, + { 111, "data\\se\\sam_12.wav", 123, 0, 0 /*, "冻气(大)"*/ }, + { 112, "data\\se\\sam_13.wav", 123, 0, 0 /*, "雷击(小)"*/ }, + { 113, "data\\se\\sam_14.wav", 123, 0, 0 /*, "雷击(中)"*/ }, + { 114, "data\\se\\sam_15.wav", 85, 0, 0 /*, "雷击(必杀绝技)"*/ }, + { 115, "data\\se\\sam_16.wav", 123, 0, 0 /*, "光柱"*/ }, + { 116, "data\\se\\sam_17.wav", 123, 0, 0 /*, "光线"*/ }, + { 117, "data\\se\\sam_18.wav", 123, 0, 0 /*, "镭射"*/ }, + { 118, "data\\se\\sam_19.wav", 123, 0, 0 /*, "吸血"*/ }, + { 119, "data\\se\\sam_20.wav", 123, 0, 0 /*, "诅咒"*/ }, + { 120, "data\\se\\sam_21.wav", 123, 0, 0 /*, "石化"*/ }, + { 121, "data\\se\\sam_22.wav", 123, 0, 0 /*, "苏醒"*/ }, + { 122, "data\\se\\sam_23.wav", 123, 0, 0 /*, "魔法弹"*/ }, + { 123, "data\\se\\sam_24.wav", 123, 0, 0 /*, "净化"*/ }, + + // 棕雁 +// { 151, "data\\se\\sak_01.wav", 121, 0, 1 /*, "鸡"*/ }, +// { 152, "data\\se\\sak_02.wav", 121, 0, 1 /*, "狼号声"*/ }, + { 151, "data\\se\\sak_01.wav", 127, 0, 1 /*, "丛林"*/ }, +//x { 152, "data\\se\\sak_02.wav", 127, 4, 1 /*, "人声吵杂"*/ }, + { 152, "data\\se\\sak_02.wav", 127, 0, 1 /*, "人声吵杂"*/ }, + { 153, "data\\se\\sak_03.wav", 121, 0, 1 /*, "雨"*/ }, + { 154, "data\\se\\sak_04.wav", 90, 0, 1 /*, "风"*/ }, + { 155, "data\\se\\sak_05.wav", 95, 0, 1 /*, "飘雪"*/ }, + { 156, "data\\se\\sak_06.wav", 127, 0, 1 /*, "雷鸣"*/ }, + { 157, "data\\se\\sak_07.wav", 125, 0, 1 /*, "潺潺水声"*/ }, + { 158, "data\\se\\sak_08.wav", 125, 0, 1 /*, "海浪声"*/ }, + { 159, "data\\se\\sak_09a.wav", 120, 0, 1 /*, "鸟鸣声"*/ }, + { 160, "data\\se\\sak_10.wav", 115, 0, 1 /*, " 鸣,振翅声"*/ }, + { 161, "data\\se\\sak_11.wav", 85, 0, 1 /*, "喷水场"*/ }, + { 162, "data\\se\\sak_12.wav", 120, 0, 1 /*, "风车"*/ }, + { 163, "data\\se\\sak_13.wav", 100, 0, 1 /*, "水滴"*/ }, + { 164, "data\\se\\sak_14.wav", 127, 0, 1 /*, "草原"*/ }, + { 165, "data\\se\\sak_15.wav", 120, 0, 1 /*, "地面震动"*/ }, + { 166, "data\\se\\sak_16.wav", 120, 0, 1 /*, "丢石子到水中"*/ }, + { 167, "data\\se\\sak_17.wav", 110, 0, 1 /*, "烧落叶取暖"*/ }, + { 168, "data\\se\\sak_09b.wav", 120, 0, 1 /*, "鸟鸣(森林)"*/ }, + + // 扑旦 丞 + { 201, "data\\se\\sas_01.wav", 90, 0, 0 /*, "照像的声音"*/ }, + { 202, "data\\se\\sas_02.wav", 80, 0, 0 /*, "打开视窗"*/ }, + { 203, "data\\se\\sas_03.wav", 75, 0, 0 /*, "关闭视窗"*/ }, + { 204, "data\\se\\sas_04.wav", 80, 0, 0 /*, "打开视窗2"*/ }, + { 205, "data\\se\\sas_05.wav", 80, 0, 0 /*, "关闭视窗2"*/ }, + { 206, "data\\se\\sas_06.wav", 80, 0, 0 /*, "结束的音乐"*/ }, + { 207, "data\\se\\sas_07.wav", 123, 0, 0 /*, ""*/ }, + { 208, "data\\se\\sas_08.wav", 123, 0, 0 /*, ""*/ }, + { 209, "data\\se\\sas_09.wav", 123, 0, 0 /*, ""*/ }, + { 210, "data\\se\\sas_10.wav", 123, 0, 0 /*, ""*/ }, + { 211, "data\\se\\sas_11.wav", 65, 0, 0 /*, 伊矛伙失永皿""*/ }, + { 212, "data\\se\\sas_12.wav", 80, 0, 0 /*, "使用项目"*/ }, + { 213, "data\\se\\sas_13.wav", 123, 0, 0 /*, "NG长音"*/ }, +// { 214, "data\\se\\sas_14.wav", 127, 0, 0 /*, "胜利"*/ }, + { 215, "data\\se\\sas_15.wav", 82, 0, 0 /*, "相遇"*/ }, + { 216, "data\\se\\sas_16.wav", 110, 0, 0 /*, "交换宠物"*/ }, + { 217, "data\\se\\sas_17.wav", 85, 0, 0 /*, "点滑鼠2"*/ }, + { 218, "data\\se\\sas_18.wav", 123, 0, 0 /*, ""*/ }, + { 219, "data\\se\\sas_19.wav", 82, 0, 0 /*, "照像"*/ }, + { 220, "data\\se\\sas_20.wav", 60, 0, 0 /*, "NG短音"*/ }, + { 221, "data\\se\\sas_21.wav", 123, 0, 0 /*, ""*/ }, + + // 母丢□斥 + { 250, "data\\se\\sad_01.wav", 85, 0, 0 /*, "损害1(赤手空拳)"*/ }, + { 251, "data\\se\\sad_02.wav", 80, 0, 0 /*, "损害2(斧,棍棒)"*/ }, +//x { 252, "data\\se\\sad_03.wav", 95, -3, 0 /*, "损害3(枪)"*/ }, + { 252, "data\\se\\sad_03.wav", 95, 0, 0 /*, "损害3(枪)"*/ }, + { 253, "data\\se\\sad_04.wav", 85, 0, 0 /*, "损害4(弓)"*/ }, + { 254, "data\\se\\sad_05.wav", 90, 0, 0 /*, "损害5(爪)"*/ }, + + // BGM +// { 401, "data\\bgm\\ls2b_01.wav", 5 /*, "自由模式之曲"*/ }, +// { 402, "data\\bgm\\ls2b_02.wav", 5 /*, "游戏中的曲"*/ }, +// { 403, "data\\bgm\\ls2b_03.wav", 5 /*, "地下之曲"*/ }, +// { 404, "data\\bgm\\ls2b_04.wav", 5 /*, "头目之曲"*/ }, + + { -1 } // 蔽羹筏寞 壅今卅中方丹卞 +}; + + diff --git a/gmsv/include/title.h b/gmsv/include/title.h new file mode 100644 index 0000000..2f2248f --- /dev/null +++ b/gmsv/include/title.h @@ -0,0 +1,21 @@ +#ifndef __TITLE_H__ +#define __TITLE_H__ + +#include "common.h" +#include "util.h" + +INLINE BOOL TITLE_CHECKTABLEINDEX( int index ); +int TITLE_getTitleIndex( int index); + +char* TITLE_makeTitleStatusString( int charaindex, int havetitleindex ); +char* TITLE_makeSkillFalseString( void ); + +BOOL TITLE_addtitle( int charaindex, int titleindex ); +BOOL TITLE_deltitle( int charaindex, int titleindex ); +BOOL TITLE_initTitleName( char* filename ); +BOOL TITLE_reinitTitleName( void); +BOOL TITLE_initTitleConfig( char* filename ); +BOOL TITLE_TitleCheck( int charaindex, BOOL mode); +BOOL TITLE_TitleCheck_Nomsg( int charaindex, BOOL mode, int *addcnt, int *delcnt); +#endif + /*__TITLE_H__*/ diff --git a/gmsv/include/trade.h b/gmsv/include/trade.h new file mode 100644 index 0000000..3a0cc4c --- /dev/null +++ b/gmsv/include/trade.h @@ -0,0 +1,18 @@ +#ifndef __TRADE_H__ +#define __TRADE_H__ +#include "version.h" +#include "common.h" +#include "util.h" +#include "net.h" + +BOOL TRADE_Search(int fd, int meindex, char* message); + +void CHAR_Trade(int fd, int index, char* message); + +#ifdef _ITEM_PILEFORTRADE +void TRADE_InitTradeList( void); +#endif + +void TRADE_CheckTradeListUser( void); + +#endif diff --git a/gmsv/include/util.h b/gmsv/include/util.h new file mode 100644 index 0000000..0d06f6d --- /dev/null +++ b/gmsv/include/util.h @@ -0,0 +1,136 @@ +#ifndef __UTIL_H__ +#define __UTIL_H__ + +#include +#include +#include + +#include "common.h" + +typedef struct tagSTRING32 +{ + char string[32]; +}STRING32; +typedef struct tagSTRING64 +{ + char string[64]; +}STRING64; +typedef struct tagSTRING128 +{ + char string[128]; +}STRING128; + +typedef struct tagRECT +{ + int x; + int y; + int width; + int height; +}RECT; +typedef struct tagPOINT +{ + int x; + int y; +}POINT; +/* strtol 及仿永由□迕卞银丹 */ +typedef enum +{ + CHAR,SHORT,INT,DOUBLE +}CTYPE; + +void chop( char* src ); +void dchop( char* src , char* del); +#define chomp(src) dchop(src,"\n"); +void chompex( char *buf ); +void pohcd( char* src , char* del); +void strcpysafe( char* dest ,size_t n,const char* src ); +void strncpysafe( char* dest ,const size_t n , + const char* src ,const int length ); +char* strcatsafe( char* src, int size, char* ap ); +BOOL strtolchecknum( char* arg , void* number,int base ,CTYPE type); +int strcmptail( char *s1 , char *s2 ); +int texttoiTail( char *hoge); +int textToInt( char *str ); +void deleteCharFromString( char* src , char* dels ); +void deleteCharFromStringNoEscape( char* src , char* dels ); +#define deleteWhiteSpace( src ) deleteCharFromStringNoEscape( src," \t" ) +char* replaceString( char* src, char oldc ,char newc ); + +char* escapeStrStr( char* src, char* needle ); +BOOL getStringFromIndexWithDelim_body( char* src ,char* delim ,int index, char* buf , int buflen, char *file, int line ); +#define getStringFromIndexWithDelim( src, delim, index, buf, buflen ) getStringFromIndexWithDelim_body( src, delim, index, buf, buflen, __FILE__, __LINE__ ) + +void getFourIntsFromString(char* src,int* int1,int* int2,int* int3, + int* int4); +void deleteSequentChar( char* src , char* dels ); +int hashpjw ( char* s ); +double gettimemillis( void ); +double gettimemicros( void ); + +int bindlocalhost( int port ); +int connectHost( char* hostname , unsigned short port ); +int existsNewLineCharacter( char* line ); +int hashpjw ( char* s ); +int charInclude( char* src, char* include ); +char* nindex( char* string, int c , int number ); +int rgetFileName( char* dirname , STRING64* string, int size); +#define RAND(x,y) ((x-1)+1+ \ + (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) ) +/*#define RAND(x,y) (x+(int)( (double)(y)*rand() / (RAND_MAX+1.0)) )*/ +void makeRandomString( char *cand , char *out , int len ); +BOOL checkStringsUnique( char** strings, int num ,int verbose); + +char* makeEscapeString( char* src , char* dest, int sizeofdest); +char* makeStringFromEscaped( char* src ); +INLINE double time_diff(struct timeval subtrahend,struct timeval subtractor); +BOOL PointInRect( RECT* rect, POINT* p ); +BOOL CoordinateInRect( RECT* rect, int x, int y); +int clipRect( RECT *rect1, RECT *rect2, RECT *ret ); +BOOL isstring1or0( char* string ); +void easyGetTokenFromString( char *src , int count , char*output , int len ); + +float linearDiv( float val1 , float val2 , float d ); +BOOL isExistFile( char* filename ); +char *cnv10to62( int a, char *out, int outlen ); +BOOL checkRedundancy( int *src, int srclen); +void shuffle_ints( int num, int *a, int t ); +unsigned short CheckCRC( unsigned char *p , int size ); +// Shan Add +INLINE double time_diff(struct timeval subtrahend,struct timeval subtractor); + + +/* 穴弁夫卅曰 */ +#define ABS(x) ((x)>=0 ? (x) : -(x)) + +/* 轾毛 0 - 7 卞濮覆卞允月 */ +#define VALIDATEDIR(x) ({(x)%=8;(x)=((x)+8)%8;}) + +/* 4田奶玄犯□正毛2田奶玄犯□正午仄化银丹 */ +#define GETLOWVALUE(x) ( (x)&0x0000ffff) +#define GETHIGHVALUE(x) ((((x)&0xffff0000)>>16)&0x0000ffff) +#define SETLOWVALUE(x,y) ((x)=((x)&0xffff0000)|( (y) &0x0000ffff)) +#define SETHIGHVALUE(x,y) ((x)=((x)&0x0000ffff)|(((y)<<16)&0xffff0000)) +#define MAKE2VALUE(x,y) ((((x)<<16)&0xffff0000)|((y)&0x0000ffff)) + +/* 4田奶玄犯□正毛1田奶玄*4午仄化丐勾井丹穴弁夫 */ +#define GETFIRSTVALUE(x) ( (x)&0x000000ff ) +#define GETSECONDVALUE(x) ((((x)&0x0000ff00)>>8 )&0x000000ff) +#define GETTHIRDVALUE(x) ((((x)&0x00ff0000)>>16)&0x000000ff) +#define GETFOURTHVALUE(x) ((((x)&0xff000000)>>24)&0x000000ff) + +#define SETFIRSTVALUE(x,y) ((x)=(((x)&0xffffff00)\ + |( y &0x000000ff))) +#define SETSECONDVALUE(x,y) ((x)=(((x)&0xffff00ff)\ + |(((y)<<8 )&0x0000ff00))) +#define SETTHIRDVALUE(x,y) ((x)=(((x)&0xff00ffff)\ + |(((y)<<16)&0x00ff0000))) +#define SETFOURTHVALUE(x,y) ((x)=(((x)&0x00ffffff)\ + |(((y)<<24)&0xff000000))) + +#define MAKE4VALUE(a,b,c,d) ( (((a)<<24)&0xff000000)\ + |(((b)<<16)&0x00ff0000)\ + |(((c)<< 8)&0x0000ff00)\ + |( (d) &0x000000ff)) + +#endif + /* __UTIL_H__ */ diff --git a/gmsv/include/version.h b/gmsv/include/version.h new file mode 100644 index 0000000..354e943 --- /dev/null +++ b/gmsv/include/version.h @@ -0,0 +1,574 @@ +#ifndef __VERSION_H__ +#define __VERSION_H__ +#include "correct_bug.h" //BUG FIX +#include "version_pk.h" //PK SERVER + +/*Server 版本控制*/ +#define _NEW_SERVER_ +#define _SERVER_NUMS +#define SERVER_VERSION "龙zoro版GMSV服务端v2.2.2.28" + +#define UNIQUE_KEYCODEITEM 100 +#define UNIQUE_KEYCODEPET "i" + +#define _SA_VERSION_70 // (可开放) WON ADD 石器时代7.0 的版本控制 +//#define _DEFAULT_PKEY "Wonwonwon" // (可开放)( 石器 6.0 ) +//#define _RUNNING_KEY "11111111" // (可开放)( 石器 6.0 ) +#define _DEFAULT_PKEY "ttttttttt" // (可开放)( 石器 6.0 ) +#define _RUNNING_KEY "20041215" // (可开放)( 石器 6.0 ) + +#define _VERSION_20010911 // (可开放) 9.11 编码修改 + +// ------------------------------------------------------------------- +//新功能:测试伺服器专用 人员:彦豪 +#define _TEST_PETCREATE // (不可开) ANDY 测宠的GM指令 +//#define _LOGIN_ADDITEM // (不可开) ANDY 登入加满物品 +//#define _NEW_TESTSERVER // (不可开) ANDY 玩家创新人物时,给予五转125等级及叁只宠物 +//#define _TEST_PETFUSIONTIME // (不可开) ANDY 测试宠物融合 食时间加快 +/* ------------------------------------------------------------------- + * 专案:家族庄园数量修改 人员:小瑜、彦勋、志伟、小民 + */ + +/* +修改装园数量方式: +Account Server 程式: + acfamily.h MAX_FMPOINT要修改 +Account Server 游戏环境: + saac/family/fmpoint/db_fmpoint档案中须新增庄园入口坐标等设定 + 庄园进入图层|庄园进入X座标|庄园进入Y座标|庄园族长图层|庄园邻近之村庄|占领庄园之家族 index|占领庄园之家族 name|占领庄园之家族综合声望值 + 例如: + 100|607|563|1041|1|3|shan|3132238 + 200|73|588|2031|2||| +Game Server 程式: + version.h FAMILY_MAXHOME、MANORNUM要修正 + family.c FM_PKFLOOR 须增设战斗图层 + FAMILY_RidePet() 中须加入族长家图层 + FAMILY_LeaderFunc() 中须加入邀请函id + npcutil.c addNpcFamilyTax function中须加入(庄园图层%100)此为庄园税收部份 +Game Server 游戏环境: + gmsv_v2/data/npc/family/manorsman.arg* id须修正 + gmsv_v2/data/npc/family/scheduleman.arg* id须修正 +*/ + +#define _FAMILY_MANORNUM_CHANGE // CoolFish 用来修改装园数量(4.0) +#ifdef _FAMILY_MANORNUM_CHANGE +#define FAMILY_MAXHOME 10 // (4.0) 家族据点 +#define MANORNUM 10 // (4.0) 庄园数量 +#define FMPOINTNUM 10 // (4.0) 有据点家族的最大数量 +#endif +#define _FMVER21 // (可开放) 家族职掌功能 +#define _PERSONAL_FAME // (可开放) Arminius 8.30 家族个人声望 +// ------------------------------------------------------------------- +//专案:石器活动自动化 人员:晓威、家麟 +#define _SERVICE // (可开放) Terry 2001/10/03 活动功能自动化 + +#define _EVERYONE_RIDE // (可开放) Robin 0924 骑宠平民化 +// ------------------------------------------------------------------- +//专案:攻击性咒术的制作 人员:笃志 +// #define __ATTACK_MAGIC_MSG // (不开放) +#define __ATTACK_MAGIC // (可开放) 提供战场中的攻击性咒术 +#define _ADD_ACTION // (可开放) 一般NPC动作状况的设定 + +// ------------------------------------------------------------------- +//专案:宠物、道具编码 人员:小瑜 +#define _UNIQUE_P_I // (可开放) CoolFish 2001/10/11 + +// ------------------------------------------------------------------- +//专案:新版人物储存pn 及 当机不回朔 1018 人员:彦勋 +#define _NEWSAVE // (可开放) Robin +#define _STORECHAR // (可开放) Robin +#define _DROPCHECK // (可开放) Robin 防止重复丢道具 +#define _DROPCHECK2 // (可开放) Robin 防止重复丢道具 +// ------------------------------------------------------------------- +//专案 : 精灵王 人员 : 彦豪 +#define _PET_TRANS // (可开放) 宠物转生功能 +#define _NEW_WARPMAN // (可开放) NPC多重WARP功能 +#define _PET_TALK // (可开放) 宠物对话 +#define _PET_LIMITLEVEL // (可开放) 特殊宠设计(玛蕾) +#define _MAP_NOEXIT // (可开放) 特殊地图不得原登&原登回指定点 +// ------------------------------------------------------------------- +// 专案:GM指令、层级Reload 人员:小瑜 +#define _GMRELOAD // (可开放) CoolFish: 2001/11/12 +// ------------------------------------------------------------------- +// 专案:伊甸大陆 人员:彦豪、阿民、小瑜 +#define _GAMBLE_ROULETTE // (可开放) 彦豪 赌场轮盘 宝宝小猪 +#define _FIX_GAMBLENUM // (可开放) 轮盘修正 : 下线扣积分 +#define _GAMBLE_BANK // (可开放) 彦豪 赌场银行 +#define _DROPSTAKENEW // (可开放) CoolFish: 赌场下注 +#define _PETRACE // (可开放) CoolFish: 2001/12/3 宠物竞速场 +#define _NEWEVENT // (可开放) CoolFish: 2001/12/5 新的任务旗标 +//#define _BIGSMALL // (不可开) Arminius 12.15 骰子比大小 +//#define _AUCTIONEER // (不可开) Arminius 12.20 拍卖店 +// ------------------------------------------------------------------- +//专案:鞭炮制作 人员:晓威 +#define _ITEM_FIRECRACKER // (可开放) 战斗中使用鞭炮可以把年兽吓走 +// ------------------------------------------------------------------- +//新功能:庄园PK规则(酷哥定的) 人员:志伟、志旺 +#define _MANOR_PKRULE // (可开放) +#define _MANOR_FIXFMPK // (可开放) WON ADD 家族约战的 GM 指令,测试用的 +// ------------------------------------------------------------------- +// 新功能:新功能&宠物技能 人员:彦豪 +#define _PSKILL_FALLGROUND // (可开放) 宠物技能 (落马术) +#define _ENEMY_FALLGROUND // (可开放) NPC 落马 +#define _BATTLE_NEWPOWER // (可开放) +#define _Item_MoonAct // (可开放) 月神的守护 +#define _Item_DeathAct // (可开放) 恶魔的首饰 +#define _Item_PetAct // (可开放) 驯兽戒指 +#define _Item_ReLifeAct // (可开放) 需要itemset1.txt 才能开) 替身娃娃 +#define _BATTLESTEAL_FIX // (可开放) 修正偷窃 +#define _CFREE_petskill // (可开放) 需要petskill1.txt 才能开) 新学习宠物技能技能 +#define _data_newreadfile // (可开放) 新的server setup.cf 档案 包含 itemset1.txt petskill1.txt 两个新档 +#define _ITEM_MAXUSERNUM // (可开放) 新 itemset1.txt ITEM 使用次数 +// ------------------------------------------------------------------- +//新功能:伊甸二期 人员:彦豪 +#define _PET_TALKPRO // (可开放) 宠物对话加强 & 改 END +#define _PRO_NPCFIX // (可开放) NPC功能加强 +#define _PRO_BATTLEENEMYSKILL // (可开放) 战斗加强 提升NPC的AI技能 +#define _NEW_WARPPOINT // (可开放) 传送点多重条件判断WARP +#define _FIX_CHECKITEM // (可开放) 道具不做非法检查 +// ------------------------------------------------------------------- +//新功能:伊甸二 人员:小民,WON +#define _ADD_ENCOUNT // (可开放) WON 增加敌遭遇触发修件 +#define _WON_PET_MAIL_LOG // (可开放) WON 玩家寄宠邮 LOG +// ------------------------------------------------------------------- +// 新功能:伊甸叁期 4.0 人员:彦豪, 志伟 , 又荣 , 志旺 +//#define _LOSE_FINCH_ // (不可开) ANDY 朱雀技能 +#define _FIX_FAMILY_PK_LIMIT // (可开放) WON 将可挑战庄园的由前十大改为前二十大 +#define _ADD_POOL_ITEM // (可开放) WON 增加可寄放的道具 +#define _ITEM_METAMO // (可开放) shan metamo sprite. code:robin->shan +#define _ENEMY_ATTACK_AI // (可开放) shan enemy attack mode. code:shan +#define _ITEM_TIME_LIMIT // (可开放) shan time limit of item. code:shan +#define _MIND_ICON // (可开放) shan show icon from char mind. code:shan +#define _BATTLENPC_WARP_PLAYER // (可开放) shan npc warp player when n round. code:shan +#define _ITEM_WARP_FIX_BI // (可开放) shan fix bbi to bi. code:shan +#define _SKILL_DAMAGETOHP // (可开放) ANDY 嗜血技 +#define _Skill_MPDAMAGE // (可开放) ANDY MP伤害 +#define _WAEI_KICK // (可开放) ANDY 跨星球踢人 +#define _BATTLE_TIMESPEED // (可开放) ANDY 战斗时间 测试(北京不必开,挡加速功能) +#define _NEW_RIDEPETS // (可开放) ANDY 新骑宠 +#define _FIXBUG_ATTACKBOW // (可开放) ANDY 修正骑宠使用投掷武器bug +#define _NPCCHANGE_PLAYERIMG // (可开放) ANDY NPC改变玩家图号, 强制落马,认玩家图号 (测完) +#define _ITEM_ATTSKILLMAGIC // (可开放) ANDY 道具技能 +#define _EQUIT_DEFMAGIC // (可开放) ANDY 抗魔装备 +#define _FIX_MAGICDAMAGE // (可开放) ANDY 修正魔法公式 叁期开放 +#define _ITEM_CONSTITUTION // (可开放) ANDY 修正个人体质 +#define _MAGIC_REHPAI // (可开放) ANDY 补血AI +#define _TRANSER_MAN // (可开放) ANDY 传送师 +#define _TAKE_ITEMDAMAGE // (可开放) ANDY 道具损坏 ITEMSET2 +#define _FIX_FIRECRACKER // (可开放) ANDY 修正 鞭炮 +#define _FIX_ITEMPROB // (可开放) ANDY 修正 掉宝率 +#define _ADD_DEAMGEDEFC // (可开放) ANDY 额外伤害 & 附加攻击 ITEMSET2 +#define _FIX_MAXCHARMP // (可开放) ANDY MP上限 +#define _ITEM_INSLAY // (可开放) ANDY 镶宝石 动作 +#define _ITEMSET2_ITEM // (可开放) ANDY ITEMSET2 +#define _ITEM_NPCCHANGE // (可开放) ANDY 工匠 (提炼, 精工) +#define _PETSKILL_FIXITEM // (可开放) ANDY 修复 && 同道具损坏 +#define _FIX_SETWORKINT // (可开放) ANDY (FIXWORKINT) +#define _ITEM_ADDEXP // (可开放) vincent 道具:指定时间内增加经验值上升幅度 +#define _ITEM_ADDEXP2 // 智果时间可以累加 Robin +#define _FIX_METAMORIDE // (可开放) ANDY +//#define _M_SERVER // (可开放) GM SERVER (北京&韩国不必开) +//#define _FIX_MSERVER // (可开放) GM SERVER PROC (北京&韩国不必开) +#define _CHECK_ITEMDAMAGE // (可开放) 道具损坏修正 7/26 +#define _SKILL_WILDVIOLENT_ATT // (可开放) vincent 宠技:狂暴攻击 +#define _MAGIC_WEAKEN // (可开放) vincent 精灵:虚弱 +#define _SKILL_WEAKEN // (可开放) vincent 宠技:虚弱//需要开#define _MAGIC_WEAKEN +#define _SKILL_SPEEDY_ATT // (可开放) vincent 宠技:疾速攻击 +#define _SKILL_GUARDBREAK2 // (可开放) vincent 宠技:破除防御2 +#define _SKILL_SACRIFICE // (可开放) vincent 宠技:救援 +#define _PSKILL_MODIFY // (可开放) ANDY 属性强化攻击 +#define _PSKILL_MDFYATTACK // (可开放) ANDY 攻击转化属性 +#define _MAGIC_DEFMAGICATT // (可开放) ANDY 魔法防御 +#define _MAGIC_SUPERWALL // (可开放) ANDY 铁壁防御 +#define _OTHER_MAGICSTAUTS // (可开放) ANDY +#define _SKILL_TOOTH // (可开放) ANDY 齿术 +#define _MAGIC_DEEPPOISON // (可开放) vincent 精灵:剧毒 +#define _MAGIC_BARRIER // (可开放) vincent 精灵:魔障 +#define _MAGIC_NOCAST // (可开放) vincent 精灵:沉默 +#define _ITEM_CRACKER // (可开放) vincent 道具:拉炮 //需要开#define _MIND_ICON +#define _SKILL_DEEPPOISON // (可开放) vincent 宠技:剧毒 //需要开#define _MAGIC_DEEPPOISON +#define _SKILL_BARRIER // (可开放) vincent 宠技:魔障 //需要开#define _MAGIC_BARRIER +#define _SKILL_NOCAST // (可开放) vincent 宠技:沉默 //需要开#define _MAGIC_NOCAST +#define _SKILL_ROAR // (可开放) vincent 宠技:大吼(克年兽) +#define _SKILL_REFRESH // (可开放) vincent 宠技:解除异常状态 +#define _ITEM_REFRESH // (可开放) vincent 解除异常状态道具 +#define _MAGIC_TOCALL // (可开放) kjl 召唤 02/06/20 kjl + +// ------------------------------------------------------------------- +// 新功能:来吉卡功能 人员:彦豪 +#define _ITEMSET3_ITEM // (可开放) ANDY itemset3.txt +#define _SUIT_ITEM // (可开放) ANDY (套装) 来吉卡 需用itemset3.txt +#define _PETSKILL_SETDUCK // (可开放) ANDY 蒙奇技能 +#define _VARY_WOLF // (可开放) pet skill : vary wolf. code:shan +// ------------------------------------------------------------------- +// 新功能:专案5.0 人员: +//#define _ITEMTBL_STAIC // (不可开) ANDY (静态ITEMTBL) +#define _USEWARP_FORNUM // (可开放) ANDY 记忆羽毛 来吉卡 +#define _IMPRECATE_ITEM // (可开放) ANDY 特殊道具 来吉卡 +#define _MAGICPET_SKILL // (可开放) ANDY 魔法宠技能 +#define _ITEM_CHECKWARES // (可开放) ANDY 锁定传送不能 +#define _NPC_REPLACEMENT // (可开放) ANDY 置换战斗npc +#define _EMENY_CHANCEMAN // (可开放) ANDY EMENY 选择 +#define _TYPE_TOXICATION // (可开放) ANDY 中毒无法回血 +#define _PET_FUSION // (可开放) ANDY 宠物融合 enemybase1.txt +#define _NPC_FUSION // (可开放) ANDY NPC宠物融合 +#define _ITEM_EDITBASES // (可开放) ANDY 营养剂 +#define _PET_EVOLUTION // (可开放) ANDY 进化表 + +// ------------------------------------------------------------------- +// 新功能:5.0追加部分 人员: +#define _AVID_TRADETRYBUG // (可开放) ANDY 防止交易中丢宠/道具 寄(宠物)邮件 石币 +#define _ASSESS_SYSEFFICACY // (可开放) ANDY 评估系统效能 12/04 更新 +#define _ASSESS_SYSEFFICACY_SUB // (可开放) Robin 评估系统效能 增加检查内回圈 +#define _PREVENT_TEAMATTACK // (可开放) ANDY 防止同队互打 12/04 更新 +#define _ITEM_ORNAMENTS // (可开放) ANDY 装饰道具 12/04 更新 //出版部 +#define _CHIKULA_STONE // (可开放) ANDY 奇克拉之石 12/04 更新 //来吉卡 宠包 +#define _SEND_EFFECT // (可开放) WON AC送下雪、下雨等特效 12/04 更新 +#define _PETMAIL_DEFNUMS // (可开放) ANDY 宠物邮件限制 +#define _TEAM_KICKPARTY // (可开放) ANDY 队长踢人(非战斗状态) +#define _PETSKILL_TIMID // (可开放) ANDY 宠技-怯战 +#define _PETS_SELECTCON // (可开放) ANDY 宠物不可点选出战 +#define _CHRISTMAS_REDSOCKS // (可开放) ANDY 圣诞红袜 +#define _FIX_ARRAYBUG // (可开放) ANDY 修正array 溢位 +#define _USER_CHARLOOPS // (可开放) ANDY 新用物件LOOP +#define _BATTLE_PROPERTY // (可开放) ANDY 战斗属性特性 +#define _PETSKILL_PROPERTY // (可开放) ANDY 无属魔兽宠技 +#define _ITEM_FIXALLBASE // (可开放) ANDY 修复之石 +#define _ITEM_LOVERPARTY // (可开放) ANDY 情人节道具 +#define _ITEM_FORUSERNAMES // (可开放) ANDY 道具所有人 +#define _BATTLECOMMAND_TIME // (可开放) ANDY 防止玩家开缓速(回合战斗时间) +#define _NPCENEMY_ADDPOWER // (可开放) ANDY 修改怪物的能力值 +//#define _BAD_PLAYER // (不可开) WON 送坏玩家去关 + + +// ------------------------------------------------------------------- +// 新功能:专案6.0 人员: +// +#define _PETSKILL_CANNEDFOOD // (可开放) ANDY 宠物技能罐头 for 6.0 +#define _TEST_DROPITEMS // (可开放) ANDY 测试丢宠 +#define _MAP_WARPPOINT // (可开放) ANDY Map WarpPoint +//#define _AUTO_ADDADDRESS // (可开放) ANDY 自动新增名片 +#define _DEFEND_TIMECHECK // (可开放) ANDY 内部测试时间 +#define _TREASURE_BOX // (可开放) ANDY 宝箱 +#define _BENEMY_EVENTRUN // (可开放) ANDY 战斗npc给道具 +#define _BATTLE_ABDUCTII // (可开放) ANDY 旅途夥伴2 +#define _BATTLE_LIGHTTAKE // (可开放) ANDY 采光术 +#define _BATTLE_ATTCRAZED // (可开放) ANDY 疯狂暴走 +#define _STATUS_WATERWORD // (可开放) ANDY 水世界状态 +#define _ITEM_WATERWORDSTATUS // (可开放) ANDY 水世界状态道具 +//#define _KILL_12_STOP_GMSV // (可开放) WON 下sigusr2後关闭GMSV +//#define _DELBORNPLACE // (可开放) Syu 6.0 统一出生於新手村 +#define _REEDIT_PETBBIS // (可开放) ANDY 修正宠物波比图形 +#define _CAPTURE_FREES // (可开放) ANDY 补抓条件 +#define _THROWITEM_ITEMS // (可开放) 丢掷後有奖品 +#define _OBJSEND_C // (可开放) ANDY _OBJSEND_C +#define _ADD_SHOW_ITEMDAMAGE // (可开放) WON 显示物品耐久度 + +//-------------------------------------------------------------------------- +//专案 7.0 职业系统 人员:彦豪 志旺 旭诚 奇铨 + +#define _CHANGETRADERULE // (可开放) Syu ADD 交易规则修订 +#define _TRADE_SHOWHP // (可开放) Syu ADD 交易显示血量 +#define _SHOOTCHESTNUT // (可开放) Syu ADD 宠技:丢栗子 +#define _SKILLLIMIT // (可开放) Syu ADD 不得攻击我方限制 +#define _TRADESYSTEM2 // (可开放) Syu ADD 新交易系统 +#define _NPC_NOSAVEPOINT // (可开放) ANDY 纪录点不存人物资料 +#define _ACFMPK_LIST // (可开放) ANDY 家族对战列表修正 +#define _PETSKILL2_TXT // (可开放) ANDY petskill2.txt +#define _PETSKILL_CHECKTYPE // (可开放) ANDY 宠物技能使用时机 +#define _PETSKILL_TEAR // (可开放) ANDY 宠技 撕裂伤口 +#define _NPC_MAKEPAIR // (可开放) ANDY NPC 配对 +#define _ITEMSET4_TXT // (可开放) ANDY itemset4.txt +#define _ITEM_PILENUMS // (可开放) ANDY 道具素材堆叠 需 itemset4 +#define _ITEM_PILEFORTRADE // (可开放) ANDY 交易堆叠 +#define _ITEM_EQUITSPACE // (可开放) ANDY 新装备栏位 +#define _PET_LOSTPET // (可开放) ANDY 遗失宠物搜寻计划宠物 +#define _ITEMSET5_TXT // (可开放) ANDY itemset5.txt +#define _ITEMSET6_TXT // (可开放) ANDY itemset6.txt +#define _EQUIT_ARRANGE // (可开放) ANDY 挡格 需要 itemset5.txt +#define _EQUIT_SEQUENCE // (可开放) ANDY 攻击顺序 需要 itemset5.txt +#define _EQUIT_ADDPILE // (可开放) ANDY 增加可堆叠数 需要 itemset5.txt +#define _EQUIT_HITRIGHT // (可开放) ANDY 命中 需要 itemset5.txt +#define _EQUIT_NEGLECTGUARD // (可开放) ANDY 忽视目标防御力% 需要 itemset6.txt +#define _EQUIT_NEWGLOVE // (可开放) ANDY 手套栏位 +#define _FM_JOINLIMIT // (可开放) ANDY 加入家族条件限制 +#define _FIX_MAX_GOLD // (可开放) WON ADD 增加人物金钱上限 +#define _CK_ONLINE_PLAYER_COUNT // (可开放) WON 计算线上人数 (要配合ac,否则会重开) +#define _PET_SKILL_SARS // (可开放) WON ADD 毒煞蔓延 +#define _SONIC_ATTACK // (可开放) WON ADD 音波攻击 +#define _NET_REDUCESEND // (可开放) ANDY 减少DB资料传送 +#define _FEV_ADD_NEW_ITEM // (可开放) Change 增加复活守精 +#define _ALLDOMAN // (可开放) Syu ADD 排行榜NPC +#define _LOCKHELP_OK // (可开放) Syu ADD 锁定不可加入战斗 +#define _TELLCHANNEL // (可开放) Syu ADD 密语频道 +// 新功能:职业 +#define _NEWREQUESTPROTOCOL // (可开放) Syu ADD 新增Protocol要求细项 +#define _OUTOFBATTLESKILL // (可开放) Syu ADD 非战斗时技能Protocol +#define _CHAR_PROFESSION // (可开放) WON ADD 人物职业栏位 +#define _PROFESSION_SKILL // (可开放) WON ADD 人物职业技能 +#define _NPC_WELFARE // (可开放) WON ADD 职业NPC +#define _PROFESSION_FIX_LEVEL // (可开放) WON ADD 修正职业经验值(北京&韩国不必开) +#define _GM_SIGUSR2 // (可开放) Change 下达sigusr2後执行 gm_sigusr_command档案内的GM指令,若没有指令就关闭GMSV +#define _GM_BROADCAST // (可开放) WON ADD 客服公告系统 +#define _NPC_ADDLEVELUP // (可开放) ANDY NPC增加玩家等级 +#define _CHAR_FIXDATADEF // (可开放) ANDY 修正人物资料初始 +//系统改良 +#define _SIMPLIFY_ITEMSTRING // (可开放) ANDY 简化道具字串 +#define _CHAR_NEWLOGOUT // (可开放) ANDY 登出新机制 +#define _CHATROOMPROTOCOL // (可开放) Syu ADD 聊天室频道 8/27 + +#define _CHAR_POOLITEM // (可开放) ANDY 人物道具仓库共用 +#define _NPC_DEPOTITEM // (可开放) ANDY 人物道具仓库共用 + +#define _SIMPLIFY_PETSTRING // (可开放) ANDY 简化宠物存档字串 +#define _SIMPLIFY_ITEMSTRING2 // (可开放) ANDY 简化道具字串2 +#define _WOLF_TAKE_AXE // (可开放) WON ADD 抓双头狼的限制 +#define _FIX_UNNECESSARY // (可开放) ANDY 修正不必要的判断 +#define _ITEM_MAGICRECOVERY // (可开放) ANDY 新光镜守 +//9/17更新 +#define _PETSKILL_GYRATE // (可开放) Change 宠技:回旋攻击 +#define _PETSKILL_ACUPUNCTURE // (可开放) Change 宠技:针刺外皮 (client端的_PETSKILL_ACUPUNCTURE也要开) +#define _PETSKILL_RETRACE // (可开放) Change 宠技:追迹攻击 +#define _PETSKILL_HECTOR // (可开放) Change 宠技:威吓 +//10/13更新 +#define _PETSKILL_FIREKILL // (可开放) Change 宠技:火线猎杀 +#define _PETSKILL_DAMAGETOHP // (可开放) Change 宠技:暗月狂狼(嗜血技的变体) +#define _PETSKILL_BECOMEFOX // (可开放) Change 宠技:媚惑术 +//10/22更新 +// 新功能:修改WORKER(新付费机制) +#define _FIX_MESSAGE // (可开放) WON ADD 修改WORKER封包内容 (北京&韩国不必开) + +//11/12更新 +#define _PETSKILL_SHOWMERCY // (可开) Change 宠技:手下留情 +#define _NPC_ActionFreeCmp // (可开) Change 替NPC参数加入新的比较方式 +//-------------------------------------------------------------------------- + + +//11/26 +#define _NPC_ProfessionTrans // (可开) Change 替职业NPC加入判断转生 +#define _NPC_NewDelPet // (可开) Change 替NPC加入删除宠物(原本就有了,只是用warpman使用时不成功,所以先做一个顶一下) +//#define _MUSEUM // 石器博物馆 Robin 2003/11 + #ifdef _MUSEUM + #define _DELBORNPLACE + #endif +#define _CHANGEGALAXY // (可开) 星系移民 Robin 2003/10 +#define _ALLDOMAN_DEBUG // (可开) Change 修正重启server後排行榜消失bug +//20031217 +#define _CHRISTMAS_REDSOCKS_NEW // (可开) Change 新圣诞红袜 +#define _PETSKILL_COMBINED // (可开) Change 宠技:难得糊涂 [综合魔法(依参数乱数取出魔法)] +//情人节活动 +#define _NPC_ADDWARPMAN1 // (可开放) Change npcgen_warpman增加功能(设定组队人数、设定组队男女人数) +#define _ITEM_QUITPARTY // (可开放) Change 队伍解散时特定道具即会消失 +#define _ITEM_ADDEQUIPEXP // (可开) Change 装备後经验值增加 +//2004/2/18 +#define _ITEM_LVUPUP // (可开) Change 突破宠物等级限制的药(玄武专用) +//2004/02/25 +#define _PETSKILL_BECOMEPIG // (可开) Change 宠技:乌力化 +#define _ITEM_UNBECOMEPIG // (可开) Change 乌力化的解药 +#define _PET_TALKBBI // (可开) Change 增加判断bbi +#define _ITEM_USEMAGIC // (可开) Change 由道具使用魔法 +//2004/04/07 +#define _ITEM_PROPERTY // (可开) Change 改变四属性道具 +#define _SUIT_ADDENDUM // (可开) Change 替套装增加功能 (_SUIT_ITEM要开) +//2004/05/05 +#define _ITEM_CHECKDROPATLOGOUT // (可开) Change 检查回纪录点时身上有无登出後消失道具,若有,不可回纪录点 +#define _FM_MODIFY // 家族功能修改(开放) +#define _CHANNEL_MODIFY // 频道功能整合(开放) +#define _STANDBYPET // Robin 待机宠封包 +#define _PROSKILL_OPTIMUM // Robin 职业技能处理最佳化 +#define _PETSKILL_OPTIMUM // Robin 宠物技能处理最佳化 +#define _MAGIC_OPTIMUM // Robin Magic table 最佳化 +#define _AC_PIORITY // Nuke 提高AC的优先权(可开) +//2004/05/12 +#define _CHAR_POOLPET // (可开放) Robin 人物宠物仓库共用 +#define _NPC_DEPOTPET // (可开放) Robin 人物宠物仓库共用 +#define _TIMEOUTKICK // (可开) 时段制踢人 Robin 2003/10 +#define _MAGIC_RESIST_EQUIT // (可开) WON ADD 职业抗性装备 +#define _LOG_OTHER // 杂项讯息专用LOG + +//-------------------------------------------------------------------------- +//机动营测试中 + + +// ------------------------------------------------------------------- +//#define _NPC_QUIZSCOPE // (不可开) Change 替NPC增加题号 围参数 +//#define _ITEM_ADDCOMBO // (不可开) Change 装备後合击率增加(战场上要有2个人以上带才有用)未完成... +//#define _NPC_AIRDELITEM // (不可开) Change 搭加美航空时所扣除的道具(就是飞机票啦) +//#define _NPC_AIRLEVEL // (不可开) Change 搭加美航空的最大最等级限制(等级过高不给搭) + +//#define _ANDYLOG_TEST +//#define _NPC_WELFARE_2 // (不可开) WON ADD 职业NPC-2 +//#define _UNIVERSE_CHATROOM // (不可开) ANDY 全星系聊天 +//#define _FIX_ALLDOMAN // (不可开) ANDY 修正英雄战场 +//制作中 +//#define _SEND_PROF_DATA // (不可开) ANDY ADD 传送职业更新给cli +//#define _AUCPROTOCOL // (不可开) Syu ADD 拍卖频道开关Protocol +//#define _NPC_SELLSTH // (不可开) ANDY 拍卖系统 +//#define _NPC_SEPARATEDATA // (不可开) ANDY NPC 资料分离 + +//------------------------------------------------------------------------ +// 以下为冻结功能 +//------------------------------------------------------------------------ +//#define fix_login_event // (不可开) WON 补回伊甸一期的声望 (北京不必开) +//#define _FIX_DEL_MAP // (不可开) WON 玩家抽地图送监狱 +//#define _PETFIGHT // (不可开) 宠物竞技场 +//#define _EXM_RANDITEM // (不可开) NPC (Exchangeman) 乱数要求物品 (已取消) +//#define add_amulet_map // (不可开) WON 增加太阳神首饰的 围 +//#define _ACFMPK_NOFREE // (不可开) ANDY 家族无条件 +//-------------------------------------------------------------------------- +// 6.0追加功能 pile + +//#define _IMPOROVE_ITEMTABLE // (不可开) ANDY 改善ITEM TABLE +//#define _NPC_SHOPALTER01 // (不可开) Change 买卖系统修改(配合Client改为图形介面所做的修改) +//#define _GM_IDENTIFY // (不可开) Change 是否秀出GM头顶上识别字串的GM指令 +//#define _GSERVER_RUNTIME // (不可开) Change 传送GSERVER执行多少时间给Mserver (Mserver要配合) +//#define _NPC_VERYWELFARE // (不可开) Change 非常好康A的NPC +//-------------------------------------------------------------------------- +//#define _ADD_NEWEVENT // (不可开) WON 多增任务旗标 +//#define _BLACK_MARKET // (不可开) shan a black market. code:shan +//#define _DYNAMIC_BUILDER_MAP // (不可开) shan (test)dynamic builder on the upper map. code:shan +//#define _TEST_ITEMMEMORY // (不可开) ANDY (测试ITEMTABL) +//#define _LASTERR_FUNCTION // (不可开) ANDY (lastFunction) +//#define _MARKET_TRADE // (不可开) ANDY 交易市集 +//#define _PAUCTION_MAN // (不可开) ANDY +//#define _SKILL_SELFEXPLODE // (不可开) vincent 宠技:自爆(缺图) +//#define _ADD_FAMILY_TAX // (不可开) WON 增加庄园税收 (要配合ac,否则会重开) +//#define _SYUTRY +/* ------------------------------------------------------------------- + * 新功能:PK星系 1121 人员:彦勋,小金 + */ +//#define _PKPETSHOP // (不可开) + +// ------------------------------------------------------------------- +//特殊活动功能 +//#define _CHECK_GAMESPEED // (不可开) ANDY 加速检测 +//#define _NPCSERVER_NEW // (不可开) ANDY NPC 伺服器 +//#define _OBJS_TALKFUN // (不可开) ANDY TALK 搜寻法 +#define _NEWOPEN_MAXEXP // (可开) ANDY MAX经验值 +//#define _MERGE_LOG // (不可开) ANDY 合成 LOG +//#define _CHECK_UCODE // (不可开) ANDY 检查 + +//#define _DEATH_FAMILYCONTEND // (不可开) ANDY 家族战报名 +//#define _NEW_INSERVERPOINT // (不可开) ANDY 登入座标 +//#define _DEATH_CONTENDWATCH // (不可开) ANDY 决斗观看 +//#define _DEATH_CONTENDTEST // (不可开) ANDY 死斗赛程加快 + +//#define _DEATH_FAMILY_GM_COMMAND // (可开) WON ADD 家族战GM指令 +//#define _DEATH_FAMILY_LOGIN_CHECK // (可开) WON ADD 家族战登入检查 +//#define _DEATH_FAMILY_STRUCT // (可开) WON ADD 家族战存放胜负资料 +//#define _DEATH_FAMILY_CANT_SCHEDULE // (可开) WON ADD 家族战玩家不能自行约战 + +//#define _ACTION_BULLSCR // (不可开) ANDY 蛮牛&朱雀 活动功能 (7/30以後才能关闭) +//#define _BULL_FIXPLAYER // (不可开) ANDY 修正人物蛮牛活动功能 +//#define _BULL_CUTBULLSCR // (不可开) ANDY 终止蛮牛活动积分 +//#define _ACTION_GMQUE // (不可开) ANDY GM活动功能 永保留 +//#define _PET_FUSIONSHOWTIME // (不可开) ANDY 宠物蛋秀时间 +//#define _NEW_PLAYERGOLD // (可开放) ANDY 新帐号给钱 +// ------------------------------------------------------------------- +//登入检查动作 + +//#define _FIX_TSKILLCAN // (可开放) ANDY 修正宠物T技罐头 以及 清除T字技(非机暴) +//#define _CHANGEGOATMETAMO // (可开放) Syu 羊年兽更换新图 + +// ------------------------------------------------------------------- +// 新功能:GM密频功能扩充 +//#define _GM_WARP_PLAYER // (不可开) WON 传送玩家 (北京&韩国不必开) +//#define _RECAL_ASK_PLAYER // (不可开) WON 要求人物资料 (北京&韩国不必开) +//#define _RECAL_SEND_COUNT // (不可开) WON 传送GS资讯 (北京&韩国不必开) +//#define _RECAL_SERVER_OFF // (不可开) WON MSERVER 关闭 GS (北京&韩国不必开) + +//#define _ENEMYTEMP_OPTIMUM // Robin EnemyBase table 最佳化 +//#define _ENEMY_OPTIMUM // Robin Enemy table 最佳化 +//#define _CHECK_BATTLETIME // Robin 纪录每一战斗指令时间(测试用) +//#define _CHECK_BATTLE_IO // Robin 纪录战斗封包传送(测试用) + +//复刻版 +//#define _BACK_VERSION //复刻版 +#define _REDHAT_V9 //(可开) Change 在REDHAT9.0的版本下编译时打开 +//#define _UN_FMPOINT // (可开) Change 关掉申请家族据点 +//#define _UN_FMMEMO //(可开)Change 关掉家族之间留言板 +//-------------------------------------------------------------------------- +//专案 7.5 精灵的招唤 人员:彦勋 奇铨 小威 +#define _NPC_EXCHANGEMANTRANS // (可开) Change 替exchangeman加入判断转生 +#define _ANGEL_SUMMON // Robin 天使召唤 + #ifdef _ANGEL_SUMMON + #define _ADD_NEWEVENT + #endif +// Terry define start ------------------------------------------------------------------- +#define _STREET_VENDOR // 摆摊功能(开放) +#define _WATCH_EVENT // 查询任务功能(开放) +#define _NEW_MANOR_LAW // 新庄园规则(开放) +#define _MAP_TIME // 特殊地图,会倒数(开放) +#define _PETSKILL_LER // 雷尔技能(开放) +#define _TEACHER_SYSTEM // 导师系统(开放) +// Terry define end ------------------------------------------------------------------- +#define _FIX_MAGIC_RESIST // (可开) Change 职业魔法抗性 +#define _ADD_DUNGEON // (可开) Change 追加地牢 +#define _PROFESSION_ADDSKILL // (可开) Change 追加职业技能 +#define _ITEM_ADDPETEXP // (可开) Change 增加宠物经验值道具(可吃此道具宠物,平常不可获得经验值) +#define _TRANS_6 // (可开) Change 人物6转 +#define _TRANS_7 // (可开) Change 人物7转 +#define _PET_2TRANS // (可开) Change 宠物2转 +#define _PET_2LIMITLEVEL // (可开) Change 帮助宠物2转的玛蕾 +#define _MAGICSTAUTS_RESIST // (可开) Change (火电冰)抗性精灵 +#define _EQUIT_RESIST // (可开) Change 单一装备抗性(可抗单一功能异常状态)有抗火 雷 冰 虚弱 魔障 沉默 落马 +#define _SUIT_TWFWENDUM // (可开) Change 四属性套装功能 (_SUIT_ITEM要开) +#define _EXCHANGEMAN_REQUEST_DELPET // (可开) Change 替exchangeman的TYPE:REQUEST增加删除宠物 +//#define _75_TEST // (不可开) 7.5测试server +//#define _PK_SERVER //百万pk活动 +//#define _DEATH_CONTEND // (可开) 百万pk活动 ANDY 死斗 +//#define _DEATH_CONTENDAB // (可开) 百万pk活动 ANDY 正式死斗 +//-------------------------------------------------------------------------- + +#define _ESCAPE_RESET // 恶宝逃跑後暂时不可组队 Robin 2004/07/22 +#define _DEL_DROP_GOLD // 删除地上过时的石币 Robin +#define _ITEM_STONE // cyg 奇怪的石头 +#define _HELP_NEWHAND // cyg 新创角色给予新手道具) +#define _DEF_FMFREETIME // cyg GM指令 退出家族时间限制设为0 +#define _DEF_GETYOU // cyg GM指令 查询自己两格 围内的玩家帐号 +#define _DEF_NEWSEND // cyg GM指令 传送玩家时可加句子也可不加 +#define _DEF_SUPERSEND // cyg GM指令 可传送已某帐号为中心附近3格内所有玩家 +#define _SUIT_ADDPART3 // (可开) Change 套装功能第叁弹 回避提高% 沉默抗性提高% 敏提高% 防提高% 攻提高% +#define _PETSKILL_2TIMID // (可开) Change 怯战第二版(狂狮怒吼) +#define CAVALRY_DEBUG // (暂时开) Change 座骑攻击除错中 +#define _SHOW_FUSION // (可开) Change 融合宠物在CLIENT端只显示转生数,修改为融合宠显示为融合(client端也要开) +#define _CONTRACT // (可开) Robin 契约功能 +#define _FONT_SIZE // (可开) Robin 字型大小功能 +#define _PROSK99 // (可开) Change 检查职技等级送白狼 +#define _TIME_TICKET // Robin 限时入场 森林捉宠用 +#define _HALLOWEEN_EFFECT // 万圣节特效 +#define _ADD_STATUS_2 // 新增传送人物状态第二类 +#define _ADD_reITEM // (可开) Change 检查道具栏位空格 +#define _ADD_NOITEM_BATTLE // 新增NPC检查人物身上没道具会进入战斗 +#define _PETSKILL_BATTLE_MODEL // 宠物技能战斗模组 +#define _RACEMAN // cyg 猎宠大会新npc +#define _PETSKILL_ANTINTER // (可开) Change 宠技:蚁之葬 参考_PETSKILL_2TIMID +#define _PETSKILL_REGRET // (可开) Change 宠技:憾甲一击 参考_SONIC_ATTACK +#define _SUIT_ADDPART4 // (可开) Change 套装功能第四弹 中毒攻击% 加强法师魔法(机率30%) 抵抗法师的魔法 + +//#define _CHECK_ENEMY_PET // (不可开) Change 检查玩家是否持有不可当宠物的角色(enemy.txt的petflg栏位为0代表不可拿来当宠物) +//#define _ITEM_TYPETABLE // (不可开) Change 追加typetable +//#define _MERGE_NEW_8 // Robin 8.0版 新合成规则 +//#define _RIGHTCLICK // Robin 滑鼠右键功能 +//#define _JOBDAILY // cyg 任务日志功能 +//#define _ALCHEMIST // Robin 精 功能 +//#define _CHECK_ITEM_MODIFY // 检查异常加强的道具 +//#define _PETSKILL_EXPLODE // (不可开) Change 宠技:爆裂攻击 + +//------------------------------------------------------------------------------------ +#define _ITEM_SETLOVER // 结婚功能 +#define _CREATE_MM_1_2 // 制作极品玛蕾菲雅 +#define _SendTo // 传送到玩家身边 +#define _GET_BATTLE_EXP // 经验设置 +#ifndef _NEW_TESTSERVER + #define _NEW_PLAYER_CF // 新手状态设置 +#endif +#define _USER_EXP_CF // 用户自定义经验 +#define _TRANS_LEVEL_CF // 转生超越160级设置 +#define _UNLAW_WARP_FLOOR // 禁止传送地区 +#define _UNREG_NEMA // 禁止人物名称 +#define _GM_ITEM // 玩家GM命令物品 +#define _GM_METAMO_RIDE // GM人物骑所有宠 +#define _GM_RIDE // GM命令设置骑宠权限 +#define _LOCK_IP // 锁定IP +#endif diff --git a/gmsv/include/version.h.bak b/gmsv/include/version.h.bak new file mode 100644 index 0000000..24ce181 --- /dev/null +++ b/gmsv/include/version.h.bak @@ -0,0 +1,570 @@ +#ifndef __VERSION_H__ +#define __VERSION_H__ +#include "correct_bug.h" //BUG FIX +#include "version_pk.h" //PK SERVER + +/*Server 版本控制*/ +#define _NEW_SERVER_ +#define _SERVER_NUMS +#define SERVER_VERSION "龙zoro版GMSV服务端v1.5" + +#define UNIQUE_KEYCODEITEM 100 +#define UNIQUE_KEYCODEPET "i" + +#define _SA_VERSION_70 // (可开放) WON ADD 石器时代7.0 的版本控制 +//#define _DEFAULT_PKEY "Wonwonwon" // (可开放)( 石器 6.0 ) +//#define _RUNNING_KEY "11111111" // (可开放)( 石器 6.0 ) +#define _DEFAULT_PKEY "ttttttttt" // (可开放)( 石器 6.0 ) +#define _RUNNING_KEY "20041215" // (可开放)( 石器 6.0 ) + +#define _VERSION_20010911 // (可开放) 9.11 编码修改 + +// ------------------------------------------------------------------- +//新功能:测试伺服器专用 人员:彦豪 +#define _TEST_PETCREATE // (不可开) ANDY 测宠的GM指令 +//#define _LOGIN_ADDITEM // (不可开) ANDY 登入加满物品 +//#define _NEW_TESTSERVER // (不可开) ANDY 玩家创新人物时,给予五转125等级及叁只宠物 +//#define _TEST_PETFUSIONTIME // (不可开) ANDY 测试宠物融合 食时间加快 +/* ------------------------------------------------------------------- + * 专案:家族庄园数量修改 人员:小瑜、彦勋、志伟、小民 + */ + +/* +修改装园数量方式: +Account Server 程式: + acfamily.h MAX_FMPOINT要修改 +Account Server 游戏环境: + saac/family/fmpoint/db_fmpoint档案中须新增庄园入口坐标等设定 + 庄园进入图层|庄园进入X座标|庄园进入Y座标|庄园族长图层|庄园邻近之村庄|占领庄园之家族 index|占领庄园之家族 name|占领庄园之家族综合声望值 + 例如: + 100|607|563|1041|1|3|shan|3132238 + 200|73|588|2031|2||| +Game Server 程式: + version.h FAMILY_MAXHOME、MANORNUM要修正 + family.c FM_PKFLOOR 须增设战斗图层 + FAMILY_RidePet() 中须加入族长家图层 + FAMILY_LeaderFunc() 中须加入邀请函id + npcutil.c addNpcFamilyTax function中须加入(庄园图层%100)此为庄园税收部份 +Game Server 游戏环境: + gmsv_v2/data/npc/family/manorsman.arg* id须修正 + gmsv_v2/data/npc/family/scheduleman.arg* id须修正 +*/ + +#define _FAMILY_MANORNUM_CHANGE // CoolFish 用来修改装园数量(4.0) +#ifdef _FAMILY_MANORNUM_CHANGE +#define FAMILY_MAXHOME 9 // (4.0) 家族据点 +#define MANORNUM 9 // (4.0) 庄园数量 +#define FMPOINTNUM 9 // (4.0) 有据点家族的最大数量 +#endif +#define _FMVER21 // (可开放) 家族职掌功能 +#define _PERSONAL_FAME // (可开放) Arminius 8.30 家族个人声望 +// ------------------------------------------------------------------- +//专案:石器活动自动化 人员:晓威、家麟 +#define _SERVICE // (可开放) Terry 2001/10/03 活动功能自动化 + +#define _EVERYONE_RIDE // (可开放) Robin 0924 骑宠平民化 +// ------------------------------------------------------------------- +//专案:攻击性咒术的制作 人员:笃志 +// #define __ATTACK_MAGIC_MSG // (不开放) +#define __ATTACK_MAGIC // (可开放) 提供战场中的攻击性咒术 +#define _ADD_ACTION // (可开放) 一般NPC动作状况的设定 + +// ------------------------------------------------------------------- +//专案:宠物、道具编码 人员:小瑜 +#define _UNIQUE_P_I // (可开放) CoolFish 2001/10/11 + +// ------------------------------------------------------------------- +//专案:新版人物储存pn 及 当机不回朔 1018 人员:彦勋 +#define _NEWSAVE // (可开放) Robin +#define _STORECHAR // (可开放) Robin +#define _DROPCHECK // (可开放) Robin 防止重复丢道具 +#define _DROPCHECK2 // (可开放) Robin 防止重复丢道具 +// ------------------------------------------------------------------- +//专案 : 精灵王 人员 : 彦豪 +#define _PET_TRANS // (可开放) 宠物转生功能 +#define _NEW_WARPMAN // (可开放) NPC多重WARP功能 +#define _PET_TALK // (可开放) 宠物对话 +#define _PET_LIMITLEVEL // (可开放) 特殊宠设计(玛蕾) +#define _MAP_NOEXIT // (可开放) 特殊地图不得原登&原登回指定点 +// ------------------------------------------------------------------- +// 专案:GM指令、层级Reload 人员:小瑜 +#define _GMRELOAD // (可开放) CoolFish: 2001/11/12 +// ------------------------------------------------------------------- +// 专案:伊甸大陆 人员:彦豪、阿民、小瑜 +#define _GAMBLE_ROULETTE // (可开放) 彦豪 赌场轮盘 宝宝小猪 +#define _FIX_GAMBLENUM // (可开放) 轮盘修正 : 下线扣积分 +#define _GAMBLE_BANK // (可开放) 彦豪 赌场银行 +#define _DROPSTAKENEW // (可开放) CoolFish: 赌场下注 +#define _PETRACE // (可开放) CoolFish: 2001/12/3 宠物竞速场 +#define _NEWEVENT // (可开放) CoolFish: 2001/12/5 新的任务旗标 +//#define _BIGSMALL // (不可开) Arminius 12.15 骰子比大小 +//#define _AUCTIONEER // (不可开) Arminius 12.20 拍卖店 +// ------------------------------------------------------------------- +//专案:鞭炮制作 人员:晓威 +#define _ITEM_FIRECRACKER // (可开放) 战斗中使用鞭炮可以把年兽吓走 +// ------------------------------------------------------------------- +//新功能:庄园PK规则(酷哥定的) 人员:志伟、志旺 +#define _MANOR_PKRULE // (可开放) +#define _MANOR_FIXFMPK // (可开放) WON ADD 家族约战的 GM 指令,测试用的 +// ------------------------------------------------------------------- +// 新功能:新功能&宠物技能 人员:彦豪 +#define _PSKILL_FALLGROUND // (可开放) 宠物技能 (落马术) +#define _ENEMY_FALLGROUND // (可开放) NPC 落马 +#define _BATTLE_NEWPOWER // (可开放) +#define _Item_MoonAct // (可开放) 月神的守护 +#define _Item_DeathAct // (可开放) 恶魔的首饰 +#define _Item_PetAct // (可开放) 驯兽戒指 +#define _Item_ReLifeAct // (可开放) 需要itemset1.txt 才能开) 替身娃娃 +#define _BATTLESTEAL_FIX // (可开放) 修正偷窃 +#define _CFREE_petskill // (可开放) 需要petskill1.txt 才能开) 新学习宠物技能技能 +#define _data_newreadfile // (可开放) 新的server setup.cf 档案 包含 itemset1.txt petskill1.txt 两个新档 +#define _ITEM_MAXUSERNUM // (可开放) 新 itemset1.txt ITEM 使用次数 +// ------------------------------------------------------------------- +//新功能:伊甸二期 人员:彦豪 +#define _PET_TALKPRO // (可开放) 宠物对话加强 & 改 END +#define _PRO_NPCFIX // (可开放) NPC功能加强 +#define _PRO_BATTLEENEMYSKILL // (可开放) 战斗加强 提升NPC的AI技能 +#define _NEW_WARPPOINT // (可开放) 传送点多重条件判断WARP +#define _FIX_CHECKITEM // (可开放) 道具不做非法检查 +// ------------------------------------------------------------------- +//新功能:伊甸二 人员:小民,WON +#define _ADD_ENCOUNT // (可开放) WON 增加敌遭遇触发修件 +#define _WON_PET_MAIL_LOG // (可开放) WON 玩家寄宠邮 LOG +// ------------------------------------------------------------------- +// 新功能:伊甸叁期 4.0 人员:彦豪, 志伟 , 又荣 , 志旺 +//#define _LOSE_FINCH_ // (不可开) ANDY 朱雀技能 +#define _FIX_FAMILY_PK_LIMIT // (可开放) WON 将可挑战庄园的由前十大改为前二十大 +#define _ADD_POOL_ITEM // (可开放) WON 增加可寄放的道具 +#define _ITEM_METAMO // (可开放) shan metamo sprite. code:robin->shan +#define _ENEMY_ATTACK_AI // (可开放) shan enemy attack mode. code:shan +#define _ITEM_TIME_LIMIT // (可开放) shan time limit of item. code:shan +#define _MIND_ICON // (可开放) shan show icon from char mind. code:shan +#define _BATTLENPC_WARP_PLAYER // (可开放) shan npc warp player when n round. code:shan +#define _ITEM_WARP_FIX_BI // (可开放) shan fix bbi to bi. code:shan +#define _SKILL_DAMAGETOHP // (可开放) ANDY 嗜血技 +#define _Skill_MPDAMAGE // (可开放) ANDY MP伤害 +#define _WAEI_KICK // (可开放) ANDY 跨星球踢人 +#define _BATTLE_TIMESPEED // (可开放) ANDY 战斗时间 测试(北京不必开,挡加速功能) +#define _NEW_RIDEPETS // (可开放) ANDY 新骑宠 +#define _FIXBUG_ATTACKBOW // (可开放) ANDY 修正骑宠使用投掷武器bug +#define _NPCCHANGE_PLAYERIMG // (可开放) ANDY NPC改变玩家图号, 强制落马,认玩家图号 (测完) +#define _ITEM_ATTSKILLMAGIC // (可开放) ANDY 道具技能 +#define _EQUIT_DEFMAGIC // (可开放) ANDY 抗魔装备 +#define _FIX_MAGICDAMAGE // (可开放) ANDY 修正魔法公式 叁期开放 +#define _ITEM_CONSTITUTION // (可开放) ANDY 修正个人体质 +#define _MAGIC_REHPAI // (可开放) ANDY 补血AI +#define _TRANSER_MAN // (可开放) ANDY 传送师 +#define _TAKE_ITEMDAMAGE // (可开放) ANDY 道具损坏 ITEMSET2 +#define _FIX_FIRECRACKER // (可开放) ANDY 修正 鞭炮 +#define _FIX_ITEMPROB // (可开放) ANDY 修正 掉宝率 +#define _ADD_DEAMGEDEFC // (可开放) ANDY 额外伤害 & 附加攻击 ITEMSET2 +#define _FIX_MAXCHARMP // (可开放) ANDY MP上限 +#define _ITEM_INSLAY // (可开放) ANDY 镶宝石 动作 +#define _ITEMSET2_ITEM // (可开放) ANDY ITEMSET2 +#define _ITEM_NPCCHANGE // (可开放) ANDY 工匠 (提炼, 精工) +#define _PETSKILL_FIXITEM // (可开放) ANDY 修复 && 同道具损坏 +#define _FIX_SETWORKINT // (可开放) ANDY (FIXWORKINT) +#define _ITEM_ADDEXP // (可开放) vincent 道具:指定时间内增加经验值上升幅度 +#define _ITEM_ADDEXP2 // 智果时间可以累加 Robin +#define _FIX_METAMORIDE // (可开放) ANDY +//#define _M_SERVER // (可开放) GM SERVER (北京&韩国不必开) +//#define _FIX_MSERVER // (可开放) GM SERVER PROC (北京&韩国不必开) +#define _CHECK_ITEMDAMAGE // (可开放) 道具损坏修正 7/26 +#define _SKILL_WILDVIOLENT_ATT // (可开放) vincent 宠技:狂暴攻击 +#define _MAGIC_WEAKEN // (可开放) vincent 精灵:虚弱 +#define _SKILL_WEAKEN // (可开放) vincent 宠技:虚弱//需要开#define _MAGIC_WEAKEN +#define _SKILL_SPEEDY_ATT // (可开放) vincent 宠技:疾速攻击 +#define _SKILL_GUARDBREAK2 // (可开放) vincent 宠技:破除防御2 +#define _SKILL_SACRIFICE // (可开放) vincent 宠技:救援 +#define _PSKILL_MODIFY // (可开放) ANDY 属性强化攻击 +#define _PSKILL_MDFYATTACK // (可开放) ANDY 攻击转化属性 +#define _MAGIC_DEFMAGICATT // (可开放) ANDY 魔法防御 +#define _MAGIC_SUPERWALL // (可开放) ANDY 铁壁防御 +#define _OTHER_MAGICSTAUTS // (可开放) ANDY +#define _SKILL_TOOTH // (可开放) ANDY 齿术 +#define _MAGIC_DEEPPOISON // (可开放) vincent 精灵:剧毒 +#define _MAGIC_BARRIER // (可开放) vincent 精灵:魔障 +#define _MAGIC_NOCAST // (可开放) vincent 精灵:沉默 +#define _ITEM_CRACKER // (可开放) vincent 道具:拉炮 //需要开#define _MIND_ICON +#define _SKILL_DEEPPOISON // (可开放) vincent 宠技:剧毒 //需要开#define _MAGIC_DEEPPOISON +#define _SKILL_BARRIER // (可开放) vincent 宠技:魔障 //需要开#define _MAGIC_BARRIER +#define _SKILL_NOCAST // (可开放) vincent 宠技:沉默 //需要开#define _MAGIC_NOCAST +#define _SKILL_ROAR // (可开放) vincent 宠技:大吼(克年兽) +#define _SKILL_REFRESH // (可开放) vincent 宠技:解除异常状态 +#define _ITEM_REFRESH // (可开放) vincent 解除异常状态道具 +#define _MAGIC_TOCALL // (可开放) kjl 召唤 02/06/20 kjl + +// ------------------------------------------------------------------- +// 新功能:来吉卡功能 人员:彦豪 +#define _ITEMSET3_ITEM // (可开放) ANDY itemset3.txt +#define _SUIT_ITEM // (可开放) ANDY (套装) 来吉卡 需用itemset3.txt +#define _PETSKILL_SETDUCK // (可开放) ANDY 蒙奇技能 +#define _VARY_WOLF // (可开放) pet skill : vary wolf. code:shan +// ------------------------------------------------------------------- +// 新功能:专案5.0 人员: +//#define _ITEMTBL_STAIC // (不可开) ANDY (静态ITEMTBL) +#define _USEWARP_FORNUM // (可开放) ANDY 记忆羽毛 来吉卡 +#define _IMPRECATE_ITEM // (可开放) ANDY 特殊道具 来吉卡 +#define _MAGICPET_SKILL // (可开放) ANDY 魔法宠技能 +#define _ITEM_CHECKWARES // (可开放) ANDY 锁定传送不能 +#define _NPC_REPLACEMENT // (可开放) ANDY 置换战斗npc +#define _EMENY_CHANCEMAN // (可开放) ANDY EMENY 选择 +#define _TYPE_TOXICATION // (可开放) ANDY 中毒无法回血 +#define _PET_FUSION // (可开放) ANDY 宠物融合 enemybase1.txt +#define _NPC_FUSION // (可开放) ANDY NPC宠物融合 +#define _ITEM_EDITBASES // (可开放) ANDY 营养剂 +#define _PET_EVOLUTION // (可开放) ANDY 进化表 + +// ------------------------------------------------------------------- +// 新功能:5.0追加部分 人员: +#define _AVID_TRADETRYBUG // (可开放) ANDY 防止交易中丢宠/道具 寄(宠物)邮件 石币 +#define _ASSESS_SYSEFFICACY // (可开放) ANDY 评估系统效能 12/04 更新 +#define _ASSESS_SYSEFFICACY_SUB // (可开放) Robin 评估系统效能 增加检查内回圈 +#define _PREVENT_TEAMATTACK // (可开放) ANDY 防止同队互打 12/04 更新 +#define _ITEM_ORNAMENTS // (可开放) ANDY 装饰道具 12/04 更新 //出版部 +#define _CHIKULA_STONE // (可开放) ANDY 奇克拉之石 12/04 更新 //来吉卡 宠包 +#define _SEND_EFFECT // (可开放) WON AC送下雪、下雨等特效 12/04 更新 +#define _PETMAIL_DEFNUMS // (可开放) ANDY 宠物邮件限制 +#define _TEAM_KICKPARTY // (可开放) ANDY 队长踢人(非战斗状态) +#define _PETSKILL_TIMID // (可开放) ANDY 宠技-怯战 +#define _PETS_SELECTCON // (可开放) ANDY 宠物不可点选出战 +#define _CHRISTMAS_REDSOCKS // (可开放) ANDY 圣诞红袜 +#define _FIX_ARRAYBUG // (可开放) ANDY 修正array 溢位 +#define _USER_CHARLOOPS // (可开放) ANDY 新用物件LOOP +#define _BATTLE_PROPERTY // (可开放) ANDY 战斗属性特性 +#define _PETSKILL_PROPERTY // (可开放) ANDY 无属魔兽宠技 +#define _ITEM_FIXALLBASE // (可开放) ANDY 修复之石 +#define _ITEM_LOVERPARTY // (可开放) ANDY 情人节道具 +#define _ITEM_FORUSERNAMES // (可开放) ANDY 道具所有人 +#define _BATTLECOMMAND_TIME // (可开放) ANDY 防止玩家开缓速(回合战斗时间) +#define _NPCENEMY_ADDPOWER // (可开放) ANDY 修改怪物的能力值 +//#define _BAD_PLAYER // (不可开) WON 送坏玩家去关 + + +// ------------------------------------------------------------------- +// 新功能:专案6.0 人员: +// +#define _PETSKILL_CANNEDFOOD // (可开放) ANDY 宠物技能罐头 for 6.0 +#define _TEST_DROPITEMS // (可开放) ANDY 测试丢宠 +#define _MAP_WARPPOINT // (可开放) ANDY Map WarpPoint +//#define _AUTO_ADDADDRESS // (可开放) ANDY 自动新增名片 +#define _DEFEND_TIMECHECK // (可开放) ANDY 内部测试时间 +#define _TREASURE_BOX // (可开放) ANDY 宝箱 +#define _BENEMY_EVENTRUN // (可开放) ANDY 战斗npc给道具 +#define _BATTLE_ABDUCTII // (可开放) ANDY 旅途夥伴2 +#define _BATTLE_LIGHTTAKE // (可开放) ANDY 采光术 +#define _BATTLE_ATTCRAZED // (可开放) ANDY 疯狂暴走 +#define _STATUS_WATERWORD // (可开放) ANDY 水世界状态 +#define _ITEM_WATERWORDSTATUS // (可开放) ANDY 水世界状态道具 +//#define _KILL_12_STOP_GMSV // (可开放) WON 下sigusr2後关闭GMSV +//#define _DELBORNPLACE // (可开放) Syu 6.0 统一出生於新手村 +#define _REEDIT_PETBBIS // (可开放) ANDY 修正宠物波比图形 +#define _CAPTURE_FREES // (可开放) ANDY 补抓条件 +#define _THROWITEM_ITEMS // (可开放) 丢掷後有奖品 +#define _OBJSEND_C // (可开放) ANDY _OBJSEND_C +#define _ADD_SHOW_ITEMDAMAGE // (可开放) WON 显示物品耐久度 + +//-------------------------------------------------------------------------- +//专案 7.0 职业系统 人员:彦豪 志旺 旭诚 奇铨 + +#define _CHANGETRADERULE // (可开放) Syu ADD 交易规则修订 +#define _TRADE_SHOWHP // (可开放) Syu ADD 交易显示血量 +#define _SHOOTCHESTNUT // (可开放) Syu ADD 宠技:丢栗子 +#define _SKILLLIMIT // (可开放) Syu ADD 不得攻击我方限制 +#define _TRADESYSTEM2 // (可开放) Syu ADD 新交易系统 +#define _NPC_NOSAVEPOINT // (可开放) ANDY 纪录点不存人物资料 +#define _ACFMPK_LIST // (可开放) ANDY 家族对战列表修正 +#define _PETSKILL2_TXT // (可开放) ANDY petskill2.txt +#define _PETSKILL_CHECKTYPE // (可开放) ANDY 宠物技能使用时机 +#define _PETSKILL_TEAR // (可开放) ANDY 宠技 撕裂伤口 +#define _NPC_MAKEPAIR // (可开放) ANDY NPC 配对 +#define _ITEMSET4_TXT // (可开放) ANDY itemset4.txt +#define _ITEM_PILENUMS // (可开放) ANDY 道具素材堆叠 需 itemset4 +#define _ITEM_PILEFORTRADE // (可开放) ANDY 交易堆叠 +#define _ITEM_EQUITSPACE // (可开放) ANDY 新装备栏位 +#define _PET_LOSTPET // (可开放) ANDY 遗失宠物搜寻计划宠物 +#define _ITEMSET5_TXT // (可开放) ANDY itemset5.txt +#define _ITEMSET6_TXT // (可开放) ANDY itemset6.txt +#define _EQUIT_ARRANGE // (可开放) ANDY 挡格 需要 itemset5.txt +#define _EQUIT_SEQUENCE // (可开放) ANDY 攻击顺序 需要 itemset5.txt +#define _EQUIT_ADDPILE // (可开放) ANDY 增加可堆叠数 需要 itemset5.txt +#define _EQUIT_HITRIGHT // (可开放) ANDY 命中 需要 itemset5.txt +#define _EQUIT_NEGLECTGUARD // (可开放) ANDY 忽视目标防御力% 需要 itemset6.txt +#define _EQUIT_NEWGLOVE // (可开放) ANDY 手套栏位 +#define _FM_JOINLIMIT // (可开放) ANDY 加入家族条件限制 +#define _FIX_MAX_GOLD // (可开放) WON ADD 增加人物金钱上限 +#define _CK_ONLINE_PLAYER_COUNT // (可开放) WON 计算线上人数 (要配合ac,否则会重开) +#define _PET_SKILL_SARS // (可开放) WON ADD 毒煞蔓延 +#define _SONIC_ATTACK // (可开放) WON ADD 音波攻击 +#define _NET_REDUCESEND // (可开放) ANDY 减少DB资料传送 +#define _FEV_ADD_NEW_ITEM // (可开放) Change 增加复活守精 +#define _ALLDOMAN // (可开放) Syu ADD 排行榜NPC +#define _LOCKHELP_OK // (可开放) Syu ADD 锁定不可加入战斗 +#define _TELLCHANNEL // (可开放) Syu ADD 密语频道 +// 新功能:职业 +#define _NEWREQUESTPROTOCOL // (可开放) Syu ADD 新增Protocol要求细项 +#define _OUTOFBATTLESKILL // (可开放) Syu ADD 非战斗时技能Protocol +#define _CHAR_PROFESSION // (可开放) WON ADD 人物职业栏位 +#define _PROFESSION_SKILL // (可开放) WON ADD 人物职业技能 +#define _NPC_WELFARE // (可开放) WON ADD 职业NPC +#define _PROFESSION_FIX_LEVEL // (可开放) WON ADD 修正职业经验值(北京&韩国不必开) +#define _GM_SIGUSR2 // (可开放) Change 下达sigusr2後执行 gm_sigusr_command档案内的GM指令,若没有指令就关闭GMSV +#define _GM_BROADCAST // (可开放) WON ADD 客服公告系统 +#define _NPC_ADDLEVELUP // (可开放) ANDY NPC增加玩家等级 +#define _CHAR_FIXDATADEF // (可开放) ANDY 修正人物资料初始 +//系统改良 +#define _SIMPLIFY_ITEMSTRING // (可开放) ANDY 简化道具字串 +#define _CHAR_NEWLOGOUT // (可开放) ANDY 登出新机制 +#define _CHATROOMPROTOCOL // (可开放) Syu ADD 聊天室频道 8/27 + +#define _CHAR_POOLITEM // (可开放) ANDY 人物道具仓库共用 +#define _NPC_DEPOTITEM // (可开放) ANDY 人物道具仓库共用 + +#define _SIMPLIFY_PETSTRING // (可开放) ANDY 简化宠物存档字串 +#define _SIMPLIFY_ITEMSTRING2 // (可开放) ANDY 简化道具字串2 +#define _WOLF_TAKE_AXE // (可开放) WON ADD 抓双头狼的限制 +#define _FIX_UNNECESSARY // (可开放) ANDY 修正不必要的判断 +#define _ITEM_MAGICRECOVERY // (可开放) ANDY 新光镜守 +//9/17更新 +#define _PETSKILL_GYRATE // (可开放) Change 宠技:回旋攻击 +#define _PETSKILL_ACUPUNCTURE // (可开放) Change 宠技:针刺外皮 (client端的_PETSKILL_ACUPUNCTURE也要开) +#define _PETSKILL_RETRACE // (可开放) Change 宠技:追迹攻击 +#define _PETSKILL_HECTOR // (可开放) Change 宠技:威吓 +//10/13更新 +#define _PETSKILL_FIREKILL // (可开放) Change 宠技:火线猎杀 +#define _PETSKILL_DAMAGETOHP // (可开放) Change 宠技:暗月狂狼(嗜血技的变体) +#define _PETSKILL_BECOMEFOX // (可开放) Change 宠技:媚惑术 +//10/22更新 +// 新功能:修改WORKER(新付费机制) +#define _FIX_MESSAGE // (可开放) WON ADD 修改WORKER封包内容 (北京&韩国不必开) + +//11/12更新 +#define _PETSKILL_SHOWMERCY // (可开) Change 宠技:手下留情 +#define _NPC_ActionFreeCmp // (可开) Change 替NPC参数加入新的比较方式 +//-------------------------------------------------------------------------- + + +//11/26 +#define _NPC_ProfessionTrans // (可开) Change 替职业NPC加入判断转生 +#define _NPC_NewDelPet // (可开) Change 替NPC加入删除宠物(原本就有了,只是用warpman使用时不成功,所以先做一个顶一下) +//#define _MUSEUM // 石器博物馆 Robin 2003/11 + #ifdef _MUSEUM + #define _DELBORNPLACE + #endif +#define _CHANGEGALAXY // (可开) 星系移民 Robin 2003/10 +#define _ALLDOMAN_DEBUG // (可开) Change 修正重启server後排行榜消失bug +//20031217 +#define _CHRISTMAS_REDSOCKS_NEW // (可开) Change 新圣诞红袜 +#define _PETSKILL_COMBINED // (可开) Change 宠技:难得糊涂 [综合魔法(依参数乱数取出魔法)] +//情人节活动 +#define _NPC_ADDWARPMAN1 // (可开放) Change npcgen_warpman增加功能(设定组队人数、设定组队男女人数) +#define _ITEM_QUITPARTY // (可开放) Change 队伍解散时特定道具即会消失 +#define _ITEM_ADDEQUIPEXP // (可开) Change 装备後经验值增加 +//2004/2/18 +#define _ITEM_LVUPUP // (可开) Change 突破宠物等级限制的药(玄武专用) +//2004/02/25 +#define _PETSKILL_BECOMEPIG // (可开) Change 宠技:乌力化 +#define _ITEM_UNBECOMEPIG // (可开) Change 乌力化的解药 +#define _PET_TALKBBI // (可开) Change 增加判断bbi +#define _ITEM_USEMAGIC // (可开) Change 由道具使用魔法 +//2004/04/07 +#define _ITEM_PROPERTY // (可开) Change 改变四属性道具 +#define _SUIT_ADDENDUM // (可开) Change 替套装增加功能 (_SUIT_ITEM要开) +//2004/05/05 +#define _ITEM_CHECKDROPATLOGOUT // (可开) Change 检查回纪录点时身上有无登出後消失道具,若有,不可回纪录点 +#define _FM_MODIFY // 家族功能修改(开放) +#define _CHANNEL_MODIFY // 频道功能整合(开放) +#define _STANDBYPET // Robin 待机宠封包 +#define _PROSKILL_OPTIMUM // Robin 职业技能处理最佳化 +#define _PETSKILL_OPTIMUM // Robin 宠物技能处理最佳化 +#define _MAGIC_OPTIMUM // Robin Magic table 最佳化 +#define _AC_PIORITY // Nuke 提高AC的优先权(可开) +//2004/05/12 +#define _CHAR_POOLPET // (可开放) Robin 人物宠物仓库共用 +#define _NPC_DEPOTPET // (可开放) Robin 人物宠物仓库共用 +#define _TIMEOUTKICK // (可开) 时段制踢人 Robin 2003/10 +#define _MAGIC_RESIST_EQUIT // (可开) WON ADD 职业抗性装备 +#define _LOG_OTHER // 杂项讯息专用LOG + +//-------------------------------------------------------------------------- +//机动营测试中 + + +// ------------------------------------------------------------------- +//#define _NPC_QUIZSCOPE // (不可开) Change 替NPC增加题号 围参数 +//#define _ITEM_ADDCOMBO // (不可开) Change 装备後合击率增加(战场上要有2个人以上带才有用)未完成... +//#define _NPC_AIRDELITEM // (不可开) Change 搭加美航空时所扣除的道具(就是飞机票啦) +//#define _NPC_AIRLEVEL // (不可开) Change 搭加美航空的最大最等级限制(等级过高不给搭) + +//#define _ANDYLOG_TEST +//#define _NPC_WELFARE_2 // (不可开) WON ADD 职业NPC-2 +//#define _UNIVERSE_CHATROOM // (不可开) ANDY 全星系聊天 +//#define _FIX_ALLDOMAN // (不可开) ANDY 修正英雄战场 +//制作中 +//#define _SEND_PROF_DATA // (不可开) ANDY ADD 传送职业更新给cli +//#define _AUCPROTOCOL // (不可开) Syu ADD 拍卖频道开关Protocol +//#define _NPC_SELLSTH // (不可开) ANDY 拍卖系统 +//#define _NPC_SEPARATEDATA // (不可开) ANDY NPC 资料分离 + +//------------------------------------------------------------------------ +// 以下为冻结功能 +//------------------------------------------------------------------------ +//#define fix_login_event // (不可开) WON 补回伊甸一期的声望 (北京不必开) +//#define _FIX_DEL_MAP // (不可开) WON 玩家抽地图送监狱 +//#define _PETFIGHT // (不可开) 宠物竞技场 +//#define _EXM_RANDITEM // (不可开) NPC (Exchangeman) 乱数要求物品 (已取消) +//#define add_amulet_map // (不可开) WON 增加太阳神首饰的 围 +//#define _ACFMPK_NOFREE // (不可开) ANDY 家族无条件 +//-------------------------------------------------------------------------- +// 6.0追加功能 pile + +//#define _IMPOROVE_ITEMTABLE // (不可开) ANDY 改善ITEM TABLE +//#define _NPC_SHOPALTER01 // (不可开) Change 买卖系统修改(配合Client改为图形介面所做的修改) +#define _GM_IDENTIFY // (不可开) Change 是否秀出GM头顶上识别字串的GM指令 +//#define _GSERVER_RUNTIME // (不可开) Change 传送GSERVER执行多少时间给Mserver (Mserver要配合) +//#define _NPC_VERYWELFARE // (不可开) Change 非常好康A的NPC +//-------------------------------------------------------------------------- +//#define _ADD_NEWEVENT // (不可开) WON 多增任务旗标 +//#define _BLACK_MARKET // (不可开) shan a black market. code:shan +//#define _DYNAMIC_BUILDER_MAP // (不可开) shan (test)dynamic builder on the upper map. code:shan +//#define _TEST_ITEMMEMORY // (不可开) ANDY (测试ITEMTABL) +//#define _LASTERR_FUNCTION // (不可开) ANDY (lastFunction) +//#define _MARKET_TRADE // (不可开) ANDY 交易市集 +//#define _PAUCTION_MAN // (不可开) ANDY +//#define _SKILL_SELFEXPLODE // (不可开) vincent 宠技:自爆(缺图) +//#define _ADD_FAMILY_TAX // (不可开) WON 增加庄园税收 (要配合ac,否则会重开) +//#define _SYUTRY +/* ------------------------------------------------------------------- + * 新功能:PK星系 1121 人员:彦勋,小金 + */ +//#define _PKPETSHOP // (不可开) + +// ------------------------------------------------------------------- +//特殊活动功能 +//#define _CHECK_GAMESPEED // (不可开) ANDY 加速检测 +//#define _NPCSERVER_NEW // (不可开) ANDY NPC 伺服器 +//#define _OBJS_TALKFUN // (不可开) ANDY TALK 搜寻法 +#define _NEWOPEN_MAXEXP // (可开) ANDY MAX经验值 +//#define _MERGE_LOG // (不可开) ANDY 合成 LOG +//#define _CHECK_UCODE // (不可开) ANDY 检查 + +//#define _DEATH_FAMILYCONTEND // (不可开) ANDY 家族战报名 +//#define _NEW_INSERVERPOINT // (不可开) ANDY 登入座标 +//#define _DEATH_CONTENDWATCH // (不可开) ANDY 决斗观看 +//#define _DEATH_CONTENDTEST // (不可开) ANDY 死斗赛程加快 + +//#define _DEATH_FAMILY_GM_COMMAND // (可开) WON ADD 家族战GM指令 +//#define _DEATH_FAMILY_LOGIN_CHECK // (可开) WON ADD 家族战登入检查 +//#define _DEATH_FAMILY_STRUCT // (可开) WON ADD 家族战存放胜负资料 +//#define _DEATH_FAMILY_CANT_SCHEDULE // (可开) WON ADD 家族战玩家不能自行约战 + +//#define _ACTION_BULLSCR // (不可开) ANDY 蛮牛&朱雀 活动功能 (7/30以後才能关闭) +//#define _BULL_FIXPLAYER // (不可开) ANDY 修正人物蛮牛活动功能 +//#define _BULL_CUTBULLSCR // (不可开) ANDY 终止蛮牛活动积分 +//#define _ACTION_GMQUE // (不可开) ANDY GM活动功能 永保留 +//#define _PET_FUSIONSHOWTIME // (不可开) ANDY 宠物蛋秀时间 +//#define _NEW_PLAYERGOLD // (可开放) ANDY 新帐号给钱 +// ------------------------------------------------------------------- +//登入检查动作 + +//#define _FIX_TSKILLCAN // (可开放) ANDY 修正宠物T技罐头 以及 清除T字技(非机暴) +//#define _CHANGEGOATMETAMO // (可开放) Syu 羊年兽更换新图 + +// ------------------------------------------------------------------- +// 新功能:GM密频功能扩充 +//#define _GM_WARP_PLAYER // (不可开) WON 传送玩家 (北京&韩国不必开) +//#define _RECAL_ASK_PLAYER // (不可开) WON 要求人物资料 (北京&韩国不必开) +//#define _RECAL_SEND_COUNT // (不可开) WON 传送GS资讯 (北京&韩国不必开) +//#define _RECAL_SERVER_OFF // (不可开) WON MSERVER 关闭 GS (北京&韩国不必开) + +//#define _ENEMYTEMP_OPTIMUM // Robin EnemyBase table 最佳化 +//#define _ENEMY_OPTIMUM // Robin Enemy table 最佳化 +//#define _CHECK_BATTLETIME // Robin 纪录每一战斗指令时间(测试用) +//#define _CHECK_BATTLE_IO // Robin 纪录战斗封包传送(测试用) + +//复刻版 +//#define _BACK_VERSION //复刻版 +#define _REDHAT_V9 //(可开) Change 在REDHAT9.0的版本下编译时打开 +//#define _UN_FMPOINT // (可开) Change 关掉申请家族据点 +//#define _UN_FMMEMO //(可开)Change 关掉家族之间留言板 +//-------------------------------------------------------------------------- +//专案 7.5 精灵的招唤 人员:彦勋 奇铨 小威 +#define _NPC_EXCHANGEMANTRANS // (可开) Change 替exchangeman加入判断转生 +#define _ANGEL_SUMMON // Robin 天使召唤 + #ifdef _ANGEL_SUMMON + #define _ADD_NEWEVENT + #endif +// Terry define start ------------------------------------------------------------------- +#define _STREET_VENDOR // 摆摊功能(开放) +#define _WATCH_EVENT // 查询任务功能(开放) +#define _NEW_MANOR_LAW // 新庄园规则(开放) +#define _MAP_TIME // 特殊地图,会倒数(开放) +#define _PETSKILL_LER // 雷尔技能(开放) +#define _TEACHER_SYSTEM // 导师系统(开放) +// Terry define end ------------------------------------------------------------------- +#define _FIX_MAGIC_RESIST // (可开) Change 职业魔法抗性 +#define _ADD_DUNGEON // (可开) Change 追加地牢 +#define _PROFESSION_ADDSKILL // (可开) Change 追加职业技能 +#define _ITEM_ADDPETEXP // (可开) Change 增加宠物经验值道具(可吃此道具宠物,平常不可获得经验值) +#define _TRANS_6 // (可开) Change 人物6转 +#define _TRANS_7 // (可开) Change 人物7转 +#define _PET_2TRANS // (可开) Change 宠物2转 +#define _PET_2LIMITLEVEL // (可开) Change 帮助宠物2转的玛蕾 +#define _MAGICSTAUTS_RESIST // (可开) Change (火电冰)抗性精灵 +#define _EQUIT_RESIST // (可开) Change 单一装备抗性(可抗单一功能异常状态)有抗火 雷 冰 虚弱 魔障 沉默 落马 +#define _SUIT_TWFWENDUM // (可开) Change 四属性套装功能 (_SUIT_ITEM要开) +#define _EXCHANGEMAN_REQUEST_DELPET // (可开) Change 替exchangeman的TYPE:REQUEST增加删除宠物 +//#define _75_TEST // (不可开) 7.5测试server +//#define _PK_SERVER //百万pk活动 +//#define _DEATH_CONTEND // (可开) 百万pk活动 ANDY 死斗 +//#define _DEATH_CONTENDAB // (可开) 百万pk活动 ANDY 正式死斗 +//-------------------------------------------------------------------------- + +#define _ESCAPE_RESET // 恶宝逃跑後暂时不可组队 Robin 2004/07/22 +#define _DEL_DROP_GOLD // 删除地上过时的石币 Robin +#define _ITEM_STONE // cyg 奇怪的石头 +#define _HELP_NEWHAND // cyg 新创角色给予新手道具) +#define _DEF_FMFREETIME // cyg GM指令 退出家族时间限制设为0 +#define _DEF_GETYOU // cyg GM指令 查询自己两格 围内的玩家帐号 +#define _DEF_NEWSEND // cyg GM指令 传送玩家时可加句子也可不加 +#define _DEF_SUPERSEND // cyg GM指令 可传送已某帐号为中心附近3格内所有玩家 +#define _SUIT_ADDPART3 // (可开) Change 套装功能第叁弹 回避提高% 沉默抗性提高% 敏提高% 防提高% 攻提高% +#define _PETSKILL_2TIMID // (可开) Change 怯战第二版(狂狮怒吼) +#define CAVALRY_DEBUG // (暂时开) Change 座骑攻击除错中 +#define _SHOW_FUSION // (可开) Change 融合宠物在CLIENT端只显示转生数,修改为融合宠显示为融合(client端也要开) +#define _CONTRACT // (可开) Robin 契约功能 +#define _FONT_SIZE // (可开) Robin 字型大小功能 +#define _PROSK99 // (可开) Change 检查职技等级送白狼 +#define _TIME_TICKET // Robin 限时入场 森林捉宠用 +#define _HALLOWEEN_EFFECT // 万圣节特效 +#define _ADD_STATUS_2 // 新增传送人物状态第二类 +#define _ADD_reITEM // (可开) Change 检查道具栏位空格 +#define _ADD_NOITEM_BATTLE // 新增NPC检查人物身上没道具会进入战斗 +#define _PETSKILL_BATTLE_MODEL // 宠物技能战斗模组 +#define _RACEMAN // cyg 猎宠大会新npc +#define _PETSKILL_ANTINTER // (可开) Change 宠技:蚁之葬 参考_PETSKILL_2TIMID +#define _PETSKILL_REGRET // (可开) Change 宠技:憾甲一击 参考_SONIC_ATTACK +#define _SUIT_ADDPART4 // (可开) Change 套装功能第四弹 中毒攻击% 加强法师魔法(机率30%) 抵抗法师的魔法 + +//#define _CHECK_ENEMY_PET // (不可开) Change 检查玩家是否持有不可当宠物的角色(enemy.txt的petflg栏位为0代表不可拿来当宠物) +//#define _ITEM_TYPETABLE // (不可开) Change 追加typetable +//#define _MERGE_NEW_8 // Robin 8.0版 新合成规则 +//#define _RIGHTCLICK // Robin 滑鼠右键功能 +//#define _JOBDAILY // cyg 任务日志功能 +//#define _ALCHEMIST // Robin 精 功能 +//#define _CHECK_ITEM_MODIFY // 检查异常加强的道具 +//#define _PETSKILL_EXPLODE // (不可开) Change 宠技:爆裂攻击 + +//------------------------------------------------------------------------------------ +#define _ITEM_SETLOVER // 结婚功能 +#define _CREATE_MM_1_2 // 制作极品玛蕾菲雅 +#define _SendTo // 传送到玩家身边 +#define _GET_BATTLE_EXP // 经验设置 +#ifndef _NEW_TESTSERVER + #define _NEW_PLAYER_CF // 新手状态设置 +#endif +#define _USER_EXP_CF // 用户自定义经验 +#define _FM_RIDE_PET // 家族骑宠 +#define _UNLAW_WARP_FLOOR // 禁止传送地区 +#define _UNREG_NEMA // 禁止人物名称 +#endif diff --git a/gmsv/include/version_pk.h b/gmsv/include/version_pk.h new file mode 100644 index 0000000..dd5b101 --- /dev/null +++ b/gmsv/include/version_pk.h @@ -0,0 +1,9 @@ +#ifndef _PKSERVER_VERSION_H_ +#define _PKSERVER_VERSION_H_ + +//#define _PKSEVER_VER // (不可开) 跨星系pk伺服器 + +//赛程 +//排名 +//积分计算 +#endif diff --git a/gmsv/include/vssver.scc b/gmsv/include/vssver.scc new file mode 100644 index 0000000..2902d88 Binary files /dev/null and b/gmsv/include/vssver.scc differ diff --git a/gmsv/init.c b/gmsv/init.c new file mode 100644 index 0000000..c567215 --- /dev/null +++ b/gmsv/init.c @@ -0,0 +1,723 @@ +#include "version.h" +#include +#include +#include +#include + + +#include "configfile.h" +#include "util.h" +#include "net.h" +#include "msignal.h" +#include "buf.h" +#include "object.h" +#include "char.h" +#include "char_data.h" +#include "item.h" +#include "readmap.h" +#include "function.h" +#include "saacproto_cli.h" +#include "lssproto_serv.h" +#include "readnpc.h" +#include "log.h" +#include "handletime.h" +#include "title.h" +#include "encount.h" +#include "enemy.h" +#include "battle.h" +#include "magic_base.h" +#include "pet_skill.h" +#include "item_gen.h" +#include "petmail.h" +#include "npc_quiz.h" + + +#ifdef _M_SERVER +#include "mclient.h" +#endif + +#ifdef _NPCSERVER_NEW +#include "npcserver.h" +#endif + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 +#include "profession_skill.h" +#endif + +#ifdef _ITEM_QUITPARTY +#include "init.h" +//int itemquitparty_num = 0; +//static DisappearItem *Disappear_Item; +#endif + +#define MESSAGEFILE "hoge.txt" + +#define OPTIONSTRING "d:f:h" +#define usage() print( "Usage: %s ["OPTIONSTRING"]\n", getProgname() ); + +void printUsage( void ) +{ + usage(); + /*print( "Usage: %s ["OPTIONSTRING"]\n", progname );*/ + print( " [-d debuglevel] default value is 0\n" ); + print( " [-f configfilename] default value is setup.cf\n" + ); +} + +/* + * 戊穴件玉仿奶件毛质 允月 + * + * 娄醒 + * argc 侬 及醒 + * argv 侬 及 + * 忒曰袄 + * TRUE(1) 恳橘卅戊穴件玉仿奶件娄醒分匀凶日 + * FALSE(0) 唱橘卅戊穴件玉仿奶件娄醒分匀凶日 + */ +BOOL parseCommandLine( int argc , char** argv ) +{ + int c; /* getopt 匹银丹 */ + extern char* optarg; /* getopt 匹银丹 */ + + + while( ( c = getopt( argc, argv ,OPTIONSTRING )) != -1 ){ + switch( c ){ + case 'd': + { + int debuglevel; + if( !strtolchecknum( optarg, (int*)&debuglevel, 10, + INT)){ + print( "Specify digit number\n" ); + return FALSE; + } + setDebuglevel( debuglevel ); + break; + } + case 'f': + setConfigfilename( optarg ); + break; + case 'h': + printUsage(); + return FALSE; + break; + + default: + printUsage(); + return FALSE; + break; + + } + } + return TRUE; +} + + +/* + * 棕雁 醒毛由□旦允月 + * 娄醒 + * env 棕雁 醒及 + * + * 漆及赭窒手仄卅中 + */ +BOOL parseEnvironment( char** env ) +{ + if( getDebuglevel() >= 3 ){ + int index=0; + while( env[index] != NULL )print( "%s " , env[index++] ); + print( "\n" ); + } + return TRUE; +} + + + + +/*lsgen迕及伐□平件弘田永白央及 五今*/ +#define LSGENWORKINGBUFFER 65536*4 + + + +#define GOTORETURNFALSEIFFALSE(x) if(!(x))goto RETURNFALSE +/* + * 赓渝祭伙□民件 + * 娄醒 + * argc argv及醒 + * argv 戊穴件玉仿奶件娄醒 + * env 棕雁 醒 + * 忒曰袄 + * TRUE(1) 岳 + * FALSE(1) 撩 + */ +BOOL init(int argc , char** argv , char** env ) +{ +#ifdef _ITEM_QUITPARTY + FILE *f; + int i; + char line[256]; +#endif + srand( getpid()); + print( "This Program is compiled at %s %s by gcc %s\n", + __DATE__ , __TIME__ , __VERSION__ ); + + defaultConfig( argv[0] ); + signalset(); + + GOTORETURNFALSEIFFALSE(parseCommandLine( argc , argv )); + GOTORETURNFALSEIFFALSE(parseEnvironment( env )); + + { + Char aho; + debug( sizeof( aho ), d); + debug( sizeof( aho.data ), d); + debug( sizeof( aho.string ), d); + debug( sizeof( aho.flg ),d); + debug( sizeof( aho.indexOfExistItems ), d); + debug( sizeof( aho.haveSkill ), d); + debug( sizeof( aho.indexOfHaveTitle ), d); + debug( sizeof( aho.addressBook ),d); + debug( sizeof( aho.workint ),d); + debug( sizeof( aho.workchar ),d); + } + + print( "配置文件: %s\n" , getConfigfilename() ); + + GOTORETURNFALSEIFFALSE(readconfigfile( getConfigfilename() ) ); + //ttom start + { int iWork = setEncodeKey(); + if( iWork == 0 ){ + // 巨件戊□玉平□毛涩烂 + printf( "----------------------------------------\n" ); + printf( "-------------[编码] 无法设置 %s\n", getConfigfilename() ); + printf( "----------------------------------------\n" ); + exit( 1 ); + }else{ + // 巨件戊□玉平□毛涩烂 + printf( "编码 = %d\n", iWork ); + } + } + // AcWBuff毛涩烂 + { int iWork = setAcWBSize(); + if( iWork == 0 ){ + printf( "----------------------------------------\n" ); + printf( "-------------[AC缓冲] 无法设置 %s\n", getConfigfilename() ); + printf( "----------------------------------------\n" ); + exit( 1 ); + }else{ + printf( "AC缓冲 = %d\n", iWork ); + } + } + //ttom end + + if( getDebuglevel() >= 1 ){ +// print("ServerType: %d\n", getServerType() ); + print("调试等级: %d\n" , getDebuglevel() ); + print("内存单元: %d\n" , getMemoryunit() ); + print("内存单元数量: %d\n" , getMemoryunitnum() ); + + print("账号服务器地址: %s\n" , getAccountservername() ); + print("账号服务器端口: %d\n" , getAccountserverport() ); + print("登陆服务器名称: %s\n", + getGameservername()); + print("登陆服务器密码: %s\n", getAccountserverpasswd()); + + print("等待连接端口: %d\n", getPortnumber() ); + + print("服务端序列号: %d\n", getServernumber() ); + + print("重复地址使用: %d\n", getReuseaddr() ); + + + print("最大在线人数: %d\n", + getFdnum() ); + print("最大在线宠数: %d\n" , getPetcharnum() ); + print("最大其他数目: %d\n" , getOtherscharnum() ); + print("最大对象数目: %d\n", getObjnum() ); + print("最大物品数目: %d\n", getItemnum() ); + print("最大战斗数目: %d\n", getBattlenum() ); +#ifdef _GET_BATTLE_EXP + print("战斗经验倍数: %d\n", getBattleexp() ); +#endif + print("顶层文件目录: %s\n" , getTopdir()); + print("地图文件目录: %s\n" , getMapdir()); + print("地图标识文件: %s\n" , getMaptilefile()); + print("物品配置文件: %s\n" , getItemfile()); + print("不可战斗文件: %s\n" , getInvfile()); + print("显示位置文件: %s\n" , getAppearfile()); + print("遇敌配置文件: %s\n" , getEffectfile()); + print("头衔名称文件: %s\n" , getTitleNamefile()); + print("头衔配置文件: %s\n" , getTitleConfigfile()); + print("遇敌坐标文件: %s\n" , getEncountfile()); + print("遇敌组群文件: %s\n" , getGroupfile()); + print("宠物基本文件: %s\n" , getEnemyBasefile()); + print("创建宠物文件: %s\n" , getEnemyfile()); + print("精灵魔法文件: %s\n" , getMagicfile()); + +#ifdef __ATTACK_MAGIC + print("攻击魔法文件: %s\n" , getAttMagicfileName() ); +#endif + + print("宠物技能文件: %s\n" , getPetskillfile()); + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + print("职业技能文件: %s\n" , getProfession()); +#endif + + print("物品成份文件: %s\n", getItematomfile()); + print("猜迷问题文件: %s\n", getQuizfile()); +#ifdef _BLACK_MARKET + print("地下市场文件: %s\n", getBMItemFile()); +#endif +#ifdef _GMRELOAD + print("G M 配置文件: %s\n", getGMSetfile()); +#endif + print("日志记录文件: %s\n" , getLsgenlogfilename() ); + print("还原资料目录: %s\n" , getStoredir()); + print("NPC 配置目录: %s\n" , getNpcdir()); + print("日志记载文件: %s\n", getLogdir()); + print("日志配置文件: %s\n", getLogconffile() ); + print("GM的指命密码: %s\n", getChatMagicPasswd() ); + print("使用GM的权限: %d\n", getChatMagicCDKeyCheck() ); + + print("NPC 模板数目: %d\n" , getNpctemplatenum() ); + print("NPC 最大数目: %d\n" , getNpccreatenum() ); + + print("走路时间间隔: %d\n" , getWalksendinterval()); + print("清除所有间隔: %d\n" , getCAsendinterval_ms()); + print("清除目标间隔: %d\n" , getCDsendinterval_ms()); + print("执行一次时间: %d\n" , getOnelooptime_ms()); + print("宠物清除时间: %d\n" , getPetdeletetime()); + print("道具清除时间: %d\n" , getItemdeletetime()); +#ifdef _DEL_DROP_GOLD + print("石器清除时间: %d\n" , getGolddeletetime()); +#endif + print("数据保存间隔: %d\n" , getCharSavesendinterval()); + + print("名片最大数目: %d\n",getAddressbookoffmsgnum()); + print("读取频率协议: %d\n",getProtocolreadfrequency()); + + print("连接错误上限: %d\n",getAllowerrornum()); + +#ifdef _M_SERVER + print("GM服务器地址: %s\n",getmservername()); + print("GM服务器端口: %d\n",getmserverport()); +#endif +#ifdef _NPCSERVER_NEW + print("Npc服务器地址: %s\n",getnpcserveraddr()); + print("Npc服务器端口: %d\n",getnpcserverport()); +#endif +#ifdef _NEW_PLAYER_CF + print("出生人物转数: %d\n",getNewplayertrans()); + print("出生人物等级: %d\n",getNewplayerlv()); + print("出生人物金钱: %d\n",getNewplayergivegold()); + print("出生宠物等级: %d\n",getNewplayerpetlv()); + print("出生拥有宠物: NO1:%d NO2:%d NO3:%d NO4:%d NO5:%d\n",getNewplayergivepet(0), + getNewplayergivepet(1), + getNewplayergivepet(2), + getNewplayergivepet(3), + getNewplayergivepet(4)); + print("出生拥有物品: ITEM1:%d ITEM2:%d ITEM3:%d ITEM4:%d ITEM5:%d\n" + "       ITEM1:%d ITEM2:%d ITEM3:%d ITEM4:%d ITEM5:%d\n" + "       ITEM1:%d ITEM2:%d ITEM3:%d ITEM4:%d ITEM5:%d\n" + ,getNewplayergiveitem(0) + ,getNewplayergiveitem(1) + ,getNewplayergiveitem(2) + ,getNewplayergiveitem(3) + ,getNewplayergiveitem(4) + ,getNewplayergiveitem(5) + ,getNewplayergiveitem(6) + ,getNewplayergiveitem(7) + ,getNewplayergiveitem(8) + ,getNewplayergiveitem(9) + ,getNewplayergiveitem(10) + ,getNewplayergiveitem(11) + ,getNewplayergiveitem(12) + ,getNewplayergiveitem(13) + ,getNewplayergiveitem(14)); +#endif +#ifdef _UNLAW_WARP_FLOOR + print("禁止传送地图: FLOOR1:%d FLOOR2:%d FLOOR3:%d FLOOR4:%d FLOOR5:%d\n",getUnlawwarpfloor(0), + getUnlawwarpfloor(1), + getUnlawwarpfloor(2), + getUnlawwarpfloor(3), + getUnlawwarpfloor(4)); +#endif +#ifdef _UNREG_NEMA + print("禁止人物名称: NAME1:%s NAME2:%s NAME3:%s NAME4:%s NAME5:%s\n",getUnregname(0), + getUnregname(1), + getUnregname(2), + getUnregname(3), + getUnregname(4)); +#endif +#ifdef _TRANS_LEVEL_CF + print("人物等级转数: %d\n",getChartrans()); + print("宠物等级转数: %d\n",getPettrans()); +#endif + +#ifdef _LOCK_IP + print("封锁 IP 设置: %s\n",getLockipPath()); +#endif + } + + { //andy_add 2003/05/05 check GameServer Name + char *GameServerName; + GameServerName = getGameserverID(); + if( GameServerName == NULL || strlen( GameServerName) <= 0 ) + return FALSE; + print("\n游戏服务器ID: %s\n", GameServerName ); + } + + print("开始初始化\n" ); + +//#define DEBUG1( arg... ) if( getDebuglevel()>1 ){##arg} + print( "建立内存空间..." ); + GOTORETURNFALSEIFFALSE(configmem( getMemoryunit(), + getMemoryunitnum() ) ); + GOTORETURNFALSEIFFALSE(memInit()); + print( "完成\n" ); + if( !initConnect(getFdnum()) ) + goto MEMEND; + while( 1 ){ + print( "尝试绑定本地端口 %d... " , getPortnumber()); + bindedfd = bindlocalhost( getPortnumber() ); + if( bindedfd == -1 ) + sleep( 10 ); + else + break; + + } + print( "完成\n" ); + print( "建立对象..." ); + if( !initObjectArray( getObjnum()) ) + goto CLOSEBIND; + print( "完成\n" ); + print( "建立人物..." ); + if(!CHAR_initCharArray( getFdnum(), getPetcharnum(),getOtherscharnum()) ) + goto CLOSEBIND; + print( "完成\n" ); + print( "建立物品:%s...", getItemfile()); + if(!ITEM_readItemConfFile( getItemfile()) ) + goto CLOSEBIND; + if(!ITEM_initExistItemsArray( getItemnum() ) ) + goto CLOSEBIND; + print( "完成\n" ); + + print( "建立战斗..." ); + if(!BATTLE_initBattleArray( getBattlenum() ) ) + goto CLOSEBIND; + print( "完成\n" ); + + print( "建立功能模块..." ); + if( !initFunctionTable() ) + goto CLOSEBIND; + print( "完成\n" ); + + print( "初始化邮件..." ); + if( !PETMAIL_initOffmsgBuffer( getAddressbookoffmsgnum() )) + goto CLOSEBIND; + print( "完成\n" ); + + print( "读取不可战斗文件..." ); + if( !CHAR_initInvinciblePlace( getInvfile() ) ) + goto CLOSEBIND; + print( "完成\n" ); + + print( "读取显示位置文件..." ); + if( !CHAR_initAppearPosition( getAppearfile() ) ) + goto CLOSEBIND; + print( "完成\n" ); + + print( "读取头衔名称文件..." ); + if( !TITLE_initTitleName( getTitleNamefile() ) ) + goto CLOSEBIND; + print( "完成\n" ); + + print( "读取头衔配置文件..." ); + if( !TITLE_initTitleConfig( getTitleConfigfile() ) ) + goto CLOSEBIND; + print( "完成\n" ); + + print( "读取遇敌坐标文件..." ); + if( !ENCOUNT_initEncount( getEncountfile() ) ) + goto CLOSEBIND; + print( "完成\n" ); + + print( "读取宠物基本文件..." ); + if( !ENEMYTEMP_initEnemy( getEnemyBasefile() ) ) + goto CLOSEBIND; + print( "完成\n" ); + + print( "读取创建宠物文件..." ); + if( !ENEMY_initEnemy( getEnemyfile() ) ) + goto CLOSEBIND; + print( "完成\n" ); + + print( "读取遇敌组群文件..." ); + if( !GROUP_initGroup( getGroupfile() ) ) + goto CLOSEBIND; + print( "完成\n" ); + print( "读取魔法文件..." ); + if( !MAGIC_initMagic( getMagicfile() ) ) + goto CLOSEBIND; + print( "完成\n" ); + + #ifdef __ATTACK_MAGIC + + print( "读取魔法攻击文件..." ); + + if( !ATTMAGIC_initMagic( getAttMagicfileName() ) ) +// if( !ATTMAGIC_initMagic( getMagicfile() ) ) + goto CLOSEBIND; + + print( "魔法攻击文件 -->%s..." , getAttMagicfileName()); + print( "完成\n" ); + + #endif + + print( "读取宠物技能文件..." ); + if( !PETSKILL_initPetskill( getPetskillfile() ) ) + goto CLOSEBIND; + print( "完成\n" ); + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + print( "读取职业技能文件..." ); + if( !PROFESSION_initSkill( getProfession() ) ){ + goto CLOSEBIND; + } + print( "完成\n" ); +#endif + + /* 失奶 丞及笺 毛 戈 */ + print( "读取物品成份文件..." ); + if( !ITEM_initItemAtom( getItematomfile()) ) + goto CLOSEBIND; + print("完成\n" ); + + print( "初始化物品高速缓冲..." ); + if( !ITEM_initItemIngCache() ) + goto CLOSEBIND; + print("完成\n" ); + + print( "初始化物品名称..." ); + if( !ITEM_initRandTable() ) + goto CLOSEBIND; + print("完成\n" ); + + print( "读取遇敌配置文件..." ); + if( !CHAR_initEffectSetting( getEffectfile() ) ) + goto CLOSEBIND; + print( "完成\n" ); + print( "读取猜迷问题文件..." ); + if( !QUIZ_initQuiz( getQuizfile() ) ) + goto CLOSEBIND; + print( "完成\n" ); + +#ifdef _BLACK_MARKET + print( "地下市场文件..." ); + if ( !LoadBMItem(getBMItemFile()) ) + goto CLOSEBIND; + print( "完成\n" ); +#endif + +#ifdef _GMRELOAD + print( "读取GM配置文件..." ); + if ( !LoadGMSet( getGMSetfile() ) ) + goto CLOSEBIND; + print( "完成\n" ); +#endif + +#ifdef _GMRELOAD + print( "读取经验配置文件..." ); + if ( !LoadEXP( getEXPfile() ) ) + goto CLOSEBIND; + print("最高等级: %d...",getMaxLevel()); + print("一般等级: %d...",getYBLevel()); + print( "完成\n" ); +#endif + +#ifdef _ANGEL_SUMMON + print("读取任务列表文件..."); + if( !LoadMissionList( ) ) + goto CLOSEBIND; + print("完成\n"); +#endif + +#ifdef _CONTRACT + print("读取契约文件..."); + //if( !LoadMissionList( ) ) + // goto CLOSEBIND; + if( !ITEM_initContractTable() ) + goto CLOSEBIND; + print("完成\n"); +#endif + +#ifdef _JOBDAILY + print("读取任务日志文件..."); + if(!LoadJobdailyfile()) + goto CLOSEBIND; + print("完成\n"); +#endif + +#ifdef _RACEMAN + print("读取宠物赛跑文件..."); + if(!LoadRacepetfile()) + goto CLOSEBIND; + print("完成\n"); +#endif + +#ifdef _LOCK_IP + print("读取锁定IP文件..."); + if(!loadLockip( getLockipPath())) + goto CLOSEBIND; + print("完成\n"); +#endif + + print( "建立地图..." ); + if( !MAP_initReadMap( getMaptilefile() , getMapdir() )) + goto CLOSEBIND; + print( "完成\n" ); + print( "读取NPC文件..." ); + if( !NPC_readNPCSettingFiles( getNpcdir(), getNpctemplatenum(), + getNpccreatenum() ) ) + goto CLOSEBIND; + print( "完成\n" ); + print( "初始化 NPC 服务器... " ); + if( lssproto_InitServer( lsrpcClientWriteFunc, LSGENWORKINGBUFFER ) < 0 ) + goto CLOSEBIND; + print( "完成\n" ); + print( "尝试连接账号服务器... " ); + acfd = connectHost( getAccountservername(), getAccountserverport()); + if(acfd == -1) + goto CLOSEBIND; + +/* + { + int errorcode; + int errorcodelen; + int qs; + + errorcodelen = sizeof(errorcode); + qs = getsockopt( acfd, SOL_SOCKET, SO_RCVBUF , &errorcode, &errorcodelen); + //andy_log + print("\n\n GETSOCKOPT SO_RCVBUF: [ %d, %d, %d] \n", qs, errorcode, errorcodelen); + } +*/ + + print( "完成\n" ); + initConnectOne( acfd, NULL , 0 ); + if( !CONNECT_acfdInitRB( acfd)) goto CLOSEAC; + if( !CONNECT_acfdInitWB( acfd)) goto CLOSEAC; + CONNECT_setCtype( acfd, AC ); + + print( "初始化 NPC 客户端 ... " ); + /* rpc(client)及赓渝祭 */ + if( saacproto_InitClient( lsrpcClientWriteFunc,LSGENWORKINGBUFFER, acfd) < 0 ) + goto CLOSEAC; + print( "完成\n" ); + + print( "向账号服务器发送登陆请求... " ); + /* 夫弘奶件邰菲毛请允 */ + saacproto_ACServerLogin_send(acfd, getGameservername(), + getAccountserverpasswd()); + print( "完成\n" ); + + if( isExistFile( getLsgenlogfilename() ) ){ + lssproto_SetServerLogFiles( getLsgenlogfilename(), + getLsgenlogfilename() ); + saacproto_SetClientLogFiles( getLsgenlogfilename(), + getLsgenlogfilename() ); + } + + + print( "初始化已完成\n" ); + +#ifdef _MUSEUM + if( getMuseum() ) + print("\n这是石器博物馆!!\n"); + else + print("\n这是普通星球!!\n"); +#endif + + print( "开始记始日志\n" ); + { + char logconffile[512]; + snprintf( logconffile, sizeof( logconffile), "%s/%s" , + getLogdir(), getLogconffile() ); + if( !initLog( logconffile ) ) + goto CLOSEAC; + } + +#ifdef _M_SERVER + print( "尝试连接GM服务器... " ); + mfd = connectmServer( getmservername(), getmserverport()); + if (mfd ==-1 ){ + print( "连接GM服务器失败... " ); + }else{ + initConnectOne( mfd, NULL , 0 ); + print( "成败连接GM服务器... " ); + } +#endif + +#ifdef _NPCSERVER_NEW + npcfd = connectNpcServer( getnpcserveraddr(), getnpcserverport()); + if( npcfd == -1 ){ + print( "连接NPC服务器失败... " ); + }else{ + initConnectOne( npcfd, NULL , 0 ); + print( "成败连接NPC服务器... " ); + NPCS_NpcSLogin_send( npcfd); + } +#endif + +#ifdef _ITEM_QUITPARTY + print( "读取队伍解散物品消失文件..." ); + + //读取档案 + f = fopen( getitemquitparty(), "r" ); + if( f != NULL ){ + while( fgets( line, sizeof( line ), f ) ){ + if( line[0] == '#' )continue; + if( line[0] == '\n' )continue; + chomp( line ); + itemquitparty_num++; + } + if( fseek( f, 0, SEEK_SET ) == -1 ){ + print( "物品录找错误\n" ); + fclose(f); + goto CLOSEAC; + } + //配记忆体 + Disappear_Item = allocateMemory( sizeof(struct tagDisappearItem) * itemquitparty_num ); + if( Disappear_Item == NULL ){ + print( "无法分配内存 %d\n", sizeof(struct tagDisappearItem) * itemquitparty_num ); + fclose( f ); + goto CLOSEAC; + } + + i = 0; + //将道具编号存入 Disappear_Item.string + while( fgets( line, sizeof( line ), f ) ){ + if( line[0] == '#' )continue; + if( line[0] == '\n' )continue; + chomp( line ); + sprintf( Disappear_Item[i].string,"%s",line ); + print("\n道具编号:%s", Disappear_Item[i].string ); + i++; + } + fclose(f); + } +#endif + + DEBUG_ADJUSTTIME = 0; + print( "\n" ); + return TRUE; + +CLOSEAC: + close( acfd ); +CLOSEBIND: + close( bindedfd ); + endConnect(); +MEMEND: + memEnd(); +RETURNFALSE: + return FALSE; +} diff --git a/gmsv/item/item.c b/gmsv/item/item.c new file mode 100644 index 0000000..86f6d58 --- /dev/null +++ b/gmsv/item/item.c @@ -0,0 +1,2327 @@ +#include "version.h" +#include +#include +#include +#include +#include +#include "common.h" +#include "char.h" +#include "char_data.h" +#include "battle.h" +#include "item.h" +#include "buf.h" +#include "function.h" +#include "magic_base.h" + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 +#include "profession_skill.h" +#endif + +static int ITEM_tblen = 0; +static ITEM_exists* ITEM_item; +static int ITEM_itemnum; +static int ITEM_UseItemnum=0; +static char* ITEM_checkString( char* string ); +static int ITEM_getRandomValue( char* string,int* randomwidth, int num ); +static int ITEM_isstring1or0( char* string,int* randomwidth, int num ); + +#ifdef _IMPOROVE_ITEMTABLE +typedef struct _tag_ITEM_transformList +{ + int Si; + int use; +}sITEM_transformList; +sITEM_transformList *ITEM_TransformList = NULL; +static int defitemtbls=0; +static int totalitemtbls=0; +#endif + +#ifdef _SIMPLIFY_ITEMSTRING +typedef struct ITEM_tag_intDataSetting +{ + char* dumpchar; + int defaults; + int table; +}ITEM_intDataSetting; + +typedef struct ITEM_tag_charDataSetting +{ + char* dumpchar; + char* defaults; + int table; +}ITEM_charDataSetting; + +static ITEM_intDataSetting ITEM_setintdata[]={ + {"id", 0, ITEM_ID }, + {"bi", 0, ITEM_BASEIMAGENUMBER }, + {"cs", 0, ITEM_COST }, + {"ep", ITEM_OTHER, ITEM_TYPE }, + {"ft", 0, ITEM_ABLEUSEFIELD }, + {"tg", 0, ITEM_TARGET }, + {"lv", 0, ITEM_LEVEL }, +#ifdef _ITEM_MAXUSERNUM + {"dib", -1, ITEM_DAMAGEBREAK }, +#endif +#ifdef _ITEMSET4_TXT + {"upin", 1, ITEM_USEPILENUMS }, + {"canpile", 0, ITEM_CANBEPILE }, + {"nestr", 0, ITEM_NEEDSTR }, + {"nedex", 0, ITEM_NEEDDEX }, + {"netra", 0, ITEM_NEEDTRANS }, + {"neprof", 0, ITEM_NEEDPROFESSION }, +#endif +#ifdef _TAKE_ITEMDAMAGE + {"dmce", 0, ITEM_DAMAGECRUSHE }, + {"mdmce", 0, ITEM_MAXDAMAGECRUSHE }, +#endif +#ifdef _ADD_DEAMGEDEFC + {"otdmag", 0, ITEM_OTHERDAMAGE }, + {"otdefc", 0, ITEM_OTHERDEFC }, +#endif +#ifdef _SUIT_ITEM + {"nsuit", 0, ITEM_SUITCODE }, +#endif + {"ann", 0, ITEM_ATTACKNUM_MIN }, + {"anx", 0, ITEM_ATTACKNUM_MAX }, + {"ma", 0, ITEM_MODIFYATTACK }, + {"md", 0, ITEM_MODIFYDEFENCE }, + + {"mh", 0, ITEM_MODIFYQUICK}, //ITEM_MODIFYHP }, ITEM_MODIFYQUICK + {"mm", 0, ITEM_MODIFYHP}, //ITEM_MODIFYMP }, ITEM_MODIFYHP + {"mq", 0, ITEM_MODIFYMP}, //ITEM_MODIFYQUICK }, ITEM_MODIFYMP + {"ml", 0, ITEM_MODIFYLUCK }, + {"mc", 0, ITEM_MODIFYCHARM }, + {"mv", 0, ITEM_MODIFYAVOID }, + {"mat", 0, ITEM_MODIFYATTRIB }, + {"mav", 0, ITEM_MODIFYATTRIBVALUE }, + {"mid", -1, ITEM_MAGICID }, + {"mpr", 0, ITEM_MAGICPROB }, + {"mu", 0, ITEM_MAGICUSEMP }, +#ifdef _ITEMSET5_TXT + {"arr", 0, ITEM_MODIFYARRANGE }, + {"seqce", 0, ITEM_MODIFYSEQUENCE }, + {"iapi", 0, ITEM_ATTACHPILE }, + {"hirt", 0, ITEM_HITRIGHT }, +#endif + +#ifdef _ITEMSET6_TXT + {"neguard", 0, ITEM_NEGLECTGUARD}, +#endif + {"mrf", 0, ITEM_MERGEFLG}, + +}; + +static ITEM_charDataSetting ITEM_setchardata[]={ + {"na", "", ITEM_NAME }, /* ITEM_NAME */ + {"sn", "", ITEM_SECRETNAME }, /* ITEM_SCRETNAME */ + {"en", "", ITEM_EFFECTSTRING }, /* ITEM_EFFECTSTRING */ + {"ar", "", ITEM_ARGUMENT }, /* ITEM_ARGUMENT */ +#ifdef _ITEM_INSLAY + {"acode", "", ITEM_TYPECODE }, /*ITEM_TYPECODE,*/ + {"inlaycode", "", ITEM_INLAYCODE}, /*ITEM_INLAYCODE,*/ +#endif + {"cdk", "", ITEM_CDKEY }, /* ITEM_CDKEY */ +#ifdef _ITEM_FORUSERNAMES + {"forname", "", ITEM_FORUSERNAME }, //ITEM_FORUSERNAME, + {"forcdkey", "", ITEM_FORUSERCDKEY }, //ITEM_FORUSERCDKEY +#endif + +#ifdef _ANGEL_SUMMON + {"mindex", "", ITEM_ANGELMISSION}, + {"angel", "", ITEM_ANGELINFO}, + {"hero", "", ITEM_HEROINFO}, +#endif + +#ifdef _CONTRACT + {"ctt", "", ITEM_CONTRACTTIME}, + {"cta", "", ITEM_CONTRACTARG}, +#endif + +#ifdef _UNIQUE_P_I + {"ucode", "", ITEM_UNIQUECODE}, /* ITEM_UNIQUECODE */ +#endif +}; + +static ITEM_charDataSetting ITEM_setmemdata={ + "", "", -1 /* ITEM_MEMO */ +}; + + +#else +typedef struct ITEM_tag_intDataSetting +{ + char* dumpchar; + int defaults; +}ITEM_intDataSetting; + +typedef struct ITEM_tag_charDataSetting +{ + char* dumpchar; + char* defaults; +}ITEM_charDataSetting; + +static ITEM_intDataSetting ITEM_setintdata[ITEM_DATAINTNUM]={ + {"id", 0}, /* ITEM_ID */ + {"bi", 0}, /* ITEM_ITEMBASEIMAGENUMBER */ + {"cs", 0}, /* ITEM_COST */ + {"ep", ITEM_OTHER}, /* ITEM_TYPE */ + {"ft", 0}, /* ITEM_ABLEUSEFIELD */ + {"tg", 0}, /* ITEM_TARGET */ + {"lv", 0}, /* ITEM_LEVEL */ + +#ifdef _ITEM_MAXUSERNUM + {"dib", -1}, /*ITEM_DAMAGEBREAK*/ +#endif + +#ifdef _ITEMSET4_TXT + {"upin", 1}, //ITEM_USEPILENUMS, + {"canpile", 0}, //ITEM_CANBEPILE + {"nestr", 0}, //ITEM_NEEDSTR, + {"nedex", 0}, //ITEM_NEEDDEX, + {"netra", 0}, //ITEM_NEEDTRANS, + {"neprof", 0}, //ITEM_NEEDPROFESSION, +#endif + +#ifdef _TAKE_ITEMDAMAGE + {"dmce", 0}, /*ITEM_DAMAGECRUSHE*/ + {"mdmce",0}, //ITEM_MAXDAMAGECRUSHE +#endif + +#ifdef _ADD_DEAMGEDEFC + {"otdmag", 0}, //ITEM_OTHERDAMAGE, + {"otdefc", 0}, //ITEM_OTHERDEFC, +#endif + +#ifdef _SUIT_ITEM + {"nsuit", 0}, //ITEM_SUITCODE, +#endif + {"ann", 0}, /* ITEM_ATTACKNUM_MIN */ + {"anx", 0}, /* ITEM_ATTACKNUM_MAX */ + {"ma", 0}, /* ITEM_MODIFYATTACK */ + {"md", 0}, /* ITEM_MODIFYDEFENCE */ + {"mh", 0}, /* ITEM_MODIFYHP */ + {"mm", 0}, /* ITEM_MODIFYMP */ + + {"mq", 0}, /* ITEM_MODIFYQUICK */ + + {"ml", 0}, /* ITEM_MODIFYLUCK */ + {"mc", 0}, /* ITEM_MODIFYCHARM */ + {"mv", 0}, /* ITEM_MODIFYAVOID */ + {"mat", 0}, /* ITEM_MODIFYATTRIB */ + {"mav", 0}, /* ITEM_MODIFYATTRIBVALUE */ + + {"mid", -1}, /* ITEM_MAGICID */ + {"mpr", 0}, /* ITEM_MAGICPROB */ + {"mu", 0}, /* ITEM_MAGICUSEMP */ +#ifdef _ITEMSET5_TXT + {"arr", 0}, /*ITEM_MODIFYARRANGE*/ + {"seqce", 0}, //ITEM_MODIFYSEQUENCE, + {"iapi", 0}, //ITEM_ATTACHPILE + {"hirt", 0}, //ITEM_HITRIGHT //额外命中 +#endif + +#ifdef _ITEMSET6_TXT + {"neguard", 0}, //ITEM_NEGLECTGUARD +// {"bemerge", 0}, //ITEM_BEMERGE +#endif + {"mpo", 0}, /* ITEM_POISON */ + {"mpa", 0}, /* ITEM_PARALYSIS */ + {"msl", 0}, /* ITEM_SLEEP */ + {"mst", 0}, /* ITEM_STONE */ + {"mdr", 0}, /* ITEM_DRUNK */ + {"mco", 0}, /* ITEM_CONFUSION */ + + {"mcr", 0}, /* ITEM_CRITICAL */ + + {"ua", -1}, /* ITEM_USEACTION */ + {"drlo",FALSE}, /* ITEM_DROPATLOGOUT */ + {"valo",FALSE}, /* ITEM_VANISHATLOGOUT */ + {"ioed",TRUE}, /* ITEM_ISOVERED */ + {"cpm", TRUE}, /* ITEM_CANPETMAIL */ + {"cmf", TRUE}, /* ITEM_CANMERGEFROM */ + {"cmt", TRUE}, /* ITEM_CANMERGETO */ + + {"ingv0",0}, /* ITEM_INGVALUE0 */ + {"ingv1",0}, + {"ingv2",0}, + {"ingv3",0}, + {"ingv4",0}, + + {"ipt", 0}, /* ITEM_PUTTIME */ + {"ll", 0}, /* ITEM_LEAKLEVEL */ + {"mrf", 0}, /* ITEM_MERGEFLG */ + {"clv", 0}, /* ITEM_CRUSHLEVEL */ + + {"v1", 0}, /* ITEM_VAR1 */ + {"v2", 0}, /* ITEM_VAR2 */ + {"v3", 0}, /* ITEM_VAR3 */ + {"v4", 0}, /* ITEM_VAR4 */ +}; + +static ITEM_charDataSetting ITEM_setchardata[ITEM_DATACHARNUM]={ + {"na", ""}, /* ITEM_NAME */ + {"sn", ""}, /* ITEM_SCRETNAME */ + {"en", ""}, /* ITEM_EFFECTSTRING */ + {"ar", ""}, /* ITEM_ARGUMENT */ +#ifdef _ITEM_INSLAY + {"acode", ""}, /*ITEM_TYPECODE,*/ + {"inlaycode", ""}, /*ITEM_INLAYCODE,*/ +#endif + {"cdk", ""}, /* ITEM_CDKEY */ +#ifdef _ITEM_FORUSERNAMES + {"forname", ""}, //ITEM_FORUSERNAME, + {"forcdkey", ""}, //ITEM_FORUSERCDKEY +#endif +// CoolFish: 2001/10/11 +#ifdef _UNIQUE_P_I + {"ucode", ""}, /* ITEM_UNIQUECODE */ +#endif + {"ingn0", ""}, /* ITEM_INGNAME0 */ + {"ingn1", ""}, + {"ingn2", ""}, + {"ingn3", ""}, + {"ingn4", ""}, + + {"inif", ""}, /* ITEM_PREOVERFUNC */ + {"preof", ""}, /* ITEM_PREOVERFUNC */ + {"posof", ""}, /* ITEM_POSTOVERFUNC */ + {"wf", "ITEM_DeleteTimeWatched"}, /* ITEM_WATCHFUNC */ + {"usef", ""}, /* ITEM_USEFUNC */ + {"atchf", ""}, /* ITEM_ATTACH */ + {"dtchf", ""}, /* ITEM_DETACH */ + {"attaf", ""}, /* ITEM_ATTACKFUNC */ + {"pickupf", ""}, /* ITEM_PICKUPFUNC */ +#ifdef _Item_ReLifeAct + {"relifes", ""}, /*ITEM_DIERELIFEFUNC*/ +#endif + +}; + +static ITEM_charDataSetting ITEM_setmemdata={ + "", "" /* ITEM_MEMO */ +}; +#endif + +typedef enum +{ + ITEM_INTENTRY=0, + ITEM_CHARENTRY=1, + ITEM_INTFUNC=2, + ITEM_CHARFUNC=3, +}ITEM_DATATYPECATEGORY; + +static struct ITEM_itemconfentry +{ + char* entryname; + ITEM_DATATYPECATEGORY type; + int index; + void* func; +}ITEM_itemconfentries[]={ + {"name", ITEM_CHARFUNC, ITEM_NAME, ITEM_checkString}, + {"secretname", ITEM_CHARFUNC, ITEM_SECRETNAME, ITEM_checkString}, + {"effectstring",ITEM_CHARFUNC, ITEM_EFFECTSTRING, ITEM_checkString}, + {"argument", ITEM_CHARENTRY, ITEM_ARGUMENT, NULL}, +#ifdef _ITEM_INSLAY + {"acode", ITEM_CHARENTRY, ITEM_TYPECODE, NULL}, + {"inlaycode", ITEM_CHARENTRY, ITEM_INLAYCODE, NULL}, +#endif + {"initfunc", ITEM_CHARENTRY, ITEM_INITFUNC, NULL}, + {"preoverfunc", ITEM_CHARENTRY, ITEM_PREOVERFUNC, NULL}, + {"postoverfunc",ITEM_CHARENTRY, ITEM_POSTOVERFUNC, NULL}, + {"watchfunc", ITEM_CHARENTRY, ITEM_WATCHFUNC, NULL}, + {"usefunc", ITEM_CHARENTRY, ITEM_USEFUNC, NULL}, + {"attachfunc", ITEM_CHARENTRY, ITEM_ATTACHFUNC, NULL}, + {"detachfunc", ITEM_CHARENTRY, ITEM_DETACHFUNC, NULL}, + {"dropfunc", ITEM_CHARENTRY, ITEM_DROPFUNC, NULL}, + {"pickupfunc", ITEM_CHARENTRY, ITEM_PICKUPFUNC, NULL}, +#ifdef _Item_ReLifeAct + {"relifefunc", ITEM_CHARENTRY, ITEM_DIERELIFEFUNC, NULL}, +#endif + {"id", ITEM_INTENTRY, ITEM_ID, NULL}, + {"imagenumber", ITEM_INTENTRY, ITEM_BASEIMAGENUMBER, NULL}, + {"cost", ITEM_INTENTRY, ITEM_COST, NULL}, + {"type", ITEM_INTENTRY, ITEM_TYPE, NULL}, + {"fieldtype", ITEM_INTENTRY, ITEM_ABLEUSEFIELD, NULL}, + {"target", ITEM_INTENTRY, ITEM_TARGET, NULL}, + + {"level", ITEM_INTENTRY, ITEM_LEVEL, NULL}, +#ifdef _ITEM_MAXUSERNUM + {"dambreak", ITEM_INTENTRY, ITEM_DAMAGEBREAK, NULL}, +#endif + +#ifdef _ITEMSET4_TXT + {"upinums", ITEM_INTENTRY, ITEM_USEPILENUMS, NULL}, + {"campile", ITEM_INTENTRY, ITEM_CANBEPILE, NULL}, + {"nestr", ITEM_INTENTRY, ITEM_NEEDSTR, NULL}, + {"nedex", ITEM_INTENTRY, ITEM_NEEDDEX, NULL}, + {"netra", ITEM_INTENTRY, ITEM_NEEDTRANS, NULL}, + {"neprof", ITEM_INTENTRY, ITEM_NEEDPROFESSION, NULL}, +#endif + +#ifdef _TAKE_ITEMDAMAGE + {"damcrushe", ITEM_INTENTRY, ITEM_DAMAGECRUSHE, NULL}, + {"maxdmce", ITEM_INTENTRY, ITEM_MAXDAMAGECRUSHE, NULL}, +#endif + +#ifdef _ADD_DEAMGEDEFC + {"otdmags", ITEM_INTENTRY, ITEM_OTHERDAMAGE, NULL}, + {"otdefcs", ITEM_INTENTRY, ITEM_OTHERDEFC, NULL}, +#endif +#ifdef _SUIT_ITEM + {"nsuit", ITEM_INTENTRY, ITEM_SUITCODE, NULL}, //ITEM_SUITCODE, +#endif + {"attacknum_min",ITEM_INTENTRY, ITEM_ATTACKNUM_MIN, NULL}, + {"attacknum_max",ITEM_INTENTRY, ITEM_ATTACKNUM_MAX, NULL}, + {"attack", ITEM_INTFUNC, ITEM_MODIFYATTACK, ITEM_getRandomValue}, + {"defence", ITEM_INTFUNC, ITEM_MODIFYDEFENCE, ITEM_getRandomValue}, + {"quick", ITEM_INTFUNC, ITEM_MODIFYQUICK, ITEM_getRandomValue}, + + {"hp", ITEM_INTFUNC, ITEM_MODIFYHP, ITEM_getRandomValue}, + {"mp", ITEM_INTFUNC, ITEM_MODIFYMP, ITEM_getRandomValue}, + {"luck", ITEM_INTFUNC, ITEM_MODIFYLUCK, ITEM_getRandomValue}, + {"charm", ITEM_INTFUNC, ITEM_MODIFYCHARM, ITEM_getRandomValue}, + {"avoid", ITEM_INTFUNC, ITEM_MODIFYAVOID, ITEM_getRandomValue}, + {"attrib", ITEM_INTENTRY, ITEM_MODIFYATTRIB, NULL}, + {"attribvalue", ITEM_INTENTRY, ITEM_MODIFYATTRIBVALUE,NULL}, + + {"magicid", ITEM_INTENTRY, ITEM_MAGICID, NULL}, + {"magicprob", ITEM_INTENTRY, ITEM_MAGICPROB, NULL}, + {"magicusemp", ITEM_INTENTRY, ITEM_MAGICUSEMP, NULL}, +#ifdef _ITEMSET5_TXT + {"arr", ITEM_INTENTRY, ITEM_MODIFYARRANGE, NULL}, + {"seqce", ITEM_INTENTRY, ITEM_MODIFYSEQUENCE, NULL}, + {"iapi", ITEM_INTENTRY, ITEM_ATTACHPILE, NULL}, + {"hirt", ITEM_INTENTRY, ITEM_HITRIGHT, NULL}, +#endif +#ifdef _ITEMSET6_TXT + {"neguard", ITEM_INTENTRY, ITEM_NEGLECTGUARD, NULL}, +// {"bemerge", ITEM_INTENTRY, ITEM_BEMERGE, NULL}, +#endif + {"poison", ITEM_INTFUNC, ITEM_POISON, ITEM_getRandomValue}, + {"paralysis", ITEM_INTFUNC, ITEM_PARALYSIS, ITEM_getRandomValue}, + {"sleep", ITEM_INTFUNC, ITEM_SLEEP, ITEM_getRandomValue}, + {"stone", ITEM_INTFUNC, ITEM_STONE, ITEM_getRandomValue}, + {"drunk", ITEM_INTFUNC, ITEM_DRUNK, ITEM_getRandomValue}, + {"confusion", ITEM_INTFUNC, ITEM_CONFUSION, ITEM_getRandomValue}, + + {"critical", ITEM_INTFUNC, ITEM_CRITICAL, ITEM_getRandomValue}, + + {"useaction", ITEM_INTENTRY, ITEM_USEACTION, NULL}, + + {"dropatlogout",ITEM_INTFUNC, ITEM_DROPATLOGOUT, ITEM_isstring1or0}, + {"vanishatdrop",ITEM_INTFUNC, ITEM_VANISHATDROP, ITEM_isstring1or0}, + {"isovered", ITEM_INTFUNC, ITEM_ISOVERED, ITEM_isstring1or0}, + {"canpetmail", ITEM_INTFUNC, ITEM_CANPETMAIL, ITEM_isstring1or0}, + {"canmergefrom",ITEM_INTFUNC, ITEM_CANMERGEFROM, ITEM_isstring1or0}, + {"canmergeto", ITEM_INTFUNC, ITEM_CANMERGETO, ITEM_isstring1or0}, + + {"ingname0", ITEM_CHARENTRY, ITEM_INGNAME0, NULL}, + {"ingvalue0", ITEM_INTENTRY, ITEM_INGVALUE0, NULL}, + {"ingname1", ITEM_CHARENTRY, ITEM_INGNAME1, NULL}, + {"ingvalue1", ITEM_INTENTRY, ITEM_INGVALUE1, NULL}, + {"ingname2", ITEM_CHARENTRY, ITEM_INGNAME2, NULL}, + {"ingvalue2", ITEM_INTENTRY, ITEM_INGVALUE2, NULL}, + {"ingname3", ITEM_CHARENTRY, ITEM_INGNAME3, NULL}, + {"ingvalue3", ITEM_INTENTRY, ITEM_INGVALUE3, NULL}, + {"ingname4", ITEM_CHARENTRY, ITEM_INGNAME4, NULL}, + {"ingvalue4", ITEM_INTENTRY, ITEM_INGVALUE4, NULL}, +}; + + +#ifdef _ITEMTBL_STAIC +ITEM_table ITEM_tbl[28000]; +#else +ITEM_table* ITEM_tbl=NULL; +#endif + +static INLINE BOOL ITEM_CHECKARRAYINDEX(int index) +{ + if( ITEM_itemnum<=(index) || (index)<0 )return FALSE; + return TRUE; +} + +INLINE BOOL _ITEM_CHECKINDEX( char *file, int line, int index) +{ + if( !ITEM_CHECKARRAYINDEX(index) ) { + if( index != -1 ) { + print( "err %s:%d \n", file, line); + } + return FALSE; + } + if( ITEM_item[index].use == FALSE ) { + return FALSE; + } + return TRUE; +} + +static INLINE int ITEM_CHECKINTDATAINDEX(int index) +{ + if( ITEM_DATAINTNUM <= index || index < 0 )return FALSE; + return TRUE; +} + +static INLINE int ITEM_CHECKCHARDATAINDEX(int index) +{ + if( ITEM_DATACHARNUM<=index || index<0 )return FALSE; + return TRUE; +} + +BOOL ITEM_initExistItemsArray( int num ) +{ + int i; + + BOOL ITEM_checksetdata( void ); + if( ITEM_checksetdata() == FALSE )return FALSE; + + ITEM_itemnum = num; + + ITEM_item = allocateMemory( sizeof( ITEM_exists ) * num ); + if( ITEM_item == NULL ) return FALSE; + + for( i = 0 ; i < num ; i ++ ){ + memset( &ITEM_item[i], 0 , sizeof( ITEM_exists )); + ITEM_item[i].use = FALSE; + } + + return TRUE; +} + +BOOL ITEM_endExistItemsArray( void ) +{ + freeMemory( ITEM_item ); + return TRUE; +} + +int _ITEM_initExistItemsOne( char *file, int line, ITEM_Item* itm ) +{ + int i; + int itemID=-1; + static int Sindex=1; + itemID = itm->data[ITEM_ID]; + if( ITEM_CHECKITEMTABLE(itm->data[ITEM_ID] ) == FALSE){ + print("CHAR itemData err Item_id:%d=%s%d!!\n", itm->data[ITEM_ID], file, line); + return -1; + } + for( i = 0 ; i < ITEM_itemnum ; i ++ ) { + Sindex++; + if( Sindex >= ITEM_itemnum ) Sindex = 1; + if( Sindex < 1 ) Sindex = 1; + if( !ITEM_item[Sindex].use){ + int charaindex; + charaindex = ITEM_item[Sindex].itm.workint[ITEM_WORKCHARAINDEX]; + if( CHAR_CHECKINDEX( charaindex) && + CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) { + int j; + for( j = 0; j < CHAR_MAXITEMHAVE; j ++ ) { + if( CHAR_getItemIndex( charaindex, j) == Sindex) { + print( "item.c: error! chara have this item charaindex[%d] " + "itemindex[%d] Name(%s)POS(%d)NAME(%s)\n", + charaindex, Sindex, + CHAR_getUseName( charaindex ), j, + ITEM_item[Sindex].itm.string[ITEM_NAME].string ); + print( "from %s:%d\n", file, line); + ITEM_item[Sindex].use = TRUE; + break; + } + } + if( j != CHAR_MAXITEMHAVE ) continue; + } + memcpy( &ITEM_item[Sindex].itm , itm , sizeof( ITEM_Item ) ); + ITEM_item[Sindex].use = TRUE; + { + BOOL (*initfunc)(ITEM_Item*)=NULL; + initfunc = (BOOL(*)(ITEM_Item*)) getFunctionPointerFromName( itm->string[ITEM_INITFUNC].string ); + if( initfunc ){ + if( initfunc( &ITEM_item[Sindex].itm ) == FALSE ){ + ITEM_item[Sindex].use = FALSE; + fprint( "Error:Can't init item\n" ); + return -1; + } + } + } + ITEM_UseItemnum++; + ITEM_constructFunctable( Sindex); + return Sindex; + } + } + fprint( "错误:物品已满\n" ); + return -1; +} + +void _ITEM_endExistItemsOne( int index , char *file, int line) +{ + int i,j; + int hitcnt = 0; + int playernum = CHAR_getPlayerMaxNum(); + + if( !ITEM_CHECKINDEX(index)) return; + + for( i = 0; i < playernum; i ++ ) { + if( CHAR_CHECKINDEX( i)) { + for( j = 0; j < CHAR_MAXITEMHAVE; j ++ ) { + if( CHAR_getItemIndex( i, j) == index) { + print( "warning !! player have this item:%d call from [%s:%d](%s)(%s)\n", + index, file,line, CHAR_getUseName(i),ITEM_item[index].itm.string[ITEM_NAME].string ); + hitcnt ++; + if( hitcnt > 1 ) { + print( "ITEM_INDEX(%d) duplicate!!\n", index); + } + } + } + } + } + + if( hitcnt < 1 ){ + ITEM_item[index].use = FALSE; + ITEM_item[index].itm.workint[ITEM_WORKCHARAINDEX] = -1; + ITEM_UseItemnum--; + } +} + +INLINE int ITEM_getIntStrict( int index ,ITEM_DATAINT element,int* error) +{ + if(!ITEM_CHECKINDEX(index))return *error=FALSE; + if(!ITEM_CHECKINTDATAINDEX(element))return *error=FALSE; + return ITEM_item[index].itm.data[element]; +} + +INLINE int _ITEM_getInt( char *file, int line, int index ,ITEM_DATAINT element) +{ + if(!ITEM_CHECKINDEX(index)){ + return -1; + } + if(!ITEM_CHECKINTDATAINDEX(element)) { + return -1; + } + return ITEM_item[index].itm.data[element]; +} + +INLINE int ITEM_setIntStrict( int index ,ITEM_DATAINT element,int data, + int* error) +{ + int buf; + if(!ITEM_CHECKINDEX(index)) + return *error=FALSE; + if(!ITEM_CHECKINTDATAINDEX(element)) + return *error=FALSE; + buf = ITEM_item[index].itm.data[element]; + ITEM_item[index].itm.data[element] = data; + return buf; +} + +INLINE int _ITEM_setInt( char *file, int line, int index ,ITEM_DATAINT element, int data) +{ + int buf; + if( !ITEM_CHECKINDEX( index) ){ + return -1; + } + + if( !ITEM_CHECKINTDATAINDEX( element) ){ + return -1; + } + + buf = ITEM_item[ index].itm.data[ element]; + ITEM_item[ index].itm.data[ element] = data; + return buf; +} + +INLINE char* ITEM_getChar( int index ,ITEM_DATACHAR element ) +{ + if(!ITEM_CHECKINDEX(index))return NULL; + if(!ITEM_CHECKCHARDATAINDEX(element))return NULL; + return ITEM_item[index].itm.string[element].string; +} + +INLINE BOOL ITEM_setChar( int index ,ITEM_DATACHAR element , char* new) +{ + if(!ITEM_CHECKINDEX(index))return FALSE; + if(!ITEM_CHECKCHARDATAINDEX(element))return FALSE; + strcpysafe( ITEM_item[index].itm.string[element].string, + sizeof( ITEM_item[index].itm.string[element].string ), + new ); + return TRUE; +} + +INLINE int ITEM_getWorkInt( int index ,ITEM_WORKDATAINT element) +{ + if( !ITEM_CHECKINDEX(index) ) return -1; + if( element >= ITEM_WORKDATAINTNUM || element < 0 ) return -1; + return ITEM_item[index].itm.workint[element]; +} + +INLINE int ITEM_setWorkInt( int index ,ITEM_WORKDATAINT element, int data) +{ + int buf; + if( !ITEM_CHECKINDEX( index) ) return -1; + if( element >= ITEM_WORKDATAINTNUM || element < 0 ) return -1; + + buf = ITEM_item[index].itm.workint[element]; + ITEM_item[index].itm.workint[element] = data; + return buf; +} + +INLINE int ITEM_getITEM_itemnum( void ) +{ + return ITEM_itemnum; +} + +INLINE int ITEM_getITEM_UseItemnum( void ) +{ + return ITEM_UseItemnum; +} + + +INLINE BOOL ITEM_getITEM_use( int index ) +{ + if( !ITEM_CHECKINDEX(index))return FALSE; + return ITEM_item[index].use; +} + +void ITEM_constructFunctable( int itemindex ) +{ + int i; + if( !ITEM_CHECKINDEX(itemindex))return; + + for( i=ITEM_FIRSTFUNCTION; i < ITEM_LASTFUNCTION ; i++ ) { + ITEM_item[itemindex].itm.functable[i-ITEM_FIRSTFUNCTION] + = getFunctionPointerFromName( ITEM_getChar( itemindex,i ) ); + } +} + +void* ITEM_getFunctionPointer( int itemindex, int functype ) +{ + if( !ITEM_CHECKINDEX(itemindex) )return NULL; + if( functype < ITEM_FIRSTFUNCTION || functype >= ITEM_LASTFUNCTION ){ + print( "类型错误:%d\n", functype); + return NULL; + } + return ITEM_item[itemindex].itm. + functable[functype-ITEM_FIRSTFUNCTION]; +} + +int ITEM_getItemMaxIdNum( void) +{ + return ITEM_tblen; +} + +BOOL ITEM_checksetdata( void ) +{ + int i; + char* strings[ITEM_DATAINTNUM + ITEM_DATACHARNUM + 1]; +#ifdef _SIMPLIFY_ITEMSTRING + int num=0; + for(i = 0; i < arraysizeof( ITEM_setintdata) ; i ++ ) + strings[ num++ ] = ITEM_setintdata[i].dumpchar; + for( i = 0 ; i < arraysizeof( ITEM_setchardata) ; i ++ ) + strings[ num++ ] = ITEM_setchardata[i].dumpchar; + strings[ITEM_DATAINTNUM+ITEM_DATACHARNUM] = ITEM_setmemdata.dumpchar; + + if( ! checkStringsUnique( strings, num,1 ) ){ + fprint( "ITEM_set????data is overlapped.\nIt is not allowed\n"); + return FALSE; + } +#else + for(i = 0; i < ITEM_DATAINTNUM ; i ++ ) + strings[i] = ITEM_setintdata[i].dumpchar; + for( i = 0 ; i < ITEM_DATACHARNUM ; i ++ ) + strings[ITEM_DATAINTNUM+i] = ITEM_setchardata[i].dumpchar; + + + strings[ITEM_DATAINTNUM+ITEM_DATACHARNUM] = ITEM_setmemdata.dumpchar; + + if( ! checkStringsUnique( strings, arraysizeof( strings ),1 ) ){ + fprint( "ITEM_set????data is overlapped.\nIt is not allowed\n"); + return FALSE; + } +#endif + return TRUE; +} + +static char ITEM_dataString[STRINGBUFSIZ]; +char* ITEM_makeStringFromItemIndex( int index, int mode ) +{ + if( 0 <= index && index < ITEM_itemnum && ITEM_item[index].use == TRUE) + ; + else + return NULL; + return ITEM_makeStringFromItemData( &ITEM_item[index].itm, mode ); +} + +#ifdef _SIMPLIFY_ITEMSTRING2 +BOOL CHECK_HaveBeSave( int itemID, int oneNum, int type ) +{ + if( ITEM_ID == type ) return TRUE; + if( ITEMTBL_getInt( itemID, type) == oneNum ) return FALSE; + return TRUE; +} +#endif + +char* ITEM_makeStringFromItemData( ITEM_Item* one, int mode ) +{ + int i; + char delim1 = '\0'; + char delim2 = '\0'; + int strlength=0; + +#ifdef _SIMPLIFY_ITEMSTRING2 + int itemID = one->data[ ITEM_ID]; + if( !ITEM_CHECKITEMTABLE( itemID) ) return NULL; +#endif + if( mode == 0 ) { + delim1 = '='; delim2 = '|'; + }else { + delim1 = ':'; delim2 = ','; + } + +#ifdef _SIMPLIFY_ITEMSTRING + for(i = 0; i < arraysizeof( ITEM_setintdata) ; i ++ ){ + char linedata[128]; +#ifdef _SIMPLIFY_ITEMSTRING2 + if( !CHECK_HaveBeSave( itemID, one->data[ ITEM_setintdata[i].table], ITEM_setintdata[i].table) ) continue; +#endif + snprintf( linedata , sizeof(linedata), + "%s%c%d%c", ITEM_setintdata[i].dumpchar, delim1, + one->data[ ITEM_setintdata[i].table], delim2 ); + strcpysafe( &ITEM_dataString[strlength], sizeof( ITEM_dataString ) - strlength, linedata ); + strlength += strlen( linedata ); + } + + for( i = 0 ; i < arraysizeof( ITEM_setchardata) ; i ++ ){ + char linedata[128]; + char escapebuffer[128]; + if( strlen( one->string[ ITEM_setchardata[i].table].string) == 0 ) continue; + + snprintf( linedata , sizeof(linedata), + "%s%c%s%c", ITEM_setchardata[i].dumpchar,delim1, + makeEscapeString( one->string[ITEM_setchardata[i].table].string, escapebuffer, + sizeof(escapebuffer)), delim2); + strcpysafe( &ITEM_dataString[strlength], sizeof( ITEM_dataString ) - strlength, linedata ); + strlength += strlen( linedata ); + } +#else + for( i = 0 ; i < ITEM_DATAINTNUM ; i ++ ) { + char linedata[128]; + snprintf( linedata , sizeof(linedata), + "%s%c%d%c", ITEM_setintdata[i].dumpchar, delim1, one->data[i], delim2 ); + strcpysafe( &ITEM_dataString[strlength], sizeof( ITEM_dataString ) - strlength, linedata ); + strlength += strlen( linedata ); + } + + for( i = 0 ; i < ITEM_DATACHARNUM ; i ++ ){ + char linedata[128]; + char escapebuffer[128]; + if( strlen( one->string[i].string) != 0 ) { + snprintf( linedata , sizeof(linedata), + "%s%c%s%c", ITEM_setchardata[i].dumpchar,delim1, + makeEscapeString(one->string[i].string,escapebuffer, + sizeof(escapebuffer)), delim2); + strcpysafe( &ITEM_dataString[strlength], sizeof( ITEM_dataString ) - strlength, linedata ); + strlength += strlen( linedata ); + } + } +#endif + dchop( ITEM_dataString, (mode == 0 ) ? "|" : ","); + return ITEM_dataString; +} + +BOOL ITEM_makeExistItemsFromStringToArg( char* src , ITEM_Item* item, int mode ) +{ + int readindex=1; + char delim1[2]; + char delim2[2]; + + if( mode == 0 ) { + strcpy( delim1, "="); + strcpy( delim2, "|"); + } + else { + strcpy( delim1, ":"); + strcpy( delim2, ","); + } +#ifdef _SIMPLIFY_ITEMSTRING + { + + int itemID=-1; + while( 1 ){ + char linebuf[512]; + char firstToken[256]; + char secondToken[256]; + if( getStringFromIndexWithDelim( src ,delim2 , readindex, linebuf, sizeof( linebuf)) == FALSE ) break; + + readindex++; + if( getStringFromIndexWithDelim( linebuf, delim1, 1, firstToken, sizeof( firstToken )) == FALSE )return FALSE; + if( strcmp( firstToken, "id" ) ) continue; + strcpysafe( secondToken , sizeof( secondToken ), linebuf + strlen( firstToken) + strlen( delim1) ); + itemID = atoi( secondToken); + if( !ITEM_CHECKITEMTABLE( itemID) ) return FALSE; + ITEM_getDefaultItemData( itemID, item); + break; + } + readindex =1; + } +#else + ITEM_getDefaultItemSetting(item); +#endif + + while( 1 ){ + BOOL ret; + char linebuf[512]; + + char firstToken[256]; + char secondToken[256]; + int i; + + ret = getStringFromIndexWithDelim( src ,delim2 , readindex,linebuf, sizeof(linebuf) ); + if( ret == FALSE ) + break; + ret = getStringFromIndexWithDelim( linebuf, delim1, 1, firstToken, sizeof( firstToken ) ); + if( ret == FALSE ) return FALSE; + strcpysafe( secondToken , sizeof( secondToken ), + linebuf + strlen(firstToken) + strlen(delim1) ); +#ifdef _SIMPLIFY_ITEMSTRING + for(i = 0; i < arraysizeof( ITEM_setintdata) ; i ++ ){ + if( strcmp( firstToken , ITEM_setintdata[i].dumpchar) ) continue; + item->data[ITEM_setintdata[i].table] = atoi( secondToken ); + goto NEXT; + } + + for(i = 0; i < arraysizeof( ITEM_setchardata) ; i ++ ){ + if( strcmp(firstToken ,ITEM_setchardata[i].dumpchar ) ) continue; + strcpysafe( item->string[ ITEM_setchardata[i].table].string, + sizeof(item->string[ITEM_setchardata[i].table].string), + makeStringFromEscaped(secondToken)); + goto NEXT; + } +#else + for( i = 0 ; i < ITEM_DATAINTNUM ; i ++ ){ + if( strcmp(firstToken ,ITEM_setintdata[i].dumpchar) == 0 ){ + item->data[i] = atoi( secondToken ); + goto NEXT; + } + } + + for( i = 0 ; i < ITEM_DATACHARNUM ; i ++ ){ + if( strcmp(firstToken ,ITEM_setchardata[i].dumpchar ) == 0 ){ + strcpysafe( item->string[i].string, + sizeof(item->string[i].string), + makeStringFromEscaped(secondToken)); + goto NEXT; + } + } +#endif + fprint( "??? : %s[%s]\n" , src , firstToken ); + + NEXT: + readindex++; + } + + return TRUE; +} + +void ITEM_getDefaultItemSetting(ITEM_Item* itm) +{ + int i; + memset( itm, 0 , sizeof( ITEM_Item )); +#ifdef _SIMPLIFY_ITEMSTRING + for(i = 0; i < arraysizeof( ITEM_setintdata) ; i ++ ){ + itm->data[ITEM_setintdata[i].table] = ITEM_setintdata[i].defaults; + } + for(i = 0; i < arraysizeof( ITEM_setchardata) ; i ++ ){ + strcpysafe( itm->string[ITEM_setchardata[i].table].string, + sizeof( itm->string[ITEM_setchardata[i].table].string), + ITEM_setchardata[i].defaults); + } +#else + for(i=0;idata[i] = ITEM_setintdata[i].defaults; + for(i=0;istring[i].string, + sizeof(itm->string[i].string), + ITEM_setchardata[i].defaults); +#endif + + strcpysafe( itm->string[ITEM_WATCHFUNC].string, + sizeof(itm->string[ITEM_WATCHFUNC].string), "ITEM_DeleteTimeWatched" ); + + + for(i=0;iworkint[i] = -1; + } + +} + +#ifdef _SIMPLIFY_ITEMSTRING +void ITEM_getDefaultItemData( int itemID, ITEM_Item* itm) +{ + int i; +// memset( itm, 0 , sizeof( ITEM_Item )); + + for(i=0;idata[i] = ITEMTBL_getInt( itemID, i); + } + for(i=0;istring[i].string, sizeof( itm->string[i].string), + ITEMTBL_getChar( itemID, i) ); + } + for(i=0;iworkint[i] = -1; + } + + strcpysafe( itm->string[ITEM_WATCHFUNC].string, sizeof( itm->string[ITEM_WATCHFUNC].string), + "ITEM_DeleteTimeWatched" ); + +} +#endif + +static int ITEM_getRandomValue( char* string,int* randomwidth, int num ) +{ + int minvalue; + int maxvalue; + char token[64]; + int ret; +#if 1 + *randomwidth = 0; + + ret = getStringFromIndexWithDelim( string,",",num -1,token, sizeof( token)); + if( ret == FALSE ) { + return 0; + } + minvalue = atoi( token); + ret = getStringFromIndexWithDelim( string,",",num ,token, sizeof( token)); + if( ret == FALSE ) { + return minvalue; + } + maxvalue = atoi( token); + *randomwidth = ABS( maxvalue - minvalue); + return min( minvalue, maxvalue); + +#else + minvalue = atoi( string ); + startmax = index( string,',' ); + if( startmax != NULL ){ + maxvalue = atoi(startmax+1); + *randomwidth = ABS(maxvalue - minvalue); + return min(minvalue,maxvalue); + } + *randomwidth = 0; + return minvalue; +#endif +} +static int ITEM_isstring1or0( char* string,int* randomwidth, int num ) +{ + char token[64]; + int ret; + + ret = getStringFromIndexWithDelim( string,",",num -1,token, sizeof( token)); + if( ret == FALSE ) { + return FALSE; + } + + return isstring1or0( token); +} + +static char* ITEM_checkString( char* string ) +{ +#define ITEM_STRINGLEN 64 + if( strlen(string) >= ITEM_STRINGLEN ) + print( "Over %d:[%s]\n",ITEM_STRINGLEN ,string ); + return string; +#undef ITEM_STRINGLEN +} + +BOOL ITEM_readItemConfFile( char* filename ) +{ + FILE* f; + char line[512]; + char token[64]; + int linenum=0; + int i; + int maxid=0, itemid; + int ret; + int intdata[ITEM_DATAINTNUM]; + + f = fopen(filename,"r"); + if( f == NULL ){ + print( "不能打开文件\n"); + return FALSE; + } +#ifdef _ITEMSET2_ITEM + +#define ITEM_ID_TOKEN_INDEX 17 + +#else + +#ifdef _ITEM_MAXUSERNUM +#define ITEM_ID_TOKEN_INDEX 15 +#endif + +#endif + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + + ret = getStringFromIndexWithDelim( line, ",", ITEM_ID_TOKEN_INDEX, token, sizeof(token)); + if( ret == FALSE ){ + fprint("文件秩序错误:%s 第:%d行\n",filename,linenum); + continue; + } + itemid = atoi( token); + if( itemid > maxid ){ + maxid = itemid; + } + } + + if( maxid <=0 ) { + print( "最大ID错误\n"); + fclose(f); + return FALSE; + } + + if( fseek( f, 0, SEEK_SET ) == -1 ){ + fprint( "搜索错误\n" ); + fclose(f); + return FALSE; + } +#ifdef _IMPOROVE_ITEMTABLE + ITEM_tblen = linenum+1; + print( "物品数 %d - 大小:%d\n", linenum, sizeof(ITEM_table)); + if( ITEM_TransformList != NULL ) + freeMemory( ITEM_TransformList); + defitemtbls = (maxid+1); + ITEM_TransformList = allocateMemory( sizeof(sITEM_transformList) * defitemtbls ); + for( i = 0 ; i < (maxid+1); i ++ ) { + ITEM_TransformList[i].use = FALSE; + } +#else + print( "物品最大ID %d", maxid); + ITEM_tblen = maxid + 1; +#endif + +#ifdef _ITEMTBL_STAIC + for( i = 0 ; i < 28000 ; i ++ ) { + ITEM_tbl[i].use = FALSE; + } +#else + if( ITEM_tbl != NULL ) + freeMemory( ITEM_tbl); + ITEM_tbl = allocateMemory( sizeof(ITEM_table) * ITEM_tblen ); + + if( ITEM_tbl == NULL ){ + fprint( "无法分配内存 %d\n" , sizeof(ITEM_table)*ITEM_tblen ); + fclose( f ); + return FALSE; + } + for( i = 0 ; i < ITEM_tblen ; i ++ ) { + ITEM_tbl[i].use = FALSE; + } +#endif + linenum = 0; + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + replaceString( line, '\t' , ' ' ); + +{ + char buf[256]; + for( i = 0; i < strlen( line); i ++) { + if( line[i] != ' ' ) { + break; + } + strcpy( buf, &line[i]); + } + if( i != 0 ) { + strcpy( line, buf); + } +} +{ + char token[256]; + int ret; + int readpos = 1; + BOOL dataerror = FALSE; + ITEM_Item itm; + + ITEM_getDefaultItemSetting(&itm); + + for( i=0 ; i< ITEM_DATAINTNUM ; i++ ) { + intdata[i] = 0; + } + itemid = 0; + for( i = 0 ; i < arraysizeof( ITEM_itemconfentries) ; i ++ ){ + ret = getStringFromIndexWithDelim( line,",",readpos,token, sizeof(token)); + if( ret == FALSE ) { +#ifdef _Item_ReLifeAct + { + char buf[256]; + char buf1[256]; + sscanf( line,"%s,%s", buf, buf1); + print("[ITEM data Error] tbl=%d:%s line:%d[%s]\n", + readpos, ITEM_itemconfentries[i].entryname, linenum, line); + } +#else + fprint("Syntax Error tki:%d file:%s line:%d[%s]\n", + i , filename,linenum,line); +#endif + dataerror = TRUE; + break; + } + + if( readpos == ITEM_ID_TOKEN_INDEX ) + itemid = atoi( token); + + readpos ++; + + if( strlen( token ) != 0 ) { + switch(ITEM_itemconfentries[i].type){ + case ITEM_INTENTRY: + itm.data[ITEM_itemconfentries[i].index] = atoi( token ); + break; + case ITEM_CHARENTRY: + strcpysafe( itm.string[ITEM_itemconfentries[i].index].string, + sizeof(itm.string[ITEM_itemconfentries[i].index].string), + token); + break; + case ITEM_INTFUNC: + { + int (*intfunction)(char*,int*, int ); + intfunction = ITEM_itemconfentries[i].func; + itm.data[ITEM_itemconfentries[i].index] + = intfunction(line, + &intdata[ITEM_itemconfentries[i].index],readpos); + if( intfunction == ITEM_getRandomValue) readpos ++; + + } + break; + case ITEM_CHARFUNC: + { + char* (*charfunction)(char* ); + charfunction = ITEM_itemconfentries[i].func; + strcpysafe( itm.string[ITEM_itemconfentries[i].index].string, + sizeof(itm.string[ITEM_itemconfentries[i].index].string), + charfunction( token)); + break; + } + default: + break; + } + } + } + if( !dataerror) { +#ifdef _IMPOROVE_ITEMTABLE + int ListNum = itemid; + itemid = totalitemtbls; +#endif + if( itemid >= ITEM_tblen ){ + print( "ITEM_tbl full:%d err !!\n" , itemid ); + }else if( ITEM_tbl[itemid].use == TRUE ) { + fprint( "Duplicate Itemid %d.ignore\n" , itemid ); + }else{ + if( itm.string[ITEM_SECRETNAME].string[0] == '\0') { + fprint( "ERROR: ID %d item doesn't have secretname\n" + ,itemid ); + memcpy( &itm.string[ITEM_SECRETNAME].string, + &itm.string[ITEM_NAME].string, + sizeof(itm.string[ITEM_NAME].string)); + } +{ + int attacknum_min, attacknum_max; + attacknum_min = itm.data[ITEM_ATTACKNUM_MIN]; + attacknum_max = itm.data[ITEM_ATTACKNUM_MAX]; + if( attacknum_min == 0 ) attacknum_min = attacknum_max; + itm.data[ITEM_ATTACKNUM_MIN] = min( attacknum_min, + attacknum_max); + itm.data[ITEM_ATTACKNUM_MAX] = max( attacknum_min, + attacknum_max); +} + memcpy( &ITEM_tbl[itemid].itm, &itm, sizeof(ITEM_Item)); + ITEM_tbl[itemid].use = TRUE; + + for( i=0 ; i< ITEM_DATAINTNUM ; i++ ){ + ITEM_tbl[itemid].randomdata[i] = intdata[i]; + } +#ifdef _IMPOROVE_ITEMTABLE + + if( ITEM_TransformList[ ListNum].use != 0 ){ + ITEM_tbl[itemid].use = TRUE; + ITEM_TransformList[ ListNum].use = 0; + }else { + ITEM_TransformList[ ListNum].Si = totalitemtbls; + ITEM_TransformList[ ListNum].use = TRUE; + } + totalitemtbls++; +#endif + } + } +} + } + fclose(f); + return TRUE; +} + +CHAR_EquipPlace ITEM_getEquipPlace( int charaindex, int itmid ) +{ + ITEM_CATEGORY cat; + cat = ITEM_getInt( itmid , ITEM_TYPE ); + switch( cat ){ + case ITEM_FIST: + case ITEM_SPEAR: + case ITEM_AXE: + case ITEM_CLUB: +// case ITEM_SHIELD: + case ITEM_BOOMERANG: + case ITEM_BREAKTHROW: + case ITEM_BOUNDTHROW: + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + { + int i=0; + + // 勇士职业技能二刀流 + for( i=0; i 0 ) return -1; +#endif + return CHAR_ARM; + break; + +#ifdef _ITEM_EQUITSPACE + case ITEM_WBELT: + return CHAR_EQBELT; + break; + case ITEM_WSHIELD: + if( BATTLE_GetWepon( charaindex ) != ITEM_BOW ) + return CHAR_EQSHIELD; + break; + case ITEM_WSHOES: + return CHAR_EQSHOES; + break; +#endif + +#ifdef _EQUIT_NEWGLOVE + case ITEM_WGLOVE: + return CHAR_EQGLOVE; + break; +#endif + default: + break; + } + return -1; +} +#define ITEMSTRINGBUFSIZ 512 +static char ITEM_itemStatusStringBuffer[ITEMSTRINGBUFSIZ]; +char* ITEM_makeItemStatusString( int haveitemindex, int itemindex ) +{ + char escapename[256]; + char escapeeffectstring[256]; + char paramshow[256]; + int leaklevel; + int itemcolor = 0; + int flg; + char INGNAME0[4]; + char INGNAME1[4]; + + if( !ITEM_CHECKINDEX(itemindex) ) return NULL; + leaklevel = ITEM_getInt(itemindex,ITEM_LEAKLEVEL); + + //if( leaklevel >= 1 ) // Nuke debug + { + makeEscapeString( ITEM_getChar(itemindex, ITEM_SECRETNAME), + escapename, sizeof(escapename) ); + /*if( leaklevel >= 2 ) + { + static struct Showparamint{ + char* name; + int intindex; + }showparamint[]={ + { "ATK" , ITEM_MODIFYATTACK }, + { "DEF" , ITEM_MODIFYDEFENCE }, + { "HP" , ITEM_MODIFYHP }, + { "MP" , ITEM_MODIFYMP }, + { "QUICK" , ITEM_MODIFYQUICK }, + { "LUCK" , ITEM_MODIFYLUCK }, + { "CHARM" , ITEM_MODIFYCHARM }, + }; + int i; + int stringlen=0; + + paramshow[0] = '\0'; + + for( i = 0 ; i < arraysizeof( showparamint ); i ++ ){ + int value; + char sign; + char tmpbuf[128]; + value = ITEM_getInt(itemindex,showparamint[i].intindex); + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + + + +#endif + + if( value == 0 )continue; + else if( value > 0 ) sign = '+'; + else sign = '-'; + + snprintf( tmpbuf,sizeof( tmpbuf ), "%s%c%d ", + showparamint[i].name,sign,ABS(value) ); + + strcpysafe( paramshow + stringlen , + sizeof(paramshow) - stringlen, tmpbuf ); + stringlen +=strlen(tmpbuf); + if( stringlen >= arraysizeof( paramshow )) + break; + } + dchop( paramshow , " " ); + } + else*/ + paramshow[0] = '\0'; + + } + /*else{ + if(strlen(ITEM_getChar(itemindex,ITEM_SECRETNAME)) > 0){ + makeEscapeString(ITEM_getChar(itemindex,ITEM_SECRETNAME),escapename,sizeof(escapename)); + } + else makeEscapeString( ITEM_getChar(itemindex,ITEM_NAME),escapename,sizeof(escapename)); + paramshow[0] = '\0'; + }*/ + + makeEscapeString( ITEM_getChar( itemindex, ITEM_EFFECTSTRING), + escapeeffectstring, + sizeof(escapeeffectstring)); + itemcolor = CHAR_COLORWHITE; + if( strlen( ITEM_getChar( itemindex, ITEM_CDKEY)) != 0 ) { + itemcolor = CHAR_COLORGREEN; + }else { + if( ITEM_getInt( itemindex, ITEM_MERGEFLG) ) { + itemcolor = CHAR_COLORYELLOW; + } + } + flg = 0; + if( ITEM_getInt( itemindex, ITEM_CANPETMAIL)) { + flg |= 1 << 0; + } + if( ITEM_getInt( itemindex, ITEM_CANMERGEFROM)) { + flg |= 1 << 1; + } + if( ITEM_getInt( itemindex, ITEM_TYPE) == ITEM_DISH ) { + flg |= 1 << 2; + } +#ifdef _ITEM_INSLAY + if( ITEM_getInt( itemindex, ITEM_TYPE) == ITEM_METAL ) { + flg |= 1 << 3; + }else if( ITEM_getInt( itemindex, ITEM_TYPE) == ITEM_JEWEL ) { + flg |= 1 << 4; + } +#endif +#ifdef _PETSKILL_FIXITEM + if( ITEM_getInt( itemindex, ITEM_DAMAGECRUSHE) + != ITEM_getInt( itemindex, ITEM_MAXDAMAGECRUSHE) ){ + flg |= 1 << 5; + } +#endif + +#ifdef _ALCHEMIST + strcpy( INGNAME0, ITEM_getChar( itemindex, ITEM_INGNAME0) ); + strcpy( INGNAME1, ITEM_getChar( itemindex, ITEM_INGNAME1) ); + if( (INGNAME0[0] != NULL && INGNAME1[0] != NULL) || (INGNAME0[0] == NULL) ) { + strcpy( INGNAME0, "杂" ); + } +#endif + + if( haveitemindex == -1 ) { +#ifdef _ADD_SHOW_ITEMDAMAGE // WON ADD 显示物品耐久度 + char buff1[256]; + int crushe = ITEM_getInt( itemindex, ITEM_DAMAGECRUSHE); + int maxcrushe = ITEM_getInt( itemindex, ITEM_MAXDAMAGECRUSHE); + if(crushe < 1) crushe = 1; + if(maxcrushe < 1){ + sprintf(buff1, "不会损坏"); + }else{ + maxcrushe = maxcrushe/1000; + crushe = crushe/1000; + if( maxcrushe <= 0 ) maxcrushe = 1; + snprintf(buff1, sizeof(buff1), "%d%%", (int)((crushe*100)/maxcrushe) ); + } + + snprintf(ITEM_itemStatusStringBuffer, + sizeof( ITEM_itemStatusStringBuffer), +#ifdef _ITEM_PILENUMS +#ifdef _ALCHEMIST + "%s|%s|%d|%s|%d|%d|%d|%d|%d|%s|%d|%s", +#else + "%s|%s|%d|%s|%d|%d|%d|%d|%d|%s|%d", +#endif +#else + "%s|%s|%d|%s|%d|%d|%d|%d|%d|%s", +#endif + escapename, paramshow, + itemcolor, escapeeffectstring , + ITEM_getInt( itemindex, ITEM_BASEIMAGENUMBER), + ITEM_getInt( itemindex, ITEM_ABLEUSEFIELD), + ITEM_getInt( itemindex, ITEM_TARGET), + ITEM_getInt( itemindex, ITEM_LEVEL), + flg, + buff1 +#ifdef _ITEM_PILENUMS + ,ITEM_getInt( itemindex, ITEM_USEPILENUMS) +#ifdef _ALCHEMIST + ,INGNAME0 //,ITEM_getInt( itemindex, ITEM_ALCHEMIST) +#endif +#endif + ); +#else + snprintf(ITEM_itemStatusStringBuffer, + sizeof( ITEM_itemStatusStringBuffer), + "%s|%s|%d|%s|%d|%d|%d|%d|%d", + escapename, paramshow, + itemcolor, escapeeffectstring , + ITEM_getInt( itemindex, ITEM_BASEIMAGENUMBER), + ITEM_getInt( itemindex, ITEM_ABLEUSEFIELD), + ITEM_getInt( itemindex, ITEM_TARGET), + ITEM_getInt( itemindex, ITEM_LEVEL), + flg + ); +#endif + }else { +#ifdef _ADD_SHOW_ITEMDAMAGE // WON ADD 显示物品耐久度 + char buff1[256]; + int crushe = ITEM_getInt( itemindex, ITEM_DAMAGECRUSHE); + int maxcrushe = ITEM_getInt( itemindex, ITEM_MAXDAMAGECRUSHE); + if(crushe < 1) crushe = 1; + if(maxcrushe < 1){ + sprintf(buff1, "不会损坏"); + }else{ + maxcrushe = maxcrushe/1000; + crushe = crushe/1000; + if( maxcrushe <= 0 ) maxcrushe = 1; + snprintf(buff1, sizeof(buff1), "%d%%", (int)((crushe*100)/maxcrushe) ); + } + snprintf(ITEM_itemStatusStringBuffer, sizeof( ITEM_itemStatusStringBuffer), + +#ifdef _ITEM_PILENUMS +#ifdef _ALCHEMIST + "%d|%s|%s|%d|%s|%d|%d|%d|%d|%d|%s|%d|%s", +#else + "%d|%s|%s|%d|%s|%d|%d|%d|%d|%d|%s|%d", +#endif +#else + "%d|%s|%s|%d|%s|%d|%d|%d|%d|%d|%s", +#endif + haveitemindex, + escapename, paramshow, + itemcolor, escapeeffectstring , + ITEM_getInt( itemindex, ITEM_BASEIMAGENUMBER), + ITEM_getInt( itemindex, ITEM_ABLEUSEFIELD), + ITEM_getInt( itemindex, ITEM_TARGET), + ITEM_getInt( itemindex, ITEM_LEVEL), + flg, + buff1 +#ifdef _ITEM_PILENUMS + ,ITEM_getInt( itemindex, ITEM_USEPILENUMS) +#ifdef _ALCHEMIST + ,INGNAME0 //,ITEM_getInt( itemindex, ITEM_ALCHEMIST) +#endif +#endif + ); +#else + snprintf(ITEM_itemStatusStringBuffer, + sizeof( ITEM_itemStatusStringBuffer), + "%d|%s|%s|%d|%s|%d|%d|%d|%d|%d", + haveitemindex, + escapename, paramshow, + itemcolor, escapeeffectstring , + ITEM_getInt( itemindex, ITEM_BASEIMAGENUMBER), + ITEM_getInt( itemindex, ITEM_ABLEUSEFIELD), + ITEM_getInt( itemindex, ITEM_TARGET), + ITEM_getInt( itemindex, ITEM_LEVEL), + flg + ); +#endif + } + + return ITEM_itemStatusStringBuffer; +} + +char* ITEM_makeItemFalseString( void ) +{ + +#ifdef _ADD_SHOW_ITEMDAMAGE // WON ADD 显示物品耐久度 + strcpysafe( ITEM_itemStatusStringBuffer, + sizeof( ITEM_itemStatusStringBuffer), +#ifdef _ITEM_PILENUMS +#ifdef _ALCHEMIST + "|||||||||||" +#else + "||||||||||" +#endif +#else + "|||||||||" +#endif + ); + +#else + strcpysafe( ITEM_itemStatusStringBuffer, + sizeof( ITEM_itemStatusStringBuffer), + "||||||||" ); +#endif + return ITEM_itemStatusStringBuffer; +} + +char* ITEM_makeItemFalseStringWithNum( int haveitemindex ) +{ +#ifdef _ADD_SHOW_ITEMDAMAGE // WON ADD 显示物品耐久度 + snprintf( ITEM_itemStatusStringBuffer, sizeof( ITEM_itemStatusStringBuffer), + +#ifdef _ITEM_PILENUMS +#ifdef _ALCHEMIST + "%d||||||||||||", +#else + "%d|||||||||||", +#endif +#else + "%d||||||||||", +#endif + haveitemindex ); +#else + snprintf( ITEM_itemStatusStringBuffer, sizeof( ITEM_itemStatusStringBuffer), + "%d|||||||||", haveitemindex); +#endif + return ITEM_itemStatusStringBuffer; +} + +BOOL ITEM_makeItem( ITEM_Item* itm, int number ) +{ + int i; +#ifdef _IMPOROVE_ITEMTABLE + int Itemsi; +#endif + if( ITEM_CHECKITEMTABLE(number) == FALSE ){ + print(" Can't makeItem for itemid:%d!!\n", number); + return FALSE; + } +#ifdef _IMPOROVE_ITEMTABLE + Itemsi = ITEM_getSIndexFromTransList( number); + memcpy( itm, &ITEM_tbl[Itemsi].itm , sizeof( ITEM_Item ) ); //new + for( i=0 ; idata[i] = ITEM_tbl[Itemsi].itm.data[i] + randomvalue; //new + } +#else + memcpy( itm, &ITEM_tbl[number].itm , sizeof( ITEM_Item ) ); //new + for( i=0 ; idata[i] = ITEM_tbl[number].itm.data[i] + randomvalue; //new + } +#endif + itm->data[ITEM_LEAKLEVEL] = 1; + return TRUE; +} + +int ITEM_makeItemAndRegist( int number ) +{ + ITEM_Item itm; + memset( &itm, 0, sizeof( itm)); + if( ITEM_makeItem( &itm, number ) == FALSE ) + return -1; + return ITEM_initExistItemsOne( &itm ); +} + +#define EQUIP_FIX_MAX 10000000 +void ITEM_equipEffect( int index ) +{ + int i; + int attribaccum[4] = { 0,0,0,0}; +#ifdef _ANGEL_SUMMON + int angelmode, angelequip =0; +#endif + static struct itmeffectstruct{ + int itemdataintindex; + int charmodifyparamindex; + int accumulation; + int min; + int max; + int type; + }itemEffect[]={ + { ITEM_MODIFYATTACK, CHAR_WORKATTACKPOWER, 0, 0, EQUIP_FIX_MAX, 0}, + { ITEM_MODIFYDEFENCE, CHAR_WORKDEFENCEPOWER, -100, 0, EQUIP_FIX_MAX, 0}, + { ITEM_MODIFYQUICK, CHAR_WORKQUICK, -100, 0, EQUIP_FIX_MAX, 0}, + { ITEM_MODIFYHP, CHAR_WORKMAXHP, 0, 0, EQUIP_FIX_MAX, 0}, + { ITEM_MODIFYMP, CHAR_WORKMAXMP, 0, 0, 1000, 0}, // MP 反100引匹 + + { ITEM_MODIFYLUCK, CHAR_WORKFIXLUCK, 0, 1, 5, 0}, + { ITEM_MODIFYCHARM, CHAR_WORKFIXCHARM, 0, 0, 100, 0}, + { ITEM_MODIFYAVOID, CHAR_WORKFIXAVOID, 0, 0, EQUIP_FIX_MAX, 0}, + { ITEM_POISON, CHAR_WORKMODPOISON, 0, -100, 100, 0}, + { ITEM_PARALYSIS, CHAR_WORKMODPARALYSIS, 0, -100, 100, 0}, + { ITEM_SLEEP, CHAR_WORKMODSLEEP, 0, -100, 100, 0}, + { ITEM_STONE, CHAR_WORKMODSTONE, 0, -100, 100, 0}, + { ITEM_DRUNK, CHAR_WORKMODDRUNK, 0, -100, 100, 0}, + { ITEM_CONFUSION, CHAR_WORKMODCONFUSION, 0, -100, 100, 0}, + { ITEM_CRITICAL, CHAR_WORKMODCRITICAL, 0, -100, 100, 0}, +#ifdef _ADD_DEAMGEDEFC + { ITEM_OTHERDAMAGE, CHAR_WORKOTHERDMAGE, 0, -100, 100, 0}, + { ITEM_OTHERDEFC, CHAR_WORKOTHERDEFC, 0, -100, 100, 0}, +#endif + +#ifdef _ITEMSET5_TXT + { ITEM_MODIFYARRANGE, CHAR_WORKFIXARRANGE, 0, 0, 1000, 0}, + { ITEM_MODIFYSEQUENCE, CHAR_WORKFIXSEQUENCE, 0, 0, 100, 1}, + { ITEM_ATTACHPILE, CHAR_WORKATTACHPILE, 0, 0, 10, 1}, + { ITEM_HITRIGHT, CHAR_WORKHITRIGHT, 0, 0, 40, 1}, +#endif +#ifdef _ITEMSET6_TXT + { ITEM_NEGLECTGUARD, CHAR_WORKNEGLECTGUARD, 0, 0, 30, 1}, +#endif + }; + + for( i = 0 ; i < arraysizeof( itemEffect ); i ++ ) + itemEffect[i].accumulation = 0; + + if( !CHAR_CHECKINDEX(index) )return; + +#ifdef _ANGEL_SUMMON + angelmode = CHAR_getWorkInt( index, CHAR_WORKANGELMODE); +#endif + + for( i = 0 ; i < CHAR_EQUIPPLACENUM ; i ++ ){ + int id = CHAR_getItemIndex(index,i); + if( ITEM_CHECKINDEX(id) ){ + int j; + int attrib = 0; + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + if( i == CHAR_ARM ) + CHAR_sendStatusString( index , "S"); +#endif + + for( j=0; j < arraysizeof( itemEffect ); j ++ ) { +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + + if( i == CHAR_EQSHIELD ){ + int item_type = ITEM_FIST; + item_type = ITEM_getInt( id, ITEM_TYPE ); + + // 当左手装备武器的时候 + if( item_type != ITEM_WSHIELD ){ + int k; + // 勇士职业技能二刀流 + for( k=0; kskill, SKILL_LEVEL); + skill_level = PROFESSION_CHANGE_SKILL_LEVEL_A( skill_level ); + rate = (skill_level * 3 + 20); + value = ITEM_getInt( id, itemEffect[j].itemdataintindex ) * rate / 100; + itemEffect[j].accumulation += value; + } + } + }else + itemEffect[j].accumulation += ITEM_getInt( id, itemEffect[j].itemdataintindex ); + }else +#endif + itemEffect[j].accumulation += ITEM_getInt( id, itemEffect[j].itemdataintindex ); + } + + attrib = ITEM_getInt( id, ITEM_MODIFYATTRIB); + if( attrib > 0 && attrib < 5) { + attribaccum[attrib - 1] += ITEM_getInt( id, ITEM_MODIFYATTRIBVALUE); + } + +#ifdef _ANGEL_SUMMON + //if( !strcmp( ITEM_getChar( id, ITEM_USEFUNC), "ITEM_AngelToken") ) { + if( ITEM_getInt( id, ITEM_ID) == ANGELITEM ) { + //print(" 使者信物装备中 "); + angelequip = TRUE; + } +#endif + + + } + } + +#ifdef _ANGEL_SUMMON + if( angelmode == TRUE && angelequip == FALSE ) { + CHAR_setWorkInt( index, CHAR_WORKANGELMODE, FALSE); + CHAR_sendAngelMark( CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), 0); + print(" 卸下使者信物 "); + } + if( angelmode == FALSE && angelequip == TRUE ) { + CHAR_setWorkInt( index, CHAR_WORKANGELMODE, TRUE); + CHAR_sendAngelMark( CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), 1); + CHAR_talkToCli( index, -1, "你受到了精灵保护,不会被敌人攻击。", CHAR_COLORYELLOW ); + print(" 装备使者信物 "); + } +#endif + +#ifdef _FIX_MAXCHARMP + for(i = 3 ; i < arraysizeof( itemEffect ) ; i ++ ){ +#else + for(i = 5 ; i < arraysizeof( itemEffect ) ; i ++ ){ +#endif + int work=0; + if( itemEffect[i].type == 1 ){ + work = itemEffect[i].accumulation; + }else{ + work = CHAR_getWorkInt(index,itemEffect[i].charmodifyparamindex) + itemEffect[i].accumulation; + work = min( itemEffect[i].max, work ); + work = max( itemEffect[i].min, work ); + } + CHAR_setWorkInt( index, itemEffect[i].charmodifyparamindex, work ); + } + + + for( i = 0; i < 4; i ++ ) { + CHAR_setWorkInt( index, CHAR_WORKFIXEARTHAT + i, + CHAR_getWorkInt( index, CHAR_WORKFIXEARTHAT + i) + + attribaccum[i]); + } + for( i = 0; i < 4; i ++ ) { + int j; + for( j = 0; j < 4; j ++ ) { + if( i != j ) { + CHAR_setWorkInt( index, CHAR_WORKFIXEARTHAT + j, + CHAR_getWorkInt(index, CHAR_WORKFIXEARTHAT + j) - attribaccum[i]); + } + } + } + for( i = 0; i < 4; i ++ ) { + if( CHAR_getWorkInt( index, CHAR_WORKFIXEARTHAT + i) > CHAR_MAXATTRIB) { + CHAR_setWorkInt( index, CHAR_WORKFIXEARTHAT + i, CHAR_MAXATTRIB); + } + } + + { + int work; + work = CHAR_getWorkInt(index,CHAR_WORKFIXSTR)+ itemEffect[0].accumulation; + CHAR_setWorkInt( index, CHAR_WORKFIXSTR, max( 0, work ) ); + work = CHAR_getWorkInt(index,CHAR_WORKFIXTOUGH) + itemEffect[1].accumulation; + CHAR_setWorkInt( index, CHAR_WORKFIXTOUGH, max( -100, work ) ); + work = CHAR_getWorkInt( index, CHAR_WORKFIXDEX) + itemEffect[2].accumulation; + CHAR_setWorkInt( index, CHAR_WORKFIXDEX, max( -100, work ) ); + } + +} + +void Other_DefcharWorkInt( int index) +{ + +#ifdef _SUIT_ITEM + int mfix,mtgh,mdex,mods,maxhp; + mfix = CHAR_getWorkInt( index, CHAR_WORKFIXSTR); + mtgh = CHAR_getWorkInt( index, CHAR_WORKFIXTOUGH); + mdex = CHAR_getWorkInt( index, CHAR_WORKFIXDEX); + maxhp = CHAR_getWorkInt( index, CHAR_WORKMAXHP); + + mods = CHAR_getWorkInt( index, CHAR_WORKSUITMODSTR); + mfix = mfix+((mfix*mods)/100); + CHAR_setWorkInt( index, CHAR_WORKFIXSTR, mfix+CHAR_getWorkInt( index, CHAR_WORKSUITSTR)); + CHAR_setWorkInt( index, CHAR_WORKFIXTOUGH, mtgh+CHAR_getWorkInt( index, CHAR_WORKSUITTGH)); + CHAR_setWorkInt( index, CHAR_WORKFIXDEX, mdex+CHAR_getWorkInt( index, CHAR_WORKSUITDEX)); + CHAR_setWorkInt( index, CHAR_WORKMAXHP, maxhp+ CHAR_getWorkInt( index, CHAR_WORKSUITVIT)); +#ifdef _SUIT_ADDPART3 + if( mfix > 0 ) + CHAR_setWorkInt( index, CHAR_WORKFIXSTR, CHAR_getWorkInt( index, CHAR_WORKFIXSTR)+mfix*CHAR_getWorkInt( index, CHAR_WORKSUITSTR_P)/100.0); + if( mtgh > 0 ) + CHAR_setWorkInt( index, CHAR_WORKFIXTOUGH, CHAR_getWorkInt( index, CHAR_WORKFIXTOUGH)+mtgh*CHAR_getWorkInt( index, CHAR_WORKSUITTGH_P)/100.0); + if( mdex > 0) + CHAR_setWorkInt( index, CHAR_WORKFIXDEX, CHAR_getWorkInt( index, CHAR_WORKFIXDEX)+mdex*CHAR_getWorkInt( index, CHAR_WORKSUITDEX_P)/100.0); +#endif +#endif//_SUIT_ITEM + +#ifdef _MAGIC_RESIST_EQUIT // WON ADD 职业抗性装备 + /*{ + int f_res = -1, i_res = -1, t_res = -1; + f_res = CHAR_getWorkInt( index, CHAR_WORK_F_RESIST ); + i_res = CHAR_getWorkInt( index, CHAR_WORK_I_RESIST ); + t_res = CHAR_getWorkInt( index, CHAR_WORK_T_RESIST ); + + CHAR_setWorkInt( index, CHAR_WORK_F_RESIST, f_res+CHAR_getWorkInt( index, CHAR_WORK_F_SUIT ) ); + CHAR_setWorkInt( index, CHAR_WORK_I_RESIST, i_res+CHAR_getWorkInt( index, CHAR_WORK_I_SUIT ) ); + CHAR_setWorkInt( index, CHAR_WORK_T_RESIST, t_res+CHAR_getWorkInt( index, CHAR_WORK_T_SUIT ) ); + }*/ +#endif + + +#ifdef _PETSKILL_SETDUCK + //profession fix + //使用回避招式时,会将防值减去30%然後设定成回避值,奇怪的设定,也造成原本设定的回避值跟没设一样,因此我(Change)先把整段拿掉 + /*if( CHAR_getWorkInt( index, CHAR_MYSKILLDUCK) > 0 ){ + int mtgh = CHAR_getWorkInt( index, CHAR_WORKFIXTOUGH); + mtgh -= (mtgh*30)/100; + if( mtgh < 0 ) mtgh=0; + CHAR_setWorkInt( index, CHAR_MYSKILLDUCKPOWER, mtgh); + }*/ +#endif +#ifdef _MAGICPET_SKILL + if( CHAR_getWorkInt( index, CHAR_MYSKILLSTR) > 0 ){ + int mpower, mdef; + mpower = CHAR_getWorkInt( index, CHAR_WORKFIXSTR); + mdef = CHAR_getWorkInt( index, CHAR_MYSKILLSTRPOWER); + mpower += (mtgh*mdef)/100; + if( mtgh < 0 ) mtgh=0; + CHAR_setWorkInt( index, CHAR_WORKFIXSTR, mpower); + } + if( CHAR_getWorkInt( index, CHAR_MYSKILLTGH) > 0 ){ + int mpower, mdef; + mpower = CHAR_getWorkInt( index, CHAR_WORKFIXTOUGH); + mdef = CHAR_getWorkInt( index, CHAR_MYSKILLTGHPOWER); + mpower += (mtgh*mdef)/100; + if( mtgh < 0 ) mtgh=0; + CHAR_setWorkInt( index, CHAR_WORKFIXTOUGH, mpower); + } + if( CHAR_getWorkInt( index, CHAR_MYSKILLDEX) > 0 ){ + int mpower, mdef; + mpower = CHAR_getWorkInt( index, CHAR_WORKFIXDEX); + mdef = CHAR_getWorkInt( index, CHAR_MYSKILLDEXPOWER); + mpower += (mtgh*mdef)/100; + if( mtgh < 0 ) mtgh=0; + CHAR_setWorkInt( index, CHAR_WORKFIXDEX, mpower); + } +#endif + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + if( CHAR_getWorkInt( index, CHAR_MYSKILLHIT) > 0 ){ + int mpower, mdef; + mpower = CHAR_getWorkInt( index, CHAR_MYSKILLHIT); + mdef = CHAR_getWorkInt( index, CHAR_WORKHITRIGHT); + mpower += (mtgh*mdef)/100; + if( mtgh < 0 ) mtgh=0; + CHAR_setWorkInt( index, CHAR_MYSKILLHIT, mpower); + } + if( CHAR_getWorkInt( index, CHAR_WORK_WEAPON) > 0 ){ // 武器专精 + int mpower, mdef; + mpower = CHAR_getWorkInt( index, CHAR_WORKFIXSTR); + mdef = CHAR_getWorkInt( index, CHAR_WORKMOD_WEAPON); + mpower = mpower * ( 100 + mdef ) /100; + if( mtgh < 0 ) mtgh=0; + CHAR_setWorkInt( index, CHAR_WORKFIXSTR, mpower); + } +#endif + +#ifdef _VARY_WOLF + if(CHAR_getInt( index, CHAR_BASEIMAGENUMBER)==101428){ + int Rands=0, power; + Rands = CHAR_getWorkInt( index, CHAR_SKILLSTRPOWER); + power = CHAR_getWorkInt( index, CHAR_WORKFIXSTR); + power = power + (power*Rands)/100; + CHAR_setWorkInt( index, CHAR_WORKFIXSTR, power); + + Rands = CHAR_getWorkInt( index, CHAR_SKILLDEXPOWER); + power = CHAR_getWorkInt( index, CHAR_WORKFIXDEX); + power = power + (power*Rands)/100; + CHAR_setWorkInt( index, CHAR_WORKFIXDEX, power); + } +#endif + +#ifdef _PROFESSION_ADDSKILL + if( CHAR_getWorkInt( index, CHAR_WORKFEAR ) > 0 ){ + CHAR_setWorkInt( index, CHAR_WORKFIXSTR, CHAR_getWorkInt( index, CHAR_WORKFIXSTR ) - mfix*0.1 ); + CHAR_setWorkInt( index, CHAR_WORKFIXTOUGH, CHAR_getWorkInt( index, CHAR_WORKFIXTOUGH ) - mtgh*0.1 ); + CHAR_setWorkInt( index, CHAR_WORKFIXDEX, CHAR_getWorkInt( index, CHAR_WORKFIXDEX ) - mdex*0.2 ); + } +#endif + +#ifdef _MAGIC_WEAKEN + if(CHAR_getWorkInt(index,CHAR_WORKWEAKEN)>0){ + CHAR_setWorkInt( index, CHAR_WORKFIXSTR, CHAR_getWorkInt( index, CHAR_WORKFIXSTR)*0.8); + CHAR_setWorkInt( index, CHAR_WORKFIXTOUGH, CHAR_getWorkInt( index, CHAR_WORKFIXTOUGH)*0.8); + CHAR_setWorkInt( index, CHAR_WORKFIXDEX, CHAR_getWorkInt( index, CHAR_WORKFIXDEX)*0.8); + CHAR_setWorkInt( index, CHAR_WORKWEAKEN, CHAR_getWorkInt( index, CHAR_WORKWEAKEN)-1); + } +#endif +#ifdef _MAGIC_BARRIER// vincent 精灵:魔障 + if( CHAR_getWorkInt( index, CHAR_WORKBARRIER) > 0){ + CHAR_setWorkInt( index, CHAR_WORKBARRIER, CHAR_getWorkInt( index, CHAR_WORKBARRIER) - 1); + } +#endif + + CHAR_setWorkInt(index, CHAR_WORKATTACKPOWER, CHAR_getWorkInt( index, CHAR_WORKFIXSTR ) ); + CHAR_setWorkInt(index, CHAR_WORKDEFENCEPOWER, CHAR_getWorkInt( index, CHAR_WORKFIXTOUGH ) ); + CHAR_setWorkInt(index, CHAR_WORKQUICK, CHAR_getWorkInt( index, CHAR_WORKFIXDEX ) ); +} + +char* ITEM_getAppropriateName(int itemindex) +{ + int nameindex; + if( !ITEM_CHECKINDEX(itemindex ) )return NULL; + if( ITEM_getInt(itemindex,ITEM_LEAKLEVEL) <= 0 ) + nameindex = ITEM_NAME; + else + nameindex = ITEM_SECRETNAME; + return ITEM_getChar(itemindex,nameindex); + +} + +char* ITEM_getEffectString( int itemindex ) +{ + if( !ITEM_CHECKINDEX(itemindex))return NULL; + return ITEM_item[itemindex].itm.string[ITEM_EFFECTSTRING].string; +} + +char *ITEM_getItemInfoFromNumber( int itemid ) +{ + return ITEMTBL_getChar( itemid, ITEM_EFFECTSTRING); +} + +INLINE char* _ITEM_getNameFromNumber( char *file, int line, int itemid ) +{ + if( ITEM_CHECKITEMTABLE(itemid) == FALSE ){ + print("Can't Get ItemTable for:%d! - %s:%d\n",itemid, file, line); + return NULL; + } + return ITEMTBL_getChar( itemid, ITEM_NAME); +} + +int ITEM_getcostFromITEMtabl( int itemid ) +{ + return ITEMTBL_getInt( itemid, ITEM_COST); +} + +int ITEM_getlevelFromITEMtabl( int itemid ) +{ + return ITEMTBL_getInt( itemid, ITEM_LEVEL); +} + +int ITEM_getgraNoFromITEMtabl( int itemid ) +{ + return ITEMTBL_getInt( itemid, ITEM_BASEIMAGENUMBER); +} + +int ITEM_getcanpetmailFromITEMtabl( int itemid ) +{ + return ITEMTBL_getInt( itemid, ITEM_CANPETMAIL); +} + +int ITEM_getvanishatdropFromITEMtabl( int itemid ) +{ + return ITEMTBL_getInt( itemid, ITEM_VANISHATDROP); +} + +int ITEM_getdropatlogoutFromITEMtabl( int itemid ) +{ + return ITEMTBL_getInt( itemid, ITEM_DROPATLOGOUT); +} + +int ITEM_getmergeItemFromFromITEMtabl( int itemid ) +{ + return ITEMTBL_getInt( itemid, ITEM_CANMERGEFROM); +} + +BOOL ITEM_canuseMagic( int itemindex) +{ + if( !ITEM_CHECKINDEX(itemindex))return FALSE; + if( MAGIC_getMagicArray( ITEM_item[itemindex].itm.data[ITEM_MAGICID]) != -1 ) { + return TRUE; + } + return FALSE; +} + +INLINE ITEM_Item *ITEM_getItemPointer( int index ) +{ + if(!ITEM_CHECKINDEX(index))return NULL; + return &ITEM_item[index].itm; +} + +int ITEM_isTargetValid( int charaindex, int itemindex, int toindex) +{ + int itemtarget; + int Myside; + itemtarget = ITEM_getInt( itemindex, ITEM_TARGET ); + + Myside = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLESIDE ); + if ((toindex >= 0x0) && (toindex <= 0x13)) return 0; + + if (toindex == 0x14) {//20 右下全 0 + if (itemtarget == ITEM_TARGET_ALLMYSIDE){ + if( Myside == 0 )return 0; + }else if(itemtarget == ITEM_TARGET_ALLOTHERSIDE ){ + if( Myside == 1 )return 0; + } + }else if (toindex == 0x15) {//21 左上全 1 + if (itemtarget == ITEM_TARGET_ALLMYSIDE){ + if( Myside == 1 )return 0; + }else if( itemtarget == ITEM_TARGET_ALLOTHERSIDE ){ + if( Myside == 0 )return 0; + } + }else if (toindex == 0x16) { + if (itemtarget == ITEM_TARGET_ALL) + return 0; + } + return -1; +} +// Nuke end + + +#ifdef _ITEM_CHECKWARES +BOOL CHAR_CheckInItemForWares( int charaindex, int flg) +{ + int itemindex, i; + char token[256]; + + for( i=0; i<24; i++) { + itemindex = CHAR_getItemIndex( charaindex, i); + if( !ITEM_CHECKINDEX( itemindex) ) continue; + if( ITEM_getInt( itemindex, ITEM_TYPE) == ITEM_WARES ) { + if( flg == 0 ){ + return FALSE; + } + sprintf(token,"交出%s",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + + CHAR_setItemIndex( charaindex, i ,-1); + ITEM_endExistItemsOne( itemindex); + CHAR_sendItemDataOne( charaindex, i); + } + } + return TRUE; +} +#endif + + +#ifdef _IMPOROVE_ITEMTABLE + +BOOL ITEMTBL_CHECKINDEX( int ItemID) +{ + if( ItemID < 0 || ItemID >= defitemtbls ) + return FALSE; + return ITEM_TransformList[ ItemID].use; +} + +int ITEM_getSIndexFromTransList( int ItemID) +{ + if( !ITEMTBL_CHECKINDEX( ItemID) ) + return -1; + return ITEM_TransformList[ ItemID].Si; +} + +int ITEM_getTotalitemtblsFromTransList() +{ + return totalitemtbls; +} + +int ITEM_getMaxitemtblsFromTransList() +{ + return defitemtbls; +} +#endif + +int ITEMTBL_getInt( int ItemID, ITEM_DATAINT datatype) +{ +#ifdef _IMPOROVE_ITEMTABLE + int itemsi=0; + if( !ITEM_CHECKITEMTABLE( ItemID) ) return -1; + itemsi = ITEM_getSIndexFromTransList( ItemID); + if( datatype >= ITEM_DATAINTNUM || datatype < 0 ) return -1; + return ITEM_tbl[itemsi].itm.data[datatype]; //new +#else + if( datatype >= ITEM_DATAINTNUM || datatype < 0 ) return -1; + if( ITEM_CHECKITEMTABLE(ItemID) == FALSE )return -1; + return ITEM_tbl[ItemID].itm.data[datatype]; //new +#endif +} + +char *ITEMTBL_getChar( int ItemID, ITEM_DATACHAR datatype) +{ +#ifdef _IMPOROVE_ITEMTABLE + int itemsi=0; + if( !ITEM_CHECKITEMTABLE( ItemID) ) return NULL; + itemsi = ITEM_getSIndexFromTransList( ItemID); + if( datatype >= ITEM_DATACHARNUM || datatype < 0 ) return NULL; + return ITEM_tbl[itemsi].itm.string[datatype].string; //new +#else + if( datatype >= ITEM_DATACHARNUM || datatype < 0 ) return NULL; + if( ITEM_CHECKITEMTABLE(ItemID) == FALSE )return NULL; + return ITEM_tbl[ItemID].itm.string[datatype].string; //new +#endif +} + +INLINE BOOL ITEM_CHECKITEMTABLE( int number ) +{ +#ifdef _IMPOROVE_ITEMTABLE + int itemsi=0; + if( !ITEMTBL_CHECKINDEX( number) ) return FALSE; + itemsi = ITEM_getSIndexFromTransList( number); + if( itemsi < 0 || itemsi >= ITEM_tblen ) + return FALSE; + return ITEM_tbl[itemsi].use; //new +#else + if( number < 0 || number >= ITEM_tblen ){ + //andy_log + print("ITEM_CHECKITEMTABLE() number:%d ITEM_tblen:%d !!\n", number, ITEM_tblen ); + return FALSE; + } + return ITEM_tbl[number].use; //new +#endif +} + +int ITEM_getItemDamageCrusheED( int itemindex) +{ + int crushe = ITEM_getInt( itemindex, ITEM_DAMAGECRUSHE); + int maxcrushe = ITEM_getInt( itemindex, ITEM_MAXDAMAGECRUSHE); + if(maxcrushe < 1)return -1; + if( maxcrushe > 1000000) maxcrushe = 1000000; + if( crushe > 1000000) crushe = 1000000; + + return ((int) (crushe*100)/maxcrushe); +} + +void ITEM_RsetEquit( int charaindex) +{ + int i, itemindex, ti=-1; + for( i=0; i baseData + randData ) { + char szBuffer[1024]; + ITEM_setInt( itemindex, checkList[i], baseData); + sprintf( szBuffer, " 修正异常道具: id=%d a=%d now=%d base=%d rand=%d ", + item_ID, checkList[i], nowData, baseData, randData ); + print( szBuffer); + if( CHAR_CHECKINDEX(charaindex) ) { + LogOther( + CHAR_getChar( charaindex, CHAR_CDKEY), + CHAR_getChar( charaindex, CHAR_NAME), + szBuffer ); + } + + } + } +} +#endif diff --git a/gmsv/item/item_contract.c b/gmsv/item/item_contract.c new file mode 100644 index 0000000..70a4e04 --- /dev/null +++ b/gmsv/item/item_contract.c @@ -0,0 +1,251 @@ +#include "version.h" +#ifdef _CONTRACT +#include /* strstr */ +#include /* isdigit, isalnum */ +#include "common.h" +#include "char.h" +#include "char_base.h" +#include "char_data.h" +#include "configfile.h" +#include "item.h" +#include "item_event.h" +#include "object.h" +#include "anim_tbl.h" +#include "magic.h" +#include "handletime.h" +#include "log.h" +#include "util.h" +#include "encount.h" +#include "battle.h" +#include "battle_item.h" +#include "lssproto_serv.h" +#include "net.h" +#include "pet.h" +#include "npcutil.h" +#include "enemy.h" + +typedef struct{ + int used; + char name[32]; + char fmname[32]; +} contractSignTag; + +//ITEM_contractTable ITEM_contractTbl[MAX_CONTRACTTABLE]; +static ITEM_contractTable *ITEM_contractTbl; + +BOOL ITEM_initContractTable( ) +{ + // + FILE *fp; + char data[2048]; + int i; + + print("\读取 contract.txt ...."); + + ITEM_contractTbl = (ITEM_contractTable *)allocateMemory( sizeof(struct tagITEM_contract) * MAX_CONTRACTTABLE ); + + if( ITEM_contractTbl == NULL ){ + fprint( "无法分配内存 %d\n" , + sizeof(struct tagITEM_contract)*MAX_CONTRACTTABLE); + fclose( fp ); + return FALSE; + } + + memset( ITEM_contractTbl, 0 , sizeof(struct tagITEM_contract) * MAX_CONTRACTTABLE); + + fp = fopen("data/contract.txt", "r"); + if( fp == NULL ) { + print("\n无法读取 contract.txt!! "); + return FALSE; + } + + for( i =0; i >MAX_CONTRACTTABLE; i++) { + ITEM_contractTbl[i].used = FALSE; + } + + while(1) { + int ret; + int index; + char token[2048]; + ret = fgets( data, sizeof(data), fp); + if( ret == NULL || ret == EOF) + break; + + if( getStringFromIndexWithDelim( data, "|", 1, token, sizeof(token)) == TRUE) { + index = atoi( token); + if( index <0 || index >= MAX_CONTRACTTABLE) continue; + } + else { continue; } + + if( getStringFromIndexWithDelim( data, "|", 2, token, sizeof(token)) == TRUE) { + ITEM_contractTbl[index].argnum = atoi( token); + } + else { continue; } + + if( getStringFromIndexWithDelim( data, "|", 3, token, sizeof(token)) == TRUE) { + strcpy( ITEM_contractTbl[index].detail, token); + } + else { continue; } + + ITEM_contractTbl[i].used = TRUE; + + print("\n契约[%d] %d %s", index, ITEM_contractTbl[index].argnum, ITEM_contractTbl[index].detail); + } + + fclose( fp); + + return TRUE; + +} + +void ITEM_contract( int charaindex, int toindex, int haveitemindex) +{ + int itemindex; + int conindex; + char data[2048+1024]; + + if( !CHAR_CHECKINDEX( charaindex ) ) return; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX(itemindex) ) return; + + //conindex = atoi( ITEM_getChar( itemundex, ITEM_CONTRACTNUM)); + conindex = atoi( ITEM_getChar( itemindex, ITEM_ARGUMENT)); + + sprintf( data, "%s|%d|%s|%s", ITEM_contractTbl[conindex].detail, + ITEM_contractTbl[conindex].argnum, + ITEM_getChar( itemindex, ITEM_CONTRACTARG), + ITEM_getChar( itemindex, ITEM_CONTRACTTIME) ); + + print("\n contract_send:%s\n", data); + + lssproto_WN_send( getfdFromCharaIndex( charaindex), WINDOW_MESSAGETYPE_CONTRACT, + WINDOW_BUTTONTYPE_YESNO, + CHAR_WINDOWTYPE_CONTRACT_ANSWER, + itemindex, + data ); + +} + + +void ITEM_contractSign( int fd, int itemindex, int signindex) +{ + int charaindex; + int i; + int conIndex; + int complete =0; + int item_id; + char contractSignData[512]; + contractSignTag contractSign[4]; + + print("\n contractSign:%d:%d ", itemindex, signindex); + + charaindex = CONNECT_getCharaindex( fd ); + if( !CHAR_CHECKINDEX(charaindex)) return; + + if( signindex <0 || signindex >=4) return; + for( i=0 ; i= CHAR_MAXITEMHAVE ) return; + if( strcmp( ITEM_getChar( itemindex, ITEM_USEFUNC), "ITEM_contract") ) return; + + conIndex = atoi( ITEM_getChar( itemindex, ITEM_ARGUMENT)); + if( signindex >= ITEM_contractTbl[conIndex].argnum ) return; + + strcpy( contractSignData, ITEM_getChar( itemindex, ITEM_CONTRACTARG) ); + + for( i=0; i<4; i++) contractSign[i].used = FALSE; + + for( i=0; i<4; i++) { + int index; + char buf[512]; + char token[32]; + if( getStringFromIndexWithDelim( contractSignData, ",", i+1, buf, sizeof( buf )-1) == FALSE ) + break; + if( strlen( buf) == 0) break; + getStringFromIndexWithDelim( buf, ":", 1, token, sizeof( token )-1 ); + index = atoi( token); + if( index <0 || index >=4) break; + getStringFromIndexWithDelim( buf, ":", 2, contractSign[index].name, sizeof( contractSign[index].name )-1 ); + getStringFromIndexWithDelim( buf, ":", 3, contractSign[index].fmname, sizeof( contractSign[index].fmname )-1 ); + contractSign[index].used = TRUE; + } + + if( contractSign[signindex].used == TRUE) return; + + strcpy( contractSign[signindex].name, CHAR_getChar( charaindex, CHAR_NAME) ); + strcpy( contractSign[signindex].fmname, CHAR_getChar( charaindex, CHAR_FMNAME) ); + contractSign[signindex].used = TRUE; + + // 检查是否完成契约 + for( i =0; i<4; i++) { + if( contractSign[i].used == TRUE) + complete++; + } + if( complete >= ITEM_contractTbl[conIndex].argnum ) { + char buf[512]; + if( CHAR_findEmptyItemBoxNo( charaindex ) < ITEM_contractTbl[conIndex].argnum -1 ) { + sprintf( buf, "要完成这个契约,请先准备%d个空道具栏位。", ITEM_contractTbl[conIndex].argnum -1); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + return; + } + } + + + strcpy( contractSignData, ""); + for( i=0; i<4; i++) { + char buf[512]; + if( contractSign[i].used == FALSE) continue; + sprintf( buf, "%d:%s:%s,", i, contractSign[i].name, contractSign[i].fmname); + strcat( contractSignData, buf); + } + ITEM_setChar( itemindex, ITEM_CONTRACTARG, contractSignData); + + CHAR_talkToCli( charaindex, -1, "完成契约签名。", CHAR_COLORYELLOW); + + + // 完成契约 + if( complete >= ITEM_contractTbl[conIndex].argnum ) { + struct tm *nowtime; + char timebuf[512]; + + // 纪录日期 + nowtime = localtime( (time_t *)&NowTime.tv_sec ); + sprintf( timebuf, "%04d年%02d月%02d日", + nowtime->tm_year +1900, nowtime->tm_mon+1, nowtime->tm_mday); + ITEM_setChar( itemindex, ITEM_CONTRACTTIME, timebuf); + + CHAR_talkToCli( charaindex, -1, "完成所有签名,契约成立!", CHAR_COLORYELLOW); + // 复制契约 + item_id = ITEM_getInt( itemindex, ITEM_ID); + for( i =0 ; i < ITEM_contractTbl[conIndex].argnum -1 ; i++) + { + int emptyindex; + int newitemindex; + + emptyindex = CHAR_findEmptyItemBox( charaindex ); + + if( emptyindex < 0 ){ + CHAR_talkToCli( charaindex, -1, "空间栏位不足。", CHAR_COLORYELLOW); + break; + } + + newitemindex = ITEM_makeItemAndRegist( item_id ); + + if( newitemindex != -1 ){ + CHAR_setItemIndex( charaindex, emptyindex, newitemindex ); + ITEM_setWorkInt( newitemindex, ITEM_WORKOBJINDEX, -1); + ITEM_setWorkInt( newitemindex, ITEM_WORKCHARAINDEX, charaindex); + CHAR_sendItemDataOne( charaindex, emptyindex); + ITEM_setChar( newitemindex, ITEM_CONTRACTARG, contractSignData); + ITEM_setChar( newitemindex, ITEM_CONTRACTTIME, timebuf); + } + + CHAR_talkToCli( charaindex, -1, "复制契约书。", CHAR_COLORYELLOW); + } + } +} + +#endif diff --git a/gmsv/item/item_event.c b/gmsv/item/item_event.c new file mode 100644 index 0000000..b57221b --- /dev/null +++ b/gmsv/item/item_event.c @@ -0,0 +1,4612 @@ +#include "version.h" +#include /* strstr */ +#include /* isdigit, isalnum */ +#include "common.h" +#include "char.h" +#include "char_base.h" +#include "char_data.h" +#include "configfile.h" +#include "item.h" +#include "item_event.h" +#include "object.h" +#include "anim_tbl.h" +#include "magic.h" +#include "handletime.h" +#include "log.h" +#include "util.h" +#include "encount.h" +#include "battle.h" +#include "battle_item.h" +#include "lssproto_serv.h" +#include "net.h" +#include "pet.h" +#include "npcutil.h" +#include "enemy.h" +#ifdef _Item_ReLifeAct +#include "battle_magic.h" +#endif +#ifdef _MARKET_TRADE +#include "item_trade.h" +#endif +#ifdef _ITEM_WARP_FIX_BI +extern tagRidePetTable ridePetTable[296]; +#endif +#include "pet_skill.h" + +#ifdef _DEATH_CONTENDAB +#include "deathcontend.h" +#endif + +#ifdef _CFREE_petskill +#include "npc_freepetskillshop.h" +#endif + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 +#include "profession_skill.h" +#endif + +int ITEM_TimeDelCheck( int itemindex ) +{ int icnt, jcnt, playernum; + playernum = CHAR_getPlayerMaxNum(); + for( icnt = 0; icnt < playernum; icnt ++ ) { + if( CHAR_CHECKINDEX( icnt ) ) { + for( jcnt = 0; jcnt < CHAR_MAXITEMHAVE; jcnt ++ ) { + if( CHAR_getItemIndex( icnt, jcnt ) == itemindex ) { + print( "道具效力时间已到,进行奇怪道具处理(%s)(%s)\n", + CHAR_getUseName(icnt),ITEM_getAppropriateName(itemindex) ); + return FALSE; + } + } + } + } + return TRUE; +} + +int ITEM_eventDrop( int itemindex, int charaindex, int itemcharaindex ) +{ + typedef void (*DROPF)(int,int); + char szBuffer[256]=""; + DROPF dropfunc=NULL; + + if( ITEM_CHECKINDEX(itemindex) == FALSE )return -1; + + dropfunc=(DROPF)ITEM_getFunctionPointer( itemindex, ITEM_DROPFUNC ); + if( dropfunc ){ + dropfunc( charaindex, itemindex ); + } + + if( ITEM_getInt( itemindex, ITEM_VANISHATDROP) != 1 )return 0; + snprintf( szBuffer, sizeof( szBuffer), "%s 消灭了。", + ITEM_getAppropriateName(itemindex) ); + CHAR_talkToCli( charaindex, -1, szBuffer, CHAR_COLORWHITE ); + + { + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), /* 失奶 丞 寞 */ +#endif + "Drop&Delete(丢出後消失)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + CHAR_setItemIndex( charaindex, itemcharaindex, -1); + ITEM_endExistItemsOne( itemindex ); + return 1; +} + +#undef UNDEF +#define UNDEF (-1) + +typedef struct { + char* cmd; /* 摹 侬 */ + char* onmessage; /* 丢永本□斥 侬 */ + char* offmessage; /* 丢永本□斥 侬 */ + int element; /* 覆擂卞卅月邰豳 */ + int maxElement; /* element匹隙烂今木凶邰豳及 袄毛手勾邰豳 */ +} ITEM_EFFECTPARAM; +static ITEM_EFFECTPARAM ITEM_restorableParam[] = { + {"hp", "HP回复了。", "HP降低了。",CHAR_HP, CHAR_WORKMAXHP}, + {"mp", "MP回复了。", "MP降低了。",CHAR_MP, CHAR_WORKMAXMP}, +}; +static ITEM_EFFECTPARAM ITEM_statusParam[] = { + {"po", CHAR_POISONSTRING, CHAR_RECOVERPOISONSTRING, + CHAR_POISON, UNDEF}, + + {"pa", CHAR_PARALYSISSTRING, CHAR_RECOVERPARALYSISSTRING, + CHAR_PARALYSIS, UNDEF}, + + {"si", CHAR_SILENCESTRING, CHAR_RECOVERSILENCESTRING, + CHAR_SLEEP,UNDEF}, + + {"st", CHAR_STONESTRING, CHAR_RECOVERSTONESTRING, CHAR_STONE, UNDEF}, + + {"da", CHAR_DARKNESSSTRING, CHAR_RECOVERDARKNESSSTRING, + CHAR_DRUNK,UNDEF}, + + {"co", CHAR_CONFUSIONSTRING,CHAR_RECOVERCONFUSIONSTRING, + CHAR_CONFUSION, UNDEF}, +}; + +/*#define LOCAL_DEBUG*/ +#ifdef LOCAL_DEBUG +#define DOUTFILE "doutfile" +#include +#include +static int eprintf(char* format, ...){ + va_list arg; + long len; + FILE* fp; + fp = fopen(DOUTFILE, "a"); + va_start(arg, format); + len = vfprintf(stderr, format, arg); + if(fp){ vfprintf(fp, format, arg); fclose(fp); } + va_end(arg); + return len; +} + +#define fprint eprintf +#endif + +static BOOL ITEM_isValidEffect(char* cmd, int value){ + int i; + + for(i=0; istring[ITEM_ARGUMENT].string; + if(* effectarg == '\0') return TRUE; + for(p=effectarg; *p != '\0'; ){ + int i; + if(*p == SEPARATORI) p++; + for(q=cmd, i=0; isalnum(*p) && i 0 ) + onoroff=ITEM_restorableParam[i].onmessage; + else if( amount < 0 ) + onoroff=ITEM_restorableParam[i].offmessage; + else + return FALSE; + strcpysafe( ansmsg, sizeof(ansmsg), onoroff ); + CHAR_talkToCli( charaindex, -1, ansmsg, CHAR_COLORWHITE); + return TRUE; +#else + if(value == ITEM_EFFECT_RESTORE_NORMAL){ + int maxv, curv, amount; + maxv =CHAR_getWorkInt(charaindex, ITEM_restorableParam[i].maxElement); + curv =CHAR_getInt(charaindex, ITEM_restorableParam[i].element); + amount = 30; + if(curv + amount < 0) amount = -curv; + CHAR_setInt(charaindex, ITEM_restorableParam[i].element, min((curv+amount), maxv)); + snprintf( ansmsg, sizeof(ansmsg), "%s回复了。", + ITEM_restorableParam[i].onmessage ); + CHAR_talkToCli( charaindex, -1, ansmsg, CHAR_COLORWHITE); + return TRUE; + }else if(value == ITEM_EFFECT_RESTORE_COMPLETE){ + int maxv; + maxv =CHAR_getWorkInt(charaindex, ITEM_restorableParam[i].maxElement); + CHAR_setInt(charaindex, ITEM_restorableParam[i].element, maxv); + snprintf( ansmsg, sizeof(ansmsg), "%s已完全回复。", ITEM_restorableParam[i].onmessage ); + CHAR_talkToCli( charaindex, -1, ansmsg, CHAR_COLORWHITE ); + return TRUE; + }else + return FALSE; +#endif + + } + } + if( value >= 0 ){ + int found = 0; + for(i=0; i (int)( itemputtime + getItemdeletetime() ) ) { + if( ITEM_TimeDelCheck( itemindex ) == FALSE ){ + return ; + } + { + LogItem( + "NULL", + "NULL", +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), +#endif + "TiemDelete", + OBJECT_getFloor( objindex ), + OBJECT_getX( objindex ), + OBJECT_getY( objindex ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + ITEM_endExistItemsOne(itemindex); + CHAR_ObjectDelete(objindex); + } +} + +void ITEM_useEffectTohelos( int charaindex, int to_charaindex, int haveitemindex) +{ + char buf[64]; + char msgbuf[64]; + int ret; + int itemindex; + int cutrate, limitcount; + int per; + int sendcharaindex = charaindex; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + CHAR_setItemIndex(charaindex, haveitemindex ,-1); + CHAR_sendItemDataOne( charaindex, haveitemindex); + ret = getStringFromIndexWithDelim( ITEM_getChar(itemindex, ITEM_ARGUMENT) , + "|", 1, buf, sizeof( buf)); + if( ret != TRUE ) { + { + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), +#endif + "FieldErrorUse", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + ITEM_endExistItemsOne( itemindex); + return; + } + cutrate = atoi( buf); + if( cutrate < 0 ) cutrate = 0; + ret = getStringFromIndexWithDelim( ITEM_getChar(itemindex, ITEM_ARGUMENT) , + "|", 2, buf, sizeof( buf)); + if( ret != TRUE ) { + { + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), +#endif + "FieldUse", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + ITEM_endExistItemsOne( itemindex); + return; + } + limitcount = atoi( buf); + if( limitcount < 0) limitcount = 0; + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_CLIENT) { + sendcharaindex = CHAR_getWorkInt( charaindex, CHAR_WORKPARTYINDEX1); + } + CHAR_setWorkInt( sendcharaindex, CHAR_WORK_TOHELOS_CUTRATE, cutrate); + CHAR_setWorkInt( sendcharaindex, CHAR_WORK_TOHELOS_COUNT, limitcount); + + snprintf( msgbuf, sizeof(msgbuf), + "抓到了%s 。", ITEM_getChar(itemindex, ITEM_NAME) ); + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORWHITE ); + + if( sendcharaindex != charaindex ) { + snprintf( msgbuf, sizeof(msgbuf), + "%s 抓到了 %s。 ", + CHAR_getChar( charaindex, CHAR_NAME), + ITEM_getChar( itemindex, ITEM_NAME) ); + CHAR_talkToCli( sendcharaindex, -1, msgbuf, CHAR_COLORWHITE ); + } + + { + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), +#endif + "FieldUse", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + ITEM_endExistItemsOne( itemindex); + per = ENCOUNT_getEncountPercentMin( sendcharaindex, + CHAR_getInt( sendcharaindex, CHAR_FLOOR), + CHAR_getInt( sendcharaindex, CHAR_X), + CHAR_getInt( sendcharaindex, CHAR_Y)); + if( per != -1) { + CHAR_setWorkInt( sendcharaindex, CHAR_WORKENCOUNTPROBABILITY_MIN, per); + } + per = ENCOUNT_getEncountPercentMax( sendcharaindex, + CHAR_getInt( sendcharaindex, CHAR_FLOOR), + CHAR_getInt( sendcharaindex, CHAR_X), + CHAR_getInt( sendcharaindex, CHAR_Y)); + if( per != -1) { + CHAR_setWorkInt( sendcharaindex, CHAR_WORKENCOUNTPROBABILITY_MAX, per); + } + CHAR_sendStatusString( sendcharaindex, "E" ); +} + +void ITEM_dropMic( int charaindex , int itemindex ) +{ + if( !ITEM_CHECKINDEX( itemindex )) return; + + CHAR_setWorkInt( charaindex, CHAR_WORKFLG, + CHAR_getWorkInt( charaindex, CHAR_WORKFLG ) & ~WORKFLG_MICMODE ); +} + +void ITEM_useMic_Field( int charaindex, int to_charaindex, int haveitemindex ) +{ + if( CHAR_getWorkInt( charaindex, CHAR_WORKFLG ) & WORKFLG_MICMODE ){ + CHAR_setWorkInt( charaindex, CHAR_WORKFLG, + CHAR_getWorkInt( charaindex, CHAR_WORKFLG ) & ~WORKFLG_MICMODE ); + CHAR_talkToCli( charaindex, -1, "将麦克风设定为OFF。", CHAR_COLORWHITE); + }else{ + CHAR_setWorkInt( charaindex, CHAR_WORKFLG, + CHAR_getWorkInt( charaindex, CHAR_WORKFLG ) | WORKFLG_MICMODE ); + CHAR_talkToCli( charaindex, -1, "将麦克风设定为ON。", CHAR_COLORWHITE); + } +} +#if 1 +char *aszHealStringByOwn[] = { + "%s的耐久力回复%d", + "%s的气力回复%d", + "%s的魅力上升%d", + "%s的忠诚度上升%d", + "" +}; + +char *aszDownStringByOwn[] = { + "%s的耐久力减低%d", + "%s的气力减低%d", + "%s的魅力下降%d", + "%s的忠诚度下降%d", + "" +}; + +char *aszHealStringByOther[] = { + "藉由%s%s的耐久力回复%d", + "藉由%s%s的气力回复%d", + "藉由%s%s的魅力上升%d", + "藉由%s%s的忠诚度上升%d", + "" +}; + +char *aszDownStringByOther[] = { + "藉由%s%s的耐久力减低%d", + "藉由%s%s的气力减低%d", + "藉由%s%s的魅力减低%d", + "藉由%s%s的忠诚度减低%d", + "" +}; + +char *aszKeyString[] = {"体", "气", "魅", "忠", ""}; +int aHealInt[] = { CHAR_HP, CHAR_MP, CHAR_CHARM, CHAR_VARIABLEAI, -1 }; +int aHealMaxWork[] = { CHAR_WORKMAXHP, CHAR_WORKMAXMP, -1, -1, -1 }; + +void ITEM_useRecovery_Field( + int charaindex, + int toindex, + int haveitemindex +){ + int work, workmax, workmin; + int power[BD_KIND_END] = {0,0,0}, + prevhp = 0, + workhp = 0, + recovery[BD_KIND_END] = {0,0,0}; + int itemindex, kind = BD_KIND_HP, HealFlg = 0, j; + char *p = NULL, *arg, msgbuf[256]; + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX(itemindex) ) return; + if( CHAR_CHECKINDEX( toindex ) == FALSE )return ; + arg = ITEM_getChar(itemindex, ITEM_ARGUMENT ); + if( arg == NULL ) return; + +#ifdef _ITEM_UNBECOMEPIG + if( (p = strstr( arg, "解猪" )) != NULL ){ + if( CHAR_getInt( toindex, CHAR_BECOMEPIG ) > -1 ){ + CHAR_setInt( toindex, CHAR_BECOMEPIG, -1 ); + CHAR_complianceParameter( toindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( toindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( toindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + CHAR_talkToCli( toindex,-1,"乌力化失效了。",CHAR_COLORWHITE); + CHAR_DelItemMess( charaindex, haveitemindex, 0); + } + return; + } +#endif +#ifdef _ITEM_LVUPUP + if( (p = strstr( arg, "LVUPUP" ) ) != NULL ){ + if (CHAR_getInt(toindex, CHAR_WHICHTYPE)==CHAR_TYPEPET){ + int pidx=0,lvup=0,lv=0; + sprintf( msgbuf, "%s", p+7 ); + pidx = atoi( strtok( msgbuf, " " ) ); + if( pidx != CHAR_getInt( toindex, CHAR_PETID) || CHAR_getInt(toindex, CHAR_LIMITLEVEL) == 0 ){ + CHAR_talkToCli( charaindex,-1,"无法使用",CHAR_COLORWHITE); + return; + } + lv = CHAR_getInt( toindex, CHAR_LV ); + if( lv < 10 || lv >= 140 ){ + CHAR_talkToCli( charaindex,-1,"目前等级无法使用",CHAR_COLORWHITE); + return; + } + if( (p = strstr( arg, "地" )) != NULL ) + lvup=2; + if( (p = strstr( arg, "水" )) != NULL ) + lvup=3; + if( (p = strstr( arg, "火" )) != NULL ) + lvup=0; + if( (p = strstr( arg, "风" )) != NULL ) + lvup=1; + if( lv%4 != lvup || CHAR_getInt(toindex, CHAR_LIMITLEVEL)-lv >= 1 ){// + CHAR_talkToCli( charaindex,-1,"破除封印失败",CHAR_COLORWHITE); + CHAR_DelItemMess( charaindex, haveitemindex, 0); + return; + } + CHAR_setInt(toindex, CHAR_LIMITLEVEL, CHAR_getInt(toindex, CHAR_LIMITLEVEL)+1); + CHAR_talkToCli( charaindex,-1,"封印魔咒减弱,最高等级提升",CHAR_COLORWHITE); + if( CHAR_getInt(toindex, CHAR_LIMITLEVEL) == 140 ){ + CHAR_setInt(toindex, CHAR_LIMITLEVEL, 0); + CHAR_talkToCli( charaindex,-1,"封印魔咒解除了",CHAR_COLORWHITE); + } + CHAR_DelItemMess( charaindex, haveitemindex, 0); + CHAR_complianceParameter( toindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( toindex , CHAR_WORKOBJINDEX )); + } + return; + } + if( (p = strstr( arg, "UPUPLV" ) ) != NULL ){ + if (CHAR_getInt(toindex, CHAR_WHICHTYPE)==CHAR_TYPEPET){ + int pidx=0,lvup=0,lv=0; + sprintf( msgbuf, "%s", p+7 ); + pidx = atoi( strtok( msgbuf, " " ) ); + if( pidx != CHAR_getInt( toindex, CHAR_PETID) || CHAR_getInt(toindex, CHAR_LIMITLEVEL) == 0 ){ + CHAR_talkToCli( charaindex,-1,"无法使用",CHAR_COLORWHITE); + return; + } + lv = CHAR_getInt( toindex, CHAR_LV ); + if( lv < 125 || lv > 140 ){ + CHAR_talkToCli( charaindex,-1,"目前等级无法使用",CHAR_COLORWHITE); + return; + } + CHAR_setInt(toindex, CHAR_LIMITLEVEL, 0); + CHAR_talkToCli( charaindex,-1,"封印魔咒解除了",CHAR_COLORWHITE); + CHAR_DelItemMess( charaindex, haveitemindex, 0); + CHAR_complianceParameter( toindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( toindex , CHAR_WORKOBJINDEX )); + } + return; + } +#endif +#ifdef _ITEM_PROPERTY + if( (p = strstr( arg, "PROPERTY" ) ) != NULL ){ + //print("地水火风:%s", arg ); + if (CHAR_getInt(toindex, CHAR_WHICHTYPE)!=CHAR_TYPEPLAYER) + return; + if( (p = strstr( arg, "+" ) ) != NULL ){//旋转属性 正转 + if( CHAR_getInt( toindex, CHAR_EARTHAT ) == 100 ) + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )-10 ), + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_WATERAT ) == 100 ) + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )-10 ), + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_FIREAT ) == 100 ) + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )-10 ), + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_WINDAT ) == 100 ) + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )-10 ), + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_EARTHAT ) > 0 && CHAR_getInt( toindex, CHAR_WATERAT ) > 0 ) + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )-10 ), + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_WATERAT ) > 0 && CHAR_getInt( toindex, CHAR_FIREAT ) > 0 ) + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )-10 ), + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_FIREAT ) > 0 && CHAR_getInt( toindex, CHAR_WINDAT ) > 0 ) + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )-10 ), + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_WINDAT ) > 0 && CHAR_getInt( toindex, CHAR_EARTHAT ) > 0 ) + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )-10 ), + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )+10 ); + } + if( (p = strstr( arg, "-" ) ) != NULL ){//旋转属性 反转 + if( CHAR_getInt( toindex, CHAR_EARTHAT ) == 100 ) + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )-10 ), + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_WATERAT ) == 100 ) + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )-10 ), + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_FIREAT ) == 100 ) + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )-10 ), + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_WINDAT ) == 100 ) + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )-10 ), + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_EARTHAT ) > 0 && CHAR_getInt( toindex, CHAR_WATERAT ) > 0 ) + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )+10 ), + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )-10 ); + else if( CHAR_getInt( toindex, CHAR_WATERAT ) > 0 && CHAR_getInt( toindex, CHAR_FIREAT ) > 0 ) + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )+10 ), + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )-10 ); + else if( CHAR_getInt( toindex, CHAR_FIREAT ) > 0 && CHAR_getInt( toindex, CHAR_WINDAT ) > 0 ) + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )+10 ), + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )-10 ); + else if( CHAR_getInt( toindex, CHAR_WINDAT ) > 0 && CHAR_getInt( toindex, CHAR_EARTHAT ) > 0 ) + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )+10 ), + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )-10 ); + } + CHAR_DelItemMess( charaindex, haveitemindex, 0); + CHAR_complianceParameter( toindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( toindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( toindex , + CHAR_P_STRING_EARTH | + CHAR_P_STRING_WATER | + CHAR_P_STRING_FIRE | + CHAR_P_STRING_WIND + ); + return; + } +#endif +#ifdef _ITEM_ADDPETEXP + if( (p = strstr( arg, "GETEXP" )) != NULL ){ + if (CHAR_getInt(toindex, CHAR_WHICHTYPE)==CHAR_TYPEPET){ + getStringFromIndexWithDelim( arg, "|", 2, msgbuf,sizeof( msgbuf));//宠物编号 + if( atoi(msgbuf) == CHAR_getInt( toindex, CHAR_PETID) ){ + getStringFromIndexWithDelim( arg, "|", 3, msgbuf,sizeof( msgbuf));//等级上限(等级超过才可用) + if( CHAR_getInt( toindex, CHAR_LV ) >= atoi(msgbuf) ){ + getStringFromIndexWithDelim( arg, "|", 4, msgbuf,sizeof( msgbuf));//经验值增加 + if( CHAR_getInt( toindex, CHAR_LV) < CHAR_MAXUPLEVEL ){ + int UpLevel = 0; + CHAR_setWorkInt( toindex, CHAR_WORKGETEXP, atoi(msgbuf) );//回存CHAR_WORKGETEXP + CHAR_AddMaxExp( toindex, CHAR_getWorkInt( toindex, CHAR_WORKGETEXP ) ); + sprintf( msgbuf,"这石头里面不知道有什麽样的矿,让我看看。(增加经验%d)", CHAR_getWorkInt( toindex, CHAR_WORKGETEXP ) ); + CHAR_talkToCli( charaindex,-1,msgbuf,CHAR_COLORWHITE); + UpLevel = CHAR_LevelUpCheck( toindex , charaindex); + if( UpLevel > 0 ){ + if( getBattleDebugMsg( ) != 0 ){ + snprintf( msgbuf, sizeof(msgbuf), + "(%s) 升级至 %d", + CHAR_getUseName( toindex ), + CHAR_getInt( toindex, CHAR_LV ) ); + BATTLE_talkToCli( charaindex, msgbuf, CHAR_COLORYELLOW ); + } + } + for( j = 0; j < UpLevel; j ++ ){ + CHAR_PetLevelUp( toindex ); + CHAR_PetAddVariableAi( toindex, AI_FIX_PETLEVELUP ); + } + CHAR_complianceParameter( toindex ); + } + else{ + CHAR_talkToCli( charaindex,-1,"不能使用",CHAR_COLORWHITE); + } + /*CHAR_send_P_StatusString( charindex, CHAR_P_STRING_DUELPOINT| + CHAR_P_STRING_TRANSMIGRATION| CHAR_P_STRING_RIDEPET| + CHAR_P_STRING_BASEBASEIMAGENUMBER| CHAR_P_STRING_GOLD| + CHAR_P_STRING_EXP| CHAR_P_STRING_LV| CHAR_P_STRING_HP|CHAR_P_STRING_LEARNRIDE); + */ + } + else + CHAR_talkToCli( charaindex,-1,"这石头....(无法判别,无法增加经验)",CHAR_COLORWHITE); + } + CHAR_DelItemMess( charaindex, haveitemindex, 0); + CHAR_complianceParameter( toindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( toindex , CHAR_WORKOBJINDEX )); + return; + } + else{ + CHAR_talkToCli( charaindex,-1,"不能使用",CHAR_COLORWHITE); + } + } +#endif + for( j = 0; j < BD_KIND_END; j ++ ){ + power[j] = 0; + recovery[j] = 0; + } + if( (p = strstr( arg, "全" )) != NULL ){ + HealFlg = ( 1 << BD_KIND_HP ); + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPET ){ + }else{ + HealFlg |= ( 1 << BD_KIND_MP ); + } + power[BD_KIND_HP] = 10000000; + power[BD_KIND_MP] = 100; + } + kind = BD_KIND_HP; + if( (p = strstr( arg, aszKeyString[kind] )) != NULL ){ + HealFlg |= ( 1 << kind ); + if( sscanf( p+2, "%d", &work ) != 1 ){ + power[kind] = 1; + }else{ + power[kind] = RAND( (work*0.9), (work*1.1) ); + } +#ifndef _MAGIC_REHPAI + power[kind] *= GetRecoveryRate( toindex ); +#endif + } + kind = BD_KIND_MP; + if( (p = strstr( arg, aszKeyString[kind] )) != NULL + && CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER){ + HealFlg |= ( 1 << kind ); + if( sscanf( p+2, "%d", &work ) != 1 ){ + power[kind] = 1; + }else{ + power[kind] = RAND( (work*0.9), (work*1.1) ); + } + } + kind = BD_KIND_AI; + if( (p = strstr( arg, aszKeyString[kind] )) != NULL + && CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPET){ + HealFlg |= ( 1 << kind ); + if( sscanf( p+2, "%d", &work ) != 1 ){ + power[kind] = 1; + }else{ + power[kind] = RAND( (work*0.9), (work*1.1) ); + } + power[kind] *= 100; + } + kind = BD_KIND_CHARM; + if( (p = strstr( arg, aszKeyString[kind] )) != NULL + && CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ){ + HealFlg |= ( 1 << kind ); + if( sscanf( p+2, "%d", &work ) != 1 ){ + power[kind] = 1; + }else{ + power[kind] = RAND( (work*0.9), (work*1.1) ); + } + } + if( HealFlg == 0 )return; +#ifdef _TYPE_TOXICATION + if( CHAR_CanCureFlg( toindex, "HP") == FALSE )return; +#endif + + for( j = 0; j < BD_KIND_END; j ++ ){ + if( ( HealFlg & ( 1 << j ) ) == 0 )continue; + prevhp = CHAR_getInt( toindex, aHealInt[j] ); + workhp = prevhp + (int)power[j]; + + if( j == BD_KIND_CHARM ){ + workmax = 100; + workmin = 0; + }else + if( j == BD_KIND_AI ){ + workmax = 10000; + workmin = -10000; + }else{ + workmax = CHAR_getWorkInt( toindex, aHealMaxWork[j] ); + workmin = 1; + } + workhp = min( workhp, workmax ); + workhp = max( workhp, workmin ); + CHAR_setInt( toindex, aHealInt[j], workhp ); + recovery[j] = workhp - prevhp; + if( j == BD_KIND_AI ){ + recovery[j] *= 0.01; + } + } + CHAR_complianceParameter( toindex ); + + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + if( charaindex != toindex ) { + CHAR_send_P_StatusString( toindex, CHAR_P_STRING_HP|CHAR_P_STRING_MP|CHAR_P_STRING_CHARM); + } + } + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_HP|CHAR_P_STRING_MP|CHAR_P_STRING_CHARM); + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER && + CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE ){ + CHAR_PartyUpdate( toindex, CHAR_N_STRING_HP|CHAR_N_STRING_MP ); + } + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPET ){ + int i; + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + int workindex = CHAR_getCharPet( charaindex, i ); + if( workindex == toindex ){ + CHAR_send_K_StatusString( charaindex, i, CHAR_K_STRING_HP|CHAR_K_STRING_AI); + } + } + } + + + for( j = 0; j < BD_KIND_END; j ++ ){ + if( ( HealFlg & ( 1 << j ) ) == 0 )continue; + if( charaindex != toindex) { + if( power[j] >= 0 ){ + snprintf( msgbuf, sizeof( msgbuf), + aszHealStringByOwn[j], + CHAR_getUseName( toindex ), recovery[j] ); + }else{ + snprintf( msgbuf, sizeof( msgbuf), + aszDownStringByOwn[j], + CHAR_getUseName( toindex ), -recovery[j] ); + } + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORWHITE); + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + if( power[j] >= 0 ){ + snprintf( msgbuf, sizeof( msgbuf), + aszHealStringByOther[j], + CHAR_getUseName( charaindex ), + CHAR_getUseName( toindex ), recovery[j] ); + }else{ + snprintf( msgbuf, sizeof( msgbuf), + aszDownStringByOther[j], + CHAR_getUseName( charaindex ), + CHAR_getUseName( toindex ), -recovery[j] ); + } + CHAR_talkToCli( toindex, -1, msgbuf, CHAR_COLORWHITE); + } + }else { + if( power[j] >= 0 ){ + snprintf( msgbuf, sizeof( msgbuf), + aszHealStringByOwn[j], + CHAR_getUseName( charaindex ), recovery[j] ); + }else{ + snprintf( msgbuf, sizeof( msgbuf), + aszDownStringByOwn[j], + CHAR_getUseName( charaindex ), -recovery[j] ); + } + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORWHITE); + } + } + { + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), +#endif + "FieldUse", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + CHAR_DelItemMess( charaindex, haveitemindex, 0); + +} + +#endif + +void ITEM_useRecovery( int charaindex, int toindex, int haveitemindex) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return ; + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + }else + if( battlemode ){ + ITEM_useRecovery_Battle( charaindex, toindex, haveitemindex ); + }else{ + ITEM_useRecovery_Field( charaindex, toindex, haveitemindex ); + } + +} + +#ifdef _ITEM_MAGICRECOVERY +void ITEM_useMRecovery( int charaindex, int toindex, int haveitemindex) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return ; + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + }else + if( battlemode ){ + ITEM_useMRecovery_Battle( charaindex, toindex, haveitemindex ); + }else{ +// ITEM_useRecovery_Field( charaindex, toindex, haveitemindex ); + } + +} + +#endif + +#ifdef _ITEM_USEMAGIC +void ITEM_useMagic( int charaindex, int toindex, int haveitemindex) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return ; + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + }else + if( battlemode ){ + ITEM_useMagic_Battle( charaindex, toindex, haveitemindex ); + } +} +#endif + +#ifdef _PET_LIMITLEVEL +void ITEM_useOtherEditBase( int charaindex, int toindex, int haveitemindex) +{ + int itemindex,i; + int work[4]; + int num=-1,type; + int LevelUpPoint,petrank; + char buf1[256]; + char buf2[][32]={"腕力成长率","耐久力成长率","速度成长率","体力成长率","能力"}; + char buf3[][32]={"大幅提高","略为提高","略为减少"}; + if( !CHAR_CHECKINDEX( charaindex ) ) return; + if( !CHAR_CHECKINDEX( toindex ) ) return; +#define RAND(x,y) ((x-1)+1+ (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) ) + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX(itemindex) ) return; + if( CHAR_getInt( toindex, CHAR_PETID) == 718 +#ifdef _PET_2LIMITLEVEL + || CHAR_getInt( toindex, CHAR_PETID) == 401 +#endif + ) { + + int maxnums=50; + + if( CHAR_getInt( toindex,CHAR_LV ) < 74 ) { + sprintf(buf1,"给我的吗?好美丽的项 喔!〈能力起了变化〉"); + CHAR_talkToCli( charaindex, toindex, buf1, CHAR_COLORWHITE); + num = ITEM_MODIFYATTACK; + LevelUpPoint = CHAR_getInt( toindex, CHAR_ALLOCPOINT ); + petrank = CHAR_getInt( toindex, CHAR_PETRANK ); + work[3] =(( LevelUpPoint >> 24 ) & 0xFF); + work[0] = (( LevelUpPoint >> 16 ) & 0xFF); + work[1] = (( LevelUpPoint >> 8 ) & 0xFF); + work[2] = (( LevelUpPoint >> 0 ) & 0xFF); + for( i=0; i<4; i++) { + type = ITEM_getInt( itemindex, (num + i)); + work[i] += type; + strcpy( buf1,"\0"); + if( work[i] > maxnums ) { + sprintf(buf1,"%s 已经达到最高了。", buf2[i]); + work[i] = maxnums; + }else if( work[i] < 0 ) { + sprintf(buf1,"%s 已经为零了。", buf2[i]); + work[i] = 0; + }else { + if( type > 0 ) { + if( type > 2 ) + sprintf(buf1,"%s %s %s", buf2[i], buf3[0], "。"); + else + sprintf(buf1,"%s %s %s", buf2[i], buf3[1], "。"); + }else if( type < 0 ){ + sprintf(buf1,"%s %s %s", buf2[i], buf3[2], "。"); + } + } + if( strcmp( buf1, "\0")) { + CHAR_talkToCli( charaindex, toindex, buf1, CHAR_COLORWHITE); + } + } + + LevelUpPoint = ( work[3]<< 24) + ( work[0]<< 16) + ( work[1]<< 8) + ( work[2]<< 0); + CHAR_setInt( toindex, CHAR_ALLOCPOINT, LevelUpPoint); + CHAR_setInt( toindex, CHAR_PETRANK, petrank); + LogPetPointChange( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), + CHAR_getChar( charaindex, CHAR_NAME), + toindex, 4, + CHAR_getInt( toindex, CHAR_LV), + "item_use", + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X ), + CHAR_getInt( charaindex, CHAR_Y ) + ); + } + + }else { + sprintf(buf1,"???"); + } + CHAR_DelItem( charaindex, haveitemindex); + return; +} +#endif + +void ITEM_useStatusChange( int charaindex, int toindex, int haveitemindex) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return ; //{撩 + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + }else + if( battlemode ){ + ITEM_useStatusChange_Battle( charaindex, toindex, haveitemindex ); + }else{ + } + +} + +void ITEM_useStatusRecovery( int charaindex, int toindex, int haveitemindex) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return ; //{撩 + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + }else + if( battlemode ){ + ITEM_useStatusRecovery_Battle( charaindex, toindex, haveitemindex ); + }else{ + } +} + +void ITEM_useMagicDef( int charaindex, int toindex, int haveitemindex) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return; + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + }else + if( battlemode ){ + ITEM_useMagicDef_Battle( charaindex, toindex, haveitemindex ); + }else{ + } + +} + +void ITEM_useParamChange( int charaindex, int toindex, int haveitemindex) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return ; + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + }else + if( battlemode ){ + ITEM_useParamChange_Battle( charaindex, toindex, haveitemindex ); + } +} + +void ITEM_useFieldChange( int charaindex, int toindex, int haveitemindex) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return ; + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + }else + if( battlemode ){ + ITEM_useFieldChange_Battle( charaindex, toindex, haveitemindex ); + } +} + +void ITEM_useAttReverse( int charaindex, int toindex, int haveitemindex) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return; + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + }else + if( battlemode ){ + ITEM_useAttReverse_Battle( charaindex, toindex, haveitemindex ); + }else{ + } +} + +void ITEM_useMic( int charaindex, int toindex, int haveitemindex) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return; + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + }else + if( battlemode ){ + }else{ + ITEM_useMic_Field( charaindex, toindex, haveitemindex ); + } + +} + +void ITEM_useCaptureUp( int charaindex, int toindex, int haveitemindex) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return ; //{撩 + + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + }else + if( battlemode ){ + ITEM_useCaptureUp_Battle( charaindex, toindex, haveitemindex ); + }else{ + } + +} + +#ifdef _PETSKILL_CANNEDFOOD +static void ITEM_usePetSkillCanned_PrintWindow( int charaindex, int flg) +{ + int fd; + char message[256], buf[2048]; + if( !CHAR_CHECKINDEX( charaindex )) return; + fd = getfdFromCharaIndex( charaindex); + if( fd == - 1 ) return; + + memset( message, 0, sizeof(message)); + sprintf( message, "%d", flg); + lssproto_WN_send( fd, WINDOWS_MESSAGETYPE_PETSKILLSHOW, + WINDOW_BUTTONTYPE_NONE, + ITEM_WINDOWTYPE_SELECTPETSKILL_SELECT, + -1, + makeEscapeString( message, buf, sizeof( buf))); +} + +void ITEM_usePetSkillCanned_WindowResult( int charaindex, int seqno, int select, char * data) +{ + int itemindex=-1, itemNo, petindex=-1, petNo; + int SkillNo, SkillID; + char buf1[256]; + char *skillarg=NULL; + + petNo = CHAR_getWorkInt( charaindex, CHAR_WORKRENAMEITEMNUM); + itemNo = CHAR_getWorkInt( charaindex, CHAR_WORKRENAMEITEMINDEX); + + + itemindex = CHAR_getItemIndex( charaindex, itemNo); + if( !ITEM_CHECKINDEX( itemindex) ) return; + petindex = CHAR_getCharPet( charaindex, petNo); + if( !CHAR_CHECKINDEX(petindex) ) return; + SkillNo = atoi( data); + if( SkillNo < 0 || SkillNo >= CHAR_MAXPETSKILLHAVE ) return; + + skillarg = ITEM_getChar( itemindex, ITEM_ARGUMENT); + SkillID = atoi( skillarg); + +#ifdef _CFREE_petskill + if( NPC_CHECKFREEPETSKILL( charaindex, petindex, SkillID) == FALSE ){ + CHAR_talkToCli( charaindex, -1, "该宠物无法学习此项技能!", CHAR_COLORYELLOW); + return; + } +#endif + + CHAR_setPetSkill( petindex, SkillNo, SkillID); + memset( buf1, 0, sizeof(buf1)); + snprintf( buf1, sizeof( buf1 ), "W%d", petNo); + CHAR_sendStatusString( charaindex, buf1 ); + CHAR_sendStatusString( charaindex, "P"); + { + int skillarray = PETSKILL_getPetskillArray( SkillID); + sprintf( buf1, "宠物%s学习%s,道具 %s消失了。", + CHAR_getUseName( petindex), PETSKILL_getChar( skillarray, PETSKILL_NAME), + ITEM_getChar( itemindex, ITEM_NAME) ); + } + + CHAR_talkToCli( charaindex, -1, buf1, CHAR_COLORYELLOW); + CHAR_setItemIndex( charaindex, itemNo ,-1); + CHAR_sendItemDataOne( charaindex, itemNo); + ITEM_endExistItemsOne( itemindex); +} + +#endif + +static void ITEM_useRenameItem_PrintWindow( int charaindex, int page) +{ + int fd; + int pos = 0; + int i; + int btntype = WINDOW_BUTTONTYPE_CANCEL; + char message[1024]; + char msgwk[1024]; + char buf[2048]; + + if( !CHAR_CHECKINDEX( charaindex )) return; + if( page < 0 || page > 3 ) { + print( "%s:%d err\n", __FILE__, __LINE__); + return; + } + fd = getfdFromCharaIndex( charaindex); + if( fd == - 1 ) return; + + snprintf( message, sizeof( message), + "2\n 要变更那个项目的名称呢\n" + " Page:%d\n", page +1); + + for( i = page *5; i < page *5 +5; i ++ ) { + int itemindex = CHAR_getItemIndex( charaindex, i); + BOOL flg = FALSE; + while( 1 ) { + char *cdkey; + if( !ITEM_CHECKINDEX( itemindex)) break; + cdkey = ITEM_getChar( itemindex, ITEM_CDKEY); + if( !cdkey) { + print( "%s:%d err\n", __FILE__, __LINE__); + break; + } + if( ITEM_getInt( itemindex, ITEM_MERGEFLG) != 1) break; + if( ITEM_getInt( itemindex, ITEM_TYPE) == ITEM_DISH) break; + if( ITEM_getInt( itemindex, ITEM_CRUSHLEVEL) != 0 ) break; + if( strlen( cdkey) != 0 ) { + if( strcmp( cdkey, CHAR_getChar( charaindex, CHAR_CDKEY)) != 0 ) { + break; + } + } + flg = TRUE; + break; + } + if( flg ) { + char *nm = ITEM_getChar( itemindex, ITEM_SECRETNAME); + char wk[256]; + if( pos +strlen( nm) +1 > sizeof( msgwk)) { + print( "buffer over error %s:%d\n", __FILE__, __LINE__); + break; + } + snprintf( wk, sizeof( wk), "%s\n", nm); + strncpy( &msgwk[pos], wk, sizeof( msgwk) -pos -1); + pos += strlen( wk); + } + else { + if( pos +2 > sizeof( msgwk)) { + print( "buffer over error %s:%d\n", __FILE__, __LINE__); + break; + } + strncpy( &msgwk[pos], "\n", sizeof( msgwk) -pos -1 ); + pos += 1; + } + } + strcat( message, msgwk); + switch( page){ + case 0: + btntype |= WINDOW_BUTTONTYPE_NEXT; + break; + case 3: + btntype |= WINDOW_BUTTONTYPE_PREV; + break; + case 1: + case 2: + btntype |= WINDOW_BUTTONTYPE_PREV|WINDOW_BUTTONTYPE_NEXT; + break; + } + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + btntype, + CHAR_WINDOWTYPE_SELECTRENAMEITEM_PAGE1+page, + -1, + makeEscapeString( message, buf, sizeof(buf))); +} + +void ITEM_useRenameItem( int charaindex, int toindex, int haveitemindex) +{ + + ITEM_useRenameItem_PrintWindow( charaindex, 0); + + CHAR_setWorkInt( charaindex, CHAR_WORKRENAMEITEMNUM, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKRENAMEITEMINDEX, haveitemindex); +/* + char buf[256]; + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX( itemindex) ) return; + sprintf( buf, "%s功能已被取消。", ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, "功能已被取消。", CHAR_COLORRED ); + + { + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), + itemindex, + "魔术笔DEL", + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X ), + CHAR_getInt( charaindex, CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + + CHAR_setItemIndex( charaindex, haveitemindex, -1); + CHAR_sendItemDataOne( charaindex, haveitemindex); + ITEM_endExistItemsOne( itemindex ); +*/ +} + +void ITEM_useRenameItem_WindowResult( int charaindex, int seqno, int select, char * data) +{ + int page = 0; + int fd; + if( select == WINDOW_BUTTONTYPE_CANCEL) return; + + fd = getfdFromCharaIndex( charaindex); + if( fd == - 1 ) return; + if( seqno != CHAR_WINDOWTYPE_SELECTRENAMEITEM_RENAME ) { + if( select == WINDOW_BUTTONTYPE_NEXT ) page = 1; + else if( select == WINDOW_BUTTONTYPE_PREV ) page = -1; + if( select == WINDOW_BUTTONTYPE_NEXT || select == WINDOW_BUTTONTYPE_PREV ) { + int winno = seqno - CHAR_WINDOWTYPE_SELECTRENAMEITEM_PAGE1; + winno += page; + if( winno < 0 ) winno = 0; + if( winno > 3 ) winno = 3; + ITEM_useRenameItem_PrintWindow( charaindex, winno); + }else { + char message[1024]; + char buf[2048]; + char haveitemindex = CHAR_getWorkInt( charaindex, CHAR_WORKRENAMEITEMNUM); + int itemindex; + if( haveitemindex == -1 ) { + haveitemindex = (seqno - CHAR_WINDOWTYPE_SELECTRENAMEITEM_PAGE1) * 5 + + ( atoi(data)-1); + CHAR_setWorkInt( charaindex, CHAR_WORKRENAMEITEMNUM, haveitemindex); + } + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + + snprintf( message, sizeof( message), + "%s 名字要更改\n" + "请输入姓名\n" + "全形13个字, 半形26个字", + ITEM_getChar( itemindex, ITEM_NAME)); + + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT, + WINDOW_BUTTONTYPE_OKCANCEL, + CHAR_WINDOWTYPE_SELECTRENAMEITEM_RENAME, + -1, + makeEscapeString( message, buf, sizeof(buf))); + + } + } + else { + BOOL flg = FALSE; + char message[1024]; + char buf[2048]; + while( 1 ) { + char *p; + if( strlen( data) > 26 || strlen( data) < 1) { + if( strlen( data) > 26 ) { + strcpy( message, "超过文字限制"); + }else { + strcpy( message, "请输入一个文字以上"); + } + break; + } + + // WON ADD 修正魔术笔改名问题 + flg = TRUE; + + for( p = data; *p ; p ++) { + if( *p == ' '){ + strcpy( message, "不可空白"); + flg = FALSE; + break; + } + if( strncmp( p, " ",2) == 0 ) { + strcpy( message, "不可空白"); + flg = FALSE; + break; + } + if( *p == '|'){ + strcpy( message, "不可有特殊符号"); + flg = FALSE; + break; + } + } + + break; + } + + + if( !flg ) { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_SELECTRENAMEITEM_RENAME_ATTENTION, + -1, + makeEscapeString( message, buf, sizeof(buf))); + } + else { + char haveitemindex = CHAR_getWorkInt( charaindex, CHAR_WORKRENAMEITEMNUM); + int itemindex; + int renameitemindex; + int renameitemhaveindex; + int remain; + char msgbuf[128]; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX( itemindex)) { + print( "%s %d err\n", __FILE__, __LINE__); + return; + } + ITEM_setChar( itemindex, ITEM_SECRETNAME, data); + ITEM_setChar( itemindex, ITEM_CDKEY, + CHAR_getChar( charaindex, CHAR_CDKEY)); + CHAR_sendItemDataOne( charaindex, haveitemindex); + snprintf( msgbuf, sizeof(msgbuf),"把 %s 命名成 %s ", + ITEM_getChar( itemindex, ITEM_NAME), data); + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORYELLOW); + renameitemhaveindex = CHAR_getWorkInt( charaindex, CHAR_WORKRENAMEITEMINDEX); + renameitemindex = CHAR_getItemIndex( charaindex, renameitemhaveindex); + if( !ITEM_CHECKINDEX( renameitemindex)) { + print( "%s %d err\n", __FILE__, __LINE__); + return; + } + remain = atoi( ITEM_getChar( renameitemindex, ITEM_ARGUMENT)); + if( remain != 0 ) { + remain --; + if( remain <= 0 ) { + snprintf( msgbuf, sizeof(msgbuf),"%s 消失了", + ITEM_getChar( renameitemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORYELLOW); + CHAR_setItemIndex( charaindex, renameitemhaveindex, -1); + CHAR_sendItemDataOne( charaindex, renameitemhaveindex); + ITEM_endExistItemsOne( renameitemindex ); + }else { + char buf[32]; + snprintf( buf, sizeof( buf),"%d", remain); + ITEM_setChar( renameitemindex, ITEM_ARGUMENT, buf); + } + } + } + } +} + +//------------------------------------------------------------------------- +// 今中仇欠毛 蜇允月楮醒[ +// 午仄凶凛卞]仿件母丞卞ㄠ ㄥ毛蓟太] 蟆午 飓 寞毛 凳允月[ +//------------------------------------------------------------------------- +void ITEM_dropDice( int charaindex, int itemindex) +{ + char *dicename[] = { "一", "二", "叁", "四", "五", "六"}; + int diceimagenumber[] = { 24298,24299,24300,24301,24302,24303}; + int r = RAND( 0,5); + + // 飓 寞毛谨 + ITEM_setInt( itemindex, ITEM_VAR1, ITEM_getInt( itemindex, ITEM_BASEIMAGENUMBER)); + // 飓 寞凳蕙 + ITEM_setInt( itemindex, ITEM_BASEIMAGENUMBER, diceimagenumber[r]); + // 蟆凳蕙 + ITEM_setChar( itemindex, ITEM_SECRETNAME, dicename[r]); + + // 犯□正及弁仿奶失件玄尺及霜耨反晓匏楮醒匹垫丹及匹]仇仇匹反支日卅中[ +} +//------------------------------------------------------------------------- +// 今中仇欠毛 蜇允月楮醒[ +// 胶匀凶凛卞] 蟆午 飓 寞毛葭卞 允[ +//------------------------------------------------------------------------- +void ITEM_pickupDice( int charaindex, int itemindex) +{ + // 飓 寞毛葭卞 允[ + ITEM_setInt( itemindex, ITEM_BASEIMAGENUMBER, ITEM_getInt( itemindex, ITEM_VAR1)); + // 蟆手葭卞 允 + ITEM_setChar( itemindex, ITEM_SECRETNAME, ITEM_getChar( itemindex, ITEM_NAME)); +} +enum { + ITEM_LOTTERY_1ST, // 1羁 + ITEM_LOTTERY_2ND, + ITEM_LOTTERY_3RD, + ITEM_LOTTERY_4TH, + ITEM_LOTTERY_5TH, // 5羁 + ITEM_LOTTERY_6TH, // 6羁 + ITEM_LOTTERY_NONE, // 陆木 + ITEM_LOTTERY_NUM, +}; +//------------------------------------------------------------------------- +// 旦疋□玉仁元互综日木月凛及楮醒[ +// 仇仇匹窒羁操卞卅月井毛瑁户月[ +// 割 反动票及骚曰[ + +#define PRE_6 (10000) +#define PRE_5 (1300 + PRE_6) +#define PRE_4 (600 + PRE_5) +#define PRE_3 (300 + PRE_4) +#define PRE_2 (8 + PRE_3) +#define PRE_1 (1 + PRE_2) + + +//#define PRE_5 (13000) +//#define PRE_4 (2300 + PRE_5) +//#define PRE_3 (540 + PRE_4) +//#define PRE_2 (8 + PRE_3) +//#define PRE_1 (1 + PRE_2) + + +//#define PRE_5 (16000) +//#define PRE_4 (2500 + PRE_5) +//#define PRE_3 (400 + PRE_4) +//#define PRE_2 (10 + PRE_3) +//#define PRE_1 (1 + PRE_2) +//#define PRE_5 (27000) +//#define PRE_4 (4000 + PRE_5) +//#define PRE_3 (400 + PRE_4) +//#define PRE_2 (10 + PRE_3) +//#define PRE_1 (1 + PRE_2) +// +//------------------------------------------------------------------------- +BOOL ITEM_initLottery(ITEM_Item* itm) +{ + int r = RAND( 0, 49999); + int hit = ITEM_LOTTERY_NONE; // + char result[7]; // 请 + int countnum[6]; + int count; + int i; + int len; + // 域荚综匀化月及匹[疯粟 仄凶凛午井卞综曰卅云今木卅中方丹卞[ + if( itm->data[ITEM_VAR3] == 1 ) return TRUE; + + // 铲蓟允月[ + if( r < PRE_6 ) hit = ITEM_LOTTERY_6TH; + else if( r < PRE_5 ) hit = ITEM_LOTTERY_5TH; + else if( r < PRE_4 ) hit = ITEM_LOTTERY_4TH; + else if( r < PRE_3 ) hit = ITEM_LOTTERY_3RD; + else if( r < PRE_2 ) hit = ITEM_LOTTERY_2ND; + else if( r < PRE_1 ) hit = ITEM_LOTTERY_1ST; + else hit = ITEM_LOTTERY_NONE; + + // 请 毛瑁烂允月[ + count = 0; + memset( countnum, 0, sizeof( countnum)); + if( hit != ITEM_LOTTERY_NONE ) { + // 癫曰毛本永玄 + result[0] = result[1] = result[2] = hit+1; + count = 3; + countnum[hit] = 3; + } + while( count < 6 ) { + int r = RAND( ITEM_LOTTERY_1ST, ITEM_LOTTERY_6TH); + if( countnum[r] >= 2 ) continue; + // 2/3仁日中及割 匹]职及陆木钓 毛伉□民今六化支月[ + // 升五升五[ + if( ( hit != ITEM_LOTTERY_NONE && count == 3 ) + || ( hit == ITEM_LOTTERY_NONE && count == 0 ) ) + { + if( RAND( 0,2)) { + result[count] = result[count+1] = r+1; + countnum[r] += 2; + count += 2; + continue; + } + } + countnum[r] ++; + result[count] = r+1; + count++; + } + // 请 毛扑乓永白伙允月[ + // 癫曰及凛反2/3及割 匹]癫曰醒侬毛域 欠卞裔烂允月[ + // 玉平玉平躲绊毛谎丹啃[ + len = sizeof( result)-2; + if( hit != ITEM_LOTTERY_NONE ) { + if( RAND( 0,2) ) { + // 癫曰醒侬毛域 欠卞[ + char s = result[0]; + result[0] = result[5]; + result[5] = s; + len = sizeof( result)-3; + } + } + for( i = 0; i < 10; i ++) { + int x = RAND( 0, len); + int y = RAND( 0, len); + int s; + s = result[x]; + result[x] = result[y]; + result[y] = s; + } + // 及凶户] 侬 健中卞仄化云仁[ + result[sizeof(result)-1] = '\0'; + itm->data[ITEM_VAR1] = hit; + // 户仁匀凶市它件玄 + itm->data[ITEM_VAR2] = 0; + itm->data[ITEM_VAR3] = 1; + memcpy( itm->string[ITEM_ARGUMENT].string, result, sizeof( result)); + + return TRUE; +} +//------------------------------------------------------------------------- +// 旦疋□玉仁元毛银匀凶凛及楮醒[ +// ㄥ荚银丹午]窒羁操井及失奶 丞卞 祭允月[ +//------------------------------------------------------------------------- +void ITEM_useLottery( int charaindex, int toindex, int haveitemindex) +{ + int i,j; + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + int count = ITEM_getInt( itemindex, ITEM_VAR2); + int hit = ITEM_getInt( itemindex, ITEM_VAR1); + char buff[1024]; + char num[6][3] = { {"迭"},{"迫"},{"迤"},{"迨"},{"郊"}, {"郎"}}; + char numbuff[128]; + char *n; + int result; + BOOL flg; + if( !ITEM_CHECKINDEX( itemindex) ) return; + if( count == 0 ) { + ITEM_setChar( itemindex, ITEM_EFFECTSTRING, ""); + } + // ㄥ荚 及银迕反]陆木仄井丐曰 卅中及匹]仇仇匹失奶 丞毛壅允 + else if( count == 6 ) { + CHAR_setItemIndex( charaindex , haveitemindex, -1 ); + CHAR_sendItemDataOne( charaindex, haveitemindex); + ITEM_endExistItemsOne( itemindex ); + return; + } + n = ITEM_getChar( itemindex, ITEM_ARGUMENT); + // for debug +#if 0 + snprintf( buff, sizeof( buff), "羁操“%d 请 : %d%d%d%d%d%d", + hit, + (int)(n[0]+1),(int)(n[1]+1), + (int)(n[2]+1),(int)(n[3]+1), + (int)(n[4]+1),(int)(n[5]+1) + ); + CHAR_talkToCli( charaindex, -1, + buff, CHAR_COLORYELLOW ); +#endif + result = (int)n[count]-1; + // 伉□民井譬屯月 + flg = FALSE; + for( i = 0; i < count+1 && flg == FALSE; i ++ ) { + for( j = i+1; j < count+1 && flg == FALSE; j ++ ) { + if( i != j ) { + if( n[i] == n[j] ) { + flg = TRUE; + } + } + } + } + memset( numbuff, 0, sizeof( numbuff)); + memcpy( numbuff, ITEM_getChar( itemindex, ITEM_EFFECTSTRING), (count)*2); + // 躲绊 侬 卞]请 毛请允[ + snprintf( buff, sizeof( buff), "%s%s", numbuff, num[result]); + count ++; + ITEM_setInt( itemindex, ITEM_VAR2, count); + // ㄥ荚 匹癫曰卅日癫曰失奶 丞卞 凳]陆木卅日陆木午 憎] + // 戚荚母皮伙弁伉永弁匹壅允[ + if( count >= 6 ) { + // 癫曰 + if( hit != ITEM_LOTTERY_NONE ) { + int newitemindex; + char strbuff[1024]; + char msgbuff[1024]; + // 壅仄化 + CHAR_setItemIndex( charaindex , haveitemindex, -1 ); + ITEM_endExistItemsOne( itemindex ); + // 2729 - 2734 反 仁元及1 6羁 + newitemindex = ITEM_makeItemAndRegist( 2729 + hit); + CHAR_setItemIndex( charaindex , haveitemindex, newitemindex ); + // 请 手戊疋□ + snprintf( strbuff, sizeof( strbuff), "%s %s", buff, + ITEM_getChar( newitemindex, ITEM_EFFECTSTRING)); + ITEM_setChar( newitemindex, ITEM_EFFECTSTRING, strbuff); + CHAR_sendItemDataOne( charaindex, haveitemindex); + snprintf( msgbuff, sizeof( msgbuff), "中了第%d奖", hit+1 ); + CHAR_talkToCli( charaindex, -1, + msgbuff, + CHAR_COLORYELLOW ); + } + // 陆木 + else { +// CHAR_setItemIndex( charaindex , haveitemindex, -1 ); + // 请 手戊疋□ + char strbuff[1024]; + snprintf( strbuff, sizeof( strbuff), "%s 没中,下次再来", buff); + ITEM_setChar( itemindex, ITEM_EFFECTSTRING, strbuff); + CHAR_sendItemDataOne( charaindex, haveitemindex); +// ITEM_endExistItemsOne( itemindex ); +// CHAR_talkToCli( charaindex, -1, +// "反内木″", +// CHAR_COLORWHITE ); + } + } + // 公丹元扎 中凛反]犯□正毛霜曰卅云允分仃[ + else { + char strbuff[1024]; + if( flg) { + // 旦矢□旦煌遥 + // 失奶 丞及 及戊丢件玄反]ㄠ垫ㄡㄧ 侬匹] + // 旦矢□旦毛银匀化荼垫仄化中月[ + int spc = 16 + ( 6-count)*2; + char space[17]; + memset( space, ' ', spc); + space[spc] = '\0'; + snprintf( strbuff, sizeof( strbuff), "%s%s快中了", buff, space); + } + else { + strcpy( strbuff, buff); + } + ITEM_setChar( itemindex, ITEM_EFFECTSTRING, strbuff); + CHAR_sendItemDataOne( charaindex, haveitemindex); + } +} + +void ITEM_WarpDelErrorItem( int charaindex ) +{ + int j; + for(j=0; j= 12 ){ + CHAR_talkToCli(charaindex, -1, "此处无法使用。", CHAR_COLORYELLOW); + return; + } + + memset( buf, 0, sizeof( buf)); + sprintf( buf, "%d %d %d %d", flg, Mf, Mx, My); + ITEM_setChar(itemindex, ITEM_ARGUMENT, buf); + ITEM_setInt( itemindex, ITEM_DAMAGEBREAK, usenum); + sprintf( buf, "飞行纪录点(%s,%d,%d)", MapString[i], Mx, My); + ITEM_setChar( itemindex, ITEM_EFFECTSTRING, buf); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORYELLOW); + CHAR_sendItemDataOne( charaindex, haveitemindex); + } + + // WON ADD + if( ITEM_WarpForAny(charaindex, haveitemindex, ff, fx, fy, flg) == FALSE ) + return; +} +#endif + +// Robin 0707 petFollow +void ITEM_petFollow( int charaindex, int toindex, int haveitemindex ) +{ + char *arg; + int itemindex, followLv, haveindex, i; + //print(" PetFollow_toindex:%d ", toindex); + if( CHAR_getWorkInt( charaindex, CHAR_WORKPETFOLLOW ) != -1 ){ + if( CHAR_CHECKINDEX( CHAR_getWorkInt( charaindex, CHAR_WORKPETFOLLOW ) ) ){ + CHAR_talkToCli( charaindex, -1, "请先收回放出的宠物!", CHAR_COLORWHITE ); + return; + } + CHAR_setWorkInt( charaindex, CHAR_WORKPETFOLLOW, -1); + } +#ifdef _FIX_METAMORIDE + if( CHAR_CHECKJOINENEMY( charaindex) == TRUE ){ + CHAR_talkToCli( charaindex, -1, "搭乘中无法使用!", CHAR_COLORWHITE ); + return; + } +#endif + + if( CHAR_CHECKINDEX( toindex ) == FALSE ) return; + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + arg = ITEM_getChar(itemindex, ITEM_ARGUMENT ); + if( arg == NULL )return; + + if( sscanf( arg, "%d", &followLv) != 1 ) + return; + if( CHAR_getInt( toindex, CHAR_LV ) > followLv ){ + CHAR_talkToCli( charaindex, -1, "道具的等级不足!", CHAR_COLORWHITE ); + return; + } + if( CHAR_getWorkInt( toindex, CHAR_WORKFIXAI ) < 80 ) + { + //CHAR_talkToCli( charaindex, -1, "宠物的忠诚度不足!", CHAR_COLORWHITE ); + //return; + } + + + haveindex = -1; + for( i = 0; i < 5; i++ ) + { + if( CHAR_getCharPet( charaindex, i) == toindex ) { + haveindex = i; + break; + } + } + if( haveindex == -1) return; + + + if( !PET_dropPetFollow( charaindex, haveindex, -1, -1, -1 ) ) { + CHAR_talkToCli( charaindex, -1, "宠物跟随失败!", CHAR_COLORWHITE ); + return; + } + +} + +// Nuke start 0624: Hero's bless +void ITEM_useSkup( int charaindex, int toindex, int haveitemindex) +{ + int itemindex; + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + CHAR_setInt(charaindex,CHAR_SKILLUPPOINT, + CHAR_getInt(charaindex,CHAR_SKILLUPPOINT)+1); + CHAR_Skillupsend(charaindex); + CHAR_talkToCli(charaindex, -1, "你感受到自己的能力被提升了。", CHAR_COLORWHITE); + + CHAR_DelItem( charaindex, haveitemindex); +} +// Nuke end +extern void setNoenemy(); +// Nuke start 0626: Dragon's bless +void ITEM_useNoenemy( int charaindex, int toindex, int haveitemindex) +{ + int itemindex,fd; + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + fd=CHAR_getWorkInt( charaindex, CHAR_WORKFD); + setNoenemy(fd); + CHAR_talkToCli(charaindex, -1, "你感受到周边的杀气消失了。", CHAR_COLORWHITE); + CHAR_DelItem( charaindex, haveitemindex); + +} +// Nuke end + +// Arminius 7.2: Ra's amulet +void ITEM_equipNoenemy( int charaindex, int itemindex ) +{ + char buf[4096]; + int evadelevel; + int fl,fd; + + if( ITEM_CHECKINDEX(itemindex) == FALSE )return; + + if( ITEM_getArgument( ITEM_getChar(itemindex,ITEM_ARGUMENT),"noen", buf, sizeof(buf) ) + == FALSE ){ + return; + } + + evadelevel=atoi(buf); + fl=CHAR_getInt(charaindex, CHAR_FLOOR); + fd=CHAR_getWorkInt( charaindex, CHAR_WORKFD); + if (evadelevel>=200) { + setEqNoenemy(fd, 200); + CHAR_talkToCli(charaindex, -1, "一道奇异的光芒隐藏了你的行踪。", CHAR_COLORWHITE); + return; + } else if (evadelevel>=120) { + setEqNoenemy(fd, 120); + + if ( (fl==100)||(fl==200)||(fl==300)||(fl==400)||(fl==500) ){ + CHAR_talkToCli(charaindex, -1, "一道奇异的光芒隐藏了你的行踪。", CHAR_COLORWHITE); + return; + } + } else if (evadelevel>=80) { + setEqNoenemy(fd, 80); + if ( (fl==100)||(fl==200)||(fl==300)||(fl==400) ){ + + CHAR_talkToCli(charaindex, -1, "一道奇异的光芒隐藏了你的行踪。", CHAR_COLORWHITE); + return; + } + } else if (evadelevel>=40) { + setEqNoenemy(fd, 40); + if ( (fl==100)||(fl==200) ) { + CHAR_talkToCli(charaindex, -1, "一道奇异的光芒隐藏了你的行踪。", CHAR_COLORWHITE); + return; + } + } + CHAR_talkToCli(charaindex, -1, "什麽事也没有发生。", CHAR_COLORWHITE); +} + +#ifdef _Item_MoonAct +void ITEM_randEnemyEquipOne( int charaindex, int toindex, int haveitemindex) +{ + int itemindex, RandNum=0; + char buf[256]; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX( itemindex)) return; + + if( ITEM_getArgument( ITEM_getChar( itemindex,ITEM_ARGUMENT), "rand", buf, sizeof(buf) ) == FALSE ){ + return; + } + + if( (RandNum=atoi( buf)) > 0 ){ + int fd = CHAR_getWorkInt( charaindex, CHAR_WORKFD); + setEqRandenemy(fd, RandNum); + CHAR_talkToCli(charaindex, -1, "遇敌率降低了。", CHAR_COLORWHITE); + sprintf( buf, "道具 %s消失了。", ITEM_getChar( itemindex, ITEM_NAME) ); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); + return; + } + + +} + +void ITEM_randEnemyEquip( int charaindex, int itemindex) +{ + char buf[4096]; + int RandNum=0; + int fd; + + if( ITEM_CHECKINDEX(itemindex) == FALSE )return; + if( ITEM_getArgument( ITEM_getChar(itemindex,ITEM_ARGUMENT),"rand", buf, sizeof(buf) ) + == FALSE ){ + return; + } + + RandNum=atoi( buf); + fd=CHAR_getWorkInt( charaindex, CHAR_WORKFD); + if (RandNum > 0 ) { + setEqRandenemy(fd, RandNum); + CHAR_talkToCli(charaindex, -1, "遇敌率降低了。", CHAR_COLORWHITE); + return; + } + +} +void ITEM_RerandEnemyEquip( int charaindex, int itemindex) +{ + int RandNum=0; + int fd; + + if( ITEM_CHECKINDEX(itemindex) == FALSE )return; + + fd=CHAR_getWorkInt( charaindex, CHAR_WORKFD); + RandNum = getEqRandenemy( fd); + + if (RandNum > 0 ) { + clearEqRandenemy( fd); + CHAR_talkToCli(charaindex, -1, "遇敌率回复。", CHAR_COLORWHITE); + return; + } +} +#endif + +#ifdef _ITEM_WATERWORDSTATUS +void ITEM_WaterWordStatus( int charaindex, int toindex, int haveitemindex) +{ + int itemindex; + char itemarg[256]; + + if( !CHAR_CHECKINDEX( charaindex) ){ + return; + } + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX( itemindex) ){ + return; + } + + if( ITEM_getArgument( ITEM_getChar( itemindex, ITEM_ARGUMENT),"time", itemarg, sizeof(itemarg) ) != FALSE ){ + char token[256]; + int nums = CHAR_getWorkInt( charaindex, CHAR_WORKSTATUSWATER); + if( nums < 0 ) nums = 0; + if( nums > 0 ){ + CHAR_talkToCli( charaindex, -1, "水中呼吸时间不得累积。", CHAR_COLORYELLOW); + return; + } + CHAR_setWorkInt( charaindex, CHAR_WORKSTATUSWATER, nums+atoi(itemarg)); + CHAR_setItemIndex(charaindex, haveitemindex ,-1); + CHAR_sendItemDataOne( charaindex, haveitemindex); + ITEM_endExistItemsOne(itemindex); + + sprintf( token, "水中呼吸时间增加%d分,总计%d分。", atoi(itemarg), + CHAR_getWorkInt( charaindex, CHAR_WORKSTATUSWATER)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + }else{ + CHAR_talkToCli(charaindex, -1, "什麽事也没发生。", CHAR_COLORYELLOW); + } +} +#endif + +#ifdef _CHIKULA_STONE +void ITEM_ChikulaStone( int charaindex, int toindex, int haveitemindex) +{ + int itemindex,fd; + char itemarg[256]; + + if( !CHAR_CHECKINDEX( charaindex) ) return; + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX( itemindex) ) return; + + fd = CHAR_getWorkInt( charaindex, CHAR_WORKFD); + CHAR_setWorkInt( charaindex, CHAR_WORKCHIKULAHP, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORKCHIKULAMP, 0 ); + setChiStone( fd, 0); //1hp 2mp + + if( ITEM_getArgument( ITEM_getChar( itemindex, ITEM_ARGUMENT),"hp", itemarg, sizeof(itemarg) ) != FALSE ){ + setChiStone( fd, 1); + CHAR_setWorkInt( charaindex, CHAR_WORKCHIKULAHP, atoi( itemarg) ); + }else if( ITEM_getArgument( ITEM_getChar( itemindex, ITEM_ARGUMENT),"mp", itemarg, sizeof(itemarg) ) != FALSE ){ + setChiStone( fd, 2); + CHAR_setWorkInt( charaindex, CHAR_WORKCHIKULAMP, atoi( itemarg) ); + }else{ + } + + CHAR_talkToCli(charaindex, -1, "接受奇克拉的祝福。", CHAR_COLORWHITE); + CHAR_setItemIndex(charaindex, haveitemindex ,-1); + CHAR_sendItemDataOne( charaindex, haveitemindex); + ITEM_endExistItemsOne(itemindex); +} +#endif + +#ifdef _ITEM_ORNAMENTS +void ITEM_PutOrnaments( int charaindex, int itemindex) +{ + char *arg=NULL; + char itemname[256]; + int bbnums=0; + if( !CHAR_CHECKINDEX( charaindex) ) return; + if( !ITEM_CHECKINDEX( itemindex) ) return; + arg = ITEM_getChar( itemindex, ITEM_ARGUMENT); + if( arg == NULL ) return;//ITEM_BASEIMAGENUMBER + bbnums = atoi( arg); + ITEM_setInt( itemindex, ITEM_BASEIMAGENUMBER, bbnums); + ITEM_setWorkInt( itemindex, ITEM_CANPICKUP, 1); + + sprintf( itemname,"%s%s%s",CHAR_getChar( charaindex, CHAR_NAME), "的", ITEM_getChar( itemindex, ITEM_SECRETNAME)); + ITEM_setChar( itemindex, ITEM_SECRETNAME, itemname); +} +#endif + +#ifdef _SUIT_ITEM + +/* +#ifdef _SUIT_TWFWENDUM + #define MAX_SUITTYPE 18 +#else + #ifdef _SUIT_ADDENDUM + #define MAX_SUITTYPE 14 + #else + #ifdef _MAGIC_RESIST_EQUIT // WON ADD 职业抗性装备 + #define MAX_SUITTYPE 11 + #else + #define MAX_SUITTYPE 8 + #endif//_MAGIC_RESIST_EQUIT + #endif//_SUIT_ADDENDUM +#endif//_SUIT_TWFWENDUM +*/ +void ITEM_CheckSuitEquip( int charaindex) +{ + int i, j, itemindex, defCode=-1, same=0; + int nItem[CHAR_STARTITEMARRAY]; + int maxitem; + struct tagIntSuit{ + char fun[256]; + int intfun; //CHAR_getInt + }; + struct tagIntSuit ListSuit[]={ + {"VIT",CHAR_WORKSUITVIT}, + {"FSTR",CHAR_WORKSUITMODSTR}, + {"MSTR",CHAR_WORKSUITSTR}, + {"MTGH",CHAR_WORKSUITTGH}, + {"MDEX",CHAR_WORKSUITDEX}, + {"WAST",CHAR_WORKSTATUSWATER}, + {"HP", CHAR_WORKROUNDHP}, + {"MP", CHAR_WORKROUNDMP} +#ifdef _MAGIC_RESIST_EQUIT // WON ADD 职业抗性装备 + ,{"FRES", CHAR_WORK_F_SUIT}, + {"IRES", CHAR_WORK_I_SUIT}, + {"TRES", CHAR_WORK_T_SUIT} +#endif +#ifdef _SUIT_ADDENDUM + ,{"RESIST",CHAR_WORKRESIST}, //异常抗性率 + {"COUNTER",CHAR_WORKCOUNTER}, //反击率 + {"M_POW",CHAR_WORKMPOWER} //加强法师的魔法 +#endif +#ifdef _SUIT_TWFWENDUM + ,{"EARTH",CHAR_WORK_EA}, //地 + {"WRITER",CHAR_WORK_WR}, //水 + {"FIRE",CHAR_WORK_FI}, //火 + {"WIND",CHAR_WORK_WI} //风 +#endif +#ifdef _SUIT_ADDPART3 + ,{"WDUCKPOWER",CHAR_WORKDUCKPOWER},//套装回避 + {"RENOCASE",CHAR_WORKRENOCAST}, //沉默抗性率 + {"SUITSTRP",CHAR_WORKSUITSTR_P},//攻提升 单位为% + {"SUITTGH_P",CHAR_WORKSUITTGH_P},//防提升 单位为% + {"SUITDEXP",CHAR_WORKSUITDEX_P}//敏提升 单位为% +#endif +#ifdef _SUIT_ADDPART4 + ,{"SUITPOISON",CHAR_SUITPOISON},//带毒装备 + {"M2_POW",CHAR_WORKMPOWER2}, //加强法师的魔法,与M_POW功能相同(机率30%) + {"UN_POW_M",CHAR_WORKUNMPOWER} //抵抗法师的魔法 +#endif + }; + maxitem = sizeof(ListSuit)/sizeof(ListSuit[0]); + CHAR_setWorkInt( charaindex, CHAR_WORKSUITITEM, 0); + for( i=0; i=0; k-- ){ + if( nItem[i] == nItem[k] ) same++; + } + if( same >= 3 && nItem[i] != 0 )defCode = nItem[i]; + } + if( defCode == -1 ) return; + CHAR_setWorkInt( charaindex, CHAR_WORKSUITITEM, defCode); + for( i=0; i=200) { + CHAR_talkToCli(charaindex, -1, "环绕着你的光芒消失了。", CHAR_COLORWHITE); + return; + } else if (el>=120) { + if ( (fl==100)||(fl==200)||(fl==300)||(fl==400)||(fl==500) ) { + CHAR_talkToCli(charaindex, -1, "环绕着你的光芒消失了。", CHAR_COLORWHITE); + return; + } + } else if (el>=80) { + if ( (fl==100)||(fl==200)||(fl==300)||(fl==400) ) { + CHAR_talkToCli(charaindex, -1, "环绕着你的光芒消失了。", CHAR_COLORWHITE); + return; + } + } else if (el>=40) { + if ( (fl==100)||(fl==200) ) { + CHAR_talkToCli(charaindex, -1, "环绕着你的光芒消失了。", CHAR_COLORWHITE); + return; + } + } + CHAR_talkToCli(charaindex, -1, "什麽事也没有发生。", CHAR_COLORWHITE); +} + +extern void setStayEncount(int fd); +void ITEM_useEncounter( int charaindex, int toindex, int haveitemindex) +{ + int itemindex,fd; + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + fd=CHAR_getWorkInt( charaindex, CHAR_WORKFD); + setStayEncount(fd); +#ifdef _USER_CHARLOOPS + { + Char *ch; + ch = CHAR_getCharPointer( charaindex); + if( ch == NULL ) return; + strcpysafe( ch->charfunctable[CHAR_LOOPFUNCTEMP1].string, + sizeof( ch->charfunctable[CHAR_LOOPFUNCTEMP1]), "CHAR_BattleStayLoop");//战斗 + CHAR_setInt( charaindex, CHAR_LOOPINTERVAL, 2500); + CHAR_constructFunctable( charaindex); + } +#endif + CHAR_talkToCli(charaindex, -1, "你感受到周边突然充满了杀气!", CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); + +} + +#ifdef _DEATH_CONTENDWATCH +void ITEM_useWatchBattle( int charaindex, int toindex, int haveitemindex) +{ + int itemindex,fd; + int battleTi; + char buf1[256]; + char *itemarg=NULL; + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + if( (itemarg = ITEM_getChar( itemindex, ITEM_ARGUMENT)) == NULL ) return; + battleTi = atoi( itemarg); + fd = CHAR_getWorkInt( charaindex, CHAR_WORKFD); + + { + ArrangeBattleC *aBo=NULL; + ArrangeBattleC *aB1=NULL; + ArrangeBattleC *aB2=NULL; + + if( battleTi<0 || battleTi>MAXBATTLEPAGE ) return; + if( (aBo=ArrangeBattleC_getInBattleArray( battleTi)) == NULL){ + sprintf( buf1, "目前场%d并没有竞赛。", battleTi); + CHAR_talkToCli(charaindex, -1, buf1, CHAR_COLORYELLOW); + return; + } + + if( (aB1=aBo->next[0]) == NULL || + (aB2=aBo->next[1]) == NULL || + !CHAR_CHECKINDEX( aB1->toindex) || + !CHAR_CHECKINDEX( aB2->toindex) || + CHAR_getWorkInt( aB1->toindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE || + CHAR_getWorkInt( aB2->toindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE ){ + + sprintf( buf1, "目前场%d尚未开始战斗。", battleTi); + CHAR_talkToCli(charaindex, -1, buf1, CHAR_COLORYELLOW); + return; + } + + if( BATTLE_WatchEntry( charaindex, aB1->toindex) ){ + + }else{ + sprintf( buf1, "观战失败!", battleTi); + CHAR_talkToCli(charaindex, -1, buf1, CHAR_COLORYELLOW); + return; + } + } + + sprintf( buf1, "道具 %s消失了。", ITEM_getChar( itemindex, ITEM_NAME) ); + CHAR_talkToCli(charaindex, -1, buf1, CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); +} +#endif + +#ifdef _Item_DeathAct +void ITEM_UseDeathCounter( int charaindex, int toindex, int haveitemindex) +{ + int itemindex,fd; + int itemmaxuse=-1; + char buf1[256]; + char *itemarg; + char itemnumstr[32]; + int okfloor = 0; + BOOL Useflag=FALSE; + int i = 1; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + +#ifdef _ITEM_STONE + itemarg = ITEM_getChar(itemindex,ITEM_ARGUMENT); + while(1){ + if( getStringFromIndexWithDelim( itemarg, "|", i , itemnumstr, sizeof( itemnumstr)) == FALSE ) + break; + okfloor = atoi(itemnumstr); + if( CHAR_getInt( charaindex, CHAR_FLOOR ) == okfloor ){ + Useflag = TRUE; + break; + } + i++; + } + if(okfloor != 0){ // 奇怪的石头 + itemmaxuse = ITEM_getInt( itemindex, ITEM_DAMAGEBREAK); + if( itemmaxuse != -1 ) { + itemmaxuse--; + ITEM_setInt( itemindex, ITEM_DAMAGEBREAK, itemmaxuse); + if( itemmaxuse < 1 ) { + sprintf( buf1, "%s消失了。", ITEM_getChar( itemindex, ITEM_NAME) ); + CHAR_talkToCli(charaindex, -1, buf1, CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); + if(Useflag==FALSE) { + CHAR_talkToCli(charaindex, -1, "没有发生任何事情!", CHAR_COLORYELLOW); + return; + } + }else{ + sprintf( buf1, "原地遇敌,可使用次数剩馀%d次。", itemmaxuse); + ITEM_setChar( itemindex, ITEM_EFFECTSTRING, buf1); + CHAR_sendItemDataOne( charaindex, haveitemindex); + if(Useflag==FALSE) { + CHAR_talkToCli(charaindex, -1, "没有发生任何事情!", CHAR_COLORYELLOW); + return; + } + } + fd = CHAR_getWorkInt( charaindex, CHAR_WORKFD); + setStayEncount(fd); + CHAR_talkToCli(charaindex, -1, "你身边笼罩阴暗气息!", CHAR_COLORYELLOW); + }else{ + sprintf( buf1, "%s消失了。", ITEM_getChar( itemindex, ITEM_NAME) ); + CHAR_talkToCli(charaindex, -1, buf1, CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); + if(Useflag==FALSE) { + CHAR_talkToCli(charaindex, -1, "没有发生任何事情!", CHAR_COLORYELLOW); + return; + } + fd = CHAR_getWorkInt( charaindex, CHAR_WORKFD); + setStayEncount(fd); + CHAR_talkToCli(charaindex, -1, "你身边笼罩阴暗气息!", CHAR_COLORYELLOW); + } + }else{ //恶魔宝石 +#endif +#ifdef _ITEM_MAXUSERNUM + itemmaxuse = ITEM_getInt( itemindex, ITEM_DAMAGEBREAK); + if( itemmaxuse != -1 ) { + itemmaxuse--; + ITEM_setInt( itemindex, ITEM_DAMAGEBREAK, itemmaxuse); + if( itemmaxuse < 1 ) { + sprintf( buf1, "道具 %s消失了。", ITEM_getChar( itemindex, ITEM_NAME) ); + CHAR_talkToCli(charaindex, -1, buf1, CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); + }else{ + sprintf( buf1, "原地遇敌,可使用次数剩馀%d次。", itemmaxuse); + ITEM_setChar( itemindex, ITEM_EFFECTSTRING, buf1); + CHAR_sendItemDataOne( charaindex, haveitemindex); + } + fd = CHAR_getWorkInt( charaindex, CHAR_WORKFD); + setStayEncount(fd); + CHAR_talkToCli(charaindex, -1, "你感受到周边突然充满了杀气!", CHAR_COLORYELLOW); + }else{ + CHAR_DelItem( charaindex, haveitemindex); + return; + } +#else + fd = CHAR_getWorkInt( charaindex, CHAR_WORKFD); + setStayEncount(fd); + sprintf( buf1, "道具 %s消失了。", ITEM_getChar( itemindex, ITEM_NAME) ); + CHAR_talkToCli(charaindex, -1, buf1, CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); +#endif +#ifdef _ITEM_STONE + } +#endif +#ifdef _USER_CHARLOOPS + { + Char *ch; + ch = CHAR_getCharPointer( charaindex); + if( ch == NULL ) return; + strcpysafe( ch->charfunctable[CHAR_LOOPFUNCTEMP1].string, + sizeof( ch->charfunctable[CHAR_LOOPFUNCTEMP1]), "CHAR_BattleStayLoop");//战斗 + CHAR_setInt( charaindex, CHAR_LOOPINTERVAL, 2500); + CHAR_constructFunctable( charaindex); + } +#endif +} +#endif + +#ifdef _CHRISTMAS_REDSOCKS +void ITEM_useMaxRedSocks( int charaindex, int toindex, int haveitemindex) +{ + int itemtimes = -1, itemindex; + char *itemarg=NULL; + int present[13]={ 13061, 13062, 13063, 13064, 13088, 13089, 13090, 13091, //1. + 14756, 17256, + 13092,19692,20594}; + int nowtimes = time( NULL); + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + itemarg = ITEM_getChar( itemindex, ITEM_ARGUMENT); + if( itemarg == NULL ) { + CHAR_talkToCli(charaindex, -1, "道具无效!", CHAR_COLORYELLOW); + return; + } + itemtimes = atoi( itemarg); + if( nowtimes >= itemtimes && nowtimes <= itemtimes+(60*60*24) ){ //限制时间内可换礼物 + int si=0, ret; + char token[256]; + //删除 + CHAR_setItemIndex(charaindex, haveitemindex ,-1); + CHAR_sendItemDataOne( charaindex, haveitemindex); + ITEM_endExistItemsOne(itemindex); + itemindex = -1; + //新增 + si = rand()%100; + if( si > 70 ){ + si = rand()%3+10; + }else if( si > 60 ){ + si = rand()%2+8; + }else { + si = rand()%8; + } + itemindex = ITEM_makeItemAndRegist( present[ si]); + if( !ITEM_CHECKINDEX( itemindex)){ + CHAR_talkToCli(charaindex, -1, "礼物无效!", CHAR_COLORYELLOW); + return; + } + ret = CHAR_addItemSpecificItemIndex( charaindex, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + ITEM_endExistItemsOne( itemindex); + CHAR_talkToCli(charaindex, -1, "礼物置放栏位错误!", CHAR_COLORYELLOW); + return; + } + sprintf( token,"拿到%s",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW ); + CHAR_sendItemDataOne( charaindex, ret); + }else{ + char token[256]; + if( nowtimes < itemtimes ){ + int days, hours, minute, second; + int defTimes = itemtimes - nowtimes; + + days = defTimes/(24*60*60); + defTimes = defTimes-( days*(24*60*60)); + hours = defTimes/(60*60); + defTimes = defTimes-( hours*(60*60)); + minute = defTimes/60; + defTimes = defTimes-( minute*60); + second = defTimes; + sprintf( token,"%s还差%d天%d小时%d分%d秒才可使用!", + ITEM_getChar( itemindex, ITEM_NAME), days, hours, minute, second); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW ); + }else if( nowtimes > itemtimes+(60*60*24) ){ + sprintf( token,"%s使用期限已过!", ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW ); + } + } +} +#endif + +#ifdef _CHRISTMAS_REDSOCKS_NEW +void ITEM_useMaxRedSocksNew( int charaindex, int toindex, int haveitemindex) +{ + int itemindex; + char *itemarg=NULL; + char itemnumstr[32]; + int itemnum=0; + int present[20]; + int si=0, ret,i; + char token[256]; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + itemarg = ITEM_getChar( itemindex, ITEM_ARGUMENT); + if( itemarg == NULL ){ + CHAR_talkToCli(charaindex, -1, "这是个芭乐圣诞袜!", CHAR_COLORYELLOW); + return; + } + + //道具数量 + if( getStringFromIndexWithDelim( itemarg, "|", 1, itemnumstr, sizeof( itemnumstr)) == FALSE ) + return; + itemnum = atoi(itemnumstr); + if( itemnum > 20 ) + itemnum = 20; + for(i=0;i= CHAR_MAXITEMHAVE ) { + ITEM_endExistItemsOne( itemindex); + CHAR_talkToCli(charaindex, -1, "礼物置放栏位错误!", CHAR_COLORYELLOW); + return; + } + sprintf( token,"拿到%s",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW ); + CHAR_sendItemDataOne( charaindex, ret); + +} +#endif + +#ifdef _PETSKILL_CANNEDFOOD +void ITEM_useSkillCanned( int charaindex, int toindex, int itemNo) +{ + int itemindex; + char buf1[256]; + itemindex = CHAR_getItemIndex( charaindex, itemNo); + if(!ITEM_CHECKINDEX( itemindex)) return; + if( !CHAR_CHECKINDEX( toindex) ) return; + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPET) { + int i, petNo=-1; + for( i=0; i -1 ){//变成乌力了 + CHAR_talkToCli( charaindex, -1, "无法变身,乌力化中不能变身!", CHAR_COLORYELLOW ); + return; + } +#endif + + +#ifdef _FIXBUG_ATTACKBOW + { + int armindex = CHAR_getItemIndex( charaindex, CHAR_ARM); + if( ITEM_CHECKINDEX( armindex) == TRUE ) { + int armtype = BATTLE_GetWepon( charaindex); + if( armtype == ITEM_BOW || armtype == ITEM_BOUNDTHROW || + armtype == ITEM_BREAKTHROW || armtype == ITEM_BOOMERANG) { + CHAR_talkToCli( charaindex, -1, "使用远距离武器无法变身!", CHAR_COLORYELLOW ); + return; + } + } + } +#endif + + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + // 爵 钒铵凛反 骰允月 + if( battlemode == BATTLE_CHARMODE_INIT ){ + return; + } + // 爵 分匀凶日 + if( IsBATTLING( charaindex ) == TRUE ){ + toindex = BATTLE_No2Index(CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ), toindex ); + + } + + if( CHAR_CHECKINDEX( toindex ) == FALSE ) return; + + haveindex = -1; + for( i = 0; i < 5; i++ ){ + if( CHAR_getCharPet( charaindex, i) == toindex ) { + haveindex = i; + break; + } + } + if( haveindex == -1 && charaindex != toindex ){ + CHAR_talkToCli( charaindex, -1, "无法变身,只能变成自己的宠物!", CHAR_COLORYELLOW ); + return; + } + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + arg = ITEM_getChar(itemindex, ITEM_ARGUMENT ); + if( arg == NULL )return; + if( sscanf( arg, "%d", &metamoTime) != 1 ) + return; + + + if( toindex != charaindex ){ + CHAR_setWorkInt( charaindex, CHAR_WORKITEMMETAMO, NowTime.tv_sec +metamoTime); + sprintf( msg, "变身成%s!", CHAR_getChar( toindex, CHAR_NAME) ); + } + else { + CHAR_setWorkInt( charaindex, CHAR_WORKITEMMETAMO, 0); + sprintf( msg, "变回自己!"); + } + CHAR_talkToCli( charaindex, -1, msg, CHAR_COLORYELLOW ); + + CHAR_setInt( charaindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( toindex, CHAR_BASEBASEIMAGENUMBER) ); + CHAR_complianceParameter( charaindex); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + + CHAR_DelItem( charaindex, haveitemindex); + +} +#endif +#ifdef _ITEM_CRACKER +void ITEM_Cracker(int charaindex,int toindex,int haveitemindex) +{ + int battlemode; + // 检查玩家是否有效 + if(CHAR_CHECKINDEX(charaindex) == FALSE) return; //失败 + battlemode = CHAR_getWorkInt(charaindex,CHAR_WORKBATTLEMODE); + // 战斗中使用无效 + if(!battlemode) ITEM_useCracker_Effect(charaindex,toindex,haveitemindex); + else CHAR_talkToCli(charaindex,-1,"什麽也没发生。",CHAR_COLORWHITE); +} +#endif + +void ITEM_AddPRSkillPercent( int charaindex,int toindex,int haveitemindex) +{ +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + int level; + char token[64]; + int MySKPercent=0, itemindex=-1, i; + + if( !CHAR_CHECKINDEX( charaindex) ) return; + if( CHAR_getInt( charaindex, PROFESSION_CLASS ) == 0 ) return; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX( itemindex) )return; + level=atoi(ITEM_getChar(itemindex,ITEM_ARGUMENT)); + + for( i=0; i 10000 ) MySKPercent = 10000; + CHAR_setIntPSkill( charaindex, i, SKILL_LEVEL, MySKPercent); + } + + CHAR_setItemIndex( charaindex, haveitemindex ,-1); + CHAR_sendItemDataOne( charaindex, haveitemindex); + ITEM_endExistItemsOne( itemindex ); + CHAR_sendStatusString( charaindex , "S"); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + sprintf( token, "所有职业技能熟练度上升%d%。", level); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); +#endif +} + +void ITEM_AddPRSkillPoint( int charaindex,int toindex,int haveitemindex) +{ +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + int point; + char token[64]; + int MyPRpoint=0, itemindex=-1; + if( !CHAR_CHECKINDEX( charaindex) ) return; + if( CHAR_getInt( charaindex, PROFESSION_CLASS ) == 0 ) return; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX( itemindex) )return; + point=atoi(ITEM_getChar(itemindex,ITEM_ARGUMENT)); + + MyPRpoint = CHAR_getInt( charaindex, PROFESSION_SKILL_POINT); + CHAR_setInt( charaindex, PROFESSION_SKILL_POINT, MyPRpoint+point ); + + + CHAR_setItemIndex( charaindex, haveitemindex ,-1); + CHAR_sendItemDataOne( charaindex, haveitemindex); + ITEM_endExistItemsOne( itemindex ); + + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + + CHAR_talkToCli( charaindex, -1, "增加一点职业技能点数。", CHAR_COLORYELLOW); + sprintf( token, "增加%d点职业技能点数。", point); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); +#endif +} + +#ifdef _ITEM_ADDEXP //vincent 经验提升 +void ITEM_Addexp(int charaindex,int toindex,int haveitemindex) +{ + // 检查玩家是否有效 + if(CHAR_CHECKINDEX(charaindex) == FALSE) return; //失败 +#if 1 + ITEM_useAddexp_Effect(charaindex,toindex,haveitemindex); +#else + if( !CHAR_getWorkInt(charaindex,CHAR_WORKITEM_ADDEXP)){ + ITEM_useAddexp_Effect(charaindex,toindex,haveitemindex); + }else{ + CHAR_talkToCli(charaindex,-1,"先前使用之药效依然存在",CHAR_COLORYELLOW); + } +#endif +} +#endif + +#ifdef _ITEM_REFRESH //vincent 解除异常状态道具 +void ITEM_Refresh(int charaindex,int toindex,int haveitemindex) +{ + int battlemode,itemindex; +print("\nvincent--ITEM_Refresh"); + // 检查玩家是否有效 + if(CHAR_CHECKINDEX(charaindex) == FALSE) + { +print("\nvincent--(charaindex) == FALSE"); + return; //失败 + } + itemindex = CHAR_getItemIndex(charaindex,haveitemindex); + + battlemode = CHAR_getWorkInt(charaindex,CHAR_WORKBATTLEMODE); + if(battlemode) + { +print("\nvincent--enter ITEM_useAddexp_Effect"); +print("\nvincent-->charaindex:%d,toindex:%d",charaindex,toindex); + ITEM_useRefresh_Effect(charaindex,toindex,haveitemindex); + } + else CHAR_talkToCli(charaindex,-1,"什麽也没发生。",CHAR_COLORWHITE); + + /* 平乓仿弁正□及赭 伉旦玄井日壅蛔 */ + CHAR_setItemIndex(charaindex, haveitemindex ,-1); + CHAR_sendItemDataOne( charaindex, haveitemindex);/* 失奶 丞凳蕙 */ + /* 壅允 */ + ITEM_endExistItemsOne( itemindex ); +} +#endif +//Terry 2001/12/21 +#ifdef _ITEM_FIRECRACKER +void ITEM_firecracker(int charaindex,int toindex,int haveitemindex) +{ + int battlemode; + + // 检查玩家是否有效 + if(CHAR_CHECKINDEX(charaindex) == FALSE) return; //失败 + + battlemode = CHAR_getWorkInt(charaindex,CHAR_WORKBATTLEMODE); + + if( battlemode // 检查是否在战斗中 +#ifdef _PETSKILL_BECOMEPIG + && CHAR_getInt( charaindex, CHAR_BECOMEPIG) == -1 +#endif + ) + ITEM_useFirecracker_Battle(charaindex,toindex,haveitemindex); + else + CHAR_talkToCli(charaindex,-1,"什麽也没发生。",CHAR_COLORWHITE); +} +#endif +//Terry end + + +void ITEM_WearEquip( int charaindex, int itemindex) +{ + // WON ADD +// if( ITEM_getInt(itemindex,ITEM_ID) == 20130 ){ + CHAR_setWorkInt( charaindex, CHAR_PickAllPet, TRUE); +/// } + return; +} +void ITEM_ReWearEquip( int charaindex, int itemindex) +{ + CHAR_setWorkInt( charaindex, CHAR_PickAllPet, FALSE); + return; +} + + +#ifdef _Item_ReLifeAct +void ITEM_DIErelife( int charaindex, int itemindex, int eqw) +{ + int ReceveEffect=-1; + int toNo; + int battleindex=-1; + int attackNo=-1; + int WORK_HP=1; + char buf[256]; + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + if( BATTLE_CHECKINDEX( battleindex ) == FALSE ) { + print("\n battleindex =%d return", battleindex); + return; + } + if( CHAR_CHECKINDEX( charaindex) == FALSE ) + return; + if( ITEM_CHECKINDEX( itemindex) == FALSE ) + return; +#ifdef _DUMMYDIE + if( CHAR_getFlg( charaindex, CHAR_ISDUMMYDIE) == FALSE ) { +#else + if( CHAR_getFlg( charaindex, CHAR_ISDIE) == FALSE ) { +#endif + print("\n [ %d, CHAR_ISDIE DUMMY FALSE] return !", charaindex); + return; + } + + if( ITEM_getArgument( ITEM_getChar(itemindex,ITEM_ARGUMENT),"HP", buf, sizeof(buf) ) + == FALSE ){ + WORK_HP = 1; + }else { + if( !strcmp( buf, "FULL") ) { + WORK_HP = CHAR_getWorkInt( charaindex, CHAR_WORKMAXHP ); + }else { + WORK_HP=atoi( buf); + } + } + + ReceveEffect = SPR_fukkatu3; + toNo = BATTLE_Index2No( battleindex, charaindex ); + attackNo = -1; + + BATTLE_MultiReLife( battleindex, attackNo, toNo, WORK_HP, ReceveEffect ); + CHAR_setItemIndex( charaindex, eqw ,-1); + ITEM_endExistItemsOne( itemindex); + CHAR_sendItemDataOne( charaindex, eqw); + return; +} +#endif + +#ifdef _EQUIT_DEFMAGIC +void ITEM_MagicEquitWear( int charaindex, int itemindex) +{ + char buf[256]; + char *itemarg; + char Free[][128]={"EA","WA","FI","WI","QU"}; + int index=0; + int dMagic=0; + itemarg = ITEM_getChar(itemindex,ITEM_ARGUMENT); + memset( buf, 0, sizeof( char) *256); + if( itemarg == NULL ) return; + while( index < arraysizeof( Free) ) { + if( ITEM_getArgument( itemarg, Free[ index], buf, sizeof(buf)) == TRUE ) { + dMagic = atoi( buf); + if( dMagic <= 100 && dMagic >= -100 ) { + int def_magic = CHAR_getWorkInt( charaindex, CHAR_EQUITDEFMAGIC_E+index); + CHAR_setWorkInt( charaindex, CHAR_EQUITDEFMAGIC_E+index, def_magic + dMagic); + } + dMagic = 0; + } + index++; + if( (CHAR_EQUITDEFMAGIC_E+index) > CHAR_EQUITQUIMAGIC ) + break; + } + + return; +} + +void ITEM_MagicEquitReWear( int charaindex, int itemindex){ + char buf[256]; + char *itemarg; + char Free[][128]={"EA","WA","FI","WI","QU"}; + int index=0; + int dMagic=0; + + itemarg = ITEM_getChar(itemindex,ITEM_ARGUMENT); + memset( buf, 0, sizeof( char) *256); + if( itemarg == NULL ) return; + while( index < arraysizeof( Free) ) { + if( ITEM_getArgument( itemarg, Free[ index], buf, sizeof(buf)) == TRUE ) { + dMagic = atoi( buf); + if( dMagic <= 100 && dMagic >= -100 ) { + int def_magic = CHAR_getWorkInt( charaindex, CHAR_EQUITDEFMAGIC_E+index); + CHAR_setWorkInt( charaindex, CHAR_EQUITDEFMAGIC_E+index, def_magic - dMagic); + } + dMagic = 0; + } + index++; + if( (CHAR_EQUITDEFMAGIC_E+index) > CHAR_EQUITQUIMAGIC ) + break; + } + + return; +} +#endif + +#ifdef _EQUIT_RESIST +void ITEM_MagicResist( int charaindex, int itemindex) +{ + char *itemarg,*p=NULL; + itemarg = ITEM_getChar(itemindex,ITEM_ARGUMENT); + if( itemarg == NULL ) return; + if( p = strstr( itemarg, "抗火" ) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITFIRE, atoi( p+4 ) ); + } + else if( p = strstr( itemarg, "抗雷" ) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITTHUNDER, atoi( p+4 ) ); + } + else if( p = strstr( itemarg, "抗冰" ) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITICE, atoi( p+4 ) ); + } + else if( p = strstr( itemarg, "虚弱" ) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITWEAKEN, atoi( p+4 ) ); + } + else if( p = strstr( itemarg, "魔障" ) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITBARRIER, atoi( p+4 ) ); + } + else if( p = strstr( itemarg, "沉默" ) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITNOCAST, atoi( p+4 ) ); + } + else if( p = strstr( itemarg, "落马" ) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITFALLRIDE, atoi( p+4 ) ); + } + +} + +void ITEM_MagicReResist( int charaindex, int itemindex) +{ + char *itemarg,*p=NULL; + itemarg = ITEM_getChar(itemindex,ITEM_ARGUMENT); + if( itemarg == NULL ) return; + if( p = strstr( itemarg, "抗火" ) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITFIRE, 0 ); + } + else if( p = strstr( itemarg, "抗雷" ) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITFIRE, 0 ); + } + else if( p = strstr( itemarg, "抗冰" ) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITFIRE, 0 ); + } + else if( p = strstr( itemarg, "虚弱" ) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITFIRE, 0 ); + } + else if( p = strstr( itemarg, "魔障" ) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITFIRE, 0 ); + } + else if( p = strstr( itemarg, "沉默" ) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITFIRE, 0 ); + } + else if( p = strstr( itemarg, "落马" ) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITFIRE, 0 ); + } +} +#endif + +#ifdef _MAGIC_RESIST_EQUIT // WON ADD 职业抗性装备 +void ITEM_P_MagicEquitWear( int charaindex, int itemindex ) +{ + char buf[256] = {0}; + char *itemarg; + char Free[][128]={"FR","IR","TR"}; + int dMagic=0; + int i; + + itemarg = ITEM_getChar(itemindex,ITEM_ARGUMENT); + if( itemarg == NULL ) return; + +// print("\n won test 10.0 ==> itemarg(%s)", itemarg ); + + for( i=0; i<3; i++ ){ + if( ITEM_getArgument( itemarg, Free[ i ], buf, sizeof(buf)) == TRUE ) { + dMagic = atoi( buf); +// print("\n won test 10.1 ==> i(%d) dMagic(%d)", i, dMagic ); + + if( dMagic <= 100 && dMagic >= -100 ){ + int def_magic = CHAR_getWorkInt( charaindex, CHAR_WORK_F_SUIT+i ); + CHAR_setWorkInt( charaindex, CHAR_WORK_F_SUIT+i, def_magic + dMagic); + +// print("\n won test 10.2 ==> i(%d)(%d)", i, CHAR_getWorkInt( charaindex, CHAR_WORK_F_SUIT+i ) ); + } + dMagic = 0; + } + } + + return; +} + + +void ITEM_P_MagicEquitReWear( int charaindex, int itemindex ) +{ + char buf[256] = {0}; + char *itemarg; + char Free[][128]={"FR","IR","TR"}; + int dMagic=0; + int i; + + itemarg = ITEM_getChar(itemindex,ITEM_ARGUMENT); + if( itemarg == NULL ) return; + +// print("\n won test 10.0 ==> itemarg(%s)", itemarg ); + + for( i=0; i<3; i++ ){ + if( ITEM_getArgument( itemarg, Free[ i ], buf, sizeof(buf)) == TRUE ) { + dMagic = atoi( buf); +// print("\n won test 10.1 ==> i(%d) dMagic(%d)", i, dMagic ); + + if( dMagic <= 100 && dMagic >= -100 ){ + int def_magic = CHAR_getWorkInt( charaindex, CHAR_WORK_F_SUIT+i ); + CHAR_setWorkInt( charaindex, CHAR_WORK_F_SUIT+i, def_magic - dMagic); + +// print("\n won test 10.2 ==> i(%d)(%d)", i, CHAR_getWorkInt( charaindex, CHAR_WORK_F_SUIT+i ) ); + } + dMagic = 0; + } + } + + return; + +} +#endif + + + +#ifdef _ITEM_WARP_FIX_BI +void recoverbi(int index) +{ + int eBbi=-1, eArm=-1, eNum=-1, eBi=-1, bi=-1; + + bi = CHAR_getInt( index, CHAR_BASEIMAGENUMBER); + eBbi = CHAR_getInt( index, CHAR_BASEBASEIMAGENUMBER); + eArm = CHAR_getItemIndex( index, CHAR_ARM); + eNum = ITEM_FIST; + if(ITEM_CHECKINDEX(eArm)) + eNum = ITEM_getInt( eArm, ITEM_TYPE); + + eBi = CHAR_getNewImagenumberFromEquip( eBbi, eNum); + + if(CHAR_getInt( index, CHAR_RIDEPET)!=-1) //骑宠 + CHAR_complianceParameter(index); + else //非骑宠 + if((eBi!=-1)&&(eBi!=bi)) + CHAR_setInt( index, CHAR_BASEIMAGENUMBER, eBi); +} +#endif + +#ifdef _ITEM_TIME_LIMIT +void ITEM_TimeLimit( int charaindex) +{ + int i = 0; + int iid = 0; + long lTime = 0; + char buff[256]; + + if( !CHAR_CHECKINDEX( charaindex) ) return; + for( i=0; i < CHAR_MAXITEMHAVE ; i++ ){ + int itemindex = CHAR_getItemIndex( charaindex , i ); + if( !ITEM_CHECKINDEX( itemindex ) ) continue; + lTime = ITEM_getWorkInt( itemindex, ITEM_WORKTIMELIMIT); + if( ITEM_getInt( itemindex, ITEM_ID) == 20173 //燃烧火把 + || ITEM_getInt( itemindex, ITEM_ID) == 20704 ){ + if( lTime > 0 && NowTime.tv_sec > lTime ){ + iid = ITEM_getInt( itemindex, ITEM_ID) + 1; + snprintf( buff, sizeof( buff), "%s的效果已消失..", ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, buff, CHAR_COLORGREEN); + CHAR_DelItemMess( charaindex, i, 0); + itemindex = ITEM_makeItemAndRegist( iid); + if(itemindex!=-1){ + CHAR_setItemIndex( charaindex, i, itemindex); + ITEM_setWorkInt( itemindex, ITEM_WORKOBJINDEX, -1); + ITEM_setWorkInt( itemindex, ITEM_WORKCHARAINDEX, charaindex); + CHAR_sendItemDataOne( charaindex, i); + } + } + } + } + +} +#endif + +#ifdef _BLACK_MARKET +void ITEM_BM_Exchange( int charaindex, int iindex) +{ + BOOL pckConfirm=FALSE; + int cdnConfirm=0; + int i, j, fd, id, itemindex, gTmp; + char sBuf[256]=""; + + fd = getfdFromCharaIndex( charaindex); + + if(!CHAR_CHECKINDEX( charaindex)) return; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE)!=BATTLE_CHARMODE_NONE) return; + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE)!=CHAR_PARTY_NONE) return; + if( CHAR_getFlg( charaindex, CHAR_ISTRADE)) return; + if( iindex==-1) return; + + for( i=0; i<12; i++){ + if(iindex==CONNECT_get_BMList( getfdFromCharaIndex( charaindex), i)){ + pckConfirm = TRUE; + break; + } + } + + if(pckConfirm){ + if(!BMItem[iindex].GCondition||BMItem[iindex].GCondition=CHAR_MAXITEMHAVE){ + print( "npc_exchange.c: ACCEPTadditem error itemindex[%d]\n", itemindex); + ITEM_endExistItemsOne( itemindex); + sprintf( sBuf, "交易失败..."); + CHAR_talkToCli( charaindex, -1, sBuf, CHAR_COLORRED); + return; + } + CHAR_sendItemDataOne( charaindex, ret); + } + gTmp = CHAR_getInt( charaindex, CHAR_GOLD); + gTmp -= BMItem[iindex].GCondition; + CHAR_setInt( charaindex, CHAR_GOLD, gTmp); + CHAR_complianceParameter( charaindex); + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_GOLD); + + sprintf( sBuf,"交出石币 %d", BMItem[iindex].GCondition); + CHAR_talkToCli( charaindex, -1, sBuf, CHAR_COLORWHITE); + // test shan shan + sprintf( sBuf, "....这个你就收下吧!!"); + CHAR_talkToCli( charaindex, -1, sBuf, CHAR_COLORYELLOW); + // add to Empty + for( i=0; i<12; i++){ + if(BMSellList[i]==iindex){ + BMSellList[i] = RAND(0, BMINum-1); + break; + } + } + for( i=0; i<12; i++) + CONNECT_set_BMList( getfdFromCharaIndex( charaindex), i, -1); + return; + } + } + } + sprintf( sBuf, "交易失败..."); + CHAR_talkToCli( charaindex, -1, sBuf, CHAR_COLORRED); +} +#endif + +#ifdef _ITEM_CONSTITUTION +void ITEM_Constitution( int charaindex, int toindex, int haveitemindex) +{ + char buf[256]; + char *itemarg; + char Free[][128]={"VI","ST","TG","DE"}; + int index=0, FixPoint=0, itemindex; + BOOL FIXs=FALSE; + int AllPoint=0; + + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ) + return; + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + itemarg = ITEM_getChar( itemindex, ITEM_ARGUMENT); + if( itemarg == NULL ) return; + memset( buf, 0, sizeof( char) *256); + + AllPoint = CHAR_getInt( charaindex, CHAR_VITAL) + +CHAR_getInt( charaindex, CHAR_VITAL+1) + +CHAR_getInt( charaindex, CHAR_VITAL+2) + +CHAR_getInt( charaindex, CHAR_VITAL+3); + + while( index < arraysizeof( Free) ) { + if( ITEM_getArgument( itemarg, Free[ index], buf, sizeof(buf)) == TRUE ) { + FixPoint = atoi( buf); + if( FixPoint <= 100 && FixPoint > 0 ) { + int points = CHAR_getInt( charaindex, CHAR_VITAL+index); + //Change Fix + //if( points < (FixPoint*100) ) break; + if( points < (FixPoint*100) || AllPoint-(FixPoint*100) <= 0 ) + { + CHAR_talkToCli( charaindex, -1, "物品无效。", CHAR_COLORYELLOW); + return; + } + CHAR_setInt( charaindex, CHAR_VITAL+index, (points-(FixPoint*100))); + CHAR_setInt( charaindex, CHAR_SKILLUPPOINT, CHAR_getInt( charaindex, CHAR_SKILLUPPOINT) + FixPoint); + FIXs = TRUE; + } + FixPoint = 0; + } + index++; + if( (CHAR_VITAL+index) > CHAR_DEX ) + break; + } + CHAR_complianceParameter( charaindex); + CHAR_send_P_StatusString( charaindex, + CHAR_P_STRING_MAXHP|CHAR_P_STRING_HP|CHAR_P_STRING_LV|CHAR_P_STRING_EXP| + CHAR_P_STRING_ATK|CHAR_P_STRING_DEF|CHAR_P_STRING_QUICK| + CHAR_P_STRING_VITAL|CHAR_P_STRING_STR|CHAR_P_STRING_TOUGH|CHAR_P_STRING_DEX); + + CHAR_Skillupsend( charaindex); + memset( buf, 0, sizeof( buf)); + if( FIXs == TRUE ) { + sprintf( buf, "%s", "你的身体感到变化。"); + }else { + sprintf( buf, "%s", "物品无效。"); + } + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); +} +#endif + +#ifdef _NEW_RIDEPETS +void ITEM_useLearnRideCode( int charaindex, int toindex, int haveitemindex) +{//CHAR_LOWRIDEPETS + int itemindex, i; + char buf1[256]; + char *itemarg; + int ridetrans; + typedef struct{ + char arg[256]; + int Code; + }tagNewRideCode; + tagNewRideCode NewRides[12]={ + { "RIDE_PET0", RIDE_PET0}, { "RIDE_PET1", RIDE_PET1}, { "RIDE_PET2", RIDE_PET2}, + { "RIDE_PET3", RIDE_PET3}, { "RIDE_PET4", RIDE_PET4}, { "RIDE_PET5", RIDE_PET5}, + { "RIDE_PET6", RIDE_PET6}, { "RIDE_PET7", RIDE_PET7}, { "RIDE_PET8", RIDE_PET8}, + { "RIDE_PET9", RIDE_PET9}, { "RIDE_PET10", RIDE_PET10}, { "RIDE_PET11", RIDE_PET11} + }; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + itemarg = ITEM_getChar( itemindex, ITEM_ARGUMENT); + if( itemarg == NULL ) return; + memset( buf1, 0, sizeof( buf1)); + if( getStringFromIndexWithDelim(itemarg,"|", 3, buf1, sizeof(buf1)) == FALSE ) + ridetrans=0; + else + ridetrans=atoi(buf1); + if( getStringFromIndexWithDelim(itemarg,"|", 1, buf1, sizeof(buf1)) == FALSE ) + return; + for( i=0; i<12; i++) { + if( !strcmp( NewRides[i].arg, buf1) ) { + int LRCode = CHAR_getInt( charaindex, CHAR_LOWRIDEPETS); + if(CHAR_getInt( charaindex, CHAR_TRANSMIGRATION) < ridetrans){ + char token[256]; + memset( token, 0, sizeof( token)); + if( getStringFromIndexWithDelim(itemarg,"|", 2, buf1, sizeof(buf1)) != FALSE ){ + sprintf( token, "必须%d转人以上才能学习骑%s。",ridetrans,buf1); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + return; + } + } + LRCode = LRCode|NewRides[i].Code; + CHAR_setInt( charaindex, CHAR_LOWRIDEPETS, LRCode); + memset( buf1, 0, sizeof( buf1)); + if( getStringFromIndexWithDelim(itemarg,"|", 2, buf1, sizeof(buf1)) != FALSE ){ + char token[256]; + memset( token, 0, sizeof( token)); + sprintf( token, "学习了新的骑宠 (%s)。", buf1); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); + CHAR_sendStatusString( charaindex, "x"); + } + break; + } + } +} + +#endif + + + + + +#ifdef _ITEM_EDITBASES +void ITEM_useFusionEditBase( int charaindex, int toindex, int haveitemindex) +{ + int itemindex; + int work[4]={0,0,0,0}; + int anhour = PETFEEDTIME;//宠物 食时间(单位:秒) + + if( !CHAR_CHECKINDEX( charaindex ) ) return; + if( !CHAR_CHECKINDEX( toindex ) ) return; + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPET){ + CHAR_talkToCli( charaindex, -1, "物品仅限宠物使用。", CHAR_COLORYELLOW); + return; + } + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX(itemindex) ) return; + if( CHAR_getInt( toindex, CHAR_FUSIONBEIT) == 1 && + CHAR_getInt( toindex, CHAR_FUSIONRAISE) > 0 ){//检查是否为融合宠 + +#ifdef _TEST_PETFUSIONTIME +#else + int time_l; + int nowTime; // Robin fix + time_l = CHAR_getInt( toindex, CHAR_FUSIONTIMELIMIT); + nowTime = (int)time(NULL); +#if 1 // 消化药 + { + char *arg = NULL; + int deltime; + char msg[1024]; + arg = ITEM_getChar( itemindex, ITEM_ARGUMENT); + if( arg != NULL && !strncmp( arg, "消", 2) ) { + sscanf( arg, "消 %d", &deltime); + time_l -= (deltime*60); + CHAR_setInt( toindex, CHAR_FUSIONTIMELIMIT, time_l); + CHAR_DelItem( charaindex, haveitemindex); + sprintf( msg, "加快宠物蛋的消化速度 %d 分钟。", deltime); + CHAR_talkToCli( charaindex, -1, msg, CHAR_COLORYELLOW); + if( (time_l + anhour) <= nowTime ) { + int min, sec, deftime; + deftime = nowTime - (time_l + anhour); + min = deftime/60; + sec = deftime%60; + sprintf( msg, "宠物蛋已经可以 食了,超过 食时间%d分%d秒。", min, sec); + CHAR_talkToCli( charaindex, -1, msg, CHAR_COLORYELLOW); + return; + } + } + } +#endif + if( (time_l + anhour) > nowTime ){ //现在的时间要超过(time_l+anhour)才可以 食 + char Mess1[256]; + int min, sec, deftime; + //int nowTime = (int)time(NULL); + deftime = (time_l + anhour) - nowTime; + min = deftime/60; + sec = deftime%60; + sprintf( Mess1, "宠物蛋需过%d分%d秒才可 食。", min, sec); + CHAR_talkToCli( charaindex, -1, Mess1, CHAR_COLORYELLOW); + return; + } +#endif +//--------------------------------------------- + work[3] = CHAR_getInt( toindex, CHAR_EVOLUTIONBASEVTL); + work[0] = CHAR_getInt( toindex, CHAR_EVOLUTIONBASESTR); + work[1] = CHAR_getInt( toindex, CHAR_EVOLUTIONBASETGH); + work[2] = CHAR_getInt( toindex, CHAR_EVOLUTIONBASEDEX); + PET_showEditBaseMsg( charaindex, toindex, itemindex, work); + CHAR_setInt( toindex, CHAR_EVOLUTIONBASEVTL, work[3]); + CHAR_setInt( toindex, CHAR_EVOLUTIONBASESTR, work[0]); + CHAR_setInt( toindex, CHAR_EVOLUTIONBASETGH, work[1]); + CHAR_setInt( toindex, CHAR_EVOLUTIONBASEDEX, work[2]); +//--------------------------------------------- + LogPetPointChange( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), + CHAR_getChar( charaindex, CHAR_NAME), + toindex, 4, + CHAR_getInt( toindex, CHAR_LV), + "item_use", + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X ), + CHAR_getInt( charaindex, CHAR_Y ) + ); + + LogPetFeed( + CHAR_getChar( charaindex, CHAR_NAME), + CHAR_getChar( charaindex, CHAR_CDKEY), + CHAR_getChar( toindex, CHAR_NAME), + toindex, + CHAR_getInt( toindex, CHAR_LV), + ITEM_getChar( itemindex, CHAR_NAME), // Key + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y), + CHAR_getChar( toindex, CHAR_UNIQUECODE) ); + +#ifdef _PET_EVOLUTION + { + int raise = CHAR_getInt( toindex, CHAR_FUSIONRAISE); + CHAR_setInt( toindex, CHAR_FUSIONRAISE, --raise); + CHAR_setInt( toindex, CHAR_FUSIONTIMELIMIT, nowTime); + if( CHAR_getInt( toindex, CHAR_FUSIONRAISE) <= 0 ){//孵化 + char buf[256], buf1[256]; + int newindex; + sprintf( buf, "蛋〈%s〉孵化成", CHAR_getUseName( toindex )); + + newindex = EVOLUTION_createPetFromEnemyIndex( charaindex, toindex, 1); + if( !CHAR_CHECKINDEX( newindex) ){ + CHAR_talkToCli( charaindex, -1, "宠物孵化发生错误。", CHAR_COLORYELLOW); + return; + } + sprintf( buf1, "〈%s〉。", CHAR_getChar( newindex, CHAR_NAME)); + strcat( buf, buf1); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + + LogPetFeed( + CHAR_getChar( charaindex, CHAR_NAME), + CHAR_getChar( charaindex, CHAR_CDKEY), + CHAR_getChar( toindex, CHAR_NAME), + toindex, + CHAR_getInt( toindex, CHAR_LV), + buf, // Key + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y), + CHAR_getChar( toindex, CHAR_UNIQUECODE) ); + + } + } +#endif + }else { + CHAR_talkToCli( charaindex, -1, "???", CHAR_COLORYELLOW); + } + CHAR_DelItem( charaindex, haveitemindex); + return; +} +#endif + +#ifdef _THROWITEM_ITEMS +static int Niceitem = 0; + int golds[3]={ 10000, 20000, 50000}; + int items1[18] = { 13092, 13091, 20439, 20417, 1284, 20172, 18210, 19014, 18360, 18362, 18364, + 18359, 18356, 18357, 18510, 20418, 20419, 1452}; + int items2[11] = { 15842, 16136, 14334, 14034, 14634, 14934, 15534, 14934, 16432, 17057, 19695}; + + int items3[10] = { 16014, 16314, 14515, 14215, 14815, 15115, 15715, 15295, 16552, 17157}; + + int items4[18] = { 14516, 14513, 14216, 14213, 14816, 14813, 15116, 15716, 15415, 17360, 20279, + 20282, 20276, 20270, 20288, 20290, 20291, 20289}; + int items5[5] = { 20280, 20283, 20277, 20271, 20274}; + int items6[5] = { 20284, 20272, 20275, 20281, 20278}; +void ITEM_ThrowItemBox( int charaindex, int toindex, int haveitemindex) +{ + int i, ret, Iindex, ItemID=-1, itemindex; + char token[256]; + + if( !CHAR_CHECKINDEX(charaindex) ) return; + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX(itemindex) ) return; + + if( Niceitem > 10 ) ret = rand()%920; + else ret = rand()%1000; + + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE ; i++ ){ + Iindex = CHAR_getItemIndex( charaindex , i ); + if( !ITEM_CHECKINDEX(itemindex) ) continue; + if( itemindex == Iindex ){ + CHAR_DelItem( charaindex, i); + + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), +#endif + "WarpManDelItem", + CHAR_getInt( charaindex, CHAR_FLOOR), CHAR_getInt( charaindex, CHAR_X ), + CHAR_getInt( charaindex, CHAR_Y ), ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + break; + } + } + if( i >= CHAR_MAXITEMHAVE ){ + return; + } + + if( ret <= 774 ){ + int Golds=0; + Golds = golds[ RAND(0,2)]; + CHAR_AddGold( charaindex, Golds); + }else { + if( ret < 924 ){ + ItemID = items1[RAND(0,17)]; + }else if( ret < 964 ){ + ItemID = items2[RAND(0,10)]; + }else if( ret < 984 ){ + ItemID = items3[RAND(0,9)]; + Niceitem++; + }else if( ret < 994 ){ + ItemID = items4[RAND(0,17)]; + Niceitem++; + }else if( ret < 999 ){ + ItemID = items5[RAND(0,4)]; + Niceitem++; + }else { + ItemID = items6[RAND(0,4)]; + Niceitem++; + } + + Iindex = ITEM_makeItemAndRegist( ItemID); + if( !ITEM_CHECKINDEX( Iindex) ){ + return; + } + ret = CHAR_addItemSpecificItemIndex( charaindex, Iindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + ITEM_endExistItemsOne( Iindex); + return; + } + sprintf( token,"拿到%s", ITEM_getChar( Iindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW ); + CHAR_sendItemDataOne( charaindex, ret); + } +} +#endif + +#ifdef _ITEM_LOVERPARTY +void ITEM_LoverSelectUser( int charaindex, int toindex, int haveitemindex) +{ + int itemindex, i; + int playernum = CHAR_getPlayerMaxNum(); + + if( !CHAR_CHECKINDEX( charaindex ) ) return; + if( !CHAR_CHECKINDEX( toindex ) ) return; + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER){ + CHAR_talkToCli( charaindex, -1, "物品仅限人物使用。", CHAR_COLORYELLOW); + return; + } + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX(itemindex) ) return; + if( ITEM_getInt( itemindex, ITEM_TYPE) != 16 ){ + ITEM_setInt( itemindex, ITEM_TYPE, 16); + return; + } + if( !strcmp( ITEM_getChar( itemindex, ITEM_FORUSERNAME), "") || + !strcmp( ITEM_getChar( itemindex, ITEM_FORUSERCDKEY), "") ){//寻找设定对象 + if( charaindex == toindex ){ + CHAR_talkToCli( charaindex, -1, "不能选择自己使用。", CHAR_COLORYELLOW); + return; + } + ITEM_setChar( itemindex, ITEM_FORUSERNAME, CHAR_getChar( toindex, CHAR_NAME) ); + ITEM_setChar( itemindex, ITEM_FORUSERCDKEY, CHAR_getChar( toindex, CHAR_CDKEY) ); + ITEM_setInt( itemindex, ITEM_TARGET, 0); + { + char token[256]; + sprintf( token, "%s(%s)", + ITEM_getChar( itemindex, ITEM_SECRETNAME), CHAR_getChar( toindex, CHAR_NAME)); + ITEM_setChar( itemindex, ITEM_SECRETNAME, token); + sprintf( token, "传送对象设定为%s。", CHAR_getChar( toindex, CHAR_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + } + CHAR_sendItemDataOne( charaindex, haveitemindex); + }else{ + char buf1[256]; + //if( CHAR_getInt( charaindex, CHAR_FLOOR) == 117 || CHAR_getInt( charaindex, CHAR_FLOOR) == 887 || + //CHAR_getInt( charaindex, CHAR_FLOOR) == 1042 || CHAR_getInt( charaindex, CHAR_FLOOR) == 2032 || + //CHAR_getInt( charaindex, CHAR_FLOOR) == 3032 || CHAR_getInt( charaindex, CHAR_FLOOR) == 4032 || + //CHAR_getInt( charaindex, CHAR_FLOOR) == 5032 || CHAR_getInt( charaindex, CHAR_FLOOR) == 6032 || + //CHAR_getInt( charaindex, CHAR_FLOOR) == 7032 || CHAR_getInt( charaindex, CHAR_FLOOR) == 8032 || + //CHAR_getInt( charaindex, CHAR_FLOOR) == 9032 ){ + if( checkUnlawWarpFloor( CHAR_getInt( charaindex, CHAR_FLOOR) ) ) { + CHAR_talkToCli( charaindex, -1, "你的所在位置无法传送。", CHAR_COLORYELLOW ); + return; + } + + for( i=0; i= 10000) continue; + + if( (int)NowTime.tv_sec > (int)( OBJECT_getTime( objindex) + getItemdeletetime() ) ) { + + LogStone( + -1, + "NULL", + "NULL", + amount, + 0, + "Del(删除过时金钱)", + OBJECT_getFloor( objindex ), + OBJECT_getX( objindex ), + OBJECT_getY( objindex ) + ); + + CHAR_ObjectDelete(objindex); + } + } +} + +void GOLD_DeleteTimeCheckOne( int objindex) +{ + int amount; + + if( CHECKOBJECT( objindex ) == FALSE ) return; + if( OBJECT_getType( objindex) != OBJTYPE_GOLD) return; + + amount = OBJECT_getIndex( objindex); + if( amount >= 10000) return; + + if( (int)NowTime.tv_sec > (int)( OBJECT_getTime( objindex) + getItemdeletetime() ) ) { + + LogStone( + -1, + "NULL", + "NULL", + amount, + 0, + "Del(删除过时金钱)", + OBJECT_getFloor( objindex ), + OBJECT_getX( objindex ), + OBJECT_getY( objindex ) + ); + + CHAR_ObjectDelete(objindex); + } + +} + +#endif + +#ifdef _TIME_TICKET +void ITEM_timeticket( int charaindex, int toindex, int haveitemindex) +{ + ITEM_timeticketEx( charaindex, toindex, haveitemindex, 0); +} + +void ITEM_timeticketEx( int charaindex, int toindex, int haveitemindex, int flag) +{ + int itemindex; + int addtime; + int nowtime = time(NULL); + int tickettime; + int lefttime; + char msg[1024]; + + if( !CHAR_CHECKINDEX( charaindex ) ) return; + + if( check_TimeTicketMap( CHAR_getInt( charaindex, CHAR_FLOOR)) == FALSE + && flag == 0 ) { + CHAR_talkToCli( charaindex, -1, "这个地点不可使用。", CHAR_COLORYELLOW); + return; + } + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX(itemindex) ) return; + + tickettime = CHAR_getWorkInt( charaindex, CHAR_WORKTICKETTIME); + if( tickettime > nowtime+20 ) { + CHAR_talkToCli( charaindex, -1, "时间必须剩下20秒以内才可使用。", CHAR_COLORYELLOW); + return; + } + // 第一次使用的话 + if( tickettime == 0 ) { + tickettime = nowtime; + CHAR_setWorkInt( charaindex, CHAR_WORKTICKETTIMESTART, nowtime); + } + // 战斗中且超过时限时使用 + //if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE + // && tickettime < nowtime ) { + //tickettime = nowtime; + // sprintf(msg, "时间不足%d秒。", nowtime - tickettime ); + // CHAR_talkToCli( charaindex, -1, msg, CHAR_COLORYELLOW); + //} + + addtime = atoi( ITEM_getChar( itemindex, ITEM_ARGUMENT)); + tickettime += addtime; + CHAR_setWorkInt( charaindex, CHAR_WORKTICKETTIME, tickettime ); + lefttime = tickettime - nowtime; + if( lefttime > 0 ) + sprintf(msg, "时间增加%d秒,还剩下%d分%d秒。", addtime, lefttime/60, lefttime%60 ); + else + sprintf(msg, "时间增加%d秒,还不足%d分%d秒。", addtime, (-lefttime)/60, (-lefttime)%60 ); + CHAR_talkToCli( charaindex, -1, msg, CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); +} +#endif + +#ifdef _ITEM_SETLOVER +void ITEM_SetLoverUser( int charaindex, int toindex, int haveitemindex) +{ + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + int playernum = CHAR_getPlayerMaxNum(); + char token[256],*pActionNumber,szMsg[128]; + int floor = CHAR_getInt(charaindex,CHAR_FLOOR); + + if( !strcmp( CHAR_getChar( charaindex, CHAR_LOVE), "YES")) + { + CHAR_talkToCli( charaindex, -1, "重婚是违法的!您已经结婚了哦~", CHAR_COLORYELLOW); + return; + } + if( !CHAR_CHECKINDEX( charaindex ) ) return; + if( !CHAR_CHECKINDEX( toindex ) ) return; + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER) + { + CHAR_talkToCli( charaindex, -1, "只能和玩家结婚哦", CHAR_COLORYELLOW); + return; + } + if( CHAR_getInt(charaindex,CHAR_TRANSMIGRATION)<3 ||CHAR_getInt(toindex,CHAR_TRANSMIGRATION)<3) + { + CHAR_talkToCli( charaindex, -1, "如果想结婚的话,双方必须3转以上哦~", CHAR_COLORYELLOW); + return; + } + if( charaindex == toindex ) + { + CHAR_talkToCli( charaindex, -1, "难道您想和自己结婚吗?", CHAR_COLORYELLOW); + return; + } + if ( IsMale(charaindex)==IsMale(toindex)) + { + CHAR_talkToCli( charaindex, -1, "同性怎么结婚呢?", CHAR_COLORYELLOW); + return; + } + if( !ITEM_CHECKINDEX(itemindex) ) return; + int id = ITEM_getInt( itemindex, ITEM_ID); + itemindex = ITEM_makeItemAndRegist( id ); + + if( strcmp( CHAR_getChar( charaindex, CHAR_LOVE), "YES") && + strcmp( CHAR_getChar( toindex, CHAR_LOVE), "YES"))//第二次判断双方是否已经结婚 + { + if( itemindex != -1 ){ + CHAR_setChar( charaindex, CHAR_LOVERID, CHAR_getChar( toindex, CHAR_CDKEY) ); + CHAR_setChar( charaindex, CHAR_LOVERNAME, CHAR_getChar( toindex, CHAR_NAME) ); + if (strcmp(CHAR_getChar( toindex, CHAR_LOVERID), CHAR_getChar( charaindex, CHAR_CDKEY))==0 && + strcmp(CHAR_getChar( toindex, CHAR_LOVERNAME), CHAR_getChar( charaindex, CHAR_NAME))==0) + { + int i; + char szMsg1[16],*arg; + + sprintf( token, "已经答应了%s的求婚", CHAR_getChar( toindex, CHAR_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + sprintf( token, "%s已经响应了你的求婚", CHAR_getChar( charaindex, CHAR_NAME)); + CHAR_talkToCli( toindex, -1, token, CHAR_COLORYELLOW); + + CHAR_setChar( toindex, CHAR_LOVE,"YES"); + CHAR_setChar( charaindex, CHAR_LOVE,"YES"); + CHAR_setChar( charaindex, CHAR_LOVERID, CHAR_getChar( toindex, CHAR_CDKEY) ); + CHAR_setChar( charaindex, CHAR_LOVERNAME, CHAR_getChar( toindex, CHAR_NAME) ); + CHAR_setChar( toindex, CHAR_LOVERID, CHAR_getChar( charaindex, CHAR_CDKEY) ); + CHAR_setChar( toindex, CHAR_LOVERNAME, CHAR_getChar( charaindex, CHAR_NAME) ); + sprintf(szMsg,"%d 8 101883",floor); + CHAR_CHAT_DEBUG_effect(charaindex,szMsg); + CHAR_DelItem( charaindex, haveitemindex); + for(i=0;i=playernum) + { + CHAR_talkToCli( charaindex, -1, "很抱歉,您的爱人不在线哦~", CHAR_COLORYELLOW ); + return; + } + + if( !CHAR_CHECKINDEX( charaindex ) ) return; + if( !CHAR_CHECKINDEX( i ) ) return; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX(itemindex) ) return; + + if( checkUnlawWarpFloor( CHAR_getInt( charaindex, CHAR_FLOOR) ) ) { + CHAR_talkToCli( charaindex, -1, "很抱歉,您的爱人在神秘遥远地方,无法传送。", CHAR_COLORYELLOW ); + return; + }//UNWARP地图禁止使用 + if( checkUnlawWarpFloor( CHAR_getInt( i, CHAR_FLOOR) ) ) { + CHAR_talkToCli( charaindex, -1, "很抱歉,您的爱人在神秘遥远地方,无法传送。", CHAR_COLORYELLOW ); + return; + }//UNWARP地图禁止使用 + int itemmaxuse=0; + + if(strcmp(CHAR_getChar(i,CHAR_LOVERID),CHAR_getChar(charaindex,CHAR_CDKEY)) == 0 && + strcmp(CHAR_getChar(i,CHAR_LOVERNAME),CHAR_getChar(charaindex,CHAR_NAME)) == 0) + { + CHAR_DischargePartyNoMsg( charaindex);//解散团队 + int floor, x, y; + char token[256]; + floor = CHAR_getInt( i, CHAR_FLOOR); + x = CHAR_getInt( i, CHAR_X); + y = CHAR_getInt( i, CHAR_Y); + + CHAR_warpToSpecificPoint( charaindex, floor, x, y ); + sprintf( token, "%s:亲爱的,我来了!", CHAR_getChar( charaindex, CHAR_NAME)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "已传送到爱人%s身边!", CHAR_getChar( i, CHAR_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW ); + print("\n玩家% 传送到玩家%s身边", CHAR_getChar( charaindex, CHAR_NAME),CHAR_getChar(i, CHAR_NAME)); + return; + } + }else + CHAR_talkToCli( charaindex, -1, "您没有结婚哦~", CHAR_COLORYELLOW ); +} + +void ITEM_LoverUnmarry( int charaindex, int toindex, int haveitemindex) +{ + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + int i; + char token[256]; + int playernum = CHAR_getPlayerMaxNum(); + //检查是否结婚 + if( !strcmp( CHAR_getChar( charaindex, CHAR_LOVE), "YES")) + { + for(i=0;i=playernum) + { + CHAR_talkToCli( charaindex, -1, "很抱歉,您的爱人不在线哦~", CHAR_COLORYELLOW ); + return; + } + + if( !CHAR_CHECKINDEX( charaindex ) ) return; + if( !CHAR_CHECKINDEX( i ) ) return; + if( !ITEM_CHECKINDEX(itemindex) ) return; + + if(strcmp(ITEM_getChar( itemindex, ITEM_SECRETNAME), "同意离婚戒指")){ + int id = ITEM_getInt( itemindex, ITEM_ID); + itemindex = ITEM_makeItemAndRegist( id ); + + if( itemindex != -1 ){ + + int emptyitemindexinchara = CHAR_findEmptyItemBox( toindex ); + + if( emptyitemindexinchara < 0 ){ + sprintf( token, "%s物品栏已满。离婚失败" , CHAR_getChar( i, CHAR_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + sprintf( token, "%s向您发起离婚,但您的物品栏已满。" , CHAR_getChar( charaindex, CHAR_NAME)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW);} + else{ + CHAR_setItemIndex( i, emptyitemindexinchara, itemindex); + ITEM_setChar( itemindex, ITEM_NAME, "同意离婚戒指"); + ITEM_setChar( itemindex, ITEM_SECRETNAME, "同意离婚戒指"); + sprintf( token, "%s向你申请离婚,如果同意请使用该戒指!", CHAR_getChar( charaindex, CHAR_NAME)); + ITEM_setChar( itemindex, ITEM_EFFECTSTRING, token); + CHAR_sendItemDataOne( i, emptyitemindexinchara); + ITEM_endExistItemsOne(itemindex); + sprintf( token, " %s向您提出离婚并把 %s 给你!", CHAR_getChar( charaindex, CHAR_NAME),ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW); + sprintf( token, "已经向%s发起离婚", CHAR_getChar( i, CHAR_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); + return;}} + }else{ + CHAR_setChar( i, CHAR_LOVE,""); + CHAR_setChar( i, CHAR_LOVERID,""); + CHAR_setChar( i, CHAR_LOVERNAME,""); + CHAR_setChar( charaindex, CHAR_LOVE,""); + CHAR_setChar( charaindex, CHAR_LOVERID,""); + CHAR_setChar( charaindex, CHAR_LOVERNAME,""); + CHAR_talkToCli( i, -1, "双方离婚成功!", CHAR_COLORYELLOW); + CHAR_talkToCli( charaindex, -1, "双方离婚成功!", CHAR_COLORYELLOW);} + CHAR_DelItem( charaindex, haveitemindex); + }else + CHAR_talkToCli( charaindex, -1, "您没有结婚哦~", CHAR_COLORYELLOW ); +} + + +#endif + +#ifdef _ITEM_METAMO +void ITEM_ColorMetamo( int charaindex, int toindex, int haveitemindex) +{ + int MetamoList[12][5]={ + /*{ 造型 , 红 , 绿 , 黄 , 灰 }, //此行为说明行*/ + { 100000, 100000, 100005, 100010, 100015}, //小矮子 + { 100020, 100025, 100030, 100035, 100020}, //赛亚人 + { 100040, 100055, 100050, 100045, 100040}, //辫子男孩 + { 100060, 100060, 100065, 100070, 100075}, //酷哥 + { 100080, 100095, 100085, 100090, 100080}, //熊皮男 + { 100100, 100100, 100115, 100110, 100105}, //大个 + { 100120, 100135, 100120, 100125, 100130}, //小矮妹 + { 100140, 100145, 100140, 100150, 100155}, //熊皮妹 + { 100160, 100165, 100170, 100160, 100175}, //帽子妹 + { 100180, 100190, 100195, 100185, 100180}, //短发夹妹 + { 100200, 100200, 100210, 100210, 100205}, //手套女 + { 100220, 100230, 100225, 100220, 100235}, //辣妹 + }; + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + char *itemarg,p; + int OldMetamoId, NewMetamoId, i; + itemarg=ITEM_getChar(itemindex,ITEM_ARGUMENT); + if( itemarg == NULL ) return; + OldMetamoId=CHAR_getInt( charaindex, CHAR_BASEBASEIMAGENUMBER); + for(i=0;i<12;i++) + if(OldMetamoId>=MetamoList[i][0] && OldMetamoId=MetamoList[11][0]) + break; + if(i==12){ + CHAR_talkToCli( charaindex, -1, "变色失败,你造型并不是人物造型", CHAR_COLORYELLOW); + return; + } + if( strstr( itemarg, "红" ) ){ + CHAR_talkToCli( charaindex, -1, "变成红色", CHAR_COLORYELLOW); + NewMetamoId=MetamoList[i][1]; + }else if( strstr( itemarg, "绿" ) ){ + CHAR_talkToCli( charaindex, -1, "变成绿色", CHAR_COLORYELLOW); + NewMetamoId=MetamoList[i][2]; + }else if( strstr( itemarg, "黄" ) ){ + CHAR_talkToCli( charaindex, -1, "变成黄色", CHAR_COLORYELLOW); + NewMetamoId=MetamoList[i][3]; + }else if( strstr( itemarg, "灰" ) ){ + CHAR_talkToCli( charaindex, -1, "变成灰色", CHAR_COLORYELLOW); + NewMetamoId=MetamoList[i][4]; + }else if( strstr( itemarg, "随" ) ){ + srand(time(0)); + do + NewMetamoId=MetamoList[i][rand()%4+1]; + while(NewMetamoId==OldMetamoId); + CHAR_talkToCli( charaindex, -1, "随机变色成功", CHAR_COLORYELLOW); + }else{ + CHAR_talkToCli( charaindex, -1, "变色失败", CHAR_COLORYELLOW); + return; + } + if(NewMetamoId==0)return; + CHAR_setInt( charaindex , CHAR_BASEIMAGENUMBER , NewMetamoId ); + CHAR_setInt( charaindex , CHAR_BASEBASEIMAGENUMBER , NewMetamoId ); + + CHAR_complianceParameter( charaindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + CHAR_DelItem( charaindex, haveitemindex); +} + +void ITEM_CharaMetamo( int charaindex, int toindex, int haveitemindex) +{ + int OldMetamoId=0, NewMetamoId=0; + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + char *itemarg,p; + itemarg=ITEM_getChar(itemindex,ITEM_ARGUMENT); + if( itemarg == NULL ) return; + OldMetamoId=CHAR_getInt( charaindex, CHAR_BASEBASEIMAGENUMBER); + if(OldMetamoId >= 100000 || OldMetamoId < 100240){ + if( strstr( itemarg, "豆丁囝" ) && OldMetamoId < 100120){ + CHAR_talkToCli( charaindex, -1, "更改造型为豆囝", CHAR_COLORYELLOW); + NewMetamoId=(OldMetamoId/1000)*1000+(OldMetamoId%20); + }else if( strstr( itemarg, "赛亚人" ) && OldMetamoId < 100120 ){ + CHAR_talkToCli( charaindex, -1, "更改造型为赛亚人", CHAR_COLORYELLOW); + NewMetamoId=(OldMetamoId/1000)*1000+20+(OldMetamoId%20); + }else if( strstr( itemarg, "辫子男孩" ) && OldMetamoId < 100120 ){ + CHAR_talkToCli( charaindex, -1, "更改造型为辫子男孩", CHAR_COLORYELLOW); + NewMetamoId=(OldMetamoId/1000)*1000+40+(OldMetamoId%20); + }else if( strstr( itemarg, "酷哥" ) && OldMetamoId < 100120 ){ + CHAR_talkToCli( charaindex, -1, "更改造型为酷哥", CHAR_COLORYELLOW); + NewMetamoId=(OldMetamoId/1000)*1000+60+(OldMetamoId%20); + }else if( strstr( itemarg, "熊皮男" ) && OldMetamoId < 100120 ){ + CHAR_talkToCli( charaindex, -1, "更改造型为熊皮男", CHAR_COLORYELLOW); + NewMetamoId=(OldMetamoId/1000)*1000+80+(OldMetamoId%20); + }else if( strstr( itemarg, "大只佬" ) && OldMetamoId < 100120 ){ + CHAR_talkToCli( charaindex, -1, "更改造型为大只佬", CHAR_COLORYELLOW); + NewMetamoId=(OldMetamoId/1000)*1000+100+(OldMetamoId%20); + }else if( strstr( itemarg, "随机" ) && OldMetamoId < 100120 ){ + srand(time(0)); + do + NewMetamoId=(OldMetamoId/1000)*1000+(rand()%6)*20+(OldMetamoId%20); + while(NewMetamoId==OldMetamoId); + CHAR_talkToCli( charaindex, -1, "随机更改造型成功", CHAR_COLORYELLOW); + } + if( strstr( itemarg, "豆丁囡" ) && OldMetamoId >= 100120 ){ + CHAR_talkToCli( charaindex, -1, "更改造型为豆丁囡", CHAR_COLORYELLOW); + NewMetamoId=(OldMetamoId/1000)*1000+120+(OldMetamoId%20); + }else if( strstr( itemarg, "熊皮妹" ) && OldMetamoId >= 100120 ){ + CHAR_talkToCli( charaindex, -1, "更改造型为熊皮妹", CHAR_COLORYELLOW); + NewMetamoId=(OldMetamoId/1000)*1000+140+(OldMetamoId%20); + }else if( strstr( itemarg, "帽子妹" ) && OldMetamoId >= 100120 ){ + CHAR_talkToCli( charaindex, -1, "更改造型为帽子妹", CHAR_COLORYELLOW); + NewMetamoId=(OldMetamoId/1000)*1000+160+(OldMetamoId%20); + }else if( strstr( itemarg, "短发夹妹" ) && OldMetamoId >= 100120 ){ + CHAR_talkToCli( charaindex, -1, "更改造型为短发夹妹", CHAR_COLORYELLOW); + NewMetamoId=(OldMetamoId/1000)*1000+180+(OldMetamoId%20); + }else if( strstr( itemarg, "手套女" ) && OldMetamoId >= 100120 ){ + CHAR_talkToCli( charaindex, -1, "更改造型为手套女", CHAR_COLORYELLOW); + NewMetamoId=(OldMetamoId/1000)*1000+200+(OldMetamoId%20); + }else if( strstr( itemarg, "辣妹" ) && OldMetamoId >= 100120 ){ + CHAR_talkToCli( charaindex, -1, "更改造型为辣妹", CHAR_COLORYELLOW); + NewMetamoId=(OldMetamoId/1000)*1000+220+(OldMetamoId%20); + }else if( strstr( itemarg, "随机" ) && OldMetamoId >= 100120 ){ + srand(time(0)); + do + NewMetamoId=(OldMetamoId/1000)*1000+(rand()%6)*20+120+(OldMetamoId%20); + while(NewMetamoId==OldMetamoId); + CHAR_talkToCli( charaindex, -1, "随机更改造型成功", CHAR_COLORYELLOW); + } + }else{ + CHAR_talkToCli( charaindex, -1, "你并不是人物造型!", CHAR_COLORYELLOW); + return; + } + if(NewMetamoId==0){ + CHAR_talkToCli( charaindex, -1, "你的性别不同,无没更改此造型!", CHAR_COLORYELLOW); + return;} + CHAR_setInt( charaindex , CHAR_BASEIMAGENUMBER , NewMetamoId ); + CHAR_setInt( charaindex , CHAR_BASEBASEIMAGENUMBER , NewMetamoId ); + + CHAR_complianceParameter( charaindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + CHAR_DelItem( charaindex, haveitemindex); +} + +void ITEM_SexMetamo( int charaindex, int toindex, int haveitemindex) +{ + int OldMetamoId, NewMetamoId; + OldMetamoId=CHAR_getInt( charaindex, CHAR_BASEBASEIMAGENUMBER); + if(OldMetamoId>=100000 && OldMetamoId <100020){ //豆丁囝 + NewMetamoId=OldMetamoId+120; + CHAR_talkToCli( charaindex, -1, "恭喜你变性成豆丁囡!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100020 && OldMetamoId <100040){ //赛亚人 + NewMetamoId=OldMetamoId+160; + CHAR_talkToCli( charaindex, -1, "恭喜你变性成短发夹妹!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100040 && OldMetamoId <100060){ //辫子男孩 + NewMetamoId=OldMetamoId+120; + CHAR_talkToCli( charaindex, -1, "恭喜你变性成帽子妹!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100060 && OldMetamoId <100080){ //酷哥 + NewMetamoId=OldMetamoId+160; + CHAR_talkToCli( charaindex, -1, "恭喜你变性成辣妹!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100080 && OldMetamoId <100100){ //熊皮男 + NewMetamoId=OldMetamoId+60; + CHAR_talkToCli( charaindex, -1, "恭喜你变性成熊皮妹!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100100 && OldMetamoId <100120){ //大只佬 + NewMetamoId=OldMetamoId+100; + CHAR_talkToCli( charaindex, -1, "恭喜你变性成手套女!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100120 && OldMetamoId <100140){ //豆丁囡 + NewMetamoId=OldMetamoId-120; + CHAR_talkToCli( charaindex, -1, "恭喜你变性成豆丁囝!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100140 && OldMetamoId <100160){ //熊皮妹 + NewMetamoId=OldMetamoId-60; + CHAR_talkToCli( charaindex, -1, "恭喜你变性成熊皮男!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100160 && OldMetamoId <100180){ //帽子妹 + NewMetamoId=OldMetamoId-120; + CHAR_talkToCli( charaindex, -1, "恭喜你变性成辫子男孩!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100180 && OldMetamoId <100200){ //短发夹妹 + NewMetamoId=OldMetamoId-160; + CHAR_talkToCli( charaindex, -1, "恭喜你变性成赛亚人!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100200 && OldMetamoId <100220){ //手套女 + NewMetamoId=OldMetamoId-100; + CHAR_talkToCli( charaindex, -1, "恭喜你变性成大只佬!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100220 && OldMetamoId <100240){ //辣妹 + NewMetamoId=OldMetamoId-160; + CHAR_talkToCli( charaindex, -1, "恭喜你变性成酷哥!", CHAR_COLORYELLOW); + }else{ + CHAR_talkToCli( charaindex, -1, "你并不是人物造型,无法变性!", CHAR_COLORYELLOW); + return;} + if(NewMetamoId==0)return; + CHAR_setInt( charaindex , CHAR_BASEIMAGENUMBER , NewMetamoId ); + CHAR_setInt( charaindex , CHAR_BASEBASEIMAGENUMBER , NewMetamoId ); + + CHAR_complianceParameter( charaindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + CHAR_DelItem( charaindex, haveitemindex); +} +#endif + +#ifdef _GM_ITEM +void ITEM_GMFUNCTION( int charaindex, int toindex, int haveitemindex) +{ + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + char *itemarg; + char gmtime[16]; + char gmfunction[16]; + char token[64]; + itemarg=ITEM_getChar(itemindex,ITEM_ARGUMENT); + if( itemarg == NULL ) return; + memset( gmfunction, 0, sizeof( gmfunction)); + memset( gmtime, 0, sizeof( gmtime)); + getStringFromIndexWithDelim(itemarg,"|", 1, gmfunction, sizeof(gmfunction)); + getStringFromIndexWithDelim(itemarg,"|", 2, gmtime, sizeof(gmtime)); + CHAR_setChar( charaindex , CHAR_GMFUNCTION, gmfunction ); + CHAR_setInt( charaindex , CHAR_GMTIME, atoi(gmtime) ); + sprintf( token, "获得使用%s权限%d!", gmfunction, atoi(gmtime)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + sprintf( token, "相关使用请查看[help %s]无需GM密码!",CHAR_getChar( charaindex, CHAR_GMFUNCTION), gmfunction); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW ); + CHAR_DelItem( charaindex, haveitemindex); +} +#endif + diff --git a/gmsv/item/item_event.c.bak b/gmsv/item/item_event.c.bak new file mode 100644 index 0000000..07057e5 --- /dev/null +++ b/gmsv/item/item_event.c.bak @@ -0,0 +1,4635 @@ +#include "version.h" +#include /* strstr */ +#include /* isdigit, isalnum */ +#include "common.h" +#include "char.h" +#include "char_base.h" +#include "char_data.h" +#include "configfile.h" +#include "item.h" +#include "item_event.h" +#include "object.h" +#include "anim_tbl.h" +#include "magic.h" +#include "handletime.h" +#include "log.h" +#include "util.h" +#include "encount.h" +#include "battle.h" +#include "battle_item.h" +#include "lssproto_serv.h" +#include "net.h" +#include "pet.h" +#include "npcutil.h" +#include "enemy.h" +#ifdef _Item_ReLifeAct +#include "battle_magic.h" +#endif +#ifdef _MARKET_TRADE +#include "item_trade.h" +#endif +#ifdef _ITEM_WARP_FIX_BI +extern tagRidePetTable ridePetTable[146]; +#endif +#include "pet_skill.h" + +#ifdef _DEATH_CONTENDAB +#include "deathcontend.h" +#endif + +#ifdef _CFREE_petskill +#include "npc_freepetskillshop.h" +#endif + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 +#include "profession_skill.h" +#endif + +int ITEM_TimeDelCheck( int itemindex ) +{ int icnt, jcnt, playernum; + playernum = CHAR_getPlayerMaxNum(); + for( icnt = 0; icnt < playernum; icnt ++ ) { + if( CHAR_CHECKINDEX( icnt ) ) { + for( jcnt = 0; jcnt < CHAR_MAXITEMHAVE; jcnt ++ ) { + if( CHAR_getItemIndex( icnt, jcnt ) == itemindex ) { + print( "道具效力时间已到,进行奇怪道具处理(%s)(%s)\n", + CHAR_getUseName(icnt),ITEM_getAppropriateName(itemindex) ); + return FALSE; + } + } + } + } + return TRUE; +} + +int ITEM_eventDrop( int itemindex, int charaindex, int itemcharaindex ) +{ + typedef void (*DROPF)(int,int); + char szBuffer[256]=""; + DROPF dropfunc=NULL; + + if( ITEM_CHECKINDEX(itemindex) == FALSE )return -1; + + dropfunc=(DROPF)ITEM_getFunctionPointer( itemindex, ITEM_DROPFUNC ); + if( dropfunc ){ + dropfunc( charaindex, itemindex ); + } + + if( ITEM_getInt( itemindex, ITEM_VANISHATDROP) != 1 )return 0; + snprintf( szBuffer, sizeof( szBuffer), "%s 消灭了。", + ITEM_getAppropriateName(itemindex) ); + CHAR_talkToCli( charaindex, -1, szBuffer, CHAR_COLORWHITE ); + + { + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), /* 失奶 丞 寞 */ +#endif + "Drop&Delete(丢出後消失)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + CHAR_setItemIndex( charaindex, itemcharaindex, -1); + ITEM_endExistItemsOne( itemindex ); + return 1; +} + +#undef UNDEF +#define UNDEF (-1) + +typedef struct { + char* cmd; /* 摹 侬 */ + char* onmessage; /* 丢永本□斥 侬 */ + char* offmessage; /* 丢永本□斥 侬 */ + int element; /* 覆擂卞卅月邰豳 */ + int maxElement; /* element匹隙烂今木凶邰豳及 袄毛手勾邰豳 */ +} ITEM_EFFECTPARAM; +static ITEM_EFFECTPARAM ITEM_restorableParam[] = { + {"hp", "HP回复了。", "HP降低了。",CHAR_HP, CHAR_WORKMAXHP}, + {"mp", "MP回复了。", "MP降低了。",CHAR_MP, CHAR_WORKMAXMP}, +}; +static ITEM_EFFECTPARAM ITEM_statusParam[] = { + {"po", CHAR_POISONSTRING, CHAR_RECOVERPOISONSTRING, + CHAR_POISON, UNDEF}, + + {"pa", CHAR_PARALYSISSTRING, CHAR_RECOVERPARALYSISSTRING, + CHAR_PARALYSIS, UNDEF}, + + {"si", CHAR_SILENCESTRING, CHAR_RECOVERSILENCESTRING, + CHAR_SLEEP,UNDEF}, + + {"st", CHAR_STONESTRING, CHAR_RECOVERSTONESTRING, CHAR_STONE, UNDEF}, + + {"da", CHAR_DARKNESSSTRING, CHAR_RECOVERDARKNESSSTRING, + CHAR_DRUNK,UNDEF}, + + {"co", CHAR_CONFUSIONSTRING,CHAR_RECOVERCONFUSIONSTRING, + CHAR_CONFUSION, UNDEF}, +}; + +/*#define LOCAL_DEBUG*/ +#ifdef LOCAL_DEBUG +#define DOUTFILE "doutfile" +#include +#include +static int eprintf(char* format, ...){ + va_list arg; + long len; + FILE* fp; + fp = fopen(DOUTFILE, "a"); + va_start(arg, format); + len = vfprintf(stderr, format, arg); + if(fp){ vfprintf(fp, format, arg); fclose(fp); } + va_end(arg); + return len; +} + +#define fprint eprintf +#endif + +static BOOL ITEM_isValidEffect(char* cmd, int value){ + int i; + + for(i=0; istring[ITEM_ARGUMENT].string; + if(* effectarg == '\0') return TRUE; + for(p=effectarg; *p != '\0'; ){ + int i; + if(*p == SEPARATORI) p++; + for(q=cmd, i=0; isalnum(*p) && i 0 ) + onoroff=ITEM_restorableParam[i].onmessage; + else if( amount < 0 ) + onoroff=ITEM_restorableParam[i].offmessage; + else + return FALSE; + strcpysafe( ansmsg, sizeof(ansmsg), onoroff ); + CHAR_talkToCli( charaindex, -1, ansmsg, CHAR_COLORWHITE); + return TRUE; +#else + if(value == ITEM_EFFECT_RESTORE_NORMAL){ + int maxv, curv, amount; + maxv =CHAR_getWorkInt(charaindex, ITEM_restorableParam[i].maxElement); + curv =CHAR_getInt(charaindex, ITEM_restorableParam[i].element); + amount = 30; + if(curv + amount < 0) amount = -curv; + CHAR_setInt(charaindex, ITEM_restorableParam[i].element, min((curv+amount), maxv)); + snprintf( ansmsg, sizeof(ansmsg), "%s回复了。", + ITEM_restorableParam[i].onmessage ); + CHAR_talkToCli( charaindex, -1, ansmsg, CHAR_COLORWHITE); + return TRUE; + }else if(value == ITEM_EFFECT_RESTORE_COMPLETE){ + int maxv; + maxv =CHAR_getWorkInt(charaindex, ITEM_restorableParam[i].maxElement); + CHAR_setInt(charaindex, ITEM_restorableParam[i].element, maxv); + snprintf( ansmsg, sizeof(ansmsg), "%s已完全回复。", ITEM_restorableParam[i].onmessage ); + CHAR_talkToCli( charaindex, -1, ansmsg, CHAR_COLORWHITE ); + return TRUE; + }else + return FALSE; +#endif + + } + } + if( value >= 0 ){ + int found = 0; + for(i=0; i (int)( itemputtime + getItemdeletetime() ) ) { + if( ITEM_TimeDelCheck( itemindex ) == FALSE ){ + return ; + } + { + LogItem( + "NULL", + "NULL", +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), +#endif + "TiemDelete", + OBJECT_getFloor( objindex ), + OBJECT_getX( objindex ), + OBJECT_getY( objindex ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + ITEM_endExistItemsOne(itemindex); + CHAR_ObjectDelete(objindex); + } +} + +void ITEM_useEffectTohelos( int charaindex, int to_charaindex, int haveitemindex) +{ + char buf[64]; + char msgbuf[64]; + int ret; + int itemindex; + int cutrate, limitcount; + int per; + int sendcharaindex = charaindex; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + CHAR_setItemIndex(charaindex, haveitemindex ,-1); + CHAR_sendItemDataOne( charaindex, haveitemindex); + ret = getStringFromIndexWithDelim( ITEM_getChar(itemindex, ITEM_ARGUMENT) , + "|", 1, buf, sizeof( buf)); + if( ret != TRUE ) { + { + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), +#endif + "FieldErrorUse", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + ITEM_endExistItemsOne( itemindex); + return; + } + cutrate = atoi( buf); + if( cutrate < 0 ) cutrate = 0; + ret = getStringFromIndexWithDelim( ITEM_getChar(itemindex, ITEM_ARGUMENT) , + "|", 2, buf, sizeof( buf)); + if( ret != TRUE ) { + { + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), +#endif + "FieldUse", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + ITEM_endExistItemsOne( itemindex); + return; + } + limitcount = atoi( buf); + if( limitcount < 0) limitcount = 0; + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_CLIENT) { + sendcharaindex = CHAR_getWorkInt( charaindex, CHAR_WORKPARTYINDEX1); + } + CHAR_setWorkInt( sendcharaindex, CHAR_WORK_TOHELOS_CUTRATE, cutrate); + CHAR_setWorkInt( sendcharaindex, CHAR_WORK_TOHELOS_COUNT, limitcount); + + snprintf( msgbuf, sizeof(msgbuf), + "抓到了%s 。", ITEM_getChar(itemindex, ITEM_NAME) ); + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORWHITE ); + + if( sendcharaindex != charaindex ) { + snprintf( msgbuf, sizeof(msgbuf), + "%s 抓到了 %s。 ", + CHAR_getChar( charaindex, CHAR_NAME), + ITEM_getChar( itemindex, ITEM_NAME) ); + CHAR_talkToCli( sendcharaindex, -1, msgbuf, CHAR_COLORWHITE ); + } + + { + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), +#endif + "FieldUse", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + ITEM_endExistItemsOne( itemindex); + per = ENCOUNT_getEncountPercentMin( sendcharaindex, + CHAR_getInt( sendcharaindex, CHAR_FLOOR), + CHAR_getInt( sendcharaindex, CHAR_X), + CHAR_getInt( sendcharaindex, CHAR_Y)); + if( per != -1) { + CHAR_setWorkInt( sendcharaindex, CHAR_WORKENCOUNTPROBABILITY_MIN, per); + } + per = ENCOUNT_getEncountPercentMax( sendcharaindex, + CHAR_getInt( sendcharaindex, CHAR_FLOOR), + CHAR_getInt( sendcharaindex, CHAR_X), + CHAR_getInt( sendcharaindex, CHAR_Y)); + if( per != -1) { + CHAR_setWorkInt( sendcharaindex, CHAR_WORKENCOUNTPROBABILITY_MAX, per); + } + CHAR_sendStatusString( sendcharaindex, "E" ); +} + +void ITEM_dropMic( int charaindex , int itemindex ) +{ + if( !ITEM_CHECKINDEX( itemindex )) return; + + CHAR_setWorkInt( charaindex, CHAR_WORKFLG, + CHAR_getWorkInt( charaindex, CHAR_WORKFLG ) & ~WORKFLG_MICMODE ); +} + +void ITEM_useMic_Field( int charaindex, int to_charaindex, int haveitemindex ) +{ + if( CHAR_getWorkInt( charaindex, CHAR_WORKFLG ) & WORKFLG_MICMODE ){ + CHAR_setWorkInt( charaindex, CHAR_WORKFLG, + CHAR_getWorkInt( charaindex, CHAR_WORKFLG ) & ~WORKFLG_MICMODE ); + CHAR_talkToCli( charaindex, -1, "将麦克风设定为OFF。", CHAR_COLORWHITE); + }else{ + CHAR_setWorkInt( charaindex, CHAR_WORKFLG, + CHAR_getWorkInt( charaindex, CHAR_WORKFLG ) | WORKFLG_MICMODE ); + CHAR_talkToCli( charaindex, -1, "将麦克风设定为ON。", CHAR_COLORWHITE); + } +} +#if 1 +char *aszHealStringByOwn[] = { + "%s的耐久力回复%d", + "%s的气力回复%d", + "%s的魅力上升%d", + "%s的忠诚度上升%d", + "" +}; + +char *aszDownStringByOwn[] = { + "%s的耐久力减低%d", + "%s的气力减低%d", + "%s的魅力下降%d", + "%s的忠诚度下降%d", + "" +}; + +char *aszHealStringByOther[] = { + "藉由%s%s的耐久力回复%d", + "藉由%s%s的气力回复%d", + "藉由%s%s的魅力上升%d", + "藉由%s%s的忠诚度上升%d", + "" +}; + +char *aszDownStringByOther[] = { + "藉由%s%s的耐久力减低%d", + "藉由%s%s的气力减低%d", + "藉由%s%s的魅力减低%d", + "藉由%s%s的忠诚度减低%d", + "" +}; + +char *aszKeyString[] = {"体", "气", "魅", "忠", ""}; +int aHealInt[] = { CHAR_HP, CHAR_MP, CHAR_CHARM, CHAR_VARIABLEAI, -1 }; +int aHealMaxWork[] = { CHAR_WORKMAXHP, CHAR_WORKMAXMP, -1, -1, -1 }; + +void ITEM_useRecovery_Field( + int charaindex, + int toindex, + int haveitemindex +){ + int work, workmax, workmin; + int power[BD_KIND_END] = {0,0,0}, + prevhp = 0, + workhp = 0, + recovery[BD_KIND_END] = {0,0,0}; + int itemindex, kind = BD_KIND_HP, HealFlg = 0, j; + char *p = NULL, *arg, msgbuf[256]; + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX(itemindex) ) return; + if( CHAR_CHECKINDEX( toindex ) == FALSE )return ; + arg = ITEM_getChar(itemindex, ITEM_ARGUMENT ); + if( arg == NULL ) return; + +#ifdef _ITEM_UNBECOMEPIG + if( (p = strstr( arg, "解猪" )) != NULL ){ + if( CHAR_getInt( toindex, CHAR_BECOMEPIG ) > -1 ){ + CHAR_setInt( toindex, CHAR_BECOMEPIG, -1 ); + CHAR_complianceParameter( toindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( toindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( toindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + CHAR_talkToCli( toindex,-1,"乌力化失效了。",CHAR_COLORWHITE); + CHAR_DelItemMess( charaindex, haveitemindex, 0); + } + return; + } +#endif +#ifdef _ITEM_LVUPUP + if( (p = strstr( arg, "LVUPUP" ) ) != NULL ){ + if (CHAR_getInt(toindex, CHAR_WHICHTYPE)==CHAR_TYPEPET){ + int pidx=0,lvup=0,lv=0; + sprintf( msgbuf, "%s", p+7 ); + pidx = atoi( strtok( msgbuf, " " ) ); + if( pidx != CHAR_getInt( toindex, CHAR_PETID) || CHAR_getInt(toindex, CHAR_LIMITLEVEL) == 0 ){ + CHAR_talkToCli( charaindex,-1,"无法使用",CHAR_COLORWHITE); + return; + } + lv = CHAR_getInt( toindex, CHAR_LV ); + if( lv < 10 || lv >= 140 ){ + CHAR_talkToCli( charaindex,-1,"目前等级无法使用",CHAR_COLORWHITE); + return; + } + if( (p = strstr( arg, "地" )) != NULL ) + lvup=2; + if( (p = strstr( arg, "水" )) != NULL ) + lvup=3; + if( (p = strstr( arg, "火" )) != NULL ) + lvup=0; + if( (p = strstr( arg, "风" )) != NULL ) + lvup=1; + if( lv%4 != lvup || CHAR_getInt(toindex, CHAR_LIMITLEVEL)-lv >= 1 ){// + CHAR_talkToCli( charaindex,-1,"破除封印失败",CHAR_COLORWHITE); + CHAR_DelItemMess( charaindex, haveitemindex, 0); + return; + } + CHAR_setInt(toindex, CHAR_LIMITLEVEL, CHAR_getInt(toindex, CHAR_LIMITLEVEL)+1); + CHAR_talkToCli( charaindex,-1,"封印魔咒减弱,最高等级提升",CHAR_COLORWHITE); + if( CHAR_getInt(toindex, CHAR_LIMITLEVEL) == 140 ){ + CHAR_setInt(toindex, CHAR_LIMITLEVEL, 0); + CHAR_talkToCli( charaindex,-1,"封印魔咒解除了",CHAR_COLORWHITE); + } + CHAR_DelItemMess( charaindex, haveitemindex, 0); + CHAR_complianceParameter( toindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( toindex , CHAR_WORKOBJINDEX )); + } + return; + } + if( (p = strstr( arg, "UPUPLV" ) ) != NULL ){ + if (CHAR_getInt(toindex, CHAR_WHICHTYPE)==CHAR_TYPEPET){ + int pidx=0,lvup=0,lv=0; + sprintf( msgbuf, "%s", p+7 ); + pidx = atoi( strtok( msgbuf, " " ) ); + if( pidx != CHAR_getInt( toindex, CHAR_PETID) || CHAR_getInt(toindex, CHAR_LIMITLEVEL) == 0 ){ + CHAR_talkToCli( charaindex,-1,"无法使用",CHAR_COLORWHITE); + return; + } + lv = CHAR_getInt( toindex, CHAR_LV ); + if( lv < 125 || lv > 140 ){ + CHAR_talkToCli( charaindex,-1,"目前等级无法使用",CHAR_COLORWHITE); + return; + } + CHAR_setInt(toindex, CHAR_LIMITLEVEL, 0); + CHAR_talkToCli( charaindex,-1,"封印魔咒解除了",CHAR_COLORWHITE); + CHAR_DelItemMess( charaindex, haveitemindex, 0); + CHAR_complianceParameter( toindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( toindex , CHAR_WORKOBJINDEX )); + } + return; + } +#endif +#ifdef _ITEM_PROPERTY + if( (p = strstr( arg, "PROPERTY" ) ) != NULL ){ + //print("地水火风:%s", arg ); + if (CHAR_getInt(toindex, CHAR_WHICHTYPE)!=CHAR_TYPEPLAYER) + return; + if( (p = strstr( arg, "+" ) ) != NULL ){//旋转属性 正转 + if( CHAR_getInt( toindex, CHAR_EARTHAT ) == 100 ) + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )-10 ), + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_WATERAT ) == 100 ) + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )-10 ), + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_FIREAT ) == 100 ) + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )-10 ), + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_WINDAT ) == 100 ) + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )-10 ), + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_EARTHAT ) > 0 && CHAR_getInt( toindex, CHAR_WATERAT ) > 0 ) + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )-10 ), + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_WATERAT ) > 0 && CHAR_getInt( toindex, CHAR_FIREAT ) > 0 ) + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )-10 ), + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_FIREAT ) > 0 && CHAR_getInt( toindex, CHAR_WINDAT ) > 0 ) + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )-10 ), + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_WINDAT ) > 0 && CHAR_getInt( toindex, CHAR_EARTHAT ) > 0 ) + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )-10 ), + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )+10 ); + } + if( (p = strstr( arg, "-" ) ) != NULL ){//旋转属性 反转 + if( CHAR_getInt( toindex, CHAR_EARTHAT ) == 100 ) + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )-10 ), + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_WATERAT ) == 100 ) + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )-10 ), + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_FIREAT ) == 100 ) + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )-10 ), + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_WINDAT ) == 100 ) + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )-10 ), + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )+10 ); + else if( CHAR_getInt( toindex, CHAR_EARTHAT ) > 0 && CHAR_getInt( toindex, CHAR_WATERAT ) > 0 ) + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )+10 ), + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )-10 ); + else if( CHAR_getInt( toindex, CHAR_WATERAT ) > 0 && CHAR_getInt( toindex, CHAR_FIREAT ) > 0 ) + CHAR_setInt( toindex, CHAR_WATERAT, CHAR_getInt( toindex, CHAR_WATERAT )+10 ), + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )-10 ); + else if( CHAR_getInt( toindex, CHAR_FIREAT ) > 0 && CHAR_getInt( toindex, CHAR_WINDAT ) > 0 ) + CHAR_setInt( toindex, CHAR_FIREAT, CHAR_getInt( toindex, CHAR_FIREAT )+10 ), + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )-10 ); + else if( CHAR_getInt( toindex, CHAR_WINDAT ) > 0 && CHAR_getInt( toindex, CHAR_EARTHAT ) > 0 ) + CHAR_setInt( toindex, CHAR_WINDAT, CHAR_getInt( toindex, CHAR_WINDAT )+10 ), + CHAR_setInt( toindex, CHAR_EARTHAT, CHAR_getInt( toindex, CHAR_EARTHAT )-10 ); + } + CHAR_DelItemMess( charaindex, haveitemindex, 0); + CHAR_complianceParameter( toindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( toindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( toindex , + CHAR_P_STRING_EARTH | + CHAR_P_STRING_WATER | + CHAR_P_STRING_FIRE | + CHAR_P_STRING_WIND + ); + return; + } +#endif +#ifdef _ITEM_ADDPETEXP + if( (p = strstr( arg, "GETEXP" )) != NULL ){ + if (CHAR_getInt(toindex, CHAR_WHICHTYPE)==CHAR_TYPEPET){ + getStringFromIndexWithDelim( arg, "|", 2, msgbuf,sizeof( msgbuf));//宠物编号 + if( atoi(msgbuf) == CHAR_getInt( toindex, CHAR_PETID) ){ + getStringFromIndexWithDelim( arg, "|", 3, msgbuf,sizeof( msgbuf));//等级上限(等级超过才可用) + if( CHAR_getInt( toindex, CHAR_LV ) >= atoi(msgbuf) ){ + getStringFromIndexWithDelim( arg, "|", 4, msgbuf,sizeof( msgbuf));//经验值增加 + if( CHAR_getInt( toindex, CHAR_LV) < CHAR_MAXUPLEVEL ){ + int UpLevel = 0; + CHAR_setWorkInt( toindex, CHAR_WORKGETEXP, atoi(msgbuf) );//回存CHAR_WORKGETEXP + CHAR_AddMaxExp( toindex, CHAR_getWorkInt( toindex, CHAR_WORKGETEXP ) ); + sprintf( msgbuf,"这石头里面不知道有什麽样的矿,让我看看。(增加经验%d)", CHAR_getWorkInt( toindex, CHAR_WORKGETEXP ) ); + CHAR_talkToCli( charaindex,-1,msgbuf,CHAR_COLORWHITE); + UpLevel = CHAR_LevelUpCheck( toindex , charaindex); + if( UpLevel > 0 ){ + if( getBattleDebugMsg( ) != 0 ){ + snprintf( msgbuf, sizeof(msgbuf), + "(%s) 升级至 %d", + CHAR_getUseName( toindex ), + CHAR_getInt( toindex, CHAR_LV ) ); + BATTLE_talkToCli( charaindex, msgbuf, CHAR_COLORYELLOW ); + } + } + for( j = 0; j < UpLevel; j ++ ){ + CHAR_PetLevelUp( toindex ); + CHAR_PetAddVariableAi( toindex, AI_FIX_PETLEVELUP ); + } + CHAR_complianceParameter( toindex ); + } + else{ + CHAR_talkToCli( charaindex,-1,"不能使用",CHAR_COLORWHITE); + } + /*CHAR_send_P_StatusString( charindex, CHAR_P_STRING_DUELPOINT| + CHAR_P_STRING_TRANSMIGRATION| CHAR_P_STRING_RIDEPET| + CHAR_P_STRING_BASEBASEIMAGENUMBER| CHAR_P_STRING_GOLD| + CHAR_P_STRING_EXP| CHAR_P_STRING_LV| CHAR_P_STRING_HP|CHAR_P_STRING_LEARNRIDE); + */ + } + else + CHAR_talkToCli( charaindex,-1,"这石头....(无法判别,无法增加经验)",CHAR_COLORWHITE); + } + CHAR_DelItemMess( charaindex, haveitemindex, 0); + CHAR_complianceParameter( toindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( toindex , CHAR_WORKOBJINDEX )); + return; + } + else{ + CHAR_talkToCli( charaindex,-1,"不能使用",CHAR_COLORWHITE); + } + } +#endif + for( j = 0; j < BD_KIND_END; j ++ ){ + power[j] = 0; + recovery[j] = 0; + } + if( (p = strstr( arg, "全" )) != NULL ){ + HealFlg = ( 1 << BD_KIND_HP ); + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPET ){ + }else{ + HealFlg |= ( 1 << BD_KIND_MP ); + } + power[BD_KIND_HP] = 10000000; + power[BD_KIND_MP] = 100; + } + kind = BD_KIND_HP; + if( (p = strstr( arg, aszKeyString[kind] )) != NULL ){ + HealFlg |= ( 1 << kind ); + if( sscanf( p+2, "%d", &work ) != 1 ){ + power[kind] = 1; + }else{ + power[kind] = RAND( (work*0.9), (work*1.1) ); + } +#ifndef _MAGIC_REHPAI + power[kind] *= GetRecoveryRate( toindex ); +#endif + } + kind = BD_KIND_MP; + if( (p = strstr( arg, aszKeyString[kind] )) != NULL + && CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER){ + HealFlg |= ( 1 << kind ); + if( sscanf( p+2, "%d", &work ) != 1 ){ + power[kind] = 1; + }else{ + power[kind] = RAND( (work*0.9), (work*1.1) ); + } + } + kind = BD_KIND_AI; + if( (p = strstr( arg, aszKeyString[kind] )) != NULL + && CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPET){ + HealFlg |= ( 1 << kind ); + if( sscanf( p+2, "%d", &work ) != 1 ){ + power[kind] = 1; + }else{ + power[kind] = RAND( (work*0.9), (work*1.1) ); + } + power[kind] *= 100; + } + kind = BD_KIND_CHARM; + if( (p = strstr( arg, aszKeyString[kind] )) != NULL + && CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ){ + HealFlg |= ( 1 << kind ); + if( sscanf( p+2, "%d", &work ) != 1 ){ + power[kind] = 1; + }else{ + power[kind] = RAND( (work*0.9), (work*1.1) ); + } + } + if( HealFlg == 0 )return; +#ifdef _TYPE_TOXICATION + if( CHAR_CanCureFlg( toindex, "HP") == FALSE )return; +#endif + + for( j = 0; j < BD_KIND_END; j ++ ){ + if( ( HealFlg & ( 1 << j ) ) == 0 )continue; + prevhp = CHAR_getInt( toindex, aHealInt[j] ); + workhp = prevhp + (int)power[j]; + + if( j == BD_KIND_CHARM ){ + workmax = 100; + workmin = 0; + }else + if( j == BD_KIND_AI ){ + workmax = 10000; + workmin = -10000; + }else{ + workmax = CHAR_getWorkInt( toindex, aHealMaxWork[j] ); + workmin = 1; + } + workhp = min( workhp, workmax ); + workhp = max( workhp, workmin ); + CHAR_setInt( toindex, aHealInt[j], workhp ); + recovery[j] = workhp - prevhp; + if( j == BD_KIND_AI ){ + recovery[j] *= 0.01; + } + } + CHAR_complianceParameter( toindex ); + + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + if( charaindex != toindex ) { + CHAR_send_P_StatusString( toindex, CHAR_P_STRING_HP|CHAR_P_STRING_MP|CHAR_P_STRING_CHARM); + } + } + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_HP|CHAR_P_STRING_MP|CHAR_P_STRING_CHARM); + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER && + CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE ){ + CHAR_PartyUpdate( toindex, CHAR_N_STRING_HP|CHAR_N_STRING_MP ); + } + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPET ){ + int i; + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + int workindex = CHAR_getCharPet( charaindex, i ); + if( workindex == toindex ){ + CHAR_send_K_StatusString( charaindex, i, CHAR_K_STRING_HP|CHAR_K_STRING_AI); + } + } + } + + + for( j = 0; j < BD_KIND_END; j ++ ){ + if( ( HealFlg & ( 1 << j ) ) == 0 )continue; + if( charaindex != toindex) { + if( power[j] >= 0 ){ + snprintf( msgbuf, sizeof( msgbuf), + aszHealStringByOwn[j], + CHAR_getUseName( toindex ), recovery[j] ); + }else{ + snprintf( msgbuf, sizeof( msgbuf), + aszDownStringByOwn[j], + CHAR_getUseName( toindex ), -recovery[j] ); + } + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORWHITE); + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + if( power[j] >= 0 ){ + snprintf( msgbuf, sizeof( msgbuf), + aszHealStringByOther[j], + CHAR_getUseName( charaindex ), + CHAR_getUseName( toindex ), recovery[j] ); + }else{ + snprintf( msgbuf, sizeof( msgbuf), + aszDownStringByOther[j], + CHAR_getUseName( charaindex ), + CHAR_getUseName( toindex ), -recovery[j] ); + } + CHAR_talkToCli( toindex, -1, msgbuf, CHAR_COLORWHITE); + } + }else { + if( power[j] >= 0 ){ + snprintf( msgbuf, sizeof( msgbuf), + aszHealStringByOwn[j], + CHAR_getUseName( charaindex ), recovery[j] ); + }else{ + snprintf( msgbuf, sizeof( msgbuf), + aszDownStringByOwn[j], + CHAR_getUseName( charaindex ), -recovery[j] ); + } + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORWHITE); + } + } + { + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), +#endif + "FieldUse", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + CHAR_DelItemMess( charaindex, haveitemindex, 0); + +} + +#endif + +void ITEM_useRecovery( int charaindex, int toindex, int haveitemindex) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return ; + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + }else + if( battlemode ){ + ITEM_useRecovery_Battle( charaindex, toindex, haveitemindex ); + }else{ + ITEM_useRecovery_Field( charaindex, toindex, haveitemindex ); + } + +} + +#ifdef _ITEM_MAGICRECOVERY +void ITEM_useMRecovery( int charaindex, int toindex, int haveitemindex) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return ; + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + }else + if( battlemode ){ + ITEM_useMRecovery_Battle( charaindex, toindex, haveitemindex ); + }else{ +// ITEM_useRecovery_Field( charaindex, toindex, haveitemindex ); + } + +} + +#endif + +#ifdef _ITEM_USEMAGIC +void ITEM_useMagic( int charaindex, int toindex, int haveitemindex) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return ; + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + }else + if( battlemode ){ + ITEM_useMagic_Battle( charaindex, toindex, haveitemindex ); + } +} +#endif + +#ifdef _PET_LIMITLEVEL +void ITEM_useOtherEditBase( int charaindex, int toindex, int haveitemindex) +{ + int itemindex,i; + int work[4]; + int num=-1,type; + int LevelUpPoint,petrank; + char buf1[256]; + char buf2[][32]={"腕力成长率","耐久力成长率","速度成长率","体力成长率","能力"}; + char buf3[][32]={"大幅提高","略为提高","略为减少"}; + if( !CHAR_CHECKINDEX( charaindex ) ) return; + if( !CHAR_CHECKINDEX( toindex ) ) return; +#define RAND(x,y) ((x-1)+1+ (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) ) + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX(itemindex) ) return; + if( CHAR_getInt( toindex, CHAR_PETID) == 718 +#ifdef _PET_2LIMITLEVEL + || CHAR_getInt( toindex, CHAR_PETID) == 401 +#endif + ) { + + int maxnums=50; + + if( CHAR_getInt( toindex,CHAR_LV ) < 74 ) { + sprintf(buf1,"给我的吗?好美丽的项 喔!〈能力起了变化〉"); + CHAR_talkToCli( charaindex, toindex, buf1, CHAR_COLORWHITE); + num = ITEM_MODIFYATTACK; + LevelUpPoint = CHAR_getInt( toindex, CHAR_ALLOCPOINT ); + petrank = CHAR_getInt( toindex, CHAR_PETRANK ); + work[3] =(( LevelUpPoint >> 24 ) & 0xFF); + work[0] = (( LevelUpPoint >> 16 ) & 0xFF); + work[1] = (( LevelUpPoint >> 8 ) & 0xFF); + work[2] = (( LevelUpPoint >> 0 ) & 0xFF); + for( i=0; i<4; i++) { + type = ITEM_getInt( itemindex, (num + i)); + work[i] += type; + strcpy( buf1,"\0"); + if( work[i] > maxnums ) { + sprintf(buf1,"%s 已经达到最高了。", buf2[i]); + work[i] = maxnums; + }else if( work[i] < 0 ) { + sprintf(buf1,"%s 已经为零了。", buf2[i]); + work[i] = 0; + }else { + if( type > 0 ) { + if( type > 2 ) + sprintf(buf1,"%s %s %s", buf2[i], buf3[0], "。"); + else + sprintf(buf1,"%s %s %s", buf2[i], buf3[1], "。"); + }else if( type < 0 ){ + sprintf(buf1,"%s %s %s", buf2[i], buf3[2], "。"); + } + } + if( strcmp( buf1, "\0")) { + CHAR_talkToCli( charaindex, toindex, buf1, CHAR_COLORWHITE); + } + } + + LevelUpPoint = ( work[3]<< 24) + ( work[0]<< 16) + ( work[1]<< 8) + ( work[2]<< 0); + CHAR_setInt( toindex, CHAR_ALLOCPOINT, LevelUpPoint); + CHAR_setInt( toindex, CHAR_PETRANK, petrank); + LogPetPointChange( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), + CHAR_getChar( charaindex, CHAR_NAME), + toindex, 4, + CHAR_getInt( toindex, CHAR_LV), + "item_use", + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X ), + CHAR_getInt( charaindex, CHAR_Y ) + ); + } + + }else { + sprintf(buf1,"???"); + } + CHAR_DelItem( charaindex, haveitemindex); + return; +} +#endif + +void ITEM_useStatusChange( int charaindex, int toindex, int haveitemindex) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return ; //{撩 + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + }else + if( battlemode ){ + ITEM_useStatusChange_Battle( charaindex, toindex, haveitemindex ); + }else{ + } + +} + +void ITEM_useStatusRecovery( int charaindex, int toindex, int haveitemindex) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return ; //{撩 + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + }else + if( battlemode ){ + ITEM_useStatusRecovery_Battle( charaindex, toindex, haveitemindex ); + }else{ + } +} + +void ITEM_useMagicDef( int charaindex, int toindex, int haveitemindex) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return; + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + }else + if( battlemode ){ + ITEM_useMagicDef_Battle( charaindex, toindex, haveitemindex ); + }else{ + } + +} + +void ITEM_useParamChange( int charaindex, int toindex, int haveitemindex) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return ; + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + }else + if( battlemode ){ + ITEM_useParamChange_Battle( charaindex, toindex, haveitemindex ); + } +} + +void ITEM_useFieldChange( int charaindex, int toindex, int haveitemindex) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return ; + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + }else + if( battlemode ){ + ITEM_useFieldChange_Battle( charaindex, toindex, haveitemindex ); + } +} + +void ITEM_useAttReverse( int charaindex, int toindex, int haveitemindex) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return; + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + }else + if( battlemode ){ + ITEM_useAttReverse_Battle( charaindex, toindex, haveitemindex ); + }else{ + } +} + +void ITEM_useMic( int charaindex, int toindex, int haveitemindex) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return; + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + }else + if( battlemode ){ + }else{ + ITEM_useMic_Field( charaindex, toindex, haveitemindex ); + } + +} + +void ITEM_useCaptureUp( int charaindex, int toindex, int haveitemindex) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return ; //{撩 + + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + }else + if( battlemode ){ + ITEM_useCaptureUp_Battle( charaindex, toindex, haveitemindex ); + }else{ + } + +} + +#ifdef _PETSKILL_CANNEDFOOD +static void ITEM_usePetSkillCanned_PrintWindow( int charaindex, int flg) +{ + int fd; + char message[256], buf[2048]; + if( !CHAR_CHECKINDEX( charaindex )) return; + fd = getfdFromCharaIndex( charaindex); + if( fd == - 1 ) return; + + memset( message, 0, sizeof(message)); + sprintf( message, "%d", flg); + lssproto_WN_send( fd, WINDOWS_MESSAGETYPE_PETSKILLSHOW, + WINDOW_BUTTONTYPE_NONE, + ITEM_WINDOWTYPE_SELECTPETSKILL_SELECT, + -1, + makeEscapeString( message, buf, sizeof( buf))); +} + +void ITEM_usePetSkillCanned_WindowResult( int charaindex, int seqno, int select, char * data) +{ + int itemindex=-1, itemNo, petindex=-1, petNo; + int SkillNo, SkillID; + char buf1[256]; + char *skillarg=NULL; + + petNo = CHAR_getWorkInt( charaindex, CHAR_WORKRENAMEITEMNUM); + itemNo = CHAR_getWorkInt( charaindex, CHAR_WORKRENAMEITEMINDEX); + + + itemindex = CHAR_getItemIndex( charaindex, itemNo); + if( !ITEM_CHECKINDEX( itemindex) ) return; + petindex = CHAR_getCharPet( charaindex, petNo); + if( !CHAR_CHECKINDEX(petindex) ) return; + SkillNo = atoi( data); + if( SkillNo < 0 || SkillNo >= CHAR_MAXPETSKILLHAVE ) return; + + skillarg = ITEM_getChar( itemindex, ITEM_ARGUMENT); + SkillID = atoi( skillarg); + +#ifdef _CFREE_petskill + if( NPC_CHECKFREEPETSKILL( charaindex, petindex, SkillID) == FALSE ){ + CHAR_talkToCli( charaindex, -1, "该宠物无法学习此项技能!", CHAR_COLORYELLOW); + return; + } +#endif + + CHAR_setPetSkill( petindex, SkillNo, SkillID); + memset( buf1, 0, sizeof(buf1)); + snprintf( buf1, sizeof( buf1 ), "W%d", petNo); + CHAR_sendStatusString( charaindex, buf1 ); + CHAR_sendStatusString( charaindex, "P"); + { + int skillarray = PETSKILL_getPetskillArray( SkillID); + sprintf( buf1, "宠物%s学习%s,道具 %s消失了。", + CHAR_getUseName( petindex), PETSKILL_getChar( skillarray, PETSKILL_NAME), + ITEM_getChar( itemindex, ITEM_NAME) ); + } + + CHAR_talkToCli( charaindex, -1, buf1, CHAR_COLORYELLOW); + CHAR_setItemIndex( charaindex, itemNo ,-1); + CHAR_sendItemDataOne( charaindex, itemNo); + ITEM_endExistItemsOne( itemindex); +} + +#endif + +static void ITEM_useRenameItem_PrintWindow( int charaindex, int page) +{ + int fd; + int pos = 0; + int i; + int btntype = WINDOW_BUTTONTYPE_CANCEL; + char message[1024]; + char msgwk[1024]; + char buf[2048]; + + if( !CHAR_CHECKINDEX( charaindex )) return; + if( page < 0 || page > 3 ) { + print( "%s:%d err\n", __FILE__, __LINE__); + return; + } + fd = getfdFromCharaIndex( charaindex); + if( fd == - 1 ) return; + + snprintf( message, sizeof( message), + "2\n 要变更那个项目的名称呢\n" + " Page:%d\n", page +1); + + for( i = page *5; i < page *5 +5; i ++ ) { + int itemindex = CHAR_getItemIndex( charaindex, i); + BOOL flg = FALSE; + while( 1 ) { + char *cdkey; + if( !ITEM_CHECKINDEX( itemindex)) break; + cdkey = ITEM_getChar( itemindex, ITEM_CDKEY); + if( !cdkey) { + print( "%s:%d err\n", __FILE__, __LINE__); + break; + } + if( ITEM_getInt( itemindex, ITEM_MERGEFLG) != 1) break; + if( ITEM_getInt( itemindex, ITEM_TYPE) == ITEM_DISH) break; + if( ITEM_getInt( itemindex, ITEM_CRUSHLEVEL) != 0 ) break; + if( strlen( cdkey) != 0 ) { + if( strcmp( cdkey, CHAR_getChar( charaindex, CHAR_CDKEY)) != 0 ) { + break; + } + } + flg = TRUE; + break; + } + if( flg ) { + char *nm = ITEM_getChar( itemindex, ITEM_SECRETNAME); + char wk[256]; + if( pos +strlen( nm) +1 > sizeof( msgwk)) { + print( "buffer over error %s:%d\n", __FILE__, __LINE__); + break; + } + snprintf( wk, sizeof( wk), "%s\n", nm); + strncpy( &msgwk[pos], wk, sizeof( msgwk) -pos -1); + pos += strlen( wk); + } + else { + if( pos +2 > sizeof( msgwk)) { + print( "buffer over error %s:%d\n", __FILE__, __LINE__); + break; + } + strncpy( &msgwk[pos], "\n", sizeof( msgwk) -pos -1 ); + pos += 1; + } + } + strcat( message, msgwk); + switch( page){ + case 0: + btntype |= WINDOW_BUTTONTYPE_NEXT; + break; + case 3: + btntype |= WINDOW_BUTTONTYPE_PREV; + break; + case 1: + case 2: + btntype |= WINDOW_BUTTONTYPE_PREV|WINDOW_BUTTONTYPE_NEXT; + break; + } + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + btntype, + CHAR_WINDOWTYPE_SELECTRENAMEITEM_PAGE1+page, + -1, + makeEscapeString( message, buf, sizeof(buf))); +} + +void ITEM_useRenameItem( int charaindex, int toindex, int haveitemindex) +{ + + ITEM_useRenameItem_PrintWindow( charaindex, 0); + + CHAR_setWorkInt( charaindex, CHAR_WORKRENAMEITEMNUM, -1); + CHAR_setWorkInt( charaindex, CHAR_WORKRENAMEITEMINDEX, haveitemindex); +/* + char buf[256]; + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX( itemindex) ) return; + sprintf( buf, "%s功能已被取消。", ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, "功能已被取消。", CHAR_COLORRED ); + + { + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), + itemindex, + "魔术笔DEL", + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X ), + CHAR_getInt( charaindex, CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + + CHAR_setItemIndex( charaindex, haveitemindex, -1); + CHAR_sendItemDataOne( charaindex, haveitemindex); + ITEM_endExistItemsOne( itemindex ); +*/ +} + +void ITEM_useRenameItem_WindowResult( int charaindex, int seqno, int select, char * data) +{ + int page = 0; + int fd; + if( select == WINDOW_BUTTONTYPE_CANCEL) return; + + fd = getfdFromCharaIndex( charaindex); + if( fd == - 1 ) return; + if( seqno != CHAR_WINDOWTYPE_SELECTRENAMEITEM_RENAME ) { + if( select == WINDOW_BUTTONTYPE_NEXT ) page = 1; + else if( select == WINDOW_BUTTONTYPE_PREV ) page = -1; + if( select == WINDOW_BUTTONTYPE_NEXT || select == WINDOW_BUTTONTYPE_PREV ) { + int winno = seqno - CHAR_WINDOWTYPE_SELECTRENAMEITEM_PAGE1; + winno += page; + if( winno < 0 ) winno = 0; + if( winno > 3 ) winno = 3; + ITEM_useRenameItem_PrintWindow( charaindex, winno); + }else { + char message[1024]; + char buf[2048]; + char haveitemindex = CHAR_getWorkInt( charaindex, CHAR_WORKRENAMEITEMNUM); + int itemindex; + if( haveitemindex == -1 ) { + haveitemindex = (seqno - CHAR_WINDOWTYPE_SELECTRENAMEITEM_PAGE1) * 5 + + ( atoi(data)-1); + CHAR_setWorkInt( charaindex, CHAR_WORKRENAMEITEMNUM, haveitemindex); + } + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + + snprintf( message, sizeof( message), + "%s 名字要更改\n" + "请输入姓名\n" + "全形13个字, 半形26个字", + ITEM_getChar( itemindex, ITEM_NAME)); + + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT, + WINDOW_BUTTONTYPE_OKCANCEL, + CHAR_WINDOWTYPE_SELECTRENAMEITEM_RENAME, + -1, + makeEscapeString( message, buf, sizeof(buf))); + + } + } + else { + BOOL flg = FALSE; + char message[1024]; + char buf[2048]; + while( 1 ) { + char *p; + if( strlen( data) > 26 || strlen( data) < 1) { + if( strlen( data) > 26 ) { + strcpy( message, "超过文字限制"); + }else { + strcpy( message, "请输入一个文字以上"); + } + break; + } + + // WON ADD 修正魔术笔改名问题 + flg = TRUE; + + for( p = data; *p ; p ++) { + if( *p == ' '){ + strcpy( message, "不可空白"); + flg = FALSE; + break; + } + if( strncmp( p, " ",2) == 0 ) { + strcpy( message, "不可空白"); + flg = FALSE; + break; + } + if( *p == '|'){ + strcpy( message, "不可有特殊符号"); + flg = FALSE; + break; + } + } + + break; + } + + + if( !flg ) { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_SELECTRENAMEITEM_RENAME_ATTENTION, + -1, + makeEscapeString( message, buf, sizeof(buf))); + } + else { + char haveitemindex = CHAR_getWorkInt( charaindex, CHAR_WORKRENAMEITEMNUM); + int itemindex; + int renameitemindex; + int renameitemhaveindex; + int remain; + char msgbuf[128]; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX( itemindex)) { + print( "%s %d err\n", __FILE__, __LINE__); + return; + } + ITEM_setChar( itemindex, ITEM_SECRETNAME, data); + ITEM_setChar( itemindex, ITEM_CDKEY, + CHAR_getChar( charaindex, CHAR_CDKEY)); + CHAR_sendItemDataOne( charaindex, haveitemindex); + snprintf( msgbuf, sizeof(msgbuf),"把 %s 命名成 %s ", + ITEM_getChar( itemindex, ITEM_NAME), data); + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORYELLOW); + renameitemhaveindex = CHAR_getWorkInt( charaindex, CHAR_WORKRENAMEITEMINDEX); + renameitemindex = CHAR_getItemIndex( charaindex, renameitemhaveindex); + if( !ITEM_CHECKINDEX( renameitemindex)) { + print( "%s %d err\n", __FILE__, __LINE__); + return; + } + remain = atoi( ITEM_getChar( renameitemindex, ITEM_ARGUMENT)); + if( remain != 0 ) { + remain --; + if( remain <= 0 ) { + snprintf( msgbuf, sizeof(msgbuf),"%s 消失了", + ITEM_getChar( renameitemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORYELLOW); + CHAR_setItemIndex( charaindex, renameitemhaveindex, -1); + CHAR_sendItemDataOne( charaindex, renameitemhaveindex); + ITEM_endExistItemsOne( renameitemindex ); + }else { + char buf[32]; + snprintf( buf, sizeof( buf),"%d", remain); + ITEM_setChar( renameitemindex, ITEM_ARGUMENT, buf); + } + } + } + } +} + +//------------------------------------------------------------------------- +// 今中仇欠毛 蜇允月楮醒[ +// 午仄凶凛卞]仿件母丞卞ㄠ ㄥ毛蓟太] 蟆午 飓 寞毛 凳允月[ +//------------------------------------------------------------------------- +void ITEM_dropDice( int charaindex, int itemindex) +{ + char *dicename[] = { "一", "二", "叁", "四", "五", "六"}; + int diceimagenumber[] = { 24298,24299,24300,24301,24302,24303}; + int r = RAND( 0,5); + + // 飓 寞毛谨 + ITEM_setInt( itemindex, ITEM_VAR1, ITEM_getInt( itemindex, ITEM_BASEIMAGENUMBER)); + // 飓 寞凳蕙 + ITEM_setInt( itemindex, ITEM_BASEIMAGENUMBER, diceimagenumber[r]); + // 蟆凳蕙 + ITEM_setChar( itemindex, ITEM_SECRETNAME, dicename[r]); + + // 犯□正及弁仿奶失件玄尺及霜耨反晓匏楮醒匹垫丹及匹]仇仇匹反支日卅中[ +} +//------------------------------------------------------------------------- +// 今中仇欠毛 蜇允月楮醒[ +// 胶匀凶凛卞] 蟆午 飓 寞毛葭卞 允[ +//------------------------------------------------------------------------- +void ITEM_pickupDice( int charaindex, int itemindex) +{ + // 飓 寞毛葭卞 允[ + ITEM_setInt( itemindex, ITEM_BASEIMAGENUMBER, ITEM_getInt( itemindex, ITEM_VAR1)); + // 蟆手葭卞 允 + ITEM_setChar( itemindex, ITEM_SECRETNAME, ITEM_getChar( itemindex, ITEM_NAME)); +} +enum { + ITEM_LOTTERY_1ST, // 1羁 + ITEM_LOTTERY_2ND, + ITEM_LOTTERY_3RD, + ITEM_LOTTERY_4TH, + ITEM_LOTTERY_5TH, // 5羁 + ITEM_LOTTERY_6TH, // 6羁 + ITEM_LOTTERY_NONE, // 陆木 + ITEM_LOTTERY_NUM, +}; +//------------------------------------------------------------------------- +// 旦疋□玉仁元互综日木月凛及楮醒[ +// 仇仇匹窒羁操卞卅月井毛瑁户月[ +// 割 反动票及骚曰[ + +#define PRE_6 (10000) +#define PRE_5 (1300 + PRE_6) +#define PRE_4 (600 + PRE_5) +#define PRE_3 (300 + PRE_4) +#define PRE_2 (8 + PRE_3) +#define PRE_1 (1 + PRE_2) + + +//#define PRE_5 (13000) +//#define PRE_4 (2300 + PRE_5) +//#define PRE_3 (540 + PRE_4) +//#define PRE_2 (8 + PRE_3) +//#define PRE_1 (1 + PRE_2) + + +//#define PRE_5 (16000) +//#define PRE_4 (2500 + PRE_5) +//#define PRE_3 (400 + PRE_4) +//#define PRE_2 (10 + PRE_3) +//#define PRE_1 (1 + PRE_2) +//#define PRE_5 (27000) +//#define PRE_4 (4000 + PRE_5) +//#define PRE_3 (400 + PRE_4) +//#define PRE_2 (10 + PRE_3) +//#define PRE_1 (1 + PRE_2) +// +//------------------------------------------------------------------------- +BOOL ITEM_initLottery(ITEM_Item* itm) +{ + int r = RAND( 0, 49999); + int hit = ITEM_LOTTERY_NONE; // + char result[7]; // 请 + int countnum[6]; + int count; + int i; + int len; + // 域荚综匀化月及匹[疯粟 仄凶凛午井卞综曰卅云今木卅中方丹卞[ + if( itm->data[ITEM_VAR3] == 1 ) return TRUE; + + // 铲蓟允月[ + if( r < PRE_6 ) hit = ITEM_LOTTERY_6TH; + else if( r < PRE_5 ) hit = ITEM_LOTTERY_5TH; + else if( r < PRE_4 ) hit = ITEM_LOTTERY_4TH; + else if( r < PRE_3 ) hit = ITEM_LOTTERY_3RD; + else if( r < PRE_2 ) hit = ITEM_LOTTERY_2ND; + else if( r < PRE_1 ) hit = ITEM_LOTTERY_1ST; + else hit = ITEM_LOTTERY_NONE; + + // 请 毛瑁烂允月[ + count = 0; + memset( countnum, 0, sizeof( countnum)); + if( hit != ITEM_LOTTERY_NONE ) { + // 癫曰毛本永玄 + result[0] = result[1] = result[2] = hit+1; + count = 3; + countnum[hit] = 3; + } + while( count < 6 ) { + int r = RAND( ITEM_LOTTERY_1ST, ITEM_LOTTERY_6TH); + if( countnum[r] >= 2 ) continue; + // 2/3仁日中及割 匹]职及陆木钓 毛伉□民今六化支月[ + // 升五升五[ + if( ( hit != ITEM_LOTTERY_NONE && count == 3 ) + || ( hit == ITEM_LOTTERY_NONE && count == 0 ) ) + { + if( RAND( 0,2)) { + result[count] = result[count+1] = r+1; + countnum[r] += 2; + count += 2; + continue; + } + } + countnum[r] ++; + result[count] = r+1; + count++; + } + // 请 毛扑乓永白伙允月[ + // 癫曰及凛反2/3及割 匹]癫曰醒侬毛域 欠卞裔烂允月[ + // 玉平玉平躲绊毛谎丹啃[ + len = sizeof( result)-2; + if( hit != ITEM_LOTTERY_NONE ) { + if( RAND( 0,2) ) { + // 癫曰醒侬毛域 欠卞[ + char s = result[0]; + result[0] = result[5]; + result[5] = s; + len = sizeof( result)-3; + } + } + for( i = 0; i < 10; i ++) { + int x = RAND( 0, len); + int y = RAND( 0, len); + int s; + s = result[x]; + result[x] = result[y]; + result[y] = s; + } + // 及凶户] 侬 健中卞仄化云仁[ + result[sizeof(result)-1] = '\0'; + itm->data[ITEM_VAR1] = hit; + // 户仁匀凶市它件玄 + itm->data[ITEM_VAR2] = 0; + itm->data[ITEM_VAR3] = 1; + memcpy( itm->string[ITEM_ARGUMENT].string, result, sizeof( result)); + + return TRUE; +} +//------------------------------------------------------------------------- +// 旦疋□玉仁元毛银匀凶凛及楮醒[ +// ㄥ荚银丹午]窒羁操井及失奶 丞卞 祭允月[ +//------------------------------------------------------------------------- +void ITEM_useLottery( int charaindex, int toindex, int haveitemindex) +{ + int i,j; + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + int count = ITEM_getInt( itemindex, ITEM_VAR2); + int hit = ITEM_getInt( itemindex, ITEM_VAR1); + char buff[1024]; + char num[6][3] = { {"迭"},{"迫"},{"迤"},{"迨"},{"郊"}, {"郎"}}; + char numbuff[128]; + char *n; + int result; + BOOL flg; + if( !ITEM_CHECKINDEX( itemindex) ) return; + if( count == 0 ) { + ITEM_setChar( itemindex, ITEM_EFFECTSTRING, ""); + } + // ㄥ荚 及银迕反]陆木仄井丐曰 卅中及匹]仇仇匹失奶 丞毛壅允 + else if( count == 6 ) { + CHAR_setItemIndex( charaindex , haveitemindex, -1 ); + CHAR_sendItemDataOne( charaindex, haveitemindex); + ITEM_endExistItemsOne( itemindex ); + return; + } + n = ITEM_getChar( itemindex, ITEM_ARGUMENT); + // for debug +#if 0 + snprintf( buff, sizeof( buff), "羁操“%d 请 : %d%d%d%d%d%d", + hit, + (int)(n[0]+1),(int)(n[1]+1), + (int)(n[2]+1),(int)(n[3]+1), + (int)(n[4]+1),(int)(n[5]+1) + ); + CHAR_talkToCli( charaindex, -1, + buff, CHAR_COLORYELLOW ); +#endif + result = (int)n[count]-1; + // 伉□民井譬屯月 + flg = FALSE; + for( i = 0; i < count+1 && flg == FALSE; i ++ ) { + for( j = i+1; j < count+1 && flg == FALSE; j ++ ) { + if( i != j ) { + if( n[i] == n[j] ) { + flg = TRUE; + } + } + } + } + memset( numbuff, 0, sizeof( numbuff)); + memcpy( numbuff, ITEM_getChar( itemindex, ITEM_EFFECTSTRING), (count)*2); + // 躲绊 侬 卞]请 毛请允[ + snprintf( buff, sizeof( buff), "%s%s", numbuff, num[result]); + count ++; + ITEM_setInt( itemindex, ITEM_VAR2, count); + // ㄥ荚 匹癫曰卅日癫曰失奶 丞卞 凳]陆木卅日陆木午 憎] + // 戚荚母皮伙弁伉永弁匹壅允[ + if( count >= 6 ) { + // 癫曰 + if( hit != ITEM_LOTTERY_NONE ) { + int newitemindex; + char strbuff[1024]; + char msgbuff[1024]; + // 壅仄化 + CHAR_setItemIndex( charaindex , haveitemindex, -1 ); + ITEM_endExistItemsOne( itemindex ); + // 2729 - 2734 反 仁元及1 6羁 + newitemindex = ITEM_makeItemAndRegist( 2729 + hit); + CHAR_setItemIndex( charaindex , haveitemindex, newitemindex ); + // 请 手戊疋□ + snprintf( strbuff, sizeof( strbuff), "%s %s", buff, + ITEM_getChar( newitemindex, ITEM_EFFECTSTRING)); + ITEM_setChar( newitemindex, ITEM_EFFECTSTRING, strbuff); + CHAR_sendItemDataOne( charaindex, haveitemindex); + snprintf( msgbuff, sizeof( msgbuff), "中了第%d奖", hit+1 ); + CHAR_talkToCli( charaindex, -1, + msgbuff, + CHAR_COLORYELLOW ); + } + // 陆木 + else { +// CHAR_setItemIndex( charaindex , haveitemindex, -1 ); + // 请 手戊疋□ + char strbuff[1024]; + snprintf( strbuff, sizeof( strbuff), "%s 没中,下次再来", buff); + ITEM_setChar( itemindex, ITEM_EFFECTSTRING, strbuff); + CHAR_sendItemDataOne( charaindex, haveitemindex); +// ITEM_endExistItemsOne( itemindex ); +// CHAR_talkToCli( charaindex, -1, +// "反内木″", +// CHAR_COLORWHITE ); + } + } + // 公丹元扎 中凛反]犯□正毛霜曰卅云允分仃[ + else { + char strbuff[1024]; + if( flg) { + // 旦矢□旦煌遥 + // 失奶 丞及 及戊丢件玄反]ㄠ垫ㄡㄧ 侬匹] + // 旦矢□旦毛银匀化荼垫仄化中月[ + int spc = 16 + ( 6-count)*2; + char space[17]; + memset( space, ' ', spc); + space[spc] = '\0'; + snprintf( strbuff, sizeof( strbuff), "%s%s快中了", buff, space); + } + else { + strcpy( strbuff, buff); + } + ITEM_setChar( itemindex, ITEM_EFFECTSTRING, strbuff); + CHAR_sendItemDataOne( charaindex, haveitemindex); + } +} + +void ITEM_WarpDelErrorItem( int charaindex ) +{ + int j; + for(j=0; j= 12 ){ + CHAR_talkToCli(charaindex, -1, "此处无法使用。", CHAR_COLORYELLOW); + return; + } + + memset( buf, 0, sizeof( buf)); + sprintf( buf, "%d %d %d %d", flg, Mf, Mx, My); + ITEM_setChar(itemindex, ITEM_ARGUMENT, buf); + ITEM_setInt( itemindex, ITEM_DAMAGEBREAK, usenum); + sprintf( buf, "飞行纪录点(%s,%d,%d)", MapString[i], Mx, My); + ITEM_setChar( itemindex, ITEM_EFFECTSTRING, buf); + CHAR_talkToCli(charaindex, -1, buf, CHAR_COLORYELLOW); + CHAR_sendItemDataOne( charaindex, haveitemindex); + } + + // WON ADD + if( ITEM_WarpForAny(charaindex, haveitemindex, ff, fx, fy, flg) == FALSE ) + return; +} +#endif + +// Robin 0707 petFollow +void ITEM_petFollow( int charaindex, int toindex, int haveitemindex ) +{ + char *arg; + int itemindex, followLv, haveindex, i; + //print(" PetFollow_toindex:%d ", toindex); + if( CHAR_getWorkInt( charaindex, CHAR_WORKPETFOLLOW ) != -1 ){ + if( CHAR_CHECKINDEX( CHAR_getWorkInt( charaindex, CHAR_WORKPETFOLLOW ) ) ){ + CHAR_talkToCli( charaindex, -1, "请先收回放出的宠物!", CHAR_COLORWHITE ); + return; + } + CHAR_setWorkInt( charaindex, CHAR_WORKPETFOLLOW, -1); + } +#ifdef _FIX_METAMORIDE + if( CHAR_CHECKJOINENEMY( charaindex) == TRUE ){ + CHAR_talkToCli( charaindex, -1, "搭乘中无法使用!", CHAR_COLORWHITE ); + return; + } +#endif + + if( CHAR_CHECKINDEX( toindex ) == FALSE ) return; + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + arg = ITEM_getChar(itemindex, ITEM_ARGUMENT ); + if( arg == NULL )return; + + if( sscanf( arg, "%d", &followLv) != 1 ) + return; + if( CHAR_getInt( toindex, CHAR_LV ) > followLv ){ + CHAR_talkToCli( charaindex, -1, "道具的等级不足!", CHAR_COLORWHITE ); + return; + } + if( CHAR_getWorkInt( toindex, CHAR_WORKFIXAI ) < 80 ) + { + //CHAR_talkToCli( charaindex, -1, "宠物的忠诚度不足!", CHAR_COLORWHITE ); + //return; + } + + + haveindex = -1; + for( i = 0; i < 5; i++ ) + { + if( CHAR_getCharPet( charaindex, i) == toindex ) { + haveindex = i; + break; + } + } + if( haveindex == -1) return; + + + if( !PET_dropPetFollow( charaindex, haveindex, -1, -1, -1 ) ) { + CHAR_talkToCli( charaindex, -1, "宠物跟随失败!", CHAR_COLORWHITE ); + return; + } + +} + +// Nuke start 0624: Hero's bless +void ITEM_useSkup( int charaindex, int toindex, int haveitemindex) +{ + int itemindex; + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + CHAR_setInt(charaindex,CHAR_SKILLUPPOINT, + CHAR_getInt(charaindex,CHAR_SKILLUPPOINT)+1); + CHAR_Skillupsend(charaindex); + CHAR_talkToCli(charaindex, -1, "你感受到自己的能力被提升了。", CHAR_COLORWHITE); + + CHAR_DelItem( charaindex, haveitemindex); +} +// Nuke end +extern void setNoenemy(); +// Nuke start 0626: Dragon's bless +void ITEM_useNoenemy( int charaindex, int toindex, int haveitemindex) +{ + int itemindex,fd; + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + fd=CHAR_getWorkInt( charaindex, CHAR_WORKFD); + setNoenemy(fd); + CHAR_talkToCli(charaindex, -1, "你感受到周边的杀气消失了。", CHAR_COLORWHITE); + CHAR_DelItem( charaindex, haveitemindex); + +} +// Nuke end + +// Arminius 7.2: Ra's amulet +void ITEM_equipNoenemy( int charaindex, int itemindex ) +{ + char buf[4096]; + int evadelevel; + int fl,fd; + + if( ITEM_CHECKINDEX(itemindex) == FALSE )return; + + if( ITEM_getArgument( ITEM_getChar(itemindex,ITEM_ARGUMENT),"noen", buf, sizeof(buf) ) + == FALSE ){ + return; + } + + evadelevel=atoi(buf); + fl=CHAR_getInt(charaindex, CHAR_FLOOR); + fd=CHAR_getWorkInt( charaindex, CHAR_WORKFD); + if (evadelevel>=200) { + setEqNoenemy(fd, 200); + CHAR_talkToCli(charaindex, -1, "一道奇异的光芒隐藏了你的行踪。", CHAR_COLORWHITE); + return; + } else if (evadelevel>=120) { + setEqNoenemy(fd, 120); + + if ( (fl==100)||(fl==200)||(fl==300)||(fl==400)||(fl==500) ){ + CHAR_talkToCli(charaindex, -1, "一道奇异的光芒隐藏了你的行踪。", CHAR_COLORWHITE); + return; + } + } else if (evadelevel>=80) { + setEqNoenemy(fd, 80); + if ( (fl==100)||(fl==200)||(fl==300)||(fl==400) ){ + + CHAR_talkToCli(charaindex, -1, "一道奇异的光芒隐藏了你的行踪。", CHAR_COLORWHITE); + return; + } + } else if (evadelevel>=40) { + setEqNoenemy(fd, 40); + if ( (fl==100)||(fl==200) ) { + CHAR_talkToCli(charaindex, -1, "一道奇异的光芒隐藏了你的行踪。", CHAR_COLORWHITE); + return; + } + } + CHAR_talkToCli(charaindex, -1, "什麽事也没有发生。", CHAR_COLORWHITE); +} + +#ifdef _Item_MoonAct +void ITEM_randEnemyEquipOne( int charaindex, int toindex, int haveitemindex) +{ + int itemindex, RandNum=0; + char buf[256]; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX( itemindex)) return; + + if( ITEM_getArgument( ITEM_getChar( itemindex,ITEM_ARGUMENT), "rand", buf, sizeof(buf) ) == FALSE ){ + return; + } + + if( (RandNum=atoi( buf)) > 0 ){ + int fd = CHAR_getWorkInt( charaindex, CHAR_WORKFD); + setEqRandenemy(fd, RandNum); + CHAR_talkToCli(charaindex, -1, "遇敌率降低了。", CHAR_COLORWHITE); + sprintf( buf, "道具 %s消失了。", ITEM_getChar( itemindex, ITEM_NAME) ); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); + return; + } + + +} + +void ITEM_randEnemyEquip( int charaindex, int itemindex) +{ + char buf[4096]; + int RandNum=0; + int fd; + + if( ITEM_CHECKINDEX(itemindex) == FALSE )return; + if( ITEM_getArgument( ITEM_getChar(itemindex,ITEM_ARGUMENT),"rand", buf, sizeof(buf) ) + == FALSE ){ + return; + } + + RandNum=atoi( buf); + fd=CHAR_getWorkInt( charaindex, CHAR_WORKFD); + if (RandNum > 0 ) { + setEqRandenemy(fd, RandNum); + CHAR_talkToCli(charaindex, -1, "遇敌率降低了。", CHAR_COLORWHITE); + return; + } + +} +void ITEM_RerandEnemyEquip( int charaindex, int itemindex) +{ + int RandNum=0; + int fd; + + if( ITEM_CHECKINDEX(itemindex) == FALSE )return; + + fd=CHAR_getWorkInt( charaindex, CHAR_WORKFD); + RandNum = getEqRandenemy( fd); + + if (RandNum > 0 ) { + clearEqRandenemy( fd); + CHAR_talkToCli(charaindex, -1, "遇敌率回复。", CHAR_COLORWHITE); + return; + } +} +#endif + +#ifdef _ITEM_WATERWORDSTATUS +void ITEM_WaterWordStatus( int charaindex, int toindex, int haveitemindex) +{ + int itemindex; + char itemarg[256]; + + if( !CHAR_CHECKINDEX( charaindex) ){ + return; + } + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX( itemindex) ){ + return; + } + + if( ITEM_getArgument( ITEM_getChar( itemindex, ITEM_ARGUMENT),"time", itemarg, sizeof(itemarg) ) != FALSE ){ + char token[256]; + int nums = CHAR_getWorkInt( charaindex, CHAR_WORKSTATUSWATER); + if( nums < 0 ) nums = 0; + if( nums > 0 ){ + CHAR_talkToCli( charaindex, -1, "水中呼吸时间不得累积。", CHAR_COLORYELLOW); + return; + } + CHAR_setWorkInt( charaindex, CHAR_WORKSTATUSWATER, nums+atoi(itemarg)); + CHAR_setItemIndex(charaindex, haveitemindex ,-1); + CHAR_sendItemDataOne( charaindex, haveitemindex); + ITEM_endExistItemsOne(itemindex); + + sprintf( token, "水中呼吸时间增加%d分,总计%d分。", atoi(itemarg), + CHAR_getWorkInt( charaindex, CHAR_WORKSTATUSWATER)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + }else{ + CHAR_talkToCli(charaindex, -1, "什麽事也没发生。", CHAR_COLORYELLOW); + } +} +#endif + +#ifdef _CHIKULA_STONE +void ITEM_ChikulaStone( int charaindex, int toindex, int haveitemindex) +{ + int itemindex,fd; + char itemarg[256]; + + if( !CHAR_CHECKINDEX( charaindex) ) return; + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX( itemindex) ) return; + + fd = CHAR_getWorkInt( charaindex, CHAR_WORKFD); + CHAR_setWorkInt( charaindex, CHAR_WORKCHIKULAHP, 0 ); + CHAR_setWorkInt( charaindex, CHAR_WORKCHIKULAMP, 0 ); + setChiStone( fd, 0); //1hp 2mp + + if( ITEM_getArgument( ITEM_getChar( itemindex, ITEM_ARGUMENT),"hp", itemarg, sizeof(itemarg) ) != FALSE ){ + setChiStone( fd, 1); + CHAR_setWorkInt( charaindex, CHAR_WORKCHIKULAHP, atoi( itemarg) ); + }else if( ITEM_getArgument( ITEM_getChar( itemindex, ITEM_ARGUMENT),"mp", itemarg, sizeof(itemarg) ) != FALSE ){ + setChiStone( fd, 2); + CHAR_setWorkInt( charaindex, CHAR_WORKCHIKULAMP, atoi( itemarg) ); + }else{ + } + + CHAR_talkToCli(charaindex, -1, "接受奇克拉的祝福。", CHAR_COLORWHITE); + CHAR_setItemIndex(charaindex, haveitemindex ,-1); + CHAR_sendItemDataOne( charaindex, haveitemindex); + ITEM_endExistItemsOne(itemindex); +} +#endif + +#ifdef _ITEM_ORNAMENTS +void ITEM_PutOrnaments( int charaindex, int itemindex) +{ + char *arg=NULL; + char itemname[256]; + int bbnums=0; + if( !CHAR_CHECKINDEX( charaindex) ) return; + if( !ITEM_CHECKINDEX( itemindex) ) return; + arg = ITEM_getChar( itemindex, ITEM_ARGUMENT); + if( arg == NULL ) return;//ITEM_BASEIMAGENUMBER + bbnums = atoi( arg); + ITEM_setInt( itemindex, ITEM_BASEIMAGENUMBER, bbnums); + ITEM_setWorkInt( itemindex, ITEM_CANPICKUP, 1); + + sprintf( itemname,"%s%s%s",CHAR_getChar( charaindex, CHAR_NAME), "的", ITEM_getChar( itemindex, ITEM_SECRETNAME)); + ITEM_setChar( itemindex, ITEM_SECRETNAME, itemname); +} +#endif + +#ifdef _SUIT_ITEM + +/* +#ifdef _SUIT_TWFWENDUM + #define MAX_SUITTYPE 18 +#else + #ifdef _SUIT_ADDENDUM + #define MAX_SUITTYPE 14 + #else + #ifdef _MAGIC_RESIST_EQUIT // WON ADD 职业抗性装备 + #define MAX_SUITTYPE 11 + #else + #define MAX_SUITTYPE 8 + #endif//_MAGIC_RESIST_EQUIT + #endif//_SUIT_ADDENDUM +#endif//_SUIT_TWFWENDUM +*/ +void ITEM_CheckSuitEquip( int charaindex) +{ + int i, j, itemindex, defCode=-1, same=0; + int nItem[CHAR_STARTITEMARRAY]; + int maxitem; + struct tagIntSuit{ + char fun[256]; + int intfun; //CHAR_getInt + }; + struct tagIntSuit ListSuit[]={ + {"VIT",CHAR_WORKSUITVIT}, + {"FSTR",CHAR_WORKSUITMODSTR}, + {"MSTR",CHAR_WORKSUITSTR}, + {"MTGH",CHAR_WORKSUITTGH}, + {"MDEX",CHAR_WORKSUITDEX}, + {"WAST",CHAR_WORKSTATUSWATER}, + {"HP", CHAR_WORKROUNDHP}, + {"MP", CHAR_WORKROUNDMP} +#ifdef _MAGIC_RESIST_EQUIT // WON ADD 职业抗性装备 + ,{"FRES", CHAR_WORK_F_SUIT}, + {"IRES", CHAR_WORK_I_SUIT}, + {"TRES", CHAR_WORK_T_SUIT} +#endif +#ifdef _SUIT_ADDENDUM + ,{"RESIST",CHAR_WORKRESIST}, //异常抗性率 + {"COUNTER",CHAR_WORKCOUNTER}, //反击率 + {"M_POW",CHAR_WORKMPOWER} //加强法师的魔法 +#endif +#ifdef _SUIT_TWFWENDUM + ,{"EARTH",CHAR_WORK_EA}, //地 + {"WRITER",CHAR_WORK_WR}, //水 + {"FIRE",CHAR_WORK_FI}, //火 + {"WIND",CHAR_WORK_WI} //风 +#endif +#ifdef _SUIT_ADDPART3 + ,{"WDUCKPOWER",CHAR_WORKDUCKPOWER},//套装回避 + {"RENOCASE",CHAR_WORKRENOCAST}, //沉默抗性率 + {"SUITSTRP",CHAR_WORKSUITSTR_P},//攻提升 单位为% + {"SUITTGH_P",CHAR_WORKSUITTGH_P},//防提升 单位为% + {"SUITDEXP",CHAR_WORKSUITDEX_P}//敏提升 单位为% +#endif +#ifdef _SUIT_ADDPART4 + ,{"SUITPOISON",CHAR_SUITPOISON},//带毒装备 + {"M2_POW",CHAR_WORKMPOWER2}, //加强法师的魔法,与M_POW功能相同(机率30%) + {"UN_POW_M",CHAR_WORKUNMPOWER} //抵抗法师的魔法 +#endif + }; + maxitem = sizeof(ListSuit)/sizeof(ListSuit[0]); + CHAR_setWorkInt( charaindex, CHAR_WORKSUITITEM, 0); + for( i=0; i=0; k-- ){ + if( nItem[i] == nItem[k] ) same++; + } + if( same >= 3 && nItem[i] != 0 )defCode = nItem[i]; + } + if( defCode == -1 ) return; + CHAR_setWorkInt( charaindex, CHAR_WORKSUITITEM, defCode); + for( i=0; i=200) { + CHAR_talkToCli(charaindex, -1, "环绕着你的光芒消失了。", CHAR_COLORWHITE); + return; + } else if (el>=120) { + if ( (fl==100)||(fl==200)||(fl==300)||(fl==400)||(fl==500) ) { + CHAR_talkToCli(charaindex, -1, "环绕着你的光芒消失了。", CHAR_COLORWHITE); + return; + } + } else if (el>=80) { + if ( (fl==100)||(fl==200)||(fl==300)||(fl==400) ) { + CHAR_talkToCli(charaindex, -1, "环绕着你的光芒消失了。", CHAR_COLORWHITE); + return; + } + } else if (el>=40) { + if ( (fl==100)||(fl==200) ) { + CHAR_talkToCli(charaindex, -1, "环绕着你的光芒消失了。", CHAR_COLORWHITE); + return; + } + } + CHAR_talkToCli(charaindex, -1, "什麽事也没有发生。", CHAR_COLORWHITE); +} + +extern void setStayEncount(int fd); +void ITEM_useEncounter( int charaindex, int toindex, int haveitemindex) +{ + int itemindex,fd; + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + fd=CHAR_getWorkInt( charaindex, CHAR_WORKFD); + setStayEncount(fd); +#ifdef _USER_CHARLOOPS + { + Char *ch; + ch = CHAR_getCharPointer( charaindex); + if( ch == NULL ) return; + strcpysafe( ch->charfunctable[CHAR_LOOPFUNCTEMP1].string, + sizeof( ch->charfunctable[CHAR_LOOPFUNCTEMP1]), "CHAR_BattleStayLoop");//战斗 + CHAR_setInt( charaindex, CHAR_LOOPINTERVAL, 2500); + CHAR_constructFunctable( charaindex); + } +#endif + CHAR_talkToCli(charaindex, -1, "你感受到周边突然充满了杀气!", CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); + +} + +#ifdef _DEATH_CONTENDWATCH +void ITEM_useWatchBattle( int charaindex, int toindex, int haveitemindex) +{ + int itemindex,fd; + int battleTi; + char buf1[256]; + char *itemarg=NULL; + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + if( (itemarg = ITEM_getChar( itemindex, ITEM_ARGUMENT)) == NULL ) return; + battleTi = atoi( itemarg); + fd = CHAR_getWorkInt( charaindex, CHAR_WORKFD); + + { + ArrangeBattleC *aBo=NULL; + ArrangeBattleC *aB1=NULL; + ArrangeBattleC *aB2=NULL; + + if( battleTi<0 || battleTi>MAXBATTLEPAGE ) return; + if( (aBo=ArrangeBattleC_getInBattleArray( battleTi)) == NULL){ + sprintf( buf1, "目前场%d并没有竞赛。", battleTi); + CHAR_talkToCli(charaindex, -1, buf1, CHAR_COLORYELLOW); + return; + } + + if( (aB1=aBo->next[0]) == NULL || + (aB2=aBo->next[1]) == NULL || + !CHAR_CHECKINDEX( aB1->toindex) || + !CHAR_CHECKINDEX( aB2->toindex) || + CHAR_getWorkInt( aB1->toindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE || + CHAR_getWorkInt( aB2->toindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE ){ + + sprintf( buf1, "目前场%d尚未开始战斗。", battleTi); + CHAR_talkToCli(charaindex, -1, buf1, CHAR_COLORYELLOW); + return; + } + + if( BATTLE_WatchEntry( charaindex, aB1->toindex) ){ + + }else{ + sprintf( buf1, "观战失败!", battleTi); + CHAR_talkToCli(charaindex, -1, buf1, CHAR_COLORYELLOW); + return; + } + } + + sprintf( buf1, "道具 %s消失了。", ITEM_getChar( itemindex, ITEM_NAME) ); + CHAR_talkToCli(charaindex, -1, buf1, CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); +} +#endif + +#ifdef _Item_DeathAct +void ITEM_UseDeathCounter( int charaindex, int toindex, int haveitemindex) +{ + int itemindex,fd; + int itemmaxuse=-1; + char buf1[256]; + char *itemarg; + char itemnumstr[32]; + int okfloor = 0; + BOOL Useflag=FALSE; + int i = 1; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + +#ifdef _ITEM_STONE + itemarg = ITEM_getChar(itemindex,ITEM_ARGUMENT); + while(1){ + if( getStringFromIndexWithDelim( itemarg, "|", i , itemnumstr, sizeof( itemnumstr)) == FALSE ) + break; + okfloor = atoi(itemnumstr); + if( CHAR_getInt( charaindex, CHAR_FLOOR ) == okfloor ){ + Useflag = TRUE; + break; + } + i++; + } + if(okfloor != 0){ // 奇怪的石头 + itemmaxuse = ITEM_getInt( itemindex, ITEM_DAMAGEBREAK); + if( itemmaxuse != -1 ) { + itemmaxuse--; + ITEM_setInt( itemindex, ITEM_DAMAGEBREAK, itemmaxuse); + if( itemmaxuse < 1 ) { + sprintf( buf1, "%s消失了。", ITEM_getChar( itemindex, ITEM_NAME) ); + CHAR_talkToCli(charaindex, -1, buf1, CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); + if(Useflag==FALSE) { + CHAR_talkToCli(charaindex, -1, "没有发生任何事情!", CHAR_COLORYELLOW); + return; + } + }else{ + sprintf( buf1, "原地遇敌,可使用次数剩馀%d次。", itemmaxuse); + ITEM_setChar( itemindex, ITEM_EFFECTSTRING, buf1); + CHAR_sendItemDataOne( charaindex, haveitemindex); + if(Useflag==FALSE) { + CHAR_talkToCli(charaindex, -1, "没有发生任何事情!", CHAR_COLORYELLOW); + return; + } + } + fd = CHAR_getWorkInt( charaindex, CHAR_WORKFD); + setStayEncount(fd); + CHAR_talkToCli(charaindex, -1, "你身边笼罩阴暗气息!", CHAR_COLORYELLOW); + }else{ + sprintf( buf1, "%s消失了。", ITEM_getChar( itemindex, ITEM_NAME) ); + CHAR_talkToCli(charaindex, -1, buf1, CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); + if(Useflag==FALSE) { + CHAR_talkToCli(charaindex, -1, "没有发生任何事情!", CHAR_COLORYELLOW); + return; + } + fd = CHAR_getWorkInt( charaindex, CHAR_WORKFD); + setStayEncount(fd); + CHAR_talkToCli(charaindex, -1, "你身边笼罩阴暗气息!", CHAR_COLORYELLOW); + } + }else{ //恶魔宝石 +#endif +#ifdef _ITEM_MAXUSERNUM + itemmaxuse = ITEM_getInt( itemindex, ITEM_DAMAGEBREAK); + if( itemmaxuse != -1 ) { + itemmaxuse--; + ITEM_setInt( itemindex, ITEM_DAMAGEBREAK, itemmaxuse); + if( itemmaxuse < 1 ) { + sprintf( buf1, "道具 %s消失了。", ITEM_getChar( itemindex, ITEM_NAME) ); + CHAR_talkToCli(charaindex, -1, buf1, CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); + }else{ + sprintf( buf1, "原地遇敌,可使用次数剩馀%d次。", itemmaxuse); + ITEM_setChar( itemindex, ITEM_EFFECTSTRING, buf1); + CHAR_sendItemDataOne( charaindex, haveitemindex); + } + fd = CHAR_getWorkInt( charaindex, CHAR_WORKFD); + setStayEncount(fd); + CHAR_talkToCli(charaindex, -1, "你感受到周边突然充满了杀气!", CHAR_COLORYELLOW); + }else{ + CHAR_DelItem( charaindex, haveitemindex); + return; + } +#else + fd = CHAR_getWorkInt( charaindex, CHAR_WORKFD); + setStayEncount(fd); + sprintf( buf1, "道具 %s消失了。", ITEM_getChar( itemindex, ITEM_NAME) ); + CHAR_talkToCli(charaindex, -1, buf1, CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); +#endif +#ifdef _ITEM_STONE + } +#endif +#ifdef _USER_CHARLOOPS + { + Char *ch; + ch = CHAR_getCharPointer( charaindex); + if( ch == NULL ) return; + strcpysafe( ch->charfunctable[CHAR_LOOPFUNCTEMP1].string, + sizeof( ch->charfunctable[CHAR_LOOPFUNCTEMP1]), "CHAR_BattleStayLoop");//战斗 + CHAR_setInt( charaindex, CHAR_LOOPINTERVAL, 2500); + CHAR_constructFunctable( charaindex); + } +#endif +} +#endif + +#ifdef _CHRISTMAS_REDSOCKS +void ITEM_useMaxRedSocks( int charaindex, int toindex, int haveitemindex) +{ + int itemtimes = -1, itemindex; + char *itemarg=NULL; + int present[13]={ 13061, 13062, 13063, 13064, 13088, 13089, 13090, 13091, //1. + 14756, 17256, + 13092,19692,20594}; + int nowtimes = time( NULL); + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + itemarg = ITEM_getChar( itemindex, ITEM_ARGUMENT); + if( itemarg == NULL ) { + CHAR_talkToCli(charaindex, -1, "道具无效!", CHAR_COLORYELLOW); + return; + } + itemtimes = atoi( itemarg); + if( nowtimes >= itemtimes && nowtimes <= itemtimes+(60*60*24) ){ //限制时间内可换礼物 + int si=0, ret; + char token[256]; + //删除 + CHAR_setItemIndex(charaindex, haveitemindex ,-1); + CHAR_sendItemDataOne( charaindex, haveitemindex); + ITEM_endExistItemsOne(itemindex); + itemindex = -1; + //新增 + si = rand()%100; + if( si > 70 ){ + si = rand()%3+10; + }else if( si > 60 ){ + si = rand()%2+8; + }else { + si = rand()%8; + } + itemindex = ITEM_makeItemAndRegist( present[ si]); + if( !ITEM_CHECKINDEX( itemindex)){ + CHAR_talkToCli(charaindex, -1, "礼物无效!", CHAR_COLORYELLOW); + return; + } + ret = CHAR_addItemSpecificItemIndex( charaindex, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + ITEM_endExistItemsOne( itemindex); + CHAR_talkToCli(charaindex, -1, "礼物置放栏位错误!", CHAR_COLORYELLOW); + return; + } + sprintf( token,"拿到%s",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW ); + CHAR_sendItemDataOne( charaindex, ret); + }else{ + char token[256]; + if( nowtimes < itemtimes ){ + int days, hours, minute, second; + int defTimes = itemtimes - nowtimes; + + days = defTimes/(24*60*60); + defTimes = defTimes-( days*(24*60*60)); + hours = defTimes/(60*60); + defTimes = defTimes-( hours*(60*60)); + minute = defTimes/60; + defTimes = defTimes-( minute*60); + second = defTimes; + sprintf( token,"%s还差%d天%d小时%d分%d秒才可使用!", + ITEM_getChar( itemindex, ITEM_NAME), days, hours, minute, second); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW ); + }else if( nowtimes > itemtimes+(60*60*24) ){ + sprintf( token,"%s使用期限已过!", ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW ); + } + } +} +#endif + +#ifdef _CHRISTMAS_REDSOCKS_NEW +void ITEM_useMaxRedSocksNew( int charaindex, int toindex, int haveitemindex) +{ + int itemindex; + char *itemarg=NULL; + char itemnumstr[32]; + int itemnum=0; + int present[20]; + int si=0, ret,i; + char token[256]; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + itemarg = ITEM_getChar( itemindex, ITEM_ARGUMENT); + if( itemarg == NULL ){ + CHAR_talkToCli(charaindex, -1, "这是个芭乐圣诞袜!", CHAR_COLORYELLOW); + return; + } + + //道具数量 + if( getStringFromIndexWithDelim( itemarg, "|", 1, itemnumstr, sizeof( itemnumstr)) == FALSE ) + return; + itemnum = atoi(itemnumstr); + if( itemnum > 20 ) + itemnum = 20; + for(i=0;i= CHAR_MAXITEMHAVE ) { + ITEM_endExistItemsOne( itemindex); + CHAR_talkToCli(charaindex, -1, "礼物置放栏位错误!", CHAR_COLORYELLOW); + return; + } + sprintf( token,"拿到%s",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW ); + CHAR_sendItemDataOne( charaindex, ret); + +} +#endif + +#ifdef _PETSKILL_CANNEDFOOD +void ITEM_useSkillCanned( int charaindex, int toindex, int itemNo) +{ + int itemindex; + char buf1[256]; + itemindex = CHAR_getItemIndex( charaindex, itemNo); + if(!ITEM_CHECKINDEX( itemindex)) return; + if( !CHAR_CHECKINDEX( toindex) ) return; + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPET) { + int i, petNo=-1; + for( i=0; i -1 ){//变成乌力了 + CHAR_talkToCli( charaindex, -1, "无法变身,乌力化中不能变身!", CHAR_COLORYELLOW ); + return; + } +#endif + + +#ifdef _FIXBUG_ATTACKBOW + { + int armindex = CHAR_getItemIndex( charaindex, CHAR_ARM); + if( ITEM_CHECKINDEX( armindex) == TRUE ) { + int armtype = BATTLE_GetWepon( charaindex); + if( armtype == ITEM_BOW || armtype == ITEM_BOUNDTHROW || + armtype == ITEM_BREAKTHROW || armtype == ITEM_BOOMERANG) { + CHAR_talkToCli( charaindex, -1, "使用远距离武器无法变身!", CHAR_COLORYELLOW ); + return; + } + } + } +#endif + + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + // 爵 钒铵凛反 骰允月 + if( battlemode == BATTLE_CHARMODE_INIT ){ + return; + } + // 爵 分匀凶日 + if( IsBATTLING( charaindex ) == TRUE ){ + toindex = BATTLE_No2Index(CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ), toindex ); + + } + + if( CHAR_CHECKINDEX( toindex ) == FALSE ) return; + + haveindex = -1; + for( i = 0; i < 5; i++ ){ + if( CHAR_getCharPet( charaindex, i) == toindex ) { + haveindex = i; + break; + } + } + if( haveindex == -1 && charaindex != toindex ){ + CHAR_talkToCli( charaindex, -1, "无法变身,只能变成自己的宠物!", CHAR_COLORYELLOW ); + return; + } + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + arg = ITEM_getChar(itemindex, ITEM_ARGUMENT ); + if( arg == NULL )return; + if( sscanf( arg, "%d", &metamoTime) != 1 ) + return; + + + if( toindex != charaindex ){ + CHAR_setWorkInt( charaindex, CHAR_WORKITEMMETAMO, NowTime.tv_sec +metamoTime); + sprintf( msg, "变身成%s!", CHAR_getChar( toindex, CHAR_NAME) ); + } + else { + CHAR_setWorkInt( charaindex, CHAR_WORKITEMMETAMO, 0); + sprintf( msg, "变回自己!"); + } + CHAR_talkToCli( charaindex, -1, msg, CHAR_COLORYELLOW ); + + CHAR_setInt( charaindex, CHAR_BASEIMAGENUMBER, CHAR_getInt( toindex, CHAR_BASEBASEIMAGENUMBER) ); + CHAR_complianceParameter( charaindex); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + + CHAR_DelItem( charaindex, haveitemindex); + +} +#endif +#ifdef _ITEM_CRACKER +void ITEM_Cracker(int charaindex,int toindex,int haveitemindex) +{ + int battlemode; + // 检查玩家是否有效 + if(CHAR_CHECKINDEX(charaindex) == FALSE) return; //失败 + battlemode = CHAR_getWorkInt(charaindex,CHAR_WORKBATTLEMODE); + // 战斗中使用无效 + if(!battlemode) ITEM_useCracker_Effect(charaindex,toindex,haveitemindex); + else CHAR_talkToCli(charaindex,-1,"什麽也没发生。",CHAR_COLORWHITE); +} +#endif + +void ITEM_AddPRSkillPercent( int charaindex,int toindex,int haveitemindex) +{ +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + + int MySKPercent=0, itemindex=-1, i; + + if( !CHAR_CHECKINDEX( charaindex) ) return; + if( CHAR_getInt( charaindex, PROFESSION_CLASS ) == 0 ) return; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX( itemindex) )return; + + for( i=0; i 100 ) MySKPercent = 100; + CHAR_setIntPSkill( charaindex, i, SKILL_LEVEL, MySKPercent); + } + + CHAR_setItemIndex( charaindex, haveitemindex ,-1); + CHAR_sendItemDataOne( charaindex, haveitemindex); + ITEM_endExistItemsOne( itemindex ); + CHAR_sendStatusString( charaindex , "S"); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + CHAR_talkToCli( charaindex, -1, "所有职业技能熟练度上升10%。", CHAR_COLORYELLOW); +#endif +} + +void ITEM_AddPRSkillPoint( int charaindex,int toindex,int haveitemindex) +{ +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + + int MyPRpoint=0, itemindex=-1; + if( !CHAR_CHECKINDEX( charaindex) ) return; + if( CHAR_getInt( charaindex, PROFESSION_CLASS ) == 0 ) return; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX( itemindex) )return; + + MyPRpoint = CHAR_getInt( charaindex, PROFESSION_SKILL_POINT); + CHAR_setInt( charaindex, PROFESSION_SKILL_POINT, MyPRpoint+1 ); + + + CHAR_setItemIndex( charaindex, haveitemindex ,-1); + CHAR_sendItemDataOne( charaindex, haveitemindex); + ITEM_endExistItemsOne( itemindex ); + + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + + CHAR_talkToCli( charaindex, -1, "增加一点职业技能点数。", CHAR_COLORYELLOW); +#endif +} + +#ifdef _ITEM_ADDEXP //vincent 经验提升 +void ITEM_Addexp(int charaindex,int toindex,int haveitemindex) +{ + // 检查玩家是否有效 + if(CHAR_CHECKINDEX(charaindex) == FALSE) return; //失败 +#if 1 + ITEM_useAddexp_Effect(charaindex,toindex,haveitemindex); +#else + if( !CHAR_getWorkInt(charaindex,CHAR_WORKITEM_ADDEXP)){ + ITEM_useAddexp_Effect(charaindex,toindex,haveitemindex); + }else{ + CHAR_talkToCli(charaindex,-1,"先前使用之药效依然存在",CHAR_COLORYELLOW); + } +#endif +} +#endif + +#ifdef _ITEM_REFRESH //vincent 解除异常状态道具 +void ITEM_Refresh(int charaindex,int toindex,int haveitemindex) +{ + int battlemode,itemindex; +print("\nvincent--ITEM_Refresh"); + // 检查玩家是否有效 + if(CHAR_CHECKINDEX(charaindex) == FALSE) + { +print("\nvincent--(charaindex) == FALSE"); + return; //失败 + } + itemindex = CHAR_getItemIndex(charaindex,haveitemindex); + + battlemode = CHAR_getWorkInt(charaindex,CHAR_WORKBATTLEMODE); + if(battlemode) + { +print("\nvincent--enter ITEM_useAddexp_Effect"); +print("\nvincent-->charaindex:%d,toindex:%d",charaindex,toindex); + ITEM_useRefresh_Effect(charaindex,toindex,haveitemindex); + } + else CHAR_talkToCli(charaindex,-1,"什麽也没发生。",CHAR_COLORWHITE); + + /* 平乓仿弁正□及赭 伉旦玄井日壅蛔 */ + CHAR_setItemIndex(charaindex, haveitemindex ,-1); + CHAR_sendItemDataOne( charaindex, haveitemindex);/* 失奶 丞凳蕙 */ + /* 壅允 */ + ITEM_endExistItemsOne( itemindex ); +} +#endif +//Terry 2001/12/21 +#ifdef _ITEM_FIRECRACKER +void ITEM_firecracker(int charaindex,int toindex,int haveitemindex) +{ + int battlemode; + + // 检查玩家是否有效 + if(CHAR_CHECKINDEX(charaindex) == FALSE) return; //失败 + + battlemode = CHAR_getWorkInt(charaindex,CHAR_WORKBATTLEMODE); + + if( battlemode // 检查是否在战斗中 +#ifdef _PETSKILL_BECOMEPIG + && CHAR_getInt( charaindex, CHAR_BECOMEPIG) == -1 +#endif + ) + ITEM_useFirecracker_Battle(charaindex,toindex,haveitemindex); + else + CHAR_talkToCli(charaindex,-1,"什麽也没发生。",CHAR_COLORWHITE); +} +#endif +//Terry end + + +void ITEM_WearEquip( int charaindex, int itemindex) +{ + // WON ADD +// if( ITEM_getInt(itemindex,ITEM_ID) == 20130 ){ + CHAR_setWorkInt( charaindex, CHAR_PickAllPet, TRUE); +/// } + return; +} +void ITEM_ReWearEquip( int charaindex, int itemindex) +{ + CHAR_setWorkInt( charaindex, CHAR_PickAllPet, FALSE); + return; +} + + +#ifdef _Item_ReLifeAct +void ITEM_DIErelife( int charaindex, int itemindex, int eqw) +{ + int ReceveEffect=-1; + int toNo; + int battleindex=-1; + int attackNo=-1; + int WORK_HP=1; + char buf[256]; + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + if( BATTLE_CHECKINDEX( battleindex ) == FALSE ) { + print("\n battleindex =%d return", battleindex); + return; + } + if( CHAR_CHECKINDEX( charaindex) == FALSE ) + return; + if( ITEM_CHECKINDEX( itemindex) == FALSE ) + return; +#ifdef _DUMMYDIE + if( CHAR_getFlg( charaindex, CHAR_ISDUMMYDIE) == FALSE ) { +#else + if( CHAR_getFlg( charaindex, CHAR_ISDIE) == FALSE ) { +#endif + print("\n [ %d, CHAR_ISDIE DUMMY FALSE] return !", charaindex); + return; + } + + if( ITEM_getArgument( ITEM_getChar(itemindex,ITEM_ARGUMENT),"HP", buf, sizeof(buf) ) + == FALSE ){ + WORK_HP = 1; + }else { + if( !strcmp( buf, "FULL") ) { + WORK_HP = CHAR_getWorkInt( charaindex, CHAR_WORKMAXHP ); + }else { + WORK_HP=atoi( buf); + } + } + + ReceveEffect = SPR_fukkatu3; + toNo = BATTLE_Index2No( battleindex, charaindex ); + attackNo = -1; + + BATTLE_MultiReLife( battleindex, attackNo, toNo, WORK_HP, ReceveEffect ); + CHAR_setItemIndex( charaindex, eqw ,-1); + ITEM_endExistItemsOne( itemindex); + CHAR_sendItemDataOne( charaindex, eqw); + return; +} +#endif + +#ifdef _EQUIT_DEFMAGIC +void ITEM_MagicEquitWear( int charaindex, int itemindex) +{ + char buf[256]; + char *itemarg; + char Free[][128]={"EA","WA","FI","WI","QU"}; + int index=0; + int dMagic=0; + itemarg = ITEM_getChar(itemindex,ITEM_ARGUMENT); + memset( buf, 0, sizeof( char) *256); + if( itemarg == NULL ) return; + while( index < arraysizeof( Free) ) { + if( ITEM_getArgument( itemarg, Free[ index], buf, sizeof(buf)) == TRUE ) { + dMagic = atoi( buf); + if( dMagic <= 100 && dMagic >= -100 ) { + int def_magic = CHAR_getWorkInt( charaindex, CHAR_EQUITDEFMAGIC_E+index); + CHAR_setWorkInt( charaindex, CHAR_EQUITDEFMAGIC_E+index, def_magic + dMagic); + } + dMagic = 0; + } + index++; + if( (CHAR_EQUITDEFMAGIC_E+index) > CHAR_EQUITQUIMAGIC ) + break; + } + + return; +} + +void ITEM_MagicEquitReWear( int charaindex, int itemindex){ + char buf[256]; + char *itemarg; + char Free[][128]={"EA","WA","FI","WI","QU"}; + int index=0; + int dMagic=0; + + itemarg = ITEM_getChar(itemindex,ITEM_ARGUMENT); + memset( buf, 0, sizeof( char) *256); + if( itemarg == NULL ) return; + while( index < arraysizeof( Free) ) { + if( ITEM_getArgument( itemarg, Free[ index], buf, sizeof(buf)) == TRUE ) { + dMagic = atoi( buf); + if( dMagic <= 100 && dMagic >= -100 ) { + int def_magic = CHAR_getWorkInt( charaindex, CHAR_EQUITDEFMAGIC_E+index); + CHAR_setWorkInt( charaindex, CHAR_EQUITDEFMAGIC_E+index, def_magic - dMagic); + } + dMagic = 0; + } + index++; + if( (CHAR_EQUITDEFMAGIC_E+index) > CHAR_EQUITQUIMAGIC ) + break; + } + + return; +} +#endif + +#ifdef _EQUIT_RESIST +void ITEM_MagicResist( int charaindex, int itemindex) +{ + char *itemarg,*p=NULL; + itemarg = ITEM_getChar(itemindex,ITEM_ARGUMENT); + if( itemarg == NULL ) return; + if( p = strstr( itemarg, "抗火" ) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITFIRE, atoi( p+4 ) ); + } + else if( p = strstr( itemarg, "抗雷" ) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITTHUNDER, atoi( p+4 ) ); + } + else if( p = strstr( itemarg, "抗冰" ) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITICE, atoi( p+4 ) ); + } + else if( p = strstr( itemarg, "虚弱" ) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITWEAKEN, atoi( p+4 ) ); + } + else if( p = strstr( itemarg, "魔障" ) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITBARRIER, atoi( p+4 ) ); + } + else if( p = strstr( itemarg, "沉默" ) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITNOCAST, atoi( p+4 ) ); + } + else if( p = strstr( itemarg, "落马" ) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITFALLRIDE, atoi( p+4 ) ); + } + +} + +void ITEM_MagicReResist( int charaindex, int itemindex) +{ + char *itemarg,*p=NULL; + itemarg = ITEM_getChar(itemindex,ITEM_ARGUMENT); + if( itemarg == NULL ) return; + if( p = strstr( itemarg, "抗火" ) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITFIRE, 0 ); + } + else if( p = strstr( itemarg, "抗雷" ) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITFIRE, 0 ); + } + else if( p = strstr( itemarg, "抗冰" ) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITFIRE, 0 ); + } + else if( p = strstr( itemarg, "虚弱" ) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITFIRE, 0 ); + } + else if( p = strstr( itemarg, "魔障" ) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITFIRE, 0 ); + } + else if( p = strstr( itemarg, "沉默" ) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITFIRE, 0 ); + } + else if( p = strstr( itemarg, "落马" ) ){ + CHAR_setWorkInt( charaindex, CHAR_WORKEQUITFIRE, 0 ); + } +} +#endif + +#ifdef _MAGIC_RESIST_EQUIT // WON ADD 职业抗性装备 +void ITEM_P_MagicEquitWear( int charaindex, int itemindex ) +{ + char buf[256] = {0}; + char *itemarg; + char Free[][128]={"FR","IR","TR"}; + int dMagic=0; + int i; + + itemarg = ITEM_getChar(itemindex,ITEM_ARGUMENT); + if( itemarg == NULL ) return; + +// print("\n won test 10.0 ==> itemarg(%s)", itemarg ); + + for( i=0; i<3; i++ ){ + if( ITEM_getArgument( itemarg, Free[ i ], buf, sizeof(buf)) == TRUE ) { + dMagic = atoi( buf); +// print("\n won test 10.1 ==> i(%d) dMagic(%d)", i, dMagic ); + + if( dMagic <= 100 && dMagic >= -100 ){ + int def_magic = CHAR_getWorkInt( charaindex, CHAR_WORK_F_SUIT+i ); + CHAR_setWorkInt( charaindex, CHAR_WORK_F_SUIT+i, def_magic + dMagic); + +// print("\n won test 10.2 ==> i(%d)(%d)", i, CHAR_getWorkInt( charaindex, CHAR_WORK_F_SUIT+i ) ); + } + dMagic = 0; + } + } + + return; +} + + +void ITEM_P_MagicEquitReWear( int charaindex, int itemindex ) +{ + char buf[256] = {0}; + char *itemarg; + char Free[][128]={"FR","IR","TR"}; + int dMagic=0; + int i; + + itemarg = ITEM_getChar(itemindex,ITEM_ARGUMENT); + if( itemarg == NULL ) return; + +// print("\n won test 10.0 ==> itemarg(%s)", itemarg ); + + for( i=0; i<3; i++ ){ + if( ITEM_getArgument( itemarg, Free[ i ], buf, sizeof(buf)) == TRUE ) { + dMagic = atoi( buf); +// print("\n won test 10.1 ==> i(%d) dMagic(%d)", i, dMagic ); + + if( dMagic <= 100 && dMagic >= -100 ){ + int def_magic = CHAR_getWorkInt( charaindex, CHAR_WORK_F_SUIT+i ); + CHAR_setWorkInt( charaindex, CHAR_WORK_F_SUIT+i, def_magic - dMagic); + +// print("\n won test 10.2 ==> i(%d)(%d)", i, CHAR_getWorkInt( charaindex, CHAR_WORK_F_SUIT+i ) ); + } + dMagic = 0; + } + } + + return; + +} +#endif + + + +#ifdef _ITEM_WARP_FIX_BI +void recoverbi(int index) +{ + int eBbi=-1, eArm=-1, eNum=-1, eBi=-1, bi=-1; + + bi = CHAR_getInt( index, CHAR_BASEIMAGENUMBER); + eBbi = CHAR_getInt( index, CHAR_BASEBASEIMAGENUMBER); + eArm = CHAR_getItemIndex( index, CHAR_ARM); + eNum = ITEM_FIST; + if(ITEM_CHECKINDEX(eArm)) + eNum = ITEM_getInt( eArm, ITEM_TYPE); + + eBi = CHAR_getNewImagenumberFromEquip( eBbi, eNum); + + if(CHAR_getInt( index, CHAR_RIDEPET)!=-1) //骑宠 + CHAR_complianceParameter(index); + else //非骑宠 + if((eBi!=-1)&&(eBi!=bi)) + CHAR_setInt( index, CHAR_BASEIMAGENUMBER, eBi); +} +#endif + +#ifdef _ITEM_TIME_LIMIT +void ITEM_TimeLimit( int charaindex) +{ + int i = 0; + int iid = 0; + long lTime = 0; + char buff[256]; + + if( !CHAR_CHECKINDEX( charaindex) ) return; + for( i=0; i < CHAR_MAXITEMHAVE ; i++ ){ + int itemindex = CHAR_getItemIndex( charaindex , i ); + if( !ITEM_CHECKINDEX( itemindex ) ) continue; + lTime = ITEM_getWorkInt( itemindex, ITEM_WORKTIMELIMIT); + if( ITEM_getInt( itemindex, ITEM_ID) == 20173 //燃烧火把 + || ITEM_getInt( itemindex, ITEM_ID) == 20704 ){ + if( lTime > 0 && NowTime.tv_sec > lTime ){ + iid = ITEM_getInt( itemindex, ITEM_ID) + 1; + snprintf( buff, sizeof( buff), "%s的效果已消失..", ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, buff, CHAR_COLORGREEN); + CHAR_DelItemMess( charaindex, i, 0); + itemindex = ITEM_makeItemAndRegist( iid); + if(itemindex!=-1){ + CHAR_setItemIndex( charaindex, i, itemindex); + ITEM_setWorkInt( itemindex, ITEM_WORKOBJINDEX, -1); + ITEM_setWorkInt( itemindex, ITEM_WORKCHARAINDEX, charaindex); + CHAR_sendItemDataOne( charaindex, i); + } + } + } + } + +} +#endif + +#ifdef _BLACK_MARKET +void ITEM_BM_Exchange( int charaindex, int iindex) +{ + BOOL pckConfirm=FALSE; + int cdnConfirm=0; + int i, j, fd, id, itemindex, gTmp; + char sBuf[256]=""; + + fd = getfdFromCharaIndex( charaindex); + + if(!CHAR_CHECKINDEX( charaindex)) return; + if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE)!=BATTLE_CHARMODE_NONE) return; + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE)!=CHAR_PARTY_NONE) return; + if( CHAR_getFlg( charaindex, CHAR_ISTRADE)) return; + if( iindex==-1) return; + + for( i=0; i<12; i++){ + if(iindex==CONNECT_get_BMList( getfdFromCharaIndex( charaindex), i)){ + pckConfirm = TRUE; + break; + } + } + + if(pckConfirm){ + if(!BMItem[iindex].GCondition||BMItem[iindex].GCondition=CHAR_MAXITEMHAVE){ + print( "npc_exchange.c: ACCEPTadditem error itemindex[%d]\n", itemindex); + ITEM_endExistItemsOne( itemindex); + sprintf( sBuf, "交易失败..."); + CHAR_talkToCli( charaindex, -1, sBuf, CHAR_COLORRED); + return; + } + CHAR_sendItemDataOne( charaindex, ret); + } + gTmp = CHAR_getInt( charaindex, CHAR_GOLD); + gTmp -= BMItem[iindex].GCondition; + CHAR_setInt( charaindex, CHAR_GOLD, gTmp); + CHAR_complianceParameter( charaindex); + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_GOLD); + + sprintf( sBuf,"交出石币 %d", BMItem[iindex].GCondition); + CHAR_talkToCli( charaindex, -1, sBuf, CHAR_COLORWHITE); + // test shan shan + sprintf( sBuf, "....这个你就收下吧!!"); + CHAR_talkToCli( charaindex, -1, sBuf, CHAR_COLORYELLOW); + // add to Empty + for( i=0; i<12; i++){ + if(BMSellList[i]==iindex){ + BMSellList[i] = RAND(0, BMINum-1); + break; + } + } + for( i=0; i<12; i++) + CONNECT_set_BMList( getfdFromCharaIndex( charaindex), i, -1); + return; + } + } + } + sprintf( sBuf, "交易失败..."); + CHAR_talkToCli( charaindex, -1, sBuf, CHAR_COLORRED); +} +#endif + +#ifdef _ITEM_CONSTITUTION +void ITEM_Constitution( int charaindex, int toindex, int haveitemindex) +{ + char buf[256]; + char *itemarg; + char Free[][128]={"VI","ST","TG","DE"}; + int index=0, FixPoint=0, itemindex; + BOOL FIXs=FALSE; + int AllPoint=0; + + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ) + return; + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + + itemarg = ITEM_getChar( itemindex, ITEM_ARGUMENT); + if( itemarg == NULL ) return; + memset( buf, 0, sizeof( char) *256); + + AllPoint = CHAR_getInt( charaindex, CHAR_VITAL) + +CHAR_getInt( charaindex, CHAR_VITAL+1) + +CHAR_getInt( charaindex, CHAR_VITAL+2) + +CHAR_getInt( charaindex, CHAR_VITAL+3); + + while( index < arraysizeof( Free) ) { + if( ITEM_getArgument( itemarg, Free[ index], buf, sizeof(buf)) == TRUE ) { + FixPoint = atoi( buf); + if( FixPoint <= 100 && FixPoint > 0 ) { + int points = CHAR_getInt( charaindex, CHAR_VITAL+index); + //Change Fix + //if( points < (FixPoint*100) ) break; + if( points < (FixPoint*100) || AllPoint-(FixPoint*100) <= 0 ) + { + CHAR_talkToCli( charaindex, -1, "物品无效。", CHAR_COLORYELLOW); + return; + } + CHAR_setInt( charaindex, CHAR_VITAL+index, (points-(FixPoint*100))); + CHAR_setInt( charaindex, CHAR_SKILLUPPOINT, CHAR_getInt( charaindex, CHAR_SKILLUPPOINT) + FixPoint); + FIXs = TRUE; + } + FixPoint = 0; + } + index++; + if( (CHAR_VITAL+index) > CHAR_DEX ) + break; + } + CHAR_complianceParameter( charaindex); + CHAR_send_P_StatusString( charaindex, + CHAR_P_STRING_MAXHP|CHAR_P_STRING_HP|CHAR_P_STRING_LV|CHAR_P_STRING_EXP| + CHAR_P_STRING_ATK|CHAR_P_STRING_DEF|CHAR_P_STRING_QUICK| + CHAR_P_STRING_VITAL|CHAR_P_STRING_STR|CHAR_P_STRING_TOUGH|CHAR_P_STRING_DEX); + + CHAR_Skillupsend( charaindex); + memset( buf, 0, sizeof( buf)); + if( FIXs == TRUE ) { + sprintf( buf, "%s", "你的身体感到变化。"); + }else { + sprintf( buf, "%s", "物品无效。"); + } + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); +} +#endif + +#ifdef _NEW_RIDEPETS +void ITEM_useLearnRideCode( int charaindex, int toindex, int haveitemindex) +{//CHAR_LOWRIDEPETS + int itemindex, i; + char buf1[256]; + char *itemarg; + typedef struct{ + char arg[256]; + int Code; + }tagNewRideCode; + tagNewRideCode NewRides[12]={ + { "RIDE_PET0", RIDE_PET0}, { "RIDE_PET1", RIDE_PET1}, { "RIDE_PET2", RIDE_PET2}, + { "RIDE_PET3", RIDE_PET3}, { "RIDE_PET4", RIDE_PET4}, { "RIDE_PET5", RIDE_PET5}, + { "RIDE_PET6", RIDE_PET6}, { "RIDE_PET7", RIDE_PET7}, { "RIDE_PET8", RIDE_PET8}, + { "RIDE_PET9", RIDE_PET9}, { "RIDE_PET10", RIDE_PET10}, { "RIDE_PET11", RIDE_PET11} + }; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if(!ITEM_CHECKINDEX(itemindex)) return; + itemarg = ITEM_getChar( itemindex, ITEM_ARGUMENT); + if( itemarg == NULL ) return; + memset( buf1, 0, sizeof( buf1)); + if( getStringFromIndexWithDelim(itemarg,"|", 1, buf1, sizeof(buf1)) == FALSE ) + return; +#ifdef _FM_RIDE_PET + int fmRides=0; + switch( CHAR_getWorkInt( charaindex, CHAR_WORKFMFLOOR) ) + { + case 1041: + fmRides = RIDE_PET9; + break; + case 2031: + fmRides = RIDE_PET8; + break; + case 3031: + fmRides = RIDE_PET7; + break; + case 4031: + fmRides = RIDE_PET1; + break; + case 5031: + fmRides = RIDE_PET3; + break; + case 6031: + fmRides = RIDE_PET5; + break; + case 7031: + fmRides = RIDE_PET4; + break; + case 8031: + fmRides = RIDE_PET6; + break; + case 9031: + fmRides = RIDE_PET2; + break; + default: + fmRides = 0; + } +#endif + for( i=0; i<12; i++) { + if( !strcmp( NewRides[i].arg, buf1) ) { + int LRCode = CHAR_getInt( charaindex, CHAR_LOWRIDEPETS); + if( RIDE_PET0 == NewRides[i].Code + && CHAR_getInt( charaindex, CHAR_TRANSMIGRATION) < 5 + ){ + char token[256]; + memset( token, 0, sizeof( token)); + if( getStringFromIndexWithDelim(itemarg,"|", 2, buf1, sizeof(buf1)) != FALSE ){ + sprintf( token, "必须五转转人以上才能学习骑%s。",buf1); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + return;//机暴限五转 + } + } + if( (RIDE_PET10 == NewRides[i].Code || RIDE_PET11 == NewRides[i].Code) + && CHAR_getInt( charaindex, CHAR_TRANSMIGRATION) < 6 + ){ + char token[256]; + memset( token, 0, sizeof( token)); + if( getStringFromIndexWithDelim(itemarg,"|", 2, buf1, sizeof(buf1)) != FALSE ){ + sprintf( token, "必须六转人以上才能学习骑%s。",buf1); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + return;//新骑宠限六转 + } + } + if(((fmRides == NewRides[i].Code + && CHAR_getInt( charaindex, CHAR_FMLEADERFLAG ) != FMMEMBER_NONE + && CHAR_getInt( charaindex, CHAR_FMLEADERFLAG ) != FMMEMBER_APPLY) + || (RIDE_PET0 == NewRides[i].Code + || RIDE_PET10 == NewRides[i].Code + || RIDE_PET11 == NewRides[i].Code)) + || getFmridepet()==0) + { + LRCode = LRCode|NewRides[i].Code; + CHAR_setInt( charaindex, CHAR_LOWRIDEPETS, LRCode); + memset( buf1, 0, sizeof( buf1)); + if( getStringFromIndexWithDelim(itemarg,"|", 2, buf1, sizeof(buf1)) != FALSE ){ + char token[256]; + memset( token, 0, sizeof( token)); + sprintf( token, "学习了新的骑宠 (%s)。", buf1); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); + CHAR_sendStatusString( charaindex, "x"); + } + break; + }else{ + char token[256]; + memset( token, 0, sizeof( token)); + if( getStringFromIndexWithDelim(itemarg,"|", 2, buf1, sizeof(buf1)) != FALSE ){ + sprintf( token, "必须拥有该庄园的正式成员才能学习骑%s。",buf1); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + return; + } + } + } + } +} + +#endif + + + + + +#ifdef _ITEM_EDITBASES +void ITEM_useFusionEditBase( int charaindex, int toindex, int haveitemindex) +{ + int itemindex; + int work[4]={0,0,0,0}; + int anhour = PETFEEDTIME;//宠物 食时间(单位:秒) + + if( !CHAR_CHECKINDEX( charaindex ) ) return; + if( !CHAR_CHECKINDEX( toindex ) ) return; + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPET){ + CHAR_talkToCli( charaindex, -1, "物品仅限宠物使用。", CHAR_COLORYELLOW); + return; + } + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX(itemindex) ) return; + if( CHAR_getInt( toindex, CHAR_FUSIONBEIT) == 1 && + CHAR_getInt( toindex, CHAR_FUSIONRAISE) > 0 ){//检查是否为融合宠 + +#ifdef _TEST_PETFUSIONTIME +#else + int time_l; + int nowTime; // Robin fix + time_l = CHAR_getInt( toindex, CHAR_FUSIONTIMELIMIT); + nowTime = (int)time(NULL); +#if 1 // 消化药 + { + char *arg = NULL; + int deltime; + char msg[1024]; + arg = ITEM_getChar( itemindex, ITEM_ARGUMENT); + if( arg != NULL && !strncmp( arg, "消", 2) ) { + sscanf( arg, "消 %d", &deltime); + time_l -= (deltime*60); + CHAR_setInt( toindex, CHAR_FUSIONTIMELIMIT, time_l); + CHAR_DelItem( charaindex, haveitemindex); + sprintf( msg, "加快宠物蛋的消化速度 %d 分钟。", deltime); + CHAR_talkToCli( charaindex, -1, msg, CHAR_COLORYELLOW); + if( (time_l + anhour) <= nowTime ) { + int min, sec, deftime; + deftime = nowTime - (time_l + anhour); + min = deftime/60; + sec = deftime%60; + sprintf( msg, "宠物蛋已经可以 食了,超过 食时间%d分%d秒。", min, sec); + CHAR_talkToCli( charaindex, -1, msg, CHAR_COLORYELLOW); + return; + } + } + } +#endif + if( (time_l + anhour) > nowTime ){ //现在的时间要超过(time_l+anhour)才可以 食 + char Mess1[256]; + int min, sec, deftime; + //int nowTime = (int)time(NULL); + deftime = (time_l + anhour) - nowTime; + min = deftime/60; + sec = deftime%60; + sprintf( Mess1, "宠物蛋需过%d分%d秒才可 食。", min, sec); + CHAR_talkToCli( charaindex, -1, Mess1, CHAR_COLORYELLOW); + return; + } +#endif +//--------------------------------------------- + work[3] = CHAR_getInt( toindex, CHAR_EVOLUTIONBASEVTL); + work[0] = CHAR_getInt( toindex, CHAR_EVOLUTIONBASESTR); + work[1] = CHAR_getInt( toindex, CHAR_EVOLUTIONBASETGH); + work[2] = CHAR_getInt( toindex, CHAR_EVOLUTIONBASEDEX); + PET_showEditBaseMsg( charaindex, toindex, itemindex, work); + CHAR_setInt( toindex, CHAR_EVOLUTIONBASEVTL, work[3]); + CHAR_setInt( toindex, CHAR_EVOLUTIONBASESTR, work[0]); + CHAR_setInt( toindex, CHAR_EVOLUTIONBASETGH, work[1]); + CHAR_setInt( toindex, CHAR_EVOLUTIONBASEDEX, work[2]); +//--------------------------------------------- + LogPetPointChange( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), + CHAR_getChar( charaindex, CHAR_NAME), + toindex, 4, + CHAR_getInt( toindex, CHAR_LV), + "item_use", + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X ), + CHAR_getInt( charaindex, CHAR_Y ) + ); + + LogPetFeed( + CHAR_getChar( charaindex, CHAR_NAME), + CHAR_getChar( charaindex, CHAR_CDKEY), + CHAR_getChar( toindex, CHAR_NAME), + toindex, + CHAR_getInt( toindex, CHAR_LV), + ITEM_getChar( itemindex, CHAR_NAME), // Key + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y), + CHAR_getChar( toindex, CHAR_UNIQUECODE) ); + +#ifdef _PET_EVOLUTION + { + int raise = CHAR_getInt( toindex, CHAR_FUSIONRAISE); + CHAR_setInt( toindex, CHAR_FUSIONRAISE, --raise); + CHAR_setInt( toindex, CHAR_FUSIONTIMELIMIT, nowTime); + if( CHAR_getInt( toindex, CHAR_FUSIONRAISE) <= 0 ){//孵化 + char buf[256], buf1[256]; + int newindex; + sprintf( buf, "蛋〈%s〉孵化成", CHAR_getUseName( toindex )); + + newindex = EVOLUTION_createPetFromEnemyIndex( charaindex, toindex, 1); + if( !CHAR_CHECKINDEX( newindex) ){ + CHAR_talkToCli( charaindex, -1, "宠物孵化发生错误。", CHAR_COLORYELLOW); + return; + } + sprintf( buf1, "〈%s〉。", CHAR_getChar( newindex, CHAR_NAME)); + strcat( buf, buf1); + CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW); + + LogPetFeed( + CHAR_getChar( charaindex, CHAR_NAME), + CHAR_getChar( charaindex, CHAR_CDKEY), + CHAR_getChar( toindex, CHAR_NAME), + toindex, + CHAR_getInt( toindex, CHAR_LV), + buf, // Key + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y), + CHAR_getChar( toindex, CHAR_UNIQUECODE) ); + + } + } +#endif + }else { + CHAR_talkToCli( charaindex, -1, "???", CHAR_COLORYELLOW); + } + CHAR_DelItem( charaindex, haveitemindex); + return; +} +#endif + +#ifdef _THROWITEM_ITEMS +static int Niceitem = 0; + int golds[3]={ 10000, 20000, 50000}; + int items1[18] = { 13092, 13091, 20439, 20417, 1284, 20172, 18210, 19014, 18360, 18362, 18364, + 18359, 18356, 18357, 18510, 20418, 20419, 1452}; + int items2[11] = { 15842, 16136, 14334, 14034, 14634, 14934, 15534, 14934, 16432, 17057, 19695}; + + int items3[10] = { 16014, 16314, 14515, 14215, 14815, 15115, 15715, 15295, 16552, 17157}; + + int items4[18] = { 14516, 14513, 14216, 14213, 14816, 14813, 15116, 15716, 15415, 17360, 20279, + 20282, 20276, 20270, 20288, 20290, 20291, 20289}; + int items5[5] = { 20280, 20283, 20277, 20271, 20274}; + int items6[5] = { 20284, 20272, 20275, 20281, 20278}; +void ITEM_ThrowItemBox( int charaindex, int toindex, int haveitemindex) +{ + int i, ret, Iindex, ItemID=-1, itemindex; + char token[256]; + + if( !CHAR_CHECKINDEX(charaindex) ) return; + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX(itemindex) ) return; + + if( Niceitem > 10 ) ret = rand()%920; + else ret = rand()%1000; + + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE ; i++ ){ + Iindex = CHAR_getItemIndex( charaindex , i ); + if( !ITEM_CHECKINDEX(itemindex) ) continue; + if( itemindex == Iindex ){ + CHAR_DelItem( charaindex, i); + + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), +#endif + "WarpManDelItem", + CHAR_getInt( charaindex, CHAR_FLOOR), CHAR_getInt( charaindex, CHAR_X ), + CHAR_getInt( charaindex, CHAR_Y ), ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + break; + } + } + if( i >= CHAR_MAXITEMHAVE ){ + return; + } + + if( ret <= 774 ){ + int Golds=0; + Golds = golds[ RAND(0,2)]; + CHAR_AddGold( charaindex, Golds); + }else { + if( ret < 924 ){ + ItemID = items1[RAND(0,17)]; + }else if( ret < 964 ){ + ItemID = items2[RAND(0,10)]; + }else if( ret < 984 ){ + ItemID = items3[RAND(0,9)]; + Niceitem++; + }else if( ret < 994 ){ + ItemID = items4[RAND(0,17)]; + Niceitem++; + }else if( ret < 999 ){ + ItemID = items5[RAND(0,4)]; + Niceitem++; + }else { + ItemID = items6[RAND(0,4)]; + Niceitem++; + } + + Iindex = ITEM_makeItemAndRegist( ItemID); + if( !ITEM_CHECKINDEX( Iindex) ){ + return; + } + ret = CHAR_addItemSpecificItemIndex( charaindex, Iindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + ITEM_endExistItemsOne( Iindex); + return; + } + sprintf( token,"拿到%s", ITEM_getChar( Iindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW ); + CHAR_sendItemDataOne( charaindex, ret); + } +} +#endif + +#ifdef _ITEM_LOVERPARTY +void ITEM_LoverSelectUser( int charaindex, int toindex, int haveitemindex) +{ + int itemindex, i; + int playernum = CHAR_getPlayerMaxNum(); + + if( !CHAR_CHECKINDEX( charaindex ) ) return; + if( !CHAR_CHECKINDEX( toindex ) ) return; + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER){ + CHAR_talkToCli( charaindex, -1, "物品仅限人物使用。", CHAR_COLORYELLOW); + return; + } + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX(itemindex) ) return; + if( ITEM_getInt( itemindex, ITEM_TYPE) != 16 ){ + ITEM_setInt( itemindex, ITEM_TYPE, 16); + return; + } + if( !strcmp( ITEM_getChar( itemindex, ITEM_FORUSERNAME), "") || + !strcmp( ITEM_getChar( itemindex, ITEM_FORUSERCDKEY), "") ){//寻找设定对象 + if( charaindex == toindex ){ + CHAR_talkToCli( charaindex, -1, "不能选择自己使用。", CHAR_COLORYELLOW); + return; + } + ITEM_setChar( itemindex, ITEM_FORUSERNAME, CHAR_getChar( toindex, CHAR_NAME) ); + ITEM_setChar( itemindex, ITEM_FORUSERCDKEY, CHAR_getChar( toindex, CHAR_CDKEY) ); + ITEM_setInt( itemindex, ITEM_TARGET, 0); + { + char token[256]; + sprintf( token, "%s(%s)", + ITEM_getChar( itemindex, ITEM_SECRETNAME), CHAR_getChar( toindex, CHAR_NAME)); + ITEM_setChar( itemindex, ITEM_SECRETNAME, token); + sprintf( token, "传送对象设定为%s。", CHAR_getChar( toindex, CHAR_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + } + CHAR_sendItemDataOne( charaindex, haveitemindex); + }else{ + char buf1[256]; + //if( CHAR_getInt( charaindex, CHAR_FLOOR) == 117 || CHAR_getInt( charaindex, CHAR_FLOOR) == 887 || + //CHAR_getInt( charaindex, CHAR_FLOOR) == 1042 || CHAR_getInt( charaindex, CHAR_FLOOR) == 2032 || + //CHAR_getInt( charaindex, CHAR_FLOOR) == 3032 || CHAR_getInt( charaindex, CHAR_FLOOR) == 4032 || + //CHAR_getInt( charaindex, CHAR_FLOOR) == 5032 || CHAR_getInt( charaindex, CHAR_FLOOR) == 6032 || + //CHAR_getInt( charaindex, CHAR_FLOOR) == 7032 || CHAR_getInt( charaindex, CHAR_FLOOR) == 8032 || + //CHAR_getInt( charaindex, CHAR_FLOOR) == 9032 ){ + if( checkUnlawWarpFloor( CHAR_getInt( charaindex, CHAR_FLOOR) ) ) { + CHAR_talkToCli( charaindex, -1, "你的所在位置无法传送。", CHAR_COLORYELLOW ); + return; + } + + for( i=0; i= 10000) continue; + + if( (int)NowTime.tv_sec > (int)( OBJECT_getTime( objindex) + getItemdeletetime() ) ) { + + LogStone( + -1, + "NULL", + "NULL", + amount, + 0, + "Del(删除过时金钱)", + OBJECT_getFloor( objindex ), + OBJECT_getX( objindex ), + OBJECT_getY( objindex ) + ); + + CHAR_ObjectDelete(objindex); + } + } +} + +void GOLD_DeleteTimeCheckOne( int objindex) +{ + int amount; + + if( CHECKOBJECT( objindex ) == FALSE ) return; + if( OBJECT_getType( objindex) != OBJTYPE_GOLD) return; + + amount = OBJECT_getIndex( objindex); + if( amount >= 10000) return; + + if( (int)NowTime.tv_sec > (int)( OBJECT_getTime( objindex) + getItemdeletetime() ) ) { + + LogStone( + -1, + "NULL", + "NULL", + amount, + 0, + "Del(删除过时金钱)", + OBJECT_getFloor( objindex ), + OBJECT_getX( objindex ), + OBJECT_getY( objindex ) + ); + + CHAR_ObjectDelete(objindex); + } + +} + +#endif + +#ifdef _TIME_TICKET +void ITEM_timeticket( int charaindex, int toindex, int haveitemindex) +{ + ITEM_timeticketEx( charaindex, toindex, haveitemindex, 0); +} + +void ITEM_timeticketEx( int charaindex, int toindex, int haveitemindex, int flag) +{ + int itemindex; + int addtime; + int nowtime = time(NULL); + int tickettime; + int lefttime; + char msg[1024]; + + if( !CHAR_CHECKINDEX( charaindex ) ) return; + + if( check_TimeTicketMap( CHAR_getInt( charaindex, CHAR_FLOOR)) == FALSE + && flag == 0 ) { + CHAR_talkToCli( charaindex, -1, "这个地点不可使用。", CHAR_COLORYELLOW); + return; + } + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX(itemindex) ) return; + + tickettime = CHAR_getWorkInt( charaindex, CHAR_WORKTICKETTIME); + if( tickettime > nowtime+20 ) { + CHAR_talkToCli( charaindex, -1, "时间必须剩下20秒以内才可使用。", CHAR_COLORYELLOW); + return; + } + // 第一次使用的话 + if( tickettime == 0 ) { + tickettime = nowtime; + CHAR_setWorkInt( charaindex, CHAR_WORKTICKETTIMESTART, nowtime); + } + // 战斗中且超过时限时使用 + //if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE + // && tickettime < nowtime ) { + //tickettime = nowtime; + // sprintf(msg, "时间不足%d秒。", nowtime - tickettime ); + // CHAR_talkToCli( charaindex, -1, msg, CHAR_COLORYELLOW); + //} + + addtime = atoi( ITEM_getChar( itemindex, ITEM_ARGUMENT)); + tickettime += addtime; + CHAR_setWorkInt( charaindex, CHAR_WORKTICKETTIME, tickettime ); + lefttime = tickettime - nowtime; + if( lefttime > 0 ) + sprintf(msg, "时间增加%d秒,还剩下%d分%d秒。", addtime, lefttime/60, lefttime%60 ); + else + sprintf(msg, "时间增加%d秒,还不足%d分%d秒。", addtime, (-lefttime)/60, (-lefttime)%60 ); + CHAR_talkToCli( charaindex, -1, msg, CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); +} +#endif + +#ifdef _ITEM_SETLOVER +void ITEM_SetLoverUser( int charaindex, int toindex, int haveitemindex) +{ + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + int playernum = CHAR_getPlayerMaxNum(); + char token[256],*pActionNumber,szMsg[128]; + int floor = CHAR_getInt(charaindex,CHAR_FLOOR); + + if( !strcmp( CHAR_getChar( charaindex, CHAR_LOVE), "YES")) + { + CHAR_talkToCli( charaindex, -1, "重婚是违法的!您已经结婚了哦~", CHAR_COLORYELLOW); + return; + } + if( !CHAR_CHECKINDEX( charaindex ) ) return; + if( !CHAR_CHECKINDEX( toindex ) ) return; + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER) + { + CHAR_talkToCli( charaindex, -1, "只能和玩家结婚哦", CHAR_COLORYELLOW); + return; + } + if( CHAR_getInt(charaindex,CHAR_TRANSMIGRATION)<1 ||CHAR_getInt(toindex,CHAR_TRANSMIGRATION)<1) + { + CHAR_talkToCli( charaindex, -1, "如果想结婚的话,双方必须1转以上哦~", CHAR_COLORYELLOW); + return; + } + if( charaindex == toindex ) + { + CHAR_talkToCli( charaindex, -1, "难道您想和自己结婚吗?", CHAR_COLORYELLOW); + return; + } + if ( IsMale(charaindex)==IsMale(toindex)) + { + CHAR_talkToCli( charaindex, -1, "同性怎么结婚呢?", CHAR_COLORYELLOW); + return; + } + if( !ITEM_CHECKINDEX(itemindex) ) return; + int id = ITEM_getInt( itemindex, ITEM_ID); + itemindex = ITEM_makeItemAndRegist( id ); + + if( strcmp( CHAR_getChar( charaindex, CHAR_LOVE), "YES") && + strcmp( CHAR_getChar( toindex, CHAR_LOVE), "YES"))//第二次判断双方是否已经结婚 + { + if( itemindex != -1 ){ + CHAR_setChar( charaindex, CHAR_LOVERID, CHAR_getChar( toindex, CHAR_CDKEY) ); + CHAR_setChar( charaindex, CHAR_LOVERNAME, CHAR_getChar( toindex, CHAR_NAME) ); + if (strcmp(CHAR_getChar( toindex, CHAR_LOVERID), CHAR_getChar( charaindex, CHAR_CDKEY))==0 && + strcmp(CHAR_getChar( toindex, CHAR_LOVERNAME), CHAR_getChar( charaindex, CHAR_NAME))==0) + { + int i; + char szMsg1[16],*arg; + + sprintf( token, "已经答应了%s的求婚", CHAR_getChar( toindex, CHAR_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + sprintf( token, "%s已经响应了你的求婚", CHAR_getChar( charaindex, CHAR_NAME)); + CHAR_talkToCli( toindex, -1, token, CHAR_COLORYELLOW); + + CHAR_setChar( toindex, CHAR_LOVE,"YES"); + CHAR_setChar( charaindex, CHAR_LOVE,"YES"); + CHAR_setChar( charaindex, CHAR_LOVERID, CHAR_getChar( toindex, CHAR_CDKEY) ); + CHAR_setChar( charaindex, CHAR_LOVERNAME, CHAR_getChar( toindex, CHAR_NAME) ); + CHAR_setChar( toindex, CHAR_LOVERID, CHAR_getChar( charaindex, CHAR_CDKEY) ); + CHAR_setChar( toindex, CHAR_LOVERNAME, CHAR_getChar( charaindex, CHAR_NAME) ); + sprintf(szMsg,"%d 8 101883",floor); + CHAR_CHAT_DEBUG_effect(charaindex,szMsg); + CHAR_DelItem( charaindex, haveitemindex); + for(i=0;i=playernum) + { + CHAR_talkToCli( charaindex, -1, "很抱歉,您的爱人不在线哦~", CHAR_COLORYELLOW ); + return; + } + + if( !CHAR_CHECKINDEX( charaindex ) ) return; + if( !CHAR_CHECKINDEX( i ) ) return; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX(itemindex) ) return; + + if( checkUnlawWarpFloor( CHAR_getInt( charaindex, CHAR_FLOOR) ) ) { + CHAR_talkToCli( charaindex, -1, "很抱歉,您的爱人在神秘遥远地方,无法传送。", CHAR_COLORYELLOW ); + return; + }//UNWARP地图禁止使用 + if( checkUnlawWarpFloor( CHAR_getInt( i, CHAR_FLOOR) ) ) { + CHAR_talkToCli( charaindex, -1, "很抱歉,您的爱人在神秘遥远地方,无法传送。", CHAR_COLORYELLOW ); + return; + }//UNWARP地图禁止使用 + int itemmaxuse=0; + + if(strcmp(CHAR_getChar(i,CHAR_LOVERID),CHAR_getChar(charaindex,CHAR_CDKEY)) == 0 && + strcmp(CHAR_getChar(i,CHAR_LOVERNAME),CHAR_getChar(charaindex,CHAR_NAME)) == 0) + { + CHAR_DischargePartyNoMsg( charaindex);//解散团队 + int floor, x, y; + char token[256]; + floor = CHAR_getInt( i, CHAR_FLOOR); + x = CHAR_getInt( i, CHAR_X); + y = CHAR_getInt( i, CHAR_Y); + + CHAR_warpToSpecificPoint( charaindex, floor, x, y ); + sprintf( token, "%s:亲爱的,我来了!", CHAR_getChar( charaindex, CHAR_NAME)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW ); + sprintf( token, "已传送到爱人%s身边!", CHAR_getChar( i, CHAR_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW ); + print("\n玩家% 传送到玩家%s身边", CHAR_getChar( charaindex, CHAR_NAME),CHAR_getChar(i, CHAR_NAME)); + return; + } + }else + CHAR_talkToCli( charaindex, -1, "您没有结婚哦~", CHAR_COLORYELLOW ); +} + +void ITEM_LoverUnmarry( int charaindex, int toindex, int haveitemindex) +{ + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + int i; + char token[256]; + int playernum = CHAR_getPlayerMaxNum(); + //检查是否结婚 + if( !strcmp( CHAR_getChar( charaindex, CHAR_LOVE), "YES")) + { + for(i=0;i=playernum) + { + CHAR_talkToCli( charaindex, -1, "很抱歉,您的爱人不在线哦~", CHAR_COLORYELLOW ); + return; + } + + if( !CHAR_CHECKINDEX( charaindex ) ) return; + if( !CHAR_CHECKINDEX( i ) ) return; + if( !ITEM_CHECKINDEX(itemindex) ) return; + + if(strcmp(ITEM_getChar( itemindex, ITEM_SECRETNAME), "同意离婚戒指")){ + int id = ITEM_getInt( itemindex, ITEM_ID); + itemindex = ITEM_makeItemAndRegist( id ); + + if( itemindex != -1 ){ + + int emptyitemindexinchara = CHAR_findEmptyItemBox( toindex ); + + if( emptyitemindexinchara < 0 ){ + sprintf( token, "%s物品栏已满。离婚失败" , CHAR_getChar( i, CHAR_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + sprintf( token, "%s向您发起离婚,但您的物品栏已满。" , CHAR_getChar( charaindex, CHAR_NAME)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW);} + else{ + CHAR_setItemIndex( i, emptyitemindexinchara, itemindex); + ITEM_setChar( itemindex, ITEM_NAME, "同意离婚戒指"); + ITEM_setChar( itemindex, ITEM_SECRETNAME, "同意离婚戒指"); + sprintf( token, "%s向你申请离婚,如果同意请使用该戒指!", CHAR_getChar( charaindex, CHAR_NAME)); + ITEM_setChar( itemindex, ITEM_EFFECTSTRING, token); + CHAR_sendItemDataOne( i, emptyitemindexinchara); + ITEM_endExistItemsOne(itemindex); + sprintf( token, " %s向您提出离婚并把 %s 给你!", CHAR_getChar( charaindex, CHAR_NAME),ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW); + sprintf( token, "已经向%s发起离婚", CHAR_getChar( i, CHAR_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + CHAR_DelItem( charaindex, haveitemindex); + return;}} + }else{ + CHAR_setChar( i, CHAR_LOVE,""); + CHAR_setChar( i, CHAR_LOVERID,""); + CHAR_setChar( i, CHAR_LOVERNAME,""); + CHAR_setChar( charaindex, CHAR_LOVE,""); + CHAR_setChar( charaindex, CHAR_LOVERID,""); + CHAR_setChar( charaindex, CHAR_LOVERNAME,""); + CHAR_talkToCli( i, -1, "双方离婚成功!", CHAR_COLORYELLOW); + CHAR_talkToCli( charaindex, -1, "双方离婚成功!", CHAR_COLORYELLOW);} + CHAR_DelItem( charaindex, haveitemindex); + }else + CHAR_talkToCli( charaindex, -1, "您没有结婚哦~", CHAR_COLORYELLOW ); +} + + +#endif + +#ifdef _ITEM_METAMO +void ITEM_ColorMetamo( int charaindex, int toindex, int haveitemindex) +{ + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + char *itemarg,p; + int OldMetamoId, NewMetamoId; + itemarg=ITEM_getChar(itemindex,ITEM_ARGUMENT); + if( itemarg == NULL ) return; + OldMetamoId=CHAR_getInt( charaindex, CHAR_BASEBASEIMAGENUMBER); + if(OldMetamoId >= 100000 || OldMetamoId < 100240){ + if( strstr( itemarg, "红" ) ){ + CHAR_talkToCli( charaindex, -1, "变成红色", CHAR_COLORYELLOW); + if(((OldMetamoId%100)/10)%2==0) + NewMetamoId=(OldMetamoId/10)*10; + else + NewMetamoId=(OldMetamoId/10)*10-10; + }else if( strstr( itemarg, "绿" ) ){ + CHAR_talkToCli( charaindex, -1, "变成绿色", CHAR_COLORYELLOW); + if(((OldMetamoId%100)/10)%2==0) + NewMetamoId=(OldMetamoId/10)*10+5; + else + NewMetamoId=(OldMetamoId/10)*10-5; + }else if( strstr( itemarg, "黄" ) ){ + CHAR_talkToCli( charaindex, -1, "变成黄色", CHAR_COLORYELLOW); + if(((OldMetamoId%100)/10)%2==0) + NewMetamoId=(OldMetamoId/10)*10+10; + else + NewMetamoId=(OldMetamoId/10)*10; + }else if( strstr( itemarg, "灰" ) ){ + CHAR_talkToCli( charaindex, -1, "变成灰色", CHAR_COLORYELLOW); + if(((OldMetamoId%100)/10)%2==0) + NewMetamoId=(OldMetamoId/10)*10+15; + else + NewMetamoId=(OldMetamoId/10)*10+5; + }else if( strstr( itemarg, "随" ) ){ + srand(time(0)); + do + if(((OldMetamoId%100)/10)%2==0) + NewMetamoId=(OldMetamoId/10)*10+(rand()%4)*5; + else + NewMetamoId=(OldMetamoId/10)*10+(rand()%4)*5-10; + while(NewMetamoId==OldMetamoId); + CHAR_talkToCli( charaindex, -1, "随机变色成功", CHAR_COLORYELLOW); + }else{ + CHAR_talkToCli( charaindex, -1, "变色失败", CHAR_COLORYELLOW); + return;} + }else + CHAR_talkToCli( charaindex, -1, "变色失败,你造型并不是人物造型", CHAR_COLORYELLOW); + if(NewMetamoId==0)return; + CHAR_setInt( charaindex , CHAR_BASEIMAGENUMBER , NewMetamoId ); + CHAR_setInt( charaindex , CHAR_BASEBASEIMAGENUMBER , NewMetamoId ); + + CHAR_complianceParameter( charaindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + CHAR_DelItem( charaindex, haveitemindex); +} + +void ITEM_CharaMetamo( int charaindex, int toindex, int haveitemindex) +{ + int OldMetamoId=0, NewMetamoId=0; + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + char *itemarg,p; + itemarg=ITEM_getChar(itemindex,ITEM_ARGUMENT); + if( itemarg == NULL ) return; + OldMetamoId=CHAR_getInt( charaindex, CHAR_BASEBASEIMAGENUMBER); + if(OldMetamoId >= 100000 || OldMetamoId < 100240){ + if( strstr( itemarg, "豆丁囝" ) && OldMetamoId < 100120){ + CHAR_talkToCli( charaindex, -1, "更改造型为豆囝", CHAR_COLORYELLOW); + NewMetamoId=(OldMetamoId/1000)*1000+(OldMetamoId%20); + }else if( strstr( itemarg, "赛亚人" ) && OldMetamoId < 100120 ){ + CHAR_talkToCli( charaindex, -1, "更改造型为赛亚人", CHAR_COLORYELLOW); + NewMetamoId=(OldMetamoId/1000)*1000+20+(OldMetamoId%20); + }else if( strstr( itemarg, "辫子男孩" ) && OldMetamoId < 100120 ){ + CHAR_talkToCli( charaindex, -1, "更改造型为辫子男孩", CHAR_COLORYELLOW); + NewMetamoId=(OldMetamoId/1000)*1000+40+(OldMetamoId%20); + }else if( strstr( itemarg, "酷哥" ) && OldMetamoId < 100120 ){ + CHAR_talkToCli( charaindex, -1, "更改造型为酷哥", CHAR_COLORYELLOW); + NewMetamoId=(OldMetamoId/1000)*1000+60+(OldMetamoId%20); + }else if( strstr( itemarg, "熊皮男" ) && OldMetamoId < 100120 ){ + CHAR_talkToCli( charaindex, -1, "更改造型为熊皮男", CHAR_COLORYELLOW); + NewMetamoId=(OldMetamoId/1000)*1000+80+(OldMetamoId%20); + }else if( strstr( itemarg, "大只佬" ) && OldMetamoId < 100120 ){ + CHAR_talkToCli( charaindex, -1, "更改造型为大只佬", CHAR_COLORYELLOW); + NewMetamoId=(OldMetamoId/1000)*1000+100+(OldMetamoId%20); + }else if( strstr( itemarg, "随机" ) && OldMetamoId < 100120 ){ + srand(time(0)); + do + NewMetamoId=(OldMetamoId/1000)*1000+(rand()%6)*20+(OldMetamoId%20); + while(NewMetamoId==OldMetamoId); + CHAR_talkToCli( charaindex, -1, "随机更改造型成功", CHAR_COLORYELLOW); + } + if( strstr( itemarg, "豆丁囡" ) && OldMetamoId >= 100120 ){ + CHAR_talkToCli( charaindex, -1, "更改造型为豆丁囡", CHAR_COLORYELLOW); + NewMetamoId=(OldMetamoId/1000)*1000+120+(OldMetamoId%20); + }else if( strstr( itemarg, "熊皮妹" ) && OldMetamoId >= 100120 ){ + CHAR_talkToCli( charaindex, -1, "更改造型为熊皮妹", CHAR_COLORYELLOW); + NewMetamoId=(OldMetamoId/1000)*1000+140+(OldMetamoId%20); + }else if( strstr( itemarg, "帽子妹" ) && OldMetamoId >= 100120 ){ + CHAR_talkToCli( charaindex, -1, "更改造型为帽子妹", CHAR_COLORYELLOW); + NewMetamoId=(OldMetamoId/1000)*1000+160+(OldMetamoId%20); + }else if( strstr( itemarg, "短发夹妹" ) && OldMetamoId >= 100120 ){ + CHAR_talkToCli( charaindex, -1, "更改造型为短发夹妹", CHAR_COLORYELLOW); + NewMetamoId=(OldMetamoId/1000)*1000+180+(OldMetamoId%20); + }else if( strstr( itemarg, "手套女" ) && OldMetamoId >= 100120 ){ + CHAR_talkToCli( charaindex, -1, "更改造型为手套女", CHAR_COLORYELLOW); + NewMetamoId=(OldMetamoId/1000)*1000+200+(OldMetamoId%20); + }else if( strstr( itemarg, "辣妹" ) && OldMetamoId >= 100120 ){ + CHAR_talkToCli( charaindex, -1, "更改造型为辣妹", CHAR_COLORYELLOW); + NewMetamoId=(OldMetamoId/1000)*1000+220+(OldMetamoId%20); + }else if( strstr( itemarg, "随机" ) && OldMetamoId >= 100120 ){ + srand(time(0)); + do + NewMetamoId=(OldMetamoId/1000)*1000+(rand()%6)*20+120+(OldMetamoId%20); + while(NewMetamoId==OldMetamoId); + CHAR_talkToCli( charaindex, -1, "随机更改造型成功", CHAR_COLORYELLOW); + } + }else{ + CHAR_talkToCli( charaindex, -1, "你并不是人物造型!", CHAR_COLORYELLOW); + return; + } + if(NewMetamoId==0){ + CHAR_talkToCli( charaindex, -1, "你的性别不同,无没更改此造型!", CHAR_COLORYELLOW); + return;} + CHAR_setInt( charaindex , CHAR_BASEIMAGENUMBER , NewMetamoId ); + CHAR_setInt( charaindex , CHAR_BASEBASEIMAGENUMBER , NewMetamoId ); + + CHAR_complianceParameter( charaindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + CHAR_DelItem( charaindex, haveitemindex); +} + +void ITEM_SexMetamo( int charaindex, int toindex, int haveitemindex) +{ + int OldMetamoId, NewMetamoId; + OldMetamoId=CHAR_getInt( charaindex, CHAR_BASEBASEIMAGENUMBER); + if(OldMetamoId>=100000 && OldMetamoId <100020){ //豆丁囝 + NewMetamoId=OldMetamoId+120; + CHAR_talkToCli( charaindex, -1, "恭喜你变性成豆丁囡!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100020 && OldMetamoId <100040){ //赛亚人 + NewMetamoId=OldMetamoId+160; + CHAR_talkToCli( charaindex, -1, "恭喜你变性成短发夹妹!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100040 && OldMetamoId <100060){ //辫子男孩 + NewMetamoId=OldMetamoId+120; + CHAR_talkToCli( charaindex, -1, "恭喜你变性成帽子妹!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100060 && OldMetamoId <100080){ //酷哥 + NewMetamoId=OldMetamoId+160; + CHAR_talkToCli( charaindex, -1, "恭喜你变性成辣妹!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100080 && OldMetamoId <100100){ //熊皮男 + NewMetamoId=OldMetamoId+60; + CHAR_talkToCli( charaindex, -1, "恭喜你变性成熊皮妹!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100100 && OldMetamoId <100120){ //大只佬 + NewMetamoId=OldMetamoId+100; + CHAR_talkToCli( charaindex, -1, "恭喜你变性成手套女!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100120 && OldMetamoId <100140){ //豆丁囡 + NewMetamoId=OldMetamoId-120; + CHAR_talkToCli( charaindex, -1, "恭喜你变性成豆丁囝!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100140 && OldMetamoId <100160){ //熊皮妹 + NewMetamoId=OldMetamoId-60; + CHAR_talkToCli( charaindex, -1, "恭喜你变性成熊皮男!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100160 && OldMetamoId <100180){ //帽子妹 + NewMetamoId=OldMetamoId-120; + CHAR_talkToCli( charaindex, -1, "恭喜你变性成辫子男孩!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100180 && OldMetamoId <100200){ //短发夹妹 + NewMetamoId=OldMetamoId-160; + CHAR_talkToCli( charaindex, -1, "恭喜你变性成赛亚人!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100200 && OldMetamoId <100220){ //手套女 + NewMetamoId=OldMetamoId-100; + CHAR_talkToCli( charaindex, -1, "恭喜你变性成大只佬!", CHAR_COLORYELLOW); + }else if(OldMetamoId>=100220 && OldMetamoId <100240){ //辣妹 + NewMetamoId=OldMetamoId-160; + CHAR_talkToCli( charaindex, -1, "恭喜你变性成酷哥!", CHAR_COLORYELLOW); + }else{ + CHAR_talkToCli( charaindex, -1, "你并不是人物造型,无法变性!", CHAR_COLORYELLOW); + return;} + if(NewMetamoId==0)return; + CHAR_setInt( charaindex , CHAR_BASEIMAGENUMBER , NewMetamoId ); + CHAR_setInt( charaindex , CHAR_BASEBASEIMAGENUMBER , NewMetamoId ); + + CHAR_complianceParameter( charaindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + CHAR_DelItem( charaindex, haveitemindex); +} +#endif \ No newline at end of file diff --git a/gmsv/item/item_gen.c b/gmsv/item/item_gen.c new file mode 100644 index 0000000..75280f8 --- /dev/null +++ b/gmsv/item/item_gen.c @@ -0,0 +1,1889 @@ +/*********************************************** + * 失奶 丞宁岳″ + **********************************************/ +#include "version.h" +#include +#include +#include +#include +#include +#include +#include + +#include "configfile.h" +#include "util.h" +#include "buf.h" + +#include "char.h" +#include "item.h" +#include "item_gen.h" +#include "enemy.h" +#include "log.h" +#include "saacproto_cli.h" +#include "family.h" +#include "magic_base.h" + +#define DEBUGPRINT 0 +#define DEBUGPRINT_DETAIL 0 + +// shan begin +#define FOOD_HP_RATE 200 +#define FOOD_MP_RATE 200 +#define FOOD_SUCCESS_RATE 150 +#define FOOD_TURN_ADDPOINT 1 +// shan end + +static int ITEM_getTableNum( int num); + +/* 豳笺及袄及MAX袄 */ +#define ITEM_ATOMIND_MAX 1000 +// shan add +#define ITEM_ATOMIND_FM_MAX 4000 + +#define ITEM_RANDRANGEDOM 1000 +#ifdef _MERGE_NEW_8 // 1st +#define ITEM_RANDRANGEDOM_BASE 600 +#else +#define ITEM_RANDRANGEDOM_BASE 0 +#endif +// shan add +#define ITEM_FM_RANDRANGEDOM 4000 + +/*********************************************** + * (ITEM_GEN_RAND_MIN/1000) * ITEN_GEN_SEARCH_MIN + * - (ITEM_GEN_RAND_MAX/1000) * ITEN_GEN_SEARCH_MAX + * 仇木分仃及汔及豳笺及 区毛潸曰丹月仪卞卅月[ + **********************************************/ + +/* 豳笺及袄 及仿件母丞汔及 剂午 ㄠㄟㄟㄟ坌 */ +#define ITEM_GEN_RAND_MIN 700 +#define ITEM_GEN_RAND_MAX 1200 + +/* 失奶 丞毛腹绸允月豳笺及袄及汔及 剂午 及 (double) */ +#define ITEN_GEN_SEARCH_MIN (0.7) +#define ITEN_GEN_SEARCH_MAX (1.10) + +static struct tagItemSearchRangeTable { + double searchmin; + double searchmax; +}ItemSearchTable[2] = { +// { 0.7, 1.1}, +// shan add +// { 0.7, 1.3}, +// { 0.5, 1.5} + { 0.8, 1.2}, + { 0.7, 1.3} +}; + +static struct tagItemRandRangeTable { + int randmin; + int randmax; +}ItemRandTable[2] = { +// { 700, 1200}, + { 700, 1300}, + { 900, 1100} +}; + +#define ITEM_GEN_RATE 0.7 + +static struct _tagItemRandRangeTableForItem { + int num; /* 豳笺及备仿件弁及湘 袄 */ + int minnum; /* 仿件弁 潸曰丹月袄及Min */ + int maxnum; /* 仿件弁 潸曰丹月袄及MAX num +戚及仿件弁及犒*ITEM_GEN_RATE) */ + double rate; /* maxnum / num*/ +}ItemRandTableForItem[] = { + { 10, 0,0,0 }, + { 30, 0,0,0 }, + { 65, 0,0,0 }, + { 125, 0,0,0 }, + { 205, 0,0,0 }, + { 305, 0,0,0 }, + { 425, 0,0,0 }, + { 565, 0,0,0 }, + { 725, 0,0,0 }, + { 905, 0,0,0 }, + { 1125, 0,0,0 }, // shan add + { 1354, 0,0,0 }, + { 1594, 0,0,0 }, + { 1825, 0,0,0 }, + { 2105, 0,0,0 }, + { 2405, 0,0,0 }, + { 2725, 0,0,0 }, + { 3065, 0,0,0 }, + { 3425, 0,0,0 }, + { 3805, 0,0,0 } +}; + +#define ATOM_LEVEL_MAX 16 +struct item_atom +{ + char name[32]; + unsigned int name_hash; + int magicflg; +}; + + +struct item_atom *item_atoms; +int item_atoms_size; +#define MAX_ITEM_ATOMS_SIZE 256 + +struct item_ingindtable { + double data[MAX_ITEM_ATOMS_SIZE]; + int index; + int num; +}; + +static int ITEM_getAtomIndexByName( char *nm ) // 从素材名称取得素材index +{ + int i; + unsigned int h = hashpjw( nm ); + for( i = 0; i < item_atoms_size; i ++ ){ + if( item_atoms[i].name_hash == h && + strcmp( item_atoms[i].name, nm) == 0 ){ + return i; + } + } + return -1; +} + +#ifdef _ITEMTBL_STAIC +extern ITEM_table ITEM_tbl[28000]; +#else +extern ITEM_table *ITEM_tbl; +#endif + +struct ingcache +{ + int use; +#define MAXING_ONE 5 + int inguse; + int canmergefrom; + int canmergeto; + int hitnum; + int ingind[MAXING_ONE]; + int ingval[MAXING_ONE]; +}; + +int ITEM_initRandTable( void) +{ + int i; + for( i = 0; i < arraysizeof( ItemRandTableForItem); i ++) { + if( i == 0 ) ItemRandTableForItem[i].minnum = 0; + else { + ItemRandTableForItem[i].minnum = ItemRandTableForItem[i-1].maxnum+1; + } + if( i + 1 != arraysizeof( ItemRandTableForItem)) { + ItemRandTableForItem[i].maxnum = + ItemRandTableForItem[i].num + + (ItemRandTableForItem[i+1].num - ItemRandTableForItem[i].num) + *ITEM_GEN_RATE; + + } + else { + // shan add + ItemRandTableForItem[i].maxnum = 4000; + //ItemRandTableForItem[i].maxnum = 1000; + } + ItemRandTableForItem[i].rate = ItemRandTableForItem[i].maxnum + / (double)ItemRandTableForItem[i].num; + } + /*for( i = 0; i < arraysizeof( ItemRandTableForItem); i ++) { + print( "\ntable num:[%d] min:[%d] max:[%d] rate:[%3.3f] ", + ItemRandTableForItem[i].num, + ItemRandTableForItem[i].minnum, + ItemRandTableForItem[i].maxnum, + ItemRandTableForItem[i].rate); + }*/ + return TRUE; +} + +static struct ingcache *icache; +int icache_num; + +#ifdef _IMPOROVE_ITEMTABLE +int ADD_ICACHE_INGRED( int ItemID) +{ + char *itemarg; + int i, nk=0; + + for( i=0; i<5; i++){ + itemarg = ITEMTBL_getChar( ItemID, ITEM_INGNAME0+i);//成分名 + if( itemarg == NULL ) continue; + if( itemarg[0] ){ + icache[ItemID].ingind[nk] = ITEM_getAtomIndexByName( itemarg); + if( icache[ItemID].ingind[nk] < 0 ){ + + print( "fuck ing[%s][%d] for %d %s\n", + itemarg, + ITEMTBL_getInt( ItemID, ITEM_INGVALUE0+i), + ITEMTBL_getInt( ItemID, ITEM_ID), + ITEMTBL_getChar( ItemID, ITEM_NAME) ); + + }else { + icache[ItemID].ingval[nk] = ITEMTBL_getInt( ItemID, ITEM_INGVALUE0+i); + nk++; + } + } + } + return nk; +} + +int ITEM_initItemIngCache( void ) +{ + int i; + print ( "初始化物品缓冲: 最大ID数:%d\n", ITEM_getItemMaxIdNum( ) ); + icache_num = ITEM_getMaxitemtblsFromTransList( ); + + icache = allocateMemory( sizeof( struct ingcache ) * icache_num ); + if( icache == NULL ){ + print( "初始化物品缓冲: 没有物品\n" ); + return FALSE; + } + print( "初始化物品缓冲: 读取物品数=%d\n", icache_num); + remove( "icache.txt"); + + memset( icache, 0, icache_num * sizeof( struct ingcache) ); + for( i=0; i= MAX_ITEM_ATOMS_SIZE ){ + print( "初始化物品成份: 物品成份太多了\n" ); + return FALSE; + } + + item_atoms_size = count; + print( "初始化物品成份: 读取 %d 物品成份...", count ); + + return TRUE; +} + +/* + + 刭醒及伊□玄 + + base 互 100 匹 min 互 0.7 匹 max 互 1.3 分匀凶日} + 70 ~ 130 卞剽域卞坌 允月[午曰丐尹内剽域[ + 剽域元扎卅仁仄凶曰允月井手仄木卅中及匹} + 失奶 丞毁迕伙□民件午仄化仇仇卞烂聒允月 by ringo 1999Oct1 + 1000坌及min_rate,max_rate匹健丹[ + double 支float 反]支支仇仄中及匹银歹卅中[ + */ +static int +ITEM_randRange( int base, int min_rate , int max_rate ) +{ + int minnum; + int maxnum; + int range; + +#ifdef _MERGE_LOG + print("\n物品队列(基本:%d, 最小价格%d, 最大价格:%d) ", base, min_rate, max_rate); +#endif + + if( min_rate > max_rate) { + int tmp; + tmp = min_rate; + min_rate = max_rate; + max_rate = tmp; + } + minnum = rint((double)base / ITEM_RANDRANGEDOM * min_rate); + maxnum = rint((double)base / ITEM_RANDRANGEDOM * max_rate); + range = ( maxnum - minnum ); + + if( min_rate == max_rate && min_rate == 0 ) return 0; + if( range == 0 ) return base; + if( range < 0 ) return 0; + +#ifdef _MERGE_LOG + print("\n最後下限:%d 最後上限:%d ", minnum, minnum+range); +#endif + + return minnum + RAND( 0, range); +} + +typedef int (*FUNC)( const void *, const void * ); + +static int cmprutine( double *p1, double *p2) +{ + if( *p1 < *p2 ) return -1; + if( *p1 > *p2 ) return 1; + return 0; +} +/* + * 嫖中及卞丐歹六月 + * 忒曰袄反 互中仁勾卞卅匀凶井[ + * 宁歹六月蟆卞]末□玄仄化岈屯化] + * table卞梯匀凶 坌]箫仄化中仁[ + */ + +static void ITEM_simplify_atoms( struct item_ingindtable *inds, int num, + int *retinds, int *retvals, int petindex, int alchemist) +{ + //int newinds[MAX_ITEM_ATOMS_SIZE]; + //int newvals[MAX_ITEM_ATOMS_SIZE]; + int i; + double oddstable[] = { + 0.1, + 0.25, + 0.35, + 0.4, + 0.42, + 0.44, + 0.46, + 0.47, + 0.48, + 0.49, + 0.5, + 0.51, + 0.52, + 0.53 + }; +#if 0 + double oddstable[] = { + 0.08, + 0.224, + 0.315, + 0.37, + 0.395, + 0.405, + 0.415, + 0.42, + 0.425, + 0.43, + 0.435, + 0.44, + 0.445, + 0.45 + }; + double oddstable[] = { + 0.05, + 0.175, + 0.247, + 0.305, + 0.342, + 0.361, + 0.37, + 0.375, + 0.379, + 0.382, + 0.387, + 0.39, + 0.393, + 0.396 + }; +#endif + for( i = 0; i < num; i ++ ) { + int datacnt = (inds + i)->num; + if( datacnt > 1 ) { + int j; + qsort( (inds + i)->data, datacnt, + sizeof( double ), (FUNC)cmprutine); + for( j = 1; j < datacnt; j ++ ) { + int tablenum; + double rate; + tablenum = ITEM_getTableNum( (inds + i)->data[j-1]); + rate = ItemRandTableForItem[tablenum].rate / ItemRandTableForItem[0].rate; + (inds + i)->data[j] += (inds + i)->data[j-1] * oddstable[j-1] * rate; + } + } + *(retinds + i) = ( inds + i)->index; + *(retvals + i) = (int)( inds + i)->data[ datacnt-1]; + // shan add begin + if( petindex != -1 ){ +#ifdef _MERGE_NEW_8 + /*if( alchemist ) { // 使用守护兽精 时无上限 // 改:皆有上限 + if (CHAR_getInt(petindex, CHAR_PETFAMILY) == 1){ + if( *( retvals + i) > ITEM_ATOMIND_FM_MAX ){ + *( retvals + i) = ITEM_ATOMIND_FM_MAX; + } + }else{ + if( *( retvals + i) > ITEM_ATOMIND_MAX ){ + *( retvals + i) = ITEM_ATOMIND_MAX; + } + } + } + else */ + { // 非精 时有上限 + if( *( retvals + i) > ITEM_ATOMIND_MAX ){ + *( retvals + i) = ITEM_ATOMIND_MAX; + } + } +#else + if (CHAR_getInt(petindex, CHAR_PETFAMILY) == 1){ + if( *( retvals + i) > ITEM_ATOMIND_FM_MAX ){ + *( retvals + i) = ITEM_ATOMIND_FM_MAX; + } + }else{ + if( *( retvals + i) > ITEM_ATOMIND_MAX ){ + *( retvals + i) = ITEM_ATOMIND_MAX; + } + } +#endif + } + // shan end + } +} + +/* +PET_ADD_INGRED( nm,vl1,vl2,vl3) +{ + if( strlen( ENEMYTEMP_getChar( petarray, nm)) != 0 ) + { + fixatom[ingnum] =ITEM_getAtomIndexByName( ENEMYTEMP_getChar( petarray, nm) ); + if( fixatom[ingnum] < 0 ) + { + print( "\nfucking atom:[%s] for pet id %d", ENEMYTEMP_getChar( petarray, nm), petid ); + continue; + } + + baseup[ingnum] = ENEMYTEMP_getInt( petarray, vl1); + minadd[ingnum] = ENEMYTEMP_getInt( petarray, vl2); + maxadd[ingnum] = ENEMYTEMP_getInt( petarray, vl3); + + if( petindex != -1) + { + if( CHAR_getInt(petindex, CHAR_PETFAMILY) == 1 ) + { + int ownerindex = CHAR_getWorkInt(petindex, CHAR_WORKPLAYERINDEX); + if (!CHAR_CHECKINDEX(ownerindex)) + { + print("ownerindex err!\n"); + return; + } + if( CHAR_getInt( ownerindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER) + { + print("\n Pet Ownerindex Error"); + return; + } + baseup[ingnum] = PetLv[getFmLv(ownerindex)]; + } + } + + if( minadd[ingnum] > maxadd[ingnum] ) + { + int tmp = minadd[ingnum]; + minadd[ingnum] = maxadd[ingnum];maxadd[ingnum] = tmp; + } + + if( CHAR_getInt(petid, CHAR_PETFAMILY) == 1 ) + { + if( minadd[ingnum]<0 ) + minadd[ingnum] = ITEM_FM_RANDRANGEDOM; + if( maxadd[ingnum]<0 ) + maxadd[ingnum] = ITEM_FM_RANDRANGEDOM; + } + else + { + if( minadd[ingnum]<0 ) + minadd[ingnum] = ITEM_RANDRANGEDOM; + if( maxadd[ingnum]<0 ) + maxadd[ingnum] = ITEM_RANDRANGEDOM; + } + ingnum++; + } +} +*/ + + +#ifdef _MERGE_NEW_8 +int PET_ADD_INGRED( int nm, int vl1, int vl2, int vl3, + int petindex, int petarray, int petid, int ingnum, + int *baseup, int *minadd, int *maxadd, int *fixatom ) +{ + // 家族修正 守护兽时用 + int PetLv[] = { 0, 77, 108, 145, 188, 237, 292, 353, 420, 493, 572}; + // 家族(个人)修正 非守护兽时用 + //int PetLvPersonal[] = { 0, 77, 108, 145, 188, 237, 292, 353, 420, 493, 572}; + + if( strlen( ENEMYTEMP_getChar( petarray, nm)) != 0 ) { + fixatom[ingnum] =ITEM_getAtomIndexByName( ENEMYTEMP_getChar( petarray, nm) ); + if( fixatom[ingnum] < 0 ) { + print( "\nfucking atom:[%s] for pet id %d", ENEMYTEMP_getChar( petarray, nm), petid ); + return 1; //continue; + } + baseup[ingnum] = ENEMYTEMP_getInt( petarray, vl1); + minadd[ingnum] = ITEM_RANDRANGEDOM_BASE + ENEMYTEMP_getInt( petarray, vl2); + maxadd[ingnum] = ITEM_RANDRANGEDOM_BASE + ENEMYTEMP_getInt( petarray, vl3); + + if( petindex != -1) { + int ownerindex = CHAR_getWorkInt(petindex, CHAR_WORKPLAYERINDEX); + + if (!CHAR_CHECKINDEX(ownerindex)) { + print("宠物主人错误\n"); + return 2; // just return; + } + + if( CHAR_getInt(petindex, CHAR_PETFAMILY) == 1 ) { + if( CHAR_getInt( ownerindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER) { + print("宠物主人错误\n"); + CHAR_talkToCli( ownerindex, -1, "非族长不能用守护兽加工唷!", CHAR_COLORYELLOW); + return 2; // just return; + } + baseup[ingnum] = PetLv[getFmLv(ownerindex)]; + } + else { // 8.0新增 + baseup[ingnum] = PetLv[getFameLv(ownerindex)]; + } + } + + if( minadd[ingnum] > maxadd[ingnum] ) { + int tmp = minadd[ingnum]; + minadd[ingnum] = maxadd[ingnum]; + maxadd[ingnum] = tmp; + } + + if( CHAR_getInt(petid, CHAR_PETFAMILY) == 1 ) { + if( minadd[ingnum]<0 ) + minadd[ingnum] = ITEM_FM_RANDRANGEDOM; + if( maxadd[ingnum]<0 ) + maxadd[ingnum] = ITEM_FM_RANDRANGEDOM; + } + else { + if( minadd[ingnum]<0 ) + minadd[ingnum] = ITEM_RANDRANGEDOM; + if( maxadd[ingnum]<0 ) + maxadd[ingnum] = ITEM_RANDRANGEDOM; + } + ingnum++; + } +} +#endif + +/* + 矢永玄及ID井日}刭醒及膜恳涩烂毛潸曰分允[ + + int *fixuse : 袄瑛绊娄醒[ 及 醒毛午曰}烂聒醒毛中木化井尹允 + + int *fixatom : 升及豳笺卞覆允月膜恳卅及井 + int *baseup : 湘 袄卞凶中允月笛遥 + int *minadd : 井仃遥及 凝卞凶中允月笛遥 + int *maxadd : 井仃遥及 卞凶中允月笛遥 + + */ + +static void +ITEM_merge_getPetFix( int petid, int *fixuse, int *fixatom, + int *baseup, + int *minadd, + int *maxadd, + int petindex, + int *fm_fix) +{ + int i; + int ingnum = 0; + int petarray; + +// shan begin +#define FamilyLv 11 + //int PetLv[FamilyLv]; + //for(i=0; i maxadd[ingnum] ) { int tmp = minadd[ingnum];minadd[ingnum] = maxadd[ingnum];maxadd[ingnum] = tmp;}if( CHAR_getInt(petid, CHAR_PETFAMILY) == 1 ){if( minadd[ingnum]<0 ) minadd[ingnum] = ITEM_FM_RANDRANGEDOM;if( maxadd[ingnum]<0 ) maxadd[ingnum] = ITEM_FM_RANDRANGEDOM;}else{if( minadd[ingnum]<0 ) minadd[ingnum] = ITEM_RANDRANGEDOM;if( maxadd[ingnum]<0 ) maxadd[ingnum] = ITEM_RANDRANGEDOM;}ingnum++;} +#define PET_ADD_INGRED( nm,vl1,vl2,vl3) if( strlen( ENEMYTEMP_getChar( petarray, nm)) != 0 ) { fixatom[ingnum] =ITEM_getAtomIndexByName( ENEMYTEMP_getChar( petarray, nm) ); if( fixatom[ingnum] < 0 ){ print( "\nfucking atom:[%s] for pet id %d", ENEMYTEMP_getChar( petarray, nm), petid ); continue;} baseup[ingnum] = ENEMYTEMP_getInt( petarray, vl1); minadd[ingnum] = ITEM_RANDRANGEDOM_BASE + ENEMYTEMP_getInt( petarray, vl2); maxadd[ingnum] = ITEM_RANDRANGEDOM_BASE + ENEMYTEMP_getInt( petarray, vl3); if( petindex != -1){ if( CHAR_getInt(petindex, CHAR_PETFAMILY) == 1 ){ int ownerindex = CHAR_getWorkInt(petindex, CHAR_WORKPLAYERINDEX); if (!CHAR_CHECKINDEX(ownerindex)){print("ownerindex err!\n");return;}if( CHAR_getInt( ownerindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER){print("\n Pet Ownerindex Error");return;}baseup[ingnum] = PetLv[getFmLv(ownerindex)];}}if( minadd[ingnum] > maxadd[ingnum] ) { int tmp = minadd[ingnum];minadd[ingnum] = maxadd[ingnum];maxadd[ingnum] = tmp;}if( CHAR_getInt(petid, CHAR_PETFAMILY) == 1 ){if( minadd[ingnum]<0 ) minadd[ingnum] = ITEM_FM_RANDRANGEDOM;if( maxadd[ingnum]<0 ) maxadd[ingnum] = ITEM_FM_RANDRANGEDOM;}else{if( minadd[ingnum]<0 ) minadd[ingnum] = ITEM_RANDRANGEDOM;if( maxadd[ingnum]<0 ) maxadd[ingnum] = ITEM_RANDRANGEDOM;}ingnum++;} +#else +#define PET_ADD_INGRED( nm,vl1,vl2,vl3) if( strlen( ENEMYTEMP_getChar( petarray, nm)) != 0 ) { fixatom[ingnum] =ITEM_getAtomIndexByName( ENEMYTEMP_getChar( petarray, nm) ); if( fixatom[ingnum] < 0 ){ print( "\nfucking atom:[%s] for pet id %d", ENEMYTEMP_getChar( petarray, nm), petid ); continue;} baseup[ingnum] = ENEMYTEMP_getInt( petarray, vl1); minadd[ingnum] = ENEMYTEMP_getInt( petarray, vl2); maxadd[ingnum] = ENEMYTEMP_getInt( petarray, vl3); if( petindex != -1){ if( CHAR_getInt(petindex, CHAR_PETFAMILY) == 1 ){ int ownerindex = CHAR_getWorkInt(petindex, CHAR_WORKPLAYERINDEX); if (!CHAR_CHECKINDEX(ownerindex)){print("ownerindex err!\n");return;}if( CHAR_getInt( ownerindex, CHAR_FMLEADERFLAG) != 1){print("\n Pet Ownerindex Error");return;}baseup[ingnum] = PetLv[getFmLv(ownerindex)];}}if( minadd[ingnum] > maxadd[ingnum] ) {int tmp = minadd[ingnum];minadd[ingnum] = maxadd[ingnum];maxadd[ingnum] = tmp;}if( CHAR_getInt(petid, CHAR_PETFAMILY) == 1 ){if( minadd[ingnum]<0 ) minadd[ingnum] = ITEM_FM_RANDRANGEDOM;if( maxadd[ingnum]<0 ) maxadd[ingnum] = ITEM_FM_RANDRANGEDOM;}else{if( minadd[ingnum]<0 ) minadd[ingnum] = ITEM_RANDRANGEDOM;if( maxadd[ingnum]<0 ) maxadd[ingnum] = ITEM_RANDRANGEDOM;}ingnum++;} +#endif + +#ifdef _MERGE_NEW_8 +#undef PET_ADD_INGRED + ret = PET_ADD_INGRED( E_T_ATOMFIXNAME1, E_T_ATOMBASEADD1, E_T_ATOMFIXMIN1, E_T_ATOMFIXMAX1, petindex, petarray, petid, ingnum, baseup, minadd, maxadd, fixatom ); + if( ret == 1 ) continue; else if( ret == 2 ) return; + ret = PET_ADD_INGRED( E_T_ATOMFIXNAME2, E_T_ATOMBASEADD2, E_T_ATOMFIXMIN2, E_T_ATOMFIXMAX2, petindex, petarray, petid, ingnum, baseup, minadd, maxadd, fixatom ); + if( ret == 1 ) continue; else if( ret == 2 ) return; + ret = PET_ADD_INGRED( E_T_ATOMFIXNAME3, E_T_ATOMBASEADD3, E_T_ATOMFIXMIN3, E_T_ATOMFIXMAX3, petindex, petarray, petid, ingnum, baseup, minadd, maxadd, fixatom ); + if( ret == 1 ) continue; else if( ret == 2 ) return; + ret = PET_ADD_INGRED( E_T_ATOMFIXNAME4, E_T_ATOMBASEADD4, E_T_ATOMFIXMIN4, E_T_ATOMFIXMAX4, petindex, petarray, petid, ingnum, baseup, minadd, maxadd, fixatom ); + if( ret == 1 ) continue; else if( ret == 2 ) return; + ret = PET_ADD_INGRED( E_T_ATOMFIXNAME5, E_T_ATOMBASEADD5, E_T_ATOMFIXMIN5, E_T_ATOMFIXMAX5, petindex, petarray, petid, ingnum, baseup, minadd, maxadd, fixatom ); + if( ret == 1 ) continue; else if( ret == 2 ) return; +#else + PET_ADD_INGRED( E_T_ATOMFIXNAME1, E_T_ATOMBASEADD1, E_T_ATOMFIXMIN1, E_T_ATOMFIXMAX1); + PET_ADD_INGRED( E_T_ATOMFIXNAME2, E_T_ATOMBASEADD2, E_T_ATOMFIXMIN2, E_T_ATOMFIXMAX2); + PET_ADD_INGRED( E_T_ATOMFIXNAME3, E_T_ATOMBASEADD3, E_T_ATOMFIXMIN3, E_T_ATOMFIXMAX3); + PET_ADD_INGRED( E_T_ATOMFIXNAME4, E_T_ATOMBASEADD4, E_T_ATOMFIXMIN4, E_T_ATOMFIXMAX4); + PET_ADD_INGRED( E_T_ATOMFIXNAME5, E_T_ATOMBASEADD5, E_T_ATOMFIXMIN5, E_T_ATOMFIXMAX5); +#endif + +#ifdef _MERGE_LOG + print("\n %d.[ me:%s, min%d, b:%d, max:%d]", i, ENEMYTEMP_getChar( petarray, E_T_ATOMFIXNAME1+i), + minadd[i], baseup[i], maxadd[i]); +#endif + } + + if( CHAR_getInt(petindex, CHAR_PETFAMILY) == 1 ) { + int ownerindex = CHAR_getWorkInt(petindex, CHAR_WORKPLAYERINDEX); + if( CHAR_CHECKINDEX(ownerindex) ) { + *fm_fix = PetLv[getFmLv(ownerindex)]; + } + } + + *fixuse = ingnum; + return; +} + +/* + * 公及 互]宁岳葭失奶 丞卞丐匀凶日FALSE毛忒允 + */ + +static BOOL ITEM_merge_checkitem( ITEM_Item *items, int itemsnum, int id) +{ + int loop; + for( loop = 0; loop < itemsnum; loop ++ ) { + if( items[loop].data[ITEM_ID] == id ) break; + } + if( loop == itemsnum ) return TRUE; + return FALSE; +} + +static int ITEM_merge_with_retry( ITEM_Item *items,int itemsnum, + int *ingindtable, int ingnum, + int *ingtable, int searchtable, int petindex ) +{ + + int ideal; + int idel_num[5][5] = { { 0}, + { 250,0 }, + { 400,150,0}, + { 700,260,70,0}, + { 740,500,200,40,0} + }; + int endflg[5]; + BOOL first = TRUE; + int extractcnt = 0; +#define MAXMATCH 2048 + int matchid[MAXMATCH]; + int i,j,k; + + + if( ingnum > 5 ) ideal = 5; + else ideal = ingnum; + memset( endflg, 0, sizeof( endflg)); + while( 1 ) { + int r = RAND( 0, 999); + int extractnum; + int match = 0; + if( extractcnt >= ideal ) break; + // 计算合成道具的必须材料数 + for( extractnum = 0; extractnum < ideal; extractnum ++ ) { + if( r >= idel_num[ideal-1][extractnum] ) { + break; + } + } + if( endflg[extractnum] == TRUE ) continue; + endflg[extractnum] = TRUE; + extractcnt++; + extractnum = ideal - ( extractnum ); + + if( first ) { + for( i = 0; i < icache_num; i++ ){ // 搜寻全部ITEM + if( icache[i].use && icache[i].canmergeto) { // 如果是可合成的ITEM + icache[i].hitnum = 0; + for( j = 0; j < icache[i].inguse; j ++ ) { // 这个ITEM的材料数 + for( k = 0; k < ingnum ; k ++){ // 合成的材料数 + if( icache[i].ingind[j] == ingindtable[k] ) { // 材料符合 + if( searchtable == 0 ) { // 道具合成的话 + int tablenum = ITEM_getTableNum( ingtable[k]); // 材料等级 + // shan begin + if( petindex != -1){ + if( CHAR_getInt(petindex, CHAR_PETFAMILY) == 1 ){ // 如果是守护兽的话 + int ownerindex = CHAR_getWorkInt(petindex, CHAR_WORKPLAYERINDEX); + int familyLevel = getFmLv(ownerindex); + if (!CHAR_CHECKINDEX(ownerindex)){ + print("主人索引错误!\n"); + return -1; + } +#ifdef _FMVER21 + if( CHAR_getInt( ownerindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER){ +#else + if( CHAR_getInt( ownerindex, CHAR_FMLEADERFLAG) != 1){ +#endif + print("\n 宠物主人索引错误"); + return -1; + } + // 需符合上下限 + if( icache[i].ingval[j] <= ingtable[k]*ItemRandTableForItem[tablenum].rate && + icache[i].ingval[j] >= ingtable[k]*(1/ItemRandTableForItem[tablenum].rate) && + icache[i].ingval[j] <= ItemRandTableForItem[familyLevel+9].maxnum) { + icache[i].hitnum++; + break; + } + }else{ // 非守护兽的话 + float toplimit = ingtable[k]*ItemRandTableForItem[tablenum].rate; + if( toplimit > 1000) toplimit = 1000; + // 需符合上下限 + if( icache[i].ingval[j] <= toplimit && + icache[i].ingval[j] >= ingtable[k]*(1/ItemRandTableForItem[tablenum].rate)){ + icache[i].hitnum++; + break; + } + } + } + // shan end + }else { // 食物合成的话 + // shan begin + if( CHAR_getInt(petindex, CHAR_PETFAMILY) == 1 ){ + int ownerindex = CHAR_getWorkInt(petindex, CHAR_WORKPLAYERINDEX); + int familyLevel = getFmLv(ownerindex); + if (!CHAR_CHECKINDEX(ownerindex)){ + print("主人索引错误!\n"); + return -1; + } +#ifdef _FMVER21 + if( CHAR_getInt( ownerindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER){ +#else + if( CHAR_getInt( ownerindex, CHAR_FMLEADERFLAG) != 1){ +#endif + print("\n 宠物主人索引错误"); + return -1; + } + if( ingtable[k] > ItemRandTableForItem[familyLevel+9].maxnum / + ItemSearchTable[searchtable].searchmax ){ + ingtable[k] = ItemRandTableForItem[familyLevel+9].maxnum / + ItemSearchTable[searchtable].searchmax; + } + }else{ + if( ingtable[k] > ItemRandTableForItem[9].maxnum / + ItemSearchTable[searchtable].searchmax ){ + ingtable[k] = ItemRandTableForItem[9].maxnum / + ItemSearchTable[searchtable].searchmax; + } + } + // shan end + + if( icache[i].ingval[j] <= ingtable[k]*ItemSearchTable[searchtable].searchmax && + icache[i].ingval[j] >= ingtable[k]*ItemSearchTable[searchtable].searchmin){ + icache[i].hitnum++; + break; + } + } + } + } + } + // 符合的材料数必须相同 + if( icache[i].hitnum == icache[i].inguse && icache[i].hitnum == extractnum ){ + if( ITEM_merge_checkitem(items,itemsnum,i)) { + matchid[match++] = i; + } + } + } + } + first = FALSE; + }else { + for( i = 0; i < icache_num; i++ ){ + if( icache[i].use && icache[i].canmergeto) { + if( icache[i].hitnum == icache[i].inguse && icache[i].hitnum == extractnum ){ + if( ITEM_merge_checkitem(items,itemsnum,i)) { + matchid[match++] = i; + } + } + } + } + } +#ifdef _MERGE_LOG + print("\n 必须符合的材料数(乱数):%d \n", extractnum); + + { + int j; + + for( j =0; j 0 ) { + int i; + + print("\n matchid[%d]={",match); + for( i=0; i 0 ) { + return matchid[ random() % match ]; + }else { + + } + } + return -1; + +} + +#ifdef _NEW_MANOR_LAW +extern struct FM_POINTLIST fmpointlist; +#endif + +int ITEM_mergeItem( int charaindex, ITEM_Item *items, int num , int money, int petid, int searchtable, int petindex, int alchemist) +{ + int i; + + // shan add + int item_type = -1; + int ingnum =0; + struct item_ingindtable ingindtable[MAX_ITEM_ATOMS_SIZE]; + int sortedingindtable[MAX_ITEM_ATOMS_SIZE]; + int sortedingtable[MAX_ITEM_ATOMS_SIZE]; + /* 矢永玄卞方月膜恳迕 */ + int pet_fixatom[MAX_ITEM_ATOMS_SIZE]; + int pet_baseup[MAX_ITEM_ATOMS_SIZE]; + int pet_minadd[MAX_ITEM_ATOMS_SIZE]; + int pet_maxadd[MAX_ITEM_ATOMS_SIZE]; + int pet_fixuse = MAX_ITEM_ATOMS_SIZE; + int fm_fix; + + int nowtime; + + nowtime = time( NULL); + // 如果合成封包过於频繁... + if( nowtime - CHAR_getWorkInt( charaindex, CHAR_WORKLASTMERGETIME) < 5+(num-2) ) { + CHAR_setWorkInt( charaindex, CHAR_WORKLASTMERGETIME, nowtime); + //CHAR_talkToCli( charaindex, -1 ,"合成料理过於频繁,休息一下比较好哟。", CHAR_COLORRED); + print(" 合成频繁 "); + return items[RAND( 0, (num-1))].data[ITEM_ID]; + } + CHAR_setWorkInt( charaindex, CHAR_WORKLASTMERGETIME, nowtime); + + for( i = 0; i < arraysizeof( ingindtable); i ++ ) { + int j; + for( j = 0; j < MAX_ITEM_ATOMS_SIZE; j ++ ) { + ingindtable[i].data[j] = 0.0; + } + ingindtable[i].num = 0; + ingindtable[i].index = -1; + } + for(i=0; i ItemRandTableForItem[familyLevel+9].maxnum ){ + sortedingtable[i] = RAND(ItemRandTableForItem[familyLevel+9].minnum, + ItemRandTableForItem[familyLevel+9].maxnum); + } + }else{ + sortedingtable[i] = ITEM_randRange( sortedingtable[i], + ItemRandTable[searchtable].randmin , + ItemRandTable[searchtable].randmax); + } + } + else{ + if( searchtable == 0 ) { + sortedingtable[i] = ITEM_randRange( sortedingtable[i], + ((1/ItemRandTableForItem[tablenum].rate)*ITEM_MERGE_RANGEWIDTH_FORMIN) + * ITEM_RANDRANGEDOM, + ItemRandTableForItem[tablenum].rate * ITEM_MERGE_RANGEWIDTH_FORMAX + * ITEM_RANDRANGEDOM); + if(sortedingtable[i] > 905) sortedingtable[i] = 905; + } + else { + sortedingtable[i] = ITEM_randRange( sortedingtable[i], + ItemRandTable[searchtable].randmin , + ItemRandTable[searchtable].randmax); + } + } + } + // shan end + } + } +#ifdef _MERGE_LOG + { + int k; + //char mergech[][256] = {"石","木","骨","牙","皮","线","贝壳","壳","材9","材10","材11","材12","材13","材14","材15","材16"}; + for( k=0;k<5;k++) { + print("\n merger(宠物能力配上)(材料): %d.[ %s, %d]", + k, /*mergech[ sortedingindtable[k]]*/item_atoms[ sortedingindtable[k]].name, sortedingtable[k]); + } + } +#endif + + if( ingnum == 0 ) + return -1; + { + int created; + for( i = 0 ; i < 5; i++ ) { + created = ITEM_merge_with_retry( items, num, sortedingindtable,ingnum, + sortedingtable, searchtable, petindex); + if( created >= 0 ) { + // shan begin + if( petindex != -1){ +#ifdef _FMVER21 +#else + if( CHAR_getInt( CHAR_getWorkInt(petindex, CHAR_WORKPLAYERINDEX), CHAR_FMLEADERFLAG ) > 0 ){ +#endif + int kind_num = 0; + int syndp = 0; + int fooddp = 0; + char buf[64]; + int ownerindex = CHAR_getWorkInt(petindex, CHAR_WORKPLAYERINDEX); + if (!CHAR_CHECKINDEX(ownerindex)){ + print("ownerindex err!\n"); + return -1; + } + if( searchtable == 1 ){ + + if( ITEMTBL_getInt( created, ITEM_INGVALUE0) != 0 ) kind_num++; + if( ITEMTBL_getInt( created, ITEM_INGVALUE1) != 0 ) kind_num++; + if( ITEMTBL_getInt( created, ITEM_INGVALUE2) != 0 ) kind_num++; + if( ITEMTBL_getInt( created, ITEM_INGVALUE3) != 0 ) kind_num++; + if( ITEMTBL_getInt( created, ITEM_INGVALUE4) != 0 ) kind_num++; + + fooddp = ITEMTBL_getInt( created, ITEM_INGVALUE0) + + ITEMTBL_getInt( created, ITEM_INGVALUE1) + + ITEMTBL_getInt( created, ITEM_INGVALUE2) + + ITEMTBL_getInt( created, ITEM_INGVALUE3) + + ITEMTBL_getInt( created, ITEM_INGVALUE4); +#ifndef _NEW_MANOR_LAW + #ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + fooddp = sqrt(fooddp) * pow(2,kind_num-2) * RAND(0,6) / 200; + #else + fooddp = sqrt(fooddp) * pow(2,kind_num-2) * RAND(0,6) / 100; + #endif + print("FoodDP: num->%d sumdp->%d", kind_num, fooddp); + sprintf(buf, "%d", fooddp); + + #ifdef _PERSONAL_FAME // Arminius 8.30: 家族个人声望 + CHAR_earnFame(ownerindex, fooddp); + #endif + + #ifdef _FMVER21 + if( CHAR_getInt( CHAR_getWorkInt(petindex, CHAR_WORKPLAYERINDEX), CHAR_FMLEADERFLAG ) > 0 && + CHAR_getInt( CHAR_getWorkInt(petindex, CHAR_WORKPLAYERINDEX), CHAR_FMLEADERFLAG ) != FMMEMBER_APPLY ) + { + // CoolFish: 2001/10/03 + int fd = getfdFromCharaIndex(ownerindex); + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(ownerindex, CHAR_FMNAME), + CHAR_getInt(ownerindex, CHAR_FMINDEX), + CHAR_getWorkInt(ownerindex, CHAR_WORKFMINDEXI), + FM_FIX_FMDEALFOOD, buf, "", + // CoolFish: 2001/10/03 + CHAR_getWorkInt(ownerindex, CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(fd)); + // CHAR_getWorkInt(ownerindex, CHAR_WORKFMCHARINDEX), 0); + } + #else + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(ownerindex, CHAR_FMNAME), + CHAR_getInt(ownerindex, CHAR_FMINDEX), + CHAR_getWorkInt(ownerindex, CHAR_WORKFMINDEXI), + FM_FIX_FMDEALFOOD, buf, "", + CHAR_getWorkInt(ownerindex, CHAR_WORKFMCHARINDEX), 0); + #endif +#endif + }else{ + int ownerindex = CHAR_getWorkInt(petindex, CHAR_WORKPLAYERINDEX); + syndp = ITEMTBL_getInt( created, ITEM_INGVALUE0) + + ITEMTBL_getInt( created, ITEM_INGVALUE1) + + ITEMTBL_getInt( created, ITEM_INGVALUE2) + + ITEMTBL_getInt( created, ITEM_INGVALUE3) + + ITEMTBL_getInt( created, ITEM_INGVALUE4); +#ifndef _NEW_MANOR_LAW + #ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + syndp = syndp / 200; + #else + syndp = syndp / 100; + #endif + sprintf(buf, "%d", syndp); + + #ifdef _PERSONAL_FAME // Arminius 8.30: 家族个人声望 + CHAR_earnFame(ownerindex, syndp); + #endif + + #ifdef _FMVER21 + if( CHAR_getInt( CHAR_getWorkInt(petindex, CHAR_WORKPLAYERINDEX), CHAR_FMLEADERFLAG ) > 0 && + CHAR_getInt( CHAR_getWorkInt(petindex, CHAR_WORKPLAYERINDEX), CHAR_FMLEADERFLAG ) != FMMEMBER_APPLY ) + { + // CoolFish: 2001/10/03 + int fd = getfdFromCharaIndex(ownerindex); + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(ownerindex, CHAR_FMNAME), + CHAR_getInt(ownerindex, CHAR_FMINDEX), + CHAR_getWorkInt(ownerindex, CHAR_WORKFMINDEXI), + FM_FIX_FMSYNTHESIZE, buf, "", + // CoolFish: 2001/10/03 + CHAR_getWorkInt(ownerindex, CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(fd)); + } + #else + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(ownerindex, CHAR_FMNAME), + CHAR_getInt(ownerindex, CHAR_FMINDEX), + CHAR_getWorkInt(ownerindex, CHAR_WORKFMINDEXI), + FM_FIX_FMSYNTHESIZE, buf, "", + CHAR_getWorkInt(ownerindex, CHAR_WORKFMCHARINDEX), 0); + #endif +#endif + } +#ifdef _FMVER21 +#else + } +#endif + } + // shan end +#ifdef _MERGE_LOG + print( "\nANDY merged: item[%s] atom[%s]:[%d] [%s]:[%d] [%s]:[%d] [%s]:[%d] [%s]:[%d]", + ITEMTBL_getChar( created, ITEM_NAME), + ITEMTBL_getChar( created, ITEM_INGNAME0), + ITEMTBL_getInt( created, ITEM_INGVALUE0), + ITEMTBL_getChar( created, ITEM_INGNAME1), + ITEMTBL_getInt( created, ITEM_INGVALUE1), + ITEMTBL_getChar( created, ITEM_INGNAME2), + ITEMTBL_getInt( created, ITEM_INGVALUE2), + ITEMTBL_getChar( created, ITEM_INGNAME3), + ITEMTBL_getInt( created, ITEM_INGVALUE3), + ITEMTBL_getChar( created, ITEM_INGNAME4), + ITEMTBL_getInt( created, ITEM_INGVALUE4) ); +#endif + /* + #ifdef _ACTION_BULLSCR + if( CHAR_CHECKINDEX( charaindex) && (CHAR_getInt( charaindex, CHAR_ABULLSTART) == 10) ){ + int cTableLevel=0, adScore=0; + char buf1[256]; + int Myscore = CHAR_getInt( charaindex, CHAR_ABULLSCORE); + memset( buf1, 0, sizeof( buf1)); + cTableLevel = ITEM_getTableNum( ITEMTBL_getInt( created, ITEM_INGVALUE0)); + if( cTableLevel >= 15 ) adScore = 4; + else if( cTableLevel >= 6 ) adScore = 1; + else adScore = 0; + if( adScore > 0 ){ + sprintf( buf1, "合成料理等级:%d,增加绩分:%d,总共绩分:%d。", + cTableLevel, adScore, Myscore+adScore); + CHAR_setInt( charaindex, CHAR_ABULLSCORE, Myscore+adScore); + }else{ + sprintf( buf1, "合成料理等级:%d,需等级6以上才加分。", + cTableLevel); + } + CHAR_talkToCli( charaindex, -1, buf1, CHAR_COLORYELLOW); + } + #endif + */ + return created; + } + } + return items[RAND( 0, (num-1))].data[ITEM_ID]; + } + return -3; +} + +int ITEM_canDigest( ITEM_Item *itm ) +{ + /* 1蜊 及笺 及 蟆互涩烂今木化中凶日1} + 公丹匹卅中卅日0 */ + if( itm->string[ITEM_INGNAME0].string[0] ) return 1; else return 0; +} + + + +int ITEM_merge_test(void) +{ + int iid,i,k; + ITEM_Item itm[1]; + + for( k = 0 ; k < 10 ; k ++ ){ + iid = 1; + for( i = 0 ; i < 20 ; i ++ ){ + ITEM_makeItem( &itm[0] , iid ); + print( "%d RETURN: %d\n", i, + // shan + iid = ITEM_mergeItem( -1, itm, 1 , 0, -1,0,-1,0) ); + } + print( "------\n" ); + } + return 0; +} + +int ITEM_mergeItem_merge( int charaindex, int petid, char *data, int petindex, int alchemist) +{ + BOOL result = FALSE; + int i; + int ret; + int cnt = 0; + int itemindexs[CHAR_MAXITEMHAVE - CHAR_STARTITEMARRAY]; + int haveitemindexs[CHAR_MAXITEMHAVE - CHAR_STARTITEMARRAY]; + // Nuke +2 1026: Avoid merge cheat + int itemflag[CHAR_MAXITEMHAVE - CHAR_STARTITEMARRAY]; + int j,collision=0; + + char buff[64]; + + ITEM_Item items[CHAR_MAXITEMHAVE - CHAR_STARTITEMARRAY]; + // Nuke +1 1026 + memset(itemflag,0,sizeof(itemflag)); + + { + int emptyindex = CHAR_findEmptyItemBox( charaindex ); + if( emptyindex == -1 ){ + CHAR_talkToCli( charaindex, -1, "合成时,最少需空一格物品栏位!", CHAR_COLORYELLOW); + return -1; + } + } + + for( i = CHAR_STARTITEMARRAY; i < CHAR_MAXITEMHAVE; i ++ ) { + int haveitemindex; + ret = getStringFromIndexWithDelim( data , "|", + i - CHAR_STARTITEMARRAY+1, + buff, sizeof( buff ) ); + if( ret == FALSE ) break; + haveitemindex = atoi( buff); + if( CHAR_CHECKITEMINDEX( charaindex, haveitemindex) ) { + int itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( ITEM_CHECKINDEX( itemindex)) { +#ifdef _ITEM_INSLAY + char *code; + if( (code = ITEM_getChar( itemindex, ITEM_TYPECODE)) == NULL ) { + if( strcmp( code, "\0") ) { + char token[256]; + snprintf( token, sizeof( token), "似乎对%s没有兴趣。", + ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + return FALSE; + } + } +#endif + if( ITEM_getmergeItemFromFromITEMtabl( ITEM_getInt( itemindex, ITEM_ID)) == TRUE ){ //检查是否可合成 + ITEM_Item *itm; + itm = ITEM_getItemPointer(itemindex); + if( itm != NULL ) { + ITEM_makeItem( &items[cnt], ITEM_getInt( itemindex, ITEM_ID)); + itemindexs[cnt] = itemindex; + haveitemindexs[cnt] = haveitemindex; + // Nuke start 1026 + for (j=0;j 1 ) { + int randtable = 0; + if( items[0].data[ITEM_TYPE] == ITEM_DISH ) { + randtable = 1; + } + ret = ITEM_mergeItem( charaindex, items, cnt, 0, petid, randtable, petindex, alchemist); + if( ret == -10) + CHAR_talkToCli( charaindex, -1, "非法的合成方法", CHAR_COLORWHITE); + CHAR_setInt( charaindex, CHAR_MERGEITEMCOUNT, + CHAR_getInt( charaindex, CHAR_MERGEITEMCOUNT)+1); + + for( i = 0; i < cnt; i ++ ) { +#ifdef _ITEM_PILENUMS + int pilenum=0; + int itemindex = CHAR_getItemIndex( charaindex, haveitemindexs[i]); + if( !ITEM_CHECKINDEX( itemindex) ) continue; + pilenum = ITEM_getInt( itemindex, ITEM_USEPILENUMS); + pilenum -= 1; + ITEM_setInt( itemindex, ITEM_USEPILENUMS, pilenum); + if( pilenum <= 0 ){ +#endif + CHAR_setItemIndex( charaindex, haveitemindexs[i], -1); + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindexs[i], +#else + ITEM_getInt( itemindexs[i], ITEM_ID), /* 失奶 丞 寞 */ +#endif + "mergedel(合成所删除的道具)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( itemindexs[i], ITEM_UNIQUECODE), + ITEM_getChar( itemindexs[i], ITEM_NAME), + ITEM_getInt( itemindexs[i], ITEM_ID) + ); + + ITEM_endExistItemsOne( itemindexs[i]); +#ifdef _ITEM_PILENUMS + } +#endif + } + CHAR_sendItemData( charaindex, haveitemindexs, cnt); + + if( ret >= 0 ) { + int rc; + int createitemindex = ITEM_makeItemAndRegist( ret); +#ifdef _MERGE_LOG + print("\n merge[ret:%d]", ret); + print("\n merge[createitemindex:%d]", createitemindex); +#endif + // shan begin + if( createitemindex != -1 ){ + if( petindex != -1){ + if( CHAR_getInt(petindex, CHAR_PETFAMILY) == 1 ){ + int ownerindex = CHAR_getWorkInt(petindex, CHAR_WORKPLAYERINDEX); + if (!CHAR_CHECKINDEX(ownerindex)){ + print("ownerindex err!\n"); + return -1; + } +#ifdef _FMVER21 + if( CHAR_getInt( ownerindex, CHAR_FMLEADERFLAG) != FMMEMBER_LEADER){ +#else + if( CHAR_getInt( ownerindex, CHAR_FMLEADERFLAG) != 1){ +#endif + print("\n Pet Ownerindex Error"); + return -1; + } + if( randtable == 1){ + char *p; + char charbuf1[512]="",charbuf2[1024]="",charbuf[128]=""; + char argbuf[256]; + int arg1 = 0, arg2 = 0; + if( ITEM_getInt( createitemindex, ITEM_TYPE) == 20){ + if( (p = strstr( ITEM_getChar(createitemindex, ITEM_ARGUMENT), "气")) ){ + strcpy( argbuf, (p+2)); + arg1 = atoi(argbuf); + arg1 = arg1 * FOOD_MP_RATE / 100; + } + if( (p = strstr( ITEM_getChar(createitemindex, ITEM_ARGUMENT), "体")) ){ + strcpy( argbuf, (p+2)); + arg2 = atoi(argbuf); + arg2 = arg2 * FOOD_HP_RATE / 100; + } + if( arg1 != 0 && arg2 != 0 ){ + sprintf( charbuf1, "气%d体%d", arg1, arg2); + } + else if( arg1 != 0){ + sprintf( charbuf1, "气%d", arg1); + } + else if( arg2 != 0){ + sprintf( charbuf1, "体%d", arg2); + } + sprintf( charbuf, "(家族料理)"); + strcpy( charbuf2, ITEM_getChar( createitemindex, ITEM_EFFECTSTRING)); + strncat( charbuf2, charbuf, 10); + ITEM_setChar( createitemindex, ITEM_ARGUMENT, charbuf1); + ITEM_setChar( createitemindex, ITEM_EFFECTSTRING, charbuf2); + } + } + } + } + } + // shan end + ITEM_setInt( createitemindex, ITEM_MERGEFLG, TRUE); + if( createitemindex != -1 ) { + rc = CHAR_addItemSpecificItemIndex( charaindex, createitemindex); + if( rc >= 0 && rc < CHAR_MAXITEMHAVE) { + CHAR_sendItemDataOne( charaindex, rc); + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + createitemindex, +#else + ITEM_getInt( createitemindex, ITEM_ID), +#endif + "mergeadd(合成出来的道具)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + ITEM_getChar( createitemindex, ITEM_UNIQUECODE), + ITEM_getChar( createitemindex, ITEM_NAME), + ITEM_getInt( createitemindex, ITEM_ID) + ); + result = TRUE; + } + else { + ITEM_endExistItemsOne( createitemindex); + } + } + } + } + return result; +} + +static int ITEM_getTableNum( int num) +{ + int i; + for( i = 0; i < arraysizeof( ItemRandTableForItem); i ++) { + if( num <= ItemRandTableForItem[i].maxnum ) { + break; + } + } + if( i == arraysizeof( ItemRandTableForItem)) i--; + return i; +} + +#ifdef _ITEM_INSLAY +int PETSKILL_ITEM_inslay( int charindex, int inslayindex, int itemindex) +{ + char *inslaystr , *code; + char buf1[256], buf2[256]; + char codeTemp[][32]={ "NULL", "NULL", "NULL"}; + char TypeName[][256]={ + "攻", "防", "敏", "HP", "MP", "幸运", "伤", "吸", "魔法ID" + }; + int worktyp[] = { + ITEM_MODIFYATTACK, ITEM_MODIFYDEFENCE, ITEM_MODIFYQUICK, + ITEM_MODIFYHP, ITEM_MODIFYMP, ITEM_MODIFYLUCK, + ITEM_OTHERDAMAGE, ITEM_OTHERDEFC, ITEM_MAGICID + }; + int worknum[ arraysizeof(worktyp)]; + + int i; +#define MAXCANINSLAY 3 + + memset( worknum, 0, sizeof( worknum)); + if( !CHAR_CHECKINDEX( charindex) ) return FALSE; + if( !ITEM_CHECKINDEX( inslayindex) ) return FALSE; + if( !ITEM_CHECKINDEX( itemindex) ) return FALSE; + if( itemindex == inslayindex ) return FALSE; + if( (code = ITEM_getChar( itemindex, ITEM_TYPECODE)) == NULL ) { + print(" ITEM_TYPECODE == NULL error !!\n"); + return FALSE; + } + if( !strcmp( code, "\0") || !strcmp( code, "NULL" ) ) return FALSE; + if( (inslaystr = ITEM_getChar( inslayindex, ITEM_INLAYCODE)) == NULL ) { + print(" ITEM_INLAYCODE == NULL error !!\n"); + return FALSE; + } + + for( i = 0; i < MAXCANINSLAY; i ++ ) { + if( getStringFromIndexWithDelim( inslaystr , "|", i+1, buf1, sizeof( buf1 ) ) == TRUE ){ + if( strcmp( buf1, "\0")){ + sprintf( codeTemp[i], "%s", buf1); + } + continue; + } + break; + } + + for( i = 0; i < MAXCANINSLAY; i ++ ) { + if( strcmp( codeTemp[i], "NULL") ) continue; + sprintf( codeTemp[i], "%s", code); + break; + } + if( i == MAXCANINSLAY ) { + CHAR_talkToCli( charindex, -1, "武器或防具已经镶满了。", CHAR_COLORYELLOW); + return FALSE; + } + memset( buf2, 0, sizeof( buf2)); + sprintf( buf2, "%s|%s|%s", codeTemp[0], codeTemp[1], codeTemp[2]); + print("buf2:%s\n", buf2); + ITEM_setChar( inslayindex, ITEM_INLAYCODE, buf2); + + for( i=0; i 0 ) { //魔法 ID + int magicid,mp; + magicid = ITEM_getInt( itemindex, ITEM_MAGICID); + ITEM_setInt( inslayindex, ITEM_MAGICID, magicid); + mp = ITEM_getInt( itemindex, ITEM_MAGICUSEMP ); + ITEM_setInt( inslayindex, ITEM_MAGICUSEMP, mp); + } + for( i=ITEM_FIRSTFUNCTION; i 0 ) { //取得魔法名称 + int marray = MAGIC_getMagicArray( ITEM_getInt( inslayindex, ITEM_MAGICID)); + if( marray != -1 ){ + if( (magicname = MAGIC_getChar( marray, MAGIC_NAME)) != NULL ){ + sprintf( Mname, "%s", magicname); + } + } + ITEM_setInt( inslayindex, ITEM_MAGICID, ITEM_getInt( inslayindex, ITEM_MAGICID)); + } + sprintf( secretname, "%s%s%d %s%s%d %s%s%d %s%s%d %s%s%d %s%s%d %s%s%d %s", + TypeName[0],(worknum[0]>=0)?"+":"",worknum[0], + TypeName[1],(worknum[1]>=0)?"+":"",worknum[1], + TypeName[2],(worknum[2]>=0)?"+":"",worknum[2], + TypeName[3],(worknum[3]>=0)?"+":"",worknum[3], + TypeName[4],(worknum[4]>=0)?"+":"",worknum[4], + TypeName[6],(worknum[6]>=0)?"+":"",worknum[6], + TypeName[7],(worknum[7]>=0)?"+":"",worknum[7], Mname); + ITEM_setChar( inslayindex, ITEM_EFFECTSTRING, secretname); + } + + return TRUE; +} + +#endif + +#ifdef _PETSKILL_FIXITEM +int PETSKILL_ITEM_FixItem( int charindex, int fixindex, int *itemindex) +{ + int index, i; + char *buf2; + int crushes, maxcrushes; +#define MAXFIXNUM 2 + index = 0; + for( i=0; i= 5 ){ +#ifdef _ITEM_FIXALLBASE + char *ITEM_ARG = ITEM_getChar( index, ITEM_ARGUMENT); + if( ITEM_ARG != NULL && !strcmp( ITEM_ARG, "FIXITEMALL") ){ + }else{ +#endif + CHAR_talkToCli( charindex, -1, "材料不符", CHAR_COLORYELLOW); + return FALSE; +#ifdef _ITEM_FIXALLBASE + } +#endif + } + + crushes = ITEM_getInt( fixindex, ITEM_DAMAGECRUSHE); + maxcrushes = ITEM_getInt( fixindex, ITEM_MAXDAMAGECRUSHE); + if( crushes >= (maxcrushes*0.80) ) { + char buff[256]; + sprintf( buff, "%s并没有损坏到需要修复。", ITEM_getChar( fixindex, ITEM_NAME)); + CHAR_talkToCli( charindex, -1, buff, CHAR_COLORYELLOW); + return FALSE; + }else { + char *buf1; + if( maxcrushes < 500 ){ + CHAR_talkToCli( charindex, -1, "此物品已不能修复", CHAR_COLORYELLOW); + return FALSE; + } + if( crushes <= 0 ) return FALSE; + maxcrushes = maxcrushes*0.85; + crushes = maxcrushes; + ITEM_setInt( fixindex, ITEM_DAMAGECRUSHE, crushes); + ITEM_setInt( fixindex, ITEM_MAXDAMAGECRUSHE, maxcrushes); + //修正名称 + buf1 = ITEM_getChar( fixindex, ITEM_SECRETNAME); + if( strstr( buf1, "(") != 0 ) { + char buf5[256]; + if( getStringFromIndexWithDelim( buf1,"(",1, buf5, sizeof( buf5)) != FALSE ) { + sprintf( buf1, buf5); + } + } + ITEM_setChar( fixindex, ITEM_SECRETNAME, buf1); + ITEM_setInt( fixindex, ITEM_CRUSHLEVEL, 0); + } + return TRUE; +} +#endif + + + diff --git a/gmsv/item/item_trade.c b/gmsv/item/item_trade.c new file mode 100644 index 0000000..123bbc8 --- /dev/null +++ b/gmsv/item/item_trade.c @@ -0,0 +1,477 @@ +/********************/ +/* 市集交易系统 */ +/********************/ +#include +#include "version.h" +#include "item_trade.h" +#include "handletime.h" +#include "object.h" +#include "trade.h" +#include "readmap.h" +#include "lssproto_serv.h" +#include "enemy.h" +#include "pet.h" + +#ifdef _MARKET_TRADE +#define MAXTRADES 4 +MapTrade TRADE_DATAS[MAXTRADES] = { + { -1, 5, 5, 0, -1, "NULL"},{ -1, 10, 5, 0, -1, "NULL"}, + { -1, 5, 10, 0, -1, "NULL"},{ -1, 10, 10, 0, -1, "NULL"} +}; +void InitMapTradeData( int index, int Stime) +{ + int i; + for( i=0; i= TRADE_DATAS[i].x && x < (TRADE_DATAS[i].x+TRADEXSIZE) ) { + if( y >= TRADE_DATAS[i].y && y < (TRADE_DATAS[i].y+TRADEYSIZE) ) { + FIND = TRUE; + break; + } + } + if( FIND == TRUE ) break; + i++; + } + if( i >= arraysizeof( TRADE_DATAS) ) + return -1; + return i; +} + +BOOL MAP_TRADEDROP( int charindex, int itemindex,int floor, int x, int y) +{ //return FALSE 物品丢在地上 TRUE 不丢在地上(可能是贩卖道具) + int exhibition=-1; + int CreateItem=-1,/*itemID=-1,*/ itemimage=-1; + int objindex; + char itemname[256]="(样)"; + + if( CHECKMAP_TRADE( charindex, floor, x, y) == FALSE ) + return FALSE; + if( (exhibition = CHECKMAP_TRADEXY(charindex, floor, x, y)) == -1 ) + return FALSE; + exhibition+=TRADESTARTNUM; + if( CHAR_getWorkInt( charindex, CHAR_MAPTRADETYPE) != exhibition ) { + print("\n 不是摊位[%d]主人[%d] ", exhibition, CHAR_getWorkInt( charindex, CHAR_MAPTRADETYPE)); + return TRUE; + } + + if( MAPTRADE_CHECKMAPFULL( floor, x, y) == TRUE ) { + CHAR_talkToCli( charindex, -1, "前方已有贩卖样品!", CHAR_COLORYELLOW); + return TRUE; + } + + //itemID = ITEM_getInt( itemindex, ITEM_ID ); + //CreateItem = ITEM_makeItemAndRegist( itemID); + itemimage = ITEM_getInt( itemindex, ITEM_BASEIMAGENUMBER); + if( ITEM_getChar( itemindex, ITEM_SECRETNAME) != NULL ) { + if( strstr( ITEM_getChar( itemindex, ITEM_SECRETNAME), "(样)") == NULL ) { + sprintf( itemname, "%s(样)", ITEM_getChar( itemindex, ITEM_SECRETNAME)); + } + } + + //CREAT 贩卖样品 + CreateItem = ITEM_makeItemAndRegist( TRADEITEMID); + if( !ITEM_CHECKINDEX( CreateItem ) ) + return TRUE; + //复制ITEM资料 + ITEM_setInt( CreateItem, ITEM_BASEIMAGENUMBER, itemimage); + ITEM_setChar( CreateItem, ITEM_NAME, itemname); + ITEM_setChar( CreateItem, ITEM_SECRETNAME, itemname); + ITEM_setChar( CreateItem, ITEM_EFFECTSTRING, "贩卖样品");//ITEM_EFFECTSTRING + ITEM_setChar( CreateItem, ITEM_ARGUMENT, "贩卖样品"); + + //丢 + ITEM_setWorkInt( CreateItem, ITEM_WORKOBJINDEX, -1); + ITEM_setWorkInt( CreateItem, ITEM_WORKCHARAINDEX, charindex); + ITEM_setInt( CreateItem, ITEM_PUTTIME, NowTime.tv_sec); + objindex = CHAR_DropItemAbsolute( CreateItem, floor, x, y, TRUE); + if( objindex == -1 ) { + ITEM_endExistItemsOne( CreateItem ); + return TRUE; + } + + ITEM_setWorkInt( CreateItem, ITEM_WORKTRADEINDEX, exhibition); + ITEM_setWorkInt( CreateItem, ITEM_WORKTRADETYPE, TRADETYPE_SELL ); + ITEM_setWorkInt( CreateItem, ITEM_WORKTRADESELLINDEX, itemindex); + ITEM_setWorkInt( CreateItem, ITEM_WORKCHARAINDEX, charindex); + + CHAR_sendWatchEvent( objindex,CHAR_ACTSTAND,NULL,0,TRUE); + CHAR_sendCToArroundCharacter( objindex); + TRADE_DATAS[exhibition-TRADESTARTNUM ].Goodindex = CreateItem; + + sprintf( TRADE_DATAS[exhibition-TRADESTARTNUM ].Goodname,"道具-%s", itemname); + return TRUE; +} + +BOOL MAP_TRADEPICKUP( int charindex, int index, int floor, int x, int y, int flg) +{ + int masterindex; + int objindex=-1; + int exhibition;//摊位 + + if( (exhibition = CHECKMAP_TRADEXY(charindex, floor, x, y)) == -1 ) + return FALSE; + masterindex = TRADE_getMasterInt( exhibition); + if( MAPTRADE_CHECKMASTERIN( masterindex, charindex, exhibition) == FALSE ) + return TRUE; + + if( masterindex == charindex || !CHAR_CHECKINDEX( masterindex) ) {//主人收回 + switch( flg ) { //清除 + case TRADEITEMTYPE: + objindex = ITEM_getWorkInt( index, ITEM_WORKOBJINDEX); + ITEM_endExistItemsOne( index); + OBJECT_setIndex( objindex, 0); + CHAR_ObjectDelete( objindex); + break; + case TRADEPETTYPE: + objindex = CHAR_getWorkInt( index, CHAR_WORKOBJINDEX); + CHAR_CharaDelete( index); + ITEM_endExistItemsOne( index); + break; + } + }else { //交易 + char buf1[256], msg[256]; + int fd = getfdFromCharaIndex( charindex); + int mfd = getfdFromCharaIndex( masterindex); + int snum=-1; + memset( buf1, 0, sizeof( buf1)); +//======================= + //masterindex + if( CHAR_getWorkInt( masterindex, CHAR_WORKTRADEMODE) == CHAR_TRADE_TRADING || + CHAR_getWorkInt( masterindex, CHAR_WORKTRADEMODE) == CHAR_TRADE_TRADING ){ + CHAR_talkToCli( charindex, -1, "主人正在买卖中!", CHAR_COLORYELLOW); + return TRUE; + } + CHAR_talkToCli(charindex, -1, "请稍候。", CHAR_COLORYELLOW); + sprintf(buf1, "C|%d|%s|1", fd, CHAR_getChar( charindex, CHAR_NAME)); + lssproto_TD_send( mfd, -1, buf1); + sprintf(buf1, "C|%d|%s|1", mfd, CHAR_getChar( masterindex, CHAR_NAME)); + lssproto_TD_send( fd, -1, buf1); + + CHAR_setWorkInt( charindex, CHAR_WORKTRADEMODE, CHAR_TRADE_TRADING); + CHAR_setWorkInt( masterindex, CHAR_WORKTRADEMODE, CHAR_TRADE_TRADING); + CONNECT_set_confirm( fd, FALSE); + CONNECT_set_confirm( mfd, FALSE); + CHAR_sendTradeEffect( charindex, 1); + CHAR_sendTradeEffect( masterindex, 1); + + switch( flg ) { //清除 + case TRADEITEMTYPE: //CHAR_Trade + if( (snum = MAPTRADE_getItemSpace( masterindex, index)) != -1 ) { + sprintf( buf1, "T|%d|%s|I|1|%d", fd, CHAR_getChar( charindex, CHAR_NAME), + snum ); + print(" MAP_TRADEPICKUP_check1 "); + CHAR_Trade( mfd, masterindex, buf1); + } + + snprintf(msg, sizeof(msg), "T|%d|%s|S|I|%d|%d", mfd, CHAR_getChar( masterindex, CHAR_NAME), snum, 1); + lssproto_TD_send( mfd, -1, msg); + break; + case TRADEPETTYPE: + if((snum = MAPTRADE_getPetSpace( masterindex, index)) != -1 ) { + sprintf( buf1, "T|%d|%s|P|3|%d", fd, CHAR_getChar( charindex, CHAR_NAME), + snum ); + print(" MAP_TRADEPICKUP_check2 "); + CHAR_Trade( mfd, masterindex, buf1); + } + snprintf(msg, sizeof(msg), "T|%d|%s|S|P|%d|%d", mfd, + CHAR_getChar( masterindex, CHAR_NAME), snum, 3); + lssproto_TD_send( mfd, -1, msg); + break; + } +//======================= + } + return TRUE; +} + + +int TRADE_getMasterInt( int index) +{ + if( index < 0 || index >= arraysizeof( TRADE_DATAS) ) + return -1; + return TRADE_DATAS[index].masterindex; +} + +int TRADE_getTimeInt( int index) +{ + if( index < 0 || index >= arraysizeof( TRADE_DATAS) ) + return FALSE; + return TRADE_DATAS[index].Ttime; +} + +BOOL TRADE_setMasterInt( int index, int Num) +{ + if( index < 0 || index >= arraysizeof( TRADE_DATAS) ) + return FALSE; + TRADE_DATAS[index].masterindex = Num; + return TRUE; +} + +BOOL TRADE_setTimeInt( int index, int Num) +{ + if( index < 0 || index >= arraysizeof( TRADE_DATAS) ) + return FALSE; + TRADE_DATAS[index].Ttime = Num; + return TRUE; +} + +int TRADE_getMaxNumInt() +{ + return arraysizeof( TRADE_DATAS); +} + +int TRADE_AddMasrerTrade( int toindex) +{ //设定摊位主人 + int i; + if( CHAR_getWorkInt( toindex, CHAR_MAPTRADETYPE) > 0 ) + return -1; + for( i=0; i< arraysizeof( TRADE_DATAS); i++) { + if( TRADE_DATAS[i].masterindex < 0 ) { + TRADE_setMasterInt( i, toindex); + TRADE_setTimeInt( i, NowTime.tv_sec); + return i+TRADESTARTNUM; + } + } + return -1; +} + +void MAPTRADE_CLEANGOLD( int floor, int num) +{ //TRADE_DATAS + OBJECT object; + int x,y; + + if( TRADE_DATAS[ num].masterindex != -1 ) { + print("\n 删除摊位[%d], 主人[%d]存在!!", num, TRADE_DATAS[ num].masterindex); + return; + } + for( x=TRADE_DATAS[ num].x; x<(TRADE_DATAS[ num].x+TRADEXSIZE); x++ ) { + for( y=TRADE_DATAS[ num].y; y<(TRADE_DATAS[ num].y+TRADEYSIZE); y++) { + for( object=MAP_getTopObj(floor,x,y) ; object ; object = NEXT_OBJECT(object ) ) { + int index = GET_OBJINDEX(object); + int objtype = OBJECT_getType(index); + int objindex = OBJECT_getIndex( index); + + if( objtype == OBJTYPE_NOUSE )continue; + if( objtype == OBJTYPE_ITEM ){ + if( ITEM_getWorkInt( objindex, ITEM_WORKTRADETYPE) == TRADETYPE_SELL ) { + ITEM_endExistItemsOne( objindex); + OBJECT_setIndex( index, 0); + CHAR_ObjectDelete(index); //清除 + print("clean( %d )", index ); + } + break; + } + if( objtype == OBJTYPE_CHARA ){ + if( CHAR_getInt( objindex, CHAR_WHICHTYPE) == CHAR_TYPEPET) { + if( CHAR_getWorkInt( objindex, CHAR_WORKTRADETYP) == TRADETYPE_SELL ) { + ITEM_endExistItemsOne( objindex); + OBJECT_setIndex( index, 0); + CHAR_CharaDelete( objindex); + } + } + } + } + } + } +} + +BOOL MAPTRADE_CHECKMASTERIN( int masterindex , int toindex, int num) +{ + int exhibition = num; + exhibition+=TRADESTARTNUM; + if( !CHAR_CHECKINDEX( masterindex) ) return FALSE; + if( CHAR_getWorkInt( masterindex, CHAR_MAPTRADETYPE) != exhibition ) + return FALSE; + + if( CHAR_getInt( masterindex, CHAR_FLOOR) != TRADEMAP ) { //主人不在了 + CHAR_talkToCli( toindex, -1, "主人不在!", CHAR_COLORYELLOW); + return FALSE; + }else { + int mapnum = CHECKMAP_TRADEXY( masterindex, CHAR_getInt( masterindex, CHAR_FLOOR), + CHAR_getInt( masterindex, CHAR_X), + CHAR_getInt( masterindex, CHAR_Y)); + if( (mapnum == -1 ) || + CHAR_getWorkInt( masterindex, CHAR_MAPTRADETYPE) != (mapnum+TRADESTARTNUM) ) { + CHAR_talkToCli( toindex, -1, "主人不在摊位上!", CHAR_COLORYELLOW); + //主人不在位置上 + return FALSE; + } + + } + return TRUE; +} + +BOOL MAPTRADE_CHECKMAPFULL(int fl, int x, int y) +{ + OBJECT object; + BOOL FIND=FALSE; + for( object=MAP_getTopObj(fl,x,y) ; object ; + object = NEXT_OBJECT(object ) ){ + int objindex = GET_OBJINDEX(object); + int index = OBJECT_getIndex( objindex); + + switch( OBJECT_getType(objindex) ){ + case OBJTYPE_NOUSE: + break; + case OBJTYPE_CHARA: + if( CHAR_getInt( index, CHAR_WHICHTYPE) != CHAR_TYPEPET ) { + break; + } + case OBJTYPE_ITEM: + FIND = TRUE; + break; + } + } + return FIND; +} + +BOOL MAP_TRADEPETDROP( int charindex, int petindex,int floor, int x, int y) +{ + int exhibition=-1; + int Createpet=-1,petid=-1, petimage=-1; + int objindex, i, enemynum=-1; + char petname[256]="(样)"; + if( CHECKMAP_TRADE( charindex, floor, x, y) == FALSE ) + return FALSE; + if( (exhibition = CHECKMAP_TRADEXY(charindex, floor, x, y)) == -1 ) + return FALSE; + exhibition+=TRADESTARTNUM; + + if( CHAR_getWorkInt( charindex, CHAR_MAPTRADETYPE) != exhibition ) { + print("\n 不是摊位[%d]主人[%d] ", exhibition, CHAR_getWorkInt( charindex, CHAR_MAPTRADETYPE)); + return TRUE; + } + + if( MAPTRADE_CHECKMAPFULL( floor, x, y) == TRUE ) { + CHAR_talkToCli( charindex, -1, "前方已有贩卖样品!", CHAR_COLORYELLOW); + return TRUE; + } + + + petimage = CHAR_getInt( petindex, CHAR_BASEIMAGENUMBER); + if( CHAR_getChar( petindex, CHAR_NAME) != NULL ) { + if( strstr( CHAR_getChar( petindex, CHAR_NAME), "(样)") == NULL ) { + sprintf( petname ,"%s(样)", CHAR_getChar( petindex, CHAR_NAME) ); + } + } + + //CREAT 贩卖样品 ENEMY_TEST_createPetIndex + + petid = CHAR_getInt( petindex, CHAR_PETID ); + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID ) == petid ){//ENEMY_TEMPNO + print("\n find pet[%d]", petid); + break; + } + } + if( i == enemynum ) + return FALSE; + Createpet = ENEMY_TEST_createPetIndex( i); + if( !CHAR_CHECKINDEX( Createpet ) ) return TRUE; + //复制可视条件 + CHAR_setChar( Createpet, CHAR_NAME, petname); + CHAR_setInt( Createpet, CHAR_BASEIMAGENUMBER, petimage); + CHAR_setInt( Createpet, CHAR_BASEBASEIMAGENUMBER, petimage); + + //丢下宠物 + objindex = PET_dropPetAbsolute( Createpet,floor,x,y, FALSE ); + if( objindex == -1 ) { + CHAR_endCharOneArray( Createpet ); + return TRUE; + } + + CHAR_setWorkInt( Createpet, CHAR_WORKOBJINDEX, objindex ); + CHAR_setWorkInt( Createpet, CHAR_WORKTRADETYP, TRADETYPE_SELL); + CHAR_setWorkInt( Createpet, CHAR_WORKTRADESELLINDEX, petindex); + + CHAR_setInt( Createpet, CHAR_ALLOCPOINT, TRADEPETUPLV ); + CHAR_setChar( Createpet, CHAR_OWNERCDKEY, "WAEI_SYSOWN"); + CHAR_setChar( Createpet, CHAR_OWNERCHARANAME, "WAEI_SYSOWN"); + CHAR_setInt( Createpet, CHAR_FLOOR, floor); + CHAR_setInt( Createpet, CHAR_X, x); + CHAR_setInt( Createpet, CHAR_Y, y); + CHAR_setInt( Createpet, CHAR_PUTPETTIME, NowTime.tv_sec); + CHAR_sendCToArroundCharacter( objindex); + TRADE_DATAS[exhibition-TRADESTARTNUM ].Goodindex = Createpet; + + sprintf( TRADE_DATAS[exhibition-TRADESTARTNUM ].Goodname,"宠物-%s", petname); + return TRUE; +} + +int MAPTRADE_getItemSpace( int meindex, int itemindex) +{ + int i; + int index = ITEM_getWorkInt( itemindex, ITEM_WORKTRADESELLINDEX); + for( i=CHAR_EQUIPPLACENUM; i= arraysizeof( TRADE_DATAS) ) + return -1; + return TRADE_DATAS[index].Goodindex; +} + +BOOL MAPTRADE_setSellIndex( int index, int num) +{ + if( index < 0 || index >= arraysizeof( TRADE_DATAS) ) + return FALSE; + TRADE_DATAS[index].Goodindex = num; + return TRUE; +} + +void MAPTRADE_setCharSellName( int index, char *buf) +{ + if( index < 0 || index >= arraysizeof( TRADE_DATAS) ) + return; + if( buf == NULL ) + return; + snprintf( TRADE_DATAS[index].Goodname, sizeof( TRADE_DATAS[index].Goodname), buf); +} + +char* MAPTRADE_getCharSellName( int index ) +{ + if( index < 0 || index >= arraysizeof( TRADE_DATAS) ) + return NULL; + return TRADE_DATAS[index].Goodname; +} +#endif + + + + diff --git a/gmsv/item/makefile b/gmsv/item/makefile new file mode 100644 index 0000000..16252a0 --- /dev/null +++ b/gmsv/item/makefile @@ -0,0 +1,249 @@ +INCFLAGS=-I. -I../include + +CFLAGS=-w -O3 $(INCFLAGS) + +PROG=libitem.a + +SRC=item.c item_event.c item_gen.c item_trade.c item_contract.c +OBJ=$(SRC:.c=.o) + +ifeq (0,$(MAKELEVEL)) +CC=gcc +RM=rm -f +AR=ar cr +MV=mv +RANLIB=ranlib +SED=sed +SHELL=/bin/sh +endif + +all: $(PROG) + +$(PROG): $(OBJ) + $(RM) $(PROG) + $(AR) $(PROG) $(OBJ) + $(RANLIB) $(PROG) + +depend: + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(CC) $(INCFLAGS) -M $(SRC) >> makefile + +clean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + +distclean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + $(MV) makefile Makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(RM) makefile.bak + +# DO NOT DELETE THIS LINE +item.o: item.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h /usr/include/string.h \ + /usr/include/strings.h /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h ../include/common.h \ + ../include/char.h ../include/char_base.h ../include/skill.h \ + ../include/util.h /usr/include/sys/time.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/netinet/in.h \ + /usr/include/stdint.h /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/battle.h ../include/buf.h ../include/function.h \ + ../include/magic_base.h ../include/profession_skill.h +item_event.o: item_event.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/ctype.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/endian.h /usr/include/bits/endian.h ../include/common.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/configfile.h ../include/item_event.h ../include/object.h \ + ../include/anim_tbl.h ../include/magic.h ../include/handletime.h \ + ../include/log.h ../include/encount.h ../include/battle.h \ + ../include/battle_item.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/pet.h ../include/npcutil.h \ + ../include/enemy.h ../include/battle_magic.h ../include/pet_skill.h \ + ../include/npc_freepetskillshop.h ../include/profession_skill.h +item_gen.o: item_gen.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h /usr/include/string.h \ + /usr/include/strings.h /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/ctype.h /usr/include/math.h /usr/include/bits/huge_val.h \ + /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h \ + ../include/configfile.h ../include/common.h ../include/util.h \ + /usr/include/sys/time.h ../include/buf.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/netinet/in.h \ + /usr/include/stdint.h /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/item_gen.h ../include/enemy.h ../include/log.h \ + ../include/saacproto_cli.h ../include/saacproto_util.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h ../include/family.h \ + ../include/magic_base.h +item_trade.o: item_trade.c /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/version.h ../include/correct_bug.h ../include/version_pk.h \ + ../include/item_trade.h ../include/char.h ../include/common.h \ + /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/handletime.h ../include/object.h ../include/trade.h \ + ../include/readmap.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/enemy.h ../include/pet.h +item_contract.o: item_contract.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/ctype.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/endian.h /usr/include/bits/endian.h ../include/common.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/configfile.h ../include/item_event.h ../include/object.h \ + ../include/anim_tbl.h ../include/magic.h ../include/handletime.h \ + ../include/log.h ../include/encount.h ../include/battle.h \ + ../include/battle_item.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/pet.h ../include/npcutil.h \ + ../include/enemy.h diff --git a/gmsv/item/makefile.bak b/gmsv/item/makefile.bak new file mode 100644 index 0000000..e2e93de --- /dev/null +++ b/gmsv/item/makefile.bak @@ -0,0 +1,183 @@ +INCFLAGS=-I. -I../include + +CFLAGS=-w -O3 $(INCFLAGS) + +PROG=libitem.a + +SRC=item.c item_event.c item_gen.c item_trade.c item_contract.c +OBJ=$(SRC:.c=.o) + +ifeq (0,$(MAKELEVEL)) +CC=gcc +RM=rm -f +AR=ar cr +MV=mv +RANLIB=ranlib +SED=sed +SHELL=/bin/sh +endif + +all: $(PROG) + +$(PROG): $(OBJ) + $(RM) $(PROG) + $(AR) $(PROG) $(OBJ) + $(RANLIB) $(PROG) + +depend: + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(CC) $(INCFLAGS) -M $(SRC) >> makefile + +clean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + +distclean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + $(MV) makefile Makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(RM) makefile.bak + +# DO NOT DELETE THIS LINE +item.o: item.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h /usr/include/string.h /usr/include/strings.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/common.h ../include/char.h ../include/char_base.h \ + ../include/skill.h ../include/util.h /usr/include/sys/time.h \ + /usr/include/bits/time.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/buf.h ../include/function.h ../include/magic_base.h +item_event.o: item_event.c /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/ctype.h /usr/include/bits/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/bits/stdio_lim.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/configfile.h ../include/item_event.h ../include/object.h \ + ../include/anim_tbl.h ../include/magic.h ../include/handletime.h \ + ../include/log.h ../include/encount.h ../include/battle.h \ + ../include/battle_item.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h +item_gen.o: item_gen.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h /usr/include/string.h /usr/include/strings.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/ctype.h /usr/include/math.h /usr/include/bits/huge_val.h \ + /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/float.h \ + ../include/configfile.h ../include/common.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/bits/time.h ../include/buf.h \ + ../include/char.h ../include/char_base.h ../include/skill.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/item_gen.h ../include/enemy.h ../include/log.h +item_trade.o: item_trade.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h /usr/include/string.h /usr/include/strings.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/ctype.h /usr/include/math.h /usr/include/bits/huge_val.h \ + /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/float.h \ + ../include/configfile.h ../include/common.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/bits/time.h ../include/buf.h \ + ../include/char.h ../include/char_base.h ../include/skill.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/item_gen.h ../include/enemy.h ../include/log.h \ + ../include/item_trade.h diff --git a/gmsv/link.c b/gmsv/link.c new file mode 100644 index 0000000..f71d32d --- /dev/null +++ b/gmsv/link.c @@ -0,0 +1,153 @@ +#include +#include "version.h" +#include "link.h" +#include "buf.h" + +/* + * 伉件弁及 卞勾仃月 + * 娄醒 + * top 玄永皿用□玉 + * add 尥仃笛尹月用□玉及 毛忡 允月用□玉尺及禾奶件正□ + * 忒曰袄 + * TRUE(1) 岳 + * FALSE(0) 撩 + */ +BOOL Nodeappendtail( Node** top , Node* add ) +{ + Node* c; /*伙□皿迕*/ + Node* next; /*蕙仄仁综月用□玉迕*/ + + /*玄永皿互NULL井升丹井及民尼永弁*/ + if( *top == NULL ){ + *top = allocateMemory( sizeof( Node ) ); + if( *top== NULL ) return FALSE; + (*top)->next = NULL; /*粮五反 中*/ + (*top)->size = add->size; /*赢今及忡栋*/ + (*top)->val = add->val; /*禾奶件正□及戊疋□*/ + return TRUE; + } + + for( c = *top ; c->next ; c = c->next ); /* c及匏 毛内日允 */ + next = allocateMemory( sizeof(Node) ); + if( next == NULL )return FALSE; + c->next = next; /* next卞袄毛涩烂允月 */ + next->next = NULL; /*粮五反 中*/ + next->val = add->val; /*禾奶件正□及戊疋□*/ + next->size = add->size; /*赢今及忡栋*/ + return TRUE; +} + + + + +/* + * 伉件弁及蟆卞勾仃月 + * 娄醒 + * top 玄永皿用□玉 + * add 尥仃笛尹月用□玉及 毛忡 允月用□玉尺及禾奶件正□ + * 忒曰袄 + * TRUE(1) 岳 + * FALSE(0) 撩 + */ +BOOL Nodeappendhead( Node** nowtop , Node* add ) +{ + Node* newtop; /*蕙仄中燮 迕*/ + + /*玄永皿互NULL井升丹井及民尼永弁*/ + if( *nowtop == NULL ){ + *nowtop = allocateMemory( sizeof( Node ) ); + if( *nowtop == NULL ) return FALSE; + (*nowtop)->next = NULL; /*粮五反 中*/ + (*nowtop)->size = add->size; /*赢今及忡栋*/ + (*nowtop)->val = add->val; /*禾奶件正□及戊疋□*/ + return TRUE; + } + + /* + * 蕙仄中用□玉毛域勾综月 + * next 互犒允手及毛 nowtop 卞允月[ + * nowtop 卞反 割忡仄凶 newtop 毛医 允月[ + */ + newtop = allocateMemory( sizeof(Node) ); + newtop->next = *nowtop; + newtop->val = add->val; + newtop->size = add->size; + *nowtop = newtop; + return TRUE; +} + + + + +/* + * 域 赓及用□玉毛娄醒卞戊疋□仄化潸曰轮仁 + * 娄醒 + * top 用□玉及燮 + * ret 潸曰轮中凶用□玉及戊疋□ + * 忒曰袄 + * TRUE(1) 岳 + * FALSE(0) 撩 用□玉及燮 互NULL + */ +BOOL Noderemovehead( Node** top , Node* ret) +{ + Node* newtop; /*蕙仄仁燮 卞卅月用□玉*/ + + if( *top == NULL )return FALSE; + + ret->val = (*top)->val; + ret->size = (*top)->size; + newtop = (*top)->next; + freeMemory( *top ); + *top = newtop; + + return TRUE; +} + + + + + +/* + * 域 及用□玉毛娄醒卞戊疋□仄化潸曰轮仁 + * 娄醒 + * top 用□玉及燮 + * ret 潸曰轮中凶用□玉及戊疋□ + * 忒曰袄 + * TRUE(1) 岳 + * FALSE(0) 撩 用□玉及燮 互NULL + */ +BOOL Noderemovetail( Node** top , Node* ret) +{ + Node* c; /*伙□皿迕*/ + Node* c1; /*伙□皿迕 中勾匹手 c->next毛隙允*/ + + if( *top == NULL )return FALSE; + + c = *top; /*赓渝袄涩烂*/ + c1 = c->next; /*赓渝袄涩烂*/ + while(1){ + if( c1->next == NULL ) + /* + * 仇及凛鳔匹 c1 + * | + * c ---> +------+ + * | next |---->+------+ + * |------| | next |---->NULL + * | | +------+ + * +------+ | | + * +------+ + *午卅匀化中月 + */ + break; + c=c->next; + c1=c->next; + } + c->next = NULL; /*c1卞丐凶月手及毛绰轮允月及匹next反NULL午允月*/ + /*戊疋□*/ + ret->val = c1->val; + ret->size = c1->size; + + freeMemory( c1 ); + + return TRUE; +} diff --git a/gmsv/log.c b/gmsv/log.c new file mode 100644 index 0000000..922a98f --- /dev/null +++ b/gmsv/log.c @@ -0,0 +1,926 @@ +#include "version.h" +#include +#include +#include +#include + +#include "common.h" +#include "util.h" +#include "log.h" +#include "handletime.h" +#include "net.h" +#include "char_base.h" + +/* + * + * 夫弘白央奶伙及潘 反append 允月手及午仄卅中手及互丐月[ + * append允月手及反 赓卞白央奶伙毛夫日中化云仁[ + * 公丹匹卅中手及反踏五仇心及凶太卞fopen(..,"w")允月 + * by ringo + */ + +struct tagLogconf{ + char* label; + char* entry; + char filename[256]; + FILE* f; + BOOL append; /* append 允月井}踏五仇心及凶太卞SEEK_SET允月井 */ +}LogConf[LOG_TYPE_NUM]={ + { "TALK: ", "talklog" ,"", NULL , TRUE}, + { "PROC: ", "proc" , "" , NULL , FALSE}, + { "ITEM: ", "itemlog" ,"", NULL , TRUE}, + { "STONE: ", "stonelog" ,"", NULL , TRUE}, + { "PET: ", "petlog" ,"", NULL , TRUE}, + { "TENSEI: ", "tenseilog" ,"", NULL , TRUE}, + { "KILL: ", "killlog","",NULL,TRUE}, + // CoolFish: 2001/4/19 + { "TRADE: ", "tradelog", "", NULL, TRUE}, + // Arminius: 2001/6/14 + { "HACK: ", "hacklog", "", NULL, TRUE}, + // Nuke: 0626 Speed + { "SPEED: ", "speedlog", "", NULL, TRUE}, + // CoolFish: FMPopular 2001/9/12 + { "FMPOP: ", "fmpoplog", "", NULL, TRUE}, + // Robin 10/02 + { "FAMILY: ", "familylog", "", NULL, TRUE}, + // Shan 11/02 + { "GM: ", "gmlog", "", NULL, TRUE}, + // Terry 2001/09/28 +#ifdef _SERVICE + { "SERVICE: ", "servicelog", "", NULL, TRUE}, +#endif +#ifdef _GAMBLE_ROULETTE + { "", "gamblelog", "", NULL, TRUE}, +#endif +#ifdef _TEST_PETCREATE + { "", "creatpetlog", "", NULL, TRUE}, + { "", "creatpetavglog", "", NULL, TRUE}, +#endif + { "LOGIN: ", "loginlog", "", NULL, TRUE}, + { "", "pettranslog", "", NULL, TRUE}, +//Syu 增加庄园战胜负Log + { "FMPKRESULT: ", "fmpkresultlog" ,"", NULL , TRUE}, + +// Syu ADD 新增家族个人银行存取Log (不含家族银行) + { "BANKSTONELOG: ", "bankstonelog" ,"", NULL , TRUE}, + + { "ACMESSAGE: ", "acmessagelog" ,"", NULL , TRUE}, + { "PKCONTEND:", "pkcontendlog", "", NULL, TRUE}, +#ifdef _STREET_VENDOR + { "STREETVENDOR: ", "StreetVendorlog" ,"", NULL , TRUE}, +#endif +#ifdef _ANGEL_SUMMON + { "ANGEL: ", "angellog" ,"", NULL , TRUE}, +#endif +#ifdef _LOG_OTHER + { "OTHER: ", "otherlog" ,"", NULL , TRUE}, +#endif +#ifdef _NEW_MANOR_LAW + { "FMPKGETMONEY: ","FMPKGetMoneylog","",NULL,TRUE}, + { "FMFAMESHOP: ","FMFameShoplog","",NULL,TRUE}, +#endif +}; + +tagWarplog warplog[MAXMAPNUM]; +tagWarpCount warpCount[MAXMAPLINK]; + +/*------------------------------------------------------------ + * 夫弘涩烂白央奶伙毛 氏匹 file 毛钒仁 + * 娄醒 + * filename char* 夫弘涩烂白央奶伙 + * 忒曰袄 + * FALSE 反褐 卅撩 匹丐月[ + ------------------------------------------------------------*/ +static BOOL readLogConfFile( char* filename ) +{ + FILE* f; + char line[256]; + char basedir[256]; + int linenum=0; + + { + char* r; + r = rindex( filename, '/' ); + if( r == NULL )snprintf(basedir,sizeof(basedir),"." ); + else{ + memcpy( basedir,filename,r-filename ); + basedir[r-filename] = '\0'; + } + } + + f = fopen( filename , "r"); + if( f == NULL ){ + print( "Can't open %s\n" , filename ); + return FALSE; + } + while( fgets( line, sizeof( line ) ,f ) ){ + char firstToken[256]; + int i; + BOOL ret; + + linenum++; + deleteWhiteSpace(line); /* remove whitespace */ + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); /* remove tail newline */ + ret = getStringFromIndexWithDelim( line , "=", 1, firstToken, sizeof(firstToken) ); + if( ret == FALSE ){ + print( "Find error at %s in line %d. Ignore\n", + filename , linenum); + continue; + } + for( i=0 ; i= LOG_TYPE_NUM )return; + if( LogConf[logtype].append ){ + if( !LogConf[logtype].f )return; + fputs( LogConf[logtype].label, LogConf[logtype].f); + va_start(arg,format); + vfprintf( LogConf[logtype].f,format,arg ); + va_end( arg ); + fputc( '\n', LogConf[logtype].f ); + } else { + FILE *f = fopen( LogConf[logtype].filename ,"w" ); + if( !f ) return; + fputs(LogConf[logtype].label , f ); + va_start(arg,format); + vfprintf( f , format,arg); + va_end(arg); + fputc( '\n' , f); + fclose(f); + } +} + +BOOL initLog( char* filename ) +{ + if( readLogConfFile( filename ) == FALSE )return FALSE; + openAllLogFile(); + return TRUE; +} + +//Syu 增加庄园战胜负Log +void Logfmpk( + char *winner, int winnerindex, int num1, + char *loser, int loserindex, int num2, + char *date, char *buf1, char *buf2, int flg) +{ + switch( flg){ + case 1: + { + struct tm tm1; + char buf[256]; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + sprintf( buf, " (%d:%d)", tm1.tm_hour, tm1.tm_min); + printl( LOG_FMPKRESULT, "\nFMPK: [%s]地点:%s %s(%d) 约战要求 %s(%d) time:%s", + buf1, buf2, + winner, winnerindex, loser, loserindex, buf); + } + break; + case 2: + printl( LOG_FMPKRESULT, "\nFMPK: Winner %s(%d)=>%d Loser %s(%d)=>%d time:%s", + winner, winnerindex, num1, + loser, loserindex, num2 ,date); + break; + } +} + +#ifdef _NEW_MANOR_LAW +void LogFMPKGetMomey(char *szFMName,char *szID,char *szCharName,int iMomentum,int iGetMoney,int iDest) +{ + struct tm tm1; + char szDest[3][6] = {"身上","银行","错误"}; + + if(iDest < 0 || iDest > 1) iDest = 2; + memcpy(&tm1,localtime((time_t*)&NowTime.tv_sec),sizeof(tm1)); + printl(LOG_FMPK_GETMONEY,"FMName:%s\tID:%s\tName:%s\tMomentum:%d\tGetMoney:%d\tAddTo:%s\t(%d:%d)", + szFMName,szID,szCharName,iMomentum,iGetMoney,szDest[iDest],tm1.tm_hour,tm1.tm_min); +} + +void LogFMFameShop(char *szFMName,char *szID,char *szCharName,int iFame,int iCostFame) +{ + struct tm tm1; + + memcpy(&tm1,localtime((time_t*)&NowTime.tv_sec),sizeof(tm1)); + printl(LOG_FM_FAME_SHOP,"FMName:%s\tID:%s\tName:%s\tFame:%d\tCostFame:%d\t(%d:%d)", + szFMName,szID,szCharName,iFame,iCostFame,tm1.tm_hour,tm1.tm_min); +} +#endif + +void LogAcMess( int fd, char *type, char *mess ) +{ + struct tm tm1; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + if( strstr( mess, "Broadcast") != NULL ) return; + printl( LOG_ACMESS, "%d %s [%s] (%d:%d)" , fd, type, mess, tm1.tm_hour, tm1.tm_min); +} + +void LogItem( + char *CharName, /* 平乓仿弁正 */ + char *CharID, /* 平乓仿弁正ID */ + int ItemNo, /* 失奶 丞 寞 */ + char *Key, /* 平□伐□玉 */ + int floor, /* 甄 */ + int x, + int y, + char *uniquecode, // shan 2001/12/14 + char *itemname, int itemID +){ + struct tm tm1; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + + printl( LOG_ITEM, "%s\t%s\t%d(%s)=%s,(%d,%d,%d)(%d:%d),%s" , CharName, CharID, + itemID, itemname, + Key, floor, x, y, tm1.tm_hour, tm1.tm_min, uniquecode ); + + +} +void LogPkContend( char *teamname1, char *teamname2, + int floor, + int x, + int y, + int flg +) +{ + struct tm tm1; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + + if( flg == 0 ) { + printl( LOG_PKCONTEND, "[%32s 胜 %32s],(%5d,%4d,%4d)(%d:%d)" , + teamname1, teamname2, + floor, x, y, tm1.tm_hour, tm1.tm_min); + }else{ + printl( LOG_PKCONTEND, "Msg:[%s],(%5d,%4d,%4d)(%d:%d)" , + teamname1, floor, x, y, tm1.tm_hour, tm1.tm_min); + } + +} + +void LogPetTrans( + char *cdkey, char *uniwuecde, char *uniwuecde2, + char *CharName, int floor, int x, int y, + int petID1, char *PetName1, int petLV, int petrank, int vital1, int str1, int tgh1, int dex1, int total1, + int petID2, char *PetName2, int vital2, int str2, int tgh2, int dex2, int total2, + int work0, int work1, int work2, int work3, int ans, int trans + ){ + struct tm tm1; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + printl( PETTRANS, "\n*PETTRANS cdkey=%s unid=%s munid=%s %s (%d:%d) %d=%s LV:%d rand:%d trans:%d :[ %d, %d, %d, %d]=%d %d=%s :[ %d, %d, %d, %d]=%d [ %d, %d, %d, %d]=%d\n", + cdkey, uniwuecde, uniwuecde2, + CharName, tm1.tm_hour, tm1.tm_min, + petID1, PetName1, petLV, petrank, trans, vital1, str1, tgh1, dex1, total1, + petID2, PetName2, vital2, str2, tgh2, dex2, total2, + work0, work1, work2, work3, ans ); +} +/*------------------------------------------------------------ + * + * 矢永玄夫弘毛潸月 + * +-------------------------------------------------------------*/ +void LogPet( + char *CharName, /* 平乓仿弁正 */ + char *CharID, + char *PetName, + int PetLv, + char *Key, /* 平□伐□玉 */ + int floor, /* 甄 */ + int x, + int y, + char *uniquecode // shan 2001/12/14 +){ + struct tm tm1; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + // shan 2001/12/14 + //printl( LOG_PET, "%s\t%s\t%s:%d=%s,(%d,%d,%d)(%d:%d)" , CharName, CharID, + // PetName, PetLv, + // Key, + // floor, x, y, tm1.tm_hour, tm1.tm_min ); + printl( LOG_PET, "%s\t%s\t%s:%d=%s,(%d,%d,%d)(%d:%d),%s" , CharName, CharID, + PetName, PetLv, + Key, + floor, x, y, tm1.tm_hour, tm1.tm_min, uniquecode); +} + +#ifdef _STREET_VENDOR +void LogStreetVendor( + char *SellName, + char *SellID, + char *BuyName, + char *BuyID, + char *ItemPetName, + int PetLv, //若是道具此值为 -1 + int iPrice, + char *Key, + int Sfloor, + int Sx, + int Sy, + int Bfloor, + int Bx, + int By, + char *uniquecode +){ + struct tm tm1; + memcpy(&tm1,localtime((time_t *)&NowTime.tv_sec),sizeof(tm1)); + printl(LOG_STREET_VENDOR,"Sell:%s\t%s\tBuy:%s\t%s\tName=%s:Lv=%d|Price:%d,%s,SXY(%d,%d,%d)BXY(%d,%d,%d)(%d:%d),%s",SellName,SellID,BuyName,BuyID, + ItemPetName,PetLv,iPrice,Key,Sfloor,Sx,Sy,Bfloor,Bx,By,tm1.tm_hour,tm1.tm_min,uniquecode); +} +#endif + +void LogBankStone( + char *CharName, /* 平乓仿弁正 */ + char *CharId, /* 交□扒□ID */ + int meindex, + int Gold, /* 嗯喊 */ + char *Key, /* 平□伐□玉 */ + int floor, /* 甄 */ + int x, + int y, + int my_gold, + int my_personagold + +){ + struct tm tm1; + + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + printl( LOG_STONE, "%s:%s\ts:%d=%s,(%d,%d,%d)(%d:%d) <>" , + CharId, CharName, Gold, Key, + floor, x, y, tm1.tm_hour, tm1.tm_min , my_gold, my_personagold ); +} + +void LogPetPointChange( + char * CharName, char *CharID, char *PetName, int petindex, int errtype, + int PetLv, char *Key,int floor, int x, int y) { + + struct tm tm1; + int vit,str,tgh,dex; + int l_vit,l_str,l_tgh,l_dex; + int pet_ID, levellvup; + + pet_ID = CHAR_getInt( petindex, CHAR_PETID ); + vit = CHAR_getInt( petindex, CHAR_VITAL ); + str = CHAR_getInt( petindex, CHAR_STR ); + tgh = CHAR_getInt( petindex, CHAR_TOUGH ); + dex = CHAR_getInt( petindex, CHAR_DEX ); + levellvup = CHAR_getInt( petindex, CHAR_ALLOCPOINT); + + l_vit = (levellvup >> 24); + l_str = (levellvup >> 16)&0xff; + l_tgh = (levellvup >> 8 )&0xff; + l_dex = (levellvup >> 0 )&0xff; + + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + printl( LOG_PET, "%s\t%s\t%s:%d=%s,(%d,%d,%d)(%d:%d),err:%d %d<<%d,%d,%d,%d>>lvup<<%d,%d,%d,%d>>" , + CharName, CharID, PetName, PetLv, Key, floor, x, y, tm1.tm_hour, tm1.tm_min , errtype, + pet_ID ,vit,str,tgh,dex,l_vit,l_str,l_tgh,l_dex); +} + +/*------------------------------------------------------------ + * + * 鳖戏夫弘毛潸月 + * +-------------------------------------------------------------*/ +void LogTensei( + char *CharName, /* 平乓仿弁正 */ + char *CharID, + char *Key, /* 平□伐□玉 */ + int level, //伊矛伙 + int transNum, //鳖戏荚醒 + int quest, //弁巨旦玄醒 + int home, //请褥哗 + int item, // 笛失奶 丞 井曰醒 + int pet, // 笛矢永玄 井曰醒 + int vital, // 祭蟆Vital + int b_vital, // 祭 vital + int str, // 祭蟆str + int b_str, // 祭 str + int tgh, // 祭蟆 + int b_tgh, // 祭 + int dex, // 祭蟆 + int b_dex // 祭 +){ + struct tm tm1; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + printl( LOG_TENSEI, "%s\t%s\t%s=(%d,%d,%d,%d,%d,%d),(vi=%d->%d,str=%d->%d,tgh=%d->%d,dex=%d->%d),(%d,%d)" + ,CharName, + CharID, + Key, + level, + transNum, + quest, + home, + item, + pet, + vital, + b_vital, + str, + b_str, + tgh, + b_tgh, + dex, + b_dex, + tm1.tm_hour, tm1.tm_min + ); +} + +// LOG_TALK +void LogTalk( + char *CharName, /* 平乓仿弁正 */ + char *CharID, + int floor, /* 甄 */ + int x, + int y, + char *message +){ + struct tm tm1; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + + printl( LOG_TALK, "%2d:%2d\t%s\t%s\t%d_%d_%d\tT=%s" , + tm1.tm_hour, tm1.tm_min, + (CharID==NULL) ? "(null)" :CharID, + (CharName==NULL) ? "(null)" :CharName, + floor, x, y, + message ); + + +} +#ifdef _TEST_PETCREATE +void backupTempLogFile( char *buf, char *entryname, int Num) +{ + int i; + char szBuffer[256]; + //entry + for( i=0 ; itm_year+1900, ptm->tm_mon+1, ptm->tm_mday ); + + if( LogConf[i].f != NULL ){ + /* 左□皿件今木化中凶日弁夫□术 */ + fclose( LogConf[i].f ); + /* 伉生□丞 */ + rename( LogConf[i].filename, szBuffer ); + /* 疯太左□皿件 */ + LogConf[i].f = fopen( LogConf[i].filename , "a" ); + + }else{ + /* 伉生□丞 */ + rename( LogConf[i].filename, szBuffer ); + /* 疯太左□皿件 */ + LogConf[i].f = fopen( LogConf[i].filename , "a" ); + + } + } +} +/*------------------------------------------------------------ +* +* 云嗯毛胶丹 +* +-------------------------------------------------------------*/ +// Syu ADD 新增家族个人银行存取Log (不含家族银行) +void LogFamilyBankStone( + char *CharName, + char *CharId, + int Gold, + int MyGold, + char *Key, + int floor, + int x, + int y, + int banksum +){ + struct tm tm1; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + printl( LOG_BANKSTONELOG, "%s:%s\t%d=%s [%d] CHAR_GOLD(%d),(%d,%d,%d)(%d:%d)" , CharId, CharName, Gold, Key,banksum, + MyGold, floor, x, y, tm1.tm_hour, tm1.tm_min ); + print("\n%s:%s\t%d=%s [%d] CHAR_GOLD(%d),(%d,%d,%d)(%d:%d)\n" , CharId, CharName, Gold, Key,banksum, + MyGold, floor, x, y, tm1.tm_hour, tm1.tm_min ); +} + +void LogStone( + int TotalGold, + char *CharName, /* 平乓仿弁正 */ + char *CharId, /* 交□扒□ID */ + int Gold, /* 嗯喊 */ + int MyGold, + char *Key, /* 平□伐□玉 */ + int floor, /* 甄 */ + int x, + int y +){ + struct tm tm1; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + if(TotalGold == -1){ + printl( LOG_STONE, "%s:%s\t%d=%s TOTAL_GOLD(%d),CHAR_GOLD(%d),(%d,%d,%d)(%d:%d)" , CharId, CharName, Gold, Key,TotalGold, + MyGold, floor, x, y, tm1.tm_hour, tm1.tm_min ); + } + else{ + printl( LOG_STONE, "%s:%s\t%d=%s CHAR_GOLD(%d),(%d,%d,%d)(%d:%d)" , CharId, CharName, Gold, Key, + MyGold, floor, x, y, tm1.tm_hour, tm1.tm_min ); + } +} + +//ttom 12/26/2000 print the kill log +void LogKill( + char *CharName, + char *CharId, + char *CharPet_Item +){ + struct tm tm1; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + printl( LOG_KILL, "Name=%s:ID=%s\t%s (%d:%d)" ,CharName,CharId, CharPet_Item, + tm1.tm_hour, tm1.tm_min ); +} +//ttom + +// CoolFish: Trade 2001/4/19 +void LogTrade(char *message) +{ + struct tm tm1; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + printl( LOG_TRADE, "%s (%d:%d)" , message, tm1.tm_hour, tm1.tm_min ); +} + +// CoolFish: Family Popular 2001/9/12 +void LogFMPOP(char *message) +{ + struct tm tm1; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + + printl( LOG_FMPOP, "%s (%d:%d)" , message, tm1.tm_hour, tm1.tm_min ); +} + +// Arminius 2001/6/14 +char hackmsg[HACK_TYPE_NUM][4096]= + { "??? 什麽事也没有发生", + "无法取得通讯协定码", + "收到无法辨识的通讯协定码", + "检查码错误", + "人物的HP为负", + }; + +void logHack(int fd, int errcode) +{ + struct tm tm1; + char cdkey[4096]; + char charname[4096]; + unsigned long ip; + char ipstr[4096]; + + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + CONNECT_getCdkey( fd, cdkey, 4096); + CONNECT_getCharname( fd, charname, 4096); + ip=CONNECT_get_userip(fd); + sprintf(ipstr,"%d.%d.%d.%d", + ((unsigned char *)&ip)[0], + ((unsigned char *)&ip)[1], + ((unsigned char *)&ip)[2], + ((unsigned char *)&ip)[3]); + if ((errcode<0) || (errcode>=HACK_TYPE_NUM)) errcode=HACK_NOTHING; + + printl( LOG_HACK, "(%d:%d) %s ip=%s cdkey=%s charname=%s", + tm1.tm_hour, tm1.tm_min, hackmsg[errcode], ipstr, cdkey, charname); +} + +// Nuke 0626 +void logSpeed(int fd) +{ + struct tm tm1; + char cdkey[4096]; + char charname[4096]; + unsigned long ip; + char ipstr[4096]; + + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + CONNECT_getCdkey( fd, cdkey, 4096); + CONNECT_getCharname( fd, charname, 4096); + ip=CONNECT_get_userip(fd); + sprintf(ipstr,"%d.%d.%d.%d", + ((unsigned char *)&ip)[0], + ((unsigned char *)&ip)[1], + ((unsigned char *)&ip)[2], + ((unsigned char *)&ip)[3]); + printl( LOG_SPEED, "(%d:%d) ip=%s cdkey=%s charname=%s", + tm1.tm_hour, tm1.tm_min, ipstr, cdkey, charname); +} + +// Shan +void LogGM( + char *CharName, //角色名称 + char *CharID, //玩家ID + char *Message, //指令内容 + int floor, + int x, + int y +) +{ + struct tm tm1; + + memcpy(&tm1,localtime((time_t *)&NowTime.tv_sec),sizeof(tm1)); + printl(LOG_GM,"%s\t%s\t%s\t(%d,%d,%d)\t(%d:%d)", + CharName,CharID,Message,floor,x,y,tm1.tm_hour,tm1.tm_min); +} + +// Robin 10/02 +void LogFamily( + char *FMName, + int fmindex, + char *charName, + char *charID, + char *keyWord, + char *data +){ + struct tm tm1; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + // CoolFish: 2001/10/11 log time + printl( LOG_FAMILY, "%s\t%d\t%s\t%s\t= %s, %s (%d:%d)", + FMName, fmindex, charName, charID, + keyWord, data, tm1.tm_hour, tm1.tm_min ); +} + +// Terry 2001/09/28 +#ifdef _SERVICE +void LogService( + char *CharName, //角色名称 + char *CharID, //玩家ID + int itemid, //物品ID + char *Key, //说明 + int floor, + int x, + int y +) +{ + struct tm tm1; + + memcpy(&tm1,localtime((time_t *)&NowTime.tv_sec),sizeof(tm1)); + printl(LOG_SERVICE,"%s\t%s\t%d=%s,(%d,%d,%d)(%d:%d)", + CharName,CharID,itemid,Key,floor,x,y,tm1.tm_hour,tm1.tm_min); + print("%s\t%s\t%d=%s,(%d,%d,%d)(%d:%d)", + CharName,CharID,itemid,Key,floor,x,y,tm1.tm_hour,tm1.tm_min); +} +#endif + +#ifdef _TEST_PETCREATE +void LogCreatPet( + char *PetName, int petid, int lv, int hp, + int char_vital, int char_str, int char_tgh, int char_dex, + int vital, int str, int tgh, int dex, + int fixstr, int fixtgh, int fixdex, + int lvup, int petrank, + int flg + ) { + struct tm tm1; + memcpy(&tm1,localtime((time_t *)&NowTime.tv_sec),sizeof(tm1)); + if( flg == 0 ) { + printl(LOG_CREATPET,"%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,power,%d,%d,%d", + PetName, petid, lv, hp, char_vital/100, char_str/100, char_tgh/100, char_dex/100, + vital, str, tgh, dex, lvup, petrank,fixstr,fixtgh,fixdex); + }else { + printl(LOG_AVGCREATPET,"%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,power,%d,%d,%d", + PetName, petid, lv, hp, char_vital/100, char_str/100, char_tgh/100, char_dex/100, + vital, str, tgh, dex, lvup, petrank,fixstr,fixtgh,fixdex); + } +} +#endif + +#ifdef _GAMBLE_ROULETTE +void LogGamble( + char *CharName, //角色名称 + char *CharID, //玩家ID + char *Key, //说明 + int floor, + int x, + int y, + int player_stone, //所拥有金钱 + int Gamble_stone, //下注本金 + int get_stone, //获得 + int Gamble_num, + int flg //flg = 1 玩家 2 庄家 +) +{ + struct tm tm1; + memcpy(&tm1,localtime((time_t *)&NowTime.tv_sec),sizeof(tm1)); + + if( flg == 1 ) { + printl(LOG_GAMBLE,"%s\t%s\t TYPE:%s <>\t(%d,%d,%d)-(%d:%d) GAMBLENUM=%d", + CharName,CharID,Key, player_stone, Gamble_stone, get_stone, floor,x,y,tm1.tm_hour,tm1.tm_min, Gamble_num); + }else if( flg == 2 ) { + printl(LOG_GAMBLE,"%s\tROULETTE MASTER\t TYPE:%s <>\t(%d,%d,%d)-(%d:%d)", + CharName,Key, player_stone, floor,x,y,tm1.tm_hour,tm1.tm_min); + } +} + +#endif + +void LogLogin( + char *CharID, //玩家ID + char *CharName, //角色名称 + int saveIndex, + char *ipadress +) +{ + struct tm tm1; + + memcpy(&tm1,localtime((time_t *)&NowTime.tv_sec),sizeof(tm1)); + + printl(LOG_LOGIN,"%s\t%s\ti=%d\t%s\t(%d:%d)", + CharID,CharName,saveIndex,ipadress,tm1.tm_hour,tm1.tm_min); + +} + + +void warplog_to_file() +{ + int i =0; + char outbuf[128]; + FILE *f; + f = fopen("log/warp1.log" ,"w" ); + if( !f ) return; + + for( i=0; i +#include +#include + + +void lssproto_SetServerLogFiles( char *r , char *w ) +{ + lssproto_strcpysafe( lssproto_writelogfilename , w , sizeof(lssproto_writelogfilename )); + lssproto_strcpysafe( lssproto_readlogfilename , r , sizeof(lssproto_readlogfilename )); +} +int lssproto_InitServer( int (*writefunc)(int,char*,int) , int worksiz ) +{ + int i; + if( (void*)writefunc == NULL){lssproto.write_func = lssproto_default_write_wrap;} else {lssproto.write_func = writefunc;} + lssproto_AllocateCommonWork(worksiz); + lssproto_stringwrapper = (char**)calloc( 1,sizeof(char*) * MAXLSRPCARGS); + if(lssproto_stringwrapper ==NULL)return -1; + memset( lssproto_stringwrapper , 0, sizeof(char*)*MAXLSRPCARGS); + for(i=0;i",fd,__LINE__,func) + +int lssproto_ServerDispatchMessage(int fd, char *encoded) +{ + int func,fieldcount; + char raw[65500]; + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + + util_DecodeMessage(raw,encoded); + + if( !util_SplitMessage(raw,SEPARATOR) ){ + print("\nDME1:package=%s\n",raw); + DME(); return -1; + } + if (!util_GetFunctionFromSlice(&func, &fieldcount)) { + logHack(fd,HACK_GETFUNCFAIL); + DME(); return -1; + } + + if (func==LSSPROTO_W_RECV) { + int checksum=0, checksumrecv; + int x; + int y; + char direction[65500]; + + checksum += util_deint(2, &x); + checksum += util_deint(3, &y); + checksum += util_destring(4, direction); + util_deint(5, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_W_recv(fd, x, y, direction); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_W2_RECV) { + int checksum=0, checksumrecv; + int x; + int y; + char direction[65500]; + + checksum += util_deint(2, &x); + checksum += util_deint(3, &y); + checksum += util_destring(4, direction); + util_deint(5, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_W2_recv(fd, x, y, direction); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_EV_RECV) { + int checksum=0, checksumrecv; + int event; + int seqno; + int x; + int y; + int dir; + + checksum += util_deint(2, &event); + checksum += util_deint(3, &seqno); + checksum += util_deint(4, &x); + checksum += util_deint(5, &y); + checksum += util_deint(6, &dir); + util_deint(7, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_EV_recv(fd, event, seqno, x, y, dir); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_DU_RECV) { + int checksum=0, checksumrecv; + int x; + int y; + + checksum += util_deint(2, &x); + checksum += util_deint(3, &y); + util_deint(4, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_DU_recv(fd, x, y); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_EO_RECV) { + int checksum=0, checksumrecv; + int dummy; + + checksum += util_deint(2, &dummy); + util_deint(3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_EO_recv(fd, dummy); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_BU_RECV) { + int checksum=0, checksumrecv; + int dummy; + + checksum += util_deint(2, &dummy); + util_deint(3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_BU_recv(fd, dummy); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_JB_RECV) { + int checksum=0, checksumrecv; + int x; + int y; + + checksum += util_deint(2, &x); + checksum += util_deint(3, &y); + util_deint(4, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_JB_recv(fd, x, y); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_LB_RECV) { + int checksum=0, checksumrecv; + int x; + int y; + + checksum += util_deint(2, &x); + checksum += util_deint(3, &y); + util_deint(4, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_LB_recv(fd, x, y); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_B_RECV) { + int checksum=0, checksumrecv; + char command[65500]; + + checksum += util_destring(2, command); + util_deint(3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_B_recv(fd, command); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_SKD_RECV) { + int checksum=0, checksumrecv; + int dir; + int index; + + checksum += util_deint(2, &dir); + checksum += util_deint(3, &index); + util_deint(4, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_SKD_recv(fd, dir, index); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_ID_RECV) { + int checksum=0, checksumrecv; + int x; + int y; + int haveitemindex; + int toindex; + + checksum += util_deint(2, &x); + checksum += util_deint(3, &y); + checksum += util_deint(4, &haveitemindex); + checksum += util_deint(5, &toindex); + util_deint(6, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_ID_recv(fd, x, y, haveitemindex, toindex); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_PI_RECV) { + int checksum=0, checksumrecv; + int x; + int y; + int dir; + + checksum += util_deint(2, &x); + checksum += util_deint(3, &y); + checksum += util_deint(4, &dir); + util_deint(5, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_PI_recv(fd, x, y, dir); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_DI_RECV) { + int checksum=0, checksumrecv; + int x; + int y; + int itemindex; + + checksum += util_deint(2, &x); + checksum += util_deint(3, &y); + checksum += util_deint(4, &itemindex); + util_deint(5, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_DI_recv(fd, x, y, itemindex); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_DG_RECV) { + int checksum=0, checksumrecv; + int x; + int y; + int amount; + + checksum += util_deint(2, &x); + checksum += util_deint(3, &y); + checksum += util_deint(4, &amount); + util_deint(5, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_DG_recv(fd, x, y, amount); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_DP_RECV) { + int checksum=0, checksumrecv; + int x; + int y; + int petindex; + + checksum += util_deint(2, &x); + checksum += util_deint(3, &y); + checksum += util_deint(4, &petindex); + util_deint(5, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_DP_recv(fd, x, y, petindex); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_MI_RECV) { + int checksum=0, checksumrecv; + int fromindex; + int toindex; + + checksum += util_deint(2, &fromindex); + checksum += util_deint(3, &toindex); + util_deint(4, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_MI_recv(fd, fromindex, toindex); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_MSG_RECV) { + int checksum=0, checksumrecv; + int index; + char message[65500]; + int color; + + checksum += util_deint(2, &index); + checksum += util_destring(3, message); + checksum += util_deint(4, &color); + util_deint(5, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_MSG_recv(fd, index, message, color); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_PMSG_RECV) { + int checksum=0, checksumrecv; + int index; + int petindex; + int itemindex; + char message[65500]; + int color; + + checksum += util_deint(2, &index); + checksum += util_deint(3, &petindex); + checksum += util_deint(4, &itemindex); + checksum += util_destring(5, message); + checksum += util_deint(6, &color); + util_deint(7, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_PMSG_recv(fd, index, petindex, itemindex, message, color); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_AB_RECV) { + int checksum=0, checksumrecv; + util_deint(2, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_AB_recv(fd); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_DAB_RECV) { + int checksum=0, checksumrecv; + int index; + + checksum += util_deint(2, &index); + util_deint(3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_DAB_recv(fd, index); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_AAB_RECV) { + int checksum=0, checksumrecv; + int x; + int y; + + checksum += util_deint(2, &x); + checksum += util_deint(3, &y); + util_deint(4, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_AAB_recv(fd, x, y); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_L_RECV) { + int checksum=0, checksumrecv; + int dir; + + checksum += util_deint(2, &dir); + util_deint(3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_L_recv(fd, dir); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_TK_RECV) { + int checksum=0, checksumrecv; + int x; + int y; + char message[65500]; + int color; + int area; + + checksum += util_deint(2, &x); + checksum += util_deint(3, &y); + checksum += util_destring(4, message); + checksum += util_deint(5, &color); + checksum += util_deint(6, &area); + util_deint(7, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_TK_recv(fd, x, y, message, color, area); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_M_RECV) { + int checksum=0, checksumrecv; + int fl; + int x1; + int y1; + int x2; + int y2; + + checksum += util_deint(2, &fl); + checksum += util_deint(3, &x1); + checksum += util_deint(4, &y1); + checksum += util_deint(5, &x2); + checksum += util_deint(6, &y2); + util_deint(7, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_M_recv(fd, fl, x1, y1, x2, y2); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_C_RECV) { + int checksum=0, checksumrecv; + int index; + + checksum += util_deint(2, &index); + util_deint(3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_C_recv(fd, index); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_S_RECV) { + int checksum=0, checksumrecv; + char category[65500]; + + checksum += util_destring(2, category); + util_deint(3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_S_recv(fd, category); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_FS_RECV) { + int checksum=0, checksumrecv; + int flg; + + checksum += util_deint(2, &flg); + util_deint(3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_FS_recv(fd, flg); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_HL_RECV) { + int checksum=0, checksumrecv; + int flg; + + checksum += util_deint(2, &flg); + util_deint(3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_HL_recv(fd, flg); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_PR_RECV) { + int checksum=0, checksumrecv; + int x; + int y; + int request; + + checksum += util_deint(2, &x); + checksum += util_deint(3, &y); + checksum += util_deint(4, &request); + util_deint(5, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_PR_recv(fd, x, y, request); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_KS_RECV) { + int checksum=0, checksumrecv; + int petarray; + checksum += util_deint(2, &petarray); + util_deint(3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_KS_recv(fd, petarray); + util_DiscardMessage(); + return 0; + } + +#ifdef _STANDBYPET + if (func==LSSPROTO_SPET_RECV) { + int checksum=0, checksumrecv; + int standbypet; + checksum += util_deint(2, &standbypet); + util_deint(3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_SPET_recv(fd, standbypet); + util_DiscardMessage(); + return 0; + } +#endif + +#ifdef _RIGHTCLICK + if (func==LSSPROTO_RCLICK_RECV) { + int checksum=0, checksumrecv; + int type; + char data[1024]; + checksum += util_deint(2, &type); + checksum += util_destring(3, data); + util_deint(4, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_RCLICK_recv(fd, type, data); + util_DiscardMessage(); + return 0; + } +#endif + + if (func==LSSPROTO_AC_RECV) { + int checksum=0, checksumrecv; + int x; + int y; + int actionno; + + checksum += util_deint(2, &x); + checksum += util_deint(3, &y); + checksum += util_deint(4, &actionno); + util_deint(5, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_AC_recv(fd, x, y, actionno); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_MU_RECV) { + int checksum=0, checksumrecv; + int x; + int y; + int array; + int toindex; + + checksum += util_deint(2, &x); + checksum += util_deint(3, &y); + checksum += util_deint(4, &array); + checksum += util_deint(5, &toindex); + util_deint(6, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_MU_recv(fd, x, y, array, toindex); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_PS_RECV) { + int checksum=0, checksumrecv; + int havepetindex; + int havepetskill; + int toindex; + char data[65500]; + + checksum += util_deint(2, &havepetindex); + checksum += util_deint(3, &havepetskill); + checksum += util_deint(4, &toindex); + checksum += util_destring(5, data); + util_deint(6, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_PS_recv(fd, havepetindex, havepetskill, toindex, data); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_ST_RECV) { + int checksum=0, checksumrecv; + int titleindex; + + checksum += util_deint(2, &titleindex); + util_deint(3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_ST_recv(fd, titleindex); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_DT_RECV) { + int checksum=0, checksumrecv; + int titleindex; + + checksum += util_deint(2, &titleindex); + util_deint(3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_DT_recv(fd, titleindex); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_FT_RECV) { + int checksum=0, checksumrecv; + char data[65500]; + + checksum += util_destring(2, data); + util_deint(3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_FT_recv(fd, data); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_SKUP_RECV) { + int checksum=0, checksumrecv; + int skillid; + + checksum += util_deint(2, &skillid); + util_deint(3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_SKUP_recv(fd, skillid); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_KN_RECV) { + int checksum=0, checksumrecv; + int havepetindex; + char data[65500]; + + checksum += util_deint(2, &havepetindex); + checksum += util_destring(3, data); + util_deint(4, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_KN_recv(fd, havepetindex, data); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_WN_RECV) { + int checksum=0, checksumrecv; + int x; + int y; + int seqno; + int objindex; + int select; + char data[65500]; + + checksum += util_deint(2, &x); + checksum += util_deint(3, &y); + checksum += util_deint(4, &seqno); + checksum += util_deint(5, &objindex); + checksum += util_deint(6, &select); + checksum += util_destring(7, data); + + util_deint(8, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_WN_recv(fd, x, y, seqno, objindex, select, data); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_SP_RECV) { + int checksum=0, checksumrecv; + int x; + int y; + int dir; + + checksum += util_deint(2, &x); + checksum += util_deint(3, &y); + checksum += util_deint(4, &dir); + util_deint(5, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_SP_recv(fd, x, y, dir); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_CLIENTLOGIN_RECV) { + int checksum=0, checksumrecv; + char cdkey[65500]; + char passwd[65500]; + + strcpy(PersonalKey, _DEFAULT_PKEY); + + checksum += util_destring(2, cdkey); + checksum += util_destring(3, passwd); + + util_deint(4, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + + lssproto_ClientLogin_recv(fd, cdkey, passwd); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_CREATENEWCHAR_RECV) { + int checksum=0, checksumrecv; + int dataplacenum; + char charname[65500]; + int imgno; + int faceimgno; + int vital; + int str; + int tgh; + int dex; + int earth; + int water; + int fire; + int wind; + int hometown; + + checksum += util_deint(2, &dataplacenum); + checksum += util_destring(3, charname); + checksum += util_deint(4, &imgno); + checksum += util_deint(5, &faceimgno); + checksum += util_deint(6, &vital); + checksum += util_deint(7, &str); + checksum += util_deint(8, &tgh); + checksum += util_deint(9, &dex); + checksum += util_deint(10, &earth); + checksum += util_deint(11, &water); + checksum += util_deint(12, &fire); + checksum += util_deint(13, &wind); + checksum += util_deint(14, &hometown); + util_deint(15, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_CreateNewChar_recv(fd, dataplacenum, charname, imgno, faceimgno, vital, str, tgh, dex, earth, water, fire, wind, hometown); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_CHARDELETE_RECV) { + int checksum=0, checksumrecv; + char charname[65500]; + + checksum += util_destring(2, charname); + util_deint(3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_CharDelete_recv(fd, charname); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_CHARLOGIN_RECV) { + int checksum=0, checksumrecv; + char charname[65500]; + + checksum += util_destring(2, charname); + util_deint(3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_CharLogin_recv(fd, charname); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_CHARLIST_RECV) { + int checksum=0, checksumrecv; +#ifdef _PKSEVER_VER + int star = 0; + util_deint(2, &checksumrecv); + util_deint(3, &star); +#else + util_deint(2, &checksumrecv); +#endif + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + +//#ifdef _PKSEVER_VER +// lssproto_CharList_recv( fd, star); +//#else + lssproto_CharList_recv( fd); +//#endif + + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_CHARLOGOUT_RECV) { + int checksum=0, checksumrecv; + int Flg=1; +#ifdef _CHAR_NEWLOGOUT + checksum += util_deint(2, &Flg); + util_deint(3, &checksumrecv); +#else + util_deint(2, &checksumrecv); +#endif + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_CharLogout_recv(fd, Flg); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_PROCGET_RECV) { + int checksum=0, checksumrecv; + + strcpy( PersonalKey, _DEFAULT_PKEY); + + util_deint(2, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_ProcGet_recv(fd); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_PLAYERNUMGET_RECV) { + int checksum=0, checksumrecv; + util_deint(2, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_PlayerNumGet_recv(fd); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_ECHO_RECV) { + int checksum=0, checksumrecv; + char test[65500]; + + checksum += util_destring(2, test); + util_deint(3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_Echo_recv(fd, test); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_SHUTDOWN_RECV) { + int checksum=0, checksumrecv; + char passwd[65500]; + int min; + + checksum += util_destring(2, passwd); + checksum += util_deint(3, &min); + util_deint(4, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_Shutdown_recv(fd, passwd, min); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_TD_RECV) { + int checksum=0, checksumrecv; + char message[65500]; + + checksum += util_destring(2, message); + util_deint(3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_TD_recv(fd, message); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_FM_RECV) { + int checksum=0, checksumrecv; + char message[65500]; + + checksum += util_destring(2, message); + util_deint(3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_FM_recv(fd, message); + util_DiscardMessage(); + return 0; + } + + if (func==LSSPROTO_PETST_RECV) { + int checksum=0, checksumrecv; + int nPet; + int sPet; + + checksum += util_deint(2, &nPet); + checksum += util_deint(3, &sPet); + util_deint(4, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_PETST_recv(fd, nPet, sPet); + util_DiscardMessage(); + return 0; + } + + // _BLACK_MARKET + if (func==LSSPROTO_BM_RECV) { + int checksum=0, checksumrecv; + int iindex; + + checksum += util_deint(2, &iindex); + util_deint(3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_BM_recv(fd, iindex); + util_DiscardMessage(); + return 0; + } + +#ifdef _FIX_DEL_MAP // WON ADD 玩家抽地图送监狱 + if (func==LSSPROTO_DM_RECV) { + char buffer[2]; + buffer[0] = '\0'; + lssproto_DM_recv( fd ); + util_DiscardMessage(); + return 0; + } + +#endif + +#ifdef _CHECK_GAMESPEED + if (func==LSSPROTO_CS_RECV) { + char buffer[2]; + buffer[0] = '\0'; + lssproto_CS_recv( fd ); + util_DiscardMessage(); + return 0; + } +#endif +#ifdef _TEAM_KICKPARTY + if ( func == LSSPROTO_KTEAM_RECV ) { + int checksum = 0, checksumrecv; + int sindex; + checksum += util_deint( 2, &sindex); + util_deint( 3, &checksumrecv); + if(checksum!=checksumrecv){ + util_DiscardMessage(); + logHack( fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_KTEAM_recv( fd, sindex); + util_DiscardMessage(); + return 0; + } +#endif + +#ifdef _MIND_ICON + if(func==LSSPROTO_MA_RECV){ + int checksum = 0, checksumrecv; + int nMind; + int x, y; + + checksum += util_deint( 2, &nMind); + checksum += util_deint( 3, &x); + checksum += util_deint( 4, &y); + util_deint( 5, &checksumrecv); + if(checksum!=checksumrecv){ + util_DiscardMessage(); + logHack( fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_MA_recv(fd, x, y, nMind); + util_DiscardMessage(); + return 0; + } +#endif + +#ifdef _CHATROOMPROTOCOL // (不可开) Syu ADD 聊天室频道 + if (func==LSSPROTO_CHATROOM_RECV) { + int checksum=0, checksumrecv; + char test[65500]; + + checksum += util_destring(2, test); + util_deint(3, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_CHATROOM_recv(fd, test); + util_DiscardMessage(); + return 0; + } +#endif + +#ifdef _NEWREQUESTPROTOCOL // (不可开) Syu ADD 新增Protocol要求细项 + if ( func==LSSPROTO_RESIST_RECV ) { + char buffer[2]; + buffer[0] = '\0'; + lssproto_RESIST_recv( fd ); + util_DiscardMessage(); + return 0; + } +#endif +#ifdef _OUTOFBATTLESKILL // (不可开) Syu ADD 非战斗时技能Protocol + if(func==LSSPROTO_BATTLESKILL_RECV){ + int checksum = 0, checksumrecv; + int iNum; + + checksum += util_deint( 2, &iNum); + util_deint( 3, &checksumrecv); + if(checksum!=checksumrecv){ + util_DiscardMessage(); + logHack( fd, HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_BATTLESKILL_recv(fd, iNum); + util_DiscardMessage(); + return 0; + } +#endif +#ifdef _STREET_VENDOR + if(func == LSSPROTO_STREET_VENDOR_RECV){ + int checksum = 0,checksumrecv; + char message[65500]; + + checksum += util_destring(2,message); + util_deint(3,&checksumrecv); + if(checksum != checksumrecv){ + util_DiscardMessage(); + logHack(fd,HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_STREET_VENDOR_recv(fd,message); + util_DiscardMessage(); + return 0; + } +#endif +#ifdef _JOBDAILY + if(func == LSSPROTO_JOBDAILY_RECV){ + int checksum = 0,checksumrecv; + char buffer[16384]; + + buffer[0] = '\0'; + memset(buffer,0,16384); //kkkkkkkkk + checksum += util_destring(2,buffer); + util_deint(3,&checksumrecv); + if(checksum != checksumrecv){ + util_DiscardMessage(); + logHack(fd,HACK_CHECKSUMERROR); + DME(); return -1; + } + print("\njobdaily:%s ",buffer); + lssproto_JOBDAILY_recv(fd,buffer); + util_DiscardMessage(); + return 0; + + } +#endif +#ifdef _TEACHER_SYSTEM + if(func == LSSPROTO_TEACHER_SYSTEM_RECV){ + int checksum = 0,checksumrecv; + char message[65500]; + + checksum += util_destring(2,message); + util_deint(3,&checksumrecv); + if(checksum != checksumrecv){ + util_DiscardMessage(); + logHack(fd,HACK_CHECKSUMERROR); + DME(); return -1; + } + lssproto_TEACHER_SYSTEM_recv(fd,message); + util_DiscardMessage(); + return 0; + } +#endif +#ifdef _ADD_STATUS_2 + if(func == LSSPROTO_S2_RECV){ + return 0; + } +#endif + + util_DiscardMessage(); + logHack(fd,HACK_NOTDISPATCHED); + DME(); return -1; +} + +/* + servertoclient XYD( int x, int y, int dir ); + 潜卞爵 蔽 卞皿伊奶乩□及匏 毛 譬帮允月凶户卞银丹[ +*/ +void lssproto_XYD_send(int fd,int x,int y,int dir) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkint(buffer, x); + checksum += util_mkint(buffer, y); + checksum += util_mkint(buffer, dir); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_XYD_SEND, buffer); +} + +void lssproto_EV_send(int fd,int seqno,int result) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkint(buffer, seqno); + checksum += util_mkint(buffer, result); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_EV_SEND, buffer); +} + +void lssproto_EN_send(int fd,int result,int field) +{ + char buffer[65500]; + int checksum=0; + + //print(" EN_send "); + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkint(buffer, result); + checksum += util_mkint(buffer, field); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_EN_SEND, buffer); +} + + +void lssproto_RS_send(int fd,char* data) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkstring(buffer, data); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_RS_SEND, buffer); +} + + +void lssproto_RD_send(int fd,char* data) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkstring(buffer, data); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_RD_SEND, buffer); +} + +void lssproto_B_send(int fd,char* command) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkstring(buffer, command); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_B_SEND, buffer); +} + +void lssproto_I_send(int fd,char* data) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkstring(buffer, data); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_I_SEND, buffer); +} + +void lssproto_SI_send(int fd,int fromindex,int toindex) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkint(buffer, fromindex); + checksum += util_mkint(buffer, toindex); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_SI_SEND, buffer); +} + +void lssproto_MSG_send(int fd,int aindex,char* text,int color) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkint(buffer, aindex); + checksum += util_mkstring(buffer, text); + checksum += util_mkint(buffer, color); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_MSG_SEND, buffer); +} + + +void lssproto_PME_send(int fd,int objindex,int graphicsno,int x,int y,int dir,int flg,int no,char* cdata) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkint(buffer, objindex); + checksum += util_mkint(buffer, graphicsno); + checksum += util_mkint(buffer, x); + checksum += util_mkint(buffer, y); + checksum += util_mkint(buffer, dir); + checksum += util_mkint(buffer, flg); + checksum += util_mkint(buffer, no); + checksum += util_mkstring(buffer, cdata); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_PME_SEND, buffer); +} + + +void lssproto_AB_send(int fd,char* data) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkstring(buffer, data); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_AB_SEND, buffer); +} + + +void lssproto_ABI_send(int fd,int num,char* data) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkint(buffer, num); + checksum += util_mkstring(buffer, data); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_ABI_SEND, buffer); +} + +void lssproto_TK_send(int fd,int index,char* message,int color) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkint(buffer, index); + checksum += util_mkstring(buffer, message); + checksum += util_mkint(buffer, color); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_TK_SEND, buffer); +} + +void lssproto_MC_send(int fd,int fl,int x1,int y1,int x2,int y2,int tilesum,int objsum,int eventsum,char* data) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkint(buffer, fl); + checksum += util_mkint(buffer, x1); + checksum += util_mkint(buffer, y1); + checksum += util_mkint(buffer, x2); + checksum += util_mkint(buffer, y2); + checksum += util_mkint(buffer, tilesum); + checksum += util_mkint(buffer, objsum); + checksum += util_mkint(buffer, eventsum); + checksum += util_mkstring(buffer, data); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_MC_SEND, buffer); +} + + +void lssproto_M_send(int fd,int fl,int x1,int y1,int x2,int y2,char* data) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkint(buffer, fl); + checksum += util_mkint(buffer, x1); + checksum += util_mkint(buffer, y1); + checksum += util_mkint(buffer, x2); + checksum += util_mkint(buffer, y2); + checksum += util_mkstring(buffer, data); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_M_SEND, buffer); +} + +/* + servertoclient C( string data ); + (Characters) + 弁仿奶失件玄反 CA 互 化}公及平乓仿卞勾中化譬卅井匀凶凛反} C + 匹仇及楮醒毛邰菲匹五月[扔□田反民尼永弁仄卅中[ + + string data + 白巧□穴永玄反 动票及3潘 及嫩 毛戊件穴匹卅日屯凶 + 手及匹丐月.公木冗木及嫩 及 褥反今日卞凶化徇'|'匹仁亢日木 + 化中月[ + + 凶化徇匹仁亢日木凶玄□弁件互12蜊及桦宁 + 玄□弁件及 反 + + WHICHTYPE|CHARINDEX|X|Y|DIR|BASEIMG|LEVEL|NAMECOLOR|NAME|SELFTITLE|WALKABLE|HEIGHT|POPUPNAMECOLOR + 仇及左皮斥尼弁玄反平乓仿弁正□匹丐月午中丹仇午匹丐月[ + + WHICHTYPE 反]仇及平乓仿弁正□互升丹中匀凶潘 及手及 + 匹丐月井[仇木反扔□田□匹反动票及方丹卞烂聒今木化中月[ + + typedef enum + { + CHAR_TYPENONE, 窒匹手卅中 + CHAR_TYPEPLAYER, 皿伊奶乩□ + CHAR_TYPEENEMY, 衬 + CHAR_TYPEPET, 矢永玄 + CHAR_TYPEDOOR, 玉失 + CHAR_TYPEBOX , + CHAR_TYPEMSG , 枣 + CHAR_TYPEWARP , 伐□皿札□件 + CHAR_TYPESHOP , 饕 + CHAR_TYPEHEALER , 甲□仿□ + CHAR_TYPEOLDMAN , 赢 + CHAR_TYPEROOMADMIN, 尕 遣盒 + CHAR_TYPETOWNPEOPLE, 引切及夫午 + CHAR_TYPEDENGON, 鳗蜕 + CHAR_TYPEADM, 鳗蜕 + CHAR_TYPETEMPLE, Temple master + CHAR_TYPESTORYTELLER, 贿曰 + CHAR_TYPERANKING, 尕 遣仿件平件弘 憎 + CHAR_TYPEOTHERNPC, 公及职及腹绸覆擂卞卅日卅中NPC + CHAR_TYPEPRINTPASSMAN, 玉失及由旦伐□玉 憎允月NPC + CHAR_TYPENPCENEMY, 裔烂衬 + CHAR_TYPEACTION, 失弁扑亦件卞 杀允月NPC + CHAR_TYPEWINDOWMAN, 它奴件玉它 憎允月NPC 旦玄井手) + CHAR_TYPESAVEPOINT, 本□皮禾奶件玄 + CHAR_TYPEWINDOWHEALER, 它奶件玉它正奶皿及甲□仿□ + CHAR_TYPEITEMSHOP, 云饕 + CHAR_TYPESTONESHOP, 檗 盒 矢永玄及 盒 + CHAR_TYPEDUELRANKING, DUEL仿件平件弘NPC + CHAR_TYPEWARPMAN, 伐□皿穴件NPC + CHAR_TYPEEVENT, 奶矛件玄NPC + CHAR_TYPEMIC, 奶矛件玄NPC + CHAR_TYPELUCKYMAN, 奶矛件玄NPC + CHAR_TYPEBUS, 穴件乒旦田旦 + CHAR_TYPECHARM, 奶矛件玄NPC + CHAR_TYPENUM, + }CHAR_TYPE; + + 公木反职及皿伊奶乩□支NPC支衬匹丐月[扔□田□互霜耨 + 允月午五反苇尹月 区卞勾中化蝈 霜耨允月[勾引 + 曰弁仿奶失件玄反}仇及由弗永玄毛熬仃午匀凶午五卞仇及 + 由弗永玄卞踏井木化中卅中平乓仿毛 匀化中凶日壅仄化仄 + 引匀化方中午中丹仇午匹丐月[引凶}穴它旦市□末伙毛丐 + 歹六凶午五卞 憎允月树 反仇及树 及心卞湘中化中月[ + 分井日}穴它旦市□末伙毛丐歹六凶午五卞 憎允月仇午互 + 凳今木凶桦宁反}扔□田□反}仇及楮醒毛 读卞裟太 + 分今卅仃木壬卅日卅中[ SELFTITLE卞勾中化反}犯伉立正 + 匹丐月凶化徇毛孔仁引卅中方丹卞巨旦弗□皿今木化中月[ + 弁仿奶失件玄反失弁扑亦件及戊穴件玉(CA)互仁月引匹反 + 切匹 憎允月[CHARINDEX扔□田□ 及域啦卞平乓仿毛 + 烂匹五月 寞}BASEIMG反 憎及凶户及 寞}LEVEL反平乓 + 仿及伊矛伙(0卅日 憎仄卅中[仇及袄反NPC卅升卞银丹[) + WALKABLE反1及午五公及晓毛骚聊允月仇午互匹五}0卅日骚 + 聊允月仇午互匹五卅中[HEIGHT反嫖今毛手勾手及井公丹匹 + 卅中及井及隙烂[ + + 平乓仿弁正□及 蟆午愤 惫寞反} + 巨旦弗□皿今木卅仃木壬卅日卅中['|'匹玄□弁件毛 + 潸曰分仄化井日巨旦弗□皿毛荸轮允月[巨旦弗□皿允月午' + |'互幻井及 侬卞云五井歹月及匹} 赓反签账卞'|'毛犯 + 伉立正午仄化方中[霜耨允月 手} 蟆午愤 惫寞毛巨旦 + 弗□皿仄化井日凶化徇匹勾卅中匹井日霜耨允月[ + 引凶]矢永玄及桦宁反愤 惫寞及医歹曰卞交□扒□互涩烂 + 仄凶矢永玄及 蟆互霜耨今木化仁月[ + + 凶化徇匹仁亢日木凶玄□弁件互6蜊及桦宁 + 玄□弁件及 反 + INDEX|X|Y|BASEIMG|LEVEL|ITEM1LINEINFO + 匹哗 卞 切化中月失奶 丞卞勾中化及树 匹丐月[ + INDEX反平乓仿及奶件犯弁永旦午井少日卅中INDEX匹丐月[ + 公及失奶 丞毛壅允凛卞银迕允月[X,Y反失奶 丞及弘夫□ + 田伙匏 [BASEIMG反 飓及 寞[ITEM1LINEINFO反1垫 + info卞 憎允月凶户及树 匹丐月[失奶 丞它奶件玉它 + 及 憎迕及树 反 及 芊匹迕啦允月[失奶 丞卞楮仄化 + 反CA反 卅中[ITEM1LINEINFO反巨旦弗□ + 皿今木月[仇及巨旦弗□皿及 芊反晓及嫩 毛辅寰[ + + 凶化徇匹仁亢日木凶玄□弁件互4蜊及桦宁 + 玄□弁件及 反 + INDEX|X|Y|VALUE + 匹哗 卞 切化中月云嗯卞勾中化及树 匹丐月[ 反允 + 屯化醒侬[INDEX,X,Y 反失奶 丞午 元[VALUE 反升木分 + 仃及汹井午中丹仪匹丐月[失奶 丞卞勾中化及树 匹丐月[ + 凶化徇匹仁亢日木凶玄□弁件互1蜊及桦宁 + INDEX + 仇及平乓仿及C反项尹日木卅中[ +*/ +void lssproto_C_send(int fd,char* data) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkstring(buffer, data); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_C_SEND, buffer); +} + +/* + servertoclient CA( string data ); + (CharacterAction) + 苇尹月 区卞中月平乓仿及失弁扑亦件橇谪毛凳蕙允月[ + 扔□田□井日弁仿奶失件玄卞域 读卞霜耨允月[ + 备平乓仿及1失弁扑亦件仍午卞霜耨[扔□田□反失弁扑亦件毛匹五月分 + 仃做谅允月仇午[ + + string data + CHARINDEX|X|Y|ACTION|PARAM1|PARAM2|PARAM3|PARAM4|....毛戊 + 件穴匹仁亢匀凶手及卞允月[PARAM反失弁扑亦件仍午卞蜊醒手 + 银中井凶手仇午卅月[动票反失弁扑亦件域 [X,Y反匏 匹升 + 及失弁扑亦件匹手}丐凶日仄中匏 毛隙烂允月[ + 仇及 侬 反巨旦弗□皿今木卅中[ + + ACTION PARAM1 PARAM2 + PARAM3 PARAM4 + Stand:0 轾0~7 + Walk:1 轾0~7 + Attack:2 轾0~7 + Throw:3 轾0~7 + Damage:4 轾0~7 + Dead:5 轾0~7 + UseMagic:6 轾0~7 + UseItem:7 轾0~7 + Effect:8 轾0~7 巨白尼弁玄 寞 + Down:10 (逦木月) 轾0~7 + Sit:11 (甄月) 轾0~7 + Hand:12 (澎毛蕊月) 轾0~7 + Pleasure:13 (减少) 轾0~7 + Angry:14 (变月) 轾0~7 + Sad:15 ( 仄戈) 轾0~7 + Guard:16 (布□玉) 轾0~7 + actionwalk:17 (失弁扑亦件迕汹五) 轾0~7 + nod:18 (丹卅内仁) 轾0~7 + actionstand:19 (失弁扑亦件迕 切禾□术) 轾0~7 + Battle:20 (爵 树 ) 轾0~7 BattleNo(-1 卅日 憎壅允 SideNo HelpNo ㄠ卅日踞仃毛裟少CA 憎]ㄟ卅日壅允]引凶反 仄 + Leader:21 (伉□母□树 ) 轾0~7 0: 憎壅允 1: 憎 + Watch:22 (爵 棋爵) 轾0~7 0: 憎壅允 1: 憎 + namecolor:23( 蟆及缙树 ) 轾0~7 蟆及缙 寞 + Turn:30( 轾 晶) 轾0~7 + Warp:31(伐□皿) 轾0~7 + + ACTION及袄反帮醒匹} 反晓及 及尔羹及嫩 匹丐月[ +*/ +void lssproto_CA_send(int fd,char* data) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkstring(buffer, data); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_CA_SEND, buffer); +} + +/* + servertoclient CD( string data ); + (CharacterDelete) + data 反犯伉立正 , 匹嗉濠日木凶奶件犯永弁旦[ + 醒瘀霜月仪互请 月[ + 仇及ID毛 匀化中月平乓仿弁正互壅尹凶凛卞扔□田井日弁仿奶失件玄尺 + 午鳗歹月[ +*/ +void lssproto_CD_send(int fd,char* data) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkstring(buffer, data); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_CD_SEND, buffer); +} + +/* + servertoclient R( string data ); + (Radar) + 伊□母□及 毛弁仿奶失件玄卞霜耨允月[弁仿奶失件玄反仇及霜耨毛 + 邰菲允月仇午反卅中[扔□田□互赝癫卅正奶立件弘匹霜耨允月[ + 凶午尹壬10汹丐月仁仍午午井}1坌仍午午井[ + + string data + x ,y, kind ,及赐卞袄毛'|'匹仁亢匀化卅日屯凶手及毛 + 今日卞'|'匹卅日屯凶手及[ + x,y反平乓仿井日及濮覆匏 [kind反动票卞仄户允醒袄匹反卅中 + 筏寞[伊□母□卞丹勾月 及潘 毛隙烂允月[霜日木化仁月手及 + 及潘 反}公木引匹卞儒尹凶 芊午井}旦平伙匹 祭仄}公木反 + 扔□田□互哔尹月[ + + kind及袄 + E 衬 + P 皿伊奶乩□ + S 熔 + G 云嗯 + I 失奶 丞(熔动陆) + + data及 “"12|22|E|13|24|P|14|28|P" + 仇及 侬 反巨旦弗□皿今木卅中[ +*/ +void lssproto_R_send(int fd,char* data) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkstring(buffer, data); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_R_SEND, buffer); +} + +/* + servertoclient S( string data ); + (Status) + 平乓仿及旦 □正旦毛霜耨允月[ + 犯□正反 市 打伉筏寞 侬(域 侬) 午卅匀化中月[勾引曰 赓及 + 1 侬毛苇木壬窒及旦 □正旦井坌月[ 反2 侬 井日匹丐月[ + 反动票及白巧□穴永玄卞仄凶互丹[凶化徇筏寞'|'互犯伉立正匹丐月[ + 2蜊 动嫦及玄□弁件互 匹丐月[ + + P 蝈由仿丢□正 + kubun hp maxhp mp maxmp str tough exp maxexp exp + level attackpower deffencepower + fixdex fixcharm fixluck fixfireat fixwaterat fixearthat fixwindat + gold 尥仃化中月 + 惫寞及index 蟆 愤裘惫寞 + + 犯伉立正反 '|' 匹丐月[引凶 蟆午愤裘惫寞反} + 巨旦弗□皿仄凶手及毛 + 凶化徇匹勾卅仆凶手及互骚耨今木月[ + 公木冗木及袄及滇反动票[ + kubun 卞ㄠ互 匀化中月午蟆由仿丢□正毛霜耨] + ㄡ动晓分午]备申永玄及 匀化中月手及及由仿丢□正互赐 卞 匀化霜耨今木化中月[ + 尹壬]ㄢ互 凶日hp午Maxhp互kubun 动嫦及玄□弁件卞 户日木化中月[ + + kunun int + Hp( )hp int + MaxHp int + Mp(热诸由伐□) int + MaxMp int + Vital( ) int + Str( ) int + Tough(暹屺今) int + Dex(豳镀今) int + Exp(烦董袄)exp int + MaxExp(戚引匹及烦董袄) int + Level(伊矛伙) int + Attack( 猾 ) int + Defense(潮 ) int + fQuick( 蔽豳镀今) int + fCharm( ) int + fLuck(扪) int + fEarth(哗)fixearthat int + fWater( ) int + fFire(绍) int + fWid(氘)fixwindat int + Gold(云嗯) int + 惫寞及index int + 犯亘巨伙禾奶件玄 int + 鳖戏荚醒 int + 蟆 侬 + 愤裘惫寞 侬 + + 填 ( char 及 公及引引踏仁 ) + + P10|20|10|20|10|10|10|1|2|13|13|1|100|10|尺氏天|abc|def + + C 甄 + floor maxx maxy x y + 毛 | 匹嗉濠匀化霜月[ + 填 ( char 及 公及引引踏仁 ) + + C1024|100|100|10|20 + + 晓筏及 匹反}白夫失ID1024, 扔奶术100x100 X 10,Y 20及午仇 + 欠卞平乓仿弁正□互中月午中丹 卞卅月[仇及穴奶平乓仿及白 + 夫失手孔仁户凶甄 毛弁仿奶失件玄互襞月仇午互匹五月及反仇及 + 戊穴件玉及心匹丐月[汹五及瑛绊反白夫失 及匏 仄井歹井日卅 + 中[方匀化}必□丞钒铵凛}闭蟾银迕及午五}伐□皿及午五卅升 + 反}仇及戊穴件玉毛勾井匀化恳仄中袄毛霜耨仄卅仁化反卅日卅中[ + + I 蝈失奶 丞 + (失奶 丞1)|(失奶 丞2)...(失奶 丞n) + 失奶 丞及 反动票及 芊匹由永弁允月[ + 夫午勾及失奶 丞反}井卅日内动票及6勾及玄□弁件及本永玄匹 + 霜耨今木月[夫午勾夫午勾及 反} + + 蟆| 蟆2|旦 □斥|失奶 丞及 |失瓦丢 寞|银迕第 桦赭|银迕覆擂|失奶 丞伊矛伙|白仿弘 + + 失奶 丞 反摹 伊矛伙匹愤 读卞 凳今木月[ + 蟆2反摹 伊矛伙卞方匀化}失奶 丞及 互 月 烂[ + 弁仿奶失件玄及失奶 丞 及2垫 卞 木月仪[ + 旦 □斥反 蟆及缙毛赘月及卞银丹[ + 失奶 丞及 [ + 失瓦丢 寞反} 飓 寞[ + 银迕第 桦赭午反]仇及失奶 丞互升仇匹银迕允月仪互第 井互 匀化中月[ + 仇木反]扔□田□匹反动票及方丹卞烂聒今木化中月[ + + typedef enum + { + ITEM_FIELD_ALL, 允屯化及桦赭匹银尹月 + ITEM_FIELD_BATTLE, 爵 及心 + ITEM_FIELD_MAP, 骚橘穴永皿晓及心 + + }ITEM_FIELDTYPE; + + 银迕覆擂午反]仇及失奶 丞毛银迕允月仇午及请 月覆擂互 匀化中月[ + 扔□田□匹反动票及方丹卞烂聒今木化中月[ + + typedef enum + { + ITEM_TARGET_MYSELF, 愤坌及心 + ITEM_TARGET_OTHER, 职及谛 愤坌殖戈) + ITEM_TARGET_ALLMYSIDE, 蝈 + ITEM_TARGET_ALLOTHERSIDE, 锹澎础蝈 + ITEM_TARGET_ALL, 蝈化 + }ITEM_TARGETTYPE; + + 仇及醒侬卞100毛箫允午]韶氏匹中月樊手覆擂午卅月[ + 失奶 丞伊矛伙[仇及伊矛伙动晓及樊匹卅中午隶 请 卅中[ + 白仿弘 [缙氏卅白仿弘毛霜耨允月[备申永玄及覆杀反动票及骚曰[ + + 0bit 矢永玄丢□伙匹霜耨第 卅失奶 丞井升丹井[霜耨第 分午ㄠ[ㄟ分午霜耨匹五卅中[ + 1Bit 仇及失奶 丞互宁岳请 月井升丹井[ + 2Bit 仇及失奶 丞互 井升丹井[1分午 匹丐月[ + + 仇仇及 匹反巨旦弗□皿允月[ + 填 ( char 及 公及引引踏仁 ) + + I丐幻 卅 阂|str+2|1|丐幻\|中元|10|2|0 + + 旦 □斥及袄及啦 反}帮醒袄匹 + + 1 旦 □斥A + 2 旦 □斥B + 3 旦 □斥C + 4 旦 □斥D + + 午允月[引凶}失奶 丞 及坞及 坌卞勾中化反}5蜊及玄□弁件互 + 坞匹}勾引曰凶化徇互卅日氏分橇谪匹霜耨今木化仁月[ + + S 蝈旦平伙 + (旦平伙0)|(旦平伙1)|(旦平伙2) ... (旦平伙n) + 惫寞午 元匹}平乓仿互手化月 旦平伙醒坌毛霜耨允月[勾引 + 曰卅中手及反 ||| 午卅月及匹丐月[ + 备巨件玄伉及 反} + 旦平伙及潘 戊□玉|伊矛伙 + 匹丐月[ + 填 ( char 及 公及引引踏仁 ) + + S10|2|20|2||| + + T 惫寞 + (惫寞0)|(惫寞1)|(惫寞2) ... (惫寞n) + 惫寞及巨件玄伉互坞及桦宁反 '|' 互 粮允月及匹} 粮仄凶手 + 及毛 仄化旦平乓件仄化反卅日卅中[井卅日内 蜊醒坌霜耨 + 允月[ + 夫午勾}夫午勾及 反} + 蟆 + 及心匹丐月[ + 填 ( 霜日木化仁月 char 及 公及引引匹丐月 ) + + T丐幻|方匀天日中 + + 仇木手巨旦弗□皿允月[ + + M 坌由仿丢□正 + 平乓仿弁正□及旦 □正旦及丹切} 卞 凳今木月手及(蜇箕 + 袄)午公丹匹卅中手及( 袄卅升)互丐月[升木井及旦 □正旦 + 互 凳今木月凶太卞 荚蝈 及由仿丢□正毛霜耨允月及反生永玄 + 伐□弁玄仿白奴永弁毛 蛲卞银丹仇午卞卅月及匹} 卞HP , + MP,EXP及袄分仃卞仄廿匀凶由仿丢□正霜耨戊穴件玉毛迕啦允月[ + 公木互仇及M戊穴件玉匹丐月[2 侬 动嫦及 域玄□弁件反HP及 + 蜇箕袄 , 玄□弁件反MP} 赶玄□弁件反EXP匹丐月[ + 动票卞填 毛仄户允[ + + M54|210|8944909 + + 仇及 匹反HP及蜇箕袄互54}MP及蜇箕袄互210}烦董袄互8944909 + 卞卅匀化中月及分[仇及3潘 反 卞 凳 蘸互嫖中午 歹木月 + 凶户 仄凶戊穴件玉祭仄凶互}手切欠氏仇及M戊穴件玉及井歹 + 曰卞P戊穴件玉匹蝈由仿丢□正毛霜耨仄化手方中[凶分仄} 赝 + 卞生永玄伐□弁毛银丹凶户卞反}仇及戊穴件玉毛银丹仇午互蹂俦 + 今木月[ + + D 平乓仿及ID + 夫弘奶件凛卞分仃霜月平乓仿及index]公木午凛棉毛霜月[ + D1000|912766409午井匹霜日木月[ + + E 巨件市它件玄割 票蜃)|(晓蜃) + 巨件市它件玄 毛霜耨允月[割 反n/100 + 弁仿奶失件玄反]票蜃及袄井日旦正□玄仄化]ㄠ汹汹仁 卞+1仄凶割 匹巨件市它件玄允月井毛 蝇允月[ + 凶分仄]晓蜃及袄毛旋尹卅中方丹卞允月[ + 戚荚卞仇木互霜日木化仁月引匹仇及割 匹巨件市它件玄毛煌遥允月仪[ + + J0 J6 银尹月热诸及 + 银尹月热诸及 毛霜耨允月[ + 0 6 反公木冗木失奶 丞及隶 组赭卞覆杀仄化中月[域 及隶 组赭 ] ]澎]隶澡 + 仄井隶 请 卅中 烂分互]漆 傀舰及啃卞蝈化及隶 组赭及树 毛霜月 + J0|kubun|mp|field|target|name|comment + 午中丹白巧□穴永玄卞卅匀化中月[ + kubun 反公及 互丐月井 中井[ㄟ分午 中[公木动嫦卞玄□弁件允日卅中[ㄠ分午丐月[ + mp反壅 竣 毛 允[ + field反升及桦赭匹银尹月井[扔□田□匹反动票及 卞烂聒今木化中月[ + + typedef enum + { + MAGIC_FIELD_ALL, 允屯化及桦赭匹银尹月 + MAGIC_FIELD_BATTLE, 爵 及心 + MAGIC_FIELD_MAP, 骚橘穴永皿晓及心 + + }MAGIC_FIELDTYPE; + + target反升木毛覆擂卞请 月井[扔□田□匹反动票及方丹卞烂聒今木化中月[ + + typedef enum + { + MAGIC_TARGET_MYSELF, 愤坌及心 + MAGIC_TARGET_OTHER, 职及谛 愤坌殖戈) + MAGIC_TARGET_ALLMYSIDE, 蝈 + MAGIC_TARGET_ALLOTHERSIDE, 锹澎础蝈 + MAGIC_TARGET_ALL, 蝈化 + MAGIC_TARGET_NONE, 簿手蓟 请 卅中[ 豢支凶户及凛 + MAGIC_TARGET_OTHERWITHOUTMYSELF,职及谛 愤坌殖引卅中) + MAGIC_TARGET_WITHOUTMYSELFANDPET, 愤坌午矢永玄动陆 + MAGIC_TARGET_WHOLEOTHERSIDE, 及扔奶玉蝈 + }MAGIC_TARGETTYPE; + + 仇及醒侬卞100毛箫允午]韶氏匹中月樊手覆擂午卅月[ + + name反热诸 [ + comment反仇及热诸及 [ + + N0 N3 醮棉及由仿丢□正 + 醮棉卞卅匀化中月谛及树 毛霜耨允月[ + N0|kubun|level|charaindex|maxhp|hp|mp|name + + kubun 反公及 互丐月井 中井[ㄟ分午 中[公木动嫦卞玄□弁件允日卅中[ㄠ蝈由仿丢□正[ + 2动晓分午]备申永玄及 匀化中月手及及由仿丢□正 1bit level 2bit charaindex卅升 + 互霜耨今木月[ + charaindex 反醮棉及charaindex + level反公及谛及伊矛伙[ + maxhp反公及谛及MAXHP + hp反公及谛及蜇箕及HP + mp反公及谛及竣 + name 反公及谛及 蟆[ + + K0 K4 雯 由仿丢□正 + hp maxhp mp maxmp str tough exp + level attackpower deffencepower + fixdex fixcharm fixluck fixfireat fixwaterat fixearthat fixwindat + 蟆 status + K及 卞0 4毛隙烂仄化}升及雯 井毛隙烂允月仇午[ + 公及戚及玄□弁件卞0互 凶日公及矢永玄 反 中午蜕丹仪[ + 丐月桦宁反ㄠ匹丐月[1分午蝈由仿丢□正[ + 2动晓分午]备申永玄及 匀化中月手及及由仿丢□正 1bit hp 2bit maxhp卅升 + 互霜耨今木月[ + 犯伉立正反 '|' 匹丐月[引凶 蟆午愤裘惫寞反} + 巨旦弗□皿仄凶手及毛 + 凶化徇匹勾卅仆凶手及互骚耨今木月[ + 公木冗木及袄及滇反动票[ + + No.( 寞) int + islive(戏韶) int + GRA( 飓 寞) int + Hp(觐菁 ) int + MaxHp( 觐菁 ) int + Mp int + MapMp int + Exp(烦董袄) int + MaxExp(戚引匹及烦董袄) int + Level(伊矛伙) int + Attack( 猾 ) int + Defense(潮 ) int + Quick(豳镀今) int + Ai(镝擦蘸) int + fEarth(哗) int + fWater( ) int + fFire(绍) int + fWid(氘) int + Slot( 檗 醒) int + 蟆 凳袱第白仿弘 int + 蟆 侬 + 交□扒□矢永玄 侬 + + 蟆 凳袱第白仿弘午反]仇及矢永玄及 蟆毛 凳仄化方中井升丹井及白仿弘匹] + 1 分午 凳 ]ㄟ分午 凳尕第午卅月[ + + 填 ( char 及 公及引引踏仁 ) + + P10|20|10|20|10|10|10|1|2|13|13|1|100|10|尺氏天|PC + + W0 W4 矢永玄及 犯□正 + W0|skillid|field|target|name|comment| x 7 + W0 W4 反公木冗木及矢永玄卞覆杀仄化中月[ + petskillid 反]矢永玄及 及 寞[pet_skillinfo.h卞烂聒今木化中月[ + field 反公及 互升仇匹银迕匹五月井[扔□田□匹反动票及方丹卞烂聒今木化中月[ + + typedef enum + { + PETSKILL_FIELD_ALL, 允屯化及桦赭匹银尹月 + PETSKILL_FIELD_BATTLE, 爵 及心 + PETSKILL_FIELD_MAP, 骚橘穴永皿晓及心 + + }PETSKILL_FIELDTYPE; + + target 反公及 及覆擂互升丹中丹手及井[扔□田□匹反戚及方丹卞烂聒今木化中月[ + + typedef enum + { + PETSKILL_TARGET_MYSELF, 愤坌及心 + PETSKILL_TARGET_OTHER, 职及谛 愤坌殖戈) + PETSKILL_TARGET_ALLMYSIDE, 蝈 + PETSKILL_TARGET_ALLOTHERSIDE, 锹澎础蝈 + PETSKILL_TARGET_ALL, 蝈化 + PETSKILL_TARGET_NONE, 簿手蓟 请 卅中[ 豢支凶户及凛 + PETSKILL_TARGET_OTHERWITHOUTMYSELF,职及谛 愤坌殖引卅中) + PETSKILL_TARGET_WITHOUTMYSELFANDPET, 愤坌午矢永玄动陆 + }PETSKILL_TARGETTYPE; + + name 反 及 蟆[ + comment反公及 卞覆允月 [ + target|name|comment| 反 及醒及坌ㄠ垫匹霜日木化仁月[ + 反域杀ㄦ勾引匹[ 匹 互 仃化中月 "|"及心互粮仁 桦宁 + 反弁仿奶失件玄匹腴户化 憎允月仪[ +*/ +void lssproto_S_send(int fd,char* data) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkstring(buffer, data); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_S_SEND, buffer); +} + +/* + servertoclient D( int category , int dx , int dy , string data ); + (Display) + 卞窒井 憎允月隙 [ + + + int category + 窒毛 憎允月井[ + + 袄 + 1 愤坌动陆卞芨尹凶母丢□斥[data反 侬 + 卞卅匀凶袄[ + 2 愤坌互丹仃凶母丢□斥[data反 侬 卞 + 卅匀凶袄 + + int dx + 穴奶平乓仿井日及弘伉永玉锹覆匏 X[域 读卞反奶矛件玄互 戏 + 仄凶匏 [弁仿奶失件玄反仇及袄井日赝给赝濠卅匏 毛煌遥仄化 + 允月[ + int dy + 锹覆匏 Y + string data + 憎允月 [ 反category卞方匀化瑁引月[ + 仇及 侬 反巨旦弗□皿今木卅仃木壬 + 卅日卅中[ +*/ +void lssproto_D_send(int fd,int category,int dx,int dy,char* data) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkint(buffer, category); + checksum += util_mkint(buffer, dx); + checksum += util_mkint(buffer, dy); + checksum += util_mkstring(buffer, data); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_D_SEND, buffer); +} + +/* + servertoclient FS( int flg); + (FlgSet)PS及及杀蚕[引凶反夫弘奶件凛卅升卞愤坌及橇谪午仄化霜日木化仁月[ + + int flg + 0 bit 0: 醮棉Off 1: 醮棉On + 蜇箕 银迕 1 bit 0: 爵 辅笛off 1: 爵 辅笛On + 2 bit 0: DUEL off 1: DUEL On + 3 bit 0: 骚及民乓永玄乒□玉 1: 由□ 奴卞仄井民乓永玄互 壬卅中乒□玉 + 4 bit 0: 铜跟晶OK 1: 铜跟晶蛐 +*/ +void lssproto_FS_send(int fd,int flg) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkint(buffer, flg); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_FS_SEND, buffer); +} + +/* + servertoclient HL( int flg); + (HeLp)HL及及杀蚕[引凶反由□ 奴及醮棉互爵 及云踞仃乒□玉毛 凳仄凶桦宁卞霜日木化仁月[ + + int flg + 0: 云踞仃乒□玉Off 1: 云踞仃乒□玉On +*/ +void lssproto_HL_send(int fd,int flg) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkint(buffer, flg); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_HL_SEND, buffer); +} + +/* + servertoclient PR( int request, int result); + (PartyRequest)醮棉邰菲及杀蚕[PR毛弁仿奶失件玄互霜匀化中卅仁化手仇木毛熬仃潸月凛互丐月[ + 由□ 奴互 螺荸辣 褪互 仃凶 卅升及凛[ + + int request + 0: 轮迩 1: 迩 + int result + 0: 撩 1: 岳 +*/ +void lssproto_PR_send(int fd,int request,int result) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkint(buffer, request); + checksum += util_mkint(buffer, result); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_PR_SEND, buffer); +} + +#ifdef _PETS_SELECTCON +void lssproto_PETS_send(int fd,int petarray,int result) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkint(buffer, petarray); + checksum += util_mkint(buffer, result); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_PETST_SEND, buffer); +} +#endif + +void lssproto_KS_send(int fd,int petarray,int result) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkint(buffer, petarray); + checksum += util_mkint(buffer, result); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_KS_SEND, buffer); +} + +void lssproto_SPET_send(int fd, int standbypet, int result) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkint(buffer, standbypet); + checksum += util_mkint(buffer, result); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_SPET_SEND, buffer); +} + +/* + servertoclient PS( int result, int havepetindex, int havepetskill, int toindex); + (PetSkill use result)矢永玄及 毛银匀凶瑛绊弁仿奶失件玄及PS卞覆杀仄化霜日木化仁月[ + result 动陆反弁仿奶失件玄及PS卞覆杀仄化中月[白奴□伙玉晓井日仄井裟壬木卅中[ + + int result + 瑛绊[0: 撩 1:岳 + int havepetindex + 窒 及矢永玄互银迕仄凶井[ + int havepetskill + 窒 及 毛银迕仄凶井[ + int toindex + 簿卞 芊毛银迕仄凶井[仇木反左皮斥尼弁玄支平乓仿及index匹反卅中[动票及 卞卅匀化中月[ + + 愤坌 = 0 + 矢永玄 = 1 5 + 醮棉 = 6 10 S N 及0 4卞覆杀[愤坌愤褥手殖引木化中月 + + 覆擂互蝈够]午井坌井日卅中]午井及桦宁反-1匹霜耨允月[ +*/ +void lssproto_PS_send(int fd,int result,int havepetindex,int havepetskill,int toindex) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkint(buffer, result); + checksum += util_mkint(buffer, havepetindex); + checksum += util_mkint(buffer, havepetskill); + checksum += util_mkint(buffer, toindex); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_PS_SEND, buffer); +} + +/* + servertoclient SKUP( int point ); + (SKillUP) + 旦平伙失永皿互匹五月仪毛扔□田互骚襞允月[中仁勾晓仆日木月井毛隙烂允月[ +*/ +void lssproto_SKUP_send(int fd,int point) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkint(buffer, point); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_SKUP_SEND, buffer); +} + +/* + servertoclient WN( int windowtype, int buttontype, int seqno, int objindex, string data ); + (Window) + 它奴件玉它毛 憎六方午扔□田□互弁仿奶失件玄卞骚襞允月[ + + int windowtype + 它奴件玉它正奶皿[升及方丹卅溥挚及它奴件玉它毛 憎允月井[仇木午buttontype 及赚心宁歹六匹 + 它奴件玉它互瑁烂允月[ + 扔□田□匹反动票及 卞涩烂今木化中月[ + + typedef enum + { + WINDOW_MESSAGETYPE_MESSAGE, 丢永本□斥及心 + WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT, 丢永本□斥午域垫 + WINDOW_MESSAGETYPE_SELECT, 蓟 它奴件玉它 + WINDOW_MESSAGETYPE_PETSELECT, 矢永玄蓟 它奴件玉它 + WINDOW_MESSAGETYPE_PARTYSELECT, 醮棉蓟 它奴件玉它 + WINDOW_MESSAGETYPE_PETANDPARTYSELECT, 矢永玄]醮棉蓟 它奴件玉它 + WINDOW_MESSAGETYPE_ITEMSHOPMENU, 云饕及丢瓦亘□它奶件玉它 + WINDOW_MWSSAGETYPE_ITEMSHOPYMAIN, 云饕及丢奶件它奶件玉它 + WINDOW_MESSAGETYPE_LIMITITEMSHOPMAIN, 中潸曰毁 失奶 丞盒及丢奶件它奶件玉它 + WINDOW_MESSAGETYPE_PETSKILLSHOP, 矢永玄及 盒今氏它奶件玉它 + WINDOW_MESSAGETYPE_WIDEMESSAGE, 丢永本□斥及心 五中 + WINDOW_MESSAGETYPE_WIDEMESSAGEANDLINEINPUT, 丢永本□斥午域垫 五中 + + }WINDOW_MESSAGETYPE; + + int buttontype + 示正件及溥挚毛隙烂允月[扔□田□匹反动票及迕卞烂聒今木化中月[ + + #define WINDOW_BUTTONTYPE_NONE (0) + #define WINDOW_BUTTONTYPE_OK (1 << 0) + #define WINDOW_BUTTONTYPE_CANCEL (1 << 1) + #define WINDOW_BUTTONTYPE_YES (1 << 2) + #define WINDOW_BUTTONTYPE_NO (1 << 3) + #define WINDOW_BUTTONTYPE_PREV (1 << 4) + #define WINDOW_BUTTONTYPE_NEXT (1 << 5) + + 仇木日及赚心宁歹六匹霜耨允月[ 尹壬]YES示正件午NO示正件互 仄中凛反 + WINDOW_BUTTONTYPE_YES | WINDOW_BUTTONTYPE_NO (=12) + 匹霜月[ + + int seqno + 仇及它奴件玉它及 寞毛憎允[扔□田□互栋 允月[ + 弁仿奶失件玄反WN卞化仇及它奴件玉它及丑综瑛绊毛忒允及卞]仇及 寞毛骄尹化忒蚕允月[ + 仇木卞方匀化扔□田□反升及NPC及升及桦 匹及它奴件玉它井毛 蝇请 月方丹卞允月[ + int objindex + 仇及它奴件玉它毛请六午蜕匀凶NPC卅升及index互伞 今木化中月[ + 扑旦 丞互请六午蜕匀凶桦宁反-1卅升互 匀化中月[ + 弁仿奶失件玄反]它奴件玉它 及WN皿夫玄戊伙匹仇及醒袄毛公及引引忒六壬 中[ + string data + 丢永本□斥 毛憎允[ 反巨旦弗□皿允月["\n"匹嗉濠月午荼垫午中丹啦 午允月[ + 引凶]弁仿奶失件玄及它奴件玉它匹 憎请 月产汔毛旋尹凶端反愤 读卞荼垫今木月[ + 蓟 饷及丐月它奴件玉它匹反]"\n"匹嗉濠日木凶 赓及玄□弁件互丢永本□斥及垫醒 + 午卅曰]戚卞丢永本□斥及玄□弁件互 赓及玄□弁件匹隙烂今木凶蜊醒粮五] + 公及丐午及玄□弁件 互ㄠ勾内勾及蓟 饷午卅月[引凶蟆井日赐卞 1 井日 + 寞毛喃曰癫化]蓟 仄凶桦宁及WN匹及忒蚕及凛卞忒允[ + string data(云饕迕 + 丢永本□斥 毛憎允[ 反巨旦弗□皿允月["\n"匹嗉濠月午荼垫午中丹啦 午允月[ + 引凶]弁仿奶失件玄及它奴件玉它匹 憎请 月产汔毛旋尹凶端反愤 读卞荼垫今木月[ + 犯□正 反嫩 卞" "匹嗉濠日木化中引允[ + U 丹V + 中 月白仿弘 丹ㄟ“ 月ㄠ 蟆及犯□正银丹井白仿弘 银丹ㄟ“银歹卅中“1 + 饕及 蟆 丢永本□斥 饕丢永本□斥 蜊醒蓟 丢永本□斥 伊矛伙箫曰卅中丢永本□斥 割 丢永本□斥 + 失奶 丞互中匀天中丢永本□斥 失奶 丞 尹月 尹卅中白仿弘 尹月“ㄟ 尹卅中“ㄠ 失奶 丞伊矛伙 + 袄蟾 飓 寞 失奶 丞 尹月 尹卅中白仿弘 失奶 丞伊矛伙 袄蟾 飓 寞 + + 0|1|扔丞幼伙及 湛盒|中日匀仄扎中}窒及方丹分中|中日匀仄扎中升木卞允月|窒蜊 邰分中|公木毛隶 允月卞反伊矛伙互 + 箫曰卅中仃升中中及井中| 癫卞中中氏分友|云中云中失奶 丞互中匀天中元扎友尹井″ 皮□丢仿件| + ㄟ|ㄠㄟㄟ|ㄠㄥㄟㄟㄟ|产域 卞 猾\n躲绊 歇|泔阕|ㄟ|ㄤㄟ|ㄠㄥㄟㄟㄡ| ㄡㄟ荚汊\n 莴卞反勾五 \n兜中 + + U 月V + 中 月白仿弘 丹ㄟ“ 月ㄠ 蟆及犯□正银丹井白仿弘 银丹ㄟ“银歹卅中“1 + 饕及 蟆 丢永本□斥 饕丢永本□斥 云嗯互中匀天中卞卅匀切扎丹丢永本□斥|割 丢永本□斥 + 失奶 丞 木月 木卅中白仿弘 袄蟾 飓 寞 失奶 丞 木月 木卅中白仿弘 + 袄蟾 飓 寞 + + ㄠ|1|扔丞幼伙及 填盒|中日匀仄扎中}升月允月" 中日匀仄扎中升木毛 匀化仁木月[| 癫卞中中氏分友| + 公木分午}云嗯互左□田□仄切扎丹友 皮□丢仿件|ㄟ|ㄡㄟ|ㄠㄥㄟㄟㄟ| + 产域 卞 猾\n躲绊 歇|泔阕|ㄟ|ㄠㄟ|ㄠㄥㄟㄟㄡ| ㄡㄟ荚汊\n 莴卞反勾五 \n兜中 + U失奶 丞 仃月V + 白仿弘 月=ㄟ 丐午窒蜊 仃日木月井 + 饕及 蟆 + 仃月丢永本□斥 仇木动晓 仃日木卅中丢永本□斥 割 丢永本□斥 + 蟆 仃日木月井白仿弘 第 >ㄟ]尕第>ㄠ 袄蟾 飓 寞 域垫奶件白巧 失奶 丞 寞 ㄠ井日 + 蟆 仃日木月井白仿弘 第 >ㄟ]尕第>ㄠ 袄蟾 飓 寞 域垫奶件白巧 失奶 丞 寞 ㄠ井日 + U失奶 丞娄五潸月V + 白仿弘 娄五潸月=ㄠ + 饕及 蟆 娄五请允丢永本□斥 失奶 丞互域 及凛及丢永本□斥|割 丢永本□斥 + 蟆 娄五请六月井升丹井白仿弘 第 >ㄟ]尕第>ㄠ 失奶 丞伊矛伙 袄蟾 飓 寞 域垫奶件白巧 + 蟆 娄五请六月井升丹井白仿弘 第 >ㄟ]尕第>ㄠ 失奶 丞伊矛伙 袄蟾 飓 寞 域垫奶件白巧 + + U公及职V + 饕及 蟆 丢永本□斥 + + 扔丞幼伙及 填盒|中日匀仄扎中}升月允月" + + string data(矢永玄及 盒今氏迕 + 丢永本□斥 毛憎允[ 反巨旦弗□皿允月["\n"匹嗉濠月午荼垫午中丹啦 午允月[ + 引凶]弁仿奶失件玄及它奴件玉它匹 憎请 月产汔毛旋尹凶端反愤 读卞荼垫今木月[ + 犯□正 反嫩 卞" "匹嗉濠日木化中引允[ + U矢永玄及 潸 V + 蟆及树 银丹井升丹井" 银丹“0{银歹卅中“1 饕及 蟆 丢奶件丢永本□斥 + 袄蟾 袄蟾 + + 1 扔丞幼伙及 湛盒 中日匀仄扎中引匀六[允壬日仄中 壬匀井匹允方 + 及讽公及迭 500 猾 ㄢㄟ⊙ { 豢 ㄢㄟ⊙ + 哗萄域葱 1000 蕙仄中 苇互丐月井手 赝癫 +*/ +void lssproto_WN_send(int fd,int windowtype,int buttontype,int seqno,int objindex,char* data) +{ + char buffer[65500]; + int checksum=0; + +#ifdef _NO_WARP + // shan hanjj add Begin + CONNECT_set_seqno(fd,seqno); + CONNECT_set_selectbutton(fd,buttontype); + // shan End +#endif + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkint(buffer, windowtype); + checksum += util_mkint(buffer, buttontype); + checksum += util_mkint(buffer, seqno); + checksum += util_mkint(buffer, objindex); + checksum += util_mkstring(buffer, data); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_WN_SEND, buffer); + +} + +/* + servertoclient EF( int effect, int level, string option ); + (EFfect) + 湿支惚毛嫦日仄凶曰[弁仿奶失件玄卞蝈 读卅躲绊 蜇六方午霜月[ + + int effect + 躲绊 寞[公木冗木毛箫仄遥允月午] 午手及躲绊互 日木引允[ㄢ卞允月午惚午湿互嫦匀凶曰午井仄引允[ + + 1:惚 + 2:湿 + 4:饼蹄湿 烂 + + int level + 躲绊及雄今[ㄟ反壅允[ㄠ ㄤ反 蜇及雄今毛 允[ + string option + 漆 傀舰迕 +*/ +/* Arminius + 新增给丢骰子的动画 + int effect = 10 丢骰子 + level dont care + option = "pet1x|pet1y|dice1|pet2x|pet2y|dice2" (no makeEscapeString) +*/ +void lssproto_EF_send(int fd,int effect,int level,char* option) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkint(buffer, effect); + checksum += util_mkint(buffer, level); + checksum += util_mkstring(buffer, option); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_EF_SEND, buffer); +} + +/* + servertoclient SE( int x, int y, int senumber, int sw ); + (SoundEffect) + 弁仿奶失件玄卞SE毛 日允方丹卞隙憎允月[ + + int x,y + SE毛 耨葭及甄 [ + int senumber + 及 寞 + int sw + 毛 日允井鞅户月井[ + + 0:鞅户月 + 1: 日允 +*/ +void lssproto_SE_send(int fd,int x,int y,int senumber,int sw) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkint(buffer, x); + checksum += util_mkint(buffer, y); + checksum += util_mkint(buffer, senumber); + checksum += util_mkint(buffer, sw); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_SE_SEND, buffer); +} + +/* + servertoclient ClientLogin(string result); + ClientLogin及忒蚕[ + + string result + "ok" 午中丹 侬 [仇及 侬 反巨旦弗□皿今木卅中[ +*/ +void lssproto_ClientLogin_send(int fd,char* result) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkstring(buffer, result); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_CLIENTLOGIN_SEND, buffer); +} + +/* + servertoclient CreateNewChar(string result,string data); + CreateNewChar及忒蚕[ + + string result + "successful" 井 "failed" 及中内木井[仇及 侬 反巨旦弗□ + 皿仄卅中[ + string data + "failed" 及凛反 毛憎允谛棉及苇化坌月 侬 + 匹丐月[失市它件玄扔□田井日及忒蚕公及引引匹丐月[ + 动票及 侬 + + "failed bad parameter" + + 及桦宁反}平乓仿综岳及午五卞筋烂及由仿丢□正及 区毛旋尹化 + 中月午中丹午毛啦 允月[仇木反必□丞扔□田□互请 允月丢永 + 本□斥匹丐月[仇及 侬 反巨旦弗□皿仄卅中[ +*/ +void lssproto_CreateNewChar_send(int fd,char* result,char* data) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkstring(buffer, result); + checksum += util_mkstring(buffer, data); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_CREATENEWCHAR_SEND, buffer); +} + +/* + servertoclient CharDelete(string result,string data); + CharDelete 及忒蚕[ + + string result + "successful" 井 "failed" 及中内木井[巨旦弗□皿仄卅中[ + string data + "failed" 及凛反 毛憎允谛棉及苇化坌月 侬 + 匹丐月[失市它件玄扔□田井日及忒蚕公及引引匹丐月[ + 犯伉立正毛孔仁引卅中及匹}巨旦弗□皿仄卅中[ +*/ +void lssproto_CharDelete_send(int fd,char* result,char* data) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkstring(buffer, result); + checksum += util_mkstring(buffer, data); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_CHARDELETE_SEND, buffer); +} + +/* + servertoclient CharLogin(string result,string data); + CharaLogin及忒蚕[ + + string result + "successful" 井 "failed" 及中内木井[巨旦弗□皿仄卅中[ + string data + "failed" 及凛反 公及 及 侬 [巨旦弗□皿仄卅中[ +*/ +void lssproto_CharLogin_send(int fd,char* result,char* data) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkstring(buffer, result); + checksum += util_mkstring(buffer, data); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_CHARLOGIN_SEND, buffer); +} + +/* + servertoclient CharList(string result,string data); + CharList及忒蚕[ + + string result + "successful" 井 "failed" 及中内木井[巨旦弗□皿仄卅中 + string data + result互"successful"及凛反}失市它件玄扔□田□卞忡绣今木化 + 中月允屯化及平乓仿及 蟆}左皿扑亦件毛毛旦矢□旦匹嗉濠匀凶 + 域蜊及 侬 [仇及 侬 毛综匀化中月及反}失市它件玄扔□田[ + result 互 "failed" 及凛反 毛憎允谛棉及苇化坌月 侬 匹 + 丐月[岳 及凛及左皿扑亦件及 褥反动票及午云曰匹丐月[ + dataplace|faceimage|level|maxhp|atk|def|quick|charm|earth|water|fire|wind|logincount|name|place + + dataplace + 本□皮犯□正及窒 井[仇木匹平乓仿弁正□伉旦玄及窒 井毛瑁烂允月[ + faceimage + 涌及 飓 寞 + level + 平乓仿及伊矛伙 + maxhp,atk,def,quick,charm + 备由仿丢□正[ + earth.water,fire,wind + 备箪岭袄 + logincount + 夫弘奶件市它件玄 + name + 平乓仿及 蟆 + place + 平乓仿及中月桦赭 + + "|" 匹嗉濠日木化中月[ 公木冗木及嫩 反}巨旦弗□皿今木化中月[公及丐午凶化徇 + 匹勾卅仆月[ +*/ +void lssproto_CharList_send(int fd,char* result,char* data) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkstring(buffer, result); + checksum += util_mkstring(buffer, data); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_CHARLIST_SEND, buffer); +} + +/* + servertoclient CharLogout(string result , string data); + Logout卞覆允月忒蚕[ + + string result + "successful" 井 "failed" 及中内木井[巨旦弗□皿仄卅中[ + string data + "failed" 及凛卞及心啦 互丐曰}撩 及 (橇谪)毛憎允谛棉 + 及苇化坌月 侬 匹丐月[巨旦弗□皿仄卅中[ +*/ +void lssproto_CharLogout_send(int fd,char* result,char* data) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkstring(buffer, result); + checksum += util_mkstring(buffer, data); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_CHARLOGOUT_SEND, buffer); +} + +/* + servertoclient ProcGet( string data); + ProcGet及忒蚕[ + + string data + 巨旦弗□皿允月[必□丞扔□田□及 树 毛霜耨允月[ 反log/proc白央奶伙卞踏井木月 午 元[ +*/ +void lssproto_ProcGet_send(int fd,char* data) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkstring(buffer, data); + + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_PROCGET_SEND, buffer); +} + +/* + servertoclient PlayerNumGet( int logincount, int player); + PlayerNumGet及忒蚕[ + + int logincount,player +*/ +void lssproto_PlayerNumGet_send(int fd,int logincount,int player) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkint(buffer, logincount); + checksum += util_mkint(buffer, player); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_PLAYERNUMGET_SEND, buffer); +} + +/* + servertoclient Echo( string test ); + Echo卞覆允月忒蚕[ + + string test + 今五幻升 今木凶 侬 [巨旦弗□皿仄卅中[ +*/ +void lssproto_Echo_send(int fd,char* test) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkstring(buffer, test); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_ECHO_SEND, buffer); +} + +// CoolFish: Trade 2001/4/18 + +void lssproto_TD_send(int fd, int index, char* message) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkstring(buffer, message); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_TD_SEND, buffer); +} +#ifdef _CHATROOMPROTOCOL // (不可开) Syu ADD 聊天室频道 +void lssproto_CHATROOM_send ( int fd , char* message ) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkstring(buffer, message); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_CHATROOM_SEND, buffer); +} +#endif +#ifdef _NEWREQUESTPROTOCOL // (不可开) Syu ADD 新增Protocol要求细项 +void lssproto_RESIST_send ( int fd , char* message ) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkstring(buffer, message); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_RESIST_SEND, buffer); +} +#endif +#ifdef _OUTOFBATTLESKILL // (不可开) Syu ADD 非战斗时技能Protocol +void lssproto_BATTLESKILL_send ( int fd , char* message ) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkstring(buffer, message); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_BATTLESKILL_SEND, buffer); +} +#endif +void lssproto_NU_send(int fd, int nu) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkint(buffer, nu); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_NU_SEND, buffer); +} + + +void lssproto_FM_send(int fd, char* message) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkstring(buffer, message); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_FM_SEND, buffer); +} + + +void lssproto_WO_send(int fd,int effect) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkint(buffer, effect); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_WO_SEND, buffer); +} +#ifdef _ITEM_CRACKER +void lssproto_IC_send(int fd, int x, int y) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkint(buffer, x); + checksum += util_mkint(buffer, y); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_IC_SEND, buffer); +} +#endif +#ifdef _MAGIC_NOCAST // 精灵:沉默 +void lssproto_NC_send(int fd,int flg) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkint(buffer, flg); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_NC_SEND, buffer); +} +#endif + +#ifdef _CHECK_GAMESPEED +void lssproto_CS_send( int fd, int deltimes) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkint( buffer, deltimes); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_CS_SEND, buffer); +} +#endif + +#ifdef _STREET_VENDOR +void lssproto_STREET_VENDOR_send(int fd,char *message) +{ + char buffer[65500]; + int checksum = 0; + + strcpy(buffer,""); + + CONNECT_getCdkey(fd,PersonalKey,4096); + strcat(PersonalKey,_RUNNING_KEY); + + checksum += util_mkstring(buffer,message); + util_mkint(buffer,checksum); + util_SendMesg(fd,LSSPROTO_STREET_VENDOR_SEND,buffer); +} +#endif + +#ifdef _RIGHTCLICK +void lssproto_RCLICK_send(int fd, int type, char* data) +{ + char buffer[65500]; + int checksum=0; + + print("\n RCLICK_send( type=%d data=%s) ", type, data ); + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkint(buffer, type); + checksum += util_mkint(buffer, data); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_RCLICK_SEND, buffer); +} +#endif + +#ifdef _JOBDAILY +void lssproto_JOBDAILY_send(int fd,char *data) +{ + char buffer[65500]; + int checksum = 0; + + strcpy(buffer,""); + + CONNECT_getCdkey(fd,PersonalKey,4096); + strcat(PersonalKey,_RUNNING_KEY); + + //print("tocli_data:%s ",data); + checksum += util_mkstring(buffer,data); + util_mkint(buffer,checksum); + //print("tocli_buffer:%s ",buffer); + util_SendMesg(fd,LSSPROTO_JOBDAILY_SEND,buffer); +} +#endif + +#ifdef _TEACHER_SYSTEM +void lssproto_TEACHER_SYSTEM_send(int fd,char *data) +{ + char buffer[65500]; + int checksum = 0; + + strcpy(buffer,""); + + CONNECT_getCdkey(fd,PersonalKey,4096); + strcat(PersonalKey,_RUNNING_KEY); + + checksum += util_mkstring(buffer,data); + util_mkint(buffer,checksum); + util_SendMesg(fd,LSSPROTO_TEACHER_SYSTEM_SEND,buffer); +} +#endif + +#ifdef _ADD_STATUS_2 +void lssproto_S2_send(int fd,char* data) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer,""); + + CONNECT_getCdkey( fd, PersonalKey, 4096); + strcat(PersonalKey, _RUNNING_KEY); + + checksum += util_mkstring(buffer, data); + util_mkint(buffer, checksum); + util_SendMesg(fd, LSSPROTO_S2_SEND, buffer); +} +#endif diff --git a/gmsv/lssproto_util.c b/gmsv/lssproto_util.c new file mode 100644 index 0000000..ca66441 --- /dev/null +++ b/gmsv/lssproto_util.c @@ -0,0 +1,1475 @@ +#define _LSSPROTOUTIL_C_ +#include "version.h" +#include +#include +#include +#ifndef WIN32 +#include +#include +#endif +#include "lssproto_util.h" +//ttom +2 for degug +#define IS_2BYTEWORD( _a_ ) ( (char)(0x80) <= (_a_) && (_a_) <= (char)(0xFF) ) + +#include "common.h" +#ifdef lssproto__ENCRYPT +long lssproto_ringoCompressor( unsigned char *code , long codelen , unsigned char *text , long textlen); +long lssproto_ringoDecompressor( unsigned char *text , long textlen , unsigned char *code , long codelen); +#endif +/* + lsrpc routines +*/ +int lssproto_AllocateCommonWork(int bufsiz) +{ + lssproto.workbufsize = bufsiz; + lssproto.work = NULL; + lssproto.arraywork = NULL; + lssproto.escapework = NULL; + lssproto.val_str = NULL; + lssproto.token_list = NULL; + lssproto.cryptwork = NULL; + lssproto.jencodecopy = NULL; + lssproto.jencodeout = NULL; + lssproto.compresswork = NULL; + lssproto.work = (char*)calloc( 1, lssproto.workbufsize ); + lssproto.arraywork = (char*)calloc( 1, lssproto.workbufsize ); + lssproto.escapework = (char*)calloc( 1, lssproto.workbufsize ); + lssproto.val_str = (char*)calloc( 1, lssproto.workbufsize ); + lssproto.token_list = (char**)calloc( 1, lssproto.workbufsize *sizeof( char** ) ); + lssproto.cryptwork = (char*)calloc( 1, lssproto.workbufsize * 3 ); + lssproto.jencodecopy = (char*)calloc( 1, lssproto.workbufsize * 3 ); + lssproto.jencodeout = (char*)calloc( 1, lssproto.workbufsize * 3 ); + lssproto.compresswork = (char*)calloc( 1, lssproto.workbufsize * 3 ); + memset( lssproto.work , 0, lssproto.workbufsize ); + memset( lssproto.arraywork , 0, lssproto.workbufsize ); + memset( lssproto.escapework , 0, lssproto.workbufsize ); + memset( lssproto.val_str , 0, lssproto.workbufsize ); + memset( (char*)lssproto.token_list ,0, lssproto.workbufsize*sizeof(char**) ); + memset( lssproto.cryptwork , 0, lssproto.workbufsize*3 ); + memset( lssproto.jencodecopy , 0, lssproto.workbufsize*3 ); + memset( lssproto.jencodeout , 0, lssproto.workbufsize*3 ); + memset( lssproto.compresswork , 0, lssproto.workbufsize*3 ); + if( lssproto.work == NULL || + lssproto.arraywork == NULL || + lssproto.escapework == NULL || + lssproto.val_str == NULL || + lssproto.token_list == NULL || + lssproto.cryptwork == NULL || + lssproto.jencodecopy == NULL || + lssproto.jencodeout == NULL || + lssproto.compresswork == NULL ){ + free( lssproto.work);free( lssproto.val_str); + free( lssproto.escapework);free( lssproto.arraywork ); + free( lssproto.token_list);free( lssproto.cryptwork ); + free( lssproto.jencodecopy);free( lssproto.jencodeout ); + free( lssproto.compresswork ); + return -1; + } + return 0; +} +/********** + Get message information from a network input +**********/ +void lssproto_GetMessageInfo( int *id , char *funcname , int len, char **tk ) +{ + if( tk[0] == NULL || tk[1] == NULL ){ + *id = 0; + lssproto_strcpysafe( funcname , "" , len ); + return; + } + *id = strtoul( tk[0] ,NULL,10); + lssproto_strcpysafe( funcname , tk[1] , len ); + return; +} +/******************************************** + string utilities +*********************************************/ +void lssproto_strcpysafe( char *dest, char *src, int maxlen ) +{ + int i; + for(i=0;i (int)( lssproto.workbufsize*3-2) ){ + fprintf( stderr, "lsgen: badly configured work buflen\n" ); + exit(1); + } + if( (flag%2) == 1 ) flag ++; + lssproto.compresswork[0] = flag; + memcpy( lssproto.compresswork+1,src,srclen ); + compressed_l = srclen + 1; + } else { + if((flag%2)==0)flag++; + lssproto.compresswork[0] = flag; + compressed_l = lssproto_ringoCompressor( + (unsigned char*)lssproto.compresswork + 1 , + (long)lssproto.workbufsize*3 - 1, + (unsigned char*)src , + (long)strlen(src) ) + 1; /* be careful! */ + } + /* return empty line if error or buffer excess */ + if( compressed_l <= 0 ){ + lssproto_strcpysafe( out , "\n" , maxoutlen ); + return; + } + memcpy( lssproto.jencodecopy ,lssproto.compresswork ,compressed_l ); + lssproto_jEncode( lssproto.jencodecopy , compressed_l , JENCODE_KEY , + lssproto.jencodeout, &jencodedlen , lssproto.workbufsize*3 -1 ); + lssproto_encode64( (unsigned char*)lssproto.jencodeout , jencodedlen, (unsigned char*)out ); +} +/* translate code64 text to original lsrpc text */ +static void lssproto_decodeString( char *src , char *out ) +{ + int compressed_l =0, outlen64; + int l; + long decompressed_l = 0; + /* copy src to copybuffer because jencoder modifies the input buffer */ + l = strlen( src ); + if( src[l-1]=='\n' || src[l-1]=='\r' )src[l-1]=0; + if( src[l-2]=='\n' || src[l-2]=='\r' )src[l-2]=0; + outlen64 = lssproto_decode64( (unsigned char*)src , (unsigned char*)lssproto.jencodecopy ); + lssproto_jDecode( lssproto.jencodecopy , outlen64 , JENCODE_KEY, + lssproto.compresswork , &compressed_l); + /*out[outlen]=0; PENDING*/ + if( (lssproto.compresswork[0] % 2 ) == 0 ){ + if( compressed_l <= 0 ){ + decompressed_l = 0; + fprintf( stderr, "LSRPC: too short:[%s]\n", src ); + } else { + memcpy( out, lssproto.compresswork+1, compressed_l -1 ); + decompressed_l = compressed_l -1; + } + } else { + decompressed_l = + lssproto_ringoDecompressor( (unsigned char*)out , + (long)lssproto.workbufsize , + (unsigned char*)lssproto.compresswork+1 , + (long)compressed_l -1 ); + } + out[decompressed_l] = 0; +} +/* followings are taken from code64.c */ +char lssproto_charset[64]={ + 'A','B','C','D', 'E','F','G','H', + 'I','J','K','L', 'M','N','O','P', + 'Q','R','S','T', 'U','V','W','X', + 'Y','Z','a','b', 'c','d','e','f', + 'g','h','i','j', 'k','l','m','n', + 'o','p','q','r', 's','t','u','v', + 'w','x','y','z', '0','1','2','3', + '4','5','6','7', '8','9','+','-' +}; +char lssproto_reversecharset[256]={ + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,62, 0,63,0,0, + 52,53,54,55, 56,57,58,59, + 60,61,0,0, 0,0,0,0, + 0,0,1,2, 3,4,5,6, + 7,8,9,10, 11,12,13,14, + 15,16,17,18, 19,20,21,22, + 23,24,25,0, 0,0,0,0, + 0,26,27,28, 29,30,31,32, + 33,34,35,36, 37,38,39,40, + 41,42,43,44, 45,46,47,48, + 49,50,51,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0 +}; + +static void lssproto_encode64( unsigned char *in , int len , unsigned char *out ) +{ + int i; + int use_bytes; + int address = 0; + out[0] = 0; + for(i=0;;i+=3){ + unsigned char in1 , in2 , in3; + unsigned char out1 ,out2 , out3 , out4; + if( i >= len ) break; + if( i >= (len-1)){ /* the last letter ( to be thrown away ) */ + in1 = in[i] & 0xff; + in2 = in3 = 0; + use_bytes = 2; + } else if( i >= (len-2)){ /* the last 2 letters ( process only 1 byte)*/ + in1 = in[i] & 0xff; + in2 = in[i+1] & 0xff; + in3 = 0; + use_bytes = 3; + } else { /* there are more or equal than 3 letters */ + in1 = in[i] & 0xff; + in2 = in[i+1] & 0xff; + in3 = in[i+2] & 0xff; + use_bytes = 4; + } + out1 = ((in1 & 0xfc)>>2) & 0x3f; + out2 = ((in1 & 0x03)<<4) | ((( in2 & 0xf0)>>4)&0x0f); + out3 = ((in2 & 0x0f)<<2) | ((( in3 & 0xc0)>>6)&0x03); + out4 = (in3 & 0x3f ); + if( use_bytes >= 2 ){ + out[address++] = lssproto_charset[out1]; + out[address++] = lssproto_charset[out2]; + out[address]=0; + } + if( use_bytes >= 3 ){ + out[address++] = lssproto_charset[out3]; + out[address]=0; + } + if( use_bytes >= 4 ){ + out[address++] = lssproto_charset[out4]; + out[address]=0; + } + } +} +/* + * Decode it + * char *in : encoded ascii chars + * char *out : decoded( output) + * return value : output byte count + * + * note: no need to have bigger buffer. because output is to + * be smaller than input string size + */ +static int lssproto_decode64( unsigned char *in , unsigned char *out ) +{ + unsigned char in1 , in2 , in3 , in4; + unsigned char out1 , out2 , out3; + int use_bytes; + int address= 0; + int i; + for(i=0;;i+=4 ){ + if( in[i] == 0 ){ + break; + } else if( in[i+1] == 0 ){ /* the last letter */ + break; + } else if( in[i+2] == 0 ){ /* the last 2 letters */ + in1 = lssproto_reversecharset[in[i]]; + in2 = lssproto_reversecharset[in[i+1]]; + in3 = in4 = 0; + use_bytes = 1; + } else if( in[i+3] == 0 ){ /* the last 3 letters */ + in1 = lssproto_reversecharset[in[i]]; + in2 = lssproto_reversecharset[in[i+1]]; + in3 = lssproto_reversecharset[in[i+2]]; + in4 = 0; + use_bytes = 2; + } else { /* process 4 letters */ + in1 = lssproto_reversecharset[in[i]]; + in2 = lssproto_reversecharset[in[i+1]]; + in3 = lssproto_reversecharset[in[i+2]]; + in4 = lssproto_reversecharset[in[i+3]]; + use_bytes = 3; + } + out1 = (in1<<2) | (((in2 & 0x30)>>4)&0x0f) ; + out2 = ((in2 & 0x0f )<<4) | ((( in3 & 0x3c)>>2)&0x0f); + out3 = ( (in3 &0x03)<<6) | ( in4 & 0x3f ); + if( use_bytes >= 1 ){ + out[address++] = out1; + } + if( use_bytes >= 2 ){ + out[address++] = out2; + } + if( use_bytes >= 3 ){ + out[address++] = out3; + } + if( use_bytes != 3 ){ + break; + } + } + return address; +} + +/* followings are taken from Jencode.c by jun */ +static void lssproto_jEncode(char *src,int srclen,int key,char *encoded,int *encodedlen,int maxencodedlen) +{ + char sum=0; + int i; + if(srclen+1 > maxencodedlen){ + *encodedlen = maxencodedlen; + for(i=0;i<(*encodedlen);i++)encoded[i] = src[i]; + } + if(srclen+1 <= maxencodedlen){ + *encodedlen=srclen+1; + for(i=0;i i) encoded[i] = src[i] + sum*((i*i)%3); + if(abs((key%srclen)) == i) encoded[i] = sum; + if(abs((key%srclen)) < i) encoded[i] = src[i-1] + sum*((i*i)%7); + } + } +} +static void lssproto_jDecode(char *src,int srclen,int key,char *decoded,int *decodedlen) +{ + char sum=0; + int i; + *decodedlen=srclen-1; + if( *decodedlen == 0 ){ + return; /* return error if length is 0 */ + } + sum = src[abs(key%(*decodedlen))]; + for(i=0;i i) decoded[i] = src[i] - sum*((i*i)%3); + if(abs((key%(*decodedlen))) < i) decoded[i-1] = src[i] - sum*((i*i)%7); + } + for(i=0;i<(*decodedlen);i++){ + if(((key%7) == (i%5))||((key%2) == (i%2)))decoded[i] = ~decoded[i]; + } +} + +/*****************************************************************/ +/* Compress / Decompress routine */ +/*****************************************************************/ +#define B00000000 0 +#define B00000001 1 +#define B00000010 2 +#define B00000011 3 +#define B00000100 4 +#define B00000101 5 +#define B00000110 6 +#define B00000111 7 +#define B00001000 8 +#define B00001001 9 +#define B00001010 10 +#define B00001011 11 +#define B00001100 12 +#define B00001101 13 +#define B00001110 14 +#define B00001111 15 +#define B00010000 16 +#define B00010001 17 +#define B00010010 18 +#define B00010011 19 +#define B00010100 20 +#define B00010101 21 +#define B00010110 22 +#define B00010111 23 +#define B00011000 24 +#define B00011001 25 +#define B00011010 26 +#define B00011011 27 +#define B00011100 28 +#define B00011101 29 +#define B00011110 30 +#define B00011111 31 +#define B00100000 32 +#define B00100001 33 +#define B00100010 34 +#define B00100011 35 +#define B00100100 36 +#define B00100101 37 +#define B00100110 38 +#define B00100111 39 +#define B00101000 40 +#define B00101001 41 +#define B00101010 42 +#define B00101011 43 +#define B00101100 44 +#define B00101101 45 +#define B00101110 46 +#define B00101111 47 +#define B00110000 48 +#define B00110001 49 +#define B00110010 50 +#define B00110011 51 +#define B00110100 52 +#define B00110101 53 +#define B00110110 54 +#define B00110111 55 +#define B00111000 56 +#define B00111001 57 +#define B00111010 58 +#define B00111011 59 +#define B00111100 60 +#define B00111101 61 +#define B00111110 62 +#define B00111111 63 +#define B01000000 64 +#define B01000001 65 +#define B01000010 66 +#define B01000011 67 +#define B01000100 68 +#define B01000101 69 +#define B01000110 70 +#define B01000111 71 +#define B01001000 72 +#define B01001001 73 +#define B01001010 74 +#define B01001011 75 +#define B01001100 76 +#define B01001101 77 +#define B01001110 78 +#define B01001111 79 +#define B01010000 80 +#define B01010001 81 +#define B01010010 82 +#define B01010011 83 +#define B01010100 84 +#define B01010101 85 +#define B01010110 86 +#define B01010111 87 +#define B01011000 88 +#define B01011001 89 +#define B01011010 90 +#define B01011011 91 +#define B01011100 92 +#define B01011101 93 +#define B01011110 94 +#define B01011111 95 +#define B01100000 96 +#define B01100001 97 +#define B01100010 98 +#define B01100011 99 +#define B01100100 100 +#define B01100101 101 +#define B01100110 102 +#define B01100111 103 +#define B01101000 104 +#define B01101001 105 +#define B01101010 106 +#define B01101011 107 +#define B01101100 108 +#define B01101101 109 +#define B01101110 110 +#define B01101111 111 +#define B01110000 112 +#define B01110001 113 +#define B01110010 114 +#define B01110011 115 +#define B01110100 116 +#define B01110101 117 +#define B01110110 118 +#define B01110111 119 +#define B01111000 120 +#define B01111001 121 +#define B01111010 122 +#define B01111011 123 +#define B01111100 124 +#define B01111101 125 +#define B01111110 126 +#define B01111111 127 +#define B10000000 128 +#define B10000001 129 +#define B10000010 130 +#define B10000011 131 +#define B10000100 132 +#define B10000101 133 +#define B10000110 134 +#define B10000111 135 +#define B10001000 136 +#define B10001001 137 +#define B10001010 138 +#define B10001011 139 +#define B10001100 140 +#define B10001101 141 +#define B10001110 142 +#define B10001111 143 +#define B10010000 144 +#define B10010001 145 +#define B10010010 146 +#define B10010011 147 +#define B10010100 148 +#define B10010101 149 +#define B10010110 150 +#define B10010111 151 +#define B10011000 152 +#define B10011001 153 +#define B10011010 154 +#define B10011011 155 +#define B10011100 156 +#define B10011101 157 +#define B10011110 158 +#define B10011111 159 +#define B10100000 160 +#define B10100001 161 +#define B10100010 162 +#define B10100011 163 +#define B10100100 164 +#define B10100101 165 +#define B10100110 166 +#define B10100111 167 +#define B10101000 168 +#define B10101001 169 +#define B10101010 170 +#define B10101011 171 +#define B10101100 172 +#define B10101101 173 +#define B10101110 174 +#define B10101111 175 +#define B10110000 176 +#define B10110001 177 +#define B10110010 178 +#define B10110011 179 +#define B10110100 180 +#define B10110101 181 +#define B10110110 182 +#define B10110111 183 +#define B10111000 184 +#define B10111001 185 +#define B10111010 186 +#define B10111011 187 +#define B10111100 188 +#define B10111101 189 +#define B10111110 190 +#define B10111111 191 +#define B11000000 192 +#define B11000001 193 +#define B11000010 194 +#define B11000011 195 +#define B11000100 196 +#define B11000101 197 +#define B11000110 198 +#define B11000111 199 +#define B11001000 200 +#define B11001001 201 +#define B11001010 202 +#define B11001011 203 +#define B11001100 204 +#define B11001101 205 +#define B11001110 206 +#define B11001111 207 +#define B11010000 208 +#define B11010001 209 +#define B11010010 210 +#define B11010011 211 +#define B11010100 212 +#define B11010101 213 +#define B11010110 214 +#define B11010111 215 +#define B11011000 216 +#define B11011001 217 +#define B11011010 218 +#define B11011011 219 +#define B11011100 220 +#define B11011101 221 +#define B11011110 222 +#define B11011111 223 +#define B11100000 224 +#define B11100001 225 +#define B11100010 226 +#define B11100011 227 +#define B11100100 228 +#define B11100101 229 +#define B11100110 230 +#define B11100111 231 +#define B11101000 232 +#define B11101001 233 +#define B11101010 234 +#define B11101011 235 +#define B11101100 236 +#define B11101101 237 +#define B11101110 238 +#define B11101111 239 +#define B11110000 240 +#define B11110001 241 +#define B11110010 242 +#define B11110011 243 +#define B11110100 244 +#define B11110101 245 +#define B11110110 246 +#define B11110111 247 +#define B11111000 248 +#define B11111001 249 +#define B11111010 250 +#define B11111011 251 +#define B11111100 252 +#define B11111101 253 +#define B11111110 254 +#define B11111111 255 +/* masks for first byte ( write )*/ +int lssproto_modifymask_first[8][9]={ + {0, B00000001,B00000011,B00000111,B00001111,B00011111,B00111111,B01111111,B11111111},/* mod 0*/ + {0, B00000011,B00000111,B00001111,B00011111,B00111111,B01111111,B11111111,B11111111},/* mod 1*/ + {0, B00000111,B00001111,B00011111,B00111111,B01111111,B11111111,B11111111,B11111111},/* mod 2*/ + {0, B00001111,B00011111,B00111111,B01111111,B11111111,B11111111,B11111111,B11111111},/* mod 3*/ + {0, B00011111,B00111111,B01111111,B11111111,B11111111,B11111111,B11111111,B11111111},/* mod 4*/ + {0, B00111111,B01111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111},/* mod 5*/ + {0, B01111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111},/* mod 6*/ + {0, B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111},/* mod 7*/ +}; +/* masks for second byte ( write ) */ +int lssproto_modifymask_second[8][9]={ + {0, B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000},/* mod 0 */ + {0, B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000001},/* mod 1 */ + {0, B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000001,B00000011},/* mod 2 */ + {0, B00000000,B00000000,B00000000,B00000000,B00000000,B00000001,B00000011,B00000111},/* mod 3 */ + {0, B00000000,B00000000,B00000000,B00000000,B00000001,B00000011,B00000111,B00001111},/* mod 4 */ + {0, B00000000,B00000000,B00000000,B00000001,B00000011,B00000111,B00001111,B00011111},/* mod 5 */ + {0, B00000000,B00000000,B00000001,B00000011,B00000111,B00001111,B00011111,B00111111},/* mod 6 */ + {0, B00000000,B00000001,B00000011,B00000111,B00001111,B00011111,B00111111,B01111111},/* mod 7 */ +}; +/* + * used by bitstream routines + */ +int bitstream_maxbyte, bitstream_bitaddr ; +char *bitstream_buf; +/* initialize bitstream for output */ +static int initOutputBitStream( char *buf ,int buflen) +{ + bitstream_bitaddr = 0; + bitstream_maxbyte = buflen; + bitstream_buf = buf; + memset( buf,0, buflen); + return 0; +} +/* initialize bitstream for input */ +static int initInputBitStream( char *buf , int buflen) +{ + bitstream_bitaddr = 0; + bitstream_maxbyte = buflen; + bitstream_buf = buf; + return 0; +} +/* + * read from bit stream. used only from 1 bit to 8 bits + * this is a base routine + */ +static unsigned int readInputBitStreamBody( int bwidth ) +{ + int mod = bitstream_bitaddr % 8; + int byteaddr = bitstream_bitaddr / 8; + /* return if excess */ + if( byteaddr >= bitstream_maxbyte)return 0; + if( bwidth >= 1 && bwidth <= 8){ + int b1 = (( bitstream_buf[byteaddr] & lssproto_modifymask_first[mod][bwidth] )>>mod); + int b2 = (( bitstream_buf[byteaddr+1] & lssproto_modifymask_second[mod][bwidth])<<(8-mod)); + bitstream_bitaddr += bwidth; + return b1 | b2; + } else { + return 0; + } +} +/* + * read from bit stream. used from 1 bit to 32 bits + * + */ +static unsigned int readInputBitStream( int bwidth ) +{ + if( bwidth <= 0 ){ + return 0; + } else if( bwidth >= 1 && bwidth <= 8 ){ + return readInputBitStreamBody( bwidth ); + } else if( bwidth >= 9 && bwidth <= 16 ){ + unsigned int first = readInputBitStreamBody(8); + unsigned int second = readInputBitStreamBody( bwidth-8); + return first + (second << 8 ); + } else if( bwidth >= 17 && bwidth <= 24 ){ + unsigned int first = readInputBitStreamBody(8); + unsigned int second = readInputBitStreamBody(8); + unsigned int third = readInputBitStreamBody(bwidth-8); + return first + ( second << 8 ) + ( third << 16 ); + } else if( bwidth >= 25 && bwidth <= 32 ){ + unsigned int first = readInputBitStreamBody(8); + unsigned int second = readInputBitStreamBody(8); + unsigned int third = readInputBitStreamBody(8); + unsigned int forth = readInputBitStreamBody(bwidth-8); + return first + ( second << 8 ) + ( third << 16 ) + ( forth << 24 ); + } + return 0; +} +/* + * write to a bitstream. only used from 1 bit to 8 bits + * this is a base routine. + */ +static int writeOutputBitStreamBody( int bwidth , unsigned char b) +{ + int mod = bitstream_bitaddr % 8; + int byteaddr = bitstream_bitaddr / 8; + /* return error if excess */ + if( bitstream_maxbyte <= (byteaddr+1)) return -1; + bitstream_buf[byteaddr] &= lssproto_modifymask_first[mod][bwidth]; + bitstream_buf[byteaddr] |= (b << mod) & lssproto_modifymask_first[mod][bwidth]; + bitstream_buf[byteaddr+1] &= lssproto_modifymask_second[mod][bwidth]; + bitstream_buf[byteaddr+1] |= (b>>(8-mod))& lssproto_modifymask_second[mod][bwidth]; + bitstream_bitaddr += bwidth; + return byteaddr+1; +} +/* + * write to a bitstream. used from 1 bits to 32 bits + * returns -1 if error or buffer excession + */ +static int writeOutputBitStream( int bwidth, unsigned int dat) +{ + int ret; + if( bwidth <= 0){ + return -1; + } else if( bwidth >= 1 && bwidth <= 8 ){ + if((ret=writeOutputBitStreamBody( bwidth , (unsigned char)dat))<0)return -1; + } else if( bwidth > 8 && bwidth <= 16 ){ + if(writeOutputBitStreamBody( 8 , (unsigned char)(dat&0xff))<0)return -1; + if((ret=writeOutputBitStreamBody( bwidth - 8 , ( unsigned char)((dat>>8)&0xff)))<0)return -1; + } else if( bwidth > 16 && bwidth <= 24 ){ + if(writeOutputBitStreamBody( 8 , (unsigned char)(dat&0xff))<0)return -1; + if(writeOutputBitStreamBody( 8 , (unsigned char)((dat>>8)&0xff))<0)return -1; + if((ret=writeOutputBitStreamBody( bwidth-16,(unsigned char)((dat>>16)&0xff)))<0)return -1; + } else if( bwidth > 24 && bwidth <= 32 ){ + if(writeOutputBitStreamBody( 8 , (unsigned char)(dat&0xff))<0)return -1; + if(writeOutputBitStreamBody( 8 , (unsigned char)((dat>>8)&0xff))<0)return -1; + if(writeOutputBitStreamBody( 8 , (unsigned char)((dat>>16)&0xff))<0)return -1; + if((ret=writeOutputBitStreamBody( bwidth-24,(unsigned char)((dat>>24)&0xff)))<0)return -1; + } else { + return -1; + } + return ret; +} +#define CHAR_SIZE 256 +#define NODE_SIZE 512 +#define BITS_LEN 9 /* 9 bit lzw compression */ +typedef struct { + unsigned char chr; + int parent; + int brother; + int child; +}NODE; +long lssproto_ringoCompressor( unsigned char *code , long codelen , + unsigned char *text , long textlen) +{ + NODE node[NODE_SIZE]; + int freeNode; + int w,k; /* used in this algo */ + int textind; /* index to text buffer */ + int i; + int position = 0; /* indicates the last byte of code buffer */ + if( textlen <= 0 ) return -1; + initOutputBitStream((char*) code,codelen); + /* fill characters ( 0 ~ 255 ) in the beggining part of + Node list */ + for(i=0; i<= CHAR_SIZE; i++){ + node[i].chr = (unsigned char)i; + node[i].brother = i + 1; + node[i].parent = 0; + node[i].child = 0; + } + node[CHAR_SIZE].brother = 0; + freeNode = CHAR_SIZE + 1; + w = text[0]; + textind = 1; + while(1){ + int rv; + if( textind >= textlen ){ + k = CHAR_SIZE; /* indicates EOF */ + } else { + k = text[textind]; + } + /* search if pattern 'wk' is registered or not. */ + rv = node[w].child; + while(1){ + if( rv <= 0 ) break; + if( node[rv].chr == k ) break; + rv = node[rv].brother; + } + if( rv > 0 ){ + /* found it */ + w = rv; + } else { + position = writeOutputBitStream( BITS_LEN ,w ); + /* return if buffer excession */ + if( position > codelen ) return -1; + /* register pattern 'wk' in the dictionary */ + if( freeNode < NODE_SIZE ){ + node[freeNode].parent = w; + node[freeNode].chr = k; + node[freeNode].brother = node[w].child; + node[freeNode].child = 0; + node[w].child = freeNode; + freeNode++; + } + w = k; + } + if( textind == ( textlen + 1 ) ) break; + textind++; + } + return position; +} + +/* + * Decoder. + * return -1 if buffer excession. Notice buffer text + * is modified . + */ +long lssproto_ringoDecompressor( unsigned char *text , long textlen , + unsigned char *code , long codelen) +{ + NODE node[NODE_SIZE]; + int stack[NODE_SIZE]; + int sp; + int freeNode; + int len; + int i; + int k = 0; + int w = 0; + if( codelen <= 0 ) return -1; + initInputBitStream( (char*)code , codelen ); + for(i=0;i= freeNode ){ + stack[sp++] = k; /* exception */ + if( sp >=( sizeof( stack ) /sizeof(stack[0] )) )return -1; + k = w; + } else { + k = rv; + } + while(k> CHAR_SIZE ){ + if( k >= (sizeof(node)/sizeof(node[0]))) return -1; + stack[sp++] = node[k].chr; + k = node[k].parent; + if( sp >=( sizeof( stack ) /sizeof(stack[0] )) ) return -1; + } + stack[sp++] = k; + if( sp >= ( sizeof( stack ) /sizeof(stack[0] )) ) return -1; + /* output to text buffer from stack.*/ + while(sp){ + if( ++len > textlen ) return -1; + *text++ = stack[--sp]; + } + /* register the pattern 'wk'*/ + if( len > 1 && freeNode < NODE_SIZE ){ + node[freeNode].parent = w; + node[freeNode].chr = k; + if( w >= (sizeof(node)/sizeof(node[0])))return -1; + node[freeNode].brother = node[w].child; + node[freeNode].child = 0; + node[w].child = freeNode; + freeNode++; + } + w = rv; + } + return len; +} +#endif /* ifdef lssproto__ENCRYPT */ + +/* Convert 62-base digits to 10 digits */ +int lssproto_a62toi( char *a ) +{ + int ret = 0; + int minus ; + if( a[0] == '-' ){ + minus = -1; + a++; + } else { + minus = 1; + } + + while( *a != '\0' ) + { + ret *= 62; + if( '0' <= (*a) && (*a) <= '9' ) + ret += (*a)-'0'; + else + if( 'a' <= (*a) && (*a) <= 'z' ) + ret += (*a)-'a'+10; + else + if( 'A' <= (*a) && (*a) <= 'Z' ) + ret += (*a)-'A'+36; + else + return 0; + a++; + } + return ret * minus; +} + +/* Convert 10-base digits into 62-base digits. */ +char *lssproto_cnv10to62( int a, char *out, int outlen ) +{ + int i, j; + char base[] = { "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"}; + int tmp[64]; + int src; + int minus; + int baselen = sizeof( base)-1; + if( a < 0 ){ + minus = 1; + a *= -1; + } else { + minus = 0; + } + /* special case */ + if( a < baselen) { + if( minus ){ + *(out) = '-'; + *(out+1) = base[a]; + *(out+2) = '\0'; + return (out); + } else { + *out = base[a]; + *(out+1) = '\0'; + return( out); + } + } + src = a; + for( i = 0; src >= baselen; i ++ ) { + tmp[i] = src % baselen; + src /= baselen; + } + i--; + if( minus ){ + *out = '-'; + *(out+1) = base[src]; + for( j = 2; i >= 0; i --, j ++ ) { + if( j > outlen - 2 ) return NULL; + *(out+j) = base[tmp[i]]; + } + } else { + *out = base[src]; + for( j = 1; i >= 0; i --, j ++ ) { + if( j > outlen - 2 ) return NULL; + *(out+j) = base[tmp[i]]; + } + } + *(out+j) = '\0'; + return( out); +} diff --git a/gmsv/magic/magic.c b/gmsv/magic/magic.c new file mode 100644 index 0000000..a4f3ebf --- /dev/null +++ b/gmsv/magic/magic.c @@ -0,0 +1,846 @@ +#include "version.h" +#include +#include + +#include "common.h" +#include "char_base.h" +#include "char_data.h" +#include "item.h" +#include "battle.h" +#include "magic_base.h" +#include "magic.h" +#include "magic_field.h" +#include "family.h" +#include "handletime.h" +#include "battle_magic.h" +#include "battle_event.h" +#include"lssproto_serv.h" +#ifdef _ITEM_ATTSKILLMAGIC +#include "pet_skill.h" +#endif +//#include "battle_event.h" +// shan add code +#define MP_RATE 0.7 + + +int MAGIC_Use( int charaindex, int haveitemindex, int toindex) +{ + int itemindex; + int magicid,marray,mp; + int ret; + MAGIC_CALLFUNC func; + + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX( itemindex) ) return FALSE; + magicid = ITEM_getInt( itemindex, ITEM_MAGICID); + marray = MAGIC_getMagicArray( magicid); + if( marray == -1 ) return FALSE; + + func = MAGIC_getMagicFuncPointer( MAGIC_getChar( marray, MAGIC_FUNCNAME));//MAGIC_NAME + if( (mp = ITEM_getInt( itemindex, ITEM_MAGICUSEMP)) < 0 ){ + print("err mp:%d -%s-%d\n", mp, ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) ); + + } + + // shan add begin + if( CHAR_getInt( charaindex, CHAR_FMINDEX ) >= 1 ){ + // 光精 + if( CHAR_getInt( charaindex, CHAR_FMSPRITE ) == 0){ + if( (marray >=0 && marray <=31) || (marray >= 105 && marray <=107 )) + mp *= MP_RATE; + } + // 暗精 + if( CHAR_getInt( charaindex, CHAR_FMSPRITE ) == 1){ + if( marray >=32 && marray <=81 ) + mp *= MP_RATE; + } + } + // shan end + if( func ) { + ret = func( charaindex, toindex, marray, mp ); + }else { + ret = FALSE; + } + return ret; +} + +int MAGIC_GetArrayNo( int charaindex, int haveitemindex) +{ + int itemindex; + int magicid; + itemindex = CHAR_getItemIndex( charaindex, haveitemindex); + if( !ITEM_CHECKINDEX( itemindex) ) return FALSE; + + magicid = ITEM_getInt( itemindex, ITEM_MAGICID); + + return magicid; +} +int MAGIC_DirectUse( + int charaindex, + int magicid, + int toindex, + int itemnum +) +{ + MAGIC_CALLFUNC func; + int mp, ret, marray; + int itemindex=-1; +#ifdef _MAGIC_NOCAST//沉默状态无法施法 + if( CHAR_getWorkInt( charaindex, CHAR_WORKNOCAST ) > 0 ){ + CHAR_talkToCli(charaindex, -1, "沉默中无法吟唱咒术", CHAR_COLORYELLOW); + return FALSE; + } +#endif + + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER){ + itemindex = CHAR_getItemIndex( charaindex, itemnum); + if( !ITEM_CHECKINDEX( itemindex) ){ + print("ANDY err MAGIC_DirectUse() itemindex:%d !\n", itemindex); + return FALSE; + } + }else{ + itemindex = itemnum; + } + + marray = MAGIC_getMagicArray( magicid ); + func = MAGIC_getMagicFuncPointer( MAGIC_getChar( marray, MAGIC_FUNCNAME ) ); + if( (mp = ITEM_getInt( itemindex, ITEM_MAGICUSEMP )) < 0 ){ + } + // shan add begin + if( CHAR_getInt( charaindex, CHAR_FMINDEX ) >= 1 ){ + // 光精 + if( CHAR_getInt( charaindex, CHAR_FMSPRITE ) == 0){ + if( (marray >=0 && marray <=31) ) + mp *= MP_RATE; + } + // 暗精 + if( CHAR_getInt( charaindex, CHAR_FMSPRITE ) == 1){ + if( marray >=32 && marray <=81 ) + mp *= MP_RATE; + } + } + if( func ) { + ret = func( charaindex, toindex, marray, mp ); + } + else { + ret = FALSE; + } + return ret; +} + +int MAGIC_Recovery( int charaindex, int toindex, int marray, int mp ) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + return FALSE; + } + + + if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE; + CHAR_setInt( charaindex, CHAR_MP, + CHAR_getInt( charaindex, CHAR_MP ) - mp ); + if( IsBATTLING( charaindex ) == TRUE ){ +#ifdef _PREVENT_TEAMATTACK //恩惠不得 使用敌方 + int battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && + BattleArray[battleindex].type != BATTLE_TYPE_P_vs_P ){ + + if( BATTLE_CheckSameSide( charaindex, toindex) == 0 ){//不同边 + int battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + BATTLE_NoAction( battleindex, BATTLE_Index2No( battleindex, charaindex) ); + CHAR_talkToCli( charaindex, -1, "恩惠精灵..不得施予非玩家敌方。", CHAR_COLORYELLOW); + return FALSE; + } + } +#endif + if (toindex==22){print("jinchao err\n");return FALSE;} // shan(对全体使用魔法的bug),修改者jinchao+2001/12/07 + MAGIC_Recovery_Battle( charaindex, toindex, marray, mp ); + }else{ + if( CHAR_CHECKINDEX( toindex ) == FALSE )return FALSE; // shan(对全体使用魔法的bug),修改者jinchao+2001/12/07 + MAGIC_Recovery_Field( charaindex, marray); + } + + return TRUE; +} + +int MAGIC_OtherRecovery( int charaindex, int toindex, int marray, int mp ) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; //{撩 + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + return FALSE; + } + + if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE; // 井匀凶日母丢 + CHAR_setInt( charaindex, CHAR_MP, + CHAR_getInt( charaindex, CHAR_MP ) - mp ); + if( IsBATTLING( charaindex ) == TRUE ){ +#ifdef _PREVENT_TEAMATTACK //滋润 不得使用敌方 + int battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && + BattleArray[battleindex].type != BATTLE_TYPE_P_vs_P ){ + if( BATTLE_CheckSameSide( charaindex, toindex) == 0 ){//不同边 + int battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + BATTLE_NoAction( battleindex, BATTLE_Index2No( battleindex, charaindex) ); + CHAR_talkToCli( charaindex, -1, "滋润精灵..不得施予非玩家敌方。", CHAR_COLORYELLOW); + return FALSE; + } + } +#endif + MAGIC_Recovery_Battle( charaindex, toindex, marray, mp ); + }else{ + if( CHAR_CHECKINDEX( toindex ) == FALSE )return FALSE; //{撩 + MAGIC_OtherRecovery_Field( charaindex, toindex, marray); + } + return TRUE; +} + +// 白奴□伙玉及箪岭毛 祭今六月 芊 +int MAGIC_FieldAttChange( int charaindex, int toindex, int marray, int mp ) +{ + int battlemode; + + // INDEX民尼永弁 + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; //{撩 + + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + + // 爵 钒铵凛反 骰允月 + if( battlemode == BATTLE_CHARMODE_INIT ){ + return FALSE; + } + + // 壅 民尼永弁 + if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE; // 井匀凶日母丢 + // 仇及 芊反 骚卞 壅 仄化 中[穴奶瓜旦卞卅月仇午反 中 + CHAR_setInt( charaindex, CHAR_MP, + CHAR_getInt( charaindex, CHAR_MP ) - mp ); + + // 爵 分匀凶日 + if( IsBATTLING( charaindex ) == TRUE ){ + return MAGIC_FieldAttChange_Battle( charaindex, toindex, marray, mp ); + }else{ + // 爵 匹卅井匀凶日 + return FALSE; + } +} +int MAGIC_StatusChange( int charaindex, int toindex, int marray, int mp ) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + return FALSE; + } + + if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE; + CHAR_setInt( charaindex, CHAR_MP, CHAR_getInt( charaindex, CHAR_MP ) - mp ); + if( IsBATTLING( charaindex ) == TRUE ){ +#ifdef _PREVENT_TEAMATTACK //异常状态不得使用友方 + int battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && + BattleArray[battleindex].type != BATTLE_TYPE_P_vs_P ){ + if( BATTLE_CheckSameSide( charaindex, toindex) == 1 ){//同边 + int battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + BATTLE_NoAction( battleindex, BATTLE_Index2No( battleindex, charaindex) ); + CHAR_talkToCli( charaindex, -1, "异常状态..不得施予友方。", CHAR_COLORYELLOW); + return FALSE; + } + } +#endif + return MAGIC_StatusChange_Battle( charaindex, toindex, marray, mp ); + }else{ + return FALSE; + } +} + +#ifdef _OTHER_MAGICSTAUTS +int MAGIC_MagicStatusChange( int charaindex, int toindex, int marray, int mp ) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE ) return FALSE; + + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + return FALSE; + } + if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE; + CHAR_setInt( charaindex, CHAR_MP, CHAR_getInt( charaindex, CHAR_MP ) - mp ); + if( IsBATTLING( charaindex ) == TRUE ){ + return MAGIC_MagicStatusChange_Battle( charaindex, toindex, marray, mp ); + }else{ + return FALSE; + } +} +#endif + +#ifdef _MAGIC_DEEPPOISON//新增ver2,主要设定毒状态5回未解时人物会阵亡 +// 旦 □正旦唱橘毛芨尹月 芊 +int MAGIC_StatusChange2( int charaindex, int toindex, int marray, int mp ) +{ + int battlemode; + + // INDEX民尼永弁 + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; //{撩 + + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + + // 爵 钒铵凛反 骰允月 + if( battlemode == BATTLE_CHARMODE_INIT ){ + return FALSE; + } + + //扣气 + if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE; + + CHAR_setInt( charaindex, CHAR_MP, + CHAR_getInt( charaindex, CHAR_MP ) - mp ); + + //call func + if( IsBATTLING( charaindex ) == TRUE ){ + return MAGIC_StatusChange_Battle2( charaindex, toindex, marray, mp ); + }else{ + return FALSE; + } +} +#endif +// 旦 □正旦唱橘荚汊今六月 芊 +int MAGIC_StatusRecovery( int charaindex, int toindex, int marray, int mp ) +{ + int battlemode; + + // INDEX民尼永弁 + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; //{撩 + + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + + // 爵 钒铵凛反 骰允月 + if( battlemode == BATTLE_CHARMODE_INIT ){ + return FALSE; + } + + // 壅 民尼永弁 + if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE; // 井匀凶日母丢 + // 仇及 芊反 骚卞 壅 仄化 中[穴奶瓜旦卞卅月仇午反 中 + CHAR_setInt( charaindex, CHAR_MP, + CHAR_getInt( charaindex, CHAR_MP ) - mp ); + + // 爵 分匀凶日 + if( IsBATTLING( charaindex ) == TRUE ){ + return MAGIC_StatusRecovery_Battle( charaindex, toindex, marray, mp ); + }else{ + // 爵 匹卅井匀凶日 + return FALSE; + } +} + +int MAGIC_MagicDef( int charaindex, int toindex, int marray, int mp ) +{ + int battlemode; + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ){ + return FALSE; + } + + if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE; + CHAR_setInt( charaindex, CHAR_MP, CHAR_getInt( charaindex, CHAR_MP ) - mp ); + if( IsBATTLING( charaindex ) == TRUE ){ +#ifdef _PREVENT_TEAMATTACK //光镜守..不得使用敌方 + int battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER + /*&& BattleArray[battleindex].type != BATTLE_TYPE_P_vs_P*/ ){ + if( BATTLE_CheckSameSide( charaindex, toindex) == 0 ){//不同边 + int battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + BATTLE_NoAction( battleindex, BATTLE_Index2No( battleindex, charaindex) ); + CHAR_talkToCli( charaindex, -1, "光镜守..不得施予敌方。", CHAR_COLORYELLOW); + return FALSE; + } + } +#endif + return MAGIC_MagicDef_Battle( charaindex, toindex, marray, mp ); + }else{ + return FALSE; + } +} + + +// 竣濮井日汊唾今六月 芊 +int MAGIC_Ressurect( int charaindex, int toindex, int marray, int mp ) +{ + int battlemode; + + // INDEX民尼永弁 + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; //{撩 + + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + + // 爵 钒铵凛反 骰允月 + if( battlemode == BATTLE_CHARMODE_INIT ){ + return FALSE; + } + + // 壅 民尼永弁 + if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE; // 井匀凶日母丢 + // 仇及 芊反 骚卞 壅 仄化 中[穴奶瓜旦卞卅月仇午反 中 + CHAR_setInt( charaindex, CHAR_MP, + CHAR_getInt( charaindex, CHAR_MP ) - mp ); + + // 爵 分匀凶日 + if( IsBATTLING( charaindex ) == TRUE ){ + return MAGIC_Ressurect_Battle( charaindex, toindex, marray, mp ); + }else{ + // 爵 匹卅井匀凶日 + return FALSE; + } +} + +// 箪岭毛 鳖今六月 芊 +int MAGIC_AttReverse( int charaindex, int toindex, int marray, int mp ) +{ + int battlemode; + + // INDEX民尼永弁 + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; //{撩 + + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + + // 爵 钒铵凛反 骰允月 + if( battlemode == BATTLE_CHARMODE_INIT ){ + return FALSE; + } + + // 壅 民尼永弁 + if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE; // 井匀凶日母丢 + // 仇及 芊反 骚卞 壅 仄化 中[穴奶瓜旦卞卅月仇午反 中 + CHAR_setInt( charaindex, CHAR_MP, + CHAR_getInt( charaindex, CHAR_MP ) - mp ); + + // 爵 分匀凶日 + if( IsBATTLING( charaindex ) == TRUE ){ + return MAGIC_AttReverse_Battle( charaindex, toindex, marray, mp ); + }else{ + // 爵 匹卅井匀凶日 + return FALSE; + } +} + + + +// 竣濮井日汊唾≈ 芊 豢 +int MAGIC_ResAndDef( int charaindex, int toindex, int marray, int mp ) +{ + int battlemode; + + // INDEX民尼永弁 + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; //{撩 + + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + + // 爵 钒铵凛反 骰允月 + if( battlemode == BATTLE_CHARMODE_INIT ){ + return FALSE; + } + + // 壅 民尼永弁 + if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE; // 井匀凶日母丢 + // 仇及 芊反 骚卞 壅 仄化 中[穴奶瓜旦卞卅月仇午反 中 + CHAR_setInt( charaindex, CHAR_MP, + CHAR_getInt( charaindex, CHAR_MP ) - mp ); + + // 爵 分匀凶日 + if( IsBATTLING( charaindex ) == TRUE ){ + return MAGIC_ResAndDef_Battle( charaindex, toindex, marray, mp ); + }else{ + // 爵 匹卅井匀凶日 + return FALSE; + } +} + + + +#ifdef __ATTACK_MAGIC + +int MAGIC_AttMagic( int charaindex , int toindex , int marray , int mp ) +{ + int battlemode; + + if( FALSE == CHAR_CHECKINDEX( charaindex ) ) + return FALSE; + + battlemode = CHAR_getWorkInt( charaindex , CHAR_WORKBATTLEMODE ); + if( BATTLE_CHARMODE_INIT == battlemode ) + return FALSE; + // 若是宠物魔法,不扣mp + if(CHAR_getInt(charaindex,CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) + { + if( CHAR_getInt( charaindex , CHAR_MP ) < mp ) + return FALSE; + + CHAR_setInt( charaindex , CHAR_MP , CHAR_getInt( charaindex , CHAR_MP ) - mp ); + } + + if( TRUE == IsBATTLING( charaindex ) ) + return MAGIC_AttMagic_Battle( charaindex , toindex , marray , mp ); + + return FALSE; + +} + +#endif + +#ifdef _ITEM_METAMO +int MAGIC_Metamo( int charaindex, int toindex, int marray, int mp ) +{ + int battlemode, haveindex, power, i; + char msg[128]; + + if( CHAR_CHECKINDEX( charaindex ) == FALSE ) return FALSE; + + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + // 爵 钒铵凛反 骰允月 + if( battlemode == BATTLE_CHARMODE_INIT ){ + return FALSE; + } + // 爵 分匀凶日 + if( IsBATTLING( charaindex ) == TRUE ){ + //MAGIC_Recovery_Battle( charaindex, toindex, marray, mp ); + //return FALSE; + toindex = BATTLE_No2Index( + CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ), toindex ); + //print(" battle_metamo:%d ", toindex); + } + + if( CHAR_CHECKINDEX( toindex ) == FALSE ) return FALSE; + + if( CHAR_getInt( charaindex, CHAR_RIDEPET ) != -1 ){ + CHAR_talkToCli( charaindex, -1, "无法变身,骑乘中不能变身!", CHAR_COLORWHITE ); + return FALSE; + } +#ifdef _FIX_METAMORIDE + if( CHAR_CHECKJOINENEMY( charaindex) == TRUE ){ + CHAR_talkToCli( charaindex, -1, "无法变身,搭乘中不能变身!", CHAR_COLORYELLOW ); + return FALSE; + } +#else + if( CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER) == 100259 ){ + CHAR_talkToCli( charaindex, -1, "无法变身,搭乘中不能变身!", CHAR_COLORWHITE ); + return FALSE; + } +#endif +#ifdef _FIXBUG_ATTACKBOW + { + int armindex = CHAR_getItemIndex( charaindex, CHAR_ARM); + if( ITEM_CHECKINDEX( armindex) == TRUE ) { + int armtype = BATTLE_GetWepon( charaindex); + if( armtype == ITEM_BOW || armtype == ITEM_BOUNDTHROW || + armtype == ITEM_BREAKTHROW || armtype == ITEM_BOOMERANG) { + CHAR_talkToCli( charaindex, -1, "使用远距离武器无法变身!", CHAR_COLORYELLOW ); + return FALSE; + } + } + } +#endif + haveindex = -1; + for( i = 0; i < 5; i++ ) + { + if( CHAR_getCharPet( charaindex, i) == toindex ) { + haveindex = i; + break; + } + } + if( haveindex == -1 && charaindex != toindex ) + { + CHAR_talkToCli( charaindex, -1, "无法变身,只能变成自己的宠物!", CHAR_COLORWHITE ); + return FALSE; + } + + if( CHAR_getInt( toindex, CHAR_BASEIMAGENUMBER) == 100259 ){ + CHAR_talkToCli( charaindex, -1, "不能变身成加美!", CHAR_COLORWHITE ); + return FALSE; + } + + power = atoi(MAGIC_getChar( marray, MAGIC_OPTION )); + + if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE; + CHAR_setInt( charaindex, CHAR_MP, + CHAR_getInt( charaindex, CHAR_MP ) - mp ); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_MP); + + if( toindex != charaindex ) { + CHAR_setWorkInt( charaindex, CHAR_WORKITEMMETAMO, NowTime.tv_sec +power); + sprintf( msg, "变身成%s!", CHAR_getChar( toindex, CHAR_NAME) ); + } + else { + CHAR_setWorkInt( charaindex, CHAR_WORKITEMMETAMO, 0); + sprintf( msg, "变回自己!"); + } + CHAR_talkToCli( charaindex, -1, msg, CHAR_COLORWHITE ); + + CHAR_setInt( charaindex, CHAR_BASEIMAGENUMBER, + CHAR_getInt( toindex, CHAR_BASEBASEIMAGENUMBER) ); + CHAR_complianceParameter( charaindex); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); +//#endif + + return TRUE; +} +#endif + +#ifdef _ITEM_ATTSKILLMAGIC +int MAGIC_AttSkill( int charaindex, int toindex,int marray, int mp ) +{ + int battlemode; + int battleindex=-1; + char *magicarg, funName[256]; + int skillID=-1; + PETSKILL_CALLFUNC func; + if( CHAR_CHECKINDEX( charaindex ) == FALSE ) return FALSE; + if( IsBATTLING( charaindex ) == FALSE ) return FALSE; + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + if( BATTLE_CHECKINDEX( battleindex ) == FALSE ) return FALSE; + + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + if( battlemode == BATTLE_CHARMODE_INIT ) return FALSE; + if( toindex < 0 || toindex > 19 ) return FALSE; + if( CHAR_getInt( charaindex, CHAR_MP ) < mp ) return FALSE; + + memset( funName, 0, sizeof( char)*256 ); + //MAGIC_Recovery_Battle( charaindex, toindex, marray, mp ); + magicarg = MAGIC_getChar( marray, MAGIC_OPTION ); + if (!magicarg) return FALSE; + if( strstr( magicarg, ";" ) != NULL ) { + char buff1[256]; + if( getStringFromIndexWithDelim( magicarg, ";", 1, buff1, sizeof( buff1)) == FALSE ) + return FALSE; + snprintf( funName, sizeof(funName), buff1); + if( getStringFromIndexWithDelim( magicarg, ";", 2, buff1, sizeof( buff1)) == FALSE ) + return FALSE; + skillID = atoi( buff1); + }else + return FALSE; + func = PETSKILL_getPetskillFuncPointer( funName); + if( !func ){ + print("\n *func not FOUND !!"); + return FALSE; + } + if( func( charaindex, toindex, skillID, "MAGICSKILL" ) == FALSE ) return FALSE; + CHAR_setInt( charaindex, CHAR_MP, CHAR_getInt( charaindex, CHAR_MP ) - mp ); + return TRUE; + +} +#endif +#ifdef _MAGIC_BARRIER// vincent 精灵:魔障 +int MAGIC_Barrier( int charaindex, int toindex, int marray, int mp ) +{ + + int battlemode; + int i,turn,perStatus; + int ToList[SIDE_OFFSET*2+1]; + char *magicarg; + int attackNo=0; + int battleindex,Success = 0; + char szTurn[] = "turn"; + char szSuccess[] = "成"; + char *pszP; + + //check index + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; + + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + + // 爵 钒铵凛反 骰允月//?? + if( battlemode == BATTLE_CHARMODE_INIT ){ + return FALSE; + } + + //mp不足 + if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE; + //消耗mp + CHAR_setInt( charaindex, CHAR_MP, + CHAR_getInt( charaindex, CHAR_MP ) - mp ); + //魔法名称 + magicarg = MAGIC_getChar( marray, MAGIC_OPTION ); + if( magicarg == NULL ) { + print("\n magicarg == NULL "); + return FALSE; + } + pszP = magicarg; + + //读取作用回合数 + if( ( pszP = strstr( pszP, szTurn ) ) != NULL){ + pszP += sizeof( szTurn ); + sscanf( pszP, "%d", &turn ); + } + // 岳 涩烂//命中率 + if( ( pszP = strstr( pszP, szSuccess ) ) != NULL){ + pszP += sizeof( szSuccess ); + sscanf( pszP, "%d", &Success ); + } + + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + attackNo = BATTLE_Index2No( battleindex, charaindex ); + BATTLE_MultiList( battleindex, toindex, ToList ); +//施魔法动画效果 + BATTLE_MagicEffect(battleindex, attackNo, ToList, MAGIC_EFFECT_USER, SPR_hoshi); + + charaindex = BATTLE_No2Index( battleindex, attackNo ); + //check是否战斗中 + if( IsBATTLING( charaindex ) == TRUE ) + { + + for( i = 0; ToList[i] != -1; i ++ ) + { + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + if( BATTLE_StatusAttackCheck( charaindex,toindex, BATTLE_ST_BARRIER, Success, 30, 1.0, &perStatus ) == TRUE ) + { + CHAR_setWorkInt( toindex, CHAR_WORKBARRIER, turn+1 ); +// BATTLE_BadStatusString( ToList[i], BATTLE_ST_BARRIER ); + } + } + return TRUE; + }else{ + return FALSE; + } +} +#endif +#ifdef _MAGIC_NOCAST// vincent 精灵:沉默 +int MAGIC_Nocast( int charaindex, int toindex, int marray, int mp ) +{ + + int battlemode; + int i,turn,perStatus; + int ToList[SIDE_OFFSET*2+1]; + char *magicarg; + int attackNo=0; + int battleindex,Success = 0; + char szTurn[] = "turn"; + char szSuccess[] = "成"; + char *pszP; + + //check index + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; + + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + + // 爵 钒铵凛反 骰允月//?? + if( battlemode == BATTLE_CHARMODE_INIT ){ + return FALSE; + } + + //mp不足 + if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE; + //消耗mp + CHAR_setInt( charaindex, CHAR_MP, + CHAR_getInt( charaindex, CHAR_MP ) - mp ); + //魔法名称 + magicarg = MAGIC_getChar( marray, MAGIC_OPTION ); + if( magicarg == NULL ) { + print("\n magicarg == NULL "); + return FALSE; + } + pszP = magicarg; + + //读取作用回合数 + if( ( pszP = strstr( pszP, szTurn ) ) != NULL){ + pszP += sizeof( szTurn ); + sscanf( pszP, "%d", &turn ); + } + // 岳 涩烂//命中率 + if( ( pszP = strstr( pszP, szSuccess ) ) != NULL){ + pszP += sizeof( szSuccess ); + sscanf( pszP, "%d", &Success ); + } +// print("\nvincent-->MAGIC_Nocast use"); + battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX ); + attackNo = BATTLE_Index2No( battleindex, charaindex ); + BATTLE_MultiList( battleindex, toindex, ToList ); +//施魔法动画效果 + BATTLE_MagicEffect(battleindex, attackNo, ToList, MAGIC_EFFECT_USER, SPR_hoshi); + charaindex = BATTLE_No2Index( battleindex, attackNo ); + //check是否战斗中 + if( IsBATTLING( charaindex ) == TRUE ) + { + + for( i = 0; ToList[i] != -1; i ++ ) + { + toindex = BATTLE_No2Index( battleindex, ToList[i] ); + if( BATTLE_StatusAttackCheck( charaindex,toindex, BATTLE_ST_NOCAST, Success, 30, 1.0, &perStatus ) == TRUE + && CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPET) + { + CHAR_setWorkInt( toindex, CHAR_WORKNOCAST, turn ); +//无法展开咒术页 + lssproto_NC_send( getfdFromCharaIndex( toindex ), 1); + //print("\nvincent-->NOCASTING2"); +// BATTLE_BadStatusString( ToList[i], BATTLE_ST_NOCAST ); + } + } + return TRUE; + }else{ + return FALSE; + } +} +#endif + +#ifdef _MAGIC_WEAKEN// vincent 精灵:虚弱 +int MAGIC_Weaken( int charaindex, int toindex, int marray, int mp ) +{ + + int battlemode; + //check index + if( CHAR_CHECKINDEX( charaindex ) == FALSE )return FALSE; + + battlemode = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ); + + // 爵 钒铵凛反 骰允月//?? + if( battlemode == BATTLE_CHARMODE_INIT ){ + return FALSE; + } + + //mp不足 + if( CHAR_getInt( charaindex, CHAR_MP ) < mp )return FALSE; + //消耗mp + CHAR_setInt( charaindex, CHAR_MP, + CHAR_getInt( charaindex, CHAR_MP ) - mp ); + + //check是否战斗中 + if( IsBATTLING( charaindex ) == TRUE ){ + return MAGIC_ParamChange_Turn_Battle( charaindex, toindex, marray, mp ); + }else{ + return FALSE; + } +} +#endif + +#ifdef _MAGIC_TOCALL +int MAGIC_ToCallDragon( int charaindex, int toindex,int marray, int mp ) +{ + int battlemode; + + print("MAGIC_ToCallDragon in .................\n"); + if( FALSE == CHAR_CHECKINDEX( charaindex ) ) + return FALSE; + + battlemode = CHAR_getWorkInt( charaindex , CHAR_WORKBATTLEMODE ); + if( BATTLE_CHARMODE_INIT == battlemode ) + return FALSE; + if( CHAR_getInt( charaindex , CHAR_MP ) < mp ) + return FALSE; + + CHAR_setInt( charaindex , CHAR_MP , CHAR_getInt( charaindex , CHAR_MP ) - mp ); + + if( TRUE == IsBATTLING( charaindex ) ) + return MAGIC_ToCallDragon_Battle( charaindex , toindex , marray , mp ); + + return FALSE; +} +#endif + + + + diff --git a/gmsv/magic/magic_base.c b/gmsv/magic/magic_base.c new file mode 100644 index 0000000..4cf3cb8 --- /dev/null +++ b/gmsv/magic/magic_base.c @@ -0,0 +1,521 @@ +#include "version.h" +#include +#include + +#include "common.h" +#include "buf.h" +#include "configfile.h" +#include "magic_base.h" +#include "magic.h" + +static Magic *MAGIC_magic; +static int MAGIC_magicnum; + + + +#ifdef __ATTACK_MAGIC + +AttMagic *ATTMAGIC_magic; +int ATTMAGIC_magicnum; + +#endif + + + +typedef struct tagMagic_MagicFunctionTable +{ + char *functionname; /* 热诸涩烂白央奶伙卞踏仁楮醒及 蟆 */ + MAGIC_CALLFUNC func; /* 端卞裟太请今木月楮醒 */ + int hash; /* hash */ +}MAGIC_MagicFunctionTable; + +/* 热诸毛 支仄凶日仇仇卞瓒 允月仪 */ +static MAGIC_MagicFunctionTable MAGIC_functbl[] = { + { "MAGIC_Recovery", MAGIC_Recovery, 0}, + { "MAGIC_OtherRecovery", MAGIC_OtherRecovery, 0}, + { "MAGIC_FieldAttChange", MAGIC_FieldAttChange, 0}, + { "MAGIC_StatusChange", MAGIC_StatusChange, 0}, + { "MAGIC_MagicDef", MAGIC_MagicDef, 0}, + { "MAGIC_StatusRecovery", MAGIC_StatusRecovery, 0}, + { "MAGIC_Ressurect", MAGIC_Ressurect, 0}, + { "MAGIC_AttReverse", MAGIC_AttReverse, 0}, + { "MAGIC_ResAndDef", MAGIC_ResAndDef, 0}, + +#ifdef __ATTACK_MAGIC + { "MAGIC_AttMagic" , MAGIC_AttMagic , 0 }, +#endif +#ifdef _OTHER_MAGICSTAUTS + { "MAGIC_MagicStatusChange", MAGIC_MagicStatusChange, 0}, +#endif +#ifdef _ITEM_METAMO + { "MAGIC_Metamo", MAGIC_Metamo, 0}, +#endif +#ifdef _ITEM_ATTSKILLMAGIC + //{ "MAGIC_AttSkill", MAGIC_AttSkill, 0}, +#endif +#ifdef _MAGIC_WEAKEN // vincent 精灵:虚弱 + { "MAGIC_Weaken", MAGIC_Weaken, 0}, +#endif +#ifdef _MAGIC_DEEPPOISON // vincent 精灵:剧毒 + { "MAGIC_StatusChange2", MAGIC_StatusChange2,0}, +#endif +#ifdef _MAGIC_BARRIER // vincent 精灵:魔障 + { "MAGIC_Barrier", MAGIC_Barrier, 0}, +#endif +#ifdef _MAGIC_NOCAST // vincent 精灵:沉默 + { "MAGIC_Nocast", MAGIC_Nocast, 0}, +#endif +#ifdef _MAGIC_TOCALL // 奔龙阵 + { "MAGIC_ToCallDragon", MAGIC_ToCallDragon, 0}, +#endif +}; + +/*----------------------------------------------------------------------*/ + + +/* 湘 民尼永弁]失弁本旦楮溢 */ +/*----------------------------------------------------------------------*/ +INLINE BOOL MAGIC_CHECKINDEX( int index ) +{ + if( MAGIC_magicnum<=index || index<0 )return FALSE; + return TRUE; +} +/*----------------------------------------------------------------------*/ +static INLINE BOOL MAGIC_CHECKINTDATAINDEX( int index) +{ + if( MAGIC_DATAINTNUM <= index || index < 0 ) return FALSE; + return TRUE; +} +/*----------------------------------------------------------------------*/ +static INLINE BOOL MAGIC_CHECKCHARDATAINDEX( int index) +{ + if( MAGIC_DATACHARNUM <= index || index < 0 ) return FALSE; + return TRUE; +} +/*----------------------------------------------------------------------*/ +INLINE int MAGIC_getInt( int index, MAGIC_DATAINT element) +{ + return MAGIC_magic[index].data[element]; +} +/*----------------------------------------------------------------------*/ +INLINE int MAGIC_setInt( int index, MAGIC_DATAINT element, int data) +{ + int buf; + buf = MAGIC_magic[index].data[element]; + MAGIC_magic[index].data[element]=data; + return buf; +} +/*----------------------------------------------------------------------*/ +INLINE char* MAGIC_getChar( int index, MAGIC_DATACHAR element) +{ + if( !MAGIC_CHECKINDEX( index)) return NULL; + if( !MAGIC_CHECKCHARDATAINDEX( element)) return NULL; + return MAGIC_magic[index].string[element].string; +} + +/*----------------------------------------------------------------------*/ +INLINE BOOL MAGIC_setChar( int index ,MAGIC_DATACHAR element, char* new ) +{ + if(!MAGIC_CHECKINDEX(index))return FALSE; + if(!MAGIC_CHECKCHARDATAINDEX(element))return FALSE; + strcpysafe( MAGIC_magic[index].string[element].string, + sizeof(MAGIC_magic[index].string[element].string), + new ); + return TRUE; +} +/*---------------------------------------------------------------------- + * 芊及醒毛襞月[ + *---------------------------------------------------------------------*/ +int MAGIC_getMagicNum( void) +{ + return MAGIC_magicnum; +} + +/*---------------------------------------------------------------------- + * 芊及涩烂白央奶伙毛 戈 + *---------------------------------------------------------------------*/ +BOOL MAGIC_initMagic( char *filename) +{ + FILE* f; + char line[256]; + int linenum=0; + int magic_readlen=0; + int i,j; + + int max_magicid =0; + char token[256]; + + f = fopen(filename,"r"); + if( f == NULL ){ + print( "文件打开失败\n"); + return FALSE; + } + + MAGIC_magicnum=0; + + /* 引内 躲卅垫互窒垫丐月井升丹井譬屯月 */ + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + +#ifdef _MAGIC_OPTIMUM // Robin 取出最大MAGIC ID + if( getStringFromIndexWithDelim( line, ",", MAGIC_DATACHARNUM+MAGIC_ID+1, + token, sizeof(token)) == FALSE ) + continue; + max_magicid = max( atoi( token), max_magicid); +#endif + + MAGIC_magicnum++; + } + +#ifdef _MAGIC_OPTIMUM + print("有效魔法:%d 最大魔法:%d ...", MAGIC_magicnum, max_magicid); + MAGIC_magicnum = max_magicid +1; +#endif + + if( fseek( f, 0, SEEK_SET ) == -1 ){ + fprint( "搜索错误\n" ); + fclose(f); + return FALSE; + } + + MAGIC_magic = allocateMemory( sizeof(struct tagMagic) + * MAGIC_magicnum ); + if( MAGIC_magic == NULL ){ + fprint( "无法分配内存 %d\n" , + sizeof(struct tagMagic)*MAGIC_magicnum); + fclose( f ); + return FALSE; + } + + /* 赓渝祭 */ + for( i = 0; i < MAGIC_magicnum; i ++ ) { + for( j = 0; j < MAGIC_DATAINTNUM; j ++ ) { + MAGIC_setInt( i,j,-1); + } + for( j = 0; j < MAGIC_DATACHARNUM; j ++ ) { + MAGIC_setChar( i,j,""); + } + } + + /* 引凶 心 允 */ + linenum = 0; + while( fgets( line, sizeof( line ), f ) ){ + linenum ++; + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + + /* 垫毛帮溥允月 */ + /* 引内 tab 毛 " " 卞 五晶尹月 */ + replaceString( line, '\t' , ' ' ); + /* 燮 及旦矢□旦毛潸月[*/ +{ + char buf[256]; + for( i = 0; i < strlen( line); i ++) { + if( line[i] != ' ' ) { + break; + } + strcpy( buf, &line[i]); + } + if( i != 0 ) { + strcpy( line, buf); + } +} +{ + char token[256]; + int ret; + +#ifdef _MAGIC_OPTIMUM + if( getStringFromIndexWithDelim( line, ",", MAGIC_DATACHARNUM+MAGIC_ID+1, + token, sizeof(token)) == FALSE ) + continue; + magic_readlen = atoi( token); +#endif + + for( i = 0; i < MAGIC_DATACHARNUM; i ++ ) { + + /* 侬 迕玄□弁件毛苇月 */ + ret = getStringFromIndexWithDelim( line,",", + i + 1, + token,sizeof(token)); + if( ret==FALSE ){ + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + break; + } + MAGIC_setChar( magic_readlen, i, token); + } + /* 4勾 动嫦反醒袄犯□正 */ +#define MAGIC_STARTINTNUM 5 + for( i = MAGIC_STARTINTNUM; i < MAGIC_DATAINTNUM+MAGIC_STARTINTNUM; i ++ ) { + ret = getStringFromIndexWithDelim( line,",",i,token, + sizeof(token)); + +#ifdef __ATTACK_MAGIC + + if( FALSE == ret ) + + break; + + if( 0 != strlen( token ) ) + { + MAGIC_setInt( magic_readlen , i - MAGIC_STARTINTNUM , atoi( token ) ); + } + +#else + + if( ret==FALSE ){ + fprint("文件语法错误:%s 第%d行\n",filename,linenum); + break; + } + if( strlen( token) != 0 ) { + MAGIC_setInt( magic_readlen, i - MAGIC_STARTINTNUM, atoi( token)); + } + + #endif + } + +#ifdef __ATTACK_MAGIC + + if( i != MAGIC_STARTINTNUM + MAGIC_IDX && i != MAGIC_DATAINTNUM + MAGIC_STARTINTNUM ) + continue; + +#else + + if( i < MAGIC_DATAINTNUM+MAGIC_STARTINTNUM ) + continue; + +#endif + /* 切斤匀午尕称鼎分仃升仇丹允月[ */ + if( MAGIC_getInt( magic_readlen, MAGIC_TARGET_DEADFLG) == 1 ) { + MAGIC_setInt( magic_readlen, MAGIC_TARGET, + MAGIC_getInt( magic_readlen, MAGIC_TARGET)+100); + } + + magic_readlen ++; +} + } + fclose(f); + + MAGIC_magicnum = magic_readlen; + + + print( "有效魔法数是 %d...", MAGIC_magicnum ); + + /* hash 及瓒 */ + for( i = 0; i < arraysizeof( MAGIC_functbl); i ++ ) { + MAGIC_functbl[i].hash = hashpjw( MAGIC_functbl[i].functionname); + } +#if 0 + for( i=0; i = 0 && magicid < MAGIC_magicnum) + return magicid; +#else + int i; + for( i = 0; i < MAGIC_magicnum; i ++ ) { + if( MAGIC_magic[i].data[MAGIC_ID] == magicid ) { + return i; + } + } +#endif + return -1; +} +/*------------------------------------------------------------ + * 热诸及楮醒 井日禾奶件正□毛忒允 + * 娄醒 + * name char* 热诸及 蟆 + * 忒曰袄 + * 楮醒尺及禾奶件正[卅中桦宁卞反NULL + ------------------------------------------------------------*/ +MAGIC_CALLFUNC MAGIC_getMagicFuncPointer(char* name) +{ + int i; + int hash; //ttom + //ttom 12/18/2000 + if(name==NULL) return NULL; + //ttom + //int hash = hashpjw( name ); + hash=hashpjw(name); + for( i = 0 ; i< arraysizeof( MAGIC_functbl) ; i++ ) { + if( MAGIC_functbl[i].hash == hash ) { + if( strcmp( MAGIC_functbl[i].functionname, name ) == 0 ) { + return MAGIC_functbl[i].func; + } + } + } + return NULL; +} + + +// Nuke start (08/23) +/* + 酱 Nuke 今氏及民尼永弁[ + 芊及躲绊 区毛民尼永弁允月[ + + Check the validity of the target of a magic. + Return value: + 0: Valid + -1: Invalid +*/ +int MAGIC_isTargetValid( int magicid, int toindex) +{ + int marray; + marray= MAGIC_getMagicArray( magicid); + + #ifdef __ATTACK_MAGIC + + if( toindex >= 0 && toindex <= 19 ) + return 0; + + // One side of players + if( 20 == toindex || 21 == toindex ) + { + if( MAGIC_TARGET_WHOLEOTHERSIDE == MAGIC_magic[marray].data[MAGIC_TARGET] || MAGIC_TARGET_ALL_ROWS == MAGIC_magic[marray].data[MAGIC_TARGET] ) + return 0; + else + return -1; + } + + // All players + if( 22 == toindex ) + { + if( MAGIC_TARGET_ALL == MAGIC_magic[marray].data[MAGIC_TARGET] ) + return 0; + else + return -1; + } + + // One row + if( 23 == toindex || 24 == toindex || 25 == toindex || 26 == toindex ) + { + if( MAGIC_TARGET_ONE_ROW == MAGIC_magic[marray].data[MAGIC_TARGET] ) + return 0; + else + return -1; + } + + #else + + // Single player + if ((toindex >= 0x0) && (toindex <= 0x13)) return 0; + // All players + if (toindex == 0x16) { + if (MAGIC_magic[marray].data[MAGIC_TARGET] == MAGIC_TARGET_ALL) + return 0; else return -1; + } + // One side of players + if ((toindex == 0x14) || (toindex == 0x15)) { + if (MAGIC_magic[marray].data[MAGIC_TARGET] == MAGIC_TARGET_WHOLEOTHERSIDE) + return 0; else return -1; + } + + #endif + + // Others: Error + return -1; +} +// Nuke end diff --git a/gmsv/magic/magic_field.c b/gmsv/magic/magic_field.c new file mode 100644 index 0000000..ecf2255 --- /dev/null +++ b/gmsv/magic/magic_field.c @@ -0,0 +1,149 @@ +#include "version.h" +#include + +#include "common.h" +#include "char_base.h" +#include "char.h" +#include "magic_base.h" +#include "magic.h" +#include "magic_field.h" + +/* + * 哗晓匹及 芊及质 + */ +/*---------------------------------------------------------------------- + * 愤坌及心荚汊 + * 娄醒 + * charaindex int 愤坌及index + * magicindex int 芊及index + *---------------------------------------------------------------------*/ +int MAGIC_Recovery_Field( int charaindex, int magicindex) +{ + char *magicarg; + float power; + int workhp; + int prevhp; + char msgbuf[64]; + +#ifdef _TYPE_TOXICATION + if( CHAR_CanCureFlg( charaindex, "HP") == FALSE ) return TRUE; +#endif + magicarg = MAGIC_getChar( magicindex, MAGIC_OPTION ); + power = atoi( magicarg ); + power = RAND( (power*0.9), (power*1.1) ); +#ifndef _MAGIC_REHPAI + power *= GetRecoveryRate( charaindex ); +#endif + prevhp = CHAR_getInt( charaindex, CHAR_HP ); + workhp = prevhp + (int)power; + CHAR_setInt( charaindex, CHAR_HP, + min( workhp, CHAR_getWorkInt( charaindex, CHAR_WORKMAXHP ) ) ); + CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_HP|CHAR_P_STRING_MP); + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE ) { + int mypartyarray = -1; + int oyaindex = CHAR_getWorkInt( charaindex, CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX( oyaindex )) { + int i; + for( i = 0; i < CHAR_PARTYMAX; i ++ ) { + int workindex = CHAR_getWorkInt( oyaindex, CHAR_WORKPARTYINDEX1 +i); + if( CHAR_CHECKINDEX( workindex) ) { + if( workindex == charaindex ) { + mypartyarray = i; + break; + } + } + } + if( mypartyarray != -1 ) { + for( i = 0; i < CHAR_PARTYMAX; i ++ ) { + int index = CHAR_getPartyIndex( charaindex, i); + if( CHAR_CHECKINDEX( index) ) { + if( index != charaindex) { + CHAR_send_N_StatusString( index, mypartyarray, + CHAR_N_STRING_HP|CHAR_N_STRING_MP); + } + } + } + } + } + } + snprintf( msgbuf, sizeof( msgbuf), "耐久力回复%d", + min( workhp, CHAR_getWorkInt( charaindex, CHAR_WORKMAXHP)) - prevhp); + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORWHITE); + return TRUE; + +} +/*---------------------------------------------------------------------- + * 职谛毛荚汊 + * 娄醒 + * charaindex int 愤坌及index + * toindex int 荚汊允月谛及index + * magicindex int 芊及index + *---------------------------------------------------------------------*/ +int MAGIC_OtherRecovery_Field( int charaindex, int toindex, int magicindex) +{ + char *magicarg; + float power; + int workhp; + int prevhp; + char msgbuf[64]; + +#ifdef _TYPE_TOXICATION + if( CHAR_CanCureFlg( charaindex, "HP") == FALSE )return FALSE; +#endif + magicarg = MAGIC_getChar( magicindex, MAGIC_OPTION ); + power = atoi( magicarg ); + power = RAND( (power*0.9), (power*1.1) ); +#ifndef _MAGIC_REHPAI + power *= GetRecoveryRate( toindex ); +#endif + prevhp = CHAR_getInt( toindex, CHAR_HP ); + workhp = prevhp + (int)power; + CHAR_setInt( toindex, CHAR_HP, + min( workhp, CHAR_getWorkInt( toindex, CHAR_WORKMAXHP ) ) ); + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + if( charaindex != toindex ) { + CHAR_send_P_StatusString( toindex, CHAR_P_STRING_HP); + } + } + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_HP|CHAR_P_STRING_MP); + if( charaindex != toindex) { + CHAR_PartyUpdate( charaindex, CHAR_N_STRING_MP); + CHAR_PartyUpdate( toindex, CHAR_N_STRING_HP); + } + else { + CHAR_PartyUpdate( charaindex, CHAR_N_STRING_MP|CHAR_N_STRING_HP); + } + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPET ){ + int i; + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + int workindex = CHAR_getCharPet( charaindex, i ); + if( workindex == toindex ){ + CHAR_send_K_StatusString( charaindex, i, CHAR_K_STRING_HP); + } + } + } + + if( charaindex != toindex) { + snprintf( msgbuf, sizeof( msgbuf), "%s的耐久力回复%d", + CHAR_getUseName( toindex ), + min( workhp, CHAR_getWorkInt( toindex, CHAR_WORKMAXHP)) - prevhp); + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORWHITE); + + if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + snprintf( msgbuf, sizeof( msgbuf), "藉由%s耐久力回复%d", + CHAR_getUseName( charaindex ), + min( workhp,CHAR_getWorkInt( toindex, CHAR_WORKMAXHP)) - prevhp); + CHAR_talkToCli( toindex, -1, msgbuf, CHAR_COLORWHITE); + } + } + else { + snprintf( msgbuf, sizeof( msgbuf), "耐久力回复%d", + min( workhp,CHAR_getWorkInt( charaindex, CHAR_WORKMAXHP)) - prevhp); + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORWHITE); + + } + + return TRUE; + +} + diff --git a/gmsv/magic/makefile b/gmsv/magic/makefile new file mode 100644 index 0000000..996a7ba --- /dev/null +++ b/gmsv/magic/makefile @@ -0,0 +1,145 @@ +INCFLAGS=-I. -I../include + + +CFLAGS=-w -O3 $(INCFLAGS) + +PROG=libmagic.a + +SRC=magic.c magic_base.c magic_field.c +OBJ=$(SRC:.c=.o) + + +ifeq (0,$(MAKELEVEL)) +CC=gcc +RM=rm -f +AR=ar cr +MV=mv +RANLIB=ranlib +SED=sed +SHELL=/bin/sh +endif + +all: $(PROG) + +$(PROG): $(OBJ) + $(RM) $(PROG) + $(AR) $(PROG) $(OBJ) + $(RANLIB) $(PROG) + +depend: + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(CC) $(INCFLAGS) -M $(SRC) >> makefile + +clean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + +distclean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(RM) makefile.bak + +# DO NOT DELETE THIS LINE +magic.o: magic.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/string.h ../include/common.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h ../include/char_base.h ../include/skill.h \ + ../include/util.h /usr/include/sys/time.h /usr/include/time.h \ + /usr/include/bits/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/char.h ../include/battle.h ../include/magic_base.h \ + ../include/magic.h ../include/magic_field.h ../include/family.h \ + ../include/handletime.h ../include/battle_magic.h \ + ../include/battle_event.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/pet_skill.h +magic_base.o: magic_base.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/string.h ../include/common.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h ../include/buf.h ../include/configfile.h \ + ../include/magic_base.h ../include/util.h /usr/include/sys/time.h \ + /usr/include/time.h /usr/include/bits/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/magic.h +magic_field.o: magic_field.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + ../include/common.h /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/magic_base.h ../include/magic.h \ + ../include/magic_field.h diff --git a/gmsv/magic/makefile.bak b/gmsv/magic/makefile.bak new file mode 100644 index 0000000..bb734b9 --- /dev/null +++ b/gmsv/magic/makefile.bak @@ -0,0 +1,121 @@ +INCFLAGS=-I. -I../include + + +CFLAGS=-w -O3 $(INCFLAGS) + +PROG=libmagic.a + +SRC=magic.c magic_base.c magic_field.c +OBJ=$(SRC:.c=.o) + + +ifeq (0,$(MAKELEVEL)) +CC=gcc +RM=rm -f +AR=ar cr +MV=mv +RANLIB=ranlib +SED=sed +SHELL=/bin/sh +endif + +all: $(PROG) + +$(PROG): $(OBJ) + $(RM) $(PROG) + $(AR) $(PROG) $(OBJ) + $(RANLIB) $(PROG) + +depend: + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(CC) $(INCFLAGS) -M $(SRC) >> makefile + +clean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + +distclean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(RM) makefile.bak + +# DO NOT DELETE THIS LINE +magic.o: magic.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/common.h ../include/char_base.h ../include/skill.h \ + ../include/util.h /usr/include/sys/time.h /usr/include/time.h \ + /usr/include/bits/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/char.h ../include/battle.h ../include/magic_base.h \ + ../include/magic.h ../include/battle_magic.h ../include/magic_field.h +magic_base.o: magic_base.c /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + /usr/include/string.h ../include/common.h ../include/buf.h \ + ../include/configfile.h ../include/magic_base.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/magic.h +magic_field.o: magic_field.c /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/common.h ../include/char_base.h ../include/skill.h \ + ../include/util.h /usr/include/sys/time.h /usr/include/time.h \ + /usr/include/bits/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/magic_base.h ../include/magic.h \ + ../include/magic_field.h diff --git a/gmsv/main.c b/gmsv/main.c new file mode 100644 index 0000000..191184e --- /dev/null +++ b/gmsv/main.c @@ -0,0 +1,379 @@ +#include "version.h" +#include +#include +#include +#include +#include + + +#include "init.h" +#include "net.h" +#include "handletime.h" +#include "char.h" +#include "map_warppoint.h" +#include "npcgen.h" +#include "log.h" +#include "configfile.h" +#include "battle.h" +#include "petmail.h" +#include "autil.h" +#include "family.h" +#include "defend.h" +#include "trade.h" + +#ifdef _NPCSERVER_NEW +#include "npcserver.h" +#endif + +#ifdef _RECAL_SEND_COUNT // WON 传送GS资讯 +#include "mclient.h" +#endif + +#ifdef _DEATH_CONTEND +#include "deathcontend.h" +#endif +#ifdef _CHATROOMPROTOCOL // (不可开) Syu ADD 聊天室频道 +#include "chatroom.h" +#endif + +static void ShutdownProc( void); +void mainloop( void ); +struct tm tmNow, tmOld; +void family_proc(); +// Terry add 2001/10/11 +#ifdef _SERVICE +extern int g_nServiceSocket; +#endif + +#ifdef _CHANNEL_MODIFY +extern int InitOccChannel(void); +#endif + +#ifdef _ANGEL_SUMMON +#define ANGELTIMELIMIT 3*24*60*60 // 完成任务时限(秒) +int AngelReady =0; +int AngelTimelimit = ANGELTIMELIMIT; +time_t AngelNextTime; +void AngelReadyProc(); +#endif + +#include "genver.h" + +void warplog_proc(); + +int main( int argc , char** argv, char** env ) +{ + /* 午曰丐尹内凛棉毛涩烂仄化云仁 */ + setNewTime(); + + if ( argc > 1 && 0==strcmp(argv[1],"-v")) + { + printf("%s",genver); + exit(0); + } + else fprintf(stderr,"%s",genver); + + EXITWITHEXITCODEIFFALSE( util_Init() , 1); + + LoadAnnounce(); // Arminius 7.12 loginannounce + + /* 赓渝涩烂 */ + memcpy( &tmOld, localtime( (time_t *)&NowTime.tv_sec), sizeof( tmNow ) ); + + EXITWITHEXITCODEIFFALSE( init(argc , argv ,env ) , 1); + + LoadPetTalk(); // Arminius 8.14 pet talk + +#ifdef _GAMBLE_BANK + Load_GambleBankItems(); +#endif + +#ifdef _CFREE_petskill + Load_PetSkillCodes(); +#endif +#ifdef _ITEM_PILEFORTRADE + TRADE_InitTradeList(); +#endif + +#ifdef _DEATH_CONTEND + if( PKLIST_InitPkTeamList( MAXTEAMNUM ) == -1 ) return 1; +#endif + +#if USE_MTIO + /* 穴伙民旦伊永玉及午五反仇仇匹坌昴 */ + if( MTIO_setup() < 0 ){ + print( "cannot setup MT environment\n" ); + return 1; + } + + /* 仇仇匹 join 仄化蔽 */ + MTIO_join(); +#else + mainloop(); +#endif + + return 0; +} + +void mainloop( void ) +{ + NPC_generateLoop( 1 ); + signal(SIGUSR1,sigusr1); + signal(SIGUSR2,sigusr2); +#ifdef _MAP_WARPPOINT + MAPPOINT_InitMapWarpPoint(); + if( !MAPPOINT_loadMapWarpPoint() ){ + return; + } +#endif + +#ifdef _ASSESS_SYSEFFICACY + Assess_InitSysEfficacy(); +#endif + +#ifdef _CHECK_BATTLETIME + check_battle_com_init(); +#endif + +#ifdef _CHATROOMPROTOCOL // (不可开) Syu ADD 聊天室频道 + InitChatRoom(); +#endif + +#ifdef _CHANNEL_MODIFY + if(!InitOccChannel()) return; // 初始化职业频道 +#endif + +#ifdef _GM_BROADCAST // WON ADD 客服公告系统 + Init_GM_BROADCAST( 0, 0, 0, "" ); +#endif + +#ifdef _DEATH_FAMILY_STRUCT // WON ADD 家族战存放胜负资料 + Init_FM_PK_STRUCT(); +#endif + +#ifdef _ANGEL_SUMMON + AngelReady = 0; + AngelNextTime = time(NULL) + 1*60; +#endif + +//#ifdef _ALLDOMAN +// InitHeroList(); +//#endif + while(1){ +#ifdef _ASSESS_SYSEFFICACY + Assess_SysEfficacy( 0 ); +#endif + setNewTime(); + memcpy(&tmNow, localtime( (time_t *)&NowTime.tv_sec), + sizeof( tmNow ) ); + if( tmOld.tm_hour != getLogHour( ) && tmNow.tm_hour == getLogHour( ) ){ + backupAllLogFile( &tmOld ); + } + setNewTime(); + +#ifdef _ASSESS_SYSEFFICACY_SUB //显示LOOP时间 +Assess_SysEfficacy_sub( 0, 1); + netloop_faster(); +Assess_SysEfficacy_sub( 1, 1); + +//Assess_SysEfficacy_sub( 0, 2); + NPC_generateLoop( 0 ); +//Assess_SysEfficacy_sub( 1, 2); + +Assess_SysEfficacy_sub( 0, 3); + BATTLE_Loop(); +Assess_SysEfficacy_sub( 1, 3); + +Assess_SysEfficacy_sub( 0, 4); + CHAR_Loop(); +Assess_SysEfficacy_sub( 1, 4); + +//Assess_SysEfficacy_sub( 0, 5); + PETMAIL_proc(); +//Assess_SysEfficacy_sub( 1, 5); + +//Assess_SysEfficacy_sub( 0, 6); + family_proc(); +//Assess_SysEfficacy_sub( 1, 6); + +//Assess_SysEfficacy_sub( 0, 7); + chardatasavecheck(); +//Assess_SysEfficacy_sub( 1, 7); +#ifdef _GM_BROADCAST // WON ADD 客服公告系统 +//Assess_SysEfficacy_sub( 0, 8); + GM_BROADCAST(); +//Assess_SysEfficacy_sub( 1, 8); +#endif + +#else //不显示LOOP时间 + netloop_faster(); + NPC_generateLoop( 0 ); + BATTLE_Loop(); + CHAR_Loop(); + PETMAIL_proc(); + family_proc(); + chardatasavecheck(); +#ifdef _GM_BROADCAST // WON ADD 客服公告系统 + GM_BROADCAST(); +#endif +#endif + +#ifdef _ANGEL_SUMMON + AngelReadyProc(); +#endif + + if( tmOld.tm_sec != tmNow.tm_sec ) { + CHAR_checkEffectLoop(); + } + if( SERVSTATE_getShutdown()> 0 ) { + ShutdownProc(); + } + + tmOld = tmNow; +#ifdef _ASSESS_SYSEFFICACY + Assess_SysEfficacy( 1); +#endif + } +#ifdef _SERVICE + close(g_nServiceSocket); +#endif +} + +static void sendmsg_toall( char *msg ) +{ + int i; + int playernum = CHAR_getPlayerMaxNum(); + + for( i = 0 ; i < playernum ; i++) { + if( CHAR_getCharUse(i) != FALSE ) { + CHAR_talkToCli( i, -1, msg, CHAR_COLORYELLOW); + } + } +} +static void ShutdownProc( void) +{ +#define SYSINFO_SHUTDOWN_MSG "再过 %d 分钟後,即开始进行server系统维护。" +#define SYSINFO_SHUTDOWN_MSG_COMP "server已关闭。" + int diff,hun; + + diff = NowTime.tv_sec - SERVSTATE_getShutdown(); + hun = SERVSTATE_getLimittime() - (diff/60); + if( hun != SERVSTATE_getDsptime() ){ + char buff[256]; + if( hun != 0 ) { + snprintf( buff, sizeof(buff), SYSINFO_SHUTDOWN_MSG, hun); + } + else { + strcpy( buff, SYSINFO_SHUTDOWN_MSG_COMP); + } + sendmsg_toall( buff); + SERVSTATE_setDsptime(hun); + if( hun == 1 ) { + SERVSTATE_SetAcceptMore( 0 ); + } + } + /* closesallsockets */ + if( hun == 0) { + closeAllConnectionandSaveData(); + SERVSTATE_setShutdown(0); + SERVSTATE_setDsptime(0); + SERVSTATE_setLimittime(0); +#ifdef _KILL_12_STOP_GMSV // WON ADD 下sigusr2後关闭GMSV + //andy_reEdit 2003/04/28不准开... + //system("./stop.sh"); +#endif + } + +} + +void family_proc() +{ + static unsigned long gettime = 0; + static unsigned long checktime = 0; + static unsigned long proctime = 0; + +#ifdef _CK_ONLINE_PLAYER_COUNT // WON ADD 计算线上人数 + static unsigned long player_count_time = 0; + int PLAYER_COUNT_TIME = 60*5; // 30秒传一次人数至 AC +#endif + +#ifdef _RECAL_SEND_COUNT // WON 传送GS资讯 + static unsigned long recal_count_time = 0; + int RECAL_COUNT_TIME = 60; + if( (unsigned long)NowTime.tv_sec > recal_count_time ){ + recal_get_count(); +#ifdef _GSERVER_RUNTIME //传送GSERVER执行多少时间给MSERVER + gserver_runtime(); +#endif + recal_count_time = (unsigned long)NowTime.tv_sec + RECAL_COUNT_TIME; + } +#endif + + if( time(NULL) < proctime ) return; + proctime = time(NULL)+5; + + if( (unsigned long)NowTime.tv_sec > gettime ){ + getNewFMList(); + gettime = (unsigned long)NowTime.tv_sec + 60*10; + } + + if( (unsigned long)NowTime.tv_sec > checktime ){ + //checkFamilyIndex(); + + checktime = (unsigned long)NowTime.tv_sec + 60*30; + } + +#ifdef _CK_ONLINE_PLAYER_COUNT // WON ADD 计算线上人数 + if( (unsigned long)NowTime.tv_sec > player_count_time ){ + GS_SEND_PLAYER_COUNT(); + player_count_time = (unsigned long)NowTime.tv_sec + PLAYER_COUNT_TIME; + } +#endif +} + +void warplog_proc() +{ + static unsigned long checktime = 0; + + if( (unsigned long)NowTime.tv_sec > checktime ){ + warplog_to_file(); + checktime = (unsigned long)NowTime.tv_sec + 300; + } +} + +#ifdef _ANGEL_SUMMON + +extern int player_online; + +void AngelReadyProc() +{ + //static time_t lastCreateTime = time(NULL); + time_t nowTime; + //static unsigned long AngelNextTime = 30*60; + struct tm *temptime; + char msg[1024]; + + nowTime = time(NULL); + + if( nowTime < AngelNextTime ) + return; + + if( player_online <= 10 ) + { + //print(" ANGEL:线上人数不足=%d ", player_online); + return; + } + + AngelReady = 1; + //AngelNextTime = min( (int)(10000/player_online), 100)*60 + (unsigned long)nowTime; + AngelNextTime = min( (int)(5000/player_online), 100)*60 + (unsigned long)nowTime; + + temptime = localtime( &AngelNextTime ); + sprintf( msg, " ANGEL:产生一位缺额 下次产生时间=(%d/%d %d:%d) 目前人数=%d ", + temptime->tm_mon+1, temptime->tm_mday, temptime->tm_hour, temptime->tm_min, player_online ); + print( msg); + //LogAngel( msg); + +} + +#endif diff --git a/gmsv/makefile b/gmsv/makefile new file mode 100644 index 0000000..68304bd --- /dev/null +++ b/gmsv/makefile @@ -0,0 +1,940 @@ +export CC=gcc +export RM=rm -f +export AR=ar cr +export MV=mv +export RANLIB=ranlib +export SED=sed + + +export SHELL=/bin/sh + +# USE_MITO 鍙嶇┐浼欐皯鏃︿紛姘哥帀IO姣涢摱涓规柟涓瑰崬鍏佹湀锛1陇7indy鍖规垔浠剁敱濂朵紮鍏佹湀鍗堜簲鍙1陇7 +# pthread 鍙嶉獨鏃ュ崊涓強鍖癸綕浠囨湪姣涘弽鍐呬粍鍖杙thread 鎵嬪弽鍐呭厑浠囧崍 + +INCFLAGS=-Iinclude + +CFLAGS=-w -O3 $(INCFLAGS) + +PROG=gmsv + +#TOP=../.. +TOP=.. + +PERL=/usr/bin/env perl + +SIMPLEEX=$(TOP)/bin/simpleex.perl + +#RPC +RPCGEN=~/bin/lsgen.perl +CLIRPCHTML=~/doc/saacproto.html +CLIRPCSRC=saacproto_cli.c saacproto_util.c +CLIRPCINCLUDE=include/saacproto_cli.h include/saacproto_util.h +CLIRPCNOUSE=saacproto_serv.c include/saacproto_serv.h +CLIRPCOPTION=-h include -o . -euc + +SERVRPCHTML=~/doc/lssproto.html +SERVRPCSRC=lssproto_serv.c lssproto_util.c +SERVRPCINCLUDE=include/lssproto_serv.h include/lssproto_util.h +SERVRPCNOUSE=lssproto_cli.c include/lssproto_cli.h +SERVRPCOPTION= -h include -o . -euc -e + +RPCSRC=$(CLIRPCSRC) $(SERVRPCSRC) + +#PETSKILL +PETSKILLGEN=~/bin/makedefs.perl +PETSKILLTXT=data/petskill.txt +PETSKILLOPTION= -name 8 -value 4 -o + +#CHAR_ANIM +ANIMDATAGEN=~/bin/convertStringtographicnumber.perl +ANIMDATATXT=include/anim_tbl.h +ANIMDATAFILE=char/ls2data.h + + +SUBDIR=char npc map item battle magic +LIBS=char/libchar.a npc/libnpc.a map/libmap.a\ +item/libitem.a \ +magic/libmagic.a \ +battle/libbattle.a \ + +SRC=main.c init.c configfile.c util.c net.c buf.c msignal.c link.c mclient.c \ +callfromac.c callfromcli.c object.c handletime.c function.c log.c npcserver.c \ +autil.c npcshandle.c\ +$(CLIRPCSRC) $(SERVRPCSRC) + +OBJ=$(SRC:.c=.o) + + +#LDFLAGS=-lm -lpthread +LDFLAGS=-lm + + +ifeq ($(shell uname),Linux) + LDFLAGS+= +endif +ifeq ($(shell uname),SunOS) + LDFLAGS+=-lnsl -lsocket +endif +ifeq ($(shell uname),FreeBSD) + LDFLAGS+= +endif + +all: $(PROG) + +$(PROG): genver $(RPCSRC) $(ANIMDATAFILE) $(LIBS) $(OBJ) + $(CC) $(CFLAGS) -o $(PROG) $(OBJ) $(LIBS) $(LDFLAGS) + +genver: + $(SHELL) ./genver.sh + +depend: $(RPCSRC) $(ANIMDATAFILE) + @for dir in $(SUBDIR) ; do \ + $(MAKE) -C $$dir depend;\ + done + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(CC) $(INCFLAGS) -M $(SRC) >> makefile + +clean: + @for dir in $(SUBDIR) ; do \ + $(MAKE) -C $$dir clean;\ + done + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + +distclean: + @for dir in $(SUBDIR) ; do \ + $(MAKE) -C $$dir distclean;\ + done + $(RM) $(CLIRPCSRC) + $(RM) $(CLIRPCINCLUDE) + $(RM) $(SERVRPCSRC) + $(RM) $(SERVRPCINCLUDE) + $(RM) $(ANIMDATAFILE) + $(RM) include/*~ + + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + + $(MV) Makefile Makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' Makefile.bak>Makefile + $(RM) Makefile.bak + +data: $(RPCSRC) $(ANIMDATAFILE) + +$(CLIRPCSRC): #$(RPCGEN) $(CLIRPCHTML) $(CLIRPCGEN) +# $(PERL) $(RPCGEN) $(CLIRPCOPTION) $(CLIRPCHTML) +# $(RM) $(CLIRPCNOUSE) + +$(SERVRPCSRC): #$(RPCGEN) $(SERVRPCHTML) $(SERVRPCGEN) +# $(PERL) $(RPCGEN) $(SERVRPCOPTION) $(SERVRPCHTML) +# $(RM) $(SERVRPCNOUSE) + +$(ANIMDATAFILE): #$(ANIMDATAGEN) $(ANIMDATATXT) +# $(PERL) $(ANIMDATAGEN) $(ANIMDATATXT) > $(ANIMDATAFILE) + +$(LIBS): + @target=`echo $@ | $(SED) s/\\\\/.\\*//`; \ + $(MAKE) -C $$target; + + +jpex : + $(PERL) $(SIMPLEEX) *.c */*.c | nkf -s > jp_literal.sjis + + + +# DO NOT DELETE THIS LINE +main.o: main.c include/version.h include/correct_bug.h \ + include/version_pk.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/time.h /usr/include/bits/time.h /usr/include/string.h \ + /usr/include/signal.h /usr/include/bits/sigset.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/bits/sigthread.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h include/init.h include/common.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h include/net.h \ + /usr/include/sys/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/netinet/in.h \ + /usr/include/stdint.h /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/sys/types.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h include/link.h \ + include/handletime.h include/char.h include/char_base.h include/skill.h \ + include/util.h /usr/include/stdlib.h /usr/include/alloca.h \ + include/title.h include/addressbook.h include/char_data.h \ + include/item.h include/map_warppoint.h include/npcgen.h include/log.h \ + include/configfile.h include/battle.h include/petmail.h include/autil.h \ + include/family.h include/defend.h include/trade.h include/chatroom.h \ + genver.h +init.o: init.c include/version.h include/correct_bug.h \ + include/version_pk.h /usr/include/unistd.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/typesizes.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/stdio.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/strings.h include/configfile.h include/common.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h include/net.h /usr/include/netinet/in.h \ + /usr/include/stdint.h /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + include/link.h include/msignal.h include/buf.h include/object.h \ + include/char.h include/char_base.h include/skill.h include/title.h \ + include/addressbook.h include/char_data.h include/item.h \ + include/readmap.h include/function.h include/saacproto_cli.h \ + include/saacproto_util.h /usr/include/string.h include/lssproto_serv.h \ + include/lssproto_util.h include/readnpc.h include/log.h \ + include/handletime.h include/encount.h include/enemy.h include/battle.h \ + include/magic_base.h include/pet_skill.h include/item_gen.h \ + include/petmail.h include/npc_quiz.h include/profession_skill.h \ + include/init.h +configfile.o: configfile.c include/version.h include/correct_bug.h \ + include/version_pk.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/string.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h include/util.h /usr/include/sys/time.h \ + /usr/include/time.h /usr/include/bits/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h include/common.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h include/lssproto_util.h include/configfile.h \ + include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + include/link.h include/npcutil.h include/char.h include/char_base.h \ + include/skill.h include/title.h include/addressbook.h \ + include/char_data.h include/item.h include/lssproto_serv.h \ + include/npc_raceman.h +util.o: util.c include/version.h include/correct_bug.h \ + include/version_pk.h /usr/include/sys/types.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/typesizes.h /usr/include/time.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/sys/time.h /usr/include/sys/stat.h \ + /usr/include/bits/stat.h /usr/include/netinet/in.h \ + /usr/include/stdint.h /usr/include/bits/wchar.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/string.h /usr/include/stdlib.h /usr/include/alloca.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/dirent.h /usr/include/bits/dirent.h /usr/include/netdb.h \ + /usr/include/rpc/netdb.h /usr/include/bits/netdb.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h /usr/include/ctype.h include/common.h \ + include/util.h include/configfile.h +net.o: net.c include/version.h include/correct_bug.h include/version_pk.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h /usr/include/string.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h /usr/include/netdb.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/sys/socket.h /usr/include/sys/uio.h \ + /usr/include/bits/uio.h /usr/include/sys/time.h \ + /usr/include/arpa/inet.h /usr/include/netinet/tcp.h \ + /usr/include/sys/timeb.h include/net.h include/common.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + include/link.h include/buf.h include/msignal.h include/configfile.h \ + include/util.h include/saacproto_cli.h include/saacproto_util.h \ + /usr/include/strings.h include/lssproto_serv.h include/lssproto_util.h \ + include/char.h include/char_base.h include/skill.h include/title.h \ + include/addressbook.h include/char_data.h include/item.h \ + include/handletime.h include/log.h include/object.h \ + include/item_event.h include/enemy.h include/battle.h \ + include/pet_event.h include/char_talk.h include/petmail.h \ + include/chatmagic.h +buf.o: buf.c include/version.h include/correct_bug.h include/version_pk.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h /usr/include/string.h \ + include/buf.h include/common.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h include/handletime.h /usr/include/sys/time.h +msignal.o: msignal.c include/version.h include/correct_bug.h \ + include/version_pk.h /usr/include/signal.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/include/bits/sigset.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/typesizes.h /usr/include/bits/signum.h \ + /usr/include/time.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/bits/sigthread.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/stdio.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + include/buf.h include/common.h include/net.h /usr/include/sys/time.h \ + /usr/include/bits/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/netinet/in.h \ + /usr/include/stdint.h /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/sys/types.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h include/link.h \ + include/char.h include/char_base.h include/skill.h include/util.h \ + /usr/include/stdlib.h /usr/include/alloca.h include/title.h \ + include/addressbook.h include/char_data.h include/item.h \ + include/object.h include/configfile.h include/lssproto_serv.h \ + include/lssproto_util.h /usr/include/string.h /usr/include/strings.h \ + include/saacproto_cli.h include/saacproto_util.h include/log.h \ + include/petmail.h +link.o: link.c /usr/include/stdlib.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h include/version.h \ + include/correct_bug.h include/version_pk.h include/link.h \ + include/common.h /usr/include/stdio.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h include/buf.h +mclient.o: mclient.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/string.h /usr/include/strings.h /usr/include/sys/types.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/sys/time.h /usr/include/sys/stat.h \ + /usr/include/bits/stat.h /usr/include/netinet/in.h \ + /usr/include/stdint.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/stdlib.h /usr/include/alloca.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/fcntl.h /usr/include/bits/fcntl.h \ + /usr/include/netdb.h /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h include/autil.h \ + include/version.h include/correct_bug.h include/version_pk.h \ + include/common.h include/util.h include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h include/link.h include/char.h \ + include/char_base.h include/skill.h include/title.h \ + include/addressbook.h include/char_data.h include/item.h \ + include/mclient.h include/log.h include/handletime.h \ + include/chatmagic.h +callfromac.o: callfromac.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + include/version.h include/correct_bug.h include/version_pk.h \ + include/common.h /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + include/saacproto_cli.h include/saacproto_util.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/time.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h /usr/include/string.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + include/lssproto_serv.h include/lssproto_util.h include/net.h \ + /usr/include/sys/time.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + include/link.h include/char.h include/char_base.h include/skill.h \ + include/util.h include/title.h include/addressbook.h \ + include/char_data.h include/item.h include/object.h include/readmap.h \ + include/msignal.h include/map_deal.h include/npc_duelranking.h \ + include/npc_warpman.h include/handletime.h include/npc_scheduleman.h \ + include/configfile.h include/chatroom.h include/npc_eventaction.h \ + include/family.h include/defend.h include/log.h include/buf.h \ + include/npc_alldoman.h include/npc_raceman.h +callfromcli.o: callfromcli.c include/version.h include/correct_bug.h \ + include/version_pk.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/time.h /usr/include/bits/time.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h include/common.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h include/util.h \ + /usr/include/sys/time.h include/lssproto_serv.h include/lssproto_util.h \ + /usr/include/string.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h include/saacproto_cli.h include/saacproto_util.h \ + include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + include/link.h include/char.h include/char_base.h include/skill.h \ + include/title.h include/addressbook.h include/char_data.h \ + include/item.h include/object.h include/readmap.h include/handletime.h \ + include/configfile.h include/event.h include/pet.h include/battle.h \ + include/battle_command.h include/magic.h include/petmail.h \ + include/item_gen.h include/pet_skill.h include/log.h include/map_deal.h \ + include/trade.h include/family.h include/item_event.h \ + include/profession_skill.h include/chatroom.h +object.o: object.c include/version.h include/correct_bug.h \ + include/version_pk.h /usr/include/sys/stat.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/typesizes.h /usr/include/time.h \ + /usr/include/bits/stat.h /usr/include/stdio.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/string.h /usr/include/stdlib.h /usr/include/sys/types.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h /usr/include/dirent.h \ + /usr/include/bits/dirent.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + include/common.h /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h include/object.h \ + include/char_base.h include/skill.h include/util.h \ + /usr/include/sys/time.h include/title.h include/addressbook.h \ + include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix2_lim.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h include/link.h include/char.h \ + include/char_data.h include/item.h include/buf.h include/readmap.h \ + include/pet.h +handletime.o: handletime.c include/version.h include/correct_bug.h \ + include/version_pk.h /usr/include/time.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/time.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/sys/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h include/common.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + include/handletime.h +function.o: function.c include/version.h include/correct_bug.h \ + include/version_pk.h /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + include/common.h /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h include/char_event.h include/char_base.h \ + include/skill.h include/title.h include/addressbook.h include/net.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + include/link.h include/char.h include/char_data.h include/item.h \ + include/item_event.h include/magic.h include/pet_event.h \ + include/npc_townpeople.h include/npc_Dengon.h include/npc_door.h \ + include/npc_healer.h include/npc_oldman.h include/npc_warp.h \ + include/npc_storyteller.h include/npc_msg.h include/npc_npcenemy.h \ + include/npc_action.h include/npc_windowman.h include/npc_savepoint.h \ + include/npc_windowhealer.h include/npc_itemshop.h include/npc_sysinfo.h \ + include/npc_duelranking.h include/npc_petskillshop.h \ + include/npc_petshop.h include/npc_signboard.h include/npc_warpman.h \ + include/npc_exchangeman.h include/petmail.h include/npc_timeman.h \ + include/npc_bodylan.h include/npc_mic.h include/npc_luckyman.h \ + include/npc_bus.h include/npc_charm.h include/npc_poolitemshop.h \ + include/npc_quiz.h include/npc_checkman.h include/npc_janken.h \ + include/npc_transmigration.h include/battle_event.h include/enemy.h \ + include/npc_familyman.h include/npc_bankman.h include/npc_fmdengon.h \ + include/npc_fmhealer.h include/npc_petmaker.h include/npc_fmwarpman.h \ + include/npc_fmpkman.h include/npc_fmpkcallman.h include/npc_airplane.h \ + include/npc_scheduleman.h include/npc_manorsman.h \ + include/npc_riderman.h include/npc_fmletter.h \ + include/npc_stoneserviceman.h include/npc_gamblebank.h \ + include/npc_newnpcman.h include/npc_gambleroulette.h \ + include/npc_gamblemaster.h include/npc_transerman.h \ + include/npc_freepetskillshop.h include/npc_petracemaster.h \ + include/npc_petracepet.h include/npc_itemchange.h \ + include/npc_makepair.h include/npc_petfusion.h include/npc_alldoman.h \ + include/npc_welfare.h include/npc_raceman.h +log.o: log.c include/version.h include/correct_bug.h include/version_pk.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/string.h /usr/include/time.h /usr/include/bits/time.h \ + include/common.h /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h include/util.h \ + /usr/include/sys/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h include/log.h include/handletime.h include/net.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + include/link.h include/char_base.h include/skill.h include/title.h \ + include/addressbook.h +npcserver.o: npcserver.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/strings.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/sys/time.h /usr/include/sys/stat.h \ + /usr/include/bits/stat.h /usr/include/netinet/in.h \ + /usr/include/stdint.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/stdlib.h /usr/include/alloca.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/fcntl.h /usr/include/bits/fcntl.h \ + /usr/include/netdb.h /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h include/autil.h \ + include/version.h include/correct_bug.h include/version_pk.h \ + include/common.h include/util.h include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h include/link.h include/char.h \ + include/char_base.h include/skill.h include/title.h \ + include/addressbook.h include/char_data.h include/item.h include/log.h \ + include/handletime.h include/npcserver.h include/lssproto_serv.h \ + include/lssproto_util.h /usr/include/string.h +autil.o: autil.c include/version.h include/correct_bug.h \ + include/version_pk.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h include/autil.h \ + include/common.h /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h include/char.h \ + include/char_base.h include/skill.h include/util.h \ + /usr/include/sys/time.h include/title.h include/addressbook.h \ + include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + include/link.h include/char_data.h include/item.h \ + include/lssproto_util.h /usr/include/string.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h +npcshandle.o: npcshandle.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/strings.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/sys/time.h /usr/include/sys/stat.h \ + /usr/include/bits/stat.h /usr/include/netinet/in.h \ + /usr/include/stdint.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + /usr/include/stdlib.h /usr/include/alloca.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/fcntl.h /usr/include/bits/fcntl.h \ + /usr/include/netdb.h /usr/include/rpc/netdb.h /usr/include/bits/netdb.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h include/autil.h \ + include/version.h include/correct_bug.h include/version_pk.h \ + include/common.h include/util.h include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h include/link.h include/object.h \ + include/char.h include/char_base.h include/skill.h include/title.h \ + include/addressbook.h include/char_data.h include/item.h include/log.h \ + include/handletime.h include/npcserver.h include/lssproto_serv.h \ + include/lssproto_util.h /usr/include/string.h include/npcshandle.h \ + include/npcutil.h include/npc_eventaction.h +saacproto_cli.o: saacproto_cli.c include/version.h include/correct_bug.h \ + include/version_pk.h include/saacproto_cli.h include/saacproto_util.h \ + /usr/include/stdlib.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h /usr/include/string.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/stdio.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + include/common.h /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h include/net.h \ + /usr/include/sys/time.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + include/link.h include/chatmagic.h +saacproto_util.o: saacproto_util.c include/version.h \ + include/correct_bug.h include/version_pk.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h /usr/include/string.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/strings.h include/saacproto_util.h +lssproto_serv.o: lssproto_serv.c include/version.h include/correct_bug.h \ + include/version_pk.h include/autil.h include/common.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + include/lssproto_serv.h include/lssproto_util.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/time.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h /usr/include/string.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h include/log.h \ + include/char.h include/char_base.h include/skill.h include/util.h \ + /usr/include/sys/time.h include/title.h include/addressbook.h \ + include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + include/link.h include/char_data.h include/item.h +lssproto_util.o: lssproto_util.c include/version.h include/correct_bug.h \ + include/version_pk.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h /usr/include/string.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/strings.h include/lssproto_util.h include/common.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h diff --git a/gmsv/map/makefile b/gmsv/map/makefile new file mode 100644 index 0000000..ec4526c --- /dev/null +++ b/gmsv/map/makefile @@ -0,0 +1,175 @@ +INCFLAGS=-I.. -I../include + + +CFLAGS=-w -O3 $(INCFLAGS) + +PROG=libmap.a + +SRC=readmap.c map_deal.c map_util.c map_warppoint.c +OBJ=$(SRC:.c=.o) + +ifeq (0,$(MAKELEVEL)) +CC=gcc +RM=rm -f +AR=ar cr +MV=mv +RANLIB=ranlib +SED=sed +SHELL=/bin/sh +endif + +all: $(PROG) + +$(PROG): $(OBJ) + $(RM) $(PROG) + $(AR) $(PROG) $(OBJ) + $(RANLIB) $(PROG) + +depend: + $(MV) Makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(CC) $(INCFLAGS) -M $(SRC) >> makefile + +clean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + +distclean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(RM) makefile.bak + +# DO NOT DELETE THIS LINE +readmap.o: readmap.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h /usr/include/string.h /usr/include/dirent.h \ + /usr/include/bits/dirent.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix2_lim.h \ + /usr/include/stdint.h /usr/include/bits/wordsize.h \ + /usr/include/bits/socket.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/sys/stat.h /usr/include/bits/stat.h ../include/common.h \ + ../include/object.h ../include/readmap.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/bits/time.h ../include/buf.h \ + ../include/char.h ../include/char_base.h ../include/skill.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h ../include/link.h ../include/char_data.h \ + ../include/item.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + ../include/configfile.h +map_deal.o: map_deal.c ../include/common.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/readmap.h ../include/util.h /usr/include/sys/time.h \ + /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/char.h ../include/char_base.h \ + ../include/skill.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/map_util.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/string.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/anim_tbl.h +map_util.o: map_util.c ../include/common.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char.h ../include/char_base.h ../include/skill.h \ + ../include/util.h /usr/include/sys/time.h /usr/include/time.h \ + /usr/include/bits/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/readmap.h +map_warppoint.o: map_warppoint.c ../include/common.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char.h ../include/char_base.h ../include/skill.h \ + ../include/util.h /usr/include/sys/time.h /usr/include/time.h \ + /usr/include/bits/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/readmap.h ../include/map_warppoint.h diff --git a/gmsv/map/map_deal.c b/gmsv/map/map_deal.c new file mode 100644 index 0000000..fb6b0fd --- /dev/null +++ b/gmsv/map/map_deal.c @@ -0,0 +1,318 @@ +#include "version.h" +#include "common.h" +#include "readmap.h" +#include "char.h" +#include "map_util.h" +#include "lssproto_serv.h" +#include "net.h" +#include "anim_tbl.h" + +/*#define MAPEDITORTROUBLE*/ +#define SPR_kmydamY CG_HIT_MARK_10 // anim_tbl.h 卞瓒 今木月引匹 及巨白尼弁玄 + +/*------------------------------------------------------------ + * 汹仃月井升丹井 蝇允月[平乓仿互 氏匹中月井升丹井娄醒互丐月[ + * 娄醒 + * ff int floor + * fx int x甄 + * fy int y甄 + * isfly int 氏匹中月井升丹井 + * 忒曰袄 + * 汹仃月 TRUE(1) + * 汹仃卅中 FALSE(0) + ------------------------------------------------------------*/ +BOOL MAP_walkAbleFromPoint( int ff, int fx, int fy, BOOL isfly ) +{ + int map[2]; + + if( !MAP_getTileAndObjData( ff,fx,fy, &map[0], &map[1] ) ){ + return FALSE; + } + + if( isfly ){ + int i; + for( i = 0 ; i < 2 ; i ++ ) + if( MAP_getImageInt( map[i], MAP_HAVEHEIGHT ) == TRUE ){ + return FALSE; + } + return TRUE; + }else{ + switch( MAP_getImageInt( map[1], MAP_WALKABLE ) ){ + case 0: + return FALSE; + break; + case 1: + if( MAP_getImageInt( map[0], MAP_WALKABLE ) == 1 ){ + return TRUE; + }else{ + return FALSE; + } + break; + case 2: + return TRUE; + break; + default: + return FALSE; + break; + } + } + + return FALSE; +} + + + +/*------------------------------------------------------------ + * 汹仃月井升丹井 蝇允月[ + * 娄醒 + * index int Char 匹及 Index + * ff int floor id + * fx int x甄 + * fy int y甄 + * 忒曰袄 + * 汹中化方中 TRUE(1) + * 汹中化反母丢 FALSE(0) + ------------------------------------------------------------*/ +BOOL MAP_walkAble( int index,int ff, int fx, int fy) +{ + /* 平乓仿卅日OK */ + if( CHAR_getFlg( index, CHAR_ISTRANSPARENT ) ) return TRUE; + + // Arminius 7.9 Airplane ok + if( CHAR_getInt( index, CHAR_WHICHTYPE ) == CHAR_TYPEBUS) return TRUE; + if( CHAR_getWorkInt( index, CHAR_WORKPARTYMODE) == CHAR_PARTY_CLIENT ) { + int oyaindex = CHAR_getWorkInt( index, CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX( oyaindex)) { + if (CHAR_getInt( oyaindex, CHAR_WHICHTYPE ) == CHAR_TYPEBUS) return TRUE; + } + } + + return MAP_walkAbleFromPoint( ff,fx,fy,CHAR_getFlg(index,CHAR_ISFLYING)|CHAR_getWorkInt(index,CHAR_WORKSKYWALKER) ); +} + +/*------------------------------------------------------------ + * 甄 毛隙烂仄化}公仇及左皮斥尼弁玄卞嫖今互丐月井升丹井 + * 娄醒 + * fl int 白夫失 + * x int x 甄 + * y int y 甄 + * 忒曰袄 + * 嫖今互丐月 TRUE + * 嫖今互卅中 FALSE + ------------------------------------------------------------*/ +BOOL MAP_haveHeight( int fl, int x, int y ) +{ + int map[2]; + + /* 穴永皿犯□正毛 化仁月 */ + if( !MAP_getTileAndObjData( fl,x,y, &map[0], &map[1] ) ) + return FALSE; + + return MAP_getImageInt( map[1], MAP_HAVEHEIGHT ); +} + + + +/*---------------------------------------- + * 旦 □正旦 祭烟及 凳毛允月 + * 娄醒 + * index int 平乓仿及奶件犯永弁旦 + * map int 穴永皿犯□正 + * outof BOOL 褡戈凛}转仁凛井 TRUE 卅日壬 褡戈凛匹丐月[ + * 忒曰袄 + * 由仿丢□正 祭毛仄凶 TRUE + * 由仿丢□正 祭毛仄卅井匀凶 FALSE + ----------------------------------------*/ +static BOOL MAP_changeCharStatusFromMapDataAndTime( int index, + int map, BOOL outof) +{ +#if 0 +// 旦玄□件巨奶斥匹反银歹卅中 + int i; + int offset; + BOOL change=FALSE; + static struct tagStatusInteractionOfBitAndDefine{ + int mapdataindex; + int charadataindex; + }statusInteraction[]={ + {MAP_INTOPOISON, CHAR_POISON}, + {MAP_INTOPARALYSIS, CHAR_PARALYSIS}, + {MAP_INTOSILENCE, CHAR_SLEEP}, + {MAP_INTOSTONE, CHAR_STONE}, + {MAP_INTODARKNESS, CHAR_DRUNK}, + {MAP_INTOCONFUSION, CHAR_CONFUSION}, + + {MAP_OUTOFPOISON, CHAR_POISON}, + {MAP_OUTOFPARALYSIS, CHAR_PARALYSIS}, + {MAP_OUTOFSILENCE, CHAR_SLEEP}, + {MAP_OUTOFSTONE, CHAR_STONE}, + {MAP_OUTOFDARKNESS, CHAR_DRUNK}, + {MAP_OUTOFCONFUSION, CHAR_CONFUSION}, + }; + + if( outof == FALSE )offset = 6; + else offset= 0; + for( i = 0 ; i < 6 ; i ++ ){ + int newdata; + newdata = MAP_getImageInt(map,statusInteraction[i+offset]. + mapdataindex); + if( newdata > 0 ){ + change=TRUE; + /* 旦 □正旦及涩烂 */ + CHAR_setInt( index, + statusInteraction[i+offset].charadataindex, + CHAR_getInt(index, + statusInteraction[i+offset]. + charadataindex ) + newdata ); + } + } + return change; +#else + return FALSE; +#endif +} + + +/*------------------------------------------------------------ + * Map 奶矛件玄及 pre post毛质 允月 + * 娄醒 + * index int 昙欠丹午仄化中月平乓仿及奶件犯永弁旦 + * mode BOOL TRUE及凛反}in FALSE及凛反 out 卞覆杀 + * 忒曰袄卅仄 + ------------------------------------------------------------*/ +static void MAP_dealprepostevent( int index, BOOL mode ) +{ + int map[2]; + int i; + int damaged=FALSE,statuschange=FALSE; + + if( CHAR_getFlg(index,CHAR_ISFLYING) ) + /* 氏匹月支勾卞反窒手仄卅中 */ + return; + + if( !MAP_getMapDataFromCharIndex( index , map ) ) return; + + for( i = 0 ; i < 2 ; i ++ ){ + /* damage */ + int damage; + damage = MAP_getImageInt(map[i], + mode ? MAP_INTODAMAGE : MAP_OUTOFDAMAGE); + if( damage != 0 ){ + /* 母丢□斥汹毛恳匹 蜇允月及匹 寞 木赘尹 */ + int opt[2]={SPR_kmydamY,-damage}; + damaged=TRUE; + CHAR_setInt(index, CHAR_HP, + CHAR_getInt(index,CHAR_HP) + damage ); + CHAR_complianceParameter(index); + /* 母丢□斥熬仃凶巨白尼弁玄请允 */ + CHAR_sendWatchEvent(CHAR_getWorkInt(index,CHAR_WORKOBJINDEX), + CHAR_ACTDAMAGE,opt,2,TRUE); + } + if( MAP_changeCharStatusFromMapDataAndTime( + index,map[i], mode ? TRUE : FALSE ) ) + statuschange=TRUE; + } + if( damaged ) CHAR_sendStatusString(index,"M"); + if( statuschange ){ + CHAR_sendCToArroundCharacter(index); + CHAR_sendStatusString(index,"P"); + } + +} + + +/*---------------------------------------- + * 公及正奶伙卞昙月蟆卞裟壬木月[仇仇匹公仇井日转仁午}xxx烟及 + * 仪毛 蜇允月[ + * 娄醒 + * index int 昙欠丹午仄化中月平乓仿及奶件犯永弁旦 + * flooor int 白夫失ID + * fx int x甄 + * fy int y甄 + * 忒曰袄 + * 卅仄 + ----------------------------------------*/ +void MAP_preovered( int index ) +{ + MAP_dealprepostevent( index, FALSE ); +} + +/*---------------------------------------- + * 公及正奶伙卞昙匀凶 卞裟壬木月[ + * 娄醒 + * index int 昙欠丹午仄化中月平乓仿及奶件犯永弁旦 + * 忒曰袄 + * 卅仄 + ----------------------------------------*/ +void MAP_postovered( int index ) +{ + MAP_dealprepostevent( index, TRUE ); +} + + +/*---------------------------------------- + * 平乓仿及璃曰及穴永皿毛允屯化霜月 + * 娄醒 + * fd int + * charaindex int 平乓仿及奶件犯永弁旦 + * 忒曰袄 + * 岳 TRUE(1) + * 撩 FALSE(0) + ----------------------------------------*/ +BOOL MAP_sendArroundCharNeedFD( int fd,int charaindex ) +{ + char* stringdata; + int x=CHAR_getInt(charaindex,CHAR_X); + int y=CHAR_getInt(charaindex,CHAR_Y); + int fl=CHAR_getInt(charaindex,CHAR_FLOOR); + int size=MAP_CHAR_DEFAULTSEESIZ; + RECT seekr,retr; + seekr.x = x - (int)(size/2); + seekr.y = y - (int)(size/2); + seekr.width = size; + seekr.height = size; +#if 1 +{ + int tilesum, objsum, eventsum; + stringdata = MAP_getChecksumFromRECT(fl,&seekr,&retr, &tilesum,&objsum,&eventsum); + if( stringdata == NULL ) + return FALSE; + + lssproto_MC_send(fd,fl, + retr.x, retr.y, + retr.x + retr.width, retr.y + retr.height, + tilesum, + objsum, + eventsum, + stringdata ); +} +#else + stringdata = MAP_getdataFromRECT(fl,&seekr,&retr); + if( stringdata == NULL ) + return FALSE; + + lssproto_M_send(fd,fl, + retr.x, retr.y, + retr.x + retr.width, retr.y + retr.height, + stringdata ); +#endif + return TRUE; +} + + +/*---------------------------------------- + * 穴永皿犯□正毛 月[ + * 娄醒 + * charaindex int 平乓仿及奶件犯永弁旦 + * 忒曰袄 + * 岳 TRUE(1) + * 撩 FALSE(0) + ----------------------------------------*/ +BOOL MAP_sendArroundChar(int charaindex) +{ + int fd; + fd = getfdFromCharaIndex( charaindex ); + if( fd == -1 )return FALSE; + + return MAP_sendArroundCharNeedFD(fd, charaindex); +} diff --git a/gmsv/map/map_util.c b/gmsv/map/map_util.c new file mode 100644 index 0000000..ead0a3f --- /dev/null +++ b/gmsv/map/map_util.c @@ -0,0 +1,35 @@ +#include "version.h" +#include "common.h" +#include "char.h" +#include "readmap.h" + + +#define MAP_CHARFLOOR(x) CHAR_getInt(x,CHAR_FLOOR) +#define MAP_CHARX(x) CHAR_getInt(x,CHAR_X) +#define MAP_CHARY(x) CHAR_getInt(x,CHAR_Y) + +BOOL MAP_getMapDataFromCharIndex( int index , int* map ) +{ + int mapdata[2]; + int ret; + + ret = MAP_getTileAndObjData(MAP_CHARFLOOR(index), + MAP_CHARX(index), + MAP_CHARY(index), + &mapdata[0],&mapdata[1] ); + map[0] = mapdata[0]; + map[1] = mapdata[1]; + return ret; +} + +BOOL MAP_getMapDataFromFXY( int f , int x , int y, int* map ) +{ + int mapdata[2]; + int ret; + + ret = MAP_getTileAndObjData(f,x,y,&mapdata[0],&mapdata[1] ); + map[0] = mapdata[0]; + map[1] = mapdata[1]; + return ret; +} + diff --git a/gmsv/map/map_warppoint.c b/gmsv/map/map_warppoint.c new file mode 100644 index 0000000..17228b8 --- /dev/null +++ b/gmsv/map/map_warppoint.c @@ -0,0 +1,283 @@ +#include "version.h" + +#include +#include "common.h" +#include "char.h" +#include "char_base.h" +#include "object.h" +#include "buf.h" +#include "util.h" +#include "configfile.h" +#include "readmap.h" +#include "map_warppoint.h" + +#ifdef _MAP_WARPPOINT +#define MAP_MAXWARPPOINT 5000 + +typedef struct _tagMAPwarpPoints{ + int use; + int ofloor; + int ox; + int oy; + + int floor; + int x; + int y; + int type; +}_MAPwarpPoints; + +_MAPwarpPoints *MapWarppoint; +static int MapWarpPoints=0; +char PointType[3][256]={ "NONE", "FREE", "ERROR"}; + +char Filename[256]; +int MAPPOINT_InitMapWarpPoint() +{ + MapWarppoint = ( _MAPwarpPoints *)calloc( 1, sizeof( struct _tagMAPwarpPoints)*MAP_MAXWARPPOINT); + if( MapWarppoint == NULL ) return 0; + + sprintf(Filename, "%s/mapwarp.txt", getMapdir()); + MAPPOINT_resetMapWarpPoint( 0); + return MAP_MAXWARPPOINT; +} +/* +void MAPPOINT_checkMapWarpPoint( int floor, int x, int y) +{ + OBJECT object; + + for( object = MAP_getTopObj(fl,x,y) ; object ; + object = NEXT_OBJECT(object) ){ + int o = GET_OBJINDEX(object); + if( OBJECT_getType(o) == OBJTYPE_WARPPOINT){ + if( !MAPPOINT_CHECKINDEX( OBJECT_getIndex( o)) ) continue; + if( OBJECT_getchartype( o) != event ) continue; + MAPPOINT_MapWarpHandle( charaindex, OBJECT_getIndex( o), fl, x, y ); + found = TRUE; + break; + } + +} +*/ +void MAPPOINT_resetMapWarpPoint( int flg) +{ + int i; + if( MapWarppoint == NULL ) return; + for( i=0; i= MAP_MAXWARPPOINT ) + return FALSE; + + return MapWarppoint[ ps].use; +} + +int MAPPOINT_getMPointEVType( int ps) +{ + if( !MAPPOINT_CHECKINDEX( ps) ) + return -1; + return MapWarppoint[ ps].type; +} + +int MAPPOINT_setMapWarpFrom( int ps, char *buf) +{ + char buf1[256]; + + if( MAPPOINT_CHECKINDEX( ps) ){ + print(" 放置传送点从 %s 获得!!\n", buf); + return -1; + } + + memset( buf1, 0, sizeof( buf1)); + if( getStringFromIndexWithDelim( buf, ",", 1, buf1, sizeof(buf1)) ==FALSE ) return -1;//原点 + MapWarppoint[ps].ofloor = atoi( buf1); + if( getStringFromIndexWithDelim( buf, ",", 2, buf1, sizeof(buf1)) ==FALSE ) return -1;//原点 + MapWarppoint[ps].ox = atoi( buf1); + if( getStringFromIndexWithDelim( buf, ",", 3, buf1, sizeof(buf1)) ==FALSE ) return -1;//原点 + MapWarppoint[ps].oy = atoi( buf1); + return 1; +} + +int MAPPOINT_setMapWarpGoal( int ps, char *buf) +{ + char buf1[256]; + if( MAPPOINT_CHECKINDEX( ps) ){ + print(" 放置传送点获得 :%s!!\n", buf); + return -1; + } + + memset( buf1, 0, sizeof( buf1)); + if( getStringFromIndexWithDelim( buf, ",", 1, buf1, sizeof(buf1)) ==FALSE ) return -1;//原点 + MapWarppoint[ps].floor = atoi( buf1); + if( getStringFromIndexWithDelim( buf, ",", 2, buf1, sizeof(buf1)) ==FALSE ) return -1;//原点 + MapWarppoint[ps].x = atoi( buf1); + if( getStringFromIndexWithDelim( buf, ",", 3, buf1, sizeof(buf1)) ==FALSE ) return -1;//原点 + MapWarppoint[ps].y = atoi( buf1); + return 1; +} + +int MAPPOINT_getMapWarpGoal( int ps, int ofl, int ox, int oy, int *fl, int *x, int *y) +{ + if( !MAPPOINT_CHECKINDEX( ps) ){ + print("获取传送点PS:%d 错误!!\n", ps); + return -1; + } + + if( MapWarppoint[ps].ofloor != ofl || + MapWarppoint[ps].ox != ox || MapWarppoint[ps].oy != oy ){ + print( "不正常传送点: 旧的有问题传送点 %d %d %d !!\n" , ofl,ox,oy ); + return -1; + } + //可加判断条件 + if( MAP_IsValidCoordinate( MapWarppoint[ps].floor, MapWarppoint[ps].x, MapWarppoint[ps].y)== FALSE ){ + print( "不正常传送点:有问题 %d %d %d !!\n" , + MapWarppoint[ps].floor,MapWarppoint[ps].x, MapWarppoint[ps].y ); + return -1; + } + *fl = MapWarppoint[ps].floor; + *x = MapWarppoint[ps].x; + *y = MapWarppoint[ps].y; + return 1; +} + +int MAPPOINT_loadMapWarpPoint( ) +{ + int i=0, ps=0, objtype; + FILE *fp=NULL; + char buf[256], buf1[256]; + + if( Filename == NULL ) return -1; + fp = fopen( Filename, "r"); + if( fp == NULL ){ + return 0; + } + while( fgets( buf, sizeof( buf)-1, fp) != NULL ){ + if( strstr( buf, "#") != 0 ) continue; + if( getStringFromIndexWithDelim( buf, ":", 1, buf1, sizeof(buf1)) ==FALSE ) + continue; + for( i=0; i= arraysizeof( PointType) ){ + print(" 1.map 传送点错误 %s \n", buf); + continue; + } + MapWarppoint[ps].type = i; + if( getStringFromIndexWithDelim( buf, ":", 2, buf1, sizeof(buf1)) ==FALSE ) continue; + objtype = CHAR_EVENT_WARP; + if( !strcmp( buf1, "NULL")){ + }else if( !strcmp( buf1, "M")){ + objtype = CHAR_EVENT_WARP_MORNING; + }else if( !strcmp( buf1, "N")){ + objtype = CHAR_EVENT_WARP_NIGHT; + }else if( !strcmp( buf1, "A")){ + objtype = CHAR_EVENT_WARP_NOON; + } + memset( buf1, 0, sizeof(buf1)); + if( getStringFromIndexWithDelim( buf, ":", 3, buf1, sizeof(buf1)) ==FALSE )continue; + + if( MAPPOINT_setMapWarpFrom( ps, buf1) == -1){ + print(" 2-1.map 传送点错误 %s [%s] \n", buf, buf1); + continue; + } + if( MAPPOINT_creatMapWarpObj( ps, buf1, objtype) == -1 ){ + print(" 2.map 传送点错误 %s [%s] \n", buf, buf1); + continue; + } + memset( buf1, 0, sizeof(buf1)); + if( getStringFromIndexWithDelim( buf, ":", 4, buf1, sizeof(buf1)) ==FALSE ){ + print(" 3.map 传送点错误 %s [%s] \n", buf, buf1); + continue; + } + if( MAPPOINT_setMapWarpGoal( ps, buf1) == -1 ){ + print(" 4.map 传送点错误 %s \n", buf); + continue; + } + memset( buf1, 0, sizeof(buf1)); + if( getStringFromIndexWithDelim( buf, ":", 5, buf1, sizeof(buf1)) ==FALSE ){ + print(" 5.map 传送点错误 %s [%s] \n", buf, buf1); + continue; + } + MapWarppoint[ps].use = 1; + MapWarpPoints++; + ps++; + if( ps >= MAP_MAXWARPPOINT ){ + break; + } + } + //andy_log + print("初始化 %d 地图传送点...", MapWarpPoints); + fclose( fp); + print("完成\n"); + return 1; +} + +void MAPPOINT_MapWarpHandle( int charaindex, int ps, int ofl, int ox, int oy ) +{ + int floor, x, y; + if( MAPPOINT_getMapWarpGoal( ps, ofl, ox, oy, &floor, &x, &y) == -1 ){ + //andy_log + print( "获取传送点( %d, %d,%d,%d)错误!!\n", ps, ofl, ox, oy); + return; + } + if( floor == 777 ) return; + CHAR_warpToSpecificPoint( charaindex, floor, x, y); + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE ) == CHAR_PARTY_LEADER ) { + int i; + for( i = 1; i < CHAR_PARTYMAX; i ++ ) { + int index = CHAR_getWorkInt( charaindex, i + CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX(index) ) { + CHAR_warpToSpecificPoint( index, floor, x, y); + } + } + } +} +#endif + + + diff --git a/gmsv/map/readmap.c b/gmsv/map/readmap.c new file mode 100644 index 0000000..e13d971 --- /dev/null +++ b/gmsv/map/readmap.c @@ -0,0 +1,1453 @@ +#include "version.h" +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "common.h" +#include "object.h" +#include "readmap.h" +#include "buf.h" +#include "util.h" +#include "char.h" +#include "lssproto_serv.h" +#include "configfile.h" + +#define MAP_MAGIC "LS2MAP" + +static void MAP_makeDefaultImageData( MAP_ImageData* one ) +{ + one->data[MAP_WALKABLE] = TRUE; + one->data[MAP_HAVEHEIGHT] = FALSE; + one->data[MAP_DEFENCE] = 0; + one->data[MAP_INTODAMAGE] = 0; + one->data[MAP_OUTOFDAMAGE] = 0; + + one->data[MAP_SETED_BATTLEMAP] = 0; + one->data[MAP_BATTLEMAP] = 0; + one->data[MAP_BATTLEMAP2] = 0; + one->data[MAP_BATTLEMAP3] = 0; + one->data[MAP_INTODARKNESS] = 0; + one->data[MAP_INTOCONFUSION] = 0; + + one->data[MAP_OUTOFPOISON] = 0; + one->data[MAP_OUTOFPARALYSIS] = 0; + one->data[MAP_OUTOFSILENCE] = 0; + one->data[MAP_OUTOFSTONE] = 0; + one->data[MAP_OUTOFDARKNESS] = 0; + one->data[MAP_OUTOFCONFUSION] = 0; + +} + +static int MAP_flgSet( char* string ) +{ + int tmp; + tmp = atoi(string); + if( tmp == 0 ) + return 0; + return 1; +} +typedef enum +{ + MAP_INTENTRY=0, + MAP_CHARENTRY=1, + MAP_INTFUNC=2, + MAP_CHARFUNC=3, +}MAP_DATATYPECATEGORY; +static struct MAP_itemconfentry +{ + int type; + int index; + void* func; +}MAP_confentries[MAP_DATAINT_NUM+MAP_DATACHAR_NUM]={ + {MAP_INTENTRY, MAP_WALKABLE, MAP_flgSet}, + {MAP_INTENTRY, MAP_HAVEHEIGHT, MAP_flgSet}, + {MAP_INTENTRY, MAP_DEFENCE, NULL}, + {MAP_INTENTRY, MAP_INTODAMAGE, NULL}, + {MAP_INTENTRY, MAP_OUTOFDAMAGE, NULL}, + + {MAP_INTENTRY, MAP_SETED_BATTLEMAP, NULL}, + {MAP_INTENTRY, MAP_BATTLEMAP, NULL}, + {MAP_INTENTRY, MAP_BATTLEMAP2, NULL}, + {MAP_INTENTRY, MAP_BATTLEMAP3, NULL}, + {MAP_INTENTRY, MAP_INTODARKNESS, NULL}, + {MAP_INTENTRY, MAP_INTOCONFUSION, NULL}, + + {MAP_INTENTRY, MAP_OUTOFPOISON, NULL}, + {MAP_INTENTRY, MAP_OUTOFPARALYSIS, NULL}, + {MAP_INTENTRY, MAP_OUTOFSILENCE, NULL}, + {MAP_INTENTRY, MAP_OUTOFSTONE, NULL}, + {MAP_INTENTRY, MAP_OUTOFDARKNESS, NULL}, + {MAP_INTENTRY, MAP_OUTOFCONFUSION, NULL}, + +}; + +static MAP_ImageData* MAP_imagedata; +static unsigned int MAP_imagedatanum; +static int MAP_imgfilt[65535]; + +BOOL MAP_readMapConfFile( char* filename ) +{ + FILE* file; + char line[512]; + int maximagenumber=0; + int i; + int linenum=0; + int imgdataindex=0; + + file = fopen( filename , "r" ); + if( file == NULL ){ + fprint( "无法打开文件 %s\n", filename ); + return FALSE; + } + while( fgets( line , sizeof( line ) , file ) ){ + char imgnum[16]; + BOOL ret; + int imgnumber; + deleteSequentChar( line, " \t" ); + pohcd( line, " \t" ); + dchop(line, " \t"); + + if( line[0] == '#' )continue; + if( line[0] == '\n' )continue; + chomp( line ); + ret = getStringFromIndexWithDelim( line , " " , 1 , imgnum , sizeof( imgnum ) ); + if( ret == FALSE )continue; + imgnumber = atoi(imgnum); + maximagenumber = max( maximagenumber , imgnumber ); + } + + MAP_imagedatanum = maximagenumber + 1; + MAP_imagedata=allocateMemory(sizeof(MAP_ImageData)*MAP_imagedatanum); + if( MAP_imagedata == NULL ){ + fprint("无法分配地图数据大小=%d\n",MAP_imagedatanum); + return FALSE; + } + for( i = 0; i data[MAP_confentries[i].index] + = atoi( token ); + break; + case MAP_CHARENTRY: + strcpysafe( one->string[MAP_confentries[i].index].string, + sizeof( one->string[MAP_confentries[i].index]. + string), + token); + break; + case MAP_INTFUNC: + { + int (*intfunction)(char* ); + intfunction = MAP_confentries[i].func; + one->data[MAP_confentries[i].index] + = intfunction(token); + break; + } + case MAP_CHARFUNC: + { + char* (*charfunction)(char* ); + charfunction = MAP_confentries[i].func; + + strcpysafe( one->string[MAP_confentries[i].index].string, + sizeof(one->string[MAP_confentries[i].index]. + string), + charfunction(token)); + break; + } + default: + break; + } + } + } + + fclose( file ); + return TRUE; +} + + + + + + + +#if 1 +BOOL MAP_readBattleMapConfFile( char* filename ) +{ + FILE* file; + char line[512]; + + int i, j; + int linenum=0; + int BattleMapNo[3], iRet, iWork, iPre[3],iFirst, iLast; + + file = fopen( filename , "r" ); + if( file == NULL ){ + fprint( "无法打开 %s\n", filename ); + return FALSE; + } + + BattleMapNo[0] = 0; + BattleMapNo[1] = 0; + BattleMapNo[2] = 0; + while( fgets( line , sizeof( line ) , file ) ){ + char *p; + linenum++; + + pohcd( line, " \t" ); + dchop(line, " \t"); + + if( line[0] == '#' )continue; + if( line[0] == '\n' )continue; + chomp( line ); + + if( line[0] == '$' ){ + iRet = sscanf( line+1, "%d %d %d", &iPre[0], &iPre[1], &iPre[2] ); + BattleMapNo[0] = BattleMapNo[1] = BattleMapNo[2] = iPre[0]; + if( iRet < 1 ){ + print( "!!!!!错误 无法读取战斗地图(%s)( line %d )\n", filename, linenum ); + } + for( i = 0; i < iRet; i ++ ){ + BattleMapNo[i] = iPre[i]; + if( BattleMapNo[i] < 0 ){ + print( "!!!!!错误 战斗地图号码为负值 (%s)( line %d )\n", filename, linenum ); + } + } + + continue; + + } + if( sscanf( line, "%d", &iWork ) != 1 ){ + continue; + } + if( iWork < 0 ){ + print( "!!!!!错误 金钱号码为负值 (%s)( line %d )\n", filename, linenum ); + continue; + } + iFirst = iWork; + p = strstr( line, "to" ); + if( p != NULL ){ + if( sscanf( p+2, "%d", &iWork ) != 1 ){ + iLast = iFirst; + }else{ + iLast = iWork; + } + if( iWork < 0 ){ + print( "!!!!!错误 金钱号码为负值 (%s)( line %d )\n", filename, linenum ); + continue; + } + }else{ + iLast = iFirst; + } + + for( i = iFirst; i <= iLast; i ++ ){ + if( MAP_getImageInt( i, MAP_SETED_BATTLEMAP ) > 0 ){ + print( "!!!!!错误 相同金钱重复设定了两次(%s)( line %d )(%d)(%d & %d)\n", + filename, linenum, i, + MAP_getImageInt( i, MAP_BATTLEMAP ), + BattleMapNo[0] ); + } + + // 飓 寞恳仄中井" + if( IsValidImagenumber( i ) == FALSE ){ + continue; + } + MAP_setImageInt( i, MAP_BATTLEMAP, BattleMapNo[0] ); + MAP_setImageInt( i, MAP_BATTLEMAP2, BattleMapNo[1] ); + MAP_setImageInt( i, MAP_BATTLEMAP3, BattleMapNo[2] ); + MAP_setImageInt( i, MAP_SETED_BATTLEMAP, 1 ); + } + + } + fclose( file ); + + for( j = 0; j < arraysizeof( MAP_imgfilt ); j ++ ){ + if( MAP_imgfilt[j] == -1 )continue; + if( MAP_getImageInt( j, MAP_SETED_BATTLEMAP ) == 0 ){ + print( "!!!!!错误 金钱(%d)尚未设定 (%s)\n", j, filename ); + } + } + return TRUE; +} +#endif + +BOOL IsValidImagenumber( int imagenumber ) +{ + if( imagenumber < 0 || imagenumber >= arraysizeof( MAP_imgfilt ) ) + return FALSE; + + if( MAP_imgfilt[imagenumber] == -1 ) + return FALSE; + return TRUE; +} + +int MAP_getImageInt( int imagenumber, int element ) +{ + if( imagenumber < 0 || imagenumber >= arraysizeof( MAP_imgfilt )) + return FALSE; + + if( MAP_imgfilt[imagenumber] == -1 )return FALSE; + return MAP_imagedata[MAP_imgfilt[imagenumber]].data[element]; +} + +BOOL MAP_setImageInt( int imagenumber, int element, int value ) +{ + if( imagenumber < 0 || imagenumber >= arraysizeof( MAP_imgfilt )) + return FALSE; + + if( MAP_imgfilt[imagenumber] == -1 )return FALSE; + MAP_imagedata[MAP_imgfilt[imagenumber]].data[element] = value; + + return TRUE; +} + +static MAP_Map* MAP_map; +static unsigned int MAP_mapnum; +static unsigned int MAP_mapnum_index; + + +static int* MAP_idjumptbl; +static int MAP_idtblsize; + +BOOL MAP_initMapArray( int num ) +{ + MAP_mapnum = num ; + + MAP_map = allocateMemory( sizeof( MAP_Map ) * MAP_mapnum ); + if( MAP_map == NULL )return FALSE; + + MAP_mapnum_index = 0; + + return TRUE; +} + +void MAP_endMapArray( void ) +{ + int i; + for( i = 0 ; i < MAP_mapnum ; i ++ ){ + if( MAP_map[i].tile != NULL ) + freeMemory( MAP_map[i].tile ); + + if( MAP_map[i].obj != NULL) + freeMemory( MAP_map[i].obj ); + + } + MAP_mapnum = 0; + MAP_mapnum_index = 0; + freeMemory( MAP_map ); + MAP_map = NULL; +} + +static BOOL MAP_IsMapFile( char* filename ) +{ + FILE* f; + char buf[16]; + int ret; + + f = fopen(filename, "r"); + if( f == NULL ){ + errorprint; + return FALSE; + } + + ret = fread( buf , sizeof( char ) , 6 , f); + if( ret != 6 ) + goto FCLOSERETURNFALSE; + buf[ret] = '\0'; + + if( strcmp( buf , MAP_MAGIC ) != 0 ) + goto FCLOSERETURNFALSE; + else + goto FCLOSERETURNTRUE; + +FCLOSERETURNFALSE: + fclose(f); + return FALSE; +FCLOSERETURNTRUE: + fclose(f); + return TRUE; +} + +static BOOL MAP_readMapOne( char* filename ) +{ + FILE* f; /* 白央奶伙 */ + char buf[16]; /* 穴斥永弁瓜件田□ 心迕 */ + short data[1024]; /* 扑亦□玄 心迕田永白央 */ + int ret; /* 忒曰袄熬仃潸曰迕 */ + int i; /* 伙□皿 醒 */ + int mapindex; + + int id=0,xsiz=0,ysiz=0; /* 穴永皿犯□正及域凛伞 桦赭 */ + + short *tile=NULL; + short *obj=NULL; + MAP_Objlink** olink=NULL; + char showstring[32]; /* 穴永皿犯□正及域凛伞 桦赭 */ + struct stat filestat; /* 民尼永弁迕卞银丹 */ + BOOL invaliddata=FALSE; + if( MAP_mapnum_index >= MAP_mapnum ){ + fprint( "这里没有足够空间装载地图数组.\n" ); + return FALSE; + } + mapindex=MAP_mapnum_index; + f = fopen(filename, "r"); + if( f == NULL ){ + errorprint; + return FALSE; + } + if( fstat( fileno(f) , &filestat ) != 0 ){ + errorprint; + goto FCLOSERETURNFALSE; + } + + ret = fread( buf , sizeof( char ) , 6 , f); + if( ret != 6 ){ + errorprint; + goto FCLOSERETURNFALSE; + } + buf[ret] = '\0'; + + if( strcmp( buf , MAP_MAGIC ) != 0 ) + goto FCLOSERETURNFALSE; + ret = fread( data , sizeof( short ) , 1 , f); + if( ret != 1 ){ + errorprint; + goto FCLOSERETURNFALSE; + } + id = ntohs( data[0] ); + + ret = fread( showstring , sizeof(char), arraysizeof(showstring), f); + if( ret != arraysizeof(showstring) ){ + errorprint; + goto FCLOSERETURNFALSE; + } + showstring[arraysizeof(showstring)-1] = '\0'; + ret = fread( data, sizeof( short ) , 1 , f); + if( ret != 1 ){ + errorprint; + goto FCLOSERETURNFALSE; + } + xsiz = ntohs( data[0] ); + ret = fread( data, sizeof( short ) , 1 , f); + if( ret != 1 ){ + errorprint; + goto FCLOSERETURNFALSE; + } + ysiz = ntohs( data[0] ); + tile = allocateMemory( sizeof( short ) * xsiz * ysiz ); + if( tile == NULL ){ + fprint( "无法分配内存给头衔名称:%s xsiz:%d ysiz:%d\n", filename, xsiz, ysiz); + goto FREEOBJHP; + } + + obj = allocateMemory( sizeof( short ) * xsiz * ysiz ); + if( obj == NULL ){ + fprint( "无法分配内存给对象\n"); + goto FREETILE; + } + + olink = allocateMemory( sizeof(MAP_Objlink*) * xsiz * ysiz ); + if( olink == NULL ){ + fprint( "无法分配内存给链接\n"); + goto FREEOBJ; + } + + ret = fread( tile , sizeof( short )*xsiz*ysiz,1,f ); + if( ret != 1 ){ + errorprint; + goto FREELINK; + } + for( i = 0 ; i < xsiz * ysiz ; i ++ ) + tile[i] = ntohs( tile[i] ); + for( i = 0 ; i < xsiz * ysiz ; i ++ ){ + if( !IsValidImagenumber( tile[i] ) ){ + fprint( + "地图的图片有问题:%d x:%d y:%d 数量:%d\n", + id, i % xsiz, (int)(i / xsiz) , tile[i]); + invaliddata = TRUE; + } + } + ret = fread( obj , sizeof( short )*xsiz*ysiz,1,f ); + if( ret != 1 ){ + errorprint; + goto FREELINK; + } + for( i = 0 ; i < xsiz * ysiz ; i ++ ) + obj[i] = ntohs( obj[i] ); + for( i = 0 ; i < xsiz * ysiz ; i ++ ){ + if( !IsValidImagenumber( obj[i] ) ){ + fprint( + "地图的图片有问题:%d x:%d y:%d 数量:%d\n", + id, i % xsiz, (int)(i / xsiz) , obj[i]); + invaliddata = TRUE; + } + } + if( invaliddata )goto FREELINK; + if( ftell(f) != filestat.st_size) + fprintf(stderr,"文件大小不正确(%s). 目标文件大小:%" +#ifdef linux + "l" +#elif __FreeBSD__ + "ll" +#endif + "d 实际大小:%ld\n", + filename, filestat.st_size,ftell(f)); + + for( i=0 ; i< xsiz*ysiz ; i ++ ) + olink[i] = NULL; + + MAP_map[mapindex].id = id; + MAP_map[mapindex].xsiz = xsiz; + MAP_map[mapindex].ysiz = ysiz; + strcpysafe( MAP_map[mapindex].string , + sizeof(MAP_map[mapindex].string), + showstring ); + MAP_map[mapindex].tile = tile; + MAP_map[mapindex].obj = obj; + MAP_map[mapindex].olink = olink; +#ifdef _MAP_NOEXIT + { + FILE *fp; + char mpexit[128]; + int floorID=0,exfloor=0,ex_X=0,ex_Y=0; + int map_type=0; + MAP_map[mapindex].startpoint = 0; + fp = fopen( "./data/map/map_noexit.txt","r"); + if( fp != NULL ){ + while( fgets(mpexit, 128, fp) != NULL ) { + sscanf( mpexit,"%d %d %d %d %d", &floorID, &exfloor, &ex_X, &ex_Y, &map_type); + if( strstr( mpexit, "#" ) != NULL) + continue; + if( floorID == id) { + MAP_map[mapindex].startpoint = (exfloor<<16)+(ex_X << 8)+(ex_Y<<0); + MAP_map[mapindex].MapType = map_type; + } + } + // Nuke 1204: Bug fix + fclose(fp); + }else { + print("\n **错误** 找不到 map_noexit.txt 文件!!!"); + } + } +#endif + goto FCLOSERETURNTRUE; + +FCLOSERETURNTRUE: + MAP_mapnum_index++; + fclose(f); + return TRUE; + +FREELINK: + freeMemory( olink ); +FREEOBJ: + freeMemory( obj ); +FREETILE: + freeMemory( tile ); +FREEOBJHP: +FCLOSERETURNFALSE: + fclose(f); + return FALSE; +} +#ifdef _MAP_NOEXIT +unsigned int MAP_getExFloor_XY( int floor, int *map_type) +{ + int i; + int exfloor; + for( i=0; i 0 ) { + exfloor = (MAP_map[i].startpoint>>16)&0xffffff; + if( exfloor >= 0 ) { + *map_type = MAP_map[i].MapType; + return MAP_map[i].startpoint ; + } + } + } + } + return 0; +} +BOOL CHECKFLOORID( id) +{ + int i; + + if( id < 0 ) + return FALSE; + + for( i=0; i MAP_getfloorX(mapid) || + y < 0 || y > MAP_getfloorY(mapid)) + return FALSE; + + return TRUE; +} + +#define MAP_GETMAXSIZE 45 +static char MAP_dataString[STRINGBUFSIZ*3]; +static int MAP_workdatabuffer[MAP_GETMAXSIZE*MAP_GETMAXSIZE]; +#define MAP_DATADELIMITER "," + +char* MAP_getdataFromRECT( int floor, RECT* seekr, RECT* realr ) +{ + int floorindex; + int stringlength=0; + char tmpbuffer[128]; + int i,j; + int floorx; + int databufferindex=0; + RECT scr; + char escapebuffer[128]; + + floorindex = MAP_getfloorIndex( floor ); + if( floorindex == -1 ) { + print( "%s:%d:err\n", __FILE__, __LINE__); + return NULL; + } + if( seekr->width < 0 || seekr->height < 0 || + MAP_GETMAXSIZE < seekr->width || MAP_GETMAXSIZE < seekr->height ){ + print( "%s:%d:err\n", __FILE__, __LINE__); + return NULL; + } + snprintf( tmpbuffer,sizeof(tmpbuffer), + "%s|" , + makeEscapeString( MAP_map[floorindex].string, + escapebuffer,sizeof(escapebuffer))); + + strcpysafe( MAP_dataString, sizeof( MAP_dataString ), tmpbuffer ); + stringlength = strlen( tmpbuffer ); + + floorx = MAP_map[floorindex].xsiz; + scr.x = 0; + scr.y = 0; + scr.width = floorx; + scr.height= MAP_map[floorindex].ysiz; + + if( clipRect( seekr,&scr,realr ) == FALSE ){ + realr->x=realr->y=realr->width=realr->height=0; + return MAP_dataString; + } + for( i = realr->y ; i < realr->y + realr->height ; i ++ ){ + for( j = realr->x ; j < realr->x + realr->width ; j ++ ){ + MAP_workdatabuffer[databufferindex++] + = MAP_map[floorindex].tile[i*floorx+j]; + } + } + for( i = 0 ; i < databufferindex ; i ++ ){ + char buf[64]; + snprintf( tmpbuffer,sizeof(tmpbuffer),"%s" MAP_DATADELIMITER , + cnv10to62( MAP_workdatabuffer[i], buf, sizeof( buf)) ); + strcpysafe( &MAP_dataString[stringlength] , + sizeof( MAP_dataString ) - stringlength, + tmpbuffer ); + stringlength += strlen( tmpbuffer ); + } + if( stringlength < sizeof( MAP_dataString ) ) + MAP_dataString[stringlength-1] = NONCHAR_DELIMITER[0]; + databufferindex=0; + for( i = realr->y ; i < realr->y + realr->height ; i ++ ){ + for( j = realr->x ; j < realr->x + realr->width ; j ++ ){ + MAP_workdatabuffer[databufferindex++] + = MAP_map[floorindex].obj[i*floorx+j]; + } + } + for( i = 0 ; i < databufferindex ; i ++ ){ + char buf[64]; + if( MAP_workdatabuffer[i] == 0 ) buf[0] = '\0'; + else cnv10to62( MAP_workdatabuffer[i], buf, sizeof( buf)); + snprintf( tmpbuffer,sizeof(tmpbuffer),"%s" MAP_DATADELIMITER , + buf ); + strcpysafe( &MAP_dataString[stringlength] , + sizeof( MAP_dataString ) - stringlength, + tmpbuffer ); + stringlength += strlen( tmpbuffer ); + } + + if( stringlength < sizeof( MAP_dataString ) ) + MAP_dataString[stringlength-1] = NONCHAR_DELIMITER[0]; + + databufferindex=0; + for( i = realr->y ; i < realr->y + realr->height ; i ++ ){ + for( j = realr->x ; j < realr->x + realr->width ; j ++ ){ + OBJECT object; + BOOL found = FALSE; + for( object = MAP_getTopObj(floor,j,i) ; object ; + object = NEXT_OBJECT(object) ){ + int o = GET_OBJINDEX(object); + if( OBJECT_getType(o) == OBJTYPE_CHARA ){ + int etype; + int charaindex=OBJECT_getIndex(o); + if( !CHAR_CHECKINDEX(charaindex) )continue; + etype = CHAR_getWorkInt( charaindex, CHAR_WORKEVENTTYPE); + if( etype != CHAR_EVENT_NONE ) { + MAP_workdatabuffer[databufferindex++] = etype; + found = TRUE; + break; + } + } +#ifdef _MAP_WARPPOINT + else if( OBJECT_getType(o) == OBJTYPE_WARPPOINT ){ + int etype = OBJECT_getchartype( o); + if( etype != CHAR_EVENT_NONE ) { + MAP_workdatabuffer[databufferindex++] = (unsigned short)etype; + found = TRUE; + break; + } + } +#endif + } + if( !found ) { + MAP_workdatabuffer[databufferindex++] + = CHAR_EVENT_NONE; + } + } + } + for( i = 0 ; i < databufferindex ; i ++ ){ + char buf[64]; + if( MAP_workdatabuffer[i] == 0 ) buf[0] = '\0'; + else cnv10to62( MAP_workdatabuffer[i], buf, sizeof( buf)); + + snprintf( tmpbuffer,sizeof(tmpbuffer),"%s" MAP_DATADELIMITER, buf); + strcpysafe( &MAP_dataString[stringlength] , + sizeof( MAP_dataString ) - stringlength, tmpbuffer ); + stringlength += strlen( tmpbuffer ); + } + dchop( MAP_dataString, MAP_DATADELIMITER ); + return MAP_dataString; +} + +char *MAP_getChecksumFromRECT( int floor, RECT* seekr, RECT* realr, + int *tilesum, int *objsum, int *eventsum ) +{ + int floorindex; + int i,j; + int floorx; + int databufferindex=0; + RECT scr; + char escapebuffer[128]; + unsigned short eventbuf[MAP_CHAR_DEFAULTSEESIZ * MAP_CHAR_DEFAULTSEESIZ]; + unsigned short tilebuf[ MAP_CHAR_DEFAULTSEESIZ * MAP_CHAR_DEFAULTSEESIZ]; + unsigned short objbuf[ MAP_CHAR_DEFAULTSEESIZ * MAP_CHAR_DEFAULTSEESIZ]; + + floorindex = MAP_getfloorIndex( floor ); + if( floorindex == -1 ) return NULL; + if( seekr->width < 0 || seekr->height < 0 || + MAP_GETMAXSIZE < seekr->width || MAP_GETMAXSIZE < seekr->height ) + return NULL; + + strcpysafe( MAP_dataString, sizeof( MAP_dataString ), + makeEscapeString( MAP_map[floorindex].string, + escapebuffer,sizeof(escapebuffer))); + + floorx = MAP_map[floorindex].xsiz; + scr.x = 0; + scr.y = 0; + scr.width = floorx; + scr.height= MAP_map[floorindex].ysiz; + + if( clipRect( seekr,&scr,realr ) == FALSE ){ + realr->x=realr->y=realr->width=realr->height=0; + return MAP_dataString; + } + + *tilesum = 0; + *objsum =0; + *eventsum = 0; + memset( tilebuf, 0, sizeof( tilebuf)); + memset( objbuf, 0, sizeof( objbuf)); + memset( eventbuf, 0, sizeof( eventbuf)); + for( i = realr->y ; i < realr->y + realr->height ; i ++ ){ + for( j = realr->x ; j < realr->x + realr->width ; j ++ ){ + OBJECT object; + //BOOL found = FALSE; + for( object = MAP_getTopObj(floor,j,i) ; object ; + object = NEXT_OBJECT(object) ){ + int o = GET_OBJINDEX(object); + if( OBJECT_getType(o) == OBJTYPE_CHARA ){ + int etype; + int charaindex=OBJECT_getIndex(o); + if( !CHAR_CHECKINDEX(charaindex) )continue; + etype = CHAR_getWorkInt( charaindex, CHAR_WORKEVENTTYPE); + if( etype != CHAR_EVENT_NONE ) { + eventbuf[databufferindex] = (unsigned short)etype; + break; + } + } +#ifdef _MAP_WARPPOINT + else if( OBJECT_getType(o) == OBJTYPE_WARPPOINT ){ + int etype = OBJECT_getchartype( o); + if( etype != CHAR_EVENT_NONE ) { + eventbuf[databufferindex] = (unsigned short)etype; + break; + } + } +#endif + } + tilebuf[databufferindex] = (unsigned short)MAP_map[floorindex].tile[i*floorx+j]; + objbuf[databufferindex] = (unsigned short)MAP_map[floorindex].obj[i*floorx+j]; + databufferindex++; + } + } + *tilesum = CheckCRC( (unsigned char*)tilebuf, sizeof( tilebuf)); + *objsum = CheckCRC( (unsigned char*)objbuf, sizeof( objbuf)); + *eventsum = CheckCRC( (unsigned char*)eventbuf, sizeof( eventbuf)); + + return MAP_dataString; +} + +BOOL MAP_getTileAndObjData( int ff ,int fx, int fy, int* tile, int* obj) +{ + int floorindex,xsiz; + floorindex = MAP_getfloorIndex( ff ); + if( floorindex == -1 ) { + print( "%s:%d:err\n", __FILE__, __LINE__); + return FALSE; + } + xsiz = MAP_map[floorindex].xsiz; + + if( fx < 0 || fx >= xsiz ) { + return FALSE; + } + if( fy < 0 || fy >= MAP_map[floorindex].ysiz ) { + return FALSE; + } + + if( tile ) + *tile = MAP_map[floorindex].tile[fy*xsiz+fx]; + if( obj ) + *obj = MAP_map[floorindex].obj[fy*xsiz+fx]; + + return TRUE; +} + +BOOL MAP_setTileAndObjData( int ff ,int fx, int fy, int tile, int obj) +{ + int floorindex,xsiz; + floorindex = MAP_getfloorIndex( ff ); + if( floorindex == -1 ) { + print( "%s:%d:err\n", __FILE__, __LINE__); + return FALSE; + } + xsiz = MAP_map[floorindex].xsiz; + if( fx < 0 || fx >= xsiz ) { + return FALSE; + } + if( fy < 0 || fy >= MAP_map[floorindex].ysiz ) { + return FALSE; + } + if( tile != -1 ) + MAP_map[floorindex].tile[fy*xsiz+fx] = tile; + if( obj != -1) + MAP_map[floorindex].obj[fy*xsiz+fx] = obj; + return TRUE; +} + +BOOL MAP_initReadMap( char* maptilefile , char* mapdir ) +{ + print("\n"); + if( !MAP_readMapConfFile(maptilefile) ) + return FALSE; + if( !MAP_readBattleMapConfFile( getBattleMapfile( ) ) ) + return FALSE; + if( !MAP_readMapDir(mapdir) ) + return FALSE; + return TRUE; +} + +static int MAP_coKindAndInt[MAP_KINDNUM]= +{ + MAP_WALKABLE, +}; + +BOOL MAP_makeVariousMap(char* atile, char* aobj, int floor, int startx, + int starty, int xsiz, int ysiz, MAP_kind kind ) +{ + int i,j; + int findex; + int fxsiz; + int startpoint; + + if( atile == NULL || aobj == NULL || kind < 0 || kind >= MAP_KINDNUM ) { + print( "%s:%d:err\n", __FILE__, __LINE__); + return FALSE; + } + findex = MAP_getfloorIndex( floor ); + if( findex == -1 ) { + print( "%s:%d:err\n", __FILE__, __LINE__); + return FALSE; + } + fxsiz = MAP_map[findex].xsiz; + startpoint = startx + starty * fxsiz ; + + for( i = 0 ; i < ysiz ; i ++ ){ + for( j = 0 ; j < xsiz ; j ++ ){ + atile[i*xsiz+j] = MAP_getImageInt( MAP_map[findex].tile[ + startpoint + i*xsiz + j],MAP_coKindAndInt[kind] ) + ? 1 : 0; + + aobj[i*xsiz+j] = MAP_getImageInt( MAP_map[findex].obj[ + startpoint + i*xsiz + j],MAP_coKindAndInt[kind] ) + ? 1 : 0; + } + } + return TRUE; +} + +BOOL MAP_makeWalkableMap( char* data, int floor, int startx, int starty, + int xsiz, int ysiz ) +{ + int i,j; + char* obj; + obj = allocateMemory(xsiz*ysiz*sizeof(char)); + if( obj == NULL )return FALSE; + + if( MAP_makeVariousMap( data, obj, floor, startx, starty, xsiz, ysiz, + MAP_KINDWALKABLE ) == FALSE ){ + freeMemory( obj ); + return FALSE; + } + + for( i = 0 ; i < ysiz ; i ++ ) + for( j = 0 ; j < xsiz ; j ++ ) + data[j+i*ysiz] = data[j+i*ysiz] & obj[j+i*ysiz]; + +#ifdef DEBUG + for( i = 0 ; i < ysiz ; i ++ ){ + for( j = 0 ; j < xsiz ; j ++ ) + if( data[j+i*ysiz] ){ + print(" "); + }else + print("O"); + print("\n"); + } +#endif /*DEBUG*/ + + return TRUE; +} + +BOOL MAP_IsThereSpecificFloorid( int floorid ) +{ + if( MAP_getfloorIndex(floorid)== -1)return FALSE; + else return TRUE; +} + +BOOL MAP_IsValidCoordinate( int floor, int x, int y ) +{ + if( MAP_IsThereSpecificFloorid(floor)==FALSE )return FALSE; + if( x < 0 || MAP_getfloorX(floor)<=x )return FALSE; + if( y < 0 || MAP_getfloorY(floor)<=y )return FALSE; + return TRUE; +} + +int MAP_attackSpecificPoint( int floor, int x, int y, int damage , + int charaindex ) +{ +#if 0 + int mapindex; + int xsiz; + int objimagenumber; + + mapindex = MAP_getfloorIndex(floor); + if( mapindex == -1 ) { + print( "%s:%d:err\n", __FILE__, __LINE__); + return 5; + } + xsiz = MAP_map[mapindex].xsiz; + if( 0 > x || x >= xsiz || 0 >y || y >= MAP_map[mapindex].ysiz ) { + print( "%s:%d:err\n", __FILE__, __LINE__); + return 5; + } + if( damage <= 0 )return 5; + + objimagenumber = MAP_map[mapindex].obj[x+y*xsiz]; + + if( MAP_getImageInt( objimagenumber,MAP_DEFENCE ) > 0 ){ + MAP_map[mapindex].objhp[x+y*xsiz] -= damage; + if( MAP_map[mapindex].objhp[x+y*xsiz] < 0 ){ + MAP_map[mapindex].obj[x+y*xsiz] = 0; +#if 1 + { + char *stringdata; + RECT seekr , retr; + seekr.x = x; + seekr.y = y; + seekr.width = 1; + seekr.height = 1; + stringdata = MAP_getdataFromRECT(floor,&seekr,&retr); + if( stringdata ){ + print("RINGO: RETR: %d %d %d %d\n", + retr.x,retr.y,retr.width,retr.height); + if( CHAR_getInt( charaindex , CHAR_WHICHTYPE ) + == CHAR_TYPEPLAYER ){ + int fd = getfdFromCharaIndex( charaindex ); + lssproto_M_send(fd,floor, retr.x, retr.y, + retr.x + retr.width, retr.y + retr.height, + stringdata ); + } + } else { + print("RINGO: bad stringdata. %d %d %d %d\n", + seekr.x,seekr.y,seekr.width,seekr.height); + + } + + } +#endif + return 1; + } + return 2; + } + + if( MAP_getImageInt(MAP_map[mapindex].obj[y*xsiz+x],MAP_HAVEHEIGHT ) + == 0 ) + return 4; +#endif + return 3; +} + +BOOL MAP_appendTailObj( int floor, int x, int y, int objindex ) +{ + int mapindex; + int xsiz; + int dataindex; + MAP_Objlink* c; + MAP_Objlink* top; + + mapindex = MAP_getfloorIndex( floor ); + if( mapindex == -1 ) { + //print( "%s:%d:err(fl=%d,x=%d,y=%d)\n", __FILE__, __LINE__, floor, x, y ); + return FALSE; + } + xsiz = MAP_map[mapindex].xsiz; + if( 0 > x || x >= xsiz || 0 >y || y >= MAP_map[mapindex].ysiz ) { + //print( "%s:%d:err(fl=%d,x=%d,y=%d)\n", __FILE__, __LINE__, floor, x, y); + return FALSE; + } + dataindex = y*xsiz+x; + top = MAP_map[mapindex].olink[dataindex]; + if( top == NULL ){ + top = allocateMemory( sizeof(MAP_Objlink) ); + if( top == NULL ) { + //print( "%s:%d:err(fl=%d,x=%d,y=%d)\n", __FILE__, __LINE__, floor, x, y); + return FALSE; + } + top->next = NULL; + top->objindex = objindex; + MAP_map[mapindex].olink[dataindex] = top; + return TRUE; + } + for( c=top ; c->next ; c = c->next ); + c->next = allocateMemory(sizeof(MAP_Objlink)); + if( c->next == NULL )return FALSE; + c->next->next = NULL; + c->next->objindex = objindex; + return TRUE; +} + +BOOL MAP_removeObj( int floor, int x, int y, int objindex ) +{ + int mapindex; + int xsiz; + int dataindex; + MAP_Objlink* c; + MAP_Objlink* last=NULL; + + mapindex = MAP_getfloorIndex( floor ); + if( mapindex == -1 ) { + print( "%s:%d:错误\n", __FILE__, __LINE__); + return FALSE; + } + xsiz = MAP_map[mapindex].xsiz; + if( 0 > x || x >= xsiz || 0 >y || y >= MAP_map[mapindex].ysiz ) { + print( "%s:%d:错误 地图号[%d] x:[%d] y:[%d]\n", __FILE__, __LINE__, floor, x, y); + return FALSE; + } + dataindex = y*xsiz+x; + c = MAP_map[mapindex].olink[dataindex]; + while( c ){ + if( c->objindex == objindex ){ + if( last ) + last->next = c->next; + else + MAP_map[mapindex].olink[dataindex] = c->next; + freeMemory( c ); + return TRUE; + } + last = c; + c = c->next; + } + print( "%s:%d:错误\n", __FILE__, __LINE__); + return FALSE; +} + +BOOL _MAP_objmove( char *file, int line, int objindex, int ofloor, int ox, int oy, int nfloor, + int nx, int ny ) +{ +#if 1 + + int oldmapindex; + int oldxsiz; + + int dataindex; + MAP_Objlink* c; + MAP_Objlink* last=NULL; + MAP_Objlink* pointer=NULL; + + oldmapindex = MAP_getfloorIndex( ofloor ); + if( oldmapindex == -1 ) { + print( "%s:%d:错误 地图号[%d] x:[%d] y:[%d]\n", __FILE__, __LINE__, + ofloor, ox, oy); + return FALSE; + } + oldxsiz = MAP_map[oldmapindex].xsiz; + if( 0 > ox || ox >= oldxsiz + || 0 >oy || oy >= MAP_map[oldmapindex].ysiz ) + { + print( "%s:%d:错误 地图号[%d] x:[%d] y:[%d]\n", __FILE__, __LINE__, + ofloor, ox, oy); + return FALSE; + } + dataindex = oy*oldxsiz+ox; + c = MAP_map[oldmapindex].olink[dataindex]; + while( c ){ + if( c->objindex == objindex ){ + if( last ) + last->next = c->next; + else + MAP_map[oldmapindex].olink[dataindex] = c->next; + + pointer = c; + pointer->next = NULL; + break; + } + last = c; + c = c->next; + } + if( !pointer ) { + print( "\n%s:%d:错误( %d,%d,%d )->(%d,%d,%d)\n", __FILE__, __LINE__, + ofloor, ox, oy, nfloor, nx, ny ); + return FALSE; + } + { + int newmapindex; + int newxsiz; + MAP_Objlink* top; + + if( ofloor == nfloor ){ + newmapindex = oldmapindex; + newxsiz = oldxsiz; + }else{ + newmapindex = MAP_getfloorIndex( nfloor ); + if( newmapindex == -1 ) { + print( "%s:%d:错误 地图号[%d] x:[%d] y:[%d]\n", __FILE__, __LINE__, + nfloor, nx, ny); + return FALSE; + } + newxsiz = MAP_map[newmapindex].xsiz; + } + if( 0 > nx || nx >= newxsiz + || 0 >ny || ny >= MAP_map[newmapindex].ysiz ) + { + print( "%s:%d:错误 地图号[%d] x:[%d] y:[%d]\n", __FILE__, __LINE__, + nfloor, nx, ny); + return FALSE; + } + + dataindex = ny*newxsiz+nx; + top = MAP_map[newmapindex].olink[dataindex]; + if( top == NULL ){ + top = MAP_map[newmapindex].olink[dataindex] = pointer; + top->next = NULL; + return TRUE; + } + + for( c=top ; c->next ; c = c->next ); + c->next = pointer; + c->next->next = NULL; + return TRUE; + } +#else + if( MAP_removeObj( ofloor,ox,oy,objindex) + && MAP_appendTailObj( nfloor, nx ,ny, objindex ) ) + return TRUE; +#endif + print( "%s:%d:错误\n", __FILE__, __LINE__); + return FALSE; +} + +MAP_Objlink* _MAP_getTopObj( char *file, int line,int floor, int x, int y ) +{ + int mapindex; + int xsiz; + + mapindex = MAP_getfloorIndex( floor ); + if( mapindex == -1 ) { + //print( "callfrom[%s:%d] %s:%d:err floor(%d,%d,%d)\n", file, line, __FILE__, __LINE__, + // floor, x, y ); + return NULL; + } + + xsiz = MAP_map[mapindex].xsiz; + +#if 1 + if( x >= xsiz) return NULL; + if( y >= MAP_map[mapindex].ysiz ) return NULL; + if( x < 0 ) return NULL; + if( y < 0 ) return NULL; + return MAP_map[mapindex].olink[y*xsiz+x]; +#else + if( 0 <= x && x < xsiz && 0 <= y && y < MAP_map[mapindex].ysiz ) + return MAP_map[mapindex].olink[y*xsiz+x]; + else + return NULL; +#endif +} + +BOOL MAP_addNewObj( int floor, int x, int y, int objindex ) +{ + OBJECT map; + BOOL ret; + + for( map=MAP_getTopObj(floor,x,y) ; map ; map = NEXT_OBJECT(map)) { + if( GET_OBJINDEX(map) == objindex ) { + print( "%s:%d:err\n", __FILE__, __LINE__); + return 0; + } + } + ret = MAP_appendTailObj( floor, x, y, objindex ); + if( ret )return 1; + else return -1; +} + +char *MAP_getFloorName( int floor) +{ + int floorindex; + floorindex = MAP_getfloorIndex( floor ); + if( floorindex == -1 ) { + print( "%s:%d:err\n", __FILE__, __LINE__); + return NULL; + } + return MAP_map[floorindex].string; +} + +BOOL MAP_setObjData( int ff ,int fx, int fy, int obj, int objhp ) +{ + int floorindex,xsiz; + + floorindex = MAP_getfloorIndex( ff ); + if( floorindex == -1 ) { + print( "%s:%d:err\n", __FILE__, __LINE__); + return FALSE; + } + xsiz = MAP_map[floorindex].xsiz; + if( fx < 0 || fx >= xsiz ) { + return FALSE; + } + if( fy < 0 || fy >= MAP_map[floorindex].ysiz ) { + return FALSE; + } + MAP_map[floorindex].obj[fy*xsiz+fx] = obj; + return TRUE; +} + +void MAP_sendAroundMapdata( int fl, int fromx, int fromy) +{ + char* mapdata; + RECT seek,ret; + int i,j; + seek.x = fromx; + seek.y = fromy; + seek.width = seek.height = 1; + mapdata = MAP_getdataFromRECT(fl,&seek,&ret); + if( mapdata != NULL ) { + int x = fromx; + int y = fromy; + + for( i =x-MAP_CHAR_DEFAULTSEESIZ/2 ; i <= x+MAP_CHAR_DEFAULTSEESIZ/2 ; i++ ){ + for( j = y-MAP_CHAR_DEFAULTSEESIZ/2 ; j <= y+MAP_CHAR_DEFAULTSEESIZ/2 ; + j ++ ){ + OBJECT object; + for( object = MAP_getTopObj(fl,i,j) ; + object ; + object = NEXT_OBJECT(object ) ){ + int objindex = GET_OBJINDEX(object); + if( OBJECT_getType(objindex) == OBJTYPE_NOUSE ) continue; + if( OBJECT_getType(objindex) == OBJTYPE_CHARA ) { + int index = OBJECT_getIndex( objindex); + if( CHAR_getInt( index, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) { + int fd = getfdFromCharaIndex( index ); + if( fd != -1 ) { + lssproto_M_send( fd, fl, ret.x,ret.y, + ret.x+ret.width, ret.y+ret.height, + mapdata ); + } + } + } + } + } + } + }else { + print( "地图数据错误 %s:%d \n" , __FILE__, __LINE__); + } +} + +#ifdef _STATUS_WATERWORD //水世界状态 +int MAP_getMapFloorType( int floor) +{ + int i=0; + int WaterWord[]={8101,8015,8029,8028,8027,817,8007,8100,151,160,161,-1}; + while( WaterWord[i] != -1 ){ + if( floor == WaterWord[i] ){ + return 1; + } + i++; + } + return 0; +} +#endif + + + + diff --git a/gmsv/mclient.c b/gmsv/mclient.c new file mode 100644 index 0000000..57e7cfe --- /dev/null +++ b/gmsv/mclient.c @@ -0,0 +1,677 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "autil.h" +#include "util.h" +#include "net.h" +#include "char.h" +#include "char_base.h" +#include "mclient.h" +#include "log.h" +#include "handletime.h" +#include "chatmagic.h" + +#ifdef _RECAL_ASK_PLAYER // WON 要求人物资料 +#include "saacproto_cli.h" +#endif + +#ifdef _M_SERVER + +#define SEPARATOR ";" + +#ifdef _GSERVER_RUNTIME + BOOL gserver_runtime_starttime0_flag = TRUE; + time_t gserver_runtime_starttime0; +#endif + +//Mserver NETProc +int mproto_ClientDispatchMessage(int fd,char* data) +{ + int func,fieldcount; + char raw[65500]; + + strcpy(PersonalKey, MSPERSIONALKEY); + util_DecodeMessage(raw,data); + util_SplitMessage(raw,SEPARATOR); + if (!util_GetFunctionFromSlice(&func, &fieldcount)) { + logHack(fd,HACK_GETFUNCFAIL); + return -1; + } + + if (func==MPROTO_QUE_RECV) { + int checksum=0, checksumrecv; + int userfdid; + char ans[65500],uid[4096]; + checksum += util_destring(2,uid); + checksum += util_deint(3, &userfdid); + checksum += util_destring(4, ans); + util_deint(5, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + return -1; + } + mproto_Que_Recv(fd,uid,userfdid, ans); + util_DiscardMessage(); + return 0; + } + + if( func == MPROTO_MESSAGE_RECV ) { + int checksum=0, checksumrecv; + int userfdid; + char ans[65500],uid[4096]; + checksum += util_destring(2,uid); + checksum += util_deint(3, &userfdid); + checksum += util_destring(4, ans); + util_deint(5, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + return -1; + } + mproto_Message_Recv(fd,uid,userfdid, ans); + util_DiscardMessage(); + return 0; + } + + if (func==MPROTO_HELLO_RECV) { + util_DiscardMessage(); + return 0; + } + if (func == MPROTO_NOTALK_RECV) { + int checksum=0, checksumrecv=0; + int userfdid,ntime; + char uid[4096]; + checksum = util_destring(2,uid); + checksum += util_deint(3, &userfdid); + checksum += util_deint(4, &ntime); + util_deint(5, &checksumrecv); + print("notalk here1 sum=%d,recv=%d\n",checksum,checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + return -1; + } + print("notalk here2\n"); + mproto_NoTalk_Recv(fd,uid,userfdid, ntime); + util_DiscardMessage(); + return 0; + } + +#ifdef _GM_WARP_PLAYER // WON 传送玩家 + if (func == MPROTO_WARP_RECV) { + int checksum=0, checksumrecv=0; + int userfdid,floor,x,y; + char uid[4096]; + checksum = util_destring(2,uid); + checksum += util_deint(3, &userfdid); + checksum += util_deint(4, &floor); + checksum += util_deint(5, &x); + checksum += util_deint(6, &y); + util_deint(7, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + return -1; + } + mproto_WARP_Recv(fd, uid, userfdid, floor, x, y); + util_DiscardMessage(); + return 0; + } +#endif + +#ifdef _RECAL_ASK_PLAYER // WON 要求人物资料 + + // 线上人物资料 + if (func == MPROTO_RECALL_PLAYER_RECV) { + int checksum=0, checksumrecv=0, backup_flag=0; + int userfdid, char_num, date, GmCliId; + char uid[4096], id[20]; + + checksum = util_destring(2,uid); + checksum += util_deint(3, &userfdid); + checksum += util_deint(4, &GmCliId); + checksum += util_destring(5,id); + checksum += util_deint(6, &char_num); + checksum += util_deint(7, &date); + checksum += util_deint(8, &backup_flag); + + util_deint(9, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + return -1; + } + + mproto_RECALL_ASK_PLAYER_Recv(fd, uid, userfdid, GmCliId, id, char_num, date, backup_flag); + util_DiscardMessage(); + return 0; + } + // 备份人物资料 + if (func == MPROTO_RECALL_BACKUP_RECV) { + int checksum=0, checksumrecv=0; + int userfdid, char_num, date, GmCliId, backup_flag; + char uid[4096], id[20], char_data[1024]; + + checksum = util_destring(2, uid); + checksum += util_deint(3, &userfdid); + checksum += util_deint(4, &GmCliId); + checksum += util_destring(5,id); + checksum += util_deint(6, &char_num); + checksum += util_deint(7, &date); + checksum += util_destring(8, char_data); + checksum += util_deint(9, &backup_flag); + + util_deint(10, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + return -1; + } + + mproto_RECALL_BACKUP_PLAYER_Recv(fd, uid, userfdid, GmCliId, id, char_num, date, char_data, backup_flag); + + util_DiscardMessage(); + return 0; + } + +#endif + + if( func == MPROTO_WAEIKICK_RECV ) { + int checksum=0, checksumrecv=0, userfdid; + char uid[4096]; + checksum = util_destring(2,uid); + checksum += util_deint(3, &userfdid); + util_deint(4, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + return -1; + } + mproto_WaeiKick_Recv( fd, uid, userfdid); + util_DiscardMessage(); + return 0; + } + + if( func == MPROTO_JAIL_RECV ) { + int checksum=0, checksumrecv=0, userfdid; + char uid[4096]; + checksum = util_destring(2,uid); + checksum += util_deint(3, &userfdid); + util_deint(4, &checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + return -1; + } + mproto_Jail_Recv( fd, uid, userfdid); + util_DiscardMessage(); + return 0; + } + + if (func == MPROTO_GMTALK_RECV) { + int checksum=0,checksumrecv=0; + int ntime; + char uid[4096],data[65530]; + checksum = util_destring(2,uid); + checksum += util_deint(3,&ntime); + checksum += util_destring(4,data); + util_deint(5,&checksumrecv); + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + return -1; + } + mproto_GMTalk_Recv(fd,uid,ntime,data); + util_DiscardMessage(); + return 0; + } + +#ifdef _RECAL_SERVER_OFF // WON MSERVER 关闭 GS + if (func == MPROTO_RECALL_SERVER_OFF_RECV) { + int checksum=0,checksumrecv=0; + char msg[10]; + + struct tm *newtime; + time_t long_time; + int MIN=0, HOUR=0, SEC=0; + + time( &long_time ); + newtime = localtime( &long_time ); + + HOUR=newtime->tm_hour; + MIN=newtime->tm_min; + SEC=newtime->tm_sec; + + checksum = util_destring(2,msg); + util_deint(3,&checksumrecv); + + if (checksum!=checksumrecv) { + util_DiscardMessage(); + logHack(fd, HACK_CHECKSUMERROR); + return -1; + } + + // 关机 + if( strcmp(msg, "OFF") == 0){ + print("\n\n\n\n\n GM server shoutdown GS !! (%d:%d:%d)\n\n\n\n\n", HOUR, MIN, SEC); + system( "~/gmsvstop.sh" ); + } + + util_DiscardMessage(); + return 0; + } +#endif + + util_DiscardMessage(); + return 0; +} +//GM回覆问题 +void mproto_Que_Recv(int fd,char* uid,int userfdid,char* ans) +{ + int fd_charaindex; + char sGM[256]; + int clifd=getfdFromFdid(userfdid); + if (clifd == -1) return ; + if (ans == NULL || uid==NULL) return; + sprintf(sGM,"GM[%s]为你解答如下:",uid); + fd_charaindex = CONNECT_getCharaindex( clifd ); + if (!CHAR_CHECKINDEX(fd_charaindex)) return; + CHAR_talkToCli(fd_charaindex, -1, sGM, CHAR_COLORYELLOW); + CHAR_talkToCli(fd_charaindex, -1, ans, CHAR_COLORWHITE); + + return; +} +//GM讯息 +void mproto_Message_Recv(int fd,char* uid,int userfdid,char* ans) +{ + int fd_charaindex; + char sGM[256]; + int clifd=getfdFromFdid(userfdid); + if (clifd == -1) return ; + if (ans == NULL || uid==NULL) return; + if( !strcmp( uid, "无") ) { + sprintf( sGM, "%s", ans); + }else{ + sprintf( sGM, "GM[%s]讯息:%s", uid, ans); + } + + fd_charaindex = CONNECT_getCharaindex( clifd ); + if (!CHAR_CHECKINDEX(fd_charaindex)) return; + CHAR_talkToCli(fd_charaindex, -1, sGM, CHAR_COLORRED); + return; +} + +//GM禁言 +void mproto_NoTalk_Recv(int fd,char* uid,int userfdid,int nTime) +{ + int fd_charaindex; + int clifd=getfdFromFdid(userfdid); + print("clifd =%d\n",clifd); + if (clifd == -1) return ; + if (uid == NULL ) return ; + fd_charaindex=CONNECT_getCharaindex(clifd); + if (!CHAR_CHECKINDEX(fd_charaindex)) return; + CHAR_setInt( fd_charaindex,CHAR_SILENT, nTime ); + CHAR_setWorkInt( fd_charaindex, CHAR_WORKLOGINTIME, (int)NowTime.tv_sec ); + CHAR_talkToCli( fd_charaindex, -1, "由於捣乱,被GM禁言10到30分钟", CHAR_COLORYELLOW); + CHAR_setWorkInt(fd_charaindex, CHAR_WORKTALKCOUNT, 0 ); +} + + +#ifdef _GM_WARP_PLAYER // WON 传送玩家 +void mproto_WARP_Recv(int fd,char* uid,int userfdid,int floor, int x, int y) +{ + int fd_charaindex; + int clifd=getfdFromFdid(userfdid); + print("clifd =%d\n",clifd); + if (clifd == -1) return ; + if (uid == NULL ) return ; + fd_charaindex=CONNECT_getCharaindex(clifd); + if (!CHAR_CHECKINDEX(fd_charaindex)) return; + CHAR_warpToSpecificPoint(fd_charaindex, floor, x, y); + +} +#endif + +#ifdef _RECAL_ASK_PLAYER // WON 要求人物资料 +void mproto_RECALL_ASK_PLAYER_Recv(int fd, char *uid, int userfdid, int GmCliId, char *id, int char_num, int date, int backup_flag) +{ + extern int acfd; + saacproto_Recal_Player_send(acfd, uid, userfdid, GmCliId, id, char_num, date, backup_flag); + +} + +void mproto_RECALL_BACKUP_PLAYER_Recv(int fd, char *uid, int userfdid, int GmCliId, char *id, int char_num, int date, char *char_data, int backup_flag) +{ + extern int acfd; + saacproto_Recal_Backup_send(acfd, uid, userfdid, GmCliId, id, char_num, date, char_data, backup_flag); + +} +#endif + +//GM JAIL +void mproto_Jail_Recv(int fd,char* uid,int userfdid) +{ + int fd_charaindex; + int clifd=getfdFromFdid(userfdid); + if (clifd == -1) return; + if (uid == NULL ) return; + fd_charaindex = CONNECT_getCharaindex(clifd); + if (!CHAR_CHECKINDEX(fd_charaindex)) + return; + CHAR_talkToCli( fd_charaindex, -1, "由於捣乱,被GM关入监牢", CHAR_COLORYELLOW); + CHAR_CHAT_DEBUG_jail( -1, CHAR_getChar( fd_charaindex, CHAR_CDKEY)); +} + +//GM踢人 +void mproto_WaeiKick_Recv(int fd,char* uid,int userfdid) +{ + int fd_charaindex; + int clifd=getfdFromFdid(userfdid); + if (clifd == -1) return; + if (uid == NULL ) return; + fd_charaindex = CONNECT_getCharaindex(clifd); + if (!CHAR_CHECKINDEX(fd_charaindex)) + return; + CHAR_talkToCli( fd_charaindex, -1, "由於捣乱,被GM踢除", CHAR_COLORYELLOW); + CHAR_CHAT_DEBUG_gmkick( -1, CHAR_getChar( fd_charaindex, CHAR_CDKEY)); +} +//GM广播 +void mproto_GMTalk_Recv(int fd,char* uid,int ntime,char* data) +{ + char message[65530]; + int i; + int playernum = CHAR_getPlayerMaxNum(); + if (uid == NULL || data == NULL ) return ; + strcpy(message,""); + sprintf(message,"GM[%s]:%s",uid,data); + for( i = 0 ; i < playernum ; i++) { + if( CHAR_getCharUse(i) != FALSE ) { + CHAR_talkToCli( i, -1, message, CHAR_COLORWHITE); + } + } +} + +void mproto_Que_Send( int fd, int uid, int index, char* question) +{ + char buffer[65500], wheres[256]; + int checksum=0, floor, x, y; + + char *cdkey = CHAR_getChar( index, CHAR_CDKEY); + char *charname = CHAR_getChar( index, CHAR_NAME); + + if( strlen( question) <= 0 ){ + CHAR_talkToCli( index, -1, "字串长度不足!", CHAR_COLORYELLOW); + return; + } + memset( wheres, 0, sizeof( wheres)); + floor = CHAR_getInt( index, CHAR_FLOOR); + x = CHAR_getInt( index, CHAR_X); + y = CHAR_getInt( index, CHAR_Y); + sprintf( wheres, "%d,%d,%d", floor, x, y); + + memset( buffer, 0, sizeof( buffer)); + strcpy(PersonalKey, MSPERSIONALKEY); + checksum += util_mkint(buffer, uid); + checksum += util_mkstring(buffer, cdkey); + checksum += util_mkstring(buffer, charname); + checksum += util_mkstring(buffer, question); + checksum += util_mkstring(buffer, wheres); + util_mkint(buffer, checksum); + util_SendMesg(fd, MPROTO_QUE_SEND, buffer); +} + +#ifdef _RECAL_ASK_PLAYER // WON 要求人物资料 + +// 线上人物资料 +void saacproto_ACRecalPlayer_recv(char *uid, int userfdid, int GmCliId, char *id, int char_num, int date, char *char_data) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer, ""); + strcpy(PersonalKey, MSPERSIONALKEY); + checksum += util_mkstring(buffer, uid); + checksum += util_mkint(buffer, userfdid); + checksum += util_mkint(buffer, GmCliId); + checksum += util_mkstring(buffer, id); + checksum += util_mkint(buffer, char_num); + checksum += util_mkint(buffer, date); + checksum += util_mkstring(buffer, char_data); + + util_mkint(buffer, checksum); + util_SendMesg(mfd, MPROTO_RECALL_PLAYER_SEND, buffer); +} + +// 备份人物资料 +void saacproto_ACRecalBackupPlayer_recv(char *uid, int userfdid, int GmCliId, char *id, int char_num, int date, char *char_data) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer, ""); + strcpy(PersonalKey, MSPERSIONALKEY); + checksum += util_mkstring(buffer, uid); + checksum += util_mkint(buffer, userfdid); + checksum += util_mkint(buffer, GmCliId); + checksum += util_mkstring(buffer, id); + checksum += util_mkint(buffer, char_num); + checksum += util_mkint(buffer, date); + checksum += util_mkstring(buffer, char_data); + + util_mkint(buffer, checksum); + util_SendMesg(mfd, MPROTO_RECALL_BACKUP_SEND, buffer); +} + +// 回溯ok +void saacproto_ACRecalAllBackupOK_recv(char *uid, int userfdid, int GmCliId, char *id, int char_num, int date, char *char_data) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer, ""); + strcpy(PersonalKey, MSPERSIONALKEY); + checksum += util_mkstring(buffer, uid); + checksum += util_mkint(buffer, userfdid); + checksum += util_mkint(buffer, GmCliId); + checksum += util_mkstring(buffer, id); + checksum += util_mkint(buffer, char_num); + checksum += util_mkint(buffer, date); + checksum += util_mkstring(buffer, char_data); + util_mkint(buffer, checksum); + util_SendMesg(mfd, MPROTO_RECALL_BACKUP_OK_SEND, buffer); +} + +// 取得备份日期 +void saacproto_ACRecalBackupDate_recv(char *uid, int userfdid, int GmCliId, char *id, int char_num, int date, char *char_data) +{ + char buffer[65500]; + int checksum=0; + + strcpy(buffer, ""); + strcpy(PersonalKey, MSPERSIONALKEY); + checksum += util_mkstring(buffer, uid); + checksum += util_mkint(buffer, userfdid); + checksum += util_mkint(buffer, GmCliId); + checksum += util_mkstring(buffer, id); + checksum += util_mkint(buffer, char_num); + checksum += util_mkint(buffer, date); + checksum += util_mkstring(buffer, char_data); + + util_mkint(buffer, checksum); + util_SendMesg(mfd, MPROTO_RECALL_BACKUP_DATE_SEND, buffer); +} +#endif + + +void mproto_Type_Send( int fd, int playernum, int itemuse) +{ + char buffer[65500]; + int checksum=0; + + memset( buffer, 0, sizeof( buffer)); + strcpy(PersonalKey, MSPERSIONALKEY); + checksum += util_mkint(buffer, playernum); + checksum += util_mkint(buffer, itemuse); + util_mkint(buffer, checksum); + util_SendMesg(fd, MPROTO_TYPE_SEND, buffer); +} + +int connectmServer(char* hostname,unsigned short port) +{ + struct sockaddr_in sock; + struct hostent* hoste; + int fd,lr; + fd_set fdset,fde; + struct timeval tmv; + memset( &sock , 0 , sizeof( struct sockaddr_in ) ); + sock.sin_family = AF_INET; + sock.sin_port = htons( port ); + + sock.sin_addr.s_addr = inet_addr( hostname ); + if( sock.sin_addr.s_addr == -1 ){ + hoste = gethostbyname( hostname ); + if( hoste == NULL ){ + print( "获取主机名: %s\n", hostname); + return -1; + } + + memcpy((void*)&sock.sin_addr.s_addr , + hoste->h_addr , sizeof(struct in_addr) ); + } + + fd = socket( AF_INET, SOCK_STREAM , 0 ); + if( fd == -1 ){ + print("Cannot Create Socket( errno:%d)\n",errno ); + return -1; + } + + //set the no block + if ( fcntl(fd,F_SETFL,O_NONBLOCK) == -1 ){ + print("set noblock error!\n"); + return -1; + } + + lr = connect(fd,(struct sockaddr*)&sock,sizeof(struct sockaddr_in)); + if( lr != 0 ){ + if ( errno != EINPROGRESS ){ + print("Cannot connect. (errno:%d)\n",errno ); + close(fd); + return -1; + } + } + + FD_ZERO(&fdset); + FD_SET(fd,&fdset); + FD_SET(fd,&fde); + tmv.tv_sec =3; + tmv.tv_usec = 0; + lr=select(fd+1,NULL,&fdset,&fde,&tmv); + if (FD_ISSET(fd,&fde)){ + print("connectGmsv fde\n"); + close(fd); //add more + return -1; + } + + if ( lr > 0 && FD_ISSET(fd,&fdset)){ + + int errorcode; + int errorcodelen; + errorcode=1; + errorcodelen=sizeof(errorcode); + getsockopt(fd,SOL_SOCKET,SO_ERROR,&errorcode,&errorcodelen); + if (errorcode == 0 ){ + fcntl(fd,F_SETFL,0); + print("connectGmsv return fd=%d\n",fd); + return fd; + }else{ + print("connectGmsv errorcode error\n"); + close(fd); + return -1; + } + }else{ + close(fd); + return -1; + } + +} + +#endif + +#ifdef _RECAL_SEND_COUNT // WON 传送GS资讯 +void recal_get_count() +{ + FILE *fp; + int i, j; + char temp[3][15], c; + char buffer[256], msg[64]; + int checksum=0; + + if(mfd == -1) return; + + if( !(fp=fopen("recal_count.txt", "r")) ){ + print("\n open recal_count.txt err !!"); + } + + memset(temp, 0, sizeof(temp)); + + i=0; j=0; + do{ + c = fgetc(fp); + if(c==' '){ + i=0; j++; + continue; + } + temp[j][i]=c; + i++; + }while(c != EOF); + + temp[2][i-2]=0; + + sprintf(msg,"%5s%4d%12s", temp[0], atoi(temp[1]), temp[2]); + + strcpy(buffer, ""); + strcpy(PersonalKey, MSPERSIONALKEY); + checksum += util_mkstring(buffer, msg); + + util_mkint(buffer, checksum); + util_SendMesg(mfd, MPROTO_RECALL_COUNT_SEND, buffer); + + fclose(fp); + +} +#endif + +#ifdef _GSERVER_RUNTIME //传送GSERVER执行多少时间给MSERVER +void gserver_runtime() +{ + int checksum=0; + char buffer[1024]; + time_t starttime1; + + if(mfd == -1) return; + if( gserver_runtime_starttime0_flag ){ + gserver_runtime_starttime0_flag = FALSE; + gserver_runtime_starttime0 = time(NULL); + } + print("\nChange->传送时间给mserver\n"); + strcpy(buffer, ""); + strcpy(PersonalKey, MSPERSIONALKEY); + starttime1 = time(NULL); + checksum += util_mkint(buffer, (int)difftime(starttime1,gserver_runtime_starttime0));//传送的单位为秒 + util_mkint(buffer, checksum); + util_SendMesg(mfd, MPROTO_RECALL_GSERVER_RUNTIME, buffer); +} +#endif diff --git a/gmsv/msignal.c b/gmsv/msignal.c new file mode 100644 index 0000000..f5ee5af --- /dev/null +++ b/gmsv/msignal.c @@ -0,0 +1,118 @@ +#include "version.h" +#include +#include +#include + +#include + +#include "buf.h" +#include "net.h" +#include "char.h" +#include "item.h" +#include "object.h" +#include "configfile.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "log.h" +#include "petmail.h" + +/*------------------------------------------------------------ + * lsprotocol 及伐□平件弘 毛荸 允月楮醒毛裟少[ + * 娄醒}忒曰袄 + * 卅仄 + ------------------------------------------------------------*/ +static void endlsprotocol( void ) +{ + lssproto_CleanupServer(); + saacproto_CleanupClient(); +} + +/*------------------------------------------------------------ + * 允屯化及忡绣仄卅仃木壬卅日卅中犯□正毛母件皿允月楮醒 + * 公木冗木及乒斥亘□伙及楮醒毛裟少及心[ + * 娄醒}忒曰袄 + * 卅仄 + ------------------------------------------------------------*/ +static void allDataDump( void ) +{ + closeAllLogFile(); +#ifndef _SIMPLIFY_ITEMSTRING + storeObjects( getStoredir() ); + storePetmail(); +#endif + storeCharaData(); +} + +/*------------------------------------------------------------ + * 皿夫弘仿丞及蔽 质 及凶户卞裟太请今木月[ + * 娄醒}忒曰袄 + * 卅仄 + ------------------------------------------------------------*/ +void shutdownProgram( void ) +{ + close( acfd ); + close( bindedfd ); + endlsprotocol(); + endConnect(); + memEnd(); +} + +char *DebugFunctionName = NULL; +int DebugPoint = 0; + +void sigshutdown( int number ) +{ + + +#if USE_MTIO + { + void MTIO_join(void); + MTIO_join(); + } +#endif + print( "\n标准信息: %d\n" , number ); + if( number == 0 )print( "\nGMSV正常关闭\n" ); + print( "\n调试点数(%d)\n", DebugPoint ); + print( "\n最后函数 (%s)\n", DebugFunctionName ); + + remove( "gmsvlog.err2"); + rename( "gmsvlog.err1", "gmsvlog.err2" ); + rename( "gmsvlog.err", "gmsvlog.err1" ); + rename( "gmsvlog", "gmsvlog.err" ); + + allDataDump(); + + + signal( SIGINT , SIG_IGN ); + signal( SIGQUIT, SIG_IGN ); + signal( SIGKILL, SIG_IGN ); + signal( SIGSEGV, SIG_IGN ); + signal( SIGPIPE, SIG_IGN ); + signal( SIGTERM, SIG_IGN ); + + + shutdownProgram(); + exit(number); +} + + + +void signalset( void ) +{ + // CoolFish: Test Signal 2001/10/26 + print("\n开始获取信号..\n"); + + print("SIGINT:%d\n", SIGINT); + print("SIGQUIT:%d\n", SIGQUIT); + print("SIGKILL:%d\n", SIGKILL); + print("SIGSEGV:%d\n", SIGSEGV); + print("SIGPIPE:%d\n", SIGPIPE); + print("SIGTERM:%d\n", SIGTERM); + + signal( SIGINT , sigshutdown ); + signal( SIGQUIT, sigshutdown ); + signal( SIGKILL, sigshutdown ); + signal( SIGSEGV, sigshutdown ); + signal( SIGPIPE, SIG_IGN ); + signal( SIGTERM, sigshutdown ); +} diff --git a/gmsv/net.c b/gmsv/net.c new file mode 100644 index 0000000..2091d0a --- /dev/null +++ b/gmsv/net.c @@ -0,0 +1,3751 @@ +#define __NET_C__ +#include "version.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//ttom+1 +#include +#include "net.h" +#include "buf.h" +#include "link.h" +#include "common.h" +#include "msignal.h" +#include "configfile.h" +#include "util.h" +#include "saacproto_cli.h" +#include "lssproto_serv.h" +#include "char.h" +#include "handletime.h" +#include "log.h" +#include "object.h" +#include "item_event.h" +#include "enemy.h" +// Arminius 7.31 cursed stone +#include "battle.h" +#include "version.h" +#include "pet_event.h" +#include "char_talk.h" +#include "petmail.h" + +#ifdef _TEST_PETCREATE +#include "chatmagic.h" +#endif + +#ifdef _M_SERVER +#include "mclient.h" +#endif + +#ifdef _NPCSERVER_NEW +#include "npcserver.h" +#endif + +#define MIN(x,y) ( ( (x) < (y) ) ? (x) : (y) ) +#define IS_2BYTEWORD( _a_ ) ( (char)(0x80) <= (_a_) && (_a_) <= (char)(0xFF) ) + +#ifdef _NEW_SERVER_ +BOOL bNewServer = TRUE; +#else +BOOL bNewServer = FALSE; +#endif + +// Nuke +1 0901: For state monitor +int StateTable[WHILESAVEWAIT+1]; + +int ITEM_getRatio(); +int CHAR_players(); +#define CONO_CHECK_LOGIN 0x001 +#define CONO_CHECK_ITEM 0x010 +#define CONO_CHECK_PET 0x100 +int cono_check=0x111; + +int AC_WBSIZE = (65536*16); +//ttom+1 for the performatce +static unsigned int MAX_item_use=0; +int i_shutdown_time=0;//ttom +BOOL b_first_shutdown=FALSE;//ttom + +int mfdfulll = 0; + +/*------------------------------------------------------------ + * 扔□田及橇谪 + ------------------------------------------------------------*/ +typedef struct tag_serverState +{ + BOOL acceptmore; /* 1分匀凶日}accept 仄凶丐午 + 切斤仁匹}close 允月 */ + unsigned int fdid; /* fd 及骚曰袄 */ + unsigned int closeallsocketnum; /* closeallsocket 及酸曰及 + 醒*/ + int shutdown; /* 扔□田毛shutdown允月乒□玉 + * 0:骚橘 公木动陆:扑乓永玄扑乓永玄乒□玉 + * 乒□玉卞卅匀凶凛棉互 匀化月[ + */ + int dsptime; /* shutdown 乒□玉及伐□弁 醒*/ + int limittime; /* 仇木手 */ +}ServerState; + +typedef struct tagCONNECT +{ + BOOL use; + +#if USE_MTIO +#define MTIO_FIXED_BUFSIZE (65536) + char rb[MTIO_FIXED_BUFSIZE]; + int rbuse; + char wb[MTIO_FIXED_BUFSIZE]; + int wbuse; + pthread_mutex_t mutex; /* Connect毛中元月午五卞勾井丹夫永弁 */ +#else + char *rb; + int rbuse; + char *wb; + int wbuse; + int check_rb_oneline_b; + int check_rb_time; +#endif + + struct sockaddr_in sin; /* 涛粮燮及失玉伊旦 */ + ConnectType ctype; /* 戊生弁扑亦件及潘 */ + + char cdkey[CDKEYLEN]; /* CDKEY */ + char passwd[PASSWDLEN]; /* 由旦伐□玉 */ + LoginType state; /* 蜇箕及夫弘奶件橇谪 */ + int nstatecount; + char charname[CHARNAMELEN]; /* 夫弘奶件 及平乓仿 */ + int charaindex; /* char 尺及奶件犯永弁旦[ + * 夫弘奶件 卞袄互涩烂今木月[-1互犯白巧伙玄 + * 卞卅中凛[ + */ + char CAbuf[2048]; /* CA() 毛做谅允月啃及田永白央 */ + int CAbufsiz; /* CAbuf 及扔奶术 */ + struct timeval lastCAsendtime; /* 卞CA毛霜匀凶凛棉 */ + + char CDbuf[2048]; /* CD() 毛做谅允月啃及田永白央 */ + int CDbufsiz; /* CDbuf 及扔奶术 */ + struct timeval lastCDsendtime; /* 卞CD毛霜匀凶凛棉 */ + + struct timeval lastCharSaveTime; /* 卞平乓仿犯□正毛本□皮仄凶凛棉 */ + + struct timeval lastprocesstime; /* 卞皿夫玄戊伙毛质 仄凶凛棉*/ + struct timeval lastreadtime; /* 卞read仄凶凛棉[晓午反切互丹*/ + + // Nuke start 08/27 : For acceleration avoidance + // WALK_TOLERANCE: Permit n W messages in a second (3: is the most restricted) + #define WALK_TOLERANCE 4 + #define WALK_SPOOL 5 + #define WALK_RESTORE 100 + unsigned int Walktime; + unsigned int lastWalktime; + unsigned int Walkcount; + int Walkspool; // For walk burst after release key F10 + int Walkrestore; + // B3_TOLERANCE: Time distance between recently 3 B message (8: is the latgest) + // BEO_TOLERANCE: Time distance between the lastmost B and EO (5: is the largest) + #define B3_TOLERANCE 5 + #define BEO_TOLERANCE 3 + #define BEO_SPOOL 10 + #define BEO_RESTORE 100 + unsigned int Btime; + unsigned int lastBtime; + unsigned int lastlastBtime; + unsigned int EOtime; + +#ifdef _BATTLE_TIMESPEED +// unsigned int DefBtime; + int BDTime; + int CBTime; +#endif + +#ifdef _TYPE_TOXICATION + int toxication; +#endif + +#ifdef _CHECK_GAMESPEED + int gamespeed; +#endif +#ifdef _ITEM_ADDEXP //vincent 经验提升 + int EDTime; +#endif + // unsigned int BEO; + int BEOspool; + int BEOrestore; + // Nuke 0219: Avoid cheating + int die; + // Nuke end + // Nuke 0310 + int credit; + int fcold; + // Nuke 0406: New Flow Control + int nu; + int nu_decrease; + int ke; + // Nuke 1213: Flow Control 2 + int packetin; + + // Nuke 0624: Avoid Null Connection + unsigned int cotime; + // Nuke 0626: For no enemy + int noenemy; + // Arminius 7.2: Ra's amulet + int eqnoenemy; +#ifdef _Item_MoonAct + int eqrandenemy; +#endif + +#ifdef _CHIKULA_STONE + int chistone; +#endif + // Arminius 7.31: cursed stone + int stayencount; + + /* close 允月屯五井升丹井及筏盛 */ +#if USE_MTIO + int closed; +#endif + int battlecharaindex[CONNECT_WINDOWBUFSIZE]; + int duelcharaindex[CONNECT_WINDOWBUFSIZE]; + int tradecardcharaindex[CONNECT_WINDOWBUFSIZE]; + int joinpartycharaindex[CONNECT_WINDOWBUFSIZE]; + + // CoolFish: Trade 2001/4/18 + int tradecharaindex[CONNECT_WINDOWBUFSIZE]; + int errornum; + int fdid; + + int close_request; //the second have this + + int appendwb_overflow_flag; /* 1荚匹手appendWb互撩 仄凶日1卞允月 */ + //ttom+1 avoidance the watch the battle be kept out + BOOL in_watch_mode; + BOOL b_shut_up;//for avoid the user wash the screen + BOOL b_pass; //for avoid the unlimited area + struct timeval Wtime; + struct timeval WLtime; + BOOL b_first_warp; + int state_trans; + + // CoolFish: Trade 2001/4/18 + char TradeTmp[256]; + +#ifdef _ITEM_PILEFORTRADE + int tradelist; +#endif + // Shan Recvdata Time + struct timeval lastrecvtime; // 'FM' Stream Control time + struct timeval lastrecvtime_d; // DENGON Talk Control time + + // Arminius: 6.22 encounter + int CEP; // Current Encounter Probability + // Arminius 7.12 login announce + int announced; + + // shan battle delay time 2001/12/26 + struct timeval battle_recvtime; +#ifdef _NO_WARP + // shan hjj add Begin + int seqno; + int selectbutton; + // shan End +#endif + BOOL confirm_key; // shan trade(DoubleCheck) + +#ifdef _BLACK_MARKET + int BMSellList[12]; +#endif +} +CONNECT; + +CONNECT *Connect; /*戊生弁扑亦件忡切迕*/ + + +/* 楮醒及燮 卞勾仃化歹井月方丹卞允月分仃及穴弁夫 */ +#define SINGLETHREAD +#define MUTLITHREAD +#define ANYTHREAD + +ServerState servstate; +#if USE_MTIO +pthread_mutex_t MTIO_servstate_m; /* servstate 及夫永弁 */ +#define SERVSTATE_LOCK() pthread_mutex_lock( &MTIO_servstate_m ); +#define SERVSTATE_UNLOCK() pthread_mutex_unlock( &MTIO_servstate_m ); + +#if 1 +#define CONNECT_LOCK_ARG2(i,j) fprintf(stderr,"LO T:%d(%d:%d) %s %d", (int)pthread_self(), i,j, __FILE__,__LINE__ );pthread_mutex_lock( &Connect[i].mutex );fprintf( stderr, "CK T:%d(%d:%d)\n" , (int)pthread_self(), i,j ); +#define CONNECT_UNLOCK_ARG2(i,j) fprintf(stderr,"UNLO T:%d(%d:%d) %s %d", (int)pthread_self(), i,j, __FILE__,__LINE__ );pthread_mutex_unlock( &Connect[i].mutex );fprintf( stderr, "CK T:%d(%d:%d)\n",(int)pthread_self(), i,j); +#define CONNECT_LOCK(i) fprintf(stderr,"LO T:%d(%d) %s %d", (int)pthread_self(), i, __FILE__,__LINE__ );pthread_mutex_lock( &Connect[i].mutex );fprintf( stderr, "CK T:%d(%d)\n" ,(int)pthread_self(), i ); +#define CONNECT_UNLOCK(i) fprintf(stderr,"UNLO T:%d(%d) %s %d", (int)pthread_self(), i, __FILE__,__LINE__ );pthread_mutex_unlock( &Connect[i].mutex );fprintf( stderr, "CK T:%d(%d)\n",(int)pthread_self(), i); +/* 晓筏及夫弘反户切扎仁切扎犯奴旦弁毛罹丹及匹旦伉□皿毛中木凶曰 */ +#define MTIO_DEBUG_LOG_REDUCE 1 +#else +#define CONNECT_LOCK_ARG2(i,j) pthread_mutex_lock( &Connect[i].mutex ); +#define CONNECT_UNLOCK_ARG2(i,j) pthread_mutex_unlock( &Connect[i].mutex ); +#define CONNECT_LOCK(i) pthread_mutex_lock( &Connect[i].mutex ); +#define CONNECT_UNLOCK(i) pthread_mutex_unlock( &Connect[i].mutex ); +#define MTIO_DEBUG_LOG_REDUCE 0 +#endif + +#else +#define SERVSTATE_LOCK() +#define SERVSTATE_UNLOCK() +#define CONNECT_LOCK_ARG2(i,j) +#define CONNECT_UNLOCK_ARG2(i,j) +#define CONNECT_LOCK(i) +#define CONNECT_UNLOCK(i) +#endif + +#ifdef _CHECK_BATTLE_IO +int InBattleLoop =FALSE; +int battle_write =0; +int other_write =0; +int battle_write_cnt =0; +int other_write_cnt =0; +#endif + + + +/*------------------------------------------------------------ + * servstate毛赓渝祭允月[ + * 娄醒}忒曰袄 + * 卅仄 + ------------------------------------------------------------*/ +ANYTHREAD static void SERVSTATE_initserverState( void ) +{ + SERVSTATE_LOCK(); + servstate.acceptmore = TRUE; + servstate.fdid = 0; + servstate.closeallsocketnum = -1; + servstate.shutdown = 0; + servstate.limittime = 0; + servstate.dsptime = 0; + SERVSTATE_UNLOCK(); +} + +ANYTHREAD int SERVSTATE_SetAcceptMore( int nvalue ) +{ + BOOL buf; + SERVSTATE_LOCK(); + buf = servstate.acceptmore; + servstate.acceptmore = nvalue; + SERVSTATE_UNLOCK(); + return buf; +} +ANYTHREAD static int SERVSTATE_incrementFdid( void ) +{ + int ret; + SERVSTATE_LOCK(); + ret = servstate.fdid++; + SERVSTATE_UNLOCK(); + return ret; +} +ANYTHREAD static void SERVSTATE_setCloseallsocketnum( int a ) +{ + SERVSTATE_LOCK(); + servstate.closeallsocketnum = a; + SERVSTATE_UNLOCK(); +} +ANYTHREAD static void SERVSTATE_incrementCloseallsocketnum(void) +{ + SERVSTATE_LOCK(); + servstate.closeallsocketnum ++; + SERVSTATE_UNLOCK(); +} +ANYTHREAD void SERVSTATE_decrementCloseallsocketnum(void) +{ + SERVSTATE_LOCK(); + servstate.closeallsocketnum --; + SERVSTATE_UNLOCK(); +} +ANYTHREAD int SERVSTATE_getCloseallsocketnum( void ) +{ + int a; + SERVSTATE_LOCK(); + a = servstate.closeallsocketnum; + SERVSTATE_UNLOCK(); + return a; +} + +ANYTHREAD static int SERVSTATE_getAcceptmore(void) +{ + int a; + SERVSTATE_LOCK(); + a = servstate.acceptmore; + SERVSTATE_UNLOCK(); + return a; +} +ANYTHREAD int SERVSTATE_getShutdown(void) +{ + int a; + SERVSTATE_LOCK(); + a = servstate.shutdown; + SERVSTATE_UNLOCK(); + return a; +} +ANYTHREAD void SERVSTATE_setShutdown(int a) +{ + SERVSTATE_LOCK(); + servstate.shutdown = a; + SERVSTATE_UNLOCK(); +} +ANYTHREAD int SERVSTATE_getLimittime(void) +{ + int a; + SERVSTATE_LOCK(); + a = servstate.limittime; + SERVSTATE_UNLOCK(); + return a; +} +ANYTHREAD void SERVSTATE_setLimittime(int a) +{ + SERVSTATE_LOCK(); + servstate.limittime = a; + SERVSTATE_UNLOCK(); +} +ANYTHREAD int SERVSTATE_getDsptime(void) +{ + int a; + SERVSTATE_LOCK(); + a = servstate.dsptime; + SERVSTATE_UNLOCK(); + return a; +} +ANYTHREAD void SERVSTATE_setDsptime(int a) +{ + SERVSTATE_LOCK(); + servstate.dsptime = a; + SERVSTATE_UNLOCK(); +} + + +#if USE_MTIO == 0 + +static int appendWB( int fd, char *buf, int size ) +{ + + if( fd != acfd ) { + if( Connect[fd].wbuse + size >= WBSIZE ) { + print( "appendWB:err buffer over[%d]:%s \n", + Connect[fd].wbuse + size, Connect[fd].cdkey ); + return -1; + } + }else { + if( Connect[fd].wbuse + size > AC_WBSIZE ) { + FILE *fp=NULL; + print( "appendWB:err buffer over[%d+%d]:(SAAC) \n", Connect[fd].wbuse, size); + if( (fp=fopen("appendWBerr.log", "a+"))==NULL) return -1; + fprintf( fp, "(SAAC) appendWB:err buffer over[%d+%d/%d]:\n", Connect[fd].wbuse, size, AC_WBSIZE); + fclose( fp); + return -1; + } + } + + + + memcpy( Connect[fd].wb + Connect[fd].wbuse , + buf, size ); + Connect[fd].wbuse += size; + return size; +} +static int appendRB( int fd, char *buf, int size ) +{ + if( fd != acfd ) { + if( Connect[fd].rbuse + size > RBSIZE ) { + if( fd == mfd ) print( "appendRB:MSERVER err buffer over \n"); + else print( "appendRB:OTHER(%d) err buffer over \n", fd); + return -1; + } + }else { + if( strlen( buf) > size ){ + print( "appendRB AC buffer len err : %d/%d=\n(%s)!!\n", strlen( buf), size, buf); + } + if( Connect[fd].rbuse + size > AC_RBSIZE ) { + print( "appendRB AC err buffer over:\n(%s)\n len:%d - rbuse:%d \n", + buf, strlen(buf), Connect[fd].rbuse); + return -1; + } + } + memcpy( Connect[fd].rb + Connect[fd].rbuse , buf, size ); + Connect[fd].rbuse += size; + return size; +} + +static int shiftWB( int fd, int len ) +{ + if( Connect[fd].wbuse < len ) { + print( "shiftWB: err\n"); + return -1; + } + memmove( Connect[fd].wb, Connect[fd].wb + len, Connect[fd].wbuse - len ); + Connect[fd].wbuse -= len; + if( Connect[fd].wbuse < 0 ) { + print( "shiftWB:wbuse err\n"); + Connect[fd].wbuse = 0; + } + return len; +} +static int shiftRB( int fd, int len ) +{ + if( Connect[fd].rbuse < len ) { + print( "shiftRB: err\n"); + return -1; + } + memmove( Connect[fd].rb, Connect[fd].rb + len, Connect[fd].rbuse - len ); + Connect[fd].rbuse -= len; + if( Connect[fd].rbuse < 0 ) { + print( "shiftRB:rbuse err\n"); + Connect[fd].rbuse = 0; + } + + return len; +} + +SINGLETHREAD int lsrpcClientWriteFunc( int fd , char* buf , int size ) +{ + int r; + if( Connect[fd].use == FALSE ){ + return FALSE; + } + if( Connect[fd].appendwb_overflow_flag ){ + print( "lsrpcClientWriteFunc: buffer overflow fd:%d\n" , fd ); + return -1; + } + r = appendWB( fd, buf , size); + + // Nuke *1 0907: Ignore acfd from WB error + if(( r < 0 ) && (fd != acfd)) { + Connect[fd].appendwb_overflow_flag = 1; + CONNECT_endOne_debug(fd); + close(fd); + // Nuke + 1 0901: Why close + // print("closed in lsrpcClientWriteFunc"); + } + return r; +} + +static int logRBuseErr = 0; +SINGLETHREAD BOOL GetOneLine_fix( int fd, char *buf, int max ) +{ + int i; + if( Connect[fd].rbuse == 0 ) return FALSE; + + if( Connect[fd].check_rb_oneline_b == 0 && + Connect[fd].check_rb_oneline_b == Connect[fd].rbuse ){ + return FALSE; + } + + + for( i = 0; i < Connect[fd].rbuse && i < ( max -1); i ++ ){ + if( Connect[fd].rb[i] == '\n' ){ + memcpy( buf, Connect[fd].rb, i+1); + buf[i+1]='\0'; + shiftRB( fd, i+1 ); + +//-------- +/* + //andy_log + if( strstr( Connect[fd].rb , "ACCharLoad") != NULL && + Connect[fd].check_rb_oneline_b != 0 )//Connect[fd].rb + LogAcMess( fd, "GetOne", Connect[fd].rb ); +*/ +//-------- + logRBuseErr = 0; + Connect[fd].check_rb_oneline_b=0; + Connect[fd].check_rb_time = 0; + return TRUE; + } + } + + //print("rbuse lens: %d!!\n", Connect[fd].rbuse); + logRBuseErr++; +//-------- + //andy_log + if( fd == acfd && strstr( Connect[fd].rb , "ACCharLoad") != NULL && + logRBuseErr >= 50 ){//Connect[fd].rb + char buf[AC_RBSIZE]; + memcpy( buf, Connect[fd].rb, Connect[fd].rbuse+1); + buf[Connect[fd].rbuse+1]=0; + LogAcMess( fd, "RBUFFER", buf ); + logRBuseErr=0; + } +//-------- + Connect[fd].check_rb_oneline_b = Connect[fd].rbuse; + + return FALSE; +} + +#endif /* if USE_MTIO == 0*/ + +ANYTHREAD BOOL initConnectOne( int sockfd, struct sockaddr_in* sin ,int len ) +{ + CONNECT_LOCK(sockfd); + + Connect[sockfd].use = TRUE; + Connect[sockfd].ctype = NOTDETECTED; +#if USE_MTIO + Connect[sockfd].closed = 0; +#else + Connect[sockfd].wbuse = Connect[sockfd].rbuse = 0; + Connect[sockfd].check_rb_oneline_b = 0; + Connect[sockfd].check_rb_time = 0; +#endif + + + + memset( Connect[sockfd].cdkey , 0 , sizeof( Connect[sockfd].cdkey ) ); + memset( Connect[sockfd].passwd, 0 , sizeof( Connect[sockfd].passwd) ); + + Connect[sockfd].state = NOTLOGIN; + Connect[sockfd].nstatecount = 0; + memset( Connect[sockfd].charname,0, sizeof(Connect[sockfd].charname)); + Connect[sockfd].charaindex = -1; + + Connect[sockfd].CAbufsiz = 0; + Connect[sockfd].CDbufsiz = 0; + Connect[sockfd].rbuse = 0; + Connect[sockfd].wbuse = 0; + Connect[sockfd].check_rb_oneline_b = 0; + Connect[sockfd].check_rb_time = 0; + + Connect[sockfd].close_request = 0; /* 濠蝇邰菲白仿弘 */ + // Nuke 08/27 For acceleration avoidance + Connect[sockfd].Walktime = 0; + Connect[sockfd].lastWalktime = 0; + Connect[sockfd].Walkcount = 0; + Connect[sockfd].Walkspool = WALK_SPOOL; + Connect[sockfd].Walkrestore = WALK_RESTORE; + Connect[sockfd].Btime = 0; + Connect[sockfd].lastBtime = 0; + Connect[sockfd].lastlastBtime = 0; + Connect[sockfd].EOtime = 0; + Connect[sockfd].nu_decrease = 0; +#ifdef _BATTLE_TIMESPEED +// Connect[sockfd].DefBtime = 0; + Connect[sockfd].BDTime = 0; + Connect[sockfd].CBTime = 0; +#endif +#ifdef _CHECK_GAMESPEED + Connect[sockfd].gamespeed = 0; +#endif +#ifdef _TYPE_TOXICATION + Connect[sockfd].toxication = 0; +#endif +#ifdef _ITEM_ADDEXP //vincent 经验提升 + Connect[sockfd].EDTime = 0; +#endif +// Connect[sockfd].BEO = 0; + Connect[sockfd].BEOspool = BEO_SPOOL; + Connect[sockfd].BEOrestore = BEO_RESTORE; + //ttom + Connect[sockfd].b_shut_up=FALSE; + Connect[sockfd].Wtime.tv_sec=0;// + Connect[sockfd].Wtime.tv_usec=0;// + Connect[sockfd].WLtime.tv_sec=0;// + Connect[sockfd].WLtime.tv_usec=0;// + Connect[sockfd].b_first_warp=FALSE; + Connect[sockfd].state_trans=0;//avoid the trans + // Nuke + Connect[sockfd].die=0; + Connect[sockfd].credit=3; + Connect[sockfd].fcold=0; + // Nuke 0406: New Flow Control + Connect[sockfd].nu=30; + Connect[sockfd].ke=10; + // Nuke 1213: Flow Control 2 + Connect[sockfd].packetin=30; // if 10x10 seconds no packet, drop the line + + // Nuke 0624: Avoid Useless Connection + Connect[sockfd].cotime=0; + // Nuke 0626: For no enemy + Connect[sockfd].noenemy=0; + // Arminius 7.2: Ra's amulet + Connect[sockfd].eqnoenemy = 0; + +#ifdef _Item_MoonAct + Connect[sockfd].eqrandenemy = 0; +#endif +#ifdef _CHIKULA_STONE + Connect[sockfd].chistone = 0; +#endif + // Arminius 7.31: cursed stone + Connect[sockfd].stayencount = 0; + + // CoolFish: Init Trade 2001/4/18 + memset(&Connect[sockfd].TradeTmp, 0, sizeof(Connect[sockfd].TradeTmp)); +#ifdef _ITEM_PILEFORTRADE + Connect[sockfd].tradelist = -1; +#endif + // Arminius 6.22 Encounter + Connect[sockfd].CEP = 0; + + // Arminius 7.12 login announce + Connect[sockfd].announced=0; +#ifdef _NO_WARP + // shan hjj add Begin + Connect[sockfd].seqno=-1; + Connect[sockfd].selectbutton=1; + // shan End +#endif + Connect[sockfd].confirm_key=FALSE; // shan trade(DoubleCheck) + + if( sin != NULL )memcpy( &Connect[sockfd].sin , sin , len ); + memset( &Connect[sockfd].lastprocesstime, 0 , + sizeof(Connect[sockfd].lastprocesstime) ); + memcpy( &Connect[sockfd].lastCAsendtime, &NowTime , + sizeof(Connect[sockfd].lastCAsendtime) ); + memcpy( &Connect[sockfd].lastCDsendtime, &NowTime , + sizeof(Connect[sockfd].lastCDsendtime) ); + memcpy( &Connect[sockfd].lastCharSaveTime, &NowTime , + sizeof(Connect[sockfd].lastCharSaveTime) ); + // Shan Add + memcpy( &Connect[sockfd].lastrecvtime, &NowTime , + sizeof(Connect[sockfd].lastrecvtime) ); + memcpy( &Connect[sockfd].lastrecvtime_d, &NowTime , + sizeof(Connect[sockfd].lastrecvtime_d) ); + memcpy( &Connect[sockfd].battle_recvtime, &NowTime , + sizeof(Connect[sockfd].battle_recvtime) ); + +#ifdef _BLACK_MARKET + { + int i; + for(i=0; i<12; i++) + Connect[sockfd].BMSellList[i] = -1; + } +#endif + + memcpy( &Connect[sockfd].lastreadtime , &NowTime, + sizeof(struct timeval)); + Connect[sockfd].lastreadtime.tv_sec -= DEBUG_ADJUSTTIME; + + Connect[sockfd].errornum = 0; + Connect[sockfd].fdid = SERVSTATE_incrementFdid(); + + CONNECT_UNLOCK(sockfd); + + Connect[sockfd].appendwb_overflow_flag = 0; + return TRUE; +} + +ANYTHREAD BOOL _CONNECT_endOne( char *file, int fromline, int sockfd , int line ) +{ + CONNECT_LOCK_ARG2(sockfd,line); + + if( Connect[sockfd].use == FALSE ){ + CONNECT_UNLOCK_ARG2(sockfd,line); + //andy_log + print("连接已关闭[%d]!!\n", sockfd ); + return TRUE; + } + Connect[sockfd].use = FALSE; + if( Connect[sockfd].ctype == CLI && Connect[sockfd].charaindex >= 0 ){ + CONNECT_UNLOCK_ARG2( sockfd,line ); + if( !CHAR_logout( sockfd,TRUE )) { + print( "err %s:%d from %s:%d \n", __FILE__, __LINE__, file, fromline); + } + CONNECT_LOCK_ARG2( sockfd ,line); + } + + unsigned long ip; + int a,b,c,d; + int i; + ip=CONNECT_get_userip(sockfd); + a=(ip % 0x100); ip=ip / 0x100; + b=(ip % 0x100); ip=ip / 0x100; + c=(ip % 0x100); ip=ip / 0x100; + d=(ip % 0x100); + + print( "账号=%s 编号=%d\n", Connect[sockfd].cdkey,sockfd ); + + for(i=0;i= sizeof( Connect[fd].CAbuf ) ){ + CONNECT_UNLOCK(fd); + return FALSE; + } + + memcpy( Connect[fd].CAbuf + Connect[fd].CAbufsiz , data , size ); + Connect[fd].CAbuf[Connect[fd].CAbufsiz+size]=','; + Connect[fd].CAbufsiz += (size + 1); + CONNECT_UNLOCK(fd); + return TRUE; +} + +ANYTHREAD static int CONNECT_getCAbuf( int fd, char *out, int outmax, + int *outlen ) +{ + + CONNECT_LOCK(fd); + if( Connect[fd].use == TRUE ){ + int cplen = MIN( outmax, Connect[fd].CAbufsiz ); + memcpy( out, Connect[fd].CAbuf , cplen ); + *outlen = cplen; + CONNECT_UNLOCK(fd); + return 0; + } else { + CONNECT_UNLOCK(fd); + return -1; + } +} +ANYTHREAD static int CONNECT_getCDbuf( int fd, char *out, int outmax, + int *outlen ) +{ + CONNECT_LOCK(fd); + if( Connect[fd].use == TRUE ){ + int cplen = MIN( outmax, Connect[fd].CDbufsiz ); + memcpy( out, Connect[fd].CDbuf, cplen ); + *outlen = cplen; + CONNECT_UNLOCK(fd); + return 0; + } else { + CONNECT_UNLOCK(fd); + return 0; + } +} + +ANYTHREAD static int CONNECT_setCAbufsiz( int fd, int len ) +{ + CONNECT_LOCK(fd); + if( Connect[fd].use == TRUE ){ + Connect[fd].CAbufsiz = len; + CONNECT_UNLOCK(fd); + return 0; + } else { + CONNECT_UNLOCK(fd); + return -1; + } +} +ANYTHREAD static int CONNECT_setCDbufsiz( int fd, int len ) +{ + CONNECT_LOCK(fd); + if( Connect[fd].use == TRUE ){ + Connect[fd].CDbufsiz = len; + CONNECT_UNLOCK(fd); + return 0; + } else { + CONNECT_UNLOCK(fd); + return -1; + } +} + +ANYTHREAD static void CONNECT_setLastCAsendtime( int fd, struct timeval *t) +{ + CONNECT_LOCK(fd); + Connect[fd].lastCAsendtime = *t; + CONNECT_UNLOCK(fd); +} +ANYTHREAD static void CONNECT_getLastCAsendtime( int fd, struct timeval *t ) +{ + CONNECT_LOCK(fd); + *t = Connect[fd].lastCAsendtime; + CONNECT_UNLOCK(fd); +} +ANYTHREAD static void CONNECT_setLastCDsendtime( int fd, struct timeval *t ) +{ + CONNECT_LOCK(fd); + Connect[fd].lastCDsendtime = *t; + CONNECT_UNLOCK(fd); +} +ANYTHREAD static void CONNECT_getLastCDsendtime( int fd, struct timeval *t ) +{ + CONNECT_LOCK(fd); + *t = Connect[fd].lastCDsendtime; + CONNECT_UNLOCK(fd); +} +ANYTHREAD int CONNECT_getUse_debug( int fd, int i ) +{ + int a; + CONNECT_LOCK_ARG2(fd,i); + a = Connect[fd].use; + CONNECT_UNLOCK_ARG2(fd,i); + return a; + +} + +ANYTHREAD int CONNECT_getUse( int fd ) +{ + int a; + CONNECT_LOCK(fd); + a = Connect[fd].use; + CONNECT_UNLOCK(fd); + return a; +} +void CONNECT_setUse( int fd , int a) +//ANYTHREAD static void CONNECT_setUse( int fd , int a) +{ + CONNECT_LOCK(fd); + Connect[fd].use = a; + CONNECT_UNLOCK(fd); +} + +ANYTHREAD void CONNECT_checkStatecount( int a ) +{ + int i; + int count=0; + for( i=0; i < ConnectLen; i++ ){ + if( Connect[i].use == FALSE || Connect[i].state != a ) continue; + if( Connect[i].nstatecount <= 0 ){ + Connect[i].nstatecount=(int)time(NULL)+60; + }else{ + if( Connect[i].nstatecount < (int)time(NULL) ){ + CONNECT_endOne_debug(i); + close( i ); + count++; + } + } + } + { + memset(StateTable, 0, sizeof(StateTable)); + for (i=0; i < ConnectLen; i++) + if (Connect[i].use == TRUE) + StateTable[Connect[i].state]++; + } +} + +ANYTHREAD int CONNECT_checkStateSomeOne( int a, int maxcount) +{ + char temp[80],buffer[1024]; + int i, ret=1; + + if( StateTable[a] >= maxcount ) ret =-1; + buffer[0]=0; + for (i=0; i <= WHILESAVEWAIT; i++){ + sprintf(temp, "%4d", StateTable[i]); + strcat(buffer, temp); + } + print("\nNOW{{%s}}", buffer); + return ret; +} + +ANYTHREAD void CONNECT_setState( int fd, int a ) +{ + CONNECT_LOCK(fd); + Connect[fd].state = a; + Connect[fd].nstatecount = 0; + + // Nuke start 0829: For debugging + { + char temp[80],buffer[1024]; + int i; + memset(StateTable, 0, sizeof(StateTable)); + for (i=0; i < ConnectLen; i++) + if (Connect[i].use == TRUE) + StateTable[Connect[i].state]++; + + buffer[0]=0; + for (i=0; i <= WHILESAVEWAIT; i++){ + sprintf(temp, "%4d", StateTable[i]); + strcat(buffer, temp); + } + print("\n{{%s}}", buffer); + } + // Nuke end + + CONNECT_UNLOCK(fd); +} + +ANYTHREAD int CONNECT_getState( int fd ) +{ + int a; + CONNECT_LOCK(fd); + a = Connect[fd].state; + CONNECT_UNLOCK(fd); + return a; +} +ANYTHREAD void CONNECT_incrementErrornum(int fd ) +{ + CONNECT_LOCK(fd); + Connect[fd].errornum ++; + CONNECT_UNLOCK(fd); +} +ANYTHREAD void CONNECT_setCharaindex( int fd, int a ) +{ + CONNECT_LOCK(fd); + Connect[fd].charaindex = a; + CONNECT_UNLOCK(fd); +} +ANYTHREAD int CONNECT_getCharaindex( int fd ) +{ + int a; + CONNECT_LOCK(fd); + a = Connect[fd].charaindex; + CONNECT_UNLOCK(fd); + return a; +} +ANYTHREAD void CONNECT_getCdkey( int fd , char *out, int outlen ) +{ + CONNECT_LOCK(fd); + strcpysafe( out, outlen, Connect[fd].cdkey ); + CONNECT_UNLOCK(fd); +} +ANYTHREAD void +CONNECT_setCdkey( int sockfd, char *cd ) +{ + CONNECT_LOCK(sockfd); + snprintf( Connect[sockfd].cdkey, sizeof( Connect[sockfd].cdkey ),"%s", + cd ); + CONNECT_UNLOCK(sockfd); +} + +ANYTHREAD void CONNECT_getPasswd( int fd , char *out, int outlen ) +{ + CONNECT_LOCK(fd); + strcpysafe( out, outlen, Connect[fd].passwd ); + CONNECT_UNLOCK(fd); +} +ANYTHREAD void CONNECT_setPasswd( int fd, char *in ) +{ + CONNECT_LOCK(fd); + strcpysafe( Connect[fd].passwd, sizeof( Connect[fd].passwd ), in ); + CONNECT_UNLOCK(fd); +} +ANYTHREAD int CONNECT_getCtype( int fd ) +{ + int a; + CONNECT_LOCK(fd); + a = Connect[fd].ctype; + CONNECT_UNLOCK(fd); + return a; +} +ANYTHREAD void CONNECT_setCtype( int fd , int a ) +{ + CONNECT_LOCK(fd); + Connect[fd].ctype = a; + CONNECT_UNLOCK(fd); +} + +ANYTHREAD void CONNECT_getCharname( int fd , char *out, int outlen ) +{ + CONNECT_LOCK(fd); + strcpysafe( out, outlen, Connect[fd].charname ); + CONNECT_UNLOCK(fd); +} +ANYTHREAD void CONNECT_setCharname( int fd, char *in ) +{ + CONNECT_LOCK(fd); + strcpysafe( Connect[fd].charname, sizeof( Connect[fd].charname ), + in ); + CONNECT_UNLOCK(fd); +} + +ANYTHREAD int CONNECT_getFdid( int fd ) +{ + int a; + CONNECT_LOCK(fd); + a = Connect[fd].fdid; + CONNECT_UNLOCK(fd); + return a; +} +ANYTHREAD void CONNECT_setDuelcharaindex( int fd, int i , int a ) +{ + CONNECT_LOCK(fd); + Connect[fd].duelcharaindex[i]=a; + CONNECT_UNLOCK(fd); +} +ANYTHREAD int CONNECT_getDuelcharaindex( int fd, int i ) +{ + int a; + CONNECT_LOCK(fd); + a = Connect[fd].duelcharaindex[i]; + CONNECT_UNLOCK(fd); + return a; +} +ANYTHREAD void CONNECT_setBattlecharaindex( int fd, int i , int a ) +{ + CONNECT_LOCK(fd); + Connect[fd].battlecharaindex[i] = a; + CONNECT_UNLOCK(fd); +} +ANYTHREAD int CONNECT_getBattlecharaindex( int fd, int i ) +{ + int a; + CONNECT_LOCK(fd); + a = Connect[fd].battlecharaindex[i]; + CONNECT_UNLOCK(fd); + return a; +} +ANYTHREAD void CONNECT_setJoinpartycharaindex( int fd, int i , int a) +{ + CONNECT_LOCK(fd); + Connect[fd].joinpartycharaindex[i]=a; + CONNECT_UNLOCK(fd); +} +ANYTHREAD int CONNECT_getJoinpartycharaindex( int fd, int i ) +{ + int a; + CONNECT_LOCK(fd); + a = Connect[fd].joinpartycharaindex[i]; + CONNECT_UNLOCK(fd); + return a; +} + +// CoolFish: Trade 2001/4/18 +ANYTHREAD void CONNECT_setTradecharaindex( int fd, int i , int a ) +{ + CONNECT_LOCK(fd); + Connect[fd].tradecharaindex[i] = a; + CONNECT_UNLOCK(fd); +} + +// Shan Begin +ANYTHREAD void CONNECT_setLastrecvtime( int fd, struct timeval *a ) +{ + CONNECT_LOCK(fd); + Connect[fd].lastrecvtime = *a; + CONNECT_UNLOCK(fd); +} +ANYTHREAD void CONNECT_getLastrecvtime( int fd, struct timeval *a ) +{ + CONNECT_LOCK(fd); + *a = Connect[fd].lastrecvtime; + CONNECT_UNLOCK(fd); +} + +ANYTHREAD void CONNECT_setLastrecvtime_D( int fd, struct timeval *a ) +{ + CONNECT_LOCK(fd); + Connect[fd].lastrecvtime_d = *a; + CONNECT_UNLOCK(fd); +} +ANYTHREAD void CONNECT_getLastrecvtime_D( int fd, struct timeval *a ) +{ + CONNECT_LOCK(fd); + *a = Connect[fd].lastrecvtime_d; + CONNECT_UNLOCK(fd); +} +// 2001/12/26 +ANYTHREAD void CONNECT_SetBattleRecvTime( int fd, struct timeval *a ) +{ + CONNECT_LOCK(fd); + Connect[fd].battle_recvtime = *a; + CONNECT_UNLOCK(fd); +} +ANYTHREAD void CONNECT_GetBattleRecvTime( int fd, struct timeval *a ) +{ + CONNECT_LOCK(fd); + *a = Connect[fd].battle_recvtime; + CONNECT_UNLOCK(fd); +} +// Shan End + + +#ifdef _ITEM_PILEFORTRADE +ANYTHREAD void CONNECT_setTradeList( int fd, int num) +{ + Connect[fd].tradelist = num; +} +ANYTHREAD int CONNECT_getTradeList(int fd) +{ + return Connect[fd].tradelist; +} +#endif + +ANYTHREAD void CONNECT_setTradeTmp(int fd, char* a) +{ + CONNECT_LOCK(fd); + strcpysafe( Connect[fd].TradeTmp, sizeof(Connect[fd].TradeTmp), a); + + CONNECT_UNLOCK(fd); +} +ANYTHREAD void CONNECT_getTradeTmp(int fd, char *trademsg, int trademsglen) +{ + CONNECT_LOCK(fd); + strcpysafe(trademsg, trademsglen, Connect[fd].TradeTmp); + CONNECT_UNLOCK(fd); +} + +ANYTHREAD void CONNECT_setTradecardcharaindex( int fd, int i , int a ) +{ + CONNECT_LOCK(fd); + Connect[fd].joinpartycharaindex[i] = a; + CONNECT_UNLOCK(fd); +} +ANYTHREAD int CONNECT_getTradecardcharaindex( int fd, int i ) +{ + int a; + CONNECT_LOCK(fd); + a = Connect[fd].joinpartycharaindex[i]; + CONNECT_UNLOCK(fd); + return a; +} +ANYTHREAD int CONNECT_getClosed( int fd ) +{ +#if USE_MTIO + int a; + CONNECT_LOCK(fd); + a = Connect[fd].closed; + CONNECT_UNLOCK(fd); + return a; +#else + return 0; +#endif +} +ANYTHREAD void CONNECT_setClosed( int fd, int a ) +{ +#if USE_MTIO + CONNECT_LOCK(fd); + if( !Connect[fd].use){ + CONNECT_UNLOCK(fd); + return; + } + Connect[fd].closed =a; + CONNECT_UNLOCK(fd); +#endif +} +ANYTHREAD void CONNECT_setCloseRequest( int fd, int count ) +{ + CONNECT_LOCK(fd); + Connect[fd].close_request = count; + // Nuke + print("关闭请求设置为 %d ",fd); + CONNECT_UNLOCK(fd); +} + + +/*------------------------------------------------------------ + * CAcheck 卅升卞银歹木月楮醒[ 端卞霜月[ + * 娄醒 + * fd int 白央奶伙犯奴旦弁伉皿正 + * 忒曰袄 + * 卅仄 + ------------------------------------------------------------*/ +ANYTHREAD void CAsend( int fd ) +{ + char buf[sizeof(Connect[0].CAbuf)]; + int bufuse=0; + + if( CONNECT_getCAbuf( fd, buf, sizeof(buf), &bufuse ) < 0 )return; + if( bufuse == 0 )return; + + //print("\nshan--->(CAsend)->%s fd->%d", buf, fd); + + /* 及犯伉立正 ',' 毛'\0' 午井尹月*/ + buf[bufuse-1] = '\0'; + lssproto_CA_send( fd , buf ); + + CONNECT_setCAbufsiz( fd, 0 ); +} + + +/*------------------------------------------------------------ + * CA毛霜月[ + * 娄醒 + * 忒曰袄 + * 卅仄 + ------------------------------------------------------------*/ +ANYTHREAD void CAcheck( void ) +{ + int i; + unsigned int interval_us = getCAsendinterval_ms()*1000; + + /* Connect及蜊醒坌分仃支月井日褐中氏分卅[ */ + for( i = 0; i < ConnectLen; i ++) { + struct timeval t; + if( !CONNECT_getUse_debug(i,1008) )continue; + CONNECT_getLastCAsendtime( i, &t ); + if( time_diff_us( NowTime, t ) > interval_us ){ + CAsend( i); + CONNECT_setLastCAsendtime( i, &NowTime ); + } + } +} +ANYTHREAD void CAflush( int charaindex ) +{ + int i; + i = getfdFromCharaIndex( charaindex); + if( i == -1 )return; + CAsend(i); +} + + +/*------------------------------------------------------------ + * CDbuf 卞馨笛允月[ + * 娄醒 + * fd int 白央奶伙犯奴旦弁伉皿正 + * data char* 犯□正 + * size int 犯□正及扔奶术 + * 忒曰袄 + * 岳 TRUE(1) + * 撩 FALSE(0) + ------------------------------------------------------------*/ +ANYTHREAD BOOL CONNECT_appendCDbuf( int fd , char* data, int size ) +{ + CONNECT_LOCK(fd); + + if( ( Connect[fd].CDbufsiz + size ) >= sizeof( Connect[fd].CDbuf )){ + CONNECT_UNLOCK(fd); + return FALSE; + } + memcpy( Connect[fd].CDbuf + Connect[fd].CDbufsiz , data, size ); + Connect[fd].CDbuf[Connect[fd].CDbufsiz+size] = ','; + Connect[fd].CDbufsiz += ( size + 1 ); + CONNECT_UNLOCK(fd); + return TRUE; +} + + +/*------------------------------------------------------------ + * CDcheck 卅升卞银歹木月楮醒[ 端卞霜月[ + * 娄醒 + * fd int 白央奶伙犯奴旦弁伉皿正 + * 忒曰袄 + * 卅仄 + ------------------------------------------------------------*/ +ANYTHREAD void CDsend( int fd ) +{ + char buf[sizeof(Connect[0].CAbuf )]; + int bufuse=0; + if( CONNECT_getCDbuf( fd, buf, sizeof(buf), &bufuse ) < 0 ) return; + if( bufuse == 0 ) return; + buf[bufuse-1] = '\0'; + lssproto_CD_send(fd, buf ); + CONNECT_setCDbufsiz(fd,0); +} + + +/*------------------------------------------------------------ + * CD毛霜月[ + * 娄醒 + * 忒曰袄 + * 卅仄 + ------------------------------------------------------------*/ +ANYTHREAD void CDcheck( void ) +{ + int i; + unsigned int interval_us = getCDsendinterval_ms()*1000; + for(i=0; i interval_us ){ + CDsend( i); + CONNECT_setLastCDsendtime( i , &NowTime ); + } + } +} + +ANYTHREAD void CDflush( int charaindex ) +{ + int i; + i = getfdFromCharaIndex( charaindex); + if( i == -1 )return; + CDsend(i); +} + +void chardatasavecheck( void ) +{ + int i; + int interval = getCharSavesendinterval(); + static struct timeval chardatasavecheck_store; + if( NowTime.tv_sec > (chardatasavecheck_store.tv_sec +10)){ + chardatasavecheck_store = NowTime; + + for( i = 0; i < ConnectLen; i ++) { + CONNECT_LOCK(i); + if( Connect[i].use == TRUE + && Connect[i].state == LOGIN + && NowTime.tv_sec - Connect[i].lastCharSaveTime.tv_sec + > interval ){ + Connect[i].lastCharSaveTime = NowTime; + CONNECT_UNLOCK(i); + CHAR_charSaveFromConnect( i, FALSE ); + } else { + CONNECT_UNLOCK(i); + } + } + } else { + ; + } +} + + +#ifdef _DEATH_FAMILY_STRUCT // WON ADD 家族战存放胜负资料 +void Init_FM_PK_STRUCT() +{ + saacproto_Init_FM_PK_STRUC_send( acfd ); +} +#endif + +#ifdef _GM_BROADCAST // WON ADD 客服公告系统 +void Init_GM_BROADCAST( int loop, int time, int wait, char *msg ) +{ + int i, count = 0; + char *temp; + + BS.loop = loop; + BS.time = time; + BS.wait = wait; + BS.next_msg = 0; + + // 清空msg + memset( BS.msg, -1, sizeof(BS.msg) ); + + // 载入公告讯息 + if( ( temp = strtok( msg, " " ) ) ){ + strcpy( BS.msg[count], temp ); + for( i=1; i<10; i++ ){ + char *temp1; + if( ( temp1 = strtok( NULL, " " ) ) ){ + strcpy( BS.msg[++count], temp1 ); + } + } + } + + // 公告讯息数 + BS.max_msg_line = count; + + return; +} + +void GM_BROADCAST() +{ + int i; + static struct timeval broadcast; + int next_msg = BS.next_msg; + static int wait_time=0; + + if( BS.loop <= 0 ) return; + + if( NowTime.tv_sec > (broadcast.tv_sec + BS.time + wait_time) ){ + broadcast = NowTime; + wait_time = 0; + + if( BS.msg[next_msg] != NULL ){ + for( i = 0; i < ConnectLen; i ++) { + if( Connect[i].use == TRUE ){ + if( Connect[i].charaindex >= 0 ) + CHAR_talkToCli( Connect[i].charaindex, -1, BS.msg[next_msg], CHAR_COLORYELLOW); + } + } + } + + if( ++BS.next_msg > BS.max_msg_line ){ + BS.next_msg = 0; + wait_time = BS.wait; + + // BS.loop = 1000 时一直公告 + if( BS.loop < 1000 ) BS.loop--; + } + } +} +#endif + +/*------------------------------------------------------------ + * fd 互 valid 卅手及井升丹井毛譬屯月 + * 娄醒 + * fd int fd + * 忒曰袄 + * valid TRUE(1) + * invalid FALSE(0) + ------------------------------------------------------------*/ +ANYTHREAD INLINE int CONNECT_checkfd( int fd ) +{ + if( 0 > fd || fd >= ConnectLen ){ + return FALSE; + } + CONNECT_LOCK(fd); + if( Connect[fd].use == FALSE ){ + CONNECT_UNLOCK(fd); + return FALSE; + } else { + CONNECT_UNLOCK(fd); + return TRUE; + } +} + + +/*------------------------------------------------------------ + * cdkey 井日 fd 毛 月[ + * 娄醒 + * cd char* cdkey + * 忒曰袄 + * 白央奶伙犯奴旦弁伉皿正 方匀化} -1 及凛反巨仿□ + ------------------------------------------------------------*/ +ANYTHREAD int getfdFromCdkey( char* cd ) +{ + int i; + for( i = 0 ;i < ConnectLen ; i ++ ){ + CONNECT_LOCK(i); + if( Connect[i].use == TRUE && + strcmp( Connect[i].cdkey , cd ) == 0 ){ + CONNECT_UNLOCK(i); + return i; + } + CONNECT_UNLOCK(i); + } + return -1; +} + + +/*------------------------------------------------------------ + * charaindex 井日 fd 毛 月[ + * 陆质 及民尼永弁毛聂仁仄凶[ + * 娄醒 + * charaindex int 平乓仿及奶件犯永弁旦 + * 忒曰袄 + * 白央奶伙犯奴旦弁伉皿正 方匀化} -1 及凛反巨仿□ + ------------------------------------------------------------*/ +ANYTHREAD int getfdFromCharaIndex( int charaindex ) +{ +#if 1 + int ret; + if( !CHAR_CHECKINDEX( charaindex)) return -1; + if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER) return -1; + ret = CHAR_getWorkInt( charaindex, CHAR_WORKFD); + if( ret < 0 || ret >= ConnectLen ) return -1; + return ret; +#else + int i; + for( i = 0 ;i < ConnectLen ; i ++ ){ + CONNECT_LOCK(i); + if( Connect[i].use == TRUE + && Connect[i].charaindex == charaindex ){ + CONNECT_UNLOCK(i); + return i; + } + CONNECT_UNLOCK(i); + } + return -1; +#endif +} +/*------------------------------------------------------------ + * charaindex 井日 cdkey 毛 月[ + * 娄醒 + * charaindex int 平乓仿及奶件犯永弁旦 + * 忒曰袄 + * 0卅日岳 } 卅日撩 + ------------------------------------------------------------*/ +ANYTHREAD int getcdkeyFromCharaIndex( int charaindex , char *out, int outlen ) +{ + int i; + + for( i = 0 ;i < ConnectLen ; i ++ ){ + CONNECT_LOCK(i); + if( Connect[i].use == TRUE + && Connect[i].charaindex == charaindex ){ + snprintf( out, outlen, "%s" , Connect[i].cdkey ); + CONNECT_UNLOCK(i); + return 0; + } + CONNECT_UNLOCK(i); + } + return -1; +} + + +/*------------------------------------------------------------ + * 元fdid 及蛊毛茧允 + * 娄醒 + * fdid int fd及id + * 忒曰袄 + * -1 及凛反巨仿□ + ------------------------------------------------------------*/ +ANYTHREAD int getfdFromFdid( int fdid ) +{ + int i; + + for( i=0; i= 0 ){ + int a = Connect[i].charaindex; + CONNECT_UNLOCK(i); + return a; + } + CONNECT_UNLOCK(i); + } + + return -1; +} +/*------------------------------------------------------------ + * 平乓仿index 井日 fdid 毛手午户月[ + * 娄醒 + * charind int 白央奶伙犯奴旦弁伉皿正 + * 井尹曰切 fdid 分匀凶日平乓仿ind互云井仄中 + ------------------------------------------------------------*/ +ANYTHREAD int getFdidFromCharaIndex( int charind ) +{ + int i; + + for( i=0; i 10000 ) chikulatime = 0; +#ifdef _NPCSERVER_NEW + if( npcfd != -1) + NPCS_SendProbe( npcfd); +#endif + for (i=0;i 360 ){ + CONNECT_endOne_debug(i); + close(i); + } + } + // End + }//%30 + + if( chikulatime%30 == 0 ){ // 每300秒 + +#ifdef _ITEM_ADDEXP //vincent 经验提升 + if( CHAR_getWorkInt(Connect[i].charaindex,CHAR_WORKITEM_ADDEXP)>0 && + CHAR_getInt( Connect[i].charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ){ +#if 1 + int charaindex, exptime; + charaindex = Connect[i].charaindex; + exptime = CHAR_getWorkInt( charaindex, CHAR_WORKITEM_ADDEXPTIME) - 300; + if( exptime <= 0 ) { + CHAR_setWorkInt( charaindex, CHAR_WORKITEM_ADDEXP, 0); + CHAR_setWorkInt( charaindex, CHAR_WORKITEM_ADDEXPTIME, 0); + CHAR_talkToCli( charaindex,-1,"提升学习经验的能力消失了!",CHAR_COLORYELLOW); + } + else { + CHAR_setWorkInt( charaindex, CHAR_WORKITEM_ADDEXPTIME, exptime); + //print("\n 检查ADDEXPTIME %d ", exptime); + + if( (exptime % (60*60)) < 300 && exptime >= (60*60) ) + { + char msg[1024]; + sprintf( msg, "提升学习经验的能力剩大约 %d 小时。", (int)(exptime/(60*60)) ); + //sprintf( msg, "提升学习经验的能力剩大约 %d 分。", (int)(exptime/(60)) ); + CHAR_talkToCli( charaindex, -1, msg, CHAR_COLORYELLOW); + } + } +#else + if(Connect[i].EDTime < CHAR_getWorkInt(Connect[i].charaindex,CHAR_WORKITEM_ADDEXPTIME)){//功能作用有效期限 + Connect[i].EDTime=Connect[i].EDTime+300; + }else{ + Connect[i].EDTime = 0; + CHAR_setWorkInt( Connect[i].charaindex, CHAR_WORKITEM_ADDEXP, 0); + CHAR_setWorkInt( Connect[i].charaindex, CHAR_WORKITEM_ADDEXPTIME, 0); + CHAR_talkToCli(Connect[i].charaindex,-1,"提升学习经验的能力消失了!",CHAR_COLORYELLOW); + } +#endif + } +#endif +#ifdef _ITEM_METAMO + if( CHAR_getWorkInt( Connect[i].charaindex, CHAR_WORKITEMMETAMO) < NowTime.tv_sec + && CHAR_getWorkInt( Connect[i].charaindex, CHAR_WORKITEMMETAMO) != 0 ){ + CHAR_setWorkInt( Connect[i].charaindex, CHAR_WORKITEMMETAMO, 0); + CHAR_setWorkInt( Connect[i].charaindex, CHAR_WORKNPCMETAMO, 0 ); //与npc对话後的变身也要变回来 + CHAR_complianceParameter( Connect[i].charaindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( Connect[i].charaindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( Connect[i].charaindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + CHAR_talkToCli( Connect[i].charaindex,-1,"变身失效了。",CHAR_COLORWHITE); + } +#endif +#ifdef _ITEM_TIME_LIMIT + ITEM_TimeLimit(Connect[i].charaindex); // (可开放) shan time limit of item. code:shan +#endif + }//%30 + +#ifndef _USER_CHARLOOPS + //here 原地遇敌 + if( Connect[i].stayencount ) { + if( Connect[i].BDTime < time( NULL) ) { + if( CHAR_getWorkInt(Connect[i].charaindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE){ + lssproto_EN_recv( i, CHAR_getInt(Connect[i].charaindex,CHAR_X), + CHAR_getInt(Connect[i].charaindex,CHAR_Y)); + Connect[i].BDTime = time( NULL); + } + } + } +#endif +#ifdef _CHIKULA_STONE + if( chikulatime%3 == 0 && getChiStone( i) > 0) { //自动补血 + CHAR_AutoChikulaStone( Connect[i].charaindex, getChiStone( i)); + } +#endif + + if( chikulatime%6 == 0 ) { //水世界状态 +#ifdef _STATUS_WATERWORD + CHAR_CheckWaterStatus( Connect[i].charaindex); +#endif + // Nuke 0626: No enemy + if (Connect[i].noenemy>0) { + Connect[i].noenemy--; + if (Connect[i].noenemy==0) { + CHAR_talkToCli(CONNECT_getCharaindex(i),-1,"守护消失了。",CHAR_COLORWHITE); + } + } + } + //每10秒 +#ifdef _TYPE_TOXICATION //中毒 + if( Connect[i].toxication > 0 ){ + CHAR_ComToxicationHp( Connect[i].charaindex); + } +#endif + // Nuke 0624 Avoid Useless Connection + if (Connect[i].state == NOTLOGIN) { + Connect[i].cotime++; + if (Connect[i].cotime>30) { + print( "LATE" ); + CONNECT_endOne_debug(i); + close(i); + } + }else{ + Connect[i].cotime=0; + } + + if ((Connect[i].nu <= 22)) { + int r; + if (Connect[i].nu<=0) { + Connect[i].nu_decrease++; + if( Connect[i].nu_decrease >= 30 ) + Connect[i].nu_decrease = 30; + if (Connect[i].nu_decrease>22) logSpeed(i); + }else { + Connect[i].nu_decrease-=1; + if( Connect[i].nu_decrease < 0 ) + Connect[i].nu_decrease = 0; + } + r=22-Connect[i].nu_decrease; + r=(r>=15)?r:15; + lssproto_NU_send(i,r); + Connect[i].nu+=r; + } + // Nuke 1213: Flow control 2 + Connect[i].packetin--; // Remove a counter + if (Connect[i].packetin<=0) { // Time out, drop this line + print("Drop line: sd=%d\n",i); + CONNECT_endOne_debug(i); + close(i); + } +#ifdef _PETSKILL_BECOMEPIG + /*if( CHAR_getInt( Connect[i].charaindex, CHAR_BECOMEPIG) > -1 ){ //处於乌力化状态 + if( ( CHAR_getInt( Connect[i].charaindex, CHAR_BECOMEPIG ) - 10 ) <= 0 ){ //乌力时间结束了 + CHAR_setInt( Connect[i].charaindex, CHAR_BECOMEPIG, 0 ); + if( CHAR_getWorkInt( Connect[i].charaindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE ){ //不是在战斗状态下 + CHAR_setInt( Connect[i].charaindex, CHAR_BECOMEPIG, -1 );//结束乌力状态 + CHAR_complianceParameter( Connect[i].charaindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( Connect[i].charaindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( Connect[i].charaindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + CHAR_talkToCli( Connect[i].charaindex,-1,"乌力化失效了。",CHAR_COLORWHITE); + } + } + else{ + char temp[256]; + CHAR_setInt( Connect[i].charaindex, CHAR_BECOMEPIG, CHAR_getInt( Connect[i].charaindex, CHAR_BECOMEPIG ) - 10 ); + if( CHAR_getWorkInt( Connect[i].charaindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE ){ //不是在战斗状态下 + if( chikulatime%6 == 0 ){//60秒 + sprintf(temp, "乌力时间:%d秒", CHAR_getInt( Connect[i].charaindex, CHAR_BECOMEPIG )); + CHAR_talkToCli( Connect[i].charaindex,-1,temp,CHAR_COLORWHITE); + } + } + } + }*/ + if( CHAR_getWorkInt( Connect[i].charaindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE ){ //不是在战斗状态下 + if( CHAR_getInt( Connect[i].charaindex, CHAR_BECOMEPIG) > -1 ){ //处於乌力化状态 + char temp[256]; + sprintf(temp, "乌力时间:%d秒", CHAR_getInt( Connect[i].charaindex, CHAR_BECOMEPIG )); + CHAR_talkToCli( Connect[i].charaindex,-1,temp,CHAR_COLORWHITE); + } + } +#endif + //10秒 +#ifdef _MAP_TIME + if(CHAR_getWorkInt(Connect[i].charaindex,CHAR_WORK_MAP_TIME) > 0 + && CHAR_getWorkInt(Connect[i].charaindex,CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE){ + CHAR_setWorkInt(Connect[i].charaindex,CHAR_WORK_MAP_TIME,CHAR_getWorkInt(Connect[i].charaindex,CHAR_WORK_MAP_TIME) - 10); + if(CHAR_getWorkInt(Connect[i].charaindex,CHAR_WORK_MAP_TIME) <= 0){ + // 时间到了,传回入口 + CHAR_talkToCli(Connect[i].charaindex,-1,"你因为受不了高热而热死!传回裂缝入口。",CHAR_COLORRED); + CHAR_warpToSpecificPoint(Connect[i].charaindex,30008,39,38); + CHAR_setInt(Connect[i].charaindex,CHAR_HP,1); + CHAR_AddCharm(Connect[i].charaindex,-3); + CHAR_send_P_StatusString(Connect[i].charaindex,CHAR_P_STRING_HP); + CHAR_send_P_StatusString(Connect[i].charaindex,CHAR_P_STRING_CHARM); + } + else{ + char szMsg[64]; + sprintf(szMsg,"在这高热的环境下你只能再待 %d 秒。",CHAR_getWorkInt(Connect[i].charaindex,CHAR_WORK_MAP_TIME)); + CHAR_talkToCli(Connect[i].charaindex,-1,szMsg,CHAR_COLORRED); + } + } +#endif + } + } + } + +#ifdef _PETSKILL_BECOMEPIG + if( checkT2 != NowTimes && (checkT2) <= NowTimes ) { + int i; + checkT2 = time(NULL); + ++chikulatime2;//每1秒 + if( chikulatime2 > 1000 ) chikulatime2 = 0; + for (i=0;i -1 ){ //处於乌力化状态 + if( ( CHAR_getInt( Connect[i].charaindex, CHAR_BECOMEPIG ) - 1 ) <= 0 ){ //乌力时间结束了 + CHAR_setInt( Connect[i].charaindex, CHAR_BECOMEPIG, 0 ); + if( CHAR_getWorkInt( Connect[i].charaindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE ){ //不是在战斗状态下 + CHAR_setInt( Connect[i].charaindex, CHAR_BECOMEPIG, -1 );//结束乌力状态 + CHAR_complianceParameter( Connect[i].charaindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( Connect[i].charaindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( Connect[i].charaindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + CHAR_talkToCli( Connect[i].charaindex,-1,"乌力化失效了。",CHAR_COLORWHITE); + } + } + else{ + CHAR_setInt( Connect[i].charaindex, CHAR_BECOMEPIG, CHAR_getInt( Connect[i].charaindex, CHAR_BECOMEPIG ) - 1 ); + } + } + } + } + } +#endif + +} + +// Nuke 0126: Resource protection +int isThereThisIP(unsigned long ip) +{ + int i; + unsigned long ipa; + for(i = 0; i< ConnectLen ; i++ ) + if( !Connect[i].use ) continue; + if( Connect[i].state == NOTLOGIN || Connect[i].state == WHILEDOWNLOADCHARLIST ) { + memcpy(&ipa,&Connect[i].sin.sin_addr,4); + if (ipa==ip) return 1; + } + return 0; +} + +#if USE_MTIO == 0 + +int player_online = 0; + +SINGLETHREAD BOOL netloop_faster( void ) +{ + + int ret , loop_num; + struct timeval tmv; /*timeval*/ + static int fdremember = 0; + + static unsigned int total_item_use=0; + static int petcnt=0; +// static unsigned int nu_time=0; + struct timeval st, et; + unsigned int casend_interval_us , cdsend_interval_us; + int acceptmore = SERVSTATE_getAcceptmore(); + fd_set fdset; + unsigned int looptime_us; + int allowerrornum = getAllowerrornum(); + int acwritesize = getAcwriteSize(); +#ifdef _AC_PIORITY + static int flag_ac=1; + static int fdremembercopy=0; + static int totalloop=0; + static int totalfd=0; + static int totalacfd=0; + static int counter=0; +#endif + +#if 0 +#ifdef _M_SERVER + static unsigned int m_time=0; + unsigned int mm; + static int connectnum = 0; + + if (mfd < 0){ + mm=time(NULL); + if( (mm - m_time > 120) && connectnum < 5 ){ + m_time = mm; + mfd = connectmServer(getmservername(),getmserverport()); + connectnum ++; + if (mfd != -1){ + initConnectOne(mfd,NULL,0); + print("connect to mserver successed\n"); + connectnum = 0; //重设连线次数 + }else{ + print("connect to mserver failed\n"); + } + } + }else { + connectnum = 0; + } +#endif +#endif + +/* + { + int errorcode; + int errorcodelen; + int qs; + + errorcodelen = sizeof(errorcode); + qs = getsockopt( acfd, SOL_SOCKET, SO_RCVBUF , &errorcode, &errorcodelen); + //andy_log + print("\n\n GETSOCKOPT SO_RCVBUF: [ %d, %d, %d] \n", qs, errorcode, errorcodelen); + } +*/ +#ifdef _NPCSERVER_NEW + { + static unsigned int NStime=0; + static int connectNpcnum = 0; + if( (NStime + 120) < time(NULL) && connectNpcnum < 10 ){ + NStime = time(NULL); + if (npcfd < 0){ + npcfd = connectNpcServer( getnpcserveraddr(), getnpcserverport()); + connectNpcnum ++; + if (npcfd != -1){ + initConnectOne( npcfd, NULL, 0); + print("connect to NpcServer successed\n"); + NPCS_NpcSLogin_send( npcfd); + connectNpcnum = 0; //重设连线次数 + } + }else { + connectNpcnum = 0; + } + } + } +#endif + looptime_us = getOnelooptime_ms()*1000 ; + casend_interval_us = getCAsendinterval_ms()*1000; + cdsend_interval_us = getCDsendinterval_ms()*1000; + + FD_ZERO( &fdset ); + FD_SET( bindedfd ,& fdset); + tmv.tv_sec = tmv.tv_usec = 0; + ret = select( bindedfd + 1 , &fdset,(fd_set*)NULL,(fd_set*)NULL,&tmv ); + if( ret < 0 && ( errno != EINTR )){ + print( "accept select() error:%s\n", strerror(errno)); + } + if( ret > 0 && FD_ISSET(bindedfd , &fdset ) ){ + struct sockaddr_in sin; + int addrlen=sizeof( struct sockaddr_in ); + int sockfd; + sockfd = accept( bindedfd ,(struct sockaddr*) &sin , &addrlen ); + if( sockfd == -1 && errno == EINTR ){ + ; + }else if( sockfd != -1 ){ + unsigned long sinip; + int cono=1, from_acsv = 0; + if (cono_check&CONO_CHECK_LOGIN){ + if( StateTable[WHILELOGIN]+StateTable[WHILELOGOUTSAVE] > QUEUE_LENGTH1 || + StateTable[WHILEDOWNLOADCHARLIST] > QUEUE_LENGTH2 ){ + print("err State[%d,%d,%d]!!\n", StateTable[WHILELOGIN], + StateTable[WHILELOGOUTSAVE], + StateTable[WHILEDOWNLOADCHARLIST] ); + + CONNECT_checkStatecount( WHILEDOWNLOADCHARLIST); + cono=0; + } + } + if (cono_check&CONO_CHECK_ITEM) + if (total_item_use >= MAX_item_use){ + print("err item_use full!!"); + cono=0; + } + if (cono_check&CONO_CHECK_PET) + if( petcnt >= CHAR_getPetMaxNum() ){ + print("err pet_use full!!"); + cono=0; + } + + { + char temp[80]; + sprintf(temp,"%d.%d.%d.%d", + ((unsigned char *)&sin.sin_addr)[0], + ((unsigned char *)&sin.sin_addr)[1], + ((unsigned char *)&sin.sin_addr)[2], + ((unsigned char *)&sin.sin_addr)[3]); + if (strcmp(getAccountservername(),temp)==0) { + cono=1; from_acsv=1; + print("From acsv. "); + } +#ifdef _M_SERVER + if (strcmp(getmservername(),temp) == 0){ + cono=1; + print("From mserver\n"); + } +#endif + } + //print("CO"); + + { + float fs=0.0; + if( (fs = ((float)Connect[acfd].rbuse/AC_RBSIZE) ) > 0.6 ){ + print( "andy AC rbuse: %3.2f [%4d]\n", fs, Connect[acfd].rbuse ); + if( fs > 0.78 ) cono = 0; + } + } + + memcpy( &sinip, &sin.sin_addr, 4); + // Nuke *1 0126: Resource protection + if((cono == 0) || (acceptmore <= 0) || isThereThisIP( sinip) ){ + // Nuke +2 Errormessage + char mess[1024]="E伺服器忙线中,请稍候再试。"; + if (!from_acsv) + write(sockfd,mess,strlen(mess)+1); + print( "accept but drop[cono:%d,acceptmore:%d]\n", cono, acceptmore); + close( sockfd ); + }else if( sockfd < ConnectLen ){ + char mess[1024] = "A";// Nuke +2 Errormessage + if( bNewServer ) +#ifdef _SA_VERSION_70 // WON ADD 石器时代7.0 的版本控制 + mess[0]='F'; // 7.0 +#endif + else + mess[0]='$'; + + //char mess[1024]="E伺服器忙线中,请稍候再试。"; + if (!from_acsv) + send(sockfd,mess,strlen(mess)+1,0); + initConnectOne(sockfd,&sin,addrlen); + if( getNodelay() ){ + int flag = 1; + int result = setsockopt( sockfd, IPPROTO_TCP, TCP_NODELAY, + (char*)&flag, sizeof(int)); + if( result < 0 ){ + print("setsockopt TCP_NODELAY failed:%s\n", + strerror( errno )); + } else { + print( "NO" ); + } + } + }else { + // Nuke +2 Errormessage + char mess[1024]="E伺服器人数已满,请稍候再试。"; + if (!from_acsv) write(sockfd,mess,strlen(mess)+1); + close( sockfd ); + // Nuke +1 0901: Why close + } + } + } + loop_num=0; + gettimeofday( &st, NULL ); + while(1) + { + char buf[65535*2]; + int j; + //ttom+1 for the debug + static int i_tto=0; + static int i_timeNu=0; + + gettimeofday( &et, NULL ); + if( time_diff_us( et,st) >= looptime_us ) //执行每超过0.1秒资要做的的工作 + { +#define LOOP_NUM_ADD_CREDIT 5 +#define CREDIT_SPOOL 3 + switch( acceptmore) + { + case -1: + print( "#"); +#ifdef _KILL_12_STOP_GMSV // WON ADD 下sigusr2後关闭GMSV + //andy_reEdit 2003/04/28 + //system("./stop.sh"); +#endif + break; + case 0: + print( "$"); + if(!b_first_shutdown) + { + b_first_shutdown=TRUE; + i_shutdown_time=SERVSTATE_getLimittime(); + print("\n 关闭服务器时间=%d",i_shutdown_time); + } + break; + default: + { + static int i_counter=0; + // Syu ADD 定时读取Announce + static int j_counter=0; + // Syu ADD 每小时重新更新英雄战厂排行榜资料 + static int h_counter=0; + // 不会归零的计时器 + static long total_count=0; + + int i; + int item_max; + + if(i_counter>10) + {//10秒 + player_online = 0;//looptime_us +#ifdef _AC_PIORITY + //print("\n", + // (totalfd*1.0)/(totalloop*1.0), + // totalfd,totalloop,totalacfd); + totalloop=0; totalfd=0; totalacfd=0; +#endif + i_counter=0; + item_max = ITEM_getITEM_itemnum(); + total_item_use = ITEM_getITEM_UseItemnum(); + for (i=0;i 60*10 ) + {//6000 约 600秒=10分钟 + j_counter=0; + print("\n定时读取公告"); + LoadAnnounce(); +#ifdef _CHECK_BATTLETIME + check_battle_com_show(); +#endif + } + /* + #ifdef _ALLDOMAN // Syu ADD 排行榜NPC + // Syu ADD 每小时重新更新英雄战厂排行榜资料 + if ( h_counter > 60*60 ){//36000 约 3600秒=60分钟 + h_counter=0; + print("\nSyu log LoadHerolist"); + saacproto_UpdataStele_send ( acfd , "FirstLoad", "LoadHerolist" , "华义" , 0 , 0 , 0 , 999 ) ; + } + #endif + */ + if( i_timeNu != time(NULL) ) // 每整秒执行一次 + { + i_timeNu = time(NULL); + +#ifdef _DEL_DROP_GOLD + //if( total_count % 60 == 0 ) { //每分钟执行 + // GOLD_DeleteTimeCheckLoop(); + //} +#endif + //if( total_count % 60*10 == 0 ) { //每10分钟执行 + //} + + //if( total_count % 60*60 == 0 ) { //每60分钟执行 + //} + + + i_counter++; + // Syu ADD 定时读取Announce + j_counter++; + // Syu ADD 每小时重新更新英雄战厂排行榜资料 + h_counter++; + + total_count++; + } + } + + if((i_tto%60)==0) + { + i_tto=0; + print("."); + } +#ifdef _TEST_PETCREATE + if(i_tto % 30 ==0 ) + { + TEST_CreatPet(); + } +#endif + i_tto++; + + //andy add 2003/0212------------------------------------------ + CONNECT_SysEvent_Loop( ); + //------------------------------------------------------------ + } // switch() +#ifdef _AC_PIORITY + if (flag_ac==2) fdremember=fdremembercopy; + flag_ac=1; + totalloop++; +#endif + break; // Break while + } // if(>0.1sec) + + loop_num++; + +#ifdef _AC_PIORITY + switch (flag_ac) + { + case 1: + fdremembercopy=fdremember; + fdremember=acfd; + flag_ac=2; + break; + case 2: + counter++; + if (counter>=3) + { + counter=0; + fdremember=fdremembercopy+1; + flag_ac=0; + } + break; + default: + fdremember++; + break; + } +#else + fdremember++; +#endif + if( fdremember == ConnectLen ) fdremember =0; + if( Connect[fdremember].use == FALSE )continue; + if( Connect[fdremember].state == WHILECLOSEALLSOCKETSSAVE ) continue; +#ifdef _AC_PIORITY + totalfd++; + if (fdremember==acfd) totalacfd++; +#endif + /* read select */ + FD_ZERO( &fdset ); + FD_SET( fdremember , &fdset ); + tmv.tv_sec = tmv.tv_usec = 0; + ret = select( fdremember + 1, &fdset, (fd_set*)NULL,(fd_set*)NULL,&tmv); + if( ret > 0 ){ + if( FD_ISSET( fdremember, &fdset ) ){ + errno = 0; + memset( buf, 0, sizeof( buf)); + ret = read( fdremember, buf, sizeof(buf)); + if( ret > 0 && sizeof( buf ) <= ret ){ + print( "Read(%s) buf len:%d - %d !!\n", (fdremember==acfd)?"AC":"OTHERFD", ret, sizeof(buf) ); + } + + if( ret == -1 && errno == EINTR ){ + ; + } else if( ret == -1 || ret == 0 ){ + if( fdremember == acfd ){ + print( "read return:%d %s\n",ret,strerror(errno)); + print( "netloop_faster: acsv is down! aborting...\n" ); + shutdownProgram(); + exit(1); +#ifdef _M_SERVER + }else if ( fdremember == mfd ) { + CONNECT_endOne_debug(fdremember); + close(fdremember); + mfd = -1; +#endif +#ifdef _NPCSERVER_NEW + }else if ( fdremember == npcfd ) { + CONNECT_endOne_debug(fdremember); + close(fdremember); + npcfd = -1; + +#endif + } else { + if( ret == -1 ) + print( "读取返回: %d %s \n", errno, strerror( errno)); + + print( "\n玩家" ); + CONNECT_endOne_debug(fdremember ); + close( fdremember ); + continue; + } + } else { + + if( appendRB( fdremember, buf, ret ) == -2 && getErrUserDownFlg() == 1){ + CONNECT_endOne_debug(fdremember ); + close( fdremember ); + continue; + }else{ + Connect[fdremember].lastreadtime = NowTime; + Connect[fdremember].lastreadtime.tv_sec -= + DEBUG_ADJUSTTIME; + Connect[fdremember].packetin = 30; + } + } + } else { + } + } else if( ret < 0 && errno != EINTR){ + print( "读取选择错误:%s\n", strerror( errno )); + } + + for( j = 0; j < 3; j ++ ) { + char rbmess[65535*2]; + memset( rbmess, 0, sizeof( rbmess)); + if( GetOneLine_fix( fdremember, rbmess, sizeof(rbmess)) == FALSE )continue; + if( !( (rbmess[0]== '\r' && rbmess[1] == '\n') || rbmess[0] == '\n') ){ + if( fdremember == acfd ){ + if( saacproto_ClientDispatchMessage( fdremember, rbmess)< 0){ + } +#ifdef _M_SERVER + }else if ( fdremember == mfd ) { + if ( mproto_ClientDispatchMessage( fdremember, rbmess) < 0) {} +#endif +#ifdef _NPCSERVER_NEW + }else if ( fdremember == npcfd ) { + if (NSproto_DispatchMessage(fdremember,rbmess) < 0) {} + +#endif + }else{ + if( lssproto_ServerDispatchMessage( fdremember, rbmess )< 0){ + //print(" DispatchMsg_Error!!! "); + Connect[fdremember].errornum ++; + } + } + } + if( Connect[fdremember].errornum > allowerrornum ){ + print( "Too many Errors:%s close\n", + inet_ntoa(Connect[fdremember].sin.sin_addr )); + CONNECT_endOne_debug(fdremember); + close(fdremember); + break; + } + } + if( Connect[fdremember].errornum > allowerrornum ){ + continue; + } + if( Connect[fdremember].CAbufsiz > 0 && + time_diff_us( et, Connect[fdremember].lastCAsendtime) + > casend_interval_us ){ + CAsend( fdremember); + Connect[fdremember].lastCAsendtime = et; + } + if( Connect[fdremember].CDbufsiz > 0 && + time_diff_us( et, Connect[fdremember].lastCDsendtime) + > cdsend_interval_us ){ + CDsend( fdremember); + Connect[fdremember].lastCDsendtime = et; + } + if( Connect[fdremember].wbuse >0 ){ + FD_ZERO( &fdset ); + FD_SET( fdremember, &fdset ); + tmv.tv_sec = tmv.tv_usec = 0; + ret = select( fdremember + 1, + (fd_set*)NULL, &fdset, (fd_set*)NULL,&tmv); + + if( ret > 0 ){ + if( FD_ISSET( fdremember , &fdset ) ){ + //Nuke start 0907: Protect gmsv + if (fdremember == acfd) { + ret = write( fdremember , Connect[fdremember].wb , + ( Connect[fdremember].wbuse < acwritesize) ? + Connect[fdremember].wbuse : acwritesize ); + } else { +#ifdef _BACK_VERSION + ret = write( fdremember , Connect[fdremember].wb , + ( Connect[fdremember].wbuse < acwritesize) ? + Connect[fdremember].wbuse : acwritesize ); +#else + ret = write( fdremember , Connect[fdremember].wb , + ( Connect[fdremember].wbuse < 16384) ? + Connect[fdremember].wbuse : 16384 ); +#endif + } + // Nuke end + + if( ret == -1 && errno == EINTR ){ + ; + } else if( ret == -1 ){ + CONNECT_endOne_debug(fdremember ); + close( fdremember ); +#ifdef _M_SERVER + if (fdremember == mfd ) mfd =-1; +#endif +#ifdef _NPCSERVER_NEW + if (fdremember == npcfd ) npcfd =-1; +#endif + continue; + } else if( ret > 0 ){ + shiftWB( fdremember, ret ); + } + } + } else if( ret < 0 && errno != EINTR ){ + print( "select() error:%s\n", strerror(errno)); + } + } + /* 正奶丞失它玄及质 */ + if( fdremember == acfd +#ifdef _M_SERVER + || fdremember == mfd +#endif +#ifdef _NPCSERVER_NEW + || fdremember == npcfd +#endif + ) + continue; + + //ttom start : because of the second have this + if( Connect[fdremember].close_request ){ + print( "强迫关闭:%s \n", + inet_ntoa(Connect[fdremember].sin.sin_addr )); + CONNECT_endOne_debug(fdremember); + close(fdremember); + continue; + } + //ttom end + } + return TRUE; +} +#endif /* if USE_MTIO == 0 */ + +ANYTHREAD void outputNetProcLog( int fd, int mode) +{ + int i; + int c_use=0,c_notdetect=0 ; + int c_ac=0, c_cli=0 , c_adm =0, c_max=0; + int login=0; + char buffer[4096]; + char buffer2[4096]; + + strcpysafe(buffer,sizeof(buffer), "Server Status\n"); + c_max = ConnectLen; + + + for(i=0;i= 0 ){ + login ++; + } + } + CONNECT_UNLOCK(i); + } + + snprintf( buffer2 , sizeof( buffer2 ) , + "connect_use=%d\n" + "connect_notdetect=%d\n" + "connect_ac=%d\n" + "connect_cli=%d\n" + "connect_adm=%d\n" + "connect_max=%d\n" + "login=%d\n", + c_use , c_notdetect,c_ac,c_cli,c_adm,c_max,login ); + strcatsafe( buffer , sizeof(buffer),buffer2 ); + { + int char_max = CHAR_getCharNum(); + int char_use = 0 ; + int pet_use = 0; + for(i=0;i + +/* + 邰卅 醒凶切 + */ +pthread_t main_thread , io_thread; +int mt_r1, mt_r2; + +/* + IO旦伊永玉及 匹及夫弘 + */ +MUTLITHREAD void MTIO_print( char *s ) +{ + fprintf( stderr , "%s", s ); +} + +/* + + 穴伙民旦伊永玉棕雁毛赓渝祭允月 + + */ +static void MTIO_loop( void ); +void mainloop(void); /* main.c */ +SINGLETHREAD int +MTIO_setup( void ) +{ + if( pthread_create( &main_thread , NULL , (void *)mainloop, + &mt_r1 ) ){ + print( "cannot create main thread\n" ); + return -1; + } + if( pthread_create( &io_thread , NULL, (void*)MTIO_loop, &mt_r2 ) ){ + print( "cannot create io thread\n" ); + return -1; + } + return 0; +} +SINGLETHREAD void +MTIO_join( void ) +{ + pthread_join( main_thread, NULL ); + pthread_join( io_thread, NULL ); +} + + +/* + * 引月切允木匀升 appendRB + * TRUE : 岳 + * FALSE : 撩 + * + * 签账仇及丹尹卅中卅[ + */ +MUTLITHREAD static BOOL MTIO_appendRB( int conindex, char *src, int length ) +{ + CONNECT_LOCK(conindex); + if( ( Connect[conindex].rbuse + length ) > MTIO_FIXED_BUFSIZE ){ + CONNECT_UNLOCK(conindex); + return FALSE; + } + memcpy( Connect[conindex].rb + Connect[conindex].rbuse , + src, length ); + Connect[conindex].rbuse += length; + + CONNECT_UNLOCK(conindex); + + return TRUE; +} +MUTLITHREAD static BOOL MTIO_appendWB( int conindex, char *src, int length ) +{ + CONNECT_LOCK(conindex); + if( ( Connect[conindex].wbuse + length ) > MTIO_FIXED_BUFSIZE ){ + CONNECT_UNLOCK(conindex); + return FALSE; + } + memcpy( Connect[conindex].wb + Connect[conindex].wbuse , + src, length ); + Connect[conindex].wbuse += length; + + CONNECT_UNLOCK(conindex); + return FALSE; +} + +MUTLITHREAD static void MTIO_shiftWB( int conindex, int len ) +{ + CONNECT_LOCK(conindex); + memmove( Connect[conindex].wb, Connect[conindex].wb + len, + Connect[conindex].wbuse - len ); + Connect[conindex].wbuse -= len; + CONNECT_UNLOCK(conindex); +} + +/* + 1垫午曰分允[午曰分仄凶卅互今毛井尹允 + 嫖簧祭及凶户} outlen 卞反勾友卞蜗坌卅扔奶术互反中匀化月午移烂允月冗 + */ +MUTLITHREAD int MTIO_getOneLine( int conindex, char *out, int outlen ) +{ + int i; + char *p; + CONNECT_LOCK(conindex); + + p = Connect[conindex].rb; + for(i=0 ; i < (outlen-1) && i < Connect[conindex].rbuse ; i++ ){ + out[i] = p[i]; + if( p[i] == '\n' ){ + int len = i+1; + /* 敦岳仄化中月″″*/ + memmove( Connect[conindex].rb, Connect[conindex].rb+len, + Connect[conindex].rbuse - len ); + Connect[conindex].rbuse -= len; + CONNECT_UNLOCK(conindex); + out[len]=0; + + return len; + } + } + /* 垫反卅中 */ + CONNECT_UNLOCK(conindex); + return 0; +} + + + +/* + IO 分仃毛支月捩菁伙□皿 + */ +MUTLITHREAD static void +MTIO_loop( void ) +{ + while(1){ + int ret , i; + fd_set fds; + struct timeval tmv; + char tmp[MTIO_FIXED_BUFSIZE]; + + MTIO_print("$"); +#if MTIO_DEBUG_LOG_REDUCE + usleep( 100 * 1000 ); +#endif + + /* 引内accept仄切扎丹升 */ + tmv.tv_sec = tmv.tv_usec = 0; + FD_ZERO( &fds ); + FD_SET( bindedfd, &fds ); + ret = select( bindedfd+1, &fds, (fd_set*)NULL,(fd_set*)NULL,&tmv); + if( ret > 0 && FD_ISSET( bindedfd, &fds ) ){ + struct sockaddr_in sin; + int addrlen = sizeof( struct sockaddr_in ); + int sockfd; + sockfd = accept( bindedfd, (struct sockaddr*) &sin, &addrlen ); + if( sockfd == -1 && errno == EINTR ){ + ; + } else if( sockfd != -1 ){ + int acceptmore = SERVSTATE_getAcceptmore(); + MTIO_print("CO" ); + if( acceptmore <= 0 ){ + MTIO_print( "accept but drop\n" ); + close( sockfd ); + } else if( sockfd < ConnectLen ){ + if( getNodelay() ){ + + int flag = 1, result; + result = setsockopt( sockfd, IPPROTO_TCP, TCP_NODELAY, + (char*)&flag,sizeof(int)); + if( result == 0 ) MTIO_print( "NO" ); + } + initConnectOne( sockfd,&sin, addrlen ); + } else { + MTIO_print( "CO_full" ); + close(sockfd ); + } + } + } /* FD_ISSET */ + + FD_ZERO( &fds ); + for(i = 0; i< ConnectLen ; i++ ){ + CONNECT_LOCK(i); + if( Connect[i].use ) FD_SET( i , &fds ); + CONNECT_UNLOCK(i); + } + /* 穴伙民旦伊永玉卅及匹谨匀化手方中及分[ 50ms引匀化心月*/ + tmv.tv_sec = 0; + tmv.tv_usec = 50 * 1000; + ret = select( ConnectLen+1, &fds, (fd_set*)NULL,(fd_set*)NULL,&tmv ); + if( ret > 0 ) { + for(i=0;i 0 ){ + MTIO_appendRB( i, tmp, r ); + } else { + if( i == acfd ){ + MTIO_print( "saac is down???? \n" ); + sigshutdown( -1 ); + exit(1); + } else { + MTIO_print("REr" ); + /* 穴伙民旦伊永玉匹反}白仿弘毛凶化月分仃卞允月 */ + CONNECT_setClosed(i,1); + } + } + } + } + /* 勾亢卞write */ + FD_ZERO( &fds ); + for(i=0;i 0 ) FD_SET( i ,&fds ); + CONNECT_UNLOCK_ARG2(i,2620); + } + tmv.tv_sec = tmv.tv_usec = 0; + ret = select( ConnectLen+1, (fd_set*)NULL,&fds,(fd_set*)NULL,&tmv); + if( ret > 0 ) { + for(i=0;i 0 ){ + MTIO_shiftWB( i, w ); + } else if( w == -1 ){ + MTIO_print( "WEr" ); + CONNECT_setClosed(i,1); + close(i); + continue; + } + } + } + } +} +/* + I/O匹卅中旦伊永玉井日及心裟壬木月[ + close反I/O旦伊永玉匹反域濠方壬卅中 + */ +MUTLITHREAD static void closeCheck( void ) +{ + int i; + for(i=0;i allowerrornum ){ + CONNECT_setClosed(i,1); + close(i); + continue; + } + } + } + { + static struct timeval cacd_check_store_time; + if( time_diff( NowTime , cacd_check_store_time ) > 0.1 ){ + cacd_check_store_time = NowTime; + CAcheck(); + CDcheck(); + closeCheck(); + MTIO_print("!"); + } + } + return TRUE; +} + +MUTLITHREAD int lsrpcClientWriteFunc( int fd , char* buf , int size ) +{ + int r; + + if( CONNECT_getUse_debug(fd,2573) == FALSE ){ + return FALSE; + } + r = MTIO_appendWB( fd, buf, size ); + return r; +} + + +#endif /* if USE_MTIO */ +// Nuke start 08/27: For acceleration avoidance +//ttom+1 +#define m_cktime 500 +//static float m_cktime=0; + +int checkWalkTime(int fd) +{ + int me, interval; + //ttom + float f_Wtime,f_WLtime,f_interval; + // Nuke + return 0; + + //ARM&Tom correct + //me=CONNECT_getCharaindex(fd); + me=fd; + Connect[me].Walktime = time(0); + gettimeofday( &Connect[me].Wtime, (struct timezone*)NULL);// + interval = abs(Connect[me].Walktime - Connect[me].lastWalktime); + //ttom + f_Wtime =Connect[me].Wtime.tv_sec*1000+Connect[me].Wtime.tv_usec/1000; + f_WLtime=Connect[me].WLtime.tv_sec*1000+Connect[me].WLtime.tv_usec/1000; + f_interval=abs(f_Wtime-f_WLtime); + //ttom + Connect[me].Walkrestore--; + + if (Connect[me].Walkrestore <= 0) { + //print("Walkspool restored "); + Connect[me].Walkspool = WALK_SPOOL; + Connect[me].Walkrestore = WALK_RESTORE; + } + if (f_interval > m_cktime ) { + Connect[me].WLtime = Connect[me].Wtime; + Connect[me].Walkcount = 0; + } else { + Connect[me].Walkcount++; + if (Connect[me].Walkcount > 1) { + Connect[me].Walkspool--; + if (Connect[me].Walkspool > 0) { + Connect[me].Walkcount = 0; + print("Walkspool consumed as %d", Connect[me].Walkspool); + return 0; + } + /*Connect[me].Walkspool=WALK_SPOOL; + Connect[me].Walkrestore=WALK_RESTORE; + print("Walk dropped \n"); + Connect[me].credit=-10; + return 0;*/ + return -1; + } + } + return 0; +} +int setBtime(int fd) +{ + int me, interval; + //ARM & Tom + //me=CONNECT_getCharaindex(fd); + me=fd; + Connect[me].BEOrestore--; + if (Connect[me].BEOrestore <= 0) { + Connect[me].BEOrestore = BEO_RESTORE; + Connect[me].BEOspool = BEO_SPOOL; + //print("BEOspool restored "); + } + Connect[me].lastlastBtime = Connect[me].lastBtime; + Connect[me].lastBtime = Connect[me].Btime; + Connect[me].Btime = time(0); + interval = abs(Connect[me].Btime - Connect[me].lastlastBtime); + //print("B3interval:%d ",interval); + if ( interval < B3_TOLERANCE ) { + Connect[me].BEOspool--; + //print("B3spool consumed as:%d ",Connect[me].BEOspool); + if (Connect[me].BEOspool <= 0) return -1; + else return 0; + } else return 0; +} +int checkBEOTime(int fd) +{ + int me, interval; + //ARM & Tom + //me=CONNECT_getCharaindex(fd); + me=fd; + Connect[me].EOtime = time(0); + interval = abs(Connect[me].EOtime - Connect[me].Btime); + //print("BEOinterval:%d ",interval); + + if ( interval < BEO_TOLERANCE) { + Connect[me].BEOspool--; + //print("BEOspool consumed as:%d ",Connect[me].BEOspool); + // Nuke 0626: Do not kick out + if (Connect[me].BEOspool <= 0) { Connect[me].nu_decrease++; return -1; } + else return 0; + } else return 0; +} +int ITEM_getRatio() +{ + int i, r; + int item_max = ITEM_getITEM_itemnum(); + int item_use = 0; + for(i=0;i 进入了sigusr2了\n"); + f = fopen("./gm_sigusr_command", "r"); + memset( message, 0, sizeof(message)); + memset( message2, 0, sizeof(message2)); + + if( f ){ + fscanf(f,"%s",message); + print("fev ==> 档案内容(%s)\n",message); + if( strcmp(message,"") == 0 + || strcmp(message,"Shutdown") == 0){ + if( fgets(message2, sizeof(message2), f) ){ + print("\nReceived Shutdown signal...n分钟後维护\n\n"); + lssproto_Shutdown_recv(0, "hogehoge", atoi(message2)); // n分钟後维修 + } + else{ + print("\nReceived Shutdown signal...\n\n"); + lssproto_Shutdown_recv(0, "hogehoge", 5); // 5分钟後维修 + } + } + else + { + print("fev ==> 执行GM指令\n"); + func = gm_CHAR_getChatMagicFuncPointer(message,TRUE); + if( func ){ + if( fgets(message2, sizeof(message2), f) ) + print("fev ==> 参数内容(%s)\n",message2); + + func(1000,message2); + } + } + fclose(f); + } + else{ + print("\nReceived Shutdown signal...\n\n"); + lssproto_Shutdown_recv(0, "hogehoge", 5); // 5分钟後维修 + } + signal(SIGUSR2,sigusr2); +#else + signal(SIGUSR2,sigusr2); + print("\nReceived Shutdown signal...\n\n"); + lssproto_Shutdown_recv(0, "hogehoge", 5); // 5分钟後维修 +#endif +} + +// Nuke end +//ttom start +void CONNECT_set_watchmode(int fd, BOOL B_Watch) +{ + int me; + me=CONNECT_getCharaindex(fd); + Connect[me].in_watch_mode = B_Watch; +} +BOOL CONNECT_get_watchmode(int fd) +{ + int me; + BOOL B_ret; + me=CONNECT_getCharaindex(fd); + B_ret=Connect[me].in_watch_mode; + return B_ret; +} +BOOL CONNECT_get_shutup(int fd) +{ + int me; + BOOL B_ret; + me=CONNECT_getCharaindex(fd); + B_ret=Connect[me].b_shut_up; + return B_ret; +} +void CONNECT_set_shutup(int fd,BOOL b_shut) +{ + int me; + me=CONNECT_getCharaindex(fd); + Connect[me].b_shut_up = b_shut; +} +unsigned long CONNECT_get_userip(int fd) +{ + unsigned long ip; + memcpy(&ip,&Connect[fd].sin.sin_addr, sizeof(long)); + return ip; +} +void CONNECT_set_pass(int fd,BOOL b_ps) +{ + int me; + me=CONNECT_getCharaindex(fd); + Connect[me].b_pass = b_ps; +} +BOOL CONNECT_get_pass(int fd) +{ + int me; + BOOL B_ret; + me=CONNECT_getCharaindex(fd); + B_ret=Connect[me].b_pass; + return B_ret; +} +void CONNECT_set_first_warp(int fd,BOOL b_ps) +{ + int me; + me=CONNECT_getCharaindex(fd); + Connect[me].b_first_warp = b_ps; +} +BOOL CONNECT_get_first_warp(int fd) +{ + int me; + BOOL B_ret; + me=CONNECT_getCharaindex(fd); + B_ret=Connect[me].b_first_warp; + return B_ret; +} +void CONNECT_set_state_trans(int fd,int a) +{ + int me; + me=CONNECT_getCharaindex(fd); + Connect[me].state_trans=a; +} +int CONNECT_get_state_trans(int fd) +{ + int me,i_ret; + me=CONNECT_getCharaindex(fd); + i_ret=Connect[me].state_trans; + return i_ret; +} +//ttom end + +// Arminius 6.22 encounter +int CONNECT_get_CEP(int fd) +{ + return Connect[fd].CEP; +} + +void CONNECT_set_CEP(int fd, int cep) +{ + Connect[fd].CEP=cep; +} +// Arminius end + +// Arminius 7.12 login announce +int CONNECT_get_announced(int fd) +{ + return Connect[fd].announced; +} + +void CONNECT_set_announced(int fd, int a) +{ + Connect[fd].announced=a; +} + +// shan trade(DoubleCheck) begin +int CONNECT_get_confirm(int fd) +{ + return Connect[fd].confirm_key; +} +void CONNECT_set_confirm(int fd, BOOL b) +{ + Connect[fd].confirm_key = b; +} +// end + +#ifdef _BLACK_MARKET +int CONNECT_get_BMList(int fd, int i) +{ + return Connect[fd].BMSellList[i]; +} +void CONNECT_set_BMList(int fd,int i, int b) +{ + Connect[fd].BMSellList[i] = b; +} +#endif + +#ifdef _NO_WARP +// shan hjj add Begin +int CONNECT_get_seqno(int fd) +{ + return Connect[fd].seqno; +} +void CONNECT_set_seqno(int fd, int a) +{ + if( (Connect[fd].seqno==CHAR_WINDOWTYPE_QUIZ_MAIN)&&(a==0) ) + a = CHAR_WINDOWTYPE_QUIZ_MAIN; + Connect[fd].seqno = a; +} +int CONNECT_get_selectbutton(int fd) +{ + return Connect[fd].selectbutton; +} +void CONNECT_set_selectbutton(int fd, int a) +{ + Connect[fd].selectbutton = a; +} +// shan End +#endif + +int isDie(int fd) +{ + return (Connect[fd].die); +} + +void setDie(int fd) +{ + Connect[fd].die=1; +} + +int checkNu(fd) +{ + Connect[fd].nu--; + //print("NU=%d\n",Connect[fd].nu); + if (Connect[fd].nu<0) return -1; + return 0; +} + +int checkKe(fd) +{ + Connect[fd].ke--; + //print("KE=%d\n",Connect[fd].ke); + if (Connect[fd].ke<0) return -1; + return 0; +} + +// Nuke start 0626: For no enemy function +void setNoenemy(fd) +{ + Connect[fd].noenemy=6; +} +void clearNoenemy(fd) +{ + Connect[fd].noenemy=0; +} +int getNoenemy(fd) +{ + return Connect[fd].noenemy; +} +// Nuke end + +// Arminius 7/2: Ra's amulet +void setEqNoenemy(int fd, int level) +{ + Connect[fd].eqnoenemy=level; +} + +void clearEqNoenemy(int fd) +{ + Connect[fd].eqnoenemy=0; +} + +int getEqNoenemy(int fd) +{ + return Connect[fd].eqnoenemy; +} + +#ifdef _Item_MoonAct +void setEqRandenemy(int fd, int level) +{ + Connect[fd].eqrandenemy=level; +} + +void clearEqRandenemy(int fd) +{ + Connect[fd].eqrandenemy=0; +} + +int getEqRandenemy(int fd) +{ + return Connect[fd].eqrandenemy; +} + +#endif + +#ifdef _CHIKULA_STONE +void setChiStone(int fd, int nums) +{ + Connect[fd].chistone=nums; +} +int getChiStone(int fd) +{ + return Connect[fd].chistone; +} +#endif + +// Arminius 7.31 cursed stone +void setStayEncount(int fd) +{ + Connect[fd].stayencount=1; +} + +void clearStayEncount(int fd) +{ + Connect[fd].stayencount=0; +} + +int getStayEncount(int fd) +{ + return Connect[fd].stayencount; +} + +void CONNECT_setBDTime( int fd, int nums) +{ + Connect[fd].BDTime = nums; +} + +int CONNECT_getBDTime( int fd) +{ + return Connect[fd].BDTime; +} + +#ifdef _TYPE_TOXICATION +void setToxication( int fd, int flg) +{ + Connect[fd].toxication = flg; +} +int getToxication( int fd) +{ + return Connect[fd].toxication; +} +#endif + +#ifdef _BATTLE_TIMESPEED +void RescueEntryBTime( int charaindex, int fd, unsigned int lowTime, unsigned int battletime) +{ + int NowTime = (int)time(NULL); + + Connect[fd].CBTime = NowTime; +//Connect[fd].CBTime+battletime +} + +BOOL CheckDefBTime( int charaindex, int fd, unsigned int lowTime, unsigned int battletime, unsigned int addTime)//lowTime延迟时间 +{ + int delayTime = 0; + unsigned int NowTime = (unsigned int)time(NULL); + + //print(" NowTime=%d lowTime=%d battleTime=%d CBTime=%d", NowTime, lowTime, battletime, Connect[fd].CBTime); + + lowTime += battletime; + if( (Connect[fd].CBTime+battletime) > lowTime ) lowTime = Connect[fd].CBTime+battletime; + if( NowTime < lowTime ){//lowTime应该的战斗结束时间 + int r=0; + delayTime = lowTime - NowTime; + delayTime = ( delayTime<=0 )?1:delayTime; + r = (-4)*(delayTime+2); + lssproto_NU_send( fd, r); + Connect[fd].nu += r; + } + //Connect[fd].BDTime = (NowTime+20)+delayTime; + Connect[fd].BDTime = (NowTime+rand()%5)+delayTime+addTime; // 恶宝等待时间 + //print(" BDTime=%d ", Connect[fd].BDTime); + return TRUE; +} +#endif + +#ifdef _CHECK_GAMESPEED +int getGameSpeedTime( int fd) +{ + return Connect[fd].gamespeed; +} +void setGameSpeedTime( int fd, int times) +{ + Connect[fd].gamespeed =times; +} +#endif + + +BOOL MSBUF_CHECKbuflen( int size, float defp) +{ + if( mfd == -1 ) return FALSE; + if( Connect[mfd].wbuse + size >= WBSIZE*defp) return FALSE; + + return TRUE; +} + diff --git a/gmsv/npc/11npc_action.c b/gmsv/npc/11npc_action.c new file mode 100644 index 0000000..26c85e5 --- /dev/null +++ b/gmsv/npc/11npc_action.c @@ -0,0 +1,137 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "npc_action.h" + +/* + * 皿伊奶乩□及失弁扑亦件卞 杀允月NPC[ + * 签卞韵曰忒仄凶曰允月分仃分互[ + * 汹仁]引凶反 匀化中月及失弁扑亦件卞反 杀仄卅中[ + * + * 娄醒“ + * msgcol: 丢永本□斥及缙[犯白巧伙玄反疵缙 + * normal: 骚卞韵匀化五凶凛支 躲卅失弁扑亦件卞覆仄化及忒蚕 + * attack: 猾失弁扑亦件卞覆允月忒蚕 + * damage: 母丢□斥毛熬仃凶失弁扑亦件卞覆允月忒蚕 + * down: 逦木月失弁扑亦件卞覆允月忒蚕 + * sit: 甄月失弁扑亦件卞覆仄化及忒蚕 + * hand: 澎毛蕊月失弁扑亦件卞覆仄化及忒蚕 + * pleasure: 减少失弁扑亦件卞覆仄化及忒蚕 + * angry: 变月失弁扑亦件卞覆仄化及忒蚕 + * sad: 仄戈失弁扑亦件卞覆仄化及忒蚕 + * guard: 布□玉允月失弁扑亦件卞覆仄化及忒蚕 + */ + + +#define NPC_ACTION_MSGCOLOR_DEFAULT CHAR_COLORYELLOW + +enum { + CHAR_WORK_MSGCOLOR = CHAR_NPCWORKINT1, +}; + +/********************************* +* 赓渝质 +*********************************/ +BOOL NPC_ActionInit( int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + int tmp; + + tmp = NPC_Util_GetNumFromStrWithDelim( argstr, "msgcol"); + if( tmp == -1 ) tmp = NPC_ACTION_MSGCOLOR_DEFAULT; + CHAR_setWorkInt( meindex, CHAR_WORK_MSGCOLOR, tmp); + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEACTION ); + + + return TRUE; +} + + + + +/********************************* +* 仄井仃日木凶凛及质 +*********************************/ +void NPC_ActionTalked( int meindex , int talkerindex , char *szMes , + int color ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[64]; + + /* 皿伊奶乩□卞覆仄化分仃 杀允月 */ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + /* ㄠ弘伉永玉动 及心 */ + if( !NPC_Util_charIsInFrontOfChar( talkerindex, meindex, 1 )) return; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, + "normal", + buf, sizeof( buf)) + != NULL ) + { + CHAR_talkToCli( talkerindex, meindex ,buf , + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR )); + } + +} +/********************************* +* watch质 +*********************************/ +void NPC_ActionWatch( int meobjindex, int objindex, CHAR_ACTION act, + int x,int y,int dir, int* opt,int optlen ) +{ + int meindex; + int index; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[64]; + int i; + struct { + CHAR_ACTION act; + char *string; + }searchtbl[] = { + { CHAR_ACTATTACK, "attack"}, + { CHAR_ACTDAMAGE, "damage"}, + { CHAR_ACTDOWN, "down"}, + { CHAR_ACTSIT, "sit"}, + { CHAR_ACTHAND, "hand"}, + { CHAR_ACTPLEASURE, "pleasure"}, + { CHAR_ACTANGRY, "angry"}, + { CHAR_ACTSAD, "sad"}, + { CHAR_ACTGUARD, "guard"}, + { CHAR_ACTNOD, "nod"}, + { CHAR_ACTTHROW, "throw"}, + }; + + if( OBJECT_getType( objindex) != OBJTYPE_CHARA) return; + index = OBJECT_getIndex( objindex); + /* 皿伊奶乩□卞及心 杀允月 */ + if( CHAR_getInt( index, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER) return; + + meindex = OBJECT_getIndex( meobjindex); + + /* 轾五宁匀化ㄠ弘伉永玉匹卅中午 杀仄卅中 */ + if( NPC_Util_isFaceToFace( meindex, index, 1 ) != TRUE ) return; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + for( i = 0; i < arraysizeof( searchtbl); i ++ ) { + if( searchtbl[i].act == act) { + if( NPC_Util_GetStrFromStrWithDelim( argstr, + searchtbl[i].string, + buf, sizeof( buf)) + != NULL ) + { + CHAR_talkToCli( index, meindex ,buf , + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR )); + break; + } + } + } +} diff --git a/gmsv/npc/makefile b/gmsv/npc/makefile new file mode 100644 index 0000000..98a515d --- /dev/null +++ b/gmsv/npc/makefile @@ -0,0 +1,3103 @@ +INCFLAGS=-I. -I../include + + +CFLAGS=-w -O3 $(INCFLAGS) + +PROG=libnpc.a + +SRC=readnpc.c npcgen.c npctemplate.c npccreate.c npcutil.c \ +npc_warp.c npc_townpeople.c \ +npc_msg.c npc_healer.c npc_oldman.c \ +npc_storyteller.c npc_dengon.c npc_doorman.c \ +npc_npcenemy.c npc_itemchange.c \ +npc_action.c npc_windowman.c npc_savepoint.c \ +npc_windowhealer.c npc_itemshop.c npc_sysinfo.c \ +npc_duelranking.c npc_petskillshop.c npc_petshop.c \ +npc_signboard.c npc_warpman.c npc_exchangeman.c \ +npc_timeman.c npc_bodylan.c npc_mic.c \ +npc_luckyman.c npc_bus.c npc_charm.c npc_quiz.c \ +npc_poolitemshop.c npc_checkman.c npc_janken.c \ +npc_transmigration.c npc_makepair.c \ +npc_familyman.c npc_fmdengon.c npc_fmwarpman.c \ +npc_fmhealer.c npc_bankman.c npc_fmpkman.c\ +npc_airplane.c npc_scheduleman.c npc_fmpkcallman.c\ +npc_manorsman.c npc_riderman.c npc_fmletter.c npc_petmaker.c \ +npc_gamblemaster.c npc_gambleroulette.c npc_petfusion.c\ +npc_stoneserviceman.c npc_newnpcman.c npc_gamblebank.c \ +npc_petracemaster.c npc_petracepet.c npc_bigsmallmaster.c \ +npc_bigsmallpet.c npc_auctioneer.c npc_freepetskillshop.c \ +npc_eventaction.c \ +npc_mtradenpcman.c npc_blackmarket.c npc_transerman.c npc_pauctionman.c npc_alldoman.c\ +npc_sellsthman.c \ +npc_welfare.c npc_verywelfare.c npc_welfare2.c \ +npc_raceman.c + +OBJ=$(SRC:.c=.o) + +ifeq (0,$(MAKELEVEL)) +CC=gcc +RM=rm -f +AR=ar cr +MV=mv +RANLIB=ranlib +SED=sed +SHELL=/bin/sh +endif + +all: $(PROG) + +$(PROG): $(OBJ) + $(RM) $(PROG) + $(AR) $(PROG) $(OBJ) + $(RANLIB) $(PROG) + +depend: + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(CC) $(INCFLAGS) -M $(SRC) >> makefile + +clean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + +distclean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(RM) makefile.bak + +# DO NOT DELETE THIS LINE +readnpc.o: readnpc.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/string.h ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h ../include/common.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h ../include/npctemplate.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/char_base.h ../include/skill.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/npccreate.h +npcgen.o: npcgen.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/common.h /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/npccreate.h ../include/util.h /usr/include/sys/time.h \ + /usr/include/time.h /usr/include/bits/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/npctemplate.h ../include/char_base.h \ + ../include/skill.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/buf.h ../include/object.h \ + ../include/readmap.h ../include/handletime.h ../include/map_deal.h +npctemplate.o: npctemplate.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/string.h ../include/common.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h ../include/npctemplate.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/char_base.h ../include/skill.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/buf.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/handletime.h \ + ../include/anim_tbl.h ../include/configfile.h +npccreate.o: npccreate.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/string.h ../include/common.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h ../include/npccreate.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/npctemplate.h ../include/char_base.h \ + ../include/skill.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/buf.h ../include/readmap.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/handletime.h ../include/configfile.h +npcutil.o: npcutil.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/common.h /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h ../include/char.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/configfile.h ../include/object.h ../include/map_deal.h \ + ../include/npcutil.h ../include/npc_door.h ../include/readmap.h \ + ../include/npccreate.h ../include/enemy.h ../include/family.h \ + ../include/saacproto_cli.h ../include/saacproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h +npc_warp.o: npc_warp.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/object.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/map_deal.h ../include/readmap.h \ + ../include/npccreate.h ../include/npcutil.h ../include/handletime.h \ + ../include/npc_eventaction.h +npc_townpeople.o: npc_townpeople.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h ../include/object.h \ + ../include/common.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/handletime.h ../include/anim_tbl.h \ + ../include/npc_door.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/string.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h ../include/npcutil.h +npc_msg.o: npc_msg.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h ../include/char.h ../include/common.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/npcutil.h +npc_healer.o: npc_healer.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/string.h /usr/include/ctype.h /usr/include/endian.h \ + /usr/include/bits/endian.h ../include/object.h ../include/common.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/npcutil.h ../include/readmap.h +npc_oldman.o: npc_oldman.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h ../include/object.h ../include/common.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/npcutil.h ../include/npc_oldman.h \ + ../include/readmap.h +npc_storyteller.o: npc_storyteller.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h ../include/char.h \ + ../include/common.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h +npc_dengon.o: npc_dengon.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/time.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/time.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/string.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h ../include/npcutil.h \ + ../include/handletime.h +npc_doorman.o: npc_doorman.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/object.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/handletime.h ../include/npc_doorman.h \ + ../include/npc_door.h ../include/npcutil.h ../include/configfile.h +npc_npcenemy.o: npc_npcenemy.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/npc_npcenemy.h \ + ../include/battle.h ../include/enemy.h ../include/readmap.h \ + ../include/encount.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/configfile.h ../include/anim_tbl.h \ + ../include/handletime.h ../include/npc_eventaction.h +npc_itemchange.o: npc_itemchange.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/readmap.h ../include/battle.h \ + ../include/log.h ../include/enemy.h ../include/handletime.h \ + ../include/npc_eventaction.h ../include/npc_itemchange.h +npc_action.o: npc_action.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/npc_action.h +npc_windowman.o: npc_windowman.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/configfile.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/npc_windowman.h +npc_savepoint.o: npc_savepoint.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/object.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/npcutil.h ../include/npc_oldman.h \ + ../include/readmap.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/log.h +npc_windowhealer.o: npc_windowhealer.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/npc_windowhealer.h +npc_itemshop.o: npc_itemshop.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/pet_skill.h \ + ../include/npc_eventaction.h ../include/readmap.h ../include/log.h \ + ../include/family.h +npc_sysinfo.o: npc_sysinfo.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/char_event.h ../include/object.h ../include/handletime.h \ + ../include/magic.h ../include/npcutil.h ../include/chatmagic.h \ + ../include/configfile.h ../include/npcgen.h +npc_duelranking.o: npc_duelranking.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npc_duelranking.h \ + ../include/handletime.h +npc_petskillshop.o: npc_petskillshop.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/pet_skill.h ../include/readmap.h \ + ../include/battle.h +npc_petshop.o: npc_petshop.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/pet_skill.h ../include/readmap.h \ + ../include/battle.h ../include/log.h +npc_signboard.o: npc_signboard.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/readmap.h ../include/family.h +npc_warpman.o: npc_warpman.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npc_warpman.h \ + ../include/map_deal.h ../include/readmap.h ../include/battle.h \ + ../include/npc_exchangeman.h ../include/log.h ../include/enemy.h \ + ../include/handletime.h ../include/npc_eventaction.h +npc_exchangeman.o: npc_exchangeman.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/npc_exchangeman.h \ + ../include/npc_eventaction.h ../include/log.h ../include/battle.h \ + ../include/handletime.h ../include/enemy.h ../include/npc_warp.h +npc_timeman.o: npc_timeman.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/object.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/npcutil.h ../include/npc_oldman.h \ + ../include/readmap.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/log.h ../include/handletime.h +npc_bodylan.o: npc_bodylan.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/npc_windowhealer.h +npc_mic.o: npc_mic.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/string.h ../include/common.h /usr/include/errno.h \ + /usr/include/bits/errno.h /usr/include/linux/errno.h \ + /usr/include/asm/errno.h ../include/char_base.h ../include/skill.h \ + ../include/util.h /usr/include/sys/time.h /usr/include/time.h \ + /usr/include/bits/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/npcutil.h ../include/npc_mic.h \ + ../include/saacproto_cli.h ../include/saacproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/battle.h +npc_luckyman.o: npc_luckyman.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/npc_luckyman.h +npc_bus.o: npc_bus.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/npc_bus.h ../include/handletime.h +npc_charm.o: npc_charm.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/npc_charm.h +npc_quiz.o: npc_quiz.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/common.h /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/npc_quiz.h ../include/npcutil.h \ + ../include/char.h ../include/char_data.h ../include/item.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/buf.h ../include/function.h \ + ../include/readmap.h ../include/object.h ../include/log.h +npc_poolitemshop.o: npc_poolitemshop.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h ../include/char.h \ + ../include/common.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/string.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/npcutil.h \ + ../include/npc_poolitemshop.h ../include/log.h ../include/handletime.h +npc_checkman.o: npc_checkman.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h +npc_janken.o: npc_janken.c ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/common.h /usr/include/stdio.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/npc_janken.h ../include/npcutil.h \ + ../include/char.h ../include/char_data.h ../include/item.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/buf.h ../include/function.h \ + ../include/readmap.h ../include/object.h ../include/log.h +npc_transmigration.o: npc_transmigration.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/math.h /usr/include/bits/huge_val.h \ + /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/enemy.h ../include/log.h \ + ../include/battle.h ../include/readmap.h \ + ../include/npc_transmigration.h ../include/npc_pettransman.h +npc_makepair.o: npc_makepair.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/npc_transerman.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/readmap.h ../include/battle.h \ + ../include/log.h ../include/enemy.h ../include/handletime.h \ + ../include/npc_makepair.h ../include/npc_eventaction.h +npc_familyman.o: npc_familyman.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/configfile.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npc_familyman.h \ + ../include/family.h +npc_fmdengon.o: npc_fmdengon.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/time.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/time.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/string.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/saacproto_cli.h ../include/saacproto_util.h \ + ../include/npcutil.h ../include/handletime.h ../include/npc_fmdengon.h \ + ../include/family.h +npc_fmwarpman.o: npc_fmwarpman.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/time.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/time.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/string.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/saacproto_cli.h ../include/saacproto_util.h \ + ../include/npc_fmwarpman.h ../include/npc_scheduleman.h \ + ../include/readmap.h ../include/log.h ../include/battle.h \ + ../include/handletime.h ../include/family.h +npc_fmhealer.o: npc_fmhealer.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/string.h /usr/include/ctype.h /usr/include/endian.h \ + /usr/include/bits/endian.h ../include/object.h ../include/common.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/npcutil.h ../include/readmap.h +npc_bankman.o: npc_bankman.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/configfile.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npc_bankman.h \ + ../include/family.h +npc_fmpkman.o: npc_fmpkman.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/npc_fmpkman.h \ + ../include/npc_scheduleman.h ../include/npc_fmwarpman.h \ + ../include/family.h ../include/readmap.h ../include/battle.h \ + ../include/log.h +npc_airplane.o: npc_airplane.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/npc_airplane.h ../include/handletime.h +npc_scheduleman.o: npc_scheduleman.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/time.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/time.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/string.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h ../include/npcutil.h \ + ../include/handletime.h ../include/npc_scheduleman.h \ + ../include/family.h +npc_fmpkcallman.o: npc_fmpkcallman.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/npc_fmpkcallman.h ../include/family.h \ + ../include/readmap.h ../include/battle.h ../include/log.h \ + ../include/npc_scheduleman.h ../include/handletime.h +npc_manorsman.o: npc_manorsman.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/time.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/time.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/string.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h ../include/npcutil.h \ + ../include/handletime.h ../include/npc_scheduleman.h \ + ../include/family.h ../include/npc_manorsman.h \ + ../include/saacproto_cli.h ../include/saacproto_util.h \ + ../include/configfile.h ../include/log.h +npc_riderman.o: npc_riderman.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/configfile.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npc_riderman.h \ + ../include/family.h ../include/log.h +npc_fmletter.o: npc_fmletter.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/configfile.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npc_fmletter.h \ + ../include/family.h ../include/log.h +npc_petmaker.o: npc_petmaker.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/string.h /usr/include/ctype.h /usr/include/endian.h \ + /usr/include/bits/endian.h ../include/object.h ../include/common.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/npcutil.h ../include/readmap.h \ + ../include/enemy.h ../include/chatmagic.h ../include/log.h +npc_gamblemaster.o: npc_gamblemaster.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/handletime.h ../include/readmap.h \ + ../include/log.h ../include/npc_eventaction.h \ + ../include/npc_gamblemaster.h +npc_gambleroulette.o: npc_gambleroulette.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/readmap.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/handletime.h \ + ../include/npc_gambleroulette.h +npc_petfusion.o: npc_petfusion.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/readmap.h ../include/battle.h \ + ../include/log.h ../include/enemy.h ../include/handletime.h \ + ../include/npc_eventaction.h ../include/npc_petfusion.h \ + ../include/pet.h ../include/chatmagic.h +npc_stoneserviceman.o: npc_stoneserviceman.c /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/wchar.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h ../include/char.h \ + ../include/common.h /usr/include/stdio.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/version.h ../include/correct_bug.h \ + ../include/version_pk.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/stdlib.h /usr/include/alloca.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/npc_stoneserviceman.h \ + ../include/readmap.h ../include/battle.h ../include/log.h \ + ../include/enemy.h ../include/configfile.h +npc_newnpcman.o: npc_newnpcman.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/math.h /usr/include/bits/huge_val.h \ + /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/enemy.h ../include/log.h \ + ../include/battle.h ../include/readmap.h ../include/handletime.h \ + ../include/npc_eventaction.h ../include/npc_newnpcman.h \ + ../include/pet.h +npc_gamblebank.o: npc_gamblebank.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/math.h /usr/include/bits/huge_val.h \ + /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/enemy.h ../include/log.h \ + ../include/battle.h ../include/readmap.h ../include/handletime.h \ + ../include/configfile.h ../include/npc_gamblebank.h +npc_petracemaster.o: npc_petracemaster.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/time.h /usr/include/bits/time.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/handletime.h \ + ../include/npc_petracemaster.h +npc_petracepet.o: npc_petracepet.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/handletime.h \ + ../include/npc_petracepet.h +npc_bigsmallmaster.o: npc_bigsmallmaster.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/time.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/time.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/string.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h ../include/npcutil.h \ + ../include/handletime.h ../include/configfile.h \ + ../include/npc_bigsmallmaster.h ../include/npc_windowman.h +npc_bigsmallpet.o: npc_bigsmallpet.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/time.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/time.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/string.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h ../include/npcutil.h \ + ../include/handletime.h ../include/configfile.h \ + ../include/npc_bigsmallpet.h +npc_auctioneer.o: npc_auctioneer.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/time.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/time.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/string.h ../include/char.h ../include/common.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/npcutil.h ../include/handletime.h \ + ../include/configfile.h ../include/npc_auctioneer.h ../include/pet.h \ + ../include/anim_tbl.h ../include/log.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h +npc_freepetskillshop.o: npc_freepetskillshop.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/pet_skill.h ../include/readmap.h \ + ../include/battle.h ../include/configfile.h \ + ../include/npc_eventaction.h ../include/npc_freepetskillshop.h +npc_eventaction.o: npc_eventaction.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/map_deal.h ../include/readmap.h \ + ../include/battle.h ../include/log.h ../include/enemy.h \ + ../include/handletime.h ../include/npc_eventaction.h \ + ../include/family.h ../include/profession_skill.h \ + ../include/chatmagic.h +npc_mtradenpcman.o: npc_mtradenpcman.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/math.h /usr/include/bits/huge_val.h \ + /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/enemy.h ../include/log.h \ + ../include/battle.h ../include/readmap.h ../include/handletime.h \ + ../include/npc_eventaction.h +npc_blackmarket.o: npc_blackmarket.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/configfile.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h +npc_transerman.o: npc_transerman.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/npc_transerman.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/readmap.h ../include/battle.h \ + ../include/log.h ../include/enemy.h ../include/handletime.h \ + ../include/npc_eventaction.h +npc_pauctionman.o: npc_pauctionman.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/readmap.h ../include/battle.h \ + ../include/log.h ../include/enemy.h ../include/handletime.h \ + ../include/npc_eventaction.h ../include/npc_pauctionman.h +npc_alldoman.o: npc_alldoman.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/string.h /usr/include/ctype.h /usr/include/endian.h \ + /usr/include/bits/endian.h ../include/object.h ../include/common.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/npcutil.h ../include/readmap.h \ + ../include/enemy.h ../include/chatmagic.h ../include/log.h \ + ../include/npc_itemchange.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npc_eventaction.h \ + ../include/npc_charm.h ../include/npc_alldoman.h +npc_sellsthman.o: npc_sellsthman.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/readmap.h ../include/battle.h \ + ../include/log.h ../include/enemy.h ../include/handletime.h \ + ../include/npc_eventaction.h ../include/npc_sellsthman.h \ + ../include/pet_skill.h +npc_welfare.o: npc_welfare.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/pet_skill.h ../include/readmap.h \ + ../include/battle.h ../include/profession_skill.h \ + ../include/chatmagic.h ../include/npc_welfare.h \ + ../include/npc_exchangeman.h +npc_verywelfare.o: npc_verywelfare.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/configfile.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npc_verywelfare.h +npc_welfare2.o: npc_welfare2.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h +npc_raceman.o: npc_raceman.c ../include/version.h \ + ../include/correct_bug.h ../include/version_pk.h /usr/include/time.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/time.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/signal.h /usr/include/bits/signum.h \ + /usr/include/bits/siginfo.h /usr/include/bits/sigaction.h \ + /usr/include/bits/sigcontext.h /usr/include/asm/sigcontext.h \ + /usr/include/bits/sigstack.h /usr/include/bits/sigthread.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/string.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/saacproto_cli.h ../include/saacproto_util.h \ + ../include/npcutil.h ../include/handletime.h ../include/npc_raceman.h \ + ../include/family.h ../include/log.h ../include/enemy.h diff --git a/gmsv/npc/makefile.bak b/gmsv/npc/makefile.bak new file mode 100644 index 0000000..e673f56 --- /dev/null +++ b/gmsv/npc/makefile.bak @@ -0,0 +1,2525 @@ +INCFLAGS=-I. -I../include + + +CFLAGS=-w -O3 $(INCFLAGS) + +PROG=libnpc.a + +SRC=readnpc.c npcgen.c npctemplate.c npccreate.c npcutil.c \ +npc_warp.c npc_townpeople.c \ +npc_msg.c npc_healer.c npc_oldman.c \ +npc_storyteller.c npc_dengon.c npc_doorman.c \ +npc_npcenemy.c npc_itemchange.c \ +npc_action.c npc_windowman.c npc_savepoint.c \ +npc_windowhealer.c npc_itemshop.c npc_sysinfo.c \ +npc_duelranking.c npc_petskillshop.c npc_petshop.c \ +npc_signboard.c npc_warpman.c npc_exchangeman.c \ +npc_timeman.c npc_bodylan.c npc_mic.c \ +npc_luckyman.c npc_bus.c npc_charm.c npc_quiz.c \ +npc_poolitemshop.c npc_checkman.c npc_janken.c \ +npc_transmigration.c npc_makepair.c \ +npc_familyman.c npc_fmdengon.c npc_fmwarpman.c \ +npc_fmhealer.c npc_bankman.c npc_fmpkman.c\ +npc_airplane.c npc_scheduleman.c npc_fmpkcallman.c\ +npc_manorsman.c npc_riderman.c npc_fmletter.c npc_petmaker.c \ +npc_gamblemaster.c npc_gambleroulette.c npc_petfusion.c\ +npc_stoneserviceman.c npc_newnpcman.c npc_gamblebank.c \ +npc_petracemaster.c npc_petracepet.c npc_bigsmallmaster.c \ +npc_bigsmallpet.c npc_auctioneer.c npc_freepetskillshop.c \ +npc_eventaction.c \ +npc_mtradenpcman.c npc_blackmarket.c npc_transerman.c npc_pauctionman.c npc_alldoman.c\ +npc_sellsthman.c \ +npc_welfare.c npc_verywelfare.c npc_welfare2.c \ +npc_raceman.c + +OBJ=$(SRC:.c=.o) + +ifeq (0,$(MAKELEVEL)) +CC=gcc +RM=rm -f +AR=ar cr +MV=mv +RANLIB=ranlib +SED=sed +SHELL=/bin/sh +endif + +all: $(PROG) + +$(PROG): $(OBJ) + $(RM) $(PROG) + $(AR) $(PROG) $(OBJ) + $(RANLIB) $(PROG) + +depend: + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(CC) $(INCFLAGS) -M $(SRC) >> makefile + +clean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + +distclean: + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(RM) makefile.bak + +# DO NOT DELETE THIS LINE +readnpc.o: readnpc.c ../include/version.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + /usr/include/string.h ../include/common.h ../include/npctemplate.h \ + ../include/util.h /usr/include/sys/time.h /usr/include/time.h \ + /usr/include/bits/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/char_base.h ../include/skill.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/npccreate.h +npcgen.o: npcgen.c ../include/version.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/npccreate.h ../include/util.h /usr/include/sys/time.h \ + /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/npctemplate.h ../include/char_base.h \ + ../include/skill.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/buf.h ../include/object.h \ + ../include/readmap.h ../include/handletime.h ../include/map_deal.h +npctemplate.o: npctemplate.c ../include/version.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + /usr/include/string.h ../include/common.h ../include/npctemplate.h \ + ../include/util.h /usr/include/sys/time.h /usr/include/time.h \ + /usr/include/bits/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/char_base.h ../include/skill.h \ + ../include/title.h ../include/addressbook.h ../include/net.h \ + /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/buf.h ../include/char_data.h \ + ../include/item.h ../include/char.h ../include/handletime.h \ + ../include/anim_tbl.h ../include/configfile.h +npccreate.o: npccreate.c ../include/version.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + /usr/include/string.h ../include/common.h ../include/npccreate.h \ + ../include/util.h /usr/include/sys/time.h /usr/include/time.h \ + /usr/include/bits/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/npctemplate.h ../include/char_base.h \ + ../include/skill.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/buf.h ../include/readmap.h \ + ../include/char_data.h ../include/item.h ../include/char.h \ + ../include/handletime.h ../include/configfile.h +npcutil.o: npcutil.c ../include/version.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char.h ../include/char_base.h ../include/skill.h \ + ../include/util.h /usr/include/sys/time.h /usr/include/time.h \ + /usr/include/bits/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/configfile.h ../include/object.h ../include/map_deal.h \ + ../include/npcutil.h ../include/npc_door.h ../include/readmap.h \ + ../include/npccreate.h ../include/enemy.h ../include/family.h \ + ../include/saacproto_cli.h ../include/saacproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h +npc_warp.o: npc_warp.c ../include/version.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/object.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/map_deal.h ../include/readmap.h \ + ../include/npccreate.h ../include/npcutil.h ../include/handletime.h +npc_townpeople.o: npc_townpeople.c ../include/version.h \ + ../include/object.h ../include/common.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/handletime.h ../include/anim_tbl.h \ + ../include/npc_door.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/string.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/npcutil.h +npc_msg.o: npc_msg.c ../include/version.h ../include/char.h \ + ../include/common.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/npcutil.h +npc_healer.o: npc_healer.c ../include/version.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + /usr/include/string.h /usr/include/ctype.h /usr/include/endian.h \ + /usr/include/bits/endian.h ../include/object.h ../include/common.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/npcutil.h ../include/readmap.h +npc_oldman.o: npc_oldman.c ../include/version.h ../include/object.h \ + ../include/common.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/npcutil.h ../include/npc_oldman.h \ + ../include/readmap.h +npc_storyteller.o: npc_storyteller.c ../include/version.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h +npc_dengon.o: npc_dengon.c ../include/version.h ../include/char.h \ + ../include/common.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/string.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/npcutil.h ../include/handletime.h +npc_doorman.o: npc_doorman.c ../include/version.h ../include/object.h \ + ../include/common.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/handletime.h ../include/npc_doorman.h \ + ../include/npc_door.h ../include/npcutil.h ../include/configfile.h +npc_npcenemy.o: npc_npcenemy.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/npc_npcenemy.h \ + ../include/battle.h ../include/enemy.h ../include/readmap.h \ + ../include/encount.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/configfile.h ../include/anim_tbl.h ../include/handletime.h +npc_action.o: npc_action.c ../include/version.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/npc_action.h +npc_windowman.o: npc_windowman.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/configfile.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/npc_windowman.h +npc_savepoint.o: npc_savepoint.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/object.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/npcutil.h ../include/npc_oldman.h \ + ../include/readmap.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h ../include/log.h +npc_windowhealer.o: npc_windowhealer.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/npc_windowhealer.h +npc_itemshop.o: npc_itemshop.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/pet_skill.h ../include/readmap.h ../include/log.h +npc_sysinfo.o: npc_sysinfo.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/char_event.h ../include/object.h ../include/handletime.h \ + ../include/magic.h ../include/npcutil.h ../include/chatmagic.h \ + ../include/configfile.h ../include/npcgen.h +npc_duelranking.o: npc_duelranking.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/saacproto_cli.h ../include/saacproto_util.h \ + ../include/npc_duelranking.h +npc_petskillshop.o: npc_petskillshop.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/pet_skill.h ../include/readmap.h ../include/battle.h +npc_petshop.o: npc_petshop.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/pet_skill.h ../include/readmap.h ../include/battle.h \ + ../include/log.h +npc_signboard.o: npc_signboard.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/readmap.h ../include/family.h +npc_warpman.o: npc_warpman.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/saacproto_cli.h ../include/saacproto_util.h \ + ../include/npc_warpman.h ../include/map_deal.h ../include/readmap.h \ + ../include/battle.h ../include/npc_exchangeman.h ../include/log.h \ + ../include/enemy.h ../include/handletime.h +npc_exchangeman.o: npc_exchangeman.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/npc_exchangeman.h ../include/log.h ../include/battle.h \ + ../include/handletime.h ../include/enemy.h ../include/npc_warp.h +npc_timeman.o: npc_timeman.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/object.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/npcutil.h ../include/npc_oldman.h \ + ../include/readmap.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h ../include/log.h \ + ../include/handletime.h +npc_bodylan.o: npc_bodylan.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/npc_windowhealer.h +npc_mic.o: npc_mic.c ../include/version.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + /usr/include/string.h ../include/common.h ../include/char_base.h \ + ../include/skill.h ../include/util.h /usr/include/sys/time.h \ + /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/npcutil.h ../include/npc_mic.h \ + ../include/saacproto_cli.h ../include/saacproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h ../include/battle.h +npc_luckyman.o: npc_luckyman.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/npc_luckyman.h +npc_bus.o: npc_bus.c ../include/version.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/npc_bus.h ../include/handletime.h +npc_charm.o: npc_charm.c ../include/version.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/npc_charm.h +npc_quiz.o: npc_quiz.c ../include/version.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/npc_quiz.h ../include/npcutil.h \ + ../include/char.h ../include/char_data.h ../include/item.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/buf.h ../include/function.h \ + ../include/readmap.h ../include/object.h ../include/log.h +npc_poolitemshop.o: npc_poolitemshop.c ../include/version.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/string.h /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/npcutil.h \ + ../include/npc_poolitemshop.h ../include/log.h +npc_checkman.o: npc_checkman.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h +npc_janken.o: npc_janken.c ../include/version.h /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/npc_janken.h ../include/npcutil.h \ + ../include/char.h ../include/char_data.h ../include/item.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/buf.h ../include/function.h \ + ../include/readmap.h ../include/object.h ../include/log.h +npc_transmigration.o: npc_transmigration.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/math.h /usr/include/bits/huge_val.h \ + /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/float.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h ../include/enemy.h \ + ../include/log.h ../include/battle.h ../include/readmap.h \ + ../include/npc_transmigration.h ../include/npc_pettransman.h +npc_familyman.o: npc_familyman.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/configfile.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npc_familyman.h \ + ../include/family.h +npc_fmdengon.o: npc_fmdengon.c ../include/version.h ../include/char.h \ + ../include/common.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/string.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npcutil.h \ + ../include/handletime.h ../include/npc_fmdengon.h ../include/family.h +npc_fmwarpman.o: npc_fmwarpman.c ../include/version.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/string.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npc_fmwarpman.h \ + ../include/npc_scheduleman.h ../include/readmap.h ../include/battle.h \ + ../include/handletime.h ../include/family.h +npc_fmhealer.o: npc_fmhealer.c ../include/version.h +npc_alldoman.o: npc_alldoman.c ../include/version.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + /usr/include/string.h /usr/include/ctype.h /usr/include/endian.h \ + /usr/include/bits/endian.h ../include/object.h ../include/common.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/npcutil.h ../include/readmap.h +npc_bankman.o: npc_bankman.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/configfile.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npc_bankman.h \ + ../include/family.h +npc_fmpkman.o: npc_fmpkman.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/npc_fmpkman.h ../include/npc_scheduleman.h \ + ../include/npc_fmwarpman.h ../include/family.h ../include/readmap.h \ + ../include/battle.h ../include/log.h +npc_airplane.o: npc_airplane.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/npc_airplane.h ../include/handletime.h +npc_scheduleman.o: npc_scheduleman.c ../include/version.h \ + /usr/include/time.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/time.h /usr/include/bits/types.h ../include/char.h \ + ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/bits/stdio_lim.h ../include/char_base.h \ + ../include/skill.h ../include/util.h /usr/include/sys/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/string.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/npcutil.h ../include/handletime.h \ + ../include/npc_scheduleman.h ../include/family.h +npc_fmpkcallman.o: npc_fmpkcallman.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/npc_fmpkcallman.h ../include/family.h ../include/readmap.h \ + ../include/battle.h ../include/log.h +npc_manorsman.o: npc_manorsman.c ../include/version.h \ + /usr/include/time.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/time.h /usr/include/bits/types.h ../include/char.h \ + ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/bits/stdio_lim.h ../include/char_base.h \ + ../include/skill.h ../include/util.h /usr/include/sys/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/string.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/npcutil.h ../include/handletime.h \ + ../include/npc_scheduleman.h ../include/family.h \ + ../include/npc_manorsman.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/configfile.h +npc_riderman.o: npc_riderman.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/configfile.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npc_riderman.h \ + ../include/family.h ../include/log.h +npc_fmletter.o: npc_fmletter.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/configfile.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/saacproto_cli.h \ + ../include/saacproto_util.h ../include/npc_fmletter.h \ + ../include/family.h ../include/log.h +npc_petmaker.o: npc_petmaker.c ../include/version.h \ + /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + /usr/include/string.h /usr/include/ctype.h /usr/include/endian.h \ + /usr/include/bits/endian.h ../include/object.h ../include/common.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char.h ../include/char_data.h \ + ../include/item.h ../include/npcutil.h ../include/readmap.h \ + ../include/enemy.h ../include/chatmagic.h ../include/log.h +npc_gamblemaster.o: npc_gamblemaster.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/handletime.h ../include/readmap.h ../include/log.h \ + ../include/npc_gamblemaster.h +npc_gambleroulette.o: npc_gambleroulette.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/handletime.h ../include/npc_gambleroulette.h +npc_stoneserviceman.o: npc_stoneserviceman.c /usr/include/string.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/sys/sysmacros.h \ + /usr/include/sys/socket.h /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/arpa/inet.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/bits/stdio_lim.h ../include/char_base.h \ + ../include/version.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/bits/time.h \ + /usr/include/stdlib.h /usr/include/alloca.h ../include/title.h \ + ../include/addressbook.h ../include/net.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/npc_stoneserviceman.h ../include/readmap.h \ + ../include/battle.h ../include/log.h ../include/enemy.h \ + ../include/configfile.h +npc_newnpcman.o: npc_newnpcman.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/math.h /usr/include/bits/huge_val.h \ + /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/float.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h ../include/enemy.h \ + ../include/log.h ../include/battle.h ../include/readmap.h \ + ../include/handletime.h ../include/npc_newnpcman.h +npc_gamblebank.o: npc_gamblebank.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/math.h /usr/include/bits/huge_val.h \ + /usr/include/bits/mathdef.h /usr/include/bits/mathcalls.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/float.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h ../include/enemy.h \ + ../include/log.h ../include/battle.h ../include/readmap.h \ + ../include/handletime.h ../include/npc_gamblebank.h +npc_petracemaster.o: npc_petracemaster.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/handletime.h ../include/npc_petracemaster.h +npc_petracepet.o: npc_petracepet.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/handletime.h ../include/npc_petracepet.h +npc_bigsmallmaster.o: npc_bigsmallmaster.c ../include/version.h \ + /usr/include/time.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/time.h /usr/include/bits/types.h ../include/char.h \ + ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/bits/stdio_lim.h ../include/char_base.h \ + ../include/skill.h ../include/util.h /usr/include/sys/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/string.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/npcutil.h ../include/handletime.h \ + ../include/configfile.h ../include/npc_bigsmallmaster.h \ + ../include/npc_windowman.h +npc_bigsmallpet.o: npc_bigsmallpet.c ../include/version.h \ + /usr/include/time.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/time.h /usr/include/bits/types.h ../include/char.h \ + ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/bits/stdio_lim.h ../include/char_base.h \ + ../include/skill.h ../include/util.h /usr/include/sys/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/string.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/npcutil.h ../include/handletime.h \ + ../include/configfile.h ../include/npc_bigsmallpet.h +npc_auctioneer.o: npc_auctioneer.c ../include/version.h \ + /usr/include/time.h /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/time.h /usr/include/bits/types.h ../include/char.h \ + ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/bits/stdio_lim.h ../include/char_base.h \ + ../include/skill.h ../include/util.h /usr/include/sys/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/string.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h ../include/npcutil.h ../include/handletime.h \ + ../include/configfile.h ../include/npc_bigsmallmaster.h \ + ../include/npc_windowman.h +npc_freepetskillshop.o: npc_freepetskillshop.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/handletime.h ../include/npc_freepetskillshop.h +npc_eventaction.o: npc_eventaction.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/handletime.h ../include/npc_eventaction.h +npc_mtradenpcman.o: npc_eventaction.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/handletime.h ../include/npc_mtradenpcman.h +npc_transerman.o: npc_transerman.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h ../include/npc_transerman.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/handletime.h ../include/npc_freepetskillshop.h +npc_itemchange.o: npc_itemchange.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h ../include/npc_itemchange.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/handletime.h ../include/npc_freepetskillshop.h +npc_pauctionman.o: npc_pauctionman.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h ../include/npc_pauctionman.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/handletime.h ../include/npc_freepetskillshop.h +npc_makepair.o: npc_makepair.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h ../include/npc_makepair.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/handletime.h ../include/npc_freepetskillshop.h +npc_petfusion.o: npc_petfusion.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h ../include/npc_petfusion.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/lssproto_serv.h \ + ../include/lssproto_util.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + ../include/handletime.h ../include/npc_freepetskillshop.h +npc_welfare.o: npc_welfare.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/configfile.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + ../include/saacproto_util.h ../include/npc_welfare.h +npc_welfare2.o: npc_welfare2.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/configfile.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + ../include/saacproto_util.h ../include/npc_welfare.h +npc_verywelfare.o: npc_verywelfare.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/configfile.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + ../include/saacproto_util.h ../include/npc_verywelfare.h +npc_raceman.o: npc_raceman.c ../include/version.h \ + /usr/include/string.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + ../include/char.h ../include/common.h /usr/include/stdio.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/types.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/bits/stdio_lim.h \ + ../include/char_base.h ../include/skill.h ../include/util.h \ + /usr/include/sys/time.h /usr/include/time.h /usr/include/bits/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/sysmacros.h \ + /usr/include/alloca.h ../include/title.h ../include/addressbook.h \ + ../include/net.h /usr/include/netinet/in.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/stdint.h \ + /usr/include/bits/wordsize.h /usr/include/bits/socket.h \ + /usr/include/bits/sockaddr.h /usr/include/asm/socket.h \ + /usr/include/asm/sockios.h /usr/include/bits/in.h \ + /usr/include/bits/byteswap.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + ../include/link.h ../include/char_data.h ../include/item.h \ + ../include/object.h ../include/npcutil.h ../include/configfile.h \ + ../include/lssproto_serv.h ../include/lssproto_util.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + ../include/saacproto_util.h ../include/npc_raceman.h + + diff --git a/gmsv/npc/npc_action.c b/gmsv/npc/npc_action.c new file mode 100644 index 0000000..bca580f --- /dev/null +++ b/gmsv/npc/npc_action.c @@ -0,0 +1,137 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "npc_action.h" + +/* + * 皿伊奶乩□及失弁扑亦件卞 杀允月NPC[ + * 签卞韵曰忒仄凶曰允月分仃分互[ + * 汹仁]引凶反 匀化中月及失弁扑亦件卞反 杀仄卅中[ + * + * 娄醒“ + * msgcol: 丢永本□斥及缙[犯白巧伙玄反疵缙 + * normal: 骚卞韵匀化五凶凛支 躲卅失弁扑亦件卞覆仄化及忒蚕 + * attack: 猾失弁扑亦件卞覆允月忒蚕 + * damage: 母丢□斥毛熬仃凶失弁扑亦件卞覆允月忒蚕 + * down: 逦木月失弁扑亦件卞覆允月忒蚕 + * sit: 甄月失弁扑亦件卞覆仄化及忒蚕 + * hand: 澎毛蕊月失弁扑亦件卞覆仄化及忒蚕 + * pleasure: 减少失弁扑亦件卞覆仄化及忒蚕 + * angry: 变月失弁扑亦件卞覆仄化及忒蚕 + * sad: 仄戈失弁扑亦件卞覆仄化及忒蚕 + * guard: 布□玉允月失弁扑亦件卞覆仄化及忒蚕 + */ + + +#define NPC_ACTION_MSGCOLOR_DEFAULT CHAR_COLORYELLOW + +enum { + CHAR_WORK_MSGCOLOR = CHAR_NPCWORKINT1, +}; + +/********************************* +* 赓渝质 +*********************************/ +BOOL NPC_ActionInit( int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + int tmp; + + tmp = NPC_Util_GetNumFromStrWithDelim( argstr, "msgcol"); + if( tmp == -1 ) tmp = NPC_ACTION_MSGCOLOR_DEFAULT; + CHAR_setWorkInt( meindex, CHAR_WORK_MSGCOLOR, tmp); + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEACTION ); + + + return TRUE; +} + + + + +/********************************* +* 仄井仃日木凶凛及质 +*********************************/ +void NPC_ActionTalked( int meindex , int talkerindex , char *szMes , + int color ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[64]; + + /* 皿伊奶乩□卞覆仄化分仃 杀允月 */ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + /* ㄠ弘伉永玉动 及心 */ + if( !NPC_Util_charIsInFrontOfChar( talkerindex, meindex, 1 )) return; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, + "normal", + buf, sizeof( buf)) + != NULL ) + { + CHAR_talkToCli( talkerindex, meindex ,buf , + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR )); + } + +} +/********************************* +* watch质 +*********************************/ +void NPC_ActionWatch( int meobjindex, int objindex, CHAR_ACTION act, + int x,int y,int dir, int* opt,int optlen ) +{ + int meindex; + int index; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[64]; + int i; + struct { + CHAR_ACTION act; + char *string; + }searchtbl[] = { + { CHAR_ACTATTACK, "attack"}, + { CHAR_ACTDAMAGE, "damage"}, + { CHAR_ACTDOWN, "down"}, + { CHAR_ACTSIT, "sit"}, + { CHAR_ACTHAND, "hand"}, + { CHAR_ACTPLEASURE, "pleasure"}, + { CHAR_ACTANGRY, "angry"}, + { CHAR_ACTSAD, "sad"}, + { CHAR_ACTGUARD, "guard"}, + { CHAR_ACTNOD, "nod"}, + { CHAR_ACTTHROW, "throw"}, + }; + + if( OBJECT_getType( objindex) != OBJTYPE_CHARA) return; + index = OBJECT_getIndex( objindex); + /* 皿伊奶乩□卞及心 杀允月 */ + if( CHAR_getInt( index, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER) return; + + meindex = OBJECT_getIndex( meobjindex); + + /* 轾五宁匀化ㄠ弘伉永玉匹卅中午 杀仄卅中 */ + if( NPC_Util_isFaceToFace( meindex, index, 1 ) != TRUE ) return; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + for( i = 0; i < arraysizeof( searchtbl); i ++ ) { + if( searchtbl[i].act == act) { + if( NPC_Util_GetStrFromStrWithDelim( argstr, + searchtbl[i].string, + buf, sizeof( buf)) + != NULL ) + { + CHAR_talkToCli( index, meindex ,buf , + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR )); + break; + } + } + } +} diff --git a/gmsv/npc/npc_airplane.c b/gmsv/npc/npc_airplane.c new file mode 100644 index 0000000..0aaffd6 --- /dev/null +++ b/gmsv/npc/npc_airplane.c @@ -0,0 +1,879 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "npc_airplane.h" +#include "handletime.h" + +/* + * 加美航空 (Made from Bus) + */ + +enum { + NPC_WORK_ROUTETOX = CHAR_NPCWORKINT1, /* 升仇尺" 甄 */ + 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, + NPC_WORK_ONEWAYFLG = CHAR_NPCWORKINT11, + NPC_WORK_RUNWAVE = CHAR_NPCWORKINT13, +}; + +/* 蛐 丢永本□斥及enum */ +enum { + NPC_AIR_MSG_GETTINGON, + NPC_AIR_MSG_NOTPARTY, + NPC_AIR_MSG_OVERPARTY, + NPC_AIR_MSG_DENIEDITEM, + NPC_AIR_MSG_ALLOWITEM, + NPC_AIR_MSG_LEVEL, + NPC_AIR_MSG_GOLD, + NPC_AIR_MSG_EVENT, + NPC_AIR_MSG_START, + NPC_AIR_MSG_END, +#ifdef _NPC_AIRDELITEM + NPC_AIR_MSG_DELITEM, +#endif +#ifdef _NPC_AIRLEVEL + NPC_AIR_MSG_MAXLEVEL, +#endif +}; +typedef struct { + char option[32]; + char defaultmsg[128]; +}NPC_AIR_MSG; +NPC_AIR_MSG airmsg[] = { + { "msg_gettingon", "PAON!(你无法於中途加入我们唷!)"}, + { "msg_notparty", "PAPAON!!无法以团队加入唷!"}, + { "msg_overparty", "PAON!!人数已满。"}, + { "msg_denieditem", "PAPAON!!我可不要这个道具!"}, + { "msg_allowitem", "哇喔~(想要那个道具啊!)"}, + { "msg_level", "PAPAON!!你的等级还不够唷!"}, + { "msg_stone", "PAPAON!!金钱不足唷!"}, + { "msg_event", "PAON!!你无法加入唷!"}, + { "msg_start", "哇喔~(出发进行)"}, + { "msg_end", "哇喔~(到罗)"} +#ifdef _NPC_AIRDELITEM + ,{ "msg_delitem", "你没有搭乘的道具"} +#endif +#ifdef _NPC_AIRLEVEL + ,{ "msg_maxlevel", "你的等级过高哦"} +#endif +}; + +static int NPC_AirSetPoint( int meindex, char *argstr); +static void NPC_AirSetDestPoint( int meindex, char *argstr); +static BOOL NPC_AirCheckDeniedItem( int meindex, int charaindex, char *argstr); +static BOOL NPC_AirCheckLevel( int meindex, int charaindex, char *argstr); +static int NPC_AirCheckStone( int meindex, int charaindex, char *argstr); +static void NPC_AirSendMsg( int meindex, int talkerindex, int tablenum); +static int NPC_AirGetRoutePointNum( int meindex, char *argstr ); +static void NPC_Air_walk( int meindex); +#ifdef _NPC_AIRLEVEL +static BOOL NPC_AirCheckMaxLevel( int meindex, int charaindex, char *argstr); +#endif + +#define NPC_AIR_LOOPTIME 100 +#define NPC_AIR_WAITTIME_DEFAULT 180 +#define NPC_AIR_WAITINGMODE_WAITTIME 5000 + +/********************************* +* 赓渝质 +*********************************/ +BOOL NPC_AirInit( int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + int i; + char buf[256],buf1[256]; + int routenum; + int waittime; + int seflg; + int onewayflg; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + /* 卅仃木壬中仃卅中娄醒及民尼永弁 */ + routenum = NPC_Util_GetNumFromStrWithDelim( argstr, "routenum"); + if( routenum == -1 ) { + print( "npcair:nothing routenum \n"); + return FALSE; + } + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEMAX, routenum); + + for( i = 1; i <= routenum; i ++ ) { + char routetostring[64]; + snprintf( routetostring, sizeof( routetostring), "routeto%d", i); + if( NPC_Util_GetStrFromStrWithDelim( argstr, routetostring,buf, sizeof(buf)) + == NULL ) + { + print( "npcair:nothing route to \n"); + return FALSE; + } + } + //ANDY_ADD NPC_WORK_RUNWAVE + if( NPC_Util_GetStrFromStrWithDelim( argstr, "WAVE",buf1, sizeof(buf1)) == NULL ) { + CHAR_setWorkInt( meindex, NPC_WORK_RUNWAVE, 77); + }else { + CHAR_setWorkInt( meindex, NPC_WORK_RUNWAVE, atoi( buf1) ); + } + + waittime = NPC_Util_GetNumFromStrWithDelim( argstr, "waittime"); + if( waittime == -1 ) waittime = NPC_AIR_WAITTIME_DEFAULT; + CHAR_setWorkInt( meindex, NPC_WORK_WAITTIME, waittime); + + seflg = NPC_Util_GetNumFromStrWithDelim( argstr, "seflg"); + if( seflg == -1 ) seflg = TRUE; + CHAR_setWorkInt( meindex, NPC_WORK_SEFLG, seflg); + + onewayflg = NPC_Util_GetNumFromStrWithDelim( argstr, "oneway"); + if( onewayflg == -1 ) onewayflg = FALSE; // default + CHAR_setWorkInt( meindex, NPC_WORK_ONEWAYFLG, onewayflg); + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEBUS ); + + CHAR_setWorkInt( meindex, NPC_WORK_MODE, 0); + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, 2); + CHAR_setWorkInt( meindex, NPC_WORK_ROUNDTRIP, 0); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTROUTE, 0); + + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, + NPC_AIR_WAITINGMODE_WAITTIME); + + /* 蜇箕及凛棉毛本永玄 */ + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + + for( i = 0; i < CHAR_PARTYMAX; i ++) { + CHAR_setWorkInt( meindex, CHAR_WORKPARTYINDEX1 + i, -1); + } + + /* 伙□玄瑁烂允月 */ +{ + int rev; + int r = CHAR_getWorkInt( meindex, NPC_WORK_ROUTEMAX); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTROUTE, RAND( 1, r)); + //print( "route:%d\n",CHAR_getWorkInt( meindex, NPC_WORK_CURRENTROUTE)); + + /* 欠旦正□玄 */ + rev = NPC_Util_GetNumFromStrWithDelim( argstr, "reverse"); + if( rev == 1 ) { + int num = NPC_AirGetRoutePointNum( meindex, argstr); + if( num <= 0 ) { + print( "npcairplane:真奇怪!\n"); + return FALSE; + } + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, num-1); + CHAR_setWorkInt( meindex, NPC_WORK_ROUNDTRIP, 1); + } + /* 伙□玄毛本永玄允月 */ + NPC_AirSetPoint( meindex, argstr); + /* 垫五燮毛 憎允月 */ + NPC_AirSetDestPoint( meindex, argstr); +} + + return TRUE; +} + + +/********************************* +* 仄井仃日木凶凛及质 +*********************************/ +void NPC_AirTalked( int meindex , int talkerindex , char *szMes , + int color ) +{ + int i; + int partyflg = FALSE; + int npc_wave = CHAR_getWorkInt( meindex, NPC_WORK_RUNWAVE); + + /* 皿伊奶乩□卞覆仄化分仃 杀允月 */ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + /* 愤坌及由□ 奴 昙菸 井升丹井譬屯月 */ + for( i = 0; i < CHAR_PARTYMAX; i ++ ) { + int index = CHAR_getWorkInt( meindex, CHAR_WORKPARTYINDEX1+i); + if( CHAR_CHECKINDEX(index)){ + if( index == talkerindex) { + partyflg = TRUE; + } + } + } + if( !partyflg ) { + //NPC_AirCheckJoinParty( meindex, talkerindex, TRUE); + } + else { + if( CHAR_getWorkInt( meindex, NPC_WORK_MODE) == 0 ) { + int i; + // #define NPC_AIR_DEBUGROUTINTG "routingtable:" + if( strstr( szMes, "出发" ) || + strstr( szMes, "出发" ) || + strstr( szMes, "Go" ) || + strstr( szMes, "go" )) + { + CHAR_setWorkInt( meindex, NPC_WORK_MODE,1); + + /* 伙□皿楮醒及裟请仄毛汹仁簧蘸卞允月 */ + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, NPC_AIR_LOOPTIME); + + /* SE 日允 穴件乒旦及陲太 */ + if( CHAR_getWorkInt( meindex, NPC_WORK_SEFLG )) { + //andy_reEdit NPC_WORK_RUNWAVE + CHAR_sendSEoArroundCharacter( + CHAR_getInt( meindex, CHAR_FLOOR), + CHAR_getInt( meindex, CHAR_X), + CHAR_getInt( meindex, CHAR_Y), + npc_wave, + TRUE); + } + /* 请 允月凛及丢永本□斥*/ + for( i = 1; i < CHAR_PARTYMAX; i ++ ) { + int partyindex = CHAR_getWorkInt( meindex, CHAR_WORKPARTYINDEX1+i); + if( CHAR_CHECKINDEX( partyindex)) { + NPC_AirSendMsg( meindex, partyindex, NPC_AIR_MSG_START); + } + } + } + } +#if 0 + else if( strstr( szMes, "停止" ) || + strstr( szMes, "停止" ) || + strstr( szMes, "stop" ) || + strstr( szMes, "Stop" )) + { + CHAR_setWorkInt( meindex, NPC_WORK_MODE,2); + + /* 伙□皿楮醒及奶件正□田伙毛聂仁允月 */ + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, + NPC_AIR_WAITINGMODE_WAITTIME); + /* 蜇箕及凛棉毛本永玄 */ + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + } + else if( strstr( szMes, NPC_AIR_DEBUGROUTINTG )) { + /* 犯田永弘迕 */ + char *p = strstr( szMes,NPC_AIR_DEBUGROUTINTG); + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + if( p) { + int a = atoi( p+strlen(NPC_AIR_DEBUGROUTINTG)); + if( a <0 ) a = 1; + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTROUTE, a); + } + //print( "route:%d\n",CHAR_getWorkInt( meindex, NPC_WORK_CURRENTROUTE)); + /* 伙□玄毛本永玄允月 */ + NPC_AirSetPoint( meindex, argstr); + } +#endif + } +} +/************************************** + * 伙□皿楮醒 + **************************************/ +void NPC_AirLoop( int meindex) +{ + int i; + int npc_wave = CHAR_getWorkInt( meindex, NPC_WORK_RUNWAVE); + switch( CHAR_getWorkInt( meindex, NPC_WORK_MODE )) { + case 0: + /* 谨切乒□玉及凛]凛棉毛民尼永弁允月 */ + /* 凛棉互烦匀凶及匹]请 允月 */ + if( CHAR_getWorkInt( meindex, NPC_WORK_CURRENTTIME) + + CHAR_getWorkInt( meindex, NPC_WORK_WAITTIME) + < NowTime.tv_sec) + { + /* SE 日允 穴件乒旦及陲太 */ + if( CHAR_getWorkInt( meindex, NPC_WORK_SEFLG )) { + //ANDY_reEdit + CHAR_sendSEoArroundCharacter( + CHAR_getInt( meindex, CHAR_FLOOR), + CHAR_getInt( meindex, CHAR_X), + CHAR_getInt( meindex, CHAR_Y), + npc_wave, + TRUE); + } + /* 请 允月凛及丢永本□斥*/ + for( i = 1; i < CHAR_PARTYMAX; i ++ ) { + int partyindex = CHAR_getWorkInt( meindex, CHAR_WORKPARTYINDEX1+i); + if( CHAR_CHECKINDEX( partyindex)) { + NPC_AirSendMsg( meindex, partyindex, NPC_AIR_MSG_START); + } + } + + CHAR_setWorkInt( meindex, NPC_WORK_MODE,1); + /* 伙□皿楮醒及裟请仄毛汹仁簧蘸卞允月 */ + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, NPC_AIR_LOOPTIME); + } + return; + case 1: + /* 汹仁 */ + NPC_Air_walk( meindex); + case 2: + /* 鞅引匀化中月乒□玉 */ + /* 凛棉互烦匀凶及匹]请 允月 */ + if( CHAR_getWorkInt( meindex, NPC_WORK_CURRENTTIME) + + (CHAR_getWorkInt( meindex, NPC_WORK_WAITTIME) /3) + < NowTime.tv_sec) + { + CHAR_setWorkInt( meindex, NPC_WORK_MODE,1); + /* 伙□皿楮醒及裟请仄毛汹仁簧蘸卞允月 */ + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, NPC_AIR_LOOPTIME); + + } + return; + case 3: + /* 谗邋仄化手]弁仿奶失件玄及 樟谨切及啃卞] + * 剂仄仇仇匹它尼奶玄毛中木化支月 + */ + if( CHAR_getWorkInt( meindex, NPC_WORK_CURRENTTIME) + 3 < NowTime.tv_sec){ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, NPC_AIR_WAITINGMODE_WAITTIME); + { + int r = CHAR_getWorkInt( meindex, NPC_WORK_ROUTEMAX); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTROUTE, RAND( 1, r)); + } + CHAR_setWorkInt( meindex, NPC_WORK_ROUNDTRIP, + CHAR_getWorkInt( meindex, NPC_WORK_ROUNDTRIP)^1); + if( CHAR_getWorkInt( meindex, NPC_WORK_ROUNDTRIP) == 1) { + int num = NPC_AirGetRoutePointNum( meindex, argstr); + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, num-1); + }else { + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, + CHAR_getWorkInt( meindex, NPC_WORK_ROUTEPOINT) +1); + } + NPC_AirSetPoint( meindex, argstr); + NPC_AirSetDestPoint( meindex, argstr); + CHAR_DischargeParty( meindex, 0); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + if ((CHAR_getWorkInt(meindex, NPC_WORK_ONEWAYFLG) == 1) && + (CHAR_getWorkInt(meindex, NPC_WORK_ROUNDTRIP) == 1) ){ + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, NPC_AIR_LOOPTIME); + CHAR_setWorkInt( meindex, NPC_WORK_MODE, 1); + } else + CHAR_setWorkInt( meindex, NPC_WORK_MODE, 0); + } + return; + default: + break; + } +} +/************************************** + * 汹仁[ + **************************************/ +static void NPC_Air_walk( int meindex) +{ + POINT start, end; + int dir; + int ret; + int i; + int npc_wave = CHAR_getWorkInt( meindex, NPC_WORK_RUNWAVE ); + + /* 汹仁楮溢 */ + /* 谗邋仄凶凛及质 */ + start.x = CHAR_getInt( meindex, CHAR_X); + start.y = CHAR_getInt( meindex, CHAR_Y); + end.x = CHAR_getWorkInt( meindex, NPC_WORK_ROUTETOX); + end.y = CHAR_getWorkInt( meindex, NPC_WORK_ROUTETOY); + + /* 谗邋仄凶及匹戚及禾奶件玄卞 */ + if( start.x == end.x && start.y == end.y ) { + int add = 1; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + if( CHAR_getWorkInt( meindex, NPC_WORK_ROUNDTRIP ) == 1 ) { + add *= -1; + } + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, + CHAR_getWorkInt( meindex, NPC_WORK_ROUTEPOINT) +add); + if( NPC_AirSetPoint( meindex, argstr) == FALSE ) { + /* 卞谗邋*/ + /* 谨切乒□玉卞允月 */ + CHAR_setWorkInt( meindex, NPC_WORK_MODE,3); + + /* SE 日允 穴件乒旦及陲太 */ + if( CHAR_getWorkInt( meindex, NPC_WORK_SEFLG )) { + //ANDY_reEdit + CHAR_sendSEoArroundCharacter( + CHAR_getInt( meindex, CHAR_FLOOR), + CHAR_getInt( meindex, CHAR_X), + CHAR_getInt( meindex, CHAR_Y), + npc_wave, + TRUE); + } + /* 邋中凶凛及丢永本□斥*/ + for( i = 1; i < CHAR_PARTYMAX; i ++ ) { + int partyindex = CHAR_getWorkInt( meindex, CHAR_WORKPARTYINDEX1+i); + if( CHAR_CHECKINDEX( partyindex)) { + NPC_AirSendMsg( meindex, partyindex, NPC_AIR_MSG_END); + } + } + /* 蜇箕及凛棉毛本永玄 */ + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + return; + } + else { + return; + } + } + /*-------------------------------------------------------*/ + /* 汹井六月质 */ + + /* 轾毛菲户月 */ + dir = NPC_Util_getDirFromTwoPoint( &start,&end ); + + /* 漆中月桦赭及谨 由□ 奴汹五匹银丹 */ + end.x = CHAR_getInt( meindex, CHAR_X); + end.y = CHAR_getInt( meindex, CHAR_Y); + +#if 0 + /* 夫匀井井匀凶凛及啃及质 */ + for( i = 0; i < 100; i ++ ) { + if( dir < 0 ) { + dir = RAND( 0,7); + } + dir = NPC_Util_SuberiWalk( meindex, dir); + if( dir >= 0 && dir <= 7) break; + } +#endif + + if( dir >= 0 && dir <= 7 ) { + /* 汹仁 */ + ret = CHAR_walk( meindex, dir, 0); + + if( ret == CHAR_WALKSUCCESSED ) { + /* 愤坌互褪卅日醮棉毛汹井六月 */ + int i; + int mefl=CHAR_getInt( meindex, CHAR_FLOOR); + for( i = 1; i < CHAR_PARTYMAX; i ++ ) { + int toindex = CHAR_getWorkInt( meindex, i + CHAR_WORKPARTYINDEX1); + int fl = CHAR_getInt( toindex, CHAR_FLOOR); + int xx = CHAR_getInt( toindex, CHAR_X); + int yy = CHAR_getInt( toindex, CHAR_Y); + if( CHAR_CHECKINDEX(toindex) && + (mefl==fl) && (abs(xx-end.x)+abs(yy-end.y)<10) ) { + int parent_dir; + /* 阂及匏 午]褪及汹五蟆及匏 井日 轾毛菲户月 */ + /* 汹仁 */ + start.x = xx; + start.y = yy; + parent_dir = NPC_Util_getDirFromTwoPoint( &start,&end ); + /* 弘仿犯奴它旦左皿扑亦件汹五毛 蜇允月啃卞] + * 戚及阂反蟆及阂及 毛馨丹方丹卞允月 + */ + end = start; + if( parent_dir != -1 ) { + CHAR_walk( toindex, parent_dir, 0); + } + } + } + } + } +} +/************************************** + * 戚及桦赭毛本永玄允月 + **************************************/ +static int NPC_AirSetPoint( int meindex, char *argstr) +{ + char buf[4096]; + char buf2[256]; + char buf3[256]; + int floor,warpx,warpy; + int ret; + char routetostring[64]; + + snprintf( routetostring, sizeof( routetostring), "routeto%d", + CHAR_getWorkInt( meindex, NPC_WORK_CURRENTROUTE)); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, routetostring,buf, sizeof(buf)) + == NULL ) + { + print( "npcair:nothing route \n"); + return FALSE; + } + + ret = getStringFromIndexWithDelim( buf, ";", + CHAR_getWorkInt( meindex, NPC_WORK_ROUTEPOINT), + buf2, sizeof(buf2)); + if( ret == FALSE ) return FALSE; + + // Arminius: add floor + + ret = getStringFromIndexWithDelim( buf2, ",", 1, + buf3, sizeof(buf3)); + if( ret == FALSE) return FALSE; + floor = atoi(buf3); + + ret = getStringFromIndexWithDelim( buf2, ",", 2, + buf3, sizeof(buf3)); + if( ret == FALSE) return FALSE; + CHAR_setWorkInt( meindex, NPC_WORK_ROUTETOX, atoi( buf3)); + warpx = atoi(buf3); + + ret = getStringFromIndexWithDelim( buf2, ",", 3, + buf3, sizeof(buf3)); + if( ret == FALSE) return FALSE; + CHAR_setWorkInt( meindex, NPC_WORK_ROUTETOY, atoi( buf3)); + warpy = atoi(buf3); + + if (floor!=CHAR_getInt(meindex, CHAR_FLOOR)) { + int i; + CHAR_warpToSpecificPoint(meindex, floor, warpx, warpy); + + for( i = 1; i < CHAR_PARTYMAX; i ++ ) { + int toindex = CHAR_getWorkInt( meindex, i + CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX(toindex) ) { + CHAR_warpToSpecificPoint(toindex, floor, warpx, warpy); + } + } + CHAR_setWorkInt( meindex, NPC_WORK_ROUTETOX, warpx); + CHAR_setWorkInt( meindex, NPC_WORK_ROUTETOY, warpy); + } + + return TRUE; +} +/************************************** + * route 寞井日] 蟆互丐匀凶日公木毛 + * 惫寞及午仇卞本永玄允月[ + **************************************/ +static void NPC_AirSetDestPoint( int meindex, char *argstr) +{ + char buf[256]; + char routename[256]; + + snprintf( routename, sizeof( routename), "routename%d", + CHAR_getWorkInt( meindex, NPC_WORK_CURRENTROUTE)); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, routename, buf, sizeof( buf)) + != NULL ) + { + CHAR_setChar( meindex, CHAR_OWNTITLE, buf); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX)); + } +} +/************************************** + * 隙烂今木凶失奶 丞毛 匀化中月井民尼永弁允月 + * 匀化中凶日分户 + **************************************/ +static BOOL NPC_AirCheckDeniedItem( int meindex, int charaindex, char *argstr) +{ + char buf[1024]; + BOOL found = TRUE; + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "denieditem", buf, sizeof( buf)) + != NULL ) + { + int i; + int ret; + for( i = 1; ; i ++) { + int itemid; + char buf2[64]; + int j; + ret = getStringFromIndexWithDelim( buf, ",", i, buf2, sizeof(buf2)); + if( ret == FALSE ) break; + itemid = atoi( buf2); + for( j = 0; j < CHAR_MAXITEMHAVE; j ++) { + int itemindex = CHAR_getItemIndex( charaindex, j); + if( ITEM_CHECKINDEX( itemindex)) { + if( ITEM_getInt( itemindex, ITEM_ID) == itemid) { + found = FALSE; + break; + } + } + } + } + } + return found; +} +/************************************** + * 隙烂今木凶失奶 丞毛 匀化中月井民尼永弁允月 + * 匀化中卅中午分户 + **************************************/ +BOOL NPC_AirCheckAllowItem( int meindex, int charaindex, BOOL pickupmode) +{ + char buf[1024]; + BOOL found = TRUE; + BOOL pickup = FALSE; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "pickupitem", buf, sizeof( buf)) + != NULL ) + { + pickup = TRUE; + } + if( NPC_Util_GetStrFromStrWithDelim( argstr, "allowitem", buf, sizeof( buf)) + != NULL ) + { + int i; + int ret; + for( i = 1; ; i ++) { + int itemid; + char buf2[64]; + int j; + BOOL getflg; + ret = getStringFromIndexWithDelim( buf, ",", i, buf2, sizeof(buf2)); + if( ret == FALSE ) break; + itemid = atoi( buf2); + getflg = FALSE; + for( j = 0; j < CHAR_MAXITEMHAVE; j ++) { + int itemindex = CHAR_getItemIndex( charaindex, j); + if( ITEM_CHECKINDEX( itemindex)) { + if( ITEM_getInt( itemindex, ITEM_ID) == itemid) { + /* 椭瘀互缭匀化中月井日]公及失奶 丞毛潸月 */ + if( pickupmode && pickup && !getflg) { + CHAR_DelItem( charaindex, j); + getflg = TRUE; + } + break; + } + } + } + if( j == CHAR_MAXITEMHAVE) { + found = FALSE; + break; + } + } + } + return found; +} + +/************************************** + * 隙烂今木凶伊矛伙动晓井民尼永弁允月 + **************************************/ +static BOOL NPC_AirCheckLevel( int meindex, int charaindex, char *argstr) +{ + int level; + + /* 卅仃木壬中仃卅中娄醒及民尼永弁 */ + level = NPC_Util_GetNumFromStrWithDelim( argstr, "needlevel"); + if( level == -1 ) { + return TRUE; + } + if( CHAR_getInt( charaindex, CHAR_LV) >= level ) return TRUE; + + return FALSE; +} + +#ifdef _NPC_AIRLEVEL +static BOOL NPC_AirCheckMaxLevel( int meindex, int charaindex, char *argstr) +{ + int level; + + /* 卅仃木壬中仃卅中娄醒及民尼永弁 */ + level = NPC_Util_GetNumFromStrWithDelim( argstr, "maxlevel"); + if( level == -1 ) { + return TRUE; + } + if( CHAR_getInt( charaindex, CHAR_LV) < level ) return TRUE; + + return FALSE; +} +#endif + +/************************************** + * 豢嗯毛民尼永弁允月 + * -1 蛲 0动晓” ]井勾 邰Stone + **************************************/ +static int NPC_AirCheckStone( int meindex, int charaindex, char *argstr) +{ + int gold; + + /* 卅仃木壬中仃卅中娄醒及民尼永弁 */ + gold = NPC_Util_GetNumFromStrWithDelim( argstr, "needstone"); + if( gold == -1 ) { + return 0; + } + if( CHAR_getInt( charaindex, CHAR_GOLD) >= gold ) return gold; + + return -1; +} +/************************************** + * 丢永本□斥毛霜月 + * 娄醒及丢永本□斥互卅仃木壬犯白巧伙玄丢永本□斥毛霜月 + **************************************/ +static void NPC_AirSendMsg( int meindex, int talkerindex, int tablenum) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[256]; + char msg[256]; + if( tablenum < 0 || tablenum >= arraysizeof( airmsg)) return; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, airmsg[tablenum].option, buf, sizeof( buf)) + != NULL ) + { + strcpy( msg, buf); + } + else { + snprintf( msg, sizeof(msg),airmsg[tablenum].defaultmsg); + } + CHAR_talkToCli( talkerindex, meindex, msg, CHAR_COLORYELLOW); +} +/************************************** + * 伙□玄 □皮伙及禾奶件玄及醒毛潸 允月 + **************************************/ +static int NPC_AirGetRoutePointNum( int meindex, char *argstr ) +{ + int i; + char buf[4096]; + char buf2[256]; + int ret; + char routetostring[64]; + + snprintf( routetostring, sizeof( routetostring), "routeto%d", + CHAR_getWorkInt( meindex, NPC_WORK_CURRENTROUTE)); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, routetostring,buf, sizeof(buf)) + == NULL ) + { + print( "npcair:nothing route \n"); + return -1; + } + for( i = 1; ; i ++ ) { + ret = getStringFromIndexWithDelim( buf, ";", i, buf2, sizeof(buf2)); + if( ret == FALSE) break; + } + return( i -1); +} +BOOL NPC_AirCheckJoinParty( int meindex, int charaindex, BOOL msgflg) +{ + //int fd; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + int ret; + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + /* ㄠ弘伉永玉动 及心 */ + if( !NPC_Util_charIsInFrontOfChar( charaindex, meindex, 1 )) return FALSE; + /* 昙乐反蛐 允月 */ + if( CHAR_getWorkInt( meindex, NPC_WORK_MODE) != 0 ) { + if( msgflg) NPC_AirSendMsg( meindex, charaindex, NPC_AIR_MSG_GETTINGON); + return FALSE; + } + /* 天□化不分匀凶日分户 */ + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE ) != CHAR_PARTY_NONE) { + if( msgflg) NPC_AirSendMsg( meindex, charaindex, NPC_AIR_MSG_NOTPARTY); + return FALSE; + } + /* 由□ 奴及谛醒毛民尼永弁允月 */ + if( CHAR_getEmptyPartyArray( meindex) == -1 ) { + if( msgflg) NPC_AirSendMsg( meindex, charaindex, NPC_AIR_MSG_OVERPARTY); + return FALSE; + } + /* 失奶 丞及民尼永弁毛允月(嗟鞅失奶 丞) */ + if( !NPC_AirCheckDeniedItem( meindex, charaindex, argstr)) { + if( msgflg) NPC_AirSendMsg( meindex, charaindex, NPC_AIR_MSG_DENIEDITEM); + return FALSE; + } +#ifdef _ITEM_CHECKWARES + if( CHAR_CheckInItemForWares( charaindex, 0) == FALSE ) { + CHAR_talkToCli( charaindex, -1, "无法携带货物上机。", CHAR_COLORYELLOW); + return FALSE; + } +#endif + + /* 失奶 丞及民尼永弁毛允月( 邰失奶 丞) */ + if( !NPC_AirCheckAllowItem( meindex, charaindex, FALSE)) { + if( msgflg) NPC_AirSendMsg( meindex, charaindex, NPC_AIR_MSG_ALLOWITEM); + return FALSE; + } +#ifdef _NPC_AIRDELITEM + if( !NPC_AirCheckDelItem( meindex, charaindex, FALSE) ){ //若是没扣除了道具 + if( msgflg ) NPC_AirSendMsg( meindex, charaindex, NPC_AIR_MSG_DELITEM); + return FALSE; + } +#endif + /* 伊矛伙及民尼永弁毛允月 */ + if( !NPC_AirCheckLevel( meindex, charaindex, argstr)) { + if( msgflg) NPC_AirSendMsg( meindex, charaindex, NPC_AIR_MSG_LEVEL); + return FALSE; + } +#ifdef _NPC_AIRLEVEL + if( !NPC_AirCheckMaxLevel( meindex, charaindex, argstr)) { + if( msgflg) NPC_AirSendMsg( meindex, charaindex, NPC_AIR_MSG_MAXLEVEL); + return FALSE; + } +#endif + /* 奶矛件玄 井民尼永弁允月 */ +// if( CHAR_getInt( charaindex, CHAR_NOWEVENT) != 0 || +// CHAR_getInt( charaindex, CHAR_NOWEVENT2) != 0 || +// CHAR_getInt( charaindex, CHAR_NOWEVENT3) != 0 ) +// { +// if( msgflg) NPC_AirSendMsg( meindex, charaindex, NPC_AIR_MSG_EVENT); +// return FALSE; +// } + /* 豢嗯及民尼永弁毛允月 云嗯毛潸月及匹] 蔽民尼永弁卞允月仇午″ */ + ret = NPC_AirCheckStone( meindex, charaindex, argstr); + if( ret == -1 ) { + if( msgflg) NPC_AirSendMsg( meindex, charaindex, NPC_AIR_MSG_GOLD); + return FALSE; + } + if( ret != 0 ) { + char msgbuf[128]; + /* 豢嗯毛午月 */ + CHAR_setInt( charaindex, CHAR_GOLD, + CHAR_getInt( charaindex, CHAR_GOLD) - ret); + /* 霜耨 */ + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_GOLD); + snprintf( msgbuf, sizeof( msgbuf), "支付了%d Stone!", ret); + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORYELLOW); + } + /* 由□ 奴卞 月 */ + //CHAR_JoinParty_Main( charaindex, meindex); + + //fd = getfdFromCharaIndex( charaindex ); + + //lssproto_PR_send( fd, 1, 1); + + return TRUE; +} + +#ifdef _NPC_AIRDELITEM //上飞机时,检查是否要扣除道具 +BOOL NPC_AirCheckDelItem( int meindex, int charaindex, BOOL pickupmode) +{ + char buf[1024]; + BOOL found = TRUE; + BOOL pickup = FALSE; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + if( NPC_Util_GetStrFromStrWithDelim( argstr, "delitem", buf, sizeof( buf)) + != NULL ) + { + int i; + int ret; + for( i = 1; ; i ++) { + int itemid; + char buf2[64]; + int j; + ret = getStringFromIndexWithDelim( buf, ",", i, buf2, sizeof(buf2)); + if( ret == FALSE ) break; + itemid = atoi( buf2); + for( j = 0; j < CHAR_MAXITEMHAVE; j ++) { + int itemindex = CHAR_getItemIndex( charaindex, j); + if( ITEM_CHECKINDEX( itemindex)) { + if( ITEM_getInt( itemindex, ITEM_ID) == itemid) { + CHAR_DelItem( charaindex, j); + break; + } + } + } + if( j == CHAR_MAXITEMHAVE) { + found = FALSE; + break; + } + } + } + return found; +} +#endif diff --git a/gmsv/npc/npc_alldoman.c b/gmsv/npc/npc_alldoman.c new file mode 100644 index 0000000..e04ff04 --- /dev/null +++ b/gmsv/npc/npc_alldoman.c @@ -0,0 +1,497 @@ +#include "version.h" +#include +#include +#include +#include "object.h" +#include "char_base.h" +#include "char.h" +#include "util.h" +#include "npcutil.h" +#include "item.h" +#include "readmap.h" +#include "enemy.h" +#include "chatmagic.h" +#include "log.h" +#include "npc_itemchange.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "npc_eventaction.h" +#include "npc_charm.h" + +#ifdef _ALLDOMAN +#include "npc_alldoman.h" + +#ifdef _FIX_ALLDOMAN +void Send_S_herolist( int ti ); +#define MAX_HERO_LIST 50 +typedef struct _tagHerolistBase +{ + char strings[3][64]; + int intdata[3]; + int use; +}HerolistBase; +HerolistBase Herolist[MAX_HERO_LIST]; +#else +#define MAX_HERO_COLUMN 7 +#define MAX_HERO_LIST 100 +char Herolist[MAX_HERO_LIST][MAX_HERO_COLUMN][72]; +#endif + + + +int sort[MAX_HERO_LIST][2]; +int countnum = -1 ; +int showpage = 1 ; +int totalpage = 1; + +static void NPC_Alldoman_selectWindow( int meindex, int talker, int seqno,char *data); + +void NPC_AlldomanWindowTalked(int meindex, int talkerindex, int seqno, int select,char *data) +{ + char buf2[256]; + char buf[256]; + int i; + int playernum = CHAR_getPlayerMaxNum(); + //andy_log + print( "seqno:%d\n", seqno); + switch(seqno) + { + case NPC_ALLDOMAN_MAIN_WND: + if ( select == WINDOW_BUTTONTYPE_NEXT ) { + showpage ++ ; + NPC_Alldoman_selectWindow(meindex , talkerindex , 4 ,""); + } + if ( select == WINDOW_BUTTONTYPE_OK ) { + //CHAR_talkToCli(talkerindex,meindex,"看清楚了!",CHAR_COLORRED); + showpage = 1 ; + NPC_Alldoman_selectWindow(meindex , talkerindex, 5 ,""); + } + break; + case NPC_ALLDOMAN_SELECT_WND: + if(atoi(data)==2) { + //CHAR_talkToCli(talkerindex,meindex,"1!",CHAR_COLORRED); + if ( CHAR_getInt( talkerindex , CHAR_FLOOR ) != 8200 ) { + CHAR_talkToCli(talkerindex,-1,"这里只能给真正的英雄刻写!",CHAR_COLORRED); + break; + } + if ( CHAR_getWorkInt( talkerindex , CHAR_WORKHEROFLOOR ) > 132 || + CHAR_getWorkInt( talkerindex , CHAR_WORKHEROFLOOR ) <= 0 ) { + CHAR_setWorkInt( talkerindex , CHAR_WORKHEROFLOOR , 0 ) ; + CHAR_talkToCli(talkerindex,-1,"这里只能给真正的英雄刻写!",CHAR_COLORRED); + break; + } + sprintf( buf2 , "你拿出了打败守灵者%3d的证明,试图将自己的姓名刻上石碑!" , CHAR_getWorkInt( talkerindex , CHAR_WORKHEROFLOOR ) ); + CHAR_talkToCli(talkerindex,-1,buf2,CHAR_COLORRED); + if ( CHAR_getWorkInt( talkerindex , CHAR_WORKHEROFLOOR ) == 132 ) { + sprintf( buf2 , "%s" , "尼斯大陆英雄" ) ; + //到达顶层对全星系广播 + sprintf( buf , "%s征服了英雄战场,由风之精灵将这个消息通知全世界,新的英雄诞生了!!" , CHAR_getChar( talkerindex, CHAR_NAME ) ); + for( i = 0 ; i < playernum ; i++) { + if( CHAR_getCharUse(i) != FALSE ) { + CHAR_talkToCli( i, -1, buf, CHAR_COLORBLUE2); + } + } + } + else if ( CHAR_getWorkInt( talkerindex , CHAR_WORKHEROFLOOR ) >= 130 ) + sprintf( buf2 , "%s" , "尼斯大陆战士" ) ; + else if ( CHAR_getWorkInt( talkerindex , CHAR_WORKHEROFLOOR ) >= 125 ) + sprintf( buf2 , "%s" , "尼斯大陆勇士" ) ; + else if ( CHAR_getWorkInt( talkerindex , CHAR_WORKHEROFLOOR ) >= 120 ) + sprintf( buf2 , "%s" , "萨伊那斯英雄" ) ; + else if ( CHAR_getWorkInt( talkerindex , CHAR_WORKHEROFLOOR ) >= 115 ) + sprintf( buf2 , "%s" , "斯巴达战士" ) ; + else if ( CHAR_getWorkInt( talkerindex , CHAR_WORKHEROFLOOR ) >= 110 ) + sprintf( buf2 , "%s" , "萨姆吉尔战士" ) ; + else if ( CHAR_getWorkInt( talkerindex , CHAR_WORKHEROFLOOR ) >= 100 ) + sprintf( buf2 , "%s" , "玛丽那丝战士" ) ; + else if ( CHAR_getWorkInt( talkerindex , CHAR_WORKHEROFLOOR ) >= 80 ) + sprintf( buf2 , "%s" , "卡坦战士" ) ; + else if ( CHAR_getWorkInt( talkerindex , CHAR_WORKHEROFLOOR ) >= 60 ) + sprintf( buf2 , "%s" , "霍特尔战士" ) ; + else if ( CHAR_getWorkInt( talkerindex , CHAR_WORKHEROFLOOR ) >= 40 ) + sprintf( buf2 , "%s" , "降魔勇士" ) ; + else if ( CHAR_getWorkInt( talkerindex , CHAR_WORKHEROFLOOR ) >= 20 ) + sprintf( buf2 , "%s" , "圣灵勇士" ) ; + else if ( CHAR_getWorkInt( talkerindex , CHAR_WORKHEROFLOOR ) >= 1 ) + sprintf( buf2 , "%s" , "初犊勇士" ) ; + else + sprintf( buf2 , " " ); + saacproto_UpdataStele_send ( + acfd , + CHAR_getChar( talkerindex , CHAR_CDKEY ), + CHAR_getChar( talkerindex , CHAR_NAME ) , + buf2 , + CHAR_getInt( talkerindex , CHAR_LV ) , + CHAR_getInt( talkerindex , CHAR_TRANSMIGRATION) , + 10 , + CHAR_getWorkInt( talkerindex , CHAR_WORKHEROFLOOR ) + ) ; + //清除WorkFloor + CHAR_setWorkInt( talkerindex , CHAR_WORKHEROFLOOR , 0 ) ; + } + if(atoi(data)==4) { + //CHAR_talkToCli(talkerindex,meindex,"2!",CHAR_COLORRED); + showpage = 1 ; + NPC_Alldoman_selectWindow(meindex , talkerindex, 6 ,""); + } + if(atoi(data)==6) { + //CHAR_talkToCli(talkerindex,meindex,"3!",CHAR_COLORRED); + } + break; + case NPC_ALLDOMAN_LIST_WND: + if( select == WINDOW_BUTTONTYPE_OK ){ + print("\nSyu log FloorWorkint => %d" , CHAR_getWorkInt( talkerindex , CHAR_WORKHEROFLOOR )); + } + if( select == WINDOW_BUTTONTYPE_PREV && showpage > 1 ) { + showpage -- ; + NPC_Alldoman_selectWindow(meindex , talkerindex, 6 ,"" ); + } + if( select == WINDOW_BUTTONTYPE_NEXT && showpage < totalpage ) { + showpage ++ ; + NPC_Alldoman_selectWindow(meindex , talkerindex, 6 ,""); + } + break; + } +} + +static void NPC_Alldoman_selectWindow( int meindex, int talker, int num, char *data) +{ + int buttontype = 0,windowtype = 0,windowno = 0 , i ; + int fd = getfdFromCharaIndex( talker); + char token[1024]; + char token2[100 * 100]; + + + //andy_log + print( "NPC_Alldoman_selectWindow( num:%d)\n", num); + switch(num) + { + case 4: + if ( showpage == 1 ) { + buttontype = WINDOW_BUTTONTYPE_NEXT; + sprintf( token, "485447圣饼时,吉鲁出现大批机暴横行,所到之处皆无一幸免,尼斯各村的长老达成共识,调集各村勇士,前往消灭这群发狂的机暴,这群勇士在海底隧道入口跟这群机暴激战,不料,实力相差悬殊,勇士们伤亡惨重,残馀的勇士,选择在霍特尔海底通路的入口做最"); + } + else if ( showpage == 2 ) { + buttontype = WINDOW_BUTTONTYPE_NEXT; + sprintf( token, "後的的抵抗,各村长老召集大批人力,封死所有通往吉鲁的海底通道,终於在大批机暴涌入前,将入口封死,此地为485550圣饼时所建造,为纪念485447圣饼时所牺牲的勇士,立此石碑,建此地洞,命名为“英雄战场”,望後世人效法先烈的行径,达到强种强"); + } + else if ( showpage == 3) { + buttontype = WINDOW_BUTTONTYPE_OK; + sprintf( token, "族为目的,让尼斯大陆的人们生生不息,上面的英雄是最近勇闯“英雄战场”所留下来的,特此诏告全尼斯英雄!\n\n 英雄战场制作委员会"); + } + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = NPC_ALLDOMAN_MAIN_WND; + lssproto_WN_send(fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token ); + break; + case 5: + buttontype = WINDOW_BUTTONTYPE_NONE; + windowtype = WINDOW_MESSAGETYPE_SELECT; + windowno = NPC_ALLDOMAN_SELECT_WND; + sprintf(token, + "0\n\n         刻写石碑" + "\n\n        检视其他勇者" + "\n\n          取消" + ); + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX),token); + break; + case 6: + if ( totalpage != 1 && showpage == 1 ) + buttontype = WINDOW_BUTTONTYPE_OK | WINDOW_BUTTONTYPE_NEXT; + else if ( totalpage == 1 ) + buttontype = WINDOW_BUTTONTYPE_OK ; + else if ( totalpage != 1 && showpage == totalpage ) + buttontype = WINDOW_BUTTONTYPE_OK | WINDOW_BUTTONTYPE_PREV; + else if ( totalpage != 1 && showpage != 1 && showpage != totalpage ) + buttontype = WINDOW_BUTTONTYPE_OK | WINDOW_BUTTONTYPE_PREV | WINDOW_BUTTONTYPE_NEXT; + windowtype = WINDOW_MESSAGETYPE_WIDEMESSAGEANDLINEINPUT; + windowno = NPC_ALLDOMAN_LIST_WND; + sprintf ( token2 , " 姓名 头衔 楼层 等级 转生\n"); + for ( i=0+(showpage-1 )*15; i= MAX_HERO_LIST || i<0 ) break; + if( Herolist[i].use == 0 ) continue; + sprintf( token , "%16s %13s %7d %7d %7d\n" , + Herolist[i].strings[1], Herolist[i].strings[2], + Herolist[i].intdata[3], Herolist[i].intdata[0], + Herolist[i].intdata[1] ); + strcat( token2, token); +#else + if( atoi ( Herolist[sort[MAX_HERO_LIST - 1 - i ][1]][6] ) == 0 || + atoi ( Herolist[sort[MAX_HERO_LIST - 1 - i ][1]][3] ) == 0 ) + continue ; + sprintf( token , "%16s %13s %7d %7d %7d\n" , + Herolist[sort[MAX_HERO_LIST - 1 - i ][1]][1] , + Herolist[sort[MAX_HERO_LIST - 1 - i ][1]][2] , + atoi ( Herolist[sort[MAX_HERO_LIST - 1 - i ][1]][6] ), + atoi ( Herolist[sort[MAX_HERO_LIST - 1 - i ][1]][3] ), + atoi ( Herolist[sort[MAX_HERO_LIST - 1 - i ][1]][4] ) + ); + strcat ( token2 , token ) ; + if ( i + 1 == countnum ) + break; +#endif + } + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX),token2); + break; + } +} + +static int loadherolist = 0; +BOOL NPC_AlldomanInit( int meindex ) +{ +//andy_log +//print( "\n\nNPC_AlldomanInit( %d)\n\n", meindex); + if( loadherolist == 0){ + loadherolist = 1; + saacproto_UpdataStele_send ( acfd , "FirstLoad", "LoadHerolist" , "华义" , 0 , 0 , 0 , 999 ) ; + } + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEALLDOMAN); + CHAR_setFlg( meindex , CHAR_ISATTACKED , 0 ); + return TRUE; +} + +void NPC_AlldomanTalked( int meindex , int talker , char *msg ,int color ) +{ + if( NPC_Util_CharDistance( talker, meindex ) > 1) return; + if( NPC_Util_isFaceToFace( talker, meindex , 1 ) == FALSE ) return; + showpage = 1 ; + NPC_Alldoman_selectWindow(meindex, talker , 4 ,""); +} +#ifdef _FIX_ALLDOMAN +void NPC_rePlaceHeroList( int fti, int tti) +{ + int i; + if( tti<0 || tti>=MAX_HERO_LIST ) return; + if( fti<0 || fti>=MAX_HERO_LIST ) return; + for( i=0; i<3; i++ ){ + sprintf( Herolist[tti].strings[i], "%s", Herolist[fti].strings[i]); + } + for( i=0; i<4; i++ ){ + Herolist[tti].intdata[i] = Herolist[fti].intdata[i]; + } + Herolist[tti].use = Herolist[fti].use; + Herolist[fti].use = 0; +} +#endif +void NPC_AlldomanWriteStele ( char *token ) +{ +/*#ifdef _FIX_ALLDOMAN + char buf1[512], buf2[256]; + int k=0, ti=-1, i; + BOOL rePlace = FALSE; + + if( token==NULL || strlen( token)<=0 ) return; + +//andy_log +print( "token:[%s]\n", token); + + if( getStringFromIndexWithDelim( token, ",", 1, buf1, sizeof( buf1) ) == FALSE ) return; +//andy_log +print( "buf1:[%s]\n", buf1); + if( !strcmp( buf1, "A|") ){ + for( i=0; i=MAX_HERO_LIST ) continue; + if( rePlace == TRUE ){ + for( i=MAX_HERO_LIST-1; i>ti; i++ ){ + NPC_rePlaceHeroList( i-1, i); + } + Herolist[ti].use = 0; + } + if( getStringFromIndexWithDelim( buf1, "|", 2, buf2, sizeof( buf2) ) == FALSE ) continue; + sprintf( Herolist[ti].strings[0], "%s", buf2 ); + if( getStringFromIndexWithDelim( buf1, "|", 3, buf2, sizeof( buf2) ) == FALSE ) continue; + sprintf( Herolist[ti].strings[1], "%s", buf2 ); + if( getStringFromIndexWithDelim( buf1, "|", 4, buf2, sizeof( buf2) ) == FALSE ) continue; + sprintf( Herolist[ti].strings[3], "%s", buf2 ); + + if( getStringFromIndexWithDelim( buf1, "|", 5, buf2, sizeof( buf2) ) == FALSE ) continue; + Herolist[ti].intdata[0] = atoi( buf2); + if( getStringFromIndexWithDelim( buf1, "|", 6, buf2, sizeof( buf2) ) == FALSE ) continue; + Herolist[ti].intdata[1] = atoi( buf2); + if( getStringFromIndexWithDelim( buf1, "|", 7, buf2, sizeof( buf2) ) == FALSE ) continue; + Herolist[ti].intdata[3] = atoi( buf2); + Herolist[ti].use = 1; +//andy_log +print( "ti:[%d]\n", ti); + } + //andy_log + for( i=0; i sort[j+1][0] ){ + flag = 1 ; + temp = sort[j][0]; + temp1 = sort[j][1]; + sort[j][0] = sort[j + 1][0]; + sort[j][1] = sort[j + 1][1]; + sort[j+1][0] = temp; + sort[j+1][1] = temp1; + } + } + if ( flag != 1 ) + break; + } + totalpage = countnum / 15 ; + if ( ( countnum % 15 ) != 0 ) + totalpage ++; +#endif + return; + } + } + linenum ++; +//#endif + + if ( (addr = strstr ( token , "\n" )) == NULL ) break; + strcpy ( token , addr + 1 ) ; + if( token == NULL || (lens = strlen( token)) <= 0 ) { +#ifdef _ALLDOMAN_DEBUG + countnum = 0 ; + for ( i = 0 ; i < MAX_HERO_LIST ; i ++ ) { + sort[i][0] = atoi ( Herolist[i][6] ) ; + sort[i][1] = i ; + if ( sort[i][0] != 0 && sort[i][0] != -1 ) + countnum ++ ; + } + for ( i = 0 ; i < MAX_HERO_LIST - 1 ; i ++ ) { + flag = 0 ; + for ( j = 0 ; j < MAX_HERO_LIST - 1 ; j ++ ) { + if ( sort[j][0] > sort[j+1][0] ){ + flag = 1 ; + temp = sort[j][0]; + temp1 = sort[j][1]; + sort[j][0] = sort[j + 1][0]; + sort[j][1] = sort[j + 1][1]; + sort[j+1][0] = temp; + sort[j+1][1] = temp1; + } + } + if ( flag != 1 ) + break; + } + totalpage = countnum / 15 ; + if ( ( countnum % 15 ) != 0 ) + totalpage ++; +#endif + return; + } + } + + countnum = 0 ; + for ( i = 0 ; i < MAX_HERO_LIST ; i ++ ) { + sort[i][0] = atoi ( Herolist[i][6] ) ; + sort[i][1] = i ; + if ( sort[i][0] != 0 && sort[i][0] != -1 ) + countnum ++ ; + } + + for ( i = 0 ; i < MAX_HERO_LIST - 1 ; i ++ ) { + flag = 0 ; + for ( j = 0 ; j < MAX_HERO_LIST - 1 ; j ++ ) { + if ( sort[j][0] > sort[j+1][0] ){ + flag = 1 ; + temp = sort[j][0]; + temp1 = sort[j][1]; + sort[j][0] = sort[j + 1][0]; + sort[j][1] = sort[j + 1][1]; + sort[j+1][0] = temp; + sort[j+1][1] = temp1; + } + } + if ( flag != 1 ) + break; + } + + + totalpage = countnum / 15 ; + if ( ( countnum % 15 ) != 0 ) + totalpage ++; +//#endif +} + +void NPC_Alldoman_S_WriteStele( char *ocdkey , char *oname , char *ncdkey , + char *nname , char *title , int level , int trns , int floor ) +{ +#ifdef _FIX_ALLDOMAN + return; +#else + int i , j , temp , temp1 , flag ; + for ( i = 0 ; i < MAX_HERO_COLUMN ; i ++ ) { + if ( ( strcmp( Herolist[i][0] , ocdkey ) == 0 ) && ( strcmp( Herolist[i][1] , oname ) == 0 ) ) { + sprintf( Herolist[i][0] , "%s" , ncdkey ) ; + sprintf( Herolist[i][1] , "%s" , nname ) ; + sprintf( Herolist[i][2] , "%s" , title ) ; + sprintf( Herolist[i][3] , "%d" , level ) ; + sprintf( Herolist[i][4] , "%d" , trns ) ; + sprintf( Herolist[i][6] , "%d" , floor ) ; + break; + } + } + countnum = 0 ; + for ( i = 0 ; i < MAX_HERO_LIST ; i ++ ) { + sort[i][0] = atoi ( Herolist[i][6] ) ; + sort[i][1] = i ; + if ( sort[i][0] != 0 && sort[i][0] != -1 ) + countnum ++ ; + } + for ( i = 0 ; i < MAX_HERO_LIST - 1 ; i ++ ) { + flag = 0 ; + for ( j = 0 ; j < MAX_HERO_LIST - 1 ; j ++ ) { + if ( sort[j][0] > sort[j+1][0] ){ + flag = 1 ; + temp = sort[j][0]; + temp1 = sort[j][1]; + sort[j][0] = sort[j + 1][0]; + sort[j][1] = sort[j + 1][1]; + sort[j+1][0] = temp; + sort[j+1][1] = temp1; + } + } + if ( flag != 1 ) + break; + } + totalpage = countnum / 15 ; + if ( ( countnum % 15 ) != 0 ) + totalpage ++ ; + +#endif +} + +#endif + diff --git a/gmsv/npc/npc_auctioneer.c b/gmsv/npc/npc_auctioneer.c new file mode 100644 index 0000000..9eb4a14 --- /dev/null +++ b/gmsv/npc/npc_auctioneer.c @@ -0,0 +1,17 @@ +#include "version.h" +#include +#include +#include "char.h" +#include "object.h" +#include "lssproto_serv.h" +#include "npcutil.h" +#include "handletime.h" +#include "char_base.h" +#include "configfile.h" +#include "npc_auctioneer.h" +#include "pet.h" +#include "item.h" +#include "util.h" +#include "anim_tbl.h" +#include "log.h" +#include "saacproto_cli.h" diff --git a/gmsv/npc/npc_bankman.c b/gmsv/npc/npc_bankman.c new file mode 100644 index 0000000..002819b --- /dev/null +++ b/gmsv/npc/npc_bankman.c @@ -0,0 +1,585 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "configfile.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "npc_bankman.h" +#include "family.h" + +extern int familyNumTotal; +extern char familyListBuf[MAXFAMILYLIST]; + +char sendbuf[1024]; +char buf[1024]; +char subbuf[128]; +int i, j; + + +struct { + int windowno; + int windowtype; + int buttontype; + int takeitem; + int giveitem; + char message[4096]; +}w; + +struct { + BOOL use; + int checkhaveitem; + int checkhaveitemgotowin; + int checkdonthaveitem; + int checkdonthaveitemgotowin; + int warp; + int battle; + int gotowin; +}buttonproc[13]; /* ok,cancel, yes,no,prev,next 及凛及质 */ + + + + + +enum { + CHAR_WORK_MSGCOLOR = CHAR_NPCWORKINT1, +}; +static void NPC_Bankman_selectWindow( int meindex, int toindex, int num); +static BOOL NPC_Bankman_readData( int meindex, int windowno, BOOL chkflg); +static int NPC_Bankman_restoreButtontype( char *data ); + +BOOL NPC_BankmanInit( int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024]; + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "conff", buf, sizeof( buf))== NULL ){ + print( "familyman:没有指定设定的档案 。\n"); + return FALSE; + } + /* 赓渝凛卞涩烂犯□正毛民尼永弁仄化支月 */ + if( !NPC_Bankman_readData( meindex, -1, TRUE) ) { + return FALSE; + } + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEWINDOWMAN ); + + return TRUE; +} + +void NPC_BankmanTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + + NPC_Bankman_selectWindow( meindex, talkerindex, 1 ); + +} + +void NPC_BankmanLooked( int meindex , int lookedindex) +{ + + print(" Look:me:%d,looked:%d ",meindex,lookedindex); + NPC_Bankman_selectWindow( meindex, lookedindex,1 ); + +} + +static void NPC_Bankman_selectWindow( int meindex, int toindex, int num) +{ + + int fd; + char buf[256]; + + /* 皿伊奶乩□卞覆仄化分仃 杀允月 */ + if( CHAR_getInt( toindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + /* ㄠ弘伉永玉动 及心 */ + if( !NPC_Util_charIsInFrontOfChar( toindex, meindex, 1 )) return; + + if( !NPC_Bankman_readData( meindex, num, FALSE) ) { + print( "familyman:readdata error\n"); + return; + } + + fd = getfdFromCharaIndex( toindex); + if( fd != -1 ) { + lssproto_WN_send( fd, w.windowtype, + w.buttontype, + w.windowno+100, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( w.message, buf, sizeof(buf))); + } +} + +void NPC_BankmanWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) + +{ + + int button = -1; + char buf[2048], buff[256]; + + /* ㄠ弘伉永玉动 及心 */ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) return; + + /* 仇及它奴件玉它 寞及犯□正毛 心 戈 */ + if( !NPC_Bankman_readData( meindex, seqno - 100, FALSE) ) { + print( "familyman:readdata error\n"); + return; + } + /* 瓷仄凶示正件毛譬屯月 */ + if( w.windowtype == WINDOW_MESSAGETYPE_SELECT ) { + //if( w.windowtype == WINDOW_MESSAGETYPE_MESSAGE ) { + // shan end + button = atoi( data)+5; + if( button > 12 ) { + print( "familyman:invalid button[%d]\n", button); + return; + } + } + else if( select & WINDOW_BUTTONTYPE_OK) button = 0; + else if( select & WINDOW_BUTTONTYPE_CANCEL) button = 1; + else if( select & WINDOW_BUTTONTYPE_YES) button = 2; + else if( select & WINDOW_BUTTONTYPE_NO) button = 3; + else if( select & WINDOW_BUTTONTYPE_PREV) button = 4; + else if( select & WINDOW_BUTTONTYPE_NEXT) button = 5; + else { + print( "familyman:invalid button[%d]\n", select); + return; + } + // shan begin + //if( buttonproc[button].use == TRUE ) { + //if( select > 0) { + if( button > 0 ) { + // shan end + int fd; + int newwin = -1; + + fd = getfdFromCharaIndex( talkerindex); + + /* 示正件卞方匀化质 毛孔曰歹仃月 */ + if( newwin == -1 ) { + newwin = buttonproc[button].gotowin; + } + + // Robin + // 银行 + // shan begin + if( select == WINDOW_BUTTONTYPE_YES) { + newwin = 5; + } + // shan end + if( newwin == 5 ) { + if( CHAR_getInt( talkerindex, CHAR_FMINDEX ) < 1 && + CHAR_getInt( talkerindex, CHAR_BANKGOLD) < 1 ) + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString("\n您的资格不符合!" + "\n请先加入家族!", buff, sizeof(buff))); + else { + sprintf(buf, "B|G|%d", CHAR_getInt( talkerindex, CHAR_BANKGOLD) ); + lssproto_FM_send( fd, buf ); + } + return; + } + // 家族帐户 + if( newwin == 6 ) + { + if( CHAR_getInt( talkerindex, CHAR_FMINDEX ) > 0 ) + saacproto_ACGetFMData_send( acfd, CHAR_getChar( talkerindex, CHAR_FMNAME), + CHAR_getInt( talkerindex, CHAR_FMINDEX ), + CHAR_getWorkInt( talkerindex, CHAR_WORKFMINDEXI ), + 1, + CONNECT_getFdid(fd) + ); + else + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString("\n您的资格不符合!" + "\n请先加入家族!", buff, sizeof(buff))); + return; + } + // 退出 + if( newwin == 7 ) + { + if( CHAR_getInt( talkerindex, CHAR_FMINDEX ) == -1 ) { + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString("\n您的资格不符合!" + "\n请先加入家族!", buff, sizeof(buff))); + return; + } + + print(" WN2FM "); + FAMILY_Leave( fd, talkerindex, "E|1"); + + return; + } + + if( !NPC_Bankman_readData( meindex, newwin, FALSE) ) { + print( "familyman:readdata error\n"); + return; + } + if( fd != -1 ) { + lssproto_WN_send( fd, w.windowtype, + w.buttontype, + w.windowno+100, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( w.message, buf, sizeof(buf))); + } + + + + } +} + +static BOOL NPC_Bankman_readData( int meindex, int windowno, BOOL chkflg) +{ + + int i; + int linenum = 0; + int endflg = FALSE; + int buttonendflg; + int winno = -1; + int buttonconfmode; + int b_mode; + int selectnum ; + int messagepos; + BOOL errflg = FALSE; + BOOL readflg = TRUE; + FILE *fp; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char filename[64]; + char opfile[128]; + char line[1024]; + char firstToken[1024]; + char secondToken[1024]; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + NPC_Util_GetStrFromStrWithDelim( argstr, "conff", filename, sizeof( filename)); + sprintf( opfile, "%s/", getNpcdir( ) ); + strcat( opfile, filename); + fp = fopen( opfile, "r"); + if( fp == NULL ) { + print( "familyman:file open error [%s]\n", opfile); + return FALSE; + } + + while( readflg == TRUE ) { + endflg = FALSE; + buttonendflg = TRUE; + buttonconfmode = FALSE; + selectnum = 0; + messagepos = 0; + winno = -1; + b_mode = -1; + errflg = FALSE; + + /* 赓渝祭 */ + w.windowno = -1; + w.windowtype = -1; + w.buttontype = -1; + w.takeitem = -1; + w.giveitem = -1; + w.message[0] = '\0'; + + for( i = 0; i < arraysizeof( buttonproc); i ++ ) { + buttonproc[i].use = FALSE; + buttonproc[i].checkhaveitem = -1; + buttonproc[i].checkhaveitemgotowin = -1; + buttonproc[i].checkdonthaveitem = -1; + buttonproc[i].checkdonthaveitemgotowin = -1; + buttonproc[i].warp = -1; + buttonproc[i].battle = -1; + buttonproc[i].gotowin = -1; + } + + while( 1) { + char buf[256]; + int ret; + if( !fgets( line, sizeof( line), fp)){ + readflg = FALSE; + break; + } + + linenum ++; + + /* 戊丢件玄反 骰 */ + if( line[0] == '#' || line[0] == '\n') continue; + /* 荼垫潸月 */ + chomp( line ); + + /* 垫毛帮溥允月 */ + /* 引内 tab 毛 " " 卞 五晶尹月 */ + replaceString( line, '\t' , ' ' ); + /* 燮 及旦矢□旦毛潸月[*/ + for( i = 0; i < strlen( line); i ++) { + if( line[i] != ' ' ) { + break; + } + strcpy( buf, &line[i]); + } + if( i != 0 ) strcpy( line, buf); + + /* delim "=" 匹 赓(1)及玄□弁件毛 月*/ + ret = getStringFromIndexWithDelim( line, "=", 1, firstToken, + sizeof( firstToken ) ); + if( ret == FALSE ){ + print( "Find error at %s in line %d. Ignore\n", + filename , linenum); + continue; + } + /* delim "=" 匹2 及玄□弁件毛 月*/ + ret = getStringFromIndexWithDelim( line, "=", 2, secondToken, + sizeof( secondToken ) ); + if( ret == FALSE ){ + print( "Find error at %s in line %d. Ignore\n", + filename , linenum); + continue; + } + + if( strcasecmp( firstToken, "winno") == 0 ) { + if( winno != -1 ) { + print( "familyman:已有winno却重新定义winno\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + readflg = FALSE; + break; + } + /* 它奴件玉它No毛忡绣 */ + winno = atoi( secondToken); + continue; + } + /* 它奴件玉它No 互瑁引匀化中卅中凛及垫反 骰允月 */ + if( winno == -1 ) { + print( "familyman:winno 尚未定义,资料却已设定。\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + readflg = FALSE; + errflg = FALSE; + break; + } + /* 它奴件玉它No 互域谯仄凶凛反椭瘀毛 戈[ + * 公木动陆反 骰允月 */ + if( (chkflg == FALSE && winno == windowno )|| + chkflg == TRUE) + { + if( buttonconfmode == TRUE ) { + if( strcasecmp( firstToken, "gotowin") == 0 ) { + buttonproc[b_mode].gotowin = atoi( secondToken); + } + else if( strcasecmp( firstToken, "checkhaveitem") == 0 ) { + buttonproc[b_mode].checkhaveitem = atoi( secondToken); + } + else if( strcasecmp( firstToken, "haveitemgotowin") == 0 ) { + buttonproc[b_mode].checkhaveitemgotowin = atoi( secondToken); + } + else if( strcasecmp( firstToken, "checkdonthaveitem") == 0 ) { + buttonproc[b_mode].checkdonthaveitem = atoi( secondToken); + } + else if( strcasecmp( firstToken, "donthaveitemgotowin") == 0 ) { + buttonproc[b_mode].checkdonthaveitemgotowin = atoi( secondToken); + } + else if( strcasecmp( firstToken, "endbutton") == 0 ) { + if( buttonproc[b_mode].gotowin == - 1 ) { + if( buttonproc[b_mode].checkhaveitem == -1 && + buttonproc[b_mode].checkdonthaveitem == -1) + { + errflg = TRUE; + } + else { + /* 升匀切井井凶匀吊分仃匹手涩烂今木化中木壬 */ + if( !((buttonproc[b_mode].checkhaveitem != -1 && + buttonproc[b_mode].checkhaveitemgotowin != -1) + || (buttonproc[b_mode].checkdonthaveitem != -1 && + buttonproc[b_mode].checkdonthaveitemgotowin != -1))) + { + errflg = TRUE; + } + } + } + + if( errflg == TRUE) { + print( "familyman: 找不到gotowin\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + readflg = FALSE; + errflg = TRUE; + break; + } + buttonproc[b_mode].use = TRUE; + buttonconfmode = FALSE; + buttonendflg = TRUE; + } + } + else { + + w.windowno = winno; + /* 它奴件玉它正奶皿及涩烂 */ + if( strcasecmp( firstToken, "wintype") == 0 ) { + w.windowtype = atoi( secondToken); + } + /* 示正件正奶皿及涩烂 */ + else if( strcasecmp( firstToken, "buttontype") == 0 ) { + w.buttontype = NPC_Bankman_restoreButtontype( secondToken); + } + /* getitem及涩烂 */ + else if( strcasecmp( firstToken, "takeitem") == 0 ) { + w.takeitem = atoi( secondToken); + } + /* giveitem及涩烂 */ + else if( strcasecmp( firstToken, "giveitem") == 0 ) { + w.giveitem = atoi( secondToken); + } + /* message及涩烂 */ + else if( strcasecmp( firstToken, "message") == 0 ) { + if( messagepos == 0 ) { + strcpy( w.message, secondToken); + messagepos = strlen( w.message); + } + else { + w.message[messagepos]='\n'; + messagepos++; + strcpy( &w.message[messagepos], secondToken); + messagepos+=strlen(secondToken); + } + } + /* 示正件毛瓷仄凶凛及涩烂 */ + else if( strcasecmp( firstToken, "okpressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 0; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "cancelpressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 1; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "yespressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 2; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "nopressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 3; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "prevpressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 4; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "nextpressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 5; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "selected") == 0 ) { + buttonconfmode = TRUE; + b_mode = 6 + selectnum; + buttonendflg = FALSE; + selectnum ++; + } + /* 涩烂蔽歹曰 */ + else if( strcasecmp( firstToken, "endwin") == 0 ) { + endflg = TRUE; + if( chkflg == FALSE) { + readflg = FALSE; + } + break; + } + else { + print( "familyman:设定是不可能的参数\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + } + } + } + else { + if( strcasecmp( firstToken, "endwin") == 0 ) { + winno = -1; + } + } + } + if( buttonendflg == FALSE) { + print( "familyman: 找不到endbutton\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + break; + } + if( winno != -1 ) { + if( w.windowtype == -1 ) { + print( "familyman: 找不到wintype\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + break; + } + if( w.buttontype == -1 ) { + print( "familyman: 找不到button\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + break; + } + if( strlen( w.message) == 0 ) { + print( "familyman: 找不到message\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + break; + } + } + } + fclose( fp); + + if( chkflg == FALSE && w.windowno == -1 ) { + print( "familyman: 找不到所指定的windowno\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + return FALSE; + } + if( winno != -1 && endflg == FALSE) { + print( "familyman: 找不到endwin\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + return FALSE; + } + if( errflg == TRUE) return FALSE; + + return TRUE; +} +/* + * buttontype=匹隙烂仄凶 侬 毛醒袄卞 晶允月[ + * + */ +static int NPC_Bankman_restoreButtontype( char *data ) +{ + int ret = 0; + int rc; + int i; + char buff[1024]; + + for( i = 1; ; i ++ ) { + rc = getStringFromIndexWithDelim( data, "|", i, buff, + sizeof( buff ) ); + if( rc == FALSE) break; + if( strcasecmp( buff, "ok") == 0 ) { + ret |= WINDOW_BUTTONTYPE_OK; + } + else if( strcasecmp( buff, "cancel") == 0 ) { + ret |= WINDOW_BUTTONTYPE_CANCEL; + } + else if( strcasecmp( buff, "yes") == 0 ) { + ret |= WINDOW_BUTTONTYPE_YES; + } + else if( strcasecmp( buff, "no") == 0 ) { + ret |= WINDOW_BUTTONTYPE_NO; + } + else if( strcasecmp( buff, "prev") == 0 ) { + ret |= WINDOW_BUTTONTYPE_PREV; + } + else if( strcasecmp( buff, "next") == 0 ) { + ret |= WINDOW_BUTTONTYPE_NEXT; + } + } + if( ret == 0 ) { + ret = atoi( data); + } + return ret; +} diff --git a/gmsv/npc/npc_bigsmallmaster.c b/gmsv/npc/npc_bigsmallmaster.c new file mode 100644 index 0000000..277b4e8 --- /dev/null +++ b/gmsv/npc/npc_bigsmallmaster.c @@ -0,0 +1,13 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "lssproto_serv.h" +#include "npcutil.h" +#include "handletime.h" +#include +#include "char_base.h" +#include "configfile.h" +#include "npc_bigsmallmaster.h" +#include "npc_windowman.h" + diff --git a/gmsv/npc/npc_bigsmallpet.c b/gmsv/npc/npc_bigsmallpet.c new file mode 100644 index 0000000..b2715c9 --- /dev/null +++ b/gmsv/npc/npc_bigsmallpet.c @@ -0,0 +1,11 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "lssproto_serv.h" +#include "npcutil.h" +#include "handletime.h" +#include +#include "char_base.h" +#include "configfile.h" +#include "npc_bigsmallpet.h" diff --git a/gmsv/npc/npc_blackmarket.c b/gmsv/npc/npc_blackmarket.c new file mode 100644 index 0000000..dbf09e5 --- /dev/null +++ b/gmsv/npc/npc_blackmarket.c @@ -0,0 +1,69 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "configfile.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" + +#ifdef _BLACK_MARKET +extern struct BlackMarketItem BMItem[BMIMAX]; +extern int BMINum; +extern int BMSellList[12]; + +void NPC_BlackMarketTalked( int meindex, int talker, char *msg, int color) +{ + char sBuf[512]="", tBuf[512]=""; + if(!CHAR_CHECKINDEX( talker)) return; + if(getfdFromCharaIndex( talker)==-1) return; + if(CHAR_getInt( talker, CHAR_WHICHTYPE)!=CHAR_TYPEPLAYER) return; + if(NPC_Util_isFaceToFace( talker, meindex, 1)!=TRUE) return; + + sprintf( tBuf, "嘿嘿....\n在我这边有各式各样的武器、防具及道具,你想要跟我交换吗?换好了可就不能反悔喔~"); + + lssproto_WN_send(getfdFromCharaIndex( talker), + WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_BLACKMARKET, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( tBuf, sBuf, sizeof(sBuf))); + return; +} +BOOL NPC_BlackMarketInit( int meindex) +{ + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_TYPEWINDOWMAN); + CHAR_setFlg( meindex, CHAR_ISATTACKED , 0); + return TRUE; +} +void NPC_BlackMarketWindowTalked( int index, int talker, int seqno, int select, char *data) +{ + int i; + char sBuf[1024]="", sBuf1[256]=""; + + if(!CHAR_CHECKINDEX( talker)) return; + if(getfdFromCharaIndex( talker)==-1) return; + if(CHAR_getInt( talker, CHAR_WHICHTYPE)!=CHAR_TYPEPLAYER) return; + if(NPC_Util_isFaceToFace( talker, index, 1)!=TRUE) return; + + if( seqno == CHAR_WINDOWTYPE_BLACKMARKET){ + for(i=0; i<12; i++){ + CONNECT_set_BMList( getfdFromCharaIndex( talker), i, BMSellList[i]); + sprintf( sBuf1, "%d|%d|%s\n", BMSellList[i], BMItem[BMSellList[i]].iGraphicsNum, BMItem[BMSellList[i]].iName); + strcat( sBuf, sBuf1); + } + + lssproto_WN_send( getfdFromCharaIndex( talker), + WINDOW_MESSAGETYPE_BLACKMARKET, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_BLACKMARKET, + CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), + sBuf ); + } +} +#endif + + + + diff --git a/gmsv/npc/npc_bodylan.c b/gmsv/npc/npc_bodylan.c new file mode 100644 index 0000000..33dc6fd --- /dev/null +++ b/gmsv/npc/npc_bodylan.c @@ -0,0 +1,487 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "npc_windowhealer.h" + + + + +/* + *迭{示犯奴仿件必□斥毛银尹壬 杀允月NPC + * 引内 仄井仃日木凶日}公及皿伊奶乩□卞 + * 仇及NPC及INDEX毛忡绣允月[ + * + *迫{NPC及璃曰匹失弁扑亦件互丐匀凶日}失弁扑亦件毛粟仇仄凶皿伊奶乩□互 + *NPC及INDEX毛忡 仄化中月井民尼永弁 + *民尼永弁 卅日戚反失弁扑亦件及扑□弗件旦民尼永弁允月 + *涡侗及失弁扑亦件毛仄化中凶日皿伊奶乩□及市它件玄毛失永皿今六月[ + *市它件玄失永皿 }蝈扑□弗件旦 卅日隙烂及桦赭尺伐□皿今六月 + * + */ + +enum { + BODYLAN_E_COMMANDNUM = CHAR_NPCWORKINT1, // 戊穴件玉及赢今 +}; + + +// 它奶件玉它乒□玉 +enum{ + BODYLAN_WIN_FIRST, + BODYLAN_WIN_LAST_GOOD, + BODYLAN_WIN_LAST_NG, + BODYLAN_WIN_GOOD_NO, + BODYLAN_WIN_ALREADY, + BODYLAN_WIN_NOT_PREEVENT, + BODYLAN_WIN_END +}; + +static void NPC_BodyLan_Profit( int meindex, int playerindex ); + +static void NPC_BodyLan_Window( + int meindex, + int talkerindex, + int mode +); + + +/********************************* +* 赓渝质 +*********************************/ +BOOL NPC_BodyLanInit( int meindex ) +{ + + char szP[256], szArg[4096]; + char buf[256]; + int i, needSeq; + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEEVENT ); + + if( NPC_Util_GetArgStr( meindex, szArg, sizeof( szArg ) ) == NULL ){ + print( "npc_bodylan.c:没有引数(%s)\n", + CHAR_getChar(meindex,CHAR_NPCARGUMENT) ); + return FALSE; + } + + + // 扑□弗件旦毛茧允 + if( NPC_Util_GetStrFromStrWithDelim( szArg, "Act", szP, sizeof( szP ) ) == NULL ){ + print( "npc_bodylan:动作文字列尚未设定(%s)\n", szArg ); + return FALSE; + } + + for( i = 0 ; ; i ++ ){ + // 邰卅赐 + if( getStringFromIndexWithDelim( szP, ",", i, buf, sizeof( buf)) != FALSE ){ + needSeq = atoi(buf); + // 穴奶瓜旦互 凶日仇仇引匹 + if( needSeq < 0 ){ + if( i <= 0 ){ + print( "npc_bodylan:动作列尚未设定(%s)\n", szArg ); + } + // 醒毛本永玄 + CHAR_setWorkInt( meindex, BODYLAN_E_COMMANDNUM, i ); + break; + }else{ + // 伙□皿仄化醒尹月 + } + }else{ + if( i <= 0 ){ + print( "npc_bodylan:动作列尚未设定(%s)\n", szArg ); + } + // 醒毛本永玄 + CHAR_setWorkInt( meindex, BODYLAN_E_COMMANDNUM, i ); + break; + } + } + + + + return TRUE; + +} + + + + +/********************************* +* 仄井仃日木凶凛及质 +*********************************/ +void NPC_BodyLanTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + char szP[256], szArg[4096]; + int EventNo = -1,Pre_Event = -1; + + /* 皿伊奶乩□卞覆仄化分仃 杀允月 */ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + + /* ㄠ弘伉永玉动 及心 */ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 2 ) + { + return; + } + + // 娄醒 侬 + if( NPC_Util_GetArgStr( meindex, szArg, sizeof( szArg ) ) == NULL ){ + print( "npc_bodylan.c:没有引数(%s)\n", + CHAR_getChar(meindex,CHAR_NPCARGUMENT) ); + return ; + }else{ + // 奶矛件玄 寞潸 + if( NPC_Util_GetStrFromStrWithDelim( szArg, "EventNo", szP, sizeof( szP ) ) != NULL ){ + EventNo = atoi(szP); + } + // 仪蟆 邰奶矛件玄 寞潸 + if( NPC_Util_GetStrFromStrWithDelim( szArg, "Pre_Event", szP, sizeof( szP ) ) != NULL ){ + Pre_Event = atoi(szP); + } + } + + // 仪蟆卞 邰奶矛件玄 寞互丐木壬 + if( Pre_Event >= 0 ){ + // 奶矛件玄卞覆仄化升丹仄化中月井民尼永弁 + if( NPC_EventCheckFlg( talkerindex, Pre_Event ) == FALSE ){ + // 邰奶矛件玄毛弁伉失仄化中卅井匀凶日仇及本伉白 + NPC_BodyLan_Window( meindex, talkerindex, BODYLAN_WIN_NOT_PREEVENT ); + return; + } + } + // 奶矛件玄 寞互丐木壬 + if( EventNo >= 0 ){ + // 奶矛件玄卞覆仄化升丹仄化中月井民尼永弁 + if( NPC_EventCheckFlg( talkerindex, EventNo ) == TRUE ){ + // 匀化中凶日仇及本伉白 + NPC_BodyLan_Window( meindex, talkerindex, BODYLAN_WIN_ALREADY ); + return; + } + } + + // 蟆荚仇及皿伊奶乩□反愤坌午韵匀化中凶井 + if( CHAR_getWorkInt( talkerindex, CHAR_WORKTRADER ) == meindex ){ + + // 今日卞戊穴件玉互蝈 岳 仄化中凶日 + if( CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT ) + >= CHAR_getWorkInt( meindex, BODYLAN_E_COMMANDNUM ) + ){ + // 岳 ″″仍 井" + NPC_BodyLan_Window( meindex, talkerindex, BODYLAN_WIN_LAST_GOOD ); + return; + }else{ + // 撩 + NPC_BodyLan_Window( meindex, talkerindex, BODYLAN_WIN_LAST_NG ); + return; + } + }else{ + // 赓户化卅及匹创尹月 + // 皿伊奶乩□卞愤坌及奶件犯永弁旦毛忡绣今六月 + CHAR_setWorkInt( talkerindex, CHAR_WORKTRADER, meindex ); + // 扑□弗件旦反 赓井日卞赓渝祭 + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 1 ); + + // 公及端本伉白午井韵月屯五井卅丐’’’ + NPC_BodyLan_Window( meindex, talkerindex, BODYLAN_WIN_FIRST ); + return; + } +} + + +/*======================================= + * watch 质 + *======================================*/ +void NPC_BodyLanWatch( + int objmeindex, + int objmoveindex, + CHAR_ACTION act, + int x, + int y, + int dir, + int* opt, + int optlen +) +{ + char szP[256], szArg[4096]; + char buf[256]; + int actindex; + int meindex; + int seqNo, needSeq; + + // 平乓仿弁正动陆反伉正□件 + if( OBJECT_getType(objmoveindex) != OBJTYPE_CHARA ) return; + actindex = OBJECT_getIndex(objmoveindex); + // 皿伊奶乩□动陆反伉正□件 + if( CHAR_getInt( actindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) return; + + // 愤坌及奶件犯永弁旦 + meindex = OBJECT_getIndex(objmeindex); + + // 愤坌及INDEX毛忡 仄化中月井"中卅仃木壬伉正□件 + if( CHAR_getWorkInt( actindex, CHAR_WORKTRADER ) != meindex ){ + return; + } + + // 升仇引匹失弁扑亦件毛仄化中月井 + seqNo = CHAR_getWorkInt( actindex, CHAR_WORKSHOPRELEVANT ); + // 卅桦宁反 赓井日 + if( seqNo < 1 )seqNo = 1; + + // 娄醒 侬 + if( NPC_Util_GetArgStr( meindex, szArg, sizeof( szArg ) ) == NULL ){ + print( "npc_bodylan.c:没有引数(%s)\n", + CHAR_getChar(meindex,CHAR_NPCARGUMENT) ); + return ; + } + + + // 扑□弗件旦毛茧允 + if( NPC_Util_GetStrFromStrWithDelim( szArg, "Act", szP, sizeof( szP ) ) == NULL ){ + print( "npc_bodylan:动作文字列尚未设定(%s)\n", szArg ); + return; + } + + // 邰卅赐 + if(getStringFromIndexWithDelim( szP, ",", seqNo, buf, sizeof( buf)) != FALSE ){ + needSeq = atoi(buf); + }else{ + // 卅兮井卅井匀凶日 赓井日 + CHAR_setWorkInt( actindex, CHAR_WORKSHOPRELEVANT, 1 ); + +// print( "做过头了。回到最初。\n", seqNo, needSeq ); + // 窒井韵月屯五井’’’ + return; + } + + // 漆荚 邰卅失弁扑亦件互域谯仄凶 + if( needSeq == act ){ + // 域谯仄凶[仇木互 井 +// print( "成功\(%d次数是%d)\n", seqNo, needSeq ); + seqNo ++; + if( seqNo >= CHAR_getWorkInt( meindex, BODYLAN_E_COMMANDNUM ) ){ +// print( "在此结束。\n" ); + } + // 仇及匏 毛忡绣 + CHAR_setWorkInt( actindex, CHAR_WORKSHOPRELEVANT, seqNo ); + }else{ + // 撩 仄凶桦宁反 赓井日支曰 仄 + CHAR_setWorkInt( actindex, CHAR_WORKSHOPRELEVANT, 1 ); +// print( "(%d次数是%d)\n", seqNo, needSeq ); + } + +} + + + +//********* 岳 凛及仍 ********* +static void NPC_BodyLan_Profit( int meindex, int playerindex ) +{ + char szArg[4096], szP[256]; + int fl, x, y, pmode, i, subindex, parent; + + // 娄醒 侬 + if( NPC_Util_GetArgStr( meindex, szArg, sizeof( szArg ) ) == NULL ){ + print( "npc_bodylan.c:没有引数(%s)\n", + CHAR_getChar(meindex,CHAR_NPCARGUMENT) ); + return ; + } + + //********************************************* + // + // 仍 公及ㄠ[伐□皿涩烂 + // + //********************************************* + if( NPC_Util_GetStrFromStrWithDelim( szArg, "Warp", szP, sizeof( szP ) ) != NULL ){ + // 仍 卞伐□皿[甄 潸月 + if( sscanf( szP, "%d,%d,%d", &fl, &x, &y ) == 3 ){ + }else{ + print( "npc_bodylan: 无法读取空间座标(%s)\n", szP ); + return; + } + // 由□ 奴赚氏匹月桦宁阂间手伐□皿 + pmode = CHAR_getWorkInt( playerindex, CHAR_WORKPARTYMODE ); + switch( pmode ){ + case 1: // 愤坌互褪 + parent = playerindex; + break; + case 2: // 愤坌互阂间[褪毛潸 + parent = CHAR_getWorkInt( playerindex, CHAR_WORKPARTYINDEX1 ); + break; + default: + // 由□ 奴元扎卅井匀凶[愤坌分仃伐□皿 + CHAR_warpToSpecificPoint( playerindex, fl, x, y ); + return; + } + // 蝈够伐□皿 + for( i = 0; i < CHAR_PARTYMAX; i ++ ){ + subindex = CHAR_getWorkInt( parent, CHAR_WORKPARTYINDEX1+i ); + if( CHAR_CHECKINDEX( subindex ) == FALSE )continue; + // 由□ 奴蝈够伐□皿 + CHAR_warpToSpecificPoint( subindex, fl, x, y ); + } + } + + + +} + +#if 1 +static void NPC_BodyLan_Window( + int meindex, + int talkerindex, + int mode +) +{ + char token[1024]; + char escapedname[2048]; + char szArg[4096]; + char szP[256]; + int fd; + int buttontype = 0, windowtype = 0, windowno = 0; + + if( CHAR_CHECKINDEX( talkerindex ) == FALSE )return; + fd = getfdFromCharaIndex( talkerindex ); + + // 娄醒 侬 + if( NPC_Util_GetArgStr( meindex, szArg, sizeof( szArg ) ) == NULL ){ + print( "npc_bodylan.c:没有引数(%s)\n", + CHAR_getChar(meindex,CHAR_NPCARGUMENT) ); + return ; + } + + szP[0] = 0; + + switch( mode ){ + case BODYLAN_WIN_FIRST: + // 赓卞 今木凶桦宁及本伉白 + if( NPC_Util_GetStrFromStrWithDelim( szArg, "First", szP, sizeof( szP ) ) == NULL ){ + print( "npc_bodylan:一开始讲话的文字没有输入(%s)\n", szArg ); + return; + } + sprintf( token,"%s", szP ); + buttontype=WINDOW_BUTTONTYPE_YES|WINDOW_BUTTONTYPE_NO; + windowtype=WINDOW_MESSAGETYPE_MESSAGE; + windowno=mode; + break; + + case BODYLAN_WIN_LAST_GOOD: + // 匹恳荸分匀凶日 + if( NPC_Util_GetStrFromStrWithDelim( szArg, "Good", szP, sizeof( szP ) ) == NULL ){ + print( "npc_bodylan:答对时说的文字没有输入(%s)\n", szArg ); + return; + } + sprintf( token,"%s", szP ); + buttontype=WINDOW_BUTTONTYPE_YESNO;// YES|NO + windowtype=WINDOW_MESSAGETYPE_MESSAGE; + windowno=mode; + break; + + case BODYLAN_WIN_LAST_NG: + // 匹恳荸分匀凶日 + if( NPC_Util_GetStrFromStrWithDelim( szArg, "Ng", szP, sizeof( szP ) ) == NULL ){ + print( "npc_bodylan:答错时说的文字没有输入(%s)\n", szArg ); + return; + } + sprintf( token,"%s", szP ); + buttontype=WINDOW_BUTTONTYPE_OK;// OK + windowtype=WINDOW_MESSAGETYPE_MESSAGE; + windowno=mode; + break; + + case BODYLAN_WIN_GOOD_NO: + // 恳荸凛卞 毛平乓件本伙 + if( NPC_Util_GetStrFromStrWithDelim( szArg, "Good_No", szP, sizeof( szP ) ) == NULL ){ + print( "npc_bodylan:答对时取消奖品的文字没有输入(%s)\n", szArg ); + return; + } + sprintf( token,"%s", szP ); + buttontype=WINDOW_BUTTONTYPE_OK;// OK + windowtype=WINDOW_MESSAGETYPE_MESSAGE; + windowno=mode; + break; + + case BODYLAN_WIN_ALREADY: + // 允匹卞奶矛件玄毛蔽 仄化中凶桦宁 + if( NPC_Util_GetStrFromStrWithDelim( szArg, "Good_No", szP, sizeof( szP ) ) == NULL ){ + print( "npc_bodylan:事件结束时的文字没有输入(%s)\n", szArg ); + return; + } + sprintf( token,"%s", szP ); + buttontype=WINDOW_BUTTONTYPE_OK; // OK + windowtype=WINDOW_MESSAGETYPE_MESSAGE; + windowno=mode; + break; + + case BODYLAN_WIN_NOT_PREEVENT: + // 仪蟆卞 邰卅奶矛件玄毛仇卅仄化中卅中桦宁 + if( NPC_Util_GetStrFromStrWithDelim( szArg, "Pre_Not", szP, sizeof( szP ) ) == NULL ){ + print( "npc_bodylan:?事前事件结束的文字没有输入(%s)\n", szArg ); + return; + } + sprintf( token,"%s", szP ); + buttontype=WINDOW_BUTTONTYPE_OK; // OK + windowtype=WINDOW_MESSAGETYPE_MESSAGE; + windowno=mode; + break; + default: + return; + } + + makeEscapeString( token, escapedname, sizeof(escapedname)); + /*-仇仇匹霜耨允月--*/ + lssproto_WN_send( fd, windowtype, + buttontype, + windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + escapedname); + + +} + + + +/*----------------------------------------- +弁仿奶失件玄井日忒匀化五凶凛卞裟太请今木月[ +-------------------------------------------*/ +void NPC_BodyLanWindowTalked( + int meindex, + int talkerindex, + int seqno, + int select, + char *data +) +{ + + + if( NPC_Util_CharDistance( talkerindex, meindex ) > 2) return; + + switch( seqno){ + case BODYLAN_WIN_LAST_GOOD: // 恳荸凛卞OK瓷今木凶日 + if(select==WINDOW_BUTTONTYPE_YES ){ + NPC_BodyLan_Profit( meindex, talkerindex ); + // 皿伊奶乩□卞愤坌及奶件犯永弁旦毛侉木今六月 + CHAR_setWorkInt( talkerindex, CHAR_WORKTRADER, -1 ); + // 扑□弗件旦反 赓井日卞赓渝祭 + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 1 ); + }else + if( select == WINDOW_BUTTONTYPE_NO ){ + // 恳荸凛卞平乓件本伙今木凶日 + NPC_BodyLan_Window( meindex, talkerindex, BODYLAN_WIN_GOOD_NO ); + // 皿伊奶乩□卞愤坌及奶件犯永弁旦毛侉木今六月 + CHAR_setWorkInt( talkerindex, CHAR_WORKTRADER, -1 ); + // 扑□弗件旦反 赓井日卞赓渝祭 + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 1 ); + } + break; + default: + break; + } + +} + + + +#endif + diff --git a/gmsv/npc/npc_bus.c b/gmsv/npc/npc_bus.c new file mode 100644 index 0000000..1fe73ee --- /dev/null +++ b/gmsv/npc/npc_bus.c @@ -0,0 +1,761 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "npc_bus.h" +#include "handletime.h" + +/* + * 田旦心凶中卅仪毛允月NPC + */ + +enum { + NPC_WORK_ROUTETOX = CHAR_NPCWORKINT1, /* 升仇尺" 甄 */ + 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 */ +enum { + NPC_BUS_MSG_GETTINGON, + NPC_BUS_MSG_NOTPARTY, + NPC_BUS_MSG_OVERPARTY, + NPC_BUS_MSG_DENIEDITEM, + NPC_BUS_MSG_ALLOWITEM, + NPC_BUS_MSG_LEVEL, + NPC_BUS_MSG_GOLD, + NPC_BUS_MSG_EVENT, + NPC_BUS_MSG_START, + NPC_BUS_MSG_END, +}; +typedef struct { + char option[32]; + char defaultmsg[128]; +}NPC_BUS_MSG; +NPC_BUS_MSG busmsg[] = { + { "msg_gettingon", "PAON!(你无法於中途加入我们唷!)"}, + { "msg_notparty", "PAPAON!!无法以团队加入唷!"}, + { "msg_overparty", "PAON!!人数已满。"}, + { "msg_denieditem", "PAPAON!!我可不要这个道具!"}, + { "msg_allowitem", "哇喔~(想要那个道具啊!)"}, + { "msglevel", "PAPAON!!你的等级还不够唷!"}, + { "msg_stone", "PAPAON!!金钱不足唷!"}, + { "msg_event", "PAON!!你无法加入唷!"}, + { "msg_start", "哇喔~(出发进行)"}, + { "msg_end", "哇喔~(到罗)"} + +}; + +static int NPC_BusSetPoint( int meindex, char *argstr); +static void NPC_BusSetDestPoint( int meindex, char *argstr); +static BOOL NPC_BusCheckDeniedItem( int meindex, int charaindex, char *argstr); +static BOOL NPC_BusCheckLevel( int meindex, int charaindex, char *argstr); +static int NPC_BusCheckStone( int meindex, int charaindex, char *argstr); +static void NPC_BusSendMsg( int meindex, int talkerindex, int tablenum); +static int NPC_BusGetRoutePointNum( int meindex, char *argstr ); +static void NPC_Bus_walk( int meindex); + +#define NPC_BUS_LOOPTIME 200 + +/* 谨切凛棉犯白巧伙玄 */ +#define NPC_BUS_WAITTIME_DEFAULT 180 + +#define NPC_BUS_WAITINGMODE_WAITTIME 5000 + +/********************************* +* 赓渝质 +*********************************/ +BOOL NPC_BusInit( int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + int i; + char buf[256]; + int routenum; + int waittime; + int seflg; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + /* 卅仃木壬中仃卅中娄醒及民尼永弁 */ + routenum = NPC_Util_GetNumFromStrWithDelim( argstr, "routenum");//行驶路线数量 + + if( routenum == -1 ) { + print( "npcbus:nothing routenum \n"); + return FALSE; + } + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEMAX, routenum); + + for( i = 1; i <= routenum; i ++ ) { + char routetostring[64]; + snprintf( routetostring, sizeof( routetostring), "routeto%d", i); + if( NPC_Util_GetStrFromStrWithDelim( argstr, routetostring,buf, sizeof(buf)) + == NULL ) + { + print( "npcbus:nothing route to \n"); + return FALSE; + } + + } + waittime = NPC_Util_GetNumFromStrWithDelim( argstr, "waittime"); + + if( waittime == -1 ) waittime = NPC_BUS_WAITTIME_DEFAULT; + CHAR_setWorkInt( meindex, NPC_WORK_WAITTIME, waittime); + + seflg = NPC_Util_GetNumFromStrWithDelim( argstr, "seflg"); + + if( seflg == -1 ) seflg = TRUE; + CHAR_setWorkInt( meindex, NPC_WORK_SEFLG, seflg); + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEBUS ); + + CHAR_setWorkInt( meindex, NPC_WORK_MODE, 0); + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, 2); + CHAR_setWorkInt( meindex, NPC_WORK_ROUNDTRIP, 0); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTROUTE, 0); + + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, + NPC_BUS_WAITINGMODE_WAITTIME); + + /* 蜇箕及凛棉毛本永玄 */ + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + + for( i = 0; i < CHAR_PARTYMAX; i ++) { + CHAR_setWorkInt( meindex, CHAR_WORKPARTYINDEX1 + i, -1); + } + + /* 伙□玄瑁烂允月 */ +{ + int rev; + int r = CHAR_getWorkInt( meindex, NPC_WORK_ROUTEMAX); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTROUTE, RAND( 1, r)); + //print( "route:%d\n",CHAR_getWorkInt( meindex, NPC_WORK_CURRENTROUTE)); + + /* 欠旦正□玄 */ + rev = NPC_Util_GetNumFromStrWithDelim( argstr, "reverse"); + + if( rev == 1 ) { + int num = NPC_BusGetRoutePointNum( meindex, argstr); + + if( num <= 0 ) { + print( "npcbus:真奇怪!\n"); + return FALSE; + } + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, num-1); + CHAR_setWorkInt( meindex, NPC_WORK_ROUNDTRIP, 1); + } + /* 伙□玄毛本永玄允月 */ + NPC_BusSetPoint( meindex, argstr); + /* 垫五燮毛 憎允月 */ + NPC_BusSetDestPoint( meindex, argstr); +} + + return TRUE; +} + + +/********************************* +* 仄井仃日木凶凛及质 +*********************************/ +void NPC_BusTalked( int meindex , int talkerindex , char *szMes , + int color ) +{ + int i; + int partyflg = FALSE; + + /* 皿伊奶乩□卞覆仄化分仃 杀允月 */ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + /* 愤坌及由□ 奴 昙菸 井升丹井譬屯月 */ + for( i = 0; i < CHAR_PARTYMAX; i ++ ) { + int index = CHAR_getWorkInt( meindex, CHAR_WORKPARTYINDEX1+i); + if( CHAR_CHECKINDEX(index)){ + if( index == talkerindex) { + partyflg = TRUE; + } + } + } + if( !partyflg ) { + //NPC_BusCheckJoinParty( meindex, talkerindex, TRUE); + } + else { + if( CHAR_getWorkInt( meindex, NPC_WORK_MODE) == 0 ) { + int i; + // #define NPC_BUS_DEBUGROUTINTG "routingtable:" + if( strstr( szMes, "出发" ) || + strstr( szMes, "出发" ) || + strstr( szMes, "Go" ) || + strstr( szMes, "go" )) + { + CHAR_setWorkInt( meindex, NPC_WORK_MODE,1); + + /* 伙□皿楮醒及裟请仄毛汹仁簧蘸卞允月 */ + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, NPC_BUS_LOOPTIME); + /* SE 日允 穴件乒旦及陲太 */ + if( CHAR_getWorkInt( meindex, NPC_WORK_SEFLG )) { + CHAR_sendSEoArroundCharacter( + CHAR_getInt( meindex, CHAR_FLOOR), + CHAR_getInt( meindex, CHAR_X), + CHAR_getInt( meindex, CHAR_Y), + 60, + TRUE); + } + /* 请 允月凛及丢永本□斥*/ + for( i = 1; i < CHAR_PARTYMAX; i ++ ) { + int partyindex = CHAR_getWorkInt( meindex, CHAR_WORKPARTYINDEX1+i); + if( CHAR_CHECKINDEX( partyindex)) { + NPC_BusSendMsg( meindex, partyindex, NPC_BUS_MSG_START); + } + } + } + } +#if 0 + else if( strstr( szMes, "停止" ) || + strstr( szMes, "停止" ) || + strstr( szMes, "stop" ) || + strstr( szMes, "Stop" )) + { + CHAR_setWorkInt( meindex, NPC_WORK_MODE,2); + + /* 伙□皿楮醒及奶件正□田伙毛聂仁允月 */ + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, + NPC_BUS_WAITINGMODE_WAITTIME); + /* 蜇箕及凛棉毛本永玄 */ + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + } + else if( strstr( szMes, NPC_BUS_DEBUGROUTINTG )) { + /* 犯田永弘迕 */ + char *p = strstr( szMes,NPC_BUS_DEBUGROUTINTG); + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + if( p) { + int a = atoi( p+strlen(NPC_BUS_DEBUGROUTINTG)); + if( a <0 ) a = 1; + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTROUTE, a); + } + //print( "route:%d\n",CHAR_getWorkInt( meindex, NPC_WORK_CURRENTROUTE)); + /* 伙□玄毛本永玄允月 */ + NPC_BusSetPoint( meindex, argstr); + } +#endif + } +} +/************************************** + * 伙□皿楮醒 + **************************************/ +void NPC_BusLoop( int meindex) +{ + int i; + switch( CHAR_getWorkInt( meindex, NPC_WORK_MODE )) { + case 0: + /* 谨切乒□玉及凛]凛棉毛民尼永弁允月 */ + /* 凛棉互烦匀凶及匹]请 允月 */ + if( CHAR_getWorkInt( meindex, NPC_WORK_CURRENTTIME) + + CHAR_getWorkInt( meindex, NPC_WORK_WAITTIME) + < NowTime.tv_sec) + { + /* SE 日允 穴件乒旦及陲太 */ + if( CHAR_getWorkInt( meindex, NPC_WORK_SEFLG )) { + CHAR_sendSEoArroundCharacter( + CHAR_getInt( meindex, CHAR_FLOOR), + CHAR_getInt( meindex, CHAR_X), + CHAR_getInt( meindex, CHAR_Y), + 60, + TRUE); + } + /* 请 允月凛及丢永本□斥*/ + for( i = 1; i < CHAR_PARTYMAX; i ++ ) { + int partyindex = CHAR_getWorkInt( meindex, CHAR_WORKPARTYINDEX1+i); + if( CHAR_CHECKINDEX( partyindex)) { + NPC_BusSendMsg( meindex, partyindex, NPC_BUS_MSG_START); + } + } + + CHAR_setWorkInt( meindex, NPC_WORK_MODE,1); + /* 伙□皿楮醒及裟请仄毛汹仁簧蘸卞允月 */ + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, NPC_BUS_LOOPTIME); + } + return; + case 1: + /* 汹仁 */ + NPC_Bus_walk( meindex); + case 2: + /* 鞅引匀化中月乒□玉 */ + /* 凛棉互烦匀凶及匹]请 允月 */ + if( CHAR_getWorkInt( meindex, NPC_WORK_CURRENTTIME) + + (CHAR_getWorkInt( meindex, NPC_WORK_WAITTIME) /3) + < NowTime.tv_sec) + { + CHAR_setWorkInt( meindex, NPC_WORK_MODE,1); + /* 伙□皿楮醒及裟请仄毛汹仁簧蘸卞允月 */ + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, NPC_BUS_LOOPTIME); + + } + return; + case 3: + /* 谗邋仄化手]弁仿奶失件玄及 樟谨切及啃卞] + * 剂仄仇仇匹它尼奶玄毛中木化支月 + */ + if( CHAR_getWorkInt( meindex, NPC_WORK_CURRENTTIME) + 3 + < NowTime.tv_sec) + { + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + /* 伙□皿楮醒及裟请仄毛赞仁允月 */ + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, + NPC_BUS_WAITINGMODE_WAITTIME); + + /* 伙□玄瑁烂允月 */ + { + int r = CHAR_getWorkInt( meindex, NPC_WORK_ROUTEMAX); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTROUTE, RAND( 1, r)); + //print( "route:%d\n",CHAR_getWorkInt( meindex, NPC_WORK_CURRENTROUTE)); + } + /* 垫五窖曰白仿弘 凳 */ + CHAR_setWorkInt( meindex, NPC_WORK_ROUNDTRIP, + CHAR_getWorkInt( meindex, NPC_WORK_ROUNDTRIP)^1); + + /* 戚禾奶件玄及譬濡 */ + /* 窖曰反 溃质 */ + if( CHAR_getWorkInt( meindex, NPC_WORK_ROUNDTRIP) == 1) { + /* 公及伙□玄及 嫖禾奶件玄醒毛 月 */ + int num = NPC_BusGetRoutePointNum( meindex, argstr); + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, num-1); + } + else { + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, + CHAR_getWorkInt( meindex, NPC_WORK_ROUTEPOINT) +1); + } + /* 戚及禾奶件玄及甄 毛本永玄允月 */ + NPC_BusSetPoint( meindex, argstr); + /* 垫五燮毛 憎允月 */ + NPC_BusSetDestPoint( meindex, argstr); + /* 由□ 奴 仃月质 毛允月 */ + CHAR_DischargeParty( meindex, 0); + /* 蜇箕及凛棉毛本永玄 */ + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + /* 乒□玉弁伉失 */ + CHAR_setWorkInt( meindex, NPC_WORK_MODE, 0); + } + return; + default: + break; + } +} +/************************************** + * 汹仁[ + **************************************/ +static void NPC_Bus_walk( int meindex) +{ + POINT start, end; + int dir; + int ret; + int i; + + /* 汹仁楮溢 */ + /* 谗邋仄凶凛及质 */ + start.x = CHAR_getInt( meindex, CHAR_X); + start.y = CHAR_getInt( meindex, CHAR_Y); + end.x = CHAR_getWorkInt( meindex, NPC_WORK_ROUTETOX); + end.y = CHAR_getWorkInt( meindex, NPC_WORK_ROUTETOY); + + /* 谗邋仄凶及匹戚及禾奶件玄卞 */ + if( start.x == end.x && start.y == end.y ) { + int add = 1; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + if( CHAR_getWorkInt( meindex, NPC_WORK_ROUNDTRIP ) == 1 ) { + add *= -1; + } + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, + CHAR_getWorkInt( meindex, NPC_WORK_ROUTEPOINT) +add); + if( NPC_BusSetPoint( meindex, argstr) == FALSE ) { + /* 卞谗邋*/ + /* 谨切乒□玉卞允月 */ + CHAR_setWorkInt( meindex, NPC_WORK_MODE,3); + + /* SE 日允 穴件乒旦及陲太 */ + if( CHAR_getWorkInt( meindex, NPC_WORK_SEFLG )) { + CHAR_sendSEoArroundCharacter( + CHAR_getInt( meindex, CHAR_FLOOR), + CHAR_getInt( meindex, CHAR_X), + CHAR_getInt( meindex, CHAR_Y), + 60, + TRUE); + } + /* 邋中凶凛及丢永本□斥*/ + for( i = 1; i < CHAR_PARTYMAX; i ++ ) { + int partyindex = CHAR_getWorkInt( meindex, CHAR_WORKPARTYINDEX1+i); + if( CHAR_CHECKINDEX( partyindex)) { + NPC_BusSendMsg( meindex, partyindex, NPC_BUS_MSG_END); + } + } + /* 蜇箕及凛棉毛本永玄 */ + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + return; + } + else { + return; + } + } + /*-------------------------------------------------------*/ + /* 汹井六月质 */ + + /* 轾毛菲户月 */ + dir = NPC_Util_getDirFromTwoPoint( &start,&end ); + + /* 漆中月桦赭及谨 由□ 奴汹五匹银丹 */ + end.x = CHAR_getInt( meindex, CHAR_X); + end.y = CHAR_getInt( meindex, CHAR_Y); + + /* 夫匀井井匀凶凛及啃及质 */ + for( i = 0; i < 100; i ++ ) { + if( dir < 0 ) { + dir = RAND( 0,7); + } + dir = NPC_Util_SuberiWalk( meindex, dir); + if( dir >= 0 && dir <= 7) break; + } + + if( dir >= 0 && dir <= 7 ) { + /* 汹仁 */ + ret = CHAR_walk( meindex, dir, 0); + + if( ret == CHAR_WALKSUCCESSED ) { + /* 愤坌互褪卅日醮棉毛汹井六月 */ + int i; + for( i = 1; i < CHAR_PARTYMAX; i ++ ) { + int toindex = CHAR_getWorkInt( meindex, i + CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX(toindex) ) { + int parent_dir; + /* 阂及匏 午]褪及汹五蟆及匏 井日 轾毛菲户月 */ + /* 汹仁 */ + start.x = CHAR_getInt( toindex, CHAR_X); + start.y = CHAR_getInt( toindex, CHAR_Y); + parent_dir = NPC_Util_getDirFromTwoPoint( &start,&end ); + /* 弘仿犯奴它旦左皿扑亦件汹五毛 蜇允月啃卞] + * 戚及阂反蟆及阂及 毛馨丹方丹卞允月 + */ + end = start; + if( parent_dir != -1 ) { + CHAR_walk( toindex, parent_dir, 0); + } + } + } + } + } +} +/************************************** + * 戚及桦赭毛本永玄允月 + **************************************/ +static int NPC_BusSetPoint( int meindex, char *argstr) +{ + char buf[4096]; + char buf2[256]; + char buf3[256]; + int ret; + char routetostring[64]; + + snprintf( routetostring, sizeof( routetostring), "routeto%d", + CHAR_getWorkInt( meindex, NPC_WORK_CURRENTROUTE)); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, routetostring,buf, sizeof(buf)) + == NULL ) + { + print( "npcbus:nothing route \n"); + return FALSE; + } + ret = getStringFromIndexWithDelim( buf, ";", + CHAR_getWorkInt( meindex, NPC_WORK_ROUTEPOINT), + buf2, sizeof(buf2)); + + if( ret == FALSE ) return FALSE; + + ret = getStringFromIndexWithDelim( buf2, ",", 1, + buf3, sizeof(buf3)); + if( ret == FALSE) return FALSE; + CHAR_setWorkInt( meindex, NPC_WORK_ROUTETOX, atoi( buf3)); + + ret = getStringFromIndexWithDelim( buf2, ",", 2, + buf3, sizeof(buf3)); + if( ret == FALSE) return FALSE; + CHAR_setWorkInt( meindex, NPC_WORK_ROUTETOY, atoi( buf3)); + return TRUE; +} +/************************************** + * route 寞井日] 蟆互丐匀凶日公木毛 + * 惫寞及午仇卞本永玄允月[ + **************************************/ +static void NPC_BusSetDestPoint( int meindex, char *argstr) +{ + char buf[256]; + char routename[256]; + + snprintf( routename, sizeof( routename), "routename%d", + CHAR_getWorkInt( meindex, NPC_WORK_CURRENTROUTE)); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, routename, buf, sizeof( buf)) + != NULL ) + { + CHAR_setChar( meindex, CHAR_OWNTITLE, buf); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX)); + } +} +/************************************** + * 隙烂今木凶失奶 丞毛 匀化中月井民尼永弁允月 + * 匀化中凶日分户 + **************************************/ +static BOOL NPC_BusCheckDeniedItem( int meindex, int charaindex, char *argstr) +{ + char buf[1024]; + BOOL found = TRUE; + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "denieditem", buf, sizeof( buf)) + != NULL ) + { + int i; + int ret; + for( i = 1; ; i ++) { + int itemid; + char buf2[64]; + int j; + ret = getStringFromIndexWithDelim( buf, ",", i, buf2, sizeof(buf2)); + if( ret == FALSE ) break; + itemid = atoi( buf2); + for( j = 0; j < CHAR_MAXITEMHAVE; j ++) { + int itemindex = CHAR_getItemIndex( charaindex, j); + if( ITEM_CHECKINDEX( itemindex)) { + if( ITEM_getInt( itemindex, ITEM_ID) == itemid) { + found = FALSE; + break; + } + } + } + } + } + return found; +} +/************************************** + * 隙烂今木凶失奶 丞毛 匀化中月井民尼永弁允月 + * 匀化中卅中午分户 + **************************************/ +BOOL NPC_BusCheckAllowItem( int meindex, int charaindex, BOOL pickupmode) +{ + char buf[1024]; + BOOL found = TRUE; + BOOL pickup = FALSE; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "pickupitem", buf, sizeof( buf))!= NULL ){ + pickup = TRUE; + } + if( NPC_Util_GetStrFromStrWithDelim( argstr, "allowitem", buf, sizeof( buf))!= NULL ){ + int i; + int ret; + for( i = 1; ; i ++) { + int itemid; + char buf2[64]; + int j; + BOOL getflg; + ret = getStringFromIndexWithDelim( buf, ",", i, buf2, sizeof(buf2)); + if( ret == FALSE ) break; + itemid = atoi( buf2); + getflg = FALSE; + for( j = 0; j < CHAR_MAXITEMHAVE; j ++) { + int itemindex = CHAR_getItemIndex( charaindex, j); + if( ITEM_CHECKINDEX( itemindex)) { + if( ITEM_getInt( itemindex, ITEM_ID) == itemid) { + if( pickupmode && pickup && !getflg) { + CHAR_DelItem( charaindex, j); + getflg = TRUE; + } + break; + } + } + } + if( j == CHAR_MAXITEMHAVE) { + found = FALSE; + break; + } + } + } + return found; +} + +/************************************** + * 隙烂今木凶伊矛伙动晓井民尼永弁允月 + **************************************/ +static BOOL NPC_BusCheckLevel( int meindex, int charaindex, char *argstr) +{ + int level; + + /* 卅仃木壬中仃卅中娄醒及民尼永弁 */ + level = NPC_Util_GetNumFromStrWithDelim( argstr, "needlevel"); + if( level == -1 ) { + return TRUE; + } + if( CHAR_getInt( charaindex, CHAR_LV) >= level ) return TRUE; + + return FALSE; +} +/************************************** + * 豢嗯毛民尼永弁允月 + * -1 蛲 0动晓” ]井勾 邰Stone + **************************************/ +static int NPC_BusCheckStone( int meindex, int charaindex, char *argstr) +{ + int gold; + + /* 卅仃木壬中仃卅中娄醒及民尼永弁 */ + gold = NPC_Util_GetNumFromStrWithDelim( argstr, "needstone"); + if( gold == -1 ) { + return 0; + } + if( CHAR_getInt( charaindex, CHAR_GOLD) >= gold ) return gold; + + return -1; +} +/************************************** + * 丢永本□斥毛霜月 + * 娄醒及丢永本□斥互卅仃木壬犯白巧伙玄丢永本□斥毛霜月 + **************************************/ +static void NPC_BusSendMsg( int meindex, int talkerindex, int tablenum) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[256]; + char msg[256]; + if( tablenum < 0 || tablenum >= arraysizeof( busmsg)) return; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, busmsg[tablenum].option, buf, sizeof( buf)) + != NULL ) + { + strcpy( msg, buf); + } + else { + snprintf( msg, sizeof(msg),busmsg[tablenum].defaultmsg); + } + CHAR_talkToCli( talkerindex, meindex, msg, CHAR_COLORYELLOW); +} +/************************************** + * 伙□玄 □皮伙及禾奶件玄及醒毛潸 允月 + **************************************/ +static int NPC_BusGetRoutePointNum( int meindex, char *argstr ) +{ + int i; + char buf[4096]; + char buf2[256]; + int ret; + char routetostring[64]; + + snprintf( routetostring, sizeof( routetostring), "routeto%d", + CHAR_getWorkInt( meindex, NPC_WORK_CURRENTROUTE)); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, routetostring,buf, sizeof(buf)) + == NULL ) + { + print( "npcbus:nothing route \n"); + return -1; + } + for( i = 1; ; i ++ ) { + ret = getStringFromIndexWithDelim( buf, ";", i, buf2, sizeof(buf2)); + if( ret == FALSE) break; + } + return( i -1); +} +BOOL NPC_BusCheckJoinParty( int meindex, int charaindex, BOOL msgflg) +{ + //int fd; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + int ret; + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + /* ㄠ弘伉永玉动 及心 */ + if( !NPC_Util_charIsInFrontOfChar( charaindex, meindex, 1 )) return FALSE; + /* 昙乐反蛐 允月 */ + if( CHAR_getWorkInt( meindex, NPC_WORK_MODE) != 0 ) { + if( msgflg) NPC_BusSendMsg( meindex, charaindex, NPC_BUS_MSG_GETTINGON); + return FALSE; + } + /* 天□化不分匀凶日分户 */ + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE ) != CHAR_PARTY_NONE) { + if( msgflg) NPC_BusSendMsg( meindex, charaindex, NPC_BUS_MSG_NOTPARTY); + return FALSE; + } + /* 由□ 奴及谛醒毛民尼永弁允月 */ + if( CHAR_getEmptyPartyArray( meindex) == -1 ) { + if( msgflg) NPC_BusSendMsg( meindex, charaindex, NPC_BUS_MSG_OVERPARTY); + return FALSE; + } + /* 失奶 丞及民尼永弁毛允月(嗟鞅失奶 丞) */ + if( !NPC_BusCheckDeniedItem( meindex, charaindex, argstr)) { + if( msgflg) NPC_BusSendMsg( meindex, charaindex, NPC_BUS_MSG_DENIEDITEM); + return FALSE; + } +#ifdef _ITEM_CHECKWARES + if( CHAR_CheckInItemForWares( charaindex, 0) == FALSE ) { + CHAR_talkToCli( charaindex, -1, "无法携带货物上车。", CHAR_COLORYELLOW); + return FALSE; + } +#endif + /* 失奶 丞及民尼永弁毛允月( 邰失奶 丞) */ + if( !NPC_BusCheckAllowItem( meindex, charaindex, FALSE)) { + if( msgflg) NPC_BusSendMsg( meindex, charaindex, NPC_BUS_MSG_ALLOWITEM); + return FALSE; + } + /* 伊矛伙及民尼永弁毛允月 */ + if( !NPC_BusCheckLevel( meindex, charaindex, argstr)) { + if( msgflg) NPC_BusSendMsg( meindex, charaindex, NPC_BUS_MSG_LEVEL); + return FALSE; + } + /* 奶矛件玄 井民尼永弁允月 */ +// if( CHAR_getInt( charaindex, CHAR_NOWEVENT) != 0 || +// CHAR_getInt( charaindex, CHAR_NOWEVENT2) != 0 || +// CHAR_getInt( charaindex, CHAR_NOWEVENT3) != 0 ) +// { +// if( msgflg) NPC_BusSendMsg( meindex, charaindex, NPC_BUS_MSG_EVENT); +// return FALSE; +// } + /* 豢嗯及民尼永弁毛允月 云嗯毛潸月及匹] 蔽民尼永弁卞允月仇午″ */ + ret = NPC_BusCheckStone( meindex, charaindex, argstr); + if( ret == -1 ) { + if( msgflg) NPC_BusSendMsg( meindex, charaindex, NPC_BUS_MSG_GOLD); + return FALSE; + } + if( ret != 0 ) { + char msgbuf[128]; + /* 豢嗯毛午月 */ + CHAR_setInt( charaindex, CHAR_GOLD, + CHAR_getInt( charaindex, CHAR_GOLD) - ret); + /* 霜耨 */ + CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_GOLD); + snprintf( msgbuf, sizeof( msgbuf), "支付了%d Stone!", ret); + CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORYELLOW); + } + /* 由□ 奴卞 月 */ + //CHAR_JoinParty_Main( charaindex, meindex); + + //fd = getfdFromCharaIndex( charaindex ); + + //lssproto_PR_send( fd, 1, 1); + + + return TRUE; +} diff --git a/gmsv/npc/npc_charm.c b/gmsv/npc/npc_charm.c new file mode 100644 index 0000000..f6ddd82 --- /dev/null +++ b/gmsv/npc/npc_charm.c @@ -0,0 +1,285 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "npc_charm.h" + +// 医毛 仁煌遥挚反 + +//伊矛伙← ← 蜇箕及 / + +//荚汊汹反{ㄤ匹允[ +/* +#define RATE 4 //伊□玄" +#define CHARMHEAL 5 // 及荚汊汹 +#define WARU 3 // 毛喃月袄 + +*/ + +#define RATE 10 //伊□玄" +#define CHARMHEAL 5 // 及荚汊汹 +#define WARU 3 // 毛喃月袄 + + +static void NPC_Charm_selectWindow( int meindex, int toindex, int num); +int NPC_CharmCost(int meindex,int talker); +void NPC_CharmUp(int meindex,int talker); + + +/********************************* +* 赓渝质 +*********************************/ +BOOL NPC_CharmInit( int meindex ) +{ + /*--平乓仿及正奶皿毛涩烂--*/ + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPECHARM ); + return TRUE; + +} + + +/********************************* +* 仄井仃日木凶凛及质 +*********************************/ +void NPC_CharmTalked( int meindex , int talkerindex , char *szMes ,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; + } + + NPC_Charm_selectWindow( meindex, talkerindex, 0); +} + + +/* + * 备质 卞坌仃月 + */ +static void NPC_Charm_selectWindow( int meindex, int toindex, int num) +{ + + char token[1024]; + char escapedname[1024]; + int fd = getfdFromCharaIndex( toindex); + int buttontype = 0; + int windowtype = 0; + int windowno = 0; + int cost = 0; + int chartype; + + /*--它奶件玉它正奶皿丢永本□斥互云云中及匹燮卞涩烂--*/ + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + + switch( num) { + case 0: + /*--蓟 --*/ + sprintf(token,"4\n     = = 美容师 = = " + "\n\n  欢迎光临,今天要做什麽呢?" + "\n " + "\n\n    《 给我魅力 》 " + "\n\n    《 什麽也不做 》 " + ); + + buttontype = WINDOW_BUTTONTYPE_NONE; + windowtype = WINDOW_MESSAGETYPE_SELECT; + windowno = CHAR_WINDOWTYPE_CHARM_START; + break; + + case 1: + cost = NPC_CharmCost( meindex, toindex); + if(cost == -1){ + sprintf(token,"     = = 美容师 = = " + "\n\n    你的魅力真是完美" + "\n\n   请永远保持你的魅力唷。" + ); + buttontype = WINDOW_BUTTONTYPE_OK; + }else{ + sprintf(token,"     = = 美容师 = = " + "\n 佮齵在,千禧特惠价实施中�" + "\n\n 要将你的魅力上升五点的话" + "\n    需要%6d的stone唷!" + "\n\n   即使这样也可以吗?",cost + ); + buttontype = WINDOW_BUTTONTYPE_YESNO; + + } + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_CHARM_END; + + break; + + case 2: + cost = NPC_CharmCost( meindex, toindex); + chartype = CHAR_getInt( toindex, CHAR_IMAGETYPE); + + if(cost > CHAR_getInt( toindex, CHAR_GOLD)) { + sprintf(token,"     = = 美容师 = = " + "\n\n   哎呀!你的钱不够唷!" + "\n   先去存好钱下次再来吧!" + ); + + }else{ + NPC_CharmUp( meindex, toindex); + + /*--平乓仿及正奶皿卞方匀化丢永本□斥毛 尹化心凶--*/ + switch( chartype) { + case CHAR_IMAGETYPE_GIRL: + sprintf(token,"     = = 美容师 = = " + "\n\n  嗯,这样你的魅力就上升罗!" + "\n\n   愈来愈可爱了呢!" + ); + + break; + case CHAR_IMAGETYPE_BOY: + sprintf(token,"     = = 美容师 = = " + "\n\n  嗯,这样你的魅力就上升罗!" + "\n\n  是不是比刚才要帅多了呢?" + ); + break; + + case CHAR_IMAGETYPE_CHILDBOY: + case CHAR_IMAGETYPE_CHILDGIRL: + sprintf(token,"     = = 美容师 = = " + "\n\n  嗯,这样你的魅力就上升罗!" + "\n\n   真的变得好可爱唷!" + ); + break; + + case CHAR_IMAGETYPE_MAN: + sprintf(token,"     = = 美容师 = = " + "\n\n  嗯,这样你的魅力就上升罗!" + "\n\n    变得更酷了呢!" + ); + break; + + case CHAR_IMAGETYPE_WOMAN: + sprintf(token,"     = = 美容师 = = " + "\n\n  嗯,这样你的魅力就上升罗!" + "\n\n 可真是变得愈来愈美了呢!" + ); + break; + + } + } + + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_CHARM_END; + break; + } + + makeEscapeString( token, escapedname, sizeof( escapedname)); + /*-仇仇匹霜耨允月--*/ + lssproto_WN_send( fd, windowtype, + buttontype, + windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + escapedname); + +} + + +/*----------------------------------------- +弁仿奶失件玄井日忒匀化五凶凛卞裟太请今木月[ +-------------------------------------------*/ +void NPC_CharmWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 2) return; + + switch( seqno){ + case CHAR_WINDOWTYPE_CHARM_START: + if(atoi( data) == 2) { + NPC_Charm_selectWindow( meindex, talkerindex, 1 ); + } + break; + + case CHAR_WINDOWTYPE_CHARM_END: + if(select == WINDOW_BUTTONTYPE_YES) { + NPC_Charm_selectWindow( meindex, talkerindex, 2 ); + } + break; + } + +} + + + +/*-- --*/ +void NPC_CharmUp(int meindex,int talker) +{ + int cost; + int i; + int petindex; + char petsend[64]; + + /*--云嗯毛蛹日仄引仄斤丹--*/ + cost = NPC_CharmCost( meindex, talker); + CHAR_setInt( talker, CHAR_GOLD, + CHAR_getInt( talker, CHAR_GOLD) - cost); + CHAR_send_P_StatusString( talker, CHAR_P_STRING_GOLD); + + /*-- 互ㄠㄟㄟ动晓卞卅月桦宁反雄娄卞ㄠㄟㄟ卞允月--*/ + if(CHAR_getInt( talker, CHAR_CHARM) + CHARMHEAL >= 100) { + CHAR_setInt( talker, CHAR_CHARM, 100); + }else{ + /*-- 毛本永玄--*/ + CHAR_setInt(talker, CHAR_CHARM, + (CHAR_getInt( talker, CHAR_CHARM) + CHARMHEAL)); + } + + /*--旦 □正旦及凳蕙--*/ + CHAR_complianceParameter( talker ); + CHAR_send_P_StatusString( talker, CHAR_P_STRING_CHARM); + + + /*--矢永玄及由仿丢□正毛凳蕙--*/ + for( i = 0 ; i < CHAR_MAXPETHAVE ; i++){ + petindex = CHAR_getCharPet( talker, i); + + if( petindex == -1 ) continue; + + /* 平乓仿及 民尼永弁 */ + if( !CHAR_CHECKINDEX( talker ) ) continue; + + /*--由仿丢□正譬帮--*/ + CHAR_complianceParameter( petindex ); + sprintf( petsend, "K%d", i ); + CHAR_sendStatusString( talker , petsend ); + } +} + + +/*--云嗯及煌遥--*/ +int NPC_CharmCost(int meindex,int talker) +{ + int cost; + int level; + int charm; + int trans; + + level = CHAR_getInt( talker, CHAR_LV); + charm = CHAR_getInt( talker, CHAR_CHARM); + trans = CHAR_getInt( talker, CHAR_TRANSMIGRATION); + + if(charm >= 100) return -1; + + if(charm <= 1) charm = WARU; + + /*-- 煌遥挚 --*/ + cost = level * RATE * (charm / WARU) * (trans+1); + + return cost; + +} diff --git a/gmsv/npc/npc_checkman.c b/gmsv/npc/npc_checkman.c new file mode 100644 index 0000000..5a7bccd --- /dev/null +++ b/gmsv/npc/npc_checkman.c @@ -0,0 +1,472 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" + + +//蜇箕及银迕匹五月白仿弘及醒 +#define MAXEVENTFLG 96 + +/* + * 奶矛件玄及白仿弘毛民尼永弁允月 + * + */ + +static void NPC_CheckMan_selectWindow( int meindex, int toindex, int num); +int NPC_NowFlgCheck(int meindex,int talker,int now[MAXEVENTFLG]); +int NPC_EndFlgCheck(int meindex,int talker ,int nowflg[MAXEVENTFLG]); +BOOL NPC_FlgCheckMain( int meindex,int talker,int nowindex,int now[MAXEVENTFLG],char *work2); + +/********************************* +* 赓渝质 +*********************************/ +BOOL NPC_CheckManInit( int meindex ) +{ + /*--平乓仿及正奶皿毛涩烂--*/ + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPECHECKMAN); + + return TRUE; +} + + +/********************************* +* 仄井仃日木凶凛及质 +*********************************/ +void NPC_CheckManTalked( int meindex , int talkerindex , char *szMes ,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; + } + + // 赓及它奶件玉它卞 + NPC_CheckMan_selectWindow( meindex, talkerindex, 0); + +} + + +/* + * 备质 卞坌仃月 + */ +static void NPC_CheckMan_selectWindow( int meindex, int talker, int num) +{ + + char token[1024]; + char work[256]; + char work2[512]; + + char escapedname[1024]; + int fd = getfdFromCharaIndex( talker); + int buttontype = 0; + int windowtype = 0; + int windowno = 0; + int now[MAXEVENTFLG]; + int nowindex; + int i; + int page; + + work[0] = 0; + work2[0] = 0; + token[0] = 0; + + now[0] =0; + + /*--它奶件玉它正奶皿丢永本□斥互云云中及匹燮卞涩烂--*/ + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + + switch( num) { + + case 0: + CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANT,0); + CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC,0); + + /*--蓟 --*/ + sprintf(token,"3\n {{{{>>{民尼永弁穴件{>> " + "\n{{{蜇箕及白仿弘民尼永弁毛仄引□允" + "\n" + "\n{{{{ U{NOW白仿弘民尼永弁{V " + "\n{{{{ U{END白仿弘民尼永弁{V " + "\n\n{{ U{NOW白仿弘民尼永弁 择称 V " + "\n{{ U{END白仿弘民尼永弁 择称 V " + ); + + buttontype = WINDOW_BUTTONTYPE_CANCEL; + windowtype = WINDOW_MESSAGETYPE_SELECT; + windowno = CHAR_WINDOWTYPE_CHECKMAN_START; + break; + + //NOW白仿弘及棵签 憎 + case 1: + + //NOW白仿弘及民尼永弁 + nowindex = NPC_NowFlgCheck( meindex, talker, now); + + //窒矢□斥 井 + page = CHAR_getWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC) ; + + if(page == 0 || page == 1){ + i = 0; + }else{ + i = 83; + } + + //矢□斥 + for(; i < nowindex ; i++) + { + sprintf(work,"%d,",now[ i]); + strcat(work2,work); + } + + sprintf(token,"{{{{{>>{民尼永弁穴件{>> " + "\n{{蜇箕及筑 及 匀化中月 NOW奶矛件玄" + "\n%s" + ,work2); + + if(page != 2 && nowindex > 83) + { + //乒□玉 + CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANT,1); + //矢□斥 + CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC,2); + + buttontype = WINDOW_BUTTONTYPE_NEXT; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_CHECKMAN_MAIN; + + }else{ + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + } + + break; + + + //END白仿弘及棵签 憎 + case 2: + //蔽 白仿弘及民尼永弁 + nowindex = NPC_EndFlgCheck( meindex, talker, now); + + //窒矢□斥 井 + page = CHAR_getWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC) ; + + if(page == 0 || page == 1){ + i = 0; + }else{ + i = 83; + } + work2[0]=0; + + //矢□斥 + for(; i < nowindex ; i++) + { + sprintf(work,"%d,",now[ i]); + strcat(work2,work); + } + sprintf(token,"{{{{{>>{民尼永弁穴件{>> " + "\n{{蜇箕及筑 及 匀化中月 END奶矛件玄" + "\n%s" + ,work2); + + if(page != 2 && nowindex > 83) + { + //乒□玉 + CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANT,2); + //矢□斥 + CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC,2); + + buttontype = WINDOW_BUTTONTYPE_NEXT; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_CHECKMAN_MAIN; + + }else{ + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + } + + break; + + + // NOW白仿弘及择称 憎 + case 4: + { + + //NOW白仿弘民尼永弁 + nowindex = NPC_NowFlgCheck( meindex, talker, now); + + if(NPC_FlgCheckMain( meindex, talker, nowindex,now,work2) + == FALSE) + { + return; + } + + + sprintf(token,"{{{{{>>{民尼永弁穴件{>> " + "\n{{蜇箕及筑 及 匀化中月 NOW奶矛件玄" + "\n%s" + ,work2); + + page = CHAR_getWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC) ; + nowindex = (nowindex / ((6*page)+1)); + + if(page != 16 && nowindex != 0) + { + //乒□玉 + CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANT,4); + //矢□斥 + page = CHAR_getWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC); + page++; + CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC,page); + + buttontype = WINDOW_BUTTONTYPE_NEXT; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_CHECKMAN_MAIN; + }else{ + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + } + + } + break; + + // END白仿弘及择称 憎 + case 5: + { + //END白仿弘及民尼永弁 + nowindex = NPC_EndFlgCheck( meindex, talker, now); + + + if(NPC_FlgCheckMain( meindex, talker, nowindex, now, work2) + == FALSE) + { + return; + } + + sprintf(token,"{{{{{>>{民尼永弁穴件{>> " + "\n{{蜇箕及筑 及 匀化中月 END奶矛件玄" + "\n%s" + ,work2); + + page = CHAR_getWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC) ; + + nowindex = (nowindex / ((6*page)+1)); + + if(page != 16 && nowindex != 0) + { + //乒□玉 + CHAR_setWorkInt(talker, CHAR_WORKSHOPRELEVANT, 5); + //矢□斥 + page = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANTSEC); + page++; + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTSEC, page); + + buttontype = WINDOW_BUTTONTYPE_NEXT; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_CHECKMAN_MAIN; + }else{ + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + } + + } + } + + makeEscapeString( token, escapedname, sizeof( escapedname)); + /*-仇仇匹霜耨允月--*/ + lssproto_WN_send( fd, windowtype, + buttontype, + windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + escapedname); + +} + + +/*----------------------------------------- +弁仿奶失件玄井日忒匀化五凶凛卞裟太请今木月[ +-------------------------------------------*/ +void NPC_CheckManWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + int datano; + + if( NPC_Util_CharDistance( talkerindex, meindex ) > 2) return; + + datano = atoi(data); + + if(select == WINDOW_BUTTONTYPE_OK) + { + NPC_CheckMan_selectWindow( meindex, talkerindex, 0 ); + }else if(select == WINDOW_BUTTONTYPE_CANCEL) { + return; + } + + + + + switch(CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANT)){ + case 1: + if(CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTSEC) == 2){ + NPC_CheckMan_selectWindow( meindex, talkerindex, 1 ); + } + break; + + case 2: + if(CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTSEC) == 2){ + NPC_CheckMan_selectWindow( meindex, talkerindex, 2 ); + } + break; + + case 4: + if(CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTSEC) >= 2){ + NPC_CheckMan_selectWindow( meindex, talkerindex, 4 ); + } + + case 5: + if(CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTSEC) >= 2){ + NPC_CheckMan_selectWindow( meindex, talkerindex, 5 ); + } + + break; + } + + switch( datano ){ + case 1: + NPC_CheckMan_selectWindow( meindex, talkerindex, 1 ); + break; + + case 2: + NPC_CheckMan_selectWindow( meindex, talkerindex, 2 ); + break; + + case 4: + NPC_CheckMan_selectWindow( meindex, talkerindex, 4 ); + break; + + case 5: + NPC_CheckMan_selectWindow( meindex, talkerindex, 5 ); + break; + } + +} + +/* + *{奶矛件玄 白仿弘毛民尼永弁允月 + */ +int NPC_NowFlgCheck(int meindex,int talker ,int nowflg[MAXEVENTFLG]) +{ + int i = 0; + int j = 0; + + for(i= 0; i < MAXEVENTFLG ; i++){ + if(NPC_NowEventCheckFlg( talker, i) == TRUE) + { + nowflg[j] = i; + j++; + } + } + + return j; +} + +/* + *{奶矛件玄蔽 白仿弘毛民尼永弁允月 + */ +int NPC_EndFlgCheck(int meindex,int talker ,int nowflg[MAXEVENTFLG]) +{ + int i = 0; + int j = 0; + + for(i= 0; i < MAXEVENTFLG ; i++){ + + if(NPC_EventCheckFlg( talker, i) == TRUE) + { + nowflg[j] = i; + j++; + } + } + + return j; +} + +/* + * 择称 + * + */ +BOOL NPC_FlgCheckMain( int meindex,int talker,int nowindex,int now[MAXEVENTFLG],char *work2) +{ + int page; + int max; + int i; + int shou; + int j=1; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char work[512]; + char buf[40]; + char buf2[42]; + + //窒矢□斥 井 + page = CHAR_getWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC) ; + + if(page == 0) { + page =1; + CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC,1) ; + } + + if(page == 1){ + i = 0; + if( nowindex >6 ){ + max =7; + }else{ + max =nowindex; + } + }else{ + max = (page * 6) +1; + i = max - 7; + shou = nowindex / max; + + if(shou == 0){ + max = nowindex; + }else{ + i = max - 7; + } + } + + //奶矛件玄及择称互踏井木化中月白央奶伙毛 心仇戈 + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("NPC_CheckMan:GetArgStrErr"); + return FALSE; + } + + work[0] = 0; + work2[0] = 0; + + //矢□斥 + for(; i < max ; i++) + { + sprintf(work,"#%d:",now[ i]); + j = 1; + while( getStringFromIndexWithDelim(argstr, "|", j, buf,sizeof( buf)) + !=FALSE ) + { + j++; + if(strstr(buf,work) != NULL){ + sprintf(buf2,"%s\n",buf); + strcat(work2,buf2); + break; + } + } + } + + return TRUE; +} diff --git a/gmsv/npc/npc_dengon.c b/gmsv/npc/npc_dengon.c new file mode 100644 index 0000000..0b2e220 --- /dev/null +++ b/gmsv/npc/npc_dengon.c @@ -0,0 +1,248 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "lssproto_serv.h" +#include "npcutil.h" +#include "handletime.h" + +static BOOL NPC_DengonReadString( int meindex, int id, char *str ); +static void NPC_DengonWriteString( int meindex, int talkerindex, int id, char *str ); + +#define DENGONFILEDIR "./Dengon/" +#define DENGONFILELINENUM 1000 +#define DENGONFILESTRINGSIZE 256 +#define DENGONFILECOUNTERSIZE 11 +#define DENGONFILEENTRYSIZE (DENGONFILECOUNTERSIZE+DENGONFILESTRINGSIZE+1) +#define MESSAGEINONEWINDOW 7 + +char NPC_sendbuf[DENGONFILEENTRYSIZE*MESSAGEINONEWINDOW]; + +BOOL NPC_DengonInit( int meindex ) +{ + char filename[256], tmp[256]; + FILE *f; + int i,j; + int id, maxid; + + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_TYPEDENGON ); + + snprintf( filename,sizeof(filename), "%s%d_%d_%d", + DENGONFILEDIR, CHAR_getInt( meindex, CHAR_FLOOR ), + CHAR_getInt( meindex, CHAR_X ), + CHAR_getInt( meindex, CHAR_Y ) ); + + if( ! (f=fopen( filename, "r" )) ){ + f = fopen( filename, "w" ); + if( f ){ + }else{ + print( "ERROR:Can't create Dengonfile %s!\n",filename ); + return FALSE; + } + for( j = 0; j < DENGONFILELINENUM; j++ ){ + fwrite( "0000000000:", sizeof(char), + DENGONFILECOUNTERSIZE, f); + for( i=0;i maxid ) { + maxid = id; + } + } + + CHAR_setWorkInt( meindex, CHAR_WORKDENGONMAXID, maxid ); + + fclose(f); + return TRUE; +} + + +void NPC_DengonWindowTalked( int index, int talker, + int seqno, int select, char *data) +{ + char buf[DENGONFILEENTRYSIZE*MESSAGEINONEWINDOW*2]; + + int id; + +#define DENGONDISTANCE 3 + + if(NPC_Util_CharDistance(index,talker) > DENGONDISTANCE ) return; + if( seqno == CHAR_WINDOWTYPE_DENGON) { + int buttontype = 0; + int maxid; + switch( select ){ + case WINDOW_BUTTONTYPE_NEXT: + case WINDOW_BUTTONTYPE_PREV: + id = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANT) + + MESSAGEINONEWINDOW + * (( select == WINDOW_BUTTONTYPE_NEXT) ? 1 : -1); + + maxid = CHAR_getWorkInt( index, CHAR_WORKDENGONMAXID ); + + if( id > maxid) id = maxid; + else if( id < 2 ) id = 1; + + buttontype = WINDOW_BUTTONTYPE_OKCANCEL; + if( id == maxid ) buttontype |= WINDOW_BUTTONTYPE_PREV; + else if( id == 1 ) buttontype |= WINDOW_BUTTONTYPE_NEXT; + else { + buttontype |= WINDOW_BUTTONTYPE_PREV; + buttontype |= WINDOW_BUTTONTYPE_NEXT; + } + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANT, id); + if( NPC_DengonReadString( index, id, NPC_sendbuf ) ){ + int fd; + fd = getfdFromCharaIndex( talker ); + if( fd == -1 )return; + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_WIDEMESSAGEANDLINEINPUT, + buttontype, + CHAR_WINDOWTYPE_DENGON, + CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), + makeEscapeString( NPC_sendbuf, buf, sizeof(buf))); + } + break; + case WINDOW_BUTTONTYPE_OK: + if( strlen( data) == 0 ) break; + id = CHAR_getWorkInt(index, CHAR_WORKDENGONMAXID ); + id++; + NPC_DengonWriteString( index, talker, id, data ); + CHAR_setWorkInt(index, CHAR_WORKDENGONMAXID, id ); + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANT, id); + if( NPC_DengonReadString( index, id, NPC_sendbuf ) ){ + int fd; + fd = getfdFromCharaIndex( talker ); + if( fd == -1 )return; + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_WIDEMESSAGEANDLINEINPUT, + WINDOW_BUTTONTYPE_OKCANCEL| + WINDOW_BUTTONTYPE_PREV, + CHAR_WINDOWTYPE_DENGON, + CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), + makeEscapeString( NPC_sendbuf, buf, sizeof(buf))); + } + break; + default: + break; + } + } +} + + + + +void NPC_DengonLooked( int meindex, int lookedindex ) +{ + int maxid; + char buf[DENGONFILEENTRYSIZE*MESSAGEINONEWINDOW*2]; + if( NPC_Util_CharDistance( lookedindex, meindex ) > 1) return; + maxid = CHAR_getWorkInt( meindex, CHAR_WORKDENGONMAXID ); + if( NPC_DengonReadString( meindex, maxid, NPC_sendbuf ) ){ + int fd; + fd = getfdFromCharaIndex( lookedindex ); + if( fd == -1 )return; + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_WIDEMESSAGEANDLINEINPUT, + WINDOW_BUTTONTYPE_OKCANCEL| + WINDOW_BUTTONTYPE_PREV, + CHAR_WINDOWTYPE_DENGON, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( NPC_sendbuf, buf, sizeof(buf))); + + CHAR_setWorkInt( lookedindex, CHAR_WORKSHOPRELEVANT, maxid); + + } + +} + +static BOOL NPC_DengonReadString( int meindex, int id, char *str ) +{ + char filename[256]; + char readbuf[DENGONFILEENTRYSIZE*MESSAGEINONEWINDOW]; + + FILE *f; + int maxid, i, sendid, len; + char *writeptr, *readptr; + + + maxid = CHAR_getWorkInt( meindex, CHAR_WORKDENGONMAXID ); + if( id > maxid ) id = maxid; + sendid = id - MESSAGEINONEWINDOW + 1; + + if( sendid < maxid - DENGONFILELINENUM + 1 ){ + sendid = maxid - DENGONFILELINENUM + 1; + } + + if( sendid < 1 ) sendid = 1; + + snprintf( filename,sizeof(filename), "%s%d_%d_%d", + DENGONFILEDIR, CHAR_getInt( meindex, CHAR_FLOOR ), + CHAR_getInt( meindex, CHAR_X ), + CHAR_getInt( meindex, CHAR_Y ) ); + + writeptr = str; + strcpy( writeptr, " 传言板\n"); + len = strlen(writeptr); + writeptr += len; + + f = fopen( filename, "r" ); + if( !f ) return FALSE; +{ + char buf[DENGONFILEENTRYSIZE]; + int wptr = 0; + readbuf[0] = '\0'; + for( i = 0; i < MESSAGEINONEWINDOW; i ++ ) { + fseek( f, ((sendid+i)%DENGONFILELINENUM)*DENGONFILEENTRYSIZE, SEEK_SET ); + fread( buf, sizeof(char), + DENGONFILEENTRYSIZE , f ); + memcpy( &readbuf[wptr], buf,sizeof( buf)); + wptr += DENGONFILEENTRYSIZE; + } +} + fclose(f); + readptr = readbuf + DENGONFILECOUNTERSIZE; + for( i=0;i +#include + + +static int NPC_Door_isOpen( int meindex ); + +/* + * 玉失毛 蜇允月凶户及NPC卞 邰卅楮醒及烂聒[ + * 正奶皿 “ Door + * + * NPCARGUMENT及袄反} + * + * og|cg|idname|swcount|closetime_sec|soonflg0/1|passflg0/1/2 + * + * passflg 反}1分匀凶日天允歹□升勾五匹丐月啦 卞卅月[2分匀凶日 + * 濮覆夫日井卅中[ 0分匀凶日由旦伐□玉匹卅中[ + * + * 毛隙烂允月[ 引月引匹及凛棉反犯白巧伙玄匹反1凛棉[ + * 涩烂毛踏仁午五卞反 飓 寞互褐邰卅躲绊毛手勾井日镗啦互 邰匹丐月[ + * + * 愤坌及引歹曰卞C毛霜耨允月楮醒互丐月井日}1垫info, 飓 寞 + * 毛 凳仄化井日公及楮醒毛方屯壬弁仿奶失件玄及 卞 憎今木化中月 + * 橇谪互 蕙卞卅月[ + */ + +#define NPC_DOOR_OPENMSG "玉失互}夫日中凶!" +#define NPC_DOOR_CLOSEMSG "玉失毛}仄户凶!" +#define NPC_DOOR_CANTOPENMSG "井亢互丐歹卅中及匹}玉失毛夫日仁仇午互\ +匹五卅中!" + +#define ROPEGRAPHIC 9259 /* 蔷 卞丐月骚木卅中夫□皿 */ + +enum{ + NPC_DOOR_FLG_SOONCLOSE = 1, + NPC_DOOR_FLG_WATCHCLOSE = 2 +}; + + +/* + * 玉失日仄中涩烂毛允月卞反}仇仇匹 + * maxhp , maxmp , level , str , tough 毛0卞允月午方中[ + * + */ +BOOL NPC_DoorInit( int meindex ) +{ + char arg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char settingdir[1024]; + char buf[256]; + + NPC_Util_GetArgStr( meindex, arg, sizeof( arg)); + CHAR_setWorkInt( meindex, CHAR_WORKEVENTTYPE,CHAR_EVENT_NPC); + + getStringFromIndexWithDelim(arg, "|" , 1 , buf,sizeof(buf) ); + CHAR_setWorkInt( meindex , CHAR_WORKDOOROPENG , atoi( buf )); + getStringFromIndexWithDelim(arg, "|" , 2 , buf,sizeof(buf) ); + CHAR_setWorkInt( meindex , CHAR_WORKDOORCLOSEG , atoi( buf )); + getStringFromIndexWithDelim(arg, "|" , 3 , buf,sizeof(buf) ); + CHAR_setWorkChar( meindex , CHAR_WORKDOORNAME , buf ); + strcpysafe( settingdir,sizeof( settingdir) , buf ); + getStringFromIndexWithDelim(arg, "|" , 4 , buf,sizeof(buf) ); + CHAR_setWorkInt( meindex , CHAR_WORKDOORSWITCHCOUNT , atoi( buf )); + getStringFromIndexWithDelim(arg, "|" , 5 , buf,sizeof(buf) ); + CHAR_setWorkInt( meindex , CHAR_WORKDOORCLOSETIME , atoi( buf )); + + CHAR_setInt( meindex , CHAR_MERCHANTLEVEL , atoi( buf )); + getStringFromIndexWithDelim(arg, "|" , 6 , buf,sizeof(buf) ); + CHAR_setWorkInt( meindex , CHAR_WORKDOORSOONFLG , atoi( buf )); + + getStringFromIndexWithDelim(arg, "|" , 7 , buf,sizeof(buf) ); + CHAR_setWorkInt( meindex , CHAR_WORKDOORPASSFLG , atoi( buf )); + CHAR_setWorkInt( meindex , CHAR_WORKDOORORIGINALGRAPHIC, + CHAR_getInt( meindex,CHAR_BASEIMAGENUMBER )); + CHAR_setInt( meindex, CHAR_LV, 0 ); + if( getStringFromIndexWithDelim( arg , "|" , 8 , buf ,sizeof( buf ))){ + if( strncmp( buf , "title" ,5 ) == 0 ){ + print( "This is a title door:'%s'\n" , buf ); + CHAR_setWorkInt( meindex , CHAR_WORKDOORPASSFLG ,0 ); + CHAR_setWorkChar( meindex , CHAR_WORKDOORTITLE , buf ); + CHAR_setInt( meindex, CHAR_LV, 1 ); + } else if( isdigit( buf[0] )){ + if( getStringFromIndexWithDelim(arg, "|" , 8 , buf,sizeof(buf) )) + CHAR_setWorkChar( meindex, CHAR_WORKDOORGOLDLIMIT, buf); + if( getStringFromIndexWithDelim(arg, "|" , 10 , buf,sizeof(buf) )) + CHAR_setWorkChar( meindex, CHAR_WORKDOORWEEK, buf); + if( getStringFromIndexWithDelim(arg, "|" , 11 , buf,sizeof(buf) )) + CHAR_setWorkChar( meindex, CHAR_WORKDOORHOUR, buf); + if( getStringFromIndexWithDelim(arg, "|" , 12 , buf,sizeof(buf) )) + CHAR_setWorkChar( meindex, CHAR_WORKDOORMINUTE, buf); + } + } + + CHAR_setInt( meindex , CHAR_HP , 0 ); + CHAR_setInt( meindex , CHAR_MP , 0 ); + CHAR_setInt( meindex , CHAR_MAXMP , 0 ); + CHAR_setInt( meindex , CHAR_STR , 0 ); + CHAR_setInt( meindex , CHAR_TOUGH, 0 ); + { + int g = CHAR_getWorkInt( meindex , CHAR_WORKDOOROPENG ); + if( g >= 11900 && g <= 11915 ){ + CHAR_setWorkInt( meindex , CHAR_WORKDOORKEYITEMID , 15 ); + } else if( g >= 11916 && g <= 11931 ){ + + CHAR_setWorkInt( meindex , CHAR_WORKDOORKEYITEMID , 16 ); + } else { + CHAR_setWorkInt( meindex , CHAR_WORKDOORKEYITEMID , -1 ); + } + if(CHAR_getWorkInt( meindex , CHAR_WORKDOORPASSFLG )==2){ + CHAR_setWorkInt( meindex , CHAR_WORKDOORKEYITEMID , -2 ); + } + if( CHAR_getInt( meindex , CHAR_BASEIMAGENUMBER ) == + ROPEGRAPHIC ){ + CHAR_setWorkInt( meindex , CHAR_WORKDOORKEYITEMID,-2 ); + } + } + + { + int closeg = CHAR_getWorkInt( meindex , CHAR_WORKDOORCLOSEG ); + int dir = -1; + switch( closeg ){ + case 11900: dir = 6; break; /* 霁及玉失 夫分曰仄凶 */ + case 11902: dir = 0; break; /* 夫分曰丹尹 */ + case 11904: dir = 2; break; /* 心亢丹尹 */ + case 11906: dir = 4; break; /* 心亢仄凶 */ + + case 11908: dir = 6; break; /* 赢中霁及玉失 夫分曰仄凶 */ + case 11910: dir = 0; break; /* 夫分曰丹尹 */ + case 11912: dir = 2; break; /* 心亢丹尹 */ + case 11914: dir = 4; break; /* 心亢仄凶 */ + + case 11916: dir = 6; break; /* 嗡及玉失 夫分曰仄凶 */ + case 11918: dir = 0; break; /* 夫分曰丹尹 */ + case 11920: dir = 2; break; /* 心亢丹尹 */ + case 11922: dir = 4; break; /* 心亢仄凶 */ + + case 11924: dir = 6; break; /* 赢中嗡及玉失 夫分曰仄凶 */ + case 11926: dir = 0; break; /* 夫分曰丹尹 */ + case 11928: dir = 2; break; /* 心亢丹尹 */ + case 11930: dir = 4; break; /* 心亢仄凶 */ + + case 11958: dir = 2; break; /* 赢中 及玉失 心亢丹尹 */ + case 11960: dir = 4; break; /* 心亢仄凶 */ + case 11962: dir = 6; break; /* 夫分曰仄凶 */ + case 11964: dir = 0; break; /* 夫分曰丹尹 */ + + case 11966: dir = 2; break; /* 及玉失 心亢丹尹 */ + case 11968: dir = 4; break; /* 心亢仄凶 */ + case 11970: dir = 6; break; /* 夫分曰仄凶 */ + case 11972: dir = 0; break; /* 夫分曰丹尹 */ + + case 11978: dir = 2; break; /* 赢中嗯及玉失 心亢丹尹 */ + case 11980: dir = 4; break; /* 心亢仄凶 */ + case 11982: dir = 6; break; /* 夫分曰仄凶 */ + case 11984: dir = 0; break; /* 夫分曰丹尹 */ + + case 11986: dir = 2; break; /* 嗯及玉失 心亢丹尹 */ + case 11988: dir = 4; break; /* 心亢仄凶 */ + case 11990: dir = 6; break; /* 夫分曰仄凶 */ + case 11992: dir = 0; break; /* 夫分曰丹尹 */ + + default: break; + } + if( dir >= 0 )CHAR_setInt(meindex,CHAR_DIR,dir); + } + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEDOOR ); + CHAR_setFlg( meindex , CHAR_ISATTACKED , 0 ); + CHAR_setInt( meindex , CHAR_WORKDOORSWITCHCURRENT , 0 ); + CHAR_setWorkInt( meindex, CHAR_WORKDOOREXPIRETIME, 0xffffffff); + if( CHAR_getWorkInt( meindex , CHAR_WORKDOORPASSFLG ) == 1){ + NPC_ROOMINFO roominfo; + if( NPC_RoomAdminNew_ReadFile( CHAR_getWorkChar( meindex, CHAR_WORKDOORNAME), &roominfo) == TRUE ){ + NPC_DoorSetPasswd( meindex, roominfo.passwd); + CHAR_setWorkInt( meindex, CHAR_WORKDOOREXPIRETIME, roominfo.expire); + }else { + NPC_DoorSetPasswd( meindex, "8hda8iauia90494jasd9asodfasdf89" ); + if( getStringFromIndexWithDelim(arg, "|" , 13 , buf,sizeof(buf) )) + if( strlen( buf) != 0 ) + NPC_DoorSetPasswd( meindex, buf ); + } + } + + CHAR_setInt( meindex, CHAR_BASEIMAGENUMBER , CHAR_getWorkInt(meindex, CHAR_WORKDOORCLOSEG)); + NPC_DoorRefreshOverFlg( meindex ); + CHAR_setWorkInt( meindex, CHAR_WORKEVENTTYPE, CHAR_EVENT_NPC); + return TRUE; +} +void NPC_DoorAddSwitchCounter( int meindex , int i , int doindex ) +{ + if( i != 0 && CHAR_getWorkInt( meindex, CHAR_WORKDOORSWITCHCOUNT) + != 0 ){ + CHAR_setWorkInt( meindex, CHAR_WORKDOORSWITCHCURRENT , + CHAR_getWorkInt(meindex, + CHAR_WORKDOORSWITCHCURRENT) + + i ); + if( CHAR_getWorkInt( meindex, CHAR_WORKDOORSWITCHCURRENT ) == + CHAR_getWorkInt( meindex, CHAR_WORKDOORSWITCHCOUNT) ){ + NPC_DoorOpen( meindex , doindex ); + } else { + NPC_DoorClose( meindex , doindex ); + } + } +} + +void NPC_DoorSetSwitchCounter( int meindex, int i , int doindex ) +{ + if( !CHAR_CHECKINDEX(meindex))return; + CHAR_setWorkInt( meindex , CHAR_WORKDOORSWITCHCURRENT , i ); + NPC_DoorAddSwitchCounter( meindex, 0 , doindex ); +} + +static int NPC_DoorSamePos( int meindex ){ + int iWork; + OBJECT object; + int floor = CHAR_getInt( meindex, CHAR_FLOOR ); + int x = CHAR_getInt( meindex, CHAR_X ); + int y = CHAR_getInt( meindex, CHAR_Y ); + + for( object=MAP_getTopObj( floor, x,y ); object ; object = NEXT_OBJECT(object) ){ + int objindex = GET_OBJINDEX(object); + if( OBJECT_getType(objindex) != OBJTYPE_CHARA )continue; + iWork = OBJECT_getIndex(objindex); + if( CHAR_getInt(iWork,CHAR_HP) < 0 )continue; + if( CHAR_getInt( iWork,CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){ + return iWork; + } + } + return -1; +} + +void NPC_DoorWatch( int myobjindex, int moveobjindex, CHAR_ACTION act, + int x, int y, int dir, int* opt, int optlen ) +{ + unsigned long closetime; + int meindex, moveindex; + + if( OBJECT_getType( moveobjindex) != OBJTYPE_CHARA ) { + return; + } + meindex = OBJECT_getIndex(myobjindex); + moveindex = OBJECT_getIndex(moveobjindex); + if( NPC_Door_isOpen( meindex ) == 0 )return; + if( CHAR_getInt( moveindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ){ + return; + } + if( CHAR_getWorkInt( meindex , CHAR_WORKDOORSOONFLG )){ + if( CHAR_getInt( meindex , CHAR_TALKCOUNT ) > 0 ){ + if( NPC_DoorSamePos( meindex ) == -1 ){ + NPC_DoorClose(meindex , -1 ); + CHAR_setInt( meindex , CHAR_TALKCOUNT, 0 ); + } + } + }else + if( CHAR_getInt( meindex, CHAR_MERCHANTLEVEL ) >= 0 ){ + closetime = (unsigned long )CHAR_getWorkInt( meindex , CHAR_WORKDOORCLOSETIME ); + if( (unsigned long) NowTime.tv_sec > (unsigned long) closetime ){ + NPC_DoorClose(meindex , -1 ); + } + } +} + + +#if 1 +void NPC_DoorOff( int meindex , int movedindex ) +{ + if( CHAR_getWorkInt( meindex , CHAR_WORKDOORSOONFLG )){ + NPC_DoorClose(meindex , -1 ); + } else { + } +} +#endif + +void NPC_DoorPostOver( int meindex , int movedindex ) +{ + if( CHAR_getWorkInt( meindex , CHAR_WORKDOORSOONFLG )){ + CHAR_setInt( meindex , CHAR_TALKCOUNT, 1 ); + CHAR_setFlg( meindex , CHAR_ISOVERED , 0 ); /* 骚木卅仁允月 */ + } +} + +void NPC_DoorLooked( int meindex , int lookedindex ) +{ + int needkey; + + if( CHAR_getInt( meindex , CHAR_LV )){ + char token[32]; + char *p = CHAR_getWorkChar( meindex , CHAR_WORKDOORTITLE ); + int i,j,ok=FALSE; + for(i = 0 ; ; i++ ){ + int r; + r = getStringFromIndexWithDelim( p,":",2+i,token ,sizeof(token)); + if(r){ + int titleind = atoi( token ); + for(j=0;j=1 ){ + if( NPC_Door_isOpen( meindex ) ){ + NPC_DoorFlip( meindex , lookedindex ); + return; + } +#define NPC_DOOR_EXPIRE_MSG "%s 的房间有效期限至 %d/%d %d:%d" + else { + if( CHAR_getWorkInt( meindex, CHAR_WORKDOOREXPIRETIME) + != 0xffffffff ){ + struct tm tmwk; + time_t expire = CHAR_getWorkInt( meindex, CHAR_WORKDOOREXPIRETIME); + char msgbuf[128]; + + NPC_ROOMINFO roominfo; + /* 由旦午 躲渝蜃毛本永玄允月 */ + NPC_RoomAdminNew_ReadFile( + CHAR_getWorkChar( meindex, CHAR_WORKDOORNAME), + &roominfo); + memcpy( &tmwk, localtime( &expire), sizeof( tmwk)); + snprintf( msgbuf, sizeof( msgbuf), NPC_DOOR_EXPIRE_MSG, + roominfo.charaname, + tmwk.tm_mon+1, tmwk.tm_mday, + tmwk.tm_hour, tmwk.tm_min); + CHAR_talkToCli( lookedindex, meindex, msgbuf, CHAR_COLORWHITE); + } + } + #undef NPC_DOOR_EXPIRE_MSG + return; + } + needkey = CHAR_getWorkInt( meindex , CHAR_WORKDOORKEYITEMID ); + if( needkey >= 0 ){ + if( NPC_Util_countHaveItem( lookedindex , needkey ) > 0 ){ + NPC_DoorFlip( meindex , lookedindex); + } else { + CHAR_talkToCli( lookedindex , -1 , NPC_DOOR_CANTOPENMSG , CHAR_COLORWHITE ); + } + } else if( needkey == -1 ){ + NPC_DoorFlip(meindex , lookedindex ); + } else { + CHAR_talkToCli( lookedindex , -1 , "这扇门似乎怎麽也打不开!" , CHAR_COLORWHITE); + } +} +void NPC_DoorTalked( int meindex , int talkerindex , char *msg , int color ) +{ + char *m = CHAR_getWorkChar( meindex , CHAR_WORKDOORPASSWD ); + if(NPC_Util_CharDistance( talkerindex, meindex ) > 1)return; + if( CHAR_getWorkInt( meindex , CHAR_WORKDOORPASSFLG ) != 1 ){ + return; + } + if( CHAR_getWorkInt( meindex , CHAR_WORKDOORPASSFLG ) >= 1 && + ((unsigned long)NowTime.tv_sec) > (unsigned long) + CHAR_getWorkInt( meindex , CHAR_WORKDOOREXPIRETIME )){ + print( "RINGO: passdoor expired ( talked )\n" ); + return; + } + if( m[0] == '\0' )return; + cutDotsTail( msg ); + if( strcmp( m , msg ) == 0 ){ + NPC_DoorFlip( meindex , talkerindex ); + }else { + CHAR_talkToCli( talkerindex , -1 , "密码不正确啦!", CHAR_COLORWHITE ); + } +} + +int NPC_DoorSearchByName( char *name ) +{ + int i; + int charnum = CHAR_getCharNum(); + + for(i= CHAR_getPlayerMaxNum() + CHAR_getPetMaxNum(); + i= 0 ) CHAR_talkToCli( doindex , -1 , NPC_DOOR_CLOSEMSG, CHAR_COLORWHITE ); + CHAR_setInt( meindex , CHAR_TALKCOUNT, 0 ); +} +void NPC_DoorOpen(int meindex , int doindex ) +{ + CHAR_setWorkInt( meindex , CHAR_WORKDOORCLOSETIME, + NowTime.tv_sec + + CHAR_getInt( meindex , CHAR_MERCHANTLEVEL)); + CHAR_setInt( meindex , CHAR_BASEIMAGENUMBER , + CHAR_getWorkInt( meindex,CHAR_WORKDOOROPENG )); + NPC_DoorRefreshOverFlg( meindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, + CHAR_WORKOBJINDEX )); + if( doindex >= 0 ) + CHAR_talkToCli( doindex , -1, NPC_DOOR_OPENMSG ,CHAR_COLORWHITE); +} + +static int NPC_Door_isOpen( int meindex ) +{ + int now_g = CHAR_getInt( meindex , CHAR_BASEIMAGENUMBER ); + int open_g = CHAR_getWorkInt( meindex ,CHAR_WORKDOOROPENG ); + if( now_g == open_g ) return 1; else return 0; +} + +BOOL NPC_DoorRefreshOverFlg( int meind ) +{ + if( !CHAR_CHECKINDEX(meind))return FALSE; + if( NPC_Door_isOpen( meind ) ==1 ){ + CHAR_setFlg( meind , CHAR_ISOVERED , 1 ); + } else { + CHAR_setFlg( meind , CHAR_ISOVERED , 0 ); + } + return TRUE; +} + +BOOL NPC_DoorSetRopeFlag(int fl,int x,int y, int flag ) +{ + int ind = NPC_DoorSearchByPosition( fl,x,y ); + if( ind < 0 ) return FALSE; + if( flag ){ + CHAR_setInt( ind , CHAR_BASEIMAGENUMBER , ROPEGRAPHIC ); + } else { + CHAR_setInt(ind , CHAR_BASEIMAGENUMBER , 0 ); + } + NPC_DoorRefreshOverFlg( ind ); + CHAR_sendCToArroundCharacter( + CHAR_getWorkInt( ind , CHAR_WORKOBJINDEX )); + + return TRUE; +} + diff --git a/gmsv/npc/npc_doorman.c b/gmsv/npc/npc_doorman.c new file mode 100644 index 0000000..c02433a --- /dev/null +++ b/gmsv/npc/npc_doorman.c @@ -0,0 +1,215 @@ +#include "version.h" +#include +#include "object.h" +#include "char_base.h" +#include "char.h" +#include "item.h" +#include "util.h" +#include "handletime.h" +#include "npc_doorman.h" +#include "npc_door.h" +#include "npcutil.h" +#include "configfile.h" +/* + * + * 曰卞玉失互丐月午五卞公及玉失毛窒日井及椭瘀卞方匀化钒仁NPC. + * 玉失及午卅曰卞create允月分仃匹}公及玉失毛丑综今六月仇午互匹五月[ + * 反卅仄井仃日木凶午五卞蝈平乓仿毛腹绸仄化}引歹曰8穴旦卞玉失互中月 + * 桦宁反公及允屯化卞覆仄化排黍允月[孔凶勾及玉失互 凛卞钒仁仇午卞卅月[ + * + * 奶件正□白尼奶旦反Talk匹 + * + * 玉失毛钒仁凶户卞 + * + * 1 云嗯毛蔼璋允月[蔼璋匹五凶日夫日仁 gold|100 + * 2 失奶 丞毛1蜊蔼璋允月 [蔼璋匹五凶日夫日仁 item|45 + * 3 失奶 丞毛 匀化中月井升丹井譬屯月[ 匀化中凶日钒仁[itemhave|44 + * 4 失奶 丞毛 匀化中卅中井升丹井譬屯月[ 匀化中卅井匀凶日钒仁[ + * itemnothave|333 + * 5 惫寞毛手匀化中月井升丹井譬屯月[ 匀化中凶日钒仁[ titlehave|string + * 6 惫寞毛手匀化中卅中井升丹井譬屯月[ 匀化中卅井匀凶日钒仁[ + * titlenothave|string + * + * 井卅日内撙 卞蚕尹月午钒仁[嗯及桦宁反} + *>100打□伙玉中凶分五引允互中中匹允井"=匹>反中=午中丹午100打□伙玉 + * 午日木月[中五卅曰>反中=分仃蜕匀化手午日木月[匹}>100打□伙玉 + * 中凶分五引仄凶[=午蜕歹木月[ + * + * 失奶 丞蔼璋及桦宁反}>窒★毛域蜊中凶分五引允互中中匹允井"=午五仁[ + * 3井日6及桦宁反}窒井反卅仄井仃化椭瘀互公欠匀化凶日钒仁[ + * + * + * + * 旦玄及 芊 + * + *1 玉失毛化五午丹卞 仁 + *2 仇及NPC毛赝癫卞玉失及午卅曰卞 仁[娄醒毛 gold|100 卞允月 + *3 仇及NPC卞覆仄化}100打□伙玉动晓手匀化中月橇谪匹>反中=午蜕丹 + *4 玉失互夫日中化嗯互蛹匀凶日岳 [ + * + */ + +static void NPC_DoormanOpenDoor( char *nm ); + +BOOL NPC_DoormanInit( int meindex ) +{ + char arg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char dname[1024]; + + /* 奶矛件玄及正奶皿涩烂 */ + CHAR_setWorkInt( meindex, CHAR_WORKEVENTTYPE,CHAR_EVENT_NPC); + + CHAR_setInt( meindex , CHAR_HP , 0 ); + CHAR_setInt( meindex , CHAR_MP , 0 ); + CHAR_setInt( meindex , CHAR_MAXMP , 0 ); + CHAR_setInt( meindex , CHAR_STR , 0 ); + CHAR_setInt( meindex , CHAR_TOUGH, 0 ); + CHAR_setInt( meindex , CHAR_LV , 0 ); + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPETOWNPEOPLE ); + CHAR_setFlg( meindex , CHAR_ISOVERED , 0 ); + CHAR_setFlg( meindex , CHAR_ISATTACKED , 0 ); /* 猾今木卅中方氏 */ + + NPC_Util_GetArgStr( meindex, arg, sizeof( arg)); + + if(!getStringFromIndexWithDelim( arg, "|", 3, dname, sizeof(dname ))){ + print("RINGO: 设定看门者时需要门的名字唷!:%s:\n", + arg ); + return FALSE; + } + print( "RINGO: Doorman create: arg: %s dname: %s\n",arg,dname); + CHAR_setWorkChar( meindex , CHAR_WORKDOORMANDOORNAME , dname ); + + return TRUE; +} + +void NPC_DoormanTalked( int meindex , int talkerindex , char *msg , + int color ) +{ + char mode[128]; + char opt[256]; + char arg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + /* 皿伊奶乩□互玉失穴件及1弘伉永玉动 卅日反氏及丹 */ + if(NPC_Util_CharDistance( talkerindex, meindex ) > 1)return; + + NPC_Util_GetArgStr( meindex, arg, sizeof( arg)); + + if( !getStringFromIndexWithDelim( arg, "|", 1, mode, sizeof( mode ))) + return; + + if( !getStringFromIndexWithDelim( arg, "|", 2, opt, sizeof( opt ) )) + return; + + if( strcmp( mode , "gold" ) == 0 ){ + int g = atoi( opt ); + int yn = NPC_Util_YN( msg ); + /*char *nm = CHAR_getChar( meindex , CHAR_NAME );*/ + char msg[256]; + + if( g > 0 && yn < 0 ){ + snprintf( msg ,sizeof( msg ) , + "打开门需要给我%d的金子这样可以吗?", g ); + CHAR_talkToCli( talkerindex, meindex , msg, CHAR_COLORWHITE ); + } else if( g > 0 && yn == 0 ){ + snprintf( msg , sizeof( msg ), + "打开门 %d的金子是必要的。", g ); + } else if( g > 0 && yn == 1 ){ + int now_g = CHAR_getInt( talkerindex, CHAR_GOLD ); + if( now_g < g ){ + snprintf( msg , sizeof( msg ) , + "打开门 %d的金子是必要的。", g ); + CHAR_talkToCli( talkerindex, meindex , msg, CHAR_COLORWHITE ); + } else { + snprintf( msg , sizeof( msg ), + "%d 收到金子了。现在就来开门。", g ); + CHAR_talkToCli( talkerindex, meindex , msg, CHAR_COLORWHITE ); + + /* 云嗯毛必永玄 */ + now_g -= g; + CHAR_setInt( talkerindex , CHAR_GOLD , now_g ); + /* 丐凶日仄中旦 □正旦毛霜耨 */ + CHAR_send_P_StatusString(talkerindex, CHAR_P_STRING_GOLD); + + /* 玉失夫日仁 */ + NPC_DoormanOpenDoor( + CHAR_getWorkChar( meindex, CHAR_WORKDOORMANDOORNAME)); + } + } + } else if( strcmp( mode , "item" ) == 0 ){ + CHAR_talkToCli( talkerindex, meindex , + "尚在未支援模式。", + CHAR_COLORWHITE); + } else if( strcmp( mode , "itemhave" ) == 0 ){ + CHAR_talkToCli( talkerindex, meindex , + "尚在未支援模式。", + CHAR_COLORWHITE); + } else if( strcmp( mode , "itemnothave" ) == 0 ){ + CHAR_talkToCli( talkerindex, meindex , + "尚在未支援模式。", + CHAR_COLORWHITE); + } else if( strcmp( mode , "titlehave" ) == 0 ){ + CHAR_talkToCli( talkerindex, meindex , + "尚在未支援模式。", + CHAR_COLORWHITE); + + } else if( strcmp( mode , "roomlimit" ) == 0 ){ + + /* 盒及谛醒孺蜃互丐月桦宁 */ + char szOk[256], szNg[256], szBuf[32]; + int checkfloor; + int maxnum, i, iNum; + + if( !getStringFromIndexWithDelim( arg, "|", 2, szBuf, sizeof( szBuf ) )) + return; + + /* 譬屯月白夫失午 谛醒 */ + if( sscanf( szBuf, "%d:%d", &checkfloor, &maxnum ) != 2 ){ + return; + } + + for( iNum = 0,i = 0; i < getFdnum(); i ++ ){ + /* 皿伊奶乩□动陆卞反饬 互 中 */ + if( CHAR_getCharUse( i ) == FALSE )continue; + if( CHAR_getInt( i, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER )continue; + /* 隙烂及白夫失动陆卞饬 互 中 */ + if( CHAR_getInt( i, CHAR_FLOOR ) != checkfloor )continue; + iNum++; + } + if( !getStringFromIndexWithDelim( arg, "|", 5, szNg, sizeof( szNg ))){ + strcpy( szNg, "。。。。" ); /* 凤伞卅仄及本伉白 */ + } + if( !getStringFromIndexWithDelim( arg, "|", 4, szOk, sizeof( szOk ))){ + strcpy( szOk, "开门吧。。。" ); /* 凤伞丐曰及本伉白 */ + } + + if( iNum >= maxnum ){ + /* 毛译尹化中月桦宁 */ + CHAR_talkToCli( talkerindex, meindex ,szNg, CHAR_COLORWHITE); + }else{ + /* 卞 凶卅中桦宁 */ + CHAR_talkToCli( talkerindex, meindex ,szOk, CHAR_COLORWHITE); + NPC_DoormanOpenDoor( + CHAR_getWorkChar( meindex, CHAR_WORKDOORMANDOORNAME)); + } + + } else if( strcmp( mode , "titlenothave" ) == 0 ){ + CHAR_talkToCli( talkerindex, meindex , + "尚在未支援模式。", + CHAR_COLORWHITE); + } +} + +/* + * 蟆匹腹绸仄化甲永玄仄凶及毛允屯化钒仁[ + * + */ +static void NPC_DoormanOpenDoor( char *nm) +{ + int doori = NPC_DoorSearchByName( nm ); + print( "RINGO: Doorman's Door: index: %d\n", doori ); + + NPC_DoorOpen( doori , -1 ); + +} + diff --git a/gmsv/npc/npc_duelranking.c b/gmsv/npc/npc_duelranking.c new file mode 100644 index 0000000..31d0ae2 --- /dev/null +++ b/gmsv/npc/npc_duelranking.c @@ -0,0 +1,895 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "net.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "npc_duelranking.h" +#include "handletime.h" + +#ifdef _DEATH_CONTEND +#include "deathcontend.h" +#endif + +#ifdef _DEATH_FAMILY_GM_COMMAND // WON ADD 家族战GM指令 +#include "family.h" +#endif + +static void NPC_Duelranking_selectWindow( int meindex, int toindex, int num, int select ); +#define NPC_DUELRANKING_WINDOWLINENUM 10 + +#ifdef _DEATH_FAMILYCONTEND +BOOL NPC_ReadFamilyPK_List( void); +BOOL NPC_BackupFamilyPK_List( void); +BOOL NPC_getFamilyPK_List( int ti, char *buf, int sizes); +BOOL NPC_CheckJoin_FamilyPK_List( int meindex, int toindex); +#endif + +enum{ + WINDOWTYPE_PKLIST_START=10, + WINDOWTYPE_PKLIST_SELECT, + WINDOWTYPE_PKLIST_SELECT1, + WINDOWTYPE_PKLIST_SELECT2, + + WINDOWTYPE_FAMILYCONTENDSTART, + WINDOWTYPE_FAMILYCONTENDSELECT, + WINDOWTYPE_FAMILYCONTENDLIST, + WINDOWTYPE_FAMILYCONTENDJOIN, + + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT1, + NPC_WORK_BATTLELOOP = CHAR_NPCWORKINT2, +}; + +BOOL NPC_DuelrankingInit( int meindex ) +{ +#ifdef _DEATH_CONTEND + char buf1[256]; + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + CHAR_setWorkInt( meindex, NPC_WORK_BATTLELOOP, 0); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + + if( NPC_Util_GetArgStr( meindex, npcarg, sizeof( npcarg) ) != NULL && + NPC_Util_GetStrFromStrWithDelim( npcarg, "PKLoop", buf1, sizeof( buf1)) != NULL ){ + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, atoi(buf1)); + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "PKLType", buf1, sizeof( buf1)) != NULL ){ + CHAR_setWorkInt( meindex, NPC_WORK_BATTLELOOP, atoi( buf1)); + } + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "PKLDelay", buf1, sizeof( buf1)) != NULL ){ + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec + (atoi( buf1)*60) ); + } + } +#endif + +#ifdef _DEATH_FAMILYCONTEND + { + char buf1[256]; + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + CHAR_setWorkInt( meindex, NPC_WORK_BATTLELOOP, 0); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + if( NPC_Util_GetArgStr( meindex, npcarg, sizeof( npcarg) ) != NULL && + NPC_Util_GetStrFromStrWithDelim( npcarg, "LoadFMList", buf1, sizeof( buf1)) != NULL ){ + if( strstr( buf1, "ON") != NULL ) + NPC_ReadFamilyPK_List(); + } + } +#endif + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEDUELRANKING ); + return TRUE; +} + +void NPC_DuelrankingLooked( int meindex , int lookedindex) +{ + +#ifdef _DEATH_FAMILYCONTEND + char buf1[256]; + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + if( NPC_Util_GetArgStr( meindex, npcarg, sizeof( npcarg) ) != NULL && + NPC_Util_GetStrFromStrWithDelim( npcarg, "FmPkJoin", buf1, sizeof( buf1)) != NULL ){ + + if( strstr( buf1, "ON") !=NULL ){ + CHAR_setWorkInt( lookedindex, CHAR_WORKSHOPRELEVANT, 0); + NPC_Duelranking_selectWindow( meindex, lookedindex, 2, -1); + return; + }else{ + return; + } + } +#endif + +#ifdef _DEATH_CONTEND + char buf1[256]; + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + //static int first = 1; + if( NPC_Util_GetArgStr( meindex, npcarg, sizeof( npcarg) ) != NULL && + NPC_Util_GetStrFromStrWithDelim( npcarg, "PKCharts", buf1, sizeof( buf1)) != NULL ){ + if( strstr( buf1, "ON") !=NULL ){ + CHAR_setWorkInt( lookedindex, CHAR_WORKSHOPRELEVANT, 0); + NPC_Duelranking_selectWindow( meindex, lookedindex, 2, -1); + //if( first == 1 ) saacproto_PKLISTCHARTS_send( acfd, 2, 1); + //first = 0; + return; + }else{ + return; + } + } +#endif + +#ifdef _DEATH_FAMILY_GM_COMMAND // WON ADD 家族战GM指令 + NPC_Duelranking_selectWindow( meindex, lookedindex, 2, -1); +#endif + + NPC_Duelranking_selectWindow( meindex, lookedindex, 1, -1); +} + +static void NPC_Duelranking_selectWindow( int meindex, int toindex, int num, int select) +{ + + int fd; + int button; + if( CHAR_getInt( toindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + if( NPC_Util_CharDistance( toindex, meindex ) > 1) return; + if( (fd = getfdFromCharaIndex( toindex)) == -1 ) return; + + switch( num){ + case 1: + { + char message[1024]; + char buf[2048]; + strcpy( message, + "1\n" + " 要看哪一个? \n\n\n" + " <强者们> \n\n" + " < 自己 > \n\n" + " <都不看> \n\n" ); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_DUELRANKING_START, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( message, buf, sizeof(buf))); + } + break; +#ifdef _DEATH_CONTEND + case 2: + { + char message[1024]; + char buf[2048]; + strcpy( message, + "1\n" + " 要看哪一个? \n\n" +// " <资格赛排行> \n" + " < 正式赛程表 > \n" + " < 队伍资料 > \n" +// " < 参加赛程 > \n" + " < 赛程纪录 > \n" ); + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_CANCEL, + WINDOWTYPE_PKLIST_START, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( message, buf, sizeof(buf))); + } + break; +/* case 3: + { + char token[4096], buf[256], buf1[256],buf2[256]; + char teamname[256]; + int win, lose, battle, score; + int page, i, pagecount=10; + page = CHAR_getWorkInt( toindex, CHAR_WORKSHOPRELEVANT); + button = WINDOW_BUTTONTYPE_OK | WINDOW_BUTTONTYPE_PREV | WINDOW_BUTTONTYPE_NEXT; + + if( select == WINDOW_BUTTONTYPE_PREV || select == WINDOW_BUTTONTYPE_NEXT) { + if( select == WINDOW_BUTTONTYPE_NEXT ){ + if( page < 40 ) page++; + }else if( select == WINDOW_BUTTONTYPE_PREV ){ + if( page > 0 ) page--; + } + }else if( select == WINDOW_BUTTONTYPE_OK ){ + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 0); + return; + } + if( page < 0 || page >= 40 ) page = 0; + if( page == 0 ) button = WINDOW_BUTTONTYPE_OK | WINDOW_BUTTONTYPE_NEXT; + if( page == 39 ) button = WINDOW_BUTTONTYPE_OK | WINDOW_BUTTONTYPE_PREV; + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, page); + snprintf( token, sizeof( token), + " 资格赛排行榜\n\n" + "排名 队伍 胜 负 场 积分\n\n" ); + + for( i=0; i= 30 && score > 0 ) strcpy( buf2, "★"); + sprintf( buf1, "%4dth %-18s %3d %3d %3d %3d %s\n", (page*pagecount)+1+i, + teamname, win, lose, battle, score, buf2); + + strcat( token, buf1); + } + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_WIDEMESSAGEANDLINEINPUT, + button, WINDOWTYPE_PKLIST_SELECT, CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token ); + } + break; +*/ + case 5://晋级队伍 + case 3://正式赛程 + { + char token[4096], buf1[256]; + char teamname1[256], teamname2[256], typestring[256]; + int tindex, dtimes, stimes=0; + int page, i, pagecount=10; + int winno = WINDOWTYPE_PKLIST_SELECT; + + page = CHAR_getWorkInt( toindex, CHAR_WORKSHOPRELEVANT); + button = WINDOW_BUTTONTYPE_OK | WINDOW_BUTTONTYPE_PREV | WINDOW_BUTTONTYPE_NEXT; + + if( select == WINDOW_BUTTONTYPE_PREV || select == WINDOW_BUTTONTYPE_NEXT) { + if( select == WINDOW_BUTTONTYPE_NEXT ){ + if( page < 11 ) page++; + }else if( select == WINDOW_BUTTONTYPE_PREV ){ + if( page > 0 ) page--; + } + }else if( select == WINDOW_BUTTONTYPE_OK ){ + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 0); + return; + } + if( page < 0 || page >= 11 ) page = 0; + if( page == 0 ) button = WINDOW_BUTTONTYPE_OK | WINDOW_BUTTONTYPE_NEXT; + if( page == 10 ) button = WINDOW_BUTTONTYPE_OK | WINDOW_BUTTONTYPE_PREV; + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, page); + + switch( num){ + case 3: + snprintf( token, sizeof( token), + " 赛程表\n\n" + "场次 队伍 剩馀时间 状态\n\n" ); + break; + case 5: + snprintf( token, sizeof( token), " 队伍名单&赛程纪录\n\n" + "纪录 \n\n" ); + winno = WINDOWTYPE_PKLIST_SELECT2; + break; + } + + for( i=0; i 0 ) page--; + } + }else if( select == WINDOW_BUTTONTYPE_OK ){ + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 0); + return; + } + if( page < 0 || page >= 4 ) page = 0; + if( page == 0 ) button = WINDOW_BUTTONTYPE_OK | WINDOW_BUTTONTYPE_NEXT; + if( page == 3 ) button = WINDOW_BUTTONTYPE_OK | WINDOW_BUTTONTYPE_PREV; + + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, page); + snprintf( token, sizeof( token), + " 跨星系家族赛资格排行榜\n\n" + "排名 家族名称 家族族长名称\n\n" ); + for( i=0; i 0 ) page--; + } + }else if( select == WINDOW_BUTTONTYPE_OK ){ + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 0); + return; + } + if( page < 0 || page >= 40 ) page = 0; + if( page == 0 ) button = WINDOW_BUTTONTYPE_OK | WINDOW_BUTTONTYPE_NEXT; + if( page == 39 ) button = WINDOW_BUTTONTYPE_OK | WINDOW_BUTTONTYPE_PREV; + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, page); + snprintf( token, sizeof( token), + " 跨星系家族战排行榜\n\n" ); + + + for( i=0; i<40*10; i++){ + memset( all_msg[i] , 0, sizeof( all_msg[i])); + } + + if( (fp = fopen( "d_fm_pk_log.txt", "r" )) != NULL ){ + i=0; + //andy_log + print( "read d_fm_pk_log.txt !!\n"); + while( fgets( buf1, sizeof( buf1)-1, fp) ){ + //andy_log + print( "read buf1:%s !!\n", buf1); + if( buf1[0] == 0 || buf1[0] == '#' ||strlen(buf1) <= 0 ) continue; + buf1[ strlen(buf1) -1] = 0; + snprintf( all_msg[i], sizeof( all_msg[i]), "%s", buf1); + i++; + } + fclose( fp ); + }else{ + //andy_log + print( "Can't read d_fm_pk_log.txt !!\n"); + } + + for( i=0; i 1) return; + switch( seqno){ + case CHAR_WINDOWTYPE_DUELRANKING_START: + if( atoi( data) == 3 ) { + saacproto_DBGetEntryByCount_send( acfd, + DB_DUELPOINT, 0, + NPC_DUELRANKING_WINDOWLINENUM, fdid, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX)); + } + if( atoi( data) == 5 ) { + char dbkey[256]; + CHAR_makeDBKey( talkerindex, dbkey, sizeof( dbkey)); + saacproto_DBGetEntryRank_send( acfd, DB_DUELPOINT, dbkey, fdid, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX)); + } + break; + case CHAR_WINDOWTYPE_DUELRANKING_TOPRANKING: + if( select == WINDOW_BUTTONTYPE_PREV || select == WINDOW_BUTTONTYPE_NEXT) { + int count = CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT); + if( select == WINDOW_BUTTONTYPE_NEXT ) { + count += NPC_DUELRANKING_WINDOWLINENUM; + }else { + count -= NPC_DUELRANKING_WINDOWLINENUM; + } + + if( count < 0) count = 0; + saacproto_DBGetEntryByCount_send( acfd, + DB_DUELPOINT, + count, + NPC_DUELRANKING_WINDOWLINENUM, fdid, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX)); + }else if( select == WINDOW_BUTTONTYPE_OK ) { + if( strlen( data) != 0 ) { + int count; + count = atoi( data); + if( count < 1 ) count = 1; + saacproto_DBGetEntryByCount_send( acfd, + DB_DUELPOINT, + count-1, + NPC_DUELRANKING_WINDOWLINENUM, fdid, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX)); + } + } + break; +#ifdef _DEATH_CONTEND + case WINDOWTYPE_PKLIST_START: + { + switch( atoi( data)){ + case 2://资格赛排行 + NPC_Duelranking_selectWindow( meindex, talkerindex, 3, select); + break; + case 3://正式赛程 + NPC_Duelranking_selectWindow( meindex, talkerindex, 4, select); + break; + case 4://队伍资料 + NPC_Duelranking_selectWindow( meindex, talkerindex, 5, select); + break; + case 5://加入赛程 + NPC_Duelranking_selectWindow( meindex, talkerindex, 6, -1); + break; + case 6://晋级队伍 + NPC_Duelranking_selectWindow( meindex, talkerindex, 7, select); + break; + } + } + break; + case WINDOWTYPE_PKLIST_SELECT: + NPC_Duelranking_selectWindow( meindex, talkerindex, 3, select); + break; + case WINDOWTYPE_PKLIST_SELECT1: + NPC_Duelranking_selectWindow( meindex, talkerindex, 4, select); + break; + case WINDOWTYPE_PKLIST_SELECT2: + NPC_Duelranking_selectWindow( meindex, talkerindex, 5, select); + break; +#endif +#ifdef _DEATH_FAMILYCONTEND + case WINDOWTYPE_FAMILYCONTENDSTART: + { + switch( atoi( data)){ + case 2://资格排行 + NPC_Duelranking_selectWindow( meindex, talkerindex, 3, select); + break; + case 3://报名 + NPC_Duelranking_selectWindow( meindex, talkerindex, 4, select); + break; + } + } + break; + case WINDOWTYPE_FAMILYCONTENDSELECT: + NPC_Duelranking_selectWindow( meindex, talkerindex, 3, select); + break; +#endif + +#ifdef _DEATH_FAMILY_GM_COMMAND // WON ADD 家族战GM指令 + case WINDOWTYPE_PKLIST_START: + { + switch( atoi( data ) ){ + case 2: + NPC_Duelranking_selectWindow( meindex, talkerindex, 3, select); + break; + } + } + break; + case WINDOWTYPE_PKLIST_SELECT1: + NPC_Duelranking_selectWindow( meindex, talkerindex, 3, select); + break; +#endif + + + } +} + +void NPC_Duelranking_PrintRanking( char *data, int count_start, int fdid, int msgid2) +{ + char message[1024]; + char buf[2048]; + int i; + int cnt = 0; + int button = 0; + int fd = getfdFromFdid( fdid); + if( fd == -1 ) return; + message[0] = '\0'; + snprintf( message, sizeof( message), + " 世界的强者们\n\n" + " Rank DuelPoint Lv Name\n\n" ); + for( i = 1; ; i ++ ) { + char rankdata[256]; + char cdandname[64]; + char charaname[32]; + char rank[16]; + char score[64]; + char msgbuf[512]; + char cdkey[32]; + char lv[16]; + char hosi[6]; + + if( !getStringFromIndexWithDelim( data, "|", i, rankdata, sizeof( rankdata))) { + break; + } + if( !getStringFromIndexWithDelim( rankdata, ",", 2, rank, sizeof( rank)) ){ + continue; + } + if( !getStringFromIndexWithDelim( rankdata, ",", 3, cdandname, sizeof( cdandname)) ){ continue; + } + makeStringFromEscaped( cdandname); + if( !getStringFromIndexWithDelim( cdandname, "_", 1, cdkey, sizeof( cdkey)) ){ + continue; + } + if( !getStringFromIndexWithDelim( cdandname, "_", 2, charaname, sizeof( charaname)) ){ + continue; + } + if( !getStringFromIndexWithDelim( rankdata, ",", 4, score, sizeof( score)) ){ + continue; + } + if( !getStringFromIndexWithDelim( rankdata, ",", 5, lv, sizeof( lv)) ){ + lv[0] = '\0'; + } + { + char *mycdkey = CHAR_getChar( CONNECT_getCharaindex(fd), CHAR_CDKEY); + char *myname = CHAR_getChar( CONNECT_getCharaindex(fd), CHAR_NAME); + char engnum[4][3] = { "st","nd","rd","th"}; + int dsprank = atoi(rank); + if( dsprank > 3) dsprank = 3; + if( mycdkey != NULL && myname != NULL && strcmp( cdkey, mycdkey) == 0 && + strcmp( charaname, myname) == 0 ) { + strcpy( hosi, "★"); + }else { + strcpy( hosi, " "); + } + snprintf( msgbuf, sizeof( msgbuf), "%s %5d%s %10s %3s %s\n", + hosi, + atoi(rank)+1, engnum[dsprank], + score, lv, + charaname ); + } + strcatsafe( message, sizeof( message), msgbuf); + cnt ++; + } + if( cnt == 0 ) { + strcpy( message, "\n 没有其他的资料了。"); + button = WINDOW_BUTTONTYPE_PREV|WINDOW_BUTTONTYPE_OK; + }else if( cnt < NPC_DUELRANKING_WINDOWLINENUM ) { + if( count_start >= NPC_DUELRANKING_WINDOWLINENUM) { + button = WINDOW_BUTTONTYPE_OK | WINDOW_BUTTONTYPE_PREV; + }else { + button = WINDOW_BUTTONTYPE_OK; + } + }else if( count_start == 0 ) { + button = WINDOW_BUTTONTYPE_NEXT|WINDOW_BUTTONTYPE_OK; + }else { + button = WINDOW_BUTTONTYPE_NEXT|WINDOW_BUTTONTYPE_PREV|WINDOW_BUTTONTYPE_OK; + } + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_WIDEMESSAGEANDLINEINPUT, + button, + CHAR_WINDOWTYPE_DUELRANKING_TOPRANKING, + msgid2, + makeEscapeString( message, buf, sizeof(buf))); + + if( cnt == 0 ) { + CHAR_setWorkInt( CONNECT_getCharaindex(fd), CHAR_WORKSHOPRELEVANT, -1); + }else { + CHAR_setWorkInt( CONNECT_getCharaindex(fd), CHAR_WORKSHOPRELEVANT, count_start); + } +} + +void NPC_Duelranking_CallMyRanking( int count, int msgid, int msgid2) +{ + count -= 5; + if( count < 0 ) count = 0; + saacproto_DBGetEntryByCount_send( acfd, DB_DUELPOINT, + count, NPC_DUELRANKING_WINDOWLINENUM, + msgid, msgid2 ); +} + +#ifdef _DEATH_CONTEND +void NPC_Duelrankingloop( int meindex) +{ + static int side = 0; + int i; + + if( CHAR_getWorkInt( meindex, NPC_WORK_CURRENTTIME) < NowTime.tv_sec ){ + char buf1[256]; + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + + if( NPC_Util_GetArgStr( meindex, npcarg, sizeof( npcarg) ) != NULL && + NPC_Util_GetStrFromStrWithDelim( npcarg, "PKLoop", buf1, sizeof( buf1)) != NULL ){ + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, atoi(buf1)); + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "PKLType", buf1, sizeof( buf1)) != NULL ){ + CHAR_setWorkInt( meindex, NPC_WORK_BATTLELOOP, atoi( buf1)); + } + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "PKLDelay", buf1, sizeof( buf1)) != NULL ){ + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec + (atoi( buf1)*60) ); + } + } + } + if( CHAR_getWorkInt( meindex, NPC_WORK_BATTLELOOP) == 0 ) return; + + for( i=0; i= MAXJOINFM ) break; + } + fclose( fp); + return TRUE; +} + +BOOL NPC_BackupFamilyPK_List( void) +{ + FILE *fp=NULL; + int i; + + if( (fp=fopen("fmlist.txt", "w+")) == NULL ) return FALSE; + for( i=0; i MAXJOINFM ) return FALSE; + if( JoinFamilyList[ti].use == 0 ) return FALSE; + + snprintf( buf, sizes, "%d|%s|%s|%s|%d|", + JoinFamilyList[ti].fmindex, JoinFamilyList[ti].fmname, + JoinFamilyList[ti].ucdkey, JoinFamilyList[ti].uname, JoinFamilyList[ti].join ); + + return TRUE; +} + +BOOL NPC_CheckJoin_FamilyPK_List( int meindex, int toindex) +{ + int i; + + //andy_log + print( " *check: [%d,%s,%s]\n", CHAR_getInt( toindex, CHAR_FMINDEX), + CHAR_getChar( toindex, CHAR_CDKEY), CHAR_getChar( toindex, CHAR_NAME) ); + + for( i=0; i +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "map_deal.h" +#include "readmap.h" +#include "battle.h" +#include "log.h" +#include "enemy.h" +#include "handletime.h" +#include "npc_eventaction.h" +#include "family.h" + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 +#include "profession_skill.h" +#include "chatmagic.h" +#endif + +enum{ + NPC_EVENTMODE_NONE, + NPC_EVENTMODE_OPEN, + NPC_EVENTMODE_EVENT, +}; + +typedef struct { + char arg[32]; + int born; + int dead; +}NPC_TimeMan; + +#define YOAKE 700 +#define NICHIBOTU 300 +#define SHOUGO 125 +#define YONAKA 500 + +static NPC_TimeMan TimeTble[] = { + {"ALLNIGHT", NICHIBOTU+1, YOAKE}, + {"ALLNOON", YOAKE+1, NICHIBOTU}, + {"AM", YONAKA+1, SHOUGO}, + {"PM", SHOUGO+1, YONAKA}, + {"FORE", YOAKE+1, SHOUGO}, + {"AFTER", SHOUGO+1, NICHIBOTU}, + {"EVNING", NICHIBOTU+1, YONAKA}, + {"MORNING", YONAKA+1, YOAKE}, + {"FREE", 0, 1024}, +}; + +extern void BATTLE_changeRideImage( int index ); + + +#define MAXNPCPOINT 10 + +BOOL ActionNpc_WarpPoint(int meindex,int talker,char *npcarg) +{ + char data[1024], buf1[256], buf2[256]; + int i=1, j=0; + BOOL EvFlg=FALSE; + + struct { + int FLOOR; + int X; + int Y; + }Points[MAXNPCPOINT]; + + for( i=0;i= MAXNPCPOINT ) + break; + } + where = RAND( 0, j-1); + if( MAP_IsValidCoordinate( Points[where].FLOOR, Points[where].X, Points[where].Y ) == TRUE ){ + CHAR_warpToSpecificPoint( meindex, Points[where].FLOOR, Points[where].X, Points[where].Y); + EvFlg = TRUE; + }else { + for( i=0; i<10; i++) { + print("%d.[%d,%d,%d]\n", i, Points[i].FLOOR, Points[i].X, Points[i].Y); + } + } + } + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "WARPPOINT", data, sizeof( data)) != NULL ) { + int where=0; + i=1; + j=0; + while( getStringFromIndexWithDelim( data, ";", i, buf1, sizeof( buf1)) != FALSE ) { + i++; + getStringFromIndexWithDelim( buf1, ",", 1, buf2, sizeof( buf2)); + Points[j].FLOOR = atoi( buf2); + getStringFromIndexWithDelim( buf1, ",", 2, buf2, sizeof( buf2)); + Points[j].X = atoi( buf2); + getStringFromIndexWithDelim( buf1, ",", 3, buf2, sizeof( buf2)); + Points[j].Y = atoi( buf2); + j++; + if( j >= MAXNPCPOINT ) + break; + } + where = RAND( 0, j-1); + if( MAP_IsValidCoordinate( Points[where].FLOOR, Points[where].X, Points[where].Y ) == TRUE ){ + CHAR_warpToSpecificPoint( talker, Points[where].FLOOR, Points[where].X, Points[where].Y); + EvFlg = TRUE; + }else { + for( i=0; i<10; i++) { + print("%d.[%d,%d,%d]\n", i, Points[i].FLOOR, Points[i].X, Points[i].Y); + } + } + + } + + return EvFlg; +} + +BOOL ActionNpc_CheckMenuFree( int meindex, int toindex, char *npcarg, int nums) +{ + char buf1[1024], buf2[256]; + if( nums < 1 ) return FALSE; + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "CHECKPARTY", buf1, sizeof( buf1) ) != NULL){ + if( strstr( buf1, "TRUE") != 0 ) { + if( Action_PartyCheck( meindex, toindex) == FALSE) { + CHAR_talkToCli( toindex, meindex, "请一个一个来!", CHAR_COLORYELLOW); + return FALSE; + } + } + } + if( getStringFromIndexWithDelim( npcarg,"}", nums, buf1, sizeof( buf1)) == FALSE ) + return FALSE; + + if( NPC_Util_GetStrFromStrWithDelim( buf1, "FREE", buf2, sizeof( buf2) ) == NULL) + return FALSE; + + if( NPC_ActionPassCheck( meindex, toindex, buf2) == FALSE ) { + CHAR_talkToCli( toindex, meindex, "条件不足!", CHAR_COLORYELLOW); + return FALSE; + } + return Action_RunDoEventAction( meindex, toindex, buf1); +} + +BOOL ActionNpc_CheckFree( int meindex, int toindex, char *npcarg) +{ + char buf1[1024], buf2[256]; + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "CHECKPARTY", buf1, sizeof( buf1) ) != NULL){ + if( strstr( buf1, "TRUE") != 0 ) { + if( Action_PartyCheck( meindex, toindex) == FALSE) { + CHAR_talkToCli( toindex, meindex, "请一个一个来!", CHAR_COLORYELLOW); + return FALSE; + } + } + } + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "FREE", buf2, sizeof( buf2) ) == NULL) + return FALSE; + + if( NPC_ActionPassCheck( meindex, toindex, buf2) == FALSE ) { + CHAR_talkToCli( toindex, meindex, "条件不足!", CHAR_COLORYELLOW); + return FALSE; + } + return Action_RunDoEventAction( meindex, toindex, buf1); +} + +#ifdef _CHANNEL_MODIFY +extern int *piOccChannelMember; +#endif + +BOOL Action_RunDoEventAction( int meindex, int toindex, char *buf1) +{ + char buf2[1256]; + +#if 1 // Robin NPC执行动作前再一次检查FREE条件 + if( NPC_Util_GetStrFromStrWithDelim( buf1, "FREE", buf2, sizeof( buf2)) != NULL ) { + if( NPC_ActionPassCheck( meindex, toindex, buf2 ) == FALSE && buf2[0] != NULL ) { + print("\n 改封包!?跳过NPC的FREE检查!!:%s:%d,%d,%d ", + CHAR_getChar(toindex, CHAR_CDKEY), + CHAR_getInt(toindex, CHAR_FLOOR), + CHAR_getInt(toindex, CHAR_X), + CHAR_getInt(toindex, CHAR_Y) ); + CHAR_warpToSpecificPoint(toindex,117,225,13); + return FALSE; + } + } +#endif + + + if( NPC_Util_GetStrFromStrWithDelim( buf1, "AddGold", buf2, sizeof( buf2)) != NULL ) { + if( NPC_ActionAddGold2( toindex, buf2) == FALSE ) + return FALSE; + } + + if( NPC_Util_GetStrFromStrWithDelim( buf1, "DelGold", buf2, sizeof( buf2)) != NULL ) { + if( NPC_ActionDelGold( toindex, buf2) == FALSE ) + return FALSE; + } + if( NPC_Util_GetStrFromStrWithDelim( buf1, "DelItem", buf2, sizeof( buf2)) != NULL ) { + //print("\n DelItem:%s:%d ", __FILE__, __LINE__); + if( NPC_ActionDelItem( toindex, buf2) == FALSE ) { + //print("\n 改封包??NPC_ActionDelItem:%s:%s ", CHAR_getChar(toindex, CHAR_CDKEY), buf2); + //CHAR_warpToSpecificPoint(toindex,117,225,13); + return FALSE; + } + } + + //条件成立後npc所给的道具 + if( NPC_Util_GetStrFromStrWithDelim( buf1, "AddItem", buf2, sizeof( buf2)) != NULL ) { + if( NPC_ActionAddItem( toindex, buf2) == FALSE ) + return FALSE; + } + + if( NPC_Util_GetStrFromStrWithDelim( buf1, "DelPet", buf2, sizeof( buf2)) != NULL ) { + if( NPC_ActionDelPet( toindex, buf2) == FALSE ) + return FALSE; + } + +#ifdef _NPC_NewDelPet + if( NPC_Util_GetStrFromStrWithDelim( buf1, "NewDelPet", buf2, sizeof( buf2)) != NULL ) { + if( NPC_ActionNewDelPet( toindex, buf2) == FALSE ) + return FALSE; + } +#endif + + if( NPC_Util_GetStrFromStrWithDelim( buf1, "AddPet", buf2, sizeof( buf2)) != NULL ) { + if( NPC_ActionAddPet( toindex, buf2) == FALSE ) + return FALSE; + } + if( NPC_Util_GetStrFromStrWithDelim( buf1, "EvEnd", buf2, sizeof( buf2)) != NULL ) { + if( NPC_ActionSetEend( toindex, buf2) == FALSE ) + return FALSE; + } + if( NPC_Util_GetStrFromStrWithDelim( buf1, "EvNow", buf2, sizeof( buf2)) != NULL ) { + if( NPC_ActionSetNow( toindex, buf2) == FALSE ) + return FALSE; + } + + if( NPC_Util_GetStrFromStrWithDelim( buf1, "Event_End", buf2, sizeof( buf2) ) != NULL) { + if( NPC_ActionSetEend( toindex, buf2) == FALSE ) { + return FALSE; + } + } + + if( NPC_Util_GetStrFromStrWithDelim( buf1, "Event_Now", buf2, sizeof( buf2) ) != NULL) { + if( NPC_ActionSetNow( toindex, buf2) == FALSE ) + return FALSE; + } + + + if( NPC_Util_GetStrFromStrWithDelim( buf1, "EvClr", buf2, sizeof( buf2) ) != NULL) { + if( NPC_ActionClearEvent( toindex, buf2) == FALSE ) + return FALSE; + } + +#ifdef _NPCCHANGE_PLAYERIMG + if( NPC_Util_GetStrFromStrWithDelim( buf1, "CHANGEBBI", buf2, sizeof( buf2) ) != NULL) { + if( NPC_ActionChangePlayerBBI( meindex, toindex, buf2) == FALSE ) + return FALSE; + } +#endif + + if( NPC_Util_GetStrFromStrWithDelim( buf1, "SetLastTalkelder", buf2, sizeof( buf2) ) != NULL) { + CHAR_setInt( toindex, CHAR_LASTTALKELDER, atoi( buf2)); + } + +#ifdef _TYPE_TOXICATION + if( NPC_Util_GetStrFromStrWithDelim( buf1, "TOXICATION", buf2, sizeof( buf2) ) != NULL) { + int fd = getfdFromCharaIndex( toindex ); + if( strstr( buf2, "TRUE") != 0 ){ + setToxication( fd, 1); + CHAR_setWorkInt( toindex, CHAR_WORKTOXICATION, 0 ); + if( NPC_Util_GetStrFromStrWithDelim( buf1, "TOXICATIONMSG", buf2, sizeof( buf2) ) != NULL) { + CHAR_talkToCli( toindex, -1, buf1, CHAR_COLORYELLOW); + } + }else { + CHAR_setWorkInt( toindex, CHAR_WORKTOXICATION, 0 ); + setToxication( fd, 0); + if( NPC_Util_GetStrFromStrWithDelim( buf1, "DETOXIFYMSG", buf2, sizeof( buf2) ) != NULL) { + CHAR_talkToCli( toindex, -1, buf2, CHAR_COLORYELLOW); + } + } + } +#endif + +#ifdef _ACTION_GMQUE + if( NPC_Util_GetStrFromStrWithDelim( buf1, "GMACTION", buf2, sizeof( buf2) ) != NULL) { + if( strstr( buf2, "TRUE") != 0 ){ + if( GMQUE_getQueStr( meindex, toindex) == FALSE ){ + return FALSE; + } + } + } + if( NPC_Util_GetStrFromStrWithDelim( buf1, "ShowGmque", buf2, sizeof( buf2) ) != NULL) { + if( strstr( buf2, "TRUE") != 0 ) + GMQUE_showQueStr( meindex, toindex); + } + if( NPC_Util_GetStrFromStrWithDelim( buf1, "DelGmquePet", buf2, sizeof( buf2) ) != NULL) { + int count = atoi( buf2); + if( GMQUE_DelQueStrPet( meindex, toindex, count) == FALSE ){ + return FALSE; + } + } + if( NPC_Util_GetStrFromStrWithDelim( buf1, "GetGmPrize", buf2, sizeof( buf2) ) != NULL) { + if( GMQUE_AddQueStrTrophy( meindex, toindex) == FALSE ){ + return FALSE; + } + } + if( NPC_Util_GetStrFromStrWithDelim( buf1, "CleanGmque", buf2, sizeof( buf2) ) != NULL) { + if( strstr( buf2, "TRUE") != 0 ) + GMQUE_cleanQueStr( toindex); + } +#endif + +#ifdef _NEW_PLAYERGOLD + if( NPC_Util_GetStrFromStrWithDelim( buf1, "CHECKNEWPLAYER", buf2, sizeof( buf2) ) != NULL) { + if( strstr( buf2, "TRUE") != 0 ){ + char *CdKey; + char *UserName; + CdKey = CHAR_getChar( toindex, CHAR_CDKEY); + UserName = CHAR_getChar( toindex, CHAR_NAME); + saacproto_ACNEWPlayerList_send( acfd, CdKey, UserName, toindex, 1); + } + } +#endif + + if(NPC_Util_GetStrFromStrWithDelim( buf1, "GetRandItem", buf2, sizeof( buf2) ) != NULL ){ + int j=1, rand_cnt=1; + char buf3[256]; + while( getStringFromIndexWithDelim( buf2 , "," , j, buf3, sizeof( buf3)) != FALSE ){ + j++; + rand_cnt++; + } + NPC_ActionTreasureRandItemGet( meindex, toindex, rand_cnt, buf2); + } + +#ifdef _ACTION_BULLSCR + if( NPC_Util_GetStrFromStrWithDelim( buf1, "ABULLSCORE", buf2, sizeof( buf2) ) != NULL) { + if( strstr( buf2, "TRUE") != NULL ){ + if( CHAR_getInt( toindex, CHAR_ABULLSTART) != 20 ){ + CHAR_setInt( toindex, CHAR_ABULLSTART, 10); + CHAR_setInt( toindex, CHAR_ABULLSCORE, 0); + CHAR_setInt( toindex, CHAR_ABULLTIME, 0); + CHAR_setInt( toindex, CHAR_ABULLSTARTTIME, (int)time( NULL)); + CHAR_talkToCli( toindex, -1, "你开始参予与此活动。", CHAR_COLORYELLOW); + }else { + return FALSE; + } + }else { + CHAR_setInt( toindex, CHAR_ABULLSTART, 20); + CHAR_setInt( toindex, CHAR_ABULLSCORE, 0); + CHAR_setInt( toindex, CHAR_ABULLTIME, 0); + CHAR_setInt( toindex, CHAR_ABULLSTARTTIME, 0); + } + } + if( NPC_Util_GetStrFromStrWithDelim( buf1, "CHECKSCORE", buf2, sizeof( buf2) ) != NULL) { + if( strstr( buf2, "TRUE") != 0 ){ + if( CHAR_getInt( toindex, CHAR_ABULLSTART) != 20 && + CHAR_getInt( toindex, CHAR_ABULLSTART) == 10 ){ + int jointime, joindata, joinhr, ntime; + ntime = CHAR_getInt( toindex, CHAR_ABULLTIME); + jointime = CHAR_getInt( toindex, CHAR_ABULLSTARTTIME); + jointime = (int)time( NULL) - jointime; + + joindata = jointime/(24*60*60); + joinhr = (jointime%(24*60*60))/(60*60); + + + if( ntime < 0 ) ntime = 0; + sprintf( buf1, "战斗时间已累积%d分%d秒,活动累积积分:%d, 参与%d天%d小时。", + ntime/60, ntime%60, CHAR_getInt( toindex, CHAR_ABULLSCORE), + joindata, joinhr); + CHAR_talkToCli( toindex, -1, buf1, CHAR_COLORYELLOW); + } + } + } +#endif + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + //andy_add 2003/07/17 + if( NPC_Util_GetStrFromStrWithDelim( buf1, "AddPFSkillPoint", buf2, sizeof( buf2) ) != NULL) { + if( NPC_ActionAddProfessionSkillPoint( toindex, buf2 ) == FALSE ){ + return FALSE; + } + } + //andy_add 2003/07/17 + if( NPC_Util_GetStrFromStrWithDelim( buf1, "CleanProfession", buf2, sizeof( buf2) ) != NULL) { + if( NPC_ActionCleanProfession( toindex, buf2 ) == FALSE ){ + sprintf( buf2, "处理职业参数失败!!" ); + CHAR_talkToCli( toindex, -1, buf2, CHAR_COLORYELLOW); + return FALSE; + } + } + + if( NPC_Util_GetStrFromStrWithDelim( buf1, "PROFESSION", buf2, sizeof( buf2) ) != NULL) { + int p_class = atoi(buf2); + // 判断职业 + if( CHAR_getInt( toindex, PROFESSION_CLASS ) != PROFESSION_CLASS_NONE && (p_class != 0) ){ + sprintf( buf2, "你已经有职业了!!" ); + CHAR_talkToCli( toindex, -1, buf2, CHAR_COLORYELLOW); + return FALSE; + } + + if( p_class > PROFESSION_CLASS_NONE && p_class < PROFESSION_CLASS_NUM ) // 1:战士 2:巫师 3:猎人 + { + int i, value = 0; + int skill_id = -1; + + // 还原点数 + if( PROFESSION_RESTORE_POINT( toindex ) != 1 ) return FALSE; + + // 设定职业 + CHAR_setInt( toindex, PROFESSION_CLASS, p_class ); +#ifdef _CHANNEL_MODIFY + if(CHAR_getInt(toindex,PROFESSION_CLASS) > 0){ + int i,pclass = CHAR_getInt(toindex,PROFESSION_CLASS) - 1; + for(i=0;i 0){ + int i,pclass = CHAR_getInt(toindex,PROFESSION_CLASS) - 1; + for(i=0;i") != NULL ){ + strcat( Head, ">"); + flg = 1; + }else if( strstr( buf2, "<") != NULL ){ + strcat( Head, "<"); + flg = 2; + }else if( strstr( buf2, "!") != NULL ) { + strcat( Head, "!"); + flg = 5; + } + }else if(strstr( buf2, "<") != NULL){ + strcpy( Head, "<"); + flg = 4; + }else if(strstr( buf2, ">") != NULL){ + strcpy( Head, ">"); + flg = 3; + } + Head[ strlen( Head)+1] = 0; + if( NPC_Util_GetStrFromStrWithDelim( buf2, Head, buf3, sizeof( buf3) ) != NULL) { + if( flg == 0 ) + if( atoi(buf3) != partys ) return FALSE; + else if( flg == 1 ) + if( atoi(buf3) < partys ) return FALSE; + else if( flg == 2 ) + if( atoi(buf3) > partys ) return FALSE; + else if( flg == 3 ) + if( atoi(buf3) <= partys ) return FALSE; + else if( flg == 4 ) + if( atoi(buf3) >= partys ) return FALSE; + else if( flg == 5 ) + if( atoi(buf3) == partys ) return FALSE; + } + }*/ +#endif + + ActionNpc_WarpPoint( meindex, toindex, buf1); + return TRUE; +} +BOOL Action_PartyCheck( int meindex, int talker) +{ + if(CHAR_getWorkInt(talker,CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE){ + return FALSE; + } + return TRUE; +} + +BOOL NPC_ActionAddGold( int talker, int Golds) +{ + CHAR_AddGold( talker, Golds); + return TRUE; +} + +BOOL NPC_ActionDelGold( int talker,char *buf) +{ + int Golds=0; + int PGold=0; + if( buf == NULL ) return FALSE; + Golds = atoi( buf); + PGold = CHAR_getInt( talker, CHAR_GOLD); + if( PGold < Golds ) { + CHAR_talkToCli( talker, -1, "你身上的钱不够喔!", CHAR_COLORYELLOW); + return FALSE; + }else { + char buf1[256]; + sprintf( buf1, "交出%d石币", Golds); + CHAR_talkToCli( talker, -1, buf1, CHAR_COLORYELLOW); + } + CHAR_setInt( talker, CHAR_GOLD, PGold-Golds); + CHAR_send_P_StatusString( talker , CHAR_P_STRING_GOLD); + return TRUE; +} + +// WON ADD +BOOL NPC_ActionAddGold2( int talker,char *buf) +{ + int Golds=0; + int PGold=0; + int MaxGold = 0; + int total_gold = 0; + if( buf == NULL ) return FALSE; + Golds = atoi( buf); + PGold = CHAR_getInt( talker, CHAR_GOLD); + MaxGold = CHAR_getMaxHaveGold( talker ); + + total_gold = PGold + Golds; + if( total_gold > MaxGold ) total_gold = MaxGold; + + CHAR_setInt( talker, CHAR_GOLD, total_gold ); + CHAR_send_P_StatusString( talker , CHAR_P_STRING_GOLD); + return TRUE; +} + +BOOL NPC_ActionDelPet( int talker, char *buf) +{ + int petsel; + int petindex=0, k=1; + int fd = getfdFromCharaIndex( talker ); + char msgbuf[64], szPet[128],buff2[256],buff3[256]; + char buf2[256],buff1[256]; + int defpet; + int petno,kNum,find=0,petLv=0,flg=-1; + + while( getStringFromIndexWithDelim(buf , "," , k, buff1, sizeof( buff1)) !=FALSE ) { + k++; + if( strstr( buff1,"-") != NULL ) { + getStringFromIndexWithDelim(buff1,"-",2,buff3,sizeof(buff3)); + getStringFromIndexWithDelim(buff1,"-",1,buf2,sizeof(buf2)); + + if( strstr( buf2,"!") != NULL ) { + flg = 0; + getStringFromIndexWithDelim(buf2,"!=",2,buff2,sizeof(buff2)); + }else if( strstr( buf,"<") != NULL ) { + flg = 1; + getStringFromIndexWithDelim(buf2,"<",2,buff2,sizeof(buff2)); + }else if( strstr( buf,">") != NULL ) { + flg = 2; + getStringFromIndexWithDelim(buf2,">",2,buff2,sizeof(buff2)); + }else if( strstr( buf,"=") != NULL) { + flg = 3; + getStringFromIndexWithDelim(buf2,"=",2,buff2,sizeof(buff2)); + }else + return FALSE; + petLv = atoi( buff2); + } + continue; + + if(strstr(buff3,"*")!=NULL){ + getStringFromIndexWithDelim(buff3,"*",1,buf2,sizeof(buf2)); + petno = atoi(buf2); + getStringFromIndexWithDelim(buff3,"*",2,buf2,sizeof(buf2)); + kNum = atoi(buf2); + }else { + petno = atoi( buff3); + kNum = 30; + } + //andy_log + print("petno:%d kNum:%d \n ", petno, kNum); + + find =0; + + for(petsel=0 ; petsel < CHAR_MAXPETHAVE ; petsel++) { + petindex = CHAR_getCharPet( talker, petsel); + if( !CHAR_CHECKINDEX(petindex)) continue; + if(CHAR_getInt( petindex, CHAR_PETID) != petno )continue; + + switch( flg) { + case 0: + if( CHAR_getInt( petindex, CHAR_LV ) != petLv ) { + }else { + continue; + } + break; + case 1: + if( CHAR_getInt( petindex, CHAR_LV ) < petLv ) { + }else { + continue; + } + break; + case 2: + if( CHAR_getInt( petindex, CHAR_LV ) > petLv ) { + }else { + continue; + } + break; + case 3: + if( CHAR_getInt( petindex, CHAR_LV ) != petLv )continue; + break; + } + + petindex = CHAR_getCharPet( talker, petsel); + if( !CHAR_CHECKINDEX(petindex) ) + continue; + if( CHAR_getWorkInt( CONNECT_getCharaindex( fd), CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE ) + continue; + defpet = CHAR_getInt( talker, CHAR_DEFAULTPET); + + if(defpet == petsel) { + CHAR_setInt( talker, CHAR_DEFAULTPET, -1); + lssproto_KS_send( fd, -1, TRUE); + } + + snprintf( msgbuf,sizeof( msgbuf), "交出%s。", CHAR_getChar( petindex, CHAR_NAME)); + CHAR_talkToCli( talker, -1, msgbuf, CHAR_COLORYELLOW); + LogPet( + CHAR_getChar( talker, CHAR_NAME ), + CHAR_getChar( talker, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "TenseiDel", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + CHAR_setCharPet( talker, petsel, -1); + CHAR_endCharOneArray( petindex ); + snprintf( szPet, sizeof( szPet ), "K%d", petsel); + CHAR_sendStatusString( talker, szPet ); + + find++; + if( find >= kNum ) + break; //条件数目皆删除完 + } + } + + return TRUE; +} + +#ifdef _NPC_NewDelPet +BOOL NPC_ActionNewDelPet( int toindex, char *msg) +{ + int i,petindex=0,petlev,petnum,petcount,mypetlevel,petid; + char buf[32],buf2[32]; + int flg=0,count=0; + + //比较方式 + if ( strstr( msg, "=" ) ) + flg = 0; + else if( strstr( msg, "<" ) ) + flg = 1; + else + flg = 2; + + //等级 + if ( getStringFromIndexWithDelim( msg, "-", 1, buf, sizeof( buf )) ){ + char cmp[12]; + if( flg == 0 ) + strcpy(cmp,"="); + else if( flg == 1 ) + strcpy(cmp,"<"); + else + strcpy(cmp,">"); + if ( getStringFromIndexWithDelim( buf, cmp, 2, buf2, sizeof( buf2 )) ){ + petlev = atoi(buf2); + } + else + return FALSE; + } + else + return FALSE; + + //宠物编号 + if ( getStringFromIndexWithDelim( msg, "-", 2, buf, sizeof( buf )) ){ + if ( getStringFromIndexWithDelim( buf, "*", 1, buf2, sizeof( buf2 )) ){ + petnum = atoi( buf2 ); + } + else + return FALSE; + } + else + return FALSE; + + //数量 + if ( getStringFromIndexWithDelim( msg, "-", 2, buf, sizeof( buf )) ){ + if ( getStringFromIndexWithDelim( buf, "*", 2, buf2, sizeof( buf2 )) ){ + petcount = atoi( buf2 ); + } + else + return FALSE; + } + else + return FALSE; + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + BOOL cmp=FALSE; + petindex = CHAR_getCharPet( toindex, i); + petid = CHAR_getInt( petindex, CHAR_PETID); + mypetlevel = CHAR_getInt( petindex, CHAR_LV); + + if( flg == 0 ) + if( mypetlevel == petlev ) cmp = TRUE; + if( flg == 1 ) + if( mypetlevel < petlev ) cmp = TRUE; + if( flg == 2 ) + if( mypetlevel > petlev ) cmp = TRUE; + + if( petnum == petid && cmp ){//删除宠物 + char szPet[128]; + int defpet; + char msgbuf[64]; + int fd = getfdFromCharaIndex( toindex ); + + if( !CHAR_CHECKINDEX(petindex) ) return FALSE; + + if( CHAR_getInt( toindex, CHAR_RIDEPET) == i ) { + + //CHAR_talkToCli( talker, -1, "骑乘中的宠物无法交出!", CHAR_COLORYELLOW ); + //return FALSE; + + CHAR_setInt( toindex, CHAR_RIDEPET, -1); + CHAR_send_P_StatusString( toindex, CHAR_P_STRING_RIDEPET ); + CHAR_complianceParameter( toindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( toindex , CHAR_WORKOBJINDEX )); + } + + //公及平乓仿互爵 卅日}矢永玄毛丹日内蔽 + if( CHAR_getWorkInt( CONNECT_getCharaindex( fd ), CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) + return FALSE; + //及矢永玄互田玄伙井升丹井及民尼永弁 + defpet = CHAR_getInt( toindex, CHAR_DEFAULTPET); + if(defpet == i){ + CHAR_setInt( toindex, CHAR_DEFAULTPET, -1); + lssproto_KS_send( fd, -1, TRUE); + } + + snprintf( msgbuf,sizeof( msgbuf), "交出%s。", + CHAR_getChar( petindex, CHAR_NAME)); + CHAR_talkToCli( toindex, -1, msgbuf, CHAR_COLORWHITE); + + // 矢永玄毛澎 仄凶夫弘 + LogPet( CHAR_getChar( toindex, CHAR_NAME ), // 平乓仿 + CHAR_getChar( toindex, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "EvnetDell(任务删除)", + CHAR_getInt( toindex,CHAR_FLOOR), + CHAR_getInt( toindex,CHAR_X ), + CHAR_getInt( toindex,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + + + // 切 井日壅允 + CHAR_setCharPet( toindex, i, -1); + + CHAR_endCharOneArray( petindex ); + + snprintf( szPet, sizeof( szPet ), "K%d", i); + // 蕙仄中矢永玄旦 □正旦霜曰勾仃月 + CHAR_sendStatusString( toindex, szPet ); + + ++count; + if( count >= petcount ) + break; + } + } + + return TRUE; +} +#endif + +BOOL NPC_ActionAddPet( int talker, char *buf) +{ + int ret; + char msgbuf[64], buff3[256]; + int enemynum; + int i,j,k=1; + int petindex, petindex2, petid; + + k=1; + while( getStringFromIndexWithDelim(buf , "," , k, buff3, sizeof(buff3)) !=FALSE ){ + k++; + //检查宠物栏是否有空位 + for( i = 0 ;i < CHAR_MAXPETHAVE ; i++) { + petindex = CHAR_getCharPet( talker, i); + if( petindex == -1 ) + break; + } + + if( i == CHAR_MAXPETHAVE ) { + snprintf( msgbuf,sizeof( msgbuf), "宠物已满!!"); + CHAR_talkToCli( talker, -1, msgbuf, CHAR_COLORYELLOW); + return FALSE; + } + + petid = atoi( buff3); + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID ) == petid ) + //if( ENEMY_getInt( i, ENEMY_TEMPNO ) == petid ) + break; + } + + if( i == enemynum ) + continue; + + ret = ENEMY_createPetFromEnemyIndex( talker, i); + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + if( CHAR_getCharPet( talker, i ) == ret ) + break; + } + if( i == CHAR_MAXPETHAVE ) + i = 0; + if( CHAR_CHECKINDEX( ret ) == TRUE ){ + CHAR_setMaxExpFromLevel( ret, CHAR_getInt( ret, CHAR_LV )); + } + + petindex2 = CHAR_getCharPet(talker, i); + if( !CHAR_CHECKINDEX( petindex2) ) + continue; + snprintf( msgbuf,sizeof( msgbuf), "拿到%s。", CHAR_getChar(petindex2,CHAR_NAME)); + CHAR_talkToCli( talker, -1, msgbuf, CHAR_COLORYELLOW); + for(j = 0; j < CHAR_MAXPETHAVE; j++){ + petindex = CHAR_getCharPet(talker, j); + if( !CHAR_CHECKINDEX( petindex) ) + continue; + CHAR_complianceParameter( petindex ); + snprintf( msgbuf, sizeof( msgbuf ), "K%d", j ); + CHAR_sendStatusString( talker, msgbuf ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d", j ); + CHAR_sendStatusString( talker, msgbuf ); + } + + LogPet( + CHAR_getChar( talker, CHAR_NAME ), + CHAR_getChar( talker, CHAR_CDKEY ), + CHAR_getChar( petindex2, CHAR_NAME), + CHAR_getInt( petindex2, CHAR_LV), + "TenseiGet", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + CHAR_getChar( petindex2, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + } + return TRUE; +} + +#ifdef _ITEM_PILENUMS +BOOL NPC_DelItem( int toindex, int ti, int num) +{ + int itemindex, pilenum; + + itemindex = CHAR_getItemIndex( toindex , ti); + if( !ITEM_CHECKINDEX(itemindex) ) return FALSE; + pilenum = ITEM_getInt( itemindex, ITEM_USEPILENUMS); + if( pilenum < num ) return FALSE; + + pilenum = pilenum - num; + if( pilenum <= 0 ){ + { + LogItem( + CHAR_getChar( toindex, CHAR_NAME ), + CHAR_getChar( toindex, CHAR_CDKEY ), +#ifdef _add_item_log_name + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), +#endif + "Sell(卖道具)", + CHAR_getInt( toindex,CHAR_FLOOR), + CHAR_getInt( toindex,CHAR_X ), + CHAR_getInt( toindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + + ); + } + CHAR_setItemIndex( toindex, ti, -1); + ITEM_endExistItemsOne( itemindex); + }else{ + ITEM_setInt( itemindex, ITEM_USEPILENUMS, pilenum); + } + CHAR_sendItemDataOne( toindex, ti); + return TRUE; +} + + +void NPC_ActionDoPileClearItem( int toindex, int itemID) +{ + int i, itemindex; + char token[256]; + + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE ; i++ ){ + itemindex = CHAR_getItemIndex( toindex , i ); + if( !ITEM_CHECKINDEX(itemindex) ) continue; + if( ITEM_getInt(itemindex, ITEM_ID) != itemID ) continue; + sprintf( token, "交出道具%s",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( toindex, -1, token, CHAR_COLORYELLOW); + + LogItem( + CHAR_getChar( toindex, CHAR_NAME ), + CHAR_getChar( toindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), +#endif + "任务收取", + CHAR_getInt( toindex,CHAR_FLOOR), + CHAR_getInt( toindex,CHAR_X ), + CHAR_getInt( toindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + + ); + CHAR_setItemIndex( toindex, i, -1); + ITEM_endExistItemsOne( itemindex); + CHAR_sendItemDataOne( toindex, i); + } +} + +BOOL NPC_ActionDoPileDelItem( int toindex, int itemID, int num) +{ + int i, itemindex, finditem=0, pilenum=0, onenum=0; + char token[256]; + + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE && (finditem= (num-finditem) ){ + pilenum -= (num-finditem); + onenum += (num-finditem); + }else { + onenum = pilenum; + pilenum=0; + } + finditem += onenum; + + ITEM_setInt( itemindex, ITEM_USEPILENUMS, pilenum); + sprintf( token, "交出%d个%s", onenum, ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( toindex, -1, token, CHAR_COLORYELLOW); + if( pilenum <= 0 ){ + LogItem( + CHAR_getChar( toindex, CHAR_NAME ), + CHAR_getChar( toindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), +#endif + "任务收取", + CHAR_getInt( toindex,CHAR_FLOOR), + CHAR_getInt( toindex,CHAR_X ), + CHAR_getInt( toindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + + ); + + + CHAR_setItemIndex( toindex, i, -1); + ITEM_endExistItemsOne( itemindex); + } + CHAR_sendItemDataOne( toindex, i); + } + + if( finditem != num && num != -1 ) return FALSE; + return TRUE; +} + +BOOL NPC_ActionDelItem( int talker, char *buf) +{ + char buff3[128], buf2[32]; + int k=1, itemid, neednum; + if( !CHAR_CHECKINDEX( talker) ) return FALSE; + while( getStringFromIndexWithDelim(buf , "," , k++, buff3, sizeof(buff3)) !=FALSE ) { + neednum = 1; + if( getStringFromIndexWithDelim( buff3, "*", 1, buf2, sizeof(buf2)) == FALSE ) continue; + itemid = atoi( buf2); + if( getStringFromIndexWithDelim( buff3, "*", 2, buf2, sizeof(buf2)) == TRUE ){ + neednum = atoi( buf2); + if( NPC_ActionDoPileDelItem( talker, itemid, neednum) == FALSE ) return FALSE; + }else{ + NPC_ActionDoPileClearItem( talker, itemid); + } + } + return TRUE; +} +#else +BOOL NPC_ActionDelItem( int talker, char *buf) +{ + int i = 1, j = 1,k = 1; + char buff3[128]; + char buf2[32]; + int itemindex; + char token[256]; + + if( !CHAR_CHECKINDEX( talker) ) return FALSE; + while( getStringFromIndexWithDelim(buf , "," , k, buff3, sizeof(buff3)) !=FALSE ) { + k++; + if(strstr(buff3,"*")!=NULL){ + int itemno, kosuu=0, id, cnt=0; + struct _tagItemArray { + int index; + int itemindex; + }; + struct _tagItemArray ItemArray[20]; + for( i=0; i<20 ; i++){ + ItemArray[i].itemindex = -1; + ItemArray[i].index = -1; + } + //取得字串 + getStringFromIndexWithDelim(buff3,"*",1,buf2,sizeof(buf2)); + itemno = atoi(buf2); + getStringFromIndexWithDelim(buff3,"*",2,buf2,sizeof(buf2)); + kosuu = atoi(buf2); + //取得 item index + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE ; i++ ){ + itemindex=CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX(itemindex) ){ + id=ITEM_getInt(itemindex ,ITEM_ID ); + if(itemno==id){ + ItemArray[cnt].itemindex = itemindex; + ItemArray[cnt].index = i; + cnt++; + } + } + if(cnt == kosuu) + break; + } + if(cnt != kosuu){ + CHAR_talkToCli( talker, -1,"条件不足", CHAR_COLORYELLOW); + return FALSE; + } + //收取物品 + for( i=0; i<20; i++) { + itemindex = ItemArray[i].itemindex; + if( !ITEM_CHECKINDEX(itemindex) ) break; + sprintf(token,"交出%s",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORYELLOW); + CHAR_setItemIndex( talker, ItemArray[i].index ,-1); + ITEM_endExistItemsOne( itemindex); + CHAR_sendItemDataOne( talker, ItemArray[i].index); + LogItem( + CHAR_getChar( talker, CHAR_NAME ), CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), +#endif + "WarpManDelItem", + CHAR_getInt( talker, CHAR_FLOOR), CHAR_getInt( talker, CHAR_X ), + CHAR_getInt( talker, CHAR_Y ), ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + }else{ + for( j = CHAR_STARTITEMARRAY ; j < CHAR_MAXITEMHAVE ; j++){ + itemindex = CHAR_getItemIndex( talker ,j); + if( ITEM_CHECKINDEX(itemindex) ){ + if( atoi( buff3) == ITEM_getInt(itemindex,ITEM_ID)){ + LogItem( + CHAR_getChar( talker, CHAR_NAME ), + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), +#endif + "WarpManDelItem", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + + ); + sprintf( token, "交出%s。", + ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORYELLOW); + CHAR_DelItem( talker, j); + } + } + } + } + } + return TRUE; +} +#endif + + + +BOOL NPC_ActionAddItem( int talker, char *buf) +{ + int itemID,k=0,itemindex=-1; + int spaceNum=5,i; + char buff3[256], msgbuf[64], token[256]; + int ret; + + k=1; + while( getStringFromIndexWithDelim(buf , "," , k, buff3, sizeof(buff3)) !=FALSE ){ + k++; + for( i = spaceNum ; i < CHAR_MAXITEMHAVE ; i++ ){ + itemindex=CHAR_getItemIndex( talker , i ); + if( itemindex == -1 ) { + spaceNum = i+1; + break; + } + } + if( i == CHAR_MAXITEMHAVE ) { + snprintf( msgbuf,sizeof( msgbuf), "物品栏空间不足!!"); + CHAR_talkToCli( talker, -1, msgbuf, CHAR_COLORYELLOW); + return FALSE; + } + } + k=1; + while( getStringFromIndexWithDelim(buf , "," , k, buff3, sizeof(buff3)) !=FALSE ){ + k++; + itemID = atoi( buff3); + if( itemID ) + itemindex = ITEM_makeItemAndRegist( itemID); + if(itemindex == -1) + continue; + ret = CHAR_addItemSpecificItemIndex( talker, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + ITEM_endExistItemsOne( itemindex); + print ("\n ret error!!"); + return FALSE; + } + + sprintf( token,"拿到%s",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORYELLOW ); + CHAR_sendItemDataOne( talker, ret); + } + + return TRUE; +} + +BOOL NPC_ActionSetEend( int talkerindex, char * buf) +{ + int eveno; + int talkNo=1, iflg=0; + char buf1[256]; + + while( getStringFromIndexWithDelim( buf,",",talkNo,buf1,sizeof( buf1)) != FALSE) { + talkNo++; + eveno = atoi( buf); + NPC_EventSetFlg( talkerindex, eveno); + if( ++iflg > 20 ) break; + } + return TRUE; +} + +BOOL NPC_ActionClearEvent( int toindex, char * buf) +{ + int eveno; + int talkNo=1, iflg=0; + char buf1[256]; + + while( getStringFromIndexWithDelim( buf,",",talkNo,buf1,sizeof( buf1)) != FALSE) { + talkNo++; + eveno = atoi( buf); + NPC_NowEndEventSetFlgCls( toindex, eveno); + if( ++iflg > 20 ) break; + } + return TRUE; +} + +BOOL NPC_ActionSetNow( int toindex, char * buf) +{ + int eveno; + int talkNo=1, iflg=0; + char buf1[256]; + + while( getStringFromIndexWithDelim( buf,",",talkNo,buf1,sizeof( buf1)) != FALSE) { + talkNo++; + eveno = atoi( buf); + NPC_NowEventSetFlg( toindex, eveno); + if( ++iflg > 20 ) break; + } + return TRUE; +} + + +BOOL NPC_ActionPassCheck( int meindex, int talker, 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(NPC_ActionBigSmallCheck( meindex, talker, buff3)==FALSE) { + loop=1; + break; + } + } + if(loop==0) { + CHAR_setWorkInt( talker, CHAR_WORKWARPCHECK, TRUE ); + return TRUE; + } + }else{ + if( NPC_ActionBigSmallCheck( meindex, talker, buff2) == TRUE){ + CHAR_setWorkInt( talker, CHAR_WORKWARPCHECK, TRUE ); + return TRUE; + + } + } + } + CHAR_setWorkInt( talker, CHAR_WORKWARPCHECK, FALSE ); + return FALSE; + +} + +BOOL NPC_ActionBigSmallCheck(int meindex,int talker,char* buf) +{ + + char buff2[128], buff3[128]; + int kosuu,temp=-1,flg=0; + +#ifdef _NEW_WARPMAN + char buff1[128]; + if(strstr( buf, "-") != NULL) { + getStringFromIndexWithDelim( buf, "-", 2, buff3, sizeof(buff3)); + temp = atoi( buff3); + getStringFromIndexWithDelim( buf, "-", 1, buff1, sizeof(buff1)); + strcpy( buf, buff1); + } +#endif + + if( strstr( buf, "<") != NULL ){ + getStringFromIndexWithDelim( buf, "<", 2, buff3, sizeof(buff2)); + kosuu = atoi( buff3); + getStringFromIndexWithDelim( buf, "<", 1, buff2, sizeof(buff2)); + + if( NPC_ActionFreeIfCheck( meindex, talker, buff2, buff3, kosuu, 1, temp)==TRUE){ + return TRUE; + } + }else if(strstr( buf, ">") != NULL){ + getStringFromIndexWithDelim( buf, ">", 2, buff3, sizeof(buff2)); + kosuu = atoi(buff3); + getStringFromIndexWithDelim( buf, ">" ,1, buff2, sizeof(buff2)); + + if( NPC_ActionFreeIfCheck( meindex, talker, buff2, buff3, kosuu, 2, temp) == TRUE ){ + return TRUE; + } + + }else if( strstr( buf, "!" ) != NULL){ + getStringFromIndexWithDelim( buf, "!=", 2, buff3, sizeof(buff2)); + kosuu = atoi( buff3); + getStringFromIndexWithDelim( buf, "!=", 1, buff2, sizeof(buff2)); + if( NPC_ActionFreeIfCheck( meindex, talker, buff2, buff3, kosuu, 0, temp) == TRUE ){ + return FALSE; + }else{ + return TRUE; + } + }else if( strstr( buf, "=") != NULL){ + getStringFromIndexWithDelim( buf, "=", 2, buff3, sizeof(buff2)); + kosuu = atoi( buff3); + getStringFromIndexWithDelim( buf, "=", 1, buff2, sizeof(buff2)); + flg = 0; + if( strstr( buf, "*") != NULL){ + if( NPC_ActionWarpManReduce( meindex, talker, buf)==TRUE){ + return TRUE; + } + } +#ifdef _NPC_ActionFreeCmp + else if( strstr( buf, "^") != NULL){ + if( NPC_ActionWarpManReduce2( meindex, talker, buf)==TRUE){ + return TRUE; + } + } +#endif + else if( NPC_ActionFreeIfCheck( meindex, talker, buff2, buff3, kosuu, flg, temp) == TRUE ) { + return TRUE; + } + } + return FALSE; +} + +#ifdef _NPC_ActionFreeCmp +//其实功能和原本的NPC_ActionWarpManReduce差不多,但为了不影响以前的设定,所以不去修改原本的 +BOOL NPC_ActionWarpManReduce2(int meindex,int talker,char *buf) +{ + char buf2[512]; + char buf3[256]; + int i, itemindex, itemno, kosuu; + int id=0; + int nums = 0; + + getStringFromIndexWithDelim(buf,"=",2,buf2,sizeof(buf2)); + getStringFromIndexWithDelim(buf2,"^",1,buf3,sizeof(buf3)); + itemno = atoi(buf3); + getStringFromIndexWithDelim(buf2,"^",2,buf3,sizeof(buf3)); + kosuu = atoi(buf3); + + for( i=CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE;i++ ){ + itemindex=CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX(itemindex) ){ + id=ITEM_getInt(itemindex ,ITEM_ID ); + if( itemno == id ){ + nums += ITEM_getInt( itemindex, ITEM_USEPILENUMS);//数量 + } + } + } + + if( nums == kosuu ) return TRUE; + + return FALSE; +} +#endif + +#ifdef _NEW_MANOR_LAW +extern struct FM_POINTLIST fmpointlist; +#endif + +BOOL NPC_ActionFreeIfCheck(int meindex,int talker, char* buf, char *opt, int kosuu,int flg, int temp) +{ + if(strcmp(buf,"LV")==0){ + if(NPC_ActionLevelCheck(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } + if(strcmp(buf,"GOLD")==0){ + print("\n GOLD"); + if(NPC_ActionGoldCheck(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } + if( strcmp(buf,"TRANS") == 0 ) { + if( NPC_ActionCheckTrans( meindex, talker, kosuu, flg) == TRUE ) + return TRUE; + } + + if( !strcmp( buf, "GTIME") ){ + if( NPC_CheckTimeDefine( opt) == TRUE ) + return TRUE; + } + + if(strcmp( buf, "TIME") == 0) { + if(NPC_TiemCheck( meindex, talker, kosuu, flg) == TRUE) + return TRUE; + } + + if( strcmp( buf, "PET") == 0 ) { + if( temp > 0 ) { + if( ActionCheckMyPet( meindex, talker, kosuu, flg, temp) == TRUE ) + return TRUE; + }else + return FALSE; + } + if(strcmp(buf,"ITEM")==0){ + if(NPC_ActionItemCheck(meindex,talker,kosuu, flg)==TRUE) + return TRUE; + } + + if(strcmp(buf,"EQUIT")==0){ + if(NPC_ActioneEquitCheck(meindex,talker,kosuu, flg)==TRUE) + return TRUE; + } + + if( !strcmp(buf,"ENDEV") || !strcmp(buf,"EVEND") ){ + if(NPC_EventCheckFlg( talker, kosuu)==TRUE) + return TRUE; + } + if( !strcmp(buf,"NOWEV") || !strcmp(buf,"EVNOW") ){ + if(NPC_NowEventCheckFlg( talker, kosuu)==TRUE) + return TRUE; + } + + if(strcmp(buf,"PARTY")==0){ + if(NPC_ActionPartyCheck( talker, kosuu, flg)==TRUE) + return TRUE; + } + if(strcmp(buf,"reITEM")==0){ + if( NPC_ActionReItemCheck( talker, kosuu, flg)==TRUE) + return TRUE; + } + if(strcmp(buf,"rePET")==0){ + if( NPC_ActionRePetCheck( talker, kosuu, flg)==TRUE) + return TRUE; + } +#ifdef _ACTION_GMQUE + if( strcmp( buf, "GMFLG") == 0 ) { + if( CheckGmQueflg( talker, kosuu, flg) == TRUE ) + return TRUE; + } + if( strcmp( buf, "GMCHECK") == 0 ){ + if( GMQUE_CheckQueStr( meindex, talker, kosuu) == TRUE ){ + return TRUE; + } + } +#endif +#ifdef _NPCCHANGE_PLAYERIMG + if(strcmp( buf, "BBI")==0) { + if( NPC_CheckPlayerBBI( meindex, talker, kosuu, flg)== TRUE) { + return TRUE; + } + } +#endif + if( strcmp( buf, "FM") == 0 ){ + if( CHAR_getInt( talker, CHAR_FMLEADERFLAG ) > 0 && + CHAR_getInt( talker, CHAR_FMLEADERFLAG ) != FMMEMBER_APPLY) + if( CHAR_getWorkInt( talker, CHAR_WORKFMFLOOR) == kosuu ){ + return TRUE; + } + } + if(strcmp(buf,"DR")==0){ + if(NPC_ActionDuelRankCheck(meindex,talker,kosuu,flg)==TRUE){ + return TRUE; + } + } + if(strcmp(buf,"DP")==0){ + if(NPC_ActionDuelPointCheck(meindex,talker,kosuu,flg)==TRUE){ + return TRUE; + } + } + +#ifdef _ACTION_BULLSCR + if( strcmp( buf, "ABSCO") == 0 ) { + if( NPC_ActionCheckABullscore( meindex, talker, kosuu, flg) == TRUE ) + return TRUE; + } + if( strcmp( buf, "ABSTART") == 0 ) { + if( NPC_ActionCheckABullstart( meindex, talker, kosuu, flg) == TRUE ) + return TRUE; + } + if( strcmp( buf, "ABTIME") == 0 ) { + if( NPC_ActionCheckABulltime( meindex, talker, kosuu, flg) == TRUE ) + return TRUE; + } + if( strcmp( buf, "ABEVENT") == 0 ) { + if( NPC_ActionCheckABullEvent( meindex, talker) == TRUE ) + return TRUE; + } +#endif + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + if( strcmp( buf, "CLASS") == 0 ){ + if(NPC_ActionClassCheck(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } + if( strcmp( buf, "Skill") == 0 ){ + if( NPC_ActionSkillCheck( meindex, talker, kosuu, flg)==TRUE) + return TRUE; + } + if( strcmp( buf, "SkNum") == 0 ){ + if( NPC_ActionSkillNumCheck( meindex, talker, kosuu, flg)==TRUE) + return TRUE; + } + if( strcmp( buf, "SKCP") == 0 ){ + if( NPC_ActionSkillPointAndSkillCheck( meindex, talker, kosuu, flg)==TRUE) + return TRUE; + } +#endif + + +#ifdef _TREASURE_BOX + if( strcmp( buf, "BOX") == 0 ){ + if( NPC_ActionTreasureTypeCheck( meindex, kosuu, + //NPC_TIME_EVENTMODE = CHAR_NPCWORKINT6,// 1 + CHAR_getWorkInt( meindex, CHAR_NPCWORKINT6) ,flg)==TRUE) + return TRUE; + } +#endif + +#ifdef _NPC_ADDWARPMAN1 + if( strcmp( buf, "PARTYCOUNT") == 0){ + if(NPC_ActionPartyCountCheck( talker, kosuu, flg)==TRUE) + return TRUE; + } + if( strcmp( buf, "MANCOUNT" ) == 0 ){ + if(NPC_ActionManCountCheck( talker, kosuu, flg ) == TRUE ) + return TRUE; + } + if( strcmp( buf, "WOMANCOUNT" ) == 0 ){ + if(NPC_ActionWomanCountCheck( talker, kosuu, flg ) == TRUE ) + return TRUE; + } +#endif + +#ifdef _ANGEL_SUMMON + if(strcmp(buf,"ANGEL_NOW")==0){ + if( NPC_ActionMissionAngelCheck(meindex,talker,kosuu, MISSION_DOING, 0)==TRUE) + return TRUE; + } + if(strcmp(buf,"HERO_NOW")==0){ + if( NPC_ActionMissionHeroCheck(meindex,talker,kosuu, MISSION_DOING, 0)==TRUE) + return TRUE; + } + if(strcmp(buf,"ANGEL_OVER")==0){ + if( NPC_ActionMissionAngelCheck(meindex,talker,kosuu, MISSION_HERO_COMPLETE, 0)==TRUE) + return TRUE; + } + if(strcmp(buf,"HERO_OVER")==0){ + if( NPC_ActionMissionHeroCheck(meindex,talker,kosuu, MISSION_HERO_COMPLETE, 0)==TRUE) + return TRUE; + } + if(strcmp(buf,"ANGEL_OUT")==0){ + if( NPC_ActionMissionAngelCheck(meindex,talker,kosuu, MISSION_TIMEOVER, 0)==TRUE) + return TRUE; + } + if(strcmp(buf,"HERO_OUT")==0){ + if( NPC_ActionMissionHeroCheck(meindex,talker,kosuu, MISSION_TIMEOVER, 0)==TRUE) + return TRUE; + } + + if(strcmp(buf,"ANGEL_I_NOW")==0){ + if( NPC_ActionMissionAngelCheck(meindex,talker,kosuu, MISSION_DOING, TRUE)==TRUE) + return TRUE; + } + if(strcmp(buf,"HERO_I_NOW")==0){ + if( NPC_ActionMissionHeroCheck(meindex,talker,kosuu, MISSION_DOING, TRUE)==TRUE) + return TRUE; + } + if(strcmp(buf,"ANGEL_I_OVER")==0){ + if( NPC_ActionMissionAngelCheck(meindex,talker,kosuu, MISSION_HERO_COMPLETE, TRUE)==TRUE) + return TRUE; + } + if(strcmp(buf,"HERO_I_OVER")==0){ + if( NPC_ActionMissionHeroCheck(meindex,talker,kosuu, MISSION_HERO_COMPLETE, TRUE)==TRUE) + return TRUE; + } + if(strcmp(buf,"ANGEL_I_OUT")==0){ + if( NPC_ActionMissionAngelCheck(meindex,talker,kosuu, MISSION_TIMEOVER, TRUE)==TRUE) + return TRUE; + } + if(strcmp(buf,"HERO_I_OUT")==0){ + if( NPC_ActionMissionHeroCheck(meindex,talker,kosuu, MISSION_TIMEOVER, TRUE)==TRUE) + return TRUE; + } + if(strcmp( buf, "HEROCNT") == 0) { + //if(NPC_EventLevelCheck( meindex, talker, kosuu, flg) == TRUE) { + if(NPC_HeroCompleteCountCheck( meindex, talker, kosuu, flg) == TRUE) + return TRUE; + } + +#endif +#ifdef _NEW_MANOR_LAW + if(strcmp(buf,"MANOR") == 0){ + // 大於-1表示要检查是否为庄园家族成员才能warp + if(kosuu > -1){ + int iFmIndex = -1,iHadFmindex = -1; + char token[256]; + + iFmIndex = CHAR_getInt(talker,CHAR_FMINDEX); + getStringFromIndexWithDelim(fmpointlist.pointlistarray[kosuu],"|",5,token,sizeof(token)); + iHadFmindex = atoi(token); + if(iFmIndex > -1){ + // 是庄园拥有家族的成员 + if(iFmIndex == iHadFmindex){ + // 必须有家族且是正式族员 + if(CHAR_getInt(talker,CHAR_FMLEADERFLAG) != FMMEMBER_NONE && + CHAR_getInt(talker,CHAR_FMLEADERFLAG) != FMMEMBER_APPLY) return TRUE; + } + } + } + } +#endif + + return FALSE; +} + +BOOL NPC_ActioneEquitCheck(int meindex,int talker,int itemNo, int flg) +{ + int i; + int itemindex=-1; + int id; + for( i=0;i point1) + return TRUE; + } + + return FALSE; +} + +BOOL ActionCheckMyPet( int meindex, int talker, int petLv, int flg, int petid) +{ + int petsel,petindex=-1; + int lv=-1; + for(petsel=0 ; petsel < CHAR_MAXPETHAVE ; petsel++) { + petindex = CHAR_getCharPet( talker, petsel); + if( petindex == -1 ) + continue; + if(CHAR_getInt( petindex, CHAR_PETID) != petid ) + continue; + break; + } + if( petsel == CHAR_MAXPETHAVE ) { + return FALSE; + }else { //找到条件宠 + lv = CHAR_getInt( petindex, CHAR_LV); + if( NPC_ActionBigSmallLastCheck( petLv, lv, flg) == TRUE) { + return TRUE; + }else { + return FALSE; + } + } + return FALSE; +} + + +BOOL NPC_ActionCheckTrans(int meindex,int talker,int trans,int flg) +{ + int myTrans; + myTrans=CHAR_getInt(talker, CHAR_TRANSMIGRATION); + if( NPC_ActionBigSmallLastCheck( trans, myTrans, flg ) == TRUE ) { + return TRUE; + } + return FALSE; +} + +BOOL NPC_ActionLevelCheck(int meindex,int talker,int level,int flg) +{ + int mylevel; + mylevel=CHAR_getInt(talker,CHAR_LV); + if(NPC_ActionBigSmallLastCheck( level, mylevel, flg) == TRUE){ + return TRUE; + } + return FALSE; +} + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 +BOOL NPC_ActionClassCheck(int meindex,int talker,int p_class,int flg) +{ + int myclass; + myclass= CHAR_getInt( talker, PROFESSION_CLASS ); + + if(NPC_ActionBigSmallLastCheck( p_class, myclass, flg) == TRUE){ + return TRUE; + } + return FALSE; +} + +BOOL NPC_ActionSkillPointAndSkillCheck( int meindex,int talker,int sknum,int flg) +{ + int myskillpoint, myskillnum=0, myskilllevel; + int mysknum=0, j; + myskillpoint= CHAR_getInt( talker, PROFESSION_SKILL_POINT ); + myskilllevel= CHAR_getInt( talker, PROFESSION_LEVEL ); + + for( j=0; jskill, 0, 0 ); + pSkil->use = 0; + } + }else if( !strcmp( buf2, "CLASS") ){ + if( getStringFromIndexWithDelim( buf1 , "=" , 2, buf2, sizeof( buf2)) ==FALSE ) continue; + if( strstr( buf2, "ALL") != NULL ){ + CHAR_setInt( toindex , PROFESSION_CLASS, 0); +#ifdef _CHANNEL_MODIFY + if(CHAR_getInt(toindex,PROFESSION_CLASS) > 0){ + int i,pclass = CHAR_getInt(toindex,PROFESSION_CLASS) - 1; + for(i=0;i= kosuu ) return TRUE; +#endif + + return FALSE; + +} + +#ifdef _NPCCHANGE_PLAYERIMG //andy +BOOL NPC_ActionChangePlayerBBI( int meindex, int charindex, char *Img) +{ + int cBBI; + char buf1[256]; + memset( buf1, 0, sizeof( buf1)); + if( !CHAR_CHECKINDEX( charindex) ) + return FALSE; + if( !CHAR_CHECKINDEX( meindex) ) + return FALSE; +#ifdef _FIXBUG_ATTACKBOW + { + int armtype; + int itemindex = CHAR_getItemIndex( charindex, CHAR_ARM); + if( ITEM_CHECKINDEX(itemindex) ){ + armtype = ITEM_getInt( itemindex, ITEM_TYPE ); + if( armtype == ITEM_BOW || armtype == ITEM_BOUNDTHROW || + armtype == ITEM_BREAKTHROW || armtype == ITEM_BOOMERANG) { + CHAR_talkToCli( charindex, -1, "使用远距离武器无法变身!", CHAR_COLORYELLOW ); + return FALSE; + } + } + + } +#endif +#ifdef _PETSKILL_BECOMEPIG + if( CHAR_getInt( charindex, CHAR_BECOMEPIG) > -1 ){//变成乌力了 + CHAR_talkToCli( charindex, -1, "无法变身,乌力化中不能变身!", CHAR_COLORYELLOW ); + return; + } +#endif + if( CHAR_getInt( charindex, CHAR_RIDEPET) != -1 ) {//骑宠不换图 + CHAR_setInt( charindex, CHAR_RIDEPET, -1 ); + BATTLE_changeRideImage( charindex ); + CHAR_talkToCli( charindex, -1, "取消骑宠状态。", CHAR_COLORYELLOW); + + //change -----> 修改bug(落马後,宠物选项的状态依然为"骑乘",这里修正过来 + CHAR_complianceParameter( charindex ); + CHAR_send_P_StatusString( charindex, CHAR_P_STRING_RIDEPET); + + //return FALSE; + } +#ifdef _ITEM_METAMO + CHAR_setWorkInt( charindex, CHAR_WORKITEMMETAMO, 0); +#endif + + if( Img == NULL || !strcmp( Img, "\0")) + return FALSE; +//======================= + CHAR_setWorkInt( charindex, CHAR_WORKNPCMETAMO, meindex); + if( strstr( Img, "NPCBBI") != NULL ) { + cBBI = CHAR_getInt( meindex, CHAR_BASEBASEIMAGENUMBER); + sprintf( buf1, "你化身成了%s的样子。", CHAR_getChar( meindex, CHAR_NAME)); + }else if( strstr( Img, "MYBBI") != NULL ) { + cBBI = CHAR_getInt( charindex, CHAR_BASEBASEIMAGENUMBER); + CHAR_setWorkInt( charindex, CHAR_WORKNPCMETAMO, 0); + sprintf( buf1, "变回了原来的样子。"); + }else if( strstr( Img, ",") != NULL ) { + int imgindex=1, maxImg=0; + while( getStringFromIndexWithDelim( Img, ",", imgindex, buf1, sizeof( buf1)) != FALSE ) { + imgindex++; + maxImg++; + } + if( (imgindex = (rand()%maxImg)) > maxImg) imgindex = 1; + if( imgindex < 1 ) imgindex = 1; + + if( getStringFromIndexWithDelim( Img, ",", imgindex, buf1, sizeof( buf1)) == FALSE ) + return FALSE; + cBBI = atoi( buf1); + sprintf( buf1, "你样子改变了。"); + }else { + cBBI = atoi( Img); + sprintf( buf1, "你样子改变了。"); + } +//======================= + if( cBBI < 0 ) { + return FALSE; + } + CHAR_talkToCli( charindex, -1, buf1, CHAR_COLORYELLOW); + //CHAR_BASEBASEIMAGENUMBER CHAR_BASEIMAGENUMBER + CHAR_setInt( charindex, CHAR_BASEIMAGENUMBER, cBBI); + CHAR_complianceParameter( charindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( charindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + //CHAR_K_STRING_BASEIMAGENUMBER + //CHAR_P_STRING_BASEBASEIMAGENUMBER + return TRUE; +} +#endif + +#ifdef _NPCCHANGE_PLAYERIMG +BOOL NPC_CheckPlayerBBI( int meindex, int charindex, int BBI, int flg) +{ + int MyBBI; + if( !CHAR_CHECKINDEX( charindex)) + return FALSE; + if( BBI < 0 ) + return FALSE; + MyBBI = CHAR_getInt( charindex, CHAR_BASEIMAGENUMBER); + return NPC_ActionBigSmallLastCheck( BBI, MyBBI,flg); +} +#endif + +BOOL showString( int meindex, char *showstr,int flg) +{ //广播 + char buf1[256]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + int toindex = -1; + int floor; + int i; + if( NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL ) { + print("\n not found argstr "); + return FALSE; + } + if( NPC_Util_GetStrFromStrWithDelim( argstr, showstr,buf1, sizeof(buf1)) == NULL ) { + strcpy( buf1, showstr); + } + toindex = -1; + floor = CHAR_getInt( meindex , CHAR_FLOOR); + while( toindex < 1000) { + toindex ++; + if( !CHAR_CHECKINDEX( toindex) ) + continue; + if( CHAR_getInt( toindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) + continue; + if( CHAR_getInt( toindex , CHAR_FLOOR) != floor ) + continue; + CHAR_talkToCli( toindex, meindex, buf1, CHAR_COLORYELLOW); + if( flg == 1 ) { + CHAR_setWorkInt( toindex, CHAR_WORKSTAKEFLAG, FALSE ); + for( i=0; i<5; i++) { + CHAR_setWorkInt( toindex, i+CHAR_WORKSTAKETYPE1, 0); + } + } + } + return TRUE; +} + +BOOL NPC_getTimeXYPoint( int meindex, int Mode) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[256], buf1[256], buf2[256]; + int fl=-1, x, y; + int GraNo = -1; + int points = 1; //条件成立为1 + if( Mode <= 0 ) { + points = 2; + } + memset( npcarg, 0, sizeof( npcarg)); + if( !CHAR_CHECKINDEX( meindex) ) return FALSE; + if( NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg)) == NULL ){ + print("WarpMan:GetArgStrErr"); + return FALSE; + } + memset( buf, 0, sizeof( buf)); + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "TimeXYPoint", buf, sizeof( buf)) != NULL ){ + if( getStringFromIndexWithDelim(buf , "&" , points, buf1, sizeof( buf1)) != FALSE ){ + memset( buf2, 0, sizeof( buf2)); + if( getStringFromIndexWithDelim(buf1 , "," , 1, buf2, sizeof( buf2)) == FALSE ){ + return FALSE; + } + fl = atoi( buf2); + if( getStringFromIndexWithDelim(buf1 , "," , 2, buf2, sizeof( buf2)) == FALSE ){ + return FALSE; + } + x = atoi( buf2); + if( getStringFromIndexWithDelim(buf1 , "," , 3, buf2, sizeof( buf2)) == FALSE ){ + return FALSE; + } + y = atoi( buf2); + if( MAP_IsValidCoordinate( fl, x, y ) == FALSE ){ + char filename[256]; + NPC_Util_CheckAssignArgFile( meindex, filename); + return FALSE; + } + if( CHAR_getInt( meindex, CHAR_FLOOR) != fl || + CHAR_getInt( meindex, CHAR_X) != x || + CHAR_getInt( meindex, CHAR_Y) != y ){ + CHAR_warpToSpecificPoint( meindex, fl , x , y); + } + } + } + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "GraNo", buf, sizeof( buf)) != NULL ){ + if( getStringFromIndexWithDelim(buf , "&" , points, buf1, sizeof( buf1)) != FALSE ){ + GraNo = atoi( buf1); + CHAR_setInt( meindex, CHAR_BASEIMAGENUMBER, GraNo); + } + } + return TRUE; +} + +BOOL NPC_getTimeData( int meindex, char *npcarg, int *born, int *dead, int loopspeed) +{ + int i; + char buf[256]; + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "NEWTIME", buf, sizeof( buf)) != NULL ){ + for(i=0 ; i<9 ; i++){ + if( strstr( buf, TimeTble[i].arg ) != NULL){ + *born = TimeTble[i].born; + *dead = TimeTble[i].dead; + return TRUE; + } + } + } + return FALSE; +} + +BOOL NPC_CheckTimeDefine( char *timetype) +{ + LSTIME nowlstime; + int born=-1, dead=-1, finds=0, i; + + RealTimeToLSTime( NowTime.tv_sec, &nowlstime); + + for(i=0 ; i<9 ; i++){ + if( strstr( timetype, TimeTble[i].arg ) != NULL){ + born = TimeTble[i].born; + dead = TimeTble[i].dead; + finds = 1; + break; + } + } + if( finds == 0 ) return FALSE; + + if( born < dead ){ + if( (born < nowlstime.hour) && (dead > nowlstime.hour) ){ + return TRUE; + } + }else{ + if( (born < nowlstime.hour && 1024 > nowlstime.hour) || + ( 0 < nowlstime.hour && dead > nowlstime.hour)){ + return TRUE; + } + } + + return FALSE; +} + +void NPC_TimeDefineDo( int meindex, int born, int dead, int typeMode) +{ + LSTIME nowlstime; + RealTimeToLSTime( NowTime.tv_sec, &nowlstime); + if(born < dead){ + if( (born < nowlstime.hour) && (dead > nowlstime.hour) ){ + CHAR_setWorkInt(meindex,typeMode,0); + }else{ + CHAR_setWorkInt(meindex,typeMode,1); + } + }else{ + if( (born < nowlstime.hour && 1024 > nowlstime.hour) || ( 0 < nowlstime.hour && dead > nowlstime.hour)){ + CHAR_setWorkInt(meindex,typeMode,0); + }else{ + CHAR_setWorkInt(meindex,typeMode,1); + } + } + if( NPC_getTimeXYPoint( meindex, CHAR_getWorkInt( meindex, typeMode)) == FALSE ) + return; +} + + +void GetRand_WarpPoint( char *buf, int *fl, int *x, int *y ) +{ + char buff1[256],buff2[256]; + int i=0,point=1; + struct { + int m_fl; + int m_x; + int m_y; + } RandPoint[]={ + {0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}, + {0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}, + {0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}, + {0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}, + }; + while( getStringFromIndexWithDelim( buf,";",point,buff1,sizeof( buff1)) != FALSE) { + point++; + getStringFromIndexWithDelim(buff1,",",1,buff2,sizeof(buff2)); + RandPoint[i].m_fl = atoi(buff2); + getStringFromIndexWithDelim(buff1,",",2,buff2,sizeof(buff2)); + RandPoint[i].m_x = atoi(buff2); + getStringFromIndexWithDelim(buff1,",",3,buff2,sizeof(buff2)); + RandPoint[i].m_y = atoi(buff2); + i++; + if( i >= arraysizeof( RandPoint) ) + break; + } + + point = RAND( 0, i); + if( RandPoint[point].m_fl <= 0 || point > arraysizeof( RandPoint) -1) { + point = 0; + } + *fl = RandPoint[point].m_fl; + *x = RandPoint[point].m_x; + *y = RandPoint[point].m_y; + + return; +} + +#ifdef _EMENY_CHANCEMAN +int NPC_EmenyChanceCheck( int meindex, int charaindex, char *arg) +{ + char buf1[256]; + int sex=2, fl=-1,x=-1,y=-1; + memset( buf1, 0, sizeof( buf1)); + + if( NPC_Util_GetStrFromStrWithDelim( arg, "CHECKSEX", buf1, sizeof( buf1)) == NULL ) { + return charaindex; + } + if( strstr( buf1, "male") != 0 ){ + sex = 1; + } + if( NPC_Util_GetStrFromStrWithDelim( arg, "NOBATTLEWARP", buf1, sizeof( buf1)) != NULL ) { + char data[256]; + if( getStringFromIndexWithDelim( buf1,",", 1, data, sizeof(data)) == FALSE ) return charaindex; + fl = atoi( data); + if( getStringFromIndexWithDelim( buf1,",", 2, data, sizeof(data)) == FALSE ) return charaindex; + x = atoi( data); + if( getStringFromIndexWithDelim( buf1,",", 3, data, sizeof(data)) == FALSE ) return charaindex; + y = atoi( data); + } + return NPC_DischargePartyForSex( meindex, charaindex, fl, x, y, sex); +} + +int NPC_DischargePartyForSex( int meindex, int charaindex, int fl, int x, int y, int fsex) +{ + int Party[CHAR_PARTYMAX] = {-1,-1,-1,-1,-1}; + int masterindex =-1, i, j, playerNo; + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_LEADER ){ + playerNo = CHAR_getInt( charaindex, CHAR_BASEBASEIMAGENUMBER); + if( CHAR_getSexInt( playerNo ) == fsex ) { + if( MAP_IsValidCoordinate( fl, x, y) != FALSE ){ + CHAR_warpToSpecificPoint( charaindex, fl, x, y); + return -1; + } + }else { + return charaindex; + } + } + CHAR_talkToCli( charaindex, -1, "团队重组!", CHAR_COLORYELLOW); + + for( i = 0; i < CHAR_PARTYMAX; i ++ ) { + int index = CHAR_getWorkInt( charaindex, CHAR_WORKPARTYINDEX1+i); + if( !CHAR_CHECKINDEX( index)) continue; + Party[i] = index;//纪录所有人 + } + CHAR_DischargePartyNoMsg( charaindex);//解散团队 + + for( i = 0; i < CHAR_PARTYMAX; i ++ ) { + int index = Party[i]; + playerNo = CHAR_getInt( index, CHAR_BASEBASEIMAGENUMBER); + if( CHAR_getSexInt( playerNo ) == fsex ) { + if( MAP_IsValidCoordinate( fl, x, y) != FALSE ){ + CHAR_warpToSpecificPoint( index, fl, x, y); + } + Party[i] = -1; + } + } + j = CHAR_WORKPARTYINDEX1; + for( i = 0; i < CHAR_PARTYMAX; i ++ ) { + int index = Party[i]; + if( !CHAR_CHECKINDEX( index ))continue; + if( !CHAR_CHECKINDEX( masterindex )){ + masterindex = index; + CHAR_setWorkInt( masterindex, CHAR_WORKPARTYMODE, CHAR_PARTY_LEADER); + CHAR_setWorkInt( masterindex, j++, masterindex); + }else { + CHAR_setWorkInt( masterindex, j++, index); + CHAR_setWorkInt( index, CHAR_WORKPARTYMODE, CHAR_PARTY_CLIENT); + CHAR_setWorkInt( index, CHAR_WORKPARTYINDEX1, masterindex); + } + } + return masterindex; +} +#endif + +#ifdef _ACTION_GMQUE +BOOL GMQUE_InSertQue( int meindex, int charaindex) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + int maxque, i, j, event; + char buf1[256],buf2[256],page[512], token[256]; +#define RAND(x,y) ((x-1)+1+ (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) ) + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr"); + return FALSE; + } + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "RANDGMQUE", buf1, sizeof( buf1) ) == NULL) + return FALSE; + maxque = atoi( buf1); + + memset( token, 0, sizeof( token)); + for( i=0; i= CHAR_MAXPETHAVE ){ + snprintf( buf1,sizeof( buf1), "人物身上并没有%s LV:%d。", ENEMYTEMP_getChar( array, E_T_NAME), lvarr); + CHAR_talkToCli( charaindex, -1, buf1, CHAR_COLORYELLOW); + return FALSE; + } + } + if( CHAR_getInt( charaindex, CHAR_GMQUENUMS) <= 0 ){ + int GMQUEACTION = rand()%100; + GMQUEACTION = (GMQUEACTION<1)?1:GMQUEACTION; + CHAR_setInt( charaindex, CHAR_GMQUENUMS, GMQUEACTION); + } + + if( CHAR_getInt( charaindex, CHAR_GMQUENUMS) > 97 ){//pet + }else if( CHAR_getInt( charaindex, CHAR_GMQUENUMS) > 40 ){//item + if( CHAR_findEmptyItemBox( charaindex ) == -1 ){ + CHAR_talkToCli( charaindex, -1, "身上物品栏位已满,无法领奖。", CHAR_COLORYELLOW); + return FALSE; + } + }else {//gold + if( CHAR_getInt( charaindex, CHAR_GOLD) >= 800000 ){ + CHAR_talkToCli( charaindex, -1, "身上石币大於等於80万,无法领奖。", CHAR_COLORYELLOW); + return FALSE; + } + } + + if( count != petset ){ + sprintf( buf1,"找到%d只符合条件的宠,但需要%d只。", petset, count); + CHAR_talkToCli( charaindex, -1, buf1, CHAR_COLORYELLOW); + return FALSE; + } + return TRUE; +} + +BOOL GMQUE_DelQueStrPet( int meindex, int charaindex, int count) +{ + int i, j, k=0, petset=0; + char buf1[256], buf2[256]; + int array; + int petarray[5]={-1,-1,-1,-1,-1}; + char *bufarg = NULL; + + bufarg = CHAR_getChar( charaindex, CHAR_GMQUESTR1); + if( bufarg == NULL ) return FALSE; + for( i=0; i<4; i++) { + int petTempNo, lvarr; + if( getStringFromIndexWithDelim( bufarg, "&", i+1, buf1, sizeof(buf1)) == FALSE ) + continue; + if( getStringFromIndexWithDelim( buf1, "-", 1, buf2, sizeof(buf2)) == FALSE ) + return FALSE; +// petTempNo = ENEMY_getEnemyTempNoFromId( atoi( buf2)); + petTempNo = atoi( buf2); + array = ENEMYTEMP_getEnemyTempArrayFromTempNo( petTempNo); + if( getStringFromIndexWithDelim( buf1, "-", 2, buf2, sizeof(buf2)) == FALSE ) + return FALSE; + lvarr = atoi( buf2); + for( j=0; j= CHAR_MAXPETHAVE ){ + snprintf( buf1,sizeof( buf1), "找不到%s LV:%d。", ENEMYTEMP_getChar( array, ENEMY_NAME), lvarr); + CHAR_talkToCli( charaindex, -1, buf1, CHAR_COLORYELLOW); + return FALSE; + } + } + for( i=0; i<5; i++) { //杀宠 + char szPet[256]; + int pindex = -1; + if( petarray[i] == -1 ) break; + pindex = CHAR_getCharPet( charaindex, petarray[i]); + if( !CHAR_CHECKINDEX( pindex) ) continue; + if( CHAR_getInt( charaindex, CHAR_DEFAULTPET) == petarray[i] ) { + CHAR_setInt( charaindex, CHAR_DEFAULTPET, -1); + lssproto_KS_send( getfdFromCharaIndex( charaindex), -1, TRUE); + } + snprintf( szPet,sizeof( szPet), "交出%s。", CHAR_getChar( pindex, CHAR_NAME)); + CHAR_talkToCli( charaindex, -1, szPet, CHAR_COLORYELLOW); + CHAR_setCharPet( charaindex, petarray[i], -1); + CHAR_endCharOneArray( pindex ); + snprintf( szPet, sizeof( szPet ), "K%d", petarray[i]); + CHAR_sendStatusString( charaindex, szPet ); + petset++; + } + if( count != petset ) return FALSE; + return TRUE; +} + +BOOL GMQUE_AddQueStrTrophy( int meindex, int charaindex) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + int array, rands=0; + int petID[4]={1642,1636,475}; + + int itemID1[9]={ 20131, 20594, 20171, 17005, 20210, 20211, 20212, 20213, 2435};//道具 + int itemID2[6]={ 17759, 17259, 14752, 15053, 14154, 16556}; + int itemID3[2]={ 20282, 20273}; + int itemID4[8]={ 14693, 15233, 17053, 17056, 14364, 15023, 15562, 17603}; + int itemID5[8]={ 3843, 14902, 6214, 15235, 4474, 17005, 17554, 17558}; + + int Gold[5]={ 20000, 50000, 100000, 150000, 200000}; + char token[256]; +#define RAND(x,y) ((x-1)+1+ (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) ) + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr"); + return FALSE; + } + rands = CHAR_getInt( charaindex, CHAR_GMQUENUMS); + if( rands > 97 ){//pet + int ret, i; + rands = RAND(0,3); + array = ENEMY_getEnemyArrayFromId( petID[rands]); + ret = ENEMY_createPetFromEnemyIndex( charaindex, array); + if( !CHAR_CHECKINDEX( ret )) return FALSE; + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + if( CHAR_getCharPet( charaindex, i ) == ret ) + break; + } + if( i == CHAR_MAXPETHAVE ) return FALSE; + if( CHAR_CHECKINDEX( ret ) == TRUE ){ + CHAR_setMaxExpFromLevel( ret, CHAR_getInt( ret, CHAR_LV )); + } + snprintf( token,sizeof( token), "拿到%s。", CHAR_getChar( ret, CHAR_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + CHAR_complianceParameter( ret ); + snprintf( token, sizeof( token ), "K%d", i ); + CHAR_sendStatusString( charaindex, token ); + snprintf( token, sizeof( token ), "W%d", i ); + CHAR_sendStatusString( charaindex, token ); + }else if( rands > 40 ){//item + int itemindex=-1, ret; + rands = RAND(0,100); + if( rands == 0 ){ + itemindex = ITEM_makeItemAndRegist( itemID3[ RAND(0,1)]); + }else if( rands >= 97 ){ + itemindex = ITEM_makeItemAndRegist( itemID2[ RAND(0,5)]); + }else if( rands >= 70){ + itemindex = ITEM_makeItemAndRegist( itemID4[ RAND(0,7)]); + }else if( rands >= 40){ + itemindex = ITEM_makeItemAndRegist( itemID5[ RAND(0,7)]); + }else { + itemindex = ITEM_makeItemAndRegist( itemID1[ RAND(0,8)]); + } + if(itemindex == -1) return FALSE; + ret = CHAR_addItemSpecificItemIndex( charaindex, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + ITEM_endExistItemsOne( itemindex); + return FALSE; + } + sprintf( token,"拿到%s",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW ); + CHAR_sendItemDataOne( charaindex, ret); + }else {//石币 + int Golds=0; + rands = RAND(0,30); + if( rands >= 15 ){ + Golds = Gold[0]; + }else if( rands >= 10 ){ + Golds = Gold[1]; + }else{ + rands = RAND(2,4); + Golds = Gold[rands]; + } + CHAR_AddGold( charaindex, Golds); + } + GMQUE_cleanQueStr( charaindex); + return TRUE; +} + +BOOL CheckGmQueflg( int talker,int nCount,int flg) +{ + int myGmflg; + myGmflg = CHAR_getInt(talker, CHAR_GMQUEFLG); + if( NPC_ActionBigSmallLastCheck( nCount, myGmflg, flg ) == TRUE ) { + return TRUE; + } + return FALSE; +} +#endif + +BOOL NPC_ActionDuelRankCheck(int meindex,int talker,int rank,int flg) +{ + int myrank; + myrank=CHAR_getWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC); + if( NPC_ActionBigSmallLastCheck( rank, myrank, flg)==TRUE){ + return TRUE; + } + + return FALSE; +} + +BOOL NPC_ActionDuelPointCheck(int meindex,int talker,int rank,int flg) +{ + int myduel; + myduel = CHAR_getInt( talker, CHAR_DUELPOINT); + if( NPC_ActionBigSmallLastCheck( rank, myduel, flg)==TRUE){ + return TRUE; + } + + return FALSE; +} + +#ifdef _ACTION_BULLSCR//CheckABulltime +BOOL NPC_ActionCheckABulltime( int meindex,int talker,int nCount,int flg) +{ + int ntime, nowtime, dntime; + ntime = CHAR_getInt(talker, CHAR_ABULLSTARTTIME); + nowtime = (int)time( NULL); + dntime = (nowtime - ntime); + + nCount = (nCount*24)*(60*60);//换算成秒数 + if( NPC_ActionBigSmallLastCheck( nCount, dntime, flg ) == TRUE ) { + return TRUE; + } + return FALSE; +} + +BOOL NPC_ActionCheckABullstart( int meindex,int talker,int start,int flg) +{ + int myStart; + myStart = CHAR_getInt(talker, CHAR_ABULLSTART); + if( NPC_ActionBigSmallLastCheck( start, myStart, flg ) == TRUE ) { + return TRUE; + } + return FALSE; +} +BOOL NPC_ActionCheckABullscore( int meindex,int talker,int score,int flg) +{ + int myScore; + myScore = CHAR_getInt(talker, CHAR_ABULLSCORE); + if( NPC_ActionBigSmallLastCheck( score, myScore, flg ) == TRUE ) { + return TRUE; + } + return FALSE; +} + +BOOL NPC_ActionCheckABullEvent( int meindex, int talker) +{ + int i; + int Event[12]={12, 38, 22, 17, 32, 33, 34, 30, 31, 64, 81, 111}; + //NPC_NowEventCheckFlg + char Eventarg[12][256]={ + "梦德洞窟任务", "马祖任务", "强恩一族", "龙穴任务", "梦幻洞窟", "梦幻洞窟", "梦幻洞窟", + "黄金羚羊", "五兄弟之谜", "四圣石任务", "金飞任务", "火灵勇士任务" }; + + for( i=0; i<12; i++){ + if( NPC_EventCheckFlg( talker, Event[i]) == FALSE ){ + char token[256]; + sprintf( token, "你尚未完成[%s]。", Eventarg[i] ); + CHAR_talkToCli( talker, -1, token, CHAR_COLORYELLOW); + return FALSE; + } + } + + return TRUE; +} +#endif + +BOOL NPC_ActionTreasureTypeCheck(int meindex,int level, int type, int flg) +{ + int mylevel; + +// if( CHAR_getWorkInt( meindex, NPC_TIME_EVENTMODE) == NPC_EVENTMODE_EVENT ){ + mylevel = (type == NPC_EVENTMODE_EVENT)?1:0; + if( NPC_ActionBigSmallLastCheck( level, mylevel, flg)==TRUE) + return TRUE; + return FALSE; +} + +BOOL NPC_ActionTreasureRandItemGet(int meidex,int talker,int rand_j,char *buf) +{ + char buff2[64]; + int randitem; + int ret; + int itemindex; + char token[128]; + + if(rand_j == 0) { + print("Event:由於0的介入,出现错误。"); + return FALSE; + } + + randitem = rand()%rand_j; + if(randitem == 0) randitem = rand_j; + + getStringFromIndexWithDelim(buf , "," , randitem, buff2, sizeof(buff2)) ; + + itemindex = ITEM_makeItemAndRegist( atoi( buff2)); + + if(itemindex == -1) return FALSE; + + /*失奶 丞及馨笛( 涛失奶 丞 卞中木化仄引丹 */ + ret = CHAR_addItemSpecificItemIndex( talker, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + print( "npc_exchangeman.c: additem error itemindex[%d]\n", itemindex); + ITEM_endExistItemsOne( itemindex); + return FALSE; + } + + if(itemindex != -1) { + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), /* 失奶 丞 寞 */ +#endif + "EventAddItem(任务需求所得到的道具)", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + + sprintf(token,"收下了%s",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + + CHAR_sendItemDataOne( talker, ret); + return TRUE; + +} + +#ifdef _NPC_ADDLEVELUP // (不可开) ANDY 外部测试机用来增加玩家等级 +extern tagRidePetTable ridePetTable[296]; +void NPC_ActionLevelAndTransUp( int meindex, int charindex, int level, int skillpoint, int exp, int ridepet) +{ + char szBuffer[256]=""; + if( !CHAR_CHECKINDEX( charindex) ) + return; +//int CHAR_LevelUpCheck( int charaindex , int toindex) + if( exp > 0 ){ + int LevelUp=0; + int myexp = CHAR_getInt( charindex, CHAR_EXP); + myexp += exp; + if( myexp > 300000000 ) myexp = 300000000; + CHAR_setInt( charindex, CHAR_EXP, myexp); + snprintf( szBuffer, sizeof(szBuffer), + "(%s) 得到 EXP %d", CHAR_getUseName( charindex ), exp); + CHAR_talkToCli( charindex, -1, szBuffer, CHAR_COLORYELLOW); + LevelUp = CHAR_LevelUpCheck( charindex , -1); + if( LevelUp > 0 ){ + snprintf( szBuffer, sizeof(szBuffer), + "(%s) 升级至 %d", + CHAR_getUseName( charindex ), + CHAR_getInt( charindex, CHAR_LV ) + ); + CHAR_talkToCli( charindex, -1, szBuffer, CHAR_COLORYELLOW); + CHAR_setInt( charindex, CHAR_SKILLUPPOINT, + CHAR_getInt( charindex, CHAR_SKILLUPPOINT) + LevelUp*3 ); + CHAR_complianceParameter( charindex ); + } + } + + if( level > 0 ){ + CHAR_setInt( charindex, CHAR_LV, level); + snprintf( szBuffer, sizeof(szBuffer), + "(%s) 等级设定为 %d", + CHAR_getUseName( charindex ), CHAR_getInt( charindex, CHAR_LV ) + ); + CHAR_talkToCli( charindex, -1, szBuffer, CHAR_COLORYELLOW); + } + + if( skillpoint > 0 ){ + int MySp = CHAR_getInt( charindex, CHAR_SKILLUPPOINT); + MySp += skillpoint; + CHAR_setInt( charindex, CHAR_SKILLUPPOINT, MySp); + } + if( ridepet >= 0 ){ + int basepet[2][4]={ {2066,2067,2068,2069}, + {2072,2073,2074,2075}}; + int petTemp[]={-1,-1,-1,-1,-1}; + char msgbuf[256]; + int petNum=0; + int i,j=0; + int k=0, petindex,enemyarray; + petTemp[j++] = basepet[0][rand()%4]; + petTemp[j++] = basepet[1][rand()%4]; + + for( i=0; i< arraysizeof(ridePetTable) ; i++ ){ + if( CHAR_getInt( charindex, CHAR_BASEBASEIMAGENUMBER) == ridePetTable[i].charNo ){ + petTemp[j]= ridePetTable[i].petId; + j++; + if( j >= arraysizeof( petTemp) ) + break; + } + } + j=0; + for( petNum=0; petNum= CHAR_MAXITEMHAVE ) + return FALSE; + } + return TRUE; +} + +BOOL NPC_ActionMissionHeroCheck(int meindex,int talker,int mission,int flg,int checkitem) +{ + int mindex; + char nameinfo[64]; + int i, itemindex, itemid; + + mindex = checkIfAngel( talker); + if( mindex <= -1 ) return FALSE; + if( missiontable[mindex].mission != mission) return FALSE; + getMissionNameInfo( talker, nameinfo); + if( strcmp( nameinfo, missiontable[mindex].heroinfo )) return FALSE; + if( missiontable[mindex].flag != flg ) return FALSE; + + if( checkitem ) { // 有无信物 + for( i=CHAR_STARTITEMARRAY;i= CHAR_MAXITEMHAVE ) + return FALSE; + } + + return TRUE; +} + + +BOOL NPC_HeroCompleteCountCheck(int meindex,int talker,int count,int flg) +{ + + int herocnt; + herocnt = CHAR_getInt(talker,CHAR_HEROCNT); + + if(NPC_EventBigSmallLastCheck( count, herocnt, flg) == TRUE) + { + if(flg == 3) return FALSE; + return TRUE; + } + + if(flg == 3) return TRUE; + return FALSE; + +} + + + +#endif diff --git a/gmsv/npc/npc_exchangeman.c b/gmsv/npc/npc_exchangeman.c new file mode 100644 index 0000000..5fe99eb --- /dev/null +++ b/gmsv/npc/npc_exchangeman.c @@ -0,0 +1,4348 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "net.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "npc_exchangeman.h" +#include "npc_eventaction.h" +#include "log.h" +#include "battle.h" +#include "handletime.h" +#include "enemy.h" +#include "npc_warp.h" + +static void NPC_ExChangeMan_selectWindow( int meindex, int talker,int num); +BOOL NPC_TypeCheck(int meindex,int talker,char *szMes); +int NPC_ExChangeManEventCheck( int meindex, int talker, char *buff1); +BOOL NPC_EventItemCheck(int meindex,int talker,int itemNo,int flg); +BOOL NPC_EventLevelCheck(int meindex,int talker,int level,int flg); +// Arminius 8.14 move to .h (for pet talk) +//BOOL NPC_EventBigSmallCheck(int meindex,int talker,char* buf); +BOOL NPC_EventFreeIfCheck(int meindex,int talker,char* buf,int kosuu,int flg); +BOOL NPC_EventBigSmallLastCheck(int point1,int mypoint,int flg); +BOOL NPC_ENDEventNoCheck(int meindex,int talker,int shiftbit,int flg); +BOOL NPC_NOWEventNoCheck(int meindex,int talker,int shiftbit,int flg); +BOOL NPC_TiemCheck(int meindex,int talker,int time,int flg); +BOOL NPC_EventAddPet(int meindex, int talker, char *buff2,int mode); +BOOL NPC_RandItemGet(int meindex, int talker,int rand_j,char *buf); + +BOOL NPC_PetLvCheckType2(int petindex,int meindex,int talker,char *buf,int mode); +BOOL NPC_PetLvCheck(int meindex,int talker,char *buf,int mode); +void NPC_RequestMain(int meindex,int talker,char *buf); +void NPC_AcceptMain(int meindex,int talker ,char*buf); +void NPC_MsgDisp(int meindex,int talker,int num); +BOOL NPC_EventAdd(int meindex,int talker,int mode); +BOOL NPC_AcceptDel(int meindex,int talker,int mode); +BOOL NPC_SavePointCheck(int meindex,int talker,int shiftbit,int flg); + +BOOL NPC_EventReduce(int meindex,int talker,char *buf); +BOOL NPC_EventDelItem(int meindex,int talker,char *buf,int breakflg); +BOOL NPC_EventDelItemEVDEL(int meindex,int talker,char *buf,char *nbuf,int breakflg); +BOOL NPC_EventAddItem(int meindex,int talker,char *buf); +int NPC_EventFile(int meindex,int talker,char *buf); +BOOL NPC_EventDelPet(int meindex,int talker, int petsel); +void NPC_PetSkillMakeStr(int meindex,int toindex,int select); +void NPC_CleanMain(int meindex,int talker,char *buf); +void NPC_EventPetSkill( int meindex, int talker, char *data); +BOOL NPC_ItemFullCheck(int meindex,int talker,char *buf,int mode,int evcnt); +void NPC_CharmStatus(int meindex,int talker); +BOOL NPC_ImageCheck(int meindex,int talker,int kosuu,int flg); +int NPC_EventGetCost(int meindex,int talker,char *arg); + +BOOL NPC_EventWarpNpc(int meindex,char *buf); + + +enum { + CHAR_WORK_EVENTWARP = CHAR_NPCWORKINT4, + +}; + +/********************************* +* 赓渝质 +*********************************/ +BOOL NPC_ExChangeManInit( int meindex ) +{ + + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024*2]; + int i = 1; + char buf4[256]; + + CHAR_setWorkInt(meindex,CHAR_WORK_EVENTWARP,1); + +#if 0 + char buf2[512]; + char buf3[256]; + int j=1; + int nameflg=0; + int itemno; + char *ret; + char sendbuf[2][10]={"无法传送。","可以传送。"}; + char droplogbuf[2][10]={"没消失。","消失了。"}; + int flg=0; +#endif + + + /*--NPC及正奶皿毛本永玄允月--*/ + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEEVENT ); + + + /*--涩烂白央奶伙毛 心 心--*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL) { + print("NPC_ExChange.c TypeCheck: GetArgStrErr\n"); + print("NPCName=%s\n", CHAR_getChar( meindex ,CHAR_NAME)); + return FALSE; + } + + i = 1; + /*--奶矛件玄NPC互健丹失奶 丞毛民尼永弁允月--*/ + /*--民尼永弁嫩 } 午仄化壅尹月井"}矢永玄丢□伙匹霜木月井"--*/ + while(getStringFromIndexWithDelim( argstr ,"EventEnd" ,i ,buf ,sizeof(buf)) + != FALSE) + { + i++; + /*--仇仇匹踏井木化中月及反}伐□瓦件弘毛请允-*/ + if(strstr( buf,"GetItem") != NULL) { + if(strstr( buf,"ItemFullMsg") == NULL) { + NPC_Util_GetStrFromStrWithDelim(buf,"EventNo",buf4,sizeof(buf4)); + print("\n### EventNo=%d %s:ItemFullMsg 脱离###", + atoi( buf4), + CHAR_getChar( meindex, CHAR_NAME)); + } + } + + if(strstr( buf,"GetPet") != NULL) { + if(strstr( buf,"PetFullMsg") == NULL) { + NPC_Util_GetStrFromStrWithDelim(buf,"EventNo",buf4,sizeof(buf4)); + print("\n### ventNo=%d %s:PetFullMsg 脱离 ###", + atoi(buf4), + CHAR_getChar(meindex,CHAR_NAME)); + } + } + + if(strstr( buf,"GetEgg") != NULL) { + if(strstr( buf,"PetFullMsg") == NULL) { + NPC_Util_GetStrFromStrWithDelim(buf,"EventNo",buf4,sizeof(buf4)); + print("\n### ventNo=%d %s:PetFullMsg 脱离 ###", + atoi(buf4), + CHAR_getChar(meindex,CHAR_NAME)); + } + } + + if(strstr( buf,"GetStone") != NULL){ + if(strstr( buf,"StoneFullMsg") == NULL){ + NPC_Util_GetStrFromStrWithDelim(buf,"EventNo",buf4,sizeof(buf4)); + print("\n### EventNo=%d %s:StonFullMsg 脱离 ###", + atoi( buf4), + CHAR_getChar( meindex, CHAR_NAME)); + } + } + + if(strstr( buf,"DelStone") != NULL) { + if(strstr( buf,"StoneLessMsg") == NULL) { + NPC_Util_GetStrFromStrWithDelim(buf,"EventNo",buf4,sizeof(buf4)); + print("\n### EventNo=%d %s:StoneLessMsg 脱离 ###", + atoi(buf4), + CHAR_getChar(meindex,CHAR_NAME)); + } + } + } + + + i = 1; + +#if 0 + /*--奶矛件玄NPC互健丹失奶 丞毛民尼永弁允月--*/ + /*--民尼永弁嫩 } 午仄化壅尹月井"}矢永玄丢□伙匹霜木月井"--*/ + while(getStringFromIndexWithDelim( argstr ,"EventEnd" ,i ,buf ,sizeof(buf)) + !=FALSE) + { + i++; + /*--仇仇匹踏井木化中月及反}伐□瓦件弘毛请允-*/ + if(NPC_Util_GetStrFromStrWithDelim( buf,"GetItem", buf2,sizeof( buf2)) + !=NULL) + { + j=1; + flg=0; + while(getStringFromIndexWithDelim( buf2,",", j, buf3, sizeof(buf3)) + !=FALSE) + { + j++; + if(strstr( buf2, "*")!=NULL){ + getStringFromIndexWithDelim( buf3 ,"*" ,1, buf4 ,sizeof(buf4)); + itemno = atoi(buf4); + }else{ + /*--失奶 丞瓜件田□必永玄--*/ + itemno = atoi(buf3); + } + + ret=NPC_Util_GetStrFromStrWithDelim( buf,"NoWarning", buf4,sizeof(buf4)); + if(ret != NULL){ + char buff[8]; + int k=1; + + while(getStringFromIndexWithDelim( buf4,"," ,k ,buff, sizeof(buff)) + !=FALSE){ + k++; + if(itemno == atoi(buff)) + { + flg=1; + break; + } + } + } + + if(flg == 0){ + if( (itemno >=2400 && itemno < 3000) &&( + (ITEM_getdropatlogoutFromITEMtabl(itemno) == 1) + || (ITEM_getvanishatdropFromITEMtabl(itemno) == 1) + || (ITEM_getcanpetmailFromITEMtabl(itemno) == 0)) + ){ + if(nameflg==0){ + print("\n%s",CHAR_getChar( meindex ,CHAR_NAME)); + nameflg=1; + } + print("\nID:%-5d,Logout:%-8s,DropCls:%-8s,SendMail:%-8s,%-16s", + itemno, + droplogbuf[ITEM_getdropatlogoutFromITEMtabl(itemno)], + droplogbuf[ITEM_getvanishatdropFromITEMtabl(itemno)], + sendbuf[ITEM_getcanpetmailFromITEMtabl(itemno)], + ITEM_getNameFromNumber(itemno) + ); + } + } + + } + } + + } +#endif + return TRUE; + +} + +/*-- 及啖 --*/ +BOOL NPC_EventWarpNpc(int meindex,char *buf) +{ + char token[32]; + char buf2[32]; + int floor,x,y; + int ret; + int cnt; + int dcnt = 1; + + /*--蜇箕及伐□皿及赐 --*/ + cnt = CHAR_getWorkInt(meindex,CHAR_WORK_EVENTWARP); + while(getStringFromIndexWithDelim(buf,",", dcnt,buf2,sizeof(buf2) ) + !=FALSE ){ + dcnt++; + } + + if(dcnt <= cnt) cnt=1; + + + while(getStringFromIndexWithDelim(buf,",", cnt,buf2,sizeof(buf2)) !=FALSE ) + { + cnt++; + ret=getStringFromIndexWithDelim(buf2,".", 1,token,sizeof(token)); + if( ret == FALSE ) { + continue; + } + floor = atoi( token ); + + ret=getStringFromIndexWithDelim(buf2,".", 2,token,sizeof(token)); + if( ret == FALSE ){ + continue; + } + x = atoi( token ); + + ret=getStringFromIndexWithDelim(buf2,".", 3,token,sizeof(token)); + if( ret == FALSE ) { + continue; + } + y = atoi( token ); + + CHAR_setWorkInt(meindex,CHAR_WORK_EVENTWARP, cnt); + CHAR_warpToSpecificPoint(meindex, floor, x, y); + return TRUE; + } + + return FALSE; + +} + + +/********************************* +* 仄井仃日木凶凛及质 +*********************************/ +void NPC_ExChangeManTalked( int meindex , int talkerindex , char *szMes ,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); + CHAR_setWorkInt( talkerindex ,CHAR_WORKSHOPRELEVANTSEC, 0); + CHAR_setWorkInt( talkerindex ,CHAR_WORKSHOPRELEVANTTRD, 0); + + /*--正奶皿 卞坌仃月--*/ + NPC_TypeCheck( meindex, talkerindex, szMes); + +} + +/*------------------------------------------------------------ + *涩烂白央奶伙毛 心 心}椭瘀互丐匀凶正奶皿及质 毛允月 + *-------------------------------------------------------------*/ +BOOL NPC_TypeCheck(int meindex,int talker,char *szMes) +{ + + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024*2]; + char buf2[512]; + int i = 1; + int EvNo; + int evch; + + /*--涩烂白央奶伙毛 心 心--*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("NPC_ExChange.c TypeCheck: GetArgStrErr\n"); + print("NPCName=%s\n", CHAR_getChar(meindex,CHAR_NAME)); + return FALSE; + } + + /*-- 涩烂白央奶伙毛坌喃允月 --*/ + while(getStringFromIndexWithDelim( argstr,"EventEnd",i,buf,sizeof( buf)) + != FALSE){ + i++; + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANT, 0); + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTSEC, 0); + + /*-- 奶矛件玄瓜件田□毛必永玄 --*/ + if(NPC_Util_GetStrFromStrWithDelim(buf,"EventNo", + buf2, sizeof( buf2) ) == NULL) continue; + + if(strstr( buf2, "-") != 0) { + EvNo = -1; + }else{ + EvNo = atoi( buf2); + } + + /*-- 白仿弘民尼永弁毛垫丹[允匹卞奶矛件玄互蔽 仄化中月桦宁反戚尺 --*/ + if(NPC_EventCheckFlg( talker, EvNo) == TRUE) continue; + + /*--平□伐□玉及民尼永弁毛垫丹--*/ + if(NPC_Util_GetStrFromStrWithDelim( buf,"KeyWord", buf2,sizeof( buf2) ) + != NULL){ + if(strcmp( szMes, buf2) != 0) continue; + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANT, i); + } + + /*--矢永玄及 蟆及民尼永弁互 匀化月井毛民尼永弁--*/ + if(NPC_Util_GetStrFromStrWithDelim( buf,"Pet_Name", buf2,sizeof( buf2)) != NULL){ + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTSEC, 1); + } + evch = NPC_ExChangeManEventCheck( meindex, talker, buf); + if(evch != -1) { + if(NPC_Util_GetStrFromStrWithDelim( buf,"TYPE", buf2, sizeof( buf2)) != NULL){ + + if( strstr( buf2, "REQUEST") != NULL) { + NPC_RequestMain( meindex, talker, buf); + return TRUE; + }else if( strstr( buf2, "ACCEPT") != NULL) { + /*-匙 毛熬仃午月 --*/ + NPC_AcceptMain( meindex, talker, buf); + return TRUE; + + }else if(strstr( buf2, "MESSAGE") != NULL) { + char token[14*100]; + char token2[14*50]; + if(NPC_Util_GetStrFromStrWithDelim( buf,"NomalMsg", token,sizeof( token) ) + != NULL ) { + if(NPC_AcceptDel( meindex, talker, 0) == FALSE) return FALSE; + if(EvNo != -1) + NPC_NowEventSetFlg( talker, EvNo); + CHAR_talkToCli( talker, meindex, token, CHAR_COLORWHITE); + if(NPC_Util_GetStrFromStrWithDelim( buf,"NpcWarp", token2,sizeof( token2) ) + != NULL){ + NPC_EventWarpNpc(meindex,token2); + } + if(NPC_Util_GetStrFromStrWithDelim( buf, "EndSetFlg", buf2, sizeof( buf2) ) + !=NULL){ + char buf3[16]; + int k = 1; + if(EvNo != -1) NPC_NowEventSetFlgCls( talker, EvNo); + while(getStringFromIndexWithDelim(buf2 , "," ,k, buf3, sizeof(buf3)) + !=FALSE ){ + k++; + NPC_EventSetFlg( talker, atoi( buf3)); + } + } + if( NPC_Util_GetStrFromStrWithDelim( buf, "CleanFlg", + buf2, sizeof( buf2)) != NULL) { + char buf3[16]; + int k = 1; + k= 1 ; + while(getStringFromIndexWithDelim(buf2 , "," , k, + buf3, sizeof(buf3)) + != FALSE ){ + NPC_NowEndEventSetFlgCls( talker, atoi(buf3)); + k++; + } + } +#ifdef _ANGEL_SUMMON + // 完成召唤任务 + if( NPC_Util_GetStrFromStrWithDelim( buf, "MISSIONOVER", + buf2, sizeof( buf2)) != NULL) + { + int mindex; + int mission; + char nameinfo[64]; + + mission = atoi( buf2); + mindex = checkIfAngel( talker); + + if( mission == missiontable[mindex].mission ) + { + char msg[1024]; + + print(" ====完成召唤任务==== "); + + CHAR_setInt( talker, CHAR_HEROCNT, + CHAR_getInt( talker, CHAR_HEROCNT)+1 ); + getMissionNameInfo( talker, nameinfo); + saacproto_ACMissionTable_send( acfd, MISSION_HERO_COMPLETE, 4, nameinfo, ""); + sprintf( msg, " 完成任务 i:%d m:%d %s ", mindex, mission, nameinfo); + print( msg); + LogAngel( msg ); + } + + } + + // 清除召唤任务 + if( NPC_Util_GetStrFromStrWithDelim( buf, "MISSIONCLEAN", + buf2, sizeof( buf2)) != NULL) + { + int mindex; + int mission; + char nameinfo[64]; + + mission = atoi( buf2); + mindex = checkIfAngel( talker); + + if( mission == missiontable[mindex].mission ) + { + char msg[1024]; + + getMissionNameInfo( talker, nameinfo); + saacproto_ACMissionTable_send( acfd, mindex, 3, nameinfo, ""); + + sprintf( msg, " 放弃任务 i:%d m:%d %s ", mindex, mission, nameinfo); + print( msg); + LogAngel( msg ); + } + + } +#endif + + }else if(NPC_Util_GetStrFromStrWithDelim(buf, "NomalWindowMsg", + token, sizeof( token) ) + !=NULL) { + /*--它奶件玉它匹丢永本□斥毛忒允--*/ + int fd = getfdFromCharaIndex( talker); +#ifdef _NEWEVENT + if(NPC_Util_GetStrFromStrWithDelim(buf, "NomalWindowMsg1", + buf2, sizeof(buf2)) != NULL){ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_NEXT, + CHAR_WINDOWTYPE_WINDOWEVENT_STARTMSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + }else { +#endif + char token2[14*50]; + if(NPC_AcceptDel( meindex, talker,0) == FALSE) return FALSE; + if( EvNo != -1) NPC_NowEventSetFlg( talker, EvNo); + + if(NPC_Util_GetStrFromStrWithDelim( buf,"NpcWarp", + token2,sizeof( token2) ) != NULL){ + NPC_EventWarpNpc(meindex,token2); + } + if(NPC_Util_GetStrFromStrWithDelim( buf, "EndSetFlg", + buf2, sizeof( buf2) ) !=NULL){ + char buf3[16]; + int k = 1; + if(EvNo != -1) NPC_NowEventSetFlgCls( talker, EvNo); + while(getStringFromIndexWithDelim(buf2 , "," ,k, + buf3, sizeof(buf3)) !=FALSE ){ + k++; + NPC_EventSetFlg( talker, atoi( buf3)); + } + } + //奶矛件玄白仿弘毛壅允 + if( NPC_Util_GetStrFromStrWithDelim( buf, "CleanFlg", + buf2, sizeof( buf2)) != NULL) { + char buf3[16]; + int k = 1; + + k= 1 ; + while(getStringFromIndexWithDelim(buf2 , "," , k, + buf3, sizeof(buf3)) != FALSE ){ + NPC_NowEndEventSetFlgCls( talker, atoi(buf3)); + k++; + } + } +#ifdef _ANGEL_SUMMON + // 完成召唤任务 + if( NPC_Util_GetStrFromStrWithDelim( buf, "MISSIONOVER", + buf2, sizeof( buf2)) != NULL) + { + int mindex; + int mission; + char nameinfo[64]; + + mission = atoi( buf2); + mindex = checkIfAngel( talker); + + if( mission == missiontable[mindex].mission ) + { + char msg[1024]; + + print(" ====完成召唤任务==== "); + + CHAR_setInt( talker, CHAR_HEROCNT, + CHAR_getInt( talker, CHAR_HEROCNT)+1 ); + getMissionNameInfo( talker, nameinfo); + saacproto_ACMissionTable_send( acfd, MISSION_HERO_COMPLETE, 4, nameinfo, ""); + sprintf( msg, " 完成任务 i:%d m:%d %s ", mindex, mission, nameinfo); + print( msg); + LogAngel( msg ); + } + + } + + // 清除召唤任务 + if( NPC_Util_GetStrFromStrWithDelim( buf, "MISSIONCLEAN", + buf2, sizeof( buf2)) != NULL) + { + int mindex; + int mission; + char nameinfo[64]; + + mission = atoi( buf2); + mindex = checkIfAngel( talker); + + if( mission == missiontable[mindex].mission ) + { + print(" ====清除召唤任务==== "); + + getMissionNameInfo( talker, nameinfo); + saacproto_ACMissionTable_send( acfd, mindex, 3, nameinfo, ""); + } + + } +#endif + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_YES, + CHAR_WINDOWTYPE_WINDOWEVENT_STARTMSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); +#ifdef _NEWEVENT + } +#endif + } + + return TRUE; + + }else if(strstr( buf2, "CLEAN") != NULL) { + NPC_CleanMain( meindex, talker, buf); + return TRUE; + } + } + } + } + + strcpy( buf, "\0"); + if( NPC_Util_GetStrFromStrWithDelim( argstr, "NomalMainMsg", buf, sizeof( buf)) == NULL ) { + print("\n err:NOT FIND NomalMainMsg"); + return FALSE; + } + i = 1; + while(getStringFromIndexWithDelim( buf, ",", i, buf2, sizeof( buf2))!= FALSE){ + i++; + } + i--; + i = rand()%i + 1; + getStringFromIndexWithDelim( buf,",", i, buf2, sizeof( buf2)); + CHAR_talkToCli( talker, meindex, buf2, CHAR_COLORWHITE); + return TRUE; +} + + +/*----------------------------------- + *正奶皿 卞质 毛坌仃月 + ------------------------------------*/ +static void NPC_ExChangeMan_selectWindow( int meindex, int talker,int num) +{ + + switch( num) { + /*--伉弁巨旦玄滇--*/ + case 0: + /*-奶矛件玄 卅及匹}奶矛件玄毛鞅户月井升丹井毛 丹--*/ + NPC_MsgDisp( meindex, talker, 0); + break; + + case 1: + /*--蕙筋卞奶矛件玄垫丹--*/ + NPC_MsgDisp( meindex, talker, 5); + break; + + /*--失弁本皿玄滇--*/ + case 2: + /*--熬仃潸曰--*/ + NPC_MsgDisp( meindex, talker, 6); + break; + + case 3: + /*--熬仃潸曰--*/ + NPC_MsgDisp( meindex, talker, 11); + break; + } + +} + +/*------------------------------------- + *奶矛件玄毛匙 允月质 及丢奶件 + --------------------------------------*/ +void NPC_RequestMain(int meindex,int talker,char *buf) +{ + int shiftbit; + char buf2[128]; + + /*--奶矛件玄瓜件田□毛必永玄--*/ + NPC_Util_GetStrFromStrWithDelim( buf,"EventNo", buf2,sizeof( buf2) ); + shiftbit = atoi( buf2); + + if(NPC_NowEventCheckFlg( talker, shiftbit) == TRUE) { + NPC_ExChangeMan_selectWindow( meindex, talker, 0); + }else{ + NPC_ExChangeMan_selectWindow( meindex, talker, 1); + } +} + +/*--------------------------------------- + * 奶矛件玄蔽 及丢奶件 + ----------------------------------------*/ +void NPC_AcceptMain(int meindex,int talker ,char *buf) +{ + + NPC_ExChangeMan_selectWindow( meindex, talker, 2); +} + +/*---------------------------------------- + * 白仿弘毛弁伉失允月啃及丢奶件 + ----------------------------------------*/ +void NPC_CleanMain(int meindex,int talker,char *buf) +{ + NPC_ExChangeMan_selectWindow( meindex, talker, 3); +} + +/*----------------------------------------- +弁仿奶失件玄井日忒匀化五凶凛卞裟太请今木月[ +-------------------------------------------*/ +void NPC_ExChangeManWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + /*-- 及引歹曰卞中卅中午五反蔽 --*/ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 2) { + return; + } + + + switch( seqno) { + + /*--白仿弘毛壅允凛及它奶件玉它--*/ + case CHAR_WINDOWTYPE_WINDOWEVENT_CLEANMSG: + if( select == WINDOW_BUTTONTYPE_YES) { + NPC_MsgDisp( meindex, talkerindex, 12); + }else if(select == WINDOW_BUTTONTYPE_NO) { + } + break; + +#ifdef _NEWEVENT + case CHAR_WINDOWTYPE_WINDOWEVENT_STARTMSG: + if(select == WINDOW_BUTTONTYPE_NEXT) { + CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD, + CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD) + 1); + NPC_MsgDisp( meindex, talkerindex, 99); + }else if(select == WINDOW_BUTTONTYPE_PREV) { + CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD, + CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD) - 1); + NPC_MsgDisp( meindex, talkerindex, 99); + } + break; +#else + case CHAR_WINDOWTYPE_WINDOWEVENT_STARTMSG: + break; +#endif + /*--伉弁巨旦玄及丐曰互午丹丢永本□斥--*/ + case CHAR_WINDOWTYPE_WINDOWEVENT_REQTHANK: + if(select == WINDOW_BUTTONTYPE_NEXT) { + CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD, + CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD)+1); + NPC_MsgDisp( meindex, talkerindex, 22); + }else if(select == WINDOW_BUTTONTYPE_PREV) { + CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD, + CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD)-1); + NPC_MsgDisp( meindex, talkerindex, 22); + } + break; + + /*--失弁本皿玄及丐曰互午丹丢永本□斥--*/ + case CHAR_WINDOWTYPE_WINDOWEVENT_ACCTHANK: + if(select == WINDOW_BUTTONTYPE_NEXT) { + CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD, + CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD)+1); + NPC_MsgDisp( meindex, talkerindex, 82); + }else if(select == WINDOW_BUTTONTYPE_PREV) { + CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD, + CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD)-1); + NPC_MsgDisp( meindex, talkerindex, 82); + } + break; + + /*--蜇箕及奶矛件玄毛鞅户月井--*/ + case CHAR_WINDOWTYPE_WINDOWEVENT_NOWEVENT: + if(select == WINDOW_BUTTONTYPE_YES) { + NPC_MsgDisp( meindex, talkerindex, 7); + }else if(select == WINDOW_BUTTONTYPE_NO){ + NPC_MsgDisp( meindex, talkerindex, 1); + } + break; + + /*--伉弁巨旦玄及丢奶件它奶件玉它--*/ + case CHAR_WINDOWTYPE_WINDOWEVENT_REQMAINMSG: + if(select == WINDOW_BUTTONTYPE_YES) { + CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD,0); + NPC_MsgDisp( meindex, talkerindex, 2); + }else if(select == WINDOW_BUTTONTYPE_NO) { + + }else if(select == WINDOW_BUTTONTYPE_NEXT) { + CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD, + CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD)+1); + NPC_MsgDisp( meindex, talkerindex, 55); + }else if(select == WINDOW_BUTTONTYPE_PREV) { + CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD, + CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD)-1); + NPC_MsgDisp( meindex, talkerindex, 55); + } + break; + + /*--熬仃潸曰及丢奶件及它奶件玉它--*/ + case CHAR_WINDOWTYPE_WINDOWEVENT_ACCMAINMSG: + if(select == WINDOW_BUTTONTYPE_YES) { + CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD,0); +#ifdef _NEWEVENT + NPC_MsgDisp( meindex, talkerindex, 81); +#else + NPC_MsgDisp( meindex, talkerindex, 8); +#endif + }else if(select == WINDOW_BUTTONTYPE_NO) { + }else if(select == WINDOW_BUTTONTYPE_NEXT) { + CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD, + CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD)+1); + NPC_MsgDisp( meindex, talkerindex, 66); + }else if(select == WINDOW_BUTTONTYPE_PREV) { + CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD, + CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD)-1); + NPC_MsgDisp( meindex, talkerindex, 66); + } + break; + +#ifdef _NEWEVENT + case CHAR_WINDOWTYPE_WINDOWEVENT_ACCTHANKNEW: + if(select == WINDOW_BUTTONTYPE_OK){ + CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD,0); + NPC_MsgDisp( meindex, talkerindex, 8); + }else if(select == WINDOW_BUTTONTYPE_NEXT) { + CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD, + CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD)+1); + NPC_MsgDisp( meindex, talkerindex, 81); + }else if(select == WINDOW_BUTTONTYPE_PREV) { + CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD, + CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD)-1); + NPC_MsgDisp( meindex, talkerindex, 81); + } + break; +#endif + /*--矢永玄及 毛芨尹月它奶件玉它--*/ + case CHAR_WINDOWTYPE_WINDOWPETSKILLSHOP: + if(CHAR_getWorkInt( talkerindex ,CHAR_WORKSHOPRELEVANTTRD) ==0) { + NPC_EventPetSkill( meindex, talkerindex, data); + NPC_MsgDisp( meindex, talkerindex, 25); + }else{ + NPC_EventPetSkill( meindex, talkerindex, data); + NPC_MsgDisp( meindex, talkerindex, 88); + } + break; + } +} + + +/*------------------------- + * 椭瘀毛心凶仄化中月井 + --------------------------*/ +int NPC_ExChangeManEventCheck( int meindex, int talker, char *buff1) +{ + char buff2[512]; + char buff3[128]; + char buf[512]; + int i = 1,j = 1; + int loop = 0; + + NPC_Util_GetStrFromStrWithDelim( buff1, "EVENT", buf, sizeof( buf)); + + /*-- EVENt及椭瘀毛赐 卞苇化中仁 --*/ + 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(NPC_EventBigSmallCheck( meindex, talker, buff3) == FALSE) + { + loop = 1; + break; + } + } + + if(loop == 0){ + i--; + return i; + } + /*--椭瘀互夫午勾--*/ + }else{ + if(NPC_EventBigSmallCheck( meindex, talker, buff2) == TRUE) { + i--; + return i; + } + } + + } + + return -1; + +} + +/*--------------------------------- + * 凝筏寞民尼永弁 + --------------------------------*/ +BOOL NPC_EventBigSmallCheck(int meindex,int talker, char* buf) +{ + + char buff2[128]; + int kosuu; + + /*--矢永玄及民尼永弁互反中匀化中月桦宁反域绎PET椭瘀毛民尼永弁允月 --*/ + if(strstr( buf, "PET") != NULL) { + if(strstr( buf, "EV") != NULL) { + if(NPC_PetLvCheck( meindex, talker, buf, 1) != FALSE) return TRUE; + }else{ + if(NPC_PetLvCheck( meindex, talker, buf, 0) != FALSE) return TRUE; + } + return FALSE; + } + + /*--动票反} 骚及筏寞民尼永弁 --*/ + if(strstr( buf, "<") != NULL) { + getStringFromIndexWithDelim( buf, "<", 2, buff2, sizeof( buff2)); + kosuu = atoi( buff2); + getStringFromIndexWithDelim( buf, "<", 1, buff2, sizeof( buff2)); + + if(NPC_EventFreeIfCheck( meindex, talker, buff2, kosuu, 1) == TRUE) { + return TRUE; + } + + }else if(strstr( buf, ">") != NULL) { + getStringFromIndexWithDelim( buf, ">", 2, buff2, sizeof(buff2)); + kosuu = atoi(buff2); + getStringFromIndexWithDelim( buf, ">" ,1, buff2, sizeof(buff2)); + + if(NPC_EventFreeIfCheck( meindex, talker, buff2, kosuu, 2)==TRUE) { + return TRUE; + } + + }else if(strstr( buf, "!=" ) != NULL) { + getStringFromIndexWithDelim( buf, "!=", 2, buff2, sizeof( buff2)); + kosuu = atoi( buff2); + getStringFromIndexWithDelim( buf, "!=", 1, buff2, sizeof( buff2)); + if(NPC_EventFreeIfCheck( meindex, talker, buff2, kosuu, 3) == TRUE) { + return TRUE; + } + + }else if(strstr( buf, "=") != NULL) { + getStringFromIndexWithDelim( buf, "=", 2, buff2, sizeof( buff2)); + kosuu = atoi( buff2); + getStringFromIndexWithDelim( buf, "=", 1, buff2, sizeof( buff2)); + + if(strstr( buf, "*") != NULL) { + if(NPC_EventReduce( meindex, talker, buf) == TRUE){ + return TRUE; + } + }else if(NPC_EventFreeIfCheck( meindex, talker, buff2, kosuu, 0) + == TRUE) + { + return TRUE; + } + } + + return FALSE; + +} + + +/*----------------------------------- + * 嫩 毛 凶仄化中月井及民尼永弁 + *-----------------------------------*/ +BOOL NPC_EventFreeIfCheck(int meindex,int talker,char* buf,int kosuu,int flg) +{ + + /*--伊矛伙民尼永弁--*/ + if(strcmp( buf, "LV") == 0) { + if(NPC_EventLevelCheck( meindex, talker, kosuu, flg) == TRUE) { + return TRUE; + } + } + + /*--失奶 丞民尼永弁--*/ + if(strcmp( buf, "ITEM") == 0) { + if(NPC_EventItemCheck( meindex, talker, kosuu, flg) == TRUE) { + return TRUE; + } + } + + /*--蔽 奶矛件玄民尼永弁--*/ + if(strcmp( buf, "ENDEV") == 0) { + if(NPC_ENDEventNoCheck( meindex, talker, kosuu, flg) == TRUE) { + return TRUE; + } + } + + if(strcmp( buf, "NOWEV") == 0) { + if(NPC_NOWEventNoCheck( meindex, talker, kosuu, flg) == TRUE) { + return TRUE; + } + } + + if(strcmp( buf, "SP" ) == 0) { + if(NPC_SavePointCheck( meindex, talker, kosuu, flg) == TRUE) { + return TRUE; + } + } + + if(strcmp( buf, "TIME") == 0) { + if(NPC_TiemCheck( meindex, talker, kosuu, flg) == TRUE) { + return TRUE; + } + } + +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + if(strcmp(buf,"CLASS")==0){ + if(NPC_ActionClassCheck(meindex,talker,kosuu,flg)==TRUE) + return TRUE; + } +#endif + + if(strcmp( buf, "IMAGE") == 0) { + if(NPC_ImageCheck( meindex, talker, kosuu, flg) == TRUE) { + return TRUE; + } + } + +#ifdef _ANGEL_SUMMON + if(strcmp(buf,"ANGEL_NOW")==0){ + if( NPC_ActionMissionAngelCheck(meindex,talker,kosuu, MISSION_DOING, 0)==TRUE) + return TRUE; + } + if(strcmp(buf,"HERO_NOW")==0){ + if( NPC_ActionMissionHeroCheck(meindex,talker,kosuu, MISSION_DOING, 0)==TRUE) + return TRUE; + } + if(strcmp(buf,"ANGEL_OVER")==0){ + if( NPC_ActionMissionAngelCheck(meindex,talker,kosuu, MISSION_HERO_COMPLETE, 0)==TRUE) + return TRUE; + } + if(strcmp(buf,"HERO_OVER")==0){ + if( NPC_ActionMissionHeroCheck(meindex,talker,kosuu, MISSION_HERO_COMPLETE, 0)==TRUE) + return TRUE; + } + if(strcmp(buf,"ANGEL_OUT")==0){ + if( NPC_ActionMissionAngelCheck(meindex,talker,kosuu, MISSION_TIMEOVER, 0)==TRUE) + return TRUE; + } + if(strcmp(buf,"HERO_OUT")==0){ + if( NPC_ActionMissionHeroCheck(meindex,talker,kosuu, MISSION_TIMEOVER, 0)==TRUE) + return TRUE; + } + + if(strcmp(buf,"ANGEL_I_NOW")==0){ + if( NPC_ActionMissionAngelCheck(meindex,talker,kosuu, MISSION_DOING, TRUE)==TRUE) + return TRUE; + } + if(strcmp(buf,"HERO_I_NOW")==0){ + if( NPC_ActionMissionHeroCheck(meindex,talker,kosuu, MISSION_DOING, TRUE)==TRUE) + return TRUE; + } + if(strcmp(buf,"ANGEL_I_OVER")==0){ + if( NPC_ActionMissionAngelCheck(meindex,talker,kosuu, MISSION_HERO_COMPLETE, TRUE)==TRUE) + return TRUE; + } + if(strcmp(buf,"HERO_I_OVER")==0){ + if( NPC_ActionMissionHeroCheck(meindex,talker,kosuu, MISSION_HERO_COMPLETE, TRUE)==TRUE) + return TRUE; + } + if(strcmp(buf,"ANGEL_I_OUT")==0){ + if( NPC_ActionMissionAngelCheck(meindex,talker,kosuu, MISSION_TIMEOVER, TRUE)==TRUE) + return TRUE; + } + if(strcmp(buf,"HERO_I_OUT")==0){ + if( NPC_ActionMissionHeroCheck(meindex,talker,kosuu, MISSION_TIMEOVER, TRUE)==TRUE) + return TRUE; + } + if(strcmp( buf, "HEROCNT") == 0) { + //if(NPC_EventLevelCheck( meindex, talker, kosuu, flg) == TRUE) { + if(NPC_HeroCompleteCountCheck( meindex, talker, kosuu, flg) == TRUE) + return TRUE; + } + +#endif +#ifdef _NPC_EXCHANGEMANTRANS + //判断转生 + { + //print("\n判断转生"); + if(strcmp(buf,"TRANS")==0){ + int mytrans; + mytrans = CHAR_getInt(talker,CHAR_TRANSMIGRATION); + if(NPC_EventBigSmallLastCheck( kosuu, mytrans, flg) == TRUE) + return TRUE; + } + } +#endif +#ifdef _PROSK99 + if(strstr( buf, "PROSK" ) != NULL) {//PROSK99>16 职技等级大於等於99%的数量要超过16个 + char *p=NULL; + int i,level=0,count=0; + CHAR_HaveSkill *pSkil; + if( p = strstr( buf, "PROSK" ) ) + level = atoi(p+5); + else + level = 100; + for( i = 0; i < CHAR_SKILLMAXHAVE; i ++ ){ + if( pSkil = CHAR_getCharHaveSkill( talker, i ) ) + if( SKILL_getInt( &pSkil->skill, SKILL_LEVEL) >= level ) + ++count; + } + if(NPC_EventBigSmallLastCheck( kosuu, count, flg) == TRUE) + return TRUE; + } +#endif + +#ifdef _ADD_reITEM + if(strstr( buf, "reITEM" ) != NULL) { + int i,count=0,itemindex=-1; + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE ; i++ ){ + itemindex = CHAR_getItemIndex( talker , i ); + if( !ITEM_CHECKINDEX( itemindex) ) + ++count; + } + if(NPC_EventBigSmallLastCheck( kosuu, count, flg) == TRUE) + return TRUE; + } +#endif + + return FALSE; + +} + +/*-------------------------------- + * 矢永玄及伊矛伙毛民尼永弁允月 + ---------------------------------*/ +BOOL NPC_PetLvCheck(int meindex,int talker,char *buf,int mode) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff2[16]; + char buf3[8]; + int petno; + int baseno; + int petlevel = 0; + int flg=0; + int mypetlevel = 0; + int i = 0; + int petindex; + char name[512]; + int cnt = 0; + int loop; + + + /*--隙烂今木凶矢永玄及瓜件田□ ID)毛潸 --*/ + getStringFromIndexWithDelim( buf, "-", 2, buff2, sizeof( buff2)); + if(strstr(buff2,"*") != NULL) { + getStringFromIndexWithDelim( buff2, "*", 1, buf3, sizeof( buf3)); + petno = atoi( buf3); + getStringFromIndexWithDelim( buff2, "*", 2, buf3, sizeof( buf3)); + loop = atoi( buf3); + + }else{ + petno = atoi( buff2); + loop = 1; + + } + + /*--矢永玄 互钒中化中月井及民尼永弁--*/ + for(i=0; i < CHAR_MAXPETHAVE ; i++) { + if(loop == cnt) return TRUE; + + petindex = CHAR_getCharPet( talker, i); + if( petindex == -1 ) continue; + + /*--矢永玄及ID毛潸 仄化中仁--*/ + baseno = CHAR_getInt( petindex, CHAR_PETID); + + /* 矢永玄及ID午}蜇箕及乒□玉毛譬屯月 */ + if( (baseno == petno) && (CHAR_getInt( petindex, CHAR_ENDEVENT) + == mode)) + { + /*--伊矛伙毛民尼永弁允月--*/ + mypetlevel = CHAR_getInt( petindex, CHAR_LV); + getStringFromIndexWithDelim( buf, "-", 1, buff2, sizeof( buff2)); + + if(strstr( buf, "<") != NULL) { + flg = 1; + getStringFromIndexWithDelim( buff2, "<", 2, buf3, sizeof(buf3)); + }else if(strstr( buf, ">") != NULL) { + getStringFromIndexWithDelim( buff2, ">", 2, buf3, sizeof(buf3)); + flg = 2; + }else if(strstr( buf, "=") != NULL) { + getStringFromIndexWithDelim( buff2, "=", 2, buf3, sizeof(buf3)); + flg = 0; + } + + petlevel = atoi( buf3); + + if(NPC_EventBigSmallLastCheck( petlevel, mypetlevel, flg) == TRUE) { + /*--矢永玄及 蟆互涩烂今木化中凶日 蟆及民尼永弁 月--*/ + if(CHAR_getWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC)==1) { + char *usename; + + /*--涩烂白央奶伙及 心 心--*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("PetLevel:GetArgStrErr"); + return FALSE; + } + + usename = CHAR_getUseName( petindex); + NPC_Util_GetStrFromStrWithDelim( argstr, "Pet_Name", + name,sizeof( name)); + + if(strcmp( name, usename) == 0) + { + cnt++; + continue; + } + }else { + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTSEC, 0); + cnt++; + continue; + } + } + } + } + + if(loop == cnt) return TRUE; + if(i == CHAR_MAXPETHAVE) return FALSE; + + return FALSE; +} + + +/*-------------------------------- + * 矢永玄及伊矛伙毛民尼永弁允月 + ---------------------------------*/ +int NPC_PetLvCheckType2(int petindex,int meindex,int talker,char *buf,int mode) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff2[16]; + char buf3[8]; + int petno; + int baseno; + int petlevel = 0; + int flg = 0; + int mypetlevel = 0; + char name[512]; + + /*--隙烂今木凶矢永玄及瓜件田□ ID)毛潸 --*/ + getStringFromIndexWithDelim( buf, "-", 2, buff2, sizeof( buff2)); + if(strstr(buff2,"*") != NULL) { + getStringFromIndexWithDelim( buff2, "*", 1, buf3, sizeof( buf3)); + petno = atoi( buf3); + }else{ + petno = atoi( buff2); + } + + + /*--矢永玄及ID毛潸 仄化中仁--*/ + baseno = CHAR_getInt( petindex, CHAR_PETID); + + /*--矢永玄及ID午}蜇箕及乒□玉毛譬屯月--*/ + if( (baseno == petno) && (CHAR_getInt( petindex, CHAR_ENDEVENT) + == mode)) + { + /*--伊矛伙毛民尼永弁允月--*/ + mypetlevel=CHAR_getInt( petindex, CHAR_LV); + getStringFromIndexWithDelim( buf, "-", 1,buff2,sizeof(buff2)); + + if(strstr( buf, "<") != NULL) { + flg = 1; + getStringFromIndexWithDelim( buff2, "<", 2, + buf3, sizeof(buf3)); + }else if(strstr( buf, ">") != NULL) { + getStringFromIndexWithDelim( buff2, ">", 2, buf3, sizeof(buf3)); + flg = 2; + }else if(strstr( buf, "=") != NULL) { + getStringFromIndexWithDelim( buff2, "=", 2, buf3, sizeof(buf3)); + flg = 0; + } + + petlevel = atoi(buf3); + + if(NPC_EventBigSmallLastCheck( petlevel, mypetlevel, flg) + == TRUE) + { + /*--矢永玄及 蟆互涩烂今木化中凶日 蟆及民尼永弁 月--*/ + if(CHAR_getWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC) == 1) { + char *usename; + + /*--涩烂白央奶伙及 心 心--*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("PetLevel:GetArgStrErr"); + return FALSE; + } + + usename = CHAR_getUseName( petindex); + NPC_Util_GetStrFromStrWithDelim(argstr,"Pet_Name", + name, sizeof( name)); + + if(strcmp( name, usename) == 0) + { + return TRUE; + } + }else { + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTSEC, 0); + return TRUE; + } + } + } + + return FALSE; + +} + +/*------------------------ + *请 鳔及民尼永弁 + --------------------------*/ +BOOL NPC_SavePointCheck(int meindex,int talker,int shiftbit,int flg) +{ + int point; + + point = CHAR_getInt( talker, CHAR_SAVEPOINT); + + if( (point & ( 1<< shiftbit)) == ( 1<< shiftbit)) { + if(flg == 3) return FALSE; + return TRUE; + } + + if(flg == 3) return TRUE; + return FALSE; +} + +/*------------------------ + *奶丢□斥及民尼永弁 + --------------------------*/ +BOOL NPC_ImageCheck(int meindex,int talker,int kosuu,int flg) +{ + int image; + + image = CHAR_getInt( talker, CHAR_IMAGETYPE); + + if(NPC_EventBigSmallLastCheck( image, kosuu, flg) == TRUE) { + return TRUE; + } + return FALSE; + +} + + +/*----------------------------------------- + * 凛棉及民尼永弁毛垫丹(丐中引中凛棉) + ------------------------------------------*/ +BOOL NPC_TiemCheck(int meindex,int talker,int time,int flg) +{ + LSTIME nowlstime; + int now; + + RealTimeToLSTime( NowTime.tv_sec, &nowlstime); + now = getLSTime( &nowlstime); + + if(NPC_EventBigSmallLastCheck( time, now, flg) == TRUE) { + return TRUE; + } + return FALSE; + +} + +/*------------------------------ + *--Item毛民尼永弁 + -------------------------------*/ +BOOL NPC_EventItemCheck(int meindex,int talker,int itemNo,int flg) +{ + int i; + int itemindex = -1; + int id; + + //Change fix 不检查穿戴在身上的道具 + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE ; i++ ) { + + itemindex=CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX( itemindex) ) { + id=ITEM_getInt( itemindex ,ITEM_ID ); + + if(NPC_EventBigSmallLastCheck( itemNo, id, flg) == TRUE) { + if(flg == 0) return TRUE; + continue; + }else{ + if(flg == 0) continue; + return FALSE; + } + } + } + + if(flg == 3) return TRUE; + + return FALSE; + +} + + +/*------------------------------ + * level毛民尼永弁 + -------------------------------*/ +BOOL NPC_EventLevelCheck(int meindex,int talker,int level,int flg) +{ + + int mylevel; + mylevel = CHAR_getInt(talker,CHAR_LV); + + if(NPC_EventBigSmallLastCheck( level, mylevel, flg) == TRUE) + { + if(flg == 3) return FALSE; + return TRUE; + } + + if(flg == 3) return TRUE; + return FALSE; + +} + + + +/*------------------------------ + * ENDEventNo毛民尼永弁 + -------------------------------*/ +BOOL NPC_ENDEventNoCheck(int meindex,int talker,int shiftbit,int flg) +{ + + if(NPC_EventCheckFlg( talker, shiftbit) == TRUE) { + if(flg == 3) return FALSE; + return TRUE; + } + + if(flg == 3) return TRUE; + return FALSE; +} + + +/*------------------------------ + * NOWEventNo毛民尼永弁 + -------------------------------*/ +BOOL NPC_NOWEventNoCheck(int meindex,int talker,int shiftbit,int flg) +{ + if(NPC_NowEventCheckFlg( talker, shiftbit) == TRUE) { + if(flg == 3) return TRUE; + return TRUE; + } + + if(flg == 3) return TRUE; + return FALSE; +} + +/*--------------------------------------- + * 蔽民尼永弁 + --------------------------------------*/ +BOOL NPC_EventBigSmallLastCheck(int point1,int mypoint,int flg) +{ + + if(flg == 0) { + if(point1 == mypoint) { + return TRUE; + } + }else if(flg == 1) { + if(mypoint < point1) { + return TRUE; + } + }else if(flg == 2) { + if(mypoint > point1) { + return TRUE; + } + }else if(flg == 3) { + if(point1 != mypoint) { + return TRUE; + } + } + return FALSE; +} + + +/*--------------------------------- + *丢永本□斥毛请 允月 + *----------------------------------*/ +#ifdef _CHANNEL_MODIFY +extern int *piOccChannelMember; +#endif +void NPC_MsgDisp(int meindex,int talker,int num) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; +#ifdef _NEWEVENT + char buf[4096]; + char token2[4096]; + char buf2[4096]; + char token[4096]; + char tmp[4096]; +#else + char buf[1024*2]; + char token2[50*14]; + char buf2[512]; + char token[512]; + char tmp[32]; +#endif + int i = 1; + int work = 0; + int EvNo = 0; + int fd = getfdFromCharaIndex( talker); + int buttontype = WINDOW_BUTTONTYPE_OK; + int windowtype = CHAR_WINDOWTYPE_WINDOWEVENT_STARTMSG; + int evch; + + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("MsgDisp:GetArgStrErr"); + print("NPCName=%s\n", CHAR_getChar( meindex, CHAR_NAME)); + return ; + } + if(num == 22 || num == 82 || num == 55 || num == 66) { + int pwork; + + pwork = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD); + pwork = (pwork / 100) -1 ; + + getStringFromIndexWithDelim( argstr, "EventEnd", pwork, buf,sizeof( buf)); + + }else{ + /*涩烂白央奶伙毛坌喃允月*/ + while(getStringFromIndexWithDelim( argstr, "EventEnd", i, buf, sizeof(buf)) + != FALSE) + { + i++; + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTSEC, 0); + + /*--奶矛件玄瓜件田□毛必永玄--*/ + NPC_Util_GetStrFromStrWithDelim( buf, "EventNo", buf2, sizeof( buf2)); + if(strstr( buf2, "-1") != 0) { + EvNo = -1; + }else{ + EvNo = atoi( buf2); + } + EvNo = atoi( buf2); + + /*--白仿弘民尼永弁毛垫丹[允匹卞}仇及奶矛件玄互蔽 仄化中月桦宁反戚尺--*/ + if(NPC_EventCheckFlg( talker, EvNo) == TRUE) continue; + + /*--平□伐□玉及民尼永弁毛垫丹--*/ + if(NPC_Util_GetStrFromStrWithDelim( buf,"Pet_Name", buf2,sizeof( buf2)) + != NULL ) + { + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTSEC, 1); + } + + /*--平□伐□玉及民尼永弁毛垫丹--*/ + if(NPC_Util_GetStrFromStrWithDelim( buf,"KeyWord", buf2,sizeof( buf2) ) + != NULL) + { + if(CHAR_getWorkInt( talker ,CHAR_WORKSHOPRELEVANT) != i) continue; + } + + evch = NPC_ExChangeManEventCheck( meindex, talker, buf); + + if(evch != -1) { + + /*--奶矛件玄椭瘀及民尼永弁--*/ + // if(NPC_ExChangeManEventCheck( meindex, talker, buf) == TRUE) { + break; + } + } + } + + //print(" NPC_MsgDisp:%d ", num); + + switch( num) { + case 0: + /*蜇箕及奶矛件玄毛鞅户月井升丹井毛 仁丢永本□斥--*/ + if( NPC_Util_GetStrFromStrWithDelim( buf, "StopMsg", + buf2, sizeof( buf2) ) + != NULL) + { + strcpysafe( token,sizeof( buf2), buf2); + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowtype = CHAR_WINDOWTYPE_WINDOWEVENT_NOWEVENT; + } + break; + + case 1: + /*--支户月井升丹井毛 中凶今中及NO毛蚕尹凶桦宁及丢永本□斥--*/ + if( NPC_Util_GetStrFromStrWithDelim( buf, "NoStopMsg", + buf2, sizeof( buf2)) + != NULL) + { + strcpysafe( token, sizeof(buf2), buf2); + + } + break; + + case 7: + /*--蜇箕及奶矛件玄毛鞅户凶午五及丢永本□斥--*/ + if( NPC_Util_GetStrFromStrWithDelim( buf, "EndStopMsg", + buf2, sizeof( buf2)) + != NULL) + { + strcpysafe( token, sizeof( buf2), buf2); + + /*--奶矛件玄 毛 匀化中凶桦宁反壅蛔--*/ + NPC_EventAdd( meindex, talker, 1); + + /*--白仿弘毛壅允--*/ + NPC_NowEventSetFlgCls( talker, EvNo); + + /*--蝇匀凶及匹} 毛今仆凶--*/ + if(CHAR_getInt( talker, CHAR_CHARM) > 0) { + CHAR_setInt( talker, CHAR_CHARM, CHAR_getInt(talker,CHAR_CHARM) -1); + CHAR_complianceParameter( talker ); + CHAR_send_P_StatusString( talker, CHAR_P_STRING_CHARM); + NPC_CharmStatus( meindex, talker); + } + } + break; + + case 2: + /*--丐曰互午丹丢永本□斥--*/ + if( NPC_Util_GetStrFromStrWithDelim( buf, "ThanksMsg", + buf2, sizeof( buf2) ) + != NULL) + { + strcpysafe( token,sizeof( buf2), buf2); + /*--奶矛件玄 白仿弘毛本永玄--*/ + if(NPC_EventAdd(meindex, talker, 0) != FALSE) { + NPC_NowEventSetFlg( talker, EvNo); + } + else { + return; + } + + + if(NPC_Util_GetStrFromStrWithDelim( buf, "EndSetFlg", + buf2, sizeof( buf2) ) + !=NULL) + { + char buf3[16]; + int k = 1; + if(EvNo != -1) NPC_NowEventSetFlgCls( talker, EvNo); + + while(getStringFromIndexWithDelim(buf2 , "," ,k, + buf3, sizeof(buf3)) + !=FALSE ) + { + k++; + NPC_EventSetFlg( talker, atoi( buf3)); + } + } + + if( NPC_Util_GetStrFromStrWithDelim( buf, "CleanFlg", + buf2, sizeof( buf2)) + != NULL) { + char buf3[16]; + int k = 1; + + k= 1 ; + while(getStringFromIndexWithDelim(buf2 , "," , k, + buf3, sizeof(buf3)) + != FALSE ) + { + NPC_NowEndEventSetFlgCls( talker, atoi(buf3)); + k++; + } + } + + + + } + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD, 1); + work = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD); + work = work + ( i * 100); + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD, work); + + if(NPC_Util_GetStrFromStrWithDelim( buf,"NpcWarp", + token2,sizeof( token2) ) + != NULL){ + NPC_EventWarpNpc(meindex,token2); + } + + /*--戚矢□斥互丐月桦宁反示正件方它奶件玉它及正奶皿毛井尹月--*/ + if(strstr( buf, "ThanksMsg2") != NULL) { + /*仇仇匹霜耨允月*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_NEXT, + CHAR_WINDOWTYPE_WINDOWEVENT_REQTHANK, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return; + } + + break; + + case 22: + + work = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD); + work = work % 100; + + if(work == 1){ + if( NPC_Util_GetStrFromStrWithDelim( buf, "ThanksMsg", + buf2, sizeof( buf2) ) + != NULL) + { + strcpysafe( token,sizeof( buf2), buf2); + } + + /*--戚矢□斥互丐月桦宁反示正件方它奶件玉它及正奶皿毛井尹月--*/ + if(strstr( buf, "ThanksMsg2") != NULL) { + + /*仇仇匹霜耨允月*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_NEXT, + CHAR_WINDOWTYPE_WINDOWEVENT_REQTHANK, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return; + } + + }else{ + + sprintf( tmp, "ThanksMsg%d", work); + if( NPC_Util_GetStrFromStrWithDelim( buf, tmp, + buf2, sizeof( buf2) ) + != NULL) { + strcpysafe( token,sizeof( buf2), buf2); + } + + work++; + sprintf( tmp, "ThanksMsg%d", work); + + + /*--戚矢□斥互丐月桦宁反示正件方它奶件玉它及正奶皿毛井尹月--*/ + if(strstr( buf, tmp) != NULL) { + + /*仇仇匹霜耨允月*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_NEXT, + CHAR_WINDOWTYPE_WINDOWEVENT_REQTHANK, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return; + }else{ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_WINDOWEVENT_REQTHANK, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return; + } + } + break; + + case 25: + /*--丐曰互午丹丢永本□斥--*/ + if( NPC_Util_GetStrFromStrWithDelim( buf, "ThanksMsg", + buf2, sizeof( buf2) ) + != NULL) + { + strcpysafe( token,sizeof( buf2), buf2); + /*--奶矛件玄 白仿弘毛本永玄--*/ + if(NPC_EventAdd(meindex, talker, 2) != FALSE) { + NPC_NowEventSetFlg( talker, EvNo); + } + } + break; + + + case 3: + /*-- 骚及丢永本□斥--*/ + if( NPC_Util_GetStrFromStrWithDelim( buf, "NomalMsg", + buf2, sizeof( buf2) ) + != NULL) + { + strcpysafe(token, sizeof( buf2), buf2); + } + break; + + case 4: + /*--失奶 丞互中匀天中及凛及丢永本□斥--*/ + if( NPC_Util_GetStrFromStrWithDelim( buf, "ItemFullMsg", + buf2, sizeof( buf2) ) + != NULL) + { + strcpysafe(token, sizeof( buf2), buf2); + } + break; + + case 5: + /*--匙 毛允月端及丢奶件及丢永本□斥--*/ + if( NPC_Util_GetStrFromStrWithDelim( buf, "RequestMsg", + buf2, sizeof( buf2) ) + != NULL) + { + + if(strstr(buf2,"%8d") != NULL) { + char buf3[64]; + int cost; + + NPC_Util_GetStrFromStrWithDelim( buf, "DelStone", + buf3, sizeof( buf3) ); + cost = NPC_EventGetCost( meindex, talker, buf3); + + sprintf(token,buf2,cost); + + }else{ + strcpysafe( token,sizeof( buf2), buf2); + } + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowtype = CHAR_WINDOWTYPE_WINDOWEVENT_REQMAINMSG; + } + + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD, 1); + work = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD); + work = work + ( i * 100); + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD, work); + + /*--戚矢□斥互丐月桦宁反示正件它奶件玉它及正奶皿毛井尹月--*/ + if(strstr( buf, "RequestMsg2") != NULL) { + /*仇仇匹霜耨允月*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_NEXT, + CHAR_WINDOWTYPE_WINDOWEVENT_REQMAINMSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return; + } + break; + + case 55: + + work = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD); + work = work % 100; + + if(work == 1){ + if( NPC_Util_GetStrFromStrWithDelim( buf, "RequestMsg", + buf2, sizeof( buf2) ) + != NULL) + { + strcpysafe( token, sizeof( buf2), buf2); + } + + /*--戚矢□斥互丐月桦宁反示正件方它奶件玉它及正奶皿毛井尹月--*/ + if(strstr( buf, "RequestMsg2") != NULL){ + /*仇仇匹霜耨允月*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_NEXT, + CHAR_WINDOWTYPE_WINDOWEVENT_REQMAINMSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return; + } + }else{ + + sprintf( tmp, "RequestMsg%d", work); + if( NPC_Util_GetStrFromStrWithDelim( buf, tmp, + buf2, sizeof( buf2) ) + != NULL){ + strcpysafe( token,sizeof( buf2), buf2); + + } + work++; + sprintf( tmp, "RequestMsg%d", work); + /*--戚矢□斥互丐月桦宁反示正件方它奶件玉它及正奶皿毛井尹月--*/ + if(strstr( buf, tmp) != NULL) { + + /*仇仇匹霜耨允月*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_NEXT, + CHAR_WINDOWTYPE_WINDOWEVENT_REQMAINMSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return; + }else{ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_YESNO, + CHAR_WINDOWTYPE_WINDOWEVENT_REQMAINMSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return; + } + } + break; + + + case 6: + //print(" 6_答应? "); + /*--熬仃潸曰及端及丢奶件及丢永本□斥--*/ + if( NPC_Util_GetStrFromStrWithDelim( buf, "AcceptMsg", + buf2, sizeof( buf2) ) + != NULL) + { + if(strstr(buf2,"%8d") != NULL) { + char buf3[64]; + int cost; + + NPC_Util_GetStrFromStrWithDelim( buf, "DelStone", + buf3, sizeof( buf3) ); + cost = NPC_EventGetCost( meindex, talker, buf3); + + sprintf( token, buf2, cost); + }else{ + strcpysafe( token, sizeof( buf2), buf2); + } + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowtype = CHAR_WINDOWTYPE_WINDOWEVENT_ACCMAINMSG; + } + + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD, 1); + work = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD); + work = work + ( i * 100); + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD, work); + + /*--戚矢□斥互丐月桦宁反示正件它奶件玉它及正奶皿毛井尹月--*/ + if(strstr( buf, "AcceptMsg2") != NULL) { + /*仇仇匹霜耨允月*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_NEXT, + CHAR_WINDOWTYPE_WINDOWEVENT_ACCMAINMSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return; + } + break; + + + case 66: + //print(" 66_答应? "); + work = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD); + work = work % 100; + + if(work == 1){ + if( NPC_Util_GetStrFromStrWithDelim( buf, "AcceptMsg", + buf2, sizeof( buf2) ) + != NULL) + { + strcpysafe( token,sizeof( buf2), buf2); + } + + /*--戚矢□斥互丐月桦宁反示正件方它奶件玉它及正奶皿毛井尹月--*/ + if(strstr( buf, "AcceptMsg2") != NULL) { + /*仇仇匹霜耨允月*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_NEXT, + CHAR_WINDOWTYPE_WINDOWEVENT_ACCMAINMSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return; + } + }else{ + + sprintf( tmp, "AcceptMsg%d", work); + if( NPC_Util_GetStrFromStrWithDelim( buf, tmp, + buf2, sizeof( buf2) ) + != NULL){ + strcpysafe( token,sizeof( buf2), buf2); + } + work++; + sprintf( tmp, "AcceptMsg%d", work); + /*--戚矢□斥互丐月桦宁反示正件方它奶件玉它及正奶皿毛井尹月--*/ + if(strstr( buf, tmp) != NULL) { + + /*仇仇匹霜耨允月*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_NEXT, + CHAR_WINDOWTYPE_WINDOWEVENT_ACCMAINMSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return; + }else{ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_YESNO, + CHAR_WINDOWTYPE_WINDOWEVENT_ACCMAINMSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return; + } + } + break; + + case 8: + //print(" 8_答应? "); + + if( NPC_Util_GetStrFromStrWithDelim( buf, "ThanksMsg", + buf2, sizeof( buf2) ) + != NULL) + { + strcpysafe( token, sizeof( buf2), buf2); + /*--奶矛件玄 白仿弘毛本永玄--*/ + if(NPC_AcceptDel( meindex, talker,0) == FALSE){ + return ; + } + + if(NPC_Util_GetStrFromStrWithDelim( buf, "EndSetFlg", + buf2, sizeof( buf2) ) + !=NULL) + { + char buf3[16]; + int k = 1; + if(EvNo != -1) NPC_NowEventSetFlgCls( talker, EvNo); + + while(getStringFromIndexWithDelim(buf2 , "," ,k, + buf3, sizeof(buf3)) + !=FALSE ) + { + k++; + NPC_EventSetFlg( talker, atoi( buf3)); + } + } + + if( NPC_Util_GetStrFromStrWithDelim( buf, "Charm", + buf2, sizeof( buf2)) + !=NULL) + { + /*--仇仇引匹 凶日} 毛晓仆月---*/ + if( CHAR_getInt( talker, CHAR_CHARM) < 100 && EvNo > 0 ){ + if(CHAR_getInt( talker, CHAR_CHARM) + atoi(buf2) > 100){ + CHAR_setInt( talker, CHAR_CHARM,100); + + }else{ + CHAR_setInt( talker, CHAR_CHARM, + CHAR_getInt(talker,CHAR_CHARM) + atoi(buf2)); + + } + + CHAR_complianceParameter( talker ); + CHAR_send_P_StatusString( talker, CHAR_P_STRING_CHARM); + NPC_CharmStatus( meindex, talker); + } + } + + if( NPC_Util_GetStrFromStrWithDelim( buf, "CleanFlg", + buf2, sizeof( buf2)) + != NULL) { + char buf3[16]; + int k = 1; + + k= 1 ; + while(getStringFromIndexWithDelim(buf2 , "," , k, + buf3, sizeof(buf3)) + != FALSE ) + { + NPC_NowEndEventSetFlgCls( talker, atoi(buf3)); + k++; + } + } + + + // Robin add 清除职业 + if( NPC_Util_GetStrFromStrWithDelim( buf, "PROFESSION", + buf2, sizeof( buf2)) != NULL) + { + int p_class = atoi( buf2); + //Change fix 2004/07/05 + for( i=0; i 0 ){ + p_class = 1; + CHAR_talkToCli( talker, -1, "请先把职业装备通通卸下!", CHAR_COLORWHITE); + break; + } + } + } + if( p_class == 0) + { + print(" ====清除职业==== "); + + // 还原点数 + //if( PROFESSION_RESTORE_POINT( talker ) != 1 ) return FALSE; + + // 设定职业归零 + CHAR_setInt( talker, PROFESSION_CLASS, p_class ); +#ifdef _CHANNEL_MODIFY + if(CHAR_getInt(talker,PROFESSION_CLASS) > 0){ + int i,pclass = CHAR_getInt(talker,PROFESSION_CLASS) - 1; + for(i=0;i 0 ){ + if(CHAR_getInt( talker, CHAR_CHARM) + atoi(buf2) > 100){ + CHAR_setInt( talker, CHAR_CHARM,100); + }else{ + CHAR_setInt( talker, CHAR_CHARM, + CHAR_getInt(talker,CHAR_CHARM) + atoi( buf2)); + } + CHAR_complianceParameter( talker ); + CHAR_send_P_StatusString( talker, CHAR_P_STRING_CHARM); + NPC_CharmStatus( meindex, talker); + } + } + } + + break; + + + case 9: + + if( NPC_Util_GetStrFromStrWithDelim( buf, "NomalWindowMsg", + buf2, sizeof( buf2) ) + != NULL) + { + strcpysafe( token, sizeof( buf2), buf2); + if(EvNo != -1) NPC_NowEventSetFlg( talker, EvNo); + } +#ifdef _NEWEVENT + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD, 1); + work = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD); + work = work + ( i * 100); + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD, work); + + /*--戚矢□斥互丐月桦宁反示正件它奶件玉它及正奶皿毛井尹月--*/ + if(strstr( buf, "NomalWindowMsg2") != NULL) { + /*仇仇匹霜耨允月*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_NEXT, + CHAR_WINDOWTYPE_WINDOWEVENT_STARTMSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return; + } +#endif + break; + +#ifdef _NEWEVENT + case 99: + work = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD); + work = work % 100; + + if(work == 1) + { + if( NPC_Util_GetStrFromStrWithDelim( buf, "NomalWindowMsg1", + buf2, sizeof( buf2) ) != NULL) + strcpysafe( token,sizeof( buf2), buf2); + + /*--戚矢□斥互丐月桦宁反示正件方它奶件玉它及正奶皿毛井尹月--*/ + if(strstr( buf, "NomalWindowMsg2") != NULL) { + /*仇仇匹霜耨允月*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_NEXT, + CHAR_WINDOWTYPE_WINDOWEVENT_STARTMSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return; + } + }else{ + + sprintf( tmp, "NomalWindowMsg%d", work); + if( NPC_Util_GetStrFromStrWithDelim( buf, tmp, + buf2, sizeof( buf2) ) + != NULL){ + strcpysafe( token,sizeof( buf2), buf2); + } + work++; + sprintf( tmp, "NomalWindowMsg%d", work); + /*--戚矢□斥互丐月桦宁反示正件方它奶件玉它及正奶皿毛井尹月--*/ + if(strstr( buf, tmp) != NULL) { + + /*仇仇匹霜耨允月*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_NEXT, + CHAR_WINDOWTYPE_WINDOWEVENT_STARTMSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return; + }else{ + int fd = getfdFromCharaIndex( talker); + char token2[14*50]; + /*--仇仇匹}失奶 丞卅升及馨笛毛垫丹--*/ + if(NPC_AcceptDel( meindex, talker,0) == FALSE) return; + + /*白仿弘毛本永玄仄化中木壬}本永玄允月--*/ + if( EvNo != -1) NPC_NowEventSetFlg( talker, EvNo); + + if(NPC_Util_GetStrFromStrWithDelim( buf,"NpcWarp", + token2,sizeof( token2) )!= NULL){ + NPC_EventWarpNpc(meindex,token2); + } + + //白仿弘毛 化月 + if(NPC_Util_GetStrFromStrWithDelim( buf, "EndSetFlg", + buf2, sizeof( buf2) )!=NULL) + { + char buf3[16]; + int k = 1; + + if(EvNo != -1) NPC_NowEventSetFlgCls( talker, EvNo); + + while(getStringFromIndexWithDelim(buf2 , "," ,k, + buf3, sizeof(buf3)) !=FALSE ) + { + k++; + NPC_EventSetFlg( talker, atoi( buf3)); + } + } + //奶矛件玄白仿弘毛壅允 + if( NPC_Util_GetStrFromStrWithDelim( buf, "CleanFlg", + buf2, sizeof( buf2)) != NULL) { + char buf3[16]; + int k = 1; + + k= 1 ; + while(getStringFromIndexWithDelim(buf2 , "," , k, + buf3, sizeof(buf3)) + != FALSE ) + { + NPC_NowEndEventSetFlgCls( talker, atoi(buf3)); + k++; + } + } + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_YES, + CHAR_WINDOWTYPE_WINDOWEVENT_STARTMSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return; + } + } + break; +#endif + case 10: + + /*--矢永玄互中匀天中及凛及丢永本□斥--*/ + if( NPC_Util_GetStrFromStrWithDelim( buf, "PetFullMsg", + buf2, sizeof( buf2) ) + != NULL) + { + strcpysafe( token, sizeof( buf2), buf2); + print(" PetFullMsg:%s ", token); + } + else + { + print(" PetFullMsg_Error:%d ", __LINE__); + } + break; + + case 11: + /*--白仿弘毛壅允午五及丢永本□斥--*/ + if( NPC_Util_GetStrFromStrWithDelim( buf, "CleanMainMsg", + buf2, sizeof( buf2) ) + != NULL) + { + strcpysafe( token, sizeof( buf2), buf2); + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowtype = CHAR_WINDOWTYPE_WINDOWEVENT_CLEANMSG; + } + break; + case 12: + /*--白仿弘毛壅仄凶 及永本□斥--*/ + if( NPC_Util_GetStrFromStrWithDelim( buf, "CleanFlgMsg", + buf2, sizeof( buf2) ) + != NULL) + { + char buf3[64]; + int loop=1; + + strcpysafe( token, sizeof( buf2), buf2); + NPC_Util_GetStrFromStrWithDelim( buf, "CleanFlg", + buf2, sizeof( buf2) ); + while(getStringFromIndexWithDelim(buf2 , "," , loop, buf3, sizeof(buf3)) + != FALSE ) + { + NPC_NowEndEventSetFlgCls( talker, atoi(buf3)); + loop++; + } + } + break; + + case 13: + /*--云嗯互中匀天中及丢永本□斥--*/ + if( NPC_Util_GetStrFromStrWithDelim( buf, "StoneFullMsg", + buf2, sizeof( buf2) ) + != NULL) + { + strcpysafe( token, sizeof( buf2), buf2); + } + break; + + case 14: + /*--云嗯互凶曰卅中丢永本□斥--*/ + if( NPC_Util_GetStrFromStrWithDelim( buf, "StoneLessMsg", + buf2, sizeof( buf2) ) + != NULL) + { + strcpysafe( token, sizeof( buf2), buf2); + } + break; + } + + /*仇仇匹霜耨允月*/ +#ifdef _NEWEVENT + if(num != 8) +#endif + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + buttontype, + windowtype, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + +} + +/*-------------------------------------- + *奶矛件玄迕及失奶 丞毛馨笛允月 + ---------------------------------------*/ +BOOL NPC_EventAdd(int meindex,int talker,int mode) +{ + + char buf[64]; + char buff2[128]; + int j = 1,i = 0; + int kosuucnt = 0; + int itemindex; + char buff[1024*2]; + int rand_j = 0; + int rand_flg = 0; + int rand_cnt = 0; + int evcnt; + int b_flg = 0; + + /*--涩烂白央奶伙 卞踏中化丐月椭瘀毛 凶仄化中月手及毛 五请允--*/ + evcnt = NPC_EventFile( meindex, talker, buff); + + if(evcnt == -1) return FALSE; + +// if(NPC_EventFile( meindex, talker, buff) == FALSE) return FALSE; + + /*--失奶 丞及醒毛民尼永弁--*/ + if(NPC_ItemFullCheck( meindex, talker, buff, mode, evcnt) == FALSE){ + NPC_MsgDisp( meindex, talker, 4); + return FALSE; + } + + /*--云嗯民尼永弁卞 月--*/ + if(NPC_Util_GetStrFromStrWithDelim( buff, "DelStone", buff2, sizeof( buff2) ) + !=NULL) + { + int stone; + + stone = NPC_EventGetCost( meindex, talker, buff2); + + if( (CHAR_getInt( talker, CHAR_GOLD) - stone) < 0 ){ + NPC_MsgDisp( meindex, talker, 14); + return FALSE; + } + } + + + /*--矢永玄及 毛馨笛允月--*/ + if((NPC_Util_GetStrFromStrWithDelim( buff, "pet_skill", buff2, sizeof( buff2) ) + !=NULL) && mode == 0 ){ + if(mode == 0) { + NPC_PetSkillMakeStr( meindex, talker, 1); + return TRUE; + } + } + + + if(mode == 2) mode = 0; + + /*--矢永玄毛馨笛允月---*/ + if(NPC_Util_GetStrFromStrWithDelim( buff, "GetPet", buff2, sizeof( buff2) ) + !=NULL) + { + if(mode == 0){ + if(NPC_EventAddPet( meindex, talker, buff2,0) == FALSE) { + NPC_MsgDisp( meindex, talker, 10); + return FALSE; + } + }else if(mode == 1){ + + } + } + + // Robin add 从NPC取宠物蛋 + if(NPC_Util_GetStrFromStrWithDelim( buff, "GetEgg", buff2, sizeof( buff2) ) + !=NULL) + { + if(mode == 0){ + if(NPC_EventAddEgg( meindex, talker, buff2,0) == FALSE) { + print(" AddEgg_Error:%d ", __LINE__); + NPC_MsgDisp( meindex, talker, 10); + return FALSE; + } + }else if(mode == 1){ + + } + } + + if(NPC_Util_GetStrFromStrWithDelim( buff, "DelItem", buff2, sizeof( buff2) ) !=NULL){ + if(strstr(buff2,"EVDEL") != NULL){ + char work[256]; + char nbuf[256]; + + NPC_Util_GetStrFromStrWithDelim(buf, "EVENT", buff2, sizeof( buff2)); + getStringFromIndexWithDelim( buff2, ",", evcnt, work, sizeof( work)); + + if(strstr(buff,"Break")!=NULL){ + b_flg=1; + }else{ + b_flg=0; + } + + if(NPC_Util_GetStrFromStrWithDelim( buff, "NotDel", nbuf, sizeof( nbuf)) != NULL) { + NPC_EventDelItemEVDEL( meindex, talker, work, nbuf,b_flg); + }else{ + NPC_EventDelItemEVDEL( meindex, talker, work, "-1",b_flg); + } + + }else{ + if(strstr(buff,"Break")!=NULL){ + b_flg=1; + }else{ + b_flg=0; + } + + NPC_EventDelItem( meindex, talker, buff2, b_flg); + } + } + + /*--云嗯毛潸月---*/ + if(NPC_Util_GetStrFromStrWithDelim( buff, "DelStone", buff2, sizeof( buff2) ) + !=NULL) + { + int stone; + char token[128]; + + stone = NPC_EventGetCost( meindex, talker, buff2); + + CHAR_setInt(talker,CHAR_GOLD,CHAR_getInt( talker, CHAR_GOLD) - stone); + + /*--由仿丢□正霜曰--*/ + CHAR_send_P_StatusString( talker, CHAR_P_STRING_GOLD); + sprintf(token, "付出%d的stone。", stone); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + } + + + /*--仿件母丞失奶 丞---*/ + if(NPC_Util_GetStrFromStrWithDelim( buff, "GetRandItem", buf, sizeof( buf) ) != NULL ){ + j=1; + while( getStringFromIndexWithDelim( buf , "," , j, buff2, sizeof( buff2)) != FALSE ){ + j++; + rand_j++; + } + rand_cnt = 1; + } + + + /*-- 骚及失奶 丞必永玄--*/ + if(NPC_Util_GetStrFromStrWithDelim( buff, "GetItem", buf, sizeof( buf)) != NULL ){ + if(mode == 0) { + j = 1; + /*--窒蜊及失奶 丞毛 允井"--*/ + while(getStringFromIndexWithDelim( buf, "," , j, buff2, sizeof(buff2)) !=FALSE ){ + j++; + } + + j--; + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE ; i++ ){ + itemindex=CHAR_getItemIndex( talker , i ); + if( !ITEM_CHECKINDEX( itemindex) ){ + kosuucnt++; + } + } + j= j + rand_cnt; + if( kosuucnt < j ){ + NPC_MsgDisp( meindex, talker, 4); + return FALSE; + + }else{ + if(NPC_Util_GetStrFromStrWithDelim( buff, "GetRandItem", buff2, sizeof( buff2)) !=NULL) { + rand_flg = 1; + NPC_RandItemGet( meindex, talker, rand_j, buff2); + } + if(NPC_EventAddItem( meindex, talker, buf) == FALSE) return FALSE; + } + }else if(mode == 1){ + if(strstr(buff,"Break")!=NULL){ + b_flg=1; + }else{ + b_flg=0; + } + NPC_EventDelItem( meindex, talker, buf,b_flg); + } + } + + if( (NPC_Util_GetStrFromStrWithDelim( buff, "GetRandItem", buf, sizeof( buf) ) + !=NULL) && (rand_flg == 0) && mode == 0 ) + { + /*--民尼永弁 癫卞蝈 月井"-*/ + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE ; i++ ){ + itemindex=CHAR_getItemIndex( talker , i ); + if( !ITEM_CHECKINDEX( itemindex) ){ + kosuucnt++; + } + } + /*--坞五互丐月井升丹井--*/ + if( kosuucnt == 0 ){ + NPC_MsgDisp( meindex, talker, 4); + return FALSE; + } + + + NPC_RandItemGet( meindex, talker, rand_j,buf); + } + +#ifdef _EXCHANGEMAN_REQUEST_DELPET + if( NPC_Util_GetStrFromStrWithDelim( buff, "DelPet", buff2, sizeof( buff2) ) != NULL && mode == 0 ) { + char buf4[32]; + char buf5[256]; + int i=1; + char work[256]; + int j=1; + + if(strstr(buff2,"EVDEL") != NULL){ + NPC_Util_GetStrFromStrWithDelim( buf, "EVENT", buf5, sizeof( buf5)); + getStringFromIndexWithDelim( buf5, ",",evcnt , buff2, sizeof( buff2)); + while(getStringFromIndexWithDelim( buff2, "&", j, work, sizeof( work))!=FALSE){ + j++; + if(strstr( work, "PET") != NULL) { + if(strstr( work, "EV") != NULL) { + if(NPC_PetLvCheck( meindex, talker, work, 1) == FALSE) return FALSE; + }else{ + if(NPC_PetLvCheck( meindex, talker, work, 0) == FALSE) return FALSE; + } + } + } + j = 1; + while(getStringFromIndexWithDelim( buff2, "&", j, work, sizeof( work)) != FALSE){ + j++; + if(strstr( work, "PET") == NULL ) continue; + + if(strstr(work,"*") != NULL){ + int cnt=0; + int petcnt=0; + int petindex; + + getStringFromIndexWithDelim( work, "*", 2, buf4, sizeof( buf4)); + cnt = atoi(buf4); + + for(i=0 ; i < CHAR_MAXPETHAVE ; i++){ + petindex = CHAR_getCharPet( talker, i); + + if( petindex == -1 ) continue; + + if(strstr( work, "EV") != NULL) { + if(NPC_PetLvCheckType2(petindex, meindex, talker, work, 1) + == FALSE) { + continue; + } + }else{ + if(NPC_PetLvCheckType2(petindex, meindex, talker, work, 0) == FALSE) { + continue; + } + } + + if(NPC_EventDelPet( meindex, talker,i) == FALSE) return FALSE; + + petcnt++; + /*--隙烂蜊醒坌及矢永玄毛壅仄凶井升丹井"--*/ + if(cnt == petcnt) break; + + } + }else{ + /*--矢永玄毛绰轮允月醒毛隙烂仄化卅中及匹竟癫矢永玄毛蝈化壅允--*/ + + int petindex; + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + petindex = CHAR_getCharPet( talker, i); + + if( !CHAR_CHECKINDEX( petindex) ) continue; + + if(strstr( buff2, "EV") != NULL){ + if(NPC_PetLvCheckType2( petindex, meindex, talker, work, 1) == FALSE){ + continue; + } + }else{ + if(NPC_PetLvCheckType2( petindex, meindex, talker, work, 0) == FALSE) { + continue; + } + } + + if(NPC_EventDelPet( meindex, talker, i) == FALSE) return FALSE; + } + } + } + + }else{ + /*--手丹1蘸}矢永玄毛 匀化中月井及民尼永弁毛垫丹--*/ + while(getStringFromIndexWithDelim( buff2, ",", j, work, sizeof( work)) + !=FALSE) + { + j++; + /*--矢永玄及民尼永弁互反中匀化中月桦宁反域绎PET椭瘀毛民尼永弁允月 --*/ + if(strstr( work, "PET") != NULL) { + if(strstr( work, "EV") != NULL) { + if(NPC_PetLvCheck( meindex, talker, work, 1) == FALSE) return FALSE; + }else{ + if(NPC_PetLvCheck( meindex, talker, work, 0) == FALSE) return FALSE; + } + } + } + j = 1; + + while(getStringFromIndexWithDelim( buff2, ",", j, work, sizeof( work)) != FALSE) + { + j++; + if(strstr(work,"*") != NULL) + { + int cnt=0; + int petcnt=0; + int petindex; + + getStringFromIndexWithDelim( work, "*", 2, buf4, sizeof( buf4)); + cnt = atoi(buf4); + + for(i=0 ; i < CHAR_MAXPETHAVE ; i++){ + petindex = CHAR_getCharPet( talker, i); + + if( petindex == -1 ) continue; + + if(strstr( work, "EV") != NULL) { + if(NPC_PetLvCheckType2(petindex, meindex, talker, work, 1) == FALSE) { + continue; + } + }else{ + if(NPC_PetLvCheckType2(petindex, meindex, talker, work, 0) == FALSE) { + continue; + } + } + + if(NPC_EventDelPet( meindex, talker,i) == FALSE) return FALSE; + + petcnt++; + /*--隙烂蜊醒坌及矢永玄毛壅仄凶井升丹井"--*/ + if(cnt == petcnt) break; + } + }else{ + /*--矢永玄毛绰轮允月醒毛隙烂仄化卅中及匹竟癫矢永玄毛蝈化壅允--*/ + + int petindex; + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + petindex = CHAR_getCharPet( talker, i); + + if( !CHAR_CHECKINDEX( petindex) ) continue; + + if(strstr( buff2, "EV") != NULL){ + if(NPC_PetLvCheckType2( petindex, meindex, talker, work, 1) == FALSE){ + continue; + } + }else{ + if(NPC_PetLvCheckType2( petindex, meindex, talker, work, 0) == FALSE) { + continue; + } + } + if(NPC_EventDelPet( meindex, talker, i) == FALSE) return FALSE; + } + } + } + } + } +#endif + return TRUE; + +} + + +/*-------------------------------------- + *仿件母丞匹失奶 丞毛必永玄今六月 + ------------------------------------ */ +BOOL NPC_RandItemGet(int meidex,int talker,int rand_j,char *buf) +{ + char buff2[64]; + int randitem; + int ret; + int itemindex; + char token[128]; + + if(rand_j == 0) { + print("Event:由於0的介入,出现错误。"); + return FALSE; + } + + randitem = rand()%rand_j; + if(randitem == 0) randitem = rand_j; + + getStringFromIndexWithDelim(buf , "," , randitem, buff2, sizeof(buff2)) ; + + itemindex = ITEM_makeItemAndRegist( atoi( buff2)); + + if(itemindex == -1) return FALSE; + + /*失奶 丞及馨笛( 涛失奶 丞 卞中木化仄引丹 */ + ret = CHAR_addItemSpecificItemIndex( talker, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + print( "npc_exchangeman.c: additem error itemindex[%d]\n", itemindex); + ITEM_endExistItemsOne( itemindex); + return FALSE; + } + + if(itemindex != -1) { + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), /* 失奶 丞 寞 */ +#endif + "EventAddItem(任务需求所得到的道具)", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + + sprintf(token,"收下了%s",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + + CHAR_sendItemDataOne( talker, ret); + return TRUE; + +} + + +/*---------------------------------------------------- + * 奶矛件玄 + ----------------------------------------------------*/ +BOOL NPC_AcceptDel(int meindex,int talker,int mode ) +{ + + char buf[1024*2]; + char buff2[256]; + int rand_j = 0; + int j = 0; + int evcnt; + int b_flg = 0; + evcnt = NPC_EventFile( meindex, talker, buf); + if(evcnt == -1) return FALSE; + + /*--涩烂白央奶伙 卞井井木化中月椭瘀毛 凶仄化中月手及毛 五请允--*/ +// if(NPC_EventFile(meindex,talker,buf)==FALSE) return FALSE; + + /*--失奶 丞及醒毛民尼永弁--*/ + if(NPC_ItemFullCheck( meindex, talker, buf, mode, evcnt) == FALSE){ + NPC_MsgDisp( meindex, talker, 4); + return FALSE; + } + + /*--云嗯民尼永弁卞 月--*/ + if(NPC_Util_GetStrFromStrWithDelim( buf, "DelStone", buff2, sizeof( buff2) ) + !=NULL) + { + int stone; + stone = NPC_EventGetCost( meindex, talker, buff2); + + if( (CHAR_getInt( talker, CHAR_GOLD) - stone) < 0 ) { + NPC_MsgDisp( meindex, talker, 14); + return FALSE; + } + } + + + /*--云嗯民尼永弁卞 月--*/ + if(NPC_Util_GetStrFromStrWithDelim( buf, "GetStone", buff2, sizeof( buff2) )!=NULL){ + int stone; + stone = atoi(buff2); + + if( (CHAR_getInt( talker, CHAR_GOLD) + stone) >= CHAR_getMaxHaveGold( talker) ) { + NPC_MsgDisp( meindex, talker, 13); + return FALSE; + } + } + + + /*--矢永玄及 毛馨笛允月--*/ + if((NPC_Util_GetStrFromStrWithDelim( buf, "pet_skill", buff2, sizeof( buff2) ) + !=NULL) && mode == 0 ){ + if(mode == 0){ + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD, 1); + NPC_PetSkillMakeStr( meindex, talker, 1); + return TRUE; + } + } + + /*--矢永玄毛壅允---*/ + if(NPC_Util_GetStrFromStrWithDelim( buf, "DelPet", buff2, sizeof( buff2) ) != NULL) { + char buf4[32]; + char buf5[256]; + int i=1; + char work[256]; + int j=1; + + if(strstr(buff2,"EVDEL") != NULL){ + NPC_Util_GetStrFromStrWithDelim( buf, "EVENT", buf5, sizeof( buf5)); + getStringFromIndexWithDelim( buf5, ",",evcnt , buff2, sizeof( buff2)); + + + /*--手丹1蘸}矢永玄毛 匀化中月井及民尼永弁毛垫丹--*/ + while(getStringFromIndexWithDelim( buff2, "&", j, work, sizeof( work)) + !=FALSE) + { + j++; + + /*--矢永玄及民尼永弁互反中匀化中月桦宁反域绎PET椭瘀毛民尼永弁允月 --*/ + if(strstr( work, "PET") != NULL) { + if(strstr( work, "EV") != NULL) { + if(NPC_PetLvCheck( meindex, talker, work, 1) == FALSE) return FALSE; + }else{ + if(NPC_PetLvCheck( meindex, talker, work, 0) == FALSE) return FALSE; + } + } + } + j = 1; + + + while(getStringFromIndexWithDelim( buff2, "&", j, work, sizeof( work)) + != FALSE) + { + j++; + if(strstr( work, "PET") == NULL ) continue; + + if(strstr(work,"*") != NULL) + { + int cnt=0; + int petcnt=0; + int petindex; + + getStringFromIndexWithDelim( work, "*", 2, buf4, sizeof( buf4)); + cnt = atoi(buf4); + + for(i=0 ; i < CHAR_MAXPETHAVE ; i++){ + petindex = CHAR_getCharPet( talker, i); + + if( petindex == -1 ) continue; + + if(strstr( work, "EV") != NULL) { + if(NPC_PetLvCheckType2(petindex, meindex, talker, work, 1) + == FALSE) { + continue; + } + }else{ + if(NPC_PetLvCheckType2(petindex, meindex, talker, work, 0) + == FALSE) { + continue; + } + } + + if(NPC_EventDelPet( meindex, talker,i) == FALSE) return FALSE; + + petcnt++; + /*--隙烂蜊醒坌及矢永玄毛壅仄凶井升丹井"--*/ + if(cnt == petcnt) break; + + } + }else{ + /*--矢永玄毛绰轮允月醒毛隙烂仄化卅中及匹竟癫矢永玄毛蝈化壅允--*/ + + int petindex; + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + petindex = CHAR_getCharPet( talker, i); + + if( !CHAR_CHECKINDEX( petindex) ) continue; + + if(strstr( buff2, "EV") != NULL){ + if(NPC_PetLvCheckType2( petindex, meindex, talker, work, 1) + == FALSE){ + continue; + } + }else{ + if(NPC_PetLvCheckType2( petindex, meindex, talker, work, 0) + == FALSE) { + continue; + } + } + + if(NPC_EventDelPet( meindex, talker, i) == FALSE) return FALSE; + } + } + } + + }else{ + + /*--手丹1蘸}矢永玄毛 匀化中月井及民尼永弁毛垫丹--*/ + while(getStringFromIndexWithDelim( buff2, ",", j, work, sizeof( work)) + !=FALSE) + { + j++; + /*--矢永玄及民尼永弁互反中匀化中月桦宁反域绎PET椭瘀毛民尼永弁允月 --*/ + if(strstr( work, "PET") != NULL) { + if(strstr( work, "EV") != NULL) { + if(NPC_PetLvCheck( meindex, talker, work, 1) == FALSE) return FALSE; + }else{ + if(NPC_PetLvCheck( meindex, talker, work, 0) == FALSE) return FALSE; + } + } + } + j = 1; + + + while(getStringFromIndexWithDelim( buff2, ",", j, work, sizeof( work)) + != FALSE) + { + j++; + if(strstr(work,"*") != NULL) + { + int cnt=0; + int petcnt=0; + int petindex; + + getStringFromIndexWithDelim( work, "*", 2, buf4, sizeof( buf4)); + cnt = atoi(buf4); + + for(i=0 ; i < CHAR_MAXPETHAVE ; i++){ + petindex = CHAR_getCharPet( talker, i); + + if( petindex == -1 ) continue; + + if(strstr( work, "EV") != NULL) { + if(NPC_PetLvCheckType2(petindex, meindex, talker, work, 1) + == FALSE) { + continue; + } + }else{ + if(NPC_PetLvCheckType2(petindex, meindex, talker, work, 0) + == FALSE) { + continue; + } + } + + if(NPC_EventDelPet( meindex, talker,i) == FALSE) return FALSE; + + petcnt++; + /*--隙烂蜊醒坌及矢永玄毛壅仄凶井升丹井"--*/ + if(cnt == petcnt) break; + + } + }else{ + /*--矢永玄毛绰轮允月醒毛隙烂仄化卅中及匹竟癫矢永玄毛蝈化壅允--*/ + + int petindex; + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) { + petindex = CHAR_getCharPet( talker, i); + + if( !CHAR_CHECKINDEX( petindex) ) continue; + + if(strstr( buff2, "EV") != NULL){ + if(NPC_PetLvCheckType2( petindex, meindex, talker, work, 1) + == FALSE){ + continue; + } + }else{ + if(NPC_PetLvCheckType2( petindex, meindex, talker, work, 0) + == FALSE) { + continue; + } + } + + if(NPC_EventDelPet( meindex, talker, i) == FALSE) return FALSE; + } + } + } + } + } + + + + /*--云嗯毛丐仆月---*/ + if(NPC_Util_GetStrFromStrWithDelim( buf, "GetStone", buff2, sizeof( buff2) ) + !=NULL) + { + int stone; + char token[128]; + + stone = atoi(buff2); + CHAR_setInt(talker,CHAR_GOLD,CHAR_getInt( talker, CHAR_GOLD) + stone); + /*--由仿丢□正霜曰--*/ + CHAR_send_P_StatusString( talker, CHAR_P_STRING_GOLD); + + sprintf( token,"得到%d的stone", stone); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + } + + + /*--矢永玄毛馨笛允月---*/ + if(NPC_Util_GetStrFromStrWithDelim( buf, "GetPet", buff2, sizeof( buff2) ) + !=NULL) + { + if(NPC_EventAddPet( meindex, talker, buff2,1) == FALSE) { + NPC_MsgDisp( meindex, talker, 10); + return FALSE; + } + } + + // Robin add 从NPC取宠物蛋 + if(NPC_Util_GetStrFromStrWithDelim( buf, "GetEgg", buff2, sizeof( buff2) ) + !=NULL) + { + if(NPC_EventAddEgg( meindex, talker, buff2,1) == FALSE) { + print(" AddEgg_Error:%d ", __LINE__); + NPC_MsgDisp( meindex, talker, 10); + return FALSE; + } + } + + /*--失奶 丞毛壅允--*/ + if(NPC_Util_GetStrFromStrWithDelim( buf, "DelItem", buff2, sizeof( buff2) ) != NULL){ + if(strstr(buff2,"EVDEL") != NULL){ + char work[256]; + char nbuf[256]; + + NPC_Util_GetStrFromStrWithDelim(buf, "EVENT", buff2, sizeof( buff2)); + getStringFromIndexWithDelim( buff2, ",", evcnt, work, sizeof( work)); + + if(strstr(buf,"Break")!=NULL){ + b_flg=1; + }else{ + b_flg=0; + } + + if(NPC_Util_GetStrFromStrWithDelim( buf, "NotDel", nbuf, sizeof( nbuf)) != NULL ){ + NPC_EventDelItemEVDEL( meindex, talker, work, nbuf,b_flg); + }else{ + NPC_EventDelItemEVDEL( meindex, talker, work, "-1",b_flg); + } + }else{ + if(strstr(buf,"Break")!=NULL){ + b_flg=1; + }else{ + b_flg=0; + } + NPC_EventDelItem( meindex, talker, buff2,b_flg); + } + } + + + /*--云嗯毛潸月---*/ + if(NPC_Util_GetStrFromStrWithDelim( buf, "DelStone", buff2, sizeof( buff2) ) + !=NULL) + { + int stone; + char token[128]; + + stone = NPC_EventGetCost( meindex, talker, buff2); + + CHAR_setInt(talker,CHAR_GOLD,CHAR_getInt( talker, CHAR_GOLD) - stone); + /*--由仿丢□正霜曰--*/ + CHAR_send_P_StatusString( talker, CHAR_P_STRING_GOLD); + sprintf( token, "付出%d的stone。", stone); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + } + + + /*--仿件母丞失奶 丞毛馨笛允月---*/ + if(NPC_Util_GetStrFromStrWithDelim( buf, "GetRandItem", buff2, sizeof( buff2) ) + !=NULL) + { + char buf3[32]; + j = 1; + while(getStringFromIndexWithDelim(buff2 , "," , j, buf3, sizeof( buf3)) + != FALSE ) + { + j++; + rand_j++; + } + NPC_RandItemGet( meindex, talker, rand_j, buff2); + } + + + /*--失奶 丞毛馨笛允月---*/ + if(NPC_Util_GetStrFromStrWithDelim( buf, "GetItem", buff2, sizeof( buff2) ) + !=NULL) + { + NPC_EventAddItem( meindex, talker, buff2); + } + + /*--由仿丢□正及霜耨--*/ + CHAR_complianceParameter( talker ); + CHAR_send_P_StatusString( talker , + CHAR_P_STRING_ATK|CHAR_P_STRING_DEF| + CHAR_P_STRING_CHARM|CHAR_P_STRING_QUICK| + CHAR_P_STRING_WATER|CHAR_P_STRING_FIRE| + CHAR_P_STRING_WIND|CHAR_P_STRING_EARTH + ); + + return TRUE; + +} + + +/*-------------------------- + * 奶矛件玄矢永玄毛绰轮 + ---------------------------*/ +BOOL NPC_EventDelPet(int meindex,int talker, int petsel) +{ + + int petindex; + char szPet[128]; + int defpet; + char msgbuf[64]; + + int fd = getfdFromCharaIndex( talker ); + + petindex = CHAR_getCharPet( talker, petsel); + + if( !CHAR_CHECKINDEX(petindex) ) return FALSE; + + if( CHAR_getInt( talker, CHAR_RIDEPET) == petsel ) { + + //CHAR_talkToCli( talker, -1, "骑乘中的宠物无法交出!", CHAR_COLORYELLOW ); + //return FALSE; + + CHAR_setInt( talker, CHAR_RIDEPET, -1); + CHAR_send_P_StatusString( talker, CHAR_P_STRING_RIDEPET ); + CHAR_complianceParameter( talker ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( talker , CHAR_WORKOBJINDEX )); + print(" DelRidePet "); + } + print(" EventDelPet "); + + /*--公及平乓仿互爵 卅日}矢永玄毛丹日内蔽 --*/ + if( CHAR_getWorkInt( CONNECT_getCharaindex( fd), + CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) return FALSE; + /*--公及矢永玄互田玄伙井升丹井及民尼永弁--*/ + defpet = CHAR_getInt( talker, CHAR_DEFAULTPET); + if(defpet == petsel){ + CHAR_setInt( talker, CHAR_DEFAULTPET, -1); + lssproto_KS_send( fd, -1, TRUE); + } + + snprintf( msgbuf,sizeof( msgbuf), "交出%s。", + CHAR_getChar( petindex, CHAR_NAME)); + CHAR_talkToCli( talker, -1, msgbuf, CHAR_COLORWHITE); + + // 矢永玄毛澎 仄凶夫弘 + LogPet( + CHAR_getChar( talker, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( talker, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "EvnetDell(任务删除)", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + + + /* 切 井日壅允 */ + CHAR_setCharPet( talker, petsel, -1); + + CHAR_endCharOneArray( petindex ); + + snprintf( szPet, sizeof( szPet ), "K%d", petsel); + // 蕙仄中矢永玄旦 □正旦霜曰勾仃月 + CHAR_sendStatusString( talker, szPet ); + + return TRUE; + +} + + +/*---------------------------- + * 矢永玄毛馨笛允月 + ------------------------------*/ +BOOL NPC_EventAddPet(int meindex, int talker, char *buff2,int mode) +{ + int ret; + char msgbuf[64]; + int enemynum; + int enemyid; + int i; + int petindex; + + /*--矢永玄 互钒中化中月井及民尼永弁--*/ + for( i = 0 ;i < CHAR_MAXPETHAVE ; i++) { + petindex = CHAR_getCharPet( talker, i); + if( petindex == -1 ) break; + } + + if(i == CHAR_MAXPETHAVE) return FALSE; + + + /* 娄醒及ID井日index毛潸 */ + if(strstr(buff2,",") != NULL){ + char buf2[16]; + while(getStringFromIndexWithDelim( buff2, ",", i, buf2, sizeof( buf2)) + != FALSE) { + i++; + } + i--; + i = rand()%i + 1; + getStringFromIndexWithDelim( buff2, ",", i, buf2, sizeof( buf2)); + enemyid = atoi( buf2); + }else{ + enemyid = atoi( buff2); + } + + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == enemyid) { + break; + } + } + + if( i == enemynum ) return FALSE; + + ret = ENEMY_createPetFromEnemyIndex( talker, i); + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + if( CHAR_getCharPet( talker, i ) == ret )break; + } + if( i == CHAR_MAXPETHAVE ) i = 0; + if( CHAR_CHECKINDEX( ret ) == TRUE ){ + CHAR_setMaxExpFromLevel( ret, CHAR_getInt( ret, CHAR_LV )); + } + + petindex = CHAR_getCharPet(talker,i); + + if( !CHAR_CHECKINDEX( petindex) )return FALSE; + CHAR_complianceParameter( petindex ); + snprintf( msgbuf, sizeof( msgbuf ), "K%d", i ); + CHAR_sendStatusString( talker, msgbuf ); + + snprintf( msgbuf, sizeof( msgbuf ), "W%d", i ); + CHAR_sendStatusString( talker, msgbuf ); + snprintf( msgbuf,sizeof( msgbuf), "拿到%s。", + CHAR_getChar(petindex,CHAR_NAME)); + CHAR_talkToCli( talker, -1, msgbuf, CHAR_COLORWHITE); + + // 矢永玄毛澎卞 木凶夫弘 + LogPet( + CHAR_getChar( talker, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( talker, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "EventGet(任务得到)", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + + + + if(mode == 0) { + /*--奶矛件玄迕及矢永玄--*/ + CHAR_setInt( petindex, CHAR_ENDEVENT, 1); + } + + return TRUE; + +} + +// Robin add NPC给宠物蛋 +BOOL NPC_EventAddEgg(int meindex, int talker, char *buff2,int mode) +{ + int ret; + char msgbuf[64]; + int enemynum; + int enemyid; + int petid; + int raise; + int i; + int petindex; + char buf2[32]; + char buf3[32]; + + print("\n 给蛋啦!!:%s ", buff2); + + /*--矢永玄 互钒中化中月井及民尼永弁--*/ + for( i = 0 ;i < CHAR_MAXPETHAVE ; i++) { + petindex = CHAR_getCharPet( talker, i); + if( petindex == -1 ) break; + } + + if(i == CHAR_MAXPETHAVE) { + print(" AddEgg_Error:%d ", __LINE__); + return FALSE; + } + + + /* 娄醒及ID井日index毛潸 */ + if(strstr(buff2,",") != NULL){ // 是否为随机给与 + while(getStringFromIndexWithDelim( buff2, ",", i, buf2, sizeof( buf2)) + != FALSE) { + i++; + } + i--; + i = rand()%i + 1; + getStringFromIndexWithDelim( buff2, ",", i, buf2, sizeof( buf2)); + + }else{ + strcpy( buf2, buff2); + } + + getStringFromIndexWithDelim( buf2, ";", 1, buf3, sizeof( buf3)); + enemyid = atoi( buf3); // 宠物蛋ID + getStringFromIndexWithDelim( buf2, ";", 2, buf3, sizeof( buf3)); + petid = atoi( buf3); // 孵出的宠物ID + getStringFromIndexWithDelim( buf2, ";", 3, buf3, sizeof( buf3)); + raise = atoi( buf3); // 养次数 + + + // 将enemyid转成enemybaseid + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == petid) { + break; + } + } + if( i == enemynum ) { + print(" AddEgg_Error:%d ", __LINE__); + return FALSE; + } + petid = ENEMY_getInt( i, ENEMY_TEMPNO); + + + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == enemyid) { + break; + } + } + if( i == enemynum ) { + print(" AddEgg_Error:%d ", __LINE__); + return FALSE; + } + + ret = ENEMY_createPetFromEnemyIndex( talker, i); + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + if( CHAR_getCharPet( talker, i ) == ret )break; + } + if( i == CHAR_MAXPETHAVE ) i = 0; + if( CHAR_CHECKINDEX( ret ) == TRUE ){ + CHAR_setMaxExpFromLevel( ret, CHAR_getInt( ret, CHAR_LV )); + } + + petindex = CHAR_getCharPet(talker,i); + + if( !CHAR_CHECKINDEX( petindex) ) { + print(" AddEgg_Error:%d ", __LINE__); + return FALSE; + } + + // 设为宠物蛋 + CHAR_setInt( petindex, CHAR_FUSIONBEIT, 1); + CHAR_setInt( petindex, CHAR_FUSIONCODE, -1); + CHAR_setInt( petindex, CHAR_FUSIONRAISE, raise); + CHAR_setInt( petindex, CHAR_FUSIONINDEX, petid); + CHAR_setInt( petindex, CHAR_FUSIONTIMELIMIT, (int)time( NULL)); + + CHAR_complianceParameter( petindex ); + snprintf( msgbuf, sizeof( msgbuf ), "K%d", i ); + CHAR_sendStatusString( talker, msgbuf ); + + snprintf( msgbuf, sizeof( msgbuf ), "W%d", i ); + CHAR_sendStatusString( talker, msgbuf ); + snprintf( msgbuf,sizeof( msgbuf), "拿到%s。", + CHAR_getChar(petindex,CHAR_NAME)); + CHAR_talkToCli( talker, -1, msgbuf, CHAR_COLORWHITE); + + // 矢永玄毛澎卞 木凶夫弘 + LogPet( + CHAR_getChar( talker, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( talker, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "EventGetEgg(任务得到)", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + + + + if(mode == 0) { + /*--奶矛件玄迕及矢永玄--*/ + CHAR_setInt( petindex, CHAR_ENDEVENT, 1); + } + + return TRUE; + +} + + +/*--------------------------- + * 奶矛件玄 毛绰轮允月 + -----------------------------**/ +BOOL NPC_EventDelItem(int meindex,int talker,char *buf,int breakflg) +{ + + int i = 1, j = 1, k = 1 ; + char buff3[128]; + char buf2[32]; + int itemindex; + char token[256]; + + while(getStringFromIndexWithDelim(buf , "," , k, buff3, sizeof(buff3)) + !=FALSE ) + { + k++; + if(strstr(buff3,"*") != NULL) { + int itemno; + int kosuu; + int id; + int cnt=0; + + getStringFromIndexWithDelim( buff3, "*", 1, buf2, sizeof( buf2)); + itemno = atoi( buf2); + getStringFromIndexWithDelim( buff3, "*", 2, buf2, sizeof( buf2)); + kosuu = atoi( buf2); + + if( breakflg != 1 ) + NPC_ActionDoPileDelItem( talker, itemno, kosuu);//有堆叠的处理 + else{ + for( i =0 ; i < CHAR_MAXITEMHAVE ; i++ ){ + itemindex = CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX( itemindex) ) { + id = ITEM_getInt( itemindex , ITEM_ID ); + if(itemno == id) { + cnt++; + LogItem( + CHAR_getChar( talker, CHAR_NAME ), // 平乓仿 + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), // 失奶 丞 寞 +#endif + "EventDelItem(任务需求所收回的道具)", + CHAR_getInt( talker, CHAR_FLOOR), + CHAR_getInt( talker, CHAR_X ), + CHAR_getInt( talker, CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + + if(breakflg == 1){ + sprintf(token,"%s 坏了",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + }else{ + sprintf(token,"交出%s",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + } + //--失奶 丞毛坫诮-- + CHAR_setItemIndex( talker, i ,-1); + ITEM_endExistItemsOne(itemindex); + CHAR_sendItemDataOne( talker, i); + + if(cnt == kosuu){ + break; + } + } + } + } + } + } + else{ + /*--蓟氏分 寞及失奶 丞毛蓟请---*/ + for( j = 0 ; j < CHAR_MAXITEMHAVE ; j++){ + itemindex = CHAR_getItemIndex( talker ,j); + + if( ITEM_CHECKINDEX( itemindex)){ + if( atoi( buff3) == ITEM_getInt( itemindex, ITEM_ID)) { + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), /* 失奶 丞 寞 */ +#endif + "EventDelItem(任务需求所收回的道具)", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + if(breakflg == 1){ + sprintf(token,"%s 坏了",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + }else{ + sprintf( token, "交出%s。", + ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + } + /*--失奶 丞毛坫诮--*/ + CHAR_setItemIndex( talker, j ,-1); + ITEM_endExistItemsOne( itemindex); + /*--由仿丢□正霜耨--*/ + CHAR_sendItemDataOne( talker, j); + } + } + } + } + } + + return TRUE; +} + +BOOL NPC_EventDelItemEVDEL(int meindex,int talker,char *buf,char *nbuf,int breakflg) +{ + + int k = 1, l = 1; + char buff3[128]; + char buf2[32]; + char buf4[32]; + + + + while(getStringFromIndexWithDelim(buf , "&" , k, buf4, sizeof(buf4)) !=FALSE ){ + int itemno; + k++; + if(strstr(buf4,"ITEM") == NULL) continue; + getStringFromIndexWithDelim(buf4 , "=" , 2, buff3, sizeof(buff3)); + + if(strstr(buff3,"*") != NULL) { + int kosuu; +#ifndef _ITEM_PILENUMS + char token[256]; + int i, itemindex, id, cnt; +#endif + getStringFromIndexWithDelim( buff3, "*", 1, buf2, sizeof( buf2)); + itemno = atoi( buf2); + getStringFromIndexWithDelim( buff3, "*", 2, buf2, sizeof( buf2)); + kosuu = atoi( buf2); + if(strstr(nbuf,"-1") == NULL){ + l = 1; + while(getStringFromIndexWithDelim(nbuf , "," , l, buf2, sizeof(buf2))){ + l++; + if(itemno == atoi( buf2)){ + l = -1; + break; + } + } + if(l == -1) continue; + } +#ifdef _ITEM_PILENUMS + NPC_ActionDoPileDelItem( talker, itemno, kosuu); +#else + cnt = 0; + for( i =0 ; i < CHAR_MAXITEMHAVE ; i++ ){ + itemindex = CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX( itemindex) ) { + id = ITEM_getInt( itemindex , ITEM_ID ); + if(itemno == id) { + cnt++; + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), /* 失奶 丞 寞 */ +#endif + "EventDelItem(任务需求所收回的道具)", + CHAR_getInt( talker, CHAR_FLOOR), + CHAR_getInt( talker, CHAR_X ), + CHAR_getInt( talker, CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + if(breakflg == 1){ + sprintf(token,"%s 坏了",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + }else{ + sprintf(token,"交出%s",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + } + CHAR_setItemIndex( talker, i ,-1); + ITEM_endExistItemsOne(itemindex); + CHAR_sendItemDataOne( talker, i); + if(cnt == kosuu){ + break; + } + } + } + } +#endif + }else{ +#ifndef _ITEM_PILENUMS + int j, itemindex; + char token[256]; +#endif + if(strstr(nbuf,"-1") == NULL){ + l = 1; + while(getStringFromIndexWithDelim(nbuf , "," , l, buf2, sizeof(buf2))){ + l++; + if(atoi(buff3) == atoi( buf2)){ + l = -1; + break; + } + } + if(l == -1) continue; + } + itemno = -1; +#ifdef _ITEM_PILENUMS + NPC_ActionDoPileDelItem( talker, itemno, itemno); +#else + for( j = 0 ; j < CHAR_MAXITEMHAVE ; j++){ + itemindex = CHAR_getItemIndex( talker ,j); + if( ITEM_CHECKINDEX( itemindex)){ + if( atoi( buff3) == ITEM_getInt( itemindex, ITEM_ID)) { + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), /* 失奶 丞 寞 */ +#endif + "EventDelItem(任务需求所收回的道具)", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + if(breakflg == 1){ + sprintf(token,"%s 坏了",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + }else{ + sprintf( token, "交出%s。", + ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + } + CHAR_setItemIndex( talker, j ,-1); + ITEM_endExistItemsOne( itemindex); + CHAR_sendItemDataOne( talker, j); + } + } + } +#endif + } + } + + return TRUE; +} + + +/*---------------------- + * 奶矛件玄 毛馨笛] + -----------------------*/ +BOOL NPC_EventAddItem(int meindex,int talker,char *buf) +{ + + char buff3[128]; + int i = 1; + int itemindex; + char buf3[32]; + int ret; + char token[256]; + + while(getStringFromIndexWithDelim(buf , "," , i, buff3, sizeof( buff3)) + != FALSE ) + { + i++; + if(strstr( buff3, "*") != NULL) { + + int itemno; + int kosuu; + int loop = 0; + + getStringFromIndexWithDelim( buff3, "*", 1, buf3,sizeof( buf3)); + itemno = atoi( buf3); + getStringFromIndexWithDelim( buff3, "*", 2, buf3,sizeof( buf3)); + kosuu = atoi( buf3); + + for(loop = 0 ; loop < kosuu ; loop++) { + itemindex = ITEM_makeItemAndRegist( itemno); + + if(itemindex == -1) return FALSE; + + /*失奶 丞及馨笛( 涛失奶 丞 卞中木化仄引丹 */ + ret = CHAR_addItemSpecificItemIndex( talker, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + print("npc_exchange:ACCEPTadditem error itemindex[%d]\n",itemindex); + ITEM_endExistItemsOne( itemindex); + return FALSE; + } + + if(itemindex != -1) { + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), /* 失奶 丞 寞 */ +#endif + "EventAddItem(任务需求所得到的道具)", + CHAR_getInt( talker, CHAR_FLOOR), + CHAR_getInt( talker, CHAR_X ), + CHAR_getInt( talker, CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + sprintf( token, "拿到%s。", ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + + CHAR_sendItemDataOne( talker, ret); + } + }else{ + itemindex = ITEM_makeItemAndRegist( atoi( buff3)); + + if(itemindex == -1) return FALSE; + + /*失奶 丞及馨笛( 涛失奶 丞 卞中木化仄引丹 */ + ret = CHAR_addItemSpecificItemIndex( talker, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + print( "npc_exchange.c: ACCEPTadditem error itemindex[%d]\n", itemindex); + ITEM_endExistItemsOne( itemindex); + return FALSE; + } + + if(itemindex != -1) { + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), /* 失奶 丞 寞 */ +#endif + "EventAddItem(任务需求所得到的道具)", + CHAR_getInt( talker, CHAR_FLOOR), + CHAR_getInt( talker, CHAR_X ), + CHAR_getInt( talker, CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + sprintf(token,"拿到%s。", ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + + CHAR_sendItemDataOne( talker, ret); + } + } + + return TRUE; +} + + +/*--------------------------------- + *椭瘀毛 凶仄化中月及毛 五请允 + ------------- ---------------------*/ +int NPC_EventFile(int meindex,int talker,char *arg) +{ + + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff2[256]; + char buf[1024*2]; + int i=1; + int EvNo=0; + int evch; + + /*--涩烂白央奶伙毛 心 戈--*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + + print("GetArgStrErr"); + return -1; + } + + /*涩烂白央奶伙毛坌喃允月*/ + while(getStringFromIndexWithDelim( argstr, "EventEnd", i, buf,sizeof( buf)) + != FALSE) + { + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTSEC, 0); + i++; + /*--奶矛件玄瓜件田□毛必永玄--*/ + NPC_Util_GetStrFromStrWithDelim( buf, "EventNo", buff2,sizeof( buff2) ); + EvNo = atoi( buff2); + + /*--白仿弘民尼永弁毛垫丹[允匹卞}仇及奶矛件玄互蔽 仄化中月桦宁反戚尺--*/ + if(NPC_EventCheckFlg( talker, EvNo) == TRUE) continue; + + /*--平□伐□玉及民尼永弁毛垫丹--*/ + if(NPC_Util_GetStrFromStrWithDelim( buf,"Pet_Name", buff2,sizeof( buff2) ) + != NULL) + { + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTSEC, 1); + } + /*--平□伐□玉及民尼永弁毛垫丹--*/ + if(NPC_Util_GetStrFromStrWithDelim( buf,"KeyWord", buff2,sizeof( buff2) ) + != NULL) + { + if(CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANT) != i ) continue; + } + + evch = NPC_ExChangeManEventCheck( meindex, talker, buf); + + if(evch != -1) { + /*--奶矛件玄椭瘀及民尼永弁--*/ +// if(NPC_ExChangeManEventCheck( meindex, talker, buf) == TRUE) { + strcpysafe(arg, sizeof( buf) ,buf); + return evch; + } + } + + return -1; + +} + + +/*--------------------------------- + * 失奶 丞及民尼永弁分仃毛垫丹 + -----------------------------------*/ +BOOL NPC_EventReduce(int meindex,int talker,char *buf) +{ + + char buf2[512]; + char buf3[256]; + int id = 0; + int i; + int itemindex; + int itemno; + int kosuu; + int cnt = 0; + + getStringFromIndexWithDelim( buf, "=", 2, buf2, sizeof( buf2)); + getStringFromIndexWithDelim( buf2, "*", 1, buf3, sizeof( buf3)); + itemno = atoi( buf3); + getStringFromIndexWithDelim( buf2, "*", 2, buf3, sizeof( buf3)); + kosuu = atoi( buf3); + + for( i = 0 ; i < CHAR_MAXITEMHAVE ; i++ ){ + itemindex = CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX( itemindex) ){ + id = ITEM_getInt( itemindex ,ITEM_ID); + if(itemno == id){ + //change add 增加对堆叠的判断 + int pilenum = ITEM_getInt( itemindex, ITEM_USEPILENUMS); + if( pilenum ) + cnt+=pilenum; + else + cnt++; + + if(cnt >= kosuu){ + return TRUE; + } + } + } + } + + return FALSE; + +} + +/*---------------------------------- + *矢永玄卞旦平伙毛创尹今六月 + ----------------------------------*/ +void NPC_EventPetSkill( int meindex, int talker, char *data) +{ + + int skill; + int pet; + int slot; + int cost; + int skillID = 0; + char buf[64]; + char argstr[1024]; + char msg[512]; + int petindex; + char msgbuf[128]; + int fd = getfdFromCharaIndex( talker ); + int evcnt; + + if( NPC_Util_CharDistance( talker, meindex ) > 2) { + return; + } + + evcnt = NPC_EventFile( meindex, talker, argstr); + + if(evcnt == -1) return; + + /*--涩烂白央奶伙 卞妪井k伊 中月椭瘀毛 凶仄化中月手及毛 五请允--*/ +// if(NPC_EventFile( meindex, talker, argstr) == FALSE) return ; + + /*弁仿奶失件玄井日忒匀化仁月犯□正--*/ + /*升及 毛尹日氏分井"(蓟 寞) 升及矢永玄井"(蓟 寞) + 升及旦夫永玄井"(蓟 寞) 袄蟾*/ + makeStringFromEscaped( data); + + /*--犯□正及蕊曰坌仃--*/ + getStringFromIndexWithDelim( data, "|", 1, buf, sizeof( buf)); + skill = atoi( buf); + getStringFromIndexWithDelim( data, "|", 2, buf, sizeof( buf)); + pet = atoi( buf); + getStringFromIndexWithDelim( data, "|", 3, buf ,sizeof( buf)); + slot = atoi(buf); + getStringFromIndexWithDelim( data, "|", 4, buf, sizeof( buf)); + cost = atoi( buf); + + /*--旦平伙 毛必永玄允月--*/ + if( NPC_Util_GetStrFromStrWithDelim( argstr, "pet_skill", + msg, sizeof( msg)) != NULL) + { + getStringFromIndexWithDelim( msg, ",", skill, buf ,sizeof( buf)); + skillID = atoi( buf); + } + slot--; + + + petindex = CHAR_getCharPet( talker, pet-1); + + if(petindex == -1){ + print("PetindexErr"); + return; + } + + /*--公及平乓仿互爵 卅日}矢永玄毛丹日内蔽 --*/ + if( CHAR_getWorkInt( CONNECT_getCharaindex( fd), + CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) return ; + + /*--矢永玄卞 毛创尹今六月--*/ + CHAR_setPetSkill( petindex, slot, skillID); + + /*--云嗯毛蛹日允--*/ + CHAR_setInt( talker, CHAR_GOLD, (CHAR_getInt( talker, CHAR_GOLD) - cost)); + + snprintf( msgbuf, sizeof( msgbuf ), "W%d",pet-1); + + // 蕙仄中矢永玄及 犯□正毛霜曰勾仃月 + CHAR_sendStatusString( talker, msgbuf ); + + CHAR_sendStatusString( talker, "P"); + +} + + +/*---------------------------------------- + * 失奶 丞互中匀天中井升丹井及民尼永弁 +----------- ------------------------------*/ +BOOL NPC_ItemFullCheck(int meindex,int talker,char *buf,int mode,int evcnt) +{ + + char buff2[256]; + int i = 1,j = 1; + int maxitem = 0; + int kosuucnt = 0; + int itemindex; + char buf3[256]; + int rand_j = 0; + int rand_cnt = 0; + char nbuf[256]; + char buff6[16]; + int l = 1; + + if(NPC_Util_GetStrFromStrWithDelim( buf, "DelItem", buff2, sizeof( buff2) ) != NULL ){ + if(strstr(buff2,"EVDEL") != NULL){ + char buff4[64]; + char buff5[32]; + + i = 1; + NPC_Util_GetStrFromStrWithDelim( buf, "EVENT", buff2, sizeof( buff2)); + getStringFromIndexWithDelim(buff2, "," , evcnt, buf3, sizeof(buf3)); + + while(getStringFromIndexWithDelim(buf3, "&" , j, buff4, sizeof(buff4))){ + j++; + if(strstr(buff4,"ITEM") != NULL) { + if(strstr(buff4,"*") != NULL) { + int itemno; + + l = 1; + getStringFromIndexWithDelim(buff4, "=" , 2, buff5, sizeof(buff5)); + getStringFromIndexWithDelim(buff5, "*" , 1, buff6, sizeof(buff6)); + itemno = atoi(buff6); + + if(NPC_Util_GetStrFromStrWithDelim( buf, "NotDel", nbuf, sizeof( nbuf)) !=NULL){ + while(getStringFromIndexWithDelim(nbuf , "," , l,buff6, sizeof(buff6))) + { + l++; + if(itemno == atoi( buff6)) + { + l = -1; + break; + } + } + } + if(l == -1) continue; + getStringFromIndexWithDelim(buff5, "*" , 2, buff6, sizeof(buff6)); + maxitem -= atoi( buff6); + }else{ + getStringFromIndexWithDelim(buff4, "=" , 2, buff5, sizeof(buff5)); + l = 1; + + if(NPC_Util_GetStrFromStrWithDelim( buf, "NotDel", nbuf, sizeof( nbuf)) + !=NULL){ + while(getStringFromIndexWithDelim(nbuf , "," , l,buff6, sizeof(buff6))) { + l++; + if(atoi(buff5) == atoi( buff6)){ + l = -1; + break; + } + } + } + if(l == -1) continue; + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE ; i++ ) { + itemindex = CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX( itemindex)) { + if(atoi( buff5) == ITEM_getInt( itemindex, ITEM_ID)) { + maxitem--; + } + } + } + } + } + } + }else{ + char buff3[128]; + i = 1; + while(getStringFromIndexWithDelim(buff2, "," , i, buff3, sizeof(buff3)) !=FALSE ){ + i++; + if(strstr( buff3, "*") != NULL){ + getStringFromIndexWithDelim( buff3, "*", 2, buf3, sizeof( buf3)); + maxitem -= atoi( buf3); + }else{ + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE ; i++ ) { + itemindex=CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX( itemindex)) { + if(atoi( buff3) == ITEM_getInt( itemindex, ITEM_ID)) { + maxitem--; + } + } + } + } + } + + } + } + + if(NPC_Util_GetStrFromStrWithDelim( buf, "GetRandItem", buff2, sizeof( buff2) ) !=NULL && mode == 0){ + j = 1; + while(getStringFromIndexWithDelim(buff2 , "," , j, buf3, sizeof( buf3)) !=FALSE ){ + j++; + rand_j++; + } + rand_cnt = 1; + for( i = CHAR_STARTITEMARRAY ; i +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "configfile.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "npc_familyman.h" +#include "family.h" + +extern int familyNumTotal; +extern char familyListBuf[MAXFAMILYLIST]; + +char sendbuf[1024]; +char buf[1024]; +char subbuf[128]; +int i, j; + +/* + * 涩烂今木凶它奴件玉它毛请允NPC + * 棵哑 平旦玄失玉矛件民乓□仁日中卅日综木月井手[ + * + */ + +struct { + int windowno; + int windowtype; + int buttontype; + int takeitem; + int giveitem; + char message[4096]; +}w; + +struct { + BOOL use; + int checkhaveitem; + int checkhaveitemgotowin; + int checkdonthaveitem; + int checkdonthaveitemgotowin; + int warp; + int battle; + int gotowin; +}buttonproc[13]; /* ok,cancel, yes,no,prev,next 及凛及质 */ + + + + + +enum { + CHAR_WORK_MSGCOLOR = CHAR_NPCWORKINT1, +}; +static void NPC_Familyman_selectWindow( int meindex, int toindex, int num); +static BOOL NPC_Familyman_readData( int meindex, int windowno, BOOL chkflg); +static int NPC_Familyman_restoreButtontype( char *data ); + +/********************************* +* 赓渝质 +*********************************/ +BOOL NPC_FamilymanInit( int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024]; + //int i; + //char secondToken[1024]; + + // Robin test + // print(" familyman_Init "); + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "conff", buf, sizeof( buf)) + == NULL ) + { + print( "familyman:没有指定设定的档案 。\n"); + return FALSE; + } + /* 赓渝凛卞涩烂犯□正毛民尼永弁仄化支月 */ + if( !NPC_Familyman_readData( meindex, -1, TRUE) ) { + return FALSE; + } + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEWINDOWMAN ); + + return TRUE; +} + + + + +/********************************* +* 仄井仃日木凶凛及质 +*********************************/ +void NPC_FamilymanTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + + NPC_Familyman_selectWindow( meindex, talkerindex, 1 ); + +} +/********************************* +* 苇日木凶凛及质 +*********************************/ +void NPC_FamilymanLooked( int meindex , int lookedindex) +{ + + print(" Look:me:%d,looked:%d ",meindex,lookedindex); + NPC_Familyman_selectWindow( meindex, lookedindex,1 ); + +} + +static void NPC_Familyman_selectWindow( int meindex, int toindex, int num) +{ + + int fd; + char buf[256]; + + /* 皿伊奶乩□卞覆仄化分仃 杀允月 */ + if( CHAR_getInt( toindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + /* ㄠ弘伉永玉动 及心 */ + if( !NPC_Util_charIsInFrontOfChar( toindex, meindex, 1 )) return; + + if( !NPC_Familyman_readData( meindex, num, FALSE) ) { + print( "familyman:readdata error\n"); + return; + } + + fd = getfdFromCharaIndex( toindex); + if( fd != -1 ) { + lssproto_WN_send( fd, w.windowtype, + w.buttontype, + w.windowno+100, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( w.message, buf, sizeof(buf))); + + } +} + +void NPC_FamilymanWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) + +{ + + int button = -1; + char buf[256]; + + /* ㄠ弘伉永玉动 及心 */ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) return; + + // CoolFish Add For Check Old Leader Del Family + if(seqno == CHAR_WINDOWTYPE_FAMILYMAN_OUT) + { + int fd = getfdFromCharaIndex( talkerindex); + if(select == WINDOW_BUTTONTYPE_YES) + FAMILY_Leave( fd, talkerindex, "E|1"); + return; + } + // CoolFish End + + /* 仇及它奴件玉它 寞及犯□正毛 心 戈 */ + if( !NPC_Familyman_readData( meindex, seqno - 100, FALSE) ) { + print( "familyman:readdata error\n"); + return; + } + /* 瓷仄凶示正件毛譬屯月 */ + if( w.windowtype == WINDOW_MESSAGETYPE_SELECT ) { + button = atoi( data)+5; + if( button > 12 ) { + print( "familyman:invalid button[%d]\n", button); + return; + } + } + else if( select & WINDOW_BUTTONTYPE_OK) button = 0; + else if( select & WINDOW_BUTTONTYPE_CANCEL) button = 1; + else if( select & WINDOW_BUTTONTYPE_YES) button = 2; + else if( select & WINDOW_BUTTONTYPE_NO) button = 3; + else if( select & WINDOW_BUTTONTYPE_PREV) button = 4; + else if( select & WINDOW_BUTTONTYPE_NEXT) button = 5; + else { + print( "familyman:invalid button[%d]\n", select); + return; + } + if( buttonproc[button].use == TRUE ) { + int fd; + int newwin = -1; + + fd = getfdFromCharaIndex( talkerindex); + + /* 示正件卞方匀化质 毛孔曰歹仃月 */ + if( newwin == -1 ) { + newwin = buttonproc[button].gotowin; + } + + // Robin + // 成立 + if( newwin == 5 ) { + if( CHAR_getInt( talkerindex, CHAR_FMINDEX ) > 0 ) + { + //CHAR_talkToCli( talkerindex, -1, "资格不符!已经加入家族。", CHAR_COLORWHITE ); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\n很抱歉喔!你已经加入家族了!", buf, sizeof(buf))); + return; + } + if( (CHAR_getInt( talkerindex, CHAR_TRANSMIGRATION ) == 0) + && (CHAR_getInt( talkerindex, CHAR_LV) < 30) ) + { + //CHAR_talkToCli( talkerindex, -1, "很抱歉!等级不足。", CHAR_COLORWHITE ); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\n很抱歉喔!你的等级不足!", buf, sizeof(buf))); + return; + } + + if( !NPC_EventCheckFlg( talkerindex, 4 ) ) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\n很抱歉喔!你必须先完成成人礼才行!", buf, sizeof(buf))); + return; + } + + if( CHAR_getInt( talkerindex, CHAR_GOLD ) < 10000 ) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\n很抱歉喔!你的申请手续费不足!", buf, sizeof(buf))); + return; + } + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_FAMILYADD, WINDOW_BUTTONTYPE_NONE, CHAR_WINDOWTYPE_FAMILYMAN_ADD, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), "Hello!!" ); + + return; + } + // 列表 , 加入 + if( newwin == 6 ) + { + /* + strcpy( buf, ""); + j = 0; + for( i=1 ; i<=8 ; i++ ) { + if( i > familyNumTotal ) break; + if( getStringFromIndexWithDelim( familyListBuf, "|", i, subbuf, + sizeof(subbuf) ) == FALSE) break; + strcat( buf, "|" ); + strcat( buf, subbuf ); + j++; + } + + sprintf( sendbuf, "S|F|%d|%d|%d%s", familyNumTotal, 1, j, buf ); + //print(" FL:%s ", sendbuf ); + lssproto_FM_send( fd, sendbuf ); + */ + + //saacproto_ACShowFMList_send( acfd ); + + FAMILY_Detail( fd, talkerindex, "S|F|1|0" ); + return; + + } + // 退出 + if( newwin == 7 ) + { + if( CHAR_getInt( talkerindex, CHAR_FMINDEX ) == -1 ) { + // CHAR_talkToCli( talkerindex, -1, "你还未加入任何家族呀。", CHAR_COLORWHITE ); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\n很抱歉喔!你还没有加入任何家族呀!", buf, sizeof(buf))); + return; + } + + //if (CHAR_getInt(talkerindex, CHAR_FMLEADERFLAG) == FMMEMBER_LEADER) { + // CHAR_talkToCli( talkerindex, -1, "族长....", CHAR_COLORWHITE ); + // return; + //} + + print(" WN2FM "); + + // CoolFish Change for old leader del family check + if(CHAR_getInt(talkerindex, CHAR_FMLEADERFLAG) == FMMEMBER_LEADER) + { + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_YESNO, CHAR_WINDOWTYPE_FAMILYMAN_OUT, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + makeEscapeString("\n您现在是这个家族的族长喔...\n\n家族解散了就无法再救回唷!~\n\n确定要解散家族吗?",buf, sizeof(buf))); + return; + } + else + FAMILY_Leave( fd, talkerindex, "E|1"); + // CoolFish Change End + + return; + } + + if( !NPC_Familyman_readData( meindex, newwin, FALSE) ) { + print( "familyman:readdata error\n"); + return; + } +#if 0 + +#endif + + //fd = getfdFromCharaIndex( talkerindex); + if( fd != -1 ) { + lssproto_WN_send( fd, w.windowtype, + w.buttontype, + w.windowno+100, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( w.message, buf, sizeof(buf))); + } + + + + } +} +/* + * 涩烂白央奶伙毛 氏匹隙烂今木凶windowno及犯□正毛本永玄允月 + * + * 娄醒“ + * meindex int 仇及NPC及charaindex + * windowno int 它奴件玉它 寞 + * + */ +static BOOL NPC_Familyman_readData( int meindex, int windowno, BOOL chkflg) +{ + + int i; + int linenum = 0; + int endflg = FALSE; + int buttonendflg; + int winno = -1; + int buttonconfmode; + int b_mode; + int selectnum ; + int messagepos; + BOOL errflg = FALSE; + BOOL readflg = TRUE; + FILE *fp; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char filename[64]; + char opfile[128]; + char line[1024]; + char firstToken[1024]; + char secondToken[1024]; + + /* 它奴件玉它及涩烂毛 曰 戈厌瞻 */ + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + /* 涩烂白央奶伙 潸 */ + NPC_Util_GetStrFromStrWithDelim( argstr, "conff", filename, sizeof( filename)); + + sprintf( opfile, "%s/", getNpcdir( ) ); + strcat( opfile, filename); + + fp = fopen( opfile, "r"); + if( fp == NULL ) { + print( "familyman:file open error [%s]\n", opfile); + return FALSE; + } + + while( readflg == TRUE ) { + endflg = FALSE; + buttonendflg = TRUE; + buttonconfmode = FALSE; + selectnum = 0; + messagepos = 0; + winno = -1; + b_mode = -1; + errflg = FALSE; + + /* 赓渝祭 */ + w.windowno = -1; + w.windowtype = -1; + w.buttontype = -1; + w.takeitem = -1; + w.giveitem = -1; + w.message[0] = '\0'; + + for( i = 0; i < arraysizeof( buttonproc); i ++ ) { + buttonproc[i].use = FALSE; + buttonproc[i].checkhaveitem = -1; + buttonproc[i].checkhaveitemgotowin = -1; + buttonproc[i].checkdonthaveitem = -1; + buttonproc[i].checkdonthaveitemgotowin = -1; + buttonproc[i].warp = -1; + buttonproc[i].battle = -1; + buttonproc[i].gotowin = -1; + } + + while( 1) { + char buf[256]; + int ret; + if( !fgets( line, sizeof( line), fp)){ + readflg = FALSE; + break; + } + + linenum ++; + + /* 戊丢件玄反 骰 */ + if( line[0] == '#' || line[0] == '\n') continue; + /* 荼垫潸月 */ + chomp( line ); + + /* 垫毛帮溥允月 */ + /* 引内 tab 毛 " " 卞 五晶尹月 */ + replaceString( line, '\t' , ' ' ); + /* 燮 及旦矢□旦毛潸月[*/ + for( i = 0; i < strlen( line); i ++) { + if( line[i] != ' ' ) { + break; + } + strcpy( buf, &line[i]); + } + if( i != 0 ) strcpy( line, buf); + + /* delim "=" 匹 赓(1)及玄□弁件毛 月*/ + ret = getStringFromIndexWithDelim( line, "=", 1, firstToken, + sizeof( firstToken ) ); + if( ret == FALSE ){ + print( "Find error at %s in line %d. Ignore\n", + filename , linenum); + continue; + } + /* delim "=" 匹2 及玄□弁件毛 月*/ + ret = getStringFromIndexWithDelim( line, "=", 2, secondToken, + sizeof( secondToken ) ); + if( ret == FALSE ){ + print( "Find error at %s in line %d. Ignore\n", + filename , linenum); + continue; + } + + if( strcasecmp( firstToken, "winno") == 0 ) { + if( winno != -1 ) { + print( "familyman:已有winno却重新定义winno\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + readflg = FALSE; + break; + } + /* 它奴件玉它No毛忡绣 */ + winno = atoi( secondToken); + continue; + } + /* 它奴件玉它No 互瑁引匀化中卅中凛及垫反 骰允月 */ + if( winno == -1 ) { + print( "familyman:winno 尚未定义,资料却已设定。\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + readflg = FALSE; + errflg = FALSE; + break; + } + /* 它奴件玉它No 互域谯仄凶凛反椭瘀毛 戈[ + * 公木动陆反 骰允月 */ + if( (chkflg == FALSE && winno == windowno )|| + chkflg == TRUE) + { + if( buttonconfmode == TRUE ) { + if( strcasecmp( firstToken, "gotowin") == 0 ) { + buttonproc[b_mode].gotowin = atoi( secondToken); + } + else if( strcasecmp( firstToken, "checkhaveitem") == 0 ) { + buttonproc[b_mode].checkhaveitem = atoi( secondToken); + } + else if( strcasecmp( firstToken, "haveitemgotowin") == 0 ) { + buttonproc[b_mode].checkhaveitemgotowin = atoi( secondToken); + } + else if( strcasecmp( firstToken, "checkdonthaveitem") == 0 ) { + buttonproc[b_mode].checkdonthaveitem = atoi( secondToken); + } + else if( strcasecmp( firstToken, "donthaveitemgotowin") == 0 ) { + buttonproc[b_mode].checkdonthaveitemgotowin = atoi( secondToken); + } + else if( strcasecmp( firstToken, "endbutton") == 0 ) { + if( buttonproc[b_mode].gotowin == - 1 ) { + if( buttonproc[b_mode].checkhaveitem == -1 && + buttonproc[b_mode].checkdonthaveitem == -1) + { + errflg = TRUE; + } + else { + /* 升匀切井井凶匀吊分仃匹手涩烂今木化中木壬 */ + if( !((buttonproc[b_mode].checkhaveitem != -1 && + buttonproc[b_mode].checkhaveitemgotowin != -1) + || (buttonproc[b_mode].checkdonthaveitem != -1 && + buttonproc[b_mode].checkdonthaveitemgotowin != -1))) + { + errflg = TRUE; + } + } + } + + if( errflg == TRUE) { + print( "familyman: 找不到gotowin\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + readflg = FALSE; + errflg = TRUE; + break; + } + buttonproc[b_mode].use = TRUE; + buttonconfmode = FALSE; + buttonendflg = TRUE; + } + } + else { + + w.windowno = winno; + /* 它奴件玉它正奶皿及涩烂 */ + if( strcasecmp( firstToken, "wintype") == 0 ) { + w.windowtype = atoi( secondToken); + } + /* 示正件正奶皿及涩烂 */ + else if( strcasecmp( firstToken, "buttontype") == 0 ) { + w.buttontype = NPC_Familyman_restoreButtontype( secondToken); + } + /* getitem及涩烂 */ + else if( strcasecmp( firstToken, "takeitem") == 0 ) { + w.takeitem = atoi( secondToken); + } + /* giveitem及涩烂 */ + else if( strcasecmp( firstToken, "giveitem") == 0 ) { + w.giveitem = atoi( secondToken); + } + /* message及涩烂 */ + else if( strcasecmp( firstToken, "message") == 0 ) { + if( messagepos == 0 ) { + strcpy( w.message, secondToken); + messagepos = strlen( w.message); + } + else { + w.message[messagepos]='\n'; + messagepos++; + strcpy( &w.message[messagepos], secondToken); + messagepos+=strlen(secondToken); + } + } + /* 示正件毛瓷仄凶凛及涩烂 */ + else if( strcasecmp( firstToken, "okpressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 0; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "cancelpressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 1; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "yespressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 2; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "nopressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 3; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "prevpressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 4; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "nextpressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 5; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "selected") == 0 ) { + buttonconfmode = TRUE; + b_mode = 6 + selectnum; + buttonendflg = FALSE; + selectnum ++; + } + /* 涩烂蔽歹曰 */ + else if( strcasecmp( firstToken, "endwin") == 0 ) { + endflg = TRUE; + if( chkflg == FALSE) { + readflg = FALSE; + } + break; + } + else { + print( "familyman:设定是不可能的参数\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + } + } + } + else { + if( strcasecmp( firstToken, "endwin") == 0 ) { + winno = -1; + } + } + } + if( buttonendflg == FALSE) { + print( "familyman: 找不到endbutton\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + break; + } + if( winno != -1 ) { + if( w.windowtype == -1 ) { + print( "familyman: 找不到wintype\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + break; + } + if( w.buttontype == -1 ) { + print( "familyman: 找不到button\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + break; + } + if( strlen( w.message) == 0 ) { + print( "familyman: 找不到message\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + break; + } + } + } + fclose( fp); + + if( chkflg == FALSE && w.windowno == -1 ) { + print( "familyman: 找不到所指定的windowno\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + return FALSE; + } + if( winno != -1 && endflg == FALSE) { + print( "familyman: 找不到endwin\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + return FALSE; + } + if( errflg == TRUE) return FALSE; + + return TRUE; +} +/* + * buttontype=匹隙烂仄凶 侬 毛醒袄卞 晶允月[ + * + */ +static int NPC_Familyman_restoreButtontype( char *data ) +{ + int ret = 0; + int rc; + int i; + char buff[1024]; + + for( i = 1; ; i ++ ) { + rc = getStringFromIndexWithDelim( data, "|", i, buff, + sizeof( buff ) ); + if( rc == FALSE) break; + if( strcasecmp( buff, "ok") == 0 ) { + ret |= WINDOW_BUTTONTYPE_OK; + } + else if( strcasecmp( buff, "cancel") == 0 ) { + ret |= WINDOW_BUTTONTYPE_CANCEL; + } + else if( strcasecmp( buff, "yes") == 0 ) { + ret |= WINDOW_BUTTONTYPE_YES; + } + else if( strcasecmp( buff, "no") == 0 ) { + ret |= WINDOW_BUTTONTYPE_NO; + } + else if( strcasecmp( buff, "prev") == 0 ) { + ret |= WINDOW_BUTTONTYPE_PREV; + } + else if( strcasecmp( buff, "next") == 0 ) { + ret |= WINDOW_BUTTONTYPE_NEXT; + } + } + if( ret == 0 ) { + ret = atoi( data); + } + return ret; +} + + diff --git a/gmsv/npc/npc_fmchallenge.c b/gmsv/npc/npc_fmchallenge.c new file mode 100644 index 0000000..b45e914 --- /dev/null +++ b/gmsv/npc/npc_fmchallenge.c @@ -0,0 +1,776 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "lssproto_serv.h" +#include "npcutil.h" +#include "handletime.h" +#include "npc_fmchallenge.h" +#include "family.h" + +// 全部的家族 pk 赛程 +enum { + NPC_WORK_ID = CHAR_NPCWORKINT1, // 登记员 ID, 从 0 开始 +}; + +enum { + CHAR_WORK_PAGE = CHAR_WORKSHOPRELEVANT, // 换页用 + CHAR_WORK_DUELTIME = CHAR_WORKSHOPRELEVANTSEC, // 所选择的 pk 时间 +}; + +#define SCHEDULEFILEDIR "./Schedule/" + +void NPC_LoadPKSchedule(int meindex); // Load schedule from disk +void NPC_SavePKSchedule(int meindex); // save schedule to disk +// 产生排程表的 data +void NPC_LIST_gendata(int meindex, int talkerindex, int page, char *buf, int size); +// 产生选择家族的 data +void NPC_SELECT_gendata(int meindex, int page, char *buf, int size); +// 产生排程详细的 data +void NPC_DETAIL_gendata(int meindex, char *buf, int size, int dueltime); + +BOOL NPC_SchedulemanInit( int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + int meid; + int interval; + + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_TYPEFMSCHEDULEMAN ); + CHAR_setWorkInt ( meindex, NPC_WORK_PREVIOUSCHECKTIME, -1); + + // 参数 + NPC_Util_GetArgStr(meindex, argstr, sizeof(argstr)); + meid = NPC_Util_GetNumFromStrWithDelim(argstr, "id" ); + if ((meid<0) || (meid>=MAX_SCHEDULEMAN)) { + print("SCHEDULEMAN init error: invalid ID(%d)\n",meid); + meid=0; + } + CHAR_setWorkInt(meindex, NPC_WORK_ID, meid); + + interval = NPC_Util_GetNumFromStrWithDelim(argstr, "loopinterval" ); + if ((interval<100) || (interval>10000)) interval=1000; + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, interval); + + interval = NPC_Util_GetNumFromStrWithDelim(argstr, "challengetimeout"); + if ((interval<60) || (interval>60*60)) interval=20*60; + CHAR_setWorkInt(meindex, NPC_WORK_CHALLENGETIMEOUT, interval); + + interval = NPC_Util_GetNumFromStrWithDelim(argstr, "settingtimeout"); + if ((interval<10) || (interval>60*60)) interval=60; + CHAR_setWorkInt(meindex, NPC_WORK_SETTINGTIMEOUT, interval); + + interval = NPC_Util_GetNumFromStrWithDelim(argstr, "fightinterval"); + if ((interval<5) || (interval>60)) interval = 50; + CHAR_setWorkInt(meindex, NPC_WORK_FIGHTINTERVAL, interval); + + NPC_LoadPKSchedule(meindex); + + return TRUE; +} + +void NPC_SchedulemanTalked(int meindex, int talkerindex, char *msg, int color) +{ +// CHAR_talkToCli(talkerindex, meindex, "你好,我是家族PK登记员。", color); + +#if 0 + char buf[4096]; + int page; + + if (NPC_Util_CharDistance(meindex,talkerindex) > 2) return; + + if (strncmp(msg,"list",4)==0) { + CHAR_talkToCli(talkerindex, meindex, "显示将送出的 WN PKSCHEDULELIST data。", color); + page=atoi(&msg[4]); + + NPC_RemoveExpiredBattle(meindex); + NPC_LIST_gendata(meindex, talkerindex, page, buf, sizeof(buf)); + + CHAR_talkToCli(talkerindex, -1, buf, CHAR_COLORWHITE); + } else if (strncmp(msg,"select",6)==0) { + CHAR_talkToCli(talkerindex, meindex, "显示将送出的 WN PKSCHEDULESELECTFAMILY data。", color); + page=atoi(&msg[6]); + + NPC_SELECT_gendata(meindex, page, buf, sizeof(buf)); + + CHAR_talkToCli(talkerindex, -1, buf, CHAR_COLORWHITE); + } else if (strncmp(msg,"detail",6)==0) { + page=atoi(&msg[6]); + + CHAR_talkToCli(talkerindex, meindex, "显示将送出的 WN PKSCHEDULEDETAIL data。", color); + + NPC_DETAIL_gendata(meindex, buf, sizeof(buf), page); + + CHAR_talkToCli(talkerindex, -1, buf, CHAR_COLORWHITE); + } else { + CHAR_talkToCli(talkerindex, meindex, "你好,我是家族PK登记员。", color); + sprintf(buf, "我的 ID 是 %d (最大 %d)。", + CHAR_getWorkInt(meindex, NPC_WORK_ID), MAX_SCHEDULEMAN-1); + CHAR_talkToCli(talkerindex, meindex, buf, color); + CHAR_talkToCli(talkerindex, meindex, "目前测试中,测试指令:list,select,detail", color); + CHAR_talkToCli(talkerindex, meindex, "请下令。", color); + } +#endif + + char buf[4096]; + int fd; + + if (NPC_Util_CharDistance(meindex, talkerindex) > 2) return; + if (!NPC_Util_isFaceToFace(meindex, talkerindex, 2)) return; + fd = getfdFromCharaIndex(talkerindex); + if (fd == -1) return; + + CHAR_setWorkInt(talkerindex, CHAR_WORK_PAGE, 0); + NPC_LIST_gendata(meindex, talkerindex, 0, buf, sizeof(buf)); + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_PKSCHEDULELIST, + WINDOW_BUTTONTYPE_NEXT | WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_SCHEDULEMAN_START, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); +} + +void NPC_SchedulemanWindowTalked(int meindex, int talkerindex, + int seqno, int select, char *data) +{ + int page; + int buttontype; + char buf[4096],token[256]; + int fd,i,dt,a; + int fmpks_pos; + + if (NPC_Util_CharDistance(meindex,talkerindex) > 2) return; + if (!NPC_Util_isFaceToFace(meindex, talkerindex, 2)) return; + fd = getfdFromCharaIndex(talkerindex); + if (fd == -1) return; + fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID)*MAX_SCHEDULE; + +// print("seqno=%d select=%d data=%s\n", seqno,select,data); + + switch (seqno) { + case CHAR_WINDOWTYPE_SCHEDULEMAN_START: + switch (select) { + case WINDOW_BUTTONTYPE_NEXT: + case WINDOW_BUTTONTYPE_PREV: + page=CHAR_getWorkInt(talkerindex, CHAR_WORK_PAGE) + + MAXSCHEDULEINONEWINDOW + * (( select == WINDOW_BUTTONTYPE_NEXT) ? 1 : -1); + buttontype=WINDOW_BUTTONTYPE_NEXT | WINDOW_BUTTONTYPE_PREV | WINDOW_BUTTONTYPE_CANCEL; + if (page<0) { + page=0; + buttontype=WINDOW_BUTTONTYPE_NEXT | WINDOW_BUTTONTYPE_CANCEL; + } + if (page>MAX_SCHEDULE-MAXSCHEDULEINONEWINDOW) { + page=MAX_SCHEDULE-MAXSCHEDULEINONEWINDOW; + buttontype=WINDOW_BUTTONTYPE_PREV | WINDOW_BUTTONTYPE_CANCEL; + } + CHAR_setWorkInt(talkerindex, CHAR_WORK_PAGE, page); + // Send WN + NPC_LIST_gendata(meindex, talkerindex, page, buf, sizeof(buf)); + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_PKSCHEDULELIST, + buttontype, + CHAR_WINDOWTYPE_SCHEDULEMAN_START, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + break; + case WINDOW_BUTTONTYPE_OK: + +#ifdef _DEATH_FAMILY_CANT_SCHEDULE // WON ADD 家族战玩家不能自行约战 + CHAR_talkToCli(talkerindex, meindex, "此星球无法约战", CHAR_COLORWHITE); + break; +#endif + + if ((CHAR_getInt(talkerindex,CHAR_FMLEADERFLAG)==FMMEMBER_LEADER) && + (CHAR_getWorkInt(talkerindex, CHAR_WORKFMSETUPFLAG)==1)) { + // 只有已成立家族的族长可以使用进一步的功能 (设定、更改、同意) + + // decide: send family list or detail or accept + dt=atoi(data); + for (i=0; iMAXFAMILYINONEWINDOW) + buttontype |= WINDOW_BUTTONTYPE_NEXT; + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_PKSCHEDULESELECTFAMILY, + buttontype, + CHAR_WINDOWTYPE_SCHEDULEMAN_SELECT, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + } + break; + case FMPKS_FLAG_CHALLENGE: + { // 主队族长可以重设条件,客队则是同意 pk,其他人滚蛋 + int tkfmindex=CHAR_getInt(talkerindex, CHAR_FMINDEX); + if (tkfmindex==fmpks[fmpks_pos+i].host_index) { + fmpks[fmpks_pos+i].flag=FMPKS_FLAG_SETTING; + fmpks[fmpks_pos+i].setting_timeout= + CHAR_getWorkInt(meindex, NPC_WORK_SETTINGTIMEOUT); + // 送出细部调整的列表 + CHAR_setWorkInt(talkerindex, CHAR_WORK_DUELTIME, dt); + NPC_DETAIL_gendata(meindex, buf, sizeof(buf), dt); + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_PKSCHEDULEDETAIL, + WINDOW_BUTTONTYPE_OK | WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_SCHEDULEMAN_DETAIL, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + } else if (tkfmindex==fmpks[fmpks_pos+i].guest_index) { + fmpks[fmpks_pos+i].flag=FMPKS_FLAG_SCHEDULED; + page=CHAR_getWorkInt(talkerindex, CHAR_WORK_PAGE); + buttontype=WINDOW_BUTTONTYPE_NEXT | WINDOW_BUTTONTYPE_PREV | WINDOW_BUTTONTYPE_OK; + if (page<0) { + page=0; + buttontype=WINDOW_BUTTONTYPE_NEXT | WINDOW_BUTTONTYPE_OK; + } + if (page>MAX_SCHEDULE-MAXSCHEDULEINONEWINDOW) { + page=MAX_SCHEDULE-MAXSCHEDULEINONEWINDOW; + buttontype=WINDOW_BUTTONTYPE_PREV | WINDOW_BUTTONTYPE_OK; + } + CHAR_talkToCli(talkerindex, meindex, + "你的家族已经接受挑战。", CHAR_COLORWHITE); + // 重新送出 list + NPC_LIST_gendata(meindex, talkerindex, page, buf, sizeof(buf)); + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_PKSCHEDULELIST, + buttontype, + CHAR_WINDOWTYPE_SCHEDULEMAN_START, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + } + } + break; + case FMPKS_FLAG_SETTING: + { // 主队族长可以重设条件 + int tkfmindex=CHAR_getInt(talkerindex, CHAR_FMINDEX); + if (tkfmindex==fmpks[fmpks_pos+i].host_index) { + fmpks[fmpks_pos+i].flag=FMPKS_FLAG_SETTING; + fmpks[fmpks_pos+i].setting_timeout= + CHAR_getWorkInt(meindex, NPC_WORK_SETTINGTIMEOUT); + // 送出细部调整的列表 + CHAR_setWorkInt(talkerindex, CHAR_WORK_DUELTIME, dt); + NPC_DETAIL_gendata(meindex, buf, sizeof(buf), dt); + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_PKSCHEDULEDETAIL, + WINDOW_BUTTONTYPE_OK | WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_SCHEDULEMAN_DETAIL, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + } + } + } + break; + } + } + NPC_SavePKSchedule(meindex); + } else { + + if (CHAR_getInt(talkerindex,CHAR_FMLEADERFLAG)!=FMMEMBER_LEADER) { + CHAR_talkToCli(talkerindex, meindex, + "只有族长才能预约家族PK喔。", CHAR_COLORWHITE); + } else if (CHAR_getWorkInt(talkerindex, CHAR_WORKFMSETUPFLAG)!=1) { + CHAR_talkToCli(talkerindex, meindex, + "你的家族还没有正式成立喔。", CHAR_COLORWHITE); + } + } + + break; + } + break; + case CHAR_WINDOWTYPE_SCHEDULEMAN_SELECT: + switch (select) { + case WINDOW_BUTTONTYPE_PREV: + case WINDOW_BUTTONTYPE_NEXT: + page=CHAR_getWorkInt(talkerindex, CHAR_WORK_PAGE) + + MAXFAMILYINONEWINDOW + * (( select == WINDOW_BUTTONTYPE_NEXT) ? 1 : -1); + buttontype=WINDOW_BUTTONTYPE_NEXT | WINDOW_BUTTONTYPE_PREV; + if (page<1) { + page=1; + buttontype=WINDOW_BUTTONTYPE_NEXT; + } + if (page>familyNumTotal-MAXFAMILYINONEWINDOW+1) { + page=familyNumTotal-MAXFAMILYINONEWINDOW+1; + buttontype=WINDOW_BUTTONTYPE_PREV; + } + CHAR_setWorkInt(talkerindex, CHAR_WORK_PAGE, page); + // Send WN + NPC_SELECT_gendata(meindex, page, buf, sizeof(buf)); + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_PKSCHEDULESELECTFAMILY, + buttontype, + CHAR_WINDOWTYPE_SCHEDULEMAN_SELECT, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + break; + case WINDOW_BUTTONTYPE_OK: +#ifdef _FMVER21 + if ((CHAR_getInt(talkerindex,CHAR_FMLEADERFLAG)==FMMEMBER_LEADER) && +#else + if ((CHAR_getInt(talkerindex,CHAR_FMLEADERFLAG)==1) && +#endif + (CHAR_getWorkInt(talkerindex, CHAR_WORKFMSETUPFLAG)==1)) { + dt=CHAR_getWorkInt(talkerindex, CHAR_WORK_DUELTIME); + for (i=0; i0) && (a<=40)) fmpks[fmpks_pos+i].prepare_time=a; + } + // 最大人数 + if (getStringFromIndexWithDelim(data,"|",5,token,sizeof(token))) { + a=atoi(token); + if ((a>0) && (a<=50)) fmpks[fmpks_pos+i].max_player=a; + } + fmpks[fmpks_pos+i].flag=FMPKS_FLAG_CHALLENGE; + fmpks[fmpks_pos+i].challenge_timeout= + CHAR_getWorkInt(meindex, NPC_WORK_CHALLENGETIMEOUT); + CHAR_talkToCli(talkerindex, meindex, + "家族挑战设定完成。", CHAR_COLORWHITE); + } + break; + case WINDOW_BUTTONTYPE_CANCEL: + fmpks[fmpks_pos+i].flag=FMPKS_FLAG_NONE; + CHAR_talkToCli(talkerindex, meindex, + "清除家族挑战。", CHAR_COLORWHITE); + break; + } + NPC_SavePKSchedule(meindex); + } + } + } + } + break; + } +} + +void NPC_SchedulemanLoop(int meindex) +{ +// int fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID)*MAX_SCHEDULE; + +/* + print("Scheduleman: fmpks_pos=%d dueltime=%d host=%s guest=%s\n", + fmpks_pos, fmpks[fmpks_pos].dueltime, fmpks[fmpks_pos].host_name, fmpks[fmpks_pos].guest_name); +*/ + + NPC_RemoveExpiredBattle(meindex); + NPC_ProcessTimeout(meindex); +} + +// 移除过期的战斗 +void NPC_RemoveExpiredBattle(int meindex) +{ + struct tm tm1; + int keeptime; + int i,expired=-1; + int fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID)*MAX_SCHEDULE; + int prevckt = CHAR_getWorkInt(meindex, NPC_WORK_PREVIOUSCHECKTIME); + int fin = CHAR_getWorkInt(meindex, NPC_WORK_FIGHTINTERVAL); + int h,d; + + // 以目前的时刻当标准去移除过期的排程 + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); +/* + if (tm1.tm_hour==0) + keeptime=0; + else + keeptime=(tm1.tm_hour-1)*100 + tm1.tm_min; +*/ + if (tm1.tm_min=0) { + // 移动後面的排程来取代已经失效的排程 + for (i=expired+1; i=60 ) h=h+100-60; + if (h>=2400) { + h = h-2400; + d = 10000; + } + fmpks[fmpks_pos+i].dueltime=d+h; + } + } +} + +// 处理 timeout +void NPC_ProcessTimeout(int meindex) +{ + int i; + int fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID)*MAX_SCHEDULE; + + for (i=0; i=0) { + fmpks[fmpks_pos+i].challenge_timeout--; + if (fmpks[fmpks_pos+i].challenge_timeout<0) { + fmpks[fmpks_pos+i].host_index = -1; + strcpy(fmpks[fmpks_pos+i].host_name, "-1"); + fmpks[fmpks_pos+i].guest_index = -1; + strcpy(fmpks[fmpks_pos+i].guest_name, "-1"); + fmpks[fmpks_pos+i].prepare_time = -1; + fmpks[fmpks_pos+i].max_player = -1; + fmpks[fmpks_pos+i].flag=-1; + } + } + } + if (fmpks[fmpks_pos+i].flag==FMPKS_FLAG_SETTING) { + if (fmpks[fmpks_pos+i].setting_timeout>=0) { + fmpks[fmpks_pos+i].setting_timeout--; + if (fmpks[fmpks_pos+i].setting_timeout<0) { + fmpks[fmpks_pos+i].host_index = -1; + strcpy(fmpks[fmpks_pos+i].host_name, "-1"); + fmpks[fmpks_pos+i].guest_index = -1; + strcpy(fmpks[fmpks_pos+i].guest_name, "-1"); + fmpks[fmpks_pos+i].prepare_time = -1; + fmpks[fmpks_pos+i].max_player = -1; + fmpks[fmpks_pos+i].flag=-1; + } + } + } + } +} + +// 检查, 一个家族只能安排一场战斗 +BOOL NPC_AlreadyScheduled(int meindex, int talkerindex) +{ + int i; + int fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID)*MAX_SCHEDULE; + int tkfmindex = CHAR_getInt(talkerindex, CHAR_FMINDEX); + int flag=1; + + for (i=0; i=FMPKS_FLAG_SCHEDULED) { + if (fmpks[fmpks_pos+i].host_index==tkfmindex) return TRUE; + } else if (fmpks[fmpks_pos+i].flag!=FMPKS_FLAG_NONE) { + if (flag==1) flag=0; else return TRUE; + } + } + return FALSE; +} + +// 读取 schedule 档案 +void NPC_LoadPKSchedule(int meindex) +{ + char filename[256],tmp[4096],token[256]; + FILE *f; + int i; + int fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID)*MAX_SCHEDULE; + + snprintf(filename,sizeof(filename), "%s%d_%d_%d", + SCHEDULEFILEDIR, CHAR_getInt(meindex, CHAR_FLOOR), + CHAR_getInt(meindex, CHAR_X), + CHAR_getInt(meindex, CHAR_Y) ); + + if( ! (f=fopen( filename, "r" )) ){ // create new schedule file + f = fopen( filename, "w" ); + if( !f ){ + print( "ERROR:Can't create Schedule file %s!\n",filename ); + return; + } + for (i=0; i=MAX_SCHEDULE)) return; + + // 记录目前的时间 + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + sprintf(buf, "%d|", tm1.tm_hour*100 + tm1.tm_min); + + for (i=page; i +#include "char.h" +#include "object.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "npcutil.h" +#include "handletime.h" +#include "npc_fmdengon.h" +#include "family.h" + +#define DENGONFILELINENUM 35 // 整个公布栏的资料笔数 +#define FMSDENGONFILELINENUM 140 // 家族间的留言板资料笔数 +#define DENGONFILEENTRYSIZE 128 // 本文大小 +#ifdef _NEW_MANOR_LAW +#define MESSAGEINONEWINDOW 10 // 每页所显示的笔数 +#else +#define MESSAGEINONEWINDOW 7 // 每页所显示的笔数 +#endif +#define FMMAXNUM 1000 // 家族数量的最大值 +#define FM_MEMBERLIST 2 // 家族成员列表 (主功能表的按键) +#define FM_MEMBERMEMO 3 // 家族留言 (主功能表的按键) +#ifdef _UN_FMMEMO +#define FM_FMPOINT 4 // 申请家族据点 (主功能表的按键) +#define FM_FMDPTOP 5 // 家族间强者表 (主功能表的按键) +#else +#define FM_FMMEMO 4 // 家族之间留言板 (主功能表的按键) +#ifdef _UN_FMPOINT +#define FM_FMDPTOP 5 // 家族间强者表 (主功能表的按键) +#else +#define FM_FMPOINT 5 // 申请家族据点 (主功能表的按键) +#define FM_FMDPTOP 6 // 家族间强者表 (主功能表的按键) +#endif//_UN_FMPOINT +#endif//_UN_FMMEMO +#define FM_WAITTIME (3*60) +#define FMSDENGON_SN 10000 // 家族之间的留言板的识别码 + +extern struct FMMEMBER_LIST memberlist[FMMAXNUM]; // 接收 AC 成员列表资料的 ARRAY +extern struct FMS_MEMO fmsmemo; // 家族之间的留言板 +extern struct FM_POINTLIST fmpointlist; // 家族据点 +extern struct FMS_DPTOP fmdptop; // 家族强者表 +extern int leaderdengonindex; // 777 家族公布栏 index +char NPC_sendbuf[DENGONFILEENTRYSIZE*MESSAGEINONEWINDOW]; // 一整页的大小 +char enlistbuf[4096]; // 家族成员召募 BUF(显示用的) + +unsigned long READTIME1 = 0, + READTIME2 = 0, + READTIME3 = 0, + READTIME4 = 0; + +// 公布栏的初始化(when gmsv start) +BOOL NPC_FmDengonInit( int meindex) +{ + int i; + + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_TYPEDENGON); + + if( CHAR_getInt(meindex, CHAR_FLOOR) == 777 ){ + leaderdengonindex = meindex; + } + + if( READTIME1 == 0 || READTIME2 == 0 || READTIME3 == 0 || READTIME4 == 0 ){ + READTIME1 = NowTime.tv_sec+FM_WAITTIME, + READTIME2 = NowTime.tv_sec+FM_WAITTIME, + READTIME3 = NowTime.tv_sec+FM_WAITTIME, + READTIME4 = NowTime.tv_sec+FM_WAITTIME; + + // 取得家族的成员列表(memberlist struct),以及家族的留言板 + for( i=0; i DENGONDISTANCE) return; +#endif + + // 家族留言板 + if( seqno == CHAR_WINDOWTYPE_FM_DENGON) + { + int dengonindex; + int fmindex_wk; + char tmp_buffer[4096],tmp[4096]; + + getStringFromIndexWithDelim(data,"|",1,tmp_buffer,sizeof(tmp_buffer)); + dengonindex = atoi(tmp_buffer); + + fmindex_wk = CHAR_getWorkInt( talker, CHAR_WORKFMINDEXI); + + if( fmindex_wk < 0 || fmindex_wk >= FMMAXNUM) return; + + switch( select){ + case WINDOW_BUTTONTYPE_NEXT: + case WINDOW_BUTTONTYPE_PREV: + { + int fd,i; + fd = getfdFromCharaIndex( talker); + if( fd == -1) return; + + dengonindex += 7 * (( select == WINDOW_BUTTONTYPE_NEXT) ? 1 : -1); + if( dengonindex > memberlist[fmindex_wk].memoindex && memberlist[fmindex_wk].memonum < DENGONFILELINENUM) + dengonindex = memberlist[fmindex_wk].memoindex; + else if( dengonindex < 6 && memberlist[fmindex_wk].memonum < DENGONFILELINENUM) + dengonindex = 6; + else if( dengonindex < 1 && memberlist[fmindex_wk].memonum >= DENGONFILELINENUM) + dengonindex = memberlist[fmindex_wk].memonum+dengonindex; + else if( dengonindex > memberlist[fmindex_wk].memonum && memberlist[fmindex_wk].memonum >= DENGONFILELINENUM) + dengonindex -= memberlist[fmindex_wk].memonum; + + buttontype = WINDOW_BUTTONTYPE_OKCANCEL; + if( dengonindex==memberlist[fmindex_wk].memoindex && memberlist[fmindex_wk].memonum >= DENGONFILELINENUM) + buttontype |= WINDOW_BUTTONTYPE_PREV; + else if( (dengonindex - 7)<=memberlist[fmindex_wk].memoindex && (dengonindex - 7)>=(memberlist[fmindex_wk].memoindex - 7) && + memberlist[fmindex_wk].memonum >= DENGONFILELINENUM) + buttontype |= WINDOW_BUTTONTYPE_NEXT; + else if( dengonindex==memberlist[fmindex_wk].memoindex) + buttontype |= WINDOW_BUTTONTYPE_PREV; + else if( dengonindex == 6) buttontype |= WINDOW_BUTTONTYPE_NEXT; + else{ + buttontype |= WINDOW_BUTTONTYPE_PREV; + buttontype |= WINDOW_BUTTONTYPE_NEXT; + } + if(dengonindex >= 6){ + strcpy( NPC_sendbuf, memberlist[fmindex_wk].memo[dengonindex - 6]); + strcat( NPC_sendbuf, "\n"); + for( i=(dengonindex - 5); i<=dengonindex; i++){ + strcat( NPC_sendbuf, memberlist[fmindex_wk].memo[i]); + strcat( NPC_sendbuf, "\n"); + } + sprintf(tmp, "%d\n", dengonindex); + strcat( NPC_sendbuf, tmp); + } + if(dengonindex < 6){ + strcpy( NPC_sendbuf, memberlist[fmindex_wk].memo[memberlist[fmindex_wk].memonum+(dengonindex - 6)]); + strcat( NPC_sendbuf, "\n"); + for( i=memberlist[fmindex_wk].memonum+(dengonindex - 5); i DENGONFILELINENUM) + memberlist[fmindex_wk].memonum = DENGONFILELINENUM; + + memberlist[fmindex_wk].memoindex++; + if( memberlist[fmindex_wk].memoindex >= DENGONFILELINENUM) + memberlist[fmindex_wk].memoindex=0; + + dengonindex = memberlist[fmindex_wk].memoindex; + + if( dengonindex < 6 && memberlist[fmindex_wk].memonum= 6){ + strcpy( NPC_sendbuf, memberlist[fmindex_wk].memo[dengonindex - 6]); + strcat( NPC_sendbuf, "\n"); + for( i=(dengonindex-5); i<=dengonindex; i++){ + strcat( NPC_sendbuf, memberlist[fmindex_wk].memo[i]); + strcat( NPC_sendbuf, "\n"); + } + sprintf(tmp, "%d\n", dengonindex); + strcat( NPC_sendbuf, tmp); + } + if( dengonindex < 6){ + strcpy( NPC_sendbuf, memberlist[fmindex_wk].memo[memberlist[fmindex_wk].memonum+(dengonindex - 6)]); + strcat( NPC_sendbuf, "\n"); + for( i=memberlist[fmindex_wk].memonum+(dengonindex - 5); i fmsmemo.memoindex && fmsmemo.memonum < FMSDENGONFILELINENUM) + dengonindex = fmsmemo.memoindex; + else if( dengonindex < 6 && fmsmemo.memonum < FMSDENGONFILELINENUM) + dengonindex = 6; + else if( dengonindex < 1 && fmsmemo.memonum >= FMSDENGONFILELINENUM) + dengonindex = fmsmemo.memonum+dengonindex; + else if( dengonindex > fmsmemo.memonum && fmsmemo.memonum >= FMSDENGONFILELINENUM) + dengonindex -= fmsmemo.memonum; + + buttontype = WINDOW_BUTTONTYPE_OKCANCEL; + if( dengonindex==fmsmemo.memoindex && fmsmemo.memonum >= FMSDENGONFILELINENUM) + buttontype |= WINDOW_BUTTONTYPE_PREV; + else if( (dengonindex-7)<=fmsmemo.memoindex && (dengonindex - 7)>=(fmsmemo.memoindex - 7) && + fmsmemo.memonum >= FMSDENGONFILELINENUM) + buttontype |= WINDOW_BUTTONTYPE_NEXT; + else if( dengonindex == fmsmemo.memoindex) + buttontype |= WINDOW_BUTTONTYPE_PREV; + else if( dengonindex == 6 ) + buttontype |= WINDOW_BUTTONTYPE_NEXT; + else{ + buttontype |= WINDOW_BUTTONTYPE_PREV; + buttontype |= WINDOW_BUTTONTYPE_NEXT; + } + + if( dengonindex >= 6 ){ + if( (dengonindex - 6) >= 140 ) return; + strcpy( NPC_sendbuf, fmsmemo.memo[dengonindex - 6]); + strcat( NPC_sendbuf, "\n"); + for( i=(dengonindex - 5); i<=dengonindex; i++){ + strcat( NPC_sendbuf, fmsmemo.memo[i]); + strcat( NPC_sendbuf, "\n"); + } + sprintf(tmp, "%d\n", dengonindex); + strcat( NPC_sendbuf, tmp); + } + if(dengonindex < 6){ + if( (fmsmemo.memonum+(dengonindex - 6)) >= 140 || + (fmsmemo.memonum+(dengonindex - 6)) < 0 ) return; + + strcpy( NPC_sendbuf, fmsmemo.memo[fmsmemo.memonum+(dengonindex - 6)]); + + strcat( NPC_sendbuf, "\n"); + for( i=fmsmemo.memonum+(dengonindex - 5); i FMSDENGONFILELINENUM) + fmsmemo.memonum = FMSDENGONFILELINENUM; + + fmsmemo.memoindex++; + if( fmsmemo.memoindex >= FMSDENGONFILELINENUM) + fmsmemo.memoindex = 0; + + dengonindex = fmsmemo.memoindex; + if( dengonindex < 6 && fmsmemo.memonum= 6){ + strcpy( NPC_sendbuf, fmsmemo.memo[dengonindex - 6]); + strcat( NPC_sendbuf, "\n"); + for( i=(dengonindex - 5); i<=dengonindex; i++){ + strcat( NPC_sendbuf, fmsmemo.memo[i]); + strcat( NPC_sendbuf, "\n"); + } + sprintf(tmp, "%d\n", dengonindex); + strcat( NPC_sendbuf, tmp); + } + if(dengonindex < 6){ + strcpy( NPC_sendbuf, fmsmemo.memo[fmsmemo.memonum+(dengonindex - 6)]); + strcat( NPC_sendbuf, "\n"); + for( i=fmsmemo.memonum+(dengonindex - 5); i= FMMAXNUM) return; + + fd = getfdFromCharaIndex( talker ); + if( fd == -1 ) return; + + switch( select ){ + case WINDOW_BUTTONTYPE_OK: + { + strcpy( numberlistbuf, memberlist[fmindex_wk].numberlistarray[0]); + strcat( numberlistbuf, "\n"); + for( i=1; i<10; i++){ + strcat( numberlistbuf, memberlist[fmindex_wk].numberlistarray[i]); + strcat( numberlistbuf, "\n"); + } + // 增加程式码(向AC要召募人员的值) + sprintf(enlistbuf, "是否继续召募家族人员|0|%d",memberlist[fmindex_wk].accept); + strcat( numberlistbuf, enlistbuf); + strcat( numberlistbuf, "\n"); + lssproto_WN_send( fd, WINDOW_FMMESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_OK| + WINDOW_BUTTONTYPE_NEXT, + CHAR_WINDOWTYPE_FM_MEMBERLIST, +#ifndef _FM_MODIFY + CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), +#else + -1, +#endif + makeEscapeString( numberlistbuf, buf, sizeof(buf))); + } + break; + default: + break; + } + } + + // 强者表的选项视窗 + else if( seqno == CHAR_WINDOWTYPE_FM_DPSELECT) + { + int fmindex_wk; + fmindex_wk = CHAR_getWorkInt( talker, CHAR_WORKFMINDEXI); + + if( CHAR_getInt(talker, CHAR_FMINDEX) > 0 ){ + if( fmindex_wk < 0 || fmindex_wk >= FMMAXNUM){ + print("FamilyNumber Data Error!!"); + return; + } + } + + buttonevent = atoi(data); + switch( buttonevent ){ + case 1: // 前叁十大家族综合声望列表 + { + int fd,i; + char listbuf[4096]; + fd = getfdFromCharaIndex( talker ); + if( fd == -1 ) return; + + strcpy( listbuf, fmdptop.topmemo[0]); + strcat( listbuf, "\n"); + for( i=1; i<10; i++){ + strcat( listbuf, fmdptop.topmemo[i]); + strcat( listbuf, "\n"); + } + strcat( listbuf, "0\n"); +#ifdef _FMVER21 + lssproto_WN_send( fd, WINDOW_FMMESSAGETYPE_TOP30DP, +#else + lssproto_WN_send( fd, WINDOW_FMMESSAGETYPE_DP, +#endif + WINDOW_BUTTONTYPE_OK| + WINDOW_BUTTONTYPE_NEXT, + CHAR_WINDOWTYPE_FM_DPTOP, +#ifndef _FM_MODIFY + CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), +#else + -1, +#endif + makeEscapeString( listbuf, buf, sizeof(buf))); + } + break; + case 2: // 前十大家族冒险列表 + { + int fd,i; + char listbuf[4096]; + fd = getfdFromCharaIndex( talker ); + if( fd == -1 ) return; + + strcpy( listbuf, fmdptop.adv_topmemo[0]); + strcat( listbuf, "\n"); + for( i=1; i<10; i++){ + strcat( listbuf, fmdptop.adv_topmemo[i]); + strcat( listbuf, "\n"); + } + + lssproto_WN_send( fd, WINDOW_FMMESSAGETYPE_DP, + WINDOW_BUTTONTYPE_OK| + WINDOW_BUTTONTYPE_PREV, + CHAR_WINDOWTYPE_FM_DPME, +#ifndef _FM_MODIFY + CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), +#else + -1, +#endif + makeEscapeString( listbuf, buf, sizeof(buf))); + } + break; + case 3: // 前十大家族伺育列表 + { + int fd,i; + char listbuf[4096]; + fd = getfdFromCharaIndex( talker ); + if( fd == -1 ) return; + + strcpy( listbuf, fmdptop.feed_topmemo[0]); + strcat( listbuf, "\n"); + for( i=1; i<10; i++){ + strcat( listbuf, fmdptop.feed_topmemo[i]); + strcat( listbuf, "\n"); + } + + lssproto_WN_send( fd, WINDOW_FMMESSAGETYPE_DP, + WINDOW_BUTTONTYPE_OK| + WINDOW_BUTTONTYPE_PREV, + CHAR_WINDOWTYPE_FM_DPME, +#ifndef _FM_MODIFY + CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), +#else + -1, +#endif + makeEscapeString( listbuf, buf, sizeof(buf))); + } + break; +#ifndef _NEW_MANOR_LAW + case 4: // 前十大家族合成列表 + { + int fd,i; + char listbuf[4096]; + fd = getfdFromCharaIndex( talker ); + if( fd == -1 ) return; + + strcpy( listbuf, fmdptop.syn_topmemo[0]); + strcat( listbuf, "\n"); + for( i=1; i<10; i++){ + strcat( listbuf, fmdptop.syn_topmemo[i]); + strcat( listbuf, "\n"); + } + + lssproto_WN_send( fd, WINDOW_FMMESSAGETYPE_DP, + WINDOW_BUTTONTYPE_OK| + WINDOW_BUTTONTYPE_PREV, + CHAR_WINDOWTYPE_FM_DPME, +#ifndef _FM_MODIFY + CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), +#else + -1, +#endif + makeEscapeString( listbuf, buf, sizeof(buf))); + } + break; + case 5: // 前十大家族料理列表 + { + int fd,i; + char listbuf[4096]; + fd = getfdFromCharaIndex( talker ); + if( fd == -1 ) return; + + strcpy( listbuf, fmdptop.food_topmemo[0]); + strcat( listbuf, "\n"); + for( i=1; i<10; i++){ + strcat( listbuf, fmdptop.food_topmemo[i]); + strcat( listbuf, "\n"); + } + + lssproto_WN_send( fd, WINDOW_FMMESSAGETYPE_DP, + WINDOW_BUTTONTYPE_OK| + WINDOW_BUTTONTYPE_PREV, + CHAR_WINDOWTYPE_FM_DPME, +#ifndef _FM_MODIFY + CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), +#else + -1, +#endif + makeEscapeString( listbuf, buf, sizeof(buf))); + } + break; +#endif +#ifdef _NEW_MANOR_LAW + case 4: // 前十大家族PK列表 +#else + case 6: // 前十大家族PK列表 +#endif + { + int fd,i; + char listbuf[4096]; + fd = getfdFromCharaIndex( talker ); + if( fd == -1 ) return; + + strcpy( listbuf, fmdptop.pk_topmemo[0]); + strcat( listbuf, "\n"); + for( i=1; i<10; i++){ + strcat( listbuf, fmdptop.pk_topmemo[i]); + strcat( listbuf, "\n"); + } + + lssproto_WN_send( fd, WINDOW_FMMESSAGETYPE_DP, + WINDOW_BUTTONTYPE_OK| + WINDOW_BUTTONTYPE_PREV, + CHAR_WINDOWTYPE_FM_DPME, +#ifndef _FM_MODIFY + CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), +#else + -1, +#endif + makeEscapeString( listbuf, buf, sizeof(buf))); + } + break; +#ifdef _NEW_MANOR_LAW + case 5: // 十大气势家族 + { + int fd,i; + char listbuf[4096]; + fd = getfdFromCharaIndex( talker ); + if( fd == -1 ) return; + + strcpy( listbuf, fmdptop.momentum_topmemo[0]); + strcat( listbuf, "\n"); + for( i=1; i<10; i++){ + strcat( listbuf, fmdptop.momentum_topmemo[i]); + strcat( listbuf, "\n"); + } + + lssproto_WN_send( fd, WINDOW_FMMESSAGETYPE_10_MEMONTUM, + WINDOW_BUTTONTYPE_OK| + WINDOW_BUTTONTYPE_PREV, + CHAR_WINDOWTYPE_FM_DPME, +#ifndef _FM_MODIFY + CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), +#else + -1, +#endif + makeEscapeString( listbuf, buf, sizeof(buf))); + } + break; +#endif +#ifndef _NEW_MANOR_LAW + case 7: // 自己家族声望排行榜 +#else + case 6: +#endif + { + int fd,i,h,k,fmid; + char listbuf[4096]; + + fd = getfdFromCharaIndex( talker ); + if( fd == -1 ) return; + + fmid = CHAR_getWorkInt(talker, CHAR_WORKFMINDEXI); + if( fmid < 0 ){ + sprintf( NPC_sendbuf, " 『警 告』\n 抱歉!你不是家族人员,无法查看。"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, WINDOW_BUTTONTYPE_OK, + -1, + -1, + makeEscapeString( NPC_sendbuf, buf, sizeof(buf))); + return; + } + + for( h=0; h= 994 ) h = 990; + else h -= 4; + + strcpy( listbuf, fmdptop.topmemo[h]); + if( k == h ) strcat( listbuf, "|1"); + strcat( listbuf, "\n"); + for( i = h + 1; i < h + 10; i++){ + strcat( listbuf, fmdptop.topmemo[i]); + if(i == k) strcat( listbuf, "|1"); + strcat( listbuf, "\n"); + } +#ifdef _FMVER21 + lssproto_WN_send( fd, WINDOW_FMMESSAGETYPE_TOP30DP, +#else + lssproto_WN_send( fd, WINDOW_FMMESSAGETYPE_DP, +#endif + WINDOW_BUTTONTYPE_OK| + WINDOW_BUTTONTYPE_PREV, + CHAR_WINDOWTYPE_FM_DPME, +#ifndef _FM_MODIFY + CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), +#else + -1, +#endif + makeEscapeString( listbuf, buf, sizeof(buf))); + } + break; +#ifdef _NEW_MANOR_LAW + case 7: // 自己家族气势排名 + { + int fd,h,fmid; + char listbuf[4096]; + char szTempbuf[12]; + + fd = getfdFromCharaIndex( talker ); + if( fd == -1 ) return; + + fmid = CHAR_getWorkInt(talker, CHAR_WORKFMINDEXI); + if( fmid < 0 ){ + sprintf( NPC_sendbuf, " 『警 告』\n 抱歉!你不是家族人员,无法查看。"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, WINDOW_BUTTONTYPE_OK, + -1, + -1, + makeEscapeString( NPC_sendbuf, buf, sizeof(buf))); + return; + } + + for( h=0; h 0 ){ + if( fmindex_wk < 0 || fmindex_wk >= FMMAXNUM){ + print("FamilyNumber Data Error!!"); + return; + } + } + + buttonevent = atoi(data); + + switch( buttonevent ){ + case FM_MEMBERLIST: + { + int fd; + + fd = getfdFromCharaIndex( talker ); + if( fd == -1 ) return; + + if( CHAR_getInt(talker, CHAR_FMINDEX) <= 0){ + sprintf( NPC_sendbuf, " 『警 告』\n 抱歉!你不是家族人员,不得使用公布栏。"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, WINDOW_BUTTONTYPE_OK, + -1, -1, makeEscapeString( NPC_sendbuf, buf, sizeof(buf))); + return; + } + /* + #ifdef _FMVER21 + if( CHAR_getInt( talker, CHAR_FMLEADERFLAG ) == FMMEMBER_LEADER || + CHAR_getInt( talker, CHAR_FMLEADERFLAG ) == FMMEMBER_ELDER ){ + #else + if( CHAR_getInt( talker, CHAR_FMLEADERFLAG) == 1){ + #endif + saacproto_ACShowMemberList_send( acfd, fmindex_wk); + READTIME1 = NowTime.tv_sec+FM_WAITTIME; + }else + */ + if( NowTime.tv_sec > READTIME1 ){ + saacproto_ACShowMemberList_send( acfd, fmindex_wk); + READTIME1 = NowTime.tv_sec+FM_WAITTIME; + } + +#ifdef _FMVER21 + // if( CHAR_getInt( talker, CHAR_FMLEADERFLAG ) == FMMEMBER_LEADER || + // CHAR_getInt( talker, CHAR_FMLEADERFLAG ) == FMMEMBER_ELDER || + // CHAR_getInt( talker, CHAR_FMLEADERFLAG ) == FMMEMBER_VICELEADER ){ + if( CHAR_getInt( talker, CHAR_FMLEADERFLAG ) == FMMEMBER_LEADER || + CHAR_getInt( talker, CHAR_FMLEADERFLAG ) == FMMEMBER_ELDER ){ +#else + if( CHAR_getInt( talker, CHAR_FMLEADERFLAG) == 1 ){ +#endif + sprintf( NPC_sendbuf, " 『族 长 需 知』\n请小心处理族员的资料,一经修改後就无法回复原态,敬请小心。"); + }else{ + sprintf( NPC_sendbuf, " 『列 表 需 知』\n 此表族长可作修改,族员仅能查看。"); + } + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_FM_MESSAGE2, +#ifndef _FM_MODIFY + CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), +#else + -1, +#endif + makeEscapeString( NPC_sendbuf, buf, sizeof(buf))); + } + break; +#ifdef _UN_FMPOINT +#else + case FM_FMPOINT: + { + int fd; + + fd = getfdFromCharaIndex( talker ); + if( fd == -1 ) return; + +#ifdef _FMVER21 + if( CHAR_getInt( talker, CHAR_FMLEADERFLAG) == FMMEMBER_LEADER ){ +#else + if( CHAR_getInt( talker, CHAR_FMLEADERFLAG) == 1 ){ +#endif + saacproto_ACFMPointList_send(acfd); + sprintf( NPC_sendbuf, " 『族 长 需 知』\n请小心慎选所申请的据点,一但选取据点後就无法回复原态,敬请小心。"); + READTIME4 = NowTime.tv_sec+FM_WAITTIME; + } + else{ + sprintf( NPC_sendbuf, " 『列 表 需 知』\n此表族长可以申请,其馀仅能查看。"); + } + + if( NowTime.tv_sec > READTIME4 ){ + saacproto_ACFMPointList_send(acfd); + READTIME4 = NowTime.tv_sec+FM_WAITTIME; + } + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_FM_MESSAGE1, +#ifndef _FM_MODIFY + CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), +#else + -1, +#endif + makeEscapeString( NPC_sendbuf, buf, sizeof(buf))); + } + break; +#endif //_UN_FMPOINT + case FM_FMDPTOP: + { + int fd; + + fd = getfdFromCharaIndex( talker ); + if( fd == -1 ) return; + + if( NowTime.tv_sec > READTIME3 ){ + saacproto_ACShowTopFMList_send( acfd, FM_TOP_INTEGRATE ); + saacproto_ACShowTopFMList_send( acfd, FM_TOP_ADV ); + saacproto_ACShowTopFMList_send( acfd, FM_TOP_FEED ); + saacproto_ACShowTopFMList_send( acfd, FM_TOP_SYNTHESIZE ); + saacproto_ACShowTopFMList_send( acfd, FM_TOP_DEALFOOD ); + saacproto_ACShowTopFMList_send( acfd, FM_TOP_PK ); +#ifdef _NEW_MANOR_LAW + saacproto_ACShowTopFMList_send(acfd, FM_TOP_MOMENTUM); +#endif + READTIME3 = NowTime.tv_sec+FM_WAITTIME; + } + memset(NPC_sendbuf,0,sizeof(NPC_sendbuf)); + strcpy( NPC_sendbuf, "\n 叁十大家族声望列表\n"); + strcat( NPC_sendbuf, " 十大冒险家族\n"); + strcat( NPC_sendbuf, " 十大饲育家族\n"); +#ifndef _NEW_MANOR_LAW + strcat( NPC_sendbuf, " 十大合成家族\n"); + strcat( NPC_sendbuf, " 十大料理家族\n"); +#endif + strcat( NPC_sendbuf, " 十大战斗家族\n"); +#ifdef _NEW_MANOR_LAW + strcat( NPC_sendbuf, " 十大气势家族\n"); +#endif + strcat( NPC_sendbuf, " 自己家族声望列表\n"); +#ifdef _NEW_MANOR_LAW + strcat( NPC_sendbuf, " 自己家族气势排名\n"); +#endif + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_FM_DPSELECT, +#ifndef _FM_MODIFY + CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), +#else + -1, +#endif + makeEscapeString( NPC_sendbuf, buf, sizeof(buf))); + + } + break; + case FM_MEMBERMEMO: + { + int fd,i,dengonindex; + char tmp[4096]; + fd = getfdFromCharaIndex( talker ); + + if( fd == -1 ) return; + + if( CHAR_getInt(talker, CHAR_FMINDEX) <= 0){ + sprintf( NPC_sendbuf, " 『警 告』\n 抱歉!你不是家族人员,不得使用公布栏。"); + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, + -1, + makeEscapeString( NPC_sendbuf, buf, sizeof(buf))); + return; + } + + if( NowTime.tv_sec > READTIME2 ){ + saacproto_ACFMReadMemo_send( acfd, fmindex_wk); + READTIME2 = NowTime.tv_sec+FM_WAITTIME; + } + + dengonindex = memberlist[fmindex_wk].memoindex; + if( memberlist[fmindex_wk].memoindex < 6 && memberlist[fmindex_wk].memonum < DENGONFILELINENUM ){ + dengonindex = 6; + } + + if( dengonindex >= 6 ){ + strcpy( NPC_sendbuf, memberlist[fmindex_wk].memo[dengonindex - 6]); + strcat( NPC_sendbuf, "\n"); + for( i=(dengonindex - 5); i<=dengonindex; i++){ + strcat( NPC_sendbuf, memberlist[fmindex_wk].memo[i]); + strcat( NPC_sendbuf, "\n"); + } + sprintf(tmp, "%d\n", dengonindex); + strcat( NPC_sendbuf, tmp); + } + if( dengonindex < 6 ){ + strcpy( NPC_sendbuf, + memberlist[fmindex_wk].memo[memberlist[fmindex_wk].memonum + (dengonindex - 6)]); + strcat( NPC_sendbuf, "\n"); + for( i=memberlist[fmindex_wk].memonum + (dengonindex - 5); i READTIME3 ){ + saacproto_ACFMReadMemo_send( acfd, FMSDENGON_SN); + READTIME3 = NowTime.tv_sec+FM_WAITTIME; + } + dengonindex = fmsmemo.memoindex; + if( fmsmemo.memoindex<6 || fmsmemo.memonum>FMSDENGONFILELINENUM ){ + dengonindex = 6; + } + if( dengonindex >= 6 ){ + strcpy( NPC_sendbuf, fmsmemo.memo[dengonindex - 6]); + strcat( NPC_sendbuf, "\n"); + for( i=(dengonindex - 5); i<=dengonindex; i++){ + strcat( NPC_sendbuf, fmsmemo.memo[i]); + strcat( NPC_sendbuf, "\n"); + } + sprintf(tmp, "%d\n", dengonindex); + strcat( NPC_sendbuf, tmp); + } + if( dengonindex < 6 ){ + if( (fmsmemo.memonum + (dengonindex - 6)) < 0 || (fmsmemo.memonum + (dengonindex - 6)) >= 140 ) + return; + strcpy( NPC_sendbuf, fmsmemo.memo[fmsmemo.memonum + (dengonindex - 6)]); + strcat( NPC_sendbuf, "\n"); + for( i=fmsmemo.memonum + (dengonindex - 5); i= FMMAXNUM) return; + + getStringFromIndexWithDelim(data,"|",1,tmp_buffer,sizeof(tmp_buffer)); + numberlistindex = atoi(tmp_buffer); + getStringFromIndexWithDelim(data,"|",2,tmp_buffer,sizeof(tmp_buffer)); + buttonevent = atoi(tmp_buffer); + getStringFromIndexWithDelim(data,"|",3,dutybuf,sizeof(dutybuf)); + +#ifdef _FMVER21 + // if( buttonevent>=1 && buttonevent<=11 && + // ( CHAR_getInt( talker, CHAR_FMLEADERFLAG ) == FMMEMBER_LEADER || + // CHAR_getInt( talker, CHAR_FMLEADERFLAG ) == FMMEMBER_ELDER || + // CHAR_getInt( talker, CHAR_FMLEADERFLAG ) == FMMEMBER_VICELEADER )) + if( buttonevent>=1 && buttonevent<=11 && + ( CHAR_getInt( talker, CHAR_FMLEADERFLAG ) == FMMEMBER_LEADER || + CHAR_getInt( talker, CHAR_FMLEADERFLAG ) == FMMEMBER_ELDER )) +#else + if( buttonevent>=1 && buttonevent<=11 && CHAR_getInt( talker, CHAR_FMLEADERFLAG) == 1 ) +#endif + { + int fd,i; + int int_status; + char getstatus[4096]; + + fd = getfdFromCharaIndex( talker ); + if( fd == -1 ) return; + + strcpy( getstatus, memberlist[fmindex_wk].numberlistarray[numberlistindex+buttonevent - 1] + + (strlen( memberlist[fmindex_wk].numberlistarray[numberlistindex+buttonevent - 1]) - 1)); + + int_status = atoi(getstatus); + + // 家族的加入、退出、申请等选项 + if( buttonevent!=11 ) +#ifdef _FMVER21 + strcpy( memberlist[fmindex_wk].numberlistarray[numberlistindex+buttonevent - 1] + + (strlen(memberlist[fmindex_wk].numberlistarray[numberlistindex+buttonevent - 1]) - 1), dutybuf); +#else + switch( int_status ){ + case 1: + case 3: + strcpy( memberlist[fmindex_wk].numberlistarray[numberlistindex+buttonevent - 1] + + (strlen(memberlist[fmindex_wk].numberlistarray[numberlistindex+buttonevent - 1]) - 1), "4"); + break; + case 2: + strcpy( memberlist[fmindex_wk].numberlistarray[numberlistindex+buttonevent - 1] + + (strlen(memberlist[fmindex_wk].numberlistarray[numberlistindex+buttonevent - 1]) - 1), "1"); + break; + default: + break; + } +#endif + // 家族的召募选项 + if( buttonevent == 11 ) + { + strcpy( getstatus, enlistbuf + (strlen(enlistbuf) - 1)); + int_status = atoi(getstatus); + + switch( int_status ){ + case 1: + memberlist[fmindex_wk].accept = 0; + sprintf(enlistbuf, "是否继续召募家族人员|%d|%d",numberlistindex,memberlist[fmindex_wk].accept); + break; + case 0: + memberlist[fmindex_wk].accept = 1; + sprintf(enlistbuf, "是否继续召募家族人员|%d|%d",numberlistindex,memberlist[fmindex_wk].accept); + break; + default: + break; + } + } + + strcpy( numberlistbuf, memberlist[fmindex_wk].numberlistarray[numberlistindex]); + strcat( numberlistbuf, "\n"); + for( i=(numberlistindex + 1); i memberlist[fmindex_wk].fmnum) + buttontype |= WINDOW_BUTTONTYPE_PREV; + else if( numberlistindex == 0 ) + buttontype |= WINDOW_BUTTONTYPE_NEXT; + else{ + buttontype |= WINDOW_BUTTONTYPE_PREV; + buttontype |= WINDOW_BUTTONTYPE_NEXT; + } + + lssproto_WN_send( fd, WINDOW_FMMESSAGETYPE_SELECT, + buttontype, + CHAR_WINDOWTYPE_FM_MEMBERLIST, +#ifndef _FM_MODIFY + CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), +#else + -1, +#endif + makeEscapeString( numberlistbuf, buf, sizeof(buf))); + } // end if + switch( select ){ + case WINDOW_BUTTONTYPE_NEXT: + case WINDOW_BUTTONTYPE_PREV: + { + int fd,i; + + fd = getfdFromCharaIndex( talker ); + if( fd == -1 ) return; + + numberlistindex += 10 * (( select == WINDOW_BUTTONTYPE_NEXT) ? 1 : -1); + + if( numberlistindex >= memberlist[fmindex_wk].fmnum) + numberlistindex -= 10; + else if( numberlistindex < 1 ) + numberlistindex = 0; + + buttontype = WINDOW_BUTTONTYPE_OK; + if( (numberlistindex + 10) >= memberlist[fmindex_wk].fmnum) + buttontype |= WINDOW_BUTTONTYPE_PREV; + else if( numberlistindex==0 ) + buttontype |= WINDOW_BUTTONTYPE_NEXT; + else{ + buttontype |= WINDOW_BUTTONTYPE_PREV; + buttontype |= WINDOW_BUTTONTYPE_NEXT; + } + + strcpy( numberlistbuf, memberlist[fmindex_wk].numberlistarray[numberlistindex]); + strcat( numberlistbuf, "\n"); + for( i=(numberlistindex+1); i= 30) + return; + //listindex = 20; + //listindex -= 10; + //else if( listindex < 1 ) + // listindex = 0; + if (listindex < 0) return; + + buttontype = WINDOW_BUTTONTYPE_OK; + if( (listindex + 10) >= 30) + buttontype |= WINDOW_BUTTONTYPE_PREV; + else if( listindex==0 ) + buttontype |= WINDOW_BUTTONTYPE_NEXT; + else{ + buttontype |= WINDOW_BUTTONTYPE_PREV; + buttontype |= WINDOW_BUTTONTYPE_NEXT; + } + + strcpy( listbuf, fmdptop.topmemo[listindex]); + strcat( listbuf, "\n"); + for( i=(listindex+1); i FMPOINTNUM) + pointlistindex -= 10; + else if( pointlistindex < 1 ) + pointlistindex = 0; + + buttontype = WINDOW_BUTTONTYPE_OK; + if( (pointlistindex + 10) > FMPOINTNUM) + buttontype |= WINDOW_BUTTONTYPE_PREV; + else if( pointlistindex==0 ) + buttontype |= WINDOW_BUTTONTYPE_NEXT; + else{ + buttontype |= WINDOW_BUTTONTYPE_PREV; + buttontype |= WINDOW_BUTTONTYPE_NEXT; + } + + strcpy( pointlistbuf, fmpointlist.pointlistarray[pointlistindex]); + strcat( pointlistbuf, "\n"); + for( i=(pointlistindex+1); i READTIME3 ){ + saacproto_ACShowTopFMList_send(acfd, FM_TOP_INTEGRATE); + saacproto_ACShowTopFMList_send(acfd, FM_TOP_ADV); + saacproto_ACShowTopFMList_send(acfd, FM_TOP_FEED); + saacproto_ACShowTopFMList_send(acfd, FM_TOP_SYNTHESIZE); + saacproto_ACShowTopFMList_send(acfd, FM_TOP_DEALFOOD); + saacproto_ACShowTopFMList_send(acfd, FM_TOP_PK); +#ifdef _NEW_MANOR_LAW + saacproto_ACShowTopFMList_send(acfd, FM_TOP_MOMENTUM); +#endif + READTIME3 = NowTime.tv_sec+FM_WAITTIME; + } + + strcpy( NPC_sendbuf, "\n 叁十大家族声望列表\n"); + strcat( NPC_sendbuf, " 十大冒险家族\n"); + strcat( NPC_sendbuf, " 十大饲育家族\n"); +#ifndef _NEW_MANOR_LAW + strcat( NPC_sendbuf, " 十大合成家族\n"); + strcat( NPC_sendbuf, " 十大料理家族\n"); +#endif + strcat( NPC_sendbuf, " 十大战斗家族\n"); +#ifdef _NEW_MANOR_LAW + strcat( NPC_sendbuf, " 十大气势家族\n"); +#endif + strcat( NPC_sendbuf, " 自己家族声望列表\n"); +#ifdef _NEW_MANOR_LAW + strcat( NPC_sendbuf, " 自己家族气势排名\n"); +#endif + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_FM_DPSELECT, +#ifndef _FM_MODIFY + CHAR_getWorkInt( index, CHAR_WORKOBJINDEX), +#else + -1, +#endif + makeEscapeString( NPC_sendbuf, buf, sizeof(buf))); + } + break; + case WINDOW_BUTTONTYPE_OK: + break; + default: + break; + } + + } +} + +// call FmDengon NPC event +#ifndef _FM_MODIFY +void NPC_FmDengonLooked( int meindex, int lookedindex ) +{ + char buf[DENGONFILEENTRYSIZE*MESSAGEINONEWINDOW*2]; + char menubuf[4096]; + int fd; + + if (!CHAR_CHECKINDEX(lookedindex)) return; + + fd = getfdFromCharaIndex( lookedindex ); + if( fd == -1 ) return; + + // 必须站在布告栏的前面一格 + if( NPC_Util_CharDistance( lookedindex, meindex ) > 1) return; + // 空白处请勿更动 + strcpy( menubuf, " 『家族布告栏』\n\n"); + strcat( menubuf, " 家族成员列表\n"); + strcat( menubuf, " 家族留言\n"); +#ifdef _UN_FMMEMO +#else + strcat( menubuf, " 家族之间留言板\n"); +#endif +#ifdef _UN_FMPOINT +#else + strcat( menubuf, " 申请家族据点\n"); +#endif + strcat( menubuf, " 家族之间强者表"); + + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_FM_SELECT, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( menubuf, buf, sizeof(buf))); +} +#else +void NPC_FmDengonLooked( int meindex, int lookedindex ) +{ + char buf[DENGONFILEENTRYSIZE*MESSAGEINONEWINDOW*2]; + char menubuf[4096]; + int fd; + + if (!CHAR_CHECKINDEX(lookedindex)) return; + + fd = getfdFromCharaIndex( lookedindex ); + if( fd == -1 ) return; + + // 空白处请勿更动 + strcpy( menubuf, " 『家族布告栏』\n\n"); + strcat( menubuf, " 家族成员列表\n"); + strcat( menubuf, " 家族留言\n"); +#ifdef _UN_FMMEMO +#else + strcat( menubuf, " 家族之间留言板\n"); +#endif +#ifdef _UN_FMPOINT +#else + strcat( menubuf, " 申请家族据点\n"); +#endif + strcat( menubuf, " 家族之间强者表"); + + lssproto_WN_send(fd, + WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_FM_SELECT, + -1, + makeEscapeString( menubuf, buf, sizeof(buf))); +} +#endif diff --git a/gmsv/npc/npc_fmhealer.c b/gmsv/npc/npc_fmhealer.c new file mode 100644 index 0000000..7968f72 --- /dev/null +++ b/gmsv/npc/npc_fmhealer.c @@ -0,0 +1,144 @@ +#include "version.h" +/*---------- Shan (BEGIN) ----------*/ +/*--------- AD 2001/05/28 ---------*/ +// +// 家族医疗 +// +/*---------- Shan(END) ----------*/ +#include +#include +#include + +#include "object.h" +#include "char_base.h" +#include "char.h" +#include "util.h" +#include "npcutil.h" +#include "item.h" +#include "readmap.h" + +#define RANGE 2 +void NPC_FmHealerSpeak( int index, int talker); +void NPC_FmHealerAllHeal( int talker ); +BOOL NPC_FmMoneyCheck(int meindex,int talker); +int NPC_FmCostCheck(int talker); +void NPC_FmCharCheckPoint(int meindex,int talker); +int NPC_FmWorkInput(int meindex,int talker); + +BOOL NPC_FmHealerInit( int meindex ) +{ + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEHEALER ); + CHAR_setFlg( meindex , CHAR_ISATTACKED , 0 ); + return TRUE; +} + +void NPC_FmHealerTalked( int meindex , int talker , char *msg ,int color ) +{ + char* npcarg; + char token[32]; + int msgNo; + + npcarg = CHAR_getChar(meindex,CHAR_NPCARGUMENT); + + getStringFromIndexWithDelim( npcarg, "|", 1, token,sizeof( token)); + msgNo = atoi( token ); + + if( CHAR_getInt( talker , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) + return; + + if( NPC_Util_isFaceToFace( talker, meindex , 2 ) == FALSE ) + { + if( NPC_Util_isFaceToFace( talker, meindex , 1 ) == FALSE ) + return; + } + + //if( CHAR_getInt(meindex, CHAR_FLOOR) != CHAR_getWorkInt(talker, CHAR_WORKFMFLOOR)){ + //print("\n npc floor->%d player floor->%d",CHAR_getInt(meindex, CHAR_FLOOR), + // CHAR_getWorkInt(talker, CHAR_WORKFMFLOOR)); + // CHAR_talkToCli(talker, meindex, + // "抱歉!你不是本家族人员,无法帮你回复。",CHAR_COLORWHITE); + // return; + //} + + if( (CHAR_getWorkInt( talker, CHAR_WORKPARTYMODE) == 0) + || (CHAR_getWorkInt( talker, CHAR_WORKPARTYMODE) == 2)){ + NPC_FmHealerAllHeal( talker); + if(msgNo == 1) { + CHAR_talkToCli( talker, meindex, + "已经全部回复。请小心自己的身体唷!",CHAR_COLORWHITE); + }else if(msgNo == 2){ + CHAR_talkToCli( talker, meindex, + "由於你是本家族人员,请让我帮你回复吧!",CHAR_COLORWHITE); + } + }else{ + int i = 0; + int otherindex; + for( i=0 ; i < CHAR_PARTYMAX ; i++){ + otherindex = CHAR_getWorkInt( talker, CHAR_WORKPARTYINDEX1 + i); + if(otherindex != -1){ + NPC_FmHealerAllHeal( otherindex); + if(msgNo == 1){ + CHAR_talkToCli( otherindex, meindex, + "已经全部回复。请小心自己的身体唷!",CHAR_COLORWHITE); + }else if(msgNo == 2){ + CHAR_talkToCli( otherindex, meindex, + "由於你是本家族人员,请让我帮你回复吧!",CHAR_COLORWHITE); + } + } + } + } +} + +void NPC_FmHealerAllHeal( int talker ) +{ + int i; + int petindex; + char petsend[3]; + char msgbuf[5]; + + CHAR_setInt( talker , CHAR_HP ,CHAR_getWorkInt( talker, CHAR_WORKMAXHP ) ); + CHAR_setInt( talker , CHAR_MP ,CHAR_getWorkInt( talker, CHAR_WORKMAXMP ) ); + + for(i = 0 ; i < CHAR_MAXPETHAVE; i ++){ + petindex = CHAR_getCharPet( talker, i); + if( petindex == -1 ) continue; + + if( !CHAR_CHECKINDEX( talker ) ) continue; + if( CHAR_CHECKINDEX( petindex) == FALSE ) continue; + CHAR_setFlg( petindex, CHAR_ISDIE, 0); + CHAR_setInt( petindex , CHAR_HP ,CHAR_getWorkInt( petindex, CHAR_WORKMAXHP ) ); + CHAR_setInt( petindex , CHAR_MP ,CHAR_getWorkInt( petindex, CHAR_WORKMAXMP ) ); + CHAR_complianceParameter( petindex ); + sprintf( petsend, "K%d", i ); + CHAR_sendStatusString( talker , petsend ); + } + + if(CHAR_getWorkInt( talker, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE ){ + int topartyarray = -1; + int oyaindex = CHAR_getWorkInt( talker, CHAR_WORKPARTYINDEX1); + if( CHAR_CHECKINDEX( oyaindex )){ + int i; + for( i = 0; i < CHAR_PARTYMAX; i ++ ){ + int workindex = CHAR_getWorkInt( oyaindex, CHAR_WORKPARTYINDEX1 + i); + if( CHAR_CHECKINDEX( workindex) ){ + if( workindex == talker ){ + topartyarray = i; + break; + } + } + } + for( i = 0; i < CHAR_PARTYMAX; i ++ ) { + int otherindex = CHAR_getPartyIndex( talker, i); + if( CHAR_CHECKINDEX( otherindex) ){ + snprintf( msgbuf, sizeof( msgbuf), "N%d", topartyarray); + if( otherindex != talker){ + CHAR_sendStatusString( otherindex, msgbuf); + } + } + } + } + } + CHAR_send_P_StatusString( talker, CHAR_P_STRING_HP); + CHAR_send_P_StatusString( talker, CHAR_P_STRING_MP); +} + diff --git a/gmsv/npc/npc_fmletter.c b/gmsv/npc/npc_fmletter.c new file mode 100644 index 0000000..0625c37 --- /dev/null +++ b/gmsv/npc/npc_fmletter.c @@ -0,0 +1,679 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "configfile.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "npc_fmletter.h" +#include "family.h" +#include "log.h" + +extern struct FM_POINTLIST fmpointlist; + +char sendbuf[1024]; +char buf[1024]; +char subbuf[128]; +int i, j; + +/* + * 涩烂今木凶它奴件玉它毛请允NPC + * 棵哑 平旦玄失玉矛件民乓□仁日中卅日综木月井手[ + * + */ + +struct { + int windowno; + int windowtype; + int buttontype; + int takeitem; + int giveitem; + char message[4096]; + int letter; +}w; + +struct { + BOOL use; + int checkhaveitem; + int checkhaveitemgotowin; + int checkdonthaveitem; + int checkdonthaveitemgotowin; + int warp; + int battle; + int gotowin; +}buttonproc[13]; /* ok,cancel, yes,no,prev,next 及凛及质 */ + + + + + +enum { + CHAR_WORK_MSGCOLOR = CHAR_NPCWORKINT1, +}; + +static void NPC_FmLetter_selectWindow( int meindex, int toindex, int num); +static BOOL NPC_FmLetter_readData( int meindex, int windowno, BOOL chkflg); +static int NPC_FmLetter_restoreButtontype( char *data ); + +/********************************* +* 赓渝质 +*********************************/ +BOOL NPC_FmLetterInit( int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024]; + //int i; + //char secondToken[1024]; + + // Robin test + // print(" fmleter_Init "); + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "conff", buf, sizeof( buf)) + == NULL ) + { + print( "fmletter:没有指定设定的档案 。\n"); + return FALSE; + } + /* 赓渝凛卞涩烂犯□正毛民尼永弁仄化支月 */ + if( !NPC_FmLetter_readData( meindex, -1, TRUE) ) { + return FALSE; + } + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEWINDOWMAN ); + + return TRUE; +} + + + + +/********************************* +* 仄井仃日木凶凛及质 +*********************************/ +void NPC_FmLetterTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + //print(" FmLetter_fmindex:%d ", CHAR_getInt( meindex, CHAR_FMINDEX) ); + + + int fmindex = 0, village, i; + char token[256]; + char buf[256]; + for( i=0 ; i 1) return; + + /* 仇及它奴件玉它 寞及犯□正毛 心 戈 */ + if( !NPC_FmLetter_readData( meindex, seqno - 100, FALSE) ) { + print( "fmletter:readdata error\n"); + return; + } + /* 瓷仄凶示正件毛譬屯月 */ + if( w.windowtype == WINDOW_MESSAGETYPE_SELECT ) { + button = atoi( data)+5; + if( button > 12 ) { + print( "fmletter:invalid button[%d]\n", button); + return; + } + } + else if( select & WINDOW_BUTTONTYPE_OK) button = 0; + else if( select & WINDOW_BUTTONTYPE_CANCEL) button = 1; + else if( select & WINDOW_BUTTONTYPE_YES) button = 2; + else if( select & WINDOW_BUTTONTYPE_NO) button = 3; + else if( select & WINDOW_BUTTONTYPE_PREV) button = 4; + else if( select & WINDOW_BUTTONTYPE_NEXT) button = 5; + else { + print( "fmletter:invalid button[%d]\n", select); + return; + } + if( buttonproc[button].use == TRUE ) { + int fd; + int newwin = -1; + + fd = getfdFromCharaIndex( talkerindex); + + /* 示正件卞方匀化质 毛孔曰歹仃月 */ + if( newwin == -1 ) { + newwin = buttonproc[button].gotowin; + } + + + // Robin + if( newwin == 5 ) { + int emptyitemindexinchara = CHAR_findEmptyItemBox( talkerindex ); + int itemindex = ITEM_makeItemAndRegist( w.letter ); + + if( emptyitemindexinchara < 0 ) return; + + if( itemindex != -1 ){ + char msgbuf[128]; + CHAR_setItemIndex( talkerindex, emptyitemindexinchara, itemindex ); + /* Work犯□正毛涩烂 */ + ITEM_setWorkInt(itemindex, ITEM_WORKOBJINDEX,-1); + ITEM_setWorkInt(itemindex, ITEM_WORKCHARAINDEX, talkerindex); + CHAR_sendItemDataOne( talkerindex, emptyitemindexinchara); + LogItem( + CHAR_getChar( talkerindex, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( talkerindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), /* 失奶 丞 寞 */ +#endif + "AddLetter(制作邀请函)", + CHAR_getInt( talkerindex,CHAR_FLOOR), + CHAR_getInt( talkerindex,CHAR_X ), + CHAR_getInt( talkerindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + snprintf( msgbuf, sizeof( msgbuf), "制作%s成功\。", + ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talkerindex, -1,msgbuf, CHAR_COLORWHITE); + } + } + + // Robin + if( newwin == 6 ) { + int emptyitemindexinchara = CHAR_findEmptyItemBox( talkerindex ); + int itemindex = ITEM_makeItemAndRegist( w.letter ); + + if( emptyitemindexinchara < 0 ) return; + + if( itemindex != -1 ){ + char msgbuf[128]; + CHAR_setItemIndex( talkerindex, emptyitemindexinchara, itemindex ); + /* Work犯□正毛涩烂 */ + ITEM_setWorkInt(itemindex, ITEM_WORKOBJINDEX,-1); + ITEM_setWorkInt(itemindex, ITEM_WORKCHARAINDEX, talkerindex); + CHAR_sendItemDataOne( talkerindex, emptyitemindexinchara); + LogItem( + CHAR_getChar( talkerindex, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( talkerindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), /* 失奶 丞 寞 */ +#endif + "AddLetter(制作邀请函)", + CHAR_getInt( talkerindex,CHAR_FLOOR), + CHAR_getInt( talkerindex,CHAR_X ), + CHAR_getInt( talkerindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + snprintf( msgbuf, sizeof( msgbuf), "制作%s成功\。", + ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talkerindex, -1,msgbuf, CHAR_COLORWHITE); + } + } + + + if( !NPC_FmLetter_readData( meindex, newwin, FALSE) ) { + print( "fmletter:readdata error\n"); + return; + } + + //fd = getfdFromCharaIndex( talkerindex); + if( fd != -1 ) { + lssproto_WN_send( fd, w.windowtype, + w.buttontype, + w.windowno+100, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( w.message, buf, sizeof(buf))); + } + + + + } +} +/* + * 涩烂白央奶伙毛 氏匹隙烂今木凶windowno及犯□正毛本永玄允月 + * + * 娄醒“ + * meindex int 仇及NPC及charaindex + * windowno int 它奴件玉它 寞 + * + */ +static BOOL NPC_FmLetter_readData( int meindex, int windowno, BOOL chkflg) +{ + + int i; + int linenum = 0; + int endflg = FALSE; + int buttonendflg; + int winno = -1; + int buttonconfmode; + int b_mode; + int selectnum ; + int messagepos; + BOOL errflg = FALSE; + BOOL readflg = TRUE; + FILE *fp; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char filename[64]; + char opfile[128]; + char line[1024]; + char firstToken[1024]; + char secondToken[1024]; + + /* 它奴件玉它及涩烂毛 曰 戈厌瞻 */ + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + /* 涩烂白央奶伙 潸 */ + NPC_Util_GetStrFromStrWithDelim( argstr, "conff", filename, sizeof( filename)); + + sprintf( opfile, "%s/", getNpcdir( ) ); + strcat( opfile, filename); + + fp = fopen( opfile, "r"); + if( fp == NULL ) { + print( "fmletter:file open error [%s]\n", opfile); + return FALSE; + } + + while( readflg == TRUE ) { + endflg = FALSE; + buttonendflg = TRUE; + buttonconfmode = FALSE; + selectnum = 0; + messagepos = 0; + winno = -1; + b_mode = -1; + errflg = FALSE; + + /* 赓渝祭 */ + w.windowno = -1; + w.windowtype = -1; + w.buttontype = -1; + w.takeitem = -1; + w.giveitem = -1; + w.message[0] = '\0'; + + for( i = 0; i < arraysizeof( buttonproc); i ++ ) { + buttonproc[i].use = FALSE; + buttonproc[i].checkhaveitem = -1; + buttonproc[i].checkhaveitemgotowin = -1; + buttonproc[i].checkdonthaveitem = -1; + buttonproc[i].checkdonthaveitemgotowin = -1; + buttonproc[i].warp = -1; + buttonproc[i].battle = -1; + buttonproc[i].gotowin = -1; + } + + while( 1) { + char buf[256]; + int ret; + if( !fgets( line, sizeof( line), fp)){ + readflg = FALSE; + break; + } + + linenum ++; + + /* 戊丢件玄反 骰 */ + if( line[0] == '#' || line[0] == '\n') continue; + /* 荼垫潸月 */ + chomp( line ); + + /* 垫毛帮溥允月 */ + /* 引内 tab 毛 " " 卞 五晶尹月 */ + replaceString( line, '\t' , ' ' ); + /* 燮 及旦矢□旦毛潸月[*/ + for( i = 0; i < strlen( line); i ++) { + if( line[i] != ' ' ) { + break; + } + strcpy( buf, &line[i]); + } + if( i != 0 ) strcpy( line, buf); + + /* delim "=" 匹 赓(1)及玄□弁件毛 月*/ + ret = getStringFromIndexWithDelim( line, "=", 1, firstToken, + sizeof( firstToken ) ); + if( ret == FALSE ){ + print( "Find error at %s in line %d. Ignore\n", + filename , linenum); + continue; + } + /* delim "=" 匹2 及玄□弁件毛 月*/ + ret = getStringFromIndexWithDelim( line, "=", 2, secondToken, + sizeof( secondToken ) ); + if( ret == FALSE ){ + print( "Find error at %s in line %d. Ignore\n", + filename , linenum); + continue; + } + + if( strcasecmp( firstToken, "winno") == 0 ) { + if( winno != -1 ) { + print( "fmletter:已有winno却重新定义winno\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + readflg = FALSE; + break; + } + /* 它奴件玉它No毛忡绣 */ + winno = atoi( secondToken); + continue; + } + + /* 它奴件玉它No 互瑁引匀化中卅中凛及垫反 骰允月 */ + if( winno == -1 ) { + print( "fmletter:winno 尚未定义,资料却已设定。\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + readflg = FALSE; + errflg = FALSE; + break; + } + /* 它奴件玉它No 互域谯仄凶凛反椭瘀毛 戈[ + * 公木动陆反 骰允月 */ + if( (chkflg == FALSE && winno == windowno )|| + chkflg == TRUE) + { + if( buttonconfmode == TRUE ) { + if( strcasecmp( firstToken, "gotowin") == 0 ) { + buttonproc[b_mode].gotowin = atoi( secondToken); + } + else if( strcasecmp( firstToken, "checkhaveitem") == 0 ) { + buttonproc[b_mode].checkhaveitem = atoi( secondToken); + } + else if( strcasecmp( firstToken, "haveitemgotowin") == 0 ) { + buttonproc[b_mode].checkhaveitemgotowin = atoi( secondToken); + } + else if( strcasecmp( firstToken, "checkdonthaveitem") == 0 ) { + buttonproc[b_mode].checkdonthaveitem = atoi( secondToken); + } + else if( strcasecmp( firstToken, "donthaveitemgotowin") == 0 ) { + buttonproc[b_mode].checkdonthaveitemgotowin = atoi( secondToken); + } + else if( strcasecmp( firstToken, "endbutton") == 0 ) { + if( buttonproc[b_mode].gotowin == - 1 ) { + if( buttonproc[b_mode].checkhaveitem == -1 && + buttonproc[b_mode].checkdonthaveitem == -1) + { + errflg = TRUE; + } + else { + /* 升匀切井井凶匀吊分仃匹手涩烂今木化中木壬 */ + if( !((buttonproc[b_mode].checkhaveitem != -1 && + buttonproc[b_mode].checkhaveitemgotowin != -1) + || (buttonproc[b_mode].checkdonthaveitem != -1 && + buttonproc[b_mode].checkdonthaveitemgotowin != -1))) + { + errflg = TRUE; + } + } + } + + if( errflg == TRUE) { + print( "fmletter: 找不到gotowin\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + readflg = FALSE; + errflg = TRUE; + break; + } + buttonproc[b_mode].use = TRUE; + buttonconfmode = FALSE; + buttonendflg = TRUE; + } + } + else { + + w.windowno = winno; + + sprintf( buf, "letter%d", CHAR_getInt( meindex, CHAR_FMINDEX) ); + + /* 它奴件玉它正奶皿及涩烂 */ + if( strcasecmp( firstToken, "wintype") == 0 ) { + w.windowtype = atoi( secondToken); + } + /* 示正件正奶皿及涩烂 */ + else if( strcasecmp( firstToken, "buttontype") == 0 ) { + w.buttontype = NPC_FmLetter_restoreButtontype( secondToken); + } + /* getitem及涩烂 */ + else if( strcasecmp( firstToken, "takeitem") == 0 ) { + w.takeitem = atoi( secondToken); + } + /* giveitem及涩烂 */ + else if( strcasecmp( firstToken, "giveitem") == 0 ) { + w.giveitem = atoi( secondToken); + } + else if( strcasecmp( firstToken, buf) == 0 ) { + w.letter = atoi( secondToken); + } + + /* message及涩烂 */ + else if( strcasecmp( firstToken, "message") == 0 ) { + if( messagepos == 0 ) { + strcpy( w.message, secondToken); + messagepos = strlen( w.message); + } + else { + w.message[messagepos]='\n'; + messagepos++; + strcpy( &w.message[messagepos], secondToken); + messagepos+=strlen(secondToken); + } + } + /* 示正件毛瓷仄凶凛及涩烂 */ + else if( strcasecmp( firstToken, "okpressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 0; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "cancelpressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 1; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "yespressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 2; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "nopressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 3; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "prevpressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 4; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "nextpressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 5; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "selected") == 0 ) { + buttonconfmode = TRUE; + b_mode = 6 + selectnum; + buttonendflg = FALSE; + selectnum ++; + } + /* 涩烂蔽歹曰 */ + else if( strcasecmp( firstToken, "endwin") == 0 ) { + endflg = TRUE; + if( chkflg == FALSE) { + readflg = FALSE; + } + break; + } + else { + //print( "fmletter:设定是不可能的参数\n"); + //print( "filename:[%s] line[%d]\n", filename, linenum); + } + } + } + else { + if( strcasecmp( firstToken, "endwin") == 0 ) { + winno = -1; + } + } + } + if( buttonendflg == FALSE) { + print( "fmletter: 找不到endbutton\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + break; + } + if( winno != -1 ) { + if( w.windowtype == -1 ) { + print( "fmletter: 找不到wintype\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + break; + } + if( w.buttontype == -1 ) { + print( "fmletter: 找不到button\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + break; + } + if( strlen( w.message) == 0 ) { + print( "fmletter: 找不到message\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + break; + } + } + } + fclose( fp); + + if( chkflg == FALSE && w.windowno == -1 ) { + print( "fmletter: 找不到所指定的windowno\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + return FALSE; + } + if( winno != -1 && endflg == FALSE) { + print( "fmletter: 找不到endwin\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + return FALSE; + } + if( errflg == TRUE) return FALSE; + + return TRUE; +} +/* + * buttontype=匹隙烂仄凶 侬 毛醒袄卞 晶允月[ + * + */ +static int NPC_FmLetter_restoreButtontype( char *data ) +{ + int ret = 0; + int rc; + int i; + char buff[1024]; + + for( i = 1; ; i ++ ) { + rc = getStringFromIndexWithDelim( data, "|", i, buff, + sizeof( buff ) ); + if( rc == FALSE) break; + if( strcasecmp( buff, "ok") == 0 ) { + ret |= WINDOW_BUTTONTYPE_OK; + } + else if( strcasecmp( buff, "cancel") == 0 ) { + ret |= WINDOW_BUTTONTYPE_CANCEL; + } + else if( strcasecmp( buff, "yes") == 0 ) { + ret |= WINDOW_BUTTONTYPE_YES; + } + else if( strcasecmp( buff, "no") == 0 ) { + ret |= WINDOW_BUTTONTYPE_NO; + } + else if( strcasecmp( buff, "prev") == 0 ) { + ret |= WINDOW_BUTTONTYPE_PREV; + } + else if( strcasecmp( buff, "next") == 0 ) { + ret |= WINDOW_BUTTONTYPE_NEXT; + } + } + if( ret == 0 ) { + ret = atoi( data); + } + return ret; +} + + + + diff --git a/gmsv/npc/npc_fmpkcallman.c b/gmsv/npc/npc_fmpkcallman.c new file mode 100644 index 0000000..1549722 --- /dev/null +++ b/gmsv/npc/npc_fmpkcallman.c @@ -0,0 +1,392 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "npc_fmpkcallman.h" +#include "family.h" +#include "readmap.h" +#include "battle.h" +#include "log.h" + +// WON ADD 增加族长召唤的限制 +#include "npc_scheduleman.h" +#include "handletime.h" + + +static void NPC_FMPKCallMan_selectWindow(int meindex, int toindex, int num, int select); +void NPC_CallFMMember(int meindex, int floor, int fmindex, char *fmname, int index); + +/********************************* +* 赓渝质 +*********************************/ +BOOL NPC_FMPKCallManInit( int meindex ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024]; + char buff2[256]; + int fl, x, y; + + if( NPC_Util_GetArgStr( meindex, npcarg, sizeof( npcarg)) == NULL){ + print("FMPKCallMan:GetArgStrErr"); + return FALSE; + } + + /*--伐□皿互涩烂今木化中月井----*/ + /*--伐□皿互涩烂今木化卅仃木壬NPC毛综日卅中仇午卞允月--*/ + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "WARP", buf, sizeof( buf))==NULL){ + print("FMPKCallMan Err is %s",npcarg); + print("FMPKCallMan Err"); + return FALSE; + } + + /*--伐□皿互涩烂今木化中化手伐□皿燮互卅仃木壬手切欠氏NPC毛综日卅中--*/ + getStringFromIndexWithDelim(buf,",",1,buff2,sizeof(buff2)); + fl=atoi(buff2); + getStringFromIndexWithDelim(buf,",",2,buff2,sizeof(buff2)); + x=atoi(buff2); + getStringFromIndexWithDelim(buf,",",3,buff2,sizeof(buff2)); + y=atoi(buff2); + + if( MAP_IsValidCoordinate( fl,x,y )== FALSE ){ + print( "FMWarp NPC:Invalid warpman ERR" ); + return FALSE; + } + + /*--正奶皿涩烂--*/ + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEWARPMAN ); + + return TRUE; +} + +/********************************* +* 仄井仃日木凶凛及质 +*********************************/ +void NPC_FMPKCallManTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + /* 皿伊奶乩□卞覆仄化分仃 杀允月 */ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + + /*-- 及蟆卞中月井升丹井"--*/ + if(NPC_Util_isFaceToFace(talkerindex,meindex,2 )==FALSE){ + /* ㄠ弘伉永玉动 及心 */ + if( NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) return; + } + + /*--伐□弁及赓渝祭--*/ + CHAR_setWorkInt(talkerindex, CHAR_WORKSHOPRELEVANT, 0); + + /*-反元户及蓟 --*/ + NPC_FMPKCallMan_selectWindow( meindex, talkerindex, 0, -1); +} + +static void NPC_FMPKCallMan_selectWindow( int meindex, int toindex, + int num,int select) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[1024], buf[256], buf2[256]; + int fd = getfdFromCharaIndex(toindex); + + if( fd == -1 ) { + fprint( "getfd err\n"); + return; + } + + // print("meindex:%d toindex:%d num:%d select:%d", meindex, toindex, num, select); + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr"); + return ; + } + /*--涩烂白央奶伙及 卞白夫失谛醒互隙烂今木化中月井今木化中木壬白夫失谛醒及喃曰请仄*/ + if(strstr(npcarg,"%4d")!=NULL){ + int work; + NPC_Util_GetStrFromStrWithDelim( npcarg, "WARP", buf, sizeof( buf)); + getStringFromIndexWithDelim(buf,",",1,buf2,sizeof(buf2)); + work = atoi( buf2); + } + + token[0] = '\0'; + + switch(num) { + + case 0: + if (NPC_Util_GetStrFromStrWithDelim(npcarg, "MainMsg", buf, + sizeof(buf)) == NULL) + return; + sprintf(token, "3\n ★家族PK场★\n" + "%s" + "\n 《召唤家族成员》" + "\n 《返回记录点》" + "\n 《取消》", + buf); + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_FMPKCALLMAN_START, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token); + break; + case 1: +#ifdef _FMVER21 + if( CHAR_getInt( toindex, CHAR_FMLEADERFLAG) == FMMEMBER_LEADER) +#else + if( CHAR_getInt( toindex, CHAR_FMLEADERFLAG) == 1) +#endif + { + if (CHAR_getWorkInt(toindex, CHAR_WORKFMSETUPFLAG) != 1) + { + if (NPC_Util_GetStrFromStrWithDelim(npcarg, "NoSetupMsg", buf, + sizeof(buf)) == NULL) + return; + if (strstr(buf, "%s") != NULL) + sprintf(token, buf, CHAR_getChar(toindex, CHAR_FMNAME)); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, token); + } + else + { + if (NPC_Util_GetStrFromStrWithDelim(npcarg, "CallMsg", buf, + sizeof(buf)) == NULL) + return; + if (strstr(buf, "%s") != NULL) + sprintf(token, buf, CHAR_getChar(toindex, CHAR_FMNAME)); + +// WON ADD 增加族长召唤的限制 + { + int fmindex, fmpk_pos=-1, j; + int now_time; + struct tm tm1; +// Terry add for 索引值为 0 的家族会有问题,所以多加判断家族名称 + char szFMName[32]; +// end + + memcpy(&tm1,localtime((time_t *)&NowTime.tv_sec),sizeof(tm1)); + + fmindex = CHAR_getWorkInt(toindex, CHAR_WORKFMINDEXI); +// Terry add for 索引值为 0 的家族会有问题,所以多加判断家族名称 + strncpy(szFMName,CHAR_getChar(toindex,CHAR_FMNAME),sizeof(szFMName)); +// end + + for( j=0; j <= MAX_SCHEDULEMAN*MAX_SCHEDULE; j++ ){ +// Terry fix for 索引值为 0 的家族会有问题,所以多加判断家族名称 +// if( (fmindex == fmpks[j].host_index ) || (fmindex == fmpks[j].guest_index ) ){ + if((fmindex == fmpks[j].host_index && strcmp(szFMName,fmpks[j].host_name) == 0) || + (fmindex == fmpks[j].guest_index && strcmp(szFMName,fmpks[j].guest_name) == 0)){ +//end + fmpk_pos=j; + break; + } + } + + if(fmpk_pos != -1){ + + if(fmpk_pos <= MANORNUM*MAX_SCHEDULE+1){ + now_time=NowTime.tv_sec+(60*60); + }else{ + if(tm1.tm_hour+1==24) now_time=10000; + else now_time=(tm1.tm_hour+1) * 100; + } + + if( (fmpks[fmpk_pos].flag != FMPKS_FLAG_SCHEDULED) && + (fmpks[fmpk_pos].flag != FMPKS_FLAG_MANOR_PREPARE) ) + { + sprintf(token,"你没有家族约战,请先约战吧。"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, token); + + }else if( now_time < fmpks[fmpk_pos].dueltime ){ + + sprintf(token,"请在对战前一小时再来召唤族员吧!"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, token); + + }else{ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_YESNO, + CHAR_WINDOWTYPE_FMPKCALLMAN_CALL, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token); + } + }else{ + sprintf(token,"你没有家族约战,请先约战吧。"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, token); + } + } + + } + } else { + if (NPC_Util_GetStrFromStrWithDelim(npcarg, "NoLeaderMsg", buf, + sizeof(buf)) == NULL) + return; + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, buf); + } + break; + case 2: + if (NPC_Util_GetStrFromStrWithDelim(npcarg, "LeavepkMsg", buf, + sizeof(buf)) == NULL) + return; + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_YESNO, + CHAR_WINDOWTYPE_FMPKCALLMAN_LEAVE, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), buf); + break; + } +} + +/*----------------------------------------- + * 弁仿奶失件玄井日忒匀化五凶凛卞裟太请今木月[ + * +-------------------------------------------*/ +void NPC_FMPKCallManWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + int datanum = -1, fl, x, y; + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024], buff2[256]; + + int fd = getfdFromCharaIndex(talkerindex); + if (fd == -1) return; + if (NPC_Util_GetArgStr(meindex, npcarg, sizeof(npcarg)) == NULL) + { + print("GetArgStrErr"); + return; + } + NPC_Util_GetStrFromStrWithDelim(npcarg, "WARP", buf, sizeof(buf)); + getStringFromIndexWithDelim(buf, ",", 1, buff2, sizeof(buff2)); + fl = atoi(buff2); + getStringFromIndexWithDelim(buf, ",", 2, buff2, sizeof(buff2)); + x = atoi(buff2); + getStringFromIndexWithDelim(buf, ",", 3, buff2, sizeof(buff2)); + y = atoi(buff2); + + makeStringFromEscaped( data); + + print("meindex:%d seqno:%d select:%d data:%s\n", meindex, seqno, select, data); + + datanum = atoi( data); + switch( seqno){ + + /*--反元引曰及 --*/ + case CHAR_WINDOWTYPE_FMPKCALLMAN_START: + if (datanum == 1) + NPC_FMPKCallMan_selectWindow(meindex, talkerindex, 1, -1); + else if (datanum == 2) + NPC_FMPKCallMan_selectWindow(meindex, talkerindex, 2, -1); + break; + case CHAR_WINDOWTYPE_FMPKCALLMAN_CALL: + if (select == WINDOW_BUTTONTYPE_YES) + { + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString("\n召唤中···请稍候!\n@#$%↑&*···", buf, sizeof(buf))); + NPC_CallFMMember(meindex, + CHAR_getInt(talkerindex, CHAR_FLOOR), + CHAR_getInt(talkerindex, CHAR_FMINDEX), + CHAR_getChar(talkerindex, CHAR_FMNAME), + CHAR_getWorkInt(talkerindex, CHAR_WORKFMINDEXI)); + } + break; + case CHAR_WINDOWTYPE_FMPKCALLMAN_COME: + if (select == WINDOW_BUTTONTYPE_YES) + { + print("CHAR_WINDOWTYPE_FMPKCALLMAN_COME\n"); + if (CHAR_getWorkInt(talkerindex, CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) + return; + if (CHAR_getWorkInt(talkerindex, CHAR_WORKPARTYMODE) + != CHAR_PARTY_NONE) + CHAR_DischargeParty(talkerindex, 0); + + CHAR_setWorkInt(talkerindex, CHAR_WORKWARPCHECK, FALSE); + CHAR_setWorkInt(talkerindex, CHAR_WORKFMPKFLAG, 1); + CHAR_warpToSpecificPoint(talkerindex, fl, x, y); + } + break; + case CHAR_WINDOWTYPE_FMPKCALLMAN_LEAVE: + if (select == WINDOW_BUTTONTYPE_YES) + { + int spfl = 0, spx = 0, spy = 0, i = 0, itemindex = 0; + if (CHAR_getWorkInt(talkerindex, CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) + return; + if (CHAR_getWorkInt(talkerindex, CHAR_WORKPARTYMODE) + != CHAR_PARTY_NONE) + { + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString("\n无法以团队方式离开唷!\n请先解散团队!", buf, sizeof(buf))); + return; + } + for (i = 0; i < CHAR_MAXITEMHAVE; i++) + { + itemindex = CHAR_getItemIndex(talkerindex, i); + if (ITEM_CHECKINDEX(itemindex) == FALSE) continue; + + if (ITEM_getInt(itemindex, ITEM_DROPATLOGOUT) == TRUE) + { + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString("\n您身上有贵重物品喔!\n为了避免在传送途中不小心损坏,\n请先将这类物品卸下,\n谢谢您的合作!", buf, sizeof(buf))); + return; + } + + } + CHAR_setWorkInt(talkerindex, CHAR_WORKWARPCHECK, FALSE); + CHAR_getElderPosition(CHAR_getInt(talkerindex, CHAR_LASTTALKELDER), + &spfl, &spx, &spy); + CHAR_warpToSpecificPoint(talkerindex, spfl, spx, spy); + } + break; + default: + break; + } +} + +extern struct FM_PKFLOOR fmpkflnum[FAMILY_FMPKFLOOR]; +void NPC_CallFMMember(int meindex, int floor, int fmindex, char *fmname, int index) +{ + int i, charindex; + char buf[256]; + extern int familyMemberIndex[FAMILY_MAXNUM][FAMILY_MAXMEMBER]; + print("CallFMMember_NPC_meindex:%d\n", meindex); + for( i = 0; i < FAMILY_MAXMEMBER; i++) + { + charindex = familyMemberIndex[index][i]; + if( charindex >= 0 ) { + if( CHAR_getCharUse(charindex) ) + { + print("charindex:%d name:%s\n", charindex, CHAR_getChar(charindex, CHAR_NAME)); + if (CHAR_getInt(charindex, CHAR_FLOOR) == floor) continue; + if (CHAR_getWorkInt(charindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE) + { + int fd = getfdFromCharaIndex(charindex); + int charfloor = CHAR_getInt(charindex, CHAR_FLOOR); + int j = 0, checkflag = 0; + if (fd == -1) continue; +#ifdef _FMVER21 + if (CHAR_getInt(charindex, CHAR_FMLEADERFLAG) < 0 || + CHAR_getInt(charindex, CHAR_FMLEADERFLAG) == FMMEMBER_APPLY) continue; +#else + if (CHAR_getInt(charindex, CHAR_FMLEADERFLAG) <= 0 ) continue; +#endif + for (j = 0; j < FAMILY_FMPKFLOOR; j++) + { + if (charfloor == fmpkflnum[j].fl) + checkflag = 1; + } + if (checkflag != 1) + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_YESNO, CHAR_WINDOWTYPE_FMPKCALLMAN_COME, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + makeEscapeString("\n家族已经在PK罗~要不要加入呢?\n不过若是在组队状态中,将会脱离团队唷!", buf, sizeof(buf))); + } + } + else + familyMemberIndex[index][i] = -1; + } + } +} diff --git a/gmsv/npc/npc_fmpkman.c b/gmsv/npc/npc_fmpkman.c new file mode 100644 index 0000000..ea28a8d --- /dev/null +++ b/gmsv/npc/npc_fmpkman.c @@ -0,0 +1,301 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "npc_fmpkman.h" +#include "npc_scheduleman.h" +#include "npc_fmwarpman.h" +#include "family.h" +#include "readmap.h" +#include "battle.h" +#include "log.h" + +enum { + NPC_WORK_ID = CHAR_NPCWORKINT1, +}; + +static void NPC_FMPKMan_selectWindow(int meindex, int toindex, int num, int select); +// shan add +BOOL NPC_PARTY_CHAECK1(int meindex,int talker); +void NPC_ERR_DiSP1(int meindex,int talker,int errNO); + +/********************************* +* 赓渝质 +*********************************/ +BOOL NPC_FMPKManInit( int meindex ) +{ + + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024]; + char buff2[256]; + int fl, x, y, meid; + + if( NPC_Util_GetArgStr( meindex, npcarg, sizeof( npcarg)) == NULL){ + print("FMPKMan:GetArgStrErr"); + return FALSE; + } + + /*--伐□皿互涩烂今木化中月井----*/ + /*--伐□皿互涩烂今木化卅仃木壬NPC毛综日卅中仇午卞允月--*/ + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "WARP", buf, sizeof( buf))==NULL){ + print("FMPKMan Err is %s",npcarg); + print("FMPKMan Err"); + return FALSE; + } + + /*--伐□皿互涩烂今木化中化手伐□皿燮互卅仃木壬手切欠氏NPC毛综日卅中--*/ + getStringFromIndexWithDelim(buf,",",1,buff2,sizeof(buff2)); + fl=atoi(buff2); + getStringFromIndexWithDelim(buf,",",2,buff2,sizeof(buff2)); + x=atoi(buff2); + getStringFromIndexWithDelim(buf,",",3,buff2,sizeof(buff2)); + y=atoi(buff2); + + if( MAP_IsValidCoordinate( fl,x,y )== FALSE ){ + print( "FMWarp NPC:Invalid warpman ERR" ); + return FALSE; + } + + meid = NPC_Util_GetNumFromStrWithDelim(npcarg, "ID"); + if ((meid < 0) || (meid >= MAX_SCHEDULEMAN)) + { + print("FMPKMAN NPC: Init error Invalid ID:%d", meid); + return FALSE; + } + CHAR_setWorkInt(meindex, NPC_WORK_ID, meid); + + /*--正奶皿涩烂--*/ + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEWARPMAN ); + + return TRUE; + +} + +/********************************* +* 仄井仃日木凶凛及质 +*********************************/ +void NPC_FMPKManTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + /* 皿伊奶乩□卞覆仄化分仃 杀允月 */ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + + /*-- 及蟆卞中月井升丹井"--*/ + if(NPC_Util_isFaceToFace(talkerindex,meindex,2 )==FALSE){ + /* ㄠ弘伉永玉动 及心 */ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) return; + } + + /*--伐□弁及赓渝祭--*/ + CHAR_setWorkInt(talkerindex, CHAR_WORKSHOPRELEVANT, 0); + + /*-反元户及蓟 --*/ + NPC_FMPKMan_selectWindow( meindex, talkerindex, 0, -1); +} + +static void NPC_FMPKMan_selectWindow( int meindex, int toindex, int num,int select) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[1024], buf[256], buf2[256]; + int buttontype = 0, windowtype = 0, windowno = 0; + int fd = getfdFromCharaIndex(toindex); + int num1 = 0, num2 = 0; + int fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID) * MAX_SCHEDULE; + + if( fd == -1 ) { + print( "getfd err\n"); + return; + } + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr"); + return ; + } + /*--涩烂白央奶伙及 卞白夫失谛醒互隙烂今木化中月井今木化中木壬白夫失谛醒及喃曰请仄*/ + if(strstr(npcarg,"%4d")!=NULL){ + int work; + NPC_Util_GetStrFromStrWithDelim( npcarg, "WARP", buf, sizeof( buf)); + getStringFromIndexWithDelim(buf,",",1,buf2,sizeof(buf2)); + work = atoi( buf2); + } + + token[0] = '\0'; + + switch(num){ + // 赓及它奴件玉它 + case 0: + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "MainMsg", buf, + sizeof( buf)) == NULL) + return; + sprintf(token, "3\n     ★家族PK场★\n" + "%s" + "\n 《 察看双方人数 》" + "\n 《 离开PK场 》", + buf); + buttontype = WINDOW_BUTTONTYPE_NONE; + windowtype = WINDOW_MESSAGETYPE_SELECT; + windowno = CHAR_WINDOWTYPE_FMPKMAN_START; + break; + case 1: + if(NPC_Util_GetStrFromStrWithDelim(npcarg, "ViewMsg", buf, + sizeof(token)) == NULL) + return; + NPC_GetPKFMNum(CHAR_getInt(toindex, CHAR_FLOOR), + fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_index, + &num1, &num2); +/* + print("host:%s guest:%s hostindex:%d guestindex:%d\n", + fmpks[fmpks_pos].host_name, + fmpks[fmpks_pos].guest_name, + fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_index); +*/ + sprintf(token, "\n%s\n\n%s:%4d人\n\n%s:%4d人", buf, + fmpks[fmpks_pos].host_name, num1, + fmpks[fmpks_pos].guest_name, num2); + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_FMPKMAN_VIEW; + break; + case 2: + if(NPC_Util_GetStrFromStrWithDelim(npcarg, "LeavepkMsg", token, + sizeof(token)) == NULL) + return; + + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_FMPKMAN_LEAVEPK; + break; + default: + break; + } + + /*--巨旦弗□皿--*/ + //makeEscapeString( token, escapedname, sizeof(escapedname)); + + + /*--霜耨--*/ + lssproto_WN_send( fd, windowtype, + buttontype, + windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + +} + +/*----------------------------------------- + * 弁仿奶失件玄井日忒匀化五凶凛卞裟太请今木月[ + * +-------------------------------------------*/ +void NPC_FMPKManWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + int datanum = -1, fl, x, y; + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024], buff2[256]; + + if (NPC_Util_GetArgStr(meindex, npcarg, sizeof(npcarg)) == NULL) + { + print("GetArgStrErr"); + return; + } + NPC_Util_GetStrFromStrWithDelim(npcarg, "WARP", buf, sizeof(buf)); + getStringFromIndexWithDelim(buf, ",", 1, buff2, sizeof(buff2)); + fl = atoi(buff2); + getStringFromIndexWithDelim(buf, ",", 2, buff2, sizeof(buff2)); + x = atoi(buff2); + getStringFromIndexWithDelim(buf, ",", 3, buff2, sizeof(buff2)); + y = atoi(buff2); + + makeStringFromEscaped( data); + +// print("meindex:%d seqno:%d select:%d data:%s\n", meindex, seqno, select, data); + + datanum = atoi( data); + switch( seqno){ + + /*--反元引曰及 --*/ + case CHAR_WINDOWTYPE_FMPKMAN_START: + if (datanum == 1) + NPC_FMPKMan_selectWindow(meindex, talkerindex, 1, -1); + else if (datanum == 2) + NPC_FMPKMan_selectWindow(meindex, talkerindex, 2, -1); + break; + case CHAR_WINDOWTYPE_FMPKMAN_VIEW: + break; + case CHAR_WINDOWTYPE_FMPKMAN_LEAVEPK: + if (select == WINDOW_BUTTONTYPE_YES) + { + if (CHAR_getWorkInt(talkerindex, CHAR_WORKBATTLEMODE) + != BATTLE_CHARMODE_NONE) + return; + + // shan add + if(NPC_PARTY_CHAECK1( meindex, talkerindex)==FALSE){ + NPC_ERR_DiSP1( meindex, talkerindex, 1); + return; + } + + CHAR_setWorkInt(talkerindex, CHAR_WORKWARPCHECK, FALSE); + CHAR_warpToSpecificPoint(talkerindex, fl, x, y); + } + break; + default: + break; + } +} + +// shan add +BOOL NPC_PARTY_CHAECK1(int meindex,int talker) +{ + if(CHAR_getWorkInt(talker,CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE){ + return FALSE; + } + return TRUE; +} + +// shan add errNO=1(组队) +void NPC_ERR_DiSP1(int meindex,int talker,int errNO) +{ + char token[1024]; + int i=0; + int otherindex; + int fd = getfdFromCharaIndex( talker); + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr"); + return ; + } + + if(errNO==1){ + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "PartyMsg",token, sizeof( token))==NULL){ + sprintf(token, "无法以团队离场。\n\n请把团队解散之後再个别\n离场。"); + } + + if(CHAR_getWorkInt(talker,CHAR_WORKPARTYMODE)==CHAR_PARTY_CLIENT){ + + }else{ + for( i=0 ; i < CHAR_PARTYMAX ;i++){ + otherindex=CHAR_getWorkInt(talker,CHAR_WORKPARTYINDEX1+i); + if(otherindex != -1){ + fd = getfdFromCharaIndex( otherindex); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_WINDOWWARPMAN_ERR, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + } + } + return ; + } + } +} + + + diff --git a/gmsv/npc/npc_fmwarpman.c b/gmsv/npc/npc_fmwarpman.c new file mode 100644 index 0000000..9e18978 --- /dev/null +++ b/gmsv/npc/npc_fmwarpman.c @@ -0,0 +1,1272 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "npc_fmwarpman.h" +#include "npc_scheduleman.h" +#include "readmap.h" +#include "log.h" +#include "battle.h" +#include "handletime.h" +#include "family.h" +#include "errno.h" + +#define FMWARPMAN_INIT_LOOPTIME 600 // 0.1秒 +#define FMWARPMAN_FREE_LOOPTIME 9000 // 1.5秒 +#define FMWARPMAN_BUSY_LOOPTIME 3000 // 0.5秒 +#define FMWARPMAN_WAIT_LOOPTIME 18000 // 3秒 +#define FMWARPMAN_CLEANPLACE 59 +//#define FMWARPMAN_CLEANPLACE 9 +#define TRUE 1 +#define FALSE 0 +// CoolFish Rem 2002/2/25 +// #define MANOR 4 + +enum { + NPC_WORK_MODEFLAG = CHAR_NPCWORKINT1, + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT2, + NPC_WORK_WARPFLOOR = CHAR_NPCWORKINT3, + NPC_WORK_FMNUMI = CHAR_NPCWORKINT4, + NPC_WORK_FMNUMII = CHAR_NPCWORKINT5, + NPC_WORK_ID = CHAR_NPCWORKINT6, + NPC_WORK_TIMEFLAG = CHAR_NPCWORKINT9, + NPC_WORK_TALKFLAG = CHAR_NPCWORKINT10, + NPC_WORK_CleanTime = CHAR_NPCWORKINT11, +}; + +enum { + NPC_STATEINIT, + NPC_STATEFREE, + NPC_STATEBUSY, + NPC_STATEWAIT, +}; + +enum { + NPC_WORK_WINFMNAME = CHAR_NPCWORKCHAR1, +}; + +void NPC_ERR_FMDiSP(int meindex, int talker, int errNO); +static void NPC_FMWarpMan_selectWindow(int meindex, int toindex, int num, int select); +void NPC_FMBATTLESET(int floor, int index1, int index2, int flag); +void NPC_WarpFamily(int floor, int index1, int index2, int fl, int x, int y); +void NPC_BattleOut(int fmindex, int fmindex1); +void NPC_CleanPK(int floor, int meindex); +int NPC_FMFloorUse(int floor); +void NPC_talkToFloor(int floor, int index1, int index2, char *data); +void CheckLeavePK(int npcindex, int floor, int index1, int index2); + +void CHECK_FMPknumInFloor( int meindex) +{ + int fmnum1 = 0, fmnum2 = 0; + int fmpks_pos; + + fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID) * MAX_SCHEDULE; + // Nuke 20040920: Bug fix 庄园人数满时要检查总人数 + //print("<<%d %d>>",fmpks_pos,MAX_SCHEDULEMAN); + //if( fmpks_pos < 0 || fmpks_pos >= MAX_SCHEDULEMAN ) return; + if( fmpks_pos < 0 || fmpks_pos >= MAX_SCHEDULEMAN * MAX_SCHEDULE ) return; + NPC_GetPKFMNum(CHAR_getWorkInt(meindex, NPC_WORK_WARPFLOOR), + fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_index, + &fmnum1, &fmnum2 ); + + CHAR_setWorkInt( meindex, NPC_WORK_FMNUMI , fmnum1); + CHAR_setWorkInt( meindex, NPC_WORK_FMNUMII, fmnum2); +} + +extern int familyMemberIndex[FAMILY_MAXNUM][FAMILY_MAXMEMBER]; + +BOOL NPC_FMWarpManInit( int meindex ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff2[256]; + char buf[1024]; + int fl, x, y, meid; + // shan + int fl1, x1, y1; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("FMWarpMan:GetArgStrErr"); + return FALSE; + } + + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "WARP1", buf, sizeof( buf))==NULL){ + print("FMWarpman Err is %s",npcarg); + print("FMWarpman Err"); + return FALSE; + } + + getStringFromIndexWithDelim(buf,",",1,buff2,sizeof(buff2)); + fl=atoi(buff2); + CHAR_setWorkInt(meindex, NPC_WORK_WARPFLOOR, fl); + getStringFromIndexWithDelim(buf,",",2,buff2,sizeof(buff2)); + x=atoi(buff2); + getStringFromIndexWithDelim(buf,",",3,buff2,sizeof(buff2)); + y=atoi(buff2); + + if( MAP_IsValidCoordinate( fl,x,y )== FALSE ){ + print( "FMWarp NPC:Invalid warpman ERR" ); + return FALSE; + } + + // shan begin + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "WARP2", buf, sizeof( buf))==NULL){ + print("FMWarpman Err is %s",npcarg); + print("FMWarpman Err"); + return FALSE; + } + getStringFromIndexWithDelim(buf,",",1,buff2,sizeof(buff2)); + fl1=atoi(buff2); + CHAR_setWorkInt(meindex, NPC_WORK_WARPFLOOR, fl); + getStringFromIndexWithDelim(buf,",",2,buff2,sizeof(buff2)); + x1=atoi(buff2); + getStringFromIndexWithDelim(buf,",",3,buff2,sizeof(buff2)); + y1=atoi(buff2); + if( MAP_IsValidCoordinate( fl1,x1,y1 )== FALSE ){ + print( "FMWarp NPC:Invalid warpman ERR" ); + return FALSE; + } + // shan end + + meid = NPC_Util_GetNumFromStrWithDelim(npcarg, "ID"); + if ((meid < 0) || (meid >= MAX_SCHEDULEMAN)) + { + print("FMWARP NPC: Init error invalid ID:%d\n", meid); + return FALSE; + } + + /*--正奶皿涩烂--*/ + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, FMWARPMAN_INIT_LOOPTIME); + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEWARPMAN ); + CHAR_setWorkInt(meindex, NPC_WORK_MODEFLAG, NPC_STATEINIT); + CHAR_setWorkInt(meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + CHAR_setWorkInt(meindex, NPC_WORK_TIMEFLAG, 0); + CHAR_setWorkInt(meindex, NPC_WORK_TALKFLAG, -1); + CHAR_setWorkInt(meindex, NPC_WORK_ID, meid); + CHAR_setWorkInt(meindex, NPC_WORK_FMNUMI, 0); + CHAR_setWorkInt(meindex, NPC_WORK_FMNUMII, 0); + + CHAR_setWorkInt( meindex, NPC_WORK_CleanTime, 6*10); + + return TRUE; +} + +void NPC_FMWarpManTalked(int meindex, int talkerindex, char *szMes, int color) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + CHAR_setWorkInt( talkerindex, CHAR_WORKWARPCHECK, FALSE ); + + 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; + } + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr"); + return ; + } + + if(CHAR_getWorkInt(talkerindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE){ + NPC_ERR_FMDiSP( meindex, talkerindex, 1); + } + + CHAR_setWorkInt( talkerindex , CHAR_WORKSHOPRELEVANTTRD , 0 ); + NPC_FMWarpMan_selectWindow( meindex, talkerindex, 0, -1); +} + +void NPC_FMWarpManLoop(int meindex) +{ + struct tm tm1; + struct tm *tm2; + int fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID) * MAX_SCHEDULE; + int floor = CHAR_getWorkInt(meindex, NPC_WORK_WARPFLOOR); +#ifdef _DEATH_FAMILY_GM_COMMAND // WON ADD 家族战GM指令 + int i; + int playernum = CHAR_getPlayerMaxNum(); +#endif + + // WON ADD 修正snprintf会导致当机的bug + if( (tm2=localtime((time_t *)&NowTime.tv_sec) ) == NULL ){ + print("\n won ==> time err !! "); + return; + } + memcpy(&tm1, localtime((time_t *)&NowTime.tv_sec), sizeof(tm1)); + +#ifdef _DEATH_FAMILY_GM_COMMAND // WON ADD 家族战GM指令 + { + static int next_time[5] = {10,20,30,40,50}, flag[5] = {0}; + int now_time = time(NULL); + int j, ID = 0; + + ID = CHAR_getWorkInt(meindex, NPC_WORK_ID) - MANORNUM ; + + if( flag[ ID - 1 ] == 0 ){ + next_time[ ID - 1 ] += now_time; + flag[ ID -1 ] = 1; + } + + if( now_time > next_time[ID - 1] ){ + next_time[ID -1] = now_time + (60 * 5); + + for( i=0; i= 准备时间则设定BUSY状态 + + if (tm1.tm_min > CHAR_getWorkInt(meindex, NPC_WORK_TALKFLAG) + && tm1.tm_min == 0) + { + // 通知成员进场 + if (fmpks[fmpks_pos].flag == FMPKS_FLAG_SCHEDULED) + NPC_talkToFloor(CHAR_getInt(meindex, CHAR_FLOOR), + fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_index, "可以准备进场了!"); + CHAR_setWorkInt(meindex, NPC_WORK_TALKFLAG, tm1.tm_min); + } + if ((fmpks[fmpks_pos].prepare_time > 0) && (fmpks[fmpks_pos].flag == FMPKS_FLAG_SCHEDULED)) + { + int clock = 0; + + NPC_FMBATTLESET(floor, fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_index, -1); + if (tm1.tm_hour - (fmpks[fmpks_pos].dueltime / 100) < 0) + clock = (fmpks[fmpks_pos].dueltime % 100) + fmpks[fmpks_pos].prepare_time - 60; + else + clock = fmpks[fmpks_pos].dueltime - (tm1.tm_hour * 100) + fmpks[fmpks_pos].prepare_time; + + if ((tm1.tm_min >= clock) && (fmpks[fmpks_pos].prepare_time > 0)) + { + + NPC_talkToFloor(floor, fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_index, "开战罗~!!"); + CHAR_setWorkInt(meindex, NPC_WORK_MODEFLAG, NPC_STATEBUSY); + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, FMWARPMAN_BUSY_LOOPTIME); + NPC_FMBATTLESET(floor, fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_index, 1); + + print("\n won ==> set fmwaperman state busy !!"); + + +#ifdef _DEATH_FAMILY_GM_COMMAND // WON ADD 家族战GM指令 + { + int num1 = 0, num2 = 0; + int winflag = 0; + int floor = CHAR_getWorkInt(meindex, NPC_WORK_WARPFLOOR); + + NPC_GetPKFMNum(floor, fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_index, &num1, &num2); + + if( num2 < 20 ){ + NPC_WarpFamily(floor, -1, + fmpks[fmpks_pos].guest_index, + CHAR_getInt(meindex, CHAR_FLOOR), + CHAR_getInt(meindex, CHAR_X), + CHAR_getInt(meindex, CHAR_Y)); + NPC_talkToFloor( floor, -1, fmpks[fmpks_pos].guest_index, "因未满二十人而离场" ); +#ifdef _DEATH_FAMILY_STRUCT // WON ADD 家族战存放胜负资料 + { + char out[256]; + sprintf( out, "[%s](%d) 因未满二十人弃权", fmpks[fmpks_pos].guest_name, num2 ); + saacproto_FM_PK_STRUCT_send( acfd, out ); + } +#endif + } + + if( num1 < 20 ){ + NPC_WarpFamily(floor, fmpks[fmpks_pos].host_index, + -1, + CHAR_getInt(meindex, CHAR_FLOOR), + CHAR_getInt(meindex, CHAR_X), + CHAR_getInt(meindex, CHAR_Y)); + NPC_talkToFloor( floor, fmpks[fmpks_pos].host_index, -1, "因未满二十人而离场" ); +#ifdef _DEATH_FAMILY_STRUCT // WON ADD 家族战存放胜负资料 + { + char out[256]; + sprintf( out, "[%s](%d) 因未满二十人弃权", fmpks[fmpks_pos].host_name/* .host_index*/, num1 ); + saacproto_FM_PK_STRUCT_send( acfd, out ); + } +#endif + } + } +#endif + } + else if (tm1.tm_min > CHAR_getWorkInt(meindex, NPC_WORK_TIMEFLAG)) + { + char buf[256]; + int clock = 0; + CHAR_setWorkInt(meindex, NPC_WORK_TIMEFLAG, tm1.tm_min); + clock = ((fmpks[fmpks_pos].dueltime % 100) + fmpks[fmpks_pos].prepare_time) - tm1.tm_min; + if (clock >= 60) clock = clock - 60; + sprintf(buf, "距离对战时间还剩下:%4d分钟", clock); + NPC_talkToFloor(floor, fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_index, buf); + } + } + }else if (CHAR_getWorkInt(meindex, NPC_WORK_MODEFLAG) == NPC_STATEBUSY){ + // 检查场内人数、判断胜负 + int num1 = 0, num2 = 0; + int winflag = 0; + int floor = CHAR_getWorkInt(meindex, NPC_WORK_WARPFLOOR); + int meid = CHAR_getWorkInt(meindex, NPC_WORK_ID); + + print("\n won ==> check_winner : npc_meid(%d)", meid ); + + NPC_GetPKFMNum(floor, fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_index, &num1, &num2); + NPC_FMBATTLESET(floor, fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_index, 1); + CheckLeavePK(meindex, floor, fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_index); + + if (meid > MANORNUM){ + if (tm1.tm_min == FMWARPMAN_CLEANPLACE){ + // 判断胜负、WARP离场、设定NPC状态 + NPC_BattleOut(fmpks[fmpks_pos].host_index, fmpks[fmpks_pos].guest_index); + NPC_FMBATTLESET(floor, fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_index, -1); + if (fmpks[fmpks_pos].win == 0){// 生存战 + if (num1 > num2) + winflag = 1; + else if(num1 < num2) + winflag = 2; + else + winflag = 3; + }else if (fmpks[fmpks_pos].win == 1){ // 打飞战 + if ((CHAR_getWorkInt(meindex, NPC_WORK_FMNUMI) - num1) < (CHAR_getWorkInt(meindex, NPC_WORK_FMNUMII) - num2)) + winflag = 1; + else if ((CHAR_getWorkInt(meindex, NPC_WORK_FMNUMI) - num1) > (CHAR_getWorkInt(meindex, NPC_WORK_FMNUMII) - num2)) + winflag = 2; + else + winflag = 3; + } + } + } + if ((num1 == 0) && (num2 != 0)){ + winflag = 2; + }else if ((num2 == 0) && (num1 != 0)){ + winflag = 1; + }else if ((num1 == 0) && (num2 == 0)){ + winflag = 3; + } + if (winflag > 0 && winflag < 3){ +#ifdef _MANOR_PKRULE + if(meid > MANORNUM){ +#endif +#ifdef _DEATH_FAMILY_GM_COMMAND // WON ADD 家族战GM指令 + { + int i, win_index = -1, loser_index = -1; + char *win_name, *loser_name, msg[256] = {0}, token[256] = {0}; + struct tm tm1; + int n1 = 0, n2 = 0; + // FILE *f; + + if(winflag == 1){ + win_index = fmpks[fmpks_pos].host_index; + win_name = fmpks[fmpks_pos].host_name; + n1 = num1; + loser_index = fmpks[fmpks_pos].guest_index; + loser_name = fmpks[fmpks_pos].guest_name; + n2 = num2; + }else if(winflag == 2){ + win_index = fmpks[fmpks_pos].guest_index; + win_name = fmpks[fmpks_pos].guest_name; + n1 = num2; + loser_index = fmpks[fmpks_pos].host_index; + loser_name = fmpks[fmpks_pos].host_name; + n2 = num1; + }else{ + win_index = fmpks[fmpks_pos].host_index; + win_name = fmpks[fmpks_pos].host_name; + loser_index = fmpks[fmpks_pos].guest_index; + loser_name = fmpks[fmpks_pos].guest_name; + } + + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + + if(winflag == 1 || winflag == 2){ + sprintf( msg, "[%s](%d)人 胜 [%s](%d)人", win_name, n1, loser_name, n2 ); + sprintf( token, "战况播报: %s", msg ); + }else if( winflag == 3 ){ + sprintf( msg, "[%s] 平手 [%s]", win_name, loser_name ); + sprintf( token, "战况播报: %s", msg ); + } + +#ifdef _DEATH_FAMILY_STRUCT // WON ADD 家族战存放胜负资料 + { + char out[256] = {0}; + sprintf( out, "%d/%d/%d:%d %s", tm1.tm_mon+1, tm1.tm_mday, tm1.tm_hour, tm1.tm_min, msg ); + saacproto_FM_PK_STRUCT_send( acfd, out ); + } +#endif + + for( i=0 ; i< playernum ; i++ ){ + if( CHAR_CHECKINDEX( i ) == FALSE ) continue; + CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW); + } + /* + if( (f = fopen( "d_fm_pk_log.txt", "a+" ) ) ){ + fprintf( f, "%d/%d/%d:%d %s\n", tm1.tm_mon+1, tm1.tm_mday, tm1.tm_hour, tm1.tm_min, msg ); + fclose( f ); + }else{ + print("\n open file (d_fm_pk_log.txt) Err !!"); + } + */ + } +#else + // 流浪家族pk 过声望 + if (winflag == 1){ + saacproto_ACFixFMPK_send(acfd, + fmpks[fmpks_pos].host_name, + fmpks[fmpks_pos].host_index + 1, + fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_name, + fmpks[fmpks_pos].guest_index + 1, + fmpks[fmpks_pos].guest_index); + } else { + saacproto_ACFixFMPK_send(acfd, + fmpks[fmpks_pos].guest_name, + fmpks[fmpks_pos].guest_index + 1, + fmpks[fmpks_pos].guest_index, + fmpks[fmpks_pos].host_name, + fmpks[fmpks_pos].host_index + 1, + fmpks[fmpks_pos].host_index); + } +#endif + +#ifdef _MANOR_PKRULE + } +#endif + + { + if (meid > 0 && meid <= MANORNUM){// CoolFish 2002/2/25 Change MANOR -> MANORNUM +#ifdef _NEW_MANOR_LAW + int i,iFmIndex1,iFmIndex2,iCharindex; +#endif + fmpks[fmpks_pos + 1].flag = FMPKS_FLAG_MANOR_BATTLEEND; + if (winflag == 1){ + char token[256]; + sprintf( token, " (%d:%d) %d/%d/%d", + tm1.tm_hour, tm1.tm_min, + tm1.tm_year+1900, tm1.tm_mon+1, tm1.tm_mday); + saacproto_ACFixFMPoint_send(acfd, + fmpks[fmpks_pos].host_name, + fmpks[fmpks_pos].host_index + 1, + fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_name, + fmpks[fmpks_pos].guest_index + 1, + fmpks[fmpks_pos].guest_index, meid); + //Syu 增加庄园战胜负Log + Logfmpk( + fmpks[fmpks_pos].host_name, + fmpks[fmpks_pos].host_index, + num1, + fmpks[fmpks_pos].guest_name, + fmpks[fmpks_pos].guest_index, + num2, token, "", "", 2); +#ifdef _NEW_MANOR_LAW + // 原家族守住了庄园,家族成员可得到石币 + iFmIndex1 = fmpks[fmpks_pos].host_index; + for(i=0;i= 0 && CHAR_getCharUse(iCharindex)){ + // 获得金钱 = 个人气势 * 5000 + int iAddGold = ((float)CHAR_getInt(iCharindex,CHAR_MOMENTUM)/100.0f) * 5000.0f; + int iGold = CHAR_getInt(iCharindex,CHAR_BANKGOLD),iMaxGold; + // 先放入个人银行 + if(iGold + iAddGold > CHAR_MAXBANKGOLDHAVE){ + CHAR_setInt(iCharindex,CHAR_BANKGOLD,CHAR_MAXBANKGOLDHAVE); + // 个人银行放不下了,放到个人身上 + iAddGold = iGold + iAddGold - CHAR_MAXBANKGOLDHAVE; + iGold = CHAR_getInt(iCharindex,CHAR_GOLD); + iMaxGold = CHAR_getMaxHaveGold(iCharindex); + if(iGold + iAddGold > iMaxGold) CHAR_setInt(iCharindex,CHAR_GOLD,iMaxGold); + else CHAR_setInt(iCharindex,CHAR_GOLD,iGold + iAddGold); + LogFMPKGetMomey(CHAR_getChar(iCharindex,CHAR_FMNAME), + CHAR_getChar(iCharindex,CHAR_CDKEY), + CHAR_getChar(iCharindex,CHAR_NAME), + CHAR_getInt(iCharindex,CHAR_MOMENTUM),iAddGold,0); + } + else{ + CHAR_setInt(iCharindex,CHAR_BANKGOLD,iGold + iAddGold); + LogFMPKGetMomey(CHAR_getChar(iCharindex,CHAR_FMNAME), + CHAR_getChar(iCharindex,CHAR_CDKEY), + CHAR_getChar(iCharindex,CHAR_NAME), + CHAR_getInt(iCharindex,CHAR_MOMENTUM),iAddGold,1); + } + CHAR_talkToCli(iCharindex,-1,"辛苦了!守护住庄园的奖金已汇入你的个人银行",CHAR_COLORRED); + } + } +#endif + } + else if (winflag == 2){ + char token[256]; + sprintf( token, " (%d:%d) %d/%d/%d", + tm1.tm_hour, tm1.tm_min, + tm1.tm_year+1900, tm1.tm_mon+1, tm1.tm_mday); + saacproto_ACFixFMPoint_send(acfd, + fmpks[fmpks_pos].guest_name, + fmpks[fmpks_pos].guest_index + 1, + fmpks[fmpks_pos].guest_index, + fmpks[fmpks_pos].host_name, + fmpks[fmpks_pos].host_index + 1, + fmpks[fmpks_pos].host_index, meid); + //Syu 增加庄园战胜负Log + Logfmpk( + fmpks[fmpks_pos].guest_name, + fmpks[fmpks_pos].guest_index, + num2, + fmpks[fmpks_pos].host_name, + fmpks[fmpks_pos].host_index, + num1, token, "", "", 2); + } + CHAR_setWorkInt(meindex, NPC_WORK_MODEFLAG, NPC_STATEFREE); + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, FMWARPMAN_FREE_LOOPTIME); + print("FMWarpMan State:%d\n", CHAR_getWorkInt(meindex, NPC_WORK_MODEFLAG)); +#ifdef _NEW_MANOR_LAW + // 双方的个人及家族气势都要归零 + iFmIndex1 = fmpks[fmpks_pos].host_index; + iFmIndex2 = fmpks[fmpks_pos].guest_index; + for(i=0;i= 0 && CHAR_getCharUse(iCharindex)){ + CHAR_setInt(iCharindex,CHAR_MOMENTUM,0); + CHAR_talkToCli(iCharindex,-1,"庄园战後个人及家族气势归零",CHAR_COLORRED); + } + iCharindex = familyMemberIndex[iFmIndex2][i]; + if(iCharindex >= 0 && CHAR_getCharUse(iCharindex)){ + CHAR_setInt(iCharindex,CHAR_MOMENTUM,0); + CHAR_talkToCli(iCharindex,-1,"庄园战後个人及家族气势归零",CHAR_COLORRED); + } + } +#endif + } + } + if (winflag == 1) + { + CHAR_setWorkChar(meindex, NPC_WORK_WINFMNAME, fmpks[fmpks_pos].host_name); + } + else if (winflag == 2) + { + CHAR_setWorkChar(meindex, NPC_WORK_WINFMNAME, fmpks[fmpks_pos].guest_name); + + } + NPC_WarpFamily(floor, fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_index, + CHAR_getInt(meindex, CHAR_FLOOR), + CHAR_getInt(meindex, CHAR_X), + CHAR_getInt(meindex, CHAR_Y)); + if (meid > MANORNUM){// CoolFish 2002/2/25 Change MANOR -> MANORNUM + CHAR_setWorkInt(meindex, NPC_WORK_MODEFLAG, NPC_STATEWAIT); + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, FMWARPMAN_WAIT_LOOPTIME); + } + }else if( winflag == 3 ){ + if (meid > 0 && meid <= MANORNUM) // CoolFish 2002/2/25 Change MANOR -> MANORNUM + + fmpks[fmpks_pos + 1].flag = FMPKS_FLAG_MANOR_BATTLEEND; + NPC_talkToFloor(floor, fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_index, "双方平手,不分胜负!!"); + NPC_WarpFamily(floor, fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_index, + CHAR_getInt(meindex, CHAR_FLOOR), + CHAR_getInt(meindex, CHAR_X), + CHAR_getInt(meindex, CHAR_Y)); + CHAR_setWorkInt(meindex, NPC_WORK_MODEFLAG, NPC_STATEWAIT); + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, FMWARPMAN_WAIT_LOOPTIME); + } + }else if (CHAR_getWorkInt(meindex, NPC_WORK_MODEFLAG) == NPC_STATEWAIT){ + + // andy_edit 2002/07/29 + if (tm1.tm_min == FMWARPMAN_CLEANPLACE) + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, FMWARPMAN_FREE_LOOPTIME); + + NPC_CleanPK(floor, meindex); + + if (tm1.tm_min == 0){ + CHAR_setWorkInt(meindex, NPC_WORK_MODEFLAG, NPC_STATEFREE); + // shan add + NPC_FMBATTLESET(floor, fmpks[fmpks_pos].host_index, fmpks[fmpks_pos].guest_index, -1); + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, FMWARPMAN_FREE_LOOPTIME); + // 将 fmwarpman 初始化 + CHAR_setWorkInt(meindex, NPC_WORK_FMNUMI, 0); + CHAR_setWorkInt(meindex, NPC_WORK_FMNUMII, 0); + CHAR_setWorkInt(meindex, NPC_WORK_TIMEFLAG, 0); + CHAR_setWorkInt(meindex, NPC_WORK_TALKFLAG, -1); + CHAR_setWorkChar(meindex, NPC_WORK_WINFMNAME, ""); + } + } +} + +void NPC_FMWarpManWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024], buff2[256], tmpbuf[256]; + int fl, x, y, fmpks_pos, fd; + + if( !CHAR_CHECKINDEX( talkerindex) )return; + fd = getfdFromCharaIndex(talkerindex); + if (fd == -1) return; + + if( NPC_Util_CharDistance( talkerindex, meindex ) > 2) { + return; + } + if(select==WINDOW_BUTTONTYPE_OK){ + return; + } + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr"); + return ; + } + // shan add + fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID) * MAX_SCHEDULE; + + if (CHAR_getWorkInt(talkerindex, CHAR_WORKFMINDEXI) == fmpks[fmpks_pos].host_index){ + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "WARP1", buf, sizeof( buf)) == NULL ){ + print("FM WARPMAN Can't Read WARP1!\n"); + return; + } + }else if (CHAR_getWorkInt(talkerindex, CHAR_WORKFMINDEXI) == fmpks[fmpks_pos].guest_index){ + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "WARP2", buf, sizeof( buf)) == NULL ){ + print("FM WARPMAN Can't Read WARP2!\n"); + return; + } + }else{ + CHAR_talkToCli( talkerindex, meindex, "你并非对战双方所属任一家族成员!", CHAR_COLORYELLOW); + return; + } + getStringFromIndexWithDelim(buf,",",1,buff2,sizeof(buff2)); + fl=atoi(buff2); + getStringFromIndexWithDelim(buf,",",2,buff2,sizeof(buff2)); + x=atoi(buff2); + getStringFromIndexWithDelim(buf,",",3,buff2,sizeof(buff2)); + y=atoi(buff2); + + + switch (seqno){ + case CHAR_WINDOWTYPE_WINDOWWARPMAN_MAIN: + if(select==WINDOW_BUTTONTYPE_YES){ + if( CHAR_getWorkInt( talkerindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) return; + if(CHAR_getWorkInt(talkerindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE){ + CHAR_talkToCli( talkerindex, meindex, "请解散团队!", CHAR_COLORYELLOW); + return; + } + + if(CHAR_getWorkInt( talkerindex , CHAR_WORKSHOPRELEVANTTRD) <= 0){ + if( CHAR_getWorkInt( talkerindex, CHAR_WORKWARPCHECK ) == TRUE ) { + if (CHAR_getWorkInt(meindex, NPC_WORK_MODEFLAG) == NPC_STATEFREE){ + if (CHAR_getWorkInt(talkerindex, CHAR_WORKFMINDEXI) == fmpks[fmpks_pos].host_index){ + int tmpnum1 = CHAR_getWorkInt(meindex, NPC_WORK_FMNUMI) + 1; + CHAR_setWorkInt(meindex, NPC_WORK_FMNUMI, tmpnum1); + }else if (CHAR_getWorkInt(talkerindex, CHAR_WORKFMINDEXI) == fmpks[fmpks_pos].guest_index){ + int tmpnum2 = CHAR_getWorkInt(meindex, NPC_WORK_FMNUMII) + 1; + CHAR_setWorkInt(meindex, NPC_WORK_FMNUMII, tmpnum2); + }else{ + CHAR_talkToCli( talkerindex, meindex, "你并非对战双方所属任一家族成员!", CHAR_COLORYELLOW); + } + CHAR_setWorkInt(talkerindex, CHAR_WORKFMPKFLAG, 1); + CHAR_setWorkInt(talkerindex, CHAR_WORKFMMANINDEX, meindex); + CHAR_setWorkInt( talkerindex, CHAR_WORKWARPCHECK, FALSE ); + CHAR_warpToSpecificPoint(talkerindex, fl, x,y); +/* { + FILE *fp; + struct tm tm1; + char szFileName[128]; + + memcpy(&tm1, localtime((time_t *)&NowTime.tv_sec), sizeof(tm1)); + memset(szFileName,0,sizeof(szFileName)); + sprintf(szFileName,"FMPkWarp.%d%d%d.log",tm1.tm_mon,tm1.tm_hour,tm1.tm_min); + fp = fopen(szFileName,"a+"); + if(fp != NULL){ + fprintf(fp,"FMName:%s\tName:%s\tWarpHost:%d\tWarpGuest:%d\tFloor:%d,%d,%d\tMaxPlayer:%d\n", + CHAR_getChar(talkerindex,CHAR_FMNAME),CHAR_getChar(talkerindex,CHAR_NAME), + CHAR_getWorkInt(meindex,NPC_WORK_FMNUMI), + CHAR_getWorkInt(meindex,NPC_WORK_FMNUMII), + fl,x,y, + fmpks[fmpks_pos].max_player); + fclose(fp); + } + else printf("%s(errno:%x)\n",sys_errlist[errno],errno); + } +*/ + } + else return; + { + struct tm tm1; + int clock = 0; + int fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID) * MAX_SCHEDULE; + memcpy(&tm1, localtime((time_t *)&NowTime.tv_sec), sizeof(tm1)); + clock = ((fmpks[fmpks_pos].dueltime % 100) + fmpks[fmpks_pos].prepare_time) - tm1.tm_min; + if (clock >= 60) clock = clock - 60; + sprintf(tmpbuf, "\n请等候双方准备完毕後再开战!" + "\n战斗时请不要随意登出或离开。" + "\n赢得胜利的家族也请先稍後一下," + "\n等待裁判的宣布後再离场!" + "\n谢谢您的合作!" + "\n距离对战时间还剩下:%4d分钟", + clock); + lssproto_WN_send(fd, + WINDOW_MESSAGETYPE_MESSAGE, WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString(tmpbuf, buff2, sizeof(buff2))); + } + } + } + else{ + if(CHAR_getInt(talkerindex,CHAR_GOLD) < CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD)){ + NPC_ERR_FMDiSP( meindex, talkerindex, 2); + return ; + } + CHAR_DelGold( talkerindex, CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD )); + CHAR_setWorkInt( talkerindex, CHAR_WORKWARPCHECK, FALSE ); + CHAR_warpToSpecificPoint(talkerindex, fl, x,y); + } + } + break; + } +} + +void NPC_ERR_FMDiSP(int meindex,int talker,int errNO) +{ + + char token[1024]; + int i=0; + int otherindex; + int fd = getfdFromCharaIndex( talker); + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr"); + return ; + } + + if(errNO==1){ + /*--由□ 奴□匹 仄井仃凶--*/ + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "PartyMsg",token, sizeof( token))==NULL) { + /*--涩烂今木化卅仃木壬}票及丢永本□斥毛银丹--*/ + sprintf(token, "\n\n无法加入团队,请先解散团队!"); + } + + if(CHAR_getWorkInt(talker,CHAR_WORKPARTYMODE)==CHAR_PARTY_CLIENT){ + + }else{ + + /*--伉□母□互 仄井仃凶桦宁及心--*/ + /*--由□ 奴□蝈够卞丢永本□斥毛请允--*/ + for( i=0 ; i < CHAR_PARTYMAX ;i++) + { + otherindex=CHAR_getWorkInt(talker,CHAR_WORKPARTYINDEX1+i); + + if(otherindex != -1){ + fd = getfdFromCharaIndex( otherindex); + + /*-仇仇匹霜耨允月--*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_WINDOWWARPMAN_ERR, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + } + } + return ; + } + + }else if (errNO==2){ + /*--嗯互凶曰卅中匹允[--*/ + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "MoneyMsg", token, sizeof( token))==NULL){ + /*--云嗯互箫曰卅中及卞}涩烂今木化卅井匀凶日}票及丢永本□斥毛 歹曰卞请允--*/ + sprintf(token,"\n\n金钱似乎不足唷,请存好钱後再过来。"); + } + } + + /*-仇仇匹霜耨允月--*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_WINDOWWARPMAN_ERR, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); +} + +static void NPC_FMWarpMan_selectWindow( int meindex, int toindex, int num,int select) +{ + struct tm tm1; + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[1024]; + char buf[256]; + char buf2[1024]; + char buf3[256]; + int fl = 0, num1 = 0, num2 = 0; + int fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID) * MAX_SCHEDULE; + int floor = CHAR_getWorkInt(meindex, NPC_WORK_WARPFLOOR); + int fd = getfdFromCharaIndex( toindex); + if( fd == -1 ) { + fprint( "getfd err\n"); + return; + } + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr"); + return ; + } + /*--涩烂白央奶伙及 卞白夫失谛醒互隙烂今木化中月井今木化中木壬白夫失谛醒及喃曰请仄*/ + if(strstr(npcarg,"%4d")!=NULL){ + NPC_Util_GetStrFromStrWithDelim( npcarg, "WARP1", buf, sizeof( buf)); + getStringFromIndexWithDelim(buf,",",1,buf3,sizeof(buf3)); + fl = NPC_FMFloorUse(atoi(buf3)); + } + CHAR_setWorkInt(toindex, CHAR_WORKWARPCHECK, TRUE); + CHAR_setWorkInt(toindex, NPC_WORK_WARPFLOOR, fl); + memcpy(&tm1, localtime((time_t *)&NowTime.tv_sec), sizeof(tm1)); + + if (CHAR_getWorkInt(meindex, NPC_WORK_MODEFLAG) == NPC_STATEFREE) + { + if (((CHAR_getWorkInt(toindex, CHAR_WORKFMINDEXI) == fmpks[fmpks_pos].host_index) + && (strcmp(CHAR_getChar(toindex, CHAR_FMNAME), fmpks[fmpks_pos].host_name) == 0)) + || ((CHAR_getWorkInt(toindex, CHAR_WORKFMINDEXI) == fmpks[fmpks_pos].guest_index) + && (strcmp(CHAR_getChar(toindex, CHAR_FMNAME), fmpks[fmpks_pos].guest_name) == 0))) + { + if ((fmpks[fmpks_pos].host_index != -1) + && (CHAR_getWorkInt(toindex, CHAR_WORKFMINDEXI) == fmpks[fmpks_pos].host_index)) + { + // WON ADD 修正家族pk场的约战问题 + + if(fmpks[fmpks_pos].flag == -1) return; + + if (fmpks[fmpks_pos].flag != FMPKS_FLAG_SCHEDULED) + + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString("\n这场战斗对方好像还没同意呢!\n下次请记得先邀约对方後再来登记吧~", token, sizeof(token))); + return; + } +#ifdef _FMVER21 + if (CHAR_getInt(toindex, CHAR_FMLEADERFLAG) == FMMEMBER_APPLY) +#else + if (CHAR_getInt(toindex, CHAR_FMLEADERFLAG) == 0) +#endif + { + char tmpbuf[256]; + sprintf(tmpbuf, "\n你还没有正式加入%s家族,所以不能进场!", fmpks[fmpks_pos].host_name); + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString(tmpbuf, token, sizeof(token))); + return; + } + //andy_add 2003/06/17 + CHECK_FMPknumInFloor( meindex); + if (CHAR_getWorkInt(meindex, NPC_WORK_FMNUMI) > (fmpks[fmpks_pos].max_player - 1)){ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, makeEscapeString("\n已经不能再进去罗~!\n家族进场人数已经到达设定上限了!", token, sizeof(token))); + return; + } + } + else if ((fmpks[fmpks_pos].guest_index != -1) + && (CHAR_getWorkInt(toindex, CHAR_WORKFMINDEXI) == fmpks[fmpks_pos].guest_index)) + { + // WON ADD 修正家族pk场的约战问题 + + if(fmpks[fmpks_pos].flag == -1) return; + + if (fmpks[fmpks_pos].flag != FMPKS_FLAG_SCHEDULED) + + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString("\n这场战斗你好像还没同意呢!\n下次请记得提早来跟我确认~", token, sizeof(token))); + return; + } +#ifdef _FMVER21 + if (CHAR_getInt(toindex, CHAR_FMLEADERFLAG) == FMMEMBER_APPLY) +#else + if (CHAR_getInt(toindex, CHAR_FMLEADERFLAG) == 0) +#endif + { + char tmpbuf[256]; + sprintf(tmpbuf, "\n你还没有正式加入%s家族,所以不能进场!", fmpks[fmpks_pos].guest_name); + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString(tmpbuf, token, sizeof(token))); + return; + } + //andy_add 2003/06/17 + CHECK_FMPknumInFloor( meindex); + if( CHAR_getWorkInt( meindex, NPC_WORK_FMNUMII) > (fmpks[fmpks_pos].max_player - 1)){ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString("已经不能再进去罗~!\n家族进场人数已经到达设定上限了!", token, sizeof(token))); + return; + } + } + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "FreeMsg", buf2, sizeof( buf2)) == NULL) return; + CONNECT_set_pass(fd, TRUE); + CONNECT_set_first_warp(fd, TRUE); + sprintf(token, buf2, fmpks[fmpks_pos].guest_name, fmpks[fmpks_pos].host_name, + tm1.tm_hour, tm1.tm_min); + CHAR_setWorkInt( toindex , CHAR_WORKFMMANINDEX, meindex ); + CHAR_setWorkInt( toindex , CHAR_WORKSHOPRELEVANTTRD , -1 ); + } else if ((((CHAR_getWorkInt(toindex, CHAR_WORKFMINDEXI) == fmpks[fmpks_pos + 1].host_index) + && (strcmp(CHAR_getChar(toindex, CHAR_FMNAME), fmpks[fmpks_pos + 1].host_name) == 0)) + || ((CHAR_getWorkInt(toindex, CHAR_WORKFMINDEXI) == fmpks[fmpks_pos + 1].guest_index) + && (strcmp(CHAR_getChar(toindex, CHAR_FMNAME), fmpks[fmpks_pos + 1].guest_name) == 0))) + && (((fmpks[fmpks_pos + 1].flag == FMPKS_FLAG_SCHEDULED) + || (fmpks[fmpks_pos + 1].flag == FMPKS_FLAG_MANOR_PREPARE))) + ) + { + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "NextMsg", buf2, sizeof( buf2)) == NULL) return; + sprintf(token, buf2, fl, tm1.tm_hour, tm1.tm_min); + CONNECT_set_pass(fd, FALSE); + CONNECT_set_first_warp(fd, FALSE); + } + else if ((strcmp(fmpks[fmpks_pos].host_name, "") == 0) || (strcmp(fmpks[fmpks_pos].guest_name, "") == 0)) + { + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "TalkMsg", buf2, sizeof( buf2)) == NULL) return; + sprintf(token, buf2); + CONNECT_set_pass(fd, FALSE); + CONNECT_set_first_warp(fd, FALSE); + } + else + { + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "AskMsg", buf2, sizeof( buf2)) == NULL) return; + CONNECT_set_pass(fd, FALSE); + CONNECT_set_first_warp(fd, FALSE); + sprintf(token, buf2, fmpks[fmpks_pos].guest_name, fmpks[fmpks_pos].host_name); + } + } + else if (CHAR_getWorkInt(meindex, NPC_WORK_MODEFLAG) == NPC_STATEBUSY) // 两家族战斗中 + { + if (((CHAR_getWorkInt(toindex, CHAR_WORKFMINDEXI) == fmpks[fmpks_pos].host_index) + && (strcmp(CHAR_getChar(toindex, CHAR_FMNAME), fmpks[fmpks_pos].host_name) == 0)) + || ((CHAR_getWorkInt(toindex, CHAR_WORKFMINDEXI) == fmpks[fmpks_pos].guest_index) + && (strcmp(CHAR_getChar(toindex, CHAR_FMNAME), fmpks[fmpks_pos].guest_name) == 0))) + { + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "BusyMsg", buf2, sizeof( buf2)) == NULL){ + print("\nGet BusyMsg Message Error"); + return; + } + NPC_GetPKFMNum(floor, + fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_index, + &num1, &num2); + sprintf(token, buf2, + fmpks[fmpks_pos].host_name, num1, + fmpks[fmpks_pos].guest_name, num2, + tm1.tm_hour, tm1.tm_min); + } else if ((((CHAR_getWorkInt(toindex, CHAR_WORKFMINDEXI) == fmpks[fmpks_pos + 1].host_index) + && (strcmp(CHAR_getChar(toindex, CHAR_FMNAME), fmpks[fmpks_pos + 1].host_name) == 0)) + || ((CHAR_getWorkInt(toindex, CHAR_WORKFMINDEXI) == fmpks[fmpks_pos + 1].guest_index) + && (strcmp(CHAR_getChar(toindex, CHAR_FMNAME), fmpks[fmpks_pos + 1].guest_name) == 0))) + && (((fmpks[fmpks_pos + 1].flag == FMPKS_FLAG_SCHEDULED) + || (fmpks[fmpks_pos + 1].flag == FMPKS_FLAG_MANOR_PREPARE))) + ) + { + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "NextMsg", buf2, sizeof( buf2)) == NULL) return; + sprintf(token, buf2, fl, tm1.tm_hour, tm1.tm_min); + } else { + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "AskMsg", buf2, sizeof( buf2)) == NULL) return; + sprintf(token, buf2, fmpks[fmpks_pos].guest_name, fmpks[fmpks_pos].host_name); + } + CONNECT_set_pass(fd, FALSE); + CONNECT_set_first_warp(fd, FALSE); + } + else if (CHAR_getWorkInt(meindex, NPC_WORK_MODEFLAG) == NPC_STATEWAIT) // 两家族战斗结束 + { + if (((CHAR_getWorkInt(toindex, CHAR_WORKFMINDEXI) == fmpks[fmpks_pos].host_index) + && (strcmp(CHAR_getChar(toindex, CHAR_FMNAME), fmpks[fmpks_pos].host_name) == 0)) + || ((CHAR_getWorkInt(toindex, CHAR_WORKFMINDEXI) == fmpks[fmpks_pos].guest_index) + && (strcmp(CHAR_getChar(toindex, CHAR_FMNAME), fmpks[fmpks_pos].guest_name) == 0))) + { + char tmpbuf[256]; + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "EndMsg", buf2, sizeof( buf2)) == NULL){ + print("\nGet EndMsg Message Error"); + return; + } + NPC_GetPKFMNum(floor, + fmpks[fmpks_pos].host_index, + fmpks[fmpks_pos].guest_index, + &num1, &num2); + if (strcmp(CHAR_getWorkChar(meindex, NPC_WORK_WINFMNAME), "") == 0) + sprintf(tmpbuf, "双方平手!"); + else sprintf(tmpbuf, "%s获胜了!!", CHAR_getWorkChar(meindex, NPC_WORK_WINFMNAME)); + sprintf(token, buf2, fmpks[fmpks_pos].guest_name, + fmpks[fmpks_pos].host_name, tmpbuf); + } else if ((((CHAR_getWorkInt(toindex, CHAR_WORKFMINDEXI) == fmpks[fmpks_pos + 1].host_index) + && (strcmp(CHAR_getChar(toindex, CHAR_FMNAME), fmpks[fmpks_pos + 1].host_name) == 0)) + || ((CHAR_getWorkInt(toindex, CHAR_WORKFMINDEXI) == fmpks[fmpks_pos + 1].guest_index) + && (strcmp(CHAR_getChar(toindex, CHAR_FMNAME), fmpks[fmpks_pos + 1].guest_name) == 0))) + && (((fmpks[fmpks_pos + 1].flag == FMPKS_FLAG_SCHEDULED) + || (fmpks[fmpks_pos + 1].flag == FMPKS_FLAG_MANOR_PREPARE))) + ) + { + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "NextMsg", buf2, sizeof( buf2)) == NULL) return; + sprintf(token, buf2, fl, tm1.tm_hour, tm1.tm_min); + } else { + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "AskMsg", buf2, sizeof( buf2)) == NULL) return; + sprintf(token, buf2, fmpks[fmpks_pos].guest_name, fmpks[fmpks_pos].host_name); + } + CONNECT_set_pass(fd, FALSE); + CONNECT_set_first_warp(fd, FALSE); + } + /*-仇仇匹霜耨允月--*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_YESNO, + CHAR_WINDOWTYPE_WINDOWWARPMAN_MAIN, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + +} + +int NPC_FMFloorUse(int floor) +{ + int i; + int players = 0; + int playernum = CHAR_getPlayerMaxNum(); + + /* 皿伊奶乩□民尼永弁 */ + for( i=0 ; i< playernum ; i++ ){ + if( CHAR_getCharUse(i) == FALSE )continue; + if(CHAR_getInt(i,CHAR_FLOOR)==floor){ + players++; + } + } + return players; +} + +void NPC_GetPKFMNum(int floor, int index1, int index2, int *num1, int *num2) +{ + int i = 0, charindex; + + *num1 = 0; *num2 = 0; + + /* 皿伊奶乩□民尼永弁 */ + for (i = 0 ; i < FAMILY_MAXMEMBER; i++ ){ + charindex = familyMemberIndex[ index1][i]; + if( CHAR_getCharUse( charindex) ){ + if (CHAR_getInt(charindex, CHAR_FLOOR) == floor) + *num1 = *num1 + 1; + }else + familyMemberIndex[ index1][i] = -1; + + charindex = familyMemberIndex[index2][i]; + if (CHAR_getCharUse(charindex)){ + if (CHAR_getInt(charindex, CHAR_FLOOR) == floor) + *num2 = *num2 + 1; + }else + familyMemberIndex[ index2][i] = -1; + } + +} + +void NPC_FMBATTLESET(int floor, int index1, int index2, int flag) +{ + int i = 0, charindex; + + for (i = 0; i < FAMILY_MAXMEMBER; i++) + { + charindex = familyMemberIndex[index1][i]; + if (CHAR_getCharUse(charindex)) + { + if (CHAR_getInt(charindex ,CHAR_FLOOR) == floor) + { + CHAR_setWorkInt( charindex, CHAR_WORKBATTLEFLAG, flag); + if(flag==1) + CHAR_setFlg(charindex, CHAR_ISDUEL, 1); + } + } + else + familyMemberIndex[index1][i] = -1; + charindex = familyMemberIndex[index2][i]; + if (CHAR_getCharUse(charindex)) + { + if (CHAR_getInt(charindex ,CHAR_FLOOR) == floor) + { + CHAR_setWorkInt( charindex, CHAR_WORKBATTLEFLAG, flag); + if(flag==1) + CHAR_setFlg(charindex, CHAR_ISDUEL, 1); + } + } + else + familyMemberIndex[index2][i] = -1; + } +} + +void NPC_CleanPK(int floor, int meindex) +{ + int i; + int playernum = CHAR_getPlayerMaxNum(); + int fl = CHAR_getInt(meindex, CHAR_FLOOR); + int x = CHAR_getInt(meindex, CHAR_X); + int y = CHAR_getInt(meindex, CHAR_Y); + + for( i=0 ; i< playernum ; i++ ) + { + if( CHAR_getCharUse(i) == FALSE )continue; + if(CHAR_getInt(i,CHAR_FLOOR)==floor) + CHAR_warpToSpecificPoint(i, fl, x, y); + } +} + +void NPC_talkToFloor(int floor, int index1, int index2, char *data) +{ + int i = 0, charindex; + + for (i = 0; i < FAMILY_MAXMEMBER; i++) + { + charindex = familyMemberIndex[index1][i]; + if (CHAR_getCharUse(charindex)) + { + print("charname:%s fmname:%s\n", + CHAR_getChar(charindex, CHAR_NAME), + CHAR_getChar(charindex, CHAR_FMNAME)); + if (CHAR_getInt(charindex, CHAR_FLOOR) == floor) + CHAR_talkToCli(charindex, -1, data, CHAR_COLORYELLOW); + } + else + familyMemberIndex[index1][i] = -1; + charindex = familyMemberIndex[index2][i]; + if (CHAR_getCharUse(charindex)) + { + print("charname:%s fmname:%s\n", + CHAR_getChar(i, CHAR_NAME), + CHAR_getChar(i, CHAR_FMNAME)); + if (CHAR_getInt(charindex, CHAR_FLOOR) == floor) + CHAR_talkToCli(charindex, -1, data, CHAR_COLORRED); + } + else + familyMemberIndex[index2][i] = -1; + } +} + +void NPC_WarpFamily(int floor, int index1, int index2, int fl, int x, int y) +{ + int i, charindex1, charindex2; + + for (i = 0; i < FAMILY_MAXMEMBER; i++){ + charindex1 = familyMemberIndex[index1][i]; + charindex2 = familyMemberIndex[index2][i]; + if (CHAR_getCharUse(charindex1)) + { + if (CHAR_getInt(charindex1, CHAR_FLOOR) == floor) + { + CHAR_setWorkInt(charindex1, CHAR_WORKBATTLEFLAG, FALSE); + CHAR_warpToSpecificPoint(charindex1, fl, x, y); + } + } + else + familyMemberIndex[index1][i] = -1; + if (CHAR_getCharUse(charindex2)) + { + if (CHAR_getInt(charindex2, CHAR_FLOOR) == floor) + { + CHAR_setWorkInt(charindex2, CHAR_WORKBATTLEFLAG, FALSE); + CHAR_warpToSpecificPoint(charindex2, fl, x, y); + } + } + else + familyMemberIndex[index1][i] = -1; + } +} + +void NPC_BattleOut(int index1, int index2) +{ + int i, charindex1, charindex2; + + for (i = 0; i < FAMILY_MAXMEMBER; i++) + { + charindex1 = familyMemberIndex[index1][i]; + charindex2 = familyMemberIndex[index2][i]; + if(CHAR_getCharUse(charindex1)){ + if(CHAR_getWorkInt( charindex1, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) + BATTLE_WatchStop(charindex1); + } + else + familyMemberIndex[index1][i] = -1; + + if(CHAR_getCharUse(charindex2)){ + if(CHAR_getWorkInt( charindex2, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) + BATTLE_WatchStop(charindex2); + } + else + familyMemberIndex[index2][i] = -1; + } +} + +void CheckLeavePK(int npcindex, int floor, int index1, int index2) +{ + int i = 0, charindex, fl = 0, x = 0, y = 0; + fl = CHAR_getInt(npcindex, CHAR_FLOOR); + x = CHAR_getInt(npcindex, CHAR_X); + y = CHAR_getInt(npcindex, CHAR_Y); + + for (i = 0; i < FAMILY_MAXMEMBER; i++) + { + charindex = familyMemberIndex[index1][i]; + if (CHAR_getCharUse(charindex)){ + if (CHAR_getInt(charindex, CHAR_FLOOR) == floor){ + if (CHAR_getWorkInt(charindex, CHAR_WORKFMPKFLAG) < 0){ + if (CHAR_getWorkInt(charindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE) + CHAR_DischargeParty( charindex, 0); + CHAR_setWorkInt(charindex, CHAR_WORKWARPCHECK, FALSE); + CHAR_setWorkInt(charindex, CHAR_WORKBATTLEFLAG, FALSE); + CHAR_warpToSpecificPoint(charindex, fl, x, y); + CHAR_talkToCli(charindex, -1, "战败离场", CHAR_COLORRED); + } + } + }else + familyMemberIndex[index1][i] = -1; + charindex = familyMemberIndex[index2][i]; + if (CHAR_getCharUse(charindex)){ + if (CHAR_getInt(charindex, CHAR_FLOOR) == floor){ + if (CHAR_getWorkInt(charindex, CHAR_WORKFMPKFLAG) < 0){ + if (CHAR_getWorkInt(charindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE) + CHAR_DischargeParty(charindex, 0); + CHAR_setWorkInt(charindex, CHAR_WORKWARPCHECK, FALSE); + CHAR_setWorkInt(charindex, CHAR_WORKBATTLEFLAG, FALSE); + CHAR_warpToSpecificPoint(charindex, fl, x, y); + CHAR_talkToCli(charindex, -1, "战败离场", CHAR_COLORRED); + } + } + }else + familyMemberIndex[index2][i] = -1; + } +} diff --git a/gmsv/npc/npc_freepetskillshop.c b/gmsv/npc/npc_freepetskillshop.c new file mode 100644 index 0000000..1e1cfd4 --- /dev/null +++ b/gmsv/npc/npc_freepetskillshop.c @@ -0,0 +1,561 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "pet_skill.h" +#include "readmap.h" +#include "battle.h" +#include "configfile.h" +#include "util.h" +#include "npc_eventaction.h" +#include "npc_freepetskillshop.h" + +#ifdef _CFREE_petskill + +enum { + CHAR_WORK_SKILLSELECT = CHAR_NPCWORKINT1, +}; + +enum { + SELECTSKILL_START=10, + SELECTSKILL_TEACH=23, + SELECTSKILL_END=30, +}; + +enum { + START_WINDOW=0, + SKILL_WINDOW, + MEEND_WINDOW, +}; + +static void NPC_FreePetSkillShop_selectWindow( int meindex, int toindex, int num,int select); +BOOL NPC_FreePetSkillMakeStr(int meindex,int toindex, int select); +//BOOL NPC_CHECKFREEPETSKILL( int toindex, int petindex, int skillID); +BOOL NPC_SkillShopItemCheck(int meindex,int talker,int itemNo, int cou); +BOOL NPC_SkillShopDelItems(int meindex,int talker, char *buf); +BOOL NPC_SkillShopPetCheck( int toindex, int petindex, int skillID ); +BOOL NPC_SkillShopWarp( int meindex, int talkindex); + +#define MAXNPCPOINT 10 + +BOOL NPC_FreePetSkillShopInit( int meindex ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char msg[256]; + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_FREESKILLSHOP ); + CHAR_setWorkInt( meindex, CHAR_WORK_SKILLSELECT, 0); + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr NO arg !!"); + return FALSE; + } + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "pet_skill", msg, sizeof( msg)) != NULL){ + char buf[256], filename[256]; + int k=1, skillID, skillarray; + while( getStringFromIndexWithDelim( msg, ",", k, buf, sizeof( buf) ) ){ + k++; + skillID=atoi(buf); + skillarray = PETSKILL_getPetskillArray( skillID); + if( PETSKILL_CHECKINDEX( skillarray) == FALSE ) continue; + if( PETSKILL_getInt( skillarray, PETSKILL_ILLEGAL) == 1){ + if( NPC_Util_CheckAssignArgFile( meindex, filename) != NULL ){ + print("\n宠物技能不规范:[%d-%s] ->文件:%s\n", + skillID, + PETSKILL_getChar( skillarray, PETSKILL_NAME), + filename ); + } + } + } + }else{ + return FALSE; + } + + return TRUE; +} +void NPC_FreePetSkillShopTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + if(NPC_Util_isFaceToFace(talkerindex,meindex,2 )==FALSE){ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) return; + } + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 1 ); + + NPC_FreePetSkillShop_selectWindow( meindex, talkerindex, START_WINDOW,-1); +} + +static void NPC_FreePetSkillShop_selectWindow( int meindex, int toindex, int num,int select) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[1024]; + int fd = getfdFromCharaIndex( toindex); + int buttontype = 0, windowtype = 0, windowno = 0; + char buf1[256]; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr"); + return ; + } + + switch(num) { + case START_WINDOW: + { + BOOL Evflg = TRUE; + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "start_msg", token, sizeof( token)) == NULL) { + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 0); + return; + } + if( CHAR_getWorkInt( toindex, CHAR_WORKSHOPRELEVANT) != 1 ) { + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 0); + return; + } + //玩家条件判断 + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "FREE", buf1, sizeof( buf1)) != NULL ) { + if( NPC_ActionPassCheck( meindex, toindex, buf1) == FALSE ) { + Evflg = FALSE; + } + } + if( Evflg == FALSE) { + CHAR_talkToCli( toindex, -1, "你想让宠物学特殊技能?可你的条件还不够喔!", CHAR_COLORYELLOW); + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 0); + return; + }else { + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + buttontype = WINDOW_BUTTONTYPE_NEXT; + windowno = SELECTSKILL_START; + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 2); + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token ); + } + } + break; + case SKILL_WINDOW: + if( NPC_FreePetSkillMakeStr( meindex, toindex, select) == FALSE ) { + print("\n npc_freepetskillshop.c 错误"); + } + break; + case MEEND_WINDOW: + break; + } +} + +void NPC_FreePetSkillShopWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data) +{ + int skill; + int pet; + int slot; + int cost; + int skillID=0; + int petskillindex; + char buf[64]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char msg[512]; + int petindex; + char msgbuf[128]; + double rate= 1.0; + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("GetArgStrErr"); + return; + } + + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + if(NPC_Util_isFaceToFace(talkerindex,meindex,2 )==FALSE){ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) return; + } + if( CHAR_getWorkInt( talkerindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) + return ; + + + switch( seqno) { + case SELECTSKILL_START: + if( CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT) != 2 ) { + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + return; + } + NPC_FreePetSkillShop_selectWindow( meindex, talkerindex, SKILL_WINDOW, -1); + break; + case SELECTSKILL_TEACH: + if( CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT) != 3 ) { + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + return; + } + makeStringFromEscaped( data); + getStringFromIndexWithDelim(data,"|",1,buf,sizeof(buf)); + skill=atoi(buf); + getStringFromIndexWithDelim(data,"|",2,buf,sizeof(buf)); + pet=atoi(buf); + getStringFromIndexWithDelim(data,"|",3,buf,sizeof(buf)); + slot=atoi(buf); + getStringFromIndexWithDelim(data,"|",4,buf,sizeof(buf)); + cost=atoi(buf); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "pet_skill", msg, sizeof( msg)) != NULL){ + getStringFromIndexWithDelim(msg,",",skill,buf,sizeof(buf)); + skillID=atoi(buf); + } + slot--; + if( slot < 0 ) return; + + petindex = CHAR_getCharPet( talkerindex, pet-1); + if( !CHAR_CHECKINDEX(petindex) ){ + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return ; + } + if( NPC_Util_GetStrFromStrWithDelim( argstr, "skill_rate", msg, sizeof( msg)) != NULL){ + rate = atof( msg); + } + petskillindex = PETSKILL_getPetskillArray( skillID ); + if( !PETSKILL_CHECKINDEX( petskillindex)){ + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return ; + } + + cost = PETSKILL_getInt( petskillindex, PETSKILL_COST ); + cost = cost * rate; + + //条件判断 + if(CHAR_getInt(talkerindex,CHAR_GOLD) < cost){ + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return; + } + + if( NPC_CHECKFREEPETSKILL( talkerindex, petindex, skillID ) == TRUE ){ + + if( Action_RunDoEventAction( meindex, talkerindex, argstr) == FALSE ){ + CHAR_talkToCli( talkerindex, -1, "所需物品不足!!", CHAR_COLORYELLOW); + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + return; + } + + CHAR_setPetSkill( petindex, slot, skillID); + CHAR_setInt( talkerindex, CHAR_GOLD, ( CHAR_getInt( talkerindex, CHAR_GOLD) - cost) ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d",pet-1); + CHAR_sendStatusString( talkerindex, msgbuf ); + CHAR_sendStatusString( talkerindex, "P"); + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + //WARP + if( NPC_SkillShopWarp( meindex, talkerindex) == TRUE ) + return; + }else { + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + CHAR_talkToCli( talkerindex, -1, "条件不足!!", CHAR_COLORYELLOW); + } + //ADD + NPC_FreePetSkillShop_selectWindow( meindex, talkerindex, SKILL_WINDOW, -1); + break; + case SELECTSKILL_END: + break; + } + + return; +} + +BOOL NPC_CHECKFREEPETSKILL( int toindex, int petindex, int skillID) +{ + int skillindex=-1; + char SCode[256]; + char Free[256]; + int i, petID; + skillindex = PETSKILL_getPetskillArray( skillID ); + memset( Free, 0, sizeof( Free)); + if( !PETSKILL_CHECKINDEX( skillindex) ) { + return FALSE; + } + + petID = CHAR_getInt( petindex, CHAR_PETID); + sprintf( SCode, "%s", PETSKILL_getChar( skillindex, PETSKILL_KINDCODE)); + sprintf( Free, "%s", PETSKILL_getChar( skillindex, PETSKILL_FREE)); + + //CHECK CODE + if( !strcmp( SCode, "\0")) { + return TRUE; + } + + for( i=0; i= cou ) + return TRUE; + } + return FALSE; + +} + +BOOL NPC_SkillShopDelItems(int meindex,int talker, char *buf) +{ + char buf1[256]; + char item[256], cout[256]; + int i=1; + BOOL Evflg=TRUE; + while( getStringFromIndexWithDelim( buf, ",", i,buf1, sizeof( buf1)) != FALSE ) { + i++; + if( strstr( buf1, "*") != NULL ) { + getStringFromIndexWithDelim( buf1, "*", 1, item, sizeof( item)); + getStringFromIndexWithDelim( buf1, "*", 2, cout, sizeof( cout)); + }else { + strcpy( item, buf1); + strcpy( cout, "1"); + } + if( NPC_SkillShopItemCheck( meindex, talker, atoi( item), atoi( cout)) == FALSE ) { + Evflg=FALSE; + break; + } + if( Evflg == FALSE ) + break; + } + if( Evflg == FALSE ) + return FALSE; + if( NPC_ActionDelItem( talker, buf) == TRUE ) { + return TRUE; + } + return FALSE; +} + +BOOL NPC_SkillShopPetCheck( int toindex, int petindex, int skillID ) +{ + char Free[256]; + int i; + char data[256], msg[256]; + int skillindex = PETSKILL_getPetskillArray( skillID ); + + memset( Free, 0, sizeof( Free)); + sprintf( Free, "%s", PETSKILL_getChar( skillindex, PETSKILL_FREE)); + + if( NPC_Util_GetStrFromStrWithDelim( Free, "FREE", data, sizeof( data)) != NULL ) { + BOOL EvFlg = TRUE; + i=1; + while( getStringFromIndexWithDelim( data, "|", i, msg, sizeof( msg)) != FALSE ) { + i++; + if( strstr( msg, "LV") != NULL ) { + char LvStr[256]; + int LV=0; + if( strstr( msg, ">" ) != NULL ) { + if( getStringFromIndexWithDelim( msg, ">", 2, LvStr, sizeof( LvStr)) != FALSE ) { + LV = atoi( LvStr); + if( CHAR_getInt( petindex, CHAR_LV) <= LV ) + EvFlg = FALSE; + } + }else if( strstr( msg, "<")) { + if( getStringFromIndexWithDelim( msg, "<", 2, LvStr, sizeof( LvStr)) != FALSE ) { + LV = atoi( LvStr); + if( CHAR_getInt( petindex, CHAR_LV) >= LV ) + EvFlg = FALSE; + } + } + }else if( strstr( msg, "SK") != NULL ) { + int j=0, PskId=-1, ID; + char strSK[256]; + int petskillindex; + + getStringFromIndexWithDelim( msg, "=", 2, strSK, sizeof( strSK) ); + ID = atoi( strSK); + for( j=0; j < CHAR_MAXPETSKILLHAVE; j++) { + PskId = CHAR_getPetSkill( petindex, j); + petskillindex = PETSKILL_getPetskillArray( PskId ); + if( !PETSKILL_CHECKINDEX( petskillindex)) + continue; + if( ID == PskId ) { + if( strstr( msg, "!=") !=NULL ) + EvFlg = FALSE; + break; + } + } + if( j == CHAR_MAXPETSKILLHAVE ) { + EvFlg = FALSE; + break; + } + } + if( EvFlg == FALSE ) + break; + } + if( EvFlg == FALSE ) { + return FALSE; + }else { + return TRUE; + } + } + return TRUE; +} + +BOOL NPC_SkillShopWarp( int meindex, int talkindex) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char data[1024], buf1[256], buf2[256]; + int i=1, j=1; + BOOL EvFlg=FALSE; + struct { + int FLOOR; + int X; + int Y; + }Points[MAXNPCPOINT]; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr"); + return FALSE; + } + + for( i=0;i= MAXNPCPOINT ) + break; + } + where = RAND( 0, i-1); + CHAR_warpToSpecificPoint( meindex, Points[where].FLOOR, Points[where].X, Points[where].Y); + EvFlg = TRUE; + } + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "WARP", data, sizeof( data)) != NULL ) { + int P_Floor,P_X,P_Y; + getStringFromIndexWithDelim( data, ",", 1, buf2, sizeof( buf2)); + P_Floor = atoi( buf2); + getStringFromIndexWithDelim( data, ",", 2, buf2, sizeof( buf2)); + P_X = atoi( buf2); + getStringFromIndexWithDelim( data, ",", 3, buf2, sizeof( buf2)); + P_Y = atoi( buf2); + CHAR_warpToSpecificPoint( talkindex, P_Floor, P_X, P_Y); + EvFlg = TRUE; + } + + return EvFlg; +} + +#endif + + + + + diff --git a/gmsv/npc/npc_gamblebank.c b/gmsv/npc/npc_gamblebank.c new file mode 100644 index 0000000..9cfb70f --- /dev/null +++ b/gmsv/npc/npc_gamblebank.c @@ -0,0 +1,519 @@ +#include "version.h" +#include +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "enemy.h" +#include "log.h" +#include "battle.h" +#include "readmap.h" +#include "handletime.h" +#include "configfile.h" +#ifdef _GAMBLE_BANK +#include "npc_gamblebank.h" + +static void NPC_GambleBank_selectWindow( int meindex, int toindex, int num, int flg); +int NPC_GambleBank_DoGold( int meindex, int toindex, int Gold, int flg); +BOOL NPC_GambleBank_AddItem( int meindex, int toindex, int itemId, int count); + +enum { + GAMBLE_START = 0, + GAMBLE_SELET, + GAMBLE_MAN_BANK, + GAMBLE_MAN_CHANG1, + GAMBLE_MAN_CHANG2, + GAMBLE_END, +}; + +enum { + NPC_WORK_INDEX = CHAR_NPCWORKINT1, + NPC_WORK_WORKTYPE = CHAR_NPCWORKINT2, // 0,-1 = NULL 2 = 银行 3 = 换币 4 = BOTH + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT3, + NPC_WORK_PAGE = CHAR_NPCWORKINT4, +/* + 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, +*/ +}; +#define _GAMBLEBANK_U_NOLOCK //同时对多人 + +#define GAMBLEBANK_LOOPTIME 80 +#define GAMBLEBANK_STANDBY 5000 +#define GAMBLEBANK_DEF 3 //手续费 / 100 +#define GAMBLEBANK_GETMAX 1000000 +#define GAMBLEBANK_GETMIN 100 +#define LIST_PAGE 7 +BOOL NPC_GambleBankInit( int meindex ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf1[256]; + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_GAMBLEBANK ); + +#ifdef _GAMBLEBANK_U_NOLOCK + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, GAMBLEBANK_STANDBY); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); +#endif + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, -1); + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg)) == NULL) { + print("GambleBank:GetArgStrErr"); + return FALSE; + } + + if(NPC_Util_GetStrFromStrWithDelim( npcarg,"GAMBLE_TYPE", buf1,sizeof( buf1) ) == NULL) { + print("GAMBLE_TYPE err !"); + return FALSE; + } + CHAR_setWorkInt( meindex, NPC_WORK_WORKTYPE, atoi( buf1) ); + + return TRUE; +} +//CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_GOLD); +void NPC_GambleBankLoop( int meindex) +{ +#ifdef _GAMBLEBANK_U_NOLOCK + + int fulltime = GAMBLEBANK_LOOPTIME; + if( ( CHAR_getWorkInt( meindex, NPC_WORK_CURRENTTIME) + fulltime) >= NowTime.tv_sec ) + return; + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, -1); +#endif + return; +} + +void NPC_GambleBankTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + char buf1[256]; + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + int work_type; + + if( !CHAR_CHECKINDEX( talkerindex) || !CHAR_CHECKINDEX( meindex) ) + return; + 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; + } + } + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg)) == NULL) { + print("GambleBank:GetArgStrErr"); + return; + } +#ifdef _FIX_GAMBLENUM + if( CHAR_getInt( talkerindex, CHAR_GAMBLENUM) < 0 ) { + CHAR_setInt( talkerindex, CHAR_GAMBLENUM, 0); + } +#endif + if(NPC_Util_GetStrFromStrWithDelim( npcarg,"GAMBLE_TYPE", buf1,sizeof( buf1) ) == NULL) { + print("GAMBLE_TYPE err !"); + return; + } + + CHAR_setWorkInt( meindex, NPC_WORK_WORKTYPE, atoi( buf1) ); + work_type = CHAR_getWorkInt( meindex, NPC_WORK_WORKTYPE); + + + if( work_type < 1 || work_type > 4 ) { // 0 or -1 + strcpy( buf1,"暂时停止服务。"); + CHAR_talkToCli( talkerindex, meindex, buf1, CHAR_COLORYELLOW); + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, -1); + return; + } +#ifdef _GAMBLEBANK_U_NOLOCK + +#else + if( CHAR_getWorkInt( meindex , NPC_WORK_INDEX) >= 0 ) { + strcpy( buf1,"我正忙着!"); + CHAR_talkToCli( talkerindex, meindex, buf1, CHAR_COLORYELLOW); + return; + }else { + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, talkerindex); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + } +#endif + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 1); + NPC_GambleBank_selectWindow( meindex, talkerindex, GAMBLE_START, 1); +} + +static void NPC_GambleBank_selectWindow( int meindex, int toindex, int num, int flg) +{ + char token[256]; + char buf1[256],buf2[256]; + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + int buttontype = 0, windowtype = 0, windowno = 0; + int fd = getfdFromCharaIndex( toindex); + int i; + int page=-1; + //flg <= 0 错误 1 正常 flg = 2 钱不够 3 = 个人存款将满 + // 4 = 个人银行将满 5 = 提领上限 6 = 提领下限 + char Gamble_End[][56] = { + "error_msg", "end_msg", "money_msg", "full_msg1", + "full_msg2","getmax_msg","getmin_msg", + }; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GambleBank:GetArgStrErr"); + return; + } + + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + switch( num) { + case GAMBLE_START: + if( NPC_Util_GetStrFromStrWithDelim( npcarg,"gamble_start", token, sizeof( token) ) == NULL) { + print("gamble_start msg err !"); + return; + } + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowno = NPC_GambleBank_START; + break; + + case GAMBLE_SELET: + i = 1; + strcpy( token, "\0"); + sprintf( buf2,"%s%d", "gamble_msg0", i); + while( NPC_Util_GetStrFromStrWithDelim( npcarg, buf2, buf1, sizeof( buf1) ) != NULL ) { + if( strstr( buf1, "NULL" ) == NULL ) { + strcat( token , buf1); + strcat( token, "\n"); + }else { + strcat( token, "\n"); + } + i++; + sprintf( buf2,"%s%d", "gamble_msg0", i); + } + windowtype=WINDOW_MESSAGETYPE_SELECT; + windowno = NPC_GambleBank_SELECT; + break; + + case GAMBLE_MAN_BANK: //银行 + sprintf( token,"%d", CHAR_getInt( toindex, CHAR_PERSONAGOLD ) ); + windowtype = WINDOW_MESSAGETYPE_BANK; + windowno = NPC_GambleBank_BANK; + break; + + case GAMBLE_MAN_CHANG1: //换物 + { + char snum[256]; + page = CHAR_getWorkInt( toindex, CHAR_WORKSHOPRELEVANT); + strcpy( token, "换物"); + sprintf( token, "你有%d积分,想换哪一个奖品呢?\n", CHAR_getInt( toindex, CHAR_GAMBLENUM)); + for( i=(page*LIST_PAGE);i<(page*LIST_PAGE+LIST_PAGE);i++) { + if( i>=arraysizeof( GB_ITEMS)) { + break; + } + if( !strcmp( GB_ITEMS[i].name,"NEXT") ) { + strcat( token, " 下一页"); + break; + } + if( !strcmp( GB_ITEMS[i].name,"END") ) { + strcat( token, " 取消\n"); + break; + } + + sprintf( snum,"%s%d\t%s", + "积分:", GB_ITEMS[i].Gnum, + GB_ITEMS[i].name); + snum[36] = 0; + strcat( token, snum); + strcat( token,"\n"); + strcpy( snum, "\0"); + } + + windowtype = WINDOW_MESSAGETYPE_SELECT; + buttontype = WINDOW_BUTTONTYPE_NONE; + windowno = NPC_GambleBank_CHANG1; + } + break; + case GAMBLE_END: + CHAR_send_P_StatusString( toindex, CHAR_P_STRING_GOLD); + if( flg < 0 || flg > 6) { + flg = 0; + } + if( NPC_Util_GetStrFromStrWithDelim( npcarg, Gamble_End[flg], token, sizeof( token) ) == NULL) { + print("Gamble_End[%d] noe found !", flg); + return; + } + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, -1); +#ifdef _GAMBLEBANK_U_NOLOCK +#else + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, -1); +#endif + windowno = NPC_GambleBank_END; + buttontype = WINDOW_BUTTONTYPE_OK; + break; + } + + lssproto_WN_send( fd, windowtype, + buttontype, + windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); +} + +void NPC_GambleBankWindowTalked ( int meindex, int talkerindex, int seqno, int select, char *data) +{ + int stone_gold = 0; + int flg=1; + int work_type=-1; + int type; + type = atoi( data); + + if( !CHAR_CHECKINDEX( talkerindex) || !CHAR_CHECKINDEX( meindex) ) + return; + + work_type = CHAR_getWorkInt( meindex, NPC_WORK_WORKTYPE ); + if( work_type < 1 || work_type > 4 ) { + return; + } + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } +#ifdef _GAMBLEBANK_U_NOLOCK +#else + { + char buf1[256]; + if( CHAR_getWorkInt( meindex , NPC_WORK_INDEX) != talkerindex ) { + strcpy( buf1,"我正忙着呢!"); + CHAR_talkToCli( talkerindex, meindex, buf1, CHAR_COLORYELLOW); + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, -1); + return; + } + } +#endif + + if(NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) return; + } + if( NPC_Util_CharDistance( talkerindex, meindex ) > 2) { + return; + } + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + switch( seqno) { + case NPC_GambleBank_START: + if( select == WINDOW_BUTTONTYPE_YES ) { + NPC_GambleBank_selectWindow( meindex, talkerindex, GAMBLE_SELET, flg); + }else { + NPC_GambleBank_selectWindow( meindex, talkerindex, GAMBLE_END, flg); + } + break; + case NPC_GambleBank_SELECT: + if( type == 1 ) { //银行 + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 2); + NPC_GambleBank_selectWindow( meindex, talkerindex, GAMBLE_MAN_BANK, flg); + }else if( type == 2 ) { //换物 + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + NPC_GambleBank_selectWindow( meindex, talkerindex, GAMBLE_MAN_CHANG1, flg); + }else { + NPC_GambleBank_selectWindow( meindex, talkerindex, GAMBLE_END, flg); + } + break; + case NPC_GambleBank_BANK: //2 + if( CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT) != 2 ) //错误程序 + return; + if( work_type != 2 && work_type != 4 ) { + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, -1); + return; + } + if( select == 4 && atoi( data) != 0 ) { + stone_gold = atoi( data); + flg = NPC_GambleBank_DoGold( meindex, talkerindex, stone_gold, select); + //flg = 1 正常 flg = 2 钱不够 flg <= 0 错误 + if( flg == 1 ) { + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, -1); + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, -1); + return; + } + } + NPC_GambleBank_selectWindow( meindex, talkerindex, GAMBLE_END, flg); + break; + case NPC_GambleBank_CHANG1: //换物 + { + int page,ItemID; + int count; + type -=1; + page = CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT)*LIST_PAGE; + if( work_type != 3 && work_type != 4 ) { + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, -1); + return; + } + + if( page < 0 ) //错误对话程序 + return; + if( (page+type) < 0 || (page+type) >= arraysizeof( GB_ITEMS) ) { + NPC_GambleBank_selectWindow( meindex, talkerindex, GAMBLE_END, flg); + }else if( !strcmp( GB_ITEMS[page+type].name,"NEXT") ){ + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, + CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT) + 1); + NPC_GambleBank_selectWindow( meindex, talkerindex, GAMBLE_MAN_CHANG1, flg); + }else if( !strcmp( GB_ITEMS[page+type].name,"END") ){ + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, -1); + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, -1); + return; + }else { + if( type < 7 && type >= 0 ) { + if( GB_ITEMS[page+type].name == NULL || + !strcmp( GB_ITEMS[page+type].name, "\0") ) { + }else { + ItemID = GB_ITEMS[page+type].ItemId; //ID + count = GB_ITEMS[page+type].Gnum; //积分 + NPC_GambleBank_AddItem( meindex, talkerindex, ItemID, count); + } + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, -1); + } + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, -1); + } + } + break; + case NPC_GambleBank_END: + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, -1); + break; + } +} + + +int NPC_GambleBank_DoGold( int meindex, int toindex, int Gold, int flg) +{ + //flg = 1 正常 flg = 2 钱不够 flg <= 0 错误 3 = 个人存款将满 4 = 个人银行将满 5 = 单次最高金额 + char buf1[256]; + int player_gold = CHAR_getInt( toindex, CHAR_GOLD ); + int stone_def = 0; //手续费 +// int def = GAMBLEBANK_DEF; + //不作无意义的存取款 + if( flg != 4 ) + return 0; + if( Gold == 0 ) { + return 0; + } + + if( Gold < 0 ) { //取款 + Gold *=-1; + //stone_def = (Gold * def) /100; + stone_def = 300; + if( Gold > GAMBLEBANK_GETMAX ) { + return 5; + }else if( Gold < GAMBLEBANK_GETMIN ) { + return 6; + } + if( ( player_gold + Gold ) > CHAR_getMaxHaveGold(toindex) ) { + return 3; //取款後将超过个人金额 + }else if( (Gold + stone_def)> CHAR_getInt( toindex, CHAR_PERSONAGOLD ) ) { //银行存款不够 + return 2; + } + + CHAR_setInt( toindex, CHAR_PERSONAGOLD, (CHAR_getInt( toindex, CHAR_PERSONAGOLD )-(Gold+stone_def))); + + CHAR_AddGold( toindex, Gold); + + sprintf( buf1,"取款:%d ,手续费:%d,银行剩馀:%d 。", Gold, stone_def, CHAR_getInt( toindex, CHAR_PERSONAGOLD )); + CHAR_talkToCli( toindex, meindex, buf1, CHAR_COLORYELLOW); + LogBankStone( CHAR_getChar( toindex, CHAR_NAME ), CHAR_getChar( toindex, CHAR_CDKEY ), + toindex, Gold, + "GB_Bank_Get(银行取款)", + CHAR_getInt( toindex, CHAR_FLOOR), + CHAR_getInt( toindex, CHAR_X ), CHAR_getInt( toindex, CHAR_Y ) , + CHAR_getInt( toindex, CHAR_GOLD ), + CHAR_getInt( toindex, CHAR_PERSONAGOLD ) + ); + return 1; + }else if( Gold > 0 ) { //存款 + if( Gold > player_gold ) { + return 2; + }else if( (Gold + CHAR_getInt( toindex, CHAR_PERSONAGOLD ) ) > CHAR_MAXPERSONAGOLD ) { + return 4; + } + + CHAR_DelGold( toindex, Gold ); + + CHAR_setInt( toindex, CHAR_PERSONAGOLD, (CHAR_getInt( toindex, CHAR_PERSONAGOLD ) + Gold ) ); + sprintf( buf1,"存款:%d ,银行剩馀:%d 。", Gold, CHAR_getInt( toindex, CHAR_PERSONAGOLD )); + CHAR_talkToCli( toindex, meindex, buf1, CHAR_COLORYELLOW); + LogBankStone( CHAR_getChar( toindex, CHAR_NAME ), CHAR_getChar( toindex, CHAR_CDKEY ), + toindex, Gold, + "GB_Bank_save(银行存款)", + CHAR_getInt( toindex, CHAR_FLOOR), + CHAR_getInt( toindex, CHAR_X ), CHAR_getInt( toindex, CHAR_Y ), + CHAR_getInt( toindex, CHAR_GOLD ), + CHAR_getInt( toindex, CHAR_PERSONAGOLD ) + ); + return 1; + } + return 0; +} + +BOOL NPC_GambleBank_AddItem( int meindex, int toindex, int itemId, int count) +{ + int i=-1,itemindex=-1; + int ret=-1; + char token[256]; + strcpy( token,"\0"); + if( count < 0 || itemId < 0 ) + return FALSE; + + if( CHAR_getInt( toindex, CHAR_GAMBLENUM) < count ) { + sprintf( token,"游乐场积分不足!"); + CHAR_talkToCli( toindex, -1,token,CHAR_COLORWHITE); + return FALSE; + } + for( i = 0 ; i < CHAR_MAXITEMHAVE ; i++ ){ + itemindex=CHAR_getItemIndex( toindex , i ); + if( itemindex == -1 ) { + break; + } + } + if( i == CHAR_MAXITEMHAVE ) { + snprintf( token,sizeof( token), "物品栏空间不足!!"); + CHAR_talkToCli( toindex, -1, token, CHAR_COLORWHITE); + return FALSE; + } + itemindex = ITEM_makeItemAndRegist( itemId); + if(itemindex == -1) + return FALSE; + ret = CHAR_addItemSpecificItemIndex( toindex, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + ITEM_endExistItemsOne( itemindex); + return FALSE; + } + LogItem( + CHAR_getChar( toindex, CHAR_NAME ), + CHAR_getChar( toindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), +#endif + "G_BANK(游乐场积分兑换道具)", + CHAR_getInt( toindex,CHAR_FLOOR), + CHAR_getInt( toindex,CHAR_X ), + CHAR_getInt( toindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + sprintf( token,"拿到%s",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( toindex, -1,token,CHAR_COLORWHITE); + CHAR_sendItemDataOne( toindex, ret); + CHAR_setInt( toindex, CHAR_GAMBLENUM, CHAR_getInt( toindex, CHAR_GAMBLENUM) - count); + sprintf( token,"游乐场积分剩馀: %d", CHAR_getInt( toindex, CHAR_GAMBLENUM)); + CHAR_talkToCli( toindex, -1,token,CHAR_COLORWHITE); + return TRUE; +} + +#endif + + + + + diff --git a/gmsv/npc/npc_gamblemaster.c b/gmsv/npc/npc_gamblemaster.c new file mode 100644 index 0000000..fb709dc --- /dev/null +++ b/gmsv/npc/npc_gamblemaster.c @@ -0,0 +1,600 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "handletime.h" +#include "readmap.h" +#include "log.h" +#include "npc_eventaction.h" + +#ifdef _GAMBLE_ROULETTE + +#include "npc_gamblemaster.h" +void defPlayerGold( int meindex, int flg); +void NPC_GAMBLEMASTER_RESET( int meindex); +void Codef_Gold( int meindex, int toindex, int stone, int flg, char *token); +void NPC_GambleRoulette_selectWindow(int meindex,int toindex,int num,int select); + +enum +{ + ROULETTE_START=0, + ROULETTE_SELECT, + ROULETTE_LOOK, + ROULETTE_END, +}; + +enum +{ + roulette1 = 11, roulette2, roulette3, roulette4, roulette5, roulette6, roulette7, + roulette8, roulette9, roulette10, roulette11, roulette12, roulette13, roulette14, + roulette15, roulette16, roulette17, roulette18, roulette19, roulette20, + + roulette21 = 41, roulette22, roulette23, roulette24, roulette25, roulette26, + roulette27, roulette28, roulette29, roulette30, roulette31, roulette32, + roulette33, roulette34, roulette35, roulette36, roulette37, roulette38, + roulette39, roulette40, + roulette41 = 71, roulette42, roulette43, roulette44, roulette45, + + roulette51 = 101, roulette52=102, roulette53=103, + roulette61 = 111, roulette62=112, +}; + +typedef struct tagGambleMaster +{ + int m_fx; + int m_fy; + int m_type; //号码 + int m_RG; //红绿1 2 + int m_EO; //单双1 2 + int m_SI; + int m_IN; + char str_type[56]; + int m_nums; +}GambleEndType; +GambleEndType EndTypedef[60]={ +{22, 8 , roulette1 , roulette41, roulette43, roulette51, roulette61, "号码红1", 0}, +{7 , 8 , roulette1 , roulette41, roulette43, roulette51, roulette61, "号码红1", 0}, +{22, 10, roulette3 , roulette41, roulette43, roulette51, roulette61, "号码红3", 0}, +{7 , 6 , roulette3 , roulette41, roulette43, roulette51, roulette61, "号码红3", 0}, +{20, 11, roulette5 , roulette41, roulette43, roulette51, roulette61, "号码红5", 0}, +{9 , 5 , roulette5 , roulette41, roulette43, roulette51, roulette61, "号码红5", 0}, +{19, 5 , roulette6 , roulette41, roulette44, roulette53, roulette61, "号码红6", 0}, +{10, 11, roulette6 , roulette41, roulette44, roulette53, roulette61, "号码红6", 0}, +{17, 5 , roulette8 , roulette41, roulette44, roulette53, roulette61, "号码红8", 0}, +{12, 11, roulette8 , roulette41, roulette44, roulette53, roulette61, "号码红8", 0}, +{16, 5 , roulette9 , roulette41, roulette43, roulette53, roulette61, "号码红9", 0}, +{13, 11, roulette9 , roulette41, roulette43, roulette53, roulette61, "号码红9", 0}, +{15, 5 , roulette10, roulette41, roulette44, roulette53, roulette61, "号码红10", 0}, +{14, 11, roulette10, roulette41, roulette44, roulette53, roulette61, "号码红10", 0}, +{12, 5 , roulette13, roulette41, roulette43, roulette52, roulette62, "号码红13", 0}, +{17, 11, roulette13, roulette41, roulette43, roulette52, roulette62, "号码红13", 0}, +{22, 6 , roulette17, roulette41, roulette43, roulette53, roulette62, "号码红17", 0}, +{7 , 10, roulette17, roulette41, roulette43, roulette53, roulette62, "号码红17", 0}, +{22, 5 , roulette18, roulette41, roulette44, roulette52, roulette62, "号码红18", 0}, +{7 , 11, roulette18, roulette41, roulette44, roulette52, roulette62, "号码红18", 0}, + +{22, 9 , roulette22, roulette42, roulette44, roulette51, roulette61, "号码绿2", 0}, +{7 , 7 , roulette22, roulette42, roulette44, roulette51, roulette61, "号码绿2", 0}, +{21, 11, roulette24, roulette42, roulette44, roulette51, roulette61, "号码绿4", 0}, +{8 , 5 , roulette24, roulette42, roulette44, roulette51, roulette61, "号码绿4", 0}, +{18, 5 , roulette27, roulette42, roulette43, roulette53, roulette61, "号码绿7", 0}, +{11, 11, roulette27, roulette42, roulette43, roulette53, roulette61, "号码绿7", 0}, +{19, 11, roulette31, roulette42, roulette43, roulette51, roulette62, "号码绿11", 0}, +{10, 5 , roulette31, roulette42, roulette43, roulette51, roulette62, "号码绿11", 0}, +{18, 11, roulette32, roulette42, roulette44, roulette51, roulette62, "号码绿12", 0}, +{11, 5 , roulette32, roulette42, roulette44, roulette51, roulette62, "号码绿12", 0}, +{16, 11, roulette34, roulette42, roulette44, roulette52, roulette62, "号码绿14", 0}, +{14, 5 , roulette34, roulette42, roulette44, roulette52, roulette62, "号码绿14", 0}, +{15, 11, roulette35, roulette42, roulette43, roulette52, roulette62, "号码绿15", 0}, +{13, 5 , roulette35, roulette42, roulette43, roulette52, roulette62, "号码绿15", 0}, +{22, 7 , roulette36, roulette42, roulette44, roulette53, roulette62, "号码绿16", 0}, +{7 , 9 , roulette36, roulette42, roulette44, roulette53, roulette62, "号码绿16", 0}, +{21, 5 , roulette39, roulette42, roulette43, roulette52, roulette62, "号码绿19", 0}, +{8 , 11, roulette39, roulette42, roulette43, roulette52, roulette62, "号码绿19", 0}, +{20, 5 , roulette40, roulette42, roulette44, roulette52, roulette62, "号码绿20", 0}, +{9 , 11, roulette40, roulette42, roulette44, roulette52, roulette62, "号码绿20", 0}, +{22,11, roulette45, 0, 0, roulette52, 0, "号码00"}, + +{ 7, 5, -1, -1, -1, -1, -1, "号码X", 0}, +{ -1, -1, -1, -1, -1, -1, -1, "无", 0}, +}; + +enum { + /* + NPC_WORK_ROUTETOX = CHAR_NPCWORKINT1, + NPC_WORK_ROUTETOY = CHAR_NPCWORKINT2, + NPC_WORK_ROUTEPOINT = CHAR_NPCWORKINT3, +*/ + NPC_WORK_NPCAI = CHAR_NPCWORKINT3, + NPC_WORK_NPCACTION = CHAR_NPCWORKINT3, + NPC_WORK_MASTERSTONE = CHAR_NPCWORKINT4, + NPC_WORK_MODE = CHAR_NPCWORKINT5, + NPC_WORK_SYSTIME = CHAR_NPCWORKINT6, + NPC_WORK_GAMEFLG = CHAR_NPCWORKINT7, + NPC_WORK_GAMBLECODE = CHAR_NPCWORKINT8, + NPC_WORK_MASTERFLG = CHAR_NPCWORKINT9, + NPC_WORK_ENDPOINT = CHAR_NPCWORKINT10, +}; + +#define ROULETTE_ERRTIME 500 +#define ROULETTE_STANDBY1 40 +#define ROULETTE_LOOPTIME 3000 + +BOOL NPC_Gamble_MasterInit( int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf1[256]; + + if( NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL ) { + print("\n not found argstr "); + return FALSE; + } + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "gamble_code",buf1, sizeof(buf1)) == NULL ) { + print("\n gamble_code error: not found !!"); + return FALSE; + } + CHAR_setWorkInt( meindex, NPC_WORK_GAMBLECODE, atoi( buf1)); + //游戏阶段 + CHAR_setWorkInt( meindex, NPC_WORK_GAMEFLG, 0); + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_GAMBLEMASTER ); + // NPC_WORK_MODE 主持人状态 0: 等待 1:GAME START 2:GAME END + CHAR_setWorkInt( meindex, NPC_WORK_MODE, 0); + CHAR_setWorkInt( meindex, NPC_WORK_MASTERFLG, 30); + CHAR_setWorkInt( meindex, NPC_WORK_MASTERSTONE, 0); + CHAR_setWorkInt( meindex, NPC_WORK_NPCAI, 0); + //设定LOOP TIMER + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, ROULETTE_LOOPTIME); + //用来记录时间点 + CHAR_setWorkInt( meindex, NPC_WORK_SYSTIME, NowTime.tv_sec); + return TRUE; +} + +void NPC_Gamble_MasterTalked( int meindex , int talkerindex , char *szMes , int color ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + + 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; + } + + if( NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL ) { + print("\n not found argstr "); + return; + } + // 0 选单 11 - 19 规则 21 - 29 积分 + CHAR_setWorkInt(talkerindex , CHAR_WORKSHOPRELEVANT,0); + NPC_GambleRoulette_selectWindow( meindex, talkerindex, ROULETTE_START, -1 ); +} + +void NPC_GambleRoulette_selectWindow(int meindex,int toindex,int num,int select) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf1[256],buf2[256]; + char token[256]; + int buttontype = 0, windowtype = 0, windowno = 0; + int fd = getfdFromCharaIndex( toindex); + int pagenum=0, i; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + + if( NPC_Util_GetArgStr( meindex, npcarg, sizeof( npcarg)) == NULL ) { + print("\n not found npcarg "); + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT,0); + return; + } + switch( num) { + case ROULETTE_START: + i = 1; + strcpy( token, "\0"); + sprintf( buf2,"%s%d", "gamble_msg0", i); + while( NPC_Util_GetStrFromStrWithDelim( npcarg, buf2, buf1, sizeof( buf1) ) != NULL ) { + if( strstr( buf1, "NULL" ) == NULL ) { + strcat( token , buf1); + strcat( token, "\n"); + }else { + strcat( token, "\n"); + } + i++; + sprintf( buf2,"%s%d", "gamble_msg0", i); + } + windowtype=WINDOW_MESSAGETYPE_SELECT; + windowno = WINDOWTYPE_GAMBLEROULETTE_START; + break; + break; + case ROULETTE_SELECT: + //页 select + pagenum = CHAR_getWorkInt( toindex , CHAR_WORKSHOPRELEVANT); + strcpy( token, "\0"); + if( select >= 0 ) { + sprintf( buf2,"%s%2d", "page_num", select); + CHAR_setWorkInt( toindex , CHAR_WORKSHOPRELEVANT, select+1); + }else { + sprintf( buf2,"%s%2d", "page_num", pagenum ); + pagenum+=1; + CHAR_setWorkInt( toindex , CHAR_WORKSHOPRELEVANT, pagenum); + } + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, buf2, token, sizeof( token) ) == NULL ) { + print("\n error: not found token:%s", token); + CHAR_setWorkInt( toindex , CHAR_WORKSHOPRELEVANT,0); + return; + } + + sprintf( buf2,"%s%2d", "page_num", CHAR_getWorkInt( toindex , CHAR_WORKSHOPRELEVANT)); + if( NPC_Util_GetStrFromStrWithDelim( npcarg, buf2, buf1, sizeof( buf1) ) == NULL ) { + windowno = WINDOWTYPE_GAMBLEROULETTE_END; + buttontype = WINDOW_BUTTONTYPE_OK; + }else { + windowno = WINDOWTYPE_GAMBLEROULETTE_SELECT; + buttontype = WINDOW_BUTTONTYPE_NEXT; + } + break; + case ROULETTE_LOOK: + { //显示时补回积分 + int G_num = CHAR_getInt( toindex, CHAR_GAMBLENUM ); + + if( CHAR_getWorkInt( toindex, CHAR_WORKSTAKEFLAG) != FALSE) { + for( i=0; i<5; i++) { + if( CHAR_getWorkInt( toindex, i+CHAR_WORKSTAKETYPE1) > 0 ) + G_num++; + } + } + if( G_num < 0 ) G_num = 0; + sprintf( token,"你的游乐场积分为%d。", G_num ); + windowno = WINDOWTYPE_GAMBLEROULETTE_END; + buttontype = WINDOW_BUTTONTYPE_OK; + } + break; + case ROULETTE_END: + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "page_endmsg", token, sizeof( token) ) == NULL ) { + print("\n error: not found end_msg"); + CHAR_setWorkInt( toindex , CHAR_WORKSHOPRELEVANT,0); + return; + } + + windowno = WINDOWTYPE_GAMBLEROULETTE_END; + buttontype = WINDOW_BUTTONTYPE_OK; + break; + } + + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token); +} + +void NPC_Gamble_MasterWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data) +{ + int pagenum=0; + + 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; + } + + switch( seqno ) { + case WINDOWTYPE_GAMBLEROULETTE_START: + pagenum = atoi( data); + if( pagenum == 4 ) { + NPC_GambleRoulette_selectWindow( meindex, talkerindex, ROULETTE_END, -1 ); + }else { + if( pagenum == 3 ) { //ROULETTE_LOOK + NPC_GambleRoulette_selectWindow( meindex, talkerindex, ROULETTE_LOOK, -1 ); + }else { + pagenum = (pagenum*10)+1; + NPC_GambleRoulette_selectWindow( meindex, talkerindex, ROULETTE_SELECT, pagenum ); + } + } + break; + case WINDOWTYPE_GAMBLEROULETTE_SELECT: + NPC_GambleRoulette_selectWindow( meindex, talkerindex, ROULETTE_SELECT, -1 ); + break; + case WINDOWTYPE_GAMBLEROULETTE_END: + CHAR_setWorkInt(talkerindex , CHAR_WORKSHOPRELEVANT, 0); + break; + } + return; +} + +void NPC_Gamble_MasterLoop( int meindex) +{ + int objmeindex = -1; + int full_time; + //int Master_Stone = 0; + int timeNum = 0; + //int time_run=0; + //int act; + objmeindex = CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX); + switch( CHAR_getWorkInt( meindex, NPC_WORK_MODE )) { + case 0: // 等待 + full_time = ROULETTE_STANDBY1; + timeNum = CHAR_getWorkInt( meindex, NPC_WORK_MASTERFLG ); + if( ( CHAR_getWorkInt( meindex, NPC_WORK_SYSTIME) + full_time) < NowTime.tv_sec ) { + if( timeNum == 30 ) { //倒数20秒 + //0 null 1 准备 2 跑 3 停 + CHAR_setWorkInt( meindex, NPC_WORK_GAMEFLG, 1); + showString( meindex, "下注时间剩下20秒。", 0); + }else if( timeNum == 10 ) { + showString( meindex, "standby_msg", 0); //广播 + SetCasinoMap( meindex, 0, 0); //设定地图不可下注 + }else if( timeNum <= 6 ) { //开始 + //0 null 1 准备 2 跑 3 停 + CHAR_setWorkInt( meindex, NPC_WORK_GAMEFLG, 2); + CHAR_setWorkInt( meindex, NPC_WORK_MODE, 1); + showString( meindex, "start_msg", 0); //广播 + } + CHAR_setWorkInt( meindex, NPC_WORK_MASTERFLG, timeNum - 2 ); + } + break; + case 1: // GAME START + if( CHAR_getWorkInt( meindex, NPC_WORK_GAMEFLG) == 3 ) { + CHAR_setWorkInt( meindex, NPC_WORK_MODE, 2); + } + break; + case 2: // GAME END + CHAR_setWorkInt( meindex, NPC_WORK_MODE, 3); + defPlayerGold( meindex , TRUE); //计算输赢 + CHAR_setWorkInt( meindex, NPC_WORK_ENDPOINT, 0); + NPC_MAPCLEANGOLD( meindex , CHAR_getInt( meindex, CHAR_FLOOR )); + + LogGamble( + CHAR_getChar( meindex, CHAR_NAME ), "master", + "ROULETTE", CHAR_getInt( meindex, CHAR_FLOOR), + CHAR_getInt( meindex, CHAR_X ), + CHAR_getInt( meindex, CHAR_Y ) , + CHAR_getWorkInt( meindex, NPC_WORK_MASTERSTONE), 0, 0, 0, 2 + ); + break; + case 3: + CHAR_setWorkInt( meindex, NPC_WORK_MODE, 0); + CHAR_setWorkInt( meindex, NPC_WORK_GAMEFLG, 0); + showString( meindex, "end_msg", 0); //广播 + SetCasinoMap( meindex, 0, 1); //设定地图可下注 + CHAR_setWorkInt( meindex, NPC_WORK_MASTERFLG, 30 ); + CHAR_setWorkInt( meindex, NPC_WORK_SYSTIME, NowTime.tv_sec); + break; + default: + NPC_GAMBLEMASTER_RESET( meindex); + break; + } +} + +void defPlayerGold( int meindex , int flg) +{ + int X,Y; + int endpoint; + int End_type = 0; + int toindex=0, i, master_floor; + int player_type; + int gamble_num; + //float def; + char token[256], buff[256]; + char buf1[56],buf2[56]; + BOOL GAMBLE_YES = FALSE; + endpoint = CHAR_getWorkInt( meindex, NPC_WORK_ENDPOINT); + + X = (endpoint >> 16 ); + Y = (endpoint & 0xffff); + + for( End_type = 0; End_type < arraysizeof(EndTypedef) ; End_type++ ) { + if( (X == EndTypedef[ End_type].m_fx) && (Y == EndTypedef[ End_type].m_fy )) { + break; + } + } + + if( End_type == arraysizeof(EndTypedef) ) { + print("\n\n **********GAMBLE MASTER ERROR !! **************"); + print("\n NOT FOUND : X=%d Y=%d EndTypedef[I] !!", X, Y); + return; + } +/*Log===================================== + { //记录用 + FILE *fp; + int kp=0,pn=0;; + fp = fopen("./data/npc/roulette/lookgamble.txt","w+"); + if( fp != NULL ) { + if( EndTypedef[ End_type].m_nums < 10000 ) + EndTypedef[ End_type].m_nums = EndTypedef[ End_type].m_nums+1; + for( kp=0; kp 0 && EndTypedef[ kp].m_type > 0 ) { + fprintf( fp," %s 中奖次数 [%d] ", EndTypedef[ kp].str_type, EndTypedef[ kp].m_nums ); + if( (pn+1)%2 == 0 ) { + fprintf( fp," \n"); + } + pn ++; + } + } + fclose( fp); + } + } +//========================================*/ + + if( EndTypedef[ End_type].m_type <= 0 ) { + showString( meindex, "号码X,通杀!", 0); + }else { + sprintf( token ,"中奖号码 : %s ", EndTypedef[End_type].str_type ); + showString( meindex, token, 0 ); + } + if( EndTypedef[ End_type].m_EO == roulette43 ) { + sprintf( buf1,"单"); + }else { + sprintf( buf1,"双"); + } + if( EndTypedef[ End_type].m_RG == roulette41 ) { + sprintf( buf2,"红"); + }else { + sprintf( buf2,"绿"); + } + //找在场的人 + toindex = -1; + master_floor = CHAR_getInt( meindex , CHAR_FLOOR); + while( toindex < 10000 ) { + toindex++; + if( !CHAR_CHECKINDEX( toindex) ) + continue; + if( CHAR_getInt( toindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) + continue; + if( master_floor != CHAR_getInt( toindex, CHAR_FLOOR ) ) //是否在赌场 + continue; + if( CHAR_getWorkInt( toindex, CHAR_WORKSTAKEFLAG) == FALSE ) //是否有下注 + continue; + //是否赌中 + GAMBLE_YES = FALSE; + CHAR_setWorkInt( toindex, CHAR_WORKSTAKEFLAG, FALSE); + for( i=0; i<5; i++) { + player_type = CHAR_getWorkInt( toindex, i+CHAR_WORKSTAKETYPE1); + gamble_num = 0; + if( player_type > 0 ) { + if( player_type == EndTypedef[End_type].m_type ) { //中了号码 + if( EndTypedef[End_type].m_type == roulette45 ) { + gamble_num += 40; + }else { + gamble_num += 20; + } + GAMBLE_YES = TRUE; + //算钱 + Codef_Gold( meindex, toindex, gamble_num, 0, EndTypedef[End_type].str_type ); + }else if( player_type == EndTypedef[End_type].m_RG ) { //中了红绿 + gamble_num += 1; + GAMBLE_YES = TRUE; + Codef_Gold( meindex, toindex, gamble_num, 0, buf2 ); + }else if( player_type == EndTypedef[End_type].m_EO ) { //中了单双 + gamble_num += 1; + GAMBLE_YES = TRUE; + Codef_Gold( meindex, toindex, gamble_num, 0, buf1 ); + }else if( player_type == EndTypedef[End_type].m_SI ) { //横列 + gamble_num += 2; + GAMBLE_YES = TRUE; + sprintf( token,"%s%d", "横列", EndTypedef[End_type].m_SI-100 ); + Codef_Gold( meindex, toindex, gamble_num, 0, token ); + }else if( player_type == EndTypedef[End_type].m_IN ) { //1-10 11-20 + gamble_num += 1; + GAMBLE_YES = TRUE; + if( (EndTypedef[End_type].m_IN - 100 ) == 11 ) { + snprintf( buff, sizeof( buff),"1-10"); + }else if( (EndTypedef[End_type].m_IN - 100 ) == 12 ) { + snprintf( buff, sizeof( buff),"11-20"); + } + sprintf( token,"%s%s", " 围", buff ); + Codef_Gold( meindex, toindex, gamble_num, 0, token ); + }else { //没中 扣积分 + if( (player_type>>16) == EndTypedef[End_type].m_type || + (player_type&0xffff) == EndTypedef[End_type].m_type + ) { //中双号 + gamble_num += 10; + GAMBLE_YES = TRUE; + sprintf( token,"%s%s", "双号-", EndTypedef[End_type].str_type ); + Codef_Gold( meindex, toindex, gamble_num, 0, token ); + }else if( player_type > 0 ) { //72 73 74 75 没中 扣积分 + strcpy( token, "\0"); + if( player_type >= roulette41 && player_type <= roulette44 ) { //红绿单双 + sprintf( token,"%s", "押注 红绿单双 没中"); + }else if( player_type == roulette45 ) { //数字00 + sprintf( token,"%s", "押注 数字00 没中"); + }else if( player_type >= roulette51 && player_type <= roulette53 ) { //横列 + sprintf( token,"%s", "押注 横列 没中"); + }else if( player_type >= roulette61 && player_type <= roulette62 ) { // 围 + sprintf( token,"%s", "押注 围 没中"); + }else if( player_type > (1<<16) ) { //双号 + sprintf( token,"%s", "押注 双号 没中"); + }else { //数字 + sprintf( token,"%s", "押注 数字 没中"); + } + gamble_num -= 1; + Codef_Gold( meindex, toindex, gamble_num, 1, token ); + } + } + } + //清空 + CHAR_setWorkInt( toindex, i+CHAR_WORKSTAKETYPE1, 0); + } + if( CHAR_getInt( toindex, CHAR_GAMBLENUM) < 0 ) { + CHAR_setInt( toindex, CHAR_GAMBLENUM, 0 ); + }else if( CHAR_getInt( toindex, CHAR_GAMBLENUM) > 10000 ) { + CHAR_setInt( toindex, CHAR_GAMBLENUM, 10000 ); + } + sprintf( token, "你的游乐场积分累计为%d分。", CHAR_getInt( toindex, CHAR_GAMBLENUM)); + CHAR_talkToCli( toindex, meindex, token, CHAR_COLORYELLOW); + + if( GAMBLE_YES == FALSE ) { + sprintf( token, "你所有押注都没中奖!"); + CHAR_talkToCli( toindex, meindex, token, CHAR_COLORYELLOW); + continue; + } + + } + return; +} + +void Codef_Gold( int meindex, int toindex, int stone,int flg, char *token) +{ + char buf1[256]; + int dnum=-1; + int Master_gnum=0; + Master_gnum = CHAR_getWorkInt( meindex, NPC_WORK_MASTERSTONE); + Master_gnum += stone; + if( !flg ) { + sprintf( buf1,"恭喜你中了:%s,可拿得 %d 点积分", token, stone); + CHAR_talkToCli( toindex, meindex, buf1, CHAR_COLORYELLOW); +#ifdef _FIX_GAMBLENUM + stone += 1; //加上一开始下注扣的积分 +#endif + CHAR_setInt( toindex, CHAR_GAMBLENUM, CHAR_getInt( toindex, CHAR_GAMBLENUM) + stone); + + }else { + dnum = stone; + if( stone < 0 ) { + dnum = (dnum*(-1)); + } + + sprintf( buf1,"%s,扣 %d 点积分", token, dnum); + CHAR_talkToCli( toindex, meindex, buf1, CHAR_COLORYELLOW); +#ifdef _FIX_GAMBLENUM +#else + CHAR_setInt( toindex, CHAR_GAMBLENUM, CHAR_getInt( toindex, CHAR_GAMBLENUM) + stone); +#endif + } + + LogGamble( + CHAR_getChar( toindex, CHAR_NAME ), + CHAR_getChar( toindex, CHAR_CDKEY ), + "ROULETTE", + CHAR_getInt( toindex, CHAR_FLOOR), + CHAR_getInt( toindex, CHAR_X ), + CHAR_getInt( toindex, CHAR_Y ), + CHAR_getInt( toindex, CHAR_GOLD), + stone, + 0, + CHAR_getInt( toindex, CHAR_GAMBLENUM ), + 1 + ); + + //纪录盈亏 + if( Master_gnum > 5000000 ) Master_gnum = 5000000; + if( Master_gnum < 0 ) Master_gnum = 0; + CHAR_setWorkInt( meindex, NPC_WORK_MASTERSTONE, Master_gnum); + return; +} +//重置 错误处理 +void NPC_GAMBLEMASTER_RESET( int meindex) +{ + //错误处理 + print("\n 错误处理"); + CHAR_setWorkInt( meindex, NPC_WORK_GAMEFLG, 0);//0 null 1 准备 2 跑 + CHAR_setWorkInt( meindex, NPC_WORK_MODE, 0); + showString( meindex, "本回合不算!等5分钟後重新开始!!", 1); + NPC_MAPCLEANGOLD( meindex , CHAR_getInt( meindex, CHAR_FLOOR )); + //defPlayerGold( meindex , FALSE); + CHAR_setWorkInt( meindex, NPC_WORK_SYSTIME, NowTime.tv_sec + ROULETTE_ERRTIME); +} + +#endif + + + diff --git a/gmsv/npc/npc_gambleroulette.c b/gmsv/npc/npc_gambleroulette.c new file mode 100644 index 0000000..a2c9953 --- /dev/null +++ b/gmsv/npc/npc_gambleroulette.c @@ -0,0 +1,474 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "readmap.h" +#include "lssproto_serv.h" +#include "handletime.h" + +#ifdef _GAMBLE_ROULETTE +#include "npc_gambleroulette.h" + +#define _OTHER_ROUND //另一种跑法 + +static void Gamble_Roulette_walk( int meindex); +static int Gamble_RouletteSetPoint( int meindex ); +static void Find_Master( int meindex); +int RunRand( int meindex, int flg ); +BOOL SetEndPoint( int meindex ); +void Gamble_Roulette_Reset( int meindex, int flg); +void ResetDataStart( int meindex); +BOOL ReadPointData( int meindex ); +enum { + NPC_WORK_ROUTETOX = CHAR_NPCWORKINT1, + 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, //记录主持人index +}; + +typedef struct tagRoulettePoint { + int x; + int y; + int flg; +}RoulettePoint; +RoulettePoint PointData[]={ + {-1,-1,-1},{-1,-1,-1},{-1,-1,-1},{-1,-1,-1}, +}; + +RoulettePoint TestPointData[4*8]; + +#define ROULETTE_STANDBY 1500 +#define ROULETTE_LOOPTIME 1000 + +#define ROULETTE_RUNTIME1 50 + +BOOL NPC_Gamble_RouletteInit( int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_GAMBLEROULETTE ); + //CHAR_setWorkInt( meindex, NPC_WORK_ROUTEMAX, routenum); + //小猪要走几格才停 + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEMAX, 0); + CHAR_setWorkInt( meindex, NPC_WORK_SEFLG, -1); + // NPC_WORK_MODE 小猪的状态 0:等待 1:走(顺) + CHAR_setWorkInt( meindex, NPC_WORK_MODE, 0); + //第几个地图点 + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, 0); + //顺向 1 逆向 0 + CHAR_setWorkInt( meindex, NPC_WORK_ROUNDTRIP, 1); + //第几个路线 + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTROUTE, 0); + //设定LOOP TIMER + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, ROULETTE_STANDBY); + //用来记录时间点 + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX)); + if( ReadPointData( meindex) == FALSE ) + return FALSE; + return TRUE; +} + +void NPC_Gamble_RouletteTalked( int meindex , int talkerindex , char *szMes , int color ) +{ + return; +} + +void NPC_Gamble_RouletteWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data) +{ + return; +} + +void NPC_Gamble_RouletteLoop( int meindex) +{ + int objmeindex = -1, index = 0, act = 0; + objmeindex = CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX); + switch( CHAR_getWorkInt( meindex, NPC_WORK_MODE )) { + case 0: //停止时等待 为等待主持人下命令 + + //抓主持人index 检查主持人 是否喊开始 + if( CHAR_getWorkInt( meindex, NPC_WORK_SEFLG) < 0 ) { + CHAR_setWorkInt( meindex, NPC_WORK_MODE,5); + }else { + index = CHAR_getWorkInt( meindex, NPC_WORK_SEFLG); + //CHAR_NPCWORKINT7 0 null 1 准备 2 跑 3 停 + if( CHAR_getWorkInt( index, CHAR_NPCWORKINT7 ) == 2 ) { + CHAR_sendCToArroundCharacter( objmeindex); + CHAR_setWorkInt( meindex, NPC_WORK_MODE,1); + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, ROULETTE_RUNTIME1); + //决定小猪走几格 + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEMAX, RunRand( meindex, 0 ) ); + ResetDataStart( meindex);//决定进点 + if( CHAR_getInt( meindex, CHAR_X) == 14 && + CHAR_getInt( meindex, CHAR_Y) == 8 ) { + }else { + print("\n\n####################\n 小猪不在原点!![%d,%d]", + CHAR_getInt( meindex, CHAR_X), + CHAR_getInt( meindex, CHAR_Y) + ); + + } + }else if( CHAR_getWorkInt( index, CHAR_NPCWORKINT7 ) == 1 || + ( CHAR_getWorkInt( index, CHAR_NPCWORKINT9) < 30 && + CHAR_getWorkInt( index, CHAR_NPCWORKINT9) > 24 ) + ) { //准备 + if( CHAR_getInt( meindex, CHAR_X) == 14 && CHAR_getInt( meindex, CHAR_Y) == 8 ) { + }else { + CHAR_warpToSpecificPoint( meindex, CHAR_getInt( meindex, CHAR_FLOOR), + 14, 8); + CHAR_setInt( meindex, CHAR_X, 14); + CHAR_setInt( meindex, CHAR_Y, 8); + CHAR_sendCToArroundCharacter( objmeindex); + } + } + } + break; + case 1: + Gamble_Roulette_walk( meindex); + break; + case 2: + break; + case 3: + //点归零 + CHAR_setWorkInt( meindex, NPC_WORK_MODE, 0); + //动作 + act = CHAR_ACTATTACK; + CHAR_sendWatchEvent( objmeindex, act, NULL,0, FALSE); + CHAR_setWorkInt( meindex, CHAR_WORKACTION, act); + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEMAX, 0); + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, ROULETTE_STANDBY); + + //送人物资料给视觉 围内的人 + CHAR_sendCToArroundCharacter( objmeindex); + if( SetEndPoint( meindex ) == FALSE ) { + print("\n not Set EndPoint !!"); + } +#ifdef _OTHER_ROUND +#else + ReadPointData( meindex); //load round data +#endif + //还原主持人 + index = CHAR_getWorkInt( meindex, NPC_WORK_SEFLG); + CHAR_setWorkInt( index, CHAR_NPCWORKINT7, 3); + break; + case 5: //寻找主持人 + Find_Master( meindex); + if( CHAR_getWorkInt( meindex, NPC_WORK_SEFLG) < 0 ) { + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, 0); + CHAR_setWorkInt( meindex, NPC_WORK_MODE,-1); + }else { + CHAR_setWorkInt( meindex, NPC_WORK_MODE, 0); + } + break; + default: + //重置 错误处理 + Gamble_Roulette_Reset( meindex, 0); + break; + } +} + +static void Gamble_Roulette_walk( int meindex) +{ + POINT start, end; + int dir; + int ret; + int i,run_num = 0; + int objmeindex = -1; + objmeindex = CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX); + + start.x = CHAR_getInt( meindex, CHAR_X); + start.y = CHAR_getInt( meindex, CHAR_Y); + end.x = CHAR_getWorkInt( meindex, NPC_WORK_ROUTETOX); + end.y = CHAR_getWorkInt( meindex, NPC_WORK_ROUTETOY); + // loop timer分为两部分 1. 处理下一点 2. 走到下一点 + + if( start.x == end.x && start.y == end.y ) { +#ifdef _OTHER_ROUND +#else + int add = 1; + //如果为 NPC_WORK_ROUNDTRIP != 1 逆向 + if( CHAR_getWorkInt( meindex, NPC_WORK_ROUNDTRIP ) != 1 ) { + add *= -1; + } + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, + CHAR_getWorkInt( meindex, NPC_WORK_ROUTEPOINT) +add); +#endif + if( Gamble_RouletteSetPoint( meindex ) == FALSE ) { +#ifdef _OTHER_ROUND + CHAR_setWorkInt( meindex, NPC_WORK_MODE,3); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + return; +#else + if( CHAR_getWorkInt( meindex, NPC_WORK_ROUNDTRIP ) != 1 ) { + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, arraysizeof( PointData) ); //逆向 + }else { + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, -1); //顺向 + } + return; +#endif + }else { + return; + } + } +//-------------------------------------------------------------------- + run_num = CHAR_getWorkInt( meindex, NPC_WORK_ROUTEMAX); + if( run_num > 0 ){ + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEMAX, (run_num - 1) ); + }else { +#ifdef _OTHER_ROUND + CHAR_setWorkInt( meindex, NPC_WORK_MODE,3); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + return; +#else + int npc_ai=0; + int masterindex; + masterindex = CHAR_getWorkInt( meindex, NPC_WORK_SEFLG); + npc_ai = CHAR_getWorkInt( masterindex, CHAR_NPCWORKINT3); + if( npc_ai > 10 ) { + if( start.x == 7 && start.y == 5 ) { // 7,5 + CHAR_setWorkInt( masterindex, CHAR_NPCWORKINT3, 0); + }else { + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEMAX, 1); + return; + } + } + CHAR_setWorkInt( meindex, NPC_WORK_MODE,3); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + return; +#endif + } +//-------------------------------------------------------------------- + dir = NPC_Util_getDirFromTwoPoint( &start,&end ); + for( i = 0; i < 100; i ++ ) { + if( dir < 0 ) { + dir = RAND( 0,7); + } + dir = NPC_Util_SuberiWalk( meindex, dir); + if( dir >= 0 && dir <= 7) break; + } + if( dir >= 0 && dir <= 7 ) { + ret = CHAR_walk( meindex, dir, 0); + } +} + +static void Find_Master( int meindex) +{ + int floor, x=14, y=3; + OBJECT object; + floor = CHAR_getInt( meindex , CHAR_FLOOR); + for( object = MAP_getTopObj( floor, x, y) ; object ; object = NEXT_OBJECT(object ) ){ + int findex; + int objindex = GET_OBJINDEX(object); + if( !CHECKOBJECTUSE( objindex)) continue; + findex = OBJECT_getIndex( objindex); + if( !CHAR_CHECKINDEX( findex)) continue; + if( CHAR_getInt( findex , CHAR_WHICHTYPE ) != CHAR_GAMBLEMASTER ) continue; + if( CHAR_getWorkInt( findex, CHAR_NPCWORKINT8) != 10001 ) continue; + CHAR_setWorkInt( meindex, NPC_WORK_SEFLG, findex) ; + return; + } +} + +int RunRand( int meindex, int flg ) +{ +#define RAND(x,y) ((x-1)+1+ (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) ) + int run_num1=0; + int i; + + run_num1 = RAND( 90, 150); + for( i=0; i<6; i++ ) { + run_num1 += RAND( 0, 20); + } + return run_num1; +} + +BOOL SetEndPoint( int meindex ) +{ + int x,y; + int master; + int endpoint; + + master = CHAR_getWorkInt( meindex, NPC_WORK_SEFLG); + if( !CHAR_CHECKINDEX( master) ) + return FALSE; + + if( CHAR_getWorkInt( master, CHAR_NPCWORKINT7) != 2 ) { + print("\n error( master,CHAR_NPCWORKINT7) != 2 "); + return FALSE; + } + + x = CHAR_getInt( meindex, CHAR_X); + y = CHAR_getInt( meindex, CHAR_Y); + endpoint = (x<<16)+(y<<0); + CHAR_setWorkInt( master, CHAR_NPCWORKINT10, endpoint); + return TRUE; +} + +void Gamble_Roulette_Reset( int meindex, int flg) +{ + //错误处理 + int index; + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEMAX, 0); + CHAR_setWorkInt( meindex, NPC_WORK_MODE, 0); + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, ROULETTE_STANDBY); + + index = CHAR_getWorkInt( meindex, NPC_WORK_SEFLG); + if( !CHAR_CHECKINDEX( index) ) { + print("\n Gamble_Roulette error: no master !!"); + return; + } + CHAR_setWorkInt( index, CHAR_NPCWORKINT7, 3); + CHAR_setWorkInt( index, CHAR_NPCWORKINT10, 0); +} + +void ResetDataStart( int meindex ) +{ +#define RAND(x,y) ((x-1)+1+ (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) ) + int Start=1; + struct tagWalkStartPoint{ + int x; + int y; + int rip; + }WalkStart[]={ + {7,5,1}, {7,11,0}, {22,11,1}, {22,5,0}, + }; + Start = RAND( 0, 3); + + CHAR_setWorkInt( meindex, NPC_WORK_ROUNDTRIP, WalkStart[Start].rip ); + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, Start); + CHAR_setWorkInt( meindex, NPC_WORK_ROUTETOX, WalkStart[Start].x ); + CHAR_setWorkInt( meindex, NPC_WORK_ROUTETOY, WalkStart[Start].y ); + + { + int i=0,k; + int RIP = CHAR_getWorkInt( meindex, NPC_WORK_ROUNDTRIP); + k = CHAR_getWorkInt( meindex, NPC_WORK_ROUTEPOINT); + if( RIP ) { + while( i < (arraysizeof( TestPointData))) { + k++; + if( k > 3 ) k = 0; + TestPointData[i].x = PointData[k].x; + TestPointData[i].y = PointData[k].y; + i++; + } + }else { + while( i < (arraysizeof( TestPointData))) { + k--; + if( k < 0 ) k = 3; + TestPointData[i].x = PointData[k].x; + TestPointData[i].y = PointData[k].y; + i++; + } + } + } +#ifdef _OTHER_ROUND + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, 0); +#endif +} + +BOOL ReadPointData( int meindex ) +{ + + char buf1[256], buf2[32], buf3[16]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + int k=1,i=0; + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "roulette",buf1, sizeof(buf1)) == NULL ) { + print("\n roulette error: not found !!"); + return FALSE; + } + k=1; + while( getStringFromIndexWithDelim( buf1, ";", k, buf2, sizeof(buf2) ) != FALSE ) { + k++; + if( strstr( buf2,",") == NULL ) + continue; + + if( getStringFromIndexWithDelim( buf2, ",", 1, buf3, sizeof(buf3)) == FALSE) { + return FALSE; + } + PointData[i].x = atoi( buf3); + if( getStringFromIndexWithDelim( buf2, ",", 2, buf3, sizeof(buf3)) == FALSE) { + return FALSE; + } + PointData[i].y = atoi( buf3); + if( i > 9 ) { + break; + } + i++; + } +#ifdef _OTHER_ROUND +#else + Gamble_RouletteSetPoint( meindex); +#endif + return TRUE;//arraysizeof( PointData) +} + +static int Gamble_RouletteSetPoint( int meindex ) +{ +#ifdef _OTHER_ROUND + int i; + i = CHAR_getWorkInt( meindex, NPC_WORK_ROUTEPOINT); + CHAR_setWorkInt( meindex, NPC_WORK_ROUTETOX, TestPointData[i].x ); + CHAR_setWorkInt( meindex, NPC_WORK_ROUTETOY, TestPointData[i].y ); + i++; + CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, i); + if( i >= arraysizeof( TestPointData) ) { + return FALSE; + } +#else + int i; + i = CHAR_getWorkInt( meindex, NPC_WORK_ROUTEPOINT); + if( i<0 || i>arraysizeof( PointData) -1) { + return FALSE; + } + CHAR_setWorkInt( meindex, NPC_WORK_ROUTETOX, PointData[i].x ); + CHAR_setWorkInt( meindex, NPC_WORK_ROUTETOY, PointData[i].y ); +#endif + {//检查路线 + struct tagWalkStartPoint{ + int x; + int y; + }WalkStart[]={ + {22,5}, {7,5}, {7,11}, {22,11}, {22,5}, {7,5} + }; + int ch_x,ch_y; + int next_x,next_y; + int h; + ch_x = CHAR_getInt( meindex, CHAR_X); + ch_y = CHAR_getInt( meindex, CHAR_Y); + for( h=1; h<5; h++) { + if( ch_x == WalkStart[h].x && + ch_y == WalkStart[h].y) { + next_x = CHAR_getWorkInt( meindex, NPC_WORK_ROUTETOX); + next_y = CHAR_getWorkInt( meindex, NPC_WORK_ROUTETOY); + if( next_x == WalkStart[h+1].x && + next_y == WalkStart[h+1].y) { + + }else if( next_x == WalkStart[h-1].x && + next_y == WalkStart[h-1].y) { + }else { + print("\n ##############################"); + print("\n ERR : [%d,%d] -> [%d,%d]",ch_x,ch_y,next_x,next_y); + } + break; + } + } + } + return TRUE; +} + +#endif + + + diff --git a/gmsv/npc/npc_healer.c b/gmsv/npc/npc_healer.c new file mode 100644 index 0000000..91ecc8e --- /dev/null +++ b/gmsv/npc/npc_healer.c @@ -0,0 +1,181 @@ +#include "version.h" +#include +#include +#include + +#include "object.h" +#include "char_base.h" +#include "char.h" +#include "util.h" +#include "npcutil.h" +#include "item.h" +#include "readmap.h" + + +#define RANGE 2 +void NPC_HealerSpeak( int index, int talker); +void NPC_HealerAllHeal( int talker ); +BOOL NPC_MoneyCheck(int meindex,int talker); +int NPC_CostCheck(int talker); +void NPC_CharCheckPoint(int meindex,int talker); +int NPC_WorkInput(int meindex,int talker); + + +/********************************** +赓渝祭 +************************************/ +BOOL NPC_HealerInit( int meindex ) +{ + //正奶皿毛甲□仿□卞涩烂 + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEHEALER ); + // 猾匹五卅中 邰卅中井手 + CHAR_setFlg( meindex , CHAR_ISATTACKED , 0 ); + //晓卞昙木卅中 +// CHAR_setFlg( meindex , CHAR_ISOVERED , 0 ); + + return TRUE; + +} + + + + +/*------------------------------------------- + * + * 今木}HP,MP毛蝈钒卞允月 + * + --------------------------------------------*/ +void NPC_HealerTalked( int meindex , int talker , char *msg ,int color ) +{ + + char* npcarg; + char token[32]; + int msgNo; + + + npcarg = CHAR_getChar(meindex,CHAR_NPCARGUMENT); + + getStringFromIndexWithDelim( npcarg, "|", 1, token,sizeof( token)); + msgNo = atoi( token ); + + /*---皿伊奶乩□卞覆仄化分仃 杀允月---*/ + if( CHAR_getInt( talker , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) return; + + /*--- 区动 井" 区反1引凶反}仄氏匹中月井"---*/ + /* ㄠ弘伉永玉动 及心 */ + if( NPC_Util_CharDistance( talker, meindex ) > 2) return; + + if( (CHAR_getWorkInt( talker, CHAR_WORKPARTYMODE) == 0) + || (CHAR_getWorkInt( talker, CHAR_WORKPARTYMODE) == 2) ) + { + /*--荚汊今六引仄斤丹--*/ + NPC_HealerAllHeal( talker); + if(msgNo == 1) { + CHAR_talkToCli( talker, meindex, + "已经全部回复。请在下次的比赛中加油唷!",CHAR_COLORWHITE); + + }else if(msgNo == 2) { + CHAR_talkToCli( talker, meindex, + "由於你很诚实,让我帮你回复吧!",CHAR_COLORWHITE); + } + + }else{ + int i = 0; + int otherindex; + + for( i=0 ; i < CHAR_PARTYMAX ; i++) + { + otherindex = CHAR_getWorkInt( talker, CHAR_WORKPARTYINDEX1 + i); + if(otherindex != -1){ + + NPC_HealerAllHeal( otherindex); + if(msgNo == 1) { + CHAR_talkToCli( otherindex, meindex, + "已经全部回复。请在下次的比赛中加油唷!",CHAR_COLORWHITE); + + }else if(msgNo == 2) { + CHAR_talkToCli( otherindex, meindex, + "由於你很诚实,让我帮你回复吧!",CHAR_COLORWHITE); + } + } + } + } +} + + +/*----------------------*/ +/* 荚汊 */ +/*-----------------------*/ +void NPC_HealerAllHeal( int talker ) +{ + int i; + int petindex; + char petsend[3]; + char msgbuf[5]; + + CHAR_setInt( talker , CHAR_HP ,CHAR_getWorkInt( talker, CHAR_WORKMAXHP ) ); + CHAR_setInt( talker , CHAR_MP ,CHAR_getWorkInt( talker, CHAR_WORKMAXMP ) ); + + + + for(i = 0 ; i < CHAR_MAXPETHAVE; i ++) { + petindex = CHAR_getCharPet( talker, i); + + if( petindex == -1 ) continue; + + /* 平乓仿及 民尼永弁 */ + if( !CHAR_CHECKINDEX( talker ) ) continue; + + /* 矢永玄及index民尼永弁毛允月 */ + if( CHAR_CHECKINDEX( petindex) == FALSE ) continue; + + /*--荚汊--*/ + CHAR_setFlg( petindex, CHAR_ISDIE, 0); + CHAR_setInt( petindex , CHAR_HP ,CHAR_getWorkInt( petindex, CHAR_WORKMAXHP ) ); + CHAR_setInt( petindex , CHAR_MP ,CHAR_getWorkInt( petindex, CHAR_WORKMAXMP ) ); + + /*--由仿丢□正譬帮--*/ + CHAR_complianceParameter( petindex ); + sprintf( petsend, "K%d", i ); + CHAR_sendStatusString( talker , petsend ); + } + + /*---醮棉互中木壬醮棉卞手霜耨--*/ + if(CHAR_getWorkInt( talker, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE ) + { + int topartyarray = -1; + int oyaindex = CHAR_getWorkInt( talker , CHAR_WORKPARTYINDEX1); + + if( CHAR_CHECKINDEX( oyaindex )) { + int i; + + /* 愤坌午怂仄凶支勾及醮棉及 及桦赭毛潸 */ + for( i = 0; i < CHAR_PARTYMAX; i ++ ) { + int workindex = CHAR_getWorkInt( oyaindex, CHAR_WORKPARTYINDEX1 + i); + if( CHAR_CHECKINDEX( workindex) ) { + if( workindex == talker ) { + topartyarray = i; + break; + } + } + } + + for( i = 0; i < CHAR_PARTYMAX; i ++ ) { + int otherindex = CHAR_getPartyIndex( talker, i); + /* 醮棉由仿丢□正毛霜月 */ + if( CHAR_CHECKINDEX( otherindex) ) { + snprintf( msgbuf, sizeof( msgbuf), "N%d", topartyarray); + if( otherindex != talker) { + CHAR_sendStatusString( otherindex, msgbuf); + } + } + } + } + } + + /*--由仿丢□正霜曰--*/ + CHAR_send_P_StatusString( talker, CHAR_P_STRING_HP); + CHAR_send_P_StatusString( talker, CHAR_P_STRING_MP); + +} + diff --git a/gmsv/npc/npc_itemchange.c b/gmsv/npc/npc_itemchange.c new file mode 100644 index 0000000..fa44c19 --- /dev/null +++ b/gmsv/npc/npc_itemchange.c @@ -0,0 +1,259 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.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_itemchange.h" + +#ifdef _ITEM_NPCCHANGE +enum { + ITEMCHANGE_START=1, + ITEMCHANGE_SELECT, + ITEMCHANGE_MESSAGE, + ITEMCHANGE_END, + ITEMCHANGE_ERROR, + +}; +enum { + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT1, +/* + 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, +*/ +}; + +static void NPC_ItemchangeMan_selectWindow( int meindex, int toindex, int num,int select); +BOOL ItemchangeMan_GetNeedStr( int meindex, int toindex, char *npcarg, char *token, int num ); +BOOL ItemchangeMan_GetMenuStr( int meindex, int toindex, char *npcarg, char *token); + +BOOL NPC_ItemchangeManInit( 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_ITEMCHANGENPC); + + //CHAR_setInt( meindex, CHAR_LOOPINTERVAL, NEWNPCMAN_STANDBY); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + + return TRUE; +} +//CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANT,1); +void NPC_ItemchangeManTalked( 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_ItemchangeMan_selectWindow( meindex, talkerindex, ITEMCHANGE_START, -1); + +} + +void NPC_ItemchangeManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data) +{ + int flg=-1; + if( select == WINDOW_BUTTONTYPE_NO || select == WINDOW_BUTTONTYPE_CANCEL) + return; + switch( seqno) { + case NPC_ITEMCHANGE_START: + break; + case NPC_ITEMCHANGE_SELECT: + NPC_ItemchangeMan_selectWindow( meindex, talkerindex, ITEMCHANGE_SELECT, flg); + break; + case NPC_ITEMCHANGE_MESSAGE: + flg = atoi( data); + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, flg); + NPC_ItemchangeMan_selectWindow( meindex, talkerindex, ITEMCHANGE_MESSAGE, flg); + break; + case NPC_ITEMCHANGE_END: + flg = CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT); + NPC_ItemchangeMan_selectWindow( meindex, talkerindex, ITEMCHANGE_END , flg); + break; + } + +} + +static void NPC_ItemchangeMan_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); + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + 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 ITEMCHANGE_START: + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "START_MSG", token, sizeof( token) ) == NULL) { + print("TranserMan Get START_MSG ERROR !"); + return; + } + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, ITEMCHANGE_START); + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowno = NPC_ITEMCHANGE_SELECT; + break; + case ITEMCHANGE_SELECT: + if( ItemchangeMan_GetMenuStr( meindex, toindex, npcarg, token) == FALSE ) + return; + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, ITEMCHANGE_SELECT); + windowtype = WINDOW_MESSAGETYPE_SELECT; + buttontype = WINDOW_BUTTONTYPE_CANCEL; + windowno = NPC_ITEMCHANGE_MESSAGE; + break; + case ITEMCHANGE_MESSAGE: + if( ItemchangeMan_GetNeedStr( meindex, toindex, npcarg, token, select ) == FALSE ) + return; + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowno = NPC_ITEMCHANGE_END; + break; + case ITEMCHANGE_END: + if( ActionNpc_CheckMenuFree( meindex, toindex, npcarg, select ) == FALSE ){ + memset( token, 0, sizeof( token)); + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "FAIL_MSG", token, sizeof( token) ) != NULL) { + CHAR_talkToCli( toindex, meindex, token, CHAR_COLORYELLOW); + } + } + return; + break; + case ITEMCHANGE_ERROR: + break; + } + + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token); +} + +void NPC_ItemchangeManLoop( int meindex) +{ + +} + +BOOL ItemchangeMan_GetMenuStr( int meindex, int toindex, char *npcarg, char *token) +{ + char buf1[1024], buf2[256], buf3[256]; + char NullName[256] = {"未知的物品"}; + BOOL FINDS=FALSE; + int talkNo=1; + int addID; + if( npcarg == NULL ) return FALSE; + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "MenuHead", buf1, sizeof( buf1) ) == NULL){ + print("ItemchangeMan Get MenuHead ERROR!"); + return FALSE; + } + + sprintf( token, "%s\n", buf1); + + while( getStringFromIndexWithDelim( npcarg,"}", talkNo, buf1, sizeof( buf1)) != FALSE ) { + char *ItemName; + talkNo++; + + if( NPC_Util_GetStrFromStrWithDelim( buf1, "CHANGEITEM", buf2, sizeof( buf2)) != NULL ){ + addID = atoi( buf2); + if( (ItemName = ITEM_getNameFromNumber( addID)) == NULL ){ + sprintf( buf3, " %s\n", NullName); + }else{ + sprintf( buf3, " %s\n", ItemName); + } + // continue; + }else { + memset( buf3, 0, sizeof( buf3)); + if( NPC_Util_GetStrFromStrWithDelim( buf1, "CHANGEMSG", buf3, sizeof( buf3)) == NULL ) + continue; + strcat( buf3, "\n"); + } + FINDS = TRUE; + strcat( token, buf3); + } + + return FINDS; +} + +BOOL ItemchangeMan_GetNeedStr( int meindex, int toindex, char *npcarg, char *token, int num ) +{ + char buf1[1024], buf2[256], buf3[256]; + char NullName[256] = {"未知的物品"}; + int talkNo=1, addID, i=0; + BOOL FINDS = FALSE; + if( npcarg == NULL ) return FALSE; + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "NeedHead", buf1, sizeof( buf1) ) == NULL){ + print("ItemchangeMan Get NeedHead ERROR!\n%s", npcarg); + return FALSE; + } + sprintf( token, "%s\n", buf1); + if( getStringFromIndexWithDelim( npcarg,"}", num, buf1, sizeof( buf1)) == FALSE ) { + printf("Get NeedMess error !!\n"); + return FALSE; + } + + if( NPC_Util_GetStrFromStrWithDelim( buf1, "NeedItem", buf2, sizeof( buf2) ) != NULL){ + while( getStringFromIndexWithDelim( buf2, ",", talkNo, buf1, sizeof( buf1)) != FALSE ) { + char *ItemName=NULL; + talkNo++; + + addID = atoi( buf1); + FINDS = TRUE; + if( (ItemName = ITEM_getNameFromNumber( addID)) == NULL ){ + sprintf( buf3, "%s ", NullName); + }else{ + sprintf( buf3, "%s ", ItemName); + } + strcat( token, buf3); + if( i%3 == 0 ) + strcat( token, "\n"); + i++; + } + }else { + if( NPC_Util_GetStrFromStrWithDelim( buf1, "NeedMsg", buf2, sizeof( buf2) ) == NULL) + return FALSE; + sprintf( token, "%s ", buf2); + FINDS = TRUE; + } + + if( NPC_Util_GetStrFromStrWithDelim( buf2, "DelGold", buf1, sizeof( buf1)) != NULL ) { + char goldmess[256]; + int gold = atoi( buf1); + if( gold > 0 ) { + sprintf( goldmess, "石币:%d \n", gold); + strcat( token, goldmess); + } + } + + return FINDS; +} +//void ItemchangeMan_CheckMenuFree( int meindex, int toindex, char *npcarg, int nums) +#endif + + diff --git a/gmsv/npc/npc_itemshop.c b/gmsv/npc/npc_itemshop.c new file mode 100644 index 0000000..86b11b8 --- /dev/null +++ b/gmsv/npc/npc_itemshop.c @@ -0,0 +1,1385 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "pet_skill.h" +#include "npc_eventaction.h" +#include "readmap.h" +#include "log.h" +#include "family.h" + +#define MAXSHOPITEM 33 +static void NPC_ItemShop_selectWindow( int meindex, int talker, int num,int select); +void NPC_ItemShop_BuyMain(int meindex,int talker,int before ); + +#ifdef _ADD_FAMILY_TAX // WON ADD 增加庄园税收 + +#else +void NPC_GetItemList(char *argstr,char * argtoken2); + #ifdef _NEW_MANOR_LAW + void NPC_ItemStrStr(int itemID,double rate,char *name,char *token2,int iCostFame,int iChangeItemCost); + #else + void NPC_ItemStrStr(int itemID,double rate,char *name,char *token2); + #endif +#endif + +BOOL NPC_SetNewItem(int meindex,int talker,char *data); +BOOL NPC_SellNewItem(int meindex,int talker,char *data); + +void NPC_ItemShop_Menu(int meindex,int talker); + +#ifdef _NPC_SHOPALTER01 +int NPC_GetLimtItemList(int talker,char *argstr,char *token2,int sell, char* sLimt); //sLimt存放玩家的物品可否卖出,以及价钱,格式为 0|100|10|0|1|50|10|0|1|80|10|0| ,0:可卖,1:不可卖,再来数值为价钱,10为table,0为堆叠 +#else +int NPC_GetLimtItemList(int talker,char *argstr,char *token2,int sell); +#endif + +void NPC_ItemShop_SellMain(int meindex,int talker,int select); +int NPC_GetSellItemList(int itemindex,int flg,char *argstr,char *argtoken,int select,int sell); +#ifdef _NEW_MANOR_LAW +BOOL NPC_AddItemBuy(int meindex, int talker,int itemID,int kosuu,double rate,int iCostFame,int iChangeItemCost); +#else +BOOL NPC_AddItemBuy(int meindex, int talker,int itemID,int kosuu,double rate); +#endif +int NPC_SellItemstrsStr(int itemindex,int flg,double rate,char *argtoken,int select,int sell); +void NPC_LimitItemShop(int meindex,int talker,int select); +void NPC_ExpressmanCheck(int meindex,int talker); + +enum{ + NPC_SHOP_WORK_NO = CHAR_NPCWORKINT1, + NPC_SHOP_WORK_EV = CHAR_NPCWORKINT2, + NPC_SHOP_WORK_EXPRESS = CHAR_NPCWORKINT3, +}; + + + +typedef struct { + char arg[32]; + int type; +}NPC_Shop; + + +static NPC_Shop TypeTable[] = { + { "FIST", 0 }, //拳 + { "AXE", 1 }, //斧 + { "CLUB", 2 }, //棍棒 + { "SPEAR", 3}, //矛 + { "BOW", 4}, //弓 + { "SHIELD", 5}, //盾 + { "HELM", 6 }, //头盔 + { "ARMOUR", 7 }, //盔甲 + { "BRACELET", 8}, //手镯 + { "ANCLET", 9 }, //踝饰 + { "NECKLACE", 10}, //项 + { "RING", 11}, //戒指 + { "BELT", 12}, //腰带 + { "EARRING", 13}, //耳环 + { "NOSERING", 14}, //鼻环 + { "AMULET", 15}, //护身符 + { "OTHER", 16}, + { "BOOMERANG", 17}, //回力标 + { "BOUNDTHROW", 18}, + { "BREAKTHROW", 19}, //投掷物 +#ifdef _ITEM_TYPETABLE + { "DISH", 20}, + { "METAL", 21}, + { "JEWEL", 22}, + { "WARES", 23}, + { "WBELT", 24}, + { "WSHIELD", 25}, + { "WSHOES", 26}, + { "WGLOVE", 27}, + { "ANGELTOKEN", 28}, + { "HEROTOKEN", 29}, +#endif + { "ACCESSORY", 30}, //配件 + { "OFFENCE", 40}, //攻击 + { "DEFENCE", 50}, //防御 + +}; + +BOOL NPC_ItemShopInit( int meindex ) +{ + + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEITEMSHOP ); + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("GetArgStrErr"); + return FALSE; + } + if(strstr(argstr,"LIMITSHOP") != NULL) { + CHAR_setWorkInt( meindex, NPC_SHOP_WORK_NO, 1); + }else{ + CHAR_setWorkInt( meindex, NPC_SHOP_WORK_NO, 0); + } + if(strstr( argstr, "EVENT") != NULL) { + CHAR_setWorkInt( meindex, NPC_SHOP_WORK_EV, 1); + }else{ + CHAR_setWorkInt( meindex, NPC_SHOP_WORK_EV, 0); + } + if(strstr( argstr, "EXPRESS") != NULL) { + CHAR_setWorkInt( meindex, NPC_SHOP_WORK_EXPRESS, 1); + }else{ + CHAR_setWorkInt( meindex, NPC_SHOP_WORK_EXPRESS, 0); + } + + return TRUE; +} + +void NPC_ItemShopTalked( int meindex , int talker , char *szMes ,int color ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff[1024]; + char buf2[256]; + char token[1024]; + int i = 1; + BOOL sellonlyflg = FALSE; + char sellmsg[1024]; + + if( CHAR_getInt( talker , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + + if(NPC_Util_isFaceToFace( meindex, talker, 2) == FALSE) {//交谈时检查是否面对面 + if( NPC_Util_CharDistance( talker, meindex ) > 1) return; //若距离大於1跳出 + } + + //取得npc买卖设定档内的内容,若为NULL,则错误 + if(NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL){ + print("itemshopGetArgStrErr"); + return; + } + + //取得NPC只能卖的讯息 + if( NPC_Util_GetStrFromStrWithDelim( argstr, "sellonly_msg", token, sizeof( token)) != NULL){ + sellonlyflg = TRUE; //NPC不能买玩家的东西 + strcpysafe(sellmsg, sizeof( sellmsg), token);//例如:sellmsg的值可能是->并不是专门收买东西的店。 + } + + //取得玩家买东西的指令. buff为一串买东西指令的字串,例如:买,购买,感谢您,kau,buy,menu,谢谢,买东西,当玩家打出这些字句时,就可以买东西了 + if( NPC_Util_GetStrFromStrWithDelim( argstr, "buy_msg", buff, sizeof( buff)) != NULL ){ + while(getStringFromIndexWithDelim(buff,",",i,buf2,sizeof(buf2)) != FALSE ){ + i++; //若买东西的指令有8个,i就会加到8 + if( strstr( szMes, buf2) != NULL) { + if( CHAR_getWorkInt( meindex, NPC_SHOP_WORK_EV) == 0) { + if( CHAR_getWorkInt( meindex, NPC_SHOP_WORK_NO) == 1) { + if( sellonlyflg ) { + NPC_ItemShop_selectWindow( meindex, talker, 3, -1); + return; + } + }else{ + NPC_ItemShop_selectWindow( meindex, talker, 1, -1); + return; + } + }else{ + if(CHAR_getWorkInt( meindex, NPC_SHOP_WORK_NO) == 1) { + if( sellonlyflg) { + NPC_ItemShop_selectWindow( meindex, talker, 3, -1); + return; + } + }else{ + NPC_ItemShop_selectWindow( meindex, talker, 1, -1); + return; + } + return; + } + } + } + } + i=1; + + //取得玩家卖东西的指令. buff为一串卖东西指令的字串,例如:卖东西,卖,sell,uru 当玩家打出这些字句时,就可以卖东西了 + if( NPC_Util_GetStrFromStrWithDelim( argstr, "sell_msg", buff, sizeof( buff)) != NULL ){ + while( getStringFromIndexWithDelim(buff,",", i,buf2,sizeof(buf2)) != FALSE ){ + i++; + if(strstr(szMes,buf2) != NULL) { + NPC_ItemShop_selectWindow( meindex, talker, 2, -1); + return; + } + } + } + i = 1; + + //其它讯息 + if( NPC_Util_GetStrFromStrWithDelim( argstr, "other_msg", buff, sizeof( buff)) != NULL ){ + while(getStringFromIndexWithDelim( buff, ",", i, buf2, sizeof( buf2)) != FALSE ){ + i++; + if(strstr(szMes,buf2) != NULL) { + if(NPC_Util_GetStrFromStrWithDelim( argstr, "hint_msg", + token, sizeof( token)) != NULL) + { + CHAR_talkToCli( talker, meindex, token, CHAR_COLORWHITE); + return; + } + } + } + } + + if(CHAR_getWorkInt( meindex, NPC_SHOP_WORK_NO) == 1) { + if(CHAR_getWorkInt( meindex, NPC_SHOP_WORK_EV) == 1) { + if( sellonlyflg) { + CHAR_talkToCli( talker, meindex, sellmsg, CHAR_COLORWHITE); + return; + } + }else{ + if( sellonlyflg) { + NPC_ItemShop_selectWindow( meindex, talker, 3, -1); + return; + } + } + }else{ + if(CHAR_getWorkInt( meindex, NPC_SHOP_WORK_EV) == 1) { + if( sellonlyflg) { + CHAR_talkToCli( talker, meindex, sellmsg, CHAR_COLORWHITE); + return; + } + }else{ + if(CHAR_getWorkInt( meindex, NPC_SHOP_WORK_EXPRESS) == 1) { + NPC_ExpressmanCheck( meindex, talker); + }else{ + NPC_ItemShop_selectWindow( meindex, talker, 0, -1); + } + } + } + +} + +static void NPC_ItemShop_selectWindow( int meindex, int talker, int num,int select) +{ + switch( num) { + case 0: + CHAR_send_P_StatusString( talker, CHAR_P_STRING_GOLD);//传送金钱,若100元 送出去的资料格式可能为 P8Nz2|100| + + if(CHAR_getWorkInt( meindex, NPC_SHOP_WORK_EXPRESS) == 1 ) { + if(CHAR_getWorkInt( meindex, NPC_SHOP_WORK_NO) ==0 ) { + NPC_ExpressmanCheck( meindex, talker);//长毛象快递 + } + }else if(CHAR_getWorkInt( meindex, NPC_SHOP_WORK_NO) == 1) { + + }else{ + NPC_ItemShop_Menu( meindex, talker);//选择(买,卖,离开)的小视窗 + } + break; + + case 1://进入买视窗 + CHAR_sendStatusString( talker,"I");//传送玩家身上所有的道具给Client + NPC_ItemShop_BuyMain( meindex, talker, select); + break; + + case 2://进入卖视窗 + CHAR_sendStatusString( talker,"I"); + NPC_ItemShop_SellMain( meindex, talker, select); + break; + + case 3: + NPC_LimitItemShop( meindex, talker, select); + break; + + } +} + +void NPC_ItemShopWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 3) { + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return; + } + + makeStringFromEscaped( data); + + switch( seqno){ + + case CHAR_WINDOWTYPE_WINDOWITEMSHOP_STARTMSG: + if(atoi( data) == 1 ) NPC_ItemShop_selectWindow(meindex, talkerindex, 1, -1); + if(atoi( data) == 2) NPC_ItemShop_selectWindow(meindex, talkerindex, 2, -1); + if(atoi( data) == 3) return;/*--窒手仄卅中--*/ + break; + case CHAR_WINDOWTYPE_WINDOWITEMSHOP_BUY_MSG: + if(NPC_SetNewItem(meindex , talkerindex, data) == TRUE) { + NPC_ItemShop_selectWindow( meindex, talkerindex, 1, 0); + }else{ + NPC_ItemShop_selectWindow( meindex, talkerindex ,0, -1); + } + + break; + case CHAR_WINDOWTYPE_WINDOWITEMSHOP_SELL_MSG: + if(NPC_SellNewItem(meindex , talkerindex, data) == TRUE) { + NPC_ItemShop_selectWindow( meindex, talkerindex, 2, 0); + + }else{ + NPC_ItemShop_selectWindow( meindex, talkerindex, 0, -1); + } + + break; + + case CHAR_WINDOWTYPE_WINDOWITEMSHOP_LIMIT: + if(select == WINDOW_BUTTONTYPE_YES) { + NPC_ItemShop_selectWindow( meindex, talkerindex ,2, -1); + + }else if(select == WINDOW_BUTTONTYPE_NO) { + return; + }else if(select == WINDOW_BUTTONTYPE_OK) { + NPC_ItemShop_selectWindow( meindex, talkerindex, 2, -1); + } + break; + + case CHAR_WINDOWTYPE_WINDOWITEMSHOP_EXPRESS: + if(atoi(data) == 2) { + NPC_ItemShop_selectWindow( meindex, talkerindex, 1, -1); + }else if(atoi( data) == 4) { + NPC_ItemShop_selectWindow( meindex, talkerindex, 2, -1); + } + } +} + +void NPC_ItemShop_BuyMain(int meindex,int talker,int before ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[NPC_UTIL_GETARGSTR_BUFSIZE]; + int fd = getfdFromCharaIndex( talker); + + char token2[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff2[256]; + char buff[256]; + +#ifdef _NPC_SHOPALTER01 + char sLimt[1024]; //存放玩家物品可否卖出及价钱 + char tokentemp[NPC_UTIL_GETARGSTR_BUFSIZE]; //与token功能相同 + float fdata; //转换sell_rate为数值 +#endif + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("itemshop_GetArgStr_Err"); + return; + } +#ifdef _ADD_STATUS_2 + sprintf(token,"FAME|%d",CHAR_getInt(talker,CHAR_FAME)/100); + lssproto_S2_send(fd,token); +#endif + if(before != -1) { + sprintf(token,"0|0"); + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_ITEMSHOPMAIN, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_BUY_MSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + }else{ + + NPC_Util_GetStrFromStrWithDelim( argstr, "main_msg", buff, sizeof( buff)); + NPC_Util_GetStrFromStrWithDelim( argstr, "buy_main", buff2, sizeof( buff2)); + + sprintf(token,"0|1|%d|%s|%s|%s|", CHAR_WINDOWTYPE_WINDOWITEMSHOP_STARTMSG, + CHAR_getChar( meindex, CHAR_NAME), buff, buff2); + + NPC_Util_GetStrFromStrWithDelim( argstr, "what_msg", buff, sizeof( buff)); + NPC_Util_GetStrFromStrWithDelim( argstr, "level_msg", buff2, sizeof( buff)); + + snprintf( token2, sizeof( token2), "%s|%s", buff, buff2); + + strncat( token, token2, sizeof( token)); + + NPC_Util_GetStrFromStrWithDelim( argstr, "realy_msg", buff, sizeof( buff)); + NPC_Util_GetStrFromStrWithDelim( argstr, "itemfull_msg", buff2, sizeof( buff2)); + + sprintf( token2, "|%s|%s", buff, buff2); + strncat(token , token2,sizeof(token)); + strcpy(token2, "|"); + +#ifdef _ADD_FAMILY_TAX // WON ADD 增加庄园税收 + +#else + NPC_GetItemList( argstr, token2); +#endif + strncat( token, token2, sizeof( token)); + } + +#ifdef _NPC_SHOPALTER01 + sprintf(tokentemp,"%s",""); + sprintf(sLimt,"%s",""); + NPC_GetLimtItemList( talker, argstr, tokentemp, -1, sLimt);//详细玩家要卖出的道具资料 + fdata = atof(NPC_Util_GetStrFromStrWithDelim( argstr, "sell_rate", buff, sizeof( buff))); + fdata *= 100; //原本资料为小数,Client端处理的为整数,所以乘以100 + sprintf(token,"%suseritem|%d%s", token, (int)fdata, sLimt);//原本的字串後再加上sell_rate,与sLimt资料 +#endif + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_ITEMSHOPMAIN, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_BUY_MSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + +} + +#ifdef _ADD_FAMILY_TAX // WON ADD 增加庄园税收 + +#else +void NPC_GetItemList(char *argstr,char *argtoken) +#endif +{ + int i = 1; + int tmp; + char *name ; + char buff2[256]; +#ifdef _NEW_MANOR_LAW + char buff3[NPC_UTIL_GETARGSTR_LINEMAX]; + char buff4[256]; + char buff5[NPC_UTIL_GETARGSTR_LINEMAX]; + char buff6[256]; + int iCostFame = 0; + int iChangeItemCost = 0; +#endif + char buff[NPC_UTIL_GETARGSTR_LINEMAX]; + char token2[NPC_UTIL_GETARGSTR_BUFSIZE]; + double rate = 1.0; + int loopcnt = 0; + + if(NPC_Util_GetStrFromStrWithDelim( argstr, "buy_rate", buff2, sizeof( buff2)) + != NULL){ + rate = atof( buff2); + } +#ifdef _NEW_MANOR_LAW + memset(buff3,0,sizeof(buff3)); + memset(buff5,0,sizeof(buff5)); + if(NPC_Util_GetStrFromStrWithDelim(argstr,"CostFame",buff3,sizeof(buff3)) == NULL) iCostFame = -1; + if(NPC_Util_GetStrFromStrWithDelim(argstr,"ChangeItemCost",buff5,sizeof(buff5)) == NULL) iChangeItemCost = -1; +#endif + if( NPC_Util_GetStrFromStrWithDelim( argstr, "ItemList", buff, sizeof( buff)) != NULL ){ + while( getStringFromIndexWithDelim(buff,",",i,buff2,sizeof(buff2)) !=FALSE ) { +#ifdef _NEW_MANOR_LAW + if(iCostFame > -1){ + if(getStringFromIndexWithDelim(buff3,",",i,buff4,sizeof(buff4)) != FALSE) iCostFame = atoi(buff4); + } + if(iChangeItemCost > -1){ + if(getStringFromIndexWithDelim(buff5,",",i,buff6,sizeof(buff6)) != FALSE) iChangeItemCost = atoi(buff6); + } +#endif + i++; + if(strstr( buff2, "-") == NULL) { + name = ITEM_getNameFromNumber( atoi(buff2)); + if(name == NULL) continue; + loopcnt++; + if(loopcnt == MAXSHOPITEM) break; + +#ifdef _ADD_FAMILY_TAX // WON ADD 增加庄园税收 + +#else + #ifdef _NEW_MANOR_LAW + NPC_ItemStrStr( atoi( buff2), rate, name, token2,iCostFame,iChangeItemCost); + #else + NPC_ItemStrStr( atoi( buff2), rate, name, token2); + #endif +#endif + strncat( argtoken, token2, sizeof(token2)); + }else{ + int start; + int end; + getStringFromIndexWithDelim( buff2, "-", 1, token2, sizeof(token2)); + start = atoi( token2); + getStringFromIndexWithDelim( buff2, "-", 2 ,token2, sizeof(token2)); + end = atoi( token2); + if(start > end){ + tmp = start; + start = end; + end = tmp; + } + end++; + for(; start < end ; start++ ) { + /*--引内 蟆 --*/ + + name = ITEM_getNameFromNumber( start ); + if(name == NULL) continue; + loopcnt++; + if(loopcnt == MAXSHOPITEM) break; + +#ifdef _ADD_FAMILY_TAX // WON ADD 增加庄园税收 + +#else + #ifdef _NEW_MANOR_LAW + NPC_ItemStrStr( start, rate, name, token2,iCostFame,iChangeItemCost); + #else + NPC_ItemStrStr( start, rate, name, token2); + #endif +#endif + strncat( argtoken, token2, sizeof(token2)); + } + } + } + } +} + +#ifdef _ADD_FAMILY_TAX // WON ADD 增加庄园税收 + +#else + #ifdef _NEW_MANOR_LAW + void NPC_ItemStrStr(int itemID,double rate,char *name,char *token2,int iCostFame,int iChangeItemCost) + #else + void NPC_ItemStrStr(int itemID,double rate,char *name,char *token2) + #endif +#endif +{ + + int gold; + int level; + int graNo; + char info[1024]; + char escape[256]; + +#ifdef _ADD_FAMILY_TAX // WON ADD 增加庄园税收(改九大庄园时要修改) + +#else + #ifdef _NEW_MANOR_LAW + if(iChangeItemCost > -1) gold = iChangeItemCost; + else + #endif + gold = ITEM_getcostFromITEMtabl( itemID); +#endif + level = ITEM_getlevelFromITEMtabl( itemID); + graNo = ITEM_getgraNoFromITEMtabl( itemID); + strcpy(escape,ITEM_getItemInfoFromNumber( itemID)); + gold=(int)(gold * rate); + + makeEscapeString( escape, info, sizeof( info)); + makeEscapeString( name, escape, sizeof( escape)); +#ifdef _NEW_MANOR_LAW + sprintf(token2,"%s|0|%d|%d|%d|%s|%d|",escape,level,gold,graNo,info,iCostFame < 0 ? -1:iCostFame/100); +#else + sprintf( token2, "%s|0|%d|%d|%d|%s|", escape, level, gold, graNo, info); +#endif +} + +BOOL NPC_SetNewItem(int meindex,int talker,char *data) +{ + + char buf[1024]; + char buff2[128]; +#ifdef _NEW_MANOR_LAW + char buff3[1024]; + char buff4[128]; + char buff5[1024]; + char buff6[128]; + int iCostFame = 0; + int iChangeItemCost = 0; +#endif + int i = 1, j = 1; + int select; + int kosuu = 0; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + double rate = 1.0; + int gold = 0; + int kosuucnt = 0; + int itemindex; + + /*--忒匀化五凶犯□正毛本伊弁玄午蜊醒卞坌荸--*/ + getStringFromIndexWithDelim( data, "|", 1, buf, sizeof( buf)); + select = atoi(buf); + if(select == 0) return FALSE; + getStringFromIndexWithDelim( data, "|", 2, buf, sizeof( buf)); + kosuu = atoi(buf); + if( kosuu <= 0 ) return FALSE; + + /*--蜊醒及民尼永弁 癫卞蝈 月井"-*/ + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE ; i++ ) { + itemindex = CHAR_getItemIndex( talker , i ); + if( !ITEM_CHECKINDEX( itemindex) ) { + kosuucnt++; + } + } + + /*--忒匀化 凶蜊醒及 互 端及蜊醒 扔□田础 方曰聂中午云井仄中及匹--*/ + /*--扔□田□础及 毛 木月--*/ + if( kosuucnt < kosuu) kosuu = kosuucnt; + + /*--未夫及桦宁反巨仿□--*/ + if(kosuucnt == 0 ) return FALSE; + + i = 1; + + /*--云饕及白央奶伙 中坭反白央奶伙互钒仃卅井匀凶午五反蔽 --*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("shop_GetArgStr_Err"); + return FALSE; + } + + /*---伊□玄毛潸 卅仃木壬1.0)-*/ + if(NPC_Util_GetStrFromStrWithDelim( argstr, "buy_rate", buf, sizeof( buf)) != NULL) { + rate= atof( buf); + } + +#ifdef _NEW_MANOR_LAW + memset(buff3,0,sizeof(buff3)); + memset(buff5,0,sizeof(buff5)); + if(NPC_Util_GetStrFromStrWithDelim(argstr,"CostFame",buff3,sizeof(buff3)) == NULL) iCostFame = -1; + if(NPC_Util_GetStrFromStrWithDelim(argstr,"ChangeItemCost",buff5,sizeof(buff5)) == NULL) iChangeItemCost = -1; +#endif + + /*--失奶 丞及馨笛毛垫丹午仇欠-*/ + if( NPC_Util_GetStrFromStrWithDelim( argstr, "ItemList", buf, sizeof( buf)) != NULL ){ + while(getStringFromIndexWithDelim(buf , "," , j, buff2, sizeof(buff2)) != FALSE ){ +#ifdef _NEW_MANOR_LAW + if(iCostFame > -1){ + if(getStringFromIndexWithDelim(buff3,",",j,buff4,sizeof(buff4)) != FALSE) iCostFame = atoi(buff4); + } + if(iChangeItemCost > -1){ + if(getStringFromIndexWithDelim(buff5,",",j,buff6,sizeof(buff6)) != FALSE) iChangeItemCost = atoi(buff6); + } +#endif + j++; + /*-- "-"互殖引木化中月井升丹井--*/ + if(strstr( buff2, "-") == NULL) { + if( ITEM_getcostFromITEMtabl(atoi(buff2)) !=-1) { + if ( i == select) { + /*---失奶 丞及综岳---*/ + /*--蜊醒坌综岳--*/ +#ifdef _NEW_MANOR_LAW + if(NPC_AddItemBuy(meindex, talker,atoi(buff2),kosuu,rate,iCostFame,iChangeItemCost) != TRUE) +#else + if(NPC_AddItemBuy(meindex, talker,atoi(buff2),kosuu,rate) != TRUE) +#endif + { + return FALSE; + } + return TRUE; + } + i++; + } + }else{ + /*--失奶 丞互 15-25 及溥匹霜日木凶桦宁--*/ + int start; + int end; + + /* "-"匹嗉濠日木凶铵户及醒袄午 及醒袄毛潸 --*/ + getStringFromIndexWithDelim( buff2, "-", 1, argstr, sizeof(argstr)); + start = atoi( argstr); + getStringFromIndexWithDelim( buff2, "-", 2 ,argstr, sizeof(argstr)); + end = atoi( argstr); + end++; + + /*-- 寞互菅卞卅匀化中凶日} 木赘尹月**/ + if(start > end){ + gold = start; + start = end; + end = gold; + } + + /*--"-"匹嗉濠日木凶坌及失奶 丞毛树 毛 月--*/ + for(; start < end ; start++ ) { + if( ITEM_getcostFromITEMtabl( start) != -1) { + if ( i == select) { + /*---失奶 丞及综岳---*/ + /*--蜊醒坌综岳--*/ +#ifdef _NEW_MANOR_LAW + if(NPC_AddItemBuy(meindex, talker, start, kosuu, rate,iCostFame,iChangeItemCost) != TRUE) +#else + if(NPC_AddItemBuy(meindex, talker, start, kosuu, rate) != TRUE) +#endif + { + return FALSE; + } + return TRUE; + } + i++; + } + } + } + } + } + + return FALSE; + +} + +/*--------------------------------------------- + *失奶 丞及馨笛毛垫丹 + *--------------------------------------------*/ +#ifdef _NEW_MANOR_LAW +BOOL NPC_AddItemBuy(int meindex, int talker,int itemID,int kosuu,double rate,int iCostFame,int iChangeItemCost) +#else +BOOL NPC_AddItemBuy(int meindex, int talker,int itemID,int kosuu,double rate) +#endif +{ + + int itemindex; + int i; + int gold; + int ret; + int maxgold; +#ifdef _NEW_MANOR_LAW + int iTotalCostFame = -1; +#endif +#ifdef _ADD_FAMILY_TAX // WON ADD 增加庄园税收(改九大庄园时要修改) + +#else + #ifdef _NEW_MANOR_LAW + if(iChangeItemCost > -1) gold = iChangeItemCost; + else + #endif + gold = ITEM_getcostFromITEMtabl( itemID); + gold = (int)(gold * rate); +#endif + + maxgold = gold * kosuu; + if(CHAR_getInt( talker, CHAR_GOLD) < maxgold ) return FALSE; +#ifdef _NEW_MANOR_LAW + if(iCostFame > 0){ + iTotalCostFame= iCostFame * kosuu; + if(CHAR_getInt(talker,CHAR_FAME) < iTotalCostFame) return FALSE; + } +#endif + + + for(i = 0 ; i < kosuu ; i++){ + itemindex = ITEM_makeItemAndRegist( itemID); + + if(itemindex == -1) return FALSE; + ret = CHAR_addItemSpecificItemIndex( talker, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + print( "npc_itemshop.c: additem error itemindex[%d]\n", itemindex); + ITEM_endExistItemsOne( itemindex); + return FALSE; + } + CHAR_sendItemDataOne( talker, ret); + } + CHAR_DelGold( talker, maxgold); +#ifdef _NEW_MANOR_LAW + if(iTotalCostFame > 0){ + CHAR_setInt(talker,CHAR_FAME,CHAR_getInt(talker,CHAR_FAME) - iTotalCostFame); + if(CHAR_getInt(talker,CHAR_FMINDEX) != -1 && (strcmp(CHAR_getChar(talker,CHAR_FMNAME),""))){ + int fd = getfdFromCharaIndex(talker); + char buf[256]; + sprintf(buf,"%d",CHAR_getInt(talker,CHAR_FAME)); + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(talker,CHAR_FMNAME), + CHAR_getInt(talker,CHAR_FMINDEX), + CHAR_getWorkInt(talker,CHAR_WORKFMINDEXI), + FM_FIX_FAME,buf,"", + CHAR_getWorkInt(talker,CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(fd)); + LogFMFameShop(CHAR_getChar(talker,CHAR_FMNAME), + CHAR_getChar(talker,CHAR_CDKEY), + CHAR_getChar(talker,CHAR_NAME), + CHAR_getInt(talker,CHAR_FAME), + iTotalCostFame); + } + } +#endif + //CHAR_send_P_StatusString( talker, CHAR_P_STRING_GOLD); + return TRUE; + +} + +//选择 (买,卖,出去) 的小视窗 +void NPC_ItemShop_Menu(int meindex,int talker) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[NPC_UTIL_GETARGSTR_LINEMAX]; + char buff[256]; + int fd = getfdFromCharaIndex( talker); + +#ifdef _NPC_SHOPALTER01 + char sLimt[1024]; //存放玩家物品可否卖出及价钱 + char tokentemp[NPC_UTIL_GETARGSTR_BUFSIZE]; //与token功能相同 + float fdata; //转换sell_rate为数值 +#endif + + //argstr取得整个设定档的讯息: 例如->buy_rate:1.0|sell_rate:0.2|buy_msg:买,购买,感谢您,kau,buy............. (中间的分格号是读入时加入的) + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("shop_GetArgStr_Err"); + return; + } + + //token为视窗上面的title文字 例如: 萨姆吉尔的防具店|欢迎光临 + NPC_Util_GetStrFromStrWithDelim( argstr, "main_msg", buff, sizeof( buff)); +#ifdef _NEW_MANOR_LAW + snprintf(token, sizeof(token),"%s|%s|%d",CHAR_getChar(meindex,CHAR_NAME),buff,CHAR_getInt(talker,CHAR_FAME)/100); +#else + snprintf(token, sizeof(token),"%s|%s",CHAR_getChar( meindex, CHAR_NAME), buff); +#endif + +#ifdef _NPC_SHOPALTER01 + sprintf(tokentemp,"%s",""); + sprintf(sLimt,"%s",""); + NPC_GetLimtItemList( talker, argstr, tokentemp, -1, sLimt);//详细玩家要卖出的道具资料 + fdata = atof(NPC_Util_GetStrFromStrWithDelim( argstr, "sell_rate", buff, sizeof( buff))); + fdata *= 100; //原本资料为小数,Client端处理的为整数,所以乘以100 + sprintf(token,"%suseritem|%d%s", token, (int)fdata, sLimt);//原本的字串後再加上sell_rate,与sLimt资料 +#endif + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_ITEMSHOPMENU, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_STARTMSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + +} + +void NPC_ItemShop_SellMain(int meindex,int talker,int before) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[NPC_UTIL_GETARGSTR_BUFSIZE]; + int fd = getfdFromCharaIndex( talker); + + //取得npc设定资料 + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("shop_GetArgStr_Err"); + return; + } + +#ifdef _ADD_STATUS_2 + sprintf(token,"FAME|%d",CHAR_getInt(talker,CHAR_FAME)/100); + lssproto_S2_send(fd,token); +#endif + + if(before != -1) { + sprintf(token,"1|0"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_ITEMSHOPMAIN + +CHAR_getWorkInt(meindex,NPC_SHOP_WORK_NO), + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_SELL_MSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + }else{ + + char token2[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff2[256]; + char buff[256]; + + NPC_Util_GetStrFromStrWithDelim( argstr, "main_msg", buff, sizeof( buff)); + NPC_Util_GetStrFromStrWithDelim( argstr, "sell_main", buff2, sizeof( buff)); + sprintf( token, "1|1|%d|%s|%s|%s|", CHAR_WINDOWTYPE_WINDOWITEMSHOP_STARTMSG, + CHAR_getChar( meindex, CHAR_NAME), buff, buff2); + + NPC_Util_GetStrFromStrWithDelim( argstr, "stone_msg", buff, sizeof( buff)); + + if(CHAR_getWorkInt(meindex,NPC_SHOP_WORK_EXPRESS) == 1 ) { + NPC_Util_GetStrFromStrWithDelim( argstr, "exrealy_msg", buff2, sizeof(buff2)); + }else{ + NPC_Util_GetStrFromStrWithDelim( argstr, "realy_msg", buff2, sizeof( buff2)); + } + sprintf( token2,"%s|%s|", buff, buff2); +#ifdef _NPC_SHOPALTER01 + NPC_GetLimtItemList( talker,argstr, token2, -1, NULL);//详细玩家要卖出的道具资料 +#else + NPC_GetLimtItemList( talker,argstr, token2, -1);//详细玩家要卖出的道具资料 +#endif + strncat( token, token2, sizeof( token)); + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_ITEMSHOPMAIN+ + CHAR_getWorkInt(meindex,NPC_SHOP_WORK_NO), + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_SELL_MSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + } +} +#ifdef _NPC_SHOPALTER01 +int NPC_GetLimtItemList(int talker, char *argstr, char* token2,int sell, char* sLimt)//sLimt:玩家可卖物品的字串 +#else +int NPC_GetLimtItemList(int talker, char *argstr, char* token2,int sell) +#endif +{ + + char token[NPC_UTIL_GETARGSTR_LINEMAX]; + char buff[NPC_UTIL_GETARGSTR_LINEMAX]; + char token3[NPC_UTIL_GETARGSTR_LINEMAX]; + int k = 0 , i = 1 , j = 0; + int imax; + int itemtype = 0; + int itemindex; + int okflg = 0; + char buf[256]; + int flg=0; + int cost; + +#ifdef _NPC_SHOPALTER01 + char sbuf[256]; //取得sLimt前,用sbuf取得每一项资料,再存入sLimt +#endif + + + if(sell == -1 ){ + i = CHAR_STARTITEMARRAY; + imax = CHAR_MAXITEMHAVE; + flg = -1; + }else{ + i= sell; + imax= sell + 1; + flg = 1; + } + + for( ; i < imax ; i++ ){ + okflg=0; + itemindex = CHAR_getItemIndex( talker , i ); + + if( ITEM_CHECKINDEX( itemindex) ){ + if( NPC_Util_GetStrFromStrWithDelim( argstr,"LimitItemType", buff, sizeof( buff)) != NULL ){ + k = 1; + while(getStringFromIndexWithDelim(buff , "," , k, token, sizeof(token)) != FALSE ){ +#ifdef _ITEM_TYPETABLE + int cmpmaxitem = sizeof(TypeTable)/sizeof(TypeTable[0]); +#endif + k++; +#ifdef _ITEM_TYPETABLE + for(j = 0 ; j < cmpmaxitem ; j++){ +#else + for(j = 0 ; j < ITEM_CATEGORYNUM+3 ; j++){ +#endif + if(strcmp( TypeTable[ j].arg , token) == 0 ) { + itemtype = TypeTable[ j].type; + if(ITEM_getInt(itemindex,ITEM_TYPE) == itemtype) { + cost = NPC_GetSellItemList(itemindex,0,argstr,token3,i,sell); + if(cost != -1) return cost; + strncat( token2, token3, sizeof( token3)); +#ifdef _NPC_SHOPALTER01 + print("Change->itemtype = %d",itemtype); + print("Change->token2:%s\n",token2); + print("Change->token3:%s\n",token3); + if( sLimt ) + { + if( getStringFromIndexWithDelim(token3 , "|" , 2, sbuf, sizeof( sbuf)) ){ + sprintf(sLimt,"%s|%s",sLimt,sbuf); + if( getStringFromIndexWithDelim(token3 , "|" , 3, sbuf, sizeof( sbuf)) ){ + sprintf(sLimt,"%s|%s",sLimt,sbuf); + if( getStringFromIndexWithDelim(token3 , "|" , 6, sbuf, sizeof( sbuf)) ){ + sprintf(sLimt,"%s|%s",sLimt,sbuf); + if( getStringFromIndexWithDelim(token3 , "|" , 7, sbuf, sizeof( sbuf)) ){ + sprintf(sLimt,"%s|%s",sLimt,sbuf); + } + } + } + } + } +#endif + okflg = 1; + }else if(itemtype == 30){ + if( 8 <= ITEM_getInt(itemindex,ITEM_TYPE) + && (ITEM_getInt(itemindex,ITEM_TYPE) <= 15) ){ + cost = NPC_GetSellItemList(itemindex,0,argstr,token3,i,sell); + if(cost != -1) return cost; + strncat(token2,token3,sizeof(token3)); +#ifdef _NPC_SHOPALTER01 + print("Change->itemtype = 30"); + print("Change->token2:%s\n",token2); + print("Change->token3:%s\n",token3); + if( sLimt ) + { + if( getStringFromIndexWithDelim(token3 , "|" , 2, sbuf, sizeof( sbuf)) ){ + sprintf(sLimt,"%s|%s",sLimt,sbuf); + if( getStringFromIndexWithDelim(token3 , "|" , 3, sbuf, sizeof( sbuf)) ){ + sprintf(sLimt,"%s|%s",sLimt,sbuf); + if( getStringFromIndexWithDelim(token3 , "|" , 6, sbuf, sizeof( sbuf)) ){ + sprintf(sLimt,"%s|%s",sLimt,sbuf); + if( getStringFromIndexWithDelim(token3 , "|" , 7, sbuf, sizeof( sbuf)) ){ + sprintf(sLimt,"%s|%s",sLimt,sbuf); + } + } + } + } + } +#endif + okflg = 1; + } + }else if(itemtype == 40){ + if(( 0 <= ITEM_getInt(itemindex,ITEM_TYPE) + && (ITEM_getInt(itemindex,ITEM_TYPE) <= 4)) + || (17 <= ITEM_getInt(itemindex,ITEM_TYPE) + && (ITEM_getInt(itemindex,ITEM_TYPE) <= 19))) { + cost = NPC_GetSellItemList(itemindex,0,argstr,token3,i,sell); + if(cost != -1) return cost; + strncat(token2,token3,sizeof(token3)); +#ifdef _NPC_SHOPALTER01 + print("Change->itemtype = 40"); + print("Change->token2:%s\n",token2); + print("Change->token3:%s\n",token3); + if( sLimt ) + { + if( getStringFromIndexWithDelim(token3 , "|" , 2, sbuf, sizeof( sbuf)) ){ + sprintf(sLimt,"%s|%s",sLimt,sbuf); + if( getStringFromIndexWithDelim(token3 , "|" , 3, sbuf, sizeof( sbuf)) ){ + sprintf(sLimt,"%s|%s",sLimt,sbuf); + if( getStringFromIndexWithDelim(token3 , "|" , 6, sbuf, sizeof( sbuf)) ){ + sprintf(sLimt,"%s|%s",sLimt,sbuf); + if( getStringFromIndexWithDelim(token3 , "|" , 7, sbuf, sizeof( sbuf)) ){ + sprintf(sLimt,"%s|%s",sLimt,sbuf); + } + } + } + } + } +#endif + okflg = 1; + } + }else if(itemtype == 50){ + if( 5 <= ITEM_getInt(itemindex,ITEM_TYPE) + && (ITEM_getInt(itemindex,ITEM_TYPE) <= 7) ){ + cost = NPC_GetSellItemList(itemindex,0,argstr,token3,i,sell); + if(cost != -1) return cost; + strncat(token2,token3,sizeof(token3)); +#ifdef _NPC_SHOPALTER01 + print("Change->itemtype = 50"); + print("Change->token2:%s\n",token2); + print("Change->token3:%s\n",token3); + if( sLimt ) + { + if( getStringFromIndexWithDelim(token3 , "|" , 2, sbuf, sizeof( sbuf)) ){ + sprintf(sLimt,"%s|%s",sLimt,sbuf); + if( getStringFromIndexWithDelim(token3 , "|" , 3, sbuf, sizeof( sbuf)) ){ + sprintf(sLimt,"%s|%s",sLimt,sbuf); + if( getStringFromIndexWithDelim(token3 , "|" , 6, sbuf, sizeof( sbuf)) ){ + sprintf(sLimt,"%s|%s",sLimt,sbuf); + if( getStringFromIndexWithDelim(token3 , "|" , 7, sbuf, sizeof( sbuf)) ){ + sprintf(sLimt,"%s|%s",sLimt,sbuf); + } + } + } + } + } +#endif + okflg = 1; + } + } + break; + } + } + + if(okflg == 1) break; + } + } + if( (NPC_Util_GetStrFromStrWithDelim( argstr, "LimitItemNo", buff,sizeof( buff))!= NULL) && okflg == 0 ){ + k = 1; + while(getStringFromIndexWithDelim(buff , "," , k, token, sizeof(token)) != FALSE ){ + k++; + if(strstr( token, "-")==NULL && strcmp(token,"") != 0) { + if(ITEM_getInt(itemindex,ITEM_ID) == atoi(token)) { + cost = NPC_GetSellItemList(itemindex,0,argstr,token3,i,sell); + if(cost != -1) return cost; + strncat(token2,token3,sizeof(token3)); +#ifdef _NPC_SHOPALTER01 + print("Change->1\n"); + print("Change->token2:%s\n",token2); + print("Change->token3:%s\n",token3); + if( sLimt ) + { + if( getStringFromIndexWithDelim(token3 , "|" , 2, sbuf, sizeof( sbuf)) ){ + sprintf(sLimt,"%s|%s",sLimt,sbuf); + if( getStringFromIndexWithDelim(token3 , "|" , 3, sbuf, sizeof( sbuf)) ){ + sprintf(sLimt,"%s|%s",sLimt,sbuf); + if( getStringFromIndexWithDelim(token3 , "|" , 6, sbuf, sizeof( sbuf)) ){ + sprintf(sLimt,"%s|%s",sLimt,sbuf); + if( getStringFromIndexWithDelim(token3 , "|" , 7, sbuf, sizeof( sbuf)) ){ + sprintf(sLimt,"%s|%s",sLimt,sbuf); + } + } + } + } + } +#endif + okflg=1; + } + }else if (strstr( token, "-") != NULL){ + int start, end; + int work; + + if( getStringFromIndexWithDelim( token, "-", 1, buf, sizeof(buf)) == FALSE ) + return -1; + start = atoi( buf); + if( getStringFromIndexWithDelim( token, "-", 2 ,buf, sizeof(buf)) == FALSE ) + return -1; + end = atoi( buf); + + if(start > end){ + work = start; + start = end; + end = work; + } + + end++; + if( (start <= ITEM_getInt(itemindex,ITEM_ID)) && (ITEM_getInt(itemindex,ITEM_ID) < end) ){ + cost = NPC_GetSellItemList(itemindex,0,argstr,token3,i,sell); + if(cost != -1) return cost; + strncat(token2,token3,sizeof(token3)); +#ifdef _NPC_SHOPALTER01 + print("Change->2\n"); + print("Change->token2:%s\n",token2); + print("Change->token3:%s\n",token3); + if( sLimt ) + { + if( getStringFromIndexWithDelim(token3 , "|" , 2, sbuf, sizeof( sbuf)) ){ + sprintf(sLimt,"%s|%s",sLimt,sbuf); + if( getStringFromIndexWithDelim(token3 , "|" , 3, sbuf, sizeof( sbuf)) ){ + sprintf(sLimt,"%s|%s",sLimt,sbuf); + if( getStringFromIndexWithDelim(token3 , "|" , 6, sbuf, sizeof( sbuf)) ){ + sprintf(sLimt,"%s|%s",sLimt,sbuf); + if( getStringFromIndexWithDelim(token3 , "|" , 7, sbuf, sizeof( sbuf)) ){ + sprintf(sLimt,"%s|%s",sLimt,sbuf); + } + } + } + } + } +#endif + okflg = 1; + } + } + } + } + + if(okflg == 0) { + cost = NPC_GetSellItemList(itemindex, 1, argstr, token3, i, sell); + if(sell != -1) return -1; + strncat( token2, token3, sizeof( token3)); +#ifdef _NPC_SHOPALTER01 + print("Change->4\n"); + print("Change->token2:%s\n",token2); + print("Change->token3:%s\n",token3); + if( sLimt ) + { + if( getStringFromIndexWithDelim(token3 , "|" , 2, sbuf, sizeof( sbuf)) ){ + sprintf(sLimt,"%s|%s",sLimt,sbuf); + if( getStringFromIndexWithDelim(token3 , "|" , 3, sbuf, sizeof( sbuf)) ){ + sprintf(sLimt,"%s|%s",sLimt,sbuf); + if( getStringFromIndexWithDelim(token3 , "|" , 6, sbuf, sizeof( sbuf)) ){ + sprintf(sLimt,"%s|%s",sLimt,sbuf); + if( getStringFromIndexWithDelim(token3 , "|" , 7, sbuf, sizeof( sbuf)) ){ + sprintf(sLimt,"%s|%s",sLimt,sbuf); + } + } + } + } + } +#endif + } + + } + } + return -1; +} + + + +/*---------------------------------------------------------- + + 弁仿奶失件玄卞霜耨允月皿夫玄戊伙及综岳 + + *----------------------------------------------------------*/ +int NPC_GetSellItemList(int itemindex,int flg, char *argstr,char *argtoken,int select,int sell) +{ + char buff[256]; + double rate = 0.2; + char buff2[256]; + char buff3[64]; + int k = 1; + int cost = -1; + + if(NPC_Util_GetStrFromStrWithDelim( argstr,"special_item",buff, sizeof( buff)) != NULL){ + if(NPC_Util_GetStrFromStrWithDelim( argstr,"special_rate",buff2, sizeof( buff2)) != NULL ){ + rate = atof(buff2); + }else{ + rate = 1.2; + } + + while(getStringFromIndexWithDelim(buff , "," , k, buff2, sizeof(buff2)) !=FALSE ){ + k++; + if(strstr( buff2, "-") == NULL && strcmp(buff2,"") != 0) { + if(ITEM_getInt(itemindex,ITEM_ID) == atoi(buff2)){ + cost = NPC_SellItemstrsStr( itemindex,0, rate, argtoken,select,sell); + return cost; + } + }else if (strstr( buff2, "-") != NULL){ + int start; + int end; + int work; + getStringFromIndexWithDelim( buff2, "-", 1, buff3, sizeof(buff3)); + start = atoi( buff3); + getStringFromIndexWithDelim( buff2, "-", 2 ,buff3, sizeof(buff3)); + end = atoi( buff3); + + if(start > end){ + work = start; + start = end; + end = work; + } + end++; + if( (start <= ITEM_getInt(itemindex,ITEM_ID)) && (ITEM_getInt(itemindex,ITEM_ID) < end) ){ + cost = NPC_SellItemstrsStr( itemindex,0, rate, argtoken,select,sell); + return cost; + } + } + } + } + if( NPC_Util_GetStrFromStrWithDelim( argstr,"sell_rate",buff, sizeof( buff)) != NULL ){ + rate = atof(buff); + cost = NPC_SellItemstrsStr( itemindex, flg ,rate, argtoken,select,sell); + return cost; + } + + return cost; +} + +int NPC_SellItemstrsStr(int itemindex,int flg,double rate,char *argtoken,int select,int sell) +{ + int cost; + char escapedname[256]; + char name[256]; + char *eff; + + + cost = ITEM_getInt( itemindex, ITEM_COST); + cost = (int)(cost * rate); + + if(sell != -1) return cost; + + strcpy( escapedname, ITEM_getChar( itemindex, ITEM_SECRETNAME)); + makeEscapeString( escapedname, name, sizeof( name)); + eff=ITEM_getChar(itemindex, ITEM_EFFECTSTRING); + makeEscapeString( eff, escapedname, sizeof(escapedname)); + + + + sprintf( argtoken, +#ifdef _ITEM_PILENUMS + "%s|%d|%d|%d|%s|%d|%d|", +#else + "%s|%d|%d|%d|%s|%d|", +#endif + name, flg, cost, + ITEM_getInt( itemindex, ITEM_BASEIMAGENUMBER), + escapedname, select +#ifdef _ITEM_PILENUMS + ,ITEM_getInt( itemindex, ITEM_USEPILENUMS) +#endif + ); + + return -1; + +} + +BOOL NPC_SellNewItem(int meindex,int talker,char *data) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[256], token2[256]; + int cost, k, select, itemindex; + int MyGold, MaxGold, sellnum=1; + + MaxGold = CHAR_getMaxHaveGold( talker); + MyGold = CHAR_getInt( talker, CHAR_GOLD); + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("GetArgStrErr"); + return FALSE; + } + getStringFromIndexWithDelim(data , "|" ,1, token, sizeof( token)); + select = atoi(token); +#ifdef _ITEM_PILENUMS + getStringFromIndexWithDelim(data , "|" ,2, token, sizeof( token)); + sellnum = atoi(token); +#endif + + if( select < CHAR_STARTITEMARRAY || select >= CHAR_MAXITEMHAVE ) return FALSE; + k = select; + itemindex = CHAR_getItemIndex( talker , k); +#ifdef _NPC_SHOPALTER01 + cost = NPC_GetLimtItemList( talker,argstr, token2,select, NULL); +#else + cost = NPC_GetLimtItemList( talker,argstr, token2,select); +#endif + if( cost == -1 || (cost*sellnum)+MyGold >= MaxGold || !ITEM_CHECKINDEX( itemindex) ){ + int fd = getfdFromCharaIndex( talker); + sprintf(token,"\n\n哎呀!对不起" "\n\n对不起啊 ! 可不可以再选一次呢?" ); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_LIMIT, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return FALSE; + } +#ifdef _ITEM_PILENUMS + if( NPC_DelItem( talker, k, sellnum) == FALSE ) return FALSE; +#else + { + LogItem( + CHAR_getChar( talker, CHAR_NAME ), + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), +#endif + "Sell(卖道具)", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + + ); + } + CHAR_DelItem( talker, k); +#endif + CHAR_AddGold( talker, cost*sellnum); + CHAR_send_P_StatusString( talker, CHAR_P_STRING_GOLD); + return TRUE; +} + + + +void NPC_LimitItemShop(int meindex,int talker,int select) +{ + + int fd = getfdFromCharaIndex( talker); + char token[NPC_UTIL_GETARGSTR_LINEMAX]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024]; + + if( NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("shop_GetArgStr_Err"); + return; + } + + if(NPC_Util_GetStrFromStrWithDelim( argstr, "sellonly_msg", buf, sizeof( buf))!=NULL){ + sprintf(token,"\n\n%s", buf); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_YESNO, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_LIMIT, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + }else{ + CHAR_talkToCli( talker, meindex, "这是买卖专门店。",CHAR_COLORWHITE); + } + return; +} + +void NPC_ExpressmanCheck(int meindex,int talker) +{ + int fd = getfdFromCharaIndex( talker); + char token[1024]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024]; + + if( NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("shop_GetArgStr_Err"); + return; + } + NPC_Util_GetStrFromStrWithDelim( argstr, "main_msg", buf, sizeof( buf)); + sprintf(token,"4\n       %s\n\n%s" + "\n\n     < 打工 >   " + "\n\n     <交付行李>" + ,CHAR_getChar(meindex,CHAR_NAME),buf); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_EXPRESS, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + return; + + +} + diff --git a/gmsv/npc/npc_janken.c b/gmsv/npc/npc_janken.c new file mode 100644 index 0000000..93ebc7a --- /dev/null +++ b/gmsv/npc/npc_janken.c @@ -0,0 +1,517 @@ +#include "version.h" +#include +#include "common.h" +#include "char_base.h" +#include "npc_janken.h" +#include "npcutil.h" +#include "char.h" +#include "lssproto_serv.h" +#include "buf.h" +#include "function.h" +#include "readmap.h" +#include "object.h" +#include "log.h" + +/* + *元扎氏仃氏 + */ +static void NPC_Janken_selectWindow( int meindex, int talker, int num); +void NPC_JnakenJudge(int meindex,int talker,int sel); +BOOL NPC_JankenEntryItemCheck(int talker,char *buf); +BOOL NPC_JankenEntryItemDel(int talker,char *buf); +void NPC_WarpPointGet(int meindex,int talker,int *fl,int *x,int *y,int judge); + + +/********************************* +* 赓渝质 +*********************************/ +BOOL NPC_JankenInit( int meindex ) +{ + + //正奶皿毛本永玄 + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEJANKEN ); + + return TRUE; + +} + + +/********************************* +* 仄井仃日木凶凛及质 +*********************************/ +void NPC_JankenTalked( int meindex , int talkerindex , char *szMes , + int color ) +{ + /* 皿伊奶乩□卞覆仄化分仃 杀允月 */ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + + /* ㄠ弘伉永玉动 及心 */ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) return; + + NPC_Janken_selectWindow(meindex, talkerindex, 0); + + + + +} + + + +/****************************** + * 公木冗木及质 卞坌仃月 + ******************************/ +static void NPC_Janken_selectWindow( int meindex, int talker, int num) +{ + + char token[1024]; + char buf[32]; + int fd = getfdFromCharaIndex( talker); + int buttontype=0; + int windowtype=0; + int windowno=0; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + + + /*--它奶件玉它正奶皿丢永本□斥互云云中及匹燮卞涩烂--*/ + windowtype=WINDOW_MESSAGETYPE_MESSAGE; + + /*--涩烂白央奶伙毛 心 心--*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("NPC_janken Init: GetArgStrErr"); + return ; + } + + + switch( num) + { + case 0: + + /*-- 旦正□玄及丢永本□斥互 仃木壬巨仿□ 憎 --*/ + if(NPC_Util_GetStrFromStrWithDelim( argstr, "MainMsg", token, sizeof( token)) + == NULL) + { + print("Janken:MainMsg:%s", CHAR_getChar( meindex, CHAR_NAME)); + return ; + } + + /*--蓟 --*/ + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_JANKEN_START; + break; + + + case 1: + + //失奶 丞及民尼永弁 + if(NPC_Util_GetStrFromStrWithDelim( argstr, "EntryItem", + buf, sizeof( buf)) + != NULL) { + + if(NPC_JankenEntryItemCheck(talker,buf) == FALSE) + { + NPC_Janken_selectWindow(meindex, talker, 3); + } + + //巨件玄伉迕及失奶 丞毛绰轮 + if(NPC_JankenEntryItemDel(talker,buf) == FALSE){ + print("元扎氏仃氏ERR:失奶 丞壅仄卞仄匀天中"); + } + } + + + /*--蓟 --*/ + sprintf(token," 剪刀石头布!!\n" + "\n\n 《 石头 》" + "\n\n 《 剪刀 》" + "\n\n 《 布 》" + ); + + buttontype=WINDOW_BUTTONTYPE_NONE; + windowtype=WINDOW_MESSAGETYPE_SELECT; + windowno=CHAR_WINDOWTYPE_JANKEN_MAIN; + break; + + case 2: + /*--丐中仇蓟 --*/ + //sprintf(token," 丐中仇匹″″\n" + sprintf(token," 平手再来!!\n" + "\n\n 《 石头 》" + "\n\n 《 剪刀 》" + "\n\n 《 布 》" + ); + + buttontype=WINDOW_BUTTONTYPE_NONE; + windowtype=WINDOW_MESSAGETYPE_SELECT; + windowno=CHAR_WINDOWTYPE_JANKEN_MAIN; + break; + + case 3: + /*-- 旦正□玄及丢永本□斥互 仃木壬巨仿□ 憎 --*/ + NPC_Util_GetStrFromStrWithDelim( argstr, "NoItem", token, sizeof( token)); + + buttontype=WINDOW_BUTTONTYPE_OK; + windowtype=WINDOW_MESSAGETYPE_MESSAGE; + windowno=CHAR_WINDOWTYPE_JANKEN_END; + + break; + + } + + +// makeEscapeString( token, escapedname, sizeof(escapedname)); + /*-仇仇匹霜耨允月--*/ + lssproto_WN_send( fd, windowtype, + buttontype, + windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + + +} + + + +/********************************* +* 它奴件玉它丢永本□斥卞覆允月质 +*********************************/ +void NPC_JankenWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + /* ㄠ弘伉永玉动 及心 */ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) return; + + switch( seqno){ + case CHAR_WINDOWTYPE_JANKEN_START: + + if(select==WINDOW_BUTTONTYPE_YES){ + NPC_Janken_selectWindow(meindex, talkerindex, 1); + } + break; + + case CHAR_WINDOWTYPE_JANKEN_MAIN: + if (atoi(data) >= 3){ + NPC_JnakenJudge(meindex,talkerindex,atoi(data) ); + } + break; + } +} + + +/* + *斥乓件弗件及 烂 + */ +void NPC_JnakenJudge(int meindex,int talker,int sel) +{ + int player=-1; + int jankenman; + char j_char[3][8]={" 石头 "," 剪刀 "," 布 "}; + char token[1024]; + int shouhai = 0; + int fd = getfdFromCharaIndex( talker); + int fl=0,x=0,y=0; + + + if(sel == 3) player = 0; //弘□ + if(sel == 5) player = 1; //民亦平 + if(sel == 7) player = 2; //由□ + + jankenman = rand()%3; + + switch(jankenman){ + case 0: + if(player == 2){ + shouhai = 1; + }else if(player == 1){ + shouhai = 2; + } + break; + + case 1: + if(player == 0){ + shouhai = 1; + }else if(player == 2){ + shouhai = 2; + } + break; + + case 2: + if(player == 1){ + shouhai = 1; + }else if(player == 0){ + shouhai = 2; + } + break; + } + + if(shouhai == 1){ + //Change add 玩家猜胜了给的道具 + NPC_JankenItemGet( meindex, talker, "WinItem" ); + + NPC_WarpPointGet(meindex, talker, &fl, &x, &y, 0); + + snprintf( token, sizeof( token ) , + " ~ 结 果 ~ \n\n" + " %16s %-16s\n" + " [%s] VS [%s]\n\n\n" + " %-16s 胜利", + CHAR_getChar(meindex,CHAR_NAME),CHAR_getChar(talker,CHAR_NAME), + j_char[jankenman],j_char[player], + CHAR_getChar(talker,CHAR_NAME) + ); + +// CHAR_talkToCli( talker , -1 ,token , CHAR_COLORCYAN ); + + //伐□皿 + CHAR_warpToSpecificPoint(talker, fl, x, y); + + // 匀凶午五反>减少=及失弁扑亦件毛允月[ + CHAR_sendWatchEvent( CHAR_getWorkInt( talker, CHAR_WORKOBJINDEX), + CHAR_ACTPLEASURE,NULL,0,TRUE); + CHAR_setWorkInt( talker, CHAR_WORKACTION, CHAR_ACTPLEASURE); + + }else if(shouhai == 2){ + + //Change add 玩家猜输了给的道具 + NPC_JankenItemGet( meindex, talker, "LoseItem" ); + + NPC_WarpPointGet(meindex, talker, &fl, &x, &y, 1); + snprintf( token, sizeof( token ) , + " ~ 结 果 ~ \n\n" + " %16s %-16s\n" + " [%s] VS [%s]\n\n\n" + " %-16s 输了", + CHAR_getChar(meindex,CHAR_NAME),CHAR_getChar(talker,CHAR_NAME), + j_char[jankenman],j_char[player], + CHAR_getChar(talker,CHAR_NAME) + ); +// CHAR_talkToCli( talker , -1 ,token , CHAR_COLORCYAN ); + + //伐□皿 + CHAR_warpToSpecificPoint(talker, fl, x, y); + + // 仃凶午五反> 仄中=失弁扑亦件毛允月 + CHAR_sendWatchEvent( CHAR_getWorkInt( talker, CHAR_WORKOBJINDEX), + CHAR_ACTSAD,NULL,0,TRUE); + CHAR_setWorkInt( talker, CHAR_WORKACTION, CHAR_ACTSAD); + + + }else{ + //仇仇卞仁月午丐中仇 + NPC_Janken_selectWindow( meindex, talker, 2); + return; + } + + //霜耨 + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_JANKEN_END, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + + +} + + +/* + *伐□皿燮毛GET允月[ + */ +void NPC_WarpPointGet(int meindex,int talker,int *fl,int *x,int *y,int judge) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char *strbuf[2] = {"WinWarp","LoseWarp"}; + char buf[64]; + char buf2[32]; + + /*--涩烂白央奶伙毛 心 心--*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("NPC_janken Init: GetArgStrErr"); + return ; + } + + + /*--伐□皿燮毛潸 --*/ + NPC_Util_GetStrFromStrWithDelim( argstr, strbuf[judge], buf, sizeof( buf)); + getStringFromIndexWithDelim(buf,",",1,buf2,sizeof(buf2)); + *fl=atoi(buf2); + getStringFromIndexWithDelim(buf,",",2,buf2,sizeof(buf2)); + *x=atoi(buf2); + getStringFromIndexWithDelim(buf,",",3,buf2,sizeof(buf2)); + *y=atoi(buf2); + + +} + +/* + *--失奶 丞及民尼永弁分仃毛垫丹 + */ +BOOL NPC_JankenEntryItemCheck(int talker,char *buf) +{ + + char buf2[512]; + char buf3[256]; + int id=0; + BOOL flg = FALSE; + int i; + int itemindex; + int itemno; + int kosuu; + int cnt=0; + int k=1; + + while(getStringFromIndexWithDelim(buf , "," , k, buf2, sizeof(buf2)) + !=FALSE ) + { + flg = FALSE; + k++; + + if(strstr(buf2,"*") != NULL){ + cnt = 0; + getStringFromIndexWithDelim(buf2,"*",1,buf3,sizeof(buf3)); + itemno = atoi(buf3); + getStringFromIndexWithDelim(buf2,"*",2,buf3,sizeof(buf3)); + kosuu = atoi(buf3); + + for( i=0 ; i < CHAR_MAXITEMHAVE;i++ ){ + itemindex = CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX(itemindex) ){ + id = ITEM_getInt(itemindex ,ITEM_ID ); + if(itemno == id){ + cnt++; + if(cnt == kosuu){ + flg = TRUE; + break; + } + } + } + } + if(flg == FALSE) + { + return FALSE; + } + }else{ + itemno = atoi(buf2); + + for( i=0 ; i < CHAR_MAXITEMHAVE;i++ ){ + itemindex = CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX(itemindex) ){ + id = ITEM_getInt(itemindex ,ITEM_ID ); + if(itemno == id){ + flg = TRUE; + break; + } + } + } + + if(flg == FALSE) + { + return FALSE; + } + } + } + + return TRUE; + +} + +BOOL NPC_JankenEntryItemDel(int talker,char *buf) +{ + + int i = 1, j = 1,k = 1; + char buff3[128]; + char buf2[32]; + int itemindex; + + while(getStringFromIndexWithDelim(buf , "," , k, buff3, sizeof(buff3)) !=FALSE ){ + k++; + if(strstr(buff3, "*") !=NULL){ + int itemno; + int kosuu; + int id; + int cnt=0; + getStringFromIndexWithDelim(buff3,"*",1,buf2,sizeof(buf2)); + itemno = atoi(buf2); + getStringFromIndexWithDelim(buff3,"*",2,buf2,sizeof(buf2)); + kosuu = atoi(buf2); + for( i =0 ; i < CHAR_MAXITEMHAVE ; i++ ){ + itemindex = CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX(itemindex) ){ + id=ITEM_getInt(itemindex ,ITEM_ID ); + if(itemno==id){ + cnt++; + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), /* 失奶 丞 寞 */ +#endif + "QuizDelItem(猜谜->交出道具)", + CHAR_getInt( talker, CHAR_FLOOR), + CHAR_getInt( talker, CHAR_X ), + CHAR_getInt( talker, CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + CHAR_DelItem( talker, i); + if(cnt == kosuu){ + break; + } + } + } + } + }else{ + /*--蓟氏分 寞及失奶 丞毛蓟请---*/ + for( j = 0 ; j < CHAR_MAXITEMHAVE ; j++){ + itemindex = CHAR_getItemIndex( talker ,j); + + if( ITEM_CHECKINDEX(itemindex) ){ + if( atoi( buff3) == ITEM_getInt(itemindex,ITEM_ID)){ + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), /* 失奶 丞 寞 */ +#endif + "QuizDelItem(猜谜->交出道具)", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + CHAR_DelItem( talker, j); + } + } + } + } + } + + return TRUE; +} + +BOOL NPC_JankenItemGet(int meindex,int talker, char *wl) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[64]; + + /*--涩烂白央奶伙毛 心 心--*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("NPC_janken ItemGet: GetArgStrErr"); + return ; + } + + if(NPC_Util_GetStrFromStrWithDelim( argstr, wl, buf, sizeof( buf) ) !=NULL){ + NPC_EventAddItem( meindex, talker, buf); + } +} + diff --git a/gmsv/npc/npc_luckyman.c b/gmsv/npc/npc_luckyman.c new file mode 100644 index 0000000..5d2e3bf --- /dev/null +++ b/gmsv/npc/npc_luckyman.c @@ -0,0 +1,239 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "npc_luckyman.h" + + +static void NPC_LuckyMan_selectWindow( int meindex, int toindex, int num,char *msg); +void NPC_LuckyManAllHeal( int talker,int mode ); +BOOL NPC_LuckyManLevelCheck(int meindex,int talker); +void NPC_LuckyDisp(int meindex,int talker); +BOOL NPC_LuckyCostCheck(int meindex,int talker,int cost); +int NPC_GetMoney(int meindex,int talker,char *buf); + + + +/********************************* +* 赓渝质 +*********************************/ +BOOL NPC_LuckyManInit( int meindex ) +{ + + /*--平乓仿及正奶皿毛涩烂--**/ + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPELUCKYMAN ); + + return TRUE; +} + + + + +/********************************* +* 仄井仃日木凶凛及质 +*********************************/ +void NPC_LuckyManTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[256]; + char token[512]; + int cost; + + + + /*-- 及蟆卞中月井升丹井"--*/ + if(NPC_Util_isFaceToFace( meindex ,talkerindex ,2) == FALSE) { + /* ㄠ弘伉永玉动 及心 */ + if(NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) return; + } + + /*--涩烂白央奶伙毛 心 心--*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL) { + print("NPC_ExChange.c TypeCheck: GetArgStrErr\n"); + print("NPCName=%s\n", CHAR_getChar( meindex, CHAR_NAME)); + return; + } + + + NPC_Util_GetStrFromStrWithDelim( argstr,"Stone", buf, sizeof( buf)); + cost = NPC_GetMoney( meindex, talkerindex, buf); + + NPC_Util_GetStrFromStrWithDelim( argstr,"main_msg", buf, sizeof( buf)); + sprintf( token, buf, cost); + + NPC_LuckyMan_selectWindow( meindex, talkerindex, 2, token); + +} + + +static void NPC_LuckyMan_selectWindow( int meindex, int toindex, int num,char *msg) +{ + + int fd = getfdFromCharaIndex( toindex); + char token[1024]; + int buttontype = 0,windowtype = 0,windowno = 0; + + + switch( num){ + case 1: + sprintf(token ,"       ☆今日的运势☆ " + "\n\n%s",msg + ); + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_WINDOWPETSHOP_START; + break; + + case 2: + sprintf(token, "        ☆占卜师☆ " + "\n\n%s",msg + ); + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_WINDOWPETSHOP_START; + break; + + case 3: + sprintf(token, "        ☆占卜师☆ " + "\n\n%s",msg + ); + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_WINDOWPETSHOP_START; + break; + } + + + /*--霜耨--*/ + lssproto_WN_send( fd, windowtype, + buttontype, + windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + +} + + +/*----------------------------------------- +弁仿奶失件玄井日忒匀化五凶凛卞裟太请今木月[ +-------------------------------------------*/ +void NPC_LuckyManWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[256]; + int money; + int level; + + /*--涩烂白央奶伙毛 心 心--*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("NPC_ExChange.c TypeCheck: GetArgStrErr\n"); + print("NPCName=%s\n", CHAR_getChar(meindex,CHAR_NAME)); + return; + } + + switch( seqno){ + case CHAR_WINDOWTYPE_WINDOWPETSHOP_START: + if(select == WINDOW_BUTTONTYPE_YES) { + NPC_Util_GetStrFromStrWithDelim( argstr, "Stone", buf,sizeof(buf)); + + if(strstr(buf,"LV") != NULL) { + char buff2[32]; + level = CHAR_getInt( talkerindex, CHAR_LV); + getStringFromIndexWithDelim( buf, "*", 2, buff2,sizeof( buff2)); + money = level * atoi( buff2); + + if(NPC_LuckyCostCheck(meindex,talkerindex,money) == FALSE) { + NPC_Util_GetStrFromStrWithDelim( argstr,"NoMoney", buf, sizeof( buf)); + NPC_LuckyMan_selectWindow( meindex, talkerindex, 3, buf); + return; + } + }else{ + money = atoi( buf); + if(NPC_LuckyCostCheck(meindex,talkerindex ,money) == FALSE) { + NPC_Util_GetStrFromStrWithDelim( argstr,"NoMoney", buf,sizeof( buf)); + NPC_LuckyMan_selectWindow( meindex, talkerindex, 3, buf); + return; + } + } + + CHAR_DelGold( talkerindex, money ); + + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + NPC_LuckyDisp( meindex, talkerindex); + + }else if(select == WINDOW_BUTTONTYPE_OK) { + + } + break; + } +} + + + +void NPC_LuckyDisp(int meindex,int talker) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[16]; + char token[1024]; + char buf2[512]; + int i = 1; + + /*--涩烂白央奶伙毛 心 心--*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL) { + print("NPC_Savepoint.c Init: GetArgStrErr"); + return; + } + + /*--扪毛苇月--*/ + sprintf( buf, "luck%d", CHAR_getInt( talker, CHAR_LUCK)); + NPC_Util_GetStrFromStrWithDelim( argstr, buf, buf2, sizeof( buf2)); + + while(getStringFromIndexWithDelim( buf2, ",", i, token, sizeof( token)) + != FALSE) + { + i++; + } + i--; + i = rand()%i + 1; + + /*--仿件母丞匹丢永本□斥毛 憎今六月--*/ + getStringFromIndexWithDelim( buf2,",", i, token, sizeof( token)); + NPC_LuckyMan_selectWindow( meindex, talker, 1, token); +} + + +/*---云嗯及民尼永弁-**/ +BOOL NPC_LuckyCostCheck(int meindex,int talker,int cost) +{ + /*--蜇箕反移涩烂---*/ + /*---云嗯互箫曰月井升丹井及民尼永弁---*/ + if(CHAR_getInt( talker, CHAR_GOLD) < cost) { + return FALSE; + } + return TRUE; + +} + + +int NPC_GetMoney(int meindex,int talker,char *buf) +{ + int level; + int money; + + if(strstr(buf,"LV") != NULL) { + char buff2[32]; + level = CHAR_getInt(talker,CHAR_LV); + getStringFromIndexWithDelim( buf, "*" ,2, buff2,sizeof( buff2)); + money = level * atoi( buff2); + }else{ + money = atoi( buf); + } + return money; + +} diff --git a/gmsv/npc/npc_makepair.c b/gmsv/npc/npc_makepair.c new file mode 100644 index 0000000..7a8b3fd --- /dev/null +++ b/gmsv/npc/npc_makepair.c @@ -0,0 +1,542 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "npc_transerman.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_makepair.h" +#include "npc_eventaction.h" + +#ifdef _NPC_MAKEPAIR +#define MAXPAIRNUMS 30 +PairMenu PairList[2][MAXPAIRNUMS]; + +enum { + WINDOW_START=10, + WINDOW_USER, + WINDOW_SELECT, //心理测验 + WINDOW_PAIR, //配对找对象 + WINDOW_PAIROK, + WINDOW_PAIRNO, + WINDOW_WARP, //跳跃 + WINDOW_END, //结束 + WINDOW_TALKSTART=20, + WINDOW_TALKSELECT, + WINDOW_TALKPAIR, + WINDOW_RETURN, + WINDOW_TALKEND, +}; +enum { + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT1, + NPC_WORK_PAIRTEAMS = 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, +*/ +}; +#define MAKEPAIR_STANDBY 100*60 +static void NPC_MakePair_selectWindow( int meindex, int toindex, int num,int select); +BOOL MakePairMan_GetMenuStr( int meindex, int toindex, char *npcarg, char *token); +void CheckPairUsers( int *male, int *female); +BOOL NPC_PairForage( int meindex, int toindex, char *arg, char *token); +BOOL NPC_PairRegister( int toindex); +void NPC_PairUserAndWarp( int meindex, int toindex, int forindex, char *arg); +int NPC_getPairCode( int toindex); +int NPC_getTitleMsg( int meindex, int toindex, char *arg, char *token, int title); +int NPC_getNextTitle( int meindex, int toindex, char *arg, int title, int select); + + +BOOL NPC_MakePairManInit( int meindex ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + int i; + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("err NPC_MakePairMan: GetArgStrErr!!"); + return FALSE; + } + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_MAKEPAIR); + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, MAKEPAIR_STANDBY); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + CHAR_setWorkInt( meindex, NPC_WORK_PAIRTEAMS, 0); + + for( i=0; i 0){ + CHAR_setWorkInt( toindex, CHAR_MYPAIRINDEX, -1); + sprintf( token, "取消前一次的邀请。"); + }else { + char buf1[256]; + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "FREE", buf1, sizeof( buf1) ) != NULL) { + if( NPC_ActionPassCheck( meindex, toindex, buf1) == FALSE ){ + CHAR_talkToCli( toindex, meindex, "条件不足!", CHAR_COLORYELLOW); + return; + } + } + NPC_PairForage( meindex, toindex, npcarg, token); + } + buttontype = WINDOW_BUTTONTYPE_OK; + windowno = WINDOW_TALKEND; + } + break; + case WINDOW_PAIROK: //同意 + if( CHAR_getWorkInt( toindex, CHAR_MYPAIRFLG) > 0){ + int forindex = CHAR_getWorkInt( toindex, CHAR_MYPAIRINDEX); + NPC_PairUserAndWarp( meindex, toindex, forindex, npcarg); + } + return; + case WINDOW_PAIRNO://不同意 + { + int forindex = CHAR_getWorkInt( toindex, CHAR_MYPAIRINDEX); + if( CHAR_CHECKINDEX( forindex) ){ + if( CHAR_getWorkInt( forindex, CHAR_MYPAIRFLG) > 0 ){ + CHAR_talkToCli( forindex, meindex, "对方拒绝邀请。", CHAR_COLORYELLOW); + CHAR_setWorkInt( forindex, CHAR_MYPAIRINDEX, -1); + CHAR_setWorkInt( forindex, CHAR_MYPAIRFLG, -1); + } + } + CHAR_setWorkInt( toindex, CHAR_MYPAIRINDEX, -1); + CHAR_setWorkInt( toindex, CHAR_MYPAIRFLG, -1); + CHAR_talkToCli( toindex, meindex, "拒绝对方邀请。", CHAR_COLORYELLOW); + return; + } + break; + case WINDOW_WARP: + break; + case WINDOW_END: + break; + } + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token); +} + +void NPC_MakePairManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) + return; + memset( npcarg, 0, sizeof( npcarg)); + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("err NPC_MakePairMan: GetArgStrErr!!"); + return; + } + switch( seqno) { + case WINDOW_TALKSTART: + { + int choose=atoi( data); + if( select == WINDOW_BUTTONTYPE_CANCEL || select == WINDOW_BUTTONTYPE_NO) + return; + switch( choose){ + case 1://查人数 + NPC_MakePair_selectWindow( meindex, talkerindex, WINDOW_USER, 0); + break; + case 2://配对 + NPC_MakePair_selectWindow( meindex, talkerindex, WINDOW_PAIR, 0); + break; + case 3://心理测验 + NPC_MakePair_selectWindow( meindex, talkerindex, WINDOW_SELECT, 0); + break; + } + } + + break; + case WINDOW_TALKSELECT: + { + int title = CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT); + title = NPC_getNextTitle( meindex, talkerindex, npcarg, title, select); + if( title < 0 ) return ; + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, title); + NPC_MakePair_selectWindow( meindex, talkerindex, WINDOW_SELECT, select); + } + break; + case WINDOW_TALKPAIR://配对邀请回覆 + if( select == WINDOW_BUTTONTYPE_CANCEL || select == WINDOW_BUTTONTYPE_NO){ + NPC_MakePair_selectWindow( meindex, talkerindex, WINDOW_PAIRNO, 0); + }else { + NPC_MakePair_selectWindow( meindex, talkerindex, WINDOW_PAIROK, 0); + } + break; + case WINDOW_RETURN: + NPC_MakePair_selectWindow( meindex, talkerindex, WINDOW_START, 0); + break; + case WINDOW_TALKEND: + break; + } +} +void NPC_MakePairManLoop( int meindex) +{ + int i; + for( i=0; i 0 ){ + if( !CHAR_CHECKINDEX( PairList[0][i].pindex) ){ + PairList[0][i].pindex = -1; + PairList[0][i].use = -1; + } + } + if( PairList[1][i].use > 0 ){ + if( !CHAR_CHECKINDEX( PairList[1][i].pindex) ){ + PairList[1][i].pindex = -1; + PairList[1][i].use = -1; + } + } + } +} + +BOOL MakePairMan_GetMenuStr( int meindex, int toindex, char *npcarg, char *token) +{ + char buf1[1024], buf2[256], buf3[256]; + BOOL FINDS=FALSE; + int talkNo=1; + if( npcarg == NULL ) return FALSE; + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "MenuHead", buf1, sizeof( buf1) ) == NULL){ + return FALSE; + } + sprintf( token, "%s\n", buf1); + + sprintf( buf1, "MEMU%d", talkNo); + while( NPC_Util_GetStrFromStrWithDelim( npcarg, buf1, buf2, sizeof( buf2)) != NULL ) { + talkNo++; + sprintf( buf1, "MEMU%d", talkNo); + FINDS = TRUE; + sprintf( buf3, " %s\n", buf2); + strcat( token, buf3); + } + return FINDS; +} + +void CheckPairUsers( int *male, int *female) +{ + int i; + *male = 0; + *female = 0; + for( i=0; i 0 ) *male+=1; + if( PairList[1][i].use > 0 ) *female+=1; + } +} + +BOOL NPC_PairForage( int meindex, int toindex, char *arg, char *token) +{ + char buf1[256]; + int i; + int codes = CHAR_getWorkInt( toindex, CHAR_MYPAIRCODE); + int Psex = CHAR_getSexInt( CHAR_getInt( toindex, CHAR_BASEBASEIMAGENUMBER) ); + Psex = (Psex==1)?1:0; + + + for( i=0; i 0 ) continue; + name = CHAR_getChar( PairList[Psex][i].pindex, CHAR_NAME); + cdKey = CHAR_getChar( PairList[Psex][i].pindex, CHAR_CDKEY); + if( strcmp( PairList[Psex][i].name, name) || strcmp( PairList[Psex][i].cdKey, cdKey) ){ + PairList[Psex][i].use = -1; + PairList[Psex][i].forindex = -1; + continue; + } + sprintf( token, "你的配对对象为: %s\n已送出邀请,请等候对方回应。", name); + if( NPC_Util_GetStrFromStrWithDelim( arg, "InviteMsg", buf1, sizeof( buf1) ) == NULL){ + break; + } + PairList[Psex][i].forindex = toindex; + fd = getfdFromCharaIndex( PairList[Psex][i].pindex); + + CHAR_setWorkInt( toindex, CHAR_MYPAIRFLG, 1); + CHAR_setWorkInt( toindex, CHAR_MYPAIRINDEX, PairList[Psex][i].pindex); + CHAR_setWorkInt( PairList[Psex][i].pindex, CHAR_MYPAIRFLG, 2); + CHAR_setWorkInt( PairList[Psex][i].pindex, CHAR_MYPAIRINDEX, toindex); + + name = CHAR_getChar( toindex, CHAR_NAME); + sprintf( buf, "%s:\n玩家%s\n%s", CHAR_getChar( meindex, CHAR_NAME),name, buf1); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, WINDOW_BUTTONTYPE_OKCANCEL, WINDOW_TALKPAIR, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), buf); + break; + } + if( i>= MAXPAIRNUMS ) { + if( NPC_Util_GetStrFromStrWithDelim( arg, "NoPairMsg", buf1, sizeof( buf1) ) != NULL){ + sprintf( token, "%s",buf1); + }else { + sprintf( token, "没有找到对象。"); + } + if( CHAR_getWorkInt( toindex, CHAR_MYPAIRFLG) <= 0 ) { + NPC_PairRegister( toindex); + } + return FALSE; + } + return TRUE; +} + +BOOL NPC_PairRegister( int toindex) +{ + char *cdKey = CHAR_getChar( toindex, CHAR_CDKEY); + char *name = CHAR_getChar( toindex, CHAR_NAME); + int space=-1,i; + int Psex = CHAR_getSexInt( CHAR_getInt( toindex, CHAR_BASEBASEIMAGENUMBER) ); + Psex = (Psex==1)?0:1; + for( i=0; i=MAXPAIRNUMS){ + if( space != -1 && CHAR_getWorkInt( toindex, CHAR_MYPAIRCODE) > 0 ){ + PairList[Psex][space].use = 1; + PairList[Psex][space].forindex = -1; + sprintf( PairList[Psex][space].cdKey, "%s", cdKey); + sprintf( PairList[Psex][space].name, "%s", name); + PairList[Psex][space].pindex = toindex; + PairList[Psex][space].code = CHAR_getWorkInt( toindex, CHAR_MYPAIRCODE); + + CHAR_talkToCli( toindex, -1, "新增至配对名单。", CHAR_COLORYELLOW); + return TRUE; + } + } + return FALSE; +} + +void NPC_PairUserAndWarp( int meindex, int toindex, int forindex, char *arg) +{ + char buf1[256]; + int fl=-1, x=-1, y=-1; + + if( !CHAR_CHECKINDEX( toindex)) return; + CHAR_setWorkInt( toindex, CHAR_MYPAIRINDEX, -1); + CHAR_setWorkInt( toindex, CHAR_MYPAIRFLG, -1); + if( !CHAR_CHECKINDEX( forindex)) return; + CHAR_setWorkInt( forindex, CHAR_MYPAIRINDEX, -1); + CHAR_setWorkInt( forindex, CHAR_MYPAIRFLG, -1); + + if( CHAR_getWorkInt( toindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE ) return; + if( CHAR_getWorkInt( forindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE ) return; + + if( NPC_Util_GetStrFromStrWithDelim( arg, "PAIRTOPOINT", buf1, sizeof( buf1) ) != NULL){ + char buf2[256]; + if( getStringFromIndexWithDelim( buf1,",",1,buf2,sizeof( buf2)) != FALSE ) + fl = atoi( buf2); + if( getStringFromIndexWithDelim( buf1,",",2,buf2,sizeof( buf2)) != FALSE ) + x = atoi( buf2); + if( getStringFromIndexWithDelim( buf1,",",3,buf2,sizeof( buf2)) != FALSE ) + y = atoi( buf2); + } + CHAR_DischargePartyNoMsg( toindex);//解散团队 + CHAR_DischargePartyNoMsg( forindex);//解散团队 + if( MAP_IsValidCoordinate( fl, x, y) != FALSE ){ + CHAR_warpToSpecificPoint( toindex, fl, x, y); + CHAR_warpToSpecificPoint( forindex, fl, x, y); + } + + CHAR_JoinParty_Main( toindex, forindex); + //lssproto_PR_send( fd, 0, 1); + { + int i; + for( i=0; i 0 ){ + if( PairList[0][i].pindex == toindex || + PairList[0][i].pindex == forindex ){ + PairList[0][i].pindex = -1; + PairList[0][i].use = -1; + } + } + if( PairList[1][i].use > 0 ){ + if( PairList[1][i].pindex == toindex || + PairList[1][i].pindex == forindex ){ + PairList[1][i].pindex = -1; + PairList[1][i].use = -1; + } + } + } + } +} + +int NPC_getPairCode( int toindex) +{ + char *arg=NULL; + int code=-1, i; + if( !CHAR_CHECKINDEX( toindex)) return-1; + for( i=0; i<15; i++) { + char buf1[256]; + int itemindex = CHAR_getItemIndex( toindex, i); + if( !ITEM_CHECKINDEX( itemindex) ) continue; + arg = ITEM_getChar(itemindex, ITEM_ARGUMENT );// 性别|个性编号|FLG + if( arg == NULL )continue; + if( NPC_Util_GetStrFromStrWithDelim( arg, "PAIRCODE", buf1, sizeof( buf1) ) == NULL) continue; + code = atoi( buf1); + break; + } + return code; +} + +int NPC_getNextTitle( int meindex, int toindex, char *arg, int title, int select) +{ + char buf[NPC_UTIL_GETARGSTR_BUFSIZE], buf1[1024], buf2[256]; + int toID=0; + memset( buf, 0, sizeof( buf)); + if( getStringFromIndexWithDelim( arg, "PSYCHOMETRICS", 2, buf, sizeof( buf)) == FALSE ) + return -1; + if( getStringFromIndexWithDelim( buf , "}", title, buf1, sizeof( buf1)) == FALSE ) + return -1; + if( select == WINDOW_BUTTONTYPE_YES ) { + if( NPC_Util_GetStrFromStrWithDelim( buf1, "YESFOR", buf2, sizeof( buf2 )) == NULL) + return -1; + }else { + if( NPC_Util_GetStrFromStrWithDelim( buf1, "NOFOR", buf2, sizeof( buf2) ) == NULL) + return -1; + } + toID = atoi( buf2); + return toID; +} + +int NPC_getTitleMsg( int meindex, int toindex, char *arg, char *token, int title) +{ + char buf[NPC_UTIL_GETARGSTR_BUFSIZE], buf1[1024], buf2[256]; + memset( buf, 0, sizeof( buf)); + + if( getStringFromIndexWithDelim( arg, "PSYCHOMETRICS", 2, buf, sizeof( buf)) == FALSE ) + return -1; + //取得下一题 + if( getStringFromIndexWithDelim( buf , "}", title, buf1, sizeof( buf1)) == FALSE ) + return FALSE; + if( NPC_Util_GetStrFromStrWithDelim( buf1, "TITLEMSG", buf2, sizeof( buf2 )) == NULL){ + if( NPC_Util_GetStrFromStrWithDelim( buf1, "FREE", buf2, sizeof( buf2 )) == NULL){ + return -1; + } + if( NPC_ActionPassCheck( meindex, toindex, buf2) == FALSE ) { + CHAR_talkToCli( toindex, meindex, "条件不足", CHAR_COLORYELLOW); + return -1; + } + if( Action_RunDoEventAction( meindex, toindex, buf1) == FALSE ){ + CHAR_talkToCli( toindex, meindex, "条件不足", CHAR_COLORYELLOW); + return -1; + } + if( NPC_Util_GetStrFromStrWithDelim( buf1, "ENDMSG", buf2, sizeof( buf2 )) == NULL){ + return -1; + } + sprintf( token, "%s", buf2); + return 2; + } + + sprintf( token, "%s", buf2); + return 1; +} +#endif diff --git a/gmsv/npc/npc_manorsman.c b/gmsv/npc/npc_manorsman.c new file mode 100644 index 0000000..eb72c7c --- /dev/null +++ b/gmsv/npc/npc_manorsman.c @@ -0,0 +1,1244 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "lssproto_serv.h" +#include "npcutil.h" +#include "handletime.h" +#include "npc_scheduleman.h" +#include "family.h" +#include "npc_manorsman.h" +#include "saacproto_cli.h" +#include "net.h" +#include "configfile.h" +#include "log.h" + +/* + * 庄园 PK 登记员 + * + */ +#define MAX_MANORSMAN 22 +static int FMPK_ManorsmanList[MAX_MANORSMAN]={ +-1,-1,-1,-1,-1, +-1,-1,-1,-1,-1, +-1,-1,-1,-1,-1, +-1,-1,-1,-1,-1, +-1,-1 }; + +enum { + NPC_WORK_ID = CHAR_NPCWORKINT1, // 登记员 ID, 从 0 开始 + NPC_WORK_MANORID = CHAR_NPCWORKINT2, // 庄园编号 + NPC_WORK_CHALLENGEWAIT = CHAR_NPCWORKINT3, // 挑战等待时间 + NPC_WORK_PEACEWAIT = CHAR_NPCWORKINT4, // 休战时间 + NPC_WORK_PREVLOOPTIME = CHAR_NPCWORKINT5, // 前一次处理 Loop 的时间 +#ifdef _NEW_MANOR_LAW + NPC_WORK_BETTLETIME = CHAR_NPCWORKINT6 // 记录开打时的日期 +#endif +}; + +#define SCHEDULEFILEDIR "./Schedule/" + +#ifdef _FIX_FAMILY_PK_LIMIT // WON ADD 将可挑战庄园的由前十大改为前二十大 +#define PK_LIMIT 20 +#endif + + +extern struct FM_POINTLIST fmpointlist; +extern void NPC_talkToFloor(int floor, int index1, int index2, char *data); +#ifdef _MANOR_PKRULE +extern struct FMS_DPTOP fmdptop; +#endif + +void NPC_ManorLoadPKSchedule(int meindex); // Load schedule from disk +#ifdef _NEW_MANOR_LAW +void SortManorSchedule(); +int SortManorScheduleMomentum(const void *indexa, const void *indexb); +extern int familyMemberIndex[FAMILY_MAXNUM][FAMILY_MAXMEMBER]; +int g_iSortManor; +#endif + +int NPC_getManorsmanListIndex( int ID) +{ + + if( ID < 0 || ID >= MAX_MANORSMAN ){ + return FMPK_ManorsmanList[ ID]; + } + return -1; +} +BOOL NPC_ManorSmanInit( int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + int meid; + int a; + + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_TYPEMANORSCHEDULEMAN ); + + // 参数 + NPC_Util_GetArgStr(meindex, argstr, sizeof(argstr)); + meid = NPC_Util_GetNumFromStrWithDelim(argstr, "id" ); + if ((meid<0) || (meid>=MAX_SCHEDULEMAN)) { + print("MANORSMAN init error: invalid ID(%d)\n",meid); + meid=0; + } + CHAR_setWorkInt(meindex, NPC_WORK_ID, meid); + + a = NPC_Util_GetNumFromStrWithDelim(argstr, "loop" ); + if ((a<100) || (a>10000)) a=1000; + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, a); + + a = NPC_Util_GetNumFromStrWithDelim(argstr, "manorid" ); + if ((a<1) || (a>/*4*/MANORNUM)) {// CoolFish 2002/2/25 + print("MANORSMAN init error: invalid manor id(%d).", a); + a=1; + } + CHAR_setWorkInt(meindex, NPC_WORK_MANORID, a); + + a = NPC_Util_GetNumFromStrWithDelim(argstr, "challengewait"); + if ((a<1) || (a>259200)) { + print("MANORSMAN init error: invalid challengewait(%d).",a); + a=259200; + } + CHAR_setWorkInt(meindex, NPC_WORK_CHALLENGEWAIT, a); + + a = NPC_Util_GetNumFromStrWithDelim(argstr, "peacewait"); + if ((a<1) || (a>432000)) { + print("MANORSMAN init error: invalid peacewait(%d).",a); + a=604800; + } + CHAR_setWorkInt(meindex, NPC_WORK_PEACEWAIT, a); + + NPC_ManorLoadPKSchedule(meindex); + + CHAR_setWorkInt(meindex, NPC_WORK_PREVLOOPTIME, NowTime.tv_sec); +#ifdef _NEW_MANOR_LAW + CHAR_setWorkInt(meindex,NPC_WORK_BETTLETIME,0); +#endif + + if( CHAR_getWorkInt( meindex, NPC_WORK_ID) >= 0 && + CHAR_getWorkInt( meindex, NPC_WORK_ID) 2) return; + if (!NPC_Util_isFaceToFace(meindex, talkerindex, 2)) return; + fd = getfdFromCharaIndex(talkerindex); + if (fd == -1) return; + + switch (fmpks[fmpks_pos+1].flag) { + case FMPKS_FLAG_NONE: + // 没有约定战斗,此时可以下战书 + saacproto_ACFMPointList_send(acfd); +#ifdef _MANOR_PKRULE + sprintf(buf, "庄园所有权争夺战的挑战资格\n\n" + "一、没有拥有庄园的家族\n" + #ifdef _FIX_FAMILY_PK_LIMIT // WON ADD 将可挑战庄园的由前十大改为前二十大 + "二、家族排行必需为前二十大家族\n" + #else + "二、家族排行必需为前十大家族\n" + #endif + "叁、踢馆时间:下午六点至凌晨叁点\n\n" + "请稍待,我将确认你的资格。"); +#else + sprintf(buf, "庄园所有权争夺战的挑战资格\n\n" + "一、没有拥有庄园的家族\n" + "二、家族的声望高於庄园家族的声望\n\n" + "请稍待,我将确认你的资格。"); +#endif + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_YESNO, + CHAR_WINDOWTYPE_CHECKMAN_START, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + break; + case FMPKS_FLAG_MANOR_PREPARE: + // 目前已经定好战斗,准备中 + { + int timeleft=fmpks[fmpks_pos+1].dueltime-NowTime.tv_sec; + int dd,hh,mm; + char buf2[4096]; + dd = /*fmpks[fmpks_pos+1].dueltime*/ timeleft / 86400; + hh = /*fmpks[fmpks_pos+1].dueltime*/ timeleft / 3600 - dd*24; + mm = /*fmpks[fmpks_pos+1].dueltime*/ timeleft / 60 - dd*24*60 - hh*60; + memset(buf2,0,sizeof(buf2)); + if (dd>0) sprintf(buf, " %d 天", dd); else strcpy(buf, ""); + strcat(buf2, buf); + if (hh>0) sprintf(buf, " %d 小时", hh); else strcpy(buf, ""); + strcat(buf2, buf); + if (mm>0) sprintf(buf, " %d 分锺", mm); else strcpy(buf, ""); + strcat(buf2, buf); + if (strlen(buf2)==0) + sprintf(buf, "庄园所有权争夺战\n『%s VS %s』\n\n" + "即将开始,请准备入场。", + fmpks[fmpks_pos+1].guest_name, + fmpks[fmpks_pos+1].host_name); + else + sprintf(buf, "庄园所有权争夺战\n『%s VS %s』\n\n" + "预定将在%s後开始。", + fmpks[fmpks_pos+1].guest_name, + fmpks[fmpks_pos+1].host_name, + buf2); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + } + break; + case FMPKS_FLAG_MANOR_PEACE: + // 战斗已经结束的和平时期 + { + int timeleft=fmpks[fmpks_pos+1].dueltime-NowTime.tv_sec; + int dd,hh,mm; + char buf2[4096]; + dd = /*fmpks[fmpks_pos+1].dueltime*/ timeleft / 86400; + hh = /*fmpks[fmpks_pos+1].dueltime*/ timeleft / 3600 - dd*24; + mm = /*fmpks[fmpks_pos+1].dueltime*/ timeleft / 60 - dd*24*60 - hh*60; + strcpy(buf2,""); + if (dd>0) sprintf(buf, " %d 天", dd); else strcpy(buf, ""); + strcat(buf2, buf); + if (hh>0) sprintf(buf, " %d 小时", hh); else strcpy(buf, ""); + strcat(buf2, buf); + if (mm>0) sprintf(buf, " %d 分锺", mm); else strcpy(buf, ""); + strcat(buf2, buf); + + if (strlen(buf2)==0) + strcpy(buf, "请稍等,让我准备一下申请踢馆的表格。"); + else + sprintf(buf, "现在是休战时期,要踢馆的话\n请%s後再来申请。",buf2); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), buf); + } + break; + case FMPKS_FLAG_MANOR_BATTLEBEGIN: + // 目前正在进行踢馆 + sprintf(buf, "庄园所有权争夺战\n『%s VS %s』\n\n" + "开~打~罗~\n还没进场的人赶快进场吧。", + fmpks[fmpks_pos+1].guest_name, + fmpks[fmpks_pos+1].host_name); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + break; + case FMPKS_FLAG_MANOR_OTHERPLANET: + // 在别的星球进行战斗 + sprintf(buf, "庄园所有权争夺战\n『%s VS %s』\n\n" + "决斗地点在 %s 。", + fmpks[fmpks_pos+1].guest_name, + fmpks[fmpks_pos+1].host_name, + fmpks[fmpks_pos+2].host_name); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + break; + } +} +#else +void NPC_ManorSmanTalked(int meindex, int talkerindex, char *msg, int color) +{ + char buf[4096]; + int fd; + int fmpks_pos = CHAR_getWorkInt(meindex,NPC_WORK_ID)*MAX_SCHEDULE; + int manorid = CHAR_getWorkInt(meindex,NPC_WORK_MANORID); + + if(CHAR_CHECKINDEX(meindex) == FALSE){ + printf("\nNPC_ManorSmanTalked error!(meindex:%d)",meindex); + return; + } + if(NPC_Util_CharDistance(meindex,talkerindex) > 2) return; + if(!NPC_Util_isFaceToFace(meindex,talkerindex,2)) return; + fd = getfdFromCharaIndex(talkerindex); + if(fd == -1) return; + + if(fmpks[fmpks_pos+1].flag == FMPKS_FLAG_CHALLENGE) fmpks[fmpks_pos+1].flag = FMPKS_FLAG_NONE; + + switch(fmpks[fmpks_pos+1].flag){ + // 挑战期 1800~2200 + case FMPKS_FLAG_NONE: + case FMPKS_FLAG_WAIT: + saacproto_ACFMPointList_send(acfd); + sprintf(buf,"庄园所有权争夺战的挑战资格\n\n" + "一、没有庄园的家族\n" + "二、家族的气势高於庄园家族的气势\n" + "叁、约战时间终止时,气势排名第一者获得挑战资格\n" + "四、气势相同者以最先报名者获得资格\n" + "按 OK 我将确认你的资格,按 NO 观看挑战排名"); + lssproto_WN_send(fd,WINDOW_MESSAGETYPE_MESSAGE,WINDOW_BUTTONTYPE_YESNO,CHAR_WINDOWTYPE_CHECKMAN_START, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX),buf); + if(fmpointlist.fm_momentum[manorid-1] <= -1){ + int hadfmindex,index; + char token[256]; + + getStringFromIndexWithDelim(fmpointlist.pointlistarray[manorid-1],"|",5,token,sizeof(token)); + hadfmindex = atoi(token); + if(hadfmindex != -1){ + for(index=0;index= FAMILY_MAXNUM){ + getStringFromIndexWithDelim(fmpointlist.pointlistarray[manorid-1],"|",6,token,sizeof(token)); + printf("\nNPC_ManorSmanTalked():save fm_momentum error(%d:%s)",hadfmindex,token); + break; + } + // 记录这个时刻守庄家族的气势 + else fmpointlist.fm_momentum[manorid-1] = fmdptop.fmMomentum[index]; + } + } + SortManorSchedule(); + break; + // 挑战准备期 2200~取得挑战资格的家族当时挑战的时间(隔天的 1800~2200 之间) + case FMPKS_FLAG_MANOR_PREPARE: + // 目前已经定好战斗,准备中 + { + int timeleft = fmpks[fmpks_pos+1].dueltime - NowTime.tv_sec; + int mm,hh,dd; + char buf2[4096]; + + dd = timeleft / 86400; + hh = timeleft / 3600 - dd * 24; + mm = timeleft / 60 - dd * 24 * 60 - hh * 60; + memset(buf2,0,sizeof(buf2)); + if(dd > 0) sprintf(buf," %d 天",dd); else strcpy(buf,""); + strcat(buf2,buf); + if(hh > 0) sprintf(buf," %d 小时",hh); else strcpy(buf,""); + strcat(buf2,buf); + if(mm > 0) sprintf(buf," %d 分锺",mm); else strcpy(buf,""); + strcat(buf2,buf); + if(strlen(buf2) == 0) + sprintf(buf,"庄园所有权争夺战\n『%s VS %s』\n\n即将开始,请准备入场。", + fmpks[fmpks_pos+1].guest_name,fmpks[fmpks_pos+1].host_name); + else + sprintf(buf,"庄园所有权争夺战\n『%s VS %s』\n\n预定将在%s後开始。", + fmpks[fmpks_pos+1].guest_name,fmpks[fmpks_pos+1].host_name,buf2); + lssproto_WN_send(fd,WINDOW_MESSAGETYPE_MESSAGE,WINDOW_BUTTONTYPE_OK,CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex,CHAR_WORKOBJINDEX),buf); + } + break; + // 休战期及准备期,五天 + case FMPKS_FLAG_MANOR_PEACE: + case FMPKS_FLAG_MANOR_PEACE_SAVE: + { + int timeleft = fmpks[fmpks_pos+1].dueltime-NowTime.tv_sec; + int dd,hh,mm; + char buf2[4096]; + dd = timeleft / 86400; + hh = timeleft / 3600 - dd*24; + mm = timeleft / 60 - dd*24*60 - hh*60; + memset(buf2,0,sizeof(buf2)); + if(dd > 0) sprintf(buf," %d 天",dd); else strcpy(buf,""); + strcat(buf2,buf); + if(hh > 0) sprintf(buf," %d 小时",hh); else strcpy(buf,""); + strcat(buf2,buf); + if(mm > 0) sprintf(buf," %d 分锺",mm); else strcpy(buf,""); + strcat(buf2,buf); + + if(strlen(buf2) == 0) strcpy(buf, "请稍等,让我准备一下申请踢馆的表格。"); + else sprintf(buf, "现在非挑战时期,要挑战的话\n请%s後再来申请。",buf2); + lssproto_WN_send(fd,WINDOW_MESSAGETYPE_MESSAGE,WINDOW_BUTTONTYPE_OK,CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX),buf); + } + break; + // 挑战中 + case FMPKS_FLAG_MANOR_BATTLEBEGIN: + sprintf(buf,"庄园所有权争夺战\n『%s VS %s』\n\n开~打~罗~\n还没进场的人赶快进场吧。", + fmpks[fmpks_pos+1].guest_name,fmpks[fmpks_pos+1].host_name); + lssproto_WN_send(fd,WINDOW_MESSAGETYPE_MESSAGE,WINDOW_BUTTONTYPE_OK,CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX),buf); + break; + case FMPKS_FLAG_MANOR_OTHERPLANET: + // 在别的星球进行战斗 + sprintf(buf,"庄园所有权争夺战\n『%s VS %s』\n\n决斗地点在 %s 。", + fmpks[fmpks_pos+1].guest_name,fmpks[fmpks_pos+1].host_name,fmpks[fmpks_pos+2].host_name); + lssproto_WN_send(fd,WINDOW_MESSAGETYPE_MESSAGE,WINDOW_BUTTONTYPE_OK,CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex,CHAR_WORKOBJINDEX),buf); + break; + } +} +#endif + +void NPC_ManorSmanWindowTalked(int meindex, int talkerindex, + int seqno, int select, char *data) +{ + int fd, fmpks_pos, manorid, tkfmindex, tkfmdp; + char buf[4096],token[256]; + int hadfmindex; +#ifndef _ACFMPK_LIST + char hadfmname[256]; +#endif + int hadfmpopular; + + if (NPC_Util_CharDistance(meindex,talkerindex) > 2) return; + if (!NPC_Util_isFaceToFace(meindex, talkerindex, 2)) return; + fd = getfdFromCharaIndex(talkerindex); + if (fd == -1) return; + fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID)*MAX_SCHEDULE; + manorid = CHAR_getWorkInt(meindex, NPC_WORK_MANORID); + tkfmindex = CHAR_getWorkInt(talkerindex, CHAR_WORKFMINDEXI); + tkfmdp = CHAR_getWorkInt(talkerindex, CHAR_WORKFMDP); + getStringFromIndexWithDelim(fmpointlist.pointlistarray[manorid-1], "|", 5, token, sizeof(token)); + hadfmindex = atoi(token); + getStringFromIndexWithDelim(fmpointlist.pointlistarray[manorid-1], "|", 7, token, sizeof(token)); + hadfmpopular = atoi(token); + + switch (seqno){ + case CHAR_WINDOWTYPE_CHECKMAN_START: + if (select==WINDOW_BUTTONTYPE_YES){ +#ifdef _ACFMPK_NOFREE + sprintf(buf, "庄园挑战会有一天的准备期\n" + "你可以随时询问我以得知剩下的时间\n" + "挑战结束後不论胜负将会有二天的休战期\n" + "休战期间不能挑战\n\n" + "你确定要挑战这个庄园吗?"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_YESNO, + CHAR_WINDOWTYPE_CHECKMAN_MAIN, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), buf); + return; +#endif + +#ifdef _FMVER21 + if ((CHAR_getInt(talkerindex,CHAR_FMLEADERFLAG)==FMMEMBER_LEADER) && +#else + if ((CHAR_getInt(talkerindex,CHAR_FMLEADERFLAG)==1) && +#endif + (CHAR_getWorkInt(talkerindex, CHAR_WORKFMSETUPFLAG)==1)){ + if (hadfmindex != -1) { + if (hadfmindex-1 != tkfmindex){ + int check=0,i; + // Arminius 2.25 fix: fmpks 中第 1~"MANORNUM" 组一定要给 manorsman + for (i=0; i<=/*3*/MANORNUM-1; i++) { // 9个庄园 + getStringFromIndexWithDelim(fmpointlist.pointlistarray[i], "|", 5, token, sizeof(token)); + if (tkfmindex==atoi(token)-1) check=1; + } + for (i=1; i<=/*4*/MANORNUM; i++) { // 是否已经挑战其他庄园 + if ((fmpks[i*MAX_SCHEDULE+1].guest_index==tkfmindex) && + (strcmp(fmpks[i*MAX_SCHEDULE+1].guest_name, + CHAR_getChar(talkerindex, CHAR_FMNAME))==0) + ) { + check=2; + } + } + if (check==0){ + int won1; +#ifdef _MANOR_PKRULE // WON ADD 2002/01/22 + #ifdef _NEW_MANOR_LAW + //----------------------------------------- + int index; + won1 = 1; + + for(index=0;index= FAMILY_MAXNUM){ + printf("\nNPC_ManorSmanWindowTalked():find tkfmIndex error (%d)",tkfmindex); + } + else + // 如果挑战家族气势不足守庄家族气势的九成,不能挑战 + if(fmdptop.fmMomentum[index] < fmpointlist.fm_momentum[manorid-1]*0.9) won1 = 0; + //----------------------------------------- + #else + //----------------------------------------- + int i; + char won2[256]; + won1 = 0; + #ifdef _FIX_FAMILY_PK_LIMIT // WON ADD 将可挑战庄园的由前十大改为前二十大 + for(i=0; i< PK_LIMIT; i++){ + #else + for(i=0; i<10; i++){ + #endif + if( getStringFromIndexWithDelim( fmdptop.topmemo[i], "|", 3, won2, sizeof(won2)) == FALSE ) { + print("err Get fmdptop.topmemo[%d] if FALSE !!\n", i); + break; + } + if( strcmp(CHAR_getChar(talkerindex, CHAR_FMNAME) ,won2) == 0 ){ + won1= 1; + break; + } + //----------------------------------------- + } + #endif + + if(won1 == 1){ + // WON END + #ifdef _NEW_MANOR_LAW + sprintf(buf,"确定庄园挑战资格後会有一天的准备时间\n" + "你可以随时询问我以得知剩下的时间\n" + "挑战结束後至下次挑战期将会有一天的休战期\n" + "和四天的准备期,在这五天期间内不能挑战\n\n" + "你确定要挑战这个庄园吗?"); + #else + sprintf(buf,"庄园挑战会有一天的准备期\n" + "你可以随时询问我以得知剩下的时间\n" + "挑战结束後不论胜负将会有二天的休战期\n" + "休战期间不能挑战\n\n" + "你确定要挑战这个庄园吗?"); + #endif +#else + if(tkfmdp >= hadfmpopular){ + sprintf(buf,"庄园挑战会有一天的准备期\n" + "你可以随时询问我以得知剩下的时间\n" + "挑战结束後不论胜负将会有五天的休战期\n" + "休战期间不能挑战\n\n" + "你确定要挑战这个庄园吗?"); +#endif + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_YESNO, + CHAR_WINDOWTYPE_CHECKMAN_MAIN, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + } + else{ +#ifdef _NEW_MANOR_LAW + sprintf(buf, "你的家族气势尚未到达庄园家族气势的九成,请再加油。"); +#else + #ifdef _MANOR_PKRULE + #ifdef _FIX_FAMILY_PK_LIMIT // WON ADD 将可挑战庄园的由前十大改为前二十大 + sprintf(buf, "你的家族声望尚未进入前二十大家族,请再加油。"); + #else + sprintf(buf, "你的家族声望尚未进入前十大家族,请再加油。"); + #endif + #else + sprintf(buf, "你的家族声望尚不足以挑战\n" + "拥有这个庄园的家族,请再加油。"); + #endif +#endif + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + } + } + else if(check == 2){ + sprintf(buf, "你的家族正在挑战其他庄园,\n" + "请把机会留给其他家族吧!"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + } + else{ + sprintf(buf, "一个家族只能拥有一个庄园,\n" + "如果庄园家族之间需要切磋\n" + "请到家族PK场。"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + } + } + else{ + sprintf(buf, "这个庄园已经是你的家族的喔。"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + } + } + else{ + sprintf(buf, "现在并没有庄园家族,\n" + "直接去申请迁入就可以了哟。"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + } + } + else{ + sprintf(buf, "只有族长可以下战书喔。"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + } + } +#ifdef _NEW_MANOR_LAW + else if(select == WINDOW_BUTTONTYPE_NO){ + int i,index,manorindex; + char szMsg[3072]; + + sprintf(buf," 庄园挑战排名表\n名次 家族名称 时间 气势\n"); + manorindex = CHAR_getWorkInt(meindex,NPC_WORK_MANORID) - 1; + // 送出挑战排名 + for(i=0;i<10;i++){ + index = ManorSchedule[manorindex].iSort[i]; + if(ManorSchedule[manorindex].iFmIndex[index] != -1){ + sprintf(szMsg,"%2d %s\n",i+1,ManorSchedule[manorindex].szMemo[index]); + strcat(buf,szMsg); + } + } + lssproto_WN_send(fd,WINDOW_FMMESSAGETYPE_MANOR_SCHEDULE,WINDOW_BUTTONTYPE_OK,CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex,CHAR_WORKOBJINDEX),buf); + } +#endif + break; + case CHAR_WINDOWTYPE_CHECKMAN_MAIN: + if (select==WINDOW_BUTTONTYPE_YES) { + +#ifdef _ACFMPK_NOFREE + #ifndef _NEW_MANOR_LAW + NPC_ManorSavePKSchedule(meindex, talkerindex, 0); + sprintf( buf, "庄园挑战登陆确认中,请稍後。"); + CHAR_talkToCli( talkerindex, meindex, buf, CHAR_COLORYELLOW); + #else + NPC_ManorAddToSchedule(meindex,talkerindex); + #endif + return; +#endif + +#ifdef _FMVER21 + if ((CHAR_getInt(talkerindex,CHAR_FMLEADERFLAG)==FMMEMBER_LEADER) && +#else + if ((CHAR_getInt(talkerindex,CHAR_FMLEADERFLAG)==1) && +#endif + (CHAR_getWorkInt(talkerindex, CHAR_WORKFMSETUPFLAG)==1) && + (hadfmindex != -1) && + (hadfmindex - 1 != tkfmindex) +#ifndef _MANOR_PKRULE + && (tkfmdp >= hadfmpopular) +#endif + ){ +#ifndef _ACFMPK_LIST + struct tm tm1; +#endif + +#ifndef _NEW_MANOR_LAW + #ifdef _MANOR_PKRULE + time_t timep; + struct tm *p; + time(&timep); + p = gmtime(&timep); + if( p->tm_hour+8 > 24) + p->tm_hour = p->tm_hour-16; + else + p->tm_hour = p->tm_hour+8; + if(p->tm_hour<18 && p->tm_hour>2){ + sprintf(buf, "请於下午6:00至凌晨3:00再来约战吧!"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + break; + } + #endif + // WON ADD 修正家族pk场的约战问题 + if( fmpks[fmpks_pos+1].flag != FMPKS_FLAG_NONE ){ + sprintf(buf, "这个庄园已经有人约战了喔。"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + return; + } +#endif +#ifdef _ACFMPK_LIST + #ifndef _NEW_MANOR_LAW + NPC_ManorSavePKSchedule(meindex, talkerindex, 0); + sprintf( buf, "庄园挑战登陆确认中,请稍後。"); + CHAR_talkToCli( talkerindex, meindex, buf, CHAR_COLORYELLOW); + #else + NPC_ManorAddToSchedule(meindex,talkerindex); + #endif +#else + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + getStringFromIndexWithDelim(fmpointlist.pointlistarray[manorid-1], "|", 6, token, sizeof(token)); + strcpy(hadfmname, token); + + fmpks[fmpks_pos+1].dueltime = CHAR_getWorkInt(meindex, NPC_WORK_CHALLENGEWAIT) + NowTime.tv_sec + - tm1.tm_min*60 + 1800; // Arminius 11.1 改成一律 xx:30 开打 + fmpks[fmpks_pos+1].host_index = hadfmindex-1; + strcpy(fmpks[fmpks_pos+1].host_name, hadfmname); + fmpks[fmpks_pos+1].guest_index = tkfmindex; + strcpy(fmpks[fmpks_pos+1].guest_name, CHAR_getChar(talkerindex, CHAR_FMNAME)); + fmpks[fmpks_pos+1].prepare_time = 15; + fmpks[fmpks_pos+1].max_player = 50; + fmpks[fmpks_pos+1].win = -1; + fmpks[fmpks_pos+1].flag = FMPKS_FLAG_MANOR_OTHERPLANET; + strcpy(fmpks[fmpks_pos+2].host_name, getGameserverID()); + + #ifndef _NEW_MANOR_LAW + NPC_ManorSavePKSchedule(meindex, talkerindex, 0); + sprintf(buf, "庄园挑战已经设定完成,请好好准备。"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + #else + NPC_ManorAddToSchedule(meindex,talkerindex); + #endif + fmpks[fmpks_pos+1].flag = FMPKS_FLAG_MANOR_PREPARE; +#endif + + } + } + break; + } +} + +void NPC_CleanPkList( int ti) +{ +// Terry fix 要清为-1不能清为0 +/* fmpks[ ti+1 ].host_index = 0; + fmpks[ ti+1].guest_index=0; + fmpks[ ti].host_index=0; + fmpks[ ti].guest_index=0;*/ + fmpks[ ti+1 ].host_index = -1; + fmpks[ ti+1].guest_index=-1; + fmpks[ ti].host_index=-1; + fmpks[ ti].guest_index=-1; + + strcpy(fmpks[ ti+1].host_name,""); + strcpy(fmpks[ ti+1].guest_name,""); + strcpy(fmpks[ ti].host_name,""); + strcpy(fmpks[ ti].guest_name,""); + strcpy(fmpks[ ti+2].host_name,""); +} + +void NPC_ManorSmanLoop(int meindex) +{ + struct tm tm1; + int fmpks_pos; +#ifdef _NEW_MANOR_LAW + int iOffsetTime; +#endif + + if(CHAR_CHECKINDEX(meindex) == FALSE){ + printf("\nNPC_ManorSmanLoop error!(meindex:%d)",meindex); + return; + } + + fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID)*MAX_SCHEDULE; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + + switch (fmpks[fmpks_pos+1].flag) { + case FMPKS_FLAG_NONE: +#ifdef _NEW_MANOR_LAW + { + int hadfmindex,index,manorid; + char token[256]; + //此时可以开始挑战 + manorid = CHAR_getWorkInt(meindex,NPC_WORK_MANORID); + getStringFromIndexWithDelim(fmpointlist.pointlistarray[manorid-1],"|",5,token,sizeof(token)); + hadfmindex = atoi(token); + if(hadfmindex != -1){ + for(index=0;index= FAMILY_MAXNUM){ + getStringFromIndexWithDelim(fmpointlist.pointlistarray[manorid-1],"|",6,token,sizeof(token)); + printf("\nNPC_ManorSmanLoop():save fm_momentum error(%d:%s)",hadfmindex,token); + break; + } + // 记录这个时刻守庄家族的气势 + else fmpointlist.fm_momentum[manorid-1] = fmdptop.fmMomentum[index]; + // 进入下一个状态 + fmpks[fmpks_pos+1].flag = FMPKS_FLAG_WAIT; + // 挑战期共4小时(1800~2200) + fmpks[fmpks_pos+1].dueltime = NowTime.tv_sec + 3600 * 4; + NPC_ManorSavePKSchedule(meindex, -1, FMPKS_FLAG_WAIT,fmpks[fmpks_pos+1].dueltime,tm1); + } + SortManorSchedule(); + } +#endif + break; +#ifdef _NEW_MANOR_LAW + // 进入挑战期,已记录家族气势,等待挑战排程 + case FMPKS_FLAG_WAIT: + { + int manorid,i,iPlayerNum = CHAR_getPlayerMaxNum(); + char szMsg[256]; + + manorid = CHAR_getWorkInt(meindex,NPC_WORK_MANORID); + // 还没开打,气势改变要去向AC要即时资料 + fmpointlist.fm_inwar[manorid-1] = TRUE; + if(fmpks[fmpks_pos+1].dueltime <= NowTime.tv_sec){ + // 挑战家族中气势最高的获得挑战权 + int manorindex = CHAR_getWorkInt(meindex,NPC_WORK_MANORID) - 1; + int iNo1FmIndexSort = ManorSchedule[manorindex].iSort[0]; + int index = ManorSchedule[manorindex].iFmIndex[iNo1FmIndexSort],iFmIndex1,iCharindex; + char token[256],fmname[256]; + // 没人挑战 + if(index < 0){ + // 直接进入到挑战结束 + fmpks[fmpks_pos+1].flag = FMPKS_FLAG_MANOR_BATTLEEND; + CHAR_setWorkInt(meindex,NPC_WORK_BETTLETIME,tm1.tm_mday); + // 通知所有人 + for(i=0;i= 0 && CHAR_getCharUse(iCharindex)){ + // 获得金钱 = 个人气势 * 5000 + int iAddGold = ((float)CHAR_getInt(iCharindex,CHAR_MOMENTUM)/100.0f) * 5000.0f; + int iGold = CHAR_getInt(iCharindex,CHAR_BANKGOLD),iMaxGold; + // 先放入个人银行 + if(iGold + iAddGold > CHAR_MAXBANKGOLDHAVE){ + CHAR_setInt(iCharindex,CHAR_BANKGOLD,CHAR_MAXBANKGOLDHAVE); + // 个人银行放不下了,放到个人身上 + iAddGold = iGold + iAddGold - CHAR_MAXBANKGOLDHAVE; + iGold = CHAR_getInt(iCharindex,CHAR_GOLD); + iMaxGold = CHAR_getMaxHaveGold(iCharindex); + if(iGold + iAddGold > iMaxGold) CHAR_setInt(iCharindex,CHAR_GOLD,iMaxGold); + else CHAR_setInt(iCharindex,CHAR_GOLD,iGold + iAddGold); + LogFMPKGetMomey(CHAR_getChar(iCharindex,CHAR_FMNAME), + CHAR_getChar(iCharindex,CHAR_CDKEY), + CHAR_getChar(iCharindex,CHAR_NAME), + CHAR_getInt(iCharindex,CHAR_MOMENTUM),iAddGold,0); + } + else{ + CHAR_setInt(iCharindex,CHAR_BANKGOLD,iGold + iAddGold); + LogFMPKGetMomey(CHAR_getChar(iCharindex,CHAR_FMNAME), + CHAR_getChar(iCharindex,CHAR_CDKEY), + CHAR_getChar(iCharindex,CHAR_NAME), + CHAR_getInt(iCharindex,CHAR_MOMENTUM),iAddGold,1); + } + CHAR_talkToCli(iCharindex,-1,"辛苦了!守护住庄园的奖金已汇入你的个人银行",CHAR_COLORRED); + // 家族的个人及家族气势都要归零 + CHAR_setInt(iCharindex,CHAR_MOMENTUM,0); + CHAR_talkToCli(iCharindex,-1,"庄园战後个人及家族气势归零",CHAR_COLORRED); + } + } + } + } + else{ + // 挑战时间已过,选出的挑战家族和守庄家族有约一天的时间可以准备 + NPC_ManorSavePKSchedule(meindex,index,0,-1,ManorSchedule[manorindex].tm1[iNo1FmIndexSort]); + // 开打了,气势改变也不用去向AC要即时资料了 + fmpointlist.fm_inwar[manorid-1] = FALSE; + // 通知所有人 + sprintf(szMsg,"%s 家族获得挑战庄园资格",ManorSchedule[manorindex].szFmName[iNo1FmIndexSort]); + + for(i=0;i= FAMILY_MAXNUM){ + lssproto_WN_send(getfdFromCharaIndex(charaindex),WINDOW_MESSAGETYPE_MESSAGE,WINDOW_BUTTONTYPE_OK,CHAR_WINDOWTYPE_CHECKMAN_END, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX),"抱歉,找不到你的家族气势资料"); + return; + } + // 比较气势 + if(ManorSchedule[manorindex].iFmMomentum[index] < fmdptop.fmMomentum[i]){ + int fmpks_pos,iPlayerNum = CHAR_getPlayerMaxNum(); + char szMsg[256]; + + // 通知所有人 + fmpks_pos = CHAR_getWorkInt(meindex,NPC_WORK_ID) * MAX_SCHEDULE; + sprintf(szMsg,"%s 家族被 %s 家族挤下挑战排程",ManorSchedule[manorindex].szFmName[index],CHAR_getChar(charaindex,CHAR_FMNAME)); + for(i=0;i momentumB) ? -1:1; +} +#endif diff --git a/gmsv/npc/npc_mic.c b/gmsv/npc/npc_mic.c new file mode 100644 index 0000000..8086249 --- /dev/null +++ b/gmsv/npc/npc_mic.c @@ -0,0 +1,163 @@ +#include "version.h" +#include +#include + +#include "common.h" +#include "char_base.h" +#include "char.h" +#include "npcutil.h" +#include "npc_mic.h" +#include "saacproto_cli.h" +#include "lssproto_serv.h" +#include "battle.h" + +enum { + CHAR_WORK_FLOOR = CHAR_NPCWORKINT1, + CHAR_WORK_LX = CHAR_NPCWORKINT2, + CHAR_WORK_LY = CHAR_NPCWORKINT3, + CHAR_WORK_RX = CHAR_NPCWORKINT4, + CHAR_WORK_RY = CHAR_NPCWORKINT5, + CHAR_WORK_MODE = CHAR_NPCWORKINT6, + CHAR_WORK_TYPE = CHAR_NPCWORKINT7, + CHAR_WORK_WIND = CHAR_NPCWORKINT8, + CHAR_WORK_FMFL = CHAR_NPCWORKINT9, +}; + + +BOOL NPC_MicInit( int meindex ) +{ + int i; + int arg_param[8]; + char argstr[256]; + char buf[64]; + + + NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)); + + + if( strstr(argstr, "FREE")!=NULL){ + CHAR_setWorkInt(meindex,CHAR_WORK_TYPE,1); + } + if( strstr(argstr, "WIND")!=NULL){ + CHAR_setWorkInt(meindex,CHAR_WORK_WIND,1); + } + + + if( strstr( argstr , "|" ) != NULL){ + for( i = 1; i < 9; i ++ ) { + if( getStringFromIndexWithDelim(argstr, "|" , i , buf,sizeof(buf) ) + == FALSE ) + { + printf( "NPC_MIC:省略参数\n"); + arg_param[i-1] = 0; + continue; + } + arg_param[i-1] = atoi(buf); + } + CHAR_setWorkInt( meindex, CHAR_WORK_FLOOR, arg_param[0]); + CHAR_setWorkInt( meindex, CHAR_WORK_LX, min( arg_param[1],arg_param[3])); + CHAR_setWorkInt( meindex, CHAR_WORK_LY, min( arg_param[2],arg_param[4])); + CHAR_setWorkInt( meindex, CHAR_WORK_RX, max( arg_param[1],arg_param[3])); + CHAR_setWorkInt( meindex, CHAR_WORK_RY, max( arg_param[2],arg_param[4])); + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_TYPEMIC); + + CHAR_setWorkInt( meindex, CHAR_WORK_FMFL, arg_param[7]); + return TRUE; + + }else{ + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_TYPEMIC); + CHAR_setWorkInt( meindex, CHAR_WORK_MODE, 1); + return TRUE; + } + + return FALSE; +} + +void NPC_MicTalked( int meindex , int talkerindex , char *msg ,int color ) +{ + + int i; + int playernum; + int x,y; + char message[4096]; + char buf[2048]; + + if( CHAR_getInt(talkerindex,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER) return; + if(CHAR_getWorkInt(meindex,CHAR_WORK_TYPE) == 0){ + if(NPC_Util_isFaceToChara(talkerindex,meindex,1 ) ==FALSE) return; + } + + snprintf( buf, sizeof( buf), "%s\n%s", + CHAR_getChar( talkerindex, CHAR_NAME), + msg); + + // Robin 0621 族长广播 + print(" MIC_FL:%d ", CHAR_getWorkInt( meindex, CHAR_WORK_FMFL )); + if( CHAR_getWorkInt( meindex, CHAR_WORK_FMFL ) != 0 ) + { +#ifdef _FMVER21 + if( CHAR_getInt( talkerindex, CHAR_FMLEADERFLAG ) == FMMEMBER_LEADER) +#else + if( CHAR_getInt( talkerindex, CHAR_FMLEADERFLAG ) == 1) +#endif + // && ( CHAR_getWorkInt( talkerindex, CHAR_WORKFMFLOOR) == CHAR_getWorkInt( meindex, CHAR_WORK_FLOOR ) ) ) + { + print(" FMLeaderTalk_send:%s,%d,%d,%s ", + CHAR_getChar( talkerindex, CHAR_FMNAME), CHAR_getInt( talkerindex, CHAR_FMINDEX), + CHAR_getWorkInt( talkerindex, CHAR_WORKFMINDEXI), buf); + + sprintf(message, "[族长广播]%s", buf); + saacproto_ACFMAnnounce_send( acfd, + CHAR_getChar( talkerindex, CHAR_FMNAME), + CHAR_getInt( talkerindex, CHAR_FMINDEX), + CHAR_getWorkInt( talkerindex, CHAR_WORKFMINDEXI), + message, + color + ); + return; + } + + } + + makeEscapeString( buf, message, sizeof(buf)); + + playernum = CHAR_getPlayerMaxNum(); + + for( i = 0; i < playernum; i ++ ) { + BOOL flg = FALSE; + if( CHAR_getCharUse(i) == FALSE ) continue; + if( CHAR_getInt( i, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ) continue; + if( CHAR_getInt( i, CHAR_FLOOR) != CHAR_getWorkInt( meindex, CHAR_WORK_FLOOR) ){ + continue; + } + if( CHAR_getWorkInt( meindex, CHAR_WORK_MODE) == 0 ) { + x = CHAR_getInt( i, CHAR_X); + y = CHAR_getInt( i, CHAR_Y); + if( x >= CHAR_getWorkInt( meindex, CHAR_WORK_LX) && + x <= CHAR_getWorkInt( meindex, CHAR_WORK_RX) && + y >= CHAR_getWorkInt( meindex, CHAR_WORK_LY) && + y <= CHAR_getWorkInt( meindex, CHAR_WORK_RY)){ + flg = TRUE; + } + }else { + flg = TRUE; + } + if( flg) { + CHAR_talkToCli( i, talkerindex, msg, CHAR_COLORYELLOW); + if( CHAR_getWorkInt( meindex, CHAR_WORK_WIND) == 1 ) { + if( CHAR_getWorkInt( i, CHAR_WORKBATTLEMODE) + == BATTLE_CHARMODE_NONE) + { + int fd = getfdFromCharaIndex( i); + if( fd != -1 ) { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_MICMESSAGE, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + message); + } + } + } + } + } +} diff --git a/gmsv/npc/npc_msg.c b/gmsv/npc/npc_msg.c new file mode 100644 index 0000000..99df502 --- /dev/null +++ b/gmsv/npc/npc_msg.c @@ -0,0 +1,46 @@ +#include "version.h" +#define _NPC_MSG_C_ + +#include "char.h" +#include "char_base.h" +#include "npcutil.h" + + +/* + 霾滇读卅枣 [ 飓反窒匹手方仁[ + 午曰丐尹内升及 轾井日匹手苇尹月方丹卞允月[ + + init , looked 及心卞 杀 + + */ +BOOL NPC_MsgInit( int meindex ) +{ + //CHAR_setInt( meindex , CHAR_HP , 0 ); + + //CHAR_setInt( meindex , CHAR_MP , 0 ); + //CHAR_setInt( meindex , CHAR_MAXMP , 0 ); + + //CHAR_setInt( meindex , CHAR_STR , 0 ); + //CHAR_setInt( meindex , CHAR_TOUGH, 0 ); + + //CHAR_setInt( meindex , CHAR_LV , 0 ); + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPETOWNPEOPLE ); + //CHAR_setFlg( meindex , CHAR_ISOVERED , 0 ); + //CHAR_setFlg( meindex , CHAR_ISATTACKED , 0 ); /* 猾今木卅中方氏 */ + + return TRUE; +} + + +/* + * 苇日木凶[反卅允分仃[ + */ +void NPC_MsgLooked( int meindex , int lookedindex ) +{ + char arg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + NPC_Util_GetArgStr( meindex, arg, sizeof( arg)); + CHAR_talkToCli( lookedindex , -1 , arg , CHAR_COLORWHITE ); + +} diff --git a/gmsv/npc/npc_mtradenpcman.c b/gmsv/npc/npc_mtradenpcman.c new file mode 100644 index 0000000..28ffd2c --- /dev/null +++ b/gmsv/npc/npc_mtradenpcman.c @@ -0,0 +1,238 @@ +#include "version.h" +#include +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "enemy.h" +#include "log.h" +#include "battle.h" +#include "readmap.h" +#include "handletime.h" +#include "npc_eventaction.h" + +#ifdef _MARKET_TRADE +#include "npc_mtradenpcman.h" +#include "item_trade.h" + +#define MAPTRADE_CHECK 3000 +#define MAPTRADE_CHECKMASTER 100 +#define MAPTRADE_CHECKSELL 200 + +enum { + MAPTRADE_START = 1, + MAPTRADE_MAN, + MAPTRADE_END, +}; +enum { + NPC_WORK_INDEX = CHAR_NPCWORKINT1, + NPC_WORK_WORKTYPE = CHAR_NPCWORKINT2, + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT3, + NPC_WORK_SELLINDEX = CHAR_NPCWORKINT4, +/* + 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, +*/ +}; + +static void NPC_MapTrade_selectWindow( int meindex, int toindex, int num,int select); + +BOOL MapTradeManInit( int meindex ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg)) == NULL) { + print("MapTradeManInit: GetArgStrErr"); + return FALSE; + } + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_MAPTRADEMAN ); + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, MAPTRADE_CHECK); + + CHAR_setWorkInt( meindex, NPC_WORK_SELLINDEX, 0 ); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + CHAR_setWorkInt( meindex, NPC_WORK_INDEX, TRADE_getMaxNumInt()); + InitMapTradeData( -1, 0); //初始摊位资料 + return TRUE; +} + +void MapTradeManLoop( int meindex) +{ + int masterindex=-1, i; + int maxNum = TRADE_getMaxNumInt(); + int nums=0; + + if( CHAR_getWorkInt( meindex, NPC_WORK_CURRENTTIME) > NowTime.tv_sec) + return; + else + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec+MAPTRADE_CHECKMASTER); + + for( i=0; i 0 ) { + sprintf(token , "你已经承租了%d号摊位了呀!", + CHAR_getWorkInt( toindex, CHAR_MAPTRADETYPE)); + }else if( (num = TRADE_AddMasrerTrade( toindex)) != -1 ) { + CHAR_setWorkInt( toindex, CHAR_MAPTRADETYPE, num); + sprintf(token , "好了,%d号摊位暂时就租给你了。\n一旦下线离开後这摊位就必须归还了。", num); + //CHAR_talkToCli( i, -1, buff, CHAR_COLORYELLOW); + Msg_Type = 1; + } + } + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, MAPTRADE_END); + buttontype = WINDOW_BUTTONTYPE_YES; + windowno = MAPTRADE_END; + break; + case MAPTRADE_END: + Msg_Type = 3; + buttontype = WINDOW_BUTTONTYPE_YES; + windowno = MAPTRADE_END; + break; + } + if( !strcmp( token, "\0")) { + if( NPC_Util_GetStrFromStrWithDelim( npcarg, message[Msg_Type], token, sizeof( token)) == NULL ) + return; + } + //送讯息给 CLI + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token ); +} + +void MapTradeManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data) +{ + + if(NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) return; + } + + if( select != WINDOW_BUTTONTYPE_YES ) { + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + return; + } + + switch( seqno) { + case MAPTRADE_MAN: + if( CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT) != MAPTRADE_MAN ) { + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + return; + } + if( CHAR_getInt( talkerindex, CHAR_MAPTRADETYPE) > 0 ) { + char buf1[256]; + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + + sprintf( buf1, "你已经是%d号摊位的主人了呀!", CHAR_getInt( talkerindex, CHAR_MAPTRADETYPE)); + CHAR_talkToCli( talkerindex, -1, buf1, CHAR_COLORYELLOW); + return; + } + NPC_MapTrade_selectWindow( meindex, talkerindex, MAPTRADE_MAN, select); + break; + case MAPTRADE_END: + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + return; + break; + } + return; +} +/* + while( getStringFromIndexWithDelim(buf1, ",", k, buf2, sizeof(buf2)) != FALSE ) { + Re_Pet[k-1] = atoi( buf2); + if( Re_Pet[k-1] < 0 ) + return FALSE; + k++; + if( (k-1) >= arraysizeof( Re_Pet) ) + break; + } +*/ +#endif diff --git a/gmsv/npc/npc_newnpcman.c b/gmsv/npc/npc_newnpcman.c new file mode 100644 index 0000000..0fa0145 --- /dev/null +++ b/gmsv/npc/npc_newnpcman.c @@ -0,0 +1,1182 @@ +#include "version.h" +#include +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "enemy.h" +#include "log.h" +#include "battle.h" +#include "readmap.h" +#include "handletime.h" +#include "npc_eventaction.h" +#include "npc_newnpcman.h" +#include "pet.h" +#define NEWNPCMAN_STANDBY 5000 +#define NEWNPCMAN_WAITTIME 150 +enum { + WINDOW_START=1, + WINDOW_SELECT1, + WINDOW_SELECT2, + WINDOW_SELECT3, + WINDOW_SELECTLOSTPET, + WINDOW_DEFIND, + WINDOW_WARP, + WINDOW_END, + + NPC_PROGRAMEGINEER_START=1, + NPC_PROGRAMEGINEER_SELECT1, + NPC_PROGRAMEGINEER_SELECT2, + NPC_PROGRAMEGINEER_SELECT3, + NPC_PROGRAMEGINEER_SELECTLOSTPET, + NPC_PROGRAMEGINEER_DEFIND, + NPC_PROGRAMEGINEER_END, +}; +enum { + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT1, +/* + 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, +*/ +}; +/* +char UserBBIs[12][256]={ + "小矮子", "赛亚人", "辫子男孩", "酷哥", "熊皮男", "大个", + "小矮妹", "熊皮妹", "帽子妹", "短法发夹妹", "手套女", "辣妹" }; +char PetBBIs[4][256]={//格鲁西斯 贝鲁卡 金格萨贝鲁 贝鲁伊卡 + "格鲁西斯-红虎", "贝鲁卡-绿虎", "金格萨贝鲁-金虎", "贝鲁伊卡-黄虎" }; + +int PlayerBBI[6*2][4]={ + { 100000, 100005, 100010, 100015 }, //小矮子 + { 100025, 100030, 100035, 100020 }, //赛亚人 + { 100055, 100050, 100045, 100040 }, //辫子男孩 + { 100060, 100065, 100070, 100075 }, //酷哥 + { 100095, 100085, 100090, 100080 }, //熊皮男 + { 100100, 100115, 100110, 100115 }, //大个 + + { 100135, 100120, 100125, 100130 }, //小矮妹 + { 100145, 100140, 100150, 100155 }, //熊皮妹 + { 100165, 100170, 100160, 100175 }, //帽子妹 + { 100190, 100195, 100185, 100180 }, //短发发夹妹 + { 100200, 100210, 100215, 100205 }, //手套女 + { 100230, 100225, 100220, 100235 } //辣妹 + }; +*/ + +static int checkPc[48][3]; + +static void NPC_NewNpcMan_selectWindow( int meindex, int toindex, int num, int flg); + +void NPC_reCheckMyPetUnusual( int meindex, int toindex);//检查宠物异常 + +BOOL CHECK_ReplacePET( int toindex); //更换宠物 +void NPC_reCheckItemPilenum( int meindex, int toindex);//还原铁枪叁堆叠 +BOOL CHECK_ITEMEQUIT( int toindex);//更换灵力铠 +BOOL CHECK_PETBBI( int toindex);//修正宠物图号 + +#ifdef _PET_LOSTPET +BOOL NPC_reFindMyLostPet( int meindex, int toindex, char *buf); +BOOL NPC_getLostPetString( int meindex, int toindex); +BOOL NPC_backupLostPetString( int toindex); +static char petstring[7][2048]={"","","","","","",""}; +#endif + +BOOL NPC_NewNpcManInit( int meindex ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("TRANSER_MAN: GetArgStrErr!!"); + return FALSE; + } + + { + int i; + for( i=0; i<48; i++){ + if( i == 0 ){ + checkPc[i][0]=30000; + checkPc[i][1]=30024; + checkPc[i][2]=100000; + }else{ + checkPc[i][0] = checkPc[i-1][0] + 25; + checkPc[i][1] = checkPc[i-1][1] + 25; + checkPc[i][2] = checkPc[i-1][2] + 5; + } +// print("ANDY checkPc:%d[%d,%d,%d]\n", i, checkPc[i][0], checkPc[i][1], checkPc[i][2]); + } + } + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_NEWNPCMAN); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + return TRUE; +} + +void NPC_NewNpcManLoop( int meindex) +{ + +} + +void NPC_NewNpcManTalked( int meindex , int talkerindex , char *msg , int color ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + 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; + } + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("TRANSER_MAN: GetArgStrErr!!"); + return; + } + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + if( CHAR_getInt( talkerindex, CHAR_BASEBASEIMAGENUMBER) != 101578 ){ + NPC_NewNpcMan_selectWindow( meindex, talkerindex, WINDOW_SELECT1, 0); + return; + } + NPC_NewNpcMan_selectWindow( meindex, talkerindex, WINDOW_START, 0); +} + +static void NPC_NewNpcMan_selectWindow( int meindex, int toindex, int num, int flg) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[256]; + + int buttontype = 0, windowtype = 0, windowno = 0; + int fd = getfdFromCharaIndex( toindex); + + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + + 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){ + return; + } + + memset( token, 0, sizeof( token)); + switch( num) { + case WINDOW_START: + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "START_MSG", token, sizeof( token) ) == NULL) { + return; + } + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowno = NPC_PROGRAMEGINEER_DEFIND; + break; + case WINDOW_SELECT1: + sprintf(token," 请选择" + "\n 《修正宠物异常》" + "\n 《修正宠物图号》" + "\n 《更换灵力铠》" +#ifdef _PET_LOSTPET + "\n 《领回遗失宠物》" +#endif +// "\n 《还原铁枪叁堆叠》" + + ); + windowtype = WINDOW_MESSAGETYPE_SELECT; + buttontype = WINDOW_BUTTONTYPE_CANCEL; + windowno = NPC_PROGRAMEGINEER_SELECT2; + break; + case WINDOW_SELECT2: + switch( flg){ + case 1://修正宠物异常 + NPC_reCheckMyPetUnusual( meindex, toindex); + CHAR_talkToCli( toindex, -1, "身上宠物检查完毕!", CHAR_COLORYELLOW); + return; + break; + case 2://修正宠物图号 + CHECK_PETBBI( toindex); + return; + break; + case 3://更换灵力铠 + if( CHECK_ITEMEQUIT( toindex) == TRUE ){ + CHAR_talkToCli( toindex, -1, "检查完毕!", CHAR_COLORYELLOW); + } + return; + break; + + case 4: +#ifdef _PET_LOSTPET + if( NPC_reFindMyLostPet( meindex, toindex, token) == FALSE ){ + CHAR_talkToCli( toindex, -1, "查无资料!", CHAR_COLORYELLOW); + return; + } + windowtype = WINDOW_MESSAGETYPE_SELECT; + buttontype = WINDOW_BUTTONTYPE_CANCEL; + windowno = NPC_PROGRAMEGINEER_SELECTLOSTPET; +#endif + break; + case 5: //还原铁枪叁堆叠 +// NPC_reCheckItemPilenum( meindex, toindex); + return; + break; + } + break; +/* + case WINDOW_SELECT3: + { + int petnum, petindex; + petnum = atoi( data)-1; + if( petnum >= CHAR_MAXPETHAVE || petnum < 0 ) return; + petindex = CHAR_getCharPet( talker, petsel); + if( !CHAR_CHECKINDEX(petindex) ) return; + break; + } +*/ + case WINDOW_SELECTLOSTPET: +#ifdef _PET_LOSTPET + { + int ret, i, ti, ltime, cost; + Char ch; + char msgbuf[256]; + char petstring1[2048]; + + int havepetelement = CHAR_getCharPetElement( toindex); + ti = flg; + if( havepetelement < 0 ){ + CHAR_talkToCli( toindex, -1, "宠物栏位已满!", CHAR_COLORYELLOW); + return; + } + if( NPC_getLostPetString( meindex, toindex) == FALSE ) { + CHAR_talkToCli( toindex, -1, "领取宠物失败!", CHAR_COLORYELLOW); + return; + } + + if( getStringFromIndexWithDelim( petstring[ti-1], "#", 2, petstring1, sizeof( petstring1)) == FALSE ){ + CHAR_talkToCli( toindex, -1, "领取宠物失败!", CHAR_COLORYELLOW); + return; + }else{ + char buf1[256]; + if( getStringFromIndexWithDelim( petstring[ti-1], "|", 6, buf1, sizeof( buf1)) == FALSE ) return; + ltime = atoi(buf1); + ltime = time( NULL) - ltime; + ltime = ltime/(60*60*24); + if( getStringFromIndexWithDelim( petstring[ti-1], "|", 4, buf1, sizeof( buf1)) == FALSE ) return; + cost = atoi( buf1); +#if 0 // 修正保释金 + cost = cost + (ltime*100); + cost = (cost>10000)?10000:cost; +#else + cost = cost + (ltime*10000); +#endif + if( CHAR_getInt( toindex, CHAR_GOLD) < cost ) { + sprintf( buf1, "宠物已寄放%d天,共需%d石币才可领回。", ltime, cost); + CHAR_talkToCli( toindex, meindex, buf1, CHAR_COLORYELLOW); + return; + } + } + + + ret = CHAR_makePetFromStringToArg( petstring1, &ch, -2); + strcpy( petstring[ti-1], ""); + if( ret ) { + char buf1[256]; + int petindex = PET_initCharOneArray( &ch ); + if( !CHAR_CHECKINDEX( petindex) ){ + CHAR_talkToCli( toindex, -1, "领取宠物失败!", CHAR_COLORYELLOW); + return; + } + print("ANDY petindex:%d[%s]\n", petindex, CHAR_getChar( petindex, CHAR_NAME) ); + + CHAR_complianceParameter( petindex ); + CHAR_setInt( petindex, CHAR_HP, CHAR_getWorkInt( petindex, CHAR_WORKMAXHP)); + CHAR_setWorkInt( petindex, CHAR_WORKPLAYERINDEX, toindex); + CHAR_setCharPet( toindex, havepetelement, petindex); + CHAR_setChar( petindex, CHAR_OWNERCDKEY, + CHAR_getChar( toindex, CHAR_CDKEY)); + CHAR_setChar( petindex, CHAR_OWNERCHARANAME, + CHAR_getChar( toindex, CHAR_NAME)); + + if( NPC_backupLostPetString( toindex) == FALSE ){ + print("ANDY err backup petstring !!\n"); + return; + } + + sprintf( buf1, "LostPGet:%d", cost); + LogPet( + CHAR_getChar( toindex, CHAR_NAME ), + CHAR_getChar( toindex, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + buf1, + CHAR_getInt( toindex,CHAR_FLOOR), + CHAR_getInt( toindex,CHAR_X ), + CHAR_getInt( toindex,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + sprintf( buf1, "领取宠物%s。", CHAR_getUseName( petindex)); + CHAR_talkToCli( toindex, meindex, buf1, CHAR_COLORYELLOW); + for( i = 0; i < CHAR_MAXPETHAVE; i++){ + int petindex = CHAR_getCharPet( toindex, i); + if( !CHAR_CHECKINDEX( petindex) ) + continue; + CHAR_complianceParameter( petindex ); + snprintf( msgbuf, sizeof( msgbuf ), "K%d", i ); + CHAR_sendStatusString( toindex, msgbuf ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d", i ); + CHAR_sendStatusString( toindex, msgbuf ); + } + CHAR_DelGold( toindex, cost); + }else{ + CHAR_talkToCli( toindex, -1, "领取宠物失败!", CHAR_COLORYELLOW); + return; + } + return; + } +#endif + return; + break; + case WINDOW_DEFIND: + { + int i; + int face = CHAR_getInt( toindex, CHAR_FACEIMAGENUMBER); + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "CHECK_MSG", token, sizeof( token) ) == NULL) { + return; + } + for( i=0; i<48; i++){ + if( face >= checkPc[i][0] && face < checkPc[i][1] ) + break; + } + if( i >= 48 )return; + CHAR_setWorkInt( toindex, CHAR_WORKNPCMETAMO, meindex); + CHAR_setInt( toindex, CHAR_BASEIMAGENUMBER, checkPc[i][2]); + CHAR_complianceParameter( toindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( toindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( toindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowno = NPC_PROGRAMEGINEER_END; + } + break; + case WINDOW_END: + { + CHAR_setWorkInt( toindex, CHAR_WORKNPCMETAMO, -1); + CHAR_setInt( toindex, CHAR_BASEBASEIMAGENUMBER, + CHAR_getInt( toindex, CHAR_BASEIMAGENUMBER) ); + + CHAR_complianceParameter( toindex ); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( toindex , CHAR_WORKOBJINDEX )); + CHAR_send_P_StatusString( toindex , CHAR_P_STRING_BASEBASEIMAGENUMBER); + return; + } + break; + } + + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token); +} + +void NPC_NewNpcManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data) +{ + if(NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) + return; + } + + if( select == WINDOW_BUTTONTYPE_CANCEL || select == WINDOW_BUTTONTYPE_NO){ + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + CHAR_setWorkInt( talkerindex, CHAR_WORKNPCMETAMO, -1); + return; + } + switch( seqno) { + case NPC_TRANSERMAN_START: + break; + case NPC_PROGRAMEGINEER_SELECT1: + NPC_NewNpcMan_selectWindow( meindex, talkerindex, WINDOW_SELECT1, atoi( data)); + break; + case NPC_PROGRAMEGINEER_SELECT2: + NPC_NewNpcMan_selectWindow( meindex, talkerindex, WINDOW_SELECT2, atoi( data)); + break; + case NPC_PROGRAMEGINEER_SELECT3: + NPC_NewNpcMan_selectWindow( meindex, talkerindex, WINDOW_SELECT3, atoi( data)); + break; + case NPC_PROGRAMEGINEER_SELECTLOSTPET: + NPC_NewNpcMan_selectWindow( meindex, talkerindex, WINDOW_SELECTLOSTPET, atoi( data)); + break; + case NPC_PROGRAMEGINEER_DEFIND: + NPC_NewNpcMan_selectWindow( meindex, talkerindex, WINDOW_DEFIND, atoi( data)); + break; + case NPC_PROGRAMEGINEER_END: + NPC_NewNpcMan_selectWindow( meindex, talkerindex, WINDOW_END, atoi( data)); + break; + } +} + +BOOL CHECK_ITEMEQUIT( int toindex) +{ + int i, itemindex; + char token[256]; + + for (i = CHAR_STARTITEMARRAY; i < CHAR_MAXITEMHAVE; i ++) { + itemindex = CHAR_getItemIndex( toindex, i); + if( ITEM_getInt( itemindex, ITEM_ID) == 19646 ){ + CHAR_DelItem( toindex, i); + itemindex = -1; + itemindex = ITEM_makeItemAndRegist( 1292); + if( !ITEM_CHECKINDEX( itemindex) ){ + }else{ + int ret = CHAR_addItemSpecificItemIndex( toindex, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + ITEM_endExistItemsOne( itemindex); + continue; + } + sprintf( token,"拿到%s", ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( toindex, -1, token, CHAR_COLORYELLOW ); + CHAR_sendItemDataOne( toindex, ret); + continue; + } + } + if( ITEM_getInt( itemindex, ITEM_ID) == 1292 && + ITEM_getInt( itemindex, ITEM_MAXDAMAGECRUSHE) > 0 ){ + + ITEM_setInt( itemindex, ITEM_MAXDAMAGECRUSHE, 0); + ITEM_setInt( itemindex, ITEM_DAMAGECRUSHE, 0); + sprintf(token,"修正%s损坏度", ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_sendItemDataOne( toindex, i); + CHAR_talkToCli( toindex, -1, token, CHAR_COLORYELLOW); + } + } + + // 寄放店 + for (i = 0; i < CHAR_MAXPOOLITEMHAVE; i++) { + if( ITEM_getInt( itemindex, ITEM_ID) == 1292 && + ITEM_getInt( itemindex, ITEM_MAXDAMAGECRUSHE) > 0 ){ + + ITEM_setInt( itemindex, ITEM_MAXDAMAGECRUSHE, 0); + ITEM_setInt( itemindex, ITEM_DAMAGECRUSHE, 0); + sprintf(token,"修正寄放店中%s损坏度", ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( toindex, -1, token, CHAR_COLORYELLOW); + } + } + + return TRUE; +} + + +BOOL CHECK_PETBBI( int toindex) +{ + int i, petindex, PetID; + BOOL Finds = FALSE; + char token[256]; + for( i=0; i < CHAR_MAXPETHAVE; i++) { + int parry, array, PetBBI; + petindex = CHAR_getCharPet( toindex, i); + if( !CHAR_CHECKINDEX( petindex) ) continue; + PetID = CHAR_getInt( petindex, CHAR_PETID); + array = ENEMY_getEnemyArrayFromTempNo( PetID); + if( !ENEMY_CHECKINDEX( array)) continue; + parry = ENEMYTEMP_getEnemyTempArray( array); + PetBBI = ENEMYTEMP_getInt( parry, E_T_IMGNUMBER); + + if( CHAR_getInt( petindex, CHAR_BASEBASEIMAGENUMBER) != PetBBI || + CHAR_getInt( petindex, CHAR_BASEIMAGENUMBER) != PetBBI ){ + CHAR_setInt( petindex, CHAR_BASEBASEIMAGENUMBER, PetBBI); + CHAR_setInt( petindex, CHAR_BASEIMAGENUMBER, PetBBI); + sprintf( token, "修正%s图号", CHAR_getUseName( petindex)); + CHAR_talkToCli( toindex, -1, token, CHAR_COLORYELLOW); + Finds = TRUE; + } + CHAR_setInt( petindex, CHAR_EARTHAT, ENEMYTEMP_getInt( parry, E_T_EARTHAT) ); + CHAR_setInt( petindex, CHAR_WATERAT, ENEMYTEMP_getInt( parry, E_T_WATERAT) ); + CHAR_setInt( petindex, CHAR_FIREAT, ENEMYTEMP_getInt( parry, E_T_FIREAT) ); + CHAR_setInt( petindex, CHAR_WINDAT, ENEMYTEMP_getInt( parry, E_T_WINDAT) ); + } + for( i=0; i %s (%s:%s)(file:%s %d) !! \n", + petID, PetNAME, CHAR_getUseName( toindex), + CHAR_getChar( toindex, CHAR_CDKEY), __FILE__, __LINE__ ); + } + } + + for( i=0; i 0 )continue; + + if( i == CHAR_getInt( toindex, CHAR_DEFAULTPET) ) { + int fd = getfdFromCharaIndex( toindex); + CHAR_setInt( toindex, CHAR_DEFAULTPET, -1); + lssproto_KS_send( fd, -1, TRUE); + } + + snprintf( szPet,sizeof( szPet), "交出%s。", CHAR_getUseName( petindex) ); + CHAR_talkToCli( toindex, -1, szPet, CHAR_COLORYELLOW); + LogPet( + CHAR_getChar( toindex, CHAR_NAME ), + CHAR_getChar( toindex, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "TenseiDel", + CHAR_getInt( toindex,CHAR_FLOOR), + CHAR_getInt( toindex,CHAR_X ), + CHAR_getInt( toindex,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) + ); + + Finds = TRUE; + CHAR_setCharPet( toindex, i, -1); + CHAR_endCharOneArray( petindex ); + + array = ENEMY_getEnemyArrayFromTempNo( 1133); + if( !ENEMY_CHECKINDEX( array)) continue; + ret = ENEMY_createPetFromEnemyIndex( toindex, array); + if( !CHAR_CHECKINDEX( ret ) ) continue; + + snprintf( szPet, sizeof( szPet), "拿到%s。", CHAR_getUseName( ret) ); + CHAR_talkToCli( toindex, -1, szPet, CHAR_COLORWHITE); + + LogPet( + CHAR_getChar( toindex, CHAR_NAME ), + CHAR_getChar( toindex, CHAR_CDKEY ), + CHAR_getChar( ret, CHAR_NAME), + CHAR_getInt( ret, CHAR_LV), + "TenseiGet", + CHAR_getInt( toindex,CHAR_FLOOR), + CHAR_getInt( toindex,CHAR_X ), + CHAR_getInt( toindex,CHAR_Y ), + CHAR_getChar( ret, CHAR_UNIQUECODE) + ); + + } + + for( i=0; i 1 ){ + int itemID, pilenum=1, newindex; + itemID = ITEM_getInt( itemindex, ITEM_ID); + if( !ITEM_CHECKITEMTABLE( itemID) ) continue; + pilenum = ITEM_getInt( itemindex, ITEM_USEPILENUMS); + while( pilenum > 1 ){ + int ti = CHAR_findEmptyItemBox( toindex); + if( ti == -1 ){ + CHAR_sendItemDataOne( toindex, i); + CHAR_talkToCli( toindex, -1, "道具栏位已满。", CHAR_COLORYELLOW); + return; + } + newindex = ITEM_makeItemAndRegist( itemID); + if( !ITEM_CHECKINDEX( newindex) ) break; + CHAR_setItemIndex( toindex , ti, newindex); + CHAR_sendItemDataOne( toindex, ti); + pilenum--; + ITEM_setInt( itemindex, ITEM_USEPILENUMS, pilenum); + } + if( ITEM_getInt( itemindex, ITEM_CANBEPILE) != ITEMTBL_getInt( itemID, ITEM_CANBEPILE) ) + ITEM_setInt( itemindex, ITEM_CANBEPILE, ITEMTBL_getInt( itemID, ITEM_CANBEPILE) ); + CHAR_sendItemDataOne( toindex, i); + } + } + CHAR_talkToCli( toindex, -1, "铁枪叁处理完毕。", CHAR_COLORYELLOW); +} + +#ifdef _PET_LOSTPET +BOOL NPC_reFindMyLostPet( int meindex, int toindex, char *buf) +{ + //地上0 溜宠 1 宠邮 2 + FILE *fp = NULL; + char *CdKey=NULL; + int lv=0, cost, ltime, count=0, i, type; + char filename[256], line[2048], buf1[256]; + char petname[256], typebuf[256]; + char buf2[10][256]={"\n","\n","\n","\n","\n", + "\n","\n","\n","\n","\n" }; + CdKey = CHAR_getChar( toindex, CHAR_CDKEY ); + if( CdKey == NULL ) return FALSE; + sprintf( filename, "lostpet/%s.txt", CdKey); + strcpy( buf, "==宠物遗失纪录==\n"); + if( (fp=fopen( filename, "r")) == NULL ) return FALSE; + + while( fgets( line , sizeof( line ) , fp ) && count < 7){ + if( line == NULL ) continue; + if( getStringFromIndexWithDelim( line, "|", 1, buf1, sizeof( buf1)) == FALSE ) continue; + if( strcmp( CHAR_getChar( toindex, CHAR_CDKEY ), buf1 )) continue; + if( getStringFromIndexWithDelim( line, "|", 6, buf1, sizeof( buf1)) == FALSE ) continue; + ltime = atoi(buf1); + ltime = time( NULL) - ltime; + ltime = ltime/(60*60*24); + if( ltime > 14 ) continue;//续放14天 + + if( getStringFromIndexWithDelim( line, "|", 2, petname, sizeof( petname)) == FALSE ) continue; + if( getStringFromIndexWithDelim( line, "|", 3, buf1, sizeof( buf1)) == FALSE ) continue; + lv = atoi( buf1); + if( getStringFromIndexWithDelim( line, "|", 4, buf1, sizeof( buf1)) == FALSE ) continue; + cost = atoi( buf1); + + if( getStringFromIndexWithDelim( line, "#", 3, buf1, sizeof( buf1)) == FALSE ) continue; + type = atoi( buf1); + if( type == 1 ){ + strcpy( typebuf, "溜宠"); + }else if( type == 2 ){ + strcpy( typebuf, "宠邮"); + }else{ + strcpy( typebuf, "地上"); + } + + sprintf( buf2[count++], "%s LV:%d石币:%d(%d天%s)\n", petname, lv, cost, ltime, typebuf); + } + fclose( fp); + for( i=0; i<7; i++){ + strcat( buf, buf2[i]); + } + if( count == 0 ) return FALSE; + return TRUE; +} + +BOOL NPC_getLostPetString( int meindex, int toindex) +{ + FILE *fp = NULL; + char *CdKey=NULL; + int count=0, i, ltime; + char filename[256], line[2048], buf1[256]; + + for( i=0; i<7; i++) + strcpy( petstring[i], ""); + + CdKey = CHAR_getChar( toindex, CHAR_CDKEY ); + if( CdKey == NULL ) return FALSE; + sprintf( filename, "lostpet/%s.txt", CdKey); + if( (fp=fopen( filename, "r")) == NULL ) return FALSE; + + while( fgets( line , sizeof( line ) , fp ) && count < 7){ + if(strlen( line) <= 0 ) continue; +// if( getStringFromIndexWithDelim( line, "#", 2, buf1, sizeof( buf1)) == FALSE ) return FALSE; +// Terry fix 读取时没有判断时间 2004/09/22 + if(getStringFromIndexWithDelim(line,"|",6,buf1,sizeof(buf1)) == FALSE) continue; + ltime = atoi(buf1); + ltime = time( NULL) - ltime; + ltime = ltime/(60*60*24); + if(ltime > 14) continue;//续放14天 +// Terry end + strcpy( petstring[count++], line); + } + + fclose( fp); + return TRUE; +} + +BOOL NPC_backupLostPetString( int toindex) +{ + FILE *fp = NULL; + char *CdKey=NULL; + int i, count=0; + char filename[256]; + + CdKey = CHAR_getChar( toindex, CHAR_CDKEY ); + if( CdKey == NULL ) return FALSE; + sprintf( filename, "lostpet/%s.txt", CdKey); + if( (fp=fopen( filename, "w")) == NULL ) return FALSE; + + for( i=0; i<7; i++){ + if( strlen( petstring[i]) <= 0 ) continue; + fprintf( fp, "%s", petstring[i]); + count++; + } + fclose( fp); + + if( count == 0 ) + remove( filename); + + return TRUE; +} + +/* + + +#ifdef _NEW_WARPMAN +#include "npc_newnpcman.h" +#define NEWNPCMAN_STANDBY 5000 +#define NEWNPCMAN_WAITTIME 150 + +enum{ +NPC_NEWNPCMAN_START=21, +NPC_NEWNPCMAN_MAN, +NPC_NEWNPCMAN_END, +}; + +enum { + NEWNPC_START = 1, + NEWNPC_MAN, + NEWNPC_END, +}; + +enum { + NPC_WORK_INDEX = CHAR_NPCWORKINT1, + NPC_WORK_WORKTYPE = CHAR_NPCWORKINT2, + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT3, +}; + +BOOL CHECK_YEARPET( int toindex); +static void NPC_NewNpcMan_selectWindow( int meindex, int toindex, int num, int flg); +int NPC_NewNpcManDelPet(int meindex,int talker, int petsel); +BOOL NPC_NewNpcManAddPet(int meindex, int talker, int petid); + +//可换四种宠 +static int Re_Pet[4]; +// shan +char uStr[128]=""; + +BOOL NPC_NewNpcManInit( int meindex ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf1[256],buf2[256]; + int k=1; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg)) == NULL) { + print("GambleBank:GetArgStrErr"); + return FALSE; + } + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "REPET", buf1, sizeof( buf1)) == NULL ) { + return FALSE; + } + + while( getStringFromIndexWithDelim(buf1, ",", k, buf2, sizeof(buf2)) != FALSE ) { + Re_Pet[k-1] = atoi( buf2); + if( Re_Pet[k-1] < 0 ) + return FALSE; + k++; + if( (k-1) >= arraysizeof( Re_Pet) ) + break; + } + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_NEWNPCMAN ); + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, NEWNPCMAN_STANDBY); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, -1); + return TRUE; +} + +void NPC_NewNpcManLoop( int meindex) +{ + //test + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf1[256],buf2[256]; + int k=1; + + int fulltime = NEWNPCMAN_WAITTIME; + if( (CHAR_getWorkInt( meindex, NPC_WORK_CURRENTTIME) + fulltime) > NowTime.tv_sec ) + return; + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, -1); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + + //test + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg)) == NULL) { + print("GambleBank:GetArgStrErr"); + return; + } + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "REPET", buf1, sizeof( buf1)) == NULL ) { + return; + } + + while( getStringFromIndexWithDelim(buf1, ",", k, buf2, sizeof(buf2)) != FALSE ) { + Re_Pet[k-1] = atoi( buf2); + if( Re_Pet[k-1] < 0 ) + return; + k++; + if( (k-1) >= arraysizeof( Re_Pet) ) + break; + } + //test end +} + +void NPC_NewNpcManTalked( int meindex , int talkerindex , char *msg , int color ) +{ + char buf1[256]; + + 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; + } + + if( CHAR_getWorkInt( meindex , NPC_WORK_INDEX) >= 0 ) { + sprintf( buf1,"%s","我正忙着呢!"); + print("\n NPC_WORK_INDEX = %d ", CHAR_getWorkInt( meindex , NPC_WORK_INDEX)); + CHAR_talkToCli( talkerindex, meindex, buf1, CHAR_COLORYELLOW); + return; + }else { + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, talkerindex); + print("\n start : NPC_WORK_INDEX = talkerindex"); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + NPC_NewNpcMan_selectWindow( meindex, talkerindex, NEWNPC_START, 0); + } +} + +static void NPC_NewNpcMan_selectWindow( int meindex, int toindex, int num, int flg) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[256]; + char token_str[][56]={"ERROR_MSG","START_MSG","END_MSG","ERROR_ALL"}; + int buttontype = 0, windowtype = 0, windowno = 0; + int fd = getfdFromCharaIndex( toindex); + int petno = 718, petid =1479; + int type_str = 0; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg)) == NULL) { + print("GambleBank:GetArgStrErr"); + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, -1); + return ; + } + + if( CHAR_getWorkInt( meindex , NPC_WORK_INDEX) != toindex ) { + sprintf( token,"%s","我正忙着呢!"); + CHAR_talkToCli( toindex, meindex, token, CHAR_COLORYELLOW); + return; + } + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + print("\n switch( num=%d)", num); + switch( num) { + case NEWNPC_START: + type_str = 1; + buttontype = WINDOW_BUTTONTYPE_OKCANCEL; + windowno = NPC_NEWNPCMAN_START; + break; + + case NEWNPC_MAN: + { + if( CHECK_YEARPET( toindex) == TRUE ) { + type_str = 1; + windowtype = WINDOW_MESSAGETYPE_PETSELECT; + buttontype = WINDOW_BUTTONTYPE_CANCEL; + windowno = NPC_NEWNPCMAN_MAN; + }else { + type_str = 3; + buttontype = WINDOW_BUTTONTYPE_OK; + windowno = NPC_NEWNPCMAN_END; + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, -1); + } + } + break; + + case NEWNPC_END: + type_str = 0; + if( flg <= CHAR_MAXPETHAVE && flg >= 0 ) { + petno = flg; + + if( ( petid = NPC_NewNpcManDelPet( meindex, toindex, petno)) >= 0 ) { + if( NPC_NewNpcManAddPet( meindex, toindex, petid) == TRUE ) { + type_str = 2; + } + } + } + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, -1); + buttontype = WINDOW_BUTTONTYPE_OK; + windowno = NPC_NEWNPCMAN_END; + + break; + } + + if(NPC_Util_GetStrFromStrWithDelim( npcarg, token_str[ type_str], token,sizeof( token) ) == NULL) { + print("token_str[%d] err !", type_str); + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, -1); + return; + } + + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token); +} + +void NPC_NewNpcManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data) +{ + + 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; + } + + print("\n seqno=%d, select=%d", seqno, select); + switch( seqno) { + case NPC_NEWNPCMAN_START: + if( select != WINDOW_BUTTONTYPE_YES && select != WINDOW_BUTTONTYPE_OK ) { + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, -1); + return; + } + if(select==WINDOW_BUTTONTYPE_CANCEL) { + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, -1); + }else { + NPC_NewNpcMan_selectWindow( meindex, talkerindex, NEWNPC_MAN, -1); + } + break; + + case NPC_NEWNPCMAN_MAN: + { + int petnum; + petnum = atoi( data)-1; + + print("\n petnum=%d", petnum); + if(select==WINDOW_BUTTONTYPE_CANCEL) { + CHAR_setWorkInt( meindex , NPC_WORK_INDEX, -1); + }else { + NPC_NewNpcMan_selectWindow( meindex, talkerindex, NEWNPC_END, petnum); + } + } + break; + + case NPC_NEWNPCMAN_END: + break; + } +} + +int NPC_NewNpcManDelPet(int meindex,int talker, int petsel) +{ + int defpet; + int fd = getfdFromCharaIndex( talker ); + char msgbuf[64], szPet[128]; + int k=0; + int petindex=-1; + + petindex = CHAR_getCharPet( talker, petsel); + if( !CHAR_CHECKINDEX(petindex) ) + return -1; + + for( k=0;k +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "npc_npcenemy.h" +#include "battle.h" +#include "enemy.h" +#include "readmap.h" +#include "encount.h" +#include "lssproto_serv.h" +#include "configfile.h" +#include "anim_tbl.h" +#include "handletime.h" +#include "npc_eventaction.h" + +enum { + CHAR_WORK_ENCOUNTTYPE = CHAR_NPCWORKINT1, /* 巨件市它件玄及酷 */ + CHAR_WORK_DIEACT = CHAR_NPCWORKINT2, /* 韶氏分凛升丹允月井 */ + CHAR_WORK_WARP_FLOOR = CHAR_NPCWORKINT3, /* 伐□皿允月白夫失*/ + CHAR_WORK_WARP_X = CHAR_NPCWORKINT4, /* 伐□皿允月X */ + CHAR_WORK_WARP_Y = CHAR_NPCWORKINT5, /* 伐□皿允月Y */ + CHAR_WORK_ONEBATTLE = CHAR_NPCWORKINT6, /* 域勾仄井爵 仄卅中 */ + NPC_TIME_MODE = CHAR_NPCWORKINT7, + CHAR_WORK_BASEIMGBAK = CHAR_NPCWORKINT8, /* 手午及 飓 寞 */ + CHAR_WORK_DIETIME = CHAR_NPCWORKINT9, /* 韶氏分凛棉 */ + CHAR_WORK_REVIVALTIME = CHAR_NPCWORKINT10, /* 戏五忒月凛棉 */ + CHAR_WORK_BATTLETYPE = CHAR_NPCWORKINT11, +}; + +#define NPC_ENEMY_REVIVALTIMA_DEFAULT 120 + +static int gymbody[] = { + SPR_001em,SPR_011em,SPR_021em,SPR_031em,SPR_041em,SPR_051em, + SPR_061em,SPR_071em,SPR_081em,SPR_091em,SPR_101em,SPR_111em, + + SPR_002em,SPR_012em,SPR_022em,SPR_032em,SPR_042em,SPR_052em, + SPR_062em,SPR_072em,SPR_082em,SPR_092em,SPR_102em,SPR_112em, + + SPR_003em,SPR_013em,SPR_023em,SPR_033em,SPR_043em,SPR_053em, + SPR_063em,SPR_073em,SPR_083em,SPR_093em,SPR_103em,SPR_113em, + + SPR_004em,SPR_014em,SPR_024em,SPR_034em,SPR_044em,SPR_054em, + SPR_064em,SPR_074em,SPR_084em,SPR_094em,SPR_104em,SPR_114em, +}; + +#ifdef _NEW_WARPMAN +static BOOL NPC_NPCEnemy_CheckFree( int meindex, int toindex, BOOL *Party); +BOOL NPC_WarpAllMsg(int meindex,int toindex ); +BOOL NPCEnemy_CheckFree( int meindex, int talker, char *buf); +BOOL NPCEnemy_BSCheck(int meindex,int talker,char* buf); +BOOL NPCEnemy_FreeIfCheck(int meindex,int talker,char* buf,int kosuu,int flg, int temp); +BOOL NPCEnemy_WarpManReduce(int meindex,int talker,char *buf); +BOOL NPCEnemy_BigSmallLastCheck(int point1,int mypoint,int flg); +BOOL NPCEnemy_CheckTrans(int meindex,int talker,int trans,int flg); +BOOL NPCEnemy_LevelCheck(int meindex,int talker,int level,int flg); +BOOL NPCEnemy_CheckMyPet( int meindex, int talker, int petLv, int flg, int petid); +BOOL NPCEnemy_ItemCheck(int meindex,int talker,int itemNo,int flg); +#endif +#ifdef _NPC_REPLACEMENT +void Check_EnemyWarpMe( int meindex, char *args ); +#endif +static int NPC_NPCEnemy_StealItem( char *argstr, int meindex, int charaindex); + +BOOL NPC_NPCEnemyInit( int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[64]; + int tmp, gym; + + + if( NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL ) { + print("Can't GetArgStr !!"); + return FALSE; + } + if( NPC_Util_GetStrFromStrWithDelim( argstr, "sktype", buf, sizeof( buf)) != NULL ){ + CHAR_setWorkInt( meindex, CHAR_WORK_BATTLETYPE, atoi( buf)); + }else{ + CHAR_setWorkInt( meindex, CHAR_WORK_BATTLETYPE, 0); + } + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "enemyno", buf, sizeof( buf)) == NULL ){ + char filename[256]; + NPC_Util_CheckAssignArgFile( meindex, filename); + print( "NPCEnemy: nothing parameter [enemyno]:\n%s\n", filename); + return FALSE; + }else { + int i; + for( i = 0; i < NPC_ENEMY_ENEMYNUMBER; i ++ ) { + int curEnemy; + char data[128]; + int ret; + ret = getStringFromIndexWithDelim( buf,",", i + 1, data, sizeof(data)); + if( ret == FALSE) + break; + curEnemy = ENEMY_getEnemyArrayFromId( atoi( data)); + if( !ENEMY_CHECKINDEX( curEnemy) ) { + char filename[256]; + NPC_Util_CheckAssignArgFile( meindex, filename); + print( "NPCEnemy: invalid param [enemyno:%d data:%s curEnemy:%d]\nfile:%s\n",i+1, data, curEnemy, filename ); + return FALSE; + } + } + } + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "steal", buf, sizeof( buf)) != NULL ) { + if( NPC_Util_GetStrFromStrWithDelim( argstr, "item", buf, sizeof( buf)) == NULL ) { + print( "NPCEnemy:有指定steal而没有指定item,很奇怪\n"); + return FALSE; + } + } + + gym = NPC_Util_GetNumFromStrWithDelim( argstr, "gym"); + + if( gym > 0 ){ + CHAR_setInt( meindex, CHAR_BASEBASEIMAGENUMBER, + gymbody[RAND( 0, arraysizeof( gymbody ) - 1)] ); + CHAR_setInt( meindex, CHAR_BASEIMAGENUMBER, + CHAR_getInt( meindex, CHAR_BASEBASEIMAGENUMBER ) ); + CHAR_setInt( meindex, CHAR_LV, gym ); + } + tmp = NPC_Util_GetNumFromStrWithDelim( argstr, "dieact"); + if( tmp != 1 ) + tmp = 0; + CHAR_setWorkInt( meindex, CHAR_WORK_DIEACT, tmp); + if( strstr( argstr, "NEWNPCENEMY") != 0 ) { + CHAR_setWorkInt( meindex, CHAR_WORK_WARP_FLOOR, 0 ); + CHAR_setWorkInt( meindex, CHAR_WORK_WARP_Y, 0 ); + CHAR_setWorkInt( meindex, CHAR_WORK_WARP_X, 0 ); + }else { + if( CHAR_getWorkInt( meindex, CHAR_WORK_DIEACT) == 1 ) { + char buff1[256]; + if( NPC_Util_GetStrFromStrWithDelim( argstr, "warpfl", buff1, sizeof( buff1) ) == NULL) { + print( "NPCENEMY: nothing warp_floor %s\n", buff1); + return FALSE; + } + tmp = atoi( buff1); + CHAR_setWorkInt( meindex, CHAR_WORK_WARP_FLOOR, tmp); + if( NPC_Util_GetStrFromStrWithDelim( argstr, "warpx", buff1, sizeof( buff1) ) == NULL) { + print( "NPCENEMY: nothing warp_x\n"); + return FALSE; + } + tmp = atoi( buff1); + CHAR_setWorkInt( meindex, CHAR_WORK_WARP_X, tmp); + if( NPC_Util_GetStrFromStrWithDelim( argstr, "warpy", buff1, sizeof( buff1) ) == NULL) { + print( "NPCENEMY: nothing warp_y\n"); + return FALSE; + } + tmp = atoi( buff1); + CHAR_setWorkInt( meindex, CHAR_WORK_WARP_Y, tmp); + if( MAP_IsValidCoordinate( CHAR_getWorkInt( meindex, CHAR_WORK_WARP_FLOOR), + CHAR_getWorkInt( meindex, CHAR_WORK_WARP_X), + CHAR_getWorkInt( meindex, CHAR_WORK_WARP_Y) ) == FALSE ){ + char filename[256]; + NPC_Util_CheckAssignArgFile( meindex, filename); + print( "NPCENEMY: %s: .\n %s.\nInvalid fl=%d,x=%d,y=%d\n", filename, argstr, + CHAR_getWorkInt( meindex, CHAR_WORK_WARP_FLOOR), + CHAR_getWorkInt( meindex, CHAR_WORK_WARP_X), + CHAR_getWorkInt( meindex, CHAR_WORK_WARP_Y) ); + return FALSE; + } + } + } + //andy_end + tmp = NPC_Util_GetNumFromStrWithDelim( argstr, "entype"); + if( tmp != 1 && tmp != 2) + tmp = 0; + CHAR_setWorkInt( meindex, CHAR_WORK_ENCOUNTTYPE, tmp); + + tmp = NPC_Util_GetNumFromStrWithDelim( argstr, "onebattle"); + if( tmp != 1 ) + tmp = 0; + CHAR_setWorkInt( meindex, CHAR_WORK_ONEBATTLE, tmp); + + tmp = NPC_Util_GetNumFromStrWithDelim( argstr, "time"); + if( tmp == -1 ) + tmp = NPC_ENEMY_REVIVALTIMA_DEFAULT; + CHAR_setWorkInt( meindex, CHAR_WORK_REVIVALTIME, tmp); + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPENPCENEMY ); + CHAR_setWorkInt( meindex, CHAR_WORKEVENTTYPE, CHAR_EVENT_ENEMY); + CHAR_setWorkInt( meindex, CHAR_WORK_BASEIMGBAK, + CHAR_getInt( meindex, CHAR_BASEIMAGENUMBER)); + return TRUE; +} + +void NPC_NPCEnemyTalked( int meindex , int talkerindex , char *szMes , + int color ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[256]; + + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + if( NPC_Util_GetArgStr( meindex, npcarg, sizeof( npcarg)) == NULL ) { + print("Can't GetArgStr !!"); + return; + } + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "NEWTIME", buf, sizeof( buf)) != NULL ){ + if( CHAR_getWorkInt( meindex, NPC_TIME_MODE) <= 0 ) { + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "Time_Msg", buf, sizeof( buf) ) != NULL) { + CHAR_talkToCli( talkerindex, meindex, buf, CHAR_COLORYELLOW); + } + return; + } + } + if( !NPC_Util_charIsInFrontOfChar( talkerindex, meindex, 1 )) + return; + if( CHAR_getWorkInt( meindex, CHAR_WORK_ENCOUNTTYPE) >= 1 ) { + NPC_NPCEnemy_Encount( meindex, talkerindex, 1); + } +} + +int NPC_NPCEnemy_Encount( int meindex, int charaindex, int mode) +{ + + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[512]; + BOOL flg = TRUE; + int battlemax = getBattlenum(); + int i; + if( CHAR_getInt( meindex, CHAR_BASEIMAGENUMBER) == 0 ) { + return FALSE; + } + if( mode == 0 ) { + if( CHAR_getWorkInt( meindex, CHAR_WORK_ENCOUNTTYPE) == 1 ) { + flg = FALSE; + } + }else if( mode == 1 ) { + if( CHAR_getWorkInt( meindex, CHAR_WORK_ENCOUNTTYPE) == 0 ) { + flg = FALSE; + } + } + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + if( !flg) { + if( NPC_Util_GetStrFromStrWithDelim( argstr, "deniedmsg", buf, sizeof( buf)) != NULL ) { + CHAR_talkToCliAndParty( charaindex, meindex ,buf , CHAR_COLORYELLOW ); + } + return FALSE; + } + flg = FALSE; + while( 1 ) { + char buf[1024]; + if( NPC_Util_GetStrFromStrWithDelim( argstr, "item", buf, sizeof( buf)) != NULL ) { + char data[128]; + BOOL found = FALSE; + + for( i = 0; i < CHAR_MAXITEMHAVE; i ++ ) { + int j; + int itemid; + int ret = getStringFromIndexWithDelim( buf,",", i + 1,data, sizeof(data)); + if( ret == FALSE) + break; + found = FALSE; + itemid = atoi( data); + for( j = 0; j < CHAR_MAXITEMHAVE; j ++ ) { + int itemindex = CHAR_getItemIndex( charaindex, j); + if( ITEM_CHECKINDEX( itemindex)) { + if( ITEM_getInt( itemindex, ITEM_ID) == itemid ) { + found = TRUE; + break; + } + } + } + if( !found ) + break; + } + if( !found ) + break; + } +#ifdef _ADD_NOITEM_BATTLE + if(NPC_Util_GetStrFromStrWithDelim(argstr,"noitem",buf,sizeof(buf)) != NULL){ + char data[128]; + BOOL found = FALSE; + + for(i=0;i= sizeof( buf) ) { + print( "buffer over\n"); + return FALSE; + } + } + else { + strcpysafe( &buf[len], sizeof( buf)-len, "\n" ); + len++; + if( len >= sizeof( buf) ) { + print( "buffer over\n"); + return FALSE; + } + } + } + + if( fd != -1 ) { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_YESNO, + CHAR_WINDOWTYPE_NPCENEMY_START, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( buf, escapebuf,sizeof(escapebuf))); + } + /* 仇仇分仃 卞伉正□件 */ + return FALSE; + }else { + /* 爵 卞 日六月 */ + flg = NPC_NPCEnemy_BattleIn( meindex, charaindex); + } + } + } + if( !flg) { + if( NPC_Util_GetStrFromStrWithDelim( argstr, "deniedmsg", buf, sizeof( buf)) + != NULL ) + { + CHAR_talkToCliAndParty( charaindex, meindex ,buf , CHAR_COLORYELLOW ); + } + } + return flg; +} + +int NPC_NPCEnemy_Dying( int battleindex, int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[64]; + int i,toindex=-1; + int tmp=-1; + + if( !CHAR_CHECKINDEX( meindex)) { + return FALSE; + } + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + +#ifdef _NEW_WARPMAN + if( strstr( argstr, "NEWNPCENEMY") ) { + }else { +#endif + /* 蝇 及陲太 */ + if( NPC_Util_GetStrFromStrWithDelim( argstr, "endmsg", buf, sizeof( buf)) != NULL ) { + for( i = 0; i < 5; i ++ ) { + /* 爵 卞辅笛仄化中月蝈够卞丢永本□斥 */ + int toindex = BattleArray[battleindex].Side[0].Entry[i].charaindex; + if( CHAR_CHECKINDEX( toindex) ) { + CHAR_talkToCli( toindex, meindex ,buf , CHAR_COLORYELLOW ); + } + } + + } +#ifdef _NEW_WARPMAN + } +#endif + if( NPC_Util_GetStrFromStrWithDelim( argstr, "steal", buf, sizeof( buf)) != NULL ) { + print("\n steal TRUE !!"); + if( atoi( buf) == 1 ) { + int charaindex = BattleArray[battleindex].Side[0].Entry[0].charaindex; + NPC_NPCEnemy_StealItem( argstr, meindex, charaindex); + } + + } +#ifdef _ALLDOMAN // (不可开) Syu ADD 排行榜NPC + if( NPC_Util_GetStrFromStrWithDelim( argstr, "herobattlefield", buf, sizeof( buf)) != NULL ) { + int charaindex = BattleArray[battleindex].Side[0].Entry[0].charaindex; + CHAR_setWorkInt ( charaindex , CHAR_WORKHEROFLOOR , atoi ( buf ) ) ; + // Syu ADD + if ( atoi ( buf ) > CHAR_getInt ( charaindex , CHAR_HEROFLOOR ) ) + CHAR_setInt ( charaindex , CHAR_HEROFLOOR , atoi( buf ) ) ; + } + +#endif + tmp = NPC_Util_GetNumFromStrWithDelim( argstr, "dieact"); + if( tmp != 1 ) + tmp = 0; + CHAR_setWorkInt( meindex, CHAR_WORK_DIEACT, tmp); + if( CHAR_getWorkInt( meindex, CHAR_WORK_DIEACT) == 0 ) { + Char *ch; + CHAR_setInt( meindex, CHAR_BASEIMAGENUMBER, 0); + print("bbi---->bi10"); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX)); + + CHAR_setWorkInt( meindex, CHAR_WORKEVENTTYPE, CHAR_EVENT_ALTERRATIVE); + MAP_sendAroundMapdata( CHAR_getInt( meindex, CHAR_FLOOR), + CHAR_getInt( meindex, CHAR_X), + CHAR_getInt( meindex, CHAR_Y)); + ch = CHAR_getCharPointer( meindex); + if( ch != NULL ) { + strcpysafe( ch->charfunctable[CHAR_LOOPFUNC].string, + sizeof( ch->charfunctable[CHAR_LOOPFUNC]), + "NPCEnemyLoop"); + CHAR_constructFunctable( meindex); + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, 5000); + CHAR_setWorkInt( meindex, CHAR_WORK_DIETIME, NowTime.tv_sec); + }else { + print( "NPCENEMY:err\n"); + } + }else { + for( i = 0; i < 5; i ++ ) { + toindex = BattleArray[battleindex].Side[0].Entry[i].charaindex; + if( CHAR_CHECKINDEX( toindex) ) { +#ifdef _NEW_WARPMAN + if( strstr( argstr, "NEWNPCENEMY") ) { + BOOL Party=TRUE; + if( NPC_NPCEnemy_CheckFree( meindex, toindex , &Party) == FALSE ) { + continue; + } + if( Party == TRUE ) { + }else { + if( CHAR_getWorkInt( toindex, CHAR_WORKPARTYMODE ) == CHAR_PARTY_LEADER ) { + if( NPC_WarpAllMsg( meindex, toindex ) == TRUE ) { + return TRUE; + } + } + continue; + } + } + CHAR_DischargeParty( toindex, 0); // 拆队 + CHAR_warpToSpecificPoint( toindex, + CHAR_getWorkInt( meindex, CHAR_WORK_WARP_FLOOR), + CHAR_getWorkInt( meindex, CHAR_WORK_WARP_X), + CHAR_getWorkInt( meindex, CHAR_WORK_WARP_Y) + ); + +#else + CHAR_warpToSpecificPoint( toindex, + CHAR_getWorkInt( meindex, CHAR_WORK_WARP_FLOOR), + CHAR_getWorkInt( meindex, CHAR_WORK_WARP_X), + CHAR_getWorkInt( meindex, CHAR_WORK_WARP_Y) + ); +#endif +#ifdef _NPC_REPLACEMENT + Check_EnemyWarpMe( meindex, argstr); +#endif + } + } + } + return TRUE; +} + +void NPC_NPCEnemyLoop( int meindex ) +{ + + if( NowTime.tv_sec > CHAR_getWorkInt( meindex, CHAR_WORK_DIETIME) + + CHAR_getWorkInt( meindex, CHAR_WORK_REVIVALTIME)){ + Char *ch; + CHAR_setInt( meindex, CHAR_BASEIMAGENUMBER, CHAR_getWorkInt( meindex, CHAR_WORK_BASEIMGBAK)); + print("bbi---->bi11"); + + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX)); + CHAR_setWorkInt( meindex, CHAR_WORKEVENTTYPE, CHAR_EVENT_ENEMY); + MAP_sendAroundMapdata( CHAR_getInt( meindex, CHAR_FLOOR), + CHAR_getInt( meindex, CHAR_X), + CHAR_getInt( meindex, CHAR_Y)); + ch = CHAR_getCharPointer( meindex); + if( ch != NULL ) { + strcpysafe( ch->charfunctable[CHAR_LOOPFUNC].string, + sizeof( ch->charfunctable[CHAR_LOOPFUNC]), ""); + CHAR_constructFunctable( meindex); +// CHAR_setInt( meindex, CHAR_LOOPINTERVAL, 0); + } + } +} + + +BOOL NPC_NPCEnemy_BattleIn( int meindex, int charaindex) +{ + int gym; + int ret; + char buf[256]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + + memset( argstr, 0, sizeof( argstr)); + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + gym = NPC_Util_GetNumFromStrWithDelim( argstr, "gym"); + +#ifdef _EMENY_CHANCEMAN + { + int masterindex=-1; + masterindex = NPC_EmenyChanceCheck( meindex, charaindex, argstr); + if( CHAR_CHECKINDEX( masterindex)){ + charaindex = masterindex; + }else { + return TRUE; + } + } +#endif + if( gym > 0 ){ + ret = BATTLE_CreateVsEnemy( charaindex, 2, meindex); + }else{ + ret = BATTLE_CreateVsEnemy( charaindex, 1, meindex); + } + if( ret == 0 ) { + BattleArray[CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX)].WinFunc = NPC_NPCEnemy_Dying; + if( NPC_Util_GetStrFromStrWithDelim( argstr, "startmsg", buf, sizeof( buf)) != NULL ){ + CHAR_talkToCliAndParty( charaindex, meindex ,buf , CHAR_COLORYELLOW ); + } + if( NPC_Util_GetStrFromStrWithDelim( argstr, "steal", buf, sizeof( buf))!= NULL ){ + if( atoi( buf) == 0 ) { + NPC_NPCEnemy_StealItem( argstr, meindex, charaindex); + } + } + } + return ( ret == 0 ) ?TRUE:FALSE ; +} + +void NPC_NPCEnemyWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data) +{ + if( seqno == CHAR_WINDOWTYPE_NPCENEMY_START) { + if( select == WINDOW_BUTTONTYPE_YES) { +#if 0 + print(" NPC_NPCEnemyWindowTalked "); + if( CHAR_getWorkInt( meindex, CHAR_WORKEVENTTYPE) != CHAR_EVENT_ENEMY ) { + print(" NPCEnemyError!! "); + return; + } +#endif + NPC_NPCEnemy_BattleIn( meindex, talkerindex); + } + } +} + +static int NPC_NPCEnemy_StealItem( char *argstr, int meindex, int charaindex) +{ + char itembuf[1024]; + if( NPC_Util_GetStrFromStrWithDelim( argstr, "item", itembuf, sizeof( itembuf)) + != NULL ) + { + char data[128]; + int delitemgroup[CHAR_MAXITEMHAVE]; + int found = 0; + int i; + for( i = 0; i < CHAR_MAXITEMHAVE; i ++ ) { + int j; + int itemid; + int ret = getStringFromIndexWithDelim( itembuf,",", i + 1,data, sizeof(data)); + if( ret == FALSE) { + break; + } + itemid = atoi( data); + for( j = 0; j < CHAR_MAXITEMHAVE; j ++ ) { + int itemindex = CHAR_getItemIndex( charaindex, j); + if( ITEM_CHECKINDEX( itemindex)){ + if( ITEM_getInt( itemindex, ITEM_ID) == itemid ){ + CHAR_setItemIndex( charaindex, j, -1); + ITEM_endExistItemsOne( itemindex); + delitemgroup[found] = j; + found ++; + break; + } + } + } + if( !found ) break; + } + CHAR_sendItemData( charaindex, delitemgroup, found); + } + else { + print( "NPCENEMY:奇怪\n"); + return FALSE; + } + return TRUE; +} + +#ifdef _NEW_WARPMAN +static BOOL NPC_NPCEnemy_CheckFree( int meindex, int toindex, BOOL *Party) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf1[1024],buf2[256],buf3[256],buf4[256]; + char token[256]; + char temp1[16]; + int talkNo = 1; + int point=1; + + int i=0,type=0; + + struct tagWarpPoint { + int floor; + int x; + int y; + }AllWarPoint[]={ + {0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}, + {0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}, + {0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}, + }; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL) { + print("GetArgStrErr"); + return FALSE; + } + if( (strstr( npcarg,"NEWNPCENEMY") == NULL) && (strstr( npcarg,"OVER") == NULL) ) { + return FALSE; + }else { + } + + while( getStringFromIndexWithDelim( npcarg,"OVER",talkNo,buf1,sizeof( buf1)) != FALSE ) { + + talkNo++; + sprintf(temp1,"NEWEVENT"); + if( strstr( buf1, temp1) != NULL) { + if( NPC_Util_GetStrFromStrWithDelim( buf1, "FREE", buf2, sizeof( buf2) ) == FALSE ) { + continue; + } + if( NPC_ActionPassCheck( meindex, toindex, buf2) == FALSE ) { + continue; + } + + if( NPC_Util_GetStrFromStrWithDelim( buf1, "endmsg", token, sizeof( token)) != NULL ) { + CHAR_talkToCli( toindex, meindex ,token , CHAR_COLORYELLOW ); + } +#ifdef _ALLDOMAN // (不可开) Syu ADD 排行榜NPC + if( NPC_Util_GetStrFromStrWithDelim( buf1, "herobattlefield", token, sizeof( token)) != NULL ) { + CHAR_setWorkInt ( toindex , CHAR_WORKHEROFLOOR , atoi ( token ) ) ; + if ( atoi ( token ) > CHAR_getInt ( toindex , CHAR_HEROFLOOR ) ) + CHAR_setInt ( toindex , CHAR_HEROFLOOR , atoi( token ) ) ; + + } +#endif + + if( NPC_Util_GetStrFromStrWithDelim( buf1, "WARP", buf2, sizeof( buf2) ) == FALSE ){ + continue; + }else {//RAND arraysizeof AllWarPoint + while( getStringFromIndexWithDelim( buf2, ";", point, buf3,sizeof( buf3)) != FALSE ) { + point++; + getStringFromIndexWithDelim( buf3, ",", 1, buf4, sizeof( buf4)); + AllWarPoint[i].floor = atoi( buf4); + getStringFromIndexWithDelim( buf3, ",", 2, buf4, sizeof( buf4)); + AllWarPoint[i].x = atoi( buf4); + getStringFromIndexWithDelim( buf3, ",", 3, buf4, sizeof( buf4)); + AllWarPoint[i].y = atoi( buf4); + i++; + if( i >= arraysizeof( AllWarPoint) ) + break; + } + type = RAND( 0, i-1); + if( AllWarPoint[type].floor <= 0 || type > arraysizeof( AllWarPoint)-1) { + type = 0; + } + CHAR_setWorkInt( meindex, CHAR_WORK_WARP_FLOOR, AllWarPoint[type].floor ); + CHAR_setWorkInt( meindex, CHAR_WORK_WARP_X, AllWarPoint[type].x ); + CHAR_setWorkInt( meindex, CHAR_WORK_WARP_Y, AllWarPoint[type].y ); + + } + if( NPC_Util_GetStrFromStrWithDelim( buf1, "CHECKPARTY", buf4, sizeof( buf4)) != NULL ) { + if( strstr( buf4, "FALSE") != NULL ) { + *Party = FALSE; + } + } + if( *Party == TRUE ) { + Action_RunDoEventAction( meindex, toindex, buf1); + } + return TRUE; + } + } + return FALSE; +} + + +BOOL NPCEnemy_CheckFree( int meindex, int talker, 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(NPCEnemy_BSCheck(meindex,talker,buff3)==FALSE) { + loop=1; + break; + } + } + if(loop==0) { + CHAR_setWorkInt( talker, CHAR_WORKWARPCHECK, TRUE ); + return TRUE; + } + }else{ + if( NPCEnemy_BSCheck( meindex, talker, buff2) == TRUE ){ + CHAR_setWorkInt( talker, CHAR_WORKWARPCHECK, TRUE ); + return TRUE; + } + } + } + CHAR_setWorkInt( talker, CHAR_WORKWARPCHECK, FALSE ); + return FALSE; +} + +BOOL NPCEnemy_BSCheck(int meindex,int talker,char* buf) +{ + char buff2[128]; + int kosuu,temp=-1,flg=0; + char buff1[128],buff3[128]; + if(strstr( buf, "-") != NULL) { + //buff3为抓宠物ID + getStringFromIndexWithDelim( buf, "-", 2, buff3, sizeof(buff3)); + temp = atoi( buff3); + getStringFromIndexWithDelim( buf, "-", 1, buff1, sizeof(buff1)); + strcpy( buf, buff1); + } + + if(strstr( buf, "<") != NULL){ + getStringFromIndexWithDelim( buf, "<", 2, buff2, sizeof(buff2)); + kosuu = atoi( buff2); + getStringFromIndexWithDelim( buf, "<", 1, buff2, sizeof(buff2)); + + if(NPCEnemy_FreeIfCheck( meindex, talker, buff2, kosuu, 1, temp)==TRUE){ + return TRUE; + } + }else if(strstr( buf, ">") != NULL){ + getStringFromIndexWithDelim( buf, ">", 2, buff2, sizeof(buff2)); + kosuu = atoi(buff2); + getStringFromIndexWithDelim( buf, ">" ,1, buff2, sizeof(buff2)); + + if(NPCEnemy_FreeIfCheck( meindex, talker, buff2, kosuu, 2, temp)==TRUE){ + return TRUE; + } + + }else if(strstr( buf, "!" ) != NULL){ + getStringFromIndexWithDelim( buf, "!=", 2, buff2, sizeof(buff2)); + kosuu = atoi( buff2); + getStringFromIndexWithDelim( buf, "!=", 1, buff2, sizeof(buff2)); + if(NPCEnemy_FreeIfCheck( meindex, talker, buff2, kosuu, 0, temp) == TRUE){ + return FALSE; + }else{ + return TRUE; + } + + }else if(strstr( buf, "=") != NULL){ + + getStringFromIndexWithDelim( buf, "=", 2, buff2, sizeof(buff2)); + kosuu = atoi( buff2); + getStringFromIndexWithDelim( buf, "=", 1, buff2, sizeof(buff2)); + + if( strstr( buf, "PET")) { + flg = 3; + } + if(strstr( buf, "*") != NULL){ + if( NPCEnemy_WarpManReduce( meindex, talker, buf)==TRUE){ + return TRUE; + } + }else if(NPCEnemy_FreeIfCheck( meindex, talker, buff2, kosuu, flg, temp)==TRUE){ + return TRUE; + } + } + return FALSE; +} + +BOOL NPCEnemy_FreeIfCheck(int meindex,int talker,char* buf,int kosuu,int flg, int temp) +{ + if(strcmp(buf,"LV")==0){ + if(NPCEnemy_LevelCheck(meindex,talker,kosuu,flg)==TRUE){ + return TRUE; + } + } + + if( strcmp(buf,"TRANS") == 0 ) { + if( NPCEnemy_CheckTrans( meindex, talker, kosuu, flg) == TRUE ) + return TRUE; + } + if( strcmp( buf, "PET") == 0 ) { + if( temp > 0 ) { + if( NPCEnemy_CheckMyPet( meindex, talker, kosuu, flg, temp) == TRUE ) + return TRUE; + }else + return FALSE; + } + + if(strcmp(buf,"ITEM")==0){ + if(NPCEnemy_ItemCheck(meindex,talker,kosuu,flg)==TRUE){ + return TRUE; + } + } + if(strcmp(buf,"ENDEV")==0){ + if(NPC_EventCheckFlg( talker, kosuu)==TRUE){ + return TRUE; + } + } + if(strcmp(buf,"NOWEV")==0){ + if(NPC_NowEventCheckFlg( talker, kosuu)==TRUE){ + return TRUE; + } + } + return FALSE; + +} + +BOOL NPCEnemy_WarpManReduce(int meindex,int talker,char *buf) +{ + + char buf2[512]; + char buf3[256]; + int id=0; + int i; + int itemindex; + int itemno; + int kosuu; + int cnt=0; + + getStringFromIndexWithDelim(buf,"=",2,buf2,sizeof(buf2)); + getStringFromIndexWithDelim(buf2,"*",1,buf3,sizeof(buf3)); + itemno = atoi(buf3); + getStringFromIndexWithDelim(buf2,"*",2,buf3,sizeof(buf3)); + kosuu = atoi(buf3); + + for( i=0 ; i < CHAR_MAXITEMHAVE;i++ ){ + itemindex=CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX(itemindex) ){ + id=ITEM_getInt(itemindex ,ITEM_ID ); + if(itemno==id){ + cnt++; + if(cnt==kosuu){ + return TRUE; + } + } + } + } + + return FALSE; + +} + +BOOL NPCEnemy_BigSmallLastCheck(int point1,int mypoint,int flg) +{ + + if(flg==0){ + if(point1==mypoint) { + return TRUE; + } + + }else if(flg==1){ + if(mypoint < point1) { + return TRUE; + } + + }else if(flg==2){ + if(mypoint > point1) { + return TRUE; + } + } + + return FALSE; + +} + +BOOL NPCEnemy_LevelCheck(int meindex,int talker,int level,int flg) +{ + int mylevel; + mylevel=CHAR_getInt(talker,CHAR_LV); + if(NPCEnemy_BigSmallLastCheck(level,mylevel,flg)==TRUE) { + return TRUE; + } + return FALSE; +} + +BOOL NPCEnemy_CheckTrans(int meindex,int talker,int trans,int flg) +{ + int myTrans; + myTrans=CHAR_getInt(talker, CHAR_TRANSMIGRATION); + if( NPCEnemy_BigSmallLastCheck( trans, myTrans, flg ) == TRUE ) { + return TRUE; + } + return FALSE; +} + +BOOL NPCEnemy_CheckMyPet( int meindex, int talker, int petLv, int flg, int petid) +{ + int petsel,petindex=-1; + for(petsel=0 ; petsel < CHAR_MAXPETHAVE ; petsel++) { + petindex = CHAR_getCharPet( talker, petsel); + if( petindex == -1 ) + continue; + if(CHAR_getInt( petindex, CHAR_PETID) != petid ) + continue; + break; + } + if( petsel == CHAR_MAXPETHAVE ) { + return FALSE; + }else { //找到条件宠 + switch( flg) { + case 0: + if( CHAR_getInt( petindex, CHAR_LV) != petLv ) + return TRUE; + break; + case 1: + if( CHAR_getInt( petindex, CHAR_LV) < petLv ) + return TRUE; + break; + case 2: + if( CHAR_getInt( petindex, CHAR_LV) > petLv ) + return TRUE; + break; + case 3: + if( CHAR_getInt( petindex, CHAR_LV) == petLv ) + return TRUE; + break; + } + return FALSE; + } + return FALSE; +} + +BOOL NPCEnemy_ItemCheck(int meindex,int talker,int itemNo,int flg) +{ + int i; + int itemindex=-1; + int id; + + for( i=0;i 0 && addcnt > 0 ) { + snprintf( message, sizeof( message ) , + "你丧失了%d%s 称号的资格。" + "不是得到了%d%s 的称号资格吗?" + , delcnt, + delcnt < 10 ? NPC_OLDMAN_TITLE_UNIT1:NPC_OLDMAN_TITLE_UNIT2, + addcnt, + addcnt < 10 ? NPC_OLDMAN_TITLE_UNIT1:NPC_OLDMAN_TITLE_UNIT2 + ); + CHAR_talkToCli( talkerindex , meindex , message , CHAR_COLORWHITE ); + } + else if( delcnt > 0 ) { + snprintf( message, sizeof( message ) , + "你已丧失得到%d%s称号的资格。", delcnt, + delcnt < 10 ? NPC_OLDMAN_TITLE_UNIT1:NPC_OLDMAN_TITLE_UNIT2); + CHAR_talkToCli( talkerindex , meindex , message , CHAR_COLORWHITE ); + } + else if( addcnt > 0 ) { + snprintf( message, sizeof( message ) , + "给你%d%s的称号吧!", addcnt, // CoolFish: d%s -> %d%s 2001/4/18 + addcnt < 10 ? NPC_OLDMAN_TITLE_UNIT1:NPC_OLDMAN_TITLE_UNIT2); + CHAR_talkToCli( talkerindex , meindex , message , CHAR_COLORWHITE ); + } + if( delcnt > 0 ) { + snprintf( message, sizeof( message), + "失去%d%s 称号!", delcnt, + delcnt < 10 ? NPC_OLDMAN_TITLE_UNIT1:NPC_OLDMAN_TITLE_UNIT2); + CHAR_talkToCli( talkerindex, -1, message, CHAR_COLORYELLOW); + } + if( addcnt > 0 ) { + snprintf( message, sizeof( message), + "获得%d%s 称号!", addcnt, + addcnt < 10 ? NPC_OLDMAN_TITLE_UNIT1:NPC_OLDMAN_TITLE_UNIT2); + CHAR_talkToCli( talkerindex, -1, message, CHAR_COLORYELLOW); + } + } +} + if( title_change ) CHAR_sendStatusString( talkerindex , "T" ); + +} diff --git a/gmsv/npc/npc_pauctionman.c b/gmsv/npc/npc_pauctionman.c new file mode 100644 index 0000000..b8b0567 --- /dev/null +++ b/gmsv/npc/npc_pauctionman.c @@ -0,0 +1,530 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.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_pauctionman.h" +#include "saacproto_cli.h" + +//拍卖王 andy +#ifdef _PAUCTION_MAN +enum { + WINDOW_START=5, + WINDOW_SELECT, + WINDOW_BUY, + WINDOW_SELL, + WINDOW_BUYDO, + WINDOW_SELLDO, + WINDOW_WARP, + WINDOW_END, +}; +enum { + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT1, + NPC_WORK_MULTIPLE = 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, +*/ +}; +typedef struct _tagAUCTIONITEM{ + int index; + int ti; + long Stime; + char Name[256]; + int level; + int use; + struct _tagAUCTIONITEM *next; +}AUCTIONITEMs; +#define AUCTION_ADD 1 +#define AUCTION_DEL 2 +#define MAXAUCTIONs 20 +AUCTIONITEMs *pAuctionItem; +#define STANDBYTIME 50 + +static void NPC_Pauctionman_selectWindow( int meindex, int toindex, int num,int select); +BOOL NPC_PAItemShop_Main(int meindex,int talker, char *argstr,char *token, int sizes); +BOOL NPC_PAItemShop_BuyMain(int meindex, int talker, char *argstr,char *token, int sizes); +BOOL NPC_PAItemShop_SellMain(int meindex,int talker, char *argstr,char *token, int sizes); +int NPC_PAGetMyLimtItem(int talker, char *argstr, char* token, int sizes); +BOOL NPC_PAItemShop_BuyDo( int meindex, int toindex, char *npcarg, int select); +BOOL NPC_PAItemShop_SellDo( int meindex, int toindex, char *npcarg, int select); + +AUCTIONITEMs *LIST_getNew(); +int NPC_PAItemShop_GetItem( int ti, int *ret); + +void NPC_PAGetItemList( char *argstr, char *token, int sizes); +void NPC_AUCTIONITEMs_Init(); + +BOOL NPC_PauctionManInit( 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_PAUCTIONMAN); + + //CHAR_setInt( meindex, CHAR_LOOPINTERVAL, NEWNPCMAN_STANDBY); + CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + NPC_AUCTIONITEMs_Init(); + return TRUE; +} + +void NPC_PauctionManTalked( 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_Pauctionman_selectWindow( meindex, talkerindex, WINDOW_START, 0); +} + +void NPC_PauctionManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data) +{ + if( select == WINDOW_BUTTONTYPE_CANCEL || select == WINDOW_BUTTONTYPE_NO) + return; + switch( seqno) { + case NPC_PAUCTION_START: + break; + case NPC_PAUCTION_SELECT: + { + int index=0; + index = atoi( data); + switch( index) { + case 1: + NPC_Pauctionman_selectWindow( meindex, talkerindex, WINDOW_BUY, atoi( data)); + break; + case 2: + NPC_Pauctionman_selectWindow( meindex, talkerindex, WINDOW_SELL, atoi( data)); + break; + } + } + break; + case NPC_PAUCTION_BUY: + NPC_Pauctionman_selectWindow( meindex, talkerindex, WINDOW_BUYDO, atoi( data)); + break; + case NPC_PAUCTION_SELL: + NPC_Pauctionman_selectWindow( meindex, talkerindex, WINDOW_SELLDO, atoi( data)); + break; + case NPC_PAUCTION_WARP: + if( select == WINDOW_BUTTONTYPE_CANCEL ) + return; + NPC_Pauctionman_selectWindow( meindex, talkerindex, WINDOW_WARP, atoi( data)); + break; + case NPC_PAUCTION_END: + break; + } + +} +//while( getStringFromIndexWithDelim( npcarg,"}",talkNo, buf1, sizeof( buf1)) != FALSE ) { +static void NPC_Pauctionman_selectWindow( int meindex, int toindex, int num, int select) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[NPC_UTIL_GETARGSTR_BUFSIZE]; + + int buttontype = 0, windowtype = 0, windowno = 0; + int fd = getfdFromCharaIndex( toindex); + + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + + if(NPC_Util_isFaceToFace( meindex ,toindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( toindex, meindex, 1) == FALSE) + return; + } + + if( Action_PartyCheck( meindex, toindex) == FALSE) { + CHAR_talkToCli( toindex, meindex, "请一个一个来!", CHAR_COLORYELLOW); + 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: + if( NPC_PAItemShop_Main( meindex, toindex, npcarg, token, sizeof( token)) == FALSE ) { + return; + } + + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, WINDOW_START); + buttontype = WINDOW_BUTTONTYPE_NONE; + windowtype = WINDOW_MESSAGETYPE_ITEMSHOPMENU; + windowno = NPC_PAUCTION_SELECT; + break; + case WINDOW_SELECT: + windowtype = WINDOW_MESSAGETYPE_SELECT; + buttontype = WINDOW_BUTTONTYPE_CANCEL; + windowno = NPC_PAUCTION_WARP; + break; +// ================ Sell + case WINDOW_SELLDO: + if( select != 0 ){ + if( NPC_PAItemShop_SellDo( meindex, toindex, npcarg, select) == FALSE ){ + return; + } + } + if( NPC_PAItemShop_Main( meindex, toindex, npcarg, token, sizeof( token)) == FALSE ) { + return; + } + + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, WINDOW_START); + buttontype = WINDOW_BUTTONTYPE_NONE; + windowtype = WINDOW_MESSAGETYPE_ITEMSHOPMENU; + windowno = NPC_PAUCTION_SELECT; + break; + case WINDOW_SELL: + if( NPC_PAItemShop_SellMain( meindex, toindex, npcarg, token, sizeof( token)) == FALSE ){ + return; + } + buttontype = WINDOW_BUTTONTYPE_NONE; + windowtype = WINDOW_MESSAGETYPE_ITEMSHOPMAIN; + windowno = NPC_PAUCTION_SELL; + break; +// ================ BUY + case WINDOW_BUYDO: + if( select != 0 ){ + if( NPC_PAItemShop_BuyDo( meindex, toindex, npcarg, select-1) == FALSE ){ + return; + } + } + if( NPC_PAItemShop_Main( meindex, toindex, npcarg, token, sizeof( token)) == FALSE ) { + return; + } + + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, WINDOW_START); + buttontype = WINDOW_BUTTONTYPE_NONE; + windowtype = WINDOW_MESSAGETYPE_ITEMSHOPMENU; + windowno = NPC_PAUCTION_SELECT; + break; + case WINDOW_BUY: + if( NPC_PAItemShop_BuyMain( meindex, toindex, npcarg, token, sizeof( token)) == FALSE ){ + return; + } + buttontype = WINDOW_BUTTONTYPE_NONE; + windowtype = WINDOW_MESSAGETYPE_ITEMSHOPMAIN; + windowno = NPC_PAUCTION_BUY; + break; +// ================ + case WINDOW_WARP: + ActionNpc_CheckMenuFree( meindex, toindex, npcarg, select); + return; + + case WINDOW_END: + break; + } + + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token); +} +void NPC_PauctionManLoop( int meindex) +{ + +} + +BOOL NPC_PAItemShop_Main(int meindex,int talker, char *argstr,char *token, int sizes) +{ + char buff[256]; + //int fd = getfdFromCharaIndex( talker); + memset( buff, 0, sizeof( buff)); + if( NPC_Util_GetStrFromStrWithDelim( argstr, "MAIN_MESS", buff, sizeof( buff)) == NULL ) + return FALSE; + snprintf(token, sizes,"%s|%s", CHAR_getChar( meindex, CHAR_NAME), buff); + return TRUE; +} + +BOOL NPC_PAItemShop_BuyMain(int meindex, int talker, char *argstr,char *token, int sizes) +{ + //int fd = getfdFromCharaIndex( talker); + char token2[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff2[256]; + char buff[256]; + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "MAIN_MESS", buff, sizeof( buff)) == NULL ) + return FALSE; + if( NPC_Util_GetStrFromStrWithDelim( argstr, "BUY_MESS", buff2, sizeof( buff2)) == NULL ) + return FALSE; + memset( token2, 0, sizeof( token2)); + sprintf(token,"0|1|%d|%s|%s|%s|", CHAR_WINDOWTYPE_WINDOWITEMSHOP_STARTMSG, + CHAR_getChar( meindex, CHAR_NAME), buff, buff2); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "WHAT_MESS", buff, sizeof( buff)) == NULL ) + return FALSE; + if( NPC_Util_GetStrFromStrWithDelim( argstr, "LEVEL_MESS", buff2, sizeof( buff2)) == NULL ) + return FALSE; + + snprintf( token2, sizeof( token2), "%s|%s", buff, buff2); + strncat( token, token2, sizes); + if( NPC_Util_GetStrFromStrWithDelim( argstr, "REALY_MESS", buff, sizeof( buff)) == NULL ) + return FALSE; + if( NPC_Util_GetStrFromStrWithDelim( argstr, "ITEMFULL_MESS", buff2, sizeof( buff2)) == NULL ) + return FALSE; + memset( token2, 0, sizeof( token2)); + sprintf( token2, "|%s|%s", buff, buff2); + strncat(token , token2, sizeof( token2)); + strcpy(token2, "|"); + NPC_PAGetItemList( argstr, token2, sizeof( token2)); + strncat( token, token2, sizes); + + return TRUE; +} + + +void NPC_PAGetItemList( char *argstr, char *token, int sizes) +{ + int i=1, ret=-1; + char token2[NPC_UTIL_GETARGSTR_BUFSIZE]; + for( i=0; iindex = itemindex; + works->use = 1; + works->ti = ret; + works->next = NULL; + if( heads == NULL ) { + pAuctionItem = works; + }else { + heads->next = works; + } + works = pAuctionItem; + return itemindex; + } + i++; + heads = works; + works = works->next; + if( i >= MAXAUCTIONs ) + break; + } + return -1; +} + +BOOL NPC_PAItemShop_DelItem( int ti, int index) +{ + AUCTIONITEMs *works = NULL; + AUCTIONITEMs *heads = NULL; + works = pAuctionItem; + //heads = pAuctionItem; + + while( works != NULL ) { + if( works->ti == ti ) { + if( heads == NULL ){ + pAuctionItem = works->next; + }else { + heads->next = works->next; + } + free( works); + return TRUE; + } + heads = works; + works = works->next; + } + return FALSE; +} + +int NPC_PAItemShop_GetItem( int ti, int *ret) +{ + AUCTIONITEMs *works = NULL; + //heads + int i; + works = pAuctionItem; + + for( i=0; inext; + } + + if( works == NULL ) return -1; + if( works->use > 0 ){ + *ret = works->ti; + return works->index; + } + return -1; +} + +BOOL NPC_PAItemShop_reItem( int itemindex, char *Data) +{ + if( !ITEM_CHECKINDEX( itemindex) ) + return FALSE; + + return TRUE; +} + +AUCTIONITEMs *LIST_getNew() +{ + AUCTIONITEMs *MBUF=NULL; + MBUF = (AUCTIONITEMs *) calloc( 1, sizeof( struct _tagAUCTIONITEM) ); + if( MBUF == NULL ) + return NULL; + MBUF->use = -1; + MBUF->ti = -1; + MBUF->next = NULL; + return MBUF; +} +#endif + diff --git a/gmsv/npc/npc_petfusion.c b/gmsv/npc/npc_petfusion.c new file mode 100644 index 0000000..fd2d05e --- /dev/null +++ b/gmsv/npc/npc_petfusion.c @@ -0,0 +1,253 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "char_data.h" +#include "npcutil.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_petfusion.h" +#include "pet.h" +#include "chatmagic.h" + + +#ifdef _NPC_FUSION + +enum { + WINDOW_START=10, + WINDOW_SELECT, + WINDOW_FUSION, + WINDOW_WARP, //跳跃 + WINDOW_END, //结束 + + WINDOW_TALKSTART=20, + WINDOW_TALKSELECT, + WINDOW_RETURN, + WINDOW_TALKEND, +}; +enum { + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT1, +/* + 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, +*/ +}; + +static void NPC_PetFusion_selectWindow( int meindex, int toindex, int num,int select); +BOOL NPC_DoPetFusion( int meindex, int toindex, char *data, int sizes); + + +BOOL NPC_PetFusionManInit( int meindex ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("err NPC_PetFusionManInit: GetArgStrErr!!"); + return FALSE; + } + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_PETFUSIONMAN); + //CHAR_setInt( meindex, CHAR_LOOPINTERVAL, MAKEPAIR_STANDBY); + //CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec); + //CHAR_setWorkInt( meindex, NPC_WORK_PAIRTEAMS, 0); + return TRUE; +} +void NPC_PetFusionManTalked( 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; + } +#ifdef _ITEM_CHECKWARES + if( CHAR_CheckInItemForWares( talkerindex, 0) == FALSE ){ + CHAR_talkToCli( talkerindex, meindex, "无法服务携带货物的人!", CHAR_COLORYELLOW); + return; + } +#endif + + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, WINDOW_START); + NPC_PetFusion_selectWindow( meindex, talkerindex, WINDOW_START, 0); +} + +static void NPC_PetFusion_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); + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + if( Action_PartyCheck( meindex, toindex) == FALSE) { + CHAR_talkToCli( toindex, meindex, "请一个一个来!", CHAR_COLORYELLOW); + return; + } + memset( npcarg, 0, sizeof( npcarg)); + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("err NPC_MakePairMan: GetArgStrErr!!"); + return; + } + memset( token, 0, sizeof( token)); + + switch( num){ + case WINDOW_START: + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "StartMsg", token, sizeof( token) ) == NULL){ + return; + } + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowno = WINDOW_TALKSTART; + break; + case WINDOW_SELECT: + if( ActionNpc_CheckFree( meindex, toindex, npcarg) == FALSE ) { + buttontype = WINDOW_BUTTONTYPE_OK; + windowno = WINDOW_TALKEND; + }else { + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "SelectMsg", token, sizeof( token) ) == NULL){ + return; + } + windowtype = WINDOWS_MESSAGETYPE_PETFUSION; + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowno = WINDOW_TALKSELECT; + } + break; + case WINDOW_FUSION: + //融合处理 + break; + case WINDOW_WARP: + break; + case WINDOW_END: + break; + } + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, windowno); + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token); +} +void NPC_PetFusionManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) + return; + if( select == WINDOW_BUTTONTYPE_NO || select == WINDOW_BUTTONTYPE_CANCEL ){ + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + return; + } + if( CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT) != seqno ) + return; + memset( npcarg, 0, sizeof( npcarg)); + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("err NPC_MakePairMan: GetArgStrErr!!"); + return; + } + if( CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT) != seqno ) + return; + + switch( seqno) { + case WINDOW_TALKSTART: + NPC_PetFusion_selectWindow( meindex, talkerindex, WINDOW_SELECT, 0); + break; + case WINDOW_TALKSELECT: + { + if( NPC_DoPetFusion( meindex, talkerindex, data, sizeof( data)) == FALSE ) + return; + return; + NPC_PetFusion_selectWindow( meindex, talkerindex, WINDOW_FUSION, 0); + } + break; + case WINDOW_RETURN: + break; + case WINDOW_TALKEND: + break; + } +} + +void NPC_PetFusionManLoop( int meindex) +{ +} + +BOOL NPC_DoPetFusion( int meindex, int toindex, char *data, int sizes) +{ + char buf[256]; + int i, flg, MainIndex=-1, Subindex1=-1, Subindex2=-1; + int work[4], skill1[7], skill2[7]; + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + memset( buf, 0, sizeof( buf)); + sprintf( buf, "%s", data); + if( !CHAR_CHECKINDEX( meindex) ) return FALSE; + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("err NPC_MakePairMan: GetArgStrErr!!"); + return FALSE; + } + for( i=0; i +#include +#include + +#include "object.h" +#include "char_base.h" +#include "char.h" +#include "util.h" +#include "npcutil.h" +#include "item.h" +#include "readmap.h" +#include "enemy.h" +#include "chatmagic.h" +#include "log.h" + +#define EVFLG 118 // 58->白虎 118->青龙 + +void pet_make( int charaindex, char* message ); + +BOOL NPC_PetMakerInit( int meindex ) +{ + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEPETMAKER ); + CHAR_setFlg( meindex , CHAR_ISATTACKED , 0 ); + return TRUE; +} + +void NPC_PetMakerTalked( int meindex , int talker , char *msg ,int color ) +{ + char* npcarg; + char token[32],tmpbuf[256]; + int msgNo/*,translv*/; + int point,ckpoint,array,shift; + int i,num=0; + + array = EVFLG / 32; + shift = EVFLG % 32; + point = CHAR_getInt( talker, CHAR_ENDEVENT + array); + ckpoint = point; + + npcarg = CHAR_getChar(meindex,CHAR_NPCARGUMENT); + + getStringFromIndexWithDelim( npcarg, "|", 1, token,sizeof( token)); + msgNo = atoi( token ); + + if( CHAR_getInt( talker , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) + return; + + if( NPC_Util_isFaceToFace( talker, meindex , 2 ) == FALSE ) + { + if( NPC_Util_isFaceToFace( talker, meindex , 1 ) == FALSE ) + return; + } + + //translv = CHAR_getInt( talker, CHAR_TRANSMIGRATION); // 白虎 + + for(i=0; i=CHAR_MAXPETHAVE ){ + sprintf(tmpbuf, "抱歉~没多馀的空间可放置宠物。"); + CHAR_talkToCli( talker, meindex, + tmpbuf,CHAR_COLORWHITE); + return; + } + + pet_make( talker, "1845" ); + + point = point | (1 << shift); + CHAR_setInt( talker, CHAR_ENDEVENT + array, point); +} + +void pet_make( int charaindex, char* message ) +{ + int ret; + char msgbuf[64]; + int enemynum; + int enemyid; + int i; + + enemyid = atoi(message); + enemynum = ENEMY_getEnemyNum(); + + for( i=0; i +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "handletime.h" + +#ifdef _PETRACE +#include "npc_petracemaster.h" + +#define PETRACEPETNUM 3 +#define PETRACEMASTER_INITPET_LOOPTIME 3000 // 3秒 +#define PETRACEMASTER_WAITDROPI_LOOPTIME 30000 // 30秒 +#define PETRACEMASTER_WAITDROPII_LOOPTIME 10000 // 10秒 +#define PETRACEMASTER_WAITDROPIII_LOOPTIME 5000 // 5秒 +#define PETRACEMASTER_WAITDROPIV_LOOPTIME 1000 // 1秒 +#define PETRACEMASTER_PETRACING_LOOPTIME 3000 // 3秒 +#define PETRACEMASTER_SHOWWINPET_LOOPTIME 10000 // 10秒 +#define PETRACEDROPSTAKETIME 120 // 2分钟 120 +#define PETRACESHOWWINPET 30 // 30秒 +#define PETRACESTDPAYRATE 6 +#define PETRACESTDGOLD 1 // 计算赔率时基本金额 1000 + +static void NPC_PetRaceMaster_selectWindow(int meindex, int toindex, int num, int select); +void NPC_findRacePetIndex(int meindex, int floor); +void NPC_givePriceToPlayer(int meindex, int floor, int winpetindex); + +enum +{ + NPC_WORK_STATE = CHAR_NPCWORKINT1, + NPC_WORK_PET1 = CHAR_NPCWORKINT2, + NPC_WORK_PET2 = CHAR_NPCWORKINT3, + NPC_WORK_PET3 = CHAR_NPCWORKINT4, + NPC_WORK_PETGROUP = CHAR_NPCWORKINT5, + NPC_WORK_STATECHANGE = CHAR_NPCWORKINT6, + NPC_WORK_FINDPETFLAG = CHAR_NPCWORKINT7, + NPC_WORK_WINPET = CHAR_NPCWORKINT8, + NPC_WORK_PETGOAL = CHAR_NPCWORKINT9, +}; +enum +{ + NPC_State_Init, + NPC_State_WaitDropStake, + NPC_State_PetRacing, + NPC_State_ShowWinPet, +}; +enum +{ + NPC_State_Wait, + NPC_State_Run, + NPC_State_ShowWin, +}; +typedef struct tagPetRaceGraTable +{ + int pet1gra; + int pet2gra; + int pet3gra; + char pet1name[64]; + char pet2name[64]; + char pet3name[64]; + int pet1win; + int pet2win; + int pet3win; +#ifdef _DROPSTAKENEW +#else + float payrate1; + float payrate2; + float payrate3; +#endif + char state1[64]; + char state2[64]; + char state3[64]; +}PetRaceGraTable; +#ifdef _DROPSTAKENEW +PetRaceGraTable petracegra[27] = +{ + {100820, 100821, 100822, "扑满乌力", "乌力莱德", "乌力固力", 0, 0, 0, "良好", "良好", "良好"}, + {100823, 100824, 100825, "布依布鲁", "布依布依", "布依胖", 0, 0, 0, "良好", "良好", "良好"}, + {100842, 100843, 100844, "尼加斯", "尼基斯", "特洛可斯", 0, 0, 0, "良好", "良好", "良好"}, + {100852, 100853, 100855, "克拉尔", "拉斯基", "克达达", 0, 0, 0, "良好", "良好", "良好"}, + {100859, 100856, 100857, "可卡特", "卡卡特", "昆依特", 0, 0, 0, "良好", "良好", "良好"}, + {100864, 100865, 100866, "蓝宝", "瑞德宝", "毛宝", 0, 0, 0, "良好", "良好", "良好"}, + {100829, 100826, 100827, "比比加", "加加", "加斯奥", 0, 0, 0, "良好", "良好", "良好"}, + {100830, 100832, 100833, "乌宝依", "威比", "乌拉拉", 0, 0, 0, "良好", "良好", "良好"}, + {100883, 100884, 100885, "尤里蛙", "裘里蛙", "艾尔蛙", 0, 0, 0, "良好", "良好", "良好"}, + {100898, 100900, 100901, "可可恩", "布兰恩", "迪布恩", 0, 0, 0, "良好", "良好", "良好"}, + {100834, 100836, 100837, "贝洛金", "贝洛贝", "贝洛波波", 0, 0, 0, "良好", "良好", "良好"}, + {100838, 100840, 100841, "蓝龟", "龟之钢", "卡拉龟", 0, 0, 0, "良好", "良好", "良好"}, + {100879, 100881, 100880, "迪加", "波波顿", "砂鲨", 0, 0, 0, "良好", "良好", "良好"}, + {100888, 100887, 100889, "莫拉司", "欧瑟菲", "玛斯特", 0, 0, 0, "良好", "良好", "良好"}, + {100913, 100914, 100915, "莱姆洛斯", "朱利洛斯", "辛普洛斯", 0, 0, 0, "良好", "良好", "良好"}, + {100845, 100846, 100847, "呼波波", "呼鲁鲁", "鲁拉其斯", 0, 0, 0, "良好", "良好", "良好"}, + {100849, 100850, 100851, "邦诺斯娜", "杨格斯", "迪基格斯", 0, 0, 0, "良好", "良好", "良好"}, + {100878, 100876, 100877, "玻洛布斯", "加耶布斯", "迪米布斯", 0, 0, 0, "良好", "良好", "良好"}, + {100908, 100909, 100906, "阿米朵", "邦司凉朵", "朵巴奈特", 0, 0, 0, "良好", "良好", "良好"}, + {100916, 100918, 100919, "立杜鲁斯", "巴克亚司", "雷德力克斯", 0, 0, 0, "良好", "良好", "良好"}, + {100860, 100862, 100861, "司尔顿", "梅尔顿", "格尔希洛", 0, 0, 0, "良好", "良好", "良好"}, + {100867, 100870, 100868, "欧林吉鲁", "芭拉芭", "史凯鲁", 0, 0, 0, "良好", "良好", "良好"}, + {100871, 100873, 100874, "普鲁夏", "萨格鲁", "玛斯贝卡", 0, 0, 0, "良好", "良好", "良好"}, + {100894, 100895, 100896, "固力摩", "摩吉摩吉", "摩米索拉", 0, 0, 0, "良好", "良好", "良好"}, + {100902, 100903, 100905, "格里兰", "摩里", "塔斯夫", 0, 0, 0, "良好", "良好", "良好"}, + {100912, 100911, 100910, "伊夫霍恩", "布依伦斯", "布莱兹", 0, 0, 0, "良好", "良好", "良好"}, + {100891, 100892, 100893, "嘎吱拉", "哥斯哥斯", "蒙哥拉斯", 0, 0, 0, "良好", "良好", "良好"}, +}; +#else +PetRaceGraTable petracegra[27] = +{ + {100820, 100821, 100822, "扑满乌力", "乌力莱德", "乌力固力", 0, 0, 0, 2, 2, 2, "良好", "良好", "良好"}, + {100823, 100824, 100825, "布依布鲁", "布依布依", "布依胖", 0, 0, 0, 2, 2, 2, "良好", "良好", "良好"}, + {100842, 100843, 100844, "尼加斯", "尼基斯", "特洛可斯", 0, 0, 0, 2, 2, 2, "良好", "良好", "良好"}, + {100852, 100853, 100855, "克拉尔", "拉斯基", "克达达", 0, 0, 0, 2, 2, 2, "良好", "良好", "良好"}, + {100859, 100856, 100857, "可卡特", "卡卡特", "昆依特", 0, 0, 0, 2, 2, 2, "良好", "良好", "良好"}, + {100864, 100865, 100866, "蓝宝", "瑞德宝", "毛宝", 0, 0, 0, 2, 2, 2, "良好", "良好", "良好"}, + {100829, 100826, 100827, "比比加", "加加", "加斯奥", 0, 0, 0, 2, 2, 2, "良好", "良好", "良好"}, + {100830, 100832, 100833, "乌宝依", "威比", "乌拉拉", 0, 0, 0, 2, 2, 2, "良好", "良好", "良好"}, + {100883, 100884, 100885, "尤里蛙", "裘里蛙", "艾尔蛙", 0, 0, 0, 2, 2, 2, "良好", "良好", "良好"}, + {100898, 100900, 100901, "可可恩", "布兰恩", "迪布恩", 0, 0, 0, 2, 2, 2, "良好", "良好", "良好"}, + {100834, 100836, 100837, "贝洛金", "贝洛贝", "贝洛波波", 0, 0, 0, 2, 2, 2, "良好", "良好", "良好"}, + {100838, 100840, 100841, "蓝龟", "龟之钢", "卡拉龟", 0, 0, 0, 2, 2, 2, "良好", "良好", "良好"}, + {100879, 100881, 100880, "迪加", "波波顿", "砂鲨", 0, 0, 0, 2, 2, 2, "良好", "良好", "良好"}, + {100888, 100887, 100889, "莫拉司", "欧瑟菲", "玛斯特", 0, 0, 0, 2, 2, 2, "良好", "良好", "良好"}, + {100913, 100914, 100915, "莱姆洛斯", "朱利洛斯", "辛普洛斯", 0, 0, 0, 2, 2, 2, "良好", "良好", "良好"}, + {100845, 100846, 100847, "呼波波", "呼鲁鲁", "鲁拉其斯", 0, 0, 0, 2, 2, 2, "良好", "良好", "良好"}, + {100849, 100850, 100851, "邦诺斯娜", "杨格斯", "迪基格斯", 0, 0, 0, 2, 2, 2, "良好", "良好", "良好"}, + {100878, 100876, 100877, "玻洛布斯", "加耶布斯", "迪米布斯", 0, 0, 0, 2, 2, 2, "良好", "良好", "良好"}, + {100908, 100909, 100906, "阿米朵", "邦司凉朵", "朵巴奈特", 0, 0, 0, 2, 2, 2, "良好", "良好", "良好"}, + {100916, 100918, 100919, "立杜鲁斯", "巴克亚司", "雷德力克斯", 0, 0, 0, 2, 2, 2, "良好", "良好", "良好"}, + {100860, 100862, 100861, "司尔顿", "梅尔顿", "格尔希洛", 0, 0, 0, 2, 2, 2, "良好", "良好", "良好"}, + {100867, 100870, 100868, "欧林吉鲁", "芭拉芭", "史凯鲁", 0, 0, 0, 2, 2, 2, "良好", "良好", "良好"}, + {100871, 100873, 100874, "普鲁夏", "萨格鲁", "玛斯贝卡", 0, 0, 0, 2, 2, 2, "良好", "良好", "良好"}, + {100894, 100895, 100896, "固力摩", "摩吉摩吉", "摩米索拉", 0, 0, 0, 2, 2, 2, "良好", "良好", "良好"}, + {100902, 100903, 100905, "格里兰", "摩里", "塔斯夫", 0, 0, 0, 2, 2, 2, "良好", "良好", "良好"}, + {100912, 100911, 100910, "伊夫霍恩", "布依伦斯", "布莱兹", 0, 0, 0, 2, 2, 2, "良好", "良好", "良好"}, + {100891, 100892, 100893, "嘎吱拉", "哥斯哥斯", "蒙哥拉斯", 0, 0, 0, 2, 2, 2, "良好", "良好", "良好"}, +}; +#endif +BOOL NPC_PetRaceMasterInit( int meindex ) +{ + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, PETRACEMASTER_INITPET_LOOPTIME); + CHAR_setInt(meindex, CHAR_WHICHTYPE, CHAR_PETRACEMASTER); + CHAR_setWorkInt(meindex, NPC_WORK_STATE, NPC_State_Init); + CHAR_setWorkInt(meindex, NPC_WORK_PETGROUP, 0); +#ifdef _DROPSTAKENEW +#else + petracegra[0].payrate1 = 0; + petracegra[0].payrate2 = 0; + petracegra[0].payrate3 = 0; +#endif + return TRUE; +} + +void NPC_PetRaceMasterTalked( int meindex , int talkerindex , char *szMes , int color ) +{ + // 尚须新增说明以及宠物状况 + if (CHAR_getInt(talkerindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER) + return; + if (NPC_Util_isFaceToFace(talkerindex, meindex, 2) == FALSE) + if (NPC_Util_CharDistance(talkerindex, meindex) > 1) + return; + NPC_PetRaceMaster_selectWindow(meindex, talkerindex, 0, -1); +} + +static void NPC_PetRaceMaster_selectWindow(int meindex, int toindex, int num, int select) +{ + char token[1024]; + int buttontype = 0, windowtype = 0, windowno = 0; + int fd = getfdFromCharaIndex(toindex); + if (fd == -1) return; + token[0] = '\0'; + switch(num) + { + case 0: + sprintf(token, "4\n\n ★宠物竞速场★\n" + "你好,想要知道什麽情报吗?\n" + "\n 《察看游戏规则》" + "\n 《宠物状况》" + "\n 《离开》"); + buttontype = WINDOW_BUTTONTYPE_NONE; + windowtype = WINDOW_MESSAGETYPE_SELECT; + windowno = CHAR_WINDOWTYPE_PETRACEMASTER_START; + break; + case 1: +#ifdef _DROPSTAKENEW + sprintf(token, + "\n竞速场规则:" + "\n参加竞速的宠物总共有叁只,您可以依照宠物" + "\n的状况或个人喜好下注,请将兑换得到的彩券" + "\n放置於欲下注的号码前方。当竞速结束时,主" + "\n持人将会自动帮您计算积分。" + "\n请注意:当您离开此房间或登出时,下注的彩" + "\n卷及积分将无法取回唷!"); +#else + sprintf(token, + "\n竞速场规则:参加竞速的宠物共有叁只,您可" + "\n以依照宠物状况或个人喜好下注,每个宠物有" + "\n自己的赔率。请将石币丢置於欲下注的号码前" + "\n方。当竞速结束时,主持人会自动地将金额放" + "\n回你的身上或存入个人银行。" + "\n请注意:银行金额请勿超过一千万!当您离开" + "\n此房间或登出时,下注的金额将无法取回唷!"); +#endif + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_PETRACEMASTER_RULE; + break; + case 2: + { + int petgroup = CHAR_getWorkInt(meindex, NPC_WORK_PETGROUP); + int petindex1 = CHAR_getWorkInt(meindex, NPC_WORK_PET1); + int petindex2 = CHAR_getWorkInt(meindex, NPC_WORK_PET2); + int petindex3 = CHAR_getWorkInt(meindex, NPC_WORK_PET3); + int pet1win = petracegra[petgroup].pet1win; + int pet2win = petracegra[petgroup].pet2win; + int pet3win = petracegra[petgroup].pet3win; + int total = pet1win + pet2win + pet3win; + float winrate1 = 0, winrate2 = 0, winrate3 = 0; +#ifdef _DROPSTAKENEW +#else + char cpayrate1[64], cpayrate2[64], cpayrate3[64]; + if (petracegra[petgroup].payrate1 == 0) + snprintf(cpayrate1, sizeof(cpayrate1), "???"); + else + snprintf(cpayrate1, sizeof(cpayrate1), "%6.2f", petracegra[petgroup].payrate1); + if (petracegra[petgroup].payrate2 == 0) + snprintf(cpayrate2, sizeof(cpayrate2), "???"); + else + snprintf(cpayrate2, sizeof(cpayrate2), "%6.2f", petracegra[petgroup].payrate2); + if (petracegra[petgroup].payrate3 == 0) + snprintf(cpayrate3, sizeof(cpayrate3), "???"); + else + snprintf(cpayrate3, sizeof(cpayrate3), "%6.2f", petracegra[petgroup].payrate3); +#endif + if (total == 0) + { + winrate1 = 0; winrate2 = 0; winrate3 = 0; + } + else + { + winrate1 = (float)pet1win / (float)total; + winrate2 = (float)pet2win / (float)total; + winrate3 = (float)pet3win / (float)total; + } +#ifdef _DROPSTAKENEW + sprintf(token, "宠物状况\n\n 宠物 胜场 败场 状况 胜场率\n" + "========================================" + "%-10s%-6d%-6d%-8s%-6.2f\n" + "%-10s%-6d%-6d%-8s%-6.2f\n" + "%-10s%-6d%-6d%-8s%-6.2f\n", + CHAR_getChar(petindex1, CHAR_NAME), pet1win, total - pet1win, + petracegra[petgroup].state1, winrate1, + CHAR_getChar(petindex2, CHAR_NAME), pet2win, total - pet2win, + petracegra[petgroup].state2, winrate2, + CHAR_getChar(petindex3, CHAR_NAME), pet3win, total - pet3win, + petracegra[petgroup].state3, winrate3); +#else + sprintf(token, "宠物状况\n\n 宠物 胜场 败场 状况 胜场率 赔率\n" + "========================================" + "%-10s%-6d%-6d%-6s%-6.2f%-4s\n" + "%-10s%-6d%-6d%-6s%-6.2f%-4s\n" + "%-10s%-6d%-6d%-6s%-6.2f%-4s\n", + CHAR_getChar(petindex1, CHAR_NAME), pet1win, total - pet1win, + petracegra[petgroup].state1, winrate1, cpayrate1, + CHAR_getChar(petindex2, CHAR_NAME), pet2win, total - pet2win, + petracegra[petgroup].state2, winrate2, cpayrate2, + CHAR_getChar(petindex3, CHAR_NAME), pet3win, total - pet3win, + petracegra[petgroup].state3, winrate3, cpayrate3); +#endif + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_PETRACEMASTER_PET; + } + break; + case 3: + default: + break; + } + lssproto_WN_send(fd, windowtype, buttontype, windowno, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), token); +} + +void NPC_PetRaceMasterWindowTalked(int meindex, int talkerindex, int seqno, int select, char *data) +{ + int datanum = 0; + makeStringFromEscaped(data); + datanum = atoi(data); + switch(seqno) + { + case CHAR_WINDOWTYPE_PETRACEMASTER_START: + if (datanum == 1) + NPC_PetRaceMaster_selectWindow(meindex, talkerindex, 1, -1); + else if (datanum == 2) + NPC_PetRaceMaster_selectWindow(meindex, talkerindex, 2, -1); + break; + case CHAR_WINDOWTYPE_PETRACEMASTER_RULE: + if (datanum == 3) + NPC_PetRaceMaster_selectWindow(meindex, talkerindex, 1, -1); + case CHAR_WINDOWTYPE_PETRACEMASTER_PET: + case CHAR_WINDOWTYPE_PETRACEMASTER_LEAVE: + default: + break; + } +} + +void NPC_PetRaceMasterLoop( int meindex) +{ + int floor = CHAR_getInt(meindex, CHAR_FLOOR); + time_t t1; + time(&t1); + switch(CHAR_getWorkInt(meindex, NPC_WORK_STATE)) + { + case NPC_State_Init: + // 寻找宠物index + NPC_findRacePetIndex(meindex, floor); + break; + case NPC_State_WaitDropStake: + { + char tmpbuf[256]; + int statechangetime = CHAR_getWorkInt(meindex, NPC_WORK_STATECHANGE); + if (t1 < statechangetime) + { + if (statechangetime - t1 <= 5) + { + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, PETRACEMASTER_WAITDROPIV_LOOPTIME); + snprintf(tmpbuf, sizeof(tmpbuf), "还有%2d秒就要开跑了,请大家踊跃下注!", + (int)(statechangetime - t1) % 60); + } + else if (statechangetime - t1 <= 10) + { + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, PETRACEMASTER_WAITDROPIII_LOOPTIME); + snprintf(tmpbuf, sizeof(tmpbuf), "还有%2d秒就要开跑了,请大家踊跃下注!", + (int)(statechangetime - t1) % 60); + } + else if (statechangetime - t1 <= 30) + { + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, PETRACEMASTER_WAITDROPII_LOOPTIME); + snprintf(tmpbuf, sizeof(tmpbuf), "还有%2d秒就要开跑了,请大家踊跃下注!", + (int)(statechangetime - t1) % 60); + } + else + snprintf(tmpbuf, sizeof(tmpbuf), "还有%2d分钟%2d秒就要开跑了,请大家踊跃下注!", + (int)(statechangetime - t1) / 60, (int)(statechangetime - t1) % 60); + } + if (t1 >= statechangetime) + { +#ifdef _DROPSTAKENEW +#else + float payrate1 = 0, payrate2 = 0, payrate3 = 0; + int pet1gold = 0, pet2gold = 0, pet3gold = 0, totalgold = 0; + int petindex1 = CHAR_getWorkInt(meindex, NPC_WORK_PET1); + int petindex2 = CHAR_getWorkInt(meindex, NPC_WORK_PET2); + int petindex3 = CHAR_getWorkInt(meindex, NPC_WORK_PET3); + int randpet = CHAR_getWorkInt(meindex, NPC_WORK_PETGROUP); + float droprate1 = 0, droprate2 = 0, droprate3 = 0, totaldroprate, Npayrate = PETRACESTDPAYRATE; +#endif + int i = 0; + CHAR_setWorkInt(meindex, NPC_WORK_STATE, NPC_State_PetRacing); + // 设定地面不可下注 + SetCasinoMap(meindex, 0, FALSE); +#ifdef _DROPSTAKENEW + snprintf(tmpbuf, sizeof(tmpbuf), "请大家停止下注,宠物赛跑开始罗!"); +#else + // 告知大家赔率(取得宠物下注金额计算赔率) + GetCasinoMapGold(meindex, PET_RACE1, &pet1gold); + GetCasinoMapGold(meindex, PET_RACE2, &pet2gold); + GetCasinoMapGold(meindex, PET_RACE3, &pet3gold); + totalgold = pet1gold + pet2gold + pet3gold; + if (totalgold <= 0) + { + payrate1 = 2; payrate2 = 2; payrate3 = 2; + } + else + { + if (pet1gold <= PETRACESTDGOLD) + pet1gold = PETRACESTDGOLD; + if (pet2gold <= PETRACESTDGOLD) + pet2gold = PETRACESTDGOLD; + if (pet3gold <= PETRACESTDGOLD) + pet3gold = PETRACESTDGOLD; + totalgold = pet1gold + pet2gold + pet3gold; + droprate1 = totalgold / pet1gold; + droprate2 = totalgold / pet2gold; + droprate3 = totalgold / pet3gold; + totaldroprate = droprate1 + droprate2 + droprate3; + if (totaldroprate / droprate1 > PETRACESTDPAYRATE) + { + payrate1 = 1; Npayrate -= 1; + } + if (totaldroprate / droprate2 > PETRACESTDPAYRATE) + { + payrate2 = 1; Npayrate -= 1; + } + if (totaldroprate / droprate3 > PETRACESTDPAYRATE) + { + payrate3 = 1; Npayrate -= 1; + } + if (payrate1 != 1) + payrate1 = droprate1 / totaldroprate * Npayrate; + if (payrate2 != 1) + payrate2 = droprate2 / totaldroprate * Npayrate; + if (payrate3 != 1) + payrate3 = droprate3 / totaldroprate * Npayrate; + } + petracegra[randpet].payrate1 = payrate1; + petracegra[randpet].payrate3 = payrate2; + petracegra[randpet].payrate2 = payrate3; + SetCasinoPayRate(meindex, PET_RACE1, payrate1); + SetCasinoPayRate(meindex, PET_RACE2, payrate2); + SetCasinoPayRate(meindex, PET_RACE3, payrate3); + snprintf(tmpbuf, sizeof(tmpbuf), "请大家停止下注,宠物赛跑开始罗!%s的赔率为%5.2f;%s的赔率为%5.2f;%s的赔率为%5.2f", + CHAR_getChar(petindex1, CHAR_NAME), payrate1, + CHAR_getChar(petindex2, CHAR_NAME), payrate2, + CHAR_getChar(petindex3, CHAR_NAME), payrate3); +#endif + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, PETRACEMASTER_PETRACING_LOOPTIME); + // 设定宠物状态 + for (i = 0; i < PETRACEPETNUM; i++) + { + CHAR_setWorkInt(CHAR_getWorkInt(meindex, NPC_WORK_PET1 + i), NPC_WORK_STATE, NPC_State_Run); + CHAR_setInt(CHAR_getWorkInt(meindex, NPC_WORK_PET1 + i), CHAR_LOOPINTERVAL, 1000); + } + } + CHAR_talkToFloor(floor, meindex, tmpbuf, CHAR_COLORWHITE); + } + break; + case NPC_State_PetRacing: + if (CHAR_getWorkInt(meindex, NPC_WORK_PETGOAL) == PETRACEPETNUM) + { + char tmpbuf[256]; + int winpetindex = CHAR_getWorkInt(meindex, NPC_WORK_WINPET); + int petgroup = CHAR_getWorkInt(meindex, NPC_WORK_PETGROUP); + snprintf(tmpbuf, sizeof(tmpbuf), "竞赛结束,胜利的宠物是:%s\n", + CHAR_getChar(winpetindex, CHAR_NAME)); + CHAR_talkToFloor(floor, meindex, tmpbuf, CHAR_COLORYELLOW); + // 设定输赢,以计算赔率 + if (CHAR_getWorkInt(meindex, NPC_WORK_PET1) == winpetindex) + petracegra[petgroup].pet1win = petracegra[petgroup].pet1win + 1; + else if (CHAR_getWorkInt(meindex, NPC_WORK_PET2) == winpetindex) + petracegra[petgroup].pet2win = petracegra[petgroup].pet2win + 1; + else if (CHAR_getWorkInt(meindex, NPC_WORK_PET3) == winpetindex) + petracegra[petgroup].pet3win = petracegra[petgroup].pet3win + 1; + CHAR_setWorkInt(meindex, NPC_WORK_STATE, NPC_State_ShowWinPet); + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, PETRACEMASTER_SHOWWINPET_LOOPTIME); + CHAR_setWorkInt(meindex, NPC_WORK_STATECHANGE, t1 + PETRACESHOWWINPET); + // 发奖金 + NPC_givePriceToPlayer(meindex, floor, winpetindex); + } + break; + case NPC_State_ShowWinPet: + { + int statechangetime = CHAR_getWorkInt(meindex, NPC_WORK_STATECHANGE); + if (t1 >= statechangetime) + { + int randpet = RAND(0, arraysizeof(petracegra) - 1); + int petindex1 = CHAR_getWorkInt(meindex, NPC_WORK_PET1); + int petindex2 = CHAR_getWorkInt(meindex, NPC_WORK_PET2); + int petindex3 = CHAR_getWorkInt(meindex, NPC_WORK_PET3); + char tmpbuf[256]; + CHAR_setWorkInt(meindex, NPC_WORK_PETGROUP, randpet); + CHAR_setWorkInt(meindex, NPC_WORK_STATE, NPC_State_WaitDropStake); + CHAR_setWorkInt(meindex, NPC_WORK_WINPET, 0); + CHAR_setWorkInt(meindex, NPC_WORK_PETGOAL, 0); + CHAR_setWorkInt(meindex, NPC_WORK_STATECHANGE, t1 + PETRACEDROPSTAKETIME); + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, PETRACEMASTER_WAITDROPI_LOOPTIME); + // 设定地面可下注 + SetCasinoMap(meindex, 0, TRUE); + // 设定宠物 + CHAR_setWorkInt(petindex1, NPC_WORK_STATE, NPC_State_Wait); + CHAR_setInt(petindex1, CHAR_LOOPINTERVAL, 1000); + CHAR_setInt(petindex1, CHAR_BASEIMAGENUMBER, petracegra[randpet].pet1gra); + CHAR_setChar(petindex1, CHAR_NAME, petracegra[randpet].pet1name); + + CHAR_setWorkInt(petindex2, NPC_WORK_STATE, NPC_State_Wait); + CHAR_setInt(petindex2, CHAR_LOOPINTERVAL, 1000); + CHAR_setInt(petindex2, CHAR_BASEIMAGENUMBER, petracegra[randpet].pet2gra); + CHAR_setChar(petindex2, CHAR_NAME, petracegra[randpet].pet2name); + + CHAR_setWorkInt(petindex3, NPC_WORK_STATE, NPC_State_Wait); + CHAR_setInt(petindex3, CHAR_LOOPINTERVAL, 1000); + CHAR_setInt(petindex3, CHAR_BASEIMAGENUMBER, petracegra[randpet].pet3gra); + CHAR_setChar(petindex3, CHAR_NAME, petracegra[randpet].pet3name); + // 设定宠物状况 +#ifdef _DROPSTAKENEW +#else + petracegra[randpet].payrate1 = 0; + petracegra[randpet].payrate3 = 0; + petracegra[randpet].payrate2 = 0; +#endif + { + int state1 = RAND(0, 3); + int state2 = RAND(0, 3); + int state3 = RAND(0, 3); + if (state1 == 0) + sprintf(petracegra[randpet].state1, "良好"); + else if (state1 == 1) + sprintf(petracegra[randpet].state1, "普通"); + else if (state1 == 2) + sprintf(petracegra[randpet].state1, "不佳"); + else if (state1 == 3) + sprintf(petracegra[randpet].state1, "未知"); + if (state2 == 0) + sprintf(petracegra[randpet].state2, "良好"); + else if (state2 == 1) + sprintf(petracegra[randpet].state2, "普通"); + else if (state2 == 2) + sprintf(petracegra[randpet].state2, "不佳"); + else if (state2 == 3) + sprintf(petracegra[randpet].state2, "未知"); + if (state3 == 0) + sprintf(petracegra[randpet].state3, "良好"); + else if (state3 == 1) + sprintf(petracegra[randpet].state3, "普通"); + else if (state3 == 2) + sprintf(petracegra[randpet].state3, "不佳"); + else if (state3 == 3) + sprintf(petracegra[randpet].state3, "未知"); + } + snprintf(tmpbuf, sizeof(tmpbuf), "宠物竞速准备中,请大家踊跃下注!"); + CHAR_talkToFloor(floor, meindex, tmpbuf, CHAR_COLORYELLOW); + } + } + break; + default: + break; + } +} + +void NPC_findRacePetIndex(int meindex, int floor) +{ + int i = 0, j = 0; + time_t t1; + time(&t1); + + if (CHAR_getWorkInt(meindex, NPC_WORK_FINDPETFLAG) == 0) + { + for (i = 0; i < CHAR_getCharNum(); i++) + { + if (CHAR_getInt(i, CHAR_FLOOR) == floor) + { + if (CHAR_getInt(i, CHAR_WHICHTYPE) == CHAR_PETRACEPET) + { + for (j = 0; j < PETRACEPETNUM; j++) + { + if (CHAR_getWorkInt(meindex, NPC_WORK_PET1 + j) == 0) + { + CHAR_setWorkInt(meindex, NPC_WORK_PET1 + j, i); + CHAR_setWorkInt(i, CHAR_NPCWORKINT2, meindex); + break; + } + } + } + } + } + if (CHAR_getWorkInt(meindex, NPC_WORK_PET1) > 0 + && CHAR_getWorkInt(meindex, NPC_WORK_PET2) > 0 + && CHAR_getWorkInt(meindex, NPC_WORK_PET3) > 0) + { + CHAR_setWorkInt(meindex, NPC_WORK_FINDPETFLAG, 1); + CHAR_setWorkInt(meindex, NPC_WORK_STATE, NPC_State_WaitDropStake); + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, PETRACEMASTER_WAITDROPI_LOOPTIME); + CHAR_setWorkInt(meindex, NPC_WORK_STATECHANGE, t1 + PETRACEDROPSTAKETIME); + } + else CHAR_setWorkInt(meindex, NPC_WORK_FINDPETFLAG, 0); + } +} + +void NPC_givePriceToPlayer(int meindex, int floor, int winpetindex) +{ + int wincasinotype = 0; + if (CHAR_getWorkInt(meindex, NPC_WORK_PET1) == winpetindex) + wincasinotype = PET_RACE1; + else if (CHAR_getWorkInt(meindex, NPC_WORK_PET2) == winpetindex) + wincasinotype = PET_RACE2; + else if (CHAR_getWorkInt(meindex, NPC_WORK_PET3) == winpetindex) + wincasinotype = PET_RACE3; + if (wincasinotype == 0) return; + else + CasinoPay(meindex, wincasinotype); +} +#endif diff --git a/gmsv/npc/npc_petracepet.c b/gmsv/npc/npc_petracepet.c new file mode 100644 index 0000000..4779ad5 --- /dev/null +++ b/gmsv/npc/npc_petracepet.c @@ -0,0 +1,274 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "handletime.h" + +#ifdef _PETRACE +#include "npc_petracepet.h" + +#define PETRACEPET_WAIT_LOOPTIME 30000 // 30秒 +#define PETRACEPET_SHOWWIN_LOOPTIME 10000 // 10秒 + +static void NPC_PetRacePet_Walk(int meindex); +static int NPC_PetRacePetSetPoint(int meindex, char *argstr); + +enum +{ + NPC_WORK_STATE = CHAR_NPCWORKINT1, + NPC_WORK_MASTER = CHAR_NPCWORKINT2, + NPC_WORK_ROUTEPOINT = CHAR_NPCWORKINT3, + NPC_WORK_ROUTETOX = CHAR_NPCWORKINT4, + NPC_WORK_ROUTETOY = CHAR_NPCWORKINT5, + NPC_WORK_WAITFLAG = CHAR_NPCWORKINT6, + NPC_WORK_FLOOR = CHAR_NPCWORKINT7, + NPC_WORK_X = CHAR_NPCWORKINT8, + NPC_WORK_Y = CHAR_NPCWORKINT9, + NPC_WORK_DIR = CHAR_NPCWORKINT10, + NPC_WORK_STOPX = CHAR_NPCWORKINT11, + NPC_WORK_STOPY = CHAR_NPCWORKINT12, +}; +enum +{ + NPC_State_Wait, + NPC_State_Run, + NPC_State_ShowWin, +}; + +BOOL NPC_PetRacePetInit( int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[256]; + int showstopx, showstopy; + int routenum = 0, i = 0; + + NPC_Util_GetArgStr(meindex, argstr, sizeof(argstr)); + for (i = 1; i <= routenum; i++) + { + char routetostring[64]; + snprintf(routetostring, sizeof(routetostring), "routeto"); + if (NPC_Util_GetStrFromStrWithDelim(argstr, routetostring, buf, sizeof(buf)) == NULL) + { + print("Init_npcracepet: Didn't set route\n"); + return FALSE; + } + } + showstopx = NPC_Util_GetNumFromStrWithDelim(argstr, "showstopx"); + showstopy = NPC_Util_GetNumFromStrWithDelim(argstr, "showstopy"); + if (showstopx < 0 || showstopx > 100 || showstopy < 0 || showstopy > 100) + return FALSE; + CHAR_setInt(meindex, CHAR_WHICHTYPE, CHAR_PETRACEPET); + CHAR_setWorkInt(meindex, NPC_WORK_STATE, NPC_State_Wait); + CHAR_setWorkInt(meindex, NPC_WORK_ROUTEPOINT, 2); + CHAR_setWorkInt(meindex, NPC_WORK_WAITFLAG, 1); + CHAR_setWorkInt(meindex, NPC_WORK_FLOOR, CHAR_getInt(meindex, CHAR_FLOOR)); + CHAR_setWorkInt(meindex, NPC_WORK_X, CHAR_getInt(meindex, CHAR_X)); + CHAR_setWorkInt(meindex, NPC_WORK_Y, CHAR_getInt(meindex, CHAR_Y)); + CHAR_setWorkInt(meindex, NPC_WORK_DIR, CHAR_getInt(meindex, CHAR_DIR)); + CHAR_setWorkInt(meindex, NPC_WORK_STOPX, showstopx); + CHAR_setWorkInt(meindex, NPC_WORK_STOPY, showstopy); + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, PETRACEPET_WAIT_LOOPTIME); + NPC_PetRacePetSetPoint(meindex, argstr); + + return TRUE; +} + +void NPC_PetRacePetTalked( int meindex , int talkerindex , char *szMes , int color ) +{ +} + +void NPC_PetRacePetLoop( int meindex) +{ + switch(CHAR_getWorkInt(meindex, NPC_WORK_STATE)) + { + case NPC_State_Wait: + { + if (CHAR_getWorkInt(meindex, NPC_WORK_WAITFLAG) == 0) + { + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + NPC_Util_GetArgStr(meindex, argstr, sizeof(argstr)); + CHAR_setWorkInt(meindex, NPC_WORK_ROUTEPOINT, 2); + NPC_PetRacePetSetPoint(meindex, argstr); + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, PETRACEPET_WAIT_LOOPTIME); + CHAR_setInt(meindex, CHAR_DIR, CHAR_getWorkInt(meindex, NPC_WORK_DIR)); + CHAR_warpToSpecificPoint(meindex, + CHAR_getWorkInt(meindex, NPC_WORK_FLOOR), + CHAR_getWorkInt(meindex, NPC_WORK_X), + CHAR_getWorkInt(meindex, NPC_WORK_Y)); + CHAR_setWorkInt(meindex, NPC_WORK_WAITFLAG, 1); + } + } + break; + case NPC_State_Run: + { + int interval = 50; + int random = 0; + if (CHAR_getWorkInt(meindex, NPC_WORK_ROUTETOX) <= CHAR_getWorkInt(meindex, NPC_WORK_STOPX) + && CHAR_getWorkInt(meindex, NPC_WORK_ROUTETOY) >= CHAR_getWorkInt(meindex, NPC_WORK_STOPY)) + random = 3; + else + random = RAND(0, 8); + if (random == 0) // 攻击 + { + int rands = RAND(0, 3); + interval = 1500; + CHAR_sendAction(meindex, 0, FALSE); + if (rands == TRUE) + { + char tmpbuf[256]; + int floor = CHAR_getInt(meindex, CHAR_FLOOR); + int master = CHAR_getWorkInt(meindex, NPC_WORK_MASTER); + int randomi = RAND(1, 9); + if (randomi == 1) + snprintf(tmpbuf, sizeof(tmpbuf), "哦~看来%s好像发威了唷!", + CHAR_getChar(meindex, CHAR_NAME)); + else if (randomi == 2) + snprintf(tmpbuf, sizeof(tmpbuf), "%s使出了奋力的一击~", + CHAR_getChar(meindex, CHAR_NAME)); + else if (randomi == 3) + snprintf(tmpbuf, sizeof(tmpbuf), "咦...%s发怒了?", + CHAR_getChar(meindex, CHAR_NAME)); + if (randomi > 0 && randomi < 4) + CHAR_talkToFloor(floor, master, tmpbuf, CHAR_COLORWHITE); + } + } + else if (random == 1) // 晕倒 + { + int rands = RAND(0, 3); + interval = 2500; + CHAR_sendAction(meindex, 2, FALSE); + if (rands == TRUE) + { + char tmpbuf[256]; + int floor = CHAR_getInt(meindex, CHAR_FLOOR); + int master = CHAR_getWorkInt(meindex, NPC_WORK_MASTER); + int randomi = RAND(1, 9); + if (randomi == 1) + snprintf(tmpbuf, sizeof(tmpbuf), "%s好像晕倒了呢...", + CHAR_getChar(meindex, CHAR_NAME)); + else if (randomi == 2) + snprintf(tmpbuf, sizeof(tmpbuf), "%s受伤了吗?", + CHAR_getChar(meindex, CHAR_NAME)); + else if (randomi == 3) + snprintf(tmpbuf, sizeof(tmpbuf), "嘿...%s晕倒後又勇敢的爬起来了!", + CHAR_getChar(meindex, CHAR_NAME)); + if (randomi > 0 && randomi < 4) + CHAR_talkToFloor(floor, master, tmpbuf, CHAR_COLORWHITE); + } + } + else if (random == 2) // 站立 + { + interval = 500; + CHAR_sendAction(meindex, 3, FALSE); + } + else // 一般 + interval = RAND(20, 100); + NPC_PetRacePet_Walk(meindex); + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, interval); + } + break; + case NPC_State_ShowWin: + { + int action = RAND(0, 11); + CHAR_sendAction(meindex, action, FALSE); + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, PETRACEPET_SHOWWIN_LOOPTIME); + } + break; + default: + break; + } +} + +static void NPC_PetRacePet_Walk(int meindex) +{ + POINT start, end; + int dir, i; + + start.x = CHAR_getInt(meindex, CHAR_X); + start.y = CHAR_getInt(meindex, CHAR_Y); + end.x = CHAR_getWorkInt(meindex, NPC_WORK_ROUTETOX); + end.y = CHAR_getWorkInt(meindex, NPC_WORK_ROUTETOY); + if (start.x == end.x && start.y == end.y) + { + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + NPC_Util_GetArgStr(meindex, argstr, sizeof( argstr)); + CHAR_setWorkInt(meindex, NPC_WORK_ROUTEPOINT, + CHAR_getWorkInt(meindex, NPC_WORK_ROUTEPOINT) + 1); + + if (NPC_PetRacePetSetPoint(meindex, argstr) == FALSE) + { + // 到达目的地後,初始状态 + char tmpbuf[256]; + int masterindex = CHAR_getWorkInt(meindex, NPC_WORK_MASTER); + int petgoal = CHAR_getWorkInt(masterindex, CHAR_NPCWORKINT9); + int floor = CHAR_getInt(masterindex, CHAR_FLOOR); + if (CHAR_getWorkInt(masterindex, CHAR_NPCWORKINT8) == 0) + { + CHAR_setWorkInt(masterindex, CHAR_NPCWORKINT8, meindex); + CHAR_sendAction(meindex, 3, FALSE); + snprintf(tmpbuf, sizeof(tmpbuf), "首先到达目的地的是...%s", + CHAR_getChar(meindex, CHAR_NAME)); + } + else + { + CHAR_warpToSpecificPoint(meindex, 888, 7, 7); + snprintf(tmpbuf, sizeof(tmpbuf), "接着到达目的地的是...%s", + CHAR_getChar(meindex, CHAR_NAME)); + } + CHAR_setWorkInt(meindex, NPC_WORK_STATE, NPC_State_ShowWin); + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, 500); + CHAR_setWorkInt(meindex, NPC_WORK_WAITFLAG, 0); + CHAR_setWorkInt(masterindex, CHAR_NPCWORKINT9, petgoal + 1); + CHAR_talkToFloor(floor, masterindex, tmpbuf, CHAR_COLORWHITE); + return; + } + else + return; + } + dir = NPC_Util_getDirFromTwoPoint(&start, &end); + end.x = CHAR_getInt(meindex, CHAR_X); + end.y = CHAR_getInt(meindex, CHAR_Y); + for(i = 0; i < 100; i++) + { + if (dir < 0) + dir = RAND(0, 7); + dir = NPC_Util_SuberiWalk(meindex, dir); + if (dir >= 0 && dir <= 7) break; + } + if (dir >= 0 && dir <= 7) + { + int result = 0; + result = CHAR_walk(meindex, dir, 0); + } +} + +static int NPC_PetRacePetSetPoint(int meindex, char *argstr) +{ + // 寻找下一步 x , y + char buf[4096], buf2[256], buf3[256]; + int ret; + char routetostring[64]; + snprintf(routetostring, sizeof(routetostring), "routeto"); + if (NPC_Util_GetStrFromStrWithDelim(argstr, routetostring, buf, sizeof(buf)) == NULL) + { + print("SetPoint_npcracepet: Didn't set route %s\n", routetostring); + return FALSE; + } + ret = getStringFromIndexWithDelim(buf, ";", + CHAR_getWorkInt(meindex, NPC_WORK_ROUTEPOINT), buf2, sizeof(buf2)); + if (ret == FALSE) return FALSE; + ret = getStringFromIndexWithDelim(buf2, ",", 1, buf3, sizeof(buf3)); + if (ret == FALSE) return FALSE; + CHAR_setWorkInt(meindex, NPC_WORK_ROUTETOX, atoi(buf3)); + ret = getStringFromIndexWithDelim(buf2, ",", 2, buf3, sizeof(buf3)); + if (ret == FALSE) return FALSE; + CHAR_setWorkInt(meindex, NPC_WORK_ROUTETOY, atoi(buf3)); + return TRUE; +} + +#endif + + diff --git a/gmsv/npc/npc_petshop.c b/gmsv/npc/npc_petshop.c new file mode 100644 index 0000000..8f5f4a3 --- /dev/null +++ b/gmsv/npc/npc_petshop.c @@ -0,0 +1,1481 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "pet_skill.h" +#include "readmap.h" +#include "battle.h" +#include "log.h" +#ifdef _CHECK_ENEMY_PET +#include "enemy.h" +#endif +/* 丢永本□斥及enum */ +enum { + NPC_PETSHOP_MSG_OVER, + NPC_PETSHOP_MSG_MAIN, + NPC_PETSHOP_MSG_REALY, + NPC_PETSHOP_MSG_THANKS, + NPC_PETSHOP_MSG_COST, + NPC_PETSHOP_MSG_POOLTHANKS, + NPC_PETSHOP_MSG_POOLFULL, + NPC_PETSHOP_MSG_GETFULL, +}; +typedef struct { + char option[32]; + char defaultmsg[128]; +}NPC_PETSHOP_MSG; + +NPC_PETSHOP_MSG shopmsg[] = { + { "over_msg", "钱用完罗!没问题吗?"}, + { "main_msg", "欢迎"}, + { "realy_msg", "真的可以吗?"}, + { "thanks_msg", "谢谢!"}, + { "cost_msg", "钱不够喔!"}, + { "pooltanks_msg", "谢谢!"}, + { "poolfull_msg", "超过的无法处理喔"}, + { "getfull_msg", "你不是有很多宠物吗"} + +}; + +#define PETCOST 10 + +void NPC_PetDate(int meindex,int toindex,int select,char *token); +void NPC_PetDate2(int meindex,int talker,int select,char *token); +void NPC_PetDate3(int meindex,int talker,int select,char *token); +void NPC_PetDel2( int meindex, int talker, int select, char *token); +void NPC_PetDel3( int meindex, int talker, int select, char *token); +void NPC_getDrawPet( int meindex, int toindex, char *token, int *buttontype, int select); + +static void NPC_PetShop_selectWindow( int meindex, int toindex, int num,int select); +int NPC_GetCost(int meindex,int talker,int petindex); +void NPC_PetDel(int meindex, int toindex,int select,char* token); +void NPC_MaxGoldOver(int meindex,int toindex,int select,char *token); + +#ifdef _NPC_DEPOTPET +void NPC_PoolPetShop_DepotPet_Menu( int meindex, int talkerindex); +void NPC_DepotPet_List( int meindex, int toindex, char *token, int *buttontype, int select); +void NPC_DepotPet_Add( int meindex, int talker, int select, char *token); +void NPC_DepotPet_Get( int meindex, int talker, int select, char *token); +void NPC_DepotPet_AskGet(int meindex,int talker,int select,char *token); +//void NPC_DepotPet_Pet_printWindow( int meindex, int talkerindex); +//void NPC_DepotPet_Depot_printWindow( int meindex, int talkerindex); +//BOOL NPC_DepotPet_InsertPet( int meindex, int talkerindex, int num); +//BOOL NPC_DepotPet_getPet( int meindex, int talkerindex, int num); +#endif + + +// 仃 木嗯喊煌遥挚 +#define NPC_GETPOOLCOST( talker) ( 50 + CHAR_getInt( talker, CHAR_LV)*4) + +// 仃 木嗯犯白巧伙玄 +#define NPC_PETSHOP_POOLCOST_DEFAULT 200 + +/*--伐□弁 及割忡--*/ +enum { + CHAR_WORK_NOMALRATE = CHAR_NPCWORKINT1, + CHAR_WORK_SPECIALRATE = CHAR_NPCWORKINT2, + CHAR_WORK_POOLCOST = CHAR_NPCWORKINT3, + CHAR_WORK_POOLFLG = CHAR_NPCWORKINT4, +}; + + +/********************************* +* 赓渝质 +*********************************/ +BOOL NPC_PetShopInit( int meindex ) +{ + + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[256]; + double rate; + int intrate; +// int cost; + int tmp; + + /*--正奶皿涩烂--*/ + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPESTONESHOP ); + + + if( NPC_Util_GetArgStr( meindex, npcarg, sizeof( npcarg)) == NULL){ + print("GetArgStrErr"); + return FALSE; + } + + /*--伊□玄毛铵户卞筏盛今六化云仁*/ + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "nomal_rate", buf, sizeof( buf)) != NULL){ + rate = atof( buf); + intrate = ( int)( rate *1000); + CHAR_setWorkInt( meindex , CHAR_WORK_NOMALRATE ,intrate ); + }else{ + CHAR_setWorkInt( meindex , CHAR_WORK_NOMALRATE ,1000 ); + } + + + /*--旦矢扑乓伙伊□玄手筏盛今六化云仁--*/ + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "special_rate", buf, sizeof( buf)) + !=NULL) + { + rate = atof( buf); + intrate = ( int)( rate *1000); + CHAR_setWorkInt( meindex , CHAR_WORK_SPECIALRATE ,intrate ); + }else{ + CHAR_setWorkInt( meindex , CHAR_WORK_SPECIALRATE ,1200 ); + } + + // 仃 木嗯筏盛 + //cost = NPC_Util_GetNumFromStrWithDelim( npcarg, "pool_cost"); + //if( cost == -1 ) cost = NPC_PETSHOP_POOLCOST_DEFAULT; + //CHAR_setWorkInt( meindex, CHAR_WORK_POOLCOST, cost); + + + // 仃 木互请 月井升丹井毛筏盛 + tmp = NPC_Util_GetNumFromStrWithDelim( npcarg, "pool_flg"); + if( tmp != 1 ) tmp = 0; + CHAR_setWorkInt( meindex, CHAR_WORK_POOLFLG, tmp); + + return TRUE; + +} + + + + +/********************************* +* 仄井仃日木凶凛及质 +*********************************/ +void NPC_PetShopTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + + /* 皿伊奶乩□卞覆仄化分仃 杀允月 */ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + + + /*-- 及蟆卞中月井升丹井"--*/ + if(NPC_Util_isFaceToFace(talkerindex,meindex,2 )==FALSE){ + /* ㄠ弘伉永玉动 及心 */ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) return; + } + + /*--伐□弁及赓渝祭--*/ + CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANT,0); + + /*-反元户及蓟 --*/ + NPC_PetShop_selectWindow( meindex, talkerindex,0,-1); + +} + +/********************************* +* 苇日木凶凛及质 +*********************************/ +void NPC_PetShopLooked( int meindex , int lookedindex) +{ + /* 皿伊奶乩□卞覆仄化分仃 杀允月 */ + if( CHAR_getInt( lookedindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + + /* ㄠ弘伉永玉动 及心 */ + if( NPC_Util_CharDistance( lookedindex, meindex ) > 2) return; + + /*--伐□弁及赓渝祭--*/ +// CHAR_setWorkInt(lookedindex,CHAR_WORKSHOPRELEVANT,0); + + +// NPC_PetShop_selectWindow( meindex, lookedindex,0,-1); + +} + +static void NPC_PetShop_selectWindow( int meindex, int toindex, int num,int select) +{ + + char token[1024]; + int buttontype=0,windowtype=0,windowno=0; + char buf[1024]; + int fd = getfdFromCharaIndex( toindex); + + //print("\n NPC_PetShop_selectWindow num:%d select:%d ", num, select); + + if( fd == -1 ) { + fprint( "getfd err\n"); + return; + } + + token[0] = '\0'; + + switch(num){ + // 赓及它奴件玉它 + case 0: + NPC_MaxGoldOver( meindex, toindex, NPC_PETSHOP_MSG_MAIN, buf); +#ifdef _NPC_DEPOTPET + if( !CHAR_getWorkInt( meindex, CHAR_WORK_POOLFLG)) { + sprintf(token, "4\n      ☆宠物商店☆" + "%s" + "\n" + "\n       《 卖宠物 》" + "\n" + "\n" + "\n 《 离开 》", + buf); + }else { + sprintf(token, "4\n      ☆宠物商店☆" + "%s" + "\n 《 寄放宠物 》" + "\n 《 领取宠物 》" + "\n       《 卖宠物 》" + "\n 《 使用仓库 》" + "\n 《 离开 》", + buf); + } +#else + if( !CHAR_getWorkInt( meindex, CHAR_WORK_POOLFLG)) { + sprintf(token, "4\n      ☆宠物商店☆" + "%s" + "\n" + "\n       《 卖宠物 》" + "\n" + "\n 《 离开 》", + buf); + }else { + sprintf(token, "4\n      ☆宠物商店☆" + "%s" + "\n 《 寄放宠物 》" + "\n 《 领取宠物 》" + "\n       《 卖宠物 》" + "\n 《 离开 》", + buf); + } +#endif + + buttontype=WINDOW_BUTTONTYPE_NONE; + windowtype=WINDOW_MESSAGETYPE_SELECT; + windowno=CHAR_WINDOWTYPE_WINDOWPETSHOP_START; + break; + case 1: + buttontype=WINDOW_BUTTONTYPE_CANCEL; + windowtype=WINDOW_MESSAGETYPE_PETSELECT; + windowno=CHAR_WINDOWTYPE_WINDOWPETSHOP_PETSELECT; + break; + case 2: + NPC_PetDate(meindex,toindex,select,token); + buttontype=WINDOW_BUTTONTYPE_YESNO; + windowtype=WINDOW_MESSAGETYPE_MESSAGE; + windowno=CHAR_WINDOWTYPE_WINDOWPETSHOP_MAIN; + break; + case 3: + if( (CHAR_getInt(toindex,CHAR_GOLD)+CHAR_getWorkInt(toindex,CHAR_WORKSHOPRELEVANTSEC)) + > CHAR_getMaxHaveGold( toindex) ){ + + NPC_MaxGoldOver( meindex, toindex, NPC_PETSHOP_MSG_OVER, token); + windowno=CHAR_WINDOWTYPE_WINDOWPETSHOP_GOLDOVER; + buttontype=WINDOW_BUTTONTYPE_YESNO; + }else{ + NPC_PetDel(meindex,toindex,select,token); + buttontype=WINDOW_BUTTONTYPE_OK; + windowno=CHAR_WINDOWTYPE_WINDOWPETSHOP_END; + } + + windowtype=WINDOW_MESSAGETYPE_MESSAGE; + break; + case 4: + NPC_PetDel(meindex,toindex,select,token); + buttontype=WINDOW_BUTTONTYPE_OK; + windowno=CHAR_WINDOWTYPE_WINDOWPETSHOP_END; + windowtype=WINDOW_MESSAGETYPE_MESSAGE; + break; + case 5: // 领取寄放宠列表 + if( CHAR_getWorkInt( meindex, CHAR_WORK_POOLFLG ) != 1 ) + return; + buttontype=WINDOW_BUTTONTYPE_CANCEL; + windowtype=WINDOW_MESSAGETYPE_PETSELECT; + windowno=CHAR_WINDOWTYPE_WINDOWPETSHOP_PETSELECT2; + break; + case 6: + if( CHAR_getInt( toindex, CHAR_GOLD) + < NPC_GETPOOLCOST( toindex)) + { + NPC_MaxGoldOver(meindex, toindex, NPC_PETSHOP_MSG_COST, token); + buttontype = WINDOW_BUTTONTYPE_OK; + } + else { + NPC_PetDate2( meindex, toindex, select, token); + buttontype = WINDOW_BUTTONTYPE_YESNO; + } + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_WINDOWPETSHOP_MAIN2; + break; + + case 7: + if( CHAR_getWorkInt( meindex, CHAR_WORK_POOLFLG ) != 1 ) + return; + if( CHAR_getInt( toindex, CHAR_GOLD) < NPC_GETPOOLCOST( toindex)){ + NPC_MaxGoldOver(meindex, toindex, NPC_PETSHOP_MSG_COST, token); + }else { + NPC_PetDel2( meindex, toindex, select, token); + } + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_WINDOWPETSHOP_END; + break; + // 仃 木 互域 + case 8: + NPC_MaxGoldOver( meindex, toindex, NPC_PETSHOP_MSG_POOLFULL, token); + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_WINDOWPETSHOP_END; + break; + // 娄五潸曰矢永玄域 它奴件玉它 + case 9: // 取出寄放宠列表 + if( CHAR_getWorkInt( meindex, CHAR_WORK_POOLFLG) != 1 ) + return; + NPC_getDrawPet( meindex, toindex, token, &buttontype, select); + windowtype = WINDOW_MESSAGETYPE_SELECT; + windowno = CHAR_WINDOWTYPE_WINDOWPETSHOP_DRAWSELECT; + break; + // 娄五潸曰 " + case 10: + NPC_PetDate3( meindex, toindex, select, token); + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_WINDOWPETSHOP_ASKDRAW; + break; + // 忒允 + case 11: + if( CHAR_getWorkInt( meindex, CHAR_WORK_POOLFLG ) != 1 ) + return; + NPC_PetDel3( meindex, toindex, select, token); + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_WINDOWPETSHOP_END; + break; + // 矢永玄 互域 + case 12: + NPC_MaxGoldOver( meindex, toindex, NPC_PETSHOP_MSG_GETFULL, token); + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_WINDOWPETSHOP_END; + break; +#ifdef _NPC_DEPOTPET + case 13: // 存入仓库列表 + if( !CHAR_CheckDepotPet( toindex) ) + return; + buttontype=WINDOW_BUTTONTYPE_CANCEL; + windowtype=WINDOW_MESSAGETYPE_PETSELECT; + windowno=CHAR_WINDOWTYPE_DEPOTPETSHOP_ADD; + break; + case 14: // 取出仓库列表 + if( !CHAR_CheckDepotPet( toindex) ) + return; + NPC_DepotPet_List( meindex, toindex, token, &buttontype, select); + //buttontype=WINDOW_BUTTONTYPE_CANCEL; + windowtype = WINDOW_MESSAGETYPE_SELECT; + windowno = CHAR_WINDOWTYPE_DEPOTPETSHOP_GET; + break; + + case 15: // 询问确认存入仓库 + if( CHAR_getInt( toindex, CHAR_GOLD) + < NPC_GETPOOLCOST( toindex)) + { + NPC_MaxGoldOver(meindex, toindex, NPC_PETSHOP_MSG_COST, token); + buttontype = WINDOW_BUTTONTYPE_OK; + } + else { + NPC_PetDate2( meindex, toindex, select, token); + buttontype = WINDOW_BUTTONTYPE_YESNO; + } + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_DEPOTPETSHOP_ASKADD; + break; + + case 16: // 询问确认取出仓库 + NPC_DepotPet_AskGet( meindex, toindex, select, token); + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_DEPOTPETSHOP_ASKGET; + break; + + case 17: // 确认存入仓库 + if( !CHAR_CheckDepotPet(toindex) ) + return; + if( CHAR_getInt( toindex, CHAR_GOLD) < NPC_GETPOOLCOST( toindex)){ + NPC_MaxGoldOver(meindex, toindex, NPC_PETSHOP_MSG_COST, token); + }else { + NPC_DepotPet_Add( meindex, toindex, select, token); + } + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_WINDOWPETSHOP_END; + break; + + case 18: // 确认取出仓库 + if( CHAR_getWorkInt( meindex, CHAR_WORK_POOLFLG ) != 1 ) + return; + if( NPC_DepotPet_CheckLevel( meindex, toindex, select, token) == TRUE) { + NPC_DepotPet_Get( meindex, toindex, select, token); + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_WINDOWPETSHOP_END; + } + else { + sprintf( token, "\n你无法照顾这只宠物。"); + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_WINDOWPETSHOP_END; + } + break; +#endif + // CoolFish: Add 2001/7/4 + default: + break; + + } + + /*--巨旦弗□皿--*/ + //makeEscapeString( token, escapedname, sizeof(escapedname)); + + + /*--霜耨--*/ + lssproto_WN_send( fd, windowtype, + buttontype, + windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + +} + +void NPC_PetShopWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + int datanum = -1; + if( NPC_Util_CharDistance( talkerindex, meindex ) > 2) { + return; + } + + //print("\n NPC_PetShopWindowTalked: data:%s seq:%d sel:%d ", data, seqno, select); + + makeStringFromEscaped( data); + + datanum = atoi( data); + + switch( seqno){ + case CHAR_WINDOWTYPE_WINDOWPETSHOP_START: + { + int poolflg = CHAR_getWorkInt( meindex, CHAR_WORK_POOLFLG); + + if( ( datanum == 3 && poolflg) || // 卖宠物 + ( datanum == 2 && !poolflg ) ){ // 领取宠物 + NPC_PetShop_selectWindow( meindex, talkerindex, 1, -1 ); + }else if( datanum == 1 && poolflg) { // 寄放宠物 + if( CHAR_getCharPoolPetElement( talkerindex) != -1 ) { + NPC_PetShop_selectWindow( meindex, talkerindex, 5, -1 ); + } + else { + NPC_PetShop_selectWindow( meindex, talkerindex, 8, -1 ); + } + }else if( datanum == 2 && poolflg ) { // 领取宠物 + if( CHAR_getCharPetElement( talkerindex) != -1 ) { + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + NPC_PetShop_selectWindow( meindex, talkerindex, 9, 0); + }else { + NPC_PetShop_selectWindow( meindex, talkerindex, 12, -1 ); + } + } +#ifdef _NPC_DEPOTPET + else if( datanum == 4 ) { // 使用宠物仓库 + print(" 使用宠物仓库 "); + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + if( !CHAR_CheckDepotPet( talkerindex) ){ + CHAR_GetDepotPet( meindex, talkerindex); + CHAR_talkToCli( talkerindex, -1, "取得宠物,请稍後!", CHAR_COLORYELLOW); + }else{ + NPC_PoolPetShop_DepotPet_Menu( meindex, talkerindex); + } + } +#endif + } + break; + case CHAR_WINDOWTYPE_WINDOWPETSHOP_PETSELECT: + if(select==WINDOW_BUTTONTYPE_CANCEL){ + NPC_PetShop_selectWindow( meindex, talkerindex, 0,-1 ); + + }else{ + NPC_PetShop_selectWindow( meindex, talkerindex, 2, datanum ); + } + break; + case CHAR_WINDOWTYPE_WINDOWPETSHOP_PETSELECT2: + if(select==WINDOW_BUTTONTYPE_CANCEL){ + NPC_PetShop_selectWindow( meindex, talkerindex, 0,-1 ); + }else{ + NPC_PetShop_selectWindow( meindex, talkerindex, 6, datanum ); + } + break; + case CHAR_WINDOWTYPE_WINDOWPETSHOP_MAIN: + if(select==WINDOW_BUTTONTYPE_YES){ + NPC_PetShop_selectWindow( meindex, talkerindex, 3,-1 ); + }else{ + NPC_PetShop_selectWindow( meindex, talkerindex,1,-1); + } + break; + case CHAR_WINDOWTYPE_WINDOWPETSHOP_MAIN2: + if(select==WINDOW_BUTTONTYPE_YES){ + NPC_PetShop_selectWindow( meindex, talkerindex, 7,-1 ); + }else { + NPC_PetShop_selectWindow( meindex, talkerindex,5,-1); + } + break; + case CHAR_WINDOWTYPE_WINDOWPETSHOP_ASKDRAW: + if( select == WINDOW_BUTTONTYPE_YES){ + if( CHAR_getCharPetElement( talkerindex) != -1 ) { + NPC_PetShop_selectWindow( meindex, talkerindex, 11,-1 ); + }else { + NPC_PetShop_selectWindow( meindex, talkerindex, 12, -1 ); + } + }else { + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + NPC_PetShop_selectWindow( meindex, talkerindex, 9, 0); + } + break; + case CHAR_WINDOWTYPE_WINDOWPETSHOP_GOLDOVER: + if( select == WINDOW_BUTTONTYPE_YES){ + NPC_PetShop_selectWindow( meindex, talkerindex, 4,-1 ); + }else{ + NPC_PetShop_selectWindow( meindex, talkerindex, 0,-1 ); + } + break; + case CHAR_WINDOWTYPE_WINDOWPETSHOP_DRAWSELECT: + if( select == WINDOW_BUTTONTYPE_PREV){ + NPC_PetShop_selectWindow( meindex, talkerindex, 9, -1); + }else if( select == WINDOW_BUTTONTYPE_NEXT) { + NPC_PetShop_selectWindow( meindex, talkerindex, 9, 1); + }else if( select != WINDOW_BUTTONTYPE_CANCEL) { + if( CHAR_getCharPetElement( talkerindex) != -1 ) { + NPC_PetShop_selectWindow( meindex, talkerindex, 10, datanum); + }else { + NPC_PetShop_selectWindow( meindex, talkerindex, 12, -1 ); + } + }else { + NPC_PetShop_selectWindow( meindex, talkerindex, 0,-1 ); + } + break; + +#ifdef _NPC_DEPOTPET + case CHAR_WINDOWTYPE_DEPOTPETSHOP_HANDLE: + if( !CHAR_CheckDepotPet( talkerindex) ) return ; + switch( datanum ) { + case 1://放入 + if( CHAR_findEmptyDepotPet( talkerindex) == -1 ){ + CHAR_talkToCli( talkerindex, -1, "宠物仓库已满!", CHAR_COLORYELLOW); + return; + } + //NPC_DepotPet_Pet_printWindow( meindex, talkerindex); + NPC_PetShop_selectWindow( meindex, talkerindex, 13, -1 ); + break; + case 2://取出 + if( CHAR_getCharPetElement( talkerindex) < 0 ) { + CHAR_talkToCli( talkerindex, -1, "身上宠物栏位已满!", CHAR_COLORYELLOW); + return; + } + NPC_PetShop_selectWindow( meindex, talkerindex, 14, 0); + break; + case 0: + NPC_PetShop_selectWindow( meindex, talkerindex, 0, -1); + break; + } + break; + + case CHAR_WINDOWTYPE_DEPOTPETSHOP_ADD: + if(select==WINDOW_BUTTONTYPE_CANCEL){ + NPC_PetShop_selectWindow( meindex, talkerindex, 0,-1 ); + }else{ + NPC_PetShop_selectWindow( meindex, talkerindex, 15, datanum ); + } + break; + + case CHAR_WINDOWTYPE_DEPOTPETSHOP_GET: + if( select == WINDOW_BUTTONTYPE_PREV){ + NPC_PetShop_selectWindow( meindex, talkerindex, 14, -1); + }else if( select == WINDOW_BUTTONTYPE_NEXT) { + NPC_PetShop_selectWindow( meindex, talkerindex, 14, 1); + }else if( select != WINDOW_BUTTONTYPE_CANCEL) { + if( CHAR_getCharPetElement( talkerindex) != -1 ) { + NPC_PetShop_selectWindow( meindex, talkerindex, 16, datanum); + }else { + NPC_PetShop_selectWindow( meindex, talkerindex, 12, -1 ); + } + }else { + NPC_PetShop_selectWindow( meindex, talkerindex, 0,-1 ); + } + + break; + case CHAR_WINDOWTYPE_DEPOTPETSHOP_ASKADD: // 确认存入仓库 + if(select==WINDOW_BUTTONTYPE_YES){ + NPC_PetShop_selectWindow( meindex, talkerindex, 17,-1 ); + }else { + NPC_PetShop_selectWindow( meindex, talkerindex,13,-1); + } + break; + + case CHAR_WINDOWTYPE_DEPOTPETSHOP_ASKGET: // 确认取出仓库 + if( select == WINDOW_BUTTONTYPE_YES){ + if( CHAR_getCharPetElement( talkerindex) != -1 ) { + NPC_PetShop_selectWindow( meindex, talkerindex, 18,-1 ); + }else { + NPC_PetShop_selectWindow( meindex, talkerindex, 12, -1 ); + } + }else { + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + NPC_PetShop_selectWindow( meindex, talkerindex, 14, 0); + } + break; +#endif + + case CHAR_WINDOWTYPE_WINDOWPETSHOP_END: + if( select == WINDOW_BUTTONTYPE_OK){ + NPC_PetShop_selectWindow( meindex, talkerindex, 0,-1 ); + } + break; + + // CoolFish: Add 2001/7/4 + default: + break; + + } +} + +void NPC_PetDate(int meindex,int talker,int select,char *token) +{ + + int petindex; + int cost; + char *petname; + char buf[1024]; + + /*--伐□弁及赓渝祭--*/ + CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANT,select); + + petindex = CHAR_getCharPet( talker, select-1); + + + if( !CHAR_CHECKINDEX(petindex) ) return; + + NPC_MaxGoldOver( meindex, talker, NPC_PETSHOP_MSG_REALY, buf); + + cost=NPC_GetCost(meindex,talker,petindex); + + petname = CHAR_getUseName( petindex); + + sprintf(token,"\n是[%s]没错吧?""%s" + "\n\n 买卖价格 %d STONE\n" + ,petname,buf,cost); + +} + +void NPC_PetDate2(int meindex,int talker,int select,char *token) +{ + + int petindex; + char *petname; + CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANT,select); + + petindex = CHAR_getCharPet( talker, select-1); + if( !CHAR_CHECKINDEX(petindex) ) return; + petname = CHAR_getUseName( petindex); + sprintf(token,"\n寄放[%s]" + "\n\n 寄放价格 %d stone\n" + ,petname, NPC_GETPOOLCOST( talker) + ); +} + +void NPC_PetDate3(int meindex,int talker,int select,char *token) +{ + int poolindex; + int petindex; + char *petname; + poolindex = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANT) * 5 + select - 1; + CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANT,poolindex ); + petindex = CHAR_getCharPoolPet( talker, poolindex); + if( !CHAR_CHECKINDEX(petindex) ) return; + petname = CHAR_getUseName( petindex); + sprintf(token,"\n领回[%s]", petname); +} + +int NPC_GetCost(int meindex,int talker,int petindex) +{ + int cost; + int levelcost; + int level; + int getlevel; + int graNo; + int rare; + int charm=50; + int petai; + int i=1; + double rate=1.0; + int intrate; + char buf[1024]; + char buff2[128]; + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr"); + return FALSE; + } + + + getlevel=CHAR_getInt(petindex,CHAR_PETGETLV); + level=CHAR_getInt(petindex,CHAR_LV); + graNo=CHAR_getInt(petindex,CHAR_BASEBASEIMAGENUMBER); + rare=CHAR_getInt(petindex,CHAR_RARE); + + if(getlevel==0) getlevel=1 ; + + /*--袄蟾毛菲户月--*/ + levelcost=(level*level)*10; + getlevel=(getlevel*getlevel)*10; +// Syu ADD 修改卖转生宠金钱会变负的bug +#ifdef _PET_2TRANS + if( CHAR_getInt(petindex , CHAR_TRANSMIGRATION)>0) +#else + if( CHAR_getInt(petindex , CHAR_TRANSMIGRATION)==1) +#endif + getlevel=10; + + + if(rare==0){ rare=1; + }else if(rare==1){ rare=5; + }else if(rare==2){ rare=8;} + + cost = ((levelcost-getlevel)+(level*PETCOST))*rare; + intrate = CHAR_getWorkInt( meindex , CHAR_WORK_NOMALRATE); + rate=(double) intrate / 1000; + + + NPC_Util_GetStrFromStrWithDelim( npcarg, "special_pet", buf, sizeof( buf)); + + i=1; + /*--旦矢扑乓伙伊□玄匹煌遥今木月矢永玄毛喃曰请允 矢永玄及隙烂反 飓 寞)--*/ + while( getStringFromIndexWithDelim(buf,",",i,buff2,sizeof(buff2)) !=FALSE ) + { + if(strstr( buff2, "-")==NULL){ + if(graNo == atoi(buff2)){ + intrate=CHAR_getWorkInt( meindex , CHAR_WORK_SPECIALRATE); + rate=(double) intrate / 1000; + break; + } + }else{ + /*--失奶 丞互 15-25 及溥匹嗉濠日木化中月桦宁--*/ + int start; + int end; + int tmp; + int graflg=0; + char token2[128]; + + /*-"-"匹嗉濠日木凶铵户及醒袄午 及醒袄毛潸 --*/ + getStringFromIndexWithDelim( buff2, "-", 1, token2, sizeof(token2)); + start = atoi( token2); + getStringFromIndexWithDelim( buff2, "-", 2 ,token2, sizeof(token2)); + end = atoi( token2); + + /*-- 寞互菅卞卅匀化中凶日} 木赘尹月**/ + if(start > end){ + tmp=start; + start=end; + end=tmp; + } + + end++; + /*--"-"匹嗉濠日木凶坌及失奶 丞树 毛 月--*/ + if(start <= graNo && graNo < end){ + intrate=CHAR_getWorkInt( meindex , CHAR_WORK_SPECIALRATE); + rate=(double) intrate / 1000; + graflg=1; + break; + } + + if(graflg ==1) break; + } + i++; + } + + /*--矢永玄及镝擦蘸毛 ---*/ + petai=CHAR_getWorkInt(petindex,CHAR_WORKFIXAI); + + /*-- 毛必永玄--*/ + charm = CHAR_getWorkInt(talker,CHAR_WORKFIXCHARM); + + /*-- ≈镝擦蘸 / ㄡ */ + charm = charm + petai; + + if(charm < 20){ + charm = 20; + } + + charm = charm / 2; + + cost = (int)cost*rate; + + rate=(double)charm/100; + + /*-- 镝擦喘仃--*/ + cost = cost * rate; + + /*--云嗯毛筏盛--*/ + CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC,cost); + + return cost; +} + + +#if 1 + +void NPC_PetDel(int meindex, int talker,int select,char* token) +{ + int petindex; + int petsel; + char szPet[128]; + int cost; + int defpet; + int fd = getfdFromCharaIndex( talker ); + + NPC_MaxGoldOver( meindex, talker, NPC_PETSHOP_MSG_THANKS, token); + petsel=(CHAR_getWorkInt(talker,CHAR_WORKSHOPRELEVANT)-1); + petindex = CHAR_getCharPet( talker, petsel); + + if( !CHAR_CHECKINDEX(petindex) ) return; + + // CoolFish: Family 2001/6/14 + if (CHAR_getInt(petindex, CHAR_PETFAMILY) == 1){ +/* char buf[1024]; + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString("\n\n很抱歉~守护兽无法贩卖喔!\n请自己好好照顾!", buf, sizeof(buf))); +*/ + sprintf(token,"\n\n很抱歉~守护兽无法贩卖喔!\n请自己好好照顾!"); + return; + } + + // Robin 0725 + if (CHAR_getInt( talker, CHAR_RIDEPET ) == petsel ){ +/* char buf[1024]; + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString("\n\n骑乘中的宠物无法贩卖喔!", buf, sizeof(buf))); +*/ + sprintf(token,"\n\n骑乘中的宠物无法贩卖喔!"); + return; + } + + if( CHAR_getWorkInt( CONNECT_getCharaindex(fd), + CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) return ; + defpet=CHAR_getInt(talker,CHAR_DEFAULTPET); + if(defpet==petsel){ + CHAR_setInt(talker,CHAR_DEFAULTPET,-1); + lssproto_KS_send( fd, -1, TRUE); + } + CHAR_setCharPet( talker, petsel, -1); + LogPet( + CHAR_getChar( talker, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( talker, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "sell(卖宠)", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + CHAR_endCharOneArray( petindex ); + + snprintf( szPet, sizeof( szPet ), "K%d", petsel); + CHAR_sendStatusString( talker, szPet ); + cost=NPC_GetCost(meindex,talker,petindex); + CHAR_AddGold( talker, cost); + +} +#endif +void NPC_PetDel2( int meindex, int talker, int select, char *token) +{ + + int petindex; + int selectpet; + int emptyindex; + char szPet[128]; + int fd = getfdFromCharaIndex( talker ); + + if( fd == -1 ) { + fprint( "err\n"); + return; + } + // 矢永玄犯□正 凳[矢永玄 仃 木 + selectpet = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANT) -1; + petindex = CHAR_getCharPet( talker, selectpet); + if( !CHAR_CHECKINDEX( petindex) ) return; + + // Robin 0725 + if (CHAR_getInt( talker, CHAR_RIDEPET ) == selectpet ) + { +/* char buf[1024]; + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + -1, -1, + makeEscapeString("\n\n骑乘中的宠物无法寄放喔!", buf, sizeof(buf))); +*/ + sprintf(token,"\n\n骑乘中的宠物无法寄放喔!"); + return; + } + + // 坞五毛茧允[蟆卞茧仄化民尼永弁仄化中月及匹]仇仇匹坞中化中卅中及反云井仄中 + emptyindex = CHAR_getCharPoolPetElement( talker); + if( emptyindex == -1 ) { + fprint( "err\n"); + return; + } + // 爵 赏 迕矢永玄卅日]公木及瓒 毛壅允[ + if( CHAR_getInt( talker, CHAR_DEFAULTPET) == selectpet) { + CHAR_setInt( talker, CHAR_DEFAULTPET, -1); + lssproto_KS_send( fd, -1, TRUE); + } + // 仃 木 卞]矢永玄及奶件犯永弁旦毛戊疋□ + CHAR_setCharPoolPet( talker, emptyindex, petindex); + // 矢永玄 井日壅允 + CHAR_setCharPet( talker, selectpet, -1); + + // 丢永本□斥潸 + NPC_MaxGoldOver( meindex, talker, NPC_PETSHOP_MSG_POOLTHANKS, token); + // 云嗯蛹日允 + + CHAR_DelGold( talker, NPC_GETPOOLCOST( talker) ); + + // 云嗯犯□正霜月 + CHAR_send_P_StatusString(talker,CHAR_P_STRING_GOLD); + + snprintf( szPet, sizeof( szPet ), "K%d", selectpet); + // 蕙仄中矢永玄旦 □正旦霜曰勾仃月 + CHAR_sendStatusString( talker, szPet ); + // 矢永玄毛 仃凶夫弘 + LogPet( + CHAR_getChar( talker, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( talker, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "pool(寄放宠物店)", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + +} + +void NPC_PetDel3( int meindex, int talker, int select, char *token) +{ + + int petindex; + int selectpet; + int emptyindex; + char szPet[128]; + int workindex[CHAR_MAXPOOLPETHAVE]; + int i; + int cnt; + + selectpet = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANT) ; + petindex = CHAR_getCharPoolPet( talker, selectpet); + if( !CHAR_CHECKINDEX( petindex) ) return; + emptyindex = CHAR_getCharPetElement( talker); + if( emptyindex == -1 ) { + fprint( "err\n"); + return; + } + + // 如果是守护兽改为普通兽 + if( CHAR_getInt( petindex, CHAR_PETFAMILY) == 1 + && CHAR_getInt( talker, CHAR_FMLEADERFLAG) != 3 ) { + CHAR_setInt( petindex, CHAR_PETFAMILY, 0); + CHAR_talkToCli( talker, -1, "守护兽改为普通兽", CHAR_COLORYELLOW); + } + + CHAR_setCharPet( talker, emptyindex, petindex); + CHAR_setCharPoolPet( talker, selectpet, -1); + NPC_MaxGoldOver( meindex, talker, NPC_PETSHOP_MSG_POOLTHANKS, token); + snprintf( szPet, sizeof( szPet ), "K%d", emptyindex); + CHAR_sendStatusString( talker, szPet ); + snprintf( szPet, sizeof( szPet), "W%d",emptyindex); + CHAR_sendStatusString( talker, szPet ); + for( i = 0; i < CHAR_MAXPOOLPETHAVE; i ++ ) { + workindex[i] = -1; + } + cnt = 0; + for( i = 0; i < CHAR_MAXPOOLPETHAVE; i ++ ) { + int petindex = CHAR_getCharPoolPet( talker, i); + if( CHAR_CHECKINDEX( petindex) ) { + workindex[cnt++] = petindex; + } + } + for( i = 0; i < CHAR_MAXPOOLPETHAVE; i ++ ) { + CHAR_setCharPoolPet( talker, i, workindex[i]); + } + LogPet( + CHAR_getChar( talker, CHAR_NAME ), + CHAR_getChar( talker, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "draw(领取宠物店)", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14 + ); +#ifdef _PET_EVOLUTION + if( CHAR_getInt( petindex, CHAR_FUSIONBEIT) == 1 && + CHAR_getInt( petindex, CHAR_FUSIONRAISE) > 0 ){//检查是否为融合宠 + CHAR_setInt( petindex, CHAR_FUSIONTIMELIMIT, (int)time( NULL)); + } +#endif +} + +void NPC_getDrawPet( int meindex, int toindex, char *token, int *buttontype, int select) +{ + // ㄠ矢□斥丐凶曰及垫醒 + #define LINENUM 5 + char buf[1024]; + int i; + int startnum, endnum; + int petindex = -1; + // 蜇箕及矢□斥 + int page = CHAR_getWorkInt( toindex, CHAR_WORKSHOPRELEVANT); + int limit; + //andy_reEdit 2003/09/18 + limit = (CHAR_getInt(toindex,CHAR_TRANSMIGRATION)*2)+5; + + endnum = (page + select+1)*LINENUM ; + startnum = endnum - LINENUM; + *buttontype = WINDOW_BUTTONTYPE_CANCEL; + // 羹矢□斥譬帮[ + if( endnum >= limit ) { + endnum = limit; + if( page +select!= 0 ) *buttontype |= WINDOW_BUTTONTYPE_PREV; + } + else if( endnum <= LINENUM ) { + endnum = LINENUM; + *buttontype |= WINDOW_BUTTONTYPE_NEXT; + } + else { + *buttontype |= WINDOW_BUTTONTYPE_PREV | WINDOW_BUTTONTYPE_NEXT; + } + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, page +select); + + strcpy( token, "2\n亖亖亖 请选择宠物 亖亖亖\n\n"); + for( i = startnum; i < endnum; i ++ ) { + petindex = CHAR_getCharPoolPet( toindex, i); + if( CHAR_CHECKINDEX( petindex) ) { + snprintf( buf, sizeof( buf), "LV.%3d MaxHP %3d %s\n", + CHAR_getInt( petindex, CHAR_LV), + CHAR_getWorkInt( petindex, CHAR_WORKMAXHP), + CHAR_getUseName( petindex) + ); + } + else { + strcpy( buf, "\n"); + } + strcat( token, buf); + } + // 戚及域蜊毛譬屯化] 井匀凶日戚尺示正件毛潸月 + if( i != limit ) { + petindex = CHAR_getCharPoolPet( toindex, i); + if( !CHAR_CHECKINDEX( petindex)) { + *buttontype &= ~WINDOW_BUTTONTYPE_NEXT; + } + } +} + +/* + *云嗯互左□田□公及职中欠中欠 + */ +void NPC_MaxGoldOver(int meindex,int toindex,int select,char *token) +{ + + char buf[1024]; + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg)); + + if( select < 0 || select >= arraysizeof( shopmsg)) return; + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, shopmsg[select].option, buf, sizeof( buf)) + == NULL ) + { + strcpy( buf, shopmsg[select].defaultmsg); + } + + snprintf(token,sizeof(buf),"\n\n%s",buf); + +} + +#ifdef _NPC_DEPOTPET +void NPC_PoolPetShop_DepotPet_Menu( int meindex, int talkerindex) +{ + int fd; + + //print(" NPC_PoolPetShop_DepotPet_Menu "); + + fd = getfdFromCharaIndex( talkerindex); + if( fd != -1 ) { + char message[1024]; + char buf[2048]; + + strcpy( message, + "3\n\n" + " 使用宠物仓库\n\n" + " <存放宠物>\n" + " <取回宠物>\n" + ); + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_DEPOTPETSHOP_HANDLE, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( message, buf, sizeof(buf))); + } +} + +void NPC_DepotPet_List( int meindex, int toindex, char *token, int *buttontype, int select) +{ + // ㄠ矢□斥丐凶曰及垫醒 + #define LINENUM 5 + char buf[1024]; + int i; + int startnum, endnum; + int petindex = -1; + // 蜇箕及矢□斥 + int page = CHAR_getWorkInt( toindex, CHAR_WORKSHOPRELEVANT); + int limit; + + limit = CHAR_MAXDEPOTPETHAVE; + + endnum = (page + select+1)*LINENUM ; + startnum = endnum - LINENUM; + *buttontype = WINDOW_BUTTONTYPE_CANCEL; + // 羹矢□斥譬帮[ + if( endnum >= limit ) { + endnum = limit; + if( page +select!= 0 ) *buttontype |= WINDOW_BUTTONTYPE_PREV; + } + else if( endnum <= LINENUM ) { + endnum = LINENUM; + *buttontype |= WINDOW_BUTTONTYPE_NEXT; + } + else { + *buttontype |= WINDOW_BUTTONTYPE_PREV | WINDOW_BUTTONTYPE_NEXT; + } + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, page +select); + + strcpy( token, "2\n亖亖亖 请选择要从仓库取出的宠物 亖亖亖\n\n"); + for( i = startnum; i < endnum; i ++ ) { + petindex = CHAR_getDepotPetIndex( toindex, i); + if( CHAR_CHECKINDEX( petindex) ) { + snprintf( buf, sizeof( buf), "LV.%3d MaxHP %3d %s\n", + CHAR_getInt( petindex, CHAR_LV), + CHAR_getWorkInt( petindex, CHAR_WORKMAXHP), + CHAR_getUseName( petindex) + ); + } + else { + strcpy( buf, "\n"); + } + strcat( token, buf); + } + // 戚及域蜊毛譬屯化] 井匀凶日戚尺示正件毛潸月 + if( i != limit ) { + petindex = CHAR_getDepotPetIndex( toindex, i); + if( !CHAR_CHECKINDEX( petindex)) { + *buttontype &= ~WINDOW_BUTTONTYPE_NEXT; + } + } + //print("\n DepotPet_List:%s ", token); +} + + +void NPC_DepotPet_Add( int meindex, int talker, int select, char *token) +{ + + int petindex; + int selectpet; + int emptyindex; + char szPet[128]; + int fd = getfdFromCharaIndex( talker ); + + if( fd == -1 ) { + fprint( "err\n"); + return; + } + // 矢永玄犯□正 凳[矢永玄 仃 木 + selectpet = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANT) -1; + //print("\n selectpet:%d ", selectpet); + petindex = CHAR_getCharPet( talker, selectpet); + if( !CHAR_CHECKINDEX( petindex) ) return; + + // Robin 0725 + if (CHAR_getInt( talker, CHAR_RIDEPET ) == selectpet ) + { + sprintf(token,"\n\n骑乘中的宠物无法存入仓库喔!"); + return; + } + + if( CHAR_getInt( petindex, CHAR_PETFAMILY) == 1 ) + { + sprintf(token,"\n\n家族守护兽无法存入仓库喔!"); + return; + } + +#ifdef _CHECK_ENEMY_PET + { + int j; + for( j=0;j 0 ){//检查是否为融合宠 + CHAR_setInt( petindex, CHAR_FUSIONTIMELIMIT, (int)time( NULL)); + } +#endif +} + +void NPC_DepotPet_AskGet(int meindex,int talker,int select,char *token) +{ + int depotindex; + int petindex; + char *petname; + depotindex = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANT) * 5 + select - 1; + CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANT,depotindex ); + petindex = CHAR_getDepotPetIndex( talker, depotindex); + if( !CHAR_CHECKINDEX(petindex) ) return; + petname = CHAR_getUseName( petindex); + sprintf(token,"\n领回[%s]", petname); +} + +int NPC_DepotPet_CheckRepeat( int charaindex) +{ + int petindex1, petindex2; + int i, j, find, ret = FALSE; + int workindex[CHAR_MAXDEPOTPETHAVE], cnt =0; + + for( i =0; i <(CHAR_MAXDEPOTPETHAVE-1); i++) + { + petindex1 = CHAR_getDepotPetIndex( charaindex, i); + if( !CHAR_CHECKINDEX( petindex1)) continue; + find = 0; + for( j =(i+1); j 0) + { + CHAR_setDepotPetIndex( charaindex, i, -1); + NPC_DepotPet_CheckRepeat_del( charaindex, petindex1); + } + } + + for( i = 0; i < CHAR_MAXDEPOTPETHAVE; i ++ ) { + workindex[i] = -1; + } + for( i = 0; i < CHAR_MAXDEPOTPETHAVE; i ++ ) { + int pindex = CHAR_getDepotPetIndex( charaindex, i); + if( CHAR_CHECKINDEX( pindex) ) { + workindex[cnt++] = pindex; + } + } + for( i = 0; i < CHAR_MAXDEPOTPETHAVE; i ++ ) { + CHAR_setDepotPetIndex( charaindex, i, workindex[i]); + } + + return ret; +} + +int NPC_DepotPet_CheckRepeat_del( int charaindex, int petindex) +{ + int i; + + LogPet( + CHAR_getChar( charaindex, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( charaindex, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "del(清除仓库洗宠)", + CHAR_getInt( charaindex,CHAR_FLOOR), + CHAR_getInt( charaindex,CHAR_X ), + CHAR_getInt( charaindex,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + + CHAR_endCharOneArray( petindex ); + +} + +// 检查等级是否足够 +int NPC_DepotPet_CheckLevel(int meindex,int talker,int select,char *token) +{ + int petindex; + int selectpet; + + if( !CHAR_CheckDepotPet( talker) ) + return FALSE; + + selectpet = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANT) ; + petindex = CHAR_getDepotPetIndex( talker, selectpet); + if( !CHAR_CHECKINDEX(petindex) ) return FALSE; + + //print("\n trans:%d char_lv:%d pet_lv:%d ", + // CHAR_getInt( talker, CHAR_TRANSMIGRATION), + // CHAR_getInt( talker, CHAR_LV), + // CHAR_getInt( petindex, CHAR_LV) ); + + // 如果是守护兽改为普通兽 + if( CHAR_getInt( petindex, CHAR_PETFAMILY) == 1 + && CHAR_getInt( talker, CHAR_FMLEADERFLAG) != 3 ) { + CHAR_setInt( petindex, CHAR_PETFAMILY, 0); + } + + if( CHAR_getWorkInt( talker, CHAR_PickAllPet) == TRUE ) { // 装备驯兽戒指的话... + return TRUE; + } + + if( CHAR_getInt( talker, CHAR_TRANSMIGRATION) > 0 + || CHAR_getInt( talker, CHAR_LV)+5 >= CHAR_getInt( petindex, CHAR_LV) ) { + return TRUE; + } + + return FALSE; + +} + +#endif + diff --git a/gmsv/npc/npc_petskillshop.c b/gmsv/npc/npc_petskillshop.c new file mode 100644 index 0000000..8cd0401 --- /dev/null +++ b/gmsv/npc/npc_petskillshop.c @@ -0,0 +1,243 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "pet_skill.h" +#include "readmap.h" +#include "battle.h" + +enum { + CHAR_WORK_STONESELECT = CHAR_NPCWORKINT1, +}; + +static void NPC_PetSkillShop_selectWindow( int meindex, int toindex, int num,int select); +BOOL NPC_PetSkillMakeStr(int meindex,int toindex,int select); + +BOOL NPC_PetSkillShopInit( int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char msg[256]; + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPESTONESHOP ); + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("GetArgStrErr"); + return FALSE; + } + if( NPC_Util_GetStrFromStrWithDelim( argstr, "pet_skill", msg, sizeof( msg)) != NULL){ + char buf[256], filename[256]; + int k=1, skillID, skillarray; + while( getStringFromIndexWithDelim( msg, ",", k, buf, sizeof( buf) ) ){ + k++; + skillID=atoi(buf); + skillarray = PETSKILL_getPetskillArray( skillID); + if( PETSKILL_CHECKINDEX( skillarray) == FALSE ) continue; + if( PETSKILL_getInt( skillarray, PETSKILL_ILLEGAL) == 1){ + if( NPC_Util_CheckAssignArgFile( meindex, filename) != NULL ){ + print("PetSkillShop illegal skill:[%d-%s] ->file:%s", + skillID, + PETSKILL_getChar( skillarray, PETSKILL_NAME), + filename ); + } + } + } + }else{ + return FALSE; + } + + return TRUE; +} + +void NPC_PetSkillShopTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + if(NPC_Util_isFaceToFace(talkerindex,meindex,2 )==FALSE){ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) return; + } + NPC_PetSkillShop_selectWindow( meindex, talkerindex,0,-1); +} + +void NPC_PetSkillShopLooked( int meindex , int lookedindex) +{ + if( CHAR_getInt( lookedindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + if( NPC_Util_CharDistance( lookedindex, meindex ) > 2) return; +} + +static void NPC_PetSkillShop_selectWindow( int meindex, int toindex, int num,int select) +{ + switch(num){ + case 0: + NPC_PetSkillMakeStr(meindex,toindex,select); + break; + case 1: + break; + } +} + +void NPC_PetSkillShopWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + int skill; + int pet; + int slot; + int cost; + int skillID=0; + int petskillindex; + char buf[64]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char msg[512]; + int petindex; + char msgbuf[128]; + int fd = getfdFromCharaIndex( talkerindex ); + double rate= 1.0; + + if( NPC_Util_CharDistance( talkerindex, meindex ) > 2) { + return; + } + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("GetArgStrErr"); + return; + } + makeStringFromEscaped( data); + getStringFromIndexWithDelim(data,"|",1,buf,sizeof(buf)); + skill=atoi(buf); + getStringFromIndexWithDelim(data,"|",2,buf,sizeof(buf)); + pet=atoi(buf); + getStringFromIndexWithDelim(data,"|",3,buf,sizeof(buf)); + slot=atoi(buf); + getStringFromIndexWithDelim(data,"|",4,buf,sizeof(buf)); + cost=atoi(buf); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "pet_skill", + msg, sizeof( msg)) != NULL){ + getStringFromIndexWithDelim(msg,",",skill,buf,sizeof(buf)); + skillID=atoi(buf); + } + + slot--; + if( !CHAR_CHECKPETSKILLINDEX( slot)){ + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return ; + } + petindex = CHAR_getCharPet( talkerindex, pet-1); + if( !CHAR_CHECKINDEX(petindex) ){ + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return ; + } + if(skillID < 0) return ; + + if(petindex == -1){ + print("petskillshop.c:170 PetindexError"); + return; + } + + if( CHAR_getWorkInt( CONNECT_getCharaindex(fd), + CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) return ; + if( NPC_Util_GetStrFromStrWithDelim( argstr, "skill_rate", msg, sizeof( msg)) != NULL){ + rate = atof( msg); + } + + petskillindex = PETSKILL_getPetskillArray( skillID ); + if(petskillindex == -1){ + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return ; + } + + cost = PETSKILL_getInt( petskillindex, PETSKILL_COST ); + cost = cost * rate; + + if(CHAR_getInt(talkerindex,CHAR_GOLD) < cost){ + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return; + } + CHAR_setPetSkill( petindex, slot, skillID); + + CHAR_DelGold( talkerindex, cost ); + + snprintf( msgbuf, sizeof( msgbuf ), "W%d",pet-1); + CHAR_sendStatusString( talkerindex, msgbuf ); + CHAR_sendStatusString( talkerindex, "P"); + NPC_PetSkillShop_selectWindow( meindex, talkerindex,0,-1); +} + +BOOL NPC_PetSkillMakeStr(int meindex,int toindex,int select) +{ + + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char msg[256]; + double rate=1.0; + int i=0; + char token[NPC_UTIL_GETARGSTR_LINEMAX]; + int fd = getfdFromCharaIndex( toindex); + + if(select==0){ + sprintf(token,"0|0"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_PETSKILLSHOP, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWPETSKILLSHOP, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + } + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("GetArgStrErr"); + return FALSE; + } + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "main_msg", + msg, sizeof( msg)) == NULL){ + print("mainERR"); + return FALSE; + } + + sprintf(token,"1|%s|%s", + CHAR_getChar(meindex,CHAR_NAME),msg); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "skill_rate", msg, sizeof( msg)) != NULL){ + rate=atof(msg); + } + + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "pet_skill", + msg, sizeof( msg) ) != NULL){ + int skillarray; + int skillID; + int cost; + char token2[265]; + char buf[64]; + + i=1; + while( getStringFromIndexWithDelim(msg,",",i,buf,sizeof(buf)) !=FALSE ){ + i++; + skillID=atoi(buf); + skillarray = PETSKILL_getPetskillArray( skillID); + + if( PETSKILL_CHECKINDEX( skillarray) == FALSE ) + continue; + if( PETSKILL_getInt( skillarray, PETSKILL_ILLEGAL) == 1) continue; + cost = PETSKILL_getInt(skillarray,PETSKILL_COST); + cost = (int)cost*rate; + sprintf(token2,"|%s|%d|%s", + PETSKILL_getChar(skillarray, PETSKILL_NAME), + cost, + PETSKILL_getChar(skillarray, PETSKILL_COMMENT) + ); + strcat(token,token2); + } + } + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_PETSKILLSHOP, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWPETSKILLSHOP, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return TRUE; +} + diff --git a/gmsv/npc/npc_pkpetshop.c b/gmsv/npc/npc_pkpetshop.c new file mode 100644 index 0000000..3e22dab --- /dev/null +++ b/gmsv/npc/npc_pkpetshop.c @@ -0,0 +1,1533 @@ +//krynn 2001/12/6 +//PKPetShop + +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "pet_skill.h" +#include "readmap.h" +#include "log.h" +#include "enemy.h" +#include "npc_pkpetshop.h" +#include "battle.h" + +#ifdef _PKPETSHOP +#define MAXSHOPPET 33 + +static void NPC_PKPetShop_selectWindow( int meindex, int talker, int num,int select); +void NPC_PKPetShop_BuyMain(int meindex,int talker,int before ); +void NPC_PKPetShop_GetPetList(char *argstr,char * argtoken2); +BOOL NPC_PKPetShop_SetNewPet(int meindex,int talker,char *data); +BOOL NPC_PKPetShop_SellNewPet(int meindex,int talker,char *data); + +void NPC_PKPetShop_Menu(int meindex,int talker); +int NPC_PKPetShop_GetLimtPetList(int talker,char *argstr,char *token2,int sell); +void NPC_PKPetShop_SellMain(int meindex,int talker,int select); +int NPC_GetSellPetList(int itemindex,int flg,char *argstr,char *argtoken,int select,int sell); +BOOL NPC_AddPetBuy(int meindex, int talker,int petID,int kosuu,double rate); +void NPC_PetStrStr(int petID,double rate,char *name,char *token2, int index); +int NPC_SellPetstrsStr(int itemindex,int flg,double rate,char *argtoken,int select,int sell); +void NPC_LimitPetShop(int meindex,int talker,int select); +void NPC_PKPetShop_ExpressmanCheck(int meindex,int talker); + + +/*--伐□弁 烂聒--*/ +enum{ + NPC_PKPETSHOP_WORK_NO = CHAR_NPCWORKINT1, + NPC_PKPETSHOP_WORK_EV = CHAR_NPCWORKINT2, + NPC_PKPETSHOP_WORK_EXPRESS = CHAR_NPCWORKINT3, +}; + + +typedef struct { + char arg[32]; + int type; +}PKPETSHOP_NPC_Shop; + + +static PKPETSHOP_NPC_Shop TypeTable[] = { + { "FIST", 0 }, + { "AXE", 1 }, + { "CLUB", 2 }, + { "SPEAR", 3}, + { "BOW", 4}, + { "SHIELD", 5}, + { "HELM", 6 }, + { "ARMOUR", 7 }, + { "BRACELET", 8}, + { "ANCLET", 9 }, + { "NECKLACE", 10}, + { "RING", 11}, + { "BELT", 12}, + { "EARRING", 13}, + { "NOSERING", 14}, + { "AMULET", 15}, + { "OTHER", 16}, + { "BOOMERANG", 17}, + { "BOUNDTHROW", 18}, + { "BREAKTHROW", 19}, +#ifdef _ITEM_TYPETABLE + { "DISH", 20}, + { "METAL", 21}, + { "JEWEL", 22}, + { "WARES", 23}, + { "WBELT", 24}, + { "WSHIELD", 25}, + { "WSHOES", 26}, + { "WGLOVE", 27}, + { "ANGELTOKEN", 28}, + { "HEROTOKEN", 29}, +#endif + { "ACCESSORY", 30}, + { "OFFENCE", 40}, + { "DEFENCE", 50}, + +}; + + +/********************************* +* 初始 +*********************************/ +BOOL NPC_PKPetShopInit( int meindex ) +{ + + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + + /*--正奶皿涩烂--*/ + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEPKPetShop ); + + if( NPC_Util_GetArgStr(meindex, argstr, sizeof(argstr)) == NULL ) + { + print("NPC_PKPetShopInit_GetArgStrErr"); + return FALSE; + } + if(strstr(argstr,"LIMITSHOP") != NULL) + { /*- 中潸曰毁迕白仿弘--*/ + CHAR_setWorkInt( meindex, NPC_PKPETSHOP_WORK_NO, 1); + } + else + { + CHAR_setWorkInt( meindex, NPC_PKPETSHOP_WORK_NO, 0); + } + + if(strstr( argstr, "EVENT") != NULL) + { /*- 中潸曰毁迕白仿弘--*/ + CHAR_setWorkInt( meindex, NPC_PKPETSHOP_WORK_EV, 1); + } + else + { + CHAR_setWorkInt( meindex, NPC_PKPETSHOP_WORK_EV, 0); + } + + if(strstr( argstr, "EXPRESS") != NULL) + { /*-扪霜盒白仿弘--*/ + CHAR_setWorkInt( meindex, NPC_PKPETSHOP_WORK_EXPRESS, 1); + } + else + { + CHAR_setWorkInt( meindex, NPC_PKPETSHOP_WORK_EXPRESS, 0); + } + return TRUE; +} + + +/********************************* +* 仄井仃日木凶凛及质 +*********************************/ +void NPC_PKPetShopTalked( int meindex , int talker , char *szMes ,int color ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff[1024]; + char buf2[256]; + char token[1024]; + int i = 1; + BOOL sellonlyflg = FALSE; + char sellmsg[1024]; + + /* 皿伊奶乩□卞覆仄化分仃 杀允月 */ + if( CHAR_getInt( talker , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) + { + return; + } + + /*-- 及蟆卞中月井升丹井"--*/ + if(NPC_Util_isFaceToFace( meindex, talker, 2) == FALSE) + { /* ㄠ弘伉永玉动 及心 */ + if( NPC_Util_CharDistance( talker, meindex ) > 1) return; + } + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL) + { + print("NPC_PKPetShopInit_GetArgStrErr"); + return; + } + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "sellonly_msg", + token, sizeof( token)) + != NULL) + { + sellonlyflg = TRUE; + strcpysafe(sellmsg, sizeof( sellmsg), token); + } + + /*-- 涛 丹它奶件玉它卞中仃月井升丹井--*/ + if( NPC_Util_GetStrFromStrWithDelim( argstr, "buy_msg", + buff, sizeof( buff)) != NULL ) + { + while(getStringFromIndexWithDelim(buff,",",i,buf2,sizeof(buf2)) != FALSE) + { + i++; + if( strstr( szMes, buf2) != NULL) { + if( CHAR_getWorkInt( meindex, NPC_PKPETSHOP_WORK_EV) == 0) { + /*- 中潸曰毁 井升丹井及民尼永弁--*/ + if( CHAR_getWorkInt( meindex, NPC_PKPETSHOP_WORK_NO) == 1) { + if( sellonlyflg ) { + NPC_PKPetShop_selectWindow( meindex, talker, 3, -1); + return; + } + } + else{ + NPC_PKPetShop_selectWindow( meindex, talker, 1, -1); + return; + } + }else{ + if(CHAR_getWorkInt( meindex, NPC_PKPETSHOP_WORK_NO) == 1) { + if( sellonlyflg) { + NPC_PKPetShop_selectWindow( meindex, talker, 3, -1); + return; + } + }else{ + NPC_PKPetShop_selectWindow( meindex, talker, 1, -1); + return; + } + return; + } + } + } + } + i=1; + + /*-- 涛 月它奶件玉它卞中仃月井升丹井--*/ + if( NPC_Util_GetStrFromStrWithDelim( argstr, "sell_msg", + buff, sizeof( buff)) != NULL ) + { + while( getStringFromIndexWithDelim(buff,",", i,buf2,sizeof(buf2)) + != FALSE ) + { + i++; + if(strstr(szMes,buf2) != NULL) { + NPC_PKPetShop_selectWindow( meindex, talker, 2, -1); + return; + } + } + } + i = 1; + + + /*--公及职及甲件玄毛仁木月蜕邯匹 仄井仃月--*/ + if( NPC_Util_GetStrFromStrWithDelim( argstr, "other_msg", + buff, sizeof( buff)) != NULL ) + { + while(getStringFromIndexWithDelim( buff, ",", i, buf2, sizeof( buf2)) + !=FALSE) + { + i++; + if(strstr(szMes,buf2) != NULL) { + /*--甲件玄丢永本□斥--*/ + if(NPC_Util_GetStrFromStrWithDelim( argstr, "hint_msg", + token, sizeof( token)) != NULL) + { + CHAR_talkToCli( talker, meindex, token, CHAR_COLORWHITE); + return; + } + } + } + } + + /*- 中潸曰毁 井升丹井及民尼永弁--*/ + if(CHAR_getWorkInt( meindex, NPC_PKPETSHOP_WORK_NO) == 1) + { + if(CHAR_getWorkInt( meindex, NPC_PKPETSHOP_WORK_EV) == 1) + { + if( sellonlyflg) + { + CHAR_talkToCli( talker, meindex, sellmsg, CHAR_COLORWHITE); + return; + } + } + else + { /*-- 中潸曰毁 及丢永本□斥--*/ + if( sellonlyflg) + { + NPC_PKPetShop_selectWindow( meindex, talker, 3, -1); + return; + } + } + } + else + { + if(CHAR_getWorkInt( meindex, NPC_PKPETSHOP_WORK_EV) == 1) { + if( sellonlyflg) { + CHAR_talkToCli( talker, meindex, sellmsg, CHAR_COLORWHITE); + return; + } + }else{ + + if(CHAR_getWorkInt( meindex, NPC_PKPETSHOP_WORK_EXPRESS) == 1) { + NPC_PKPetShop_ExpressmanCheck( meindex, talker); + }else{ + /*--仇仇引匹 凶日隋骚它奶件玉它(丢瓦亘□) 憎--*/ + /*-- 中潸曰毁 匹卅仁化 骚及饕卅日丢瓦亘□ 憎--*/ + NPC_PKPetShop_selectWindow( meindex, talker, 0, -1); + } + } + } + +} + +static void NPC_PKPetShop_selectWindow( int meindex, int talker, int num,int select) +{ + + print("\n NPC_PKPetShop_selectWindow()"); + print("\n num = %d ", num); + switch( num) { + case 0: + /*--丢瓦亘□ --*/ + /*--由仿丢□正霜曰--*/ + CHAR_send_P_StatusString( talker, CHAR_P_STRING_GOLD); + + if(CHAR_getWorkInt( meindex, NPC_PKPETSHOP_WORK_EXPRESS) == 1 ) + { + if(CHAR_getWorkInt( meindex, NPC_PKPETSHOP_WORK_NO) ==0 ) + { + NPC_PKPetShop_ExpressmanCheck( meindex, talker); + } + } + else if(CHAR_getWorkInt( meindex, NPC_PKPETSHOP_WORK_NO) == 1) + { + } + else + { + NPC_PKPetShop_Menu( meindex, talker); + } + break; + + case 1: + /*-- 丹 --*/ + NPC_PKPetShop_BuyMain( meindex, talker, select); + break; + + case 2: + /*-- 月 --*/ + NPC_PKPetShop_SellMain( meindex, talker, select); + break; + + case 3: + /*-- 中潸曰毁 匹允方 --*/ + NPC_LimitPetShop( meindex, talker, select); + break; + + } +} + + + +/*----------------------------------------- + * 弁仿奶失件玄井日忒匀化五凶凛卞裟太请今木月[ + * +-------------------------------------------*/ +void NPC_PKPetShopWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + /*-- 及引歹曰卞中卅中午五反蔽 --*/ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 3) { + /*--由仿丢□正霜曰--*/ + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return; + } + + makeStringFromEscaped( data); + switch( seqno){ + + case CHAR_WINDOWTYPE_WINDOWITEMSHOP_STARTMSG: + /*--备丢瓦亘□卞 壬允--*/ + /*-- 丹--*/ + if(atoi( data) == 1 ) NPC_PKPetShop_selectWindow(meindex, talkerindex, 1, -1); + + /*-- 月--*/ + if(atoi( data) == 2) NPC_PKPetShop_selectWindow(meindex, talkerindex, 2, -1); + + /*--请月--*/ + if(atoi( data) == 3) return;/*--窒手仄卅中--*/ + + break; + + + case CHAR_WINDOWTYPE_WINDOWITEMSHOP_BUY_MSG: + /*--失奶 丞及馨笛--*/ + if(NPC_PKPetShop_SetNewPet(meindex , talkerindex, data) == TRUE) { + + NPC_PKPetShop_selectWindow( meindex, talkerindex, 1, 0); + + }else{ + NPC_PKPetShop_selectWindow( meindex, talkerindex ,0, -1); + } + + break; + + + case CHAR_WINDOWTYPE_WINDOWITEMSHOP_SELL_MSG: + /*--失奶 丞及绰轮--*/ + if(NPC_PKPetShop_SellNewPet(meindex , talkerindex, data) == TRUE) { + NPC_PKPetShop_selectWindow( meindex, talkerindex, 2, 0); + + }else{ + NPC_PKPetShop_selectWindow( meindex, talkerindex, 0, -1); + } + + break; + + case CHAR_WINDOWTYPE_WINDOWITEMSHOP_LIMIT: + if(select == WINDOW_BUTTONTYPE_YES) { + NPC_PKPetShop_selectWindow( meindex, talkerindex ,2, -1); + + }else if(select == WINDOW_BUTTONTYPE_NO) { + return; + }else if(select == WINDOW_BUTTONTYPE_OK) { + NPC_PKPetShop_selectWindow( meindex, talkerindex, 2, -1); + } + break; + + case CHAR_WINDOWTYPE_WINDOWITEMSHOP_EXPRESS: + if(atoi(data) == 2) { + NPC_PKPetShop_selectWindow( meindex, talkerindex, 1, -1); + }else if(atoi( data) == 4) { + NPC_PKPetShop_selectWindow( meindex, talkerindex, 2, -1); + } + } +} + + +/*----------------------------------------- + * + * 丹质 丢奶件(弁仿奶失件玄霜耨树 综岳 + * + *krynn 2001/12/9 加的注释 + *before == -1 + *before <> -1 + *krynn end + *-----------------------------------------*/ +void NPC_PKPetShop_BuyMain(int meindex,int talker,int before ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[NPC_UTIL_GETARGSTR_BUFSIZE]; + int fd = getfdFromCharaIndex( talker); + + /* + 曰 中白仿弘 蟆及犯□正银丹井白仿弘 饕及 蟆 丢永本□斥| 丹丢永本□斥 + 蜊醒蓟 丢永本□斥 伊矛伙箫曰卅中丢永本□斥 割 丢永本□斥 + 蟆 尹月 尹卅中白仿弘 失奶 丞伊矛伙 袄蟾 飓 寞 域垫奶件白巧 + 蟆 尹月 尹卅中白仿弘 失奶 丞伊矛伙 袄蟾 飓 寞 域垫奶件白巧 + */ + + /*--云饕及白央奶伙 中坭反白央奶伙互钒仃卅井匀凶午五反蔽 --*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("itemshop_GetArgStr_Err"); + return; + } + + /*--蟆荚及犯□正银丹井---*/ + if(before != -1) + { /*--蟆荚及犯□正互酸匀化中月及匹职及树 反霜日卅仁 --*/ + sprintf(token,"0|0"); + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_ITEMSHOPMAIN, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_BUY_MSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + }else{ + + char token2[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff2[256]; + char buff[256]; + + /*--备丢永本□斥毛潸 仄化弁仿奶失件玄卞霜月犯□正毛综月-*/ + /*--仇及支曰 反五凶卅中井手--*/ + NPC_Util_GetStrFromStrWithDelim( argstr, "main_msg", buff, sizeof( buff)); + NPC_Util_GetStrFromStrWithDelim( argstr, "buy_main", buff2, sizeof( buff2)); + sprintf(token,"0|1|%d|%s|%s|%s|", CHAR_WINDOWTYPE_WINDOWITEMSHOP_STARTMSG, + CHAR_getChar( meindex, CHAR_NAME), buff, buff2); + + NPC_Util_GetStrFromStrWithDelim( argstr, "what_msg", buff, sizeof( buff)); + NPC_Util_GetStrFromStrWithDelim( argstr, "level_msg", buff2, sizeof( buff)); + snprintf( token2, sizeof( token2), "%s|%s", buff, buff2); + + /*-- 侬 宁 --*/ + strncat( token, token2, sizeof( token)); + + NPC_Util_GetStrFromStrWithDelim( argstr, "realy_msg", buff, sizeof( buff)); + NPC_Util_GetStrFromStrWithDelim( argstr, "itemfull_msg", buff2, sizeof( buff2)); + sprintf( token2, "|%s|%s", buff, buff2); + + /*-- 侬 瑛--*/ + strncat(token , token2,sizeof(token)); + strcpy(token2, "|"); + + /*--失奶 丞树 及 --*/ + NPC_PKPetShop_GetPetList( argstr, token2 ); + // krynn 2001/12/12 bebug 用 + print("%s",token2); + // end krynn + + /*--丢永本□斥午失奶 丞树 及宁 --*/ + strncat( token, token2, sizeof( token)); + } + + /*-- 侬 毛巨旦弗□皿今六月--*/ +// makeEscapeString( token, escapedname, sizeof(escapedname)); + + /*--仇仇匹霜耨--*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_ITEMSHOPMAIN, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_BUY_MSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + +} + +/*------------------------------------------------------ + *失奶 丞楮溢及 侬 毛综月( 丹 + *------------------------------------------------------*/ +void NPC_PKPetShop_GetPetList(char *argstr,char *argtoken) +{ + + int i = 1; + int tmp; + int EnemyCnt; + char *name ; + char buff2[256]; + char buff[NPC_UTIL_GETARGSTR_LINEMAX]; + char token2[NPC_UTIL_GETARGSTR_BUFSIZE]; + double rate = 1.0; + int loopcnt = 0; + + /*-伊□玄毛 月[ 仃木壬ㄠ匹裔烂--*/ + if(NPC_Util_GetStrFromStrWithDelim( argstr, "buy_rate", buff2, sizeof( buff2)) + != NULL){ + rate = atof( buff2); + } + + /*- 健丹齿 毛潸 --*/ + if( NPC_Util_GetStrFromStrWithDelim( argstr, "PetList", buff, sizeof( buff)) + != NULL ) + { + while( getStringFromIndexWithDelim(buff,",",i,buff2,sizeof(buff2)) + !=FALSE ) + { + i++; + /*--涩烂白央奶伙及失奶 丞互 "-"匹嗉濠日木化中月井及民尼永弁--*/ + if(strstr( buff2, "-") == NULL) { + /*--引内 蟆 --*/ + // krynn 2001/12/10 + EnemyCnt = ENEMY_getEnemyNum(); + for( tmp=0 ; tmp < EnemyCnt ; tmp++ ) + { + if( ENEMY_getInt( tmp , ENEMY_ID ) == atoi( buff2 ) ) + { + print("\nNPC_PKPetShop_GetPetList: tmp = %d", tmp); + break; + } + } + if( tmp == EnemyCnt ) + { + return; + } + name = ENEMY_getChar( tmp , ENEMY_NAME ); + // krynn end + /*-- 蟆互 卅日}失奶 丞互绣箕仄卅中及匹公及 寞反 骰--*/ + if(name == NULL) continue; + + loopcnt++; + if(loopcnt == MAXSHOPPET) break; + + /*-- 端及皿夫玄戊伙勾仁曰--*/ + NPC_PetStrStr( atoi( buff2), rate, name, token2, tmp); + + /*--丢永本□斥 侬 午 瑛--*/ + strncat( argtoken, token2, sizeof(token2)); + } + else + { + return; + /*krynn 2001/12/13 这段应该用不到了,先 mark,改为直接 return + --失奶 丞互 15-25 及溥匹嗉濠日木化中月桦宁-- + int start; + int end; + + //-"-"匹嗉濠日木凶铵户及醒袄午 及醒袄毛潸 -- + getStringFromIndexWithDelim( buff2, "-", 1, token2, sizeof(token2)); + start = atoi( token2); + getStringFromIndexWithDelim( buff2, "-", 2 ,token2, sizeof(token2)); + end = atoi( token2); + + //-- 寞互菅卞卅匀化中凶日} 木赘尹月 + if(start > end) + { + tmp = start; + start = end; + end = tmp; + } + + end++; + + //--"-"匹嗉濠日木凶坌及失奶 丞树 毛 月-- + for(; start < end ; start++ ) + { + //--引内 蟆 -- + + name = ITEM_getNameFromNumber( start ); + //-- 蟆互 卅日}失奶 丞互绣箕仄卅中及匹公及 寞反 骰-- + if(name == NULL) continue; + + loopcnt++; + if(loopcnt == MAXSHOPPET) break; + + //-- 端及皿夫玄戊伙勾仁曰-- + NPC_PetStrStr( start, rate, name, token2, tmp); + + //--丢永本□斥 侬 午 瑛-- + strncat( argtoken, token2, sizeof(token2)); + }*/ + } + } + } +} + + +/*----------------------------------------------------------------- + 皿夫玄戊伙综岳 +-------------------------------------------------------------------*/ +void NPC_PetStrStr(int petID,double rate,char *name,char *token2,int index) +{ + int i; + int gold; + int level; + int graNo; + int TempNo; + int EnemyTempNum; + char info[1024]; + //char tryItem[256]; // krynn 2001/12/12 只是要看 getItemInfoFromNumber 读出来的字串长什麽样的 + char escape[256] = {"PK Server 宠"}; + + //krynn 2001/12/10 try + //gold = ITEM_getcostFromITEMtabl( itemID); + //level = ITEM_getlevelFromITEMtabl( itemID); + //graNo = ITEM_getgraNoFromITEMtabl( itemID); + TempNo = ENEMY_getInt( index , ENEMY_TEMPNO ); + EnemyTempNum = ENEMYTEMP_getEnemyNum(); + for( i=0 ; i < EnemyTempNum ; i++ ) + { + if( ENEMYTEMP_getInt( i , E_T_TEMPNO ) == TempNo ) + { + break; + } + } + if( i == EnemyTempNum ) + { + return; + } + gold = RAND(0,20); + level = 0; + graNo = ENEMYTEMP_getInt( i , E_T_IMGNUMBER ); + //print("\nPKPetShop::NPC_PetStrStr(): TempNo = %d ; graNo = %d",TempNo,graNo); + /*--伊□玄毛井仃月--*/ + gold=(int)(gold * rate); + + //strcpy( tryItem,ITEM_getItemInfoFromNumber( 10 ) ); + //print("PKPetShop::NPC_PetStrStr(): try = %s\n",tryItem); + //krynn end + + makeEscapeString( escape, info, sizeof( info)); + + makeEscapeString( name, escape, sizeof( escape)); + + sprintf( token2, "%s|0|%d|%d|%d|%s|", escape, level, gold, graNo, info); +} + + +/*------------------------------------------- + *( 丹) + *弁仿奶失件玄井日忒匀凶 凶瑛绊毛 掏今六月 + * + *------------------------------------------*/ +BOOL NPC_PKPetShop_SetNewPet(int meindex,int talker,char *data) +{ + + char buf[1024]; + char buff2[128]; + int i = 1, j = 1; + int select; + int kosuu = 0; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + double rate = 1.0; + int gold = 0; + int EmptyPetCnt=0; + + /*--忒匀化五凶犯□正毛本伊弁玄午蜊醒卞坌荸--*/ + print("\nNPC_PKPetShop_SetNewPet: data = %s",data); + getStringFromIndexWithDelim( data, "|", 1, buf, sizeof( buf)); + select=atoi(buf); // krynn 2001/12/10 select 是玩家传回要买的第几样 + print("\nNPC_PKPetShop_SetNewPet: select = %d",select); + if(select == 0) return FALSE; + getStringFromIndexWithDelim( data, "|", 2, buf, sizeof( buf)); + kosuu=atoi(buf); + print("\nNPC_PKPetShop_SetNewPet: kosuu(玩家要买的数量) = %d",kosuu); + + if( kosuu <= 0 ) return FALSE; + + /* 仍潜谛 及矢永玄及坞五毛茧允 */ + if( !CHAR_CHECKINDEX(talker) ) + { + return FALSE; + } + for( i=0 ; i < CHAR_MAXPETHAVE ; i++ ) + { + if( CHAR_getCharPet( talker,i) == -1 ) + { + EmptyPetCnt++; + } + } + // 有 EmptyPetCnt 个宠物空位 + /* 坞五互 中 */ + print("\nNPC_PKPetShop_SetNewPet:EmptyPetCnt(玩家有的空位) = %d",EmptyPetCnt); + if( EmptyPetCnt <= 0 ) return FALSE; + if( EmptyPetCnt > CHAR_MAXPETHAVE ) + { + EmptyPetCnt = CHAR_MAXPETHAVE; + } + if( kosuu > EmptyPetCnt ) + { + kosuu = EmptyPetCnt; + } + + // krynn 2001/12/10 + // 应该用不到,所以 mark 起来 + /*--蜊醒及民尼永弁 癫卞蝈 月井" + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE ; i++ ) { + itemindex = CHAR_getItemIndex( talker , i ); + + if( !ITEM_CHECKINDEX( itemindex) ) { + kosuucnt++; + } + } + + --忒匀化 凶蜊醒及 互 端及蜊醒 扔□田础 方曰聂中午云井仄中及匹 + --扔□田□础及 毛 木月 + if( kosuucnt < kosuu){ + kosuu = kosuucnt; + } + --未夫及桦宁反巨仿□ + if(kosuucnt == 0 ){ + return FALSE; + } + krynn end */ + + i = 1; + + /*--云饕及白央奶伙 中坭反白央奶伙互钒仃卅井匀凶午五反蔽 --*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("shop_GetArgStr_Err"); + return FALSE; + } + + /*---伊□玄毛潸 卅仃木壬1.0)-*/ + if(NPC_Util_GetStrFromStrWithDelim( argstr, "buy_rate", buf, sizeof( buf)) + != NULL) { + rate= atof( buf); + } + + /*--失奶 丞及馨笛毛垫丹午仇欠-*/ + if( NPC_Util_GetStrFromStrWithDelim( argstr, "PetList", + buf, sizeof( buf)) != NULL ) + { + while(getStringFromIndexWithDelim(buf , "," , j, buff2, sizeof(buff2)) + != FALSE ) + { + j++; + /*-- "-"互殖引木化中月井升丹井--*/ + if(strstr( buff2, "-") == NULL) + { // krynn 2001/12/10 try + //if( ITEM_getcostFromITEMtabl(atoi(buff2)) !=-1) { + // + if ( i == select) + { + /*---失奶 丞及综岳---*/ + /*--蜊醒坌综岳--*/ + if(NPC_AddPetBuy(meindex, talker,atoi(buff2),kosuu,rate) != TRUE) + { + return FALSE; + } + return TRUE; + } + i++; + // krynn end} + }else{ + /*--失奶 丞互 15-25 及溥匹霜日木凶桦宁--*/ + int start; + int end; + + /* "-"匹嗉濠日木凶铵户及醒袄午 及醒袄毛潸 --*/ + getStringFromIndexWithDelim( buff2, "-", 1, argstr, sizeof(argstr)); + start = atoi( argstr); + getStringFromIndexWithDelim( buff2, "-", 2 ,argstr, sizeof(argstr)); + end = atoi( argstr); + end++; + + /*-- 寞互菅卞卅匀化中凶日} 木赘尹月**/ + if(start > end){ + gold = start; + start = end; + end = gold; + } + + /*--"-"匹嗉濠日木凶坌及失奶 丞毛树 毛 月--*/ + for(; start < end ; start++ ) { + if( ITEM_getcostFromITEMtabl( start) != -1) { + if ( i == select) { + /*---失奶 丞及综岳---*/ + /*--蜊醒坌综岳--*/ + if(NPC_AddPetBuy(meindex, talker, start, kosuu, rate) != TRUE) + { + return FALSE; + } + return TRUE; + } + i++; + } + } + } + } + } + + return FALSE; + +} + + +/*--------------------------------------------- + *失奶 丞及馨笛毛垫丹 + *--------------------------------------------*/ +BOOL NPC_AddPetBuy(int meindex, int talker,int petID,int kosuu,double rate) +{ + int i,j,k,index,EnemyCnt,UpLevel; + int gold; + int ret; + int maxgold; + int Grade=0; + char buf[1024]; + char msgbuf[64]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + + // krynn 2001/12/15 get get's grade of this PKPetShop + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("shop_GetArgStr_Err"); + return FALSE; + } + if(NPC_Util_GetStrFromStrWithDelim( argstr, "Grade", buf, sizeof( buf)) + != NULL) + { + Grade = atoi( buf ); + } + // end krynn + + /*--伊□玄毛井仃月--*/ + // krynn 2001/12/11 mark and change + //gold = ITEM_getcostFromITEMtabl( itemID); + gold = 4; + // krynn end + gold = (int)(gold * rate); + maxgold = gold * kosuu; + + if(CHAR_getInt( talker, CHAR_GOLD) < maxgold ) return FALSE; + + /*--云嗯毛蛹日允--*/ + CHAR_setInt( talker, CHAR_GOLD,CHAR_getInt( talker, CHAR_GOLD) - maxgold); + + EnemyCnt = ENEMY_getEnemyNum(); + for( index=0 ; index < EnemyCnt ; index++ ) + { + if( ENEMY_getInt( index , ENEMY_ID ) == petID ) + { + print("\nNPC_AddPetBuy: index = %d", index); + break; + } + } + if( index == EnemyCnt ) + { + return FALSE; + } + + /*--蜊醒坌综岳--*/ + for(i = 0 ; i < kosuu ; i++) + { + if( (ret = ENEMY_createPetFromEnemyIndex( talker , index )) == -1 ) + { + return FALSE; + }; + /******************/ + /* 矢永玄树 霜月 */ + /******************/ + // 升仇卞反中匀凶井卅 + for( j = 0 ; j < CHAR_MAXPETHAVE ; j++ ) + { + if( CHAR_getCharPet( talker , j ) == ret ) + { + break; + } + } + if( j == CHAR_MAXPETHAVE ){ + return FALSE; + } + if( CHAR_CHECKINDEX( ret ) == TRUE ){ + CHAR_setMaxExpFromLevel( ret, Grade); + UpLevel = CHAR_LevelUpCheck( ret , talker); + for( k = 0; k < UpLevel; k ++ ){ + CHAR_PetLevelUp( ret ); + CHAR_PetAddVariableAi( ret, AI_FIX_PETLEVELUP ); + } + CHAR_complianceParameter( ret ); + CHAR_setInt( ret , CHAR_HP , CHAR_getWorkInt( ret , CHAR_WORKMAXHP ) ); + + snprintf( msgbuf, sizeof( msgbuf ), "K%d", j ); + CHAR_sendStatusString( talker, msgbuf ); + + snprintf( msgbuf, sizeof( msgbuf ), "W%d", j ); + CHAR_sendStatusString( talker, msgbuf ); + } + } + CHAR_send_P_StatusString( talker, CHAR_P_STRING_GOLD); + return TRUE; +} + + + +/*---------------------------------------- + *丢瓦亘□ + *----------------------------------------*/ +void NPC_PKPetShop_Menu(int meindex,int talker) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[NPC_UTIL_GETARGSTR_LINEMAX]; + char buff[256]; + int fd = getfdFromCharaIndex( talker); + + /* 饕及 蟆 丢永本□斥| */ + /*--云饕及白央奶伙 中坭反白央奶伙互钒仃卅井匀凶午五反蔽 --*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("shop_GetArgStr_Err"); + return; + } + + NPC_Util_GetStrFromStrWithDelim( argstr, "main_msg", buff, sizeof( buff)); + snprintf(token, sizeof(token),"%s|%s",CHAR_getChar( meindex, CHAR_NAME), buff); + + // print("%s",escapedname); + /*--仇仇匹霜耨--*/ + //krynn 2001/12/10 这里的参数似乎可以延用 ItemShop 的 code,先用用看 + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_ITEMSHOPMENU, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_STARTMSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + //krynn end +} + + +/*------------------------------------------- + * 月质 (皿夫玄戊伙毛综岳 + * + *-------------------------------------------*/ +void NPC_PKPetShop_SellMain(int meindex,int talker,int before) +{ + + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[NPC_UTIL_GETARGSTR_BUFSIZE]; + int fd = getfdFromCharaIndex( talker); + + + /* + 曰 中白仿弘 蟆及犯□正银丹井白仿弘 饕及 蟆 丢永本□斥| 月丢永本□斥 + 云嗯互中匀天中卞卅月方丢永本□斥 割 丢永本□斥 + 蟆 木月 木卅中白仿弘 袄蟾 飓 寞 域垫奶件白巧 失奶 丞 寞 ㄠ井日 + 蟆 木月 木卅中白仿弘 袄蟾 飓 寞 域垫奶件白巧 失奶 丞 寞 ㄠ井日 + */ + + /*--云饕及白央奶伙 中坭反白央奶伙互钒仃卅井匀凶午五反蔽 --*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("shop_GetArgStr_Err"); + return; + } + + /*--蟆荚及犯□正银丹井---*/ + if(before != -1) { + + /*--蟆荚及犯□正互酸匀化中月及匹职及树 反霜日卅仁 --*/ + sprintf(token,"1|0"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_ITEMSHOPMAIN + +CHAR_getWorkInt(meindex,NPC_PKPETSHOP_WORK_NO), + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_SELL_MSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + }else{ + + char token2[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff2[256]; + char buff[256]; + + /*--备丢永本□斥毛潸 仄化弁仿奶失件玄卞霜月犯□正毛综月-*/ + /*--仇及支曰 反五凶卅中井手--*/ + NPC_Util_GetStrFromStrWithDelim( argstr, "main_msg", buff, sizeof( buff)); + NPC_Util_GetStrFromStrWithDelim( argstr, "sell_main", buff2, sizeof( buff)); + sprintf( token, "1|1|%d|%s|%s|%s|", CHAR_WINDOWTYPE_WINDOWITEMSHOP_STARTMSG, + CHAR_getChar( meindex, CHAR_NAME), buff, buff2); + + NPC_Util_GetStrFromStrWithDelim( argstr, "stone_msg", buff, sizeof( buff)); + + if(CHAR_getWorkInt(meindex,NPC_PKPETSHOP_WORK_EXPRESS) == 1 ) { + NPC_Util_GetStrFromStrWithDelim( argstr, "exrealy_msg", buff2, sizeof(buff2)); + }else{ + NPC_Util_GetStrFromStrWithDelim( argstr, "realy_msg", buff2, sizeof( buff2)); + } + sprintf( token2,"%s|%s|", buff, buff2); + + /*--失奶 丞树 及 --*/ + NPC_PKPetShop_GetLimtPetList( talker,argstr, token2, -1); + + /*--丢永本□斥午失奶 丞树 及宁 --*/ + strncat( token, token2, sizeof( token)); + + /*--仇仇匹霜耨--*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_ITEMSHOPMAIN+ + CHAR_getWorkInt(meindex,NPC_PKPETSHOP_WORK_NO), + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_SELL_MSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + } +} + + + + + +/*-------------------------------- + +愤坌互云饕卞 月失奶 丞及 侬 毛及赏 + + *-------------------------------*/ +int NPC_PKPetShop_GetLimtPetList(int talker, char *argstr, char* token2,int sell) +{ + + char token[NPC_UTIL_GETARGSTR_LINEMAX]; + char buff[NPC_UTIL_GETARGSTR_LINEMAX]; + char token3[NPC_UTIL_GETARGSTR_LINEMAX]; + int k = 0 , i = 1 , j = 0; + int imax; + int itemtype = 0; + int itemindex; + int okflg = 0; + char buf[256]; + int flg=0; + int cost; + + + if(sell == -1 ){ + i = CHAR_STARTITEMARRAY; + imax = CHAR_MAXITEMHAVE; + flg = -1; + }else{ + i= sell; + imax= sell + 1; + flg = 1; + } + + /*--- 木月失奶 丞毛潸 允月[--*/ + /** 旦矢扑乓伙失奶 丞毛手匀化中凶日 伊□玄匹煌遥--*/ + /*-- 旦矢扑乓伙质 匹皿夫弘仿丞互 --*/ + + for( ; i < imax ; i++ ){ + okflg=0; + itemindex = CHAR_getItemIndex( talker , i ); + + if( ITEM_CHECKINDEX( itemindex) ){ + + /*--失奶 丞及正奶皿互域谯仄凶日} 木月--*/ + if( NPC_Util_GetStrFromStrWithDelim( argstr,"LimitItemType", + buff, sizeof( buff)) + != NULL ) + { + k = 1; + while(getStringFromIndexWithDelim(buff , "," , k, token, sizeof(token)) + != FALSE ) + { +#ifdef _ITEM_TYPETABLE + int cmpmaxitem = sizeof(TypeTable)/sizeof(TypeTable[0]); +#endif + k++; +#ifdef _ITEM_TYPETABLE + for(j = 0 ; j < cmpmaxitem ; j++){ +#else + for(j = 0 ; j < ITEM_CATEGORYNUM+3 ; j++){ +#endif + if(strcmp( TypeTable[ j].arg , token) == 0 ) { + itemtype = TypeTable[ j].type; + if(ITEM_getInt(itemindex,ITEM_TYPE) == itemtype) { + + /*-- 侬 综岳--*/ + cost = NPC_GetSellPetList(itemindex,0,argstr,token3,i,sell); + if(cost != -1) return cost; + strncat( token2, token3, sizeof( token3)); + okflg = 1; + }else if(itemtype == 30){ + if( 8 <= ITEM_getInt(itemindex,ITEM_TYPE) + && (ITEM_getInt(itemindex,ITEM_TYPE) <= 15) ){ + /*-- 侬 综岳--*/ + cost = NPC_GetSellPetList(itemindex,0,argstr,token3,i,sell); + if(cost != -1) return cost; + strncat(token2,token3,sizeof(token3)); + okflg = 1; + } + }else if(itemtype == 40){ + if(( 0 <= ITEM_getInt(itemindex,ITEM_TYPE) + && (ITEM_getInt(itemindex,ITEM_TYPE) <= 4)) + || (17 <= ITEM_getInt(itemindex,ITEM_TYPE) + && (ITEM_getInt(itemindex,ITEM_TYPE) <= 19)) + ) { + /*-- 侬 综岳--*/ + cost = NPC_GetSellPetList(itemindex,0,argstr,token3,i,sell); + if(cost != -1) return cost; + strncat(token2,token3,sizeof(token3)); + okflg = 1; + } + }else if(itemtype == 50){ + if( 5 <= ITEM_getInt(itemindex,ITEM_TYPE) + && (ITEM_getInt(itemindex,ITEM_TYPE) <= 7) ){ + /*-- 侬 综岳--*/ + cost = NPC_GetSellPetList(itemindex,0,argstr,token3,i,sell); + if(cost != -1) return cost; + strncat(token2,token3,sizeof(token3)); + okflg = 1; + } + } + break; + } + } + + if(okflg == 1) break; + } + } + /*--正奶皿卞卅仁化 涛 寞仄化 木月失奶 丞井民尼永弁--*/ + if( (NPC_Util_GetStrFromStrWithDelim( argstr, "LimitItemNo", + buff,sizeof( buff)) + != NULL) + && okflg == 0 ) + { + k = 1; + while(getStringFromIndexWithDelim(buff , "," , k, token, sizeof(token)) + != FALSE ) + { + k++; + /*--窒手涩烂今木化卅井匀凶日} 骰允月-*/ + if(strstr( token, "-")==NULL && strcmp(token,"") != 0) { + if(ITEM_getInt(itemindex,ITEM_ID) == atoi(token)) { + /*-- 侬 综岳--*/ + cost = NPC_GetSellPetList(itemindex,0,argstr,token3,i,sell); + if(cost != -1) return cost; + strncat(token2,token3,sizeof(token3)); + okflg=1; + } + }else if (strstr( token, "-") != NULL){ + int start; + int end; + int work; + + /*-- 侬 综岳--*/ + /* "-"匹嗉濠日木凶铵户及醒袄午 及醒袄毛潸 --*/ + getStringFromIndexWithDelim( token, "-", 1, buf, sizeof(buf)); + start = atoi( buf); + getStringFromIndexWithDelim( token, "-", 2 ,buf, sizeof(buf)); + end = atoi( buf); + + /*-- 寞互菅卞卅匀化中凶日} 木赘尹月**/ + if(start > end){ + work = start; + start = end; + end = work; + } + + end++; + /*--"-"匹嗉濠日木凶坌及失奶 丞毛树 毛 月--*/ + if( (start <= ITEM_getInt(itemindex,ITEM_ID)) + && (ITEM_getInt(itemindex,ITEM_ID) < end) ) + { + /*-- 侬 综岳--*/ + cost = NPC_GetSellPetList(itemindex,0,argstr,token3,i,sell); + if(cost != -1) return cost; + strncat(token2,token3,sizeof(token3)); + okflg = 1; + } + } + } + } + + /*-- 月仇午互匹五卅中--*/ + if(okflg == 0) { + cost = NPC_GetSellPetList(itemindex, 1, argstr, token3, i, sell); + if(sell != -1) return -1; + strncat( token2, token3, sizeof( token3)); + } + + } + } + return -1; +} + + + +/*---------------------------------------------------------- + + 弁仿奶失件玄卞霜耨允月皿夫玄戊伙及综岳 + + *----------------------------------------------------------*/ +int NPC_GetSellPetList(int itemindex,int flg, char *argstr,char *argtoken,int select,int sell) +{ + + char buff[256]; + double rate = 0.2; + char buff2[256]; + char buff3[64]; + int k = 1; + int cost = -1; + + /*--旦矢扑乓伙伊□玄--**/ + if(NPC_Util_GetStrFromStrWithDelim( argstr,"special_item",buff, sizeof( buff)) + != NULL) + { + if(NPC_Util_GetStrFromStrWithDelim( argstr,"special_rate",buff2, sizeof( buff2)) + != NULL ) + { + rate = atof(buff2); + }else{ + rate = 1.2; + } + + while(getStringFromIndexWithDelim(buff , "," , k, buff2, sizeof(buff2)) !=FALSE ) + { + k++; + + if(strstr( buff2, "-") == NULL && strcmp(buff2,"") != 0) { + if(ITEM_getInt(itemindex,ITEM_ID) == atoi(buff2)){ + cost = NPC_SellPetstrsStr( itemindex,0, rate, argtoken,select,sell); + return cost; + } + }else if (strstr( buff2, "-") != NULL){ + int start; + int end; + int work; + + /*-- 侬 综岳--*/ + /* "-"匹嗉濠日木凶铵户及醒袄午 及醒袄毛潸 --*/ + getStringFromIndexWithDelim( buff2, "-", 1, buff3, sizeof(buff3)); + start = atoi( buff3); + getStringFromIndexWithDelim( buff2, "-", 2 ,buff3, sizeof(buff3)); + end = atoi( buff3); + + /*-- 寞互菅卞卅匀化中凶日} 木赘尹月**/ + if(start > end){ + work = start; + start = end; + end = work; + } + end++; + + /*--"-"匹嗉濠日木凶坌及失奶 丞毛树 毛 月--*/ + if( (start <= ITEM_getInt(itemindex,ITEM_ID)) + && (ITEM_getInt(itemindex,ITEM_ID) < end) + ){ + + cost = NPC_SellPetstrsStr( itemindex,0, rate, argtoken,select,sell); + return cost; + } + } + } + } + + /*--用□穴伙伊□玄--*/ + if( NPC_Util_GetStrFromStrWithDelim( argstr,"sell_rate",buff, sizeof( buff)) + != NULL ) + { + rate = atof(buff); + cost = NPC_SellPetstrsStr( itemindex, flg ,rate, argtoken,select,sell); + return cost; + } + + return cost; +} + + +/*------------------------------------------ + + 侬 毛综月(丹曰迕) + +*------------------------------------------*/ +int NPC_SellPetstrsStr(int itemindex,int flg,double rate,char *argtoken,int select,int sell) +{ + int cost; + char escapedname[256]; + char name[256]; + char *eff; + + + cost = ITEM_getInt( itemindex, ITEM_COST); + cost = (int)(cost * rate); + + if(sell != -1) return cost; + + + //strcpy( escapedname, ITEM_getChar( itemindex, ITEM_NAME)); + strcpy( escapedname, ITEM_getChar( itemindex, ITEM_SECRETNAME)); + makeEscapeString( escapedname, name, sizeof( name)); + eff=ITEM_getChar(itemindex, ITEM_EFFECTSTRING); + makeEscapeString( eff, escapedname, sizeof(escapedname)); + + + + sprintf(argtoken,"%s|%d|%d|%d|%s|%d|", + name, + flg, + cost, + ITEM_getInt( itemindex, ITEM_BASEIMAGENUMBER), + escapedname, + select + ); + + return -1; + +} + +/*-------------------------------------------- + * + *弁仿奶失件玄井日瑛绊互忒匀化五凶午五 月 + * + *-------------------------------------------*/ +BOOL NPC_PKPetShop_SellNewPet(int meindex,int talker,char *data) +{ + int select; + int cost; + int oldcost; + char token[32]; + int k; + int itemindex; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token2[256]; + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("GetArgStrErr"); + return FALSE; + } + + + /*--忒匀化 凶犯□正及坌荸--*/ + getStringFromIndexWithDelim(data , "|" ,1, token, sizeof( token)); + select = atoi(token); + getStringFromIndexWithDelim(data , "|" ,2, token, sizeof( token)); + oldcost = atoi(token); + + if(select == 0) return FALSE; + + cost = NPC_PKPetShop_GetLimtPetList( talker,argstr, token2,select); + + + /*--啜丹手及毛丹欠丹午仄凶午五及巨仿□--*/ + if(oldcost != cost || cost == -1) + { + int fd = getfdFromCharaIndex( talker); + char token[256]; + + sprintf(token,"\n\n哎呀!对不起" + "\n\n对不起啊 ! 可不可以再选一次呢?" + ); + + k = select; + itemindex = CHAR_getItemIndex( talker ,k); + + + /*--夫弘及请 --*/ + if(itemindex != -1) { + print("\n%s(%d,%d,%d):和选择的东西不同error([%s(%d)]要消失了)", + CHAR_getChar(talker, CHAR_NAME), + CHAR_getInt( talker, CHAR_FLOOR), + CHAR_getInt( talker, CHAR_X ), + CHAR_getInt( talker, CHAR_Y ), + ITEM_getChar(itemindex, CHAR_NAME), + ITEM_getInt( itemindex, ITEM_ID ) + ); + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), /* 失奶 丞 寞 */ +#endif + "SellErr", + CHAR_getInt( talker, CHAR_FLOOR), + CHAR_getInt( talker, CHAR_X ), + CHAR_getInt( talker, CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + }else{ + print("\n%s(%d,%d,%d):和选择的东西不同error(没有任何item存在)", + CHAR_getChar(talker, CHAR_NAME), + CHAR_getInt( talker, CHAR_FLOOR), + CHAR_getInt( talker, CHAR_X ), + CHAR_getInt( talker, CHAR_Y ) + ); + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( talker, CHAR_CDKEY ), + -1, /* 失奶 丞 寞 */ + "SellErr", + CHAR_getInt( talker, CHAR_FLOOR), + CHAR_getInt( talker, CHAR_X ), + CHAR_getInt( talker, CHAR_Y ), + "-1", "NULL", -1 ); + } + /*--仇仇匹霜耨--*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_LIMIT, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + + return FALSE; + } + + k = select; + itemindex=CHAR_getItemIndex( talker ,k); + + if(itemindex != -1) { + { + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), /* 失奶 丞 寞 */ +#endif + "Sell", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + + ); + } + + } + + CHAR_DelItem( talker, k); + CHAR_AddGold( talker, cost); + CHAR_send_P_StatusString( talker, CHAR_P_STRING_GOLD); + + return TRUE; +} + + + +void NPC_LimitPetShop(int meindex,int talker,int select) +{ + + int fd = getfdFromCharaIndex( talker); + char token[NPC_UTIL_GETARGSTR_LINEMAX]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024]; + + /*--云饕及白央奶伙 中坭反白央奶伙互钒仃卅井匀凶午五反蔽 --*/ + if( NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("shop_GetArgStr_Err"); + return; + } + + /*-- 中潸曰毁 饕匹允丢永本□斥-*/ + if(NPC_Util_GetStrFromStrWithDelim( argstr, "sellonly_msg", buf, sizeof( buf)) + !=NULL) + { + sprintf(token,"\n\n%s", buf); + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_YESNO, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_LIMIT, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + }else{ + CHAR_talkToCli( talker, meindex, "这是买卖专门店。",CHAR_COLORWHITE); + } + return; +} + + +/*--扪霜盒今氏--*/ +void NPC_PKPetShop_ExpressmanCheck(int meindex,int talker) +{ + int fd = getfdFromCharaIndex( talker); + char token[1024]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024]; + + /*--云饕及白央奶伙 中坭反白央奶伙互钒仃卅井匀凶午五反蔽 --*/ + if( NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("shop_GetArgStr_Err"); + return; + } + + + /*-- 中潸曰毁 饕匹允丢永本□斥-*/ + NPC_Util_GetStrFromStrWithDelim( argstr, "main_msg", buf, sizeof( buf)); + sprintf(token,"4\n       %s\n\n%s" + "\n\n     < 打工 >   " + "\n\n     <交付行李>" + ,CHAR_getChar(meindex,CHAR_NAME),buf); + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_EXPRESS, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + return; + + +} + + +#endif + // _PKPETSHOP + + + + diff --git a/gmsv/npc/npc_pkpetshop.c.bak b/gmsv/npc/npc_pkpetshop.c.bak new file mode 100644 index 0000000..85eb862 --- /dev/null +++ b/gmsv/npc/npc_pkpetshop.c.bak @@ -0,0 +1,1539 @@ +//krynn 2001/12/6 +//PKPetShop + +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "pet_skill.h" +#include "readmap.h" +#include "log.h" +#include "enemy.h" +#include "npc_pkpetshop.h" +#include "battle.h" + +#ifdef _PKPETSHOP +#define MAXSHOPPET 33 + +static void NPC_PKPetShop_selectWindow( int meindex, int talker, int num,int select); +void NPC_PKPetShop_BuyMain(int meindex,int talker,int before ); +void NPC_PKPetShop_GetPetList(char *argstr,char * argtoken2); +BOOL NPC_PKPetShop_SetNewPet(int meindex,int talker,char *data); +BOOL NPC_PKPetShop_SellNewPet(int meindex,int talker,char *data); + +void NPC_PKPetShop_Menu(int meindex,int talker); +int NPC_PKPetShop_GetLimtPetList(int talker,char *argstr,char *token2,int sell); +void NPC_PKPetShop_SellMain(int meindex,int talker,int select); +int NPC_GetSellPetList(int itemindex,int flg,char *argstr,char *argtoken,int select,int sell); +BOOL NPC_AddPetBuy(int meindex, int talker,int petID,int kosuu,double rate); +void NPC_PetStrStr(int petID,double rate,char *name,char *token2, int index); +int NPC_SellPetstrsStr(int itemindex,int flg,double rate,char *argtoken,int select,int sell); +void NPC_LimitPetShop(int meindex,int talker,int select); +void NPC_PKPetShop_ExpressmanCheck(int meindex,int talker); + + +/*--伐□弁 烂聒--*/ +enum{ + NPC_PKPETSHOP_WORK_NO = CHAR_NPCWORKINT1, + NPC_PKPETSHOP_WORK_EV = CHAR_NPCWORKINT2, + NPC_PKPETSHOP_WORK_EXPRESS = CHAR_NPCWORKINT3, +}; + + +typedef struct { + char arg[32]; + int type; +}PKPETSHOP_NPC_Shop; + + +static PKPETSHOP_NPC_Shop TypeTable[] = { + { "FIST", 0 }, + { "AXE", 1 }, + { "CLUB", 2 }, + { "SPEAR", 3}, + { "BOW", 4}, + { "SHIELD", 5}, + { "HELM", 6 }, + { "ARMOUR", 7 }, + { "BRACELET", 8}, + { "ANCLET", 9 }, + { "NECKLACE", 10}, + { "RING", 11}, + { "BELT", 12}, + { "EARRING", 13}, + { "NOSERING", 14}, + { "AMULET", 15}, + { "OTHER", 16}, + { "BOOMERANG", 17}, + { "BOUNDTHROW", 18}, + { "BREAKTHROW", 19}, +#ifdef _ITEM_TYPETABLE + { "DISH", 20}, + { "METAL", 21}, + { "JEWEL", 22}, + { "WARES", 23}, + { "WBELT", 24}, + { "WSHIELD", 25}, + { "WSHOES", 26}, + { "WGLOVE", 27}, + { "ANGELTOKEN", 28}, + { "HEROTOKEN", 29}, +#endif + { "ACCESSORY", 30}, + { "OFFENCE", 40}, + { "DEFENCE", 50}, + +}; + + +/********************************* +* 初始 +*********************************/ +BOOL NPC_PKPetShopInit( int meindex ) +{ + + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + + /*--正奶皿涩烂--*/ + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEPKPetShop ); + + if( NPC_Util_GetArgStr(meindex, argstr, sizeof(argstr)) == NULL ) + { + print("NPC_PKPetShopInit_GetArgStrErr"); + return FALSE; + } + if(strstr(argstr,"LIMITSHOP") != NULL) + { /*- 中潸曰毁迕白仿弘--*/ + CHAR_setWorkInt( meindex, NPC_PKPETSHOP_WORK_NO, 1); + } + else + { + CHAR_setWorkInt( meindex, NPC_PKPETSHOP_WORK_NO, 0); + } + + if(strstr( argstr, "EVENT") != NULL) + { /*- 中潸曰毁迕白仿弘--*/ + CHAR_setWorkInt( meindex, NPC_PKPETSHOP_WORK_EV, 1); + } + else + { + CHAR_setWorkInt( meindex, NPC_PKPETSHOP_WORK_EV, 0); + } + + if(strstr( argstr, "EXPRESS") != NULL) + { /*-扪霜盒白仿弘--*/ + CHAR_setWorkInt( meindex, NPC_PKPETSHOP_WORK_EXPRESS, 1); + } + else + { + CHAR_setWorkInt( meindex, NPC_PKPETSHOP_WORK_EXPRESS, 0); + } + return TRUE; +} + + +/********************************* +* 仄井仃日木凶凛及质 +*********************************/ +void NPC_PKPetShopTalked( int meindex , int talker , char *szMes ,int color ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff[1024]; + char buf2[256]; + char token[1024]; + int i = 1; + BOOL sellonlyflg = FALSE; + char sellmsg[1024]; + + /* 皿伊奶乩□卞覆仄化分仃 杀允月 */ + if( CHAR_getInt( talker , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) + { + return; + } + + /*-- 及蟆卞中月井升丹井"--*/ + if(NPC_Util_isFaceToFace( meindex, talker, 2) == FALSE) + { /* ㄠ弘伉永玉动 及心 */ + if( NPC_Util_CharDistance( talker, meindex ) > 1) return; + } + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL) + { + print("NPC_PKPetShopInit_GetArgStrErr"); + return; + } + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "sellonly_msg", + token, sizeof( token)) + != NULL) + { + sellonlyflg = TRUE; + strcpysafe(sellmsg, sizeof( sellmsg), token); + } + + /*-- 涛 丹它奶件玉它卞中仃月井升丹井--*/ + if( NPC_Util_GetStrFromStrWithDelim( argstr, "buy_msg", + buff, sizeof( buff)) != NULL ) + { + while(getStringFromIndexWithDelim(buff,",",i,buf2,sizeof(buf2)) != FALSE) + { + i++; + if( strstr( szMes, buf2) != NULL) { + if( CHAR_getWorkInt( meindex, NPC_PKPETSHOP_WORK_EV) == 0) { + /*- 中潸曰毁 井升丹井及民尼永弁--*/ + if( CHAR_getWorkInt( meindex, NPC_PKPETSHOP_WORK_NO) == 1) { + if( sellonlyflg ) { + NPC_PKPetShop_selectWindow( meindex, talker, 3, -1); + return; + } + } + else{ + NPC_PKPetShop_selectWindow( meindex, talker, 1, -1); + return; + } + }else{ + if(CHAR_getWorkInt( meindex, NPC_PKPETSHOP_WORK_NO) == 1) { + if( sellonlyflg) { + NPC_PKPetShop_selectWindow( meindex, talker, 3, -1); + return; + } + }else{ + NPC_PKPetShop_selectWindow( meindex, talker, 1, -1); + return; + } + return; + } + } + } + } + i=1; + + /*-- 涛 月它奶件玉它卞中仃月井升丹井--*/ + if( NPC_Util_GetStrFromStrWithDelim( argstr, "sell_msg", + buff, sizeof( buff)) != NULL ) + { + while( getStringFromIndexWithDelim(buff,",", i,buf2,sizeof(buf2)) + != FALSE ) + { + i++; + if(strstr(szMes,buf2) != NULL) { + NPC_PKPetShop_selectWindow( meindex, talker, 2, -1); + return; + } + } + } + i = 1; + + + /*--公及职及甲件玄毛仁木月蜕邯匹 仄井仃月--*/ + if( NPC_Util_GetStrFromStrWithDelim( argstr, "other_msg", + buff, sizeof( buff)) != NULL ) + { + while(getStringFromIndexWithDelim( buff, ",", i, buf2, sizeof( buf2)) + !=FALSE) + { + i++; + if(strstr(szMes,buf2) != NULL) { + /*--甲件玄丢永本□斥--*/ + if(NPC_Util_GetStrFromStrWithDelim( argstr, "hint_msg", + token, sizeof( token)) != NULL) + { + CHAR_talkToCli( talker, meindex, token, CHAR_COLORWHITE); + return; + } + } + } + } + + /*- 中潸曰毁 井升丹井及民尼永弁--*/ + if(CHAR_getWorkInt( meindex, NPC_PKPETSHOP_WORK_NO) == 1) + { + if(CHAR_getWorkInt( meindex, NPC_PKPETSHOP_WORK_EV) == 1) + { + if( sellonlyflg) + { + CHAR_talkToCli( talker, meindex, sellmsg, CHAR_COLORWHITE); + return; + } + } + else + { /*-- 中潸曰毁 及丢永本□斥--*/ + if( sellonlyflg) + { + NPC_PKPetShop_selectWindow( meindex, talker, 3, -1); + return; + } + } + } + else + { + if(CHAR_getWorkInt( meindex, NPC_PKPETSHOP_WORK_EV) == 1) { + if( sellonlyflg) { + CHAR_talkToCli( talker, meindex, sellmsg, CHAR_COLORWHITE); + return; + } + }else{ + + if(CHAR_getWorkInt( meindex, NPC_PKPETSHOP_WORK_EXPRESS) == 1) { + NPC_PKPetShop_ExpressmanCheck( meindex, talker); + }else{ + /*--仇仇引匹 凶日隋骚它奶件玉它(丢瓦亘□) 憎--*/ + /*-- 中潸曰毁 匹卅仁化 骚及饕卅日丢瓦亘□ 憎--*/ + NPC_PKPetShop_selectWindow( meindex, talker, 0, -1); + } + } + } + +} + +static void NPC_PKPetShop_selectWindow( int meindex, int talker, int num,int select) +{ + + print("\n NPC_PKPetShop_selectWindow()"); + print("\n num = %d ", num); + switch( num) { + case 0: + /*--丢瓦亘□ --*/ + /*--由仿丢□正霜曰--*/ + CHAR_send_P_StatusString( talker, CHAR_P_STRING_GOLD); + + if(CHAR_getWorkInt( meindex, NPC_PKPETSHOP_WORK_EXPRESS) == 1 ) + { + if(CHAR_getWorkInt( meindex, NPC_PKPETSHOP_WORK_NO) ==0 ) + { + NPC_PKPetShop_ExpressmanCheck( meindex, talker); + } + } + else if(CHAR_getWorkInt( meindex, NPC_PKPETSHOP_WORK_NO) == 1) + { + } + else + { + NPC_PKPetShop_Menu( meindex, talker); + } + break; + + case 1: + /*-- 丹 --*/ + NPC_PKPetShop_BuyMain( meindex, talker, select); + break; + + case 2: + /*-- 月 --*/ + NPC_PKPetShop_SellMain( meindex, talker, select); + break; + + case 3: + /*-- 中潸曰毁 匹允方 --*/ + NPC_LimitPetShop( meindex, talker, select); + break; + + } +} + + + +/*----------------------------------------- + * 弁仿奶失件玄井日忒匀化五凶凛卞裟太请今木月[ + * +-------------------------------------------*/ +void NPC_PKPetShopWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + /*-- 及引歹曰卞中卅中午五反蔽 --*/ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 3) { + /*--由仿丢□正霜曰--*/ + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return; + } + + makeStringFromEscaped( data); + switch( seqno){ + + case CHAR_WINDOWTYPE_WINDOWITEMSHOP_STARTMSG: + /*--备丢瓦亘□卞 壬允--*/ + /*-- 丹--*/ + if(atoi( data) == 1 ) NPC_PKPetShop_selectWindow(meindex, talkerindex, 1, -1); + + /*-- 月--*/ + if(atoi( data) == 2) NPC_PKPetShop_selectWindow(meindex, talkerindex, 2, -1); + + /*--请月--*/ + if(atoi( data) == 3) return;/*--窒手仄卅中--*/ + + break; + + + case CHAR_WINDOWTYPE_WINDOWITEMSHOP_BUY_MSG: + /*--失奶 丞及馨笛--*/ + if(NPC_PKPetShop_SetNewPet(meindex , talkerindex, data) == TRUE) { + + NPC_PKPetShop_selectWindow( meindex, talkerindex, 1, 0); + + }else{ + NPC_PKPetShop_selectWindow( meindex, talkerindex ,0, -1); + } + + break; + + + case CHAR_WINDOWTYPE_WINDOWITEMSHOP_SELL_MSG: + /*--失奶 丞及绰轮--*/ + if(NPC_PKPetShop_SellNewPet(meindex , talkerindex, data) == TRUE) { + NPC_PKPetShop_selectWindow( meindex, talkerindex, 2, 0); + + }else{ + NPC_PKPetShop_selectWindow( meindex, talkerindex, 0, -1); + } + + break; + + case CHAR_WINDOWTYPE_WINDOWITEMSHOP_LIMIT: + if(select == WINDOW_BUTTONTYPE_YES) { + NPC_PKPetShop_selectWindow( meindex, talkerindex ,2, -1); + + }else if(select == WINDOW_BUTTONTYPE_NO) { + return; + }else if(select == WINDOW_BUTTONTYPE_OK) { + NPC_PKPetShop_selectWindow( meindex, talkerindex, 2, -1); + } + break; + + case CHAR_WINDOWTYPE_WINDOWITEMSHOP_EXPRESS: + if(atoi(data) == 2) { + NPC_PKPetShop_selectWindow( meindex, talkerindex, 1, -1); + }else if(atoi( data) == 4) { + NPC_PKPetShop_selectWindow( meindex, talkerindex, 2, -1); + } + } +} + + +/*----------------------------------------- + * + * 丹质 丢奶件(弁仿奶失件玄霜耨树 综岳 + * + *krynn 2001/12/9 加的注释 + *before == -1 + *before <> -1 + *krynn end + *-----------------------------------------*/ +void NPC_PKPetShop_BuyMain(int meindex,int talker,int before ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[NPC_UTIL_GETARGSTR_BUFSIZE]; + int fd = getfdFromCharaIndex( talker); + + /* + 曰 中白仿弘 蟆及犯□正银丹井白仿弘 饕及 蟆 丢永本□斥| 丹丢永本□斥 + 蜊醒蓟 丢永本□斥 伊矛伙箫曰卅中丢永本□斥 割 丢永本□斥 + 蟆 尹月 尹卅中白仿弘 失奶 丞伊矛伙 袄蟾 飓 寞 域垫奶件白巧 + 蟆 尹月 尹卅中白仿弘 失奶 丞伊矛伙 袄蟾 飓 寞 域垫奶件白巧 + */ + + /*--云饕及白央奶伙 中坭反白央奶伙互钒仃卅井匀凶午五反蔽 --*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("itemshop_GetArgStr_Err"); + return; + } + + /*--蟆荚及犯□正银丹井---*/ + if(before != -1) + { /*--蟆荚及犯□正互酸匀化中月及匹职及树 反霜日卅仁 --*/ + sprintf(token,"0|0"); + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_ITEMSHOPMAIN, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_BUY_MSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + }else{ + + char token2[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff2[256]; + char buff[256]; + + /*--备丢永本□斥毛潸 仄化弁仿奶失件玄卞霜月犯□正毛综月-*/ + /*--仇及支曰 反五凶卅中井手--*/ + NPC_Util_GetStrFromStrWithDelim( argstr, "main_msg", buff, sizeof( buff)); + NPC_Util_GetStrFromStrWithDelim( argstr, "buy_main", buff2, sizeof( buff2)); + sprintf(token,"0|1|%d|%s|%s|%s|", CHAR_WINDOWTYPE_WINDOWITEMSHOP_STARTMSG, + CHAR_getChar( meindex, CHAR_NAME), buff, buff2); + + NPC_Util_GetStrFromStrWithDelim( argstr, "what_msg", buff, sizeof( buff)); + NPC_Util_GetStrFromStrWithDelim( argstr, "level_msg", buff2, sizeof( buff)); + snprintf( token2, sizeof( token2), "%s|%s", buff, buff2); + + /*-- 侬 宁 --*/ + strncat( token, token2, sizeof( token)); + + NPC_Util_GetStrFromStrWithDelim( argstr, "realy_msg", buff, sizeof( buff)); + NPC_Util_GetStrFromStrWithDelim( argstr, "itemfull_msg", buff2, sizeof( buff2)); + sprintf( token2, "|%s|%s", buff, buff2); + + /*-- 侬 瑛--*/ + strncat(token , token2,sizeof(token)); + strcpy(token2, "|"); + + /*--失奶 丞树 及 --*/ + NPC_PKPetShop_GetPetList( argstr, token2 ); + // krynn 2001/12/12 bebug 用 + print("%s",token2); + // end krynn + + /*--丢永本□斥午失奶 丞树 及宁 --*/ + strncat( token, token2, sizeof( token)); + } + + /*-- 侬 毛巨旦弗□皿今六月--*/ +// makeEscapeString( token, escapedname, sizeof(escapedname)); + + /*--仇仇匹霜耨--*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_ITEMSHOPMAIN, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_BUY_MSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + +} + +/*------------------------------------------------------ + *失奶 丞楮溢及 侬 毛综月( 丹 + *------------------------------------------------------*/ +void NPC_PKPetShop_GetPetList(char *argstr,char *argtoken) +{ + + int i = 1; + int tmp; + int EnemyCnt; + char *name ; + char buff2[256]; + char buff[NPC_UTIL_GETARGSTR_LINEMAX]; + char token2[NPC_UTIL_GETARGSTR_BUFSIZE]; + double rate = 1.0; + int loopcnt = 0; + + /*-伊□玄毛 月[ 仃木壬ㄠ匹裔烂--*/ + if(NPC_Util_GetStrFromStrWithDelim( argstr, "buy_rate", buff2, sizeof( buff2)) + != NULL){ + rate = atof( buff2); + } + + /*- 健丹齿 毛潸 --*/ + if( NPC_Util_GetStrFromStrWithDelim( argstr, "PetList", buff, sizeof( buff)) + != NULL ) + { + while( getStringFromIndexWithDelim(buff,",",i,buff2,sizeof(buff2)) + !=FALSE ) + { + i++; + /*--涩烂白央奶伙及失奶 丞互 "-"匹嗉濠日木化中月井及民尼永弁--*/ + if(strstr( buff2, "-") == NULL) { + /*--引内 蟆 --*/ + // krynn 2001/12/10 + EnemyCnt = ENEMY_getEnemyNum(); + for( tmp=0 ; tmp < EnemyCnt ; tmp++ ) + { + if( ENEMY_getInt( tmp , ENEMY_ID ) == atoi( buff2 ) ) + { + print("\nNPC_PKPetShop_GetPetList: tmp = %d", tmp); + break; + } + } + if( tmp == EnemyCnt ) + { + return; + } + name = ENEMY_getChar( tmp , ENEMY_NAME ); + // krynn end + /*-- 蟆互 卅日}失奶 丞互绣箕仄卅中及匹公及 寞反 骰--*/ + if(name == NULL) continue; + + loopcnt++; + if(loopcnt == MAXSHOPPET) break; + + /*-- 端及皿夫玄戊伙勾仁曰--*/ + NPC_PetStrStr( atoi( buff2), rate, name, token2, tmp); + + /*--丢永本□斥 侬 午 瑛--*/ + strncat( argtoken, token2, sizeof(token2)); + } + else + { + return; + /*krynn 2001/12/13 这段应该用不到了,先 mark,改为直接 return + --失奶 丞互 15-25 及溥匹嗉濠日木化中月桦宁-- + int start; + int end; + + //-"-"匹嗉濠日木凶铵户及醒袄午 及醒袄毛潸 -- + getStringFromIndexWithDelim( buff2, "-", 1, token2, sizeof(token2)); + start = atoi( token2); + getStringFromIndexWithDelim( buff2, "-", 2 ,token2, sizeof(token2)); + end = atoi( token2); + + //-- 寞互菅卞卅匀化中凶日} 木赘尹月 + if(start > end) + { + tmp = start; + start = end; + end = tmp; + } + + end++; + + //--"-"匹嗉濠日木凶坌及失奶 丞树 毛 月-- + for(; start < end ; start++ ) + { + //--引内 蟆 -- + + name = ITEM_getNameFromNumber( start ); + //-- 蟆互 卅日}失奶 丞互绣箕仄卅中及匹公及 寞反 骰-- + if(name == NULL) continue; + + loopcnt++; + if(loopcnt == MAXSHOPPET) break; + + //-- 端及皿夫玄戊伙勾仁曰-- + NPC_PetStrStr( start, rate, name, token2, tmp); + + //--丢永本□斥 侬 午 瑛-- + strncat( argtoken, token2, sizeof(token2)); + }*/ + } + } + } +} + + +/*----------------------------------------------------------------- + 皿夫玄戊伙综岳 +-------------------------------------------------------------------*/ +void NPC_PetStrStr(int petID,double rate,char *name,char *token2,int index) +{ + int i; + int gold; + int level; + int graNo; + int TempNo; + int EnemyTempNum; + char info[1024]; + //char tryItem[256]; // krynn 2001/12/12 只是要看 getItemInfoFromNumber 读出来的字串长什麽样的 + char escape[256] = {"PK Server 宠"}; + + //krynn 2001/12/10 try + //gold = ITEM_getcostFromITEMtabl( itemID); + //level = ITEM_getlevelFromITEMtabl( itemID); + //graNo = ITEM_getgraNoFromITEMtabl( itemID); + TempNo = ENEMY_getInt( index , ENEMY_TEMPNO ); + EnemyTempNum = ENEMYTEMP_getEnemyNum(); + for( i=0 ; i < EnemyTempNum ; i++ ) + { + if( ENEMYTEMP_getInt( i , E_T_TEMPNO ) == TempNo ) + { + break; + } + } + if( i == EnemyTempNum ) + { + return; + } + gold = RAND(0,20); + level = 0; + graNo = ENEMYTEMP_getInt( i , E_T_IMGNUMBER ); + //print("\nPKPetShop::NPC_PetStrStr(): TempNo = %d ; graNo = %d",TempNo,graNo); + /*--伊□玄毛井仃月--*/ + gold=(int)(gold * rate); + + //strcpy( tryItem,ITEM_getItemInfoFromNumber( 10 ) ); + //print("PKPetShop::NPC_PetStrStr(): try = %s\n",tryItem); + //krynn end + + makeEscapeString( escape, info, sizeof( info)); + + makeEscapeString( name, escape, sizeof( escape)); + + sprintf( token2, "%s|0|%d|%d|%d|%s|", escape, level, gold, graNo, info); +} + + +/*------------------------------------------- + *( 丹) + *弁仿奶失件玄井日忒匀凶 凶瑛绊毛 掏今六月 + * + *------------------------------------------*/ +BOOL NPC_PKPetShop_SetNewPet(int meindex,int talker,char *data) +{ + + char buf[1024]; + char buff2[128]; + int i = 1, j = 1; + int select; + int kosuu = 0; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + double rate = 1.0; + int gold = 0; + int EmptyPetCnt=0; + + /*--忒匀化五凶犯□正毛本伊弁玄午蜊醒卞坌荸--*/ + print("\nNPC_PKPetShop_SetNewPet: data = %s",data); + getStringFromIndexWithDelim( data, "|", 1, buf, sizeof( buf)); + select=atoi(buf); // krynn 2001/12/10 select 是玩家传回要买的第几样 + print("\nNPC_PKPetShop_SetNewPet: select = %d",select); + if(select == 0) return FALSE; + getStringFromIndexWithDelim( data, "|", 2, buf, sizeof( buf)); + kosuu=atoi(buf); + print("\nNPC_PKPetShop_SetNewPet: kosuu(玩家要买的数量) = %d",kosuu); + + if( kosuu <= 0 ) return FALSE; + + /* 仍潜谛 及矢永玄及坞五毛茧允 */ + if( !CHAR_CHECKINDEX(talker) ) + { + return FALSE; + } + for( i=0 ; i < CHAR_MAXPETHAVE ; i++ ) + { + if( CHAR_getCharPet( talker,i) == -1 ) + { + EmptyPetCnt++; + } + } + // 有 EmptyPetCnt 个宠物空位 + /* 坞五互 中 */ + print("\nNPC_PKPetShop_SetNewPet:EmptyPetCnt(玩家有的空位) = %d",EmptyPetCnt); + if( EmptyPetCnt <= 0 ) return FALSE; + if( EmptyPetCnt > CHAR_MAXPETHAVE ) + { + EmptyPetCnt = CHAR_MAXPETHAVE; + } + if( kosuu > EmptyPetCnt ) + { + kosuu = EmptyPetCnt; + } + + // krynn 2001/12/10 + // 应该用不到,所以 mark 起来 + /*--蜊醒及民尼永弁 癫卞蝈 月井" + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE ; i++ ) { + itemindex = CHAR_getItemIndex( talker , i ); + + if( !ITEM_CHECKINDEX( itemindex) ) { + kosuucnt++; + } + } + + --忒匀化 凶蜊醒及 互 端及蜊醒 扔□田础 方曰聂中午云井仄中及匹 + --扔□田□础及 毛 木月 + if( kosuucnt < kosuu){ + kosuu = kosuucnt; + } + --未夫及桦宁反巨仿□ + if(kosuucnt == 0 ){ + return FALSE; + } + krynn end */ + + i = 1; + + /*--云饕及白央奶伙 中坭反白央奶伙互钒仃卅井匀凶午五反蔽 --*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("shop_GetArgStr_Err"); + return FALSE; + } + + /*---伊□玄毛潸 卅仃木壬1.0)-*/ + if(NPC_Util_GetStrFromStrWithDelim( argstr, "buy_rate", buf, sizeof( buf)) + != NULL) { + rate= atof( buf); + } + + /*--失奶 丞及馨笛毛垫丹午仇欠-*/ + if( NPC_Util_GetStrFromStrWithDelim( argstr, "PetList", + buf, sizeof( buf)) != NULL ) + { + while(getStringFromIndexWithDelim(buf , "," , j, buff2, sizeof(buff2)) + != FALSE ) + { + j++; + /*-- "-"互殖引木化中月井升丹井--*/ + if(strstr( buff2, "-") == NULL) + { // krynn 2001/12/10 try + //if( ITEM_getcostFromITEMtabl(atoi(buff2)) !=-1) { + // + if ( i == select) + { + /*---失奶 丞及综岳---*/ + /*--蜊醒坌综岳--*/ + if(NPC_AddPetBuy(meindex, talker,atoi(buff2),kosuu,rate) != TRUE) + { + return FALSE; + } + return TRUE; + } + i++; + // krynn end} + }else{ + /*--失奶 丞互 15-25 及溥匹霜日木凶桦宁--*/ + int start; + int end; + + /* "-"匹嗉濠日木凶铵户及醒袄午 及醒袄毛潸 --*/ + getStringFromIndexWithDelim( buff2, "-", 1, argstr, sizeof(argstr)); + start = atoi( argstr); + getStringFromIndexWithDelim( buff2, "-", 2 ,argstr, sizeof(argstr)); + end = atoi( argstr); + end++; + + /*-- 寞互菅卞卅匀化中凶日} 木赘尹月**/ + if(start > end){ + gold = start; + start = end; + end = gold; + } + + /*--"-"匹嗉濠日木凶坌及失奶 丞毛树 毛 月--*/ + for(; start < end ; start++ ) { + if( ITEM_getcostFromITEMtabl( start) != -1) { + if ( i == select) { + /*---失奶 丞及综岳---*/ + /*--蜊醒坌综岳--*/ + if(NPC_AddPetBuy(meindex, talker, start, kosuu, rate) != TRUE) + { + return FALSE; + } + return TRUE; + } + i++; + } + } + } + } + } + + return FALSE; + +} + + +/*--------------------------------------------- + *失奶 丞及馨笛毛垫丹 + *--------------------------------------------*/ +BOOL NPC_AddPetBuy(int meindex, int talker,int petID,int kosuu,double rate) +{ + int i,j,k,index,EnemyCnt,UpLevel; + int gold; + int ret; + int maxgold; + int Grade=0; + char buf[1024]; + char msgbuf[64]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + + // krynn 2001/12/15 get get's grade of this PKPetShop + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("shop_GetArgStr_Err"); + return FALSE; + } + if(NPC_Util_GetStrFromStrWithDelim( argstr, "Grade", buf, sizeof( buf)) + != NULL) + { + Grade = atoi( buf ); + } + // end krynn + + /*--伊□玄毛井仃月--*/ + // krynn 2001/12/11 mark and change + //gold = ITEM_getcostFromITEMtabl( itemID); + gold = 4; + // krynn end + gold = (int)(gold * rate); + maxgold = gold * kosuu; + + if(CHAR_getInt( talker, CHAR_GOLD) < maxgold ) return FALSE; + + /*--云嗯毛蛹日允--*/ + CHAR_setInt( talker, CHAR_GOLD,CHAR_getInt( talker, CHAR_GOLD) - maxgold); + + /* krynn 2001/12/11 PKServer 应该用不到家族,所以先 mark 起来 + if( addNpcFamilyTax( meindex, talker, maxgold*0.4 ) ) + print(" FamilyTaxDone! "); + else + print(" FamilyTaxError!"); + // end krynn*/ + EnemyCnt = ENEMY_getEnemyNum(); + for( index=0 ; index < EnemyCnt ; index++ ) + { + if( ENEMY_getInt( index , ENEMY_ID ) == petID ) + { + print("\nNPC_AddPetBuy: index = %d", index); + break; + } + } + if( index == EnemyCnt ) + { + return FALSE; + } + + /*--蜊醒坌综岳--*/ + for(i = 0 ; i < kosuu ; i++) + { + if( (ret = ENEMY_createPetFromEnemyIndex( talker , index )) == -1 ) + { + return FALSE; + }; + /******************/ + /* 矢永玄树 霜月 */ + /******************/ + // 升仇卞反中匀凶井卅 + for( j = 0 ; j < CHAR_MAXPETHAVE ; j++ ) + { + if( CHAR_getCharPet( talker , j ) == ret ) + { + break; + } + } + if( j == CHAR_MAXPETHAVE ){ + return FALSE; + } + if( CHAR_CHECKINDEX( ret ) == TRUE ){ + CHAR_setMaxExpFromLevel( ret, Grade); + UpLevel = CHAR_LevelUpCheck( ret , talker); + for( k = 0; k < UpLevel; k ++ ){ + CHAR_PetLevelUp( ret ); + CHAR_PetAddVariableAi( ret, AI_FIX_PETLEVELUP ); + } + CHAR_complianceParameter( ret ); + CHAR_setInt( ret , CHAR_HP , CHAR_getWorkInt( ret , CHAR_WORKMAXHP ) ); + + snprintf( msgbuf, sizeof( msgbuf ), "K%d", j ); + CHAR_sendStatusString( talker, msgbuf ); + + snprintf( msgbuf, sizeof( msgbuf ), "W%d", j ); + CHAR_sendStatusString( talker, msgbuf ); + } + } + CHAR_send_P_StatusString( talker, CHAR_P_STRING_GOLD); + return TRUE; +} + + + +/*---------------------------------------- + *丢瓦亘□ + *----------------------------------------*/ +void NPC_PKPetShop_Menu(int meindex,int talker) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[NPC_UTIL_GETARGSTR_LINEMAX]; + char buff[256]; + int fd = getfdFromCharaIndex( talker); + + /* 饕及 蟆 丢永本□斥| */ + /*--云饕及白央奶伙 中坭反白央奶伙互钒仃卅井匀凶午五反蔽 --*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("shop_GetArgStr_Err"); + return; + } + + NPC_Util_GetStrFromStrWithDelim( argstr, "main_msg", buff, sizeof( buff)); + snprintf(token, sizeof(token),"%s|%s",CHAR_getChar( meindex, CHAR_NAME), buff); + + // print("%s",escapedname); + /*--仇仇匹霜耨--*/ + //krynn 2001/12/10 这里的参数似乎可以延用 ItemShop 的 code,先用用看 + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_ITEMSHOPMENU, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_STARTMSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + //krynn end +} + + +/*------------------------------------------- + * 月质 (皿夫玄戊伙毛综岳 + * + *-------------------------------------------*/ +void NPC_PKPetShop_SellMain(int meindex,int talker,int before) +{ + + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[NPC_UTIL_GETARGSTR_BUFSIZE]; + int fd = getfdFromCharaIndex( talker); + + + /* + 曰 中白仿弘 蟆及犯□正银丹井白仿弘 饕及 蟆 丢永本□斥| 月丢永本□斥 + 云嗯互中匀天中卞卅月方丢永本□斥 割 丢永本□斥 + 蟆 木月 木卅中白仿弘 袄蟾 飓 寞 域垫奶件白巧 失奶 丞 寞 ㄠ井日 + 蟆 木月 木卅中白仿弘 袄蟾 飓 寞 域垫奶件白巧 失奶 丞 寞 ㄠ井日 + */ + + /*--云饕及白央奶伙 中坭反白央奶伙互钒仃卅井匀凶午五反蔽 --*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("shop_GetArgStr_Err"); + return; + } + + /*--蟆荚及犯□正银丹井---*/ + if(before != -1) { + + /*--蟆荚及犯□正互酸匀化中月及匹职及树 反霜日卅仁 --*/ + sprintf(token,"1|0"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_ITEMSHOPMAIN + +CHAR_getWorkInt(meindex,NPC_PKPETSHOP_WORK_NO), + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_SELL_MSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + }else{ + + char token2[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff2[256]; + char buff[256]; + + /*--备丢永本□斥毛潸 仄化弁仿奶失件玄卞霜月犯□正毛综月-*/ + /*--仇及支曰 反五凶卅中井手--*/ + NPC_Util_GetStrFromStrWithDelim( argstr, "main_msg", buff, sizeof( buff)); + NPC_Util_GetStrFromStrWithDelim( argstr, "sell_main", buff2, sizeof( buff)); + sprintf( token, "1|1|%d|%s|%s|%s|", CHAR_WINDOWTYPE_WINDOWITEMSHOP_STARTMSG, + CHAR_getChar( meindex, CHAR_NAME), buff, buff2); + + NPC_Util_GetStrFromStrWithDelim( argstr, "stone_msg", buff, sizeof( buff)); + + if(CHAR_getWorkInt(meindex,NPC_PKPETSHOP_WORK_EXPRESS) == 1 ) { + NPC_Util_GetStrFromStrWithDelim( argstr, "exrealy_msg", buff2, sizeof(buff2)); + }else{ + NPC_Util_GetStrFromStrWithDelim( argstr, "realy_msg", buff2, sizeof( buff2)); + } + sprintf( token2,"%s|%s|", buff, buff2); + + /*--失奶 丞树 及 --*/ + NPC_PKPetShop_GetLimtPetList( talker,argstr, token2, -1); + + /*--丢永本□斥午失奶 丞树 及宁 --*/ + strncat( token, token2, sizeof( token)); + + /*--仇仇匹霜耨--*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_ITEMSHOPMAIN+ + CHAR_getWorkInt(meindex,NPC_PKPETSHOP_WORK_NO), + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_SELL_MSG, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + } +} + + + + + +/*-------------------------------- + +愤坌互云饕卞 月失奶 丞及 侬 毛及赏 + + *-------------------------------*/ +int NPC_PKPetShop_GetLimtPetList(int talker, char *argstr, char* token2,int sell) +{ + + char token[NPC_UTIL_GETARGSTR_LINEMAX]; + char buff[NPC_UTIL_GETARGSTR_LINEMAX]; + char token3[NPC_UTIL_GETARGSTR_LINEMAX]; + int k = 0 , i = 1 , j = 0; + int imax; + int itemtype = 0; + int itemindex; + int okflg = 0; + char buf[256]; + int flg=0; + int cost; + + + if(sell == -1 ){ + i = CHAR_STARTITEMARRAY; + imax = CHAR_MAXITEMHAVE; + flg = -1; + }else{ + i= sell; + imax= sell + 1; + flg = 1; + } + + /*--- 木月失奶 丞毛潸 允月[--*/ + /** 旦矢扑乓伙失奶 丞毛手匀化中凶日 伊□玄匹煌遥--*/ + /*-- 旦矢扑乓伙质 匹皿夫弘仿丞互 --*/ + + for( ; i < imax ; i++ ){ + okflg=0; + itemindex = CHAR_getItemIndex( talker , i ); + + if( ITEM_CHECKINDEX( itemindex) ){ + + /*--失奶 丞及正奶皿互域谯仄凶日} 木月--*/ + if( NPC_Util_GetStrFromStrWithDelim( argstr,"LimitItemType", + buff, sizeof( buff)) + != NULL ) + { + k = 1; + while(getStringFromIndexWithDelim(buff , "," , k, token, sizeof(token)) + != FALSE ) + { +#ifdef _ITEM_TYPETABLE + int cmpmaxitem = sizeof(TypeTable)/sizeof(TypeTable[0]); +#endif + k++; +#ifdef _ITEM_TYPETABLE + for(j = 0 ; j < cmpmaxitem ; j++){ +#else + for(j = 0 ; j < ITEM_CATEGORYNUM+3 ; j++){ +#endif + if(strcmp( TypeTable[ j].arg , token) == 0 ) { + itemtype = TypeTable[ j].type; + if(ITEM_getInt(itemindex,ITEM_TYPE) == itemtype) { + + /*-- 侬 综岳--*/ + cost = NPC_GetSellPetList(itemindex,0,argstr,token3,i,sell); + if(cost != -1) return cost; + strncat( token2, token3, sizeof( token3)); + okflg = 1; + }else if(itemtype == 30){ + if( 8 <= ITEM_getInt(itemindex,ITEM_TYPE) + && (ITEM_getInt(itemindex,ITEM_TYPE) <= 15) ){ + /*-- 侬 综岳--*/ + cost = NPC_GetSellPetList(itemindex,0,argstr,token3,i,sell); + if(cost != -1) return cost; + strncat(token2,token3,sizeof(token3)); + okflg = 1; + } + }else if(itemtype == 40){ + if(( 0 <= ITEM_getInt(itemindex,ITEM_TYPE) + && (ITEM_getInt(itemindex,ITEM_TYPE) <= 4)) + || (17 <= ITEM_getInt(itemindex,ITEM_TYPE) + && (ITEM_getInt(itemindex,ITEM_TYPE) <= 19)) + ) { + /*-- 侬 综岳--*/ + cost = NPC_GetSellPetList(itemindex,0,argstr,token3,i,sell); + if(cost != -1) return cost; + strncat(token2,token3,sizeof(token3)); + okflg = 1; + } + }else if(itemtype == 50){ + if( 5 <= ITEM_getInt(itemindex,ITEM_TYPE) + && (ITEM_getInt(itemindex,ITEM_TYPE) <= 7) ){ + /*-- 侬 综岳--*/ + cost = NPC_GetSellPetList(itemindex,0,argstr,token3,i,sell); + if(cost != -1) return cost; + strncat(token2,token3,sizeof(token3)); + okflg = 1; + } + } + break; + } + } + + if(okflg == 1) break; + } + } + /*--正奶皿卞卅仁化 涛 寞仄化 木月失奶 丞井民尼永弁--*/ + if( (NPC_Util_GetStrFromStrWithDelim( argstr, "LimitItemNo", + buff,sizeof( buff)) + != NULL) + && okflg == 0 ) + { + k = 1; + while(getStringFromIndexWithDelim(buff , "," , k, token, sizeof(token)) + != FALSE ) + { + k++; + /*--窒手涩烂今木化卅井匀凶日} 骰允月-*/ + if(strstr( token, "-")==NULL && strcmp(token,"") != 0) { + if(ITEM_getInt(itemindex,ITEM_ID) == atoi(token)) { + /*-- 侬 综岳--*/ + cost = NPC_GetSellPetList(itemindex,0,argstr,token3,i,sell); + if(cost != -1) return cost; + strncat(token2,token3,sizeof(token3)); + okflg=1; + } + }else if (strstr( token, "-") != NULL){ + int start; + int end; + int work; + + /*-- 侬 综岳--*/ + /* "-"匹嗉濠日木凶铵户及醒袄午 及醒袄毛潸 --*/ + getStringFromIndexWithDelim( token, "-", 1, buf, sizeof(buf)); + start = atoi( buf); + getStringFromIndexWithDelim( token, "-", 2 ,buf, sizeof(buf)); + end = atoi( buf); + + /*-- 寞互菅卞卅匀化中凶日} 木赘尹月**/ + if(start > end){ + work = start; + start = end; + end = work; + } + + end++; + /*--"-"匹嗉濠日木凶坌及失奶 丞毛树 毛 月--*/ + if( (start <= ITEM_getInt(itemindex,ITEM_ID)) + && (ITEM_getInt(itemindex,ITEM_ID) < end) ) + { + /*-- 侬 综岳--*/ + cost = NPC_GetSellPetList(itemindex,0,argstr,token3,i,sell); + if(cost != -1) return cost; + strncat(token2,token3,sizeof(token3)); + okflg = 1; + } + } + } + } + + /*-- 月仇午互匹五卅中--*/ + if(okflg == 0) { + cost = NPC_GetSellPetList(itemindex, 1, argstr, token3, i, sell); + if(sell != -1) return -1; + strncat( token2, token3, sizeof( token3)); + } + + } + } + return -1; +} + + + +/*---------------------------------------------------------- + + 弁仿奶失件玄卞霜耨允月皿夫玄戊伙及综岳 + + *----------------------------------------------------------*/ +int NPC_GetSellPetList(int itemindex,int flg, char *argstr,char *argtoken,int select,int sell) +{ + + char buff[256]; + double rate = 0.2; + char buff2[256]; + char buff3[64]; + int k = 1; + int cost = -1; + + /*--旦矢扑乓伙伊□玄--**/ + if(NPC_Util_GetStrFromStrWithDelim( argstr,"special_item",buff, sizeof( buff)) + != NULL) + { + if(NPC_Util_GetStrFromStrWithDelim( argstr,"special_rate",buff2, sizeof( buff2)) + != NULL ) + { + rate = atof(buff2); + }else{ + rate = 1.2; + } + + while(getStringFromIndexWithDelim(buff , "," , k, buff2, sizeof(buff2)) !=FALSE ) + { + k++; + + if(strstr( buff2, "-") == NULL && strcmp(buff2,"") != 0) { + if(ITEM_getInt(itemindex,ITEM_ID) == atoi(buff2)){ + cost = NPC_SellPetstrsStr( itemindex,0, rate, argtoken,select,sell); + return cost; + } + }else if (strstr( buff2, "-") != NULL){ + int start; + int end; + int work; + + /*-- 侬 综岳--*/ + /* "-"匹嗉濠日木凶铵户及醒袄午 及醒袄毛潸 --*/ + getStringFromIndexWithDelim( buff2, "-", 1, buff3, sizeof(buff3)); + start = atoi( buff3); + getStringFromIndexWithDelim( buff2, "-", 2 ,buff3, sizeof(buff3)); + end = atoi( buff3); + + /*-- 寞互菅卞卅匀化中凶日} 木赘尹月**/ + if(start > end){ + work = start; + start = end; + end = work; + } + end++; + + /*--"-"匹嗉濠日木凶坌及失奶 丞毛树 毛 月--*/ + if( (start <= ITEM_getInt(itemindex,ITEM_ID)) + && (ITEM_getInt(itemindex,ITEM_ID) < end) + ){ + + cost = NPC_SellPetstrsStr( itemindex,0, rate, argtoken,select,sell); + return cost; + } + } + } + } + + /*--用□穴伙伊□玄--*/ + if( NPC_Util_GetStrFromStrWithDelim( argstr,"sell_rate",buff, sizeof( buff)) + != NULL ) + { + rate = atof(buff); + cost = NPC_SellPetstrsStr( itemindex, flg ,rate, argtoken,select,sell); + return cost; + } + + return cost; +} + + +/*------------------------------------------ + + 侬 毛综月(丹曰迕) + +*------------------------------------------*/ +int NPC_SellPetstrsStr(int itemindex,int flg,double rate,char *argtoken,int select,int sell) +{ + int cost; + char escapedname[256]; + char name[256]; + char *eff; + + + cost = ITEM_getInt( itemindex, ITEM_COST); + cost = (int)(cost * rate); + + if(sell != -1) return cost; + + + //strcpy( escapedname, ITEM_getChar( itemindex, ITEM_NAME)); + strcpy( escapedname, ITEM_getChar( itemindex, ITEM_SECRETNAME)); + makeEscapeString( escapedname, name, sizeof( name)); + eff=ITEM_getChar(itemindex, ITEM_EFFECTSTRING); + makeEscapeString( eff, escapedname, sizeof(escapedname)); + + + + sprintf(argtoken,"%s|%d|%d|%d|%s|%d|", + name, + flg, + cost, + ITEM_getInt( itemindex, ITEM_BASEIMAGENUMBER), + escapedname, + select + ); + + return -1; + +} + +/*-------------------------------------------- + * + *弁仿奶失件玄井日瑛绊互忒匀化五凶午五 月 + * + *-------------------------------------------*/ +BOOL NPC_PKPetShop_SellNewPet(int meindex,int talker,char *data) +{ + int select; + int cost; + int oldcost; + char token[32]; + int k; + int itemindex; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token2[256]; + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("GetArgStrErr"); + return FALSE; + } + + + /*--忒匀化 凶犯□正及坌荸--*/ + getStringFromIndexWithDelim(data , "|" ,1, token, sizeof( token)); + select = atoi(token); + getStringFromIndexWithDelim(data , "|" ,2, token, sizeof( token)); + oldcost = atoi(token); + + if(select == 0) return FALSE; + + cost = NPC_PKPetShop_GetLimtPetList( talker,argstr, token2,select); + + + /*--啜丹手及毛丹欠丹午仄凶午五及巨仿□--*/ + if(oldcost != cost || cost == -1) + { + int fd = getfdFromCharaIndex( talker); + char token[256]; + + sprintf(token,"\n\n哎呀!对不起" + "\n\n对不起啊 ! 可不可以再选一次呢?" + ); + + k = select; + itemindex = CHAR_getItemIndex( talker ,k); + + + /*--夫弘及请 --*/ + if(itemindex != -1) { + print("\n%s(%d,%d,%d):和选择的东西不同error([%s(%d)]要消失了)", + CHAR_getChar(talker, CHAR_NAME), + CHAR_getInt( talker, CHAR_FLOOR), + CHAR_getInt( talker, CHAR_X ), + CHAR_getInt( talker, CHAR_Y ), + ITEM_getChar(itemindex, CHAR_NAME), + ITEM_getInt( itemindex, ITEM_ID ) + ); + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), /* 失奶 丞 寞 */ +#endif + "SellErr", + CHAR_getInt( talker, CHAR_FLOOR), + CHAR_getInt( talker, CHAR_X ), + CHAR_getInt( talker, CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + }else{ + print("\n%s(%d,%d,%d):和选择的东西不同error(没有任何item存在)", + CHAR_getChar(talker, CHAR_NAME), + CHAR_getInt( talker, CHAR_FLOOR), + CHAR_getInt( talker, CHAR_X ), + CHAR_getInt( talker, CHAR_Y ) + ); + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( talker, CHAR_CDKEY ), + -1, /* 失奶 丞 寞 */ + "SellErr", + CHAR_getInt( talker, CHAR_FLOOR), + CHAR_getInt( talker, CHAR_X ), + CHAR_getInt( talker, CHAR_Y ), + "-1", "NULL", -1 ); + } + /*--仇仇匹霜耨--*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_LIMIT, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + + return FALSE; + } + + k = select; + itemindex=CHAR_getItemIndex( talker ,k); + + if(itemindex != -1) { + { + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID ), /* 失奶 丞 寞 */ +#endif + "Sell", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + + ); + } + + } + + CHAR_DelItem( talker, k); + CHAR_AddGold( talker, cost); + CHAR_send_P_StatusString( talker, CHAR_P_STRING_GOLD); + + return TRUE; +} + + + +void NPC_LimitPetShop(int meindex,int talker,int select) +{ + + int fd = getfdFromCharaIndex( talker); + char token[NPC_UTIL_GETARGSTR_LINEMAX]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024]; + + /*--云饕及白央奶伙 中坭反白央奶伙互钒仃卅井匀凶午五反蔽 --*/ + if( NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("shop_GetArgStr_Err"); + return; + } + + /*-- 中潸曰毁 饕匹允丢永本□斥-*/ + if(NPC_Util_GetStrFromStrWithDelim( argstr, "sellonly_msg", buf, sizeof( buf)) + !=NULL) + { + sprintf(token,"\n\n%s", buf); + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_YESNO, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_LIMIT, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + }else{ + CHAR_talkToCli( talker, meindex, "这是买卖专门店。",CHAR_COLORWHITE); + } + return; +} + + +/*--扪霜盒今氏--*/ +void NPC_PKPetShop_ExpressmanCheck(int meindex,int talker) +{ + int fd = getfdFromCharaIndex( talker); + char token[1024]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024]; + + /*--云饕及白央奶伙 中坭反白央奶伙互钒仃卅井匀凶午五反蔽 --*/ + if( NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { + print("shop_GetArgStr_Err"); + return; + } + + + /*-- 中潸曰毁 饕匹允丢永本□斥-*/ + NPC_Util_GetStrFromStrWithDelim( argstr, "main_msg", buf, sizeof( buf)); + sprintf(token,"4\n丂丂丂丂丂丂丂%s\n\n%s" + "\n\n丂丂丂丂丂< 打工 >丂丂丂" + "\n\n丂丂丂丂 <交付行李>" + ,CHAR_getChar(meindex,CHAR_NAME),buf); + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_WINDOWITEMSHOP_EXPRESS, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + return; + + +} + + +#endif + // _PKPETSHOP + + + + diff --git a/gmsv/npc/npc_poolitemshop.c b/gmsv/npc/npc_poolitemshop.c new file mode 100644 index 0000000..6b4925a --- /dev/null +++ b/gmsv/npc/npc_poolitemshop.c @@ -0,0 +1,882 @@ +#include "version.h" + +#include "char.h" +#include "lssproto_serv.h" +#include "npcutil.h" +#include "npc_poolitemshop.h" +#include "log.h" +#include "handletime.h" + +#define NPC_POOLITEMSHOP_DEFAULT_COST 200 + +enum { + NPC_WORK_COST = CHAR_NPCWORKINT1, + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT9, +}; + +enum { + NPC_POOLITEMSHOP_MSG_MAIN=0, + NPC_POOLITEMSHOP_MSG_POOL, + NPC_POOLITEMSHOP_MSG_DRAW, + NPC_POOLITEMSHOP_MSG_REALY, + NPC_POOLITEMSHOP_MSG_STONE, + NPC_POOLITEMSHOP_MSG_POOLFULL, + NPC_POOLITEMSHOP_MSG_ITEMFULL, + + CHAR_WINDOWTYPE_POOLITEMSHOP_START = 290, + CHAR_WINDOWTYPE_POOLITEMSHOP_POOL_MSG, + CHAR_WINDOWTYPE_POOLITEMSHOP_DRAW_MSG, + CHAR_WINDOWTYPE_POOLITEMSHOP_FULL_MSG, + CHAR_WINDOWTYPE_POOLITEMSHOP_HAVEITEMFULL_MSG, + CHAR_WINDOWTYPE_POOLITEMSHOP_END, + +#ifdef _NPC_DEPOTITEM + CHAR_WINDOWTYPE_DEPOTITEMSHOP_MENU = 310, + CHAR_WINDOWTYPE_DEPOTITEMSHOP_HANDLE, + CHAR_WINDOWTYPE_DEPOTITEMSHOP_ADD, + CHAR_WINDOWTYPE_DEPOTITEMSHOP_GET, +#endif +}; + +typedef struct { + char option[32]; + char defaultmsg[128]; +}NPC_POOLITEMSHOP_MSG; + +NPC_POOLITEMSHOP_MSG poolshopmsg[] = { + { "main_msg", "欢迎"}, + { "pool_main", "要寄放什麽呢"}, + { "draw_main", "要领养什麽呢"}, + { "realy_msg", "真的要那个吗"}, + { "stone_msg", "钱不够喔!"}, + { "poolfull_msg", "超过的无法处理喔"}, + { "itemfull_msg", "项目有很多"} +}; + +static BOOL NPC_PoolItemShop_DrawItem( int meindex, int talkerindex, int num); +static BOOL NPC_PoolItemShop_PoolItem( int meindex, int talkerindex, int num); +static void NPC_PoolItemShop_MakeItemString_Draw( int meindex, int talkerindex, + char *retstring,int retstringlen); +static void NPC_PoolItemShop_MakeItemString_Pool( int meindex, int talkerindex, + char *retstring,int retstringlen); +static char *NPC_PoolItemShop_getMsg_noarg( int tablenum, + char *argstr, char *retstring, int retstringlen); +static void NPC_PoolItemShop_printWindow_Draw( int meindex, int talkerindex); +static void NPC_PoolItemShop_printWindow_Pool( int meindex, int talkerindex); +static void NPC_PoolItemShop_printWindow_Full( int meindex, int talkerindex); +void NPC_PoolItemShop_printWindow_Start( int meindex, int talkerindex); +static void NPC_PoolItemShop_printWindow_HaveItemFull( int meindex, int talkerindex); + +#ifdef _NPC_DEPOTITEM +void NPC_PoolItemShop_DepotItem_Menu( int meindex, int talkerindex); +void NPC_DepotItem_Item_printWindow( int meindex, int talkerindex); +void NPC_DepotItem_Depot_printWindow( int meindex, int talkerindex); +BOOL NPC_DepotItem_InsertItem( int meindex, int talkerindex, int num); +BOOL NPC_DepotItem_gettItem( int meindex, int talkerindex, int num); +#endif + +#define NPCPOOLITEMLOOP 1000*20 +int othertime=0; +BOOL NPC_PoolItemShopInit( int meindex) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + int cost; + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + cost = NPC_Util_GetNumFromStrWithDelim( argstr, "cost"); + if( cost == -1 ) cost = NPC_POOLITEMSHOP_DEFAULT_COST; + CHAR_setWorkInt( meindex, NPC_WORK_COST, cost); + + return TRUE; +} + +void NPC_PoolItemShopLoop( int meindex) +{ +} + +void NPC_PoolItemShopTalked( int meindex , int talkerindex , + char *szMes ,int color ) +{ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + if( !NPC_Util_isFaceToFace( meindex, talkerindex, 2)) { + if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) return; + } + NPC_PoolItemShop_printWindow_Start( meindex, talkerindex); +} + +void NPC_PoolItemShopWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 2) return; + + //print("\n NPC_PoolItemShopWindowTalked: seq:%d sel:%d data:%s", seqno, select, data); + + switch( seqno ) { + case CHAR_WINDOWTYPE_POOLITEMSHOP_START: + switch( atoi( data)) { + case 1: + if( CHAR_getCharPoolItemIndexElement( talkerindex) != -1 ) { + NPC_PoolItemShop_printWindow_Pool( meindex, talkerindex); + }else { + NPC_PoolItemShop_printWindow_Full( meindex, talkerindex); + } + break; + case 2: + if( CHAR_findEmptyItemBox( talkerindex) != -1 ) { + NPC_PoolItemShop_printWindow_Draw( meindex, talkerindex); + }else { + NPC_PoolItemShop_printWindow_HaveItemFull( meindex, talkerindex); + } + break; +#ifdef _NPC_DEPOTITEM + case 3: + if( !CHAR_CheckDepotItem( talkerindex) ){ + CHAR_GetDepotItem( meindex, talkerindex); + CHAR_talkToCli( talkerindex, -1, "取得道具,请稍後!", CHAR_COLORYELLOW); + }else{ + NPC_PoolItemShop_DepotItem_Menu( meindex, talkerindex); + } + break; +#endif + + } + break; + case CHAR_WINDOWTYPE_POOLITEMSHOP_POOL_MSG: + if( atoi( data) == 0){ + NPC_PoolItemShop_printWindow_Start( meindex, talkerindex); + }else { + NPC_PoolItemShop_PoolItem( meindex, talkerindex, atoi(data)-1); + } + break; + case CHAR_WINDOWTYPE_POOLITEMSHOP_DRAW_MSG: + if( atoi( data) == 0){ + NPC_PoolItemShop_printWindow_Start( meindex, talkerindex); + }else { + NPC_PoolItemShop_DrawItem( meindex, talkerindex, atoi(data)-1); + } + break; + case CHAR_WINDOWTYPE_POOLITEMSHOP_FULL_MSG: + NPC_PoolItemShop_printWindow_Start( meindex, talkerindex); + break; + case CHAR_WINDOWTYPE_POOLITEMSHOP_HAVEITEMFULL_MSG: + NPC_PoolItemShop_printWindow_Start( meindex, talkerindex); + break; + +#ifdef _NPC_DEPOTITEM + case CHAR_WINDOWTYPE_DEPOTITEMSHOP_MENU: + if( !CHAR_CheckDepotItem( talkerindex) ){ + CHAR_GetDepotItem( meindex, talkerindex); + return; + }else{ + NPC_PoolItemShop_DepotItem_Menu( meindex, talkerindex); + } + break; + case CHAR_WINDOWTYPE_DEPOTITEMSHOP_HANDLE: + if( !CHAR_CheckDepotItem( talkerindex) ) return ; + switch( atoi( data)) { + case 1://放入 + if( CHAR_findEmptyDepotItem( talkerindex) == -1 ){ + CHAR_talkToCli( talkerindex, -1, "仓库已满!", CHAR_COLORYELLOW); + return; + } + NPC_DepotItem_Item_printWindow( meindex, talkerindex); + break; + case 2: + if( CHAR_findEmptyItemBox( talkerindex) == -1 ) { + CHAR_talkToCli( talkerindex, -1, "身上道具栏位已满!", CHAR_COLORYELLOW); + return; + } + NPC_DepotItem_Depot_printWindow( meindex, talkerindex); + break; + } + break; + case CHAR_WINDOWTYPE_DEPOTITEMSHOP_ADD://放入 + if( !CHAR_CheckDepotItem( talkerindex) ) return ; + if( atoi( data) == 0){ + NPC_PoolItemShop_DepotItem_Menu( meindex, talkerindex); + }else { + if( NPC_DepotItem_InsertItem( meindex, talkerindex, atoi( data)-1) == FALSE ){ + NPC_PoolItemShop_DepotItem_Menu( meindex, talkerindex); + CHAR_talkToCli( talkerindex, -1, "存放道具失败,请稍後再试!", CHAR_COLORYELLOW); + } + } + break; + case CHAR_WINDOWTYPE_DEPOTITEMSHOP_GET: + if( !CHAR_CheckDepotItem( talkerindex) ) return ; + if( atoi( data) == 0){ + NPC_PoolItemShop_DepotItem_Menu( meindex, talkerindex); + }else { + if( NPC_DepotItem_gettItem( meindex, talkerindex, atoi( data)-1) == FALSE ){ + NPC_PoolItemShop_DepotItem_Menu( meindex, talkerindex); + CHAR_talkToCli( talkerindex, -1, "取出道具失败,请稍後再试!", CHAR_COLORYELLOW); + } + } + break; +#endif + + default: + break; + } +} + +void NPC_PoolItemShop_printWindow_Start( int meindex, int talkerindex) +{ + int fd; + + fd = getfdFromCharaIndex( talkerindex); + if( fd != -1 ) { + char message[1024]; + char buf[2048]; + +#ifdef _NPC_DEPOTITEM + strcpy( message, + "3\n\n" + " 欢迎光临\n\n" + " <寄放道具>\n" + " <取回道具>\n" + " <使用仓库>\n\n" + " < 离开 >" + ); +#else + strcpy( message, + "3\n\n" + " 欢迎光临\n\n" + " <寄放道具>\n" + " <取回道具>\n\n\n" + " < 离开 >" + ); +#endif + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_POOLITEMSHOP_START, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( message, buf, sizeof(buf))); + } +} + +#ifdef _NPC_DEPOTITEM +void NPC_PoolItemShop_DepotItem_Menu( int meindex, int talkerindex) +{ + int fd; + + fd = getfdFromCharaIndex( talkerindex); + if( fd != -1 ) { + char message[1024]; + char buf[2048]; + + strcpy( message, + "3\n\n" + " 使用道具仓库\n\n" + " <存放道具>\n" + " <取回道具>\n" + ); + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_SELECT, + WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_DEPOTITEMSHOP_HANDLE, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( message, buf, sizeof(buf))); + } +} + +void NPC_DepotItem_MakeItemString( int meindex, int talkerindex, char *retstring,int retstringlen) +{ + int i; + int itemindex; + int pos = 0; + char buff[1024]; + + retstring[0] = '\0'; + for( i = CHAR_STARTITEMARRAY; i < CHAR_MAXITEMHAVE; i ++ ) { + int poolflg = FALSE; + itemindex = CHAR_getItemIndex( talkerindex, i); + if( !ITEM_CHECKINDEX( itemindex) ) continue; + + if( ITEM_getInt( itemindex, ITEM_DROPATLOGOUT) || ITEM_getInt( itemindex, ITEM_VANISHATDROP) || + !ITEM_getInt( itemindex, ITEM_CANPETMAIL) ) { + poolflg = TRUE; + } + snprintf( buff, sizeof( buff), +#ifdef _ITEM_PILENUMS + "%s|%d|%d|%d|%s|%d|%d|", +#else + "%s|%d|%d|%d|%s|%d|", +#endif + ITEM_getChar( itemindex, ITEM_SECRETNAME), + poolflg,CHAR_getWorkInt( meindex, NPC_WORK_COST), + ITEM_getInt( itemindex, ITEM_BASEIMAGENUMBER), + ITEM_getChar( itemindex, ITEM_EFFECTSTRING), +#ifdef _ITEM_PILENUMS + ITEM_getInt( itemindex, ITEM_USEPILENUMS), +#endif + i + 1 ); + + if( pos +strlen( buff)>= retstringlen) { + fprint( "buffer over err\n"); + break; + } + strcpy( &retstring[pos], buff); + pos += strlen( buff); + } +} + +void NPC_DepotItem_Item_printWindow( int meindex, int talkerindex) +{ + char itemstring[65536-1024]; + char sendstring[65536]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff2[1024]; + char buff3[1024]; + char buff4[1024]; + int fd; + + if( (fd = getfdFromCharaIndex( talkerindex)) == -1 ){ + fprint( "err\n"); + return; + } + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + snprintf( sendstring, sizeof( sendstring), "0|%d|%s|%s|%s|%s|", + CHAR_getfindEmptyDepotItem( talkerindex), + CHAR_getChar( meindex, CHAR_NAME), + NPC_PoolItemShop_getMsg_noarg( NPC_POOLITEMSHOP_MSG_POOL, argstr, buff2, sizeof( buff2)), + NPC_PoolItemShop_getMsg_noarg( NPC_POOLITEMSHOP_MSG_POOLFULL, argstr, buff3, sizeof( buff3)), + NPC_PoolItemShop_getMsg_noarg( NPC_POOLITEMSHOP_MSG_REALY, argstr, buff4, sizeof( buff4)) + ); + + NPC_DepotItem_MakeItemString( meindex, talkerindex, itemstring, sizeof( itemstring)); + strcat( sendstring, itemstring); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_POOLITEMSHOPMAIN, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_DEPOTITEMSHOP_ADD, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), sendstring); + +} + +void NPC_DepotItem_MakeDepotString( int meindex, int talkerindex, char *retstring,int retstringlen) +{ + int i; + int itemindex; + int pos = 0; + char buff[1024]; + + retstring[0] = '\0'; + for( i = 0; i < /*60*/CHAR_MAXDEPOTITEMHAVE; i ++ ) { + int poolflg = FALSE; + itemindex = CHAR_getDepotItemIndex( talkerindex, i); + if( !ITEM_CHECKINDEX( itemindex)) continue; + snprintf( buff, sizeof( buff), +#ifdef _ITEM_PILENUMS + "%s|%d|%d|%d|%d|%s|%d|", +#else + "%s|%d|%d|%d|%d|%s|", +#endif + ITEM_getChar( itemindex, ITEM_SECRETNAME), + poolflg, + ITEM_getInt( itemindex, ITEM_LEVEL), + ITEM_getInt( itemindex, ITEM_COST), + ITEM_getInt( itemindex, ITEM_BASEIMAGENUMBER), + ITEM_getChar( itemindex, ITEM_EFFECTSTRING) +#ifdef _ITEM_PILENUMS + ,ITEM_getInt( itemindex, ITEM_USEPILENUMS) +#endif + ); + if( pos +strlen( buff)>= retstringlen) { + fprint( "buffer over err\n"); + break; + } + strcpy( &retstring[pos], buff); + pos += strlen( buff); + } + +} + +void NPC_DepotItem_Depot_printWindow( int meindex, int talkerindex) +{ + char itemstring[65536-1024]; + char sendstring[65536]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff[1024]; + char buff2[1024]; + char buff3[1024]; + int fd; + + if( (fd = getfdFromCharaIndex( talkerindex)) == -1 )return; + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + snprintf( sendstring, sizeof( sendstring), "1|%s|%s|%s|%s|", + CHAR_getChar( meindex, CHAR_NAME), + NPC_PoolItemShop_getMsg_noarg( NPC_POOLITEMSHOP_MSG_DRAW, argstr, buff2, sizeof( buff2)), + NPC_PoolItemShop_getMsg_noarg( NPC_POOLITEMSHOP_MSG_ITEMFULL, argstr, buff, sizeof( buff)), + NPC_PoolItemShop_getMsg_noarg( NPC_POOLITEMSHOP_MSG_REALY, argstr, buff3, sizeof( buff3)) + ); + NPC_DepotItem_MakeDepotString( meindex, talkerindex, itemstring, sizeof( itemstring)); + strcat( sendstring, itemstring); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_POOLITEMSHOPMAIN, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_DEPOTITEMSHOP_GET, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + sendstring); + + //print("\n NPC_DepotItem_Depot_printWindow:%s size:%d ", sendstring, strlen(sendstring)); +} + +void NPC_DepotItem_CheckRepeat_Del( int charaindex, int ti, int itemindex) +{ + char token[256]; + sprintf( token, "仓库道具%s,编码重复!(系统清除)", + ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( charaindex, -1, token, CHAR_COLORYELLOW); + LogItem( + CHAR_getChar( charaindex, CHAR_NAME ), + CHAR_getChar( charaindex, CHAR_CDKEY ), +#ifdef _add_item_log_name + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), +#endif + "repeat(仓库道具重复)", + 0, 0, 0, + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) ); + + CHAR_setDepotItemIndex( charaindex, ti, -1); + ITEM_endExistItemsOne( itemindex); +} + +void NPC_DepotItem_CheckRepeat( int talkerindex) +{ + int i, j, cnt=0, itemindex, itemindex1; + + for( i=0; i<(CHAR_MAXDEPOTITEMHAVE-1); i++){ + itemindex = CHAR_getDepotItemIndex( talkerindex, i); + if( !ITEM_CHECKINDEX( itemindex)) continue; + cnt=0; + for( j=(i+1); j= arraysizeof( poolshopmsg)) return NULL; + + if( NPC_Util_GetStrFromStrWithDelim( argstr, poolshopmsg[tablenum].option, buf, sizeof( buf)) != NULL ) { + strcpysafe( retstring, retstringlen, buf); + }else { + strcpysafe( retstring, retstringlen, poolshopmsg[tablenum].defaultmsg); + } + return retstring; +} + +static void NPC_PoolItemShop_MakeItemString_Pool( int meindex, int talkerindex, + char *retstring,int retstringlen) +{ + int i; + int itemindex; + int pos = 0; + char buff[1024]; + + retstring[0] = '\0'; + for( i = CHAR_STARTITEMARRAY; i < CHAR_MAXITEMHAVE; i ++ ) { + itemindex = CHAR_getItemIndex( talkerindex, i); + if( ITEM_CHECKINDEX( itemindex)) { + int poolflg = FALSE; + if( ITEM_getInt( itemindex, ITEM_DROPATLOGOUT) || + ITEM_getInt( itemindex, ITEM_VANISHATDROP) || + !ITEM_getInt( itemindex, ITEM_CANPETMAIL)){ + poolflg = TRUE; + } + snprintf( buff, sizeof( buff), +#ifdef _ITEM_PILENUMS + "%s|%d|%d|%d|%s|%d|%d|", +#else + "%s|%d|%d|%d|%s|%d|", +#endif + ITEM_getChar( itemindex, ITEM_SECRETNAME), + poolflg,CHAR_getWorkInt( meindex, NPC_WORK_COST), + ITEM_getInt( itemindex, ITEM_BASEIMAGENUMBER), + ITEM_getChar( itemindex, ITEM_EFFECTSTRING), +#ifdef _ITEM_PILENUMS + ITEM_getInt( itemindex, ITEM_USEPILENUMS), +#endif + i + 1 ); + if( pos +strlen( buff)>= retstringlen) { + fprint( "buffer over err\n"); + break; + } + strcpy( &retstring[pos], buff); + pos += strlen( buff); + } + } +} + +static void NPC_PoolItemShop_MakeItemString_Draw( int meindex, int talkerindex, + char *retstring,int retstringlen) +{ + int i; + int itemindex; + int pos = 0; + char buff[1024]; + + retstring[0] = '\0'; + for( i = 0; i < CHAR_MAXPOOLITEMHAVE; i ++ ) { + itemindex = CHAR_getPoolItemIndex( talkerindex, i); + if( ITEM_CHECKINDEX( itemindex)) { + int poolflg = FALSE; + snprintf( buff, sizeof( buff), +#ifdef _ITEM_PILENUMS + "%s|%d|%d|%d|%d|%s|%d|", + +#else + "%s|%d|%d|%d|%d|%s|", +#endif + ITEM_getChar( itemindex, ITEM_SECRETNAME), + poolflg, + ITEM_getInt( itemindex, ITEM_LEVEL), + ITEM_getInt( itemindex, ITEM_COST), + ITEM_getInt( itemindex, ITEM_BASEIMAGENUMBER), + ITEM_getChar( itemindex, ITEM_EFFECTSTRING) +#ifdef _ITEM_PILENUMS + ,ITEM_getInt( itemindex, ITEM_USEPILENUMS) +#endif + ); + if( pos +strlen( buff)>= retstringlen) { + fprint( "buffer over err\n"); + break; + } + strcpy( &retstring[pos], buff); + pos += strlen( buff); + } + } +} + +static BOOL NPC_PoolItemShop_PoolItem( int meindex, int talkerindex, int num) +{ + int emptyindex; + int itemindex; + int cost = CHAR_getWorkInt( meindex, NPC_WORK_COST); + + emptyindex = CHAR_getCharPoolItemIndexElement( talkerindex); + if( emptyindex == -1 ) { + return FALSE; + } + + itemindex = CHAR_getItemIndex( talkerindex, num); + if( !ITEM_CHECKINDEX( itemindex)) { + fprint( "err"); + return FALSE; + } + CHAR_DelGold( talkerindex, cost ); + + CHAR_setPoolItemIndex( talkerindex, emptyindex, itemindex); + + CHAR_setItemIndex( talkerindex, num, -1); + CHAR_sendItemDataOne( talkerindex, num); + + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + LogItem( + CHAR_getChar( talkerindex, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( talkerindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), /* 失奶 丞 寞 */ +#endif + "pool(寄放道具)", + CHAR_getInt( talkerindex,CHAR_FLOOR), + CHAR_getInt( talkerindex,CHAR_X ), + CHAR_getInt( talkerindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + + ); + return TRUE; +} + +static BOOL NPC_PoolItemShop_DrawItem( int meindex, int talkerindex, int num) +{ + int emptyindex; + int itemindex; + int i; + int cnt; + int work[CHAR_MAXPOOLITEMHAVE]; + + emptyindex = CHAR_findEmptyItemBox( talkerindex); + if( emptyindex == -1 ) return FALSE; + + itemindex = CHAR_getPoolItemIndex( talkerindex, num); + if( !ITEM_CHECKINDEX( itemindex)) { + fprint( "err\n"); + return FALSE; + } + CHAR_setItemIndex( talkerindex, emptyindex, itemindex); + CHAR_setPoolItemIndex( talkerindex, num, -1); + CHAR_sendItemDataOne( talkerindex, emptyindex); + for( i = 0; i < CHAR_MAXPOOLITEMHAVE; i ++ ) { + work[i] = -1; + } + cnt = 0; + for( i = 0; i < CHAR_MAXPOOLITEMHAVE; i ++ ) { + itemindex = CHAR_getPoolItemIndex( talkerindex, i); + if( ITEM_CHECKINDEX( itemindex)) { + work[ cnt++] = itemindex; + } + } + for( i = 0; i < CHAR_MAXPOOLITEMHAVE; i ++ ) { + CHAR_setPoolItemIndex( talkerindex, i, work[i]); + } + LogItem( + CHAR_getChar( talkerindex, CHAR_NAME ), + CHAR_getChar( talkerindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), +#endif + "draw(领取道具)", + CHAR_getInt( talkerindex,CHAR_FLOOR), + CHAR_getInt( talkerindex,CHAR_X ), + CHAR_getInt( talkerindex,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + return TRUE; +} diff --git a/gmsv/npc/npc_quiz.c b/gmsv/npc/npc_quiz.c new file mode 100644 index 0000000..e84cfbc --- /dev/null +++ b/gmsv/npc/npc_quiz.c @@ -0,0 +1,1426 @@ +#include "version.h" +#include +#include "common.h" +#include "char_base.h" +#include "npc_quiz.h" +#include "npcutil.h" +#include "char.h" +#include "lssproto_serv.h" +#include "buf.h" +#include "function.h" +#include "readmap.h" +#include "object.h" +#include "log.h" + +#define MEPLAYER 8 +#define OLDNO 100 + +enum { + CHAR_WORK_PLAYER1 = CHAR_NPCWORKINT1, + CHAR_WORK_PLAYER2 = CHAR_NPCWORKINT2, + CHAR_WORK_PLAYER3 = CHAR_NPCWORKINT3, + CHAR_WORK_PLAYER4 = CHAR_NPCWORKINT4, + CHAR_WORK_PLAYER5 = CHAR_NPCWORKINT5, + CHAR_WORK_PLAYER6 = CHAR_NPCWORKINT6, + CHAR_WORK_PLAYER7 = CHAR_NPCWORKINT7, + CHAR_WORK_PLAYER8 = CHAR_NPCWORKINT8, + CHAR_WORK_QUIZNUM = CHAR_NPCWORKINT9, +}; + +NPC_QUIZ* Quiz; + +struct pl{ + int talkerindex; + int quizno; + int answer; + int ansno; + int oldno[OLDNO]; + int *ptr; +}; + + +static int quizcnt = 0; + + +static void NPC_Quiz_selectWindow( int meindex, int talker, int num); +int *NPC_GetQuestion(int meindex); +BOOL NPC_QuizItemFullCheck(int meindex, int talker); +BOOL NPC_PlayerCheck(int meindex,int talker); +int NPC_RealyCheack(int meindex,int talker); +int NPC_QuizRandAnswer(int p_no,int q_no, int mode, + char *work1,char *work2,char *work3); +int NPC_QuizBorderLine(int ans, char *buf); +int NPC_QuizWarpBorderLine(int ans, char *buf); + +BOOL NPC_QuizAddItem(int talker,char *buf); + +BOOL NPC_EntryItemDel(int talker,char *buf); +BOOL NPC_EntryItemCheck(int talker,char *buf); +BOOL NPC_EntryStoneDel(int talker,char *buf); +BOOL NPC_EntryStoneCheck(int talker,char *buf); +BOOL NPC_QUIZPARTY_CHAECK(int meindex,int talker); + +BOOL NPC_QuizInit( int meindex ) +{ + + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024]; + int *tbl; + int i; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + if(NPC_Util_GetStrFromStrWithDelim( argstr, "StartMsg", buf, sizeof( buf)) == NULL){ + print("Quiz_StartMsgErr:%s", CHAR_getChar( meindex, CHAR_NAME)); + return FALSE; + } + + if(NPC_Util_GetStrFromStrWithDelim( argstr, "Quiznum", buf, sizeof( buf)) == NULL){ + print("QuizNumErrErr:%s", CHAR_getChar( meindex, CHAR_NAME)); + return FALSE; + } + + CHAR_setWorkInt( meindex, CHAR_WORK_QUIZNUM, atoi( buf)); + + for(i =0 ; i < 8 ; i++){ + CHAR_setWorkInt( meindex, CHAR_WORK_PLAYER1 + i, -1); + } + tbl = NPC_GetQuestion( meindex); + + if( CHAR_getWorkInt( meindex, CHAR_WORK_QUIZNUM) > ( tbl[0] - 1)){ + print( + "%s丗符合条件,圆圈quiz的问题数(%d 比出题数(%d题)不足", + CHAR_getChar( meindex, CHAR_NAME), + (tbl[0]-1), + CHAR_getWorkInt( meindex, CHAR_WORK_QUIZNUM) + ); + return FALSE; + } + + return TRUE; + +} + +void NPC_QuizTalked( int meindex , int talkerindex , char *szMes , + int color ) +{ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) return; + + if(NPC_QUIZPARTY_CHAECK(meindex,talkerindex)==FALSE){ + NPC_Quiz_selectWindow( meindex, talkerindex, 4); + + } + if(NPC_QuizItemFullCheck(meindex, talkerindex) == FALSE){ + NPC_Quiz_selectWindow( meindex, talkerindex, 3); + }else{ + NPC_Quiz_selectWindow( meindex, talkerindex, 0); + } +} + +static void NPC_Quiz_selectWindow( int meindex, int talker, int num) +{ + + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[1024]; + char buf[256]; + char buf2[256]; + char buf3[256]; + + int i = 0,k; + int questionno = 0; + int fd = getfdFromCharaIndex( talker); + int buttontype = 0; + int messagetype = 0; + int windowno = 0; + int len = 4; + int p_no; + int p_old; + int loop=0; + int ans; + BOOL entryflg = TRUE; + switch( num) { + case 0: + if(NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL){ + print("GetArgstrErr:Quiz %s",CHAR_getChar( meindex, CHAR_NAME)); + } + if(NPC_Util_GetStrFromStrWithDelim( argstr,"StartMsg", + token, sizeof( token)) == NULL){ + print("%s的StartMsg不存在", CHAR_getChar(meindex,CHAR_NAME)); + return; + } + buttontype = WINDOW_BUTTONTYPE_YESNO; + messagetype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_QUIZ_START; + break; + + case 1: + if(NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL){ + print("GetArgstrErr:Quiz %s",CHAR_getChar( meindex, CHAR_NAME)); + } + if(NPC_Util_GetStrFromStrWithDelim( argstr,"EntryItem", + buf2, sizeof( buf2)) != NULL){ + if(NPC_EntryItemCheck( talker, buf2) == FALSE){ + entryflg = FALSE; + } + } + if(NPC_Util_GetStrFromStrWithDelim( argstr,"EntryStone", + buf3, sizeof( buf3)) != NULL){ + if(NPC_EntryStoneCheck( talker, buf3) == FALSE){ + entryflg = FALSE; + } + } + if(entryflg == FALSE){ + if(NPC_Util_GetStrFromStrWithDelim( argstr,"NoEntryMsg", + token, sizeof( token)) != NULL) { + buttontype = WINDOW_BUTTONTYPE_OK; + messagetype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_QUIZ_START; + + } + + }else if(NPC_PlayerCheck( meindex, talker) == FALSE) { + /*--谛醒左□田□---*/ + sprintf(token,"\n\n\n 请,稍等一下" + "\n{{ ㄠ蘸卞公氏卅卞锹澎匹五卅中井日" + ); + buttontype = WINDOW_BUTTONTYPE_OK; + messagetype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_QUIZ_START; + + }else{ + if(NPC_Util_GetStrFromStrWithDelim( argstr,"EntryItem", + buf2, sizeof( buf2)) != NULL){ + if(NPC_EntryItemDel( talker, buf2) ==FALSE){ + print("道具没有消失(%s)",CHAR_getChar(meindex,CHAR_NAME)); + return; + } + } + if(NPC_Util_GetStrFromStrWithDelim( argstr,"EntryStone", + buf3, sizeof( buf3)) != NULL){ + if(NPC_EntryStoneDel( talker, buf3) ==FALSE){ + print("金钱没有消失(%s)",CHAR_getChar(meindex,CHAR_NAME)); + return; + } + } + NPC_Quiz_selectWindow(meindex, talker, 2); + return; + } + break; + + case 3: + if(NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL){ + print("GetArgstrErr:Quiz %s",CHAR_getChar( meindex, CHAR_NAME)); + } + + /*-- 旦正□玄丢永本□斥 --*/ + if(NPC_Util_GetStrFromStrWithDelim( argstr,"ItemFullMsg", + token, sizeof( token)) == NULL) + { + print("%s的ItemFullMsg不存在", CHAR_getChar(meindex,CHAR_NAME)); + return; + } + + buttontype = WINDOW_BUTTONTYPE_OK; + messagetype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_QUIZ_START; + + break; + case 2: + /*--丢奶件--*/ + { + int *tbl; + int point; + int *pl_ptr; + int warp_flg = -1; + int floor=0,x=0,y=0; + + struct pl PLAYER; + + + /*--由□ 奴□卞卅匀化卅中井--*/ + if(NPC_QUIZPARTY_CHAECK(meindex,talker)==FALSE){ + NPC_Quiz_selectWindow( meindex, talker, 4); + } + + + + /*--荸蚕樊 寞毛 月--*/ + p_no = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANT); + point = CHAR_getWorkInt( meindex, CHAR_WORK_PLAYER1 + p_no); + pl_ptr = (int *)point; + + /*-- 丢乒伉及 毛厌瞻 卞戊疋□ --*/ + memcpy(&PLAYER, pl_ptr, sizeof(struct pl)); + + /*--蝈化及 锁互蔽歹匀凶及匹瑛绊毛 屡--*/ + if(PLAYER.quizno + == CHAR_getWorkInt( meindex, CHAR_WORK_QUIZNUM)) + { + double avg; + int okflg; + char buf2[512]; + + /*-- arg白央奶伙及 心 心 --*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL) + { + print("GetArgstrErr:Quiz %s",CHAR_getChar( meindex, CHAR_NAME)); + } + + /*--恳荸醒卞杀元化失奶 丞毛馨笛允月---*/ + if(NPC_Util_GetStrFromStrWithDelim( argstr, "GetItem", buf, sizeof( buf) ) + !=NULL) + { + okflg = NPC_QuizBorderLine(PLAYER.answer,buf); + if(okflg == -1) + { + + }else{ + + getStringFromIndexWithDelim(buf , "," , okflg+1, buf3, sizeof(buf3)); + if(NPC_QuizAddItem( talker, buf3) == FALSE) return ; + + } + } + + /*--恳荸醒卞杀元化失奶 丞毛馨笛允月---*/ + if(NPC_Util_GetStrFromStrWithDelim( argstr, "Border", buf, sizeof( buf) ) + !=NULL) + { + okflg = NPC_QuizBorderLine(PLAYER.answer,buf); + if(okflg == -1) + { + NPC_Util_GetStrFromStrWithDelim( argstr, "FailureMsg", + buf2,sizeof(buf2)); + + CHAR_talkToCli( talker, meindex, buf2, CHAR_COLORWHITE); + + }else{ + + getStringFromIndexWithDelim(buf , "," , okflg+1, buf2, sizeof(buf2)); + CHAR_talkToCli( talker, meindex, buf2, CHAR_COLORWHITE); + } + } + + + /*--恳荸醒卞杀元化伐□皿今六月---*/ + if(NPC_Util_GetStrFromStrWithDelim( argstr, "Warp", buf, sizeof( buf) ) + !=NULL) + { + warp_flg = NPC_QuizWarpBorderLine(PLAYER.answer,buf); + if(warp_flg != -1) { + char warpbuf[32]; + + getStringFromIndexWithDelim(buf , "," , warp_flg+1, buf2, sizeof(buf2)); + getStringFromIndexWithDelim(buf2 , "." , 1, warpbuf, sizeof(warpbuf)); + floor = atoi(warpbuf); + getStringFromIndexWithDelim(buf2 , "." , 2, warpbuf, sizeof(warpbuf)); + x = atoi(warpbuf); + getStringFromIndexWithDelim(buf2 , "." , 3, warpbuf, sizeof(warpbuf)); + y = atoi(warpbuf); + } + } + + + + /*-- 失矛伊□斥( 剽)毛菲户月 -*/ + avg = (double)PLAYER.answer / + CHAR_getWorkInt( meindex, CHAR_WORK_QUIZNUM) * 100; +#if 0 + sprintf(token,"{{{{{{{" + "\n\n你的正确解答率是 %d题中 %d 题 " + "\n正确比率 %d 亾" + "\n\n%s", + CHAR_getWorkInt( meindex, CHAR_WORK_QUIZNUM), + PLAYER.answer, + (int)avg, + buf2 + ); +#endif + + /*--皿伊奶乩□及伐□弁 毛赓渝祭 -*/ + CHAR_setWorkInt( meindex, CHAR_WORK_PLAYER1 + + CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANT) ,-1); + +// print("\n %s %d开放",CHAR_getChar(talker,CHAR_NAME),(int)PLAYER.ptr); + + /*--丢乒伉 钒 --*/ + free(PLAYER.ptr); + +#if 0 + /*-仇仇匹霜耨允月--*/ + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_QUIZ_START, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); +#endif + + //蝈化及蔽 质 互蔽歹匀化井日伐□皿今六月[ + if(warp_flg != -1){ + CHAR_warpToSpecificPoint(talker, floor, x, y); + } + return; + + } + + /*--仇及 卞涩烂今木化中月椭瘀及 锁 寞毛 五请允--*/ + tbl = NPC_GetQuestion( meindex); + + + /*-- 锁醒及民尼永弁 tbl[0]卞反椭瘀毛 凶仄凶 锁醒互反中匀化中月 --*/ + if( CHAR_getWorkInt( meindex, CHAR_WORK_QUIZNUM) > ( tbl[0] - 1)) + { + /*-- 锁互箫曰卅中--*/ + /*--丢乒伉 钒 --*/ + free(PLAYER.ptr); + return ; + } + + /*-- 锁毛 --*/ + while(1){ + loop++; + i = rand()%( tbl[0]); + if(i == 0) continue; + questionno = tbl[i]; + + /*--褐 民尼永弁--*/ + for( k = 0 ; k < OLDNO ; k++){ + if(PLAYER.oldno[k] == questionno) { + loop = 0; + break; + } + } + if(k == OLDNO) break; + + /*-- 蜃伙□皿 鞅--*/ + if(loop == 5000) { + print("问题不足i全部重覆了j"); + break; + } + } + + p_no = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANT); + p_old = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANTSEC); + + PLAYER.quizno++; + + /*-- 漆引匹及 锁 寞毛筏盛仄化云仁--*/ + PLAYER.oldno[p_old] = questionno; + p_old++; + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTSEC, p_old); + + strncpy( buf, Quiz[questionno].question, + sizeof( Quiz[questionno].question)); + + /*--弁奶术及 锁及赢今卞方匀化}蓟 及 憎匏 毛 尹月--*/ + if(strlen( buf) < 40) { + strcat( buf, "\n"); + }else if(strlen( buf) > 79) { + len = 5; + } + + /*--签贿穴永民--*/ + if( Quiz[questionno].answertype == 4) { + + if(strlen( buf) < 40) { + strcat( buf,"\n\n"); + }else if( strlen( buf) < 80) { + strcat( buf,"\n\n"); + }else{ + strcat( buf,"\n"); + } + + /*--踏五 锁--*/ + sprintf( token," quiz 第 %d 题" + "\n%s " + "\n↓写在这里\n" + " (写完请按OK)", + PLAYER.quizno, + buf); + + buttontype = WINDOW_BUTTONTYPE_OK; + messagetype = WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT; + windowno = CHAR_WINDOWTYPE_QUIZ_MAIN; + + /*--蜇箕及橇须毛丢乒伉卞筏盛今六化云仁--*/ + memcpy(pl_ptr,&PLAYER,sizeof(struct pl)); + + break; + + /*--{ㄢ 锁{--*/ + }else if( Quiz[questionno].answertype == 2) { + char work1[128]; + char work2[128]; + char work3[128]; + + ans = (rand() % 3) + 1; + + ans = NPC_QuizRandAnswer(p_no,questionno,3, work1,work2,work3); + PLAYER.ansno = ans; + + /*-- 弁奶术 (ㄢ --*/ + sprintf(token,"%d\n quiz 第 %d 题" + "\n%s " + "\n\n1. %s" + "\n2. %s" + "\n3. %s", + len, + PLAYER.quizno, + buf, + work1, + work2, + work3 + ); + + /*-- ㄡ 锁 --*/ + }else if( Quiz[questionno].answertype == 1){ + char work1[128]; + char work2[128]; + char work3[128]; + + strcpy(work3,"-1"); + ans = NPC_QuizRandAnswer(p_no,questionno,2, work1,work2,work3); + PLAYER.ansno = ans; + + /*-- 弁奶术 (ㄡ --*/ + sprintf(token,"%d\n quiz 第 %d 题" + "\n%s " + "\n\n1. %s" + "\n2. %s", + len, + PLAYER.quizno, + buf, + work1, + work2 + ); + } + buttontype = WINDOW_BUTTONTYPE_CANCEL; + messagetype = WINDOW_MESSAGETYPE_SELECT; + windowno = CHAR_WINDOWTYPE_QUIZ_MAIN; + + memcpy(pl_ptr,&PLAYER,sizeof(struct pl)); + + } + break; + + case 4: + /*-- arg白央奶伙及 心 心 --*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL) + { + print("GetArgstrErr:Quiz %s",CHAR_getChar( meindex, CHAR_NAME)); + } + + if(NPC_Util_GetStrFromStrWithDelim( argstr,"Party", + token, sizeof( token)) != NULL) + { + buttontype = WINDOW_BUTTONTYPE_OK; + messagetype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_QUIZ_START; + } + + break; + + } + + /*-仇仇匹霜耨允月--*/ + lssproto_WN_send( fd, messagetype, + buttontype, + windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); +} + +void NPC_QuizWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + int i=0; + int old_no; + + if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) { + return; + } + switch( seqno){ + case CHAR_WINDOWTYPE_QUIZ_START: + if( select == WINDOW_BUTTONTYPE_YES) { + NPC_Quiz_selectWindow(meindex, talkerindex, 1); + } + + if(select == WINDOW_BUTTONTYPE_OK){ + } + + break; + + case CHAR_WINDOWTYPE_QUIZ_MAIN: + { + int point; + int *pl_ptr; + int p_no; + struct pl PLAYER; + + p_no = CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT); + point = CHAR_getWorkInt( meindex, CHAR_WORK_PLAYER1 + p_no); + pl_ptr = (int *)point; + + + memcpy(&PLAYER,pl_ptr,sizeof(struct pl)); + + p_no = CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT); + old_no = CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANTSEC)-1; + i= PLAYER.oldno[old_no]; + + if(select == WINDOW_BUTTONTYPE_OK){ + if( i >= quizcnt || i < 0 ) return; + if( Quiz == NULL || strlen( Quiz[i].select1) >= 128 ) return; + + if( strstr( data, Quiz[i].select1) != NULL) { + PLAYER.answer++; + } + memcpy(pl_ptr,&PLAYER,sizeof(struct pl)); + NPC_Quiz_selectWindow(meindex, talkerindex, 2); + }else if(select == WINDOW_BUTTONTYPE_CANCEL){ + CHAR_setWorkInt( meindex, CHAR_WORK_PLAYER1 + + CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT) ,-1); + free(PLAYER.ptr); + }else if( atoi( data) == 0){ + }else{ + if(atoi(data) == PLAYER.ansno){ + PLAYER.answer++; + } + memcpy(pl_ptr,&PLAYER,sizeof(struct pl)); + NPC_Quiz_selectWindow(meindex, talkerindex, 2); + } + } + break; + + } + + +} + +/* + *示□母□仿奶件及民尼永弁 + */ +int NPC_QuizBorderLine(int ans ,char *buf) +{ + char buf2[32]; + int j = 1; + int border; + + + while(getStringFromIndexWithDelim(buf , "," , j, buf2, sizeof( buf2)) + !=FALSE ) + { + border = atoi(buf2); + + if(ans >= border) { + return j; + } + + j += 2; + + } + return -1; +} +/* + *示□母□仿奶件及民尼永弁 + */ +int NPC_QuizWarpBorderLine(int ans ,char *buf) +{ + char buf2[32]; + int j = 1; + int border; + + + while(getStringFromIndexWithDelim(buf , "," , j, buf2, sizeof( buf2)) + != FALSE ) + { + border = atoi(buf2); + + if(ans >= border) { + return j; + } + + j += 2; + + } + return -1; +} + + +/* + *--失奶 丞毛馨笛今六月 + */ +BOOL NPC_QuizAddItem(int talker,char *buf) +{ + int i=1; + int ret; + char buf2[16]; + int itemindex; + char token[512]; + + /*-- 醒操 午仄化失奶 丞互涩烂今木化中月桦宁反仿件母丞匹蓟少--*/ + while(getStringFromIndexWithDelim(buf , "." , i, buf2, sizeof(buf2)) + != FALSE ) + { + i++; + } + i--; + if(i == 1){ + getStringFromIndexWithDelim(buf , "." , i, buf2, sizeof(buf2)); + }else{ + /*--仿件母丞--*/ + i = (rand() % i)+1; + getStringFromIndexWithDelim(buf , "." , i, buf2, sizeof(buf2)); + } + + itemindex = ITEM_makeItemAndRegist(atoi(buf2)); + + if(itemindex == -1) return FALSE; + + /*失奶 丞及馨笛( 涛失奶 丞 卞中木化仄引丹 */ + ret = CHAR_addItemSpecificItemIndex( talker, itemindex); + if( !CHAR_CHECKITEMINDEX( talker, ret) ){ + print( "npc_quiz.c: additem error itemindex[%d]\n", itemindex); + ITEM_endExistItemsOne( itemindex); + + CHAR_talkToCli( talker, -1, "道具栏已满", CHAR_COLORWHITE); + + return FALSE; + } + + if(itemindex != -1) { + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), /* 失奶 丞 寞 */ +#endif + "QuizAddItem(猜谜->领到的道具)", + CHAR_getInt( talker, CHAR_FLOOR), + CHAR_getInt( talker, CHAR_X ), + CHAR_getInt( talker, CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + + sprintf(token,"拿到%s。", ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + + + CHAR_sendItemDataOne( talker, ret); + return TRUE; + +} + +int NPC_QuizRandAnswer(int p_no,int q_no, int mode, + char *work1,char *work2,char *work3) +{ + int ans; + int ra; + + ans = (rand() % mode) + 1; + if(ans == 1) { + if( Quiz[q_no].answerNo == 1) { + strcpy( work1, Quiz[q_no].select1); + if(mode == 2) { + strcpy( work2, Quiz[q_no].select2); + return ans; + } + ra = rand()%2; + + if(ra == 0) { + strcpy( work2, Quiz[q_no].select2); + strcpy( work3, Quiz[q_no].select3); + }else{ + strcpy( work2, Quiz[q_no].select3); + strcpy( work3, Quiz[q_no].select2); + } + }else if( Quiz[q_no].answerNo == 2) { + strcpy( work1, Quiz[q_no].select2); + if(mode == 2) { + strcpy( work2, Quiz[q_no].select1); + return ans; + } + + ra = rand()%2; + if(ra == 0) { + strcpy( work2, Quiz[q_no].select1); + strcpy( work3, Quiz[q_no].select3); + }else{ + strcpy( work2, Quiz[q_no].select3); + strcpy( work3, Quiz[q_no].select1); + } + }else{ + strcpy( work1, Quiz[q_no].select3); + ra = rand()%2; + if(ra == 0) { + strcpy( work2, Quiz[q_no].select1); + strcpy( work3, Quiz[q_no].select2); + }else{ + strcpy( work2, Quiz[q_no].select1); + strcpy( work3, Quiz[q_no].select2); + } + } + }else if(ans == 2) { + if(Quiz[q_no].answerNo == 1) { + strcpy( work2, Quiz[q_no].select1); + if(mode == 2) { + strcpy( work1, Quiz[q_no].select2); + return ans; + } + ra=rand()%2; + if(ra == 0) { + strcpy( work1, Quiz[q_no].select2); + strcpy( work3, Quiz[q_no].select3); + }else { + strcpy( work1, Quiz[q_no].select3); + strcpy( work3, Quiz[q_no].select2); + } + }else if( Quiz[q_no].answerNo == 2) { + strcpy( work2, Quiz[q_no].select2); + if(mode == 2){ + strcpy( work1, Quiz[q_no].select1); + return ans; + } + ra = rand()%2; + if(ra == 0) { + strcpy( work1, Quiz[q_no].select1); + strcpy( work3, Quiz[q_no].select3); + }else { + strcpy( work1, Quiz[q_no].select3); + strcpy( work3, Quiz[q_no].select1); + } + }else { + strcpy( work2, Quiz[q_no].select3); + ra = rand()%2; + if(ra == 0) { + strcpy( work1, Quiz[q_no].select1); + strcpy( work3, Quiz[q_no].select2); + }else { + strcpy( work1, Quiz[q_no].select2); + strcpy( work3, Quiz[q_no].select1); + } + } + }else if(ans == 3) { + if( Quiz[q_no].answerNo == 1) { + strcpy( work3, Quiz[q_no].select1); + ra = rand()%2; + if(ra == 0) { + strcpy( work1, Quiz[q_no].select2); + strcpy( work2, Quiz[q_no].select3); + }else { + strcpy( work1, Quiz[q_no].select3); + strcpy( work2, Quiz[q_no].select2); + } + }else if( Quiz[q_no].answerNo == 2) { + strcpy( work3, Quiz[q_no].select2); + ra = rand()%2; + if(ra == 0) { + strcpy( work1, Quiz[q_no].select1); + strcpy( work2, Quiz[q_no].select3); + }else { + strcpy( work1, Quiz[q_no].select3); + strcpy( work2, Quiz[q_no].select1); + } + }else{ + strcpy( work3, Quiz[q_no].select3); + ra = rand()%2; + if(ra == 0) { + strcpy( work1, Quiz[q_no].select1); + strcpy( work2, Quiz[q_no].select2); + }else { + strcpy( work1, Quiz[q_no].select2); + strcpy( work2, Quiz[q_no].select1); + } + } + } + return ans; + +} + + +/*--皿伊奶乩□及民尼永弁 ㄧ谛引匹 --*/ +BOOL NPC_PlayerCheck(int meindex,int talker) + { + int i; + int k=0; + int *ptr; + struct pl Player; + + + NPC_RealyCheack( meindex, talker); + + /*-- 坞五互丐月井" --*/ + for(i = 0 ; i < MEPLAYER ; i++){ + if( (CHAR_getWorkInt( meindex, CHAR_WORK_PLAYER1 +i ) == -1)) + { + break; + } + } + + if(i == MEPLAYER) return FALSE; + + + /*-- 丢乒伉割忡 --*/ + if((ptr =(int *) calloc( 1,sizeof(struct pl))) == NULL){ + print("记忆体无法确保%s",CHAR_getChar(meindex,CHAR_NAME)); + return FALSE; + } + + /*-- 禾奶件正及桦赭毛创尹化云仁??-*/ + Player.ptr = ptr; + Player.talkerindex = talker; //npc及奶件犯永弁旦??? + Player.quizno = 0; //蜇箕及 锁醒 + Player.answer = 0; //恳荸醒 + Player.ansno = 0; //蚕尹及 寞毛创尹化云仁 蚕尹毛田仿田仿卞请仄凶端卞银迕) + + /*--请锁碧心 锁 及赓渝祭--*/ + for(k=0 ; k < OLDNO; k++) { + Player.oldno[k] = -1; + } + + /*--丢乒伉毛戊疋□--*/ + memcpy(ptr,&Player,sizeof(struct pl)); + + + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTSEC,0); + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANT,0); + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTTRD,0); + + + /*--愤坌及荸蚕樊 寞毛创尹化云仁--*/ + CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANT, i); + + k= (int)ptr; + CHAR_setWorkInt( meindex, CHAR_WORK_PLAYER1 + i, k ); + return TRUE; + +} + +int NPC_RealyCheack(int meindex,int talker) +{ + int fl, x, y; + int i, j; + int px[10] = {0, 1, 0,-1, 1,-1, 1, 0,-1}; + int py[10] = {0,-1,-1,-1, 0, 0, 1, 1, 1}; + int objindex; + + OBJECT object; + int talkerindex; + BOOL okflg = FALSE; + struct pl PLAYER; + int *pl_ptr; + int point; + + fl = CHAR_getInt( meindex, CHAR_FLOOR); + + for(j = 0 ; j < MEPLAYER ; j++) { + point = CHAR_getWorkInt( meindex, CHAR_WORK_PLAYER1 + j); + okflg = FALSE; + if(point == -1) continue; + + /*--荸蚕樊 寞毛 月--*/ + pl_ptr = (int *)point; + + memcpy(&PLAYER, pl_ptr, sizeof(struct pl)); + talkerindex = PLAYER.talkerindex; + + for(i=0 ; i < 10 ; i++) { + x = px[i] + CHAR_getInt( meindex, CHAR_X); + y = py[i] + CHAR_getInt( meindex, CHAR_Y); + + for(object = MAP_getTopObj(fl,x,y) ; object; + object = NEXT_OBJECT( object)) + { + objindex = GET_OBJINDEX( object); + + if( OBJECT_getType( objindex) == OBJTYPE_CHARA ){ + if( OBJECT_getIndex( objindex) == talkerindex) { + if(talkerindex == talker) { + okflg = TRUE; +// print("\n %s %d开放",CHAR_getChar(talker,CHAR_NAME),(int)PLAYER.ptr); + free(PLAYER.ptr); + CHAR_setWorkInt( meindex, CHAR_WORK_PLAYER1 + j,-1); + }else{ + okflg = TRUE; + } + break; + } + } + } + if(okflg == TRUE) break; + } + + if(okflg ==FALSE){ +// print("\n %s %d开放",CHAR_getChar(talker,CHAR_NAME),(int)PLAYER.ptr); + free(PLAYER.ptr); + CHAR_setWorkInt( meindex, CHAR_WORK_PLAYER1 + j,-1); + } + + } + + return -1; +} + +BOOL QUIZ_initQuiz( char *filename) +{ + + FILE* f; + char line[512]; + char buf2[512], buf3[128]; + char buf[512]; + int i, linenum=0; + f = fopen(filename,"r"); + if( f == NULL ){ + print( "file open error\n"); + return FALSE; + } + while( fgets( line, sizeof( line ), f ) ){ + if( line[0] == '#' )continue; + if( line[0] == '\n' )continue; + chomp( line ); + linenum ++; + quizcnt++; + } + + if( fseek( f, 0, SEEK_SET ) == -1 ){ + fprint( "Seek Error\n" ); + fclose(f); + return FALSE; + } + + Quiz = allocateMemory( sizeof(NPC_QUIZ) * (quizcnt+1) ); + if( Quiz == NULL ){ + fprint( "Can't allocate Memory %d\n", sizeof(Quiz) * (quizcnt+1)); + fclose( f ); + return FALSE; + } + linenum = 0; + memset( buf3, 0, sizeof(buf3)); + while( fgets( line, sizeof( line ), f ) ){ + if( line[0] == '#' )continue; + if( line[0] == '\n' )continue; + chomp( line ); + replaceString( line, '\t' , ' ' ); + for( i = 0; i < strlen( line); i ++) { + if( line[i] != ' ' ) { + break; + } + strcpy( buf, &line[i]); + } + if( i != 0 ) { + strcpy( line, buf); + } + + if( getStringFromIndexWithDelim( line, ",", 1, buf2, sizeof(buf2)) == FALSE ) continue; + Quiz[linenum].no = atoi(buf2); + + if( getStringFromIndexWithDelim( line, ",", 2, buf2, sizeof(buf2)) == FALSE ) continue; + Quiz[linenum].type = atoi(buf2); + + if( getStringFromIndexWithDelim( line, ",", 3, buf2, sizeof(buf2)) == FALSE ) continue; + Quiz[linenum].level = atoi(buf2); + + if( getStringFromIndexWithDelim( line, ",", 4, buf2, sizeof(buf2)) == FALSE ) continue; + Quiz[linenum].answertype = atoi(buf2); + + if( getStringFromIndexWithDelim( line, ",", 5, buf2, sizeof(buf2)) == FALSE ) continue; + Quiz[linenum].answerNo = atoi(buf2); + + if( getStringFromIndexWithDelim( line, ",", 6, buf2, sizeof(buf2)) == FALSE ) continue; + memcpy( Quiz[linenum].question, buf2, sizeof( Quiz[linenum].question)); + + + if( getStringFromIndexWithDelim( line, ",", 7, buf3, sizeof(buf3)) == FALSE ) continue; + memcpy( Quiz[linenum].select1, buf3, sizeof( Quiz[linenum].select1)); + if( getStringFromIndexWithDelim( line, ",", 8, buf3, sizeof(buf3)) == FALSE ) continue; + memcpy( Quiz[linenum].select2, buf3, sizeof( Quiz[linenum].select2)); + if( getStringFromIndexWithDelim( line, ",", 9, buf3, sizeof(buf3)) == FALSE ) continue; + memcpy( Quiz[linenum].select3, buf3, sizeof( Quiz[linenum].select3)); + + if(Quiz[linenum].answertype == 1){ + if(Quiz[linenum].answerNo == 3){ + return FALSE; + } + } + + if(Quiz[linenum].answertype == 4){ + if(Quiz[linenum].answerNo != 1){ + return FALSE; + } + } + linenum ++; +// quizcnt++; + } + if( quizcnt < linenum ){ + print("ERR linenum:%d >= quizcnt:%d\n", linenum, quizcnt); + return FALSE; + } + + quizcnt = linenum; + fclose( f); + return TRUE; + +} + +int *NPC_GetQuestion(int meindex) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + int i,j; + int type=0; + int answer=0; + int level=0; + int *tbl; + char buf[16]; +#ifdef _NPC_QUIZSCOPE + int scope0,scope1; + char buf3[32]; +#endif + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + if(NPC_Util_GetStrFromStrWithDelim(argstr,"Type",buf, sizeof( buf)) != NULL ){ + type = atoi(buf); + } + if( type <= 0){ + type = 0xffff; + } + + if(NPC_Util_GetStrFromStrWithDelim( argstr, "Answer", buf, sizeof( buf)) != NULL){ + answer = atoi(buf); + } + if(answer <= 0){ + answer = 0xffff; + } + + if(NPC_Util_GetStrFromStrWithDelim( argstr, "Level", buf, sizeof( buf)) != NULL ){ + level = atoi(buf); + } + if(level <= 0){ + level = 0xffff; + } + +#ifdef _NPC_QUIZSCOPE + scope0 = 0; + scope1 = quizcnt; + if(NPC_Util_GetStrFromStrWithDelim( argstr, "Scope", buf, sizeof( buf)) != NULL ){ + getStringFromIndexWithDelim( buf, "-", 1, buf3, sizeof(buf3)); + scope0 = atoi( buf3 ); + getStringFromIndexWithDelim( buf, "-", 2, buf3, sizeof(buf3)); + scope1 = atoi( buf3 ); + } +#endif + + for(j=0,i=0; i < quizcnt ;i++){ + if( (type & (1 << (Quiz[i].type-1))) != (1 << (Quiz[i].type-1))){ + continue; + } + if((answer & (Quiz[i].answertype)) != Quiz[i].answertype){ + continue; + } + if((level & (Quiz[i].level)) != Quiz[i].level){ + continue; + } +#ifdef _NPC_QUIZSCOPE + if( i < scope0 + || i > scope1 ) + continue; +#endif + j++; + } + + { + int tmp_tbl[j+1]; + tmp_tbl[0] = j+1; + for(j=1,i=0; i < quizcnt ;i++){ + if( (type & (1 << (Quiz[i].type-1))) != (1 << (Quiz[i].type-1))){ + continue; + } + + if((answer & (Quiz[i].answertype)) != Quiz[i].answertype){ + continue; + } + + if((level & (Quiz[i].level)) != Quiz[i].level){ + continue; + } +#ifdef _NPC_QUIZSCOPE + if( i < scope0 + || i > scope1 ) + continue; +#endif + tmp_tbl[j] = i; + + j++; + } + + tbl = tmp_tbl; + return tbl; + } +} + +/*--失奶 丞 及坞五及民尼永弁--*/ +BOOL NPC_QuizItemFullCheck(int meindex,int talker) +{ + int i; + int itemindex; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf2[32]; + + + /*--民尼永弁 癫卞蝈 月井"-*/ + for( i = CHAR_STARTITEMARRAY ; i < CHAR_MAXITEMHAVE ; i++ ) { + itemindex = CHAR_getItemIndex( talker , i ); + if( !ITEM_CHECKINDEX( itemindex) ) { + return TRUE; + } + } + + /*-- arg白央奶伙及 心 心 --*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL) + { + print("GetArgstrErr:Quiz %s",CHAR_getChar( meindex, CHAR_NAME)); + } + + /*-- 失奶 丞及民尼永弁 --*/ + if(NPC_Util_GetStrFromStrWithDelim( argstr,"EntryItem", + buf2, sizeof( buf2)) != NULL) + { + if(NPC_EntryItemCheck( talker, buf2) == FALSE){ + NPC_Quiz_selectWindow( meindex, talker, 3); + return FALSE; + + }else{ + return TRUE; + } + } + + + return FALSE; + +} + + +/* + *云嗯及民尼永弁 + */ +BOOL NPC_EntryStoneCheck(int talker,char *buf) +{ + int stone; + int cost; + + cost= atoi( buf); + stone = CHAR_getInt( talker, CHAR_GOLD); + + if(cost > stone){ + return FALSE; + } + + return TRUE; +} + +/* + *云嗯及绰轮 + */ +BOOL NPC_EntryStoneDel(int talker,char *buf) +{ + int stone; + int cost; + char token[256]; + + cost= atoi( buf); + stone = CHAR_getInt( talker, CHAR_GOLD); + + if((stone-cost) < 0){ + CHAR_setInt( talker, CHAR_GOLD, 0); + }else{ + CHAR_DelGold( talker, cost ); + } + + sprintf( token, "%d 交出stone。", cost); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + + CHAR_send_P_StatusString( talker, CHAR_P_STRING_GOLD); + return TRUE; +} + + +/* + *失奶 丞毛绰轮允月 + */ +BOOL NPC_EntryItemDel(int talker,char *buf) +{ + + int i = 1, j = 1,k = 1; + char buff3[128]; + char buf2[32]; + int itemindex; + + + while(getStringFromIndexWithDelim(buf , "," , k, buff3, sizeof(buff3)) !=FALSE ){ + k++; + if(strstr(buff3, "*") !=NULL){ + int itemno; + int kosuu; + int id; + int cnt=0; + getStringFromIndexWithDelim(buff3,"*",1,buf2,sizeof(buf2)); + itemno = atoi(buf2); + getStringFromIndexWithDelim(buff3,"*",2,buf2,sizeof(buf2)); + kosuu = atoi(buf2); + for( i =0 ; i < CHAR_MAXITEMHAVE ; i++ ){ + itemindex = CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX(itemindex) ){ + id=ITEM_getInt(itemindex ,ITEM_ID ); + if(itemno==id){ + cnt++; + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), /* 失奶 丞 寞 */ +#endif + "QuizDelItem(猜谜->交出的道具)", + CHAR_getInt( talker, CHAR_FLOOR), + CHAR_getInt( talker, CHAR_X ), + CHAR_getInt( talker, CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + + CHAR_DelItem( talker, i); + if(cnt == kosuu){ + break; + } + } + } + } + }else{ + /*--蓟氏分 寞及失奶 丞毛蓟请---*/ + for( j = 0 ; j < CHAR_MAXITEMHAVE ; j++){ + itemindex = CHAR_getItemIndex( talker ,j); + + if( ITEM_CHECKINDEX(itemindex) ){ + if( atoi( buff3) == ITEM_getInt(itemindex,ITEM_ID)){ + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), /* 失奶 丞 寞 */ +#endif + "QuizDelItem(猜谜->领到的道具)", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + CHAR_DelItem( talker, j); + } + } + } + } + } + + return TRUE; +} + +/* + *--失奶 丞及民尼永弁分仃毛垫丹 + */ +BOOL NPC_EntryItemCheck(int talker,char *buf) +{ + + char buf2[512]; + char buf3[256]; + int id=0; + BOOL flg = FALSE; + int i; + int itemindex; + int itemno; + int kosuu; + int cnt=0; + int k=1; + + while(getStringFromIndexWithDelim(buf , "," , k, buf2, sizeof(buf2)) + !=FALSE ) + { + flg = FALSE; + k++; + + if(strstr(buf2,"*") != NULL){ + cnt = 0; + getStringFromIndexWithDelim(buf2,"*",1,buf3,sizeof(buf3)); + itemno = atoi(buf3); + getStringFromIndexWithDelim(buf2,"*",2,buf3,sizeof(buf3)); + kosuu = atoi(buf3); + + for( i=0 ; i < CHAR_MAXITEMHAVE;i++ ){ + itemindex = CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX(itemindex) ){ + id = ITEM_getInt(itemindex ,ITEM_ID ); + if(itemno == id){ + cnt++; + if(cnt == kosuu){ + flg = TRUE; + break; + } + } + } + } + if(flg == FALSE) + { + return FALSE; + } + }else{ + itemno = atoi(buf2); + + for( i=0 ; i < CHAR_MAXITEMHAVE;i++ ){ + itemindex = CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX(itemindex) ){ + id = ITEM_getInt(itemindex ,ITEM_ID ); + if(itemno == id){ + flg = TRUE; + break; + } + } + } + + if(flg == FALSE) + { + return FALSE; + } + } + } + + return TRUE; + +} + +/* + * 由□ 奴井升丹井及民尼永弁 + */ +BOOL NPC_QUIZPARTY_CHAECK(int meindex,int talker) +{ + + if(CHAR_getWorkInt(talker,CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE){ + return FALSE; + } + + return TRUE; + +} + diff --git a/gmsv/npc/npc_raceman.c b/gmsv/npc/npc_raceman.c new file mode 100644 index 0000000..86f021f --- /dev/null +++ b/gmsv/npc/npc_raceman.c @@ -0,0 +1,2255 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "npcutil.h" +#include "handletime.h" +#include "npc_raceman.h" +#include "family.h" +#include "log.h" +#include "enemy.h" + +#ifdef _RACEMAN + +void Raceman_SelectWindow( int meindex, int talker, int num,int select); +void Raceman_MsgDisp(int meindex,int talker,int num,int select); +BOOL Raceman_EventAddItem( int meindex,int talker ); +BOOL Raceman_CheckItem(int meindex,int talker); +BOOL Raceman_ItemFullCheck(int meindex, int talker); +BOOL Raceman_checkpet( int meindex, int talker , int select , char *token ); +BOOL Raceman_petcheckin ( int meindex , int talker ); //限定种类 +BOOL Raceman_checkprize( int meindex , int talker ,char *token); +void Raceman_awardprize( int meindex , int talker ); +int Raceman_CheckGameType(int meindex , int talker ); +int Raceman_readmode( int meindex , int talkerindex ); +void Raceman_countrank( int meindex, int talker ); // 目前没用到 +void Raceman_renewrank( int meindex , int talker , int select ); +int Raceman_CheckSelectRank( int meindex , int talkerindex , int datanum); +void Raceman_GetQuestion( int meindex ,int talker , char *token); +BOOL Raceman_CheckAnswer( int meindex , int talker , char *data ); + + + +enum { + CHAR_WORK_PETSELECT = CHAR_NPCWORKINT1, + CHAR_WORK_RACEQUIZ = CHAR_NPCWORKINT2, +}; + +//int PetSelect; +int Pageindex; +int asktotal; + +struct RANKTABLE ranktable1[DEFMAXRANK]; +struct RANKTABLE ranktable2[DEFMAXRANK]; +struct RANKTABLE ranktable3[DEFMAXRANK]; +struct RANKTABLE ranktable4[DEFMAXRANK]; +struct RANKTABLE ranktable5[DEFMAXRANK]; +struct RANKTABLE history1[DEFMAXRANK]; +struct RANKTABLE history2[DEFMAXRANK]; +struct RANKTABLE history3[DEFMAXRANK]; +struct RANKTABLE history4[DEFMAXRANK]; +struct RANKTABLE history5[DEFMAXRANK]; + +struct ASKTABLE asktable[400]; + +int petflgtable[640]; //可抓宠的table + +char rankname[5][64] = { + "『新手赛--惊为天人排行榜』", + "『高手赛--惊为天人排行榜』", + "『家族赛--惊为天人排行榜』", + "『高手赛--无奇不有排行榜』", + "『家族赛--无奇不有排行榜』" +}; + +char historyrank[5][64] = { + "『新手历史惊为天人排行榜』", + "『高手历史惊为天人排行榜』", + "『家族历史惊为天人排行榜』", + "『高手历史无奇不有排行榜』", + "『家族历史无奇不有排行榜』" +}; + + +#define DEF_READ_WAITTIME (10) +unsigned long RTIME1 = 0, + RTIME2 = 0, + RTIME3 = 0, + RTIME4 = 0, + RTIME5 = 0; + +BOOL NPC_RacemanInit( int meindex) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf1[128]; + int ranknum,i; + char file[10][20] = { + "Mode1", + "Mode2", + "Mode3", + "Mode4", + "Mode5", + "History1", + "History2", + "History3", + "History4", + "History5" + }; + + //PetSelect = 0; + Pageindex = 0; + + if( NPC_Util_GetArgStr( meindex, npcarg, sizeof( npcarg)) == NULL) return FALSE; + + NPC_Util_GetStrFromStrWithDelim( npcarg , "RankNum", buf1, sizeof( buf1)); + ranknum = atoi(buf1); + + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_RACEMAN); //制作一只npc + + if( RTIME1 == 0 || RTIME2 == 0 || RTIME3 == 0 || RTIME4 == 0 || RTIME5 == 0){ + RTIME1 = NowTime.tv_sec+DEF_READ_WAITTIME, + RTIME2 = NowTime.tv_sec+DEF_READ_WAITTIME, + RTIME3 = NowTime.tv_sec+DEF_READ_WAITTIME, + RTIME4 = NowTime.tv_sec+DEF_READ_WAITTIME; + RTIME5 = NowTime.tv_sec+DEF_READ_WAITTIME; + + //把5种比赛记录读取进来 + for( i = 0 ; i < 10 ; i++){ + NPC_Util_GetStrFromStrWithDelim( npcarg , file[i] , buf1, sizeof( buf1)); + if(strlen(buf1) == 0) continue; + if(i < 5) + saacproto_ACRaceRecordandSort_send( acfd,meindex,buf1,"","",i+1,0,ranknum ); + else + saacproto_ACRaceRecordandSort_send( acfd,meindex,buf1,"","",i+6,0,ranknum ); + } + + } + return TRUE; + +} + +void NPC_RacemanTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + + if(NPC_Util_isFaceToFace(talkerindex,meindex,1 )==FALSE){ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) return; + } + + Raceman_SelectWindow( meindex, talkerindex,0,-1); +} + + +void Raceman_SelectWindow( int meindex, int talker, int num,int select) +{ + char token[1024]; + int fd , ret; + + fd = getfdFromCharaIndex( talker ); + if( fd == -1 ) return; + + token[0] = '\0'; + + switch( num) { + + case 0: //选单 + + Raceman_MsgDisp( meindex, talker, 0 , -1 ); + break; + + case 1: //比赛题目 + + Raceman_MsgDisp( meindex, talker, 1 , -1 ); + break; + + case 2: //领猎宠证 + + ret = Raceman_CheckGameType(meindex,talker); + if(ret == 0) + Raceman_MsgDisp( meindex, talker, 2 , -1 ); + else if(ret == 1) + Raceman_MsgDisp( meindex, talker, 9 , -1 ); + else if(ret == 2) + Raceman_MsgDisp( meindex, talker, 90 , -1 ); + else if(ret == 3) + Raceman_MsgDisp( meindex, talker, 91 , -1 ); + else if(ret == 4) + Raceman_MsgDisp( meindex, talker, 92 , -1 ); + break; + + case 3: //猎宠登记 + + ret = Raceman_CheckGameType(meindex,talker); + if(ret == 1) + Raceman_MsgDisp( meindex, talker, 9 , -1 ); //族长身分不合 + else if(ret == 4) + Raceman_MsgDisp( meindex, talker, 92 , -1 ); //家族没有正式成立 + else + Raceman_MsgDisp( meindex, talker, 3 , -1 ); + break; + + case 4: //猎宠排行榜 + + Raceman_MsgDisp( meindex, talker, 4 , -1 ); + break; + + case 5: //猎宠战利品 + + ret = Raceman_CheckGameType(meindex,talker); + if(ret == 1) + Raceman_MsgDisp( meindex, talker, 9 , -1 ); //族长身分不合 + else if(ret == 4) + Raceman_MsgDisp( meindex, talker, 92 , -1 ); //家族没有正式成立 + else + Raceman_MsgDisp( meindex, talker, 5 , -1 ); + break; + + case 6: //通关密语 + + ret = Raceman_CheckGameType(meindex,talker); + if(ret == 1) + Raceman_MsgDisp( meindex, talker, 9 , -1 ); //族长身分不合 + else if(ret == 4) + Raceman_MsgDisp( meindex, talker, 92 , -1 ); //家族没有正式成立 + else + Raceman_MsgDisp( meindex, talker, 6 , -1 ); + break; + + } +} + +void NPC_RacemanWindowTalked( int meindex , int talkerindex , int seqno, int select, char *data) +{ + int datanum = -1; + int buttontype; + int i,open,ret ; + char listbuf[4096],tmp_buffer[4096]; + + listbuf[0] = '\0'; + tmp_buffer[0] = '\0'; + + if( NPC_Util_CharDistance( talkerindex, meindex ) > 2) { + return; + } + print("\n NPC_RacemanWindowTalked: data:%s seq:%d sel:%d ", data, seqno, select); + + makeStringFromEscaped( data); + + datanum = atoi( data); + switch( seqno){ + case CHAR_WINDOWTYPE_RACE_START: + if(datanum == 2){ // 比赛题目 + Raceman_SelectWindow( meindex, talkerindex,1,-1); + }else if(datanum == 3){ // 领取猎宠证 + Raceman_SelectWindow( meindex, talkerindex,2,-1); + }else if(datanum == 4){ // 猎宠登记处 + //Raceman_SelectWindow( meindex, talkerindex,3,-1);修改 加入通关密语才能登记 + Raceman_SelectWindow( meindex, talkerindex,6,-1); + }else if(datanum == 5){ // 猎宠排行榜 + Raceman_SelectWindow( meindex, talkerindex,4,-1); + }else if(datanum == 6){ // 猎宠战利品 + Raceman_SelectWindow( meindex, talkerindex,5,-1); + } + break; + case CHAR_WINDOWTYPE_RACE_SUBJECT: + if(select == WINDOW_BUTTONTYPE_OK){ + Raceman_SelectWindow( meindex, talkerindex,0,-1); + } + break; + case CHAR_WINDOWTYPE_RACE_TICKET: + if(select == WINDOW_BUTTONTYPE_OK) + { + if(Raceman_CheckItem(meindex,talkerindex)==TRUE){ //TRUE:有证了 + Raceman_MsgDisp( meindex, talkerindex,22,-1); + }else{ + if(Raceman_EventAddItem(meindex, talkerindex)==TRUE){ + Raceman_SelectWindow( meindex, talkerindex,0,-1); + } + } + } + break; + case CHAR_WINDOWTYPE_RACE_PETSELECT: + if(Raceman_CheckItem(meindex,talkerindex)==FALSE){ //FALSE:没有证 + Raceman_MsgDisp( meindex, talkerindex,32,-1); + }else{ + if(select == WINDOW_BUTTONTYPE_CANCEL){ + Raceman_SelectWindow( meindex, talkerindex,0,-1); + }else{ + Raceman_MsgDisp( meindex, talkerindex,31,datanum); + } + } + break; + case CHAR_WINDOWTYPE_RACE_CHECKIN: + if(select == WINDOW_BUTTONTYPE_YES){ + ret = Raceman_petcheckin( meindex, talkerindex ); //登记 + if(ret == TRUE) + Raceman_SelectWindow( meindex, talkerindex,0,-1); + else + Raceman_MsgDisp( meindex, talkerindex,93,-1); + }else if(select == WINDOW_BUTTONTYPE_NO){ + Raceman_SelectWindow( meindex, talkerindex,0,-1); + } + break; + case CHAR_WINDOWTYPE_RACE_RANK: + open = Raceman_CheckSelectRank(meindex,talkerindex,datanum); + switch(open) + { + case 1: + if( NowTime.tv_sec > RTIME1 ){ + Raceman_renewrank( meindex , talkerindex , datanum-1 ); //更新 + RTIME1 = NowTime.tv_sec+DEF_READ_WAITTIME; + } + if(ranktable1[0].rank == 0) Raceman_MsgDisp( meindex, talkerindex,46,-1); + else Raceman_MsgDisp( meindex, talkerindex,41,-1); + break; + case 2: + if( NowTime.tv_sec > RTIME2 ){ + Raceman_renewrank( meindex , talkerindex , datanum-1 ); //更新 + RTIME2 = NowTime.tv_sec+DEF_READ_WAITTIME; + } + if(ranktable2[0].rank == 0) Raceman_MsgDisp( meindex, talkerindex,46,-1); + else Raceman_MsgDisp( meindex, talkerindex,42,-1); + break; + case 3: + if( NowTime.tv_sec > RTIME3 ){ + Raceman_renewrank( meindex , talkerindex , datanum-1 ); //更新 + RTIME3 = NowTime.tv_sec+DEF_READ_WAITTIME; + } + if(ranktable3[0].rank == 0) Raceman_MsgDisp( meindex, talkerindex,46,-1); + else Raceman_MsgDisp( meindex, talkerindex,43,-1); + break; + case 4: + if( NowTime.tv_sec > RTIME4 ){ + Raceman_renewrank( meindex , talkerindex , datanum-1 ); //更新 + RTIME4 = NowTime.tv_sec+DEF_READ_WAITTIME; + } + if(ranktable4[0].rank == 0) Raceman_MsgDisp( meindex, talkerindex,46,-1); + else Raceman_MsgDisp( meindex, talkerindex,44,-1); + break; + case 5: + if( NowTime.tv_sec > RTIME5 ){ + Raceman_renewrank( meindex , talkerindex , datanum-1 ); //更新 + RTIME5 = NowTime.tv_sec+DEF_READ_WAITTIME; + } + if(ranktable5[0].rank == 0) Raceman_MsgDisp( meindex, talkerindex,46,-1); + else Raceman_MsgDisp( meindex, talkerindex,45,-1); + break; + case 11: + if(history1[0].rank == 0) Raceman_MsgDisp( meindex, talkerindex,46,-1); + else Raceman_MsgDisp( meindex, talkerindex,411,-1); + break; + case 12: + if(history2[0].rank == 0) Raceman_MsgDisp( meindex, talkerindex,46,-1); + else Raceman_MsgDisp( meindex, talkerindex,412,-1); + break; + case 13: + if(history3[0].rank == 0) Raceman_MsgDisp( meindex, talkerindex,46,-1); + else Raceman_MsgDisp( meindex, talkerindex,413,-1); + break; + case 14: + if(history4[0].rank == 0) Raceman_MsgDisp( meindex, talkerindex,46,-1); + else Raceman_MsgDisp( meindex, talkerindex,414,-1); + break; + case 15: + if(history5[0].rank == 0) Raceman_MsgDisp( meindex, talkerindex,46,-1); + else Raceman_MsgDisp( meindex, talkerindex,415,-1); + break; + default: + Raceman_SelectWindow( meindex, talkerindex,0,-1); + break; + } + break; + case CHAR_WINDOWTYPE_RACE_PRIZE: + if(select == WINDOW_BUTTONTYPE_OK){ + Raceman_awardprize( meindex, talkerindex ); + Raceman_SelectWindow( meindex, talkerindex,0,-1); + } + break; + case CHAR_WINDOWTYPE_RACE_NORMAL: + if(select == WINDOW_BUTTONTYPE_OK){ + Raceman_SelectWindow( meindex, talkerindex,0,-1); + } + break; + case CHAR_WINDOWTYPE_RACE_SHOWRANK1: + switch(select){ + case WINDOW_BUTTONTYPE_NEXT: + case WINDOW_BUTTONTYPE_PREV: + { + int fd; + fd = getfdFromCharaIndex( talkerindex ); + if( fd == -1 ) return; + + Pageindex += 10 * (( select == WINDOW_BUTTONTYPE_NEXT) ? 1 : -1); + + if(ranktable1[Pageindex].catchcnt==0) { + Raceman_SelectWindow( meindex, talkerindex,0,-1); + return; + } + if( Pageindex < 0 ) return; + + buttontype = WINDOW_BUTTONTYPE_OK; + if( ranktable1[Pageindex+10].catchcnt==0) + buttontype |= WINDOW_BUTTONTYPE_PREV; + else if( Pageindex == 0) + buttontype |= WINDOW_BUTTONTYPE_NEXT; + else{ + buttontype |= WINDOW_BUTTONTYPE_PREV; + buttontype |= WINDOW_BUTTONTYPE_NEXT; + } + //收集资料 + strcpy(listbuf,"『新手惊为天人排行榜』 "); + for (i=Pageindex;i atoi(buf) ) + return 2; + + NPC_Util_GetStrFromStrWithDelim( argstr, "FornewTran", buf, sizeof( buf) ); + //sprintf(buuf,"fornewTran:%s talkerLV:%d", buf , CHAR_getInt( talker , CHAR_TRANSMIGRATION) ); + //CHAR_talkToCli( talker, -1,buuf, CHAR_COLORYELLOW); + if(CHAR_getInt( talker , CHAR_TRANSMIGRATION) > atoi(buf) ) + return 3; + } + return 0; +} +//检查有无猎宠证 +BOOL Raceman_CheckItem(int meindex,int talker) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + int item,i,itemindex,id; + char buf[128]; + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { //读参数 + print("MsgDisp:GetArgStrErr"); + print("NPCName=%s\n", CHAR_getChar( meindex, CHAR_NAME)); + return FALSE; + } + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "CheckItem", + buf, sizeof( buf) ) != NULL) + { + item = atoi(buf); + for( i = 0 ; i < CHAR_MAXITEMHAVE ; i++ ) { + + itemindex=CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX( itemindex) ) { + id=ITEM_getInt( itemindex ,ITEM_ID ); + if(id==item) return TRUE; + } + } + } + return FALSE; +} + +BOOL Raceman_ItemFullCheck(int meindex, int talker) +{ + int emptyitemindexinchara; + + emptyitemindexinchara = CHAR_findEmptyItemBox( talker ); + + if( emptyitemindexinchara < 0 ){ + return FALSE; + } + + return TRUE; +} + +//发放猎宠证 +BOOL Raceman_EventAddItem( int meindex,int talker ) +{ + int itemindex,ret,i,fd; + char token[256],buf[128],buf1[256]; + char id[16],name[64]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + int gmode; + unsigned int askno,asklv,temp=0; + + if(Raceman_ItemFullCheck( meindex, talker) == FALSE){ + Raceman_MsgDisp( meindex, talker, 21,-1); + return FALSE; + } + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { //读参数 + print("MsgDisp:GetArgStrErr"); + print("NPCName=%s\n", CHAR_getChar( meindex, CHAR_NAME)); + return FALSE; + } + + if( NPC_Util_GetStrFromStrWithDelim( argstr , "GetItem", buf, sizeof( buf)) == NULL ){ + print("raceman: GetItem Err"); + return FALSE; + } + + itemindex = ITEM_makeItemAndRegist( atoi( buf )); + if(itemindex == -1){ + print("raceman: itemindex Err"); + return FALSE; + } + + ret = CHAR_addItemSpecificItemIndex( talker, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + print( "npc_raceman.c: ACCEPTadditem error itemindex[%d]\n", itemindex); + ITEM_endExistItemsOne( itemindex); + return FALSE; + } + + NPC_Util_GetStrFromStrWithDelim( argstr , "GameMode", buf1, sizeof( buf1)); + gmode = atoi(buf1); + + if( CHAR_getInt( talker, CHAR_CATCHCNT1+gmode-1 )!=0){ + + for(i=0;i<10;i++) CHAR_setInt( talker, CHAR_KINDCNT1 + i , 0 ); + CHAR_setInt( talker,CHAR_CATCHCNT1+gmode-1, 0 ); //清除记录 + + if(gmode==3||gmode==5){ //家族赛 + strcpy(name,CHAR_getChar(talker,CHAR_FMNAME)); //家族名称 + sprintf(id,"%d",CHAR_getWorkInt(talker, CHAR_WORKFMINDEXI)); //家族id + }else{ //个人赛 + fd = getfdFromCharaIndex(talker); + CONNECT_getCharname( fd, name, sizeof( name ) ); //人物名称 + CONNECT_getCdkey( fd, id , sizeof( id ) ); //帐号 + } + + switch(gmode) + { + case 1:NPC_Util_GetStrFromStrWithDelim( argstr , "Mode1", buf1, sizeof( buf1)); break; + case 2:NPC_Util_GetStrFromStrWithDelim( argstr , "Mode2", buf1, sizeof( buf1)); break; + case 3:NPC_Util_GetStrFromStrWithDelim( argstr , "Mode3", buf1, sizeof( buf1)); break; + case 4:NPC_Util_GetStrFromStrWithDelim( argstr , "Mode4", buf1, sizeof( buf1)); break; + case 5:NPC_Util_GetStrFromStrWithDelim( argstr , "Mode5", buf1, sizeof( buf1)); break; + } + saacproto_ACRaceRecordandSort_send( acfd , talker , buf1 , id , name,9,0,0); + } + if(gmode < 4 ) //限定种类 + sprintf( buf1, "目前猎宠记录%d只。", CHAR_getInt( talker,CHAR_CATCHCNT1+gmode-1 ) ); + else{ + //random一各题目给他 + askno = rand() % asktotal; + asklv = asktable[askno].lowlv + rand()%((asktable[askno].highlv+1)-asktable[askno].lowlv); + temp = (askno << 22) & 0x7FC00000; + temp = temp | ((asklv << 14) & 0x7FFFC000); + temp = temp | ((asktable[askno].bbi - 100000) & 0x00003FFF); + CHAR_setInt( talker , CHAR_CHECKIN , temp ); + + //sprintf(buf1,"checkin:%d askno:%d askname:%s asklv%d askbbi%d", + // CHAR_getInt( talker ,CHAR_CHECKIN),askno,asktable[askno].petname,asklv,asktable[askno].bbi); + //CHAR_talkToCli( talker, -1,buf1, CHAR_COLORYELLOW); + if( asktable[askno].highlv == 0 ) + sprintf( buf1,"请抓给我等级%d『以上』的%s好吗。您目前记录%d种", asktable[askno].lowlv , asktable[askno].petname, CHAR_getInt( talker,CHAR_CATCHCNT1+gmode-1 ) ); + else + sprintf( buf1,"请抓给我『只能』等级%d的%s好吗。您目前记录%d种", asklv , asktable[askno].petname, CHAR_getInt( talker,CHAR_CATCHCNT1+gmode-1 ) ); + } + ITEM_setChar( itemindex, ITEM_EFFECTSTRING, buf1); + if(itemindex != -1) { + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), /* 失奶 丞 寞 */ +#endif + "EventAddItem(任务需求所得到的道具)", + CHAR_getInt( talker, CHAR_FLOOR), + CHAR_getInt( talker, CHAR_X ), + CHAR_getInt( talker, CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + sprintf(token,"拿到%s。", ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + CHAR_sendItemDataOne( talker, ret); + + return TRUE; +} + +// 检查是否为比赛的宠物和是否登记过 +BOOL Raceman_checkpet( int meindex, int talker , int select , char *token ) +{ + int petindex,checkpetID,petimgnum; + char *petname; + char buf[256]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + int index,gmode; + unsigned int askno,asklv,askbbi; + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { //读参数 + print("MsgDisp:GetArgStrErr"); + print("NPCName=%s\n", CHAR_getChar( meindex, CHAR_NAME)); + return FALSE; + } + + NPC_Util_GetStrFromStrWithDelim( argstr , "EndFlag", buf, sizeof( buf)); + if( strcmp(buf,"on")==0){ + NPC_Util_GetStrFromStrWithDelim( argstr , "ending_msg", buf, sizeof( buf)); + sprintf( token , "\n %s",buf); + return FALSE; + } + + if(CHAR_getInt( talker,CHAR_CATCHCNT5 ) >= asktotal ){ + strcpy( token ,"恭喜你已经达到猎宠大赛终极目标,感谢您的参与并祝您抽中大奖"); + return FALSE; + } + + petindex = CHAR_getCharPet( talker, select-1); + petname = CHAR_getUseName( petindex); + if( !CHAR_CHECKINDEX(petindex) ) return FALSE; + + if (CHAR_getInt(petindex, CHAR_PETFAMILY) == 1){ + strcpy(token,"\n 家族守护兽无法登记!"); + return FALSE; + } + + if (CHAR_getInt( talker , CHAR_RIDEPET) == select-1 ){ + strcpy(token,"\n 骑乘中的宠物无法登记!"); + return FALSE; + } + + NPC_Util_GetStrFromStrWithDelim( argstr , "GameCode", buf, sizeof( buf)); + if( CHAR_getInt(petindex,CHAR_CHECKIN) == atoi(buf) ){ //这次比赛已登记过了 + strcpy(token,"\n 这只宠物已经在本届比赛登记过了哦!"); + return FALSE; + } + + NPC_Util_GetStrFromStrWithDelim( argstr , "GameMode", buf, sizeof( buf)); + gmode = atoi(buf); + if(gmode==4||gmode==5) //不限种类 + { + petimgnum = CHAR_getInt( petindex , CHAR_BASEBASEIMAGENUMBER); + askbbi = CHAR_getInt( talker ,CHAR_CHECKIN) & 0x00003FFF; + asklv = ( CHAR_getInt( talker ,CHAR_CHECKIN ) & 0x003FC000 ) >> 14 ; + askno = ( CHAR_getInt( talker ,CHAR_CHECKIN ) & 0x7FC00000 ) >> 22 ; + + //sprintf(buf,"checkin:%d petimgnum:%d askbbi:%d petname:%s askname:%s petlv%d asklv%d", + // CHAR_getInt( talker ,CHAR_CHECKIN),petimgnum,askbbi,petname,asktable[askno].petname, + // CHAR_getInt(petindex , CHAR_LV),asklv); + //CHAR_talkToCli( talker, -1,buf, CHAR_COLORYELLOW); + + if( petimgnum != askbbi+100000 ){ + strcpy(token,"\n 请确认宠物,这只不是我要的哦!"); + return FALSE; + } + if( strcmp(petname,asktable[askno].petname)!=0) { + strcpy(token,"\n 请确认宠物,这只不是我要的哦!"); + return FALSE; + } + if( asktable[askno].highlv == 0 ){ + if( CHAR_getInt(petindex , CHAR_LV) < asktable[askno].lowlv ){ + strcpy(token,"\n 这只宠物等级不够哦!"); + return FALSE; + } + }else{ + if( CHAR_getInt(petindex , CHAR_LV) != asklv ){ + strcpy(token,"\n 请确认宠物等级,等级不对唷哦!"); + return FALSE; + } + } + + sprintf(token," === 宠物登记 ===" + "\n\n\n 您选择登记的宠物是 %s Lv:%d" + ,petname,CHAR_getInt( petindex, CHAR_LV)); + + /* + NPC_Util_GetStrFromStrWithDelim( argstr , "PetLevel", buf, sizeof( buf)); + if (CHAR_getInt(petindex , CHAR_LV) < atoi(buf)){ + strcpy(token,"\n 这只宠物等级不够!"); + return FALSE; + } + + petimgnum = CHAR_getInt( petindex , CHAR_BASEBASEIMAGENUMBER); + for(petNo=0;petNo<640;petNo++){ + if( petimgnum == petflgtable[petNo] ) // 应该要一定在table内 + break; + } + if( petNo >= 640 ){ + //sprintf(buuf2,"petimgnum:%d pftable:%d petNo:%d", petimgnum , petflgtable[2] , petNo); + //CHAR_talkToCli( talker, -1,buuf2, CHAR_COLORYELLOW); + strcpy(token,"\n 这只宠物怪怪的唷!"); + //log + LogPet( CHAR_getChar( talker, CHAR_NAME ), + CHAR_getChar( talker, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "raceman(猎宠大会非法宠记录)", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) + ); + + return FALSE;// 出问题罗,玩家拿不能拥有的宠物来登记 + } + + //sprintf(buuf2,"petimgnum:%d pftable:%d petNo:%d", petimgnum , petflgtable[petNo] , petNo); + //CHAR_talkToCli( talker, -1,buuf2, CHAR_COLORYELLOW); + + base = 1; + intNo = petNo / 32 ; + shift = petNo % 32 ; + base = base << shift; + + //sprintf(buuf2,"intNo:%d shift:%d base:%d data:%d", intNo , shift , base , CHAR_getInt( talker , CHAR_KINDCNT1 + intNo )); + //CHAR_talkToCli( talker, -1,buuf2, CHAR_COLORYELLOW); + + if( CHAR_getInt( talker , CHAR_KINDCNT1 + intNo ) & base ){ + NPC_Util_GetStrFromStrWithDelim( argstr , "repeat_msg", buf, sizeof( buf)); + sprintf(token,"\n %s",buf); + return FALSE; + }else{ + sprintf(token," === 宠物登记 ===" + "\n\n\n 您选择登记的宠物是 %s Lv:%d" + ,petname,CHAR_getInt( petindex, CHAR_LV) + ); + } + */ + } + else + { + if(NPC_Util_GetStrFromStrWithDelim( argstr , "CheckPet", buf, sizeof( buf)) != NULL ){ + checkpetID = atoi(buf); + if( !ENEMY_CHECKINDEX( checkpetID )) return FALSE; + + // sprintf(buuf2,"petindex:%d checkpetID:%d index:%d",petindex,checkpetID,index); + // CHAR_talkToCli( talker, -1,buuf2, CHAR_COLORYELLOW); + + /*保留gm指令dropmypet做法 结果同下段 + petarray = ENEMY_getEnemyArrayFromId( checkpetID ); + petindex2 = ENEMY_TEST_createPetIndex( petarray ); + test5 = CHAR_getInt( petindex2 , CHAR_BASEBASEIMAGENUMBER); + */ + + index = ENEMYTEMP_getEnemyTempArray(ENEMY_getEnemyArrayFromId(checkpetID)); + if( !ENEMYTEMP_CHECKINDEX( index )) return FALSE; + petimgnum = ENEMYTEMP_getInt(index,E_T_IMGNUMBER); //GET ENEMYTEMP_enemy[index].intdata[E_T_IMGNUMBER]; + + //sprintf(buuf,"check:%d be_check:%d",petimgnum, CHAR_getInt( petindex , CHAR_BASEBASEIMAGENUMBER)); //petarry:%d petindex2:%d test5:%d",test1,test2,petarray,petindex2,test5); + //CHAR_talkToCli( talker, -1,buuf, CHAR_COLORYELLOW); + + if( CHAR_getInt( petindex , CHAR_BASEBASEIMAGENUMBER) == petimgnum ){ + + NPC_Util_GetStrFromStrWithDelim( argstr , "PetLevel", buf, sizeof( buf)); + if (CHAR_getInt(petindex , CHAR_LV) < atoi(buf)){ + strcpy(token,"\n 这只宠物等级不够!"); + return FALSE; + } + + sprintf(token," === 宠物登记 ===" + "\n\n\n 您选择登记的宠物是 %s Lv:%d" + ,petname,CHAR_getInt( petindex, CHAR_LV) + ); + }else{ + strcpy(token,"\n 比赛的题目没有这只宠物哦!"); + return FALSE; + } + } + } + return TRUE; +} + +int Raceman_getokask( int talker, int random ) +{ + int base,i,shift; + + base = random / 32 ; + shift = random % 32 ; + i = 1 << shift ; + if( CHAR_getInt( talker , CHAR_KINDCNT1 + base ) & i ){ //为真表示解过了 + random ++; + if( random >= asktotal ) random = 0; + return Raceman_getokask( talker , random ); + }else + return random; +} + +BOOL Raceman_petcheckin( int meindex , int talker ) +{ + int petindex,fd,item,i,itemindex,itemid,gmode; + char *petname; + char id[16],name[64]; + char buf[64],buf1[64]; //buuf[128]; + char category[12]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + int base,intNo,shift,petNo,j; + unsigned int askno,asklv,temp; + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { //读参数 + print("MsgDisp:GetArgStrErr"); + print("NPCName=%s\n", CHAR_getChar( meindex, CHAR_NAME)); + return FALSE; + } + + //保险检查 + for( i = 0 ; i < 5 ; i ++ ){ + j = CHAR_getInt( talker,CHAR_CATCHCNT1 + i ) ; + if( j++ >= 0xFFFFFF ) { + CHAR_talkToCli( talker, -1, "很抱歉,您已经达到系统上限,无法再登记了", CHAR_COLORYELLOW); + return FALSE; + } + } + + petindex = CHAR_getCharPet( talker, CHAR_getWorkInt( talker , CHAR_WORK_PETSELECT ) ); + if( !CHAR_CHECKINDEX(petindex) ) return FALSE; + petname = CHAR_getUseName( petindex); + + //写入宠物栏位 + NPC_Util_GetStrFromStrWithDelim( argstr , "GameCode", buf, sizeof( buf)); + CHAR_setInt( petindex, CHAR_CHECKIN , atoi(buf) ); + LogPet( CHAR_getChar( talker, CHAR_NAME ), + CHAR_getChar( talker, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "raceman(猎宠大会收宠时记录)", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) + ); + + //收宠 + if( NPC_Util_GetStrFromStrWithDelim( argstr, "DelFlag",buf, sizeof( buf) ) != NULL){ + if( strcmp(buf,"on")==0){ + CHAR_endCharOneArray( petindex ); + CHAR_setCharPet( talker , CHAR_getWorkInt( talker , CHAR_WORK_PETSELECT ) , -1); + snprintf( category, sizeof( category), "K%d", CHAR_getWorkInt( talker , CHAR_WORK_PETSELECT )); + CHAR_sendStatusString( talker , category ); + snprintf( category, sizeof( category), "W%d",CHAR_getWorkInt( talker , CHAR_WORK_PETSELECT )); + CHAR_sendStatusString( talker , category ); + //log + LogPet( CHAR_getChar( talker, CHAR_NAME ), + CHAR_getChar( talker, CHAR_CDKEY ), + CHAR_getChar( petindex, CHAR_NAME), + CHAR_getInt( petindex, CHAR_LV), + "raceman(猎宠大会收宠时记录)", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + CHAR_getChar( petindex, CHAR_UNIQUECODE) + ); + } + } + + //分限定种类还是不同种类 + NPC_Util_GetStrFromStrWithDelim( argstr , "GameMode", buf, sizeof( buf)); + gmode = atoi(buf); + if(gmode==4||gmode==5) //不同种类 + { + petNo = ( CHAR_getInt( talker ,CHAR_CHECKIN ) & 0x7FC00000 ) >> 22 ; + //petNo -= 1; + intNo = petNo / 32 ; + shift = petNo % 32 ; + base = 1 << shift; + CHAR_setInt( talker , CHAR_KINDCNT1 + intNo , CHAR_getInt( talker , CHAR_KINDCNT1 + intNo ) | base ); + //sprintf(buuf,"chkin data:%d", CHAR_getInt( talker , CHAR_KINDCNT1 + intNo ) ); + //CHAR_talkToCli( talker, -1,buuf, CHAR_COLORYELLOW); + + //分成个人还是家族赛 + if(gmode == 5) //设定为家族赛 + { + CHAR_setInt( talker,CHAR_CATCHCNT5,CHAR_getInt( talker,CHAR_CATCHCNT5 ) +1 ); + strcpy(name,CHAR_getChar(talker,CHAR_FMNAME)); //家族名称 + sprintf(id,"%d",CHAR_getWorkInt(talker, CHAR_WORKFMINDEXI)); //家族id + } + else // 4 + { + //玩家抓宠次数加1 + fd = getfdFromCharaIndex(talker); + CHAR_setInt( talker,CHAR_CATCHCNT4,CHAR_getInt( talker,CHAR_CATCHCNT4 ) +1 ); + CONNECT_getCharname( fd, name, sizeof( name ) ); //人物名称 + CONNECT_getCdkey( fd, id , sizeof( id ) ); //帐号 + } + } + else // 1 2 3 + { + //分成个人还是家族赛 + if(gmode == 3) //设定为家族赛 + { + //族长次数加1 + CHAR_setInt( talker,CHAR_CATCHCNT3,CHAR_getInt( talker,CHAR_CATCHCNT3 ) +1 ); + strcpy(name,CHAR_getChar(talker,CHAR_FMNAME)); //家族名称 + sprintf(id,"%d",CHAR_getWorkInt(talker, CHAR_WORKFMINDEXI)); //家族id + } + else + { + //玩家抓宠次数加1 + fd = getfdFromCharaIndex(talker); + CONNECT_getCharname( fd, name, sizeof( name ) ); //人物名称 + CONNECT_getCdkey( fd, id , sizeof( id ) ); //帐号 + if(gmode == 1 ) + CHAR_setInt( talker,CHAR_CATCHCNT1,CHAR_getInt( talker,CHAR_CATCHCNT1 ) +1 ); + else + CHAR_setInt( talker,CHAR_CATCHCNT2,CHAR_getInt( talker,CHAR_CATCHCNT2 ) +1 ); + } + } + + //判断现在是比什麽 + switch(gmode) + { + case 1:NPC_Util_GetStrFromStrWithDelim( argstr , "Mode1", buf, sizeof( buf)); break; + case 2:NPC_Util_GetStrFromStrWithDelim( argstr , "Mode2", buf, sizeof( buf)); break; + case 3:NPC_Util_GetStrFromStrWithDelim( argstr , "Mode3", buf, sizeof( buf)); break; + case 4:NPC_Util_GetStrFromStrWithDelim( argstr , "Mode4", buf, sizeof( buf)); break; + case 5:NPC_Util_GetStrFromStrWithDelim( argstr , "Mode5", buf, sizeof( buf)); break; + } + //ac做一次记录跟排名 (fd,charaindex,id,name,limittime,racetype,catchcnt,ranknum) + //sprintf(buuf,"acfd:%d talker:%d mode:%s id:%s name:%s catchcnt:%d",acfd,talker,buf,id,name,CHAR_getInt( talker,CHAR_CATCHCNT ) ); + //CHAR_talkToCli( talker, -1, buuf, CHAR_COLORYELLOW); + if(gmode == 3 || gmode == 5){ + saacproto_ACRaceRecordfmdo_send( acfd , talker , CHAR_getInt( talker, CHAR_FMINDEX ) + , CHAR_getInt( petindex, CHAR_BASEBASEIMAGENUMBER) , CHAR_getChar( petindex, CHAR_UNIQUECODE ) , CHAR_getChar( petindex, CHAR_NAME) ); + + //sprintf(buuf,"acfd:%d talker:%d fmid:%d bbi:%d unicode:%s petn:%s",acfd,talker,CHAR_getInt( talker, CHAR_FMINDEX ) + // ,CHAR_getInt( petindex, CHAR_BASEBASEIMAGENUMBER),CHAR_getChar( petindex, CHAR_UNIQUECODE ),CHAR_getChar( petindex, CHAR_NAME)); + //CHAR_talkToCli( talker, -1, buuf, CHAR_COLORYELLOW); + } + saacproto_ACRaceRecordandSort_send( acfd , talker , buf , id , name , + 0 , CHAR_getInt( talker,CHAR_CATCHCNT1+gmode-1 ) , 0 ) ; + + + //猎宠证次数加1 或 决定下一个题目 + if( NPC_Util_GetStrFromStrWithDelim( argstr, "CheckItem", + buf, sizeof( buf) ) != NULL) + { + item = atoi(buf); + for( i = 0 ; i < CHAR_MAXITEMHAVE ; i++ ) { + itemindex=CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX( itemindex) ) { + itemid=ITEM_getInt( itemindex ,ITEM_ID ); + //print("itemindex:%d itemid:%d item:%d\n",itemindex,itemid,item); + if(itemid==item){ //找到猎宠证 + if(gmode < 4) + sprintf( buf1, "目前猎宠记录%d只。", CHAR_getInt( talker,CHAR_CATCHCNT1+gmode-1 ) ); + else{ + if(CHAR_getInt( talker,CHAR_CATCHCNT5 ) >= asktotal ){ + sprintf( buf1,"恭喜你达到猎宠大赛终极目标,祝您抽中大奖"); + }else{ + askno = Raceman_getokask( talker , rand() % asktotal ); + asklv = asktable[askno].lowlv + rand()%((asktable[askno].highlv+1)-asktable[askno].lowlv); + temp = (askno << 22) & 0x7FC00000; + temp = temp | ((asklv << 14) & 0x003FC000); + temp = temp | ((asktable[askno].bbi - 100000) & 0x00003FFF); + CHAR_setInt( talker , CHAR_CHECKIN , temp ); + if( asktable[askno].highlv == 0 ) + sprintf( buf1,"请抓给我等级%d『以上』的%s好吗。您目前记录%d种", asktable[askno].lowlv , asktable[askno].petname, CHAR_getInt( talker,CHAR_CATCHCNT1+gmode-1 ) ); + else + sprintf( buf1,"请抓给我『只能』等级%d的%s好吗。您目前记录%d种", asklv , asktable[askno].petname, CHAR_getInt( talker,CHAR_CATCHCNT1+gmode-1 ) ); + } + } + ITEM_setChar( itemindex, ITEM_EFFECTSTRING, buf1); + CHAR_sendItemDataOne( talker , i ); + break; + } + } + } + } + + sprintf( buf,"%sLv:%d登记完成了,加油加油。",petname,CHAR_getInt( petindex, CHAR_LV )); + CHAR_talkToCli( talker, -1, buf , CHAR_COLORWHITE); + + return TRUE; +} + +//读放在saac的排名资料,而且要是目前比赛的项目 +void Raceman_countrank( int meindex, int talker ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + int ranknum = 0,gmode; + char buf[64],buf1[64]; + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { //读参数 + print("MsgDisp:GetArgStrErr"); + print("NPCName=%s\n", CHAR_getChar( meindex, CHAR_NAME)); + return; + } + + if(NPC_Util_GetStrFromStrWithDelim( argstr , "RankNum", buf1, sizeof( buf1)) != NULL ){ + ranknum = atoi(buf1); + } + + NPC_Util_GetStrFromStrWithDelim( argstr , "GameMode", buf, sizeof( buf)); + gmode = atoi(buf); + + switch(gmode) + { + case 1:NPC_Util_GetStrFromStrWithDelim( argstr , "Mode1", buf, sizeof( buf)); break; + case 2:NPC_Util_GetStrFromStrWithDelim( argstr , "Mode2", buf, sizeof( buf)); break; + case 3:NPC_Util_GetStrFromStrWithDelim( argstr , "Mode3", buf, sizeof( buf)); break; + case 4:NPC_Util_GetStrFromStrWithDelim( argstr , "Mode4", buf, sizeof( buf)); break; + case 5:NPC_Util_GetStrFromStrWithDelim( argstr , "Mode5", buf, sizeof( buf)); break; + } + + saacproto_ACRaceRecordandSort_send( acfd,talker,buf,"","",gmode,0,ranknum ); + +} + +void Raceman_renewrank( int meindex , int talker , int select ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + int ranknum = 0; + char buf[64],buf1[64]; + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { //读参数 + print("MsgDisp:GetArgStrErr"); + print("NPCName=%s\n", CHAR_getChar( meindex, CHAR_NAME)); + return; + } + + if(NPC_Util_GetStrFromStrWithDelim( argstr , "RankNum", buf1, sizeof( buf1)) != NULL ){ + ranknum = atoi(buf1); + } + + if(NPC_Util_GetStrFromStrWithDelim( argstr , "HasGame", buf, sizeof( buf)) != NULL ){ + getStringFromIndexWithDelim( buf , "," , select , buf1 , sizeof(buf1) ); + select = atoi(buf1); + switch(select) + { + case 1:NPC_Util_GetStrFromStrWithDelim( argstr , "Mode1", buf, sizeof( buf)); break; + case 2:NPC_Util_GetStrFromStrWithDelim( argstr , "Mode2", buf, sizeof( buf)); break; + case 3:NPC_Util_GetStrFromStrWithDelim( argstr , "Mode3", buf, sizeof( buf)); break; + case 4:NPC_Util_GetStrFromStrWithDelim( argstr , "Mode4", buf, sizeof( buf)); break; + case 5:NPC_Util_GetStrFromStrWithDelim( argstr , "Mode5", buf, sizeof( buf)); break; + default: return; + } + saacproto_ACRaceRecordandSort_send( acfd,talker,buf,"","",select,0,ranknum ); + } +} + +//检查是否有资格领奖 +BOOL Raceman_checkprize( int meindex , int talker ,char *token) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[256],buf1[64]; + int lowlevel;//最低标准 下限 + int gmode; + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { //读参数 + print("MsgDisp:GetArgStrErr"); + print("NPCName=%s\n", CHAR_getChar( meindex, CHAR_NAME)); + return FALSE; + } + + NPC_Util_GetStrFromStrWithDelim( argstr , "EndFlag", buf1, sizeof( buf1)); + if( strcmp(buf1,"off")==0){ // 比赛没结束 所以不能领 + NPC_Util_GetStrFromStrWithDelim( argstr , "notend_msg", buf, sizeof( buf)); + strcpy( token, " ☆猎宠战利品颁发☆\n\n"); + strcat( token , buf ); + //strcat( token, " 比赛还在进行中唷...\n"); + return FALSE; + } + + if(Raceman_CheckItem( meindex , talker ) == FALSE){ + NPC_Util_GetStrFromStrWithDelim( argstr , "nonitem_msg", buf, sizeof( buf)); + strcpy( token, " ☆猎宠战利品颁发☆\n\n"); + strcat( token , buf ); + //strcat( token, " 很抱歉,您没有猎宠证无法领奖...\n"); + return FALSE; + } + + NPC_Util_GetStrFromStrWithDelim( argstr , "LowLevel", buf1, sizeof( buf1)); + lowlevel = atoi(buf1); + NPC_Util_GetStrFromStrWithDelim( argstr , "GameMode", buf1, sizeof( buf1)); + gmode = atoi(buf1); + + if( CHAR_getInt( talker,CHAR_CATCHCNT1+gmode-1 ) < lowlevel ){ + NPC_Util_GetStrFromStrWithDelim( argstr , "low_msg", buf, sizeof( buf)); + strcpy( token, " ☆猎宠战利品颁发☆\n\n"); + //strcat( token, " 很抱歉,您没有达到最低标准...\n"); + strcat( token , buf ); + return TRUE; + } + + //检查有无栏位 + if(Raceman_ItemFullCheck( meindex , talker) == FALSE){ + NPC_Util_GetStrFromStrWithDelim( argstr, "itemfull_msg",buf, sizeof( buf) ); + strcpy( token, " ☆猎宠战利品颁发☆\n\n "); + strcat( token, buf ); + return FALSE; + } + + strcpy( token, " ☆猎宠战利品颁发☆\n\n"); + strcat( token, " 猎宠勇士,这是你应得的战利品...\n"); + return TRUE; +} + +void Raceman_awardprize( int meindex , int talker ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + int fd,itemindex,ret,gmode,rank,lowlevel; + char id[20],name[64],buf[128],buf2[20],buf3[256]; //buuf[256]; + int i,item,itemid,random,prize; + char prizebuf[20][20]; + + memset(prizebuf,0,sizeof(prizebuf)); + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { //读参数 + print("MsgDisp:GetArgStrErr"); + print("NPCName=%s\n", CHAR_getChar( meindex, CHAR_NAME)); + return; + } + + NPC_Util_GetStrFromStrWithDelim( argstr , "LowLevel", buf2, sizeof( buf2)); + lowlevel = atoi(buf2); + + NPC_Util_GetStrFromStrWithDelim( argstr, "GameMode", buf, sizeof( buf) ); + gmode = atoi( buf ); + + if( CHAR_getInt( talker,CHAR_CATCHCNT1+gmode-1 ) < lowlevel ){ + goto DELITEM; + } + + if(gmode == 3 || gmode == 5) + { + strcpy(name,CHAR_getChar(talker,CHAR_FMNAME)); //家族名称 + sprintf(id,"%d",CHAR_getWorkInt(talker, CHAR_WORKFMINDEXI)); //家族id + } + else // 1 2 4 个人 + { + fd = getfdFromCharaIndex(talker); + CONNECT_getCharname( fd, name, sizeof( name ) ); + CONNECT_getCdkey( fd, id , sizeof( id ) ); //帐号 + } + + rank = 0; + /* 取消 决定一二叁名 + switch(gmode) + { + case 1: + for(i=0;i<3;i++){ + if(strcmp(history1[i].id,id)==0 && strcmp(history1[i].name,name)==0 + && history1[i].catchcnt == CHAR_getInt( talker,CHAR_CATCHCNT1 )){ + rank = i+1; + break; + } + }break; + case 2: + for(i=0;i<3;i++){ + if(strcmp(history2[i].id,id)==0 && strcmp(history2[i].name,name)==0 + && history2[i].catchcnt == CHAR_getInt( talker,CHAR_CATCHCNT2 )){ + rank = i+1; + break; + } + }break; + case 3: + for(i=0;i<3;i++){ + if(strcmp(history3[i].id,id)==0 && strcmp(history3[i].name,name)==0 + && history3[i].catchcnt == CHAR_getInt( talker,CHAR_CATCHCNT3 )){ + rank = i+1; + break; + } + }break; + case 4: + for(i=0;i<3;i++){ + if(strcmp(history4[i].id,id)==0 && strcmp(history4[i].name,name)==0 + && history4[i].catchcnt == CHAR_getInt( talker,CHAR_CATCHCNT4 )){ + rank = i+1; + break; + } + }break; + case 5: + for(i=0;i<3;i++){ + if(strcmp(history5[i].id,id)==0 && strcmp(history5[i].name,name)==0 + && history5[i].catchcnt == CHAR_getInt( talker,CHAR_CATCHCNT5 )){ + rank = i+1; + break; + } + }break; + } + */ + buf[0]='\0'; + if(rank == 1){ + NPC_Util_GetStrFromStrWithDelim( argstr , "thanks1_msg", buf, sizeof( buf)); + NPC_Util_GetStrFromStrWithDelim( argstr , "First", buf2, sizeof( buf2)); + }else if(rank == 2){ + NPC_Util_GetStrFromStrWithDelim( argstr , "thanks2_msg", buf, sizeof( buf)); + NPC_Util_GetStrFromStrWithDelim( argstr , "Second", buf2, sizeof( buf2)); + }else if(rank == 3){ + NPC_Util_GetStrFromStrWithDelim( argstr , "thanks3_msg", buf, sizeof( buf)); + NPC_Util_GetStrFromStrWithDelim( argstr , "Third", buf2, sizeof( buf2)); + }else{ + NPC_Util_GetStrFromStrWithDelim( argstr , "thanks_msg", buf, sizeof( buf)); + NPC_Util_GetStrFromStrWithDelim( argstr , "Normal", buf3, sizeof( buf3)); + //参加奖随机决定 + i = 0; + while( getStringFromIndexWithDelim( buf3 , "," , i+1 , buf2 , sizeof(buf2) )) + { + sprintf( prizebuf[i],"%s",buf2); + i++ ; + } + random = rand() % i; + sprintf( buf2 , "%s" , prizebuf[random]); + //sprintf(buuf,"random:%d item:%s",random,buf2); + //CHAR_talkToCli( talker , -1, buuf , CHAR_COLORYELLOW); + } + CHAR_talkToCli( talker, -1, buf, CHAR_COLORYELLOW); + prize = atoi(buf2); + + //给奖品 + itemindex = ITEM_makeItemAndRegist( prize ); + if(itemindex == -1) return; + + ret = CHAR_addItemSpecificItemIndex( talker, itemindex); + if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) { + print( "npc_raceman.c: ACCEPTadditem error itemindex[%d]\n", itemindex); + ITEM_endExistItemsOne( itemindex); + return ; + } + CHAR_sendItemDataOne( talker, ret); + +DELITEM: + //删除猎宠证 + if( NPC_Util_GetStrFromStrWithDelim( argstr, "CheckItem", buf , sizeof( buf ) ) != NULL ) + { + item = atoi(buf); + for( i = 0 ; i < CHAR_MAXITEMHAVE ; i++ ) { + itemindex=CHAR_getItemIndex( talker , i ); + if( ITEM_CHECKINDEX( itemindex) ) { + itemid=ITEM_getInt( itemindex ,ITEM_ID ); + if(itemid==item){ //找到猎宠证 + LogItem( + CHAR_getChar( talker, CHAR_NAME ), + CHAR_getChar( talker, CHAR_CDKEY ), + #ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, + #else + ITEM_getInt( itemindex, ITEM_ID ), + #endif + "因领奖而消失", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + + CHAR_DelItem( talker , i ); + CHAR_talkToCli( talker, -1, "猎宠证消失了", CHAR_COLORYELLOW); + break; + } + } + } + } + + + +} + +int Raceman_readmode( int meindex , int talkerindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + int gmode; // 1:新手限 2:个人限 3:团体限 4:个人不限 5:团体不限 + char buf[10]; + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { //读参数 + print("MsgDisp:GetArgStrErr"); + print("NPCName=%s\n", CHAR_getChar( meindex, CHAR_NAME)); + } + + if(NPC_Util_GetStrFromStrWithDelim( argstr , "GameMode", buf, sizeof( buf)) != NULL ){ + gmode = atoi(buf); + return gmode; + } + + return 0; +} + +int Raceman_CheckSelectRank(meindex,talkerindex,datanum) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[64],buf2[64]; + int select = 0; + + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) { //读参数 + print("MsgDisp:GetArgStrErr"); + print("NPCName=%s\n", CHAR_getChar( meindex, CHAR_NAME)); + } + + NPC_Util_GetStrFromStrWithDelim( argstr, "EndFlag",buf, sizeof( buf) ); + if(strcmp(buf,"off")==0){ + if(NPC_Util_GetStrFromStrWithDelim( argstr , "HasGame", buf, sizeof( buf)) != NULL ){ + getStringFromIndexWithDelim( buf , "," , datanum-1 , buf2 , sizeof(buf2) ); + select = atoi(buf2); + } + }else{ + if(NPC_Util_GetStrFromStrWithDelim( argstr , "GameMode", buf, sizeof( buf)) != NULL ){ + select = atoi(buf) + 10 ; + } + + } + + return select; +} + +void Raceman_GetQuestion( int meindex ,int talker , char *token) +{ + char line[2000]; + char buf[512];//buuf[128]; + int i,j ,quiztotal = 0, quiz = 0 ; + FILE* fp; + + fp = fopen(".//data//racequiz.txt", "r"); + if (fp == NULL) + { + print("racequiz File Open Error\n"); + strcpy( token,"系统发生错误!"); + return ; + } + while(1){ + if (fgets(line, sizeof(line), fp) == NULL) break; + quiztotal++; + } + fclose(fp); + + fp = fopen(".//data//racequiz.txt", "r"); + if (fp == NULL) + { + print("racequiz File Open Error\n"); + strcpy( token,"系统发生错误!"); + return ; + } + + quiz = rand() % (quiztotal) ; //乱数决定问题 + + j = 0 ; + while(1){ + + line[0]='\0'; + if (fgets(line, sizeof(line), fp) == NULL){ + break; + } + chop(line); + + // #为注解 + if( line[0] == '#' ) + continue; + for( i=0; i +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "configfile.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "npc_riderman.h" +#include "family.h" +#include "log.h" + +extern int familyNumTotal; +extern char familyListBuf[MAXFAMILYLIST]; +extern tagRidePetTable ridePetTable[296]; +extern struct FM_POINTLIST fmpointlist; + +char sendbuf[1024]; +char buf[1024]; +char subbuf[128]; +int i, j; + +/* + * 涩烂今木凶它奴件玉它毛请允NPC + * 棵哑 平旦玄失玉矛件民乓□仁日中卅日综木月井手[ + * + */ + +struct { + int windowno; + int windowtype; + int buttontype; + int takeitem; + int giveitem; + int takegold; + char message[4096]; + int letter[4]; +}w; + +struct { + BOOL use; + int checkhaveitem; + int checkhaveitemgotowin; + int checkdonthaveitem; + int checkdonthaveitemgotowin; + int warp; + int battle; + int gotowin; +}buttonproc[13]; /* ok,cancel, yes,no,prev,next 及凛及质 */ + + + + + +enum { + CHAR_WORK_MSGCOLOR = CHAR_NPCWORKINT1, +}; + +static void NPC_Riderman_selectWindow( int meindex, int toindex, int num); +static BOOL NPC_Riderman_readData( int meindex, int windowno, BOOL chkflg); +static int NPC_Riderman_restoreButtontype( char *data ); +// static BOOL getLetter(int meindex,int talker ); +// static BOOL checkLetter(int meindex,int talker ); + +/********************************* +* 赓渝质 +*********************************/ +BOOL NPC_RidermanInit( int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024]; + //int i; + //char secondToken[1024]; + + // Robin test + // print(" riderman_Init "); + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "conff", buf, sizeof( buf)) + == NULL ) + { + print( "riderman:没有指定设定的档案 。\n"); + return FALSE; + } + /* 赓渝凛卞涩烂犯□正毛民尼永弁仄化支月 */ + if( !NPC_Riderman_readData( meindex, -1, TRUE) ) { + return FALSE; + } + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEWINDOWMAN ); + + return TRUE; +} + + + + +/********************************* +* 仄井仃日木凶凛及质 +*********************************/ +void NPC_RidermanTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + //print(" Rideman_fmindex:%d ", CHAR_getInt( meindex, CHAR_FMINDEX) ); + + NPC_Riderman_selectWindow( meindex, talkerindex, 1 ); + +} +/********************************* +* 苇日木凶凛及质 +*********************************/ +void NPC_RidermanLooked( int meindex , int lookedindex) +{ + + //print(" Look:me:%d,looked:%d ",meindex,lookedindex); + NPC_Riderman_selectWindow( meindex, lookedindex,1 ); + +} + +static void NPC_Riderman_selectWindow( int meindex, int toindex, int num) +{ + + int fd; + char buf[256]; + + /* 皿伊奶乩□卞覆仄化分仃 杀允月 */ + if( CHAR_getInt( toindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + /* ㄠ弘伉永玉动 及心 */ + if( !NPC_Util_charIsInFrontOfChar( toindex, meindex, 1 )) return; + + if( !NPC_Riderman_readData( meindex, num, FALSE) ) { + print( "riderman:readdata error\n"); + return; + } + + fd = getfdFromCharaIndex( toindex); + if( fd != -1 ) { + lssproto_WN_send( fd, w.windowtype, + w.buttontype, + w.windowno+100, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( w.message, buf, sizeof(buf))); + } +} + +void NPC_RidermanWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) + +{ + + + int button = -1; + char buf[512]; + + /* ㄠ弘伉永玉动 及心 */ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) return; + + /* 仇及它奴件玉它 寞及犯□正毛 心 戈 */ + if( !NPC_Riderman_readData( meindex, seqno - 100, FALSE) ) { + print( "riderman:readdata error\n"); + return; + } + /* 瓷仄凶示正件毛譬屯月 */ + if( w.windowtype == WINDOW_MESSAGETYPE_SELECT ) { + button = atoi( data)+5; + if( button > 12 ) { + print( "riderman:invalid button[%d]\n", button); + return; + } + } + else if( select & WINDOW_BUTTONTYPE_OK) button = 0; + else if( select & WINDOW_BUTTONTYPE_CANCEL) button = 1; + else if( select & WINDOW_BUTTONTYPE_YES) button = 2; + else if( select & WINDOW_BUTTONTYPE_NO) button = 3; + else if( select & WINDOW_BUTTONTYPE_PREV) button = 4; + else if( select & WINDOW_BUTTONTYPE_NEXT) button = 5; + else { + print( "riderman:invalid button[%d]\n", select); + return; + } + if( buttonproc[button].use == TRUE ) { + int fd; + int newwin = -1; + + fd = getfdFromCharaIndex( talkerindex); + + /* 示正件卞方匀化质 毛孔曰歹仃月 */ + if( newwin == -1 ) { + newwin = buttonproc[button].gotowin; + } + + + //print(" takegold:%d ", w.takegold ); + + // Robin + // 学习 Lv 40 + if( newwin == 6 ) { + + int charImg; + // int i, petindex, bFind = 0; + + charImg = CHAR_getInt( talkerindex, CHAR_BASEBASEIMAGENUMBER); + if( CHAR_getInt( talkerindex, CHAR_LEARNRIDE ) >= 40 ) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\n\n你已经学会初级班了呀。\n不需要再学了。", + buf, sizeof(buf))); + return; + } + +#if 0 + if( !checkLetter( meindex, talkerindex) ) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\n\n很抱歉喔!\n学习骑乘宠物需要本庄园族长的同意书。", + buf, sizeof(buf))); + return; + } + + for( i=0; i= 80 ) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\n\n你已经学会中级班了呀。\n不需要再学了。", + buf, sizeof(buf))); + return; + } + else if( CHAR_getInt( talkerindex, CHAR_LEARNRIDE ) < 40 ) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\n\n你必须先学过初级班才能来中级班唷。", + buf, sizeof(buf))); + return; + } + +#if 0 + if( !checkLetter( meindex, talkerindex) ) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\n\n很抱歉喔!\n学习骑乘宠物需要本庄园族长的同意书。", + buf, sizeof(buf))); + return; + } + + for( i=0; i= 120 ) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\n\n你已经学会高级班了呀。\n不需要再学了。", + buf, sizeof(buf))); + return; + } + else if( CHAR_getInt( talkerindex, CHAR_LEARNRIDE ) < 80 ) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\n\n你必须先学过中级班才能来高级班唷。", + buf, sizeof(buf))); + return; + } + +#if 0 + if( !checkLetter( meindex, talkerindex) ) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\n\n很抱歉喔!\n学习骑乘宠物需要本庄园族长的同意书。", + buf, sizeof(buf))); + return; + } + + for( i=0; i 120 ) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\n\n你已经学会特级班了呀。\n不需要再学了。", + buf, sizeof(buf))); + return; + } + else if( CHAR_getInt( talkerindex, CHAR_LEARNRIDE ) < 120 ) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\n\n你必须先学过高级班才能来特级班唷。", + buf, sizeof(buf))); + return; + } + +#if 0 + if( !checkLetter( meindex, talkerindex) ) + { + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, -1, -1, + makeEscapeString( "\n\n很抱歉喔!\n学习骑乘宠物需要本庄园族长的同意书。", + buf, sizeof(buf))); + return; + } + + for( i=0; i +#include +#include +#include +#include + +#include "object.h" +#include "char.h" +#include "char_base.h" +#include "char_data.h" +#include "net.h" +#include "npcutil.h" +#include "handletime.h" +#include "readmap.h" +#include "npc_roomadminnew.h" +#include "npc_door.h" + + +/* + * 尕 遣支今氏 By Kawata + * + * 酷 汔卞 凳及啃踏五 仄凶 互镀中午 丹及匹踏五卅云仄 + */ + + +enum{ + /* 左□弁扑亦件 区 */ + CHAR_WORKINT_RANGE = CHAR_NPCWORKINT1, + /* 戚及蠡濠凛棉 */ + CHAR_WORKINT_NEXTTIME = CHAR_NPCWORKINT2, + /* 憎迕>蠡濠"坌蟆= */ + CHAR_WORKINT_PRINTCLOSETIME = CHAR_NPCWORKINT3, + /* 盒腹绸仄凶 尥 */ + CHAR_WORKINT_SEARCHROOMTIME = CHAR_NPCWORKINT4, + +}; +enum { + /* 愤坌及 蟆 */ + CHAR_WORKCHAR_MYNAME = CHAR_NPCWORKCHAR1, + /* 戚及 瘀 */ + CHAR_WORKCHAR_NEXTROOM = CHAR_NPCWORKCHAR2, + +}; + +/* 仿件平件弘 憎 迕伐□弁*/ +enum { + /* 栋 谛及 蟆 */ + CHAR_WORKCHAR_ADMNAME = CHAR_NPCWORKCHAR1, +}; + + +/* 犯□正白央奶伙毛伞 允月犯奴伊弁玄伉[ls2/src/lss 井日及锹覆隙烂 */ +#define NPC_ROOMADMINNEW_DATADIR "roomadmin/" +/* 犯□正白央奶伙及傀舰阂 */ +#define NPC_ROOMADMINNEW_EXTENSION ".room" +/* 仿件平件弘犯□正白央奶伙及傀舰阂 件禾仿伉 */ +#define NPC_ROOMADMINNEW_RANKING_EXTENSION ".score" +#define NPC_ROOMADMINNEW_RANKING_EXTENSION_TMP ".score.tmp" +/* 嫖 诳樊仿件平件弘白央奶伙 */ +#define NPC_ROOMADMINNEW_SCOREFILE ".score" +/* 蠡户濠曰"坌蟆井日丢永本□斥 */ +#define NPC_ROOMADMINNEW_PRINTCLOSETIME_DEFAULT 5 + +#define NPC_ROOMADMINNEW_MSG_CLOSE_BEFORE \ +"%s %s %s的活动,截止日%d分前。" +#define NPC_ROOMADMINNEW_MSG_CLOSE \ +"。。。已截止。" +#define NPC_ROOMADMINNEW_MSG_NONE \ +"很可惜本次没有人获得房间的拥有权。" +#define NPC_ROOMADMINNEW_MSG_CONGRATULATION \ +"恭喜您!%s获得房间的所有权!%s的金钱全部被徵收了。%s请向管理员询问房间暗号。" +#define NPC_ROOMADMINNEW_MSG_PRINTPASSWD_NONE \ +"由於你未持有房间因此没有暗号。" +#define NPC_ROOMADMINNEW_MSG_DSPPASSWD1 \ +"你的房间是 %s %s %s。" +#define NPC_ROOMADMINNEW_MSG_DSPPASSWD2 \ +"房间的暗号是 「%s 」。只要在对着门说话时在与尾加上「...」,别人就看不见了唷!" +#define NPC_ROOMADMINNEW_MSG_DSPNEXTAUCTION_NONE \ +"本日的活动结束。" +#define NPC_ROOMADMINNEW_MSG_DSPNEXTAUCTION1 \ +"接下来的房间是 %s %s %s。" +#define NPC_ROOMADMINNEW_MSG_DSPNEXTAUCTION2 \ +"截止日是 %d:%d 。到截止日为止还有%2d小时%02d分。" +#define NPC_ROOMADMINNEW_MSG_DSPNEXTAUCTION3 \ +"最低得标金额是 %s 。" + +#define NPC_ROOMADMINNEW_MSG_RANKING_INFO \ +"这是高额得标者排行榜。" +#define NPC_ROOMADMINNEW_MSG_RANKING \ +"Rank %2d:%4d/%02d/%02d %8d GOLD %s%s " + +/* 仇及NPC及丢永本□斥缙 */ +#define NPC_ROOMADMINNEW_MSGCOLOR CHAR_COLORWHITE +#define NPC_RANKING_MSGCOLOR CHAR_COLORWHITE +#define NPC_ROOMADMINNEW_2WEEK 60*60*24*14 + +static void NPC_RoomAdminNew_DspNextAuction( int meindex, int talkerindex); +static void NPC_RoomAdminNew_DspRoomPasswd( int meindex, int adminindex, int talkerindex); +static BOOL NPC_RoomAdminNew_SetNextAuction( int meindex); +static BOOL NPC_RoomAdminNew_WriteDataFile( int meindex, int pindex, char *roomname, + char *passwd, BOOL flg); +static void NPC_RoomAdminNew_CreatePasswd( char *passwd, int passlen); +static void NPC_RoomAdminNew_SendMsgThisFloor( int index, char *buff); +static int NPC_RoomAdminNew_SearchPlayerHasMostMoney( int meindex); +static void NPC_RoomAdminNew_CloseProc( int meindex); +static int NPC_RoomAdminNew_WriteScoreFile( int meindex, int pindex); +static void NPC_RoomAdminNew_ReadScoreFile( int meindex, int talkerindex, + char *admname); + +/************************************************ + * 赓渝质 + ************************************************/ +BOOL NPC_RoomAdminNewInit( int meindex ) +{ + int i; + char buf[256]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + + /* 愤坌及栋喱及蝈 及玉失互请 晓互月引匹仇及NPC反综岳今木卅中 */ + for( i = 3; ; i ++ ) { + if( getStringFromIndexWithDelim(argstr, "|" , i , buf,sizeof(buf) )) { + if( NPC_DoorSearchByName( buf) < 0 ) { + print( "admin not created.在密码门做好之前先等待。\n"); + return FALSE; + } + } + else{ + break; + } + } + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + /* 赓渝祭质 */ + + /* type本永玄 */ + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_TYPEROOMADMIN); + /* 躲 区潸 */ + getStringFromIndexWithDelim(argstr, "|" , 1 , buf,sizeof(buf) ); + CHAR_setWorkInt( meindex , CHAR_WORKINT_RANGE , atoi( buf )); + /* 愤坌及 蟆潸 */ + if( !getStringFromIndexWithDelim(argstr, "|" , 2 , buf,sizeof(buf) )) { + print( "arg err.admin not created.\n"); + return( FALSE); + } + CHAR_setWorkChar( meindex , CHAR_WORKCHAR_MYNAME , buf); + + /* 憎迕>蠡濠"坌蟆=赓渝祭 */ + CHAR_setWorkInt( meindex, CHAR_WORKINT_PRINTCLOSETIME, 0); + + /* 戚及 瘀午左□弁扑亦件钒疡凛棉毛本永玄 */ + NPC_RoomAdminNew_SetNextAuction( meindex); + + return TRUE; +} +/************************************************ + * 伙□皿质 + * 裟太请仄 蘸反公氏卅卞 匹卅仁化手中中[ + * 匹手濮覆卞ㄠ坌 卞允月仪 + ************************************************/ +void NPC_RoomAdminNewLoop( int meindex ) +{ + int hun; + /* 手仄手钒疡凛棉互瑁引匀化中卅井匀凶日潸 仄卅云允 */ + if( CHAR_getWorkInt( meindex, CHAR_WORKINT_NEXTTIME) == 0 ) { + /* 蟆荚腹绸仄凶 互啜尹壬腹绸仄卅云允 */ + struct tm tm1,tm2; + time_t t; + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + t = CHAR_getWorkInt( meindex, CHAR_WORKINT_SEARCHROOMTIME); + memcpy( &tm2, localtime( &t), + sizeof( tm2)); + if( tm1.tm_year != tm2.tm_year || + tm1.tm_mday != tm2.tm_mday || + tm1.tm_mon != tm2.tm_mon ) + { + NPC_RoomAdminNew_SetNextAuction( meindex); + } + return; + } + + hun = ceil((double)(CHAR_getWorkInt( meindex, CHAR_WORKINT_NEXTTIME) - + NowTime.tv_sec) / 60.0); + /* 手仄手及凛及啃卞hun互穴奶瓜旦及凛反ㄟ卞 允 */ + if( hun < 0 ) hun = 0; + + if( hun < NPC_ROOMADMINNEW_PRINTCLOSETIME_DEFAULT ) { + /* 蠡户濠曰嗤仁卞卅匀凶日>蠡户濠曰"坌蟆匹允=午蜕歹允 */ + if( hun != CHAR_getWorkInt( meindex, CHAR_WORKINT_PRINTCLOSETIME)) { + char buff[256]; + if( hun != 0 ) { + char buf2[1024]; + char msgbuff[16]; + char argstr2[NPC_UTIL_GETARGSTR_BUFSIZE]; + int doorindex; + + /* 盒树 潸 */ + doorindex = NPC_DoorSearchByName( CHAR_getWorkChar( meindex, CHAR_WORKCHAR_NEXTROOM)); + NPC_Util_GetArgStr( doorindex, argstr2, sizeof( argstr2)); + getStringFromIndexWithDelim( argstr2, "|" , 9 , + buf2,sizeof(buf2) ); + /* 盒树 */ + if( strlen(CHAR_getChar( doorindex, CHAR_NAME) ) != 0 ) { + strcpy( msgbuff, "号室"); + } + else { + msgbuff[0] = '\0'; + } + /* >蠡户濠曰"坌蟆匹允= */ + snprintf( buff, sizeof(buff), + NPC_ROOMADMINNEW_MSG_CLOSE_BEFORE, + buf2, + CHAR_getChar( doorindex, CHAR_NAME), + msgbuff, + hun); + + CHAR_setWorkInt( meindex, CHAR_WORKINT_PRINTCLOSETIME, hun); + } + else { + /* >蠡户濠曰引仄凶= */ + strcpy( buff, NPC_ROOMADMINNEW_MSG_CLOSE); + CHAR_setWorkInt( meindex, CHAR_WORKINT_PRINTCLOSETIME, 0); + } + /* 仇及白夫失卞中月谛蝈够卞霜耨 */ + NPC_RoomAdminNew_SendMsgThisFloor( meindex, buff); + } + } + /* 蠡户濠匀凶凛及质 */ + if( hun == 0 ) { + NPC_RoomAdminNew_CloseProc( meindex); + } +} + +/************************************************ + * 仄井仃日木凶凛及质 + ************************************************/ +void NPC_RoomAdminNewTalked( int meindex , int talkerindex , char *msg , + int color ) +{ + + /* 皿伊奶乩□互玉失穴件及1弘伉永玉动 卅日 杀允月[ */ + if(NPC_Util_CharDistance( talkerindex, meindex ) > 1)return; + + /* 仄井仃日木凶谛互 盒毛欧曰化中凶日由旦伐□玉毛 憎允月 */ + /*NPC_RoomAdminNew_DspRoomPasswd( meindex, talkerindex);*/ + + /* 戚荚钒疡凛棉] 盒毛蜕丹 */ + NPC_RoomAdminNew_DspNextAuction( meindex, talkerindex); +} +/*----------------------------------------------- + * 蠡户濠日木凶凛及质 + *----------------------------------------------*/ +static void NPC_RoomAdminNew_CloseProc( int meindex) +{ + int pindex; + char buff[256]; + char pname[32]; + int failed = TRUE; + + /* 域 云嗯毛聂仁 匀化中月皿伊奶乩□毛茧允 */ + pindex = NPC_RoomAdminNew_SearchPlayerHasMostMoney( meindex); + /* 竟癫樊失伉 */ + if( pindex != -1) { + /* ㄠ荚匹 仃月伙□皿匹允 */ + while( 1) { + char passwd[9]; + int doorindex; + doorindex = NPC_DoorSearchByName( + CHAR_getWorkChar( meindex, CHAR_WORKCHAR_NEXTROOM)); + /* 由旦伐□玉毛戏岳允月 */ + NPC_RoomAdminNew_CreatePasswd( passwd, sizeof( passwd)); + /* 白央奶伙卞仇及谛及 平□]平乓仿 ] 盒 ]由旦毛踏五 戈 */ + if( NPC_RoomAdminNew_WriteDataFile( meindex, pindex, + CHAR_getWorkChar( meindex, CHAR_WORKCHAR_NEXTROOM), + passwd, 1) + == FALSE) + { + break; + } + /* 玉失卞由旦毛本永玄 */ + if( NPC_DoorSetPasswd( doorindex, passwd) == -1 ) { + break; + } + /* 躲渝蜃毛本永玄 */ + CHAR_setWorkInt( doorindex, CHAR_WORKDOOREXPIRETIME, + CHAR_getWorkInt( meindex, CHAR_WORKINT_NEXTTIME) + + NPC_ROOMADMINNEW_2WEEK); + /* 诳樊仿件平件弘民尼永弁↓白央奶伙踏五 心 */ + NPC_RoomAdminNew_WriteScoreFile( meindex, pindex); + + CHAR_setInt( pindex, CHAR_GOLD, 0); + + CHAR_send_P_StatusString( pindex , CHAR_P_STRING_GOLD); + + /* 云户匹午丹″丢永本□斥 */ + strcpy( pname, CHAR_getChar( pindex, CHAR_NAME)); + snprintf( buff, sizeof(buff), + NPC_ROOMADMINNEW_MSG_CONGRATULATION, pname, pname, pname); + failed = FALSE; + break; + } + } + + /* 竟癫樊瓜扑引凶反质 撩 及凛 */ + if( failed) { + /* 白央奶伙井日仇及 盒及树 毛壅允 */ + NPC_RoomAdminNew_WriteDataFile( meindex, -1, + CHAR_getWorkChar( meindex, CHAR_WORKCHAR_NEXTROOM), + NULL, 0); + /* 竟癫樊反中引六氏丢永本□斥 */ + snprintf( buff, sizeof(buff), + NPC_ROOMADMINNEW_MSG_NONE); + } + /* 仇及白夫失卞中月谛蝈够卞霜耨 */ + NPC_RoomAdminNew_SendMsgThisFloor( meindex, buff); + + /* 戚及 瘀午左□弁扑亦件钒疡凛棉毛本永玄 */ + NPC_RoomAdminNew_SetNextAuction( meindex); + +} +/*----------------------------------------------- + * 域 云嗯毛聂仁 匀化中月皿伊奶乩□毛茧允 + *----------------------------------------------*/ +static int NPC_RoomAdminNew_SearchPlayerHasMostMoney( int meindex) +{ + int i,j, range; + int fl,x,y, gold; + int doorindex; + int topindex; + + fl = CHAR_getInt( meindex, CHAR_FLOOR); + x = CHAR_getInt( meindex, CHAR_X); + y = CHAR_getInt( meindex, CHAR_Y); + range = CHAR_getWorkInt( meindex , CHAR_WORKINT_RANGE); + topindex = -1; + + /* 盒及 蟆井日 斓 诳嗯喊毛譬屯月 */ + doorindex = NPC_DoorSearchByName( CHAR_getWorkChar( meindex, + CHAR_WORKCHAR_NEXTROOM)); + gold = atoi( CHAR_getWorkChar( doorindex, CHAR_WORKDOORGOLDLIMIT)); + /* 区 卞中月平乓仿及醒毛譬屯月 */ + for( i = x-range ; i <= x+range ; i++ ){ + for( j = y-range ; j <= y+range ; j ++ ){ + OBJECT object; + for( object = MAP_getTopObj( fl, i,j); object; + object = NEXT_OBJECT(object) ) + { + int objindex = GET_OBJINDEX( object); + if( OBJECT_getType(objindex) == OBJTYPE_CHARA ){ + int index; + index = OBJECT_getIndex(objindex); + if( CHAR_getInt( index, + CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ) + { + if( CHAR_getInt( index, CHAR_GOLD) >= gold ) { + if( topindex == -1 ) { + topindex = index; + } + else { + /* 玄永皿及谛午云嗯 胜 */ + int nowgold,topgold; + nowgold = CHAR_getInt( index, CHAR_GOLD ); + topgold = CHAR_getInt( topindex, CHAR_GOLD); + if( nowgold > topgold ) { + topindex = index; + } + else if( nowgold == topgold ) { + /* 域踝卅日伊矛伙互斓中谛 */ + int nowlv, toplv; + nowlv = CHAR_getInt( index, CHAR_LV ); + toplv = CHAR_getInt( topindex, CHAR_LV); + if( nowlv < toplv ) { + topindex = index; + } + /* 公木匹手荸瑁仄卅中氏卅日仿件母丞元扎*/ + /* index互燮及谛互切斤匀午尕厍分仃升 */ + else if( nowlv == toplv ) { + if( RAND( 0,1)) { + topindex = index; + } + } + } + } + } + } + } + } + } + } + return( topindex); +} +/*----------------------------------------------- + * 隙烂今木凶index及白夫失卞中月皿伊奶乩□蝈够卞 + * 丢永本□斥毛霜耨允月[ + *----------------------------------------------*/ +static void NPC_RoomAdminNew_SendMsgThisFloor( int index, char *buff) +{ + int i, fl; + int playernum = CHAR_getPlayerMaxNum(); + + fl = CHAR_getInt( index, CHAR_FLOOR); + for( i = 0; i < playernum; i ++ ) { + if( CHAR_getInt( i, CHAR_FLOOR) == fl ) { + /* 及凶户皿伊奶乩□井民尼永弁 */ + if( CHAR_getInt( i, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) { + CHAR_talkToCli( i, index, buff, NPC_ROOMADMINNEW_MSGCOLOR); + } + } + } +} +/*----------------------------------------------- + * 由旦伐□玉毛戏岳允月[passlen及-1 侬互综日木月[ + * makecdn.c及天仁曰[ + *----------------------------------------------*/ +static void NPC_RoomAdminNew_CreatePasswd( char *passwd, int passlen) +{ +#define NPC_ROOMADMINNEW_RAND() ( (rand() /256) % 32768 ) /* 256匹喃月及反刭醒及 撙及凶户 */ + int i; + char *candidates[]= { + "A","B","D", "E","F","G","H", "J","K","L","M", "N","P","Q","R", + "T","W","X","Y", "a","b","d","e", "f","g","m","n", "q","r","t", + "0","1","2", "3","4","5","6", "7","8","9" + }; + strcpy( passwd , ""); + for(i = 0;i < passlen -1 ; i++){ + strcat( passwd , candidates[ NPC_ROOMADMINNEW_RAND() % (sizeof( candidates)/sizeof(candidates[0])) ] ); + } +#undef NPC_ROOMADMINNEW_RAND +} +/*----------------------------------------------- + * 栋 谛迕及白央奶伙卞犯□正毛踏五 戈 + * + * 白央奶伙 反"房间的名字.room" + * 毛银丹[ + * + * 白央奶伙及白巧□穴永玄反] + * cdkey|charaname|passwd|expiretime + * + * + * 娄醒及flg 互ㄠ分匀凶日踏五 心]ㄟ分匀凶日白央奶伙绰轮 + * 曰袄“TRUE“岳 + * FALSE:窒日井及撩 + *----------------------------------------------*/ +static BOOL NPC_RoomAdminNew_WriteDataFile( int meindex, int pindex, + char *roomname, + char *passwd, int flg) +{ + char *cdkey; + char charaname[32*2]; + char expiretime[64]; + char filename[128]; + char outbuf[1024]; + FILE *fp_src; + + /* 白央奶伙 毛戏岳 */ + strcpy( filename, NPC_ROOMADMINNEW_DATADIR); + /*strcat( filename, CHAR_getWorkChar( meindex, CHAR_WORKCHAR_NEXTROOM));*/ + strcat( filename, roomname); + strcat( filename, NPC_ROOMADMINNEW_EXTENSION); + + if( flg) { + /* 诳仄凶谛及 平□ */ + //getcdkeyFromCharaIndex( pindex, cdkey, sizeof(cdkey )); + cdkey = CHAR_getChar( pindex, CHAR_CDKEY); + /* 诳仄凶谛及平乓仿 */ + makeEscapeString( CHAR_getChar( pindex, CHAR_NAME), + charaname, sizeof( charaname)); + /* 渝蜃濠木凛棉 */ + snprintf( expiretime, sizeof( expiretime), "%d", + CHAR_getWorkInt( meindex, CHAR_WORKINT_NEXTTIME) + + NPC_ROOMADMINNEW_2WEEK /* ㄡ葱棉 */ + ); + + /* 犯伉立正匹仁仁月 */ + snprintf( outbuf, sizeof( outbuf), "%s|%s|%s|%s|", + cdkey, charaname, passwd, expiretime); + fp_src = fopen( filename, "w"); + if( !fp_src) { + print( "[%s:%d] File Open Error\n", __FILE__, __LINE__); + return FALSE; + } + fputs( outbuf, fp_src); + fclose( fp_src); + } + else { + unlink( filename); + } + + return TRUE; + +} +/*----------------------------------------------- + * 犯□正白央奶伙毛 氏匹竟癫允月 盒互丐木壬 + * 犯□正毛伞 仄化忒允[ + *----------------------------------------------*/ +BOOL NPC_RoomAdminNew_ReadFile( char *roomname, NPC_ROOMINFO *data) +{ + FILE *fp; + char line[1024]; + char buf2[128]; + char filename[128]; + + /* 白央奶伙 毛戏岳 */ + strcpy( filename, NPC_ROOMADMINNEW_DATADIR); + strcat( filename, roomname); + strcat( filename, NPC_ROOMADMINNEW_EXTENSION); + + fp = fopen( filename, "r"); + if( !fp) return FALSE; + fgets( line, sizeof( line), fp); + /* 犯□正本永玄 */ + getStringFromIndexWithDelim( line, "|" , 1 , buf2,sizeof(buf2) ); + strcpy( data->cdkey, buf2); + getStringFromIndexWithDelim( line, "|" , 2 , buf2,sizeof(buf2) ); + strcpy( data->charaname, makeStringFromEscaped( buf2)); + getStringFromIndexWithDelim( line, "|" , 3 , buf2,sizeof(buf2) ); + strcpy( data->passwd, buf2); + getStringFromIndexWithDelim( line, "|" , 4 , buf2,sizeof(buf2) ); + if( strcmp( buf2, "max") == 0 ) { + data->expire = 0xffffffff; + } + else { + data->expire = atoi( buf2); + } + fclose( fp); + return TRUE; +} +/*----------------------------------------------- + * 戚及左□弁扑亦件及凛棉午 盒 毛伐□弁卞本永玄允月 + *----------------------------------------------*/ +static BOOL NPC_RoomAdminNew_SetNextAuction( int meindex) +{ + int i, j; + int hitindex = -1; + int charnum = CHAR_getCharNum(); + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + struct tm tmwk; + + /* 卅升毛潸 允月*/ + memcpy( &tmwk, localtime( ( time_t *)&NowTime.tv_sec), sizeof( tmwk)); + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + /* 玉失毛腹绸允月[NPC_DoorSearchByName()毛银匀凶日啼分仃升 + * 蛲互聂仁卅曰公丹卅及匹仇仇左伉斥瓜伙 + */ + for( i = CHAR_getPlayerMaxNum()+ CHAR_getPetMaxNum(); + i < charnum; + i ++ ) + { + if( CHAR_getInt( i, CHAR_WHICHTYPE) != CHAR_TYPEDOOR) { + continue; + } + if( CHAR_getWorkInt( i, CHAR_WORKDOORPASSFLG) == 0 ) { + continue; + } + /* 蟆互栋喱及手及井民尼永弁允月 */ + for( j = 3; ; j ++ ) { + int rc; + char *doorname; + char buf[256]; + int dataexist; + NPC_ROOMINFO data; + + rc = getStringFromIndexWithDelim( argstr, "|" , j, + buf,sizeof(buf) ); + if( rc != TRUE ) { + break; + } + doorname = CHAR_getWorkChar( i, CHAR_WORKDOORNAME); + /* 玉失 互域谯仄凶 */ + if( strcmp( buf, doorname ) != 0 ) { + continue; + } + /* 互域谯允月 */ + if( atoi( CHAR_getWorkChar( i, CHAR_WORKDOORWEEK)) != tmwk.tm_wday) { + break; + } + /* 域杀赓渝祭 */ + memset( &data, 0, sizeof( data)); + /* 犯□正白央奶伙井日犯□正毛 戈 */ + if( NPC_RoomAdminNew_ReadFile( doorname, &data) ) { + struct tm tmdoor; + /* 仇仇匹渝蜃濠木民尼永弁毛支匀化支月[ + * 渝蜃互濠木化中凶日白央奶伙毛绰轮允月 + * 酷 读卞丐引曰仇及伙□民件骚月仪反卅中午 丹[ + */ + if( data.expire < NowTime.tv_sec) { + NPC_RoomAdminNew_WriteDataFile( meindex, -1,doorname, NULL, 0); + /* 玉失手五木中卞*/ + NPC_DoorSetPasswd( i, "8hda8iauia90494jasd9asodfasdf89"); + CHAR_setWorkInt( i, CHAR_WORKDOOREXPIRETIME, 0xffffffff); + + break; + } + /* 漆 匹濠木月 瘀卅日 */ + memcpy( &tmdoor, localtime( ( time_t *)&data.expire), sizeof( tmdoor)); + if( tmdoor.tm_mon != tmwk.tm_mon || + tmdoor.tm_mday != tmwk.tm_mday) + { + break; + } + dataexist = TRUE; + } + else { + dataexist = FALSE; + } + /* 蜇箕及凛棉方曰 匹丐月仪[ */ + if( tmwk.tm_hour > atoi( CHAR_getWorkChar( i, CHAR_WORKDOORHOUR))){ + break; + } + if( tmwk.tm_hour == atoi( CHAR_getWorkChar( i, CHAR_WORKDOORHOUR))) { + if( tmwk.tm_min >= atoi( CHAR_getWorkChar( i, CHAR_WORKDOORMINUTE))) { + break; + } + } + /* 仇仇引匹五凶日午曰丐尹内仇及玉失反戚钒疡卞请月凤伞互 + * 丐月午中丹仪[仇木井日职及玉失午民尼永弁允月[ + */ + if( hitindex == -1 ) { + hitindex = i; + } + else { + /* 钒疡凛棉互镀仁]蜇箕欧曰日木化中月午中丹及互穸燮赐匏 */ + if( atoi( CHAR_getWorkChar( hitindex, CHAR_WORKDOORHOUR)) + > atoi( CHAR_getWorkChar( i, CHAR_WORKDOORHOUR))) + { + hitindex = i; + } + else if( atoi( CHAR_getWorkChar( hitindex, CHAR_WORKDOORHOUR)) + == atoi( CHAR_getWorkChar( i, CHAR_WORKDOORHOUR))) + { + if( atoi( CHAR_getWorkChar( hitindex, CHAR_WORKDOORMINUTE)) + > atoi( CHAR_getWorkChar( i, CHAR_WORKDOORMINUTE))) + { + hitindex = i; + } + else if( atoi( CHAR_getWorkChar( hitindex, CHAR_WORKDOORMINUTE)) + == atoi( CHAR_getWorkChar( i, CHAR_WORKDOORMINUTE))) + { + NPC_ROOMINFO datawk; + int hitindexdataexist; + hitindexdataexist = NPC_RoomAdminNew_ReadFile( + CHAR_getWorkChar( hitindex, CHAR_WORKDOORNAME), + &datawk); + if( hitindexdataexist < dataexist ) { + hitindex = i; + } + /* 仇仇引匹 月方丹卅日燮及index及引引午允月[*/ + + } + } + } + } + } + if( hitindex > 0 ) { + /* 钒疡凛棉毛本永玄 */ + tmwk.tm_sec = 0; + tmwk.tm_min = atoi( CHAR_getWorkChar( hitindex, CHAR_WORKDOORMINUTE)); + tmwk.tm_hour = atoi( CHAR_getWorkChar( hitindex, CHAR_WORKDOORHOUR)); + CHAR_setWorkInt( meindex, CHAR_WORKINT_NEXTTIME, mktime( &tmwk)); + /* 盒 毛本永玄 */ + CHAR_setWorkChar( meindex, CHAR_WORKCHAR_NEXTROOM, + CHAR_getWorkChar( hitindex, CHAR_WORKDOORNAME)); + + } + else { + CHAR_setWorkInt( meindex, CHAR_WORKINT_NEXTTIME, 0); + /* 盒 毛本永玄 */ + CHAR_setWorkChar( meindex, CHAR_WORKCHAR_NEXTROOM,"" ); + + } + /* 腹绸凛棉毛本永玄 */ + CHAR_setWorkInt( meindex, CHAR_WORKINT_SEARCHROOMTIME, NowTime.tv_sec); + return( TRUE); +} +/*----------------------------------------------- + * 仄井仃日木凶谛互 盒毛欧曰化中凶日由旦伐□玉毛 憎允月 + *----------------------------------------------*/ +static void NPC_RoomAdminNew_DspRoomPasswd( int index, int adminindex, int talkerindex) +{ + int i, rc, flg = FALSE; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char argstr2[NPC_UTIL_GETARGSTR_BUFSIZE]; + char *cdkey; + char buf[128]; + char buff[16]; + char buf2[1024]; + + NPC_ROOMINFO info; + + //getcdkeyFromCharaIndex( talkerindex, cdkey, sizeof(cdkey)); + cdkey = CHAR_getChar( talkerindex, CHAR_CDKEY); + + NPC_Util_GetArgStr( adminindex, argstr, sizeof( argstr)); + for( i = 3; ; i ++ ) { + if( getStringFromIndexWithDelim(argstr, "|" , i , buf,sizeof(buf) )) { + rc = NPC_RoomAdminNew_ReadFile( buf, &info); + if( rc == TRUE ) { + /* CDKEY 午平乓仿及 蟆互域谯仄凶日 */ + if( strcmp( info.cdkey, cdkey) == 0 && + strcmp( info.charaname, + CHAR_getChar( talkerindex, CHAR_NAME)) == 0 ) + { + int doorindex; + char msgbuf[256]; + /* 盒树 潸 */ + doorindex = NPC_DoorSearchByName( buf); + NPC_Util_GetArgStr( doorindex, argstr2, sizeof( argstr2)); + getStringFromIndexWithDelim( argstr2, "|" , 9 , + buf2,sizeof(buf2) ); + /* 盒树 */ + if( strlen(CHAR_getChar( doorindex, CHAR_NAME) ) != 0 ) { + strcpy( buff, "号室"); + } + else { + buff[0] = '\0'; + } + + /* 丢永本□斥本永玄 */ + snprintf( msgbuf, sizeof( msgbuf), + NPC_ROOMADMINNEW_MSG_DSPPASSWD1, + buf2, + CHAR_getChar( doorindex, CHAR_NAME), + buff + ); + /* 丢永本□斥霜耨 */ + CHAR_talkToCli( talkerindex, index,msgbuf, + NPC_ROOMADMINNEW_MSGCOLOR); + + /* 丢永本□斥本永玄 */ + snprintf( msgbuf, sizeof( msgbuf), + NPC_ROOMADMINNEW_MSG_DSPPASSWD2, + CHAR_getWorkChar(doorindex, CHAR_WORKDOORPASSWD) + ); + /* 丢永本□斥霜耨 */ + CHAR_talkToCli( talkerindex, index,msgbuf, + NPC_ROOMADMINNEW_MSGCOLOR); + flg = TRUE; + } + } + } + else { + break; + } + } + if( !flg) { + CHAR_talkToCli( talkerindex, index, + NPC_ROOMADMINNEW_MSG_PRINTPASSWD_NONE, + NPC_ROOMADMINNEW_MSGCOLOR); + } +} +/*----------------------------------------------- + * 戚荚钒疡凛棉] 盒毛蜕丹 + *----------------------------------------------*/ +static void NPC_RoomAdminNew_DspNextAuction( int meindex, int talkerindex) +{ + char msgbuf[2048]; + time_t closetime; + + closetime = CHAR_getWorkInt( meindex, CHAR_WORKINT_NEXTTIME); + /* 戚及钒疡凛棉互瑁引匀化中卅仃木壬>瑁引匀化引六氏[=丢永本□斥*/ + if( closetime == 0 ) { + snprintf( msgbuf, sizeof( msgbuf), + NPC_ROOMADMINNEW_MSG_DSPNEXTAUCTION_NONE + ); + CHAR_talkToCli( talkerindex, meindex,msgbuf, NPC_ROOMADMINNEW_MSGCOLOR); + } + else { + int doorindex; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char explain[1024]; /* */ + char buff[16]; + struct tm tmwk; + int difftime; + /* 盒树 毛潸 */ + doorindex = NPC_DoorSearchByName( + CHAR_getWorkChar( meindex, CHAR_WORKCHAR_NEXTROOM)); + NPC_Util_GetArgStr( doorindex, argstr, sizeof( argstr)); + getStringFromIndexWithDelim(argstr, "|" , 9 , explain,sizeof(explain)); + /* 盒树 */ + if( strlen(CHAR_getChar( doorindex, CHAR_NAME) ) != 0 ) { + strcpy( buff, "号室"); + } + else { + buff[0] = '\0'; + } + snprintf( msgbuf, sizeof( msgbuf), + NPC_ROOMADMINNEW_MSG_DSPNEXTAUCTION1, + explain, + CHAR_getChar( doorindex, CHAR_NAME), + buff + ); + CHAR_talkToCli( talkerindex, meindex,msgbuf, NPC_ROOMADMINNEW_MSGCOLOR); + /* 蠡户濠曰凛棉 */ + memcpy( &tmwk, localtime( &closetime), sizeof( tmwk)); + difftime = closetime - NowTime.tv_sec; + snprintf( msgbuf, sizeof( msgbuf), + NPC_ROOMADMINNEW_MSG_DSPNEXTAUCTION2, + tmwk.tm_hour, + tmwk.tm_min, + difftime / 3600, + (difftime % 3600) / 60 + ); + CHAR_talkToCli( talkerindex, meindex,msgbuf, NPC_ROOMADMINNEW_MSGCOLOR); + + /* 票蜃嗯喊 */ + snprintf( msgbuf, sizeof( msgbuf), + NPC_ROOMADMINNEW_MSG_DSPNEXTAUCTION3, + CHAR_getWorkChar( doorindex, CHAR_WORKDOORGOLDLIMIT) + ); + CHAR_talkToCli( talkerindex, meindex,msgbuf, NPC_ROOMADMINNEW_MSGCOLOR); + } + +} +/*----------------------------------------------- + * 诳樊仿件平件弘民尼永弁↓白央奶伙踏五 心 + * + * 白央奶伙 反"管理者的名字.score" + * 件禾仿伉白央奶伙 反"管理者的名字.score.tmp" + * + * 白央奶伙白巧□穴永玄反] + * gold|time|cdkey|charaname|owntitle + * 匹ㄠㄟ垫引匹[ + * + * 曰袄“ 岳 “仿件平件弘窒匏井忒允[仿件平件弘卞 日卅仃木壬ㄟ[ + * 撩 “-1 + *----------------------------------------------*/ +static int NPC_RoomAdminNew_WriteScoreFile( int meindex, int pindex) +{ +#define NPC_RANKING_DEFAULT 10 + int ret = 0; + char *cdkey; + char charaname[32*2],owntitle[32*2]; + char filename_dest[128],filename[128]; + char outbuf[1024], line[1024]; + FILE *fp_src, *fp_dest; + + /* 白央奶伙 毛戏岳 */ + strcpy( filename, NPC_ROOMADMINNEW_DATADIR); + strcat( filename, CHAR_getWorkChar( meindex, CHAR_WORKCHAR_MYNAME)); + strcpy( filename_dest, filename); + strcat( filename, NPC_ROOMADMINNEW_RANKING_EXTENSION); + strcat( filename_dest, NPC_ROOMADMINNEW_RANKING_EXTENSION_TMP); + + /* 诳仄凶谛及 平□ */ + //getcdkeyFromCharaIndex( pindex , cdkey , sizeof(cdkey )); + cdkey = CHAR_getChar( pindex, CHAR_CDKEY); + + /* 诳仄凶谛及平乓仿 */ + makeEscapeString( CHAR_getChar( pindex, CHAR_NAME), + charaname, sizeof( charaname)); + + /* 诳仄凶谛及惫寞 */ + makeEscapeString( CHAR_getChar( pindex, CHAR_OWNTITLE), + owntitle, sizeof( owntitle)); + + /* 犯伉立正匹仁仁月 */ + snprintf( outbuf, sizeof( outbuf), "%d|%d|%s|%s|%s|\n", + CHAR_getInt( pindex, CHAR_GOLD), + CHAR_getWorkInt( meindex,CHAR_WORKINT_NEXTTIME), + cdkey, charaname, owntitle ); + + + fp_dest = fopen( filename_dest, "w"); + if( !fp_dest) return -1; + + fp_src = fopen( filename, "r"); + if( !fp_src ) { + /* 赓及域瘀卅及匹公及引引踏中化蔽歹曰 */ + fclose( fp_dest); + fp_src = fopen( filename, "w"); + if( !fp_src) return -1; + fputs( outbuf, fp_src); + fclose( fp_src); + return 1; + } + else { + int cnt = 1; + char buf[128]; + while( fgets( line, sizeof( line), fp_src)) { + getStringFromIndexWithDelim( line, "|" , 1 , buf,sizeof(buf) ); + if( ret == 0 ) { + /* 诳嗯喊 胜 */ + if( atoi( buf) < CHAR_getInt( pindex, CHAR_GOLD) ) { + /* 嗯喊互 匀化中月及匹醣 */ + fputs( outbuf, fp_dest); + fputs( line, fp_dest); + ret = cnt; + cnt ++; + } + else { + /* 公木动陆反公及引引踏仁 */ + fputs( line, fp_dest); + } + } + else { + /* 公木动陆反公及引引踏仁 */ + fputs( line, fp_dest); + } + cnt ++; + if( cnt > NPC_RANKING_DEFAULT ) break; + } + /* 仿件平件弘互ㄠㄟ蜊公欠匀化中卅中凛 */ + if( ret == 0 && cnt <= NPC_RANKING_DEFAULT ) { + fputs( outbuf, fp_dest); + ret = cnt; + } + } + fclose( fp_src); + fclose( fp_dest); + /* 褥 木晶尹 */ + /* 簿井白央奶伙戊疋□允月棵签卅 芊襞匀化凶日 尹化票今中[ */ + fp_src = fopen( filename_dest, "r"); + if( !fp_src) return -1; + fp_dest = fopen( filename, "w"); + if( !fp_dest) { + fclose( fp_src); + return -1; + } + while( fgets( line, sizeof( line), fp_src)) { + fputs( line, fp_dest); + } + fclose( fp_dest); + fclose( fp_src); + return( ret); +#undef NPC_RANKING_DEFAULT +} +/*----------------------------------------------- + * 诳樊仿件平件弘白央奶伙 心 心↓ 憎 + * + * 娄醒 meindex 平乓仿奶件犯永弁旦[仿件平件弘NPC及奶件犯永弁旦[ + * talkerindex 仄井仃日木凶谛及index[仇木卞talk毛霜耨允月[ + * admname 尕 遣盒今氏及 蟆 + * + *----------------------------------------------*/ +static void NPC_RoomAdminNew_ReadScoreFile( int meindex, int talkerindex, + char *admname) +{ + int cnt; + char filename[128]; + char line[1024]; + FILE *fp; + + /* 白央奶伙 毛戏岳 */ + strcpy( filename, NPC_ROOMADMINNEW_DATADIR); + strcat( filename, admname); + strcat( filename, NPC_ROOMADMINNEW_RANKING_EXTENSION); + + fp = fopen( filename, "r"); + if( !fp) return; + cnt = 1; + while( fgets( line, sizeof( line), fp)) { + int gold,bidtime; + char charaname[32],owntitle[32]; + char tmp[64]; + char outbuf[1024], buf[256]; + struct tm tmwk; + + getStringFromIndexWithDelim( line, "|" , 1 , buf,sizeof(buf) ); + gold = atoi(buf); + getStringFromIndexWithDelim( line, "|" , 2 , buf,sizeof(buf) ); + bidtime = atoi(buf); + getStringFromIndexWithDelim( line, "|" , 4 , buf,sizeof(buf) ); + strcpy( charaname, makeStringFromEscaped( buf)); + getStringFromIndexWithDelim( line, "|" , 5 , buf,sizeof(buf) ); + strcpy( owntitle, makeStringFromEscaped( buf)); + if( strlen( owntitle) != 0 ) { + strcpy( tmp, "["); + strcat( tmp, owntitle); + strcat( tmp, "] "); + strcpy( owntitle, tmp); + } + else { + strcpy( owntitle, " "); + } + memcpy( &tmwk, localtime( (time_t *)&bidtime), sizeof( tmwk)); + + snprintf( outbuf, sizeof( outbuf), + NPC_ROOMADMINNEW_MSG_RANKING, + cnt, + tmwk.tm_year + 1900, + tmwk.tm_mon+1, + tmwk.tm_mday, + gold,charaname,owntitle + ); + CHAR_talkToCli( talkerindex, meindex,outbuf, + NPC_RANKING_MSGCOLOR); + cnt ++; + } + fclose( fp); + +} +/************************************************ + * 赓渝质 + ************************************************/ +BOOL NPC_RankingInit( int meindex ) +{ + char buf[256]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + /* 赓渝祭质 */ + + /* type本永玄 */ + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_TYPERANKING); + /* 栋 谛及 蟆潸 */ + if( !getStringFromIndexWithDelim(argstr, "|" , 1 , buf,sizeof(buf) )) { + print( "arg err.rankingNPC not created.\n"); + return( FALSE); + } + CHAR_setWorkChar( meindex , CHAR_WORKCHAR_ADMNAME , buf); + + return TRUE; +} +/************************************************ + * 仄井仃日木凶凛及质 + ************************************************/ +void NPC_RankingTalked( int meindex , int talkerindex , char *msg , + int color ) +{ + /* 皿伊奶乩□互玉失穴件及1弘伉永玉动 卅日 杀允月[ */ + if(NPC_Util_CharDistance( talkerindex, meindex ) > 1)return; + + CHAR_talkToCli( talkerindex, meindex, + NPC_ROOMADMINNEW_MSG_RANKING_INFO, + NPC_RANKING_MSGCOLOR); + + NPC_RoomAdminNew_ReadScoreFile( meindex, talkerindex, + CHAR_getWorkChar( meindex, CHAR_WORKCHAR_ADMNAME)); + +} +/************************************************ + * 赓渝质 + ************************************************/ +BOOL NPC_PrintpassmanInit( int meindex ) +{ + char buf[256]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + /* 赓渝祭质 */ + + /* type本永玄 */ + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_TYPEPRINTPASSMAN); + /* 栋 谛及 蟆潸 */ + if( !getStringFromIndexWithDelim(argstr, "|" , 1 , buf,sizeof(buf) )) { + print( "arg err.passmanNPC not created.\n"); + return( FALSE); + } + CHAR_setWorkChar( meindex , CHAR_WORKCHAR_ADMNAME , buf); + + return TRUE; +} +/************************************************ + * 仄井仃日木凶凛及质 + ************************************************/ +void NPC_PrintpassmanTalked( int meindex , int talkerindex , char *msg , + int color ) +{ + int i; + int charnum; + /* 皿伊奶乩□互玉失穴件及2弘伉永玉动 卅日 杀允月[ */ + if(NPC_Util_CharDistance( talkerindex, meindex ) > 2)return; + + /* 愤坌迕及栋 谛及 蟆毛腹绸允月*/ + charnum = CHAR_getCharNum(); + for(i= CHAR_getPlayerMaxNum() +CHAR_getPetMaxNum(); + i +#include "object.h" +#include "char_base.h" +#include "char.h" +#include "util.h" +#include "npcutil.h" +#include "npc_oldman.h" +#include "title.h" +#include "char_data.h" +#include "readmap.h" +#include "lssproto_serv.h" +#include "log.h" + +#define RANGE 2 + + +void NPC_SetFlg(int talker,int shiftbit); +BOOL NPC_CheckFlg(int point,int shiftbit); +BOOL NPC_SavePointItemCheck(int meindex,int talker,int itemno,int kosuu); +void NPC_MessageDisp(int meindex,int talker,int MseNo); +BOOL NPC_UsedCheck(int meindex,int talker,int flg); +BOOL NPC_SavePointItemDelete(int meindex,int talker,int itemNo,int kosuu); + +extern time_t initTime; + +BOOL NPC_SavePointInit( int meindex ) +{ + int oldmanid=0, bornfl=0, bornx=0 ,borny=0; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[32]; + char buf2[512]; + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("NPC_Savepoint.c Init: GetArgStrErr"); + return FALSE; + } + + if(NPC_Util_GetStrFromStrWithDelim(argstr,"ID",buf2,sizeof( buf2) )==NULL){ + print("SavePoint:ID尚未设定 "); + return FALSE; + } + + oldmanid=atoi(buf2); + NPC_Util_GetStrFromStrWithDelim(argstr,"Born",buf2,sizeof( buf2) ); + getStringFromIndexWithDelim( buf2,",",1,token,sizeof(token)); + bornfl = atoi( token ); + getStringFromIndexWithDelim( buf2,",",2,token,sizeof(token)); + bornx = atoi( token ); + getStringFromIndexWithDelim( buf2,",",3,token,sizeof(token)); + borny = atoi( token ); + + CHAR_setWorkInt( meindex , CHAR_WORKOLDMANID ,oldmanid ); + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPESAVEPOINT ); + CHAR_setFlg( meindex , CHAR_ISATTACKED , 1 ); + + if( MAP_IsValidCoordinate( bornfl,bornx,borny )== TRUE + && CHAR_ElderSetPosition( oldmanid ,bornfl,bornx, borny ) == TRUE ){ + return TRUE; + }else{ + printf( "Invalid elder npcarg=%s\n", argstr ); + return FALSE; + } +} + +void NPC_SavePointTalked( int meindex , int talkerindex , char *msg , + int color ) +{ + int fd; + + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[512]; + char buf2[1024]; + char timeMsg[1024]; + int oldmanid; + + if( ! NPC_Util_charIsInFrontOfChar(talkerindex,meindex,RANGE) + || CHAR_getFlg( talkerindex,CHAR_ISDIE )){ + if( (CHAR_getInt(talkerindex,CHAR_X) == CHAR_getInt(meindex,CHAR_X)) + && (CHAR_getInt(talkerindex,CHAR_Y) == CHAR_getInt(meindex,CHAR_Y)) + && (CHAR_getInt(talkerindex,CHAR_FLOOR) ==CHAR_getInt(meindex,CHAR_FLOOR)) ){ + }else{ + return; + } + } + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("NPC_Savepoint.c TypeCheck: GetArgStrErr\n"); + return ; + } + + if(NPC_Util_GetStrFromStrWithDelim(argstr,"ID",buf2,sizeof( buf2) )==NULL) return ; + oldmanid=atoi(buf2); + + if(strstr(argstr,"NOITEM")!=NULL) { + NPC_SetFlg(talkerindex,oldmanid); + } + + if(NPC_CheckFlg(CHAR_getInt(talkerindex,CHAR_SAVEPOINT),oldmanid)==FALSE){ + + if(NPC_UsedCheck(meindex,talkerindex,0)==TRUE){ + NPC_MessageDisp(meindex,talkerindex,2); + }else{ + NPC_MessageDisp(meindex,talkerindex,0); + } + }else{ + CHAR_setInt( talkerindex, CHAR_LASTTALKELDER ,CHAR_getWorkInt( meindex, CHAR_WORKOLDMANID ) ); + fd = getfdFromCharaIndex( talkerindex); + if( fd != -1 ) { +#ifndef _NPC_NOSAVEPOINT + Char *chwk; + chwk = CHAR_getCharPointer( talkerindex); + // CoolFish: +1 2001/11/05 + if (!chwk) return; + + CHAR_charSaveFromConnectAndChar( fd, chwk ,FALSE ); + // Nuke 0907: For acsv test + { + CHAR_charSaveFromConnectAndChar( fd, chwk ,FALSE ); + } +#endif + } + + NPC_Util_GetStrFromStrWithDelim(argstr,"NomalMsg",token,sizeof( token) ); + sprintf(buf2,token,CHAR_getChar(talkerindex,CHAR_NAME)); + + // Robin 0619 display time + { + time_t new_t; + int dd,hh,mm,ss; + + time(&new_t); + new_t-=initTime; + + dd=(int) new_t / 86400; new_t=new_t % 86400; + hh=(int) new_t / 3600; new_t=new_t % 3600; + mm=(int) new_t / 60; new_t=new_t % 60; + ss=(int) new_t; + + if (dd>0) { + snprintf( timeMsg, sizeof( timeMsg ) , + "本星球已经启动了 %d 日 %d 小时 %d 分 %d 秒。",dd,hh,mm,ss); + } else if (hh>0) { + snprintf( timeMsg, sizeof( timeMsg ) , + "本星球已经启动了 %d 小时 %d 分 %d 秒。",hh,mm,ss); + } else { + snprintf( timeMsg, sizeof( timeMsg ) , + "本星球已经启动了 %d 分 %d 秒。",mm,ss); + } + strcat(buf2,timeMsg); + + } + { + char temp[1024]; + //char *answer;// CoolFish: Rem 2001/4/18 + extern unsigned int StateTable[]; + // Robin 03/20 万能的天神,请赐给我灌水的力量!!!! + sprintf(temp,"目前线上人数为 %d 人。当前服务端版本 : <%s>",abs(StateTable[LOGIN]),SERVER_VERSION); + strcat(buf2,temp); + + } + CHAR_talkToCli( talkerindex , meindex , buf2 , CHAR_COLORWHITE ); + + } + + + +} + + +/*----------------------------------------- + * 弁仿奶失件玄井日忒匀化五凶凛卞裟太请今木月[ + * +-------------------------------------------*/ +void NPC_SavePointWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + + /*-- 及引歹曰卞中卅中午五反蔽 --*/ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 2) { + return; + } + + if(seqno==CHAR_WINDOWTYPE_WINDOWSAVEPOINT_START){ + if(select==WINDOW_BUTTONTYPE_YES){ + if(NPC_UsedCheck(meindex,talkerindex,1)==TRUE){ + NPC_MessageDisp(meindex,talkerindex,1); + } + } + } + + +} + + +/* + *--失奶 丞及民尼永弁分仃毛垫丹 + */ +BOOL NPC_AndReduce(int meindex,int talker,char *buf,int flg) +{ + + char buf2[512]; + char buf3[256]; + int itemNo=0; + int kosuu; + int j=1; + + if(flg==0){ + + while(getStringFromIndexWithDelim(buf,"&",j,buf2,sizeof(buf2))!=FALSE) + { + j++; + /*-- ← 互丐木壬}公及失奶 丞反 醒隙烂仄化月午蜕丹啦 --*/ + if(strstr( buf2, "*") != NULL){ + getStringFromIndexWithDelim(buf2,"*",1,buf3,sizeof(buf3)); + itemNo = atoi(buf3); + getStringFromIndexWithDelim(buf2,"*",2,buf3,sizeof(buf3)); + kosuu = atoi(buf3); + + + /*--民尼永弁乒□玉--*/ + if(NPC_SavePointItemCheck(meindex,talker,itemNo,kosuu)==FALSE){ + return FALSE; + } + + }else{ + itemNo = atoi(buf2); + + /*--民尼永弁乒□玉--*/ + if(NPC_SavePointItemCheck(meindex,talker,itemNo,1)==FALSE){ + return FALSE; + } + + } + } + + }else{ + /*-- ← 互丐木壬}公及失奶 丞反 醒隙烂仄化月午蜕丹啦 --*/ + if(strstr( buf, "*") != NULL){ + getStringFromIndexWithDelim(buf,"*",1,buf3,sizeof(buf3)); + itemNo = atoi(buf3); + getStringFromIndexWithDelim(buf,"*",2,buf3,sizeof(buf3)); + kosuu = atoi(buf3); + + /*--民尼永弁乒□玉--*/ + if(NPC_SavePointItemCheck(meindex,talker,itemNo,kosuu)==FALSE){ + return FALSE; + } + + }else{ + itemNo = atoi(buf); + /*--民尼永弁乒□玉--*/ + if(NPC_SavePointItemCheck(meindex,talker,itemNo,1)==FALSE){ + return FALSE; + } + } + + } + + + return TRUE; +} + + +BOOL NPC_AndReduceDelete(int meindex,int talker,char *buf,int flg) +{ + + char buf2[512]; + char buf3[256]; + int itemNo=0; + int kosuu; + int j=1; + + if(flg==0){ + + while(getStringFromIndexWithDelim(buf,"&",j,buf2,sizeof(buf2))!=FALSE) + { + j++; + /*-- ← 互丐木壬}公及失奶 丞反 醒隙烂仄化月午蜕丹啦 --*/ + if(strstr( buf2, "*") != NULL){ + getStringFromIndexWithDelim(buf2,"*",1,buf3,sizeof(buf3)); + itemNo = atoi(buf3); + getStringFromIndexWithDelim(buf2,"*",2,buf3,sizeof(buf3)); + kosuu = atoi(buf3); + + /*--绰轮乒□玉--*/ + if(NPC_SavePointItemDelete(meindex,talker,itemNo,kosuu)==FALSE){ + return FALSE; + } + + }else{ + itemNo = atoi(buf2); + /*--绰轮乒□玉--*/ + if(NPC_SavePointItemDelete(meindex,talker,itemNo,1)==FALSE){ + return FALSE; + } + + } + } + + }else{ + /*-- ← 互丐木壬}公及失奶 丞反 醒隙烂仄化月午蜕丹啦 --*/ + if(strstr( buf, "*") != NULL){ + getStringFromIndexWithDelim(buf,"*",1,buf3,sizeof(buf3)); + itemNo = atoi(buf3); + getStringFromIndexWithDelim(buf,"*",2,buf3,sizeof(buf3)); + kosuu = atoi(buf3); + + /*--绰轮乒□玉--*/ + if(NPC_SavePointItemDelete(meindex,talker,itemNo,kosuu)==FALSE){ + return FALSE; + } + + }else{ + itemNo = atoi(buf); + + /*--绰轮乒□玉--*/ + if(NPC_SavePointItemDelete(meindex,talker,itemNo,1)==FALSE){ + return FALSE; + } + } + + } + + + return TRUE; +} + + + +/* + * 椭瘀毛苇凶仄凶井及民尼永弁 + */ +BOOL NPC_UsedCheck(int meindex,int talker,int flg) +{ + + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[128]; + char buf2[512]; + int i=1; + int checkflg=0; + + + /*--涩烂白央奶伙毛 心 心--*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("NPC_savePoint.c UseCheck: GetArgStrErr"); + return FALSE; + } + + /*-- 邰卅失奶 丞毛手匀化中月井及民尼永弁-*/ + if(NPC_Util_GetStrFromStrWithDelim(argstr,"GetItem",buf,sizeof( buf) )!=NULL) + { + i=1; + while( getStringFromIndexWithDelim(buf,",",i,buf2,sizeof(buf2)) !=FALSE ) + { + i++; + if(strstr( buf2, "&") != NULL){ + + if(NPC_AndReduce( meindex, talker, buf2,0)==TRUE) + { + checkflg=1; + break; + } + }else{ + if(NPC_AndReduce( meindex, talker, buf2,1)==TRUE) + { + checkflg=2; + break; + } + } + } + if(checkflg==0) return FALSE; + } else return TRUE; // Arminius 2.5 如果没有设 GetItem 则一律储存 + + if(flg==1){ + if(checkflg==1){ + /*--仇仇匹绰轮及质 --*/ + if(NPC_AndReduceDelete(meindex,talker,buf2,0)==FALSE){ + return FALSE; + } + }else{ + /*--仇仇匹绰轮及质 --*/ + if(NPC_AndReduceDelete(meindex,talker,buf2,1)==FALSE){ + return FALSE; + } + } + } + + return TRUE; + +} + + + +void NPC_MessageDisp(int meindex,int talker,int MesNo) +{ + + int fd = getfdFromCharaIndex( talker); + int buttontype=WINDOW_BUTTONTYPE_OK; + int windowtype=WINDOW_MESSAGETYPE_MESSAGE; + int windowno=CHAR_WINDOWTYPE_WINDOWSAVEPOINT_START; + + char token[1024]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[32]; + + /*--涩烂白央奶伙毛 心 心--*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("NPC_savePoint.c UseCheck: GetArgStrErr"); + return ; + } + + switch(MesNo){ + case 0:/*-- 邰卅失奶 丞毛手匀化中月井及民尼永弁-*/ + NPC_Util_GetStrFromStrWithDelim(argstr,"RequestMsg",token,sizeof( token) ); + + break; + + case 1:/*-- 邰卅失奶 丞毛手匀化中月井及民尼永弁-*/ + NPC_Util_GetStrFromStrWithDelim(argstr,"OkMsg",token,sizeof( token) ); + NPC_Util_GetStrFromStrWithDelim(argstr,"ID",buf,sizeof( buf) ); + NPC_SetFlg(talker,atoi(buf)); + /*--本□皮今六化丐仆月--*/ + /* 反卅仄井仃凶蛊卞}愤坌及ID毛筏盛今六月 */ + CHAR_setInt( talker, CHAR_LASTTALKELDER ,CHAR_getWorkInt( meindex, CHAR_WORKOLDMANID ) ); + + /* 本□皮允月 */ + /* 夫永弁仄化中月反内互卅中及匹失件夫永弁仄卅中 */ + fd = getfdFromCharaIndex( talker); + if( fd != -1 ) { +#ifndef _NPC_NOSAVEPOINT + Char *chwk; + chwk = CHAR_getCharPointer( talker); + // CoolFish: +1 2001/11/05 + if (!chwk) return; + CHAR_charSaveFromConnectAndChar( fd, chwk ,FALSE ); +#endif + } + + break; + + case 2:/*-- 邰卅失奶 丞毛手匀化中月井及民尼永弁-*/ + NPC_Util_GetStrFromStrWithDelim(argstr,"RealyMsg",token,sizeof( token) ); + buttontype=WINDOW_BUTTONTYPE_YESNO; + break; + + } + lssproto_WN_send( fd, windowtype, + buttontype, + windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + +} + +BOOL NPC_SavePointItemDelete(int meindex,int talker,int itemNo,int kosuu) +{ + int i; + int itemindex; + int id; + int cnt=0; + + for( i=CHAR_STARTITEMARRAY;i +#include "object.h" +#include "char_base.h" +#include "char.h" +#include "util.h" +#include "npcutil.h" +#include "npc_oldman.h" +#include "title.h" +#include "char_data.h" +#include "readmap.h" +#include "lssproto_serv.h" +#include "log.h" + +#define RANGE 2 + + +void NPC_SetFlg(int talker,int shiftbit); +BOOL NPC_CheckFlg(int point,int shiftbit); +BOOL NPC_SavePointItemCheck(int meindex,int talker,int itemno,int kosuu); +void NPC_MessageDisp(int meindex,int talker,int MseNo); +BOOL NPC_UsedCheck(int meindex,int talker,int flg); +BOOL NPC_SavePointItemDelete(int meindex,int talker,int itemNo,int kosuu); + +extern time_t initTime; + +BOOL NPC_SavePointInit( int meindex ) +{ + int oldmanid=0, bornfl=0, bornx=0 ,borny=0; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[32]; + char buf2[512]; + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("NPC_Savepoint.c Init: GetArgStrErr"); + return FALSE; + } + + if(NPC_Util_GetStrFromStrWithDelim(argstr,"ID",buf2,sizeof( buf2) )==NULL){ + print("SavePoint:ID尚未设定 "); + return FALSE; + } + + oldmanid=atoi(buf2); + NPC_Util_GetStrFromStrWithDelim(argstr,"Born",buf2,sizeof( buf2) ); + getStringFromIndexWithDelim( buf2,",",1,token,sizeof(token)); + bornfl = atoi( token ); + getStringFromIndexWithDelim( buf2,",",2,token,sizeof(token)); + bornx = atoi( token ); + getStringFromIndexWithDelim( buf2,",",3,token,sizeof(token)); + borny = atoi( token ); + + CHAR_setWorkInt( meindex , CHAR_WORKOLDMANID ,oldmanid ); + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPESAVEPOINT ); + CHAR_setFlg( meindex , CHAR_ISATTACKED , 1 ); + + if( MAP_IsValidCoordinate( bornfl,bornx,borny )== TRUE + && CHAR_ElderSetPosition( oldmanid ,bornfl,bornx, borny ) == TRUE ){ + return TRUE; + }else{ + printf( "Invalid elder npcarg=%s\n", argstr ); + return FALSE; + } +} + +void NPC_SavePointTalked( int meindex , int talkerindex , char *msg , + int color ) +{ + int fd; + + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[512]; + char buf2[1024]; + char timeMsg[1024]; + int oldmanid; + + if( ! NPC_Util_charIsInFrontOfChar(talkerindex,meindex,RANGE) + || CHAR_getFlg( talkerindex,CHAR_ISDIE )){ + if( (CHAR_getInt(talkerindex,CHAR_X) == CHAR_getInt(meindex,CHAR_X)) + && (CHAR_getInt(talkerindex,CHAR_Y) == CHAR_getInt(meindex,CHAR_Y)) + && (CHAR_getInt(talkerindex,CHAR_FLOOR) ==CHAR_getInt(meindex,CHAR_FLOOR)) ){ + }else{ + return; + } + } + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("NPC_Savepoint.c TypeCheck: GetArgStrErr\n"); + return ; + } + + if(NPC_Util_GetStrFromStrWithDelim(argstr,"ID",buf2,sizeof( buf2) )==NULL) return ; + oldmanid=atoi(buf2); + + if(strstr(argstr,"NOITEM")!=NULL) { + NPC_SetFlg(talkerindex,oldmanid); + } + + if(NPC_CheckFlg(CHAR_getInt(talkerindex,CHAR_SAVEPOINT),oldmanid)==FALSE){ + + if(NPC_UsedCheck(meindex,talkerindex,0)==TRUE){ + NPC_MessageDisp(meindex,talkerindex,2); + }else{ + NPC_MessageDisp(meindex,talkerindex,0); + } + }else{ + CHAR_setInt( talkerindex, CHAR_LASTTALKELDER ,CHAR_getWorkInt( meindex, CHAR_WORKOLDMANID ) ); + fd = getfdFromCharaIndex( talkerindex); + if( fd != -1 ) { +#ifndef _NPC_NOSAVEPOINT + Char *chwk; + chwk = CHAR_getCharPointer( talkerindex); + // CoolFish: +1 2001/11/05 + if (!chwk) return; + + CHAR_charSaveFromConnectAndChar( fd, chwk ,FALSE ); + // Nuke 0907: For acsv test + { + CHAR_charSaveFromConnectAndChar( fd, chwk ,FALSE ); + } +#endif + } + + NPC_Util_GetStrFromStrWithDelim(argstr,"NomalMsg",token,sizeof( token) ); + sprintf(buf2,token,CHAR_getChar(talkerindex,CHAR_NAME)); + + // Robin 0619 display time + { + time_t new_t; + int dd,hh,mm,ss; + + time(&new_t); + new_t-=initTime; + + dd=(int) new_t / 86400; new_t=new_t % 86400; + hh=(int) new_t / 3600; new_t=new_t % 3600; + mm=(int) new_t / 60; new_t=new_t % 60; + ss=(int) new_t; + + if (dd>0) { + snprintf( timeMsg, sizeof( timeMsg ) , + "本星球已经启动了 %d 日 %d 小时 %d 分 %d 秒。",dd,hh,mm,ss); + } else if (hh>0) { + snprintf( timeMsg, sizeof( timeMsg ) , + "本星球已经启动了 %d 小时 %d 分 %d 秒。",hh,mm,ss); + } else { + snprintf( timeMsg, sizeof( timeMsg ) , + "本星球已经启动了 %d 分 %d 秒。",mm,ss); + } + strcat(buf2,timeMsg); + + } + { + char temp[1024]; + //char *answer;// CoolFish: Rem 2001/4/18 + extern unsigned int StateTable[]; + // Robin 03/20 万能的天神,请赐给我灌水的力量!!!! + sprintf(temp,"目前线上人数为 %d 人。当前服务端版本 : <%s>",abs(StateTable[LOGIN]),SERVER_VERSION); + strcat(buf2,temp); + + + } + CHAR_talkToCli( talkerindex , meindex , buf2 , CHAR_COLORWHITE ); + + } + + + +} + + +/*----------------------------------------- + * 弁仿奶失件玄井日忒匀化五凶凛卞裟太请今木月[ + * +-------------------------------------------*/ +void NPC_SavePointWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + + /*-- 及引歹曰卞中卅中午五反蔽 --*/ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 2) { + return; + } + + if(seqno==CHAR_WINDOWTYPE_WINDOWSAVEPOINT_START){ + if(select==WINDOW_BUTTONTYPE_YES){ + if(NPC_UsedCheck(meindex,talkerindex,1)==TRUE){ + NPC_MessageDisp(meindex,talkerindex,1); + } + } + } + + +} + + +/* + *--失奶 丞及民尼永弁分仃毛垫丹 + */ +BOOL NPC_AndReduce(int meindex,int talker,char *buf,int flg) +{ + + char buf2[512]; + char buf3[256]; + int itemNo=0; + int kosuu; + int j=1; + + if(flg==0){ + + while(getStringFromIndexWithDelim(buf,"&",j,buf2,sizeof(buf2))!=FALSE) + { + j++; + /*-- ← 互丐木壬}公及失奶 丞反 醒隙烂仄化月午蜕丹啦 --*/ + if(strstr( buf2, "*") != NULL){ + getStringFromIndexWithDelim(buf2,"*",1,buf3,sizeof(buf3)); + itemNo = atoi(buf3); + getStringFromIndexWithDelim(buf2,"*",2,buf3,sizeof(buf3)); + kosuu = atoi(buf3); + + + /*--民尼永弁乒□玉--*/ + if(NPC_SavePointItemCheck(meindex,talker,itemNo,kosuu)==FALSE){ + return FALSE; + } + + }else{ + itemNo = atoi(buf2); + + /*--民尼永弁乒□玉--*/ + if(NPC_SavePointItemCheck(meindex,talker,itemNo,1)==FALSE){ + return FALSE; + } + + } + } + + }else{ + /*-- ← 互丐木壬}公及失奶 丞反 醒隙烂仄化月午蜕丹啦 --*/ + if(strstr( buf, "*") != NULL){ + getStringFromIndexWithDelim(buf,"*",1,buf3,sizeof(buf3)); + itemNo = atoi(buf3); + getStringFromIndexWithDelim(buf,"*",2,buf3,sizeof(buf3)); + kosuu = atoi(buf3); + + /*--民尼永弁乒□玉--*/ + if(NPC_SavePointItemCheck(meindex,talker,itemNo,kosuu)==FALSE){ + return FALSE; + } + + }else{ + itemNo = atoi(buf); + /*--民尼永弁乒□玉--*/ + if(NPC_SavePointItemCheck(meindex,talker,itemNo,1)==FALSE){ + return FALSE; + } + } + + } + + + return TRUE; +} + + +BOOL NPC_AndReduceDelete(int meindex,int talker,char *buf,int flg) +{ + + char buf2[512]; + char buf3[256]; + int itemNo=0; + int kosuu; + int j=1; + + if(flg==0){ + + while(getStringFromIndexWithDelim(buf,"&",j,buf2,sizeof(buf2))!=FALSE) + { + j++; + /*-- ← 互丐木壬}公及失奶 丞反 醒隙烂仄化月午蜕丹啦 --*/ + if(strstr( buf2, "*") != NULL){ + getStringFromIndexWithDelim(buf2,"*",1,buf3,sizeof(buf3)); + itemNo = atoi(buf3); + getStringFromIndexWithDelim(buf2,"*",2,buf3,sizeof(buf3)); + kosuu = atoi(buf3); + + /*--绰轮乒□玉--*/ + if(NPC_SavePointItemDelete(meindex,talker,itemNo,kosuu)==FALSE){ + return FALSE; + } + + }else{ + itemNo = atoi(buf2); + /*--绰轮乒□玉--*/ + if(NPC_SavePointItemDelete(meindex,talker,itemNo,1)==FALSE){ + return FALSE; + } + + } + } + + }else{ + /*-- ← 互丐木壬}公及失奶 丞反 醒隙烂仄化月午蜕丹啦 --*/ + if(strstr( buf, "*") != NULL){ + getStringFromIndexWithDelim(buf,"*",1,buf3,sizeof(buf3)); + itemNo = atoi(buf3); + getStringFromIndexWithDelim(buf,"*",2,buf3,sizeof(buf3)); + kosuu = atoi(buf3); + + /*--绰轮乒□玉--*/ + if(NPC_SavePointItemDelete(meindex,talker,itemNo,kosuu)==FALSE){ + return FALSE; + } + + }else{ + itemNo = atoi(buf); + + /*--绰轮乒□玉--*/ + if(NPC_SavePointItemDelete(meindex,talker,itemNo,1)==FALSE){ + return FALSE; + } + } + + } + + + return TRUE; +} + + + +/* + * 椭瘀毛苇凶仄凶井及民尼永弁 + */ +BOOL NPC_UsedCheck(int meindex,int talker,int flg) +{ + + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[128]; + char buf2[512]; + int i=1; + int checkflg=0; + + + /*--涩烂白央奶伙毛 心 心--*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("NPC_savePoint.c UseCheck: GetArgStrErr"); + return FALSE; + } + + /*-- 邰卅失奶 丞毛手匀化中月井及民尼永弁-*/ + if(NPC_Util_GetStrFromStrWithDelim(argstr,"GetItem",buf,sizeof( buf) )!=NULL) + { + i=1; + while( getStringFromIndexWithDelim(buf,",",i,buf2,sizeof(buf2)) !=FALSE ) + { + i++; + if(strstr( buf2, "&") != NULL){ + + if(NPC_AndReduce( meindex, talker, buf2,0)==TRUE) + { + checkflg=1; + break; + } + }else{ + if(NPC_AndReduce( meindex, talker, buf2,1)==TRUE) + { + checkflg=2; + break; + } + } + } + if(checkflg==0) return FALSE; + } else return TRUE; // Arminius 2.5 如果没有设 GetItem 则一律储存 + + if(flg==1){ + if(checkflg==1){ + /*--仇仇匹绰轮及质 --*/ + if(NPC_AndReduceDelete(meindex,talker,buf2,0)==FALSE){ + return FALSE; + } + }else{ + /*--仇仇匹绰轮及质 --*/ + if(NPC_AndReduceDelete(meindex,talker,buf2,1)==FALSE){ + return FALSE; + } + } + } + + return TRUE; + +} + + + +void NPC_MessageDisp(int meindex,int talker,int MesNo) +{ + + int fd = getfdFromCharaIndex( talker); + int buttontype=WINDOW_BUTTONTYPE_OK; + int windowtype=WINDOW_MESSAGETYPE_MESSAGE; + int windowno=CHAR_WINDOWTYPE_WINDOWSAVEPOINT_START; + + char token[1024]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[32]; + + /*--涩烂白央奶伙毛 心 心--*/ + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("NPC_savePoint.c UseCheck: GetArgStrErr"); + return ; + } + + switch(MesNo){ + case 0:/*-- 邰卅失奶 丞毛手匀化中月井及民尼永弁-*/ + NPC_Util_GetStrFromStrWithDelim(argstr,"RequestMsg",token,sizeof( token) ); + + break; + + case 1:/*-- 邰卅失奶 丞毛手匀化中月井及民尼永弁-*/ + NPC_Util_GetStrFromStrWithDelim(argstr,"OkMsg",token,sizeof( token) ); + NPC_Util_GetStrFromStrWithDelim(argstr,"ID",buf,sizeof( buf) ); + NPC_SetFlg(talker,atoi(buf)); + /*--本□皮今六化丐仆月--*/ + /* 反卅仄井仃凶蛊卞}愤坌及ID毛筏盛今六月 */ + CHAR_setInt( talker, CHAR_LASTTALKELDER ,CHAR_getWorkInt( meindex, CHAR_WORKOLDMANID ) ); + + /* 本□皮允月 */ + /* 夫永弁仄化中月反内互卅中及匹失件夫永弁仄卅中 */ + fd = getfdFromCharaIndex( talker); + if( fd != -1 ) { +#ifndef _NPC_NOSAVEPOINT + Char *chwk; + chwk = CHAR_getCharPointer( talker); + // CoolFish: +1 2001/11/05 + if (!chwk) return; + CHAR_charSaveFromConnectAndChar( fd, chwk ,FALSE ); +#endif + } + + break; + + case 2:/*-- 邰卅失奶 丞毛手匀化中月井及民尼永弁-*/ + NPC_Util_GetStrFromStrWithDelim(argstr,"RealyMsg",token,sizeof( token) ); + buttontype=WINDOW_BUTTONTYPE_YESNO; + break; + + } + lssproto_WN_send( fd, windowtype, + buttontype, + windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + +} + +BOOL NPC_SavePointItemDelete(int meindex,int talker,int itemNo,int kosuu) +{ + int i; + int itemindex; + int id; + int cnt=0; + + for( i=CHAR_STARTITEMARRAY;i +#include "char.h" +#include "object.h" +#include "lssproto_serv.h" +#include "npcutil.h" +#include "handletime.h" +#include "npc_scheduleman.h" +#include "family.h" + +/* + * 家族 PK 登记员 + * + * 这个 npc 显示并且登记家族 pk 排程 + * pk 排程以一小时一场 pk 为原则排定 pk 场的赛程, 这个赛程由登记员 + * 登记与设定,主要的设定事项在 FamilyPKSchedule + * + * 这个登记员同时会将这个 schedule 写入磁碟,如果 Game Server 重新 + * 启动的话,会先读入这一份对战排程表,同时进行排程。 + * 排程只排从现在开始的 24 小时之内的赛程 + * 排程表档案的格式为: + * + * time|host_index|host_name|guest_index|guest_name|prepare_time|max_player|flag|win + * + * 档案的命名: 登记员楼层号码_登记员X座标_登记员Y座标 + * + */ + +// 全部的家族 pk 赛程 +FamilyPKSchedule fmpks[MAX_SCHEDULE*MAX_SCHEDULEMAN]; + +extern int familyNumTotal; + +enum { + NPC_WORK_ID = CHAR_NPCWORKINT1, // 登记员 ID, 从 0 开始 + NPC_WORK_CHALLENGETIMEOUT = CHAR_NPCWORKINT2, // 同意挑战的 timeout + NPC_WORK_SETTINGTIMEOUT = CHAR_NPCWORKINT3, // 设定挑战的 timeout + NPC_WORK_PREVIOUSCHECKTIME = CHAR_NPCWORKINT4, // 上一次检查的时间 + NPC_WORK_FIGHTINTERVAL = CHAR_NPCWORKINT5, // PK 场次的间隔 (单位: 分) +}; + +enum { + CHAR_WORK_PAGE = CHAR_WORKSHOPRELEVANT, // 换页用 + CHAR_WORK_DUELTIME = CHAR_WORKSHOPRELEVANTSEC, // 所选择的 pk 时间 +}; + +#define SCHEDULEFILEDIR "./Schedule/" + +void NPC_LoadPKSchedule(int meindex); // Load schedule from disk +void NPC_SavePKSchedule(int meindex); // save schedule to disk +void NPC_RemoveExpiredBattle(int meindex); // 移除过期的战斗 +void NPC_ProcessTimeout(int meindex); // 处理 timeout +BOOL NPC_AlreadyScheduled(int meindex, int talkerindex); // 检查, 一个家族只能安排一场 +// 产生排程表的 data +void NPC_LIST_gendata(int meindex, int talkerindex, int page, char *buf, int size); +// 产生选择家族的 data +void NPC_SELECT_gendata(int meindex, int talkerindex, int page, char *buf, int size); +// 产生排程详细的 data +void NPC_DETAIL_gendata(int meindex, char *buf, int size, int dueltime); + +BOOL NPC_SchedulemanInit( int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + int meid; + int interval; + + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_TYPEFMSCHEDULEMAN ); + CHAR_setWorkInt ( meindex, NPC_WORK_PREVIOUSCHECKTIME, -1); + + // 参数 + NPC_Util_GetArgStr(meindex, argstr, sizeof(argstr)); + meid = NPC_Util_GetNumFromStrWithDelim(argstr, "id" ); + if ((meid<0) || (meid>=MAX_SCHEDULEMAN)) { + print("SCHEDULEMAN init error: invalid ID(%d)\n",meid); + meid=0; + } + CHAR_setWorkInt(meindex, NPC_WORK_ID, meid); + + interval = NPC_Util_GetNumFromStrWithDelim(argstr, "loopinterval" ); + if ((interval<100) || (interval>10000)) interval=1000; + CHAR_setInt(meindex, CHAR_LOOPINTERVAL, interval); + + interval = NPC_Util_GetNumFromStrWithDelim(argstr, "challengetimeout"); + if ((interval<60) || (interval>60*60)) interval=20*60; + CHAR_setWorkInt(meindex, NPC_WORK_CHALLENGETIMEOUT, interval); + + interval = NPC_Util_GetNumFromStrWithDelim(argstr, "settingtimeout"); + if ((interval<10) || (interval>60*60)) interval=60; + CHAR_setWorkInt(meindex, NPC_WORK_SETTINGTIMEOUT, interval); + + interval = NPC_Util_GetNumFromStrWithDelim(argstr, "fightinterval"); + if ((interval<5) || (interval>60)) interval = 50; + CHAR_setWorkInt(meindex, NPC_WORK_FIGHTINTERVAL, interval); + + + NPC_LoadPKSchedule(meindex); + + return TRUE; +} + +void NPC_SchedulemanTalked(int meindex, int talkerindex, char *msg, int color) +{ + char buf[4096]; + int fd; + if (NPC_Util_CharDistance(meindex, talkerindex) > 2) return; + if (!NPC_Util_isFaceToFace(meindex, talkerindex, 2)) return; + fd = getfdFromCharaIndex(talkerindex); + if (fd == -1) return; + + CHAR_setWorkInt(talkerindex, CHAR_WORK_PAGE, 0); + NPC_LIST_gendata(meindex, talkerindex, 0, buf, sizeof(buf)); + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_PKSCHEDULELIST, + WINDOW_BUTTONTYPE_NEXT | WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_SCHEDULEMAN_START, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); +} + +void NPC_SchedulemanWindowTalked(int meindex, int talkerindex, + int seqno, int select, char *data) +{ + int page; + int buttontype; + char buf[4096],token[256]; + int fd,i,dt,a; + int fmpks_pos; + + if (NPC_Util_CharDistance(meindex,talkerindex) > 2) return; + if (!NPC_Util_isFaceToFace(meindex, talkerindex, 2)) return; + fd = getfdFromCharaIndex(talkerindex); + if (fd == -1) return; + fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID)*MAX_SCHEDULE; + +// print("seqno=%d select=%d data=%s\n", seqno,select,data); + + switch (seqno) { + case CHAR_WINDOWTYPE_SCHEDULEMAN_START: + switch (select) { + case WINDOW_BUTTONTYPE_NEXT: + case WINDOW_BUTTONTYPE_PREV: + page=CHAR_getWorkInt(talkerindex, CHAR_WORK_PAGE) + + MAXSCHEDULEINONEWINDOW + * (( select == WINDOW_BUTTONTYPE_NEXT) ? 1 : -1); + buttontype=WINDOW_BUTTONTYPE_NEXT | WINDOW_BUTTONTYPE_PREV | WINDOW_BUTTONTYPE_CANCEL; + if (page<0) { + page=0; + buttontype=WINDOW_BUTTONTYPE_NEXT | WINDOW_BUTTONTYPE_CANCEL; + } + if (page>MAX_SCHEDULE-MAXSCHEDULEINONEWINDOW) { + page=MAX_SCHEDULE-MAXSCHEDULEINONEWINDOW; + buttontype=WINDOW_BUTTONTYPE_PREV | WINDOW_BUTTONTYPE_CANCEL; + } + CHAR_setWorkInt(talkerindex, CHAR_WORK_PAGE, page); + // Send WN + NPC_LIST_gendata(meindex, talkerindex, page, buf, sizeof(buf)); + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_PKSCHEDULELIST, + buttontype, + CHAR_WINDOWTYPE_SCHEDULEMAN_START, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + break; + case WINDOW_BUTTONTYPE_OK: + +#ifdef _DEATH_FAMILY_CANT_SCHEDULE // WON ADD 家族战玩家不能自行约战 + CHAR_talkToCli(talkerindex, meindex, "此星球无法约战", CHAR_COLORWHITE); + break; +#endif + + +#ifdef _FMVER21 + if ((CHAR_getInt(talkerindex,CHAR_FMLEADERFLAG)==FMMEMBER_LEADER) && +#else + if ((CHAR_getInt(talkerindex,CHAR_FMLEADERFLAG)==1) && +#endif + + (CHAR_getWorkInt(talkerindex, CHAR_WORKFMSETUPFLAG)==1)) { + // 只有已成立家族的族长可以使用进一步的功能 (设定、更改、同意) + + // decide: send family list or detail or accept + dt=atoi(data); + for (i=0; iMAXFAMILYINONEWINDOW) + buttontype |= WINDOW_BUTTONTYPE_NEXT; + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_PKSCHEDULESELECTFAMILY, + buttontype, + CHAR_WINDOWTYPE_SCHEDULEMAN_SELECT, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + + } + break; + case FMPKS_FLAG_CHALLENGE: + { // 主队族长可以重设条件,客队则是同意 pk,其他人滚蛋 + int tkfmindex=CHAR_getWorkInt(talkerindex, CHAR_WORKFMINDEXI); + if (tkfmindex==fmpks[fmpks_pos+i].host_index) { + fmpks[fmpks_pos+i].flag=FMPKS_FLAG_SETTING; + fmpks[fmpks_pos+i].setting_timeout= + CHAR_getWorkInt(meindex, NPC_WORK_SETTINGTIMEOUT); + // 送出细部调整的列表 + CHAR_setWorkInt(talkerindex, CHAR_WORK_DUELTIME, dt); + NPC_DETAIL_gendata(meindex, buf, sizeof(buf), dt); + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_PKSCHEDULEDETAIL, + WINDOW_BUTTONTYPE_OK | WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_SCHEDULEMAN_DETAIL, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + } else if (tkfmindex==fmpks[fmpks_pos+i].guest_index) { + fmpks[fmpks_pos+i].flag=FMPKS_FLAG_SCHEDULED; + page=CHAR_getWorkInt(talkerindex, CHAR_WORK_PAGE); + buttontype=WINDOW_BUTTONTYPE_NEXT | WINDOW_BUTTONTYPE_PREV | WINDOW_BUTTONTYPE_OK; + if (page<0) { + page=0; + buttontype=WINDOW_BUTTONTYPE_NEXT | WINDOW_BUTTONTYPE_OK; + } + if (page>MAX_SCHEDULE-MAXSCHEDULEINONEWINDOW) { + page=MAX_SCHEDULE-MAXSCHEDULEINONEWINDOW; + buttontype=WINDOW_BUTTONTYPE_PREV | WINDOW_BUTTONTYPE_OK; + } + CHAR_talkToCli(talkerindex, meindex, + "你的家族已经接受挑战。", CHAR_COLORWHITE); + // 重新送出 list + NPC_LIST_gendata(meindex, talkerindex, page, buf, sizeof(buf)); + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_PKSCHEDULELIST, + buttontype, + CHAR_WINDOWTYPE_SCHEDULEMAN_START, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + } + } + break; + case FMPKS_FLAG_SETTING: + { // 主队族长可以重设条件 + int tkfmindex=CHAR_getWorkInt(talkerindex, CHAR_WORKFMINDEXI); + if (tkfmindex==fmpks[fmpks_pos+i].host_index) { + fmpks[fmpks_pos+i].flag=FMPKS_FLAG_SETTING; + fmpks[fmpks_pos+i].setting_timeout= + CHAR_getWorkInt(meindex, NPC_WORK_SETTINGTIMEOUT); + // 送出细部调整的列表 + CHAR_setWorkInt(talkerindex, CHAR_WORK_DUELTIME, dt); + NPC_DETAIL_gendata(meindex, buf, sizeof(buf), dt); + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_PKSCHEDULEDETAIL, + WINDOW_BUTTONTYPE_OK | WINDOW_BUTTONTYPE_CANCEL, + CHAR_WINDOWTYPE_SCHEDULEMAN_DETAIL, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + } + } + // WON ADD 修正家族pk场的约战问题 + break; + } + + } + } + NPC_SavePKSchedule(meindex); + } else { +#ifdef _FMVER21 + if (CHAR_getInt(talkerindex,CHAR_FMLEADERFLAG)!=FMMEMBER_LEADER) { +#else + if (CHAR_getInt(talkerindex,CHAR_FMLEADERFLAG)!=1) { +#endif + CHAR_talkToCli(talkerindex, meindex, + "只有族长才能预约家族PK喔。", CHAR_COLORWHITE); + }else if (CHAR_getWorkInt(talkerindex, CHAR_WORKFMSETUPFLAG)!=1) { + CHAR_talkToCli(talkerindex, meindex, + "你的家族还没有正式成立喔。", CHAR_COLORWHITE); + } + } + break; + } + break; + case CHAR_WINDOWTYPE_SCHEDULEMAN_SELECT: + switch (select) { + case WINDOW_BUTTONTYPE_PREV: + case WINDOW_BUTTONTYPE_NEXT: + page=CHAR_getWorkInt(talkerindex, CHAR_WORK_PAGE) + + MAXFAMILYINONEWINDOW + * (( select == WINDOW_BUTTONTYPE_NEXT) ? 1 : -1); + buttontype=WINDOW_BUTTONTYPE_NEXT | WINDOW_BUTTONTYPE_PREV; + if (page<1) { + page=1; + buttontype=WINDOW_BUTTONTYPE_NEXT; + } + if (page>familyNumTotal-MAXFAMILYINONEWINDOW+1) { + page=familyNumTotal-MAXFAMILYINONEWINDOW+1; + buttontype=WINDOW_BUTTONTYPE_PREV; + } + CHAR_setWorkInt(talkerindex, CHAR_WORK_PAGE, page); + // Send WN + NPC_SELECT_gendata(meindex, talkerindex, page, buf, sizeof(buf)); + lssproto_WN_send(fd, WINDOW_MESSAGETYPE_PKSCHEDULESELECTFAMILY, + buttontype, + CHAR_WINDOWTYPE_SCHEDULEMAN_SELECT, + CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), + buf); + break; + case WINDOW_BUTTONTYPE_OK: + +#ifdef _FMVER21 + if ((CHAR_getInt(talkerindex,CHAR_FMLEADERFLAG)==FMMEMBER_LEADER) && +#else + if ((CHAR_getInt(talkerindex,CHAR_FMLEADERFLAG)==1) && +#endif + (CHAR_getWorkInt(talkerindex, CHAR_WORKFMSETUPFLAG)==1)) { + + dt=CHAR_getWorkInt(talkerindex, CHAR_WORK_DUELTIME); + for (i=0; i0) && (a<=40)) fmpks[fmpks_pos+i].prepare_time=a; + } + // 最大人数 + if (getStringFromIndexWithDelim(data,"|",5,token,sizeof(token))) { + a=atoi(token); + if ((a>0) && (a<=50)) fmpks[fmpks_pos+i].max_player=a; + } + // 胜利条件 + if (getStringFromIndexWithDelim(data,"|",6,token,sizeof(token))) { + a=atoi(token); + if ((a>=0) && (a<=1)) fmpks[fmpks_pos+i].win = a; + } + fmpks[fmpks_pos+i].flag=FMPKS_FLAG_CHALLENGE; + fmpks[fmpks_pos+i].challenge_timeout= + CHAR_getWorkInt(meindex, NPC_WORK_CHALLENGETIMEOUT); + CHAR_talkToCli(talkerindex, meindex, + "家族挑战设定完成。", CHAR_COLORWHITE); + } + break; + case WINDOW_BUTTONTYPE_CANCEL: + fmpks[fmpks_pos+i].flag=FMPKS_FLAG_NONE; + fmpks[fmpks_pos+i].host_index=-1; + strcpy(fmpks[fmpks_pos+i].host_name,""); + fmpks[fmpks_pos+i].guest_index=-1; + strcpy(fmpks[fmpks_pos+i].guest_name,""); + CHAR_talkToCli(talkerindex, meindex, + "清除家族挑战。", CHAR_COLORWHITE); + break; + } + NPC_SavePKSchedule(meindex); + } + } + } + } + break; + } +} + +void NPC_SchedulemanLoop(int meindex) +{ +// int fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID)*MAX_SCHEDULE; + +/* + print("Scheduleman: fmpks_pos=%d dueltime=%d host=%s guest=%s\n", + fmpks_pos, fmpks[fmpks_pos].dueltime, fmpks[fmpks_pos].host_name, fmpks[fmpks_pos].guest_name); +*/ + + NPC_RemoveExpiredBattle(meindex); + NPC_ProcessTimeout(meindex); +} + +// 移除过期的战斗 +void NPC_RemoveExpiredBattle(int meindex) +{ + struct tm tm1; + int keeptime; + int i,expired=-1; + int fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID)*MAX_SCHEDULE; + int prevckt = CHAR_getWorkInt(meindex, NPC_WORK_PREVIOUSCHECKTIME); + int fin = CHAR_getWorkInt(meindex, NPC_WORK_FIGHTINTERVAL); + int h,d; + + // 以目前的时刻当标准去移除过期的排程 + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + + if (tm1.tm_min=60) keeptime = keeptime + 100 - 60; + } + if (fmpks[fmpks_pos].dueltime > keeptime) expired=23; + } + + if (expired>=0) { + // 移动後面的排程来取代已经失效的排程 + for (i=expired+1; i=60 ) h=h+100-60; + if (h>=2400) { + h = h-2400; + d = 10000; + } + fmpks[fmpks_pos+i].dueltime=d+h; + } + + // 检查第一项排程, 如果不在排定的状况下则设为『无排程』 + if (fmpks[fmpks_pos].flag < FMPKS_FLAG_SCHEDULED) { + fmpks[fmpks_pos].flag = FMPKS_FLAG_NONE; + fmpks[fmpks_pos+i].host_index=-1; + strcpy(fmpks[fmpks_pos+i].host_name,""); + fmpks[fmpks_pos+i].guest_index=-1; + strcpy(fmpks[fmpks_pos+i].guest_name,""); + } + + } +} + +// 处理 timeout +void NPC_ProcessTimeout(int meindex) +{ + int i; + int fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID)*MAX_SCHEDULE; + + for (i=0; i=0) { + fmpks[fmpks_pos+i].challenge_timeout--; + if (fmpks[fmpks_pos+i].challenge_timeout<0) { + fmpks[fmpks_pos+i].host_index = -1; + strcpy(fmpks[fmpks_pos+i].host_name, "-1"); + fmpks[fmpks_pos+i].guest_index = -1; + strcpy(fmpks[fmpks_pos+i].guest_name, "-1"); + fmpks[fmpks_pos+i].prepare_time = -1; + fmpks[fmpks_pos+i].max_player = -1; + fmpks[fmpks_pos+i].flag=-1; + fmpks[fmpks_pos+i].win=-1; + } + } + } + if (fmpks[fmpks_pos+i].flag==FMPKS_FLAG_SETTING) { + if (fmpks[fmpks_pos+i].setting_timeout>=0) { + fmpks[fmpks_pos+i].setting_timeout--; + if (fmpks[fmpks_pos+i].setting_timeout<0) { + fmpks[fmpks_pos+i].host_index = -1; + strcpy(fmpks[fmpks_pos+i].host_name, "-1"); + fmpks[fmpks_pos+i].guest_index = -1; + strcpy(fmpks[fmpks_pos+i].guest_name, "-1"); + fmpks[fmpks_pos+i].prepare_time = -1; + fmpks[fmpks_pos+i].max_player = -1; + fmpks[fmpks_pos+i].flag=-1; + fmpks[fmpks_pos+i].win=-1; + } + } + } + } +} + +// 检查, 一个家族只能安排一场战斗 +BOOL NPC_AlreadyScheduled(int meindex, int talkerindex) +{ + int i; + int fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID)*MAX_SCHEDULE; + int tkfmindex = CHAR_getWorkInt(talkerindex, CHAR_WORKFMINDEXI); + int flag=1; + + for (i=0; i=FMPKS_FLAG_SCHEDULED) { + if (fmpks[fmpks_pos+i].host_index==tkfmindex) return TRUE; + } else if (fmpks[fmpks_pos+i].flag!=FMPKS_FLAG_NONE) { + if (flag==1) flag=0; else return TRUE; + } + } + return FALSE; +} + +// 读取 schedule 档案 +void NPC_LoadPKSchedule(int meindex) +{ + char filename[256],tmp[4096],token[256]; + FILE *f; + int i; + int fmpks_pos = CHAR_getWorkInt(meindex, NPC_WORK_ID)*MAX_SCHEDULE; + + snprintf(filename,sizeof(filename), "%s%d_%d_%d", + SCHEDULEFILEDIR, CHAR_getInt(meindex, CHAR_FLOOR), + CHAR_getInt(meindex, CHAR_X), + CHAR_getInt(meindex, CHAR_Y) ); + + if( ! (f=fopen( filename, "r" )) ){ // create new schedule file + f = fopen( filename, "w" ); + if( !f ){ + print( "ERROR:Can't create Schedule file %s!\n",filename ); + return; + } + for (i=0; i=MAX_SCHEDULE)) return; + + // 记录目前的时间 + memcpy( &tm1, localtime( (time_t *)&NowTime.tv_sec), sizeof( tm1)); + sprintf(buf, "%d|", tm1.tm_hour*100 + tm1.tm_min); + + for (i=page; i +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.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_sellsthman.h" +#include "pet_skill.h" + +#ifdef _NPC_SELLSTH +enum { + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT1, + + NPC_WORK_PAGE = CHAR_NPCWORKINT2, + NPC_WORK_NUM = CHAR_NPCWORKINT3, + + NPC_WORK_CALLPAGE = CHAR_NPCWORKINT4, + NPC_WORK_CALLNUM = CHAR_NPCWORKINT5, + +/* + 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, +*/ +}; +#define SELLSTHMESS_LOOP 2000 +enum{ + WINDOW_TALK=0, + WINDOW_START=10, + WINDOW_MENU, + WINDOW_LOOK, + WINDOW_CALL, + WINDOW_FIND, + WINDOW_SELLON, + WINDOW_SELLHANDLE, + WINDOW_BUYMESS, + WINDOW_BUYHANDLE, + WINDOW_HELP, + WINDOW_END, + + NPC_WINDOW_TALK=300, + NPC_WINDOW_START, + NPC_WINDOW_MENU, + NPC_WINDOW_LOOK, + NPC_WINDOW_FIND, + NPC_WINDOW_NEXT, + NPC_WINDOW_SELLON, + NPC_WINDOW_SELLHANDLE, + NPC_WINDOW_BUYMESS, + NPC_WINDOW_BUYHANDLE, + NPC_WINDOW_HELP, + NPC_WINDOW_END, + +}; + +#define MAX_LISTPAGE 20 +#define MAX_LISTNUM 12 +struct _tagNSellSthList{ + int use; + int fd; + int sellindex; + int selltype; + int uindex; + int Iindex; + char headmess[256]; + char sellmess[256]; +}NSellSthList[MAX_LISTPAGE][MAX_LISTNUM]; + +static int StructBeInit=0; + +static void NPC_SellsthMan_selectWindow( int meindex, int toindex, int num,int select, char *data); +BOOL NPC_getSellSth_ListString( int page, int num, char *ListString, int slen ); +BOOL NPC_setSellSth_ListString( int meindex, int toindex, int *page, int *num, char *data ); +BOOL NPC_getSellSth_ViewString( int page, int num, char *ListString, int slen ); +int NPC_getSellSth_FreeTiCount( void); + +void NPC_SellrePutList( int defpage, int ti) +{ + int i; + if( NSellSthList[defpage][ti].use != 0 ) return; + for( i=(ti+1); i= MAX_LISTNUM ) return; + if( NPC_getSellSth_ViewString( page, num, token, sizeof( token)) == FALSE ){ + return; + } + windowtype = WINDOWS_MESSAGETYPE_SELLSTHVIEW; + windowno = NPC_WINDOW_NEXT; + } + break; + case WINDOW_CALL: + { + int num; + int page = CHAR_getWorkInt( toindex, CHAR_WORKSHOPRELEVANT); + num = atoi( data); + if( num <0 || num >= MAX_LISTNUM ) return; + + if( NSellSthList[page][num].use == 0 )return; + if( !CHAR_CHECKINDEX( NSellSthList[page][num].sellindex) || + NSellSthList[page][num].fd != getfdFromCharaIndex( NSellSthList[page][num].sellindex) ) + return; + + sprintf( token, "%s欲购买你拍卖(%d页,%d项)的物品,\n%s正在%s。", CHAR_getChar( toindex, CHAR_NAME), + page, num, CHAR_getChar( toindex, CHAR_NAME), MAP_getFloorName( CHAR_getInt( toindex, CHAR_FLOOR)) ); + + if( CHAR_getWorkInt( NSellSthList[page][num].sellindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE ){ + CHAR_talkToCli( NSellSthList[page][num].sellindex, meindex, token, CHAR_COLORYELLOW); + }else{ + int callfd = getfdFromCharaIndex( NSellSthList[page][num].sellindex); + buttontype = WINDOW_BUTTONTYPE_OK; + windowno = NPC_WINDOW_END; + lssproto_WN_send( callfd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token); + } + return; + } + break; + case WINDOW_FIND: + { + int page, num; + page = select >> 16; + num = select & 0x0000ffff; + + page = (page<0||page>=MAX_LISTPAGE)?0:page; + num = (num<0||num>=MAX_LISTNUM)?0:num; + if( NPC_getSellSth_ListString( page, num, token, sizeof( token) ) == FALSE ) return; + windowtype = WINDOWS_MESSAGETYPE_SELLSTHMENU; + windowno = NPC_WINDOW_NEXT; + } + break; + case WINDOW_SELLON: + if( CHAR_getWorkInt( toindex, CHAR_WORKSELLSTHNUM) >= 3 ){ + CHAR_talkToCli( toindex, meindex, "最多只能登记叁次。", CHAR_COLORRED); + return; + }else if( CHAR_getInt( toindex, CHAR_GOLD) < 100 ){ + CHAR_talkToCli( toindex, meindex, "需付100石币才能登记。", CHAR_COLORRED); + return; + } + + if( NPC_getSellSth_FreeTiCount() < 1 ){ + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "FULL_MSG", token, sizeof( token) ) == NULL) { + print("SellSthMan err Can't Get FULL_MSG string\n"); + return; + } + buttontype = WINDOW_BUTTONTYPE_OK; + windowno = NPC_WINDOW_END; + }else{ + windowtype = WINDOWS_MESSAGETYPE_SELLSTHSELL; + windowno = NPC_WINDOW_SELLON; + } + break; + case WINDOW_SELLHANDLE: + { + int page, num; + if( NPC_setSellSth_ListString( meindex, toindex, &page, &num, data ) == FALSE ) { + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "ERROR_MSG", token, sizeof( token) ) == NULL) { + print("SellSthMan err Can't Get ERROR_MSG string\n"); + return; + } + }else if( NPC_Util_GetStrFromStrWithDelim( npcarg, "OK_MSG", token, sizeof( token) ) == NULL) { + print("SellSthMan err Can't Get OK_MSG string\n"); + return; + } + { + int sellnum = CHAR_getWorkInt( toindex, CHAR_WORKSELLSTHNUM); + CHAR_setWorkInt( toindex, CHAR_WORKSELLSTHNUM, sellnum+1); + CHAR_DelGold( toindex, 100); + } + buttontype = WINDOW_BUTTONTYPE_OK; + windowno = NPC_WINDOW_END; + } + break; + case WINDOW_BUYMESS: + break; + case WINDOW_BUYHANDLE: + break; + case WINDOW_HELP: + break; + case WINDOW_END: + break; + } + + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token); +} + +void NPC_SellsthManWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data) +{ + if(NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) { + if(NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) + return; + } + if( select == WINDOW_BUTTONTYPE_CANCEL || select == WINDOW_BUTTONTYPE_NO) + return; + + switch( seqno) { + case NPC_WINDOW_START: + NPC_SellsthMan_selectWindow( meindex, talkerindex, WINDOW_MENU, select, NULL); + break; + case NPC_WINDOW_MENU: + switch( atoi( data)) { + case 1://查看 + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + NPC_SellsthMan_selectWindow( meindex, talkerindex, WINDOW_FIND, 0, NULL); + break; + case 2://登记 + NPC_SellsthMan_selectWindow( meindex, talkerindex, WINDOW_SELLON, select, NULL); + break; + } + break; + case NPC_WINDOW_LOOK: + break; + case NPC_WINDOW_FIND://包含买 + break; + case NPC_WINDOW_NEXT: + { + int ti; + int page = CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT); + + if( select == WINDOW_BUTTONTYPE_PREV ){ + page = ((page-1)<0)?0:page-1; + }else if( select == WINDOW_BUTTONTYPE_NEXT ){ + page = ((page+1)>=MAX_LISTPAGE)?(MAX_LISTPAGE-1):(page+1); + }else if( select == WINDOW_BUTTONTYPE_OK ){ //买 + }else if( select == WINDOW_BUTTONTYPE_YES ){ //买 + NPC_SellsthMan_selectWindow( meindex, talkerindex, WINDOW_CALL, select, data); + return; + }else if( select == 0 ){ + NPC_SellsthMan_selectWindow( meindex, talkerindex, WINDOW_LOOK, select, data); + return; + } + ti = (page<<16); + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, page); + NPC_SellsthMan_selectWindow( meindex, talkerindex, WINDOW_FIND, ti, data); + } + break; + case NPC_WINDOW_SELLON: + NPC_SellsthMan_selectWindow( meindex, talkerindex, WINDOW_SELLHANDLE, select, data); + break; + case NPC_WINDOW_SELLHANDLE: + break; + case NPC_WINDOW_BUYMESS: + break; + case NPC_WINDOW_BUYHANDLE: + break; + case NPC_WINDOW_HELP: + break; + case NPC_WINDOW_END: + break; + } +} +static int runType = 0; +void NPC_SellsthManLoop( int meindex) +{ + int i, j; + char headmsg[256]; + char token[256]; + int playernum, page, num; + int floor = CHAR_getInt( meindex, CHAR_FLOOR); + playernum = CHAR_getPlayerMaxNum(); + + runType = (++runType)%100; + + page = CHAR_getWorkInt( meindex, NPC_WORK_CALLPAGE ); + num = CHAR_getWorkInt( meindex, NPC_WORK_CALLNUM ); + + for( i=0; i= MAX_LISTNUM ){ + num = 0; + if( ++page >= MAX_LISTPAGE ){ + page=0; + } + } + } + CHAR_setWorkInt( meindex, NPC_WORK_CALLPAGE, page); + CHAR_setWorkInt( meindex, NPC_WORK_CALLNUM, num); + if( i >= MAX_LISTNUM )return; + sprintf( headmsg, "拍卖频道(%d页%d项):%s (拍卖者:%s)。", + page, num, NSellSthList[page][num].headmess, + CHAR_getChar( NSellSthList[page][num].sellindex, CHAR_NAME) ); + if( NSellSthList[page][num].selltype==1 ){ + sprintf( token, "拍卖道具:%s。", + ITEM_getChar( NSellSthList[page][num].Iindex, ITEM_NAME) ); + }else{ + sprintf( token, "拍卖宠物:%s LV:%d %s。", + CHAR_getChar( NSellSthList[page][num].Iindex, CHAR_NAME), + CHAR_getInt( NSellSthList[page][num].Iindex, CHAR_LV), +#ifdef _PET_2TRANS + CHAR_getInt( NSellSthList[page][num].Iindex , CHAR_TRANSMIGRATION) == 2 )?"二转":(CHAR_getInt( NSellSthList[page][num].Iindex , CHAR_TRANSMIGRATION) == 1 )?"一转":"") +#else + ( CHAR_getInt( NSellSthList[page][num].Iindex , CHAR_TRANSMIGRATION) == 1 )?"转":"" +#endif + ); + } + + for(i=0; i= MAX_LISTNUM ){ + num = 0; + if( ++page >= MAX_LISTPAGE ){ + page=0; + } + } + CHAR_setWorkInt( meindex, NPC_WORK_CALLPAGE, page); + CHAR_setWorkInt( meindex, NPC_WORK_CALLNUM, num); + + if( runType%10 == 0 ){ + for( i=0; i slen ) return FALSE; + + sprintf( ListString, "%d|%d|%s", listnum, page, buff); + printf( "ANDY ListString:%s\nstrlen = %d \n", ListString, strlen( ListString) ); + + if( strlen( ListString) <= 0 ) return FALSE; + return TRUE; +} + +BOOL NPC_setSellSth_ListString( int meindex, int toindex, int *page, int *num, char *data ) +{ + char buf1[256]; + int i, j; + int fd = getfdFromCharaIndex( toindex); + + for( i=0; i MAX_LISTNUM ) return FALSE; + if( NSellSthList[page][num].use == 0 )return FALSE; + if( !CHAR_CHECKINDEX( NSellSthList[page][num].sellindex ) )return FALSE; + sellindex = NSellSthList[page][num].sellindex; + + if( NSellSthList[page][num].selltype == 1 ){//道具 + int itemindex, crushe; + ti = NSellSthList[page][num].uindex; + itemindex = CHAR_getItemIndex( sellindex , ti); + if( !ITEM_CHECKINDEX( itemindex) ) return FALSE; + crushe = ITEM_getItemDamageCrusheED( itemindex); + sprintf( buff, "1|%s|%s|0|%d|%d|%d|0|0|0|%s|||||||", + makeEscapeString( ITEM_getChar( itemindex, ITEM_SECRETNAME), buf2, sizeof( buf2)), + makeEscapeString( ITEM_getChar( itemindex, ITEM_NAME), buf1, sizeof( buf1)), + ITEM_getInt( itemindex, ITEM_BASEIMAGENUMBER), + crushe, + ITEM_getInt( itemindex, ITEM_USEPILENUMS), + ITEM_getChar( itemindex, ITEM_EFFECTSTRING) ); + }else if( NSellSthList[page][num].selltype == 2 ){//宠物 + int petindex, i; + ti = NSellSthList[page][num].uindex; + petindex = CHAR_getCharPet( sellindex, ti); + if( !CHAR_CHECKINDEX( petindex) ) return FALSE; + //TYPE|名| |图|等级|转| |攻|防|敏|技1|技2|技3|技4|技5|技6|技7 + sprintf( buff, "2|%s|%s|%d|%d|%d|%d|%d|%d|%d|", + makeEscapeString( CHAR_getChar( petindex, CHAR_NAME ), buf1, sizeof(buf1)), + makeEscapeString( CHAR_getUseName( petindex), buf2, sizeof(buf2)), + CHAR_getInt( petindex, CHAR_BASEBASEIMAGENUMBER), + CHAR_getInt( petindex , CHAR_LV), + CHAR_getInt( petindex , CHAR_TRANSMIGRATION), + CHAR_getWorkInt(petindex , CHAR_WORKMAXHP), + CHAR_getWorkInt( petindex, CHAR_WORKATTACKPOWER), + CHAR_getWorkInt( petindex, CHAR_WORKDEFENCEPOWER), + CHAR_getWorkInt( petindex, CHAR_WORKQUICK)); + + for( i=0; i<7; i++){ + int skillarray, skillID; + skillID = CHAR_getPetSkill( petindex, i); + skillarray = PETSKILL_getPetskillArray( skillID); + if( PETSKILL_CHECKINDEX( skillarray) ){ + strcat( buff, PETSKILL_getChar( skillarray, PETSKILL_NAME) ); + } + strcat( buff, "|"); + } + } + sprintf( ListString, "%d|%s|%s|%s|%s", + num, CHAR_getChar( sellindex, CHAR_NAME), + NSellSthList[page][num].headmess, + NSellSthList[page][num].sellmess, + buff ); + + if( strlen( ListString) <= 0 ){ + print("err ListString:%s strlen <= %d\n", ListString, strlen( ListString)); + return FALSE; + } + return TRUE; +} + + +int NPC_getSellSth_FreeTiCount( void) +{ + int counts = 0, i, j; + for( i=0; i +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "readmap.h" +// Arminius 8.4 manor +#include "family.h" + +static void NPC_SignBoard_Window( int meindex, int toindex, int num,int select); + + +/********************************* +* 赓渝质 +*********************************/ +BOOL NPC_SignBoardInit( int meindex ) +{ + + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + /*--正奶皿涩烂--*/ + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEMSG ); + + /*--白央奶伙互卅仃木壬准憎 毛涩 今六卅中--*/ + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr"); + return FALSE; + } + + return TRUE; + +} + + + + +/********************************* +* 苇日木凶凛及质 +*********************************/ +void NPC_SignBoardLooked( int meindex , int lookedindex) +{ + + /* 皿伊奶乩□卞覆仄化分仃 杀允月 */ + if( CHAR_getInt( lookedindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + + /* ㄠ弘伉永玉动 及心 */ + if( NPC_Util_CharDistance( lookedindex, meindex ) > 1) return; + + + NPC_SignBoard_Window( meindex, lookedindex,0,-1); + +} + + +static void NPC_SignBoard_Window( int meindex, int toindex, int num,int select) +{ + + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[1024]; + int fd = getfdFromCharaIndex( toindex); + + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr"); + return; + } + + // Arminius: manor + { + char *p,*q; + extern struct FM_POINTLIST fmpointlist; + p=strstr(npcarg, "%manorid:"); + if (p!=NULL) { + char tmp[1024]; + int a; + + q=strstr(p+1,"%"); + if (q!=NULL) { + q[0]='\0'; + p[0]='\0'; + a=atoi(p+9); +#ifdef _FAMILY_MANORNUM_CHANGE // CoolFish 用来修改装园数量 + if ((a>=1) && (a<=MANORNUM)) { +#else + if ((a>=1) && (a<=4)) { +#endif + getStringFromIndexWithDelim(fmpointlist.pointlistarray[a-1], "|", 5, token, sizeof(token)); + if (atoi(token)>=0) { + getStringFromIndexWithDelim(fmpointlist.pointlistarray[a-1], "|", 6, token, sizeof(token)); + sprintf(tmp,"%s%s%s",npcarg,token,q+1); + strcpy(npcarg, tmp); + } else { + sprintf(tmp,"%s没有任何家族%s",npcarg,q+1); + strcpy(npcarg, tmp); + } + } + } + } + } + + sprintf(token, "      < 看板 >\n%s",npcarg); + + /*--霜耨--*/ + lssproto_WN_send( fd,WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_WINDOWPETSHOP_START, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); +} + + + +/*----------------------------------------- + * 弁仿奶失件玄井日忒匀化五凶凛卞裟太请今木月[ + * +-------------------------------------------*/ +void NPC_SignBoardWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + + if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) { + return; + } +} + diff --git a/gmsv/npc/npc_simpleshop.c b/gmsv/npc/npc_simpleshop.c new file mode 100644 index 0000000..0b9ad92 --- /dev/null +++ b/gmsv/npc/npc_simpleshop.c @@ -0,0 +1,785 @@ +#include "version.h" +#include + +#include "object.h" +#include "char_base.h" +#include "char.h" +#include "item.h" +#include "util.h" +#include "handletime.h" +#include "anim_tbl.h" +#include "npc_door.h" +#include "lssproto_serv.h" +#include "npcutil.h" +#include "npccreate.h" +#include "log.h" + + +/* + * 赏读卅饕及伙□民件[by nakamura + * + * NPCARGUMENT卞俜 仄凶失奶 丞毛 蜃卞赭 仄化中月云饕[ + * SIMPLESHOP_MAXINFINITITEM潘 蜃卞戏岳允月仇午互匹五月[ + * 蜃戏岳失奶 丞午 元潘 及失奶 丞毛 匀凶日 匀凶支勾互 + * 壑钗井日壅 允月[ + * 引凶}皿伊奶乩□井日手及毛 中午月仇午互匹五月互}丐月袄蟾 + * (NPC_SIMPLESHOPMAXBUYPRICE)方曰嫖中嗯毛障 歹卅仁化反中仃 + * 卅中 潸反匹五卅中[ 中午匀凶失奶 丞反公及桦匹卅仁卅月[ + * 引凶}失奶 丞及涩烂匹cost互涩烂今木化中卅中手及手 中午木卅中[ + * 2谛动晓及皿伊奶乩□互饕卞五凶午五反} 及菸毛穸燮允月[公丹允月 + * 仇午卞方曰饕互捩菁卞簿井毛锹澎仄化中月仇午毛 什[ + * + * 正奶皿 “SimpleShop + * 健丹奶矛件玄: init, talked, specialtalked + * + * + */ +static void NPC_SimpleShopOpenShopWindow( int meindex, int cliindex, + char *npcarg ); +static void NPC_SimpleShopGetEscapedItemString( int shopindex, + int cliindex, char *str ); +static BOOL NPC_SimpleShopProcessBuyMsg( char *msg, int shop, int cli ); +static BOOL NPC_SimpleShopProcessSellMsg( char *msg, int shop, int cli ); + +static BOOL NPC_LimitBuyInShopProcessSellMsg(char *msg,int shop,int cli); + + +static BOOL NPC_SimpleShopFillItem( int meindex, char *npcarg ); +static int NPC_SimpleShopGetItemNum( int meindex ); +static void NPC_SimpleShopNormalWindow( int meindex, + int playerindex, char *str ); +static int NPC_ShopWindowIndexToItemTableIndex( int charindex, + int shopwindowindex ); +static BOOL NPC_SimpleShopOpenShopOrNot( char *msg, char *openshopstr ); +//static void NPC_SimpleShopSetLeakLevel( int meindex ); + +#define NPC_SIMPLESHOPMAXBUYPRICE 9999 +#define SIMPLESHOPTALKBUFSIZE 256 + +#define SIMPLESHOP_FATALERRSTR "好痛!对不起,最近状况不太佳。。。" + +#define SIMPLESHOP_MAXINFINITITEM 40 + +enum{ + OPENSHOPTOKEN=1, + MSGTOKEN, + MAINTOKEN, + BUYTOKEN, + OKBUYTOKEN, + SELLTOKEN, + OKSELLTOKEN, + POORTOKEN, + ITEMFULLTOKEN, + ANOTHERPLAYERTOKEN, + RAREITEMTOKEN, + THANKYOUTOKEN, + ITEMLISTTOKEN, + + BUYINITEMLISTTOKEN, + }; +void NPC_SimpleShopTalked( int meindex, int talker, char *msg, int color ) +{ +#define SHOPRANGE 3 + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE], token[NPC_UTIL_GETARGSTR_LINEMAX]; + if( CHAR_getInt( talker,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ){ + return; + } + if( NPC_Util_charIsInFrontOfChar( talker, meindex, SHOPRANGE ) + && ! CHAR_getFlg( talker,CHAR_ISDIE ) ){ + NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg)); + getStringFromIndexWithDelim( npcarg,"|", OPENSHOPTOKEN,token, sizeof(token)); + if( NPC_SimpleShopOpenShopOrNot( msg, token ) + && NPC_Util_isFaceToFace( meindex, talker, SHOPRANGE ) ){ + CHAR_setWorkInt( meindex, CHAR_WORKSHOPCLIENTINDEX, talker ); + NPC_SimpleShopOpenShopWindow( meindex, talker, npcarg ); + }else{ + int tokennum; + int i; + char tmp[NPC_UTIL_GETARGSTR_LINEMAX]; + getStringFromIndexWithDelim( npcarg,"|", MSGTOKEN,token, sizeof(token)); + tokennum = 1; + for( i=0;token[i]!='\0';i++ ){ + if( token[i] == ',' ) tokennum++; + } + getStringFromIndexWithDelim( token,",", rand()%tokennum+1,tmp, sizeof(tmp)); + CHAR_talkToCli( talker, meindex, tmp, CHAR_COLORWHITE ); + } + } +} + +void NPC_SimpleShopSpecialTalked( int meindex, int talker, char *msg, int color ) +{ + if( CHAR_getInt(talker,CHAR_WHICHTYPE) == CHAR_TYPEPLAYER + && NPC_Util_isFaceToFace( meindex, talker, SHOPRANGE ) ){ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE], token[NPC_UTIL_GETARGSTR_LINEMAX]; + NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg)); + switch( tolower(msg[0]) ){ + case 's': + { + int ret; + if( CHAR_getWorkInt(meindex,CHAR_WORKSHOPCLIENTINDEX)!= talker ){ + getStringFromIndexWithDelim( npcarg,"|",ANOTHERPLAYERTOKEN, + token, sizeof(token)); + NPC_SimpleShopNormalWindow( meindex, talker, token ); + return; + } + ret = getStringFromIndexWithDelim( msg, "|", 3, token, sizeof(token)); + if( ret == FALSE ){ + token[0] = 'e'; + token[1] = '\0'; + } + switch( tolower(token[0])){ + case 'b': + if( (ret=NPC_SimpleShopProcessBuyMsg(msg,meindex,talker)) + <0){ + switch( ret ){ + case -2: + getStringFromIndexWithDelim( npcarg,"|",POORTOKEN, + token,sizeof(token)); + NPC_SimpleShopNormalWindow( meindex,talker,token); + break; + case -3: + getStringFromIndexWithDelim( npcarg,"|", + ITEMFULLTOKEN, + token,sizeof(token)); + NPC_SimpleShopNormalWindow(meindex,talker,token); + break; + case -1: + default: + NPC_SimpleShopNormalWindow(meindex, talker, + SIMPLESHOP_FATALERRSTR + ); + break; + } + }else{ + NPC_SimpleShopFillItem( meindex, npcarg ); + getStringFromIndexWithDelim(npcarg,"|",THANKYOUTOKEN, + token, sizeof(token)); + NPC_SimpleShopNormalWindow(meindex,talker,token); + } + break; + case 's': + if( CHAR_getWorkInt(meindex,CHAR_WORKSHOPCLIENTINDEX) != talker ){ + getStringFromIndexWithDelim( npcarg,"|", + ANOTHERPLAYERTOKEN, + token, sizeof(token)); + NPC_SimpleShopNormalWindow( meindex, talker, token ); + return; + } + if((ret=NPC_SimpleShopProcessSellMsg(msg,meindex,talker)) <0 ){ + switch(ret){ + case -2: + getStringFromIndexWithDelim( npcarg,"|", + RAREITEMTOKEN, + token, sizeof(token) ); + NPC_SimpleShopNormalWindow( meindex,talker,token); + break; + case -1: + default: + NPC_SimpleShopNormalWindow(meindex, talker, + SIMPLESHOP_FATALERRSTR ); + break; + } + }else{ + getStringFromIndexWithDelim(npcarg,"|",THANKYOUTOKEN, + token, sizeof(token)); + NPC_SimpleShopNormalWindow(meindex,talker,token); + } + break; + case 'e': + default: + CHAR_setWorkInt( meindex, CHAR_WORKSHOPCLIENTINDEX, -1 ); + break; + } + break; + } + case 'i': + if( CHAR_getWorkInt(meindex,CHAR_WORKSHOPCLIENTINDEX) + == talker ){ + NPC_SimpleShopOpenShopWindow( meindex, talker, npcarg ); + } + break; + default: + break; + } + } +} + +void NPC_LimitBuyInShopSpecialTalked( int meindex, int talker, char *msg, int color ) +{ + if( CHAR_getInt(talker,CHAR_WHICHTYPE) == CHAR_TYPEPLAYER + && NPC_Util_isFaceToFace( meindex, talker, SHOPRANGE ) ){ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE], token[NPC_UTIL_GETARGSTR_LINEMAX]; + NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg)); + switch( tolower(msg[0]) ){ + case 's': + { + int ret; + if( CHAR_getWorkInt(meindex,CHAR_WORKSHOPCLIENTINDEX) != talker ){ + getStringFromIndexWithDelim( npcarg,"|", + ANOTHERPLAYERTOKEN, + token, sizeof(token)); + NPC_SimpleShopNormalWindow( meindex, talker, token ); + return; + } + ret = getStringFromIndexWithDelim( msg, "|", 3, token, sizeof( token)); + if( ret == FALSE ){ + token[0] = 'e'; + token[1] = '\0'; + } + switch( tolower(token[0])){ + case 'b': + if( ( ret = NPC_SimpleShopProcessBuyMsg( msg, meindex, talker)) < 0){ + switch( ret ){ + case -2: + getStringFromIndexWithDelim( npcarg,"|",POORTOKEN, + token,sizeof(token)); + NPC_SimpleShopNormalWindow( meindex,talker,token); + break; + case -3: + getStringFromIndexWithDelim( npcarg,"|", + ITEMFULLTOKEN, + token,sizeof(token)); + NPC_SimpleShopNormalWindow(meindex,talker,token); + break; + case -1: + default: + NPC_SimpleShopNormalWindow(meindex, talker, + SIMPLESHOP_FATALERRSTR + ); + break; + } + }else{ + NPC_SimpleShopFillItem( meindex, npcarg ); + getStringFromIndexWithDelim(npcarg,"|",THANKYOUTOKEN, + token, sizeof(token)); + NPC_SimpleShopNormalWindow(meindex,talker,token); + + } + break; + case 's': + if( CHAR_getWorkInt(meindex,CHAR_WORKSHOPCLIENTINDEX) != talker ){ + getStringFromIndexWithDelim( npcarg,"|", + ANOTHERPLAYERTOKEN, + token, sizeof(token)); + NPC_SimpleShopNormalWindow( meindex, talker, token ); + return; + } + if((ret=NPC_LimitBuyInShopProcessSellMsg( + msg,meindex,talker))<0){ + switch(ret){ + case -2: + getStringFromIndexWithDelim( npcarg,"|", + RAREITEMTOKEN, + token,sizeof(token)); + NPC_SimpleShopNormalWindow( meindex,talker,token); + break; + case -1: + default: + NPC_SimpleShopNormalWindow(meindex, talker, SIMPLESHOP_FATALERRSTR + ); + break; + } + }else{ + getStringFromIndexWithDelim(npcarg,"|",THANKYOUTOKEN, token, sizeof(token)); + NPC_SimpleShopNormalWindow(meindex,talker,token); + + } + break; + case 'e': + default: + CHAR_setWorkInt( meindex, CHAR_WORKSHOPCLIENTINDEX, -1 ); + break; + } + break; + } + case 'i': + if( CHAR_getWorkInt(meindex,CHAR_WORKSHOPCLIENTINDEX) + == talker ){ + NPC_SimpleShopOpenShopWindow( meindex, talker, npcarg ); + } + break; + default: + break; + } + } +} + + + + + +/* + * 饕互用□穴伙它奶件玉它毛请允[它奶件玉它及廿凶氏毛瓷允午} + * 赓卞饕卞 仄井仃凶午五午 元橇谪卞手升月[ + * int meindex : 饕及index + * int playerindex : 它奶件玉它毛请允皿伊奶乩□及index + * char *str : + */ +static void NPC_SimpleShopNormalWindow( int meindex, int playerindex, + char *str ) +{ + int fd; + int objindex; + char tmp[512], *name; + + objindex = CHAR_getWorkInt(meindex,CHAR_WORKOBJINDEX); + name = CHAR_getChar( meindex, CHAR_NAME ); + snprintf(tmp,sizeof(tmp),"W|%d|N|%s|123|%s", objindex, name, str ); + fd = getfdFromCharaIndex(playerindex); + if( fd == -1 ) return; + lssproto_TK_send(fd,-1,tmp,CHAR_COLORWHITE ); +} + +/* + * 饕它奶件玉它及奶件犯弁旦井日}失奶 丞 □皮伙及奶件犯弁旦卞 晶 + * 娄醒 + * int charindex:平乓仿及奶件犯弁旦 + * int shopwindowindex:饕它奶件玉它及奶件犯弁旦[0井日反元引月[ + * 忒曰袄 + * 失奶 丞 □皮伙及奶件犯弁旦[巨仿□反-1[ + */ +static int NPC_ShopWindowIndexToItemTableIndex( int charindex, + int shopwindowindex ) +{ + int i, counter; + + counter = 0; + for( i=CHAR_STARTITEMARRAY;i NPC_SIMPLESHOPMAXBUYPRICE ){ + return -2; + } + price *= NPC_Util_sellRate(playerindex); + + CHAR_AddGold( playerindex, price ); + + CHAR_sendStatusString( playerindex , "P"); + + id = ITEM_getInt(itemind,ITEM_ID); + { + LogItem( + CHAR_getChar( playerindex, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( playerindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemind, +#else + ITEM_getInt( itemind, ITEM_ID ), /* 失奶 丞 寞 */ +#endif + "Sell", + CHAR_getInt( playerindex,CHAR_FLOOR), + CHAR_getInt( playerindex,CHAR_X ), + CHAR_getInt( playerindex,CHAR_Y ), + ITEM_getChar( itemind, ITEM_UNIQUECODE), + ITEM_getChar( itemind, ITEM_NAME), + ITEM_getInt( itemind, ITEM_ID) + ); + } + + if( ! NPC_Util_moveItemToChar( shopindex,itemind,TRUE ) ){ + return -1; + } + NPC_Util_RemoveItemByID(shopindex,id,FALSE); + return 1; +} + +static BOOL NPC_LimitBuyInShopProcessSellMsg(char *msg, + int shopindex, int playerindex ) +{ + int sellwindowindex, itemtableindex,itemind, id,i,buyokflag, setid; + int price, tmpgold; + char buf[BUFSIZ]; + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE], token[NPC_UTIL_GETARGSTR_LINEMAX]; + + if(!CHAR_CHECKINDEX(shopindex)||!CHAR_CHECKINDEX(playerindex)) + return -1; + if( !getStringFromIndexWithDelim( msg,"|",4,buf,sizeof(buf) )){ + return -1; + } + sellwindowindex = atoi(buf); + itemtableindex = sellwindowindex + CHAR_STARTITEMARRAY; + itemind = CHAR_getItemIndex(playerindex,itemtableindex ); + if( ! ITEM_CHECKINDEX(itemind) ) return -1; + id = ITEM_getInt(itemind,ITEM_ID); + NPC_Util_GetArgStr( shopindex, npcarg, sizeof(npcarg)); + getStringFromIndexWithDelim( npcarg, "|", BUYINITEMLISTTOKEN, token, sizeof( token) ); + buyokflag = FALSE; + for( i=1;getStringFromIndexWithDelim(token,",",i,buf,sizeof(buf)); i++){ + + char *tok1 = NULL; + char *tok2 = NULL; + int no1=0, no2=0; + tok1 = strtok( buf, "-" ); + tok2 = strtok( NULL, "-" ); + + setid = atoi(buf); + + if( tok1 == NULL || tok2 == NULL ){ + if( setid == 0 ) return -2; + if( setid == id ) buyokflag = TRUE; + } else { + no1 = atoi( tok1 ); + no2 = atoi( tok2 ); + if( no1 <= id && id <= no2 ){ + buyokflag = TRUE; + } + } + } + if( buyokflag == FALSE ) return -2; + price = ITEM_getInt( itemind, ITEM_COST ); + price *= NPC_Util_sellRate(playerindex); + + CHAR_AddGold( playerindex, price ); + + CHAR_sendStatusString( playerindex , "P"); + if( ! NPC_Util_moveItemToChar( shopindex,itemind,TRUE ) ){ + return -1; + } + + { + LogItem( + CHAR_getChar( playerindex, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( playerindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemind, +#else + ITEM_getInt( itemind, ITEM_ID ), /* 失奶 丞 寞 */ +#endif + "Sell", + CHAR_getInt( playerindex,CHAR_FLOOR), + CHAR_getInt( playerindex,CHAR_X ), + CHAR_getInt( playerindex,CHAR_Y ), + ITEM_getChar( itemind, ITEM_UNIQUECODE), + ITEM_getChar( itemind, ITEM_NAME), + ITEM_getInt( itemind, ITEM_ID) + ); + } + + /* 中潸匀凶失奶 丞毛壅蛔 */ + NPC_Util_RemoveItemByID(shopindex,id,FALSE); + + return 1; + +} + +/* + * 饕卞丐月失奶 丞及醒毛 月 + */ +static int NPC_SimpleShopGetItemNum( int meindex ) +{ + int counter, i; + + counter = 0; + for( i=CHAR_STARTITEMARRAY;i=2 ){ /* 手切允亢及桦宁绰轮 */ + NPC_Util_RemoveItemByID(meindex,itemid,FALSE); + } + }else{ + break; + } + } + + /* 域荚仄五屯勾今木凶橇谪卞允月 */ + //NPC_SimpleShopSetLeakLevel( meindex ); + + return TRUE; +} + + +/* + * 赓渝祭允月[ + */ +BOOL NPC_SimpleShopInit( int meindex ) +{ + unsigned int mlevel; + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + + /* 域荚撩 仄凶丐午反2蘸午综日卅中方丹卞允月 */ + int createindex = CHAR_getInt( meindex, CHAR_NPCCREATEINDEX ); + +/* print("shopinit start\n" );*/ + if( NPC_CHECKCREATEINDEX(createindex) ){ + NPC_create[createindex].intdata[NPC_CREATETIME] = -1; + } + + CHAR_setInt( meindex , CHAR_HP , 0 ); + CHAR_setInt( meindex , CHAR_MP , 0 ); + CHAR_setInt( meindex , CHAR_MAXMP , 0 ); + CHAR_setInt( meindex , CHAR_STR , 0 ); + CHAR_setInt( meindex , CHAR_TOUGH, 0 ); + CHAR_setInt( meindex , CHAR_LV , 0 ); + mlevel = ((100<<16)|(100<<0)); /* 晓匏2田奶玄互 丹午五及 } + 票匏2田奶玄互 月午五及 [ */ + CHAR_setInt( meindex, CHAR_MERCHANTLEVEL, mlevel ); + + CHAR_setWorkInt( meindex, CHAR_WORKSHOPCLIENTINDEX, -1 ); + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPESHOP ); + CHAR_setFlg( meindex , CHAR_ISOVERED , 0 ); + CHAR_setFlg( meindex , CHAR_ISATTACKED , 0 ); + + NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg)); + + /* 失奶 丞 凶六月[撩 仄凶日return FALSE */ + if( ! NPC_SimpleShopFillItem( meindex,npcarg ) ){ + print( "SHOP INIT ERROR: npcarg=%s\n", npcarg ); + return FALSE; + } + +/* print("shopinit end\n" );*/ + + + return TRUE; +} + +/* + * 饕它奶件玉它毛钒仁井升丹井 烂允月[ + * npcarg及中匀仇户及玄□弁件卞 + * 仇氏卞切反,仍户氏仁分今中,仁分今中卅 + * 及方丹卞俜 今木凶 侬 毛手午卞 烂允月[仇及午五及犯伉立正反","[ + * + * 娄醒 + * msg:皿伊奶乩□互仄扎屯匀凶 侬 + * openshopstr:npcarg及中匀仇户及玄□弁件[ + * 忒曰袄 + * 钒仁卅日TRUE, 钒井卅中卅日FALSE + */ +static BOOL NPC_SimpleShopOpenShopOrNot( char *msg, char *openshopstr ) +{ + int i; + char buf[256]; + + i=1; + while(getStringFromIndexWithDelim(openshopstr,",",i,buf,sizeof(buf))){ + if( strstr( msg, buf ) ) return TRUE; + i++; + } + return FALSE; +} + +/* + * 允屯化及手切手及毛域荚摹 今木凶橇谪卞允月[ + */ +#if 0 +static void NPC_SimpleShopSetLeakLevel( int meindex ) +{ + int i, itemindex; + + for( i=CHAR_STARTITEMARRAY;i +#include +#include +#include +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "npc_stoneserviceman.h" +#include "readmap.h" +#include "battle.h" +#include "log.h" +#include "enemy.h" +#include "configfile.h" + +#ifdef _SERVICE +#define LOOP_TIME 100 //0.1秒(进入loop function 的时间) +#define MAX_AP_MSG 128 // 接收AP送来讯息的最大数 + +// socket struct +struct socketaddr_in +{ + u_short sin_family; + u_short sin_port; + u_long sin_addr; + char sin_zero[8]; +}; + +// 接收AP传来的讯息 +typedef struct _MSG +{ + int nAid; // nAid => 流水号*10 + 讯息代号(_AP_CLIENT_MESSAGE) + int nIndex; // NPC的index值 + int nLen; // 讯息长度 + LPList Data; // 实际资料 + int bIsUse; // 这个讯息是否有使用过 +}Msg,*pMsg; +Msg g_APMsg[MAX_AP_MSG]; + +// 动作id +enum _AP_CLIENT_MESSAGE +{ + Cli_CHECKPLAYER, //要求AP对玩家是否有购买产品的确认 0 + AP_CHECKPLAYER, //AP回应玩家是否有购买产品 + Cli_YES, //玩家确定要将奖品拿走 + Cli_CANCEL, //通知AP把lock栏位清为0 + Cli_GET, //通知AP给物品 + AP_GET, //AP回应物品 5 + Cli_CONNECT, //测试是否有连到AP + AP_CONNECT, //AP回应 + AP_ERROR //AP有错误 +}; + +// NPC的工作变数 +enum +{ + NPC_WORK_FLAG1 = CHAR_NPCWORKINT2, //flag1 + NPC_WORK_FLAG2 = CHAR_NPCWORKINT3, //flag2 + NPC_WORK_FLAG3 = CHAR_NPCWORKINT4, //flag3 + NPC_WORK_TIMEOUT = CHAR_NPCWORKINT5, //time out 时间 + NPC_WORK_STATE = CHAR_NPCWORKINT6, //目前执行状态 + NPC_WORK_START = CHAR_NPCWORKINT7, //开始计时flag + NPC_WORK_LEAVE_COUNT = CHAR_NPCWORKINT8, //玩家talk时间计时 + NPC_WORK_TOINDEX = CHAR_NPCWORKINT9, //玩家的index值 + NPC_WORK_SERIALNUM = CHAR_NPCWORKINT10, //流水号 + NPC_WORK_ISUSE = CHAR_NPCWORKINT11, //目前NPC是否有玩家在使用 +}; + +// 执行的状态 +enum +{ + SERVICE_STATE_1, // check 有没有和AP连线中 + SERVICE_STATE_2, // 向AP取得玩家有无买产品 + SERVICE_STATE_3, // 取得要给玩家的东西的资料 + SERVICE_STATE_4 // end state +}; + +extern int errno; + +int g_nServiceSocket; +int g_EnableService = 0; +char g_ApID[32]; +struct socketaddr_in server_sin; +struct sockaddr temp; +unsigned short g_Port; + +static void NPC_StoneServiceMan_selectWindow(int meindex,int toindex,int num,int select); +extern int GetSerialNum(void); +static int flag = 1; + +/********************************* +* 初始化 +*********************************/ +BOOL NPC_StoneServiceManInit(int meindex ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + if(NPC_Util_GetArgStr(meindex,npcarg,sizeof(npcarg)) == NULL){ + print("StoneServiceMan:GetArgStrErr"); + return FALSE; + } + + CHAR_setInt(meindex,CHAR_LOOPINTERVAL,LOOP_TIME); + CHAR_setInt(meindex,CHAR_WHICHTYPE,CHAR_TYPESTONESERVICEMAN); + CHAR_setWorkInt(meindex,NPC_WORK_FLAG1,1); + CHAR_setWorkInt(meindex,NPC_WORK_FLAG2,1); + CHAR_setWorkInt(meindex,NPC_WORK_FLAG3,1); + CHAR_setWorkInt(meindex,NPC_WORK_TIMEOUT,0); + CHAR_setWorkInt(meindex,NPC_WORK_STATE,SERVICE_STATE_2); + CHAR_setWorkInt(meindex,NPC_WORK_START,0); + CHAR_setWorkInt(meindex,NPC_WORK_TOINDEX,-1); + CHAR_setWorkInt(meindex,NPC_WORK_ISUSE,0); + CHAR_setWorkInt(meindex,NPC_WORK_LEAVE_COUNT,0); + CHAR_setWorkInt(meindex,NPC_WORK_SERIALNUM,-1); + + g_EnableService = getEnableService(); + + //连线到AP在init时只做一次 + if(flag && g_EnableService){ + strcpy(g_ApID,getApID()); + g_Port = getApPort(); + bzero(g_APMsg,sizeof(g_APMsg)); + ConnectToAP();//连线到AP + flag = 0; + } + + return TRUE; +} + +void NPC_StoneServiceManTalked(int meindex,int talkerindex,char *szMes,int color) +{ + if(CHAR_getInt(talkerindex,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER) return; + if(NPC_Util_isFaceToFace(talkerindex,meindex,1) == FALSE) return; + NPC_StoneServiceMan_selectWindow(meindex,talkerindex,0,-1); +} + +static void NPC_StoneServiceMan_selectWindow(int meindex,int toindex,int num,int select) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[1024],buf[128],*pUserid; + int buttontype = 0, windowtype = 0, windowno = 0,nAid,nLen; + int fd = getfdFromCharaIndex(toindex); + char Data[3][32],talk[128]; + int i,j,k,Ret; + LPList DataList = NULL,Kill = NULL; + + + if(fd == -1) + { + print("getfd err\n"); + return; + } + + if(NPC_Util_GetArgStr(meindex,npcarg,sizeof(npcarg)) == NULL) + { + print("GetArgStrErr"); + return ; + } + + token[0] = '\0'; + + //如果不使用石器服务员的功能 + if(!g_EnableService) + { + sprintf(token,"\n 请到此星系的最後一颗星球使用此服务,谢谢!"); + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_SERVICE_WAIT; + + lssproto_WN_send(fd,windowtype,buttontype,windowno, + CHAR_getWorkInt(meindex,CHAR_WORKOBJINDEX), + token); + return; + } + + //如果这个玩家是第一个和NPC讲话 + if(CHAR_getWorkInt(meindex,NPC_WORK_ISUSE) == 0 && + CHAR_getWorkInt(meindex,NPC_WORK_TOINDEX) == -1) + { + //记住第一个和NPC讲话的是谁 + CHAR_setWorkInt(meindex,NPC_WORK_TOINDEX,toindex); + //设定为NPC正在使用中 + CHAR_setWorkInt(meindex,NPC_WORK_ISUSE,1); + } + //如果是第二个以後和NPC讲话的人 + else if(CHAR_getWorkInt(meindex,NPC_WORK_ISUSE) == 1 && + CHAR_getWorkInt(meindex,NPC_WORK_TOINDEX) != toindex) + { + sprintf(token,"\n 正在服务其他玩家中,请稍等..."); + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_SERVICE_WAIT; + + lssproto_WN_send(fd,windowtype,buttontype,windowno, + CHAR_getWorkInt(meindex,CHAR_WORKOBJINDEX), + token); + return; + } + if(flag) + { + ConnectToAP(); + flag = 0; + } + switch(num) + { + case 0: + case 1: + //取得玩家的id + pUserid = CHAR_getChar(toindex,CHAR_CDKEY); + if(CHAR_getWorkInt(meindex,NPC_WORK_FLAG2) == 1) + { + if(pUserid == NULL || SendToAP(Cli_CHECKPLAYER,meindex,1,pUserid,NULL) == 0) + { + if(NPC_Util_GetStrFromStrWithDelim(npcarg,"SysBusyMsg",buf,sizeof(buf)) == NULL) return; + sprintf(token,"\n %s",buf); + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_SERVICE_EXIT; + break; + } + CHAR_setWorkInt(meindex,NPC_WORK_FLAG2,0); + CHAR_setWorkInt(meindex,NPC_WORK_START,1); + } + if(CHAR_getWorkInt(meindex,NPC_WORK_STATE) == SERVICE_STATE_2) + { + // 超过五秒time out + if(CHAR_getWorkInt(meindex,NPC_WORK_TIMEOUT) >= 50) + { + close(g_nServiceSocket); + flag = 1; + sprintf(token,"\n 重新与系统取得连线..."); + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_SERVICE_CONTINUE; + CHAR_setWorkInt(meindex,NPC_WORK_TIMEOUT,0); + CHAR_setWorkInt(meindex,NPC_WORK_FLAG2,1); + CHAR_setWorkInt(meindex,NPC_WORK_START,0); + break; + } + if((Ret = RecvFromAP(&nAid,meindex,&nLen,&DataList)) == -1) + { + sprintf(token,"\n 等待回应..."); + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_SERVICE_CONTINUE; + break; + } + else + { + for(i=0;iData); + Kill = DataList; + DataList = DataList->Next; + if(Kill != NULL) free(Kill); + } + // 使用过的讯息清空 + bzero(&g_APMsg[Ret],sizeof(Msg)); + } + if(nAid == AP_CHECKPLAYER) + { + switch(atoi(Data[0])) + { + case 0: //没买 + if(NPC_Util_GetStrFromStrWithDelim(npcarg,"ErrMsg",buf,sizeof(buf)) == NULL) return; + sprintf(token,"\n %s",buf); + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_SERVICE_EXIT; + break; + case 1: //有买 + if(NPC_Util_GetStrFromStrWithDelim(npcarg,"MainMsg",buf,sizeof(buf)) == NULL) return; + sprintf(token,"5\n %s" + "\n 你要将%s" + "\n 的奖品给这个角色吗?\n" + "\n" + "\n 《 确 定 》" + "\n" + "\n 《 取 消 》", + buf,Data[1]); + buttontype = WINDOW_BUTTONTYPE_NONE; + windowtype = WINDOW_MESSAGETYPE_SELECT; + windowno = CHAR_WINDOWTYPE_SERVICE_START; + break; + //另一个角色正在使用中 + case 2: + sprintf(token,"\n 目前您的另一个角色正在领取."); + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_SERVICE_EXIT; + break; + //玩家的奖品已领完 + case 3: + sprintf(token,"\n 您的奖品已经领完了!!"); + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_SERVICE_EXIT; + break; + break; + } + } + else + { + sprintf(token,"\n 系统讯息错误!!(%d)",nAid); + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_SERVICE_EXIT; + } + CHAR_setWorkInt(meindex,NPC_WORK_TIMEOUT,0); + CHAR_setWorkInt(meindex,NPC_WORK_FLAG2,1); + } + else + { + sprintf(token,"\n 等待回应..."); + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_SERVICE_CONTINUE; + } + break; + case 2: + //取得玩家的id + pUserid = CHAR_getChar(toindex,CHAR_CDKEY); + if(CHAR_getWorkInt(meindex,NPC_WORK_FLAG3) == 1){ + if(pUserid == NULL || SendToAP(Cli_GET,meindex,1,pUserid,NULL) == 0){ + if(NPC_Util_GetStrFromStrWithDelim(npcarg,"SysBusyMsg",buf,sizeof(buf)) == NULL) return; + sprintf(token,"\n %s",buf); + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_SERVICE_EXIT; + break; + } + CHAR_setWorkInt(meindex,NPC_WORK_START,1); + CHAR_setWorkInt(meindex,NPC_WORK_FLAG3,0); + } + if(CHAR_getWorkInt(meindex,NPC_WORK_STATE) == SERVICE_STATE_3){ + // 超过五秒time out + if(CHAR_getWorkInt(meindex,NPC_WORK_TIMEOUT) >= 50){ + close(g_nServiceSocket); + flag = 1; + sprintf(token,"\n 重新与系统取得连线..."); + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_SERVICE_CONTINUE; + CHAR_setWorkInt(meindex,NPC_WORK_TIMEOUT,0); + CHAR_setWorkInt(meindex,NPC_WORK_FLAG3,1); + CHAR_setWorkInt(meindex,NPC_WORK_START,0); + break; + } + if((Ret = RecvFromAP(&nAid,meindex,&nLen,&DataList)) == -1){ + sprintf(token,"\n 等待回应..."); + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_SERVICE_CONTINUE; + break; + } + else + { + for(i=0;iData); + Kill = DataList; + DataList = DataList->Next; + if(Kill != NULL) free(Kill); + } + // 使用过的讯息清空 + bzero(&g_APMsg[Ret],sizeof(Msg)); + } + if(nAid == AP_GET) + { + //如果是给钱 + //确定玩家身上有没有空的栏位 + if(atoi(Data[2]) == 0){ + if(CHAR_getInt(toindex,CHAR_GOLD)+atoi(Data[1]) > CHAR_getMaxHaveGold(toindex) ){ + sprintf(token,"\n" + "\n 你身上的空间不足以放入那麽多钱!\n"); + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_SERVICE_EXIT; + break; + }else{ + CHAR_AddGold( toindex, atoi(Data[1]) ); + + CHAR_send_P_StatusString(toindex,CHAR_P_STRING_GOLD); + LogService(CHAR_getChar(toindex,CHAR_NAME), + CHAR_getChar(toindex,CHAR_CDKEY), + atoi(Data[1]), + "钱", + CHAR_getInt(toindex,CHAR_FLOOR), + CHAR_getInt(toindex,CHAR_X), + CHAR_getInt(toindex,CHAR_Y) + ); + sprintf(talk,"%s石币已经给你喽!!\n",Data[1]); + } + } + //如果是给物品 + else if(atoi(Data[2]) == 1){ + //确定玩家身上有没有空的栏位 + int num = 0,itemindex = 0; + + for(i=CHAR_STARTITEMARRAY;i CHAR_MAXITEMNUM){ + sprintf(token,"\n" + "\n 你的道具栏空间不够!\n"); + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_SERVICE_EXIT; + break; + } + //有空的栏位 + for(j=0;j CHAR_MAXPETHAVE) + { + sprintf(token,"\n" + "\n 你的宠物栏空间不够!\n"); + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_SERVICE_EXIT; + break; + } + //有空的栏位 + for(j=0;j getLoopTime()) + { + int talkerindex,i; + char *pUserid; + + talkerindex = CHAR_getWorkInt(meindex,NPC_WORK_TOINDEX); + pUserid = CHAR_getChar(talkerindex,CHAR_CDKEY); + if(pUserid != NULL) SendToAP(Cli_CANCEL,meindex,1,pUserid,NULL); + CHAR_setWorkInt(meindex,NPC_WORK_FLAG1,1); + CHAR_setWorkInt(meindex,NPC_WORK_FLAG2,1); + CHAR_setWorkInt(meindex,NPC_WORK_FLAG3,1); + CHAR_setWorkInt(meindex,NPC_WORK_STATE,SERVICE_STATE_2); + CHAR_setWorkInt(meindex,NPC_WORK_START,0); + CHAR_setWorkInt(meindex,NPC_WORK_TIMEOUT,0); + CHAR_setWorkInt(meindex,NPC_WORK_TOINDEX,-1); + CHAR_setWorkInt(meindex,NPC_WORK_ISUSE,0); + CHAR_setWorkInt(meindex,NPC_WORK_LEAVE_COUNT,0); + CHAR_setWorkInt(meindex,NPC_WORK_SERIALNUM,-1); + //把之前收的有关这个NPC的讯息buf清空 + for(i=0;iNext; + if(kill != NULL) free(kill); + } + bzero(&g_APMsg[i],sizeof(Msg)); + } + } + } + print("Player leave NPC\n"); + return; + } + // 未超过时间则计数 + CHAR_setWorkInt(meindex,NPC_WORK_LEAVE_COUNT,++nLeaveCount); + } + + /*if(dwLifeTime > 3000) + { + SendToAP(Cli_CONNECT,meindex,0,NULL,NULL); + dwLifeTime = 0; + print("\nI'm life!!!!!"); + } + else dwLifeTime++;*/ + // NPC_WORK_START为1时计时五秒,超过五秒为time out + if(CHAR_getWorkInt(meindex,NPC_WORK_START) == 1) + { + tm.tv_sec = 0; + tm.tv_usec = 0; + FD_ZERO(&readfds); + FD_SET(g_nServiceSocket,&readfds); + // 检查AP有没有送讯息过来 + if(!select(g_nServiceSocket+1,&readfds,NULL,NULL,&tm)) + { + nTimeout = CHAR_getWorkInt(meindex,NPC_WORK_TIMEOUT); + CHAR_setWorkInt(meindex,NPC_WORK_TIMEOUT,++nTimeout); + return; + } + print("\nAP send message."); + + // 有送讯息过来接收讯息 + switch(GetMsg(meindex)) + { + //这个讯息不是给这个NPC + case 0: + print("Msg not send to this npc!!\n"); + nTimeout = CHAR_getWorkInt(meindex,NPC_WORK_TIMEOUT); + CHAR_setWorkInt(meindex,NPC_WORK_TIMEOUT,++nTimeout); + return; + case -1: break; //重新connect to ap + case -2: print("Msg buf is full!!\n"); break; // 讯息buffer用光了 + case -3: print("Msg data is wrong!!\n"); break; // 讯息内容错误 + case -4: print("calloc fail!!\n"); break; // 记忆体配置错失败 + case -5: print("\nAP send get I'm life"); break; // AP收到Cli_CONNECT的回应 + } + CHAR_setWorkInt(meindex,NPC_WORK_START,0); + } + } +} + +void NPC_StoneServiceManWindowTalked(int meindex,int talkerindex,int seqno,int select,char *data) +{ + int datanum = -1,i; + char *pUserid; + LPList Kill = NULL; + + makeStringFromEscaped(data); + datanum = atoi( data); + switch(seqno) + { + case CHAR_WINDOWTYPE_SERVICE_START: + if(datanum == 1) + { + CHAR_setWorkInt(meindex,NPC_WORK_STATE,SERVICE_STATE_3); + NPC_StoneServiceMan_selectWindow(meindex,talkerindex,2,-1); + } + else + if(datanum == 3) NPC_StoneServiceMan_selectWindow(meindex,talkerindex,3,-1); + break; + case CHAR_WINDOWTYPE_SERVICE_EXIT: + pUserid = CHAR_getChar(talkerindex,CHAR_CDKEY); + if(pUserid != NULL) SendToAP(Cli_CANCEL,meindex,1,pUserid,NULL); + CHAR_setWorkInt(meindex,NPC_WORK_FLAG1,1); + CHAR_setWorkInt(meindex,NPC_WORK_FLAG2,1); + CHAR_setWorkInt(meindex,NPC_WORK_FLAG3,1); + CHAR_setWorkInt(meindex,NPC_WORK_STATE,SERVICE_STATE_2); + CHAR_setWorkInt(meindex,NPC_WORK_START,0); + CHAR_setWorkInt(meindex,NPC_WORK_TIMEOUT,0); + CHAR_setWorkInt(meindex,NPC_WORK_TOINDEX,-1); + CHAR_setWorkInt(meindex,NPC_WORK_ISUSE,0); + CHAR_setWorkInt(meindex,NPC_WORK_LEAVE_COUNT,0); + CHAR_setWorkInt(meindex,NPC_WORK_SERIALNUM,-1); + //把之前收的有关这个NPC的讯息buf清空 + for(i=0;iNext != NULL) + { + g_APMsg[i].Data = g_APMsg[i].Data->Next; + if(Kill != NULL) free(Kill); + } + else + { + if(Kill != NULL) free(Kill); + break; + } + } + bzero(&g_APMsg[i],sizeof(Msg)); + } + } + } + break; + case CHAR_WINDOWTYPE_SERVICE_CONTINUE: + if(CHAR_getWorkInt(meindex,NPC_WORK_STATE) == SERVICE_STATE_1) + { + NPC_StoneServiceMan_selectWindow(meindex,talkerindex,0,-1); + } + if(CHAR_getWorkInt(meindex,NPC_WORK_STATE) == SERVICE_STATE_2) + { + NPC_StoneServiceMan_selectWindow(meindex,talkerindex,1,-1); + } + if(CHAR_getWorkInt(meindex,NPC_WORK_STATE) == SERVICE_STATE_3) + { + NPC_StoneServiceMan_selectWindow(meindex,talkerindex,2,-1); + } + break; + case CHAR_WINDOWTYPE_SERVICE_WAIT: + break; + default: + print("ERROR type\n"); + break; + } +} + +//送讯息到AP + +//nAid (Cli_????) nIndex (npc Index) nLen (後续资料笔数) Data1 (user cdkey) +int SendToAP(int nAid,int nIndex,int nLen,void *Data1,void *Data2) +{ + char buf[128]; + char *pData[2]; + int i,j,bufnum; + fd_set fdset; + struct timeval tmv; + int ret; + // Syu ADD 修正石器服务员星系确认 + char *sags=""; + if( strcmp ( getAccountservername() , "210.64.50.31") == 0 ) sags = "sags31"; //北斗 + if( strcmp ( getAccountservername() , "210.64.50.41") == 0 ) sags = "sags41"; //天神 + if( strcmp ( getAccountservername() , "210.64.50.51") == 0 ) sags = "sags51"; //太阳 + if( strcmp ( getAccountservername() , "210.64.50.61") == 0 ) sags = "sags61"; //紫微 + if( strcmp ( getAccountservername() , "210.64.50.71") == 0 ) sags = "sags71"; //苍龙 + if( strcmp ( getAccountservername() , "210.64.50.81") == 0 ) sags = "sags81"; //银河 + if( strcmp ( getAccountservername() , "210.64.50.91") == 0 ) sags = "sags91"; //天鹰 + if( strcmp ( getAccountservername() , "210.64.50.101") == 0 ) sags = "sags101"; //网路家庭 + if( strcmp ( getAccountservername() , "210.64.50.106") == 0 ) sags = "sags106"; //星乐园 + if( strcmp ( getAccountservername() , "210.64.50.111") == 0 ) sags = "sags111"; //圣兽 + if( strcmp ( getAccountservername() , "152.104.1.206") == 0 ) sags = "hkgs206"; //香港 + if( strcmp ( getAccountservername() , "202.134.122.130") == 0 ) sags = "hkgs130"; //新界 + + + bzero(buf,sizeof(buf)); + pData[0] = (char*)Data1; + pData[1] = (char*)Data2; + + // 以下为编码 + // 取得流水号 + nAid = GetSerialNum()*10+nAid; +// Syu ADD 修正石器服务员星系确认 + nLen=2; + + sprintf(buf,"&;%d;%d;%d;",nAid,nIndex,nLen); + CHAR_setWorkInt(nIndex,NPC_WORK_SERIALNUM,nAid/10); + if(nLen > 0) + { + // Syu ADD 修正石器服务员星系确认 + for(j = 0 ; j < 1 ; j++) + + { + for(i = strlen(buf) ; i < 128 ; i++) + { + if(*pData[j] == '\0') + break; + else if(*pData[j] == ';') + { + buf[i] = '\\'; + buf[++i] = ';'; + } + else if(*pData[j] == '\\') + { + buf[i] = '\\'; + buf[++i] = '\\'; + } + else if(*pData[j] == '&') + { + buf[i] = '\\'; + buf[++i] = '&'; + } + else buf[i] = *pData[j]; + pData[j]++; + } +// Syu ADD 修正石器服务员星系确认 + strcat(buf,";"); + strcat(buf,sags); + + buf[strlen(buf)] = ';'; + + } + } + else strcat(buf,"0;0;"); + + + memset(&buf[strlen(buf)],'&',sizeof(buf)-strlen(buf)); + + // 检查网路可不可以传送讯息 + FD_ZERO(&fdset); + FD_SET(g_nServiceSocket,&fdset); + tmv.tv_sec = tmv.tv_usec = 0; + ret = select(g_nServiceSocket + 1,(fd_set*)NULL,&fdset,(fd_set*)NULL,&tmv); + print("ret1=%d ",ret); + + + if(ret > 0) + { + // 送讯息到AP + print("\n**SendToAP**:[%s]",buf); + if((bufnum = write(g_nServiceSocket,buf,sizeof(buf))) < 0) + { + //与主机失去连线 + print("reconnect to server!\n"); + close(g_nServiceSocket); + flag = 1; + return 0; + } + print("\nSend %d bytes to AP.",bufnum); + + } + else + { + print("reconnect to server!\n"); + close(g_nServiceSocket); + flag = 1; + + return 0; + } + + return 1; +} + +//收到AP回应的讯息 +int RecvFromAP(int *nAid,int nIndex,int *nLen,LPList *Data) +{ + int i; + + for(i=0;iData = (LPList)calloc( 1,sizeof(List))) != NULL) + { + Msg->Data->Next = NULL; + tempList = Msg->Data; + break; + } + else return -4; + } + } + // 超过MAX_AP_MSG表示讯息栏都满了 + if(j == MAX_AP_MSG) return -2; + Msg->bIsUse = 1; + + // 以下为解码 + if(buf[i] == '&') + { + if(buf[++i] == ';') + { + bzero(temp[0] , sizeof(temp[0])); + bzero(temp[1] , sizeof(temp[1])); + bzero(temp[2] , sizeof(temp[2])); + for(j = 0 ; j < 3 ; j++) + { + p = strchr(&buf[i+1] , ';'); + strncpy(temp[j] , &buf[i+1] , p - (&buf[i+1])); + i += strlen(temp[j]) + 1; + } + Msg->nAid = atoi(temp[0]); + Msg->nIndex = atoi(temp[1]); + Msg->nLen = atoi(temp[2]); + // 如果收到的是AP_CONNECT不理这个讯息 + if(Msg->nAid%10 == AP_CONNECT) + { + free(Msg->Data); + bzero(Msg,sizeof(Msg)); + return -5; + } + j = 0; + + bzero(temp[0] , sizeof(temp[0])); + + if(Msg->nLen > 0) + { + while(buf[++i] != '\0') + { + switch(buf[i]) + { + case '\\': + switch(buf[i + 1]) + { + case ';': + case '&': + case '\\': + temp[0][j++] = buf[++i]; + break; + default: + temp[0][j++] = buf[i++]; + break; + } + break; + case ';': + j = 0; + strcpy(tempList->Data,temp[0]); + tempList->Next = (LPList)calloc( 1,sizeof(List)); + tempList = tempList->Next; + bzero(temp[0],sizeof(temp[0])); + break; + case '&': + buf[i--] = '\0'; + break; + default: + temp[0][j++] = buf[i]; + break; + } + } + tempList->Next = NULL; + // 如果这个讯息是给这个NPC return 1 + if(Msg->nIndex == meindex) return 1; + else return 0; + } + } + } + else return -3; + + return 1; +} + +int ConnectToAP(void) +{ + //make socket and connect to ap + if((g_nServiceSocket = socket(PF_INET,SOCK_STREAM,0)) < 0) + //if((g_nServiceSocket = socket(PF_INET,SOCK_DGRAM,0)) < 0) + { + print("can't create socket!\n"); + return 0; + } + bzero((char*)&server_sin , sizeof(server_sin)); + server_sin.sin_family = AF_INET; + server_sin.sin_port = htons(g_Port); + server_sin.sin_addr = inet_addr(g_ApID); + memcpy(&temp , &server_sin , sizeof(server_sin)); + if(connect(g_nServiceSocket,&temp,sizeof(temp)) < 0) + { +// print("connect server error: %s\n" , sys_errlist[errno]); + print("connect server error !!\n"); + print("ip:%s,port:%d\n",g_ApID,g_Port); + return 0; + } + else print("connect AP server success!\n"); + + return 1; +} + +//取得流水号 +int GetSerialNum(void) +{ + static int i = 0; + + if(++i > 65535) + { + i = 0; + } + return i; +} + +#endif diff --git a/gmsv/npc/npc_storyteller.c b/gmsv/npc/npc_storyteller.c new file mode 100644 index 0000000..c9a4385 --- /dev/null +++ b/gmsv/npc/npc_storyteller.c @@ -0,0 +1,68 @@ +#include "version.h" +#include "char.h" + +/* + + + 井凶曰屯[ + + 伉伉□旦 匹反2潘 及仇午分引[ + + NPCARGUMENT: 0分匀凶日仇午分引0}1分匀凶日仇午分引1及贿曰 [ + + 橇谪反3勾丐曰}赐卞褡垫允月[ + + 橇谪0“ 失奶玉伉件弘[仇及橇谪匹talk今木月午} + >方仁五凶}幻仆幻仆方[中井卞手}歹仄互鳗 及井凶曰屯元扎[=匹 + 橇谪1卞啖垫[ + 橇谪1“talk今木凶日} + >公卅凶互及冗戈卅日壬}熔午夫五井尹卞}雄 卅蜕昵毛夫午勾} 今内仃方丹[ + 公及蜕昵毛及冗戈井? yes/no=yes匹橇谪2尺[no匹 + >匹反}今日壬元扎[=匹橇谪0尺 + + 橇谪2“ talk今木凶日} + >公卅凶卞鳗 及蜕昵>幻仆幻仆=毛鳗噩仄凶[ 及勾亢卞 濠卅手及午仄化 + 域戏 濠卞允月屯仄[今日壬元扎[= + 午中匀化熔毛蛹日仄}蜕昵白仿弘毛馨笛允月[ + 匹橇谪0卞手升月[ + + + + + Talked: + + if( 卞反卅仄化井日1坌凶匀化中月井"){ + 橇谪0卞手升月[ + } + + switch(橇谪){ + case 0: 质 [橇谪1尺[break; + case 1: 质 [橇谪2尺[break; + case 2: 质 [橇谪0尺[break; + } + + } + + + + + + + + + + */ +BOOL NPC_StoryTellerInit( int meindex ) +{ + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPESTORYTELLER ); + CHAR_setFlg( meindex , CHAR_ISATTACKED , 0 ); + CHAR_setFlg( meindex , CHAR_ISOVERED , 0 ); + + return TRUE; +} + + +void NPC_StoryTellerTalked( int meindex , int talker , char *msg , int col ) +{ + +} diff --git a/gmsv/npc/npc_sysinfo.c b/gmsv/npc/npc_sysinfo.c new file mode 100644 index 0000000..f3648e5 --- /dev/null +++ b/gmsv/npc/npc_sysinfo.c @@ -0,0 +1,875 @@ +#include "version.h" +#include +#include "char.h" +#include "char_event.h" +#include "object.h" +#include "handletime.h" +#include "magic.h" +#include "npcutil.h" +#include "char_data.h" +#include "chatmagic.h" +#include "net.h" +#include "configfile.h" +#include "npcgen.h" + +/* +--------------------------------------------------------------------- +sysinfo By Kawata +--------------------------------------------------------------------- +*/ + +#define NPC_SYSINFO_MSGMAX 21 + +#define NPC_SYSINFO_PASSWD_DEFAULT "G00d1uck" + +#define NPC_SYSINFO_TIMELIMIT_DEFAULT 120 + +#define NPC_SYSINFO_SHUTDOWNLIMIT_DEFAULT 5 + +#define NPC_SYSINFO_SHUTDOWN_MSG "再过 %d 分钟後,即开始进行server系统维护。" + +#define NPC_SYSINFO_SHUTDOWN_MSG_COMP "server已关闭。" +enum { + CHAR_WORK_MODE = CHAR_NPCWORKINT1, + CHAR_WORK_TIME = CHAR_NPCWORKINT2, + CHAR_WORK_TIMELIMIT = CHAR_NPCWORKINT3, + CHAR_WORK_SHUTDOWNTIME = CHAR_NPCWORKINT4, + CHAR_WORK_SHUTDOWNLIMIT = CHAR_NPCWORKINT5, + CHAR_WORK_SHUTDOWNDSPTIME = CHAR_NPCWORKINT6, + CHAR_WORK_MSGCOLOR = CHAR_NPCWORKINT7, + CHAR_WORK_PLAYER = CHAR_NPCWORKINT8, +}; + +enum { + CHAR_WORKCHAR_PASSWD = CHAR_NPCWORKCHAR1, +}; +typedef struct { + char msg[16]; +}CMD_MSG; +CMD_MSG cmd_msg[] = { + { "startinfo"}, {"endinfo"}, {"help"}, + {"player"}, {"list"}, {"sendno"}, + {"sendmsg"}, {"shutdown"}, {"msgcol"}, + {"sysinfo"}, {"info"}, + { "allowaccept" } , { "denyaccept" } , + { "closeallsockets" }, + { "allnosee" }, + { "allnobody" }, + { "movenum" }, + { "bornnum" }, + { "enemystate" }, + { "setwalktime"},{ "setcatime" },{"setcdtime"}, + { "setoneloop"}, + { "titlerestart"}, + { "setsaacwrite"}, { "setsaacread"}, +}; +enum{ + NPC_SYSINFO_MSG_STARTINFO, + NPC_SYSINFO_MSG_ENDINFO, + NPC_SYSINFO_MSG_HELP, + NPC_SYSINFO_MSG_PLAYER, + NPC_SYSINFO_MSG_LIST, + NPC_SYSINFO_MSG_SENDNO, + NPC_SYSINFO_MSG_SENDMSG, + NPC_SYSINFO_MSG_SHUTDOWN, + NPC_SYSINFO_MSG_MSGCOL, + NPC_SYSINFO_MSG_SYSINFO, + NPC_SYSINFO_MSG_INFO, + NPC_SYSINFO_MSG_ALLOWACCEPT, + NPC_SYSINFO_MSG_DENYACCEPT, + NPC_SYSINFO_MSG_CLOSEALLSOCKETS, + + /* 错痊馨笛 */ + NPC_SYSINFO_ALL_NOSEE, + NPC_SYSINFO_ALL_NOBODY, + NPC_SYSINFO_MOVE_NUM, + NPC_SYSINFO_BORN_NUM, + NPC_SYSINFO_ENEMY_STATE, + NPC_SYSINFO_SETWALKTIME, + NPC_SYSINFO_SETCATIME, + NPC_SYSINFO_SETCDTIME, + NPC_SYSINFO_SETONELOOP, + NPC_SYSINFO_TITLERESTART, + NPC_SYSINFO_SETSAACWRITE, + NPC_SYSINFO_SETSAACREAD, + + NPC_SYSINFO_MSG_NUM, +}; + +typedef struct { + char arg[32]; + char defMsg[128]; +}NPC_Sysinfo_Msg; + +static NPC_Sysinfo_Msg msgtable[] = { + { "def_msg", "我拥有和全世界的人说话的能力。" }, + { "shutdown_msg", "现在开始要进行server系统维护请尽速logout!!"}, +}; +enum{ + NPC_SYSINFO_ARG_DEF_MSG, + NPC_SYSINFO_ARG_SHUTDOWN_MSG, +}; + + +static void NPC_Sysinfo_SendMsg( int meindex, int pindex, int tblnum); +static char *NPC_Sysinfo_GetMsg( int meindex, char *msgindexstr, + char *out,int outlen, int num ); +static void NPC_Sysinfo_SendMsgToAll( int meindex, char *msg); +static void NPC_Sysinfo_Msg_EndInfo( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_Msg_Help( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_Msg_Player( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_Msg_List( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_Msg_SendNo( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_Msg_SendMsg( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_Msg_Shutdown( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_Msg_Msgcol( int meindex, int tindex, char *msg); + +/* 错痊馨笛 */ +static void NPC_Sysinfo_All_NoBody( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_All_NoSee( int meindex, int tindex, char *msg); + +static void NPC_Sysinfo_Move_Num( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_Born_Num( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_Enemy_State( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_SetWalkTime( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_SetCATime( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_SetCDTime( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_SetOneloop( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_TitleRestart( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_SetSaacwrite( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_SetSaacread( int meindex, int tindex, char *msg); + +static void NPC_Sysinfo_Msg_allowAccept(int meindex, int tindex, char*msg) +{ + SERVSTATE_SetAcceptMore( 1 ); + CHAR_talkToCli( tindex, meindex, "allowaccept OK.", CHAR_COLORYELLOW); +} +static void NPC_Sysinfo_Msg_denyAccept(int meindex, int tindex, char*msg) +{ + SERVSTATE_SetAcceptMore( 0 ); + CHAR_talkToCli( tindex, meindex, "denyaccept OK.", CHAR_COLORYELLOW); +} +static void NPC_Sysinfo_Msg_closeallsockets(int meindex, int tindex, + char*msg) +{ + CHAR_talkToCli( tindex, meindex, "closeallsockets OK.", CHAR_COLORYELLOW); + closeAllConnectionandSaveData(); +} +static void NPC_Sysinfo_Msg_Sysinfo(int meindex, int tindex, char*msg) +{ + CHAR_CHAT_DEBUG_sysinfo( tindex, msg); +} +static void NPC_Sysinfo_Msg_Info(int meindex, int tindex, char*msg) +{ + CHAR_CHAT_DEBUG_info( tindex, msg); +} + + +typedef void (*FUNC)(int,int,char *); +static FUNC functbl[] = { + NULL, + NPC_Sysinfo_Msg_EndInfo, + NPC_Sysinfo_Msg_Help, + NPC_Sysinfo_Msg_Player, + NPC_Sysinfo_Msg_List, + NPC_Sysinfo_Msg_SendNo, + NPC_Sysinfo_Msg_SendMsg, + NPC_Sysinfo_Msg_Shutdown, + NPC_Sysinfo_Msg_Msgcol, + NPC_Sysinfo_Msg_Sysinfo, + NPC_Sysinfo_Msg_Info, + NPC_Sysinfo_Msg_allowAccept, + NPC_Sysinfo_Msg_denyAccept, + NPC_Sysinfo_Msg_closeallsockets, + /* 错痊馨笛 */ + NPC_Sysinfo_All_NoSee, + NPC_Sysinfo_All_NoBody, + NPC_Sysinfo_Move_Num, + NPC_Sysinfo_Born_Num, + NPC_Sysinfo_Enemy_State, + NPC_Sysinfo_SetWalkTime, + NPC_Sysinfo_SetCATime, + NPC_Sysinfo_SetCDTime, + NPC_Sysinfo_SetOneloop, + NPC_Sysinfo_TitleRestart, + NPC_Sysinfo_SetSaacwrite, + NPC_Sysinfo_SetSaacread, + +}; + +/********************************* +* 赓渝质 +*********************************/ +BOOL NPC_SysinfoInit( int meindex ) +{ + int tmp; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff[128]; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + /* 赓渝祭质 */ + + CHAR_setWorkInt( meindex, CHAR_WORK_MODE, 0); + + /* 由旦伐□玉本永玄 */ + if( NPC_Util_GetStrFromStrWithDelim( argstr, "passwd", buff, sizeof( buff)) + == NULL) + { + strcpy( buff, NPC_SYSINFO_PASSWD_DEFAULT); + } + CHAR_setWorkChar( meindex, CHAR_WORKCHAR_PASSWD, buff); + + + tmp = NPC_Util_GetNumFromStrWithDelim( argstr, "time"); + if( tmp == -1 ) tmp = NPC_SYSINFO_TIMELIMIT_DEFAULT; + CHAR_setWorkInt( meindex, CHAR_WORK_TIMELIMIT, tmp); + + /* 丢永本□斥及缙潸 */ + tmp = NPC_Util_GetNumFromStrWithDelim( argstr, "msg_col"); + if( tmp < CHAR_COLORRED || tmp > CHAR_COLORWHITE ) + tmp = CHAR_COLORYELLOW; + CHAR_setWorkInt( meindex, CHAR_WORK_MSGCOLOR, tmp); + + CHAR_setWorkInt( meindex, CHAR_WORK_PLAYER, -1); + CHAR_setWorkInt( meindex, CHAR_WORK_SHUTDOWNTIME, 0); + CHAR_setWorkInt( meindex, CHAR_WORK_SHUTDOWNDSPTIME, 0); + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_TYPEOTHERNPC); + CHAR_setFlg( meindex, CHAR_ISATTACKED, 0); + + return TRUE; +} + +/********************************* +* Loop质 +**********************************/ +void NPC_SysinfoLoop( int meindex ) +{ + int shuttime; + if( CHAR_getWorkInt( meindex, CHAR_WORK_MODE) == 1) { + int oldtime; + /* 凛棉毛褡户月 */ + oldtime = CHAR_getWorkInt( meindex, CHAR_WORK_TIME); + /* 孺蜃凛棉左□田□匹骚橘乒□玉尺 */ + if( NowTime.tv_sec - oldtime > + CHAR_getWorkInt( meindex, CHAR_WORK_TIMELIMIT)) + { + CHAR_setWorkInt( meindex, CHAR_WORK_MODE, 0); + CHAR_setWorkInt( meindex, CHAR_WORK_PLAYER, -1); + } + } + shuttime = CHAR_getWorkInt( meindex, CHAR_WORK_SHUTDOWNTIME); + /* shutdown凛棉民尼永弁 */ + if( shuttime > 0 ) { + int diff,limit,hun; + + diff = NowTime.tv_sec - shuttime; + limit = CHAR_getWorkInt( meindex, CHAR_WORK_SHUTDOWNLIMIT); + hun = limit - (diff/60); + /* ㄠ坌云五卞丢永本□斥 */ + if( hun != CHAR_getWorkInt( meindex, CHAR_WORK_SHUTDOWNDSPTIME)){ + char buff[256]; + if( hun != 0 ) { + snprintf( buff, sizeof(buff), NPC_SYSINFO_SHUTDOWN_MSG, hun); + } + else { + strcpy( buff, NPC_SYSINFO_SHUTDOWN_MSG_COMP); + } + NPC_Sysinfo_SendMsgToAll( meindex, buff); + CHAR_setWorkInt( meindex, CHAR_WORK_SHUTDOWNDSPTIME, hun); + } + if( hun == 0) { + CHAR_setWorkInt( meindex, CHAR_WORK_SHUTDOWNDSPTIME,0); + CHAR_setWorkInt( meindex, CHAR_WORK_SHUTDOWNLIMIT,0); + CHAR_setWorkInt( meindex, CHAR_WORK_SHUTDOWNTIME,0); + } + } +} +/********************************* +* 井仃日木凶凛及质 +**********************************/ +void NPC_SysinfoTalked( int meindex, int tindex, char *msg, int color) +{ + char *msgwk; + char *buff; + int len; + int msgno; + + len = strlen( msg)+1; + msgwk = calloc( 1, sizeof(char)*len); + buff = calloc( 1, sizeof(char)*len); + strcpy( msgwk, msg); + /* 旦矢□旦毛引午户月 */ + deleteSequentChar( msgwk, " "); + if( CHAR_getWorkInt( meindex, CHAR_WORK_MODE) == 0 ) { + msgno = 0; + if( strncmp( msgwk, cmd_msg[NPC_SYSINFO_MSG_STARTINFO].msg, + strlen( cmd_msg[NPC_SYSINFO_MSG_STARTINFO].msg)) == 0) + { + if( getStringFromIndexWithDelim( msgwk, " ", 2, buff, len) + == TRUE ) + { + if( strcmp( buff, CHAR_getWorkChar( meindex, CHAR_WORKCHAR_PASSWD)) + == 0 ) + { + CHAR_setWorkInt( meindex, CHAR_WORK_MODE, 1); + CHAR_setWorkInt( meindex, CHAR_WORK_PLAYER, tindex); + CHAR_setWorkInt( meindex, CHAR_WORK_TIME, NowTime.tv_sec); + CHAR_talkToCli( tindex, meindex, + "已移到指令模式。按下help即会出现说明档。", + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + CHAR_talkToCli( tindex, meindex, + "可以在enemystate 中了解敌人的产生和行动数。", + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + + } + } + } + if( CHAR_getWorkInt( meindex, CHAR_WORK_MODE ) == 0 ) { + NPC_Sysinfo_SendMsg( meindex, tindex, NPC_SYSINFO_ARG_DEF_MSG); + } + } + else { + /* 戊穴件玉乒□玉卞仄凶谛仄井质 匹五卅中 */ + if( tindex == CHAR_getWorkInt( meindex, CHAR_WORK_PLAYER)) { + int i; + /* 公木冗木质 蕊曰坌仃 */ + for( i = NPC_SYSINFO_MSG_ENDINFO; i < NPC_SYSINFO_MSG_NUM; i ++ ) { + if( strncmp( msgwk, cmd_msg[i].msg, strlen( cmd_msg[i].msg)) == 0) { + if( functbl[i] != NULL ) { + functbl[i]( meindex, tindex, msgwk); + } + break; + } + } + CHAR_setWorkInt( meindex, CHAR_WORK_TIME, NowTime.tv_sec); + } + else { + NPC_Sysinfo_SendMsg( meindex, tindex, NPC_SYSINFO_ARG_DEF_MSG); + } + } + free( msgwk); + free( buff); +} +/*------------------------------------------------------------------------ + * 骚橘乒□玉尺 + *----------------------------------------------------------------------*/ +static void NPC_Sysinfo_Msg_EndInfo( int meindex, int tindex, char *msg) +{ + CHAR_setWorkInt( meindex, CHAR_WORK_MODE, 0); + CHAR_setWorkInt( meindex, CHAR_WORK_PLAYER, -1); + CHAR_talkToCli( tindex, meindex, + "已移到一般模式", + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + +} +/*------------------------------------------------------------------------ + * HELP丢永本□斥 + *----------------------------------------------------------------------*/ +static void NPC_Sysinfo_Msg_Help( int meindex, int tindex, char *msg) +{ + int i; + typedef struct { + char str[512]; + }SYSINFO_MSGWK; + SYSINFO_MSGWK msgwk[] = { + { "指令HELP"}, + { "help 此项讯息。"}, + { "player 表示现在LOGIN的玩家人数。"}, + { "list 讯息一览。"}, + { "send number 「number」 是数值。指定讯息的号码後将该讯息内容传送给全部的玩家。"}, + { "sendmsg msgs msgs为想传送的讯息。在send 之後空一格,即可将之後的文章送信给全部的玩家。"}, + { "shutdown min min 代表分。"}, + { "msgcol col 设定传送给玩家讯息的颜色。颜色的指定有red,green,yellow,blue,purple,cyan,white。"}, + { "sysinfo 系统状态"}, + { "info 玩家状态"}, + { "endinfo 回复普通的状态。"}, + { "denyaccept 无法接受CLIENT端的接续。"}, + { "allowaccept 接受CLIENT端的接续。"}, + { "closeallsockets 强迫让CLIENT端LOGOUT。在内部实行denyaccept。"}, + { "titlerestart 再次读取称号名的设定。"}, + { "enemystate 说明NPC的状况。"}, + { ""}, + }; + + for( i = 0; msgwk[i].str[0] != '\0'; i ++ ) { + CHAR_talkToCli( tindex, meindex, msgwk[i].str, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + } +} +/*------------------------------------------------------------------------ + * 皿伊奶乩□及醒毛譬屯月 + *----------------------------------------------------------------------*/ +static void NPC_Sysinfo_Msg_Player( int meindex, int tindex, char *msg) +{ + int i, cnt = 0; + int playernum=CHAR_getPlayerMaxNum(); + char buff[64]; + for( i=0 ; i=1 && num < NPC_SYSINFO_MSGMAX ) { + if( NPC_Sysinfo_GetMsg( meindex, "sendno", msgbuf, + sizeof( msgbuf), num) != NULL ) + { + NPC_Sysinfo_SendMsgToAll( meindex, msgbuf); + } + } + } +} +/*------------------------------------------------------------------------ + * 隙烂今木凶丢永本□斥 侬 毛霜耨允月 + *----------------------------------------------------------------------*/ +static void NPC_Sysinfo_Msg_SendMsg( int meindex, int tindex, char *msg) +{ + char buff[512]; + + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) + { + NPC_Sysinfo_SendMsgToAll( meindex, buff); + } +} +/*------------------------------------------------------------------------ + * 丢永本□斥市仿□毛 凳允月 + *----------------------------------------------------------------------*/ +static void NPC_Sysinfo_Msg_Msgcol( int meindex, int tindex, char *msg) +{ + char buff[64]; + typedef struct { + int color; + char str[10]; + }SYSINFO_COLSET; + SYSINFO_COLSET colset[] = { + { 249, "red"}, + { 250, "green"}, + { 251, "yellow"}, + { 252, "blue"}, + { 253, "purple"}, + { 254, "cyan"}, + { 255, "white"}, + }; + + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) + { + int i; + for( i = 0; i < 7; i ++ ) { + if( strstr( buff, colset[i].str) != NULL ) { + CHAR_setWorkInt( meindex, CHAR_WORK_MSGCOLOR, colset[i].color); + CHAR_talkToCli( tindex, meindex, "已改变讯息的颜色。", + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + break; + } + } + } +} +/*------------------------------------------------------------------------ + * 娄醒井日丢永本□斥毛潸 允月 + *----------------------------------------------------------------------*/ +static char *NPC_Sysinfo_GetMsg( int meindex, char *msgindexstr, + char *out,int outlen, int num ) +{ + + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char *work; + char *buff; + char *cret = NULL; + int worklen; + + worklen = strlen( msgindexstr)+3; + work = (char *)calloc( 1, worklen * sizeof( char)); + buff = (char *)calloc( 1, outlen * sizeof( char)); + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + snprintf( work, worklen, "%s%d", msgindexstr, num); + if( NPC_Util_GetStrFromStrWithDelim( argstr, work, + buff, outlen) != NULL ) + { + strcpy( out, buff); + cret = out; + } + + free( work); + free( buff); + return( cret); +} +/*------------------------------------------------------------------------ + * shutdown丢永本□斥质 + *----------------------------------------------------------------------*/ +static void NPC_Sysinfo_Msg_Shutdown( int meindex, int tindex, char *msg) +{ + char buff[10]; + int hun; + + /* 赓及丢永本□斥霜耨 */ + NPC_Sysinfo_SendMsg( meindex, tindex, NPC_SYSINFO_ARG_SHUTDOWN_MSG); + /* 凛棉本永玄 */ + CHAR_setWorkInt( meindex, CHAR_WORK_SHUTDOWNTIME, NowTime.tv_sec); + /* 孺蜃凛棉潸 */ + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) + { + hun = atoi( buff); + if( hun <= 0 ) { + hun = NPC_SYSINFO_SHUTDOWNLIMIT_DEFAULT; + } + } + else { + hun = NPC_SYSINFO_SHUTDOWNLIMIT_DEFAULT; + } + + CHAR_setWorkInt( meindex, CHAR_WORK_SHUTDOWNLIMIT, hun); + + CHAR_setWorkInt( meindex, CHAR_WORK_SHUTDOWNDSPTIME,0); +} +/*------------------------------------------------------------------------ + * 丢永本□斥毛霜月 娄醒井日丢永本□斥毛潸 + *----------------------------------------------------------------------*/ +static void NPC_Sysinfo_SendMsg( int meindex, int pindex, int tblnum) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff[128]; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + if( NPC_Util_GetStrFromStrWithDelim( argstr, msgtable[tblnum].arg, + buff, sizeof( buff)) == NULL ) + { + strcpy( buff, msgtable[tblnum].defMsg); + } + if( buff[0] != '\0' ) { + CHAR_talkToCli( pindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + } +} +/*------------------------------------------------------------------------ + * 蝈化及谛卞丢永本□斥毛霜月[ + *----------------------------------------------------------------------*/ +static void NPC_Sysinfo_SendMsgToAll( int meindex, char *msg) +{ + int i; + int playernum = CHAR_getPlayerMaxNum(); + + for( i = 0 ; i < playernum ; i++) { + if( CHAR_getCharUse(i) != FALSE ) { + CHAR_talkToCli( i, meindex, msg, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + } + } +} + + + +/* 蝈衬平乓仿毛 NO_SEE 卞允月井升丹井 */ +static void NPC_Sysinfo_All_NoSee( int meindex, int tindex, char *msg ){ + char buff[256]; + + buff[0] = buff[1] = 0; + /* 孺蜃凛棉潸 */ + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) + { + /* 卞允月桦宁 */ + if( strncmp( buff, "on", strlen( buff ) ) == 0 ){ + all_nosee = 1; + snprintf( buff, sizeof( buff), "已开启all_nosee 。" ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + }else + /* 卞允月桦宁 */ + if( strncmp( buff, "off", strlen( buff ) ) == 0 ){ + all_nosee = 0; + snprintf( buff, sizeof( buff), "已关闭all_nosee 。" ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + } + }else + if( all_nosee == 0 ){ + snprintf( buff, sizeof( buff), "all_nosee关闭着。" ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + }else{ + snprintf( buff, sizeof( buff), "all_nosee开启着。" ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + } +} + +/* 蝈衬平乓仿毛 NO_BODY 卞允月井升丹井 */ +static void NPC_Sysinfo_All_NoBody( int meindex, int tindex, char *msg ){ + char buff[256]; + + buff[0] = buff[1] = 0; + /* 孺蜃凛棉潸 */ + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) + { + /* 卞允月桦宁 */ + if( strncmp( buff, "on", strlen( buff ) ) == 0 ){ + all_nobody = 1; + snprintf( buff, sizeof( buff), "已开启all_nobody 。" ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + }else + /* 卞允月桦宁 */ + if( strncmp( buff, "off", strlen( buff ) ) == 0 ){ + all_nobody = 0; + snprintf( buff, sizeof( buff), "已关闭all_nobody 。" ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + } + }else + if( all_nobody == 0 ){ + snprintf( buff, sizeof( buff), "all_nobody 关闭着。" ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + }else{ + snprintf( buff, sizeof( buff), "all_nobody 开启着。" ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + } +} + + +/* 蝈衬平乓仿毛 ㄠ伙□皿匹窒 综今六月井" */ +static void NPC_Sysinfo_Move_Num( int meindex, int tindex, char *msg ){ + char buff[256]; + int work; + buff[0] = buff[1] = 0; + + /* 孺蜃凛棉潸 */ + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) + { + work = atoi( buff ); + if( work <= 0 ) { + work = 1000; /* 赝癫 */ + } + /* 凛卞仇木分仃 井仄引允 */ + EnemyMoveNum = work; + snprintf( buff, sizeof( buff), "让敌人同时%d动作。", + EnemyMoveNum ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + }else{ + snprintf( buff, sizeof( buff), "现在敌人同时在进行%d动作。", + EnemyMoveNum ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + } +} + + + +/* 衬平乓仿毛ㄠ伙□皿匹窒 嫖戏心请允井 */ +static void NPC_Sysinfo_Born_Num( int meindex, int tindex, char *msg ){ + char buff[256]; + int work; + buff[0] = buff[1] = 0; + + /* 孺蜃凛棉潸 */ + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) + { + work = atoi( buff ); + if( work <= 0 ) { + work = 2; /* 赝癫 */ + } + /* 凛卞仇木分仃戏心请仄引允 */ + one_loop_born = work; + snprintf( buff, sizeof( buff), "敌人同时派出最高的%d。", + one_loop_born ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + }else{ + snprintf( buff, sizeof( buff), "现在敌人同时派出最高的%d。", + one_loop_born ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + } +} + + + +/* 蜇箕及 平平乓仿橇谪毛苇月 */ +static void NPC_Sysinfo_Enemy_State( int meindex, int tindex, char *msg ){ + char buff[256]; + + if( all_nobody == 0 ){ + snprintf( buff, sizeof( buff), "allnobody 关闭着。" ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + }else{ + snprintf( buff, sizeof( buff), "allnobody 开启着。" ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + } + if( all_nosee == 0 ){ + snprintf( buff, sizeof( buff), "allnosee 关闭着。" ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + }else{ + snprintf( buff, sizeof( buff), "allnosee 开启着。" ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + } + snprintf( buff, sizeof( buff), + "bornnum 现在敌人同时派出最高的%d。", + one_loop_born ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + + snprintf( buff, sizeof( buff), + "movenum 现在敌人同时在进行%d动作。", + EnemyMoveNum ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + + +} +static void NPC_Sysinfo_SetWalkTime( int meindex, int tindex, char *msg) +{ + int interval; + char msgbuf[256]; + char buff[256]; + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) { + interval = atoi( buff); + if( interval > 0 ) { + setWalksendinterval( (unsigned)interval); + } + } + snprintf( msgbuf, sizeof(msgbuf),"WalkInterval = %d 秒",getWalksendinterval()); + CHAR_talkToCli( tindex, meindex, msgbuf, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + +} +static void NPC_Sysinfo_SetCATime( int meindex, int tindex, char *msg) +{ + int interval; + char msgbuf[256]; + char buff[256]; + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) { + interval = atoi( buff); + if( interval > 0 ) { + setCAsendinterval_ms( (unsigned)interval); + } + } + snprintf( msgbuf, sizeof(msgbuf),"CAsendInterval = %d 秒", + getCAsendinterval_ms()); + CHAR_talkToCli( tindex, meindex, msgbuf, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); +} +static void NPC_Sysinfo_SetCDTime( int meindex, int tindex, char *msg) +{ + int interval; + char msgbuf[256]; + char buff[256]; + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) { + interval = atoi( buff); + if( interval > 0 ) { + setCDsendinterval_ms( (unsigned)interval); + } + } + snprintf( msgbuf, sizeof(msgbuf),"CDsendInterval = %d 秒", + getCDsendinterval_ms()); + CHAR_talkToCli( tindex, meindex, msgbuf, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); +} +static void NPC_Sysinfo_SetOneloop( int meindex, int tindex, char *msg) +{ + int interval; + char msgbuf[256]; + char buff[256]; + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) { + interval = atoi( buff); + if( interval > 0 ) { + setOnelooptime_ms( (unsigned)interval); + } + } + snprintf( msgbuf, sizeof(msgbuf),"Onelooptime = %d 秒", + getOnelooptime_ms()); + CHAR_talkToCli( tindex, meindex, msgbuf, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); +} +static void NPC_Sysinfo_TitleRestart( int meindex, int tindex, char *msg) +{ + int rc; + char msgbuf[256]; + + rc = TITLE_reinitTitleName(); + if( rc) { + snprintf( msgbuf, sizeof(msgbuf),"读取完毕。" ); + } + else { + snprintf( msgbuf, sizeof(msgbuf),"发生ERROR。" ); + } + CHAR_talkToCli( tindex, meindex, msgbuf, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); +} + + +static void NPC_Sysinfo_SetSaacwrite( int meindex, int tindex, char *msg) +{ + int interval; + char msgbuf[256]; + char buff[256]; + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) { + interval = atoi( buff); + if( interval > 0 ) { + setSaacwritenum( (unsigned)interval); + } + } + snprintf( msgbuf, sizeof(msgbuf),"Saacwritenum = %d ",getSaacwritenum()); + CHAR_talkToCli( tindex, meindex, msgbuf, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); +} +static void NPC_Sysinfo_SetSaacread( int meindex, int tindex, char *msg) +{ + int interval; + char msgbuf[256]; + char buff[256]; + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) { + interval = atoi( buff); + if( interval > 0 ) { + setSaacreadnum( (unsigned)interval); + } + } + snprintf( msgbuf, sizeof(msgbuf),"Saacreadnum = %d ",getSaacreadnum()); + CHAR_talkToCli( tindex, meindex, msgbuf, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); +} diff --git a/gmsv/npc/npc_sysinfo.c.bak b/gmsv/npc/npc_sysinfo.c.bak new file mode 100644 index 0000000..36e46a9 --- /dev/null +++ b/gmsv/npc/npc_sysinfo.c.bak @@ -0,0 +1,876 @@ +#include "version.h" +#include + +#include "char.h" +#include "char_event.h" +#include "object.h" +#include "handletime.h" +#include "magic.h" +#include "npcutil.h" +#include "char_data.h" +#include "chatmagic.h" +#include "net.h" +#include "configfile.h" +#include "npcgen.h" + +/* +--------------------------------------------------------------------- +sysinfo By Kawata +--------------------------------------------------------------------- +*/ + +#define NPC_SYSINFO_MSGMAX 21 + +#define NPC_SYSINFO_PASSWD_DEFAULT "G00d1uck" + +#define NPC_SYSINFO_TIMELIMIT_DEFAULT 120 + +#define NPC_SYSINFO_SHUTDOWNLIMIT_DEFAULT 5 + +#define NPC_SYSINFO_SHUTDOWN_MSG "再过 %d 分钟後,即开始进行server系统维护。" + +#define NPC_SYSINFO_SHUTDOWN_MSG_COMP "server已关闭。" +enum { + CHAR_WORK_MODE = CHAR_NPCWORKINT1, + CHAR_WORK_TIME = CHAR_NPCWORKINT2, + CHAR_WORK_TIMELIMIT = CHAR_NPCWORKINT3, + CHAR_WORK_SHUTDOWNTIME = CHAR_NPCWORKINT4, + CHAR_WORK_SHUTDOWNLIMIT = CHAR_NPCWORKINT5, + CHAR_WORK_SHUTDOWNDSPTIME = CHAR_NPCWORKINT6, + CHAR_WORK_MSGCOLOR = CHAR_NPCWORKINT7, + CHAR_WORK_PLAYER = CHAR_NPCWORKINT8, +}; + +enum { + CHAR_WORKCHAR_PASSWD = CHAR_NPCWORKCHAR1, +}; +typedef struct { + char msg[16]; +}CMD_MSG; +CMD_MSG cmd_msg[] = { + { "startinfo"}, {"endinfo"}, {"help"}, + {"player"}, {"list"}, {"sendno"}, + {"sendmsg"}, {"shutdown"}, {"msgcol"}, + {"sysinfo"}, {"info"}, + { "allowaccept" } , { "denyaccept" } , + { "closeallsockets" }, + { "allnosee" }, + { "allnobody" }, + { "movenum" }, + { "bornnum" }, + { "enemystate" }, + { "setwalktime"},{ "setcatime" },{"setcdtime"}, + { "setoneloop"}, + { "titlerestart"}, + { "setsaacwrite"}, { "setsaacread"}, +}; +enum{ + NPC_SYSINFO_MSG_STARTINFO, + NPC_SYSINFO_MSG_ENDINFO, + NPC_SYSINFO_MSG_HELP, + NPC_SYSINFO_MSG_PLAYER, + NPC_SYSINFO_MSG_LIST, + NPC_SYSINFO_MSG_SENDNO, + NPC_SYSINFO_MSG_SENDMSG, + NPC_SYSINFO_MSG_SHUTDOWN, + NPC_SYSINFO_MSG_MSGCOL, + NPC_SYSINFO_MSG_SYSINFO, + NPC_SYSINFO_MSG_INFO, + NPC_SYSINFO_MSG_ALLOWACCEPT, + NPC_SYSINFO_MSG_DENYACCEPT, + NPC_SYSINFO_MSG_CLOSEALLSOCKETS, + + /* 错痊馨笛 */ + NPC_SYSINFO_ALL_NOSEE, + NPC_SYSINFO_ALL_NOBODY, + NPC_SYSINFO_MOVE_NUM, + NPC_SYSINFO_BORN_NUM, + NPC_SYSINFO_ENEMY_STATE, + NPC_SYSINFO_SETWALKTIME, + NPC_SYSINFO_SETCATIME, + NPC_SYSINFO_SETCDTIME, + NPC_SYSINFO_SETONELOOP, + NPC_SYSINFO_TITLERESTART, + NPC_SYSINFO_SETSAACWRITE, + NPC_SYSINFO_SETSAACREAD, + + NPC_SYSINFO_MSG_NUM, +}; + +typedef struct { + char arg[32]; + char defMsg[128]; +}NPC_Sysinfo_Msg; + +static NPC_Sysinfo_Msg msgtable[] = { + { "def_msg", "我拥有和全世界的人说话的能力。" }, + { "shutdown_msg", "现在开始要进行server系统维护请尽速logout!!"}, +}; +enum{ + NPC_SYSINFO_ARG_DEF_MSG, + NPC_SYSINFO_ARG_SHUTDOWN_MSG, +}; + + +static void NPC_Sysinfo_SendMsg( int meindex, int pindex, int tblnum); +static char *NPC_Sysinfo_GetMsg( int meindex, char *msgindexstr, + char *out,int outlen, int num ); +static void NPC_Sysinfo_SendMsgToAll( int meindex, char *msg); +static void NPC_Sysinfo_Msg_EndInfo( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_Msg_Help( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_Msg_Player( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_Msg_List( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_Msg_SendNo( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_Msg_SendMsg( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_Msg_Shutdown( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_Msg_Msgcol( int meindex, int tindex, char *msg); + +/* 错痊馨笛 */ +static void NPC_Sysinfo_All_NoBody( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_All_NoSee( int meindex, int tindex, char *msg); + +static void NPC_Sysinfo_Move_Num( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_Born_Num( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_Enemy_State( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_SetWalkTime( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_SetCATime( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_SetCDTime( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_SetOneloop( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_TitleRestart( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_SetSaacwrite( int meindex, int tindex, char *msg); +static void NPC_Sysinfo_SetSaacread( int meindex, int tindex, char *msg); + +static void NPC_Sysinfo_Msg_allowAccept(int meindex, int tindex, char*msg) +{ + SERVSTATE_SetAcceptMore( 1 ); + CHAR_talkToCli( tindex, meindex, "allowaccept OK.", CHAR_COLORYELLOW); +} +static void NPC_Sysinfo_Msg_denyAccept(int meindex, int tindex, char*msg) +{ + SERVSTATE_SetAcceptMore( 0 ); + CHAR_talkToCli( tindex, meindex, "denyaccept OK.", CHAR_COLORYELLOW); +} +static void NPC_Sysinfo_Msg_closeallsockets(int meindex, int tindex, + char*msg) +{ + CHAR_talkToCli( tindex, meindex, "closeallsockets OK.", CHAR_COLORYELLOW); + closeAllConnectionandSaveData(); +} +static void NPC_Sysinfo_Msg_Sysinfo(int meindex, int tindex, char*msg) +{ + CHAR_CHAT_DEBUG_sysinfo( tindex, msg); +} +static void NPC_Sysinfo_Msg_Info(int meindex, int tindex, char*msg) +{ + CHAR_CHAT_DEBUG_info( tindex, msg); +} + + +typedef void (*FUNC)(int,int,char *); +static FUNC functbl[] = { + NULL, + NPC_Sysinfo_Msg_EndInfo, + NPC_Sysinfo_Msg_Help, + NPC_Sysinfo_Msg_Player, + NPC_Sysinfo_Msg_List, + NPC_Sysinfo_Msg_SendNo, + NPC_Sysinfo_Msg_SendMsg, + NPC_Sysinfo_Msg_Shutdown, + NPC_Sysinfo_Msg_Msgcol, + NPC_Sysinfo_Msg_Sysinfo, + NPC_Sysinfo_Msg_Info, + NPC_Sysinfo_Msg_allowAccept, + NPC_Sysinfo_Msg_denyAccept, + NPC_Sysinfo_Msg_closeallsockets, + /* 错痊馨笛 */ + NPC_Sysinfo_All_NoSee, + NPC_Sysinfo_All_NoBody, + NPC_Sysinfo_Move_Num, + NPC_Sysinfo_Born_Num, + NPC_Sysinfo_Enemy_State, + NPC_Sysinfo_SetWalkTime, + NPC_Sysinfo_SetCATime, + NPC_Sysinfo_SetCDTime, + NPC_Sysinfo_SetOneloop, + NPC_Sysinfo_TitleRestart, + NPC_Sysinfo_SetSaacwrite, + NPC_Sysinfo_SetSaacread, + +}; + +/********************************* +* 赓渝质 +*********************************/ +BOOL NPC_SysinfoInit( int meindex ) +{ + int tmp; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff[128]; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + /* 赓渝祭质 */ + + CHAR_setWorkInt( meindex, CHAR_WORK_MODE, 0); + + /* 由旦伐□玉本永玄 */ + if( NPC_Util_GetStrFromStrWithDelim( argstr, "passwd", buff, sizeof( buff)) + == NULL) + { + strcpy( buff, NPC_SYSINFO_PASSWD_DEFAULT); + } + CHAR_setWorkChar( meindex, CHAR_WORKCHAR_PASSWD, buff); + + + tmp = NPC_Util_GetNumFromStrWithDelim( argstr, "time"); + if( tmp == -1 ) tmp = NPC_SYSINFO_TIMELIMIT_DEFAULT; + CHAR_setWorkInt( meindex, CHAR_WORK_TIMELIMIT, tmp); + + /* 丢永本□斥及缙潸 */ + tmp = NPC_Util_GetNumFromStrWithDelim( argstr, "msg_col"); + if( tmp < CHAR_COLORRED || tmp > CHAR_COLORWHITE ) + tmp = CHAR_COLORYELLOW; + CHAR_setWorkInt( meindex, CHAR_WORK_MSGCOLOR, tmp); + + CHAR_setWorkInt( meindex, CHAR_WORK_PLAYER, -1); + CHAR_setWorkInt( meindex, CHAR_WORK_SHUTDOWNTIME, 0); + CHAR_setWorkInt( meindex, CHAR_WORK_SHUTDOWNDSPTIME, 0); + CHAR_setInt( meindex, CHAR_WHICHTYPE, CHAR_TYPEOTHERNPC); + CHAR_setFlg( meindex, CHAR_ISATTACKED, 0); + + return TRUE; +} + +/********************************* +* Loop质 +**********************************/ +void NPC_SysinfoLoop( int meindex ) +{ + int shuttime; + if( CHAR_getWorkInt( meindex, CHAR_WORK_MODE) == 1) { + int oldtime; + /* 凛棉毛褡户月 */ + oldtime = CHAR_getWorkInt( meindex, CHAR_WORK_TIME); + /* 孺蜃凛棉左□田□匹骚橘乒□玉尺 */ + if( NowTime.tv_sec - oldtime > + CHAR_getWorkInt( meindex, CHAR_WORK_TIMELIMIT)) + { + CHAR_setWorkInt( meindex, CHAR_WORK_MODE, 0); + CHAR_setWorkInt( meindex, CHAR_WORK_PLAYER, -1); + } + } + shuttime = CHAR_getWorkInt( meindex, CHAR_WORK_SHUTDOWNTIME); + /* shutdown凛棉民尼永弁 */ + if( shuttime > 0 ) { + int diff,limit,hun; + + diff = NowTime.tv_sec - shuttime; + limit = CHAR_getWorkInt( meindex, CHAR_WORK_SHUTDOWNLIMIT); + hun = limit - (diff/60); + /* ㄠ坌云五卞丢永本□斥 */ + if( hun != CHAR_getWorkInt( meindex, CHAR_WORK_SHUTDOWNDSPTIME)){ + char buff[256]; + if( hun != 0 ) { + snprintf( buff, sizeof(buff), NPC_SYSINFO_SHUTDOWN_MSG, hun); + } + else { + strcpy( buff, NPC_SYSINFO_SHUTDOWN_MSG_COMP); + } + NPC_Sysinfo_SendMsgToAll( meindex, buff); + CHAR_setWorkInt( meindex, CHAR_WORK_SHUTDOWNDSPTIME, hun); + } + if( hun == 0) { + CHAR_setWorkInt( meindex, CHAR_WORK_SHUTDOWNDSPTIME,0); + CHAR_setWorkInt( meindex, CHAR_WORK_SHUTDOWNLIMIT,0); + CHAR_setWorkInt( meindex, CHAR_WORK_SHUTDOWNTIME,0); + } + } +} +/********************************* +* 井仃日木凶凛及质 +**********************************/ +void NPC_SysinfoTalked( int meindex, int tindex, char *msg, int color) +{ + char *msgwk; + char *buff; + int len; + int msgno; + + len = strlen( msg)+1; + msgwk = calloc( 1, sizeof(char)*len); + buff = calloc( 1, sizeof(char)*len); + strcpy( msgwk, msg); + /* 旦矢□旦毛引午户月 */ + deleteSequentChar( msgwk, " "); + if( CHAR_getWorkInt( meindex, CHAR_WORK_MODE) == 0 ) { + msgno = 0; + if( strncmp( msgwk, cmd_msg[NPC_SYSINFO_MSG_STARTINFO].msg, + strlen( cmd_msg[NPC_SYSINFO_MSG_STARTINFO].msg)) == 0) + { + if( getStringFromIndexWithDelim( msgwk, " ", 2, buff, len) + == TRUE ) + { + if( strcmp( buff, CHAR_getWorkChar( meindex, CHAR_WORKCHAR_PASSWD)) + == 0 ) + { + CHAR_setWorkInt( meindex, CHAR_WORK_MODE, 1); + CHAR_setWorkInt( meindex, CHAR_WORK_PLAYER, tindex); + CHAR_setWorkInt( meindex, CHAR_WORK_TIME, NowTime.tv_sec); + CHAR_talkToCli( tindex, meindex, + "已移到指令模式。按下help即会出现说明档。", + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + CHAR_talkToCli( tindex, meindex, + "可以在enemystate 中了解敌人的产生和行动数。", + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + + } + } + } + if( CHAR_getWorkInt( meindex, CHAR_WORK_MODE ) == 0 ) { + NPC_Sysinfo_SendMsg( meindex, tindex, NPC_SYSINFO_ARG_DEF_MSG); + } + } + else { + /* 戊穴件玉乒□玉卞仄凶谛仄井质 匹五卅中 */ + if( tindex == CHAR_getWorkInt( meindex, CHAR_WORK_PLAYER)) { + int i; + /* 公木冗木质 蕊曰坌仃 */ + for( i = NPC_SYSINFO_MSG_ENDINFO; i < NPC_SYSINFO_MSG_NUM; i ++ ) { + if( strncmp( msgwk, cmd_msg[i].msg, strlen( cmd_msg[i].msg)) == 0) { + if( functbl[i] != NULL ) { + functbl[i]( meindex, tindex, msgwk); + } + break; + } + } + CHAR_setWorkInt( meindex, CHAR_WORK_TIME, NowTime.tv_sec); + } + else { + NPC_Sysinfo_SendMsg( meindex, tindex, NPC_SYSINFO_ARG_DEF_MSG); + } + } + free( msgwk); + free( buff); +} +/*------------------------------------------------------------------------ + * 骚橘乒□玉尺 + *----------------------------------------------------------------------*/ +static void NPC_Sysinfo_Msg_EndInfo( int meindex, int tindex, char *msg) +{ + CHAR_setWorkInt( meindex, CHAR_WORK_MODE, 0); + CHAR_setWorkInt( meindex, CHAR_WORK_PLAYER, -1); + CHAR_talkToCli( tindex, meindex, + "已移到一般模式", + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + +} +/*------------------------------------------------------------------------ + * HELP丢永本□斥 + *----------------------------------------------------------------------*/ +static void NPC_Sysinfo_Msg_Help( int meindex, int tindex, char *msg) +{ + int i; + typedef struct { + char str[512]; + }SYSINFO_MSGWK; + SYSINFO_MSGWK msgwk[] = { + { "指令HELP"}, + { "help 此项讯息。"}, + { "player 表示现在LOGIN的玩家人数。"}, + { "list 讯息一览。"}, + { "send number 「number」 是数值。指定讯息的号码後将该讯息内容传送给全部的玩家。"}, + { "sendmsg msgs msgs为想传送的讯息。在send 之後空一格,即可将之後的文章送信给全部的玩家。"}, + { "shutdown min min 代表分。"}, + { "msgcol col 设定传送给玩家讯息的颜色。颜色的指定有red,green,yellow,blue,purple,cyan,white。"}, + { "sysinfo 系统状态"}, + { "info 玩家状态"}, + { "endinfo 回复普通的状态。"}, + { "denyaccept 无法接受CLIENT端的接续。"}, + { "allowaccept 接受CLIENT端的接续。"}, + { "closeallsockets 强迫让CLIENT端LOGOUT。在内部实行denyaccept。"}, + { "titlerestart 再次读取称号名的设定。"}, + { "enemystate 说明NPC的状况。"}, + { ""}, + }; + + for( i = 0; msgwk[i].str[0] != '\0'; i ++ ) { + CHAR_talkToCli( tindex, meindex, msgwk[i].str, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + } +} +/*------------------------------------------------------------------------ + * 皿伊奶乩□及醒毛譬屯月 + *----------------------------------------------------------------------*/ +static void NPC_Sysinfo_Msg_Player( int meindex, int tindex, char *msg) +{ + int i, cnt = 0; + int playernum=CHAR_getPlayerMaxNum(); + char buff[64]; + for( i=0 ; i=1 && num < NPC_SYSINFO_MSGMAX ) { + if( NPC_Sysinfo_GetMsg( meindex, "sendno", msgbuf, + sizeof( msgbuf), num) != NULL ) + { + NPC_Sysinfo_SendMsgToAll( meindex, msgbuf); + } + } + } +} +/*------------------------------------------------------------------------ + * 隙烂今木凶丢永本□斥 侬 毛霜耨允月 + *----------------------------------------------------------------------*/ +static void NPC_Sysinfo_Msg_SendMsg( int meindex, int tindex, char *msg) +{ + char buff[512]; + + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) + { + NPC_Sysinfo_SendMsgToAll( meindex, buff); + } +} +/*------------------------------------------------------------------------ + * 丢永本□斥市仿□毛 凳允月 + *----------------------------------------------------------------------*/ +static void NPC_Sysinfo_Msg_Msgcol( int meindex, int tindex, char *msg) +{ + char buff[64]; + typedef struct { + int color; + char str[10]; + }SYSINFO_COLSET; + SYSINFO_COLSET colset[] = { + { 249, "red"}, + { 250, "green"}, + { 251, "yellow"}, + { 252, "blue"}, + { 253, "purple"}, + { 254, "cyan"}, + { 255, "white"}, + }; + + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) + { + int i; + for( i = 0; i < 7; i ++ ) { + if( strstr( buff, colset[i].str) != NULL ) { + CHAR_setWorkInt( meindex, CHAR_WORK_MSGCOLOR, colset[i].color); + CHAR_talkToCli( tindex, meindex, "已改变讯息的颜色。", + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + break; + } + } + } +} +/*------------------------------------------------------------------------ + * 娄醒井日丢永本□斥毛潸 允月 + *----------------------------------------------------------------------*/ +static char *NPC_Sysinfo_GetMsg( int meindex, char *msgindexstr, + char *out,int outlen, int num ) +{ + + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char *work; + char *buff; + char *cret = NULL; + int worklen; + + worklen = strlen( msgindexstr)+3; + work = (char *)calloc( 1, worklen * sizeof( char)); + buff = (char *)calloc( 1, outlen * sizeof( char)); + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + snprintf( work, worklen, "%s%d", msgindexstr, num); + if( NPC_Util_GetStrFromStrWithDelim( argstr, work, + buff, outlen) != NULL ) + { + strcpy( out, buff); + cret = out; + } + + free( work); + free( buff); + return( cret); +} +/*------------------------------------------------------------------------ + * shutdown丢永本□斥质 + *----------------------------------------------------------------------*/ +static void NPC_Sysinfo_Msg_Shutdown( int meindex, int tindex, char *msg) +{ + char buff[10]; + int hun; + + /* 赓及丢永本□斥霜耨 */ + NPC_Sysinfo_SendMsg( meindex, tindex, NPC_SYSINFO_ARG_SHUTDOWN_MSG); + /* 凛棉本永玄 */ + CHAR_setWorkInt( meindex, CHAR_WORK_SHUTDOWNTIME, NowTime.tv_sec); + /* 孺蜃凛棉潸 */ + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) + { + hun = atoi( buff); + if( hun <= 0 ) { + hun = NPC_SYSINFO_SHUTDOWNLIMIT_DEFAULT; + } + } + else { + hun = NPC_SYSINFO_SHUTDOWNLIMIT_DEFAULT; + } + + CHAR_setWorkInt( meindex, CHAR_WORK_SHUTDOWNLIMIT, hun); + + CHAR_setWorkInt( meindex, CHAR_WORK_SHUTDOWNDSPTIME,0); +} +/*------------------------------------------------------------------------ + * 丢永本□斥毛霜月 娄醒井日丢永本□斥毛潸 + *----------------------------------------------------------------------*/ +static void NPC_Sysinfo_SendMsg( int meindex, int pindex, int tblnum) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff[128]; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + if( NPC_Util_GetStrFromStrWithDelim( argstr, msgtable[tblnum].arg, + buff, sizeof( buff)) == NULL ) + { + strcpy( buff, msgtable[tblnum].defMsg); + } + if( buff[0] != '\0' ) { + CHAR_talkToCli( pindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + } +} +/*------------------------------------------------------------------------ + * 蝈化及谛卞丢永本□斥毛霜月[ + *----------------------------------------------------------------------*/ +static void NPC_Sysinfo_SendMsgToAll( int meindex, char *msg) +{ + int i; + int playernum = CHAR_getPlayerMaxNum(); + + for( i = 0 ; i < playernum ; i++) { + if( CHAR_getCharUse(i) != FALSE ) { + CHAR_talkToCli( i, meindex, msg, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + } + } +} + + + +/* 蝈衬平乓仿毛 NO_SEE 卞允月井升丹井 */ +static void NPC_Sysinfo_All_NoSee( int meindex, int tindex, char *msg ){ + char buff[256]; + + buff[0] = buff[1] = 0; + /* 孺蜃凛棉潸 */ + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) + { + /* 卞允月桦宁 */ + if( strncmp( buff, "on", strlen( buff ) ) == 0 ){ + all_nosee = 1; + snprintf( buff, sizeof( buff), "已开启all_nosee 。" ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + }else + /* 卞允月桦宁 */ + if( strncmp( buff, "off", strlen( buff ) ) == 0 ){ + all_nosee = 0; + snprintf( buff, sizeof( buff), "已关闭all_nosee 。" ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + } + }else + if( all_nosee == 0 ){ + snprintf( buff, sizeof( buff), "all_nosee关闭着。" ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + }else{ + snprintf( buff, sizeof( buff), "all_nosee开启着。" ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + } +} + +/* 蝈衬平乓仿毛 NO_BODY 卞允月井升丹井 */ +static void NPC_Sysinfo_All_NoBody( int meindex, int tindex, char *msg ){ + char buff[256]; + + buff[0] = buff[1] = 0; + /* 孺蜃凛棉潸 */ + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) + { + /* 卞允月桦宁 */ + if( strncmp( buff, "on", strlen( buff ) ) == 0 ){ + all_nobody = 1; + snprintf( buff, sizeof( buff), "已开启all_nobody 。" ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + }else + /* 卞允月桦宁 */ + if( strncmp( buff, "off", strlen( buff ) ) == 0 ){ + all_nobody = 0; + snprintf( buff, sizeof( buff), "已关闭all_nobody 。" ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + } + }else + if( all_nobody == 0 ){ + snprintf( buff, sizeof( buff), "all_nobody 关闭着。" ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + }else{ + snprintf( buff, sizeof( buff), "all_nobody 开启着。" ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + } +} + + +/* 蝈衬平乓仿毛 ㄠ伙□皿匹窒 综今六月井" */ +static void NPC_Sysinfo_Move_Num( int meindex, int tindex, char *msg ){ + char buff[256]; + int work; + buff[0] = buff[1] = 0; + + /* 孺蜃凛棉潸 */ + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) + { + work = atoi( buff ); + if( work <= 0 ) { + work = 1000; /* 赝癫 */ + } + /* 凛卞仇木分仃 井仄引允 */ + EnemyMoveNum = work; + snprintf( buff, sizeof( buff), "让敌人同时%d动作。", + EnemyMoveNum ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + }else{ + snprintf( buff, sizeof( buff), "现在敌人同时在进行%d动作。", + EnemyMoveNum ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + } +} + + + +/* 衬平乓仿毛ㄠ伙□皿匹窒 嫖戏心请允井 */ +static void NPC_Sysinfo_Born_Num( int meindex, int tindex, char *msg ){ + char buff[256]; + int work; + buff[0] = buff[1] = 0; + + /* 孺蜃凛棉潸 */ + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) + { + work = atoi( buff ); + if( work <= 0 ) { + work = 2; /* 赝癫 */ + } + /* 凛卞仇木分仃戏心请仄引允 */ + one_loop_born = work; + snprintf( buff, sizeof( buff), "敌人同时派出最高的%d。", + one_loop_born ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + }else{ + snprintf( buff, sizeof( buff), "现在敌人同时派出最高的%d。", + one_loop_born ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + } +} + + + +/* 蜇箕及 平平乓仿橇谪毛苇月 */ +static void NPC_Sysinfo_Enemy_State( int meindex, int tindex, char *msg ){ + char buff[256]; + + if( all_nobody == 0 ){ + snprintf( buff, sizeof( buff), "allnobody 关闭着。" ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + }else{ + snprintf( buff, sizeof( buff), "allnobody 开启着。" ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + } + if( all_nosee == 0 ){ + snprintf( buff, sizeof( buff), "allnosee 关闭着。" ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + }else{ + snprintf( buff, sizeof( buff), "allnosee 开启着。" ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + } + snprintf( buff, sizeof( buff), + "bornnum 现在敌人同时派出最高的%d。", + one_loop_born ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + + snprintf( buff, sizeof( buff), + "movenum 现在敌人同时在进行%d动作。", + EnemyMoveNum ); + CHAR_talkToCli( tindex, meindex, buff, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + + +} +static void NPC_Sysinfo_SetWalkTime( int meindex, int tindex, char *msg) +{ + int interval; + char msgbuf[256]; + char buff[256]; + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) { + interval = atoi( buff); + if( interval > 0 ) { + setWalksendinterval( (unsigned)interval); + } + } + snprintf( msgbuf, sizeof(msgbuf),"WalkInterval = %d 秒",getWalksendinterval()); + CHAR_talkToCli( tindex, meindex, msgbuf, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); + +} +static void NPC_Sysinfo_SetCATime( int meindex, int tindex, char *msg) +{ + int interval; + char msgbuf[256]; + char buff[256]; + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) { + interval = atoi( buff); + if( interval > 0 ) { + setCAsendinterval_ms( (unsigned)interval); + } + } + snprintf( msgbuf, sizeof(msgbuf),"CAsendInterval = %d 秒", + getCAsendinterval_ms()); + CHAR_talkToCli( tindex, meindex, msgbuf, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); +} +static void NPC_Sysinfo_SetCDTime( int meindex, int tindex, char *msg) +{ + int interval; + char msgbuf[256]; + char buff[256]; + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) { + interval = atoi( buff); + if( interval > 0 ) { + setCDsendinterval_ms( (unsigned)interval); + } + } + snprintf( msgbuf, sizeof(msgbuf),"CDsendInterval = %d 秒", + getCDsendinterval_ms()); + CHAR_talkToCli( tindex, meindex, msgbuf, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); +} +static void NPC_Sysinfo_SetOneloop( int meindex, int tindex, char *msg) +{ + int interval; + char msgbuf[256]; + char buff[256]; + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) { + interval = atoi( buff); + if( interval > 0 ) { + setOnelooptime_ms( (unsigned)interval); + } + } + snprintf( msgbuf, sizeof(msgbuf),"Onelooptime = %d 秒", + getOnelooptime_ms()); + CHAR_talkToCli( tindex, meindex, msgbuf, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); +} +static void NPC_Sysinfo_TitleRestart( int meindex, int tindex, char *msg) +{ + int rc; + char msgbuf[256]; + + rc = TITLE_reinitTitleName(); + if( rc) { + snprintf( msgbuf, sizeof(msgbuf),"读取完毕。" ); + } + else { + snprintf( msgbuf, sizeof(msgbuf),"发生ERROR。" ); + } + CHAR_talkToCli( tindex, meindex, msgbuf, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); +} + + +static void NPC_Sysinfo_SetSaacwrite( int meindex, int tindex, char *msg) +{ + int interval; + char msgbuf[256]; + char buff[256]; + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) { + interval = atoi( buff); + if( interval > 0 ) { + setSaacwritenum( (unsigned)interval); + } + } + snprintf( msgbuf, sizeof(msgbuf),"Saacwritenum = %d ",getSaacwritenum()); + CHAR_talkToCli( tindex, meindex, msgbuf, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); +} +static void NPC_Sysinfo_SetSaacread( int meindex, int tindex, char *msg) +{ + int interval; + char msgbuf[256]; + char buff[256]; + if( getStringFromIndexWithDelim( msg, " ", 2, buff, sizeof( buff)) == TRUE ) { + interval = atoi( buff); + if( interval > 0 ) { + setSaacreadnum( (unsigned)interval); + } + } + snprintf( msgbuf, sizeof(msgbuf),"Saacreadnum = %d ",getSaacreadnum()); + CHAR_talkToCli( tindex, meindex, msgbuf, + CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR)); +} diff --git a/gmsv/npc/npc_timeman.c b/gmsv/npc/npc_timeman.c new file mode 100644 index 0000000..0cb951c --- /dev/null +++ b/gmsv/npc/npc_timeman.c @@ -0,0 +1,231 @@ +#include "version.h" +#include +#include "object.h" +#include "char_base.h" +#include "char.h" +#include "util.h" +#include "npcutil.h" +#include "npc_oldman.h" +#include "title.h" +#include "char_data.h" +#include "readmap.h" +#include "lssproto_serv.h" +#include "log.h" +#include "handletime.h" + + + + + +enum { + E_INT_GRAPHIC = CHAR_NPCWORKINT1, /* 褥蟆及 飓 */ + E_INT_GRAPHIC2 = CHAR_NPCWORKINT2, /* 褥 及 飓 */ + E_INT_BORN = CHAR_NPCWORKINT3, /* 藕戏凛棉 */ + E_INT_DEAD = CHAR_NPCWORKINT4, /* 壅尹月凛棉*/ + E_INT_MODE = CHAR_NPCWORKINT5, /* 蜇箕及乒□玉 */ + E_INT_NOWGRAPHIC = CHAR_NPCWORKINT6, /* 蜇箕及弘仿白奴永弁瓜件田□ */ + +}; + + +typedef struct { + char arg[32]; + int born; + int dead; +}NPC_TimeMan; + + +#define YOAKE 700 +#define NICHIBOTU 300 +#define SHOUGO 125 +#define YONAKA 500 + +static NPC_TimeMan TimeTble[] = { + + {"ALLNIGHT", NICHIBOTU+1, YOAKE}, /* 脐 互请化中卅中凛 */ + {"ALLNOON", YOAKE+1, NICHIBOTU},/* 脐 互请化中月凛 */ + {"AM", YONAKA+1, SHOUGO}, /* AM 凛及心 */ + {"PM", SHOUGO+1, YONAKA}, /* PM 凛及心 */ + {"FORE", YOAKE+1, SHOUGO}, /* 脐 互匹化井日恳诟引匹 */ + {"AFTER", SHOUGO+1, NICHIBOTU},/* 恳诟井日脐 互释戈引匹 */ + {"EVNING", NICHIBOTU+1, YONAKA}, /* 脐 互释氏匹井日蕞 引匹 */ + {"MORNING", YONAKA+1, YOAKE}, /* 蕞 井日脐 互哝月引匹 */ + {"FREE", 0, 1024}, +}; + + + + +BOOL NPC_TimeManInit( int meindex ) +{ + + int i=0; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[32]; + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("GetArgStrErr"); + return FALSE; + } + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPETOWNPEOPLE ); + if( NPC_Util_GetStrFromStrWithDelim( argstr, "change_no", buf, sizeof( buf)) != NULL ){ + if(strstr(buf,"CLS")!=NULL){ + CHAR_setWorkInt( meindex,E_INT_GRAPHIC2, 9999 ); + }else{ + CHAR_setWorkInt( meindex,E_INT_GRAPHIC2, atoi(buf) ); + } + }else{ + CHAR_setWorkInt( meindex,E_INT_GRAPHIC2, 9999 ); + } + + CHAR_setWorkInt( meindex, E_INT_GRAPHIC, CHAR_getInt( meindex, CHAR_BASEIMAGENUMBER) ); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "time", buf, sizeof( buf)) != NULL ){ + for(i=0 ; i<9 ; i++){ + if(strstr(buf,TimeTble[i].arg) != NULL){ + CHAR_setWorkInt( meindex, E_INT_BORN, TimeTble[i].born); + CHAR_setWorkInt( meindex, E_INT_DEAD, TimeTble[i].dead); + return TRUE; + } + } + } + + return FALSE; + +} + + +void NPC_TimeManTalked( int meindex , int talkerindex , char *msg ,int color ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[512]; + char buf[512]; + int tokennum=0; + int i; + + + /*-- 及蟆卞中月井升丹井"--*/ + if(NPC_Util_isFaceToFace( meindex ,talkerindex ,2)==FALSE){ + /* ㄠ弘伉永玉动 及心 */ + if( NPC_Util_CharDistance( talkerindex ,meindex ) > 1) return; + } + + if(CHAR_getInt(meindex,CHAR_BASEIMAGENUMBER)==9999){ + /*--壅尹化中月乒□玉--*/ + return; + } + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("GetArgStrErr"); + return; + } + + + if( CHAR_getInt(talkerindex,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER )return; + + if( NPC_Util_charIsInFrontOfChar( talkerindex, meindex, 3 ) ==FALSE) return; + + + + + if(CHAR_getWorkInt(meindex,E_INT_MODE)==0){ + /*--丢永本□斥毛忒允 */ + NPC_Util_GetStrFromStrWithDelim(argstr,"main_msg",buf,sizeof( buf) ); + + }else{ + /*弘仿白奴永弁 毛 尹凶分仃卅及匹}啜丹丢永本□斥毛忒允 */ + NPC_Util_GetStrFromStrWithDelim(argstr,"change_msg",buf,sizeof( buf) ); + } + + tokennum = 1; + /* 戊件穴匹嗉濠日木凶玄□弁件互窒仇丐月井醒尹月 */ + for( i=0;buf[i]!='\0';i++ ){ + if( buf[i] == ',' ) tokennum++; + } + + /* 仿件母丞匹升木毛韵月井瑁户化}公及玄□弁件毛潸曰分允 */ + getStringFromIndexWithDelim( buf,",", rand()%tokennum+1,token, sizeof(token)); + /*--仄扎屯月--*/ + CHAR_talkToCli( talkerindex, meindex, token, CHAR_COLORWHITE ); + + +} + +/** 引歹曰卞窒井互粟仇匀凶午五卞裟壬木月*/ +void NPC_TimeManWatch( int meobjindex, int objindex, CHAR_ACTION act, + int x,int y,int dir, int* opt,int optlen ) +{ + int meindex=0; + int index; + LSTIME nowlstime; + int born; + int dead; + + if( OBJECT_getType( objindex) != OBJTYPE_CHARA) return; + index = OBJECT_getIndex( objindex); + + /* 皿伊奶乩□卞及心 杀允月 */ + if( CHAR_getInt( index, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER) return; + + meindex = OBJECT_getIndex( meobjindex); + born = CHAR_getWorkInt( meindex , E_INT_BORN ); + dead = CHAR_getWorkInt( meindex , E_INT_DEAD ); + +// print("now_hour=%d",nowlstime.hour); + + /* 凛棉毛苇化橇谪毛瑁户月 */ + if(born < dead){ + RealTimeToLSTime( NowTime.tv_sec, &nowlstime); + if( (born < nowlstime.hour) && (dead > nowlstime.hour) ){ + if(CHAR_getWorkInt(meindex,E_INT_NOWGRAPHIC) + ==CHAR_getWorkInt( meindex, E_INT_GRAPHIC)) return; + + CHAR_setInt(meindex,CHAR_BASEIMAGENUMBER, + CHAR_getWorkInt( meindex, E_INT_GRAPHIC)); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX ) ); + CHAR_setWorkInt(meindex,E_INT_MODE,0); + CHAR_setWorkInt(meindex,E_INT_NOWGRAPHIC, + CHAR_getInt(meindex,CHAR_BASEIMAGENUMBER)); + }else{ + /*-壅尹化中月--*/ + if(CHAR_getWorkInt(meindex,E_INT_NOWGRAPHIC) + ==CHAR_getWorkInt( meindex, E_INT_GRAPHIC2)) return; + + CHAR_setInt(meindex,CHAR_BASEIMAGENUMBER, + CHAR_getWorkInt( meindex, E_INT_GRAPHIC2)); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX ) ); + CHAR_setWorkInt(meindex,E_INT_MODE,1); + CHAR_setWorkInt(meindex,E_INT_NOWGRAPHIC, + CHAR_getInt(meindex,CHAR_BASEIMAGENUMBER)); + + } + }else{ + RealTimeToLSTime( NowTime.tv_sec, &nowlstime); + if( (born < nowlstime.hour && 1024 > nowlstime.hour) + || ( 0 < nowlstime.hour && dead > nowlstime.hour) + ){ + if(CHAR_getWorkInt(meindex,E_INT_NOWGRAPHIC) + ==CHAR_getWorkInt( meindex, E_INT_GRAPHIC)) return; + + CHAR_setInt(meindex,CHAR_BASEIMAGENUMBER, + CHAR_getWorkInt( meindex, E_INT_GRAPHIC)); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX ) ); + CHAR_setWorkInt(meindex,E_INT_MODE,0); + CHAR_setWorkInt(meindex,E_INT_NOWGRAPHIC, + CHAR_getInt(meindex,CHAR_BASEIMAGENUMBER)); + }else{ + if(CHAR_getWorkInt(meindex,E_INT_NOWGRAPHIC) + ==CHAR_getWorkInt( meindex, E_INT_GRAPHIC2)) return; + + CHAR_setInt(meindex,CHAR_BASEIMAGENUMBER, + CHAR_getWorkInt( meindex, E_INT_GRAPHIC2)); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX ) ); + CHAR_setWorkInt(meindex,E_INT_MODE,1); + CHAR_setWorkInt(meindex,E_INT_NOWGRAPHIC, + CHAR_getInt(meindex,CHAR_BASEIMAGENUMBER)); + } + } + +} + diff --git a/gmsv/npc/npc_townpeople.c b/gmsv/npc/npc_townpeople.c new file mode 100644 index 0000000..401a01e --- /dev/null +++ b/gmsv/npc/npc_townpeople.c @@ -0,0 +1,72 @@ +#include "version.h" +#include "object.h" +#include "char_base.h" +#include "char.h" +#include "util.h" +#include "handletime.h" +#include "anim_tbl.h" +#include "npc_door.h" +#include "lssproto_serv.h" +#include "npcutil.h" + + +/* + * 引切及夫午太午 by nakamura + * 正奶皿 “TownPeople + * 仄井仃日木凶午五卞NPCARGUMENT及 侬 毛 仄井仃化五凶谛卞 允[ + * + * 引凶}npcarg卞 仇氏卞切反,漆 反化氏五互中中匹允友 + * 及方丹卞 剩戊件穴毛犯伉立正午仄化 醒及丢□本□斥毛 + * 踏仁仇午互匹五}公及桦宁仿件母丞匹公及 井日仄扎屯月[ + * npcgen.perl 匹反} MAN匹丐月[ MSG午幻午氏升云卅元分卅丐 + * + */ + +/* + * 仄井仃日木凶午五反NPCARGUMENT毛公及引引 允[ + */ +void NPC_TownPeopleTalked( int index, int talker, char *msg, int color ) +{ + char arg[NPC_UTIL_GETARGSTR_BUFSIZE], token[NPC_UTIL_GETARGSTR_LINEMAX]; + int i, tokennum; + + /* 3弘伉永玉动 及桦宁分仃忒蚕允月 */ + + if( CHAR_getInt(talker,CHAR_WHICHTYPE) == CHAR_TYPEPLAYER + && NPC_Util_charIsInFrontOfChar( talker, index, 3 ) ){ + + NPC_Util_GetArgStr( index, arg, sizeof( arg)); + + tokennum = 1; + /* 戊件穴匹嗉濠日木凶玄□弁件互窒仇丐月井醒尹月 */ + for( i=0;arg[i]!='\0';i++ ){ + if( arg[i] == ',' ) tokennum++; + } + + /* 仿件母丞匹升木毛韵月井瑁户化}公及玄□弁件毛潸曰分允 */ + getStringFromIndexWithDelim( arg,",", + rand()%tokennum+1,token, sizeof(token)); + + CHAR_talkToCli( talker, index, token, CHAR_COLORWHITE ); + } +} + +/* + * 赓渝祭允月[ + */ +BOOL NPC_TownPeopleInit( int meindex ) +{ + + //CHAR_setInt( meindex , CHAR_HP , 0 ); + //CHAR_setInt( meindex , CHAR_MP , 0 ); + //CHAR_setInt( meindex , CHAR_MAXMP , 0 ); + //CHAR_setInt( meindex , CHAR_STR , 0 ); + //CHAR_setInt( meindex , CHAR_TOUGH, 0 ); + //CHAR_setInt( meindex , CHAR_LV , 0 ); + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPETOWNPEOPLE ); + //CHAR_setFlg( meindex , CHAR_ISOVERED , 1 ); + //CHAR_setFlg( meindex , CHAR_ISATTACKED , 0 ); /* 猾今木卅中方氏 */ + + return TRUE; +} diff --git a/gmsv/npc/npc_transerman.c b/gmsv/npc/npc_transerman.c new file mode 100644 index 0000000..644f4e9 --- /dev/null +++ b/gmsv/npc/npc_transerman.c @@ -0,0 +1,201 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "npc_transerman.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" + +//特地从天堂高薪挖角来的"传送师" +#ifdef _TRANSER_MAN +enum { + WINDOW_START=1, + WINDOW_SELECT, + WINDOW_WARP, + WINDOW_END, +}; +enum { + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT1, +/* + 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, +*/ +}; + +#define STANDBYTIME 50 + +static void NPC_TranserMan_selectWindow( int meindex, int toindex, int num,int select); +BOOL TranserMan_GetMenuStr( int meindex, int toindex, char *npcarg, char *token); + +BOOL NPC_TranserManInit( 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); + return TRUE; +} +//CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANT,1); +void NPC_TranserManTalked( 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; + } +#ifdef _ITEM_CHECKWARES + if( CHAR_CheckInItemForWares( talkerindex, 0) == FALSE ){ + CHAR_talkToCli( talkerindex, meindex, "根据传送师工会规定,不能服务携带货物的人!", CHAR_COLORYELLOW); + return; + } +#endif +// Syu ADD 天才传送师判断组队状态 + if( CHAR_getWorkInt ( talkerindex , CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE) + { + CHAR_talkToCli( talkerindex, meindex, "根据传送师工会规定,不能帮组队中的人传送!",CHAR_COLORYELLOW); + return; + } + + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + NPC_TranserMan_selectWindow( meindex, talkerindex, WINDOW_START, 0); +} + +void NPC_TranserManWindowTalked( int meindex, int talkerindex, int seqno, + int select, char *data) +{ + if( select == WINDOW_BUTTONTYPE_CANCEL || select == WINDOW_BUTTONTYPE_NO) + return; + switch( seqno) { + case NPC_TRANSERMAN_START: + break; + case NPC_TRANSERMAN_SELECT: + NPC_TranserMan_selectWindow( meindex, talkerindex, WINDOW_SELECT, atoi( data)); + break; + case NPC_TRANSERMAN_WARP: + if( select == WINDOW_BUTTONTYPE_CANCEL ) + return; + NPC_TranserMan_selectWindow( meindex, talkerindex, WINDOW_WARP, atoi( data)); + break; + case NPC_TRANSERMAN_END: + break; + } + +} + +static void NPC_TranserMan_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); + + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + + 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: + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "START_MSG", token, sizeof( token) ) == NULL) { + print("TranserMan Get START_MSG ERROR !"); + return; + } + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, WINDOW_START); + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowno = NPC_TRANSERMAN_SELECT; + break; + case WINDOW_SELECT: + if( TranserMan_GetMenuStr( meindex, toindex, npcarg, token) == FALSE ) { + print( "TranserMan GetMenu ERROR !!"); + return; + } + windowtype = WINDOW_MESSAGETYPE_SELECT; + buttontype = WINDOW_BUTTONTYPE_CANCEL; + windowno = NPC_TRANSERMAN_WARP; + break; + case WINDOW_WARP: + if( ActionNpc_CheckMenuFree( meindex, toindex, npcarg, select) == FALSE ){ + memset( token, 0, sizeof( token)); + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "FAIL_MSG", token, sizeof( token) ) != NULL) { + CHAR_talkToCli( toindex, meindex, token, CHAR_COLORYELLOW); + } + } + return; + + case WINDOW_END: + break; + } + + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token); +} + + +void NPC_TranserManLoop( int meindex) +{ + +} + +BOOL TranserMan_GetMenuStr( int meindex, int toindex, char *npcarg, char *token) +{ + char buf1[1024], buf2[256], buf3[256]; + BOOL FINDS=FALSE; + int talkNo=1; + if( npcarg == NULL ) return FALSE; + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "MenuHead", buf1, sizeof( buf1) ) == NULL){ + print("TranserMan Get MenuHead ERROR!"); + return FALSE; + } + sprintf( token, "%s\n", buf1); + + while( getStringFromIndexWithDelim( npcarg,"}",talkNo, buf1, sizeof( buf1)) != FALSE ) { + talkNo++; + memset( buf2, 0, sizeof( buf2)); + if( NPC_Util_GetStrFromStrWithDelim( buf1, "MenuStr", buf2, sizeof( buf2)) == NULL ) + continue; + FINDS = TRUE; + + sprintf( buf3, " %s\n", buf2); + strcat( token, buf3); + } + + return FINDS; +} + +#endif + + diff --git a/gmsv/npc/npc_transmigration.c b/gmsv/npc/npc_transmigration.c new file mode 100644 index 0000000..c08f0e9 --- /dev/null +++ b/gmsv/npc/npc_transmigration.c @@ -0,0 +1,1783 @@ +#include "version.h" +#include +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "enemy.h" +#include "log.h" +#include "battle.h" +#include "readmap.h" +#include "npc_transmigration.h" + +#ifdef _PET_TRANS +#include "npc_pettransman.h" +#endif + +static void NPC_Transmigration_selectWindow( int meindex, int toindex, int num); +static int NPC_TransmigrationCheck(int meindex, int talker); +BOOL NPC_TransmigrationAddPet(int meindex, int talker, int petid); +//楮醒及烂聒 +int NPC_StartpointCheck(int meindex,int talker); +BOOL NPC_TransmigrationMain(int meindex, int toindex, char *buf); +int NPC_TransmigrationFlg_CLS(int meindex, int toindex); +BOOL NPC_TransmigrationDelPet(int meindex, int talker); +BOOL NPC_TransmigrationStatus(int meindex, int toindex,int *work); +BOOL NPC_TransmigratiomWarp(int meindex, int toindex, char *buf); +void s_eventsetend( int charaindex, int shiftbit ); + +#ifdef _PET_TRANS +int Pet_Select; +#endif + +/********************************* +* 赓渝质 +*********************************/ +BOOL NPC_TransmigrationInit( int meindex ) +{ + + /*--平乓仿及正奶皿毛涩烂--*/ + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPETRANSMIGRATION ); + + return TRUE; + +} + +/********************************* +* 仄井仃日木凶凛及质 +*********************************/ +void NPC_TransmigrationTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ +#ifdef _PET_TRANS + int i,petindex; + char buf[256]; +#endif + /* 皿伊奶乩□卞覆仄化分仃 杀允月 */ + 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; + } +// print("savepoot=%d",CHAR_getInt( talkerindex, CHAR_SAVEPOINT)); +// NPC_StartpointCheck( meindex, talkerindex); + + +//玛雷菲雅判断 成立 宠物转生 不成立 人物转生 +#ifdef _PET_TRANS + for(i=0 ; i < CHAR_MAXPETHAVE ; i++) { + petindex = CHAR_getCharPet( talkerindex, i); + if( petindex == -1 ) + continue; + //检查宠物的 ID 是否为玛雷菲雅 1479 ID 为718 + if( CHAR_getInt( petindex, CHAR_PETID) == 718 +#ifdef _PET_2TRANS + || CHAR_getInt( petindex, CHAR_PETID) == 401 +#endif + ) { + if( CHAR_getInt( petindex, CHAR_LV) > 79 ) { + //continue; + }else if( CHAR_getInt( petindex, CHAR_LV) == 79 ) { + if( strcmp( CHAR_getChar( petindex, CHAR_OWNERCDKEY), CHAR_getChar( talkerindex, CHAR_CDKEY) ) || + strcmp( CHAR_getChar( petindex, CHAR_OWNERCHARANAME), CHAR_getChar( talkerindex, CHAR_NAME) )) { + sprintf( buf,"你身上的玛雷菲雅,并不是你的啊!"); + CHAR_talkToCli( talkerindex, -1, buf, CHAR_COLORWHITE); + return; + } + break; + } + } + } + + if(i != CHAR_MAXPETHAVE) { + CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANT,1); + NPC_PetTransMan_selectWindow( meindex, talkerindex,0,-1); + }else { +#endif + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT,1); + NPC_Transmigration_selectWindow( meindex, talkerindex, 0); +#ifdef _PET_TRANS + } +#endif + + //原转生 + //CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT,1); + //NPC_Transmigration_selectWindow( meindex, talkerindex, 0); + +} + + +//备质 卞坌仃月 +static void NPC_Transmigration_selectWindow( int meindex, int toindex, int num) +{ + + char token[1024]; + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[2048]; + char buf2[512]; + char tmp[512]; + char s_tensei[64]; + int buttontype = 0; + int windowtype = 0; + int windowno = 0; + int tenseiNo = 1; + int fd = getfdFromCharaIndex( toindex); + int i = 1; + BOOL tenflg = FALSE; + char *elder[4] = {"samugiru","marinasu","jaja","karutarna"}; + int point; + int ten_no; + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("Tensei:GetArgStrErr"); + return; + } + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + tenseiNo = CHAR_getInt( toindex, CHAR_TRANSMIGRATION); + tenseiNo++; + if(CHAR_getWorkInt( toindex, CHAR_WORKSHOPRELEVANT) >= 2){ + tenseiNo--; + } + + //涩烂白央奶伙 匹及鳖戏荚醒卞丐丹手及毛蓟少凶户及赏 + sprintf(s_tensei,"TENSEI:%d",tenseiNo); + + while(getStringFromIndexWithDelim( npcarg,"END",i,buf,sizeof( buf)) != FALSE){ + i++; + if(strstr(buf,s_tensei) != NULL) { + tenflg = TRUE; + break; + } + } +#if 0 + //升木卞手丐化反引日卅井匀凶日蔽 + if(tenflg == FALSE){ + print("SettingFile Error "); + return ; + } +#endif + //ttom + print("\nTrans meindex=%d,toindex=%d,num=%d",meindex,toindex,num); + //ttom + CONNECT_set_state_trans(fd,6); + //ttom end + + //公木冗木及质 卞坌仃月[ + switch( num){ + case 0: + //ttom + //CONNECT_set_state_trans(fd,0); + //ttom end + ten_no = NPC_TransmigrationCheck(meindex, toindex); + if( +#ifdef _TRANS_6 + ten_no < 6 +#else +#ifdef _PK_SERVER + ten_no < 3//百万PK限制到3转 +#else + ten_no < 5 +#endif +#endif//_TRANS_6 + && ten_no >= 0){ + //椭瘀弁伉失□ + if(NPC_Util_GetStrFromStrWithDelim( buf,"startmsg", token,sizeof( token) ) + == NULL) + { + print("startmsgErr"); + return; + } + buttontype = WINDOW_BUTTONTYPE_NEXT; + //ttom + CONNECT_set_state_trans(fd,0); + //ttom end + }else if( +#ifdef _TRANS_6 + ten_no == 6 +#else +#ifdef _PK_SERVER + ten_no == 3//百万PK限制到3转 +#else + ten_no == 5 +#endif +#endif//_TRANS_6 + ){ + //鳖戏毛ㄤ荚支匀凶 + if(NPC_Util_GetStrFromStrWithDelim( npcarg,"maxmsg", token,sizeof( token) ) + == NULL) + { + print("maxmsgErr"); + return; + } + buttontype = WINDOW_BUTTONTYPE_OK; + }else{ + //椭瘀弁伉失仄化卅中 + if(NPC_Util_GetStrFromStrWithDelim( buf,"nonemsg", token,sizeof( token) ) + == NULL) + { + print("nonemsgErr"); + return; + } + buttontype = WINDOW_BUTTONTYPE_OK; + + } + windowno = CHAR_WINDOWTYPE_TRANSMIGRATION_START; + + break; + + case 1: + if(NPC_Util_GetStrFromStrWithDelim( buf,"mainmsg", token,sizeof( token) ) + == NULL) + { + print("mainmsgErr"); + return; + } + buttontype = WINDOW_BUTTONTYPE_OKCANCEL; + windowno = CHAR_WINDOWTYPE_TRANSMIGRATION_MAIN; + break; + + case 2: + // Robin 2001/03/05 Tensei Check + //if(!CHAR_getWorkInt(toindex,CHAR_TENSEICHECKED)) return; + + //鳖戏质 毛 + point = NPC_StartpointCheck( meindex, toindex); + if(point == -1) { + return; + } + + NPC_Util_GetStrFromStrWithDelim( npcarg,elder[point],buf2,sizeof( buf2)); + if(NPC_TransmigrationMain(meindex, toindex, buf2) == FALSE) + { + return; + } + + + sprintf( tmp, "yesmsg%d", + CHAR_getWorkInt( toindex, CHAR_WORKSHOPRELEVANT)); + + //鳖戏蔽 丢永本□斥毛分允[ + if(NPC_Util_GetStrFromStrWithDelim( buf,tmp, token,sizeof( token) ) + == NULL) + { + print("yesmsgErr"); + return; + } + + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, + CHAR_getWorkInt( toindex, CHAR_WORKSHOPRELEVANT) +1 + ); + sprintf( tmp, "yesmsg%d", + CHAR_getWorkInt( toindex, CHAR_WORKSHOPRELEVANT)); + + //鳖戏蔽 丢永本□斥毛分允[ + //鳖戏蔽 丢永本□斥毛分允[ + if(strstr(buf, tmp) == NULL) { + buttontype = WINDOW_BUTTONTYPE_OK; + windowno = CHAR_WINDOWTYPE_TRANSMIGRATION_END; + }else { + buttontype = WINDOW_BUTTONTYPE_NEXT; + windowno = CHAR_WINDOWTYPE_TRANSMIGRATION_END; + } + break; + + case 3: + + /*--蓟 --*/ + /*--平□伐□玉及民尼永弁毛垫丹--*/ + if(NPC_Util_GetStrFromStrWithDelim( buf,"nomsg", token,sizeof( token) ) + == NULL) + { + print("nomsgErr"); + return; + } + buttontype = WINDOW_BUTTONTYPE_OK; + windowno = CHAR_WINDOWTYPE_TRANSMIGRATION_NONE; + + break; + + case 4: + //鳖戏 及丢永本□斥质 + sprintf( tmp, "yesmsg%d", + CHAR_getWorkInt( toindex, CHAR_WORKSHOPRELEVANT)); + //鳖戏蔽 丢永本□斥毛分允[ + if(NPC_Util_GetStrFromStrWithDelim( buf,tmp, token,sizeof( token) ) + == NULL) + { + print("yesmsgErr"); + return; + } + + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, + CHAR_getWorkInt( toindex, CHAR_WORKSHOPRELEVANT) +1 + ); + sprintf( tmp, "yesmsg%d", + CHAR_getWorkInt( toindex, CHAR_WORKSHOPRELEVANT)); + + //鳖戏蔽 丢永本□斥毛分允[ + //鳖戏蔽 丢永本□斥毛分允[ + if(strstr(buf, tmp) == NULL) + { + buttontype = WINDOW_BUTTONTYPE_OK; + windowno = CHAR_WINDOWTYPE_TRANSMIGRATION_END; + }else{ + buttontype = WINDOW_BUTTONTYPE_NEXT; + windowno = CHAR_WINDOWTYPE_TRANSMIGRATION_END; + } + + + break; + case 5: + + // Robin 2001/03/05 Tensei Check + //if(!CHAR_getWorkInt(toindex,CHAR_TENSEICHECKED)) return; + //鳖戏质 毛 + point = NPC_StartpointCheck( meindex, toindex); + if(point == -1) return; + NPC_Util_GetStrFromStrWithDelim( npcarg,elder[point],buf2,sizeof( buf2)); + NPC_TransmigratiomWarp(meindex, toindex, buf2); +// buttontype = WINDOW_BUTTONTYPE_OK; +// windowno = CHAR_WINDOWTYPE_TRANSMIGRATION_END; + return; + break; + + + } +// makeEscapeString( token, escapedname, sizeof(escapedname)); + /*-仇仇匹霜耨允月--*/ + lssproto_WN_send( fd, windowtype, + buttontype, + windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); +} +/*----------------------------------------- +弁仿奶失件玄井日忒匀化五凶凛卞裟太请今木月[ +-------------------------------------------*/ +void NPC_TransmigrationWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + + int datanum = -1; + + int fd = getfdFromCharaIndex( talkerindex); + /*-- 及引歹曰卞中卅中午五反蔽 --*/ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 2) { + return; + } + //ttom + //CONNECT_set_state_trans(fd,6); + //ttom end + datanum = atoi( data); + switch( seqno) { + /*-- 赓及丢永本□斥-*/ + case CHAR_WINDOWTYPE_TRANSMIGRATION_START: + if( select == WINDOW_BUTTONTYPE_NEXT) { + //ttom + if(CONNECT_get_state_trans(fd)==0){ } else return; + //ttom end + NPC_Transmigration_selectWindow( meindex, talkerindex,1); + //ttom + CONNECT_set_state_trans(fd,1); + //ttom end + + } + break; + + //鳖戏允月井升丹井 仁丢永本□斥及蚕尹 + case CHAR_WINDOWTYPE_TRANSMIGRATION_MAIN: + if( select == WINDOW_BUTTONTYPE_OK) { + //ttom + if(CONNECT_get_state_trans(fd)==1){ } else return; + //ttom end + NPC_Transmigration_selectWindow( meindex, talkerindex, 2); + //ttom + CONNECT_set_state_trans(fd,2); + //ttom end + }else if(select == WINDOW_BUTTONTYPE_CANCEL) { + NPC_Transmigration_selectWindow( meindex, talkerindex, 3); + } + break; + + /*-- 及丢永本□斥--*/ + case CHAR_WINDOWTYPE_TRANSMIGRATION_END: + if( select == WINDOW_BUTTONTYPE_NEXT) { + //ttom + if(CONNECT_get_state_trans(fd)==2){ } else return; + //ttom end + NPC_Transmigration_selectWindow( meindex, talkerindex, 4); + //ttom + CONNECT_set_state_trans(fd,4); + //ttom end + }else if( select == WINDOW_BUTTONTYPE_OK) { + //ttom + if(CONNECT_get_state_trans(fd)==4){ } else return; + //ttom end + NPC_Transmigration_selectWindow( meindex, talkerindex, 5); + } + break; + +//ANDY_ADD 10/19 +#ifdef _PET_TRANS + + case CHAR_WINDOWTYPE_PETTRANS_START: //开始对话 + if( select == WINDOW_BUTTONTYPE_NEXT) { + NPC_PetTransMan_selectWindow( meindex, talkerindex, 1, 0); + } + break; + + case CHAR_WINDOWTYPE_PETTRANS_SELECT: //是否让宠物转生 + if( select == WINDOW_BUTTONTYPE_YES) { + NPC_PetTransMan_selectWindow( meindex, talkerindex, 2, 0); + }else { + NPC_PetTransMan_selectWindow( meindex, talkerindex, 5, 0); + } + break; + + case CHAR_WINDOWTYPE_PETTRANS_SELPET: //选宠 + if(select==WINDOW_BUTTONTYPE_CANCEL) { + NPC_PetTransMan_selectWindow( meindex, talkerindex, 5,-1 ); + }else { + Pet_Select = datanum; + NPC_PetTransMan_selectWindow( meindex, talkerindex, 3, datanum ); + } + break; + + case CHAR_WINDOWTYPE_PETTRANS_MAIN1: //确定宠物 确定/取消 + if(select==WINDOW_BUTTONTYPE_YES){ + NPC_PetTransMan_selectWindow( meindex, talkerindex, 4, Pet_Select); + }else { + NPC_PetTransMan_selectWindow( meindex, talkerindex, 5, -1); + } + break; + + case CHAR_WINDOWTYPE_PETTRANS_END: //宠物转生结束结束 + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + break; + +#endif + + } + + +} + +//************************************************************ +// 反元户及赢 镉卞伐□皿今六月 +//************************************************************ +BOOL NPC_TransmigratiomWarp(int meindex, int toindex, char *buf) +{ + char buf2[512]; + char buf3[128]; + char buf4[64]; + int floor=0 , x = 0, y = 0; + int i = 1; + int ret; + + //请褥翘仍午及椭瘀毛 仁 + while(getStringFromIndexWithDelim( buf,",",i,buf2,sizeof( buf2)) + != FALSE) + { + i++; + if(strstr(buf2,"Warp") != NULL) + { + getStringFromIndexWithDelim( buf2 ,"=" ,2, buf3 ,sizeof(buf3)); + //白夫失 + ret = getStringFromIndexWithDelim( buf3,".",1 ,buf4 ,sizeof( buf4)); + if(ret ==FALSE) return FALSE; + floor = atoi(buf4); + // 甄 + ret = getStringFromIndexWithDelim( buf3,".",2 ,buf4 ,sizeof( buf4)); + if(ret ==FALSE) return FALSE; + x = atoi(buf4); + // 甄 + ret = getStringFromIndexWithDelim( buf3,".",3 ,buf4 ,sizeof( buf4)); + if(ret ==FALSE) return FALSE; + y = atoi(buf4); + + } + } + + + //伐□皿燮及民尼永弁 + if( MAP_IsValidCoordinate( floor, x, y )== FALSE ){ + return FALSE; + } + + //ttom + /* + { + int tenseiNo; + tenseiNo=CHAR_getInt( toindex, CHAR_TRANSMIGRATION); + CHAR_setInt( toindex,CHAR_SKILLUPPOINT,tenseiNo*10); + print("\n the set the skillpoint %d",tenseiNo*10); + CHAR_sendStatusString( toindex , "P"); + } + */ + //ttom + + //伐□皿今六月 + CHAR_warpToSpecificPoint(toindex, floor, x, y); + + return TRUE; + +} + +//************************************************************ +//*请 鳔及民尼永弁 +// +// 曰袄“ +// ㄟ“扔丞幼伙 +// ㄠ“穴伉瓜旦 +// ㄡ“斥乓斥乓 +// ㄢ“市伙正□瓜 +// ≡ㄠ“巨仿□ +//************************************************************ +int NPC_StartpointCheck(int meindex,int talker) +{ + int point; + int shift = 0; + point = CHAR_getInt( talker, CHAR_SAVEPOINT); + for(shift = 0; shift < 4 ;shift++){ + if( (point & ( 1<< shift)) == ( 1<< shift)) { + return shift; + } + } + return -1; +} + +//******************************************************** +// +// 鳖戏椭瘀毛 凶仄化中月井升丹井及民尼永弁 +// +// 曰袄 +// 岳 “鳖戏荚醒 +// 撩 “-1 +// +//******************************************************** +static int NPC_TransmigrationCheck(int meindex, int talker) +{ + // 鳖戏椭瘀 + //伊矛伙互ㄧㄟ动晓 + //ㄣ勾及箪岭奶矛件玄互蔽歹匀化中月仇午 + // 蔽奶矛件玄毛仇卅允[(仇木反中日氏井卅 + int i,j,k=0; + int ch_no[4] = {39,40,42,46}; + int petindex; + int num; +// int petid[4] = {1, 2, 3, 4}; //矢永玄及 毛隙烂 + int petid[4] = {693, 694, 695, 696}; //矢永玄及 毛隙烂 +// int petidfinal[4] = {11, 12, 13, 14}; //矢永玄及 毛隙烂 + int petidfinal[4] = {693, 694, 695, 696}; //矢永玄及 毛隙烂 + + // Robin 2001/03/05 + //CHAR_setWorkInt(talker,CHAR_TENSEICHECKED,FALSE); + //手仄ㄤ荚动晓卅日鳖戏匹五卅中[ +#ifdef _TRANS_6 + if(CHAR_getInt( talker, CHAR_TRANSMIGRATION) >= 6){ + return 6; + } +#else + if(CHAR_getInt( talker, CHAR_TRANSMIGRATION) >= 5){ + return 5; + } +#endif + + //伊矛伙互ㄧㄟ动晓 + if(CHAR_getInt( talker, CHAR_LV) < 80) return -1; + + //奶矛件玄及白仿弘民尼永弁 +#ifdef _TRANS_6 + if(CHAR_getInt( talker, CHAR_TRANSMIGRATION) < 6){ +#else + if(CHAR_getInt( talker, CHAR_TRANSMIGRATION) < 5){ +#endif + for(i = 0; i < 4 ;i++) + if(NPC_EventCheckFlg( talker, ch_no[i] ) == FALSE) return -1; + } + + num = CHAR_getInt(talker, CHAR_TRANSMIGRATION); + + if(num < 4 ){ + //隙烂矢永玄毛手匀化中月井矢永玄民尼永弁 + for(i=0 ; i < CHAR_MAXPETHAVE ; i++){ + petindex = CHAR_getCharPet( talker, i); + if( petindex == -1 ) continue; + //ttom + //print("petid=%d ",CHAR_getInt( petindex, CHAR_PETID)); + //矢永玄及 反域踝井" + if(CHAR_getInt( petindex, CHAR_PETID) != petid[num]) continue; + + //矢永玄及伊矛伙反椭瘀毛 凶仄化中月井 +// if(CHAR_getInt( petindex, CHAR_LV) < PETLEVEL) continue; + //仇仇引匹五凶日公及矢永玄反 午 蝇 + break; + } + if(i == CHAR_MAXPETHAVE) return -1; + }else +#ifdef _TRANS_6 + if( num == 4 ) +#endif + { + for(j = 0; j < 4 ;j++){ + //诡荚 及桦宁反ㄣ 毛民尼永弁 + for(i=0 ; i < CHAR_MAXPETHAVE ; i++){ + petindex = CHAR_getCharPet( talker, i); + if( petindex == -1 ) continue; + // print("petid=%d ",CHAR_getInt( petindex, CHAR_PETID)); + //矢永玄及 反域踝井" + if(CHAR_getInt( petindex, CHAR_PETID) != petidfinal[j]) continue; + k++; + break; + } + } + if(k < 4) return -1; + } +#ifdef _TRANS_6 + else{ + /*int lasttalkelder = 2;//乌力 + if( CHAR_getInt( talker, CHAR_LASTTALKELDER) == 1 )//玛丽娜丝 + lasttalkelder = 112;//凯比 + else if( CHAR_getInt( talker, CHAR_LASTTALKELDER) == 2 )//加加 + lasttalkelder = 102;//克克尔 + else if( CHAR_getInt( talker, CHAR_LASTTALKELDER) == 3 )//卡鲁它那 + lasttalkelder = 34;//威伯 + print("\npetid:%d",lasttalkelder);*/ + + //找看看有没有带2转出生宠物 + for(i=0 ; i < CHAR_MAXPETHAVE ; i++){ + petindex = CHAR_getCharPet( talker, i); + if( petindex == -1 ) continue; + if( CHAR_getInt( petindex, CHAR_TRANSMIGRATION) == 2 + && ( CHAR_getInt( petindex, CHAR_PETID) == 2 + || CHAR_getInt( petindex, CHAR_PETID) == 112 + || CHAR_getInt( petindex, CHAR_PETID) == 102 + || CHAR_getInt( petindex, CHAR_PETID) == 34 ) ) break; + //if(CHAR_getInt( petindex, CHAR_TRANSMIGRATION) != 2 || CHAR_getInt( petindex, CHAR_PETID) != lasttalkelder ) continue; + } + if(i == CHAR_MAXPETHAVE){ + CHAR_talkToCli( talker,-1,"你没有带2转的出生宠哦!",CHAR_COLORWHITE); + return -1; + } + + + if(NPC_EventCheckFlg( talker, 63) == FALSE){ print("\nerr63");return -1;} + if(NPC_EventCheckFlg( talker, 136) == FALSE){ print("\nerr136");return -1;} + if(NPC_EventCheckFlg( talker, 175) == FALSE){ print("\nerr175");return -1;} + if(NPC_EventCheckFlg( talker, 176) == FALSE){ print("\nerr176");return -1;} + //检查有无15个魔界之门碎片 + j=0; + for( i=0 ; i 6) + CHAR_setInt(toindex ,CHAR_TRANSMIGRATION,6); + if( CHAR_getInt(toindex,CHAR_TRANSMIGRATION) == 6 )//6转後所送的宠 + present = 2546; +#else + if(CHAR_getInt( toindex, CHAR_TRANSMIGRATION) > 5) + CHAR_setInt(toindex ,CHAR_TRANSMIGRATION,5); +#endif + NPC_TransmigrationStatus(meindex, toindex, work); + NPC_TransmigrationFlg_CLS(meindex, toindex); + CHAR_setInt(toindex, CHAR_LV ,1); + CHAR_setMaxExp( toindex, 0); + +#ifdef _TRANS_6 +//删除魔界之门碎片 + for( i=0 ; i> 16 ) & 0xFFFF); + level = (float)(( equ >> 0 ) & 0xFFFF); + //tttom + //print("\n this test equ=%d,quest=%f,level=%f",equ,quest,level); + //鳖戏荚醒 + num = CHAR_getInt(toindex, CHAR_TRANSMIGRATION); // 前面已加1,故0转1时为1 + tmp = (float)para / 100; +#ifdef _TRANS_6 + if (num == 6) tmp = 620; // 六转生时旧点数不计 +#endif + ans =(float)tmp/12 + (float)(quest / 4) +( (float)(level- num * 85) /4); + return (int)ans; +} + +//******************************************************* +// 铨桩诡 +//******************************************************* +float Rounding(float work,int num) +{ + + float p; + + if(num <0 ) return work; + num--; + p = (float)pow(10,num); + + return ( (work * p + 0.5) /p); + + +} + +//******************************************************* +// +// 旦 □正旦楮溢及凳蕙 +// +//******************************************************* +BOOL NPC_TransmigrationStatus(int meindex, int toindex,int work[10]) +{ + int vital, str, tgh, dex; + int quest , level ,equ; + int t_quest, t_level; + int total,ans; + float tmp,lvup; + + vital = CHAR_getInt(toindex,CHAR_VITAL); + str = CHAR_getInt(toindex,CHAR_STR); + tgh = CHAR_getInt(toindex,CHAR_TOUGH); + dex = CHAR_getInt(toindex,CHAR_DEX); + + + //弁巨旦玄白仿弘毛民尼永弁 + quest = NPC_TransmigrationQuestCheck( toindex); + //伊矛伙 + level = CHAR_getInt(toindex,CHAR_LV); + + work[0] = level; + work[1] = quest; + + equ = CHAR_getInt(toindex, CHAR_TRANSEQUATION); + + t_quest = (float)(( equ >> 16 ) & 0xFFFF); + t_level = (float)(( equ >> 0 ) & 0xFFFF); + + if( level > 130 ) level = 130; + t_quest = t_quest + quest; + t_level = t_level + level; + + CHAR_setInt(toindex, CHAR_TRANSEQUATION, + ( t_quest << 16 )+( t_level << 0 ) + ); + + total = vital + str + tgh + dex; + ans = NPC_TransCalculation(toindex, total); + + work[2] = vital; + tmp = (float)vital/total * ans; + work[3] = Rounding(tmp,1) * 100; + + work[4] = str; + tmp = (float)str/total * ans; + work[5] = Rounding(tmp,1) * 100; + + work[6] = tgh; + tmp = (float)tgh/total * ans; + work[7] = Rounding(tmp,1) * 100; + + work[8] = dex; + tmp = (float)dex/total * ans; + work[9] = Rounding(tmp,1) * 100; + + //vital本永玄 + if(work[3] < 0) work[3] = 0; + CHAR_setInt(toindex, CHAR_VITAL, work[3]); + //str本永玄 + if(work[5] < 0) work[5] = 0; + CHAR_setInt(toindex, CHAR_STR, work[5]); + + //tghr本永玄 + if(work[7] < 0) work[7] = 0; + CHAR_setInt(toindex, CHAR_TOUGH, work[7]); + + //dex本永玄 + if(work[9] < 0) work[9] = 0; + CHAR_setInt(toindex, CHAR_DEX, work[9]); + + + + //伊矛伙 禾奶件玄手 凳 + lvup = CHAR_getInt(toindex, CHAR_SKILLUPPOINT ); +/*#ifdef _TRANS_6 + if( CHAR_getInt(toindex, CHAR_TRANSMIGRATION) == 6) + lvup = 620; +#endif*/ + lvup = lvup / 12; + lvup = Rounding(lvup, 1); + if(lvup < 0) lvup = 0; + CHAR_setInt(toindex, CHAR_SKILLUPPOINT, (int)lvup); + + /* 旦平伙失永皿匹五凶日仇木毛霜月 */ + if( CHAR_getInt( toindex,CHAR_SKILLUPPOINT ) >=1 ) + CHAR_Skillupsend(toindex); + + + return TRUE; + + +} + + +/*---------------------------- + * 矢永玄毛馨笛允月 + ------------------------------*/ +BOOL NPC_TransmigrationAddPet(int meindex, int talker, int petid) +{ + int ret; + char msgbuf[64]; + int enemynum; + int i,j; + int petindex; + int petindex2; + for( i = 0 ;i < CHAR_MAXPETHAVE ; i++) { + petindex = CHAR_getCharPet( talker, i); + if( petindex == -1 ) break; + } + if(i == CHAR_MAXPETHAVE) return FALSE; + enemynum = ENEMY_getEnemyNum(); + for( i = 0; i < enemynum; i ++ ) { + if( ENEMY_getInt( i, ENEMY_ID) == petid) { + break; + } + } + + if( i == enemynum ) return FALSE; + + ret = ENEMY_createPetFromEnemyIndex( talker, i); + + for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){ + if( CHAR_getCharPet( talker, i ) == ret )break; + } + if( i == CHAR_MAXPETHAVE ) i = 0; + if( CHAR_CHECKINDEX( ret ) == TRUE ){ + CHAR_setMaxExpFromLevel( ret, CHAR_getInt( ret, CHAR_LV )); + } + + petindex2 = CHAR_getCharPet(talker, i); + if( !CHAR_CHECKINDEX( petindex2) ) return FALSE; + + snprintf( msgbuf,sizeof( msgbuf), "拿到%s。", + CHAR_getChar(petindex2,CHAR_NAME)); + CHAR_talkToCli( talker, -1, msgbuf, CHAR_COLORWHITE); + for(j = 0; j < CHAR_MAXPETHAVE; j++){ + petindex = CHAR_getCharPet(talker, j); + if( !CHAR_CHECKINDEX( petindex) ) continue; + CHAR_complianceParameter( petindex ); + snprintf( msgbuf, sizeof( msgbuf ), "K%d", j ); + CHAR_sendStatusString( talker, msgbuf ); + snprintf( msgbuf, sizeof( msgbuf ), "W%d", j ); + CHAR_sendStatusString( talker, msgbuf ); + } + // 矢永玄毛澎卞 木凶夫弘 + LogPet( + CHAR_getChar( talker, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( talker, CHAR_CDKEY ), + CHAR_getChar( petindex2, CHAR_NAME), + CHAR_getInt( petindex2, CHAR_LV), + "TenseiGet", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + CHAR_getChar( petindex2, CHAR_UNIQUECODE) // shan 2001/12/14 + ); + + return TRUE; + +} + +#ifdef _TEACHER_SYSTEM +extern int FMAdvTbl[]; +#endif + +int NPC_TransmigrationFlg_CLS(int meindex, int toindex) +{ +#ifdef _TEACHER_SYSTEM + int iGetFame = 0; +#endif +#ifdef _PET_TRANS +#ifdef _PROSK99 + int endevflg[]={69,70,71,72,109,118,122,131,127,158,159,181,-1};//181:白狼奖品 +#else + int endevflg[]={69,70,71,72,109,118,122,131,127,158,159,-1}; +#endif + int nowevflg[]={69,70,71,72,-1}; +#endif +#ifdef _TRANS_6 + int flg[6] = {48,49,50,51,52,179}; +#else + int flg[5] = {48,49,50,51,52}; +#endif + int num= CHAR_getInt(toindex ,CHAR_TRANSMIGRATION); + int i; +#ifdef _PET_TRANS + i=0; + while(endevflg[i] != -1 ) { + if( NPC_EventCheckFlg( toindex, endevflg[i] ) == FALSE ) { + endevflg[i] = 0; + } + i++; + } + i=0; + while( nowevflg[i] != -1 ) { + if( NPC_NowEventCheckFlg( toindex, nowevflg[i] ) == FALSE ) { + nowevflg[i] = 0; + } + i++; + } +#endif + + CHAR_setInt(toindex,CHAR_ENDEVENT,0); + CHAR_setInt(toindex,CHAR_ENDEVENT2,0); + CHAR_setInt(toindex,CHAR_ENDEVENT3,0); +#ifdef _NEWEVENT + CHAR_setInt(toindex,CHAR_ENDEVENT4,0); + CHAR_setInt(toindex,CHAR_ENDEVENT5,0); + CHAR_setInt(toindex,CHAR_ENDEVENT6,0); +#endif + CHAR_setInt(toindex,CHAR_NOWEVENT,0); + CHAR_setInt(toindex,CHAR_NOWEVENT2,0); + CHAR_setInt(toindex,CHAR_NOWEVENT3,0); +#ifdef _NEWEVENT + CHAR_setInt(toindex,CHAR_NOWEVENT4,0); + CHAR_setInt(toindex,CHAR_NOWEVENT5,0); + CHAR_setInt(toindex,CHAR_NOWEVENT6,0); +#endif +#ifdef _ADD_NEWEVENT // WON 多增任务旗标 + CHAR_setInt(toindex,CHAR_ENDEVENT7,0); + CHAR_setInt(toindex,CHAR_NOWEVENT7,0); + CHAR_setInt(toindex,CHAR_ENDEVENT8,0); + CHAR_setInt(toindex,CHAR_NOWEVENT8,0); +#endif + + //鳖戏白仿弘毛 化月 +#ifdef _PET_TRANS + i=0; + while( endevflg[i] != -1 ) { + if( endevflg[i] > 0 ) { + // shan Begin + //NPC_EventSetFlg( toindex, endevflg[i]); + s_eventsetend(toindex, endevflg[i]); + // End + } + i++; + } + i=0; + while( nowevflg[i] != -1 ) { + if( nowevflg[i] > 0 ) { + NPC_NowEventSetFlg( toindex, nowevflg[i]); + } + i++; + } + +#endif + + for(i = 0 ;i < num ;i++) { + NPC_EventSetFlg(toindex, flg[i]); + // CoolFish: Family Adv 2001/8/4 + AddFMAdv(toindex, flg[i]); +#ifdef _TEACHER_SYSTEM + // 累加所得声望 + if(flg[i] < 179) iGetFame += FMAdvTbl[flg[i]]; +#endif + } +#ifdef _TEACHER_SYSTEM + iGetFame /= 20; // 导师获得学生所得声望的 5% (1/20) + // 检查所得的声望有没有大於0 + if(iGetFame > 0){ + // 检查有没有导师 + if(strlen(CHAR_getChar(toindex,CHAR_TEACHER_ID)) > 0 && strlen(CHAR_getChar(toindex,CHAR_TEACHER_NAME)) > 0){ + int iPlayernum = CHAR_getPlayerMaxNum(); + char szMsg[128]; + + // 检查导师在不在线上 + for(i=0;i= 0 ) + errtype = 3; + + if( errtype >= 0 ) { + if( NPC_Util_GetStrFromStrWithDelim( buf,errchar[ errtype], token,sizeof( token)) == NULL ) { + print("\n ERROR str errchar !!"); + return; + } + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_PETTRANS_END; + break; + } + if( NPC_Util_GetStrFromStrWithDelim( buf,"selectmsg", token,sizeof( token)) == NULL ) { + print("\n ERROR selectmsg !!"); + return; + } + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 1); + windowno = CHAR_WINDOWTYPE_PETTRANS_SELECT; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + buttontype=WINDOW_BUTTONTYPE_YESNO; + break; + + case 2: //选宠 + if( NPC_Util_GetStrFromStrWithDelim( buf,"setpetmsg", token,sizeof( token)) == NULL ) { + print("\n ERROR setpetmsg !!"); + return; + } + buttontype = WINDOW_BUTTONTYPE_NONE; + windowtype = WINDOW_MESSAGETYPE_PETSELECT; + windowno = CHAR_WINDOWTYPE_PETTRANS_SELPET; + break; + + case 3: //宠物转生 确定/取消 + if( NPC_Util_GetStrFromStrWithDelim( buf,"transmsg", buf1,sizeof( buf1)) == NULL ){ + print("\n ERROR transmsg !!"); + return; + } + strcpy( token,"\0"); + petindex = CHAR_getCharPet( toindex, select-1); + petname = CHAR_getUseName( petindex); + sprintf(token, "\n是[%s]没错吧? \n\n %s",petname,buf1); + + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowno = CHAR_WINDOWTYPE_PETTRANS_MAIN1; + break; + + case 4: //宠物转生 CHAR_TRANSMIGRATION + //转生条件判断 + petindex = CHAR_getCharPet( toindex, select-1); + if( !CHAR_CHECKINDEX( petindex) ) { + return; + } + if( CHAR_getInt( petindex, CHAR_FUSIONBEIT ) == 1 ) { + sprintf(token, "\n\n融合过的宠物不能转生喔!"); + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 0); + }else +#ifdef _PET_2TRANS + if( CHAR_getInt( toindex, CHAR_RIDEPET ) == select-1 /*&& CHAR_getInt( petindex, CHAR_TRANSMIGRATION ) > 0*/ ){//骑乘中的宠物不能转生 + sprintf(token, "\n\n骑乘中的宠物不能转生喔!"); + }else +#endif + if( CHAR_getInt( petindex, CHAR_LV) < 80 ) { + sprintf(token, "\n\n接受转生祝福的宠物必需要等级80以上喔!"); + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 0); + }else if( CHAR_getInt( petindex, CHAR_PETID) == 718 +#ifdef _PET_2TRANS + || CHAR_getInt( petindex, CHAR_PETID) == 401 +#endif + ){ + sprintf(token, "\n\n这只宠物不能转生喔!"); + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 0); +#ifdef _PET_2TRANS + }else if( CHAR_getInt( petindex, CHAR_TRANSMIGRATION ) > 1 ) { +#else + }else if( CHAR_getInt( petindex, CHAR_TRANSMIGRATION ) > 0 ) { +#endif + sprintf(token, "\n\n这只宠物已经接受过祝福了喔!"); + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 0); + //检查宠物是否重复转生 + }else { // 转生OK + petindex = CHAR_getCharPet( toindex, select-1); + if( NPC_PetTransManStatus( meindex, toindex, petindex) == FALSE ) + return; + if( NPC_Util_GetStrFromStrWithDelim( buf,"main1msg", token,sizeof( token)) == NULL ) + return; + } + + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_PETTRANS_END; //结束 + break; + + case 5: //宠物转生取消 + if( NPC_Util_GetStrFromStrWithDelim( buf,"cancelmsg", token,sizeof( token)) == NULL ) + return; + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 0); + buttontype = WINDOW_BUTTONTYPE_OK; + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = CHAR_WINDOWTYPE_PETTRANS_END; //结束 + break; + + default: + break; + } + lssproto_WN_send( fd, windowtype, buttontype, windowno, CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token); + +} + +int NPC_PetTransManCheck( int meindex, int toindex, int select) +{ + //char errchar[][56]={"errormy","erroritem","errorpet","failmsg"}; + int i; + int petindex = 0; + char token[256]; + int PetEvent_no[3]={4,69,70}; + //int PetEvent_no[3]={4,4,4}; + + int petNum = 0; + //宠物转生条件 + if( CHAR_getInt( toindex, CHAR_LV ) < 80 ) { + return 0; + }else { + //检查任务的FLAG 是否已完成宠转需要的任务 + for(i = 0; i < 3 ;i++) { + if( NPC_EventCheckFlg( toindex, PetEvent_no[i] ) == FALSE) { + return 0; + } + } + //检查所需(宠物/精灵) & 检查所需物品 + for(i=0 ; i < CHAR_MAXPETHAVE ; i++) { + petindex = CHAR_getCharPet( toindex, i); + if( petindex == -1 ) + continue; + //检查宠物的 ID 是否为玛雷菲雅 1479 ID 为718 + if(CHAR_getInt( petindex, CHAR_PETID) == 718 +#ifdef _PET_2TRANS + || CHAR_getInt( petindex, CHAR_PETID) == 401 +#endif + ){ + petNum ++; + if( CHAR_getInt( petindex, CHAR_LV) > 79 ) { + return 0; + }else if( CHAR_getInt( petindex, CHAR_LV) == 79 ) { + if( strcmp( CHAR_getChar( petindex, CHAR_OWNERCDKEY), CHAR_getChar( toindex, CHAR_CDKEY) ) || + strcmp( CHAR_getChar( petindex, CHAR_OWNERCHARANAME), CHAR_getChar( toindex, CHAR_NAME) )) { + sprintf( token,"你身上的玛雷菲雅,并不是你的啊!"); + CHAR_talkToCli( toindex, -1, token, CHAR_COLORWHITE); + return 0; + } + } + } + } + + if( petNum > 1 ) { + sprintf( token,"你怎会有那麽多玛雷菲雅呢?"); + CHAR_talkToCli( toindex, -1, token, CHAR_COLORWHITE); + print("\n error PetTrans : (PETID = 718) > 1 !!"); + return 0; + }else if( petNum != 1 ) { + print("\n 宠转发生错误 !!"); + return 0; + } + } + return -1; +} + +BOOL NPC_PetTransManStatus( int meindex, int toindex, int petNo) +{ + int petindex; + int LevelUpPoint = 0,petrank = 0; + int i,j,k,itemindex,itemID,count; + int vital1,str1,tgh1,dex1; + int vital2,str2,tgh2,dex2; + char token[128]; + int total1,total2,total,petLV,ans; + int petID,enemynum,ret; + int work[4]={0,0,0,0}; + struct PetTransDelItem { + int minItemID; + int maxItemID; + }DelItem[3] = { {19629,19632} , {19672,19687} , {19625,19628} }; +#define RAND(x,y) ((x-1)+1+ (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) ) +#ifdef _PET_2TRANS + int tran = CHAR_getInt ( petNo, CHAR_TRANSMIGRATION ); + int tpetidx1,tpetidx2; + if( tran == 0 ){ + tpetidx1 = 718; + tpetidx2 = 401; + } + else{ + tpetidx1 = 401; + tpetidx2 = 401; + } +#endif + + for(i=0 ; i < CHAR_MAXPETHAVE ; i++) { + petindex = CHAR_getCharPet( toindex, i); + if( petindex == -1 ) + continue; + if( +#ifdef _PET_2TRANS + CHAR_getInt( petindex, CHAR_PETID) == tpetidx1 + || CHAR_getInt( petindex, CHAR_PETID) == tpetidx2 +#else + CHAR_getInt( petindex, CHAR_PETID) == 718 +#endif + ){ + if( CHAR_getInt( petindex, CHAR_LV) == 79 ){ + if( strcmp( CHAR_getChar( petindex, CHAR_OWNERCDKEY), CHAR_getChar( toindex, CHAR_CDKEY) ) || + strcmp( CHAR_getChar( petindex, CHAR_OWNERCHARANAME), CHAR_getChar( toindex, CHAR_NAME) )) { + continue; + } + break; + } + } + } + if(i == CHAR_MAXPETHAVE) { + print("\n 宠物转生发生错误 !!"); + return FALSE; + } + + LevelUpPoint = CHAR_getInt( petindex, CHAR_ALLOCPOINT ); + petrank = CHAR_getInt( petindex, CHAR_PETRANK ); + + vital1 = (float)(( LevelUpPoint >> 24 ) & 0xFF); + str1 = (float)(( LevelUpPoint >> 16 ) & 0xFF); + tgh1 = (float)(( LevelUpPoint >> 8 ) & 0xFF); + dex1 = (float)(( LevelUpPoint >> 0 ) & 0xFF); + total1 = ( vital1 + str1 + tgh1 + dex1 ); + if( total1 > 150 ) total1 = 150; + if( total1 < 0 ) total1 = 0; + LevelUpPoint = CHAR_getInt( petNo, CHAR_ALLOCPOINT ); + petrank = CHAR_getInt( petNo, CHAR_PETRANK ); + petLV = CHAR_getInt( petNo, CHAR_LV); + vital2 = (float)(( LevelUpPoint >> 24 ) & 0xFF); + str2 = (float)(( LevelUpPoint >> 16 ) & 0xFF); + tgh2 = (float)(( LevelUpPoint >> 8 ) & 0xFF); + dex2 = (float)(( LevelUpPoint >> 0 ) & 0xFF); + total2 = ( vital2 + str2 + tgh2 + dex2 ); + +#ifdef _PET_2TRANS + ans = NPC_PetTransManGetAns( total1, total2, petLV, petrank, CHAR_getInt( petNo, CHAR_TRANSMIGRATION ) ); +#else + ans = NPC_PetTransManGetAns( total1, total2, petLV, petrank); +#endif + total = total1 + (total2*4); + + work[0] = ( ans * ( vital1 + (vital2*4) ) ) / total; + work[1] = ( ans * ( str1 + (str2*4) ) ) / total; + work[2] = ( ans * ( tgh1 + (tgh2*4) ) ) / total; + work[3] = ( ans * ( dex1 + (dex2*4) ) ) / total; +//取array========================= + enemynum = ENEMY_getEnemyNum(); + for(i=0;i= DelItem[j].minItemID ) && ( itemID <= DelItem[j].maxItemID ) ) { + LogItem( + CHAR_getChar( toindex, CHAR_NAME ), + CHAR_getChar( toindex, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), +#endif + "WarpManDelItem", + CHAR_getInt( toindex, CHAR_FLOOR), + CHAR_getInt( toindex, CHAR_X ), + CHAR_getInt( toindex, CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + CHAR_DelItem( toindex, i); + } + + }//for(j) + } + } + + NPC_NowEventSetFlg( toindex, 71 ); + + return TRUE; +} + + + +// shan add +void s_eventsetend( int charaindex, int shiftbit ) +{ +#ifdef _ADD_NEWEVENT // WON 多增任务旗标 + int event_num = 8; +#else + int event_num = 6; +#endif + int point; + int array; + int shift; + + array = shiftbit / 32; + shift = shiftbit % 32; + + if( array>=event_num ){ + //print("错误!!所设的任务旗标编号已超过 围(0~%d)。",32*event_num-1); + return; + } + point = CHAR_getInt( charaindex, CHAR_ENDEVENT+array); + point = point | (1< +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "configfile.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "npc_verywelfare.h" + +#ifdef _NPC_VERYWELFARE + +static void NPC_VeryWelfare_selectWindow(int meindex, int toindex, int num, int select); + +//载入非常好康NPC的初始化 +BOOL NPC_VeryWelfareInit( int meindex ) +{ + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEVERYWELFARE); + print("\n名称:%s\n",CHAR_getChar( meindex, CHAR_NAME)); + return TRUE; +} + +//对话时的处理 +void NPC_VeryWelfareTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + if( NPC_Util_isFaceToFace( talkerindex, meindex , 1 ) == FALSE ) + return; + //开始的选择画面 + NPC_VeryWelfare_selectWindow( meindex, talkerindex, 0, -1); +} + +static void NPC_VeryWelfare_selectWindow( int meindex, int toindex, int num,int select) +{ + int buttontype = 0,windowtype = 0,windowno = 0; + char buf[256]; + int fd = getfdFromCharaIndex( toindex); + char token[256]; + if( fd == -1 ) + return; + switch(num) + { + case 0: + sprintf(token,"%s","我是非常好康A的NPC,我将提供最好康A的服务。"); + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = NPC_VERYWELFARE_START; + lssproto_WN_send( fd, windowtype, WINDOW_BUTTONTYPE_OK, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX),token); + break; + case 1: + sprintf(token,"%s","2\n请选择以下的选项\n\n提升生命力\n提升魔法力"); + windowtype = WINDOW_MESSAGETYPE_SELECT; + windowno = NPC_VERYWELFARE_NO1; + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( token, buf, sizeof(buf))); + break; + case 2: + sprintf(token,"%s","我要提高生命力"); + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = NPC_VERYWELFARE_NO2; + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( token, buf, sizeof(buf))); + break; + case 3: + sprintf(token,"%s","我要提高魔法力"); + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + windowno = NPC_VERYWELFARE_NO3; + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( token, buf, sizeof(buf))); + break; + } + +} + +void NPC_VeryWelfareWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + + print("\n选:%d",select); + //int datanum = atoi( data); + switch( seqno){ + + case NPC_VERYWELFARE_START: + NPC_VeryWelfare_selectWindow(meindex, talkerindex, 1, 0); + break; + case NPC_VERYWELFARE_NO1: + NPC_VeryWelfare_selectWindow(meindex, talkerindex, 2, 1); + break; + case NPC_VERYWELFARE_NO2: + NPC_VeryWelfare_selectWindow(meindex, talkerindex, 3, 1); + break; + default: + break; + } +} + +#endif diff --git a/gmsv/npc/npc_warp.c b/gmsv/npc/npc_warp.c new file mode 100644 index 0000000..8827dbf --- /dev/null +++ b/gmsv/npc/npc_warp.c @@ -0,0 +1,380 @@ +#include "version.h" +#include +#include "object.h" +#include "char_base.h" +#include "char.h" +#include "map_deal.h" +#include "readmap.h" +#include "npccreate.h" +#include "npcutil.h" +#include "handletime.h" +#include "npc_eventaction.h" + +//#define _RECORD_NPCMAN_ //纪录 + +BOOL NPC_TimeWarpCheck(int meindex,char *buf,int mode); + +static void NPC_WarpsetNeverMake( int charaindex ) +{ + int cindex; + cindex = CHAR_getInt(charaindex,CHAR_NPCCREATEINDEX); + if( NPC_CHECKCREATEINDEX(cindex) ) + NPC_create[cindex].workdata[NPC_CREATEWORKNEVERMAKE] = 1; +} + +BOOL NPC_WarpInit( int charaindex ) +{ + char arg[NPC_UTIL_GETARGSTR_BUFSIZE]; + int ret; + int floor=-1,x=-1,y=-1; + char token[128]; + +#ifdef _RECORD_NPCMAN_ //纪录 + char evtype[256]; + char evtime[256]; + char argfile[256]; + + if( NPC_Util_CheckAssignArgFile( charaindex, argfile) == NULL ) + sprintf( argfile, "NULL"); +#endif + + CHAR_setInt( charaindex, CHAR_WHICHTYPE , CHAR_TYPEWARP ); + if( NPC_Util_GetArgStr( charaindex, arg, sizeof( arg)) == NULL ) { + print("\n GetArgStr ERR!!"); + return FALSE; + } +#ifdef _NEW_WARPPOINT + if( strstr( arg, "FREEMORE") != NULL ) { +#ifdef _RECORD_NPCMAN_ //纪录 + sprintf( evtype, "FREE"); + sprintf( evtime, "NULL"); +#endif + CHAR_setWorkInt( charaindex, CHAR_WORKEVENTTYPE, CHAR_EVENT_WARP); + }else { +#endif +#ifdef _MAP_WARPPOINT + return FALSE; +#endif +#ifdef _RECORD_NPCMAN_ //纪录 + sprintf( evtype, "NONE"); +#endif + ret=getStringFromIndexWithDelim(arg,"|", 1,token,sizeof(token)); + if( ret ) floor = atoi( token ); + ret=getStringFromIndexWithDelim(arg,"|", 2,token,sizeof(token)); + if( ret ) x = atoi( token ); + ret=getStringFromIndexWithDelim(arg,"|", 3,token,sizeof(token)); + if( ret ) y = atoi( token ); + if( MAP_IsValidCoordinate( floor,x,y )== FALSE ){ + NPC_WarpsetNeverMake( charaindex ); + //print( "Warp NPC:Invalid arg:%s\n", arg ); + print( "Warp Npc Err:%d:%d:%d->(%s)\n", + CHAR_getInt( charaindex, CHAR_FLOOR ), + CHAR_getInt( charaindex, CHAR_X ), + CHAR_getInt( charaindex, CHAR_Y ), + arg ); + return FALSE; + } + ret=getStringFromIndexWithDelim(arg,"|",4,token,sizeof(token)); + if(ret==TRUE){ + int day; + day=NPC_TimeWarpCheck(charaindex,token,0); + if(day==0){ +#ifdef _RECORD_NPCMAN_ //纪录 + sprintf( evtime, "N"); +#endif + CHAR_setWorkInt( charaindex, CHAR_WORKEVENTTYPE, CHAR_EVENT_WARP_NIGHT); + }else if(day==1){ +#ifdef _RECORD_NPCMAN_ //纪录 + sprintf( evtime, "M"); +#endif + CHAR_setWorkInt( charaindex, CHAR_WORKEVENTTYPE, CHAR_EVENT_WARP_MORNING); + }else if(day==2){ +#ifdef _RECORD_NPCMAN_ //纪录 + sprintf( evtime, "A"); +#endif + CHAR_setWorkInt( charaindex, CHAR_WORKEVENTTYPE, CHAR_EVENT_WARP_NOON); + }else{ +#ifdef _RECORD_NPCMAN_ //纪录 + sprintf( evtime, "NULL"); +#endif + CHAR_setWorkInt( charaindex, CHAR_WORKEVENTTYPE, CHAR_EVENT_WARP); + } + }else{ +#ifdef _RECORD_NPCMAN_ //纪录 + sprintf( evtime, "NULL"); +#endif + CHAR_setWorkInt( charaindex, CHAR_WORKEVENTTYPE, CHAR_EVENT_WARP); + } +#ifdef _NEW_WARPPOINT + } +#endif + CHAR_setFlg( charaindex,CHAR_ISVISIBLE, 0 ); + CHAR_setFlg( charaindex,CHAR_ISOVERED,1 ); + CHAR_setFlg( charaindex,CHAR_ISATTACKED,0 ); + CHAR_setFlg( charaindex,CHAR_ISATTACK,0 ); + +#ifdef _RECORD_NPCMAN_ //纪录 + { + FILE *fp=NULL; + char filename[256]; + sprintf( filename,"./data/npc/%s", "mapwarp.txt"); + if( (fp = fopen( filename, "a+")) != NULL ) { + fprintf( fp, "%s:%s:%d,%d,%d:%d,%d,%d:%s\n", + evtype, evtime, + CHAR_getInt( charaindex, CHAR_FLOOR), + CHAR_getInt( charaindex, CHAR_X), + CHAR_getInt( charaindex, CHAR_Y), + floor, x, y, argfile ); + fclose( fp); + }else { + } + } +#endif + return TRUE; +} + +void NPC_WarpWarpCharacter( int warpnpcindex, int charaindex ) +{ + char arg[NPC_UTIL_GETARGSTR_BUFSIZE]; + int i=0; +#ifdef _NEW_WARPPOINT + char buf1[256], buf2[256], buf3[256], freemsg[256]; + BOOL nBefind = FALSE; + struct wapepoints { + int m_floor; + int m_x; + int m_y; + }Wpoint[10]={ + {-1,0,0}, {-1,0,0}, {-1,0,0}, {-1,0,0}, {-1,0,0}, + {-1,0,0}, {-1,0,0}, {-1,0,0}, {-1,0,0}, {-1,0,0} + }; + int iRand=0; +#endif + if( CHAR_getInt( charaindex,CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ){ + return; + } + + if( NPC_Util_GetArgStr( warpnpcindex, arg, sizeof( arg)) == NULL ){ + return; + } + + { + char token[16]; + int floor=0,x=0,y=0; + int ret; + +#ifdef _NEW_WARPPOINT + i=1; + if( strstr( arg, "FREEMORE") != NULL ) { + int k=1, pw=-1; + while( getStringFromIndexWithDelim( arg, "OVER", i, buf1, sizeof( buf1)) != FALSE ) { + i++; + if( NPC_Util_GetStrFromStrWithDelim( buf1, "FREE", buf2, sizeof( buf2)) == NULL ) + continue; + if( NPC_ActionPassCheck( warpnpcindex, charaindex, buf2) == FALSE ) { + continue; + }else { + iRand=0; + if( NPC_Util_GetStrFromStrWithDelim( buf1, "TO", buf2, sizeof( buf2)) != FALSE ) { + k=1; + while( getStringFromIndexWithDelim( buf2, "&", k, freemsg, sizeof( freemsg)) != FALSE ){ + k++; + if( getStringFromIndexWithDelim( freemsg, ",", 1, buf3, sizeof( buf3)) == FALSE ) + break; + Wpoint[iRand].m_floor = atoi( buf3); + if( getStringFromIndexWithDelim( freemsg, ",", 2, buf3, sizeof( buf3)) == FALSE ) + break; + Wpoint[iRand].m_x = atoi( buf3); + if( getStringFromIndexWithDelim( freemsg, ",", 3, buf3, sizeof( buf3)) == FALSE ) + break; + Wpoint[iRand].m_y = atoi( buf3); + iRand++; + nBefind = TRUE; + if( iRand >= arraysizeof( Wpoint)) + break; + } + break; + } + } + if( nBefind == TRUE ) + break; + } + + if( nBefind == FALSE || iRand <= 0){ //没找到条件 + floor = CHAR_getInt( warpnpcindex, CHAR_FLOOR); + x = CHAR_getInt( warpnpcindex, CHAR_X); + y = CHAR_getInt( warpnpcindex, CHAR_Y); + }else { + pw = RAND( 0, (iRand-1)); + floor = Wpoint[pw].m_floor; + x = Wpoint[pw].m_x; + y = Wpoint[pw].m_y; + if( NPC_Util_GetStrFromStrWithDelim( arg, "CHECKPARTY", buf1, sizeof( buf1)) != NULL ) { + if( strstr( buf1, "TRUE") != NULL ){ + if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE ) == CHAR_PARTY_LEADER ) { + CHAR_DischargeParty( charaindex, 0); // 拆队 + } + } + } + if( MAP_IsValidCoordinate( floor,x,y )== FALSE ){ + print( "*Warp NPC:Invalid %d %d %d" , floor,x,y ); + return; + } + k=0; + } + }else { +#endif + ret=getStringFromIndexWithDelim(arg,"|", 1,token,sizeof(token)); + if( ret == FALSE )return; + floor = atoi( token ); + + ret=getStringFromIndexWithDelim(arg,"|", 2,token,sizeof(token)); + if( ret == FALSE )return; + x = atoi( token ); + + ret=getStringFromIndexWithDelim(arg,"|", 3,token,sizeof(token)); + if( ret == FALSE )return; + y = atoi( token ); +#ifdef _NEW_WARPPOINT + } +#endif + { + int ff=floor; + + int of=CHAR_getInt(charaindex, CHAR_FLOOR); + int fd=CHAR_getWorkInt( charaindex, CHAR_WORKFD); + int eqen=getEqNoenemy(fd); + if (eqen<200) { + if (eqen>=120) { + if ((ff==100)||(ff==200)||(ff==300)||(ff==400)||(ff==500)) { + if ((of!=100)&&(of!=200)&&(of!=300)&&(of!=400)&&(of!=500)) { + CHAR_talkToCli(charaindex, -1, + "太阳神的首饰发出一道奇异的光芒,隐藏了你的行踪。", CHAR_COLORWHITE); + } + } else { + if ((of==100)||(of==200)||(of==300)||(of==400)||(of==500)) { + CHAR_talkToCli(charaindex, -1, "环绕着你的光芒消失了。", CHAR_COLORWHITE); + } + } + } else if (eqen>=80) { + if ((ff==100)||(ff==200)||(ff==300)||(ff==400)) { + if ((of!=100)&&(of!=200)&&(of!=300)&&(of!=400)) { + CHAR_talkToCli(charaindex, -1, + "太阳神的首饰发出一道奇异的光芒,隐藏了你的行踪。", CHAR_COLORWHITE); + } + } else { + if ((of==100)||(of==200)||(of==300)||(of==400)) { + CHAR_talkToCli(charaindex, -1, "环绕着你的光芒消失了。", CHAR_COLORWHITE); + } + } + } else if (eqen>=40) { + if ((ff==100)||(ff==200)) { + if ((of!=100)&&(of!=200)) { + CHAR_talkToCli(charaindex, -1, + "太阳神的首饰发出一道奇异的光芒,隐藏了你的行踪。", CHAR_COLORWHITE); + } + } else { + if ((of==100)||(of==200)) { + CHAR_talkToCli(charaindex, -1, "环绕着你的光芒消失了。", CHAR_COLORWHITE); + } + } + } + } + } + +#ifdef _DROPSTAKENEW + { + i = 0; + for (i = 0; i < MAXSTAKENUM; i++){ + if (CHAR_getWorkInt(charaindex, CHAR_WORKSTAKETYPE1 + i) > 0){ + char tmpbuf[256]; + snprintf(tmpbuf, sizeof(tmpbuf), "由於你离开了房间,所以将无法取回彩券!"); + CHAR_setWorkInt(charaindex, CHAR_WORKSTAKETYPE1 + i, 0); + CHAR_talkToCli(charaindex, -1, tmpbuf, CHAR_COLORYELLOW); + } + } + CHAR_setWorkInt(charaindex, CHAR_WORKSTAKEFLAG, 0); +#ifdef _FIX_GAMBLENUM + if(CHAR_getInt(charaindex, CHAR_GAMBLENUM) < 0) + CHAR_setInt(charaindex, CHAR_GAMBLENUM, 0); +#endif + } +#endif + if( floor == -1) { + return; + }else { + if( MAP_IsValidCoordinate( floor,x,y )== FALSE ){ + print( "Warp NPC:Invalid %d %d %d" , floor,x,y ); + return; + } + + CHAR_warpToSpecificPoint(charaindex, floor, x, y); + } + } +} + +void NPC_WarpWatch( int meobjindex, int objindex, CHAR_ACTION act, + int x,int y,int dir, int* opt,int optlen ) +{ + int meindex,moveindex; + if( OBJECT_getType( objindex ) != OBJTYPE_CHARA )return; + + meindex = OBJECT_getIndex(meobjindex); + moveindex = OBJECT_getIndex(objindex); + + if( CHAR_getInt( moveindex,CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ){ + return; + } + if( act != CHAR_ACTWALK )return; + + if( opt[0] == x && opt[1] == y )return; + if( CHAR_getInt(meindex,CHAR_X) == x && CHAR_getInt(meindex,CHAR_Y) == y ) { + NPC_WarpWarpCharacter( meindex, moveindex ); + } +} + +void NPC_WarpPostOver( int meindex, int charaindex ) +{ + NPC_WarpWarpCharacter( meindex, charaindex ); +} + +int NPC_WarpSearchByPosition( int fl , int x, int y) +{ + OBJECT object; + for( object=MAP_getTopObj(fl,x,y) ; object ; + object=NEXT_OBJECT(object)){ + int objindex = GET_OBJINDEX(object); + if( OBJECT_getType( objindex ) == OBJTYPE_CHARA + && CHAR_getInt( OBJECT_getIndex(objindex), CHAR_WHICHTYPE) + == CHAR_TYPEWARP ){ + return OBJECT_getIndex(objindex); + } + } + return -1; +} + + +int NPC_TimeWarpCheck(int meindex,char *buf,int mode) +{ + LSTIME nowlstime; + char *time[4]={"N","M","A"}; + int now; + int i=0; + RealTimeToLSTime( NowTime.tv_sec, &nowlstime); + now = getLSTime( &nowlstime); + if(mode==0){ + for( i=0 ; i < 3 ; i++){ + if(strstr( buf,time[i]) != NULL){ + return i; + } + } + return -1;; + } + if(mode==1){ + if(now==CHAR_getWorkInt( meindex, CHAR_WORKEVENTTYPE)){ + return now; + } + return -1; + } + return -1; +} diff --git a/gmsv/npc/npc_warpman.c b/gmsv/npc/npc_warpman.c new file mode 100644 index 0000000..174192c --- /dev/null +++ b/gmsv/npc/npc_warpman.c @@ -0,0 +1,1134 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "saacproto_cli.h" +#include "npc_warpman.h" +#include "map_deal.h" +#include "readmap.h" +#include "battle.h" +#include "npc_exchangeman.h" +#include "log.h" +#include "enemy.h" +#include "handletime.h" +#include "npc_eventaction.h" + +static void NPC_WarpMan_selectWindow( int meindex, int toindex, int num,int select); +//ANDY_END +BOOL NPC_GetDuelPointCheck(int meindex,int talker); +BOOL NPC_PARTY_CHAECK( int meindex, int talkerindex); +void NPC_ERR_DiSP(int meindex,int talker,int errNO); + +BOOL NPC_BigSmallLastCheck(int point1,int mypoint,int flg); + +//BOOL NPC_ItemCheck(int meindex,int talker,int itemNo,int flg); +int NPC_FloorUse(int talker,int floor); +BOOL NPC_WarpMsg(int meindex,int talker,char *buf); +BOOL NPC_NpcWarpMsg(int meindex,int talker,char *arg); +int NPC_FloorUseOtherFloor(int charaindex, char *buf); + + +#ifdef _NPC_ADDLEVELUP +void NPC_LevelAndTransUp( int meindex, int charindex, int level, int skillpoint, int exp, int ridepet); +#endif + +#define WARPMAN_STANDBY 3000 +#define WARPMAN_WAIT 150 +//ANDY_ADD +int CheckWarpMsg( int meindex, int talkerindex,char *npcarg ,char *TalkStr); + +#ifdef _TREASURE_BOX +BOOL NPC_TreasureEventRunMsg( int meindex); +#endif + +BOOL NPC_TreasureRandItemGet(int meidex,int talker,int rand_j,char *buf); + +enum { + NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT1, + NPC_TIME_BORN = CHAR_NPCWORKINT2, + NPC_TIME_DEAD = CHAR_NPCWORKINT3, + NPC_TIME_MODE = CHAR_NPCWORKINT4, + + NPC_TIME_EVENTMODE = CHAR_NPCWORKINT6,// 1 + NPC_TIME_EVENTTIME = CHAR_NPCWORKINT7, + NPC_TIME_EVENONBBI = CHAR_NPCWORKINT8, + NPC_TIME_EVENOFFDBBI = CHAR_NPCWORKINT9, + NPC_TIME_EVENTNUM = CHAR_NPCWORKINT10, +}; + +enum{ + NPC_EVENTMODE_NONE, + NPC_EVENTMODE_OPEN, + NPC_EVENTMODE_EVENT, +}; + +#ifdef _NEW_WARPMAN +static void NPC_NewWarpMan_selectWindow( int meindex, int toindex, int num,int select,char *TalkStr); + +enum { + WARP_MAN=0, + NEW_WARPMAN, + NEW_WARPMAN_END + }; +#endif +#define TIMECHECKLOOP 20 +// Robin 0518 +//BOOL checkend = FALSE; + + +BOOL NPC_WarpManInit( int meindex ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buff2[256]; + char buf[1024]; + int fl,x,y; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("WarpMan:GetArgStrErr"); + return FALSE; + } + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEWARPMAN ); +#ifdef _NEW_WARPMAN + if( strstr( npcarg,"NEWWARPMAN") ) { + //timeman 功能 + CHAR_setWorkInt( meindex, NPC_TIME_MODE, 1); + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "NEWTIME", buff2, sizeof( buff2)) != NULL ){ + CHAR_setInt( meindex, CHAR_LOOPINTERVAL, 60*1000); + } +#ifdef _TREASURE_BOX + CHAR_setWorkInt( meindex, NPC_TIME_EVENTMODE, NPC_EVENTMODE_NONE); + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "TREASURE_BOX", buff2, sizeof( buff2)) != NULL ){ + if( strstr( buff2, "ON") != NULL ){ + CHAR_setWorkInt( meindex, NPC_TIME_EVENTMODE, NPC_EVENTMODE_EVENT); + CHAR_setWorkInt( meindex, NPC_TIME_EVENTTIME, NowTime.tv_sec); + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "TREASURE_ONBBI", buff2, sizeof( buff2)) != NULL ) + CHAR_setWorkInt( meindex, NPC_TIME_EVENONBBI, atoi( buff2)); + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "TREASURE_OFFDBBI", buff2, sizeof( buff2)) != NULL ) + CHAR_setWorkInt( meindex, NPC_TIME_EVENOFFDBBI, atoi( buff2)); + CHAR_setWorkInt( meindex, NPC_TIME_EVENTNUM, 0 ); + } + } + +#endif + return TRUE; + }else{ +#endif + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "WARP", buf, sizeof( buf))==NULL){ + char filename[256]; + if( NPC_Util_CheckAssignArgFile( meindex, filename) != NULL ) + print("\n Warpman Err -> file:%s", filename); + return FALSE; + } + getStringFromIndexWithDelim(buf,",",1,buff2,sizeof(buff2)); + fl=atoi(buff2); + getStringFromIndexWithDelim(buf,",",2,buff2,sizeof(buff2)); + x=atoi(buff2); + getStringFromIndexWithDelim(buf,",",3,buff2,sizeof(buff2)); + y=atoi(buff2); + if( MAP_IsValidCoordinate( fl,x,y )== FALSE ){ + char filename[256]; + NPC_Util_CheckAssignArgFile( meindex, filename); + print( "\nWarp NPC: filename:%s\n 3.Invalid warpman ERR %d %d %d" , filename, fl , x , y ); + return FALSE; + } +#ifdef _NEW_WARPMAN + } +#endif + return TRUE; +} + +void NPC_WarpManTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[256]; + int RunType=-1; + + CHAR_setWorkInt( talkerindex, CHAR_WORKWARPCHECK, FALSE ); + 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; + } + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr"); + return ; + } + +#ifdef _NEW_WARPMAN + if( strstr( npcarg,"NEWWARPMAN") ) { +#ifdef _TREASURE_BOX + if( CHAR_getWorkInt( meindex, NPC_TIME_EVENTMODE) == NPC_EVENTMODE_OPEN ) + return; +#endif + NPC_NewWarpMan_selectWindow( meindex ,talkerindex, 0, -1, szMes); + return; + }else { + if(NPC_PARTY_CHAECK( meindex, talkerindex) == FALSE) {//有组队 + NPC_ERR_DiSP( meindex, talkerindex, 1); + return; + } + + + RunType = CheckWarpMsg( meindex, talkerindex, npcarg , szMes); + if( RunType !=0 ) { + if( RunType == 1 ) { + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "nomal_msg", token, sizeof(token)) != NULL) { + CHAR_talkToCli( talkerindex, meindex,token,CHAR_COLORWHITE); + } + } + return; + } + } +#else + + + if(NPC_PARTY_CHAECK( meindex, talkerindex) == FALSE) {//有组队 + NPC_ERR_DiSP( meindex, talkerindex, 1); + return; + } + RunType = CheckWarpMsg( meindex, talkerindex, npcarg , szMes); + if( RunType !=0 ) { + if( RunType == 1 ) { + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "nomal_msg", token, sizeof(token)) != NULL) { + CHAR_talkToCli( talkerindex, meindex,token,CHAR_COLORWHITE); + } + } + return; + } +#endif + + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + CHAR_setWorkInt( talkerindex , CHAR_WORKSHOPRELEVANTTRD , 0 ); + if(strstr(npcarg,"DR")!=NULL) { + CHAR_setWorkInt( talkerindex , CHAR_WORKSHOPRELEVANTSEC , -1 ); + if(NPC_GetDuelPointCheck(meindex,talkerindex)==FALSE) return; + }else{ + NPC_WarpMan_selectWindow( meindex, talkerindex,0,-1); + } +} + +static void NPC_WarpMan_selectWindow( int meindex, int toindex, int num,int select) +{ + + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[1024]; + char buf[256]; + char buf2[1024]; + char buf3[256]; + int fl=0 ; + int money=100 ; + int fd = getfdFromCharaIndex( toindex); + char tmp[64]; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr"); + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 0); + return ; + } + + if(NPC_PARTY_CHAECK( meindex, toindex) == FALSE) { + NPC_ERR_DiSP( meindex, toindex, 1); + return; + } + + + if( CHAR_getWorkInt( toindex, CHAR_WORKSHOPRELEVANT) != 0 ) { + return; + }else { + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 1); + } + + if(strstr(npcarg,"%4d")!=NULL){ + int flwork = 0; + int work; + NPC_Util_GetStrFromStrWithDelim( npcarg, "WARP", buf, sizeof( buf)); + getStringFromIndexWithDelim(buf,",",1,buf3,sizeof(buf3)); + work = atoi( buf3); + fl = NPC_FloorUse( toindex, atoi(buf3)); + + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "Floor", buf3, sizeof( buf3)) != NULL){ + flwork = NPC_FloorUseOtherFloor(work, buf3); + } + fl = fl +flwork; + } + + NPC_Util_GetStrFromStrWithDelim( npcarg, "FREE", buf, sizeof( buf)); + + if( (NPC_ActionPassCheck(meindex,toindex,buf)==TRUE) || (strstr(buf,"ALLFREE")!=NULL) ){ + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "FreeMsg", buf2, sizeof( buf2))==NULL) return; + CONNECT_set_pass(fd,TRUE); + CONNECT_set_first_warp(fd,TRUE); + if(strstr(buf2,"%4d") != NULL){ + sprintf(token,buf2,fl); + }else{ + strcpy(token,buf2); + } + CHAR_setWorkInt( toindex , CHAR_WORKSHOPRELEVANTTRD , -1 ); + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 2); + }else { + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "PayMsg", buf2, sizeof( buf2)) != NULL){ + CONNECT_set_pass(fd,FALSE); + CONNECT_set_first_warp(fd,FALSE); + if(strstr(buf2,"%8d") != NULL){ + NPC_Util_GetStrFromStrWithDelim( npcarg, "MONEY", tmp, sizeof( tmp)); + if(strstr(tmp,"LV")!=NULL){ + int level; + char buff2[32]; + + level = CHAR_getInt(toindex,CHAR_LV); + getStringFromIndexWithDelim(tmp,"*",2,buff2,sizeof(buff2)); + money = level*atoi(buff2); + }else{ + money=atoi(tmp); + } + if(strstr(buf2,"%4d") != NULL){ + sprintf(token,buf2,fl,money); + }else{ + sprintf(token,buf2,money); + } + }else if(strstr(buf2,"%4d") != NULL){ + sprintf(token,buf2,fl); + NPC_Util_GetStrFromStrWithDelim( npcarg, "MONEY", tmp, sizeof( tmp)); + if( strstr( tmp,"-" ) != NULL){ + money=10000001; + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_WINDOWWARPMAN_MAIN, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return ; + } + }else{ + strcpy(token,buf2); + NPC_Util_GetStrFromStrWithDelim( npcarg, "MONEY", tmp, sizeof( tmp)); + if( strstr( tmp,"-" ) != NULL){ + money=10000001; + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_WINDOWWARPMAN_MAIN, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + return ; + }else{ + money = atoi(tmp); + } + } + if(CHAR_getInt(toindex,CHAR_FLOOR)==117){ + money=CHAR_getInt(toindex,CHAR_GOLD); + if (money>=10) money*=0.9; + else if( money == 0 ) { + CHAR_warpToSpecificPoint(toindex,117,225,13); + return; + } + } + CHAR_setWorkInt( toindex , CHAR_WORKSHOPRELEVANTTRD , money ); + CONNECT_set_pass(fd,TRUE); + CONNECT_set_first_warp(fd,TRUE); + + }else if(NPC_Util_GetStrFromStrWithDelim( npcarg, "NomalMsg", token,sizeof(token)) !=NULL){ + CHAR_setWorkInt( toindex , CHAR_WORKSHOPRELEVANTTRD , -2 ); + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, -1); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_WINDOWWARPMAN_MAIN, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + } + } + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_YESNO, + CHAR_WINDOWTYPE_WINDOWWARPMAN_MAIN, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); +} + +void NPC_WarpManWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[NPC_UTIL_GETARGSTR_BUFSIZE]; +#ifdef _NEW_WARPMAN + BOOL checkp=TRUE; + char buf1[1024]; + int talkNo = 1; + BOOL tenflg=FALSE; +#else + int fl,x,y; +#endif + char buff2[256]; + int fd = getfdFromCharaIndex( talkerindex ); + if( NPC_Util_CharDistance( talkerindex, meindex ) > 2) + return; + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr"); + return ; + } + if( CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT) < 1 ) { + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, -1); + return; + } + +#ifdef _NEW_WARPMAN + if( seqno == NEW_WARPMAN ) { + int eqnum=0; + eqnum = CHAR_getWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT); + sprintf(buf1,"%s", "NOFREE"); + if( eqnum >= 0 ) { + sprintf(buf1,"TALKEVENT%d", eqnum); + } + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0); + while( getStringFromIndexWithDelim( npcarg,"OVER",talkNo,buf,sizeof( buf)) != FALSE){ + if( strstr(buf, buf1) != NULL) { + strcpy( npcarg , buf); + tenflg = TRUE; + break; + } + talkNo++; + } + if( tenflg == FALSE ) { + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, -1); + return; + } + }else { +#endif + if( select != WINDOW_BUTTONTYPE_YES ) { + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, -1); + return; + } + if(NPC_PARTY_CHAECK( meindex, talkerindex) == FALSE){ + NPC_ERR_DiSP( meindex, talkerindex, 1); + return; + } +#ifdef _NEW_WARPMAN + } +#else + NPC_Util_GetStrFromStrWithDelim( npcarg, "WARP", buf, sizeof( buf)); + GetRand_WarpPoint( buf, &fl, &x, &y ); +#endif + +#ifdef _NEW_WARPMAN + switch( seqno) { + case WARP_MAN: + if( select != WINDOW_BUTTONTYPE_YES ) + return; + if( NPC_PARTY_CHAECK( meindex, talkerindex) == FALSE ){ + NPC_ERR_DiSP( meindex, talkerindex, 1); + return; + } +#else + if( select != WINDOW_BUTTONTYPE_YES) return; + if( NPC_PARTY_CHAECK( meindex, talkerindex) == FALSE) + return; +#endif + +#ifdef _NEW_WARPMAN + break; + case NEW_WARPMAN: + if( select != WINDOW_BUTTONTYPE_YES ){ + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, -1); + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "CancelMsg", buff2, sizeof( buff2) ) != NULL) { + CHAR_talkToCli( talkerindex, meindex, buff2, CHAR_COLORYELLOW); + } + return; + } + checkp=TRUE; + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "CHECKPARTY", buff2, sizeof( buff2) ) != NULL) { + if( strstr( buff2, "FALSE") != NULL ) { + checkp = FALSE; + } + } + if( checkp==TRUE && NPC_PARTY_CHAECK( meindex, talkerindex) == FALSE ) { + NPC_ERR_DiSP( meindex, talkerindex, 1); + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, -1); + return; + } + break; + case NEW_WARPMAN_END: + return; + break; + } +#endif + + if( Action_RunDoEventAction( meindex, talkerindex, npcarg) == FALSE ){ + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, -1); + return; + } + + CHAR_complianceParameter( talkerindex ); + CHAR_send_P_StatusString( talkerindex , + CHAR_P_STRING_ATK|CHAR_P_STRING_DEF| + CHAR_P_STRING_CHARM|CHAR_P_STRING_QUICK| + CHAR_P_STRING_WATER|CHAR_P_STRING_FIRE| + CHAR_P_STRING_WIND|CHAR_P_STRING_EARTH + ); + if( CHAR_getWorkInt( CONNECT_getCharaindex(fd), CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE){ + return ; + } + if(CHAR_getWorkInt( talkerindex , CHAR_WORKSHOPRELEVANTTRD) <= 0){ + CHAR_setWorkInt( talkerindex, CHAR_WORKWARPCHECK, FALSE ); +#ifdef _NEW_WARPMAN + NPC_WarpMsg( meindex, talkerindex, npcarg); +#else + if( fl == 0 && x == 0 && y == 0 ) { + }else { + CHAR_warpToSpecificPoint(talkerindex, fl, x,y); + } +#endif + }else { + if(CHAR_getInt(talkerindex,CHAR_GOLD) < + CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD)){ + NPC_ERR_DiSP( meindex, talkerindex, 2); + return ; + } + CHAR_DelGold( talkerindex, CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTTRD )); + + CHAR_setWorkInt( talkerindex, CHAR_WORKWARPCHECK, FALSE ); +#ifdef _NEW_WARPMAN + NPC_WarpMsg( meindex, talkerindex, npcarg); +#else + if( fl == 0 && x == 0 && y == 0 ) { + }else { + CHAR_warpToSpecificPoint(talkerindex, fl, x,y); + } +#endif + + } +#ifdef _NEW_WARPMAN + NPC_NpcWarpMsg( meindex, talkerindex, npcarg); +#else + } +#endif +} + +BOOL NPC_BigSmallLastCheck(int point1,int mypoint,int flg) +{ + + if(flg==0){ + if(point1==mypoint) { + return TRUE; + } + + }else if(flg==1){ + if(mypoint < point1) { + return TRUE; + } + + }else if(flg==2){ + if(mypoint > point1) { + return TRUE; + } + } + + return FALSE; + +} + +BOOL NPC_GetDuelPointCheck(int meindex,int talker) +{ + + int fdid = getFdidFromCharaIndex( talker); + char dbkey[256]; + + if( fdid == -1 ) return FALSE; + + CHAR_makeDBKey( talker, dbkey, sizeof( dbkey)); + saacproto_DBGetEntryRank_send( acfd, DB_DUELPOINT, dbkey, fdid, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX)); + + return TRUE; + +} + +void NPC_GetDuelRank(int rank,int fdid,int objindex) +{ + + int talker; + int meindex; + + + rank++; + talker = getCharindexFromFdid( fdid); + if( talker == -1 ) return; + + meindex= OBJECT_getIndex( objindex); + if( !CHAR_CHECKINDEX( meindex)) return; + + CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC,rank); + + NPC_WarpMan_selectWindow( meindex, talker,0,-1); + +} + +BOOL NPC_PARTY_CHAECK(int meindex,int talker) +{ + if(CHAR_getWorkInt(talker,CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE){ + return FALSE; + } + return TRUE; +} + +void NPC_ERR_DiSP(int meindex,int talker,int errNO) +{ + char token[1024]; + int i=0; + int otherindex; + int fd = getfdFromCharaIndex( talker); + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr"); + return ; + } + if(errNO==1){ + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "PartyMsg",token, sizeof( token))==NULL) { + sprintf(token,"\n\n    无法加入团队。  " + "\n\n    请解散团队 。 "); + } + if(CHAR_getWorkInt(talker,CHAR_WORKPARTYMODE)==CHAR_PARTY_CLIENT){ + }else{ + + for( i=0 ; i < CHAR_PARTYMAX ;i++){ + otherindex=CHAR_getWorkInt(talker,CHAR_WORKPARTYINDEX1+i); + if(otherindex != -1){ + fd = getfdFromCharaIndex( otherindex); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_WINDOWWARPMAN_ERR, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + } + } + return ; + } + }else if (errNO==2){ + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "MoneyMsg", token, sizeof( token))==NULL){ + sprintf(token,"\n\n    似乎金钱不足唷。  " + "\n\n 请存好钱後,再过来。"); + } + } + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE, + WINDOW_BUTTONTYPE_OK, + CHAR_WINDOWTYPE_WINDOWWARPMAN_ERR, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); +} + +int NPC_FloorUse(int charaindex,int floor) +{ + int i; + int players=0; + int playernum = CHAR_getPlayerMaxNum(); + for( i=0 ; i< playernum ; i++ ){ + if( CHAR_getCharUse(i) == FALSE )continue; + if(CHAR_getInt(i,CHAR_FLOOR)==floor){ + players++; + } + } + return players; +} + +int NPC_FloorUseOtherFloor(int warp, char *buf) +{ + int i,j=1; + int players=0; + int playernum = CHAR_getPlayerMaxNum(); + char buf2[32]; + int floor; + + for( i=0 ; i< playernum ; i++ ){ + if( CHAR_getCharUse(i) == FALSE )continue; + j=1; + while(getStringFromIndexWithDelim(buf,",",j,buf2,sizeof(buf2))!= FALSE){ + j++; + floor = atoi(buf2); + if(CHAR_getInt(i,CHAR_FLOOR) == floor && warp != floor) { + players++; + } + } + } + return players; +} + +BOOL NPC_WarpMsg(int meindex,int talker,char *arg) +{ + char buf[256]; + int fl=0,x=0,y=0; + int parent=-1; + int pmode; + int subindex; + int i; + + if( NPC_Util_GetStrFromStrWithDelim( arg, "WARP", buf, sizeof( buf)) == NULL ) + return FALSE; + GetRand_WarpPoint( buf, &fl, &x, &y ); + if( fl == 0 && x == 0 && y == 0 ) { + return TRUE; + }else { + if( MAP_IsValidCoordinate( fl,x,y )== FALSE ){ + print( "Warp NPC:1.Invalid warpman ERR" ); + return FALSE; + } + } +#ifdef _TIME_TICKET + if( check_TimeTicketMap( fl) ) { + int havei, itemi; + CHAR_setWorkInt( talker, CHAR_WORKTICKETTIME, 0); + CHAR_setWorkInt( talker, CHAR_WORKTICKETTIMESTART, 0); + for( havei = CHAR_STARTITEMARRAY ; havei < CHAR_MAXITEMHAVE ; havei++ ){ + itemi = CHAR_getItemIndex( talker, havei); + if( !ITEM_CHECKINDEX( itemi) ) continue; + if( strcmp( ITEM_getChar( itemi, ITEM_USEFUNC), "ITEM_timeticket") ) continue; + //if( ITEM_getInt( itemi ,ITEM_ID) != 20646 ) continue; + CHAR_talkToCli( talker, -1, "自动使用门票。", CHAR_COLORYELLOW); + ITEM_timeticketEx( talker, talker, havei, 1); + break; + } + if( havei == CHAR_MAXITEMHAVE ) { + CHAR_talkToCli( talker, -1, "请先准备专用门票才可进入。", CHAR_COLORYELLOW); + return FALSE; + } + } +#endif + pmode = CHAR_getWorkInt( talker, CHAR_WORKPARTYMODE ); + switch( pmode ){ + case 1: + parent = talker; + break; + case 2: + parent = CHAR_getWorkInt( talker, CHAR_WORKPARTYINDEX1 ); + break; + default: + CHAR_warpToSpecificPoint(talker, fl, x,y); + return TRUE; + } + if( parent < 0 ) + return TRUE; + for( i = 0; i < CHAR_PARTYMAX; i ++ ){ + subindex = CHAR_getWorkInt( parent, CHAR_WORKPARTYINDEX1+i ); + if( CHAR_CHECKINDEX( subindex ) == FALSE )continue; + if( fl==0 && x==0 && y==0 ) { + }else { + CHAR_warpToSpecificPoint( subindex, fl, x, y ); + } + } + return TRUE; +} + +#ifdef _NEW_WARPMAN +static void NPC_NewWarpMan_selectWindow( int meindex, int toindex, int num,int select,char *TalkStr) +{ + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + char token[1024]; + int buttontype = 0, windowtype = 0, windowno = 0; + char buf[NPC_UTIL_GETARGSTR_BUFSIZE],buf1[256]; + int fd = getfdFromCharaIndex( toindex); + BOOL tenflg =FALSE; + int talkNo=1,RunType=-1; + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("GetArgStrErr"); + return ; + } + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "NEWTIME", buf1, sizeof( buf1)) != NULL ){ + if( CHAR_getWorkInt( meindex, NPC_TIME_MODE) <= 0 ) { + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "Time_Msg", token, sizeof( token) ) != NULL) { + CHAR_talkToCli( toindex, meindex, token, CHAR_COLORYELLOW); + } + return; + } + } + + windowtype = WINDOW_MESSAGETYPE_MESSAGE; + sprintf( buf1,"TALKEVENT"); + //寻找多种条件 FREE + while(getStringFromIndexWithDelim( npcarg,"OVER",talkNo,buf,sizeof( buf)) != FALSE) { + if(strstr(buf, buf1) != NULL) { + //检查对话 暗语 + RunType = CheckWarpMsg( meindex, toindex, buf , TalkStr); + if( RunType > 1 ) { + return; + }else if( RunType != 0 ) { + talkNo++; + continue; + } + if( NPC_Util_GetStrFromStrWithDelim( buf, "FREE", token, sizeof( token) ) == NULL) { + print("msgErr"); + return; + } + + //检查玩家是否附合条件 + if((NPC_ActionPassCheck(meindex,toindex,token)==TRUE) || (strstr( token, "ALLFREE")!=NULL) ) { + CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, talkNo-1); + + //若附合条件 取出 FreeMsg 字串 + if(NPC_Util_GetStrFromStrWithDelim( buf, "FreeMsg", token, sizeof( token))==NULL) + return; + CONNECT_set_pass(fd,TRUE); + CONNECT_set_first_warp(fd,TRUE); + buttontype = WINDOW_BUTTONTYPE_YESNO; + windowno = NEW_WARPMAN; + tenflg = TRUE; + CHAR_setWorkInt( toindex , CHAR_WORKSHOPRELEVANTTRD , -1 ); + break; + } + } + talkNo++; + } + + //无任何条件成立 + if( tenflg == FALSE ) { + if( getStringFromIndexWithDelim( npcarg,"OVER",1,buf,sizeof( buf)) == FALSE ) + return; + if( strstr( buf, "NOFREE") == NULL ) { + return; + }else { + strcpy( npcarg, buf); + } + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "NomalMsg", token,sizeof(token)) != NULL) { + CHAR_talkToCli( toindex, meindex, token,CHAR_COLORWHITE); + return; + } + } + + //送讯息给 CLI + lssproto_WN_send( fd, windowtype, buttontype, windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token ); +} + +#endif +//ANDY_RE +int CheckWarpMsg( int meindex, int talkerindex,char *npcarg ,char *TalkStr) +{ + char buf[1024]; + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "warp_msg", buf, sizeof( buf) ) == NULL) + return 0; + if( strcmp( buf, TalkStr) ) + return 1; + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "CHECKPARTY", buf, sizeof( buf) ) != NULL) { + if( strstr( buf, "FALSE") != NULL ) { + }else { + if( NPC_PARTY_CHAECK( meindex, talkerindex) == FALSE ) { + NPC_ERR_DiSP( meindex, talkerindex, 1); + return 2; + } + } + } + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "FREE", buf, sizeof( buf)) == NULL ) + return 2; + if( ( NPC_ActionPassCheck( meindex, talkerindex, buf ) == FALSE) ) { + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "NomalMsg", buf,sizeof(buf)) != NULL) { + CHAR_talkToCli( talkerindex, meindex,buf,CHAR_COLORWHITE); + } + return 2; + }else { + if( Action_RunDoEventAction( meindex, talkerindex, npcarg) == FALSE ){ + + CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, -1); + return 3; + } + CHAR_complianceParameter( talkerindex ); + CHAR_send_P_StatusString( talkerindex , + CHAR_P_STRING_ATK|CHAR_P_STRING_DEF| + CHAR_P_STRING_CHARM|CHAR_P_STRING_QUICK| + CHAR_P_STRING_WATER|CHAR_P_STRING_FIRE| + CHAR_P_STRING_WIND|CHAR_P_STRING_EARTH ); + + if(NPC_Util_GetStrFromStrWithDelim( npcarg, "FreeMsg", buf, sizeof( buf)) != NULL ){ + CHAR_talkToCli( talkerindex, meindex, buf, CHAR_COLORWHITE); + } + + NPC_WarpMsg( meindex, talkerindex, npcarg); + NPC_NpcWarpMsg( meindex, talkerindex, npcarg); + return 4; + } + return 0; +} + +BOOL NPC_NpcWarpMsg(int meindex,int talker,char *arg) +{ + char buf[256]; + int fl=0,x=0,y=0; + + if( CHAR_CHECKINDEX( meindex ) == FALSE ) + return FALSE; + + if( NPC_Util_GetStrFromStrWithDelim( arg, "NPCPOINT", buf, sizeof( buf)) == NULL ) + return FALSE; + GetRand_WarpPoint( buf, &fl, &x, &y ); + + if( MAP_IsValidCoordinate( fl,x,y )== FALSE ){ + print( "Warp NPC:2.Invalid warpman ERR" ); + return FALSE; + } + + CHAR_warpToSpecificPoint( meindex, fl, x, y ); + + return TRUE; +} + +void NPC_WarpManLoop( int meindex) +{ + int born, dead; + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + if( !CHAR_CHECKINDEX( meindex) ) return; + + if( NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg)) == NULL ){ + print("WarpMan:GetArgStrErr"); + return; + } + if( !strstr( npcarg,"NEWWARPMAN") ) + return; + + if( NPC_getTimeData( meindex, npcarg, &born, &dead, 200) != FALSE ){ + NPC_TimeDefineDo( meindex, born, dead, NPC_TIME_MODE); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX ) ); + } +} + +void NPC_WarpManWatch( int meobjindex, int objindex, CHAR_ACTION act, + int x,int y,int dir, int* opt,int optlen ) +{ + int born, dead; + int meindex, index; + + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + if( OBJECT_getType( objindex) != OBJTYPE_CHARA) return; + index = OBJECT_getIndex( objindex); + if( !CHAR_CHECKINDEX( index) ) return; + if( CHAR_getInt( index, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER) return; + meindex = OBJECT_getIndex( meobjindex); + if( !CHAR_CHECKINDEX( meindex) ) return; + + if( NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg)) == NULL ){ + print("WarpMan:GetArgStrErr"); + return; + } + if( !strstr( npcarg,"NEWWARPMAN") ) + return; +#ifdef _TREASURE_BOX + if( CHAR_getWorkInt( meindex, NPC_TIME_EVENTMODE) == NPC_EVENTMODE_OPEN ){ + if( CHAR_getWorkInt( meindex, NPC_TIME_EVENTTIME) < NowTime.tv_sec ){ + //变回宝箱 + CHAR_setWorkInt( meindex, NPC_TIME_EVENTMODE, NPC_EVENTMODE_EVENT); + //变图 + CHAR_setInt( meindex, CHAR_BASEBASEIMAGENUMBER, + CHAR_getWorkInt( meindex, NPC_TIME_EVENOFFDBBI)); + CHAR_setInt( meindex, CHAR_BASEIMAGENUMBER, + CHAR_getWorkInt( meindex, NPC_TIME_EVENOFFDBBI)); + NPC_TreasureEventRunMsg( meindex); //是否warp + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX ) ); + } + } +#endif + if( NPC_getTimeData( meindex, npcarg, &born, &dead, 200) != FALSE ){ + NPC_TimeDefineDo( meindex, born, dead, NPC_TIME_MODE); + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX ) ); + } +} + +#ifdef _TREASURE_BOX +BOOL NPC_TreasureEventRunMsg( int meindex) +{ + char buf[256]; + char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE]; + + int fl,x,y; + + if( !CHAR_CHECKINDEX( meindex )) + return FALSE; + + + if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){ + print("WarpMan:GetArgStrErr"); + return FALSE; + } + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "TREASURE_NUM", buf, sizeof( buf)) == NULL ) + return FALSE; + + if( CHAR_getWorkInt( meindex, NPC_TIME_EVENTNUM) < atoi( buf) ) return FALSE; + CHAR_setWorkInt( meindex, NPC_TIME_EVENTNUM, 0); + + if( NPC_Util_GetStrFromStrWithDelim( npcarg, "TREASURE_POINT", buf, sizeof( buf)) == NULL ) + return FALSE; + GetRand_WarpPoint( buf, &fl, &x, &y ); + + if( MAP_IsValidCoordinate( fl,x,y )== FALSE ){ + print( "Warp NPC:2.Invalid warpman ERR" ); + return FALSE; + } + + CHAR_warpToSpecificPoint( meindex, fl, x, y ); + return TRUE; +} + +#endif + +BOOL NPC_TreasureRandItemGet(int meidex,int talker,int rand_j,char *buf) +{ + char buff2[64]; + int randitem; + int ret; + int itemindex; + char token[128]; + + if(rand_j == 0) { + print("Event:由於0的介入,出现错误。"); + return FALSE; + } + + randitem = rand()%rand_j; + if(randitem == 0) randitem = rand_j; + + getStringFromIndexWithDelim(buf , "," , randitem, buff2, sizeof(buff2)) ; + + itemindex = ITEM_makeItemAndRegist( atoi( buff2)); + + if(itemindex == -1) return FALSE; + + /*失奶 丞及馨笛( 涛失奶 丞 卞中木化仄引丹 */ + ret = CHAR_addItemSpecificItemIndex( talker, itemindex); + if( !CHAR_CHECKITEMINDEX( talker, ret) ){ + print( "npc_exchangeman.c: additem error itemindex[%d]\n", itemindex); + ITEM_endExistItemsOne( itemindex); + return FALSE; + } + + if(itemindex != -1) { + LogItem( + CHAR_getChar( talker, CHAR_NAME ), /* 平乓仿 */ + CHAR_getChar( talker, CHAR_CDKEY ), +#ifdef _add_item_log_name // WON ADD 在item的log中增加item名称 + itemindex, +#else + ITEM_getInt( itemindex, ITEM_ID), /* 失奶 丞 寞 */ +#endif + "EventAddItem(任务需求所得到的道具)", + CHAR_getInt( talker,CHAR_FLOOR), + CHAR_getInt( talker,CHAR_X ), + CHAR_getInt( talker,CHAR_Y ), + ITEM_getChar( itemindex, ITEM_UNIQUECODE), + ITEM_getChar( itemindex, ITEM_NAME), + ITEM_getInt( itemindex, ITEM_ID) + ); + } + + sprintf(token,"收下了%s",ITEM_getChar( itemindex, ITEM_NAME)); + CHAR_talkToCli( talker, -1, token, CHAR_COLORWHITE); + + CHAR_sendItemDataOne( talker, ret); + return TRUE; + +} + +#ifdef _NPC_ADDLEVELUP // (不可开) ANDY 外部测试机用来增加玩家等级 +extern tagRidePetTable ridePetTable[296]; +void NPC_LevelAndTransUp( int meindex, int charindex, int level, int skillpoint, int exp, int ridepet) +{ + char szBuffer[256]=""; + if( !CHAR_CHECKINDEX( charindex) ) + return; +//int CHAR_LevelUpCheck( int charaindex , int toindex) + if( exp > 0 ){ + int LevelUp=0; + int myexp = CHAR_getInt( charindex, CHAR_EXP); + myexp += exp; + if( myexp > 300000000 ) myexp = 300000000; + CHAR_setInt( charindex, CHAR_EXP, myexp); + snprintf( szBuffer, sizeof(szBuffer), + "(%s) 得到 EXP %d", CHAR_getUseName( charindex ), exp); + CHAR_talkToCli( charindex, -1, szBuffer, CHAR_COLORYELLOW); + LevelUp = CHAR_LevelUpCheck( charindex , -1); + if( LevelUp > 0 ){ + snprintf( szBuffer, sizeof(szBuffer), + "(%s) 升级至 %d", + CHAR_getUseName( charindex ), + CHAR_getInt( charindex, CHAR_LV ) + ); + CHAR_talkToCli( charindex, -1, szBuffer, CHAR_COLORYELLOW); + CHAR_setInt( charindex, CHAR_SKILLUPPOINT, + CHAR_getInt( charindex, CHAR_SKILLUPPOINT) + LevelUp*3 ); + CHAR_complianceParameter( charindex ); + } + } + + if( level > 0 ){ + CHAR_setInt( charindex, CHAR_LV, level); + snprintf( szBuffer, sizeof(szBuffer), + "(%s) 等级设定为 %d", + CHAR_getUseName( charindex ), CHAR_getInt( charindex, CHAR_LV ) + ); + CHAR_talkToCli( charindex, -1, szBuffer, CHAR_COLORYELLOW); + } + + if( skillpoint > 0 ){ + int MySp = CHAR_getInt( charindex, CHAR_SKILLUPPOINT); + MySp += skillpoint; + CHAR_setInt( charindex, CHAR_SKILLUPPOINT, MySp); + } + if( ridepet >= 0 ){ + int basepet[2][4]={ {2066,2067,2068,2069}, + {2072,2073,2074,2075}}; + int petTemp[]={-1,-1,-1,-1,-1}; + char msgbuf[256]; + int petNum=0; + int i,j=0; + int k=0, petindex,enemyarray; + petTemp[j++] = basepet[0][rand()%4]; + petTemp[j++] = basepet[1][rand()%4]; + + for( i=0; i< arraysizeof(ridePetTable) ; i++ ){ + if( CHAR_getInt( charindex, CHAR_BASEBASEIMAGENUMBER) == ridePetTable[i].charNo ){ + petTemp[j]= ridePetTable[i].petId; + j++; + if( j >= arraysizeof( petTemp) ) + break; + } + } + j=0; + for( petNum=0; petNum +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "pet_skill.h" +#include "readmap.h" +#include "battle.h" +#include "profession_skill.h" +#include "chatmagic.h" +#include "npc_welfare.h" +#include "npc_exchangeman.h" + +static void NPC_Welfare_selectWindow(int meindex, int toindex, int num, int select); + + +//载入好康NPC的初始化 +BOOL NPC_WelfareInit( int meindex ) +{ + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEWELFARE); + //print("名称:%s\n",CHAR_getChar( meindex, CHAR_NAME)); + return TRUE; +} + +//对话时的处理 +void NPC_WelfareTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + if(NPC_Util_isFaceToFace(talkerindex,meindex,2 )==FALSE){ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) return; + } + NPC_Welfare_selectWindow( meindex, talkerindex,0,-1); +} + +static void NPC_Welfare_selectWindow( int meindex, int toindex, int num,int select) +{ + switch(num){ + case 0: + //free + NPC_WelfareMakeStr(meindex, toindex, select); + break; + case 1: + break; + } +} + +void NPC_WelfareWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + int skill, i, j; + int cost; + int skillID=0; + char buf[64]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char msg[512]; + char message[64]; + int fd = getfdFromCharaIndex( talkerindex ); + double rate= 1.0; + int skillarray; + int p_class=0, need_class=0; + int profession_skill_point; + + memset( message, -1, sizeof(message) ); + + if( NPC_Util_CharDistance( talkerindex, meindex ) > 2) { + return; + } + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("GetArgStrErr"); + return; + } + + makeStringFromEscaped( data); + getStringFromIndexWithDelim(data,"|",1,buf,sizeof(buf)); + skill=atoi(buf); + getStringFromIndexWithDelim(data,"|",2,buf,sizeof(buf)); + cost=atoi(buf); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "profession_skill", msg, sizeof( msg)) != NULL){ + getStringFromIndexWithDelim(msg,",",skill,buf,sizeof(buf)); + skillID=atoi(buf); + } + + + if(skillID < 0) return ; + + if( CHAR_getWorkInt( CONNECT_getCharaindex(fd), CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) return ; + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "skill_rate", msg, sizeof( msg)) != NULL){ + rate = atof( msg); + } + + skillarray = PROFESSION_SKILL_getskillArray( skillID ); + + if(skillarray == -1){ + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return ; + } + + // 判断职业 + { + if( NPC_Util_GetStrFromStrWithDelim( argstr, "profession_class", msg, sizeof(msg) ) == NULL){ + return ; + }else{ + p_class = atoi(msg); + } + + // 技能所需职业 + need_class = PROFESSION_SKILL_getInt( skillarray, PROFESSION_SKILL_PROFESSION_CLASS ); + + if( CHAR_getInt( talkerindex, PROFESSION_CLASS ) == 0 ){ + char token[256]; + memset(token, -1, sizeof(token) ); + sprintf( token, "您尚未就职!" ); + CHAR_talkToCli( talkerindex, meindex, token, CHAR_COLORYELLOW); + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return; + + } + + if( CHAR_getInt( talkerindex, PROFESSION_CLASS ) != need_class && need_class != 4 ){ + char token[256]; + memset(token, -1, sizeof(token) ); + sprintf( token, "此技能你不能学喔!" ); + CHAR_talkToCli( talkerindex, meindex, token, CHAR_COLORYELLOW); + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return; + } + + + } + + // 判断剩馀点数 + { + profession_skill_point = CHAR_getInt( talkerindex, PROFESSION_SKILL_POINT ); + if( profession_skill_point <= 0 ){ + char token[256]; + memset(token, -1, sizeof(token) ); + sprintf( token, "你目前没有学习点数!" ); + CHAR_talkToCli( talkerindex, meindex, token, CHAR_COLORYELLOW); + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return; + } + } + + // 判断是否达成学习的条件 + { + int temp[4] = {0}, count = 0, flag = -1 , need_percent = -1, need_count = 0; + + for( i=0; i<4; i++){ + int limit = -1; + flag = -1; + limit = PROFESSION_SKILL_getInt( skillarray, PROFESSION_SKILL_LIMIT1+i*2 ); + need_percent = PROFESSION_SKILL_getInt( skillarray, PROFESSION_SKILL_LIMIT1+i*2 + 1 ); + + if( limit!= 0 && need_percent == 0 ) need_count++; + + if( limit == 0 ){ + continue; + }else if( limit == -1 ){ + for( j=0; j 0 ) break; + } + if( j >= PROFESSION_MAX_LEVEL ){ + char token[256]; + sprintf( token, "需先学会任1种战斗技能才能学习!"); + CHAR_talkToCli( talkerindex, meindex, token, CHAR_COLORYELLOW); + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return; + } + }else{ + flag = -1; + for( j=0; jskill, SKILL_LEVEL); + + // 判断熟练度 + if( skill_level >= need_percent ){ + flag = 1; break; + } + } + } + + // 未达成条件 + if( flag == -1 && need_percent == 0 ){ + temp[count] = limit; + count ++; + }else if( flag == -1 ){ + char token[256]; + memset(token, -1, sizeof(token) ); + sprintf( token, "尚未学会%s!", PROFESSION_SKILL_getChar( limit, PROFESSION_SKILL_NAME) ); + CHAR_talkToCli( talkerindex, -1, token, CHAR_COLORYELLOW); + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return; + }else if( flag == -2 ){ + char token[256]; + memset(token, -1, sizeof(token) ); + sprintf( token, "%s熟练度不足%d!", PROFESSION_SKILL_getChar( limit, PROFESSION_SKILL_NAME), need_percent ); + CHAR_talkToCli( talkerindex, -1, token, CHAR_COLORYELLOW); + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return; + } + } + } + + if( count == need_count && need_count != 0 ){ + char msg[256] = {0}; + + sprintf( msg, "需先学会 " ); + for( i = 0; i< count; i++ ){ + if( temp[i] != 0 ){ + char token[50] = {0}; + sprintf( token, "%s ", PROFESSION_SKILL_getChar( temp[i], PROFESSION_SKILL_NAME) ); + strcat( msg, token ); + } + } + sprintf( msg, "%s 任一种技能", msg ); + CHAR_talkToCli( talkerindex, -1, msg, CHAR_COLORYELLOW); + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + + return; + } + + } + + // 判断金钱 + { + cost = PROFESSION_SKILL_getInt( skillarray, PROFESSION_SKILL_COST ); + cost = cost * rate; + + if(CHAR_getInt(talkerindex,CHAR_GOLD) < cost){ + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + return; + } + } + +#ifdef _NPC_ProfessionTrans + //判断转生 + { + if( NPC_Util_GetStrFromStrWithDelim( argstr, "trans", msg, sizeof(msg) ) != NULL){ + int trans = atoi(msg); + print("\n转生要求:%d,%d",CHAR_getInt( talkerindex, CHAR_TRANSMIGRATION),trans); + if( CHAR_getInt( talkerindex, CHAR_TRANSMIGRATION) < trans){ + if( NPC_Util_GetStrFromStrWithDelim( argstr, "trans_msg", msg, sizeof(msg) ) != NULL){ + CHAR_talkToCli( talkerindex, meindex, msg, CHAR_COLORYELLOW); + return; + } + else{ + CHAR_talkToCli( talkerindex, meindex, "您的转生次数不够哦。", CHAR_COLORYELLOW); + return; + } + } + } + } +#endif + + // 增加技能 + { + int skill_level = 0; + + // 共通技能熟练度给50,其馀给10 + if( (skillID == 63) || (skillID == 64) || (skillID == 65) ){ + int Pskillid = -1; + skill_level = 50; + Pskillid = PROFESSION_SKILL_getskillArray( skillID ); + }else{ + skill_level = 10; + } + + if( PROFESSION_SKILL_ADDSK( talkerindex, skillID, skill_level ) == -1 ) return; + + CHAR_DelGold( talkerindex, cost ); + + CHAR_sendStatusString( talkerindex , "S"); + + NPC_Welfare_selectWindow( meindex, talkerindex,0,-1); + } + + // 传送讯息 + { + char token[256]; + int next_profession_skill_point = profession_skill_point-1; + + CHAR_setInt( talkerindex, PROFESSION_SKILL_POINT, next_profession_skill_point ); + + memset(token, -1, sizeof(token) ); + sprintf( token, "您学习了 %s,剩馀学习点数 %d" + ,PROFESSION_SKILL_getChar( skillarray, PROFESSION_SKILL_NAME ) + ,next_profession_skill_point ); + CHAR_talkToCli( talkerindex, -1, token, CHAR_COLORYELLOW); + + CHAR_sendCToArroundCharacter( CHAR_getWorkInt( talkerindex , CHAR_WORKOBJINDEX )); + } + +} + +void NPC_WelfareMakeStr(int meindex,int toindex,int select) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char msg[256]; + double rate=1.0; + int i=0; + char token[65530]; + int fd = getfdFromCharaIndex( toindex); + + if(select==0){ + sprintf(token,"0|0"); + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_PETSKILLSHOP, + WINDOW_BUTTONTYPE_NONE, + CHAR_WINDOWTYPE_WINDOWPETSKILLSHOP, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + } + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("GetArgStrErr"); + return; + } + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "main_msg", msg, sizeof( msg)) == NULL){ + print("mainERR"); + return ; + } + + sprintf(token,"1|%s|%s", CHAR_getChar(meindex,CHAR_NAME), msg); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "skill_rate", msg, sizeof( msg)) != NULL){ + rate=atof(msg); + } + + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "profession_skill", msg, sizeof( msg) ) != NULL){ + int skillarray; + int skillID; + int cost; + char token2[265]; + char buf[64]; + + i=1; + while( getStringFromIndexWithDelim(msg,",",i,buf,sizeof(buf)) !=FALSE ){ + i++; + skillID=atoi(buf); + + skillarray = PROFESSION_SKILL_getskillArray( skillID ); + + if( PROFESSION_SKILL_CHECKINDEX( skillarray ) == FALSE ) continue; + + cost = PROFESSION_SKILL_getInt( skillarray, PROFESSION_SKILL_COST ); + + cost = (int)cost*rate; + + sprintf(token2,"|%s|%d|%s|%d", + PROFESSION_SKILL_getChar( skillarray, PROFESSION_SKILL_NAME ), // 技能名称 + cost, // 金额 + PROFESSION_SKILL_getChar( skillarray, PROFESSION_SKILL_TXT ), // 说明 + PROFESSION_SKILL_getInt( skillarray, PROFESSION_SKILL_ICON ) // 图示 + ); + strcat(token,token2); + } + } + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_PROFESSIONSHOP, + WINDOW_BUTTONTYPE_NONE, + WINDOW_MESSAGETYPE_PROFESSIONSHOP, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + return; +} + + +#endif +#endif + + diff --git a/gmsv/npc/npc_welfare2.c b/gmsv/npc/npc_welfare2.c new file mode 100644 index 0000000..eb78de2 --- /dev/null +++ b/gmsv/npc/npc_welfare2.c @@ -0,0 +1,278 @@ +#include "version.h" + +#ifdef _NPC_WELFARE_2 // WON ADD 职业NPC-2 +#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 + +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "pet_skill.h" +#include "readmap.h" +#include "battle.h" +#include "profession_skill.h" +#include "chatmagic.h" +#include "npc_welfare2.h" + + +static void NPC_Welfare_selectWindow2(int meindex, int toindex, int num, int select); + +//载入好康NPC的初始化 +BOOL NPC_WelfareInit2( int meindex ) +{ + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEWELFARE); + print("名称:%s\n",CHAR_getChar( meindex, CHAR_NAME)); + return TRUE; +} + +//对话时的处理 +void NPC_WelfareTalked2( int meindex , int talkerindex , char *szMes ,int color ) +{ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + if(NPC_Util_isFaceToFace(talkerindex,meindex,2 )==FALSE){ + if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) return; + } + NPC_Welfare_selectWindow2( meindex, talkerindex,0,-1); +} + +static void NPC_Welfare_selectWindow2( int meindex, int toindex, int num,int select) +{ + switch(num){ + case 0: + //free + NPC_WelfareMakeStr2(meindex, toindex, select); + break; + case 1: + break; + } +} + +void NPC_WelfareWindowTalked2( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + int skill, i, j; + int skillID = -1, skillid = -1; + int ENDEV = -1, NOWEV = -1; + char buf[64]; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char msg[512]; + int fd = getfdFromCharaIndex( talkerindex ); + double rate= 1.0; + int skillarray; + CHAR_HaveSkill* hskill; + char err_msg[128] = {0}; + + if( NPC_Util_CharDistance( talkerindex, meindex ) > 2) { + return; + } + + if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ + print("GetArgStrErr"); + return; + } + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "ENDEV:", msg, sizeof( msg)) != NULL){ + ENDEV=atof(msg); + } + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "NOWEV:", msg, sizeof( msg)) != NULL){ + NOWEV=atof(msg); + } + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "err_msg:", err_msg, sizeof( msg)) == NULL){ + print("GetArgStrErr"); + return; + } + + if( ENDEV > 0 ){ + if( NPC_EventCheckFlg( talkerindex, ENDEV ) != TRUE ){ + CHAR_talkToCli( talkerindex, -1, err_msg, CHAR_COLORYELLOW); + return; + } + }else if( NOWEV > 0 ){ + if( NPC_EventCheckFlg( talkerindex, NOWEV ) != TRUE ){ + CHAR_talkToCli( talkerindex, -1, err_msg, CHAR_COLORYELLOW); + return; + } + } + + makeStringFromEscaped( data); + getStringFromIndexWithDelim(data,"|",1,buf,sizeof(buf)); + skill=atoi(buf); + + // 技能id + skillid = CHAR_getCharSkill( talkerindex, skill - 1 ); + skillID = skillid; + + if(skillID <= 0) return ; + + if( CHAR_getWorkInt( CONNECT_getCharaindex(fd), CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) return ; + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "skill_rate", msg, sizeof( msg)) != NULL){ + rate = atof( msg); + } + + // 不扣钱 + CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); + + skillarray = PROFESSION_SKILL_getskillArray( skillID ); + + // 检查是否有不能删除的技能 + for( i=0; i 0 && limit == skillID ){ + char token[256] = {0}; + + sprintf( token, "需先遗忘%s,才可删除此技能", PROFESSION_SKILL_getChar( skillarray_temp, PROFESSION_SKILL_NAME ) ); + CHAR_talkToCli( talkerindex, -1, token, CHAR_COLORYELLOW); + return; + } + } + } + + // 遗忘技能 + { + + int skill_level = -1; + int count = 0; + int skill_id[CHAR_SKILLMAXHAVE] = {0}; + int skill_temp[CHAR_SKILLMAXHAVE] = {0}; + + // 取熟练度 + for( i=0; iskill, SKILL_LEVEL); + + skill_id[count] = skillid; + skill_temp[count] = skill_level; + count++; + } + + // 删除所有技能 + CHAR_CHAT_DEBUG_delsk( talkerindex, "all" ); + + // 还原技能 + for( i=0; iskill, SKILL_LEVEL); + + sprintf(token2,"|%s|%d|%s|%d", + PROFESSION_SKILL_getChar( skillarray, PROFESSION_SKILL_NAME ), // 技能名称 + skill_level, // 熟练度 + PROFESSION_SKILL_getChar( skillarray, PROFESSION_SKILL_TXT ), // 说明 + PROFESSION_SKILL_getInt( skillarray, PROFESSION_SKILL_ICON ) // 图示 + ); + + strcat(token,token2); + } + + lssproto_WN_send( fd, WINDOW_MESSAGETYPE_PROFESSIONSHOP2, + WINDOW_BUTTONTYPE_NONE, + WINDOW_MESSAGETYPE_PROFESSIONSHOP, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + token); + + return; +} + + +#endif +#endif + + diff --git a/gmsv/npc/npc_windowhealer.c b/gmsv/npc/npc_windowhealer.c new file mode 100644 index 0000000..7c676bd --- /dev/null +++ b/gmsv/npc/npc_windowhealer.c @@ -0,0 +1,731 @@ +#include "version.h" +#include +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "lssproto_serv.h" +#include "npc_windowhealer.h" + + + +/*--怂 ---*/ +#define RATE 1000 + + +/* + * 涩烂今木凶它奴件玉它毛请允NPC + * 棵哑 平旦玄失玉矛件民乓□仁日中卅日综木月井手[ + * + */ + +enum { + CHAR_WORK_LEVEL = CHAR_NPCWORKINT1, + CHAR_WORK_RANGE = CHAR_NPCWORKINT2, + CHAR_WORK_HP = CHAR_NPCWORKINT3, + CHAR_WORK_MP = CHAR_NPCWORKINT4, + +}; + + +static void NPC_WindowHealer_selectWindow( int meindex, int toindex, int num); +void NPC_WindowHealerAllHeal( int talker,int mode ); +BOOL NPC_WindowHealerLevelCheck(int meindex,int talker); +BOOL NPC_WindowMoneyCheck(int meindex,int talker,int mode); +int NPC_WindowCostCheck(int meindex,int talker); +BOOL NPC_PetHealerCheck(int talker); +int NPC_WindowCostCheckMp(int meindex,int talker); + + +/********************************* +* 赓渝质 +*********************************/ +BOOL NPC_WindowHealerInit( int meindex ) +{ + + char *npcarg; + char buf2[256]; + int range=1; + int rate; + double drate; + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEHEALER ); + + npcarg = CHAR_getChar(meindex,CHAR_NPCARGUMENT); + + /*--荚汊允月午五及云嗯毛潸月伊矛伙毛筏盛--*/ + /*-- 仃木壬综日木卅中--*/ + if(getStringFromIndexWithDelim(npcarg,"|",1,buf2,sizeof(buf2))!=FALSE){ + CHAR_setWorkInt(meindex,CHAR_WORK_LEVEL,atoi(buf2)); + + }else{ + return FALSE; + } + /*--觐菁 伊□玄--*/ + if(getStringFromIndexWithDelim(npcarg, "|", 2, buf2, sizeof( buf2)) != FALSE ){ + drate = atof(buf2); + if(drate==0) { + rate=500; + }else{ + rate=(int) (drate * RATE); + } + CHAR_setWorkInt(meindex,CHAR_WORK_HP,rate); + } + if(getStringFromIndexWithDelim(npcarg, "|", 3, buf2, sizeof( buf2)) != FALSE ){ + drate = atof(buf2); + if(drate==0){ + rate=2000; + }else{ + rate=(int)( drate * RATE); + } + CHAR_setWorkInt(meindex,CHAR_WORK_MP,rate); + } + if(getStringFromIndexWithDelim(npcarg, "|", 4, buf2, sizeof( buf2)) != FALSE ){ + range=atoi(buf2); + if(range == 0){ + range=1; + } + } + CHAR_setWorkInt(meindex,CHAR_WORK_RANGE,range); + return TRUE; + +} + +void NPC_WindowHealerTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + + if( NPC_Util_CharDistance( talkerindex, meindex ) + > CHAR_getWorkInt(meindex,CHAR_WORK_RANGE)){ + return; + } + if( (CHAR_getWorkInt(talkerindex,CHAR_WORKPARTYMODE) == 0) + || (CHAR_getWorkInt(talkerindex,CHAR_WORKPARTYMODE) == 2) ){ + NPC_WindowHealer_selectWindow( meindex, talkerindex,0); + }else{ + int i=0; + int otherindex; + + for( i=0 ; i < CHAR_PARTYMAX ;i++){ + otherindex=CHAR_getWorkInt(talkerindex,CHAR_WORKPARTYINDEX1+i); + if(otherindex != -1){ + NPC_WindowHealer_selectWindow( meindex, otherindex,0); + } + } + } +} +void NPC_WindowHealerLooked( int meindex , int lookedindex) +{ + if( CHAR_getInt( lookedindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + if( NPC_Util_CharDistance( lookedindex, meindex ) + > CHAR_getWorkInt(meindex,CHAR_WORK_RANGE)){ + return; + } + NPC_WindowHealer_selectWindow( meindex, lookedindex,0); +} + +static void NPC_WindowHealer_selectWindow( int meindex, int toindex, int num) +{ + + char token[1024]; + char escapedname[1024]; + int fd = getfdFromCharaIndex( toindex); + int buttontype=0; + int windowtype=0; + int windowno=0; + + /*--它奶件玉它正奶皿丢永本□斥互云云中及匹燮卞涩烂--*/ + windowtype=WINDOW_MESSAGETYPE_MESSAGE; + + switch( num){ + case 0: + /*--蓟 --*/ + sprintf(token,"    哎呀!你受伤了吗?  \n\n " + "       < 耐久力回复>      \n" + "       < 气力回复 >      \n" + "      < 耐久力·气力回复 >   \n\n" + "       <宠物回复(免费)>     " + ); + + buttontype=WINDOW_BUTTONTYPE_CANCEL; + windowtype=WINDOW_MESSAGETYPE_SELECT; + windowno=CHAR_WINDOWTYPE_WINDOWHEALER_STARTMSG; + break; + + + case 1: + if( CHAR_getInt(toindex,CHAR_HP) ==CHAR_getWorkInt( toindex, CHAR_WORKMAXHP)){ + if(NPC_PetHealerCheck(toindex)==FALSE){ + sprintf(token, + "       < 耐久力回复 >" + "\n\n\n\n    似乎没有必要回复唷! "); + }else{ + sprintf(token, + "       < 耐久力回复 >" + "\n\n     似乎没有必要回复唷! " + "\n\n   因为宠物好像也受伤了!" + "\n 先帮他回复吧!"); + + NPC_WindowHealerAllHeal(toindex,0 ); + } + + buttontype=WINDOW_BUTTONTYPE_OK; + windowno=CHAR_WINDOWTYPE_WINDOWHEALER_HPMSG; + break; + }else if(NPC_WindowHealerLevelCheck(meindex,toindex)==TRUE){ + sprintf(token,"       < 耐久力回复 >" + "\n\n\n       是要回复耐久力没错吧!    " + "\n\n 现在的等级可以免费帮你回复唷!"); + + }else{ + int gold; + gold=NPC_WindowCostCheck(meindex,toindex); + sprintf(token,"       < 耐久力回复 >" + "\n\n\n       是要回复耐久力没错吧!    " + "\n\n     收您%d的STONE 。" + ,gold); + } + + buttontype=WINDOW_BUTTONTYPE_YESNO; + windowno=CHAR_WINDOWTYPE_WINDOWHEALER_HPMSG; + break; + + case 2: + if( CHAR_getInt(toindex,CHAR_MP) ==CHAR_getWorkInt( toindex, CHAR_WORKMAXMP)){ + if(NPC_PetHealerCheck(toindex)==FALSE){ + sprintf(token, "       < 气力回复 >" + "\n\n\n\n    似乎没有必要回复唷! "); + }else{ + sprintf(token, "       < 气力回复 >" + "\n\n     似乎没有必要回复唷! " + "\n\n   因为宠物好像也受伤了!" + "\n 先帮他回复吧!"); + NPC_WindowHealerAllHeal(toindex,0 ); + } + buttontype=WINDOW_BUTTONTYPE_OK; + windowno=CHAR_WINDOWTYPE_WINDOWHEALER_SPIRITMSG; + break; + } + + if(NPC_WindowHealerLevelCheck(meindex,toindex)==TRUE){ + sprintf(token,"       < 气力回复>" + "\n\n       是要回复气力没错吧!     " + "\n\n 现在的等级可以免费帮你回复唷!"); + }else{ + int cost; + cost=NPC_WindowCostCheckMp(meindex,toindex); + sprintf(token,"       < 气力回复>" + "\n\n\n       是要回复气力没错吧! " + "\n\n    收您%d的STONE 。", + cost); + } + buttontype=WINDOW_BUTTONTYPE_YESNO; + windowno=CHAR_WINDOWTYPE_WINDOWHEALER_SPIRITMSG; + break; + + + case 3: + sprintf(token, "\n      <耐久力已回复>" + "\n   <宠物也已回复一般状态>" + "\n\n\n      这样子就没问题了!    "); + + /*--觐菁 及心荚汊今六月--*/ + NPC_WindowHealerAllHeal( toindex ,1 ); + buttontype=WINDOW_BUTTONTYPE_OK; + windowno=CHAR_WINDOWTYPE_WINDOWHEALER_OKHPMSG; + break; + + + case 4: + sprintf(token, "\n      <气力已回复>" + "\n   <宠物也已回复一般状态>" + "\n\n\n      这样子就没问题了!    "); + /*--竣 及心荚汊今六月---*/ + NPC_WindowHealerAllHeal( toindex ,2 ); + buttontype=WINDOW_BUTTONTYPE_OK; + windowno=CHAR_WINDOWTYPE_WINDOWHEALER_OKSPIRITMSG; + break; + + + case 6: + { + int cost=0; + + if(CHAR_getInt(toindex,CHAR_HP) < CHAR_getWorkInt( toindex, CHAR_WORKMAXHP)) + { + cost+=NPC_WindowCostCheck(meindex,toindex); + } + + if( CHAR_getInt(toindex,CHAR_MP) < CHAR_getWorkInt( toindex, CHAR_WORKMAXMP)) + { + cost=cost+NPC_WindowCostCheckMp(meindex,toindex); + } + + if(cost==0) { + if(NPC_PetHealerCheck(toindex)==FALSE){ + sprintf(token, + "     < 耐久力气力回复 >" + "\n\n\n\n    似乎没有必要回复唷! "); + }else{ + sprintf(token,"     < 耐久力气力回复 >" + "\n\n     似乎没有必要回复唷! " + "\n\n   因为宠物好像也受伤了!" + "\n 先帮他回复吧!"); + NPC_WindowHealerAllHeal(toindex,0 ); + } + + + + buttontype=WINDOW_BUTTONTYPE_OK; + windowtype=WINDOW_MESSAGETYPE_MESSAGE; + windowno=CHAR_WINDOWTYPE_WINDOWHEALER_SPIRITMSG; + break; + + }else{ + sprintf(token,"    < 耐久力气力回复 >" + "\n\n\n     是要回复耐久力气力没错吧!" + "\n\n     收您%d的STONE 。",cost); + } + } + + if(NPC_WindowHealerLevelCheck(meindex,toindex)==TRUE){ + sprintf(token,"     < 耐久力气力回复 >" + "\n\n\n      是要回复耐久力气力没错吧!" + "\n\n 现在的等级可以免费帮你回复唷!"); + } + + buttontype=WINDOW_BUTTONTYPE_YESNO; + windowtype=WINDOW_MESSAGETYPE_MESSAGE; + windowno=CHAR_WINDOWTYPE_WINDOWHEALER_ALLMSG; + break; + + + case 7: + sprintf(token,"     <耐久力气力已回复>" + "\n   <宠物也已回复一般状态>" + "\n\n\n    这样一来就回复健康了!"); + + NPC_WindowHealerAllHeal( toindex ,3 ); + buttontype=WINDOW_BUTTONTYPE_OK; + windowtype=WINDOW_MESSAGETYPE_MESSAGE; + windowno=CHAR_WINDOWTYPE_WINDOWHEALER_OKALLMSG; + break; + + + case 8: + sprintf(token,"\n\n\n\n   真可惜似乎所带的金钱不够唷!"); + + buttontype=WINDOW_BUTTONTYPE_OK; + windowtype=WINDOW_MESSAGETYPE_MESSAGE; + windowno=CHAR_WINDOWTYPE_WINDOWHEALER_OKHPMSG; + break; + + case 9: + sprintf(token,"       <宠物回复>      " + "\n\n\n       已经没问题了啦!     " + "\n\n  但是太勉强的话也不行唷!  "); + NPC_WindowHealerAllHeal(toindex,0 ); + buttontype=WINDOW_BUTTONTYPE_OK; + windowtype=WINDOW_MESSAGETYPE_MESSAGE; + windowno=CHAR_WINDOWTYPE_WINDOWHEALER_OKHPMSG; + break; + + case 10: + sprintf(token,"       <宠物回复>      " + "\n\n\n  似乎没有必要回复宠物的样子。 " + "\n\n  但是太勉强的话也不行唷!  "); + buttontype=WINDOW_BUTTONTYPE_OK; + windowtype=WINDOW_MESSAGETYPE_MESSAGE; + windowno=CHAR_WINDOWTYPE_WINDOWHEALER_OKHPMSG; + break; + + + } + + + makeEscapeString( token, escapedname, sizeof(escapedname)); + /*-仇仇匹霜耨允月--*/ + lssproto_WN_send( fd, windowtype, + buttontype, + windowno, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + escapedname); + +} + + +/*----------------------------------------- +弁仿奶失件玄井日忒匀化五凶凛卞裟太请今木月[ +-------------------------------------------*/ +void NPC_WindowHealerWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) +{ + + if( NPC_Util_CharDistance( talkerindex, meindex ) > (CHAR_getWorkInt(meindex,CHAR_WORK_RANGE)+4)) return; + + switch( seqno){ + case CHAR_WINDOWTYPE_WINDOWHEALER_STARTMSG: + if(atoi(data)==2) /*--蓟 仄凶嫩 1--*/ + { + NPC_WindowHealer_selectWindow( meindex, talkerindex, 1 ); + + }else if(atoi(data)==3){ + /*--蓟 仄凶嫩 2--*/ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 2 ); + + }else if(atoi(data)==4){ + /*--蓟 仄凶嫩 2--*/ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 6 ); + + }else if(atoi(data)==6){ + /*--蓟 仄凶嫩 2--*/ + if(NPC_PetHealerCheck( talkerindex)==TRUE){ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 9 ); + }else{ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 10 ); + } + }else if(select==WINDOW_BUTTONTYPE_CANCEL){ + /*--仇仇引匹仁月午蔽 卅及匹窒手仄卅中--*/ + } + break; + + + /*-----觐菁 荚汊毛云仇卅丹-----*/ + case CHAR_WINDOWTYPE_WINDOWHEALER_HPMSG: + if(select==WINDOW_BUTTONTYPE_OK){ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 0 ); + + }else if(select==WINDOW_BUTTONTYPE_YES){ + /*--云嗯及民尼永弁--*/ + if(NPC_WindowMoneyCheck(meindex,talkerindex,1)==TRUE){ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 3 ); + }else{ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 8 ); + } + }else if(select==WINDOW_BUTTONTYPE_NO){ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 0 ); + + } + break; + + + /*-----竣 荚汊毛云仇卅丹-----*/ + case CHAR_WINDOWTYPE_WINDOWHEALER_SPIRITMSG: + if(select==WINDOW_BUTTONTYPE_OK){ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 0 ); + + }else if(select==WINDOW_BUTTONTYPE_YES){ + /*--云嗯及民尼永弁--*/ + if(NPC_WindowMoneyCheck(meindex,talkerindex,2)==TRUE){ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 4 ); + }else{ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 8 ); + } + + }else if(select==WINDOW_BUTTONTYPE_NO){ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 0 ); + } + + break; + + + /*-----觐菁 荚汊及瑛绊-----*/ + case CHAR_WINDOWTYPE_WINDOWHEALER_OKHPMSG: + if(select==WINDOW_BUTTONTYPE_OK){ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 0 ); + } + break; + + + case CHAR_WINDOWTYPE_WINDOWHEALER_OKSPIRITMSG: + if(select==WINDOW_BUTTONTYPE_OK){ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 0 ); + } + break; + + + /*--蝈荚汊今六月--*/ + case CHAR_WINDOWTYPE_WINDOWHEALER_ALLMSG: + if(select==WINDOW_BUTTONTYPE_OK){ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 0 ); + + }else if(select==WINDOW_BUTTONTYPE_YES){ + if(NPC_WindowMoneyCheck(meindex,talkerindex,3)==TRUE){ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 7 ); + }else{ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 8 ); + } + + }else if(select==WINDOW_BUTTONTYPE_NO){ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 0 ); + } + break; + + + /*--蝈荚汊及瑛绊--*/ + case CHAR_WINDOWTYPE_WINDOWHEALER_OKALLMSG: + if(select==WINDOW_BUTTONTYPE_YES){ + NPC_WindowHealer_selectWindow( meindex, talkerindex, 0 ); + } + break; + } + + if(select==WINDOW_BUTTONTYPE_CANCEL + && CHAR_getWorkInt( talkerindex, CHAR_WORKPARTYMODE ) == 2) + { + CHAR_sendWatchEvent( CHAR_getWorkInt( talkerindex, CHAR_WORKOBJINDEX), + CHAR_ACTPLEASURE,NULL,0,TRUE); + CHAR_setWorkInt( talkerindex, CHAR_WORKACTION, CHAR_ACTPLEASURE); + } + +} + + +/*--辎勾中化中月及卅日}TRUE毛忒允--*/ +BOOL NPC_PetHealerCheck(int talker) +{ + + int petindex; + int i; + + /*--矢永玄反云引仃匹荚汊仄化丐仆月--*/ + for(i=0;i CHAR_getInt(talker,CHAR_LV)){ + return TRUE; + } + + return FALSE; + +} + + +/*------------------------------------------- +云嗯 匀化月井民尼永弁 +娄醒 +meindex’’’ 及奶件犯永弁旦 +talker’’’’平乓仿弁正□及奶件犯永弁旦 +---------------------------------------------*/ +BOOL NPC_WindowMoneyCheck(int meindex,int talker,int mode) +{ + int cost=0; + int level; + + level=CHAR_getWorkInt(meindex,CHAR_WORK_LEVEL); + + if(mode==1){ + if(level <= CHAR_getInt(talker,CHAR_LV)){ + /*---云嗯毛喃曰请允---*/ + cost=NPC_WindowCostCheck(meindex,talker); + /*--蜇箕反移涩烂---*/ + /*---云嗯互箫曰月井升丹井及民尼永弁---*/ + if(CHAR_getInt(talker,CHAR_GOLD) < cost){ + return FALSE; + + } + CHAR_DelGold( talker, cost); + } + } + if(mode==2){ + if(level <= CHAR_getInt(talker,CHAR_LV)){ + /*---云嗯毛喃曰请允---*/ + cost=NPC_WindowCostCheckMp(meindex,talker); + + /*--蜇箕反移涩烂---*/ + /*---云嗯互箫曰月井升丹井及民尼永弁---*/ + if(CHAR_getInt(talker,CHAR_GOLD) < cost){ + return FALSE; + } + CHAR_DelGold( talker, cost); + } + } + + if(mode==3){ + if(level <= CHAR_getInt(talker,CHAR_LV)){ + + /*--觐菁 及云嗯及煌遥--*/ + if( CHAR_getInt(talker,CHAR_HP) +#include "char.h" +#include "object.h" +#include "char_base.h" +#include "npcutil.h" +#include "configfile.h" +#include "lssproto_serv.h" +#include "npc_windowman.h" + +struct { + int windowno; + int windowtype; + int buttontype; + int takeitem; + int giveitem; + char message[4096]; +}w; + +struct { + BOOL use; + int checkhaveitem; + int checkhaveitemgotowin; + int checkdonthaveitem; + int checkdonthaveitemgotowin; + int warp; + int battle; + int gotowin; +}buttonproc[13]; /* ok,cancel, yes,no,prev,next 及凛及质 */ + + + + + +enum { + CHAR_WORK_MSGCOLOR = CHAR_NPCWORKINT1, +}; +//static void NPC_Windowman_selectWindow( int meindex, int toindex, int num); +//static BOOL NPC_Windowman_readData( int meindex, int windowno, BOOL chkflg); +//static int NPC_Windowman_restoreButtontype( char *data ); + +/********************************* +* 赓渝质 +*********************************/ +BOOL NPC_WindowmanInit( int meindex ) +{ + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[1024]; + //int i; + //char secondToken[1024]; + + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "conff", buf, sizeof( buf)) + == NULL ) + { + print( "windowman:没有指定设定的档案 。\n"); + return FALSE; + } + /* 赓渝凛卞涩烂犯□正毛民尼永弁仄化支月 */ + if( !NPC_Windowman_readData( meindex, -1, TRUE) ) { + return FALSE; + } + + CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEWINDOWMAN ); + + return TRUE; +} + + + + +/********************************* +* 仄井仃日木凶凛及质 +*********************************/ +void NPC_WindowmanTalked( int meindex , int talkerindex , char *szMes ,int color ) +{ + + NPC_Windowman_selectWindow( meindex, talkerindex, 1 ); + +} +/********************************* +* 苇日木凶凛及质 +*********************************/ +void NPC_WindowmanLooked( int meindex , int lookedindex) +{ + + NPC_Windowman_selectWindow( meindex, lookedindex,1 ); + +} + +/*static*/ void NPC_Windowman_selectWindow( int meindex, int toindex, int num) +{ + + int fd; + char buf[256]; + + /* 皿伊奶乩□卞覆仄化分仃 杀允月 */ + if( CHAR_getInt( toindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { + return; + } + /* ㄠ弘伉永玉动 及心 */ + if( !NPC_Util_charIsInFrontOfChar( toindex, meindex, 1 )) return; + + if( !NPC_Windowman_readData( meindex, num, FALSE) ) { + print( "windowman:readdata error\n"); + return; + } + + fd = getfdFromCharaIndex( toindex); + if( fd != -1 ) { + lssproto_WN_send( fd, w.windowtype, + w.buttontype, + w.windowno+100, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( w.message, buf, sizeof(buf))); + } +} +void NPC_WindowmanWindowTalked( int meindex, int talkerindex, + int seqno, int select, char *data) + +{ + int button = -1; + char buf[256]; + if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) return; + + if( !NPC_Windowman_readData( meindex, seqno - 100, FALSE) ) { + print( "windowman:readdata error\n"); + return; + } + if( w.windowtype == WINDOW_MESSAGETYPE_SELECT ) { + button = atoi( data)+5; + if( button > 12 ) { + print( "windowman:invalid button[%d]\n", button); + return; + } + } + else if( select & WINDOW_BUTTONTYPE_OK) button = 0; + else if( select & WINDOW_BUTTONTYPE_CANCEL) button = 1; + else if( select & WINDOW_BUTTONTYPE_YES) button = 2; + else if( select & WINDOW_BUTTONTYPE_NO) button = 3; + else if( select & WINDOW_BUTTONTYPE_PREV) button = 4; + else if( select & WINDOW_BUTTONTYPE_NEXT) button = 5; + else { + print( "windowman:invalid button[%d]\n", select); + return; + } + if( buttonproc[button].use == TRUE ) { + int i; + int fd; + int newwin = -1; + if( buttonproc[button].checkhaveitem != -1 ) { + for( i = 0; i < CHAR_MAXITEMHAVE; i ++ ) { + int itemindex = CHAR_getItemIndex( talkerindex, i); + if( ITEM_CHECKINDEX( itemindex)) { + if( ITEM_getInt( itemindex, ITEM_ID) + == buttonproc[button].checkhaveitem ) + { + break; + } + } + } + if( i == CHAR_MAXITEMHAVE ) { + return; + } + newwin = buttonproc[button].checkhaveitemgotowin; + } + if( buttonproc[button].checkdonthaveitem != -1 ) { + for( i = 0; i < CHAR_MAXITEMHAVE; i ++ ) { + int itemindex = CHAR_getItemIndex( talkerindex, i); + if( ITEM_CHECKINDEX( itemindex)) { + if( ITEM_getInt( itemindex, ITEM_ID) + == buttonproc[button].checkdonthaveitem ) + { + break; + } + } + } + if( i != CHAR_MAXITEMHAVE ) { + return; + } + newwin = buttonproc[button].checkdonthaveitemgotowin; + } + + if( newwin == -1 ) { + newwin = buttonproc[button].gotowin; + } + if( !NPC_Windowman_readData( meindex, newwin, FALSE) ) { + print( "windowman:readdata error\n"); + return; + } + fd = getfdFromCharaIndex( talkerindex); + if( fd != -1 ) { + lssproto_WN_send( fd, w.windowtype, + w.buttontype, + w.windowno+100, + CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), + makeEscapeString( w.message, buf, sizeof(buf))); + } + } +} + +BOOL NPC_Windowman_readData( int meindex, int windowno, BOOL chkflg) +{ + + int i; + int linenum = 0; + int endflg = FALSE; + int buttonendflg; + int winno = -1; + int buttonconfmode; + int b_mode; + int selectnum ; + int messagepos; + BOOL errflg = FALSE; + BOOL readflg = TRUE; + FILE *fp; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char filename[64]; + char opfile[128]; + char line[1024]; + char firstToken[1024]; + char secondToken[1024]; + + /* 它奴件玉它及涩烂毛 曰 戈厌瞻 */ + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + /* 涩烂白央奶伙 潸 */ + if( NPC_Util_GetStrFromStrWithDelim( argstr, "conff", filename, sizeof( filename)) == NULL ) { + print("\n err:NOT FIND [conff] "); + return FALSE; + } + + sprintf( opfile, "%s/", getNpcdir( ) ); + strcat( opfile, filename); + + fp = fopen( opfile, "r"); + if( fp == NULL ) { + print( "windowman:file open error [%s]\n", opfile); + return FALSE; + } + + while( readflg == TRUE ) { + endflg = FALSE; + buttonendflg = TRUE; + buttonconfmode = FALSE; + selectnum = 0; + messagepos = 0; + winno = -1; + b_mode = -1; + errflg = FALSE; + + /* 赓渝祭 */ + w.windowno = -1; + w.windowtype = -1; + w.buttontype = -1; + w.takeitem = -1; + w.giveitem = -1; + w.message[0] = '\0'; + + for( i = 0; i < arraysizeof( buttonproc); i ++ ) { + buttonproc[i].use = FALSE; + buttonproc[i].checkhaveitem = -1; + buttonproc[i].checkhaveitemgotowin = -1; + buttonproc[i].checkdonthaveitem = -1; + buttonproc[i].checkdonthaveitemgotowin = -1; + buttonproc[i].warp = -1; + buttonproc[i].battle = -1; + buttonproc[i].gotowin = -1; + } + + while( 1) { + char buf[256]; + int ret; + if( !fgets( line, sizeof( line), fp)){ + readflg = FALSE; + break; + } + + linenum ++; + + /* 戊丢件玄反 骰 */ + if( line[0] == '#' || line[0] == '\n') continue; + /* 荼垫潸月 */ + chomp( line ); + + /* 垫毛帮溥允月 */ + /* 引内 tab 毛 " " 卞 五晶尹月 */ + replaceString( line, '\t' , ' ' ); + /* 燮 及旦矢□旦毛潸月[*/ + for( i = 0; i < strlen( line); i ++) { + if( line[i] != ' ' ) { + break; + } + strcpy( buf, &line[i]); + } + if( i != 0 ) strcpy( line, buf); + + /* delim "=" 匹 赓(1)及玄□弁件毛 月*/ + ret = getStringFromIndexWithDelim( line, "=", 1, firstToken, + sizeof( firstToken ) ); + if( ret == FALSE ){ + print( "Find error at %s in line %d. Ignore\n", + filename , linenum); + continue; + } + /* delim "=" 匹2 及玄□弁件毛 月*/ + ret = getStringFromIndexWithDelim( line, "=", 2, secondToken, + sizeof( secondToken ) ); + if( ret == FALSE ){ + print( "Find error at %s in line %d. Ignore\n", + filename , linenum); + continue; + } + + if( strcasecmp( firstToken, "winno") == 0 ) { + if( winno != -1 ) { + print( "windowman:已有winno却重新定义winno\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + readflg = FALSE; + break; + } + /* 它奴件玉它No毛忡绣 */ + winno = atoi( secondToken); + continue; + } + /* 它奴件玉它No 互瑁引匀化中卅中凛及垫反 骰允月 */ + if( winno == -1 ) { + print( "windowman:winno 尚未定义,资料却已设定。\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + readflg = FALSE; + errflg = FALSE; + break; + } + /* 它奴件玉它No 互域谯仄凶凛反椭瘀毛 戈[ + * 公木动陆反 骰允月 */ + if( (chkflg == FALSE && winno == windowno )|| + chkflg == TRUE) + { + if( buttonconfmode == TRUE ) { + if( strcasecmp( firstToken, "gotowin") == 0 ) { + buttonproc[b_mode].gotowin = atoi( secondToken); + } + else if( strcasecmp( firstToken, "checkhaveitem") == 0 ) { + buttonproc[b_mode].checkhaveitem = atoi( secondToken); + } + else if( strcasecmp( firstToken, "haveitemgotowin") == 0 ) { + buttonproc[b_mode].checkhaveitemgotowin = atoi( secondToken); + } + else if( strcasecmp( firstToken, "checkdonthaveitem") == 0 ) { + buttonproc[b_mode].checkdonthaveitem = atoi( secondToken); + } + else if( strcasecmp( firstToken, "donthaveitemgotowin") == 0 ) { + buttonproc[b_mode].checkdonthaveitemgotowin = atoi( secondToken); + } + else if( strcasecmp( firstToken, "endbutton") == 0 ) { + if( buttonproc[b_mode].gotowin == - 1 ) { + if( buttonproc[b_mode].checkhaveitem == -1 && + buttonproc[b_mode].checkdonthaveitem == -1) + { + errflg = TRUE; + } + else { + /* 升匀切井井凶匀吊分仃匹手涩烂今木化中木壬 */ + if( !((buttonproc[b_mode].checkhaveitem != -1 && + buttonproc[b_mode].checkhaveitemgotowin != -1) + || (buttonproc[b_mode].checkdonthaveitem != -1 && + buttonproc[b_mode].checkdonthaveitemgotowin != -1))) + { + errflg = TRUE; + } + } + } + + if( errflg == TRUE) { + print( "windowman: 找不到gotowin\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + readflg = FALSE; + errflg = TRUE; + break; + } + buttonproc[b_mode].use = TRUE; + buttonconfmode = FALSE; + buttonendflg = TRUE; + } + } + else { + + w.windowno = winno; + /* 它奴件玉它正奶皿及涩烂 */ + if( strcasecmp( firstToken, "wintype") == 0 ) { + w.windowtype = atoi( secondToken); + } + /* 示正件正奶皿及涩烂 */ + else if( strcasecmp( firstToken, "buttontype") == 0 ) { + w.buttontype = NPC_Windowman_restoreButtontype( secondToken); + } + /* getitem及涩烂 */ + else if( strcasecmp( firstToken, "takeitem") == 0 ) { + w.takeitem = atoi( secondToken); + } + /* giveitem及涩烂 */ + else if( strcasecmp( firstToken, "giveitem") == 0 ) { + w.giveitem = atoi( secondToken); + } + /* message及涩烂 */ + else if( strcasecmp( firstToken, "message") == 0 ) { + if( messagepos == 0 ) { + strcpy( w.message, secondToken); + messagepos = strlen( w.message); + } + else { + w.message[messagepos]='\n'; + messagepos++; + strcpy( &w.message[messagepos], secondToken); + messagepos+=strlen(secondToken); + } + } + /* 示正件毛瓷仄凶凛及涩烂 */ + else if( strcasecmp( firstToken, "okpressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 0; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "cancelpressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 1; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "yespressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 2; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "nopressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 3; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "prevpressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 4; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "nextpressed") == 0 ) { + buttonconfmode = TRUE; + b_mode = 5; + buttonendflg = FALSE; + } + else if( strcasecmp( firstToken, "selected") == 0 ) { + buttonconfmode = TRUE; + b_mode = 6 + selectnum; + buttonendflg = FALSE; + selectnum ++; + } + /* 涩烂蔽歹曰 */ + else if( strcasecmp( firstToken, "endwin") == 0 ) { + endflg = TRUE; + if( chkflg == FALSE) { + readflg = FALSE; + } + break; + } + else { + print( "windowman:设定是不可能的参数\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + } + } + } + else { + if( strcasecmp( firstToken, "endwin") == 0 ) { + winno = -1; + } + } + } + if( buttonendflg == FALSE) { + print( "windowman: 找不到endbutton\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + break; + } + if( winno != -1 ) { + if( w.windowtype == -1 ) { + print( "windowman: 找不到wintype\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + break; + } + if( w.buttontype == -1 ) { + print( "windowman: 找不到button\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + break; + } + if( strlen( w.message) == 0 ) { + print( "windowman: 找不到message\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + errflg = TRUE; + break; + } + } + } + fclose( fp); + + if( chkflg == FALSE && w.windowno == -1 ) { + print( "windowman: 找不到所指定的windowno\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + return FALSE; + } + if( winno != -1 && endflg == FALSE) { + print( "windowman: 找不到endwin\n"); + print( "filename:[%s] line[%d]\n", filename, linenum); + return FALSE; + } + if( errflg == TRUE) return FALSE; + + return TRUE; +} +/* + * buttontype=匹隙烂仄凶 侬 毛醒袄卞 晶允月[ + * + */ +/*static*/ int NPC_Windowman_restoreButtontype( char *data ) +{ + int ret = 0; + int rc; + int i; + char buff[1024]; + + for( i = 1; ; i ++ ) { + rc = getStringFromIndexWithDelim( data, "|", i, buff, + sizeof( buff ) ); + if( rc == FALSE) break; + if( strcasecmp( buff, "ok") == 0 ) { + ret |= WINDOW_BUTTONTYPE_OK; + } + else if( strcasecmp( buff, "cancel") == 0 ) { + ret |= WINDOW_BUTTONTYPE_CANCEL; + } + else if( strcasecmp( buff, "yes") == 0 ) { + ret |= WINDOW_BUTTONTYPE_YES; + } + else if( strcasecmp( buff, "no") == 0 ) { + ret |= WINDOW_BUTTONTYPE_NO; + } + else if( strcasecmp( buff, "prev") == 0 ) { + ret |= WINDOW_BUTTONTYPE_PREV; + } + else if( strcasecmp( buff, "next") == 0 ) { + ret |= WINDOW_BUTTONTYPE_NEXT; + } + } + if( ret == 0 ) { + ret = atoi( data); + } + return ret; +} diff --git a/gmsv/npc/npccreate.c b/gmsv/npc/npccreate.c new file mode 100644 index 0000000..81c7306 --- /dev/null +++ b/gmsv/npc/npccreate.c @@ -0,0 +1,626 @@ +#include "version.h" +#define __NPCCREATE__ + +#include +#include + +#include "common.h" +#include "npccreate.h" +#include "npctemplate.h" +#include "util.h" +#include "buf.h" +#include "readmap.h" +#include "char_data.h" +#include "handletime.h" +#include "configfile.h" + +INLINE int NPC_CHECKCREATEINDEX(int index) +{ + if( NPC_createnum <= index || index < 0 )return FALSE; + return TRUE; +} + +INLINE int NPC_CHECKCREATEINTINDEX( int index) +{ + if( NPC_CREATEINTNUM <= index || index < 0 )return FALSE; + return TRUE; +} + +INLINE int NPC_setCreateInt( int index , NPC_CREATEINT element, int data ) +{ + int buf; + buf = NPC_create[index].intdata[element]; + NPC_create[index].intdata[element] = data; + return buf; +} + +INLINE int NPC_getCreateInt( int index , NPC_CREATEINT element ) +{ + return NPC_create[index].intdata[element]; +} + + +BOOL NPC_initCreateArray( int createnum ) +{ + NPC_createnum = createnum; + NPC_create = (NPC_Create*)allocateMemory( sizeof( NPC_Create ) * NPC_createnum ); + + print( "开启大小:%d. 创建数量:%d.\n", sizeof( NPC_Create ), createnum); + if( NPC_create == NULL ){ + return FALSE; + } + NPC_create_readindex = 0; + return TRUE; +} + +void NPC_setDefaultNPCCreate( NPC_Create* cr ) +{ + if( cr == NULL )return; + + cr->intdata[NPC_CREATEFLOORID]=0; + cr->intdata[NPC_CREATEBORNLEFTUPX]=0; + cr->intdata[NPC_CREATEBORNLEFTUPY]=0; + cr->intdata[NPC_CREATEBORNRIGHTDOWNX]=0; + cr->intdata[NPC_CREATEBORNRIGHTDOWNY]=0; + cr->intdata[NPC_CREATEMOVELEFTUPX]=0; + cr->intdata[NPC_CREATEMOVELEFTUPY]=0; + cr->intdata[NPC_CREATEMOVERIGHTDOWNX]=0; + cr->intdata[NPC_CREATEMOVERIGHTDOWNY]=0; + + cr->intdata[NPC_CREATEDIR]=0; + //jeffrey 1231 +#ifdef _ADD_ACTION + cr->intdata[NPC_CREATEACTION] = 0; +#endif + cr->intdata[NPC_CREATEBASEIMAGENUMBER]=-1; + cr->intdata[NPC_CREATETIME]=0; + cr->intdata[NPC_CREATEBORNNUM]=0; + cr->intdata[NPC_CREATEENEMYNUM]=0; + cr->intdata[NPC_CREATEBOUNDARY]=1; + cr->intdata[NPC_CREATEIGNOREINVINCIBLE]=0; + + cr->intdata[NPC_CREATEDATE]=0; + + cr->intdata[NPC_CREATEFAMILY]=0; + + cr->chardata[NPC_CREATENAME].string[0]= '\0'; + + cr->workdata[NPC_CREATEWORKENEMYNUM]=0; + cr->workdata[NPC_CREATEWORKMAKESTARTSEC]=0; + cr->workdata[NPC_CREATEWORKMAKESTARTUSEC]=0; + cr->workdata[NPC_CREATEWORKNEVERMAKE]=0; + + + { + int i; + for( i=0 ; itemplateindex) ; i++ ){ + cr->templateindex[i] = -1; + cr->arg[i].string[0] = '\0'; + } + } +} + +BOOL NPC_IsNPCCreateFile( char* filename ) +{ + FILE* f; + char line1[128]; + char* ret; + + /* ~匹蔽月白央奶伙反卅仄卞允月 */ + if( filename == NULL + || strlen( filename ) < 1 + || filename[strlen(filename)-1] == '~' + || filename[0] == '#' + || strcmptail( filename, ".bak" ) == 0 )return FALSE; + + f= fopen( filename , "r" ); + if( f == NULL ) goto RETURNFALSE; + + ret = fgets( line1, sizeof( line1 ), f ); + if( ret == NULL )goto FCLOSERETURNFALSE; + + if( strcasecmp( NPC_CREATEFILEMAGIC, line1 ) == 0 ){ + fclose(f); + return TRUE; + } + +FCLOSERETURNFALSE: + fclose(f); +RETURNFALSE: + return FALSE; +} + +static int NPC_readCreateFile( char* filename ) +{ + FILE* f; + char line[512]; + int linenum=0; + int start=OFF; + NPC_Create cr; + int enemyreadindex=0; + + typedef struct tagPOINT + { + int x,y; + }POINT; + typedef struct tagREC + { + int w,h; + }REC; + POINT center[2]={{0,0},{0,0}}; /* born 互 0 匹 move 互 1 */ + REC wh[2] ={{0,0},{0,0}}; /* born 互 0 匹 move 互 1 */ + + POINT lu[2] ={{0,0},{0,0}}; /* born 互 0 匹 move 互 1 */ + POINT rd[2] ={{0,0},{0,0}}; /* born 互 0 匹 move 互 1 */ + + int defborn=FALSE; /* born 毛涩烂仄凶井升丹井 */ + int defmove=FALSE; /* move 毛涩烂仄凶井升丹井 */ + int deflurd[2]={FALSE,FALSE}; /* lu,rd 匹涩烂仄凶井升丹井 */ + char* ret; + + + if( NPC_create_readindex >= NPC_createnum ){ + print("创建超过配置缓冲\n" ); + print("配置缓冲数目是 %d\n",NPC_createnum); + print("没用文件 %s\n",filename); + return FALSE; + } + + NPC_setDefaultNPCCreate( &cr ); + + f= fopen( filename ,"r"); + if( f == NULL )return FALSE; + + ret = fgets( line, sizeof( line ), f ); + if( ret == NULL )goto FCLOSERETURNFALSE; + if( strcmp( NPC_CREATEFILEMAGIC, line ) != 0 ){ + print( "这不是一个create文件.\n" ); + goto FCLOSERETURNFALSE; + } + linenum = 1; + + while( fgets( line , sizeof( line ) , f ) ){ + + linenum++; + + if( line[0] == '#' )continue; /* comment */ + if( line[0] == '\n' )continue; /* none */ + chomp( line ); + + switch( line[0] ){ + case '{': + if( start == ON ){ + fprint( "Find {. But already START state. %s:%d\n", + filename, linenum); + fprint( "退出\n" ); + goto FCLOSERETURNFALSE; + + }else{ + NPC_setDefaultNPCCreate( &cr ); + start = ON; + } + break; + case '}': + if( start == ON ){ + int err = FALSE; + if( enemyreadindex == 0 ){ + err = TRUE; + print( "这不是遇敌数据 %s:%d\n", + filename,linenum); + }else if( MAP_IsThereSpecificFloorid( + cr.intdata[NPC_CREATEFLOORID]) == FALSE ){ + err = TRUE; + print( "地图ID号有毛病 %s:%d-floor:%d\n", + filename,linenum, cr.intdata[NPC_CREATEFLOORID]); + }else if( defborn == FALSE ){ + err = TRUE; + print( "这些不是 born 安装 %s:%d\n", + filename,linenum); + } + + if( err == FALSE ){ + cr.intdata[NPC_CREATEENEMYNUM] = enemyreadindex; + + if( deflurd[0] ){ + cr.intdata[NPC_CREATEBORNLEFTUPX] = + min(lu[0].x,rd[0].x); + cr.intdata[NPC_CREATEBORNRIGHTDOWNX] = + max(lu[0].x,rd[0].x); + cr.intdata[NPC_CREATEBORNLEFTUPY] = + min(lu[0].y,rd[0].y); + cr.intdata[NPC_CREATEBORNRIGHTDOWNY] = + max(lu[0].y,rd[0].y); + }else{ + cr.intdata[NPC_CREATEBORNLEFTUPX] = + center[0].x-wh[0].w/2; + cr.intdata[NPC_CREATEBORNRIGHTDOWNX] = + center[0].x+wh[0].w/2; + cr.intdata[NPC_CREATEBORNLEFTUPY] = + center[0].y-wh[0].h/2; + cr.intdata[NPC_CREATEBORNRIGHTDOWNY] = + center[0].y+wh[0].h/2; + } + /* 99/01/21 扎鼹 [0]-->[1]卞膜恳 */ + if( defmove ){ + if( deflurd[0] ){ + cr.intdata[NPC_CREATEMOVELEFTUPX] = + min(lu[1].x,rd[1].x); + cr.intdata[NPC_CREATEMOVERIGHTDOWNX] = + max(lu[1].x,rd[1].x); + cr.intdata[NPC_CREATEMOVELEFTUPY] = + min(lu[1].y,rd[1].y); + cr.intdata[NPC_CREATEMOVERIGHTDOWNY] = + max(lu[1].y,rd[1].y); + }else{ + cr.intdata[NPC_CREATEMOVELEFTUPX] = + center[1].x-wh[1].w/2; + cr.intdata[NPC_CREATEMOVERIGHTDOWNX] = + center[1].x+wh[1].w/2; + cr.intdata[NPC_CREATEMOVELEFTUPY] = + center[1].y-wh[1].h/2; + cr.intdata[NPC_CREATEMOVERIGHTDOWNY] = + center[1].y+wh[1].h/2; + } + + }else{ + /* born 毛戊疋□允月 */ + cr.intdata[NPC_CREATEMOVELEFTUPX] = + cr.intdata[NPC_CREATEBORNLEFTUPX]; + cr.intdata[NPC_CREATEMOVERIGHTDOWNX] = + cr.intdata[NPC_CREATEBORNRIGHTDOWNX]; + cr.intdata[NPC_CREATEMOVELEFTUPY] = + cr.intdata[NPC_CREATEBORNLEFTUPY]; + cr.intdata[NPC_CREATEMOVERIGHTDOWNY] = + cr.intdata[NPC_CREATEBORNRIGHTDOWNY]; + } + + memcpy( &NPC_create[NPC_create_readindex], &cr, + sizeof( NPC_Create ) ); + + + NPC_create_readindex++; + + if( NPC_create_readindex >= NPC_createnum ){ + print("创建超过配置缓冲\n" ); + print("配置创建文件数目 %d\n", + NPC_createnum); + print("没用文件:%s\n",filename); + goto FCLOSERETURNFALSE; + } + + } + /* 赓渝袄卞 仄化云仁 */ + NPC_setDefaultNPCCreate( &cr ); + enemyreadindex=0; + defborn=FALSE; + defmove=FALSE; + deflurd[0]=FALSE; + deflurd[1]=FALSE; + + start = OFF; + }else{ + fprint( "未解决 '}' at %s:%d\n",filename,linenum); + goto FCLOSERETURNFALSE; + } + break; + default: + { + + char firstToken[256]; + char secondToken[256]; + int ret; + ret = getStringFromIndexWithDelim( line, "=", 1, firstToken, + sizeof( firstToken ) ); + if( ret == FALSE ){ + print( "Find error at %s in line %d. Ignore\n", + filename , linenum); + break; + } + ret = getStringFromIndexWithDelim( line, "=", 2, secondToken, + sizeof( secondToken ) ); + if( ret == FALSE ){ + print( "Find error at %s in line %d. Ignore\n", + filename , linenum); + break; + } + + if( strcasecmp("floorid",firstToken) == 0 ){ + cr.intdata[NPC_CREATEFLOORID] = atoi(secondToken); + + }else if( strcasecmp("borncenter", firstToken) == 0 ){ + getFourIntsFromString(secondToken,¢er[0].x, + ¢er[0].y,&wh[0].w,&wh[0].h ); + defborn = TRUE; + }else if( strcasecmp("borncorner", firstToken) == 0 ){ + getFourIntsFromString(secondToken,&lu[0].x,&lu[0].y, + &rd[0].x,&rd[0].y ); + defborn = TRUE; + deflurd[0]=TRUE; + + }else if( strcasecmp("movecenter", firstToken) == 0 ){ + getFourIntsFromString(secondToken,¢er[1].x, + ¢er[1].y,&wh[1].w,&wh[1].h ); + defmove = TRUE; + }else if( strcasecmp("movecorner", firstToken) == 0 ){ + getFourIntsFromString(secondToken,&lu[1].x,&lu[1].y, + &rd[1].x,&rd[1].y ); + defmove = TRUE; + deflurd[1]=TRUE; + + }else if( strcasecmp("dir",firstToken) == 0 ){ + cr.intdata[NPC_CREATEDIR] = atoi( secondToken ); + + }else if( strcasecmp("graphicname",firstToken) == 0 ){ + cr.intdata[NPC_CREATEBASEIMAGENUMBER] + = CHAR_seekGraphicNumberFromString(secondToken); + + }else if( strcasecmp("name",firstToken) == 0 ){ + strcpysafe( cr.chardata[NPC_CREATENAME].string, + sizeof(cr.chardata[NPC_CREATENAME].string), + secondToken ); + + }else if( strcasecmp("time",firstToken) == 0 ){ + cr.intdata[NPC_CREATETIME] = atoi( secondToken ); + + }else if( strcasecmp("date",firstToken) == 0 ){ + cr.intdata[NPC_CREATEDATE] = atoi( secondToken ); + + }else if( strcasecmp("createnum",firstToken) == 0 ){ + cr.intdata[NPC_CREATEBORNNUM] = atoi( secondToken ); + + }else if( strcasecmp( "boundary", firstToken) == 0 ){ + cr.intdata[NPC_CREATEBOUNDARY] = atoi( secondToken ); + + }else if( strcasecmp( "ignoreinvincible", firstToken) == 0 ){ + cr.intdata[NPC_CREATEIGNOREINVINCIBLE] = atoi( secondToken ); + + //jeffrey 1231 +#ifdef _ADD_ACTION + }else if( strcasecmp( "action", firstToken) == 0 ){ + cr.intdata[NPC_CREATEACTION] = atoi( secondToken ); +#endif + // Robin 0731 + }else if( strcasecmp( "family", firstToken) == 0 ){ + cr.intdata[NPC_CREATEFAMILY] = atoi( secondToken ); + + }else if( strcasecmp("enemy", firstToken) == 0 ){ + /* 娄醒毛 六月方丹卞允月 */ + int templateindex; + char enemyname[64]; + + /* 雁钗瞬民尼永弁 */ + if( enemyreadindex <= arraysizeof(cr.templateindex) ) + /* OK */ + ; + else + break; + + /* secondToken 毛 侬 卞坌荸允月 */ + getStringFromIndexWithDelim(secondToken,"|",1,enemyname, + sizeof(enemyname) ); + templateindex= NPC_templateGetTemplateIndex(enemyname); + if( templateindex != -1 ){ + cr.templateindex[enemyreadindex] = templateindex; + { + /* 娄醒毛质 允月 */ + char tmp[2]; + int ret; + ret = getStringFromIndexWithDelim( secondToken, + "|",2,tmp, + sizeof(tmp) ); + if( ret == FALSE ) + cr.arg[enemyreadindex].string[0] = '\0'; + else + strcpysafe( cr.arg[enemyreadindex].string, + sizeof( cr.arg[enemyreadindex]. + string ), + secondToken+strlen(enemyname)+1 ); + } + enemyreadindex++; + }else + fprint( "没有这种模块:\n[%s(%d)%s] enemy:%s\n", + filename ,linenum,secondToken, enemyname); + }else{ + fprint( "没有这种登陆 %s %s:%d\n",firstToken,filename, + linenum ); + } + } + } + } + + fclose(f); + return TRUE; + +FCLOSERETURNFALSE: + fclose(f); + return FALSE; +} + +BOOL NPC_readNPCCreateFiles( char* topdirectory ,int createsize) +{ + STRING64 *filenames; + int filenum; + int i; + filenames = (STRING64 *)allocateMemory( sizeof( STRING64 ) * + (int)getFilesearchnum( ) ); + if( filenames == NULL ){ + print( "读取NPC创建文件... 内存错误\n" ); + return FALSE; + } + filenum = rgetFileName( topdirectory ,filenames ,getFilesearchnum( ) ); + if( filenum == -1 ){ + freeMemory( filenames ); + return FALSE; + } + if( filenum >= getFilesearchnum( ) ){ + print( "文件搜索数目失败 %d\n", getFilesearchnum( ) ); + while( 1 ); + } + if( !NPC_initCreateArray( createsize ) ){ + fprint( "开启创建数组错误\n" ); + freeMemory( filenames ); + return FALSE; + } + print( "读取NPC创建文件..." ); + for( i = 0 ; i < filenum ; i ++ ) + if( NPC_IsNPCCreateFile( filenames[i].string )) + if( NPC_readCreateFile( filenames[i].string ) == -1 ) + break; + print( "正确创建NPC %d ..." , NPC_create_readindex ); + NPC_createnum=NPC_create_readindex; +#ifdef DEBUG + /* 99/4/8 By Kawata csv溥挚卞仄化支月 */ + print( "Npc_Create's\n"); + for( i = 0 ; i < NPC_createnum ; i ++ ){ + int j; + /*print( "NPC_create[%d]:\n", i);*/ + print( "%d,", i); + for( j = 0 ; j < NPC_CREATECHARNUM ; j ++ ) + print("%s," , NPC_create[i].chardata[j].string ); + /*print( "\tIntdata\t" );*/ + for( j = 0 ; j < NPC_CREATEINTNUM ; j ++ ) + print("%d," , NPC_create[i].intdata[j] ); + /***print("\n" ); + print( "\tChardata\t" );***/ + for( j = 0 ; j < NPC_create[i].intdata[NPC_CREATEENEMYNUM]; j ++ ) + print("%d" , NPC_create[i].templateindex[j] ); + /*print("\n" );*/ + print("\n" ); + } +#endif /*DEBUG*/ + + freeMemory( filenames ); + return TRUE; +} + + + +/*------------------------------------------------------------ + * createindex 井日 boundary 互涩烂今木化中月井升丹井毛苇月 + * 娄醒 + * createindex int create及奶件犯永弁旦 + * 忒曰袄 + * 涩烂今木化中月 TRUE(1) + * 涩烂今木化中卅中 FALSE(0) + ------------------------------------------------------------*/ +BOOL NPC_isBoundarySet( int createindex ) +{ + if( NPC_CHECKCREATEINDEX(createindex) == FALSE )return FALSE; + return NPC_create[createindex].intdata[NPC_CREATEBOUNDARY]; +} +/*------------------------------------------------------------ + * createindex 井日 仃月 区及RECT 毛菲户月[ + * 娄醒 + * createindex int 件皿伊□玄及奶件犯永弁旦 + * r RECT* 袄毛熬仃午月RECT 及禾奶件正 + * 忒曰袄 + * 岳 TRUE(1) + * 撩 FALSE(0) + ------------------------------------------------------------*/ +BOOL NPC_createGetRECT( int createindex,RECT* r ) +{ + if( NPC_CHECKCREATEINDEX(createindex) == FALSE )return FALSE; + + r->x = NPC_create[createindex].intdata[NPC_CREATEMOVELEFTUPX]; + r->y = NPC_create[createindex].intdata[NPC_CREATEMOVELEFTUPY]; + r->width + = NPC_create[createindex].intdata[NPC_CREATEMOVERIGHTDOWNX] + - NPC_create[createindex].intdata[NPC_CREATEMOVELEFTUPX]; + r->height + = NPC_create[createindex].intdata[NPC_CREATEMOVERIGHTDOWNY] + - NPC_create[createindex].intdata[NPC_CREATEMOVELEFTUPY]; + return TRUE; +} + + + +/*------------------------------------------------------------ + * 凛棉井日综匀化手中中井升丹井民尼永弁允月[ + * 娄醒 + * cindex int 奶件犯永弁旦 + * 忒曰袄 + * BOOL 综匀化中中桦宁 TRUE(1) + * BOOL 综匀化中仃卅中桦宁 FALSE(0) + ------------------------------------------------------------*/ +BOOL NPC_createCheckGenerateFromTime( int cindex ) +{ + struct timeval old; + if( !NPC_CHECKCREATEINDEX(cindex) ) + return FALSE; + + if( NPC_create[cindex].workdata[NPC_CREATEWORKNEVERMAKE] ) + return FALSE; + + if( NPC_create[cindex].intdata[NPC_CREATEBORNNUM] + <= NPC_create[cindex].workdata[NPC_CREATEWORKENEMYNUM] ) + return FALSE; + + if( NPC_create[cindex].intdata[NPC_CREATETIME] < 0 )return FALSE; + old.tv_sec = NPC_create[cindex].workdata[NPC_CREATEWORKMAKESTARTSEC]; + old.tv_usec= NPC_create[cindex].workdata[NPC_CREATEWORKMAKESTARTUSEC]; + + if( time_diff_us( NowTime , old ) <= + NPC_create[cindex].intdata[NPC_CREATETIME]*1000 ) + return FALSE; + + return TRUE; +} + + + + +/*------------------------------------------------------------ + * 综月凛及凛棉及涩烂毛赓渝祭允月[ + * 娄醒 + * tindex int 奶件犯永弁旦 + * 忒曰袄 + * 卅仄 + ------------------------------------------------------------*/ +void NPC_createInitTime( int index ) +{ + /* 综月仪卞卅匀凶井日袄毛涩烂 */ + NPC_create[index].workdata[NPC_CREATEWORKMAKESTARTSEC] = + NowTime.tv_sec; + NPC_create[index].workdata[NPC_CREATEWORKMAKESTARTUSEC] = + NowTime.tv_usec; +} +/*------------------------------------------------------------ + * 衬毛综匀凶 卞市它件玄醒毛 支允楮醒 + * 娄醒 + * index int 奶件犯永弁旦 + * 忒曰袄 + * 卅仄 + ------------------------------------------------------------*/ +void NPC_createIncreaseEnemynum( int index ) +{ + if( !NPC_CHECKCREATEINDEX(index) )return; + NPC_create[index].workdata[NPC_CREATEWORKENEMYNUM] ++; +} +/*------------------------------------------------------------ + * 衬互韶氏匹市它件玄醒毛蛹日允楮醒 + * 娄醒 + * index int 奶件犯永弁旦 + * 忒曰袄 + * 卅仄 + ------------------------------------------------------------*/ +void NPC_createDecreaseEnemynum( int index ) +{ + if( !NPC_CHECKCREATEINDEX(index) )return; + NPC_create[index].workdata[NPC_CREATEWORKENEMYNUM] --; +} +/*------------------------------------------------------------ + * 市它件玄醒互漆 井譬屯月楮醒 + * 娄醒 + * index int 奶件犯永弁旦 + * 忒曰袄 + * TRUE:MAX FALSE:啜丹 + ------------------------------------------------------------*/ +BOOL NPC_createCheckMaxEnemynum( int index ) +{ + + if( NPC_create[index].intdata[NPC_CREATEBORNNUM] + <= NPC_create[index].workdata[NPC_CREATEWORKENEMYNUM] ) + return TRUE; + else + return FALSE; +} diff --git a/gmsv/npc/npcgen.c b/gmsv/npc/npcgen.c new file mode 100644 index 0000000..8ad9039 --- /dev/null +++ b/gmsv/npc/npcgen.c @@ -0,0 +1,387 @@ +#include "version.h" +#include + +#include "common.h" +#include "npccreate.h" +#include "npctemplate.h" +#include "char.h" +#include "char_data.h" +#include "buf.h" +#include "object.h" +#include "readmap.h" +#include "item.h" +#include "handletime.h" +#include "map_deal.h" + +typedef struct tagNPC_searchPoint +{ + int floor; + int x; + int y; +}NPC_searchPoint; + + +/* 窒荚NPC毛综月井 */ +#define NPC_CREATECHALLENGETIME 1 +int all_nosee = 0; /* ㄠ及凛{蝈化及衬毛 no_see 卞 */ +int all_nobody = 0; /* ㄠ及凛{蝈化及衬毛 no_body 卞 */ +int one_loop_born = 1; /* ㄠ伙□皿匹 嫖戏心请允醒 oneloop_born */ + +/*------------------------------------------------------------ + * 衬毛丹心分允桦赭毛瑁烂允月 + * 娄醒 + * cr NPC_Create* 甄 及汔互瑁匀化中月NPC_Create及禾奶件正 + * nobody int 1 及凛反簿手中卅中凛卞勾仁月 + * (簿井中化手综月) + * 0 及凛反簿手中卅中凛反综日卅中[ + * (簿井中凶凛及心综月) + * nosee int 1 及凛反皿伊奶乩□及骰钗及 匹手综月[ + * 0 及凛反皿伊奶乩□及骰钗及陆匹综月[ + * point NPC_searchPoint* 请蜇今六月桦赭毛医 允月 + * isflying BOOL 氏匹中月井升丹井[ 氏匹中月卅日 TRUE 匹 + * 请蜇匏 氏及及穴永皿午及癫曰 烂 + * 毛仄卅仁卅月 + * 忒曰袄 + * 综木月凛反 TRUE + * 综木卅中凛反 FALSE + ------------------------------------------------------------*/ +static BOOL NPC_searchCreatePoint( NPC_Create* cr,int nobody,int nosee, + NPC_searchPoint* point, BOOL isflying ) +{ + int floor=cr->intdata[NPC_CREATEFLOORID]; + int x = cr->intdata[NPC_CREATEBORNLEFTUPX]; + int y = cr->intdata[NPC_CREATEBORNLEFTUPY]; + int width; + int height; + int area; + int loop; + BOOL ret = FALSE; + int i, j; + + width = cr->intdata[NPC_CREATEBORNRIGHTDOWNX] + - cr->intdata[NPC_CREATEBORNLEFTUPX] + 1; + height = cr->intdata[NPC_CREATEBORNRIGHTDOWNY] + - cr->intdata[NPC_CREATEBORNLEFTUPY] + 1; + area = width * height; + if( nobody == 0 && all_nobody == 0 ) { + BOOL found = FALSE; + for( i = x ; i <= x +width && found == FALSE; i ++ ) { + for( j = y; j <= y + height && found == FALSE; j ++ ) { + OBJECT object; + for( object = MAP_getTopObj( floor, i,j); + object; + object = NEXT_OBJECT(object) ) + { + int objindex = GET_OBJINDEX( object); + if( OBJECT_getType(objindex) == OBJTYPE_CHARA ){ + if( CHAR_getInt( OBJECT_getIndex(objindex), + CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ) + { + found = TRUE; + break; + } + } + } + } + } + if( found == FALSE ) { + return( FALSE); + } + } + for( loop=0 ; loopintdata[NPC_CREATEIGNOREINVINCIBLE] == 0 + && CHAR_isInvincibleArea( floor,crx,cry ) ){ + continue; + } + if( nosee == 0 && all_nosee == 0 ) { + BOOL found = FALSE; + for( i = crx - CHAR_DEFAULTSEESIZ/2 ; + i <= crx +CHAR_DEFAULTSEESIZ/2 && found == FALSE ; i ++ ) + { + for( j = cry - CHAR_DEFAULTSEESIZ/2; + j <= cry + CHAR_DEFAULTSEESIZ/2 && found == FALSE; + j ++ ) + { + OBJECT object; + for( object = MAP_getTopObj( floor, i,j); + object; + object = NEXT_OBJECT(object) ) + { + int objindex = GET_OBJINDEX( object); + if( OBJECT_getType(objindex) == OBJTYPE_CHARA ){ + if( CHAR_getInt( OBJECT_getIndex(objindex), + CHAR_WHICHTYPE ) + == CHAR_TYPEPLAYER ) + { + found = TRUE; + break; + } + } + } + } + } + if( found == TRUE ){ + return FALSE; + } + } + if( MAP_walkAbleFromPoint( floor,crx,cry,isflying ) == TRUE ){ + point->floor = cr->intdata[NPC_CREATEFLOORID]; + point->x = crx; + point->y = cry; + ret = TRUE; + break; + }else{ + } + } + + return( ret ); +} + + +typedef struct tagNPC_Correspondfunction +{ + int template; + int ch; +}NPC_Correspondfunction; + +static NPC_Correspondfunction correspondfunction[]={ + { NPC_TEMPLATEINITFUNC, CHAR_INITFUNC }, + { NPC_TEMPLATEWALKPREFUNC, CHAR_WALKPREFUNC }, + { NPC_TEMPLATEWALKPOSTFUNC, CHAR_WALKPOSTFUNC }, + { NPC_TEMPLATEPREOVERFUNC, CHAR_PREOVERFUNC }, + { NPC_TEMPLATEPOSTOVERFUNC, CHAR_POSTOVERFUNC }, + { NPC_TEMPLATEWATCHFUNC, CHAR_WATCHFUNC }, + { NPC_TEMPLATELOOPFUNC, CHAR_LOOPFUNC }, + { NPC_TEMPLATETALKEDFUNC, CHAR_TALKEDFUNC }, + { NPC_TEMPLATEDYINGFUNC, CHAR_DYINGFUNC }, + { NPC_TEMPLATEPREATTACKEDFUNC,CHAR_PREATTACKEDFUNC }, + { NPC_TEMPLATEPOSTATTACKEDFUNC, CHAR_POSTATTACKEDFUNC }, + { NPC_TEMPLATEOFFFUNC, CHAR_OFFFUNC }, + { NPC_TEMPLATELOOKEDFUNC, CHAR_LOOKEDFUNC }, + { NPC_TEMPLATEITEMPUTFUNC, CHAR_ITEMPUTFUNC }, + { NPC_TEMPLATESPECIALTALKEDFUNC, CHAR_SPECIALTALKEDFUNC}, + { NPC_TEMPLATEWINDOWTALKEDFUNC, CHAR_WINDOWTALKEDFUNC}, +#ifdef _USER_CHARLOOPS + { NPC_TEMPLATELOOPFUNCTEMP1, CHAR_LOOPFUNCTEMP1}, + { NPC_TEMPLATELOOPFUNCTEMP2, CHAR_LOOPFUNCTEMP2}, + { NPC_TEMPLATEBATTLEPROPERTY, CHAR_BATTLEPROPERTY}, +#endif +}; +/*------------------------------------------------------------ + * 楮醒戊疋□允月 + * 娄醒 + * ch Char* 平乓仿犯□正 + * temp NPC_template* 件皿伊□玄及禾奶件正□ + * 忒曰袄 + * 卅仄 + ------------------------------------------------------------*/ +static void NPC_copyFunction( Char* ch, NPC_Template* temp ) +{ + int i; + for( i=0 ; ichardata[correspondfunction[i].template].string[0] != '\0' ) + strcpysafe( ch->charfunctable[correspondfunction[i].ch].string, + sizeof(ch->charfunctable[correspondfunction[i].ch].string), + temp->chardata[correspondfunction[i].template].string); +} + +static BOOL NPC_generateNPC( int createindex, int createtemplateindex ) +{ + Char one; + NPC_searchPoint sp; + int i; + NPC_Template* template; + NPC_Create* cr; + + if( NPC_CHECKCREATEINDEX(createindex) + && 0 <= createtemplateindex + && createtemplateindex < arraysizeof(NPC_create[createindex].templateindex ) + && NPC_CHECKTEMPLATEINDEX( NPC_create[createindex].templateindex[createtemplateindex])){ + cr = &NPC_create[createindex]; + template = &NPC_template[NPC_create[createindex]. + templateindex[createtemplateindex]]; + }else{ + return FALSE; + } + if( NPC_searchCreatePoint( cr, + template->intdata[NPC_TEMPLATEMAKEATNOBODY], + template->intdata[NPC_TEMPLATEMAKEATNOSEE], &sp, + template->intdata[NPC_TEMPLATEISFLYING]) == FALSE ){ + return FALSE; + } + if( CHAR_getDefaultChar( &one, template->intdata[NPC_TEMPLATETYPE] ) == FALSE ){ + return FALSE; + } + one.data[CHAR_FLOOR] = sp.floor; + one.data[CHAR_X] = sp.x; + one.data[CHAR_Y] = sp.y; + one.data[CHAR_DIR] = cr->intdata[NPC_CREATEDIR]; +#ifdef _ADD_ACTION + one.data[CHAR_ACTIONSTYLE] = cr->intdata[NPC_CREATEACTION]; +#endif + + one.data[CHAR_BASEBASEIMAGENUMBER] = one.data[CHAR_BASEIMAGENUMBER] + = template->intdata[NPC_TEMPLATEIMAGENUMBER]; + if( cr->intdata[NPC_CREATEBASEIMAGENUMBER] != -1 ) + one.data[CHAR_BASEBASEIMAGENUMBER] + = one.data[CHAR_BASEIMAGENUMBER] + = cr->intdata[NPC_CREATEBASEIMAGENUMBER]; + + strcpysafe(one.string[CHAR_NAME].string, + sizeof(one.string[CHAR_NAME].string), + template->chardata[NPC_TEMPLATECHARNAME].string); + + + if( cr->chardata[NPC_CREATENAME].string[0] != '\0' ){ + strcpysafe(one.string[CHAR_NAME].string, + sizeof(one.string[CHAR_NAME].string), + cr->chardata[NPC_CREATENAME].string); + } + + // Robin 0731 + one.data[CHAR_FMINDEX] = cr->intdata[NPC_CREATEFAMILY]; + NPC_copyFunctionSetToChar( template-> + intdata[NPC_TEMPLATEFUNCTIONINDEX], + &one ); + NPC_copyFunction( &one, template ); + one.data[CHAR_LOOPINTERVAL] = template-> + intdata[NPC_TEMPLATELOOPFUNCTIME]; + if( cr->arg[createtemplateindex].string[0] != '\0' ){ + strcpysafe( one.string[CHAR_NPCARGUMENT].string, + sizeof(one.string[CHAR_NPCARGUMENT].string), + cr->arg[createtemplateindex].string ); + }else{ + one.string[CHAR_NPCARGUMENT].string[0] = '\0'; + } + one.data[CHAR_WHICHTYPE] = CHAR_TYPEENEMY; + one.data[CHAR_NPCCREATEINDEX] = createindex; + { + static struct NPC_Paramtable + { + int templateindex; + int charadataindex; + }paramtbl[]={ + { NPC_TEMPLATEMINMP, CHAR_MAXMP }, + { NPC_TEMPLATEMINSTR, CHAR_STR }, + { NPC_TEMPLATEMINTOUGH, CHAR_TOUGH }, + + + }; + for( i=0 ; irandomdata[ + paramtbl[i].templateindex] ); + one.data[paramtbl[i].charadataindex] + = one.data[paramtbl[i].charadataindex] + + template->intdata[paramtbl[i].templateindex] + + randomvalue; + } + one.data[CHAR_MP] = one.data[CHAR_MAXMP]; + } + { + int itemindex=CHAR_STARTITEMARRAY; + for( i = 0 ; i < template->intdata[NPC_TEMPLATEITEMNUM] ; i ++ ){ + if( RAND(0,32767) <= template->haveitem[i].haverate ){ + if( template->haveitem[i].itemnumber == -1 + && template->haveitem[i].havenum > 0 ){ + int randomvalue = template->haveitem[i].havenum; + randomvalue *= (RAND(90,110))/100.0; + one.data[CHAR_GOLD] = min( CHAR_MAXGOLDHAVE, randomvalue ); + }else if( itemindex+i < CHAR_MAXITEMHAVE ){ + one.indexOfExistItems[itemindex+i] = + ITEM_makeItemAndRegist(template->haveitem[i] + .itemnumber); + } + } + } + } + + { + int charaindex; + int objindex; + Object obj; + charaindex = CHAR_initCharOneArray( &one ); + if( charaindex == -1 ){ + CHAR_endCharData( &one ); + return FALSE; + } + if( template->intdata[NPC_TEMPLATEISFLYING] ) + CHAR_setFlg(charaindex, CHAR_ISFLYING, 1 ); + + obj.type = OBJTYPE_CHARA; + obj.index= charaindex; + obj.x = CHAR_getInt(charaindex,CHAR_X); + obj.y = CHAR_getInt(charaindex,CHAR_Y); + obj.floor = CHAR_getInt(charaindex,CHAR_FLOOR); + objindex = initObjectOne( &obj ); + if( objindex == -1 ){ + CHAR_endCharOneArray( charaindex ); + return FALSE; + }else{ + } + CHAR_setWorkInt( charaindex,CHAR_WORKOBJINDEX,objindex ); +#ifdef _ADD_ACTION +//CHAR_WORKACTION + CHAR_setWorkInt( charaindex, CHAR_WORKACTION, + CHAR_getInt( charaindex, CHAR_ACTIONSTYLE ) ); + + CHAR_sendWatchEvent( objindex, CHAR_getWorkInt( charaindex, CHAR_WORKACTION) + ,NULL,0,TRUE); +#else + CHAR_sendWatchEvent(objindex,CHAR_ACTSTAND,NULL,0,TRUE); +#endif + CHAR_complianceParameter( charaindex ); + } + + return TRUE; +} + +void NPC_generateLoop( BOOL checkall ) +{ + int i,j; + int CreateOk=0; + int enemynum ; + static int createcount = 0; /* create及窒 井日蔺爵允月井 */ + static struct timeval _store_npc_generateloop_time; + if( checkall == FALSE) { + if( time_diff_us( NowTime, _store_npc_generateloop_time ) < (1000*1000)){ + return; + } else { + _store_npc_generateloop_time = NowTime; + } + } + + for( i=0 ; i < NPC_createnum ; i++ ){ + if( createcount >= NPC_createnum ) createcount = 0; + enemynum = NPC_getCreateInt( createcount, NPC_CREATEENEMYNUM ); + for( j = 0 ; j < enemynum ; j ++ ){ + if( NPC_createCheckGenerateFromTime(createcount) == TRUE ){ + CreateOk ++; + NPC_createInitTime(createcount); + if( NPC_generateNPC(createcount,j) == TRUE ){ + NPC_createIncreaseEnemynum(createcount); + }else{ + } + } + } + createcount ++; + if( checkall == FALSE && CreateOk >= one_loop_born ){ + break; + } + } +} + diff --git a/gmsv/npc/npctemplate.c b/gmsv/npc/npctemplate.c new file mode 100644 index 0000000..9055d37 --- /dev/null +++ b/gmsv/npc/npctemplate.c @@ -0,0 +1,1131 @@ +#include "version.h" +#define __NPCTEMPLATE__ + +#include +#include + +#include "common.h" +#include "npctemplate.h" +#include "buf.h" +#include "char_data.h" +#include "util.h" +#include "handletime.h" +#include "item.h" +#include "anim_tbl.h" +#include "configfile.h" + +/*涩烂毛棵签卞允月凶户卞楮醒烂聒本永玄毛综月 */ +typedef struct tagFunctionNameSet +{ + char* id; + char* initfunc; + char* walkprefunc; + char* walkpostfunc; + char* preoverfunc; + char* postoverfunc; + char* watchfunc; + char* loopfunc; + char* dyingfunc; + char* talkedfunc; + char* preattackedfunc; + char* postattackedfunc; + char* offfunc; + char* lookedfunc; + char* itemputfunc; + char* specialtalkedfunc; + char* windowtalkedfunc; +}FunctionNameSet; + + +static FunctionNameSet functionSet[]={ + + { "Sample" , "", "", "", "", "", "", "SampleLoop", + "SampleDying" ,"","", "","","","","",""}, + + /* 玉失 */ + { "Door" , "DoorInit" , "","", + "","DoorPostOver","DoorWatch","", + "","DoorTalked","", "", + "DoorOff","DoorLooked","","",""}, + + /* 饕 */ + { "SimpleShop" ,"SimpleShopInit","","", + "","","","","", + "SimpleShopTalked" , "","", + "","","" ,"SimpleShopSpecialTalked" ,""}, + + /* 丢永本□斥 */ + { "Msg" , "MsgInit" , "","", + "","","","", + "","","", "", + "","MsgLooked","","",""}, + + /* 伐□皿札□件 */ + { "Warp","WarpInit","","", + "","","","", + "","","","", + "","", "","",""}, + + /* 及谛 */ + { "TownPeople" ,"TownPeopleInit","","", + "","","","", + "", "TownPeopleTalked" ,"","", + "","","","",""}, + + /* 赢 */ + { "Oldman","OldmanInit","","", + "","","","", + "","OldmanTalked","","", + "","", "","",""}, + + + /* 本□皮禾奶件玄 */ + { "SavePoint","SavePointInit","","", + "","","","", + "","SavePointTalked","","", + "","", "","","SavePointWindowTalked"}, + + /* 甲□仿□ */ + { "Healer","HealerInit","","", + "","","","", + "","HealerTalked","","", + "","", "","",""}, + + /* 家族Healer add code by shan */ + { "FmHealer","FmHealerInit","","", + "","","","", + "","FmHealerTalked","","", + "","", "","",""}, + + /* 白虎给予者 add code by shan */ + { "PetMaker","PetMakerInit","","", + "","","","", + "","PetMakerTalked","","", + "","", "","",""}, + + /* 贿曰 */ + { "StoryTeller","StoryTellerInit","","", + "","","","", + "","StoryTellerTalked","","", + "","", "","",""}, + + /* 尕 遣盒 */ + { "RoomAdminNew","RoomAdminNewInit","","", + "","","","RoomAdminNewLoop", + "","RoomAdminNewTalked","","", + "","", "","",""}, + + /* 鳗蜕 */ + {"Dengon", + "DengonInit", "", "", "", "", "", "", "", "", + "", "", "", "DengonLooked", "", "","DengonWindowTalked"}, + + /* 家族留言板 add code by shan */ + {"FmDengon", + "FmDengonInit", "", "", "", "", "", "", "", "", + "", "", "", "FmDengonLooked", "", "","FmDengonWindowTalked"}, + + /*煽沓馨笛失奶 丞宁岳*/ + { "ItemCompo" , "ItemCompoInit", "", "", + "", "", "", "", + "" ,"ItemCompoTalked","","" + ,"","","" , "",""}, + + /* 裔烂衬 */ + { "NPCEnemy","NPCEnemyInit","","", + "","","NPCEnemyWatch","", + "","NPCEnemyTalked","","", + "","", "","","NPCEnemyWindowTalked"}, + + /* 失弁扑亦件楝 */ + { "Action","ActionInit","","", + "","","ActionWatch","", + "","ActionTalked","","", + "","", "","",""}, + + /* 迕它奴件玉它NPC */ + { "Windowman","WindowmanInit","","", + "","","","", + "","WindowmanTalked","","", + "","WindowmanLooked", "","","WindowmanWindowTalked"}, + + /*windowhealer */ + { "WindowHealer","WindowHealerInit","","", + "","","","", + "","WindowHealerTalked","","", + "","WindowHealerLooked", "","","WindowHealerWindowTalked"}, + + + /* ItemShop */ + { "ItemShop","ItemShopInit","","", + "","","","", + "","ItemShopTalked","","", + "","", "","","ItemShopWindowTalked"}, + + {"Sysinfo", + "SysinfoInit", "", "", + "", "", "", "SysinfoLoop", + "", "SysinfoTalked","", "", + "", "", "", "",""}, + + /* Duel仿件平件弘 憎NPC */ + { "Duelranking","DuelrankingInit","","", + "","","", +#ifdef _DEATH_CONTEND + "Duelrankingloop", +#else + "", +#endif + "","","","", + "","DuelrankingLooked", "","","DuelrankingWindowTalked"}, + + + /* PetSkillShop */ + { "PetSkillShop","PetSkillShopInit","","", + "","","","", + "","PetSkillShopTalked","","", + "","", "","","PetSkillShopWindowTalked"}, + + /* PetShop */ + { "PetShop","PetShopInit","","", + "","","","", + "","PetShopTalked","","", + "","", "","","PetShopWindowTalked"}, + + + /* SignBoard */ + { "SignBoard","SignBoardInit","","", + "","","","", + "","","","", + "","SignBoardLooked", "","","SignBoardWindowTalked"}, + + + /* WarpMan */ + { "WarpMan","WarpManInit","","", + "","","WarpManWatch","WarpManLoop", + "","WarpManTalked","","", + "","", "","","WarpManWindowTalked"}, + + + /* ExChangeman */ + { "ExChangeMan","ExChangeManInit","","", + "","","","", + "","ExChangeManTalked","","", + "","", "","","ExChangeManWindowTalked"}, + + /* timeman */ + { "TimeMan","TimeManInit","","", + "","","TimeManWatch","", + "","TimeManTalked","","", + "","", "","",""}, + + /* 示犯奴仿件必□斥 */ + { "BodyLan","BodyLanInit","","", + "","","BodyLanWatch","", + "","BodyLanTalked","","", + "","", "","","BodyLanWindowTalked"}, + + /* 示犯奴仿件必□斥 */ + { "Mic","MicInit","","", + "","","","", + "","MicTalked","","", + "","", "","",""}, + + /* 仿永平□穴件 */ + { "LuckyMan","LuckyManInit","","", + "","","","", + "","LuckyManTalked","","", + "","", "","","LuckyManWindowTalked"}, + + /* 穴件乒旦田旦楝 */ + { "Bus","BusInit","","", + "","","","BusLoop", + "","BusTalked","","", + "","", "","",""}, + + /* 加美航空 */ // Arminius 7.7 Ariplane + { "Airplane","AirInit","","", + "","","","AirLoop", + "","AirTalked","","", + "","", "","",""}, + + /* 楝 */ + { "Charm","CharmInit","","", + "","","","", + "","CharmTalked","","", + "","", "","","CharmWindowTalked"}, + + /* 弁奶术楝 */ + { "Quiz","QuizInit","","", + "","","","", + "","QuizTalked","","", + "","", "","","QuizWindowTalked"}, + + /* 失奶 丞 曰盒今氏 */ + { "PoolItemShop","PoolItemShopInit","","", + "","","","PoolItemShopLoop", + "","PoolItemShopTalked","","", + "","", "","","PoolItemShopWindowTalked"}, + + /* 奶矛件玄民尼永弁穴件 */ + { "CheckMan","CheckManInit","","", + "","","","", + "","CheckManTalked","","", + "","", "","","CheckManWindowTalked"}, + + /* 元扎氏仃氏楝 */ + { "Janken","JankenInit","","", + "","","","", + "","JankenTalked","","", + "","", "","","JankenWindowTalked"}, + + /* 鳖戏谛 */ + { "Transmigration","TransmigrationInit","","", + "","","","", + "","TransmigrationTalked","","", + "","", "","","TransmigrationWindowTalked"}, + + /* Family Man */ + { "Familyman","FamilymanInit","","", + "","","","", + "","FamilymanTalked","","", + "","FamilymanLooked", "","","FamilymanWindowTalked"}, + + /* CoolFish: Family Warp Man 2001/6/6 */ + { "FMWarpMan","FMWarpManInit","","", + "","","","FMWarpManLoop", + "","FMWarpManTalked","","", + "","", "","","FMWarpManWindowTalked"}, + + /* CoolFish: Family PK Man 2001/7/4 */ + { "FMPKMan","FMPKManInit","","", + "","","","", + "","FMPKManTalked","","", + "","", "","","FMPKManWindowTalked"}, + + /* CoolFish: Family PK CallMan 2001/7/13 */ + { "FMPKCallMan","FMPKCallManInit","","", + "","","","", + "","FMPKCallManTalked","","", + "","", "","","FMPKCallManWindowTalked"}, + + /* Bank Man */ + { "Bankman","BankmanInit","","", + "","","","", + "","BankmanTalked","","", + "","BankmanLooked", "","","BankmanWindowTalked"}, + + /* Arminius 7.13 scheduleman */ + { "Scheduleman","SchedulemanInit","","", + "","","","SchedulemanLoop", + "","SchedulemanTalked","","", + "","", "","","SchedulemanWindowTalked"}, + + /* Arminius 7.24 manor scheduleman */ + { "ManorSman","ManorSmanInit","","", + "","","","ManorSmanLoop", + "","ManorSmanTalked","","", + "","", "","","ManorSmanWindowTalked"}, + + // Robin + { "Riderman","RidermanInit","","", + "","","","", + "","RidermanTalked","","", + "","RidermanLooked", "","","RidermanWindowTalked"}, + + { "FmLetter","FmLetterInit","","", + "","","","", + "","FmLetterTalked","","", + "","FmLetterLooked", "","","FmLetterWindowTalked"} + // Terry 2001/08/30 + // 石器服务员 StoneSreviceMan +#ifdef _SERVICE + ,{ + "StoneServiceMan","StoneServiceManInit","","","","","", + "StoneServiceManLoop","", + "StoneServiceManTalked","","","","","","", + "StoneServiceManWindowTalked" + } +#endif +#ifdef _GAMBLE_BANK + ,{ + "NPC_GambleBank","GambleBankInit","","","","","", + "GambleBankLoop","", + "GambleBankTalked","","","","","","", + "GambleBankWindowTalked" + } +#endif + +#ifdef _GAMBLE_ROULETTE //Gamble_Roulette + ,{ + "NPC_GambleRoulette","GambleRouletteInit","","","","","", + "GambleRouletteLoop","", + "GambleRouletteTalked","","","","","","", + "GambleRouletteWindowTalked" + } + //主持人 + ,{ + "NPC_GambleMaster","GambleMasterInit","","","","","", + "GambleMasterLoop","", + "GambleMasterTalked","","","","","","", + "GambleMasterWindowTalked" + } + +#endif + +#ifdef _TRANSER_MAN + /* TranserMan */ + ,{ "TranserMan","TranserManInit","","", + "","","","TranserManLoop", + "","TranserManTalked","","", + "","", "","","TranserManWindowTalked" + } +#endif + +#ifdef _NPC_SELLSTH + /* SellsthMan */ + ,{ "SellsthMan","SellsthManInit","","", + "","","","SellsthManLoop", + "","SellsthManTalked","","", + "","", "","","SellsthManWindowTalked" + } +#endif + +#ifdef _NPC_MAKEPAIR + ,{ "MakePair","MakePairManInit","","", + "","","","MakePairManLoop", + "","MakePairManTalked","","", + "","", "","","MakePairManWindowTalked" + } +#endif + +#ifdef _NPC_FUSION + ,{ "PetFusion","PetFusionManInit","","", + "","","","PetFusionManLoop", + "","PetFusionManTalked","","", + "","", "","","PetFusionManWindowTalked" + } +#endif + +#ifdef _PAUCTION_MAN + /* PauctionMan */ + ,{ "PauctionMan","PauctionManInit","","", + "","","","PauctionManLoop", + "","PauctionManTalked","","", + "","", "","","PauctionManWindowTalked" + } +#endif + +#ifdef _ITEM_NPCCHANGE + ,{ "ItemchangeMan","ItemchangeManInit","","", + "","","","ItemchangeManLoop", + "","ItemchangeManTalked","","", + "","", "","","ItemchangeManWindowTalked" + } +#endif + +#ifdef _CFREE_petskill + ,{ + "NPC_FreePetSkill","FreePetSkillInit","","","","","", + "","", + "FreePetSkillTalked","","","","","","", + "FreePetSkillWindowTalked" + } + +#endif + +#ifdef _PETRACE + //主持人 + ,{ + "PetRaceMaster","PetRaceMasterInit","","","","","", + "PetRaceMasterLoop","", + "PetRaceMasterTalked","","","","","","", + "PetRaceMasterWindowTalked" + } + // 宠物 + ,{ + "PetRacePet","PetRacePetInit","","","","","", + "PetRacePetLoop","", + "PetRacePetTalked","","","","","","","" + } +#endif + +#ifdef _NEW_WARPMAN + ,{ + "NPC_NewNpcMan","NewNpcManInit","","","","","", + "NewNpcManLoop","", + "NewNpcManTalked","","","","","","", + "NewNpcManWindowTalked" + } +#endif + +#ifdef _MARKET_TRADE + ,{ + "NPC_MTradeNpcMan","MapTradeManInit","","","","","", + "MapTradeManLoop","", + "MapTradeManTalked","","","","","","", + "MapTradeManWindowTalked" + } +#endif + +#ifdef _BLACK_MARKET + ,{ + "BlackMarket", + "BlackMarketInit","","","","","","","","BlackMarketTalked","","", + "","", "","","BlackMarketWindowTalked" + } +#endif + +#ifdef _ALLDOMAN // (不可开) Syu ADD 排行榜NPC + ,{ + "Alldoman","AlldomanInit","","", + "","","","","","AlldomanTalked","","","","","","", + "AlldomanWindowTalked"} +#endif + +#ifdef _NPC_WELFARE + ,{ "Welfare","WelfareInit","","", + "","","","", + "","WelfareTalked","","", + "","", "","","WelfareWindowTalked"} +#endif + +#ifdef _NPC_VERYWELFARE + ,{ "VeryWelfare","VeryWelfareInit","","", + "","","","", + "","VeryWelfareTalked","","", + "","", "","","VeryWelfareWindowTalked"} +#endif + +#ifdef _NPC_WELFARE_2 // WON ADD 职业NPC-2 + ,{ "Welfare2","WelfareInit2","","", + "","","","", + "","WelfareTalked2","","", + "","", "","","WelfareWindowTalked2"} +#endif + +#ifdef _RACEMAN + ,{"Raceman","RacemanInit", "", "", + "", "", "", "", + "", "RacemanTalked", "", "", + "", "", "", "","RacemanWindowTalked"}, +#endif + +}; + +static int NPC_searchFunctionSet( char* name, int* unuse) +{ + int i; + for( i=0 ; i =arraysizeof(functionSet) )return FALSE; + + strcpysafe( ch->charfunctable[CHAR_INITFUNC].string, + sizeof( ch->charfunctable[CHAR_INITFUNC].string ), + functionSet[id].initfunc); + + strcpysafe( ch->charfunctable[CHAR_WALKPREFUNC].string, + sizeof(ch->charfunctable[CHAR_WALKPREFUNC].string), + functionSet[id].walkprefunc); + + strcpysafe( ch->charfunctable[CHAR_WALKPOSTFUNC].string, + sizeof(ch->charfunctable[CHAR_WALKPOSTFUNC].string), + functionSet[id].walkpostfunc); + + strcpysafe( ch->charfunctable[CHAR_PREOVERFUNC].string, + sizeof(ch->charfunctable[CHAR_PREOVERFUNC].string), + functionSet[id].preoverfunc); + + strcpysafe( ch->charfunctable[CHAR_POSTOVERFUNC].string, + sizeof(ch->charfunctable[CHAR_POSTOVERFUNC].string), + functionSet[id].postoverfunc); + + strcpysafe( ch->charfunctable[CHAR_WATCHFUNC].string, + sizeof(ch->charfunctable[CHAR_WATCHFUNC].string), + functionSet[id].watchfunc); + + strcpysafe( ch->charfunctable[CHAR_LOOPFUNC].string, + sizeof(ch->charfunctable[CHAR_LOOPFUNC].string), + functionSet[id].loopfunc); + + strcpysafe( ch->charfunctable[CHAR_TALKEDFUNC].string, + sizeof(ch->charfunctable[CHAR_TALKEDFUNC].string), + functionSet[id].talkedfunc); + + strcpysafe( ch->charfunctable[CHAR_DYINGFUNC].string, + sizeof(ch->charfunctable[CHAR_DYINGFUNC].string), + functionSet[id].dyingfunc); + + strcpysafe( ch->charfunctable[CHAR_PREATTACKEDFUNC].string, + sizeof(ch->charfunctable[CHAR_PREATTACKEDFUNC].string), + functionSet[id].preattackedfunc); + strcpysafe( ch->charfunctable[CHAR_POSTATTACKEDFUNC].string, + sizeof(ch->charfunctable[CHAR_POSTATTACKEDFUNC].string), + functionSet[id].postattackedfunc); + + strcpysafe( ch->charfunctable[CHAR_OFFFUNC].string, + sizeof(ch->charfunctable[CHAR_OFFFUNC].string), + functionSet[id].offfunc ); + + strcpysafe( ch->charfunctable[CHAR_LOOKEDFUNC].string, + sizeof(ch->charfunctable[CHAR_LOOKEDFUNC].string), + functionSet[id].lookedfunc ); + + strcpysafe( ch->charfunctable[CHAR_ITEMPUTFUNC].string, + sizeof(ch->charfunctable[CHAR_ITEMPUTFUNC].string), + functionSet[id].itemputfunc ); + + strcpysafe( ch->charfunctable[CHAR_SPECIALTALKEDFUNC].string, + sizeof(ch->charfunctable[CHAR_SPECIALTALKEDFUNC].string), + functionSet[id].specialtalkedfunc ); + + strcpysafe( ch->charfunctable[CHAR_WINDOWTALKEDFUNC].string, + sizeof(ch->charfunctable[CHAR_WINDOWTALKEDFUNC].string), + functionSet[id].windowtalkedfunc ); + +#ifdef _USER_CHARLOOPS + strcpysafe( ch->charfunctable[CHAR_LOOPFUNCTEMP1].string, + sizeof(ch->charfunctable[CHAR_LOOPFUNCTEMP1].string), ""); + + strcpysafe( ch->charfunctable[CHAR_LOOPFUNCTEMP2].string, + sizeof(ch->charfunctable[CHAR_LOOPFUNCTEMP2].string), ""); +#endif + return TRUE; +} + + +typedef enum +{ + NPC_INTENTRY=0, + NPC_CHARENTRY=1, + NPC_INTFUNC=2, + NPC_CHARFUNC=3, +}NPC_TYPECATEGORYATREADFILE; + +/*------------------------------------------------------------ + * Template index 午仄化恳仄中井升丹井check允月 + * 娄醒 + * index int index + * 忒曰袄 + * valid TRUE + * invalid FALSE + ------------------------------------------------------------*/ +INLINE int NPC_CHECKTEMPLATEINDEX(int index) +{ + if( NPC_templatenum <= index || index < 0 )return FALSE; + return TRUE; +} +/*------------------------------------------------------------ + * Template intdata index 午仄化恳仄中井升丹井check允月 + * 娄醒 + * index int index + * 忒曰袄 + * valid TRUE + * invalid FALSE + ------------------------------------------------------------*/ +static INLINE int NPC_CHECKTEMPLATEINTINDEX(int index) +{ + if( NPC_TEMPLATEINTNUM <= index || index < 0 )return FALSE; + return TRUE; +} +/*------------------------------------------------------------ + * Template chardata index 午仄化恳仄中井升丹井check允月 + * 娄醒 + * index int index + * 忒曰袄 + * valid TRUE + * invalid FALSE + ------------------------------------------------------------*/ +static INLINE int NPC_CHECKTEMPLATECHARINDEX(int index) +{ + if( NPC_TEMPLATECHARNUM <= index || index < 0 )return FALSE; + return TRUE; +} + + + +/*------------------------------------------------------------ + * NPC_Template毛赓渝祭允月[ + * 娄醒 + * filenum int 白央奶伙醒 + * 忒曰袄 + * 岳 TRUE(1) + * 撩 FALSE(0) + ------------------------------------------------------------*/ +BOOL NPC_initTemplateArray( int templatenum ) +{ + NPC_templatenum = templatenum; + NPC_template = (NPC_Template*)allocateMemory( sizeof( NPC_Template ) * + NPC_templatenum ); + if( NPC_template == NULL )return FALSE; + NPC_template_readindex = 0; + return TRUE; +} + +/*------------------------------------------------------------ + * 犯白巧伙玄及NPC 件皿伊□玄毛医 允月[ + * 娄醒 + * temp NPC_Template* 件皿伊□玄及禾奶件正□ + * 忒曰袄 + * 卅仄 + ------------------------------------------------------------*/ +void NPC_setDefaultNPCTemplate( NPC_Template* temp ) +{ + int i; + if( temp == NULL )return; + + for( i=0 ; i< arraysizeof(temp->chardata) ; i ++ ) + memset( &temp->chardata[i], 0, sizeof(temp->chardata[i] )); + + temp->intdata[NPC_TEMPLATEMAKEATNOBODY]=0; + temp->intdata[NPC_TEMPLATEMAKEATNOSEE]=0; + temp->intdata[NPC_TEMPLATEIMAGENUMBER]=0; + temp->intdata[NPC_TEMPLATETYPE]=-1; + + temp->intdata[NPC_TEMPLATEMINHP]=0; + temp->intdata[NPC_TEMPLATEMINMP]=0; + temp->intdata[NPC_TEMPLATEMINSTR]=0; + temp->intdata[NPC_TEMPLATEMINTOUGH]=0; + + temp->intdata[NPC_TEMPLATEISFLYING]=0; + + temp->intdata[NPC_TEMPLATEITEMNUM]=0; + temp->intdata[NPC_TEMPLATELOOPFUNCTIME]=-1; + temp->intdata[NPC_TEMPLATEFUNCTIONINDEX]=-1; + + for( i=0; irandomdata[i] = 0; + } + + temp->hash = 0; + temp->haveitem=NULL; +} + +BOOL NPC_IsNPCTemplateFile( char* filename ) +{ + FILE* f; + char line1[128]; + char* ret; + if( filename == NULL + ||strlen( filename ) < 1 + ||filename[strlen(filename)-1] == '~' + ||filename[0] == '#' + ||strcmptail( filename, ".bak" ) == 0 )return FALSE; + + f = fopen( filename , "r" ); + if( f == NULL ) goto RETURNFALSE; + ret = fgets( line1, sizeof( line1 ), f ); + if( ret == NULL )goto FCLOSERETURNFALSE; + + if( strcmp( NPC_TEMPLATEFILEMAGIC, line1 ) == 0 ){ + fclose(f); + return TRUE; + } + +FCLOSERETURNFALSE: + fclose(f); +RETURNFALSE: + return FALSE; +} + +void NPC_templateallocitemdata( NPC_Template* one ) +{ + int itemnum = one->intdata[NPC_TEMPLATEITEMNUM]; + if( itemnum > 8 ) itemnum = 8; + else if( itemnum <= 0 ) itemnum = 0; + /* 袄及 凳 */ + one->intdata[NPC_TEMPLATEITEMNUM] = itemnum; + one->haveitem = allocateMemory( sizeof( NPC_haveItem ) * itemnum ); + +} + + +/*------------------------------------------------------------ + * NPC_getRandomValue 午及娄醒及询晶岭及凶户及楮醒 + * 娄醒 + * string char* 侬 + * unuse int* 银歹卅中[ + * 忒曰袄 + * 仿件母丞及 斓及袄 汔及涩烂反}2 及娄醒卞忡绣允月[ + ------------------------------------------------------------*/ +static int NPC_seekGraphicNumberFromString( char* string, int* unuse ) +{ + return CHAR_seekGraphicNumberFromString( string ); + +} +/*------------------------------------------------------------ + * 仿件母丞袄毛 戈 + * 娄醒 + * string char* 侬 + * randomvalue int* 仿件母丞及 五今 + * 忒曰袄 + * 仿件母丞及 斓及袄 汔及涩烂反}2 及娄醒卞忡绣允月[ + ------------------------------------------------------------*/ +static int NPC_getRandomValue( char* string,int* randomwidth ) +{ + int minvalue; + int maxvalue; + char* startmax=NULL; + + minvalue = atoi( string ); + startmax = index( string,',' ); + if( startmax != NULL ){ + /* 仿件母丞涩烂互今木化中月 */ + /* +1 反 ","及凶户 */ + maxvalue = atoi(startmax+1); + + /* 切扎氏午仄凶涩烂分 */ + *randomwidth = ABS(maxvalue - minvalue); + return min(minvalue,maxvalue); + } + *randomwidth = 0; + return minvalue; +} + + +/*------------------------------------------------------------ + * NPCTemplate 白央奶伙毛夫午勾 戈[ + * 娄醒 + * filename char* 涩烂白央奶伙毛 心铵户月玄永皿犯奴伊弁玄伉 + * 忒曰袄 + * 岳 TRUE(1) + * 分户(仇木动晓白央奶伙毛 氏匹反中仃卅中) + * 撩 FALSE(0) + ------------------------------------------------------------*/ +BOOL NPC_readTemplateFile( char* filename ) +{ + FILE* f; + char line[512]; + int linenum=0; + int start=OFF; + NPC_Template temp; + int itmreadindex=0; + char* ret; + int randomdata[NPC_TEMPLATEINTNUM]; + int i; + + if( NPC_template_readindex >= NPC_templatenum ){ + print("模块超过配置数目\n" ); + print("配置模块数目 %d\n", NPC_templatenum); + return FALSE; + } + + for( i=0; i= NPC_templatenum ){ + print("模块超过配置数目\n" ); + print("配置模块数目是 %d\n", + NPC_templatenum); + goto FCLOSERETURNFALSE; + } + } + NPC_setDefaultNPCTemplate( &temp ); + itmreadindex=0; + start=OFF; + }else{ + fprint( "未解决 '}' at %s:%d\n",filename,linenum); + goto FCLOSERETURNFALSE; + } + break; + default: + { + typedef struct tagNPC_Readtemplate + { + char* keyword; + NPC_TYPECATEGORYATREADFILE type; + int index; + void* func; + }NPC_Readtemplate; + static NPC_Readtemplate NPC_readtemplate[NPC_TEMPLATECHARNUM+NPC_TEMPLATEINTNUM]= + { + {"templatename" , NPC_CHARENTRY, NPC_TEMPLATENAME,NULL}, + {"name" , NPC_CHARENTRY, NPC_TEMPLATECHARNAME, + NULL}, + {"makeatnobody", NPC_INTENTRY, NPC_TEMPLATEMAKEATNOBODY, + NULL}, + {"makeatnosee" , NPC_INTENTRY, NPC_TEMPLATEMAKEATNOSEE, + NULL}, + {"graphicname", NPC_INTFUNC, NPC_TEMPLATEIMAGENUMBER, + NPC_seekGraphicNumberFromString}, + {"type", NPC_INTFUNC, NPC_TEMPLATETYPE, + NPC_seekGraphicNumberFromString}, + + {"hp", NPC_INTFUNC, NPC_TEMPLATEMINHP, + NPC_getRandomValue}, + {"mp", NPC_INTFUNC, NPC_TEMPLATEMINMP, + NPC_getRandomValue}, + {"str", NPC_INTFUNC, NPC_TEMPLATEMINSTR, + NPC_getRandomValue}, + {"tough", NPC_INTFUNC, NPC_TEMPLATEMINTOUGH, + NPC_getRandomValue}, + + {"fly", NPC_INTENTRY,NPC_TEMPLATEISFLYING,NULL}, + + {"itemnum", NPC_INTENTRY, NPC_TEMPLATEITEMNUM, NULL,}, + {"functionset",NPC_INTFUNC, NPC_TEMPLATEFUNCTIONINDEX, + NPC_searchFunctionSet,}, + {"initfunc", NPC_CHARENTRY, NPC_TEMPLATEINITFUNC,NULL,}, + {"walkprefunc", NPC_CHARENTRY, NPC_TEMPLATEWALKPREFUNC, + NULL,}, + {"walkpostfunc",NPC_CHARENTRY, NPC_TEMPLATEWALKPOSTFUNC, + NULL,}, + {"preoverfunc", NPC_CHARENTRY, NPC_TEMPLATEPREOVERFUNC, + NULL,}, + {"postoverfunc",NPC_CHARENTRY, NPC_TEMPLATEPOSTOVERFUNC, + NULL,}, + {"watchfunc", NPC_CHARENTRY, NPC_TEMPLATEWATCHFUNC, + NULL,}, + {"loopfunc", NPC_CHARENTRY, NPC_TEMPLATELOOPFUNC, NULL,}, + {"talkedfunc",NPC_CHARENTRY,NPC_TEMPLATETALKEDFUNC,NULL,}, + {"dyingfunc",NPC_CHARENTRY,NPC_TEMPLATEDYINGFUNC,NULL,}, + {"preattackedfunc",NPC_CHARENTRY, + NPC_TEMPLATEPREATTACKEDFUNC,NULL,}, + {"postattackedfunc",NPC_CHARENTRY, + NPC_TEMPLATEPOSTATTACKEDFUNC,NULL,}, + {"offfunc",NPC_CHARENTRY,NPC_TEMPLATEOFFFUNC,NULL,}, + {"lookedfunc",NPC_CHARENTRY,NPC_TEMPLATELOOKEDFUNC,NULL,}, + {"itemputfunc",NPC_CHARENTRY,NPC_TEMPLATEITEMPUTFUNC, + NULL,}, + {"specialtalkedfunc",NPC_CHARENTRY, + NPC_TEMPLATESPECIALTALKEDFUNC, NULL,}, + + {"windowtalkedfunc",NPC_CHARENTRY, + NPC_TEMPLATEWINDOWTALKEDFUNC, NULL,}, + + {"loopfunctime",NPC_INTENTRY,NPC_TEMPLATELOOPFUNCTIME, + NULL,}, + }; + + char firstToken[256]; + int ret,i; + ret = getStringFromIndexWithDelim( line, "=", 1, firstToken, sizeof( firstToken ) ); + if( ret == FALSE ){ + print( "Find error at %s in line %d. Ignore\n", filename , linenum); + break; + } + + if( strcasecmp(firstToken,"itm") == 0 ){ + char one[128]; + char two[128]; + char three[128]; + int itemnumber=0,rate=0,amount=1; + char secondToken[256]={""}; + if( itmreadindex < temp.intdata[NPC_TEMPLATEITEMNUM] && + temp.haveitem != NULL ) + ; + else + continue; + ret = getStringFromIndexWithDelim( line, "=", 2, + secondToken, sizeof(secondToken ) ); + if( ret == FALSE ){ + print( "Find error at %s in line %d. Ignore\n", + filename , linenum); + secondToken[0] = '\0'; + } + ret = getStringFromIndexWithDelim( secondToken, "|", 1, one,sizeof( one ) ); + if( ret != FALSE )itemnumber=atoi(one); + ret = getStringFromIndexWithDelim( secondToken, "|", 2, two,sizeof(two)); + if( ret != FALSE )rate=atoi(two); + ret = getStringFromIndexWithDelim( secondToken, "|", 3, three,sizeof(three)); + if( ret != FALSE )amount=atoi(three); + if( rate > 0 && amount > 0 ){ + if( itemnumber == -1 ){ + temp.haveitem[itmreadindex].itemnumber = -1; + temp.haveitem[itmreadindex].haverate = rate; + temp.haveitem[itmreadindex].havenum = amount; + itmreadindex++; + }else if( ITEM_CHECKITEMTABLE( itemnumber ) == TRUE ){ + temp.haveitem[itmreadindex].itemnumber=itemnumber; + temp.haveitem[itmreadindex].haverate = rate; + temp.haveitem[itmreadindex].havenum = amount; + itmreadindex++; + }else + print("this item is not item %s:%d\n", + filename , linenum); + }else + print("rate or amount is odd setting. rate=%d " + "amount=%d %s:%d\n", rate,amount, filename, + linenum); + goto NEXT; + }else{ + for( i = 0 ; i < arraysizeof(NPC_readtemplate) ; i ++ ){ + if( strcasecmp( NPC_readtemplate[i].keyword, + firstToken ) == 0 ){ + char secondToken[256]={""}; + ret = getStringFromIndexWithDelim( + line, "=", 2, secondToken, sizeof(secondToken) + ); + if( ret == FALSE ) + print( "Find error at %s in line %d. Ignore\n" + ,filename , linenum); + + switch( NPC_readtemplate[i].type ){ + case NPC_INTENTRY: + temp.intdata[NPC_readtemplate[i].index]=atoi(secondToken); + if( NPC_readtemplate[i].index == NPC_TEMPLATEITEMNUM ) + NPC_templateallocitemdata( &temp ); + break; + case NPC_CHARENTRY: + strcpysafe( temp.chardata[NPC_readtemplate[i].index].string, + sizeof(temp.chardata[NPC_readtemplate[i].index].string), + secondToken); + break; + case NPC_INTFUNC: + { + int (*intfunction)(char*,int* ); + intfunction = NPC_readtemplate[i].func; + temp.intdata[NPC_readtemplate[i].index] + = intfunction( secondToken, &randomdata[NPC_readtemplate[i].index]); + break; + } + case NPC_CHARFUNC: + { + char* (*charfunction)(char* ); + charfunction = NPC_readtemplate[i].func; + strcpysafe( temp.chardata[NPC_readtemplate[i].index].string, + sizeof(temp.chardata[NPC_readtemplate[i].index].string), + charfunction(secondToken)); + break; + } + default: + break; + } + goto NEXT; + } + } + } + fprint("%s:%d There is no such entry %s\n" , filename, + linenum, firstToken ); + NEXT: + break; + } + break; + } + } + fclose(f); + return TRUE; + +FCLOSERETURNFALSE: + fclose(f); + return FALSE; +} + +BOOL NPC_readNPCTemplateFiles( char* topdirectory ,int templatesize) +{ + STRING64 *filenames; + int filenum; + int i; + filenames = (STRING64 *)allocateMemory( sizeof( STRING64 ) * + (int)getFilesearchnum( ) ); + if( filenames == NULL ){ + print( "读取NPC创建文件... 内存出错\n" ); + return FALSE; + } + filenum = rgetFileName( topdirectory ,filenames ,getFilesearchnum( ) ); + if( filenum == -1 ){ + fprint("无法从 %s 递归获取文件名\n",topdirectory); + freeMemory( filenames ); + return FALSE; + } + if( filenum >= getFilesearchnum( ) ){ + print( "文件搜索数目失败 %d\n", getFilesearchnum( ) ); + while( 1 ); + }else{ + print( "搜索到文件 = %d\n", filenum ); + } + if( !NPC_initTemplateArray( templatesize ) ){ + fprint( "开启模块数组错误\n" ); + freeMemory( filenames ); + return FALSE; + } + print( "读取文件模块数组错误...." ); + for( i = 0 ; i < filenum ; i ++ ) + if( NPC_IsNPCTemplateFile( filenames[i].string )) + NPC_readTemplateFile( filenames[i].string ); + print( "正确模块 %d ...\n" , NPC_template_readindex ); + NPC_templatenum=NPC_template_readindex; + freeMemory( filenames ); + return TRUE; +} + + + +/*------------------------------------------------------------ + * 侬 卞覆杀允月 template 及 index 毛忒允[ + * 娄醒 + * templatename char* 件皿伊□玄及 蟆 + * 忒曰袄 + * -1 及凛巨仿□ + ------------------------------------------------------------*/ +int NPC_templateGetTemplateIndex( char* templatename ) +{ + int i; + int hash=hashpjw( templatename ); + + for( i = 0 ; i < NPC_templatenum ; i ++ ) + if( hash == NPC_template[i].hash && + strcasecmp( templatename , NPC_template[i].chardata[NPC_TEMPLATENAME].string) == 0 ) + return i; + + return -1; +} diff --git a/gmsv/npc/npcutil.c b/gmsv/npc/npcutil.c new file mode 100644 index 0000000..3ca1103 --- /dev/null +++ b/gmsv/npc/npcutil.c @@ -0,0 +1,1736 @@ +#include "version.h" +#include +#include "common.h" +#include "char.h" +#include "char_base.h" +#include "configfile.h" +#include "object.h" +#include "item.h" +#include "map_deal.h" +#include "npcutil.h" +#include "npc_door.h" +#include "readmap.h" +#include "npccreate.h" +#include "enemy.h" + +// CoolFish: Family 2001/7/29 +#include "family.h" +#include "saacproto_cli.h" + +#define IS_2BYTEWORD( _a_ ) ( (char)(0x80) <= (_a_) && (_a_) <= (char)(0xFF) ) + +extern struct FM_POINTLIST fmpointlist; + +#ifdef _PERSONAL_FAME // Arminius 8.30: 家族个人声望 + +// Arminius: 我把声望值减半 +int FMAdvTbl[] = { // 家族冒险 Table + 0, // 0 + 15, // 1 + 5, // 2 + 0, // 3 + 10, // 4 + 5, // 5 + 0, // 6 + 0, // 7 + 30, // 8 + 0, // 9 + 0, // 10 + 0, // 11 + 68, // 12 + 68, // 13 + 0, // 14 + 15, // 15 + 120, // 16 + 90, // 17 + 0, // 18 + 120, // 19 + 0, // 20 + 0, // 21 + 60, // 22 + 0, // 23 + 0, // 24 + 0, // 25 + 60, // 26 + 0, // 27 + 0, // 28 + 0, // 29 + 0, // 30 + 60, // 31 + 0, // 32 + 0, // 33 + 30, // 34 + 225, // 35 + 0, // 36 + 0, // 37 + 60, // 38 + 135, // 39 + 600, // 40 + 0, // 41 + 360, // 42 + 0, // 43 + 0, // 44 + 480, // 45 + 840, // 46 + 0, // 47 + 600, // 48 + 600, // 49 + 600, // 50 + 600, // 51 + 600, // 52 + 600, // 53 + 720, // 54 + 0, // 55 + 0, // 56 + 0, // 57 + 0, // 58 + 0, // 59 + 0, // 60 + 0, // 61 + 0, // 62 + 120, // 63 + 900, // 64 + 0, // 65 + 0, // 66 + 0, // 67 + 0, // 68 + 0, // 69 + 0, // 70 + 15000, // 71 + 20000, // 72 + 0, // 73 + 0, // 74 + 0, // 75 + 0, // 76 + 0, // 77 + 0, // 78 + 0, // 79 + 0, // 80 + 1200, // 81 + 3000, // 82 + 0, // 83 + 1500, // 84 + 0, // 85 + 0, // 86 + 100, // 87 + 0, // 88 + 400, // 89 + 0, // 90 + 0, //91 + 0, // 92 + 0, // 93 + 0, // 94 + 0, // 95 + 0, // 96 + 100, // 97 + 0, // 98 + 0, // 99 + 0, // 100 + 0, //101 + 0, //102 + 0, //103 + 0, //104 + 600, // 105 + 0, // 106 + 100, // 107 + 0, // 108 + 0, // 109 + 400, // 110 + 500, // 111 + 1000, // 112 + 100, // 113 + 300, // 114 + 0, // 115 + 500, // 116 + 15000, // 117 + 0, // 118 + 0, // 119 + 0, // 120 + 0, // 121 + 0, // 122 + 0, // 123 + 0, // 124 + 400, // 125 + 300, // 126 + 0, // 127 + 0, // 128 + 0, // 129 + 0, // 130 + 0, // 131 + 0, // 132 + 500, // 133 +}; + +#endif + +BOOL NPC_Util_AddOneTitle( int charindex, int titleindex ) +{ + int i; + Char *c ; + + if( !CHAR_CHECKINDEX( charindex ) )return FALSE; + + c = CHAR_getCharPointer( charindex ); + // CoolFish: +1 2001/11/05 + if (!c) return FALSE; + + for(i=0;iindexOfHaveTitle[i] == -1 ){ + c->indexOfHaveTitle[i] = titleindex; + return TRUE; + } + } + return FALSE; +} + + +BOOL NPC_Util_HaveTitle( int charindex , int titleindex ) +{ + int i; + Char *c; + if( !CHAR_CHECKINDEX( charindex ) )return -1; + + c = CHAR_getCharPointer( charindex ); + // CoolFish: +1 2001/11/05 + if (!c) return FALSE; + + for(i=0;iindexOfHaveTitle[i] == titleindex ){ + return TRUE; + } + } + return FALSE; +} + + +BOOL NPC_Util_Nearby( int x1 , int y1, int x2 , int y2 ) +{ + if( ABS( x1 - x2 ) <= 1 && + ABS( y1 - y2 ) <= 1 ){ + return TRUE; + } else { + return FALSE; + } +} + +BOOL NPC_Util_CharNearby(int ind1,int ind2) +{ + if( !CHAR_CHECKINDEX(ind1)) return FALSE; + if( !CHAR_CHECKINDEX(ind2)) return FALSE; + + if( CHAR_getInt( ind1 , CHAR_FLOOR ) != + CHAR_getInt( ind2 , CHAR_FLOOR ) ){ + return FALSE; + } + + return NPC_Util_Nearby( CHAR_getInt( ind1,CHAR_X), + CHAR_getInt( ind1,CHAR_Y), + CHAR_getInt( ind2,CHAR_X), + CHAR_getInt( ind2,CHAR_Y)); + +} + + +static struct ynset +{ + int value; + char string[32]; +}yntable[] ={ + { 0 , "no" }, + { 0 , "No" }, + { 0 , "NO" }, + { 0 , "NO" }, + { 0 , "No" }, + { 0 , "no" }, + { 0 , "否" }, + { 0 , "否" }, + + { 1 , "yes" }, + { 1 , "Yes" }, + { 1 , "YES" }, + { 1 , "YES" }, + { 1 , "Yes" }, + { 1 , "yes" }, + { 1 , "是" }, + { 1 , "是" }, + +}; + +int NPC_Util_YN(char *input ) +{ + int i; + for(i=0;;i++){ + int j; + + if( input[i] == '\0' ){ + return -1; + } + for(j=0;jx - pstart->x; + dify = pend->y - pstart->y; + + if( difx < 0 )difx=-1; + else if( difx > 0 )difx=1; + if( dify < 0 )dify=-1; + else if( dify > 0 )dify=1; + + return dirtable[dify+1][difx+1]; +} + +int NPC_Util_countHaveItem( int meindex , int itemid ) +{ + int i, count=0, itemindex; + if( !CHAR_CHECKINDEX(meindex))return -1; + for( i=0 ; i= 0 ){ + CHAR_ObjectDelete( oind ); + CHAR_setItemIndex( charindex, emptyindex, itemindex ); + ITEM_setWorkInt( itemindex, ITEM_WORKOBJINDEX, -1 ); + ITEM_setWorkInt( itemindex, ITEM_WORKCHARAINDEX, charindex ); + if( net ) CHAR_sendItemDataOne( charindex, emptyindex); + return TRUE; + }else if( cind >= 0 ){ + int itemgrp[2]; + int itemindexinchara; + if( cind == charindex )return FALSE; + itemindexinchara = NPC_Util_SearchItemInChar( cind , itemindex); + if( itemindexinchara == -1 )return FALSE; + CHAR_setItemIndex( cind , itemindexinchara , -1 ); + CHAR_complianceParameter(cind); + itemgrp[0] = itemindexinchara; + CHAR_setItemIndex( charindex , emptyindex , itemindex ); + itemgrp[1] = emptyindex; + if( net ) CHAR_sendItemData( charindex, itemgrp, arraysizeof(itemgrp)); + ITEM_setWorkInt( itemindex, ITEM_WORKOBJINDEX, -1 ); + ITEM_setWorkInt( itemindex, ITEM_WORKCHARAINDEX, charindex ); + return TRUE; + } + return FALSE; +} + +BOOL NPC_Util_moveItemToMap( int itemindex , int fl , int x , int y, + BOOL net ) +{ + int oind,cind; + + if( !ITEM_CHECKINDEX( itemindex ) ) return FALSE; + + oind = ITEM_getWorkInt( itemindex , ITEM_WORKOBJINDEX ); + cind = ITEM_getWorkInt( itemindex , ITEM_WORKCHARAINDEX ); + + if( oind >= 0 ){ + return MAP_objmove( oind , OBJECT_getFloor(oind), + OBJECT_getX(oind), + OBJECT_getY(oind), + fl,x,y); + } else if( cind >= 0 ){ + int itemindexinchara = NPC_Util_SearchItemInChar(cind,itemindex); + if( itemindexinchara == -1 ) return FALSE; + + CHAR_setItemIndex( cind , itemindexinchara , -1 ); + CHAR_complianceParameter(cind); + if( net ) CHAR_sendItemDataOne( cind, itemindexinchara); + if( CHAR_DropItemAbsolute( itemindex, fl,x,y,TRUE) < 0 ){ + return FALSE; + } else { + return TRUE; + } + } + return FALSE; +} + +int NPC_Util_GiveAllItemToChar( int give , int take ) +{ + int i ; + int count=0; + + for(i=0;i= 0 )break; + }else + if( Part == 1 ){ /* 惘及仿奶件毛腹绸 */ + iTarget = SearchNearLine( x+Level, y-Level+1, + floor, 0, 1, Level*2, type ); + if( iTarget >= 0 )break; + }else + if( Part == 2 ){ /* 票及仿奶件毛腹绸 */ + iTarget = SearchNearLine( x+Level-1, y+Level, + floor, -1, 0, Level*2, type ); + if( iTarget >= 0 ) break; + }else + if( Part == 3 ){ /* 尔及仿奶件毛腹绸 */ + iTarget = SearchNearLine( x-Level, y+Level-1, + floor, 0, -1, Level*2, type ); + if( iTarget >= 0 ) break; + } + Part ++; Part &= 3; /* 戚及由□玄毛腹绸 */ + } + return iTarget; +} + +int NPC_Util_SearchNear( int meindex, int maxlen, int type ) +{ +#if 1 + /* MAP 井日及伉件弁匹腹绸允月方丹卞 凳 */ + int floor, x, y, i,iTarget = -1; + /* 蜇箕及愤坌及树 毛娄五请允 */ + if( !CHAR_CHECKINDEX( meindex ) )return -1; + floor = CHAR_getInt( meindex, CHAR_FLOOR ); + x = CHAR_getInt( meindex, CHAR_X ); + y = CHAR_getInt( meindex, CHAR_Y ); + + /* 区 匹譬屯月 */ + for( i = 0; i < maxlen; i ++ ){ + iTarget = SearchNearAround( x, y, floor, RAND( 0,3 ), i+1, type ); + if( iTarget >= 0 )break; + } + return iTarget; + + +#else + /* 仇切日反衙中支曰 */ + int floor, x, y, i,iTarget = -1, iLen, iMin = 655360, tX, tY; + /* 醒必永玄*/ + if( !CHAR_CHECKINDEX( meindex ) )return -1; + floor = CHAR_getInt( meindex, CHAR_FLOOR ); + x = CHAR_getInt( meindex, CHAR_X ); + y = CHAR_getInt( meindex, CHAR_Y ); + + /* 腹绸 */ + for( i = 0 ; i maxlen )continue; /* 木允亢*/ + if( tY > maxlen )continue; /* 卅日戚尺*/ + + /* 称井中覃 毛煌遥*/ + iLen = tX*tX+tY*tY; + /* 域 嗤井匀凶桦宁反筏 凳蕙*/ + if( iMin > iLen ){ + iMin = iLen; + iTarget = obj[i].index; /* 奶件犯永弁旦毛瓒 */ + } + } + + return iTarget; +#endif +} +/*------------------------------------------------------------ +* 域 嗤中皿伊奶乩□及腹绸 +------------------------------------------------------------*/ +int NPC_Util_SearchNearPlayer( int meindex, int maxlen ) +{ + return( NPC_Util_SearchNear( meindex, maxlen, CHAR_TYPEPLAYER)); +} +/*------------------------------------------------------------ +* 域 嗤中衬及腹绸- +-----------------------------------------------------------*/ +int NPC_Util_SearchNearEnemy( int meindex, int maxlen ) +{ + return( NPC_Util_SearchNear( meindex, maxlen, CHAR_TYPEENEMY)); +} + + + +/******************************************************* + + 标户啖 允月蟆卞窒井卞少勾井匀化中月井升丹井譬屯月 + int NPC_Util_SuberiWalk( + int index, CHAR 及奶件犯永弁旦 + int dir 汹仁轾五 + ); + + 曰袄 0 7“汹仃月 轾 + -1 “穴永皿卞娄匀井井匀化巨仿□ + -2 “平乓仿弁正卞娄匀井井匀化巨仿□ + -3 “ 卞娄匀井井匀化巨仿□ + + 标户啖 允月桦宁引内冲}产卞啖 匹五月井譬屯月[ + 啖 匹五木壬标户毛民尼永弁允月[ 仄井啖 匹五卅仃木壬 + 公切日及 轾毛忒允[ + + 公仇卞窒井丐匀凶日 穴永皿动陆 ㄠ毛忒允 +*******************************************************/ +int NPC_Util_OtherCharCheck( int ff, int fx, int fy) +{ +#if 1 + /* 腹绸 挚毛 井日及伉件弁卞 凳 */ + OBJECT object; + for( object=MAP_getTopObj(ff,fx,fy); object ; + object = NEXT_OBJECT(object) ) + { + int objindex = GET_OBJINDEX(object); + /* 元甄 卞平乓仿弁正互丐月井 */ + if( OBJECT_getType(objindex) == OBJTYPE_CHARA ){ + return 1; + } + } + return 0; +#else + /* 仇切日反蛙挚及支曰 */ + int i; + for( i = 0 ; i < objnum ; i ++){ + /* 甄 互 元井"*/ + if( obj[i].x == fx && obj[i].y == fy && obj[i].floor == ff ){ + /* 平乓仿弁正井"*/ + if( obj[i].type != OBJTYPE_NOUSE ){ + return 1; + } + } + } + return 0; +#endif +} + + +/* 汹仃卅中桦宁反唤匀化心月*/ +int NPC_Util_SuberiWalk( + int index, + int dir +) +{ + int i, OkFlg = 0, x = 0, y = 0, fl = 0; + int aDirList[3],dir2; + int tX, tY; + + x = CHAR_getInt(index,CHAR_X); + y = CHAR_getInt(index,CHAR_Y); + fl = CHAR_getInt(index,CHAR_FLOOR); + + /* 标户 轾井"*/ + switch( dir ){ + case 1: aDirList[0] = 0; aDirList[1] = 2; aDirList[2] = 1; + break; + case 3: aDirList[0] = 2; aDirList[1] = 4; aDirList[2] = 3; + break; + case 5: aDirList[0] = 4; aDirList[1] = 6; aDirList[2] = 5; + break; + case 7: aDirList[0] = 6; aDirList[1] = 0; aDirList[2] = 7; + break; + default: + tX = x+CHAR_getDX(dir); + tY = y+CHAR_getDY(dir); + /* 褡户凶*/ + if( MAP_walkAble( index,fl,tX,tY ) == 0 ){ + dir = -1;/* 穴永皿卞娄匀井井匀凶*/ + } +// }else +// if( NPC_Util_OtherCharCheck( fl,tX, tY ) ){ +// dir = -2;/* 平乓仿卞娄匀井井匀凶*/ +// } + /* 引匀允什分!! 公及引引汹仁*/ +/* CHAR_walk( index, dir, 0 );*/ + return dir; + } + + /* 引匀允什卅日 烂卅仄*/ + for( i = 0; i < 3; i ++ ){ + dir2 = aDirList[i]; + tX = x+CHAR_getDX(dir2); + tY = y+CHAR_getDY(dir2); + if( MAP_walkAble( index,fl,tX,tY ) == 0 ){ + aDirList[i] = -1; /* 垫仃卅中桦宁反公及 轾坫诮*/ +// }else if( NPC_Util_OtherCharCheck( fl,tX, tY ) ){ +// aDirList[i] = -2; /* 垫仃卅中桦宁反公及 轾坫诮*/ + }else{ + /* 垫仃凶!!*/ + OkFlg ++; + } + } + + /* ㄢ勾蝈 第 卅桦宁反} 赓及骚曰 仁*/ + if( aDirList[0] >= 0 && aDirList[1] >= 0 && aDirList[2] >= 0 ){ + }else + /* 仇切日卞 仃月井"*/ + if( aDirList[0] >= 0 ){ + dir = aDirList[0]; + }else + /* 公木午手仇切日井"*/ + if( aDirList[1] >= 0 ){ + dir = aDirList[1]; + }else{ + dir = aDirList[0]+aDirList[1]; + } + + /* 啖 */ +/* CHAR_walk( index, dir, 0 );*/ + + return dir; +} +/*----------------------------------------------------------------------- +* NPC及create凛及娄醒及 井日隙烂今木凶 侬 毛腹绸仄] +* 公及 及醒袄毛潸 允月[左皿扑亦件匹醒袄毛隙烂今六化支曰凶中午五卞忐厍 +* +* 镗啦“犯伉立正反"|"卞蜃烂仄化引允[ +* 娄醒卞 元 侬 互ㄡ勾岈氏分桦宁] +* 燮及 互穸燮今木引允[ +* ---------------------------------- +* IN : int meindex : 平乓仿index +* : char* in : 腹绸允月 侬 +* OUT: +* RETURN: +* 潸 请 卅井匀凶凛 :-1 +* 潸 请 凶凛 :醒袄 +* ---------------------------------- +* +* “ +* [File:enemykill.create] +* enemy=enemykill|range:4 +* +* call: +* range = NPC_Util_GetNumFromArg( index, "range"); +*----------------------------------------------------------------------*/ +int NPC_Util_GetNumFromArg( int meindex, char* in) +{ + BOOL rc; + int i; + char outstr[sizeof( STRING32)]; + int out = -1; + char *a = CHAR_getChar( meindex, CHAR_NPCARGUMENT); + + for( i = 1; ; i++ ) { + /* 犯伉立正ㄠ勾内勾 戈 */ + rc = getStringFromIndexWithDelim( a, "|", i, outstr, sizeof(outstr)); + if( rc == FALSE) break; + if( strstr( outstr, in) != NULL ) { + out = textToInt( outstr); + break; + } + } + + return out; +} + +/* + * 失奶 丞及 index 午平乓仿 index 及孔凶勾及树 井日} + * 平乓仿互公及失奶 丞毛 匀化月井升丹井仄日屯化 匀化凶日升及 + * 匏 卞 匀化月井毛忒允[ 失奶 丞楮 及NPC迕[CHAR_卞啖垫 + * 匹五月井手仄木氏楮醒瓜伉 + * by ringo + * + * int charindex : 覆擂平乓仿及 index + * int itemindex : 失奶 丞及index + * + * 忒曰袄 + * + * >=0 : 升及匏 卞 匀化中月及井[ 躲卅袄[ + * -1 : 手仄仁反 匀化卅中[ + * -2 : 巨仿□[ + */ +int NPC_Util_SearchItemInChar( int charindex , int itemindex) +{ + int i; + + if( !CHAR_CHECKINDEX(charindex) ) return -2; + if( !ITEM_CHECKINDEX(itemindex) ) return -2; + + for(i=0;i<=CHAR_MAXITEMHAVE;i++){ + int ii = CHAR_getItemIndex( charindex , i ); + if( ii == itemindex ){ + return i; + } + } + return -1; +} + + +/*------------------------------------------------------------------------ +* 平乓仿井日心凶职及平乓仿及 轾毛菲户月 +* +* int NPC_Util_GetDirCharToChar( int fromindex, int toindex, int mode) +* +* int fromindex 仇及平乓仿index井日 +* int toindex 仇及平乓仿index卞覆仄化及 轾互菲户日木月 +* int mode 潸 允月 轾 +* 0:toindex卞轾井匀化 +* 1:toindex及 覆 轾 +* 2:toindex卞覆仄化惘ㄨㄟ蘸 轾 +* 3:toindex卞覆仄化尔ㄨㄟ蘸 轾 +* +* 忒曰袄 岳 “dir 轾毛忒允 +* 撩 “-1 +------------------------------------------------------------------------*/ +int NPC_Util_GetDirCharToChar( int fromindex, int toindex, int mode) +{ + int ret = -1; + + if( CHAR_getInt( fromindex, CHAR_FLOOR) + == CHAR_getInt( toindex, CHAR_FLOOR)) + { + POINT start,end; + int dir; + start.x = CHAR_getInt( fromindex, CHAR_X); + start.y = CHAR_getInt( fromindex, CHAR_Y); + end.x = CHAR_getInt( toindex, CHAR_X); + end.y = CHAR_getInt( toindex, CHAR_Y); + dir = NPC_Util_getDirFromTwoPoint( &start,&end ); + if( mode == 1 ) dir = (dir > 3)? dir -4 : dir +4; + else if( mode == 2) dir = (dir + 2) % 8; + else if( mode == 3) dir = (dir < 1)? dir +6 : dir -2; + ret = dir; + } + return( ret); +} + +/*------------------------------------------------------------------------ +* 平乓仿卞覆仄化]丐月 轾卞啖 允月[ +* +* int NPC_Util_WalkCharToChar( int fromindex, int toindex, int mode) +* +* int fromindex 汹仁平乓仿index +* int toindex 汹仁 及平乓仿index +* int mode 汹仁 轾 +* 0:toindex卞轾井匀化 +* 1:toindex及 覆 轾 +* 2:toindex卞覆仄化惘ㄨㄟ蘸 轾 +* 3:toindex卞覆仄化尔ㄨㄟ蘸 轾 +* BOOL suberi NPC_Util_SuberiWalk毛哔 允月井"TRUE:允月 FALSE:仄卅中 +* +* 忒曰袄 岳 汹中凶 “dir 汹中凶 轾毛忒允 +* 撩 “-1 +------------------------------------------------------------------------*/ +int NPC_Util_WalkCharToChar( int fromindex, int toindex, int mode, int suberi) +{ + int ret = -1; + int dir; + + if( CHAR_getInt( fromindex, CHAR_FLOOR) + != CHAR_getInt( toindex, CHAR_FLOOR)) + { + return( -1); + } + dir = NPC_Util_GetDirCharToChar( fromindex, toindex, mode ); + if( dir != -1) { + if( suberi) { + dir = NPC_Util_SuberiWalk( fromindex, dir ); + } + } + if( dir >= 0 ) { + ret = CHAR_walk(fromindex,dir,0); + if( ret == CHAR_WALKSUCCESSED ) ret = dir; + else ret = -1; + } + return( ret); +} + + +/*------------------------------------------------------------------------ +* NPC毛壅 今六月[ +* +* void NPC_Util_NPCDelete( int srcindex) +* +* int srcindex 壅允index +* +------------------------------------------------------------------------*/ +void NPC_Util_NPCDelete( int srcindex) +{ + //int objindex; + //objindex = CHAR_getWorkInt(srcindex,CHAR_WORKOBJINDEX); + + /* createnum 互 及凛]戏引木凶凛棉毛本永玄允月 + * 卅兮仇仇匹仇氏卅仪毛仄化中月井午中丹午 + * create白央奶伙及time袄互戏引木化井日公木分仃坌烦匀化中月午] + * 濮覆卞允什卞戏引木化仁月午中丹酷 毛卅氏午井仄方丹午允月啃 + */ + if( CHAR_getInt( srcindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) return; + if( NPC_createCheckMaxEnemynum( CHAR_getInt(srcindex,CHAR_NPCCREATEINDEX ))) + NPC_createInitTime( CHAR_getInt(srcindex,CHAR_NPCCREATEINDEX )); + NPC_createDecreaseEnemynum( CHAR_getInt(srcindex, + CHAR_NPCCREATEINDEX ) ); + + CHAR_CharaDelete( srcindex ); + +} + +char *NPC_Util_CheckAssignArgFile( int index, char *filename) +{ + BOOL rc; + int i; + char *cret = NULL; + char outstr[64]; + char outstr2[64]; + char *a = CHAR_getChar( index , CHAR_NPCARGUMENT ); + + if( a == NULL ) { + print( "%s : %d err\n", __FILE__, __LINE__); + return cret; + } + + for( i = 1; ; i++ ) { + /* 犯伉立正ㄠ勾内勾 戈 */ + rc = getStringFromIndexWithDelim( a, "|", i, outstr, sizeof(outstr)); + if( rc == FALSE) break; + if( strstr( outstr, "file") != NULL ) { + rc = getStringFromIndexWithDelim( outstr, ":", 2, + outstr2, sizeof(outstr2)); + if( rc != FALSE ) { + strcpy( filename, outstr2); + cret = filename; + break; + } + } + } + return( cret); +} + +static char *NPC_Util_MargeStrFromArgFile( char *filename, char *buf, int len) +{ + FILE *fp; + char *cret = NULL; + char line[NPC_UTIL_GETARGSTR_LINEMAX]; + char opfile[32]; + + sprintf( opfile, "%s/", getNpcdir( ) ); + strcat( opfile, filename); + *buf = '\0'; + fp = fopen( opfile, "r"); + if( fp != NULL ) { + while( fgets( line, sizeof( line), fp)) { + if( strlen(buf) != 0 ) { + if( buf[strlen(buf) -1] != '|' ) { + strcatsafe( buf, len, "|"); + } + } + chompex( line); + strcatsafe( buf,len, line); + } + fclose( fp); + cret=buf; + } + return( cret); +} + +char *NPC_Util_GetArgStr( int index, char *argstr, int len) +{ + char filename[128]; + char *cret = NULL; + if( NPC_Util_CheckAssignArgFile( index, filename) != NULL ) { + if( NPC_Util_MargeStrFromArgFile( filename, argstr, len) != NULL ) { + cret = argstr; + } + }else { + if( CHAR_getChar( index, CHAR_NPCARGUMENT) != NULL ){ + strcpy( argstr, CHAR_getChar( index, CHAR_NPCARGUMENT)); + cret = argstr; + }else{ + cret = NULL; + } + } + if( cret == NULL ) print("File:%s\n", NPC_Util_CheckAssignArgFile( index, filename)); + + return( cret); +} + +int NPC_Util_GetNumFromStrWithDelim( char *srcstr, char* in) +{ + BOOL rc; + int i; + char outstr[32]; + int out = -1; + + for( i = 1; ; i++ ) { + /* 犯伉立正ㄠ勾内勾 戈 */ + rc = getStringFromIndexWithDelim( srcstr, "|", i, outstr, sizeof(outstr)); + if( rc == FALSE) break; + if( strstr( outstr, in) != NULL ) { + out = textToInt( outstr); + break; + } + } + + return out; +} + +char *NPC_Util_GetStrFromStrWithDelim( char *srcstr, char *srhstr, + char *buf, int buflen) +{ + BOOL rc; + char *cret = NULL; + int i; + char outstr[1024]; + char outstr2[1024]; + + memset( outstr, 0, sizeof( outstr)); + memset( outstr2, 0, sizeof( outstr2)); + buf[0] = '\0'; + for( i = 1; ; i++ ) { + rc = getStringFromIndexWithDelim( srcstr, "|", i, outstr, sizeof(outstr)); + if( rc == FALSE) break; + if( strstr( outstr, srhstr) != NULL) { + rc = getStringFromIndexWithDelim( outstr, ":", 2, outstr2, sizeof(outstr2)); + if( rc != FALSE ) { + strcpysafe( buf, buflen, outstr2 ); + cret = buf; + break; + } + } + } + return cret; +} + +inline double NPC_Util_sellRate( int seller ) +{ + return (CHAR_getInt( seller, CHAR_MERCHANTLEVEL)&0x0000ffff)*0.01; +} + +inline double NPC_Util_buyRate( int buyer ) +{ + return (CHAR_getInt( buyer, CHAR_MERCHANTLEVEL )>>16)*0.01; +} + +BOOL NPC_Util_IsVisiblePlayer( int meindex) +{ + int chr_fl,chr_x,chr_y, i, j; + BOOL found = FALSE; + + chr_fl = CHAR_getInt( meindex, CHAR_FLOOR); + chr_x = CHAR_getInt( meindex, CHAR_X); + chr_y = CHAR_getInt( meindex, CHAR_Y); + + for( i = chr_x-CHAR_DEFAULTSEESIZ/2 ; + i <= chr_x+CHAR_DEFAULTSEESIZ/2 && found == FALSE; i++ ){ + for( j = chr_y-CHAR_DEFAULTSEESIZ/2 ; + j <= chr_y+CHAR_DEFAULTSEESIZ/2 && found == FALSE; + j ++ ){ + OBJECT object; + for( object = MAP_getTopObj( chr_fl, i,j); + object; + object = NEXT_OBJECT(object) ) + { + int objindex = GET_OBJINDEX( object); + if( OBJECT_getType(objindex) == OBJTYPE_CHARA ){ + if( CHAR_getInt( OBJECT_getIndex(objindex), + CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ) + { + found = TRUE; + break; + } + } + } + } + } + return( found); +} + +BOOL NPC_Util_WordInclude( char *text , char *word ) +{ + if( strstr( text , word ) == NULL ){ + return FALSE; + } else { + return TRUE; + } +} + +void NPC_Util_RandomToken(char *in, char *out, int outbufsize ) +{ + int tokennum; + int i; + tokennum = 1; + for( i=0;in[i]!='\0';i++ ){ + if( in[i] == ',' ) tokennum++; + } + getStringFromIndexWithDelim(in,",", rand()%tokennum+1,out,outbufsize ); + +} + +void cutDotsTail( char *s ) +{ + int l = strlen( s ); + int i; + for(i=l-1;i>=0;i--){ + if( s[i] == '.' ){ + s[i] = 0; + } else { + break; + } + } +} + +int NPC_Util_FrontItem( int meindex ) +{ + int front_x, front_y,objindex,itemindex; + OBJECT obj; + + CHAR_getCoordinationDir( CHAR_getInt(meindex,CHAR_DIR) + , CHAR_getInt(meindex,CHAR_X) + , CHAR_getInt(meindex,CHAR_Y) + ,1, &front_x, &front_y ); + for( obj=MAP_getTopObj(CHAR_getInt(meindex,CHAR_FLOOR), + front_x,front_y );obj; + obj=NEXT_OBJECT(obj) ){ + objindex = GET_OBJINDEX(obj); + if( OBJECT_getType(objindex) == OBJTYPE_ITEM ){ + itemindex = OBJECT_getIndex(objindex); + if(ITEM_CHECKINDEX(itemindex) ){ + return itemindex; + }else{ + return -1; + } + } + } + + return -1; + +} + +int NPC_Util_FrontChar( int meindex ) +{ + int front_x, front_y,objindex,enemyindex; + OBJECT obj; + CHAR_getCoordinationDir( CHAR_getInt(meindex,CHAR_DIR) + , CHAR_getInt(meindex,CHAR_X) + , CHAR_getInt(meindex,CHAR_Y) + ,1, &front_x, &front_y ); + for( obj=MAP_getTopObj(CHAR_getInt(meindex,CHAR_FLOOR), + front_x,front_y );obj; + obj=NEXT_OBJECT(obj) ){ + objindex = GET_OBJINDEX(obj); + if( OBJECT_getType(objindex) == OBJTYPE_CHARA ){ + enemyindex = OBJECT_getIndex(objindex); + if(CHAR_CHECKINDEX(enemyindex) ){ + return enemyindex; + } + } + } + return -1; +} +static int NPCUtil_enemytbl[NPC_ENEMY_ENEMYNUMBER+1]; +int *NPC_Util_getEnemy( int meindex, int charaindex) +{ + int i; + char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; + char buf[64]; + int ret; + int bigcnt; + int insert; + + NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)); + for( i = 0; i < NPC_ENEMY_ENEMYNUMBER+1; i ++ ) { + NPCUtil_enemytbl[i] = -1; + } + + if( NPC_Util_GetStrFromStrWithDelim( argstr, "enemyno", buf, sizeof( buf)) + == NULL ) + { + return NULL; + } + bigcnt = 0; + insert = 0; + + for( i = 0; i < NPC_ENEMY_ENEMYNUMBER; i ++ ) { + int curEnemy; + int et_array; + char data[128]; + + ret = getStringFromIndexWithDelim( buf,",", i + 1,data, sizeof(data)); + if( ret == FALSE) { + break; + } + + curEnemy = ENEMY_getEnemyArrayFromId( atoi( data)); + if( !ENEMY_CHECKINDEX( curEnemy) ) continue; + et_array = ENEMYTEMP_getEnemyTempArray( curEnemy ); + /* 扔奶术互 五中及互中凶凛及啃及岈太赘尹 */ + if( ENEMYTEMP_getInt( et_array, E_T_SIZE ) == E_T_SIZE_BIG) { + if( bigcnt >= 5 ) { + continue; + } + /* 桦赭互 卞卅匀化中凶桦宁反 木晶尹月 */ + if( insert > 4 ) { + int target_et_array; + int flg = FALSE; + int j; + /* 木月桦赭毛茧允 */ + for( j = 0; j < 5; j ++ ) { + /* 坞中化月及反云井仄中 */ + if( !ENEMY_CHECKINDEX( NPCUtil_enemytbl[j])) break; + + target_et_array = ENEMYTEMP_getEnemyTempArray( + NPCUtil_enemytbl[j]); + /* 云井仄中 */ + if( !ENEMYTEMP_CHECKINDEX( target_et_array)) break; + + /* 木医歹木月 */ + if( ENEMYTEMP_getInt( target_et_array, E_T_SIZE) + == E_T_SIZE_NORMAL ) + { + flg = TRUE; + break; + } + } + if( !flg) continue; + + NPCUtil_enemytbl[insert] = NPCUtil_enemytbl[j]; + NPCUtil_enemytbl[j] = curEnemy; + } + else { + NPCUtil_enemytbl[insert] = curEnemy; + } + bigcnt ++; + } + else { + NPCUtil_enemytbl[insert] = curEnemy; + } + insert ++; + } + return NPCUtil_enemytbl; +} + +/*==================动票}白仿弘申永玄楮溢=============================*/ + +/* 奶矛件玄蔽 + * 申永玄白仿弘毛 化月分仃及质 + */ +void NPC_EventSetFlg(int talker,int shiftbit) + +{ + int point=0; + int array; + int shift; +#ifdef _TEACHER_SYSTEM + int iGetFame = 0; +#endif + + /*-- -1反白仿弘卞楮溢互卅中奶矛件玄 -*/ + if(shiftbit==-1) return; + + array = shiftbit / 32; + shift = shiftbit % 32; + + point = CHAR_getInt( talker, CHAR_ENDEVENT+array); + + // Arminius 8.24 prevent wash dp + if (!(point & (1 << shift))) { + // CoolFish: Family Adv 2001/8/4 + AddFMAdv(talker, shiftbit); +#ifdef _TEACHER_SYSTEM + if(shiftbit < arraysizeof(FMAdvTbl)) iGetFame = FMAdvTbl[shiftbit]; +#endif + } +#ifdef _TEACHER_SYSTEM + iGetFame /= 20; // 导师获得学生所得声望的 5% (1/20) + // 检查所得的声望有没有大於0 + if(iGetFame > 0){ + // 检查有没有导师 + if(strlen(CHAR_getChar(talker,CHAR_TEACHER_ID)) > 0 && strlen(CHAR_getChar(talker,CHAR_TEACHER_NAME)) > 0){ + int iPlayernum = CHAR_getPlayerMaxNum(),i; + char szMsg[128]; + + // 检查导师在不在线上 + for(i=0;i= arraysizeof(FMAdvTbl)) + return; + else + fmadv = FMAdvTbl[shiftbit]; + if (fmadv <= 0) return; + sprintf(buf, "%d", fmadv); + #ifdef _PERSONAL_FAME // Arminius 8.30: 家族个人声望 + CHAR_earnFame(talker, fmadv); + #endif + #ifdef _NEW_MANOR_LAW + sprintf(buf1, "%d", CHAR_getInt(talker,CHAR_FAME)); + #endif +#ifdef _FMVER21 + if (CHAR_getInt(talker, CHAR_FMLEADERFLAG) > 0 + && CHAR_getInt(talker, CHAR_FMLEADERFLAG) != FMMEMBER_APPLY) + { + // CoolFish: 2001/10/03 + int fd = getfdFromCharaIndex(talker); + saacproto_ACFixFMData_send(acfd, + CHAR_getChar(talker, CHAR_FMNAME), + CHAR_getInt(talker, CHAR_FMINDEX), + CHAR_getWorkInt(talker, CHAR_WORKFMINDEXI), + FM_FIX_FMADV, buf, +#ifndef _NEW_MANOR_LAW + "", +#else + buf1, +#endif + // CoolFish: 2001/10/03 + CHAR_getWorkInt(talker, CHAR_WORKFMCHARINDEX), + CONNECT_getFdid(fd)); + // CHAR_getWorkInt(talker, CHAR_WORKFMCHARINDEX), 0); +#ifdef _NEW_MANOR_LAW + { + int i; + for(i=0;i +#include + +#include "version.h" + +#include "common.h" +#include "npctemplate.h" +#include "npccreate.h" + +BOOL NPC_readNPCSettingFiles( char* topdirectory ,int templatesize, int createsize) +{ + print("\n"); + if( NPC_readNPCTemplateFiles( topdirectory ,templatesize) == FALSE ) + return FALSE; + + if( NPC_readNPCCreateFiles( topdirectory ,createsize) == FALSE ) + return FALSE; + + return TRUE; +} diff --git a/gmsv/npcserver.c b/gmsv/npcserver.c new file mode 100644 index 0000000..92bf691 --- /dev/null +++ b/gmsv/npcserver.c @@ -0,0 +1,407 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "autil.h" +#include "util.h" +#include "net.h" +#include "char.h" +#include "char_base.h" +#include "log.h" +#include "handletime.h" +#include "npcserver.h" +#include "lssproto_serv.h" +//#include "chatmagic.h" +#include "lssproto_util.h" + +#ifdef _NPCSERVER_NEW +#include "npcshandle.h" +#define SEPARATOR ";" + +NPCMessC *NPCMess; +static int AskListOK = 0; +//Mserver NETProc +int NSproto_DispatchMessage(int fd,char* encoded) +{ + char funcname[1024]; + if( NPCMESS_setChar( encoded) == FALSE ) + return -1; + memset( funcname, 0, sizeof( funcname)); + if( NPCMESS_getChar( funcname, sizeof( funcname)) == FALSE ) { + return 0; + } + if( !strcmp( funcname , "TEST" )){ + char buf1[1024],buf2[1024],buf3[1024]; + if( NPCMESS_getChar( buf1, sizeof( buf1)) == FALSE ) return 0; + if( NPCMESS_getChar( buf2, sizeof( buf2)) == FALSE ) return 0; + if( NPCMESS_getChar( buf3, sizeof( buf3)) == FALSE ) return 0; + return 0; + }else if( !strcmp( funcname , "NPC_LOGIN" )){ + char buf1[256]; + if( NPCMESS_getChar( buf1, sizeof( buf1)) == FALSE ) return 0; + NPCS_NpcSLogin_recv( fd, buf1); + }else if( !strcmp( funcname , "NPC_ASKLIST" )){ + char buf1[4096]; + if( NPCMESS_getChar( buf1, sizeof( buf1)) == FALSE ) return 0; + NPCS_AskNpcList_recv( fd, buf1); + return 0; + }else if( !strcmp( funcname , "NPCS_CREATE" )){ + int dir, floor, x, y, image, npcsindex; + char Name[256], buf1[256]; + if( NPCMESS_getChar( buf1, sizeof( buf1)) == FALSE ) return 0; + npcsindex = atoi( buf1); + if( NPCMESS_getChar( buf1, sizeof( buf1)) == FALSE ) return 0; + memcpy( Name, buf1, strlen( buf1)+1); + if( NPCMESS_getChar( buf1, sizeof( buf1)) == FALSE ) return 0; + dir = atoi( buf1); + if( NPCMESS_getChar( buf1, sizeof( buf1)) == FALSE ) return 0; + image = atoi( buf1); + if( NPCMESS_getChar( buf1, sizeof( buf1)) == FALSE ) return 0; + floor = atoi( buf1); + if( NPCMESS_getChar( buf1, sizeof( buf1)) == FALSE ) return 0; + x = atoi( buf1); + if( NPCMESS_getChar( buf1, sizeof( buf1)) == FALSE ) return 0; + y = atoi( buf1); + + if( NPCSERVER_CreateObjindexFromServer( fd, npcsindex, Name, image, dir, floor, x, y) == FALSE ){ + } + return 0; + }else if( !strcmp( funcname , "NPC_TALKMESS" )){ + char TalkMess[1024], buf1[1024]; + int npcobjindex, charaindex, charobjindex, Color; + if( NPCMESS_getChar( buf1, sizeof( buf1)) == FALSE ) return 0; + npcobjindex = atoi( buf1); + if( NPCMESS_getChar( buf1, sizeof( buf1)) == FALSE ) return 0; + charaindex = atoi( buf1); + if( NPCMESS_getChar( buf1, sizeof( buf1)) == FALSE ) return 0; + charobjindex = atoi( buf1); + if( NPCMESS_getChar( buf1, sizeof( buf1)) == FALSE ) return 0; + memcpy( TalkMess, buf1, strlen( buf1)+1 ); + if( NPCMESS_getChar( buf1, sizeof( buf1)) == FALSE ) return 0; + Color = atoi( buf1); + NPCS_NpcTalkMess_recv( npcobjindex, charaindex, charobjindex, TalkMess, Color); + }else if( !strcmp( funcname , "NPC_WINMESS") ){ + int charaindex, charobjindex, npcobjindex; + int seqno, windowtype, buttontype, page; + char Token[1024], buf1[1024]; + + if( NPCMESS_getChar( buf1, sizeof( buf1)) == FALSE ) return 0; + npcobjindex = atoi( buf1); + if( NPCMESS_getChar( buf1, sizeof( buf1)) == FALSE ) return 0; + charaindex = atoi( buf1); + if( NPCMESS_getChar( buf1, sizeof( buf1)) == FALSE ) return 0; + charobjindex = atoi( buf1); + if( NPCMESS_getChar( buf1, sizeof( buf1)) == FALSE ) return 0; + memcpy( Token, buf1, strlen( buf1)+1); + Token[ strlen( Token)+1] = 0; + if( NPCMESS_getChar( buf1, sizeof( buf1)) == FALSE ) return 0; + seqno = atoi( buf1); + if( NPCMESS_getChar( buf1, sizeof( buf1)) == FALSE ) return 0; + windowtype = atoi( buf1); + if( NPCMESS_getChar( buf1, sizeof( buf1)) == FALSE ) return 0; + buttontype = atoi( buf1); + if( NPCMESS_getChar( buf1, sizeof( buf1)) == FALSE ) return 0; + page = atoi( buf1); + NPCS_NpcWinMess_recv( npcobjindex, charaindex, charobjindex, Token, + seqno, windowtype, buttontype, page); + }else if( !strcmp( funcname , "NPC_CHECKFREE") ){ + int charaindex, charobjindex, npcobjindex; + char buf1[4096], freeMess1[4096]; + if( NPCMESS_getChar( buf1, sizeof( buf1)) == FALSE ) return 0; + npcobjindex = atoi( buf1); + if( NPCMESS_getChar( buf1, sizeof( buf1)) == FALSE ) return 0; + charaindex = atoi( buf1); + if( NPCMESS_getChar( buf1, sizeof( buf1)) == FALSE ) return 0; + charobjindex = atoi( buf1); + if( NPCMESS_getChar( buf1, sizeof( buf1)) == FALSE ) return 0; + memcpy( freeMess1, buf1, strlen( buf1)+1); + + NPCS_NpcCheckFreeMess_recv( npcobjindex, charaindex, charobjindex, freeMess1); + }else{ + + } + return 0; +} + +void NPCS_NpcCheckFreeMess_recv( int npcobjindex, int charaindex, int charobjindex, + char *CheckfreeMess) +{ + if( NPCS_HandleCheckFreeMess( npcobjindex, charaindex, charobjindex, + CheckfreeMess) == TRUE ){ + }else { + } +} + +void NPCS_NpcWinMess_recv( int npcobjindex, int charaindex, int charobjindex, char *WinMess, + int seqno, int windowtype, int buttontype, int page) +{ + int fd = getfdFromCharaIndex( charaindex); + if( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX) != charobjindex ) + return; + CHAR_setWorkInt( charaindex, CHAR_WORKSHOPRELEVANT, page); + lssproto_WN_send( fd, windowtype, buttontype, seqno, npcobjindex, WinMess); +} + +void NPCS_NpcWinMess_send( int npcobjindex, int npcindex, int charaindex, char *WinMess, + int seqno, int select) +{ + char buf[4096]; + int charobjindex, page; + memset( buf, 0, sizeof( buf)); + charobjindex = CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX); + page = CHAR_getWorkInt( charaindex, CHAR_WORKSHOPRELEVANT); + sprintf( buf, "NPC_WINMESS %d %d %d %d %s %d %d %d\n", npcindex, npcobjindex, charaindex, charobjindex, + WinMess, seqno, select, page); + lssproto_Send( npcfd, buf); +} + +void NPCS_AskNpcTalk_send( int objindex, int npcsindex, int charaindex, char *Nlist) +{//NPCS_TALK + char buf[4096]; + int charobjindex; + if( !CHAR_CHECKINDEX( charaindex) ) return; + memset( buf, 0, sizeof( buf)); + charobjindex = CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX); + sprintf( buf, "NPCS_TALK %d %d %d %d %s\n", npcsindex, objindex, charaindex, charobjindex, Nlist); + lssproto_Send( npcfd, buf); +} + +void NPCS_AskNpcList_recv( int fd, char *Nlist) +{ + char Npclist[256]; + int i=1, createnpc = 0; + while( getStringFromIndexWithDelim( Nlist, "|", i, Npclist,sizeof(Npclist) ) != FALSE ){ + char buf1[256], NpcName[256]; + int npcsindex, dir, floor, x, y, image; + i++; + if( getStringFromIndexWithDelim( Npclist, ",", 1, buf1, sizeof( buf1)) == FALSE ) continue; + npcsindex = atoi( buf1); + if( getStringFromIndexWithDelim( Npclist, ",", 2, buf1, sizeof( buf1)) == FALSE ) continue; + memcpy( NpcName, buf1, strlen( buf1)+1); + if( getStringFromIndexWithDelim( Npclist, ",", 3, buf1, sizeof( buf1)) == FALSE ) continue; + dir = atoi( buf1); + if( getStringFromIndexWithDelim( Npclist, ",", 4, buf1, sizeof( buf1)) == FALSE ) continue; + image = atoi( buf1); + if( getStringFromIndexWithDelim( Npclist, ",", 5, buf1, sizeof( buf1)) == FALSE ) continue; + floor = atoi( buf1); + if( getStringFromIndexWithDelim( Npclist, ",", 6, buf1, sizeof( buf1)) == FALSE ) continue; + x = atoi( buf1); + if( getStringFromIndexWithDelim( Npclist, ",", 7, buf1, sizeof( buf1)) == FALSE ) continue; + y = atoi( buf1); + NpcName[ strlen( NpcName)+1] = 0; + if( NPCSERVER_CreateObjindexFromServer( fd, npcsindex, NpcName, image, dir, floor, x, y) == FALSE ){ + }else{ + createnpc++; + } + } +} + +void NPCS_AskNpcList_send( int fd) +{ + char buf[4096]; + memset( buf, 0, sizeof( buf)); + sprintf( buf, "NPC_ASKLIST\n"); + lssproto_Send(fd, buf); +} + +void NPCS_NpcSLogin_recv( int fd, char *Mess) +{ + if( !strcmp( Mess, "OK") ){ + if( AskListOK == 0 ){ + NPCS_AskNpcList_send( fd); + AskListOK = 1; + } + }else { + } +} + +void NPCS_NpcSLogin_send( int fd) +{ + char buf[4096]; + memset( buf, 0, sizeof( buf)); + sprintf( buf, "NPC_LOGIN ABC\n"); + lssproto_Send(fd, buf); +} + +void NPCS_NpcTalkMess_recv( int npcobjindex, int charaindex, int charobjindex, char *TalkMess, int Color) +{ + NPCS_NpcstalkToCli( charaindex, npcobjindex, TalkMess, Color); +} + +int connectNpcServer(char* hostname,unsigned short port) +{ + struct sockaddr_in sock; + struct hostent* hoste; + int fd,lr; + fd_set fdset,fde; + struct timeval tmv; + + memset( &sock , 0 , sizeof( struct sockaddr_in ) ); + sock.sin_family = AF_INET; + sock.sin_port = htons( port ); + sock.sin_addr.s_addr = inet_addr( hostname ); + + if( sock.sin_addr.s_addr == -1 ){ + hoste = gethostbyname( hostname ); + if( hoste == NULL ){ + print( "获取主机名: %s\n", hostname); + return -1; + } + memcpy((void*)&sock.sin_addr.s_addr , hoste->h_addr , sizeof(struct in_addr) ); + } + + fd = socket( AF_INET, SOCK_STREAM , 0 ); + if( fd == -1 ){ + print("Cannot Create Socket( errno:%d)\n",errno ); + return -1; + } + //set the no block + if ( fcntl(fd,F_SETFL,O_NONBLOCK) == -1 ){ + print("set noblock error!\n"); + return -1; + } + lr = connect(fd,(struct sockaddr*)&sock,sizeof(struct sockaddr_in)); + if( lr != 0 ){ + if ( errno != EINPROGRESS ){ + print("Cannot connect. (errno:%d)\n",errno ); + close(fd); + return -1; + } + } + FD_ZERO(&fdset); + FD_SET(fd,&fdset); + FD_SET(fd,&fde); + tmv.tv_sec =3; + tmv.tv_usec = 0; + lr=select(fd+1,NULL,&fdset,&fde,&tmv); + if (FD_ISSET(fd,&fde)){ + print("connectNPCS fde\n"); + close(fd); //add more + return -1; + } + if ( lr > 0 && FD_ISSET(fd,&fdset)){ + int errorcode; + int errorcodelen; + errorcode=1; + errorcodelen=sizeof(errorcode); + getsockopt(fd,SOL_SOCKET,SO_ERROR,&errorcode,&errorcodelen); + if (errorcode == 0 ){ + fcntl(fd,F_SETFL,0); + print("connectNPCS return fd=%d\n",fd); + return fd; + }else{ + print("connectNPCS errorcode error\n"); + close(fd); + return -1; + } + }else{ + close(fd); + return -1; + } + +} + +void NPCS_SendProbe( int fd) +{ + char buf[65535]; + int i; + + memset( buf, 0, sizeof( buf)); + + sprintf( buf, "TEST %d,%d,%s,%s", 99999, 99999, + "1234567891012345678901234567890", "1234567891012345678901234567890" ); + + strcat( buf, " "); + for( i=0; i<5; i++) { + if( i==0 ) strcat( buf, "99999"); + else strcat( buf, ",99999"); + } + strcat( buf, " "); + for( i=0; i<15; i++) { + if( i==0 ) strcat( buf, "99999"); + strcat( buf, ",99999"); + } + + strcat( buf, "\n"); + lssproto_Send(fd, buf); +} + +BOOL NPCMESS_setChar( char *buf) +{ + char Mbuf[4096]; + int i=0,j=0; + int len=0; + NPCMessC *Works; + NPCMessC *point; + point = NULL; + + memset( Mbuf, 0, sizeof( Mbuf)); + sprintf( Mbuf, "%s", buf); + NPCMess = NULL; + while( Mbuf[i] != '\0' ) { + if( Mbuf[i] == '\n' ) + Mbuf[i] = '\0'; + i++; + } + i=0; + len = 0; + while( Mbuf[i] != '\0' && Mbuf[j] != '\0' ) { + j=i; + len = 0; + while( Mbuf[j] != ' ' && Mbuf[j] != '\0') { + len++; + j++; + } + Works = MESS_getNew(); + if( Works == NULL ) + return FALSE; + memcpy( Works->buf, &Mbuf[i], len); + Works->len = len; + if( NPCMess == NULL ) { + NPCMess = Works; + point = Works; + }else { + point->next = Works; + point = point->next; + } + i = (j+1); + } + return TRUE; +} + + +BOOL NPCMESS_getChar( char *buf, int len) +{ + NPCMessC *Works; + Works = NPCMess; + + if( Works == NULL ) + return FALSE; + memcpy( buf, Works->buf, len); + buf[ strlen( buf)+1] = 0; + NPCMess = Works->next; + free( Works); + return TRUE; +} + +NPCMessC *MESS_getNew() +{ + NPCMessC *MBUF=NULL; + MBUF = (NPCMessC *) calloc( 1, sizeof( struct _NPCMessCommand) ); + if( MBUF == NULL ) + return NULL; + memset( MBUF->buf, 0, sizeof( MBUF->buf)); + MBUF->len = 0; + MBUF->next = NULL; + return MBUF; +} +#endif diff --git a/gmsv/npcshandle.c b/gmsv/npcshandle.c new file mode 100644 index 0000000..64e74e8 --- /dev/null +++ b/gmsv/npcshandle.c @@ -0,0 +1,322 @@ +#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 diff --git a/gmsv/object.c b/gmsv/object.c new file mode 100644 index 0000000..135f347 --- /dev/null +++ b/gmsv/object.c @@ -0,0 +1,483 @@ +#include "version.h" +#include + +#include +#include +#include +#include + +#include "common.h" +#include "object.h" +#include "char_base.h" +#include "char.h" +#include "item.h" +#include "buf.h" +#include "readmap.h" +#include "pet.h" + +static Object *obj; +static int objnum; + +#ifndef _SIMPLIFY_ITEMSTRING +static int Restored = FALSE; +#endif + +BOOL initObjectArray( int num ) +{ + int i; + objnum = num; + obj = allocateMemory( sizeof( Object ) * objnum ); + if( obj == NULL ) return FALSE; + for( i = 0 ; i < objnum ; i ++ ){ + memset( &obj[i], 0 , sizeof( Object )); + obj[i].type = OBJTYPE_NOUSE; + } + return TRUE; +} + + +BOOL endObjectArray( void ) +{ + freeMemory( obj ); + return TRUE; +} + +INLINE int _initObjectOne( char *file, int line, Object* ob ) +{ + static int allocobjnum = 0; + int i; + BOOL first; + + i = allocobjnum; + first = TRUE; + while( 1 ) { + if( !first && i >= allocobjnum ) { + fprint( "Can't allocate an object\n" ); + return -1; + } + if( obj[i].type == OBJTYPE_NOUSE ) { + if( MAP_addNewObj( ob->floor ,ob->x, ob->y, i ) == 1 ){ + memcpy( &obj[i] , ob , sizeof( Object ) ); + allocobjnum = ( i+1 >= objnum) ? 0:i+1; + return i; + }else{ + allocobjnum = ( i+1 >= objnum) ? 0:i+1; + fprint( "MAP_addNewObj error\n" ); + return -1; + } + }else { + if( ++i >= objnum ) { + i = 0; + first = FALSE; + } + } + } + + fprint( "Can't allocate an object\n" ); + return -1; +} + +void endObjectOne( int index ) +{ + if(objnum <= index || index < 0 )return; + + if( MAP_removeObj(obj[index].floor,obj[index].x, obj[index].y, + index) == FALSE){ + //fprint( "REMOVE OBJ ERROR floor:%d x:%d y:%d\n",obj[index].floor,obj[index].x, obj[index].y ); + } + obj[index].type = OBJTYPE_NOUSE; +} + +BOOL CHECKOBJECT( int index ) +{ + if( 0<=index && indextype = OBJTYPE_ITEM; + else if( strcmp( token , STOREGOLDID ) == 0 ) + one->type = OBJTYPE_GOLD; + else if( strcmp( token, STORECHARID) == 0 ) + one->type = OBJTYPE_CHARA; + for( i = 2 ; i < 5 ; i ++ ){ + char first[64]; + char second[64]; + ret = getStringFromIndexWithDelim(line,"|" ,i, + token,sizeof( token )); + if( ret == FALSE )return FALSE; + + ret = getStringFromIndexWithDelim(token,"=" ,1, first,sizeof( first )); + if( ret == FALSE )return FALSE; + ret = getStringFromIndexWithDelim(token,"=" ,2, second,sizeof( second )); + if( ret == FALSE )return FALSE; + + if( strcmp( first , "x" ) == 0 ) + one->x = atoi( second ); + else if( strcmp( first , "y" ) == 0 ) + one->y = atoi( second ); + else if( strcmp( first , "floor" ) == 0 ) + one->floor = atoi( second ); + } + { + char* findex = nindex( line , '|' , 4); + *stringstart = findex + 1; + } + return TRUE; +} + +BOOL storeObjects( char* dirname ) +{ + int i; + FILE* igfile; + char igfilename[256]; + + if( Restored == TRUE ){ + snprintf( igfilename ,sizeof( igfilename ) ,"%s/%s" ,dirname , + ITEMGOLDSTOREFILENAME ); + }else{ + snprintf( igfilename ,sizeof( igfilename ) ,"%s/%s_extra" ,dirname , + ITEMGOLDSTOREFILENAME ); + + print( "\n---- Saving didn't do with gmsv. ----- \n"); + print( "---- It is because gmsv stopped before reading . ----- \n"); + print( "---- It is kept with a name of (%s) just in case. ----- \n", igfilename ); + } + igfile = fopen( igfilename , "w" ); + if( igfile == NULL ){ + print( "\n\n---- ERR:can not open (%s) for backup items. ----- \n\n", igfilename ); + return FALSE; + } + + print( "Store Objects ..."); + for( i = 0 ; i < objnum ; i ++ ){ + switch( obj[i].type ){ + case OBJTYPE_ITEM: + { + fprintf( igfile , STOREITEMID "|x=%d|y=%d|floor=%d|%s\n" , + obj[i].x , obj[i].y ,obj[i].floor, + ITEM_makeStringFromItemIndex( obj[i].index,0 ) ); + break; + } + case OBJTYPE_GOLD: + { + fprintf( igfile , STOREGOLDID "|x=%d|y=%d|floor=%d|%d\n" , + obj[i].x , obj[i].y ,obj[i].floor, obj[i].index ); + break; + } + case OBJTYPE_CHARA: + { + int petindex = obj[i].index; + if( CHAR_CHECKINDEX( petindex) ) { + if( CHAR_getInt( obj[i].index, CHAR_WHICHTYPE) == CHAR_TYPEPET){ + fprintf( igfile , STORECHARID "|x=%d|y=%d|floor=%d|%s\n" , + obj[i].x , obj[i].y ,obj[i].floor, + CHAR_makePetStringFromPetIndex( obj[i].index ) ); + } + } + break; + } + default: + break; + } + } + fclose( igfile ); + print( "done\n"); +system( "./itemda.pl" ); + print( "item backup end\n"); + return TRUE; +} +#endif + +int detectStoreFile( char* filename ) +{ + FILE* f; + char buffer[10]; + f = fopen ( filename ,"r" ); + if( f == NULL )return 3; + + if( fgets( buffer, sizeof( buffer ), f ) == NULL ){ + fclose(f); + return 3; + } + + if( strncmp(buffer,STOREITEMID,sizeof(STOREITEMID) ) == 0 || + strncmp(buffer,STOREGOLDID,sizeof(STOREGOLDID) ) == 0 ){ + fclose(f); + return 2; + } + + fclose(f); + return 3; +} + +#ifndef _SIMPLIFY_ITEMSTRING +BOOL restoreObjects( char* dirname ) +{ + char igfilename[512]; + FILE* file; + char line[2048]; + + snprintf( igfilename, sizeof(igfilename), "%s/%s", dirname, ITEMGOLDSTOREFILENAME ); + file = fopen( igfilename , "r" ); + if( file == NULL ){ + Restored = TRUE; + return FALSE; + } + while( fgets( line, sizeof( line ), file ) != NULL ){ + Object one; + char *string; + chomp( line ); + if( checkObjectStoreFile( line, &one ,&string ) == FALSE ) + continue; + switch( one.type ){ + case OBJTYPE_ITEM: + { + ITEM_Item itmone; + BOOL ret; + int objindex; + ret = ITEM_makeExistItemsFromStringToArg( string, &itmone, 0 ); + if( ret == TRUE ){ + one.index = ITEM_initExistItemsOne( &itmone ); + if( one.index == -1 ) break; + objindex = initObjectOne( &one ); + ITEM_setWorkInt(one.index,ITEM_WORKCHARAINDEX,-1); + ITEM_setWorkInt(one.index,ITEM_WORKOBJINDEX,objindex); + } + break; + } + + case OBJTYPE_GOLD: + one.index = atoi( string ); + initObjectOne( &one ); + break; + case OBJTYPE_CHARA: + { + Char ch; + int ret; + ret = CHAR_makePetFromStringToArg(string,&ch, -1); + if( ret ) { + Object object; + int objindex; + int petindex = PET_initCharOneArray( &ch ); + if( petindex < 0 ) { + print( "宠物制作失败。\n"); + } + object.type = OBJTYPE_CHARA; + object.index = petindex; + object.x = ch.data[CHAR_X]; + object.y = ch.data[CHAR_Y]; + object.floor = ch.data[CHAR_FLOOR]; + objindex = initObjectOne( &object ); + if( objindex == -1 ) { + CHAR_endCharOneArray( petindex ); + }else { + CHAR_setWorkInt( petindex,CHAR_WORKOBJINDEX,objindex ); + } + } + break; + } + default: + break; + } + } + fclose( file ); + Restored = TRUE; + + return TRUE; +} +#endif diff --git a/gmsv/saacproto_cli.c b/gmsv/saacproto_cli.c new file mode 100644 index 0000000..0136294 --- /dev/null +++ b/gmsv/saacproto_cli.c @@ -0,0 +1,2166 @@ +#include "version.h" +#define _SAACPROTOCLI_C_ +#include "version.h" +#include "saacproto_cli.h" +#include +#include +#include +#include "common.h" +#include "net.h" + +#ifdef _SEND_EFFECT // WON ADD AC送下雪、下雨等特效 +#include "chatmagic.h" +#endif + +#define IS_2BYTEWORD( _a_ ) ( (char)(0x80) <= (_a_) && (_a_) <= (char)(0xFF) ) + +/* +90 :
  • clienttoserver ACServerLogin(string servername,string serverpas);
    +91 : 必□丞扔□田□互失市它件玄扔□田□卞夫弘奶件允月午五卞银丹[ +92 : 涛粮毛舰匀凶丐午}仇及夫弘奶件毛仄卅中午允屯化及扔□申旦毛仄卅中[ +93 :

    +94 :
    +95 :
    string servername +96 :
    扔□田□ [acserv.cf卞涩烂今木化中月[ +97 :
    string serverpas +98 :
    扔□田□由旦伐□玉[acserv.cf卞涩烂今木化中月[ +99 :
    +100 : +*/ + +#ifdef _ALLDOMAN // (不可开) Syu ADD 排行榜NPC +void saacproto_UpdataStele_send( int fd , char *cdkey , char *name , char *title , int level , int trns , int time , int floor) { + saacproto_CreateHeader( saacproto.work , "UpdataStele" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( cdkey ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( name ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( title ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( level ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( trns ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( time ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( floor ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} +#endif + + +void saacproto_ACServerLogin_send( int fd,char* servername,char* serverpas ) +{ + saacproto_CreateHeader( saacproto.work , "ACServerLogin" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( servername ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( serverpas ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} +/* +114 :
  • clienttoserver ACServerLogout(void);
    +115 : 扔□田□互失市它件玄扔□田□井日夫弘失它玄允月午五卞银丹[ +116 : 涛粮反扔□田卞方匀化 澎卞濠日木月[仄凶互匀化仇木卞覆允月失市它件玄扔□田 +117 : 及忒蚕反戊生弁扑亦件毛濠月仪匹丐月[ +118 :
    +119 :
    +120 :
    +121 : +122 : +*/ + +void saacproto_ACServerLogout_send( int fd ) +{ + saacproto_CreateHeader( saacproto.work , "ACServerLogout" ); + saacproto_strcatsafe( saacproto.work , "" ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} + +#ifdef _PKSEVER_VER +void saacproto_ACCharList_send( int fd,char* id,char* pas,int mesgid, int star) +#else +void saacproto_ACCharList_send( int fd,char* id,char* pas,int mesgid ) +#endif +{ + saacproto_CreateHeader( saacproto.work , "ACCharList" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( id ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( pas ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( mesgid ) ,saacproto.workbufsize ); + +#ifdef _PKSEVER_VER + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( star ) ,saacproto.workbufsize ); +#endif + saacproto_Send( fd , saacproto.work ); +} + +void saacproto_ACCharLoad_send( int fd,char* id,char* pas,char* charname,int lock,char* opt,int mesgid ) +{ + saacproto_CreateHeader( saacproto.work , "ACCharLoad" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( id ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( pas ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( charname ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( lock ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( opt ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( mesgid ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} + +#ifdef _NEWSAVE +void saacproto_ACCharSave_send( int fd,char* id,char* charname,char* opt,char* charinfo,int unlock,int mesgid,int saveindex ) +#else +void saacproto_ACCharSave_send( int fd,char* id,char* charname,char* opt,char* charinfo,int unlock,int mesgid ) +#endif +{ + saacproto_CreateHeader( saacproto.work , "ACCharSave" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( id ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( charname ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( opt ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( charinfo ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( unlock ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( mesgid ) ,saacproto.workbufsize ); +#ifdef _NEWSAVE + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( saveindex ) ,saacproto.workbufsize ); +#endif + saacproto_Send( fd , saacproto.work ); +} + +#ifdef _PAUCTION_MAN +void saacproto_ACItemAuction_send( int fd, char *ITEMNAME, char *data, int itemID, int ret, int flg) +{ + print("ACItemAuction( %d, %s, %s, %d, %d)\n", fd, ITEMNAME, data, itemID, flg); + saacproto_CreateHeader( saacproto.work , "AUCTIONADDITEM" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( ITEMNAME ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( data ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( itemID ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( ret ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( flg ) ,saacproto.workbufsize ); + + saacproto_Send( fd , saacproto.work ); +} +#endif + +void saacproto_ACCharDelete_send( int fd,char* id,char* passwd,char* charname,char* option,int mesgid ) +{ + saacproto_CreateHeader( saacproto.work , "ACCharDelete" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( id ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( passwd ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( charname ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( option ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( mesgid ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} + +void saacproto_ACLock_send( int fd,char* id,int lock,int mesgid ) +{ + saacproto_CreateHeader( saacproto.work , "ACLock" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( id ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( lock ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( mesgid ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} + +void saacproto_ACUCheck_send( int fd,char* mem_id,int status ) +{ + saacproto_CreateHeader( saacproto.work , "ACUCheck" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( mem_id ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( status ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} + +void saacproto_DBUpdateEntryString_send( int fd,char* table,char* key,char* value,int msgid,int msgid2 ) +{ + saacproto_CreateHeader( saacproto.work , "DBUpdateEntryString" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( table ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( key ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( value ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid2 ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} + +void saacproto_DBDeleteEntryString_send( int fd,char* table,char* key,int msgid,int msgid2 ) +{ + saacproto_CreateHeader( saacproto.work , "DBDeleteEntryString" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( table ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( key ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid2 ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} + +void saacproto_DBGetEntryString_send( int fd,char* table,char* key,int msgid,int msgid2 ) +{ + saacproto_CreateHeader( saacproto.work , "DBGetEntryString" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( table ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( key ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid2 ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} + +void saacproto_DBUpdateEntryInt_send( int fd,char* table,char* key,int value,char* info,int msgid,int msgid2 ) +{ + saacproto_CreateHeader( saacproto.work , "DBUpdateEntryInt" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( table ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( key ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( value ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( info ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid2 ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} + +void saacproto_DBGetEntryRank_send( int fd,char* table,char* key,int msgid,int msgid2 ) +{ + saacproto_CreateHeader( saacproto.work , "DBGetEntryRank" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( table ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( key ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid2 ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} + +void saacproto_DBDeleteEntryInt_send( int fd,char* table,char* key,int msgid,int msgid2 ) +{ + saacproto_CreateHeader( saacproto.work , "DBDeleteEntryInt" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( table ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( key ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid2 ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} + +void saacproto_DBGetEntryInt_send( int fd,char* table,char* key,int msgid,int msgid2 ) +{ + saacproto_CreateHeader( saacproto.work , "DBGetEntryInt" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( table ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( key ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid2 ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} + +void saacproto_DBGetEntryByRank_send( int fd,char* table,int rank_start,int rank_end,int msgid,int msgid2 ) +{ + saacproto_CreateHeader( saacproto.work , "DBGetEntryByRank" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( table ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( rank_start ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( rank_end ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid2 ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} + +void saacproto_DBGetEntryByCount_send( int fd,char* table,int count_start,int num,int msgid,int msgid2 ) +{ + saacproto_CreateHeader( saacproto.work , "DBGetEntryByCount" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( table ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( count_start ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( num ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid2 ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} +/* +608 :
  • clienttoserver Broadcast( string id, string charname, string message , int flag );
    +609 : 必□丞扔□田□卞覆仄化仇及戊穴件玉毛霜耨允月午} +610 : 允屯化及必□丞扔□田□卞凶中仄化 元丢永本□斥互霜耨今木月[ +611 : id , charname 反方仁勾井歹木月及匹}蜊 及娄醒毛手勾方丹卞仄凶[ +612 : 中切中切 侬 由□旦及伙□民件毛踏井卅仁化手中中方丹卞[ +613 :
    +614 :
    string id +615 :
    user ID +616 :
    string charname +617 :
    平乓仿 (巨旦弗□皿卅仄) +618 :
    string message +619 :
    霜今木月丢永本□斥[必□丞扔□田□互驯五卞银丹[ +620 :
    +*/ + +void saacproto_Broadcast_send( int fd,char* id,char* charname,char* message,int flag ) +{ + saacproto_CreateHeader( saacproto.work , "Broadcast" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( id ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( charname ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( message ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( flag ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} +/* +634 :
  • clienttoserver Message( string id_from, string charname_from, string id_to, string charname_to, string message , int option );
    +635 : 奶件旦正件玄丢永本□斥毛霜耨允月 +636 :
    +637 :
    string id_from +638 :
    from ID +639 :
    string charname_from +640 :
    from Character name +641 :
    string id_to +642 :
    to ID +643 :
    string charname_to +644 :
    to character name +645 :
    string message +646 :
    丢永本□斥 +647 :
    int option +648 :
    左皿扑亦件[民乓永玄及缙午井中欠中欠 木木月[漆 及傀舰迕 +649 : 仇木毛升丹银丹井反必□丞扔□田□及 澎匹}失市它件玄扔□田□反 +650 : 域濠仇及 卞正永民仄卅中 +651 :
    +*/ + +void saacproto_Message_send( int fd,char* id_from,char* charname_from,char* id_to,char* charname_to,char* message,int option ) +{ + saacproto_CreateHeader( saacproto.work , "Message" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( id_from ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( charname_from ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( id_to ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( charname_to ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( message ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( option ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} + +void saacproto_MessageAck_send( int fd,char* id,char* charname,char* result,int mesgid ) +{ + saacproto_CreateHeader( saacproto.work , "MessageAck" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( id ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( charname ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( result ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( mesgid ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} + +void saacproto_MessageFlush_send( int fd,char* id,char* charname ) +{ + saacproto_CreateHeader( saacproto.work , "MessageFlush" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( id ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( charname ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} + +/************************************************************ + * CoolFish: Family 2001/5/18 + ***********************************************************/ +#ifdef _PERSONAL_FAME +void saacproto_ACAddFM_send(int fd, char *fmname, char *fmleadername, + char *fmleaderid, int fmleaderlv, char *petname, char *petattr, + char *fmrule, int fmsprite, int fmleadergrano, int fame, int charfdid) +#else +void saacproto_ACAddFM_send(int fd, char *fmname, char *fmleadername, + char *fmleaderid, int fmleaderlv, char *petname, char *petattr, + char *fmrule, int fmsprite, int fmleadergrano, int charfdid) +#endif +{ + saacproto_CreateHeader(saacproto.work, "ACAddFM"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(fmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(fmleadername), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(fmleaderid), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmleaderlv), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(petname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(petattr), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(fmrule), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmsprite), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmleadergrano), saacproto.workbufsize); +// #ifdef _PERSONAL_FAME + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fame), saacproto.workbufsize); +// #endif + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charfdid), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 +void saacproto_ACJoinFM_send(int fd, char *fmname, int fmindex, char *charname, + char *charid, int charlv, int index, int fame, int charfdid) +#else +void saacproto_ACJoinFM_send(int fd, char *fmname, int fmindex, char *charname, + char *charid, int charlv, int index, int charfdid) +#endif +{ + saacproto_CreateHeader(saacproto.work, "ACJoinFM"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(fmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(charname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(charid), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charlv), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(index), saacproto.workbufsize); +// #ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fame), saacproto.workbufsize); +// #endif + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charfdid), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +void saacproto_ACLeaveFM_send(int fd, char *fmname, int fmindex, char *charname, + char *charid, int index, int charfdid) +{ + saacproto_CreateHeader(saacproto.work, "ACLeaveFM"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(fmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(charname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(charid), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(index), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charfdid), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +void saacproto_ACDelFM_send(int fd, char *fmname, int fmindex, int index, + char *charname, char *charid, int charfdid) +{ + saacproto_CreateHeader(saacproto.work, "ACDelFM"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(fmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(index), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(charname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(charid), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charfdid), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} + +void saacproto_ACShowFMList_send(int fd) +{ + saacproto_CreateHeader(saacproto.work, "ACShowFMList"); + saacproto_Send(fd, saacproto.work); +} + +#ifdef _DEATH_FAMILY_GM_COMMAND // WON ADD 家族战GM指令 +void saacproto_ACShowMemberList_2_send( int fd, int charaindex, int fm1, int fm2, int time, int id ) +{ + saacproto_CreateHeader(saacproto.work, "ACShowMemberList2"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charaindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fm1), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fm2), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(time), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(id), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +#endif + + +void saacproto_ACShowMemberList_send(int fd, int index) +{ + saacproto_CreateHeader(saacproto.work, "ACShowMemberList"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string("MemberList"), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(index), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +void saacproto_ACFMDetail_send(int fd, char *fmname, int fmindex, int index, int charfdid) +{ + saacproto_CreateHeader(saacproto.work, "ACFMDetail"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(fmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(index), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charfdid), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +#ifdef _FMVER21 +void saacproto_ACMemberJoinFM_send(int fd, char *fmname, int fmindex, + char *charname, int charindex, int index, int result, int meindex, + int charfdid) +#else +void saacproto_ACMemberJoinFM_send(int fd, char *fmname, int fmindex, + char *charname, int charindex, int index, int result, int charfdid) +#endif +{ + saacproto_CreateHeader(saacproto.work, "ACMemberJoinFM"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(fmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(charname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(index), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(result), saacproto.workbufsize); +#ifdef _FMVER21 + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(meindex), saacproto.workbufsize); +#endif + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charfdid), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +#ifdef _FMVER21 +void saacproto_ACMemberLeaveFM_send(int fd, char *fmname, int fmindex, + char *charname, int charindex, int index, int meindex, int charfdid) +#else +void saacproto_ACMemberLeaveFM_send(int fd, char *fmname, int fmindex, + char *charname, int charindex, int index, int charfdid) +#endif +{ + saacproto_CreateHeader(saacproto.work, "ACMemberLeaveFM"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(fmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(charname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(index), saacproto.workbufsize); +#ifdef _FMVER21 + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(meindex), saacproto.workbufsize); +#endif + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charfdid), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +#ifdef _FM_MODIFY +void saacproto_ACFMCharLogin_send(int fd, char *fmname, int fmindex, char *charname, + char *charid, int charlv, int eventflag, int charfdid,int gsnum) +#else + #ifdef _FMVER21 + void saacproto_ACFMCharLogin_send(int fd, char *fmname, int fmindex, char *charname, + char *charid, int charlv, int eventflag, int charfdid) + #else + void saacproto_ACFMCharLogin_send(int fd, char *fmname, int fmindex, char *charname, + char *charid, int charlv, int charfdid) + #endif +#endif +{ + saacproto_CreateHeader(saacproto.work, "ACFMCharLogin"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(fmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(charname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(charid), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charlv), saacproto.workbufsize); +#ifdef _FMVER21 + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(eventflag), saacproto.workbufsize); +#endif + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charfdid), saacproto.workbufsize); +#ifdef _FM_MODIFY + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(gsnum), saacproto.workbufsize); +#endif + saacproto_Send(fd, saacproto.work); +} + + +#ifdef _DEATH_FAMILY_LOGIN_CHECK // WON ADD 家族战登入检查 +void saacproto_new_ACFM_Login_send( int acfd, int charaindex, char *char_id, char *char_name ) +{ + saacproto_CreateHeader(saacproto.work, "ACFMCharLogin2"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(char_id), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(char_name), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charaindex), saacproto.workbufsize); + saacproto_Send( acfd, saacproto.work ); +} +#endif + +#ifdef _DEATH_FAMILY_GM_COMMAND // WON ADD 家族战GM指令 +void saacproto_ReloadFamily_send( int acfd, int charaindex ) +{ + saacproto_CreateHeader(saacproto.work, "ACRELOADFM"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charaindex), saacproto.workbufsize); + saacproto_Send( acfd, saacproto.work ); +} +#endif + + +void saacproto_ACFMCharLogout_send(int fd, char *fmname, int fmindex, char *charname, + char *charid, int charlv, int index, int charfdid) +{ + saacproto_CreateHeader(saacproto.work, "ACFMCharLogout"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(fmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(charname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(charid), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charlv), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(index), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charfdid), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +void saacproto_ACFMReadMemo_send(int fd, int index) +{ + saacproto_CreateHeader(saacproto.work, "ACFMReadMemo"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string("ReadMemo"), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(index), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +void saacproto_ACFMWriteMemo_send(int fd, char *fmname, int fmindex, + char *data, int index) +{ + saacproto_CreateHeader(saacproto.work, "ACFMWriteMemo"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(fmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(data), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(index), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +void saacproto_ACFMPointList_send(int fd) +{ + saacproto_CreateHeader(saacproto.work, "ACFMPointList"); + saacproto_Send(fd, saacproto.work); +} + +#ifdef _CK_ONLINE_PLAYER_COUNT // WON ADD 计算线上人数 +void saacproto_GS_PLAYER_COUNT_SEND(int acfd, int num) +{ + saacproto_CreateHeader(saacproto.work, "ACGSPCOUNT"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(num), saacproto.workbufsize); + saacproto_Send(acfd, saacproto.work); +} +#endif + + +void saacproto_ACSetFMPoint_send(int fd, char *fmname, int fmindex, int index, + int fmpointindex, int fl, int x, int y, int charfdid) +{ + saacproto_CreateHeader(saacproto.work, "ACSetFMPoint"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(fmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(index), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmpointindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fl), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(x), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(y), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charfdid), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +void saacproto_ACFixFMPoint_send(int fd, char *winfmname, int winfmindex, + int winindex, char *losefmname, int losefmindex, int loseindex, + int village) +{ + saacproto_CreateHeader(saacproto.work, "ACFixFMPoint"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(winfmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(winfmindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(winindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(losefmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(losefmindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(loseindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(village), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +void saacproto_ACFMAnnounce_send(int fd, char *fmname, int fmindex, int index, + char *data, int color) +{ + saacproto_CreateHeader(saacproto.work, "ACFMAnnounce"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(fmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(index), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(data), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(color), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +void saacproto_ACShowTopFMList_send(int fd, int kindflag) +{ + saacproto_CreateHeader(saacproto.work, "ACShowTopFMList"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string("ShowTopFMList"), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(kindflag), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} + +void saacproto_ACFixFMData_send(int fd, char *fmname, int fmindex, int index, + int kindflag, char *data1, char *data2, int charindex, int charfdid) +{ + saacproto_CreateHeader(saacproto.work, "ACFixFMData"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(fmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(index), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(kindflag), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(data1), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(data2), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charfdid), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +#ifdef _FAMILYBANKSTONELOG +void saacproto_ACgetFMBankgold_send(int fd, char *fmname, int fmindex, int index, + int charindex, int charfdid) +{ + saacproto_CreateHeader(saacproto.work, "ACgetFMBankgold"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(fmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(index), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charfdid), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +#endif + + +#ifdef _DEATH_FAMILY_STRUCT // WON ADD 家族战存放胜负资料 +void saacproto_Init_FM_PK_STRUC_send( int fd ) +{ + saacproto_CreateHeader(saacproto.work, "FMINITPKSTRUCT"); + saacproto_Send(fd, saacproto.work); +} + +void saacproto_FM_PK_STRUCT_send( int fd, char *msg ) +{ + saacproto_CreateHeader(saacproto.work, "FMPKSTRUCT"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(msg), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +#endif + +void saacproto_ACFixFMPK_send(int fd, char *winfmname, int winfmindex, + int winindex, char *losefmname, int losefmindex, int loseindex) +{ + saacproto_CreateHeader(saacproto.work, "ACFixFMPK"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(winfmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(winfmindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(winindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(losefmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(losefmindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(loseindex), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +void saacproto_ACGMFixFMData_send(int fd, int index, char *charid, char *cmd, + char *data, int charfdid) +{ + saacproto_CreateHeader(saacproto.work, "ACGMFixFMData"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string("ACGMFixFMData"), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(index), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(charid), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(cmd), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(data), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charfdid), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +void saacproto_ACGetFMData_send(int fd, char *fmname, int fmindex, int index, + int kindflag, int charfdid) +{ + saacproto_CreateHeader(saacproto.work, "ACGetFMData"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(fmname), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(index), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(kindflag), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(charfdid), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} + +// Arminius 7.26 manor pk acknowledge +void saacproto_ACManorPKAck_send(int fd, char *data) +{ + saacproto_CreateHeader(saacproto.work, "ACManorPKAck"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(data), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} + +void saacproto_ACreLoadFmData_send( int fd, int type, int data) +{ + saacproto_CreateHeader( saacproto.work, "ACreLoadFmData"); + saacproto_strcatsafe( saacproto.work, saacproto_mkstr_int( type), saacproto.workbufsize); + saacproto_strcatsafe( saacproto.work, saacproto_mkstr_int( data), saacproto.workbufsize); + saacproto_Send( fd, saacproto.work); +} + +#ifdef _ACFMPK_LIST +void saacproto_ACLoadFmPk_send(int fd, int fmpks_pos) +{ + saacproto_CreateHeader(saacproto.work, "ACLoadFmPk"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmpks_pos), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} + + +void saacproto_ACSendFmPk_send(int fd, int toindex, int PkFlg, int fmpks_pos, char *msg) +{ + saacproto_CreateHeader(saacproto.work, "ACSendFmPk"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(fmpks_pos), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int( toindex), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int( PkFlg), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(msg), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} +#endif + + +#ifdef _RECAL_ASK_PLAYER // WON 要求人物资料 +void saacproto_Recal_Player_send(int acfd, char *uid, int userfdid, int GmCliId, char *id, int char_num, int date, int backup_flag) +{ + saacproto_CreateHeader(saacproto.work, "ACSendRecalPlayer"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(uid), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(userfdid), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(GmCliId), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(id), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(char_num), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(date), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(backup_flag), saacproto.workbufsize); + saacproto_Send(acfd, saacproto.work); +} + +void saacproto_Recal_Backup_send(int acfd, char *uid, int userfdid, int GmCliId, char *id, int char_num, int date, char *char_data, int backup_flag) +{ + saacproto_CreateHeader(saacproto.work, "ACSendRecalBackup"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(uid), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(userfdid), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(GmCliId), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(id), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(char_num), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(date), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(char_data), saacproto.workbufsize); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_int(backup_flag), saacproto.workbufsize); + saacproto_Send(acfd, saacproto.work); +} +#endif // end RECAL_ASK_PLAYER + +void saacproto_ACAuctionSold_send(int fd, char *data) +{ + saacproto_CreateHeader(saacproto.work, "ACAuctionSold"); + saacproto_strcatsafe(saacproto.work, saacproto_mkstr_string(data), saacproto.workbufsize); + saacproto_Send(fd, saacproto.work); +} + +int saacproto_ClientDispatchMessage(int fd ,char*line) +{ + int msgid; + char funcname[1024]; + saacproto_strcpysafe( saacproto.work , line, saacproto.workbufsize ); + saacproto_splitString( saacproto.work); + saacproto_GetMessageInfo( &msgid , funcname , sizeof(funcname),saacproto.token_list); + +#ifdef _ANDYLOG_TEST + print( "funcname:%s , line len:%d\n", funcname, strlen( line)); +#endif + + if( strcmp( funcname , "ACGmsvDownRequest" ) == 0 ){ + int min; + min = saacproto_demkstr_int( saacproto.token_list[2] ); + saacproto_ACGmsvDownRequest_recv( fd,min); + return 0; + } + + if( strcmp( funcname , "ACServerLogin" ) == 0 ){ + char* result; + char* data; + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + data = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + saacproto_ACServerLogin_recv( fd,result,data); + return 0; + } + + if( strcmp( funcname , "ACCharList" ) == 0 ){ + char* result; + char* output; + int id; + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + output = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + id = saacproto_demkstr_int( saacproto.token_list[4] ); + + saacproto_ACCharList_recv( fd,result,output,id); + return 0; + } + + if( strcmp( funcname , "ACCharLoad" ) == 0 ){ + char* result=NULL; + char* data=NULL; + int id; +#ifdef _NEWSAVE + int saveindex; +#endif + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + data = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + id = saacproto_demkstr_int( saacproto.token_list[4] ); + if( data == NULL ) return 0; + if( result == NULL ) return 0; + +#ifdef _NEWSAVE + saveindex = saacproto_demkstr_int( saacproto.token_list[5] ); + saacproto_ACCharLoad_recv( fd,result,data,id,saveindex); +#else + saacproto_ACCharLoad_recv( fd,result,data,id, -1); +#endif + return 0; + } + + if( strcmp( funcname , "ACCharSave" ) == 0 ){ + char* result; + char* data; + int id; + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + data = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + id = saacproto_demkstr_int( saacproto.token_list[4] ); + saacproto_ACCharSave_recv( fd,result,data,id); + return 0; + } + +#ifdef _DEATH_CONTEND + if( strcmp( funcname , "PKLISTGETDATA" ) == 0 ){ + char* result; + char* data; + int ti; + + ti = saacproto_demkstr_int( saacproto.token_list[2] ); + data = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + result = saacproto_wrapStringAddr( saacproto_stringwrapper[3] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[4] )); + saacproto_LoadPkTeamListData_recv( fd, result, data, ti); + return 0; + } + + if( strcmp( funcname , "PKLISTCHARTS" ) == 0 ){ + char* data; + int type, flg; + data = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + type = saacproto_demkstr_int( saacproto.token_list[3] ); + flg = saacproto_demkstr_int( saacproto.token_list[4] ); + + saacproto_PKLISTCHARTS_recv( fd, data, type, flg); + return 0; + } + +#endif + +#ifdef _PAUCTION_MAN + if( strcmp( funcname , "AUCTIONADDITEM" ) == 0 ){ + int itemID; + char *name; + char *data; + int flg, ret; + + name = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + data = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + itemID = saacproto_demkstr_int( saacproto.token_list[4] ); + ret = saacproto_demkstr_int( saacproto.token_list[5] ); + flg = saacproto_demkstr_int( saacproto.token_list[6] ); + saacproto_ACItemAuction_recv( fd, name, data, itemID, ret, flg); + + return 0; + } +#endif + + if( strcmp( funcname , "ACCharDelete" ) == 0 ){ + char* result; + char* data; + int id; + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + data = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + id = saacproto_demkstr_int( saacproto.token_list[4] ); + saacproto_ACCharDelete_recv( fd,result,data,id); + return 0; + } + + if( strcmp( funcname , "ACLock" ) == 0 ){ + char* result; + char* data; + int id; + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + data = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + id = saacproto_demkstr_int( saacproto.token_list[4] ); + saacproto_ACLock_recv( fd,result,data,id); + return 0; + } + +#ifdef _WAEI_KICK + if( strcmp( funcname , "ACKick" ) == 0 ){ + int act; + char* data; + int id; + act = saacproto_demkstr_int( saacproto.token_list[2] ); + data = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + id = saacproto_demkstr_int( saacproto.token_list[4] ); + saacproto_ACKick_recv( fd, act, data, id); + return 0; + } +#endif + +#ifdef _NEW_PLAYERGOLD + if( strcmp( funcname , "LoadNEWPlayer" ) == 0 ){ + char* data; + int charaindex; + charaindex = saacproto_demkstr_int( saacproto.token_list[2] ); + data = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + saacproto_LoadNEWPlayer_recv( fd, charaindex, data); + return 0; + } +#endif + +#ifdef _CHAR_POOLITEM + + if( strcmp( funcname , "ACSavePoolItem" ) == 0 ){ + char* result; + char* data; + int id; + + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + data = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + id = saacproto_demkstr_int( saacproto.token_list[4] ); + saacproto_ACCharSavePoolItem_recv( fd, result, data, id); + return 0; + } + + if( strcmp( funcname , "ACGetPoolItem" ) == 0 ){ + char* result; + char* data; + int id, npcid; + + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + data = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + id = saacproto_demkstr_int( saacproto.token_list[4] ); + npcid = saacproto_demkstr_int( saacproto.token_list[5] ); + saacproto_ACCharGetPoolItem_recv( fd, result, data, id, npcid); + return 0; + } +#endif + + +#ifdef _CHAR_POOLPET + + if( strcmp( funcname , "ACSavePoolPet" ) == 0 ){ + char* result; + char* data; + int id; + + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + data = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + id = saacproto_demkstr_int( saacproto.token_list[4] ); + saacproto_ACCharSavePoolPet_recv( fd, result, data, id); + return 0; + } + + if( strcmp( funcname , "ACGetPoolPet" ) == 0 ){ + char* result; + char* data; + int id, npcid; + + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + data = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + id = saacproto_demkstr_int( saacproto.token_list[4] ); + npcid = saacproto_demkstr_int( saacproto.token_list[5] ); + saacproto_ACCharGetPoolPet_recv( fd, result, data, id, npcid); + return 0; + } +#endif + + + +#ifdef _UNIVERSE_CHATROOM + if( strcmp( funcname , "ACUniChatroom" ) == 0 ){ + char* result; + char* data; + char *id; + int charaindex, clifdid; + + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + data = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + id = saacproto_wrapStringAddr( saacproto_stringwrapper[3] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[4] )); + charaindex = saacproto_demkstr_int( saacproto.token_list[5] ); + clifdid = saacproto_demkstr_int( saacproto.token_list[6] ); + + saacproto_ACUniChatroom_recv( fd, charaindex, clifdid, result, id, data); + return 0; + } + +#endif + if( strcmp( funcname , "ACUCheck" ) == 0 ){ + char* mem_id; + mem_id = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + saacproto_ACUCheck_recv( fd,mem_id); + return 0; + } +/* +354 :
  • servertoclient DBUpdateEntryString( string result, string table, string key, int msgid, int msgid2 );
    +355 : 晓及戊穴件玉及瑛绊[撩 仄化手荚汊尕第 卅及匹 骰仄化方中冗 +356 :
    +357 :
    string result +358 :
    successful 井failed +359 :
    string table +360 :
    +361 :
    int msgid +362 :
    +363 :
    int msgid2 +364 :
    +365 :
    +366 : +*/ + + if( strcmp( funcname , "DBUpdateEntryString" ) == 0 ){ + char* result; + char* table; + char* key; + int msgid; + int msgid2; + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + table = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + key = saacproto_wrapStringAddr( saacproto_stringwrapper[3] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[4] )); + msgid = saacproto_demkstr_int( saacproto.token_list[5] ); + msgid2 = saacproto_demkstr_int( saacproto.token_list[6] ); + saacproto_DBUpdateEntryString_recv( fd,result,table,key,msgid,msgid2); + return 0; + } +/* +379 :
  • servertoclient DBDeleteEntryString( string result, string table, string key , int msgid , int msgid2 );
    +380 : 侬 巨件玄伉及绰轮及瑛绊 +381 :
    +382 :
    string result +383 :
    successful / failed +384 :
    string table +385 :
    +386 :
    string key +387 :
    +388 :
    int msgid +389 :
    +390 :
    int msgid2 +391 :
    +392 :
    +393 : +*/ + + if( strcmp( funcname , "DBDeleteEntryString" ) == 0 ){ + char* result; + char* table; + char* key; + int msgid; + int msgid2; + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + table = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + key = saacproto_wrapStringAddr( saacproto_stringwrapper[3] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[4] )); + msgid = saacproto_demkstr_int( saacproto.token_list[5] ); + msgid2 = saacproto_demkstr_int( saacproto.token_list[6] ); + saacproto_DBDeleteEntryString_recv( fd,result,table,key,msgid,msgid2); + return 0; + } +/* +406 :
  • servertoclient DBGetEntryString( string result, string value, string table, string key, int msgid, int msgid2 );
    +407 : 潸曰分仄及忒曰袄 +408 :
    +409 :
    string result +410 :
    successful / failed +411 :
    string value +412 :
    袄 +413 :
    string table +414 :
    +415 :
    string key +416 :
    +417 :
    int msgid +418 :
    +419 :
    int msgid2 +420 :
    +421 :
    +422 : +*/ + + if( strcmp( funcname , "DBGetEntryString" ) == 0 ){ + char* result; + char* value; + char* table; + char* key; + int msgid; + int msgid2; + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + value = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + table = saacproto_wrapStringAddr( saacproto_stringwrapper[3] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[4] )); + key = saacproto_wrapStringAddr( saacproto_stringwrapper[4] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[5] )); + msgid = saacproto_demkstr_int( saacproto.token_list[6] ); + msgid2 = saacproto_demkstr_int( saacproto.token_list[7] ); + saacproto_DBGetEntryString_recv( fd,result,value,table,key,msgid,msgid2); + return 0; + } +/* +445 :
  • servertoclient DBUpdateEntryInt( string result , string table, string key, int msgid, int msgid2 );
    +446 : DBUpdateEntry及瑛绊[ +447 :
    +448 :
    string result +449 :
    succesful/failed +450 :
    string table +451 :
    □皮伙 毛公及引引井尹允 +452 :
    string key +453 :
    平□毛公及引引井尹允 +454 :
    int msgid, int msgid2 +455 :
    msgid 毛公及引引忒允[ +456 :
    +457 :

    +458 : +*/ + + if( strcmp( funcname , "DBUpdateEntryInt" ) == 0 ){ + char* result; + char* table; + char* key; + int msgid; + int msgid2; + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + table = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + key = saacproto_wrapStringAddr( saacproto_stringwrapper[3] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[4] )); + msgid = saacproto_demkstr_int( saacproto.token_list[5] ); + msgid2 = saacproto_demkstr_int( saacproto.token_list[6] ); + saacproto_DBUpdateEntryInt_recv( fd,result,table,key,msgid,msgid2); + return 0; + } +/* +473 :
  • servertoclient DBGetEntryRank( string result , int rank , int count, string table, string key, int msgid, int msgid2 );
    +474 : 赐匏毛忒允[ +475 :
    +476 :
    string result +477 :
    successful/failed +478 :
    int rank +479 :
    赐匏[1动晓及袄毛潸月[ +480 :
    int count +481 :
    晓井日中仁勾户井[ 赓及巨件玄伉反0井日反元引月[ +482 :
    string table +483 :
    □皮伙 毛公及引引井尹允 +484 :
    string key +485 :
    平□毛公及引引井尹允 +486 :
    int msgid, int msgid2 +487 :
    msgid 毛公及引引忒允 +488 :
    +489 :

    +490 : +491 : +*/ + + if( strcmp( funcname , "DBGetEntryRank" ) == 0 ){ + char* result; + int rank; + int count; + char* table; + char* key; + int msgid; + int msgid2; + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + rank = saacproto_demkstr_int( saacproto.token_list[3] ); + count = saacproto_demkstr_int( saacproto.token_list[4] ); + table = saacproto_wrapStringAddr( saacproto_stringwrapper[4] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[5] )); + key = saacproto_wrapStringAddr( saacproto_stringwrapper[5] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[6] )); + msgid = saacproto_demkstr_int( saacproto.token_list[7] ); + msgid2 = saacproto_demkstr_int( saacproto.token_list[8] ); + saacproto_DBGetEntryRank_recv( fd,result,rank,count,table,key,msgid,msgid2); + return 0; + } +/* +504 :
  • servertoclient DBDeleteEntryInt( string result , string table, string key, int msgid, int msgid2 );
    +505 : 绰轮及瑛绊 +506 :
    +507 :
    string result +508 :
    successful/failed +509 :
    string table +510 :
    □皮伙 毛公及引引井尹允 +511 :
    string key +512 :
    平□毛公及引引井尹允 +513 :
    int msgid, int msgid2 +514 :
    msgid 毛公及引引忒允 +515 :
    +516 :

    +517 : +*/ + + if( strcmp( funcname , "DBDeleteEntryInt" ) == 0 ){ + char* result; + char* table; + char* key; + int msgid; + int msgid2; + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + table = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + key = saacproto_wrapStringAddr( saacproto_stringwrapper[3] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[4] )); + msgid = saacproto_demkstr_int( saacproto.token_list[5] ); + msgid2 = saacproto_demkstr_int( saacproto.token_list[6] ); + saacproto_DBDeleteEntryInt_recv( fd,result,table,key,msgid,msgid2); + return 0; + } +/* +530 :
  • servertoclient DBGetEntryInt( string result , int value , string table, string key, int msgid, int msgid2 );
    +531 : 巨件玄伉及袄毛井尹允 +532 :
    +533 :
    string result +534 :
    successful/failed +535 :
    int value +536 :
    袄公及手及 +537 :
    string table +538 :
    □皮伙 毛公及引引井尹允 +539 :
    string key +540 :
    平□毛公及引引井尹允 +541 :
    int msgid, int msgid2 +542 :
    msgid 毛公及引引忒允 +543 :
    +544 : +545 : +546 : +*/ + + if( strcmp( funcname , "DBGetEntryInt" ) == 0 ){ + char* result; + int value; + char* table; + char* key; + int msgid; + int msgid2; + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + value = saacproto_demkstr_int( saacproto.token_list[3] ); + table = saacproto_wrapStringAddr( saacproto_stringwrapper[3] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[4] )); + key = saacproto_wrapStringAddr( saacproto_stringwrapper[4] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[5] )); + msgid = saacproto_demkstr_int( saacproto.token_list[6] ); + msgid2 = saacproto_demkstr_int( saacproto.token_list[7] ); + saacproto_DBGetEntryInt_recv( fd,result,value,table,key,msgid,msgid2); + return 0; + } +/* +562 :
  • servertoclient DBGetEntryByRank( string result , string list , string table, int msgid, int msgid2 );
    +563 : DBGetEntryByRank及瑛绊[ +564 :
    +565 :
    string result +566 :
    +567 :
    string list +568 :
    "RANK,KEY,SCORE,INFO|RANK,KEY,SCORE,INFO|...."
    +569 : RANK反赐匏匹丐月[KEY反公及赐匏卞卅匀化中月旦戊失毛手匀化中月 +570 : 平□[SCORE反帮醒袄匹旦戊失匹丐月[ +571 : [
    +572 : "1,RINGO,123465,data1|2,HOGE,4567,data2|2,FUCK,4567,data3"
    +573 : 仇及 分午}2匏反2谛中月仇午卞卅月[ +574 :
    string table +575 :
    □皮伙 +576 :
    int msgid, int msgid2 +577 :
    +578 :
    +579 : +580 : +*/ + + if( strcmp( funcname , "DBGetEntryByRank" ) == 0 ){ + char* result; + char* list; + char* table; + int msgid; + int msgid2; + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + list = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + table = saacproto_wrapStringAddr( saacproto_stringwrapper[3] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[4] )); + msgid = saacproto_demkstr_int( saacproto.token_list[5] ); + msgid2 = saacproto_demkstr_int( saacproto.token_list[6] ); + saacproto_DBGetEntryByRank_recv( fd,result,list,table,msgid,msgid2); + return 0; + } +/* +593 :
  • servertoclient DBGetEntryByCount( string result , string list , string table, int count_start, int msgid, int msgid2 );
    +594 : DBGetEntryByCount 及瑛绊[ +595 :
    +596 :
    string result +597 :
    SUCCESSFUL/FAILED +598 :
    string list +599 :
    请 伉旦玄[1巨件玄伉丐凶曰 "INDEX,RANK,KEY,SCORE,INFO" 及4蜊及树 +600 : 及赚匹丐曰}公木互蜊醒坌 "|" 匹勾卅互月[蜊醒互0及桦宁反 +601 : 坞 侬 [ +602 :
    int num +603 :
    中仁勾午曰分允井[1卅日1蜊[2卅日2蜊[ +604 :
    int msgid ,msgid2 +605 :
    丢永本□斥ID. +606 :
    +607 : +*/ + + if( strcmp( funcname , "DBGetEntryByCount" ) == 0 ){ + char* result; + char* list; + char* table; + int count_start; + int msgid; + int msgid2; + result = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + list = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + table = saacproto_wrapStringAddr( saacproto_stringwrapper[3] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[4] )); + count_start = saacproto_demkstr_int( saacproto.token_list[5] ); + msgid = saacproto_demkstr_int( saacproto.token_list[6] ); + msgid2 = saacproto_demkstr_int( saacproto.token_list[7] ); + saacproto_DBGetEntryByCount_recv( fd,result,list,table,count_start,msgid,msgid2); + return 0; + } +#ifdef _ALLDOMAN // (不可开) Syu ADD 排行榜NPC + if ( strcmp( funcname , "UpdataStele" ) == 0 ) { + char* token; + token = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + saacproto_UpdataStele_recv( fd , token) ; + return 0; + } + if ( strcmp( funcname , "S_UpdataStele" ) == 0 ) { + char* ocdkey; + char* oname; + char* ncdkey; + char* nname; + char* title; + int level; + int trns; + int floor; + ocdkey = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + oname = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + ncdkey = saacproto_wrapStringAddr( saacproto_stringwrapper[3] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[4] )); + nname = saacproto_wrapStringAddr( saacproto_stringwrapper[4] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[5] )); + title = saacproto_wrapStringAddr( saacproto_stringwrapper[5] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[6] )); + level = saacproto_demkstr_int( saacproto.token_list[7] ); + trns = saacproto_demkstr_int( saacproto.token_list[8] ); + floor = saacproto_demkstr_int( saacproto.token_list[9] ); + saacproto_S_UpdataStele_recv( fd , ocdkey , oname , ncdkey , nname , title , level , + trns , floor ); + return 0 ; + } +#endif +/* +621 :
  • servertoclient Broadcast( string id, string charname, string message );
    +622 : Broadcast及失市它件玄扔□田□井日必□丞扔□田□尺及霜耨迕 +623 :
    +624 :
    string id +625 :
    user ID +626 :
    string charname +627 :
    character name +628 :
    string message +629 :
    丢永本□斥 +630 :
    int flag +631 :
    1卞允月午}愤坌卞卞反 霜今木卅中[ +632 :
    +633 : +*/ + + if( strcmp( funcname , "Broadcast" ) == 0 ){ + char* id; + char* charname; + char* message; + id = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + charname = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + message = saacproto_wrapStringAddr( saacproto_stringwrapper[3] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[4] )); + saacproto_Broadcast_recv( fd,id,charname,message); + return 0; + } +/* +652 :
  • servertoclient Message( string id_from, string charname_from, string id_to, string charname_to, string message , int option , int mesgid );
    +653 : 失市它件玄扔□田□井日必□丞扔□田□卞丢永本□斥毛霜耨允月[ +654 :
    +655 :
    string id_from +656 :
    from ID +657 :
    string charname_from +658 :
    from character name +659 :
    string id_to +660 :
    to ID +661 :
    string charname_to +662 :
    to character name +663 :
    string message +664 :
    丢永本□斥及 +665 :
    int option +666 :
    左皿扑亦件(晓及楮醒毛辅寰) +667 :
    int mesgid +668 :
    丢永本□斥ID 失市它件玄扔□田□及栋 迕 +669 :
    +670 : +*/ + + if( strcmp( funcname , "Message" ) == 0 ){ + char* id_from; + char* charname_from; + char* id_to; + char* charname_to; + char* message; + int option; + int mesgid; + id_from = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + charname_from = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + id_to = saacproto_wrapStringAddr( saacproto_stringwrapper[3] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[4] )); + charname_to = saacproto_wrapStringAddr( saacproto_stringwrapper[4] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[5] )); + message = saacproto_wrapStringAddr( saacproto_stringwrapper[5] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[6] )); + option = saacproto_demkstr_int( saacproto.token_list[7] ); + mesgid = saacproto_demkstr_int( saacproto.token_list[8] ); + saacproto_Message_recv( fd,id_from,charname_from,id_to,charname_to,message,option,mesgid); + return 0; + } + + // CoolFish: Family 2001/5/9 + if( strcmp( funcname, "ACAddFM") == 0){ + int fmindex, index, charfdid; + char *result; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + fmindex = saacproto_demkstr_int(saacproto.token_list[3]); + index = saacproto_demkstr_int(saacproto.token_list[4]); + charfdid = saacproto_demkstr_int(saacproto.token_list[5]); + saacproto_ACAddFM_recv(fd, result, fmindex, charfdid, index); + return 0; + } + if( strcmp( funcname, "ACJoinFM") == 0){ + int charfdid, recv; + char *result; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + recv = saacproto_demkstr_int(saacproto.token_list[3]); + charfdid = saacproto_demkstr_int(saacproto.token_list[4]); + saacproto_ACJoinFM_recv(fd, result, recv, charfdid); + return 0; + } + if( strcmp( funcname, "ACLeaveFM") == 0){ + int charfdid, resultflag; + char *result; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + resultflag = saacproto_demkstr_int(saacproto.token_list[3]); + charfdid = saacproto_demkstr_int(saacproto.token_list[4]); + saacproto_ACLeaveFM_recv(fd, result, resultflag, charfdid); + return 0; + } + if( strcmp( funcname, "ACDelFM") == 0){ + int charfdid; + char *result; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + charfdid = saacproto_demkstr_int(saacproto.token_list[3]); + saacproto_ACDelFM_recv(fd, result, charfdid); + return 0; + } + if( strcmp( funcname, "ACShowFMList") == 0){ + int fmnum; + char *result, *data; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + fmnum = saacproto_demkstr_int(saacproto.token_list[3]); + data = saacproto_wrapStringAddr(saacproto_stringwrapper[3], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[4])); + saacproto_ACShowFMList_recv(fd, result, fmnum, data); + return 0; + } + +#ifdef _DEATH_FAMILY_GM_COMMAND // WON ADD 家族战GM指令 + if( strcmp( funcname, "ACRELOADFMOK") == 0){ + int charindex; + charindex = saacproto_demkstr_int(saacproto.token_list[2]); + saacproto_ACRELOADFMOK_recv( fd, charindex ); + return 0; + } + + if( strcmp( funcname, "ACSHOWMEMBERLIST2") == 0){ + int charaindex = -1, time = -1, id = -1, fm1 = -1, fm2 = -1; + char *fm1_name, *fm2_name; + + charaindex = saacproto_demkstr_int(saacproto.token_list[2]); + fm1 = saacproto_demkstr_int(saacproto.token_list[3]); + fm1_name = saacproto_wrapStringAddr(saacproto_stringwrapper[3], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[4])); + fm2 = saacproto_demkstr_int(saacproto.token_list[5]); + fm2_name = saacproto_wrapStringAddr(saacproto_stringwrapper[5], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[6])); + time = saacproto_demkstr_int(saacproto.token_list[7]); + id = saacproto_demkstr_int(saacproto.token_list[8]); + + saacproto_ACSHOWMEMBERLIST2_recv( fd, charaindex, fm1, fm1_name, fm2, fm2_name, time, id ); + + return 0; + } + +#endif + +#ifdef _DEATH_FAMILY_STRUCT // WON ADD 家族战存放胜负资料 + if( strcmp( funcname, "ACSendFmPkStruct") == 0){ + char *data; + + data = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + + saacproto_ACSendFmPkStruct_recv( fd, data ); + return 0; + } +#endif + +#ifdef _DEATH_FAMILY_LOGIN_CHECK // WON ADD 家族战登入检查 + if( strcmp( funcname, "ACSendMemberList") == 0){ + int charindex; + char *result, *data; + + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + charindex = saacproto_demkstr_int(saacproto.token_list[3]); + data = saacproto_wrapStringAddr(saacproto_stringwrapper[3], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[4])); + + saacproto_ACSendMember_recv( fd, result, data, charindex ); + return 0; + } +#endif + + if( strcmp( funcname, "ACShowMemberList") == 0){ + int index, fmmemnum, fmacceptflag, fmjoinnum; + char *result, *data; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + index = saacproto_demkstr_int(saacproto.token_list[3]); + fmmemnum = saacproto_demkstr_int(saacproto.token_list[4]); + fmacceptflag = saacproto_demkstr_int(saacproto.token_list[5]); + fmjoinnum = saacproto_demkstr_int(saacproto.token_list[6]); + data = saacproto_wrapStringAddr(saacproto_stringwrapper[6], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[7])); + saacproto_ACShowMemberList_recv(fd, result, index, fmmemnum, fmacceptflag, fmjoinnum, data); + return 0; + } + if( strcmp( funcname, "ACFMDetail") == 0){ + int charfdid; + char *result, *data; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + data = saacproto_wrapStringAddr(saacproto_stringwrapper[2], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[3])); + charfdid = saacproto_demkstr_int(saacproto.token_list[4]); + saacproto_ACFMDetail_recv(fd, result, data, charfdid); + return 0; + } + if( strcmp( funcname, "ACMemberJoinFM") == 0){ + int charfdid; + char *result, *data; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + data = saacproto_wrapStringAddr(saacproto_stringwrapper[2], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[3])); + charfdid = saacproto_demkstr_int(saacproto.token_list[4]); + saacproto_ACMemberJoinFM_recv(fd, result, data, charfdid); + return 0; + } + if( strcmp( funcname, "ACMemberLeaveFM") == 0){ + int charfdid; + char *result, *data; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + data = saacproto_wrapStringAddr(saacproto_stringwrapper[2], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[3])); + charfdid = saacproto_demkstr_int(saacproto.token_list[4]); + saacproto_ACMemberLeaveFM_recv(fd, result, data, charfdid); + return 0; + } + if( strcmp( funcname, "ACFMCharLogin") == 0){ + int charfdid, index, floor, fmdp, joinflag, fmsetupflag, flag, charindex; +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + int charfame; +#endif +#ifdef _NEW_MANOR_LAW + int momentum; +#endif + char *result; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + index = saacproto_demkstr_int(saacproto.token_list[3]); + floor = saacproto_demkstr_int(saacproto.token_list[4]); + fmdp = saacproto_demkstr_int(saacproto.token_list[5]); + joinflag = saacproto_demkstr_int(saacproto.token_list[6]); + fmsetupflag = saacproto_demkstr_int(saacproto.token_list[7]); + flag = saacproto_demkstr_int(saacproto.token_list[8]); + charindex = saacproto_demkstr_int(saacproto.token_list[9]); +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + charfame = saacproto_demkstr_int(saacproto.token_list[10]); + charfdid = saacproto_demkstr_int(saacproto.token_list[11]); + #ifdef _NEW_MANOR_LAW + momentum = saacproto_demkstr_int(saacproto.token_list[12]); + #endif + saacproto_ACFMCharLogin_recv(fd, result, index, floor, fmdp, + joinflag, fmsetupflag, flag, charindex, charfame, charfdid + #ifdef _NEW_MANOR_LAW + ,momentum + #endif + ); +#else + charfdid = saacproto_demkstr_int(saacproto.token_list[10]); + saacproto_ACFMCharLogin_recv(fd, result, index, floor, fmdp, + joinflag, fmsetupflag, flag, charindex, charfdid); +#endif + return 0; + } + if( strcmp( funcname, "ACFMCharLogout") == 0){ + int charfdid; + char *result; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + charfdid = saacproto_demkstr_int(saacproto.token_list[3]); + saacproto_ACFMCharLogout_recv(fd, result, charfdid); + return 0; + } + if( strcmp( funcname, "ACFMReadMemo") == 0){ + int index, num, dataindex; + char *result, *data; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + index = saacproto_demkstr_int(saacproto.token_list[3]); + num = saacproto_demkstr_int(saacproto.token_list[4]); + dataindex = saacproto_demkstr_int(saacproto.token_list[5]); + data = saacproto_wrapStringAddr(saacproto_stringwrapper[5], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[6])); + saacproto_ACFMReadMemo_recv(fd, result, index, num, dataindex, data); + return 0; + } + if( strcmp( funcname, "ACFMWriteMemo") == 0){ + int index; + char *result; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + index = saacproto_demkstr_int(saacproto.token_list[3]); + saacproto_ACFMWriteMemo_recv(fd, result, index); + return 0; + } + if( strcmp( funcname, "ACFMPointList") == 0){ + char *result, *data; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + data = saacproto_wrapStringAddr(saacproto_stringwrapper[2], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[3])); + saacproto_ACFMPointList_recv(fd, result, data); + return 0; + } + + + if( strcmp( funcname, "ACSetFMPoint") == 0){ + int charfdid, r; + char *result; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + r = saacproto_demkstr_int(saacproto.token_list[3]); + charfdid = saacproto_demkstr_int(saacproto.token_list[4]); + saacproto_ACSetFMPoint_recv(fd, result, r, charfdid); + return 0; + } + if( strcmp( funcname, "ACFixFMPoint") == 0){ + int r; + char *result; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + r = saacproto_demkstr_int(saacproto.token_list[3]); + saacproto_ACFixFMPoint_recv(fd, result, r); + return 0; + } + if( strcmp( funcname, "ACFMAnnounce") == 0){ + int fmindex, index, color, kindflag; + char *result, *fmname, *data; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + fmname = saacproto_wrapStringAddr(saacproto_stringwrapper[2], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[3])); + fmindex = saacproto_demkstr_int(saacproto.token_list[4]); + index = saacproto_demkstr_int(saacproto.token_list[5]); + kindflag = saacproto_demkstr_int(saacproto.token_list[6]); + data = saacproto_wrapStringAddr(saacproto_stringwrapper[6], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[7])); + color = saacproto_demkstr_int(saacproto.token_list[8]); + saacproto_ACFMAnnounce_recv(fd, result, fmname, fmindex, index, kindflag, data, color); + return 0; + } + if( strcmp( funcname, "ACShowTopFMList") == 0){ + int num, kindflag; + char *result, *data; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + kindflag = saacproto_demkstr_int(saacproto.token_list[3]); + num = saacproto_demkstr_int(saacproto.token_list[4]); + data = saacproto_wrapStringAddr(saacproto_stringwrapper[4], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[5])); + saacproto_ACShowTopFMList_recv(fd, result, kindflag, num, data); + return 0; + } + if( strcmp( funcname, "ACFixFMData") == 0){ + int kindflag, charfdid; + char *result, *data1, *data2; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + kindflag = saacproto_demkstr_int(saacproto.token_list[3]); + data1 = saacproto_wrapStringAddr(saacproto_stringwrapper[3], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[4])); + data2 = saacproto_wrapStringAddr(saacproto_stringwrapper[4], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[5])); + charfdid = saacproto_demkstr_int(saacproto.token_list[6]); + saacproto_ACFixFMData_recv(fd, result, kindflag, data1, data2, charfdid); + return 0; + } +#ifdef _FAMILYBANKSTONELOG + if( strcmp( funcname, "ACgetFMBankgold") == 0){ + int charfdid,r; + charfdid = saacproto_demkstr_int(saacproto.token_list[2]); + r=saacproto_demkstr_int(saacproto.token_list[3]); + saacproto_ACgetFMBankgold_recv(fd,charfdid,r); + return 0; + } +#endif + if( strcmp( funcname, "ACFixFMPK") == 0){ + int data, winindex, loseindex; + char *result; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + data = saacproto_demkstr_int(saacproto.token_list[3]); + winindex = saacproto_demkstr_int(saacproto.token_list[4]); + loseindex = saacproto_demkstr_int(saacproto.token_list[5]); + saacproto_ACFixFMPK_recv(fd, result, data, winindex, loseindex); + return 0; + } + if( strcmp( funcname, "ACGMFixFMData") == 0){ + int charfdid; + char *result, *fmname; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + fmname = saacproto_wrapStringAddr(saacproto_stringwrapper[2], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[3])); + charfdid = saacproto_demkstr_int(saacproto.token_list[4]); + saacproto_ACGMFixFMData_recv(fd, result, fmname, charfdid); + return 0; + } + if( strcmp( funcname, "ACGetFMData") == 0){ + int kindflag, charfdid, data; + char *result; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + kindflag = saacproto_demkstr_int(saacproto.token_list[3]); + data = saacproto_demkstr_int(saacproto.token_list[4]); + charfdid = saacproto_demkstr_int(saacproto.token_list[5]); + saacproto_ACGetFMData_recv(fd, result, kindflag, data, charfdid); + return 0; + } + if( strcmp( funcname, "ACFMClearPK") == 0){ + int fmindex, index; + char *result, *fmname; + result = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + fmname = saacproto_wrapStringAddr(saacproto_stringwrapper[2], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[3])); + fmindex = saacproto_demkstr_int(saacproto.token_list[4]); + index = saacproto_demkstr_int(saacproto.token_list[5]); + saacproto_ACFMClearPK_recv(fd, result, fmname, fmindex, index); + return 0; + } + // Arminius 7.26 manor pk acknowledge + if( strcmp( funcname, "ACManorPKAck") == 0){ + char *data; + data = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + saacproto_ACManorPKAck_recv(fd, data); + return 0; + } + +#ifdef _ACFMPK_LIST + if( strcmp( funcname, "ACLoadFmPk") == 0){ + char *data; + data = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + saacproto_ACLoadFmPk_recv( fd, data); + return 0; + } + if( strcmp( funcname, "ACSendFmPk") == 0){ + int toindex, flg; + toindex = saacproto_demkstr_int( saacproto.token_list[2] ); + flg =saacproto_demkstr_int( saacproto.token_list[3] ); + saacproto_ACSendFmPk_recv( fd, toindex, flg); + return 0; + } +#endif + + + +#ifdef _RECAL_ASK_PLAYER // WON 要求人物资料 + if( strcmp( funcname, "ACRecalPlayer") == 0){ // 线上人物资料 + char *uid, *id, *char_data; + int userfdid, char_num, date, GmCliId; + + uid = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + userfdid = saacproto_demkstr_int(saacproto.token_list[3]); + GmCliId = saacproto_demkstr_int(saacproto.token_list[4]); + id = saacproto_wrapStringAddr(saacproto_stringwrapper[4], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[5])); + char_num = saacproto_demkstr_int(saacproto.token_list[6]); + date = saacproto_demkstr_int(saacproto.token_list[7]); + char_data = saacproto_wrapStringAddr(saacproto_stringwrapper[7], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[8])); + + saacproto_ACRecalPlayer_recv(uid, userfdid, GmCliId, id, char_num, date, char_data); + return 0; + } + if( strcmp( funcname, "ACRecalBackupPlayer") == 0){ // 备份人物资料 + char *uid, *id, *char_data; + int userfdid, char_num, date, GmCliId; + + uid = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + userfdid = saacproto_demkstr_int(saacproto.token_list[3]); + GmCliId = saacproto_demkstr_int(saacproto.token_list[4]); + id = saacproto_wrapStringAddr(saacproto_stringwrapper[4], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[5])); + char_num = saacproto_demkstr_int(saacproto.token_list[6]); + date = saacproto_demkstr_int(saacproto.token_list[7]); + char_data = saacproto_wrapStringAddr(saacproto_stringwrapper[7], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[8])); + + saacproto_ACRecalBackupPlayer_recv(uid, userfdid, GmCliId, id, char_num, date, char_data); + return 0; + } + if( strcmp( funcname, "ACRecalBackupDate") == 0){ // 备份日期 + char *uid, *id, *char_data; + int userfdid, char_num, date, GmCliId; + + uid = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + userfdid = saacproto_demkstr_int(saacproto.token_list[3]); + GmCliId = saacproto_demkstr_int(saacproto.token_list[4]); + id = saacproto_wrapStringAddr(saacproto_stringwrapper[4], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[5])); + char_num = saacproto_demkstr_int(saacproto.token_list[6]); + date = saacproto_demkstr_int(saacproto.token_list[7]); + char_data = saacproto_wrapStringAddr(saacproto_stringwrapper[7], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[8])); + + saacproto_ACRecalBackupDate_recv(uid, userfdid, GmCliId, id, char_num, date, char_data); + return 0; + } + if( strcmp( funcname, "ACRecalAllBackupOK") == 0){ // 回溯ok + char *uid, *id, *char_data; + int userfdid, char_num, date, GmCliId; + + uid = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + userfdid = saacproto_demkstr_int(saacproto.token_list[3]); + GmCliId = saacproto_demkstr_int(saacproto.token_list[4]); + id = saacproto_wrapStringAddr(saacproto_stringwrapper[4], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[5])); + char_num = saacproto_demkstr_int(saacproto.token_list[6]); + date = saacproto_demkstr_int(saacproto.token_list[7]); + char_data = saacproto_wrapStringAddr(saacproto_stringwrapper[7], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[8])); + + saacproto_ACRecalAllBackupOK_recv(uid, userfdid, GmCliId, id, char_num, date, char_data); + return 0; + } +#endif + +#ifdef _NEW_PLAYERGOLD + if( strcmp( funcname, "ACNewPlayerList") == 0) + { + char *CdKey, *UserName; + int charaindex, RunType; + CdKey = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, + saacproto_demkstr_string(saacproto.token_list[2])); + UserName = saacproto_wrapStringAddr(saacproto_stringwrapper[2], saacproto.workbufsize, + saacproto_demkstr_string(saacproto.token_list[3])); + + charaindex = saacproto_demkstr_int(saacproto.token_list[4]); + RunType = saacproto_demkstr_int(saacproto.token_list[5]); + saacproto_ACNEWPlayerList_recv( fd, CdKey, UserName, charaindex, RunType); + return 0; + } +#endif +#ifdef _AUCTIONEER + if( strcmp(funcname, "ACAuctionSold") == 0){ + char *data; + data = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + saacproto_ACAuctionSold_recv(fd, data); + return 0; + } +#endif + +#ifdef _SEND_EFFECT // WON ADD AC送下雪、下雨等特效 + if( strcmp(funcname, "EFFECT") == 0){ + char *effect; + effect = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + print("\n AC send to GS weather effect !!"); + + CHAR_CHAT_DEBUG_sendeffect( fd, effect ); + return 0; + } +#endif + +#ifdef _GM_BROADCAST // WON ADD 客服公告系统 + if( strcmp(funcname, "GMBROADCAST") == 0){ + int time = 0, loop = 0, wait = 0; + char *msg; + + time = saacproto_demkstr_int(saacproto.token_list[2]); + loop = saacproto_demkstr_int(saacproto.token_list[3]); + wait = saacproto_demkstr_int(saacproto.token_list[4]); + msg = saacproto_wrapStringAddr(saacproto_stringwrapper[4], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[5])); + + Init_GM_BROADCAST( loop, time, wait, msg ); + + return 0; + } +#endif + +#ifdef _ANGEL_SUMMON + if( strcmp( funcname , "ACMissionTable" ) == 0 ){ + int num; + int type; + char* data; + //int charaindex; + char* angelinfo; + + num = saacproto_demkstr_int( saacproto.token_list[2] ); + type = saacproto_demkstr_int( saacproto.token_list[3] ); + data = saacproto_wrapStringAddr( saacproto_stringwrapper[3] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[4] )); + //charaindex = saacproto_demkstr_int( saacproto.token_list[5] ); + angelinfo = saacproto_wrapStringAddr( saacproto_stringwrapper[4] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[5] )); + + //saacproto_ACMissionTable_recv( fd, num, type, data, charaindex); + saacproto_ACMissionTable_recv( fd, num, type, data, angelinfo); + return 0; + } +#endif + +#ifdef _TEACHER_SYSTEM + if(strcmp(funcname,"ACCheckCharacterOnLine") == 0){ + int flag,charaindex,iOnline; + char* data; + + charaindex = saacproto_demkstr_int(saacproto.token_list[2]); + iOnline = saacproto_demkstr_int(saacproto.token_list[3]); + data = saacproto_wrapStringAddr( saacproto_stringwrapper[3] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[4] )); + flag = saacproto_demkstr_int( saacproto.token_list[5] ); + saacproto_ACCheckCharacterOnLine_recv(fd,charaindex,iOnline,data,flag); + return 0; + } +#endif + +#ifdef _RACEMAN + if( strcmp( funcname , "ACRaceRecordandSort" ) == 0 ){ + int charaindex,racetype; + char* data; + + charaindex = saacproto_demkstr_int( saacproto.token_list[2] ); + racetype = saacproto_demkstr_int( saacproto.token_list[3] ); + data = saacproto_wrapStringAddr( saacproto_stringwrapper[3] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[4] )); + + saacproto_ACRaceRecordandSort_recv(fd,charaindex,racetype,data); + } +#endif + + return -1; +} +void saacproto_SetClientLogFiles( char *r , char *w ) +{ + saacproto_strcpysafe( saacproto_readlogfilename , r , sizeof( saacproto_readlogfilename ) ); + saacproto_strcpysafe( saacproto_writelogfilename , w , sizeof( saacproto_writelogfilename ) ); +} +int saacproto_InitClient( int (*writefunc)(int,char*,int) ,int bufsiz ,int fd) +{ + int i; + if( (void*)writefunc == NULL){saacproto.write_func = saacproto_default_write_wrap;} else {saacproto.write_func = writefunc;} + saacproto_AllocateCommonWork(bufsiz); + saacproto_stringwrapper = (char**)calloc( 1,sizeof(char*) * MAXLSRPCARGS); + if(saacproto_stringwrapper ==NULL)return -1; + memset( saacproto_stringwrapper , 0, sizeof(char*)*MAXLSRPCARGS); + for(i=0;i +#include +#include +#ifndef WIN32 +#include +#include +#endif +#include "saacproto_util.h" +//ttom +1 +#define IS_2BYTEWORD( _a_ ) ( (char)(0x80) <= (_a_) && (_a_) <= (char)(0xFF) ) + +#ifdef saacproto__ENCRYPT +long saacproto_ringoCompressor( unsigned char *code , long codelen , unsigned char *text , long textlen); +long saacproto_ringoDecompressor( unsigned char *text , long textlen , unsigned char *code , long codelen); +#endif +/* + lsrpc routines +*/ +int saacproto_AllocateCommonWork(int bufsiz) +{ + saacproto.workbufsize = bufsiz; + saacproto.work = NULL; + saacproto.arraywork = NULL; + saacproto.escapework = NULL; + saacproto.val_str = NULL; + saacproto.token_list = NULL; + saacproto.cryptwork = NULL; + saacproto.jencodecopy = NULL; + saacproto.jencodeout = NULL; + saacproto.compresswork = NULL; + saacproto.work = (char*)calloc( 1, saacproto.workbufsize ); + saacproto.arraywork = (char*)calloc( 1, saacproto.workbufsize ); + saacproto.escapework = (char*)calloc( 1, saacproto.workbufsize ); + saacproto.val_str = (char*)calloc( 1, saacproto.workbufsize ); + saacproto.token_list = (char**)calloc( 1, saacproto.workbufsize *sizeof( char** ) ); + saacproto.cryptwork = (char*)calloc( 1, saacproto.workbufsize * 3 ); + saacproto.jencodecopy = (char*)calloc( 1, saacproto.workbufsize * 3 ); + saacproto.jencodeout = (char*)calloc( 1, saacproto.workbufsize * 3 ); + saacproto.compresswork = (char*)calloc( 1, saacproto.workbufsize * 3 ); + memset( saacproto.work , 0, saacproto.workbufsize ); + memset( saacproto.arraywork , 0, saacproto.workbufsize ); + memset( saacproto.escapework , 0, saacproto.workbufsize ); + memset( saacproto.val_str , 0, saacproto.workbufsize ); + memset( (char*)saacproto.token_list ,0, saacproto.workbufsize*sizeof(char**) ); + memset( saacproto.cryptwork , 0, saacproto.workbufsize*3 ); + memset( saacproto.jencodecopy , 0, saacproto.workbufsize*3 ); + memset( saacproto.jencodeout , 0, saacproto.workbufsize*3 ); + memset( saacproto.compresswork , 0, saacproto.workbufsize*3 ); + if( saacproto.work == NULL || + saacproto.arraywork == NULL || + saacproto.escapework == NULL || + saacproto.val_str == NULL || + saacproto.token_list == NULL || + saacproto.cryptwork == NULL || + saacproto.jencodecopy == NULL || + saacproto.jencodeout == NULL || + saacproto.compresswork == NULL ){ + free( saacproto.work);free( saacproto.val_str); + free( saacproto.escapework);free( saacproto.arraywork ); + free( saacproto.token_list);free( saacproto.cryptwork ); + free( saacproto.jencodecopy);free( saacproto.jencodeout ); + free( saacproto.compresswork ); + return -1; + } + return 0; +} + +int saacproto_StringRest() +{ + return 0; +/* free( saacproto.work); + saacproto.work = NULL; + saacproto.work = (char*)calloc( 1, saacproto.workbufsize ); + if( saacproto.work == NULL ) return -1; + return sizeof( saacproto.work); +*/ +} + +/********** + Get message information from a network input +**********/ +void saacproto_GetMessageInfo( int *id , char *funcname , int len, char **tk ) +{ + if( tk[0] == NULL || tk[1] == NULL ){ + *id = 0; + saacproto_strcpysafe( funcname , "" , len ); + return; + } + *id = strtoul( tk[0] ,NULL,10); + saacproto_strcpysafe( funcname , tk[1] , len ); + return; +} +/******************************************** + string utilities +*********************************************/ +void saacproto_strcpysafe( char *dest, char *src, int maxlen ) +{ + int i; + for(i=0;i (int)( saacproto.workbufsize*3-2) ){ + fprintf( stderr, "lsgen: badly configured work buflen\n" ); + exit(1); + } + if( (flag%2) == 1 ) flag ++; + saacproto.compresswork[0] = flag; + memcpy( saacproto.compresswork+1,src,srclen ); + compressed_l = srclen + 1; + } else { + if((flag%2)==0)flag++; + saacproto.compresswork[0] = flag; + compressed_l = saacproto_ringoCompressor( + (unsigned char*)saacproto.compresswork + 1 , + (long)saacproto.workbufsize*3 - 1, + (unsigned char*)src , + (long)strlen(src) ) + 1; /* be careful! */ + } + /* return empty line if error or buffer excess */ + if( compressed_l <= 0 ){ + saacproto_strcpysafe( out , "\n" , maxoutlen ); + return; + } + memcpy( saacproto.jencodecopy ,saacproto.compresswork ,compressed_l ); + saacproto_jEncode( saacproto.jencodecopy , compressed_l , JENCODE_KEY , + saacproto.jencodeout, &jencodedlen , saacproto.workbufsize*3 -1 ); + saacproto_encode64( (unsigned char*)saacproto.jencodeout , jencodedlen, (unsigned char*)out ); +} +/* translate code64 text to original lsrpc text */ +static void saacproto_decodeString( char *src , char *out ) +{ + int compressed_l =0, outlen64; + int l; + long decompressed_l = 0; + /* copy src to copybuffer because jencoder modifies the input buffer */ + l = strlen( src ); + if( src[l-1]=='\n' || src[l-1]=='\r' )src[l-1]=0; + if( src[l-2]=='\n' || src[l-2]=='\r' )src[l-2]=0; + outlen64 = saacproto_decode64( (unsigned char*)src , (unsigned char*)saacproto.jencodecopy ); + saacproto_jDecode( saacproto.jencodecopy , outlen64 , JENCODE_KEY, + saacproto.compresswork , &compressed_l); + /*out[outlen]=0; PENDING*/ + if( (saacproto.compresswork[0] % 2 ) == 0 ){ + if( compressed_l <= 0 ){ + decompressed_l = 0; + fprintf( stderr, "LSRPC: too short:[%s]\n", src ); + } else { + memcpy( out, saacproto.compresswork+1, compressed_l -1 ); + decompressed_l = compressed_l -1; + } + } else { + decompressed_l = + saacproto_ringoDecompressor( (unsigned char*)out , + (long)saacproto.workbufsize , + (unsigned char*)saacproto.compresswork+1 , + (long)compressed_l -1 ); + } + out[decompressed_l] = 0; +} +/* followings are taken from code64.c */ +char saacproto_charset[64]={ + 'A','B','C','D', 'E','F','G','H', + 'I','J','K','L', 'M','N','O','P', + 'Q','R','S','T', 'U','V','W','X', + 'Y','Z','a','b', 'c','d','e','f', + 'g','h','i','j', 'k','l','m','n', + 'o','p','q','r', 's','t','u','v', + 'w','x','y','z', '0','1','2','3', + '4','5','6','7', '8','9','+','-' +}; +char saacproto_reversecharset[256]={ + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,62, 0,63,0,0, + 52,53,54,55, 56,57,58,59, + 60,61,0,0, 0,0,0,0, + 0,0,1,2, 3,4,5,6, + 7,8,9,10, 11,12,13,14, + 15,16,17,18, 19,20,21,22, + 23,24,25,0, 0,0,0,0, + 0,26,27,28, 29,30,31,32, + 33,34,35,36, 37,38,39,40, + 41,42,43,44, 45,46,47,48, + 49,50,51,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0 +}; + +static void saacproto_encode64( unsigned char *in , int len , unsigned char *out ) +{ + int i; + int use_bytes; + int address = 0; + out[0] = 0; + for(i=0;;i+=3){ + unsigned char in1 , in2 , in3; + unsigned char out1 ,out2 , out3 , out4; + if( i >= len ) break; + if( i >= (len-1)){ /* the last letter ( to be thrown away ) */ + in1 = in[i] & 0xff; + in2 = in3 = 0; + use_bytes = 2; + } else if( i >= (len-2)){ /* the last 2 letters ( process only 1 byte)*/ + in1 = in[i] & 0xff; + in2 = in[i+1] & 0xff; + in3 = 0; + use_bytes = 3; + } else { /* there are more or equal than 3 letters */ + in1 = in[i] & 0xff; + in2 = in[i+1] & 0xff; + in3 = in[i+2] & 0xff; + use_bytes = 4; + } + out1 = ((in1 & 0xfc)>>2) & 0x3f; + out2 = ((in1 & 0x03)<<4) | ((( in2 & 0xf0)>>4)&0x0f); + out3 = ((in2 & 0x0f)<<2) | ((( in3 & 0xc0)>>6)&0x03); + out4 = (in3 & 0x3f ); + if( use_bytes >= 2 ){ + out[address++] = saacproto_charset[out1]; + out[address++] = saacproto_charset[out2]; + out[address]=0; + } + if( use_bytes >= 3 ){ + out[address++] = saacproto_charset[out3]; + out[address]=0; + } + if( use_bytes >= 4 ){ + out[address++] = saacproto_charset[out4]; + out[address]=0; + } + } +} +/* + * Decode it + * char *in : encoded ascii chars + * char *out : decoded( output) + * return value : output byte count + * + * note: no need to have bigger buffer. because output is to + * be smaller than input string size + */ +static int saacproto_decode64( unsigned char *in , unsigned char *out ) +{ + unsigned char in1 , in2 , in3 , in4; + unsigned char out1 , out2 , out3; + int use_bytes; + int address= 0; + int i; + for(i=0;;i+=4 ){ + if( in[i] == 0 ){ + break; + } else if( in[i+1] == 0 ){ /* the last letter */ + break; + } else if( in[i+2] == 0 ){ /* the last 2 letters */ + in1 = saacproto_reversecharset[in[i]]; + in2 = saacproto_reversecharset[in[i+1]]; + in3 = in4 = 0; + use_bytes = 1; + } else if( in[i+3] == 0 ){ /* the last 3 letters */ + in1 = saacproto_reversecharset[in[i]]; + in2 = saacproto_reversecharset[in[i+1]]; + in3 = saacproto_reversecharset[in[i+2]]; + in4 = 0; + use_bytes = 2; + } else { /* process 4 letters */ + in1 = saacproto_reversecharset[in[i]]; + in2 = saacproto_reversecharset[in[i+1]]; + in3 = saacproto_reversecharset[in[i+2]]; + in4 = saacproto_reversecharset[in[i+3]]; + use_bytes = 3; + } + out1 = (in1<<2) | (((in2 & 0x30)>>4)&0x0f) ; + out2 = ((in2 & 0x0f )<<4) | ((( in3 & 0x3c)>>2)&0x0f); + out3 = ( (in3 &0x03)<<6) | ( in4 & 0x3f ); + if( use_bytes >= 1 ){ + out[address++] = out1; + } + if( use_bytes >= 2 ){ + out[address++] = out2; + } + if( use_bytes >= 3 ){ + out[address++] = out3; + } + if( use_bytes != 3 ){ + break; + } + } + return address; +} + +/* followings are taken from Jencode.c by jun */ +static void saacproto_jEncode(char *src,int srclen,int key,char *encoded,int *encodedlen,int maxencodedlen) +{ + char sum=0; + int i; + if(srclen+1 > maxencodedlen){ + *encodedlen = maxencodedlen; + for(i=0;i<(*encodedlen);i++)encoded[i] = src[i]; + } + if(srclen+1 <= maxencodedlen){ + *encodedlen=srclen+1; + for(i=0;i i) encoded[i] = src[i] + sum*((i*i)%3); + if(abs((key%srclen)) == i) encoded[i] = sum; + if(abs((key%srclen)) < i) encoded[i] = src[i-1] + sum*((i*i)%7); + } + } +} +static void saacproto_jDecode(char *src,int srclen,int key,char *decoded,int *decodedlen) +{ + char sum=0; + int i; + *decodedlen=srclen-1; + if( *decodedlen == 0 ){ + return; /* return error if length is 0 */ + } + sum = src[abs(key%(*decodedlen))]; + for(i=0;i i) decoded[i] = src[i] - sum*((i*i)%3); + if(abs((key%(*decodedlen))) < i) decoded[i-1] = src[i] - sum*((i*i)%7); + } + for(i=0;i<(*decodedlen);i++){ + if(((key%7) == (i%5))||((key%2) == (i%2)))decoded[i] = ~decoded[i]; + } +} + +/*****************************************************************/ +/* Compress / Decompress routine */ +/*****************************************************************/ +#define B00000000 0 +#define B00000001 1 +#define B00000010 2 +#define B00000011 3 +#define B00000100 4 +#define B00000101 5 +#define B00000110 6 +#define B00000111 7 +#define B00001000 8 +#define B00001001 9 +#define B00001010 10 +#define B00001011 11 +#define B00001100 12 +#define B00001101 13 +#define B00001110 14 +#define B00001111 15 +#define B00010000 16 +#define B00010001 17 +#define B00010010 18 +#define B00010011 19 +#define B00010100 20 +#define B00010101 21 +#define B00010110 22 +#define B00010111 23 +#define B00011000 24 +#define B00011001 25 +#define B00011010 26 +#define B00011011 27 +#define B00011100 28 +#define B00011101 29 +#define B00011110 30 +#define B00011111 31 +#define B00100000 32 +#define B00100001 33 +#define B00100010 34 +#define B00100011 35 +#define B00100100 36 +#define B00100101 37 +#define B00100110 38 +#define B00100111 39 +#define B00101000 40 +#define B00101001 41 +#define B00101010 42 +#define B00101011 43 +#define B00101100 44 +#define B00101101 45 +#define B00101110 46 +#define B00101111 47 +#define B00110000 48 +#define B00110001 49 +#define B00110010 50 +#define B00110011 51 +#define B00110100 52 +#define B00110101 53 +#define B00110110 54 +#define B00110111 55 +#define B00111000 56 +#define B00111001 57 +#define B00111010 58 +#define B00111011 59 +#define B00111100 60 +#define B00111101 61 +#define B00111110 62 +#define B00111111 63 +#define B01000000 64 +#define B01000001 65 +#define B01000010 66 +#define B01000011 67 +#define B01000100 68 +#define B01000101 69 +#define B01000110 70 +#define B01000111 71 +#define B01001000 72 +#define B01001001 73 +#define B01001010 74 +#define B01001011 75 +#define B01001100 76 +#define B01001101 77 +#define B01001110 78 +#define B01001111 79 +#define B01010000 80 +#define B01010001 81 +#define B01010010 82 +#define B01010011 83 +#define B01010100 84 +#define B01010101 85 +#define B01010110 86 +#define B01010111 87 +#define B01011000 88 +#define B01011001 89 +#define B01011010 90 +#define B01011011 91 +#define B01011100 92 +#define B01011101 93 +#define B01011110 94 +#define B01011111 95 +#define B01100000 96 +#define B01100001 97 +#define B01100010 98 +#define B01100011 99 +#define B01100100 100 +#define B01100101 101 +#define B01100110 102 +#define B01100111 103 +#define B01101000 104 +#define B01101001 105 +#define B01101010 106 +#define B01101011 107 +#define B01101100 108 +#define B01101101 109 +#define B01101110 110 +#define B01101111 111 +#define B01110000 112 +#define B01110001 113 +#define B01110010 114 +#define B01110011 115 +#define B01110100 116 +#define B01110101 117 +#define B01110110 118 +#define B01110111 119 +#define B01111000 120 +#define B01111001 121 +#define B01111010 122 +#define B01111011 123 +#define B01111100 124 +#define B01111101 125 +#define B01111110 126 +#define B01111111 127 +#define B10000000 128 +#define B10000001 129 +#define B10000010 130 +#define B10000011 131 +#define B10000100 132 +#define B10000101 133 +#define B10000110 134 +#define B10000111 135 +#define B10001000 136 +#define B10001001 137 +#define B10001010 138 +#define B10001011 139 +#define B10001100 140 +#define B10001101 141 +#define B10001110 142 +#define B10001111 143 +#define B10010000 144 +#define B10010001 145 +#define B10010010 146 +#define B10010011 147 +#define B10010100 148 +#define B10010101 149 +#define B10010110 150 +#define B10010111 151 +#define B10011000 152 +#define B10011001 153 +#define B10011010 154 +#define B10011011 155 +#define B10011100 156 +#define B10011101 157 +#define B10011110 158 +#define B10011111 159 +#define B10100000 160 +#define B10100001 161 +#define B10100010 162 +#define B10100011 163 +#define B10100100 164 +#define B10100101 165 +#define B10100110 166 +#define B10100111 167 +#define B10101000 168 +#define B10101001 169 +#define B10101010 170 +#define B10101011 171 +#define B10101100 172 +#define B10101101 173 +#define B10101110 174 +#define B10101111 175 +#define B10110000 176 +#define B10110001 177 +#define B10110010 178 +#define B10110011 179 +#define B10110100 180 +#define B10110101 181 +#define B10110110 182 +#define B10110111 183 +#define B10111000 184 +#define B10111001 185 +#define B10111010 186 +#define B10111011 187 +#define B10111100 188 +#define B10111101 189 +#define B10111110 190 +#define B10111111 191 +#define B11000000 192 +#define B11000001 193 +#define B11000010 194 +#define B11000011 195 +#define B11000100 196 +#define B11000101 197 +#define B11000110 198 +#define B11000111 199 +#define B11001000 200 +#define B11001001 201 +#define B11001010 202 +#define B11001011 203 +#define B11001100 204 +#define B11001101 205 +#define B11001110 206 +#define B11001111 207 +#define B11010000 208 +#define B11010001 209 +#define B11010010 210 +#define B11010011 211 +#define B11010100 212 +#define B11010101 213 +#define B11010110 214 +#define B11010111 215 +#define B11011000 216 +#define B11011001 217 +#define B11011010 218 +#define B11011011 219 +#define B11011100 220 +#define B11011101 221 +#define B11011110 222 +#define B11011111 223 +#define B11100000 224 +#define B11100001 225 +#define B11100010 226 +#define B11100011 227 +#define B11100100 228 +#define B11100101 229 +#define B11100110 230 +#define B11100111 231 +#define B11101000 232 +#define B11101001 233 +#define B11101010 234 +#define B11101011 235 +#define B11101100 236 +#define B11101101 237 +#define B11101110 238 +#define B11101111 239 +#define B11110000 240 +#define B11110001 241 +#define B11110010 242 +#define B11110011 243 +#define B11110100 244 +#define B11110101 245 +#define B11110110 246 +#define B11110111 247 +#define B11111000 248 +#define B11111001 249 +#define B11111010 250 +#define B11111011 251 +#define B11111100 252 +#define B11111101 253 +#define B11111110 254 +#define B11111111 255 +/* masks for first byte ( write )*/ +int saacproto_modifymask_first[8][9]={ + {0, B00000001,B00000011,B00000111,B00001111,B00011111,B00111111,B01111111,B11111111},/* mod 0*/ + {0, B00000011,B00000111,B00001111,B00011111,B00111111,B01111111,B11111111,B11111111},/* mod 1*/ + {0, B00000111,B00001111,B00011111,B00111111,B01111111,B11111111,B11111111,B11111111},/* mod 2*/ + {0, B00001111,B00011111,B00111111,B01111111,B11111111,B11111111,B11111111,B11111111},/* mod 3*/ + {0, B00011111,B00111111,B01111111,B11111111,B11111111,B11111111,B11111111,B11111111},/* mod 4*/ + {0, B00111111,B01111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111},/* mod 5*/ + {0, B01111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111},/* mod 6*/ + {0, B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111},/* mod 7*/ +}; +/* masks for second byte ( write ) */ +int saacproto_modifymask_second[8][9]={ + {0, B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000},/* mod 0 */ + {0, B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000001},/* mod 1 */ + {0, B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000001,B00000011},/* mod 2 */ + {0, B00000000,B00000000,B00000000,B00000000,B00000000,B00000001,B00000011,B00000111},/* mod 3 */ + {0, B00000000,B00000000,B00000000,B00000000,B00000001,B00000011,B00000111,B00001111},/* mod 4 */ + {0, B00000000,B00000000,B00000000,B00000001,B00000011,B00000111,B00001111,B00011111},/* mod 5 */ + {0, B00000000,B00000000,B00000001,B00000011,B00000111,B00001111,B00011111,B00111111},/* mod 6 */ + {0, B00000000,B00000001,B00000011,B00000111,B00001111,B00011111,B00111111,B01111111},/* mod 7 */ +}; +/* + * used by bitstream routines + */ +int bitstream_maxbyte, bitstream_bitaddr ; +char *bitstream_buf; +/* initialize bitstream for output */ +static int initOutputBitStream( char *buf ,int buflen) +{ + bitstream_bitaddr = 0; + bitstream_maxbyte = buflen; + bitstream_buf = buf; + memset( buf,0, buflen); + return 0; +} +/* initialize bitstream for input */ +static int initInputBitStream( char *buf , int buflen) +{ + bitstream_bitaddr = 0; + bitstream_maxbyte = buflen; + bitstream_buf = buf; + return 0; +} +/* + * read from bit stream. used only from 1 bit to 8 bits + * this is a base routine + */ +static unsigned int readInputBitStreamBody( int bwidth ) +{ + int mod = bitstream_bitaddr % 8; + int byteaddr = bitstream_bitaddr / 8; + /* return if excess */ + if( byteaddr >= bitstream_maxbyte)return 0; + if( bwidth >= 1 && bwidth <= 8){ + int b1 = (( bitstream_buf[byteaddr] & saacproto_modifymask_first[mod][bwidth] )>>mod); + int b2 = (( bitstream_buf[byteaddr+1] & saacproto_modifymask_second[mod][bwidth])<<(8-mod)); + bitstream_bitaddr += bwidth; + return b1 | b2; + } else { + return 0; + } +} +/* + * read from bit stream. used from 1 bit to 32 bits + * + */ +static unsigned int readInputBitStream( int bwidth ) +{ + if( bwidth <= 0 ){ + return 0; + } else if( bwidth >= 1 && bwidth <= 8 ){ + return readInputBitStreamBody( bwidth ); + } else if( bwidth >= 9 && bwidth <= 16 ){ + unsigned int first = readInputBitStreamBody(8); + unsigned int second = readInputBitStreamBody( bwidth-8); + return first + (second << 8 ); + } else if( bwidth >= 17 && bwidth <= 24 ){ + unsigned int first = readInputBitStreamBody(8); + unsigned int second = readInputBitStreamBody(8); + unsigned int third = readInputBitStreamBody(bwidth-8); + return first + ( second << 8 ) + ( third << 16 ); + } else if( bwidth >= 25 && bwidth <= 32 ){ + unsigned int first = readInputBitStreamBody(8); + unsigned int second = readInputBitStreamBody(8); + unsigned int third = readInputBitStreamBody(8); + unsigned int forth = readInputBitStreamBody(bwidth-8); + return first + ( second << 8 ) + ( third << 16 ) + ( forth << 24 ); + } + return 0; +} +/* + * write to a bitstream. only used from 1 bit to 8 bits + * this is a base routine. + */ +static int writeOutputBitStreamBody( int bwidth , unsigned char b) +{ + int mod = bitstream_bitaddr % 8; + int byteaddr = bitstream_bitaddr / 8; + /* return error if excess */ + if( bitstream_maxbyte <= (byteaddr+1)) return -1; + bitstream_buf[byteaddr] &= saacproto_modifymask_first[mod][bwidth]; + bitstream_buf[byteaddr] |= (b << mod) & saacproto_modifymask_first[mod][bwidth]; + bitstream_buf[byteaddr+1] &= saacproto_modifymask_second[mod][bwidth]; + bitstream_buf[byteaddr+1] |= (b>>(8-mod))& saacproto_modifymask_second[mod][bwidth]; + bitstream_bitaddr += bwidth; + return byteaddr+1; +} +/* + * write to a bitstream. used from 1 bits to 32 bits + * returns -1 if error or buffer excession + */ +static int writeOutputBitStream( int bwidth, unsigned int dat) +{ + int ret; + if( bwidth <= 0){ + return -1; + } else if( bwidth >= 1 && bwidth <= 8 ){ + if((ret=writeOutputBitStreamBody( bwidth , (unsigned char)dat))<0)return -1; + } else if( bwidth > 8 && bwidth <= 16 ){ + if(writeOutputBitStreamBody( 8 , (unsigned char)(dat&0xff))<0)return -1; + if((ret=writeOutputBitStreamBody( bwidth - 8 , ( unsigned char)((dat>>8)&0xff)))<0)return -1; + } else if( bwidth > 16 && bwidth <= 24 ){ + if(writeOutputBitStreamBody( 8 , (unsigned char)(dat&0xff))<0)return -1; + if(writeOutputBitStreamBody( 8 , (unsigned char)((dat>>8)&0xff))<0)return -1; + if((ret=writeOutputBitStreamBody( bwidth-16,(unsigned char)((dat>>16)&0xff)))<0)return -1; + } else if( bwidth > 24 && bwidth <= 32 ){ + if(writeOutputBitStreamBody( 8 , (unsigned char)(dat&0xff))<0)return -1; + if(writeOutputBitStreamBody( 8 , (unsigned char)((dat>>8)&0xff))<0)return -1; + if(writeOutputBitStreamBody( 8 , (unsigned char)((dat>>16)&0xff))<0)return -1; + if((ret=writeOutputBitStreamBody( bwidth-24,(unsigned char)((dat>>24)&0xff)))<0)return -1; + } else { + return -1; + } + return ret; +} +#define CHAR_SIZE 256 +#define NODE_SIZE 512 +#define BITS_LEN 9 /* 9 bit lzw compression */ +typedef struct { + unsigned char chr; + int parent; + int brother; + int child; +}NODE; +long saacproto_ringoCompressor( unsigned char *code , long codelen , + unsigned char *text , long textlen) +{ + NODE node[NODE_SIZE]; + int freeNode; + int w,k; /* used in this algo */ + int textind; /* index to text buffer */ + int i; + int position = 0; /* indicates the last byte of code buffer */ + if( textlen <= 0 ) return -1; + initOutputBitStream((char*) code,codelen); + /* fill characters ( 0 ~ 255 ) in the beggining part of + Node list */ + for(i=0; i<= CHAR_SIZE; i++){ + node[i].chr = (unsigned char)i; + node[i].brother = i + 1; + node[i].parent = 0; + node[i].child = 0; + } + node[CHAR_SIZE].brother = 0; + freeNode = CHAR_SIZE + 1; + w = text[0]; + textind = 1; + while(1){ + int rv; + if( textind >= textlen ){ + k = CHAR_SIZE; /* indicates EOF */ + } else { + k = text[textind]; + } + /* search if pattern 'wk' is registered or not. */ + rv = node[w].child; + while(1){ + if( rv <= 0 ) break; + if( node[rv].chr == k ) break; + rv = node[rv].brother; + } + if( rv > 0 ){ + /* found it */ + w = rv; + } else { + position = writeOutputBitStream( BITS_LEN ,w ); + /* return if buffer excession */ + if( position > codelen ) return -1; + /* register pattern 'wk' in the dictionary */ + if( freeNode < NODE_SIZE ){ + node[freeNode].parent = w; + node[freeNode].chr = k; + node[freeNode].brother = node[w].child; + node[freeNode].child = 0; + node[w].child = freeNode; + freeNode++; + } + w = k; + } + if( textind == ( textlen + 1 ) ) break; + textind++; + } + return position; +} + +/* + * Decoder. + * return -1 if buffer excession. Notice buffer text + * is modified . + */ +long saacproto_ringoDecompressor( unsigned char *text , long textlen , + unsigned char *code , long codelen) +{ + NODE node[NODE_SIZE]; + int stack[NODE_SIZE]; + int sp; + int freeNode; + int len; + int i; + int k = 0; + int w = 0; + if( codelen <= 0 ) return -1; + initInputBitStream( (char*)code , codelen ); + for(i=0;i= freeNode ){ + stack[sp++] = k; /* exception */ + if( sp >=( sizeof( stack ) /sizeof(stack[0] )) )return -1; + k = w; + } else { + k = rv; + } + while(k> CHAR_SIZE ){ + if( k >= (sizeof(node)/sizeof(node[0]))) return -1; + stack[sp++] = node[k].chr; + k = node[k].parent; + if( sp >=( sizeof( stack ) /sizeof(stack[0] )) ) return -1; + } + stack[sp++] = k; + if( sp >= ( sizeof( stack ) /sizeof(stack[0] )) ) return -1; + /* output to text buffer from stack.*/ + while(sp){ + if( ++len > textlen ) return -1; + *text++ = stack[--sp]; + } + /* register the pattern 'wk'*/ + if( len > 1 && freeNode < NODE_SIZE ){ + node[freeNode].parent = w; + node[freeNode].chr = k; + if( w >= (sizeof(node)/sizeof(node[0])))return -1; + node[freeNode].brother = node[w].child; + node[freeNode].child = 0; + node[w].child = freeNode; + freeNode++; + } + w = rv; + } + return len; +} +#endif /* ifdef saacproto__ENCRYPT */ + +/* Convert 62-base digits to 10 digits */ +int saacproto_a62toi( char *a ) +{ + int ret = 0; + int minus ; + if( a[0] == '-' ){ + minus = -1; + a++; + } else { + minus = 1; + } + + while( *a != '\0' ) + { + ret *= 62; + if( '0' <= (*a) && (*a) <= '9' ) + ret += (*a)-'0'; + else + if( 'a' <= (*a) && (*a) <= 'z' ) + ret += (*a)-'a'+10; + else + if( 'A' <= (*a) && (*a) <= 'Z' ) + ret += (*a)-'A'+36; + else + return 0; + a++; + } + return ret * minus; +} + +/* Convert 10-base digits into 62-base digits. */ +char *saacproto_cnv10to62( int a, char *out, int outlen ) +{ + int i, j; + char base[] = { "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"}; + int tmp[64]; + int src; + int minus; + int baselen = sizeof( base)-1; + if( a < 0 ){ + minus = 1; + a *= -1; + } else { + minus = 0; + } + /* special case */ + if( a < baselen) { + if( minus ){ + *(out) = '-'; + *(out+1) = base[a]; + *(out+2) = '\0'; + return (out); + } else { + *out = base[a]; + *(out+1) = '\0'; + return( out); + } + } + src = a; + for( i = 0; src >= baselen; i ++ ) { + tmp[i] = src % baselen; + src /= baselen; + } + i--; + if( minus ){ + *out = '-'; + *(out+1) = base[src]; + for( j = 2; i >= 0; i --, j ++ ) { + if( j > outlen - 2 ) return NULL; + *(out+j) = base[tmp[i]]; + } + } else { + *out = base[src]; + for( j = 1; i >= 0; i --, j ++ ) { + if( j > outlen - 2 ) return NULL; + *(out+j) = base[tmp[i]]; + } + } + *(out+j) = '\0'; + return( out); +} diff --git a/gmsv/util.c b/gmsv/util.c new file mode 100644 index 0000000..071e189 --- /dev/null +++ b/gmsv/util.c @@ -0,0 +1,1758 @@ +#include "version.h" +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "common.h" +#include "util.h" +#include "configfile.h" + +#define IS_2BYTEWORD( _a_ ) ( (char)(0x80) <= (_a_) && (_a_) <= (char)(0xFF) ) + +/*----------------------------------------- + 仃勾及荼垫毛仇欠允 + 娄醒“ 手午及 侬 [ 涛 凳今木月冗 + + windows , macintosh , unix及升及垫手覆杀匹五月[ + + windows : \r\n + macintosh : \n\r + unix : \n + + 分匀凶井卅 + macintosh : \r + 匹允[ + 公木午仇及皿夫弘仿丞分午仃勾及 侬元扎卅仁化手 + 荼垫壅允仃升中中氏匹允井 + -----------------------------------------*/ +void chompex( char *buf ) +{ + while( *buf ){ + if( *buf == '\r' || *buf == '\n' ){ + *buf='\0'; + } + buf++; + } +} + + + +/*---------------------------------------- + * 仃勾及1 侬毛潸曰轮仁 + * 娄醒 + * src 凳允月 侬 + ----------------------------------------*/ +void chop( char* src ) +{ + /* + * 凶分凶氏卞 及 侬毛潸曰轮仁 + */ + int length = strlen( src ); + if( length == 0 ) return; + src[length-1] = '\0'; +} + + +/*---------------------------------------- + * 仃勾及 侬毛潸月[公及 侬毛 醒隙烂匹五月[ + * 娄醒 + * src 葭及 侬 + * delim 绰轮允月 侬及 [ 反NULL 侬匹蔽匀化中月仪 + ----------------------------------------*/ +void dchop( char* src , char* del) +{ + int dellen, srclen; + int i; + BOOL delete=FALSE; + + /* + * src及 欠井日譬屯化中仁[1 侬卞勾五 del 允屯化毛伙□皿仄化 + * 域谯允木壬壅允[公仄化戚及 侬卞中仁[ + */ + + srclen = strlen( src ); + dellen = strlen( del ); + if( srclen == 0 || dellen == 0 ) return; + + for( i = 0 ; i < dellen ; i ++ ){ + if( src[srclen-1] == del[i] ){ + delete = TRUE; + break; + } + } + + /* 濠曰潸曰 */ + if( delete )src[srclen - 1] = '\0'; +} + + +/*---------------------------------------- + * dchop及菅[ 赓及 侬毛潸月[公及 侬毛 醒隙烂匹五月[ + * 娄醒 + * src 葭及 侬 + * delim 绰轮允月 侬及 [ 反NULL 侬匹蔽匀化中月仪 + ----------------------------------------*/ +void pohcd( char* src , char* del) +{ + int dellen, srclen; + int i; + BOOL delete=FALSE; + + /* + * src及蟆井日譬屯化中仁[1 侬卞勾五 del 允屯化毛伙□皿仄化 + * 域谯允木壬壅允[公仄化戚及 侬卞中仁[ + */ + + srclen = strlen( src ); + dellen = strlen( del ); + if( srclen == 0 || dellen == 0 ) return; + + for( i = 0 ; i < dellen ; i ++ ){ + if( src[0] == del[i] ){ + delete = TRUE; + break; + } + } + + /* 绰轮 */ + if( delete ) + /* 仇及戊疋□匹 NULL 侬手戊疋□今木月 */ + for( i = 0 ; i < srclen ; i ++ ) + src[i] = src[i+1]; +} + + +/*---------------------------------------- + * 侬 卞 侬互殖引木化中月井升丹井譬屯月[ + * 娄醒 + * src char* 譬屯月 侬 + * include char* 殖引木化中月井升丹井及 侬 [ + * 忒曰袄 + * 岳 赓卞殖引木化中凶src及桦赭 + * 撩 -1 + ----------------------------------------*/ +int charInclude( char* src, char* include ) +{ + int i,j; + int srclen,includelen; + + srclen = strlen( src ); + includelen = strlen( include ); + + for( i = 0 ; i < srclen ; i ++ ){ + for( j = 0 ; j < includelen ; j ++ ) + if( src[i] == include[j] ) + return i; + } + return -1; +} + + +/*------------------------------------------------------------ + * EUC及2田奶玄 分仃毛戊疋□仄卅中strncpy + * freeBSD 及仿奶皮仿伉井日 strncpy 毛潸匀化五化} + * 公木毛手午卞荼瞻[*dest++ 午井银中凶中仃升}瑛宁赐辆卞愤褥互 + * 卅中及匹}银匀化中卅中[井歹曰卞 分仃升}禾奶件正手银匀化化 + * 井卅曰 卅皿夫弘仿丞 + * 娄醒 + * dest char* 戊疋□燮 + * src char* 末□旦 + * n size_t 赢今 + * 忒曰袄 + * dest + ------------------------------------------------------------*/ +char* strncpy2( char* dest, const char* src, size_t n ) +{ + if( n > 0 ){ + char* d = dest; + const char* s = src; + int i; + for( i=0; i=n ){ + *(d+i-1)='\0'; + break; + } + *(d+i) = *(s+i); + }else + *(d+i) = *(s+i); + } + } + return dest; +} + +/*---------------------------------------- + * src 井日 dest 卞戊疋□允月[ 戊疋□燮及扔奶术毛譬屯月[ + * 娄醒 + * dest 戊疋□燮 + * n 扔奶术 + * src 葭及 侬 + ----------------------------------------*/ +void strcpysafe( char* dest ,size_t n ,const char* src ) +{ + /* + * src 井日 dest 尺戊疋□允月. + * strcpy, strncpy 匹反 dest 方曰 戊疋□允月汹互 + * 五中凛卞裟少午,丢乒伉陆失弁本旦互粟月. + * 仇木毛 什啃卞, strncpy 互丐月互 strlen( src ) 互 n 方曰 + * 五中凛卞反, dest 及 互 NULL 侬午反卅日卅中. + * + * 仄凶互匀化 dest 及 五今方曰 src 及幻丹互赢中凛卞反 + * n-1 匹 strncpy 毛允月. 凝今中凛反公及引引戊疋□允月 + * + * n 互 及凛反云井仄仁卅月及匹 及凛反 窒手仄卅中[ + * + */ + // Nuke +1 (08/25): Danger if src=0 + if (!src) { + *dest = '\0'; + return; + } + if( n <= 0 ) /* 窒手仄卅中 */ + return; + + /* 仇及凛鳔匹} n >= 1 动晓互瑁烂 */ + /* NULL 侬毛哔 仄化 胜允月 */ + else if( n < strlen( src ) + 1 ){ + /* + * 田永白央互箫曰卅中及匹 n - 1(NULL 侬) + * 匹 strncpy 毛裟少 + */ + strncpy2( dest , src , n-1 ); + dest[n-1]='\0'; + }else + strcpy( dest , src ); + +} + +/*---------------------------------------- + * src 井日 length 掏允[ 戊疋□燮及 五今毛譬屯月[ + * 娄醒 + * dest 戊疋□燮 + * n 戊疋□燮及扔奶术 + * src 戊疋□葭 + * length 窒 侬戊疋□允月井 + ----------------------------------------*/ +void strncpysafe( char* dest , const size_t n , + const char* src ,const int length ) +{ + /* + * src 井日 dest 卞 length 戊疋□允月 + * strcpy, strncpy 匹反 dest 方曰 戊疋□允月汹互 + * 五中凛卞裟少午,丢乒伉陆失弁本旦互粟月. + * 仇及楮醒匹反}strlen( src ) 午 length 及凝今中幻丹 + * ( 端卞戊疋□允月汹) 午 dest 及扔奶术毛 屯化} + * strcpysafe 午 元仪毛允月[ + */ + + int Short; + Short = min( strlen( src ) , length ); + + /* NULL 侬 毛哔 仄凶 胜 */ + if( n < Short + 1 ){ + /* + * 田永白央互箫曰卅中及匹 n - 1(NULL 侬) + * 匹 strncpy 毛裟少 + */ + strncpy2( dest , src , n-1 ); + dest[n-1]='\0'; + + }else if( n <= 0 ){ + return; + }else{ + /* + * 田永白央反蜗坌卞丐月及匹 Short 匹strncpy毛裟少 + * 卅云 src 卞反 Short 及赢今 卞 NULL 互卅中及匹} + * dest 卞反 馨笛仄化云仁[ + */ + + strncpy2( dest , src , Short ); + dest[Short]= '\0'; + + } +} + +/*------------------------------------------------------------ + * strcat毛兜蝈卞 蜇允月[赞中及匹} 卅桦宁毛轮中化银歹卅中仪[ + * 娄醒 + * src char* 葭卞卅月 侬 + * size int src 及扔奶术( 欠卞升木分仃酸匀化中月井匹反 + * 卅仁化田永白央蝈 ) + * ap char* 尥仃笛尹月 + * 忒曰袄 + * src ( 木阂迕) + ------------------------------------------------------------*/ +char* strcatsafe( char* src, int size, char* ap ) +{ + strcpysafe( src + strlen( src ) , size - strlen(src), ap ); + return src; +} + +/*---------------------------------------- + * 侬 及 毛 胜允月[ 元井升丹井仄井 烂仄卅中 by ringo + * char *s1 , *s2 : 胜允月 侬 + * 忒曰袄 + * 0 “ 云卅元 + * 1 : 仇午卅月 + * 仇木反NPC及 平旦玄荸 卞支仁分勾[ + ----------------------------------------*/ +int strcmptail( char *s1 , char *s2 ) +{ + int i; + int len1 = strlen( s1 ); + int len2 = strlen( s2 ); + + for(i=0;;i++){ + int ind1 = len1 - 1 - i; + int ind2 = len2 - 1 - i; + if( ind1 < 0 || ind2 < 0 ) return 0; + if( s1[ind1] != s2[ind2] ) return 1; + } +} + + + +/*---------------------------------------- + * 侬 及 卞踏井木化中月帮醒毛必永玄允月[ + * NPC及 平旦玄荸 卞支仁分勾[ + * 凶分仄 卞中日氏 侬互丐月桦宁 骰允月[ + * 耨痊互 切卅中失伙打伉术丞卞 凳[ + * 娄醒 + * hoge char* 荸 允月 侬 + * 忒曰袄 + * 荸 仄凶帮醒[ + * + * “ + * "ringo ( 吧噗吧噗星人 ) : 100" + * 及桦宁反100互井尹月[ + * "ringo ( 吧噗吧噗星人 ) : 是100" + * 手100卞卅月[幻氏引卞NPC迕卅曰友[ + ----------------------------------------*/ +#define DECIMALCHARNUM 10 +#define FIGURECHARNUM 3 +#define SPECIALCHARNUM 2 +char *UTIL_decimalchar[DECIMALCHARNUM] = {"0","1","2", + "3", "4","5", + "6","7","8","9"}; +char *UTIL_figurechar[FIGURECHARNUM] = {"","",""}; +char *UTIL_specialchar[SPECIALCHARNUM] = {"",""}; + +/* + * 侬 井日}醒袄毛 允午 歹木月 坌毛 五请允[燮 及幻丹井日 + * 茧仄化 五请允[euc迕[ + * + * : in "这本书七万册300美金吗?" + * out "7万" + * 娄醒 + * char *in: 侬 + * char *out:请 侬 + * int outsiz:请 侬 及田永白央扔奶术 + * 忒曰袄 + * 醒袄毛 允 坌互丐匀凶日公及 侬 及赢今}卅井匀凶日ㄟ + */ +static int findNumberString( char *in, char *out, int outsiz ) +{ + int len,i,j,k, findflag, numstrflag; + char tmp[3]; + + len = strlen(in); + if( len == 0 ) return 0; + + numstrflag=0; + findflag = 0; + for( i=0,j=0;in[i]!='\0'&& j 0x7fffffff ) return 0x7fffffff; + else return (int)val; + +} + + +/* + * 挚匹 仄凶醒袄毛帮醒卞 晶 + * char *str 醒袄毛 允 侬 + * 忒曰袄 醒袄 + * + * str互"一亿4千万?"及午五忒曰袄 140000000 + */ +int kanjistrToInt( char *str ) +{ + double val,tmpval; + char tmp[3]; + int num,i,j,numflag; + + numflag = 0; + num = 1; + tmpval = 0; + val = 0; + for( i=0;str[i]!='\0';i++ ){ + if( str[i] & 0x80 ){ + tmp[0] = str[i]; + tmp[1] = str[i+1]; + tmp[2] = '\0'; + i++; + }else{ + tmp[0] = str[i]; + tmp[1] = '\0'; + } + for( j=0;j 0x7fffffff ) return 0x7fffffff; + else return (int)val; + +} + + + +/*---------------------------------------- + * 侬 及 卞踏井木化中月帮醒毛必永玄允月[ + * NPC及 平旦玄荸 卞支仁分勾[ + * 凶分仄 卞中日氏 侬互丐月桦宁 骰允月[ + * 耨痊互 切卅中失伙打伉术丞卞 凳[ + * 娄醒 + * hoge char* 荸 允月 侬 + * 忒曰袄 + * 荸 仄凶帮醒[ + * + * “ + * "ringo ( 吧噗吧噗星人 ) : 100" + * 及桦宁反100互井尹月[ + * "ringo ( 吧噗吧噗星人 ) : 是100" + * 手100卞卅月[幻氏引卞NPC迕卅曰友[ + ----------------------------------------*/ +int texttoiTail( char *hoge) +{ + return 0; /* 壬什匀化凶及匹仇丹仄凶[公及丹切楮醒仍午壅允[ */ + + +#if 0 + int len = strlen(hoge); + + if( len == 0 )return atoi(hoge); + /* 井日茧仄化 赓卞醒侬毛苇勾仃月 */ + while(--len && len >= 0){ + if( isdigit(hoge[len]) ) + break; + } + while( --len && len >= 0 ){ + if( !isdigit(hoge[len]) ) + break; + if( hoge[len]=='+' || hoge[len]=='-') + break; + } + return atoi(hoge+len+1); +#endif +#if 0 + int f = 0; + for(i=len-1;i>=0;i--){ + if( isdigit( hoge[i] ) ) f = 1; + if( (f == 1) + && !( isdigit(hoge[i]) || hoge[i]=='+' || hoge[i]=='-') ){ + return atoi( hoge + i + 1 ); + } + } + return atoi(hoge); +#endif +} + +/*---------------------------------------- + * 侬 毛醒侬井升丹井民尼永弁仄化}醒侬分匀凶日 + * 娄醒卞 木化忒允 + * 娄醒 + * arg 晶葭 + * number 晶 毛医 允月赭 + * base 湘醒 + * type 娄醒及滇( CTYPE 反 common.h 卞烛蜕今木化中月 ) + * 忒曰袄 + * TRUE(1) 岳 + * FALSE(0) strtol互敦僬卞反岳 仄卅井匀凶 + * 仇及凛及number反strtol及忒曰袄匹丐月 + ----------------------------------------*/ +BOOL strtolchecknum( char* arg , void* number,int base ,CTYPE type) +{ + char* buf; + int num; + + num = strtol( arg, &buf, base); + + switch( type ){ + case CHAR: + *(char*)number = (char)num; + break; + case SHORT: + *(short*)number = (short)num; + break; + case INT: + *(int*)number = num; + break; + case DOUBLE: + *(double*)number = (double)num; + break; + default: + break; + } + + + if( strlen( buf ) >= 1 ) + /* + * 酸曰 侬互丐月午中丹仪反 晶仄五木化卅中午中丹仪卅及分[ + */ + return FALSE; + + return TRUE; + +} + + + + +/*---------------------------------------- + * src 井日 dels 匹隙烂仄凶 侬毛潸曰轮仁 + * 田永弁旦仿永扑亘反巨旦弗□皿匹丐月仪卞镗啦[ + * 勾引曰田永弁旦仿永扑亘反绰轮匹五卅中[ + * 娄醒 + * src 凳今木月 侬 + * char* 绰轮允月 侬( 侬 匹隙烂第) + * 忒曰袄 + * 卅仄 + ----------------------------------------*/ +void deleteCharFromString( char* src , char* dels ) +{ + int index=0; /* 匹五丐互曰及 侬 匹及 index */ + int delength; /* dels 及赢今毛涩烂允月(剂仄反簧蘸失永皿及啃 */ + int i=0,j;/* i 反 src 毛伙□皿允月 醒 j 反 dels 毛伙□皿允月 醒 */ + + delength= strlen( dels ); + + while( src[i] != '\0' ){ + if( src[i] == BACKSLASH ) + /* + * 田永弁旦仿永扑亘卅及匹巨旦弗□皿允月 + * 勾引曰戚及 侬反 椭瘀卞啖 允月 + */ + src[index++] = src[++i]; /* substitute next char */ + + else{ + for( j = 0 ; j < delength ; j ++ ){ + if( src[i] == dels[j] ) + /* + * 绰轮允月 侬分[方匀化 i 卞 1 毛凶允 + */ + goto incrementi; + } + /* + * 壅允 卞隙烂今木化中卅中及匹戊疋□允月[ + */ + src[index++] = src[i]; + } + incrementi: + i++; + } + + src[index] = '\0'; +} + + + +/*---------------------------------------- + * src 井日 dels 匹隙烂仄凶 侬毛潸曰轮仁 + * 巨旦弗□皿反卅中 + * 娄醒 + * src 凳今木月 侬 + * char* 绰轮允月 侬( 侬 匹隙烂第) + * 忒曰袄 + * 卅仄 + ----------------------------------------*/ +void deleteCharFromStringNoEscape( char* src , char* dels ) +{ + int index=0; /* 匹五丐互曰及 侬 匹及 index */ + int delength; /* dels 及赢今毛涩烂允月(剂仄反簧蘸失永皿及啃 */ + int i=0,j;/* i 反 src 毛伙□皿允月 醒 j 反 dels 毛伙□皿允月 醒 */ + + delength= strlen( dels ); + + while( src[i] != '\0' ){ + for( j = 0 ; j < delength ; j ++ ){ + if( src[i] == dels[j] ) + /* + * 绰轮允月 侬分[方匀化 i 卞 1 毛凶允 + */ + goto incrementi; + } + /* + * 壅允 卞隙烂今木化中卅中及匹戊疋□允月[ + */ + src[index++] = src[i]; + incrementi: + i++; + } + + src[index] = '\0'; +} + +/*------------------------------------------------------------ + * 隙烂今木凶 侬毛隙烂今木凶 侬匹 五井尹月 + * 娄醒 + * src char* 凳今木月 侬 + * oldc char 凳今木月 侬 + * newc char 凳允月 侬 + * 忒曰袄 + * src + ------------------------------------------------------------*/ +char* replaceString( char* src, char oldc ,char newc ) +{ + char* cp=src; + + do{ + if( *cp == oldc ) *cp=newc; + }while( *cp++ ); + return src; +} + +typedef struct tagEscapeChar +{ + char escapechar; + char escapedchar; +}EscapeChar; +static EscapeChar escapeChar[]= +{ + { '\n', 'n' }, + { ',', 'c' }, + { '|', 'z' }, + { '\\', 'y' }, +}; + + +char makeCharFromEscaped( char c )//add this function,because the second had it +{ + int i; + + for( i = 0; i < sizeof( escapeChar )/sizeof( escapeChar[0] ); i++ ) + { + if( escapeChar[i].escapedchar == c ) + { + c = escapeChar[i].escapechar; + break; + } + } + return c; +} +/*---------------------------------------- + * makeEscapeString匹综岳今木凶 侬 毛葭卞 允 + * 娄醒 + * src char* 葭卞卅月 侬 [仇木互踏五赘月[ + * 忒曰袄 + * src 毛忒允[(楮醒毛 木仇卞仄支允中方丹卞) + ----------------------------------------*/ +char *makeStringFromEscaped( char* src ) +{//ttom this function all change,beside copy from the second + + int i; + // CoolFish: Fix bug 2001/10/13 + // int srclen = strlen( src ); + int srclen = 0; + int searchindex=0; + + // CoolFish: Fix bug 2001/10/13 + if (!src) return NULL; + srclen = strlen(src); + + for( i = 0; i < srclen; i ++ ) + { + // for 2Byte Word + if( IS_2BYTEWORD( src[i] ) ){ + src[searchindex++] = src[i++]; + src[searchindex++] = src[i]; + }else + if( src[i] == '\\' ) + { + // 戚及 侬卞垫仁 + i++; + src[searchindex++] = makeCharFromEscaped( src[i] ); + } + else + { + src[searchindex++] = src[i]; + } + } + src[searchindex] = '\0'; + + return src; +} + +char* makeEscapeString( char* src , char* dest, int sizeofdest) +{ //ttom this function all change, copy from the second + int i; + int srclen = 0; + int destindex=0; + + // CoolFish: Fix bug 2001/10/13 + if (!src) return NULL; + srclen = strlen(src); + + for( i = 0 ; i < srclen ; i ++ ){ + BOOL dirty=FALSE; + int j; + char escapechar='\0'; + if( destindex + 1 >= sizeofdest )break; + if( IS_2BYTEWORD( src[i] ) ){ + if( destindex + 2 >= sizeofdest )break; + + dest[destindex] = src[i]; + dest[destindex+1] = src[i+1]; + destindex += 2; + i ++; + continue; + } + for( j = 0; j= length ){ + print( "*\n"); + break; + } + src[index++]=src[i]; + /* 粮互鞅匀凶仪卞允月 */ + backchar = '\0'; + continue; + } + if( src[i] == backchar ) + /* + * 绰轮允月手元分匀凶日窒手仄卅中[勾引曰绰轮卞卅月[ + */ + continue; + + /* + * 粮及绰轮允月 侬互卅仁卅匀凶及匹 backchar 反 NULL 侬卞允月 + * 仇木互井氏元氏 + */ + backchar = '\0'; + for( j = 0 ; j < delength ; j ++ ){ + if( src[i] == dels[j] ){ + /* + * 绰轮允月 侬 分[ 仇仇匹 continue 仄卅中仪卞方曰 + * 域 侬反绰轮仄卅中仪互忡据匹五月[ + */ + backchar=src[i]; + break; + } + } + src[index++]=src[i]; + } + src[index++]='\0'; +} + +/*---------------------------------------- + * hash袄毛忒允[ 侬 卞及心银丹仇午 + * 仇木反 公及引引卅及匹失伙打伉术丞反方丹歹井日氏互 + * 中中失伙打伉术丞日仄中[ + * 娄醒 + * s 侬 + * 忒曰袄 + * int 甩永扑亘袄 + *----------------------------------------*/ +#define PRIME 211 +int hashpjw ( char* s ) +{ + char *p; + unsigned int h= 0 ,g; + for( p = s ; *p ; p ++ ){ + h = ( h<< 4 ) + (*p); + if( (g = h & 0xf0000000) != 0){ + h = h ^ (g>>24); + h = h ^ g; + } + } + return h % PRIME; +} + +/*---------------------------------------- + * 夫□市伙卞田奶件玉仄凶末弗永玄毛忒允( TCP ) + * 娄醒 + * port 夫□市伙禾□玄 + * 忒曰袄 + * -1 巨仿□ + * 1. socket扑旦 丞戊□伙及巨仿□ + * 2. bind扑旦 丞戊□伙及巨仿□ + * 3. listen扑旦 丞戊□伙及巨仿□ + ----------------------------------------*/ +int bindlocalhost( int port ) +{ + struct sockaddr_in sin; /*夫□市伙失玉伊旦迕*/ + int sfd; /*末弗永玄犯奴旦弁伉皿正*/ + int rc; /*夫□市伙伉正□件戊□玉*/ + + /*AF_INET皿夫玄戊伙 及 SOCK_STREAM */ + sfd = socket( AF_INET, SOCK_STREAM, 0 ); + if( sfd == -1 ){ + print( "%s\n" , strerror(errno ) ); + return -1; + } + + if( getReuseaddr() ) { + int sendbuff; + /* 夫□市伙失玉伊旦及疯厍迕 */ + setsockopt( sfd, SOL_SOCKET, SO_REUSEADDR, + (char *)&sendbuff, sizeof( sendbuff)); + } + + /*0弁伉失仄化袄毛医 */ + memset( &sin ,0, sizeof( struct sockaddr_in ) ); + sin.sin_family=AF_INET; + sin.sin_port = htons( port ); + sin.sin_addr.s_addr = INADDR_ANY; + + rc = bind( sfd , (struct sockaddr*)&sin, sizeof(struct sockaddr_in)); + if( rc == -1 ){ + print( "%s\n" , strerror(errno ) ); + return -1; + } + + + rc = listen( sfd , 5 ); + if( rc == -1 ){ + print( "%s\n" , strerror(errno ) ); + return -1; + } + return sfd; +} + + + +/*---------------------------------------- + * 戊生弁玄允月[( TCP ) + * 娄醒 + * hostname 涛粮允月石旦玄 + * (xx.xxx.xxx.xxx匹手中中仄xxx.co.jp午井匹手中中) + * port 涛粮允月石旦玄及禾□玄 + * 忒曰袄 + * 犯奴旦弁伉皿正( -1 及凛反巨仿□ ) + ----------------------------------------*/ +int connectHost( char* hostname , unsigned short port ) +{ + struct sockaddr_in sock; /*connect及凛卞银丹*/ + struct hostent* hoste; /*hostname及hostent*/ + int fd; /*戊生弁玄仄凶末弗永玄犯奴旦弁伉皿正*/ + int lr; /*夫□市伙伉正□件戊□玉*/ + + memset( &sock , 0 , sizeof( struct sockaddr_in ) ); + sock.sin_family = AF_INET; + sock.sin_port = htons( port ); + + /* dot notation 井升丹井毛譬屯月 */ + sock.sin_addr.s_addr = inet_addr( hostname ); + if( sock.sin_addr.s_addr == -1 ){ + /* + *巨仿□ dot notation 匹反卅中[仄凶互匀化 骚及 蟆荸瑁互 邰分[ + * dns毛夫井卅仃木壬卅日卅中凛反夫五卞中仁及手仇仇匹支匀化仁木月[ + */ + hoste = gethostbyname( hostname ); + if( hoste == NULL ){ + print( "获取主机名: %s\n", hostname); + return -1; + } + + memcpy((void*)&sock.sin_addr.s_addr , + hoste->h_addr , sizeof(struct in_addr) ); + } + + /*末弗永玄毛综月*/ + fd = socket( AF_INET, SOCK_STREAM , 0 ); + if( fd == -1 ){ + print("Cannot Create Socket(%s errno:%d)\n" + ,strerror( errno ) ,errno ); + return -1; + } + /*戊生弁玄允月*/ + lr = connect(fd,(struct sockaddr*)&sock,sizeof(struct sockaddr_in)); + if( lr != 0 ){ + print("Cannot connect. (%s errno:%d)\n" + ,strerror( errno ) ,errno ); + return -1; + } + + return fd; +} + + +/*---------------------------------------- + * 田永白央及 卞荼垫筏寞互丐月井升丹井[ + * 剂仄镀中失伙打伉术丞卞 凳[ + * 娄醒 + * char* 譬屯月 侬 + * 忒曰袄 + * 赓卞苇勾井凶荼垫筏寞及匏 失弁本旦仄凶凛卞中中袄[ + * 升丹中丹仪井午中丹午} + * existsNewLinwCharacter( "aho\nhoge\n" ) + * 分午}忒曰袄反 3 卞卅月[仇木卞镗啦允月仪[ + * -1 卅井匀凶 + * + ----------------------------------------*/ +int existsNewLineCharacter( char* line ) +{ +#if 1 + char* old = line; + do{ + if( *line == NEWLINE)return line-old; + }while( *(line++) ); +#else + int i; /*伙□皿 醒*/ + int length = strlen( line ); /*譬屯月 侬 及赢今*/ + for( i = 0 ; i < length ; i ++ ){ + if( line[i] == NEWLINE ) + return i; + } +#endif + + return -1; +} + + + +/*---------------------------------------- + * 侬 卞 侬互 歹木月桦赭毛井尹允[窒 井毛瑁户木月[ + * nindex( string , c , 1 ) 午 index( string , c ) 反 equivalent 匹丐月[ + * number互 引凶反0及凛反忒曰袄反}string午 元匹丐月[ + * + * 娄醒 + * string char* 譬屯月 侬 + * c int 譬屯月 侬 + * number int 歹月 寞 + * 忒曰袄 + * 域谯仄凶 侬及禾奶件正□ + * NULL 心勾井日卅井匀凶[ + ----------------------------------------*/ +char* nindex( char* string, int c , int number ) +{ + int i; /*伙□皿 醒*/ + int num=0; + int length = strlen( string ); /*譬屯月 侬 及赢今*/ + if( number <= 0 )return string; + for( i = 0 ; i < length ; i ++ ){ + if( string[i] == c )num++; + if( number == num ) return &string[i]; + } + return NULL; +} + +BOOL rrd( char* dirname , STRING64* buf ,int bufsize, int* index) +{ + DIR* d; + char dirn[1024]; + + d = opendir( dirname ); + if( d == NULL )return FALSE; + + while( 1 ){ + struct dirent* dent; + struct stat st; + dent = readdir( d ); + if( dent == NULL ){ + if( errno == EBADF ){ + errorprint; + closedir(d); + return FALSE; + }else + /* successful */ + break; + } + + /* . 匹铵引月白央奶伙反 引卅中 */ + if( dent->d_name[0] == '.' )continue; + + snprintf(dirn, sizeof(dirn), "%s/%s" , dirname,dent->d_name ); + if( stat( dirn , &st ) == -1 )continue; + if( S_ISDIR( st.st_mode ) ){ + if( rrd( dirn , buf ,bufsize, index) == FALSE ){ + closedir(d); + return FALSE; + } + }else{ + if( *index >= bufsize ) + break; + + strcpysafe( buf[*index].string , sizeof( buf[*index].string ), dirn ); + (*index)++; + } + } + closedir(d); + return TRUE; +} + +int rgetFileName( char* dirname , STRING64* string, int size) +{ + int index=0; + if( rrd( dirname , string ,size ,&index ) == FALSE )return -1; + else return index; +} + +BOOL checkStringsUnique( char** strings, int num ,int verbose) +{ + int i,j; + for( i = 0 ; i < num - 1; i ++ ){ + for( j = i+1 ; j < num ; j ++){ + if( !strcmp( strings[i] ,strings[j] )){ + if( verbose ) + print( "Overlapp string is %s\n", strings[i] ); + return FALSE; + } + } + } + return TRUE; +} + +BOOL PointInRect( RECT* rect, POINT* p ) +{ + if( rect->x <= p->x && p->x <= rect->x + rect->width && + rect->y <= p->y && p->y <= rect->y + rect->height ) + return TRUE; + return FALSE; +} + +BOOL CoordinateInRect( RECT* rect, int x, int y) +{ + POINT p={x,y}; + return PointInRect(rect,&p); +} + +int clipRect( RECT *rect1, RECT *rect2, RECT *ret ) +{ + if( rect1->x > rect2->x + rect2->width -1 + || rect2->x > rect1->x + rect1->width -1 + || rect1->y > rect2->y + rect2->height -1 + || rect2->y > rect1->y + rect1->height -1 ) + return 0; + ret->x = max( rect1->x, rect2->x ); + ret->y = max( rect1->y, rect2->y ); + ret->width = min( rect1->x+rect1->width, rect2->x+rect2->width ) - ret->x; + ret->height = min( rect1->y+rect1->height, rect2->y+rect2->height ) - ret->y; + return 1; +} + +BOOL isstring1or0( char* string ) +{ + if( strcasecmp(string,"TRUE" ) == 0 )return TRUE; + if( strcasecmp(string,"FALSE") == 0 )return FALSE; + if( strcasecmp(string,"1" ) == 0 )return TRUE; + if( strcasecmp(string,"0" ) == 0 )return FALSE; + if( strcasecmp(string,"ON" ) == 0 )return TRUE; + if( strcasecmp(string,"OFF" ) == 0 )return FALSE; + return FALSE; +} + +void easyGetTokenFromString( char *src,int count,char*output,int len ) +{ + int i; + int counter = 0; + + if( len <= 0 )return; + + +#define ISSPACETAB( c ) ( (c) == ' ' || (c) == '\t' ) + + for(i=0;;i++){ + if( src[i]=='\0'){ + output[0] = '\0'; + return; + } + if( i > 0 && ! ISSPACETAB( src[i-1] ) && + ! ISSPACETAB( src[i] ) ){ + continue; + } + + if( ! ISSPACETAB( src[i]) ){ + counter++; + if( counter == count){ + /* copy it */ + int j; + for(j=0;j1---- + * + * + ------------------------------------------------------------*/ +float linearDiv( float val1 , float val2 , float d ) +{ + return val1 + ( val2 - val1 ) * ( d ); +} + + +/*------------------------------------------------------------ + * 侬 及卅井井日 啦卅 侬毛len 侬午曰分仄化仿件母丞卅 + * 侬 毛勾仁月[NPC及仿件母丞由旦伐□玉戏岳卞勾井匀化月 + * + * char *cand : 仇仇井日蓟少[跳 及 侬[ + * char *out : 请 田永白央 + * int len : 请 及赢今 + ------------------------------------------------------------*/ +void makeRandomString( char *cand , char *out , int len ) +{ + int i; + int l = strlen( cand ); + + for(i=0;i= baselen; i ++ ) { + tmp[i] = src % baselen; + src /= baselen; + } + i--; + if( minus ){ + *out = '-'; + *(out+1) = base[src]; + for( j = 2; i >= 0; i --, j ++ ) { + if( j > outlen - 2 ) return NULL; + *(out+j) = base[tmp[i]]; + } + } else { + *out = base[src]; + for( j = 1; i >= 0; i --, j ++ ) { + if( j > outlen - 2 ) return NULL; + *(out+j) = base[tmp[i]]; + } + } + *(out+j) = '\0'; + return( out); +#else +/* 衙中 */ +#define CNV_NUMBER 62 + int i, j; + char base[] = { "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"}; + int tmp[64]; + int src; + if( a < 0 ) return( NULL); + if( a < CNV_NUMBER) { + *out = base[a]; + *(out+1) = '\0'; + return( out); + } + src = a; + for( i = 0; src >= CNV_NUMBER; i ++ ) { + tmp[i] = src % CNV_NUMBER; + src /= CNV_NUMBER; + } + i--; + *out = base[src]; + for( j = 1; i >= 0; i --, j ++ ) { + if( j > outlen - 2 ) return NULL; + *(out+j) = base[tmp[i]]; + } + *(out+j) = '\0'; + return( out); +#undef CNV_NUMBER +#endif +} +/* + * 芨尹日木凶 及 匹]醒袄互褐 仄化中月井譬屯月楮醒 + * -1 反覆擂陆午中丹 卅楮醒 + * + * 娄醒 + * src *int 譬屯月葭及 + * srclen int src 及 五今 + * + * 曰袄 褐 丐曰 TRUE + * 卅仄 FALSE + */ +BOOL checkRedundancy( int *src, int srclen) +{ + int i,j; + int ret = FALSE; + + for( i = 0; i < srclen; i ++ ) { + if( *(src + i) != -1 ) { + for( j = i+1; j < srclen; j ++ ) { + if( *(src +i) == *( src+j) ) { + ret = TRUE; + break; + } + } + } + } + return ret; +} +void +shuffle_ints( int num, int *a, int t ) +{ + int i; + for(i=0;i> 8 ) & 0xFF ] + ^ ( crc << 8 ) ^ BitTable[ p[ i ] ] ); + } + return crc; +} + +// Add Code By Shan 2001.06.16 +INLINE double time_diff(struct timeval subtrahend, + struct timeval subtractor) +{ + return( (subtrahend.tv_sec - subtractor.tv_sec) + + (subtrahend.tv_usec + - subtractor.tv_usec ) / (double)1E6 ); +} diff --git a/gmsv2.28_code.rar b/gmsv2.28_code.rar new file mode 100644 index 0000000..f32bb68 Binary files /dev/null and b/gmsv2.28_code.rar differ diff --git a/saac/acfamily.c b/saac/acfamily.c new file mode 100644 index 0000000..3f8d3a6 --- /dev/null +++ b/saac/acfamily.c @@ -0,0 +1,4094 @@ +#define _FAMILY_C_ + +#include "version.h" +#include "main.h" +#include "acfamily.h" +#include "util.h" +#include "saacproto_serv.h" + +#include +#include +#include +#include +#include +#include + +// 家族 Int 资料 +static char* FAMILY_INTDATA[familymaxint] = +{ + "fmindex", + "fmleadergrano", + "fmnum", + "fmjoinnum", + "fmacceptflag", + "fmsetupflag", + "fmsprite", + "fmpointindex", + "fmpopular", + "fmgold", + "fmmemberindexmaxnum", + "apply_time", + "setup_time", + "predel_time", + "memonowwritenum", + "memonum", + "fmadv", + "fmfeed", + "fmsynthesize", + "fmdealfood", + "fmpk", +#ifdef _NEW_MANOR_LAW + "fmmomentum", +#endif +}; + +// 家族 char 资料 +static char* FAMILY_CHARDATA[familymaxchar] = +{ + "fmname", + "fmleadername", + "fmleaderid", + "petname", + "petattr", + "fmrule", +}; + +// 家族成员 int 资料 +static char* MEMBER_INTDATA[memberdatamaxint] = +{ + "charlv", + "charflag", + "onlineflag", + "charfdid", + "predeltime", + "popular", +#ifdef _FMVER21 + "eventflag", +#endif +#ifdef _NEW_MANOR_LAW + "momentum", +#endif +}; + +// 家族成员 char 资料 +static char* MEMBER_CHARDATA[memberdatamaxchar] = +{ + "charname", + "charid", +}; + +// 成员种类 char 资料 +static char* MEMBERKIND_INTDATA[FMMEMBER_KINDNUM] = +{ + "无", + "一般成员", + "申请中", + "族长", + "长老", +}; + +// 家族之间留言板 +struct FMSMEMO +{ + int num; // 留言数量 + int fmsnowwritenum; // 目前留言位置 + char memodata[FMSMEMONUM][FAMILY_MEMOLEN]; // 留言内容 +}; + +// 庄园 +struct FMPOINT +{ + int fl; // 庄园进入图层 + int x; // 庄园进入X座标 + int y; // 庄园进入Y座标 + int fmfl; // 庄园族长图层 + int village; // 庄园邻近之村庄 + int hadfmindex; // 占领庄园之家族 index + char hadfmname[CHARNAME_MAX]; // 占领庄园之家族 name + int hadfmpopular; // 占领庄园之家族综合声望值 + +}; + +// 家族成员资料 +typedef struct +{ + char charname[CHARNAME_MAX]; // 成员名字 + char charid[USERID_MAX]; // 成员帐号 + int charlv; // 成员等级 + int charflag; /* + FMMEMBER_NONE 清空资料 + FMMEMBER_MEMBER 家族成员 + FMMEMBER_APPLY 申请中 + FMMEMBER_LEADER 族长 + FMMEMBER_ELDER 长老 + */ + int onlineflag; // 0:offline; gmsv index + int charfdid; // 成员在 gmsv 的 fd + int predeltime; // 预计删除成员时间 + int popular; // 成员的声望 +#ifdef _FMVER21 + int eventflag; // 是否拥有族长资格 +#endif +#ifdef _NEW_MANOR_LAW + int momentum; // 成员气势 +#endif +#ifdef _FM_MODIFY + int gsnum; // 记录玩家是在那一个game server +#endif +} MEMBERDATA; + +struct FAMILY +{ + int fmindex; // 家族 index + char fmname[CHARNAME_MAX]; // 家族名称 + char fmleadername[CHARNAME_MAX]; // 族长名称 + + char fmleaderid[USERID_MAX]; // 族长帐号 + int fmleadergrano; // 族长照片 + char petname[CHARNAME_MAX]; // 守护兽名称 + char petattr[256]; // 守护兽资料 + + int fmnum; // 家族人数,包含申请退出、加入人数 + int fmjoinnum; // 真正加入家族人数 + int fmacceptflag; // 是否接收成员 0:不接受 1:接受 + int fmsetupflag; // 0:尚未成立 1:已成立 + char fmrule[256]; // 家族主旨 + int fmsprite; // 0:光明精灵 1:黑暗精灵 + int fmpointindex; // 家族据点 index + int fmpopular; // 家族综合声望 +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + int fmtotalfame; // 家族综合 + 家族个人声望总合 +#endif +#ifdef _NEW_MANOR_LAW + int fmmomentum; // 家族气势 +#endif + int fmgold; // 家族基金 + int fmmemberindexmaxnum; // 家族目前最大人数 + int apply_time; // 家族申请时间 + int setup_time; // 家族成立时间 + int predel_time; // 预计删除家族时间 + + int memonowwritenum; // 目前留言位置 + int memonum; // 留言数量 + int fmadv; // 冒险任务声望 + int fmfeed; // 饲育声望 + int fmsynthesize; // 合成加工声望 + int fmdealfood; // 料理声望 + int fmpk; // PK声望 + char memolist[FAMILY_MEMONUM][FAMILY_MEMOLEN]; // 留言内容 + MEMBERDATA fmmemberindex[MAX_MEMBERNUM]; // 成员资料 +}; + +int db_familyupdate[MAX_FAMILY]; +int db_fmpointupdate = 0; +int db_fmsmemoupdate = 0; +int fmnownum = 0; +int fmindexmaxnum = 0; +extern gmsv gs[MAXCONNECTION]; + +struct FAMILY family[MAX_FAMILY]; +int fmpopularindex[MAX_FAMILY]; // Arminius: sort family +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 +int fmtotalfameindex[MAX_FAMILY]; +#endif +#ifdef _NEW_MANOR_LAW +int fmMomentumIndex[MAX_FAMILY]; +#endif +int fmadvindex[MAX_FAMILY]; +int fmfeedindex[MAX_FAMILY]; +int fmsynthesizeindex[MAX_FAMILY]; +int fmdealfoodindex[MAX_FAMILY]; +int fmpkindex[MAX_FAMILY]; +struct FMPOINT fmpoint[MAX_FMPOINT]; +struct FMSMEMO fmsmemo; + +// Arminius: sort family & output the sorted list +// Make a sorted index (fmindex) for the family data (family) +#ifdef _NEW_MANOR_LAW +int fmMomentumcompar(const void *indexa, const void *indexb); +#endif +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 +int fmtotalfamecompar(const void *indexa, const void *indexb); +#endif +int fmpopularcompar(const void *indexa, const void *indexb); +int fmadvcompar(const void *indexa, const void *indexb); +int fmfeedcompar(const void *indexa, const void *indexb); +int fmsynthesizecompar(const void *indexa, const void *indexb); +int fmdealfoodcompar(const void *indexa, const void *indexb); +int fmpkcompar(const void *indexa, const void *indexb); +int CheckFM(int *index, char *fmname, int fmindex); +int CheckFMUse(int index); +void setFamilyFileDataToArg(int index, char *data); +void setMemberFileDataToArg(int index, int memberindex, char *databuf); + +// sortFamily: call this after family loaded +void sortFamily(void) +{ + int i; + + for(i = 0; i < MAX_FAMILY; i++) + { +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + fmtotalfameindex[i] = i; +#endif +#ifdef _NEW_MANOR_LAW + fmMomentumIndex[i] = i; +#endif + fmpopularindex[i] = i; + fmadvindex[i] = i; + fmfeedindex[i] = i; + fmsynthesizeindex[i] = i; + fmdealfoodindex[i] = i; + fmpkindex[i] = i; + } +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + qsort(fmtotalfameindex, MAX_FAMILY, sizeof(int), &fmtotalfamecompar); +#endif + qsort(fmpopularindex, MAX_FAMILY, sizeof(int), &fmpopularcompar); + qsort(fmadvindex, MAX_FAMILY, sizeof(int), &fmadvcompar); + qsort(fmfeedindex, MAX_FAMILY, sizeof(int), &fmfeedcompar); + qsort(fmsynthesizeindex, MAX_FAMILY, sizeof(int), &fmsynthesizecompar); + qsort(fmdealfoodindex, MAX_FAMILY, sizeof(int), &fmdealfoodcompar); + qsort(fmpkindex, MAX_FAMILY, sizeof(int), &fmpkcompar); +#ifdef _NEW_MANOR_LAW + qsort(fmMomentumIndex,MAX_FAMILY,sizeof(int),&fmMomentumcompar); +#endif +} + +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 +int fmtotalfamecompar(const void *indexa, const void *indexb) +{ + int famea,fameb; + + if ( CheckFMUse(* (int*) indexa)==0 ) return 1; // empty record + if ( CheckFMUse(* (int*) indexb)==0 ) return -1; + + famea = family[ * (int*) indexa ].fmtotalfame; + fameb = family[ * (int*) indexb ].fmtotalfame; + return (famea>fameb)? -1 : 1; +} +#endif + +#ifdef _NEW_MANOR_LAW +int fmMomentumcompar(const void *indexa, const void *indexb) +{ + int momentumA,momentumB; + + if(CheckFMUse(*(int*)indexa) == 0) return 1; // empty record + if(CheckFMUse(*(int*)indexb) == 0) return -1; + + momentumA = family[*(int*)indexa].fmmomentum; + momentumB = family[*(int*)indexb].fmmomentum; + return (momentumA > momentumB) ? -1:1; +} +#endif + +int fmpopularcompar(const void *indexa, const void *indexb) +{ + int fmpopulara,fmpopularb; + + if ( CheckFMUse(* (int*) indexa)==0 ) return 1; // empty record + if ( CheckFMUse(* (int*) indexb)==0 ) return -1; + + fmpopulara = family[ * (int*) indexa ].fmpopular; + fmpopularb = family[ * (int*) indexb ].fmpopular; + return (fmpopulara>fmpopularb)? -1 : 1; +} + +int fmadvcompar(const void *indexa, const void *indexb) +{ + int fmadva,fmadvb; + + if ( CheckFMUse(* (int*) indexa)==0 ) return 1; // empty record + if ( CheckFMUse(* (int*) indexb)==0 ) return -1; + + fmadva = family[ * (int*) indexa ].fmadv; + fmadvb = family[ * (int*) indexb ].fmadv; + return (fmadva>fmadvb)? -1 : 1; +} + +int fmfeedcompar(const void *indexa, const void *indexb) +{ + int fmfeeda,fmfeedb; + + if ( CheckFMUse(* (int*) indexa)==0 ) return 1; // empty record + if ( CheckFMUse(* (int*) indexb)==0 ) return -1; + + fmfeeda = family[ * (int*) indexa ].fmfeed; + fmfeedb = family[ * (int*) indexb ].fmfeed; + return (fmfeeda>fmfeedb)? -1 : 1; +} + +int fmsynthesizecompar(const void *indexa, const void *indexb) +{ + int fmsynthesizea,fmsynthesizeb; + + if ( CheckFMUse(* (int*) indexa)==0 ) return 1; // empty record + if ( CheckFMUse(* (int*) indexb)==0 ) return -1; + + fmsynthesizea = family[ * (int*) indexa ].fmsynthesize; + fmsynthesizeb = family[ * (int*) indexb ].fmsynthesize; + return (fmsynthesizea>fmsynthesizeb)? -1 : 1; +} + +int fmdealfoodcompar(const void *indexa, const void *indexb) +{ + int fmdealfooda,fmdealfoodb; + + if ( CheckFMUse(* (int*) indexa)==0 ) return 1; // empty record + if ( CheckFMUse(* (int*) indexb)==0 ) return -1; + + fmdealfooda = family[ * (int*) indexa ].fmdealfood; + fmdealfoodb = family[ * (int*) indexb ].fmdealfood; + return (fmdealfooda>fmdealfoodb)? -1 : 1; +} + +int fmpkcompar(const void *indexa, const void *indexb) +{ + int fmpka,fmpkb; + + if ( CheckFMUse(* (int*) indexa)==0 ) return 1; // empty record + if ( CheckFMUse(* (int*) indexb)==0 ) return -1; + + fmpka = family[ * (int*) indexa ].fmpk; + fmpkb = family[ * (int*) indexb ].fmpk; + return (fmpka>fmpkb)? -1 : 1; +} + +// getFMsortedlist +// arg: buf=returned list (format: "index 名次 家族名 族长名 popular|...") +// bufsize=sizeof(buf) +// bp=begin point (bp=-1 -> begin at 0) +// ep=end point (ep=-1 -> end at MAX_FAMILY-1) +// ret: 1=success; 0=failed +// Arminius end + +// 取得家族各声望值列表 +// kindflag 1:综合 2:冒险 3:饲育 4:合成 5:料理 6:PK 7:总合(综合+个人) +int ACShowTopFMList(char *data, int datasize, int kindflag) +{ + int i = 0, j = 0; + char t1[4096]; + + strcpy(data, ""); + if (kindflag == 1) + { + for (i = 0; i < MAX_FAMILY; i++) { + if (strcmp(family[fmpopularindex[i]].fmname, "") == 0) + { + j++; + continue; + } +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + #ifdef _NEW_MANOR_LAW + sprintf(t1, "%d|%d|%s|%s|%d|%d|%d",fmtotalfameindex[i], i + 1, + family[fmtotalfameindex[i]].fmname, + family[fmtotalfameindex[i]].fmleadername, + (family[fmtotalfameindex[i]].fmpopular / 100), + (family[fmtotalfameindex[i]].fmtotalfame / 100), + (family[fmtotalfameindex[i]].fmmomentum)); + #else + sprintf(t1, "%d|%d|%s|%s|%d|%d",fmtotalfameindex[i], i + 1, + family[fmtotalfameindex[i]].fmname, + family[fmtotalfameindex[i]].fmleadername, + (family[fmtotalfameindex[i]].fmpopular / 100), + (family[fmtotalfameindex[i]].fmtotalfame / 100)); + #endif +#else + sprintf(t1, "%d|%d|%s|%s|%d", fmpopularindex[i], i + 1, + family[fmpopularindex[i]].fmname, + family[fmpopularindex[i]].fmleadername, + (family[fmpopularindex[i]].fmpopular / 100)); +#endif + if (i < MAX_FAMILY) strcat(t1, " "); + if (strlen(data) + strlen(t1) >= datasize){ + log("getFMsortedlist: datafer overflow."); + return -1; + } + strcat(data, t1); + } + } + else if (kindflag == 2) + { + for (i = 0; i < TOPFMLISTNUM; i++) { + if (strcmp(family[fmadvindex[i]].fmname, "") == 0) + { + j++; + continue; + } + sprintf(t1, "%d|%d|%s|%s|%d", fmadvindex[i], i + 1, + family[fmadvindex[i]].fmname, + family[fmadvindex[i]].fmleadername, + (family[fmadvindex[i]].fmadv / 100)); + if (i < TOPFMLISTNUM) strcat(t1, " "); + if (strlen(data) + strlen(t1) >= datasize) + { + log("getFMsortedlist: datafer overflow."); + return -1; + } + strcat(data, t1); + } + } + else if (kindflag == 3) + { + for (i = 0; i < TOPFMLISTNUM; i++) { + if (strcmp(family[fmfeedindex[i]].fmname, "") == 0) + { + j++; + continue; + } + sprintf(t1, "%d|%d|%s|%s|%d", fmfeedindex[i], i + 1, + family[fmfeedindex[i]].fmname, + family[fmfeedindex[i]].fmleadername, + (family[fmfeedindex[i]].fmfeed / 100)); + if (i < TOPFMLISTNUM) strcat(t1, " "); + if (strlen(data) + strlen(t1) >= datasize) + { + log("getFMsortedlist: datafer overflow."); + return -1; + } + strcat(data, t1); + } + } + else if (kindflag == 4) + { + for (i = 0; i < TOPFMLISTNUM; i++) { + if (strcmp(family[fmsynthesizeindex[i]].fmname, "") == 0) + { + j++; + continue; + } + sprintf(t1, "%d|%d|%s|%s|%d", fmsynthesizeindex[i], i + 1, + family[fmsynthesizeindex[i]].fmname, + family[fmsynthesizeindex[i]].fmleadername, + (family[fmsynthesizeindex[i]].fmsynthesize / 100)); + if (i < TOPFMLISTNUM) strcat(t1, " "); + if (strlen(data) + strlen(t1) >= datasize) + { + log("getFMsortedlist: datafer overflow."); + return -1; + } + strcat(data, t1); + } + } + else if (kindflag == 5) + { + for (i = 0; i < TOPFMLISTNUM; i++) { + if (strcmp(family[fmdealfoodindex[i]].fmname, "") == 0) + { + j++; + continue; + } + sprintf(t1, "%d|%d|%s|%s|%d", fmdealfoodindex[i], i + 1, + family[fmdealfoodindex[i]].fmname, + family[fmdealfoodindex[i]].fmleadername, + (family[fmdealfoodindex[i]].fmdealfood / 100)); + if (i < TOPFMLISTNUM) strcat(t1, " "); + if (strlen(data) + strlen(t1) >= datasize) + { + log("getFMsortedlist: datafer overflow."); + return -1; + } + strcat(data, t1); + } + } + else if (kindflag == 6) + { + for (i = 0; i < TOPFMLISTNUM; i++) { + if (strcmp(family[fmpkindex[i]].fmname, "") == 0) + { + j++; + continue; + } + sprintf(t1, "%d|%d|%s|%s|%d", fmpkindex[i], i + 1, + family[fmpkindex[i]].fmname, + family[fmpkindex[i]].fmleadername, + (family[fmpkindex[i]].fmpk / 100)); + if (i < TOPFMLISTNUM) strcat(t1, " "); + if (strlen(data) + strlen(t1) >= datasize) + { + log("getFMsortedlist: datafer overflow."); + return -1; + } + strcat(data, t1); + } + } +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + else if (kindflag == 7) + { + for (i = 0; i < MAX_FAMILY; i++) { + if (strcmp(family[fmtotalfameindex[i]].fmname, "") == 0) + { + j++; + continue; + } + sprintf(t1, "%d|%d|%s|%s|%d", fmtotalfameindex[i], i + 1, + family[fmtotalfameindex[i]].fmname, + family[fmtotalfameindex[i]].fmleadername, + (family[fmtotalfameindex[i]].fmtotalfame / 100)); + if (i < MAX_FAMILY) strcat(t1, " "); + if (strlen(data) + strlen(t1) >= datasize) + { + log("getFMsortedlist: datafer overflow."); + return -1; + } + strcat(data, t1); + } + } +#endif +#ifdef _NEW_MANOR_LAW + else if(kindflag == 8){ // 十大气势家族(全部气势排名都传给game server) + for(i=0;i= datasize){ + log("getFMsortedlist: datafer overflow."); + return -1; + } + strcat(data, t1); + } + } +#endif + return i - j; +} + +void AddFMMaintainSort(int index) +{ + int i = 0, j = MAX_FAMILY - 1, k; + // modify popular sort + while ((family[fmpopularindex[i]].fmpopular >= family[index].fmpopular) + && (i < MAX_FAMILY) && CheckFMUse(fmpopularindex[i])) + { + if (i == MAX_FAMILY -1) break; + i++; + } + while ((fmpopularindex[j] != index) && (j > 0)) j--; + if (j > i) + { + for (k = j; k > i; k--) fmpopularindex[k] = fmpopularindex[k - 1]; + fmpopularindex[i] = index; + } else if (j < i) { + log("ACAddFM: fmpopularindex add error (j < i)"); + } else log("ACAddFM: fmpopularindex add error (j = i)"); + // modify adv sort + i = 0;j = MAX_FAMILY;k = 0; + while ((family[fmadvindex[i]].fmadv >= family[index].fmadv) + && (i < MAX_FAMILY) && CheckFMUse(fmadvindex[i])) + { + if (i == MAX_FAMILY -1) break; + i++; + } + while ((fmadvindex[j] != index) && (j > 0)) j--; + if (j > i) + { + for (k = j; k > i; k--) fmadvindex[k] = fmadvindex[k - 1]; + fmadvindex[i] = index; + } else if (j < i) { + log("ACAddFM: fmadvindex add error (j < i)"); + } else log("ACAddFM: fmadvindex add error (j = i)"); + // modify feed sort + i = 0; j = MAX_FAMILY; k = 0; + while ((family[fmfeedindex[i]].fmfeed >= family[index].fmfeed) + && (i < MAX_FAMILY) && CheckFMUse(fmfeedindex[i])) + { + if (i == MAX_FAMILY -1) break; + i++; + } + while ((fmfeedindex[j] != index) && (j > 0)) j--; + if (j > i) + { + for (k = j; k > i; k--) fmfeedindex[k] = fmfeedindex[k - 1]; + fmfeedindex[i] = index; + } else if (j < i) { + log("ACAddFM: fmfeedindex add error (j < i)"); + } else log("ACAddFM: fmfeedindex add error (j = i)"); + // modify synthesize sort + i = 0;j = MAX_FAMILY;k = 0; + while ((family[fmsynthesizeindex[i]].fmsynthesize >= family[index].fmsynthesize) + && (i < MAX_FAMILY) && CheckFMUse(fmsynthesizeindex[i])) + { + if (i == MAX_FAMILY -1) break; + i++; + } + while ((fmsynthesizeindex[j] != index) && (j > 0)) j--; + if (j > i) + { + for (k = j; k > i; k--) fmsynthesizeindex[k] = fmsynthesizeindex[k - 1]; + fmsynthesizeindex[i] = index; + } else if (j < i) { + log("ACAddFM: fmsynthesizeindex add error (j < i)"); + } else log("ACAddFM: fmsynthesizeindex add error (j = i)"); + // modify dealfood sort + i = 0;j = MAX_FAMILY;k = 0; + while ((family[fmdealfoodindex[i]].fmdealfood >= family[index].fmdealfood) + && (i < MAX_FAMILY) && CheckFMUse(fmdealfoodindex[i])) + { + if (i == MAX_FAMILY -1) break; + i++; + } + while ((fmdealfoodindex[j] != index) && (j > 0)) j--; + if (j > i) + { + for (k = j; k > i; k--) fmdealfoodindex[k] = fmdealfoodindex[k - 1]; + fmdealfoodindex[i] = index; + } else if (j < i) { + log("ACAddFM: fmdealfoodindex add error (j < i)"); + } else log("ACAddFM: fmdealfoodindex add error (j = i)"); + // modify pk sort + i = 0;j = MAX_FAMILY;k = 0; + while ((family[fmpkindex[i]].fmpk >= family[index].fmpk) + && (i < MAX_FAMILY) && CheckFMUse(fmpkindex[i])) + { + if (i == MAX_FAMILY -1) break; + i++; + } + while ((fmpkindex[j] != index) && (j > 0)) j--; + if (j > i) + { + for (k = j; k > i; k--) fmpkindex[k] = fmpkindex[k - 1]; + fmpkindex[i] = index; + } else if (j < i) { + log("ACAddFM: fmpkindex add error (j < i)"); + } else log("ACAddFM: fmpkindex add error (j = i)"); +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + // modify pk sort + i = 0;j = MAX_FAMILY;k = 0; + while ((family[fmtotalfameindex[i]].fmtotalfame >= family[index].fmtotalfame) + && (i < MAX_FAMILY) && CheckFMUse(fmtotalfameindex[i])) + { + if (i == MAX_FAMILY -1) break; + i++; + } + while ((fmtotalfameindex[j] != index) && (j > 0)) j--; + if (j > i) + { + for (k = j; k > i; k--) fmtotalfameindex[k] = fmtotalfameindex[k - 1]; + fmtotalfameindex[i] = index; + } else if (j < i) { + log("ACAddFM: fmtotalfameindex add error (j < i)"); + } else log("ACAddFM: fmtotalfameindex add error (j = i)"); +#endif +#ifdef _NEW_MANOR_LAW + // modify momentum sort + i = 0;j = MAX_FAMILY;k = 0; + while ((family[fmMomentumIndex[i]].fmmomentum >= family[index].fmmomentum) + && (i < MAX_FAMILY) && CheckFMUse(fmMomentumIndex[i])) + { + if (i == MAX_FAMILY -1) break; + i++; + } + while ((fmMomentumIndex[j] != index) && (j > 0)) j--; + if (j > i) + { + for (k = j; k > i; k--) fmMomentumIndex[k] = fmMomentumIndex[k - 1]; + fmMomentumIndex[i] = index; + } else if (j < i) { + log("ACAddFM: fmMomentumIndex add error (j < i)"); + } else log("ACAddFM: fmMomentumIndex add error (j = i)"); +#endif +} + +void DelFMMaintainSort(int index) +{ + int i = 0,j; + // modify popular sort + while ((fmpopularindex[i] != index) && (i < MAX_FAMILY)) i++; + if (fmpopularindex[i] == index) + { + for (j = i; j < MAX_FAMILY - 1; j++) + fmpopularindex[j] = fmpopularindex[j + 1]; + fmpopularindex[MAX_FAMILY - 1] = index; // move to last one + } + // modify adv sort + i = 0;j = 0; + while ((fmadvindex[i] != index) && (i < MAX_FAMILY)) i++; + if (fmadvindex[i] == index) + { + for (j = i; j < MAX_FAMILY - 1; j++) + fmadvindex[j] = fmadvindex[j + 1]; + fmadvindex[MAX_FAMILY - 1] = index; // move to last one + } + // modify feed sort + i = 0;j = 0; + while ((fmfeedindex[i] != index) && (i < MAX_FAMILY)) i++; + if (fmfeedindex[i] == index) + { + for (j = i; j < MAX_FAMILY - 1; j++) + fmfeedindex[j] = fmfeedindex[j + 1]; + fmfeedindex[MAX_FAMILY - 1] = index; // move to last one + } + // modify synthesize sort + i = 0;j = 0; + while ((fmsynthesizeindex[i] != index) && (i < MAX_FAMILY)) i++; + if (fmsynthesizeindex[i] == index) + { + for (j = i; j < MAX_FAMILY - 1; j++) + fmsynthesizeindex[j] = fmsynthesizeindex[j + 1]; + fmsynthesizeindex[MAX_FAMILY - 1] = index; // move to last one + } + // modify dealfood sort + i = 0;j = 0; + while ((fmdealfoodindex[i] != index) && (i < MAX_FAMILY)) i++; + if (fmdealfoodindex[i] == index) + { + for (j = i; j < MAX_FAMILY - 1; j++) + fmdealfoodindex[j] = fmdealfoodindex[j + 1]; + fmdealfoodindex[MAX_FAMILY - 1] = index; // move to last one + } + // modify pk sort + i = 0;j = 0; + while ((fmpkindex[i] != index) && (i < MAX_FAMILY)) i++; + if (fmpkindex[i] == index) + { + for (j = i; j < MAX_FAMILY - 1; j++) + fmpkindex[j] = fmpkindex[j + 1]; + fmpkindex[MAX_FAMILY - 1] = index; // move to last one + } +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + // modify pk sort + i = 0;j = 0; + while ((fmtotalfameindex[i] != index) && (i < MAX_FAMILY)) i++; + if (fmtotalfameindex[i] == index) + { + for (j = i; j < MAX_FAMILY - 1; j++) + fmtotalfameindex[j] = fmtotalfameindex[j + 1]; + fmtotalfameindex[MAX_FAMILY - 1] = index; // move to last one + } +#endif +#ifdef _NEW_MANOR_LAW + // modify momentum sort + i = 0;j = 0; + while ((fmMomentumIndex[i] != index) && (i < MAX_FAMILY)) i++; + if (fmMomentumIndex[i] == index){ + for (j = i; j < MAX_FAMILY - 1; j++) + fmMomentumIndex[j] = fmMomentumIndex[j + 1]; + fmMomentumIndex[MAX_FAMILY - 1] = index; // move to last one + } +#endif +} + +// 从档案读取家族资料(启动时读取) +int readFamily(char *dir) +{ + char dirname[256]; + DIR *d; + struct dirent *de; + int i = 0, fmnum = 0, fmmaxnum = 0; + { + char tmp[256]; + snprintf(tmp, sizeof(tmp), "%s", dir); + if (mkdir(tmp, 0755) == 0) + log("create %s\n", tmp); + } + + snprintf(dirname, sizeof(dirname), "%s", dir); + d = opendir(dirname); + if (d == NULL){ + log("cannot open %s\n", dirname); + return -1; + } + de = readdir(d); + if(de == NULL){ + log("de == NULL\n"); + return -1; + } +{ + char filename[256]; + struct stat s; + for (i = 0; i < MAX_FAMILY; i++){ +// FILE *fp; + snprintf(filename, sizeof(filename), "%s/Family.%d", dirname, i); + if (stat(filename, &s) < 0)continue; + + if (!(s.st_mode & S_IFREG)){ + log("%s is not a regular file\n", filename); + continue; + } + if( readOneFamily( filename, i) != 1 ){ + log("cannot open file %s %s\n", filename, strerror(errno)); + continue; + } + fmnum = fmnum + 1; + fmmaxnum = i; + } + + fmindexmaxnum = fmmaxnum; + fmnownum = fmnum; +} + closedir(d); + +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + // 计算家族总合声望 = 家族综合声望 + 家族个人声望 + { + int i,j; + for (i = 0; i < MAX_FAMILY; i++) { + family[i].fmpopular=family[i].fmadv+family[i].fmfeed + +family[i].fmsynthesize+family[i].fmdealfood + +family[i].fmpk; + family[i].fmtotalfame=family[i].fmpopular; + for (j = 0; j < MAX_MEMBERNUM; j++) { + if ((family[i].fmmemberindex[j].charflag!=FMMEMBER_NONE) && + (family[i].fmmemberindex[j].charflag!=FMMEMBER_APPLY) ) + family[i].fmtotalfame += family[i].fmmemberindex[j].popular; + } + } + } +#endif + + sortFamily(); // Arminius: sort it + +#ifdef _DEATH_FAMILY_STRUCT // WON ADD 家族战存放胜负资料 + read_fm_pk_score(); +#endif + + return 0; +} + +// 将家族资料写入档案 +int writeFamily(char *dir) +{ + int i = 0, j = 0, k = 0; + FILE *fp; + char filename[256]; + for (i = 0; i < MAX_FAMILY; i++) + { + if (db_familyupdate[i] == 0) continue; + sprintf(filename, "%s/Family.%d", dir, i); + fp = fopen(filename, "w"); + if (fp == NULL) continue; + if ((family[i].fmindex != -1) && (strcmp(family[i].fmname, "") != 0)) + { + fprintf(fp, "fmindex=%d|fmname=%s|fmleadername=%s|fmleaderid=%s|" + "fmleadergrano=%d|petname=%s|petattr=%s|fmnum=%d|fmjoinnum=%d|" + "fmacceptflag=%d|fmsetupflag=%d|fmrule=%s|fmsprite=%d|" + "fmpointindex=%d|fmpopular=%d|fmgold=%d|fmmemberindexmaxnum=%d|" + "apply_time=%d|setup_time=%d|predel_time=%d|memonowwritenum=%d|" + "memonum=%d|fmadv=%d|fmfeed=%d|fmsynthesize=%d|fmdealfood=%d|fmpk=%d" +#ifdef _NEW_MANOR_LAW + "|fmmomentum=%d" +#endif + ,family[i].fmindex, family[i].fmname, family[i].fmleadername, + family[i].fmleaderid, family[i].fmleadergrano, family[i].petname, + family[i].petattr, family[i].fmnum, family[i].fmjoinnum, + family[i].fmacceptflag, family[i].fmsetupflag, family[i].fmrule, + family[i].fmsprite, family[i].fmpointindex, family[i].fmpopular, + family[i].fmgold, family[i].fmmemberindexmaxnum, + family[i].apply_time, family[i].setup_time, family[i].predel_time, + family[i].memonowwritenum, family[i].memonum, family[i].fmadv, + family[i].fmfeed, family[i].fmsynthesize, family[i].fmdealfood, + family[i].fmpk +#ifdef _NEW_MANOR_LAW + ,family[i].fmmomentum +#endif + ); + for (j = 0; j < family[i].memonum; j++) + fprintf(fp, "|%s%d=%s", FMMEMOLIST, j, family[i].memolist[j]); + for (k = 0; k < family[i].fmmemberindexmaxnum; k++) + { + if ((strcmp(family[i].fmmemberindex[k].charname, "") != 0) + && (strcmp(family[i].fmmemberindex[k].charid, "") != 0) + && (family[i].fmmemberindex[k].charflag != FMMEMBER_NONE)) + { +#ifdef _FMVER21 + #ifndef _NEW_MANOR_LAW + fprintf(fp, "|%s%d=charname=%s charid=%s charlv=%d charflag=%d onlineflag=%d predeltime=%d popular=%d eventflag=%d", + #else + fprintf(fp, "|%s%d=charname=%s charid=%s charlv=%d charflag=%d onlineflag=%d predeltime=%d popular=%d eventflag=%d momentum=%d", + #endif +#else + fprintf(fp, "|%s%d=charname=%s charid=%s charlv=%d charflag=%d onlineflag=%d predeltime=%d popular=%d", +#endif + FMMEMBERINDEX, k, family[i].fmmemberindex[k].charname, + family[i].fmmemberindex[k].charid, + family[i].fmmemberindex[k].charlv, + family[i].fmmemberindex[k].charflag, + family[i].fmmemberindex[k].onlineflag, + family[i].fmmemberindex[k].predeltime, + family[i].fmmemberindex[k].popular +#ifdef _FMVER21 + ,family[i].fmmemberindex[k].eventflag +#endif +#ifdef _NEW_MANOR_LAW + ,family[i].fmmemberindex[k].momentum +#endif + ); + } + } // for + fprintf(fp, "\n"); + } // if + fclose(fp); + db_familyupdate[i] = 0; + } + + return 0; +} + +// 从档案读取家族庄园(启动时读取) +int readFMPoint(char *dir) +{ + char dirname[256]; + DIR *d; + struct dirent *de; + int i = 0; + { + char tmp[256]; + snprintf(tmp, sizeof(tmp), "%s", dir); + if (mkdir(tmp, 0755) == 0) + log("create %s\n", tmp); + } + + snprintf(dirname, sizeof(dirname), "%s", dir); + d = opendir(dirname); + if (d == NULL) + { + log("无法打开文件 %s\n", dirname); + return -1; + } + while(1) + { + de = readdir(d); + if(de == NULL) break; + if (de -> d_name[0] != '.') + { + char filename[256]; + FILE *fp; + struct stat s; + snprintf(filename, sizeof(filename), "%s/%s", dirname, de -> d_name); + if (stat(filename, &s) < 0){ + continue; + } + if (!(s.st_mode & S_IFREG)) + { + log("%s is not a regular file\n", filename); + continue; + } + fp = fopen(filename, "r"); + if (fp == NULL) + { + log("无法打开文件 %s %s\n", filename, strerror(errno)); + continue; + } + while(1) + { + char line[1024]; + char data[1024]; + if (fgets(line, sizeof(line), fp) == NULL) + break; + chop(line); + easyGetTokenFromBuf(line, '|', 1, data, sizeof(data)); + fmpoint[i].fl = atoi(data); + easyGetTokenFromBuf(line, '|', 2, data, sizeof(data)); + fmpoint[i].x = atoi(data); + easyGetTokenFromBuf(line, '|', 3, data, sizeof(data)); + fmpoint[i].y = atoi(data); + easyGetTokenFromBuf(line, '|', 4, data, sizeof(data)); + fmpoint[i].fmfl = atoi(data); + easyGetTokenFromBuf(line, '|', 5, data, sizeof(data)); + fmpoint[i].village = atoi(data); + easyGetTokenFromBuf(line, '|', 6, data, sizeof(data)); + fmpoint[i].hadfmindex = atoi(data); + easyGetTokenFromBuf(line, '|', 7, data, sizeof(data)); + strcpy(fmpoint[i].hadfmname, data); + easyGetTokenFromBuf(line, '|', 8, data, sizeof(data)); + fmpoint[i].hadfmpopular = atoi(data); + + i++; + } + fclose(fp); + } + } + closedir(d); + return 0; +} + +// 将家族庄园写入档案 +int writeFMPoint(char *dir) +{ + int i = 0; + FILE *fp; + char filename[256]; + sprintf(filename, "%s/db_fmpoint", dir); + if (db_fmpointupdate == 0) + { + log("db_fmpoint 无更新资料写入文件.\n"); + return 0; + } + fp = fopen(filename, "w"); + if (fp == NULL) + { + log("无法打开文件: %s %s\n", filename, strerror(errno)); + return -1; + } + for(i = 0; i < MAX_FMPOINT; i++) + { +#ifdef _ADD_FAMILY_TAX // WON ADD 增加庄园税收 + +#else + fprintf(fp, "%d|%d|%d|%d|%d|%d|%s|%d\n", + fmpoint[i].fl, fmpoint[i].x, fmpoint[i].y, fmpoint[i].fmfl, + fmpoint[i].village, fmpoint[i].hadfmindex, fmpoint[i].hadfmname, + fmpoint[i].hadfmpopular); +#endif + } // for + fclose(fp); + db_fmpointupdate = 0; + return 0; +} + +// 从档案中读取家族之间留言资料(启动时读取) +int readFMSMemo(char *dir) +{ + char dirname[256]; + DIR *d; + struct dirent *de; + int i = 0; + { + char tmp[256]; + snprintf(tmp, sizeof(tmp), "%s", dir); + if (mkdir(tmp, 0755) == 0) + log("create %s\n", tmp); + } + + snprintf(dirname, sizeof(dirname), "%s", dir); + d = opendir(dirname); + if (d == NULL) + { + log("无法打开文件 %s\n", dirname); + return -1; + } + while(1) + { + de = readdir(d); + if(de == NULL) break; + if (de -> d_name[0] != '.') + { + char filename[256]; + FILE *fp; + struct stat s; + snprintf(filename, sizeof(filename), "%s/%s", dirname, de -> d_name); + if (stat(filename, &s) < 0){ + continue; + } + if (!(s.st_mode & S_IFREG)) + { + log("%s 不是正常文件\n", filename); + continue; + } + fp = fopen(filename, "r"); + if (fp == NULL) + { + log("无法打开文件 %s %s\n", filename, strerror(errno)); + continue; + } + { + char line[15000]; + char data[15000]; + if (fgets(line, sizeof(line), fp) == NULL) + break; + chop(line); + easyGetTokenFromBuf(line, '|', 1, data, sizeof(data)); + fmsmemo.num = atoi(data); + easyGetTokenFromBuf(line, '|', 2, data, sizeof(data)); + fmsmemo.fmsnowwritenum = atoi(data); + for (i = 0; i < fmsmemo.num; i++){ + easyGetTokenFromBuf(line, '|', 3 + i, data, sizeof(data)); + strcpy(fmsmemo.memodata[i], data); + } + } + fclose(fp); + } + } + closedir(d); + return 0; +} + +// 将家族之间留言资料写入档案 +int writeFMSMemo(char *dir) +{ + int i = 0; + FILE *fp; + char filename[256]; + sprintf(filename, "%s/db_fmsmemo", dir); + if (db_fmsmemoupdate == 0) + { + log("db_fmsmemo 无更新资料写入文件.\n"); + return 0; + } + fp = fopen(filename, "w"); + if (fp == NULL) + { + log("无法打开文件: %s %s\n", filename, strerror(errno)); + return -1; + } + fprintf(fp, "%d|%d", fmsmemo.num, fmsmemo.fmsnowwritenum); + for(i = 0; i < fmsmemo.num; i++) + { + fprintf(fp, "|%s", fmsmemo.memodata[i]); + log("%s\n", fmsmemo.memodata[i]); + } // for + fprintf(fp, "\n"); + fclose(fp); + db_fmsmemoupdate = 0; + return 0; +} + +// 取得未使用的 index +int getblankindex() +{ + int i = 0; + for(i = 0; i < MAX_FAMILY; i++) + if (((family[i].fmindex <= 0) || (family[i].fmindex > MAX_FAMILY)) + && (strcmp(family[i].fmname, "") == 0)) + return i; + return -1; +} + +// 取得未使用的 fmindex +int getblankfmindex() +{ + int i = 0, j = 0; + for (i = 1; i <= MAX_FAMILY; i++) + { + int useflag = 0; + for (j = 0; j < MAX_FAMILY; j++) + { + if (family[j].fmindex == i) + { + useflag = 1; + continue; + } + } + if (useflag == 0) + return i; + } + return -1; +} + +// 从 fmindex, fmname 取得 index +int getindex(int fmindex, char *fmname) +{ + int i = 0; + for (i = 0; i <= fmindexmaxnum; i++) + { + if ((family[i].fmindex == fmindex) + && (strcmp(family[i].fmname, fmname) == 0)) + return i; + } + return -1; +} + +// 删除庄园的家族 fmindex +int delfmpointindex(int fmindex) +{ + int i; + for (i = 0; i < MAX_FMPOINT; i++) + { + if (fmpoint[i].hadfmindex == fmindex) + { + fmpoint[i].hadfmindex = -1; + strcpy(fmpoint[i].hadfmname, "-1"); + fmpoint[i].hadfmpopular = -1; + + db_fmpointupdate = 1; + return 0; + } + } + return -1; +} + +// 检查 index 是否已使用 +int CheckFMUse(int index) +{ + if ((index >= MAX_FAMILY) || (index < 0)) + return -1; + if ((family[index].fmindex < 0) || (strcmp(family[index].fmname, "") == 0)) + return 0; + else + return 1; +} + +// 检查 index fmindex, fmname资料是否正确 +int CheckFM(int *index, char *fmname, int fmindex) +{ + if (*index == -1){ + *index = getindex(fmindex, fmname); + } + if ((*index > MAX_FAMILY) || (*index < 0)){ + log ("CheckFM_2 *index: big small? %d\n", *index); + return -1; + }else { + if ((family[*index].fmindex != fmindex) + || strcmp(family[*index].fmname, fmname) != 0) + { + log("CheckFM_3 [*index].fmindex:%d fmindex:%d [index].fmname:%s fmname:%s\n", + family[*index].fmindex, fmindex, family[*index].fmname, fmname); + return -1; + } + } + if (*index == -1){ + log ("CheckFM_4 index: -1 ? %d\n", *index); + return -1; + } + if(CheckFMUse(*index) == 0) + { + log ("CheckFM_5 index: -1 ? %d\n", *index); + return -1; + } + if (family[*index].fmnum > MAX_MEMBERNUM || family[*index].fmjoinnum > MAX_MEMBERNUM) + { + log ("CheckFM_6 fmnum: -1 ? %d\n", family[*index].fmnum); + return -1; + } + return 0; +} + +// 删除人数不足之家族或太久未上站之成员 +void delovertimeFMMem(int time) +{ + int i = 0, j = 0, k = 0; + char data[150 * MAX_FAMILY]; + extern gmsv gs[MAXCONNECTION]; + for (i = 0 ; i <= fmindexmaxnum; i++){ + if(CheckFMUse(i) == 0) + continue; + if ( ( (family[i].predel_time < time) && (family[i].predel_time != -1) + && (family[i].fmsetupflag != 1)) || (family[i].fmjoinnum==0) ){ + + log("ACDelOverTimeFM fmindex:%d fmname:%s fmjoinnum:%d flag:%d \n", + family[i].fmindex, family[i].fmname, + family[i].fmjoinnum, family[i].fmsetupflag ); + + ACDelFM(i, family[i].fmname, family[i].fmindex); + + // 传送家族已删除之讯息至各 GMSV + for (k = 0; k < MAXCONNECTION; k++){ + if (gs[k].use && gs[k].name[0]) + saacproto_ACFMAnnounce_send(k, SUCCESSFUL, + family[i].fmname, family[i].fmindex, i, + 2, "", 0); + } + + db_familyupdate[i] = 1; + continue; + } + + for (j = 1; j < family[i].fmmemberindexmaxnum; j++){ + if (family[i].fmmemberindex[j].charflag == FMMEMBER_NONE) + continue; + if ((family[i].fmmemberindex[j].predeltime < time) + && (family[i].fmmemberindex[j].predeltime != -1)){ +#ifdef _FMVER21 + ACMemberLeaveFM(i, family[i].fmname, family[i].fmindex, + family[i].fmmemberindex[j].charname, 0, j, 0); +#else + ACMemberLeaveFM(i, family[i].fmname, family[i].fmindex, + family[i].fmmemberindex[j].charname, 0, j); +#endif + db_familyupdate[i] = 1; + + /* + // 通知族长有玩家已被删除 + if (family[i].fmmemberindex[0].onlineflag > 0) + { + char buf[256]; + sprintf(buf, "(%s)因太久未上线而离开您的家族了!目前家族人数:%4d人", + family[i].fmmemberindex[j].charname, family[i].fmjoinnum); + saacproto_ACFMAnnounce_send(family[i].fmmemberindex[0].onlineflag, + SUCCESSFUL, family[i].fmname, family[i].fmindex, i, 3, buf, + family[i].fmmemberindex[0].charfdid); + } + */ + + } // if + } // for + } // for + if (db_familyupdate[i] == 1) + { + strcpy(data, ""); + for (i = 0; i <= fmindexmaxnum; i++) + { + char msg[256]; + if ((strcmp(family[i].fmname, "") != 0) && (family[i].fmindex != -1)) + { +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + sprintf(msg, "%d %s %s %d %d %d %d %d|", family[i].fmindex, family[i].fmname, + family[i].fmleadername, family[i].fmtotalfame, family[i].fmjoinnum, i, + family[i].fmsetupflag, family[i].fmacceptflag); +#else + sprintf(msg, "%d %s %s %d %d %d %d %d|", family[i].fmindex, family[i].fmname, + family[i].fmleadername, family[i].fmpopular, family[i].fmjoinnum, i, + family[i].fmsetupflag, family[i].fmacceptflag); +#endif + strcat(data, msg); + } + } + for (i = 0; i < MAXCONNECTION; i++) + { + if (gs[i].use && gs[i].name[0]) + saacproto_ACShowFMList_send(i, SUCCESSFUL, fmnownum, data); + } + } +} + +// 成立家族 +#ifdef _PERSONAL_FAME +int ACAddFM(int fd, int *workindex, char *fmname, char *fmleadername, + char *fmleaderid, int fmleaderlv, char *petname, char *petattr, + char *fmrule, int fmsprite, int fmleadergrano, int fame, int charfdid) +#else +int ACAddFM(int fd, int *workindex, char *fmname, char *fmleadername, + char *fmleaderid, int fmleaderlv, char *petname, char *petattr, + char *fmrule, int fmsprite, int fmleadergrano, int charfdid) +#endif +{ + int i = 0, index, fmindex; + time_t t1; + index = getblankindex(); + if (index == -1) { + return -1; // 家族数量已满 + } + fmindex = getblankfmindex(); + if (fmindex == -1){ + return -1; // 家族数量已满,无空的 fmindex + } + for (i = 0; i <= fmindexmaxnum; i++){ + if (strcmp(family[i].fmname, fmname) == 0) + return -2; // 已有相同家族名称存在 + } + *workindex = index; + family[index].fmindex = fmindex; + strcpy(family[index].fmname, fmname); + strcpy(family[index].fmleadername, fmleadername); + strcpy(family[index].fmleaderid, fmleaderid); + family[index].fmleadergrano = fmleadergrano; + strcpy(family[index].petname, petname); + strcpy(family[index].petattr, petattr); + family[index].fmnum = 1; + family[index].fmjoinnum = 1; + family[index].fmacceptflag = 1; + strcpy(family[index].fmrule, fmrule); + family[index].fmsprite = fmsprite; + family[index].fmpointindex = -1; + family[index].fmgold = 0; + family[index].fmmemberindexmaxnum = 1; + time(&t1); + family[index].apply_time = t1; + family[index].predel_time = t1 + PREDEL_TIME; + family[index].fmmemberindex[0].charlv = fmleaderlv; +#ifdef _FMVER21 + family[index].fmmemberindex[0].charflag = FMMEMBER_LEADER; + family[index].fmmemberindex[0].eventflag = 1; +#else + family[index].fmmemberindex[0].charflag = 1; +#endif + family[index].fmmemberindex[0].onlineflag = fd; + strcpy(family[index].fmmemberindex[0].charid, fmleaderid); + strcpy(family[index].fmmemberindex[0].charname, fmleadername); + family[index].fmmemberindex[0].charfdid = charfdid; + family[index].fmmemberindex[0].predeltime = -1; + family[index].memonowwritenum = 0; + family[index].memonum = 0; + family[index].fmpopular = 0; + family[index].fmadv = 0; + family[index].fmfeed = 0; + family[index].fmsynthesize = 0; + family[index].fmdealfood = 0; + family[index].fmpk = 0; +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + family[index].fmmemberindex[0].popular = fame; + family[index].fmtotalfame = fame; +#endif +#ifdef _NEW_MANOR_LAW + family[index].fmmomentum = 0; +#endif + + db_familyupdate[index] = 1; + fmnownum++; + if (fmindexmaxnum <= index) fmindexmaxnum = index + 1; + log("AddFM fmindexmaxnum:%d fmnownum:%d\n", fmindexmaxnum, fmnownum); + + AddFMMaintainSort(index); + + return fmindex; +} + +// 加入家族 +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 +int ACJoinFM(int fd, int index, char *fmname, int fmindex, + char *charname, char *charid, int charlv, int fame, int charfdid) +#else +int ACJoinFM(int fd, int index, char *fmname, int fmindex, + char *charname, char *charid, int charlv, int charfdid) +#endif +{ + int i = 0; + time_t t1; + if (CheckFM(&index, fmname, fmindex) < 0) return -1; + if (family[index].fmacceptflag == 0) return -2; + if (family[index].fmnum >= MAX_MEMBERNUM || family[index].fmjoinnum >= MAX_MEMBERNUM) + return -3; + + // 防止族长加入自己的家族 code:shan + if ((strcmp(family[index].fmmemberindex[0].charname, charname) == 0) + && (strcmp(family[index].fmmemberindex[0].charid, charid) == 0)) + return -1; + + for (i = 1; i < MAX_MEMBERNUM; i++){ + if ((strcmp(family[index].fmmemberindex[i].charname, "") == 0) + && (strcmp(family[index].fmmemberindex[i].charid, "") == 0)){ + strcpy(family[index].fmmemberindex[i].charname, charname); + strcpy(family[index].fmmemberindex[i].charid, charid); + family[index].fmmemberindex[i].charlv = charlv; +#ifdef _FMVER21 + family[index].fmmemberindex[i].charflag = FMMEMBER_APPLY; + family[index].fmmemberindex[i].eventflag = 0; +#else + family[index].fmmemberindex[i].charflag = 2; +#endif + family[index].fmmemberindex[i].onlineflag = fd; + family[index].fmmemberindex[i].charfdid = charfdid; + time(&t1); + family[index].fmmemberindex[i].predeltime = t1 + PREDEL_TIME; +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + family[index].fmmemberindex[i].popular = fame; + log("fame:%d\n", fame); + // 这个时候还不可以把这个人的声望加到家族 +#endif +#ifdef _NEW_MANOR_LAW + family[index].fmmemberindex[i].momentum = 0; +#endif + family[index].fmnum = family[index].fmnum + 1; + if (family[index].fmmemberindexmaxnum <= i) family[index].fmmemberindexmaxnum = i + 1; + db_familyupdate[index] = 1; +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + // 更新玩家资料 + saacproto_ACFMCharLogin_send( + family[index].fmmemberindex[i].onlineflag, + SUCCESSFUL, index,ACgetFMFloor(fmindex), family[index].fmtotalfame, + family[index].fmmemberindex[i].charflag, + family[index].fmsetupflag, 1, i, + family[index].fmmemberindex[i].popular, // Arminius 9.11 + family[index].fmmemberindex[i].charfdid +#ifdef _NEW_MANOR_LAW + ,family[index].fmmemberindex[i].momentum +#endif + ); +#else + saacproto_ACFMCharLogin_send( + family[index].fmmemberindex[i].onlineflag, + SUCCESSFUL, index,ACgetFMFloor(fmindex),family[index].fmpopular, + family[index].fmmemberindex[i].charflag, + family[index].fmsetupflag, 1, i, + family[index].fmmemberindex[i].charfdid); +#endif + // 通知族长有玩家愿意加入 + if (family[index].fmmemberindex[0].onlineflag > 0){ + char buf[256]; + sprintf(buf, "(%s lv:%d)正要求加入您的家族喔!目前家族人数:%4d人", + charname, charlv, family[index].fmjoinnum); + saacproto_ACFMAnnounce_send(family[index].fmmemberindex[0].onlineflag, + SUCCESSFUL, fmname, fmindex, index, 3, buf, + family[index].fmmemberindex[0].charfdid); + } + return 0; + } + } + return -1; +} + +// 离开家族 +int ACLeaveFM(int index, char *fmname, int fmindex, + char *charname, char* charid) +{ + int i = 0; + if (CheckFM(&index, fmname, fmindex) < 0) return -1; + + for (i = 1; i < family[index].fmmemberindexmaxnum; i++) + { + if ((strcmp(family[index].fmmemberindex[i].charname, charname) == 0) + && (strcmp(family[index].fmmemberindex[i].charid, charid) == 0)) + { +#ifdef _FMVER21 + ACMemberLeaveFM(index, fmname, fmindex, charname, 0, i, 0); +#else + ACMemberLeaveFM(index, fmname, fmindex, charname, 0, i); +#endif + db_familyupdate[index] = 1; + // 通知族长有玩家已离开家族 + if (family[index].fmmemberindex[0].onlineflag > 0) + { + char buf[256]; + sprintf(buf, "(%s)已经离开您的家族了!目前家族人数:%4d人", + charname, family[index].fmjoinnum); + saacproto_ACFMAnnounce_send(family[index].fmmemberindex[0].onlineflag, + SUCCESSFUL, fmname, fmindex, index, 3, buf, + family[index].fmmemberindex[0].charfdid); + } + return 0; + } + } + return -1; +} +#ifdef _FAMILYBANKSTONELOG +int ACgetFMBankgold(int index, char *fmname,int fmindex,int charindex) +{ + return family[index].fmgold; +} +#endif +// 修正家族资料 +// kindflag 1:是否继续招募家族成员 2:家族PK声望 3:家族守护兽 4:家族主旨 +// 5:解散家族时间 6:家族基金 7:家族冒险声望 8:家族饲育声望 +// 9:家族合成、加工声望 10:家族料理声望 11:族长禅让 +int ACFixFMData(int index, char *fmname, int fmindex, int kindflag, int charindex, + char *data1, char *data2) +{ + int recvdata = 0; + if (CheckFM(&index, fmname, fmindex) < 0) return -1; + + if (kindflag == 1 || kindflag == 2 || (kindflag >= 6 && kindflag <= 11) +#ifdef _NEW_MANOR_LAW + || kindflag == 12 || kindflag == 13 +#endif + ){ + recvdata = atoi(data1); + if (recvdata > MAXRECVPOP && (kindflag == 2 || (kindflag >= 7 && kindflag <= 10))) { + log("ACDelOverTimePOP index:%d fmname:%s kindflag:%d charindex:%d recvdata:%d\n", + index, fmname, kindflag, charindex, recvdata); + return -1; + } + } + if (kindflag == 1) + family[index].fmacceptflag = recvdata; + else if (kindflag == 2){ + family[index].fmpk = family[index].fmpk + recvdata; + if (family[index].fmpk < MINFMPOPNUM) family[index].fmpk = MINFMPOPNUM; + if (family[index].fmpk > MAXFMPOPNUM) family[index].fmpk = MAXFMPOPNUM; + }else if (kindflag == 3){ + if ((strcmp(data1, "") == 0) || (strcmp(data2, "") == 0)) return -1; + strcpy(family[index].petname, data1); + strcpy(family[index].petattr, data2); + if (family[index].fmsetupflag == 1) + family[index].predel_time = -1; + }else if (kindflag == 4){ + if (strcmp(data1, "") == 0) return -1; + strcpy(family[index].fmrule, data1); + }else if (kindflag == 5){ + time_t t1; + time(&t1); + family[index].predel_time = t1 + PREDEL_TIME; + }else if (kindflag == 6){ + if (family[index].fmgold + recvdata < 0) return -1; + family[index].fmgold = family[index].fmgold + recvdata; + if (family[index].fmgold > FMMAXGOLD) + family[index].fmgold = FMMAXGOLD; + sprintf(data2,"%d",family[index].fmgold); + } + else if (kindflag == 7){ + family[index].fmadv = family[index].fmadv + recvdata; + if (family[index].fmadv < 0) family[index].fmadv = 0; + if (family[index].fmadv > MAXFMPOPNUM) family[index].fmadv = MAXFMPOPNUM; +#ifdef _NEW_MANOR_LAW + family[index].fmmemberindex[charindex].momentum += recvdata; + if (family[index].fmmemberindex[charindex].momentum < 0) family[index].fmmemberindex[charindex].momentum = 0; + if (family[index].fmmemberindex[charindex].momentum > MAXFMPOPNUM) family[index].fmmemberindex[charindex].momentum = MAXFMPOPNUM; + family[index].fmmemberindex[charindex].popular = atoi(data2); +#endif + }else if (kindflag == 8){ + family[index].fmfeed = family[index].fmfeed + recvdata; + if (family[index].fmfeed < 0) family[index].fmfeed = 0; + if (family[index].fmfeed > MAXFMPOPNUM) family[index].fmfeed = MAXFMPOPNUM; +#ifdef _NEW_MANOR_LAW + family[index].fmmemberindex[charindex].momentum += recvdata; + if (family[index].fmmemberindex[charindex].momentum < 0) family[index].fmmemberindex[charindex].momentum = 0; + if (family[index].fmmemberindex[charindex].momentum > MAXFMPOPNUM) family[index].fmmemberindex[charindex].momentum = MAXFMPOPNUM; + family[index].fmmemberindex[charindex].popular = atoi(data2); +#endif + } +#ifndef _NEW_MANOR_LAW + else if (kindflag == 9){ + family[index].fmsynthesize = family[index].fmsynthesize + recvdata; + if (family[index].fmsynthesize < 0) family[index].fmsynthesize = 0; + if (family[index].fmsynthesize > MAXFMPOPNUM) family[index].fmsynthesize = MAXFMPOPNUM; + } + else if (kindflag == 10){ + family[index].fmdealfood = family[index].fmdealfood + recvdata; + if (family[index].fmdealfood < 0) family[index].fmdealfood = 0; + if (family[index].fmdealfood > MAXFMPOPNUM) family[index].fmdealfood = MAXFMPOPNUM; + } +#endif +#ifdef _FMVER21 + else if (kindflag == 11){ + char charname[256], charid[256]; + int charlv, onlineflag, charfdid, popular; +#ifdef _NEW_MANOR_LAW + int momentum; +#endif + int floor = ACgetFMFloor(fmindex); + if (strcmp(family[index].fmmemberindex[charindex].charname, data2) != 0 + || strcmp(family[index].fmmemberindex[charindex].charid, "") == 0) + return -1; + // shan 2002/01/04 + log("\nshan-->fmindex:%d fmname:%s newleadername:%s newleaderid->%s\n", + fmindex, fmname, family[index].fmmemberindex[charindex].charname, + family[index].fmmemberindex[charindex].charid ); + strcpy(charname, family[index].fmmemberindex[charindex].charname); + strcpy(charid, family[index].fmmemberindex[charindex].charid); + charlv = family[index].fmmemberindex[charindex].charlv; + onlineflag = family[index].fmmemberindex[charindex].onlineflag; + charfdid = family[index].fmmemberindex[charindex].charfdid; + popular = family[index].fmmemberindex[charindex].popular; +#ifdef _NEW_MANOR_LAW + momentum = family[index].fmmemberindex[charindex].momentum; +#endif + // 资料转换 + strcpy(family[index].fmmemberindex[charindex].charname, + family[index].fmmemberindex[0].charname); + strcpy(family[index].fmmemberindex[charindex].charid, + family[index].fmmemberindex[0].charid); + family[index].fmmemberindex[charindex].charlv = family[index].fmmemberindex[0].charlv; + family[index].fmmemberindex[charindex].charflag = FMMEMBER_MEMBER; + family[index].fmmemberindex[charindex].onlineflag = family[index].fmmemberindex[0].onlineflag; + family[index].fmmemberindex[charindex].charfdid = family[index].fmmemberindex[0].charfdid; + family[index].fmmemberindex[charindex].popular = family[index].fmmemberindex[0].popular; +#ifdef _NEW_MANOR_LAW + family[index].fmmemberindex[charindex].momentum = family[index].fmmemberindex[0].momentum; +#endif + + strcpy(family[index].fmmemberindex[0].charname, charname); + strcpy(family[index].fmmemberindex[0].charid, charid); + family[index].fmmemberindex[0].charlv = charlv; + family[index].fmmemberindex[0].charflag = FMMEMBER_LEADER; + family[index].fmmemberindex[0].onlineflag = onlineflag; + family[index].fmmemberindex[0].charfdid = charfdid; + family[index].fmmemberindex[0].popular = popular; +#ifdef _NEW_MANOR_LAW + family[index].fmmemberindex[0].momentum = momentum; +#endif + strcpy(family[index].fmleadername, charname); + strcpy(family[index].fmleaderid, charid); + family[index].fmleadergrano = recvdata; + strcpy(family[index].petname, ""); + strcpy(family[index].petattr, ""); + + // 更新族长资料 + if (family[index].fmmemberindex[0].onlineflag > 0) + { +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + saacproto_ACFMCharLogin_send( + family[index].fmmemberindex[0].onlineflag, + SUCCESSFUL, index, floor, family[index].fmtotalfame, + family[index].fmmemberindex[0].charflag, + family[index].fmsetupflag, 1, 0, + family[index].fmmemberindex[0].popular, // Arminius 9.11 + family[index].fmmemberindex[0].charfdid +#ifdef _NEW_MANOR_LAW + ,family[index].fmmemberindex[0].momentum +#endif + ); +#else + saacproto_ACFMCharLogin_send( + family[index].fmmemberindex[0].onlineflag, + SUCCESSFUL, index, floor, family[index].fmpopular, + family[index].fmmemberindex[0].charflag, + family[index].fmsetupflag, 1, 0, + family[index].fmmemberindex[0].charfdid); +#endif + } + // 更新成员资料 + if (family[index].fmmemberindex[charindex].onlineflag > 0) + { +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + saacproto_ACFMCharLogin_send( + family[index].fmmemberindex[charindex].onlineflag, + SUCCESSFUL, index, floor, family[index].fmtotalfame, + family[index].fmmemberindex[charindex].charflag, + family[index].fmsetupflag, 1, charindex, + family[index].fmmemberindex[charindex].popular, // Arminius 9.11 + family[index].fmmemberindex[charindex].charfdid +#ifdef _NEW_MANOR_LAW + ,family[index].fmmemberindex[charindex].momentum +#endif + ); +#else + saacproto_ACFMCharLogin_send( + family[index].fmmemberindex[charindex].onlineflag, + SUCCESSFUL, index, floor, family[index].fmpopular, + family[index].fmmemberindex[charindex].charflag, + family[index].fmsetupflag, 1, charindex, + family[index].fmmemberindex[charindex].charfdid); +#endif + } + } +#endif +#ifdef _NEW_MANOR_LAW + else if (kindflag == 12){ + family[index].fmmemberindex[charindex].momentum = recvdata; + if(family[index].fmmemberindex[charindex].momentum < 0) family[index].fmmemberindex[charindex].momentum = 0; + if(family[index].fmmemberindex[charindex].momentum > MAXFMPOPNUM) family[index].fmmemberindex[charindex].momentum = MAXFMPOPNUM; + } + else if(kindflag == 13){ + family[index].fmmemberindex[charindex].popular = recvdata; + } +#endif + if ((kindflag == 2) || (kindflag == 7) || (kindflag == 8) || (kindflag == 9) + || (kindflag == 10) +#ifdef _NEW_MANOR_LAW + || (kindflag == 12) || (kindflag == 13) +#endif + ) + { +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + // 记录玩家家族声望 +#ifndef _NEW_MANOR_LAW + if (charindex >= 0 && charindex < MAX_MEMBERNUM) + family[index].fmmemberindex[charindex].popular += recvdata; +#endif + // 计算家族声望 + family[index].fmpopular = family[index].fmadv + family[index].fmfeed + + family[index].fmsynthesize + family[index].fmdealfood + + family[index].fmpk; + { + int j; + family[index].fmtotalfame=family[index].fmpopular; +#ifdef _NEW_MANOR_LAW + family[index].fmmomentum = 0; +#endif + for (j = 0; j < MAX_MEMBERNUM; j++) { + if ((family[index].fmmemberindex[j].charflag!=FMMEMBER_NONE) && + (family[index].fmmemberindex[j].charflag!=FMMEMBER_APPLY) ) + { + family[index].fmtotalfame += family[index].fmmemberindex[j].popular; +#ifdef _NEW_MANOR_LAW + // 家族成员个人气势加总 + family[index].fmmomentum += family[index].fmmemberindex[j].momentum; +#endif + } + } +#ifdef _NEW_MANOR_LAW + // 家族气势 = (家族人数平方) / 10 + 1 + 家族成员个人气势加总 + family[index].fmmomentum += ((family[index].fmjoinnum * family[index].fmjoinnum) / 10 + 1) * 100; + log("\nACFixFMData total family momentum %d\n",family[index].fmmomentum); +#endif + } + sortFamily(); + if (family[index].fmpointindex >= 0){ + fmpoint[family[index].fmpointindex].hadfmpopular = family[index].fmtotalfame; + db_fmpointupdate = 1; + } +#else + family[index].fmpopular = family[index].fmadv + family[index].fmfeed + + family[index].fmsynthesize + family[index].fmdealfood + + family[index].fmpk; + sortFamily(); + if (family[index].fmpointindex >= 0){ + fmpoint[family[index].fmpointindex].hadfmpopular = family[index].fmpopular; + db_fmpointupdate = 1; + } + // 记录玩家家族声望 + if (charindex >= 0 && charindex < MAX_MEMBERNUM) + family[index].fmmemberindex[charindex].popular = + family[index].fmmemberindex[charindex].popular + recvdata; +#endif + // 更新族长资料 + if (family[index].fmmemberindex[0].onlineflag > 0) + { + int floor = ACgetFMFloor(fmindex); +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + saacproto_ACFMCharLogin_send( + family[index].fmmemberindex[0].onlineflag, + SUCCESSFUL, index, floor, family[index].fmtotalfame, +#ifdef _FMVER21 + family[index].fmmemberindex[0].charflag, family[index].fmsetupflag, 1, 0, +#else + 1, family[index].fmsetupflag, 1, 0, +#endif + family[index].fmmemberindex[0].popular, // Arminius 9.11 + family[index].fmmemberindex[0].charfdid +#ifdef _NEW_MANOR_LAW + ,family[index].fmmemberindex[0].momentum +#endif + ); +#else + saacproto_ACFMCharLogin_send( + family[index].fmmemberindex[0].onlineflag, + SUCCESSFUL, index, floor, family[index].fmpopular, +#ifdef _FMVER21 + family[index].fmmemberindex[0].charflag, family[index].fmsetupflag, 1, 0, +#else + 1, family[index].fmsetupflag, 1, 0, +#endif + family[index].fmmemberindex[0].charfdid); +#endif + } + } + db_familyupdate[index] = 1; + return kindflag; +} + +// 更改PK後家族PK值 +int ACFixFMPK(int winindex, char* winfmname, int winfmindex, int loseindex, + char* losefmname, int losefmindex) +{ + int award = 0; + if (CheckFM(&winindex, winfmname, winfmindex) < 0) return -1; + if (CheckFM(&loseindex, losefmname, losefmindex) < 0) return -1; + + award = (family[loseindex].fmpopular / 10); + if (family[loseindex].fmpopular - award < 0) + award = family[loseindex].fmpopular; + + family[loseindex].fmpk = family[loseindex].fmpk - award; + family[winindex].fmpk = family[winindex].fmpk + award; + + if (family[loseindex].fmpk < MINFMPOPNUM) + { +#if 1 // Robin 2003/11/27 修正输方家族PK声望到达下限时胜方可洗声望 + int overpoint; + overpoint = MINFMPOPNUM - family[loseindex].fmpk; + family[winindex].fmpk = family[winindex].fmpk - overpoint; +#endif + family[loseindex].fmpk = MINFMPOPNUM; + } + // CoolFish: 2001/11/28 MINFMPOPNUM -> MAXFMPOPNUM + if (family[winindex].fmpk > MAXFMPOPNUM) + family[winindex].fmpk = MAXFMPOPNUM; + + { + family[winindex].fmpopular = family[winindex].fmadv + family[winindex].fmfeed + + family[winindex].fmsynthesize + family[winindex].fmdealfood + + family[winindex].fmpk; + +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + { + int j; + family[winindex].fmtotalfame=family[winindex].fmpopular; + for (j = 0; j < MAX_MEMBERNUM; j++) { + if ((family[winindex].fmmemberindex[j].charflag!=FMMEMBER_NONE) && + (family[winindex].fmmemberindex[j].charflag!=FMMEMBER_APPLY) ) + family[winindex].fmtotalfame += family[winindex].fmmemberindex[j].popular; + } + } +#endif + + if (family[winindex].fmmemberindex[0].onlineflag > 0) + { + int floor = ACgetFMFloor(winfmindex); +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + saacproto_ACFMCharLogin_send( + family[winindex].fmmemberindex[0].onlineflag, + SUCCESSFUL, winindex, floor, family[winindex].fmtotalfame, + #ifdef _FMVER21 + family[winindex].fmmemberindex[0].charflag, family[winindex].fmsetupflag, 1, 0, + #else + 1, family[winindex].fmsetupflag, 1, 0, + #endif + family[winindex].fmmemberindex[0].popular, // Arminius 9.11 + family[winindex].fmmemberindex[0].charfdid + #ifdef _NEW_MANOR_LAW + ,family[winindex].fmmemberindex[0].momentum + #endif + ); +#else + saacproto_ACFMCharLogin_send( + family[winindex].fmmemberindex[0].onlineflag, + SUCCESSFUL, winindex, floor, family[winindex].fmpopular, + #ifdef _FMVER21 + family[winindex].fmmemberindex[0].charflag, family[winindex].fmsetupflag, 1, 0, + #else + 1, family[winindex].fmsetupflag, 1, 0, + #endif + family[winindex].fmmemberindex[0].charfdid); +#endif + } + family[loseindex].fmpopular = family[loseindex].fmadv + family[loseindex].fmfeed + + family[loseindex].fmsynthesize + family[loseindex].fmdealfood + + family[loseindex].fmpk; + +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + { + int j; + family[loseindex].fmtotalfame=family[loseindex].fmpopular; + for (j = 0; j < MAX_MEMBERNUM; j++) { + if ((family[loseindex].fmmemberindex[j].charflag!=FMMEMBER_NONE) && + (family[loseindex].fmmemberindex[j].charflag!=FMMEMBER_APPLY) ) + family[loseindex].fmtotalfame += family[loseindex].fmmemberindex[j].popular; + } + } +#endif + + if (family[loseindex].fmmemberindex[0].onlineflag > 0) + { + int floor = ACgetFMFloor(losefmindex); +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + saacproto_ACFMCharLogin_send( + family[loseindex].fmmemberindex[0].onlineflag, + SUCCESSFUL, loseindex, floor, family[loseindex].fmtotalfame, + #ifdef _FMVER21 + family[loseindex].fmmemberindex[0].charflag, family[loseindex].fmsetupflag, 1, 0, + #else + 1, family[loseindex].fmsetupflag, 1, 0, + #endif + family[loseindex].fmmemberindex[0].popular, // Arminius 9.11 + family[loseindex].fmmemberindex[0].charfdid + #ifdef _NEW_MANOR_LAW + ,family[loseindex].fmmemberindex[0].momentum + #endif + ); +#else + saacproto_ACFMCharLogin_send( + family[loseindex].fmmemberindex[0].onlineflag, + SUCCESSFUL, loseindex, floor, family[loseindex].fmpopular, + #ifdef _FMVER21 + family[loseindex].fmmemberindex[0].charflag, family[loseindex].fmsetupflag, 1, 0, + #else + 1, family[loseindex].fmsetupflag, 1, 0, + #endif + family[loseindex].fmmemberindex[0].charfdid); +#endif + } + } + sortFamily(); + if (family[winindex].fmpointindex >= 0) + { +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + fmpoint[family[winindex].fmpointindex].hadfmpopular = family[winindex].fmtotalfame; +#else + fmpoint[family[winindex].fmpointindex].hadfmpopular = family[winindex].fmpopular; +#endif + db_fmpointupdate = 1; + } + if (family[loseindex].fmpointindex >= 0) + { +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + fmpoint[family[loseindex].fmpointindex].hadfmpopular = family[loseindex].fmtotalfame; +#else + fmpoint[family[loseindex].fmpointindex].hadfmpopular = family[loseindex].fmpopular; +#endif + db_fmpointupdate = 1; + } + return award; +} + +// 解散家族 +int ACDelFM(int index, char *fmname, int fmindex) +{ + int i; + if (CheckFM(&index, fmname, fmindex) < 0) return -1; + + log("\nACDelFM index:%d fmname:%s fmindex:%d\n", index, fmname, fmindex); + + if (family[index].fmpointindex >= 0) + { + delfmpointindex(family[index].fmindex); + family[index].fmpointindex = -1; + } + if (family[index].memonum > 0) + { + for (i = 0; i < family[index].memonum; i++) + memset(family[index].memolist[i], 0, + sizeof(family[index].memolist[i])); + } + family[index].fmindex = -1; + memset(family[index].fmname, 0, sizeof(family[index].fmname)); + memset(family[index].memolist, 0, sizeof(family[index].memolist)); + family[index].fmnum = 0; + family[index].fmjoinnum = 0; + family[index].fmsetupflag = -1; + family[index].fmpopular = 0; + family[index].fmadv = 0; + family[index].fmfeed= 0; + family[index].fmsynthesize = 0; + family[index].fmdealfood = 0; + family[index].fmpk = 0; +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + family[index].fmtotalfame = 0; +#endif +#ifdef _NEW_MANOR_LAW + family[index].fmmomentum = 0; +#endif + for (i = 0; i < family[index].fmmemberindexmaxnum; i++) + { + // 传送最新状态给家族成员 +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + if (family[index].fmmemberindex[i].onlineflag > 0) + saacproto_ACFMCharLogin_send( + family[index].fmmemberindex[i].onlineflag, + FAILED, index, family[index].fmpointindex, + family[index].fmtotalfame, -1, family[index].fmsetupflag, 0, + i, family[index].fmmemberindex[i].popular, // Arminius 9.11 + family[index].fmmemberindex[i].charfdid + #ifdef _NEW_MANOR_LAW + ,family[index].fmmemberindex[i].momentum + #endif + ); +#else + if (family[index].fmmemberindex[i].onlineflag > 0) + saacproto_ACFMCharLogin_send( + family[index].fmmemberindex[i].onlineflag, + FAILED, index, family[index].fmpointindex, + family[index].fmpopular, -1, family[index].fmsetupflag, 0, + i, family[index].fmmemberindex[i].charfdid); +#endif + memset(family[index].fmmemberindex[i].charname, 0, + sizeof(family[index].fmmemberindex[i].charname)); + memset(family[index].fmmemberindex[i].charid, 0, + sizeof(family[index].fmmemberindex[i].charid)); + family[index].fmmemberindex[i].charflag = FMMEMBER_NONE; + family[index].fmmemberindex[i].predeltime = -1; + family[index].fmmemberindex[i].popular = 0; +#ifdef _NEW_MANOR_LAW + family[index].fmmemberindex[i].momentum = 0; +#endif + } + family[index].fmmemberindexmaxnum = 0; + fmnownum--; + if (fmindexmaxnum == index) fmindexmaxnum--; + + // 传送家族已删除之讯息至各 GMSV 以清除对战排程 + for (i = 0; i < MAXCONNECTION; i++) + { + if (gs[i].use && gs[i].name[0]) + saacproto_ACFMClearPK_send(i, SUCCESSFUL, fmname, fmindex, index); + } + + DelFMMaintainSort(index); + + db_familyupdate[i] = 1; + return 0; +} + +// 显示家族列表 +int ACShowFMList(char *data) +{ + int i = 0; + strcpy(data, ""); + + for (i = 0; i <= fmindexmaxnum; i++) + { + char msg[256]; + if ((strcmp(family[i].fmname, "") != 0) && (family[i].fmindex != -1)) + { +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + sprintf(msg, "%d %s %s %d %d %d %d %d|", family[i].fmindex, family[i].fmname, + family[i].fmleadername, family[i].fmtotalfame, family[i].fmjoinnum, i, + family[i].fmsetupflag, family[i].fmacceptflag); +#else + sprintf(msg, "%d %s %s %d %d %d %d %d|", family[i].fmindex, family[i].fmname, + family[i].fmleadername, family[i].fmpopular, family[i].fmjoinnum, i, + family[i].fmsetupflag, family[i].fmacceptflag); +#endif + strcat(data, msg); + } + } + return fmnownum; +} + +// 显示家族成员列表 +int ACShowFMMemberList(int index, int *fmacceptflag, int *fmjoinnum, char *data) +{ + int i = 0; + if ((index > MAX_FAMILY) || (index < 0)) return -1; + if (CheckFMUse(index) == 0) return -1; + + strcpy(data, ""); + *fmjoinnum = family[index].fmjoinnum; + for (i = 0; i < family[index].fmmemberindexmaxnum; i++) + { + char msg[256]; + if ((strcmp(family[index].fmmemberindex[i].charname, "") != 0) + && (strcmp(family[index].fmmemberindex[i].charid, "") != 0) + && (family[index].fmmemberindex[i].charflag != FMMEMBER_NONE)) + { +#ifdef _FM_MODIFY + #ifdef _NEW_MANOR_LAW + sprintf(msg, "%d|%s|%d|%d|%d|%d|%d|%d|%d ", i, + #else + sprintf(msg, "%d|%s|%d|%d|%d|%d|%d|%d ", i, + #endif + family[index].fmmemberindex[i].charname, + family[index].fmmemberindex[i].charlv, + family[index].fmmemberindex[i].onlineflag, + (family[index].fmmemberindex[i].popular / 100), + family[index].fmmemberindex[i].eventflag, + family[index].fmmemberindex[i].charflag, + family[index].fmmemberindex[i].gsnum + #ifdef _NEW_MANOR_LAW + ,family[index].fmmemberindex[i].momentum/100 + #endif + ); + strcat(data, msg); +#else + #ifdef _FMVER21 + sprintf(msg, "%d|%s|%d|%d|%d|%d|%d ", i, + family[index].fmmemberindex[i].charname, + family[index].fmmemberindex[i].charlv, + family[index].fmmemberindex[i].onlineflag, + (family[index].fmmemberindex[i].popular / 100), + family[index].fmmemberindex[i].eventflag, + family[index].fmmemberindex[i].charflag); + strcat(data, msg); + #else + sprintf(msg, "%d|%s|%d|%d|%d|%d ", i, + family[index].fmmemberindex[i].charname, + family[index].fmmemberindex[i].charlv, + family[index].fmmemberindex[i].onlineflag, + (family[index].fmmemberindex[i].popular / 100), + family[index].fmmemberindex[i].charflag); + strcat(data, msg); + #endif +#endif + } + } // for + *fmacceptflag = family[index].fmacceptflag; + return family[index].fmnum; +} + +// 显示家族详细资料 +int ACFMDetail(int index, char *fmname, int fmindex, char *data) +{ + if (CheckFM(&index, fmname, fmindex) < 0) return -1; + + strcpy(data, ""); + sprintf(data, "%d|%d|%s|%s|%d|%s|%s|%d|%d|%s|%d", index, family[index].fmindex, + family[index].fmname, family[index].fmleadername, + family[index].fmleadergrano, family[index].petname, family[index].petattr, + family[index].fmjoinnum, family[index].fmacceptflag, + family[index].fmrule, family[index].fmsprite ); + return 0; +} + +// 族长审核成员加入家族 +#ifdef _FMVER21 +int ACMemberJoinFM(int index, char *fmname, int fmindex, + char *charname, int charindex, int result, int meindex) +#else +int ACMemberJoinFM(int index, char *fmname, int fmindex, + char *charname, int charindex, int result) +#endif +{ + time_t t1; + int floor; + if (CheckFM(&index, fmname, fmindex) < 0) return -1; + floor = ACgetFMFloor(fmindex); + +#ifdef _FIX_LEADER_ERR // WON ADD 修正族长问题 + if (charindex == 0 ) return -1; +#endif + +#ifdef _FMVER21 + if (result < 0) return -1; + if (meindex < 0 || meindex > MAX_MEMBERNUM) return -1; +#endif + if (strcmp(family[index].fmmemberindex[charindex].charname, charname) == 0){ +#ifdef _FIXFMASSIGN // Syu ADD 修正家族一百人无法指派、移除长老 + if (family[index].fmjoinnum > MAX_MEMBERNUM) return -1; + if (result != FMMEMBER_MEMBER){ + if (result == FMMEMBER_ELDER && family[index].fmmemberindex[charindex].eventflag != 1) return -1; + if (ACFMAssignOcp(index, fmname, fmindex, charname, charindex, result) >= 0) return 0; + else return -1; + } + if( family[index].fmmemberindex[charindex].charflag == FMMEMBER_ELDER) + if (result == 1) family[index].fmmemberindex[charindex].charflag = FMMEMBER_MEMBER; +#endif + if (family[index].fmjoinnum >= MAX_MEMBERNUM) return -1; + time(&t1); + family[index].fmmemberindex[charindex].predeltime = t1 + PREDELMEMBER_TIME; + if (family[index].fmmemberindex[charindex].charflag == FMMEMBER_APPLY) family[index].fmjoinnum++; + if (family[index].fmmemberindexmaxnum <= charindex) family[index].fmmemberindexmaxnum = charindex + 1; + if (family[index].fmjoinnum >= MIN_MEMBERNUM) + { + if (family[index].fmjoinnum == MIN_MEMBERNUM) family[index].setup_time = t1; + family[index].fmsetupflag = 1; + family[index].predel_time = -1; + } + if (family[index].fmjoinnum >= MAX_MEMBERNUM) family[index].fmacceptflag = 0; +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + { + int j; + family[index].fmtotalfame=family[index].fmpopular; + for (j = 0; j < MAX_MEMBERNUM; j++) { + if ((family[index].fmmemberindex[j].charflag!=FMMEMBER_NONE) && + (family[index].fmmemberindex[j].charflag!=FMMEMBER_APPLY) ) + family[index].fmtotalfame += family[index].fmmemberindex[j].popular; + } + } +#endif +#ifdef _FMVER21 + if (result != FMMEMBER_MEMBER) + { + if (result == FMMEMBER_ELDER && family[index].fmmemberindex[charindex].eventflag != 1) + return -1; + if (ACFMAssignOcp(index, fmname, fmindex, charname, charindex, result) >= 0) + return 0; + else return -1; + } +#endif + if (family[index].fmmemberindex[charindex].onlineflag > 0){ + char buf[256]; + // 通知玩家 +#ifdef _FMVER21 + if (family[index].fmmemberindex[charindex].charflag != FMMEMBER_APPLY) + sprintf(buf, "%s族长已经将你的家族职等改为%s!", + family[index].fmname, MEMBERKIND_INTDATA[result]); + else + sprintf(buf, "恭喜你!%s已经审核完毕您的加入申请!", + family[index].fmmemberindex[meindex].charname); +#else + sprintf(buf, "恭喜你!%s族长已经审核完毕您的加入申请!", family[index].fmname); +#endif + saacproto_ACFMAnnounce_send(family[index].fmmemberindex[charindex].onlineflag, + SUCCESSFUL, fmname, fmindex, index, 3, buf, + family[index].fmmemberindex[charindex].charfdid); +#ifdef _FMVER21 + family[index].fmmemberindex[charindex].charflag = FMMEMBER_MEMBER; + // 计算家族声望 + family[index].fmpopular = family[index].fmadv + family[index].fmfeed + + family[index].fmsynthesize + family[index].fmdealfood + + family[index].fmpk; + { + int j; + family[index].fmtotalfame = family[index].fmpopular; + for (j = 0; j < MAX_MEMBERNUM; j++) + { + if ((family[index].fmmemberindex[j].charflag != FMMEMBER_NONE) && + (family[index].fmmemberindex[j].charflag != FMMEMBER_APPLY) ) + family[index].fmtotalfame += family[index].fmmemberindex[j].popular; + } + } +#else + family[index].fmmemberindex[charindex].charflag = 1; +#endif +#ifdef _NEW_MANOR_LAW + { + int i; + + family[index].fmmomentum = 0; + for(i=0;i 0) + { +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + saacproto_ACFMCharLogin_send( + family[index].fmmemberindex[0].onlineflag, + SUCCESSFUL, index, floor, family[index].fmtotalfame, + #ifdef _FMVER21 + family[index].fmmemberindex[0].charflag, family[index].fmsetupflag, 1, 0, + #else + 1, family[index].fmsetupflag, 1, 0, + #endif + family[index].fmmemberindex[0].popular, // Arminius 9.11 + family[index].fmmemberindex[0].charfdid + #ifdef _NEW_MANOR_LAW + ,family[index].fmmemberindex[0].momentum + #endif + ); +#else + saacproto_ACFMCharLogin_send( + family[index].fmmemberindex[0].onlineflag, + SUCCESSFUL, index, floor, family[index].fmpopular, + #ifdef _FMVER21 + family[index].fmmemberindex[0].charflag, family[index].fmsetupflag, 1, 0, + #else + 1, family[index].fmsetupflag, 1, 0, + #endif + family[index].fmmemberindex[0].charfdid); +#endif + } +#ifdef _FMVER21 + family[index].fmmemberindex[charindex].charflag = FMMEMBER_MEMBER; +#else + family[index].fmmemberindex[charindex].charflag = 1; +#endif + } + db_familyupdate[index] = 1; + return 0; + return -1; +} + +// 族长审核成员离开家族 +#ifdef _FMVER21 +int ACMemberLeaveFM(int index, char *fmname, int fmindex, + char *charname, int flag, int charindex, int meindex) +#else +int ACMemberLeaveFM(int index, char *fmname, int fmindex, + char *charname, int flag, int charindex) +#endif +{ + time_t t1; + if (CheckFM(&index, fmname, fmindex) < 0) return -1; +#ifdef _FMVER21 + if (meindex < 0 || meindex > MAX_MEMBERNUM) return -1; +#endif + +#ifdef _FIX_LEADER_ERR // WON ADD 修正族长问题 + if (charindex == 0 ) return -1; +#endif + + if (strcmp(family[index].fmmemberindex[charindex].charname, charname) == 0) + { + if (family[index].fmmemberindex[charindex].charflag <= 0) return -1; + if (family[index].fmmemberindex[charindex].onlineflag > 0) + { + char buf[256]; +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + saacproto_ACFMCharLogin_send( + family[index].fmmemberindex[charindex].onlineflag, + FAILED, index, family[index].fmpointindex, + 0, -1, family[index].fmsetupflag, 1, + charindex, + family[index].fmmemberindex[charindex].popular, // Arminius 9.11 + family[index].fmmemberindex[charindex].charfdid + #ifdef _NEW_MANOR_LAW + ,family[index].fmmemberindex[charindex].momentum + #endif + ); +#else + saacproto_ACFMCharLogin_send( + family[index].fmmemberindex[charindex].onlineflag, + FAILED, index, family[index].fmpointindex, + family[index].fmpopular, -1, family[index].fmsetupflag, 1, + charindex, family[index].fmmemberindex[charindex].charfdid); +#endif + // 通知玩家 + if (flag == 1) + { +#ifdef _FMVER21 + sprintf(buf, "%s已经将你踢出家族了!", family[index].fmmemberindex[meindex].charname); +#else + sprintf(buf, "%s族长已经将你踢出家族了!", family[index].fmname); +#endif + saacproto_ACFMAnnounce_send(family[index].fmmemberindex[charindex].onlineflag, + SUCCESSFUL, fmname, fmindex, index, 3, buf, + family[index].fmmemberindex[charindex].charfdid); + } + } + memset(family[index].fmmemberindex[charindex].charname, 0, + sizeof(family[index].fmmemberindex[charindex].charname)); + memset(family[index].fmmemberindex[charindex].charid, 0, + sizeof(family[index].fmmemberindex[charindex].charid)); + family[index].fmmemberindex[charindex].onlineflag = -1; + family[index].fmmemberindex[charindex].popular = 0; +#ifdef _FMVER21 + family[index].fmmemberindex[charindex].eventflag = 0; + if (family[index].fmmemberindex[charindex].charflag != FMMEMBER_APPLY) +#else + if(family[index].fmmemberindex[charindex].charflag != 2) +#endif + family[index].fmjoinnum = family[index].fmjoinnum - 1; + family[index].fmnum = family[index].fmnum - 1; + family[index].fmmemberindex[charindex].charflag = FMMEMBER_NONE; +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + { + int j; + family[index].fmtotalfame=family[index].fmpopular; + for (j = 0; j < MAX_MEMBERNUM; j++) { + if ((family[index].fmmemberindex[j].charflag!=FMMEMBER_NONE) && + (family[index].fmmemberindex[j].charflag!=FMMEMBER_APPLY) ) + family[index].fmtotalfame += family[index].fmmemberindex[j].popular; + } + } +#endif + if (family[index].fmnum < 1 || family[index].fmjoinnum < 1) + { + int i = 0, fmnum1 = 0, fmnum2 = 0; + for (i = 0; i < MAX_MEMBERNUM; i++) + { + if (family[index].fmmemberindex[i].charflag <= 0) continue; +#ifdef _FMVER21 + if (family[index].fmmemberindex[i].charflag != FMMEMBER_APPLY) +#else + if (family[index].fmmemberindex[i].charflag == 1) +#endif + fmnum1 = fmnum1 + 1; + if (family[index].fmmemberindex[i].charflag > 0) + fmnum2 = fmnum2 + 1; + } + log("MemberLeave_fmnum err!\n index:%d fmname:%s" + " orifmnum:%d orifmjoinnum:%d\n fmnum1:%d fmnum2:%d\n", + index, fmname, family[index].fmnum, + family[index].fmjoinnum, fmnum1, fmnum2); + family[index].fmjoinnum = fmnum1; + family[index].fmnum = fmnum2; + } +#ifdef _NEW_MANOR_LAW + // 家族成员个人气势设定为0 + family[index].fmmemberindex[charindex].momentum = 0; + { + int i; + + family[index].fmmomentum = 0; + for(i=0;i 0 ){ + char token[256]; + sprintf( token, "在七天之内要赶快召集10名成员,否则家族会被解散喔!剩馀%d天。", + (int)((family[index].predel_time - t1)/(60*60*24)) ); + saacproto_ACFMAnnounce_send( + family[index].fmmemberindex[0].onlineflag, + SUCCESSFUL, fmname, fmindex, index, 3, + token, family[index].fmmemberindex[0].charfdid ); + } + } + db_familyupdate[index] = 1; + return 0; + } + return -1; +} + +// 族长分配职务 +int ACFMAssignOcp(int index, char *fmname, int fmindex, + char *charname, int charindex, int result) +{ +#ifdef _FMVER21 + int floor, count = 0, i = 0; + char buf[256]; + if (CheckFM(&index, fmname, fmindex) < 0) return -1; + floor = ACgetFMFloor(fmindex); + if (result < 0) return -1; + +#ifdef _FIX_LEADER_ERR // WON ADD 修正族长问题 + if (charindex == 0 ) return -1; +#endif + + log("AsssignOcp index:%d fmindex:%d fmname:%s charname:%s charindex:%d result:%d\n", + index, fmindex, fmname, charname, charindex, result); + for (i = 0; i < MAX_MEMBERNUM; i++) + { + if (family[index].fmmemberindex[i].charflag == result + && result != FMMEMBER_MEMBER) + count++; + } + if (count >= FMELDERNUM) + { + sprintf(buf, "\n只能指派%d位家族成员成为%s喔!", + FMELDERNUM, MEMBERKIND_INTDATA[result]); + saacproto_ACFMAnnounce_send(family[index].fmmemberindex[0].onlineflag, + SUCCESSFUL, fmname, fmindex, index, 4, buf, + family[index].fmmemberindex[0].charfdid); + return -1; + } + if (strcmp(family[index].fmmemberindex[charindex].charname, charname) == 0) + { + family[index].fmmemberindex[charindex].charflag = result; + if (family[index].fmmemberindex[charindex].onlineflag > 0) + { +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + saacproto_ACFMCharLogin_send( + family[index].fmmemberindex[charindex].onlineflag, + SUCCESSFUL, index, floor, family[index].fmtotalfame, + family[index].fmmemberindex[charindex].charflag, + family[index].fmsetupflag, 1, charindex, + family[index].fmmemberindex[charindex].popular, // Arminius 9.11 + family[index].fmmemberindex[charindex].charfdid +#ifdef _NEW_MANOR_LAW + ,family[index].fmmemberindex[charindex].momentum +#endif + ); +#else + saacproto_ACFMCharLogin_send( + family[index].fmmemberindex[charindex].onlineflag, + SUCCESSFUL, index, floor, family[index].fmpopular, + family[index].fmmemberindex[charindex].charflag, + family[index].fmsetupflag, 1, charindex, + family[index].fmmemberindex[charindex].charfdid); +#endif + // 通知玩家 + sprintf(buf, "%s族长已经将你的家族职等改为%s!", family[index].fmname, + MEMBERKIND_INTDATA[result]); + saacproto_ACFMAnnounce_send(family[index].fmmemberindex[charindex].onlineflag, + SUCCESSFUL, fmname, fmindex, index, 3, buf, + family[index].fmmemberindex[charindex].charfdid); + } + if (family[index].fmmemberindex[0].onlineflag > 0) + { + // 通知族长 + sprintf(buf, "\n你已经将%s的职等改为%s了!", charname, + MEMBERKIND_INTDATA[result]); + saacproto_ACFMAnnounce_send(family[index].fmmemberindex[0].onlineflag, + SUCCESSFUL, fmname, fmindex, index, 4, buf, + family[index].fmmemberindex[0].charfdid); + } + db_familyupdate[index] = 1; + return 0; + } + log("AssignOcp Failed\n"); +#endif + return -1; +} + +// 家族成员 login +#ifdef _FM_MODIFY +int ACFMCharLogin(int fd, int index, char *fmname, int fmindex, + char *charname, char *charid, int charlv, int *floor, int *fmpopular, + int *joinflag, int *fmsetupflag, int *charindex, int charfdid, + int *charfame, int eventflag,int gsnum + #ifdef _NEW_MANOR_LAW + ,int *momentum + #endif + ) +#else + #ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + int ACFMCharLogin(int fd, int index, char *fmname, int fmindex, + char *charname, char *charid, int charlv, int *floor, int *fmpopular, + int *joinflag, int *fmsetupflag, int *charindex, int charfdid, + int *charfame, int eventflag) + #else + int ACFMCharLogin(int fd, int index, char *fmname, int fmindex, + char *charname, char *charid, int charlv, int *floor, int *fmpopular, + int *joinflag, int *fmsetupflag, int *charindex, int charfdid) + #endif +#endif +{ + int i = 0; + time_t t1; + + if (CheckFM(&index, fmname, fmindex) < 0) return -1; + + if (family[index].fmpointindex != -1) + *floor = ACgetFMFloor(fmindex); +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + *fmpopular = family[index].fmtotalfame; +#else + *fmpopular = family[index].fmpopular; +#endif + *fmsetupflag = family[index].fmsetupflag; + + for (i = 0; i < family[index].fmmemberindexmaxnum; i++){ + if ((strcmp(family[index].fmmemberindex[i].charname, charname) == 0) + && (strcmp(family[index].fmmemberindex[i].charid, charid) == 0)){ + *charindex = i; + family[index].fmmemberindex[i].onlineflag = fd; + family[index].fmmemberindex[i].charfdid = charfdid; + family[index].fmmemberindex[i].charlv = charlv; +#ifdef _FM_MODIFY + family[index].fmmemberindex[i].gsnum = gsnum; +#endif +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + *charfame = family[index].fmmemberindex[i].popular; +#endif +#ifdef _NEW_MANOR_LAW + *momentum = family[index].fmmemberindex[i].momentum; +#endif + time(&t1); + family[index].fmmemberindex[i].predeltime = t1 + PREDELMEMBER_TIME; +#ifdef _FMVER21 + *joinflag = family[index].fmmemberindex[i].charflag; + family[index].fmmemberindex[i].eventflag = eventflag; +#else + if (i == 0) *joinflag = 1; + else if ((family[index].fmmemberindex[i].charflag == 1) + || (family[index].fmmemberindex[i].charflag == 3)) + *joinflag = 2; + else *joinflag = 0; +#endif + db_familyupdate[index] = 1; + + return index; + } + } + return -1; +} + +// 家族成员离线 +int ACFMCharLogout(int index, char *fmname, int fmindex, char *charname, + char *charid, int charlv, int charfdid) +{ + int i = 0; + time_t t1; + if (CheckFM(&index, fmname, fmindex) < 0) return -1; + + for (i = 0; i < family[index].fmmemberindexmaxnum; i++) + { + if ((strcmp(family[index].fmmemberindex[i].charname, charname) == 0) + && (strcmp(family[index].fmmemberindex[i].charid, charid) == 0)) + { + family[index].fmmemberindex[i].onlineflag = 0; + family[index].fmmemberindex[i].charfdid = 0; + family[index].fmmemberindex[i].charlv = charlv; +#ifdef _FM_MODIFY + family[index].fmmemberindex[i].gsnum = 0; +#endif + time(&t1); + family[index].fmmemberindex[i].predeltime = t1 + PREDELMEMBER_TIME; + db_familyupdate[index] = 1; + return 0; + } + } + return -1; +} + +// 取得家族庄园图层 +int ACgetFMFloor(fmindex) +{ + int i = 0; + for (i = 0; i < MAX_FMPOINT; i++) + { + if (fmindex == fmpoint[i].hadfmindex) + return fmpoint[i].fmfl; + } + return -1; +} + +// 玩家手动删除角色 +int ACgetFMInfoFromChar(char *fmname, int *fmindex, + char *charname, char *charid, int *charindex) +{ + int i = 0, j = 0; + for (i = 0; i < MAX_FAMILY; i++) + { + if (family[i].fmindex <= 0) continue; + for (j = 0; j < MAX_MEMBERNUM; j++) + { + if (family[i].fmmemberindex[j].charflag <= 0) continue; + if ((strcmp(family[i].fmmemberindex[j].charname, charname) == 0) + && (strcmp(family[i].fmmemberindex[j].charid, charid) == 0)) + { + strcpy(fmname, ""); + strcpy(fmname, family[i].fmname); + *fmindex = family[i].fmindex; + *charindex = j; + db_familyupdate[i] = 1; + return i; + } + } // for + } // for + return -1; +} + +// 阅读家族留言 +int ACFMReadMemo(int index, int *dataindex, char *data) +{ + int i = 0; + char buf[256]; + strcpy(data, ""); + if (index == -1){ + return -1; + } else if (index == FMSMEMOINDEX){ + *dataindex = fmsmemo.fmsnowwritenum; + for (i = 0; i < fmsmemo.num; i++){ + sprintf(buf, "%s|", fmsmemo.memodata[i]); + strcat(data, buf); + } + return fmsmemo.num; + } + if ((index >= MAX_FAMILY) || (index < 0)) + return -1; + if (CheckFMUse(index) == 0) + return -1; + *dataindex = family[index].memonowwritenum; + for (i = 0; i < family[index].memonum; i++){ + strcpy(buf, ""); + sprintf(buf, "%s|", family[index].memolist[i]); + strcat(data, buf); + } + db_familyupdate[index] = 1; + return family[index].memonum; +} + +// 写入家族留言板 +int ACFMWriteMemo(int index, char *fmname, int fmindex, char *data) +{ + if (index == -1){ + return -1; + }else if (index == FMSMEMOINDEX){ + fmsmemo.num++; + if (fmsmemo.num > FMSMEMONUM) fmsmemo.num = FMSMEMONUM; + strcpy(fmsmemo.memodata[fmsmemo.fmsnowwritenum], data); + fmsmemo.fmsnowwritenum++; + if (fmsmemo.fmsnowwritenum >= FMSMEMONUM) fmsmemo.fmsnowwritenum = 0; + db_fmsmemoupdate = 1; + return 0; + } + if ((index > MAX_FAMILY) || (index < 0)) + return -1; + if (CheckFMUse(index) == 0) + return -1; + if ((family[index].fmindex != fmindex) || (strcmp(family[index].fmname, fmname) != 0)) { + return -1; + } + if (strlen(data) > FAMILY_MEMOLEN) return -1; + family[index].memonum++; + if (family[index].memonum > FAMILY_MEMONUM) family[index].memonum = FAMILY_MEMONUM; + strcpy(family[index].memolist[family[index].memonowwritenum], data); + family[index].memonowwritenum++; + if (family[index].memonowwritenum >= FAMILY_MEMONUM) family[index].memonowwritenum = 0; + db_familyupdate[index] = 1; + return 0; +} + +// 取得庄园列表 +int ACFMPointList(char *data) +{ + int i = 0; + char msg[256]; + strcpy(data, ""); + for (i = 0; i < MAX_FMPOINT; i++) + { + sprintf(msg, "%d|%d|%d|%d|%d|%s|%d|%d|%d ", + i, fmpoint[i].fl, fmpoint[i].x, fmpoint[i].y, + fmpoint[i].hadfmindex, fmpoint[i].hadfmname, + fmpoint[i].hadfmpopular, fmpoint[i].hadfmindex - 1, + fmpoint[i].village); + strcat(data, msg); + } + return 0; +} + + + + +// 申请庄园 +int ACSetFMPoint(int index, char *fmname, int fmindex, int fmpointindex, + int fl, int x, int y) +{ + int i = 0; + if (CheckFM(&index, fmname, fmindex) < 0) return -1; + if (family[index].fmpointindex >= 0) return -2; + if ((fmpoint[fmpointindex].x != x) || (fmpoint[fmpointindex].y != y))return -1; +#ifndef _ACFMPK_NOFREE + if (fmpoint[fmpointindex].hadfmindex > 0)return -4; + if (family[index].fmjoinnum < MINAPPLYPNUM)return -5; +#endif + + fmpoint[fmpointindex].hadfmindex = fmindex; + family[index].fmpointindex = fmpointindex; + strcpy(fmpoint[fmpointindex].hadfmname, fmname); +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + fmpoint[fmpointindex].hadfmpopular = family[index].fmtotalfame; +#else + fmpoint[fmpointindex].hadfmpopular = family[index].fmpopular; +#endif + // 更新线上家族成员状况 + for (i = 0; i < MAX_MEMBERNUM; i++){ + if (strcmp(family[index].fmmemberindex[i].charname, "") == 0) continue; + if (family[index].fmmemberindex[i].onlineflag > 0){ + int floor = ACgetFMFloor(fmindex); +#ifdef _FMVER21 +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + saacproto_ACFMCharLogin_send( + family[index].fmmemberindex[i].onlineflag, + SUCCESSFUL, index, floor, family[index].fmtotalfame, + family[index].fmmemberindex[i].charflag, family[index].fmsetupflag, 1, i, + family[index].fmmemberindex[i].popular, // Arminuis 9.11 + family[index].fmmemberindex[i].charfdid +#ifdef _NEW_MANOR_LAW + ,family[index].fmmemberindex[i].momentum +#endif + ); +#else + saacproto_ACFMCharLogin_send( + family[index].fmmemberindex[i].onlineflag, + SUCCESSFUL, index, floor, family[index].fmpopular, + family[index].fmmemberindex[i].charflag, family[index].fmsetupflag, 1, i, + family[index].fmmemberindex[i].charfdid); +#endif +#else + { + int joinflag = 0; + if (i == 0) joinflag = 1; + else joinflag = 2; + saacproto_ACFMCharLogin_send( + family[index].fmmemberindex[i].onlineflag, + SUCCESSFUL, index, floor, family[index].fmpopular, + joinflag, family[index].fmsetupflag, 1, i, + family[index].fmmemberindex[i].charfdid); + } +#endif + } + } + // 更新庄园状况 + { + char data[15000]; + if (ACFMPointList(data) >= 0){ + for (i = 0; i < MAXCONNECTION; i++) + if (gs[i].use && gs[i].name[0]) + saacproto_ACFMPointList_send(i, SUCCESSFUL, data); + } + } + + db_fmpointupdate = 1; + return 0; +} + +// 设定庄园 +int ACFixFMPoint(int winindex, char *winfmname, int winfmindex, int loseindex, + char* losefmname, int losefmindex, int village) +{ + int i = 0; + if (CheckFM(&winindex, winfmname, winfmindex) < 0) return -1; + if (CheckFM(&loseindex, losefmname, losefmindex) < 0) return -1; +#ifdef _NEW_MANOR_LAW + // 如果原家族守住了庄园 + if(fmpoint[village -1].hadfmindex == winfmindex){ + unsigned int iTotalGetGold = 0,iOldGold = 0,iTotalMamberMomentum = 0; + // 获得金钱 = (家族气势 * 10000) - (家族成员个人气势总合 * 5000) + for(i=0;i FMMAXGOLD) family[winindex].fmgold = FMMAXGOLD; + log("ACFMGetMoney fmindex:%d fmname:%s fmoldgold:%d getmoney:%d fmnewgold:%d\n", + family[winindex].fmindex,family[winindex].fmname,iOldGold,iTotalGetGold,family[winindex].fmgold); + } +#endif + delfmpointindex(losefmindex); + family[loseindex].fmpointindex = -1; + fmpoint[village -1].hadfmindex = winfmindex; + family[winindex].fmpointindex = village - 1; + strcpy(fmpoint[village - 1].hadfmname, winfmname); +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + fmpoint[village -1].hadfmpopular = family[winindex].fmtotalfame; +#else + fmpoint[village -1].hadfmpopular = family[winindex].fmpopular; +#endif +#ifdef _NEW_MANOR_LAW + // 庄园战後,家族气势全归零 + family[winindex].fmmomentum = 0; + family[loseindex].fmmomentum = 0; +#endif + // 更新线上两个家族成员资料 + for (i = 0; i < MAX_MEMBERNUM; i++){ + if (strcmp(family[winindex].fmmemberindex[i].charname, "") == 0) continue; +#ifdef _NEW_MANOR_LAW + // 庄园战後,个人气势全归零 + family[winindex].fmmemberindex[i].momentum = 0; +#endif + if (family[winindex].fmmemberindex[i].onlineflag > 0){ + int floor = ACgetFMFloor(winfmindex); +#ifdef _FMVER21 + #ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + saacproto_ACFMCharLogin_send( + family[winindex].fmmemberindex[i].onlineflag, + SUCCESSFUL, winindex, floor, family[winindex].fmtotalfame, + family[winindex].fmmemberindex[i].charflag, family[winindex].fmsetupflag, 1, i, + family[winindex].fmmemberindex[i].popular, // Arminius 9.11 + family[winindex].fmmemberindex[i].charfdid + #ifdef _NEW_MANOR_LAW + ,family[winindex].fmmemberindex[i].momentum + #endif + ); + #else + saacproto_ACFMCharLogin_send( + family[winindex].fmmemberindex[i].onlineflag, + SUCCESSFUL, winindex, floor, family[winindex].fmpopular, + family[winindex].fmmemberindex[i].charflag, family[winindex].fmsetupflag, 1, i, + family[winindex].fmmemberindex[i].charfdid); + #endif +#else + { + int joinflag = 0; + if (i == 0) joinflag = 1; + else joinflag = 2; + saacproto_ACFMCharLogin_send( + family[winindex].fmmemberindex[i].onlineflag, + SUCCESSFUL, winindex, floor, family[winindex].fmpopular, + joinflag, family[winindex].fmsetupflag, 1, i, + family[winindex].fmmemberindex[i].charfdid); + } +#endif + } + } +#ifdef _NEW_MANOR_LAW + if(loseindex >= 0){ +#endif + for (i = 0; i < MAX_MEMBERNUM; i++){ + if (strcmp(family[loseindex].fmmemberindex[i].charname, "") == 0) continue; +#ifdef _NEW_MANOR_LAW + // 庄园战後,个人气势全归零 + family[loseindex].fmmemberindex[i].momentum = 0; +#endif + if (family[loseindex].fmmemberindex[i].onlineflag > 0){ +#ifdef _FMVER21 + #ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + saacproto_ACFMCharLogin_send( + family[loseindex].fmmemberindex[i].onlineflag, + SUCCESSFUL, loseindex, -1, family[loseindex].fmtotalfame, + family[loseindex].fmmemberindex[i].charflag, family[loseindex].fmsetupflag, 1, i, + family[loseindex].fmmemberindex[i].popular, // Arminius 9.11 + family[loseindex].fmmemberindex[i].charfdid + #ifdef _NEW_MANOR_LAW + ,family[loseindex].fmmemberindex[i].momentum + #endif + ); + #else + saacproto_ACFMCharLogin_send( + family[loseindex].fmmemberindex[i].onlineflag, + SUCCESSFUL, loseindex, -1, family[loseindex].fmpopular, + family[loseindex].fmmemberindex[i].charflag, family[loseindex].fmsetupflag, 1, i, + family[loseindex].fmmemberindex[i].charfdid); + #endif +#else + { + int joinflag = 0; + if (i == 0) joinflag = 1; + else joinflag = 2; + saacproto_ACFMCharLogin_send( + family[loseindex].fmmemberindex[i].onlineflag, + SUCCESSFUL, loseindex, -1, family[loseindex].fmpopular, + joinflag, family[loseindex].fmsetupflag, 1, i, + family[loseindex].fmmemberindex[i].charfdid); + } +#endif + } + } +#ifdef _NEW_MANOR_LAW + } +#endif + // 更新庄园状况 + { + char data[15000]; + if (ACFMPointList(data) >= 0){ + for (i = 0; i < MAXCONNECTION; i++) + if (gs[i].use && gs[i].name[0]) + saacproto_ACFMPointList_send(i, SUCCESSFUL, data); + } + } + db_fmpointupdate = 1; + return 0; +} + +// 族长广播 +int ACFMAnnounce(char *fmname, int fmindex, int index, char *data, int color) +{ + if (CheckFM(&index, fmname, fmindex) < 0) return -1; + return 0; +} + +// 取得家族资料 +// kindflag 1:家族银行 +int ACGetFMData(int index, char *fmname, int fmindex, int kindflag, int *data) +{ + if (CheckFM(&index, fmname, fmindex) < 0) return -1; + + if (kindflag == 1) + *data = family[index].fmgold; + return 0; +} + +void setMemberFileDataToArg(int index, int memberindex, char *data) +{ + int i = 0; + char value[256]; + char *ptr; + if (index < 0 || index > MAX_FAMILY) return; + if (strcmp(data, "") == 0) return; + ptr = (char *)strstr(data, "="); + if (ptr == NULL) return; + strcpy(ptr, ""); + strcpy(value, ptr + 1); + for (i = 0; i < memberdatamaxint; i++){ + if (strcmp(data, MEMBER_INTDATA[i]) == 0){ + switch(i){ + case 0: + family[index].fmmemberindex[memberindex].charlv = atoi(value); + break; + case 1: + family[index].fmmemberindex[memberindex].charflag = atoi(value); + break; + case 2: + family[index].fmmemberindex[memberindex].onlineflag = atoi(value); + break; + case 3: + family[index].fmmemberindex[memberindex].charfdid = atoi(value); + break; + case 4: + family[index].fmmemberindex[memberindex].predeltime = atoi(value); + break; + case 5: + family[index].fmmemberindex[memberindex].popular = atoi(value); + break; +#ifdef _FMVER21 + case 6: + family[index].fmmemberindex[memberindex].eventflag = atoi(value); + break; +#endif +#ifdef _NEW_MANOR_LAW + case 7: + family[index].fmmemberindex[memberindex].momentum = atoi(value); + break; +#endif + default: + break; + } + return; + } + } + for (i = 0; i < memberdatamaxchar; i++){ + if (strcmp(data, MEMBER_CHARDATA[i]) == 0){ + switch(i){ + case 0: + strcpy(family[index].fmmemberindex[memberindex].charname, value); + break; + case 1: + strcpy(family[index].fmmemberindex[memberindex].charid, value); + break; + default: + break; + } + return; + } + } +} + +void setFamilyFileDataToArg(int index, char *data) +{ + int i = 0, j = 0; + char value[1024]; + char *ptr; + if (index < 0 || index > MAX_FAMILY) return; + if (strcmp(data, "") == 0) return; + ptr = (char *)strstr(data, "="); + if (ptr == NULL) return; + strcpy(ptr, ""); + strcpy(value, ptr + 1); + for (i = 0; i < familymaxint; i++){ + if (strcmp(data, FAMILY_INTDATA[i]) == 0){ + switch(i){ + case 0: + family[index].fmindex = atoi(value); + break; + case 1: + family[index].fmleadergrano = atoi(value); + break; + case 2: + family[index].fmnum = atoi(value); + break; + case 3: + family[index].fmjoinnum = atoi(value); + break; + case 4: + family[index].fmacceptflag = atoi(value); + break; + case 5: + family[index].fmsetupflag = atoi(value); + break; + case 6: + family[index].fmsprite = atoi(value); + break; + case 7: + family[index].fmpointindex = atoi(value); + break; + case 8: + family[index].fmpopular = atoi(value); + break; + case 9: + family[index].fmgold = atoi(value); + break; + case 10: + family[index].fmmemberindexmaxnum = atoi(value); + break; + case 11: + family[index].apply_time = atoi(value); + break; + case 12: + family[index].setup_time = atoi(value); + break; + case 13: + family[index].predel_time = atoi(value); + break; + case 14: + family[index].memonowwritenum = atoi(value); + break; + case 15: + family[index].memonum = atoi(value); + break; + case 16: + family[index].fmadv = atoi(value); + break; + case 17: + family[index].fmfeed = atoi(value); + break; + case 18: + family[index].fmsynthesize = atoi(value); + break; + case 19: + family[index].fmdealfood = atoi(value); + break; + case 20: + family[index].fmpk = atoi(value); + break; +#ifdef _NEW_MANOR_LAW + case 21: + family[index].fmmomentum = atoi(value); + break; +#endif + default: + break; + } + return; + } + } + for (i = 0; i < familymaxchar; i++){ + if (strcmp(data, FAMILY_CHARDATA[i]) == 0){ + switch(i){ + case 0: + strcpy(family[index].fmname, value); + break; + case 1: + strcpy(family[index].fmleadername, value); + break; + case 2: + strcpy(family[index].fmleaderid, value); + break; + case 3: + strcpy(family[index].petname, value); + break; + case 4: + strcpy(family[index].petattr, value); + break; + case 5: + strcpy(family[index].fmrule, value); + break; + default: + break; + } + return; + } + } + for (i = 0; i < FAMILY_MEMONUM; i ++){ + char memolist[256]; + sprintf(memolist, "%s%d", FMMEMOLIST, i); + if (strcmp(data, memolist) == 0){ + strcpy(family[index].memolist[i], value); + return; + } + } + for (i = 0; i < MAX_MEMBERNUM; i ++){ + char memberdata[256]; + sprintf(memberdata, "%s%d", FMMEMBERINDEX, i); + if (strcmp(data, memberdata) == 0){ + for (j = 1; j < memberdatamaxint + memberdatamaxchar; j++){ + char databuf[256]; + easyGetTokenFromBuf(value, ' ', j, databuf, sizeof(databuf)); + if (strcmp(databuf, "") == 0) continue; + setMemberFileDataToArg(index, i, databuf); + } + return; + } + } + +} + +// GM修改家族资料 +int ACGMFixFMData(int index, char *fmname, char *charid, char *cmd, + char *data) +{ + int i = 0,charindex = -1; + int floor = ACgetFMFloor(index); + if (index < 0 || index > MAX_FAMILY) return -1; + log("GMFixFMData index:%d charid:%s cmd:%s data:%s\n", + index, charid, cmd, data); + strcpy(fmname, family[index].fmname); + if (charid[0] == '-' && charid[1] == '1') + { + for (i = 0; i < familymaxint; i++) + { + if (strcmp(cmd, FAMILY_INTDATA[i]) == 0) + { + switch(i) + { + case 2: + family[index].fmnum = atoi(data); + log("fmnum:%s\n", data); + break; + case 3: + family[index].fmjoinnum = atoi(data); + log("fmjoinnum:%s\n", data); + break; + case 4: + family[index].fmacceptflag = atoi(data); + log("fmacceptflag:%s\n", data); + break; + case 5: + family[index].fmsetupflag = atoi(data); + log("fmsetupflag:%s\n", data); + break; + case 6: + family[index].fmsprite = atoi(data); + log("fmsprite:%s\n", data); + break; + case 7: + family[index].fmpointindex = atoi(data); + log("fmpointindex:%s\n", data); + break; + case 8: + family[index].fmpopular = atoi(data); + log("fmpopular:%s\n", data); + break; + case 9: + family[index].fmgold = atoi(data); + log("fmgold:%s\n", data); + break; + case 11: + family[index].apply_time = atoi(data); + log("apply_time:%s\n", data); + break; + case 12: + family[index].setup_time = atoi(data); + log("setup_time:%s\n", data); + break; + case 13: + family[index].predel_time = atoi(data); + log("predel_time:%s\n", data); + break; + case 16: + family[index].fmadv = atoi(data); + log("adv:%s\n", data); + break; + case 17: + family[index].fmfeed = atoi(data); + log("feed:%s\n", data); + break; + case 18: + family[index].fmsynthesize = atoi(data); + log("synthesize:%s\n", data); + break; + case 19: + family[index].fmdealfood = atoi(data); + log("dealfood:%s\n", data); + break; + case 20: + family[index].fmpk = atoi(data); + log("pk:%s\n", data); + break; +#ifdef _NEW_MANOR_LAW + case 21: + family[index].fmmomentum = atoi(data); + log("momentum:%s\n", data); + for(i=0;i 0){ + charindex = i; + break; + } + } + // 找不到家族成员 + if(charindex == -1){ + log("FMName:%s,id:%s\n",fmname,charid); + return -1; + } + for(i = 0; i < memberdatamaxint; i++){ + if (strcmp(cmd, MEMBER_INTDATA[i]) == 0) + { + switch(i) + { + case 0: + family[index].fmmemberindex[charindex].charlv = atoi(data); + log("charlv:%s\n", data); + break; + case 1: + family[index].fmmemberindex[charindex].charflag = atoi(data); + log("charflag:%s\n", data); + break; + case 2: + family[index].fmmemberindex[charindex].onlineflag = atoi(data); + log("onlineflag:%s\n", data); + break; + case 3: + family[index].fmmemberindex[charindex].charfdid = atoi(data); + log("charfdid:%s\n", data); + break; + case 4: + family[index].fmmemberindex[charindex].predeltime = atoi(data); + log("predeltime:%s\n", data); + break; + case 5: + family[index].fmmemberindex[charindex].popular = atoi(data); + log("popular:%s\n", data); + // 计算家族声望 + family[index].fmpopular = family[index].fmadv + family[index].fmfeed + + family[index].fmsynthesize + family[index].fmdealfood + + family[index].fmpk; + family[index].fmtotalfame = family[index].fmpopular; + for(i = 0;i < MAX_MEMBERNUM;i++){ + if((family[index].fmmemberindex[i].charflag != FMMEMBER_NONE) && + (family[index].fmmemberindex[i].charflag != FMMEMBER_APPLY)) + family[index].fmtotalfame += family[index].fmmemberindex[i].popular; + } + break; + case 6: + family[index].fmmemberindex[charindex].eventflag = atoi(data); + log("eventflag:%s\n", data); + break; +#ifdef _NEW_MANOR_LAW + case 7: + family[index].fmmemberindex[charindex].momentum = atoi(data); + log("momentum:%s\n", data); + for(i=0;i + family[index].fmmemberindex[tmpindex].popular) + tmpindex = i; + } + } + } + log("ChangeFMLeader_1 tmpindex:%d\n", tmpindex); + if (tmpindex == 0) return -1; // shan return 0 -> -1 + sprintf(buf, "%d", family[index].fmleadergrano); + if (ACFixFMData(index, fmname, fmindex, 11, tmpindex, buf, + family[index].fmmemberindex[tmpindex].charname) < 0) + return -1; + log("ChangeFMLeader_2 tmpindex:%d\n", tmpindex); + if (family[index].fmmemberindex[tmpindex].onlineflag > 0) + { + char tmpbuf[256]; + sprintf(tmpbuf, "您已经退出家族了~\n族长职位已让给%s,辛苦你了!", + family[index].fmmemberindex[0].charname); + saacproto_ACFMAnnounce_send( + family[index].fmmemberindex[tmpindex].onlineflag, + SUCCESSFUL, fmname, fmindex, index, 4, tmpbuf, + family[index].fmmemberindex[tmpindex].charfdid); + } + ACMemberLeaveFM(index, fmname, fmindex, + family[index].fmmemberindex[tmpindex].charname, 0, tmpindex, 0); + return 0; +} + +#ifdef _LEADERFUNCHECK +int CheckLeaderQ(int index, char *fmname, int fmindex, char *charname, char *charid) +{ + int result = -1; + if(CheckFM(&index, fmname, fmindex) < 0) return -1; + if ((strcmp(family[index].fmmemberindex[0].charname, charname) == 0) + && (strcmp(family[index].fmmemberindex[0].charid, charid) == 0)) + result = 0; + return result; +} +#endif + +#ifdef _ACFMPK_LIST +FamilyPKSchedule FMPK_List[FMPKLIST_MAXNUM]; +void FMPK_InitList( void) +{ + int i; + for( i=0; i= FMPKLIST_MAXNUM ) return -1; + return FMPK_List[ti].pkflg; +} +char *FMPK_GetData( int ti) +{ + if( ti <0 || ti >= FMPKLIST_MAXNUM ) return NULL; + return FMPK_List[ti].Data; +} +int FMPK_SetData( int ti, int Pkflg, char *Data, int sizes) +{ + if( ti <0 || ti >= FMPKLIST_MAXNUM ) return 0; + memcpy( FMPK_List[ti].Data, Data, sizes+1); + FMPK_List[ti].pkflg = Pkflg; + return 1; +} + +#endif + +int readOneFamilyFromTi( int ti) +{ + char filename[256]; + struct stat s; + + snprintf(filename, sizeof(filename), "%s/Family.%d", familydir, ti); + + if (stat(filename, &s) < 0)return 0; + if (!(s.st_mode & S_IFREG)){ + log("%s is not a regular file\n", filename); + return 0; + } + if( readOneFamily( filename, ti) != 1 ){ + log("cannot open file %s %s\n", filename, strerror(errno)); + return 0; + } +/* + if( readOneFamily( filename, ti) != 1 ){ + log("read:%s Error !! \n", filename); + }else{ + log("read:%s OK !! \n", filename); + } +*/ + return 1; +} + +//andy_add 2003/06/16 +int readOneFamily( char *filename, int i) +{ + char line[40000], data[40000]; + FILE *fp=NULL; + int j; + int m = 0, fmnum1 = 0, fmnum2 = 0; + + if( (fp = fopen(filename, "r") ) == NULL ) return 0; + if (fgets(line, sizeof(line), fp) == NULL) return 0; + fclose( fp); + + chop(line); + for (j = 1; j <= familymaxint + familymaxchar + MAX_MEMBERNUM + FAMILY_MEMONUM; j ++){ + easyGetTokenFromBuf(line, '|', j, data, sizeof(data)); + if (strcmp(data, "") == 0) continue; + setFamilyFileDataToArg( i, data); + } + if (family[i].fmgold > FMMAXGOLD) family[i].fmgold = FMMAXGOLD; + if (family[i].fmgold < 0) family[i].fmgold = 0; + for (m = 0; m < MAX_MEMBERNUM; m++){ + if (family[i].fmmemberindex[m].charflag <= 0) continue; + if (family[i].fmmemberindex[m].charflag != FMMEMBER_APPLY) + fmnum1 = fmnum1 + 1; + if (family[i].fmmemberindex[m].charflag > 0 ) + fmnum2 = fmnum2 + 1; + } + family[i].fmjoinnum = fmnum1; + family[i].fmnum = fmnum2; + if (family[i].fmjoinnum >= MIN_MEMBERNUM){ + family[i].fmsetupflag = 1; + family[i].predel_time = -1; + db_familyupdate[i] = 1; + }else if (family[i].fmjoinnum < MIN_MEMBERNUM){ + family[i].fmsetupflag = 0; + if (family[i].predel_time == -1) { + time_t t1; + time(&t1); + family[i].predel_time = t1 + PREDEL_TIME; + db_familyupdate[i] = 1; + } + } + return 1; +} + + +#ifdef _DEATH_FAMILY_GM_COMMAND // WON ADD 家族战GM指令 +void saacproto_ACRELOADFM_recv( int fd, int charindex ) +{ + log("\n won test 51 ==>"); + + readFamily(familydir); + + log("\n won test 53 ==>" ); + + saacproto_ACRELOADFM_send( fd, charindex ); + +} + +#endif + +#ifdef _DEATH_FAMILY_LOGIN_CHECK // WON ADD 家族战登入检查 +void saacproto_ACFMCharLogin2_recv( int fd, char *char_id, char *char_name, int charindex ) +{ + int i, j; + char data[512] = {0}; + + for( i=0; i i(%d) fmsprite(%d) charflag(%d)", i, family[i].fmsprite, family[i].fmmemberindex[j].charflag ); + log("\n won test 2 ==> fmsetupflag(%d) fmname(%s)", family[i].fmsetupflag, family[i].fmname ); + log("\n won test 3 ==> data(%s)", data ); + + saacproto_ACFMCharLogin2_send(fd, SUCCESSFUL, charindex, data ); + + return; + } + } + } + + saacproto_ACFMCharLogin2_send(fd, FAILED, charindex, data ); + +} +#endif + +#ifdef _DEATH_FAMILY_GM_COMMAND // WON ADD 家族战GM指令 +char *get_fm_leader_index( int fm_index ) +{ + + return family[ fm_index ].fmname; + +} +#endif + + +#ifdef _DEATH_FAMILY_STRUCT // WON ADD 家族战存放胜负资料 + +FM_PK_STRUCT fm_pk_struct; + +void setInt_fm_pk_struct( int index, int type, int num ) +{ + switch( type ){ + case FM_INDEX: + fm_pk_struct.fm_index[index] = num; + break; + case FM_WIN: + fm_pk_struct.fm_win[index] = num; + break; + case FM_LOSE: + fm_pk_struct.fm_lose[index] = num; + break; + case FM_SCORE: + fm_pk_struct.fm_score[index] = num; + break; + } +} + +void setChar_fm_pk_struct( int index, int type, char *msg ) +{ + switch( type ){ + case FM_NAME: + strcpy( fm_pk_struct.fm_name[index], msg ); + break; + } +} + +int getInt_fm_pk_struct( int index, int type ) +{ + switch( type ){ + case FM_INDEX: + return fm_pk_struct.fm_index[index]; + case FM_WIN: + return fm_pk_struct.fm_win[index]; + case FM_LOSE: + return fm_pk_struct.fm_lose[index]; + case FM_SCORE: + return fm_pk_struct.fm_score[index]; + } + + return -1; +} + +char *getChar_fm_pk_struct( int index, int type ) +{ + switch( type ){ + case FM_NAME: + return fm_pk_struct.fm_name[index]; + } + + return NULL; +} + + +void read_fm_pk_score() +{ + FILE *f; + int i, j; + + if( !( f = fopen( "fm_pk_struct.txt", "r" ) ) ){ + log("\n opne fm_pk_struct.txt Err !!"); + return; + } + + for( i=0; i sort "); + + for( i=0; i msg(%s) ", msg ); + msg[ strlen(msg) -1 ] = 0; + log("\n won test 200 ==> msg(%s) ", msg ); + + // send to gmsv + { + extern gmsv gs[MAXCONNECTION]; + + for (i=0; i (%d) buf(%s)", i, buf[i] ); + strcat( out , "|" ); + strcat( out, buf[i] ); + i++; + } + + fclose( f ); + + { + extern gmsv gs[MAXCONNECTION]; + + log("\n won test 9 ==> out(%s)", out ); + + for (i=0; i name(%s) name2(%s) ", getChar_fm_pk_struct( no1, FM_NAME ), getChar_fm_pk_struct( no2, FM_NAME ) ); +} + + +int get_fm_pk_index( int win_index ) +{ + int i; + + log("\n won test 32 ==> win_index(%d) ", win_index ); + + for( i=0; i i(%d)", i ); + return i; + } + } + + for( i=0; i i(%d)", i ); + return i; + } + } + + return -1; +} + +#endif + + diff --git a/saac/acfamily.h b/saac/acfamily.h new file mode 100644 index 0000000..71b0c19 --- /dev/null +++ b/saac/acfamily.h @@ -0,0 +1,296 @@ +#ifndef _FAMILY_H_ +#define _FAMILY_H_ + +#include "version.h" + +#define MAX_FAMILY 1000 // 1000 +#define TEXT_MAX 1024 +#ifdef MEMBER_100 + #define MAX_MEMBERNUM 100 +#else + #define MAX_MEMBERNUM 50 // 50 +#endif +#define MIN_MEMBERNUM 10 // 10 + +#ifdef _FIX_9_FMPOINT // WON ADD 九大庄园 +#define MAX_FMPOINT 10 +#else +#define MAX_FMPOINT 4 // 4 +#endif + +#define PREDEL_TIME 60*60*24*7 // 七天 60*60*24*3 +#define PREDELMEMBER_TIME 60*60*24*30 // 30天 60*60*24*30 +#define FAMILY_MEMONUM 35 // 家族留言板最大留言数量 +#define FAMILY_MEMOLEN 256 +#define FMSMEMOINDEX 10000 // 家族之间留言板 index +#define FMSMEMONUM 140 +#define TOPFMLISTNUM 10 // 家族排行榜数量 +#define MINFMPOPNUM -20000000 +// shan 20011207 +#define MAXFMPOPNUM 100000000 +//#define MAXFMPOPNUM 5000000 +#define MINAPPLYPNUM 30 // 申请家族最低人数 +#define FMMEMBERINDEX "fmmember" +#define FMMEMOLIST "memo" +#define FMELDERNUM 4 // 长老数量 +#ifdef _EVERYONE_RIDE + #define FMMAXGOLD 100000000 // 家族基金上限 +#else + #define FMMAXGOLD 10000000 // 家族基金上限 +#endif +// shan 20011207 +#define MAXRECVPOP 50000000 // 家族声望转移上限 +// CoolFish: 2001/11/26 +//#define MAXRECVPOP 2500000 // 家族声望转移上限 + +typedef enum +{ + fmindex, + fmleadergrano, + fmnum, + fmjoinnum, + fmacceptflag, + fmsetupflag, + fmsprite, + fmpointindex, + fmpopular, + fmgold, + fmmemberindexmaxnum, + apply_time, + setup_time, + predel_time, + memonowwritenum, + memonum, + fmadv, + fmfeed, + fmsynthesize, + fmdealfood, + fmpk, +#ifdef _NEW_MANOR_LAW + fmmomentum, +#endif + familymaxint, +} FAMILY_DATAINT; + +typedef enum +{ + fmname, + fmleadername, + fmleaderid, + petname, + petattr, + fmrule, + familymaxchar, +} FAMILY_DATACHAR; + +typedef enum +{ + charlv, + charflag, + onlineflag, + charfdid, + predeltime, + popular, +#ifdef _FMVER21 + eventflag, +#endif +#ifdef _NEW_MANOR_LAW + momentum, +#endif + memberdatamaxint, +} MEMBER_DATAINT; + +typedef enum +{ + charname, + charid, + memberdatamaxchar, +} MEMBER_DATACHAR; + +typedef enum +{ + FMMEMBER_NONE = -1, + FMMEMBER_MEMBER = 1, + FMMEMBER_APPLY, + FMMEMBER_LEADER, + FMMEMBER_ELDER, + FMMEMBER_KINDNUM, +} MEMBER_KIND; + +// #define MEMBERMEM memberdatamaxint * sizeof(int) + 50 +// #define FAMILYMEM familymaxint * sizeof(int) + 1000 + MAX_MEMBERNUM * MEMBERMEM +#ifdef _ACFMPK_LIST +void FMPK_InitList( void); +#endif +void sortFamily(void); // Arminius: sort family +int getFMsortedlist(char *buf, int bufsize, int bp, int ep); + +int readFamily(char *dir); + +int readOneFamilyFromTi( int ti); +int readOneFamily( char *filename, int i); + +int writeFamily(char *dir); +int readFMPoint(char *dir); +int writeFMPoint(char *dir); +int readFMSMemo(char *dir); +int writeFMSMemo(char *dir); +void delovertimeFMMem(int time); +#ifdef _PERSONAL_FAME +int ACAddFM(int fd, int *workindex, char *fmname, char *fmleadername, + char *fmleaderid, int fmleaderlv, char *petname, char *petattr, + char *fmrule, int fmsprite, int fmleadergrano, int fame, int charfdid); +#else +int ACAddFM(int fd, int *workindex, char *fmname, char *fmleadername, + char *fmleaderid, int fmleaderlv, char *petname, char *petattr, + char *fmrule, int fmsprite, int fmleadergrano, int charfdid); +#endif +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 +int ACJoinFM(int fd, int index, char *fmname, int fmindex, + char *charname, char *charid, int charlv, int fame, int charfdid); +#else +int ACJoinFM(int fd, int index, char *fmname, int fmindex, + char *charname, char *charid, int charlv, int charfdid); +#endif +int ACLeaveFM(int index, char *fmname, int fmindex, + char *charname, char* charid); +int ACDelFM(int index, char *fmname, int fmindex); +int ACShowFMList(char *data); +int ACShowFMMemberList(int index, int *acceptflag, int *fmjoinnum, char *data); +int ACFMDetail(int index, char *fmname, int fmindex, char *data); +#ifdef _FMVER21 +int ACMemberJoinFM(int index, char *fmname, int fmindex, + char *charname, int charindex, int result, int meindex); +#else +int ACMemberJoinFM(int index, char *fmname, int fmindex, + char *charname, int charindex, int result); +#endif +#ifdef _FMVER21 +int ACMemberLeaveFM(int index, char *fmname, int fmindex, + char *charname, int flag, int charindex, int meindex); +#else +int ACMemberLeaveFM(int index, char *fmname, int fmindex, + char *charname, int flag, int charindex); +#endif +int ACFMAssignOcp(int index, char *fmname, int fmindex, + char *charname, int charindex, int result); + +#ifdef _FM_MODIFY +int ACFMCharLogin(int fd, int index, char *fmname, int fmindex, + char *charname, char *charid, int charlv, int *floor, int *fmpopular, + int *joinflag, int *fmsetupflag, int *charindex, int charfdid, + int *charfame, int eventflag,int gsnum + #ifdef _NEW_MANOR_LAW + ,int *momentum + #endif + ); +#else + #ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + int ACFMCharLogin(int fd, int index, char *fmname, int fmindex, + char *charname, char *charid, int charlv, int *floor, int *fmpopular, + int *joinflag, int *fmsetupflag, int *charindex, int charfdid, + int *charfame, int eventflag); + #else + int ACFMCharLogin(int fd, int index, char *fmname, int fmindex, + char *charname, char *charid, int charlv, int *floor, int *fmpopular, + int *joinflag, int *fmsetupflag, int *charindex, int charfdid); + #endif +#endif + +int ACFMCharLogout(int index, char *fmname, int fmindex, char *charname, + char *charid, int charlv, int charfdid); +int delfmpointindex(int fmindex); +int ACgetFMFloor(int fmindex); +int ACgetFMInfoFromChar(char *fmname, int *fmindex, + char *charname, char *charid, int *charindex); +int ACFMReadMemo(int index, int *dataindex, char *data); +int ACFMWriteMemo(int index, char *fmname, int fmindex, char *data); +int ACFMPointList(char *data); +int ACSetFMPoint(int index, char *fmanme, int fmindex, int fmpointindex, + int fl, int x, int y); +int ACFixFMPoint(int winindex, char *winfmname, int winfmindex, int loseindex, + char *losefmname, int losefmindex, int village); +int ACShowTopFMList(char *data, int datasize, int kindflag); +int ACFMAnnounce(char *fmname, int fmindex, int index, char *data, int color); +#ifdef _FAMILYBANKSTONELOG +int ACgetFMBankgold(int index, char *fmname,int fmindex,int charindex); +#endif +int ACFixFMData(int index, char *fmname, int fmindex, int kindflag, int charindex, + char *data1, char *data2); +int ACGetFMData(int index, char *fmname, int fmindex, int kindflag, int *data); +int ACFixFMPK(int winindex, char *winfmname, int winfmindex, int loseindex, + char *losefmname, int losefmindex); +int ACGMFixFMData(int index, char *fmname, char *charid, char *cmd, char *data); +int ChangeFMLeader(int index, char *fmname, int fmindex); +#ifdef _LEADERFUNCHECK +int CheckLeaderQ(int index, char *fmname, int fmindex, char *charname, char *charid); +#endif + + + + +#ifdef _ACFMPK_LIST +#define FMPKLIST_MAXNUM 10 +typedef struct tagFamilyPKSchedule { + int pkflg; + char Data[256]; +} FamilyPKSchedule; + +void FMPK_LoadList(); +void FMPK_BackUpList(); +int FMPK_GetTypeFlg( int ti); +char *FMPK_GetData( int ti); +int FMPK_SetData( int ti, int Pkflg, char *Data, int sizes); +#endif + + + +#ifdef _DEATH_FAMILY_GM_COMMAND // WON ADD 家族战GM指令 +void saacproto_ACRELOADFM_recv( int fd, int charindex ); +char *get_fm_leader_index( int fm_index ); +#endif + + + + +#ifdef _DEATH_FAMILY_STRUCT // WON ADD 家族战存放胜负资料 + +#define fm_pk_max 200 + +typedef struct _fm_pk_struct +{ + int fm_index[fm_pk_max]; + int fm_win[fm_pk_max]; + int fm_lose[fm_pk_max]; + int fm_score[fm_pk_max]; + char fm_name[fm_pk_max][30]; +}FM_PK_STRUCT; + + +enum{ + FM_INDEX =0, + FM_WIN, + FM_LOSE, + FM_SCORE, + FM_NAME, +}; + + +void setInt_fm_pk_struct( int index, int type, int num ); +void setChar_fm_pk_struct( int index, int type, char *msg ); +int getInt_fm_pk_struct( int index, int type ); +char *getChar_fm_pk_struct( int index, int type ); + + +void set_fm_pk_score( char *msg ); +void swap_fm_pk_struct( int no1, int no2 ); +int get_fm_pk_index( int win_index ); +void read_fm_pk_score(); +//void save_fm_pk_score(); + + +#endif + + +#endif + diff --git a/saac/auction.c b/saac/auction.c new file mode 100644 index 0000000..509c335 --- /dev/null +++ b/saac/auction.c @@ -0,0 +1,98 @@ +#define _AUCTION_C_ +#include "version.h" + +#ifdef _PAUCTION_MAN +#include "lock.h" +#include "util.h" +#include "main.h" +#include "saacproto_serv.h" +#include "char.h" +#include "auction.h" + +//#define PAUCTION_ADD 1 +//#define PAUCTION_DEL 2 +//#define MAXPAITEMS 20 +/*typedef struct _tagItemAuctionData +{ + char ItemName[256]; + char Data[1024]; + int ItemId; + int use; +}ItemAuctionData; +*/ +ItemAuctionData IAData[MAXPAITEMS]; + +void IAData_Init() +{ + int i; + for( i=0; i= MAXPAITEMS ) return FALSE; + //送回给GS + for(i=0;i= MAXCONNECTION ) return FALSE; + + for(i=0;i +#include +#include +#include +#include +#include + +#include "main.h" +#include "char.h" +#include "saacproto_serv.h" +#include "util.h" +#include "saacproto_lserver.h" + +// CoolFish: Family 2001/6/12 +#include "acfamily.h" +#include "version.h" + +// Arminius 7.17 memory lock +#include "lock.h" +#include "recv.h" + +#ifdef _SASQL1 +#include "sasql.h" +#endif + +static void getCharNameFromString(char*str ,char *out ); +static void getCharOptionFromString( char *str , char *out ); +static void getCharNameFromString(char*str ,char *out ); +static void makeCharFileName( char *idstring ,char *output, int outlen,int num); +// Nuke *1*1 +static int makeSaveCharString( char *out , int outlen , + char *nm , char *opt , char *info ); +static int findBlankCharIndex( char *id ); + +static int unlinkCharFile( char *id , int num ); +#ifdef _SLEEP_CHAR // 取得非活跃人物档名 +static void makeSleepCharFileName( char *id,char *output, int outlen, int num); +static void makeSleepCharPoolItemFileName( char *id,char *output, int outlen); +#endif +#ifdef _CHAR_POOLITEM +static void makeCharPoolItemFileName( char *id,char *output, int outlen); +#endif +#define SPACE '|' +#define SPACESTRING "|" + +#define IS_2BYTEWORD( _a_ ) ( (char)(0x80) <= (_a_) && (_a_) <= (char)(0xFF) ) + + +#define USERLOG( id , format, args...) \ +{\ + char body[1000];\ + char fn[1000];\ + if(id[0]){\ + snprintf( body ,sizeof(body), "%s.log.%d" , id ,get_rotate_count() );\ + makeDirFilename( fn , sizeof(fn),logdir, getHash(id), body);\ + LOGBASE( fn , "%u " , (unsigned int ) time(NULL) );\ + LOGBASE( fn , format , ## args );\ + }\ +} + +#ifdef _ANGEL_SUMMON +struct MissionTable missiontable[MAXMISSIONTABLE]; +#endif + +/* + + + 仇及白央奶伙匹烂聒今木化中月楮醒反兮氏少 据毛勾井丹[ + + + char *c0 : ID + char *c1 : Passwd 手丹 据允氏匹月井日银歹卅中 + char *c2 : Charname + char *c3 : opt + Spock fixed, opt change to process + char *c3 : process + char *c4 : 勾井歹氏 + int i0 : lock + int i1 : mesgid +*/ + +void charLoadCallback( int ti , int auth , char *c0, char* c1 , + char *c2 , char *c3, char *c4, int i0 , int i1 ) +{ + // Spock deleted 2000/11/2 + //static int process_id = 0; + // CoolFish: Init charindex 2001/10/16 +#ifdef _NewSave + int charindex = -1; +#else + int charindex; +#endif +#ifndef _LOCK_SERVER + char loadbuf[CHARDATASIZE]; + char infobuf[CHARDATASIZE]; + int lock = i0; +#endif + char *process = c3; + char *id = c0; + char *passwd = c1; + char *charname = c2; + int mesgid = i1; + + char *deadline = c4; + + // Spock deleted 2000/11/2 + //process_id++; + + if( auth != 0 ){ + char data[100]; + + snprintf( data, sizeof( data ), "%d" , auth ); +#ifdef _NewSave + saacproto_ACCharLoad_send( ti , FAILED , data, mesgid, charindex ); +#else + saacproto_ACCharLoad_send( ti , FAILED , data, mesgid ); +#endif + + +#ifdef _FIX_MESSAGE // WON ADD 修改WORKER封包内容 + // 同一星系重覆登入送 game end + if( auth == 204 ){ +#ifdef _WAEI_KICK + log("\n (%s) AP同一星系重覆登入,踢人!! ", id ); + saacproto_ACKick_recv( ti, id, 7, -1); //踢人 +#ifdef _UNLOCKPOOL + addUnlockPool( ti, id, "", process, ""); // AP解锁 +#else + addWorkerTask( id , "dummy" , "3" , dummyCallback , ti , + id , "dummy" , charname , process ,"", mesgid , 0 ); +#endif +#endif + }else + log("\n (%s) 登入异常!!:%d ", id, auth ); +#endif + + return; + } +#ifdef _DELAY_UNLOCK + if( UNlockM_isBe( id ) ){ + saacproto_ACCharLoad_send( ti , FAILED , "locked" , mesgid, charindex ); + return; + }else +#endif + if( isLocked( id ) ){ + //int process; +#ifdef _NewSave + saacproto_ACCharLoad_send( ti , FAILED , "locked" , mesgid, charindex ); +#else + saacproto_ACCharLoad_send( ti , FAILED , "locked" , mesgid ); +#endif + //DeleteMemLock(getHash(id) & 0xff, id, &process); // 如果AP无锁则AC解锁 + log("\n (%s) AC同一星系重覆登入,踢人!! ", id ); + saacproto_ACKick_recv( ti, id, 7, -1); //踢人 + + // checkGSUCheck( id); + return; + } + +#ifdef _LOCK_SERVER + if( CHECK_LS_BEUSE() == TRUE ) { + LServer_SACheckLock2_send( ti, id, mesgid, charname, 1, process);//process + return; + }else { + saacproto_ACCharLoad_send( ti , FAILED , "locked" , mesgid, charindex ); + } +#else + + charindex = getCharIndexByName( id , charname ); +#ifdef _NewSave + //log("\n档案装载序号:%d 账号:%s 名字:%s\n", charindex, id, charname); +#endif + +#ifdef _SQL_BACKGROUND + sasql_online(id,charname); +#endif + + if( charindex < 0 ){ + /* 平乓仿互绣箕仄卅中及匹巨仿□卅及分 */ +#ifdef _NewSave + saacproto_ACCharLoad_send( ti , FAILED , + "char nonexistent" , mesgid , charindex ); +#else + saacproto_ACCharLoad_send( ti , FAILED , + "char nonexistent" , mesgid ); +#endif + return; + } + + +// log( "loadCharOne: id:[%s] char:[%s]\n", id, charname ); + + if( loadCharOne( id , charindex , loadbuf ,sizeof( loadbuf ))<0){ +#ifdef _NewSave + saacproto_ACCharLoad_send( ti , FAILED , + "cannot load ( disk i/o error?)", mesgid, charindex ); +#else + saacproto_ACCharLoad_send( ti , FAILED , + "cannot load ( disk i/o error?)", mesgid ); +#endif + return; + }else{ +#ifdef _CHAR_POOLITEM + checkCharPoolItem( id); +#endif +#ifdef _CHAR_POOLITEM + checkCharPoolPet( id); +#endif + + } + {//ttom + char *c_ptr; + c_ptr=loadbuf; + while(*c_ptr!='\0'){ + if( IS_2BYTEWORD(*c_ptr) ){ + if(*(c_ptr+1)==' '){ + *(c_ptr+1)=0x41; + } + c_ptr++; + if(*c_ptr=='\0') break; + } + c_ptr++; + } + }//ttom + + if( lock ){ + char result[100]; + char retdata[100]; + +#ifdef _LOCK_ADD_NAME + if( lockUser( getGSName(ti) , id , charname, passwd , 1 , result , sizeof( result ) , + retdata , sizeof( retdata ) , process , deadline) <0 ){ +#else + // Spock 2000/11/2 + if( lockUser( getGSName(ti) , id , passwd , 1 , result , sizeof( result ) , + retdata , sizeof( retdata ) , process , deadline) <0 ){ +#endif + saacproto_ACCharLoad_send( ti , FAILED, "lock FAIL!!" , mesgid , charindex ); + return; + }else { +#ifdef _TIMEOUTKICK + // +#endif + } + } + memset( infobuf , 0 , sizeof( infobuf )); + getCharInfoFromString( loadbuf , infobuf ); + makeStringFromEscaped( infobuf ); + + +#ifdef _BAD_PLAYER // WON ADD 送坏玩家去关 + { + extern int MAX_BAD_PLAYER; + extern char BadPlayerList[500][20]; // 定义最大 500 名 + int i; + + for( i=0; i<=MAX_BAD_PLAYER; i++){ + if( strcmp( id, BadPlayerList[i] ) == 0){ + saacproto_ACCharLoad_send( ti , BADPLAYER , infobuf , mesgid, charindex ); +#ifdef _WAEI_KICK + saacproto_ACKick_recv( ti, id, 10, -1); +#endif + return; + } + } + } +#endif + +#ifdef _NewSave + saacproto_ACCharLoad_send( ti , SUCCESSFUL , infobuf , mesgid, charindex ); +#else + saacproto_ACCharLoad_send( ti , SUCCESSFUL , infobuf , mesgid); +#endif + +#ifdef _WAEI_KICK + saacproto_ACKick_recv( ti, id, 10, -1); //踢其他星系 +#endif + + +#endif +} + +#ifdef _NewSave +int charSave( int ti , char *id , + char *charname , char *opt , char *charinfo, + int unlock , int mesgid , int charindex) +#else + int charSave( int ti , char *id , + char *charname , char *opt , char *charinfo, + int unlock , int mesgid ) +#endif +{ +#ifdef _NewSave +#else + int charindex; +#endif + char savebuf[CHARDATASIZE]; + int ret = -1; + + + memset(savebuf, 0, sizeof(savebuf)); + + //andy_log + if( strstr( charinfo, "DATAEND=") == NULL ){ + FILE *fp; + if( (fp=fopen( "badpetstring.txt", "a+")) != NULL ){ + fprintf( fp, "%s\n", charinfo); + fclose( fp); + } + log( "err add batpetstring.txt:%s[%s] !\n", id, charname); + } + + if( unlock ){ + char result[100]; + char retdata[100]; +#ifdef _LOCK_ADD_NAME + if( (ret = lockUser( getGSName(ti), id , "" , "0" , 0 , result , sizeof( result ) , + retdata , sizeof( retdata ) , "0" , "0")) < 0 ){ +#else + if( (ret = lockUser( getGSName(ti), id , "0" , 0 , result , sizeof( result ) , + retdata , sizeof( retdata ) , "0" , "0")) < 0 ){ +#endif + log( "Unlock:%s FAILED err!!\n", id); + } +#ifdef _LOCK_SERVER + if( CHECK_LS_BEUSE() == TRUE ) { + LServer_SAUNLock_send( ti, id, mesgid, 1); + } +#endif + } + // Nuke *1 add escape + if( makeSaveCharString( savebuf , sizeof( savebuf ) , + charname, opt , charinfo )<0){ + log("\n ACCharSave:too long "); + saacproto_ACCharSave_send( ti , FAILED , "too long" , mesgid ); + // Spock fixed 2000/11/1 + return ret; + } +#ifdef _NewSave + if (charindex == -1) + charindex = getCharIndexByName( id , charname ); +#else + // Nuke *1- + charindex = getCharIndexByName( id , charname ); +#endif + if( charindex < 0 ){ + int blankind = findBlankCharIndex( id ); + if( blankind < 0 ){ + log("\n ACCharSave:char full "); + saacproto_ACCharSave_send( ti , FAILED , "char full" ,mesgid); + return ret; + } else { + charindex = blankind; + } + } + + log( "账号:[%s] 人物:[%s]\n", id, charname ); + if( saveCharOne( id , charindex , savebuf ) < 0 ){ + log("\n ACCharSave:disk I/O error or a bug "); + saacproto_ACCharSave_send( ti , FAILED , "disk I/O error or a bug", mesgid ); + return ret; + } + else + { +#ifdef _SASQL + sasql_save_nm( charindex, id, charname ); + sasql_save_opt( charindex, id, opt ); + sasql_save_int_info( charindex, id, charinfo ); + sasql_save_char_info( charindex, id, charinfo ); +#endif + } + + saacproto_ACCharSave_send( ti , SUCCESSFUL , "" , mesgid); + return ret; +} + +void charListCallback( int ti , int auth , char *c0 , char *c1 , + char *c2 , char *c3 , char *c4 , int i0 , int i1 ) +{ +#ifndef _LOCK_SERVER + char listbuf[CHARDATASIZE]; +#endif + char *id = c0; + int mesgid = i0; + + //log(" 档案列表回溯:%s:%d \n", id, auth); + + if( auth != 0 ){ + char data[100]; + snprintf( data, sizeof( data ) , "%d" , auth ); + saacproto_ACCharList_send( ti , FAILED , data , mesgid ); + total_ng_charlist++; + return; + } + +if (!sasql_query(c0,c1)){ +#ifdef _SQL_REGISTER + if(!sasql_register(c0,c1)) +#endif + { + log("密码错误或没有注册\n"); + saacproto_ACCharList_send( ti , FAILED , "Password error" , mesgid); + return;}} + + + // 取消下列 unlock 动作 +#ifndef _FIX_MESSAGE // WON ADD 修改WORKER封包内容 +#ifdef _DELAY_UNLOCK + if( UNlockM_isBe( id ) ){ + saacproto_ACCharList_send( ti , FAILED , "locked" , mesgid ); + return; + }else +#endif + if( isLocked( id ) ){ + saacproto_ACCharList_send( ti , FAILED , "locked" , mesgid ); + checkGSUCheck( id ); + total_ng_charlist++; + return; + } +#endif // end FIX_MESSAGE + +#ifdef _LOCK_SERVER + if( CHECK_LS_BEUSE() == TRUE ) { + LServer_SACheckLock1_send( ti, id, mesgid, 1); + }else { + saacproto_ACCharList_send( ti , FAILED , "locked" , mesgid ); + total_ng_charlist++; + } +#else + +#ifdef _SLEEP_CHAR // 如果无新档, 将旧档移至新档 + { + char fn_old[256], fn_new[256]; + FILE *fp_old, *fp_new; + int i; + + // 移人物档 + for( i=0; i= 0) + { + if (ACDelFM(index, fmname, fmindex) >= 0) + log("ACDelFM index:%d fmname:%s fmindex:%d charname:%s, charid:%s, charindex:%d\n", + index, fmname, fmindex, charname, id, fmcharindex); + } + log("ChangeFMLeader_3 index:%d fmname:%s fmindex:%d\n", index, fmname, fmindex); +#else + if (ACDelFM(index, fmname, fmindex) >= 0) + log("ACDelFM index:%d fmname:%s fmindex:%d charname:%s, charid:%s, charindex:%d\n", + index, fmname, fmindex, charname, id, fmcharindex); +#endif + } + else + { +#ifdef _FMVER21 + if (ACMemberLeaveFM(index, fmname, fmindex, charname, 0, 0, fmcharindex) >= 0) + log("ACMemberLeaveFM index:%d fmname:%s fmindex:%d charname:%s, charid:%s, charindex:%d\n", + index, fmname, fmindex, charname, id, fmcharindex); +#else + if (ACMemberLeaveFM(index, fmname, fmindex, charname, 0, fmcharindex) >= 0) + log("ACMemberLeaveFM index:%d fmname:%s fmindex:%d charname:%s, charid:%s, charindex:%d\n", + index, fmname, fmindex, charname, id, fmcharindex); +#endif + } + } + } +#endif + // Spock 2000/12/6 + time( &timenow ); + now = localtime( &timenow ); + sprintf( logfile , "log/chardel/%04d%02d%02d.log" , + now->tm_year + 1900 , now->tm_mon + 1 , now->tm_mday ); + LOGBASE( logfile , "%04d/%02d/%02d %02d:%02d:%02d id:[%s] char:[%s] index:[%d]\n" , + now->tm_year + 1900 , now->tm_mon + 1 , now->tm_mday , + now->tm_hour , now->tm_min , now->tm_sec , + id , charname , charindex ); + // Spock end + USERLOG( id , "chardelete: successful\n" ); + saacproto_ACCharDelete_send( ti , SUCCESSFUL , "ok" , mesgid); +} + +void dummyCallback( int ti , int auth , + char *c0 , char *c1 , char *c2 , char *c3 , + char *c4 , int i0 , int i1 ) +{ + return; +} + +static void getCharNameFromString(char*str ,char *out ) +{ + int c; + + out[0]='\0'; + for(c=0;;c++){ + if( IS_2BYTEWORD( str[c] ) ){ + out[c] = str[c]; + c ++ ; // 戚及 侬尺 + out[c] = str[c]; + continue; + } + + out[c] = str[c]; + if( str[c] == '\0' )break; + + if( str[c] == SPACE ){ + out[c] = '\0'; + break; + } + } +} + +static void getCharOptionFromString( char *str , char *out ) +{ + int c; + int outc = 0; + out[outc] = '\0'; + for(c=0;;c++){ + if( str[c]=='\0')break; + if( IS_2BYTEWORD( str[c] ) ){ + c++; + if( str[c] == '\0' )break; // 公及 侬互允匹卞NULL卅日蔽 + continue; + } + + if( str[c]== SPACE ){ + c++; + for(;;c++){ + + if( str[c] == '\0' ){ // 蔽 分匀凶日 NULL 木化蔽歹月 + out[outc] = '\0'; + break; + } + + // 仇仇手ㄡ田奶玄 侬及ㄠ田奶玄 卅日手丹域田奶玄戊疋□允月 + //---- For 2Byte Code ---- + if( IS_2BYTEWORD( str[c] ) ){ + out[outc++] = str[c++]; // ㄠ田奶玄 戊疋□ + out[outc++] = str[c]; // ㄡ田奶玄 戊疋□ + if( str[c] == '\0' )break; // 公及 侬互允匹卞NULL卅日蔽 + continue; + } + + // 骚橘 侬反ㄠ田奶玄戊疋□ + out[outc] = str[c]; // 引内戊疋□ + if( str[c] == '\0' )break; // 蔽 分匀凶日蔽歹月 + + if( str[c] == SPACE ){ + out[outc] = '\0'; + break; + } + outc++; + } + return; + } + } +} + +void getCharInfoFromString( char *str , char *out ) +{ + int c=0,outc=0; + int space_counter=0; + + out[outc] = '\0'; + for(c=0;;c++){ + if( str[c]=='\0')break; + if( IS_2BYTEWORD( str[c] ) ){ + c++; + continue; + }else + if( str[c]== SPACE ){ + space_counter++; + } + if( space_counter==2 && str[c]== SPACE ){ + c++; + for(;;c++){ + if( IS_2BYTEWORD( str[c] ) ){ + out[outc++] = str[c++]; + out[outc++] = str[c]; + if( str[c] == '\0' ){ + out[outc] = '\0'; + break; + } + continue; + } + + out[outc] = str[c]; + if( str[c] == '\0' )break; + if( str[c] == SPACE ){ + out[outc] = '\0'; + break; + } + outc++; + } + return; + } + } +} + +static void makeCharFileName( char *id,char *output, int outlen, int num) +{ + char body[1024]; + if ( strlen( id) < 1)return; + + snprintf(body , sizeof(body ) , "%s.%d.char" , id , num ); + makeDirFilename(output , outlen, chardir , getHash(id) ,body); +} + +#ifdef _SLEEP_CHAR // 取得非活跃人物档名 +static void makeSleepCharFileName( char *id,char *output, int outlen, int num) +{ + char body[1024]; + if ( strlen( id) < 1)return; + + snprintf(body , sizeof(body ) , "%s.%d.char" , id , num ); + makeDirFilename(output , outlen, sleepchardir , getHash(id) ,body); +} +#endif + +int loadCharNameAndOption( char *id , char *output , int outlen) +{ + char chbuf[MAXCHAR_PER_USER][CHARDATASIZE]; + char namework[CHARDATASIZE]; + char optionwork[CHARDATASIZE]; + char nm_work[CHARDATASIZE]; + + int i,count=0; + int so_far_bytes = 0; + output[0] = 0; + + for(i=0;i 0 ){ + delim[0] = SPACE; + delim[1] = 0; + } else { + delim[0] = 0; + } + + snprintf( nm_work , sizeof( nm_work ), + "%s%s|%s" , delim,namework , optionwork ); + l = strlen( nm_work ); + + if( ( so_far_bytes + l ) < outlen ){ + strcat( output , nm_work ); + so_far_bytes += l; + count++; + } + } + + return count; +} +#ifdef _CHECK_BADFILES +int backupBadcharfile( char *filename, char *cdkey, int num) +{ + char file1[256],file2[256]; + char userpath[256]; + FILE *fp; + + log("backupBadcharfile( %s) -%s.%d-%s\n", filename, cdkey, num, userpath); + sprintf( userpath , "%s.%d.char" , cdkey , num ); + sprintf( file1, "char/0x%x/%s", getHash(cdkey) & 0xff, userpath); + sprintf( file2, "badchar/%s", userpath); + { + char buf[1024]; + int f; + bzero(buf,sizeof(buf)); + f=open( file1, O_RDONLY); + if ( f <= 0 ){ + log( "Can't open %s..\n", file1); + return 1; + } + lseek( f, -4, SEEK_END); + read(f,buf,4); + close(f); + if ((buf[2]=='\\')&&(buf[3]=='n')&& + (buf[0]=='\\')&&(buf[1]=='z')){ + return 1; + } + } + if (mkdir("badchar", 0755) == 0) + log("create %s\n", "badchar"); + sprintf( file2, "./badchar/%s", filename); + fp = fopen( file2, "a+"); + if( fp == NULL ){ + + log("create file:%s error !!\n", file1); + return -1; + } + fprintf( fp, "%s %s\n", cdkey, file1); + fclose( fp); + + log("backup badcharfile:%s..\n", userpath); + return -1; +} +#endif + +int loadCharOne( char *id , int num, char *output , int outlen ) +{ + char fn[1024]; + FILE *fp; + char c_temp,*c_ptr; + c_ptr=output; + + makeCharFileName( id , fn , sizeof(fn),num ); + fp = fopen( fn , "r" ); + if( fp == NULL ){ + return -1; + } + + do{ + c_temp = fgetc(fp); + *c_ptr=c_temp; + c_ptr++; + }while(c_temp != EOF); + *c_ptr='\0'; + + if( output[0]=='|' && output[1]=='|' ){ + return -1; + } + fclose(fp); +#ifdef _CHECK_BADFILES + if( backupBadcharfile( "badfilelist.txt", id, num) < 0 ){ + return -1; + } +#endif + return 0; +} + +int saveCharOne( char *id , int num , char *input ) +{ + char fn[1024]; + FILE *fp; + char *strp; + char *strp1; // Won 修正 hp 为负的人 + + makeCharFileName( id , fn , sizeof(fn),num ); + fp= fopen( fn , "w" ); + if( fp == NULL ) { + log( "save error 01: %d",errno );//Change add errno + return -1; + } + + // Won 修正 hp 为负的人 + if ((strp=strstr(input,"\\nhp=-"))!=NULL) { + strp1=strstr(input,"\\nmp="); + *(strp+5)='1'; + strcpy((strp+6), strp1); + } + + // Arminius + if ((strp=strstr(input,"\\nhp=0\\n"))!=NULL) *(strp+5)='1'; + + fprintf( fp , "%s" , input ); + fclose(fp); + +#if 0 //_SLEEP_CHAR // 旧档也存 + { + char fn1[1024], fn2[1024]; + makeSleepCharFileName( id , fn1 , sizeof(fn1),num ); + fp = fopen( fn1 , "w" ); + if( fp != NULL ) { + fprintf( fp , "%s" , input ); + fclose(fp); + } + + // 复制新仓库档到旧档 + makeCharPoolItemFileName( id, fn1, sizeof(fn)); + makeSleepCharPoolItemFileName( id, fn2, sizeof(fn)); + filecopy( fn1, fn2); + } +#endif +#ifdef _SQL_BACKGROUND + sasql_update(id,fn); + sasql_online(id,NULL); +#endif + log( "写入 %s 档案文件:%s\n",id , fn ); + return 0; + +} + +static int makeSaveCharString( char *out , int outlen , + char *nm , char *opt , char *info ) +{ + char nmwork[CHARDATASIZE]; + char optwork[CHARDATASIZE]; + char infowork[CHARDATASIZE]; + char outwork[CHARDATASIZE]; + char *nmwork_p , *optwork_p , *infowork_p; + int l; + + /* 戊疋□仄化 */ + + strncpy( nmwork , nm , sizeof( nmwork )); + nmwork[strlen( nm)]=0; + + strncpy( optwork , opt , sizeof( optwork )); + optwork[strlen(opt)]=0; + + strncpy( infowork , info , sizeof( infowork )); + infowork[strlen(info)]=0; + + /* 巨旦弗□皿仄 */ + /* if ( esc ) { + nmwork_p = makeEscapeString1( nm , nmwork ,sizeof( nmwork )); + optwork_p = makeEscapeString1( opt , optwork , sizeof( optwork )); + infowork_p = makeEscapeString1( info , infowork , sizeof( infowork )); +} else {*/ + + nmwork_p = makeEscapeString( nm , nmwork ,sizeof( nmwork )); + optwork_p = makeEscapeString( opt , optwork , sizeof( optwork )); + infowork_p = makeEscapeString( info , infowork , sizeof( infowork )); + +#ifdef _SASQL + { + FILE *f; + f=fopen("nmkill.txt","w"); + if( f ) + { + fprintf(f,"%s",nmwork_p); + fclose( f ); + } + f=fopen("optkill.txt","w"); + if( f ) + { + fprintf(f,"%s",optwork_p); + fclose( f ); + } + f=fopen("infokill.txt","w"); + if( f ) + { + fprintf(f,"%s",infowork_p); + fclose( f ); + } + } +#endif + // } + /* 勾卅仆月[赞中互巨仿□腹请及凶户卞域荚伐□弁卞中木月[ */ + snprintf( outwork ,sizeof( outwork ) , + "%s" SPACESTRING "%s" SPACESTRING "%s" , + nmwork_p , optwork_p , infowork_p ); + + l = strlen( outwork ); + if( l >= (outlen-1)){ + return -1; + } + + /* NULL 侬互 卞丐月井日0毛中木氏午中井氏及分[ */ + memcpy( out , outwork , l + 1); + + return 0; +} + +int getCharIndexByName( char *id , char *charname ) +{ + int i; + for(i=0;i= (outlen-1) ) break; + }while(c_temp != EOF); + *c_ptr='\0'; + fclose(fp); + return sizes; +} + +int checkCharPoolItem( char *id) +{ + char fn[256]; + FILE *fp; + + makeCharPoolItemFileName( id , fn , sizeof(fn)); + fp = fopen( fn , "r" ); + if( fp == NULL ) { + if( saveCharPoolItem( id , "", 0) < 0 ){ + log("\n Can't Create char:%s poolitem File!!", id); + return -1; + } + }else{ + fclose(fp); + } + + return 1; +} +#endif + + +#ifdef _CHAR_POOLPET +static void makeCharPoolPetFileName( char *id,char *output, int outlen) +{ + char poolpet[256]; + if ( strlen( id) < 1)return; + snprintf( poolpet , sizeof( poolpet ) , "%s.pet" , id); + makeDirFilename(output , outlen, chardir , getHash(id) ,poolpet); +} + +#ifdef _SLEEP_CHAR // 取得非活跃人物仓库档名 +static void makeSleepCharPoolPetFileName( char *id,char *output, int outlen) +{ + char poolpet[256]; + if ( strlen( id) < 1)return; + snprintf( poolpet , sizeof( poolpet ) , "%s.pet" , id); + makeDirFilename(output , outlen, sleepchardir , getHash(id) ,poolpet); +} +#endif + +int InsertCharPoolPet( char *id , char *input, int sizes) +{ + char fn[256]; + FILE *fp; + + if( sizes <= 0 ) return sizes; + makeCharPoolPetFileName( id , fn , sizeof(fn)); + + fp= fopen( fn , "a+" ); + if( fp == NULL ) { + fp= fopen( fn , "w" ); + if( fp == NULL ) { + log( "save %s error.\n", fn); + return -1; + } + } + + fprintf( fp , "%s" , input ); + fclose(fp); + + log( "add %s charpoolpet file:%s\n", id , fn ); + return sizes; +} + +int saveCharPoolPet( char *id , char *input, int sizes) +{ + char fn[256]; + FILE *fp; + + if( sizes < 0 ) return sizes; + if( input == NULL ) return -1; + makeCharPoolPetFileName( id , fn , sizeof(fn)); + + fp= fopen( fn , "w" ); + if( fp == NULL ) { + log( "save %s error.\n", fn); + return -1; + } + + fprintf( fp , "%s" , input ); + fclose(fp); + + log( "写入 %s 宠物档案文件:%s\n", id , fn ); + return sizes; +} + +int loadCharPoolPetOne( char *id , char *output , int outlen) +{ + char fn[256]; + FILE *fp; + + char c_temp,*c_ptr; + int sizes=0; + c_ptr=output; + + makeCharPoolPetFileName( id , fn , sizeof(fn)); + + fp = fopen( fn , "r" ); + if( fp == NULL ){ + if( (fp = fopen( fn , "w" )) == NULL) + return -1; + return 0; + } + + do{ + c_temp = fgetc(fp); + *c_ptr=c_temp; + c_ptr++; + sizes++; + if( sizes >= (outlen-1) ) break; + }while(c_temp != EOF); + *c_ptr='\0'; + fclose(fp); + return sizes; +} + +int checkCharPoolPet( char *id) +{ + char fn[256]; + FILE *fp; + + makeCharPoolPetFileName( id , fn , sizeof(fn)); + fp = fopen( fn , "r" ); + if( fp == NULL ) { + if( saveCharPoolPet( id , "", 0) < 0 ){ + log("\n Can't Create char:%s poolpet File!!", id); + return -1; + } + }else{ + fclose(fp); + } + + return 1; +} +#endif + + + + +int filecopy( char *oldfilename, char *newfilename) +{ + FILE *oldfile; + FILE *newfile; + char c_temp; + + if( (oldfile = fopen( oldfilename, "r") ) == NULL ) { + return -1; + } + if( (newfile = fopen( newfilename, "w") ) == NULL ) { + return -1; + } + + while(1) { + c_temp = fgetc( oldfile); + if( c_temp == EOF) + break; + fputc( c_temp, newfile); + }; + + fclose( oldfile); + fclose( newfile); + + return 0; +} diff --git a/saac/char.h b/saac/char.h new file mode 100644 index 0000000..aa56a1a --- /dev/null +++ b/saac/char.h @@ -0,0 +1,106 @@ +#ifndef _CHAR_H_ +#define _CHAR_H_ +#include "version.h" + +/* 1交□扒丐凶曰及 平乓仿醒(白央奶伙醒) */ +#define MAXCHAR_PER_USER 2 + +int isLocked( char *id ); +void charLoadCallback( int ti , int auth_ok , char *c0, char* c1 , + char *c2 , char *c3, char *c4, int i0 , int i1 ); + + +// Spock 2000/11/1 +//void charSave( int ti , char *c0 , +// char *c2 , char *c3 , char *c4, int i0 , int i1 ); +// return process number +#ifdef _NewSave +int charSave( int ti , char *c0 , + char *c2 , char *c3 , char *c4, int i0 , int i1 , int charindex ); +#else +int charSave( int ti , char *c0 , + char *c2 , char *c3 , char *c4, int i0 , int i1 ); +#endif +// Spock end + +void charListCallback( int ti , int auth_ok , char *c0 , char *c1 , + char *c2 , char *c3 , char *c4 , int i0 , int i1 ); + +void charDeleteCallback( int ti , int auth_ok , + char *c0 , char *c1 , char *c2 , char *c3 , + char *c4 , int i0 , int i1 ); +// Nuke +void dummyCallback( int ti , int auth_ok , + char *c0 , char *c1 , char *c2 , char *c3 , + char *c4 , int i0 , int i1 ); + + +// Spock 2000/11/1 +#ifdef _LOCK_ADD_NAME +int lockUser( char *gmsvname , char *id , char *name, char *passwd , int lock , + char *result, int resultlen, + char *retdata , int retdatalen , char *process , char *deadline); +#else +int lockUser( char *gmsvname , char *id , char *passwd , int lock , + char *result, int resultlen, + char *retdata , int retdatalen , char *process , char *deadline); +#endif +// Spock end + +int checkValidCharName( char *a); + +int loadCharOne( char *idstring , int num, char *output , int outlen ); +int saveCharOne( char *idstring , int num , char *input ); + +int loadCharNameAndOption( char *id , char *output , int outlen); +int getCharIndexByName( char *id , char *charname ); +void getCharInfoFromString( char *str , char *out ); + +#ifdef _CHAR_POOLITEM +int InsertCharPoolItem( char *id , char *input, int sizes); +int saveCharPoolItem( char *id , char *input, int sizes); +int loadCharPoolItemOne( char *id , char *output , int outlen); +int checkCharPoolItem( char *id); +#endif + +#ifdef _CHAR_POOLPET +int InsertCharPoolPet( char *id , char *input, int sizes); +int saveCharPoolPet( char *id , char *input, int sizes); +int loadCharPoolPetOne( char *id , char *output , int outlen); +int checkCharPoolPet( char *id); +#endif + + +#ifdef _ANGEL_SUMMON + +#define MAXMISSIONTABLE 1000 + +struct MissionTable +{ + char angelinfo[128]; + char heroinfo[128]; + int mission; + int flag; + int time; + int limittime; +}; + +extern struct MissionTable missiontable[MAXMISSIONTABLE]; + +#endif + + +#ifdef _RACEMAN +#define DEFMAXRANK 100 +struct RankTable +{ + int rank; + char id[20]; + char name[64]; + int catchcnt; +}; +extern struct RankTable ranktable[DEFMAXRANK]; +#endif + +#endif + diff --git a/saac/chatroom.c b/saac/chatroom.c new file mode 100644 index 0000000..ebdd87b --- /dev/null +++ b/saac/chatroom.c @@ -0,0 +1,505 @@ +#include "version.h" +#include "main.h" +#include "util.h" + +#include "saacproto_serv.h" +#include "saacproto_util.h" + +#ifdef _UNIVERSE_CHATROOM +#include "chatroom.h" + +UniChatRoomlist UniChatRoom[MAX_CHATROOM]; + +void CHATROOM_resetChat( int chat) +{ + int i; + if( chat<0 || chat>=MAX_CHATROOM ) return; + UniChatRoom[chat].use=0; + UniChatRoom[chat].masindex=-1; + UniChatRoom[chat].charanum=0; + for( i=0; i=MAX_CHATROOM ) return; + + easyGetTokenFromBuf( data, '|', 3, buf1, sizeof(buf1) ); + sprintf( cdkey, "%s", buf1); + easyGetTokenFromBuf( data, '|', 4, buf1, sizeof(buf1) ); + sprintf( name, "%s", buf1); + + uti = UniChatRoom[chat].masindex; + if( uti<0 || uti >= MAX_PPLINROOM ) return; + if( UniChatRoom[chat].charalist[uti].use == 0 ) return; + if( !strcmp( UniChatRoom[chat].charalist[uti].cdkey, cdkey) && + !strcmp( UniChatRoom[chat].charalist[uti].name, name) ){ + int i; + char token[256]; + CHATROOM_resetChat( chat); + sprintf( token, "D|%d|", chat); + for( i=0; i=MAX_CHATROOM ) return; + + easyGetTokenFromBuf( data, '|', 3, buf1, sizeof(buf1) ); + uti = atoi( buf1); + if( uti<0 || uti >= MAX_PPLINROOM ) return; + if( UniChatRoom[chat].charalist[uti].use == 0 ) return; + + sprintf( token, "L|%d|%d|%s|", chat, uti, UniChatRoom[chat].charalist[uti].name ); + for( i=0; i=MAX_PPLINROOM ){ + CHATROOM_resetChat( chat); + sprintf( token, "D|%d|", chat); + for( i=0; i=MAX_CHATROOM ) return; + + easyGetTokenFromBuf( data, '|', 3, buf1, sizeof(buf1) ); + sprintf( cdkey, "%s", buf1); + easyGetTokenFromBuf( data, '|', 4, buf1, sizeof(buf1) ); + sprintf( name, "%s", buf1); + easyGetTokenFromBuf( data, '|', 5, buf1, sizeof(buf1) ); + whoti = atoi( buf1); + + uti = UniChatRoom[chat].masindex; + if( uti<0 || uti >= MAX_PPLINROOM ) return; + if( UniChatRoom[chat].charalist[uti].use == 0 ) return; + if( whoti<0 || whoti >= MAX_PPLINROOM ) return; + if( UniChatRoom[chat].charalist[whoti].use == 0 ) return; + + if( !strcmp( UniChatRoom[chat].charalist[uti].cdkey, cdkey) && + !strcmp( UniChatRoom[chat].charalist[uti].name, name) ){ + int i; + char token[256]; + + sprintf( token, "K|%d|%d|", chat, whoti); + + for( i=0; i=MAX_CHATROOM ) return; + + uti = UniChatRoom[chat].masindex; + if( uti<0 || uti >= MAX_PPLINROOM ) return; + if( UniChatRoom[chat].charalist[uti].use == 0 ) return; + if( !gs[ UniChatRoom[chat].masfd].use ) return; + saacproto_ACUniChatroom_send( UniChatRoom[chat].masfd, "", SUCCESSFUL, data, -1, -1); + UniChatRoom[chat].charanum++; + +} + +void CHATROOM_AgreeJoinCR( int fd, char *data, int userindex, int clifd) +{ + int chat=-1, ti, i; + char buf1[256], cdkey[256], name[256], own[256]; + char token[256]; +extern gmsv gs[MAXCONNECTION]; + + easyGetTokenFromBuf( data, '|', 2, buf1, sizeof(buf1) ); + chat = atoi( buf1); + if( chat<0 || chat>=MAX_CHATROOM ) return; + easyGetTokenFromBuf( data, '|', 3, buf1, sizeof(buf1) ); + sprintf( cdkey, "%s", buf1); + easyGetTokenFromBuf( data, '|', 4, buf1, sizeof(buf1) ); + sprintf( name, "%s", buf1); + easyGetTokenFromBuf( data, '|', 5, buf1, sizeof(buf1) ); + sprintf( own, "%s", buf1); + + if( (ti=CHATROOM_AgreeSomeOne( chat, cdkey, name, own, fd)) < 0 ){ + sprintf( token, "A|%d|FULL|", chat); + saacproto_ACUniChatroom_send( fd, "", SUCCESSFUL, token, userindex, clifd); + }else{ + sprintf( token, "A|%d|OK|", chat); + saacproto_ACUniChatroom_send( fd, "", SUCCESSFUL, token, userindex, clifd); + UniChatRoom[chat].charanum++; + } + CHATROOM_UpdateChatRoom( -1, chat); + + +} + +void CHATROOM_GSClosedHandle( int fd) +{ + int i, j, mindex; +extern gmsv gs[MAXCONNECTION]; + //andy_log + log( "\nCHATROOM_GSClosedHandle( %d)\n", fd); + + for( j=0; j= MAX_PPLINROOM || + UniChatRoom[j].charalist[mindex].use == 0 ){ + char token[512]; + + CHATROOM_resetChat( j); + sprintf( token, "D|%d|", j); + for( i=0; i=MAX_CHATROOM ) return -1; + if( UniChatRoom[chat].use == 0 ) return -1; + for( i=0; i=MAX_CHATROOM ) return; + + easyGetTokenFromBuf( data, '|', 3, buf1, sizeof(buf1) ); + sprintf( cdkey, "%s", buf1); + easyGetTokenFromBuf( data, '|', 4, buf1, sizeof(buf1) ); + sprintf( name, "%s", buf1); + + uti = UniChatRoom[chat].masindex; + if( uti<0 || uti >= MAX_PPLINROOM ) return; + if( UniChatRoom[chat].charalist[uti].use == 0 ) return; + + if( !strcmp( UniChatRoom[chat].charalist[uti].cdkey, cdkey) && + !strcmp( UniChatRoom[chat].charalist[uti].name, name) ){ + char token[256]; + + easyGetTokenFromBuf( data, '|', 5, buf1, sizeof(buf1) ); + sprintf( result, "%s", buf1); + + easyGetTokenFromBuf( data, '|', 6, buf1, sizeof(buf1) ); + sprintf( cdkey, "%s", buf1); + easyGetTokenFromBuf( data, '|', 7, buf1, sizeof(buf1) ); + sprintf( name, "%s", buf1); + easyGetTokenFromBuf( data, '|', 8, buf1, sizeof(buf1) ); + sprintf( own, "%s", buf1); + easyGetTokenFromBuf( data, '|', 9, buf1, sizeof(buf1) ); + whofd = atoi( buf1); + if( !gs[ whofd].use ) return; + + sprintf( token, "A|%d|%s|%s|%s|%s|", chat, result, cdkey, name, own ); + if( !strcmp( result, "OK") ){ +// UniChatRoom[chat].charanum++; + if( CHATROOM_AgreeSomeOne( chat, cdkey, name, own, whofd) < 0 ){ + sprintf( token, "A|%d|FULL|%s|%s|%s|", chat, cdkey, name, own ); + } + }else{ + UniChatRoom[chat].charanum--; + } + saacproto_ACUniChatroom_send( whofd, "", SUCCESSFUL, token, -1, -1); + } +} + +void CHATROOM_MasterChatRoom( char *Cdkey, char *data ) +{ + int chat=-1, uti; + char buf1[256]; + char cdkey[256],name[256]; + +extern gmsv gs[MAXCONNECTION]; + + easyGetTokenFromBuf( data, '|', 2, buf1, sizeof(buf1) ); + chat = atoi( buf1); + if( chat<0 || chat>=MAX_CHATROOM ) return; + if( UniChatRoom[chat].use == 0 ) return; + easyGetTokenFromBuf( data, '|', 3, buf1, sizeof(buf1) ); + sprintf( cdkey, "%s", buf1); + easyGetTokenFromBuf( data, '|', 4, buf1, sizeof(buf1) ); + sprintf( name, "%s", buf1); + + uti = UniChatRoom[chat].masindex; + if( uti<0 || uti >= MAX_PPLINROOM ) return; + if( UniChatRoom[chat].charalist[uti].use == 0 ) return; + + if( !strcmp( UniChatRoom[chat].charalist[uti].cdkey, cdkey) && + !strcmp( UniChatRoom[chat].charalist[uti].name, name) ){ + int i,ti; + char token[256]; + + easyGetTokenFromBuf( data, '|', 5, buf1, sizeof(buf1) ); + ti = atoi( buf1); + if( UniChatRoom[chat].charalist[ti].use == 0 ) return; + UniChatRoom[chat].masindex = ti; + UniChatRoom[chat].masfd = UniChatRoom[chat].charalist[ti].fd; + sprintf( token, "M|%d|%d|", chat, ti ); + + for( i=0; i=MAX_CHATROOM ) return; + + for( i=0; i=MAX_CHATROOM ) return 0; +// if( UniChatRoom[chat].use == 0 ) return 0; + + sprintf( token, "U|%d|%d|%s|%d|%d|", + chat, + UniChatRoom[chat].use, + UniChatRoom[chat].chatname, + UniChatRoom[chat].masindex, + UniChatRoom[chat].charanum + ); + + + for( i=0; i= 0 ){ + }else{ + saacproto_ACUniChatroom_send( fd, cdkey, FAILED, data, userindex, clifdid ); + } + }else if( !strcmp( comm, "D") ) {//删除频道 + CHATROOM_DelChatRoom( cdkey, data); + }else if( !strcmp( comm, "L") ) {//离开频道 + CHATROOM_LeaveChatRoom( cdkey, data); + }else if( !strcmp( comm, "T") ) {//频道讯息 + CHATROOM_MessageChatRoom( cdkey, data); + }else if( !strcmp( comm, "K") ) {//踢出频道 + CHATROOM_KickChatRoom( cdkey, data); + }else if( !strcmp( comm, "J") ) {//申请加入频道 + CHATROOM_AgreeJoinCR( fd, data, userindex, clifdid); + //CHATROOM_JoinChatRoom( cdkey, data); + }else if( !strcmp( comm, "A") ) {//同意加入 + CHATROOM_AgreeChatRoom( cdkey, data); + }else if ( strcmp ( comm , "M" ) == 0 ) { // 更换室长 + CHATROOM_MasterChatRoom( cdkey, data); + }else if( !strcmp( comm, "U") ) {//更新频道 + easyGetTokenFromBuf( data, '|', 2, buf1, sizeof(buf1) ); + if( atoi( buf1) == -1 ){ + for( i=0; i +#include +#include +#include +#include +#include +#include + +/* 侬 巨件玄伉及 length */ +//#define CHARVALUE_MAX 1024 +#define MAXTABLE 16 +// Spock 2000/10/12 +#define CHARVALUE_MAX 256 // DB 字串资料的buffer大小 +#define KEY_MAX 64 // DB Key字串的buffer大小 +#define HASH_SIZE 65536 // Hash table 一次增加的Entry数量 +#define HASH_PRIME 65521 // Hash function 使用的质数 +#define DBINIT_SIZE 16384 // DB 每次配置Entry的数量 +// Spock end + +/* 犯□正矛□旦及伉件弁及邰豳1蜊毛丐日歹允[ */ +struct dbentry +{ + int use; +// unsigned int keyhash; /* 腹绸平□及甩永扑亘戊□玉 */ + int ivalue; /* 旦戊失[玄永皿 NODE 反 -1 匹} + 允屯化及旦戊失反 0 动晓匹卅中午中仃卅中*/ +// int nextind; /* -1 分匀凶日 毛啦 允月 */ + // Spock 2000/10/12 + int prev; // 前一个dbentry, -1表示此项为head + int next; // 下一个dbentry, -1表示此项为tail + char key[KEY_MAX]; + char charvalue[CHARVALUE_MAX]; +// char key[64]; /* 腹绸平□午卅月 侬 */ +// int charvalue_index; /* 侬 田永白央毛今允index */ + // Spock end +}; + +// Spock 2000/10/12 +// Database hashtable +struct hashentry +{ + char key[KEY_MAX]; // 索引key值 + int use; // 是否已被使用 + int dbind; // 指向 dbentry 的 index + int prev; // 同一key值的上一个 hashentry, -1为head + int next; // 同一key值的下一个 hashentry, -1为tail +}; +// Spock end + +typedef enum +{ + DB_INT_SORTED, + DB_STRING, +}DBTYPE; + +/* 1蜊及犯□正矛□旦毛丐日歹允 */ +struct table +{ + int use; // 0:未使用 1:已使用 + DBTYPE type; /* DB及潘 */ + char name[32]; /* 犯□正矛□旦及 蟆 */ + int num; /* 巨件玄伉及醒 */ + int toplinkindex; + // Spock 2000/10/12 + struct hashentry *hashtable; + int hashsize; + int updated; // 0:dbflush後未更新 1:已更新 + int ent_finder; // 指向最後一次配置的 hashentry + // Spock end +}; + +struct dbentry *master_buf; /* 巨件玄伉筏盛迕 */ +int dbsize = 0; /* 赓0匹}1,2,4,8,16...*/ +static int dbent_finder = 0; + +struct table dbt[MAXTABLE]; + +static void dbShowAllTable(void); + +// Spock 2000/10/12 +int dbHash(char* s) +{ + char *p; + unsigned int h= 0 ,g; + for( p = s ; *p ; p ++ ){ + h = ( h<< 4 ) + (*p); + if( (g = h & 0xf0000000) != 0){ + h = h ^ (g>>24); + h = h ^ g; + } + } + return h % HASH_PRIME; +} +// Spock end + +/* Spock deleted 2000/10/12 +struct charvalue +{ + int use; + char buf[CHARVALUE_MAX]; +}; +struct charvalue *charvalue_buf; +int charvaluesize=0; +*/ + +/* + 侬 田永白央□毛傀舰允月 + */ +/* Spock deleted 2000/10/12 +int +reallocCharValue(void) +{ + struct charvalue *previous = charvalue_buf; + struct charvalue *newbuf; + int new_charvaluesize; + if( charvaluesize == 0 ){ + new_charvaluesize = 1; + } else { + new_charvaluesize = charvaluesize * 2; + } + + newbuf = ( struct charvalue *) calloc( 1, new_charvaluesize * + sizeof( struct charvalue )); + if( newbuf == NULL ){ + log( "reallocCharValue: memory shortage!! new_charvaluesize:%d\n", + new_charvaluesize ); + return -1; + } + memset( newbuf, 0 , new_charvaluesize * sizeof( struct charvalue )); + if( previous) memcpy( (char*)newbuf, (char*)previous, + charvaluesize * sizeof( struct charvalue )); + free( previous ); + charvaluesize = new_charvaluesize; + charvalue_buf = newbuf; + + log( "reallocCharValue: " + "new_charvaluesize:%d Old address:%x New address:%x\n", + new_charvaluesize , (unsigned int )previous, + (unsigned int)newbuf ); + return 0; +} +*/ + +/* + 侬 田永白央□毛1蜊歹曰丐化月[ + 凶曰卅仁卅匀凶日realloc允月[ + +*/ +/* Spock deleted 2000/10/12 +static int charvalue_finder=0; +static int +dbAllocCharValue( void ) +{ + int i; + for(i=0;i= (sizeof( charvalue_buf[0].buf )-1)) return -1; + memcpy( charvalue_buf[index].buf , data, l+1 ); + return 0; +} +*/ + +/* + DB及云云五今互凶日氏仁卅匀凶日歹曰丐化卅云允[中引及扔奶术及2 卞允月 + 0分匀凶日1卞允月 + */ +static int +reallocDB( void ) +{ + struct dbentry *previous = master_buf; + struct dbentry *newbuf; + int new_dbsize; +/* Spock deleted 2000/10/12 + if( dbsize == 0 ){ + new_dbsize = 1; + } else { + new_dbsize = dbsize * 2; + } +*/ + // Spock+1 2000/10/12 + new_dbsize = dbsize + DBINIT_SIZE; + + newbuf = (struct dbentry* ) calloc( 1, new_dbsize * + sizeof( struct dbentry) ); + /* 丢乒伉凶曰卅中 */ + if( newbuf == NULL ){ + log( "重新分配数据: 内存不足!!! 新数据大小: %d\n", new_dbsize ); + return -1; + } + + /* 衙中幻丹井日蕙仄中 卞戊疋□仄化 */ + + memset( newbuf , 0 , new_dbsize * sizeof( struct dbentry ) ); + /* Spock deleted 2000/10/19 + if( previous )memcpy( (char*)newbuf, (char*)previous, + dbsize * sizeof( struct dbentry )); + + // 衙中幻丹毛荸 仄 + free( previous ); + */ + // Spock 2000/10/19 + if ( dbsize > 0 ) + { + memcpy( newbuf , previous , dbsize * sizeof(struct dbentry)); + free( previous ); + } + // Spock end + + dbent_finder = dbsize; // 将 dbent_finder 指向未使用的 entry + dbsize = new_dbsize; + master_buf = newbuf; + + log( "重新分配数据: 新数据大小:%d 旧地址: %x 新地址:%x\n", + new_dbsize , (unsigned int)previous, (unsigned int)newbuf ); + + return 0; +} + + + +/* + allocate a node + */ +static int +//dbAllocNode( DBTYPE type ) +// Spock +1 2000/10/13 +dbAllocNode() +{ + int i; + for(i=0;i= 0 ) master_buf[prev].next = next; + if ( next >= 0 ) master_buf[next].prev = prev; + // Spock end + /* Spock deleted 2000/10/12 + if( master_buf[index].charvalue_index >= 0 ) { + charvalue_buf[ master_buf[index].charvalue_index].use = 0; + } + */ +} +void +dbShowLink( int topind ) +{ + int cur = topind; + + log( "开始从 %d 链接数据\n", cur ); + + /* Spock deleted 2000/10/19 + for(;;){ + if( cur == -1 )break; + */ + // Spock +1 2000/10/19 + while ( cur >= 0 ) + { + if( master_buf[cur].use == 0 ){ + log( "dbShowLink: use is 0! key:%s\n", master_buf[cur].key ); + return; + } + // Spock +1 2000/10/12 + log( "%s %i\n", master_buf[cur].key, master_buf[cur].ivalue ); + /* Spock deleted 2000/10/12 + log( "%s %u %i\n", master_buf[cur].key , + master_buf[cur].keyhash, master_buf[cur].ivalue ); + */ + cur = master_buf[cur].next; + } +} +// Spock 2000/10/13 +static int +reallocHash( int dbi ) +{ + struct hashentry *previous = dbt[dbi].hashtable; + struct hashentry *newbuf; + int new_hashsize; + + new_hashsize = dbt[dbi].hashsize + HASH_SIZE; + newbuf = (struct hashentry* ) calloc( 1, new_hashsize * + sizeof( struct hashentry) ); + if( newbuf == NULL ){ + log( "重新分配无用信息: 内存不足!!! 新无用信息大小: %d\n", new_hashsize ); + return -1; + } + + memset( newbuf , 0 , new_hashsize * sizeof( struct hashentry ) ); + if( previous ) + { + memcpy( newbuf, previous, + dbt[dbi].hashsize * sizeof( struct hashentry )); + free( previous ); + } + + if ( dbt[dbi].hashsize > HASH_PRIME ) + dbt[dbi].ent_finder = dbt[dbi].hashsize; + else + dbt[dbi].ent_finder = HASH_PRIME; + dbt[dbi].hashsize = new_hashsize; + dbt[dbi].hashtable = newbuf; + + log( "重新分配无用信息: 新无用信息大小:%d 旧地址: %x 新地址:%x\n", + new_hashsize , (unsigned int)previous, (unsigned int)newbuf ); + + return 0; +} + +static int tableGetEntry( int dbi , char *k ) +{ + int hashkey = dbHash( k ); + struct hashentry *hash = dbt[dbi].hashtable; + if ( hash[hashkey].use == 0 ) return -1; + while ( 1 ) { +// if ( hash[hashkey].use == 1 && strcmp( hash[hashkey].key , k ) == 0 ){ + if ( hash[hashkey].use == 1 ){ + if( strcmp( hash[hashkey].key , k ) == 0 )return hashkey; + } + hashkey = hash[hashkey].next; + if ( hashkey <= 0 ){ +// log("err not found hash[%x] -%s!\n", hashkey, k) + return -1; + } + } +} + +static int tableInsertNode( int dbi , char *k , int dbind ) +{ + int hashkey = dbHash( k ); + int hashnext = -1; + int i; + struct hashentry *hash = dbt[dbi].hashtable; + + if ( hash[hashkey].use == 0 ) { + strcpy( hash[hashkey].key , k ); + hash[hashkey].use = 1; + hash[hashkey].dbind = dbind; + hash[hashkey].prev = -1; + hash[hashkey].next = -1; + dbt[dbi].num++; + return hashkey; + }else { + for ( i=0; i= dbt[dbi].hashsize ) + dbt[dbi].ent_finder = HASH_PRIME; + if ( hash[dbt[dbi].ent_finder].use == 0 ) + { + hashnext = dbt[dbi].ent_finder; + break; + } + } + if ( hashnext < HASH_PRIME ) + { + log( "tableInsertNode: hashentry array full. reallocating....\n" ); + if( reallocHash( dbi ) < 0 ){ + log( "tableInsertNode: reallocation fail\n" ); + return -1; + } + else + { + hash = dbt[dbi].hashtable; + hashnext = dbt[dbi].ent_finder; + } + } + strcpy( hash[hashnext].key , k ); + hash[hashnext].use = 1; + hash[hashnext].dbind = dbind; + hash[hashnext].prev = hashkey; + hash[hashnext].next = hash[hashkey].next; + if ( hash[hashkey].next >= 0 ) + hash[hash[hashkey].next].prev = hashnext; + hash[hashkey].next = hashnext; + dbt[dbi].num++; + return hashnext; + } +} + +static void +tableReleaseNode( int dbi , int ind ) +{ + dbt[dbi].hashtable[ind].use = 0; + if ( dbt[dbi].hashtable[ind].prev >= 0 ){ + dbt[dbi].hashtable[dbt[dbi].hashtable[ind].prev].next = + dbt[dbi].hashtable[ind].next; + } + if ( dbt[dbi].hashtable[ind].next >= 0 ){ + dbt[dbi].hashtable[dbt[dbi].hashtable[ind].next].prev = + dbt[dbi].hashtable[ind].prev; + } + dbt[dbi].num--; +} +// Spock end +/* + 伉件弁及玄永皿毛芨尹日木凶日}平□毛 曰卞用□玉毛腹绸允月[ + 心勾井日卅中桦宁反巨仿□匹反卅中及匹0 + + */ +/* Spock deleted 2000/10/13 +static int +dbExtractNodeByKey( int topind , char *k ) +{ + int cur = topind; + int prev = -1; + unsigned int h = hashpjw( k ); + + // 伉件弁互坞匹手心勾井日卅中分仃卅及匹0毛井尹允 + if( topind == -1 ) return 0; + + for(;;){ + if( cur == -1 )break; + if( master_buf[cur].keyhash == h + && strcmp( master_buf[cur].key , k ) == 0 ){ + // prev 及 戚互 cur 及戚卞卅月方丹卞允月 + if( prev == -1 ){ + // 燮 分匀凶及匹伉件弁反中元日卅中 + } else { + master_buf[prev].nextind = master_buf[cur].nextind; + } + // 公木匹愤坌互伉旦玄井日陆木月及匹荸 允月 + dbReleaseNode( cur ); + log( "find key %s deleted\n", k ); + return 0; + } + prev = cur; + cur = master_buf[cur].nextind; + } + // not found + log( "dbExtractNodeBykey: %s not found\n" , k ); + return 0; +} +*/ +// Spock 2000/10/13 +static int +dbExtractNodeByKey( int dbi , char *k ) +{ + int hashind = tableGetEntry( dbi , k ); + + if ( hashind < 0 ){ + log( "dbExtractNodeByKey: tableGetEntry fail, key:%s\n" , k ); + return -1; + } + if ( dbt[dbi].hashtable[hashind].dbind < 0 ){ + log( "dbExtractNodeByKey: invalid dbind in hash, key:%s\n" , k ); + return -1; + } + dbReleaseNode( dbt[dbi].hashtable[hashind].dbind ); + tableReleaseNode( dbi , hashind ); + return 0; +} +// Spock end + +/* Spock deleted 2000/10/12 +static int +dbGetEntryByKey( int topind , char *k ) +{ + int cur = topind; + unsigned int h = hashpjw( k ); + + if( topind == -1 ) return 0; + + for(;;){ + if( cur == -1 )break; + if( master_buf[cur].keyhash == h + && strcmp( master_buf[cur].key, k ) == 0 ){ + return cur; + } + cur = master_buf[cur].nextind; + } + return -1; +} +*/ + +/* + 伉件弁及玄永皿毛芨尹日木凶日}袄毛 曰卞用□玉毛腹绸仄化 + 赝濠卅午仇欠卞 Insert 允月[切中今中 井日云云五中 卞卅日氏匹中月午 + 移烂 + + */ +/* Spock deleted 2000/10/13 +static int +dbInsertNodeByIValue( int topind , int ins ) +{ + int cur = topind; + int prev = -1; + + if( topind == -1 ) return -1; + + for(;;){ + if( cur == -1 ){ + // 引匹中匀凶及匹馨笛允月 + master_buf[prev].nextind = ins; + master_buf[ins].nextind = -1; + return 0; + } + if( master_buf[cur].ivalue < master_buf[ins].ivalue ){ + if( prev == -1 ){ + log( "top_node is badly configured\n" ); + return -1; + } + master_buf[prev].nextind = ins; + master_buf[ins].nextind = cur; + return 0; + } + prev = cur; + cur = master_buf[cur].nextind; + } + + return -1; +} +*/ +// Spock 2000/10/13 +static int +dbInsertNodeByIValue( int topind , int ins ) +{ + int cur = topind; + if ( (topind < 0)||(topind >= dbsize)||(ins < 0)||(ins >= dbsize ) ) + return -1; + while ( master_buf[cur].next >= 0 ){ + if ( master_buf[master_buf[cur].next].ivalue < master_buf[ins].ivalue ) + break; + cur = master_buf[cur].next; + } + master_buf[ins].prev = cur; + master_buf[ins].next = master_buf[cur].next; + if ( master_buf[cur].next >= 0 ) + master_buf[master_buf[cur].next].prev = ins; + master_buf[cur].next = ins; + return 0; +} +// Spock end +/* Spock deleted 2000/10/13 +static int +dbAppendNode( int topind , int ins ) +{ + int cur =topind; + int prev = -1; + if( topind == -1 ) return -1; + for(;;){ + if( cur == -1 ){ + master_buf[prev].nextind = ins; + master_buf[ins].nextind = -1; + return 0; + } + prev = cur; + cur = master_buf[cur].nextind; + } + return -1; +} +*/ +// Spock 2000/10/13 +static int +dbAppendNode( int topind , int ins ) +{ + + if ( (topind < 0)||(topind >= dbsize)||(ins < 0)||(ins >= dbsize ) ) + return -1; + master_buf[ins].prev = topind; + master_buf[ins].next = master_buf[topind].next; + if ( master_buf[topind].next >= 0 ) + master_buf[master_buf[topind].next].prev = ins; + master_buf[topind].next = ins; + return 0; +} +// Spock end + +/* + 犯□正矛□旦及 蟆毛 月[db反醒互剂卅中及匹 骚卞strcmp仄化方中 + DBTYPE :潘 [ + + 云卅元卅引尹及 反}帮醒午 侬 及 卞绣箕允月仇午互匹五月[ + + */ +static int +dbGetTableIndex( char *tname , DBTYPE type ) +{ + int i; + + for(i=0;i= sizeof( master_buf[0].key) )return -1; + + if( dbi < 0 ) return -1; + + r = dbExtractNodeByKey( dbt[dbi].toplinkindex , key ); + if( r < 0 ){ + log( "dbUpdateEntryInt: dbExtractNodeByKey fail! bug!!!!\n" ); + return -1; + } + + entind = dbAllocNode(DB_INT_SORTED); + if( entind < 0 ) return -1; + master_buf[entind].ivalue = value; + snprintf( master_buf[entind].key , + sizeof(master_buf[entind].key), "%s", key ); + master_buf[entind].keyhash = hashpjw( master_buf[entind].key ); + master_buf[entind].nextind = -1; + + // 尥笛树 毛本永玄允月 + dbSetString( master_buf[entind].charvalue_index, info ); + + + r = dbInsertNodeByIValue( dbt[dbi].toplinkindex , entind ); + if( r < 0 ){ + log( "dbUpdateEntryInt: dbInsertNodeByIValue failed\n" ); + return -1; + } + + log( "dbUpdateEntryInt: successfully updated entry %s:%s:%d\n", + table, key, value ); + return 0; + +} +*/ +// Spock 2000/10/16 +int dbUpdateEntryInt( char *table , char *key , int value, char *info ) +{ + int dbi = dbGetTableIndex( table , DB_INT_SORTED ); + int dbind, hashind, newpos; + // Spock 2000/10/23 + if ( strlen( key ) >= KEY_MAX ) { + log( "dbUpdateEntryInt: key is too long, key:%s\n", key ); + return -1; + } + if ( strlen( info ) >= CHARVALUE_MAX ) { + log( "dbUpdateEntryInt: charvalue is too long, charvalue:%s\n", info ); + return -1; + } + // Spock end + if ( dbi < 0 ){ + log( "dbUpdateEntryInt: dbGetTableIndex fail\n"); + return -1; + } + hashind = tableGetEntry( dbi , key ); + if ( hashind < 0 ) + { + dbind = dbAllocNode(); + if ( dbind < 0 ) + { + log( "dbUpdateEntryInt: dbAllocNode fail\n" ); + return -1; + } + master_buf[dbind].ivalue = value; + strcpy( master_buf[dbind].key , key ); + strcpy( master_buf[dbind].charvalue , info ); + if ( dbInsertNodeByIValue( dbt[dbi].toplinkindex , dbind ) < 0 ) + { + master_buf[dbind].use = 0; + log( "dbUpdateEntryInt: dbInsertNodeByIValue fail\n" ); + return -1; + } + if ( tableInsertNode( dbi , key , dbind ) < 0 ) + { + dbReleaseNode( dbind ); + log( "dbUpdateEntryInt: tableInsertNode fail\n" ); + return -1; + } + } + else + { + dbind = dbt[dbi].hashtable[hashind].dbind; + master_buf[dbind].ivalue = value; + strcpy( master_buf[dbind].charvalue , info ); + newpos = dbind; + while ( master_buf[newpos].prev >= 0 ) + { + if ( value <= master_buf[master_buf[newpos].prev].ivalue ) + { + break; + } + newpos = master_buf[newpos].prev; + } + if ( newpos != dbind ) + { + master_buf[master_buf[dbind].prev].next = master_buf[dbind].next; + if ( master_buf[dbind].next >= 0 ) + master_buf[master_buf[dbind].next].prev = master_buf[dbind].prev; + master_buf[dbind].prev = master_buf[newpos].prev; + master_buf[dbind].next = newpos; + if ( master_buf[newpos].prev >= 0 ) + master_buf[master_buf[newpos].prev].next = dbind; + master_buf[newpos].prev = dbind; + dbt[dbi].updated = 1; + /* + log( "dbUpdateEntryInt: successfully updated entry %s:%s:%d\n", + table, key, value ); + */ + return 0; + } + while ( master_buf[newpos].next >= 0 ) + { + if ( value >= master_buf[master_buf[newpos].next].ivalue ) + { + break; + } + newpos = master_buf[newpos].next; + } + if ( newpos != dbind ) + { + master_buf[master_buf[dbind].prev].next = master_buf[dbind].next; + master_buf[master_buf[dbind].next].prev = master_buf[dbind].prev; + master_buf[dbind].prev = newpos; + master_buf[dbind].next = master_buf[newpos].next; + if ( master_buf[newpos].next >= 0 ) + master_buf[master_buf[newpos].next].prev = dbind; + master_buf[newpos].next = dbind; + } + } + dbt[dbi].updated = 1; + /* + log( "dbUpdateEntryInt: successfully updated entry %s:%s:%d\n", + table, key, value ); + */ + return 0; +} +// Spock end + +int +dbDeleteEntryInt( char *table, char *key ) +{ + int dbi = dbGetTableIndex( table , DB_INT_SORTED ); + int r; + + if ( strlen( key ) >= KEY_MAX ) { + log( "dbDeleteEntryInt: key is too long, key:%s\n", key ); + return -1; + } + if( dbi < 0 ) { + log( "dbDeleteEntryInt: dbGetTableIndex failed for %s\n", table ); + return -1; + } + //r = dbExtractNodeByKey( dbt[dbi].toplinkindex , key ); + // Spock fixed 2000/10/19 + r = dbExtractNodeByKey( dbi , key ); + if( r < 0 ){ + log( "dbDeleteEntryInt: dbExtractNodeByKey failed for %s in %s\n", + key,table ); + return -1; + } + // Spock +1 2000/10/19 + dbt[dbi].updated = 1; + log( "deleted key %s from table %s\n", key, table ); + return 0; +} + +static void +dbShowAllTable(void) +{ + int i; + + for(i=0;i= sizeof( master_buf[entind].key) ) return -1; + if( dbi <0 ) { + log( "dbGetEntryInt: dbGetTableIndex fail\n" ); + return -1; + } + // Spock 2000/10/19 + if( strlen(key) >= KEY_MAX ) { + log( "dbGetEntryInt: key is too long, key:%s\n" , key ); + return -1; + } + hashind = tableGetEntry( dbi , key ); + if( hashind < 0 ) return -1; + entind = dbt[dbi].hashtable[hashind].dbind; + //entind = dbGetEntryByKey( dbt[dbi].toplinkindex , key ); + // Spock end + if( entind < 0 ) { + log( "dbGetEntryInt: Invalid dbind in hashtable of %s\n" , table ); + return -1; + } + /* 心勾井匀凶及匹袄毛请 卞 木化忒允 */ + *output = master_buf[entind].ivalue; + + return 0; +} + +/* + 巨仿□及桦宁反 [0分匀凶日岳 [ + + int *rank_out : 仿件弁及请 + int *count_out : 晓井日窒蜊 井及请 + + int 犯□正矛□旦毁迕友 + + */ + +int +dbGetEntryRank( char *table, char *key , int *rank_out, int *count_out) +{ + int dbi = dbGetTableIndex( table , DB_INT_SORTED ); + // Spock deleted 2000/10/19 + //unsigned int hash = hashpjw(key); + int cur; + int now_score = 0x7fffffff; /*int 匹中切壬氏匹井中袄 */ + int r = -1 , i=0; + + // Spock 2000/10/23 + //if( strlen(key) >= sizeof( master_buf[cur].key) ) return -1; + if( strlen(key) >= KEY_MAX ) { + log( "dbGetEntryRank: key is too long, key:%s\n" , key ); + return -1; + } + if( dbi <0 ) { + log( "dbGetEntryRank: dbGetTableIndex fail\n" ); + return -1; + } + // Spock end + + // Spock 2000/10/23 + //cur = master_buf[dbt[dbi].toplinkindex].nextind; + cur = master_buf[dbt[dbi].toplinkindex].next; + //i=0; + //for(;;){ + // if( cur == -1 )break; + while ( cur >= 0 ) + { + // Spock end + if( master_buf[cur].ivalue != now_score ){ + r=i; + now_score = master_buf[cur].ivalue; + } + // Spock 2000/10/19 + //if( hash == master_buf[cur].keyhash && + // strcmp( master_buf[cur].key, key )== 0 ){ + if( strcmp( master_buf[cur].key , key ) == 0 ) + { + // Spock end + *rank_out = r; + *count_out = i; + return 0; + } + //cur = master_buf[cur].nextind; + // Spock fixed 2000/10/19 + cur = master_buf[cur].next; + i++; + } + *count_out = i; + *rank_out = r; + return 0; +} + +/* + int 毁迕友 + */ +int +dbGetEntryRankRange( char *table, + int start, int end, char *output, int outlen ) +{ +#define MAXHITS 1024 /* 赝癫支卅丐[匹手仇木匹蜗坌日仄中冗 ringo */ + struct hitent{ /* 仇及厌瞻 卞甲永玄仄凶支勾毛凶户化中仁 */ + int entind; + int rank; + }; + + int r=0; + struct hitent hits[MAXHITS]; + int dbi = dbGetTableIndex( table , DB_INT_SORTED ); + int cur; + int hitsuse = 0,i; + int now_score = 0x7fffffff; + + if( dbi <0 ) return -1; + if( outlen <= 0 )return -1; + + cur = dbt[dbi].toplinkindex; + // Spock 2000/10/23 + //for(;;){ + // if( cur == -1 )break; + while ( cur >= 0 ) + { + // Spock end + if( master_buf[cur].ivalue != now_score ){ + r++; + now_score = master_buf[cur].ivalue; + } + if( r >= start && r <= end ){ + hits[hitsuse].entind = cur; + hits[hitsuse].rank = r; + hitsuse++; + //if( hitsuse == MAXHITS )break; + // Spock fixed 2000/10/23 + if( hitsuse >= MAXHITS ) break; + } + //cur = master_buf[cur].nextind; + // Spock fixed 2000/10/19 + cur = master_buf[cur].next; + } + output[0] = 0; + + for(i=0;i= 0 ) + { + // Spock end + if( dbt[i].type == DB_INT_SORTED ){ + fprintf( fp , "%s %d %s\n", master_buf[entind].key, + master_buf[entind].ivalue, + //makeStringFromEscaped( + // dbGetString(master_buf[entind].charvalue_index))); + // Spock fixed 2000/10/19 + makeStringFromEscaped(master_buf[entind].charvalue)); + } else { + fprintf( fp , "%s %s\n", master_buf[entind].key, + //makeStringFromEscaped( + // dbGetString(master_buf[entind].charvalue_index))); + // Spock fixed 2000/10/19 + makeStringFromEscaped(master_buf[entind].charvalue)); + } + //entind = master_buf[entind].nextind; + // Spock fixed 2000/10/19 + entind = master_buf[entind].next; + } + fclose(fp); + dbt[i].updated = 0; + } + + return 0; +} + + +int dbRead( char *dir ) +{ + char dirname[1024]; + DIR *d; + struct dirent *de; + // Spock +1 2000/10/19 + memset( dbt , 0 , MAXTABLE * sizeof(struct table) ); + { + char tmp[1024]; + snprintf( tmp, sizeof( tmp ), "%s/int" , dir ); + if( mkdir( tmp, 0755 )==0){ + log( "创建 %s\n", tmp ); + } + snprintf( tmp, sizeof( tmp ), "%s/string" , dir ); + if( mkdir( tmp, 0755 )==0){ + log( "创建 %s\n", tmp ); + } + } + + snprintf( dirname, sizeof( dirname ), + "%s/int" , dir ); + d = opendir(dirname); + if( d == NULL ){ + log( "不能打开文件 %s\n", dirname ); + return -1; + } + + while(1){ + de = readdir( d ); + if( de == NULL )break; + if( de->d_name[0] != '.' ){ + char filename[1024]; + FILE *fp; + struct stat s; + snprintf( filename, sizeof(filename),"%s/%s",dirname, de->d_name ); + log( "读取数据:%s\n..", filename); + if( stat( filename, &s ) < 0 ){ + continue; + } + if( !( s.st_mode & S_IFREG ) ){ + continue; + } + + fp = fopen( filename, "r" ); + if( fp == NULL ){ + log( "不能打开文件 %s %s\n", + filename, strerror( errno )); + continue; + } + while(1){ + char line[1024]; + char k[1024] , v[1024], info[1024]; + if( fgets( line , sizeof( line) , fp ) == NULL )break; + chop( line); + k[0] = '\0'; + easyGetTokenFromString( line, 1, k, sizeof(k)); + v[0] = '\0'; + easyGetTokenFromString( line, 2, v, sizeof(v)); + info[0] = '\0'; + easyGetTokenFromString( line, 3, info, sizeof(info)); + dbUpdateEntryInt( de->d_name, k, atoi(v), info); + } + fclose(fp); + } + } + closedir(d); + snprintf( dirname, sizeof( dirname), "%s/string" , dir ); + d = opendir( dirname ); + if( d == NULL ){ + log( "不能打开文件 %s\n", dirname ); + return -1; + } + while(1){ + de = readdir( d ); + if( de == NULL )break; + if( de->d_name[0] != '.' ){ + char filename[1024]; + FILE *fp; + struct stat s; + snprintf( filename, sizeof( filename),"%s/%s",dirname,de->d_name ); + log( "读取数据:%s\n..", filename); + + if( stat( filename, &s ) < 0 ){ + continue; + } + if( !(s.st_mode & S_IFREG )){ + continue; + } + fp = fopen( filename, "r" ); + if( fp == NULL ){ + log( "不能打开文件 %s %s\n", + filename, strerror(errno )); + continue; + } + while(1){ + char line[CHARVALUE_MAX+1024]; + char k[1024]; + if( fgets( line, sizeof( line), fp ) == NULL )break; + /* chop */ + chop(line); + k[0] = '\0'; + easyGetTokenFromString( line, 1, k,sizeof(k)); + dbUpdateEntryString( de->d_name, k, line+strlen(k)+1); + } + // Nuke +1 1027: Close for safe + fclose(fp); + } + } + closedir(d); + return 0; +} + +/* 隙烂仄凶匏 井日隙烂仄凶蜊醒潸曰分允[ + 撩 仄凶日 }岳 仄凶日0[岳 仄化手坞及请 及午五互丐月冗[ + “num互0及午五午井}竟癫允月巨件玄伉互卅中午五[ + + int 犯□正矛□旦毁迕分冗 + + */ +int dbGetEntryCountRange( char *table, int count_start, int num, + char *output, int outlen ) +{ + int dbi = dbGetTableIndex( table , DB_INT_SORTED ); + int cur; + int i; + int now_score = 0x7fffffff , r; + + if( dbi < 0) return -1; + if( outlen < 1 ) return -1; + output[0]=0; + + //cur = master_buf[dbt[dbi].toplinkindex].nextind; + // Spock fixed 2000/10/19 + cur = master_buf[dbt[dbi].toplinkindex].next; + i=0; + r=0; + for(;;){ + if( cur == -1 ) break; + + if( master_buf[cur].ivalue != now_score ){ + r=i; + now_score = master_buf[cur].ivalue; + } + + if( ( i >= count_start ) && + ( i < (count_start + num ) ) ){ + char tmp[1024]; + if( (i !=count_start)){ + strcatsafe( output, outlen, "|" ); + } + + snprintf( tmp, sizeof( tmp), + "%d,%d,%s,%d,%s", i, r, master_buf[cur].key, + master_buf[cur].ivalue, + //dbGetString( master_buf[cur].charvalue_index )); + // Spock fixed 2000/10/19 + master_buf[cur].charvalue); + strcatsafe( output, outlen,tmp ); + } + i++; + //cur = master_buf[cur].nextind; + // Spock fixed 2000/10/19 + cur = master_buf[cur].next; + } + return 0; +} + + +/* + 侬 犯□正矛□旦及质 + */ +/* Spock deleted 2000/10/19 +int +dbUpdateEntryString( char *table, char *key, char *value ) +{ + int dbi = dbGetTableIndex(table, DB_STRING); + int r, entind; + + log( "dbUpdateEntryString: [%s] [%s] [%s]\n", table, key, value ); + + if( strlen(key) >= sizeof(master_buf[0].key) )return -1; + if( dbi < 0 )return -1; + + r = dbExtractNodeByKey( dbt[dbi].toplinkindex, key ); + if( r< 0 ){ + log( "dbUpdateEntryString dbExtractNodeByKey fail! bug!!\n" ); + return -1; + } + + entind = dbAllocNode( DB_STRING ); + if( entind < 0 ) return -1; + + master_buf[entind].ivalue = 0; + dbSetString( master_buf[entind].charvalue_index, value ); + snprintf( master_buf[entind].key, + sizeof(master_buf[0].key), "%s",key ); + master_buf[entind].keyhash = hashpjw( master_buf[entind].key ); + master_buf[entind].nextind = -1; + + if( dbAppendNode( dbt[dbi].toplinkindex, entind ) < 0 ){ + log( "dbUpdateEntryString: dbAppendNode failed\n" ); + return -1; + } + log( "dbUpdateEntryString: successfully updated entry %s:%s:%s\n", + table,key,value ); + + return 0; +} +*/ +// Spock 2000/10/19 +int dbUpdateEntryString( char *table, char *key, char *value ) +{ + int dbi = dbGetTableIndex( table , DB_STRING ); + int dbind, hashind; + + if ( strlen( key ) >= KEY_MAX ) { + log( "dbUpdateEntryString: key is too long, key:%s\n", key ); + return -1; + } + if ( strlen( value ) >= CHARVALUE_MAX ) { + log( "dbUpdateEntryString: charvalue is too long, charvalue:%s\n", value ); + return -1; + } + if ( dbi < 0 ) { + log( "dbUpdateEntryString: dbGetTableIndex fail, table:%s\n", table ); + return -1; + } + hashind = tableGetEntry( dbi , key ); + if ( hashind < 0 ) + { + dbind = dbAllocNode(); + if ( dbind < 0 ) + { + log( "dbUpdateEntryString: dbAllocNode fail\n" ); + return -1; + } + strcpy( master_buf[dbind].key , key ); + strcpy( master_buf[dbind].charvalue , value ); + if ( dbAppendNode( dbt[dbi].toplinkindex , dbind ) < 0 ) + { + master_buf[dbind].use = 0; + log( "dbUpdateEntryString: dbAppendNode fail\n" ); + return -1; + } + if ( tableInsertNode( dbi , key , dbind ) < 0 ) + { + dbReleaseNode( dbind ); + log( "dbUpdateEntryString: tableInsertNode fail\n" ); + return -1; + } + } + else + { + dbind = dbt[dbi].hashtable[hashind].dbind; + strcpy( master_buf[dbind].charvalue , value ); + } + dbt[dbi].updated = 1; + /* + log( "dbUpdateEntryString: successfully updated entry %s:%s:%s\n", + table,key,value ); + */ + return 0; +} +// Spock end + +int +dbGetEntryString( char *table, char *key, char *output, int outlen ) +{ + int dbi = dbGetTableIndex( table, DB_STRING ); + int entind; + // Spock +1 2000/10/19 + int hashind; + + // Spock 2000/10/23 + //if( strlen(key) >= sizeof( master_buf[entind].key) ) return -1; + if ( strlen(key) >= KEY_MAX ) { + log( "dbGetEntryString: key is too long, key:%s\n", key ); + return -1; + } + if( dbi <0 ) { + log( "dbGetEntryString: dbGetTableIndex fail\n" ); + return -1; + } + // Spock 2000/10/19 + hashind = tableGetEntry( dbi , key ); + if ( hashind < 0 ){ + log("err hashind <0\n") + return -1; + } + entind = dbt[dbi].hashtable[hashind].dbind; + + if ( entind < 0 ){ + log( "entind < 0 "); + return -1; + } + snprintf( output , outlen , "%s" , master_buf[entind].charvalue ); + + return 0; +} + +int +dbDeleteEntryString( char *table, char *key ) +{ + int dbi = dbGetTableIndex( table, DB_STRING ); + int r; + + // Spock 2000/10/23 + //if( strlen(key) >= sizeof( master_buf[entind].key) ) return -1; + if ( strlen(key) >= KEY_MAX ) { + log( "dbDeleteEntryString: key is too long, key:%s\n", key ); + return -1; + } + if( dbi <0 ) { + log( "dbDeleteEntryString: dbGetTableIndex fail\n" ); + return -1; + } + // Spock end + //r = dbExtractNodeByKey( dbt[dbi].toplinkindex, key ); + // Spock fixed 2000/10/19 + r = dbExtractNodeByKey( dbi , key ); + if( r < 0 ){ + log( "dbDeleteEntryString: dbExtractNodeByKey failed for %s in %s\n", + key,table ); + return -1; + } + dbt[dbi].updated = 1; + log( "deleted key %s from table %s\n", key, table ); + return 0; +} diff --git a/saac/db.h b/saac/db.h new file mode 100644 index 0000000..54eae2f --- /dev/null +++ b/saac/db.h @@ -0,0 +1,19 @@ +#ifndef _DB_H_ +#define _DB_H_ + +int dbUpdateEntryInt( char *table , char *key , int value, char *info ); +int dbUpdateEntryString( char *table, char *key, char *value ); +int dbDeleteEntryInt( char *table, char *key ); +int dbDeleteEntryString( char *table, char *key ); +int dbGetEntryInt( char *table, char *key, int *output ); +int dbGetEntryString( char *table, char *key, char *output, int outlen ); +int dbGetEntryRank( char *table, char *key , int *r_out, int *c_out ); +int dbGetEntryRankRange( char *table, + int start, int end, char *output, int outlen ); +int dbGetEntryCountRange( char *table, int count_start, int num, + char *output, int outlen ); + +int dbRead( char *dir ); +int dbFlush( char *dir ); + +#endif diff --git a/saac/deathcontend.c b/saac/deathcontend.c new file mode 100644 index 0000000..3542ccb --- /dev/null +++ b/saac/deathcontend.c @@ -0,0 +1,1127 @@ +#include "version.h" +#include +#include "main.h" +#include "saacproto_util.h" +#include "saacproto_serv.h" +#include "recv.h" +#include "char.h" +#include "util.h" + +#include "deathcontend.h" + +#ifdef _DEATH_CONTEND + +PkTeamLists *PkTeamList=NULL; +static int PKListSort[550]; +enum{ + CODE_OK=0, + CODE_ERR=-1, + CODE_OUTSTRIP=-2, + CODE_REPEAT=-3, + + CODE_LEADERERR=-10, + CODE_ERRBATTLEFULL=-11, +}; +static int maxteam = 0; + +void del_rn( char *s ) +{ + int i; + for(i=0;;i++){ + if( s[i] == '\r' || s[i] == '\n' ) s[i] = 0; + if( s[i] == 0 )break; + } +} + +int PKLIST_SetOneBHistory( int ti, int hi, int use, int teamnum, int flg ) +{ + if( ti < 0 || ti >= maxteam ) return CODE_OUTSTRIP; + if( hi < 0 || hi >= MAXBATTLENUM ) return CODE_OUTSTRIP; + if( PkTeamList[ti].BHistory[hi].use == use ) return CODE_REPEAT; + + PkTeamList[ti].BHistory[hi].teamnum = teamnum; + PkTeamList[ti].BHistory[hi].flg = flg; + PkTeamList[ti].BHistory[hi].use = use; + return CODE_OK; +} + +int PKLIST_GetOneBHistory( int ti ) +{ + int i; + if( ti < 0 || ti >= maxteam ){ + log( "GetOneBHistory(ti:%d) err return -1 !!\n", ti) + return -1; + } + for( i=0; i=DEFMAXBATTLENUM ) break; + if( PkTeamList[ti].BHistory[i].use == 0 ){ + log("return BHistory[%d] \n", i) ; + return i; + } + } + + log("return CODE_ERRBATTLEFULL err !! \n") ; + return CODE_ERRBATTLEFULL; +} +//勿动------------------------------------------------------- +void PKLIST_ResetOneTeamMan( int ti ) +{ + int k; + if( ti < 0 || ti >= maxteam ) return; + for( k=0;k= maxteam ) return; + PkTeamList[ti].use = 0; + PkTeamList[ti].teamnum = -1; + memset( PkTeamList[ti].teamname, 0, sizeof( PkTeamList[ti].teamname ) ); + memset( PkTeamList[ti].pathdir, 0, sizeof( PkTeamList[ti].pathdir) ); + memset( PkTeamList[ti].leadercdkey, 0, sizeof( PkTeamList[ti].leadercdkey ) ); +} +//----------------------------------------------------------- + +int PKLIST_InitPkTeamList( int teamnum ) +{ + int i; + if( PkTeamList != NULL || teamnum <= 0 ) return -1; + + log( "PKLIST_InitPkTeamList( maxteam:%d) \n", teamnum); + + maxteam = teamnum; + PkTeamList = (PkTeamLists *)calloc( 1, sizeof( struct _tagPkTeamLists) * maxteam ); + if( PkTeamList == NULL ){ + log( "ANDY err Can't calloc PkTeamList :%d !!\n", + sizeof( struct _tagPkTeamLists) * maxteam ); + return -1; + } + for( i=0; i= DEFWINSCORE ){ + PkTeamList[ti].inside = 2; //录取 + }else if( PkTeamList[ti].lost > DEFMAXBATTLENUM*DEFLOSERATE){// 0.7 = (1-胜率3成)*最高场次 + PkTeamList[ti].inside = 0; + }else { + PkTeamList[ti].inside = 1; + } + + if( PkTeamList[ti].score < 0 ) PkTeamList[ti].score = 0; + + ret = PKLIST_SetOneBHistory( ti, battleTi, 1, forti, winerflg); + PKLIST_SortTheCharts( ti); + return ret; +} + +int PKLIST_getStringPkTeamData( int ti, char *data, int sizes) +{ + int k; + char buf[512]; + if( PkTeamList[ti].use != 1 ) return 0; + + + sprintf( data, "%d_%d|%s|%s|%s|%d|%d|%d|%d|%d_", + ti, + PkTeamList[ti].teamnum, PkTeamList[ti].pathdir, + PkTeamList[ti].teamname, PkTeamList[ti].leadercdkey, + PkTeamList[ti].win, PkTeamList[ti].lost, + PkTeamList[ti].battleplay, PkTeamList[ti].score, + PkTeamList[ti].inside ); + + for( k=0; k= maxteam || count < 1) return; + memset( data, 0, sizeof( data)); + + for( i=startTi; i= sizeof( data)) { + saacproto_PKLISTGETDATA_send( fd, "success", i, data ); + return; + } + if( first != 1 ) strcat( data, " "); + first = 0; + strcat( data, bufarg); + } + + if( strlen( data) > 0 ){ + saacproto_PKLISTGETDATA_send( fd, "success", -1, data ); + } + + return; +} + +int PKLIST_GetPkTeamListArray( int teamnum, char *cdkey) +{ + int i; + for( i=0; i= DEFWINSCORE ){ + PkTeamList[i].inside = 2; //录取 + }else if( PkTeamList[i].lost > DEFMAXBATTLENUM*DEFLOSERATE){// 0.7 = (1-胜率3成)*最高场次 + PkTeamList[i].inside = 0; + }else { + PkTeamList[i].inside = 1; + } + } +} + +//load档 +int PKLIST_LoadPkTeamListfromFile( char *dirpath, char *listfilename ) +{ + char line[512], filename[256], buf1[64]; + FILE *fp = NULL, *efp=NULL; + int i, count=0; + + if( PkTeamList == NULL ) return -1; + sprintf( filename, "%s/%s", dirpath, listfilename); + log( "LoadPkTeamListfromFile( file:%s) \n", filename); + if( (fp = fopen( filename, "r" )) == NULL ){ + log( "can't load file:%s !\n", filename); + return -1; + } + sprintf( filename, "%s/%s", dirpath, "err1.txt"); + if( (efp = fopen( filename, "w+" )) == NULL ){ + log( "can't load file:%s !\n", filename); + return -1; + } + + while( fgets( line, sizeof( line), fp) ) { + if( strlen( line) <= 0 || line[0] == '#' ) continue; + if( count >= maxteam )break; + del_rn( line); + log( "#"); + easyGetTokenFromBuf( line, '|', 1, buf1, sizeof( buf1 )); + if( strlen( buf1) <= 0 ){ + fprintf( efp,"TEAMNUM err:%s", line); + continue; + } + PkTeamList[count].teamnum = atoi(buf1); + if( PkTeamList[count].teamnum < 0 ) continue; + easyGetTokenFromBuf( line, '|', 2, buf1, sizeof( buf1 )); + if( strlen( buf1) <= 0 ) continue; + sprintf( PkTeamList[count].pathdir, "%s", buf1); + easyGetTokenFromBuf( line, '|', 3, buf1, sizeof( buf1 )); + if( strlen( buf1) <= 0 ){ + if( strlen( buf1) <= 0 ){ + fprintf( efp,"TEAMNAME err:%s", line); + continue; + } + continue; + } + sprintf( PkTeamList[count].teamname, "%s", buf1); + easyGetTokenFromBuf( line, '|', 4, buf1, sizeof( buf1 )); + if( strlen( buf1) <= 0 ){ + if( strlen( buf1) <= 0 ){ + fprintf( efp,"MASTER err:%s", line); + continue; + } + continue; + } + sprintf( PkTeamList[count].leadercdkey, "%s", buf1); + + easyGetTokenFromBuf( line, '|', 5, buf1, sizeof( buf1 )); + if( strlen( buf1) <= 0 ) continue; + PkTeamList[count].win = atoi(buf1); + easyGetTokenFromBuf( line, '|', 6, buf1, sizeof( buf1 )); + if( strlen( buf1) <= 0 ) continue; + PkTeamList[count].lost = atoi(buf1); + easyGetTokenFromBuf( line, '|', 7, buf1, sizeof( buf1 )); + if( strlen( buf1) <= 0 ) continue; + PkTeamList[count].battleplay = atoi(buf1); + easyGetTokenFromBuf( line, '|', 8, buf1, sizeof( buf1 )); + if( strlen( buf1) <= 0 ) continue; + PkTeamList[count].score = atoi(buf1); + easyGetTokenFromBuf( line, '|', 9, buf1, sizeof( buf1 )); + if( strlen( buf1) <= 0 ) continue; + PkTeamList[count].inside = atoi(buf1); + + easyGetTokenFromBuf( line, '|', 10, buf1, sizeof( buf1 )); + if( strlen( buf1) <= 0 ) continue; + PkTeamList[count].updata = atoi(buf1); + + { + FILE *ffp=NULL; + char teamfilename[256], bufarg[256], buf2[256]; + int readfirst = 1, k, bnum=0; + sprintf( teamfilename, "%s/%s/team_%d.txt", "pklist", + PkTeamList[count].pathdir, PkTeamList[count].teamnum ); + + if( (ffp=fopen( teamfilename, "r") ) == NULL ) continue; + + while( fgets( bufarg, sizeof( bufarg), ffp) ) { + if( strlen( bufarg) <= 0 || bufarg[0] == '#' ) continue; + del_rn( bufarg); + if( readfirst == 1 ){ + for( k=0; k= MAXBATTLENUM )break;//超过战斗场次 + for( k=0; k<10; k++){ + easyGetTokenFromBuf( bufarg, '|', k+1, buf1, sizeof( buf1 )); + if( strlen( buf1) <= 0 ) continue; + easyGetTokenFromBuf( buf1, ',', 1, buf2, sizeof( buf2 )); + if( strlen( buf2) <= 0 ) continue; + PkTeamList[count].BHistory[bnum].teamnum = atoi( buf2); + easyGetTokenFromBuf( buf1, ',', 2, buf2, sizeof( buf2 )); + if( strlen( buf2) <= 0 ) continue; + PkTeamList[count].BHistory[bnum].flg = atoi( buf2); + PkTeamList[count].BHistory[bnum].use = 1; + bnum++; + } + + } + + fclose( ffp); + } + + PkTeamList[count].use = 1; + count++; + } + fclose( efp); + fclose( fp); + { + int k; + log( "\n"); + for( i=0; i 0 ) + fprintf( ffp, "%s\n", bufarg); + fclose( ffp); + } + } + fclose( fp); + return 1; +} +//PKListSort[1000] +void PKLIST_SortTheCharts( int ti) //排行榜处理 +{ +extern gmsv gs[MAXCONNECTION]; + int i, k, last=-1; + + if( PkTeamList[ti].use != 1 ) return; + if( PkTeamList[ti].battleplay < 3 ) return; + + for( k=0; k<550; k++){ + if( PKListSort[k] == -1 )continue; + if( PKListSort[k] == ti ){ + PKListSort[k] = -1; + } + } + + for( k=549; k>=0; k-- ){ + if( PKListSort[k] == -1 ){ + last = k; + continue; + } + if( PkTeamList[ti].score > PkTeamList[PKListSort[k]].score ){ + last = k; + continue; + } + break; + } + if( last == -1 ) return; + for( i=548; i>=last; i-- ){ + PKListSort[i+1] = PKListSort[i]; + } + log( "\nPKListSort[%d]=%d \n", PKListSort[last], ti); + PKListSort[last]=ti; + + //更新所有伺服器 + for (i=0; i 0 ) + saacproto_PKLISTCHARTS_send( fd, data, type, flg ); + break; + + case 3: + { + char filename[256]; + FILE *fp=NULL; + PKLIST_Sort_PKListSort(); + sprintf( filename, "%s/%s", "pklist", "hero.txt" ); + remove( filename); + if( (fp=fopen( filename, "w+")) == NULL ) return; + for( i=0; i<550; i++ ){ + if( PKListSort[i] == -1 ) continue; + fprintf( fp, "%d|%s|%s|%s|%d|%d|%d|%d|%d|%d\n", + PkTeamList[PKListSort[i]].teamnum, PkTeamList[PKListSort[i]].pathdir, + PkTeamList[PKListSort[i]].teamname, PkTeamList[PKListSort[i]].leadercdkey, + PkTeamList[PKListSort[i]].win, PkTeamList[PKListSort[i]].lost, + PkTeamList[PKListSort[i]].battleplay, PkTeamList[PKListSort[i]].score, + PkTeamList[PKListSort[i]].inside, PkTeamList[PKListSort[i]].updata ); + } + fclose( fp); + } + break; + + + } +} + +//备份存档 + + +//load档 +int PKLIST_LoadUserfromFile( char *dirpath, char *listfilename ) +{ + char line[512], filename[256], buf1[64]; + FILE *fp = NULL, *tfp=NULL, *bfp=NULL; + int i, count=0, teamn = 1; + + if( PkTeamList == NULL ) return -1; + sprintf( filename, "%s/%s", dirpath, listfilename); + log( "PKLIST_LoadUserfromFile( file:%s) \n", filename); + if( (fp = fopen( filename, "r" )) == NULL ){ + log( "can't load file:%s !\n", filename); + return -1; + } + + sprintf( filename, "%s/%s", dirpath, "d.txt"); + if( (tfp = fopen( filename, "a+" )) == NULL ){ + log( "can't load file:%s !\n", filename); + return -1; + } + sprintf( filename, "%s/%s", dirpath, "badteam.txt"); + if( (bfp = fopen( filename, "a+" )) == NULL ){ + log( "can't load file:%s !\n", filename); + return -1; + } + while( fgets( line, sizeof( line), fp) ) { + int spoint=2; + int ManNum=0, leve=1; + char StartS[256], dData[1024]; + memset( dData, 0, sizeof(dData)); + memset( StartS, 0, sizeof(StartS)); + if( strlen( line) <= 0 || line[0] == '#' ) continue; + if( count >= maxteam )break; + del_rn( line); + + //队伍名称 队伍序号 + easyGetTokenFromBuf( line, ',', 1, buf1, sizeof( buf1 )); + if( strlen( buf1) <= 0 ) continue; + sprintf( PkTeamList[count].teamname, "%s", buf1); + + PkTeamList[count].teamnum = teamn++; + + while( 1){ + easyGetTokenFromBuf( line, ',', spoint++, buf1, sizeof( buf1 )); + if( strlen( buf1) <= 0 ) break; + sprintf( StartS, "%s", buf1); //星系 + + easyGetTokenFromBuf( line, ',', spoint++, buf1, sizeof( buf1 )); + if( strlen( buf1) <= 0 ) break; + sprintf( PkTeamList[count].MyTeamMans[ManNum].cdkey, "%s", buf1); //帐号 + + easyGetTokenFromBuf( line, ',', spoint++, buf1, sizeof( buf1 )); + if( strlen( buf1) <= 0 ) break; + sprintf( PkTeamList[count].MyTeamMans[ManNum].name, "%s", buf1); //人物名 + + easyGetTokenFromBuf( line, ',', spoint++, buf1, sizeof( buf1 )); + if( strlen( buf1) <= 0 ) break; + leve = atoi( buf1); //人物等级 + + sprintf( dData, "%s,%s,%s,%d\n", + StartS, PkTeamList[count].MyTeamMans[ManNum].cdkey, + PkTeamList[count].MyTeamMans[ManNum].name, leve ); + +// strcat( dData, buf2); + + fprintf( tfp, "%s", dData); + + PkTeamList[count].MyTeamMans[ManNum].use = 1; + ManNum++; + if( ManNum>=MAXTEAMMANNUM )break; + } + if( ManNum == 0 ){ + fprintf( bfp, "%s\n", line); + continue; + } + + + sprintf( PkTeamList[count].pathdir, "0x%x", getHash( PkTeamList[count].MyTeamMans[0].cdkey )&0xff); + sprintf( PkTeamList[count].leadercdkey, "%s", PkTeamList[count].MyTeamMans[0].cdkey ); + PkTeamList[count].win = 0; + PkTeamList[count].lost = 0; + PkTeamList[count].battleplay = 0; + PkTeamList[count].score = 0; + PkTeamList[count].inside = 1; + PkTeamList[count].updata = 0; + + PkTeamList[count].use = 1; + count++; + } + fclose( bfp); + fclose( tfp); + fclose( fp); + //清除 + sprintf( filename, "%s/%s", dirpath, listfilename); + remove( filename); + + { + int k; + log( "\n"); + for( i=0; i=0; k-- ){ + if( PkTeamList[i].score <= 0 ) continue; + if( PKListSort[k] == -1 ){ + last = k; + continue; + } + if( PkTeamList[i].score > PkTeamList[PKListSort[k]].score ){ + last = k; + continue; + }else if( PkTeamList[i].score == PkTeamList[PKListSort[k]].score ){ + if( PkTeamList[i].updata < PkTeamList[PKListSort[k]].updata ){ + last = k; + continue; + }else{ + continue; + } + } + break; + } + if( last == -1 ) continue; + for( j=548; j>=last; j-- ){ + PKListSort[j+1] = PKListSort[j]; + } + PKListSort[last]=i; + } +} + + +void PKLIST_CheckAllUser( void) +{ + int i, k; + FILE *fp=NULL, *ffp=NULL; + char output[CHARDATASIZE], buf1[256]; + + + if( (fp=fopen( "checkuser.txt", "w+")) == NULL ) return; + if( (ffp=fopen( "checkteam.txt", "w+")) == NULL ) return; + log( "PKLIST_CheckAllUser()\n"); + + for( i=0; i%s\n", + i, PkTeamList[i].teamname, PkTeamList[i].teamnum, + PkTeamList[i].MyTeamMans[k].cdkey, PkTeamList[i].MyTeamMans[k].name, + buf1 ); + snprintf( PkTeamList[i].MyTeamMans[k].name, sizeof(PkTeamList[i].MyTeamMans[k].name), + "%s", buf1); + } + } + } + } + fclose( fp); + fclose( ffp); +} +/* +序号|队名|帐号_人物名|帐号_人物名|帐号_人物名|帐号_人物名|帐号_人物名|胜|败|0 + +#序号|目录|队名|帐号_人物名|胜|败|场|积分|0 + +1|0x10|第1队|cdkey|胜|败|场|积分|0 +2|0x10|第2队|cdkey|胜|败|场|积分|0 +3|0x10|第3队|cdkey|胜|败|场|积分|0 +4|0x10|第4队|cdkey|胜|败|场|积分|0 +5|0x10|第5队|cdkey|胜|败|场|积分|0 +6|0x10|第6队|cdkey|胜|败|场|积分|0 +7|0x10|第7队|cdkey|胜|败|场|积分|0 +8|0x10|第8队|cdkey|胜|败|场|积分|0 +9|0x10|第9队|cdkey|胜|败|场|积分|0 +10|0x10|第10队|cdkey|胜|败|场|积分|0 +*/ +#endif diff --git a/saac/deathcontend.h b/saac/deathcontend.h new file mode 100644 index 0000000..8a699a9 --- /dev/null +++ b/saac/deathcontend.h @@ -0,0 +1,73 @@ +#include "version.h" + +#ifdef _DEATH_CONTEND +//团队人物名单 +typedef struct +{ + int use; + char cdkey[64]; + char name[64]; +}PkTeamMans; +//战斗纪录 +typedef struct +{ + int use; + int teamnum; + int flg; //0 1 +}BattleHistorys; + +#define MAXTEAMMANNUM 5 //队伍最高人数 +#define MAXBATTLENUM 100 //队伍最高战斗纪录 + +#define DEFMAXBATTLENUM 50 //最高决斗场次 +#define DEFWINSCORE 90 +#define DEFLOSERATE 0.4 +//决斗参赛队伍info +typedef struct _tagPkTeamLists +{ + int use; //flg + int teamnum; //队伍序号 + char teamname[64]; //队伍名称 + char pathdir[64]; //队伍资料目录 + char leadercdkey[64]; //队长CDKEY + int win; //胜 + int lost; //负 + int battleplay; //总场次 + int score; + int inside; //录取旗标 + + int updata; //更新时间 + + PkTeamMans MyTeamMans[MAXTEAMMANNUM]; + BattleHistorys BHistory[MAXBATTLENUM]; +}PkTeamLists; + +//勿动------------------------------------------------------- +int PKLIST_getStringPkTeamData( int ti, char *data, int sizes); +int PKLIST_SetOneBHistory( int ti, int hi, int use, int teamnum, int flg ); +int PKLIST_GetOneBHistory( int ti ); +void PKLIST_ResetOneTeamMan( int ti ); +void PKLIST_ResetOneBHistory( int ti ); +void PKLIST_ResetOnePkTeamList( int ti ); +int PKLIST_UpdateOnePkTeamData( int ti, int forti, int winerflg); +//----------------------------------------------------------- +int PKLIST_InitPkTeamList( int maxteam ); +void PKLIST_UpdatePkTeamList( int fd, int menum, char *mecdkey, int tonum, char *tocdkey, int winer, int flg); +void PKLIST_GetPkTeamListData( int fd, int startTi, int count); +void PKLIST_GetPkTeamListDataOne( int fd, int ti); +//----------------------------------------------------------- +int PKLIST_LoadPkTeamListfromFile( char *dirpath, char *listfilename ); +int PKLIST_BackupPkTeamListfromFile( char *dirpath, char *listfilename ); +void PKLIST_SortTheCharts( int ti);//排行榜处理 +void PKLIST_TheCharts( int fd, int type, int flg); + +int PKLIST_LoadUserfromFile( char *dirpath, char *listfilename ); +int PKLIST_CutStartUserfromFile( char *dirpath, char *listfilename ); + +void PKLIST_CheckRepeatBattleHistory( void); +int PKLIST_alteUserfromFile( char *dirpath, char *listfilename ); +void PKLIST_Sort_PKListSort( void); + +void PKLIST_CheckAllUser( void); + +#endif diff --git a/saac/defend.c b/saac/defend.c new file mode 100644 index 0000000..d0529ba --- /dev/null +++ b/saac/defend.c @@ -0,0 +1,415 @@ +#include "version.h" +#include +#include +#include +#include + +#include "saacproto_serv.h" +#include "main.h" +#include "char.h" +#include "util.h" +#include "defend.h" + +#ifdef _DEFEND_NEWUSERS +extern gmsv gs[MAXCONNECTION]; + +#define DEFEND_FILENAME "db/defend/defend.txt" +#define SCORE_FILENAME "db/defend/score.txt" + +DefendArrayList *DEFENDUserList = NULL; +ScoreArrayList *DEFENDScoreList = NULL; + +static int DEFEND_MAXSCORE = 0; +static int DEFEND_MINSCORE = 0; +void DEFEND_InitList() +{ + log("DEFEND_InitList( %d) - %4.2f KB.. \n", DEFEND_MAXLISTS, + (float)(sizeof( struct _tagDefendArrayList)*DEFEND_MAXLISTS)/1024 ); + + DEFENDUserList = (DefendArrayList*)calloc( 1, sizeof( struct _tagDefendArrayList)*DEFEND_MAXLISTS); + + if( DEFENDUserList == NULL ){ + log("Can't calloc sizeof(%4.2fKB.)err !!\n", + (float)(sizeof( struct _tagDefendArrayList)*DEFEND_MAXLISTS)/1024 ); + return; + } + + DEFENDScoreList = (ScoreArrayList*)calloc( 1, sizeof( struct _tagScoreArrayList)*DEFEND_SCOREMAXLISTS); + if( DEFENDScoreList == NULL ){ + log("Can't calloc sizeof(%4.2fKB.)err !!\n", + (float)(sizeof( struct _tagDefendArrayList)*DEFEND_SCOREMAXLISTS)/1024 ); + return; + } + + DEFEND_resetUserForList(); + DEFEND_ReadUserForList( DEFEND_FILENAME); + DEFEND_resetScoreForList(); + DEFEND_ReadScoreForList( SCORE_FILENAME); +} + +int DEFEND_getUse( int si) +{ + if( si >= DEFEND_MAXLISTS || si < 0 ) return -1; + return DEFENDUserList[ si].use; +} + +int DEFEND_setUse( int si, int num) +{ + int olds; + if( si >= DEFEND_MAXLISTS || si < 0 ) return -1; + olds = DEFENDUserList[ si].use; + DEFENDUserList[ si].use = num; + return olds; +} + +void DEFEND_resetUserForList() +{ + int i; + for( i=0; i 0 ){ + DEFEND_delOneUserForList( j); + } + continue; + } + DEFEND_copyOneUserForList( j, j+1); + } + } + } + for( i=0; i= DEFEND_MAXLISTS ) return -1; + ti = i; + + for( i=(DEFEND_MAXLISTS-1); i>ti; i--){ + if( DEFEND_getUse( i-1) <= 0 ) continue; + DEFEND_copyOneUserForList( i, i-1); + } + + memcpy( DEFENDUserList[ ti].cdkey, cdkey, sizeof( DEFENDUserList[ ti].cdkey) ); + memcpy( DEFENDUserList[ ti].name, name, sizeof( DEFENDUserList[ ti].name) ); + DEFENDUserList[ ti].defnums = nums; //次数 + DEFENDUserList[ ti].type = type; + DEFENDUserList[ ti].score = score; + DEFENDUserList[ ti].use = 1; + return ti; +} + +void DEFEND_LoadUserForList( char *listarg) +{ + char buf2[256]; + char cdkey[256], name[256]; + int type, nums, score; + + easyGetTokenFromBuf( listarg, ',', 1, buf2, sizeof(buf2)); + memcpy( cdkey, buf2, sizeof( cdkey)); + easyGetTokenFromBuf( listarg, ',', 2, buf2, sizeof(buf2)); + memcpy( name, buf2, sizeof( name)); + easyGetTokenFromBuf( listarg, ',', 3, buf2, sizeof(buf2)); + nums = atoi( buf2); + easyGetTokenFromBuf( listarg, ',', 4, buf2, sizeof(buf2)); + score = atoi( buf2); + easyGetTokenFromBuf( listarg, ',', 5, buf2, sizeof(buf2)); + type = atoi( buf2); + + if( DEFEND_addUserForList( cdkey, name, score, nums, type) != -1 ){ + DEFEND_ShowUserLists(); + DEFEND_SendToUserLists(); + } +} + +void DEFEND_ReadUserForList( char *filename) +{ + FILE *fp=NULL; + char buf1[256], buf2[256]; + char cdkey[256], name[256]; + int type, nums, score; + fp = fopen( filename, "r"); + if( fp == NULL ){ + log( "Can't Read %s..!\n", filename); + return; + } + + while( fgets( buf1 , sizeof( buf1 ) , fp )){ + easyGetTokenFromBuf( buf1, ',', 1, buf2, sizeof(buf2)); + memcpy( cdkey, buf2, sizeof( cdkey)); + easyGetTokenFromBuf( buf1, ',', 2, buf2, sizeof(buf2)); + memcpy( name, buf2, sizeof( name)); + easyGetTokenFromBuf( buf1, ',', 3, buf2, sizeof(buf2)); + nums = atoi( buf2); + easyGetTokenFromBuf( buf1, ',', 4, buf2, sizeof(buf2)); + score = atoi( buf2); + easyGetTokenFromBuf( buf1, ',', 5, buf2, sizeof(buf2)); + type = atoi( buf2); + + DEFEND_addUserForList( cdkey, name, score, nums, type); + } + fclose( fp); + DEFEND_ShowUserLists(); +} + +void DEFEND_ShowUserLists() +{ + int i; + if( DEFENDUserList == NULL ) return; + for( i=0; i= DEFEND_SCOREMAXLISTS || si < 0 ) return -1; + return DEFENDScoreList[ si].use; +} + +void DEFEND_ReadScoreForList( char *filename) +{ + FILE *fp=NULL; + char buf1[256], buf2[256]; + char cdkey[256], name[256], fromname[256]; + int score; + fp = fopen( filename, "r"); + if( fp == NULL ){ + log( "Can't Read %s..!\n", filename); + return; + } + + while( fgets( buf1 , sizeof( buf1 ) , fp )){ + int i; + if( strlen(buf1) < 1 || strlen(buf1) > 512 ) continue; + for( i=0; i +#include +#include "lock.h" +#include "main.h" +#include "char.h" + +#ifdef _WORKER_AUTO_LOGOUT // WON ADD GS断线自动送LOGOUT给WORKER +#include "recv.h" +#endif + +LockNode **userlock; + +#ifdef _UNLOCKPOOL +#define UNLOCKPOOLNUM 2000 +UnlockPoolNode UnlockPool[UNLOCKPOOLNUM]; +int iUnlockPoolAdd =0; +//int iUnlockPoolClean =0; +#endif + +void Lock_Init(void) +{ + int i; + userlock= (LockNode **) calloc( 1, sizeof(LockNode *) * 256); + memset(userlock, 0, sizeof(userlock)); + for (i=0; i<256; i++) { + userlock[i] = (LockNode *)calloc( 1,sizeof(LockNode)); + userlock[i]->use=0; + userlock[i]->next=NULL; + userlock[i]->prev=NULL; + memset( userlock[i]->cdkey, 0, sizeof( userlock[i]->cdkey) ); + memset( userlock[i]->server, 0, sizeof( userlock[i]->server) ); +#ifdef _LOCK_ADD_NAME + memset( userlock[i]->name, 0, sizeof( userlock[i]->name) ); +#endif + } + log("存贮器初始化"); +} + +LockNode *Creat_newNodes( void) +{ + LockNode *newln=NULL; + newln = ( LockNode *)calloc( 1, sizeof( LockNode) ); + if( newln == NULL ){ + log( "err Can't calloc:%d lock nodes !!\n", sizeof(LockNode)); + return 0; + } + newln->use=0; + newln->next=NULL; + memset( newln->cdkey, 0, sizeof( newln->cdkey) ); + memset( newln->server, 0, sizeof( newln->server) ); +#ifdef _LOCK_ADD_NAME + memset( newln->name, 0, sizeof( newln->name) ); +#endif + return newln; +} + +#ifdef _LOCK_ADD_NAME +int InsertMemLock(int entry, char *cdkey,char *name, char *passwd, char *server, int process, char *deadline) +#else +int InsertMemLock(int entry, char *cdkey, char *passwd, char *server, int process, char *deadline) +#endif +{ + int j; + LockNode *ln = userlock[entry]; +#ifdef _LOCK_ADD_NAME + log("进入游戏:目录:char/0x%x 账号:%s 名称:%s 服务器:%s\n", entry, cdkey, name, server); +#else + log("进入游戏:目录:%x 账号:%s 服务器:%s\n", entry, cdkey, server); +#endif + + while( (ln!=NULL) && (ln->use!=0)) ln=ln->next; + + if( ln == NULL ) { + LockNode *fhead=NULL; + LockNode *p = userlock[entry]; + log("Add more lock nodes.\n"); + while (p->next!=NULL) p=p->next; + fhead = p; + for( j=0; j<32; j++) { // allocate more nodes + if( (ln = Creat_newNodes() ) == NULL ) return 0; + ln->prev=p; + p->next=ln; + p=ln; + } + while( (fhead!=NULL) && (fhead->use!=0)) fhead=fhead->next; + ln = fhead; + } + + if( ln->use !=0 ) return 0; + ln->use = 1; + strcpy( ln->cdkey, cdkey); + strcpy( ln->server, server); +#ifdef _LOCK_ADD_NAME + strcpy( ln->name, name); +#endif + ln->process = process; +#ifdef _TIMEOUTKICK + strcpy( ln->passwd, passwd); + strcpy( ln->deadline, deadline); +#endif + return 1; +} + +int DeleteMemLock(int entry, char *cdkey, int *process) +{ + LockNode *ln = userlock[entry]; + + log("删除内存信息 位置=%x 账号=%s ..\n", entry, cdkey); + + while (ln!=NULL) { + if( ln->use != 0) { +#ifdef _CHANGEGALAXY + if( !strcmp( ln->cdkey, cdkey ) && strcmp( ln->server, "移民") ) break; +#else + if( strcmp( ln->cdkey, cdkey ) == 0 ) break; +#endif + } + ln=ln->next; + } + if( ln != NULL ) { + ln->use=0; + memset( ln->cdkey, 0, sizeof( ln->cdkey) ); + memset( ln->server, 0, sizeof( ln->server) ); +#ifdef _LOCK_ADD_NAME + memset( ln->name, 0, sizeof( ln->name) ); +#endif + *process = ln->process; + log("删除成功\n"); + return 1; + } + log("删除失败!!\n"); + return 0; +} + +void DeleteMemLockServer(char *sname) +{ + int i; + LockNode *ln; + for (i=0; i<256; i++) { + ln = userlock[i]; + while (ln!=NULL) { + if (ln->use != 0) { + if( strcmp( ln->server, sname)==0) { + ln->use=0; + } + } + ln=ln->next; + } + } +} + + +#ifdef _WORKER_AUTO_LOGOUT // WON ADD GS断线自动送LOGOUT给WORKER +void Worker_auto_logout(int ti, char *sname) +{ + int i; + LockNode *ln; + + log("\nGMSV 退出或工作站退出!! \n"); + + for (i=0; i<256; i++) { + ln = userlock[i]; + while (ln!=NULL) { + if (ln->use != 0) { + if (strcmp(ln->server, sname)==0) { +#if 0 + if( addUnlockPool( ti, ln->cdkey, "", "", "") <0 ) { + char id[20]; + strcpy(id ,ln->cdkey); + log("工作站发送退出 ==> ti(%d) 账号(%s) 序号(%d)\n", ti, id, iUnlockPoolAdd ); + Worker_send_logout(ti, id); + } +#else + char id[20]; + strcpy(id ,ln->cdkey); + log("工作站发送退出==>ti(%d) 账号(%s)\n", ti, id ); + Worker_send_logout(ti, id); +#endif + } + } + ln=ln->next; + } + } +} +#endif + + + + +int isMemLocked(int entry, char *cdkey) +{ + LockNode *ln = userlock[entry]; + while (ln!=NULL) { + if (ln->use != 0) { + if (strcmp(ln->cdkey, cdkey)==0) { + if( !strcmp(ln->server, "星系移民")) + log(" 星系移民中 "); + break; + } + } + ln=ln->next; + } + if (ln!=NULL) return 1; else return 0; +} + +int GetMemLockState(int entry, char *cdkey, char *result) +{ + LockNode *ln = userlock[entry]; + + while (ln!=NULL) { + if (ln->use != 0) { + if (strcmp(ln->cdkey, cdkey)==0) { + sprintf(result, "%s 是在 %s 被锁的.",cdkey, ln->server); + return 1; + } + } + ln=ln->next; + } + sprintf(result, "%s 没有被锁.", cdkey); + return 0; +} + +int GetMemLockServer(int entry, char *cdkey, char *result) +{ + LockNode *ln = userlock[entry]; + while (ln!=NULL) { + if (ln->use != 0) { + if (strcmp(ln->cdkey, cdkey)==0) { + strcpy(result, ln->server); + return 1; + } + } + ln=ln->next; + } + return 0; +} + +int LockNode_getGname( int entries, char *id, char *gname) +{ + LockNode *ln = userlock[entries]; + while (ln!=NULL) { + if (ln->use != 0) { + if( !strcmp(ln->cdkey, id) ){ + sprintf( gname,"%s", ln->server ); + return 1; + } + } + ln=ln->next; + } + return 0; +} + +#ifdef _CHANGEGALAXY + +int DeleteGalaxyChangeLock( void) +{ + int count =0; + int entry =0; + + log(" DeleteGalaxyChangeLock "); + + for( entry =0; entry <256; entry++) { + + LockNode *ln = userlock[entry]; + + while (ln!=NULL) { + if( ln->use != 0) { + if( strcmp( ln->server, "星系移民" ) == 0 ) { + ln->use=0; + memset( ln->cdkey, 0, sizeof( ln->cdkey) ); + memset( ln->server, 0, sizeof( ln->server) ); +#ifdef _LOCK_ADD_NAME + memset( ln->name, 0, sizeof( ln->name) ); +#endif + //*process = ln->process; + count++; + } + } + ln=ln->next; + } + } + + log("num=%d ", count); + + return count; +} + + +int isChangeGalaxyLocked( char *cdkey) +{ + LockNode *ln; + int entry; + + if (!cdkey[0]) return 1; // invalid id: lock it + + entry = getHash(cdkey) & 0xff; + ln = userlock[entry]; + + while (ln!=NULL) { + if (ln->use != 0) { + if( !strcmp(ln->cdkey, cdkey) && !strcmp(ln->server, "星系移民") ) { + log(" 星系移民中 "); + break; + } + } + ln=ln->next; + } + if (ln!=NULL) return 1; else return 0; +} + +#endif + + +#ifdef _TIMEOUTKICK +int ChangeMemDeadline(int entry, char *cdkey, char *deadline) +{ + + LockNode *ln = userlock[entry]; + while (ln!=NULL) { + if (ln->use != 0) { + if (strcmp(ln->cdkey, cdkey)==0) { + log(" 修改Deadline "); + strcpy( ln->deadline, deadline); + break; + } + } + ln=ln->next; + } + if (ln!=NULL) return 1; else return 0; +} +#endif + +#ifdef _UNLOCKPOOL +void UnlockPoolProc( void) +{ + static int unlockindex =0; + static time_t lastcheck =0; + int cleanCount =0; + + + if( sys_time < lastcheck + 3 ) // 每xx秒检查 + return; + lastcheck = sys_time; + + //log("\n Start send UnlockPool to worker!! "); + + //while( UnlockPool[unlockindex].use ) { + for( unlockindex =0; unlockindex =30) // 每次最多送X个logout + // break; + } + } + + // 一次全清归零 + iUnlockPoolAdd =0; + unlockindex =0; + + log("\n Unlockpool send Count:%d index:%d", cleanCount, unlockindex); + +} + + +int addUnlockPool( int serverindex, char *cdkey, char *charname, char *process, int mesgid) +{ + int i =0; + + while( UnlockPool[iUnlockPoolAdd].use ) { + iUnlockPoolAdd++; + iUnlockPoolAdd = iUnlockPoolAdd % UNLOCKPOOLNUM; + + i++; + if( i >= UNLOCKPOOLNUM ) { + log(" UnlockPool_FULL!!!!:%d ", iUnlockPoolAdd); + return -1; + } + } + + UnlockPool[iUnlockPoolAdd].use = 1; + UnlockPool[iUnlockPoolAdd].serverindex = serverindex; + strcpy( UnlockPool[iUnlockPoolAdd].cdkey, cdkey); + strcpy( UnlockPool[iUnlockPoolAdd].charname, charname); + strcpy( UnlockPool[iUnlockPoolAdd].process, process); + UnlockPool[iUnlockPoolAdd].mesgid = mesgid; + + log("\n add_UnlockPool:i(%d),si(%d),cdkey(%s)", iUnlockPoolAdd, serverindex, UnlockPool[iUnlockPoolAdd].cdkey ); + + iUnlockPoolAdd++; + iUnlockPoolAdd = iUnlockPoolAdd % UNLOCKPOOLNUM; + + return 0; +} + +void init_UnlockPool( void) +{ + int i; + for( i =0; i < UNLOCKPOOLNUM; i++) + memset( &(UnlockPool[i]), '\0', sizeof( UnlockPoolNode) ); +} + +int inUnlockPool( char* cdkey) +{ + int i; + for( i=0; i +#include +#include +#include +#include +#include + +typedef enum +{ + MS_NOUSE = 0, + MS_NEWMESSAGE, + MS_WAIT_ACK, +} MAILSTATE; + +#define TEXT_MAX 1024 +struct mail +{ + int use; + unsigned int id_charname_hash; + char id_to[USERID_MAX]; + char charname_to[CHARNAME_MAX]; + char id_from[USERID_MAX]; + char charname_from[CHARNAME_MAX]; + char text[TEXT_MAX]; + int option; + unsigned int message_id; + MAILSTATE state; + time_t recv_time; +}; + +struct mail *mailbuf; +int mailbufsize = 0; + + +static unsigned int +getNextMessageID(void) +{ + FILE *fp; + unsigned int i; + char filename[1024]; + char line[1000]; + snprintf( filename, sizeof( filename ), + "%s/mail_id" , maildir ); + fp = fopen( filename, "r" ); + if( fp == NULL ){ + fp = fopen( filename ,"w" ); + if( fp == NULL ){ + log( "不能创建 %s ... 使用同样的邮件ID," + " saac 发送变得缓慢!(id:9999)\n", filename ); + return 9999; + } + fprintf( fp, "10000\n" ); + fclose(fp); + return 1000; + } + fgets( line, sizeof(line), fp); + i = strtoul( line, NULL, 10 ); + fclose(fp); + + fp = fopen( filename, "w" ); + if( fp == NULL ){ + log( "不能写入新的ID到 %s ... 使用同样的数字!\n", filename ); + return i; + } + fprintf( fp, "%u", i+1 ); + fclose(fp); + + log( "新邮件ID:%u\n", i); + return i; +} + +static int reallocMailBuf( void ) +{ + struct mail *previous = mailbuf; + struct mail *newbuf; + int new_mailbufsize; + if( mailbufsize == 0 ){ + new_mailbufsize = 1; + } else { + new_mailbufsize = mailbufsize * 2; + } + + newbuf = ( struct mail * )calloc( 1, new_mailbufsize * + sizeof( struct mail )); + if( newbuf == NULL ){ + log( "回复邮件缓冲: 内件不足!! 新邮件大小:%d\n", + new_mailbufsize ); + return -1; + } + memset( newbuf, 0 , new_mailbufsize * sizeof( struct mail )); + if( previous ) memcpy( (char*)newbuf, (char*)previous, + mailbufsize * sizeof( struct mail )); + free( previous ); + mailbufsize = new_mailbufsize; + mailbuf = newbuf; + + log( "重新分配邮件缓冲: " + "新邮件缓冲:%d 旧地址:%x 新地址:%x\n", + new_mailbufsize, (unsigned int)previous,(unsigned int)newbuf ); + return 0; +} + +static int mailbuf_finder = 0; +static int allocMail( int use_msgid, unsigned int msgid ) +{ + int i; + for(i=0;i + mailbuf[flush_index[j+1]].message_id ){ + int sw = flush_index[j]; + flush_index[j] = flush_index[j+1]; + flush_index[j+1] = sw; + log( "inverted %d and %d in %d \n", flush_index[j], + flush_index[j+1], j ); + } + } + } + + /* 端卞霜耨允月 */ + for(i=0;i< flush_i; i++ ){ + /* flush 及桦宁反}flush毛霜耨仄化五凶必□丞扔□田□卞 + 覆仄化分仃霜耨允木壬中中 */ + saacproto_Message_send( fd, + mailbuf[flush_index[i]].id_from, + mailbuf[flush_index[i]].charname_from, + mailbuf[flush_index[i]].id_to, + mailbuf[flush_index[i]].charname_to, + mailbuf[flush_index[i]].text, + mailbuf[flush_index[i]].option, + mailbuf[flush_index[i]].message_id ); + mailbuf[flush_index[i]].state = MS_WAIT_ACK; + log( "分类邮件ID:%u\n", + mailbuf[flush_index[i]].message_id ); + } + // Nuke *1 + log( "邮件: 发送 %d 封邮件到 %s(%s)(%s)\n", c, id, charname ,chartime()); +} + +// Nuke start: To expire undelivered mail +#define MAIL_EXPIRE_TIME 3600 +void +expireMail() +{ + int i,c=0; + unsigned int h ; + char id_charname[1000]; + time_t now=time(NULL); + + /* 1荚及flush 匹霜耨允月 醒 */ +#define MAX_FLUSH_MAIL 1024 + int flush_index[MAX_FLUSH_MAIL]; + int flush_i=0; + // Nuke +1 + log("邮件缓冲大小:%d (%s)\n",mailbufsize,chartime()); + // Nuke *1 + for(i=0;(i= MAIL_EXPIRE_TIME)) { + log( "消息ID:%u 已过期\n", mailbuf[i].message_id ); + flush_index[flush_i++] = i; + c++; + } + } + + /* 端卞霜耨允月 */ + for(i=0;i< flush_i; i++ ){ + + snprintf( id_charname, sizeof( id_charname), "%s_%s", + mailbuf[flush_index[i]].id_to, + mailbuf[flush_index[i]].charname_to ); + h = hashpjw( id_charname ) & 0xff ; + { + char savefile[1024]; + char childname[1000]; + snprintf( childname,sizeof(childname),"%u", + mailbuf[flush_index[i]].message_id ); + makeDirFilename( savefile, sizeof(savefile),maildir, + h, childname ); + if( unlink( savefile ) != 0 ){ + log( "failed to unlink %s: %s\n", + savefile, strerror(errno )); + } else { + log( "过期邮件: 删除游戏 " + "%u 从 %s(%s) 到 %s(%s)\n", + mailbuf[flush_index[i]].message_id, + mailbuf[flush_index[i]].id_from, + mailbuf[flush_index[i]].charname_from, + mailbuf[flush_index[i]].id_to, + mailbuf[flush_index[i]].charname_to ); + } + memset( &mailbuf[flush_index[i]], 0 , sizeof( mailbuf[0] )); + } + } + // Nuke *1 + log( "过期邮件: 过期 %d 消息 (%s)\n", c ,chartime()); +} + +int readMail( char *dir ) +{ + int i, read_count=0; + for( i=0; i<256; i++){ + char dirname[1000]; + DIR *d; + + snprintf(dirname, sizeof( dirname ), "%s/0x%x", dir, i ); + d = opendir(dirname); + if(d == NULL ){ + mkdir( dirname, 0755); + log("创建 %s\n", dirname); + continue; + } + while(1){ + struct dirent *de; + de = readdir( d ); + if( de == NULL )break; + if( de->d_name[0] != '.' ){ + char filename[1000]; + FILE *fp; + struct stat s; + snprintf( filename, sizeof( filename), + "%s/%s", dirname, de->d_name ); + if( stat( filename, &s ) < 0 ){ + continue; + } + if( !(s.st_mode & S_IFREG)) continue; + fp = fopen( filename, "r" ); + if( fp == NULL ){ + log( "不能打开文件 %s %s\n",filename,strerror(errno)); + continue; + } + { + char line[16384]; + char toid[1000] , fromid[1000]; + char tochar[CHARNAME_MAX*2+1]; + char fromchar[CHARNAME_MAX*2+1]; + char text[TEXT_MAX*2+1]; + int opt=0; + toid[0] = fromid[0] = tochar[0] = + fromchar[0] = text[0] = 0; + fgets( line, sizeof(line), fp ); + chop(line); + if( strncmp( TO_ID_HEAD , line, strlen(TO_ID_HEAD) )==0){ + snprintf( toid , sizeof( toid ),"%s", + line+strlen(TO_ID_HEAD )); + } + fgets( line, sizeof( line ), fp ); + chop(line); + if( strncmp( TO_CHAR_HEAD, line,strlen(TO_CHAR_HEAD))==0){ + snprintf( tochar, sizeof( tochar ), "%s", + line+strlen( TO_CHAR_HEAD )); + makeStringFromEscaped( tochar ); + } + fgets( line, sizeof( line ),fp ); + chop(line); + if( strncmp( FROM_ID_HEAD,line,strlen(FROM_ID_HEAD))==0){ + snprintf( fromid, sizeof( fromid ),"%s", + line + strlen( FROM_ID_HEAD )); + } + fgets( line,sizeof(line),fp); + chop(line); + if(strncmp(FROM_CHAR_HEAD,line,strlen(FROM_CHAR_HEAD))==0){ + snprintf( fromchar, sizeof( fromchar ), + line + strlen(FROM_CHAR_HEAD )); + makeStringFromEscaped( fromchar ); + } + fgets( line,sizeof(line),fp); + chop(line); + if( strncmp( OPTION_HEAD,line, strlen(OPTION_HEAD))==0){ + opt = atoi( line + strlen( OPTION_HEAD ) ); + } + fgets( line, sizeof( line),fp); + chop(line); + if( strncmp(TEXT_HEAD,line,strlen(TEXT_HEAD))==0){ + snprintf( text, sizeof( text), "%s", + line + strlen( TEXT_HEAD )); + makeStringFromEscaped( text ); + } + if( toid[0] == 0 || fromid[0] == 0 || + tochar[0] == 0 || fromchar[0] == 0 || + text[0] == 0 ){ + log( "有问题邮件! %s 接收ID[%c] 接收名字[%c]" + " 发送ID[%c] 发送名字[%c] 文本[%c]\n", + filename, + toid[0], tochar[0], fromid[0], fromchar[0], + text[0] ); + // Nuke +1 1027: Close for safe + fclose(fp); + continue; + } + receiveMail( fromid, fromchar, + toid, tochar, + text, opt , 1, + strtoul(de->d_name,NULL,10)); + read_count++; + } + fclose(fp); + + } + } + closedir(d); + } + log( "读取邮件: 在'%s'目录里读取到 %d 封邮件 \n", dir, read_count ); + return 0; +} diff --git a/saac/mail.h b/saac/mail.h new file mode 100644 index 0000000..94b93bf --- /dev/null +++ b/saac/mail.h @@ -0,0 +1,13 @@ +#ifndef _MAIL_H_ +#define _MAIL_H_ + +void receiveMail( char *id_from, char *charname_from, + char *id_to, char *charname_to, char *message, int option , + int use_msgid, unsigned int msgid ); +void receiveMailAck( char *id, char *charname, int a , int mesgid ); +void flushMail( int fd, char *id, char *charname ); +void expireMail(); +int readMail( char *dir ); +#endif + + diff --git a/saac/main.c b/saac/main.c new file mode 100644 index 0000000..255b17b --- /dev/null +++ b/saac/main.c @@ -0,0 +1,2169 @@ +#define _MAIN_C_ + +#ifdef _SASQL1 +#include "sasql.h" +#endif + + +#include "main.h" +#include "util.h" +#include "mail.h" +#include "db.h" +#include "saacproto_util.h" +#include "saacproto_serv.h" +#ifdef _UNIVERSE_CHATROOM +#include "chatroom.h" +#endif +// CoolFish: Family 2001/5/9 +#include "acfamily.h" +#include "version.h" + +#ifdef _DEATH_CONTEND +#include "deathcontend.h" +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "saacproto_work.h" +#ifdef _OACSTRUCT_TCP +#include "saacproto_oac.h" +#endif +#ifdef _PAUCTION_MAN +#include "auction.h" +#endif +#include "lock.h" +#define BACKLOGNUM 5 + + +#ifdef _FIX_WORKS +#include "saacproto_work.h" +int worksockfd; +#endif + +#ifdef _LOCK_SERVER +#include "saacproto_lserver.h" +#endif + +#ifdef _SEND_EFFECT // WON ADD 送下雪、下雨等特效 +#include "recv.h" +#endif + +#include "defend.h" + +#include "char.h" + +#ifdef _SASQL +#include "sasql.h" +#endif + +#ifndef _FIX_WORKS + +struct membuf +{ + int use; + char buf[512]; +// char buf[1024*128]; + int len; + int next; +}; + +struct connection +{ + int use; + int fd; + int mbtop_ri; + int mbtop_wi; + struct sockaddr_in remoteaddr; + int closed_by_remote; +}; +#else +#endif + +struct membuf *mb; +int mbsize; +int mbuse ; + +int mainsockfd; /* accept 及 域娄醒卞中木月 */ +struct sockaddr_in localaddr; /* bind 允月失玉伊旦 */ + + +struct connection *con; /* 戊生弁扑亦件 */ + +static int mb_finder=0; /* mb及坞五毛腹绸允月凶户及 + 腹绸玄永皿及匏 筏盛迕 */ +// WON FIX +char tmpbuf[65536]; +//char tmpbuf[65536*3]; /* read迕 */ + +struct timeval select_timeout; + +time_t sys_time =0; // Robin add + +extern gmsv gs[MAXCONNECTION]; + +int tcpstruct_init( char *addr, int port, int timeout_ms, int mem_use, int deb); +int tcpstruct_accept1( void ); +int tcpstruct_accept( int *tis , int ticount ); +int tcpstruct_close( int ti ); +int tcpstruct_read( int ti , char *buf , int len ); +int tcpstruct_readline( int ti , char *buf , int len ,int k ,int r); +int tcpstruct_readline_chop( int ti , char *buf, int len ); +int tcpstruct_write( int ti , char *buf , int len ); +int tcpstruct_countmbuse( void ); +int tcpstruct_connect( char *addr , int port ); +#ifndef _FIX_WORKS +void set_nodelay( int sock ); + + +#define OK 0 /* 岳 */ +#define TCPSTRUCT_ENOMEM -1 /* malloc 撩 */ +#define TCPSTRUCT_ESOCK -2 /* socket 撩 */ +#define TCPSTRUCT_EBIND -3 /* bind 撩 */ +#define TCPSTRUCT_ELISTEN -4 /* listen 撩 */ +#define TCPSTRUCT_EBUG -6 /* 田弘匹丐月 */ +#define TCPSTRUCT_EINVCIND -7 /* con尺及index互云井仄中方 */ +#define TCPSTRUCT_EREADFIN -8 /* read 允月犯□正互卅仁化 closed by remote */ +#define TCPSTRUCT_EHOST -9 /* gethostbyname 撩 */ +#define TCPSTRUCT_ECONNECT -10 /* connect 撩 */ +#define TCPSTRUCT_ECFULL -11 /* con 互中匀天中 */ +#define TCPSTRUCT_ETOOLONG -12 /* 垫互卅互允亢 */ +#define TCPSTRUCT_EMBFULL -13 /* mb 互中匀天中 */ +#define TCPSTRUCT_ECLOSEAGAIN -14 /* close 互2荚今木凶 */ +#endif + + +int port; /* 必□丞扔□田□互涛粮仄化仁月禾□玄 */ +int Total_Charlist; +int Expired_mail; +int Del_Family_or_Member; +int Write_Family; +#ifdef _NEW_PLAYERGOLD +int New_PlayerGold; +#endif + +// Nuke start +char *chartime() +{ + static char buf[80]; + time_t t; + t=time(0); + strcpy(buf,ctime(&t)); + buf[strlen(buf)-1]=0; + return(buf); +} + +/* + sigaction白弁 + */ +void sighandle( int a ) +{ + if (a==SIGUSR1) log("sigusr1信号!\n"); + + if (a==SIGUSR2) { + sigusr2( a); + log("sigusr2信号!\n"); + return; + } + #ifdef _SQL_BACKGROUND + if(!sasql_initonline()) + log("\n数据库保存失败!\n"); + #endif + log("得到一个信号! 异常中断......\n" ); + exit(1); +} + +void sigusr2(int a); + +// Arminius 7.20 memory unlock +void sigusr1(int a) +{ + int i; + FILE *f; + char key[4096],buf[4096]; + + signal(SIGUSR1, sigusr1); + + f = fopen("./unlock.arg", "r"); + + if (f) { + memset(key, 0, 4096); + fread(key, 4096, 1, f); + for (i=0; i ./sigusr1.result", buf); + system(key); + break; +#ifdef _CK_ONLINE_PLAYER_COUNT // WON ADD 计算线上人数 + case 'W': + PlayerCount(); + break; +#endif + +#ifdef _SEND_EFFECT // WON ADD 送下雪、下雨等特效 + case 'E': + log("\nAC 向 GS 发送下雪特效!!\n"); + SendEffect(&key[1]); + break; +#endif + +#ifdef _BAD_PLAYER // WON ADD 送坏玩家去关 + case 'B': + log("\nAC 发送坏玩家监狱!!\n"); + BadPlayer(); + break; +#endif + +#ifdef _RECAL_BACKUP_PLAYER // WON 回溯功能 + case 'U': + log("\n发送备份人物资料"); + // 得到备份人物资料 + send_backup_player_data(); + break; +#endif + +#ifdef _GM_BROADCAST // WON ADD 客服公告系统 + case 'G': + log("\n won test 1 ==> _GM_BROADCAST" ); + broadcast(key); + break; +#endif + +#ifdef _KILLDEADWORKER // 将所有Worker初始化 + case 'K': + log("\nKILL ALL WORKER!!!!!\n"); + initWorkerPort(); + break; +#endif + + case 'L': // Robin 列出所有Server连线 + log("\nList All Server Conncet!!!!!\n"); + for( i =0; i = 0 ){ + wk[i].ti = ti; + } else { + exit(1); + } + } + } +#endif +} + +static int countWorker( void ); + +// Nuke +int addWorkerTask( char *id , char *pas , char *flag, + void (*callbk)( int ti , int result , + char *cp0 , char *cp1 , char *cp2 , + char *cp3 , char *cp4, int i0 , int i1) , + int ti , + char *cparam0 , char *cparam1 , + char *cparam2 , char *cparam3 , char *cparam4 , + int iparam0 , int iparam1) +{ + + int i; + // Spock +1 2000/11/2 + char *process = cparam3; + for(i=0;i= MAXWK ) worker_finder = 0; + n = worker_finder; + if( wk[n].use && wk[n].status == WKSTAT_IDLE ){ + char s[256]; + + log("使用工作站:%d \n", n); + + // Nuke + { + int i; + for (i=0;id[i];i++) if (id[i]==' ') return -1; + } + + // Spock 2000/11/2 + snprintf( s , sizeof( s ) , "%s %s %s %s\n", id , pas , flag , process); + // Spock end +#ifdef _FIX_WORKS + if( cWork_write( wk[n].ti, s, strlen(s)) <= 0 ) { +#else + if( tcpstruct_write( wk[n].ti , s , strlen(s)) != strlen(s) ){ +#endif + return -1; + } else { + } + + snprintf( wk[n].cparam[0] , CHARDATASIZE , "%s", cparam0 ); + snprintf( wk[n].cparam[1] , CHARDATASIZE , "%s", cparam1 ); + snprintf( wk[n].cparam[2] , CHARDATASIZE , "%s", cparam2 ); + snprintf( wk[n].cparam[3] , CHARDATASIZE , "%s", cparam3 ); + snprintf( wk[n].cparam[4] , CHARDATASIZE , "%s", cparam4 ); + wk[n].iparam[0] = iparam0; + wk[n].iparam[1] = iparam1; + wk[n].status = WKSTAT_WAITING; + wk[n].callback = callbk; + wk[n].request_ti = ti ; + wk[n].last_query = time(NULL); + + return 0; + } + } + log( "工作站繁忙或工作站停止工作. 活动中的工作站有:%d\n", countWorker() ); + return -1; +} + +static int countWorker( void ) +{ + int i,c=0; + for(i=0;i 1min) + { + struct timeval st, et; + time_t t1; + gettimeofday(&st, NULL); + time(&t1); + delovertimeFMMem(t1); + gettimeofday(&et, NULL); + log("删除家族或成员(%fsec)\n", time_diff(et, st)); + } +#endif + + + if ((counter % 300) == 0) // 300( -> 60) + { + struct timeval st, et; + gettimeofday(&st, NULL); + writeFamily(familydir); + writeFMPoint(fmpointdir); + writeFMSMemo(fmsmemodir); + gettimeofday(&et, NULL); + log("记录家族(%fsec)\n", time_diff(et, st)); + } +#endif + } + +#ifdef _OACSTRUCT_TCP + OAC_select(); + OAC_ReadMessLine(); +#endif + + newti = tcpstruct_accept1(); + if( newti >= 0 ){ + log( "同意: %d\n" , newti ); + gs[newti].use = 1; + } + +#ifdef _LOCK_SERVER + { + int mlen; + char buf[4096]; + if( CHECK_LS_BEUSE() == TRUE ) { + TcpIp_LS_accept(); + + } + //Show_LS_MEMBufferList(); + + mlen = MMGet_LsReadBuflist( buf, sizeof( buf)); + if( mlen > 0 ) { + if( lockproto_SaacDispatchMessage( buf) < 0 ) { + log( "锁定信息:%s", buf); + } + } + CHECK_LSTYPE(); +#ifdef _TEST_LOCKSERVER + TEST_TOLOCKSERVER(); +#endif + } +#endif + +#ifdef _FIX_WORKS + { + int wkti=-1; + int tis[BACKLOGNUM]; + newti = tcpstruct_work_accept( tis , 1); + if( newti == 1 ) { + log( "同意工作站: %d\n" , newti ); + } + + + for( i=0; i 0 ){ + doWorker( i , buf ); + } else if( l == TCPSTRUCT_ETOOLONG || l < 0 ){ + checkWorkerClosed( i ); + tcpstruct_close( i ); + } else if( l == 0 ){ + ; + } +#endif + } else { + if( !gs[i].use )continue; + if( l > 0 ){ + char debugfun[256]; + buf[l]=0; + if( saacproto_ServerDispatchMessage( i , buf, debugfun)<0){ + // Nuke start + tcpstruct_close(i);// avoid the shutdown the gmsv ttom + log( "GMSV(%s) 消息:%s\n", gs[i].name, debugfun); + } + } else if( l == TCPSTRUCT_ETOOLONG ){ + log( "很长:%d 服务器名::%s\n", i , gs[i].name ); + +#ifdef _AC_UNLOCK_GS_PLAYER // WON ADD 自动UNLOCK + DeleteMemLockServer(gs[i].name); + log("\n用户(%s) 登出! 玩家解锁!!\n", gs[i].name ); +#endif + logout_game_server( i ); + } else if( l < 0 ){ + log( "关闭:%d 服务器名:%s\n", i , gs[i].name ); +#ifdef _UNIVERSE_CHATROOM + CHATROOM_GSClosedHandle( i); +#endif +#ifdef _AC_UNLOCK_GS_PLAYER // WON ADD 自动UNLOCK + DeleteMemLockServer(gs[i].name); + log("\n用户(%s) 登出! 玩家解锁!!\n", gs[i].name ); +#endif + + +#ifdef _WORKER_AUTO_LOGOUT // WON ADD GS断线自动送LOGOUT给WORKER + Worker_auto_logout( i, gs[i].name ); +#endif + logout_game_server(i); + } else if( l == 0 ){ + ; + } + } + } + { + static struct timeval tv_loop_store ; + struct timeval now; + double dif; + gettimeofday( &now , NULL ); + dif = time_diff( now, tv_loop_store ); + if( dif > 0.5 ){ // CoolFish 0.1 -> 0.5 2001/5/19 + //log( "Sl:%f" , dif ); + } + tv_loop_store = now; + } + + /* 伐□市□及正奶丞失它玄毛譬屯月[ + 正奶丞失它玄仄凶日夫弘毛分仄化伐□市□毛诮仄化仄引丹[ + 匹必□丞扔□田□卞 蔽读卞反骚襞允月 */ + { + int i; + time_t thre = time(NULL) - WKTIMEOUT; + for(i =0;i= 0 && con[i].closed_by_remote ==0 ){ + FD_SET( con[i].fd , & rfds ); + FD_SET( con[i].fd , & wfds ); + FD_SET( con[i].fd , & efds ); + } + } + + t = select_timeout; + sret = select( 1024, & rfds , (fd_set*)NULL, & efds , &t); + if( sret > 0 ) { + for(i=0;i< MAXCONNECTION;i++){ + if( ( con[i].fd >= 0 ) && FD_ISSET( con[i].fd , &rfds ) ){ + int fr = getFreeMem( ); + int rr , readsize ; + if( fr <= 0 ) continue; + if( fr > sizeof(tmpbuf ) ){ + readsize = sizeof( tmpbuf); + } else { + readsize = fr; + } + rr = read( con[i].fd , tmpbuf , readsize ); + if( rr <= 0 ){ + con[i].closed_by_remote = 1; + } else { + appendReadBuffer( i , tmpbuf , rr ); + } + } + } + } + /* write */ + t = select_timeout; + sret = select( 1024, (fd_set*)NULL, &wfds, & efds , &t); + if( sret > 0 ) { + for(i=0;i= 0 ) && FD_ISSET( con[i].fd , &wfds )){ + char send_buf[4096]; + int l , rr; + memset( send_buf, 0, sizeof( send_buf)); + l = consumeMemBufList( con[i].mbtop_wi ,send_buf, sizeof(send_buf),0 , 1 ); + rr = write( con[i].fd , send_buf , l ); + if( rr < 0 ){ + con[i].closed_by_remote = 1; + } else { + consumeMemBufList( con[i].mbtop_wi , send_buf, l, 1 , 0 ); + } + } + } + } + + for( i=0; i0 to avoid signal interrupt in select + if( (asret>0) && FD_ISSET( mainsockfd , & rfds )){ + struct sockaddr_in c; + int len , newsockfd; + int newcon; + bzero( &c , sizeof( c )); + len = sizeof( c ); + fprintf( stderr, "i can accept " ); + newcon = findregBlankCon( ); + if( newcon < 0 ) continue; + newsockfd = accept( mainsockfd, (struct sockaddr*)&c , &len ); + log( "同意: %d\n" , newsockfd ); + if( newsockfd < 0 ){ + unregMemBuf( newcon ); + continue; + } + set_nodelay( newsockfd ); + con[newcon].fd = newsockfd; + memcpy( &con[newcon].remoteaddr , &c ,sizeof(c)); + tis[accepted] = newcon; + accepted ++; + } + } + + return accepted; +} + + +int tcpstruct_close( int ti ) +{ + + if( ti < 0 || ti >= MAXCONNECTION )return TCPSTRUCT_EINVCIND; + if( con[ti].use == 0 ){ + return TCPSTRUCT_ECLOSEAGAIN; + } + close( con[ti].fd ); + con[ti].use = 0; + con[ti].fd = -1; + + /* 伉旦玄毛凶升匀化蝈 毛弁伉失允月 */ + consumeMemBufList( con[ti].mbtop_ri , NULL, + mbsize * sizeof( mb[0].buf ), 1, 0 ); + consumeMemBufList( con[ti].mbtop_wi , NULL, + mbsize * sizeof( mb[0].buf ), 1, 0 ); + unregMemBuf( con[ti].mbtop_ri ); + unregMemBuf( con[ti].mbtop_wi ); + con[ti].mbtop_ri = -1; + con[ti].mbtop_wi = -1; + return OK; +} + +/* + 心仇戈手及互手丹卅仁化}仄井手 remoteclose 分匀凶日 -1 毛井尹允 + + */ +int tcpstruct_read( int ti , char *buf , int len ) +{ + int l; + + if( ti < 0 || ti >= MAXCONNECTION || con[ti].use == 0 ) + return TCPSTRUCT_EINVCIND; + l = consumeMemBufList( con[ti].mbtop_ri , buf , len , 1 , 1); + if( l == 0 && con[ti].closed_by_remote ) return TCPSTRUCT_EREADFIN; + + return l; +} + +/* + 1垫毛方心仇戈[ + int kend : 1卅日垫 及 \n 毛诮允 + int kend_r : 1卅日垫 及 \r 手诮允(丐木壬) + + 心仇戈手及互手丹卅仁化}井勾 remote closed 分匀凶日-1毛井尹允 + // Nuke + Read 1 line + if kend==1 then delete \n at the tail + if kend_r== 1 then delete \r at the tail (if any) + if no data read, it means 'remote closed' then return -1 + */ +int tcpstruct_readline( int ti , char *buf , int len , int kend , int kend_r ) +{ + int l; + int minus = 0; + + if( ti < 0 || ti >= MAXCONNECTION || con[ti].use == 0 ) + return TCPSTRUCT_EINVCIND; + + l = getLineReadBuffer( ti , buf , len ); + if( l == 0 ){ + if( con[ti].closed_by_remote ){ + return TCPSTRUCT_EREADFIN; + } else { + return 0; + } + } + + if( kend ){ + if( buf[l-1]=='\n' ){ + buf[l-1] = 0; minus =-1; + } + } + if( kend_r ){ + if( buf[l-1]=='\r' ){ + buf[l-1] = 0; minus = -1; + } + if( buf[l-2]=='\r' ){ + buf[l-2] = 0; minus = -2; + } + } + return l + minus; +} +int tcpstruct_readline_chop( int ti , char *buf, int len ) +{ + return tcpstruct_readline( ti , buf , len , 1,1); +} + +int tcpstruct_write( int ti , char *buf , int len ) +{ + if( ti < 0 || ti >= MAXCONNECTION || con[ti].use == 0 ) + return TCPSTRUCT_EINVCIND; + return appendWriteBuffer( ti , buf , len ); +} + +int tcpstruct_connect( char *addr , int port ) +{ + int newti ; + int s, r; + struct sockaddr_in svaddr; + struct hostent *he; + + s = socket( AF_INET, SOCK_STREAM , 0 ); + if(s<0)return -2; + + bzero( &svaddr , sizeof( svaddr )); + svaddr.sin_family = AF_INET; + svaddr.sin_port = htons( port ); + + if( inet_aton( addr, &svaddr.sin_addr ) == 0 ){ + he = gethostbyname( addr ); + if( he == NULL ){ + return TCPSTRUCT_EHOST; + } + memcpy( & svaddr.sin_addr.s_addr , he->h_addr , + sizeof( struct in_addr)); + } + r = connect( s , ( struct sockaddr*)&svaddr,sizeof(svaddr)); + if( r < 0 ){ + return TCPSTRUCT_ECONNECT; + } + set_nodelay( s ); + newti = findregBlankCon( ); + if( newti < 0 ){ + fprintf( stderr , "连接失败: newti:%d\n", newti ); + return TCPSTRUCT_ECFULL; + } + con[newti].fd = s; + memcpy( & con[newti].remoteaddr , &svaddr , + sizeof( struct sockaddr_in)); + return newti; +} + +static int appendReadBuffer( int index , char *data , int len ) +{ + int top; + + top = con[index].mbtop_ri; + for(;;){ + int nextind = mb[top].next; + + if( nextind == -1 ) break; + top = nextind; + } + return appendMemBufList( top , data , len ); +} + +static int appendWriteBuffer( int index , char *data , int len ) +{ + int top; + top = con[index].mbtop_wi; + for(;;){ + int nextind = mb[top].next; + if( nextind == -1 ) break; + top = nextind; + } + return appendMemBufList( top , data , len ); +} +static int appendMemBufList( int top , char *data , int len ) +{ + int fr = getFreeMem( ); + int rest = len; + int data_topaddr = 0; + + if( len >= fr ){ + FILE *fp; + if( (fp=fopen( "badsysinfo.txt", "a+")) != NULL ){ + fprintf( fp, "appendMemBufList() len:%d / fr:%d err !! \n", len, fr); + fclose( fp); + } + //andy_log + log( "appendMemBufList() len:%d / fr:%d err !! \n", len, fr); + return -1; + } + data[len] = 0; + for(;;){ + int blanksize = sizeof( mb[0].buf ) - mb[top].len; + int cpsize = ( rest <= blanksize ) ? rest : blanksize; + memcpy( mb[top].buf + mb[top].len , + data + data_topaddr , cpsize ); + mb[top].len += cpsize; + if( rest <= blanksize ){ + return len; + } else { + int newmb; + rest -= cpsize; + data_topaddr += cpsize; + if( (newmb = findregBlankMemBuf( ) ) == TCPSTRUCT_EMBFULL ){ + FILE *fp; + if( (fp=fopen( "badsysinfo.txt", "a+")) != NULL ){ + fprintf( fp, "find newmb == TCPSTRUCT_EMBFULL err data:%s !!\n", data); + fclose( fp); + } + log( "find newmb == TCPSTRUCT_EMBFULL err data:%s !!\n", data); + } + mb[top].next = newmb; + top = mb[top].next; + } + } + return TCPSTRUCT_EBUG; +} + +static int consumeMemBufList( int top , char *out , int len , + int consumeflag , int copyflag ) +{ + int total = 0; + int top_store = top; + for(;;){ + int cpsize; + if( top == -1 ) break; + cpsize = ( mb[top].len <= ( len - total) ) ? + mb[top].len : ( len - total ); + + if( copyflag ) memcpy( out + total , mb[top].buf , cpsize ); + total += cpsize; + + if( consumeflag ){ + mb[top].len -= cpsize; + if( mb[top].len > 0 ){ + /* 勾井中反凶仄化卅中及匹memmove */ + memmove( mb[top].buf , mb[top].buf + cpsize , + sizeof( mb[top].buf ) - cpsize ); + } + } + top = mb[top].next; + if( total == len ){ + break; + } + } + + if( consumeflag ){ + /* 卅互今互0卞卅匀化月卅日荸 [匹手 赓及支勾反荸 仄卅中冗 */ + top = mb[top_store].next; + for(;;){ + if( top == -1 )break; + if( mb[top].len == 0 ){ + int prev; + mb[top_store].next = mb[top].next; + prev = top; + top = mb[top].next; + unregMemBuf( prev ); + } else { + top = mb[top].next; + } + } + } + + return total; +} + +static int getLineReadBuffer( int index , char *buf, int len ) +{ + + int top = con[index].mbtop_ri; + int ti = 0 , breakflag = 0; + + for(;;){ + int i; + int l = mb[top].len; + if( top == -1 )break; + for( i=0 ; i < l ; i++){ + if( mb[top].buf[i] == '\n' ){ + breakflag = 1; + break; + } + ti ++; + } + if( breakflag )break; + top = mb[top].next; + } + if( ti > len ){ + /* 1垫互卅互允亢月[ 卅巨仿□毛井尹六 */ + return TCPSTRUCT_ETOOLONG; + } + /* 垫互敦岳仄化卅中 */ + if( breakflag == 0 ){ + return 0; + } + + return consumeMemBufList( con[index].mbtop_ri , buf , ti+1 , 1 , 1 ); +} + + + +/* + 心仇户月 赢今毛忒允 + int index : con index + + return: + 反巨仿□ + 0动晓及桦宁反 read 仄化手方中赢今[ + + + mbsize 井日mbuse 毛娄中化扔奶术毛井仃月分仃[ + 仇引井中芴曰及坌反 骰允月[公氏卅称井中袄卞仇分歹日卅仁化手第[ + + */ +static int getFreeMem( void ) +{ + return ( mbsize - mbuse ) * sizeof( mb[0].buf ); +} + +/* + + membuf 及坞五毛茧仄分允[ + + return : 心勾井匀凶日 >=0 匹 index. + 心勾井日卅井匀凶日 + + 腹绸及午五卞反 mb_finder 毛勾井丹[ + 仇木匹腹绸仄化} 卞reg允月[ + */ + +static int findregBlankMemBuf( void ) +{ + int i; + for(i=0;i= mbsize || mb_finder < 0 ) mb_finder = 0; + + if( mb[mb_finder].use == 0 ){ + mb[mb_finder].use = 1; + mb[mb_finder].len = 0; + mb[mb_finder].next = -1; + mbuse ++; + return mb_finder; + } + } + return TCPSTRUCT_EMBFULL; +} + +/* + mb 毛荸 允月 + + */ +static int unregMemBuf( int index ) +{ + mb[index].use=0; + mb[index].next = -1; + mb[index].len = 0; + mbuse --; + return OK; +} + +static int findregBlankCon( void ) +{ + int i; + // Nuke changed 0->1 + //for(i=0;i15) || (toinfo <0) || ( toinfo >15)) + continue; + + // 是否要移民出去或移民进来 + if( !strcmp( servername[frominfo], saacname) || !strcmp( servername[toinfo], saacname) ) + { + + log(" from:%s to:%s ", servername[frominfo], servername[toinfo]); + + // 锁帐号 +#ifdef _LOCK_ADD_NAME + InsertMemLock( getHash(playerinfo) & 0xff, playerinfo, "", "", "星系移民", 0, "0"); +#else + InsertMemLock( getHash(playerinfo) & 0xff, playerinfo, "", "星系移民", 0, "0"); +#endif + + // 踢人 + log("移民前踢人 "); + for(i=0;i%s->%s", i, gs[i].name, playerinfo); + } + } + } + //else + //{ + // continue; + //} + + } + + // 列表档案改名备份 + //sprintf( backup_movelist, "%s.old", listfilename); + //rename( listfilename, backup_movelist); + + fclose( listfile); + + } + + signal(SIGUSR2, sighandle); +} + + + +#ifdef _ANGEL_SUMMON + +#define MISSIONFILE "db/missiontable.txt" + +static int initMissionTable( void ) +{ + FILE *fp; + char onedata[1024]; + char buf[1024]; + int index =0; + + memset( missiontable, 0, sizeof(missiontable)); + fp = fopen( MISSIONFILE, "r"); + if( !fp ) { + log("\n加载任务错误!!!! \n"); + //return false; + } + log("\n加载任务..."); + while(1) { + // + if( fgets( onedata, sizeof(onedata), fp) == NULL) + break; + if( onedata[0] == NULL || onedata[0] == '#' ) + continue; + //easyGetTokenFromBuf( onedata, ',', 1, buf, sizeof( buf)); + //index = atoi( buf); + easyGetTokenFromBuf( onedata, ',', 1, buf, sizeof( buf)); + if( buf[0] == NULL ) continue; + strcpy( missiontable[index].angelinfo, buf); + easyGetTokenFromBuf( onedata, ',', 2, buf, sizeof( buf)); + if( buf[0] == NULL ) continue; + strcpy( missiontable[index].heroinfo, buf); + easyGetTokenFromBuf( onedata, ',', 3, buf, sizeof( buf)); + if( buf[0] == NULL ) continue; + missiontable[index].mission = atoi( buf); + easyGetTokenFromBuf( onedata, ',', 4, buf, sizeof( buf)); + if( buf[0] == NULL ) continue; + missiontable[index].flag = atoi( buf); + easyGetTokenFromBuf( onedata, ',', 5, buf, sizeof( buf)); + if( buf[0] == NULL ) continue; + missiontable[index].time = atoi( buf); + easyGetTokenFromBuf( onedata, ',', 6, buf, sizeof( buf)); + if( buf[0] == NULL ) continue; + missiontable[index].limittime = atoi( buf); + + log(" %d=%s,%s,%d,%d,%d,%d \n", index, + missiontable[index].angelinfo, + missiontable[index].heroinfo, + missiontable[index].mission, + missiontable[index].flag, + missiontable[index].time, + missiontable[index].limittime ); + + index++; + if( index >= MAXMISSIONTABLE) break; + } + fclose( fp); + log("..成功! \n"); + //return true; +} + + +int saveMissionTable( void ) +{ + FILE *fp; + char onedata[1024]; + char buf[1024]; + int index =0; + + fp = fopen( MISSIONFILE, "w"); + if( !fp ) { + log("\n打开任务错误!!!! \n"); + //return false; + } + log("\n\n保存任务..."); + for( index =0; index < MAXMISSIONTABLE; index++) { + + if( missiontable[index].angelinfo[0] == NULL ) + continue; + sprintf( onedata, "%s,%s,%d,%d,%d,%d\n", + missiontable[index].angelinfo, + missiontable[index].heroinfo, + missiontable[index].mission, + missiontable[index].flag, + missiontable[index].time, + missiontable[index].limittime ); + fputs( onedata, fp); + } + fclose( fp); + log("..成功! \n"); + //return true; +} + +void delMissionTableOnedata( int index) +{ + int gi; + + log("\n删除任务:%d:%s:%s \n", index, missiontable[index].angelinfo, missiontable[index].heroinfo); + + if( index <0 || index >=MAXMISSIONTABLE) return; + strcpy( missiontable[index].angelinfo, ""); + strcpy( missiontable[index].heroinfo, ""); + missiontable[index].mission = 0; + missiontable[index].flag = MISSION_NONE; + missiontable[index].time = 0; + missiontable[index].limittime = 0; + + for( gi=0; gi missiontable[index].time + ANSWERTIME*60*60 ) { + + delMissionTableOnedata( index);// 删 + } + // 等待领奖完成 limittime小时 + else if( ( missiontable[index].flag == MISSION_DOING || missiontable[index].flag == MISSION_HERO_COMPLETE ) + && ( sys_time > (missiontable[index].time + missiontable[index].limittime*60*60)) ) { + + char buf[1024]; + int gi; + // 改TIMEOVER + log(" 任务及领奖时间过:%d ", index); + missiontable[index].flag = MISSION_TIMEOVER; + missiontable[index].time = time(NULL); + missiontable[index].limittime = BOUNDSTIME; + + sprintf( buf, "%d|%s|%s|%d|%d|%d|%d ", index, + missiontable[index].angelinfo, + missiontable[index].heroinfo, + missiontable[index].mission, + missiontable[index].flag, + missiontable[index].time, + missiontable[index].limittime ); + for( gi=0; gi missiontable[index].time + BOUNDSTIME*60*60 ) { + // log(" 领奖时间过:%d ", index); + // delMissionTableOnedata( index);// 删 + //} + + // 资料保留时间(BOUNDSTIME小时) + else if( missiontable[index].flag == MISSION_TIMEOVER + && sys_time > missiontable[index].time + BOUNDSTIME*60*60 ) { + log(" 保留时间过:%d ", index); + delMissionTableOnedata( index);// 删 + } + + } + saveMissionTable(); + + lastcheck = sys_time; +} + +#endif + +#ifdef _RACEMAN +//#define RANKFILE "race/ranktable.txt" +struct RankTable ranktable[DEFMAXRANK]; + +static int initRankTable( void ) +{ + //FILE *fp; + memset( ranktable, 0, sizeof(ranktable)); +/* + fp = fopen( RANKFILE, "r"); + if( !fp ) { + log("\n\n Load RankTable ERROR!!!! \n\n"); + } + log("\n\n Load RankTable... \n"); +*/ + return; +} + +#endif diff --git a/saac/main.h b/saac/main.h new file mode 100644 index 0000000..9bce00f --- /dev/null +++ b/saac/main.h @@ -0,0 +1,213 @@ +#ifndef _MAIN_H_ +#define _MAIN_H_ + + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include "version.h" + +#ifdef _MAIN_C_ +#define EXT +#else +#define EXT extern +#endif + +#define CHARDATASIZE ( 256 * 1024 ) +#define MAXWK 50//30 + +#ifdef _FIX_WORKS +void set_nodelay( int sock ); + +#define OK 0 +#define TCPSTRUCT_ENOMEM -1 /* malloc 撩 */ +#define TCPSTRUCT_ESOCK -2 /* socket 撩 */ +#define TCPSTRUCT_EBIND -3 /* bind 撩 */ +#define TCPSTRUCT_ELISTEN -4 /* listen 撩 */ +#define TCPSTRUCT_EBUG -6 /* 田弘匹丐月 */ +#define TCPSTRUCT_EINVCIND -7 /* con尺及index互云井仄中方 */ +#define TCPSTRUCT_EREADFIN -8 /* read 允月犯□正互卅仁化 closed by remote */ +#define TCPSTRUCT_EHOST -9 /* gethostbyname 撩 */ +#define TCPSTRUCT_ECONNECT -10 /* connect 撩 */ +#define TCPSTRUCT_ECFULL -11 /* con 互中匀天中 */ +#define TCPSTRUCT_ETOOLONG -12 /* 垫互卅互允亢 */ +#define TCPSTRUCT_EMBFULL -13 /* mb 互中匀天中 */ +#define TCPSTRUCT_ECLOSEAGAIN -14 /* close 互2荚今木凶 */ +#define TCPSTRUCT_WORKERROR -16 +#define TCPSTRUCT_WORKEBIND -17 + +#define INIT_SOMEERROR -18 + +extern time_t sys_time; // Robin add + +struct membuf +{ + int use; + char buf[512]; + int len; + int next; +}; + +struct connection +{ + int use; + int fd; + int mbtop_ri; + int mbtop_wi; + struct sockaddr_in remoteaddr; + int closed_by_remote; +}; + +#define FORWORKPORT 9400 +typedef enum +{ + WKSTAT_IDLE = 0, + WKSTAT_WAITING = 2, + WKSTAT_DIE = 3, +} WKSTAT; + +#define CPARAMNUM 5 +#define IPARAMNUM 3 + +struct worker +{ + int use; + int port; +#ifdef _FIX_WORKS + int fd; +#endif + int ti; + int request_ti; + WKSTAT status; + time_t last_query; + void (*callback)( int ti , int result , char *cparam0 , char *cparam1, + char *cparam2 , char *cparam3, char *cparam4, + int iparam1 , int iparam2 ); + char cparam[CPARAMNUM][CHARDATASIZE]; + int iparam[IPARAMNUM]; +}; + +struct worker wk[MAXWK]; + +#endif +char *chartime(); +#define LOGBASE( filename , format , args...)\ +{\ + FILE *f;\ + f = fopen( filename , "a" );\ + if( f != NULL ){\ + fprintf( f , format , ## args);\ + fclose(f);\ + } else{ fprintf( stderr,"fuckup! log fail!:%s:%s\n", filename,strerror(errno));}\ +} + +// Spock 2000/10/27 +#define log(format, args...) \ +{\ + fprintf( stderr, format , ## args );\ +} +// Spock end +#define SUCCESSFUL "successful" +#define FAILED "failed" + +#ifdef _BAD_PLAYER +#define BADPLAYER "badplayer" +#endif + +#define MAXCONNECTION 50 +#define WKTIMEOUT 120 +#define USERID_MAX 32 +#define CHARNAME_MAX 32 + +EXT char svpass[1024]; +EXT char topdir[1024]; +EXT char glogdir[1024]; +EXT char chardir[1024]; +EXT char logdir[1024]; +EXT char dbdir[1024]; +EXT char lockdir[1024]; +EXT char wklogdir[1024]; +EXT char maildir[1024]; + +// CoolFish: Family 2001/5/9 +EXT char familydir[1024]; +EXT char fmpointdir[1024]; +EXT char fmsmemodir[1024]; +#ifdef _LOCK_SERVER +EXT char SaName[1024]; +EXT char LSADDRESS[1024]; +EXT char TESTNAME[1024]; +EXT int LSPORT; +#endif +EXT int wknum; +EXT int log_rotate_interval; +EXT int total_ok_charlist, total_ng_charlist; + +#ifdef _OACSTRUCT_TCP +EXT int OACbindtype; +#endif + +EXT char saacname[1024]; +//EXT char movelist[1024]; + +#ifdef _SLEEP_CHAR +EXT char sleepchardir[1024]; +#endif + + +typedef struct _gmsv +{ + int use; + int fd; + char name[1024]; +} gmsv; + +int addWorkerTask( char *id , char *pas , char *flag , + void (*callbk)( int ti , int result , + char *cp0 , char *cp1 , char *cp2 , + char *cp3 , char *cp4, int i0 , int i1) , + int ti , + char *cparam0 , char *cparam1 , + char *cparam2 , char *cparam3 , char *cparam4 , + int iparam0 , int iparam1); + +int get_rotate_count(void ); +void checkGSUCheck( char *id ); +int logout_game_server( int ti ); +int is_game_server_login( int ti ); +char * getGSName( int i ); + +void gmsvBroadcast( int fd, char *p1, char *p2, char *p3 , int flag ); +int login_game_server( int ti, char *svname, char *svpas, char *result, + int resultlen , char *retdata , int retdatalen ); + +#ifdef _ANGEL_SUMMON +typedef enum +{ + MISSION_NONE =0, + MISSION_WAIT_ANSWER, + MISSION_DOING, + MISSION_HERO_COMPLETE, + MISSION_TIMEOVER, +}ANGEL_MISSIONFLAG; +#endif + + +#undef EXT +#endif + + + + + diff --git a/saac/makefile b/saac/makefile new file mode 100644 index 0000000..1b94964 --- /dev/null +++ b/saac/makefile @@ -0,0 +1,711 @@ +# +# Edit by ringo 19980606 +# 19990723 +# +# +# + +CC = gcc + +#加入mysql资料库功能 +CFLAGS=-w -O3 $(INCFLAGS) +MYSQL=-L /usr/lib/mysql/ -lmysqlclient -lz + +TOP=../.. +PROG = saac +SHELL = /bin/sh +PERL=/usr/bin/perl + +RPCGEN=${TOP}/bin/lsgen.perl + +RPCHTML = ${TOP}/doc/saacproto.html +#RPCSRC = saacproto_serv.c saacproto_util.c saacproto_work.c saacproto_sup.c saacproto_lserver.c saacproto_oac.c deathcontend.c +RPCSRC = saacproto_serv.c saacproto_util.c saacproto_work.c saacproto_lserver.c saacproto_oac.c deathcontend.c +RPCINCLUDE = saacproto_serv.h saacproto_util.h saacproto_work.h saacproto_lserver.h saacproto_oac.h deathcontend.h +RPCNOUSE = saacproto_cli.c saacproto_cli.h + +#加入mysql资料库功能 +SRC = main.c recv.c util.c char.c db.c mail.c acfamily.c defend.c lock.c tcpip_util.c chatroom.c auction.c sasql.c $(RPCSRC) +#SRC = main.c recv.c util.c char.c db.c mail.c acfamily.c defend.c lock.c tcpip_util.c chatroom.c auction.c $(RPCSRC) + +OBJ=$(SRC:.c=.o) + +WKDIR=wk +WK=acwk + + + + +all : ${PROG} ${WK} + + +${PROG} : $(RPCSRC) ${OBJ} + $(CC) $ -o $(PROG) $(OBJ) $(LFLAGS) $(MYSQL) + +${WK} : + make -C ${WKDIR} all + +depend: $(RPCSRC) $(ANIMDATAFILE) + @for dir in $(SUBDIR) ; do \ + $(MAKE) -C $$dir depend;\ + done + $(MV) Makefile Makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' Makefile.bak>Makefile + $(CC) $(INCFLAGS) -M $(SRC) >> Makefile + +clean: + @for dir in $(SUBDIR) ; do \ + $(MAKE) -C $$dir clean;\ + done + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + +distclean: + @for dir in $(SUBDIR) ; do \ + $(MAKE) -C $$dir distclean;\ + done + $(RM) $(CLIRPCSRC) + $(RM) $(CLIRPCINCLUDE) + $(RM) $(SERVRPCSRC) + $(RM) $(SERVRPCINCLUDE) + $(RM) $(ANIMDATAFILE) + $(RM) include/*~ + + $(RM) $(PROG) + $(RM) $(OBJ) + $(RM) *~ + + $(MV) Makefile Makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' Makefile.bak>Makefile + $(RM) Makefile.bak + + +rpc : ${RPCHTML} ${RPCGEN} + $(PERL) ${RPCGEN} ${RPCHTML} -h . -o . + rm -f ${RPCNOUSE} + +# DO NOT DELETE THIS LINE +main.o: main.c main.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/string.h version.h util.h mail.h db.h saacproto_util.h \ + saacproto_serv.h acfamily.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/sys/wait.h \ + /usr/include/sys/resource.h /usr/include/bits/resource.h \ + /usr/include/bits/waitflags.h /usr/include/bits/waitstatus.h \ + /usr/include/malloc.h /usr/include/fcntl.h /usr/include/bits/fcntl.h \ + /usr/include/netinet/tcp.h saacproto_work.h lock.h recv.h defend.h \ + char.h +recv.o: recv.c version.h main.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/string.h saacproto_util.h saacproto_serv.h \ + saacproto_lserver.h saacproto_work.h recv.h char.h db.h mail.h lock.h \ + util.h sasql.h acfamily.h defend.h +util.o: util.c /usr/include/unistd.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/typesizes.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/sys/stat.h /usr/include/time.h \ + /usr/include/bits/stat.h /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h main.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/bits/sched.h \ + /usr/include/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h /usr/include/strings.h \ + /usr/include/sys/time.h /usr/include/string.h version.h util.h +char.o: char.c /usr/include/time.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/time.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/sys/stat.h \ + /usr/include/bits/stat.h /usr/include/fcntl.h /usr/include/bits/fcntl.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h main.h \ + /usr/include/stdlib.h /usr/include/alloca.h /usr/include/netinet/in.h \ + /usr/include/stdint.h /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h /usr/include/strings.h \ + /usr/include/sys/time.h /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/string.h version.h char.h saacproto_serv.h \ + saacproto_util.h util.h saacproto_lserver.h acfamily.h lock.h recv.h \ + sasql.h +db.o: db.c db.h main.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/string.h version.h util.h /usr/include/dirent.h \ + /usr/include/bits/dirent.h /usr/include/sys/stat.h \ + /usr/include/bits/stat.h +mail.o: mail.c main.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/string.h version.h mail.h util.h saacproto_serv.h \ + saacproto_util.h /usr/include/malloc.h /usr/include/dirent.h \ + /usr/include/bits/dirent.h /usr/include/sys/stat.h \ + /usr/include/bits/stat.h +acfamily.o: acfamily.c version.h main.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/string.h acfamily.h util.h saacproto_serv.h \ + saacproto_util.h /usr/include/malloc.h /usr/include/dirent.h \ + /usr/include/bits/dirent.h /usr/include/sys/stat.h \ + /usr/include/bits/stat.h +defend.o: defend.c version.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/string.h /usr/include/ctype.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/time.h /usr/include/bits/time.h \ + saacproto_serv.h saacproto_util.h /usr/include/stdlib.h \ + /usr/include/sys/types.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h /usr/include/strings.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h main.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h char.h util.h \ + defend.h +lock.o: lock.c /usr/include/stdio.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h lock.h version.h main.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/string.h char.h recv.h +tcpip_util.o: tcpip_util.c version.h main.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/string.h tcpip_util.h +chatroom.o: chatroom.c version.h main.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/string.h util.h saacproto_serv.h saacproto_util.h +auction.o: auction.c version.h +sasql.o: sasql.c version.h main.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/string.h util.h mail.h db.h saacproto_util.h \ + saacproto_serv.h acfamily.h /usr/include/signal.h \ + /usr/include/bits/signum.h /usr/include/bits/siginfo.h \ + /usr/include/bits/sigaction.h /usr/include/bits/sigcontext.h \ + /usr/include/asm/sigcontext.h /usr/include/bits/sigstack.h \ + /usr/include/bits/sigthread.h /usr/include/sys/wait.h \ + /usr/include/sys/resource.h /usr/include/bits/resource.h \ + /usr/include/bits/waitflags.h /usr/include/bits/waitstatus.h \ + /usr/include/malloc.h /usr/include/fcntl.h /usr/include/bits/fcntl.h \ + /usr/include/netinet/tcp.h saacproto_work.h lock.h recv.h defend.h \ + char.h /usr/include/mysql/mysql.h /usr/include/mysql/mysql_com.h \ + /usr/include/mysql/mysql_time.h /usr/include/mysql/mysql_version.h \ + /usr/include/mysql/typelib.h /usr/include/mysql/my_list.h \ + /usr/include/mysql/my_alloc.h +saacproto_serv.o: saacproto_serv.c version.h saacproto_serv.h \ + saacproto_util.h /usr/include/stdlib.h /usr/include/features.h \ + /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h /usr/include/string.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h main.h /usr/include/stdio.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h +saacproto_util.o: saacproto_util.c version.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h /usr/include/string.h \ + /usr/include/unistd.h /usr/include/bits/posix_opt.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/strings.h main.h /usr/include/netinet/in.h \ + /usr/include/stdint.h /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h saacproto_util.h +saacproto_work.o: saacproto_work.c version.h main.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/string.h recv.h saacproto_serv.h saacproto_util.h \ + saacproto_work.h char.h +saacproto_lserver.o: saacproto_lserver.c saacproto_lserver.h version.h \ + saacproto_serv.h saacproto_util.h /usr/include/stdlib.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h /usr/include/string.h \ + /usr/include/strings.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h main.h /usr/include/stdio.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h char.h util.h +saacproto_oac.o: saacproto_oac.c version.h main.h /usr/include/stdio.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/types.h /usr/include/bits/wordsize.h \ + /usr/include/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h /usr/include/bits/wchar.h \ + /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/time.h \ + /usr/include/endian.h /usr/include/bits/endian.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/string.h util.h char.h tcpip_util.h saacproto_util.h \ + saacproto_oac.h +deathcontend.o: deathcontend.c version.h /usr/include/time.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/gnu/stubs.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h \ + /usr/include/bits/time.h /usr/include/bits/types.h \ + /usr/include/bits/wordsize.h /usr/include/bits/typesizes.h main.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/include/bits/wchar.h /usr/include/gconv.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/stdlib.h /usr/include/sys/types.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/bits/sched.h /usr/include/alloca.h \ + /usr/include/netinet/in.h /usr/include/stdint.h \ + /usr/include/bits/socket.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/limits.h \ + /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/sockaddr.h \ + /usr/include/asm/socket.h /usr/include/asm/sockios.h \ + /usr/include/bits/in.h /usr/include/bits/byteswap.h \ + /usr/include/arpa/inet.h /usr/include/netdb.h /usr/include/rpc/netdb.h \ + /usr/include/bits/netdb.h /usr/include/sys/socket.h \ + /usr/include/sys/uio.h /usr/include/bits/uio.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/confname.h \ + /usr/include/getopt.h /usr/include/strings.h /usr/include/sys/time.h \ + /usr/include/errno.h /usr/include/bits/errno.h \ + /usr/include/linux/errno.h /usr/include/asm/errno.h \ + /usr/include/string.h saacproto_util.h saacproto_serv.h recv.h char.h \ + util.h deathcontend.h diff --git a/saac/recv.c b/saac/recv.c new file mode 100644 index 0000000..0d91757 --- /dev/null +++ b/saac/recv.c @@ -0,0 +1,3266 @@ +#define _RECV_C_ + +#include "version.h" +#include "main.h" +#include "saacproto_util.h" +#include "saacproto_serv.h" +#include "saacproto_lserver.h" +#include "saacproto_work.h" +#include "recv.h" +#include "char.h" +#include "db.h" +#include "mail.h" +#include "lock.h" +#include "util.h" + +#ifdef _SASQL1 +#include "sasql.h" +#endif + +// CoolFish: Family 2001/5/9 +#include "acfamily.h" +#include "version.h" + +#include +#include + +#ifdef _PAUCTION_MAN +#include "auction.h" +#endif +#ifdef _DEATH_CONTEND +#include "deathcontend.h" +#endif +#include "defend.h" + +#ifdef _UNIVERSE_CHATROOM +#include "chatroom.h" +#endif + +#ifdef _RECAL_BACKUP_PLAYER // WON 回溯功能 +#include +#include + +#define MAX_HAVE_ITEM 20 +#define MAX_POOL_ITEM 30 +#define MAX_HAVE_PET 5 +#define MAX_POOL_PET 20 + +static int char_data_count=0; + + +#endif + + + +#ifdef _CK_ONLINE_PLAYER_COUNT // WON ADD 计算线上人数 +struct play_count +{ + int playcount; +}; +struct play_count online_player[MAXCONNECTION]; +#endif + + + +char retdata[CHARDATASIZE]; +char result[CHARDATASIZE]; + +// Spock +1 2000/11/1 +#define MAX_PROCESS 16777216 + +void saacproto_ACServerLogin_recv( int ti,char* servername , + char* serverpas ) +{ + login_game_server( ti , + servername , serverpas , + result , sizeof( result ) , + retdata , sizeof( retdata )); + + saacproto_ACServerLogin_send( ti ,result ,retdata ); +} +/* + 必□丞扔□田□互失市它件玄扔□田□井日夫弘失它玄允月[ + int fd : 覆擂socket + +*/ +void saacproto_ACServerLogout_recv( int ti ) +{ + + logout_game_server( ti ); +} + +void saacproto_ACCharLoad_recv( int ti,char* id,char* pas,char* charname , + int lock,char* opt , int mesgid) +{ + // Spock 2000/10/31 + static int process = 0; + char buf[16]; + // Spock end +#ifdef _NewSave + int charindex = -1; +#endif + + +if (!sasql_query(id,pas)){ + if(!sasql_register(id,pas)){ + log("密码错误或没有注册\n"); + saacproto_ACCharList_send( ti , FAILED , "Password error" , mesgid); + return;}} + + + if( !is_game_server_login( ti ) ){ +#ifdef _NewSave + saacproto_ACCharLoad_send( ti , FAILED , "not login" , mesgid, charindex ); +#else + saacproto_ACCharLoad_send( ti , FAILED , "not login" , mesgid ); +#endif + return; + } + +#ifdef _CHANGEGALAXY + if( isChangeGalaxyLocked( id) ) { + log(" 因星系移民被锁 "); + saacproto_ACCharLoad_send( ti , FAILED , "CHANGE_GALAXY" , mesgid, charindex ); + return; + } +#endif + + +#ifdef _UNLOCKPOOL // 登入时检查是否已在UnlockPool中 + if( inUnlockPool(id) ) { + log(" 已经在UNLOCKPOOL中 "); + saacproto_ACCharLoad_send( ti , FAILED , + "server load too high" , mesgid , charindex); + return; + } +#endif + + process++; + if ( process > MAX_PROCESS ) process = 1; + snprintf( buf , sizeof(buf) , "%d" , process ); + + if( addWorkerTask( id, pas , "2", charLoadCallback , ti , + id , pas , charname , buf , "" , lock, mesgid) < 0 ){ + + +#ifdef _NewSave + saacproto_ACCharLoad_send( ti , FAILED , + "server load too high" , mesgid , charindex); +#else + saacproto_ACCharLoad_send( ti , FAILED , + "server load too high" , mesgid ); +#endif + return; + } + + // Spock 2000/10/31 + //log( "读取档案: 附加作业 %s %s, 进程=%d\n", id,pas,process ); + // Spock end +} + +#ifdef _RELOGIN +void saacproto_ACCharLoadII_recv( int ti,char* id,char* pas,char* charname , + int lock,char* opt , int mesgid,int gs1, int gs2) +{ + char buf[16]; + int charindex = -1; + + if( !is_game_server_login( ti ) ){ + saacproto_ACCharLoad_send( ti , FAILED , "not login" , mesgid, charindex ); + return; + } + // 检查Buffer中的资料是否符合 + // 检查原先从Wgs传回CharLoad做了什麽事 + // 更新名片资料 +} +#endif + +/* + 平乓仿忡绣 + + char *id : ID + char *pas : 天允歹□升 + char *charname : 平乓仿 + char *opt : 左皿扑亦件 侬 [ CharList及午五卞丢乒午仄化忒允树 + char *charinfo : 白央奶伙卞忡绣允月平乓仿弁正及旦 □正旦树 [ + int id : 丢永本□斥id +*/ +#ifdef _NewSave +void saacproto_ACCharSave_recv( int ti, char* id, + char *charname,char* opt , + char* charinfo , int unlock , int mesgid , int charindex ) +#else +void saacproto_ACCharSave_recv( int ti, char* id, + char *charname,char* opt , + char* charinfo , int unlock , int mesgid ) +#endif +{ + char process[16]; + int ret; + if( !is_game_server_login(ti) ){ + saacproto_ACCharSave_send( ti , FAILED , "not login" , mesgid ); + return; + } +#ifdef _NewSave + ret = charSave( ti, id, charname, opt, charinfo, + unlock,mesgid, charindex ); +#else + ret = charSave( ti, id, charname, opt, charinfo, + unlock,mesgid ); +#endif + snprintf( process , sizeof(process) , "%d" , ret ); +// log( "unlock:%d, process:%s\n", unlock, process); + if( unlock) { +#ifdef _UNLOCKPOOL + if( addUnlockPool( ti, id, charname, process, mesgid) <0 ) { +#else + if( addWorkerTask( id , "dummy" , "3" , dummyCallback , ti , + id , "dummy" , charname , process ,"", + mesgid , 0 ) < 0 ) { +#endif + log("游戏退出失败, 进程=%s\n" , process ); + } else { + log("游戏退出成功, 进程=%s\n" , process ); + } + + } else { + log("自动保存\n\n"); + } + + log("在线玩家保存\n"); +} + +#ifdef _RELOGIN +void saacproto_ACCharSaveII_recv( int ti, char* id, + char *charname,char* opt , + char* charinfo , int unlock , int mesgid , int charindex ) +{ + char process[16]; + int ret; + + if( !is_game_server_login(ti) ){ + saacproto_ACCharSave_send( ti , FAILED , "not login" , mesgid ); + return; + } + ret = charSave( ti, id, charname, opt, charinfo, + unlock,mesgid, charindex ); + // 储存人物资料 + // 记录相关资讯 + // 不送GE至WGS + // 不更新名片资料 + if (unlock) { +#ifdef _UNLOCKPOOL + if( addUnlockPool( ti, id, charname, process, mesgid) <0 ) { +#else + if( addWorkerTask( id , "dummy" , "3" , dummyCallback , ti , + id , "dummy" , charname , process ,"", + mesgid , 0 ) < 0 ) { +#endif + log("游戏退出失败, 进程=%s\n" , process ); + } else { + log("游戏退出成功, 进程=%s\n" , process ); + } + } else { + log("自动保存\n\n"); + } + log("在线玩家保存\n"); +} +#endif + + +void saacproto_ACCharList_recv( int ti,char* id,char* pas , int mesgid) +{ + static int process=0; + char buf[10]; + + //log(" get_charlist "); + + process++; + if (process > MAX_PROCESS) process=1; + snprintf(buf, sizeof(buf), "%d", process); + +#ifdef _CHANGEGALAXY + if( isChangeGalaxyLocked( id) ) { + log(" 因星系移民被锁 "); + saacproto_ACCharList_send( ti , FAILED , "CHANGE_GALAXY" , mesgid ); + return; + } +#endif + + if( !is_game_server_login( ti ) ){ + saacproto_ACCharList_send( ti , FAILED , "not login" , mesgid ); + return; + } + if( addWorkerTask( id , pas , "1" , charListCallback , ti , id , pas , "", buf ,"0", + mesgid , 0 ) < 0 ){ + saacproto_ACCharList_send( ti , FAILED , "server load too high", + mesgid ); + return; + } + log( "档案列表: %s\n", id ); +} + +void saacproto_ACCharDelete_recv( int ti,char* id,char* pas, + char* charname , char *option , int mesgid) +{ + + if( !is_game_server_login(ti) ){ + saacproto_ACCharDelete_send( ti , FAILED , "not login" , mesgid ); + return; + } +#ifdef _DEATH_FAMILY_LOGIN_CHECK //无法删除人物资料 + saacproto_ACCharDelete_send( ti , FAILED , "server load too high", + mesgid ); + return; +#endif + +#ifdef _DEATH_CONTEND //无法删除人物资料 + saacproto_ACCharDelete_send( ti , FAILED , "server load too high", + mesgid ); + return; +#endif + // Nuke + if( addWorkerTask( id , pas , "4" , charDeleteCallback , ti , + id , pas , charname , "0" ,"", + mesgid , 0 ) < 0 ){ + saacproto_ACCharDelete_send( ti , FAILED , "server load too high", + mesgid ); + return; + } + log( "档案删除: 附加作业 %s %s\n",id , pas ); +} + +void saacproto_ACLock_recv( int ti ,char* id,int lock,int mesgid ) +{ + if( !is_game_server_login(ti) ){ + saacproto_ACLock_send( ti , FAILED , "not login" , mesgid ); + return; + } + // Arminius 7.25 test unlock + log("ACLock recv:%d\n",lock); + if (lock==2) { + char buf[4096]; + if (GetMemLockState(getHash(id) & 0xff, id, buf)) { + sprintf(retdata, "USRLOCKED:%s", buf); + } else { + sprintf(retdata, "USRUNLOCKED:%s", buf); + } + log(retdata); + } else if (lock==3) { + int proc; + if (DeleteMemLock(getHash(id) & 0xff, id, &proc)) { + sprintf(retdata, "GMUNLOCKSUCCESS"); + } else { + sprintf(retdata, "GMUNLOCKFAIL"); + } + log(retdata); + } else if (lock==4) { + DeleteMemLockServer(id); + sprintf(retdata, "GMUNLOCKALL"); + } else { +#ifdef _LOCK_ADD_NAME + if ( lockUser( getGSName( ti ) , id , "" , "0" , lock , result,sizeof(result), + retdata ,sizeof( retdata ) , "0" , "0") < 0 ) { +#else + if ( lockUser( getGSName( ti ) , id , "0" , lock , result,sizeof(result), + retdata ,sizeof( retdata ) , "0" , "0") < 0 ) { +#endif + log( "锁定用户: %s 失败\n" , id ); + } else { + log( "锁定用户: %s 成功\n" , id ); + } + } + // Spock end + saacproto_ACLock_send( ti , result , retdata , mesgid ); +} + +void saacproto_ACUCheck_recv( int ti , char *id , int status ) +{ + if( !is_game_server_login(ti) ){ + log( "UCHECK: server not logging in: ID:%s status:%d\n", + id, status ); + return; + } + + if( status == 0 ){ + log( "UCHECK: user %s is not locked by %s\n", id , getGSName( ti ) ); +#ifdef _DELAY_UNLOCK + //remeber the cdkey into delay unlock list. + if( UNlockM_addPlayer( id) != -1 ){ + log( "remeber:[%s] unlock 15min later!!\n", id); + saacproto_ACKick_recv( ti, id, 6, -1); //unlock + } +#ifdef _WAEI_KICK + saacproto_ACKick_recv( ti, id, 1, -1); +#endif +#endif + } else { + log( "UCHECK: user %s is still locked by %s\n", + id , getGSName( ti ) ); +#ifdef _WAEI_KICK + saacproto_ACKick_recv( ti, id, 1, -1); +#endif + } +} + + + +void saacproto_DBUpdateEntryString_recv( int fd, + char* table, + char* key, + char* value, + int msgid, + int msgid2 ) +{ + int r; + r = dbUpdateEntryString( table, key, value ); + + if( r != 0 ){ + log( "failed: DBUpdateEntryString err !!\n"); + } +/* 2003/06/26 + if( r == 0 ){ +// saacproto_DBUpdateEntryString_send( fd, SUCCESSFUL,table,key, + msgid,msgid2 ); + } else { +// saacproto_DBUpdateEntryString_send( fd, FAILED,table,key, + msgid,msgid2 ); + } +*/ +} + + +void saacproto_DBDeleteEntryString_recv( int fd, + char* table, + char* key, + int msgid, + int msgid2 ) +{ + int r; + + r = dbDeleteEntryString( table,key ); + if( r == 0 ){ + saacproto_DBDeleteEntryString_send( fd,SUCCESSFUL,table,key, + msgid,msgid2 ); + } else { + saacproto_DBDeleteEntryString_send( fd,FAILED,table,key, + msgid,msgid2 ); + } +} + + +void saacproto_DBGetEntryString_recv( int fd, + char* table, + char* key, + int msgid, + int msgid2 ) +{ + char output[16384]; + int r; + r = dbGetEntryString( table, key, output, sizeof( output) ); + if( r == 0 ){ + saacproto_DBGetEntryString_send( fd,SUCCESSFUL,output,table,key, + msgid,msgid2 ); + } else { + saacproto_DBGetEntryString_send( fd,FAILED,"",table,key, + msgid,msgid2 ); + } + +} + + + +void saacproto_DBUpdateEntryInt_recv( int fd, + char* table, + char* key, + int value, + char *info, + int msgid, + int msgid2) +{ + if( !is_game_server_login(fd) ){ + saacproto_DBUpdateEntryInt_send( fd, FAILED, "","",msgid, msgid2 ); + return; + } + if( dbUpdateEntryInt( table , key , value, info ) == 0 ){ + saacproto_DBUpdateEntryInt_send( + fd , SUCCESSFUL ,table,key, msgid, msgid2 ); + } else { + saacproto_DBUpdateEntryInt_send( fd , FAILED , table,key, msgid, msgid2 ); + } +} + +#ifdef _ALLDOMAN // (不可开) Syu ADD 排行榜NPC +void saacproto_UpdataStele_recv( int fd , char *cdkey , char *name , char *title , + int level , int trns , int time , int floor ) +{ +#ifdef _FIX_ALLDOMAN + int i, j; + + if( !strcmp( cdkey , "FirstLoad") ){ + Send_A_herolist( fd ); + }else{ + for( i=0; ii; j--){ //20031001bug (原j++) + sprintf( Herolist[j].strings[0], "%s", Herolist[j-1].strings[0] ); + sprintf( Herolist[j].strings[1], "%s", Herolist[j-1].strings[1] ); + sprintf( Herolist[j].strings[2], "%s", Herolist[j-1].strings[2] ); + Herolist[j].intdata[0] = Herolist[j-1].intdata[0]; + Herolist[j].intdata[1] = Herolist[j-1].intdata[1]; + Herolist[j].intdata[2] = Herolist[j-1].intdata[2]; + Herolist[j].intdata[3] = Herolist[j-1].intdata[3]; + Herolist[j].use = Herolist[j-1].use; + Herolist[j-1].use = 0; + } + sprintf( Herolist[i].strings[0], "%s", cdkey ); + sprintf( Herolist[i].strings[1], "%s", name ); + sprintf( Herolist[i].strings[2], "%s", title ); + Herolist[i].intdata[0] = level; + Herolist[i].intdata[1] = trns; + Herolist[i].intdata[2] = time; + Herolist[i].intdata[3] = floor; + Herolist[i].use = 1; + Send_S_herolist( i); + break; + } + SAVE_herolist( fd); + } +#else + int i, min=140, minnum=-1, nameflag=-1; + for ( i=0; i atoi(Herolist[nameflag][6]) ) { + Send_S_herolist ( Herolist[nameflag][0] , Herolist[nameflag][1] , + cdkey , name , title , level , trns , floor ) ; + sprintf ( Herolist[nameflag][2] , "%s" , title ) ; + sprintf ( Herolist[nameflag][3] , "%d" , level ) ; + sprintf ( Herolist[nameflag][4] , "%d" , trns ) ; + sprintf ( Herolist[nameflag][5] , "%d" , time ) ; + sprintf ( Herolist[nameflag][6] , "%d" , floor ) ; + SAVE_herolist( fd ); + }else if ( nameflag == -1 && floor > min ) { + Send_S_herolist ( Herolist[minnum][0] , Herolist[minnum][1] , + cdkey , name , title , level , trns , floor ) ; + sprintf ( Herolist[minnum][0] , "%s" , cdkey ) ; + sprintf ( Herolist[minnum][1] , "%s" , name ) ; + sprintf ( Herolist[minnum][2] , "%s" , title ) ; + sprintf ( Herolist[minnum][3] , "%d" , level ) ; + sprintf ( Herolist[minnum][4] , "%d" , trns ) ; + sprintf ( Herolist[minnum][5] , "%d" , time ) ; + sprintf ( Herolist[minnum][6] , "%d" , floor ) ; + SAVE_herolist( fd ); + } +#endif +} +#endif + +void saacproto_DBGetEntryRank_recv( int fd, + char* table, + char* key, + int msgid, + int msgid2) +{ + int rk,c; + + if( !is_game_server_login(fd) ){ + saacproto_DBGetEntryRank_send( fd, FAILED, 0,0,"","",msgid, msgid2 ); + return; + } + + dbGetEntryRank( table, key , &rk, &c ); + if( rk <0 ){ + saacproto_DBGetEntryRank_send( + fd, FAILED, -1, -1, table, key, msgid, msgid2 ); + } else { + saacproto_DBGetEntryRank_send( fd, SUCCESSFUL, + rk, c, table, key, msgid, msgid2 ); + } +} + + +void saacproto_DBDeleteEntryInt_recv( int fd, + char* table, + char* key, + int msgid, + int msgid2) +{ + if( !is_game_server_login(fd) ){ + saacproto_DBDeleteEntryInt_send( fd, FAILED,"","",msgid, msgid2 ); + return; + } + + if( dbDeleteEntryInt( table, key ) < 0 ){ + saacproto_DBDeleteEntryInt_send( + fd, FAILED, table, key, msgid, msgid2 ); + } else { + saacproto_DBDeleteEntryInt_send( + fd, SUCCESSFUL, table, key, msgid, msgid2 ); + } +} + + +void saacproto_DBGetEntryInt_recv( int fd, + char* table, + char* key, + int msgid, + int msgid2) +{ + int r ; + int output; + + if( !is_game_server_login(fd) ){ + saacproto_DBGetEntryInt_send( fd, FAILED,-1,"","",msgid, msgid2 ); + return; + } + + r = dbGetEntryInt( table, key, &output ); + + if( r < 0 ){ + saacproto_DBGetEntryInt_send( fd, + FAILED, -1, table, key, msgid, msgid2); + } else { + saacproto_DBGetEntryInt_send( + fd, SUCCESSFUL, output, table, key, msgid, msgid2 ); + } + +} + + +void saacproto_DBGetEntryByRank_recv( int fd, + char* table, + int start, int end, + int msgid , + int msgid2) +{ + char output[16384]; + int r; + + if( !is_game_server_login(fd) ){ + saacproto_DBGetEntryByRank_send( fd, FAILED,"","",msgid, msgid2 ); + return; + } + + r = dbGetEntryRankRange( table, start, end, output, sizeof( output )); + + if( r < 0 ){ + saacproto_DBGetEntryByRank_send( + fd, FAILED, "", table, msgid, msgid2 ); + } else { + saacproto_DBGetEntryByRank_send( + fd, SUCCESSFUL, output,table, msgid, msgid2 ); + } +} + +void saacproto_DBGetEntryByCount_recv( int fd, + char* table, + int count_start, + int num, + int msgid , + int msgid2) +{ + char output[16384]; + int r; + + if( !is_game_server_login(fd) ){ + saacproto_DBGetEntryByCount_send( + fd, FAILED,"",table,count_start,msgid, msgid2 ); + return; + } + + r = dbGetEntryCountRange( table, count_start, num, output, sizeof(output)); + + if( r < 0 ){ + saacproto_DBGetEntryByCount_send( fd, FAILED, "", table, + count_start, msgid, msgid2 ); + } else { + saacproto_DBGetEntryByCount_send( fd, SUCCESSFUL, output, table, + count_start, msgid, msgid2 ); + } +} + +void saacproto_Broadcast_recv( int fd, char* id, char* charname, char* message, int flag) +{ + if( !is_game_server_login( fd) ){ + log( "Broadcast: no login. id:%s charname:%s message:%s flag:%d\n", + id, charname, message , flag ); + return; + } + gmsvBroadcast( fd, id, charname, message , flag ); +} + + +void saacproto_Message_recv( int fd, + char* id_from, + char* charname_from, + char* id_to, + char* charname_to, + char* message, + int option ) +{ + receiveMail( id_from, charname_from, + id_to, charname_to, message, option ,0,0); +} + +void saacproto_MessageAck_recv( int fd, + char* id, + char* charname, + char* result, + int mesgid ) +{ + int a; + if( strcmp( result, SUCCESSFUL ) )a=0; else a =-1; + receiveMailAck( id, charname, a , mesgid ); +} + +void saacproto_MessageFlush_recv( int fd, + char* id, + char* charname ) +{ + flushMail( fd, id , charname ); +} + +/******************************************************* + * CoolFish: Family 2001/5/18 + ******************************************************/ +#ifdef _PERSONAL_FAME +void saacproto_ACAddFM_recv( int fd, char *fmname, char *fmleadername, + char *fmleaderid, int fmleaderlv, char *petname, char *petattr, + char *fmrule, int fmsprite, int fmleadergrano, int fame, int charfdid) +#else +void saacproto_ACAddFM_recv( int fd, char *fmname, char *fmleadername, + char *fmleaderid, int fmleaderlv, char *petname, char *petattr, + char *fmrule, int fmsprite, int fmleadergrano, int charfdid) +#endif +{ +#ifdef __FAMILY + int r = 0, index = 0; +#ifdef _PERSONAL_FAME + r = ACAddFM(fd, &index, fmname, fmleadername, fmleaderid, fmleaderlv, + petname, petattr, fmrule, fmsprite, fmleadergrano, fame, charfdid); +#else + r = ACAddFM(fd, &index, fmname, fmleadername, fmleaderid, fmleaderlv, + petname, petattr, fmrule, fmsprite, fmleadergrano, charfdid); +#endif + if (r < 0){ + saacproto_ACAddFM_send(fd, FAILED, r, index, charfdid); + }else{ + saacproto_ACAddFM_send(fd, SUCCESSFUL, r, index, charfdid); + } +#endif +} + +void saacproto_ACJoinFM_recv(int fd, char *fmname, int fmindex, +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + char *charname, char *charid, int charlv, int index, int fame, int charfdid) +#else + char *charname, char *charid, int charlv, int index, int charfdid) +#endif +{ +#ifdef __FAMILY + int r = 0; +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + r = ACJoinFM(fd, index, fmname, fmindex, charname, charid, charlv, fame, charfdid); +#else + r = ACJoinFM(fd, index, fmname, fmindex, charname, charid, charlv, charfdid); +#endif + if (r < 0){ + saacproto_ACJoinFM_send(fd, FAILED, r, charfdid); + }else{ + saacproto_ACJoinFM_send(fd, SUCCESSFUL, r, charfdid); + } +#endif +} + +void saacproto_ACLeaveFM_recv(int fd, char *fmname, int fmindex, + char *charname, char *charid, int index, int charfdid) +{ +#ifdef __FAMILY + int r = 0; + r = ACLeaveFM(index, fmname, fmindex, charname, charid); + if (r < 0){ + saacproto_ACLeaveFM_send(fd, FAILED, r, charfdid); + }else{ + saacproto_ACLeaveFM_send(fd, SUCCESSFUL, r, charfdid); + } +#endif +} + +#ifdef _LEADERFUNCHECK +void saacproto_ACDelFM_recv(int fd, char *fmname, int fmindex, + int index, char *charname, char *charid, int charfdid) +{ + int r = 0, result = 0; + result = CheckLeaderQ(index, fmname, fmindex, charname, charid); + if(result < 0) + { + saacproto_ACDelFM_send(fd, FAILED, charfdid); + return; + } + // shan modify begin + // original + /*if (ChangeFMLeader(index, fmname, fmindex) < 0) + r = ACDelFM(index, fmname, fmindex); + else + r = -1; // shan 1 -> -1 + if (r < 0) + saacproto_ACDelFM_send(fd, FAILED, charfdid); + else + saacproto_ACDelFM_send(fd, SUCCESSFUL, charfdid); + */ + r = ACDelFM(index, fmname, fmindex); + if (r < 0) + saacproto_ACDelFM_send(fd, FAILED, charfdid); + else + saacproto_ACDelFM_send(fd, SUCCESSFUL, charfdid); + // shan end +} +#else +void saacproto_ACDelFM_recv(int fd, char *fmname, int fmindex, + int index, int charfdid) +{ +#ifdef __FAMILY + int r = 0; +#ifdef _FMVER21 + if (ChangeFMLeader(index, fmname, fmindex) >= 0) + r = ACDelFM(index, fmname, fmindex); + else r = 1; +#else + r = ACDelFM(index, fmname, fmindex); +#endif + if (r < 0){ + saacproto_ACDelFM_send(fd, FAILED, charfdid); + } +#ifdef _FMVER21 + else if (r == 1){ + } +#endif + else{ + saacproto_ACDelFM_send(fd, SUCCESSFUL, charfdid); + } +#endif +} +#endif + +void saacproto_ACShowFMList_recv(int fd) +{ +#ifdef __FAMILY + int r = 0; + char data[150 * MAX_FAMILY]; + r = ACShowFMList(data); + if (r < 0){ + saacproto_ACShowFMList_send(fd, FAILED, r, "Nothing"); + }else{ + saacproto_ACShowFMList_send(fd, SUCCESSFUL, r, data); + } +#endif +} + +#ifdef _DEATH_FAMILY_GM_COMMAND // WON ADD 家族战GM指令 +void saacproto_ACShowMemberList_2_recv( int fd, int charindex, int fm1, int fm2, int time, int id ) +{ + char *fm1_name, *fm2_name; + + log("\n won test 7.2 ==> fm1(%d) fm2(%d) time(%d) id(%d)", fm1, fm2, time, id ); + + fm1_name = get_fm_leader_index( fm1 ); + fm2_name = get_fm_leader_index( fm2 ); + log("\n won test 7.3 ==> fm1_name(%s) fm2_name(%s)", fm1_name, fm2_name ); + + saacproto_ACSHOWMEMBERLIST_2_send( fd, charindex, fm1, fm1_name, fm2, fm2_name, time, id ); + +} +#endif + + +void saacproto_ACShowMemberList_recv(int fd, int index) +{ +#ifdef __FAMILY + int r = 0, fmacceptflag = 0, fmjoinnum = 0; + char data[150 * MAX_MEMBERNUM]; + r = ACShowFMMemberList(index, &fmacceptflag, &fmjoinnum, data); + if (r < 0){ + saacproto_ACShowMemberList_send(fd, FAILED, index, r, + fmacceptflag, fmjoinnum, "Nothing"); + }else{ + saacproto_ACShowMemberList_send(fd, SUCCESSFUL, index, r, + fmacceptflag, fmjoinnum, data); + } +#endif +} + +void saacproto_ACFMDetail_recv(int fd, char *fmname, + int fmindex, int index, int charfdid) +{ +#ifdef __FAMILY + int r = 0; + char data[15000]; + r = ACFMDetail(index, fmname, fmindex, data); + if (r < 0){ + saacproto_ACFMDetail_send(fd, FAILED, "Nothing", charfdid); + }else{ + saacproto_ACFMDetail_send(fd, SUCCESSFUL, data, charfdid); + } +#endif +} + +#ifdef _FMVER21 +void saacproto_ACMemberJoinFM_recv(int fd, char *fmname, int fmindex, + char *charname, int charindex, int index, int result, int meindex, + int charfdid) +#else +void saacproto_ACMemberJoinFM_recv(int fd, char *fmname, int fmindex, + char *charname, int charindex, int index, int result, int charfdid) +#endif +{ + int r = 0; +#ifdef _FMVER21 + r = ACMemberJoinFM(index, fmname, fmindex, charname, charindex, result, meindex); +#else + r = ACMemberJoinFM(index, fmname, fmindex, charname, charindex); +#endif + if (r < 0){ + saacproto_ACMemberJoinFM_send(fd, FAILED, charfdid); + }else{ + saacproto_ACMemberJoinFM_send(fd, SUCCESSFUL, charfdid); + } +} + +#ifdef _FMVER21 +void saacproto_ACMemberLeaveFM_recv(int fd, char *fmname, int fmindex, + char *charname, int charindex, int index, int meindex, int charfdid) +#else +void saacproto_ACMemberLeaveFM_recv(int fd, char *fmname, int fmindex, + char *charname, int charindex, int index, int charfdid) +#endif +{ +#ifdef __FAMILY + int r = 0; + int flag = 1; // 主动离开家族 +#ifdef _FMVER21 + r = ACMemberLeaveFM(index, fmname, fmindex, charname, flag, + charindex, meindex); +#else + r = ACMemberLeaveFM(index, fmname, fmindex, charname, flag, charindex); +#endif + if (r < 0){ + saacproto_ACMemberLeaveFM_send(fd, FAILED, charfdid); + }else{ + saacproto_ACMemberLeaveFM_send(fd, SUCCESSFUL, charfdid); + } +#endif +} + +#ifdef _FM_MODIFY +void saacproto_ACFMCharLogin_recv(int fd, char *fmname, int fmindex, + char *charname, char *charid, int charlv, int eventflag, int charfdid,int gsnum) +#else + #ifdef _FMVER21 + void saacproto_ACFMCharLogin_recv(int fd, char *fmname, int fmindex, + char *charname, char *charid, int charlv, int eventflag, int charfdid) + #else + void saacproto_ACFMCharLogin_recv(int fd, char *fmname, int fmindex, + char *charname, char *charid, int charlv, int charfdid) + #endif +#endif +{ +#ifdef __FAMILY + int r = 0, floor = 0, fmpopular = 0, joinflag = 0, fmsetupflag = 0; + int flag = 0, charindex = 0; +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + int charfame = 0; +#endif +#ifdef _NEW_MANOR_LAW + int momentum = 0; +#endif +#ifdef _FM_MODIFY + r = ACFMCharLogin(fd, -1, fmname, fmindex, charname, charid, charlv, + &floor, &fmpopular, &joinflag, &fmsetupflag, &charindex, charfdid, + &charfame, eventflag,gsnum + #ifdef _NEW_MANOR_LAW + ,&momentum + #endif + ); +#else + #ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + r = ACFMCharLogin(fd, -1, fmname, fmindex, charname, charid, charlv, + &floor, &fmpopular, &joinflag, &fmsetupflag, &charindex, charfdid, + &charfame, eventflag); + #else + r = ACFMCharLogin(fd, -1, fmname, fmindex, charname, charid, charlv, + &floor, &fmpopular, &joinflag, &fmsetupflag, &charindex, charfdid); + #endif +#endif + +#ifdef _PERSONAL_FAME // Arminius: 家族个人声望 + if (r < 0){ + saacproto_ACFMCharLogin_send(fd, FAILED, r, floor, fmpopular, + joinflag, fmsetupflag, flag, charindex, charfame, charfdid + #ifdef _NEW_MANOR_LAW + ,momentum + #endif + ); + }else{ + saacproto_ACFMCharLogin_send(fd, SUCCESSFUL, r, floor, fmpopular, + joinflag, fmsetupflag, flag, charindex, charfame, charfdid + #ifdef _NEW_MANOR_LAW + ,momentum + #endif + ); + } +#else + if (r < 0){ + saacproto_ACFMCharLogin_send(fd, FAILED, r, floor, fmpopular, + joinflag, fmsetupflag, flag, charindex, charfdid); + }else{ + saacproto_ACFMCharLogin_send(fd, SUCCESSFUL, r, floor, fmpopular, + joinflag, fmsetupflag, flag, charindex, charfdid); + } +#endif + +#endif +} + +void saacproto_ACFMCharLogout_recv(int fd, char *fmname, int fmindex, + char *charname, char *charid, int charlv, int index,int charfdid) +{ +#ifdef __FAMILY + int r = 0; + r = ACFMCharLogout(index, fmname, fmindex, charname, charid, charlv, + charfdid); + if (r < 0){ + saacproto_ACFMCharLogout_send(fd, FAILED, charfdid); + }else{ + saacproto_ACFMCharLogout_send(fd, SUCCESSFUL, charfdid); + } +#endif +} + +void saacproto_ACFMReadMemo_recv(int fd, int index) +{ + +#ifdef __FAMILY + int r = 0, dataindex; + char data[15000]; + r = ACFMReadMemo(index, &dataindex, data); + if (r < 0){ + saacproto_ACFMReadMemo_send(fd, FAILED, index, r, dataindex, "Nothing"); + }else{ + saacproto_ACFMReadMemo_send(fd, SUCCESSFUL, index, r, dataindex, data); + } +#endif + +} + +void saacproto_ACFMWriteMemo_recv(int fd, char *fmname, int fmindex, + char *data, int index) +{ +#ifdef __FAMILY + int r = 0; + r = ACFMWriteMemo(index, fmname, fmindex, data); + if (r < 0){ + saacproto_ACFMWriteMemo_send(fd, FAILED, index); + }else{ + saacproto_ACFMWriteMemo_send(fd, SUCCESSFUL, index); + } +#endif +} + +void saacproto_ACFMPointList_recv(int fd) +{ +#ifdef __FAMILY + int r = 0; + char data[15000]; + r = ACFMPointList(data); + if (r < 0) + { + saacproto_ACFMPointList_send(fd, FAILED, "nothing"); + }else{ + saacproto_ACFMPointList_send(fd, SUCCESSFUL, data); + } +#endif +} + + + +#ifdef _CK_ONLINE_PLAYER_COUNT // WON ADD 计算线上人数 +void PlayerCount(void) +{ + int i, total_count=0; + char msg[64], out_msg[1024]; + FILE *fpcount; + extern gmsv gs[MAXCONNECTION]; + + strcpy(out_msg, ""); + + for(i=0; i0%%\n", gs[i].name, online_player[i].playcount ); + strcat( out_msg, msg ); + total_count += online_player[i].playcount; + } + } + sprintf(msg, "-----------------------\n"); + strcat( out_msg, msg ); + sprintf(msg, "Total:%d\n", total_count); + strcat( out_msg, msg ); + + fpcount = fopen("count.txt","w"); + if (fpcount!=NULL){ + fprintf(fpcount,"%s", out_msg ); + fclose(fpcount); + } + +} + +void saacproto_GS_ACK_PLAYER_COUNT_recv( int fd, int playcount ) +{ + online_player[fd].playcount = playcount; +} +#endif + + + + +void saacproto_ACSetFMPoint_recv(int fd, char *fmname, int fmindex, + int index, int fmpointindex, int fl, int x, int y, int charfdid) +{ +#ifdef __FAMILY + int r = 0; + r = ACSetFMPoint(index, fmname, fmindex, fmpointindex, fl, x, y); + if (r < 0){ + saacproto_ACSetFMPoint_send(fd, FAILED, r, charfdid); + }else{ + saacproto_ACSetFMPoint_send(fd, SUCCESSFUL, r, charfdid); + } +#endif +} + +void saacproto_ACFixFMPoint_recv(int fd, char *winfmname, int winfmindex, int winindex, + char *losefmname, int losefmindex, int loseindex, int village) +{ +#ifdef __FAMILY + int r = 0; + r = ACFixFMPoint(winindex, winfmname, winfmindex, + loseindex, losefmname, losefmindex, village); + if (r < 0){ + saacproto_ACFixFMPoint_send(fd, FAILED, r); + }else{ + saacproto_ACFixFMPoint_send(fd, SUCCESSFUL, r); + } +#endif +} + +void saacproto_ACFMAnnounce_recv(int fd, char *fmname, int fmindex, int index, + char *data, int color) +{ +#ifdef __FAMILY + int r = 0, i = 0; + r = ACFMAnnounce(fmname, fmindex, index, data, color); + if (r < 0){ + saacproto_ACFMAnnounce_send(fd, FAILED, fmname, fmindex, index, + 1, data, color); + }else{ + extern gmsv gs[MAXCONNECTION]; + for (i = 0; i < MAXCONNECTION; i ++) + { + if (gs[i].use && gs[i].name[0]) + { + saacproto_ACFMAnnounce_send(i, SUCCESSFUL, fmname, fmindex, + index, 1, data, color); + } + } + } +#endif +} + +void saacproto_ACShowTopFMList_recv(int fd, int kindflag) +{ +#ifdef __FAMILY + int r = 0; + char data[150 * MAX_FAMILY]; + strcpy(data, ""); + r = ACShowTopFMList(data, sizeof(data), kindflag); + if (r < 0) { + saacproto_ACShowTopFMList_send(fd, FAILED, kindflag, r, "Nothing"); + }else { + saacproto_ACShowTopFMList_send(fd, SUCCESSFUL, kindflag, r, data); + } +#endif +} + +#ifdef _FAMILYBANKSTONELOG +void saacproto_ACgetFMBankgold_recv(int fd, char *fmname, int fmindex, + int index, int charindex, int charfdid) +{ + int r = 0; + r = ACgetFMBankgold(index, fmname, fmindex, charindex); + saacproto_ACgetFMBankgold_send(fd,charfdid,r); +} +#endif +void saacproto_ACFixFMData_recv(int fd, char *fmname, int fmindex, int index, + int kindflag, char *data1, char *data2, int charindex, int charfdid) +{ +#ifdef __FAMILY + int r = 0; + r = ACFixFMData(index, fmname, fmindex, kindflag, charindex, data1, data2); + if (r < 0){ + saacproto_ACFixFMData_send(fd, FAILED, kindflag, data1, data2, charfdid); + }else{ + saacproto_ACFixFMData_send(fd, SUCCESSFUL, kindflag, data1, data2, charfdid); + } +#endif +} + +void saacproto_ACFixFMPK_recv(int fd, char *winfmname, int winfmindex, int winindex, + char *losefmname, int losefmindex, int loseindex) +{ +#ifdef __FAMILY + int r = 0; + r = ACFixFMPK(winindex, winfmname, winfmindex, + loseindex, losefmname, losefmindex); + if (r < 0){ + saacproto_ACFixFMPK_send(fd, FAILED, r, winindex, + loseindex); + }else{ + saacproto_ACFixFMPK_send(fd, SUCCESSFUL, r, winindex, + loseindex); + } +#endif +} + +void saacproto_ACGMFixFMData_recv(int fd, int index, char *charid, char *cmd, + char *data, int charfdid) +{ +#ifdef __FAMILY + int r = 0; + char fmname[256]; + r = ACGMFixFMData(index, fmname, charid, cmd, data); + if (r < 0){ + saacproto_ACGMFixFMData_send(fd, FAILED, fmname, charfdid); + } + else{ + saacproto_ACGMFixFMData_send(fd, SUCCESSFUL, fmname, charfdid); + } +#endif +} + +void saacproto_ACGetFMData_recv(int fd, char *fmname, int fmindex, int index, + int kindflag, int charfdid) +{ +#ifdef __FAMILY + int r = 0, data = 0; + r = ACGetFMData(index, fmname, fmindex, kindflag, &data); + if (r < 0){ + saacproto_ACGetFMData_send(fd, FAILED, kindflag, data, charfdid); + }else{ + saacproto_ACGetFMData_send(fd, SUCCESSFUL, kindflag, data, charfdid); + } +#endif +} + +void saacproto_ACreLoadFmData_recv(int fd, int type, int data) +{ + int i=0; +extern gmsv gs[MAXCONNECTION]; + switch( type){ + case 1: + log( "reload FM_DATA:%d !\n", data); + readOneFamilyFromTi( data); + break; + case 2: + { + char data[15000]; + readFMPoint( fmpointdir); + if( ACFMPointList( data) >= 0 ){ + log( "reload FM_POINT !\n" ); + for (i=0; i MAX_FMPOINT) return; + saacproto_ACLoadFmPk_send( fd, FMPK_GetData( fmpks_pos-1) ); +} + +void saacproto_ACSendFmPk_recv(int fd, int fmpks_pos, int userindex, int flg, char *data) +{ + extern gmsv gs[MAXCONNECTION]; + char buf[1024]; + int i=0; + sprintf( buf, "%d|%s", fmpks_pos, data); + + if( ( userindex != -1 && FMPK_GetTypeFlg( fmpks_pos-1) == 1 )|| + FMPK_SetData( fmpks_pos-1, flg, buf, strlen( buf)) != 1 ){ + if(userindex != -1) saacproto_ACSendFmPk_send( fd, userindex, 0); + log("err ACSendFmPk_send(%d, %d)\n", userindex, 0); + return; + } + FMPK_BackUpList(); + for (i=0; i MAX_FMPOINT){ + log("\n fmpks_pos(%d) too big", fmpks_pos); + } + saacproto_ACLoadFmPk_send(fd, fm_pk_list[fmpks_pos-1]); +} +void saacproto_ACSendFmPk_recv(int fd, int fmpks_pos, char *data) +{ + extern gmsv gs[MAXCONNECTION]; + int i=0; + + if( (fmpks_pos>MAX_FMPOINT) || (fmpks_pos<1) ){ + log("\n fmpks_pos(%d) err !!", fmpks_pos); + } + sprintf(fm_pk_list[fmpks_pos-1], "%d|%s", fmpks_pos, data); + + for (i=0; i1) { log("\n char_num(%d) err !!", char_num); return; } + if( date<20000000 ) { log("\n date(%d) format err!!", date); return; } + + + if( backup_flag == 1 ){ // 备份日期 + // 回传有备份的日期 + get_backup_date(fd, uid, userfdid, GmCliId, id, char_num, date); + + }else if( backup_flag == 2 ){ // 人物资料 + get_online_player_data(fd, uid, userfdid, GmCliId, id, char_num, date); // 传回线上人物资料 + get_backup_player_data(fd, uid, userfdid, GmCliId, id, char_num, date); // 传回备份人物资料 + } + +} + +void saacproto_ACRecalBackup_recv(int fd, char *uid, int userfdid, int GmCliId, char *id, + int char_num, int date, char *char_data, int backup_flag) +{ + extern struct ITEM_PET_CHANG item_pet_chang; + char temp[64]; + int i, count=0; + char filename1[128], filename2[128]; + char body[256]; + + if(backup_flag == 1){ // 回溯人物 + // 线上人物 + sprintf(filename1, "~/saac/char/0x%x/%s.%d.char", (getHash(id)&0xff), id, char_num ); + + // 备份人物 + sprintf(filename2, "%s/char/0x%x/%s.%d.char", BACKUP_DIR, (getHash(id)&0xff), id, char_num ); + + // 移动备份人物至线上人物 + strcpy(body, ""); + sprintf(body, "mv %s %s", filename2, filename1); + system(body); + + /* 回溯成功 */ + saacproto_ACRecalPlayer_send(fd, uid, userfdid, GmCliId, id, char_num, date, char_data, 4); + + + }else if(backup_flag == 2 ){ // 部分回溯人物 + + log("\n won test 44 ==> char_data_chang(%s)", char_data); + + // 取出需回溯项目 + for(i=0;i<5;i++){ + memset(temp, 0, sizeof(temp)); + easyGetTokenFromString( char_data , count , temp , sizeof( temp )); + item_pet_chang.equit_item[i] = atoi(temp); count++; + } + for(i=0;i<15;i++){ + memset(temp, 0, sizeof(temp)); + easyGetTokenFromString( char_data , count , temp , sizeof( temp )); + item_pet_chang.have_item[i] = atoi(temp); count++; + } + for(i=0;i<30;i++){ + memset(temp, 0, sizeof(temp)); + easyGetTokenFromString( char_data , count , temp , sizeof( temp )); + item_pet_chang.pool_item[i] = atoi(temp); count++; + } + for(i=0;i<5;i++){ + memset(temp, 0, sizeof(temp)); + easyGetTokenFromString( char_data , count , temp , sizeof( temp )); + item_pet_chang.have_pet[i] = atoi(temp); count++; + } + for(i=0;i<20;i++){ + memset(temp, 0, sizeof(temp)); + easyGetTokenFromString( char_data , count , temp , sizeof( temp )); + item_pet_chang.pool_pet[i] = atoi(temp); count++; + } + + + // 处理部分回溯功能 + recal_part_backup(fd, uid, userfdid, GmCliId, id, char_num, date); + + } + +} + +void recal_part_backup(int fd, char *uid, int userfdid, int GmCliId, char *id, int char_num, int date) +{ +/* + extern struct ITEM_PET_CHANG item_pet_chang; + FILE *fp; + char filename[128], filename2[128], body[128]; + char onlin_char[65500], backup_char[65500]; + char *c_ptr, c_temp; + int i=0; + char *temp=NULL, *temp2, *temp3, *temp4, *temp5, *msg1, delim[20], out_msg[65530]; + + + // 线上人物 + { + c_ptr=onlin_char; + snprintf(body , sizeof(body ) , "%s.%d.char" , id , char_num ); + makeDirFilename(filename , sizeof(filename), chardir , getHash(id) ,body); + + if( !(fp=fopen(filename, "r")) ){ + log("\n open (%s) file err", filename ); return; + } + + memset(onlin_char, 0, sizeof(onlin_char)); + + do{ + c_temp = fgetc(fp); + *c_ptr=c_temp; + c_ptr++; + }while(c_temp != EOF); + *c_ptr='\0'; + + fclose(fp); + } + + // 备份人物 + { + c_ptr=backup_char; + snprintf(body , sizeof(body ) , "%s.%d.char" , id , char_num ); + makeDirFilename(filename , sizeof(filename), chardir , getHash(id) ,body); + + sprintf(filename2, "%s/%s", BACKUP_DIR, filename); + if( !(fp=fopen( filename2, "r" )) ){ + log("\n won test 100 ==> open (%s) file err", filename ); return; + } + + memset(backup_char, 0, sizeof(backup_char)); + + do{ + c_temp = fgetc(fp); + *c_ptr=c_temp; + c_ptr++; + }while(c_temp != EOF); + *c_ptr='\0'; + + fclose(fp); + } + + log("\n won test 1 ==>"); + + { + for(i=0;i<5;i++){ + if( item_pet_chang.equit_item[i] != i ){ + log("\n won test 2 ==> i(%d) item(%d)", i, item_pet_chang.equit_item[i]); + + // 线上人物 + while( temp==NULL ){ + log("\n won test 2.1 ==> temp(%s)", temp); + sprintf( delim, "item%d=", i); + log("\n won test 2.2 ==> delim(%s)", delim); + temp=strstr( onlin_char, delim); + log("\n won test 2.3 ==> temp(%s)", temp); + if((i==0)&&(temp==NULL)){ + sprintf( delim, "flg2="); + temp=strstr( onlin_char, delim); + log("\n won test 2.4 ==> temp(%s)", temp); + break; + } + i--; + } + + + log("\n won test 3 ==> temp(%s)", temp); + temp2=strstr( temp, "\n"); + log("\n won test 3.1 ==> temp2(%s)", temp2); + + msg1=(char*)calloc( 1,sizeof(char)*strlen(onlin_char)-strlen(temp2)+1); + snprintf(msg1, strlen(onlin_char)-strlen(temp2), "%s", onlin_char ); + log("\n won test 3.2 ==> msg1(%s)", msg1); + + // 备份人物 + sprintf( delim, "item%d=", item_pet_chang.equit_item[i]-5+1); + temp3=strstr( backup_char, delim); + temp4=strstr( temp3, "\n"); + temp5=(char*)calloc( 1,sizeof(char)*strlen(temp3)-strlen(temp4)+1); + snprintf(temp5, strlen(temp3)-strlen(temp4), "%s", temp3); + log("\n won test 4 ==> temp5(%s)", temp5); + + // 组合 + memset(out_msg, 0, sizeof(out_msg)); + strcpy(out_msg, msg1); + strcat(out_msg, temp5); // 回溯的部分 + strcat(out_msg, temp2); + log("\n won test 5 ==> out_msg(%s)", out_msg); + } + } + + } +*/ +} +#endif + + +#ifdef _CHECKFMSCHEDULE // Syu ADD 透过AC确认家族挑战排程 +void saacproto_ACCheckSchedule_recv(int fd,char *data) +{ + extern gmsv gs[MAXCONNECTION]; + int i,j; + char filename[256]; + char token[256]; + char line[64]; + char line1[64]; + char line2[64]; + FILE* fpm; + easyGetTokenFromBuf(data, '|', 2, line1, sizeof(line1)); + j = atoi(data); + snprintf( filename ,sizeof( filename ) ,"%s/%d.%s" , + "family",j,"fmschedule.txt"); + + if( !(fpm=fopen( filename , "r")) ) + { + log("\nSyu log open file error!!"); + sprintf(line2,"%d %s",j,"FALSE"); + for (i=0; i %s , %s",line,line1); + if ( atoi(line1) > atoi(line) ) + { + sprintf(line2,"%d %s",j,"TRUE"); + for (i=0; i"); + // 有lock的话踢人 + for(i=0;i"); +#ifdef _LOCK_ADD_NAME + ret = lockUser( getGSName(ti), id , "" , "0" , 0 , result , sizeof( result ) , + retdata , sizeof( retdata ) , "0" , "0"); +#else + ret = lockUser( getGSName(ti), id , "0" , 0 , result , sizeof( result ) , + retdata , sizeof( retdata ) , "0" , "0"); +#endif + snprintf( process , sizeof(process) , "%d" , ret ); +#ifdef _UNLOCKPOOL + if( addUnlockPool( ti, id, "", process, mesgid) <0 ) { +#else + if( addWorkerTask( id , "dummy" , "3" , dummyCallback , ti , + id , "dummy" , charname , process ,"", mesgid , 0 ) < 0 ) { +#endif + log("Game end error, process=%s\n" , process ); + }else { + log("Game end :process=%s\n" , process ); + } + + } + } + break; +#endif + case 10: //跨星球踢人不含load该星球 + { + int i; + for(i=0;i time(%d) loop(%d) wait(%d) \n post_msg(%s)", time, loop, wait, post_msg ); + + for(i=0; i i(%d)", i ); + saacproto_GmBroadcast_send(i, time, loop, wait, post_msg ); + } + } +} +#endif + +#ifdef _SEND_EFFECT // WON ADD 送下雪、下雨等特效 +void SendEffect(char *effect) +{ + extern gmsv gs[MAXCONNECTION]; + int i; + + for (i=0; i filenum err !!"); + return; + } + + sprintf(id_dir, "%x", (getHash(id) & 0xff) ); + + memset(char_data, 0, sizeof(char_data)); + + // 找出符合帐号的备份日期 + for( i = 0 ; i < filenum ; i ++ ){ + if(strcmp(filenames[i].string, "") != 0 ){ + char temp[64]; + get_delim(filenames[i].string, temp, "_0x", ".tar" ); + + if(strcmp(temp, id_dir)==0){ + char temp2[20]; + get_delim(filenames[i].string, temp, "AC_", "_0x" ); + snprintf(temp2, 11, "%s", temp); + strcat( char_data, temp2); + strcat( char_data, "|"); + } + } + } + + saacproto_ACRecalPlayer_send(fd, uid, userfdid, GmCliId, id, char_num, date, char_data, 1); + +} + +// 取得线上人物资料 +void get_online_player_data(int fd, char *uid, int userfdid, int GmCliId, char *id, int char_num, int date) +{ + FILE *fp; + char filename[128]; + char body[128]; + char char_data[65500]; + char *c_ptr, c_temp; + + c_ptr=char_data; + + snprintf(body , sizeof(body ) , "%s.%d.char" , id , char_num ); + makeDirFilename(filename , sizeof(filename), chardir , getHash(id) ,body); + + if( !(fp=fopen(filename, "r")) ){ + log("\n open (%s) file err", filename ); + strcpy(char_data, "无此帐号人物资料"); + saacproto_ACRecalPlayer_send(fd, uid, userfdid, GmCliId, id, char_num, date, char_data, 2); + return; + } + + strcpy(char_data, ""); + + do{ + c_temp = fgetc(fp); + *c_ptr=c_temp; + c_ptr++; + }while(c_temp != EOF); + *c_ptr='\0'; + + fclose(fp); + + if( char_data[0]=='|' && char_data[1]=='|' ){ + log("\n open (%s) file err", filename ); + strcpy(char_data, "此帐号人物资料异常"); + saacproto_ACRecalPlayer_send(fd, uid, userfdid, GmCliId, id, char_num, date, char_data, 2); + return; + } + + // 分析人物资料,取出所需的人物资料 + analysis_char(char_data); + + saacproto_ACRecalPlayer_send(fd, uid, userfdid, GmCliId, id, char_num, date, char_data, 2); + +} + +void send_backup_player_data() +{ + FILE *fp; + char filename[128]; + char char_data[65500]; + char *c_ptr, c_temp; + int fd=-1, userfdid=-1, GmCliId=-1, char_num=-1, date=-1, i, j, count; + char uid[64], id[64], temp[8][64], buf[255]; + + sprintf( filename, "%s", "backup_player_name2.txt"); + if( !(fp=fopen(filename, "r")) ){ + log("\n open backup_player_name2.txt err!!"); + return; + } + + strcpy(buf, ""); + while(1) + if( fscanf( fp, "%s", buf) == EOF ) break; + + fclose(fp); + + for(i=0; i<8; i++) memset(temp[i], 0, sizeof(temp[i]) ); + + i=0; j=0; count=0; + for( i=0; i backup_player_name.txt; ~/saac/recal_player.sh", + filename, fd, uid, userfdid, GmCliId, id, char_num, date, (getHash(id)&0xff) ); + + system(body); + + +} + +void analysis_char(char *char_data) +{ + int i; + char delime[64]; + extern struct PLAYER_DATA player_data; + + char_data_count=0; + + // player name + memset( player_data.name, 0, sizeof(player_data.name) ); + won_get(player_data.name, "", "|"); + + // player information + _won_get_player( char_data ); + + // have item + for(i=0; id_name[0] == '.' )continue; + + snprintf(dirn, sizeof(dirn), "%s/%s" , dirname,dent->d_name ); + if( stat( dirn , &st ) == -1 )continue; + if( S_ISDIR( st.st_mode ) ){ + if( rrd( dirn , buf ,bufsize, index) == -1 ){ + closedir(d); + return -1; + } + }else{ + if( *index >= bufsize ) + break; + + strcpy( buf[*index].string , dirn ); + (*index)++; + } + } + closedir(d); + return 1; +} + +void _won_get_player(char *char_data) +{ + + _won_get_2( char_data, player_data.fl, "nfl=" ); + _won_get_2( char_data, player_data.x, "nx=" ); + _won_get_2( char_data, player_data.y, "ny=" ); + _won_get_2( char_data, player_data.lv, "nlv=" ); + _won_get_2( char_data, player_data.gold, "ngld=" ); + _won_get_2( char_data, player_data.hp, "nhp=" ); + _won_get_2( char_data, player_data.mp, "nmp=" ); + _won_get_2( char_data, player_data.vi, "nvi=" ); + _won_get_2( char_data, player_data.str, "nstr=" ); + _won_get_2( char_data, player_data.tou, "ntou=" ); + _won_get_2( char_data, player_data.dex, "ndx=" ); + _won_get_2( char_data, player_data.exp, "nexp=" ); + _won_get_2( char_data, player_data.trn, "ntrn=" ); + _won_get_2( char_data, player_data.fmi, "nfmi=" ); + _won_get_2( char_data, player_data.fmlf, "nfmlf=" ); + _won_get_2( char_data, player_data.bankgld, "nbankgld=" ); + _won_get_2( char_data, player_data.fame, "nfame=" ); + _won_get_2( char_data, player_data.pgold, "npersonaglod=" ); + _won_get_2( char_data, player_data.fmname, "nfmname=" ); + + +} + +void _won_get_2(char *char_data, char *fun, char *check) +{ + memset( fun , 0, sizeof(fun) ); + won_get( fun, check, "\\n"); +} + +#endif // end RECAL_ASK_PLAYER + +#ifdef _ALLDOMAN // Syu ADD 排行榜NPC +void LOAD_herolist() +{ + FILE *fdb; + int i, linenum=0; + + char filename[256], token[512]; + + snprintf( filename , sizeof( filename ) ,"%s/%s" , "db/herolist","db_herolist.txt"); + if( !( fdb = fopen ( filename , "r+" ) ) ) { + log("\nSyu log open db_herolist.txt error!!"); + return ; + }else { +#ifdef _FIX_ALLDOMAN + int j; + char buf1[256]; + for( i=0; i= MAX_HERO_LIST ) break; + } + fclose( fdb); + + for( i=0; ii; j-- ){ + if( Herolist[j].use == 0 ) continue; + if( !strcmp( Herolist[i].strings[0], Herolist[j].strings[0]) && + !strcmp( Herolist[i].strings[1], Herolist[j].strings[1]) ){ + Herolist[j].use = 0; + } + } + } + for( j=(MAX_HERO_LIST-1); j>0; j-- ){ + if( Herolist[j].use == 0 ) continue; + if( Herolist[j-1].use == 1 ) continue; + + for( i=0; i<3; i++) { + sprintf( Herolist[j-1].strings[i], "%s", Herolist[j].strings[i]); + } + for( i=0; i<4; i++) { + Herolist[j-1].intdata[i] = Herolist[j].intdata[i]; + } + Herolist[j].use = 0; + Herolist[j-1].use = 1; + } + //andy_log + for( i=0; i= 65535 ){ + saacproto_UpdataStele_send ( fd , token ); + memset( token, 0, sizeof(token)); + lens = 0; + } + strcat( token, buf); + lens += strlen( buf); + } + fclose ( fdb ); + if( strlen( token) > 0 ) + saacproto_UpdataStele_send ( fd , token ); +#endif + } +} + +#ifdef _FIX_ALLDOMAN +void Send_S_herolist( int ti ) +{ + int i; + char token[512]; + extern gmsv gs[MAXCONNECTION]; + memset( token, 0, sizeof(token)); + strcat( token, "O|,"); + for (i = 0 ; i < MAXCONNECTION ; i ++ ) { + if ( gs[i].use && gs[i].name[0] ) { + snprintf( token, sizeof(token)-1, "%d|%s|%s|%s|%d|%d|%d|%d|", + ti, + Herolist[ti].strings[0], Herolist[ti].strings[1], Herolist[ti].strings[2], + Herolist[ti].intdata[0], Herolist[ti].intdata[1], + Herolist[ti].intdata[2], Herolist[ti].intdata[3] ); + saacproto_UpdataStele_send ( i, token); + } + } +} +#else +void Send_S_herolist( char *ocdkey , char *oname , char *ncdkey , char *nname , + char *title , int level , int trns , int floor ) +{ + int i; + extern gmsv gs[MAXCONNECTION]; + + for (i = 0 ; i < MAXCONNECTION ; i ++ ) { + if ( gs[i].use && gs[i].name[0] ) { + saacproto_S_UpdataStele_send( i , ocdkey , oname , + ncdkey , nname , title + , level , trns , floor ); + log("\nSyu log AC Send Single to Gmsv "); + } + } +} +#endif +#endif + + +#define MAXUNlockM 50 +#define delaytime (60*3) +UNLockMenus UNlockM[MAXUNlockM]; + +int UNlockM_Init( void) +{ + int i; + for( i=0; i= time(NULL) ) continue; + if( isLocked( UNlockM[i].PlayerId ) ){ + log( "等待解锁玩家: %s 还需锁定!!\n", UNlockM[i].PlayerId); + }else{ + log( "等待解锁玩家: %s 已经解锁!!\n", UNlockM[i].PlayerId); + } + reset_UNlockMPlayer( i); + nums++; + } + log( "等待解锁玩家: 总计 %d 个用户解锁 !!\n", nums); + return nums; +} + + +#ifdef _ANGEL_SUMMON + +extern int saveMissionTable( void ); + +//void saacproto_ACMissionTable_recv( int fd, int num, int type, char *data, int charaindex) +void saacproto_ACMissionTable_recv( int fd, int num, int type, char *data, char* angelinfo) +{ + extern gmsv gs[MAXCONNECTION]; + int i; + char buf[1024]; + + if( type == 1 ) { // ask data list + if( num == -1) { // ask all data + char alldata[MAXMISSIONTABLE*100]; + alldata[0]='\0'; + for( i =0; i use != 0){ + if(strcmp(ln->cdkey,id) == 0 && strcmp(ln->name,name) == 0){ + saacproto_ACCheckCharacterOnLine_send(fd,charaindex,1,ln->server,flag); + return; + } + } + ln = ln->next; + } + // 玩家不在线上 + saacproto_ACCheckCharacterOnLine_send(fd,charaindex,0,"",flag); + } + // 不须要确认名字 + else{ + while(ln != NULL){ + if(ln->use != 0){ + if(strcmp(ln->cdkey,id) == 0){ + saacproto_ACCheckCharacterOnLine_send(fd,charaindex,1,ln->server,flag); + return; + } + } + ln = ln->next; + } + // 玩家不在线上 + saacproto_ACCheckCharacterOnLine_send(fd,charaindex,0,"",flag); + } +} +#endif + +#ifdef _RACEMAN +//racetype 0:登记 9:删除 1~5:读资料 11~55:读资料 +void saacproto_ACRaceRecordandSort_recv( int fd, int charaindex, char *code , char *id, char *name , int racetype, int catchcnt, int ranknum ) +{ + //比较目前的排行 如果可以进入排行榜则写入 并且回传目前的排行榜 + FILE *fp; + char rankfile[64]; + char allfile[64]; + char line[512]; + int i,j,findflag = 0; + char buf[64]; + char data[4096]; //看server要多少笔就塞多少资料 + + //time_t endtime = (time_t)limittime; + //struct tm *limit; + + //time( &endtime ); + //limit = localtime( &endtime ); + //limit->tm_year + 1900 , limit->tm_mon + 1 , limit->tm_mday ); + //now->tm_hour , now->tm_min , now->tm_sec + //USERLOG( id , "ranktable W: successful\n" ); + data[0]='\0'; + memset( ranktable, 0, sizeof(ranktable)); + + sprintf( rankfile , "race/%s.txt", code ); + + fp = fopen( rankfile, "a+"); + if( fp == NULL ){ + log("create file:%s error !!\n", rankfile); + return; + } + if( fseek( fp , 0, SEEK_SET ) == -1 ){ + fprintf( fp ,"Seek Error\n" ); + fclose(fp); + return; + } + + i = 0; + while(1) + { + if(fgets( line, sizeof( line), fp) == NULL) break; + chop(line); + easyGetTokenFromBuf( line, '|', 1, buf, sizeof( buf )); + sprintf( ranktable[i].id, "%s", buf); + easyGetTokenFromBuf( line, '|', 2, buf, sizeof( buf )); + sprintf( ranktable[i].name,"%s", buf); + easyGetTokenFromBuf( line, '|', 3, buf, sizeof( buf )); + ranktable[i].catchcnt = atoi(buf); + i++; + } + fclose(fp); + + if(racetype == 0){ + if(catchcnt >= 230 ){ + sprintf( allfile , "race/%s_a.txt", code ); + fp = fopen( allfile , "a+"); + fprintf(fp,"%s|%s|%d|\n",id,name,catchcnt); + fclose(fp); + } + //处理排名 + fp = fopen( rankfile, "w"); + if( fp == NULL ){ + log("create file:%s error !!\n", rankfile); + return; + } + for(i=0; i < DEFMAXRANK ;i++) + { + + if( catchcnt > ranktable[i].catchcnt){ //只有大於才能把人家挤掉 + for( j=DEFMAXRANK ; j>i+1 ; j-- ) + { + strcpy(ranktable[j-1].id , ranktable[j-2].id); + strcpy(ranktable[j-1].name , ranktable[j-2].name); + ranktable[j-1].catchcnt = ranktable[j-2].catchcnt; + } + strcpy( ranktable[i].id , id); + strcpy( ranktable[i].name , name); + ranktable[i].catchcnt = catchcnt; + catchcnt = 0; + }else{ + if(strcmp(id,ranktable[i].id)==0 && strcmp(name,ranktable[i].name)==0) continue; + } + + if(ranktable[i].catchcnt == 0) break; + + fprintf(fp,"%s|%s|%d|\n",ranktable[i].id , ranktable[i].name , ranktable[i].catchcnt); + } + fclose(fp); + + }else if(racetype == 9){ //清除某笔资料 + + fp = fopen( rankfile, "w"); + if( fp == NULL ){ + log("create file:%s error !!\n", rankfile); + return; + } + for(i=0; i < DEFMAXRANK ;i++) + { + if(ranktable[i].catchcnt == 0) break; + + if(strcmp(id,ranktable[i].id)==0 && strcmp(name,ranktable[i].name)==0) continue; + + fprintf(fp,"%s|%s|%d|\n",ranktable[i].id , ranktable[i].name , ranktable[i].catchcnt); + } + fclose(fp); + + }else{ //server要资料而已 + for(i=0;i atoi(buf)){ + + findflag = 1; + break; + } + } + } + } + if( findflag == 0 ){ + fprintf(fp,"%s|%s|%d|\n",id,name,catchcnt); + } + fclose(fp); + +*/ diff --git a/saac/recv.h b/saac/recv.h new file mode 100644 index 0000000..41067ac --- /dev/null +++ b/saac/recv.h @@ -0,0 +1,145 @@ +#ifndef _RECV_H_ +#define _RECV_H_ + +#ifdef _CK_ONLINE_PLAYER_COUNT // WON ADD 计算线上人数 +void PlayerCount(void); +#endif + +#ifdef _SEND_EFFECT // WON ADD 送下雪、下雨等特效 +void SendEffect(char *ffect); +#endif + +#ifdef _BAD_PLAYER // WON ADD 送坏玩家去关 +void BadPlayer(void); +char BadPlayerList[500][20]; +int MAX_BAD_PLAYER; +#endif + +#ifdef _WORKER_AUTO_LOGOUT // WON ADD GS断线自动送LOGOUT给WORKER +void Worker_send_logout( int ti ,char* id ); +#endif + + +#ifdef _AC_SEND_FM_PK // WON ADD 庄园对战列表储存在AC +void load_fm_pk_list(void); +void save_fm_pk_list(void); +char fm_pk_list[9][255]; +#endif + +#ifdef _ALLDOMAN // Syu ADD 排行榜NPC +void LOAD_herolist(); +void SAVE_herolist(int); +void Send_A_herolist(int); + +#ifdef _FIX_ALLDOMAN +void Send_S_herolist( int ti ); +#define MAX_HERO_LIST 50 +typedef struct _tagHerolistBase +{ + char strings[3][64]; + int intdata[3]; + int use; +}HerolistBase; +HerolistBase Herolist[MAX_HERO_LIST]; +#else +void Send_S_herolist( char *ocdkey , char *oname , char *ncdkey , char *nname , + char *title , int level , int trns , int floor ); +#define MAX_HERO_COLUMN 7 +#define MAX_HERO_LIST 100 +char Herolist[MAX_HERO_LIST][MAX_HERO_COLUMN][72]; +#endif + +#endif + + +#ifdef _RECAL_BACKUP_PLAYER // WON 回溯功能 + +struct PLAYER_DATA { + char name[20]; + char fl[10]; + char x[10]; + char y[10]; + char lv[20]; + char gold[20]; + char hp[20]; + char mp[20]; + char vi[20]; + char str[20]; + char tou[20]; + char dex[20]; + char exp[20]; + char trn[20]; + char fmi[20]; + char fmlf[20]; + char bankgld[20]; + char fame[20]; + char pgold[20]; + char fmname[20]; + char item_name[50][64]; + char item[50][255]; + char pet_name[50][64]; + char pet[25][255]; +}player_data; + + +typedef struct tagSTRING64 +{ + char string[64]; +}STRING64; + +struct ITEM_PET_CHANG{ + int equit_item[5]; + int have_item[15]; + int pool_item[30]; + int have_pet[5]; + int pool_pet[20]; +}item_pet_chang; + +#define won_get(get, delime1, delime2) _won_get(get, delime1, delime2, char_data) +void _won_get(char *get, char *delime1, char *delime2, char *char_data); +void saacproto_ACRecalPlayer_recv(int fd, char *uid, int userfdid, int GmCliId, char *id, int char_num, int date, int backup_flag); +void analysis_char(char *char_data); +int get_delim(char *msg, char *temp, char *delime1, char *delime2); +void get_online_player_data(int fd, char *uid, int userfdid, int GmCliId, char *id, int char_num, int date); +void send_backup_player_data(); +void get_backup_player_data(int fd, char *uid, int userfdid, int GmCliId, char *id, int char_num, int date); +void get_backup_date(int fd, char *uid, int userfdid, int GmCliId, char *id, int char_num, int date); +void saacproto_ACRecalBackup_recv(int fd, char *uid, int userfdid, int GmCliId, char *id, int char_num, int date, char *char_data, int backup_flag); +void recal_part_backup(int fd, char *uid, int userfdid, int GmCliId, char *id, int char_num, int date); +int rgetFileName( char* dirname , STRING64* string, int size); +int rrd( char* dirname , STRING64* buf ,int bufsize, int* index); + + +#define BACKUP_DIR "/home/backup/char" + +void _won_get_player(char *char_data); +void _won_get_2(char *char_data, char *fun, char *check); + + +#endif // end RECAL_ASK_PLAYER + +typedef struct tagUNLOCKMENUS{ + char PlayerId[256]; + int use; + time_t time; +}UNLockMenus; + +int UNlockM_isBe( char *id); +int UNlockM_addPlayer( char *id); +int UNlockM_UnlockPlayer( void); +int UNlockM_Init( void); + + +#ifdef _GM_BROADCAST // WON ADD 客服公告系统 +void broadcast( char *msg ); +#endif + + +#ifdef _DEATH_FAMILY_GM_COMMAND // WON ADD 家族战GM指令 +void saacproto_ACShowMemberList_2_recv( int fd, int charindex, int fm1, int fm2, int time, int id ); +#endif + + + +#endif + diff --git a/saac/saacproto_lserver.c b/saac/saacproto_lserver.c new file mode 100644 index 0000000..8eb3e37 --- /dev/null +++ b/saac/saacproto_lserver.c @@ -0,0 +1,769 @@ +#include "saacproto_lserver.h" +#include "saacproto_serv.h" +#include "main.h" +#include "char.h" +#include "util.h" +#include "version.h" + + +#ifdef _LOCK_SERVER + +LServer Ls; +LSMem *LSbufHead; +SAMessC *SAMess; + +struct timeval select_timeout; +void REreadConfig( char *path ); +BOOL LSbuffInit() +{ + //LSbufHead->next = NULL; + //LSbufHead = NULL; + return TRUE; +} + +BOOL LServerInit() +{ + int i; + if( Ls.data[LS_FD] >= 0 ) + close( Ls.data[LS_FD]); + for( i=0;ih_addr, sizeof( struct in_addr)); + } + r = connect( s , ( struct sockaddr*)&svaddr,sizeof(svaddr)); + if( r < 0 ) return LSMESS_NOCONNECT; + set_nodelay( s ); + Ls.data[LS_FD] = s; + return LS_OK; +} +int LS_getData( int stype) +{ + return Ls.data[stype]; +} + +BOOL TcpIp_LS_accept() +{ + int sret; + struct timeval t; + char tmpbuf[4096]; + char send_buf[4096]; + int lsfd = Ls.data[LS_FD]; + LSMem *FlgMem; + fd_set rfds, wfds , efds; + + FD_ZERO( &rfds ); + FD_ZERO( &wfds ); + FD_ZERO( &efds ); + + select_timeout.tv_sec = 0; + select_timeout.tv_usec = 0; + + if( Ls.data[LS_USE] && (lsfd >= 0 ) && !Ls.errs ) { + FD_SET( lsfd, &rfds ); + FD_SET( lsfd, &wfds ); + FD_SET( lsfd, &efds ); + }else { + log(" LS error t1!!\n"); + return FALSE; + } + + t = select_timeout; + sret = select( lsfd+1, &rfds , (fd_set*)NULL, &efds , &t); + if( sret > 0 ) { + memset( tmpbuf, 0, sizeof( tmpbuf)); + if( ( lsfd >= 0 ) && FD_ISSET( lsfd , &rfds ) ){ + int rr; + rr = read( lsfd, tmpbuf , sizeof( tmpbuf)); + if( rr <= 0 ){ + Ls.errs = 1; + Ls.data[LS_LASTERROR] = LSMESS_READERROR; + } else { + Add_LS_WRMemBuffer( tmpbuf , rr, MEMREAD); //增加讯息 + } + } + } + + t = select_timeout; + sret = select( lsfd+1, (fd_set*)NULL, &wfds, &efds , &t); + if( sret > 0 ) { + if( ( lsfd >= 0 ) && FD_ISSET( lsfd , &wfds )){ + int l , rr, writesize; + FlgMem = NULL; + memset( send_buf, 0, sizeof( send_buf)); + l = MMGet_LS_WRMemBufList( send_buf, sizeof( send_buf), MEMWRITE); + if( l > 0 ){ + writesize = strlen( send_buf)+1; + rr = write( lsfd , send_buf , writesize); + if( rr < 0 ){ + Ls.errs = 1; + } + } + } + } + + return TRUE; +} + +BOOL Add_LS_WRMemBuffer( char *buf, int strlens, int flg) +{ + int i=0; + LSMem *workLS, *FindLs; + FindLs = LSbufHead; + + if( Ls.data[LS_LASTTIME] >= 50 ) { + log( "LS Mess busy:%d\n", Ls.data[LS_LASTTIME]); + return FALSE; + } + while ( 1 ) { + if( FindLs == NULL || FindLs->next == NULL ) + break; + FindLs = FindLs->next; + i++; + } + + Ls.data[LS_LASTTIME] = i; + workLS = MEMBUF_getNew(); + if( workLS == NULL ) + return FALSE; + memcpy( workLS->buf, buf, sizeof( workLS->buf)); + workLS->type = flg; + workLS->next = NULL; + + if( LSbufHead == NULL ) + LSbufHead = workLS; + else { + FindLs->next = workLS; + } + + return TRUE; +} + +LSMem *MEMBUF_getNew() +{ + LSMem *MBUF=NULL; + MBUF = (LSMem *) calloc( 1, sizeof( struct MemMessage) ); + if( MBUF == NULL ) + return NULL; + MBUF->type = 0; + return MBUF; +} + +int MMGet_LsReadBuflist( char *buf, int len) +{ + int l; + char buf1[256]; + LSMem *FlgMem; + FlgMem = NULL; + l = MMGet_LS_WRMemBufList( buf1, len, MEMREAD); + if( l > 0 ) { + memcpy( buf, &buf1, 256); + return strlen( buf1); + } + return 0; +} + +int MMGet_LS_WRMemBufList( char *buf, int len, int flg) +{ + LSMem *workLS; + LSMem *POINT1=NULL; + workLS = LSbufHead; + POINT1 = NULL; + while( workLS != NULL ){ + if( workLS->type == flg ) { + sprintf( buf, "%s", workLS->buf); + if( POINT1 == NULL ) { + LSbufHead = workLS->next; + }else { + POINT1->next = workLS->next; + } + free ( workLS); + return 1; + } + POINT1 = workLS; + workLS = workLS->next; + } + return 0; +} + +void DEL_LS_MemBufferHead() +{ + LSMem *workLS; + if( LSbufHead == NULL ) + return; + if( LSbufHead->next == NULL ) + return; + workLS = LSbufHead; + LSbufHead = LSbufHead->next; + free( workLS); +} + +void DEL_LS_MemBufferList( LSMem *FlgMem ) +{ + LSMem *workLS=NULL; + LSMem *POINT1=NULL; + + workLS = LSbufHead; + POINT1 = NULL; + while( workLS != NULL) { + if( workLS == FlgMem ) { + if( POINT1 == NULL ) { + LSbufHead = FlgMem->next; + }else { + POINT1->next = FlgMem->next; + } + free( FlgMem); + return; + }else { + POINT1 = workLS; + workLS = workLS->next; + } + } +} + +BOOL CHECK_LS_BEUSE() +{ + if( Ls.data[LS_USE] == 1) + return TRUE; + else + return FALSE; +} + +void CHECK_LSTYPE() +{ + static time_t standbyTime; + + if( Ls.data[LS_USE] ){ + if( Ls.errs ) { + if( DisConnectLServer() == FALSE ) { + log( "LS Close..\n"); + }else { + log( "LS Close error ..!!\n"); + } + } + standbyTime = time(NULL); + }else { + if( (standbyTime + 60 ) > time(NULL) ) + return; + + REreadConfig( "saac.cf"); + LServerInit(); + usleep( 200*10000); + standbyTime = time(NULL); + if( connectToLServer( LSADDRESS, LSPORT) == FALSE ) { + log("%s", "LOGIN LServer FAIL!!\n"); + return; + }else { + usleep( 100*10000); + LServer_SALogin_send(); + } + } + //if( Ls.data[LS_LASTTIME] >= 10 ) + +} + +int get_LSFD() +{ + if( Ls.data[LS_USE] ) { + return Ls.data[LS_FD]; + } + return -1; +} + +void Show_LS_MEMBufferList() +{ + LSMem *workLS=NULL; + + workLS = LSbufHead; + while( workLS != NULL ) { + log( "[ %s] ", workLS->buf); + workLS = workLS->next; + } + +} + +int lockproto_SaacDispatchMessage( char *encoded ) +{ + int lens; + char funcname[1024]; + if( SAMESS_setChar( encoded) == FALSE ) + return -1; + + memset( funcname, 0, sizeof( funcname)); + if( SAMESS_getChar( funcname, &lens) == FALSE ) { + log("funcname:NULL\n"); + return 0; + } + + if( !strcmp( funcname , "TEST" )){ + char buf1[256],buf2[256],buf3[256]; + if( SAMESS_getChar( buf1, &lens) == FALSE ) return 0; + if( SAMESS_getChar( buf2, &lens) == FALSE ) return 0; + if( SAMESS_getChar( buf3, &lens) == FALSE ) return 0; + return 0; + } + + if( !strcmp( funcname , "SACheckLock1" )){ + char si[256], Pcdkey[256], Pid[256], flg[256], PASS[256]; + if( SAMESS_getChar( si, &lens) == FALSE ) return 0; + if( SAMESS_getChar( Pcdkey, &lens) == FALSE ) return 0; + if( SAMESS_getChar( Pid, &lens) == FALSE ) return 0; + if( SAMESS_getChar( flg, &lens) == FALSE ) return 0; + if( SAMESS_getChar( PASS, &lens) == FALSE ) return 0; + LServer_SACheckLock1_recv( si, Pcdkey, Pid, flg, PASS); + return 0; + } + + if( !strcmp( funcname , "SACheckLock2" )){ + char si[256], Pcdkey[256], Pid[256], name[256], flg[256], PASS[256]; + if( SAMESS_getChar( si, &lens) == FALSE ) return 0; + if( SAMESS_getChar( Pcdkey, &lens) == FALSE ) return 0; + if( SAMESS_getChar( Pid, &lens) == FALSE ) return 0; + if( SAMESS_getChar( name, &lens) == FALSE ) return 0; + if( SAMESS_getChar( flg, &lens) == FALSE ) return 0; + if( SAMESS_getChar( PASS, &lens) == FALSE ) return 0; + LServer_SACheckLock2_recv( si, Pcdkey, Pid, name, flg, PASS); + return 0; + } + + if( !strcmp( funcname , "SALock" )){ + char si[256], Pcdkey[256], Pid[256], name[256], flg[256]; + + if( SAMESS_getChar( si, &lens) == FALSE ) return 0; + if( SAMESS_getChar( Pcdkey, &lens) == FALSE ) return 0; + if( SAMESS_getChar( Pid, &lens) == FALSE ) return 0; + if( SAMESS_getChar( name, &lens) == FALSE ) return 0; + if( SAMESS_getChar( flg, &lens) == FALSE ) return 0; + LServer_SALock_recv( si, Pcdkey, Pid, name, flg); + return 0; + } + + if( !strcmp( funcname , "SAUNLock" )){ + char si[256], Pcdkey[256], Pid[256], flg[256]; + + if( SAMESS_getChar( si, &lens) == FALSE ) return 0; + if( SAMESS_getChar( Pcdkey, &lens) == FALSE ) return 0; + if( SAMESS_getChar( Pid, &lens) == FALSE ) return 0; + if( SAMESS_getChar( flg, &lens) == FALSE ) return 0; + LServer_SAUNLock_recv( si, Pcdkey, Pid, flg); + return 0; + } + + if( !strcmp( funcname , "SAUCheck" )){ //check + char PCDKEY[256]; + if( SAMESS_getChar( PCDKEY, &lens) == FALSE ) return 0; + LServer_SAUCheck_recv( PCDKEY); + return 0; + } + + return -1; +} + +BOOL SAMESS_setChar( char *buf) +{ + char Mbuf[4096]; + int i=0,j=0; + int len=0; + SAMessC *Works; + SAMessC *point; + point = NULL; + + memset( Mbuf, 0, sizeof( Mbuf)); + sprintf( Mbuf, "%s", buf); + SAMess = NULL; + while( Mbuf[i] != '\0' ) { + if( Mbuf[i] == '\n' ) + Mbuf[i] = '\0'; + i++; + } + i=0; + len = 0; + while( Mbuf[i] != '\0' && Mbuf[j] != '\0' ) { + j=i; + len = 0; + while( Mbuf[j] != ' ' && Mbuf[j] != '\0') { + len++; + j++; + } + Works = MESS_getNew(); + if( Works == NULL ) + return FALSE; + memcpy( Works->buf, &Mbuf[i], len); + Works->len = len; + if( SAMess == NULL ) { + SAMess = Works; + point = Works; + }else { + point->next = Works; + point = point->next; + } + i = (j+1); + } + return TRUE; +} + + +BOOL SAMESS_getChar( char *buf, int *len) +{ + SAMessC *Works; + Works = SAMess; + *len = 0; + if( Works == NULL ) + return FALSE; + sprintf( buf, "%s", Works->buf); + *len = Works->len; + SAMess = Works->next; + free( Works); + return TRUE; +} + +SAMessC *MESS_getNew() +{ + SAMessC *MBUF=NULL; + MBUF = (SAMessC *) calloc( 1, sizeof( struct _SAMessCommand) ); + if( MBUF == NULL ) + return NULL; + memset( MBUF->buf, 0, sizeof( MBUF->buf)); + MBUF->len = 0; + MBUF->next = NULL; + return MBUF; +} + + +void LServer_SALogin_send() +{ + //Ls.data[LS_FD] + char buf[4096]; + sprintf( buf, "SALogin %s %d %s\n", SaName, 0, "LOGIN"); + if( Add_LS_WRMemBuffer( buf, sizeof( buf), MEMWRITE) == FALSE ) { + log( "LS WRITE ERROR!!"); + } +} + +void LServer_SACheckLock1_recv( char *si, char *Pcdkey, char *Pid, char *flg, char *PASS) +{ + +#ifndef _TEST_LOCKSERVER + int Pfd, Flg, seri; + char listbuf[CHARDATASIZE]; + Pfd = atoi( Pid); + Flg = atoi( flg); + seri = atoi( si); + + + if( !strcmp( flg, "LOCKED") ) { + saacproto_ACCharList_send( seri , FAILED , "locked" , Pfd ); + total_ng_charlist++; + }else { + loadCharNameAndOption( Pcdkey , listbuf,sizeof(listbuf)); + saacproto_ACCharList_send( seri , SUCCESSFUL , listbuf , Pfd); + total_ok_charlist++; + } +#endif +} + +void LServer_SACheckLock1_send( int ti, char *Pcdkey, int Pid, int flg) +{ + char buf[4096]; + sprintf( buf, "SACheckLock1 %d %s %d %d %s\n", ti, Pcdkey, Pid, flg, "CHECK"); + if( Add_LS_WRMemBuffer( buf, sizeof( buf), MEMWRITE) == FALSE ) { + log( "LS WRITE ERROR!!"); + } +} + +void LServer_SACheckLock2_send( int ti, char *Pcdkey, int Pid, char *charname, int flg, char *pro) +{ + char buf[4096]; + sprintf( buf, "SACheckLock2 %d %s %d %s %d %s\n", ti, Pcdkey, Pid, charname, flg, pro); + if( Add_LS_WRMemBuffer( buf, sizeof( buf), MEMWRITE) == FALSE ) { + log( "LS WRITE ERROR!!"); + } +} + +void LServer_SACheckLock2_recv( char *si, char *Pcdkey, char *Pid, char *name, char *flg, char *pro) +{ +#ifndef _TEST_LOCKSERVER + int Pfd, Flg, seri; + int charindex=-1; + char loadbuf[CHARDATASIZE]; + char infobuf[CHARDATASIZE]; + Pfd = atoi( Pid); + Flg = atoi( flg); + seri = atoi( si); + +#define IS_2BYTEWORD( _a_ ) ( (char)(0x80) <= (_a_) && (_a_) <= (char)(0xFF) ) + + + if( !strcmp( flg, "LOCKED") ) { + saacproto_ACCharLoad_send( seri , FAILED , "locked" , Pfd, charindex ); + }else { + int lock = 1; + charindex = getCharIndexByName( Pcdkey , name ); + if( charindex < 0 ){ + saacproto_ACCharLoad_send( seri , FAILED , "char nonexistent" , Pfd , charindex ); + return; + } + log( "loadCharOne: id:[%s] char:[%s]\n", Pcdkey, name ); + if( loadCharOne( Pcdkey , charindex , loadbuf ,sizeof( loadbuf ))<0){ + saacproto_ACCharLoad_send( seri , FAILED , + "cannot load ( disk i/o error?)", Pfd, charindex ); + return; + } + {//ttom + char *c_ptr; + c_ptr=loadbuf; + while(*c_ptr!='\0'){ + if( IS_2BYTEWORD(*c_ptr) ){ + if(*(c_ptr+1)==' '){ + *(c_ptr+1)=0x41; + } + c_ptr++; + if(*c_ptr=='\0') break; + } + c_ptr++; + } + }//ttom + + if( lock ){ + char result[100]; + char retdata[100]; +#ifdef _LOCK_ADD_NAME + if( lockUser( getGSName(seri) , Pcdkey , name , passwd , 1 , result , sizeof( result ) , + retdata , sizeof( retdata ) , pro , "0")<0){ +#else + if( lockUser( getGSName(seri) , Pcdkey , passwd , 1 , result , sizeof( result ) , + retdata , sizeof( retdata ) , pro , "0")<0){ +#endif + saacproto_ACCharLoad_send( seri , FAILED , "lock FAIL" , Pfd, charindex ); + log(" SAAC lock %s|%s FAIL!!\n", getGSName(seri), Pcdkey); + return; + } + } + //LS LOCK + if( CHECK_LS_BEUSE() == TRUE ) { + LServer_SALock_send( seri, Pcdkey, Pfd, name, 1); + } + + memset( infobuf , 0 , sizeof( infobuf )); + getCharInfoFromString( loadbuf , infobuf ); + makeStringFromEscaped( infobuf ); + saacproto_ACCharLoad_send( seri , SUCCESSFUL , infobuf , Pfd, charindex ); + + } +#endif +} + +void LServer_SALock_recv( char *si, char *Pcdkey, char *Pid, char *name, char *flg) +{ + int Pfd, seri; + Pfd = atoi( Pid); + seri = atoi( si); + + if( !strcmp( flg, "FAIL") ) { + log( "LS Lock %s|%s FAIL!!\n", getGSName(seri), Pcdkey); + } +} + +void LServer_SALock_send( int ti, char *Pcdkey, int Pid, char *Pname, int flg) +{ + //si[256], SANAME[256], PCDKEY[256], PNAME[256], FLG[256]; + char buf[4096]; + + sprintf( buf, "SALock %d %s %s %d %s %d\n", ti, SaName, Pcdkey, Pid, Pname, flg); + if( Add_LS_WRMemBuffer( buf, sizeof( buf), MEMWRITE) == FALSE ) { + log( "LS WRITE ERROR!!"); + } +} + +void LServer_SAUNLock_recv( char *si, char *Pcdkey, char *Pid, char *flg) +{ + int Pfd, seri; + Pfd = atoi( Pid); + seri = atoi( si); + + if( !strcmp( flg, "FAIL") ) { + log( "LS UNLock %s|%s FAIL!!\n", getGSName(seri), Pcdkey); + } +} + +void LServer_SAUNLock_send( int ti, char *Pcdkey, int Pid, int flg) +{ + char buf[4096]; + + sprintf( buf, "SAUNLock %d %s %s %d %d\n", ti, SaName, Pcdkey, Pid, flg); + if( Add_LS_WRMemBuffer( buf, sizeof( buf), MEMWRITE) == FALSE ) { + log( "LS WRITE ERROR!!\n"); + } +} + +void LServer_SAUCheck_recv( char *Pcdkey) +{ + if( isLocked( Pcdkey ) ){ + saacproto_SAUCheck_send( Pcdkey, 1); + checkGSUCheck( Pcdkey ); + return; + }else { + saacproto_SAUCheck_send( Pcdkey, 0); + return; + } +} +void saacproto_SAUCheck_send( char *Pcdkey, int flg) +{ + char buf[4096]; + + sprintf( buf, "SAUCheck %s %s %d\n", SaName, Pcdkey, flg); + if( Add_LS_WRMemBuffer( buf, sizeof( buf), MEMWRITE) == FALSE ) { + log( "LS WRITE ERROR!!"); + } +} + +void DefTimeC( char *buf, int flg)// 1 比较 2 秀时间 0 替换 +{ + static long int dTimes = 0; + time_t defLsTime; + + defLsTime = time(NULL); + if( flg == 1 ) { + if( defLsTime != dTimes ) { + log( "Time[%s]:%ld|%ld|%ld..\n", buf, defLsTime, dTimes, (defLsTime-dTimes)); + dTimes = defLsTime; + } + }else if( flg == 2 ) { + log( "Time[%s]:%ld..\n", buf, defLsTime); + }else { + dTimes = defLsTime; + } +} + +void REreadConfig( char *path ) +{ + char buf[2048]; + FILE *fp; + + fp = fopen( path , "r" ); + if( fp == NULL ) + return; + + while( fgets( buf , sizeof( buf ) , fp )){ + char command[1024]; + char param[2048]; + chop(buf); + + easyGetTokenFromString( buf , 1 , command , sizeof( command )); + easyGetTokenFromString( buf , 2 , param , sizeof( param )); + + if( strcmp( command, "SANAME" ) == 0 ){ + snprintf( SaName, sizeof( SaName ), param ); + } else if( strcmp( command, "LSADDRESS" ) == 0 ){ + snprintf( LSADDRESS, sizeof( LSADDRESS ), param ); + } else if( strcmp( command, "LSPORT" ) == 0 ){ + LSPORT = atoi( param); + } + } + + fclose(fp); + +} + +#ifdef _TEST_LOCKSERVER +void TEST_TOLOCKSERVER() +{ + static int po=0; + static time_t defLsTime; + //char charname[256]={"ankoo"}; + //char Pcdkey[256]; + int mesgid = -1; + int seri=-1; + + if( !Ls.data[LS_USE] ) + return; + if( defLsTime == time( NULL) ) + return; + defLsTime = time( NULL); + + //sprintf( Pcdkey,"%s", charname); + switch( po) { + case 0: + LServer_SACheckLock1_send( seri, TESTNAME, mesgid, 1); + LServer_SACheckLock2_send( seri, TESTNAME, mesgid, TESTNAME, 1, "-1"); + break; + case 1: + LServer_SALock_send( seri, TESTNAME, mesgid, TESTNAME, 1); + break; + case 2: + LServer_SAUNLock_send( seri, TESTNAME, mesgid, 1); + break; + } + po++; + po = po%3; +} +#endif + +#endif diff --git a/saac/saacproto_lserver.h b/saac/saacproto_lserver.h new file mode 100644 index 0000000..4370a70 --- /dev/null +++ b/saac/saacproto_lserver.h @@ -0,0 +1,113 @@ +#ifndef _LSERVER_H +#define _LSERVER_H + +#include "version.h" + +#ifdef _LOCK_SERVER +#define _DEFLSCONNECT +#ifndef BOOL +#define BOOL int +#define TRUE 1 +#define FALSE 0 +#endif + + +enum { + LS_PORT = 0, + LS_LASTTIME, + LS_FD, + LS_USE, + LS_TYPE, + LS_TI, + LS_LASTERROR, + LS_MAXDATA, +}; + +enum { + LSTYPE_NORMAL=0, + LSTYPE_STANDBY, + LSTYPE_BEDIE, + + LS_OK = 1000, + LSMESS_NOCONNECT, + LSMESS_BELIFE, + LSMESS_SOCKERROR, + LSMESS_HOSTERROR, + LSMESS_READERROR, + LSMESS_WRITEERROR, + LSMESS_LSMEMERROR, +}; + +typedef struct MemMessage +{ + char buf[4096]; + int type; + struct MemMessage *next; +}LSMem; + +#define MEMREAD 1 +#define MEMWRITE 2 +typedef struct _LockServer +{ + char address[256]; + int data[LS_MAXDATA]; + int errs; + int m_ri; + int m_wi; +}LServer; +extern LServer Ls; + + +BOOL LServerInit(); +BOOL connectToLServer( char *laddress, int lport); +BOOL DisConnectLServer(); +int tcpip_connect( char *addr , int port); +int LS_getData( int stype); +BOOL Add_LS_WRMemBuffer( char *buf, int strlens, int flg); +LSMem *MEMBUF_getNew(); +void DEL_LS_MemBufferList( LSMem *FlgMem ); +int MMGet_LS_WRMemBufList( char *buf, int len, int flg); +BOOL TcpIp_LS_accept(); +int MMGet_LsReadBuflist( char *buf, int len); +BOOL CHECK_LS_BEUSE(); +void CHECK_LSTYPE(); +int get_LSFD(); +void Show_LS_MEMBufferList(); +void DEL_LS_MemBufferHead(); + +typedef struct _SAMessCommand +{ + char buf[256]; + int len; + struct _SAMessCommand *next; +}SAMessC; +BOOL SAMESS_setChar( char *buf); +BOOL SAMESS_getChar( char *buf, int *len); + +SAMessC *MESS_getNew(); + +int lockproto_SaacDispatchMessage( char *encoded ); + +void LServer_SALogin_send(); +void LServer_SACheckLock1_send( int ti, char *Pcdkey, int Pid, int flg); +void LServer_SACheckLock1_recv( char *si, char *Pcdkey, char *Pid, char *flg, char *PASS); +void LServer_SACheckLock2_send( int ti, char *Pcdkey, int Pid, char *charname, int flg, char *pro); +void LServer_SACheckLock2_recv( char *si, char *Pcdkey, char *Pid, char *name, + char *flg, char *pro); +void LServer_SALock_recv( char *si, char *Pcdkey, char *Pid, char *name, char *flg); +void LServer_SALock_send( int ti, char *Pcdkey, int Pid, char *Pname, int flg); +void LServer_SAUNLock_recv( char *si, char *Pcdkey, char *Pid, char *flg); +//si[256], PCDKEY[256], Pid[256], FLG[256]; +void LServer_SAUNLock_send( int ti, char *Pcdkey, int Pid, int flg); +//check +void LServer_SAUCheck_recv( char *Pcdkey); +void saacproto_SAUCheck_send( char *Pcdkey, int flg); + +void DefTimeC( char *buf, int flg); +#ifdef _TEST_LOCKSERVER +void TEST_TOLOCKSERVER(); +#endif +#endif +#endif + + diff --git a/saac/saacproto_oac.c b/saac/saacproto_oac.c new file mode 100644 index 0000000..0b839f9 --- /dev/null +++ b/saac/saacproto_oac.c @@ -0,0 +1,338 @@ +#include "version.h" +#include "main.h" +#include "util.h" +#include "char.h" +#include "tcpip_util.h" +#include "saacproto_util.h" +#include "saacproto_oac.h" + +#ifdef _OACSTRUCT_TCP + +#define BACKLOGNUM 5 +int oactcptype = -1; +static int btime = 0; +OACListArray OAC_List[MAXTCPCONNECTION]; + +int OAC_InitTcpIp( int tcptype, char *addr, int tport) +{ + int tcpdb=0, binport=OAC_PORT; + + //andy_log + log( "_InitTcpIp( %d)\n", tcptype); + OAC_InitAclist(); + + if( MEMBUF_InitSize( CHARDATASIZE * 4 * MAXTCPCONNECTION , tcpdb ) != OK ){ + return INIT_SOMEERROR; + } + if( tport > 0 ) + binport = tport; + + oactcptype = tcptype; + switch( tcptype){ + case OACTYPE_BIND: + if( TCPIP_bindSocket( addr , binport, 0) < 0 ) + return INIT_SOMEERROR; + break; + case OACTYPE_CONNECT: + OAC_ReadFileInsertAcList( "oac.lis"); + OAC_ConnectOacList(); +// if( OAC_ConnectOacList() == 0 ) +// return INIT_SOMEERROR; + break; + default: + + return INIT_SOMEERROR; + } + return OK; +} + +int OAC_ConnectOacList( void) +{ + int i=0, cnt=0; + for( i=0; i btime){ + OAC_CheckConnect(); + btime = detime+180; + } + return 1; +} + +int OAC_ReadMessLine( void) +{ + int i=0, l; + char buf[ CHARDATASIZE*4 ]; + + for( i=0; i= MAXTCPCONNECTION ) break; + } + fclose( fp); + {//andy_log + int i; + for( i=0; i charindex(%d)", charindex ); + + saacproto_ACRELOADFM_recv( fd, charindex ); + + return 0; + } + + if ( strcmp( funcname, "ACShowMemberList2") == 0){ + int fm1 = -1, fm2 = -1, charindex = -1, time = -1, id = -1; + + charindex = saacproto_demkstr_int(saacproto.token_list[2]); + fm1 = saacproto_demkstr_int(saacproto.token_list[3]); + fm2 = saacproto_demkstr_int(saacproto.token_list[4]); + time = saacproto_demkstr_int(saacproto.token_list[5]); + id = saacproto_demkstr_int(saacproto.token_list[6]); + + log("\n won test 40 ==> charindex(%d) fm1(%d) fm2(%d) time(%d) id(%d)", charindex, fm1, fm2, time, id ); + + saacproto_ACShowMemberList_2_recv(fd, charindex, fm1, fm2, time, id ); + + return 0; + } + +#endif + + +#ifdef _DEATH_FAMILY_LOGIN_CHECK // WON ADD 家族战登入检查 + // 玩家login2 + if ( strcmp( funcname, "ACFMCharLogin2") == 0){ + int charindex = -1; + char *char_id, *char_name; + + char_id = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + char_name = saacproto_wrapStringAddr(saacproto_stringwrapper[2], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[3])); + charindex = saacproto_demkstr_int(saacproto.token_list[4]); + + log("\n won test 4 ==> char_id(%s) char_name(%s) charindex(%d)", char_id, char_name, charindex ); + + saacproto_ACFMCharLogin2_recv(fd, char_id, char_name, charindex ); + + return 0; + } +#endif + + // 玩家login + if ( strcmp( funcname, "ACFMCharLogin") == 0){ + int fmindex, charlv, charfdid; +#ifdef _FM_MODIFY + int gsnum; +#endif + char *fmname, *charname, *charid; +#ifdef _FMVER21 + int eventflag; +#endif + fmname = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + fmindex = saacproto_demkstr_int(saacproto.token_list[3]); + charname = saacproto_wrapStringAddr(saacproto_stringwrapper[3], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[4])); + charid = saacproto_wrapStringAddr(saacproto_stringwrapper[4], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[5])); + charlv = saacproto_demkstr_int(saacproto.token_list[6]); + +#ifdef _FMVER21 + eventflag = saacproto_demkstr_int(saacproto.token_list[7]); + charfdid = saacproto_demkstr_int(saacproto.token_list[8]); + #ifdef _FM_MODIFY + gsnum = saacproto_demkstr_int(saacproto.token_list[9]); + saacproto_ACFMCharLogin_recv(fd, fmname, fmindex, charname,charid, charlv, eventflag, charfdid,gsnum); + #else + saacproto_ACFMCharLogin_recv(fd, fmname, fmindex, charname,charid, charlv, eventflag, charfdid); + #endif +#else + charfdid = saacproto_demkstr_int(saacproto.token_list[7]); + saacproto_ACFMCharLogin_recv(fd, fmname, fmindex, charname,charid, charlv, charfdid); +#endif + return 0; + } + // 玩家logout + if ( strcmp( funcname, "ACFMCharLogout") == 0){ + int fmindex, charfdid, charlv, index; + char *fmname, *charname, *charid; + fmname = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + fmindex = saacproto_demkstr_int(saacproto.token_list[3]); + charname = saacproto_wrapStringAddr(saacproto_stringwrapper[3], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[4])); + charid = saacproto_wrapStringAddr(saacproto_stringwrapper[4], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[5])); + charlv = saacproto_demkstr_int(saacproto.token_list[6]); + index = saacproto_demkstr_int(saacproto.token_list[7]); + charfdid = saacproto_demkstr_int(saacproto.token_list[8]); + saacproto_ACFMCharLogout_recv(fd, fmname, fmindex, charname, + charid, charlv, index, charfdid); + return 0; + } + // 族长审核成员加入家族、修改家族成员职位 + if (strcmp( funcname, "ACMemberJoinFM") == 0){ + int fmindex, charfdid, index, charindex, result; + char *fmname, *charname; +#ifdef _FMVER21 + int meindex; +#endif + fmname = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + fmindex = saacproto_demkstr_int(saacproto.token_list[3]); + charname = saacproto_wrapStringAddr(saacproto_stringwrapper[3], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[4])); + charindex = saacproto_demkstr_int(saacproto.token_list[5]); + index = saacproto_demkstr_int(saacproto.token_list[6]); + result = saacproto_demkstr_int(saacproto.token_list[7]); +#ifdef _FMVER21 + meindex = saacproto_demkstr_int(saacproto.token_list[8]); + charfdid = saacproto_demkstr_int(saacproto.token_list[9]); + saacproto_ACMemberJoinFM_recv(fd, fmname, fmindex, charname, + charindex, index, result, meindex, charfdid); +#else + charfdid = saacproto_demkstr_int(saacproto.token_list[8]); + saacproto_ACMemberJoinFM_recv(fd, fmname, fmindex, charname, + charindex, index, result, charfdid); +#endif + return 0; + } + // 族长审核成员离开家族 + if (strcmp( funcname, "ACMemberLeaveFM") == 0){ + int fmindex, charfdid, index, charindex; + char *fmname, *charname; +#ifdef _FMVER21 + int meindex; +#endif + fmname = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + fmindex = saacproto_demkstr_int(saacproto.token_list[3]); + charname = saacproto_wrapStringAddr(saacproto_stringwrapper[3], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[4])); + charindex = saacproto_demkstr_int(saacproto.token_list[5]); + index = saacproto_demkstr_int(saacproto.token_list[6]); +#ifdef _FMVER21 + meindex = saacproto_demkstr_int(saacproto.token_list[7]); + charfdid = saacproto_demkstr_int(saacproto.token_list[8]); + saacproto_ACMemberLeaveFM_recv(fd, fmname, fmindex, charname, + charindex, index, meindex, charfdid); +#else + charfdid = saacproto_demkstr_int(saacproto.token_list[7]); + saacproto_ACMemberLeaveFM_recv(fd, fmname, fmindex, charname, + charindex, index, charfdid); +#endif + return 0; + } + // 列出家族据点 + if ( strcmp( funcname, "ACFMPointList") == 0){ + saacproto_ACFMPointList_recv(fd); + return 0; + } + + +#ifdef _CK_ONLINE_PLAYER_COUNT // WON ADD 计算线上人数 + if ( strcmp( funcname, "ACGSPCOUNT") == 0){ + int playcount = 0; + playcount = saacproto_demkstr_int(saacproto.token_list[2]); + saacproto_GS_ACK_PLAYER_COUNT_recv( fd, playcount ); + return 0; + } +#endif + + // 申请家族据点 + if (strcmp( funcname, "ACSetFMPoint") == 0){ + int fl, x, y, fmindex, index, fmpointindex, charfdid; + char *fmname; + fmname = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + fmindex = saacproto_demkstr_int(saacproto.token_list[3]); + index = saacproto_demkstr_int(saacproto.token_list[4]); + fmpointindex = saacproto_demkstr_int(saacproto.token_list[5]); + fl = saacproto_demkstr_int(saacproto.token_list[6]); + x = saacproto_demkstr_int(saacproto.token_list[7]); + y = saacproto_demkstr_int(saacproto.token_list[8]); + charfdid = saacproto_demkstr_int(saacproto.token_list[9]); + saacproto_ACSetFMPoint_recv(fd, fmname, fmindex, index, + fmpointindex, fl, x, y, charfdid); + return 0; + } + // 设定家族据点 + if (strcmp( funcname, "ACFixFMPoint") == 0){ + int winindex, winfmindex, loseindex, losefmindex, village; + char *winfmname, *losefmname; + winfmname = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + winfmindex = saacproto_demkstr_int(saacproto.token_list[3]); + winindex = saacproto_demkstr_int(saacproto.token_list[4]); + losefmname = saacproto_wrapStringAddr(saacproto_stringwrapper[4], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[5])); + losefmindex = saacproto_demkstr_int(saacproto.token_list[6]); + loseindex = saacproto_demkstr_int(saacproto.token_list[7]); + village= saacproto_demkstr_int(saacproto.token_list[8]); + saacproto_ACFixFMPoint_recv(fd, winfmname, winfmindex, winindex, + losefmname, losefmindex, loseindex, village); + return 0; + } + // 族长对全员广播 + if (strcmp( funcname, "ACFMAnnounce") == 0){ + int index, fmindex, color; + char *fmname, *data; + fmname = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + fmindex = saacproto_demkstr_int(saacproto.token_list[3]); + index = saacproto_demkstr_int(saacproto.token_list[4]); + data = saacproto_wrapStringAddr(saacproto_stringwrapper[4], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[5])); + color = saacproto_demkstr_int(saacproto.token_list[6]); + saacproto_ACFMAnnounce_recv(fd, fmname, fmindex, index, data, color); + return 0; + } + // 列出家族排行榜 + if ( strcmp( funcname, "ACShowTopFMList") == 0){ + int kindflag; + char *tmpbuf; + tmpbuf = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + kindflag = saacproto_demkstr_int(saacproto.token_list[3]); + saacproto_ACShowTopFMList_recv(fd, kindflag); + return 0; + } + // 修正家族资料 + if (strcmp( funcname, "ACFixFMData") == 0){ + int fmindex, charfdid, index, kindflag, charindex; + char *fmname, *data1, *data2; + fmname = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + fmindex = saacproto_demkstr_int(saacproto.token_list[3]); + index = saacproto_demkstr_int(saacproto.token_list[4]); + kindflag = saacproto_demkstr_int(saacproto.token_list[5]); + data1 = saacproto_wrapStringAddr(saacproto_stringwrapper[5], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[6])); + data2 = saacproto_wrapStringAddr(saacproto_stringwrapper[6], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[7])); + charindex = saacproto_demkstr_int(saacproto.token_list[8]); + charfdid = saacproto_demkstr_int(saacproto.token_list[9]); + saacproto_ACFixFMData_recv(fd, fmname, fmindex, index, kindflag, + data1, data2, charindex, charfdid); + return 0; + } +#ifdef _FAMILYBANKSTONELOG + if (strcmp( funcname, "ACgetFMBankgold") ==0){ + int fmindex, charfdid, index, charindex; + char *fmname; + fmname = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + fmindex = saacproto_demkstr_int(saacproto.token_list[3]); + index = saacproto_demkstr_int(saacproto.token_list[4]); + charindex = saacproto_demkstr_int(saacproto.token_list[5]); + charfdid = saacproto_demkstr_int(saacproto.token_list[6]); + saacproto_ACgetFMBankgold_recv(fd, fmname, fmindex, index, charindex, charfdid); + return 0; + } +#endif + +#ifdef _DEATH_FAMILY_STRUCT // WON ADD 家族战存放胜负资料 + if (strcmp( funcname, "FMINITPKSTRUCT") == 0){ + log("\n won test 300 ==>" ); + set_fm_pk_score( "" ); +// save_fm_pk_score(); + return 0; + } + + if (strcmp( funcname, "FMPKSTRUCT") == 0){ + char *msg; + + msg = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + + log("\n won test 54 ==> msg(%s)", msg ); + + set_fm_pk_score( msg ); +// save_fm_pk_score(); + + return 0; + } +#endif + + + // 家族PK後修正声望 + if (strcmp( funcname, "ACFixFMPK") == 0){ + int winindex, winfmindex, loseindex, losefmindex; + char *winfmname, *losefmname; + winfmname = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + winfmindex = saacproto_demkstr_int(saacproto.token_list[3]); + winindex = saacproto_demkstr_int(saacproto.token_list[4]); + losefmname = saacproto_wrapStringAddr(saacproto_stringwrapper[4], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[5])); + losefmindex = saacproto_demkstr_int(saacproto.token_list[6]); + loseindex = saacproto_demkstr_int(saacproto.token_list[7]); + saacproto_ACFixFMPK_recv(fd, winfmname, winfmindex, winindex, + losefmname, losefmindex, loseindex); + return 0; + } + // GM修正家族资料 + if (strcmp( funcname, "ACGMFixFMData") == 0){ + int index, charfdid; + char *cmd, *data, *tmpbuf,*charid; + tmpbuf = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + index = saacproto_demkstr_int(saacproto.token_list[3]); + charid = saacproto_wrapStringAddr(saacproto_stringwrapper[3], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[4])); + cmd = saacproto_wrapStringAddr(saacproto_stringwrapper[4], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[5])); + data = saacproto_wrapStringAddr(saacproto_stringwrapper[5], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[6])); + charfdid = saacproto_demkstr_int(saacproto.token_list[7]); + saacproto_ACGMFixFMData_recv(fd, index, charid, cmd, data, charfdid); + return 0; + } + // 取得家族资料 + if (strcmp( funcname, "ACGetFMData") == 0){ + int fmindex, charfdid, index, kindflag; + char *fmname; + fmname = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + fmindex = saacproto_demkstr_int(saacproto.token_list[3]); + index = saacproto_demkstr_int(saacproto.token_list[4]); + kindflag = saacproto_demkstr_int(saacproto.token_list[5]); + charfdid = saacproto_demkstr_int(saacproto.token_list[6]); + saacproto_ACGetFMData_recv(fd, fmname, fmindex, index, kindflag, + charfdid); + return 0; + } + // 广播踢馆人的资料 + if (strcmp( funcname,"ACManorPKAck") == 0){ + char *data; + data = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + saacproto_ACManorPKAck_recv(fd, data); + return 0; + } + +#ifdef _CHECKFMSCHEDULE // Syu ADD 透过AC确认家族挑战排程 + if (strcmp( funcname,"ACCheckSchedule") ==0) + { + char *data; + data = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + saacproto_ACCheckSchedule_recv(fd,data); + return 0; + } +#endif + + if (strcmp( funcname,"ACreLoadFmData") ==0){ + int type, data; + type = saacproto_demkstr_int(saacproto.token_list[2]); + data = saacproto_demkstr_int(saacproto.token_list[3]); + saacproto_ACreLoadFmData_recv( fd, type, data); + return 0; + } + +#ifdef _AC_SEND_FM_PK + if (strcmp( funcname,"ACLoadFmPk") ==0) + { + int fmpks_pos; + fmpks_pos = saacproto_demkstr_int(saacproto.token_list[2]); + saacproto_ACLoadFmPk_recv(fd, fmpks_pos); + return 0; + } +#ifdef _ACFMPK_LIST + if (strcmp( funcname,"ACSendFmPk") ==0){ + int fmpks_pos, userindex, flg; + char *data; + fmpks_pos = saacproto_demkstr_int(saacproto.token_list[2]); + userindex = saacproto_demkstr_int(saacproto.token_list[3]); + flg = saacproto_demkstr_int(saacproto.token_list[4]); + data = saacproto_wrapStringAddr( saacproto_stringwrapper[4] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[5] )); + saacproto_ACSendFmPk_recv( fd, fmpks_pos, userindex, flg, data); + return 0; + } +#else + if (strcmp( funcname,"ACSendFmPk") ==0){ + int fmpks_pos; + char *data; + fmpks_pos = saacproto_demkstr_int(saacproto.token_list[2]); + data = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + saacproto_ACSendFmPk_recv(fd, fmpks_pos, data); + return 0; + } +#endif + +#endif + + + +#ifdef _RECAL_BACKUP_PLAYER // WON 回溯功能 + + if (strcmp( funcname,"ACSendRecalPlayer") ==0) + { + char *uid, *id; + int userfdid, char_num, date, GmCliId, backup_flag; + + uid = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + userfdid = saacproto_demkstr_int(saacproto.token_list[3]); + GmCliId = saacproto_demkstr_int(saacproto.token_list[4]); + id = saacproto_wrapStringAddr( saacproto_stringwrapper[4] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[5] )); + char_num = saacproto_demkstr_int(saacproto.token_list[6]); + date = saacproto_demkstr_int(saacproto.token_list[7]); + backup_flag = saacproto_demkstr_int(saacproto.token_list[8]); + + saacproto_ACRecalPlayer_recv(fd, uid, userfdid, GmCliId, id, char_num, date, backup_flag); + + return 0; + } + + if (strcmp( funcname,"ACSendRecalBackup") ==0) + { + char *uid, *id, *char_data; + int userfdid, char_num, date, GmCliId, backup_flag; + + uid = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + userfdid = saacproto_demkstr_int(saacproto.token_list[3]); + GmCliId = saacproto_demkstr_int(saacproto.token_list[4]); + id = saacproto_wrapStringAddr( saacproto_stringwrapper[4] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[5] )); + char_num = saacproto_demkstr_int(saacproto.token_list[6]); + date = saacproto_demkstr_int(saacproto.token_list[7]); + char_data = saacproto_wrapStringAddr( saacproto_stringwrapper[7] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[8] )); + backup_flag = saacproto_demkstr_int(saacproto.token_list[9]); + + saacproto_ACRecalBackup_recv(fd, uid, userfdid, GmCliId, id, char_num, date, char_data, backup_flag); + + return 0; + } +#endif // end RECAL_ASK_PLAYER + +#ifdef _AUCTIONEER + if (strcmp( funcname,"ACAuctionSold") == 0){ + char *data; + data = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, saacproto_demkstr_string(saacproto.token_list[2])); + saacproto_ACAuctionSold_recv(fd, data); + return 0; + } +#endif + +#ifdef _NEW_PLAYERGOLD + if (strcmp( funcname,"ACNewPlayerList") == 0){ + int RunType=-1, userIndex=-1; + char *CdKey, *UserName; + CdKey = saacproto_wrapStringAddr(saacproto_stringwrapper[1], saacproto.workbufsize, + saacproto_demkstr_string(saacproto.token_list[2])); + UserName = saacproto_wrapStringAddr(saacproto_stringwrapper[2], saacproto.workbufsize, + saacproto_demkstr_string(saacproto.token_list[3])); + userIndex = saacproto_demkstr_int(saacproto.token_list[4]); + RunType = saacproto_demkstr_int(saacproto.token_list[5]); + saacproto_ACNewPlayerList_recv( fd, CdKey, UserName, userIndex, RunType); + return 0; + } + +#endif + +#ifdef _DEFEND_NEWUSERS + if( strcmp( funcname , "DEFENDLISTS" ) == 0 ){ + char* data; + int type; + type = saacproto_demkstr_int(saacproto.token_list[2]); + data = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + saacproto_DefendList_recv( fd, type, data); + + return 0; + } + if( strcmp( funcname , "CHECKDEFENDSCORE" ) == 0 ){ + char *cdkey, *name; + int userindex; + cdkey = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + name = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + userindex = saacproto_demkstr_int(saacproto.token_list[4]); + saacproto_CheckDefendScore_recv( fd, userindex, cdkey, name); + return 0; + } +#endif + + +#ifdef _CHAR_POOLITEM + if( strcmp( funcname , "ACInsertPoolItem" ) == 0 ){ + char *cdkey, *Pooldataarg; + int clifdid, userindex; + + cdkey = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + Pooldataarg = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + userindex = saacproto_demkstr_int( saacproto.token_list[4] ); + clifdid = saacproto_demkstr_int( saacproto.token_list[5] ); + saacproto_ACCharInsertPoolItem_recv( fd, cdkey, userindex, clifdid, Pooldataarg); + return 0; + } + if( strcmp( funcname , "ACSavePoolItem" ) == 0 ){ + char *cdkey, *Pooldataarg; + int clifdid, userindex; + + cdkey = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + Pooldataarg = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + userindex = saacproto_demkstr_int( saacproto.token_list[4] ); + clifdid = saacproto_demkstr_int( saacproto.token_list[5] ); + saacproto_ACCharSavePoolItem_recv( fd, cdkey, userindex, clifdid, Pooldataarg); + return 0; + } + + if( strcmp( funcname , "ACGetPoolItem" ) == 0 ){ + char *cdkey; + int clifdid, userindex, npcid; + cdkey = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + userindex = saacproto_demkstr_int( saacproto.token_list[3] ); + clifdid = saacproto_demkstr_int( saacproto.token_list[4] ); + npcid = saacproto_demkstr_int( saacproto.token_list[5] ); + + saacproto_ACCharGetPoolItem_recv( fd, cdkey, userindex, clifdid, npcid); + return 0; + } +#endif + + +#ifdef _CHAR_POOLPET + if( strcmp( funcname , "ACInsertPoolPet" ) == 0 ){ + char *cdkey, *Pooldataarg; + int clifdid, userindex; + + cdkey = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + Pooldataarg = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + userindex = saacproto_demkstr_int( saacproto.token_list[4] ); + clifdid = saacproto_demkstr_int( saacproto.token_list[5] ); + saacproto_ACCharInsertPoolPet_recv( fd, cdkey, userindex, clifdid, Pooldataarg); + return 0; + } + if( strcmp( funcname , "ACSavePoolPet" ) == 0 ){ + char *cdkey, *Pooldataarg; + int clifdid, userindex; + + cdkey = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + Pooldataarg = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + userindex = saacproto_demkstr_int( saacproto.token_list[4] ); + clifdid = saacproto_demkstr_int( saacproto.token_list[5] ); + saacproto_ACCharSavePoolPet_recv( fd, cdkey, userindex, clifdid, Pooldataarg); + return 0; + } + + if( strcmp( funcname , "ACGetPoolPet" ) == 0 ){ + char *cdkey; + int clifdid, userindex, npcid; + cdkey = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + userindex = saacproto_demkstr_int( saacproto.token_list[3] ); + clifdid = saacproto_demkstr_int( saacproto.token_list[4] ); + npcid = saacproto_demkstr_int( saacproto.token_list[5] ); + + saacproto_ACCharGetPoolPet_recv( fd, cdkey, userindex, clifdid, npcid); + return 0; + } +#endif + + + +#ifdef _UNIVERSE_CHATROOM + if( strcmp( funcname , "ACUniChatroom" ) == 0 ){ + char *cdkey, *data; + int clifdid, userindex; + cdkey = saacproto_wrapStringAddr( saacproto_stringwrapper[1] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[2] )); + data = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + userindex = saacproto_demkstr_int( saacproto.token_list[4] ); + clifdid = saacproto_demkstr_int( saacproto.token_list[5] ); + + saacproto_ACUniChatroom_recv( fd, cdkey, data, userindex, clifdid ); + return 0; + } +#endif + + +#ifdef _ANGEL_SUMMON + if( strcmp( funcname , "ACMissionTable" ) == 0 ){ + int num; + int type; + char* data; + //int charaindex; + char* angelinfo; + + num = saacproto_demkstr_int( saacproto.token_list[2] ); + type = saacproto_demkstr_int( saacproto.token_list[3] ); + data = saacproto_wrapStringAddr( saacproto_stringwrapper[3] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[4] )); + //charaindex = saacproto_demkstr_int( saacproto.token_list[5] ); + angelinfo = saacproto_wrapStringAddr( saacproto_stringwrapper[4] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[5] )); + + saacproto_ACMissionTable_recv( fd, num, type, data, angelinfo); + return 0; + } +#endif + +#ifdef _TEACHER_SYSTEM + if( strcmp( funcname , "ACCheckCharacterOnLine" ) == 0 ){ + int charaindex,flag; + char *id; + char *name; + + charaindex = saacproto_demkstr_int( saacproto.token_list[2] ); + id = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + name = saacproto_wrapStringAddr( saacproto_stringwrapper[3] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[4] )); + flag = saacproto_demkstr_int( saacproto.token_list[5] ); + + saacproto_ACCheckCharacterOnLine_recv(fd,charaindex,id,name,flag); + return 0; + } +#endif + +#ifdef _RACEMAN + if( strcmp( funcname , "ACRaceRecordandSort" ) == 0 ){ + int charaindex,racetype,catchcnt,ranknum; + char *id; + char *name; + char *code; + + charaindex = saacproto_demkstr_int( saacproto.token_list[2] ); + code = saacproto_wrapStringAddr( saacproto_stringwrapper[2] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[3] )); + id = saacproto_wrapStringAddr( saacproto_stringwrapper[3] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[4] )); + name = saacproto_wrapStringAddr( saacproto_stringwrapper[4] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[5] )); + racetype = saacproto_demkstr_int( saacproto.token_list[6] ); + catchcnt = saacproto_demkstr_int( saacproto.token_list[7] ); //玩家目前抓多少只 + ranknum = saacproto_demkstr_int( saacproto.token_list[8] ); //server要排名到几个 + + saacproto_ACRaceRecordandSort_recv( fd , charaindex , code , id , name , racetype , catchcnt ,ranknum ); + return 0; + } + + if( strcmp( funcname , "ACRaceRecordfmdo" ) == 0 ){ + int charaindex; + int fmid , bbi; + char *unicode , *petname; + + charaindex = saacproto_demkstr_int( saacproto.token_list[2] ); + fmid = saacproto_demkstr_int( saacproto.token_list[3] ); + bbi = saacproto_demkstr_int( saacproto.token_list[4] ); + unicode = saacproto_wrapStringAddr( saacproto_stringwrapper[4] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[5] )); + petname = saacproto_wrapStringAddr( saacproto_stringwrapper[5] , saacproto.workbufsize , saacproto_demkstr_string( saacproto.token_list[6] )); + + saacproto_ACRaceRecordfmdo_recv( fd , charaindex , fmid , bbi , unicode , petname ); + return 0; + } + +#endif + + sprintf( debugfun, "%s", funcname); + + return -1; +} + +void saacproto_ACServerLogin_send( int fd,char* result,char* data ) +{ + saacproto_CreateHeader( saacproto.work , "ACServerLogin" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( result ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( data ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} + +void saacproto_ACCharList_send( int fd,char* result,char* output,int id ) +{ + saacproto_CreateHeader( saacproto.work , "ACCharList" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( result ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( output ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( id ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} +static int CharDataLens = 0; +#ifdef _NewSave +void saacproto_ACCharLoad_send( int fd,char* result,char* data,int id,int charindex ) +#else +void saacproto_ACCharLoad_send( int fd,char* result,char* data,int id ) +#endif +{ + if( strstr( result, "successful") != NULL && strlen( data) > CharDataLens ){ + CharDataLens = strlen( data); + //andy_log + log("最大数据长度:%d\n", CharDataLens ); + } + + saacproto_CreateHeader( saacproto.work , "ACCharLoad" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( result ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( data ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( id ) ,saacproto.workbufsize ); +#ifdef _NewSave + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( charindex ) ,saacproto.workbufsize ); +#endif + saacproto_Send( fd , saacproto.work ); +} + +#ifdef _RELOGIN +void saacproto_ACCharLoadII_send( int fd,char* result,char* data,int id,int charindex,int gs1,int gs2 ) +{ + saacproto_CreateHeader( saacproto.work , "ACCharLoadII" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( result ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( data ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( id ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( charindex ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( gs1 ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( gs2 ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} +#endif + +/* +214 :
  • servertoclient ACCharSave( string result , string data,int id);
    +215 : ACCharSave卞覆允月忒蚕[ +216 :

    +217 :
    +218 :
    string result +219 :
    "successful" , "failed" 及中勿木井[ +220 :
    string data +221 :
    "failed"及凛反 毛憎允谛棉及苇化坌月 侬 匹丐月[ +222 :
    int id +223 :
    娄醒及id毛公及引引戊疋□仄化忒允 +224 :
    +225 :
    +226 :
    +227 : +228 : +229 : +230 : +*/ + +void saacproto_ACCharSave_send( int fd,char* result,char* data,int id ) +{ + saacproto_CreateHeader( saacproto.work , "ACCharSave" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( result ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( data ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( id ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} + +#ifdef _RELOGIN +void saacproto_ACCharSaveII_send( int fd,char* result,char* data,int id,int gs1,int gs2 ) +{ + saacproto_CreateHeader( saacproto.work , "ACCharSaveII" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( result ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( data ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( id ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( gs1 ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( gs2 ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} +#endif + +/* +256 :
  • servertoclient ACCharDelete(string result, string data,int id);
    +257 : ACCharDelete卞覆允月忒蚕[ +258 :

    +259 :
    +260 :
    string result +261 :
    "successful" , "failed" 及中勿木井[ +262 :
    string data +263 :
    "failed"及凛反 毛憎允谛棉及苇化坌月 侬 匹丐月[ +264 :
    int id +265 :
    娄醒及id及公及引引及戊疋□ +266 : +267 :
    +268 :
    +269 :
    +270 : +*/ + +void saacproto_ACCharDelete_send( int fd,char* result,char* data,int id ) +{ + saacproto_CreateHeader( saacproto.work , "ACCharDelete" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( result ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( data ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( id ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} +/* +290 :
  • servertoclient ACLock( string result, string data ,int id);
    +291 : ACLock卞覆允月忒蚕[ +292 :

    +293 :
    +294 :
    string result +295 :
    "successful" , "failed" 及中勿木井[ +296 :
    string data +297 :
    "failed"及凛反 毛憎允谛棉及苇化坌月 侬 匹丐月[ +298 :
    int id +299 :
    娄醒及id及公及引引戊疋□ +300 :
    +301 :
    +302 :
    +303 : +*/ + +void saacproto_ACLock_send( int fd,char* result,char* data,int id ) +{ + saacproto_CreateHeader( saacproto.work , "ACLock" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( result ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( data ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( id ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} +/* +318 :
  • servertoclient ACUCheck( string mem_id );
    +319 : 失市它件玄扔□田□井日必□丞扔□田□卞覆仄化}丐月交□扒□互蜇箕夫弘奶件 +320 : 仄化中月井升丹井毛民尼永弁允月[ +321 :

    +322 :
    +323 :
    string mem_id +324 :
    譬屯月覆擂及交□扒□及gamersDream member id +325 :
    +326 :

    +327 : +328 : +*/ + +void saacproto_ACUCheck_send( int fd,char* mem_id ) +{ + saacproto_CreateHeader( saacproto.work , "ACUCheck" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( mem_id ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} +/* +344 :
  • servertoclient DBUpdateEntryString( string result, string table, string key, int msgid, int msgid2 );
    +345 : 晓及戊穴件玉及瑛绊[撩 仄化手荚汊尕第 卅及匹 骰仄化方中冗 +346 :
    +347 :
    string result +348 :
    successful 井failed +349 :
    string table +350 :
    +351 :
    int msgid +352 :
    +353 :
    int msgid2 +354 :
    +355 :
    +356 : +*/ + +void saacproto_DBUpdateEntryString_send( int fd,char* result,char* table,char* key,int msgid,int msgid2 ) +{ + saacproto_CreateHeader( saacproto.work , "DBUpdateEntryString" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( result ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( table ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( key ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid2 ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} +/* +369 :
  • servertoclient DBDeleteEntryString( string result, string table, string key , int msgid , int msgid2 );
    +370 : 侬 巨件玄伉及绰轮及瑛绊 +371 :
    +372 :
    string result +373 :
    successful / failed +374 :
    string table +375 :
    +376 :
    string key +377 :
    +378 :
    int msgid +379 :
    +380 :
    int msgid2 +381 :
    +382 :
    +383 : +*/ + +void saacproto_DBDeleteEntryString_send( int fd,char* result,char* table,char* key,int msgid,int msgid2 ) +{ + saacproto_CreateHeader( saacproto.work , "DBDeleteEntryString" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( result ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( table ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( key ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid2 ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} +/* +396 :
  • servertoclient DBGetEntryString( string result, string value, string table, string key, int msgid, int msgid2 );
    +397 : 潸曰分仄及忒曰袄 +398 :
    +399 :
    string result +400 :
    successful / failed +401 :
    string value +402 :
    袄 +403 :
    string table +404 :
    +405 :
    string key +406 :
    +407 :
    int msgid +408 :
    +409 :
    int msgid2 +410 :
    +411 :
    +412 : +*/ + +void saacproto_DBGetEntryString_send( int fd,char* result,char* value,char* table,char* key,int msgid,int msgid2 ) +{ + saacproto_CreateHeader( saacproto.work , "DBGetEntryString" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( result ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( value ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( table ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( key ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid2 ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} +/* +435 :
  • servertoclient DBUpdateEntryInt( string result , string table, string key, int msgid, int msgid2 );
    +436 : DBUpdateEntry及瑛绊[ +437 :
    +438 :
    string result +439 :
    succesful/failed +440 :
    string table +441 :
    □皮伙 毛公及引引井尹允 +442 :
    string key +443 :
    平□毛公及引引井尹允 +444 :
    int msgid, int msgid2 +445 :
    msgid 毛公及引引忒允[ +446 :
    +447 :

    +448 : +*/ +#ifdef _ALLDOMAN // Syu ADD 排行榜NPC +void saacproto_UpdataStele_send( int fd , char *data ) +{ + saacproto_CreateHeader( saacproto.work , "UpdataStele" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( data ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} + +void saacproto_S_UpdataStele_send( int fd , char *ocdkey , char *oname , char *ncdkey , + char *nname , char *title , int level , int trns , int floor ) { + saacproto_CreateHeader( saacproto.work , "S_UpdataStele" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( ocdkey ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( oname ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( ncdkey ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( nname ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( title ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( level ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( trns ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( floor ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); + +} +#endif +void saacproto_DBUpdateEntryInt_send( int fd,char* result,char* table,char* key,int msgid,int msgid2 ) +{ + saacproto_CreateHeader( saacproto.work , "DBUpdateEntryInt" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( result ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( table ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( key ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid2 ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} +/* +463 :
  • servertoclient DBGetEntryRank( string result , int rank , int count, string table, string key, int msgid, int msgid2 );
    +464 : 赐匏毛忒允[ +465 :
    +466 :
    string result +467 :
    successful/failed +468 :
    int rank +469 :
    赐匏[1动晓及袄毛潸月[ +470 :
    int count +471 :
    晓井日中仁勾户井[ 赓及巨件玄伉反0井日反元引月[ +472 :
    string table +473 :
    □皮伙 毛公及引引井尹允 +474 :
    string key +475 :
    平□毛公及引引井尹允 +476 :
    int msgid, int msgid2 +477 :
    msgid 毛公及引引忒允 +478 :
    +479 :

    +480 : +481 : +*/ + +void saacproto_DBGetEntryRank_send( int fd,char* result,int rank,int count,char* table,char* key,int msgid,int msgid2 ) +{ + saacproto_CreateHeader( saacproto.work , "DBGetEntryRank" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( result ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( rank ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( count ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( table ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( key ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid2 ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} +/* +494 :
  • servertoclient DBDeleteEntryInt( string result , string table, string key, int msgid, int msgid2 );
    +495 : 绰轮及瑛绊 +496 :
    +497 :
    string result +498 :
    successful/failed +499 :
    string table +500 :
    □皮伙 毛公及引引井尹允 +501 :
    string key +502 :
    平□毛公及引引井尹允 +503 :
    int msgid, int msgid2 +504 :
    msgid 毛公及引引忒允 +505 :
    +506 :

    +507 : +*/ + +void saacproto_DBDeleteEntryInt_send( int fd,char* result,char* table,char* key,int msgid,int msgid2 ) +{ + saacproto_CreateHeader( saacproto.work , "DBDeleteEntryInt" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( result ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( table ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( key ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid2 ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} +/* +520 :
  • servertoclient DBGetEntryInt( string result , int value , string table, string key, int msgid, int msgid2 );
    +521 : 巨件玄伉及袄毛井尹允 +522 :
    +523 :
    string result +524 :
    successful/failed +525 :
    int value +526 :
    袄公及手及 +527 :
    string table +528 :
    □皮伙 毛公及引引井尹允 +529 :
    string key +530 :
    平□毛公及引引井尹允 +531 :
    int msgid, int msgid2 +532 :
    msgid 毛公及引引忒允 +533 :
    +534 : +535 : +536 : +*/ + +void saacproto_DBGetEntryInt_send( int fd,char* result,int value,char* table,char* key,int msgid,int msgid2 ) +{ + saacproto_CreateHeader( saacproto.work , "DBGetEntryInt" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( result ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( value ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( table ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( key ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid2 ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} +/* +552 :
  • servertoclient DBGetEntryByRank( string result , string list , string table, int msgid, int msgid2 );
    +553 : DBGetEntryByRank及瑛绊[ +554 :
    +555 :
    string result +556 :
    +557 :
    string list +558 :
    "RANK,KEY,SCORE,INFO|RANK,KEY,SCORE,INFO|...."
    +559 : RANK反赐匏匹丐月[KEY反公及赐匏卞卅匀化中月旦戊失毛手匀化中月 +560 : 平□[SCORE反帮醒袄匹旦戊失匹丐月[ +561 : [
    +562 : "1,RINGO,123465,data1|2,HOGE,4567,data2|2,FUCK,4567,data3"
    +563 : 仇及 分午}2匏反2谛中月仇午卞卅月[ +564 :
    string table +565 :
    □皮伙 +566 :
    int msgid, int msgid2 +567 :
    +568 :
    +569 : +570 : +*/ + +void saacproto_DBGetEntryByRank_send( int fd,char* result,char* list,char* table,int msgid,int msgid2 ) +{ + saacproto_CreateHeader( saacproto.work , "DBGetEntryByRank" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( result ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( list ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( table ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid2 ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} +/* +583 :
  • servertoclient DBGetEntryByCount( string result , string list , string table, int count_start, int msgid, int msgid2 );
    +584 : DBGetEntryByCount 及瑛绊[ +585 :
    +586 :
    string result +587 :
    SUCCESSFUL/FAILED +588 :
    string list +589 :
    请 伉旦玄[1巨件玄伉丐凶曰 "INDEX,RANK,KEY,SCORE,INFO" 及4蜊及树 +590 : 及赚匹丐曰}公木互蜊醒坌 "|" 匹勾卅互月[蜊醒互0及桦宁反 +591 : 坞 侬 [ +592 :
    int num +593 :
    中仁勾午曰分允井[1卅日1蜊[2卅日2蜊[ +594 :
    int msgid ,msgid2 +595 :
    丢永本□斥ID. +596 :
    +597 : +*/ + +void saacproto_DBGetEntryByCount_send( int fd,char* result,char* list,char* table,int count_start,int msgid,int msgid2 ) +{ + saacproto_CreateHeader( saacproto.work , "DBGetEntryByCount" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( result ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( list ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( table ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( count_start ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( msgid2 ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} +/* +611 :
  • servertoclient Broadcast( string id, string charname, string message );
    +612 : Broadcast及失市它件玄扔□田□井日必□丞扔□田□尺及霜耨迕 +613 :
    +614 :
    string id +615 :
    user ID +616 :
    string charname +617 :
    character name +618 :
    string message +619 :
    丢永本□斥 +620 :
    int flag +621 :
    1卞允月午}愤坌卞卞反 霜今木卅中[ +622 :
    +623 : +*/ + +void saacproto_Broadcast_send( int fd,char* id,char* charname,char* message ) +{ + saacproto_CreateHeader( saacproto.work , "Broadcast" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( id ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( charname ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( message ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} +/* +642 :
  • servertoclient Message( string id_from, string charname_from, string id_to, string charname_to, string message , int option , int mesgid );
    +643 : 失市它件玄扔□田□井日必□丞扔□田□卞丢永本□斥毛霜耨允月[ +644 :
    +645 :
    string id_from +646 :
    from ID +647 :
    string charname_from +648 :
    from character name +649 :
    string id_to +650 :
    to ID +651 :
    string charname_to +652 :
    to character name +653 :
    string message +654 :
    丢永本□斥及 +655 :
    int option +656 :
    左皿扑亦件(晓及楮醒毛辅寰) +657 :
    int mesgid +658 :
    丢永本□斥ID 失市它件玄扔□田□及栋 迕 +659 :
    +660 : +*/ + +void saacproto_Message_send( int fd,char* id_from,char* charname_from,char* id_to,char* charname_to,char* message,int option,int mesgid ) +{ + saacproto_CreateHeader( saacproto.work , "Message" ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( id_from ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( charname_from ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( id_to ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( charname_to ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_string( message ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( option ) ,saacproto.workbufsize ); + saacproto_strcatsafe( saacproto.work , saacproto_mkstr_int( mesgid ) ,saacproto.workbufsize ); + saacproto_Send( fd , saacproto.work ); +} + +void saacproto_SetServerLogFiles( char *r , char *w ) +{ + saacproto_strcpysafe( saacproto_writelogfilename , w , sizeof(saacproto_writelogfilename )); + saacproto_strcpysafe( saacproto_readlogfilename , r , sizeof(saacproto_readlogfilename )); +} +int saacproto_InitServer( int (*writefunc)(int,char*,int) , int worksiz ) +{ + int i; + if( (void*)writefunc == NULL){saacproto.write_func = saacproto_default_write_wrap;} else {saacproto.write_func = writefunc;} + saacproto_AllocateCommonWork(worksiz); + saacproto_stringwrapper = (char**)calloc( 1,sizeof(char*) * MAXLSRPCARGS); + if(saacproto_stringwrapper ==NULL)return -1; + memset( saacproto_stringwrapper , 0, sizeof(char*)*MAXLSRPCARGS); + for(i=0;i +#include +#include +#ifndef WIN32 +#include +#include +#endif +#include "main.h" +#include "saacproto_util.h" +#ifdef saacproto__ENCRYPT +long saacproto_ringoCompressor( unsigned char *code , long codelen , unsigned char *text , long textlen); +long saacproto_ringoDecompressor( unsigned char *text , long textlen , unsigned char *code , long codelen); +#endif +/* + lsrpc routines +*/ +int saacproto_AllocateCommonWork(int bufsiz) +{ + saacproto.workbufsize = bufsiz; + saacproto.work = NULL; + saacproto.arraywork = NULL; + saacproto.escapework = NULL; + saacproto.val_str = NULL; + saacproto.token_list = NULL; + saacproto.cryptwork = NULL; + saacproto.jencodecopy = NULL; + saacproto.jencodeout = NULL; + saacproto.compresswork = NULL; + saacproto.work = (char*)calloc( 1, saacproto.workbufsize ); + saacproto.arraywork = (char*)calloc( 1, saacproto.workbufsize ); + saacproto.escapework = (char*)calloc( 1, saacproto.workbufsize ); + saacproto.val_str = (char*)calloc( 1, saacproto.workbufsize ); + saacproto.token_list = (char**)calloc( 1, saacproto.workbufsize *sizeof( char** ) ); + saacproto.cryptwork = (char*)calloc( 1, saacproto.workbufsize * 3 ); + saacproto.jencodecopy = (char*)calloc( 1, saacproto.workbufsize * 3 ); + saacproto.jencodeout = (char*)calloc( 1, saacproto.workbufsize * 3 ); + saacproto.compresswork = (char*)calloc( 1, saacproto.workbufsize * 3 ); + memset( saacproto.work , 0, saacproto.workbufsize ); + memset( saacproto.arraywork , 0, saacproto.workbufsize ); + memset( saacproto.escapework , 0, saacproto.workbufsize ); + memset( saacproto.val_str , 0, saacproto.workbufsize ); + memset( (char*)saacproto.token_list ,0, saacproto.workbufsize*sizeof(char**) ); + memset( saacproto.cryptwork , 0, saacproto.workbufsize*3 ); + memset( saacproto.jencodecopy , 0, saacproto.workbufsize*3 ); + memset( saacproto.jencodeout , 0, saacproto.workbufsize*3 ); + memset( saacproto.compresswork , 0, saacproto.workbufsize*3 ); + if( saacproto.work == NULL || + saacproto.arraywork == NULL || + saacproto.escapework == NULL || + saacproto.val_str == NULL || + saacproto.token_list == NULL || + saacproto.cryptwork == NULL || + saacproto.jencodecopy == NULL || + saacproto.jencodeout == NULL || + saacproto.compresswork == NULL ){ + free( saacproto.work);free( saacproto.val_str); + free( saacproto.escapework);free( saacproto.arraywork ); + free( saacproto.token_list);free( saacproto.cryptwork ); + free( saacproto.jencodecopy);free( saacproto.jencodeout ); + free( saacproto.compresswork ); + return -1; + } + return 0; +} +/********** + Get message information from a network input +**********/ +void saacproto_GetMessageInfo( int *id , char *funcname , int len, char **tk ) +{ + if( tk[0] == NULL || tk[1] == NULL ){ + *id = 0; + saacproto_strcpysafe( funcname , "" , len ); + return; + } + *id = strtoul( tk[0] ,NULL,10); + saacproto_strcpysafe( funcname , tk[1] , len ); + return; +} +/******************************************** + string utilities +*********************************************/ +void saacproto_strcpysafe( char *dest, char *src, int maxlen ) +{ + int i; + for(i=0;i (int)( saacproto.workbufsize*3-2) ){ + fprintf( stderr, "lsgen: badly configured work buflen\n" ); + exit(1); + } + if( (flag%2) == 1 ) flag ++; + saacproto.compresswork[0] = flag; + memcpy( saacproto.compresswork+1,src,srclen ); + compressed_l = srclen + 1; + } else { + if((flag%2)==0)flag++; + saacproto.compresswork[0] = flag; + compressed_l = saacproto_ringoCompressor( + (unsigned char*)saacproto.compresswork + 1 , + (long)saacproto.workbufsize*3 - 1, + (unsigned char*)src , + (long)strlen(src) ) + 1; /* be careful! */ + } + /* return empty line if error or buffer excess */ + if( compressed_l <= 0 ){ + saacproto_strcpysafe( out , "\n" , maxoutlen ); + return; + } + memcpy( saacproto.jencodecopy ,saacproto.compresswork ,compressed_l ); + saacproto_jEncode( saacproto.jencodecopy , compressed_l , JENCODE_KEY , + saacproto.jencodeout, &jencodedlen , saacproto.workbufsize*3 -1 ); + saacproto_encode64( (unsigned char*)saacproto.jencodeout , jencodedlen, (unsigned char*)out ); +} +/* translate code64 text to original lsrpc text */ +static void saacproto_decodeString( char *src , char *out ) +{ + int compressed_l =0, outlen64; + int l; + long decompressed_l = 0; + /* copy src to copybuffer because jencoder modifies the input buffer */ + l = strlen( src ); + if( src[l-1]=='\n' || src[l-1]=='\r' )src[l-1]=0; + if( src[l-2]=='\n' || src[l-2]=='\r' )src[l-2]=0; + outlen64 = saacproto_decode64( (unsigned char*)src , (unsigned char*)saacproto.jencodecopy ); + saacproto_jDecode( saacproto.jencodecopy , outlen64 , JENCODE_KEY, + saacproto.compresswork , &compressed_l); + /*out[outlen]=0; PENDING*/ + if( (saacproto.compresswork[0] % 2 ) == 0 ){ + if( compressed_l <= 0 ){ + decompressed_l = 0; + fprintf( stderr, "LSRPC: too short:[%s]\n", src ); + } else { + memcpy( out, saacproto.compresswork+1, compressed_l -1 ); + decompressed_l = compressed_l -1; + } + } else { + decompressed_l = + saacproto_ringoDecompressor( (unsigned char*)out , + (long)saacproto.workbufsize , + (unsigned char*)saacproto.compresswork+1 , + (long)compressed_l -1 ); + } + out[decompressed_l] = 0; +} +/* followings are taken from code64.c */ +char saacproto_charset[64]={ + 'A','B','C','D', 'E','F','G','H', + 'I','J','K','L', 'M','N','O','P', + 'Q','R','S','T', 'U','V','W','X', + 'Y','Z','a','b', 'c','d','e','f', + 'g','h','i','j', 'k','l','m','n', + 'o','p','q','r', 's','t','u','v', + 'w','x','y','z', '0','1','2','3', + '4','5','6','7', '8','9','+','-' +}; +char saacproto_reversecharset[256]={ + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,62, 0,63,0,0, + 52,53,54,55, 56,57,58,59, + 60,61,0,0, 0,0,0,0, + 0,0,1,2, 3,4,5,6, + 7,8,9,10, 11,12,13,14, + 15,16,17,18, 19,20,21,22, + 23,24,25,0, 0,0,0,0, + 0,26,27,28, 29,30,31,32, + 33,34,35,36, 37,38,39,40, + 41,42,43,44, 45,46,47,48, + 49,50,51,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0, + 0,0,0,0, 0,0,0,0 +}; + +static void saacproto_encode64( unsigned char *in , int len , unsigned char *out ) +{ + int i; + int use_bytes; + int address = 0; + out[0] = 0; + for(i=0;;i+=3){ + unsigned char in1 , in2 , in3; + unsigned char out1 ,out2 , out3 , out4; + if( i >= len ) break; + if( i >= (len-1)){ /* the last letter ( to be thrown away ) */ + in1 = in[i] & 0xff; + in2 = in3 = 0; + use_bytes = 2; + } else if( i >= (len-2)){ /* the last 2 letters ( process only 1 byte)*/ + in1 = in[i] & 0xff; + in2 = in[i+1] & 0xff; + in3 = 0; + use_bytes = 3; + } else { /* there are more or equal than 3 letters */ + in1 = in[i] & 0xff; + in2 = in[i+1] & 0xff; + in3 = in[i+2] & 0xff; + use_bytes = 4; + } + out1 = ((in1 & 0xfc)>>2) & 0x3f; + out2 = ((in1 & 0x03)<<4) | ((( in2 & 0xf0)>>4)&0x0f); + out3 = ((in2 & 0x0f)<<2) | ((( in3 & 0xc0)>>6)&0x03); + out4 = (in3 & 0x3f ); + if( use_bytes >= 2 ){ + out[address++] = saacproto_charset[out1]; + out[address++] = saacproto_charset[out2]; + out[address]=0; + } + if( use_bytes >= 3 ){ + out[address++] = saacproto_charset[out3]; + out[address]=0; + } + if( use_bytes >= 4 ){ + out[address++] = saacproto_charset[out4]; + out[address]=0; + } + } +} +/* + * Decode it + * char *in : encoded ascii chars + * char *out : decoded( output) + * return value : output byte count + * + * note: no need to have bigger buffer. because output is to + * be smaller than input string size + */ +static int saacproto_decode64( unsigned char *in , unsigned char *out ) +{ + unsigned char in1 , in2 , in3 , in4; + unsigned char out1 , out2 , out3; + int use_bytes; + int address= 0; + int i; + for(i=0;;i+=4 ){ + if( in[i] == 0 ){ + break; + } else if( in[i+1] == 0 ){ /* the last letter */ + break; + } else if( in[i+2] == 0 ){ /* the last 2 letters */ + in1 = saacproto_reversecharset[in[i]]; + in2 = saacproto_reversecharset[in[i+1]]; + in3 = in4 = 0; + use_bytes = 1; + } else if( in[i+3] == 0 ){ /* the last 3 letters */ + in1 = saacproto_reversecharset[in[i]]; + in2 = saacproto_reversecharset[in[i+1]]; + in3 = saacproto_reversecharset[in[i+2]]; + in4 = 0; + use_bytes = 2; + } else { /* process 4 letters */ + in1 = saacproto_reversecharset[in[i]]; + in2 = saacproto_reversecharset[in[i+1]]; + in3 = saacproto_reversecharset[in[i+2]]; + in4 = saacproto_reversecharset[in[i+3]]; + use_bytes = 3; + } + out1 = (in1<<2) | (((in2 & 0x30)>>4)&0x0f) ; + out2 = ((in2 & 0x0f )<<4) | ((( in3 & 0x3c)>>2)&0x0f); + out3 = ( (in3 &0x03)<<6) | ( in4 & 0x3f ); + if( use_bytes >= 1 ){ + out[address++] = out1; + } + if( use_bytes >= 2 ){ + out[address++] = out2; + } + if( use_bytes >= 3 ){ + out[address++] = out3; + } + if( use_bytes != 3 ){ + break; + } + } + return address; +} + +/* followings are taken from Jencode.c by jun */ +static void saacproto_jEncode(char *src,int srclen,int key,char *encoded,int *encodedlen,int maxencodedlen) +{ + char sum=0; + int i; + if(srclen+1 > maxencodedlen){ + *encodedlen = maxencodedlen; + for(i=0;i<(*encodedlen);i++)encoded[i] = src[i]; + } + if(srclen+1 <= maxencodedlen){ + *encodedlen=srclen+1; + for(i=0;i i) encoded[i] = src[i] + sum*((i*i)%3); + if(abs((key%srclen)) == i) encoded[i] = sum; + if(abs((key%srclen)) < i) encoded[i] = src[i-1] + sum*((i*i)%7); + } + } +} +static void saacproto_jDecode(char *src,int srclen,int key,char *decoded,int *decodedlen) +{ + char sum=0; + int i; + *decodedlen=srclen-1; + if( *decodedlen == 0 ){ + return; /* return error if length is 0 */ + } + sum = src[abs(key%(*decodedlen))]; + for(i=0;i i) decoded[i] = src[i] - sum*((i*i)%3); + if(abs((key%(*decodedlen))) < i) decoded[i-1] = src[i] - sum*((i*i)%7); + } + for(i=0;i<(*decodedlen);i++){ + if(((key%7) == (i%5))||((key%2) == (i%2)))decoded[i] = ~decoded[i]; + } +} + +/*****************************************************************/ +/* Compress / Decompress routine */ +/*****************************************************************/ +#define B00000000 0 +#define B00000001 1 +#define B00000010 2 +#define B00000011 3 +#define B00000100 4 +#define B00000101 5 +#define B00000110 6 +#define B00000111 7 +#define B00001000 8 +#define B00001001 9 +#define B00001010 10 +#define B00001011 11 +#define B00001100 12 +#define B00001101 13 +#define B00001110 14 +#define B00001111 15 +#define B00010000 16 +#define B00010001 17 +#define B00010010 18 +#define B00010011 19 +#define B00010100 20 +#define B00010101 21 +#define B00010110 22 +#define B00010111 23 +#define B00011000 24 +#define B00011001 25 +#define B00011010 26 +#define B00011011 27 +#define B00011100 28 +#define B00011101 29 +#define B00011110 30 +#define B00011111 31 +#define B00100000 32 +#define B00100001 33 +#define B00100010 34 +#define B00100011 35 +#define B00100100 36 +#define B00100101 37 +#define B00100110 38 +#define B00100111 39 +#define B00101000 40 +#define B00101001 41 +#define B00101010 42 +#define B00101011 43 +#define B00101100 44 +#define B00101101 45 +#define B00101110 46 +#define B00101111 47 +#define B00110000 48 +#define B00110001 49 +#define B00110010 50 +#define B00110011 51 +#define B00110100 52 +#define B00110101 53 +#define B00110110 54 +#define B00110111 55 +#define B00111000 56 +#define B00111001 57 +#define B00111010 58 +#define B00111011 59 +#define B00111100 60 +#define B00111101 61 +#define B00111110 62 +#define B00111111 63 +#define B01000000 64 +#define B01000001 65 +#define B01000010 66 +#define B01000011 67 +#define B01000100 68 +#define B01000101 69 +#define B01000110 70 +#define B01000111 71 +#define B01001000 72 +#define B01001001 73 +#define B01001010 74 +#define B01001011 75 +#define B01001100 76 +#define B01001101 77 +#define B01001110 78 +#define B01001111 79 +#define B01010000 80 +#define B01010001 81 +#define B01010010 82 +#define B01010011 83 +#define B01010100 84 +#define B01010101 85 +#define B01010110 86 +#define B01010111 87 +#define B01011000 88 +#define B01011001 89 +#define B01011010 90 +#define B01011011 91 +#define B01011100 92 +#define B01011101 93 +#define B01011110 94 +#define B01011111 95 +#define B01100000 96 +#define B01100001 97 +#define B01100010 98 +#define B01100011 99 +#define B01100100 100 +#define B01100101 101 +#define B01100110 102 +#define B01100111 103 +#define B01101000 104 +#define B01101001 105 +#define B01101010 106 +#define B01101011 107 +#define B01101100 108 +#define B01101101 109 +#define B01101110 110 +#define B01101111 111 +#define B01110000 112 +#define B01110001 113 +#define B01110010 114 +#define B01110011 115 +#define B01110100 116 +#define B01110101 117 +#define B01110110 118 +#define B01110111 119 +#define B01111000 120 +#define B01111001 121 +#define B01111010 122 +#define B01111011 123 +#define B01111100 124 +#define B01111101 125 +#define B01111110 126 +#define B01111111 127 +#define B10000000 128 +#define B10000001 129 +#define B10000010 130 +#define B10000011 131 +#define B10000100 132 +#define B10000101 133 +#define B10000110 134 +#define B10000111 135 +#define B10001000 136 +#define B10001001 137 +#define B10001010 138 +#define B10001011 139 +#define B10001100 140 +#define B10001101 141 +#define B10001110 142 +#define B10001111 143 +#define B10010000 144 +#define B10010001 145 +#define B10010010 146 +#define B10010011 147 +#define B10010100 148 +#define B10010101 149 +#define B10010110 150 +#define B10010111 151 +#define B10011000 152 +#define B10011001 153 +#define B10011010 154 +#define B10011011 155 +#define B10011100 156 +#define B10011101 157 +#define B10011110 158 +#define B10011111 159 +#define B10100000 160 +#define B10100001 161 +#define B10100010 162 +#define B10100011 163 +#define B10100100 164 +#define B10100101 165 +#define B10100110 166 +#define B10100111 167 +#define B10101000 168 +#define B10101001 169 +#define B10101010 170 +#define B10101011 171 +#define B10101100 172 +#define B10101101 173 +#define B10101110 174 +#define B10101111 175 +#define B10110000 176 +#define B10110001 177 +#define B10110010 178 +#define B10110011 179 +#define B10110100 180 +#define B10110101 181 +#define B10110110 182 +#define B10110111 183 +#define B10111000 184 +#define B10111001 185 +#define B10111010 186 +#define B10111011 187 +#define B10111100 188 +#define B10111101 189 +#define B10111110 190 +#define B10111111 191 +#define B11000000 192 +#define B11000001 193 +#define B11000010 194 +#define B11000011 195 +#define B11000100 196 +#define B11000101 197 +#define B11000110 198 +#define B11000111 199 +#define B11001000 200 +#define B11001001 201 +#define B11001010 202 +#define B11001011 203 +#define B11001100 204 +#define B11001101 205 +#define B11001110 206 +#define B11001111 207 +#define B11010000 208 +#define B11010001 209 +#define B11010010 210 +#define B11010011 211 +#define B11010100 212 +#define B11010101 213 +#define B11010110 214 +#define B11010111 215 +#define B11011000 216 +#define B11011001 217 +#define B11011010 218 +#define B11011011 219 +#define B11011100 220 +#define B11011101 221 +#define B11011110 222 +#define B11011111 223 +#define B11100000 224 +#define B11100001 225 +#define B11100010 226 +#define B11100011 227 +#define B11100100 228 +#define B11100101 229 +#define B11100110 230 +#define B11100111 231 +#define B11101000 232 +#define B11101001 233 +#define B11101010 234 +#define B11101011 235 +#define B11101100 236 +#define B11101101 237 +#define B11101110 238 +#define B11101111 239 +#define B11110000 240 +#define B11110001 241 +#define B11110010 242 +#define B11110011 243 +#define B11110100 244 +#define B11110101 245 +#define B11110110 246 +#define B11110111 247 +#define B11111000 248 +#define B11111001 249 +#define B11111010 250 +#define B11111011 251 +#define B11111100 252 +#define B11111101 253 +#define B11111110 254 +#define B11111111 255 +/* masks for first byte ( write )*/ +int saacproto_modifymask_first[8][9]={ + {0, B00000001,B00000011,B00000111,B00001111,B00011111,B00111111,B01111111,B11111111},/* mod 0*/ + {0, B00000011,B00000111,B00001111,B00011111,B00111111,B01111111,B11111111,B11111111},/* mod 1*/ + {0, B00000111,B00001111,B00011111,B00111111,B01111111,B11111111,B11111111,B11111111},/* mod 2*/ + {0, B00001111,B00011111,B00111111,B01111111,B11111111,B11111111,B11111111,B11111111},/* mod 3*/ + {0, B00011111,B00111111,B01111111,B11111111,B11111111,B11111111,B11111111,B11111111},/* mod 4*/ + {0, B00111111,B01111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111},/* mod 5*/ + {0, B01111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111},/* mod 6*/ + {0, B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111},/* mod 7*/ +}; +/* masks for second byte ( write ) */ +int saacproto_modifymask_second[8][9]={ + {0, B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000},/* mod 0 */ + {0, B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000001},/* mod 1 */ + {0, B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000001,B00000011},/* mod 2 */ + {0, B00000000,B00000000,B00000000,B00000000,B00000000,B00000001,B00000011,B00000111},/* mod 3 */ + {0, B00000000,B00000000,B00000000,B00000000,B00000001,B00000011,B00000111,B00001111},/* mod 4 */ + {0, B00000000,B00000000,B00000000,B00000001,B00000011,B00000111,B00001111,B00011111},/* mod 5 */ + {0, B00000000,B00000000,B00000001,B00000011,B00000111,B00001111,B00011111,B00111111},/* mod 6 */ + {0, B00000000,B00000001,B00000011,B00000111,B00001111,B00011111,B00111111,B01111111},/* mod 7 */ +}; +/* + * used by bitstream routines + */ +int bitstream_maxbyte, bitstream_bitaddr ; +char *bitstream_buf; +/* initialize bitstream for output */ +static int initOutputBitStream( char *buf ,int buflen) +{ + bitstream_bitaddr = 0; + bitstream_maxbyte = buflen; + bitstream_buf = buf; + memset( buf,0, buflen); + return 0; +} +/* initialize bitstream for input */ +static int initInputBitStream( char *buf , int buflen) +{ + bitstream_bitaddr = 0; + bitstream_maxbyte = buflen; + bitstream_buf = buf; + return 0; +} +/* + * read from bit stream. used only from 1 bit to 8 bits + * this is a base routine + */ +static unsigned int readInputBitStreamBody( int bwidth ) +{ + int mod = bitstream_bitaddr % 8; + int byteaddr = bitstream_bitaddr / 8; + /* return if excess */ + if( byteaddr >= bitstream_maxbyte)return 0; + if( bwidth >= 1 && bwidth <= 8){ + int b1 = (( bitstream_buf[byteaddr] & saacproto_modifymask_first[mod][bwidth] )>>mod); + int b2 = (( bitstream_buf[byteaddr+1] & saacproto_modifymask_second[mod][bwidth])<<(8-mod)); + bitstream_bitaddr += bwidth; + return b1 | b2; + } else { + return 0; + } +} +/* + * read from bit stream. used from 1 bit to 32 bits + * + */ +static unsigned int readInputBitStream( int bwidth ) +{ + if( bwidth <= 0 ){ + return 0; + } else if( bwidth >= 1 && bwidth <= 8 ){ + return readInputBitStreamBody( bwidth ); + } else if( bwidth >= 9 && bwidth <= 16 ){ + unsigned int first = readInputBitStreamBody(8); + unsigned int second = readInputBitStreamBody( bwidth-8); + return first + (second << 8 ); + } else if( bwidth >= 17 && bwidth <= 24 ){ + unsigned int first = readInputBitStreamBody(8); + unsigned int second = readInputBitStreamBody(8); + unsigned int third = readInputBitStreamBody(bwidth-8); + return first + ( second << 8 ) + ( third << 16 ); + } else if( bwidth >= 25 && bwidth <= 32 ){ + unsigned int first = readInputBitStreamBody(8); + unsigned int second = readInputBitStreamBody(8); + unsigned int third = readInputBitStreamBody(8); + unsigned int forth = readInputBitStreamBody(bwidth-8); + return first + ( second << 8 ) + ( third << 16 ) + ( forth << 24 ); + } + return 0; +} +/* + * write to a bitstream. only used from 1 bit to 8 bits + * this is a base routine. + */ +static int writeOutputBitStreamBody( int bwidth , unsigned char b) +{ + int mod = bitstream_bitaddr % 8; + int byteaddr = bitstream_bitaddr / 8; + /* return error if excess */ + if( bitstream_maxbyte <= (byteaddr+1)) return -1; + bitstream_buf[byteaddr] &= saacproto_modifymask_first[mod][bwidth]; + bitstream_buf[byteaddr] |= (b << mod) & saacproto_modifymask_first[mod][bwidth]; + bitstream_buf[byteaddr+1] &= saacproto_modifymask_second[mod][bwidth]; + bitstream_buf[byteaddr+1] |= (b>>(8-mod))& saacproto_modifymask_second[mod][bwidth]; + bitstream_bitaddr += bwidth; + return byteaddr+1; +} +/* + * write to a bitstream. used from 1 bits to 32 bits + * returns -1 if error or buffer excession + */ +static int writeOutputBitStream( int bwidth, unsigned int dat) +{ + int ret; + if( bwidth <= 0){ + return -1; + } else if( bwidth >= 1 && bwidth <= 8 ){ + if((ret=writeOutputBitStreamBody( bwidth , (unsigned char)dat))<0)return -1; + } else if( bwidth > 8 && bwidth <= 16 ){ + if(writeOutputBitStreamBody( 8 , (unsigned char)(dat&0xff))<0)return -1; + if((ret=writeOutputBitStreamBody( bwidth - 8 , ( unsigned char)((dat>>8)&0xff)))<0)return -1; + } else if( bwidth > 16 && bwidth <= 24 ){ + if(writeOutputBitStreamBody( 8 , (unsigned char)(dat&0xff))<0)return -1; + if(writeOutputBitStreamBody( 8 , (unsigned char)((dat>>8)&0xff))<0)return -1; + if((ret=writeOutputBitStreamBody( bwidth-16,(unsigned char)((dat>>16)&0xff)))<0)return -1; + } else if( bwidth > 24 && bwidth <= 32 ){ + if(writeOutputBitStreamBody( 8 , (unsigned char)(dat&0xff))<0)return -1; + if(writeOutputBitStreamBody( 8 , (unsigned char)((dat>>8)&0xff))<0)return -1; + if(writeOutputBitStreamBody( 8 , (unsigned char)((dat>>16)&0xff))<0)return -1; + if((ret=writeOutputBitStreamBody( bwidth-24,(unsigned char)((dat>>24)&0xff)))<0)return -1; + } else { + return -1; + } + return ret; +} +#define CHAR_SIZE 256 +#define NODE_SIZE 512 +#define BITS_LEN 9 /* 9 bit lzw compression */ +typedef struct { + unsigned char chr; + int parent; + int brother; + int child; +}NODE; +long saacproto_ringoCompressor( unsigned char *code , long codelen , + unsigned char *text , long textlen) +{ + NODE node[NODE_SIZE]; + int freeNode; + int w,k; /* used in this algo */ + int textind; /* index to text buffer */ + int i; + int position = 0; /* indicates the last byte of code buffer */ + if( textlen <= 0 ) return -1; + initOutputBitStream((char*) code,codelen); + /* fill characters ( 0 ~ 255 ) in the beggining part of + Node list */ + for(i=0; i<= CHAR_SIZE; i++){ + node[i].chr = (unsigned char)i; + node[i].brother = i + 1; + node[i].parent = 0; + node[i].child = 0; + } + node[CHAR_SIZE].brother = 0; + freeNode = CHAR_SIZE + 1; + w = text[0]; + textind = 1; + while(1){ + int rv; + if( textind >= textlen ){ + k = CHAR_SIZE; /* indicates EOF */ + } else { + k = text[textind]; + } + /* search if pattern 'wk' is registered or not. */ + rv = node[w].child; + while(1){ + if( rv <= 0 ) break; + if( node[rv].chr == k ) break; + rv = node[rv].brother; + } + if( rv > 0 ){ + /* found it */ + w = rv; + } else { + position = writeOutputBitStream( BITS_LEN ,w ); + /* return if buffer excession */ + if( position > codelen ) return -1; + /* register pattern 'wk' in the dictionary */ + if( freeNode < NODE_SIZE ){ + node[freeNode].parent = w; + node[freeNode].chr = k; + node[freeNode].brother = node[w].child; + node[freeNode].child = 0; + node[w].child = freeNode; + freeNode++; + } + w = k; + } + if( textind == ( textlen + 1 ) ) break; + textind++; + } + return position; +} + +/* + * Decoder. + * return -1 if buffer excession. Notice buffer text + * is modified . + */ +long saacproto_ringoDecompressor( unsigned char *text , long textlen , + unsigned char *code , long codelen) +{ + NODE node[NODE_SIZE]; + int stack[NODE_SIZE]; + int sp; + int freeNode; + int len; + int i; + int k = 0; + int w = 0; + if( codelen <= 0 ) return -1; + initInputBitStream( (char*)code , codelen ); + for(i=0;i= freeNode ){ + stack[sp++] = k; /* exception */ + if( sp >=( sizeof( stack ) /sizeof(stack[0] )) )return -1; + k = w; + } else { + k = rv; + } + while(k> CHAR_SIZE ){ + if( k >= (sizeof(node)/sizeof(node[0]))) return -1; + stack[sp++] = node[k].chr; + k = node[k].parent; + if( sp >=( sizeof( stack ) /sizeof(stack[0] )) ) return -1; + } + stack[sp++] = k; + if( sp >= ( sizeof( stack ) /sizeof(stack[0] )) ) return -1; + /* output to text buffer from stack.*/ + while(sp){ + if( ++len > textlen ) return -1; + *text++ = stack[--sp]; + } + /* register the pattern 'wk'*/ + if( len > 1 && freeNode < NODE_SIZE ){ + node[freeNode].parent = w; + node[freeNode].chr = k; + if( w >= (sizeof(node)/sizeof(node[0])))return -1; + node[freeNode].brother = node[w].child; + node[freeNode].child = 0; + node[w].child = freeNode; + freeNode++; + } + w = rv; + } + return len; +} +#endif /* ifdef saacproto__ENCRYPT */ + +/* Convert 62-base digits to 10 digits */ +int saacproto_a62toi( char *a ) +{ + int ret = 0; + int minus ; + if( a[0] == '-' ){ + minus = -1; + a++; + } else { + minus = 1; + } + + while( *a != '\0' ) + { + ret *= 62; + if( '0' <= (*a) && (*a) <= '9' ) + ret += (*a)-'0'; + else + if( 'a' <= (*a) && (*a) <= 'z' ) + ret += (*a)-'a'+10; + else + if( 'A' <= (*a) && (*a) <= 'Z' ) + ret += (*a)-'A'+36; + else + return 0; + a++; + } + return ret * minus; +} + +/* Convert 10-base digits into 62-base digits. */ +char *saacproto_cnv10to62( int a, char *out, int outlen ) +{ + int i, j; + char base[] = { "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"}; + int tmp[64]; + int src; + int minus; + int baselen = sizeof( base)-1; + if( a < 0 ){ + minus = 1; + a *= -1; + } else { + minus = 0; + } + /* special case */ + if( a < baselen) { + if( minus ){ + *(out) = '-'; + *(out+1) = base[a]; + *(out+2) = '\0'; + return (out); + } else { + *out = base[a]; + *(out+1) = '\0'; + return( out); + } + } + src = a; + for( i = 0; src >= baselen; i ++ ) { + tmp[i] = src % baselen; + src /= baselen; + } + i--; + if( minus ){ + *out = '-'; + *(out+1) = base[src]; + for( j = 2; i >= 0; i --, j ++ ) { + if( j > outlen - 2 ) return NULL; + *(out+j) = base[tmp[i]]; + } + } else { + *out = base[src]; + for( j = 1; i >= 0; i --, j ++ ) { + if( j > outlen - 2 ) return NULL; + *(out+j) = base[tmp[i]]; + } + } + *(out+j) = '\0'; + return( out); +} +#ifdef _NEW_PLAYERGOLD +nNEWPlayerList *NEWPlayerList; +void NEWPLAYER_FreeGoldInit() +{ + NEWPlayerList = ( nNEWPlayerList *)calloc( 1, MAXNEWPLAYERLIST * sizeof( struct _tagNEWPlayerList)); + if( NEWPlayerList == NULL ) return; + resetNEWPlayerList(); + LoadNEWPlayerListFile( "newuser.txt"); +} + +void resetNEWPlayerList() +{ + int i; + for( i=0; i=MAXNEWPLAYERLIST ){ + log( "ANDY err Not Fuond CdKey:%s In NEWPlayerList!\n", CdKey); + return NEW_DELERR; + } + return NEW_ERR; +} + +int AddNEWPlayertoFile( char *CdKey, char *UserName, int Strlens) +{ + int i; + + for( i=0; isizeof(NEWPlayerList[i].name))?sizeof(NEWPlayerList[i].name):Strlens); + NEWPlayerList[i].use = 1; + return NEW_ADDOK; + } + if( i>=MAXNEWPLAYERLIST ){ + log( "ANDY err NEWPlayerList Be Full !\n"); + return NEW_LISTFULL; + } + return NEW_ADDERR; +} + +#endif +/* end of generated code */ diff --git a/saac/saacproto_util.h b/saac/saacproto_util.h new file mode 100644 index 0000000..a33385a --- /dev/null +++ b/saac/saacproto_util.h @@ -0,0 +1,142 @@ +#ifndef _SAACPROTOUTIL_H_ +#define _SAACPROTOUTIL_H_ +#include "version.h" +#include +#include +#ifndef WIN32 +#include +#include +#endif + + +#define saacproto__NOENCRYPT +#define saacproto__NODEBUG +struct saacproto_ { + int (*write_func)(int,char*,int) ; /* write function */ + size_t workbufsize; /* size of work area */ + char *work,*arraywork,*escapework,*val_str,*ret_work; /* work areas which have same size */ + char *cryptwork,*jencodecopy,*jencodeout,*compresswork; /* these work has bigger size (3times)*/ + char** token_list; /* token list */ + unsigned long message_id; /*= 1, */ /* for generating message IDs */ +}; + +#ifdef _SAACPROTOUTIL_C_ +struct saacproto_ saacproto = { + NULL, + 0, + NULL,NULL,NULL,NULL,NULL, + NULL,NULL,NULL,NULL, + NULL, + 1, +}; + +char **saacproto_stringwrapper; +char saacproto_readlogfilename[1024]; +char saacproto_writelogfilename[1024]; +#else +extern char **saacproto_stringwrapper; +extern struct saacproto_ saacproto; +extern char saacproto_readlogfilename[1024]; +extern char saacproto_writelogfilename[1024]; +#endif +char* saacproto_escapeString( char*a ); +char* saacproto_descapeString( char*a ); +void saacproto_splitString( char *src ); +void saacproto_strcpysafe( char *dest, char *src, int len ); +void saacproto_strcatsafe( char *dest , char *src , int maxlen ); +char*saacproto_mkstr_int( int i ); +char*saacproto_mkstr_u_int( unsigned int i ); +char*saacproto_mkstr_long( long l ); +char*saacproto_mkstr_u_long( unsigned long l ); +char*saacproto_mkstr_short( short s ); +char*saacproto_mkstr_u_short( short s ); +char*saacproto_mkstr_char( char c ); +char*saacproto_mkstr_u_char( char c); +char*saacproto_mkstr_string( char*a ); +char*saacproto_mkstr_float( float f ); +char*saacproto_mkstr_double( double d ); +char*saacproto_mkstr_int_array( int size , int *array ); +char*saacproto_mkstr_u_int_array( int size , int *array ); +char*saacproto_mkstr_short_array( int size , short *array ); +char*saacproto_mkstr_u_short_array(int size , short *array ); +char *saacproto_mkstr_char_array( int size , char *array ); +char *saacproto_mkstr_u_char_array( int size , unsigned char *array ); +char *saacproto_mkstr_float_array( int size , float *array ); +char *saacproto_mkstr_double_array( int size , double *array ); +int saacproto_demkstr_int( char*a ); +unsigned int saacproto_demkstr_u_int( char*a ); +long saacproto_demkstr_long( char*a ); +unsigned long saacproto_demkstr_u_long(char*a ); +short saacproto_demkstr_short( char*a ); +unsigned short saacproto_demkstr_u_short( char*a ); +char saacproto_demkstr_char( char*a ); +unsigned char saacproto_demkstr_u_char( char*a ); +float saacproto_demkstr_float( char*a ); +double saacproto_demkstr_double(char*a ); +char* saacproto_demkstr_string( char*a); +int *saacproto_demkstr_int_array( char**tk ,int *buf ,int start , int size ); +int *saacproto_demkstr_u_int_array( char **tk , int *buf , int start , int size ); +unsigned int *saacproto_demkstr_long_array( + char **tk , unsigned int *buf , int start , int size ); +unsigned long *saacproto_demkstr_u_long_array( + char **tk , unsigned long *buf , int start , int size ); +short *saacproto_demkstr_short_array( char **tk , short *buf , int start , int size ); +unsigned short*saacproto_demkstr_u_short_array( + char **tk , unsigned short *buf , int start , int size ); +char *saacproto_demkstr_char_array( char **tk , char *buf , int start , int size ); +unsigned char *saacproto_demkstr_u_char_array( + char **tk , unsigned char*buf , int start , int size ); +float *saacproto_demkstr_float_array( char **tk , float *buf , int start , int size ); +double *saacproto_demkstr_u_double_array( char **tk , double *buf , int start , int size ); +char *saacproto_wrapStringAddr( char *copy , int maxcopylen , char*src ); + +void saacproto_GetMessageInfo( int *id , char *funcname , int len,char **tk ); +int saacproto_ClientRead(void); +void saacproto_consumeLine(char *buf , int ofs ); +void saacproto_copyLine( char*src , char *out , int maxoutlen ); +void saacproto_Send( int fd , char *msg ); +int saacproto_AllocateCommonWork(int bufsiz); +unsigned int saacproto_GetNewMessageID(void); +void saacproto_CreateHeader(char*out, char *fname ); +void saacproto_CreateHeaderID( char *out,unsigned long msgid , char *fname ); +int saacproto_default_write_wrap( int fd , char *buf , int size ); +void saacproto_bzero( char *b , int siz ); +void saacproto_bcopy(char*s , char *d , int siz ); +char *saacproto_Ltoa( long v ); +char *saacproto_Ultoa( unsigned long v ); +void saacproto_DebugSend( int fd , char *msg ); +/* Modified by ringo to fasten int type transfer */ +char *saacproto_cnv10to62( int a, char *out, int outlen ); +int saacproto_a62toi( char *a ); + + + +#ifdef _NEW_PLAYERGOLD +#define MAXNEWPLAYERLIST 100000 +typedef struct _tagNEWPlayerList +{ + char name[256]; + int use; +}nNEWPlayerList; + +enum{ + NEW_ERR=0, + NEW_DELOK, + NEW_DELERR, + NEW_ADDOK=11, + NEW_ADDERR, + NEW_LISTFULL, +}; +void NEWPLAYER_FreeGoldInit(); +void resetNEWPlayerList(); +void backupNEWPlayerListFile( char *filename, char *refilename); +void LoadNEWPlayerListFile( char *filename); +int DelNEWPlayerfromFile( char *CdKey, char *UserName, int RunType); +int AddNEWPlayertoFile( char *CdKey, char *UserName, int Strlens); +int LoadNEWPlayerListAdd( char *filename); + +#endif + +#endif + + diff --git a/saac/saacproto_work.c b/saac/saacproto_work.c new file mode 100644 index 0000000..63d4130 --- /dev/null +++ b/saac/saacproto_work.c @@ -0,0 +1,242 @@ +#include "version.h" +#include "main.h" +#include "recv.h" +#ifdef _FIX_WORKS +#include "saacproto_serv.h" +#include "saacproto_work.h" +#include "char.h" + +extern int worksockfd; +struct timeval select_timeout; +static int findWk = 0; +int FindWorkRegBlankCon( void ); + + +int SetWorkConnectionInit( int mem_use) +{ + cWork = ( struct connection *) calloc( 1, MAXWORKCONNECTION * sizeof( struct connection )); + if( cWork == NULL ){ + //free( wb ); + return 0; + } else { + int i; + for( i=0; i= 0 && cWork[i].closed_by_remote ==0 ){ + FD_SET( cWork[i].fd , & rfds ); + FD_SET( cWork[i].fd , & wfds ); + FD_SET( cWork[i].fd , & efds ); + } + } + + t = select_timeout; + sret = select( 1024, & rfds , (fd_set*)NULL, & efds , &t); + if( sret > 0 ) { + for(i=0;i< MAXWORKCONNECTION;i++){ + if( cWork[i].use && ( cWork[i].fd >= 0 ) && FD_ISSET( cWork[i].fd , &rfds ) ){ + int rr , readsize ; + readsize = sizeof( tmpbuf); + memset( tmpbuf, 0, sizeof( tmpbuf)); + rr = read( cWork[i].fd , tmpbuf , readsize ); + if( rr <= 0 ){ + cWork[i].closed_by_remote = 1; + } else { + MEMBuffer_AddWkReadBuffer( i, tmpbuf, WK_R); + } + } + } + } + t = select_timeout; + sret = select( 1024 , (fd_set*)NULL, &wfds, & efds , &t); + if( sret > 0 ) { + for(i=0;i= 0 ) && FD_ISSET( cWork[i].fd , &wfds )){ + int rr; + memset( tmpbuf, 0, sizeof( tmpbuf)); + if( MEMBuffer_getWkLineReadBuffer( i, tmpbuf, sizeof( tmpbuf), WK_W) <= 0 ) + continue; + rr = write( cWork[i].fd , tmpbuf , strlen(tmpbuf) ); + if( rr <= 0 ){ + cWork[i].closed_by_remote = 1; + }else { + } + } + } + } + for(i=0; i0) && FD_ISSET( worksockfd , & rfds )){ + struct sockaddr_in c; + int len , newsockfd; + int newcon; + bzero( &c , sizeof( c )); + len = sizeof( c ); + newcon = FindWorkRegBlankCon(); + //newcon = FindWorkRegBlankCon( ); + if( newcon < 0 ){ + continue; + } + newsockfd = accept( worksockfd , (struct sockaddr*)&c , &len ); + + if( newsockfd < 0 ){ +// UnWorkRegMemBuf( newcon ); + continue; + } + if( MAXWK <= findWk ) continue; + set_nodelay( newsockfd ); + cWork[newcon].fd = newsockfd; + memcpy( &cWork[newcon].remoteaddr , &c ,sizeof(c)); + tis[accepted] = newcon; + //andy_add + for( j=0; j= MAXWK ) findWk=0; + if( wk[findWk].use != 1 && wk[findWk].fd < 0 ) { + wk[findWk].status = WKSTAT_IDLE; + wk[findWk].use = 1; + wk[findWk].ti = newcon; + wk[findWk].fd = newsockfd; + log( "同意工作: sockfd:%d,newfd:%d=aWork:%d\n" , worksockfd, newsockfd, findWk); + break; + } + } + accepted ++; + } + } + + return accepted; +} + +int cWork_write( int ti , char *buf , int len ) +{ + if( ti < 0 || ti >= MAXWORKCONNECTION || cWork[ti].use == 0 ) + return TCPSTRUCT_EINVCIND; + return MEMBuffer_AddWkReadBuffer( ti, buf, WK_W); +} + +int Work_close( int ti ) +{ + if( ti < 0 || ti >= MAXWORKCONNECTION )return TCPSTRUCT_EINVCIND; + if( cWork[ti].use == 0 ){ + return TCPSTRUCT_ECLOSEAGAIN; + } + close( cWork[ti].fd ); + cWork[ti].use = 0; + cWork[ti].fd = -1; + + MEMBuffer_clean( ti); + + cWork[ti].mbtop_ri = -1; + cWork[ti].mbtop_wi = -1; + + return OK; +} +#endif + + +MEMBuffers memBuf[MAXWORKCONNECTION]; //30 +void MEMBuffer_Init() +{ + int i; + for( i=0; i sizeof( memBuf[ti].buff) ) return -1; + memcpy( memBuf[ti].buff, data, strlen( data)+1); + memBuf[ti].WR = flg; + + return 1; +} + +int MEMBuffer_getWkLineReadBuffer( int ti, char *data, int sizes, int flg) +{ + if( !memBuf[ti].use ) return -1; + if( memBuf[ti].WR != flg )return -1; + + if( sizes < sizeof( memBuf[ti].buff) ){ + memBuf[ti].WR = -1; + memset( memBuf[ti].buff, 0, sizeof( memBuf[ti].buff)); + return -1; + } + memcpy( data, memBuf[ti].buff, sizeof( memBuf[ti].buff)); + memBuf[ti].WR = -1; + memset( memBuf[ti].buff, 0, sizeof( memBuf[ti].buff)); + return 1; +} + +void MEMBuffer_clean( int ti) +{ + memset( memBuf[ti].buff, 0, sizeof( memBuf[ti].buff) ); + memBuf[ti].use = 0; + memBuf[ti].WR =-1; +} + +int MEMBuffer_Find( int ti) +{ + if( !memBuf[ti].use ){ + memBuf[ti].use = 1; + memBuf[ti].WR =-1; + return 1; + } + + return -1; +} + +int FindWorkRegBlankCon( void ) +{ + int i; + + for(i=0;i +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "saacproto_work.h" +#ifdef _OACSTRUCT_TCP +#include "saacproto_oac.h" +#endif +#ifdef _PAUCTION_MAN +#include "auction.h" +#endif +#include "lock.h" +#define BACKLOGNUM 5 + + +#ifdef _FIX_WORKS +#include "saacproto_work.h" +int worksockfd; +#endif + +#ifdef _LOCK_SERVER +#include "saacproto_lserver.h" +#endif + +#ifdef _SEND_EFFECT // WON ADD 送下雪、下雨等特效 +#include "recv.h" +#endif + +#include "defend.h" + +#include "char.h" + +#include + +#define BOOL int +#define FALSE 0 +#define TRUE 1 +MYSQL mysql; +MYSQL_RES *mysql_result; +MYSQL_ROW mysql_row; + +typedef struct tagConfig +{ + char sql_IP[16]; + + int sql_Port; + + char sql_Port1[16]; + + char sql_ID[16]; + + char sql_PS[16]; + + char sql_DataBase[16]; + + char sql_Table[16]; + + char sql_Name[16]; + + char sql_PassWord[16]; + + char sql_RegTime[16]; + + char sql_LoginTime[16]; + + char sql_Path[10]; + + char sql_OnlineName[16]; + +}Config; + +Config config; + +int AutoReg; + +static int readConfig( char *path ) +{ + char buf[2048]; + FILE *fp; + + fp = fopen( path , "r" ); + if( fp == NULL ){ return -2; } + + while( fgets( buf , sizeof( buf ) , fp )){ + char command[1024]; + char param[2048]; + chop(buf); + + easyGetTokenFromString( buf , 1 , command , sizeof( command )); + easyGetTokenFromString( buf , 2 , param , sizeof( param )); + + if( strcmp( command , "sql_IP" ) == 0 ){ + strcmp( config.sql_IP , param ) ; + snprintf( config.sql_IP , sizeof( config.sql_IP) , param ); + log("\n数据库地址: %s",config.sql_IP); + } else if( strcmp( command , "sql_Port" ) == 0 ){ + config.sql_Port = atoi( param ); + snprintf( config.sql_Port1 , sizeof( config.sql_Port1) , param ); + log("\n数据库端口: %d",config.sql_Port); + } else if( strcmp( command , "sql_ID" ) == 0 ){ + strcmp( config.sql_ID , param ) ; + snprintf( config.sql_ID , sizeof( config.sql_ID) , param ); + log("\n数据库用户: %s",config.sql_ID); + } else if( strcmp( command , "sql_PS" ) == 0 ){ + strcmp( config.sql_PS , param ) ; + snprintf( config.sql_PS , sizeof( config.sql_PS) , param ); + log("\n数据库密码: %s",config.sql_PS); + } else if( strcmp( command , "sql_DataBase" ) == 0 ){ + strcmp( config.sql_DataBase , param ) ; + snprintf( config.sql_DataBase , sizeof( config.sql_DataBase) , param ); + log("\n登陆数据库名:%s",config.sql_DataBase); + } else if( strcmp( command , "sql_Table" ) == 0 ){ + strcmp( config.sql_Table , param ) ; + snprintf( config.sql_Table , sizeof( config.sql_Table) , param ); + log("\n数据库表名: %s",config.sql_Table); + } else if( strcmp( command , "sql_Name" ) == 0 ){ + strcmp( config.sql_Name , param ) ; + snprintf( config.sql_Name , sizeof( config.sql_Name) , param ); + log("\n用户名字段: %s",config.sql_Name); + } else if( strcmp( command , "sql_PassWord" ) == 0 ){ + strcmp( config.sql_PassWord , param ) ; + snprintf( config.sql_PassWord , sizeof( config.sql_PassWord) , param ); + log("\n密码字段: %s",config.sql_PassWord); + } else if( strcmp( command , "sql_RegTime" ) == 0 ){ + strcmp( config.sql_RegTime , param ) ; + snprintf( config.sql_RegTime , sizeof( config.sql_RegTime) , param ); + log("\n注册时间: %s",config.sql_RegTime); + } else if( strcmp( command , "sql_LoginTime" ) == 0 ){ + strcmp( config.sql_LoginTime , param ) ; + snprintf( config.sql_LoginTime , sizeof( config.sql_LoginTime) , param ); + log("\n登陆时间: %s",config.sql_LoginTime); + } else if( strcmp( command , "sql_Path" ) == 0 ){ + strcmp( config.sql_Path , param ) ; + snprintf( config.sql_Path , sizeof( config.sql_Path) , param ); + log("\n路径字段: %s",config.sql_Path); + } else if( strcmp( command , "sql_OnlineName" ) == 0 ){ + strcmp( config.sql_OnlineName , param ) ; + snprintf( config.sql_OnlineName , sizeof( config.sql_OnlineName) , param ); + log("\n在线玩家字段:%s",config.sql_OnlineName); + } else if( strcmp( command , "AutoReg" ) == 0 ){ + AutoReg = atoi( param ); + log("\n开放自动注册:%d",AutoReg); + fclose(fp); + return 0; + } + } +} + +BOOL sasql_init( void ) +{ + +if( mysql_init(&mysql) == NULL & readConfig("acserv.cf")) +{ + log("\n数据库初始化失败!"); + exit(1); + return FALSE; +} + + if( !mysql_real_connect( &mysql, + config.sql_IP, + config.sql_ID,//帐号 + config.sql_PS,//密码 + config.sql_DataBase,//选择的资料库 + config.sql_Port, + NULL, + 0 ) ) + { + log("\n更新数据库失败!\n"); + return FALSE; + } + + log("\n数据库连接成功!\n"); +#ifdef _SQL_BACKGROUND + if(!sasql_initonline()) + log("\n数据库初始化失败!\n"); +#endif + return TRUE; +} + +void sasql_close( void ) +{ + mysql_close( &mysql ); +} + + +BOOL sasql_query(char *nm, char *pas){ + char sqlstr[256]; + sprintf(sqlstr,"select * from %s where %s=BINARY'%s' and %s=BINARY'%s'",config.sql_Table,config.sql_Name,nm,config.sql_PassWord,pas); + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + mysql_free_result(mysql_result); + if(num_row==1){ + return TRUE;} + else{ + return FALSE;}} + else{ + log("\n 数据库查找失败!\n"); + return FALSE;} +} + + +#ifdef _SQL_BACKGROUND +BOOL sasql_update(char *nm, char *path){ + char sqlstr[256]; + sprintf(sqlstr,"update %s set %s='%s' where %s=BINARY'%s'",config.sql_Table,config.sql_Path,path,config.sql_Name,nm); + if(!mysql_query(&mysql,sqlstr)){ + return TRUE;} + else{ + log("\n更新数据库失败!\n"); + return FALSE;} +} + +BOOL sasql_online(char *nm,char *lnm){ + char sqlstr[256]; + sprintf(sqlstr,"update %s set %s='%s',%s=NOW() where %s=BINARY'%s'",config.sql_Table,config.sql_OnlineName,lnm,config.sql_LoginTime,config.sql_Name,nm); + if(!mysql_query(&mysql,sqlstr)){ + return TRUE;} + else{ + log("\n更新数据库失败!\n"); + return FALSE;} +} + +BOOL sasql_initonline(){ + char sqlstr[256]; + sprintf(sqlstr,"update %s set %s=NULL",config.sql_Table,config.sql_OnlineName); + if(!mysql_query(&mysql,sqlstr)){ + return TRUE;} + else{ + return FALSE;} +} +#endif + +#ifdef _SQL_REGISTER +BOOL sasql_register(char *nm, char *pas){ + char sqlstr[256]; + if(AutoReg==1) + { + sprintf(sqlstr,"select * from %s where %s=BINARY'%s'",config.sql_Table,config.sql_Name,nm); + if(!mysql_query(&mysql,sqlstr)){ + int num_row=0; + mysql_result=mysql_store_result(&mysql); + num_row=mysql_num_rows(mysql_result); + mysql_free_result(mysql_result); + if(num_row==0){ + sprintf(sqlstr,"INSERT INTO %s (%s,%s,%s) VALUES ('%s','%s',NOW())",config.sql_Table,config.sql_Name,config.sql_PassWord,config.sql_RegTime,nm,pas); + if(!mysql_query(&mysql,sqlstr)){ + log("\n新用户注册成功!\n"); + return TRUE;} + else{ + log("\n新用户注册失败!\n"); + return FALSE;}} + else{ + return FALSE;}} + else{ + log("\n 数据库查找失败!\n"); + return FALSE;} + } + else{ + return FALSE;} +} +#endif + +#endif \ No newline at end of file diff --git a/saac/sasql.h b/saac/sasql.h new file mode 100644 index 0000000..72b7d07 --- /dev/null +++ b/saac/sasql.h @@ -0,0 +1,34 @@ +#ifndef _SASQL_H_ +#define _SASQL_H_ + +#include "version.h" +#ifdef _SASQL +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +void sasql_close( void ); +int sasql_save_nm( int idx, char *acc, char *data );//左右人物, 帐号, 资料 +int sasql_save_opt( int idx, char *acc, char *data ); +int sasql_save_int_info( int idx, char *acc, char *data ); +int sasql_save_char_info( int idx, char *acc, char *data ); + +BOOL sasql_init( void ); +BOOL sasql_query(char *nm, char *pas); +BOOL sasql_update(char *nm, char *path); +BOOL sasql_logindate(char *nm); +BOOL sasql_online(char *nm,char *lnm,int online); +BOOL sasql_register(char *nm, char *pas); +#endif + +#endif diff --git a/saac/tcpip_util.c b/saac/tcpip_util.c new file mode 100644 index 0000000..0319248 --- /dev/null +++ b/saac/tcpip_util.c @@ -0,0 +1,473 @@ +#include "version.h" +#include "main.h" +#include "tcpip_util.h" + +#ifdef _TCPIP_UTIL +struct connection *tcpcon; +struct membuf *mems=NULL; +static int me_find=0; +static int tpsockfd1=-1; +int mesize; +int meuse; +char tmpbuf[65536]; + +#define BACKLOGNUM 5 +struct timeval select_timeout; +struct sockaddr_in localaddr; + +int MEMBUF_InitSize( int mem_use, int db ) +{ + mesize = mem_use / sizeof( struct membuf ); + meuse = 0; + me_find = 0; + mems = ( struct membuf * ) calloc( 1, mesize * sizeof(struct membuf )); + if( mems == NULL ) return TCPSTRUCT_ENOMEM; + bzero( mems , mesize * sizeof( struct membuf )); + + tcpcon = ( struct connection *) calloc( 1, MAXTCPCONNECTION * sizeof( struct connection )); + if( tcpcon == NULL ){ + free( mems ); + return TCPSTRUCT_ENOMEM; + } else { + int i; + for( i=0; i= mesize || me_find < 0 ) + me_find = 0; + if( mems[me_find].use == 0 ){ + mems[me_find].use = 1; + mems[me_find].len = 0; + mems[me_find].next = -1; + meuse ++; + return me_find; + } + } + return TCPSTRUCT_EMBFULL; +} + +int MEMBUF_findregBlankCon( void ) +{ + int i; + for( i=0; i= fr ){ + FILE *fp; + if( (fp=fopen( "badsysinfo.txt", "a+")) != NULL ){ + fprintf( fp, "appendMemBufList() len:%d / fr:%d err !! \n", len, fr); + fclose( fp); + } + return -1; + } + + data[len] = 0; + for(;;){ + int blanksize = sizeof( mems[0].buf ) - mems[top].len; + int cpsize = ( rest <= blanksize ) ? rest : blanksize; + memcpy( mems[top].buf + mems[top].len, data + data_topaddr , cpsize ); + mems[top].len += cpsize; + + if( rest <= blanksize ){ + return len; + } else { + int newmb; + rest -= cpsize; + data_topaddr += cpsize; + if( (newmb = MEMBUF_findregBlankMemBuf() ) == TCPSTRUCT_EMBFULL ){ + FILE *fp; + if( (fp=fopen( "badsysinfo.txt", "a+")) != NULL ){ + fprintf( fp, "find newmb == TCPSTRUCT_EMBFULL err data:%s !!\n", data); + fclose( fp); + } + log( "find newmb == TCPSTRUCT_EMBFULL err data:%s !!\n", data); + } + mems[top].next = newmb; + top = mems[top].next; + } + } + + return TCPSTRUCT_EBUG; +} + +int MEMBUF_consumeMemBufList( int top, char *out, int len, int consumeflag , int copyflag ) +{ + int total = 0; + int top_store = top; + for(;;){ + int cpsize; + if( top == -1 ) break; + cpsize=(mems[top].len<=(len-total))?mems[top].len:(len-total); + if( copyflag ) memcpy( out + total , mems[top].buf , cpsize ); + total += cpsize; + if( consumeflag ){ + mems[top].len -= cpsize; + if( mems[top].len > 0 ){ + memmove( mems[top].buf, mems[top].buf+cpsize, sizeof(mems[top].buf)-cpsize); + } + } + top = mems[top].next; + if( total == len ){ + break; + } + } + if( consumeflag ){ + top = mems[top_store].next; + for(;;){ + if( top == -1 )break; + if( mems[top].len == 0 ){ + int prev; + mems[top_store].next = mems[top].next; + prev = top; + top = mems[top].next; + MEMBUF_unregMemBuf( prev); + } else { + top = mems[top].next; + } + } + } + return total; +} + +int MEMBUF_getLineReadBuffer( int ti , char *buf, int len ) +{ + int i, l; + int top = tcpcon[ti].mbtop_ri; + int tci = 0 , breakflag = 0; + for(;;){ + l = mems[top].len; + if( top == -1 )break; + for( i=0 ; i < l ; i++){ + if( mems[top].buf[i] == '\n' ){ + breakflag = 1; + break; + } + tci ++; + } + if( breakflag )break; + top = mems[top].next; + } + if( tci > len ) + return TCPSTRUCT_ETOOLONG; + if( breakflag == 0 ) + return 0; + return MEMBUF_consumeMemBufList( tcpcon[ti].mbtop_ri , buf , tci+1 , 1 , 1 ); +} + +int MEMBUF_readline( int ti , char *buf , int len , int kend , int kend_r ) +{ + int l; + int minus = 0; + if( ti < 0 || ti >= MAXTCPCONNECTION || tcpcon[ti].use == 0 ) + return TCPSTRUCT_EINVCIND; + l = MEMBUF_getLineReadBuffer( ti , buf , len ); + if( l == 0 ){ + if( tcpcon[ti].closed_by_remote ){ + return TCPSTRUCT_EREADFIN; + } else { + return 0; + } + } + if( kend ){ + if( buf[l-1]=='\n' ) buf[l-1] = 0; minus =-1; + } + if( kend_r ){ + if( buf[l-1]=='\r' ) buf[l-1] = 0; minus = -1; + if( buf[l-2]=='\r' ) buf[l-2] = 0; minus = -2; + } + return l + minus; +} + +int MEMBUF_readline_chop( int ti , char *buf, int len ) +{ + return MEMBUF_readline( ti , buf , len , 1,1); +} + +int MEMBUF_writeline( int ti , char *buf , int len ) +{ + if( ti < 0 || ti >= MAXTCPCONNECTION || tcpcon[ti].use == 0 ) + return TCPSTRUCT_EINVCIND; + return MEMBUF_appWriteBuffer( ti , buf , len ); +} + +//----------------------------------------------------------------------------- + +int TCPIP_bindSocket( char *addr , int p , int timeout_ms) +{ + int sockets; + + //andy_log + log("_bindSocket( %d, %d)\n", p, timeout_ms); + + select_timeout.tv_sec = timeout_ms / 1000; + select_timeout.tv_usec = (timeout_ms - ( timeout_ms/1000)*1000)*1000; + //socket + if( (sockets = socket( AF_INET , SOCK_STREAM , 0 ) ) < 0 ) + return TCPSTRUCT_ESOCK; + //bind + bzero( &localaddr ,sizeof( localaddr )); + localaddr.sin_family = AF_INET; + localaddr.sin_port = htons( p ); + if( addr ){ + localaddr.sin_addr.s_addr = inet_addr( addr ); + } else { + localaddr.sin_addr.s_addr = htonl( INADDR_ANY ); + } + if( bind( sockets, (struct sockaddr*) &localaddr, sizeof( localaddr )) < 0 ) + return TCPSTRUCT_EBIND; + //listen + if( listen( sockets , BACKLOGNUM ) < 0 ) + return TCPSTRUCT_ELISTEN; + + tpsockfd1 = sockets; + return OK; +} + +int TCPIP_connect( char *addr , int port ) +{ + int newti ; + int s, r; + struct sockaddr_in svaddr; + struct hostent *he; + + if( (s = socket( AF_INET, SOCK_STREAM , 0 )) < 0 ) return -2; + bzero( &svaddr , sizeof( svaddr )); + svaddr.sin_family = AF_INET; + svaddr.sin_port = htons( port ); + + if( inet_aton( addr, &svaddr.sin_addr ) == 0 ){ + he = gethostbyname( addr ); + if( he == NULL ){ + return TCPSTRUCT_EHOST; + } + memcpy( & svaddr.sin_addr.s_addr , he->h_addr , + sizeof( struct in_addr)); + } + r = connect( s , ( struct sockaddr*)&svaddr,sizeof(svaddr)); + if( r < 0 ){ + return TCPSTRUCT_ECONNECT; + } + set_nodelay( s ); + newti = MEMBUF_findregBlankCon( ); + if( newti < 0 ){ + log( "connection FULL: newti:%d !\n", newti ); + return TCPSTRUCT_ECFULL; + } + + tcpcon[newti].fd = s; + memcpy( &tcpcon[newti].remoteaddr, &svaddr, sizeof( struct sockaddr_in)); + return newti; +} + + +int TCPIP_close( int ti ) +{ + if( ti < 0 || ti >= MAXTCPCONNECTION )return TCPSTRUCT_EINVCIND; + if( tcpcon[ti].use == 0 ){ + return TCPSTRUCT_ECLOSEAGAIN; + } + close( tcpcon[ti].fd ); + tcpcon[ti].use = 0; + tcpcon[ti].fd = -1; + MEMBUF_consumeMemBufList( tcpcon[ti].mbtop_ri , NULL, mesize * sizeof( mems[0].buf ), 1, 0 ); + MEMBUF_consumeMemBufList( tcpcon[ti].mbtop_wi , NULL, mesize * sizeof( mems[0].buf ), 1, 0 ); + MEMBUF_unregMemBuf( tcpcon[ti].mbtop_ri ); + MEMBUF_unregMemBuf( tcpcon[ti].mbtop_wi ); + + tcpcon[ti].mbtop_ri = -1; + tcpcon[ti].mbtop_wi = -1; + return OK; +} + +int TCPIP_selectdata( void) +{ + int i; + int sret; + struct timeval t; + + fd_set rfds, wfds , efds; + FD_ZERO( & rfds ); + FD_ZERO( & wfds ); + FD_ZERO( & efds ); + + for(i=0;i= 0 && tcpcon[i].closed_by_remote ==0 ){ + FD_SET( tcpcon[i].fd , & rfds ); + FD_SET( tcpcon[i].fd , & wfds ); + FD_SET( tcpcon[i].fd , & efds ); + } + } + + t = select_timeout; + sret = select( 1024, & rfds , (fd_set*)NULL, & efds , &t); + if( sret > 0 ) { + for(i=0; i= 0 ) && FD_ISSET( tcpcon[i].fd , &rfds ) ){ + int fr = MEMBUF_getFreeMem( ); + int rr , readsize ; + if( fr <= 0 ) continue; + if( fr > sizeof(tmpbuf ) ){ + readsize = sizeof( tmpbuf); + } else { + readsize = fr; + } + rr = read( tcpcon[i].fd , tmpbuf , readsize ); + if( rr <= 0 ){ + tcpcon[i].closed_by_remote = 1; + } else { + MEMBUF_appReadBuffer( i , tmpbuf , rr ); + } + } + } + } + /* write */ + t = select_timeout; + sret = select( 1024, (fd_set*)NULL, &wfds, & efds , &t); + if( sret > 0 ) { + for(i=0;i= 0 ) && FD_ISSET( tcpcon[i].fd , &wfds ) ){ + char send_buf[4096]; + int l , rr; + memset( send_buf, 0, sizeof( send_buf)); + l = MEMBUF_consumeMemBufList( tcpcon[i].mbtop_wi ,send_buf, sizeof(send_buf),0 , 1 ); + rr = write( tcpcon[i].fd , send_buf , l ); + if( rr < 0 ){ + tcpcon[i].closed_by_remote = 1; + } else { + MEMBUF_consumeMemBufList( tcpcon[i].mbtop_wi , send_buf, l, 1 , 0 ); + } + } + } + } + return 1; +} + +int TCPIP_accept( int *tis , int ticount ) +{ + int i, accepted=0; + fd_set rfds, wfds , efds; + + for( i=0; i 0) && FD_ISSET( tpsockfd1 , & rfds )){ + struct sockaddr_in c; + int len , newsockfd; + int newcon; + bzero( &c , sizeof( c )); + len = sizeof( c ); + fprintf( stderr, "i can accept " ); + newcon = MEMBUF_findregBlankCon( ); + if( newcon < 0 ) continue; + newsockfd = accept( tpsockfd1, (struct sockaddr*)&c , &len ); + log( "tcpip accept: %d\n" , newsockfd ); + if( newsockfd < 0 ){ + MEMBUF_unregMemBuf( newcon ); + continue; + } + set_nodelay( newsockfd ); + tcpcon[newcon].fd = newsockfd; + memcpy( &tcpcon[newcon].remoteaddr , &c ,sizeof(c)); + tis[accepted] = newcon; + accepted ++; + } + } + + return accepted; +} + +int TCPIP_send( int ti , char *buf , int len ) +{ + return MEMBUF_writeline( ti , buf , len ); +} + +int TCPIP_checkCon( int ti) +{ + if( ti < 0 || ti >= MAXTCPCONNECTION) return 0; + return tcpcon[ti].use; +} + +#endif diff --git a/saac/tcpip_util.h b/saac/tcpip_util.h new file mode 100644 index 0000000..c0a26c6 --- /dev/null +++ b/saac/tcpip_util.h @@ -0,0 +1,33 @@ +#ifndef _TCPIPAC_H +#define _TCPIPAC_H +#include "version.h" + +#ifdef _TCPIP_UTIL +#define MAXTCPCONNECTION 15 +int MEMBUF_InitSize( int mem_use, int db ); +int MEMBUF_unregMemBuf( int ti ); +int MEMBUF_findregBlankMemBuf( void ); +int MEMBUF_findregBlankCon( void ); +int MEMBUF_getFreeMem( void ); +int MEMBUF_appReadBuffer( int ti, char *data, int len); +int MEMBUF_appWriteBuffer( int ti, char *data, int len ); +int MEMBUF_appMemBufList( int top , char *data , int len ); +int MEMBUF_consumeMemBufList( int top, char *out, int len, int + consumeflag, int copyflag ); +int MEMBUF_getLineReadBuffer( int ti , char *buf, int len ); +int MEMBUF_readline( int ti , char *buf , int len , int kend , int kend_r ); +int MEMBUF_readline_chop( int ti , char *buf, int len ); +int MEMBUF_writeline( int ti , char *buf , int len ); + +//----------------------------------------------------------------------------- + +int TCPIP_bindSocket( char *addr , int p , int timeout_ms); +int TCPIP_connect( char *addr , int port ); +int TCPIP_close( int ti ); +int TCPIP_selectdata( void); +int TCPIP_accept( int *tis , int ticount ); +int TCPIP_send( int ti , char *buf , int len ); +int TCPIP_checkCon( int ti); + +#endif +#endif diff --git a/saac/util.c b/saac/util.c new file mode 100644 index 0000000..072f468 --- /dev/null +++ b/saac/util.c @@ -0,0 +1,396 @@ +#define _UTIL_C_ + +#include +#include +#include + +#include "main.h" +#include "util.h" + +#define IS_2BYTEWORD( _a_ ) ( (char)(0x80) <= (_a_) && (_a_) <= (char)(0xFF) ) +#define PRIME 211 +int hashpjw ( char* s ) +{ + char *p; + unsigned int h= 0 ,g; + for( p = s ; *p ; p ++ ){ + h = ( h<< 4 ) + (*p); + if( (g = h & 0xf0000000) != 0){ + h = h ^ (g>>24); + h = h ^ g; + } + } + return h % PRIME; +} + +int getHash ( char* s ) +{ + int i; + int h=0; + + for(i=0;; i++){ + if( s[i] == 0 ){ + break; + } + h += s[i]; + } + return h; +} + +void easyGetTokenFromString( char *src,int count,char*output,int len ) +{ + int i; + int counter = 0; + + if( len <= 0 )return; + +#define ISSPACETAB( c ) ( (c) == ' ' || (c) == '\t' ) + + for(i=0;;i++){ + if( src[i]=='\0'){ + output[0] = '\0'; + return; + } + if( i > 0 && ! ISSPACETAB( src[i-1] ) && + ! ISSPACETAB( src[i] ) ){ + continue; + } + + if( ! ISSPACETAB( src[i]) ){ + counter++; + if( counter == count){ + int j; + for(j=0;j= sizeofdest ) break; + if( IS_2BYTEWORD( src[i] ) ){ + if( destindex + 2 >= sizeofdest ) break; + dest[destindex] = src[i]; + dest[destindex+1] = src[i+1]; + destindex += 2; + i ++; + continue; + } + + for( j = 0; j= sizeofdest ) + /* '\0'坌互箫曰卅中及匹仇仇匹蔽曰 */ + break; + + /* // 蝈剩及ㄠ田奶玄 井升丹井毛民尼永弁 + if( IS_2BYTEWORD( src[i] ) ){ + // 蝈剩分[公及桦宁反ㄠ田奶玄芴坌卞褡引六月[ + // 凶分仄ㄠ田奶玄仄井卅中桦宁反公丹仄卅中 + // 公及引引ㄡ田奶玄鳖霜 + if( destindex + 2 >= sizeofdest )break; + + dest[destindex] = src[i]; + dest[destindex+1] = src[i+1]; + destindex += 2; + i ++; + continue; + } + */ + for( j = 0; j= destlen ){ + return -1; + } else { + strcat( dest, append ); + } + return 0; +} + +char *chop( char *s ) +{ + int l = strlen(s); + if( l >= 1 ){ + s[l-1]=0; + } + return s; +} + +// CoolFish: Family 2001/5/30 +void easyGetTokenFromBuf(char *src, char delim, int count, char *output, int len) +{ + int i; + int counter = 0; + int wordflag = 0; + + if( len <= 0 ) return; + + #define ISSEPARATE( c ) ((c) == delim) + + for( i=0; ; i++){ + if( src[i] == '\0' ){ + output[0] = '\0'; + return; + } + if(IS_2BYTEWORD(src[i])){ + if( i>0 && wordflag == 1 ){ + i++; + wordflag = 1; + continue; + } + if( i>0 && !ISSEPARATE(src[i-1]) && !ISSEPARATE(src[i])){ + i++; + wordflag = 1; + continue; + } + wordflag = 1; + }else{ + if( i>0 && wordflag ){ + wordflag = 0; + continue; + } + if( i>0 && !ISSEPARATE(src[i-1]) && !ISSEPARATE(src[i])){ + wordflag = 0; + continue; + } + wordflag = 0; + } + if( !ISSEPARATE(src[i]) ){ + counter++; + if( counter == count ){ + int j; + for ( j=0; j +#include +#include +#include +#include +#include +#include +#include "TCPIP.h" +#include "version.h" + +int getAddress(char *host, struct in_addr *iaddr) +{ + char *p = host; + int ishost = 0; + + if (strcmp(host,"*")==0) { + iaddr->s_addr=htonl(INADDR_ANY); + return 1; + } + while (*p) { + if (!(isdigit(*p) || ((*p) == '.'))) { + ishost = 1; + break; + } + p++; + } + if (ishost) { + struct hostent *h; + h = gethostbyname(host); + if (!h) { return 0; } + memcpy((void *) &iaddr->s_addr,(void *) h->h_addr,4); + return 1; + } else { + iaddr->s_addr = inet_addr(host); + return 1; + } +} + +int TCPbind(char *bindAddress,int bindPort) +{ + struct in_addr iaddr; + struct sockaddr_in saddr; + struct linger lg; + int sd; + int nodelay,reuse; + + if (!getAddress(bindAddress, &iaddr)) + errexit2("Host %s could not be resolved\n",bindAddress); + sd = socket(PF_INET, SOCK_STREAM, 0); + if (sd < 0) + errexit("Couldn't create server socket!\n"); + + saddr.sin_family = AF_INET; + memcpy(&saddr.sin_addr, &iaddr, sizeof(iaddr)); + saddr.sin_port = htons(bindPort); + + if (setsockopt(sd,IPPROTO_TCP,TCP_NODELAY,&nodelay,sizeof(nodelay))<0) + error("TCP_NODELAY failed\n"); + if (setsockopt(sd,SOL_SOCKET,SO_REUSEADDR,&reuse,sizeof(reuse))<0) + error("SO_REUSEADDR failed\n"); + lg.l_onoff=1; lg.l_linger=5; + if (setsockopt(sd,SOL_SOCKET,SO_LINGER,&lg,sizeof(lg))<0) + error("SO_LINGER failed\n"); + + if (bind(sd, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) + errexit3("Couldn't bind to address %s port %d\n", + bindAddress, bindPort); + if (listen(sd, 5) < 0) + errexit3("Couldn't listen to address %s port %d\n", + bindAddress, bindPort); + return(sd); +} + +int TCPaccept0(int sd,int block,unsigned long *ip) +{ + struct sockaddr_in saddr; + int ad,len,j; + + if (block==0) { + j=0; + setsockopt(sd, SOL_SOCKET, SO_LINGER, &j, sizeof(j)); + fcntl(sd, F_SETFL, O_NONBLOCK); + } + len=sizeof(saddr); + if ((ad = accept(sd, (struct sockaddr *)&saddr, (int *)&len)) < 0) { + error("Couldn't accept\n"); + return -1; + } else if (ip) memcpy(ip,&saddr.sin_addr, sizeof(unsigned long)); + return(ad); +} + +int TCPaccept(int sd) { return TCPaccept0(sd,1,0); } +int TCPacceptIP(int sd,unsigned long *ip) { return TCPaccept0(sd,1,ip); } +int TCPacceptNB(int sd) { return TCPaccept0(sd,0,0); } + +int TCPconnect0(char *bindAddress,int bindPort,int block) +{ + struct in_addr iaddr; + struct sockaddr_in saddr; + int sd,j; + int nodelay; + + if (!getAddress(bindAddress, &iaddr)) { + error2("Host %s could not be resolved\n",bindAddress); + return -1; + } + sd = socket(PF_INET, SOCK_STREAM, 0); + if (sd < 0) { + error("Couldn't create server socket!\n"); + return -1; + } + saddr.sin_family = AF_INET; + memcpy(&saddr.sin_addr, &iaddr, sizeof(iaddr)); + saddr.sin_port = htons(bindPort); + + if (setsockopt(sd,IPPROTO_TCP,TCP_NODELAY,&nodelay,sizeof(nodelay))<0) + error("TCP_NODELAY failed\n"); + + if (block==0) { + j=0; + setsockopt(sd, SOL_SOCKET, SO_LINGER, &j, sizeof(j)); + fcntl(sd, F_SETFL, O_NONBLOCK); + } + + if (connect(sd, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) { + error3("无法连接地址 %s 端口 %d\n", + bindAddress, bindPort); + return -1; + } + return(sd); +} + +int TCPconnect(char *bindAddress,int bindPort) +{ + TCPconnect0(bindAddress,bindPort,1); +} + +int TCPconnectNB(char *bindAddress,int bindPort) +{ + TCPconnect0(bindAddress,bindPort,0); +} + + + diff --git a/saac/wk/TCPIP.h b/saac/wk/TCPIP.h new file mode 100644 index 0000000..28f0743 --- /dev/null +++ b/saac/wk/TCPIP.h @@ -0,0 +1,8 @@ +int TCPbind(char *bindAddress,int bindPort); +int TCPaccept(int sd); +int TCPacceptIP(int sd,unsigned long *ip); +int TCPacceptNB(int sd); +int TCPconnect(char *bindAddress,int bindPort); +int TCPconnectNB(char *bindAddress,int bindPort); + + diff --git a/saac/wk/TCPIP.o b/saac/wk/TCPIP.o new file mode 100644 index 0000000..79277c5 Binary files /dev/null and b/saac/wk/TCPIP.o differ diff --git a/saac/wk/error.c b/saac/wk/error.c new file mode 100644 index 0000000..55ff628 --- /dev/null +++ b/saac/wk/error.c @@ -0,0 +1,70 @@ +#include +#include +#include "error.h" +#include "version.h" +//char *logfile=ERRLOG; + +#define SHOW_TIME + +char *chartime() +{ + static char buf[80]; + time_t t; + t=time(0); +// strcpy(buf,ctime(&t)); + buf[strlen(buf)-1]=' '; + return(buf); +} + +void errexit(char *message) +{ +#ifdef SHOW_TIME + fprintf(stderr,"%s",chartime()); +#endif + fprintf(stderr,"%s\n",message); + exit(1); +} + +void errexit2(char *message1, char *message2) +{ +#ifdef SHOW_TIME + fprintf(stderr,"%s",chartime()); +#endif + fprintf(stderr,message1,message2); + exit(1); +} + +void errexit3(char *message1, char *message2, int message3) +{ +#ifdef SHOW_TIME + fprintf(stderr,"%s",chartime()); +#endif + fprintf(stderr,message1,message2,message3); + exit(1); +} + +void error(char *message) +{ +#ifdef SHOW_TIME + fprintf(stderr,"%s",chartime()); +#endif + fprintf(stderr,"%s",message); +} + +void error2(char *message1, char *message2) +{ +#ifdef SHOW_TIME + fprintf(stderr,"%s",chartime()); +#endif + fprintf(stderr,message1,message2); +} + +void error3(char *message1, char *message2, int message3) +{ +#ifdef SHOW_TIME + fprintf(stderr,"%s",chartime()); +#endif + fprintf(stderr,message1,message2,message3); +} + + diff --git a/saac/wk/error.h b/saac/wk/error.h new file mode 100644 index 0000000..df0ee9f --- /dev/null +++ b/saac/wk/error.h @@ -0,0 +1,19 @@ +/* + error.h + + Handle error messages + + Created by Nuke +*/ + +void errexit(char *message); +void errexit2(char *message1,char *message2); +void errexit3(char *message1,char *message2, int message3); +void error(char *message); +void error2(char *message1,char *message2); +void error3(char *message1,char *message2, int message3); + +#define WGSLOG "wgs.log" + +#define P(A) { debug3("%s%d ","",A); } + diff --git a/saac/wk/error.o b/saac/wk/error.o new file mode 100644 index 0000000..2cf5535 Binary files /dev/null and b/saac/wk/error.o differ diff --git a/saac/wk/makefile b/saac/wk/makefile new file mode 100644 index 0000000..1623b89 --- /dev/null +++ b/saac/wk/makefile @@ -0,0 +1,14 @@ +CC=gcc + +all : acwk + + +acwk : wk.c TCPIP.o error.o tools.o + gcc -o /root/saserver/saac/acwk -O3 -g -w wk.c error.o TCPIP.o tools.o + +TCPIP: +error: +tools: + +clean : + rm -f acwk *.o *~ diff --git a/saac/wk/makefile.bak b/saac/wk/makefile.bak new file mode 100644 index 0000000..30c96fd --- /dev/null +++ b/saac/wk/makefile.bak @@ -0,0 +1,22 @@ +CC=gcc + +all : acwk + + +acwk : wk.c TCPIP.o error.o tools.o + gcc -o /root/saserver/saac/acwk -O3 -g -w wk.c error.o TCPIP.o tools.o + +TCPIP: +error: +tools: + +clean : + rm -f acwk *.o *~ + +depend: $(RPCSRC) $(ANIMDATAFILE) + @for dir in $(SUBDIR) ; do \ + $(MAKE) -C $$dir depend;\ + done + $(MV) makefile makefile.bak + $(SED) -ne '1,/^# DO NOT DELETE THIS LINE/p' makefile.bak>makefile + $(CC) $(INCFLAGS) -M $(SRC) >> makefile \ No newline at end of file diff --git a/saac/wk/tools.c b/saac/wk/tools.c new file mode 100644 index 0000000..acede60 --- /dev/null +++ b/saac/wk/tools.c @@ -0,0 +1,296 @@ +#include "error.h" +#include "tools.h" +#include "version.h" + +#define BUF_SIZE 4096 +//#define P(A) { printf("%d\n",A); } + +char Xtoken; // Original leading charactor of strxtok +char Ytoken; // Original tail charactor of strxtok + +int bakayaro(char *name) +{ + int i,sum; + if (!name) return 0; + for (i=0,sum=0;name[i];i++) sum+=name[i]*(i+1); +// error3("Aho:%s%d\n","",sum); + return sum; +} + +char *iptoa(unsigned long ip) +{ + static char buffer[80]; + unsigned char *p; + p=(unsigned char *)&ip; + sprintf(buffer,"%u.%u.%u.%u",p[0],p[1],p[2],p[3]); + return(buffer); +} + +char *strxcpy(char *src) +{ + static char dst[BUF_SIZE]; + int i; + + if (src) { + for (i=0;i<=strlen(src);i++) + dst[i]=(src[i]=='\n')?'\t':src[i]; + return(dst); + } else { + return(0); + } +} + +// +char *strxtok(char *src,int _limit) +{ + static char buf[BUF_SIZE]; + static char *ptr; + static int i,j,limit; + + if (src) { + limit=_limit '\' or '\;' => ';' or '\&' => '&' + if (buf[i+1]=='\\' || buf[i+1]==';' || buf[i+1]=='&') { + i++; buf[j++]=buf[i++]; + } + // '\' -> Ignore '\' + else { i++; } + } else if (buf[i]==';') { // Bug from AP + i++; buf[j++]=0; + Ytoken=';'; + return(ptr); + } else { + buf[j++]=buf[i++]; + } + } + buf[j]=0; + Ytoken=0; + return(ptr); +} + +// Add up \ for \, ; and & +char *xchange(char *src) +{ + static char buffer[BUF_SIZE]; + int i,j,limit; + + if (!src) return(0); + limit=strlen(src); + if (limit>=BUF_SIZE/2) limit=BUF_SIZE/2-1; + for (j=0,i=0;ihead=s->tail=0; + s->count=0; +} + +void stockAdd(Stock_Struct *s,char *data) +{ + Stock *new; + + if (!s) return; + if (!data) data=""; + // Make new stock + new=(Stock *)calloc(1,sizeof(Stock)); + new->data=strcpy((char *)calloc( 1,strlen(data)+1),data); + new->flag=0; + // Link new stock + if (!s->head) { // First Item, add to tail + s->head=s->tail=new; + } else { // Add to tail + s->tail->link=new; + s->tail=new; + } + s->count++; +} + +char *stockOut(Stock_Struct *s) +{ + static char buf[BUF_SIZE]; + Stock *t; + + if (!s || !s->head) return(0); + t=s->head; + s->head=t->link; + strcpy(buf,t->data); + free(t->data); + free(t); + s->count--; + if (!s->head) s->tail=0; + return(buf); +} + +void stockDel(Stock_Struct *s,int count) +{ + Stock *t; + + if (!s || !s->head) return; + + while ((t=s->head) && count) { + s->head=t->link; + free(t->data); + free(t); + count--; + s->count--; + } + if (!s->head) s->tail=0; +} + +int stockCount(Stock_Struct *s) +{ + return(s->count); +} + +void stockClear(Stock_Struct *s) +{ + Stock *t,*u; + if (!s) return; + u=s->head; + while (t=u) { + u=u->link; + free(t->data); + free(t); + } + s->head=0; s->tail=0; + s->count=0; +} + +void stockStore(Stock_Struct *s,char *buf,int limit) +{ + char *ptr; +// show(s); + if (!s || !buf) return; + ptr=strxtok(buf,limit); +// if (ptr && s->tail) P(s->tail->flag); + if (ptr && s->tail && + (s->tail->flag&STOCK_NONTERM)) { // Last message is non-terminated + strcat((char *)realloc(s->tail->data, + strlen(s->tail->data)+strlen(ptr)+1),ptr); + if (Ytoken==';') { s->tail->flag^=STOCK_NONTERM; s->count++; } + ptr=strxtok(0,0); + } + while (ptr) { + stockAdd(s,ptr); + if (Xtoken=='&') s->tail->flag|=STOCK_START; // The start + if (Ytoken!=';') { // Non-terminated + s->tail->flag|=STOCK_NONTERM; + s->count--; // This is not a valid item + } + ptr=strxtok(0,0); + } +} + +void rankAdd(Stock_Struct *ss,int rank,Rank_Struct *rs) +{ + int i; + + if (!ss) { error("rankAdd(): Null Stock?\n"); return; } + if (!rs) { error("rankAdd(): Null Storage?\n"); return; } + if (rank<=0) {error("rankAdd(): Invalid rank\n"); return; } + for (i=0;i<10;i++) { rs->entry[i].name[0]=0; rs->entry[i].score=0; } + rs->rank=rank; + for (i=0;(i<10)&&(ss->head);i++) { + strcpy(rs->entry[i].name,stockOut(ss)); + if (ss->head) rs->entry[i].score=atoi(stockOut(ss)); + else rs->entry[i].score=0; + } +} + +int rankSelect(int rank) +{ + return(((rank-1)/10)*10+1); +} + +int charXCount(char *buf) +{ + int i,count; + if (!buf) { error("charCount(): Null buffer?\n"); return(0); } + i=0; count=0; + while (buf[i]) { + if (buf[i]=='\\') { + if ((buf[i+1]=='\\') || (buf[i+1]=='&') || + (buf[i+1]==';')) { + i++; + } + } else if (buf[i]==';') count++; + i++; + } + return(count); +} + +// Construct the 8-byte formatted string +char *construct(char *src) +{ + static char dst[BUF_SIZE]; + const char *AND="&&&&&&&&"; + int n; + if (!src) { dst[0]=0; return(dst); } + else { + sprintf(dst,"&;%d;%s",charXCount(src)+1,src); + n=strlen(dst)%8; + if (!n) return(dst); + strcat(dst,AND+n); + } + return(dst); +} + +void show(Stock_Struct *s) +{ + Stock *trace; + if (!s) return; + for (trace=s->head;trace;trace=trace->link) + error3("<%s:%d>",trace->data,trace->flag); + error("\n"); +} + +/*main() +{ + Stock_Struct s; + char buf[100]; + char buf1[4096]; + int i; + + stockInit(&s); + while (1) { + gets(buf); +// for (i=0;buf[i];i++) printf("(%c)",buf[i]); +// stockStore(&s,buf,strlen(buf)); + printf("%s\n",construct(buf)); +// show(&s); + } +}*/ + + + + + + + + diff --git a/saac/wk/tools.h b/saac/wk/tools.h new file mode 100644 index 0000000..1205f4d --- /dev/null +++ b/saac/wk/tools.h @@ -0,0 +1,51 @@ +#define ID_SIZE 22 + +typedef struct STOCK { + struct STOCK *link; + char *data; + int flag; +} Stock; + +#define STOCK_START 1 +#define STOCK_NONTERM 2 + +typedef struct STOCK_STRUCT { + struct STOCK *head; // First item to be used + struct STOCK *tail; // Newest item + int count; +} Stock_Struct; + +typedef struct RANK_ENTRY { + char name[ID_SIZE]; + int score; +} Rank_Entry; + +typedef struct RANK_STRUCT { + struct RANK_ENTRY entry[10]; + int rank; +} Rank_Struct; + +int bakayaro(char *name); + +char *iptoa(unsigned long ip); +char *strxcpy(char *src); +char *xchange(char *src); + +void stockInit(Stock_Struct *s); +void stockAdd(Stock_Struct *s,char *data); +char *stockOut(Stock_Struct *s); +void stockDel(Stock_Struct *s,int count); +int stockCount(Stock_Struct *s); + +void rankAdd(Stock_Struct *ss,int rank,Rank_Struct *rs); +int rankSelect(int rank); + +int charXCount(char *buf); +char *construct(char *src); +void show(Stock_Struct *s); + +extern char Xtoken; +extern char Ytoken; +extern char welcome[]; + + diff --git a/saac/wk/tools.o b/saac/wk/tools.o new file mode 100644 index 0000000..684696b Binary files /dev/null and b/saac/wk/tools.o differ diff --git a/saac/wk/version.h b/saac/wk/version.h new file mode 100644 index 0000000..9f0a761 --- /dev/null +++ b/saac/wk/version.h @@ -0,0 +1,19 @@ +#ifndef __VERSION_H__ +#define __VERSION_H__ + +void Log( char *msg ); +//#define _DEBUG_WORK +#define _FIX_WORKS //wk修改 + + +// ------------------------------------------------------------------- +// 专案:(新付费机制) +#define _AP_CHECK_3_TIMES // (可开) WON ADD 减少认证次数 (北京&韩国不必开) +#define _FIX_MESSAGE // (可开) WON ADD 修改封包内容 (北京&韩国不必开) +//#define _ADD_AC_IP // (测试中) WON ADD 加AC_IP至通讯协定中 (北京&韩国不必开) + +//#define _TIMEOUTKICK // Robin 时段制 + +#endif + + diff --git a/saac/wk/wk.c b/saac/wk/wk.c new file mode 100644 index 0000000..e5062af --- /dev/null +++ b/saac/wk/wk.c @@ -0,0 +1,873 @@ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "TCPIP.h" +#include "tools.h" +#include "version.h" + +static int WORK_TYPE = 0; +#ifdef _FIX_WORKS +#define ACADDRESS "127.0.0.1" +#define ACPORT 9400 +static int afd; +int LoginToAC(); +int Ac_message_accept( char *buf, int slen); + +#endif + +#define PROD_ID "8904001" +unsigned long myIP; + +int mainsockfd; +int port = -1; +int debug = 0; +int timeout = 7200; +char logdir[1024]; + +int csd=-1; +char WGSAddress[1024]; +int WGSPort = -1; +#define BUF_SIZE 4096 +int zap=0; +int additional_process=0; + +#ifdef _ADD_AC_IP // WON ADD 加AC_IP至通讯协定中 +char AC_IP[20]; +#endif + + +void sigpipe(int i) +{ + csd=0; + signal(SIGPIPE,sigpipe); +} + +void sigusr1(int i) +{ + if (csd>0) close(csd); + csd=TCPconnect(WGSAddress,WGSPort); + signal(SIGUSR1,sigusr1); +} + +void sigusr2(int i) +{ + zap=1-zap; + additional_process=time(0)/256; + signal(SIGUSR2,sigusr2); +} + +void sigterm(int i) +{ + signal(SIGTERM,sigterm); +} + +void writeLog( char *msg ); + +char *dummy[7][2]={ + {"SYSOP","GoodNight" }, + {"SYSOP1","Good1" }, + {"SYSOP2","Good2" }, + {"SYSOP3","cary" }, + {"SYSOP4","Good4" }, + {"SYSOP5","Good5" }, + {"SYSOP6","Good6" }}; + +static int checkCSconnect( void) +{ + int num = 0; + while( csd <= 0 && num < 10 ){ + csd = TCPconnect(WGSAddress,WGSPort); + if( csd <= 0 ) sleep( 6); + num++; + } + if( csd <= 0 ){ + char buf[256]; + sprintf( buf, "无法连接到 %s:%d !\n", WGSAddress, WGSPort); + Log( buf); + return -1; + } + return 1; +} + +#ifdef _TIMEOUTKICK +static int doKN( char *id , char *pas , char *flag , char *process , char *deadline) +#else +static int doKN( char *id , char *pas , char *flag , char *process) +#endif +{ + char buffer[BUF_SIZE],idbuf[BUF_SIZE],pasbuf[BUF_SIZE],m[BUF_SIZE]; + char *ptr; + int ret, x, baka; + struct timeval tv; + fd_set rfds; + int iProcess; + + int length; + + if (zap) return(0); + + again: + + if (csd<=0) csd=TCPconnect(WGSAddress,WGSPort); + + if (csd<=0) {sleep(1); return(-1); } + else { + + tv.tv_sec=0; + tv.tv_usec=1000; + FD_ZERO(&rfds); + FD_SET(csd,&rfds); + x=select(1024,&rfds,0,0,&tv); + + if (x<0){ return(-100);} + + if (x>0) { + ret=read(csd,buffer,BUF_SIZE-8); + + if (ret<=0) { close(csd); sleep(1); csd=0; goto again; } + } + + strcpy(idbuf,xchange(id)); + strcpy(pasbuf,xchange(pas)); + iProcess = atoi( process ); + + switch (*flag) { + case '1': // Login + +#ifdef _FIX_MESSAGE // WON ADD 修改封包内容 + +#ifdef _ADD_AC_IP // WON ADD 加AC_IP至通讯协定中 + sprintf(buffer,"&;5;6;%s;%s;0;%s;",idbuf,pasbuf, AC_IP); +#else + sprintf(buffer,"&;5;6;%s;%s;0;",idbuf,pasbuf); +#endif + +#else + sprintf(buffer,"&;9999;5;J;%s;%s;",idbuf,pasbuf); +#endif + Log( buffer); + baka=90000+bakayaro(id); + break; + case '4': // Delete + +#ifdef _FIX_MESSAGE // WON ADD 修改封包内容 + +#ifdef _ADD_AC_IP // WON ADD 加AC_IP至通讯协定中 + sprintf(buffer,"删除人物:%s %s %s\n",idbuf,pasbuf, AC_IP); +#else + sprintf(buffer,"删除人物:%s %s\n",idbuf,pasbuf); +#endif + +#else + sprintf(buffer,"&;9999;5;J;%s;%s;",idbuf,pasbuf); +#endif + Log( buffer); + baka=90000+bakayaro(id); + break; + case '2': // Game Start +#ifdef _TIMEOUTKICK + case '5': // recheck WGS deadline +#endif + +#ifdef _FIX_MESSAGE // WON ADD 修改封包内容 + +#ifdef _ADD_AC_IP // WON ADD 加AC_IP至通讯协定中 + sprintf(buffer,"进入游戏:%s %s %s\n",idbuf,pasbuf, AC_IP); +#else + sprintf(buffer,"进入游戏:%s %s\n",idbuf,pasbuf); +#endif + +#else + sprintf(buffer,"&;9999;6;6;%s;%s;%d;",idbuf,pasbuf,iProcess+additional_process); +#endif + Log( buffer); + baka=10000+bakayaro(id); + break; + case '3': // Game End + +#ifdef _FIX_MESSAGE // WON ADD 修改封包内容 + +#ifdef _ADD_AC_IP // WON ADD 加AC_IP至通讯协定中 + sprintf(buffer,"退出游戏:%s %s\n",idbuf, AC_IP); +#else + sprintf(buffer,"退出游戏:%s\n",idbuf); +#endif + +#else + sprintf(buffer,"&;9999;5;7;%s;%d;",idbuf,iProcess+additional_process); +#endif + Log( buffer); + baka=20000+bakayaro(id); + break; + default: + return(-100); + } + //Log(""); + //Log(buffer); + ret=write(afd,buffer,strlen(buffer)); + //Log(""); + + // Write error + if (ret<0) { close(csd); sleep(1); csd=0; goto again; } + + // Line busy + if (ret==0) { sleep(1); return(-103); } + + tv.tv_sec=0; + tv.tv_usec=0; + FD_ZERO(&rfds); + FD_SET(csd,&rfds); + //Log (""); + x=select(1024,&rfds,0,0,&tv); + //Log (""); + if (x<0) return(-101); + if (x==0) return(0); + //Log ("
    "); + ret=read(csd,buffer,BUF_SIZE-8); + //Log (""); + snprintf( m, sizeof(m), "ret: %d ", ret ); + Log( m ); + // Read error + if (ret<=0) { close(csd); sleep(1); csd=0; return(-104); } + buffer[ret]=0; + + snprintf( m,sizeof(m) ," WGS: %s\n",buffer); + Log( m ); + + strtok(buffer,";"); // Get & + length = atoi( strtok(0,";")); // Get length + ptr=strtok(0,";"); // Get Flag + + if (ptr==0) return(-105); + + if (ptr[0]=='K') { + + int payType; + +#ifndef _FIX_MESSAGE // WON ADD 修改封包内容 + if (atoi(ptr+1)!=baka){ + char buff1[256]; + sprintf( buff1, "%d != %d\n", atoi(ptr+1), baka); + Log(buff1); + return(-100); + } +#endif + +#ifdef _TIMEOUTKICK + + payType = atoi( strtok(0,";")); + + if( *flag == '1' || *flag == '4' ) { // GameLogin or Char Delete + strtok(0,";"); // get Point + } + + if( strcmp( strtok(0,";"), idbuf)) { // get PlayerAccount + //Log(" 回传帐号不符! "); + //return(-106); + } + + switch( payType) { + case 1: // 包月制 + strcpy( deadline ,"0"); + Log(" 包月 "); + break; + case 2: // 时段制 + //strtok(0,";"); // get PlayerAccount + strcpy( deadline ,strtok(0,";")); + Log(" 时段 "); + break; + case 0: + strcpy( deadline ,"0"); + Log(" 结束 "); + break; + } + +#endif + + switch (*flag) { + case '1': // List + Log("用户登陆\n"); + break; + case '4': // Delete + Log("删除人物\n"); + break; + case '2': + Log("进入游戏\n"); + break; + case '3': + Log("退出游戏\n"); + break; +#ifdef _TIMEOUTKICK + case '5': + Log("Deadline recheck\n"); + break; +#endif + default: + Log("Strange but passed\n"); + break; + } + return(0); // Authencation passed + } + +#ifdef _FIX_MESSAGE // WON ADD 修改封包内容 + // 回传错误码 + else if (ptr[0]=='E'){ + char err_code[10]; + int i, err_num=0, login_star=-1; +#ifdef _TIMEOUTKICK + if( length != 3 ) + strtok(0,";"); // Get 1 + if( *flag != '1' && *flag != '4') { + if( strcmp( strtok(0,";"), idbuf)) { // get PlayerAccount + //Log(" 回传帐号不符! "); + //return(-106); + } + } + strcpy( deadline ,"0"); +#endif + ptr=strtok(0,";"); + + for(i=0; i<9; i++){ + if (ptr[i] == ' ' ) break; + err_code[i]=ptr[i]; + } + + err_num=atoi(err_code); + + if( err_num == 203 ){ // 203 不同星系 + login_star=atoi(ptr+i); + Log("203"); + // 回传已登入的星系代码 + if(login_star != -1) + return(login_star+2030); + } + else if( err_num == 204 ){ // 204 同星系 + Log("204"); + if( *flag == '5') + Log(" 时段未到 "); + return(204); + }else{ + char msg[256]; + sprintf( msg, "won test 1 ==> err_num(%d)", err_num); + Log( msg ); + return(err_num); + } + + + } +#endif + + return(-106); + } +} +#ifndef _FIX_WORKS +static int createMainSocket( int port ) +{ + int s,r; + struct sockaddr_in sin; + + s = socket( AF_INET , SOCK_STREAM , 0 ); + if( s < 0 ){ + fprintf( stderr, "socket error" ); + return s; + } + + sin.sin_family = AF_INET; + sin.sin_port = htons( port ); + sin.sin_addr.s_addr = htonl(INADDR_ANY); + + if( (r = bind( s , (struct sockaddr*) &sin , sizeof( sin )) ) <0 ){ + fprintf(stderr, "绑定失败" ); + return r; + } + listen( s , 5 ); + + return s; + +} +#endif +static void remove_r( char *s ) +{ + int i; + for(i=0;;i++){ + if(s[i]=='\r')s[i] =0; + if( s[i]==0)break; + } +} + +static void easyGetTokenFromString( char *src,int count,char*output,int len ) +{ + int i; + int counter = 0; + + if( len <= 0 )return; + +#define ISSPACETAB( c ) ( (c) == ' ' || (c) == '\t' ) + + for(i=0;;i++){ + if( src[i]=='\0'){ + output[0] = '\0'; + return; + } + if( i > 0 && ! ISSPACETAB( src[i-1] ) && + ! ISSPACETAB( src[i] ) ){ + continue; + } + + if( ! ISSPACETAB( src[i]) ){ + counter++; + if( counter == count){ + /* copy it */ + int j; + for(j=0;j 0 ) close( afd); + if( csd > 0 ) close( csd); +#else + fclose( fp ); +#endif + //if( AcLogFile != NULL) + // fclose( AcLogFile); + Log( "SAAC已关闭. 异常终止.\n" ); +} + +static void parseOpt( int argc , char **argv ) +{ + int c; + int option_index; + +#ifdef _ADD_AC_IP // WON ADD 修改封包内容 + memset( AC_IP, -1 , sizeof( AC_IP) ); +#endif + + if( argc == 1 ){ + strcpy( WGSAddress, "127.0.0.1" ); + WGSPort = 9200; + } + + while(1){ + static struct option long_options[] = + { + {"port" , 1, 0 ,'p'}, + {"debug" , 1, 0 , 'd'}, + {"help" , 0 , 0 , 'h'}, + {"logdir", 1, 0, 'l' }, + {"csaddr", 1, 0, 'a' }, + {"csport", 1, 0, 'c' }, +#ifdef _ADD_AC_IP // WON ADD 修改封包内容 + {"acaddr", 1, 0, 'w' }, +#endif + {0,0,0,0} + }; + +#ifdef _FIX_MESSAGE // WON ADD 修改封包内容 + c = getopt_long ( argc, argv, "p:dhl:a:c:w:", long_options, &option_index ); +#else + c = getopt_long ( argc, argv, "p:dhl:a:c:", long_options, &option_index ); +#endif + + if( c == -1 )break; + + switch(c ){ + case 'l': + if( optarg){ + snprintf( logdir, sizeof( logdir), "%s", optarg ); + } else{ + fprintf( stderr , "-l 后面需要日录名.\n" ); + } + break; + case 'p' : + port = atoi( optarg ); + break; + case 'd': + debug = 1; + break; + case 'h': + fprintf( stderr, + "使用方法: acwk [-d|--调试模试] [-p 端口|--端口 端口] [-h|--帮助] [-l 日志日录]\n" + " [-a CS地址] [-c CS端口]\n" + "默认调试模试为0.\n" + "\nCopyright 2003 龙zoro工作室 / Longzoro system supply\n" + ); + exit(0); + break; + // Spock 2000/12/5 + case 'a': + strcpy( WGSAddress, optarg ); + break; + case 'c': + WGSPort = atoi( optarg ); + break; + // Spock end +#ifdef _ADD_AC_IP // WON ADD 加AC_IP至通讯协定中 + case 'w': + strcpy( AC_IP, optarg ); + Log( AC_IP ); + break; +#endif + } + } +} + +int main( int argc , char ** argv ) +{ + + // Spock +1 2000/12/5 + WGSAddress[0] = 0; + parseOpt(argc,argv); +#ifndef _FIX_WORKS + if( port < 0 ){ + //fprintf( stderr , "You have to specify port number by -p option.\n"); + //exit(1); + WGSPort=9200; + } +#endif + // Spock 2000/12/5 + if( strlen(WGSAddress) < 8 || strlen(WGSAddress) > 16 ){ + fprintf( stderr , "你指定CS的IP地址不正确.\n"); + exit(1); + } + if( WGSPort < 0 ){ + fprintf( stderr , "你指定CS的端口不正确.\n"); + exit(1); + } +#ifndef _FIX_WORKS + fprintf( stderr , "\n端口:[%d] 调试模式:[%d] CS地址:[%s] CS端口:[%d]\n" , + port , debug , WGSAddress , WGSPort ); + // Spock end + if( (mainsockfd = createMainSocket( port ))<0){ + fprintf( stderr , "cannot create mainsocket: %s\n", + strerror( errno )); + return 1; + } +#else + fprintf( stderr , "\n调试模式:[%d] CS地址:[%s] CS端口:[%d]\n" , + debug , WGSAddress , WGSPort ); +#endif +// Nuke +1 + additional_process=time(0)/256; + signal(SIGPIPE,sigpipe); + signal(SIGUSR1,sigusr1); + signal(SIGUSR2,sigusr2); + signal(SIGTERM,sigterm); + + workerMainLoop(); + return 0; +} +/* +static char * chop( char *src ) +{ + int i; + + for(i=0;;i++){ + if( src[i] == '\n' ) src[i]= 0; + if( src[i] == 0 )break; + } + return src; +} +*/ +void writeLog( char *msg ) +{ + char logbuf[BUF_SIZE]; + time_t t; + if( sizeof( msg) > sizeof( logbuf)) + return; + sprintf( logbuf, "%s", msg); + Log( logbuf); + t = time(NULL); +} + +void Log( char *msg ) +{ +#ifdef _DEBUG_WORK + FILE *AcLogFile=NULL; + if( AcLogFile == NULL ) { + char filename[1000]; + snprintf( filename, sizeof( filename), "%s/%d.worker" , logdir, port ); + AcLogFile = fopen( filename, "a+" ); + if(AcLogFile == NULL)return; + } + + fprintf( AcLogFile, "%s" , msg ); + fclose( AcLogFile); +#else + fprintf( stderr,"%s", msg); +#endif +} + +#ifdef _FIX_WORKS +int LoginToAC() +{ + Log( "\n连接 SAAC "); + usleep( 80*10000); + Log( "."); + afd = TCPconnect( WGSAddress, ACPORT); + if( afd <= 0 ) { + close( afd); + return 0; + } + Log( ".成功\n"); + usleep( 40*10000); + return 1; +} +char tmpbuf[4096]; +int readsize; +struct timeval select_timeout; + +int Ac_message_accept( char *buf, int slen) +{ + //int i; + int sret; + //int accepted = 0; + struct timeval t; + fd_set rfds, /*wfds,*/ efds; + + readsize = sizeof( tmpbuf); + + FD_ZERO( & rfds ); + //FD_ZERO( & wfds ); + FD_ZERO( & efds ); + + FD_SET( afd, & rfds ); + //FD_SET( afd, & wfds ); + FD_SET( afd, & efds ); + + select_timeout.tv_sec = 0; + select_timeout.tv_usec = 0; + t = select_timeout; + sret = select( 1024 , & rfds , (fd_set*)NULL, & efds , &t); + if( ( afd >= 0 ) && FD_ISSET( afd , &rfds ) ){ + int rr; + rr = read( afd , tmpbuf , readsize ); + if( rr > 0 ) { + memcpy( buf, tmpbuf, slen); + }else { + Log("..WORK ERROR\n"); + return -1; + } + }else { + return 0; + } + return 1; +} + +#endif + + diff --git a/saac2.27_code.rar b/saac2.27_code.rar new file mode 100644 index 0000000..34482c5 Binary files /dev/null and b/saac2.27_code.rar differ