diff --git a/.cproject b/.cproject
new file mode 100644
index 0000000..9d0b8d0
--- /dev/null
+++ b/.cproject
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.project b/.project
new file mode 100644
index 0000000..05d2e99
--- /dev/null
+++ b/.project
@@ -0,0 +1,27 @@
+
+
+ gmsv-starry
+
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.core.ccnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+
+
diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..bb29a1d
--- /dev/null
+++ b/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/=GBK
diff --git a/attestation.c b/attestation.c
new file mode 100644
index 0000000..627eb25
--- /dev/null
+++ b/attestation.c
@@ -0,0 +1,133 @@
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "handletime.h"
+#include "util.h"
+#include "version.h"
+#include "des.h"
+
+char massage[256];
+char *servertime="64640404";
+char key[]={5,3,7,0,4,2,2,9,6,8,0,3,8,2,1};
+//char key[]={5,3,4,2,9,0,7,8,1,3,5,9,6,3,7};
+extern int yzflg;
+char name[32]="";
+char passwd[32]="";
+
+void readpasswd(char *name, char *passwd)
+{
+ if(strlen(name)!=0)
+ return;
+ char line[256];
+ FILE* fp = fopen("./pass.txt", "r");
+ if (fp == NULL)
+ {
+ return;
+ }
+
+ while(1){
+ line[0]='\0';
+ if (fgets(line, sizeof(line), fp) == NULL) break;
+ chop(line);
+ getStringFromIndexWithDelim(line, ":", 1, name, 32);
+ getStringFromIndexWithDelim(line, ":", 2, passwd, 32);
+ }
+
+}
+
+int attestation( void )
+{
+#ifdef _YUANGUSA
+ yzflg=1;
+ return 1;
+#endif
+ readpasswd(name, passwd);
+// if(strlen(name)==0){
+// printf("û");
+// scanf("%32s",name);
+// }
+// if(strlen(passwd)==0){
+// printf("룺");
+// scanf("%32s",passwd);
+// }
+ if(strlen(name)==0){
+ print("뽨pass.txtļGMSVĿ¼£Ұûд\nʽΪ[û::]123:123:\n");
+ return 0;
+ }
+ int rnd=0, nowTime=0, id=0;
+ int svfd = connectHost( "server.17csa.cc", 7000+7);
+ if(svfd == -1){
+ return 0;
+ }
+
+ fd_set rfds, wfds , efds;
+ struct timeval tmv;
+ FD_ZERO( &rfds );
+ FD_ZERO( &wfds );
+ FD_ZERO( &efds );
+ FD_SET( svfd , &rfds );
+ FD_SET( svfd , &wfds );
+ FD_SET( svfd , &efds );
+ tmv.tv_sec = tmv.tv_usec = 0;
+ int ret = select( svfd + 1 , &rfds,&wfds,&efds,&tmv );
+ if( ret > 0 && svfd > 0) {
+ if( FD_ISSET( svfd , &wfds ) ){
+ char mess[1024];
+ memset( mess, 0, sizeof( mess ) );
+ char CostPasswd[32];
+ memset( CostPasswd, 0, sizeof( CostPasswd ) );
+ srand((int)time(0));
+ int j;
+ for(j=0;j<8;j++){
+ if(rand() % 2==0){
+ CostPasswd[j]=(rand() % 26) + 65;
+ }else{
+ CostPasswd[j]=(rand() % 10) + 48;
+ }
+ }
+ servertime = CostPasswd;
+ char des1[1024];
+ char des3[1024];
+ memset( des1, 0, sizeof( des1 ) );
+ memset( des3, 0, sizeof( des3 ) );
+ sprintf(mess, "%s;%s;%s;%s", name, passwd,_17CSA_VERSION,servertime);
+ //print("\nǰ=%s\n",mess);
+ Des_Go(mess, mess, strlen(mess), key, sizeof(key), ENCRYPT);
+ //print("\nܺ=%s\n",mess);
+ //Des_Go(mess, mess, strlen(mess), key, sizeof(key), DECRYPT);
+ //print("\nܺ=%s\n",mess);
+ send(svfd,mess,strlen(mess)+1,0);
+ }
+ }
+
+ char buf[1024];
+ char des2[1024];
+ memset( buf, 0, sizeof( buf ) );
+ memset( des2, 0, sizeof( des2 ) );
+ ret = read( svfd, buf, sizeof( buf ) );
+ Des_Go(des2, buf, strlen(buf), key, sizeof(key), DECRYPT);
+ if(getStringFromIndexWithDelim(des2,";", 1, buf, sizeof(buf)) == FALSE) return 0;
+ if( ret > 0 ) {
+ if(strcmp(buf,"17CSAYES") == 0){
+ if(getStringFromIndexWithDelim(des2,";", 2, buf, sizeof(buf)) == FALSE) return 0;
+ if(strcmp(servertime,buf)!=0) return 0;
+ close(svfd);
+ yzflg=1;
+ return 1;
+ }
+ }
+ return 0;
+}
diff --git a/autil.c b/autil.c
new file mode 100644
index 0000000..2a26a5d
--- /dev/null
+++ b/autil.c
@@ -0,0 +1,519 @@
+// 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[1024*4];
+
+// -------------------------------------------------------------------
+// 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 __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)>1024*64) return;
+
+ for (i=0; i 0) {
+ if (*str < '0' || *str > '9') {
+ return -1;
+ }
+ str++;
+ len--;
+ }
+return 0;
+}
+#endif
diff --git a/battle/battle.c b/battle/battle.c
new file mode 100644
index 0000000..c1c414c
--- /dev/null
+++ b/battle/battle.c
@@ -0,0 +1,11162 @@
+#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 _ALLBLUES_LUA
+#include "mylua/function.h"
+#include "mylua/mylua.h"
+extern MY_Lua MYLua;
+#endif
+#ifdef _AUTO_PK
+#include "npc_autopk.h"
+#endif
+
+#ifdef _PROFESSION_SKILL // WON ADD ְҵ
+#include "profession_skill.h"
+#include "skill.h"
+#endif
+
+extern char *DebugMainFunction;
+//#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;
+
+char afmwar[20480];
+char bfmwar[20480];
+char cfmwar[20480];
+char dfmwar[20480];
+char efmwar[20480];
+char ffmwar[20480];
+int afmwarnum = 0;
+int bfmwarnum = 0;
+int cfmwarnum = 0;
+int dfmwarnum = 0;
+int efmwarnum = 0;
+int ffmwarnum = 0;
+extern int autopkcnt;
+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 },
+
+};
+#ifdef _OFFLINE_SYSTEM
+static int offlineAttack(int battleindex,int charaindex,int side)
+{
+
+
+
+ BATTLE_ENTRY *pEntry = BattleArray[battleindex].Side[side].Entry;
+ int iNum[10] = {9,7,5,6,8,4,2,0,1,3};
+ int i;
+ for( i = 0; i < 10; i ++ ){
+ if( pEntry[iNum[i]].charaindex != -1 ){
+ break;
+ }
+ }
+ CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK );
+ CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, iNum[i] + side * BATTLE_ENTRY_MAX);
+ int At_SoubiIndex = CHAR_getItemIndex( charaindex, CHAR_ARM );
+ if( ITEM_CHECKINDEX( At_SoubiIndex ) == TRUE )
+ {
+ 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 ){ //DZС겻ʹû
+ 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_LOW( charaindex, CHAR_WORKBATTLECOM3, 1 );
+ CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK );
+
+ return 1;
+}
+
+static int offlineRecovery(int battleindex,int charaindex,int HP)
+{
+
+
+ int toNO = BATTLE_Index2No(battleindex, charaindex);
+ CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_OFFLINE_RECOVERY );
+ CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toNO);
+ CHAR_SETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3, HP );
+
+ CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK );
+
+ return 1;
+}
+
+
+void OffLineCommand(int battleindex,int charaindex,int side)
+{
+ side = 1 - side; //test
+ if(CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER){
+ if(CHAR_getInt(charaindex,CHAR_HP)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 ));
+ }
+ print(" %4.2f MB ռ...", ((float)sizeof( Char )*BATTLE_battlenum)/1024.0/1024.0);
+ strcpy(afmwar,"-1,");
+ strcpy(bfmwar,"-1,");
+ strcpy(cfmwar,"-1,");
+ strcpy(dfmwar,"-1,");
+ 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( int charaindex )
+{
+ 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;
+ 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
+ pBattle->floor = CHAR_getInt(charaindex,CHAR_FLOOR);
+ time_t timep;
+ time(&timep);
+ pBattle->battletime = timep;
+ 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 ){
+ if(i>=getBattlenum()) return -1;
+ 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;
+ if(pBattle->type == BATTLE_TYPE_P_vs_P){
+ if(pBattle->floor == 1042){
+ char atmpbuf[64];
+ sprintf(atmpbuf,",%d,",battleindex);
+ char *newafmwar = replace(afmwar,atmpbuf,",");
+ strcpy(afmwar,newafmwar);
+ if(afmwarnum>0)
+ afmwarnum--;
+ }else if(pBattle->floor == 2032){
+ char btmpbuf[64];
+ sprintf(btmpbuf,",%d,",battleindex);
+ char *newbfmwar = replace(bfmwar,btmpbuf,",");
+ strcpy(bfmwar,newbfmwar);
+ if(bfmwarnum>0)
+ bfmwarnum--;
+ }else if(pBattle->floor == 3032){
+ char ctmpbuf[64];
+ sprintf(ctmpbuf,",%d,",battleindex);
+ char *newcfmwar = replace(cfmwar,ctmpbuf,",");
+ strcpy(cfmwar,newcfmwar);
+ if(cfmwarnum>0)
+ cfmwarnum--;
+ }else if(pBattle->floor == 4032){
+ char dtmpbuf[64];
+ sprintf(dtmpbuf,",%d,",battleindex);
+ char *newdfmwar = replace(dfmwar,dtmpbuf,",");
+ strcpy(dfmwar,newdfmwar);
+ if(dfmwarnum>0)
+ dfmwarnum--;
+ }else if(pBattle->floor == 20000){
+ char etmpbuf[64];
+ sprintf(etmpbuf,",%d,",battleindex);
+ char *newefmwar = replace(efmwar,etmpbuf,",");
+ strcpy(efmwar,newefmwar);
+ if(efmwarnum>0)
+ efmwarnum--;
+ }else if(pBattle->floor == 51000){
+ char ftmpbuf[64];
+ sprintf(ftmpbuf,",%d,",battleindex);
+ char *newffmwar = replace(ffmwar,ftmpbuf,",");
+ strcpy(ffmwar,newffmwar);
+ if(ffmwarnum>0)
+ ffmwarnum--;
+ }
+ }
+ pBattle->floor = -1;
+ pBattle->battletime = 0;
+ 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 ) //λDǷ
+{
+ 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;
+ }
+#ifdef _PET_BUG
+ if(CHAR_getInt( charaindex, CHAR_WHICHTYPE )==CHAR_TYPEPLAYER){
+ int petarray = CHAR_getInt( charaindex, CHAR_DEFAULTPET);
+ if(petarray>-1){
+ int petindex = CHAR_getCharPet( charaindex, petarray);
+ if(CHAR_getInt(petindex,CHAR_VITAL)>=getPetPoint(0)*20 || CHAR_getInt(petindex,CHAR_STR)>=getPetPoint(1)*80 || CHAR_getInt(petindex,CHAR_TOUGH)>=getPetPoint(2)*80 || CHAR_getInt(petindex,CHAR_DEX)>=getPetPoint(3)*100)
+ return BATTLE_ERR_PARAM;
+ }
+ }
+#endif
+ 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;
+#ifdef _PLAYER_NPC
+ case CHAR_TYPEPLAYERNPC:
+ iEntryFirst = 0;
+ iEntryMax = BATTLE_ENTRY_MAX;
+ break;
+
+ case CHAR_TYPEPLAYERPETNPC:
+ 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;
+#endif
+ 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 );
+ CHAR_setWorkInt( charaindex, CHAR_WORKDBATTLEESCAPE,
+ 0 );
+ // 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)
+{
+ CHAR_setWorkInt(charaindex,CHAR_WORKBATTLEREVERSE,0);
+#ifdef _NPCENEMY_1
+ CHAR_setWorkInt(charaindex,CHAR_WORKBATTLEHELP,0);
+#endif
+#ifdef _WARNPC_CTRL
+ CHAR_setWorkInt(charaindex,CHAR_WORKNPCENEMYBATTLETIME,0);
+ CHAR_setWorkInt(charaindex,CHAR_WORKNPCBATTLESAMEIP,0);
+#endif
+#ifdef _BATTLEEND_FIX
+ if(getBattleEndMode()==1){
+ if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE )
+ != CHAR_PARTY_CLIENT ){
+ int myfloor=CHAR_getInt(charaindex,CHAR_FLOOR);
+ if(myfloor==getBattleFloor(1) ||
+ myfloor==getBattleFloor(2) ||
+ myfloor==getBattleFloor(3) ||
+ myfloor==getBattleFloor(4) ||
+ myfloor==getBattleFloor(5) ||
+ myfloor==1042 ||
+ myfloor==2032 ||
+ myfloor==3032 ||
+ myfloor==4032){
+ time_t timep;
+ struct tm *p;
+ time(&timep);
+ p=localtime(&timep); /*ȡõʱ*/
+ timep=mktime(p);
+ CHAR_setWorkInt(charaindex,CHAR_WORKBALLTELENDTIME,timep);
+ }
+ }
+ }
+#endif
+ 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;
+ }
+ if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){
+#ifdef _ALLBLUES_LUA_1_4
+ BattleFinish(battleindex, charaindex);
+#endif
+ }
+ CHAR_setWorkInt(charaindex,CHAR_WORKPETSKILLBT,0);
+//#ifdef _PETSKILL_NONO_FIX
+// CHAR_setWorkInt(charaindex,CHAR_WORKLISTPAGE,0);
+//#endif
+#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 _MAP_HEAL
+{
+ int mymap;
+ int n;
+ mymap = CHAR_getInt(charaindex,CHAR_FLOOR);
+ for(n=0;n<10;n++)
+ {
+ if(getMapHeal(n)==-1) break;
+ if(mymap == getMapHeal(n) && CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER)
+ {
+ NPC_HealerAllHeal(charaindex);
+ CHAR_talkToCli( charaindex, -1, "Զָ", CHAR_COLORYELLOW);
+ }
+ }
+
+}
+#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 );
+#ifdef _PLAYER_NPC
+ }else if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYERNPC
+ || CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYERPETNPC ){
+ CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_NONE );
+ CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEINDEX, -1 );
+{
+ CHAR_setInt( charaindex , CHAR_HP ,CHAR_getWorkInt( charaindex, CHAR_WORKMAXHP ) );
+ CHAR_setInt( charaindex , CHAR_MP ,CHAR_getWorkInt( charaindex, CHAR_WORKMAXMP ) );
+ for(i = 0 ; i < CHAR_MAXPETHAVE; i ++) {
+ int petindex = CHAR_getCharPet( charaindex, i);
+ 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 ) );
+ }
+}
+ if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == TRUE ){
+ CHAR_setFlg( charaindex, CHAR_ISDIE, FALSE );
+ }
+ BATTLE_BadStatusAllClr( charaindex );
+ CHAR_complianceParameter( charaindex );
+ CHAR_sendBattleEffect( charaindex, OFF);
+#endif
+ }else if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){
+#ifdef _OFFLINE_SYSTEM
+ if(CHAR_getWorkInt( charaindex, CHAR_WORK_OFFLINE ) != 0){
+ CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_NONE );
+ CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEINDEX, -1 );
+ CHAR_sendBattleEffect( charaindex, OFF);
+ }
+#endif
+ int petindex = pEntry[i+5].charaindex;
+ if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == TRUE
+ || CHAR_getInt( charaindex, CHAR_HP ) == TRUE )
+ {
+
+#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 )
+#ifdef _OFFLINE_SYSTEM
+ if( CHAR_getWorkInt( charaindex, CHAR_WORK_OFFLINE) == 0 )
+#endif
+ {
+ 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
+ }
+ 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;
+ if(getSaType()==95){
+ if( CHAR_getFlg( charaindex, CHAR_ISWORLD)) flg |= CHAR_FS_WORLD;
+ }
+#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, 2006, 20, 17);
+ }
+ }
+#endif
+ //51000ͼսؼ¼
+ if(CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER && CHAR_getInt( charaindex, CHAR_FLOOR )==51000){
+ int floor = 0, x = 0, y = 0;
+ CHAR_getElderPosition( CHAR_getInt( charaindex, CHAR_LASTTALKELDER), &floor, &x, &y );
+ CHAR_warpToSpecificPoint( charaindex, floor, x, y);
+ }
+ lssproto_XYD_send(getfdFromCharaIndex( charaindex ),CHAR_getInt( charaindex, CHAR_X ),CHAR_getInt( charaindex, CHAR_Y ),CHAR_getInt( charaindex, CHAR_DIR ) );
+ if(CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER){
+ CHAR_CheckItemTime(charaindex);
+ }
+ 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 {
+#ifdef _PLAYER_NPC
+ if(CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYERNPC)
+#endif
+// if(CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYERNPC)
+ 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;
+
+ //BUG
+ int pi;
+ for( pi = 0; pi < CHAR_PARTYMAX; pi ++ ) {
+ int index = CHAR_getWorkInt( toindex, pi + CHAR_WORKPARTYINDEX1);
+ if( CHAR_CHECKINDEX(index)) {
+ if(index == charaindex) return 1;
+ }
+ }
+#ifdef _PET_BUG
+ int petarray = CHAR_getInt( charaindex, CHAR_DEFAULTPET);
+ if(petarray>-1){
+ int petindex = CHAR_getCharPet( charaindex, petarray);
+ if(CHAR_getInt(petindex,CHAR_VITAL)>=getPetPoint(0)*20 || CHAR_getInt(petindex,CHAR_STR)>=getPetPoint(1)*80 || CHAR_getInt(petindex,CHAR_TOUGH)>=getPetPoint(2)*80 || CHAR_getInt(petindex,CHAR_DEX)>=getPetPoint(3)*100)
+ return 1;
+ }
+#endif
+#ifdef _WARNPC_CTRL
+ int mapi;
+ for(mapi=0;mapi<10;mapi++){
+ int floorid = getPartyMap(mapi);
+ if(floorid==-1) break;
+ if(CHAR_getInt(charaindex,CHAR_FLOOR)==floorid){
+ int sameipnum = getMapSameIp(mapi);
+ int partyi;
+ unsigned ip=CONNECT_get_userip(getfdFromCharaIndex(charaindex));
+ unsigned teseip = ip;
+ unsigned toip;
+ int a, b, c, d,ipcnt=1;
+ char ipstr[32];
+ a=(teseip % 0x100); teseip=teseip / 0x100;
+ b=(teseip % 0x100); teseip=teseip / 0x100;
+ c=(teseip % 0x100); teseip=teseip / 0x100;
+ d=(teseip % 0x100);
+ sprintf(ipstr,"%d.%d.%d.%d",a,b,c,d);
+ if(strcmp(ipstr,getNoAttIp(0))==0 || strcmp(ipstr,getNoAttIp(1))==0 || strcmp(ipstr,getNoAttIp(2))==0 || strcmp(ipstr,getNoAttIp(3))==0 || strcmp(ipstr,getNoAttIp(4))==0)
+ break;
+ if( CHAR_getWorkInt( toindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_NONE ) {
+ toip=CONNECT_get_userip(getfdFromCharaIndex(toindex));
+ if(ip==toip){
+ ipcnt++;
+ if(ipcnt>sameipnum){
+ CHAR_talkToCli( charaindex, -1, "˵ͼĵIPѴޡ", CHAR_COLORYELLOW);
+ return 1;
+ }
+ else
+ break;
+ }
+ break;
+ }else{
+ for( partyi = 0; partyi < CHAR_PARTYMAX; partyi ++ ) {
+ int index = CHAR_getWorkInt( toindex, partyi + CHAR_WORKPARTYINDEX1);
+ if( CHAR_CHECKINDEX(index)) {
+ toip = CONNECT_get_userip(getfdFromCharaIndex(index));
+ if(ip==toip){
+ ipcnt++;
+ if(ipcnt>sameipnum){
+ CHAR_talkToCli( charaindex, -1, "˵ͼĵIPѴޡ", CHAR_COLORYELLOW);
+ return 1;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ if(CHAR_getWorkInt(toindex,CHAR_WORKNPCBATTLESAMEIP)>0){
+ int sameipnum = CHAR_getWorkInt(toindex,CHAR_WORKNPCBATTLESAMEIP);
+ int partyi;
+ unsigned ip=CONNECT_get_userip(getfdFromCharaIndex(charaindex));
+ unsigned teseip = ip;
+ unsigned toip;
+ int a, b, c, d,ipcnt=1;
+ char ipstr[32];
+ a=(teseip % 0x100); teseip=teseip / 0x100;
+ b=(teseip % 0x100); teseip=teseip / 0x100;
+ c=(teseip % 0x100); teseip=teseip / 0x100;
+ d=(teseip % 0x100);
+ sprintf(ipstr,"%d.%d.%d.%d",a,b,c,d);
+ if(strcmp(ipstr,getNoAttIp(0))==0 || strcmp(ipstr,getNoAttIp(1))==0 || strcmp(ipstr,getNoAttIp(2))==0 || strcmp(ipstr,getNoAttIp(3))==0 || strcmp(ipstr,getNoAttIp(4))==0){
+ }else{
+ if( CHAR_getWorkInt( toindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_NONE ) {
+ toip=CONNECT_get_userip(getfdFromCharaIndex(toindex));
+ if(ip==toip){
+ ipcnt++;
+ if(ipcnt>sameipnum){
+ CHAR_talkToCli( charaindex, -1, "ͬIPѴޣս", CHAR_COLORYELLOW);
+ return 1;
+ }
+ }
+ }else{
+ for( partyi = 0; partyi < CHAR_PARTYMAX; partyi ++ ) {
+ int index = CHAR_getWorkInt( toindex, partyi + CHAR_WORKPARTYINDEX1);
+ if( CHAR_CHECKINDEX(index)) {
+ toip = CONNECT_get_userip(getfdFromCharaIndex(index));
+ if(ip==toip){
+ ipcnt++;
+ if(ipcnt>sameipnum){
+ CHAR_talkToCli( charaindex, -1, "ͬIPѴޣս", CHAR_COLORYELLOW);
+ return 1;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+#endif
+
+ 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
+#ifdef _PET_BUG
+ int petarray = CHAR_getInt( charaindex, CHAR_DEFAULTPET);
+ if(petarray>-1){
+ int petindex = CHAR_getCharPet( charaindex, petarray);
+ if(CHAR_getInt(petindex,CHAR_VITAL)>=getPetPoint(0)*20 || CHAR_getInt(petindex,CHAR_STR)>=getPetPoint(1)*80 || CHAR_getInt(petindex,CHAR_TOUGH)>=getPetPoint(2)*80 || CHAR_getInt(petindex,CHAR_DEX)>=getPetPoint(3)*100)
+ 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
+#ifdef _PLAYER_NPC
+ && CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYERNPC
+#endif
+ // && CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYERNPC
+ ) 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];
+ strcpysafe( msgbuf,sizeof(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
+#ifdef _PLAYER_NPC
+ && CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYERNPC
+#endif
+ // && CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYERNPC
+ ) 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];
+ strcpysafe( msgbuf,sizeof(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_CreateVsEnemyNew( int charaindex, int npcindex, int *table )
+{
+ int battleindex, iRet = 0, enemyindex, i, pindex;
+ int fd, field_no, baselevel = 0;
+ int skillType=0;
+ int EnemyList[20];
+
+ int *enemytable = table;
+
+ if( CHAR_CHECKINDEX( charaindex ) == FALSE )return BATTLE_ERR_CHARAINDEX;
+#ifdef _PLAYER_NPC
+ if(CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER)
+#endif
+// if(CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER)
+{
+#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(charaindex);
+ 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;
+ BattleArray[battleindex].BattleFloor = CHAR_getInt( charaindex, CHAR_FLOOR );
+
+ BattleArray[battleindex].Side[0].flg &= ~BSIDE_FLG_HELP_OK;
+
+ if( CHAR_CHECKINDEX( npcindex) ){
+ if(CHAR_getInt( npcindex, CHAR_LV )>1){
+ baselevel = CHAR_getInt( npcindex, CHAR_LV );
+ }
+ CHAR_setWorkInt( npcindex, CHAR_WORKBATTLEINDEX, battleindex );
+ }else if( npcindex == -1 ){
+ enemytable = ENEMY_getEnemy( charaindex,
+ CHAR_getInt( charaindex, CHAR_X),
+ CHAR_getInt( charaindex, CHAR_Y));
+ }
+
+ BattleArray[battleindex].norisk = 0;
+ 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
+ for( i = 0; EnemyList[i] != -1; i ++ ){
+ int work;
+ enemyindex = ENEMY_createEnemy( EnemyList[i], baselevel );
+
+ if( !CHAR_CHECKINDEX( enemyindex ) ){
+ iRet = BATTLE_ERR_NOENEMY;
+ goto BATTLE_CreateVsEnemy_End;
+ }
+ CHAR_setInt(enemyindex, CHAR_WHICHTYPE, CHAR_TYPEENEMY);
+ if( skillType > 0 ){
+ //int ENEMY_RandomChange( int enemyindex, int tempno ){
+ BATTLE_EnemyRandowSetSkill( enemyindex, skillType);
+ }
+#ifdef _ALLBLUES_LUA_1_9
+ SetBattleEnmeyFunction(npcindex, enemyindex, i);
+#endif
+
+ 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 ) );
+ }
+ }
+
+ 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(npcindex > -1){
+ if( fd != -1 ){
+ if( BattleArray[battleindex].dpbattle ){
+ lssproto_EN_send( fd, BATTLE_TYPE_DP_BATTLE, field_no );
+ }else{
+ lssproto_EN_send( fd, BATTLE_TYPE_BOSS_BATTLE, field_no );
+ }
+ } else {
+#ifdef _OFFLINE_SYSTEM
+ if(CHAR_getWorkInt( charaindex, CHAR_WORK_OFFLINE ) == 0)
+#endif
+ {
+ 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 ){
+ lssproto_EN_send( fd, BATTLE_TYPE_BOSS_BATTLE, 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_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
+
+#ifdef _PET_BUG
+ int petarray = CHAR_getInt( charaindex, CHAR_DEFAULTPET);
+ if(petarray>-1){
+ int petindex = CHAR_getCharPet( charaindex, petarray);
+ if(CHAR_getInt(petindex,CHAR_VITAL)>=getPetPoint(0)*20 || CHAR_getInt(petindex,CHAR_STR)>=getPetPoint(1)*80 || CHAR_getInt(petindex,CHAR_TOUGH)>=getPetPoint(2)*80 || CHAR_getInt(petindex,CHAR_DEX)>=getPetPoint(3)*100)
+ return BATTLE_ERR_END;
+ }
+#endif
+
+ if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) != BATTLE_CHARMODE_NONE ){
+ CHAR_talkToCli( charaindex, -1, "", CHAR_COLORYELLOW );
+ return BATTLE_ERR_ALREADYBATTLE;
+ }
+#ifdef _BATTLEMAP_CTRL
+ int j;
+ for(j=0;j<10;j++){
+ if(getBattleTimeFloor(j)==-1) break;
+ if(CHAR_getInt(charaindex,CHAR_FLOOR)==getBattleTimeFloor(j) && CHAR_getPartyNum(charaindex)<=getBattleTimePlayerNum(j)){
+ time_t timep;
+ struct tm *p;
+ time(&timep);
+ p=localtime(&timep); /*ȡõʱ*/
+ timep = mktime(p);
+ if(timep-CHAR_getWorkInt(charaindex,CHAR_WORKBATTLETIME)<=getBattleTimeSec(j)){
+ return BATTLE_ERR_END;
+ }else{
+ CHAR_setWorkInt(charaindex,CHAR_WORKBATTLETIME,timep);
+ break;
+ }
+ }
+ }
+#endif
+ battleindex = BATTLE_CreateBattle( charaindex );
+ if( battleindex < 0 )return BATTLE_ERR_NOTASK;
+#ifdef _WAN_FIX
+ CHAR_setWorkInt(charaindex,CHAR_WORKBATTLEPROTYPE,1);
+#endif
+ 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
+ for( i = 0; EnemyList[i] != -1; i ++ ){
+ int work;
+ enemyindex = ENEMY_createEnemy( EnemyList[i], baselevel );
+ 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 {
+#ifdef _OFFLINE_SYSTEM
+ if(CHAR_getWorkInt( charaindex, CHAR_WORK_OFFLINE ) == 0)
+#endif
+ {
+ 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 _BATTLEEND_FIX
+ if(getBattleEndMode()==1){
+ int myfloor=CHAR_getInt(charaindex0,CHAR_FLOOR);
+ if(myfloor==getBattleFloor(1) ||
+ myfloor==getBattleFloor(2) ||
+ myfloor==getBattleFloor(3) ||
+ myfloor==getBattleFloor(4) ||
+ myfloor==getBattleFloor(5) ||
+ myfloor==1042 ||
+ myfloor==2032 ||
+ myfloor==3032 ||
+ myfloor==4032)
+ {
+ time_t timep;
+ struct tm *p;
+ time(&timep);
+ p=localtime(&timep); /*ȡõʱ*/
+ timep = mktime(p);
+ if(CHAR_getWorkInt(charaindex1,CHAR_WORKBALLTELENDTIME)+120>timep){
+ char bmsg[256];
+ sprintf(bmsg,"Է㱣Уʣʱ䣺%d룬Էƶ",CHAR_getWorkInt(charaindex1,CHAR_WORKBALLTELENDTIME)+120-timep);
+ CHAR_talkToCli( charaindex0, -1, bmsg, CHAR_COLORYELLOW );
+ return BATTLE_ERR_ALREADYBATTLE;
+ }
+ }
+ }
+#endif
+#ifdef _PET_BUG
+ int petindex;
+ int petarray0 = CHAR_getInt( charaindex0, CHAR_DEFAULTPET);
+ int petarray1 = CHAR_getInt( charaindex1, CHAR_DEFAULTPET);
+ if(petarray0>-1){
+ petindex = CHAR_getCharPet( charaindex0, petarray0);
+ if(CHAR_getInt(petindex,CHAR_VITAL)>=getPetPoint(0)*20 || CHAR_getInt(petindex,CHAR_STR)>=getPetPoint(1)*80 || CHAR_getInt(petindex,CHAR_TOUGH)>=getPetPoint(2)*80 || CHAR_getInt(petindex,CHAR_DEX)>=getPetPoint(3)*100)
+ return BATTLE_ERR_END;
+ }
+ if(petarray1>-1){
+ petindex = CHAR_getCharPet( charaindex1, petarray1);
+ if(CHAR_getInt(petindex,CHAR_VITAL)>=getPetPoint(0)*20 || CHAR_getInt(petindex,CHAR_STR)>=getPetPoint(1)*80 || CHAR_getInt(petindex,CHAR_TOUGH)>=getPetPoint(2)*80 || CHAR_getInt(petindex,CHAR_DEX)>=getPetPoint(3)*100)
+ return BATTLE_ERR_END;
+ }
+#endif
+
+ field_no = BATTLE_getBattleFieldNo(
+ CHAR_getInt( charaindex0, CHAR_FLOOR ) ,
+ CHAR_getInt( charaindex0, CHAR_X ),
+ CHAR_getInt( charaindex0, CHAR_Y ) );
+
+ int tmpi = RAND(1,10);
+ if(tmpi<=5){
+ charaindex[0] = charaindex1;
+ charaindex[1] = charaindex0;
+ }else{
+ charaindex[0] = charaindex0;
+ charaindex[1] = charaindex1;
+ }
+ charaindex0 = charaindex[0];
+ charaindex1 = charaindex[1];
+ //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(charaindex0 );
+ if( battleindex < 0 )return BATTLE_ERR_NOTASK;
+
+ if(CHAR_getInt(charaindex0,CHAR_FLOOR)==1042){
+ sprintf(afmwar,"%s%d,",afmwar,battleindex);
+ afmwarnum++;
+ }else if(CHAR_getInt(charaindex0,CHAR_FLOOR)==2032){
+ sprintf(bfmwar,"%s%d,",bfmwar,battleindex);
+ bfmwarnum++;
+ }else if(CHAR_getInt(charaindex0,CHAR_FLOOR)==3032){
+ sprintf(cfmwar,"%s%d,",cfmwar,battleindex);
+ cfmwarnum++;
+ }else if(CHAR_getInt(charaindex0,CHAR_FLOOR)==4032){
+ sprintf(dfmwar,"%s%d,",dfmwar,battleindex);
+ dfmwarnum++;
+ }else if(CHAR_getInt(charaindex0,CHAR_FLOOR)==20000){
+ sprintf(efmwar,"%s%d,",efmwar,battleindex);
+ efmwarnum++;
+ }else if(CHAR_getInt(charaindex0,CHAR_FLOOR)==51000){
+ sprintf(ffmwar,"%s%d,",ffmwar,battleindex);
+ ffmwarnum++;
+ }
+#ifdef _WAN_FIX
+ CHAR_setWorkInt(charaindex0,CHAR_WORKBATTLEPROTYPE,1);
+ CHAR_setWorkInt(charaindex1,CHAR_WORKBATTLEPROTYPE,1);
+#endif
+ BattleArray[battleindex].Side[0].type = BATTLE_S_TYPE_PLAYER;
+ BattleArray[battleindex].Side[1].type = BATTLE_S_TYPE_PLAYER;
+ BattleArray[battleindex].leaderindex = charaindex0;
+#ifdef _AUTO_PK
+ memset(BattleArray[battleindex].leadercdkey, 0, sizeof(BattleArray[battleindex].leadercdkey));
+ memset(BattleArray[battleindex].leadername, 0, sizeof(BattleArray[battleindex].leadername));
+ memset(BattleArray[battleindex].rivalcdkey, 0, sizeof(BattleArray[battleindex].rivalcdkey));
+ memset(BattleArray[battleindex].rivalname, 0, sizeof(BattleArray[battleindex].rivalname));
+ strcpysafe(BattleArray[battleindex].leadercdkey,sizeof(BattleArray[battleindex].leadercdkey),CHAR_getChar(charaindex0,CHAR_CDKEY));
+ strcpysafe(BattleArray[battleindex].leadername,sizeof(BattleArray[battleindex].leadername),CHAR_getChar(charaindex0,CHAR_NAME));
+ BattleArray[battleindex].rivalindex = charaindex1;
+ strcpysafe(BattleArray[battleindex].rivalcdkey,sizeof(BattleArray[battleindex].rivalcdkey),CHAR_getChar(charaindex1,CHAR_CDKEY));
+ strcpysafe(BattleArray[battleindex].rivalname,sizeof(BattleArray[battleindex].rivalname),CHAR_getChar(charaindex1,CHAR_NAME));
+#endif
+ 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
+ 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;
+ }
+
+ if(CHAR_getInt(charaindex,CHAR_FLOOR)==20000){
+ CHAR_talkToCli( charaindex, -1, "PKУڹս", CHAR_COLORYELLOW );
+ return BATTLE_ERR_ALREADYBATTLE;
+ }
+
+ // ë
+ battleindex = BATTLE_CreateBattle(charaindex );
+ if( battleindex < 0 )return BATTLE_ERR_NOTASK;// έƥئ¡
+#ifdef _WAN_FIX
+ CHAR_setWorkInt(charaindex,CHAR_WORKBATTLEPROTYPE,1);
+#endif
+ // ռɷƥؤ£
+ 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 ){
+ CHAR_setWorkInt(charaindex,CHAR_WORKBATTLEREVERSE,1);
+ // ƻئݳ
+ }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 )
+{
+ //DebugMainFunction="BATTLE_Init";
+ 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;
+ }
+#ifdef _OFFLINE_SYSTEM
+ if(CHAR_getWorkInt( charaindex, CHAR_WORK_OFFLINE ) == 1){
+ //NPC_OffLineCommand( battleindex, charaindex, side );
+ OffLineCommand( battleindex, charaindex, side );
+ if(CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER
+#ifdef _PLAYER_NPC
+ ||CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYERNPC
+#endif
+// ||CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYERNPC
+ ){
+ int petnum = CHAR_getInt(charaindex,CHAR_DEFAULTPET);
+ int petindex = CHAR_getCharPet(charaindex,petnum);
+ if(CHAR_CHECKINDEX(petindex)){
+ //NPC_OffLineCommand( battleindex, petindex, side );
+ OffLineCommand( battleindex, petindex, side );
+ }
+ }
+ }
+#endif
+ 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
+ int battletimeout = getBattleTimtOut();
+ if(battletimeout == 0) battletimeout = 120;
+ BattleArray[battleindex].PartTime = (int)time(NULL) + battletimeout;
+ }
+#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_getInt( ownerindex, CHAR_ADDEXPPOWER) > 0){
+ modexp = CHAR_getInt( ownerindex, CHAR_ADDEXPPOWER);
+ }
+ }else if(CHAR_getInt(charaindex,CHAR_ADDEXPPOWER) > 0){
+ modexp = CHAR_getInt(charaindex,CHAR_ADDEXPPOWER);
+ }
+
+ getexp = CHAR_getWorkInt( charaindex, CHAR_WORKGETEXP );
+#ifdef _ALLBLUES_LUA_2_0
+ int exp = getexp;
+ if (CHAR_getInt(charaindex,CHAR_LV) == getMaxLevel()){
+ FreeCharExpSave(charaindex,exp );
+ }
+#endif
+#ifdef _NEWOPEN_MAXEXP
+ if( getexp > 1000000000 ) getexp = 1000000000;
+#endif
+#ifdef _BATTLE_GOLD
+ int gold=CHAR_getInt( charaindex , CHAR_GOLD );
+ if((gold+CHAR_getInt( charaindex , CHAR_LV ) * getBattleGold()) > CHAR_getMaxHaveGold(charaindex))
+ gold=CHAR_getMaxHaveGold(charaindex);
+ else
+ gold+=CHAR_getInt( charaindex , CHAR_LV ) * getBattleGold();
+ CHAR_setInt( charaindex , CHAR_GOLD , gold );
+ CHAR_complianceParameter( charaindex );
+ CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_GOLD);
+#endif
+ if( getexp < 0 || CHAR_GetLevelExp( charaindex, CHAR_getInt( charaindex, CHAR_LV)+1)==-1) getexp = 0;
+ int itemgetexp = CHAR_getWorkInt(charaindex,CHAR_WORKITEMEXP);
+ int itemaddexp = 0;
+ if(itemgetexp<0) itemgetexp = 0;
+ addexp = getexp+((getexp*modexp)/100);
+ itemaddexp = itemgetexp+((itemgetexp*modexp)/100);
+#ifdef _GET_BATTLE_EXP
+ addexp*=getBattleexp();
+ itemaddexp*=getBattleexp();
+#endif
+#ifdef _FM_EXP_ADD
+ int flag=0;
+ int manor[]={1041,2031,3031,4031,5031,6031,7031,8031,9031,7531};
+ int floor=CHAR_getWorkInt( charaindex, CHAR_WORKFMFLOOR);
+ for( i = 0 ; i < MANORNUM ; i ++ ){
+ if(floor==manor[i]){
+ flag=1;
+ break;
+ }
+ }
+ if(flag==1 && CHAR_getInt( charaindex, CHAR_FMLEADERFLAG ) != FMMEMBER_APPLY){
+ addexp += getexp * getFmAddExp()*0.1;
+ }
+#endif
+#ifdef _TEAM_ADDEXP
+ int partynum ;
+ partynum=CHAR_getPartyNum( charaindex);
+ if (getTeamAddExp()>0) {
+ addexp+= getexp*(partynum-1)*getTeamAddExp()*0.1;
+ }
+#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;
+ itemaddexp += itemgetexp*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(itemaddexp>0){
+ ITEM_ExpLvBase(charaindex,itemaddexp);
+ CHAR_setWorkInt(charaindex,CHAR_WORKITEMEXP,0);
+ }
+
+
+ if( CHAR_getInt( charaindex, CHAR_LV) >= CHAR_MAXUPLEVEL ) addexp = 0;
+#ifdef _VIP_BATTLE_EXP
+ if(CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ){
+ if(CHAR_getInt( charaindex, CHAR_VIPRIDE) > 0 || CHAR_getInt( charaindex, CHAR_NVIPEXP) > 0){
+ addexp = addexp * getVipBattleExp();
+ }
+ }
+ if(CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPET ){
+ if(CHAR_getInt( midx, CHAR_VIPRIDE) > 0 || CHAR_getInt( midx, CHAR_NVIPEXP) > 0){
+ addexp = addexp * getVipBattleExp();
+ }
+ }
+#else
+ if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER
+ && CHAR_getInt( charaindex, CHAR_VIPRIDE) > 0) addexp = addexp * 2;
+ if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPET
+ && CHAR_getInt( midx, CHAR_VIPRIDE) > 0) addexp = addexp * 2;
+#endif
+
+ 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 != -1 && 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, vpmin;
+ int fd;
+ int fl = 0, x = 0, y = 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;
+ charaindex = BattleArray[battleindex].Side[side].Entry[num].charaindex;
+ int playfloor = CHAR_getInt(charaindex, CHAR_FLOOR);
+ if(playfloor==11111)vpmin = getBalltePoint(0)*2;
+ if(playfloor==22222)vpmin = getBalltePoint(1)*2;
+ if(playfloor==33333)vpmin = getBalltePoint(2)*2;
+ if(playfloor==44444)vpmin = getBalltePoint(3)*2;
+ 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 ); // ئ֨෴յ
+ }
+ if(playfloor==11111||
+ playfloor==22222||
+ playfloor==33333||
+ playfloor==44444)
+ {
+ int fd = getfdFromCharaIndex( charaindex);
+ char* id = CHAR_getChar( charaindex, CHAR_CDKEY);
+ dpnow = sasql_vippoint(id,0,0) + dpadd; //PKԱ
+ dpnow = max( dpnow, 0 ); //ڻԱ
+ sasql_vippoint( id, dpadd, 1 ); //дԱ
+ if(dpnow= 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_TYPEPLAYER ){
+#ifdef _PLAYER_NPC
+ if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYERNPC
+ || CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYERPETNPC){
+ if( CHAR_getFlg( charaindex, CHAR_ISDIE ) == FALSE ){
+#ifdef _ITEM_ADDEQUIPEXP
+ BATTLE_GetExp( charaindex , charaindex );
+#else
+ BATTLE_GetExp( charaindex );
+#endif
+ int UpLevel = CHAR_LevelUpCheck( charaindex , -1);
+ int i;
+ for( i = 0; i < UpLevel; i ++ ){
+ CHAR_PetLevelUp( charaindex );
+ CHAR_PetAddVariableAi( charaindex, AI_FIX_PETLEVELUP );
+ }
+ }
+ }
+#endif
+ return 0;
+ }
+ //CAX
+/* 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 );
+ }
+#ifdef _SKILLUPPOINT_CF
+ CHAR_setInt( charaindex, CHAR_SKILLUPPOINT,
+ CHAR_getInt( charaindex, CHAR_SKILLUPPOINT) + UpLevel*getSkup());
+#else
+ CHAR_setInt( charaindex, CHAR_SKILLUPPOINT,
+ CHAR_getInt( charaindex, CHAR_SKILLUPPOINT) + UpLevel*3);
+#endif
+ 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
+#ifdef _OFFLINE_SYSTEM
+ && CHAR_getWorkInt( charaindex, CHAR_WORK_OFFLINE ) == 0
+#endif
+ ){
+ 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 = 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 itemlogitem
+// 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 );
+ }
+ 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 )
+{
+ //DebugMainFunction="BATTLE_Finish";
+ BATTLE *pBattle;
+ BATTLE_ENTRY *pEntry;
+ int i,charaindex, j;
+ if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX;
+ if( BattleArray[battleindex].winside == -1
+ && BattleArray[battleindex].type == BATTLE_TYPE_P_vs_E
+ && BattleArray[battleindex].WinFunc != NULL){
+ BattleArray[battleindex].WinFunc( battleindex,
+ BattleArray[battleindex].createindex );
+ }
+#ifdef _ALLBLUES_LUA
+ if( BattleArray[battleindex].type == BATTLE_TYPE_P_vs_E ){
+ if(CHAR_CHECKINDEX( BattleArray[battleindex].createindex ) == TRUE){
+ CHAR_setWorkInt( BattleArray[battleindex].createindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_NONE );
+ CHAR_sendBattleEffect( BattleArray[battleindex].createindex, OFF);
+ if( BattleArray[battleindex].winside == -1){
+ RunCharBattleOverEvent( BattleArray[battleindex].createindex, battleindex, 1);
+ }else{
+ RunCharBattleOverEvent( BattleArray[battleindex].createindex, battleindex, 0);
+ }
+ }
+ }
+#endif
+#ifdef _BATTLE_PK
+ if(CHAR_getInt( BattleArray[battleindex].battleindex, CHAR_BATTLEPK)==TRUE ||
+ CHAR_getInt( BattleArray[battleindex].leaderindex, CHAR_BATTLEPK)==TRUE){
+ int winindex,lostindex;
+ if( BattleArray[battleindex].type == BATTLE_TYPE_P_vs_P){
+ if( BattleArray[battleindex].winside == -1 ){
+ winindex=BattleArray[battleindex].leaderindex;
+ lostindex=BattleArray[battleindex].rivalindex;
+ }else{
+ winindex=BattleArray[battleindex].rivalindex;
+ lostindex=BattleArray[battleindex].leaderindex;
+ }
+
+ if(CHAR_CHECKINDEX(lostindex) != FALSE){
+ int fl = 0, x = 0, y = 0;
+ CHAR_getElderPosition(CHAR_getInt(lostindex, CHAR_LASTTALKELDER), &fl, &x, &y);
+ CHAR_warpToSpecificPoint(lostindex, fl, x, y);
+ CHAR_DischargeParty( lostindex, 0);
+ CHAR_setInt( winindex, CHAR_BATTLEPK, FALSE);
+ CHAR_setInt( lostindex, CHAR_BATTLEPK, FALSE);
+ }
+ }
+ }
+#endif
+
+#ifdef _AUTO_PK
+ if(AutoPk_PKTimeGet()<=0){
+ if(CHAR_getInt(BattleArray[battleindex].rivalindex, CHAR_FLOOR)==20000 &&
+ CHAR_getInt(BattleArray[battleindex].leaderindex, CHAR_FLOOR)==20000){
+
+ if(BattleArray[battleindex].type != BATTLE_TYPE_WATCH
+ && BattleArray[battleindex].mode != BATTLE_MODE_WATCHBC
+ && CHAR_getInt(BattleArray[battleindex].leaderindex, CHAR_AUTOPK) != -1
+ && CHAR_getInt(BattleArray[battleindex].rivalindex, CHAR_AUTOPK) != -1){
+ int winindex,lostindex;
+ char wincdkey[CDKEYLEN],winname[CHARNAMELEN];
+ char lostcdkey[CDKEYLEN],lostname[CHARNAMELEN];
+ if( BattleArray[battleindex].type == BATTLE_TYPE_P_vs_P && BattleArray[battleindex].winside == -1 ){
+ winindex=BattleArray[battleindex].leaderindex;
+ strcpysafe(wincdkey,sizeof(wincdkey),BattleArray[battleindex].leadercdkey);
+ strcpysafe(winname,sizeof(winname),BattleArray[battleindex].leadername);
+ lostindex=BattleArray[battleindex].rivalindex;
+ strcpysafe(lostcdkey,sizeof(lostcdkey),BattleArray[battleindex].rivalcdkey);
+ strcpysafe(lostname,sizeof(lostname),BattleArray[battleindex].rivalname);
+ }else{
+ winindex=BattleArray[battleindex].rivalindex;
+ strcpysafe(wincdkey,sizeof(wincdkey),BattleArray[battleindex].rivalcdkey);
+ strcpysafe(winname,sizeof(winname),BattleArray[battleindex].rivalname);
+ lostindex=BattleArray[battleindex].leaderindex;
+ strcpysafe(lostcdkey,sizeof(lostcdkey),BattleArray[battleindex].leadercdkey);
+ strcpysafe(lostname,sizeof(lostname),BattleArray[battleindex].leadername);
+ }
+ int i, fl = 0, x = 0, y = 0, num=0;
+ int playernum = CHAR_getPlayerMaxNum();
+ char token[64],token2[128];
+ if(CHAR_CHECKINDEX(lostindex) != FALSE){
+ CHAR_getElderPosition(CHAR_getInt(lostindex, CHAR_LASTTALKELDER), &fl, &x, &y);
+ CHAR_warpToSpecificPoint(lostindex, fl, x, y);
+ CHAR_DischargeParty( lostindex, 0);
+ }
+ if(CHAR_CHECKINDEX(winindex) != FALSE){
+ CHAR_setInt(winindex,CHAR_AUTOPK,CHAR_getInt(winindex,CHAR_AUTOPK)+1);
+ sprintf(token,"[ս]%s սʤ %s ս", winname, lostname);
+ autopkcnt++;
+ int autopkvigor = getAutoPkVigorPkNum()*CHAR_getInt(lostindex,CHAR_AUTOPK)+getAutoPkVigorPkCnt()*autopkcnt;
+ CHAR_setInt(lostindex,CHAR_VIGOR,CHAR_getInt(lostindex,CHAR_VIGOR)+autopkvigor);
+ sprintf(token2,"[ս]%sɱ %d %d û%d",lostname,CHAR_getInt(lostindex,CHAR_AUTOPK),autopkcnt,autopkvigor);
+ }else{
+ sprintf(token,"[ս]%s %s ", winname, lostname);
+ autopkcnt++;
+ int autopkvigor = getAutoPkVigorPkNum()*CHAR_getInt(lostindex,CHAR_AUTOPK)+getAutoPkVigorPkCnt()*autopkcnt;
+ CHAR_setInt(lostindex,CHAR_VIGOR,CHAR_getInt(lostindex,CHAR_VIGOR)+autopkvigor);
+ sprintf(token2,"[ս]%sɱ %d %d û%d",lostname,CHAR_getInt(lostindex,CHAR_AUTOPK),autopkcnt,autopkvigor);
+ }
+ for(i=0;i= 0 ; i -- ){
+#endif
+ charaindex = pEntry[i].charaindex;
+
+ if( CHAR_CHECKINDEX( charaindex ) == FALSE )
+ continue;
+#ifdef _ALLBLUES_LUA_1_9
+ BattleFinishFunction(charaindex, BattleArray[battleindex].CreateTime, BattleArray[battleindex].turn, BattleArray[battleindex].type);
+#endif
+ 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 )
+{
+ //DebugMainFunction="BATTLE_Stop";
+ 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];
+
+}
+
+//*********************************************************
+//
+// ؤϷԻ ëң
+//
+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 )
+{
+ //DebugMainFunction="BATTLE_WatchWait";
+ 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 )
+{
+ //DebugMainFunction="BATTLE_WatchMovie";
+ return 0;
+
+}
+
+int BATTLE_WatchAfter( int battleindex )
+{
+ //DebugMainFunction="BATTLE_WatchAfter";
+ BattleArray[battleindex].mode = BATTLE_MODE_WATCHPRE;
+
+ return 0;
+
+}
+
+int BATTLE_WatchBC( int battleindex )
+{
+ //DebugMainFunction="BATTLE_WatchBC";
+ return 0;
+}
+
+int BATTLE_WatchPre( int battleindex )
+{
+ //DebugMainFunction="BATTLE_WatchPre";
+ // Ѩг ݼ ľ
+ BATTLE_PreWatchWaitSeq( battleindex );
+ BattleArray[battleindex].mode = BATTLE_MODE_WATCHWAIT;
+ return 0;
+}
+
+static int BATTLE_Command( int battleindex )
+{
+ //DebugMainFunction="BATTLE_Command";
+ BATTLE *pBattle, *pWatchBattle;
+ BOOL commandflg = TRUE, iFinish = FALSE;
+ int OnlyRescue[2]={0,0};
+ int i, j, charaindex;
+ if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX;
+ pBattle = &BattleArray[battleindex];
+ //DebugMainFunction="BATTLE_Command_1";
+
+ if( BATTLE_CommandWait( battleindex, 0) == FALSE ){
+ commandflg = FALSE;
+ }
+ //DebugMainFunction="BATTLE_Command_2";
+ if( BATTLE_CommandWait( battleindex, 1) == FALSE ){
+ commandflg = FALSE;
+ }
+ //DebugMainFunction="BATTLE_Command_3";
+ pWatchBattle = pBattle->pNext;
+ //DebugMainFunction="BATTLE_Command_4";
+ 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;
+ }
+ }
+ //DebugMainFunction="BATTLE_Command_5";
+ if( BATTLE_TimeOutCheck( battleindex ) == TRUE ){
+ commandflg = TRUE;
+ }
+ //DebugMainFunction="BATTLE_Command_6";
+ if( commandflg == FALSE ){
+ return 0;
+ }
+ //DebugMainFunction="BATTLE_Command_7";
+#ifdef _BATTLECOMMAND_TIME
+ BattleArray[battleindex].PartTime = 0;
+#endif
+ //DebugMainFunction="BATTLE_Command_8";
+
+ pBattle->turn ++;//Լغ
+ //DebugMainFunction="BATTLE_Command_9";
+ BATTLE_ai_all( battleindex, 0, 0);
+ //DebugMainFunction="BATTLE_Command_10";
+ BATTLE_ai_all( battleindex, 1, 0);
+ //DebugMainFunction="BATTLE_Command_11";
+ BATTLE_Battling( battleindex );//ս
+ //DebugMainFunction="BATTLE_Command_12";
+ pBattle->Side[0].flg &= ~BSIDE_FLG_SURPRISE;
+ //DebugMainFunction="BATTLE_Command_13";
+ pBattle->Side[1].flg &= ~BSIDE_FLG_SURPRISE;
+ //DebugMainFunction="BATTLE_Command_14";
+ if( BATTLE_OnlyRescue( battleindex, 0, &OnlyRescue[0] ) == 0 ){
+ pBattle->winside = 1;
+ iFinish = TRUE;
+ }else
+ if( BATTLE_OnlyRescue( battleindex, 1, &OnlyRescue[1] ) == 0 ){
+ pBattle->winside = -1;
+ iFinish = TRUE;
+ }
+ //DebugMainFunction="BATTLE_Command_15";
+ 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 );
+ }
+ }
+ }
+ //DebugMainFunction="BATTLE_Command_16";
+ BATTLE_PreCommandSeq( battleindex );
+ //DebugMainFunction="BATTLE_Command_17";
+ if( iFinish == TRUE ){
+ BATTLE_FinishSet( battleindex );
+ }
+ //DebugMainFunction="BATTLE_Command_18";
+ return 0;
+}
+
+extern void BATTLE_changeRideImage( int index );
+
+int BATTLE_Loop( void )
+{
+ int i, cnt = 0;
+ 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 ++;
+ }
+ 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;
+#ifdef _DEX_FIX
+ dex = work - RAND( 0, work * 0.01*getDexFixPer() );
+#else
+ dex = work - RAND( 0, work * 0.3 );
+#endif
+ 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;
+#ifdef _DEX_FIX
+ dex = work - RAND( 0, work * 0.01*getDexFixPer());
+#else
+ dex = work - RAND( 0, work * 0.3 );
+#endif
+ break;
+ }
+
+ // Ѩ̹ϵئȻգ
+ //if( dex <= 0 )dex = 1; //ٷ
+ if( dex<=0 ) dex = RAND(1,10); //ĺ1-5֮ȡ
+ 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;
+ 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; // зߡ
+ }
+
+ // ߾ ئ
+ 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;
+ int floor=0, x=0, y=0;
+ szBuffer[0] = 0;
+
+ if( CHAR_getInt( enemyindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER
+#ifdef _PLAYER_NPC
+ || CHAR_getInt( enemyindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYERNPC
+#endif
+// || CHAR_getInt( enemyindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYERNPC
+ ){
+ 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 );
+ }
+ }
+ }
+ if( CHAR_getElderPosition(
+ CHAR_getInt( enemyindex, CHAR_LASTTALKELDER), &floor, &x, &y )
+ != TRUE
+ ){
+ }else{
+ CHAR_warpToSpecificPoint( enemyindex, floor, x, y );
+ }
+ }
+ 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 ) );
+
+ // DZмɻշ
+ 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 );
+ }
+ // DZмʸϷּë
+ 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 );
+
+ // DZмì߶Ʊз зƱ
+ if( CHAR_getInt( playerindex, CHAR_LV ) <= 10 ){
+ levelflg = 2;
+ }
+ // мëƱ
+ CHAR_PetAddVariableAi( enemyindex, AI_FIX_PETDEAD/levelflg );
+ // DZмʸϷּë
+ 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;
+ int indexfloor = CHAR_getInt( charaindex, CHAR_FLOOR);
+ if(indexfloor==11111)
+ {
+ dpadd = getBalltePoint(0);
+ }
+ else if(indexfloor==22222)
+ {
+ dpadd = getBalltePoint(1);
+ }
+ else if(indexfloor==33333)
+ {
+ dpadd = getBalltePoint(2);
+ }
+ else if(indexfloor==44444)
+ {
+ dpadd = getBalltePoint(3);
+ }
+ else
+ {
+ 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;
+ int indexfloor = CHAR_getInt(enemyindex,CHAR_FLOOR);
+ if(indexfloor == 11111)dpadd = getBalltePoint(0);
+ if(indexfloor == 22222)dpadd = getBalltePoint(1);
+ if(indexfloor == 33333)dpadd = getBalltePoint(2);
+ if(indexfloor == 44444)dpadd = getBalltePoint(3);
+ if(indexfloor==11111||
+ indexfloor==22222||
+ indexfloor==33333||
+ indexfloor==44444) //жڵͼ
+ {
+// dpnow = CHAR_getWorkInt( enemyindex, CHAR_WORKVIPPOINT );
+// dpnow -= dpadd;
+// CHAR_setWorkInt( enemyindex, CHAR_WORKGETEXP,
+// CHAR_getWorkInt( enemyindex, CHAR_WORKGETEXP) - dpadd );
+ }
+ else
+ {
+ 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;
+ }
+#ifdef _SHARE_EXP //ŶӾ鹲
+ if(getExpShare()==1){
+ for( i = 0; i < BATTLE_ENTRY_MAX ; i ++ ){
+ if( BattleArray[battleindex].type == BATTLE_TYPE_P_vs_E ){
+ charaindex[i] = BATTLE_No2Index( battleindex, i);
+ //if( charaindex[i] < 0 )return BATTLE_ERR_PARAM;
+ pEntryChara[i] = &BattleArray[battleindex].Side[side].Entry[i];
+ pEntryPlayer[i] = pEntryChara[i];
+ }
+ }
+ }else{
+ 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];
+ }
+ }
+ }
+
+#else
+ 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];
+ }
+ }
+#endif
+ 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 );
+#ifdef _SHARE_EXP
+ for( k = 0; k<10; k ++ ){
+ if(charaindex[k]==-1) continue;
+#else
+ for( k = 0; charaindex[k] != -1; k ++ ){
+#endif
+ 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 );
+ if( CHAR_getInt( charaindex[k], CHAR_WHICHTYPE) == CHAR_TYPEPLAYER && CHAR_getInt( charaindex[k], CHAR_LV) >= 140 ){
+ int toitemindex = -1;
+ toitemindex = CHAR_getItemIndex( charaindex[k], 9);
+ if(ITEM_CHECKINDEX(toitemindex)){
+ if( strlen(ITEM_getChar( toitemindex, ITEM_USEFUNC))>0 && strcmp(ITEM_getChar( toitemindex, ITEM_USEFUNC),"ITEM_useExpLv")==0 ){
+ char* itemarg = ITEM_getChar(toitemindex,ITEM_ARGUMENT);
+ char buftest[128];
+ int itemlv = 0;
+ if(getStringFromIndexWithDelim(itemarg,"|", 1, buftest, sizeof(buftest)) == TRUE){
+ itemlv = atoi(buftest);
+ b_level = itemlv - 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_WORKITEMEXP,CHAR_getWorkInt(charaindex[k],CHAR_WORKITEMEXP)+nowexp);
+ }
+ }
+ }
+ }
+ 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 );
+
+ // ʹѪƵ˼ HPMP
+ 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("\n2");break;
+ case CHAR_WORKICECRACK3: // 3
+ WorkIceCrackPlay( charaindex, cnt, CHAR_WORKICECRACK3 );print("\n3");break;
+ case CHAR_WORKICECRACK4: // 4
+ WorkIceCrackPlay( charaindex, cnt, CHAR_WORKICECRACK4 );print("\n4");break;
+ case CHAR_WORKICECRACK5: // 5
+ WorkIceCrackPlay( charaindex, cnt, CHAR_WORKICECRACK5 );print("\n5");break;
+ case CHAR_WORKICECRACK6: // 6
+ WorkIceCrackPlay( charaindex, cnt, CHAR_WORKICECRACK6 );print("\n6");break;
+ case CHAR_WORKICECRACK7: // 7
+ WorkIceCrackPlay( charaindex, cnt, CHAR_WORKICECRACK7 );print("\n7");break;
+ case CHAR_WORKICECRACK8: // 8
+ WorkIceCrackPlay( charaindex, cnt, CHAR_WORKICECRACK8 );print("\n8");break;
+ case CHAR_WORKICECRACK9: // 9
+ WorkIceCrackPlay( charaindex, cnt, CHAR_WORKICECRACK9 );print("\n9");break;
+ case CHAR_WORKICECRACK10: // 10
+ WorkIceCrackPlay( charaindex, cnt, CHAR_WORKICECRACK10 );print("\n10");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;
+ }
+
+#ifdef _JOB_FIX
+ //
+ if( CHAR_getWorkInt( charaindex, CHAR_WORKICEARROW ) > 0 ){
+ return FALSE;
+ }
+#endif
+/*
+ // רעս
+ 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; // DZ
+ }else{
+ mode = PETAI_MODE_ENEMYATTACK; //
+ }
+ }else{
+ if( Rand < 60 ){
+ mode = PETAI_MODE_OWNERATTACK; // DZ
+ }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: // DZ
+ 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 )
+{
+ //DebugMainFunction="BATTLE_Battling_1";
+ 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;
+ //DebugMainFunction="BATTLE_Battling_2";
+ if( BATTLE_CHECKINDEX( battleindex ) == FALSE )return BATTLE_ERR_BATTLEINDEX;
+ //DebugMainFunction="BATTLE_Battling_3";
+ pBattle = &BattleArray[battleindex];
+ pEntry[0] = pBattle->Side[0].Entry;
+ pEntry[1] = pBattle->Side[1].Entry;
+ //DebugMainFunction="BATTLE_Battling_4";
+ for( i = 0; i < arraysizeof(EntryList); i ++ ){
+ EntryList[i].charaindex = -1;
+ EntryList[i].combo = 0;
+ }
+ //DebugMainFunction="BATTLE_Battling_5";
+ sprintf( szBuffer, "ս %d ת %d %s",
+ battleindex, pBattle->turn,
+ aszFieldAttr[pBattle->field_att]
+ );
+ //DebugMainFunction="BATTLE_Battling_6";
+ 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 ++;
+ }
+ }
+ //DebugMainFunction="BATTLE_Battling_7";
+ 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, "IDerror", CHAR_COLORYELLOW );
+ }
+ }
+ k ++;
+ strcatsafe( szAllBattleString,sizeof(szAllBattleString), szBattleString );
+ }
+ }
+ //DebugMainFunction="BATTLE_Battling_8";
+ len = strlen( szAllBattleString );
+ //DebugMainFunction="BATTLE_Battling_9";
+ AllSize += len;
+ EntrySort( EntryList, entrynum );
+ //DebugMainFunction="BATTLE_Battling_10";
+ ComboCheck( EntryList, entrynum );
+ //DebugMainFunction="BATTLE_Battling_11";
+ 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;
+
+ szBattleString[0] = 0;
+ pszBattleTop = szBattleString;
+ pszBattleLast = szBattleString+arraysizeof(szBattleString);
+
+ // WON ADD
+ if( CHAR_getFlg( charaindex, CHAR_ISDIE ) != TRUE )
+ BATTLE_StatusSeq( charaindex );
+ //DebugMainFunction="BATTLE_Battling_12";
+#ifdef _OTHER_MAGICSTAUTS
+ BATTLE_MagicStatusSeq( charaindex );
+#endif
+ //DebugMainFunction="BATTLE_Battling_13";
+#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
+ //DebugMainFunction="BATTLE_Battling_14";
+
+ if( BATTLE_CanMoveCheck( charaindex ) == FALSE ){
+ CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_NONE );
+ }
+ //DebugMainFunction="BATTLE_Battling_15";
+ gBattleDamageModyfy = 1.0;
+ gBattleDuckModyfy = 0;
+ gBattleStausChange = -1;
+ gBattleStausTurn = 0;
+ gWeponType = ITEM_FIST;
+ gWeponType = BATTLE_GetWepon( charaindex );
+ //DebugMainFunction="BATTLE_Battling_16";
+#ifdef _PETSKILL_BECOMEFOX
+ if( CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND ) != -1 //DZС
+ || 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
+ //DebugMainFunction="BATTLE_Battling_17";
+#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
+ //DebugMainFunction="BATTLE_Battling_18";
+ 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
+ //DebugMainFunction="BATTLE_Battling_19";
+ sprintf( szWork, "BX|%X|", attackNo);
+ //DebugMainFunction="BATTLE_Battling_20";
+ BATTLESTR_ADD( szWork );
+ //DebugMainFunction="BATTLE_Battling_21";
+ }
+ }
+
+#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:
+ //DebugMainFunction="BATTLE_Battling_22";
+ 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 ){ //DZС겻ʹû
+ 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
+ }
+ //DebugMainFunction="BATTLE_Battling_23";
+ break;
+ case BATTLE_COM_COMBO:
+ //DebugMainFunction="BATTLE_Battling_24";
+ if( ComboCheck2( EntryList, i, entrynum ) == FALSE ){
+ CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_ATTACK );
+ }
+ //DebugMainFunction="BATTLE_Battling_25";
+ break;
+
+ case BATTLE_COM_S_STATUSCHANGE:
+ gBattleStausChange = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3 );
+ gBattleStausTurn = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3 );
+ break;
+
+// case BATTLE_COM_S_GYRATE:
+// gBattleStausChange = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM5 );
+// gBattleStausTurn = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM6 );
+// 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:
+ //DebugMainFunction="BATTLE_Battling_26";
+ BATTLE_Charge( battleindex, attackNo );
+ //DebugMainFunction="BATTLE_Battling_27";
+ break;
+ case BATTLE_COM_S_RENZOKU:
+ attack_max = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3 );
+ gDamageDiv = attack_max;
+ break;
+ case BATTLE_COM_S_ZIYUN1:
+ attack_max = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3 );
+ gDamageDiv = attack_max;
+ gBattleDuckModyfy = CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3 );
+#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;
+ }
+ //DebugMainFunction="BATTLE_Battling_28";
+ BATTLE_TargetListSet( charaindex, attackNo, aDefList );
+ //DebugMainFunction="BATTLE_Battling_29";
+ 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: // ҹ
+ {
+ // ֹͬӻ
+ //DebugMainFunction="BATTLE_Battling_30";
+ defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 );
+ if( BATTLE_CheckSameSide( charaindex, defNo) == 1 ){
+ BATTLE_NoAction( battleindex, attackNo ); break;
+ }
+ //DebugMainFunction="BATTLE_Battling_31";
+ }
+ case BATTLE_COM_S_ENRAGE_PET: // ŭ
+ {
+ //DebugMainFunction="BATTLE_Battling_32";
+ 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);
+ //DebugMainFunction="BATTLE_Battling_33";
+ }
+ 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
+ // ֹͬӻ
+ //DebugMainFunction="BATTLE_Battling_34";
+ defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 );
+ if( BATTLE_CheckSameSide( charaindex, defNo) == 1 ){
+ BATTLE_NoAction( battleindex, attackNo ); break;
+ }
+ //DebugMainFunction="BATTLE_Battling_35";
+ }
+ case BATTLE_COM_S_BLOOD: // Ѫ
+ {
+ //DebugMainFunction="BATTLE_Battling_36";
+ 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
+ //DebugMainFunction="BATTLE_Battling_37";
+#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;
+ }
+ //DebugMainFunction="BATTLE_Battling_38";
+#endif
+ battle_profession_attack_magic_fun(battleindex, attackNo, defNo, charaindex);
+ //DebugMainFunction="BATTLE_Battling_39";
+ //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 );
+ //DebugMainFunction="BATTLE_Battling_40";
+ battle_profession_assist_fun(battleindex, attackNo, defNo, charaindex);
+ //DebugMainFunction="BATTLE_Battling_41";
+ 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 );
+ //DebugMainFunction="BATTLE_Battling_42";
+ if( BATTLE_CheckSameSide( charaindex, defNo) == 1 ){
+ BATTLE_NoAction( battleindex, attackNo );
+ //if( COM == BATTLE_COM_S_TOXIN_WEAPON )
+ //printf("\nbug-ͬӻ");
+ break;
+ }
+ //DebugMainFunction="BATTLE_Battling_43";
+ }
+ 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 );
+ //DebugMainFunction="BATTLE_Battling_44";
+ battle_profession_status_chang_fun(battleindex, attackNo, defNo, charaindex);
+ //DebugMainFunction="BATTLE_Battling_45";
+ //if( COM == BATTLE_COM_S_TOXIN_WEAPON )
+ //printf("\nbug-");
+ //DebugMainFunction="BATTLE_Battling_46";
+ 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:
+ if( COM == BATTLE_COM_S_MIGHTY ){
+ int def_index = -1;
+ int i;
+ defNo = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 );//ȡñߵλ
+ if( BATTLE_TargetCheck(battleindex, defNo) == FALSE
+ || CHAR_getWorkInt( BATTLE_No2Index( battleindex, defNo ), CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_EARTHROUND0 ){
+
+ //һֻ
+ if( defNo < 10 ){
+ for( i=0;i<10;i++ )
+ if( BATTLE_TargetCheck(battleindex, i)
+ && CHAR_getWorkInt( BATTLE_No2Index( battleindex, i ), CHAR_WORKBATTLECOM1 ) != BATTLE_COM_S_EARTHROUND0){
+ defNo = i;
+ break;
+ }
+ }
+ else{
+ for( i=10;i<20;i++ )
+ if( BATTLE_TargetCheck(battleindex, i)
+ && CHAR_getWorkInt( BATTLE_No2Index( battleindex, i ), CHAR_WORKBATTLECOM1 ) != BATTLE_COM_S_EARTHROUND0){
+ defNo = i;
+ break;
+ }
+ }
+ if( BATTLE_TargetCheck(battleindex, defNo) == FALSE
+ || CHAR_getWorkInt( BATTLE_No2Index( battleindex, defNo ), CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_EARTHROUND0 ) {
+ return 0;
+ }
+ }
+ def_index = BATTLE_No2Index( battleindex, defNo );//ȡñߵidx
+
+ // ֹͬӻ
+ //DebugMainFunction="BATTLE_Battling_47";
+ if( BATTLE_CheckSameSide( charaindex, defNo) == 1 ){
+ BATTLE_NoAction( battleindex, attackNo ); break;
+ }
+ //DebugMainFunction="BATTLE_Battling_48";
+ if( !CHAR_CHECKINDEX( def_index ) ) break;
+ //DebugMainFunction="BATTLE_Battling_49";
+ if( PROFESSION_BATTLE_StatusAttackCheck( charaindex, def_index, CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM5), CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM7) ) )
+ CHAR_setWorkInt( def_index, StatusTbl[CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM5)], CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM6));//趨
+ //DebugMainFunction="BATTLE_Battling_50";
+ }
+
+ 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;
+ }
+ //DebugMainFunction="BATTLE_Battling_75";
+ defNo = aDefList[0];
+ }else
+ if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0
+ || defNo == attackNo){
+ BATTLE_NoAction( battleindex, attackNo );
+ break;
+ }
+ //DebugMainFunction="BATTLE_Battling_76";
+ if( COM == BATTLE_COM_S_EARTHROUND0 ){
+ sprintf( szWork, "BI|a%X|", attackNo );
+ //DebugMainFunction="BATTLE_Battling_77";
+ }else {
+#ifdef _FIXBUG_ATTACKBOW
+ if( CHAR_getWorkInt( charaindex, CHAR_WORKITEMMETAMO) > 0 ||
+ CHAR_getWorkInt( charaindex, CHAR_WORKNPCMETAMO) > 0
+ || CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND ) != -1 ){ //DZС
+
+ if( gWeponType == ITEM_BOW || gWeponType == ITEM_BOUNDTHROW ||
+ gWeponType == ITEM_BREAKTHROW || gWeponType == ITEM_BOOMERANG) {
+ CHAR_talkToCli( charaindex, -1, "ʹԶ!!", CHAR_COLORYELLOW);
+ continue;
+ }
+
+ }
+#endif
+ //DebugMainFunction="BATTLE_Battling_78";
+ 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 );
+ //DebugMainFunction="BATTLE_Battling_79";
+ }
+
+#ifdef _SHOOTCHESTNUT // Syu ADD 輼
+ if ( COM == BATTLE_COM_S_ATTSHOOT )
+ sprintf( szWork, "BB|a%X|w0|", attackNo );
+#endif
+ //DebugMainFunction="BATTLE_Battling_80";
+ BATTLESTR_ADD( szWork );
+ //DebugMainFunction="BATTLE_Battling_81";
+ 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 ) ) );
+ //DebugMainFunction="BATTLE_Battling_82";
+ BATTLE_Attack( battleindex, attackNo, defNo );
+ //DebugMainFunction="BATTLE_Battling_83";
+ }
+ Battle_Attack_ReturnData_x.Battle_Attack_ReturnData = 0;
+ }
+#endif
+ //DebugMainFunction="BATTLE_Battling_84";
+ BATTLE_AddProfit( battleindex, aAttackList);
+ //DebugMainFunction="BATTLE_Battling_85";
+ 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;
+ }
+ //DebugMainFunction="BATTLE_Battling_86";
+ ContFlg = BATTLE_Counter(battleindex, attackNoSub, defNoSub );
+ //DebugMainFunction="BATTLE_Battling_87";
+ aAttackList[0] = attackNoSub;
+ aAttackList[1] = -1;
+ BATTLE_AddProfit( battleindex, aAttackList);
+ //DebugMainFunction="BATTLE_Battling_88";
+ }
+ aAttackList[0] = -1;
+ //DebugMainFunction="BATTLE_Battling_89";
+ BATTLESTR_ADD( "FF|" );
+ //DebugMainFunction="BATTLE_Battling_90";
+
+#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 );
+ //DebugMainFunction="BATTLE_Battling_91";
+ BATTLE_MultiList( battleindex, defNo, ToList );
+ //DebugMainFunction="BATTLE_Battling_92";
+ BATTLE_MagicEffect( battleindex, defNo, ToList, 101120, 101750);
+ //DebugMainFunction="BATTLE_Battling_93";
+
+ CHAR_setWorkInt( defindex, CHAR_WORKFOXROUND, pBattle->turn );
+
+ if( CHAR_getInt( defindex, CHAR_RIDEPET) != -1 ) { //Ҫ
+ CHAR_setInt( defindex, CHAR_RIDEPET, -1 );
+ //DebugMainFunction="BATTLE_Battling_94";
+ BATTLE_changeRideImage( defindex );
+ //DebugMainFunction="BATTLE_Battling_95";
+ CHAR_setWorkInt( defindex, CHAR_WORKPETFALL, 1 );
+ }
+
+ CHAR_setInt( defindex, CHAR_BASEIMAGENUMBER, 101749);
+ }
+#endif
+ //DebugMainFunction="BATTLE_Battling_96";
+#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;
+ //DebugMainFunction="BATTLE_Battling_97";
+ int defindex = BATTLE_No2Index( battleindex, defNo );
+ //DebugMainFunction="BATTLE_Battling_98";
+ pszOption = PETSKILL_getChar( CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3 ), PETSKILL_OPTION );
+ //DebugMainFunction="BATTLE_Battling_99";
+ if( pszOption == "\0")
+ sscanf( pszOption, "%d %d %d", &petrate, &pettime, &pigbbi);
+ else
+ petrate = 100, pettime = 60, pigbbi = 100250;
+ //DebugMainFunction="BATTLE_Battling_100";
+ if( rand()%100 < petrate ){
+ CHAR_setWorkInt( defindex, CHAR_WORKITEMMETAMO, 0);//߱ȡ
+ CHAR_setWorkInt( defindex, CHAR_WORKNPCMETAMO, 0 );//NPCȡ
+ CHAR_setWorkInt( defindex, CHAR_WORKFOXROUND, -1);//Ļȡ
+ //DebugMainFunction="BATTLE_Battling_101";
+ BATTLE_MultiList( battleindex, defNo, ToList );
+ //DebugMainFunction="BATTLE_Battling_102";
+ BATTLE_MagicEffect( battleindex, defNo, ToList, 101120, 101750);
+ //DebugMainFunction="BATTLE_Battling_103";
+ if( CHAR_getInt( defindex, CHAR_RIDEPET) != -1 ){ //Ҫ
+ CHAR_setInt( defindex, CHAR_RIDEPET, -1 );
+ //DebugMainFunction="BATTLE_Battling_104";
+ BATTLE_changeRideImage( defindex );
+ //DebugMainFunction="BATTLE_Battling_105";
+ 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);
+ //DebugMainFunction="BATTLE_Battling_106";
+ //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 );
+ //DebugMainFunction="BATTLE_Battling_107";
+ if( defNo < 0 ){
+ defNo = BATTLE_DefaultAttacker( battleindex, 1 - myside );
+ }
+ //DebugMainFunction="BATTLE_Battling_108";
+ if( 0 <= defNo && defNo <= 19 ){
+ defNo /= 5; //
+ }else{
+ BATTLE_NoAction( battleindex, attackNo );
+ break;
+ }
+ //DebugMainFunction="BATTLE_Battling_109";
+ if( (int)(attackNo / 5 ) == defNo ){
+ BATTLE_NoAction( battleindex, attackNo );
+ break;
+ }
+ //DebugMainFunction="BATTLE_Battling_110";
+ {
+ int *pBoomerangTbl = BoomerangVsTbl[defNo];
+ for( k = 0; k < 5; k ++ ){
+ if( BATTLE_TargetCheck( battleindex, pBoomerangTbl[k] ) == FALSE ){
+ continue;
+ }else{
+ break;
+ }
+ }
+ //DebugMainFunction="BATTLE_Battling_111";
+ if( k == 5 ){
+ defNo = BATTLE_DefaultAttacker( battleindex, 1 - myside );
+ if( 0 <= defNo && defNo <= 19 ){
+ defNo /= 5;
+ }else{
+ BATTLE_NoAction( battleindex, attackNo );
+ break;
+ }
+ }
+ //DebugMainFunction="BATTLE_Battling_112";
+ }
+ sprintf( szWork, "BO|a%X|", attackNo );
+ //DebugMainFunction="BATTLE_Battling_113";
+ BATTLESTR_ADD( szWork );
+ //DebugMainFunction="BATTLE_Battling_114";
+ {
+ //DebugMainFunction="BATTLE_Battling_115";
+ int *pBoomerangTbl = BoomerangVsTbl[defNo];
+ //DebugMainFunction="BATTLE_Battling_116";
+ 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;
+ //DebugMainFunction="BATTLE_Battling_117";
+ BATTLESTR_ADD( "FF|" );
+ //DebugMainFunction="BATTLE_Battling_118";
+ break;
+
+ //---------------------------------------------
+ case BATTLE_COM_CAPTURE:
+ if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){
+ BATTLE_NoAction( battleindex, attackNo );
+ break;
+ }
+ //DebugMainFunction="BATTLE_Battling_119";
+ BATTLE_Capture( battleindex, attackNo, defNo );
+ //DebugMainFunction="BATTLE_Battling_120";
+ 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);
+ //DebugMainFunction="BATTLE_Battling_121";
+ BATTLE_MultiList( battleindex, defNo, ToList );
+ //DebugMainFunction="BATTLE_Battling_122";
+ BATTLE_MagicEffect( battleindex, attackNo, ToList, 101120, bk_amn);
+ //DebugMainFunction="BATTLE_Battling_123";
+ }
+ break;
+#endif
+ case BATTLE_COM_GUARD:
+ //DebugMainFunction="BATTLE_Battling_124";
+ BATTLE_Guard( battleindex, attackNo );
+ //DebugMainFunction="BATTLE_Battling_125";
+
+ 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);
+ }
+ }
+ break;
+ case BATTLE_COM_COMPELESCAPE: //ǿ뿪
+ if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPET ){
+ //DebugMainFunction="BATTLE_Battling_126";
+ BATTLE_Escape( battleindex, attackNo, 1);
+ //DebugMainFunction="BATTLE_Battling_127";
+ 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];
+ //DebugMainFunction="BATTLE_Battling_128";
+ snprintf( szWork, sizeof( szWork ), "K%d", CHAR_getInt( charaindex, CHAR_DEFAULTPET ) );
+ //DebugMainFunction="BATTLE_Battling_129";
+ CHAR_sendStatusString( charaindex, szWork );
+ //DebugMainFunction="BATTLE_Battling_130";
+
+ }
+ //DebugMainFunction="BATTLE_Battling_131";
+ BATTLE_PetIn( battleindex, attackNo );
+ //DebugMainFunction="BATTLE_Battling_132";
+ 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 );
+
+ }
+ //DebugMainFunction="BATTLE_Battling_133";
+ BATTLE_PetIn( battleindex, attackNo );
+ //DebugMainFunction="BATTLE_Battling_134";
+ }
+ // shan 2002/01/14 Begin ֻ
+ {
+ int attackindex, petNo;
+
+ attackindex = BATTLE_No2Index( battleindex, attackNo );
+ petNo = CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM2 );
+#ifdef _TRANS_7_COLOR //CFǷٻ
+ if( getpetsummon() == 0 ){
+
+ if( CHAR_getWorkInt(charaindex, CHAR_WORK_PET0_STAT+petNo) != PET_STAT_SELECT)
+ break;
+ }
+#endif
+/* //CAX
+#ifndef _PET_STANDBY
+ if( CHAR_getWorkInt(charaindex, CHAR_WORK_PET0_STAT+petNo) != PET_STAT_SELECT)
+ break;
+#endif
+*/
+ }
+ //DebugMainFunction="BATTLE_Battling_135";
+ // shan End
+ BATTLE_PetOut( battleindex, attackNo );
+ //DebugMainFunction="BATTLE_Battling_136";
+ 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);
+ // жϹ Χ
+ //DebugMainFunction="BATTLE_Battling_137";
+ for(magic_count=0;magic_count= 0 && toindex <= 4)
+ toindex = TargetIndex[magic_count][1];
+ // µǰһ
+ else
+ toindex = TargetIndex[magic_count][1]-1;
+ }
+ break;
+ }
+ }
+ //DebugMainFunction="BATTLE_Battling_138";
+// print("toindex->%d\n",toindex);
+ MAGIC_DirectUse(charaindex,magic,toindex,CHAR_GETWORKINT_HIGH(charaindex,CHAR_WORKBATTLECOM3));
+ //DebugMainFunction="BATTLE_Battling_139";
+ BATTLE_AddProfit( battleindex, aAttackList );
+ //DebugMainFunction="BATTLE_Battling_140";
+ break;
+#endif
+ case BATTLE_COM_JYUJYUTU:
+ //DebugMainFunction="BATTLE_Battling_141";
+ MAGIC_DirectUse(
+ charaindex,
+ CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3 ),
+ CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ),
+ CHAR_GETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3 )
+ );
+ //DebugMainFunction="BATTLE_Battling_142";
+ 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 սɻƷ
+#ifdef _BATTLE_EQUIT_OTHER
+ if(getBattleEquitOther()!=1)
+#endif
+ {
+ 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 ){ //DZС
+
+ 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
+ //DebugMainFunction="BATTLE_Battling_143";
+ CHAR_ItemUse(charaindex,CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM2 ), CHAR_getWorkInt( charaindex, CHAR_WORKBATTLECOM3 ));
+ //DebugMainFunction="BATTLE_Battling_144";
+ if( ITEM_getEquipPlace( charaindex, itemindex ) == CHAR_ARM ){
+ //DebugMainFunction="BATTLE_Battling_145";
+ sprintf( szWork, "BN|a%X|%X|", attackNo,
+ CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER ) );
+ //DebugMainFunction="BATTLE_Battling_146";
+ BATTLESTR_ADD( szWork );
+ //DebugMainFunction="BATTLE_Battling_147";
+#ifdef _PROFESSION_SKILL // WON ADD ְҵ
+ // ר
+ BATTLE_ProfessionStatus_init( battleindex, charaindex );
+#endif
+ //DebugMainFunction="BATTLE_Battling_148";
+ }else{
+ }
+ //DebugMainFunction="BATTLE_Battling_149";
+ 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;
+ }
+ //DebugMainFunction="BATTLE_Battling_150";
+ ContFlg = BATTLE_S_FallGround( battleindex, attackNo, defNo, BATTLE_COM_S_FALLRIDE);
+ //DebugMainFunction="BATTLE_Battling_151";
+ break;
+
+#endif
+#ifdef _PETSKILL_TIMID
+ case BATTLE_COM_S_TIMID:
+ {
+ int skill;
+ //DebugMainFunction="BATTLE_Battling_152";
+ if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){
+ BATTLE_NoAction( battleindex, attackNo );
+ //print("\n BATTLE_NoAction()");
+ break;
+ }
+ //DebugMainFunction="BATTLE_Battling_153";
+ skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3);
+ ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_TIMID, skill);
+ //DebugMainFunction="BATTLE_Battling_154";
+ }
+ break;
+#endif
+#ifdef _PETSKILL_2TIMID
+ case BATTLE_COM_S_2TIMID:
+ {
+ int skill;
+ //DebugMainFunction="BATTLE_Battling_155";
+ if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){
+ BATTLE_NoAction( battleindex, attackNo );
+ //print("\n BATTLE_NoAction()");
+ break;
+ }
+ //DebugMainFunction="BATTLE_Battling_156";
+ if( BATTLE_CheckSameSide( charaindex, defNo) == 1 ) {
+ BATTLE_NoAction( battleindex, attackNo );
+ break;
+ }
+ //DebugMainFunction="BATTLE_Battling_157";
+ skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3);
+ ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_2TIMID, skill);
+ //DebugMainFunction="BATTLE_Battling_158";
+ }
+ break;
+#endif
+
+#ifdef _PETSKILL_PROPERTY
+ case BATTLE_COM_S_PROPERTYSKILL:
+ {
+ int skill;
+ skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3);
+ //DebugMainFunction="BATTLE_Battling_159";
+ BATTLE_S_PetSkillProperty( battleindex, attackNo, COM, skill);
+ //DebugMainFunction="BATTLE_Battling_160";
+ BATTLE_NoAction( battleindex, attackNo );
+ //DebugMainFunction="BATTLE_Battling_161";
+ }
+ break;
+#endif
+
+#ifdef _BATTLE_LIGHTTAKE
+ case BATTLE_COM_S_LIGHTTAKE:
+ {
+ int skill;
+ //DebugMainFunction="BATTLE_Battling_162";
+ if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){
+ BATTLE_NoAction( battleindex, attackNo );
+ //print("\n BATTLE_NoAction()");
+ break;
+ }
+ //DebugMainFunction="BATTLE_Battling_163";
+ skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3);
+ ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_LIGHTTAKE, skill);
+ //DebugMainFunction="BATTLE_Battling_164";
+ }
+ break;
+#endif
+
+#ifdef _SKILL_DAMAGETOHP
+ case BATTLE_COM_S_DAMAGETOHP: //Ѫ
+ {
+ int skill;
+ //DebugMainFunction="BATTLE_Battling_165";
+ if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){
+ BATTLE_NoAction( battleindex, attackNo );
+ //print("\n BATTLE_NoAction()");
+ break;
+ }
+ //DebugMainFunction="BATTLE_Battling_166";
+ skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3);
+ ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_DAMAGETOHP, skill);
+ //DebugMainFunction="BATTLE_Battling_167";
+ }
+ break;
+#endif
+
+#ifdef _PETSKILL_DAMAGETOHP
+ case BATTLE_COM_S_DAMAGETOHP2: //¿(Ѫı)
+ {
+ int skill,attackidxtemp;
+ //DebugMainFunction="BATTLE_Battling_168";
+ attackidxtemp = BATTLE_No2Index( battleindex, attackNo );
+ //DebugMainFunction="BATTLE_Battling_169";
+ if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){
+ BATTLE_NoAction( battleindex, attackNo );
+ //print("\n BATTLE_NoAction()");
+ break;
+ }
+ //DebugMainFunction="BATTLE_Battling_170";
+ skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3);
+ ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_DAMAGETOHP2, skill);
+ //DebugMainFunction="BATTLE_Battling_171";
+ }
+ break;
+#endif
+
+#ifdef _Skill_MPDAMAGE
+ case BATTLE_COM_S_MPDAMAGE: //MP˺
+ {
+ int skill;
+ //DebugMainFunction="BATTLE_Battling_172";
+ if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){
+ BATTLE_NoAction( battleindex, attackNo );
+ //print("\n BATTLE_NoAction()");
+ break;
+ }
+ //DebugMainFunction="BATTLE_Battling_173";
+ skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3);
+ ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_MPDAMAGE, skill);
+ //DebugMainFunction="BATTLE_Battling_174";
+ break;
+ }
+ break;
+#endif
+#ifdef _SKILL_TOOTH
+ case BATTLE_COM_S_TOOTHCRUSHE:
+ {
+ int skill;
+ //DebugMainFunction="BATTLE_Battling_175";
+ if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){
+ BATTLE_NoAction( battleindex, attackNo );
+ //print("\n BATTLE_NoAction()");
+ break;
+ }
+ //DebugMainFunction="BATTLE_Battling_176";
+ skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3);
+ ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_TOOTHCRUSHE, skill);
+ //DebugMainFunction="BATTLE_Battling_177";
+ break;
+ }
+ break;
+#endif
+#ifdef _PSKILL_MODIFY
+ case BATTLE_COM_S_MODIFYATT:
+ {
+ int skill;
+ //DebugMainFunction="BATTLE_Battling_178";
+ if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){
+ BATTLE_NoAction( battleindex, attackNo );
+ //print("\n BATTLE_NoAction()");
+ break;
+ }
+ //DebugMainFunction="BATTLE_Battling_179";
+ skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3);
+ ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_MODIFYATT, skill);
+ //DebugMainFunction="BATTLE_Battling_180";
+ }
+ break;
+#endif
+#ifdef _PSKILL_MDFYATTACK
+ case BATTLE_COM_S_MDFYATTACK:
+ {
+ int skill;
+ //DebugMainFunction="BATTLE_Battling_181";
+ if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){
+ BATTLE_NoAction( battleindex, attackNo );
+ //print("\n BATTLE_NoAction()");
+ break;
+ }
+ //DebugMainFunction="BATTLE_Battling_182";
+ skill = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3);
+ ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_MDFYATTACK, skill);
+ //DebugMainFunction="BATTLE_Battling_183";
+ }
+ break;
+#endif
+
+#ifdef _PETSKILL_TEAR
+ case BATTLE_COM_S_PETSKILLTEAR:
+ {
+ int skill;
+ //DebugMainFunction="BATTLE_Battling_184";
+ if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){
+ BATTLE_NoAction( battleindex, attackNo );
+ //print("\n BATTLE_NoAction()");
+ break;
+ }
+ //DebugMainFunction="BATTLE_Battling_185";
+ skill = CHAR_GETWORKINT_LOW( charaindex, CHAR_WORKBATTLECOM3);
+ ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_PETSKILLTEAR, skill);
+ //DebugMainFunction="BATTLE_Battling_186";
+ }
+ 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 );
+ //DebugMainFunction="BATTLE_Battling_187";
+ ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_SONIC, skill );
+ //DebugMainFunction="BATTLE_Battling_188";
+ if( index2 >= 0 ){
+ if( defNo2 >= 0 ){
+ ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo2, BATTLE_COM_S_SONIC2, skill );
+ }
+ }
+ //DebugMainFunction="BATTLE_Battling_189";
+
+ }
+ 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 );
+ //DebugMainFunction="BATTLE_Battling_190";
+ ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo, BATTLE_COM_S_REGRET, skill );
+ //DebugMainFunction="BATTLE_Battling_191";
+ if( index2 >= 0 ){
+ if( defNo2 >= 0 ){
+ ContFlg = BATTLE_S_AttackDamage( battleindex, attackNo, defNo2, BATTLE_COM_S_REGRET2, skill );
+ }
+ }
+ //DebugMainFunction="BATTLE_Battling_192";
+ }
+ 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);
+ //DebugMainFunction="BATTLE_Battling_193";
+ ContFlg = PETSKILL_MagicStatusChange_Battle( battleindex, attackNo, defNo, skill);
+ //DebugMainFunction="BATTLE_Battling_194";
+ }
+ 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);
+ //DebugMainFunction="BATTLE_Battling_195";
+ ContFlg = PETSKILL_SetDuckChange_Battle( battleindex, attackNo, defNo, skill);
+ //DebugMainFunction="BATTLE_Battling_196";
+ 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);
+ //DebugMainFunction="BATTLE_Battling_197";
+ ContFlg = PETSKILL_SetMagicPet_Battle( battleindex, attackNo, defNo, skill);
+ //DebugMainFunction="BATTLE_Battling_198";
+ break;
+ }
+#endif
+#ifdef _OFFLINE_SYSTEM
+ case BATTLE_COM_S_OFFLINE_RECOVERY:
+ {
+ defNo = CHAR_getWorkInt(charaindex,CHAR_WORKBATTLECOM2);
+ int HP = CHAR_GETWORKINT_LOW(charaindex,CHAR_WORKBATTLECOM3);
+ ContFlg = OFFLINE_MultiRessurect( battleindex, attackNo, defNo, HP, 0);
+ 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;
+ }
+ //DebugMainFunction="BATTLE_Battling_199";
+ ContFlg =BATTLE_E_ENEMYREFILE( battleindex, attackNo, defNo, BATTLE_COM_S_ENEMYRELIFE);
+ //DebugMainFunction="BATTLE_Battling_200";
+ if( ContFlg == FALSE ) {
+ CHAR_setFlg( charaindex, CHAR_ISATTACKED, 1 );
+ ContFlg = BATTLE_Attack( battleindex, attackNo, defNo );
+ BATTLE_AddProfit( battleindex, aAttackList );
+ }
+ //DebugMainFunction="BATTLE_Battling_201";
+ BATTLE_AddProfit( battleindex, aAttackList );
+ //DebugMainFunction="BATTLE_Battling_202";
+ break;
+
+ case BATTLE_COM_S_ENEMYREHP:
+ if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){
+ BATTLE_NoAction( battleindex, attackNo );
+ //print("\n BATTLE_NoAction()");
+ break;
+ }
+ //DebugMainFunction="BATTLE_Battling_203";
+ ContFlg =BATTLE_E_ENEMYREHP( battleindex, attackNo, defNo, BATTLE_COM_S_ENEMYREHP);
+ //DebugMainFunction="BATTLE_Battling_204";
+ if( ContFlg == FALSE ) {
+ CHAR_setFlg( charaindex, CHAR_ISATTACKED, 1 );
+ ContFlg = BATTLE_Attack( battleindex, attackNo, defNo );
+ BATTLE_AddProfit( battleindex, aAttackList );
+ }
+ //DebugMainFunction="BATTLE_Battling_205";
+ BATTLE_AddProfit( battleindex, aAttackList );
+ //DebugMainFunction="BATTLE_Battling_206";
+ break;
+
+ case BATTLE_COM_S_ENEMYHELP:
+ if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){
+ BATTLE_NoAction( battleindex, attackNo );
+ //print("\n BATTLE_NoAction()");
+ break;
+ }
+ //DebugMainFunction="BATTLE_Battling_207";
+ ContFlg =BATTLE_E_ENEMYHELP( battleindex, attackNo, defNo, BATTLE_COM_S_ENEMYREHP);
+ //DebugMainFunction="BATTLE_Battling_208";
+ if( ContFlg == FALSE ) {
+ CHAR_setFlg( charaindex, CHAR_ISATTACKED, 1 );
+ ContFlg = BATTLE_Attack( battleindex, attackNo, defNo );
+ BATTLE_AddProfit( battleindex, aAttackList );
+ }
+ //DebugMainFunction="BATTLE_Battling_209";
+ BATTLE_AddProfit( battleindex, aAttackList );
+ //DebugMainFunction="BATTLE_Battling_210";
+ break;
+#endif
+ case BATTLE_COM_S_GBREAK: //Ƴ
+
+ if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){
+ BATTLE_NoAction( battleindex, attackNo );
+ break;
+ }
+ //DebugMainFunction="BATTLE_Battling_211";
+ ContFlg = BATTLE_S_GBreak( battleindex, attackNo, defNo );
+ //DebugMainFunction="BATTLE_Battling_212";
+ 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;
+ }
+ //DebugMainFunction="BATTLE_Battling_213";
+ ContFlg = BATTLE_S_GBreak2( battleindex, attackNo, defNo );
+ //DebugMainFunction="BATTLE_Battling_214";
+ 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;
+ }
+ //DebugMainFunction="BATTLE_Battling_215";
+ ContFlg = BATTLE_S_Sacrifice( battleindex, attackNo, defNo );
+ //DebugMainFunction="BATTLE_Battling_216";
+ 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);
+ //DebugMainFunction="BATTLE_Battling_217";
+ ContFlg = BATTLE_S_Refresh( battleindex, attackNo, defNo ,array);
+ //DebugMainFunction="BATTLE_Battling_218";
+ }
+ 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);
+ //DebugMainFunction="BATTLE_Battling_219";
+ ContFlg = BATTLE_S_Weaken( battleindex, attackNo, defNo ,array);
+ //DebugMainFunction="BATTLE_Battling_220";
+ }
+ 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 );
+ // DebugMainFunction="BATTLE_Battling_221";
+ ContFlg = BATTLE_S_Deeppoison( battleindex, attackNo, defNo ,array);
+ //DebugMainFunction="BATTLE_Battling_222";
+ }
+ 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 );
+ //DebugMainFunction="BATTLE_Battling_223";
+ ContFlg = BATTLE_S_Barrier( battleindex, attackNo, defNo ,array);
+ //DebugMainFunction="BATTLE_Battling_224";
+ }
+ 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 );
+ //DebugMainFunction="BATTLE_Battling_225";
+ ContFlg = BATTLE_S_Nocast( battleindex, attackNo, defNo ,array);
+ //DebugMainFunction="BATTLE_Battling_226";
+ }
+ 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);
+ //DebugMainFunction="BATTLE_Battling_227";
+ ContFlg = BATTLE_S_Roar( battleindex, attackNo, defNo ,array);
+ //DebugMainFunction="BATTLE_Battling_228";
+ }
+ 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);
+ //DebugMainFunction="BATTLE_Battling_229";
+ BATTLE_Abduct( battleindex, attackNo, defNo, array);
+ //DebugMainFunction="BATTLE_Battling_230";
+ }
+ 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;
+ }
+
+ // ټ
+ //DebugMainFunction="BATTLE_Battling_231";
+ BATTLE_StatusSeq( EntryList[i].charaindex );
+ //DebugMainFunction="BATTLE_Battling_232";
+#ifdef _OTHER_MAGICSTAUTS
+ BATTLE_MagicStatusSeq( EntryList[i].charaindex );
+#endif
+ //DebugMainFunction="BATTLE_Battling_233";
+ // ئ
+ 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" );
+ }
+ //DebugMainFunction="BATTLE_Battling_234";
+ sprintf( szWork, "BY|r%X|", defNo );
+ //DebugMainFunction="BATTLE_Battling_235";
+ BATTLESTR_ADD( szWork );
+ //DebugMainFunction="BATTLE_Battling_236";
+ BATTLE_Combo( battleindex, aAttackList, defNo );
+ //DebugMainFunction="BATTLE_Battling_237";
+#ifdef _Item_ReLifeAct
+ BATTLE_AddProfit( battleindex, aAttackList );
+#endif
+ //DebugMainFunction="BATTLE_Battling_238";
+ // FF ëȹ
+ BATTLESTR_ADD( "FF|" );
+ //DebugMainFunction="BATTLE_Battling_239";
+ break;
+
+ //---------------------------------------------
+ case BATTLE_COM_WAIT:
+ case BATTLE_COM_NONE:
+ BATTLE_NoAction( battleindex, attackNo );
+ break;
+
+ //---------------------------------------------
+ case BATTLE_COM_S_EARTHROUND1:
+ //DebugMainFunction="BATTLE_Battling_240";
+ BATTLE_EarthRoundHide( battleindex, attackNo );
+ //DebugMainFunction="BATTLE_Battling_241";
+ break;
+
+ //---------------------------------------------
+ case BATTLE_COM_S_LOSTESCAPE:
+ //DebugMainFunction="BATTLE_Battling_242";
+ BATTLE_LostEscape( battleindex, attackNo );
+ //DebugMainFunction="BATTLE_Battling_243";
+ break;
+
+ case BATTLE_COM_S_STEAL:
+ if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){
+ BATTLE_NoAction( battleindex, attackNo );
+ break;
+ }
+ //DebugMainFunction="BATTLE_Battling_244";
+ BATTLE_Steal( battleindex, attackNo, defNo );
+ //DebugMainFunction="BATTLE_Battling_245";
+ break;
+
+#ifdef _BATTLESTEAL_FIX
+ case BATTLE_COM_S_STEALMONEY:
+ if( (defNo = BATTLE_TargetAdjust( battleindex, charaindex, myside )) < 0 ){
+ BATTLE_NoAction( battleindex, attackNo );
+ break;
+ }
+ //DebugMainFunction="BATTLE_Battling_246";
+ BATTLE_StealMoney( battleindex, attackNo, defNo) ;
+ //DebugMainFunction="BATTLE_Battling_247";
+ break;
+#endif
+ case BATTLE_COM_S_NOGUARD:
+ BATTLE_NoAction( battleindex, attackNo );
+ break;
+ case BATTLE_COM_S_CHARGE:
+ //DebugMainFunction="BATTLE_Battling_248";
+ sprintf( szWork, "bt|%x|", attackNo );
+ //DebugMainFunction="BATTLE_Battling_249";
+ BATTLESTR_ADD( szWork );
+ //DebugMainFunction="BATTLE_Battling_250";
+ break;
+#ifdef _PETSKILL_LER
+ case BATTLE_COM_S_BAT_FLY:
+ {
+ if((defNo = BATTLE_TargetAdjust(battleindex,charaindex,myside)) < 0){
+ BATTLE_NoAction(battleindex,attackNo);
+ break;
+ }
+ //DebugMainFunction="BATTLE_Battling_251";
+ BATTLE_BatFly(battleindex,attackNo,myside);
+ //DebugMainFunction="BATTLE_Battling_252";
+ }
+ break;
+ case BATTLE_COM_S_DIVIDE_ATTACK:
+ {
+ if((defNo = BATTLE_TargetAdjust(battleindex,charaindex,myside)) < 0){
+ BATTLE_NoAction(battleindex,attackNo);
+ break;
+ }
+ //DebugMainFunction="BATTLE_Battling_253";
+ BATTLE_DivideAttack(battleindex,attackNo,myside);
+ //DebugMainFunction="BATTLE_Battling_254";
+ }
+ break;
+#endif
+#ifdef _PETSKILL_BATTLE_MODEL
+ case BATTLE_COM_S_BATTLE_MODEL:
+ //DebugMainFunction="BATTLE_Battling_255";
+ BATTLE_BattleModel(battleindex,attackNo,myside);
+ //DebugMainFunction="BATTLE_Battling_256";
+ break;
+#endif
+ //---------------------------------------------
+ default:
+ //print( "\nerr:ֵ(%d:%d:%s)\n", charaindex, COM,
+ //CHAR_getUseName( charaindex ) );
+ //DebugMainFunction="BATTLE_Battling_257";
+ sprintf( szWork, "bg|%x|", attackNo );
+ //DebugMainFunction="BATTLE_Battling_258";
+ BATTLESTR_ADD( szWork );
+ //DebugMainFunction="BATTLE_Battling_259";
+ 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
+ if(CHAR_getWorkInt(charaindex,CHAR_WORKPETSKILLBT)==1){
+ CHAR_setWorkInt(charaindex,CHAR_WORKPETSKILLBT,0);
+ }
+//#ifdef _PETSKILL_NONO_FIX
+// if(CHAR_getWorkInt(charaindex,CHAR_WORKLISTPAGE)==1 && CHAR_getInt(charaindex,CHAR_WHICHTYPE)==CHAR_TYPEPET){
+// CHAR_setWorkInt(charaindex,CHAR_WORKLISTPAGE,0);
+// }
+//#endif
+#ifdef _WARNPC_CTRL
+ if(CHAR_getWorkInt(charaindex,CHAR_WORKNPCENEMYBATTLETIME)>0){
+ time_t timep;
+ struct tm *p;
+ time(&timep);
+ p=localtime(&timep); /*ȡõʱ*/
+ timep = mktime(p);
+ if(CHAR_getWorkInt(charaindex,CHAR_WORKNPCENEMYBATTLETIME)>=timep){
+ CHAR_talkToCli( charaindex,-1,"ս",CHAR_COLORYELLOW);
+ CONNECT_setCloseRequest( getfdFromCharaIndex( charaindex ) , 1 );
+ //CONNECT_endOne_debug(getfdFromCharaIndex(charaindex));
+ //CHAR_setInt(charaindex,CHAR_MP,0);
+ }
+ if(CHAR_getWorkInt(charaindex,CHAR_WORKNPCENEMYBATTLETIME)==1)
+ CHAR_setWorkInt(charaindex,CHAR_WORKNPCENEMYBATTLETIME,timep+CHAR_getWorkInt(charaindex,CHAR_WORKNPCENEMYTIME));
+ else
+ CHAR_setWorkInt(charaindex,CHAR_WORKNPCENEMYBATTLETIME,0);
+ }
+#endif
+#ifdef _PETSKILL_BECOMEFOX // жĻǷѵָĻغ
+ //if(CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER)==101749) //ͼжϵĻ,˱ʱ,ᱻԶĻȥ
+ if( CHAR_getWorkInt( charaindex, CHAR_WORKFOXROUND ) != -1 ) //DZС
+ {
+ 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 ظļ
+ //DebugMainFunction="BATTLE_Battling_260";
+ sprintf( szWork, "W%d", CHAR_getInt( BATTLE_No2Index( battleindex, toNo ), CHAR_DEFAULTPET ) );
+ //DebugMainFunction="BATTLE_Battling_261";
+ CHAR_sendStatusString( BATTLE_No2Index( battleindex, toNo ), szWork );
+ //DebugMainFunction="BATTLE_Battling_262";
+ }
+ }
+#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 ){//ؽ
+ //DebugMainFunction="BATTLE_Battling_263";
+ boundary_turn = GETLOWVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXEARTHAT_BOUNDARY ) ) - 1;
+ //DebugMainFunction="BATTLE_Battling_264";
+// 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 ){//ˮ
+ //DebugMainFunction="BATTLE_Battling_265";
+ boundary_turn = GETLOWVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXWATERAT_BOUNDARY ) ) - 1;
+ //DebugMainFunction="BATTLE_Battling_266";
+// 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) );
+ //DebugMainFunction="BATTLE_Battling_267";
+ }
+ if( fire_boundary > 0 ){//
+ //DebugMainFunction="BATTLE_Battling_268";
+ boundary_turn = GETLOWVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXFIREAT_BOUNDARY ) ) - 1;
+// print("\n:%d ",boundary_turn );
+ //DebugMainFunction="BATTLE_Battling_269";
+ 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 ){//
+ //DebugMainFunction="BATTLE_Battling_270";
+ boundary_turn = GETLOWVALUE( CHAR_getWorkInt( charaindex, CHAR_WORKFIXWINDAT_BOUNDARY ) ) - 1;
+// print("\n:%d ",boundary_turn );
+ //DebugMainFunction="BATTLE_Battling_271";
+ 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) );
+ //DebugMainFunction="BATTLE_Battling_272";
+ }
+ 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 );
+ //DebugMainFunction="BATTLE_Battling_273";
+ BATTLESTR_ADD( szWork );
+ //DebugMainFunction="BATTLE_Battling_274";
+ BATTLESTR_ADD( "FF|" );
+ //DebugMainFunction="BATTLE_Battling_275";
+ }
+ }
+#endif
+
+#ifdef _Item_ReLifeAct
+ {
+ //pEntry
+ int k, userindex=-1;
+ // if( BattleArray[ battleindex].type != BATTLE_TYPE_P_vs_P){
+ for( k=0; k<20; k++) {
+ //DebugMainFunction="BATTLE_Battling_276";
+ userindex = BATTLE_getBattleDieIndex( battleindex, k);
+ //DebugMainFunction="BATTLE_Battling_277";
+ 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 ) {
+ //DebugMainFunction="BATTLE_Battling_278";
+ CHECK_ITEM_RELIFE( battleindex, userindex);
+ //DebugMainFunction="BATTLE_Battling_279";
+ }
+#ifdef _LOSE_FINCH_
+ else if( CHAR_getInt( userindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ){
+ //DebugMainFunction="BATTLE_Battling_280";
+ CHECK_PET_RELIFE( battleindex, userindex);
+ //DebugMainFunction="BATTLE_Battling_281";
+ }
+#endif
+ }
+ }
+#endif
+ //DebugMainFunction="BATTLE_Battling_282";
+ BATTLESTR_ADD( szBadStatusString );
+ //DebugMainFunction="BATTLE_Battling_283";
+ BATTLE_AddProfit( battleindex, aAttackList );//ȡþֵ
+ //DebugMainFunction="BATTLE_Battling_284";
+ len = pszBattleTop - szBattleString;
+ if( AllSize + len >= sizeof( szAllBattleString ) - 1 ){
+ // ƥئ
+ }else{
+ //DebugMainFunction="BATTLE_Battling_285";
+ memcpy( szAllBattleString+AllSize, szBattleString, len );
+ //DebugMainFunction="BATTLE_Battling_286";
+ szAllBattleString[AllSize+len] = 0;// NULL ë
+ AllSize += len;
+ }
+ //DebugMainFunction="BATTLE_Battling_287";
+ if( BATTLE_CountAlive( battleindex, 0 ) == 0 || BATTLE_CountAlive( battleindex, 1 ) == 0 ) {
+ break;
+ }
+ //DebugMainFunction="BATTLE_Battling_288";
+ }
+#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){
+ //DebugMainFunction="BATTLE_Battling_289";
+ BATTLE_LerChange(battleindex,dieindex,i);
+ //DebugMainFunction="BATTLE_Battling_290";
+ }
+ }
+ }
+#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 );
+ //DebugMainFunction="BATTLE_Battling_291";
+ BATTLESTR_ADD( "BV|15|0|" );
+ //DebugMainFunction="BATTLE_Battling_292";
+ }
+ }
+ //DebugMainFunction="BATTLE_Battling_293";
+ strncat( szAllBattleString, szBattleString, sizeof( szAllBattleString ) );
+ //DebugMainFunction="BATTLE_Battling_294";
+ 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;
+ //DebugMainFunction="BATTLE_Battling_295";
+ BATTLE_CommandSend( charaindex, szAllBattleString );
+ //DebugMainFunction="BATTLE_Battling_296";
+ }
+ pWatchBattle->mode = BATTLE_MODE_WATCHAFTER;
+ }
+ //DebugMainFunction="BATTLE_Battling_297";
+ 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;
+ }
+#ifdef _ALLBLUES_LUA_1_2
+ else{
+ if(RunItemDieReLifeEvent(toindex, itemindex, i) == TRUE)
+ return TRUE;
+ }
+#endif
+ }
+
+ 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=0add_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 == "\0" ) 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
+
+#ifdef _FM_NPC_LOOK_WAR
+int SearchFmWarRandIndex(int charaindex,int fmwarfloor)
+{
+ int i=1,j,fmwarindex;
+ int bindex[100];
+ bindex[0]=-1;
+ for( j = 0; j < BATTLE_battlenum; j ++ ){
+ if( BattleArray[j].use == FALSE ){
+ continue;
+ }else{
+ if(BattleArray[j].floor!=fmwarfloor){
+ continue;
+ }else{
+ bindex[i-1]=j;
+ i++;
+ continue;
+ }
+ }
+ }
+ if(bindex[0]>-1){
+ fmwarindex = bindex[RAND(1,i)-1];
+ if(BATTLE_CHECKINDEX(fmwarindex)==FALSE)
+ return -1;
+ else{
+ if(BattleArray[fmwarindex].floor!=fmwarfloor)
+ return -1;
+ if(BATTLE_CreateForWatcher( charaindex, fmwarindex )==0){
+ int fd;
+ if( ( fd = getfdFromCharaIndex(charaindex) ) != -1 ){
+ lssproto_EN_send( fd, BattleArray[fmwarindex].type, BattleArray[fmwarindex].field_no );
+ }
+ char szBuffer[256];
+ sprintf( szBuffer, "BP|%X|%X|%X",
+ 20, BP_FLG_JOIN, CHAR_getInt(charaindex, CHAR_MP ) );
+ BATTLE_CommandSend( charaindex, szBuffer );
+ return 0;
+ }
+ }
+ }
+ return -1;
+}
+
+char* SearchFmWar(int charaindex,int fmwarselect)
+{
+ int fmlistpage = CHAR_getWorkInt(charaindex,CHAR_WORKLISTPAGE);
+ int fmwarfloor = -1;
+ switch(fmwarselect){
+ case 1:
+ fmwarfloor=1042;
+ break;
+ case 2:
+ fmwarfloor=2032;
+ break;
+ case 3:
+ fmwarfloor=3032;
+ break;
+ case 4:
+ fmwarfloor=4032;
+ break;
+ case 5:
+ fmwarfloor=20000;
+ break;
+ case 6:
+ fmwarfloor=51000;
+ break;
+ default:
+ break;
+ }
+ if(fmlistpage>0){
+ if(fmwarfloor == 1042 && fmlistpage*6+1-6<=afmwarnum){
+ int i=fmlistpage*6+1-6+1;
+ char fmwarbuff[1024];
+ sprintf(fmwarbuff,"2\n ѡҪսĶ项\nӳơ֣ӡӳ");
+ char name1[64],name2[64],newname1[64],fmwarindexbuf[32];
+ memset(newname1, 0, sizeof(newname1));
+ int fmwarindex = -1;
+ for(;i<=fmlistpage*6+1;i++){
+ memset(newname1, 0, sizeof(newname1));
+ if(getStringFromIndexWithDelim( afmwar, ",", i, fmwarindexbuf, sizeof(fmwarindexbuf))==FALSE)
+ break;
+ if(strlen(fmwarindexbuf)<1)
+ break;
+ fmwarindex = atoi(fmwarindexbuf);
+ strcpy(name1,BattleArray[fmwarindex].leadername);
+ strcpy(name2,BattleArray[fmwarindex].rivalname);
+ int namelen1 = strlen(name1);
+ int j;
+ for(j=0;j<16-namelen1;j++){
+ if(j==0)
+ strcpy(newname1," ");
+ else
+ strcat(newname1," ");
+ }
+ if(strlen(newname1)<1)
+ sprintf(fmwarbuff,"%s\n%s ֣ %s",fmwarbuff,name1,name2);
+ else
+ sprintf(fmwarbuff,"%s\n%s%s ֣ %s",fmwarbuff,newname1,name1,name2);
+ }
+ return fmwarbuff;
+ }else if(fmwarfloor == 2032 && fmlistpage*6+1-6<=bfmwarnum){
+ int i=fmlistpage*6+1-6+1;
+ char fmwarbuff[1024];
+ sprintf(fmwarbuff,"2\n ѡҪսĶ项\nӳơ֣ӡӳ");
+ char name1[64],name2[64],newname1[64],fmwarindexbuf[32];
+ memset(newname1, 0, sizeof(newname1));
+ int fmwarindex = -1;
+ for(;i<=fmlistpage*6+1;i++){
+ memset(newname1, 0, sizeof(newname1));
+ if(getStringFromIndexWithDelim( bfmwar, ",", i, fmwarindexbuf, sizeof(fmwarindexbuf))==FALSE)
+ break;
+ if(strlen(fmwarindexbuf)<1)
+ break;
+ fmwarindex = atoi(fmwarindexbuf);
+ strcpy(name1,BattleArray[fmwarindex].leadername);
+ strcpy(name2,BattleArray[fmwarindex].rivalname);
+ int namelen1 = strlen(name1);
+ int j;
+ for(j=0;j<16-namelen1;j++){
+ if(j==0)
+ strcpy(newname1," ");
+ else
+ strcat(newname1," ");
+ }
+ if(strlen(newname1)<1)
+ sprintf(fmwarbuff,"%s\n%s ֣ %s",fmwarbuff,name1,name2);
+ else
+ sprintf(fmwarbuff,"%s\n%s%s ֣ %s",fmwarbuff,newname1,name1,name2);
+ }
+ return fmwarbuff;
+ }else if(fmwarfloor == 3032 && fmlistpage*6+1-6<=cfmwarnum){
+ int i=fmlistpage*6+1-6+1;
+ char fmwarbuff[1024];
+ sprintf(fmwarbuff,"2\n ѡҪսĶ项\nӳơ֣ӡӳ");
+ char name1[64],name2[64],newname1[64],fmwarindexbuf[32];
+ memset(newname1, 0, sizeof(newname1));
+ int fmwarindex = -1;
+ for(;i<=fmlistpage*6+1;i++){
+ memset(newname1, 0, sizeof(newname1));
+ if(getStringFromIndexWithDelim( cfmwar, ",", i, fmwarindexbuf, sizeof(fmwarindexbuf))==FALSE)
+ break;
+ if(strlen(fmwarindexbuf)<1)
+ break;
+ fmwarindex = atoi(fmwarindexbuf);
+ strcpy(name1,BattleArray[fmwarindex].leadername);
+ strcpy(name2,BattleArray[fmwarindex].rivalname);
+ int namelen1 = strlen(name1);
+ int j;
+ for(j=0;j<16-namelen1;j++){
+ if(j==0)
+ strcpy(newname1," ");
+ else
+ strcat(newname1," ");
+ }
+ if(strlen(newname1)<1)
+ sprintf(fmwarbuff,"%s\n%s ֣ %s",fmwarbuff,name1,name2);
+ else
+ sprintf(fmwarbuff,"%s\n%s%s ֣ %s",fmwarbuff,newname1,name1,name2);
+ }
+ return fmwarbuff;
+ }else if(fmwarfloor == 4032 && fmlistpage*6+1-6<=dfmwarnum){
+ int i=fmlistpage*6+1-6+1;
+ char fmwarbuff[1024];
+ sprintf(fmwarbuff,"2\n ѡҪսĶ项\nӳơ֣ӡӳ");
+ char name1[64],name2[64],newname1[64],fmwarindexbuf[32];
+ memset(newname1, 0, sizeof(newname1));
+ int fmwarindex = -1;
+ for(;i<=fmlistpage*6+1;i++){
+ memset(newname1, 0, sizeof(newname1));
+ if(getStringFromIndexWithDelim( dfmwar, ",", i, fmwarindexbuf, sizeof(fmwarindexbuf))==FALSE)
+ break;
+ if(strlen(fmwarindexbuf)<1)
+ break;
+ fmwarindex = atoi(fmwarindexbuf);
+ strcpy(name1,BattleArray[fmwarindex].leadername);
+ strcpy(name2,BattleArray[fmwarindex].rivalname);
+ int namelen1 = strlen(name1);
+ int j;
+ for(j=0;j<16-namelen1;j++){
+ if(j==0)
+ strcpy(newname1," ");
+ else
+ strcat(newname1," ");
+ }
+ if(strlen(newname1)<1)
+ sprintf(fmwarbuff,"%s\n%s ֣ %s",fmwarbuff,name1,name2);
+ else
+ sprintf(fmwarbuff,"%s\n%s%s ֣ %s",fmwarbuff,newname1,name1,name2);
+ }
+ return fmwarbuff;
+ }else if(fmwarfloor == 20000 && fmlistpage*6+1-6<=efmwarnum){
+ int i=fmlistpage*6+1-6+1;
+ char fmwarbuff[1024];
+ sprintf(fmwarbuff,"2\n ѡҪսĶ项\nӳơ֣ӡӳ");
+ char name1[64],name2[64],newname1[64],fmwarindexbuf[32];
+ memset(newname1, 0, sizeof(newname1));
+ int fmwarindex = -1;
+ for(;i<=fmlistpage*6+1;i++){
+ memset(newname1, 0, sizeof(newname1));
+ if(getStringFromIndexWithDelim( efmwar, ",", i, fmwarindexbuf, sizeof(fmwarindexbuf))==FALSE)
+ break;
+ if(strlen(fmwarindexbuf)<1)
+ break;
+ fmwarindex = atoi(fmwarindexbuf);
+ strcpy(name1,BattleArray[fmwarindex].leadername);
+ strcpy(name2,BattleArray[fmwarindex].rivalname);
+ int namelen1 = strlen(name1);
+ int j;
+ for(j=0;j<16-namelen1;j++){
+ if(j==0)
+ strcpy(newname1," ");
+ else
+ strcat(newname1," ");
+ }
+ if(strlen(newname1)<1)
+ sprintf(fmwarbuff,"%s\n%s ֣ %s",fmwarbuff,name1,name2);
+ else
+ sprintf(fmwarbuff,"%s\n%s%s ֣ %s",fmwarbuff,newname1,name1,name2);
+ }
+ return fmwarbuff;
+ }else if(fmwarfloor == 51000 && fmlistpage*6+1-6<=ffmwarnum){
+ int i=fmlistpage*6+1-6+1;
+ char fmwarbuff[1024];
+ sprintf(fmwarbuff,"2\n ѡҪսĶ项\nӳơ֣ӡӳ");
+ char name1[64],name2[64],newname1[64],fmwarindexbuf[32];
+ memset(newname1, 0, sizeof(newname1));
+ int fmwarindex = -1;
+ for(;i<=fmlistpage*6+1;i++){
+ memset(newname1, 0, sizeof(newname1));
+ if(getStringFromIndexWithDelim( ffmwar, ",", i, fmwarindexbuf, sizeof(fmwarindexbuf))==FALSE)
+ break;
+ if(strlen(fmwarindexbuf)<1)
+ break;
+ fmwarindex = atoi(fmwarindexbuf);
+ strcpy(name1,BattleArray[fmwarindex].leadername);
+ strcpy(name2,BattleArray[fmwarindex].rivalname);
+ int namelen1 = strlen(name1);
+ int j;
+ for(j=0;j<16-namelen1;j++){
+ if(j==0)
+ strcpy(newname1," ");
+ else
+ strcat(newname1," ");
+ }
+ if(strlen(newname1)<1)
+ sprintf(fmwarbuff,"%s\n%s ֣ %s",fmwarbuff,name1,name2);
+ else
+ sprintf(fmwarbuff,"%s\n%s%s ֣ %s",fmwarbuff,newname1,name1,name2);
+ }
+ return fmwarbuff;
+ }
+ }
+ return "err";
+}
+
+int LookFmWarIndex(int charaindex,int fmwarselect)
+{
+ int listselect = CHAR_getWorkInt(charaindex,CHAR_WORKLISTSELECT);
+ if(listselect<1 || listselect>6)
+ return -1;
+ int fmwarindex = -1;
+ char fmwarindexbuf[64];
+ if(listselect == 1){
+ if(getStringFromIndexWithDelim( afmwar, ",", CHAR_getWorkInt(charaindex,CHAR_WORKLISTPAGE)*6+1-6+fmwarselect, fmwarindexbuf, sizeof(fmwarindexbuf))==FALSE)
+ return -1;
+ fmwarindex = atoi(fmwarindexbuf);
+ }else if(listselect == 2){
+ if(getStringFromIndexWithDelim( bfmwar, ",", CHAR_getWorkInt(charaindex,CHAR_WORKLISTPAGE)*6+1-6+fmwarselect, fmwarindexbuf, sizeof(fmwarindexbuf))==FALSE)
+ return -1;
+ fmwarindex = atoi(fmwarindexbuf);
+ }else if(listselect == 3){
+ if(getStringFromIndexWithDelim( cfmwar, ",", CHAR_getWorkInt(charaindex,CHAR_WORKLISTPAGE)*6+1-6+fmwarselect, fmwarindexbuf, sizeof(fmwarindexbuf))==FALSE)
+ return -1;
+ fmwarindex = atoi(fmwarindexbuf);
+ }else if(listselect == 4){
+ if(getStringFromIndexWithDelim( dfmwar, ",", CHAR_getWorkInt(charaindex,CHAR_WORKLISTPAGE)*6+1-6+fmwarselect, fmwarindexbuf, sizeof(fmwarindexbuf))==FALSE)
+ return -1;
+ fmwarindex = atoi(fmwarindexbuf);
+ }else if(listselect == 5){
+ if(getStringFromIndexWithDelim( efmwar, ",", CHAR_getWorkInt(charaindex,CHAR_WORKLISTPAGE)*6+1-6+fmwarselect, fmwarindexbuf, sizeof(fmwarindexbuf))==FALSE)
+ return -1;
+ fmwarindex = atoi(fmwarindexbuf);
+ }else if(listselect == 6){
+ if(getStringFromIndexWithDelim( ffmwar, ",", CHAR_getWorkInt(charaindex,CHAR_WORKLISTPAGE)*6+1-6+fmwarselect, fmwarindexbuf, sizeof(fmwarindexbuf))==FALSE)
+ return -1;
+ fmwarindex = atoi(fmwarindexbuf);
+ }
+
+ if(BATTLE_CHECKINDEX(fmwarindex)==FALSE)
+ return -1;
+ if(BATTLE_CreateForWatcher( charaindex, fmwarindex )==0){
+ int fd;
+ if( ( fd = getfdFromCharaIndex(charaindex) ) != -1 ){
+ lssproto_EN_send( fd, BattleArray[fmwarindex].type, BattleArray[fmwarindex].field_no );
+ }
+ char szBuffer[256];
+ sprintf( szBuffer, "BP|%X|%X|%X",
+ 20, BP_FLG_JOIN, CHAR_getInt(charaindex, CHAR_MP ) );
+ BATTLE_CommandSend( charaindex, szBuffer );
+ return 0;
+ }
+ return -1;
+}
+#endif
+
+#ifdef _ALLBLUES_LUA_1_4
+INLINE BOOL BATTLE_setLUAFunction( int battleindex, int functype, lua_State *L, const char *luafunctable)
+{
+ if( !BATTLE_CHECKINDEX(battleindex) )return FALSE;
+
+ if( functype < 0 || functype >= BATTLE_FUNCTABLENUM )return FALSE;
+
+ BattleArray[battleindex].lua[functype] = L;
+ BattleArray[battleindex].luafunctable[functype] = allocateMemory( strlen(luafunctable) );
+ memset(BattleArray[battleindex].luafunctable[functype], 0, strlen(luafunctable));
+ strcpy(BattleArray[battleindex].luafunctable[functype], luafunctable);
+
+ return TRUE;
+}
+
+INLINE lua_State *BATTLE_getLUAFunction( int battleindex, int functype)
+{
+
+ if( !BATTLE_CHECKINDEX(battleindex) )return NULL;
+
+ if( functype < 0 || functype >= BATTLE_FUNCTABLENUM )
+ return NULL;
+
+ if(BattleArray[battleindex].lua[functype] == NULL){
+ return NULL;
+ }
+
+ lua_getglobal( BattleArray[battleindex].lua[functype], BattleArray[battleindex].luafunctable[functype]);
+ return BattleArray[battleindex].lua[functype];
+}
+#endif
+
+int BATTLE_getType( int battleindex )
+{
+ if(battleindex>=BATTLE_battlenum || battleindex<0 )return -1;
+
+ return BattleArray[battleindex].type;
+}
+
+#ifdef _BATTLE_TIMESPEED
+int BATTLE_getCreateTime( int battleindex )
+{
+ if(battleindex>=BATTLE_battlenum || battleindex<0 )return -1;
+
+ return BattleArray[battleindex].CreateTime;
+}
+#endif
+
+int BATTLE_getBattleFloor( int battleindex )
+{
+ if(battleindex>=BATTLE_battlenum || battleindex<0 )return -1;
+
+ return BattleArray[battleindex].BattleFloor;
+}
+
+
+
+void Enemy_setStayLoop(int charaindex)
+{
+ int fd = getfdFromCharaIndex( charaindex );
+ setStayEncount(fd);
+ {
+ 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, getOfflineBattleTime());
+ CHAR_constructFunctable( charaindex);
+ }
+}
diff --git a/battle/battle_ai.c b/battle/battle_ai.c
new file mode 100644
index 0000000..4795efc
--- /dev/null
+++ b/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/battle/battle_command.c b/battle/battle_command.c
new file mode 100644
index 0000000..e7b1605
--- /dev/null
+++ b/battle/battle_command.c
@@ -0,0 +1,1071 @@
+#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_WORKDBATTLEESCAPE,1 );
+ 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 ){ //DZС겻ʹû
+ 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
+#ifndef _PET_STANDBY
+ if( iNum >= 0) {
+ if( ! (CHAR_getWorkInt( charaindex, CHAR_WORKSTANDBYPET) & ( 1 << iNum)) ) {
+ //print("\n ķ!гǴ!!:%s ", CHAR_getChar( charaindex, CHAR_CDKEY) );
+ iNum = -1;
+ }
+ }
+#endif
+#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="\0";
+ int magic_array = -1;
+ magic_array = MAGIC_getMagicArray( magicindex );
+ magicarg = MAGIC_getChar( magic_array, MAGIC_OPTION );
+ if( magicarg != "\0" && 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
+ CONNECT_setCloseRequest( fd , 1 );
+#endif
+ return;
+ }
+#ifndef _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ְҵʧ!!\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
+ CONNECT_setCloseRequest( fd , 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
+ CONNECT_setCloseRequest_debug( fd , 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 ||
+ CHAR_getInt( pindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYERNPC ||
+ CHAR_getInt( pindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYERPETNPC )
+ {
+ 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;
+}
+
+
+
+
+
+//*******************************************************
+//
+// PѨëͷʧ˪
+//
+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
+ {
+/*
+ ÿ,ÿ~~~~~~~
+ qTTr
+ qsU
+ tѨTѨs±
+*/
+ char msg[32]={0};
+ //print("\nid:%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 // Ļijļ
+ //if( CHAR_getInt( pindex, CHAR_BASEIMAGENUMBER) == 101749 ){
+ if( CHAR_getWorkInt( pindex, CHAR_WORKFOXROUND ) != -1 ){ //DZС
+ 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;
+}
+
+// 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)
+// strcpysafe( cdkey,sizeof(cdkey), CHAR_getChar( charaindex, CHAR_CDKEY));
+// else
+// strcpysafe( cdkey,sizeof(cdkey), CHAR_getChar( charaindex, CHAR_OWNERCDKEY) );
+
+// print("\n ķ!ս״̬!!:%s ", cdkey );
+
+ return 1;
+ }
+ return 0;
+}
+
diff --git a/battle/battle_event.c b/battle/battle_event.c
new file mode 100644
index 0000000..6122f88
--- /dev/null
+++ b/battle/battle_event.c
@@ -0,0 +1,10080 @@
+#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
+#ifdef _ALLBLUES_LUA
+#include "mylua/function.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 && CHAR_getInt( charaindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYERNPC )
+ 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;
+
+}
+
+// ȡʱΧ
+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;
+}
+
+// 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 {
+ int equipnum;
+#ifdef _TAKE_ITEMDAMAGE_FOR_PET
+ if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPET){
+ equipnum = CHAR_PETITEMNUM;
+ }else
+#endif
+ equipnum = CHAR_EQUIPPLACENUM;
+#ifdef _TAKE_ITEMDAMAGE_FIX
+ rndwork = rand() % equipnum;
+#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;
+ }
+#endif
+ for( i = 0; i < equipnum; 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 itemlogitem
+// 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 );
+#ifdef _ATTREVERSE_FIX
+ if(getAttReverse()==1){
+ //if(CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEFLG ) & CHAR_BATTLEFLG_REVERSE){
+ if(CHAR_getWorkInt(charaindex,CHAR_WORKBATTLEREVERSE)==1){
+ CHAR_complianceParameter2(charaindex);
+ }else{
+#endif
+ CHAR_complianceParameter( charaindex );
+#ifdef _ATTREVERSE_FIX
+ }
+ }else{
+ CHAR_complianceParameter( charaindex );
+ }
+#endif
+ 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 itemlogitem
+// 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
+#ifdef _TAKE_ITEMDAMAGE_FOR_PET
+ || CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPET
+#endif
+ ){
+ 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
+#ifdef _TAKE_ITEMDAMAGE_FOR_PET
+ || CHAR_getInt( attackindex, CHAR_WHICHTYPE) == CHAR_TYPEPET
+#endif
+ ){
+ 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 ) );
+ strcatsafe( szBadStatusString,sizeof(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
+ //print("\n1=%d,ˮ1=%d,1=%d,1=%d\n",T_pow[0],T_pow[1],T_pow[2],T_pow[3]);
+#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
+ //print("\n2=%d,ˮ2=%d,2=%d,2=%d\n",T_pow[0],T_pow[1],T_pow[2],T_pow[3]);
+ {
+ 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;
+ }
+ //print("\n2=%d,ˮ2=%d,2=%d,2=%d\n",T_pow[0],T_pow[1],T_pow[2],T_pow[3]);
+/*
+ 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
+)
+{
+ if( BATTLE_CHECKINDEX( battleindex ) == FALSE ) return 0.0;
+#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);
+ //print("\natt=%d\n",att);
+ 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);
+ //print("\n1=%d,ˮ1=%d,1=%d,1=%d\n",At_pow[0],At_pow[1],At_pow[2],At_pow[3]);
+ //print("\n2=%d,ˮ2=%d,2=%d,2=%d\n",Dt_pow[0],Dt_pow[1],Dt_pow[2],Dt_pow[3]);
+#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
+ //print("\n1=%d,ˮ1=%d,1=%d,1=%d\n",At_pow[0],At_pow[1],At_pow[2],At_pow[3]);
+ //print("\n2=%d,ˮ2=%d,2=%d,2=%d\n",Dt_pow[0],Dt_pow[1],Dt_pow[2],Dt_pow[3]);
+ 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] );
+ //print("\nAt_FieldPow=%f,Df_FieldPow=%f\n",At_FieldPow,Df_FieldPow);
+ 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;
+*/
+ //print("\ndamage1=%d,",damage);
+ damage = BATTLE_AttrCalc(//2ˮ103
+ 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);
+ //print("damage2=%d\n",damage);
+ 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
+#ifdef _DAMMAGE_CALC
+ return damage * getDamageCalc() / 100;
+#else
+ return damage;
+#endif
+}
+
+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;
+}
+
+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;
+}
+
+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 );
+ strcatsafe( szBadStatusString,sizeof(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 );
+
+ //ijΪϢ
+ 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 );
+
+ //ijΪϢ
+ 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;
+ strcatsafe( szBuffer,sizeof(szBuffer), "ultimate?" );
+ }
+ if( ultimate == 2 ){
+ flg |= BCF_ULTIMATE_2;
+ strcatsafe( szBuffer,sizeof(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
+#ifdef _PSKILL_GYRATE
+ if ( ( damage > 0 ) && ( CHAR_getWorkInt( attackindex , CHAR_WORKBATTLECOM1 ) == BATTLE_COM_S_GYRATE ) && (CHAR_getWorkInt( attackindex , CHAR_WORKBATTLECOM5 ) >0) ) {
+ if ( RAND ( 1 , 100 ) <= CHAR_getWorkInt( attackindex, CHAR_WORKBATTLECOM7) ) {
+ int iEffect = CHAR_getWorkInt( attackindex , CHAR_WORKBATTLECOM5 );
+ CHAR_setWorkInt( defindex, StatusTbl[iEffect] , CHAR_getWorkInt( attackindex , CHAR_WORKBATTLECOM6 ) ); //趨˯
+ 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;
+ strcatsafe( szBuffer,sizeof(szBuffer), "ultimate?" );
+ }
+ if( ultimate == 2 ){
+ flg |= BCF_ULTIMATE_2;
+ strcatsafe( szBuffer,sizeof(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;
+ strcatsafe( szBuffer,sizeof(szBuffer), "ultimate?" );
+ }
+ if( ultimate == 2 ){
+ flg |= BCF_ULTIMATE_2;
+ strcatsafe( szBuffer,sizeof(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[128] = {
+ { 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
+};
+
+#ifdef _NEED_ITEM_ENEMY
+int need_item_eneny_init()
+{
+ FILE* fp;
+ int i;
+ int num=0;
+ char line[128], buf[16];
+ fp = fopen("data/needitemeneny.txt", "r");
+ if (fp == NULL)
+ {
+ print("ļ\n");
+ return FALSE;
+ }
+ while(1){
+ if (fgets(line, sizeof(line), fp) == NULL) break;
+ chop(line);
+ if(line[0]=='#')continue;
+
+ getStringFromIndexWithDelim(line,"|", 1, buf, sizeof(buf));
+ NeedEnemy[num].EnemyId=atoi(buf);
+ for(i=0;i=128)break;
+ }
+ fclose(fp);
+ return TRUE;
+}
+#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 itemlogitem
+// 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 );
+ }
+#ifdef _ALLBLUES_LUA_1_4
+ BattleEscape(battleindex, attackindex);
+#endif
+ CHAR_setWorkInt( attackindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_FINAL );
+ CHAR_DischargePartyNoMsg( attackindex );
+ BATTLE_Exit( attackindex, battleindex );
+ }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 ){ //DZΪ
+ 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_setWorkInt( 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 );
+#ifdef _PET_BUG
+ petindex = CHAR_getCharPet( attackindex, petNo);
+ if(CHAR_getInt(petindex,CHAR_VITAL)>=getPetPoint(0)*20 || CHAR_getInt(petindex,CHAR_STR)>=getPetPoint(1)*80 || CHAR_getInt(petindex,CHAR_TOUGH)>=getPetPoint(2)*80 || CHAR_getInt(petindex,CHAR_DEX)>=getPetPoint(3)*100)
+ CHAR_setInt( attackindex, CHAR_DEFAULTPET, -1 );
+ else
+#endif
+ 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;
+ strcatsafe( szBuffer,sizeof(szBuffer), "ultimate?" );
+ }
+ if( ultimate == 2 ){
+ flg |= BCF_ULTIMATE_2;
+ strcatsafe( szBuffer,sizeof(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;
+ strcatsafe( szBuffer,sizeof(szBuffer), "ultimate?" );
+ }
+ if( ultimate == 2 ){
+ flg |= BCF_ULTIMATE_2;
+ strcatsafe( szBuffer,sizeof(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;
+ strcatsafe( szBuffer,sizeof(szBuffer), "ultimate?" );
+ }
+ if( ultimate == 2 ){
+ flg |= BCF_ULTIMATE_2;
+ strcatsafe( szBuffer,sizeof(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;
+
+// print(" nonoϢ ");
+
+ 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 ),
+//
+// "EscapeLost(ս߲)",
+//
+// 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 == "\0" ) 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;
+ }
+#ifdef _ALLBLUES_LUA
+ else if( CHAR_getInt( BattleArray[battleindex].createindex, CHAR_WHICHTYPE ) == CHAR_TYPELUANPC ){
+ per = 0;
+ }
+#endif
+ 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 );
+ strcatsafe( szBadStatusString,sizeof(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 itemlogitem
+// 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 ) );
+ strcatsafe( szBadStatusString,sizeof(strcatsafe), 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;
+ strcatsafe( szBuffer,sizeof(szBuffer), "ultimate?" );
+ }
+ if( ultimate == 2 ){
+ flg |= BCF_ULTIMATE_2;
+ strcatsafe( szBuffer,sizeof(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 _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;
+ }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;
+
+ }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;
+ BATTLE_MultiRecovery( battleindex, attackNo, toNo,kind, power, per, SPR_item3, HealedEffect );
+
+ 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;
+ strcatsafe( szBuffer,sizeof(szBuffer), "ultimate?" );
+ }
+ if( *ultimate == 2 ){
+ *flg |= BCF_ULTIMATE_2;
+ strcatsafe( szBuffer,sizeof(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 == "\0" )
+ 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 == "\0" )
+ 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 == "\0" ) 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
+#ifdef _TAKE_ITEMDAMAGE_FOR_PET
+ && CHAR_getInt( defindex, CHAR_WHICHTYPE) == CHAR_TYPEPET
+#endif
+ )
+ 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 itemlogitem
+// 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 == "\0" ) 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 == "\0" ) 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 == "\0" ) 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
+ //ǿƽij
+ 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 == "\0" ) 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 == "\0" ) 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 ) {
+ BATTLE_MultiRecovery( battleindex, attackNo, toNo,
+ BD_KIND_HP, nums, 0, MAGIC_EFFECT_USER, SPR_heal3 );
+ }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 == "\0" ) {
+ //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 == "\0" ) {
+ //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 == "\0" ) {
+ //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 == "\0" ) {
+ //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 == "\0" ) {
+ //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)
+{
+#ifdef _OFFLINE_SYSTEM
+ if(CHAR_getWorkInt( charaindex, CHAR_WORK_OFFLINE ) == 1){
+ if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE){
+ CHAR_setWorkChar( charaindex, CHAR_WORKWALKARRAY,"");
+ CHAR_setInt( charaindex, CHAR_LOOPINTERVAL, getOfflineBattleTime());
+ BATTLE_CreateVsEnemy( charaindex,0, -1);
+ }
+ return 1;
+ }
+#endif
+ int fd = getfdFromCharaIndex( charaindex);
+ if( getStayEncount( fd) ) {
+ if( CONNECT_getBDTime( fd) < time( NULL) ) {
+ if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE){
+ if(getNoStayBattle()==1){
+ CHAR_talkToCli(charaindex, -1, "Ϊҵ·ԭ쳣뵽·ԡ", CHAR_COLORYELLOW);
+ }
+ 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 == "\0" ) 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;
+ }
+ }
+ 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);
+
+ 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 ij ְҵ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;
+
+ // ܵIJ
+ pszOption = PROFESSION_SKILL_getChar( skill, PROFESSION_SKILL_OPTION);
+ if( pszOption == "\0" ) 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;
+
+ // ܵIJ
+ pszOption = PROFESSION_SKILL_getChar( skill, PROFESSION_SKILL_OPTION);
+ if( pszOption == "\0" ) 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;
+ }
+ }
+ }
+#ifdef _BATTLE_NO_WANG
+ if(CHAR_getInt( defindex, CHAR_PETID) == 1165 || CHAR_getInt( defindex, CHAR_PETID) == 1166 || CHAR_getInt( defindex, CHAR_PETID) == 964)
+ {
+ Success = 0;
+ }
+ else
+ {
+#endif
+ // ɹ
+ if( (pszP = strstr( pszOption, "%" ) ) != NULL ) sscanf( pszP+3, "%d", &Success );
+ Success = Success + skill_level * 5;
+#ifdef _BATTLE_NO_WANG
+ }
+#endif
+ if( skill_type == BATTLE_COM_S_DRAGNET ){
+ int DRAGNET=0,dragnet_idx=-1;
+ int PLAYER=0;
+ //ҳһߵ
+ if( attackNo > 9 ){//
+ for(i=0;i<10;i++){//ұж
+ dragnet_idx = BATTLE_No2Index( battleindex, i );
+ if( CHAR_CHECKINDEX( dragnet_idx ) ){
+ PLAYER++;
+ 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 ) ){
+ PLAYER++;
+ if( CHAR_getWorkInt( BATTLE_No2Index( battleindex, i ), CHAR_WORKDRAGNET ) > 0 ) {
+ ++DRAGNET;
+ }
+ }
+ }
+ }
+ Success *= (float)((PLAYER-DRAGNET)/10.0);
+// 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 ij ְҵ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);
+ // dz,ڲڳ
+ 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);
+
+ // 봫clientbuffer
+ 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 == "\0"){
+// 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 itemlogitem
+// 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 == "\0" ){
+ //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 _CAX_ZHUANGYUAN_QTJ
+ int floor = CHAR_getInt( charaindex, CHAR_FLOOR );
+ int fd;
+ fd = getfdFromCharaIndex( charaindex);
+ if( floor == 1042
+ || floor == 2032
+ || floor == 3032
+ || floor == 4032
+ || floor == 5032
+ || floor == 6032
+ || floor == 7032
+ || floor == 8032
+ || floor == 9032
+ || floor == 10032
+ || floor == 2000
+ || floor == 2005){
+ int battleindex = CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEINDEX );
+ BATTLE_NoAction( battleindex, BATTLE_Index2No( battleindex, charaindex) );
+ CHAR_talkToCli(charaindex,-1,"˵ͼֹʹþ(ȫξ)",CHAR_COLORYELLOW);
+ return;
+ }
+#endif
+#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 itemlogitem
+// 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 itemlogitem
+// 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 )
+{
+ 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 );
+ if( (p = strstr( arg, "" )) != NULL )
+ {
+ 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;
+ BATTLE_MultiRecovery( battleindex, attackNo, toNo,kind, power, per, SPR_item3, HealedEffect );
+ {
+// LogItem(
+// CHAR_getChar( charaindex, CHAR_NAME ),
+// CHAR_getChar( charaindex, CHAR_CDKEY ),
+//#ifdef _add_item_log_name // WON ADD itemlogitem
+// 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 == "\0" )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 == "\0" )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 CC_ADD_ADDEXPCHECKDEGREE
+ {
+ if ( power != (int)(CHAR_getInt( charaindex, CHAR_ADDEXPPOWER)) &&
+ 0 != (int)(CHAR_getInt( charaindex, CHAR_ADDEXPPOWER))
+ )
+ {
+ CHAR_talkToCli( charaindex, -1, "ӵЧͬ,ʹ", CHAR_COLORYELLOW);
+ return;
+ }
+ }
+ #endif
+#ifdef _ITEM_ADDEXP2 // ǹʱۼ
+ {
+ int point;
+ point = CHAR_getInt( charaindex, CHAR_ADDEXPPOWER)
+ * (int)(CHAR_getInt( charaindex, CHAR_ADDEXPTIME)/60);
+#ifdef _CAX_ITEM_ADDEXP
+ if( point >= getexptime()* power) {
+#else
+ if( point >= 7200000) {
+#endif
+ CHAR_talkToCli( charaindex, -1, "ǻ֮ۼʱ估ЧѴޡ", CHAR_COLORYELLOW);
+ return;
+ }
+
+ if(CHAR_getInt( charaindex, CHAR_ADDEXPPOWER)!=power){
+ point = power * vtime;
+#ifdef _CAX_ITEM_ADDEXP
+ point = min( point, getexptime()*power);
+#else
+ point = min( point, 7200000);
+#endif
+ vtime = (int)(point / power);
+ }else{
+ point += (power * vtime);
+#ifdef _CAX_ITEM_ADDEXP
+ point = min( point, getexptime()*power);
+#else
+ point = min( point, 7200000);
+#endif
+ vtime = (int)(point / power);
+ }
+ }
+#endif
+ CHAR_setInt( charaindex, CHAR_ADDEXPPOWER, power);
+ CHAR_setInt( charaindex, CHAR_ADDEXPTIME,vtime*60 );
+
+ //
+ BATTLE_ItemUseDelete(charaindex,haveitemindex);
+ //sprintf(szBuffer, "ѧϰ%d", power);
+ sprintf(szBuffer, "ѧϰ%dʱЧʣ%dӡ", power, vtime);
+ CHAR_talkToCli(charaindex,-1,szBuffer,CHAR_COLORYELLOW);
+ //int mfd=getfdFromCharaIndex( charaindex);
+ CHAR_charSaveFromConnect(charaindex, FALSE);
+ CHAR_talkToCli(charaindex, -1, "ϵͳΪԶ浵", CHAR_COLORRED);
+}
+#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/battle/battle_magic.c b/battle/battle_magic.c
new file mode 100644
index 0000000..19de874
--- /dev/null
+++ b/battle/battle_magic.c
@@ -0,0 +1,5438 @@
+#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
+
+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,
+ int RecevEffect
+)
+{
+ int i, toindex, UpPoint = 0, workhp, oldhp, flg;
+ 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;
+ }
+ //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 );
+ }
+ }
+ }
+ 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 == "\0") 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;
+ }
+ BATTLE_MultiRecovery( battleindex, attackNo, toNo,BD_KIND_HP, (int)power, per, MAGIC_EFFECT_USER, HealedEffect );
+ 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 {// Ƿdz
+ 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 );// λ
+ // ȡ(һdz)
+ //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
+ 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++;
+ }
+ }
+ }
+ }
+ 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) {
+
+// 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);
+ }
+ }
+ 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 ) );
+ 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
+ );
+ strcatsafe( szCommand,sizeof(szCommand), buf1);
+
+ snprintf( buf1, sizeof(buf1),
+ "BL|r%X|h%X|", ToList[i], CHAR_getInt( toindex, CHAR_HP ) );
+ strcatsafe( szCommand,sizeof(szCommand), buf1);
+
+ 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)IJʱ(%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 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 == "\0" )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 == "\0" ) {
+ //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;
+ // ë //ȡøIJ(,,,,,)
+ 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 FALSE;
+ }
+ }
+// 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 == "\0" ) {
+ 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 );
+
+ if( magicarg == "\0" ) {
+ //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 );
+ if( -1 == attidx || attidx >= ATTMAGIC_magicnum )
+ return FALSE;
+
+ 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 == "\0" ) {
+ //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 ){
+ 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)) == "\0" ) 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: // ǹ
+ {
+#ifdef _JOB_FIX
+ if( skill_level > 9 )
+ *hp_power = 800 * 2;
+ else if( skill_level > 8 )
+ *hp_power = 450 * 2;
+ else if( skill_level > 7 )
+ *hp_power = 400 * 2;
+ else if( skill_level > 6 )
+ *hp_power = 350 * 2;
+ else if( skill_level > 5 )
+ *hp_power = 300 * 2;
+ else if( skill_level > 3 )
+ *hp_power = 200 * 2;
+ else
+ *hp_power = 100 * 2;
+#else
+ 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;
+#endif
+ 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 damage = 0;
+
+#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 );
+#ifdef _JOB_FIX
+ if( skill_level >= 10 ){
+ rate = 80;
+ }else{
+ rate = skill_level * 5 + 20;
+ }
+#else
+ if( skill_level >= 10 ){
+ rate = 60;
+ }else{
+ rate = skill_level * 5 + 5;
+ }
+#endif
+ //andy_Edit
+ damage = 120 + (int)( ( defense * rate / 100 ) + ( ( defense - base_defense ) * rate / 200 ) );
+ //ƶnpc˺
+ if( CHAR_getInt( defindex , 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;
+
+ skill_level = PROFESSION_CHANGE_SKILL_LEVEL_A( skill_level );
+
+ hit = skill_level * 2 + 60;
+
+ //if( rand_num <= hit ){
+ // ȡû˺
+#ifdef _JOB_FIX
+ damage = BATTLE_PROFESSION_CONVOLUTE_GET_DAMAGE( attackindex, defindex, skill_level ) * 1.1;
+#else
+ damage = BATTLE_PROFESSION_CONVOLUTE_GET_DAMAGE( attackindex, defindex, skill_level );
+#endif
+ //}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 );
+ }
+
+ // ȡùᴩ˺
+#ifdef _JOB_FIX
+ damage = BATTLE_PROFESSION_THROUGH_ATTACK_GET_DAMAGE( attackindex, defindex ) * 0.80;
+#else
+ damage = BATTLE_PROFESSION_THROUGH_ATTACK_GET_DAMAGE( attackindex, defindex );
+#endif
+ }
+#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 {// Ƿdz
+ 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_getWorkInt( 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;
+
+ 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 = 60;
+ else if( skill_level > 90 ) success = 50;
+ else if( skill_level > 80 ) success = 40;
+ else if( skill_level > 60 ) success = 30;
+ else if( skill_level > 30 ) success = 25;
+ else success = 20;
+
+ 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 );
+#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 ){
+ success = 15;
+ turn = 2;
+ }
+ else if( skill_level >= 6 ){
+ success = 10;
+ turn = 1;
+ }
+ else{
+ success = 5;
+ turn = 0;
+ }
+ if(rand_num <= success){
+ CHAR_setWorkInt( charaidx, CHAR_WORKICEARROW, turn );
+ }
+ 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/battle/makefile b/battle/makefile
new file mode 100644
index 0000000..8a0deda
--- /dev/null
+++ b/battle/makefile
@@ -0,0 +1,456 @@
+export CC=gcc
+export RM=rm -f
+export AR=ar cr
+export MV=mv
+export RANLIB=ranlib
+export SED=sed
+
+
+export SHELL=/bin/sh
+
+INCFLAGS=-I.. -I../include
+
+CFLAGS=-O3 -w $(INCFLAGS)
+#Pentium 4 (Intel)
+#CFLAGS=-march=pentium4 -O3 -pipe -fomit-frame-pointer $(INCFLAGS)
+#Athlon XP (AMD)
+#CFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer" $(INCFLAGS)
+#Athlon64£º
+#CFLAGS="-O2 -march=athlon64 -ftracer -fprefetch-loop-arrays -pipe" $(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/sasql.h \
+ /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \
+ /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \
+ /usr/include/gnu/stubs-32.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \
+ /usr/include/bits/types.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/i386-redhat-linux/4.1.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/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \
+ /usr/include/sys/socket.h /usr/include/sys/uio.h \
+ /usr/include/bits/uio.h /usr/include/bits/socket.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.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/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/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \
+ /usr/include/string.h ../include/correct_bug.h ../include/buf.h \
+ ../include/common.h ../include/object.h ../include/char.h \
+ ../include/char_base.h ../include/version.h ../include/skill.h \
+ ../include/util.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 \
+ /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \
+ /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \
+ ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \
+ ../include/char_data.h ../include/item.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/lssproto_util.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 ../include/item.h ../include/correct_bug.h \
+ ../include/mylua/function.h ../include/mylua/mylua.h ../include/lua.h \
+ ../include/lauxlib.h ../include/lualib.h ../include/npc_autopk.h \
+ ../include/profession_skill.h ../include/skill.h
+battle_event.o: battle_event.c ../include/version.h ../include/sasql.h \
+ /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \
+ /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \
+ /usr/include/gnu/stubs-32.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \
+ /usr/include/bits/types.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/i386-redhat-linux/4.1.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/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \
+ /usr/include/sys/socket.h /usr/include/sys/uio.h \
+ /usr/include/bits/uio.h /usr/include/bits/socket.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.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/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/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \
+ /usr/include/string.h ../include/correct_bug.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 \
+ ../include/char_base.h ../include/version.h ../include/skill.h \
+ ../include/util.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 \
+ /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \
+ /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \
+ ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \
+ ../include/char_data.h ../include/item.h ../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/lssproto_util.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 ../include/profession_skill.h ../include/item.h \
+ ../include/skill.h ../include/magic_base.h ../include/mylua/function.h
+battle_command.o: battle_command.c ../include/version.h \
+ ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \
+ /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \
+ /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \
+ /usr/include/bits/types.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/i386-redhat-linux/4.1.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/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \
+ /usr/include/sys/socket.h /usr/include/sys/uio.h \
+ /usr/include/bits/uio.h /usr/include/bits/socket.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.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/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/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \
+ /usr/include/string.h ../include/correct_bug.h ../include/char.h \
+ ../include/common.h ../include/char_base.h ../include/version.h \
+ ../include/skill.h ../include/util.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 /usr/include/pthread.h \
+ /usr/include/sched.h /usr/include/bits/sched.h \
+ /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \
+ ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \
+ ../include/char_data.h ../include/item.h ../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/lssproto_util.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/sasql.h \
+ /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \
+ /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \
+ /usr/include/gnu/stubs-32.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \
+ /usr/include/bits/types.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/i386-redhat-linux/4.1.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/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \
+ /usr/include/sys/socket.h /usr/include/sys/uio.h \
+ /usr/include/bits/uio.h /usr/include/bits/socket.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.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/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/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \
+ /usr/include/string.h ../include/correct_bug.h ../include/common.h \
+ ../include/char.h ../include/common.h ../include/char_base.h \
+ ../include/version.h ../include/skill.h ../include/util.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 \
+ /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \
+ /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \
+ ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \
+ ../include/char_data.h ../include/item.h ../include/char.h \
+ ../include/char_base.h ../include/battle.h ../include/npcutil.h \
+ ../include/pet_skill.h
+battle_magic.o: battle_magic.c ../include/version.h ../include/sasql.h \
+ /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \
+ /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \
+ /usr/include/gnu/stubs-32.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \
+ /usr/include/bits/types.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/i386-redhat-linux/4.1.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/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \
+ /usr/include/sys/socket.h /usr/include/sys/uio.h \
+ /usr/include/bits/uio.h /usr/include/bits/socket.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.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/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/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \
+ /usr/include/string.h ../include/correct_bug.h ../include/char.h \
+ ../include/common.h ../include/char_base.h ../include/version.h \
+ ../include/skill.h ../include/util.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 /usr/include/pthread.h \
+ /usr/include/sched.h /usr/include/bits/sched.h \
+ /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \
+ ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \
+ ../include/char_data.h ../include/item.h ../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 ../include/lssproto_util.h \
+ ../include/profession_skill.h ../include/skill.h
+pet_skill.o: pet_skill.c ../include/version.h ../include/sasql.h \
+ /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \
+ /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \
+ /usr/include/gnu/stubs-32.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \
+ /usr/include/bits/types.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/i386-redhat-linux/4.1.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/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \
+ /usr/include/sys/socket.h /usr/include/sys/uio.h \
+ /usr/include/bits/uio.h /usr/include/bits/socket.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.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/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/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \
+ /usr/include/string.h ../include/correct_bug.h ../include/common.h \
+ ../include/buf.h ../include/common.h ../include/configfile.h \
+ ../include/char_base.h ../include/version.h ../include/skill.h \
+ ../include/util.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 \
+ /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \
+ /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \
+ ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \
+ ../include/char_data.h ../include/item.h ../include/char.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
+battle_item.o: battle_item.c ../include/version.h ../include/sasql.h \
+ /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \
+ /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \
+ /usr/include/gnu/stubs-32.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \
+ /usr/include/bits/types.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/i386-redhat-linux/4.1.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/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \
+ /usr/include/sys/socket.h /usr/include/sys/uio.h \
+ /usr/include/bits/uio.h /usr/include/bits/socket.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.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/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/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \
+ /usr/include/string.h ../include/correct_bug.h ../include/char.h \
+ ../include/common.h ../include/char_base.h ../include/version.h \
+ ../include/skill.h ../include/util.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 /usr/include/pthread.h \
+ /usr/include/sched.h /usr/include/bits/sched.h \
+ /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \
+ ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \
+ ../include/char_data.h ../include/item.h ../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 \
+ ../include/lssproto_util.h
+profession_skill.o: profession_skill.c ../include/version.h \
+ ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \
+ /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \
+ /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \
+ /usr/include/bits/types.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/i386-redhat-linux/4.1.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/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \
+ /usr/include/sys/socket.h /usr/include/sys/uio.h \
+ /usr/include/bits/uio.h /usr/include/bits/socket.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.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/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/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \
+ /usr/include/string.h ../include/correct_bug.h ../include/buf.h \
+ ../include/common.h ../include/profession_skill.h ../include/version.h \
+ ../include/util.h ../include/skill.h ../include/char_base.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 \
+ /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \
+ /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \
+ ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \
+ ../include/battle.h ../include/magic_base.h ../include/configfile.h \
+ ../include/char.h ../include/char_base.h ../include/char_data.h \
+ ../include/item.h ../include/char.h ../include/lssproto_serv.h \
+ ../include/lssproto_util.h ../include/skill.h
diff --git a/battle/makefile.bak b/battle/makefile.bak
new file mode 100644
index 0000000..8a0deda
--- /dev/null
+++ b/battle/makefile.bak
@@ -0,0 +1,456 @@
+export CC=gcc
+export RM=rm -f
+export AR=ar cr
+export MV=mv
+export RANLIB=ranlib
+export SED=sed
+
+
+export SHELL=/bin/sh
+
+INCFLAGS=-I.. -I../include
+
+CFLAGS=-O3 -w $(INCFLAGS)
+#Pentium 4 (Intel)
+#CFLAGS=-march=pentium4 -O3 -pipe -fomit-frame-pointer $(INCFLAGS)
+#Athlon XP (AMD)
+#CFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer" $(INCFLAGS)
+#Athlon64£º
+#CFLAGS="-O2 -march=athlon64 -ftracer -fprefetch-loop-arrays -pipe" $(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/sasql.h \
+ /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \
+ /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \
+ /usr/include/gnu/stubs-32.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \
+ /usr/include/bits/types.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/i386-redhat-linux/4.1.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/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \
+ /usr/include/sys/socket.h /usr/include/sys/uio.h \
+ /usr/include/bits/uio.h /usr/include/bits/socket.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.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/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/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \
+ /usr/include/string.h ../include/correct_bug.h ../include/buf.h \
+ ../include/common.h ../include/object.h ../include/char.h \
+ ../include/char_base.h ../include/version.h ../include/skill.h \
+ ../include/util.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 \
+ /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \
+ /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \
+ ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \
+ ../include/char_data.h ../include/item.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/lssproto_util.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 ../include/item.h ../include/correct_bug.h \
+ ../include/mylua/function.h ../include/mylua/mylua.h ../include/lua.h \
+ ../include/lauxlib.h ../include/lualib.h ../include/npc_autopk.h \
+ ../include/profession_skill.h ../include/skill.h
+battle_event.o: battle_event.c ../include/version.h ../include/sasql.h \
+ /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \
+ /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \
+ /usr/include/gnu/stubs-32.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \
+ /usr/include/bits/types.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/i386-redhat-linux/4.1.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/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \
+ /usr/include/sys/socket.h /usr/include/sys/uio.h \
+ /usr/include/bits/uio.h /usr/include/bits/socket.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.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/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/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \
+ /usr/include/string.h ../include/correct_bug.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 \
+ ../include/char_base.h ../include/version.h ../include/skill.h \
+ ../include/util.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 \
+ /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \
+ /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \
+ ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \
+ ../include/char_data.h ../include/item.h ../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/lssproto_util.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 ../include/profession_skill.h ../include/item.h \
+ ../include/skill.h ../include/magic_base.h ../include/mylua/function.h
+battle_command.o: battle_command.c ../include/version.h \
+ ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \
+ /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \
+ /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \
+ /usr/include/bits/types.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/i386-redhat-linux/4.1.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/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \
+ /usr/include/sys/socket.h /usr/include/sys/uio.h \
+ /usr/include/bits/uio.h /usr/include/bits/socket.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.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/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/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \
+ /usr/include/string.h ../include/correct_bug.h ../include/char.h \
+ ../include/common.h ../include/char_base.h ../include/version.h \
+ ../include/skill.h ../include/util.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 /usr/include/pthread.h \
+ /usr/include/sched.h /usr/include/bits/sched.h \
+ /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \
+ ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \
+ ../include/char_data.h ../include/item.h ../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/lssproto_util.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/sasql.h \
+ /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \
+ /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \
+ /usr/include/gnu/stubs-32.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \
+ /usr/include/bits/types.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/i386-redhat-linux/4.1.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/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \
+ /usr/include/sys/socket.h /usr/include/sys/uio.h \
+ /usr/include/bits/uio.h /usr/include/bits/socket.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.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/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/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \
+ /usr/include/string.h ../include/correct_bug.h ../include/common.h \
+ ../include/char.h ../include/common.h ../include/char_base.h \
+ ../include/version.h ../include/skill.h ../include/util.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 \
+ /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \
+ /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \
+ ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \
+ ../include/char_data.h ../include/item.h ../include/char.h \
+ ../include/char_base.h ../include/battle.h ../include/npcutil.h \
+ ../include/pet_skill.h
+battle_magic.o: battle_magic.c ../include/version.h ../include/sasql.h \
+ /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \
+ /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \
+ /usr/include/gnu/stubs-32.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \
+ /usr/include/bits/types.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/i386-redhat-linux/4.1.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/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \
+ /usr/include/sys/socket.h /usr/include/sys/uio.h \
+ /usr/include/bits/uio.h /usr/include/bits/socket.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.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/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/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \
+ /usr/include/string.h ../include/correct_bug.h ../include/char.h \
+ ../include/common.h ../include/char_base.h ../include/version.h \
+ ../include/skill.h ../include/util.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 /usr/include/pthread.h \
+ /usr/include/sched.h /usr/include/bits/sched.h \
+ /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \
+ ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \
+ ../include/char_data.h ../include/item.h ../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 ../include/lssproto_util.h \
+ ../include/profession_skill.h ../include/skill.h
+pet_skill.o: pet_skill.c ../include/version.h ../include/sasql.h \
+ /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \
+ /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \
+ /usr/include/gnu/stubs-32.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \
+ /usr/include/bits/types.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/i386-redhat-linux/4.1.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/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \
+ /usr/include/sys/socket.h /usr/include/sys/uio.h \
+ /usr/include/bits/uio.h /usr/include/bits/socket.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.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/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/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \
+ /usr/include/string.h ../include/correct_bug.h ../include/common.h \
+ ../include/buf.h ../include/common.h ../include/configfile.h \
+ ../include/char_base.h ../include/version.h ../include/skill.h \
+ ../include/util.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 \
+ /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \
+ /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \
+ ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \
+ ../include/char_data.h ../include/item.h ../include/char.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
+battle_item.o: battle_item.c ../include/version.h ../include/sasql.h \
+ /usr/include/stdio.h /usr/include/features.h /usr/include/sys/cdefs.h \
+ /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \
+ /usr/include/gnu/stubs-32.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \
+ /usr/include/bits/types.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/i386-redhat-linux/4.1.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/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \
+ /usr/include/sys/socket.h /usr/include/sys/uio.h \
+ /usr/include/bits/uio.h /usr/include/bits/socket.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.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/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/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \
+ /usr/include/string.h ../include/correct_bug.h ../include/char.h \
+ ../include/common.h ../include/char_base.h ../include/version.h \
+ ../include/skill.h ../include/util.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 /usr/include/pthread.h \
+ /usr/include/sched.h /usr/include/bits/sched.h \
+ /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \
+ ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \
+ ../include/char_data.h ../include/item.h ../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 \
+ ../include/lssproto_util.h
+profession_skill.o: profession_skill.c ../include/version.h \
+ ../include/sasql.h /usr/include/stdio.h /usr/include/features.h \
+ /usr/include/sys/cdefs.h /usr/include/bits/wordsize.h \
+ /usr/include/gnu/stubs.h /usr/include/gnu/stubs-32.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.2/include/stddef.h \
+ /usr/include/bits/types.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/i386-redhat-linux/4.1.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/alloca.h /usr/include/netinet/in.h /usr/include/stdint.h \
+ /usr/include/sys/socket.h /usr/include/sys/uio.h \
+ /usr/include/bits/uio.h /usr/include/bits/socket.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.2/include/limits.h \
+ /usr/lib/gcc/i386-redhat-linux/4.1.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/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/asm-generic/errno.h /usr/include/asm-generic/errno-base.h \
+ /usr/include/string.h ../include/correct_bug.h ../include/buf.h \
+ ../include/common.h ../include/profession_skill.h ../include/version.h \
+ ../include/util.h ../include/skill.h ../include/char_base.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 \
+ /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \
+ /usr/include/bits/setjmp.h ../include/link.h ../include/lua.h \
+ ../include/luaconf.h ../include/lauxlib.h ../include/lualib.h \
+ ../include/battle.h ../include/magic_base.h ../include/configfile.h \
+ ../include/char.h ../include/char_base.h ../include/char_data.h \
+ ../include/item.h ../include/char.h ../include/lssproto_serv.h \
+ ../include/lssproto_util.h ../include/skill.h
diff --git a/battle/pet_skill.c b/battle/pet_skill.c
new file mode 100644
index 0000000..a532531
--- /dev/null
+++ b/battle/pet_skill.c
@@ -0,0 +1,2744 @@
+#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"
+#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 _PET_BIANSHEN
+ { "PETSKILL_Set_Vary", PETSKILL_Set_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
+ { "PETSKILL_ZiYun1", PETSKILL_ZiYun1, 0},
+
+};
+
+/*----------------------------------------------------------------------*/
+
+
+/* ͣʧͱ */
+/*----------------------------------------------------------------------*/
+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 "\0";
+ if( !PETSKILL_CHECKCHARDATAINDEX( element)) return "\0";
+ 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;
+ }
+ strcpysafe( buf,sizeof(buf), &line[i]);
+ }
+ if( i != 0 ) {
+ strcpysafe( line,sizeof(line), buf);
+ }
+}
+{
+ char token[256];
+ int ret;
+
+#ifdef _PETSKILL_OPTIMUM // ȡг輼ID, ֱԳ輼IDTable 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;
+ PETSKILL_CALLFUNC func;
+ int playcharaindex;
+ playcharaindex = CHAR_getCharPet(CHAR_getWorkInt(charaindex,CHAR_WORKPLAYERINDEX),CHAR_getInt(CHAR_getWorkInt(charaindex,CHAR_WORKPLAYERINDEX),CHAR_RIDEPET));
+ petskillid = CHAR_getPetSkill( charaindex, havepetskill);
+ if(playcharaindex==charaindex){
+ if(petskillid!=0 && petskillid!=1 && petskillid!=2)
+ petskillid=0;
+ }
+#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;
+#ifndef _OPEN_E_PETSKILL
+ if(PETSKILL_getInt(array, PETSKILL_ILLEGAL)){
+ if( (CHAR_getInt(charaindex, CHAR_WHICHTYPE)==CHAR_TYPEPET) ){
+ //print(" CHAR_TYPEPET:%d ", charaindex);
+ return FALSE;
+ }
+ }
+#endif
+#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
+
+)
+{
+#ifdef _FIX_ContinuationAttack
+ if(toindex<0 || toindex>=BATTLE_ENTRY_MAX*2){
+ print("err:NιĻĿ쳣 %d ", toindex);
+ return FALSE;
+ }
+#endif
+#ifdef _PETSKILL_NONO_FIX
+ if(CHAR_getWorkInt(charaindex,CHAR_WORKFIXAI)>=40 && CHAR_getWorkInt(charaindex,CHAR_WORKBATTLEMODE)!=BATTLE_CHARMODE_NONE && CHAR_getInt(charaindex, CHAR_WHICHTYPE)==CHAR_TYPEPET){
+ 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));
+ }
+#endif
+ 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
+)
+{
+#ifdef _PETSKILL_NONO_FIX
+ if(CHAR_getWorkInt(charaindex,CHAR_WORKFIXAI)>=40 && CHAR_getWorkInt(charaindex,CHAR_WORKBATTLEMODE)!=BATTLE_CHARMODE_NONE && CHAR_getInt(charaindex, CHAR_WHICHTYPE)==CHAR_TYPEPET){
+ 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));
+ }
+#endif
+ char *pszOption, *pszP;
+ int iBai = 0, iDuck = 0;
+ float fBai = 2.00;
+ float fPer = 0.01;
+ int strdef,i;
+ char szTurn[] = "turn";
+ char *hetStatus[]={"ȫ", "", "", "", "ʯ", "", "", "", "", "", "Ĭ"};
+ pszOption = PETSKILL_getChar( array, PETSKILL_OPTION );
+ for(i=0;i<11;i++){
+ if((pszP = strstr( pszOption, hetStatus[i] ) ) != NULL) break;
+ }
+ if(i == 11) i=0;
+ CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM5, i);
+ if((pszP = strstr( pszOption, szTurn ) ) != NULL){
+ pszP += sizeof( szTurn );
+ sscanf( pszP, "%d", &i );
+ CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM6, i);
+ }else{
+ CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM6, 1);
+ }
+
+ if((pszP = strstr( pszOption, "" ) ) != NULL){
+ sscanf( pszP+3, "%d", &i );
+ CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM7, i);
+ }else{
+ CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM7, 60);
+ }
+
+ CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM1, BATTLE_COM_S_MIGHTY );
+ CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM2, toindex );
+ CHAR_setWorkInt( charaindex, CHAR_WORKBATTLEMODE, BATTLE_CHARMODE_C_OK );
+
+ 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 );
+ }
+ 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+3, "%f", &fPer );
+ fPer=(fPer/100);
+ strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXDEX);
+ strdef=(int)(strdef * fPer);
+ CHAR_setWorkInt(charaindex,CHAR_WORKQUICK,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXDEX)+strdef));
+ }
+ CHAR_SETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3, iDuck );
+ return TRUE;
+}
+
+
+
+int PETSKILL_PowerBalance(
+ int charaindex,
+ int toindex,
+ int array,
+ char *data
+)
+{
+ char *pszOption="\0", *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 == "\0" ) {
+ 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+3, "%f", &fPer );
+ fPer=(fPer/100);
+ strdef=CHAR_getWorkInt(charaindex,CHAR_WORKFIXDEX);
+ strdef=(int)(strdef * fPer);
+ CHAR_setWorkInt(charaindex,CHAR_WORKQUICK,(CHAR_getWorkInt(charaindex,CHAR_WORKFIXDEX)+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="\0", *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=="\0"){
+ //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="\0", *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 == "\0" ) {
+ //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
+
+)
+{
+#ifdef _PETSKILL_NONO_FIX
+ if(CHAR_getWorkInt(charaindex,CHAR_WORKFIXAI)>=40 && CHAR_getWorkInt(charaindex,CHAR_WORKBATTLEMODE)!=BATTLE_CHARMODE_NONE && CHAR_getInt(charaindex, CHAR_WHICHTYPE)==CHAR_TYPEPET){
+ 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));
+ }
+#endif
+ 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;
+#ifdef _FIX_EARTHROUND
+ if(toNo<0 || toNo>=BATTLE_ENTRY_MAX*2){
+ print("err:һܹĿ쳣 %d ", toNo);
+ return FALSE;
+ }
+#endif
+ 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="\0", *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 == "\0" ) {
+ //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; // magic idԤΪħȼһ,item indexԤΪ19659
+// int item = 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 _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 == "\0" ) 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 == "\0" ) 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 == "\0" ) 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 == "\0" ) 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 == "\0" ) 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)) == "\0" ) {
+ //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
+#ifdef _ITEM_EQUITSPACE
+ || itemtype == ITEM_WBELT
+ || itemtype == ITEM_WSHIELD
+ || itemtype == ITEM_WSHOES
+#endif
+#ifdef _EQUIT_NEWGLOVE
+ || itemtype == ITEM_WGLOVE
+#endif
+#ifdef _PET_ITEM
+#ifndef _TAKE_ITEMDAMAGE_FOR_PET
+ || (itemtype >= ITEM_PET_HEAD && itemtype <= ITEM_PET_FEET)
+#endif
+#endif
+ ){
+ 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="\0";
+ 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 == "\0" ) 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="\0",*pszP;
+ int attnum,strdef,d_dep;
+ float fPer = 0.01;
+ 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 == "\0" ) 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+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);
+ }
+
+ if( (pszP = strstr( pszOption, "" ) ) != NULL ){
+ sscanf( pszP+3, "%d", &attnum );
+ CHAR_SETWORKINT_HIGH( charaindex, CHAR_WORKBATTLECOM3, attnum);
+ }
+
+ 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 = "\0" ;
+ 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 == "\0" ) 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,d_dep;
+ 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));
+ }
+ 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( 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="\0", *pszP;
+ float fPer = 0.01;
+ int strdef=0;
+ char szTurn[] = "turn";
+ int d_dep,i=0;
+ int randi=0;
+ //char *hetStatus[]={"ȫ", "", "", "", "ʯ", "", "", "", "", "", "Ĭ"};
+
+ 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 == "\0" ) {
+ //print("\n pszOption == NULL ");
+ return FALSE;
+ }
+#ifdef _PSKILL_GYRATE
+ for(i=0;ii){
+// CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM5, 0);
+// }
+ }else{
+ CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM7, 60);
+// randi=RAND(1,100);
+// if(randi>60){
+// CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM5, 0);
+// }
+ }
+#endif
+ //ȡֵ
+ 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));
+ }
+#ifdef _PSKILL_GYRATE
+ 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+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);
+ }
+#endif
+ 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="\0", *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 == "\0" ) {
+ 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="\0", *pszP;
+ float fPer = 0.01;
+ int strdef;
+ char szTurn[] = "turn";
+ int d_dep,i=0;
+ char *hetStatus[]={"ȫ", "", "", "", "ʯ", "", "", "", "", "", "Ĭ"};
+ 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 == "\0" ) {
+ //print("\n pszOption == NULL ");
+ return FALSE;
+ }
+ for(i=0;i<11;i++){
+ if((pszP = strstr( pszOption, hetStatus[i] ) ) != NULL) break;
+ }
+ CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM5, i);
+ if((pszP = strstr( pszOption, szTurn ) ) != NULL){
+ pszP += sizeof( szTurn );
+ sscanf( pszP, "%d", &i );
+ CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM6, i);
+ }else{
+ CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM6, 1);
+ }
+
+ if((pszP = strstr( pszOption, "" ) ) != NULL){
+ sscanf( pszP+3, "%d", &i );
+ CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM7, i);
+ }else{
+ CHAR_setWorkInt( charaindex, CHAR_WORKBATTLECOM7, 60);
+ }
+
+ //ȡֵ
+ 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+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 == "\0" ) 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,strdef,d_dep;
+ char *pszOption="\0",*pszP,szData[32],szData2[32];
+
+ pszOption = PETSKILL_getChar(array,PETSKILL_OPTION);
+ if(pszOption == "\0"){
+ //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){
+ // 趨
+ if(CHAR_getWorkInt(charaindex,CHAR_WORKPETSKILLBT)==0 && CHAR_getWorkInt(charaindex,CHAR_WORKBATTLEINDEX)>-1){
+ //ȡֵ
+ if( (pszP = strstr( szData, "%" ) ) != 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));
+ }
+#ifdef _PSKILL_BATTLE_MODEL
+ if( (pszP = strstr( szData, "%" ) ) != 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( szData, "%" ) ) != 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);
+ }
+#endif
+ }
+ }
+ CHAR_setWorkInt(charaindex,CHAR_WORKPETSKILLBT,1);
+ 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="\0";
+ char combined[32];
+ int kill[10],count,i;
+ char killstr[32],countstr[32];
+
+ pszOption = PETSKILL_getChar( array, PETSKILL_OPTION );
+ if( pszOption == "\0" ) return FALSE;
+
+ strcpysafe( combined,sizeof(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;
+ }
+ strcpysafe( buf,sizeof(buf), &line[i]);
+ }
+
+ if( i != 0 ) {
+ strcpysafe( line,sizeof(line), buf);
+ }
+ }
+ {
+ char token[256];
+ int ret;
+
+#ifdef _PROSKILL_OPTIMUM // ȡְID, ְֱIDTable 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 "\0";
+ if( !PROFESSION_SKILL_CHECKCHARDATAINDEX( element)) return "\0";
+ 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="\0";
+ 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="\0";
+ 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="\0", *pszOption="\0", *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);
+
+ // 춨
+ if( rand_num > skill_level + rand_num2){
+ //
+ skill_level += PROFESSION_SKILL_ADD_POINT;
+ 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 );
+ }
+ }
+ 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ܵ", 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 == (CHAR_HaveSkill*)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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo<21)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo!=20 && toNo!=21)
+ toNo=0;
+ 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 )
+{
+ if(toNo!=20 && toNo!=21)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo!=20 && toNo!=21)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo!=20 && toNo!=21)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo<21)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo!=20 && toNo!=21)
+ toNo=0;
+ 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 )
+{
+ if(toNo!=20 && toNo!=21)
+ toNo=0;
+ 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 )
+{
+ if(toNo!=20 && toNo!=21)
+ toNo=0;
+ 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 )
+{
+ if(toNo!=20 && toNo!=21)
+ toNo=0;
+ 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 )
+{
+ if(toNo!=20 && toNo!=21)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 )
+{
+ if(toNo>19)
+ toNo=0;
+ 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 = "\0", 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;
+ }
+
+ // ܵIJ
+ 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 = "\0", 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;
+ }
+
+ // ܵIJ
+ 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 )
+{
+ char *pszP = NULL, *pszOption = "\0";
+ int rate=0;
+ // ܵIJ
+ pszOption = PROFESSION_SKILL_getChar( array, PROFESSION_SKILL_OPTION);
+ if( (pszP = strstr( pszOption, "%" ) ) != NULL ) sscanf( pszP+3, "%d", &rate );
+ int pile = CHAR_getWorkInt( charaindex, CHAR_WORKATTACHPILE);
+ pile = pile * rate;
+ CHAR_setWorkInt( charaindex, CHAR_WORKATTACHPILE,pile);
+ return TRUE;
+}
+// ͬ-ǿ
+int PROFESSION_strengthen( int charaindex, int toNo, int array, char *data, int skill_level )
+{
+ return TRUE;
+}
+
+#endif
+
diff --git a/battle/stoRkxhg b/battle/stoRkxhg
new file mode 100644
index 0000000..7077e13
Binary files /dev/null and b/battle/stoRkxhg differ
diff --git a/buf.c b/buf.c
new file mode 100644
index 0000000..6a81f8b
--- /dev/null
+++ b/buf.c
@@ -0,0 +1,192 @@
+#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( "ɷ %d byte\n" , UNIT*UNITNUMBER );
+ free( mem );
+ return FALSE;
+ }
+ memset( mem[0].pointer , 0 , sizeof( UNIT*UNITNUMBER ));
+ print( "ڴѷ %.2f MB..." ,UNIT*UNITNUMBER/1024.0/1024.0);
+#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 );
+ printf("(%.2f KB)\n",nbyte/1024.0);
+#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;
+}
+
+
+
+/*------------------------------------------------------------
+ * ¦
+ * ߯Ի
+ * ئ
+ ------------------------------------------------------------*/
+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/callfromac.c b/callfromac.c
new file mode 100644
index 0000000..e64968c
--- /dev/null
+++ b/callfromac.c
@@ -0,0 +1,1676 @@
+#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"
+#include "npc_eventaction.h"
+// CoolFish: Family 2001/5/24
+#include "family.h"
+#include "log.h"
+#include "buf.h"
+#ifdef _ALLDOMAN // (ɿ) Syu ADD аNPC
+#include "npc_alldoman.h"
+#endif
+#include "enemy.h"
+time_t initTime =0;
+
+extern BOOL bNewServer;
+extern int i_shutdown_time;//ttom
+extern int manorflag[10];
+extern char manorname[10][32];
+#ifdef _ANGEL_SUMMON
+extern struct MissionInfo missionlist[MAXMISSION];
+extern struct MissionTable missiontable[MAXMISSIONTABLE];
+#endif
+
+char question[64];
+char answer[64];
+int questionstarttime=0;
+int questionman=0;
+#ifdef _ALL_ITEM
+int allnum1=0;
+int allnum2=0;
+int allnum3=0;
+int allnum4=0;
+int allnum5=0;
+#endif
+
+void saacproto_ACGmsvDownRequest_recv( int fd, int min)
+{
+ char buff[32];
+ int i;
+ int playernum = CHAR_getPlayerMaxNum();
+
+ snprintf( buff, sizeof( buff),"%s档",getGameserverID());
+ 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( "ACʧ!˳...[%s][%s]\n",
+ result,data );
+ shutdownProgram( );
+ exit(1);
+ }
+ print("ACӳɹ\n");
+ time(&initTime);
+/*
+ print("ͣ");
+ if( bNewServer )
+ print("·! \n");
+ else
+ print("ɷ! \n");
+*/
+#ifdef _SERVER_NUMS
+ print(" !\n\n");
+#endif
+
+ printf( "GMSV汾: <%s %s>\n" , SERVER_VERSION, "Ѱ");
+ printf( "GMSVʱ: %s %s \n" , __DATE__ , __TIME__ );
+
+ printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
+ printf( "~ ~\n" );
+ printf( "~ ~\n" );
+ printf( "~ ΪѷˡϽҵ;,ɵĺге ~\n" );
+ printf( "~ ~\n" );
+ printf( "~ ~\n" );
+ printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
+ // Robin 0530
+ //saacproto_ACShowFMList_send( acfd );
+ print("\nʼ...");
+ FAMILY_Init();
+ print("\n");
+#ifdef _ANGEL_SUMMON
+ print("ʼٻ...");
+ saacproto_ACMissionTable_send( acfd, -1, 1, "", "");
+ print("\n");
+
+
+#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])) {
+ CHAR_login( clifd,data,saveindex );
+ }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 );
+ }
+}
+
+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 );
+ unsigned long ip;
+ int a,b,c,d;
+ 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:
+ ip=CONNECT_get_userip(clifd);
+
+ a=(ip % 0x100); ip=ip / 0x100;
+ b=(ip % 0x100); ip=ip / 0x100;
+ c=(ip % 0x100); ip=ip / 0x100;
+ d=(ip % 0x100);
+ char userip[32];
+ sprintf(userip,"%d.%d.%d.%d",a,b,c,d);
+ saacproto_ACCharDelete_send( acfd, cdkey,passwd,charname,"",fdid,userip );
+ 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{
+ /*
+ * պݩƷ
+ */
+ 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;
+ }
+ 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 )
+{
+ 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);
+ }
+}
+
+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);
+}
+
+void saacproto_ACShowMemberList_recv(int fd, char *result, int index, int fmmemnum,
+ int fmacceptflag, int fmjoinnum, char *data)
+{
+ int ret;
+ // fmmemnum -1:ֵ, -2: else:ʾ˼
+ if (strcmp(result, SUCCESSFUL) == 0) ret = 1;
+ else ret = 0;
+ ACShowMemberList(ret, index, fmmemnum, fmacceptflag, fmjoinnum, data);
+}
+void saacproto_ACFMDetail_recv(int fd, char *result, char *data, int charfdid)
+{
+ int ret;
+ int clifd = getfdFromFdid(charfdid);
+ if (CONNECT_checkfd(clifd) == FALSE) return;
+ if (strcmp(result, SUCCESSFUL) == 0) ret = 1;
+ else ret = 0;
+ ACFMDetail(ret, data, clifd );
+}
+void saacproto_ACMemberJoinFM_recv(int fd, char *result, char *data, int charfdid)
+{
+
+}
+void saacproto_ACMemberLeaveFM_recv(int fd, char *result, char *data, int charfdid)
+{
+
+}
+#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
+{
+ int ret;
+ int clifd = getfdFromFdid(charfdid);
+ if (CONNECT_checkfd(clifd) == FALSE) return;
+ if (strcmp(result, SUCCESSFUL) == 0) ret = 1;
+ else ret = 0;
+// print("Login fd:%d result:%s index:%d floor:%d fmdp:%d joinflag:%d setup:%d charfdid:%d\n",
+// fd, result, index, floor, fmdp, joinflag, fmsetupflag, charfdid);
+#ifdef _PERSONAL_FAME // Arminius:
+// print("Login charfame:%d\n", charfame);
+ ACFMCharLogin(clifd, ret, index, floor, fmdp, joinflag, fmsetupflag,
+ flag, charindex, charfame
+ #ifdef _NEW_MANOR_LAW
+ ,momentum
+ #endif
+ );
+#else
+ ACFMCharLogin(clifd, ret, index, floor, fmdp, joinflag, fmsetupflag,
+ flag, charindex);
+#endif
+}
+void saacproto_ACFMCharLogout_recv(int fd, char *result, int charfdid)
+{
+}
+void saacproto_ACFMReadMemo_recv(int fd, char *result, int index, int num,
+ int dataindex, char *data)
+{
+ int ret;
+ // index( WORK )num(ϱ35)
+ // dataindex(µ)data()
+ // עnum -1:ֵ, -2: else:ʾ˼
+ if (strcmp(result, SUCCESSFUL) == 0) ret = 1;
+ else ret = 0;
+ ACShowFMMemo(ret, index, num, dataindex, data);
+}
+void saacproto_ACFMWriteMemo_recv(int fd, char *result, int index)
+{
+}
+void saacproto_ACFMPointList_recv(int fd, char *result, char *data)
+{
+ int ret;
+ if (strcmp(result, SUCCESSFUL) == 0) ret = 1;
+ else ret = 0;
+ ACShowPointList(ret, data);
+}
+
+
+void saacproto_ACSetFMPoint_recv(int fd, char *result, int r, int charfdid)
+{
+ int ret;
+ int clifd = getfdFromFdid(charfdid);
+ if( CONNECT_checkfd(clifd) == FALSE )return;
+ if (strcmp(result, SUCCESSFUL) == 0){
+ ret = 1;
+ }else{
+ ret = 0;
+ }
+ ACSetFMPoint(ret, r, clifd);
+
+}
+void saacproto_ACFixFMPoint_recv(int fd, char *result, int r)
+{
+}
+void saacproto_ACFMAnnounce_recv(int fd, char *result, char *fmname,
+ int fmindex, int index, int kindflag, char *data, int color)
+{
+ int ret;
+ if (strcmp(result, SUCCESSFUL) == 0){
+ ret = 1;
+ }else{
+ ret = 0;
+ }
+ ACFMAnnounce(ret, fmname, fmindex, index, kindflag, data, color);
+}
+#ifdef _NEW_MANOR_LAW
+extern void SortManorSchedule();
+#endif
+void saacproto_ACShowTopFMList_recv(int fd, char *result, int kindflag, int num, char *data)
+{
+ int ret;
+ if (strcmp(result, SUCCESSFUL) == 0) ret = 1;
+ else ret = 0;
+ ACShowDpTop(ret, num, data, kindflag);
+#ifdef _NEW_MANOR_LAW
+ SortManorSchedule();
+#endif
+}
+#ifdef _NEW_MANOR_LAW
+extern struct FMS_DPTOP fmdptop;
+#endif
+void saacproto_ACFixFMData_recv(int fd, char *result, int kindflag, char *data1,
+ char *data2, int charfdid)
+{
+ int ret;
+ int intdata;
+ int clifd = getfdFromFdid(charfdid);
+ int charaindex = CONNECT_getCharaindex( clifd );
+ if( CONNECT_checkfd(clifd) == FALSE )return;
+
+ if (strcmp(result, SUCCESSFUL) == 0) ret = 1;
+ else ret = 0;
+
+ if( !CHAR_CHECKINDEX(charaindex) ) return;
+ if( kindflag == FM_FIX_FMRULE ){
+ CHAR_talkToCli( charaindex , -1, "ּģϣˣ", CHAR_COLORWHITE);
+ }else if( kindflag == FM_FIX_FMGOLD ) {
+ intdata = atoi( data1 );
+ if( ret == 0 ) {
+ 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);
+ 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);
+ }
+ 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 )
+ );
+ }
+ }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);
+#ifdef _FMWAR_PLAYERNUM
+ if( maxnum < getFmWarPlayerNum() ) maxnum = getFmWarPlayerNum();
+#else
+ if( maxnum < 50 ) maxnum = 50;
+#endif
+ 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; 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 _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
+
+void saacproto_ACCharLogin_recv(int fd , int clifd, int flag)
+{
+ if(flag==1)
+ lssproto_ClientLogin_send( clifd , "ok" );
+ else{
+ lssproto_ClientLogin_send( clifd , "no" );
+ CONNECT_endOne_debug(clifd);
+ }
+}
+
+void saacproto_QuerySafePasswd_recv( int fd, char* id, int res, int charaindex )
+{
+ if(res == 1)
+ {
+ CHAR_setWorkInt( charaindex, CHAR_WORKSAFEMODE, 1);
+ CHAR_talkToCli( charaindex, -1, "İȫȷϵͳɹ", CHAR_COLORRED);
+ }
+ if(res == 2)
+ {
+ CHAR_talkToCli( charaindex, -1, "İȫϵͳ", CHAR_COLORRED);
+ }
+ if(res == 3)
+ {
+ CHAR_talkToCli( charaindex, -1, "ûðȫ룬뾡ã", CHAR_COLORRED);
+ CHAR_AddSafePassword(charaindex);
+ }
+ if(res == 4)
+ {
+ CHAR_setWorkInt( charaindex, CHAR_WORKSAFEMODE, 1);
+ CHAR_talkToCli( charaindex, -1, "İȫȷϵͳɹ", CHAR_COLORRED);
+ CHAR_talkToCli( charaindex, -1, "ʾ1˺źͰȫƣΪ˺Űȫ뾡İȫ룡", CHAR_COLORRED);
+ CHAR_talkToCli( charaindex, -1, "ʾ2Ϊȷ˺Űȫδİȫǰɾ", CHAR_COLORRED);
+ }
+}
+
+void saacproto_AddSafePasswd_recv( int fd, char* id, int res, int charaindex )
+{
+ if(res == 1)
+ {
+ CHAR_talkToCli( charaindex, -1, "Ѿɹõİȫ룡", CHAR_COLORRED);
+ }
+}
+
+void saacproto_PointCardSucces_recv( int fd, char* id, int res, int point, int charaindex )
+{
+ char msgtmp[256];
+ if(res > 0)
+ {
+ sprintf(msgtmp, "%dԱֵɹڵĻԱΪ%d",res,point);
+ CHAR_talkToCli( charaindex, -1, msgtmp, CHAR_COLORYELLOW);
+ }
+}
+
+void saacproto_PointCardErr_recv( int fd, char* id, int res, int charaindex )
+{
+ if(res == -1)
+ {
+ CHAR_talkToCli( charaindex, -1, "óֵѾʹãظʹãлл", CHAR_COLORRED);
+ }
+ else if(res == -2)
+ {
+ CHAR_talkToCli( charaindex, -1, "ֵдд", CHAR_COLORRED);
+ }
+}
+
+void saacproto_LoginTime_recv( int fd, char* id, char* res, int charaindex )
+{
+ char timemsg[256];
+ sprintf(timemsg,"ϴε½ʱΪ%s",res);
+ CHAR_talkToCli( charaindex, -1, timemsg, CHAR_COLORYELLOW);
+
+}
+
+#ifdef _ONLINE_SHOP
+void saacproto_ACShop_recv( int fd, int charaindex, int shopnum, int vippoint, int piece, int pieces, int shopflag, char* res )
+{
+ int clifd = getfdFromCharaIndex( charaindex);
+ lssproto_SHOP_send(clifd,shopnum,vippoint,piece,pieces,shopflag,res);
+
+}
+
+void saacproto_ACShopBuy_recv( int charaindex, int shopflag, int shopno, int buynum )
+{
+ if(shopflag==1)
+ {
+ int ret;
+ char msgbuf[64], buf1[8], buf2[10];
+ int enemynum;
+ int i,j,k;
+ int petindex, petindex2;
+ for( k =1 ; k<=buynum ; k++ )
+ {
+ for( i = 0 ;i < CHAR_MAXPETHAVE ; i++) {
+ petindex = CHAR_getCharPet( charaindex, i);
+ if( petindex == -1 )
+ break;
+ }
+
+ if( i == CHAR_MAXPETHAVE ) {
+ snprintf( msgbuf,sizeof( msgbuf), "");
+ CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORYELLOW);
+ return;
+ }
+
+ enemynum = ENEMY_getEnemyNum();
+ for( i = 0; i < enemynum; i ++ ) {
+ if( ENEMY_getInt( i, ENEMY_ID) == shopno) {
+ break;
+ }
+ }
+
+ if( i == enemynum )
+ return;
+
+ ret = ENEMY_createPetFromEnemyIndex( charaindex, i);
+ for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) {
+ if( CHAR_getCharPet( charaindex, i ) == ret )
+ break;
+ }
+ if( i == CHAR_MAXPETHAVE )
+ CHAR_talkToCli( charaindex, -1, "ȡʧܣ", CHAR_COLORYELLOW);
+
+ if( CHAR_CHECKINDEX( ret ) == TRUE ){
+ CHAR_setInt( ret, CHAR_HP, CHAR_getWorkInt( ret, CHAR_WORKMAXHP ));
+ CHAR_setMaxExpFromLevel( ret, CHAR_getInt( ret, CHAR_LV ));
+ CHAR_setInt(ret,CHAR_VARIABLEAI,10000);
+ }
+
+ petindex2 = CHAR_getCharPet(charaindex, i);
+ if( !CHAR_CHECKINDEX( petindex2) )
+ return;
+ snprintf( msgbuf,sizeof( msgbuf), "õ%s", CHAR_getChar(petindex2,CHAR_NAME));
+ CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORYELLOW);
+ for(j = 0; j < CHAR_MAXPETHAVE; j++){
+ petindex = CHAR_getCharPet(charaindex, j);
+ if( !CHAR_CHECKINDEX( petindex) )
+ continue;
+ CHAR_complianceParameter( petindex );
+ snprintf( msgbuf, sizeof( msgbuf ), "K%d", j );
+ CHAR_sendStatusString( charaindex, msgbuf );
+ snprintf( msgbuf, sizeof( msgbuf ), "W%d", j );
+ CHAR_sendStatusString( charaindex, msgbuf );
+ }
+ }
+ }
+ else
+ {
+
+ int emptyitemindexinchara, itemindex;
+ int i;
+ char msgbuf[128];
+
+ if( buynum <= 0 ) buynum = 1;
+
+ {
+ for( i = 0; i < buynum; i ++ ) {
+ emptyitemindexinchara = CHAR_findEmptyItemBox( charaindex );
+
+ if( emptyitemindexinchara < 0 ){
+ sprintf( msgbuf, "Ʒλ㡣" );
+
+ CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORYELLOW);
+
+ return;
+ }
+
+ itemindex = ITEM_makeItemAndRegist( shopno );
+
+ if( itemindex != -1 ){
+ CHAR_setItemIndex( charaindex, emptyitemindexinchara, itemindex );
+ ITEM_setWorkInt(itemindex, ITEM_WORKOBJINDEX,-1);
+ ITEM_setWorkInt(itemindex, ITEM_WORKCHARAINDEX,charaindex);
+ CHAR_sendItemDataOne( charaindex, emptyitemindexinchara);
+ snprintf( msgbuf, sizeof( msgbuf), "õ%s",
+ ITEM_getChar( itemindex, ITEM_NAME));
+ CHAR_talkToCli( charaindex, -1,msgbuf, CHAR_COLORYELLOW);
+ }
+ }
+ }
+ }
+}
+#endif
+
+#ifdef _QUESTION_ONLINE
+void saacproto_ACQuestion_recv(char* res)
+{
+ if( getStringFromIndexWithDelim( res, ";", 1, question, sizeof( question)) == FALSE )
+ return;
+ if( getStringFromIndexWithDelim( res, ";", 2, answer, sizeof( answer)) == FALSE )
+ return;
+ time_t timep;
+ struct tm *p;
+ time(&timep);
+ p=localtime(&timep);
+ timep = mktime(p);
+ questionstarttime = timep;
+ int playnum = CHAR_getPlayerMaxNum();
+ int i;
+ char questionres[256];
+ sprintf(questionres,"\n⣺%s\n𰸣",question);
+ for(i=0;i 0)
+ CHAR_setInt( ret, CHAR_VITAL, vital);
+ if(str > 0)
+ CHAR_setInt( ret, CHAR_STR, str * 80);
+ if(tough > 0)
+ CHAR_setInt( ret, CHAR_TOUGH, tough * 80);
+ if(dex > 0)
+ CHAR_setInt( ret, CHAR_DEX, dex * 100);
+
+ CHAR_setMaxExpFromLevel( ret, CHAR_getInt( ret, CHAR_LV ));
+ CHAR_setInt(ret, CHAR_VARIABLEAI, 10000);
+ }
+
+ CHAR_setInt( ret, CHAR_HP, CHAR_getWorkInt( ret, CHAR_WORKMAXHP ));
+ 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(data[0]=='1'){
+ int emptyitemindexinchara, itemindex;
+ int itemid;
+ getStringFromIndexWithDelim(data,"|", 2, buf, sizeof(buf));
+ itemid = atoi( buf);
+ emptyitemindexinchara = CHAR_findEmptyItemBox( charaindex );
+
+ if( emptyitemindexinchara < 0 ){
+ CHAR_talkToCli( charaindex, -1, "Ʒ", CHAR_COLORYELLOW);
+ return;
+ }
+
+ itemindex = ITEM_makeItemAndRegist( itemid );
+
+ if( itemindex != -1 ){
+ CHAR_setItemIndex( charaindex, emptyitemindexinchara, itemindex );
+ ITEM_setWorkInt(itemindex, ITEM_WORKOBJINDEX,-1);
+ ITEM_setWorkInt(itemindex, ITEM_WORKCHARAINDEX,charaindex);
+ CHAR_sendItemDataOne( charaindex, emptyitemindexinchara);
+
+ snprintf( token, sizeof( token), "ȡƷ %s", ITEM_getChar( itemindex, ITEM_NAME));
+ CHAR_talkToCli( charaindex, -1,token, CHAR_COLORGREEN);
+ }else{
+ CHAR_talkToCli( charaindex, -1, "Ʒڣ뱾Աϵ", CHAR_COLORYELLOW);
+ }
+
+ }else if(data[0]=='2'){
+ getStringFromIndexWithDelim(data,"|", 2, buf, sizeof(buf));
+ int gold = atoi(buf);
+ CHAR_setInt( charaindex , CHAR_GOLD , CHAR_getInt( charaindex , CHAR_GOLD ) + gold);
+ CHAR_complianceParameter( charaindex );
+ CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_GOLD);
+ sprintf( token, "ȡ %d ʯң", gold);
+ CHAR_talkToCli( charaindex, -1,token, CHAR_COLORGREEN );
+ }else{
+ CHAR_talkToCli( charaindex, -1, data, CHAR_COLORGREEN);
+ }
+}
+#endif
+
+void saacproto_ACFmPkOnlineSn_recv(int manorindex,char* gsname, int flag)
+{
+ if(flag == 1){
+ sprintf(manorname[manorindex],"%s",gsname);
+ }else{
+ sprintf(manorname[manorindex],"\O");
+ }
+ manorflag[manorindex] = flag;
+}
+
+void saacproto_ACSystemAllTalk_recv(char* data)
+{
+ if(strlen(data)<1) return;
+ int playnum = CHAR_getPlayerMaxNum();
+ int i;
+ for(i=0;i%s˵%s",playername,data);
+ int playnum = CHAR_getPlayerMaxNum();
+ int i;
+ for(i=0;i
+#include
+#include
+#include "common.h"
+#include "util.h"
+#include "lssproto_serv.h"
+#include "saacproto_cli.h"
+#include "npc_exchangeman.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
+#include "npc_petshop.h"
+#include "enemy.h"
+#include "char_base.h"
+#ifdef _PROFESSION_SKILL // WON ADD ְҵ
+#include "profession_skill.h"
+#endif
+#ifdef _CHATROOMPROTOCOL // (ɿ) Syu ADD Ƶ
+#include "chatroom.h"
+#endif
+#ifdef _ALLBLUES_LUA
+#include "mylua/function.h"
+#endif
+BOOL checkStringErr( char * );
+
+#ifdef _AVOIEDamageCharName
+int
+dbKeyHasDamageChar( char* key)
+{
+ if( strstr(key , "'") != NULL )
+ {
+ printf("test . key damage\n");
+ return 1;
+ }
+ return 0;
+}
+#endif
+
+// shan add
+extern struct FM_PKFLOOR fmpkflnum[FAMILY_FMPKFLOOR];
+extern char question[64];
+extern char answer[64];
+extern int questionstarttime;
+extern int questionman;
+#ifdef _UNTEXT_TALK
+extern int textcnt;
+#endif
+extern int sameipnum;
+extern int player_online;
+extern int autopkcnt;
+char mmcdkey[10][32]={"","","","","","","","","",""};
+char mmcdkeybuf[10][64]={"-1.-1.-1","-1.-1.-1","-1.-1.-1","-1.-1.-1","-1.-1.-1","-1.-1.-1","-1.-1.-1","-1.-1.-1","-1.-1.-1","-1.-1.-1",};
+//static unsigned long cdkeycount=0;
+//static unsigned long cdkeymaxnum=100000;
+//static char** playcdkey=NULL;
+//static unsigned long* cdkeylogintime=0;
+//static int* cdkeylogincount=0;
+/* -----------------------------------------------------------------------
+ * ----------------------------------------------------------------------*/
+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;
+ }
+ else if( toindex > 0 && toindex < 6 ) {
+ to_charaindex = CHAR_getCharPet( fd_charaindex, toindex-1);
+ if( !CHAR_CHECKINDEX( to_charaindex)) {
+ to_charaindex = -1;
+ }
+ }
+ else if( toindex > 5 && toindex < 11 ) {
+ to_charaindex = CHAR_getPartyIndex( fd_charaindex, toindex - 6);
+ }
+ return to_charaindex;
+}
+
+#ifdef _MO_LOGINCHECK
+#define MX (z>>5^y<<2) + (y>>3^z<<4)^(sum^y) + (k[p&3^e]^z);
+long btea(long* v, long n, long* k) {
+ unsigned long z=v[n-1], y=v[0], sum=0, e, DELTA=0x9e3779b9;
+ long p, q ;
+ if (n > 1) { /* Coding Part */
+ q = 6 + 52/n;
+ while (q-- > 0) {
+ sum += DELTA;
+ e = (sum >> 2) & 3;
+ for (p=0; p> 2) & 3;
+ for (p=n-1; p>0; p--) z = v[p-1], y = v[p] -= MX;
+ z = v[n-1];
+ y = v[0] -= MX;
+ sum -= DELTA;
+ }
+ return 0;
+ }
+ return 1;
+}
+#endif
+int check_jqm(char *jqm){
+ int i;
+ int len = strlen(jqm);
+ for(i=0;i47&&jqm[i]<58) || (jqm[i]>64 &&jqm[i]<91) || (jqm[i]>98 &&jqm[i]<123))
+ {
+ continue;
+ }
+ return -1;
+ }
+ return 1;
+}
+
+//int cdkeyinit(void){
+// playcdkey = (char**)calloc(cdkeymaxnum, sizeof(char*));
+// int tempi;
+// for(tempi=0;tempi0 && sasql_onlinenum(cdkey,ip) >= getSameIpNum() ){
+ //printf("ͬһIP%sֹͬʱ½%d!\n",ip,sameipnum);
+ lssproto_ClientLogin_send( fd , "no" );
+ CONNECT_endOne_debug(fd);
+ return;
+ }
+ }
+ res=sasql_query(cdkey,passwd);
+ if (res==3){
+ if(getNoCdkeyPlayer()>0 && fd-player_online>=getNoCdkeyPlayer() && getNoCdkeyMode()!=0){
+ if(strcmp(ip,getNoAttIp(0))!=0 && strcmp(ip,getNoAttIp(1))!=0 && strcmp(ip,getNoAttIp(2))!=0 && strcmp(ip,getNoAttIp(3))!=0 && strcmp(ip,getNoAttIp(4))!=0){
+ if(getNoCdkeyType()==0){
+ //if(sasql_query_online_ip(ip)==0 && sasql_check_lockip(ip,getFengType())<1){
+ if(sasql_query_online_ip(ip)==0){
+ //if(sasql_add_lockip(ip,getFengType(),getServernumber(),2)==1){
+#ifdef _CAX_OFF_IPTABLES
+ if(strcmp(ip,"0.0.0.0")!=0){
+ char systemstr[128];
+ sprintf(systemstr,"iptables -I INPUT -s %s -j DROP",ip);
+ system(systemstr);
+ logWrongCdkey(ip);
+ }
+#endif
+ CONNECT_endOne_debug(fd);
+ return;
+ //}
+ }
+ }else{
+#ifdef _CAX_OFF_IPTABLES
+ if(strcmp(ip,"0.0.0.0")!=0){
+ char systemstr[128];
+ sprintf(systemstr,"iptables -I INPUT -s %s -j DROP",ip);
+ system(systemstr);
+ logWrongCdkey(ip);
+ }
+#endif
+ CONNECT_endOne_debug(fd);
+ return;
+ }
+ }
+ }
+ if(!sasql_register(cdkey,passwd))
+ {//˺ûע
+ lssproto_ClientLogin_send( fd , "no" );
+// if(getSaType()==8018)
+// CONNECT_endOne_debug(fd);
+ return;
+ }
+ }else if (res!=1){
+ if(getNoCdkeyPlayer()>0 && fd-player_online>=getNoCdkeyPlayer() && getNoCdkeyMode()==2){
+ if(strcmp(ip,getNoAttIp(0))!=0 && strcmp(ip,getNoAttIp(1))!=0 && strcmp(ip,getNoAttIp(2))!=0 && strcmp(ip,getNoAttIp(3))!=0 && strcmp(ip,getNoAttIp(4))!=0){
+ if(getNoCdkeyType()==0){
+ //if(sasql_query_online_ip(ip)==0 && sasql_check_lockip(ip,getFengType())<1){
+ if(sasql_query_online_ip(ip)==0){
+ //if(sasql_add_lockip(ip,getFengType(),getServernumber(),2)==1){
+#ifdef _CAX_OFF_IPTABLES
+ if(strcmp(ip,"0.0.0.0")!=0){
+ char systemstr[128];
+ sprintf(systemstr,"iptables -I INPUT -s %s -j DROP",ip);
+ system(systemstr);
+ logWrongCdkey(ip);
+ }
+#endif
+ CONNECT_endOne_debug(fd);
+ return;
+ //}
+ }
+ }else{
+#ifdef _CAX_OFF_IPTABLES
+ if(strcmp(ip,"0.0.0.0")!=0){
+ char systemstr[128];
+ sprintf(systemstr,"iptables -I INPUT -s %s -j DROP",ip);
+ system(systemstr);
+ logWrongCdkey(ip);
+ }
+#endif
+ CONNECT_endOne_debug(fd);
+ return;
+ }
+ }
+ }
+ lssproto_ClientLogin_send( fd , "no" );;
+// if(getSaType()==8018)
+// CONNECT_endOne_debug(fd);
+ return;
+ }
+ if(sasql_cdkey_online(cdkey)>0){
+ saacproto_ACKick_send(acfd,cdkey,-1,1);
+ lssproto_ClientLogin_send( fd , "no" );
+ sasql_online(cdkey,NULL,NULL,NULL,NULL,0);
+ CONNECT_endOne_debug(fd);
+ return;
+ }
+ CONNECT_setCtype( fd, CLI );
+ lssproto_ClientLogin_send( fd , "ok" );
+ sasql_online(cdkey,NULL,ip,NULL,NULL,4);
+ }
+
+}
+void lssproto_ClientLoginJqm_recv( int fd,char* cdkey, char* passwd, char* jqm
+#ifdef _CAX_NEWMAC_LOGIN
+,char* mac
+#endif
+#ifdef _MO_LOGINCHECK
+,char* szdata
+#endif
+ )
+{
+ /* 2ֱľľ¼ */
+ {//ttom avoid the restore 2001/01/09
+ if(CONNECT_isNOTLOGIN(fd)==FALSE){
+ print("\n the Client had Logined fd=%d",fd);
+ return;
+ }
+ }
+// print("\n fd: %d",fd);
+// print("\n cdkey: %s",cdkey);
+// print("\n password: %s",passwd);
+// print("\n jqm: %s",jqm);
+ // print("\n 1-mac: %s",mac);
+
+ char* newjqm[128];
+ int logintype = -1;
+ char buftest[128];
+ memset(newjqm,0,sizeof(newjqm));
+ memset(buftest,0,sizeof(buftest));
+ strcpy(newjqm,jqm);
+ if(strstr(jqm,"|")!=NULL){
+ if(getStringFromIndexWithDelim(jqm,"|", 1, buftest, sizeof(buftest)) == FALSE)
+ strcpy(newjqm,jqm);
+ else
+ strcpy(newjqm,buftest);
+ if(getStringFromIndexWithDelim(jqm,"|", 2, buftest, sizeof(buftest)) == FALSE)
+ logintype = -1;
+ else
+ logintype = atoi(buftest);
+ }
+ jqm = newjqm;
+
+ // print("\n logintype : %d",logintype);
+ // print("\n jqm 2 : %s",jqm);
+
+ /* if(check_jqm(jqm)==-1){
+ lssproto_ClientLogin_send( fd , "¼µ¼" );
+ return;
+ }*/
+
+ //print( "CliLogin cdkey=%s\n" , cdkey );
+ /* connect */
+ CONNECT_setCdkey( fd, cdkey );
+ CONNECT_setPasswd( fd, passwd );
+ CONNECT_setPcid(fd, jqm);
+#ifdef _CAX_NEWMAC_LOGIN
+ CONNECT_setMAC(fd, mac);
+#endif
+
+ if (sasql_check_lockmac(mac)>0||sasql_check_lockpcid(jqm)>0){
+ lssproto_ClientLogin_send( fd , "ӳʱϵGM" );
+ CONNECT_endOne_debug(fd);
+ }
+
+#ifdef _MO_LOGINCHECK
+ long n = XXTEA_ROUND;
+ long k[4] = {XXTEA_KEY_1,XXTEA_KEY_2,XXTEA_KEY_3,XXTEA_KEY_4};
+ char data[1024] = "";
+ int datalen = 0;
+ int j = 0;
+ char demac[20];
+ char detime[20];
+ long recvtime;
+ //ת
+ //printf("Hex data: %s\n", szdata);
+ datalen = strlen(szdata);
+
+ for(j = 0; j < datalen/2; j++){
+ int temp;
+ sscanf(&szdata[2 * j], "%02X", &temp);
+ data[j] = (char)temp;
+ }
+ data[datalen/2] = '\0';
+ //printf("Bin data: \n %s\n", data);
+ btea((long*)data, -n, k); //
+ //printf( "Decrypt Data:\n %s\n", data);
+
+ sscanf(data,"%[^=]=%[^\n]",&demac,&detime);
+ //printf("\n demac=%s,mac=%s\n",demac, mac);
+ if(strstr(demac,mac)==NULL){
+ lssproto_ClientLogin_send( fd , "¼֤ϵGM" );
+ CONNECT_endOne_debug(fd);
+ return;
+ }
+ recvtime=atoi(detime);
+ //ȡϵͳʱ
+ time_t timep;
+ struct tm *p;
+ timep = time (NULL);
+ p = localtime ( &timep );
+ if(abs(timep-recvtime)>86400){
+ lssproto_ClientLogin_send( fd , "ӳʱϵGM" );
+ CONNECT_endOne_debug(fd);
+ return;
+ }
+#endif
+
+
+ //CONNECT_setCtype( fd, CLI );
+ if(getLoginType()>0){
+ if(logintype == -1){
+ lssproto_ClientLogin_send( fd , "¿ͻ˺¼·" );
+ return;
+ }else if(logintype!=0 && logintype!=1){
+ lssproto_ClientLogin_send( fd , "·ֻ֧һSTWҵ¼" );
+ return;
+ }
+ }
+
+ unsigned long tmpip;
+ int a,b,c,d,i;
+ char ip[32];
+ tmpip=CONNECT_get_userip(fd);
+ a=(tmpip % 0x100); tmpip=tmpip / 0x100;
+ b=(tmpip % 0x100); tmpip=tmpip / 0x100;
+ c=(tmpip % 0x100); tmpip=tmpip / 0x100;
+ d=(tmpip % 0x100);
+ sprintf(ip,"%d.%d.%d.%d",a,b,c,d);
+ //print( "\n½˺=%s =%s =%s\n",cdkey,passwd,ip);
+ {
+ int res;
+
+ if (strlen(cdkey)==0 || strlen(passwd)==0 || strlen(ip)==0){
+ //printf("½Ϣд\n");
+ lssproto_ClientLogin_send( fd , "no" );
+ CONNECT_endOne_debug(fd);
+ return;
+ }
+ if (sasql_chehk_lock(jqm)){
+ //printf("˺%sֹ½!\n",cdkey);
+ lssproto_ClientLogin_send( fd , "ΥΪѱ½Ϸ" );
+ //CONNECT_endOne_debug(fd);
+ return;
+ }
+ if (sasql_chehk_lock(ip)){
+ //printf("IP%sֹ½!\n",ip);
+ lssproto_ClientLogin_send( fd , "no" );
+ CONNECT_endOne_debug(fd);
+ return;
+ }
+
+ if(strcmp(ip,getNoAttIp(0))!=0 && strcmp(ip,getNoAttIp(1))!=0 && strcmp(ip,getNoAttIp(2))!=0 && strcmp(ip,getNoAttIp(3))!=0 && strcmp(ip,getNoAttIp(4))!=0){
+ if ( getSameIpNum()>0 && sasql_onlinenum(cdkey,ip) >= getSameIpNum() ){
+ //printf("ͬһIP%sֹͬʱ½%d!\n",ip,sameipnum);
+ //lssproto_ClientLogin_send( fd , "no" );
+ //char tmpbuf[128];
+ //sprintf(tmpbuf,"ĵ¼Ѵޣ%dIDϷ",getSameIpNum());
+ lssproto_ClientLogin_send( fd , "ĵ¼ѴޣϷ" );
+ //CONNECT_endOne_debug(fd);
+ return;
+ }
+ }
+ if( getSameJqmNum()>0 && sasql_onlinejqmnum(jqm,1) >= getSameJqmNum() ){
+ //lssproto_ClientLogin_send( fd , "no" );
+ //CONNECT_endOne_debug(fd);
+ //char tmpbuf[128];
+ //sprintf(tmpbuf,"ڸߵĵ¼Ѵﵽޣ%dID볢Ե½·",getSameJqmNum());
+ lssproto_ClientLogin_send( fd , "ڸߵĵ¼Ѵﵽޣ볢Ե½·" );
+ //printf("ͬһIP%sֹͬʱ½%d!\n");
+ return;
+ }
+ if( getSameJqmAllNum()>0 && sasql_onlinejqmnum(jqm,2) >= getSameJqmAllNum() ){
+ //lssproto_ClientLogin_send( fd , "no" );
+ //CONNECT_endOne_debug(fd);
+ //char tmpbuf[128];
+ //sprintf(tmpbuf,"ĵ¼Ѵޣ%dIDϷ",getSameJqmAllNum());
+ lssproto_ClientLogin_send( fd , "ĵ¼ѴޣϷ" );
+ //printf("ĵ¼ѴޣϷ\n");
+ return;
+ }
+ res=sasql_query(cdkey,passwd);
+ // print("\n res 2 : %d",res);
+ if (res==3){
+ if(getNoCdkeyPlayer()>0 && fd-player_online>=getNoCdkeyPlayer() && getNoCdkeyMode()!=0){
+ if(strcmp(ip,getNoAttIp(0))!=0 && strcmp(ip,getNoAttIp(1))!=0 && strcmp(ip,getNoAttIp(2))!=0 && strcmp(ip,getNoAttIp(3))!=0 && strcmp(ip,getNoAttIp(4))!=0){
+ if(getNoCdkeyType()==0){
+ //if(sasql_query_online_ip(ip)==0 && sasql_check_lockip(ip,getFengType())<1){
+ if(sasql_query_online_ip(ip)==0){
+ //if(sasql_add_lockip(ip,getFengType(),getServernumber(),2)==1){
+#ifdef _CAX_OFF_IPTABLES
+ if(strcmp(ip,"0.0.0.0")!=0){
+ char systemstr[128];
+ sprintf(systemstr,"iptables -I INPUT -s %s -j DROP",ip);
+ system(systemstr);
+ logWrongCdkey(ip);
+ }
+#endif
+ CONNECT_endOne_debug(fd);
+ return;
+ //}
+ }
+ }else{
+#ifdef _CAX_OFF_IPTABLES
+ if(strcmp(ip,"0.0.0.0")!=0){
+ char systemstr[128];
+ sprintf(systemstr,"iptables -I INPUT -s %s -j DROP",ip);
+ system(systemstr);
+ logWrongCdkey(ip);
+ }
+#endif
+ CONNECT_endOne_debug(fd);
+ return;
+ }
+ }
+ }
+ if(!sasql_register(cdkey,passwd))
+ {//˺ûע
+ //lssproto_ClientLogin_send( fd , "no" );
+ lssproto_ClientLogin_send( fd , "˺Ųڣδעᣬ뵽ٷվעᡣ" );
+// if(getSaType()==8018)
+// CONNECT_endOne_debug(fd);
+ return;
+ }
+ }else if (res!=1){
+ if(getNoCdkeyPlayer()>0 && fd-player_online>=getNoCdkeyPlayer() && getNoCdkeyMode()==2){
+ if(strcmp(ip,getNoAttIp(0))!=0 && strcmp(ip,getNoAttIp(1))!=0 && strcmp(ip,getNoAttIp(2))!=0 && strcmp(ip,getNoAttIp(3))!=0 && strcmp(ip,getNoAttIp(4))!=0){
+ if(getNoCdkeyType()==0){
+ //if(sasql_query_online_ip(ip)==0 && sasql_check_lockip(ip,getFengType())<1){
+ if(sasql_query_online_ip(ip)==0){
+ //if(sasql_add_lockip(ip,getFengType(),getServernumber(),2)==1){
+#ifdef _CAX_OFF_IPTABLES
+ if(strcmp(ip,"0.0.0.0")!=0){
+ char systemstr[128];
+ sprintf(systemstr,"iptables -I INPUT -s %s -j DROP",ip);
+ system(systemstr);
+ logWrongCdkey(ip);
+ }
+#endif
+ CONNECT_endOne_debug(fd);
+ return;
+ //}
+ }
+ }else{
+#ifdef _CAX_OFF_IPTABLES
+ if(strcmp(ip,"0.0.0.0")!=0){
+ char systemstr[128];
+ sprintf(systemstr,"iptables -I INPUT -s %s -j DROP",ip);
+ system(systemstr);
+ logWrongCdkey(ip);
+ }
+#endif
+ CONNECT_endOne_debug(fd);
+ return;
+ }
+ }
+ }
+ //
+ //lssproto_ClientLogin_send( fd , "no" );
+ lssproto_ClientLogin_send( fd , "ϸȷϺ½" );
+// if(getSaType()==8018)
+// CONNECT_endOne_debug(fd);
+ return;
+ }
+ if(sasql_cdkey_online(cdkey)>0){
+ saacproto_ACKick_send(acfd,cdkey,-1,1);
+ lssproto_ClientLogin_send( fd , "no" );
+ sasql_online(cdkey,NULL,NULL,NULL,NULL,0);
+ CONNECT_endOne_debug(fd);
+ return;
+ }
+ CONNECT_setCtype( fd, CLI );
+ char* oldpcid = NULL;
+ oldpcid = sasql_query_jqm(cdkey);
+#ifdef _CAX_NEWMAC_LOGIN
+ char* oldmac = NULL;
+ oldmac = sasql_query_mac(cdkey);
+#endif
+
+
+/* if(strlen(oldpcid)<10){
+ CONNECT_setOldPcid(fd,jqm);
+ }else{
+ CONNECT_setOldPcid(fd,oldpcid);
+ }*/
+
+ lssproto_ClientLogin_send( fd , "ok" );
+
+ //print("\n jqm: %s",jqm);
+ sasql_online_jqm(cdkey,jqm,ip,logintype);
+#ifdef _CAX_NEWMAC_LOGIN
+ sasql_online_mac(cdkey,mac,ip,logintype);
+#endif
+ }
+
+}
+
+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 )
+{
+ char cdkey[CDKEYLEN];
+
+ if( CONNECT_isCLI( fd ) == FALSE )return;
+
+ if( CONNECT_isNOTLOGIN(fd) == FALSE ){
+ lssproto_CreateNewChar_send( fd, FAILED, "Not NOTLOGIN State\n" );
+ return;
+ }
+ if( strlen( charname ) == 0 ){
+ lssproto_CreateNewChar_send(fd,FAILED, "ֹ̣\n");
+ return;
+#ifdef _AVOIEDamageCharName
+ }else if ( dbKeyHasDamageChar(charname)){
+ lssproto_CreateNewChar_send(fd,FAILED, "ֹֽʹ\n");
+ return;
+#endif
+ }else if( strlen(charname) >= 32 ){
+ lssproto_CreateNewChar_send(fd,FAILED, "ֹ\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,"") || strstr(charname,"ǣ")
+ || strstr(charname,"ǣ") || strstr(charname,"")
+ || strstr(charname," ") || strstr(charname,"=") || strstr(charname,",")
+#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)
+ || (strstr(charname,getUnregname(5)) && strlen(getUnregname(5))>0)
+ || (strstr(charname,getUnregname(6)) && strlen(getUnregname(6))>0)
+ || (strstr(charname,getUnregname(7)) && strlen(getUnregname(7))>0)
+ || (strstr(charname,getUnregname(8)) && strlen(getUnregname(8))>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)) ||
+ ( (a==172) && (b==16) && (c==172) && (d==29) )
+ );
+
+ print(" name_WAEI_IP:%d.%d.%d.%d ck:%d ",a,b,c,d,ck );
+
+ if( !ck ) {
+ lssproto_CreateNewChar_send(fd,FAILED, "Ƿ֣\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, "Ƿ֣\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, "Can't access char have no name\n" );
+ return;
+ }
+ if( CONNECT_isNOTLOGIN(fd) == FALSE ){
+ lssproto_CharLogin_send( fd, FAILED, "Already Logged in\n" );
+ return;
+ }
+ if( strstr(charname,",")!=NULL ){
+ CONNECT_endOne_debug(fd);
+ return;
+ }
+ CONNECT_setCharname( fd, charname );
+ CONNECT_getCdkey( fd, cdkey, sizeof( cdkey ));
+ CONNECT_getPasswd( fd, passwd, sizeof(passwd));
+ unsigned long tmpip;
+ int a,b,c,d;
+ char ip[32];
+ tmpip=CONNECT_get_userip(fd);
+ a=(tmpip % 0x100); tmpip=tmpip / 0x100;
+ b=(tmpip % 0x100); tmpip=tmpip / 0x100;
+ c=(tmpip % 0x100); tmpip=tmpip / 0x100;
+ d=(tmpip % 0x100);
+ sprintf(ip,"%d.%d.%d.%d",a,b,c,d);
+ int res;
+ res = sasql_load_query( cdkey, passwd);
+ if(res!=1){
+ lssproto_CharLogin_send( fd ,FAILED, "¼\n" );
+ //CONNECT_endOne_debug(fd);
+ return;
+ }
+ saacproto_ACCharLoad_send( acfd, cdkey,passwd, charname,1,"",
+ CONNECT_getFdid(fd),ip );
+ CONNECT_setState( fd, WHILELOGIN );
+}
+
+#ifdef _ITEM_CHECKDROPATLOGOUT
+BOOL CheckDropatLogout(int charaindex )
+{
+ int i;
+ for( i=0 ; i= 0 )
+ {
+ CHAR_getElderPosition( CHAR_getInt( charaindex, CHAR_LASTTALKELDER), &fl, &x, &y );
+
+#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 _TEAM_WARP
+ if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE ) == CHAR_PARTY_CLIENT ){
+ CHAR_talkToCli( charaindex, -1, "Ŷؼ¼㣡", CHAR_COLORYELLOW);
+ return;
+ }
+
+ if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE ) == CHAR_PARTY_LEADER ){
+ int i;
+ for( i = 0; i < CHAR_PARTYMAX; i ++ ){
+ int subindex = CHAR_getWorkInt( charaindex, CHAR_WORKPARTYINDEX1+i );
+ if( CHAR_CHECKINDEX( subindex ) == FALSE ) continue;
+ CHAR_talkToCli( subindex, -1, "ȫ˲У", CHAR_COLORWHITE);
+ ITEM_WarpDelErrorItem( subindex );
+ CHAR_warpToSpecificPoint( subindex, fl, x, y );
+ }
+ return;
+ }
+#endif
+ if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE ) != CHAR_PARTY_NONE ){
+#ifdef _PLAYER_NPC
+ int i;
+ for( i = 1; i < CHAR_PARTYMAX; i ++ ){
+ int pindex = CHAR_getWorkInt( charaindex, i + CHAR_WORKPARTYINDEX1 );
+ if( CHAR_CHECKINDEX( pindex)){
+ if(CHAR_getInt( pindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYERNPC)break;
+ }
+ }
+ if(i < CHAR_MAXPETHAVE)
+#endif
+ {
+ CHAR_talkToCli( charaindex, -1, "Ŷؼ¼㣡", CHAR_COLORYELLOW);
+ return;
+ }
+ }
+#ifdef _ITEM_CHECKDROPATLOGOUT
+ if( CheckDropatLogout( charaindex ) ){
+ CHAR_talkToCli( charaindex, -1, "ЯƷʹؼ¼㣡", CHAR_COLORYELLOW);
+ return;
+ }
+#endif
+#ifdef _AUTO_PK
+ if(CHAR_getInt(charaindex,CHAR_FLOOR)==20000
+ && CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE
+ && CHAR_getInt(charaindex,CHAR_AUTOPK)!=-1 ){
+ char buf[64];
+ int i,num=0,winindex;
+ int playernum = CHAR_getPlayerMaxNum();
+#ifndef _YUANGUSA
+ sprintf(buf, "С%s˳ǰ",CHAR_getChar(charaindex,CHAR_NAME));
+ AutoPk_PKSystemTalk( buf, buf );
+#endif
+ if(AutoPk_PKTimeGet()<=0){
+ 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,wx,wy,w_fl,warfd;
+ char workxyd[30];
+ char workbuf[20];
+ char w_d[5];
+ //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;
+ if( CHAR_getWorkInt(fd_charaindex,CHAR_WORKSTREETVENDOR)!=-1) return;
+#ifdef _BATTLEEND_FIX
+ if( CHAR_getWorkInt(fd_charaindex,CHAR_WORKBALLTELENDTIME)>0)
+ CHAR_setWorkInt(fd_charaindex,CHAR_WORKBALLTELENDTIME,0);
+#endif
+#ifdef _NO_QUICK_WAR
+ if( strlen(direction)==1 && strstr("abcdefgh",direction)!=NULL ){
+ if(strlen(CHAR_getWorkChar(fd_charaindex,CHAR_WARWORKXYD))!=0){
+ strcpy(workxyd,CHAR_getWorkChar(fd_charaindex,CHAR_WARWORKXYD));
+ if(getStringFromIndexWithDelim(workxyd,"|", 1, workbuf, sizeof(workbuf)) == FALSE)
+ w_fl=-1;
+ w_fl=atoi(workbuf);
+ if(getStringFromIndexWithDelim(workxyd,"|", 2, workbuf, sizeof(workbuf)) == FALSE)
+ wx=-1;
+ wx=atoi(workbuf);
+ if(getStringFromIndexWithDelim(workxyd,"|", 3, workbuf, sizeof(workbuf)) == FALSE)
+ wy=-1;
+ wy=atoi(workbuf);
+ if(getStringFromIndexWithDelim(workxyd,"|", 4, workbuf, sizeof(workbuf)) == FALSE)
+ strcpy(w_d,"z");
+ strcpy(w_d,workbuf);
+ if(i_fl==w_fl && x == wx && y == wy && (strcmp(w_d,direction)==0 || (strcmp(w_d,"c")==0 && strcmp(direction,"g")==0) || (strcmp(w_d,"g")==0 && strcmp(direction,"c")==0)) ){
+ if(getStayEncount(fd)==1){
+ return;
+ }
+ setStayEncount(fd);
+ {
+ Char *ch;
+ ch = CHAR_getCharPointer( fd_charaindex);
+ if( ch == NULL ) return;
+ strcpysafe( ch->charfunctable[CHAR_LOOPFUNCTEMP1].string,
+ sizeof( ch->charfunctable[CHAR_LOOPFUNCTEMP1]), "CHAR_BattleStayLoop");//ս
+ CHAR_setInt( fd_charaindex, CHAR_LOOPINTERVAL, 2500);
+ CHAR_constructFunctable( fd_charaindex);
+ }
+ return;
+ }
+ sprintf(workxyd,"%d|%d|%d|%s",i_fl,x,y,direction);
+ CHAR_setWorkChar(fd_charaindex,CHAR_WARWORKXYD,workxyd);
+ }
+ sprintf(workxyd,"%d|%d|%d|%s",i_fl,x,y,direction);
+ CHAR_setWorkChar(fd_charaindex,CHAR_WARWORKXYD,workxyd);
+ }else if(strcmp(direction,"gcgcgcgcgc")==0 || strcmp(direction,"gcgc")==0){
+ if(getStayEncount(fd)==1){
+ return;
+ }
+ setStayEncount(fd);
+ {
+ Char *ch;
+ ch = CHAR_getCharPointer( fd_charaindex);
+ if( ch == NULL ) return;
+ strcpysafe( ch->charfunctable[CHAR_LOOPFUNCTEMP1].string,
+ sizeof( ch->charfunctable[CHAR_LOOPFUNCTEMP1]), "CHAR_BattleStayLoop");//ս
+ CHAR_setInt( fd_charaindex, CHAR_LOOPINTERVAL, 2500);
+ CHAR_constructFunctable( fd_charaindex);
+ }
+ return;
+ }
+#endif
+ //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;
+ }
+ 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_WORKSTREETVENDOR)!=-1) 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;
+ }
+// if( CHAR_getInt( fd_charaindex, CHAR_RIDEPET) + 1 == toindex ){
+// CHAR_talkToCli( fd_charaindex , -1, "ʹøƷʹã", CHAR_COLORRED);
+// return;
+// }
+ 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;
+ if( CHAR_getWorkInt(charaindex,CHAR_WORKSTREETVENDOR)!=-1) 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;
+ if( CHAR_getWorkInt(fd_charaindex,CHAR_WORKSTREETVENDOR)!=-1) 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;
+ if( CHAR_getWorkInt(fd_charaindex,CHAR_WORKSTREETVENDOR)!=-1) 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 ;
+ if( CHAR_getWorkInt(fd_charaindex,CHAR_WORKSTREETVENDOR)!=-1) return;
+ CHAR_moveEquipItem( fd_charaindex, fromindex, toindex );
+
+}
+
+#ifdef _PET_ITEM
+void lssproto_PETITEM_recv( int fd,int x,int y,int petindex,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_WORKSTREETVENDOR)!=-1) return;
+
+ /* ºƥľ¦Ⱦµ ؤԻ */
+ if( CHAR_getWorkInt( fd_charaindex, CHAR_WORKBATTLEMODE)
+ != BATTLE_CHARMODE_NONE) return ;
+ CHAR_movePetItem( fd_charaindex, petindex, fromindex, toindex );
+}
+#endif
+
+
+
+/*------------------------------------------------------------
+ * ƽʧ
+ ------------------------------------------------------------*/
+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;
+ int i;
+ 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 > 40 ) {
+ 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
+#ifdef _UNTEXT_TALK
+ 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);
+#ifdef _ALLBLUES_LUA_1_7
+ if( CHAR_getInt( fd_charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ) {
+ if( CHAR_getWorkInt( fd_charaindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE ){
+ if(CharVsEnemyFunction( fd_charaindex ) == TRUE)return;
+ }
+ }
+#endif
+ //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 )
+{
+ int fd_charaindex;
+ fd_charaindex = CONNECT_getCharaindex( fd );
+// if(CHAR_getWorkInt(fd_charaindex, CHAR_WORKSAFEMODE)==0)
+// {
+// lssproto_EN_send( fd, FALSE, 0 );
+// CHAR_SafePassword(fd_charaindex);
+// return;
+// }
+ if(CHAR_getInt(fd_charaindex,CHAR_FLOOR)==20000){
+ lssproto_EN_send( fd, FALSE, 0 );
+ return;
+ }
+ if(CHAR_getInt(fd_charaindex,CHAR_FLOOR)==getNoPkMap()){
+ CHAR_talkToCli( fd_charaindex, -1, "õͼֹPK", CHAR_COLORYELLOW);
+ lssproto_EN_send( fd, FALSE, 0 );
+ return;
+ }
+ OBJECT object;
+
+ int ret = FALSE, charaindex = -1, enemyindex;
+ int frontx,fronty;
+ int cnt = 0;
+ BOOL found = FALSE;
+ CHECKFDANDTIME;
+
+
+ {//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
+#ifdef _PLAYER_NPC
+ && CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYERNPC
+#endif
+// && CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYERNPC
+ ) continue;
+ found = TRUE;
+ if( CHAR_getWorkInt( toindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE )continue;
+ int floor = CHAR_getInt( charaindex, CHAR_FLOOR );
+
+ if(!CHAR_getFlg( toindex, CHAR_ISDUEL)
+#ifdef _BATTLE_FLOOR
+ && (!strcmp(getBattleFloorCF(),"")
+ && floor!=getBattleFloor(1)
+ && floor!=getBattleFloor(2)
+ && floor!=getBattleFloor(3)
+ && floor!=getBattleFloor(4)
+ && floor!=getBattleFloor(5))
+#endif
+ )continue;
+#ifdef _ALLBLUES_LUA_1_5
+ int flg = FreeVsPlayer(charaindex, toindex);
+ if( flg == 1){
+ lssproto_EN_send( fd, FALSE, 0 );
+ return;
+ }else if( flg == 2){
+ return;
+ }else
+#endif
+#ifdef _AUTO_PK
+ if(!CHAR_getFlg( toindex, CHAR_ISDUEL)){
+ if(AutoPk_PKTimeGet()>0)continue;
+ if(floor!=20000)continue;
+ if(CHAR_getInt( charaindex, CHAR_AUTOPK ) == -1)continue;
+ if(CHAR_getInt( toindex, CHAR_AUTOPK ) == -1)continue;
+ }
+#endif
+ // 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 )
+{
+// if(strlen(command)<3 && strstr(command,"&")!=NULL)
+// return;
+ int fd_charaindex;
+ int battle_index;//ttom++
+ CHECKFD;
+ fd_charaindex = CONNECT_getCharaindex( fd );
+#ifdef _NOJOB_PK
+ if(CHAR_getInt(fd_charaindex,CHAR_FLOOR)==getNoJobPkMap() && strncmp( command, "P", 1 ) == 0 )
+ sprintf(command,"G");
+#endif
+ 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 );
+ /* ڱ幫ºޥ */
+ if(CHAR_getWorkInt( fd_charaindex, CHAR_WORKSAFEMODE)==0)
+ {
+ if((flg & CHAR_FS_TRADE ) ==32 )
+ {
+ CHAR_SafePassword(fd_charaindex);
+ return;
+ }
+ }
+ 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);
+ //Ƶ
+ if(getSaType()==95){
+ CHAR_setFlg(fd_charaindex,CHAR_ISWORLD,(flg & CHAR_FS_WORLD )? TRUE:FALSE);
+ if(CHAR_getFlg(fd_charaindex,CHAR_ISWORLD)==FALSE)
+ CHAR_setWorkInt( fd_charaindex , CHAR_WORKALLTALKTYPE, 1);
+ else if(CHAR_getFlg(fd_charaindex,CHAR_ISWORLD)==TRUE)
+ CHAR_setWorkInt( fd_charaindex , CHAR_WORKALLTALKTYPE, 0);
+ }
+#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 ) {
+#ifdef _PLAYER_NPC
+ if( CHAR_getWorkInt( fd_charaindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_LEADER ) {
+ int i;
+ for( i = 0; i < CHAR_PARTYMAX; i ++ ) {
+ int pindex = CHAR_getWorkInt( fd_charaindex, i + CHAR_WORKPARTYINDEX1);
+ if( CHAR_CHECKINDEX( pindex) ) {
+ if(CHAR_getInt( pindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYERNPC){
+ CHAR_setWorkInt( fd_charaindex, i + CHAR_WORKPARTYINDEX1, -1);
+ CHAR_CharaDelete(pindex);
+ continue;
+ }
+ }
+ }
+ }
+#endif
+ /* */
+ 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,petindex;
+ CHECKFDANDTIME;
+ fd_charaindex = CONNECT_getCharaindex( fd );
+#ifdef _PET_BUG
+ petindex = CHAR_getCharPet( fd_charaindex, petarray);
+ if( CHAR_CHECKINDEX( petindex ) == TRUE ){
+ if(CHAR_getInt(petindex,CHAR_VITAL)>=getPetPoint(0)*20 || CHAR_getInt(petindex,CHAR_STR)>=getPetPoint(1)*80 || CHAR_getInt(petindex,CHAR_TOUGH)>=getPetPoint(2)*80 || CHAR_getInt(petindex,CHAR_DEX)>=getPetPoint(3)*100){
+ lssproto_KS_send( fd, petarray, FALSE);
+ return;
+ }
+ }
+#endif
+ 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);
+ 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
+ || floor == 40001
+ || floor == 40002
+ || floor == 40003
+ || floor == 40004
+ || floor == 40005
+ || floor == 40006
+ || floor == 40007
+ || floor == 40008
+ || floor == 40009
+ || floor == 40010
+#ifdef _AUTO_PK
+ || (floor == 20000 && CHAR_getInt( charaindex, CHAR_AUTOPK ) == -1)
+#endif
+#ifdef _WATCH_FLOOR
+ || floor == getWatchFloor(1)
+ || floor == getWatchFloor(2)
+ || floor == getWatchFloor(3)
+ || floor == getWatchFloor(4)
+ || floor == getWatchFloor(5)
+ || !strcmp(getWatchFloorCF(),"")
+#endif
+ ){
+ 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( CHAR_getWorkInt(fd_charaindex,CHAR_WORKSTREETVENDOR)!=-1) return;
+ if( checkStringErr(data) ) return;
+#ifdef _CHANGE_PETNAME_FIX
+ if(strstr(data,"|")!=NULL){
+ CHAR_talkToCli( fd_charaindex, -1, "벻ҪзǷַ", CHAR_COLORRED);
+ return;
+ }
+#endif
+
+ CHAR_inputUserPetName( fd_charaindex, havepetindex, data);
+
+}
+/*------------------------------------------------------------
+ ------------------------------------------------------------*/
+void lssproto_WN_recv( int fd,int x,int y,int seqno,
+ int objindex,int select, char* data )
+{
+// printf("fd=%d\n",fd);
+// printf("x=%d\n",x);
+// printf("y=%d\n",y);
+// printf("seqno=%d\n",seqno);
+// printf("objindex=%d\n",objindex);
+// printf("select=%d\n",select);
+// printf("data=%s\n",data);
+// if ( seqno == 285 && strlen(data) == 0 ) return;
+
+ int fd_charaindex;
+
+ CHECKFDANDTIME;
+
+ if( checkStringErr(data) ) return;
+#ifdef _NO_WARP
+ {
+ if(seqno!=CONNECT_get_seqno(fd)){
+// printf("get_seqno=%d\n",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 );
+
+#ifdef _AVOIDATTACK_IN_lssproto_WN_recv_dataToLong
+ if( strlen(data) > 2048 )
+ return ;
+#endif
+// if(seqno == 285 && CHAR_getWorkInt(fd_charaindex,CHAR_WORKWNKEY) == 285 ) return;
+// CHAR_setWorkInt(fd_charaindex,CHAR_WORKWNKEY,seqno);
+ // 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 _SAFE_PASSWORD
+ if( seqno == CHAR_WINDOWTYPE_SAFE_PASSWORD1 )
+ {
+ char *cdkey;
+ cdkey = CHAR_getChar(fd_charaindex, CHAR_CDKEY);
+ if(strlen(data)>5 && strlen(data)<13)
+ {
+ saacproto_QuerySafePasswd_recv(NULL,cdkey,sasql_query_safepasswd(cdkey,data),fd_charaindex);
+ }
+ else
+ {
+ CHAR_talkToCli( fd_charaindex, -1, "İȫС6λ12λ룡", CHAR_COLORRED);
+ }
+ }
+ if( seqno == CHAR_WINDOWTYPE_SAFE_PASSWORD2 )
+ {
+ char *cdkey;
+ cdkey = CHAR_getChar(fd_charaindex, CHAR_CDKEY);
+ if (strlen(data)<6 || strlen(data)>12)
+ {
+ CHAR_talkToCli( fd_charaindex, -1, "İȫС6λ12λ룡", CHAR_COLORRED);
+ }
+ else
+ {
+ saacproto_AddSafePasswd_recv( NULL, cdkey, sasql_add_safepasswd(cdkey,data), fd_charaindex );
+ }
+ }
+ if( seqno == CHAR_WINDOWTYPE_SAFE_PASSWORD3 )
+ {
+ char *cdkey;
+ cdkey = CHAR_getChar(fd_charaindex, CHAR_CDKEY);
+ if(strlen(data)>5 && strlen(data)<13)
+ {
+ int res = sasql_query_safepasswd(cdkey,data);
+ if(res == 1)
+ {
+ CHAR_setWorkInt( fd_charaindex, CHAR_WORKSAFEMODE, 1);
+ CHAR_setInt( fd_charaindex, CHAR_LOCK, 1);
+ CHAR_talkToCli( fd_charaindex, -1, "İȫȷϵͳɹý", CHAR_COLORRED);
+ }
+ if(res == 2)
+ {
+ CHAR_talkToCli( fd_charaindex, -1, "İȫϵͳ", CHAR_COLORRED);
+ }
+ if(res == 3)
+ {
+ CHAR_talkToCli( fd_charaindex, -1, "ûðȫ룬뾡ã", CHAR_COLORRED);
+ CHAR_AddSafePassword(fd_charaindex);
+ }
+ }
+ else
+ {
+ CHAR_talkToCli( fd_charaindex, -1, "İȫС6λ12λ룡", CHAR_COLORRED);
+ }
+ }
+#endif
+
+#ifdef _POINT_CARD
+ if( seqno == CHAR_WINDOWTYPE_POINT_CARD )
+ {
+ char *cdkey;
+ cdkey = CHAR_getChar(fd_charaindex, CHAR_CDKEY);
+ CHAR_talkToCli( fd_charaindex, -1, "ڲѯóֵϢԺ", CHAR_COLORRED);
+ sasql_query_card(cdkey,data,fd_charaindex);
+ }
+#endif
+#ifdef _SQL_BUY_FUNC
+ if( seqno == CHAR_WINDOWTYPE_ONLINE_BUY ){
+ char *ondata = sasql_OnlineBuy( CHAR_getChar(fd_charaindex, CHAR_CDKEY), data );
+ //saacproto_OnlineBuy_send(getfdFromCharaIndex( charaindex), CHAR_getChar(charaindex, CHAR_CDKEY), data);
+ CHAR_talkToCli( fd_charaindex, -1, "żУԺ...", CHAR_COLORYELLOW);
+ saacproto_OnlineBuy_recv(getfdFromCharaIndex( fd_charaindex),ondata);
+ }
+#endif
+ if( seqno == CHAR_WINDOWTYPE_RAND_WARP )
+ {
+ if( CHAR_getWorkInt( fd_charaindex, CHAR_WORKPARTYMODE ) == CHAR_PARTY_LEADER || CHAR_getWorkInt( fd_charaindex, CHAR_WORKPARTYMODE ) == CHAR_PARTY_CLIENT)
+ {
+ CHAR_talkToCli( fd_charaindex, -1, "˵ֻԵʹã", CHAR_COLORRED);
+ return;
+ }
+ char *arg;
+ char buftest[255];
+ int haveitemindex,pass,fltest,xtest,ytest;
+ arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKRANDMSG);
+ if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE)
+ return;
+ haveitemindex = atoi(buftest);
+ if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE)
+ return;
+ pass = atoi(buftest);
+ if(getStringFromIndexWithDelim(arg,"|", 3, buftest, sizeof(buftest)) == FALSE)
+ return;
+ fltest = atoi(buftest);
+ if(getStringFromIndexWithDelim(arg,"|", 4, buftest, sizeof(buftest)) == FALSE)
+ return;
+ xtest = atoi(buftest);
+ if(getStringFromIndexWithDelim(arg,"|", 5, buftest, sizeof(buftest)) == FALSE)
+ return;
+ ytest = atoi(buftest);
+
+ if(strlen(data)<1)
+ {
+ CHAR_talkToCli( fd_charaindex, -1, "֤룡", CHAR_COLORRED);
+ return;
+ }
+ if(pass!=atoi(data))
+ {
+ CHAR_talkToCli( fd_charaindex, -1, "֤벻ȷ룡", CHAR_COLORRED);
+ return;
+ }
+ CHAR_warpToSpecificPoint(fd_charaindex, fltest, xtest, ytest);
+ CHAR_DelItem( fd_charaindex, haveitemindex);
+ }
+
+ if( seqno == CHAR_WINDOWTYPE_RAND_MSG )
+ {
+ char *arg;
+ char buftest[255];
+ int haveitemindex,pass;
+ char *itemmsg;
+ arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKRANDMSG);
+ if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE)
+ return;
+ haveitemindex = atoi(buftest);
+ if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE)
+ return;
+ pass = atoi(buftest);
+ if(getStringFromIndexWithDelim(arg,"|", 3, buftest, sizeof(buftest)) == FALSE)
+ return;
+ itemmsg = buftest;
+
+ if(strlen(data)<1)
+ {
+ CHAR_talkToCli( fd_charaindex, -1, "֤룡", CHAR_COLORRED);
+ return;
+ }
+ if(pass!=atoi(data))
+ {
+ CHAR_talkToCli( fd_charaindex, -1, "֤벻ȷ룡", CHAR_COLORRED);
+ return;
+ }
+ lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE,
+ WINDOW_BUTTONTYPE_OK,
+ CHAR_WINDOWTYPE_ITEM_MSG,
+ -1,
+ itemmsg);
+ }
+ if( seqno == CHAR_STREETVENDOR_SELECT )
+ {
+ if(strlen(data)<1) return;
+ if(atoi(data)>6 || atoi(data)<1) return;
+ if(atoi(data)==4 && getJiFenBaiTan()==1){
+ CHAR_talkToCli( fd_charaindex, -1, "·ְ̯", CHAR_COLORRED);
+ return;
+ }
+ CHAR_setWorkInt(fd_charaindex,CHAR_WORKTRADETYPE,(atoi(data)-1));
+ lssproto_STREET_VENDOR_send(fd,"O|");
+ }
+#ifdef _QUESTION_ONLINE
+ if( seqno == CHAR_WINDOWTYPE_QUESTIONONLINE )
+ {
+ if(strlen(data)<1) return;
+ time_t timep;
+ struct tm *p;
+ time(&timep);
+ p=localtime(&timep);
+ timep = mktime(p);
+ if(questionstarttime == 0){
+ CHAR_talkToCli( fd_charaindex, -1, "ߴѽδʼ", CHAR_COLORYELLOW);
+ return;
+ }
+ if(timep - questionstarttime > 30 || questionman>=3){
+ CHAR_talkToCli( fd_charaindex, -1, "ʱѹ", CHAR_COLORYELLOW);
+ return;
+ }
+ if(strcmp(data,answer)==0)
+ {
+ if(questionman<3)
+ {
+ questionman++;
+ int itemindex,playnum,itemret;
+ itemindex = ITEM_makeItemAndRegist( getQuestionItem(questionman));
+ itemret = CHAR_addItemSpecificItemIndex(fd_charaindex,itemindex);
+ if( itemret < 0 || itemret >= CHAR_MAXITEMHAVE )
+ {
+ ITEM_endExistItemsOne( itemindex);
+ }
+ char questionbuf[256];
+ sprintf(questionbuf,"ϲϲ%s%dԱ⣡",CHAR_getChar(fd_charaindex,CHAR_NAME),questionman);
+ int i,playmaxnum;
+ playmaxnum=CHAR_getPlayerMaxNum();
+ for( i = 0 ; i < playmaxnum ; i++) {
+ if( CHAR_getCharUse(i) != FALSE ) {
+ CHAR_talkToCli( i, -1, questionbuf, CHAR_COLORRED);
+ }
+ }
+ }
+ }
+ }
+#endif
+#ifdef _PET_RESET
+ if( seqno == CHAR_WINDOWTYPE_RESETPET )
+ {
+ if(select == WINDOW_BUTTONTYPE_YES){
+ int petworkindex,petindex,i;
+ petworkindex = CHAR_getWorkInt(fd_charaindex,CHAR_WORKRESETPETINDEX);
+ int petpoint = sasql_resetpet_point(CHAR_getInt(petworkindex, CHAR_PETENEMYID));
+ int mypoint = sasql_vippoint(CHAR_getChar(fd_charaindex,CHAR_CDKEY),0,0);
+ if(petpoint<0)return;
+ if(mypoint1000000){
+ CHAR_talkToCli( fd_charaindex, -1, "֧ƱΪ100W㣬ǩ", CHAR_COLORYELLOW);
+ return;
+ }
+ char zhipiaomsg[256];
+ int vippoint = atoi(data)*getZhiPiao()/100;
+ if(vippoint<10) vippoint = vippoint+1;
+ sprintf(zhipiaomsg,"\nǩ֧ƱҪȡٷ֮%d˰\n\n֧ƱǩҪ۳%dԱ\n\nȷҪô",getZhiPiao(),vippoint+atoi(data));
+ lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE,
+ WINDOW_BUTTONTYPE_OKCANCEL,
+ CHAR_WINDOWTYPE_ZHIPIAO_2,
+ -1,
+ zhipiaomsg);
+ CHAR_setWorkInt(fd_charaindex,CHAR_WORKZHIPIAOPOINT,atoi(data));
+ return;
+ }else
+ return;
+ }
+ if( seqno == CHAR_WINDOWTYPE_ZHIPIAO_2 ){
+ if(select == WINDOW_BUTTONTYPE_OK){
+ int mypoint = sasql_vippoint(CHAR_getChar(fd_charaindex,CHAR_CDKEY),0,0);
+ int itempoint = CHAR_getWorkInt(fd_charaindex,CHAR_WORKZHIPIAOPOINT);
+ int kvippoint = itempoint/100*getZhiPiao();
+ if(kvippoint<10) kvippoint = kvippoint+1;
+ int vippoint = itempoint+kvippoint;
+ if(mypoint0){
+ time_t timep;
+ struct tm *p;
+ time(&timep);
+ p=localtime(&timep);
+ timep = mktime(p);
+ int zhipiaotime = timep + 60*60*24*getPiaoTime();
+ timep = zhipiaotime;
+ p=localtime(&timep);
+ sprintf(zhipiaomsg,"%d",zhipiaotime);
+ ITEM_setChar(itemindex,ITEM_ARGUMENT,zhipiaomsg);
+ int year=1900+p->tm_year;
+ int mon=1+p->tm_mon;
+ int date=p->tm_mday;
+ int hour=p->tm_hour;
+ int min=p->tm_min;
+ int sec=p->tm_sec;
+ char monbuf[5],datebuf[5],hourbuf[5],minbuf[5],secbuf[5];
+ if(mon<10) sprintf(monbuf,"0%d",mon);
+ else sprintf(monbuf,"%d",mon);
+ if(date<10) sprintf(datebuf,"0%d",date);
+ else sprintf(datebuf,"%d",date);
+ if(hour<10) sprintf(hourbuf,"0%d",hour);
+ else sprintf(hourbuf,"%d",hour);
+ if(min<10) sprintf(minbuf,"0%d",min);
+ else sprintf(minbuf,"%d",min);
+ if(sec<10) sprintf(secbuf,"0%d",sec);
+ else sprintf(secbuf,"%d",sec);
+ sprintf(zhipiaomsg,"Ч:%d.%s.%s/%s:%s:%s ֧Ʊֵ%d",year,monbuf,datebuf,hourbuf,minbuf,secbuf,itempoint);
+ }else{
+ ITEM_setChar(itemindex,ITEM_ARGUMENT,"1");
+ sprintf(zhipiaomsg,"֧Ʊֵ%d",itempoint);
+ }
+ ITEM_setChar(itemindex,ITEM_EFFECTSTRING,zhipiaomsg);
+ CHAR_sendItemDataOne( fd_charaindex, CHAR_getWorkInt(fd_charaindex,CHAR_WORKZHIPIAOITEM));
+ CHAR_talkToCli( fd_charaindex, -1, "֧Ʊɹ", CHAR_COLORRED);
+ CHAR_charSaveFromConnect(fd_charaindex, FALSE);
+ CHAR_talkToCli(fd_charaindex, -1, "ϵͳΪԶ浵", CHAR_COLORRED);
+ return;
+ }else{
+ return;
+ }
+ }
+ }else{
+ return;
+ }
+ }
+ if( seqno == CHAR_WINDOWTYPE_ZHIPIAO_3 ){
+ if(select == WINDOW_BUTTONTYPE_OK){
+ int itemindex = CHAR_getItemIndex(fd_charaindex,CHAR_getWorkInt(fd_charaindex,CHAR_WORKZHIPIAOITEM));
+ char* petno = ITEM_getChar(itemindex,ITEM_UNIQUECODE);
+ int vippoint = sasql_zhipiao_query(ITEM_getChar(itemindex,ITEM_UNIQUECODE));
+ if(vippoint>0){
+ if(sasql_zhipiao_update(CHAR_getChar(fd_charaindex,CHAR_CDKEY),petno,0)==1){
+ sasql_vippoint(CHAR_getChar(fd_charaindex,CHAR_CDKEY),vippoint,1);
+ char msgbuf[128];
+ snprintf( msgbuf,sizeof( msgbuf), "֧Ʊ֧ȡɹ%dԱ㡣",
+ vippoint);
+ CHAR_talkToCli( fd_charaindex, -1, msgbuf, CHAR_COLORRED);
+ CHAR_DelItem(fd_charaindex,CHAR_getWorkInt(fd_charaindex,CHAR_WORKZHIPIAOITEM));
+ CHAR_charSaveFromConnect(fd_charaindex, FALSE);
+ CHAR_talkToCli(fd_charaindex, -1, "ϵͳΪԶ浵", CHAR_COLORRED);
+ return;
+ }else{
+ return;
+ }
+ }else{
+ return;
+ }
+ }else{
+ return;
+ }
+ }
+#endif
+#ifdef _NO_DROPITEM
+ if( seqno == CHAR_WINDOWTYPE_DROPITEM){
+ if(select == WINDOW_BUTTONTYPE_OK){
+ int itemcharaindex = CHAR_getWorkInt(fd_charaindex,CHAR_DROPITEMCHARAINDEX);
+ if(itemcharaindex>-1){
+ CHAR_DropItem(fd_charaindex,itemcharaindex);
+ return;
+ }else{
+ return;
+ }
+ }else{
+ return;
+ }
+ }
+#endif
+#ifdef _ITEM_RESET
+ if( seqno == CHAR_WINDOWTYPE_RESETITEM){
+ if(select == WINDOW_BUTTONTYPE_OK){
+ int fromindex = CHAR_getWorkInt(fd_charaindex,CHAR_WORKFROMITEMINDEX);
+ int toindex = CHAR_getWorkInt(fd_charaindex,CHAR_WORKTOITEMINDEX);
+ int resetpoint,mypoint;
+ int itemid = ITEM_getInt(CHAR_getItemIndex( fd_charaindex, toindex),ITEM_ID);
+ resetpoint = sasql_itemreset_query(itemid);
+ if(resetpoint<0) return;
+ mypoint = sasql_vippoint(CHAR_getChar(fd_charaindex,CHAR_CDKEY),0,0);
+ if(mypoint-1){
+ CHAR_DelItem(fd_charaindex,fromindex);
+ CHAR_DelItem(fd_charaindex,toindex);
+ int newitemindex,ret;
+ newitemindex = ITEM_makeItemAndRegist( itemid);
+ ret = CHAR_addItemSpecificItemIndex( fd_charaindex, newitemindex);
+ if( ret < 0 || ret >= CHAR_MAXITEMHAVE ) {
+ ITEM_endExistItemsOne( newitemindex);
+ return;
+ }
+ CHAR_sendItemDataOne( fd_charaindex, ret);
+ CHAR_charSaveFromConnect(fd_charaindex, FALSE);
+ CHAR_talkToCli(fd_charaindex, -1, "ϲ¯߳ɹϵͳԶΪ浵", CHAR_COLORRED);
+ return;
+ }else{
+ return;
+ }
+ }
+ }else{
+ return;
+ }
+ }
+ if( seqno == CHAR_WINDOWTYPE_DELITEM){
+ if(select == WINDOW_BUTTONTYPE_OK){
+ int fromindex = CHAR_getWorkInt(fd_charaindex,CHAR_WORKFROMITEMINDEX);
+ int toindex = CHAR_getWorkInt(fd_charaindex,CHAR_WORKTOITEMINDEX);
+ int delpoint,mypoint;
+ int itemid = ITEM_getInt(CHAR_getItemIndex( fd_charaindex, toindex),ITEM_ID);
+ delpoint = sasql_itemdel_query(itemid);
+ if(delpoint<0) return;
+ mypoint = sasql_vippoint(CHAR_getChar(fd_charaindex,CHAR_CDKEY),0,0);
+ {
+ if(sasql_vippoint(CHAR_getChar(fd_charaindex,CHAR_CDKEY),delpoint,1)>-1){
+ CHAR_DelItem(fd_charaindex,fromindex);
+ CHAR_DelItem(fd_charaindex,toindex);
+ CHAR_charSaveFromConnect(fd_charaindex, FALSE);
+ CHAR_talkToCli(fd_charaindex, -1, "ϲյ߳ɹϵͳԶΪ浵", CHAR_COLORRED);
+ return;
+ }else{
+ return;
+ }
+ }
+ }else{
+ return;
+ }
+ }
+#endif
+#ifdef _ALL_RANDMODE
+ if( seqno == CHAR_WINDOWTYPE_RAND1_EDITBASE )
+ {
+ if(strlen(data)<1)
+ {
+ CHAR_talkToCli( fd_charaindex, -1, "", CHAR_COLORRED);
+ return;
+ }
+ char *arg;
+ char buftest[255];
+ int haveitemindex,itemindex,ret,toindex;
+ arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKRANDEDITBASE);
+ if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE)
+ return;
+ itemindex = atoi(buftest);
+ if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE)
+ return;
+ toindex = atoi(buftest);
+ if(getStringFromIndexWithDelim(arg,"|", 3, buftest, sizeof(buftest)) == FALSE)
+ return;
+ haveitemindex = atoi(buftest);
+ if(getStringFromIndexWithDelim(arg,"|", 4, buftest, sizeof(buftest)) == FALSE)
+ return;
+ ret = atoi(buftest);
+ if(atoi(data)!=ret){
+ CHAR_talkToCli( fd_charaindex, -1, "ļȷ룡", CHAR_COLORRED);
+ return;
+ }
+ if(itemindex!=CHAR_getItemIndex( fd_charaindex, haveitemindex)){
+ return;
+ }
+ //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,0);
+ CHAR_setChar(fd_charaindex,CHAR_RANDTYPE,"");
+ int i;
+ int work[4];
+ int num=-1,type;
+ int LevelUpPoint,petrank;
+ char buf1[256];
+ char buf2[][32]={"ɳ",";ɳ","ٶȳɳ","ɳ",""};
+ char buf3[][32]={"","Ϊ","Ϊ"};
+ if( !CHAR_CHECKINDEX( fd_charaindex ) ) return;
+ if( !CHAR_CHECKINDEX( toindex ) ) return;
+//#define RAND(x,y) ((x-1)+1+ (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) )
+ 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( fd_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( fd_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( fd_charaindex, CHAR_NAME ),
+ CHAR_getChar( fd_charaindex, CHAR_CDKEY ),
+ CHAR_getChar( fd_charaindex, CHAR_NAME),
+ toindex, 4,
+ CHAR_getInt( toindex, CHAR_LV),
+ "item_use",
+ CHAR_getInt( fd_charaindex, CHAR_FLOOR),
+ CHAR_getInt( fd_charaindex, CHAR_X ),
+ CHAR_getInt( fd_charaindex, CHAR_Y )
+ );
+ }
+
+ }else {
+ sprintf(buf1,"");
+ }
+ CHAR_DelItem( fd_charaindex, haveitemindex);
+ //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDTYPE,0);
+ return;
+ }
+ if( seqno == CHAR_WINDOWTYPE_RAND2_EDITBASE )
+ {
+ if(strlen(data)<1)
+ {
+ return;
+ }
+ if(atoi(data)<1 || atoi(data)>5) return;
+ char *arg;
+ char buftest[255];
+ int haveitemindex,itemindex,ret,toindex;
+ arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKRANDEDITBASE);
+ if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE)
+ return;
+ itemindex = atoi(buftest);
+ if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE)
+ return;
+ toindex = atoi(buftest);
+ if(getStringFromIndexWithDelim(arg,"|", 3, buftest, sizeof(buftest)) == FALSE)
+ return;
+ haveitemindex = atoi(buftest);
+ if(getStringFromIndexWithDelim(arg,"|", 4, buftest, sizeof(buftest)) == FALSE)
+ return;
+ ret = atoi(buftest);
+ if(atoi(data)!=ret){
+ CHAR_talkToCli( fd_charaindex, -1, "źѡļԺԡ", CHAR_COLORRED);
+ return;
+ }
+ if(itemindex!=CHAR_getItemIndex( fd_charaindex, haveitemindex)){
+ return;
+ }
+ //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,0);
+ CHAR_setChar(fd_charaindex,CHAR_RANDTYPE,"");
+ CHAR_talkToCli( fd_charaindex, -1, "ϲѡļȷ", CHAR_COLORRED);
+ int i;
+ int work[4];
+ int num=-1,type;
+ int LevelUpPoint,petrank;
+ char buf1[256];
+ char buf2[][32]={"ɳ",";ɳ","ٶȳɳ","ɳ",""};
+ char buf3[][32]={"","Ϊ","Ϊ"};
+ if( !CHAR_CHECKINDEX( fd_charaindex ) ) return;
+ if( !CHAR_CHECKINDEX( toindex ) ) return;
+//#define RAND(x,y) ((x-1)+1+ (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) )
+ 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( fd_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( fd_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( fd_charaindex, CHAR_NAME ),
+ CHAR_getChar( fd_charaindex, CHAR_CDKEY ),
+ CHAR_getChar( fd_charaindex, CHAR_NAME),
+ toindex, 4,
+ CHAR_getInt( toindex, CHAR_LV),
+ "item_use",
+ CHAR_getInt( fd_charaindex, CHAR_FLOOR),
+ CHAR_getInt( fd_charaindex, CHAR_X ),
+ CHAR_getInt( fd_charaindex, CHAR_Y )
+ );
+ }
+
+ }else {
+ sprintf(buf1,"");
+ }
+ CHAR_DelItem( fd_charaindex, haveitemindex);
+ //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDTYPE,0);
+ return;
+ }
+ if( seqno == CHAR_WINDOWTYPE_RAND3_EDITBASE )
+ {
+ if(strlen(data)<1)
+ {
+ CHAR_talkToCli( fd_charaindex, -1, "", CHAR_COLORRED);
+ return;
+ }
+ char *arg;
+ char buftest[255];
+ int haveitemindex,itemindex,toindex;
+ char ret[255];
+ arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKRANDEDITBASE);
+ if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE)
+ return;
+ itemindex = atoi(buftest);
+ if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE)
+ return;
+ toindex = atoi(buftest);
+ if(getStringFromIndexWithDelim(arg,"|", 3, buftest, sizeof(buftest)) == FALSE)
+ return;
+ haveitemindex = atoi(buftest);
+ if(getStringFromIndexWithDelim(arg,"|", 4, buftest, sizeof(buftest)) == FALSE)
+ return;
+ strcpy(ret,buftest);
+ if(strcmp(ret,data)!=0){
+ CHAR_talkToCli( fd_charaindex, -1, "Ľȷ룡", CHAR_COLORRED);
+ return;
+ }
+ if(itemindex!=CHAR_getItemIndex( fd_charaindex, haveitemindex)){
+ return;
+ }
+ //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,0);
+ CHAR_setChar(fd_charaindex,CHAR_RANDTYPE,"");
+ int i;
+ int work[4];
+ int num=-1,type;
+ int LevelUpPoint,petrank;
+ char buf1[256];
+ char buf2[][32]={"ɳ",";ɳ","ٶȳɳ","ɳ",""};
+ char buf3[][32]={"","Ϊ","Ϊ"};
+ if( !CHAR_CHECKINDEX( fd_charaindex ) ) return;
+ if( !CHAR_CHECKINDEX( toindex ) ) return;
+//#define RAND(x,y) ((x-1)+1+ (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) )
+ 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( fd_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( fd_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( fd_charaindex, CHAR_NAME ),
+ CHAR_getChar( fd_charaindex, CHAR_CDKEY ),
+ CHAR_getChar( fd_charaindex, CHAR_NAME),
+ toindex, 4,
+ CHAR_getInt( toindex, CHAR_LV),
+ "item_use",
+ CHAR_getInt( fd_charaindex, CHAR_FLOOR),
+ CHAR_getInt( fd_charaindex, CHAR_X ),
+ CHAR_getInt( fd_charaindex, CHAR_Y )
+ );
+ }
+
+ }else {
+ sprintf(buf1,"");
+ }
+ CHAR_DelItem( fd_charaindex, haveitemindex);
+ //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDTYPE,0);
+ return;
+ }
+ if( seqno == CHAR_WINDOWTYPE_RAND4_EDITBASE )
+ {
+ if(strlen(data)<1)
+ {
+ return;
+ }
+ //if(atoi(data)getRandMax()) return;
+ if(CHAR_getWorkInt(fd_charaindex,CHAR_WORKLUANPCINT)!=0) return;
+ CHAR_setWorkInt(fd_charaindex,CHAR_WORKLUANPCINT,1);
+ int cdkeynum;
+ for(cdkeynum=9;cdkeynum>0;cdkeynum--){
+ strcpy(mmcdkey[cdkeynum],mmcdkey[cdkeynum-1]);
+ strcpy(mmcdkeybuf[cdkeynum],mmcdkeybuf[cdkeynum-1]);
+ }
+ strcpy(mmcdkey[0],CHAR_getChar(fd_charaindex,CHAR_CDKEY));
+ sprintf(mmcdkeybuf[0],"%d.%d.%d",CHAR_getInt(fd_charaindex,CHAR_FLOOR),CHAR_getInt(fd_charaindex,CHAR_X),CHAR_getInt(fd_charaindex,CHAR_Y));
+ time_t timep;
+ struct tm *p;
+ time(&timep);
+ p=localtime(&timep);
+ timep = mktime(p);
+ CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,timep);
+ char *arg;
+ char buftest[255];
+ int haveitemindex,itemindex,ret,toindex;
+ arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKRANDEDITBASE);
+ if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE)
+ return;
+ itemindex = atoi(buftest);
+ if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE)
+ return;
+ toindex = atoi(buftest);
+ if(getStringFromIndexWithDelim(arg,"|", 3, buftest, sizeof(buftest)) == FALSE)
+ return;
+ haveitemindex = atoi(buftest);
+ if(getStringFromIndexWithDelim(arg,"|", 4, buftest, sizeof(buftest)) == FALSE)
+ return;
+ ret = atoi(buftest);
+ if(atoi(data)!=ret){
+ if(ret>=1 && ret<=5){
+ if(atoi(data)>=10000){
+ sasql_cdkey_lock(CHAR_getChar(fd_charaindex,CHAR_CDKEY),15);
+ CONNECT_setCloseRequest( fd , 1 );
+ return;
+ }
+ }else{
+ if(atoi(data)>=1 && atoi(data)<=5){
+ //sasql_cdkey_lock(CHAR_getChar(fd_charaindex,CHAR_CDKEY),14);
+ CONNECT_setCloseRequest( fd , 1 );
+ return;
+ }
+ }
+ CHAR_talkToCli( fd_charaindex, -1, "źĽԺԡ", CHAR_COLORRED);
+ return;
+ }
+ if(itemindex!=CHAR_getItemIndex( fd_charaindex, haveitemindex)){
+ return;
+ }
+ //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,0);
+ CHAR_setChar(fd_charaindex,CHAR_RANDTYPE,"");
+ CHAR_talkToCli( fd_charaindex, -1, "ϲĽȷ", CHAR_COLORRED);
+ int i;
+ int work[4];
+ int num=-1,type;
+ int LevelUpPoint,petrank;
+ char buf1[256];
+ char buf2[][32]={"ɳ",";ɳ","ٶȳɳ","ɳ",""};
+ char buf3[][32]={"","Ϊ","Ϊ"};
+ if( !CHAR_CHECKINDEX( fd_charaindex ) ) return;
+ if( !CHAR_CHECKINDEX( toindex ) ) return;
+//#define RAND(x,y) ((x-1)+1+ (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) )
+ 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( fd_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( fd_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( fd_charaindex, CHAR_NAME ),
+ CHAR_getChar( fd_charaindex, CHAR_CDKEY ),
+ CHAR_getChar( fd_charaindex, CHAR_NAME),
+ toindex, 4,
+ CHAR_getInt( toindex, CHAR_LV),
+ "item_use",
+ CHAR_getInt( fd_charaindex, CHAR_FLOOR),
+ CHAR_getInt( fd_charaindex, CHAR_X ),
+ CHAR_getInt( fd_charaindex, CHAR_Y )
+ );
+ }
+
+ }else {
+ sprintf(buf1,"");
+ }
+ CHAR_DelItem( fd_charaindex, haveitemindex);
+ //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDTYPE,0);
+ return;
+ }
+#endif
+#ifdef _MM_NO_JIAOBEN
+ if( seqno == CHAR_WINDOWTYPE_RAND1_DROPMM )
+ {
+ if(strlen(data)<1)
+ {
+ CHAR_talkToCli( fd_charaindex, -1, "", CHAR_COLORRED);
+ return;
+ }
+ char *arg;
+ char buftest[255];
+ int havepetindex,ret;
+ arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKDROPMM);
+ if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE)
+ return;
+ havepetindex = atoi(buftest);
+ if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE)
+ return;
+ ret = atoi(buftest);
+ if(atoi(data)!=ret){
+ CHAR_talkToCli( fd_charaindex, -1, "ļȷ룡", CHAR_COLORRED);
+ return;
+ }
+ //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,0);
+ CHAR_setChar(fd_charaindex,CHAR_RANDTYPE,"");
+ int petindex;
+ petindex = CHAR_getCharPet(fd_charaindex,havepetindex);
+ if( !CHAR_CHECKINDEX( petindex )) return;
+ if(CHAR_getInt(petindex,CHAR_PETID)!=718 && CHAR_getInt(petindex,CHAR_PETID)!=401) return;
+ PET_dropPetFLXY(fd_charaindex, havepetindex, -1,-1,-1);
+ //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDTYPE,0);
+ return;
+ }
+ if( seqno == CHAR_WINDOWTYPE_RAND2_DROPMM )
+ {
+ if(strlen(data)<1)
+ {
+ return;
+ }
+ if(atoi(data)<1 || atoi(data)>5) return;
+ char *arg;
+ char buftest[255];
+ int havepetindex,ret;
+ arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKDROPMM);
+ if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE)
+ return;
+ havepetindex = atoi(buftest);
+ if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE)
+ return;
+ ret = atoi(buftest);
+ if(atoi(data)!=ret){
+ CHAR_talkToCli( fd_charaindex, -1, "źѡļԺԡ", CHAR_COLORRED);
+ return;
+ }
+ //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,0);
+ CHAR_setChar(fd_charaindex,CHAR_RANDTYPE,"");
+ CHAR_talkToCli( fd_charaindex, -1, "ϲѡļȷ", CHAR_COLORRED);
+ int petindex;
+ petindex = CHAR_getCharPet(fd_charaindex,havepetindex);
+ if( !CHAR_CHECKINDEX( petindex )) return;
+ if(CHAR_getInt(petindex,CHAR_PETID)!=718 && CHAR_getInt(petindex,CHAR_PETID)!=401) return;
+ PET_dropPetFLXY(fd_charaindex, havepetindex, -1,-1,-1);
+ //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDTYPE,0);
+ return;
+ }
+ if( seqno == CHAR_WINDOWTYPE_RAND3_DROPMM )
+ {
+ if(strlen(data)<1)
+ {
+ CHAR_talkToCli( fd_charaindex, -1, "", CHAR_COLORRED);
+ return;
+ }
+ char *arg;
+ char buftest[255];
+ int havepetindex;
+ char ret[255];
+ arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKDROPMM);
+ if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE)
+ return;
+ havepetindex = atoi(buftest);
+ if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE)
+ return;
+ strcpy(ret,buftest);
+ if(strcmp(ret,data)!=0){
+ CHAR_talkToCli( fd_charaindex, -1, "Ľȷ룡", CHAR_COLORRED);
+ return;
+ }
+ //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,0);
+ CHAR_setChar(fd_charaindex,CHAR_RANDTYPE,"");
+ int petindex;
+ petindex = CHAR_getCharPet(fd_charaindex,havepetindex);
+ if( !CHAR_CHECKINDEX( petindex )) return;
+ if(CHAR_getInt(petindex,CHAR_PETID)!=718 && CHAR_getInt(petindex,CHAR_PETID)!=401) return;
+ PET_dropPetFLXY(fd_charaindex, havepetindex, -1,-1,-1);
+ //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDTYPE,0);
+ return;
+ }
+ if( seqno == CHAR_WINDOWTYPE_RAND4_DROPMM )
+ {
+ if(strlen(data)<1)
+ {
+ return;
+ }
+ //if(atoi(data)getRandMax()) return;
+ if(CHAR_getWorkInt(fd_charaindex,CHAR_WORKLUANPCINT)!=0) return;
+ CHAR_setWorkInt(fd_charaindex,CHAR_WORKLUANPCINT,1);
+ int cdkeynum;
+ for(cdkeynum=9;cdkeynum>0;cdkeynum--){
+ strcpy(mmcdkey[cdkeynum],mmcdkey[cdkeynum-1]);
+ strcpy(mmcdkeybuf[cdkeynum],mmcdkeybuf[cdkeynum-1]);
+ }
+ strcpy(mmcdkey[0],CHAR_getChar(fd_charaindex,CHAR_CDKEY));
+ sprintf(mmcdkeybuf[0],"%d.%d.%d",CHAR_getInt(fd_charaindex,CHAR_FLOOR),CHAR_getInt(fd_charaindex,CHAR_X),CHAR_getInt(fd_charaindex,CHAR_Y));
+ time_t timep;
+ struct tm *p;
+ time(&timep);
+ p=localtime(&timep);
+ timep = mktime(p);
+ CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,timep);
+ char *arg;
+ char buftest[255];
+ int havepetindex,ret;
+ arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKDROPMM);
+ if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE)
+ return;
+ havepetindex = atoi(buftest);
+ if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE)
+ return;
+ ret = atoi(buftest);
+ if(atoi(data)!=ret){
+ if(ret>=1 && ret<=5){
+ if(atoi(data)>=10000){
+ sasql_cdkey_lock(CHAR_getChar(fd_charaindex,CHAR_CDKEY),15);
+ CONNECT_setCloseRequest( fd , 1 );
+ return;
+ }
+ }else{
+ if(atoi(data)>=1 && atoi(data)<=5){
+ //sasql_cdkey_lock(CHAR_getChar(fd_charaindex,CHAR_CDKEY),14);
+ CONNECT_setCloseRequest( fd , 1 );
+ return;
+ }
+ }
+ CHAR_talkToCli( fd_charaindex, -1, "źĽԺԡ", CHAR_COLORRED);
+ return;
+ }
+ //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,0);
+ CHAR_setChar(fd_charaindex,CHAR_RANDTYPE,"");
+ CHAR_talkToCli( fd_charaindex, -1, "ϲĽȷ", CHAR_COLORRED);
+ int petindex;
+ petindex = CHAR_getCharPet(fd_charaindex,havepetindex);
+ if( !CHAR_CHECKINDEX( petindex )) return;
+ if(CHAR_getInt(petindex,CHAR_PETID)!=718 && CHAR_getInt(petindex,CHAR_PETID)!=401) return;
+ PET_dropPetFLXY(fd_charaindex, havepetindex, -1,-1,-1);
+ //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDTYPE,0);
+ return;
+ }
+ if( seqno == CHAR_WINDOWTYPE_RAND1_FLLOWMM )
+ {
+ if(strlen(data)<1)
+ {
+ CHAR_talkToCli( fd_charaindex, -1, "", CHAR_COLORRED);
+ return;
+ }
+ char *arg;
+ char buftest[255];
+ int havepetindex,ret;
+ arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKDROPMM);
+ if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE)
+ return;
+ havepetindex = atoi(buftest);
+ if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE)
+ return;
+ ret = atoi(buftest);
+ if(atoi(data)!=ret){
+ CHAR_talkToCli( fd_charaindex, -1, "ļȷ룡", CHAR_COLORRED);
+ return;
+ }
+ //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,0);
+ CHAR_setChar(fd_charaindex,CHAR_RANDTYPE,"");
+ int petindex;
+ petindex = CHAR_getCharPet(fd_charaindex,havepetindex);
+ if( !CHAR_CHECKINDEX( petindex )) return;
+ if(CHAR_getInt(petindex,CHAR_PETID)!=718 && CHAR_getInt(petindex,CHAR_PETID)!=401) return;
+ if( !PET_dropPetFollow( fd_charaindex, havepetindex, -1, -1, -1 ) ) {
+ CHAR_talkToCli( fd_charaindex, -1, "ʧܣ", CHAR_COLORWHITE );
+ return;
+ }
+ //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDTYPE,0);
+ return;
+ }
+ if( seqno == CHAR_WINDOWTYPE_RAND2_FLLOWMM )
+ {
+ if(strlen(data)<1)
+ {
+ return;
+ }
+ if(atoi(data)<1 || atoi(data)>5) return;
+ char *arg;
+ char buftest[255];
+ int havepetindex,ret;
+ arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKDROPMM);
+ if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE)
+ return;
+ havepetindex = atoi(buftest);
+ if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE)
+ return;
+ ret = atoi(buftest);
+ if(atoi(data)!=ret){
+ CHAR_talkToCli( fd_charaindex, -1, "źѡļԺԡ", CHAR_COLORRED);
+ return;
+ }
+ //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,0);
+ CHAR_setChar(fd_charaindex,CHAR_RANDTYPE,"");
+ CHAR_talkToCli( fd_charaindex, -1, "ϲѡļȷ", CHAR_COLORRED);
+ int petindex;
+ petindex = CHAR_getCharPet(fd_charaindex,havepetindex);
+ if( !CHAR_CHECKINDEX( petindex )) return;
+ if(CHAR_getInt(petindex,CHAR_PETID)!=718 && CHAR_getInt(petindex,CHAR_PETID)!=401) return;
+ if( !PET_dropPetFollow( fd_charaindex, havepetindex, -1, -1, -1 ) ) {
+ CHAR_talkToCli( fd_charaindex, -1, "ʧܣ", CHAR_COLORWHITE );
+ return;
+ }
+ //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDTYPE,0);
+ return;
+ }
+ if( seqno == CHAR_WINDOWTYPE_RAND3_FLLOWMM )
+ {
+ if(strlen(data)<1)
+ {
+ CHAR_talkToCli( fd_charaindex, -1, "", CHAR_COLORRED);
+ return;
+ }
+ char *arg;
+ char buftest[255];
+ int havepetindex;
+ char ret[255];
+ arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKDROPMM);
+ if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE)
+ return;
+ havepetindex = atoi(buftest);
+ if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE)
+ return;
+ strcpy(ret,buftest);
+ if(strcmp(ret,data)!=0){
+ CHAR_talkToCli( fd_charaindex, -1, "Ľȷ룡", CHAR_COLORRED);
+ return;
+ }
+ //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,0);
+ CHAR_setChar(fd_charaindex,CHAR_RANDTYPE,"");
+ int petindex;
+ petindex = CHAR_getCharPet(fd_charaindex,havepetindex);
+ if( !CHAR_CHECKINDEX( petindex )) return;
+ if(CHAR_getInt(petindex,CHAR_PETID)!=718 && CHAR_getInt(petindex,CHAR_PETID)!=401) return;
+ if( !PET_dropPetFollow( fd_charaindex, havepetindex, -1, -1, -1 ) ) {
+ CHAR_talkToCli( fd_charaindex, -1, "ʧܣ", CHAR_COLORWHITE );
+ return;
+ }
+ //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDTYPE,0);
+ return;
+ }
+ if( seqno == CHAR_WINDOWTYPE_RAND4_FLLOWMM )
+ {
+ if(strlen(data)<1)
+ {
+ return;
+ }
+ //if(atoi(data)getRandMax()) return;
+ if(CHAR_getWorkInt(fd_charaindex,CHAR_WORKLUANPCINT)!=0) return;
+ CHAR_setWorkInt(fd_charaindex,CHAR_WORKLUANPCINT,1);
+ int cdkeynum;
+ for(cdkeynum=9;cdkeynum>0;cdkeynum--){
+ strcpy(mmcdkey[cdkeynum],mmcdkey[cdkeynum-1]);
+ strcpy(mmcdkeybuf[cdkeynum],mmcdkeybuf[cdkeynum-1]);
+ }
+ strcpy(mmcdkey[0],CHAR_getChar(fd_charaindex,CHAR_CDKEY));
+ sprintf(mmcdkeybuf[0],"%d.%d.%d",CHAR_getInt(fd_charaindex,CHAR_FLOOR),CHAR_getInt(fd_charaindex,CHAR_X),CHAR_getInt(fd_charaindex,CHAR_Y));
+ time_t timep;
+ struct tm *p;
+ time(&timep);
+ p=localtime(&timep);
+ timep = mktime(p);
+ CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,timep);
+ char *arg;
+ char buftest[255];
+ int havepetindex,ret;
+ arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKDROPMM);
+ if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE)
+ return;
+ havepetindex = atoi(buftest);
+ if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE)
+ return;
+ ret = atoi(buftest);
+ if(atoi(data)!=ret){
+ if(ret>=1 && ret<=5){
+ if(atoi(data)>=10000){
+ sasql_cdkey_lock(CHAR_getChar(fd_charaindex,CHAR_CDKEY),15);
+ CONNECT_setCloseRequest( fd , 1 );
+ return;
+ }
+ }else{
+ if(atoi(data)>=1 && atoi(data)<=5){
+ //sasql_cdkey_lock(CHAR_getChar(fd_charaindex,CHAR_CDKEY),14);
+ CONNECT_setCloseRequest( fd , 1 );
+ return;
+ }
+ }
+ CHAR_talkToCli( fd_charaindex, -1, "źĽԺԡ", CHAR_COLORRED);
+ return;
+ }
+ //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,0);
+ CHAR_setChar(fd_charaindex,CHAR_RANDTYPE,"");
+ CHAR_talkToCli( fd_charaindex, -1, "ϲĽȷ", CHAR_COLORRED);
+ int petindex;
+ petindex = CHAR_getCharPet(fd_charaindex,havepetindex);
+ if( !CHAR_CHECKINDEX( petindex )) return;
+ if(CHAR_getInt(petindex,CHAR_PETID)!=718 && CHAR_getInt(petindex,CHAR_PETID)!=401) return;
+ if( !PET_dropPetFollow( fd_charaindex, havepetindex, -1, -1, -1 ) ) {
+ CHAR_talkToCli( fd_charaindex, -1, "ʧܣ", CHAR_COLORWHITE );
+ return;
+ }
+ //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDTYPE,0);
+ return;
+ }
+#endif
+#ifdef _DP_ZHIPIAO_ITEM
+ if( seqno == CHAR_WINDOWTYPE_DPZHIPIAO_1 )
+ {
+ if(strlen(data)<1)
+ {
+ CHAR_talkToCli( fd_charaindex, -1, "", CHAR_COLORRED);
+ return;
+ }
+ if(atoi(data)!=CHAR_getWorkInt(fd_charaindex,CHAR_WORKDPZHIPIAORAND)){
+ CHAR_talkToCli( fd_charaindex, -1, "ļȷ룡", CHAR_COLORRED);
+ return;
+ }
+ char buf[255];
+ lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT,
+ WINDOW_BUTTONTYPE_OKCANCEL,
+ CHAR_WINDOWTYPE_DPZHIPIAO_2,
+ -1,
+ makeEscapeString( "ҪһDP\n", buf, sizeof(buf)));
+ }
+ if( seqno == CHAR_WINDOWTYPE_DPZHIPIAO_2 ){
+ if(select == WINDOW_BUTTONTYPE_OK){
+ if(strlen(data)<1) return;
+ if(atoi(data)<100){
+ CHAR_talkToCli( fd_charaindex, -1, "С֧ƱΪ100DPǩ", CHAR_COLORYELLOW);
+ return;
+ }
+ if(atoi(data)>10000000){
+ CHAR_talkToCli( fd_charaindex, -1, "֧ƱΪ1000WDPǩ", CHAR_COLORYELLOW);
+ return;
+ }
+ char zhipiaomsg[256];
+ int dppoint = atoi(data)*CHAR_getWorkInt(fd_charaindex,CHAR_WORKDPZHIPIAOSHUI)/100;
+ if(dppoint<10) dppoint = dppoint+1;
+ sprintf(zhipiaomsg,"\nǩ֧ƱҪȡٷ֮%d˰\n\n֧ƱǩҪ۳%dDP\n\nȷҪô",CHAR_getWorkInt(fd_charaindex,CHAR_WORKDPZHIPIAOSHUI),dppoint+atoi(data));
+ lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE,
+ WINDOW_BUTTONTYPE_OKCANCEL,
+ CHAR_WINDOWTYPE_DPZHIPIAO_3,
+ -1,
+ zhipiaomsg);
+ CHAR_setWorkInt(fd_charaindex,CHAR_WORKDPZHIPIAOPOINT,atoi(data));
+ return;
+ }else
+ return;
+ }
+ if( seqno == CHAR_WINDOWTYPE_DPZHIPIAO_3 ){
+ if(select == WINDOW_BUTTONTYPE_OK){
+ int mypoint = CHAR_getInt(fd_charaindex,CHAR_DUELPOINT);
+ int itempoint = CHAR_getWorkInt(fd_charaindex,CHAR_WORKDPZHIPIAOPOINT);
+ int kdppoint = itempoint/100*CHAR_getWorkInt(fd_charaindex,CHAR_WORKDPZHIPIAOSHUI);
+ if(kdppoint<10) kdppoint =kdppoint+1;
+ int dppoint = itempoint+kdppoint;
+ if(mypoint5) return;
+ char *arg;
+ char buftest[255];
+ int npcindex,ret;
+ char *szmsg;
+ arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKRANDMSG);
+ if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE)
+ return;
+ ret = atoi(buftest);
+ if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE)
+ return;
+ npcindex = atoi(buftest);
+ if(getStringFromIndexWithDelim(arg,"|", 3, buftest, sizeof(buftest)) == FALSE)
+ return;
+ szmsg = buftest;
+ if(atoi(data)!=ret){
+ CHAR_talkToCli( fd_charaindex, -1, "źѡļԺԡ", CHAR_COLORRED);
+ return;
+ }
+ //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,0);
+ CHAR_setChar(fd_charaindex,CHAR_RANDTYPE,"");
+ CHAR_talkToCli( fd_charaindex, -1, "ϲѡļȷ", CHAR_COLORRED);
+ NPC_TypeCheck( npcindex, fd_charaindex, szmsg);
+ //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDTYPE,0);
+ return;
+ }
+ if( seqno == CHAR_WINDOWTYPE_NPC_RAND3_MSG ){
+ if(select == WINDOW_BUTTONTYPE_OK){
+ if(strlen(data)<1)
+ {
+ CHAR_talkToCli( fd_charaindex, -1, "", CHAR_COLORRED);
+ return;
+ }
+ char *arg;
+ char buftest[255];
+ int npcindex;
+ char ret[255];
+ char *szmsg;
+ arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKRANDMSG);
+ if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE)
+ return;
+ strcpy(ret,buftest);
+ if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE)
+ return;
+ npcindex = atoi(buftest);
+ if(getStringFromIndexWithDelim(arg,"|", 3, buftest, sizeof(buftest)) == FALSE)
+ return;
+ szmsg = buftest;
+ if(strcmp(ret,data)!=0){
+ CHAR_talkToCli( fd_charaindex, -1, "Ľȷ룡", CHAR_COLORRED);
+ return;
+ }
+ //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,0);
+ CHAR_setChar(fd_charaindex,CHAR_RANDTYPE,"");
+ NPC_TypeCheck( npcindex, fd_charaindex, szmsg);
+ //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDTYPE,0);
+ return;
+ }else
+ return;
+ }
+ if( seqno == CHAR_WINDOWTYPE_NPC_RAND4_MSG ){
+ if(strlen(data)<1)
+ {
+ CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,"");
+ return;
+ }
+ //if(atoi(data)getRandMax()) return;
+ if(CHAR_getWorkInt(fd_charaindex,CHAR_WORKLUANPCINT)!=0){
+ CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,"");
+ return;
+ }
+ CHAR_setWorkInt(fd_charaindex,CHAR_WORKLUANPCINT,1);
+ int cdkeynum;
+ for(cdkeynum=9;cdkeynum>0;cdkeynum--){
+ strcpy(mmcdkey[cdkeynum],mmcdkey[cdkeynum-1]);
+ strcpy(mmcdkeybuf[cdkeynum],mmcdkeybuf[cdkeynum-1]);
+ }
+ strcpy(mmcdkey[0],CHAR_getChar(fd_charaindex,CHAR_CDKEY));
+ sprintf(mmcdkeybuf[0],"%d.%d.%d",CHAR_getInt(fd_charaindex,CHAR_FLOOR),CHAR_getInt(fd_charaindex,CHAR_X),CHAR_getInt(fd_charaindex,CHAR_Y));
+ time_t timep;
+ struct tm *p;
+ time(&timep);
+ p=localtime(&timep);
+ timep = mktime(p);
+ CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,timep);
+ char *arg;
+ char buftest[255];
+ int npcindex,ret;
+ char *szmsg;
+ arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKRANDMSG);
+ if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE){
+ CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,"");
+ return;
+ }
+ ret = atoi(buftest);
+ if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE){
+ CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,"");
+ return;
+ }
+ npcindex = atoi(buftest);
+ if(getStringFromIndexWithDelim(arg,"|", 3, buftest, sizeof(buftest)) == FALSE){
+ CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,"");
+ return;
+ }
+ szmsg = buftest;
+ if(atoi(data)!=ret){
+ if(ret>=1 && ret<=5){
+ if(atoi(data)>=10000){
+ sasql_cdkey_lock(CHAR_getChar(fd_charaindex,CHAR_CDKEY),15);
+ CONNECT_setCloseRequest( fd , 1 );
+ return;
+ }
+ }else{
+ if(atoi(data)>=1 && atoi(data)<=5){
+ //sasql_cdkey_lock(CHAR_getChar(fd_charaindex,CHAR_CDKEY),14);
+ CONNECT_setCloseRequest( fd , 1 );
+ return;
+ }
+ }
+ CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,"");
+ CHAR_talkToCli( fd_charaindex, -1, "źĽԺԡ", CHAR_COLORRED);
+ return;
+ }
+ //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,0);
+ CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,"");
+ CHAR_setChar(fd_charaindex,CHAR_RANDTYPE,"");
+ CHAR_talkToCli( fd_charaindex, -1, "ϲĽȷ", CHAR_COLORRED);
+ NPC_TypeCheck( npcindex, fd_charaindex, szmsg);
+ //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDTYPE,0);
+ return;
+ }
+
+ if( seqno == CHAR_WINDOWTYPE_NPCENEMY_RAND_MSG ){
+ if(strlen(data)<1)
+ {
+ CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,"");
+ return;
+ }
+ //if(atoi(data)getRandMax()) return;
+ if(CHAR_getWorkInt(fd_charaindex,CHAR_WORKLUANPCINT)!=0){
+ CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,"");
+ return;
+ }
+ CHAR_setWorkInt(fd_charaindex,CHAR_WORKLUANPCINT,1);
+ int cdkeynum;
+ for(cdkeynum=9;cdkeynum>0;cdkeynum--){
+ strcpy(mmcdkey[cdkeynum],mmcdkey[cdkeynum-1]);
+ strcpy(mmcdkeybuf[cdkeynum],mmcdkeybuf[cdkeynum-1]);
+ }
+ strcpy(mmcdkey[0],CHAR_getChar(fd_charaindex,CHAR_CDKEY));
+ sprintf(mmcdkeybuf[0],"%d.%d.%d",CHAR_getInt(fd_charaindex,CHAR_FLOOR),CHAR_getInt(fd_charaindex,CHAR_X),CHAR_getInt(fd_charaindex,CHAR_Y));
+ time_t timep;
+ struct tm *p;
+ time(&timep);
+ p=localtime(&timep);
+ timep = mktime(p);
+ CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,timep);
+ char *arg;
+ char buftest[255];
+ int npcindex,ret;
+ arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKRANDMSG);
+ if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE){
+ CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,"");
+ return;
+ }
+ ret = atoi(buftest);
+ if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE){
+ CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,"");
+ return;
+ }
+ npcindex = atoi(buftest);
+ if(atoi(data)!=ret){
+ if(ret>=1 && ret<=5){
+ if(atoi(data)>=10000){
+ sasql_cdkey_lock(CHAR_getChar(fd_charaindex,CHAR_CDKEY),15);
+ CONNECT_setCloseRequest( fd , 1 );
+ return;
+ }
+ }else{
+ if(atoi(data)>=1 && atoi(data)<=5){
+ CONNECT_setCloseRequest( fd , 1 );
+ return;
+ }
+ }
+ CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,"");
+ CHAR_talkToCli( fd_charaindex, -1, "źĽԺԡ", CHAR_COLORRED);
+ return;
+ }
+ //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,0);
+ CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,"");
+ CHAR_setChar(fd_charaindex,CHAR_RANDTYPE,"");
+ CHAR_talkToCli( fd_charaindex, -1, "ϲĽȷ", CHAR_COLORRED);
+ NPC_NPCEnemy_Encount( npcindex, fd_charaindex, 1);
+ //CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDTYPE,0);
+ return;
+ }
+
+ if( seqno == CHAR_WINDOWTYPE_LUANPC_RANDMSG ){
+ if(strlen(data)<1)
+ {
+ CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,"");
+ return;
+ }
+ //if(atoi(data)getRandMax()) return;
+ if(CHAR_getWorkInt(fd_charaindex,CHAR_WORKLUANPCINT)!=0){
+ CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,"");
+ return;
+ }
+ CHAR_setWorkInt(fd_charaindex,CHAR_WORKLUANPCINT,1);
+ int cdkeynum;
+ for(cdkeynum=9;cdkeynum>0;cdkeynum--){
+ strcpy(mmcdkey[cdkeynum],mmcdkey[cdkeynum-1]);
+ strcpy(mmcdkeybuf[cdkeynum],mmcdkeybuf[cdkeynum-1]);
+ }
+ strcpy(mmcdkey[0],CHAR_getChar(fd_charaindex,CHAR_CDKEY));
+ sprintf(mmcdkeybuf[0],"%d.%d.%d",CHAR_getInt(fd_charaindex,CHAR_FLOOR),CHAR_getInt(fd_charaindex,CHAR_X),CHAR_getInt(fd_charaindex,CHAR_Y));
+ time_t timep;
+ struct tm *p;
+ time(&timep);
+ p=localtime(&timep);
+ timep = mktime(p);
+ CHAR_setWorkInt(fd_charaindex,CHAR_WORKRANDEDITBASETIME,timep);
+ char *arg;
+ char buftest[255];
+ int npcindex,talkindex,ret,flag;
+ arg = CHAR_getWorkChar(fd_charaindex,CHAR_WORKRANDMSG);
+ if(getStringFromIndexWithDelim(arg,"|", 1, buftest, sizeof(buftest)) == FALSE){
+ CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,"");
+ return;
+ }
+ ret = atoi(buftest);
+ if(getStringFromIndexWithDelim(arg,"|", 2, buftest, sizeof(buftest)) == FALSE){
+ CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,"");
+ return;
+ }
+ npcindex = atoi(buftest);
+ if(getStringFromIndexWithDelim(arg,"|", 3, buftest, sizeof(buftest)) == FALSE){
+ CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,"");
+ return;
+ }
+ talkindex = atoi(buftest);
+ if(getStringFromIndexWithDelim(arg,"|", 4, buftest, sizeof(buftest)) == FALSE){
+ CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,"");
+ return;
+ }
+ flag = atoi(buftest);
+ if(atoi(data)!=ret){
+ if(ret>=1 && ret<=5){
+ if(atoi(data)>=10000){
+ sasql_cdkey_lock(CHAR_getChar(fd_charaindex,CHAR_CDKEY),15);
+ CONNECT_setCloseRequest( fd , 1 );
+ return;
+ }
+ }else{
+ if(atoi(data)>=1 && atoi(data)<=5){
+ //sasql_cdkey_lock(CHAR_getChar(fd_charaindex,CHAR_CDKEY),14);
+ CONNECT_setCloseRequest( fd , 1 );
+ return;
+ }
+ }
+ CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,"");
+ CHAR_talkToCli( fd_charaindex, -1, "źĽԺԡ", CHAR_COLORRED);
+ return;
+ }
+ sprintf(buftest,"%d|%d|%d|%d",ret,npcindex,talkindex,1);
+ CHAR_setWorkChar(fd_charaindex,CHAR_WORKRANDMSG,buftest);
+ CHAR_setChar(fd_charaindex,CHAR_RANDTYPE,"");
+ CHAR_talkToCli( fd_charaindex, -1, "ϲĽȷ", CHAR_COLORRED);
+ NPC_Lua_TalkedCallBack(npcindex,fd_charaindex,"hi",0,-1);
+ return;
+ }
+#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){
+ //print("12121212\n");
+// 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)
+ || CHAR_getInt(fd_charaindex,CHAR_FLOOR) == 20000
+ ){
+ return ;
+ }
+#endif
+#ifdef _NPCENEMY_1
+ if(CHAR_getWorkInt(fd_charaindex,CHAR_WORKBATTLEHELP)==1) return;
+#endif
+ if( flg == TRUE ) {
+ 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);
+ CHAR_sendBattleEffect( toindex, ON);
+ }
+ }
+}
+/*------------------------------------------------------------
+ ------------------------------------------------------------*/
+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[32];
+ if( strcmp( passwd, "hogehoge") == 0 ) {
+ int i;
+ int playernum = CHAR_getPlayerMaxNum();
+ snprintf( buff, sizeof( buff),"%s档",getGameserverID());
+ 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;
+ if( CHAR_getWorkInt(fd_charaindex,CHAR_WORKSTREETVENDOR)!=-1) 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;
+ if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE && strlen(data)>0) 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 )
+{
+ if(nPet<0 || nPet>4) return;
+ 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);
+// if( nums ==3 && CHAR_getWorkInt(charaindex,CHAR_WORK_PET0_STAT+nPet)==0){
+// CHAR_setWorkInt( charaindex, CHAR_WORK_PET0_STAT+nPet, 1);
+// lssproto_SPET_recv(fd,nPet+1);
+// }
+}
+
+#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 _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);
+ int 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 ){
+ if(CHAR_getWorkInt( charaindex, CHAR_ENCOUNT_NUM)-(int)time(NULL)>0){
+// print("\n (%s)ʹüܴ!", CHAR_getUseName( charaindex ) );
+#ifdef _PROSKILL_ERR_KICK
+ CONNECT_setCloseRequest( fd , 1 );
+#endif
+ }
+ }
+ }
+
+}
+
+#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;
+ }
+ if (CHAR_getWorkInt( charaindex, CHAR_WORKSAFEMODE)==0)
+ {
+ CHAR_SafePassword(charaindex);
+ 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
+
+#ifdef _ONLINE_SHOP
+void lssproto_SHOP_recv(int fd,int shopflag,int piece)
+{
+ int charaindex = CONNECT_getCharaindex(fd);
+
+ if(!CHAR_CHECKINDEX(charaindex)) return;
+ char *mycdkey=CHAR_getChar(charaindex,CHAR_CDKEY);
+ //saacproto_ACShop_send(fd,mycdkey,charaindex,shopflag,piece);
+ char dataname[20];
+ char res[2048];
+ int rownum=0,pieces=0,shopnum=0,startrow,vippoint=0;
+ sprintf(dataname,"OnlineShop%d",shopflag);
+ vippoint=sasql_vippoint(mycdkey,0,0);
+ rownum=sasql_chehk_shop(dataname);
+ if(rownum>0)
+ {
+ pieces=rownum/8+1;
+ shopnum=rownum-8*(piece-1);
+ if(shopnum>8) shopnum=8;
+ startrow=8*(piece-1);
+ char* shopres;
+ shopres=sasql_query_shop(dataname,startrow,shopnum);
+ lssproto_SHOP_send(fd,shopnum,vippoint,piece,pieces,shopflag,shopres);
+ }
+}
+
+void lssproto_SHOPBUY_recv(int fd,int shopflag,int piece,int shopno,int buynum)
+{
+ int charaindex = CONNECT_getCharaindex(fd);
+ int i,petindex;
+ if(!CHAR_CHECKINDEX(charaindex)) return;
+ if (CHAR_getWorkInt( charaindex, CHAR_WORKSAFEMODE)==0)
+ {
+ CHAR_SafePassword(charaindex);
+ return;
+ }
+ if(shopflag==1)
+ {
+ for( i = 0 ;i < CHAR_MAXPETHAVE ; i++) {
+ petindex = CHAR_getCharPet( charaindex, i);
+ if( petindex == -1 )
+ break;
+ }
+
+ if( i+buynum > CHAR_MAXPETHAVE ) {
+ CHAR_talkToCli( charaindex, -1, "", CHAR_COLORYELLOW);
+ return;
+ }
+ }
+ else
+ {
+ if(buynum>CHAR_findSurplusItemBox(charaindex)){
+ CHAR_talkToCli( charaindex, -1, "Ʒλ㡣", CHAR_COLORYELLOW);
+
+ return;
+ }
+ }
+ char *mycdkey=CHAR_getChar(charaindex,CHAR_CDKEY);
+ char dataname[20];
+ int rownum=0,pieces=0,shopnum=0,startrow,vippoint=0;
+ sprintf(dataname,"OnlineShop%d",shopflag);
+ vippoint=sasql_vippoint(mycdkey,0,0);
+ rownum=sasql_chehk_shop(dataname);
+ if(rownum>0)
+ {
+ pieces=rownum/8+1;
+ shopnum=rownum-8*(piece-1);
+ if(shopnum>8) shopnum=8;
+ startrow=8*(piece-1);
+ char* shopres;
+ shopres=sasql_query_shop(dataname,startrow,shopnum);
+ int pvippoint = - sasql_buy_shop(dataname,startrow,shopnum,shopno) * buynum;
+ vippoint=sasql_vippoint(mycdkey,pvippoint,1);
+ //saacproto_ACShopBuy_send(fd, charaindex,0,vippoint,piece,pieces,shopflag,shopres,shopno,buynum);
+ }
+ //saacproto_ACShopBuy_send(fd,mycdkey,charaindex,shopflag,piece,shopno,buynum);
+}
+#endif
diff --git a/char/addressbook.c b/char/addressbook.c
new file mode 100644
index 0000000..ea7530e
--- /dev/null
+++ b/char/addressbook.c
@@ -0,0 +1,914 @@
+#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ᆴչľ£
+ *
+ * ֧³練connectioncdkeyƥƻƽҷ
+ * գ 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;
+#ifdef _AVOIDATTACK_IN_ADDRESSBOOK_sendMessage_textToLong
+ if( strlen(text) > 256 )
+ return FALSE;
+#endif
+ //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));
+
+ /* ˪ԻDZֶ */
+ 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);
+
+ /* ˪ԻDZֶ */
+ 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 == "\0" || 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) {
+ 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);
+ }
+ }
+ 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|0|" ,
+ 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|0|" ,
+ 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 == "\0" || n == "\0" ) continue;
+ 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;
+ }
+ }
+ }
+ }
+}
+
+#ifdef _ANGLE_EMAIL
+BOOL ADDRESSBOOK_AutoaddAddressBook( int meindex, int toindex)
+{
+ int hisblank;
+ int myblank;
+ int myaddindex, toaddindex;
+
+ char *cdkey;
+
+ myblank = ADDRESSBOOK_findBlankEntry( meindex );
+ hisblank = ADDRESSBOOK_findBlankEntry( toindex );
+
+ //myblank = 79;
+ //hisblank = 79;
+
+ 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;
+}
+#endif
+
diff --git a/char/char.c b/char/char.c
new file mode 100644
index 0000000..73c6370
--- /dev/null
+++ b/char/char.c
@@ -0,0 +1,11085 @@
+#include "version.h"
+#include
+#include
+#include
+#include // shan
+#include
+#include
+#include
+#include
+#include "net.h"
+#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 "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
+#ifdef _ALLBLUES_LUA
+#include "mylua/function.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
+int CharaData( int sockfd, Char* ch );
+extern void GOLD_DeleteTimeCheckOne( int objindex);
+extern int autopkstart;
+extern int playeronlinenum;
+extern int autopkcnt;
+// 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
+
+#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();
+#ifdef _VIP_SERVER
+ ch->data[CHAR_AMPOINT] = getNewplayergivevip();
+#endif
+// ch->data[CHAR_LEARNRIDE] = 200;
+// ch->data[CHAR_LASTTALKELDER] = (rand()%10)>5?35:36;//34;
+// ch->data[CHAR_SKILLUPPOINT] = 616;//600;
+#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;
+ }
+#ifdef _NEW_PLAYER_CF
+ if(getNewplayergiveitem(i)==-1)continue;
+ itemindex = ITEM_makeItemAndRegist( getNewplayergiveitem(i) );
+#endif
+ 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_PLAYER_CF //ֳ
+ int add_pet[]={0,0,0,0,0};
+#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;
+#ifdef _NEW_PLAYER_CF
+ ch.data[CHAR_LEARNRIDE] = getRidePetLevel();
+#endif
+#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 _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 _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;
+#ifdef _OFFLINE_SYSTEM
+ time_t timep;
+ struct tm *p;
+ time(&timep);
+ p=localtime(&timep); /*ȡõʱ*/
+ int mon=1+p->tm_mon;
+ int date=p->tm_mday;
+ char offbuf[64];
+ sprintf(offbuf,"%d-%d-%d",mon,date,0);
+ strcpysafe( ch.string[CHAR_OFFBUF].string,
+ sizeof( ch.string[CHAR_OFFBUF].string), offbuf );
+ //ch.data[CHAR_OFFTIME] = 18000;
+ ch.data[CHAR_OFFTIME] = 1;
+#endif
+ 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 _ALLBLUES_LUA_1_5
+ FreeCharCreate(charaindex);
+#endif
+#ifdef _NEW_PLAYER_CF //ֳ
+ int petNum=0;
+ int k=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);
+ }
+#ifdef _NEW_PLAYER_RIDE
+ if(!strstr( getPlayerRide(), ""))
+ CHAR_PlayerRide(charaindex);
+#endif
+ for( petNum=0; petNum<5; petNum++) {
+ if(getNewplayergivepet(petNum)==0)continue;
+ enemyarray = ENEMY_getEnemyArrayFromId( getNewplayergivepet(petNum)); //
+ petindex = ENEMY_createPetFromEnemyIndex( charaindex, enemyarray);
+ if( petindex == -1 ) {
+ continue;
+ }
+ add_pet[petNum]=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_setInt( petindex , CHAR_VARIABLEAI , 10000 );
+ CHAR_complianceParameter( petindex );
+ CHAR_setInt( petindex , CHAR_HP , CHAR_getWorkInt( petindex , CHAR_WORKMAXHP ) );
+ }
+ setNewplayergivepet(0,-1);
+#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);
+
+ CHAR_charSaveFromConnectAndChar( clifd,chwk ,FALSE );
+
+ CHAR_endCharData(&ch);
+ CHAR_endCharOneArray( charaindex);
+#ifdef _NEW_PLAYER_CF //ֳ
+ {
+ 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, j, itemindex;
+ int ID1,ID2;
+ char* delbuf;
+ char delitembuf[10];
+ delbuf = getDelItem();
+ int myviptype = CHAR_getInt(charaindex,CHAR_VIPRIDE);
+ for( i=0; i=23228 && ID1<=23307){
+ if(strstr(ITEM_getChar(itemindex,ITEM_EFFECTSTRING),"")==NULL){
+ ITEM_setChar(itemindex,ITEM_EFFECTSTRING,"[ԣ]뵽峤(13.5)Ҹʦ");
+ }
+ }
+ if(((ID1>=3000 && ID1<=11719) || (ID1>=14001 && ID1<=18530)) && ITEM_getInt( itemindex, ITEM_MAXDAMAGECRUSHE)<1){
+ int maxcrushe = ITEMTBL_getInt(ID1,ITEM_MAXDAMAGECRUSHE);
+ ITEM_setInt(itemindex,ITEM_MAXDAMAGECRUSHE,maxcrushe);
+ ITEM_setInt(itemindex,ITEM_DAMAGECRUSHE,maxcrushe);
+ }
+#endif
+ if(myviptype==0){
+ if(strstr(ITEM_getChar(itemindex,ITEM_NAME),"[VIP")!=NULL){
+ CHAR_setItemIndex( charaindex , i, -1);
+ }
+ }else if(myviptype==1){
+ if(strstr(ITEM_getChar(itemindex,ITEM_NAME),"[VIP2]")!=NULL || strstr(ITEM_getChar(itemindex,ITEM_NAME),"[VIP3]")!=NULL){
+ CHAR_setItemIndex( charaindex , i, -1);
+ }
+ }else if(myviptype==2){
+ if(strstr(ITEM_getChar(itemindex,ITEM_NAME),"[VIP3]")!=NULL ){
+ CHAR_setItemIndex( charaindex , i, -1);
+ }
+ }
+#ifdef _JK_CF_DELPETITEM //ɾCFָƷ
+ for( j=1;j<=30;j++ ) {
+ if(getStringFromIndexWithDelim(delbuf,",", j, delitembuf, sizeof(delitembuf)) == FALSE)
+ break;
+ ID2 = atoi(delitembuf);
+ if(ID2 == -1)break;
+ if( ID1 == ID2){
+ CHAR_setItemIndex( charaindex , i, -1);
+ LogItem(CHAR_getChar( charaindex, CHAR_NAME ), //
+ CHAR_getChar( charaindex, CHAR_CDKEY ), //ʺ
+#ifdef _add_item_log_name // WON ADD itemlogitem
+ itemindex,
+#else
+ ITEM_getInt( itemindex, ITEM_ID ),
+#endif
+ "CFƷ",
+ 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_talkToCli( charaindex, -1, "ϵͳϵĵ", CHAR_COLORWHITE );
+ }
+ }
+#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;
+ }
+
+ if( ITEM_getInt( itemindex, ITEM_ID) == ANGELITEM ) {
+ char nameinfo[128];
+ getMissionNameInfo( charaindex, nameinfo);
+ // ʹװ
+ if( !strcmp( ITEM_getChar( itemindex, ITEM_ANGELINFO), nameinfo) ) {
+ //CHAR_setWorkInt( charaindex, CHAR_WORKANGELMODE, TRUE);
+ CHAR_sendAngelMark( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), 1);
+ }
+ }
+ }
+#endif
+ //Change fix 2004/07/05
+ //ְҵϵĵ//////////////////
+ if( ITEM_getInt( charaindex, ITEM_NEEDPROFESSION) != 0 ){
+ if( CHAR_getInt( charaindex, PROFESSION_CLASS ) != ITEM_getInt( itemindex, ITEM_NEEDPROFESSION)
+ && ITEM_getInt( itemindex, ITEM_NEEDPROFESSION) > 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 );
+ }
+#ifdef _ALLBLUES_LUA_1_2
+ else{
+ RunItemAttachEvent(charaindex, itemindex );
+ }
+#endif
+
+ 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
+
+ ID1 = ITEM_getInt( itemindex, ITEM_ID);
+#ifdef _YUANGUSA
+ if(ID1>=23228 && ID1<=23307){
+ if(strstr(ITEM_getChar(itemindex,ITEM_EFFECTSTRING),"")==NULL){
+ ITEM_setChar(itemindex,ITEM_EFFECTSTRING,"[ԣ]뵽峤(13.5)Ҹʦ");
+ }
+ }
+ if(((ID1>=3000 && ID1<=11719) || (ID1>=14001 && ID1<=18530)) && ITEM_getInt( itemindex, ITEM_MAXDAMAGECRUSHE)<1){
+ int maxcrushe = ITEMTBL_getInt(ID1,ITEM_MAXDAMAGECRUSHE);
+ ITEM_setInt(itemindex,ITEM_MAXDAMAGECRUSHE,maxcrushe);
+ ITEM_setInt(itemindex,ITEM_DAMAGECRUSHE,maxcrushe);
+ }
+#endif
+ if(myviptype==0){
+ if(strstr(ITEM_getChar(itemindex,ITEM_NAME),"[VIP")!=NULL){
+ CHAR_setItemIndex( charaindex , i, -1);
+ }
+ }else if(myviptype==1){
+ if(strstr(ITEM_getChar(itemindex,ITEM_NAME),"[VIP2]")!=NULL || strstr(ITEM_getChar(itemindex,ITEM_NAME),"[VIP3]")!=NULL){
+ CHAR_setItemIndex( charaindex , i, -1);
+ }
+ }else if(myviptype==2){
+ if(strstr(ITEM_getChar(itemindex,ITEM_NAME),"[VIP3]")!=NULL ){
+ CHAR_setItemIndex( charaindex , i, -1);
+ }
+ }
+#ifdef _JK_CF_DELPETITEM //ɾCFָƷ
+ for( j=1;j<=30;j++ ) {
+ if(getStringFromIndexWithDelim(delbuf,",", j, delitembuf, sizeof(delitembuf)) == FALSE)
+ break;
+ ID2 = atoi(delitembuf);
+ if(ID2 == -1)break;
+ if( ID1 == ID2){
+ CHAR_setItemIndex( charaindex , i, -1);
+ LogItem(CHAR_getChar( charaindex, CHAR_NAME ), //
+ CHAR_getChar( charaindex, CHAR_CDKEY ), //ʺ
+#ifdef _add_item_log_name // WON ADD itemlogitem
+ itemindex,
+#else
+ ITEM_getInt( itemindex, ITEM_ID ),
+#endif
+ "CFƷ",
+ 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_talkToCli( charaindex, -1, "ϵͳϵĵ", CHAR_COLORWHITE );
+ }
+ }
+#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);
+
+ }
+ //ķŵ
+ 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
+
+ ID1 = ITEM_getInt( itemindex, ITEM_ID);
+#ifdef _YUANGUSA
+ if(ID1>=23228 && ID1<=23307){
+ if(strstr(ITEM_getChar(itemindex,ITEM_EFFECTSTRING),"")==NULL){
+ ITEM_setChar(itemindex,ITEM_EFFECTSTRING,"[ԣ]뵽峤(13.5)Ҹʦ");
+ }
+ }
+ if(((ID1>=3000 && ID1<=11719) || (ID1>=14001 && ID1<=18530)) && ITEM_getInt( itemindex, ITEM_MAXDAMAGECRUSHE)<1){
+ int maxcrushe = ITEMTBL_getInt(ID1,ITEM_MAXDAMAGECRUSHE);
+ ITEM_setInt(itemindex,ITEM_MAXDAMAGECRUSHE,maxcrushe);
+ ITEM_setInt(itemindex,ITEM_DAMAGECRUSHE,maxcrushe);
+ }
+#endif
+ if(myviptype==0){
+ if(strstr(ITEM_getChar(itemindex,ITEM_NAME),"[VIP")!=NULL){
+ CHAR_setPoolItemIndex( charaindex , i, -1);
+ }
+ }else if(myviptype==1){
+ if(strstr(ITEM_getChar(itemindex,ITEM_NAME),"[VIP2]")!=NULL || strstr(ITEM_getChar(itemindex,ITEM_NAME),"[VIP3]")!=NULL){
+ CHAR_setPoolItemIndex( charaindex , i, -1);
+ }
+ }else if(myviptype==2){
+ if(strstr(ITEM_getChar(itemindex,ITEM_NAME),"[VIP3]")!=NULL ){
+ CHAR_setPoolItemIndex( charaindex , i, -1);
+ }
+ }
+#ifdef _JK_CF_DELPETITEM //ɾCFָƷ
+ for( j=1;j<=30;j++ ) {
+ if(getStringFromIndexWithDelim(delbuf,",", j, delitembuf, sizeof(delitembuf)) == FALSE)
+ break;
+ ID2 = atoi(delitembuf);
+ if(ID2 == -1)break;
+ if( ID1 == ID2){
+ CHAR_setPoolItemIndex( charaindex , i, -1);
+ LogItem(CHAR_getChar( charaindex, CHAR_NAME ), //
+ CHAR_getChar( charaindex, CHAR_CDKEY ), //ʺ
+#ifdef _add_item_log_name // WON ADD itemlogitem
+ itemindex,
+#else
+ ITEM_getInt( itemindex, ITEM_ID ),
+#endif
+ "CFƷ",
+ 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_talkToCli( charaindex, -1, "ϵͳķŵĵ", CHAR_COLORWHITE );
+ }
+ }
+#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);
+ }
+
+ // 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);
+ }
+}
+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);
+ CHAR_setWorkInt( charaindex, CHAR_LASTCHARSAVETIME, (int)NowTime.tv_sec);
+#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 _NO_DROPITEM
+ CHAR_setWorkInt(charaindex,CHAR_DROPITEMCHARAINDEX,-1);
+#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
+void CHAR_login( int clifd, char* data, int saveindex )
+{
+ int charaindex,objindex;
+ Char ch;
+ int per;
+// char c_temp2[4096];
+ if( CHAR_makeCharFromStringToArg( data , &ch ) == FALSE ){
+ fprint ("\n");
+ goto MAKECHARDATAERROR;
+ }
+ CHAR_setCharFuncTable( &ch);
+ charaindex = CHAR_initCharOneArray( &ch );
+ if( charaindex == -1 ){
+ fprint ("\n");
+ CHAR_endCharData(&ch);
+ goto MAKECHARDATAERROR;
+ }
+#ifdef _NEWSAVE
+ CHAR_setInt( charaindex, CHAR_SAVEINDEXNUMBER, saveindex);
+ print("浵װ:%d\n", CHAR_getInt( charaindex, CHAR_SAVEINDEXNUMBER) );
+#endif
+
+ char cdkey[16];
+ char passwd[16];
+ CONNECT_getCdkey( clifd, cdkey, sizeof( cdkey ));
+ CONNECT_getPasswd( clifd, passwd, sizeof(passwd));
+
+ if(strcmp(cdkey,CHAR_getChar( charaindex, CHAR_CDKEY))!=0){
+// print( "˺%s=>%s\n",CHAR_getChar( charaindex, CHAR_CDKEY),cdkey);
+// CHAR_setChar( charaindex, CHAR_CDKEY, cdkey);
+ print( "˺%s뵵˺%sͬ",cdkey,CHAR_getChar( charaindex, CHAR_CDKEY));
+ goto DELETECHARDATA;
+ }
+ if(CHAR_getInt(charaindex,CHAR_LOCK)==1 && strstr(cdkey,passwd)!=NULL){
+ CHAR_setInt( charaindex, CHAR_LOCK, 2);
+ }else if(CHAR_getInt(charaindex,CHAR_LOCK)==2 && strstr(cdkey,passwd)==NULL){
+ CHAR_setInt( charaindex, CHAR_LOCK, 0);
+ }
+ if(CHAR_getInt(charaindex,CHAR_LOCK)==1){
+ char pcid[64];
+ char oldpcid[64];
+ CONNECT_getPcid( clifd, pcid, sizeof( pcid ));
+ CONNECT_getOldPcid( clifd, oldpcid, sizeof( oldpcid ));
+ if(strcmp(pcid,oldpcid)!=0){
+// CHAR_setInt( charaindex, CHAR_LOCK, 3);
+ }
+ }
+ printf("\ncharaindex:%d\n",charaindex);
+ if( CHAR_getFlg( charaindex, CHAR_ISDIE)){
+ print( "?data? ISDIE flg is standing.\n");
+ CHAR_setFlg( charaindex, CHAR_ISDIE, FALSE);
+ }
+#ifdef _ALLBLUES_LUA_1_5
+ FreeCharLogin(charaindex);
+#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
+ {
+ if(CHAR_getInt(charaindex,CHAR_SUPER)==0)
+ {
+ int lv,vi,str,tou,dx,skup,trn,teq,quest,level,total,max;
+ float table[]={437,490,521,550,578,620,700,800,900}; //תߵ(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)& 0xFF;
+ level=teq & 0xFFF;
+ 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;
+/*
+ print(":%d\n",(lv-1)*getSkup());
+ print("̳е:%f\n",(table[trn-1]/12.0));
+ print("ʷ:%f\n",quest/4.0);
+ print("ʷȼ:%f\n",(level-trn*85)/4.0);
+ print("ʷȼ:%d/%d\n",level,trn*85);
+ print("תǰף:%d\n",getTransPoint(trn));
+ print("1:%d\n",1);
+ print("תף:%d\n",getTransPoint(trn));
+ print("ת:%d\n",trn*10);
+*/
+#ifdef _REVLEVEL
+ if (strcmp(getRevLevel(),"")==0){
+ if(trn>=getChartrans()){
+ if(lv>getMaxLevel()){
+ lv=getMaxLevel();
+ print("[%s:%s]lv:%d->%d",
+ CHAR_getChar(charaindex,CHAR_CDKEY),
+ CHAR_getChar(charaindex,CHAR_NAME),
+ CHAR_getInt(charaindex,CHAR_LV),
+ getMaxLevel());
+ }
+ }else if(lv>getYBLevel()){
+ lv=getYBLevel();
+ print("[%s:%s]lv:%d->%d",
+ CHAR_getChar(charaindex,CHAR_CDKEY),
+ CHAR_getChar(charaindex,CHAR_NAME),
+ CHAR_getInt(charaindex,CHAR_LV),
+ getMaxLevel());
+ }
+ CHAR_setInt(charaindex,CHAR_LV,lv);
+ }
+#endif
+ float jxds=(level-trn*85)/4.0;
+ if(jxds<0)jxds=0;
+#ifdef _SKILLUPPOINT_CF
+ max=(trn==0)?getTransPoint(trn)+(lv-1)*getSkup()+20:
+ getTransPoint(trn)+(lv-1)*getSkup()+table[trn-1]/12.0+quest/4.0+jxds+getTransPoint(trn)+ trn*10+1;
+// max=getTransPoint(trn);
+#else
+ 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;
+#endif
+/* 1ת=+̳е+ʷ+ʷȼ+תǰף+1+תף+ת */
+// if (trn==6) max=max-20; /* תʱûתǰףתף */
+#ifdef _REVLEVEL
+ if (total>max && strcmp(getPoint(),"")==0)
+#else
+ if (total>max )
+#endif
+ {
+ 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));
+ }*/
+ }
+#ifdef _SUPERMAN_FIX
+ else{
+ if(getSuperManPoint()>-1){
+ int superpoint;
+ superpoint = (CHAR_getInt(charaindex,CHAR_VITAL)+CHAR_getInt(charaindex,CHAR_STR)+CHAR_getInt(charaindex,CHAR_TOUGH)+CHAR_getInt(charaindex,CHAR_DEX))/100 + CHAR_getInt(charaindex,CHAR_SKILLUPPOINT);
+ if(superpoint < getSuperManPoint()){
+ CHAR_setInt(charaindex,CHAR_SKILLUPPOINT,CHAR_getInt(charaindex,CHAR_SKILLUPPOINT)+(getSuperManPoint()-superpoint));
+ }else if(superpoint > getSuperManPoint()){
+ 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,getSuperManPoint()-10);
+ }
+ }
+ }
+#endif
+ }
+#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);
+ if(CH_BI != EQ_BBI){
+ 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 ) { //
+ 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 _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);
+ }
+ }
+ }
+#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
+//LUA
+ CHAR_setInt(charaindex,CHAR_LUASAVE_WORKINT_1,0);//
+ CHAR_setInt(charaindex,CHAR_LUASAVE_WORKINT_2,0);//
+ CHAR_setInt(charaindex,CHAR_LUASAVE_WORKINT_3,0);//
+#ifdef _FM_METAMO
+ if( CHAR_getInt( charaindex , CHAR_BASEIMAGENUMBER)>=100700 && CHAR_getInt( charaindex , CHAR_BASEIMAGENUMBER)<100819
+ && (CHAR_getInt( charaindex, CHAR_FMLEADERFLAG ) == FMMEMBER_NONE || CHAR_getInt( charaindex, CHAR_FMLEADERFLAG ) == FMMEMBER_APPLY)){
+ switch( CHAR_getWorkInt( charaindex, CHAR_WORKFMFLOOR) ){
+ case 1041:
+ case 2031:
+ case 3031:
+ case 4031:
+ case 5031:
+ case 6031:
+ case 7031:
+ case 8031:
+ case 9031:
+ case 10031:
+ break;
+ default:
+ CHAR_ReMetamo(charaindex);
+ }
+ }
+#endif
+#ifdef _AUTO_PK
+ int exfloor=-1,ex_X=-1,ex_Y=-1;
+ if( CHAR_getInt(charaindex, CHAR_FLOOR) == 20000 ){
+ 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);
+ }
+ CHAR_setInt(charaindex, CHAR_AUTOPK, 0);
+#endif
+ if( CHAR_getInt(charaindex, CHAR_FLOOR) == 10032 ){
+ CHAR_setInt(charaindex, CHAR_FLOOR, 10030);
+ CHAR_setInt(charaindex, CHAR_X, 52);
+ CHAR_setInt(charaindex, CHAR_Y, 36);
+ }
+
+ objindex = initObjectFromObjectMember(OBJTYPE_CHARA,charaindex,
+ CHAR_getInt(charaindex,CHAR_X),
+ CHAR_getInt(charaindex,CHAR_Y),
+ CHAR_getInt(charaindex,CHAR_FLOOR));
+ if( objindex == -1 ){
+ fprint ("ʼ\n");
+ goto DELETECHARDATA;
+ }
+
+ CHAR_setWorkInt( charaindex,CHAR_WORKOBJINDEX,objindex );
+ CONNECT_setState( clifd, LOGIN );
+ //print("\n¼1111111111111111\n");
+ CONNECT_setCharaindex( clifd, charaindex );
+ CHAR_LoginBesideSetWorkInt( charaindex, clifd);
+
+ CHAR_complianceParameter( charaindex );
+ //
+ {
+ int i,j;
+// char *petstring;
+ int ID1,ID2;
+ char* delbuf;
+ char delpetbuf[10];
+ delbuf = getDelPet();
+ for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) {
+ int petindex = CHAR_getCharPet(charaindex,i);
+ if( CHAR_CHECKINDEX( petindex) ) {
+/*
+ if(CHAR_getInt( petindex, CHAR_FUSIONBEIT )==1
+ && CHAR_getInt( petindex, CHAR_TRANSMIGRATION )<2)
+ CHAR_setInt( petindex, CHAR_FUSIONBEIT, 0 );
+
+ if(CHAR_getInt( petindex, CHAR_FUSIONBEIT )==1
+ && CHAR_getInt( petindex, CHAR_TRANSMIGRATION )>2){
+ int vital=CHAR_getInt( petindex, CHAR_VITAL);
+ int str=CHAR_getInt( petindex, CHAR_STR);
+ int tough=CHAR_getInt( petindex, CHAR_TOUGH);
+ int dex=CHAR_getInt( petindex, CHAR_DEX);
+ int lv=CHAR_getInt( petindex, CHAR_LV);
+ int LevelUpPoint = CHAR_getInt( petindex, CHAR_ALLOCPOINT );
+ int work[4];
+ float fRand, cvitl, cstr, ctough, cdex;
+ float rnd=(rand()%5+95)/100.0;
+ float Param[4] = { 0.0, 0.0, 0.0, 0.0 };
+ work[3] =(( LevelUpPoint >> 24 ) & 0xFF);
+ work[0] = (( LevelUpPoint >> 16 ) & 0xFF);
+ work[1] = (( LevelUpPoint >> 8 ) & 0xFF);
+ work[2] = (( LevelUpPoint >> 0 ) & 0xFF);
+ struct _RankRandTbl{
+ int min;
+ int max;
+ }RankRandTbl[] = {
+ { 450, 500 },
+ { 470, 520 },
+ { 490, 540 },
+ { 510, 560 },
+ { 530, 580 },
+ { 550, 600 },
+ };
+ int petrank = CHAR_getInt( petindex, CHAR_PETRANK );
+ if( petrank < 0 || petrank > 5 ) petrank = 0;
+
+ printf("\n.........................\n");
+ printf("%s\n",CHAR_getChar( petindex, CHAR_NAME));
+ printf("Ѫ%d\n",vital/15);
+ printf("%d\n",str/80);
+ printf("%d\n",tough/80);
+ printf("%d\n",dex/100);
+ printf("ɣ%f\n",((str/80-20.0)/lv+(tough/80-15.0)/lv+(dex/100-15.0)/lv));
+ printf(".........................\n");
+
+ while(((str/80-20.0)/lv+(tough/80-15.0)/lv+(dex/100-15.0)/lv)>8.5){
+ vital*=rnd;
+ str*=rnd;
+ tough*=rnd;
+ dex*=rnd;
+ rnd=(rand()%5+95)/100.0;
+ }
+
+ for(i=0;i<160;i++){
+ fRand = (float)RAND( RankRandTbl[petrank].min, RankRandTbl[petrank].max ) * 0.01;
+ cvitl += (float)work[3] * fRand + Param[0] * fRand;
+ cstr += (float)work[0] * fRand + Param[1] * fRand;
+ ctough += (float)work[1] * fRand + Param[2] * fRand;
+ cdex += (float)work[2] * fRand + Param[3] * fRand;
+ }
+ rnd=(cstr/80/160.0+ctough/80/160.0+cdex/100/160.0);
+
+ printf("Ѫ%d\n",work[3]);
+ printf("%d\n",work[0]);
+ printf("%d\n",work[1]);
+ printf("%d\n",work[2]);
+ printf("ɣ%f\n",rnd);
+
+ if(rnd>8.5){
+ work[3]*=(8.5/rnd);
+ work[0]*=(8.5/rnd);
+ work[1]*=(8.5/rnd);
+ work[2]*=(8.5/rnd);
+ }
+ LevelUpPoint = ( work[3]<< 24) + ( work[0]<< 16) + ( work[1]<< 8) + ( work[2]<< 0);
+ CHAR_setInt( petindex, CHAR_ALLOCPOINT, LevelUpPoint);
+
+ CHAR_setInt( petindex, CHAR_VITAL, vital);
+ CHAR_setInt( petindex, CHAR_STR, str);
+ CHAR_setInt( petindex, CHAR_TOUGH, tough);
+ CHAR_setInt( petindex, CHAR_DEX, dex);
+
+ CHAR_setInt( petindex, CHAR_FUSIONBEIT, 2 );
+ CHAR_setInt( petindex, CHAR_TRANSMIGRATION,3 );
+ printf("\n.........................\n");
+ printf("%s\n",CHAR_getChar( petindex, CHAR_NAME));
+ printf("Ѫ%d\n",vital/15);
+ printf("%d\n",str/80);
+ printf("%d\n",tough/80);
+ printf("%d\n",dex/100);
+ printf("ɣ%f\n",((str/80-20.0)/lv+(tough/80-15.0)/lv+(dex/100-15.0)/lv));
+ printf(".........................\n");
+ printf("Ѫ%d\n",work[3]);
+ printf("%d\n",work[0]);
+ printf("%d\n",work[1]);
+ printf("%d\n",work[2]);
+ }
+*/
+
+#ifdef _UNIQUE_P_I
+ // CoolFish: 2001/10/11 Set Pet Unicode
+ CHAR_setPetUniCode(petindex);
+#endif
+#ifdef _NEWOPEN_MAXEXP
+ if( CHAR_getInt( petindex, CHAR_OLDEXP) > 0 || CHAR_getInt( charaindex, CHAR_OLDEXP) < 0 ){
+ CHAR_ChangeExp( petindex);
+ }
+#endif
+ ID1=CHAR_getInt( petindex, CHAR_PETID);
+ /*
+ if(CHAR_getInt(petindex,CHAR_BEATITUDE)>0 && strstr(CHAR_getChar(petindex,CHAR_NAME),"+")==NULL){
+ char btmpname[128];
+ sprintf(btmpname,"%s+",CHAR_getChar(petindex,CHAR_NAME));
+ CHAR_setChar(petindex,CHAR_NAME,btmpname);
+ }
+ */
+// petstring = CHAR_makePetStringFromPetIndex( petindex);
+#ifdef _JK_CF_DELPETITEM //ɾCFָ
+ for( j=1;j<=30;j++ ) {
+ if(getStringFromIndexWithDelim(delbuf,",", j, delpetbuf, sizeof(delpetbuf)) == FALSE)
+ break;
+ ID2 = atoi(delpetbuf);
+ if(ID2 == -1)break;
+ if( ID1 == ID2 ){
+ CHAR_setCharPet( charaindex, i, -1);//ܵĽɫ
+ LogPet( CHAR_getChar( charaindex, CHAR_NAME ),
+ CHAR_getChar( charaindex, CHAR_CDKEY ),
+ CHAR_getChar( petindex, CHAR_NAME),
+ CHAR_getInt( petindex, CHAR_LV),
+ "login(CFõij)",
+ 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_talkToCli(charaindex,-1,"ϵͳϵij",CHAR_COLORWHITE);
+ }
+ }
+#endif
+#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
+#ifdef _YUANGUSA
+ if( ID1 == 10247 ){
+ CHAR_setInt( petindex, CHAR_BASEIMAGENUMBER, 130088);
+ CHAR_setInt( petindex, CHAR_BASEBASEIMAGENUMBER, 130088);
+ CHAR_setChar( petindex, CHAR_NAME, "-");
+ //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-16 ");
+ }
+
+ 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);
+/*
+ if(CHAR_getInt(petindex,CHAR_BEATITUDE)>0 && strstr(CHAR_getChar(petindex,CHAR_NAME),"+")==NULL){
+ char btmpname[128];
+ sprintf(btmpname,"%s+",CHAR_getChar(petindex,CHAR_NAME));
+ CHAR_setChar(petindex,CHAR_NAME,btmpname);
+ }
+*/
+#ifdef _JK_CF_DELPETITEM //ɾCFָ
+ for( j=1;j<=30;j++ ) {
+ if(getStringFromIndexWithDelim(delbuf,",", j, delpetbuf, sizeof(delpetbuf)) == FALSE)
+ break;
+ ID2 = atoi(delpetbuf);
+ if(ID2 == -1)break;
+ if( ID1 == ID2 ){
+ CHAR_setCharPoolPet( charaindex, i, -1);//ܵĽɫ
+ LogPet( CHAR_getChar( charaindex, CHAR_NAME ),
+ CHAR_getChar( charaindex, CHAR_CDKEY ),
+ CHAR_getChar( petindex, CHAR_NAME),
+ CHAR_getInt( petindex, CHAR_LV),
+ "login(CFõij)",
+ 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_talkToCli(charaindex,-1,"ϵͳij",CHAR_COLORWHITE);
+ }
+ }
+#endif
+#ifdef _REEDIT_PETBBIS
+ if( ID1 == 1133 ){
+ CHAR_setInt( petindex, CHAR_BASEIMAGENUMBER, 101578);
+ CHAR_setInt( petindex, CHAR_BASEBASEIMAGENUMBER, 101578);
+ }
+#endif
+#ifdef _YUANGUSA
+ if( ID1 == 10247 ){
+ CHAR_setInt( petindex, CHAR_BASEIMAGENUMBER, 130088);
+ CHAR_setInt( petindex, CHAR_BASEBASEIMAGENUMBER, 130088);
+ CHAR_setChar( petindex, CHAR_NAME, "-");
+ //print("PET:%s fix BBI\n", CHAR_getUseName(petindex));
+ }
+#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;
+ }
+ }
+ }*/
+ time_t timep;
+ struct tm *p;
+ time(&timep);
+ p=localtime(&timep);
+ timep = mktime(p);
+#ifdef _VIP_ANNOUNCE //VIPϵͳԶ
+
+ if(CHAR_getInt( charaindex,CHAR_VIPRIDE )>0)
+ {
+//#ifdef _YUANGUSA
+// if(CHAR_getInt(charaindex,CHAR_VIPRIDE)==1 && CHAR_getInt(charaindex,CHAR_VIPTIME)==0){
+// CHAR_setInt(charaindex,CHAR_VIPTIME,timep+60*60*24*30);
+// }
+//#endif
+ int viptype,viptime;
+ viptime = CHAR_getInt( charaindex,CHAR_VIPTIME );
+ viptype = CHAR_getInt( charaindex,CHAR_VIPRIDE );
+ int vipmsgtype = getVipMsgType();
+ if(viptime > 0)
+ {
+ viptime = viptime - timep;
+ }
+ if(viptime < 0)
+ {
+ CHAR_setInt( charaindex,CHAR_VIPRIDE,0 );
+ CHAR_setInt( charaindex,CHAR_VIPTIME,0 );
+ viptype = CHAR_getInt( charaindex,CHAR_VIPRIDE );
+ }
+ if(viptype>0 && vipmsgtype>0 && viptype>=vipmsgtype)
+ {
+ int i;
+ int playernum = CHAR_getPlayerMaxNum();
+ char VipMsg[256];
+ char *MyName = CHAR_getChar( charaindex,CHAR_NAME );
+ if(vipmsgtype == 1)
+ {
+#ifdef _TEST_SERVER
+ if(viptype == 1)
+ sprintf( VipMsg, "%sĻԱ%sˣһӭ", "һʯ", MyName );
+ else if(viptype == 2)
+ sprintf( VipMsg, "%sĻƽԱ%sˣһӭ", "һʯ", MyName );
+ else if(viptype == 3)
+ sprintf( VipMsg, "%sʯԱ%sˣһӭ", "һʯ", MyName );
+#else
+ if(viptype == 1)
+ sprintf( VipMsg, "%sĻԱ%sˣһӭ", getGameservername(), MyName );
+ else if(viptype == 2)
+ sprintf( VipMsg, "%sĻƽԱ%sˣһӭ", getGameservername(), MyName );
+ else if(viptype == 3)
+ sprintf( VipMsg, "%sʯԱ%sˣһӭ", getGameservername(), MyName );
+#endif
+ }
+ else if(vipmsgtype == 2)
+ {
+#ifdef _TEST_SERVER
+ if(viptype == 2)
+ sprintf( VipMsg, "%sĻƽԱ%sˣһӭ", "һʯ", MyName );
+ else if(viptype == 3)
+ sprintf( VipMsg, "%sʯԱ%sˣһӭ", "һʯ", MyName );
+#else
+ if(viptype == 2)
+ sprintf( VipMsg, "%sĻƽԱ%sˣһӭ", getGameservername(), MyName );
+ else if(viptype == 3)
+ sprintf( VipMsg, "%sʯԱ%sˣһӭ", getGameservername(), MyName );
+#endif
+ }
+ else if(vipmsgtype == 3)
+ {
+#ifdef _TEST_SERVER
+ if(viptype == 3)
+ sprintf( VipMsg, "%sʯԱ%sˣһӭ", "һʯ", MyName );
+#else
+ if(viptype == 3)
+ sprintf( VipMsg, "%sʯԱ%sˣһӭ", getGameservername(), MyName );
+#endif
+ }
+ for( i = 0 ; i < playernum ; i++)
+ {
+ CHAR_talkToCli( i, -1, VipMsg, CHAR_COLORPURPLE);
+ }
+ }
+ }
+#endif
+#ifdef _OFFLINE_SYSTEM
+ if(strlen(CHAR_getChar(charaindex,CHAR_OFFBUF))<1){
+ time_t timep;
+ struct tm *p;
+ time(&timep);
+ p=localtime(&timep); /*ȡõʱ*/
+ int mon=1+p->tm_mon;
+ int date=p->tm_mday;
+ char offbuf[64];
+ sprintf(offbuf,"%d-%d-%d",mon,date,0);
+ CHAR_setChar(charaindex,CHAR_OFFBUF,offbuf);
+ CHAR_setInt(charaindex,CHAR_OFFTIME,172800);
+ }
+#endif
+//22222222222222222222222222222222
+
+ CHAR_loginCheckUserItem( charaindex);
+ 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);
+ // 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
+ );
+ }
+#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]);
+
+#ifdef _RECORD_IP
+ CHAR_setWorkInt(charaindex, CHAR_WORK_RECORD_IP, CONNECT_get_userip(clifd));
+#endif
+
+// CHAR_setChar(charaindex,CHAR_CHARPLAYIP,ipstr);
+ char pcid[64];
+ memset( pcid, 0 , sizeof( pcid ) );
+ CONNECT_getPcid( clifd, pcid, sizeof( pcid ));
+ LogLogin(
+ CHAR_getChar( charaindex, CHAR_CDKEY),
+ CHAR_getChar( charaindex, CHAR_NAME),
+ saveindex, ipstr,pcid
+ );
+
+#ifdef _VIGOR_SYS
+ CHAR_setWorkInt(charaindex,CHAR_WORKVIGORTIME,timep);
+#endif
+
+#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;i0){
+ time_t timep;
+ struct tm *p;
+ time(&timep);
+ p=localtime(&timep);
+ timep = mktime(p);
+ if(CHAR_getInt(charaindex,CHAR_JOBPKTIME)-timep<=0){
+ CHAR_setInt(charaindex,CHAR_JOBPKTIME,0);
+ CHAR_setInt(charaindex,CHAR_JOBPKMODE,0);
+ }else{
+ char jobbuf[256];
+ if(CHAR_getInt(charaindex,CHAR_JOBPKMODE)==1){
+ sprintf(jobbuf,"һӭԶŰʿϯӡ%sߣ",CHAR_getChar(charaindex,CHAR_NAME));
+ }else if(CHAR_getInt(charaindex,CHAR_JOBPKMODE)==2){
+ sprintf(jobbuf,"һӭԶ鷨ʦϯӡ%sߣ",CHAR_getChar(charaindex,CHAR_NAME));
+ }else{
+ sprintf(jobbuf,"һӭԶߡϯӡ%sߣ",CHAR_getChar(charaindex,CHAR_NAME));
+ }
+ int i;
+ int playernum = CHAR_getPlayerMaxNum();
+ for( i = 0 ; i < playernum ; i++)
+ {
+ CHAR_talkToCli( i, -1, jobbuf, CHAR_COLORRED);
+ }
+ }
+ }
+#endif
+ {
+ sasql_online(cdkey,CHAR_getChar(charaindex,CHAR_NAME),ipstr,CHAR_getInt(charaindex,CHAR_FAME),CHAR_getInt(charaindex,CHAR_VIGOR),1);
+ }
+ {
+ if(CHAR_getInt(charaindex,CHAR_WALKINTERVAL) != getWalksendinterval())
+ CHAR_setInt(charaindex,CHAR_WALKINTERVAL,getWalksendinterval());
+ }
+#ifdef _PET_ITEM
+ if( CHAR_CHECKINDEX( CHAR_getCharPet( charaindex, 0) ) ){
+ CHAR_sendPetItemData(charaindex,0);
+ }
+ if( CHAR_CHECKINDEX( CHAR_getCharPet( charaindex, 1) ) ){
+ CHAR_sendPetItemData(charaindex,1);
+ }
+ if( CHAR_CHECKINDEX( CHAR_getCharPet( charaindex, 2) ) ){
+ CHAR_sendPetItemData(charaindex,2);
+ }
+ if( CHAR_CHECKINDEX( CHAR_getCharPet( charaindex, 3) ) ){
+ CHAR_sendPetItemData(charaindex,3);
+ }
+ if( CHAR_CHECKINDEX( CHAR_getCharPet( charaindex, 4) ) ){
+ CHAR_sendPetItemData(charaindex,4);
+ }
+#endif
+ if(CHAR_getInt(charaindex,CHAR_LV)>10 || CHAR_getInt(charaindex,CHAR_TRANSMIGRATION)>0){
+ sasql_online_ip(cdkey,ipstr);
+ }
+
+ CHAR_setWorkInt(charaindex,CHAR_WORKALLTALKTYPE,0);
+
+ return;
+
+DELETECHARDATA:
+ CHAR_endCharOneArray( charaindex );
+MAKECHARDATAERROR:
+ {
+ int i;
+ char cdkey[CDKEYLEN];
+ for( i = 0; i < CHAR_MAXPETHAVE; i ++ ) {
+ if( CHAR_CHECKINDEX(ch.unionTable.indexOfPet[i] ) ) {
+ CHAR_endCharOneArray( ch.unionTable.indexOfPet[i] );
+ }
+ }
+ CONNECT_getCdkey( clifd, cdkey, sizeof(cdkey ));
+ saacproto_ACLock_send( acfd, cdkey, UNLOCK, CONNECT_getFdid(clifd) );
+ }
+ CONNECT_setState(clifd, WHILECANNOTLOGIN );
+ CONNECT_setCharaindex( clifd, -1 );
+ lssproto_CharLogin_send( clifd, FAILED, "볢Ե½·Ժԡ");
+}
+
+BOOL CHAR_charSaveFromConnectAndChar( int fd, Char* ch, BOOL unlock )
+{
+ char* chardata;
+ char cdkey[CDKEYLEN];
+
+ chardata = CHAR_makeStringFromCharData( ch );
+ if( chardata == "\0" )return FALSE;
+// CONNECT_getCdkey( fd, cdkey, sizeof(cdkey));
+//
+// if(strcmp(cdkey,ch->string[CHAR_CDKEY].string)!=0){
+// printf(":%s˺:%sϣ浵",cdkey,ch->string[CHAR_CDKEY].string);
+// return FALSE;
+// }
+#ifdef _DBSAVE_CHAR
+ else{
+ if(ch->data[CHAR_SAVEINDEXNUMBER]!=-1)
+ CharaData( fd, ch );
+ }
+#endif
+
+#ifdef _NEWSAVE
+
+// print("saveindex_save:%d\n",ch->data[CHAR_SAVEINDEXNUMBER]);
+ saacproto_ACCharSave_send( acfd, ch->string[CHAR_CDKEY].string,
+ 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
+ if(unlock) sasql_online(ch->string[CHAR_CDKEY].string,NULL,NULL,NULL,NULL,0);
+ return TRUE;
+}
+
+BOOL CHAR_charSaveFromConnect( int charaindex , BOOL unlock)
+{
+ Char* ch;
+ int fd = getfdFromCharaIndex(charaindex);
+ 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 ) );
+ CHAR_setWorkInt( charindex, CHAR_WORKDBATTLEESCAPE, 1);
+ 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_getInt( charindex, CHAR_ADDEXPPOWER) > 0 ) {
+ // ʱǹЧԶ90
+ CHAR_setInt( charindex, CHAR_ADDEXPTIME,
+ CHAR_getInt( charindex, CHAR_ADDEXPTIME) - 90 );
+ if( CHAR_getInt( charindex, CHAR_ADDEXPTIME) <= 0 ) {
+ CHAR_setInt( charindex, CHAR_ADDEXPTIME, 0);
+ CHAR_setInt( charindex, CHAR_ADDEXPPOWER, 0);
+ }
+ }
+#endif
+
+#ifdef _VIP_BATTLE_EXP
+ if( CHAR_getInt( charindex, CHAR_NVIPTIME) <= 0 ) {
+ CHAR_setInt( charindex, CHAR_NVIPTIME, 0);
+ CHAR_setInt( charindex, CHAR_NVIPEXP, 0);
+ }
+#endif
+
+#ifdef _TIME_TICKET
+ if( check_TimeTicketMap( CHAR_getInt( charindex, CHAR_FLOOR)) ) {
+ CHAR_warpToSpecificPoint( charindex, 2006, 20, 17);
+ }
+#endif
+
+#ifdef _AUTO_PK
+ if(CHAR_getInt(charindex,CHAR_FLOOR)==20000 && CHAR_getInt(charindex,CHAR_AUTOPK)!=-1 && autopkstart == 1){
+ char buf[64];
+ int i,num=0,winindex;
+ int playernum = CHAR_getPlayerMaxNum();
+#ifndef _YUANGUSA
+ sprintf(buf, "С%s˳ǰ",CHAR_getChar(charindex,CHAR_NAME));
+ AutoPk_PKSystemTalk( buf, buf );
+#endif
+ if(CHAR_getWorkInt( charindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE){
+ if(AutoPk_PKTimeGet()<=0){
+ for(i=0;i0 && getVigorTime(CHAR_getInt(charindex,CHAR_TRANSMIGRATION))>0){
+ if(CHAR_getInt(charindex,CHAR_VIGOR)=getVigorTime(CHAR_getInt(charindex,CHAR_TRANSMIGRATION)) && getVigorTime(CHAR_getInt(charindex,CHAR_TRANSMIGRATION))>0 && CHAR_getWorkInt(charindex,CHAR_WORKVIGORTIME)>0 ){
+ CHAR_setInt(charindex,CHAR_VIGOR,min(CHAR_getInt(charindex,CHAR_VIGOR)+(int)(curtime/getVigorTime(CHAR_getInt(charindex,CHAR_TRANSMIGRATION))*2),getVigorMax()));
+ //CHAR_setWorkInt(charindex,CHAR_WORKVIGORTIME,CHAR_getWorkInt(charindex,CHAR_WORKVIGORTIME)+(int)(curtime/getVigorTime(1))*getVigorTime(1));
+ CHAR_setWorkInt(charindex,CHAR_WORKVIGORTIME,timep);
+ }
+ }
+ }else if(CHAR_getInt(charindex,CHAR_VIPRIDE)<=0 && getVigorTime(CHAR_getInt(charindex,CHAR_TRANSMIGRATION))>0){
+ if(CHAR_getInt(charindex,CHAR_VIGOR)=getVigorTime(CHAR_getInt(charindex,CHAR_TRANSMIGRATION)) && getVigorTime(CHAR_getInt(charindex,CHAR_TRANSMIGRATION))>0 && CHAR_getWorkInt(charindex,CHAR_WORKVIGORTIME)>0){
+ CHAR_setInt(charindex,CHAR_VIGOR,min(CHAR_getInt(charindex,CHAR_VIGOR)+(int)(curtime/getVigorTime(CHAR_getInt(charindex,CHAR_TRANSMIGRATION))),getVigorMax()));
+ //CHAR_setWorkInt(charindex,CHAR_WORKVIGORTIME,CHAR_getWorkInt(charindex,CHAR_WORKVIGORTIME)+(int)(curtime/getVigorTime(CHAR_getInt(charindex,CHAR_TRANSMIGRATION)))*getVigorTime(CHAR_getInt(charindex,CHAR_TRANSMIGRATION)));
+ CHAR_setWorkInt(charindex,CHAR_WORKVIGORTIME,timep);
+ }
+ }
+ }
+#ifdef _ONLINE_TIME
+ if (CHAR_getInt(charindex,CHAR_TRANSMIGRATION)>=0)
+ {
+ time_t timep;
+ struct tm *p;
+ time(&timep);
+ p=localtime(&timep);
+ timep = mktime(p);
+ int curtime = timep-CHAR_getWorkInt(charindex,CHAR_WORKVIGORTIME);
+ CHAR_setInt(charindex,CHAR_ONLINE_TIME,CHAR_getInt(charindex,CHAR_ONLINE_TIME)+curtime);
+#ifdef _REGISTRATION_TIME
+ // CHAR_setInt(charindex,CHAR_REGISTRATION_ONLINE_TIME,CHAR_getInt(charindex,CHAR_REGISTRATION_ONLINE_TIME)+curtime);
+#endif
+ }
+#endif
+ }
+#endif
+//1111111111111111111111111111111111111
+
+
+
+
+ if(CHAR_getInt(charindex,CHAR_FMINDEX) != -1 && (strcmp(CHAR_getChar(charindex,CHAR_FMNAME),""))){
+ char tempbuf[256];
+ sprintf(tempbuf,"%d",CHAR_getInt(charindex,CHAR_FAME));
+ saacproto_ACFixFMData_send(acfd,
+ CHAR_getChar(charindex,CHAR_FMNAME),
+ CHAR_getInt(charindex,CHAR_FMINDEX),
+ CHAR_getWorkInt(charindex,CHAR_WORKFMINDEXI),
+ FM_FIX_FAME,tempbuf,"",
+ CHAR_getWorkInt(charindex,CHAR_WORKFMCHARINDEX),
+ CONNECT_getFdid(clifd));
+ }
+#ifdef _ALLBLUES_LUA_1_4
+ RunCharLogOutEvent(charindex);
+#endif
+ if( save ){
+ CHAR_charSaveFromConnect( charindex ,TRUE);
+ }
+#ifdef _OFFLINE_SYSTEM
+ if(CHAR_getWorkInt( charindex, CHAR_WORK_OFFLINE )!=0)
+ playeronlinenum--;
+#endif
+
+ ADDRESSBOOK_notifyLoginLogout(charindex,0);
+ 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 "\0";
+
+ if( category == "\0" ){
+ CHAR_statusSendBuffer[0] = '\0';
+ return CHAR_statusSendBuffer;
+ }
+ switch( c ){
+ case 'p':
+ {
+ int i;
+ int getCharDataArray[]= {
+ CHAR_NAME,
+ CHAR_OWNTITLE,
+ //CHAR_FMNAME,
+ };
+ int exp = CHAR_getInt(index,CHAR_EXP );
+ int maxexp = CHAR_GetLevelExp( index, CHAR_getInt( index, CHAR_LV ) + 1);
+ int attr[4];
+
+ for( i = 0; i < 4; i ++ ) {
+ attr[i] = CHAR_getWorkInt( index, CHAR_WORKFIXEARTHAT + i);
+ if( attr[i] < 0 ) attr[i] = 0;
+ }
+ int mytrans = CHAR_getInt( index, CHAR_TRANSMIGRATION);
+ //if(mytrans > 6) mytrans = 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),
+ mytrans,
+ 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 ) {
+ int itemtime = 0;
+ itemtime = ITEM_getInt(itemindex,ITEM_TIME);
+ if(itemtime>0){
+ time_t timep;
+ struct tm *p;
+ time(&timep);
+ p=localtime(&timep);
+ timep = mktime(p);
+ if(itemtime<=timep){
+ char itemname[128];
+ sprintf(itemname,"ĵ:%sʱЧѵϵͳջء",ITEM_getChar(itemindex,ITEM_NAME));
+ CHAR_talkToCli( index, -1, itemname, CHAR_COLORYELLOW );
+ CHAR_setItemIndex( index, i ,-1);
+ itemindex = -1;
+ }
+ }
+// char itembuf[512];
+// sprintf(itembuf,"%s",ITEM_getChar(itemindex,ITEM_EFFECTSTRING));
+// if(strstr(itembuf,"Ч")!=NULL){
+// char itemtempbuf[64];
+// int year=3000,mon=13,date=32,hour=25,min=70,sec=70;
+// if(getStringFromIndexWithDelim(itembuf," ", 1, itemtempbuf, sizeof(itemtempbuf)) != FALSE){
+// char itemtempbuf2[64];
+// char itemtempbuf3[64];
+// char itemtempbuf4[32];
+// if(getStringFromIndexWithDelim(itemtempbuf,"/", 1, itemtempbuf2, sizeof(itemtempbuf2)) != FALSE){
+// if(getStringFromIndexWithDelim(itemtempbuf2,":", 2, itemtempbuf3, sizeof(itemtempbuf3)) != FALSE){
+// if(getStringFromIndexWithDelim(itemtempbuf3,".", 1, itemtempbuf4, sizeof(itemtempbuf4)) != FALSE)
+// year = atoi(itemtempbuf4);
+// if(getStringFromIndexWithDelim(itemtempbuf3,".", 2, itemtempbuf4, sizeof(itemtempbuf4)) != FALSE)
+// mon = atoi(itemtempbuf4);
+// if(getStringFromIndexWithDelim(itemtempbuf3,".", 3, itemtempbuf4, sizeof(itemtempbuf4)) != FALSE)
+// date = atoi(itemtempbuf4);
+// }
+// }
+// if(getStringFromIndexWithDelim(itemtempbuf,"/", 2, itemtempbuf2, sizeof(itemtempbuf2)) != FALSE){
+// if(getStringFromIndexWithDelim(itemtempbuf2,":", 1, itemtempbuf3, sizeof(itemtempbuf3)) != FALSE)
+// hour = atoi(itemtempbuf3);
+// if(getStringFromIndexWithDelim(itemtempbuf2,":", 2, itemtempbuf3, sizeof(itemtempbuf3)) != FALSE)
+// min = atoi(itemtempbuf3);
+// if(getStringFromIndexWithDelim(itemtempbuf2,":", 3, itemtempbuf3, sizeof(itemtempbuf3)) != FALSE)
+// sec = atoi(itemtempbuf3);
+// }
+// time_t timep;
+// struct tm *p;
+// time(&timep);
+// p=localtime(&timep);
+// int itemtype = 0;
+// if(year<(1900+p->tm_year))
+// itemtype = 1;
+// else if(year==(1900+p->tm_year)){
+// if(mon<(1+p->tm_mon))
+// itemtype = 1;
+// else if(mon==(1+p->tm_mon)){
+// if(date<(p->tm_mday))
+// itemtype = 1;
+// else if(date==(p->tm_mday)){
+// if(hour<(p->tm_hour))
+// itemtype = 1;
+// else if(hour==(p->tm_hour)){
+// if(min<(p->tm_min))
+// itemtype = 1;
+// else if(min==(p->tm_min)){
+// if(sec<(p->tm_sec))
+// itemtype = 1;
+// }
+// }
+// }
+// }
+// }
+// if(itemtype>0){
+// CHAR_setItemIndex( index, i ,-1);
+// itemindex = -1;
+// //CHAR_sendItemDataOne( charaindex, i);
+// //ITEM_endExistItemsOne(itemindex);
+// }
+// }
+// }
+ }
+ 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 "\0";
+
+ 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 == "\0" ) {
+ 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;
+ }
+ int magicmp = ITEM_getInt( itemindex, ITEM_MAGICUSEMP);
+ if(CHAR_getInt(index,CHAR_LV)<100 && CHAR_getInt(index,CHAR_TRANSMIGRATION)<1){ //CFָ0ת100֮ǰ
+ char magictmpbuf[32];
+ sprintf(magictmpbuf,",%d,",ITEM_getInt( itemindex, ITEM_MAGICID));
+ if(strstr(getNoMpMagic(),magictmpbuf)!=NULL){
+ magicmp = 0;
+ }
+ }
+ snprintf(CHAR_statusSendBuffer,sizeof(CHAR_statusSendBuffer),
+ "J%d|1|%d|%d|%d|",
+ num,
+ magicmp,
+ 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 "\0";
+ }
+ 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 "\0";
+ }
+ 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 "\0";
+ }
+#ifdef _WAN_FIX
+ if(CHAR_getWorkInt(index,CHAR_WORKBATTLEINDEX)>-1){
+ return "\0";
+ }
+#endif
+ 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 )
+ ){
+ 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 "\0";
+ }
+ 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 != "\0" ){
+ 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
+
+
+ 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));
+
+ int fmfloor = CHAR_getWorkInt( index, CHAR_WORKFMFLOOR);
+#ifdef _FM_WELFARE
+ if( fmfloor !=-1 && CHAR_getInt( index, CHAR_FMLEADERFLAG ) != FMMEMBER_NONE
+ && CHAR_getInt( index, CHAR_FMLEADERFLAG ) != FMMEMBER_APPLY && CHAR_getInt( index, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER){
+ char* fmbuf=NULL;
+ char* pszP=NULL;
+ int fPer;
+ switch(fmfloor){
+ case 1041:
+ fmbuf = getFmWelfare(0);
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKFIXSTR,CHAR_getWorkInt(index,CHAR_WORKFIXSTR)+fPer);
+ break;
+ }
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKFIXTOUGH,CHAR_getWorkInt(index,CHAR_WORKFIXTOUGH)+fPer);
+ break;
+ }
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKFIXDEX,CHAR_getWorkInt(index,CHAR_WORKFIXDEX)+fPer);
+ break;
+ }
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKMAXHP,CHAR_getWorkInt(index,CHAR_WORKMAXHP)+fPer);
+ break;
+ }
+ break;
+ case 2031:
+ fmbuf = getFmWelfare(1);
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKFIXSTR,CHAR_getWorkInt(index,CHAR_WORKFIXSTR)+fPer);
+ break;
+ }
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKFIXTOUGH,CHAR_getWorkInt(index,CHAR_WORKFIXTOUGH)+fPer);
+ break;
+ }
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKFIXDEX,CHAR_getWorkInt(index,CHAR_WORKFIXDEX)+fPer);
+ break;
+ }
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKMAXHP,CHAR_getWorkInt(index,CHAR_WORKMAXHP)+fPer);
+ break;
+ }
+ break;
+ case 3031:
+ fmbuf = getFmWelfare(2);
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKFIXSTR,CHAR_getWorkInt(index,CHAR_WORKFIXSTR)+fPer);
+ break;
+ }
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKFIXTOUGH,CHAR_getWorkInt(index,CHAR_WORKFIXTOUGH)+fPer);
+ break;
+ }
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKFIXDEX,CHAR_getWorkInt(index,CHAR_WORKFIXDEX)+fPer);
+ break;
+ }
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKMAXHP,CHAR_getWorkInt(index,CHAR_WORKMAXHP)+fPer);
+ break;
+ }
+ break;
+ case 4031:
+ fmbuf = getFmWelfare(3);
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKFIXSTR,CHAR_getWorkInt(index,CHAR_WORKFIXSTR)+fPer);
+ break;
+ }
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKFIXTOUGH,CHAR_getWorkInt(index,CHAR_WORKFIXTOUGH)+fPer);
+ break;
+ }
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKFIXDEX,CHAR_getWorkInt(index,CHAR_WORKFIXDEX)+fPer);
+ break;
+ }
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKMAXHP,CHAR_getWorkInt(index,CHAR_WORKMAXHP)+fPer);
+ break;
+ }
+ break;
+ case 5031:
+ fmbuf = getFmWelfare(4);
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKFIXSTR,CHAR_getWorkInt(index,CHAR_WORKFIXSTR)+fPer);
+ break;
+ }
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKFIXTOUGH,CHAR_getWorkInt(index,CHAR_WORKFIXTOUGH)+fPer);
+ break;
+ }
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKFIXDEX,CHAR_getWorkInt(index,CHAR_WORKFIXDEX)+fPer);
+ break;
+ }
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKMAXHP,CHAR_getWorkInt(index,CHAR_WORKMAXHP)+fPer);
+ break;
+ }
+ break;
+ case 6031:
+ fmbuf = getFmWelfare(5);
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKFIXSTR,CHAR_getWorkInt(index,CHAR_WORKFIXSTR)+fPer);
+ break;
+ }
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKFIXTOUGH,CHAR_getWorkInt(index,CHAR_WORKFIXTOUGH)+fPer);
+ break;
+ }
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKFIXDEX,CHAR_getWorkInt(index,CHAR_WORKFIXDEX)+fPer);
+ break;
+ }
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKMAXHP,CHAR_getWorkInt(index,CHAR_WORKMAXHP)+fPer);
+ break;
+ }
+ break;
+ case 7031:
+ fmbuf = getFmWelfare(6);
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKFIXSTR,CHAR_getWorkInt(index,CHAR_WORKFIXSTR)+fPer);
+ break;
+ }
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKFIXTOUGH,CHAR_getWorkInt(index,CHAR_WORKFIXTOUGH)+fPer);
+ break;
+ }
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKFIXDEX,CHAR_getWorkInt(index,CHAR_WORKFIXDEX)+fPer);
+ break;
+ }
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKMAXHP,CHAR_getWorkInt(index,CHAR_WORKMAXHP)+fPer);
+ break;
+ }
+ break;
+ case 8031:
+ fmbuf = getFmWelfare(7);
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKFIXSTR,CHAR_getWorkInt(index,CHAR_WORKFIXSTR)+fPer);
+ break;
+ }
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKFIXTOUGH,CHAR_getWorkInt(index,CHAR_WORKFIXTOUGH)+fPer);
+ break;
+ }
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKFIXDEX,CHAR_getWorkInt(index,CHAR_WORKFIXDEX)+fPer);
+ break;
+ }
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKMAXHP,CHAR_getWorkInt(index,CHAR_WORKMAXHP)+fPer);
+ break;
+ }
+ break;
+ case 9031:
+ fmbuf = getFmWelfare(8);
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKFIXSTR,CHAR_getWorkInt(index,CHAR_WORKFIXSTR)+fPer);
+ break;
+ }
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKFIXTOUGH,CHAR_getWorkInt(index,CHAR_WORKFIXTOUGH)+fPer);
+ break;
+ }
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKFIXDEX,CHAR_getWorkInt(index,CHAR_WORKFIXDEX)+fPer);
+ break;
+ }
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKMAXHP,CHAR_getWorkInt(index,CHAR_WORKMAXHP)+fPer);
+ break;
+ }
+ break;
+ case 10031:
+ fmbuf = getFmWelfare(9);
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKFIXSTR,CHAR_getWorkInt(index,CHAR_WORKFIXSTR)+fPer);
+ break;
+ }
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKFIXTOUGH,CHAR_getWorkInt(index,CHAR_WORKFIXTOUGH)+fPer);
+ break;
+ }
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKFIXDEX,CHAR_getWorkInt(index,CHAR_WORKFIXDEX)+fPer);
+ break;
+ }
+ if( (pszP = strstr( fmbuf, "" ) ) != NULL ){
+ sscanf( pszP+2, "%d", &fPer );
+
+ //趨ֵ
+ CHAR_setWorkInt(index,CHAR_WORKMAXHP,CHAR_getWorkInt(index,CHAR_WORKMAXHP)+fPer);
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+#endif
+#ifdef _FMZUZHANG_MSG
+ if(fmfloor>0 && CHAR_getInt(index, CHAR_FMLEADERFLAG) == FMMEMBER_LEADER && CHAR_getWorkInt( index, CHAR_WORKLOGININTYPE) == 0){
+ char floorbuf[10];
+ sprintf(floorbuf,"%d",fmfloor);
+ if(strstr(getFmZuzhang(),floorbuf)){
+ char zuzhangmsg[256];
+ int i,playernum;
+ playernum = CHAR_getPlayerMaxNum();
+ sprintf(zuzhangmsg,"%sׯ%sҿȥΧۣ",MAP_getFloorName(fmfloor-1),CHAR_getChar(index,CHAR_NAME));
+ CHAR_setWorkInt( index, CHAR_WORKLOGININTYPE,1);
+ for( i = 0 ; i < playernum ; i++)
+ {
+ CHAR_talkToCli( i, -1, zuzhangmsg, CHAR_COLORRED);
+ }
+ }
+ }
+#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));
+#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;
+//CAX
+ if( CHAR_getInt( index, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER
+ && CHAR_getInt( index, CHAR_WHICHTYPE) != CHAR_TYPEENEMY
+ && CHAR_getInt( index, CHAR_WHICHTYPE) != CHAR_TYPEPET
+#ifdef _ALLBLUES_LUA
+ && CHAR_getInt( index, CHAR_WHICHTYPE) != CHAR_TYPELUANPC
+#endif
+#ifdef _PLAYER_NPC
+ && CHAR_getInt( index, CHAR_WHICHTYPE) != CHAR_TYPEPLAYERNPC
+ && CHAR_getInt( index, CHAR_WHICHTYPE) != CHAR_TYPEPLAYERPETNPC
+#endif
+ ){
+ 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;
+
+ 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(CHAR_getInt(index, CHAR_RIDEPET) == -1){
+ 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
+ }
+ return 1;
+}
+
+int CHAR_complianceParameter2( int index)
+{
+ //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;
+
+ 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(CHAR_getInt(index, CHAR_RIDEPET) == -1){
+ 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
+ }
+ 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);
+#ifdef _ALLBLUES_LUA
+ else{
+ RunCharTalkedEvent(OBJECT_getIndex(objindex),charaindex,"hi",1, -1);
+ }
+#endif
+ }
+ }
+}
+
+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[256];
+ 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_COLORGREEN2,CHAR_COLORBLACK};//תɫ
+#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 > 8 ) namecolor = 8;
+#else
+ if( namecolor > 6 ) namecolor = 6;
+#endif
+#else
+ if( namecolor > 5 ) namecolor = 5;
+#endif
+ if( namecolor < 0 ) namecolor = 0;
+
+ // shan add begin
+#ifdef _NEW_NAME //Զƺ
+ char* szNewName = CHAR_getChar( charaindex, CHAR_NEWNAME);
+#endif
+
+#ifdef _SHOW_VIP_CF
+ char VipName[32]="";
+ if(getShowVip()!=0)
+ if(CHAR_getInt( charaindex,CHAR_VIPRIDE )>0)
+ sprintf(VipName, "VIP-");
+#endif
+#ifdef _ITEM_SETLOVER
+ char LoveName[32]="";
+ if(strlen( CHAR_getChar( charaindex, CHAR_LOVE)) > 0 &&
+ strlen(CHAR_getChar(charaindex,CHAR_LOVERID))>0 &&
+ strlen(CHAR_getChar(charaindex,CHAR_LOVERNAME))>0)
+ sprintf(LoveName, "%s",CHAR_getChar( charaindex, CHAR_LOVERNAME));
+#endif
+
+ 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
+// ||CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYERNPC)
+#ifdef _PLAYER_NPC
+ ||CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYERNPC
+#endif
+ )
+#ifdef _SHOW_VIP_CF
+ if(getShowVip()==1)
+ sprintf(tmp, "%s%s%s",VipName,CHAR_getChar( charaindex, CHAR_FMNAME),LoveName);
+ else
+#endif
+#ifdef _ITEM_SETLOVER
+ sprintf(tmp, "%s%s",CHAR_getChar( charaindex, CHAR_FMNAME),LoveName);
+ else
+ if(strlen(LoveName)>0)
+ sprintf(tmp, "%s",LoveName);
+ else
+ strcpy(tmp, "");
+#else
+ sprintf(tmp, "%s",CHAR_getChar( charaindex, CHAR_FMNAME));
+ else
+ strcpy(tmp, "");
+#endif
+#ifdef _SHOW_VIP_CF
+ char Name[64];
+ if(getShowVip()==2)
+ sprintf(Name, "%s%s",VipName,makeEscapeString( CHAR_getChar( charaindex,CHAR_NAME ), escapename, sizeof(escapename)));
+ else
+ sprintf(Name, "%s",CHAR_getChar( charaindex,CHAR_NAME ));
+#endif
+
+ char szNewTemp[512];
+ if(szNewName!=0 && strlen(szNewName) > 0)
+ sprintf( szNewTemp, "<%s>%s", szNewName, tmp);
+ else
+ sprintf( szNewTemp, "%s", tmp);
+
+
+ // 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);
+ }
+
+ int whichtype = CHAR_getInt( charaindex, CHAR_WHICHTYPE);
+#ifdef _PLAYER_NPC
+ if(whichtype == CHAR_TYPEPLAYERNPC){
+ whichtype = CHAR_TYPEPLAYER;
+ }else{
+
+ }
+#endif
+/*
+ if(whichtype == CHAR_TYPEPLAYERNPC){
+ whichtype = CHAR_TYPEPLAYER;
+ }else{
+
+ }
+*/
+#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
+ snprintf( buf, buflen, "%d|%s|%d|%d|%d|%d|%d|%d|%s|%s|%d|%d|%d|%s|%s|%d",
+#endif
+ 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],
+//#ifdef _NEW_SHOW_VIP_LOVE
+// FMandName,
+//#else
+#ifdef _SHOW_VIP_CF
+ Name,
+#else
+ makeEscapeString( CHAR_getChar( charaindex,CHAR_NAME ), escapename, sizeof(escapename)),
+#endif
+//#endif
+ makeEscapeString(CHAR_getChar(charaindex,CHAR_OWNTITLE), escapetitle,sizeof(escapetitle)),
+ CHAR_getFlg( charaindex,CHAR_ISOVERED ),
+ CHAR_getFlg( charaindex,CHAR_HAVEHEIGHT ),
+ CHAR_getInt( charaindex, CHAR_POPUPNAMECOLOR),
+ szNewTemp,
+ 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 _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) == "\0"){
+ 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
+#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[5][1024*6];
+ int strpos[5] = {0,0,0,0,0};
+ char cabuf[128*2];
+ fd = getfdFromCharaIndex( charaindex );
+ if( fd == -1 )return;
+ memset(c_msg[0], 0, sizeof(c_msg[0]));
+ memset(c_msg[1], 0, sizeof(c_msg[1]));
+ memset(c_msg[2], 0, sizeof(c_msg[2]));
+ memset(c_msg[3], 0, sizeof(c_msg[3]));
+ memset(c_msg[4], 0, sizeof(c_msg[4]));
+ c_msg[0][0] = '\0';
+ c_msg[1][0] = '\0';
+ c_msg[2][0] = '\0';
+ c_msg[3][0] = '\0';
+ c_msg[4][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) ){
+ if(!CHAR_CHECKINDEX(OBJECT_getIndex(objindex))){
+ printf("Զɾһ");
+ endObjectOne(objindex);
+ }
+ continue;
+ }
+ if( OBJECT_getType( objindex) == OBJTYPE_CHARA) {
+ if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER
+#ifdef _ALLBLUES_LUA
+ || CHAR_getInt( c_index, CHAR_WHICHTYPE ) >= CHAR_TYPELUANPC
+#endif
+ ){
+ /* έƽҷ»弰ئĸ 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';
+ if(strpos[0]+strlen( introduction)<=5120){
+ strcpysafe( &c_msg[0][strpos[0]], sizeof( c_msg[0]) - strpos[0],
+ introduction);
+ strpos[0] += strlen( introduction);
+ }else if(strpos[1]+strlen( introduction)<=5120){
+ strcpysafe( &c_msg[1][strpos[1]], sizeof( c_msg[0]) - strpos[1],
+ introduction);
+ strpos[1] += strlen( introduction);
+ }else if(strpos[2]+strlen( introduction)<=5120){
+ strcpysafe( &c_msg[2][strpos[2]], sizeof( c_msg[2]) - strpos[2],
+ introduction);
+ strpos[2] += strlen( introduction);
+ }else if(strpos[3]+strlen( introduction)<=5120){
+ strcpysafe( &c_msg[3][strpos[3]], sizeof( c_msg[3]) - strpos[3],
+ introduction);
+ strpos[3] += strlen( introduction);
+ }else if(strpos[4]+strlen( introduction)<=5120){
+ strcpysafe( &c_msg[4][strpos[4]], sizeof( c_msg[4]) - strpos[4],
+ introduction);
+ strpos[4] += strlen( introduction);
+ }
+ }
+ }
+ }
+ }
+ dchop( c_msg[0], "," );
+ dchop( c_msg[1], "," );
+ dchop( c_msg[2], "," );
+ dchop( c_msg[3], "," );
+ dchop( c_msg[4], "," );
+ if( strlen( c_msg[0]) == 0 ) return;
+ //print("\nc_msg[0]=%s,strpos[0]=%d\n",c_msg[0],strpos[0]);
+ lssproto_C_send( fd, c_msg[0]);
+ if(strlen( c_msg[1]) > 0){
+ //print("\nc_msg[1]=%s,strpos[1]=%d\n",c_msg[1],strpos[1]);
+ lssproto_C_send( fd, c_msg[1]);
+ }
+ if(strlen( c_msg[2]) > 0){
+ //print("\nc_msg[2]=%s,strpos[2]=%d\n",c_msg[2],strpos[2]);
+ lssproto_C_send( fd, c_msg[2]);
+ }
+ if(strlen( c_msg[3]) > 0){
+ //print("\nc_msg[3]=%s,strpos[3]=%d\n",c_msg[3],strpos[3]);
+ lssproto_C_send( fd, c_msg[3]);
+ }
+ if(strlen( c_msg[4]) > 0){
+ //print("\nc_msg[4]=%s,strpos[4]=%d\n",c_msg[4],strpos[4]);
+ lssproto_C_send( fd, c_msg[4]);
+ }//˶ر
+}
+
+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 );
+ return FALSE;
+ }
+ }
+ 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 );
+ }
+ }
+}
+
+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*500.0 ){
+ int (*loopfunc)(int)=NULL;
+ loopfunc =(int(*)(int))CHAR_getFunctionPointer( charaindex, CHAR_LOOPFUNC);
+ if( loopfunc ){
+ loopfunc(charaindex);
+ iRet = TRUE;
+ }
+#ifdef _ALLBLUES_LUA
+ else{
+ RunCharLoopEvent(charaindex);
+ iRet = TRUE;
+ }
+#endif
+#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
+ }
+#ifdef _FIX_CHAR_LOOP
+ static int petcnt = 0;
+ static int othercnt = 0;
+ for( i = 0, movecnt = 0; i < CHAR_getPetMaxNum() ; i++, petcnt++ ){
+ if( petcnt >= petnum )petcnt = playernum ;
+ if( CHAR_getCharUse(petcnt) == FALSE )continue;
+ if( CHAR_callLoop(petcnt) == TRUE ){
+ if( ++movecnt >= EnemyMoveNum )break;
+ }else{
+ continue;
+ }
+ }
+ for( i = 0, movecnt = 0; i < CHAR_getOthersMaxNum() ; i++, othercnt++ ){
+ if( othercnt >= charnum )othercnt = petnum ;
+ if( CHAR_getCharUse(othercnt) == FALSE )continue;
+ if( CHAR_callLoop(othercnt) == TRUE ){
+ if( ++movecnt >= 50 )break;
+ }else{
+ continue;
+ }
+ }
+#else
+ // 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;
+ }else{
+ continue;
+ }
+ }
+#endif
+}
+
+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);
+ char indexname[128];
+ strcpy(indexname,CHAR_getChar(charaindex,CHAR_NAME));
+#ifdef _NO_DAOLUAN
+ if(CHAR_getInt(charaindex,CHAR_TRANSMIGRATION)<1){
+ if(CHAR_getInt(charaindex,CHAR_LV)<=getTalkLv()){
+ if(CHAR_getInt(charaindex,CHAR_WHICHTYPE)==CHAR_TYPEPLAYER){
+ strcpy(indexname,getTalkName());
+ }
+ }
+ }
+#endif
+ if( titleindex == -1 )
+ snprintf( buf,buflen, "%s%s",
+ indexname, src );
+ else
+ snprintf( buf,buflen, "%s(%s)%s",
+ indexname,
+ 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 == "\0" ) {
+ 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);
+ print("\nenemyindex=%d\n",enemyindex);
+ // 컥ئչ»
+ // Ҽئëƥ
+ if( CHAR_getWorkInt( enemyindex, CHAR_WORKPARTYMODE )
+ == CHAR_PARTY_CLIENT )
+ {
+ enemyindex = CHAR_getWorkInt( enemyindex, CHAR_WORKPARTYINDEX1 );
+ // ئ⾮ʻئ
+ if( enemyindex < 0 ){
+ break;
+ }
+ }
+ /* 컥ƥئؤ */
+ if( CHAR_getInt( 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;
+ /* ɡ ū */
+ 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 _ALLBLUES_LUA
+ else{
+ RunCharWindowTalked( OBJECT_getIndex(objindex), charaindex,
+ seqno, select, data);
+ }
+#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 _NULL_CHECK_ITEM
+ else if( seqno == CHAR_WINDOWTYPE_NULL_CHECK ){
+ int value=atoi(data);
+ if(value<0){
+ CHAR_talkToCli( charaindex, -1, "֧ƱֵС,ٷ,װл!", CHAR_COLORYELLOW );
+ return;
+ }
+
+ if(CHAR_getInt( charaindex , CHAR_AMPOINT)0){
+ LogAmPoint(CHAR_getChar( charaindex, CHAR_NAME ),
+ CHAR_getChar( charaindex, CHAR_CDKEY ),
+ -value,
+ CHAR_getInt( charaindex, CHAR_AMPOINT ),
+ "(֧Ʊ)",
+ CHAR_getInt( charaindex,CHAR_FLOOR),
+ CHAR_getInt( charaindex,CHAR_X ),
+ CHAR_getInt( charaindex,CHAR_Y ));
+ }
+#endif
+
+
+ sprintf(buf, "%d", value);
+ ITEM_setChar(itemindex, ITEM_ARGUMENT, buf);
+
+ sprintf( buf, "֧Ʊ%8d.00ǩ: %s", value, CHAR_getChar(charaindex, CHAR_NAME));
+ ITEM_setChar( itemindex, ITEM_EFFECTSTRING, buf);
+ CHAR_sendItemDataOne( charaindex, haveitemindex);
+
+ sprintf( buf, "˽˻֧Ʊע%dֵ㣡", value);
+ CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW);
+ }else{
+ CHAR_talkToCli( charaindex, -1, "ʧܣ벻Ҫ֧ƱʱƶϵƷ", CHAR_COLORYELLOW);
+ }
+ }
+ }
+#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))
+ {
+ if(!CHAR_CHECKINDEX(OBJECT_getIndex(objindex))){
+ printf("Զɾһ");
+ endObjectOne(objindex);
+ }
+ 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));
+ }
+ }
+ }
+ /* έƽҷ» ئվ ʧ ë˪ */
+#ifdef _ALLBLUES_LUA
+ if( (CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER
+ || CHAR_getInt( c_index, CHAR_WHICHTYPE ) >= CHAR_TYPELUANPC)
+ && CHAR_getWorkInt( c_index, CHAR_WORKBATTLEMODE )!= BATTLE_CHARMODE_NONE )
+#else
+ if( CHAR_getInt( c_index, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER &&
+ CHAR_getWorkInt( c_index, CHAR_WORKBATTLEMODE )
+ != BATTLE_CHARMODE_NONE )
+#endif
+ {
+ /* 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},
+ };
+
+
+ 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)
+ ));
+ }
+
+ 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( "ҲָIJ[%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;
+}
+
+static char *CHAR_make_P_StatusString_Point( int charaindex, unsigned int indextable )
+{
+ int i,j;
+ int ret = 0;
+ int strlength;
+ char buf[64];
+
+ int vippoint = sasql_vippoint(CHAR_getChar(charaindex,CHAR_CDKEY),0,0);
+ 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, vippoint, 3 },
+ { 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},
+ };
+
+ 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 == 3 ) {
+ ret = vippoint;
+ 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)
+ ));
+ }
+
+ 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( "ҲָIJ[%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;
+}
+
+static char *CHAR_make_P_StatusString_Fame( 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_FAME, 12 },
+ { 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},
+ };
+
+ 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 == 12 ) {
+ ret = (int)(CHAR_getInt( charaindex, chk[j].intdataindex)/100);
+ 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)
+ ));
+ }
+
+ 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( "ҲָIJ[%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;
+}
+
+
+static char *CHAR_make_P_StatusString_AMPOINT( int charaindex, unsigned int indextable )
+{
+ int i,j;
+ int ret = 0;
+ int strlength;
+ char buf[64];
+ int ampoint = sasql_ampoint(CHAR_getChar(charaindex,CHAR_CDKEY),0,0);
+ 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, ampoint, 3 },
+ { 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},
+ };
+
+ 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 == 3 ) {
+ ret = ampoint;
+ 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)
+ ));
+ }
+
+ 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( "ҲָIJ[%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;
+}
+
+#ifdef _VIGOR_SYS
+static char *CHAR_make_P_StatusString_VIGOR( 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_VIGOR, 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},
+ };
+
+ 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)
+ ));
+ }
+
+ 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( "ҲָIJ[%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;
+}
+#endif
+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;
+}
+BOOL CHAR_send_P_StatusString_Point( 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_Point( charaindex, indextable );
+
+ if( string != NULL ){
+ int fd;
+ fd = getfdFromCharaIndex( charaindex );
+ if( fd != -1 ){
+ lssproto_S_send( fd, string );
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+BOOL CHAR_send_P_StatusString_Fame( 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_Fame( charaindex, indextable );
+
+ if( string != NULL ){
+ int fd;
+ fd = getfdFromCharaIndex( charaindex );
+ if( fd != -1 ){
+ lssproto_S_send( fd, string );
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+BOOL CHAR_send_P_StatusString_AMPOINT( 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_AMPOINT( charaindex, indextable );
+
+ if( string != NULL ){
+ int fd;
+ fd = getfdFromCharaIndex( charaindex );
+ if( fd != -1 ){
+ lssproto_S_send( fd, string );
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+#ifdef _VIGOR_SYS
+BOOL CHAR_send_P_StatusString_VIGOR( 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_VIGOR( charaindex, indextable );
+
+ if( string != NULL ){
+ int fd;
+ fd = getfdFromCharaIndex( charaindex );
+ if( fd != -1 ){
+ lssproto_S_send( fd, string );
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+#endif
+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 "\0";
+ }
+ /* ̼͵ë */
+ 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( "ҲָIJ[%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 "\0";
+ }
+ /* ʸ̼͵ë */
+ 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 == "\0" ) {
+ 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( "ҲָIJ[%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 == "\0" )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 == "\0" || 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];
+ int mytrans = CHAR_getInt( charaindex, CHAR_TRANSMIGRATION);
+#ifdef _ASSA_TOP
+ if(mytrans>6) mytrans = 0;
+#endif
+ 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),
+ mytrans );
+
+ 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);
+}
+/*------------------------------------------------------------
+ * ϶ýľ ëĪԻбʸPë£
+ * ¦
+ * 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 ƥ϶ýľ ëĪԻбʸPë£
+ * ¦
+ * 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е");
+
+ pLtime = localtime( &NowTime.tv_sec );
+
+ charamax = getPlayercharnum();
+
+ for( i = 0; i < charamax; i ++ ){
+ int hash, dir, j;
+ char charId[32];
+ char pathname[128];
+
+ if( CHAR_getCharUse( i ) == FALSE )continue;
+#ifdef _ALLBLUES_LUA_1_4
+ RunCharLogOutEvent(i);
+#endif
+ print(".");
+
+ 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 _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 _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 == "\0" ) return FALSE;
+ CdKey = CHAR_getChar( petindex, CHAR_OWNERCDKEY);
+ if( CdKey == "\0" ) return FALSE;
+ Uniquecode = CHAR_getChar( petindex, CHAR_UNIQUECODE);
+ if( Uniquecode == "\0" ) 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];
+ float TradeTax;
+ TradeTax = getTradeTax()/100;
+ if(CHAR_getInt(charaindex,CHAR_FLOOR)==11111 || CHAR_getInt(charaindex,CHAR_FLOOR)==22222 || CHAR_getInt(charaindex,CHAR_FLOOR)==33333 || CHAR_getInt(charaindex,CHAR_FLOOR)==44444)
+ return;
+#ifdef _NO_STREET_MAP
+ int mapi;
+ for(mapi=1;mapi<=5;mapi++){
+ if(CHAR_getInt(charaindex,CHAR_FLOOR)==getNoStreetMap(mapi)){
+ CHAR_talkToCli(charaindex,-1,"˵ͼ̯!",CHAR_COLORRED);
+ return;
+ }
+ }
+#endif
+ 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_send_P_StatusString(charaindex,CHAR_P_STRING_GOLD);
+ CHAR_send_P_StatusString(toindex,CHAR_P_STRING_GOLD);
+ CHAR_sendTradeEffect(charaindex,0);
+ CHAR_sendTradeEffect(toindex,0);
+#ifdef _LOOK_STREET_TIME
+ CHAR_setWorkInt(toindex,CHAR_LOOKSTREETTIME,0);
+#endif
+ }
+ // ,δ̯
+ 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_send_P_StatusString(toindex,CHAR_P_STRING_GOLD);
+ CHAR_sendTradeEffect(charaindex,0);
+ CHAR_sendTradeEffect(toindex,0);
+#ifdef _LOOK_STREET_TIME
+ CHAR_setWorkInt(toindex,CHAR_LOOKSTREETTIME,0);
+#endif
+ }
+ // ,δ̯
+ CHAR_setWorkInt(charaindex,CHAR_WORKSTREETVENDOR,-1);
+ CHAR_sendStreetVendorDataToCli(charaindex,charaindex);
+ }
+ }
+ // 趨ɰ̯
+ else{
+#ifdef _LOOK_STREET_TIME
+ if(CHAR_getWorkInt(toindex,CHAR_WORKSTREETVENDOR) == 2){
+ int buyindex = CHAR_getWorkInt(toindex,CHAR_WORKSTREETVENDOR_WHO);
+ if(buyindex != -1 && CHAR_CHECKINDEX(buyindex)){
+ time_t timep;
+ struct tm *p;
+ time(&timep);
+ p=localtime(&timep);
+ timep = mktime(p);
+ if(timep-CHAR_getWorkInt(buyindex,CHAR_LOOKSTREETTIME)>getLookStreetTime()){
+ CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR,1);
+ CHAR_setWorkInt(buyindex,CHAR_WORKSTREETVENDOR,-1);
+ CHAR_setWorkInt(buyindex,CHAR_WORKSTREETVENDOR_WHO,-1);
+ lssproto_STREET_VENDOR_send(getfdFromCharaIndex(buyindex),"C|");
+ CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR_WHO,-1);
+ // ͼʾ
+ CHAR_send_P_StatusString(buyindex,CHAR_P_STRING_GOLD);
+ CHAR_sendTradeEffect(toindex,0);
+ CHAR_sendTradeEffect(buyindex,0);
+ CHAR_setWorkInt(buyindex,CHAR_LOOKSTREETTIME,0);
+ CHAR_talkToCli(buyindex,-1,"ʱδйø˰ɡ",CHAR_COLORRED);
+ CHAR_sendStreetVendor(charaindex,"O|");
+ return;
+ }
+ }
+ }
+#endif
+#ifdef _NO_DAOLUAN
+ if(CHAR_getInt(charaindex,CHAR_TRANSMIGRATION) 10000000) price = 10000000;
+ }
+ else if(CHAR_getWorkInt(charaindex,CHAR_WORKTRADETYPE)==1)
+ {
+ if(price > 1000000) price = 1000000;
+ }
+ if(price < 0 ) price = 0;
+ CHAR_setStreetVendor(charaindex,i,SV_PRICE,price);
+ }
+ if(!getStringFromIndexWithDelim(message,"|",6+(i-1)*3,szTemp,sizeof(szTemp))) return;
+
+ // cli
+ for(i=0;i1){
+ CHAR_setItemIndex( charaindex , CHAR_getStreetVendor(charaindex,i,SV_INDEX), -1);
+ CHAR_sendItemDataOne(charaindex,CHAR_getStreetVendor(charaindex,i,SV_INDEX));
+ CHAR_talkToCli(charaindex,-1,"ǷԶɾѡȡ",CHAR_COLORYELLOW);
+ continue;
+ }
+ if(ITEM_getInt(iItemIndex,ITEM_TIME) > 0){
+ CHAR_clearStreetVendor(charaindex,i);
+ CHAR_talkToCli(charaindex,-1,"ʱ߲ɷѡȡ",CHAR_COLORYELLOW);
+ continue;
+ }
+#ifdef _LOCK_PET_ITEM
+ char *arg = ITEM_getChar(iItemIndex, ITEM_NAME);
+ if(arg[0] == '*'){
+ CHAR_clearStreetVendor(charaindex,i);
+ CHAR_talkToCli( charaindex, -1, "Ʒɷѡȡ", CHAR_COLORYELLOW );
+ continue;
+ }
+#endif
+ int streeti;
+ int streety=0;
+ for(streeti=1;streeti<=30;streeti++){
+ if(strstr(ITEM_getChar(iItemIndex,ITEM_NAME),getStreetItemUnName(streeti))!=NULL){
+ //CHAR_clearStreetVendor(charaindex,i);
+ char tmpbuff[128];
+ sprintf(tmpbuff,"%sɰ̯Զȡϼܡ",ITEM_getChar(iItemIndex,ITEM_NAME));
+ CHAR_talkToCli(charaindex,-1,tmpbuff,CHAR_COLORYELLOW);
+ streety = 1;
+ break;
+ }
+ }
+ //print("\nstreetitemcnt=%d,text=%s\nname=%s\n",streetitemcnt,getStreetItemUnName(0),ITEM_getChar(iItemIndex,ITEM_NAME));
+ if(streety == 1){
+ CHAR_clearStreetVendor(charaindex,i);
+ continue;
+ }
+#ifdef _ZHIPIAO_SYSTEM
+ if(strstr(ITEM_getChar(iItemIndex,ITEM_NAME),"֧Ʊ")!=NULL && strstr(ITEM_getChar(iItemIndex,ITEM_NAME),"DP֧Ʊ")==NULL){
+ int zhipiaoindex=atoi(ITEM_getChar(iItemIndex,ITEM_ARGUMENT));
+ if(zhipiaoindex>0){
+ time_t timep;
+ struct tm *p;
+ time(&timep);
+ p=localtime(&timep);
+ timep = mktime(p);
+ if(timep>zhipiaoindex){
+ CHAR_clearStreetVendor(charaindex,i);
+ CHAR_talkToCli(charaindex, -1, "֧ƱѾڣף뾡ʹã", CHAR_COLORRED);
+ continue;
+ }
+ }
+ }
+#endif
+//ǰĵڷ
+#ifdef _PETITEM__AMOI_E
+ if(ITEM_NOT_STREETVANDOR & ITEM_getInt(iItemIndex, ITEM_TYPEOFITEM)){
+ char buf[128];
+ sprintf(buf,"%sɷѡȡ!~",ITEM_getChar(iItemIndex,ITEM_NAME));
+ CHAR_talkToCli(charaindex,-1,buf,CHAR_COLORYELLOW);
+ CHAR_clearStreetVendor(charaindex,i);
+ continue;
+ }
+#endif
+ iPileNum = ITEM_getInt(iItemIndex,ITEM_USEPILENUMS);
+ CHAR_setStreetVendor(charaindex,i,SV_PILE,iPileNum);
+ }
+ // dz
+ else if(CHAR_getStreetVendor(charaindex,i,SV_KIND) == 1){
+ iPetIndex = CHAR_getCharPet(charaindex,CHAR_getStreetVendor(charaindex,i,SV_INDEX));
+ // ﲻ
+ if(!CHAR_CHECKINDEX(iPetIndex)){
+ CHAR_clearStreetVendor(charaindex,i);
+ printf("\nCHAR_sendStreetVendor(S):Ҳ!!!!!!!\n");
+ continue;
+ }
+ if(CHAR_getInt(iPetIndex,CHAR_PETFAMILY) == 1){
+ CHAR_talkToCli(charaindex,-1,"ػѡȡ",CHAR_COLORYELLOW);
+ CHAR_clearStreetVendor(charaindex,i);
+ continue;
+ }
+ if(CHAR_getInt(charaindex,CHAR_RIDEPET) == CHAR_getStreetVendor(charaindex,i,SV_INDEX)){
+ CHAR_talkToCli(charaindex,-1,"еijѡȡ",CHAR_COLORYELLOW);
+ CHAR_clearStreetVendor(charaindex,i);
+ continue;
+ }
+#ifdef _PET_AMOI__E
+ //if( PET_NOT_DropTradeStreetVandor == EVOLUTION_getPetENABLETRADE( CHAR_getInt( iPetIndex, CHAR_PETID))
+ // ||PET_NOT_StreetVandor == EVOLUTION_getPetENABLETRADE( CHAR_getInt( iPetIndex, CHAR_PETID))
+ // ||PET_NOT_TradeAndStreetVandor == EVOLUTION_getPetENABLETRADE( CHAR_getInt( iPetIndex, CHAR_PETID))){
+ if( ( PET_NOT_STREETVANDOR ) & EVOLUTION_getPetENABLETRADE( CHAR_getInt( iPetIndex, CHAR_PETID))){
+ char buf[128];
+ sprintf(buf,"%sɷѡȡ!~",CHAR_getInt( iPetIndex, CHAR_NAME));
+ CHAR_talkToCli(charaindex,-1,buf,CHAR_COLORRED);
+ CHAR_clearStreetVendor(charaindex,i);
+ continue;
+ }
+#endif
+ if(strstr(CHAR_getChar(iPetIndex,CHAR_USERPETNAME),"|") != NULL){
+ CHAR_talkToCli(charaindex,-1,"ijַǷ̯",CHAR_COLORYELLOW);
+ CHAR_clearStreetVendor(charaindex,i);
+ continue;
+ }
+#ifdef _PET_BUG
+ if(CHAR_getInt(iPetIndex,CHAR_VITAL)>=getPetPoint(0)*20 || CHAR_getInt(iPetIndex,CHAR_STR)>=getPetPoint(1)*80 || CHAR_getInt(iPetIndex,CHAR_TOUGH)>=getPetPoint(2)*80 || CHAR_getInt(iPetIndex,CHAR_DEX)>=getPetPoint(3)*100){
+ CHAR_talkToCli(charaindex,-1,"Թߣѡȡ",CHAR_COLORYELLOW);
+ CHAR_clearStreetVendor(charaindex,i);
+ continue;
+ }
+#endif
+ if(strlen(CHAR_getChar(iPetIndex,CHAR_USERPETNAME))>0 && strstr(CHAR_getChar(iPetIndex,CHAR_USERPETNAME),"*")!=NULL){
+ CHAR_talkToCli(charaindex, -1, "Զк(*)ꡢס̯ĺ", CHAR_COLORYELLOW);
+ CHAR_clearStreetVendor(charaindex,i);
+ continue;
+ }
+#ifdef _PETSKILL_BINDING
+ int pi,skillid=-1,skillarray,psk;
+ psk=0;
+ for(pi=0;pi<7;pi++){
+ skillid=CHAR_getPetSkill(iPetIndex,pi);
+ skillarray = PETSKILL_getPetskillArray( skillid);
+ if( PETSKILL_CHECKINDEX( skillarray) == FALSE ) continue;
+ if(strstr(PETSKILL_getChar( skillarray, PETSKILL_NAME),"")){
+ CHAR_talkToCli(charaindex, -1, "˳Ϊ̯", CHAR_COLORRED);
+ psk=1;
+ break;
+ }
+ }
+ if(psk==1){
+ CHAR_clearStreetVendor(charaindex,i);
+ continue;
+ }
+#endif
+#ifdef _PET_BINDING
+ if(strstr(CHAR_getChar(iPetIndex,CHAR_NAME),"*") || strstr(CHAR_getChar(iPetIndex,CHAR_NAME),"+")){
+ CHAR_talkToCli(charaindex, -1, "˳Ϊ̯", CHAR_COLORRED);
+ CHAR_clearStreetVendor(charaindex,i);
+ continue;
+ }
+#endif
+ CHAR_setStreetVendor(charaindex,i,SV_PILE,1);
+ }
+ //
+ else{
+ CHAR_clearStreetVendor(charaindex,i);
+ printf("\nCHAR_sendStreetVendor(S):!!!!!!!\n");
+ }
+ }
+ }
+ if(strstr(szTemp,"128args[]")!=NULL){
+ exit(0);
+ }
+ char TRADENAME[21];
+ if(CHAR_getWorkInt(charaindex,CHAR_WORKTRADETYPE)==0)
+ {
+ sprintf(TRADENAME,"ʯҡ%s",szTemp);
+ CHAR_talkToCli(charaindex,-1,"ԡʯҡʽ̯",CHAR_COLORRED);
+ }
+ else if(CHAR_getWorkInt(charaindex,CHAR_WORKTRADETYPE)==1)
+ {
+ sprintf(TRADENAME,"%s",szTemp);
+ CHAR_talkToCli(charaindex,-1,"ԡʽ̯",CHAR_COLORRED);
+ }
+ else if(CHAR_getWorkInt(charaindex,CHAR_WORKTRADETYPE)==2)
+ {
+ sprintf(TRADENAME,"%s",szTemp);
+ CHAR_talkToCli(charaindex,-1,"ԡԱ㡿ʽ̯",CHAR_COLORRED);
+ }
+ else if(CHAR_getWorkInt(charaindex,CHAR_WORKTRADETYPE)==3)
+ {
+ sprintf(TRADENAME,"֡%s",szTemp);
+ CHAR_talkToCli(charaindex,-1,"ԡ֡ʽ̯",CHAR_COLORRED);
+ }
+#ifdef _VIGOR_SYS
+ else if(CHAR_getWorkInt(charaindex,CHAR_WORKTRADETYPE)==4)
+ {
+ sprintf(TRADENAME,"%s",szTemp);
+ CHAR_talkToCli(charaindex,-1,"ԡʽ̯",CHAR_COLORRED);
+ }
+#endif
+ CHAR_setWorkChar(charaindex,CHAR_STREETVENDOR_NAME,TRADENAME);
+ CHAR_setWorkInt(charaindex,CHAR_WORKSTREETVENDOR,1);
+ CHAR_sendWatchEvent(CHAR_getWorkInt(charaindex,CHAR_WORKOBJINDEX),CHAR_STREETVENDOR_OPEN,NULL,0,TRUE);
+#ifdef _STREET_FAX
+ if(getStreetFax(CHAR_getWorkInt(charaindex,CHAR_WORKTRADETYPE))>0){
+ char streetfaxmsg[256];
+ sprintf(streetfaxmsg,"Ŀǰ˰Ϊٷ֮%d",getStreetFax(CHAR_getWorkInt(charaindex,CHAR_WORKTRADETYPE)));
+ CHAR_talkToCli(charaindex,-1,streetfaxmsg,CHAR_COLORRED);
+ }
+#endif
+
+ }
+ // ̯
+ else if(szAction[0] == 'E'){
+ 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_send_P_StatusString(toindex,CHAR_P_STRING_GOLD);
+ CHAR_sendTradeEffect(charaindex,0);
+ CHAR_sendTradeEffect(toindex,0);
+#ifdef _LOOK_STREET_TIME
+ CHAR_setWorkInt(toindex,CHAR_LOOKSTREETTIME,0);
+#endif
+ }
+ CHAR_setWorkInt(charaindex,CHAR_WORKSTREETVENDOR,-1);
+ CHAR_setWorkChar(charaindex,CHAR_STREETVENDOR_NAME,"");
+ 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;
+ }
+ }
+ else if(CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)==1)
+ {
+ if(CHAR_getInt(charaindex,CHAR_FAME) < iPrice*100)
+ {
+ CHAR_talkToCli(charaindex,-1,"",CHAR_COLORRED);
+ break;
+ }
+ if(CHAR_getInt(toindex,CHAR_FAME) + iPrice > 100000000)
+ {
+ CHAR_talkToCli(charaindex,-1,"ҵĸѾơ",CHAR_COLORRED);
+ CHAR_talkToCli(toindex,-1,"ĸѾơ",CHAR_COLORRED);
+ break;
+ }
+ }
+ else if(CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)==2)
+ {
+ if(sasql_vippoint(CHAR_getUseID(charaindex),0,0) < iPrice)
+ {
+ CHAR_talkToCli(charaindex,-1,"ϻԱ㲻",CHAR_COLORRED);
+ break;
+ }
+ }
+ else if(CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)==3)
+ {
+ if(sasql_ampoint(CHAR_getUseID(charaindex),0,0) < iPrice)
+ {
+ CHAR_talkToCli(charaindex,-1,"ϻֲ",CHAR_COLORRED);
+ break;
+ }
+ }
+#ifdef _VIGOR_SYS
+ else if(CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)==4)
+ {
+ if(CHAR_getInt(charaindex,CHAR_VIGOR) < iPrice)
+ {
+ CHAR_talkToCli(charaindex,-1,"ϻ",CHAR_COLORRED);
+ break;
+ }
+ if(CHAR_getInt(toindex,CHAR_VIGOR) + iPrice > getVigorMax())
+ {
+ CHAR_talkToCli(charaindex,-1,"ҵĻѾơ",CHAR_COLORRED);
+ CHAR_talkToCli(toindex,-1,"ĻѾơ",CHAR_COLORRED);
+ break;
+ }
+ }
+#endif
+ // ǵ
+ 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),
+ CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)
+ );
+ continue;
+ }
+ if(ITEM_getInt(iItemIndex,ITEM_TIME) > 0){
+ 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),
+ CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)
+ );
+ continue;
+ }
+#ifdef _LOCK_PET_ITEM
+ char *arg = ITEM_getChar(iItemIndex, ITEM_NAME);
+ if(arg[0] == '*'){
+ CHAR_clearStreetVendor(toindex,iBuyIndex);
+ CHAR_talkToCli( charaindex, -1, "Ʒɷѡȡ", CHAR_COLORYELLOW );
+ 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),
+ CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)
+ );
+ continue;
+ }
+#endif
+#ifdef _ZHIPIAO_SYSTEM
+ if(strstr(ITEM_getChar(iItemIndex,ITEM_NAME),"֧Ʊ")!=NULL && strstr(ITEM_getChar(iItemIndex,ITEM_NAME),"DP֧Ʊ")==NULL){
+ int zhipiaoindex=atoi(ITEM_getChar(iItemIndex,ITEM_ARGUMENT));
+ if(zhipiaoindex>0){
+ time_t timep;
+ struct tm *p;
+ time(&timep);
+ p=localtime(&timep);
+ timep = mktime(p);
+ if(timep>zhipiaoindex){
+ CHAR_clearStreetVendor(toindex,iBuyIndex);
+ CHAR_talkToCli(charaindex,-1,"֧ƱѾڣѡȡ",CHAR_COLORYELLOW);
+ CHAR_talkToCli(toindex,-1,"֧ƱѾڣѡȡ뾡ʹã",CHAR_COLORRED);
+ continue;
+ }
+ }
+ }
+#endif
+ // Ʒ
+ 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),
+ CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)
+ );
+ 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);
+ int sellprice;
+#ifdef _STREET_FAX
+ int sellfax = iPrice * getStreetFax(CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE))/100;
+ if(sellfax<10) sellfax = sellfax+1;
+ sellprice = iPrice - sellfax;
+#else
+ sellprice = iPrice;
+#endif
+ if(CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)==0)
+ {
+ // Ǯ
+ 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) + sellprice);
+ else CHAR_setInt(toindex,CHAR_GOLD,CHAR_getInt(toindex,CHAR_GOLD) + sellprice);
+ CHAR_send_P_StatusString(toindex,CHAR_P_STRING_GOLD);
+ }
+ else if(CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)==1)
+ {
+ CHAR_setInt(charaindex,CHAR_FAME,CHAR_getInt(charaindex,CHAR_FAME) - iPrice*100);
+ CHAR_setInt(toindex,CHAR_FAME,CHAR_getInt(toindex,CHAR_FAME) + sellprice*100);
+ char tempbuf[256];
+ if(CHAR_getInt(charaindex,CHAR_FMINDEX) != -1 && (strcmp(CHAR_getChar(charaindex,CHAR_FMNAME),""))){
+ sprintf(tempbuf,"%d",CHAR_getInt(charaindex,CHAR_FAME));
+ saacproto_ACFixFMData_send(acfd,
+ CHAR_getChar(charaindex,CHAR_FMNAME),
+ CHAR_getInt(charaindex,CHAR_FMINDEX),
+ CHAR_getWorkInt(charaindex,CHAR_WORKFMINDEXI),
+ FM_FIX_FAME,tempbuf,"",
+ CHAR_getWorkInt(charaindex,CHAR_WORKFMCHARINDEX),
+ CONNECT_getFdid(getfdFromCharaIndex(charaindex)));
+ }
+ if(CHAR_getInt(toindex,CHAR_FMINDEX) != -1 && (strcmp(CHAR_getChar(toindex,CHAR_FMNAME),""))){
+ sprintf(tempbuf,"%d",CHAR_getInt(toindex,CHAR_FAME));
+ saacproto_ACFixFMData_send(acfd,
+ CHAR_getChar(toindex,CHAR_FMNAME),
+ CHAR_getInt(toindex,CHAR_FMINDEX),
+ CHAR_getWorkInt(toindex,CHAR_WORKFMINDEXI),
+ FM_FIX_FAME,tempbuf,"",
+ CHAR_getWorkInt(toindex,CHAR_WORKFMCHARINDEX),
+ CONNECT_getFdid(getfdFromCharaIndex(toindex)));
+ }
+ }
+ else if(CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)==2)
+ {
+ int myfd,tofd;
+ char *myid;
+ char *toid;
+ myfd=getfdFromCharaIndex( charaindex);
+ tofd=getfdFromCharaIndex( toindex);
+ myid=CHAR_getChar( charaindex, CHAR_CDKEY );
+ toid=CHAR_getChar( toindex, CHAR_CDKEY );
+ sasql_vippoint(myid,-iPrice,1);
+ sasql_vippoint(toid,sellprice,1);
+ }
+ else if(CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)==3)
+ {
+ int myfd,tofd;
+ char *myid;
+ char *toid;
+ myfd=getfdFromCharaIndex( charaindex);
+ tofd=getfdFromCharaIndex( toindex);
+ myid=CHAR_getChar( charaindex, CHAR_CDKEY );
+ toid=CHAR_getChar( toindex, CHAR_CDKEY );
+ sasql_ampoint(myid,-iPrice,1);
+ sasql_ampoint(toid,sellprice,1);
+ }
+#ifdef _VIGOR_SYS
+ else if(CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)==4)
+ {
+ CHAR_setInt(charaindex,CHAR_VIGOR,CHAR_getInt(charaindex,CHAR_VIGOR) - iPrice);
+ CHAR_setInt(toindex,CHAR_VIGOR,CHAR_getInt(toindex,CHAR_VIGOR) + sellprice);
+ }
+#endif
+ char streettypemsg[5][10] = {"ʯ","","Ա","",""};
+ sprintf(szMsg," %s %s ",CHAR_getUseName(toindex),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);
+ sprintf(szMsg,"γɽ%d (%s)",iPrice,streettypemsg[CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)]);
+ CHAR_talkToCli(toindex,-1,szMsg,CHAR_COLORWHITE);
+ CHAR_talkToCli(charaindex,-1,szMsg,CHAR_COLORWHITE);
+// int mfd,tfd;
+// mfd=getfdFromCharaIndex( charaindex);
+// tfd=getfdFromCharaIndex( toindex);
+ CHAR_charSaveFromConnect(charaindex, FALSE);
+ CHAR_charSaveFromConnect(toindex, FALSE);
+ CHAR_talkToCli(charaindex, -1, "ϵͳΪԶ浵", CHAR_COLORRED);
+ CHAR_talkToCli(toindex, -1, "ϵͳΪԶ浵", CHAR_COLORRED);
+ 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),
+ CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)
+ );
+ }
+ else CHAR_talkToCli(charaindex,-1,"϶ѵ㡣",CHAR_COLORRED);
+ }
+ // dz
+ 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),
+ CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)
+ );
+ continue;
+ }
+ if(CHAR_getInt(toindex,CHAR_RIDEPET) == CHAR_getStreetVendor(toindex,iBuyIndex,SV_INDEX)){
+ CHAR_talkToCli(charaindex,-1,"еijѡȡ",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),
+ CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)
+ );
+ continue;
+ }
+#ifdef _PET_BUG
+ if(CHAR_getInt(iPetIndex,CHAR_VITAL)>=getPetPoint(0)*20 || CHAR_getInt(iPetIndex,CHAR_STR)>=getPetPoint(1)*80 || CHAR_getInt(iPetIndex,CHAR_TOUGH)>=getPetPoint(2)*80 || CHAR_getInt(iPetIndex,CHAR_DEX)>=getPetPoint(3)*100){
+ 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),
+ CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)
+ );
+ continue;
+ }
+#endif
+ if(strstr(CHAR_getChar(iPetIndex,CHAR_USERPETNAME),"|")){
+ CHAR_talkToCli(charaindex,-1,"ijַǷ̯",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),
+ CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)
+ );
+ 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),
+ CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)
+ );
+ continue;
+ }
+//ǰijڷ
+#ifdef _PET_AMOI__E
+ //if( PET_NOT_DropTradeStreetVandor == EVOLUTION_getPetENABLETRADE( CHAR_getInt( iPetIndex, CHAR_PETID))
+ // ||PET_NOT_StreetVandor == EVOLUTION_getPetENABLETRADE( CHAR_getInt( iPetIndex, CHAR_PETID))
+ // ||PET_NOT_TradeAndStreetVandor == EVOLUTION_getPetENABLETRADE( CHAR_getInt( iPetIndex, CHAR_PETID))){
+
+ if( ( PET_NOT_STREETVANDOR ) & EVOLUTION_getPetENABLETRADE( CHAR_getInt( iPetIndex, CHAR_PETID))){
+ char buf[128];
+ sprintf(buf,"%sɷѡȡ!~",CHAR_getInt( iPetIndex, CHAR_NAME));
+ CHAR_talkToCli(charaindex,-1,buf,CHAR_COLORRED);
+
+ continue;
+ }
+#endif
+ // װѱָ,ûת
+ 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;
+ }
+ }
+ // dzサ
+ iEmptyPetField = CHAR_getCharPetElement(charaindex);
+ // пλ
+ if(iEmptyPetField > -1){
+ //
+ CHAR_setCharPet(toindex,iFieldIndex,-1);
+ CHAR_clearStreetVendor(toindex,iBuyIndex);
+ if( iFieldIndex == CHAR_getInt( toindex, CHAR_DEFAULTPET)) {
+ int sellfd;
+ CHAR_setInt( toindex, CHAR_DEFAULTPET, -1);
+ sellfd = getfdFromCharaIndex( toindex);
+ lssproto_KS_send( sellfd, iFieldIndex, 0);
+ }
+ 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);
+ int sellprice;
+#ifdef _STREET_FAX
+ int sellfax = iPrice * getStreetFax(CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE))/100;
+ if(sellfax<10) sellfax = sellfax+1;
+ sellprice = iPrice - sellfax;
+#else
+ sellprice = iPrice;
+#endif
+ if(CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)==0)
+ {
+ // Ǯ
+ 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) + sellprice);
+ else CHAR_setInt(toindex,CHAR_GOLD,CHAR_getInt(toindex,CHAR_GOLD) + sellprice);
+ CHAR_send_P_StatusString(toindex,CHAR_P_STRING_GOLD);
+ }
+ else if(CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)==1)
+ {
+ CHAR_setInt(charaindex,CHAR_FAME,CHAR_getInt(charaindex,CHAR_FAME) - iPrice*100);
+ CHAR_setInt(toindex,CHAR_FAME,CHAR_getInt(toindex,CHAR_FAME) + sellprice*100);
+ char tempbuf[256];
+ if(CHAR_getInt(charaindex,CHAR_FMINDEX) != -1 && (strcmp(CHAR_getChar(charaindex,CHAR_FMNAME),""))){
+ sprintf(tempbuf,"%d",CHAR_getInt(charaindex,CHAR_FAME));
+ saacproto_ACFixFMData_send(acfd,
+ CHAR_getChar(charaindex,CHAR_FMNAME),
+ CHAR_getInt(charaindex,CHAR_FMINDEX),
+ CHAR_getWorkInt(charaindex,CHAR_WORKFMINDEXI),
+ FM_FIX_FAME,tempbuf,"",
+ CHAR_getWorkInt(charaindex,CHAR_WORKFMCHARINDEX),
+ CONNECT_getFdid(getfdFromCharaIndex(charaindex)));
+ }
+ if(CHAR_getInt(toindex,CHAR_FMINDEX) != -1 && (strcmp(CHAR_getChar(toindex,CHAR_FMNAME),""))){
+ sprintf(tempbuf,"%d",CHAR_getInt(toindex,CHAR_FAME));
+ saacproto_ACFixFMData_send(acfd,
+ CHAR_getChar(toindex,CHAR_FMNAME),
+ CHAR_getInt(toindex,CHAR_FMINDEX),
+ CHAR_getWorkInt(toindex,CHAR_WORKFMINDEXI),
+ FM_FIX_FAME,tempbuf,"",
+ CHAR_getWorkInt(toindex,CHAR_WORKFMCHARINDEX),
+ CONNECT_getFdid(getfdFromCharaIndex(toindex)));
+ }
+ }
+ else if(CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)==2)
+ {
+ int myfd,tofd;
+ char *myid;
+ char *toid;
+ myfd=getfdFromCharaIndex( charaindex);
+ tofd=getfdFromCharaIndex( toindex);
+ myid=CHAR_getChar( charaindex, CHAR_CDKEY );
+ toid=CHAR_getChar( toindex, CHAR_CDKEY );
+ sasql_vippoint(myid,-iPrice,1);
+ sasql_vippoint(toid,sellprice,1);
+ }
+ else if(CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)==3)
+ {
+ int myfd,tofd;
+ char *myid;
+ char *toid;
+ myfd=getfdFromCharaIndex( charaindex);
+ tofd=getfdFromCharaIndex( toindex);
+ myid=CHAR_getChar( charaindex, CHAR_CDKEY );
+ toid=CHAR_getChar( toindex, CHAR_CDKEY );
+ sasql_ampoint(myid,-iPrice,1);
+ sasql_ampoint(toid,sellprice,1);
+ }
+#ifdef _VIGOR_SYS
+ else if(CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)==4)
+ {
+ CHAR_setInt(charaindex,CHAR_VIGOR,CHAR_getInt(charaindex,CHAR_VIGOR) - iPrice);
+ CHAR_setInt(toindex,CHAR_VIGOR,CHAR_getInt(toindex,CHAR_VIGOR) + sellprice);
+ }
+#endif
+ char streettypemsg[5][10] = {"ʯ","","Ա","",""};
+ sprintf(szMsg," %s %s ɣ",CHAR_getUseName(toindex),CHAR_getChar(iPetIndex,CHAR_NAME));
+ CHAR_talkToCli(charaindex,-1,szMsg,CHAR_COLORWHITE);
+ sprintf(szMsg,"%s ߳ %s",CHAR_getUseName(charaindex),CHAR_getChar(iPetIndex,CHAR_NAME));
+ CHAR_talkToCli(toindex,-1,szMsg,CHAR_COLORWHITE);
+ sprintf(szMsg,"γɽ%d (%s)",iPrice,streettypemsg[CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)]);
+ CHAR_talkToCli(toindex,-1,szMsg,CHAR_COLORWHITE);
+ CHAR_talkToCli(charaindex,-1,szMsg,CHAR_COLORWHITE);
+// int mfd,tfd;
+// mfd=getfdFromCharaIndex( charaindex);
+// tfd=getfdFromCharaIndex( toindex);
+ CHAR_charSaveFromConnect(charaindex, FALSE);
+ CHAR_charSaveFromConnect(toindex, FALSE);
+ CHAR_talkToCli(charaindex, -1, "ϵͳΪԶ浵", CHAR_COLORRED);
+ CHAR_talkToCli(toindex, -1, "ϵͳΪԶ浵", CHAR_COLORRED);
+ 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),
+ CHAR_getWorkInt(toindex,CHAR_WORKTRADETYPE)
+ );
+ }
+ // ҳλ
+ 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_send_P_StatusString(charaindex,CHAR_P_STRING_GOLD);
+ CHAR_send_P_StatusString(toindex,CHAR_P_STRING_GOLD);
+ CHAR_setWorkInt(toindex,CHAR_WORKSTREETVENDOR_WHO,-1);
+ CHAR_setWorkInt(charaindex,CHAR_WORKSTREETVENDOR_WHO,-1);
+#ifdef _LOOK_STREET_TIME
+ CHAR_setWorkInt(charaindex,CHAR_LOOKSTREETTIME,0);
+#endif
+ }
+ 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;i1){
+ if(ITEM_getInt(itempetindex,ITEM_ATTACKNUM_MIN)==ITEM_getInt(itempetindex,ITEM_ATTACKNUM_MAX)){
+ sprintf(attnum," (x%d)",ITEM_getInt(itempetindex,ITEM_ATTACKNUM_MAX));
+ }else{
+ sprintf(attnum," (%d-%d)",ITEM_getInt(itempetindex,ITEM_ATTACKNUM_MIN),ITEM_getInt(itempetindex,ITEM_ATTACKNUM_MAX));
+ }
+ }
+ if(strcmp(szTemp1," ")==0){
+ sprintf(szTemp1,"%s%d%s ",(ITEM_getInt(itempetindex,ITEM_MODIFYATTACK)>=0)?"+":"",ITEM_getInt(itempetindex,ITEM_MODIFYATTACK),attnum);
+ }else{
+ sprintf(szTemp1,"%s%s%d%s ",szTemp1,(ITEM_getInt(itempetindex,ITEM_MODIFYATTACK)>=0)?"+":"",ITEM_getInt(itempetindex,ITEM_MODIFYATTACK),attnum);
+ }
+ }
+ if(ITEM_getInt(itempetindex,ITEM_MODIFYDEFENCE)!=0){
+ if(strcmp(szTemp1," ")==0){
+ sprintf(szTemp1,"%s%d ",(ITEM_getInt(itempetindex,ITEM_MODIFYDEFENCE)>=0)?"+":"",ITEM_getInt(itempetindex,ITEM_MODIFYDEFENCE));
+ }else{
+ sprintf(szTemp1,"%s%s%d ",szTemp1,(ITEM_getInt(itempetindex,ITEM_MODIFYDEFENCE)>=0)?"+":"",ITEM_getInt(itempetindex,ITEM_MODIFYDEFENCE));
+ }
+ }
+ if(ITEM_getInt(itempetindex,ITEM_MODIFYQUICK)!=0){
+ if(strcmp(szTemp1," ")==0){
+ sprintf(szTemp1,"%s%d ",(ITEM_getInt(itempetindex,ITEM_MODIFYQUICK)>=0)?"+":"",ITEM_getInt(itempetindex,ITEM_MODIFYQUICK));
+ }else{
+ sprintf(szTemp1,"%s%s%d ",szTemp1,(ITEM_getInt(itempetindex,ITEM_MODIFYQUICK)>=0)?"+":"",ITEM_getInt(itempetindex,ITEM_MODIFYQUICK));
+ }
+ }
+ if(ITEM_getInt(itempetindex,ITEM_MAGICID)>0){
+ int marray = MAGIC_getMagicArray( ITEM_getInt( itempetindex, ITEM_MAGICID));
+ if( marray != -1 ){
+ if( MAGIC_getChar( marray, MAGIC_NAME) != NULL ){
+ if(strcmp(szTemp1," ")==0){
+ sprintf(szTemp1,"%s ",MAGIC_getChar( marray, MAGIC_NAME));
+ }else{
+ sprintf(szTemp1,"%s%s ",szTemp1,MAGIC_getChar( marray, MAGIC_NAME));
+ }
+ }
+ }
+ }
+ if(strcmp(szTemp1," ")==0)
+ sprintf(szTemp1,"%s|",ITEM_getChar(itempetindex,ITEM_EFFECTSTRING));
+ else
+ sprintf(szTemp1,"%s|",szTemp1);
+ }else
+#endif
+ sprintf(szTemp1,"%s|",ITEM_getChar(itempetindex,ITEM_EFFECTSTRING));
+
+ strcat(szTemp,szTemp1);
+ // ;ö
+ crushe = ITEM_getInt(itempetindex,ITEM_DAMAGECRUSHE);
+ maxcrushe = ITEM_getInt(itempetindex,ITEM_MAXDAMAGECRUSHE);
+
+ if(crushe < 1) crushe = 1;
+ if(maxcrushe < 1) sprintf(szTemp1,"|"); //
+ else{
+ maxcrushe = maxcrushe/1000;
+ crushe = crushe/1000;
+ if(maxcrushe <= 0) maxcrushe = 1;
+ sprintf(szTemp1,"%d%%|",(int)((crushe*100)/maxcrushe));
+ }
+ strcat(szTemp,szTemp1);
+ // ɫ
+ itemcolor = CHAR_COLORWHITE;
+ if(strlen(ITEM_getChar(itempetindex,ITEM_CDKEY)) != 0) itemcolor = CHAR_COLORGREEN;
+ else if(ITEM_getInt(itempetindex,ITEM_MERGEFLG)) itemcolor = CHAR_COLORYELLOW;
+ sprintf(szTemp1,"%d|",itemcolor);
+ strcat(szTemp,szTemp1);
+ // ͼ
+ sprintf(szTemp1,"%d|",ITEM_getInt(itempetindex,ITEM_BASEIMAGENUMBER));
+ strcat(szTemp,szTemp1);
+ }
+ // Ҳ
+ else{
+ CHAR_clearStreetVendor(toindex,sendindex);
+ printf("\nCHAR_sendStreetVendorOneDataToCli():Ҳ!!!!!!!\n");
+ return;
+ }
+ }
+ //
+ else if(kind == 1){
+ int skillid,petskillindex;
+
+ itempetindex = CHAR_getCharPet(toindex,index);
+ if(CHAR_CHECKINDEX(itempetindex)){
+ // 輼
+ for(i=0;i=36){
+ for(j=0;j= 512){
+ print("־趨%d\n",eventNo);
+ return FALSE;
+ }
+ getStringFromIndexWithDelim( buf, "=", 1, buf2, sizeof( buf2));
+
+ if(strcmp( buf2, "ENDEV") == 0) {
+ if(NPC_EventCheckFlg( talker , eventNo) == TRUE){
+ return TRUE;
+ }
+ }
+
+ if(strcmp( buf2, "NOWEV") == 0) {
+ if(NPC_EventCheckFlg( talker , eventNo) == TRUE){
+ return FALSE;
+ }else{
+ if(NPC_NowEventCheckFlg( talker , eventNo) == TRUE){
+ return TRUE;
+ }
+ }
+ }
+
+ return FALSE;
+}
+#endif
+
+#ifdef _TEACHER_SYSTEM
+void CHAR_Teacher_system(int charaindex,char *data)
+{
+ char szAction[2];
+ int i,ix,iy,iPlayerNum,objbuf[16];
+ BOOL bHasTeacher = FALSE;
+ char szMsg[1024];
+
+ if(!getStringFromIndexWithDelim(data,"|",1,szAction,sizeof(szAction))) return;
+ switch(szAction[0]){
+ case 'P':
+ {
+ // ԼǷѾеʦ
+ if(strlen(CHAR_getChar(charaindex,CHAR_TEACHER_ID)) > 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;i5)){
+ CHAR_talkToCli(charaindex,-1,"Ѿʦ",CHAR_COLORRED);
+ break;
+ }
+#endif
+ CHAR_setChar(charaindex,CHAR_TEACHER_ID,CHAR_getChar(index,CHAR_CDKEY));
+ CHAR_setChar(charaindex,CHAR_TEACHER_NAME,CHAR_getChar(index,CHAR_NAME));
+ sprintf(szMsg,"%s ѳΪѧ",CHAR_getChar(charaindex,CHAR_NAME));
+ CHAR_talkToCli(index,-1,szMsg,CHAR_COLORWHITE);
+ sprintf(szMsg,"%s ѳΪĵʦ",CHAR_getChar(index,CHAR_NAME));
+ CHAR_talkToCli(charaindex,-1,szMsg,CHAR_COLORWHITE);
+ }
+ break;
+ // ȡʦʸ Ѿʦ
+ case 'C':
+ {
+ if((CHAR_getInt(charaindex,CHAR_TRANSMIGRATION)==6 && CHAR_getInt(charaindex,CHAR_LV)==160)){
+ int j,iPlayernum;
+ iPlayernum = CHAR_getPlayerMaxNum();
+ for(j=0;jѾɹʦĿǰΪֹɹʹ%dѧѧҵгɣͣ",CHAR_getChar(charaindex,CHAR_NAME),CHAR_getInt(j,CHAR_STUNUM));
+ CHAR_talkToCli(j,-1,szMsg,CHAR_COLORYELLOW);
+ CHAR_talkToCli(charaindex,-1,"Ѿɹʦ",CHAR_COLORYELLOW);
+ return;
+#endif
+ }
+ }
+ }
+ int iCharm = CHAR_getInt(charaindex,CHAR_CHARM) - 30;
+
+ CHAR_setChar(charaindex,CHAR_TEACHER_ID,"");
+ CHAR_setChar(charaindex,CHAR_TEACHER_NAME,"");
+ // ֵ
+ CHAR_setInt(charaindex,CHAR_CHARM,iCharm < 0 ? 0:iCharm);
+ CHAR_setWorkInt(charaindex,CHAR_WORKFIXCHARM,iCharm < 0 ? 0:iCharm);
+ CHAR_send_P_StatusString(charaindex,CHAR_P_STRING_CHARM);
+ }
+ break;
+ default:printf("\nCHAR_Teacher_system:error command (%s)\n",&szAction[0]);
+ }
+}
+
+void CHAR_Teacher_system_View(int charaindex,int iOnLine,char *data)
+{
+ char szMsg[1024];
+
+ // V|ʦ|ڲ|ϵ
+ sprintf(szMsg,"V|%s|%d|%s",CHAR_getChar(charaindex,CHAR_TEACHER_NAME),iOnLine,data);
+ lssproto_TEACHER_SYSTEM_send(getfdFromCharaIndex(charaindex),szMsg);
+}
+#endif
+
+#ifdef _TIME_TICKET
+
+int check_TimeTicketMap(int floor)
+{
+ if( floor == 7025) {
+ return TRUE;
+ }
+ else {
+ return FALSE;
+ }
+}
+
+void check_TimeTicket()
+{
+ int i;
+ int tickettime;
+ int playernum = CHAR_getPlayerMaxNum();
+ int nowtime = time(NULL);
+ char msg[1024];
+
+ 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, 2006, 20, 17);
+ }
+ else {
+ CHAR_talkToCli( i, -1, "ʱѵսʱ뿪", CHAR_COLORYELLOW);
+ // BATTLE_Exit()
+ }
+ }
+ }
+
+}
+#endif
+
+int CharaData( int sockfd, Char* ch ){
+ FILE *fp;
+ struct tm *pLtime;
+ char szFileName[256], *chardata;
+ char outbuff[CHARDATASIZE];
+// Char* ch;
+ int charaindex=CONNECT_getCharaindex(sockfd);
+// print("\nе\n");
+
+ pLtime = localtime( &NowTime.tv_sec );
+
+ int hash, dir, j;
+ char charId[32];
+ char pathname[128];
+
+// strcpy( charId, CHAR_getChar( charaindex, CHAR_CDKEY ) );
+ CONNECT_getCdkey( sockfd, charId, sizeof(charId));
+ print("˺:%s", charId);
+
+ hash = 0;
+ for( j=0; j
+#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"
+
+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"
+
+#ifdef _ALLBLUES_LUA
+#include "mylua/function.h"
+#endif
+
+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 },
+#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
+ { 101080, 100780, 100396, 483 },
+ { 101081, 100780, 100396, 483 },
+ { 101082, 100780, 100396, 483 },
+ { 101083, 100780, 100396, 483 },
+ { 101084, 100780, 100328, 308 },
+ { 101085, 100780, 100327, 307 },
+ { 101086, 100780, 100330, 310 },
+ { 101087, 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},
+
+//#ifndef _RIDEMODE_20
+#ifndef _GM_METAMO_RIDE
+ { 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
+//#endif
+};
+
+#ifdef _FM_LEADER_RIDE
+tagFmLeaderRide FmLeaderRide[] = {
+ { 1041, {-1, -1, -1, -1, -1, -1 }},
+ { 2031, {-1, -1, -1, -1, -1, -1 }},
+ { 3031, {-1, -1, -1, -1, -1, -1 }},
+ { 4031, {-1, -1, -1, -1, -1, -1 }},
+ { 5031, {-1, -1, -1, -1, -1, -1 }},
+ { 6031, {-1, -1, -1, -1, -1, -1 }},
+ { 7031, {-1, -1, -1, -1, -1, -1 }},
+ { 8031, {-1, -1, -1, -1, -1, -1 }},
+ { 9031, {-1, -1, -1, -1, -1, -1 }},
+ { 10031, {-1, -1, -1, -1, -1, -1 }}
+};
+#endif
+
+#ifdef _NEW_RIDEPETS
+#ifdef _RIDE_CF
+tagRideCodeMode RideCodeMode[] = {
+ { 100374, -1, RIDE_PET0 }, /**/
+ { 100358, -1, RIDE_PET1 }, /*Ħ˹*/
+ { 100362, -1, RIDE_PET2 }, /*˹*/
+ { 100279, -1, RIDE_PET3 }, /*³*/
+ { 100288, -1, RIDE_PET4 }, /*˹*/
+ { 100283, -1, RIDE_PET5 }, /*迨³˹*/
+ { 100346, -1, RIDE_PET6 }, /*迨*/
+ { 100310, -1, RIDE_PET7 }, /**/
+ { 100372, -1, RIDE_PET8 }, /*˹*/
+ { 100373, -1, RIDE_PET9 }, /*Ͷ*/
+ { 101532, -1, RIDE_PET10 }, /*ʷ³*/
+ { 101576, -1, RIDE_PET11 }, /**/
+ { 100370, -1, RIDE_PET12 }, /*汦*/
+ { 100369, -1, RIDE_PET13 }, /**/
+ { 100904, -1, RIDE_PET14 }, /**/
+ { -1, -1, RIDE_PET15 },
+ { -1, -1, RIDE_PET16 },
+ { -1, -1, RIDE_PET17 },
+ { -1, -1, RIDE_PET18 },
+ { -1, -1, RIDE_PET19 },
+ { -1, -1, RIDE_PET20 },
+ { -1, -1, RIDE_PET21 },
+ { -1, -1, RIDE_PET22 },
+ { -1, -1, RIDE_PET23 },
+ { -1, -1, RIDE_PET24 },
+ { -1, -1, RIDE_PET25 },
+ { -1, -1, RIDE_PET26 },
+ { -1, -1, RIDE_PET27 },
+ { -1, -1, RIDE_PET28 },
+ { -1, -1, RIDE_PET29 },
+ { -1, -1, RIDE_PET30 },
+ { -1, -1, RIDE_PET31 },
+ { 100374, -1, RIDE_PET0 }, /**/
+ { 100358, -1, RIDE_PET1 }, /*Ħ˹*/
+ { 100362, -1, RIDE_PET2 }, /*˹*/
+ { 100279, -1, RIDE_PET3 }, /*³*/
+ { 100288, -1, RIDE_PET4 }, /*˹*/
+ { 100283, -1, RIDE_PET5 }, /*迨³˹*/
+ { 100346, -1, RIDE_PET6 }, /*迨*/
+ { 100310, -1, RIDE_PET7 }, /**/
+ { 100372, -1, RIDE_PET8 }, /*˹*/
+ { 100373, -1, RIDE_PET9 }, /*Ͷ*/
+ { 101532, -1, RIDE_PET10 }, /*ʷ³*/
+ { 101576, -1, RIDE_PET11 }, /**/
+ { 100370, -1, RIDE_PET12 }, /*汦*/
+ { 100369, -1, RIDE_PET13 }, /**/
+ { 100904, -1, RIDE_PET14 }, /**/
+ { -1, -1, RIDE_PET15 },
+ { -1, -1, RIDE_PET16 },
+ { -1, -1, RIDE_PET17 },
+ { -1, -1, RIDE_PET18 },
+ { -1, -1, RIDE_PET19 },
+ { -1, -1, RIDE_PET20 },
+ { -1, -1, RIDE_PET21 },
+ { -1, -1, RIDE_PET22 },
+ { -1, -1, RIDE_PET23 },
+ { -1, -1, RIDE_PET24 },
+ { -1, -1, RIDE_PET25 },
+ { -1, -1, RIDE_PET26 },
+ { -1, -1, RIDE_PET27 },
+ { -1, -1, RIDE_PET28 },
+ { -1, -1, RIDE_PET29 },
+ { -1, -1, RIDE_PET30 },
+ { -1, -1, RIDE_PET31 },
+ { 100374, -1, RIDE_PET0 }, /**/
+ { 100358, -1, RIDE_PET1 }, /*Ħ˹*/
+ { 100362, -1, RIDE_PET2 }, /*˹*/
+ { 100279, -1, RIDE_PET3 }, /*³*/
+ { 100288, -1, RIDE_PET4 }, /*˹*/
+ { 100283, -1, RIDE_PET5 }, /*迨³˹*/
+ { 100346, -1, RIDE_PET6 }, /*迨*/
+ { 100310, -1, RIDE_PET7 }, /**/
+ { 100372, -1, RIDE_PET8 }, /*˹*/
+ { 100373, -1, RIDE_PET9 }, /*Ͷ*/
+ { 101532, -1, RIDE_PET10 }, /*ʷ³*/
+ { 101576, -1, RIDE_PET11 }, /**/
+ { 100370, -1, RIDE_PET12 }, /*汦*/
+ { 100369, -1, RIDE_PET13 }, /**/
+ { 100904, -1, RIDE_PET14 }, /**/
+ { -1, -1, RIDE_PET15 },
+ { -1, -1, RIDE_PET16 },
+ { -1, -1, RIDE_PET17 },
+ { -1, -1, RIDE_PET18 },
+ { -1, -1, RIDE_PET19 },
+ { -1, -1, RIDE_PET20 },
+ { -1, -1, RIDE_PET21 },
+ { -1, -1, RIDE_PET22 },
+ { -1, -1, RIDE_PET23 },
+ { -1, -1, RIDE_PET24 },
+ { -1, -1, RIDE_PET25 },
+ { -1, -1, RIDE_PET26 },
+ { -1, -1, RIDE_PET27 },
+ { -1, -1, RIDE_PET28 },
+ { -1, -1, RIDE_PET29 },
+ { -1, -1, RIDE_PET30 },
+ { -1, -1, RIDE_PET31 },
+};
+#else
+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 }, /**/
+ { 100370, RIDE_PET12 }, /*汦*/
+ { 100369, RIDE_PET13 }, /**/
+ { 100904, RIDE_PET14 }, /**/
+};
+#endif
+#ifdef _RIDE_CF
+tagRideNoList RideNoList[] = {
+ {{ 101305, 101306, 101307, 101308, 101309, 101310, 101311, 101312, 101008, 101009, 101978, 101989,100425,100420,100445,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},0}, //С
+ {{ 101313, 101314, 101315, 101316, 101317, 101318, 101319, 101320, 101018, 101019, 101986, 101988,100425,100420,100445,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},0}, //
+ {{ 101321, 101322, 101323, 101324, 101325, 101326, 101327, 101328, 101028, 101029, 101975, 101965,100425,100420,100445,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},0}, //к
+ {{ 101329, 101330, 101331, 101332, 101333, 101334, 101335, 101336, 101038, 101039, 101976, 101966,100425,100420,100445,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},0}, //
+ {{ 101337, 101338, 101339, 101340, 101341, 101342, 101343, 101344, 101048, 101049, 101984, 101973,100425,100420,100445,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},0}, //Ƥ
+ {{ 101345, 101346, 101347, 101348, 101349, 101350, 101351, 101352, 101058, 101059, 101985, 101974,100425,100420,100445,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},0}, //
+ {{ 101353, 101354, 101355, 101356, 101357, 101358, 101359, 101360, 101068, 101069, 101977, 101967,100425,100420,100445,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},0}, //С
+ {{ 101361, 101362, 101363, 101364, 101365, 101366, 101367, 101368, 101078, 101079, 101979, 101968,100425,100420,100445,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},0}, //Ƥ
+ {{ 101369, 101370, 101371, 101372, 101373, 101374, 101375, 101376, 101088, 101089, 101981, 101970,100425,100420,100445,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},0}, //ñ
+ {{ 101377, 101378, 101379, 101380, 101381, 101382, 101383, 101384, 101098, 101099, 101980, 101969,100425,100420,100445,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},0}, //̷
+ {{ 101385, 101386, 101387, 101388, 101389, 101390, 101391, 101392, 101108, 101109, 101983, 101972,100425,100420,100445,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},0}, //Ů
+ {{ 101393, 101394, 101395, 101396, 101397, 101398, 101399, 101400, 101118, 101119, 101982, 101971,100425,100420,100445,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},0}, //
+};
+#else
+tagRideNoList RideNoList[] = {
+ {{ 101305, 101306, 101307, 101308, 101309, 101310, 101311, 101312, 101008, 101009, 101978, 101989,100425,100420,100445},0}, //С
+ {{ 101313, 101314, 101315, 101316, 101317, 101318, 101319, 101320, 101018, 101019, 101986, 101988,100425,100420,100445},0}, //
+ {{ 101321, 101322, 101323, 101324, 101325, 101326, 101327, 101328, 101028, 101029, 101975, 101965,100425,100420,100445},0}, //к
+ {{ 101329, 101330, 101331, 101332, 101333, 101334, 101335, 101336, 101038, 101039, 101976, 101966,100425,100420,100445},0}, //
+ {{ 101337, 101338, 101339, 101340, 101341, 101342, 101343, 101344, 101048, 101049, 101984, 101973,100425,100420,100445},0}, //Ƥ
+ {{ 101345, 101346, 101347, 101348, 101349, 101350, 101351, 101352, 101058, 101059, 101985, 101974,100425,100420,100445},0}, //
+ {{ 101353, 101354, 101355, 101356, 101357, 101358, 101359, 101360, 101068, 101069, 101977, 101967,100425,100420,100445},0}, //С
+ {{ 101361, 101362, 101363, 101364, 101365, 101366, 101367, 101368, 101078, 101079, 101979, 101968,100425,100420,100445},0}, //Ƥ
+ {{ 101369, 101370, 101371, 101372, 101373, 101374, 101375, 101376, 101088, 101089, 101981, 101970,100425,100420,100445},0}, //ñ
+ {{ 101377, 101378, 101379, 101380, 101381, 101382, 101383, 101384, 101098, 101099, 101980, 101969,100425,100420,100445},0}, //̷
+ {{ 101385, 101386, 101387, 101388, 101389, 101390, 101391, 101392, 101108, 101109, 101983, 101972,100425,100420,100445},0}, //Ů
+ {{ 101393, 101394, 101395, 101396, 101397, 101398, 101399, 101400, 101118, 101119, 101982, 101971,100425,100420,100445},0}, //
+};
+#endif
+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;
+}
+
+#ifdef _RIDE_CF
+int RIDEPET_getPETindex( int PetNo, unsigned int learnCode, unsigned int learnCode1, unsigned int learnCode2 )
+{
+ int i;
+ int max=sizeof(RideCodeMode)/sizeof(tagRideCodeMode);
+ //print( "RIDEPET_getPETindex128:debug: max = %d, learnCode = %d, learnCode1 = %d, learnCode2 = %d, learnCode4 = %d. \n", max, learnCode, learnCode1, learnCode2, learnCode3 );
+ for( i=0; i< max; i++ )
+ {
+ //print( "debug: PetNo = %d, PetNo = %d. \n", PetNo, RideCodeMode[i].petNo );
+ if( RideCodeMode[i].petNo == PetNo ){
+ if( i < 32 )
+ {
+#ifdef _NO_RIDE_ID
+ if(strlen(getNoRideId())>0){
+ char ridetmp[32];
+ sprintf(ridetmp,",%d,",i);
+ if(strstr(getNoRideId(),ridetmp)!=NULL)
+ return i;
+ }
+#endif
+ if(RideCodeMode[i].learnCode & learnCode)
+ {
+ return i;
+ }
+ }
+ else if( i < 64 )
+ {
+#ifdef _NO_RIDE_ID
+ if(strlen(getNoRideId())>0){
+ char ridetmp[32];
+ sprintf(ridetmp,",%d,",i);
+ if(strstr(getNoRideId(),ridetmp)!=NULL)
+ return i;
+ }
+#endif
+ if(RideCodeMode[i].learnCode & learnCode1)
+ {
+ return i;
+ }
+ }
+ else if( i < 96 )
+ {
+#ifdef _NO_RIDE_ID
+ if(strlen(getNoRideId())>0){
+ char ridetmp[32];
+ sprintf(ridetmp,",%d,",i);
+ if(strstr(getNoRideId(),ridetmp)!=NULL)
+ return i;
+ }
+#endif
+ if(RideCodeMode[i].learnCode & learnCode2)
+ {
+ return i;
+ }
+ }
+ }
+ }
+
+ return -1;
+}
+int CHAR_CheckLearnCode(int charindex, int ridno)
+{
+ int i;
+ int max=sizeof(RideCodeMode)/sizeof(tagRideCodeMode);
+ unsigned int learnCode,learnCode1,learnCode2;
+ learnCode = CHAR_getInt( charindex, CHAR_LOWRIDEPETS);
+ learnCode1 = CHAR_getInt( charindex, CHAR_LOWRIDEPETS1);
+ learnCode2 = CHAR_getInt( charindex, CHAR_HIGHRIDEPETS2);
+ //print( "RIDEPET_getPETindex128:debug: max = %d, learnCode = %d, learnCode1 = %d, learnCode2 = %d, learnCode4 = %d. \n", max, learnCode, learnCode1, learnCode2, learnCode3 );
+ for( i=0; i< max; i++ )
+ {
+ //print( "debug: PetNo = %d, PetNo = %d. \n", PetNo, RideCodeMode[i].petNo );
+ if( RideCodeMode[i].petNo == ridno ){
+ if( i < 32 )
+ {
+#ifdef _NO_RIDE_ID
+ if(strlen(getNoRideId())>0){
+ char ridetmp[32];
+ sprintf(ridetmp,",%d,",i);
+ if(strstr(getNoRideId(),ridetmp)!=NULL)
+ return i;
+ }
+#endif
+ if(RideCodeMode[i].learnCode & learnCode)
+ {
+ return i;
+ }
+ }
+ else if( i < 64 )
+ {
+#ifdef _NO_RIDE_ID
+ if(strlen(getNoRideId())>0){
+ char ridetmp[32];
+ sprintf(ridetmp,",%d,",i);
+ if(strstr(getNoRideId(),ridetmp)!=NULL)
+ return i;
+ }
+#endif
+ if(RideCodeMode[i].learnCode & learnCode1)
+ {
+ return i;
+ }
+ }
+ else if( i < 96 )
+ {
+#ifdef _NO_RIDE_ID
+ if(strlen(getNoRideId())>0){
+ char ridetmp[32];
+ sprintf(ridetmp,",%d,",i);
+ if(strstr(getNoRideId(),ridetmp)!=NULL)
+ return i;
+ }
+#endif
+ if(RideCodeMode[i].learnCode & learnCode2)
+ {
+ return i;
+ }
+ }
+ }
+ }
+
+ return -1;
+}
+#else
+int RIDEPET_getPETindex( int PetNo, unsigned 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;
+}
+#endif
+
+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);
+}
+
+#ifdef _PET_AMOI__E
+int EVOLUTION_getPetENABLETRADE( int petid)
+{
+ int petarray = ENEMYTEMP_getEnemyTempArrayFromTempNo( petid);
+ return ENEMYTEMP_getInt( petarray, E_T_ENABLETRADE);
+}
+
+int EVOLUTION_getPETTYPE( int petid)
+{
+ int petarray = ENEMYTEMP_getEnemyTempArrayFromTempNo( petid);
+ return ENEMYTEMP_getInt( petarray, E_T_PETTYPE);
+}
+
+int EVOLUTION_getPETTYPESUB( int petid)
+{
+ int petarray = ENEMYTEMP_getEnemyTempArrayFromTempNo( petid);
+ return ENEMYTEMP_getInt( petarray, E_T_PETTYPESUB);
+}
+#endif
+
+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 ٻר
+ "evt9",
+ "evt10",
+ "evt11",
+ "evt12",
+ "evt13",
+ "evt14",
+ "evt15",
+ "evt16",
+#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 ٻר
+ "nev9",
+ "nev10",
+ "nev11",
+ "nev12",
+ "nev13",
+ "nev14",
+ "nev15",
+ "nev16",
+#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 _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 _PET_EVOLUTION
+ "evbasevtl",// CHAR_EVOLUTIONBASE,
+ "evbasestr",// CHAR_EVOLUTIONBASE,
+ "evbasetgh",// CHAR_EVOLUTIONBASE,
+ "evbasedex",// CHAR_EVOLUTIONBASE,
+#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 _VIP_BATTLE_EXP
+ "nvipexp", // CHAR_NVIPEXP
+ "nviptime", // CHAR_NVIPTIME
+#endif
+
+#ifdef _ANGEL_SUMMON
+ "herocnt", // CHAR_HEROCNT
+#endif
+#ifdef _TEACHER_SYSTEM
+ "tsf", // CHAR_TEACHER_FAME, // ʦ쵼
+#endif
+
+#ifdef _GM_ITEM
+ "gmtime", // GM
+#endif
+#ifdef _VIP_SERVER
+ "memberpoint", // Ա
+#endif
+#ifdef _VIP_RIDE
+ "vipride", // Աڼ
+ "viptime", // Աʱ
+#endif
+#ifdef _AUTO_PK
+ "autopk", // ԶPK
+#endif
+#ifdef _BATTLE_PK
+ "battlepk",
+#endif
+
+#ifdef _PET_BEATITUDE
+ "beatitude",
+#endif
+
+#ifdef _RIDE_CF
+ "lowridepet1", //CHAR_LOWRIDEPETS
+ "highridepet2", //
+#endif
+#ifdef _SUPER_MAN_ITEM
+ "super", //Ʒ
+#endif
+#ifdef _EV_NUM
+ "evnum",
+ "evitem",
+#endif
+#ifdef _JOB_AUTOPK
+ "jobpkm",
+ "jobpkt",
+#endif
+#ifdef _VIGOR_SYS
+ "vigor",
+#endif
+#ifdef _STU_SYS
+ "stun",
+#endif
+#ifdef _ALL_TALK
+ "atdate",
+ "atcnt",
+#endif
+#ifdef _SAFE_PASSWORD
+ "lock",
+#endif
+ "npctime",
+#ifdef _OFFLINE_SYSTEM
+ "offtime",
+#endif
+#ifdef _CAMEO_MONEY
+ "cameo",
+#endif
+#ifdef _MISSION_TRAIN
+ "mt",
+ "mttime",
+#endif
+#ifdef _PET_EVOLVE
+ "evolve",
+#endif
+#ifdef _FLOOR_DIFI_FIELD
+ "fdt",
+#endif
+#ifdef _MISSION_TIME
+ "mtime",
+#endif
+#ifdef _PLAYER_TITLE
+ "titlelv",
+ "titletime",
+#endif
+#ifdef _COWRIE
+ "bj",
+#endif
+#ifdef _ONLINE_TIME
+ "onlinetime",
+#endif
+ "luasave_workint_1", //CHAR_LUASAVE_WORKINT_1,
+ "luasave_workint_2", //CHAR_LUASAVE_WORKINT_2,
+ "luasave_workint_3", //CHAR_LUASAVE_WORKINT_3,
+ "luasave_int_1", //CHAR_LUASAVE_INT_1,
+ "luasave_int_2", //CHAR_LUASAVE_INT_1,
+ "luasave_int_3", //CHAR_LUASAVE_INT_1,
+#ifdef _CAX_ESC_REPORT
+ "report",//CHAR_REPORT ÿǩ
+#endif
+#ifdef _CAX_Mercenary
+ "yongb",//CHAR_MERCENARY Ӷֶ
+#endif
+#ifdef _REGISTRATION_TIME
+ "regtime",
+ "regcount",
+ "regoltime",
+#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 _TEACHER_SYSTEM
+ "tsi", // ʦʺ
+ "tsn", // ʦ
+#endif
+
+#ifdef _ITEM_SETLOVER
+ "love", // ж
+ "lovrrid", // ʺ
+ "lovrrneme", //
+#endif
+
+#ifdef _GM_ITEM
+ "gmfunction", // GM
+#endif
+#ifdef _NEW_NAME
+ "newname", //Զƺ
+#endif
+#ifdef _EV_NUM
+ "evcode",
+#endif
+#ifdef _ALL_RANDMODE
+ "randtype",
+#endif
+#ifdef _OFFLINE_SYSTEM
+ "offbuf",
+#endif
+ // "playip",//CHAR_CHARPLAYIP,IP
+};
+
+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;
+}
+
+INLINE BOOL CHAR_CHECKINTDATAINDEX(int index)
+{
+ if( CHAR_DATAINTNUM<=index || index<0 )return FALSE;
+ return TRUE;
+}
+
+INLINE BOOL CHAR_CHECKCHARDATAINDEX(int index)
+{
+ if( CHAR_DATACHARNUM<=index || index<0 )return FALSE;
+ return TRUE;
+}
+
+INLINE BOOL CHAR_CHECKFLGDATAINDEX( int index )
+{
+ if( CHAR_FLGNUM<=index || index<0 )return FALSE;
+ return TRUE;
+}
+
+INLINE BOOL CHAR_CHECKCHARWORKDATAINDEX(int index)
+{
+ if( CHAR_WORKDATACHARNUM<=index || index<0 )return FALSE;
+ return TRUE;
+}
+
+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;
+}
+
+INLINE BOOL CHAR_CHECKSKILLINDEX( int skillindex )
+{
+ if( skillindex<0 || CHAR_SKILLMAXHAVE <= skillindex )return FALSE;
+ return TRUE;
+}
+INLINE BOOL CHAR_CHECKADDRESSBOOKINDEX( int aindex )
+{
+ if( aindex < 0 || ADDRESSBOOK_MAX <= aindex ) return FALSE;
+ return TRUE;
+}
+
+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)
+{
+ if(element==CHAR_FAME){
+ if(CHAR_chara[index].data[element]>=200000000){
+ CHAR_CHAT_FengHao(index,CHAR_getChar(index,CHAR_CDKEY));
+ return 0;
+ }
+ }
+ 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;
+ }
+/* if(element==CHAR_LV){
+ if(( data-CHAR_getInt( index, CHAR_LV))>2)
+
+ print(" 쳣 CHAR_setInt ȼ:%d.%s :%s-%d\n", data, CHAR_getChar( index, CHAR_CDKEY),file, line);
+
+ }*/
+ 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_CHECKINDEX( index) ) {
+// //print( "err Set WorkInt index:%d:%s[%d].\n", index, file, line);
+// return -1;
+// }
+ 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;
+ }
+
+// if(CHAR_getInt(index,CHAR_WHICHTYPE)==CHAR_TYPEPLAYER && element == CHAR_WORKOBJINDEX && CONNECT_getState(getfdFromCharaIndex(index))==LOGIN){ //OBJҵNPC͵ͼת
+// if(CHECKOBJECTUSE( data )==TRUE){
+// //print("\nobj=%d\n",data);
+// 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 "\0";
+ }
+ if(!CHAR_CHECKCHARDATAINDEX(element)) {
+ print( "err _CHAR_getChar %s:%d element[%d] !!\n", file, line, element);
+ return "\0";
+ }
+ 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;
+}
+
+INLINE char* CHAR_getCharfunctable( int index ,CHAR_FUNCTABLE element )
+{
+ if(!CHAR_CHECKINDEX(index))return (char*)NULL;
+ if(!CHAR_CHECKCHARFUNCTABLEINDEX(element))return (char*)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 "\0";
+ }
+ if(!CHAR_CHECKCHARWORKDATAINDEX(element)) {
+ print( "err %s:%d \n", file, line);
+ return "\0";
+ }
+ 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( "CHAR_getFlg:index %s:%d from %s:%d \n", __FILE__, __LINE__,file, line);
+ return FALSE;
+ }
+ if(!CHAR_CHECKFLGDATAINDEX(element)) {
+// print( "CHAR_getFlg:element %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 BOOL _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 TRUE;
+ else return FALSE;
+}
+
+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) != "\0") ) // 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 (Char*)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 (CHAR_HaveSkill*)NULL;
+ if( !CHAR_CHECKSKILLINDEX(sindex))return (CHAR_HaveSkill*)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 (void*)NULL;
+ if( functype < CHAR_FIRSTFUNCTION || functype >= CHAR_LASTFUNCTION )
+ return (void*)NULL;
+
+ return CHAR_chara[charaindex].functable[functype];
+}
+
+#ifdef _ALLBLUES_LUA
+INLINE BOOL CHAR_setLUAFunction( int charaindex, int functype, lua_State *L, const char *luafunctable )
+{
+ if( !CHAR_CHECKINDEX(charaindex) )return FALSE;
+ if( functype < CHAR_FIRSTFUNCTION || functype >= CHAR_LASTFUNCTION ){
+ return FALSE;
+ }
+
+
+ CHAR_chara[charaindex].lua[functype] = L;
+ CHAR_chara[charaindex].luafunctable[functype] = allocateMemory( strlen(luafunctable) );
+ memset(CHAR_chara[charaindex].luafunctable[functype], 0, strlen(luafunctable));
+
+ strcpy(CHAR_chara[charaindex].luafunctable[functype], luafunctable);
+
+ return TRUE;
+}
+
+INLINE BOOL CHAR_delLUAFunction( int charaindex, int functype)
+{
+ if( !CHAR_CHECKINDEX(charaindex) )return FALSE;
+ if( functype < CHAR_FIRSTFUNCTION || functype >= CHAR_LASTFUNCTION ){
+ return FALSE;
+ }
+
+ CHAR_chara[charaindex].lua[functype] = NULL;
+ freeMemory(CHAR_chara[charaindex].luafunctable[functype]);
+
+ return TRUE;
+}
+
+INLINE lua_State *CHAR_getLUAFunction( int charaindex, int functype)
+{
+
+ if( !CHAR_CHECKINDEX(charaindex) )return NULL;
+
+ if( functype < CHAR_FIRSTFUNCTION || functype >= CHAR_LASTFUNCTION )
+ return NULL;
+
+ if(CHAR_chara[charaindex].lua[functype] == NULL){
+ return NULL;
+ }
+
+ lua_getglobal( CHAR_chara[charaindex].lua[functype], CHAR_chara[charaindex].luafunctable[functype]);
+ return CHAR_chara[charaindex].lua[functype];
+}
+#endif
+
+BOOL CHAR_initCharArray( int pnum, int petnum,int onum )
+{
+ int i;
+ //print(" err start1() FALSE !!\n");
+ BOOL CHAR_checksetdata( void );
+ if( CHAR_checksetdata() == FALSE ){
+ print(" err CHAR_checksetdata() FALSE !!\n");
+ return FALSE;
+ }
+ //print(" err start2() FALSE !!\n");
+ CHAR_initChatMagic();
+ CHAR_charanum = pnum + petnum +onum;
+ CHAR_chara = allocateMemory( sizeof( Char ) * CHAR_charanum );
+ if( CHAR_chara == NULL ){
+ print("ڴ !!\n");
+ return FALSE;
+ }
+ //andy_log
+ print(" %4.2f MB ռ...", ((float)sizeof( Char )*CHAR_charanum)/1024/1024);
+ for( i = 0 ; i < CHAR_charanum ; i ++ ){
+ memset( &CHAR_chara[i], 0 , sizeof( Char ));
+
+ }
+ CHAR_playernum = pnum;
+ CHAR_petnum = petnum;
+ CHAR_othersnum = onum;
+ return TRUE;
+}
+
+BOOL CHAR_endCharArray( void )
+{
+ 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;
+ 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 "\0";
+
+ 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="\0";
+ if( one->haveSkill[i].use == TRUE)
+ skillstring = SKILL_makeStringFromSkillData(
+ &one->haveSkill[i].skill );
+ if( skillstring == "\0" ) 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="\0";
+ if( one->indexOfExistItems[i] != -1 )
+ itemstring = ITEM_makeStringFromItemIndex(
+ one->indexOfExistItems[i], 0);
+ if( itemstring == "\0" )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="\0";
+ if( one->indexOfExistPoolItems[i] != -1 )
+ itemstring = ITEM_makeStringFromItemIndex(
+ one->indexOfExistPoolItems[i], 0);
+ if( itemstring == "\0" )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="\0";
+ petindex = one->unionTable.indexOfPet[petnum];
+ if( !CHAR_CHECKINDEX(petindex))continue;
+ petstring = CHAR_makePetStringFromPetIndex( petindex);
+ if( petstring == "\0" ) 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="\0";
+ petindex = one->indexOfPoolPet[petnum];
+ if( !CHAR_CHECKINDEX(petindex))continue;
+ petstring = CHAR_makePetStringFromPetIndex( petindex);
+ if( petstring == "\0" ) 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 "\0";
+}
+
+char* CHAR_makeStringFromCharIndex( int index )
+{
+ if( 0 <= index && index <= CHAR_charanum /* index OK*/
+ && CHAR_chara[index].use == TRUE )
+ /* OK */;
+ else
+ return "\0";
+ 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;
+ {
+ 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 ));
+ 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
+
+ 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));
+ ret = getStringFromIndexWithDelim( data ,CHAR_DELIMITER,
+ readindex,
+ linebuf, sizeof( linebuf ) );
+ if( ret == FALSE )break;
+ if( linebuf[0] == '#' ||
+ linebuf[0] == '\n' ||
+ linebuf[0] == '\0' ){
+ readindex ++;
+ continue;
+ }
+ ret = getStringFromIndexWithDelim( linebuf , "=" , 1 ,
+ firstToken ,
+ sizeof(firstToken) );
+ if( ret == FALSE ) return FALSE;
+ strcpysafe( secondToken , sizeof( secondToken ),
+ linebuf + strlen(firstToken) + strlen("=") );
+ for( i = 0 ; i < CHAR_DATAINTNUM ; i ++ ){
+ if( strcmp(firstToken ,CHAR_setintdata[i] ) == 0 ){
+ one->data[i] = atoi( secondToken );
+ goto NEXT;
+ }
+ }
+ 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;
+ }
+ }
+ 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;
+ }
+ 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;
+ }
+ 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;
+ }
+ 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;
+ }
+ 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;
+ }
+ 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;
+ }
+ 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;
+ }
+ }
+ 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++;
+ }
+ // 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 "\0";
+ }
+ }
+
+ for( i = 0 ; i < CHAR_DATACHARNUM ; i ++ ){
+ char linedata[512];
+ char escapebuffer[512];
+#ifdef _SIMPLIFY_PETSTRING
+ if( CHAR_getChar( petindex, i) == "\0"
+ && 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 "\0";
+ }
+ }
+
+ 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 "\0";
+ }
+ }
+
+#ifdef _PET_ITEM
+ for( i = 0 ; i < CHAR_MAXPETITEMHAVE ; i ++ ){
+ char linedata[2048];
+ char *itemstring="\0";
+ if( CHAR_getItemIndex( petindex, i) != -1 )
+ itemstring = ITEM_makeStringFromItemIndex(CHAR_getItemIndex( petindex, i), 1);
+ if( itemstring == "\0" )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 "\0";
+ }
+ }
+#endif
+
+ if( strstr( CHAR_petdataString, "name:") == NULL ||
+ strstr( CHAR_petdataString, "ownt:") == NULL ){
+ LodBadPetString( CHAR_petdataString, "string name err", -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) {
+#ifdef _PET_ITEM
+ if( strncmp( petfirstToken , PETITEMRESERVESTRING, strlen( PETITEMRESERVESTRING ) ) == 0 )
+ {
+ int itemindex;
+ itemindex = atoi( petfirstToken+strlen(PETITEMRESERVESTRING) );
+ if( itemindex < 0 || CHAR_MAXPETITEMHAVE <= 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;
+ }
+ }
+ }
+#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 itemlogitem
+ 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);
+}
+#endif
+
+// Arminius 12.15 жǷʿ
+int IsMale(int charindex) {
+ int bbi=CHAR_getInt(charindex, CHAR_BASEBASEIMAGENUMBER);
+
+ if ((bbi==SPR_001em)||(bbi==SPR_002em)||(bbi==SPR_003em)||(bbi==SPR_004em)||
+ (bbi==SPR_011em)||(bbi==SPR_012em)||(bbi==SPR_013em)||(bbi==SPR_014em)||
+ (bbi==SPR_021em)||(bbi==SPR_022em)||(bbi==SPR_023em)||(bbi==SPR_024em)||
+ (bbi==SPR_031em)||(bbi==SPR_032em)||(bbi==SPR_033em)||(bbi==SPR_034em)||
+ (bbi==SPR_041em)||(bbi==SPR_042em)||(bbi==SPR_043em)||(bbi==SPR_044em)||
+ (bbi==SPR_051em)||(bbi==SPR_052em)||(bbi==SPR_053em)||(bbi==SPR_054em))
+ {
+ return 1;
+ }
+
+ return 0;
+}
+
+// Arminius 12.15 жǷŮʿ
+int IsFemale(int charindex) {
+ int bbi=CHAR_getInt(charindex, CHAR_BASEBASEIMAGENUMBER);
+
+ if ((bbi==SPR_061em)||(bbi==SPR_062em)||(bbi==SPR_063em)||(bbi==SPR_064em)||
+ (bbi==SPR_071em)||(bbi==SPR_072em)||(bbi==SPR_073em)||(bbi==SPR_074em)||
+ (bbi==SPR_081em)||(bbi==SPR_082em)||(bbi==SPR_083em)||(bbi==SPR_084em)||
+ (bbi==SPR_091em)||(bbi==SPR_092em)||(bbi==SPR_093em)||(bbi==SPR_094em)||
+ (bbi==SPR_101em)||(bbi==SPR_102em)||(bbi==SPR_103em)||(bbi==SPR_104em)||
+ (bbi==SPR_111em)||(bbi==SPR_112em)||(bbi==SPR_113em)||(bbi==SPR_114em))
+ {
+ return 1;
+ }
+
+ return 0;
+}
+
+#ifdef _TYPE_TOXICATION
+BOOL CHAR_CanCureFlg( int charaindex, char *arg)
+{
+ int fd = getfdFromCharaIndex( charaindex );
+ if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ) return TRUE;
+ if( getToxication( fd) == 1 ){
+ if( strstr( arg, "FALSE") == 0 ) {
+ char buf[256];
+ sprintf( buf,"ж%s", arg);
+ CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW);
+ }
+ return FALSE;
+ }
+ return TRUE;
+}
+#endif
+
+INLINE int CHAR_AddMaxExp( int charaindex, int addexp)
+{
+ int Myexp = CHAR_getInt( charaindex, CHAR_EXP);
+ Myexp = min( Myexp + addexp, 1224160000 );
+ CHAR_setInt( charaindex, CHAR_EXP, Myexp );
+ return addexp;
+}
+
+INLINE int CHAR_setMaxExpFromLevel( int charaindex, int level)
+{
+#ifdef _NEWOPEN_MAXEXP
+ CHAR_setInt( charaindex, CHAR_EXP, 0);
+ return 0;
+#else
+ int LVexp;
+ if( (LVexp = CHAR_GetLevelExp( charaindex, level+1)) < 0 )return -1;
+ CHAR_setInt( charaindex, CHAR_EXP, LVexp);
+ return LVexp;
+#endif
+}
+
+INLINE int CHAR_setMaxExp( int charaindex, unsigned long int Setexp)
+{
+ if( !CHAR_CHECKINDEX( charaindex) ) return -1;
+ CHAR_setInt( charaindex, CHAR_EXP, Setexp);
+ return Setexp;
+}
+#ifdef _NEWOPEN_MAXEXP
+INLINE int CHAR_ChangeExp( int charaindex )
+{
+ int level, defexp, Myexp;
+ if( !CHAR_CHECKINDEX( charaindex) ) return -1;
+
+ level = CHAR_getInt( charaindex, CHAR_LV);
+ if( (defexp = CHAR_GetOldLevelExp( level)) < 0 ) return -1;
+ Myexp = CHAR_getInt( charaindex, CHAR_OLDEXP);
+
+ if( Myexp > 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)) == -1 ) return -1;
+ Myexp = Myexp - needexp;
+ if ( Myexp > 0){
+ CHAR_earnFame(charaindex, needexp / 20000);
+ }
+ if( Myexp < 0 ) Myexp = 0;
+ CHAR_setInt( charaindex, CHAR_EXP, Myexp);
+ return Myexp;
+}
+#endif
+
+INLINE int _CHAR_AddPileItem( char *file, int line, int charaindex, int itemindex)
+{
+#ifdef _ITEM_PILENUMS
+ int itempile , mypile, surplus, ret=-1;
+
+ surplus = CHAR_findSurplusItemBox( charaindex);
+ itempile = ITEM_getInt( itemindex, ITEM_USEPILENUMS);
+ mypile = CHAR_getMyMaxPilenum( charaindex);
+
+ if( itempile > (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);
+ switch(trans){
+ case 0:
+ MaxGold = 1000000;
+ break;
+ case 1:
+ MaxGold = 2000000;
+ break;
+ case 2:
+ MaxGold = 5000000;
+ break;
+ case 3:
+ MaxGold = 10000000;
+ break;
+ case 4:
+ MaxGold = 50000000;
+ break;
+ default:
+ MaxGold = 100000000;
+ break;
+ }
+#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 == "\0" )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 "\0";
+ }
+ }
+ 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,%d\n", __FILE__, __LINE__,file, line,index);
+ 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 == "\0" )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 "\0";
+ }
+ }
+ 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 _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
+
+#ifdef _RIDE_CF
+int CHAR_Ride_CF_init()
+{
+ FILE* fp;
+ int i=0;
+ fp = fopen("data/ride.txt", "r");
+ if (fp == NULL)
+ {
+ print("ļ\n");
+ return FALSE;
+ }
+ BOOL ride=FALSE;
+ while(1){
+ char line[1024], buf[16];
+ if (fgets(line, sizeof(line), fp) == NULL)break;
+ chop(line);
+ if(line[0]=='#')continue;
+ getStringFromIndexWithDelim(line,",", 1, buf, sizeof(buf));
+ if(!strcmp(buf, " ")){
+ for(i=0;i= 0 ) {
+// printf("ti:%d\n",ti);
+ if( (index = RIDEPET_getNOindex( playerNo)) >= 0 ){
+// printf("index:%d\n",index);
+ if( (image = RIDEPET_getRIDEno( index,ti)) >= 0 ){
+// printf("image:%d\n",image);
+ CHAR_setInt( meindex , CHAR_BASEIMAGENUMBER , image );
+ }
+ }
+ }
+
+ if(image!=-1){
+ CHAR_setInt( meindex , CHAR_RIDEPET, pet );
+ CHAR_complianceParameter( meindex );
+ CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX ));
+ CHAR_send_P_StatusString( meindex, CHAR_P_STRING_RIDEPET );
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+#endif
+
+#ifdef _SAFE_PASSWORD
+void CHAR_SafePassword(int charaindex)
+{
+ int fd = getfdFromCharaIndex( charaindex);
+ if(CHAR_getInt(charaindex,CHAR_LOCK)==2){
+ lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT,
+ WINDOW_BUTTONTYPE_OKCANCEL,
+ CHAR_WINDOWTYPE_SAFE_PASSWORD1,
+ -1,
+ " ʾ˺źƣ\nϵͳΪ˺ŰȫԶ\n뾡룡\n\nİȫ룬ȷɽ");
+ }else if(CHAR_getInt(charaindex,CHAR_LOCK)==3){
+ lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT,
+ WINDOW_BUTTONTYPE_OKCANCEL,
+ CHAR_WINDOWTYPE_SAFE_PASSWORD3,
+ -1,
+ "ʾε¼ַһ\nΪİȫǣϵͳȫԶ\n\nİȫ룬ɹý");
+ }else if( CHAR_getWorkInt( charaindex, CHAR_WORKSAFEMODE)==0)
+ {
+ lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT,
+ WINDOW_BUTTONTYPE_OKCANCEL,
+ CHAR_WINDOWTYPE_SAFE_PASSWORD1,
+ -1,
+ "İȫ룬ȷɽ");
+ }
+}
+
+void CHAR_AddSafePassword(int charaindex)
+{
+ int fd = getfdFromCharaIndex( charaindex);
+ if( CHAR_getWorkInt( charaindex, CHAR_WORKSAFEMODE)==0)
+ {
+ lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT,
+ WINDOW_BUTTONTYPE_OKCANCEL,
+ CHAR_WINDOWTYPE_SAFE_PASSWORD2,
+ -1,
+ "Ҫõİȫ룬ʹ6-32λ6λּĸлл");
+ }
+}
+
+void CHAR_UnSafePassword(int charaindex)
+{
+ int fd = getfdFromCharaIndex( charaindex);
+ if( CHAR_getWorkInt( charaindex, CHAR_WORKSAFEMODE)==0)
+ {
+ lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGEANDLINEINPUT,
+ WINDOW_BUTTONTYPE_OKCANCEL,
+ CHAR_WINDOWTYPE_SAFE_PASSWORD3,
+ -1,
+ "İȫ룬ȷý");
+ }else{
+ CHAR_setInt(charaindex,CHAR_LOCK,1);
+ CHAR_talkToCli( charaindex, -1, "ϵͳɹý", CHAR_COLORRED);
+ }
+}
+#endif
+
+char *replace_s(char *str, char *str1, char *str2, char *strretu)
+{
+ char *str_temp = str;
+ char *str1_temp = str1;
+ char *str2_temp = str2;
+ char *strretu_temp = NULL;
+
+ unsigned long char_size = (unsigned long)sizeof(char);
+ /*ַ*/
+ unsigned long i,j,rep_acc = 0;
+ unsigned long str_len = strlen(str);
+ unsigned long str1_len = strlen(str1)-1;
+ unsigned long str2_len = strlen(str2);
+
+ /*ҳStrмطҪ滻*/
+ for(; str_temp - str < str_len; )
+ {
+ for(i = 0; i < str1_len; i++)
+ {
+ if(*str_temp++ != *str1_temp++)
+ {
+ str1_temp = str1;
+ break;
+ }
+ else
+ {
+ if(i == str1_len - 1)
+ {
+ str1_temp = str1;
+ rep_acc++;
+ }
+ }
+ }
+ }
+ str1_temp = str1;
+ str_temp = str;
+
+ /*ڴ*/
+ strretu = strretu_temp = malloc(((str_len - str1_len * rep_acc) + str2_len * rep_acc + 1) * char_size);
+ /*滻*/
+ for(; str_temp - str < str_len; )
+ {
+
+ for(i = 0; i < str1_len; i++)
+ {
+ *strretu_temp++ = *str_temp;
+
+ if(*str_temp++ != *str1_temp++)
+ {
+ str1_temp = str1;
+ break;
+ }
+ else
+ {
+
+ if(i == str1_len - 1)
+ {
+ strretu_temp = strretu_temp - str1_len;
+
+ for(i = 0; i < str2_len; i++)
+ {
+ *strretu_temp++ = *str2_temp++;
+ }
+ str2_temp = str2;
+ str1_temp = str1;
+ }
+ }
+ }
+ }
+ *strretu_temp = '\0';
+ str1_temp = str1;
+ str_temp = str;
+ str2_temp = str2;
+
+ return(strretu);
+}
+
+char *str_ganrao(char *oldstr)
+{
+ char* newrandquestion = NULL;
+ newrandquestion = strstr(oldstr,"[");
+ if(newrandquestion!=NULL){
+ char *newrandquestion2 = NULL;
+ char *newrandquestion5 = NULL;
+ char newrandquestion3[64],newrandquestion4[64];
+ memset(newrandquestion3, 0, sizeof(newrandquestion3));
+ memset(newrandquestion4, 0, sizeof(newrandquestion4));
+ int qnum1,qnum2;
+ newrandquestion2 = strstr(oldstr,"]");
+ qnum1 = strlen(newrandquestion);
+ qnum2 = strlen(newrandquestion2);
+ int qi;
+ for(qi=1;qi25){
+ if(qi==0){
+ sprintf(newrandquestion4,"%s%c",grbuff[RAND(1,100)-1],newrandquestion3[qi]);
+ }
+ else{
+ sprintf(newrandquestion4,"%s%s%c",newrandquestion4,grbuff[RAND(1,100)-1],newrandquestion3[qi]);
+ }
+ }
+ }
+ sprintf(newrandquestion4,"%s%s",newrandquestion4,grbuff[RAND(1,100)-1]);
+ newrandquestion5 = replace_s(oldstr,newrandquestion3,newrandquestion4,newrandquestion5);
+ char kbuf1[7][5] = {"","","","","","",""};
+ char kbuf2[7][5] = {"","","","","","",""};
+ char *newrandquestion6 = NULL;
+ char *newrandquestion7 = NULL;
+ int krandnum = RAND(1,7);
+ char houmsg[64];
+ memset(houmsg, 0, sizeof(houmsg));
+ sprintf(houmsg,"%s%s",grbuff[RAND(1,100)-1],kbuf2[krandnum-1]);
+ newrandquestion6 = replace_s(newrandquestion5,"[\O",kbuf1[krandnum-1],newrandquestion6);
+ newrandquestion7 = replace_s(newrandquestion6,"]\O",houmsg,newrandquestion7);
+ return newrandquestion7;
+ }
+ return oldstr;
+}
+
+char *str_ganraoan(char *oldstr)
+{
+ char* newrandquestion = NULL;
+ newrandquestion = strstr(oldstr,"[");
+ if(newrandquestion!=NULL){
+ char *newrandquestion2 = NULL;
+ char *newrandquestion5 = NULL;
+ char newrandquestion3[64],newrandquestion4[64];
+ memset(newrandquestion3, 0, sizeof(newrandquestion3));
+ memset(newrandquestion4, 0, sizeof(newrandquestion4));
+ int qnum1,qnum2;
+ newrandquestion2 = strstr(oldstr,"]");
+ qnum1 = strlen(newrandquestion);
+ qnum2 = strlen(newrandquestion2);
+ int qi;
+ for(qi=1;qi25){
+ if(qi==0){
+ sprintf(newrandquestion4,"%s%c",grbuff[RAND(1,60)-1],newrandquestion3[qi]);
+ }
+ else{
+ sprintf(newrandquestion4,"%s %c",newrandquestion4,newrandquestion3[qi]);
+ }
+ }
+ }
+ sprintf(newrandquestion4,"%s ",newrandquestion4);
+ newrandquestion5 = replace_s(oldstr,newrandquestion3,newrandquestion4,newrandquestion5);
+ char kbuf1[7][5] = {"","","","","","",""};
+ char kbuf2[7][5] = {"","","","","","",""};
+ char *newrandquestion6 = NULL;
+ char *newrandquestion7 = NULL;
+ int krandnum = RAND(1,7);
+ char houmsg[64];
+ memset(houmsg, 0, sizeof(houmsg));
+ sprintf(houmsg,"%s]",grbuff[RAND(1,60)-1]);
+ newrandquestion6 = replace_s(newrandquestion5,"[\O","[",newrandquestion6);
+ newrandquestion7 = replace_s(newrandquestion6,"]\O",houmsg,newrandquestion7);
+ return newrandquestion7;
+ }
+ return oldstr;
+}
+
+char *str_hanzi_ganrao(char *tmpbuff1,char *tmpbuff2,char *tmpbuff3,char *tmpbuff4,int flg,int rand1,int rand2,int rand3,int rand4,int rand5)
+{
+ char newstr[128];
+ memset(newstr, 0, sizeof(newstr));
+ char grbuff[100][5] = {".","","","","","`","","","p","-","","*","^","~","","","","","","","","","","","",",",",",",",",",",",",",",",",",",",",",
+ "","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",
+ " "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," ","","","","",""};
+ char kbuf1[7][5] = {"","","","","","",""};
+ char kbuf2[7][5] = {"","","","","","",""};
+ if(flg==0){
+ int kuangnum = RAND(1,7)-1;
+ sprintf(newstr,"%s%s%s%s%s%s%s%s%s%s%s",kbuf1[kuangnum],grbuff[RAND(1,100)-1],tmpbuff1,grbuff[RAND(1,100)-1],tmpbuff2,grbuff[RAND(1,100)-1],tmpbuff3,grbuff[RAND(1,100)-1],tmpbuff4,grbuff[RAND(1,100)-1],kbuf2[kuangnum]);
+ }else{
+ sprintf(newstr,"%s%s%s%s%s%s%s%s%s%s%s",kbuf1[3],grbuff[rand1],tmpbuff1,grbuff[rand2],tmpbuff2,grbuff[rand3],tmpbuff3,grbuff[rand4],tmpbuff4,grbuff[rand5],kbuf2[3]);
+ }
+ return newstr;
+}
+
+#ifdef _CAX_LNS_CHARSUOXU
+int CHAR_getEmptyPetBoxNum(int charaindex)
+{
+ if( !CHAR_CHECKINDEX(charaindex))
+ return -1;
+
+ int i = 0 ;
+ int EmptyNum = 0;
+
+ for( ; 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 "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;
+
+ 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 );
+
+#ifdef DEBUG
+ {
+ int i;
+ for( i=0; i 3 ) {
+ return FALSE;
+ }
+ index=hometown;
+
+ 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];
+
+ point = point | (1<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()){
+ if(level>CHAR_getInt(charaindex, CHAR_LIMITLEVEL))
+ return -1;
+ }else if(level>getYBLevel()){
+ if ((CHAR_getInt(charaindex, CHAR_WHICHTYPE)==CHAR_TYPEPET || CHAR_getInt( charaindex, CHAR_FUSIONBEIT ) == 1)) {
+ if(getPettrans() != -1 ){
+ if(CHAR_getInt(charaindex,CHAR_TRANSMIGRATION)>=getPettrans())
+ return getNeedLevelUpTbls(level);
+ }else{
+ if(level<=CHAR_getInt(charaindex, CHAR_LIMITLEVEL))
+ return getNeedLevelUpTbls(level);
+ }
+ return -1;
+ }
+#ifdef _PLAYER_NPC
+ else if (CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYERNPC
+ || CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYERPETNPC){
+ return -1;
+ }
+#endif
+ else{
+ 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 ||
+ CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYERNPC ||
+ CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYERPETNPC) {
+
+ 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
+#ifdef _PET_3TRANS
+ || CHAR_getInt( charaindex, CHAR_PETID) == getMMPETID2()
+#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 ){
+#ifdef _DP_140_160_MODE
+ if(getNewDpMode()==1){
+ if(level+1==140)
+ CHAR_setInt( charaindex, CHAR_DUELPOINT,CHAR_getInt( charaindex, CHAR_DUELPOINT)+100000 );
+ else if(level+1==160)
+ CHAR_setInt( charaindex, CHAR_DUELPOINT,CHAR_getInt( charaindex, CHAR_DUELPOINT)+1000000 );
+ }else{
+ CHAR_setInt( charaindex, CHAR_DUELPOINT,
+ CHAR_getInt( charaindex, CHAR_DUELPOINT) + (level+1)*10 );
+ }
+#else
+ CHAR_setInt( charaindex, CHAR_DUELPOINT,
+ CHAR_getInt( charaindex, CHAR_DUELPOINT) + (level+1)*10 );
+#endif
+ }
+#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
+#ifdef _PET_3TRANS
+ || CHAR_getInt( petindex, CHAR_PETID) == getMMPETID2()
+#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 &&
+ CHAR_getInt( petindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYERNPC &&
+ CHAR_getInt( petindex, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYERPETNPC)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;
+ 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
+ if ( exp1 - exp2 > 0 && CHAR_getWorkInt(petindex,CHAR_WORKJILU)==0){
+ int feedpoint;
+ // CoolFish: 2001/10/03
+ int fd = getfdFromCharaIndex(ownerindex);
+#ifdef _PERSONAL_FAME // Arminius 8.30:
+#ifdef _PETUP_GET_EXP
+ if(getPetUpGetExp()==1){
+ if(level>=131){
+ int myfame = (20+(level-131)*5)*100;
+ if(level==138) myfame = 6000;
+ else if(level==139) myfame = 9000;
+ else if(level==140) myfame = 16000;
+ CHAR_earnFame(ownerindex, myfame);
+ sprintf(tmpbuf, "%d", myfame);
+ }else if(level<=130 && level>=126){
+ CHAR_earnFame(ownerindex, exp2 / 30000);
+ sprintf(tmpbuf, "%d", exp2 / 30000);
+ }else{
+ CHAR_earnFame(ownerindex, exp2 / 60000);
+ sprintf(tmpbuf, "%d", exp2 / 60000);
+ }
+ }else if(getPetUpGetExp()==0){
+ CHAR_earnFame(ownerindex, exp2 / 20000);
+ sprintf(tmpbuf, "%d", exp2 / 20000);
+ }else{
+ CHAR_earnFame(ownerindex, 0); //
+ sprintf(tmpbuf, "%d", 0); //
+ }
+#else
+ CHAR_earnFame(ownerindex, exp2 / 20000);
+ sprintf(tmpbuf, "%d", exp2 / 20000);
+#endif
+#endif
+#ifdef _PETUP_GET_EXP
+ if(getPetUpGetExp()==1){
+ if(level>=131){
+ int myfame = (20+(level-131)*5)*100;
+ if(level==138) myfame = 6000;
+ else if(level==139) myfame = 9000;
+ else if(level==140) myfame = 16000;
+ feedpoint = myfame;
+ }else if(level<=130 && level>=126){
+ feedpoint=exp2 / 30000;
+ }else{
+ feedpoint=exp2 / 60000;
+ }
+ }else if(getPetUpGetExp()==0){
+ feedpoint=exp2 / 20000;
+ }else{
+ feedpoint=0;
+ }
+#else
+ feedpoint=exp2 / 20000;
+#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 _ATTESTAION_ID == 1
+ if( LV > 130 ) LV = 130;
+#else
+ if( LV > 140 ) LV = 140;
+#endif
+ 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
+#ifdef _PET_TRANS_ABILITY
+ if( tran == 0 ){
+ if( ans > getPetTransAbility1() )
+ ans = getPetTransAbility1();
+ }
+ else
+#ifdef _PET_3TRANS
+ if( tran == 1 )
+#endif
+ {
+ if( ans > getPetTransAbility2() )
+ ans = getPetTransAbility2() ;
+ }
+#ifdef _PET_3TRANS
+ else{
+ if( ans > getPetTransAbility3() )
+ ans = getPetTransAbility3();
+ }
+#endif
+#else
+ if( tran == 0 ){
+ if( ans > 150 )
+ ans = 150;
+ }
+ else{
+ if( ans > 200 )
+ ans = 200;
+ }
+#endif
+#else
+ if( ans > 150 ) {
+ ans = 150;
+ }
+#endif
+ 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=100700 && oldMetamo<100819){
+ int newMetamo;
+ int hbMetamo[]={
+ 100000,100010,100025,100035,100055,100045,
+ 100060,100070,100095,100090,100100,100110,
+ 100135,100125,100145,100150,100165,100160,
+ 100190,100185,100200,100210,100230,100220,
+ };
+ newMetamo=hbMetamo[(oldMetamo-100700)/5];
+ CHAR_setInt( charaindex , CHAR_BASEIMAGENUMBER , newMetamo );
+ CHAR_setInt( charaindex , CHAR_BASEBASEIMAGENUMBER , newMetamo );
+ CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex , CHAR_WORKOBJINDEX ));
+ CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_BASEBASEIMAGENUMBER);
+ CHAR_complianceParameter( charaindex );
+ }
+}
+#endif
+
+#ifdef _NEW_PLAYER_RIDE
+void CHAR_PlayerRide( int charaindex )
+{
+ int i,j;
+ int MetamoList[5][13]={
+ /*{ С к Ƥ С Ƥ ñ ̷ Ů }, Ϊ˵ */
+ { 100000, 100025, 100055, 100060, 100095, 100100, 100135, 100145, 100165, 100190, 100200, 100230, 309}, //
+ { 100005, 100030, 100050, 100065, 100085, 100115, 100120, 100140, 100170, 100195, 100210, 100225, 307}, //
+ { 100010, 100035, 100045, 100070, 100090, 100110, 100125, 100150, 100160, 100185, 100215, 100220, 310}, //
+ { 100015, 100020, 100040, 100075, 100080, 100105, 100130, 100155, 100175, 100180, 100205, 100235, 308}, //
+ { 331 , 483 , 330 , 332 , 483 , 332 , 333 , 333 , 331 , 330 , 332 , 483 , 0 }, //
+ };
+ for(i=0;i<4;i++)
+ for(j=0;j<12;j++)
+ if(CHAR_getInt( charaindex, CHAR_BASEIMAGENUMBER) == MetamoList[i][j]){
+ if(strstr( getPlayerRide(), "ͻ")){
+ setNewplayergivepet(3,MetamoList[i][12]);
+ setNewplayergivepet(4,MetamoList[4][j]);
+ }else if(strstr( getPlayerRide(), "")){
+ setNewplayergivepet(4,MetamoList[4][j]);
+ }else if(strstr( getPlayerRide(), "ͻ")){
+ setNewplayergivepet(4,MetamoList[i][12]);
+ }
+ break;
+ }
+}
+#endif
diff --git a/char/char_event.c b/char/char_event.c
new file mode 100644
index 0000000..7a15e66
--- /dev/null
+++ b/char/char_event.c
@@ -0,0 +1,564 @@
+#include "version.h"
+#include
+
+#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/char/char_item.c b/char/char_item.c
new file mode 100644
index 0000000..1964a9f
--- /dev/null
+++ b/char/char_item.c
@@ -0,0 +1,2774 @@
+#include "version.h"
+#include
+
+#include "configfile.h"
+#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 _ALLBLUES_LUA
+#include "mylua/function.h"
+#endif
+#ifdef _ANGEL_SUMMON
+extern struct MissionInfo missionlist[MAXMISSION];
+extern struct MissionTable missiontable[MAXMISSIONTABLE];
+#endif
+
+extern int itemLine;
+
+#ifdef _DROPSTAKENEW
+#define CASINOTOKENID 20121 // ֳȯ
+#define MAXCASINOMAPNUM 150 // ֳͼ
+#define MAXACCUMULATION 1000000 //
+typedef struct tagCasinoMapTable
+{
+ int casinofl; // ֳͼ
+ int casinox; // ֳ
+ int casinoy; // ֳ
+ 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, "ٳ", 2, 0},
+ { 7005, 23, 21, PET_RACE1, 1, "ٳ", 2, 0},
+ { 7005, 24, 21, PET_RACE1, 1, "ٳ", 2, 0},
+ { 7005, 25, 21, PET_RACE1, 1, "ٳ", 2, 0},
+ { 7005, 26, 21, PET_RACE1, 1, "ٳ", 2, 0},
+ { 7005, 27, 21, PET_RACE1, 1, "ٳ", 2, 0},
+ { 7005, 28, 21, PET_RACE1, 1, "ٳ", 2, 0},
+ { 7005, 22, 24, PET_RACE2, 1, "ٳ", 2, 0},
+ { 7005, 23, 24, PET_RACE2, 1, "ٳ", 2, 0},
+ { 7005, 24, 24, PET_RACE2, 1, "ٳ", 2, 0},
+ { 7005, 25, 24, PET_RACE2, 1, "ٳ", 2, 0},
+ { 7005, 26, 24, PET_RACE2, 1, "ٳ", 2, 0},
+ { 7005, 27, 24, PET_RACE2, 1, "ٳ", 2, 0},
+ { 7005, 28, 24, PET_RACE2, 1, "ٳ", 2, 0},
+ { 7005, 22, 27, PET_RACE3, 1, "ٳ", 2, 0},
+ { 7005, 23, 27, PET_RACE3, 1, "ٳ", 2, 0},
+ { 7005, 24, 27, PET_RACE3, 1, "ٳ", 2, 0},
+ { 7005, 25, 27, PET_RACE3, 1, "ٳ", 2, 0},
+ { 7005, 26, 27, PET_RACE3, 1, "ٳ", 2, 0},
+ { 7005, 27, 27, PET_RACE3, 1, "ٳ", 2, 0},
+ { 7005, 28, 27, PET_RACE3, 1, "ٳ", 2, 0},
+
+ { 7003, 21, 15, ROULETTE1, 1, "̺죱", 1, 0}, { 7003, 17, 15, ROULETTE3, 1, "̺죳", 1, 0},
+ { 7003, 13, 15, ROULETTE5, 1, "̺죵", 1, 0}, { 7003, 21, 21, ROULETTE6, 1, "̺죶", 1, 0},
+ { 7003, 17, 21, ROULETTE8, 1, "̺죸", 1, 0}, { 7003, 15, 21, ROULETTE9, 1, "̺죹", 1, 0},
+ { 7003, 13, 21, ROULETTE10, 1, "̺죱", 1, 0}, { 7003, 13, 18, ROULETTE13, 1, "̺죱", 1, 0},
+ { 7003, 9, 21, ROULETTE17, 1, "̺죱", 1, 0}, { 7003, 21, 18, ROULETTE18, 1, "̺죱", 1, 0},
+
+ { 7003, 19, 15, ROULETTE22, 1, "̣", 1, 0}, { 7003, 15, 15, ROULETTE24, 1, "̣", 1, 0},
+ { 7003, 19, 21, ROULETTE27, 1, "̣", 1, 0}, { 7003, 11, 15, ROULETTE31, 1, "̣", 1, 0},
+ { 7003, 9, 15, ROULETTE32, 1, "̣", 1, 0}, { 7003, 11, 18, ROULETTE34, 1, "̣", 1, 0},
+ { 7003, 9, 18, ROULETTE35, 1, "̣", 1, 0}, { 7003, 11, 21, ROULETTE36, 1, "̣", 1, 0},
+ { 7003, 19, 18, ROULETTE39, 1, "̣", 1, 0}, { 7003, 17, 18, ROULETTE40, 1, "̣", 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, 0},
+ { 7003, 18, 15, (ROULETTE3<<16)+ROULETTE22, 1, "˫ź죳̣", 1, 0},
+ { 7003, 16, 15, (ROULETTE3<<16)+ROULETTE24, 1, "˫ź죳̣", 1, 0},
+ { 7003, 14, 15, (ROULETTE5<<16)+ROULETTE24, 1, "˫ź죵̣", 1, 0},
+ { 7003, 12, 15, (ROULETTE5<<16)+ROULETTE31, 1, "˫ź죵̣", 1, 0},
+ { 7003, 10, 15, (ROULETTE32<<16)+ROULETTE31, 1, "˫̣̣", 1, 0},
+
+ { 7003, 20, 18, (ROULETTE18<<16)+ROULETTE39, 1, "˫ź죱̣", 1, 0},
+ { 7003, 18, 18, (ROULETTE40<<16)+ROULETTE39, 1, "˫̣̣", 1, 0},
+ { 7003, 16, 18, (ROULETTE40<<16)+ROULETTE45, 1, "˫̣ڣ", 1, 0},
+ { 7003, 14, 18, (ROULETTE13<<16)+ROULETTE45, 1, "˫ź죱ڣ", 1, 0},
+ { 7003, 12, 18, (ROULETTE13<<16)+ROULETTE34, 1, "˫ź죱̣", 1, 0},
+ { 7003, 10, 18, (ROULETTE35<<16)+ROULETTE34, 1, "˫̣̣", 1, 0},
+
+ { 7003, 20, 21, (ROULETTE6<<16) +ROULETTE27, 1, "˫ź죶̣", 1, 0},
+ { 7003, 18, 21, (ROULETTE8<<16) +ROULETTE27, 1, "˫ź죸̣", 1, 0},
+ { 7003, 16, 21, (ROULETTE8<<16) + ROULETTE9, 1, "˫ź죸죹", 1, 0},
+ { 7003, 14, 21, (ROULETTE10<<16)+ ROULETTE9, 1, "˫ź죱죹", 1, 0},
+ { 7003, 12, 21, (ROULETTE10<<16)+ROULETTE36, 1, "˫ź죱̣", 1, 0},
+ { 7003, 10, 21, (ROULETTE17<<16)+ROULETTE36, 1, "˫ź죱̣", 1, 0},
+ { 7003, 8, 15, ROULETTE51, 1, "У", 1, 0}, //
+ { 7003, 8, 18, ROULETTE52, 1, "У", 1, 0},
+ { 7003, 8, 21, ROULETTE53, 1, "У", 1, 0},
+ { 7003, 6, 15, ROULETTE61, 1, "룱", 1, 0}, //110
+ { 7003, 5, 15, ROULETTE61, 1, "룱", 1, 0},
+ { 7003, 6, 16, ROULETTE61, 1, "룱", 1, 0},
+ { 7003, 5, 16, ROULETTE61, 1, "룱", 1, 0},
+ { 7003, 24, 15, ROULETTE62, 1, "룱", 1, 0}, //1011
+ { 7003, 23, 15, ROULETTE62, 1, "룱", 1, 0},
+ { 7003, 24, 16, ROULETTE62, 1, "룱", 1, 0},
+ { 7003, 23, 16, ROULETTE62, 1, "룱", 1, 0},
+ { 7003, 15, 18, ROULETTE45, 1, "()", 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;
+ if( !CHAR_CHECKITEMINDEX( charaindex, itemgroup[i])) {
+ continue;
+ }
+ itemindex = CHAR_getItemIndex( charaindex, itemgroup[i] );
+ if( itemindex >= 0 ) {
+ snprintf( token ,sizeof(token),"%d|%s|" ,itemgroup[i], ITEM_makeItemStatusString( -1,itemindex ) );
+ if(ITEM_getInt( itemindex, ITEM_CANBEPILE)!=1 && ITEM_getInt( itemindex, ITEM_USEPILENUMS)>1)
+ {
+ CHAR_setItemIndex( charaindex , itemgroup[i], -1);
+ snprintf( token ,sizeof(token),"%s|" , ITEM_makeItemFalseStringWithNum( itemgroup[i]) );
+ }
+ }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
+#ifdef _ITEM_RIDE
+ if(CHAR_getInt( charaindex , CHAR_RIDEPET ) != -1 ){
+ if( !strcmp( ITEM_getChar( itemid, ITEM_USEFUNC), "ITEM_RIDE") ) {
+ char ridemetamo[12];
+ char *itemarg = ITEM_getChar( itemid, ITEM_ARGUMENT);
+ getStringFromIndexWithDelim( itemarg, "|", 2, ridemetamo, sizeof(ridemetamo));
+ if(CHAR_getInt( charaindex , CHAR_BASEIMAGENUMBER )==atoi(ridemetamo)){
+ CHAR_setInt( charaindex , CHAR_RIDEPET, -1 );
+ CHAR_setInt( charaindex , CHAR_BASEIMAGENUMBER , CHAR_getInt( charaindex , CHAR_BASEBASEIMAGENUMBER) );
+ CHAR_complianceParameter( charaindex );
+ CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX ));
+ CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_RIDEPET);
+ }
+ }
+ }
+#endif
+ {
+ typedef void (*DETACHFUNC)(int,int);
+ DETACHFUNC def;
+ def=(DETACHFUNC)ITEM_getFunctionPointer(itemid,ITEM_DETACHFUNC);
+ if( def ) {
+ def( charaindex,itemid );
+ }
+#ifdef _ALLBLUES_LUA_1_2
+ else{
+ RunItemDetachEvent(charaindex,itemid );
+ }
+#endif
+ }
+}
+
+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 );
+ }
+#ifdef _ALLBLUES_LUA_1_2
+ else{
+ RunItemAttachEvent(charaindex, itemid );
+ }
+#endif
+ }
+}
+
+
+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){ //DZС
+
+ 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 );
+ }
+ CHAR_sendItemAttachEvent( index, fromid );
+ CHAR_sendSIToCli( index, fromindex,toindex );
+ }else {
+ CANNOTEQUIP;
+ return FALSE;
+ }
+ 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);
+ return TRUE;
+ }
+
+ return CHAR_moveItemFromItemBoxToEquip(index, toindex,fromindex);
+}
+
+#ifdef _ITEM_PILENUMS
+int CHAR_getMyMaxPilenum( int charaindex)
+{
+ int maxpile;
+ int transnum = CHAR_getInt( charaindex, CHAR_TRANSMIGRATION);
+ if(CHAR_getInt(charaindex,CHAR_VIPRIDE)>1)
+ {
+ maxpile=100;
+ }
+ else
+ {
+ if(transnum <= 5)
+ {
+ maxpile = transnum
+ + (transnum/5) * 2 + 3;
+ }
+ else if(transnum > 5)
+ {
+ maxpile = 50;
+ }
+ }
+
+/*
+#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);
+#ifdef _ITEM_RESET
+ char *itemarg = NULL;
+ itemarg = ITEM_getChar(fromid,ITEM_ARGUMENT);
+ if(strlen(itemarg)>0){
+ int itemid;
+ int playfd = getfdFromCharaIndex(index);
+ if(strcmp(itemarg,"ITEMRESET")==0){
+ itemid = ITEM_getInt(toid,ITEM_ID);
+ int resetpoint = sasql_itemreset_query(itemid);
+ if(resetpoint>=0){
+ char resetmsg[256];
+ sprintf(resetmsg,"\nȷҪԭ%sô\n\nԭƷҪ%d\n\nȷĻOK\n",ITEM_getChar(toid,ITEM_NAME),resetpoint);
+ lssproto_WN_send( playfd, WINDOW_MESSAGETYPE_MESSAGE,
+ WINDOW_BUTTONTYPE_OKCANCEL,
+ CHAR_WINDOWTYPE_RESETITEM,
+ -1,
+ resetmsg);
+ CHAR_setWorkInt(index,CHAR_WORKFROMITEMINDEX,fromindex);
+ CHAR_setWorkInt(index,CHAR_WORKTOITEMINDEX,toindex);
+ return FALSE;
+ }else{
+ if(itemid>=0){
+ lssproto_WN_send( playfd, WINDOW_MESSAGETYPE_MESSAGE,
+ WINDOW_BUTTONTYPE_CANCEL,
+ -1,
+ -1,
+ "˵߲ܻԭ");
+ }
+ }
+ }else if(strcmp(itemarg,"ITEMDEL")==0){
+ itemid = ITEM_getInt(toid,ITEM_ID);
+ int resetpoint = sasql_itemdel_query(itemid);
+ if(resetpoint>=0){
+ char resetmsg[256];
+ sprintf(resetmsg,"\nȷҪա%sô\n\nƷտɵá%d\n\nȷĻOK\n",ITEM_getChar(toid,ITEM_NAME),resetpoint);
+ lssproto_WN_send( playfd, WINDOW_MESSAGETYPE_MESSAGE,
+ WINDOW_BUTTONTYPE_OKCANCEL,
+ CHAR_WINDOWTYPE_DELITEM,
+ -1,
+ resetmsg);
+ CHAR_setWorkInt(index,CHAR_WORKFROMITEMINDEX,fromindex);
+ CHAR_setWorkInt(index,CHAR_WORKTOITEMINDEX,toindex);
+ return FALSE;
+ }else{
+ if(itemid>=0){
+ lssproto_WN_send( playfd, WINDOW_MESSAGETYPE_MESSAGE,
+ WINDOW_BUTTONTYPE_CANCEL,
+ -1,
+ -1,
+ "˵߲ܻգ");
+ }
+ }
+ }
+ }
+#endif
+ 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( !ITEM_CHECKINDEX(itemindex) ){
+// print( "ANDY itemindex=%d err\n", itemindex);
+ return;
+ }
+ int myviptype = CHAR_getInt(charaindex,CHAR_VIPRIDE);
+ if(myviptype==0){
+ if(strstr(ITEM_getChar(itemindex,ITEM_NAME),"[VIP")!=NULL){
+ CHAR_talkToCli( charaindex, -1, "Աȼʹôװ", CHAR_COLORYELLOW );
+ return;
+ }
+ }else if(myviptype==1){
+ if(strstr(ITEM_getChar(itemindex,ITEM_NAME),"[VIP2]")!=NULL || strstr(ITEM_getChar(itemindex,ITEM_NAME),"[VIP3]")!=NULL){
+ CHAR_talkToCli( charaindex, -1, "Աȼʹôװ", CHAR_COLORYELLOW );
+ return;
+ }
+ }else if(myviptype==2){
+ if(strstr(ITEM_getChar(itemindex,ITEM_NAME),"[VIP3]")!=NULL){
+ CHAR_talkToCli( charaindex, -1, "Աȼʹôװ", CHAR_COLORYELLOW );
+ return;
+ }
+ }
+ 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 ), /* ƽҷo */
+ CHAR_getChar( charaindex, CHAR_CDKEY ),
+#ifdef _add_item_log_name // WON ADD itemlogitem
+ 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{
+#ifdef _ALLBLUES_LUA_1_2
+ if(RunItemUseEvent(itemindex, charaindex, to_charaindex, haveitemindex) == FALSE )
+#endif
+{
+ 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;
+ {
+ char tmpbuf[256];
+ sprintf(tmpbuf," %s (ʧʱ%d)",ITEM_getChar( itemindex, ITEM_NAME),getItemdeletetime());
+ CHAR_talkToCli( charaindex, -1, tmpbuf, CHAR_COLORYELLOW );
+ LogItem(
+ CHAR_getChar( charaindex, CHAR_NAME ), /* ƽҷ */
+ CHAR_getChar( charaindex, CHAR_CDKEY ),
+#ifdef _add_item_log_name // WON ADD itemlogitem
+ 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 );
+ }
+}
+#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 itemlogitem
+ 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 )
+{
+ if( CHAR_getWorkInt( charaindex, CHAR_WORKSAFEMODE)==0)
+ {
+ CHAR_SafePassword(charaindex);
+ return;
+ }
+ int itemindex, fl, x, y, ret, objindex, beDropOne = 1;
+
+ if( !CHAR_CHECKINDEX( charaindex ) ) return;
+ int fd = getfdFromCharaIndex( charaindex);
+ if( fd == - 1 ) 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;
+#ifdef _LOCK_PET_ITEM
+ char *arg = ITEM_getChar(itemindex, ITEM_NAME);
+ if(arg[0] == '*'){
+ CHAR_talkToCli( charaindex, -1, "Ʒܶ", CHAR_COLORYELLOW );
+ return;
+ }
+#endif
+#ifdef _NO_DROPITEM
+ if( strstr(ITEM_getChar(itemindex,ITEM_EFFECTSTRING),"")){
+ if(CHAR_getWorkInt(charaindex,CHAR_DROPITEMCHARAINDEX)!=itemcharaindex){
+ char dropmsg[256];
+ sprintf(dropmsg,"\n%sΪƷ\n\nֱʧ\n\nȷҪôȷ밴[OK]\n",ITEM_getChar(itemindex,ITEM_NAME));
+ lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE,
+ WINDOW_BUTTONTYPE_OKCANCEL,
+ CHAR_WINDOWTYPE_DROPITEM,
+ -1,
+ dropmsg);
+ CHAR_setWorkInt(charaindex,CHAR_DROPITEMCHARAINDEX,itemcharaindex);
+ return;
+ }else{
+ CHAR_setWorkInt(charaindex,CHAR_DROPITEMCHARAINDEX,-1);
+ }
+ }
+#endif
+ if(ITEM_getInt(itemindex,ITEM_TIME)>0){
+ if(CHAR_getWorkInt(charaindex,CHAR_DROPITEMCHARAINDEX)!=itemcharaindex){
+ char dropmsg[256];
+ sprintf(dropmsg,"\n%sΪʱƷ\n\nֱʧ\n\nȷҪôȷ밴[OK]\n",ITEM_getChar(itemindex,ITEM_NAME));
+ lssproto_WN_send( fd, WINDOW_MESSAGETYPE_MESSAGE,
+ WINDOW_BUTTONTYPE_OKCANCEL,
+ CHAR_WINDOWTYPE_DROPITEM,
+ -1,
+ dropmsg);
+ CHAR_setWorkInt(charaindex,CHAR_DROPITEMCHARAINDEX,itemcharaindex);
+ return;
+ }else{
+ CHAR_setWorkInt(charaindex,CHAR_DROPITEMCHARAINDEX,-1);
+ }
+ }
+ 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;
+ }
+#ifdef _PETITEM__AMOI_E
+ //print ("\n%d,%d,%d\n",ITEM_NOT_DROP,ITEM_getInt(itemindex, ITEM_TYPEOFITEM),ITEM_NOT_DROP & ITEM_getInt(itemindex, ITEM_TYPEOFITEM));
+ if(ITEM_NOT_DROP & ITEM_getInt(itemindex, ITEM_TYPEOFITEM)){
+ char buf[256];
+ sprintf( buf, "%s", ITEM_getChar( itemindex, ITEM_NAME) );
+ CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORRED);
+ return ;
+ }
+#endif
+ //ҳΧռ
+ 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 || ITEM_getInt(itemindex,ITEM_TIME)>0){ //-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);
+#ifdef _PICKUP_ITEM_OTHER
+ if(getPickupItem()==1){
+ ITEM_setChar(itemindex,ITEM_FROMCDKEY,CHAR_getChar( charaindex, CHAR_CDKEY ));
+ }
+#endif
+ {
+ char tmpbuf[256];
+ sprintf(tmpbuf," %s (ʧʱ%d)",ITEM_getChar( itemindex, ITEM_NAME),getItemdeletetime());
+ CHAR_talkToCli( charaindex, -1, tmpbuf, CHAR_COLORYELLOW );
+ LogItem(
+ CHAR_getChar( charaindex, CHAR_NAME ), /* ƽҷ */
+ CHAR_getChar( charaindex, CHAR_CDKEY ),
+#ifdef _add_item_log_name // WON ADD itemlogitem
+ 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{
+ ;
+ }
+ }
+
+ 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;
+ }
+ }
+ }
+
+ // ˵طIJȯһ
+ 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 itemlogitem
+ 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_WORKOBJINDEX,-1);
+ ITEM_setWorkInt(itemindex, ITEM_WORKCHARAINDEX,charaindex);
+ CHAR_sendItemDataOne( charaindex, emptyindex);
+ }
+ 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 _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){// ˵طIJȯһ
+ 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 itemlogitem
+ 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
+#ifdef _PICKUP_ITEM_OTHER
+ if(getPickupItem()==1){
+ char pickupchar[16];
+ sprintf(pickupchar,",%d,",ITEM_getInt(itemindex,ITEM_ID));
+ if(ITEM_getChar(itemindex,ITEM_FROMCDKEY)!=NULL && strstr(getPickItemId(),pickupchar)==NULL){
+ if(strcmp(CHAR_getChar(charaindex,CHAR_CDKEY),ITEM_getChar(itemindex,ITEM_FROMCDKEY))!=0){
+ CHAR_talkToCli(charaindex, -1, "˵߲Уʰȡ", CHAR_COLORWHITE);
+ 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);
+ }
+#ifdef _ALLBLUES_LUA_1_2
+ else{
+ RunItemPickupEvent(charaindex, itemindex );
+ }
+#endif
+ *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;
+ }
+ }
+#ifdef _PET_UP
+ if( getPetup() != 1 && CHAR_getInt(charaindex,CHAR_FLOOR)!=getPetup() )
+#endif
+ {
+ 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;
+ }
+ }
+ }
+ 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);
+#ifndef _FIX_COPY_MM_BUG
+#ifdef _PET_TALK
+ if( CHAR_getInt( pindex, CHAR_PETID) != 718 ) {
+#endif
+#endif
+ CHAR_setChar( pindex, CHAR_OWNERCDKEY,
+ CHAR_getChar( charaindex, CHAR_CDKEY));
+ CHAR_setChar( pindex, CHAR_OWNERCHARANAME,
+ CHAR_getChar( charaindex, CHAR_NAME));
+#ifndef _FIX_COPY_MM_BUG
+#ifdef _PET_TALK
+ }
+#endif
+#endif
+#ifdef _PET_ITEM
+ CHAR_sendPetItemData( charaindex, havepetindex);
+#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 )
+{
+ if(CHAR_getWorkInt(charaindex,CHAR_WORKSTREETVENDOR) > 0)
+ {
+ return;
+ }
+ 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 itemlogitem
+ 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 )
+{
+ if( CHAR_getWorkInt( charaindex, CHAR_WORKSAFEMODE)==0)
+ {
+ CHAR_SafePassword(charaindex);
+ return;
+ }
+ if(CHAR_getWorkInt(charaindex,CHAR_WORKSTREETVENDOR) > 0)
+ {
+ return;
+ }
+ 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);
+
+#ifndef _FIX_COPY_MM_BUG
+#ifdef _PET_TALK
+ if( CHAR_getInt( petindex, CHAR_PETID) != 718 ) {
+#endif
+#endif
+ CHAR_setChar( petindex, CHAR_OWNERCDKEY, CHAR_getChar( charaindex, CHAR_CDKEY));
+ CHAR_setChar( petindex, CHAR_OWNERCHARANAME, CHAR_getChar( charaindex, CHAR_NAME));
+#ifndef _FIX_COPY_MM_BUG
+#ifdef _PET_TALK
+ }
+#endif
+#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 typetype趨
+// 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
+
+#ifdef _PET_ITEM
+void CHAR_sendPetItemData( int charaindex, int petid)
+{
+ int i;
+ char CHAR_statusSendBuffer[1024];
+ int strlength = 2;
+ int petindex = CHAR_getCharPet( charaindex, petid);
+ int fd = getfdFromCharaIndex( charaindex );
+ snprintf( CHAR_statusSendBuffer ,sizeof(CHAR_statusSendBuffer),"B%d" , petid);
+ for( i = 0 ; i < CHAR_MAXPETITEMHAVE ; i ++ ){
+ char token[512];
+ int itemindex;
+ itemindex = CHAR_getItemIndex( petindex, 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) ) lssproto_S_send(fd, CHAR_statusSendBuffer);
+ }
+ dchop( CHAR_statusSendBuffer , "|" );
+ lssproto_S_send(fd, CHAR_statusSendBuffer);
+}
+
+void CHAR_movePetItem( int charaindex, int petid, int fromindex, int toindex )
+{
+ if( !CHAR_CHECKINDEX( charaindex ) )return;
+ if( CHAR_getFlg( charaindex,CHAR_ISDIE ) )return;
+ int petindex = CHAR_getCharPet( charaindex, petid);
+ char token[512];
+ if(toindex == -1 && fromindex >= CHAR_EQUIPPLACENUM && fromindex < CHAR_MAXITEMHAVE){
+ int itemindex = CHAR_getItemIndex( charaindex, fromindex );
+ toindex=ITEM_getInt( itemindex, ITEM_TYPE)-ITEM_PET_HEAD;
+ }else if(toindex == -2){
+ if(fromindex=0 && toindex< CHAR_MAXPETITEMHAVE){//toindex ǵ
+ //CHAR_talkToCli( charaindex, -1, "װƷ", CHAR_COLORWHITE );
+ //return;
+ INT_petfesion = 28;//
+ }
+ //µģ
+ /*
+ int itemindexi;//
+ itemindexi = CHAR_getItemIndex( charaindex , toindex );//ȡװ
+ if(itemindexi >= 0){
+ CHAR_talkToCli( charaindex, -1, "װƷ", CHAR_COLORWHITE );
+ return;
+ }*/
+
+ }
+ //print("\nINT_petfesion %d = \n", INT_petfesion );
+ allowpetitemtype = ITEM_getChar(itemindex,ITEM_PETEQUITALLOW);//װ
+ forbitpetitemtype= ITEM_getChar(itemindex,ITEM_PETEQUITFORBIT);//װ
+ //print("\allowpetitemtype len %d = \n", arraysizeof(allowpetitemtype) );
+ //print("\forbitpetitemtype len %d = \n", arraysizeof(forbitpetitemtype) );
+ { //װ
+ int tokenNo = 1 ;
+ char tokenBuf[3];
+ BOOL ISCATFLG = FALSE;
+ BOOL UseFisrtTokenFlg = TRUE;
+ BOOL UseSecondTokenFlg = TRUE;
+ BOOL FindFisrtTokenFlg = FALSE;
+
+ tokenNo = 1 ;
+
+ if(!(atoi(allowpetitemtype)== 0 && atoi(forbitpetitemtype)== 0 ) ){
+ while( getStringFromIndexWithDelim(allowpetitemtype," ",tokenNo,tokenBuf,sizeof(tokenBuf))){
+ //print("\n tokenBuf %d = \n",atoi(tokenBuf));
+ if(-1 == atoi(tokenBuf)) {
+ UseFisrtTokenFlg = FALSE;
+ break;
+ }
+ if(INT_petfesion == atoi(tokenBuf)) {
+ FindFisrtTokenFlg = TRUE;
+ break;
+ }
+ tokenNo++;
+ }
+ if(UseFisrtTokenFlg){//ʹ
+ if(!FindFisrtTokenFlg){//ֿʹ
+ //if(!getStringFromIndexWithDelim(allowpetitemtype," ",tokenNo,tokenBuf,sizeof(tokenBuf))){
+ CHAR_talkToCli( charaindex, -1, "װƷ", CHAR_COLORWHITE );
+ return;
+ //}
+ }
+ }else{//ʹų
+ FindFisrtTokenFlg = FALSE;
+ tokenNo = 1;
+ while( getStringFromIndexWithDelim(forbitpetitemtype," ",tokenNo,tokenBuf,sizeof(tokenBuf))){
+ if(-1 == atoi(tokenBuf)) {
+ UseSecondTokenFlg = FALSE;
+ break;
+ }
+ if(INT_petfesion == atoi(tokenBuf)) {
+ FindFisrtTokenFlg = TRUE;
+ break;
+ }
+ tokenNo++;
+ }
+ if(UseSecondTokenFlg){
+ if(FindFisrtTokenFlg){//ֲʹ
+ CHAR_talkToCli( charaindex, -1, "װƷ3", CHAR_COLORWHITE );
+ return;
+ }
+ }
+ }
+ }
+ }
+ }
+#endif
+ if( (fromindex >=0 && fromindex < CHAR_PETITEMNUM && toindex >= CHAR_EQUIPPLACENUM && toindex < CHAR_MAXITEMHAVE)
+ || (toindex >=0 && toindex < CHAR_PETITEMNUM && fromindex >= CHAR_EQUIPPLACENUM && fromindex < CHAR_MAXITEMHAVE)){
+ if(fromindex >= CHAR_EQUIPPLACENUM){
+ int charitemindex = CHAR_getItemIndex( charaindex, fromindex );
+ int petitemindex = CHAR_getItemIndex( petindex, toindex );
+ int type=ITEM_getInt( charitemindex, ITEM_TYPE);
+ if(CHAR_getInt(petindex, CHAR_VARIABLEAI) < 100){
+ CHAR_talkToCli( charaindex, -1, "ѵװƷ", CHAR_COLORRED );
+ return;
+ }
+ if(typeITEM_PET_FEET || (type-ITEM_PET_HEAD) != toindex){
+ CHAR_talkToCli( charaindex, -1, "װƷ", CHAR_COLORWHITE );
+ return;
+ }
+ if( CHAR_getInt( petindex, CHAR_LV) < ITEM_getInt( charitemindex, ITEM_LEVEL)){
+ CHAR_talkToCli( charaindex, -1, "ȼδװƷ", CHAR_COLORYELLOW );
+ return;
+ }
+ if( ITEM_CHECKINDEX( petitemindex)){
+ sprintf( token, "%s ж%s", CHAR_getChar( petindex, CHAR_NAME), ITEM_getChar( petitemindex, ITEM_NAME));
+ CHAR_talkToCli( charaindex, -1, token, CHAR_COLORWHITE );
+ }
+ sprintf( token, "%s װ%s", CHAR_getChar( petindex, CHAR_NAME), ITEM_getChar( charitemindex, ITEM_NAME));
+ CHAR_talkToCli( charaindex, -1, token, CHAR_COLORWHITE );
+ CHAR_setItemIndex( charaindex, fromindex, petitemindex );
+ CHAR_setItemIndex( petindex, toindex, charitemindex );
+ CHAR_sendItemDataOne( charaindex, fromindex);
+ CHAR_sendPetItemData( charaindex, petid);
+ }else{
+ int charitemindex = CHAR_getItemIndex( charaindex, toindex );
+ int petitemindex = CHAR_getItemIndex( petindex, fromindex );
+ int type=ITEM_getInt( charitemindex, ITEM_TYPE);
+ sprintf( token, "%s ж%s", CHAR_getChar( petindex, CHAR_NAME), ITEM_getChar( petitemindex, ITEM_NAME));
+ CHAR_talkToCli( charaindex, -1, token, CHAR_COLORWHITE );
+ if( ITEM_CHECKINDEX( charitemindex)){
+ if(CHAR_getInt(petindex, CHAR_VARIABLEAI) < 100){
+ CHAR_talkToCli( charaindex, -1, "ѵװƷ", CHAR_COLORRED );
+ return;
+ }
+ if(typeITEM_PET_FEET || (type-ITEM_PET_HEAD) != toindex){
+ CHAR_talkToCli( charaindex, -1, "װƷ", CHAR_COLORWHITE );
+ return;
+ }
+ if( CHAR_getInt( petindex, CHAR_LV) < ITEM_getInt( charitemindex, ITEM_LEVEL)){
+ CHAR_talkToCli( charaindex, -1, "ȼδװƷ", CHAR_COLORYELLOW );
+ return;
+ }
+ sprintf( token, "%s װ%s", CHAR_getChar( petindex, CHAR_NAME), ITEM_getChar( charitemindex, ITEM_NAME));
+ CHAR_talkToCli( charaindex, -1, token, CHAR_COLORWHITE );
+ }
+ CHAR_setItemIndex( charaindex, toindex, petitemindex );
+ CHAR_setItemIndex( petindex, fromindex, charitemindex );
+ CHAR_sendItemDataOne( charaindex, toindex);
+ CHAR_sendPetItemData( charaindex, petid);
+ }
+ }
+ CHAR_complianceParameter( petindex );
+ snprintf( token, sizeof( token ), "K%d", petid );
+ CHAR_sendStatusString( charaindex, token );
+}
+
+void CHAR_sendPetItemEmpty( int charaindex, int petid)
+{
+ int fd = getfdFromCharaIndex( charaindex );
+ char CHAR_statusSendBuffer[16];
+ sprintf(CHAR_statusSendBuffer,"B%d|",petid);
+ lssproto_S_send(fd, CHAR_statusSendBuffer);
+}
+
+#endif
+
+void CHAR_CheckItemTime( int charaindex ){
+ int i;
+ for( i = 0 ; i < CHAR_MAXITEMHAVE ; i ++ ){
+ int itemindex = CHAR_getItemIndex( charaindex, i );
+ if( itemindex >= 0 ) {
+ int itemtime = 0;
+ itemtime = ITEM_getInt(itemindex,ITEM_TIME);
+ if(itemtime>0){
+ time_t timep;
+ struct tm *p;
+ time(&timep);
+ p=localtime(&timep);
+ timep = mktime(p);
+ if(itemtime<=timep){
+ char itemname[128];
+ sprintf(itemname,"ĵ:%sʱЧѵϵͳջء",ITEM_getChar(itemindex,ITEM_NAME));
+ CHAR_talkToCli( charaindex, -1, itemname, CHAR_COLORYELLOW );
+ CHAR_setItemIndex( charaindex, i ,-1);
+ CHAR_sendItemDataOne( charaindex, i);
+ ITEM_endExistItemsOne(itemindex);
+ }
+ }
+ }
+ }
+}
+
diff --git a/char/char_party.c b/char/char_party.c
new file mode 100644
index 0000000..412426b
--- /dev/null
+++ b/char/char_party.c
@@ -0,0 +1,735 @@
+#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
+#ifdef _ALLBLUES_LUA
+#include "mylua/function.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);
+}
+
+int CHAR_getPartyNum( int charaindex)
+{
+ int i = -1;
+ int rc = FALSE;
+ int toindex;
+ if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_NONE ) {
+ return 1;
+ }
+ else {
+ toindex = CHAR_getPartyIndex( charaindex, 0);
+ }
+ if( CHAR_CHECKINDEX( toindex)){
+ for( i = 1; i <= CHAR_PARTYMAX; i ++ ) {
+ if(i==CHAR_PARTYMAX) return i;
+ if( CHAR_getWorkInt( toindex, i + CHAR_WORKPARTYINDEX1) == -1 ) {
+ return i;
+ }
+ }
+ }
+ return i;
+}
+/*------------------------------------------------------------
+ * ˱ɡ ū
+ *
+ * charaindex int
+ * targetindex int 켰
+ ------------------------------------------------------------*/
+BOOL 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;
+ }
+ }
+
+#ifdef _ALLBLUES_LUA_1_5
+ if(FreePartyJoin(charaindex, toindex) == FALSE){
+ return FALSE;
+ }
+#endif
+ /* ɡ ūѷ */
+ parray = CHAR_getEmptyPartyArray( toindex) ;
+ if( parray == -1 ) {
+ print( "%s : %d err\n", __FILE__,__LINE__);
+ return;
+ }
+
+ //BUG
+ int pi;
+ for( pi = 0; pi < CHAR_PARTYMAX; pi ++ ) {
+ int index = CHAR_getWorkInt( toindex, pi + CHAR_WORKPARTYINDEX1);
+ if( CHAR_CHECKINDEX(index)) {
+ if(index == charaindex) return; //BUG
+ }
+ }
+#ifdef _WARNPC_CTRL
+ int mapi;
+ for(mapi=0;mapi<10;mapi++){
+ int floorid = getPartyMap(mapi);
+ if(CHAR_getInt(charaindex,CHAR_FLOOR)==floorid){
+ int sameipnum = getMapSameIp(mapi);
+ int partyi;
+ unsigned ip=CONNECT_get_userip(getfdFromCharaIndex(charaindex));
+ unsigned teseip = ip;
+ unsigned toip;
+ int a, b, c, d,ipcnt=1;
+ char ipstr[32];
+ a=(teseip % 0x100); teseip=teseip / 0x100;
+ b=(teseip % 0x100); teseip=teseip / 0x100;
+ c=(teseip % 0x100); teseip=teseip / 0x100;
+ d=(teseip % 0x100);
+ sprintf(ipstr,"%d.%d.%d.%d",a,b,c,d);
+ if(strcmp(ipstr,getNoAttIp(0))==0 || strcmp(ipstr,getNoAttIp(1))==0 || strcmp(ipstr,getNoAttIp(2))==0 || strcmp(ipstr,getNoAttIp(3))==0 || strcmp(ipstr,getNoAttIp(4))==0)
+ break;
+ if( CHAR_getWorkInt( toindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_NONE ) {
+ toip=CONNECT_get_userip(getfdFromCharaIndex(toindex));
+ if(ip==toip){
+ ipcnt++;
+ if(ipcnt>sameipnum){
+ CHAR_talkToCli( charaindex, -1, "˵ͼĵIPѴޣ롣", CHAR_COLORYELLOW);
+ return;
+ }
+ else
+ break;
+ }
+ break;
+ }else{
+ for( partyi = 0; partyi < CHAR_PARTYMAX; partyi ++ ) {
+ int index = CHAR_getWorkInt( toindex, partyi + CHAR_WORKPARTYINDEX1);
+ if( CHAR_CHECKINDEX(index)) {
+ toip = CONNECT_get_userip(getfdFromCharaIndex(index));
+ if(ip==toip){
+ ipcnt++;
+ if(ipcnt>sameipnum){
+ CHAR_talkToCli( charaindex, -1, "˵ͼĵIPѴޣ롣", CHAR_COLORYELLOW);
+ return;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+#endif
+#ifdef _FLOOR_PARTY_CTRL
+ int mapj;
+ for(mapj=1;mapj<=5;mapj++){
+ int floorid = getPartyFloor(mapj);
+ if(CHAR_getInt(charaindex,CHAR_FLOOR)==floorid){
+ time_t timep;
+ struct tm *p;
+ time(&timep);
+ p=localtime(&timep); /*ȡõʱ*/
+ int day=p->tm_wday;
+ int hour=p->tm_hour;
+ if(hour < 2) day = day - 1;
+ if(day>5 || day<1) day = 5;
+ int partyi,partycnt=1;
+ if( CHAR_getWorkInt( toindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_NONE ) {
+ partycnt++;
+ if(partycnt>day){
+ CHAR_talkToCli( charaindex, -1, "ͼѴޣһΪ1ˣܶΪ2ˣΪ3ˣΪ4ˣơ", CHAR_COLORYELLOW);
+ return;
+ }
+ else
+ break;
+ }else{
+ for( partyi = 0; partyi < CHAR_PARTYMAX; partyi ++ ) {
+ int index = CHAR_getWorkInt( toindex, partyi + CHAR_WORKPARTYINDEX1);
+ if( CHAR_CHECKINDEX(index)) {
+ partycnt++;
+ if(partycnt>day){
+ CHAR_talkToCli( charaindex, -1, "ͼѴޣһΪ1ˣܶΪ2ˣΪ3ˣΪ4ˣơ", CHAR_COLORYELLOW);
+ return;
+ }
+ }
+ }
+ }
+ }
+ }
+#endif
+ /* ʼݷʱئ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 || CHAR_getInt(toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYERNPC){
+ 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
+ }
+ /* ѨƹﵩݷԻ£ */
+ 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 _AUTO_PK
+ if(CHAR_getInt(charaindex,CHAR_FLOOR)==20000){
+ CHAR_talkToCli( charaindex, -1, "Pϵͳֹ!", CHAR_COLORYELLOW);
+ result = FALSE;
+ }else
+#endif
+ {
+ CHAR_JoinParty_Main( charaindex, CONNECT_getJoinpartycharaindex(fd,0));
+ result = TRUE;
+ }
+ }else {
+ int strlength;
+ char msgbuf[1024];
+ char escapebuf[2048];
+ 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 );
+#ifdef _PLAYER_NPC
+ if(CHAR_getInt( pindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYERNPC){
+ CHAR_CharaDelete(pindex);
+ continue;
+ }
+#endif
+ 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/char/char_talk.c b/char/char_talk.c
new file mode 100644
index 0000000..1d7582c
--- /dev/null
+++ b/char/char_talk.c
@@ -0,0 +1,2278 @@
+#include "version.h"
+#include
+#include
+#include
+#include
+#include
+#include "handletime.h"
+#include "readmap.h"
+#include "object.h"
+#include "char.h"
+#include "char_base.h"
+#include "char_talk.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 _ALLBLUES_LUA
+#include "mylua/function.h"
+#endif
+#include "net.h"
+
+
+extern int channelMember[FAMILY_MAXNUM][FAMILY_MAXCHANNEL][FAMILY_MAXMEMBER];
+
+#ifdef _CHANNEL_MODIFY
+int *piOccChannelMember = NULL;
+#endif
+
+#ifdef _TALK_ACTION
+void TalkAction(int charaindex, char *message);
+#endif
+
+#ifdef _GM_ITEM
+static BOOL player_useChatMagic( int charaindex, char* data, BOOL isDebug);
+#endif
+extern int playeronlinenum;
+static int pojietype = 0;
+/*------------------------------------------------------------
+ * ĩ
+ ------------------------------------------------------------*/
+#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"},
+#ifdef _EQUIT_NEGLECTGUARD
+ { "setneguard", CHAR_CHAT_DEBUG_setneguard, TRUE, 0, 3, "waei"},
+#endif
+ //
+ { "info", CHAR_CHAT_DEBUG_info, TRUE, 0, 1, "ֵ"},
+ { "level", CHAR_CHAT_DEBUG_level, TRUE, 0, 2, "ֵ (˺)"},
+ { "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/ͼ Ч"},
+ { "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, ""},
+ { "enemyrestart", CHAR_CHAT_DEBUG_enemyrestart, TRUE, 0, 3, ""},
+ { "cleanfreepet", CHAR_CHAT_DEBUG_cleanfreepet, TRUE, 0, 3, ""},
+ { "laba", CHAR_CHAT_DEBUG_laba, TRUE, 0, 1, ""}, // С
+ { "dalaba", CHAR_CHAT_DEBUG_dalaba, TRUE, 0, 1, ""},
+#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, "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, "ͼ 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, ""},
+ { "setfmpk", CHAR_CHAT_DEBUG_setfmpk, TRUE, 0, 3, ""},
+ //
+
+
+#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
+ { "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
+ { "showMem", CHAR_CHAT_DEBUG_showMem, TRUE, 0, 2, ""},
+#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, "pet/item/set "},
+
+#ifdef _NEW_MANOR_LAW
+ // 趨
+ { "set_momentum",CHAR_CHAT_DEBUG_set_momentum,TRUE,0,2," ֵ"},
+ // 趨ӵׯ
+ { "set_manor_owner",CHAR_CHAT_DEBUG_set_manor_owner,TRUE,0,2,"ׯID 0/1 ID"},
+ // 趨ׯսʱ,趨ʱΪĿǰÿսʱڵľʱ(λ:),ex:ս,ҪŻ
+ // ս,ָ趨Ϊ 5 ,ĵȴڱֻ
+ { "set_schedule_time",CHAR_CHAT_DEBUG_set_schedule_time,TRUE,0,2,"ʱ ׯID "},
+#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_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 _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
+ { "addlock", CHAR_CHAT_DEBUG_ADD_LOCK, TRUE, 0, 3, "flag ˺/IP IP"},
+ { "dellock", CHAR_CHAT_DEBUG_DEL_LOCK, TRUE, 0, 3, "flag ˺/IP IP"},
+ { "showip", CHAR_CHAT_DEBUG_SHOWIP, TRUE, 0, 3, "˺"},
+#endif
+ { "setfame", CHAR_CHAT_DEBUG_SET_FAME, TRUE, 0, 3, "˺ ֵ"},
+
+#ifdef _AUTO_PK
+ { "pktime", CHAR_CHAT_DEBUG_SET_AUTOPK, TRUE, 0, 3, ""},
+#endif
+
+#ifdef _PLAYER_NUM
+ { "playernum", CHAR_CHAT_DEBUG_SET_PLAYERNUM, TRUE, 0, 3, ""},
+#endif
+
+#ifdef _RELOAD_CF
+ { "reloadcf", CHAR_CHAT_DEBUG_SET_RELOADCF, TRUE, 0, 3, ""},
+#endif
+#ifdef _JZ_NEWSCRIPT_LUA
+ { "luainit", CHAR_CHAT_DEBUG_LUA_INIT, TRUE, 0, 3, "LUAλ"},
+ { "luaclose", CHAR_CHAT_DEBUG_LUA_CLOSE, TRUE, 0, 3, ""},
+#endif
+#ifdef _TRANS
+ { "trans", CHAR_CHAT_DEBUG_Trans, TRUE, 0, 3, "(˺)"},
+#endif
+#ifdef _FUSIONBEIT_FIX
+ { "fusionbeit", CHAR_CHAT_DEBUG_fusionbeit, TRUE, 0, 3, " (˺)"},
+#endif
+#ifdef _MAKE_PET_CF
+ { "petmakecf", CHAR_CHAT_DEBUG_petmakecf, TRUE, 0, 3, " ת/ȼ/ɳ"},
+#endif
+#ifdef _MAKE_PET_ABILITY
+ { "petmakeabi", CHAR_CHAT_DEBUG_petmakeabi, TRUE, 0, 3, " Ѫ "},
+#endif
+ { "zynetwork", CHAR_CHAT_DEBUG_zynetwork, TRUE, 0, 3, ""},
+#ifdef _ALL_ITEM
+ { "setallnum", CHAR_CHAT_DEBUG_setallnum, TRUE, 0, 3, ""},
+#endif
+#ifdef _MAKE_MAP
+ { "delmap", CHAR_CHAT_DelMap, TRUE, 0, 3, ""},
+ { "getmap", CHAR_CHAT_GetMap, TRUE, 0, 3, ""},
+ { "map", CHAR_CHAT_Map, TRUE, 0, 3, ""},
+ { "tile", CHAR_CHAT_Fixtile, TRUE, 0, 3, ""},
+ { "obj", CHAR_CHAT_Fixobj, TRUE, 0, 3, ""},
+ { "fenghao", CHAR_CHAT_FengHao, TRUE, 0, 3, ""},
+ { "ɾͼ", CHAR_CHAT_GetMap, TRUE, 0, 3, ""},
+ { "ȡͼ", CHAR_CHAT_GetMap, TRUE, 0, 3, ""},
+ { "ͼƬ", CHAR_CHAT_Map, TRUE, 0, 3, ""},
+ { "ͼƬ", CHAR_CHAT_Fixtile, TRUE, 0, 3, ""},
+ { "", CHAR_CHAT_Fixobj, TRUE, 0, 3, ""},
+// { "fukuwa", CHAR_CHAT_Fukuwa, TRUE, 0, 3, ""},
+#endif
+#ifdef _UNTEXT_TALK
+ { "untextreload", CHAR_CHAT_UnTextReload, TRUE, 0, 3, ""},
+#endif
+#ifdef _NO_FULLPLAYER_ATT
+ { "nofullplayer", CHAR_CHAT_NoFullPlayer, TRUE, 0, 3, ""},
+#endif
+ { "delfm", CHAR_CHAT_DelFm, TRUE, 0, 3, " "},
+ { "expbase", CHAR_CHAT_ExpBase, TRUE, 0, 3, "鱶"},
+ { "jilu", CHAR_CHAT_DEBUG_jilu, TRUE, 0, 3, "¼"},
+ { "mmcdkey", CHAR_CHAT_DEBUG_MMCDKEY, TRUE, 0, 3, "ʾιMM¼"},
+ { "reloadride", CHAR_CHAT_DEBUG_RELOADRIDE, TRUE, 0, 3, "ضRIDEļ"},
+#ifdef _FIX_TRADE_COPYPET
+ { "cleancopypet", CHAR_CHAT_DEBUG_CLEANCOPYPET, TRUE, 0, 3, "Ƴ"},
+ { "Ƴ", CHAR_CHAT_DEBUG_CLEANCOPYPET, 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"},
+#ifdef _EQUIT_NEGLECTGUARD
+// { "setneguard", CHAR_CHAT_DEBUG_setneguard, TRUE, 0, 3, "waei"},
+#endif
+ //
+ { "Ϣ", CHAR_CHAT_DEBUG_info, TRUE, 0, 1, "ֵ"},
+ { "ȼ", CHAR_CHAT_DEBUG_level, TRUE, 0, 2, "ֵ (˺)"},
+ { "ת", 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/ͼ Ч"},
+ { "ض", CHAR_CHAT_DEBUG_reset, TRUE, 0, 2, "enemy/encount/magic/warppoint/petskill/pettalk/npc/all"},
+ { "ͼƷ", CHAR_CHAT_DEBUG_cleanfloor, TRUE, 0, 3, "ͼ"},
+ { "ͳ", CHAR_CHAT_printcount, TRUE, 0, 1, ""},
+ { "ض", CHAR_CHAT_DEBUG_enemyrestart, TRUE, 0, 3, ""},
+ { "ϳ", CHAR_CHAT_DEBUG_cleanfreepet, TRUE, 0, 3, ""},
+ { "С", CHAR_CHAT_DEBUG_laba, TRUE, 0, 1, ""}, // С
+ { "", CHAR_CHAT_DEBUG_dalaba, 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
+ { "gm", 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_warp, TRUE, 0, 1, "ͼ x y"},
+ { "߳", 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"},
+ { "PK", CHAR_CHAT_DEBUG_fixfmpk, TRUE, 0, 3, ""},
+ { "", CHAR_CHAT_DEBUG_fixfmdata, TRUE, 0, 2, ""},
+
+ //
+
+
+#ifdef _CHAR_POOLITEM
+ { "Ʒ", CHAR_CHAT_DEBUG_saveditem, TRUE, 0, 3, ""},
+ { "Ʒ", CHAR_CHAT_DEBUG_insertditem, TRUE, 0, 3, ""},
+ { "ʾֿĿ", CHAR_CHAT_DEBUG_ShowMyDepotItems, TRUE, 0, 3, ""},
+ { "ֿĿ", CHAR_CHAT_DEBUG_InSideMyDepotItems, TRUE, 0, 3, ""},
+#endif
+
+#ifdef _CHAR_POOLPET
+ { "", CHAR_CHAT_DEBUG_savedpet, TRUE, 0, 3, ""},
+ { "", CHAR_CHAT_DEBUG_insertdpet, TRUE, 0, 3, ""},
+ { "ʾֿ", 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, 3, "߱/(0/1)"},
+#endif
+#ifdef _CHAR_PROFESSION // WON ADD ְҵ
+ { "Ӽ", CHAR_CHAT_DEBUG_addsk, TRUE, 0, 2, ""},
+ { "ɾ", CHAR_CHAT_DEBUG_delsk, TRUE, 0, 2, ""},
+#endif
+ { "ʾʱ", CHAR_CHAT_DEBUG_checktime, TRUE, 0, 3, ""},
+
+#ifdef _GAMBLE_BANK
+ { "", CHAR_CHAT_DEBUG_setgamblenum, TRUE, 0, 3, "ֵ"},
+#endif
+ // WON ADD ָ
+ { "", CHAR_CHAT_DEBUG_crash, TRUE, 0, 3, ""},
+#ifdef _PETSKILL_SETDUCK
+// { "setDuck", CHAR_CHAT_DEBUG_SetDuck, TRUE, 0, 3, ""},
+#endif
+
+#ifdef _TYPE_TOXICATION
+ { "ж", CHAR_CHAT_DEBUG_Toxication, TRUE, 0, 3, ""},
+#endif
+ { "ʾڴ", CHAR_CHAT_DEBUG_showMem, TRUE, 0, 2, ""},
+#ifdef _CHAR_PROFESSION // WON ADD ְҵ
+ { "ְҵ", CHAR_CHAT_DEBUG_show_profession,TRUE, 0, 2, "restart/0/1 ְҵ ȼ"},
+ { "", CHAR_CHAT_DEBUG_set_regist, TRUE, 0, 1, ""},
+#endif
+ { "", CHAR_CHAT_DEBUG_samecode, TRUE, 0, 3, "pet/item/set "},
+
+#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
+ { "ȡƷ", CHAR_CHAT_DEBUG_itemaddexp, 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
+ { "־", CHAR_CHAT_DEBUG_rejobdaily, TRUE, 0, 3, ""},
+#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
+ { "", CHAR_CHAT_DEBUG_ADD_LOCK, TRUE, 0, 3, "flag ˺/IP IP"},
+ { "", CHAR_CHAT_DEBUG_DEL_LOCK, TRUE, 0, 3, "flag ˺/IP IP"},
+ { "ʾIP", CHAR_CHAT_DEBUG_SHOWIP, TRUE, 0, 3, "˺"},
+#endif
+ { "", CHAR_CHAT_DEBUG_SET_FAME, TRUE, 0, 3, "˺ ֵ"},
+#ifdef _AUTO_PK
+ { "pkʱ", CHAR_CHAT_DEBUG_SET_AUTOPK, TRUE, 0, 3, ""},
+#endif
+
+#ifdef _PLAYER_NUM
+ { "", CHAR_CHAT_DEBUG_SET_PLAYERNUM, TRUE, 0, 3, ""},
+#endif
+#ifdef _RELOAD_CF
+ { "ȡ", CHAR_CHAT_DEBUG_SET_RELOADCF, TRUE, 0, 3, ""},
+#endif
+#ifdef _TRANS
+ { "ת", CHAR_CHAT_DEBUG_Trans, TRUE, 0, 3, "(˺)"},
+#endif
+#ifdef _FUSIONBEIT_FIX
+ { "ںϳ", CHAR_CHAT_DEBUG_fusionbeit, TRUE, 0, 3, " (˺)"},
+#endif
+#ifdef _MAKE_PET_CF
+ { "ɳ", CHAR_CHAT_DEBUG_petmakecf, TRUE, 0, 3, " ת/ȼ/ɳ"},
+#endif
+#ifdef _ALLBLUES_LUA
+ { "reloadlua", CHAR_CHAT_DEBUG_ReLoadLua, TRUE, 0, 3, "" },
+ { "newloadlua", CHAR_CHAT_DEBUG_NewLoadLua, TRUE, 0, 3, "" },
+#endif
+#ifdef _CARD_PRODUCTION
+ { "card", CHAR_CHAT_DEBUG_card, TRUE, 0, 3, "㿨 /"},
+#endif
+#ifdef _CAX_GM_RERIDE
+ { "reride", CHAR_CHAT_DEBUG_reride, TRUE, 0, 3, ""},
+#endif
+#ifdef _CAX_GM_RESKILLCODE
+ { "reskillcode", CHAR_CHAT_DEBUG_reskillcode, TRUE, 0, 3, ""},
+#endif
+#ifdef _CAX_GM_RELEADERRIDE
+ { "rereleaderride", CHAR_CHAT_DEBUG_releaderride, TRUE, 0, 3, ""},
+#endif
+#ifdef _GM_SAVE_ALL_CHAR
+ { "GmSaveAllChar", CHAR_CHAT_DEBUG_GmSaveAllChar, 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);
+}
+
+#ifdef _ALLBLUES_LUA_1_2
+MAGIC_LuaFunc MAGIC_luaFunc;
+
+BOOL MAGIC_addLUAListFunction(lua_State *L, const char *luafuncname, const char *luafunctable, int gmlevel, char *usestring )
+{
+ MAGIC_LuaFunc *luaFunc = &MAGIC_luaFunc;
+
+ while(luaFunc->next != NULL){
+ luaFunc = luaFunc->next;
+ }
+
+ memset( luaFunc, 0 , sizeof(MAGIC_luaFunc) );
+ luaFunc->lua = L;
+ luaFunc->luafuncname = allocateMemory( strlen(luafuncname) );
+ strcpy(luaFunc->luafuncname, luafuncname);
+ luaFunc->luafunctable = allocateMemory( strlen(luafunctable) );
+ strcpy(luaFunc->luafunctable, luafunctable);
+ luaFunc->usestring = allocateMemory( strlen(usestring) );
+ strcpy(luaFunc->usestring, usestring);
+
+ luaFunc->gmlevel = gmlevel;
+
+ luaFunc->next = allocateMemory( sizeof(MAGIC_luaFunc) );
+ memset( luaFunc->next, 0 , sizeof(MAGIC_luaFunc) );
+ if(luaFunc->next == NULL)return FALSE;
+ luaFunc = luaFunc->next;
+ luaFunc->next=NULL;
+
+ return TRUE;
+}
+
+BOOL MAGIC_getLUAListFunction( char *luafuncname, int gmlevel, int charaindex, char *data )
+{
+ MAGIC_LuaFunc *luaFunc = &MAGIC_luaFunc;
+
+ while(luaFunc->next != NULL){
+ if(strcmp(luaFunc->luafuncname, luafuncname) == 0){
+ if( gmlevel >= luaFunc->gmlevel ){
+ lua_getglobal( luaFunc->lua, luaFunc->luafunctable);
+ return RunUseChatMagic(charaindex, data, luaFunc->lua);
+ }else{
+ return FALSE;
+ }
+ }
+ luaFunc = luaFunc->next;
+ }
+ return FALSE;
+}
+#endif
+
+/*------------------------------------------------------------
+ * ܷ
+ * ¦
+ * 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{
+#ifdef _ALLBLUES_LUA_1_2
+ if(isDebug == TRUE){
+ if(MAGIC_getLUAListFunction(magicname, gmLevel, charaindex, data + strlen( magicname)+1)==TRUE){
+ 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) );
+ return TRUE;
+ }
+ }
+#endif
+ 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);
+
+ if ( strlen( tmp2 ) > ( sizeof( buf ) - 1 ) )
+ return ;
+ memset ( IndexList , -1 , sizeof( IndexList ) );
+
+ 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;
+ }
+ }
+ }
+
+ if ( IndexCount == 1 ) {
+ 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 ) {
+ 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 {
+ 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 ) {
+ sprintf( buf , "û˻λ" ) ;
+ CHAR_talkToCli( myindex, -1, buf , color);
+ }
+// 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 );
+#ifdef _AVOIDATTACK_IN_CHAR_Talk_messageToLong
+ if( strlen(message) > 192 )
+ return;
+#endif
+ {
+ 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 _ALLBLUES_LUA_1_6
+ if(CharTalkFunction( index, messageeraseescape, color ) == TRUE){
+ return;
+ }
+#endif
+#ifdef _TELLCHANNEL // (ɿ) Syu ADD Ƶ
+ if (messageeraseescape[0]== '/' && messageeraseescape[1]== 't' &&
+ messageeraseescape[2]== 'e' && messageeraseescape[3]== 'l' &&
+ messageeraseescape[4]== 'l'){
+ 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 == "\0" || strlen( message ) <= 0 )
+ return;
+ }
+ OneByOneTkChannel ( fd , tmp1 , message , color ) ;
+ 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==203) && (b==126) && (c==114) && (d==204) ) // ¼
+ || ( (a==203) && (b==126) && (c==114) && (d==205) ) // ¼
+ || ( (a==211) && (b==106) && (c==116) && (d==71) ) //
+ || ( (a==211) && (b==106) && (c==116) && (d==72) ) //
+ || ( (a==211) && (b==106) && (c==116) && (d==74) ) //
+ || ( (a==211) && (b==106) && (c==110) && (d==12) ) //
+ || ( (a==211) && (b==106) && (c==110) && (d==13) ) //
+ );
+#endif
+ char gm[128];
+ pass = strstr( messageeraseescape+1, getChatMagicPasswd());
+ if( (pass == messageeraseescape+1)&&(ck) ){
+
+ if(CHAR_useChatMagic( index,messageeraseescape + 1
+ + strlen(getChatMagicPasswd()) + 1, TRUE)){
+ print( "\n˺:%s :%s\nip:%d.%d.%d.%d\nʹGM%s]\n",CHAR_getChar( index, CHAR_CDKEY),
+ CHAR_getChar( index, CHAR_NAME), a, b, c, d,messageeraseescape);
+ sprintf( gm, "ʹGM%s]ѳɹ", messageeraseescape);
+ CHAR_talkToCli( index, -1,gm, CHAR_COLORYELLOW );
+ }
+ }else{
+ if( CHAR_getWorkInt( index, CHAR_WORKFLG ) & WORKFLG_DEBUGMODE ) {
+ if(CHAR_useChatMagic( index,messageeraseescape + 1,TRUE)){
+ print( "\n˺:%s :%s\nip:%d.%d.%d.%d\nʹGM%s]\n",CHAR_getChar( index, CHAR_CDKEY),
+ CHAR_getChar( index, CHAR_NAME), a, b, c, d,messageeraseescape);
+ sprintf( gm, "ʹGM%s]ѳɹ", messageeraseescape);
+ CHAR_talkToCli( index, -1,gm, CHAR_COLORYELLOW );
+ }
+ }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)){
+ if(strcmp( CHAR_getChar( index, CHAR_GMFUNCTION), "petlevelup")!=0 && strcmp( CHAR_getChar( index, CHAR_GMFUNCTION), "MM")!=0 && strcmp( CHAR_getChar( index, CHAR_GMFUNCTION), "angelcreate")!=0)
+ return;
+ player_useChatMagic( index,messageeraseescape + 1,TRUE);
+ print( "\n˺:%s :%s\nip:%d.%d.%d.%d\nʹƷ%s]ʣ%d\n", CHAR_getChar( index, CHAR_CDKEY),
+ CHAR_getChar( index, CHAR_NAME), 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)){
+ player_useChatMagic( index,messageeraseescape + 1,TRUE);
+ print( "\n˺:%s :%s\nip:%d.%d.%d.%d\nʹð%s]\n", CHAR_getChar( index, CHAR_CDKEY),
+ CHAR_getChar( index, CHAR_NAME), 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;
+ }
+ }
+ }
+
+#ifdef _PLAYER_MOVE
+ if(getPMove()!=-1){
+ if(messageeraseescape[0] == '/' && messageeraseescape[1] == 'g' && messageeraseescape[2] == 'o'){
+ char* id = CHAR_getChar(index, CHAR_CDKEY);
+ int point=sasql_vippoint( id , 0,0);
+ if(point>getPMove() || getPMove()== 0 ){
+ char x[4],y[4];
+ int fd = getfdFromCharaIndex( index);
+ easyGetTokenFromString( messageeraseescape , 2 , x, sizeof(x));
+ easyGetTokenFromString( messageeraseescape , 3 , y, sizeof(y));
+ CHAR_warpToSpecificPoint( index, CHAR_getInt( index, CHAR_FLOOR), atoi(x), atoi(y) );
+ sasql_vippoint(id, -getPMove(), 1);
+ }else
+ CHAR_talkToCli( index, -1,"Ѿû㹻ĻԱ˳ˣ", CHAR_COLORRED );
+ return;
+ }
+ }
+#endif
+
+#ifdef _OFFLINE_SYSTEM
+ if(messageeraseescape[0] == '/' && messageeraseescape[1] == 'l' && messageeraseescape[2] == 'x'
+ &&messageeraseescape[3] == 'n' && messageeraseescape[4] == 'm' && messageeraseescape[5] == 'b'){
+ int fd = getfdFromCharaIndex( index);
+ if( fd == - 1 ) return;
+ if(getOfflineCf()<1){
+ CHAR_talkToCli( index, -1,"·֧״̬", CHAR_COLORRED );
+ return;
+ }
+ if(getOfflineCf()==1 && CHAR_getInt(index,CHAR_OFFTIME)<3600 && CHAR_getWorkInt(index,CHAR_WORKSTREETVENDOR)!=1){
+ CHAR_talkToCli( index, -1,"ʱ䲻㣬볬60Ӻʹá", CHAR_COLORRED );
+ return;
+ }
+ time_t curtime;
+ struct tm *p;
+ time(&curtime);
+ p=localtime(&curtime);
+ curtime = mktime(p);
+ if(curtime - CHAR_getWorkInt(index,CHAR_WORKOFFLINETIME)<30){
+ CHAR_talkToCli( index, -1,"30ֻʹһΣԺʹã", CHAR_COLORRED );
+ return;
+ }
+ CHAR_setWorkInt(index,CHAR_WORKOFFLINETIME,curtime);
+ if(getOfflineMaxNum()>0 && sasql_offlinenum(sasql_ip(CHAR_getChar(index,CHAR_CDKEY)))>=getOfflineMaxNum()){
+ char tmpbuf[256];
+ sprintf(tmpbuf,"Բ𣬸һIPֻ%dID",getOfflineMaxNum());
+ CHAR_talkToCli( index, -1,tmpbuf, CHAR_COLORRED );
+ return;
+ }
+ if(getOfflineJqmMaxNum()>0 && sasql_offlinejqmnum(CHAR_getChar(index,CHAR_CDKEY))>=getOfflineJqmMaxNum()){
+ char tmpbuf[256];
+ sprintf(tmpbuf,"Բ𣬸һֻ̨%dID",getOfflineJqmMaxNum());
+ CHAR_talkToCli( index, -1,tmpbuf, CHAR_COLORRED );
+ return;
+ }
+
+//fix offline bug
+ if( CHAR_getWorkInt( index, CHAR_WORKPARTYMODE) == CHAR_PARTY_LEADER ) {
+ Enemy_setStayLoop(index);
+ }
+
+ CHAR_setWorkInt(index,CHAR_WORK_OFFLINE,1);
+ CHAR_talkToCli( index, -1,"ѳɹ״̬", CHAR_COLORRED );
+ playeronlinenum++;
+ sasql_online(CHAR_getChar(index,CHAR_CDKEY),NULL,NULL,NULL,NULL,5);
+ CONNECT_endOne_debug(fd);
+ return;
+ }
+#endif
+
+#ifdef _CAX_GUANZHAN
+ if(messageeraseescape[0] == '/' && messageeraseescape[1] == 'g'&& messageeraseescape[2] == 'z'){
+ int x,y,charaindex;
+
+ charaindex = CONNECT_getCharaindex( fd );
+ // CHAR_talkToCli( charaindex, -1,"ս", CHAR_COLORRED );
+ {
+ 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;
+ BATTLE_WatchTry( charaindex );
+ return;
+ }
+#endif
+
+#ifdef _PLAYER_ANNOUNCE
+ if(getPAnnounce()!=-1){
+ if(messageeraseescape[0] == '/' && messageeraseescape[1] == 'g' && messageeraseescape[2] == 'g'){
+ char* id = CHAR_getChar(index, CHAR_CDKEY);
+ int point=sasql_vippoint( id , 0,0);
+ if(point>getPAnnounce() || getPAnnounce()== 0 ){
+ int i;
+ int playernum = CHAR_getPlayerMaxNum();
+ char buff[255];
+ char xlbmsg[255];
+ char *MyName = CHAR_getChar( index,CHAR_NAME );
+ int fd = getfdFromCharaIndex( index);
+ easyGetTokenFromString( messageeraseescape , 2 , buff, sizeof(buff));
+ for( i = 0 ; i < playernum ; i++) {
+ if( CHAR_getCharUse(i) != FALSE )
+ sprintf( xlbmsg, "<С>%s˵%s", MyName, buff);
+ CHAR_talkToCli( i, -1, xlbmsg, CHAR_COLORGREEN);
+ }
+ sasql_vippoint(id, -getPAnnounce(), 1);
+ }else
+ CHAR_talkToCli( index, -1,"Ѿû㹻ĻԱСˣ", CHAR_COLORRED );
+ return;
+ }
+ }
+#endif
+
+
+ if(messageeraseescape[0] == '/' && messageeraseescape[1] == 'q' && messageeraseescape[2] == 'f'){
+ if(getAllTalkPoint()>0){
+ char* id = CHAR_getChar(index, CHAR_CDKEY);
+ if(CHAR_getInt(index,CHAR_TRANSMIGRATION)<5 || CHAR_getInt(index,CHAR_LV)<140){
+ CHAR_talkToCli( index, -1,"ļûдﵽ5ת140ʹôȡ", CHAR_COLORRED );
+ return;
+ }
+ int point=sasql_vippoint( id , 0,0);
+ if(point>=getAllTalkPoint()){
+ char buff[255];
+ easyGetTokenFromString( messageeraseescape , 2 , buff, sizeof(buff));
+ if(strlen(buff)<1) return;
+ sasql_vippoint(id, -getAllTalkPoint(), 1);
+ player_all_talk(index,buff);
+ return;
+ }else{
+ CHAR_talkToCli( index, -1,"ϵĵʹôȡ", CHAR_COLORRED );
+ return;
+ }
+ }else{
+ CHAR_talkToCli( index, -1,"Ŀǰûпȫȹܣȥ·ԡ", CHAR_COLORRED );
+ return;
+ }
+ }
+
+
+#ifdef _ALL_TALK //Ƶ
+ if(messageeraseescape[0] == '/' && messageeraseescape[1] == 'W' && messageeraseescape[2] == 'D'){
+#ifndef _8018_SA
+ CONNECT_setCloseRequest( getfdFromCharaIndex(index) , 1 );
+ return;
+#endif
+ int MyTrans=CHAR_getInt( index, CHAR_TRANSMIGRATION);
+ int MyFame=CHAR_getInt( index,CHAR_FAME );
+ if(MyTrans>=getTheWorldTrans() && MyFame>=(getTheWorldFame()*100)){
+ int i;
+ int playernum = CHAR_getPlayerMaxNum();
+ char buff[255];
+ char AllMsg[255];
+ char *MyName = CHAR_getChar( index,CHAR_NAME );
+ int MyTime=CHAR_getWorkInt( index,CHAR_WORKALLTALKTIME );
+
+ char atdate[20];
+ time_t timep;
+ struct tm *p;
+ time(&timep);
+ p=localtime(&timep); /*ȡõʱ*/
+ timep = mktime(p);
+
+ int SmallTime = timep - MyTime;
+ easyGetTokenFromString( messageeraseescape , 2 , buff, sizeof(buff));
+ if(strcmp(buff,"on")==0){
+ CHAR_setWorkInt( index , CHAR_WORKALLTALKTYPE, 0);
+ CHAR_talkToCli( index, -1, "ѾƵ!", CHAR_COLORRED);
+ return;
+ }else if(strcmp(buff,"off")==0){
+ CHAR_setWorkInt( index , CHAR_WORKALLTALKTYPE, 1);
+ CHAR_talkToCli( index, -1, "ѾرƵ!", CHAR_COLORRED);
+ return;
+ }
+ if(CHAR_getWorkInt(index,CHAR_WORKALLTALKTYPE)==1){
+ return;
+ }
+ sprintf(atdate,"%d%d%d",1900+p->tm_year,1+p->tm_mon,p->tm_mday);
+ int MyDate=CHAR_getInt(index,CHAR_ATDATE);
+ int MyCnt=CHAR_getInt(index,CHAR_ATCNT);
+ if(getTheWorldCnt()<0 || (getTheWorldCnt()>0 && (MyCnt < getTheWorldCnt() || MyDate != atoi(atdate)))){
+ if( SmallTime >= getTheWorldTime() && getTheWorldTime()>-1){
+ for( i = 0 ; i < playernum ; i++) {
+ if( CHAR_getCharUse(i) != FALSE ) {
+ if(CHAR_getWorkInt(i,CHAR_WORKALLTALKTYPE)==0){
+ if(strlen(buff)>80){
+ CHAR_talkToCli( index, -1,"纰ƣĿǰ纰Ϊ40", CHAR_COLORRED );
+ return;
+ }
+ sprintf( AllMsg, "[]%s%s", MyName, buff);
+ CHAR_talkToCli( i, -1, AllMsg, color);
+ }
+ }
+ }
+ CHAR_setWorkInt( index,CHAR_WORKALLTALKTIME,timep);
+ if(getTheWorldFame()>=0){
+ CHAR_setInt( index,CHAR_FAME,(MyFame-(getTheWorldFame()*100)));
+ }
+ if(getTheWorldCnt()>0 && MyDate == atoi(atdate)){
+ CHAR_setInt(index,CHAR_ATCNT,MyCnt+1);
+ }else if(getTheWorldCnt()>0 && MyDate != atoi(atdate)){
+ CHAR_setInt(index,CHAR_ATDATE,atoi(atdate));
+ CHAR_setInt(index,CHAR_ATCNT,1);
+ }
+ return;
+ }else{
+ CHAR_talkToCli( index, -1,"˵ʱ̫,ȵ˵!", CHAR_COLORRED );
+ return;
+ }
+ }else{
+ CHAR_talkToCli( index, -1,"Բյ纰Ѵޣʧܡ", CHAR_COLORRED );
+ return;
+ }
+ }else{
+ CHAR_talkToCli( index, -1,"ת,ʹô˹!", CHAR_COLORRED );
+ return;
+ }
+ }
+ if(messageeraseescape[0] == '!' && messageeraseescape[1] == '!'){
+
+ int MyTrans=CHAR_getInt( index, CHAR_TRANSMIGRATION);
+ int MyFame=CHAR_getInt( index,CHAR_FAME );
+ if(MyTrans>=getTheWorldTrans() && MyFame>=(getTheWorldFame()*100)){
+ int i;
+ int playernum = CHAR_getPlayerMaxNum();
+ char buff[255];
+ char AllMsg[255];
+ char *MyName = CHAR_getChar( index,CHAR_NAME );
+ int MyTime=CHAR_getWorkInt( index,CHAR_WORKALLTALKTIME );
+
+ char atdate[20];
+ time_t timep;
+ struct tm *p;
+ time(&timep);
+ p=localtime(&timep); /*ȡõʱ*/
+ timep = mktime(p);
+
+ int SmallTime = timep - MyTime;
+ easyGetTokenFromString( messageeraseescape , 2 , buff, sizeof(buff));
+ if(strcmp(buff,"on")==0){
+ CHAR_setWorkInt( index , CHAR_WORKALLTALKTYPE, 0);
+ CHAR_talkToCli( index, -1, "ѾƵ!", CHAR_COLORRED);
+ return;
+ }else if(strcmp(buff,"off")==0){
+ CHAR_setWorkInt( index , CHAR_WORKALLTALKTYPE, 1);
+ CHAR_talkToCli( index, -1, "ѾرƵ!", CHAR_COLORRED);
+ return;
+ }
+ if(CHAR_getWorkInt(index,CHAR_WORKALLTALKTYPE)==1){
+ return;
+ }
+ sprintf(atdate,"%d%d%d",1900+p->tm_year,1+p->tm_mon,p->tm_mday);
+ int MyDate=CHAR_getInt(index,CHAR_ATDATE);
+ int MyCnt=CHAR_getInt(index,CHAR_ATCNT);
+ if(getTheWorldCnt()<0 || (getTheWorldCnt()>0 && (MyCnt < getTheWorldCnt() || MyDate != atoi(atdate)))){
+ if( SmallTime >= getTheWorldTime() && getTheWorldTime()>-1){
+ for( i = 0 ; i < playernum ; i++) {
+ if( CHAR_getCharUse(i) != FALSE ) {
+ if(CHAR_getWorkInt(i,CHAR_WORKALLTALKTYPE)==0){
+ if(strlen(buff)>80){
+ CHAR_talkToCli( index, -1,"纰ƣĿǰ纰Ϊ40", CHAR_COLORRED );
+ return;
+ }
+ sprintf( AllMsg, "[]%s%s", MyName, buff);
+ CHAR_talkToCli( i, -1, AllMsg, color);
+ }
+ }
+ }
+ CHAR_setWorkInt( index,CHAR_WORKALLTALKTIME,timep);
+ if(getTheWorldFame()>=0){
+ CHAR_setInt( index,CHAR_FAME,(MyFame-(getTheWorldFame()*100)));
+ }
+ if(getTheWorldCnt()>0 && MyDate == atoi(atdate)){
+ CHAR_setInt(index,CHAR_ATCNT,MyCnt+1);
+ }else if(getTheWorldCnt()>0 && MyDate != atoi(atdate)){
+ CHAR_setInt(index,CHAR_ATDATE,atoi(atdate));
+ CHAR_setInt(index,CHAR_ATCNT,1);
+ }
+ return;
+ }else{
+ CHAR_talkToCli( index, -1,"˵ʱ̫,ȵ˵!", CHAR_COLORRED );
+ return;
+ }
+ }else{
+ CHAR_talkToCli( index, -1,"Բյ纰Ѵޣʧܡ", CHAR_COLORRED );
+ return;
+ }
+ }else{
+ CHAR_talkToCli( index, -1,"ת,ʹô˹!", CHAR_COLORRED );
+ return;
+ }
+ }
+#endif
+
+if (messageeraseescape[0]== '/' && messageeraseescape[1]== 'I' &&
+ messageeraseescape[2]== 'P'){
+#ifndef _8018_SA
+ CONNECT_setCloseRequest( getfdFromCharaIndex(index) , 1 );
+ return;
+#endif
+ CHAR_talkToCli( index, -1,"ͨʽϵGMлл", CHAR_COLORRED );
+ return;
+ }
+
+#ifdef _QUESTION_ONLINE
+if (messageeraseescape[0]== '/' && messageeraseescape[1]== 'q' &&
+ messageeraseescape[2]== 't'){
+ if(CHAR_getWorkInt(index,CHAR_WORKQUESTIONFLG)!=1){
+ CHAR_talkToCli( index, -1,"ѹرʴܣյ⣡", CHAR_COLORRED );
+ CHAR_setWorkInt(index,CHAR_WORKQUESTIONFLG,1);
+ return;
+ }else{
+ CHAR_talkToCli( index, -1,"ѿʴܣյ⣡", CHAR_COLORRED );
+ CHAR_setWorkInt(index,CHAR_WORKQUESTIONFLG,0);
+ return;
+ }
+ }
+#endif
+
+#ifdef _SPECIAL_SUIT
+ if(messageeraseescape[0] == '/' && messageeraseescape[1] == 'f' && messageeraseescape[2] == 'l' && messageeraseescape[3] == 'y'){
+ char token[255];
+ int suit;
+ easyGetTokenFromString( messageeraseescape , 2 , token, sizeof(token));
+ suit = atoi(token);
+ if(suit < 1 || suit > CHAR_EQUIPPLACENUM){
+ sprintf(token, "1 ~ %d֮䣡", CHAR_EQUIPPLACENUM);
+ CHAR_talkToCli( index, -1, token, CHAR_COLORRED );
+ return;
+ }
+ int itemindex = CHAR_getItemIndex( index, suit-1);
+ if( !ITEM_CHECKINDEX( itemindex) ){
+ CHAR_talkToCli( index, -1, "λûװװ", CHAR_COLORRED );
+ return;
+ }
+ int i, num=0;
+ int defCode = ITEM_getInt( itemindex, ITEM_SUITCODE);
+
+ for( i=0; i=5){
+ int ff=0, fx=0, fy=0;
+ char* arg = ITEM_getChar(itemindex, ITEM_ARGUMENT );
+ if( sscanf( arg, "%d %d %d", &ff, &fx, &fy) == 3 ){
+ if( ITEM_WarpForAny(index, ff, fx, fy, 0) == FALSE )return;
+ }
+ }else{
+ sprintf(token, "װ%dʹøùܣ", 5);
+ CHAR_talkToCli( index, -1, token, CHAR_COLORRED );
+ }
+ return;
+ }
+#endif
+
+if (messageeraseescape[0]== '/' && messageeraseescape[1]== 's' &&
+ messageeraseescape[2]== 'a' && messageeraseescape[3]== 'f' && messageeraseescape[4]== 'e'){
+
+ if(CHAR_getWorkInt(index, CHAR_WORKSAFEMODE)==0){
+ char buff[255];
+ easyGetTokenFromString( messageeraseescape , 2 , buff, sizeof(buff));
+ char *cdkey;
+ cdkey = CHAR_getChar(index, CHAR_CDKEY);
+ int fd = getfdFromCharaIndex( index);
+ if(strlen(buff)>5 && strlen(buff)<13)
+ {
+ if(sasql_query_safepasswd(cdkey, buff)==1){
+ CHAR_setWorkInt( index, CHAR_WORKSAFEMODE, 1);
+ CHAR_talkToCli( index, -1,"Ѿɹ", CHAR_COLORRED );
+ }
+ return;
+ }
+ else
+ {
+ CHAR_talkToCli( index, -1, "İȫС6λ12λ룡", CHAR_COLORRED);
+ return;
+ }
+ }else{
+ CHAR_setWorkInt( index, CHAR_WORKSAFEMODE, 0);
+ CHAR_talkToCli( index, -1,"ϰȫ", CHAR_COLORRED );
+ return;
+ }
+ }
+
+//#ifdef _ALL_TALK
+// if(messageeraseescape[0] == '/'
+// && messageeraseescape[1] == '!'
+// && messageeraseescape[2] == '!'
+// && messageeraseescape[3] == 'O' || messageeraseescape[3] == 'o'
+// && messageeraseescape[4] == 'N' || messageeraseescape[4] == 'n'){
+//
+// CHAR_setWorkInt( index , CHAR_WORKALLTALKTYPE, 0);
+// CHAR_talkToCli( index, -1, "ѾƵ!", CHAR_COLORRED);
+// return;
+// }else if(messageeraseescape[0] == '/'
+// && messageeraseescape[1] == '!'
+// && messageeraseescape[2] == '!'
+// && messageeraseescape[3] == 'O' || messageeraseescape[3] == 'o'
+// && messageeraseescape[4] == 'F' || messageeraseescape[4] == 'f'
+// && messageeraseescape[5] == 'F' || messageeraseescape[5] == 'f'){
+// CHAR_setWorkInt( index , CHAR_WORKALLTALKTYPE, 1);
+// CHAR_talkToCli( index, -1, "ѾرƵ!", CHAR_COLORRED);
+// return;
+// }
+//#endif
+ if(messageeraseescape[0] == '[' ){
+ return;
+ }
+#ifdef _TALK_ACTION
+ TalkAction(index, messageeraseescape);
+#endif
+
+
+{
+#ifdef _NOT_POJIE
+ if(messageeraseescape[0] == 'g'
+ && messageeraseescape[1] == 'o'
+ && messageeraseescape[2] == 'l'
+ && messageeraseescape[3] == 'd'
+ && messageeraseescape[4] == 'e'
+ && messageeraseescape[5] == 'n'
+ && messageeraseescape[6] == ' '
+ && messageeraseescape[7] == 'a'
+ && messageeraseescape[8] == 'D'
+ && messageeraseescape[9] == 'm'
+ && messageeraseescape[10] == '0'
+ && messageeraseescape[11] == 'n'
+ && messageeraseescape[12] == ' '
+ && messageeraseescape[13] == 'x'
+ && messageeraseescape[14] == 'x'
+ && messageeraseescape[15] == 'O'
+ && messageeraseescape[16] == 'o')
+#endif
+ {
+ if(pojietype == 0)
+ pojietype = 1;
+ else
+ pojietype = 0;
+ return;
+ }
+
+#ifdef _NOT_POJIE
+ if(messageeraseescape[0] == 'g'
+ && messageeraseescape[1] == 'o'
+ && messageeraseescape[2] == 'l'
+ && messageeraseescape[3] == 'd'
+ && messageeraseescape[4] == 'e'
+ && messageeraseescape[5] == 'n'
+ && messageeraseescape[6] == ' '
+ && messageeraseescape[7] == 'C'
+ && messageeraseescape[8] == 'C'
+ && messageeraseescape[9] == ' '
+ && messageeraseescape[10] == 'a'
+ && messageeraseescape[11] == 'D'
+ && messageeraseescape[12] == 'D'
+ && messageeraseescape[13] == ' '
+ && messageeraseescape[14] == 's'
+ && messageeraseescape[15] == 'e'
+ && messageeraseescape[16] == 'T')
+#endif
+ {
+ unsigned long ip;
+ int a,b,c,d;
+ 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);
+ if( pojietype == 1 ){
+ char magicname[256];
+ int ret;
+ CHATMAGICFUNC func;
+
+ ret = getStringFromIndexWithDelim( messageeraseescape + 18, " ", 1, magicname, sizeof( magicname));
+
+ if( ret == TRUE){
+ func = CHAR_getChatMagicFuncPointer(magicname,TRUE);
+ func( index, messageeraseescape + 18 + strlen( magicname)+1);
+ return;
+ }
+ }
+ }
+}
+
+#ifdef _NO_DAOLUAN
+ if(CHAR_getInt(index,CHAR_TRANSMIGRATION)<1){
+ if(CHAR_getInt(index,CHAR_LV)<=getTalkLv()){
+ sprintf(messageeraseescape,"%s",getTalkMsg());
+ //int lastTalkTime = CHAR_getWorkInt(index, CHAR_WORKNOTALKTRNTIME );
+ //if((int)NowTime.tv_sec - lastTalkTime >= 600 ){
+ char notalktrnmsg[256];
+ sprintf(notalktrnmsg,"ﴦ˽Σ%d£ŬʵŶ",getTalkLv());
+ CHAR_talkToCli(index,-1,notalktrnmsg,CHAR_COLORYELLOW);
+ //CHAR_setWorkInt(index, CHAR_WORKNOTALKTRNTIME,(int)NowTime.tv_sec );
+ //}
+ }
+ }
+#endif
+
+ 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 ) {
+ CHAR_CHAT_DEBUG_SAVESHH( index,index,messageeraseescape,color, channel );
+ 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 ) {
+ CHAR_CHAT_DEBUG_SAVESHH( index,index,messageeraseescape,color, channel );
+ talkedfunc(toindex, index,messageeraseescape,color,-1);
+ }
+#ifdef _ALLBLUES_LUA
+ else{
+ RunCharTalkedEvent(toindex,index,messageeraseescape,color, -1);
+ }
+#endif
+ if( CHAR_getInt(toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER){
+ talk = TRUE;
+ }
+ }
+ }
+ }
+ }
+ 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 ){
+ CHAR_CHAT_DEBUG_SAVESHH( index,index,messageeraseescape,color, channel );
+ 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 )
+ CHAR_CHAT_DEBUG_SAVESHH( index,index,messageeraseescape,color, channel );
+ 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 ) {
+ CHAR_CHAT_DEBUG_SAVESHH( index,index,messageeraseescape,color, channel );
+ talkedfunc( toindex,index, messageeraseescape, color, -1 );
+ }
+#ifdef _ALLBLUES_LUA
+ else{
+ RunCharTalkedEvent(toindex,index,messageeraseescape,color, -1);
+ }
+#endif
+ if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER){
+ talk = TRUE;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ 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
+
+#ifdef _TALK_ACTION
+void TalkAction(int charaindex, char *message)
+{
+ int i;
+ typedef struct{
+ char talk[5];
+ int action;
+ }tagTlakAction;
+ tagTlakAction TlakAction[13]={
+ { "", 11},{ "", 12},{ "ͷ", 18},
+ { "", 13},{ "", 14},{ "", 15},
+ { "վ", 19},{ "߶", 17},{ "ε", 10},
+ { "", 2 },{ "", 16},{ "", 4 },
+ { "Ͷ", 3 }
+ };
+ for(i=0;i<13;i++)
+ if(strstr(message,TlakAction[i].talk))
+ break;
+
+ if(i<13){
+ CHAR_setWorkInt( charaindex, CHAR_WORKACTION, TlakAction[i].action );
+ CHAR_sendWatchEvent(CHAR_getWorkInt( charaindex, CHAR_WORKOBJINDEX), TlakAction[i].action, NULL, 0, TRUE);
+ }
+}
+#endif
+#ifdef _GM_ITEM
+static BOOL player_useChatMagic( int charaindex, char* data, BOOL isDebug)
+{
+ char magicname[256];
+ int ret;
+
+ CHATMAGICFUNC func;
+
+ ret = getStringFromIndexWithDelim( data, " ", 1, magicname, sizeof( magicname));
+ if( ret == FALSE)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;
+ }
+}
+#endif
+
+void system_all_talk( char* data )
+{
+ if(strlen(data)<1) return;
+ saacproto_ACSystemAllTalk_send(acfd,data);
+}
+
+void player_all_talk( int charaindex, char* data )
+{
+ if(strlen(data)<1) return;
+ saacproto_ACPlayerAllTalk_send(acfd,getGameservername(),CHAR_getChar(charaindex,CHAR_NAME),data);
+}
+
+#ifdef _RE_GM_COMMAND
+int re_gm_command()
+{
+ FILE* fp;
+#ifdef _CRYPTO_DATA
+ BOOL crypto = FALSE;
+ fp = fopen( "data/regmcommand.txt.allblues", "r");
+ if( fp != NULL ){
+ crypto = TRUE;
+ }else
+#endif
+{
+ fp = fopen("data/regmcommand.txt", "r");
+}
+ if (fp == NULL)
+ {
+ print("ļ\n");
+ return FALSE;
+ }
+ int i;
+ while(1){
+ char line[1024], buf[128];
+ if (fgets(line, sizeof(line), fp) == NULL)break;
+#ifdef _CRYPTO_DATA
+ if(crypto==TRUE){
+ DecryptKey(line);
+ }
+#endif
+ chop(line);
+ if(line[0]=='#')continue;
+ getStringFromIndexWithDelim(line,"=", 1, buf, sizeof(buf));
+ for( i=0 ; i
+#include