Exemplo n.º 1
0
BOOL NPC_Util_isFaceToFace( int index1, int index2, int distance )
{
    int i;
    if(CHAR_getInt(index1,CHAR_FLOOR) != CHAR_getInt(index2,CHAR_FLOOR)){
        return FALSE;
    }
    if(CHAR_getInt(index1,CHAR_X) == CHAR_getInt(index2,CHAR_X )
       && CHAR_getInt(index1,CHAR_Y) == CHAR_getInt(index2,CHAR_Y) ){
        return FALSE;
    }
    for( i=1;i<=distance;i++ ){
        int walked_x, walked_y;
        CHAR_getCoordinationDir( CHAR_getInt(index1,CHAR_DIR)
                                 , CHAR_getInt(index1,CHAR_X)
                                 , CHAR_getInt(index1,CHAR_Y)
                                 ,i, &walked_x, &walked_y );
        if( CHAR_getInt(index2,CHAR_X) == walked_x
            && CHAR_getInt(index2,CHAR_Y) == walked_y ){
            CHAR_getCoordinationDir( CHAR_getInt(index2,CHAR_DIR)
                                     , CHAR_getInt(index2,CHAR_X)
                                     , CHAR_getInt(index2,CHAR_Y)
                                     ,i, &walked_x, &walked_y );
            if( CHAR_getInt(index1,CHAR_X) == walked_x
                && CHAR_getInt(index1,CHAR_Y) == walked_y ){
                return TRUE;
            }else{
                return FALSE;
            }
        }
    }
    return FALSE;
}
Exemplo n.º 2
0
/*
 * あるキャラがあるキャラの真正面の何歩か以内にいるか
 * どうか調べる
 *
 * 引数
 * int index1,index2:index1のキャラの前にindex2がいるか
 * どうかを調べる。index1は向きが関係あるけど、index2は関係ない。
 * 返り値
 * 距離がdistance以内だったらTRUE, それ以外はFALSE
 * 重なっていてもFALSE
 */
BOOL NPC_Util_charIsInFrontOfChar( int index1, int index2, int distance )
{
    int i;
    if(CHAR_getInt(index1,CHAR_FLOOR) != CHAR_getInt(index2,CHAR_FLOOR)){
        /* フロアが違ったら問題外でFALSE */
        return FALSE;
    }
    if(CHAR_getInt(index1,CHAR_X) == CHAR_getInt(index2,CHAR_X )
       && CHAR_getInt(index1,CHAR_Y) == CHAR_getInt(index2,CHAR_Y) ){
        /* かさなっていたらFALSE */
        return FALSE;
    }
    
    for( i=1;i<=distance;i++ ){
        /* index1が一歩歩いた先の座標をもとめていく */
        int walked_x, walked_y;
        CHAR_getCoordinationDir( CHAR_getInt(index1,CHAR_DIR)
                                 , CHAR_getInt(index1,CHAR_X)
                                 , CHAR_getInt(index1,CHAR_Y)
                                 ,i, &walked_x, &walked_y );
        if( CHAR_getInt(index2,CHAR_X) == walked_x
            && CHAR_getInt(index2,CHAR_Y) == walked_y ){
            /* index2と重なったらreturn TRUE */
            return TRUE;
        }
    }
    /* ぜんぜん重ならなかったらFALSE */
    return FALSE;
    
}
Exemplo n.º 3
0
int NPC_Util_FrontItem( int meindex )
{
    int front_x, front_y,objindex,itemindex;
    OBJECT obj;

    CHAR_getCoordinationDir( CHAR_getInt(meindex,CHAR_DIR)
                             , CHAR_getInt(meindex,CHAR_X)
                             , CHAR_getInt(meindex,CHAR_Y)
                             ,1, &front_x, &front_y );
    for( obj=MAP_getTopObj(CHAR_getInt(meindex,CHAR_FLOOR),
                           front_x,front_y );obj;
        obj=NEXT_OBJECT(obj) ){
        objindex = GET_OBJINDEX(obj);
        if( OBJECT_getType(objindex) == OBJTYPE_ITEM ){
            itemindex = OBJECT_getIndex(objindex);
            if(ITEM_CHECKINDEX(itemindex) ){
                return itemindex;
            }else{
                return -1;
            }
        }
    }

    return -1;

}
Exemplo n.º 4
0
BOOL NPC_Util_isFaceToChara( int index1, int index2, int distance )
{
    int i;
    if(CHAR_getInt(index1,CHAR_FLOOR) != CHAR_getInt(index2,CHAR_FLOOR)){
        return FALSE;
    }
    if(CHAR_getInt(index1,CHAR_X) == CHAR_getInt(index2,CHAR_X )
       && CHAR_getInt(index1,CHAR_Y) == CHAR_getInt(index2,CHAR_Y) ){
        /* 井今卅勻化中凶日FALSE */
        return FALSE;
    }

    for( i=1;i<=distance;i++ ){
        /* 引內}中勻仇戶及平乓仿互洶中凶  及甄  毛菲戶月 */
        int walked_x, walked_y;
        CHAR_getCoordinationDir( CHAR_getInt(index1,CHAR_DIR)
                                 , CHAR_getInt(index1,CHAR_X)
                                 , CHAR_getInt(index1,CHAR_Y)
                                 ,i, &walked_x, &walked_y );
        if( CHAR_getInt(index2,CHAR_X) == walked_x
            && CHAR_getInt(index2,CHAR_Y) == walked_y )
		{
            return TRUE;
        }else{
            return FALSE;
        }
    }
    /* 兮氏兮氏褐卅日卅井勻凶日FALSE */
    return FALSE;
}
Exemplo n.º 5
0
BOOL NPC_UtilObj_isFaceToFace( int npcobjindex, int objindex, int distance )
{
    int i;
	int npc_floor, npc_x, npc_y, npc_dir;
	npc_floor = OBJECT_getFloor( npcobjindex);
	npc_x = OBJECT_getX( npcobjindex);
	npc_y = OBJECT_getY( npcobjindex);
	npc_dir = OBJECT_getNpcdir( npcobjindex);

    if( OBJECT_getFloor( objindex) != npc_floor )
        return FALSE;
    if( OBJECT_getX( objindex) == npc_x && OBJECT_getY( objindex) == npc_y )
        return FALSE;

    for( i=1; i<=distance; i++ ){
        int walked_x, walked_y;
            CHAR_getCoordinationDir( OBJECT_getNpcdir( objindex)
                                     , OBJECT_getX( objindex), OBJECT_getY( objindex)
                                     , i, &walked_x, &walked_y );

            if( npc_x == walked_x && npc_y == walked_y ){
                return TRUE;
            }else{
                return FALSE;
            }
    }
    return FALSE;
}
Exemplo n.º 6
0
/*
 * ふたつのキャラクタが直線上に向かいあっていて、かつ
 * 距離があるグリッド以内かどうかを調べる。店用に作ったが,
 * むかいあったらレーザーを打つ敵とかにも使える。
 *
 * 引数
 * int index1, index2 : しらべるふたりのキャラのindex。
 * int distance : ふたりのあいだの距離
 * 返り値
 * むかいあっていて距離がdistance以内だったらTRUE, それ以外はFALSE
 * 重なっていてもFALSE
 */
BOOL NPC_Util_isFaceToFace( int index1, int index2, int distance )
{
    int i;
    if(CHAR_getInt(index1,CHAR_FLOOR) != CHAR_getInt(index2,CHAR_FLOOR)){
        /* フロアが違ったら問題外でFALSE */
        return FALSE;
    }
    if(CHAR_getInt(index1,CHAR_X) == CHAR_getInt(index2,CHAR_X )
       && CHAR_getInt(index1,CHAR_Y) == CHAR_getInt(index2,CHAR_Y) ){
        /* かさなっていたらFALSE */
        return FALSE;
    }
    
    for( i=1;i<=distance;i++ ){
        /* まず、いっこめのキャラが歩いた後の座標を求める */
        int walked_x, walked_y;
        CHAR_getCoordinationDir( CHAR_getInt(index1,CHAR_DIR)
                                 , CHAR_getInt(index1,CHAR_X)
                                 , CHAR_getInt(index1,CHAR_Y)
                                 ,i, &walked_x, &walked_y );
        if( CHAR_getInt(index2,CHAR_X) == walked_x
            && CHAR_getInt(index2,CHAR_Y) == walked_y ){
            /* もういっこのキャラと重なったら、もういっこを同じ
             歩数歩かせた座標を求める。そして重なったらTRUE、
             重ならなかったらFALSE*/
            CHAR_getCoordinationDir( CHAR_getInt(index2,CHAR_DIR)
                                     , CHAR_getInt(index2,CHAR_X)
                                     , CHAR_getInt(index2,CHAR_Y)
                                     ,i, &walked_x, &walked_y );
            if( CHAR_getInt(index1,CHAR_X) == walked_x
                && CHAR_getInt(index1,CHAR_Y) == walked_y ){
                return TRUE;
            }else{
                return FALSE;
            }
        }
    }
    /* ぜんぜん重ならなかったらFALSE */
    return FALSE;
}
Exemplo n.º 7
0
BOOL NPC_Util_isBackContact(int frontindex, int backindex)
{
	int dir;
	int x, y;

	dir = (CHAR_getInt(frontindex, CHAR_DIR) + 4) % 8;
	VALIDATEDIR(dir);
	CHAR_getCoordinationDir(dir,
				CHAR_getInt(frontindex, CHAR_X),
				CHAR_getInt(frontindex, CHAR_Y), 1, &x, &y);
	if (x == CHAR_getInt(backindex, CHAR_X)
	    && y == CHAR_getInt(backindex, CHAR_Y)
	    && CHAR_getInt(backindex, CHAR_DIR)
	    == CHAR_getInt(frontindex, CHAR_DIR))
		return TRUE;
	else
		return FALSE;
}
Exemplo n.º 8
0
int NPC_Util_FrontChar( int meindex )
{
    int front_x, front_y,objindex,enemyindex;
    OBJECT obj;
    CHAR_getCoordinationDir( CHAR_getInt(meindex,CHAR_DIR)
                             , CHAR_getInt(meindex,CHAR_X)
                             , CHAR_getInt(meindex,CHAR_Y)
                             ,1, &front_x, &front_y );
    for( obj=MAP_getTopObj(CHAR_getInt(meindex,CHAR_FLOOR),
                           front_x,front_y );obj;
        obj=NEXT_OBJECT(obj) ){
        objindex = GET_OBJINDEX(obj);
        if( OBJECT_getType(objindex) == OBJTYPE_CHARA ){
            enemyindex = OBJECT_getIndex(objindex);
            if(CHAR_CHECKINDEX(enemyindex) ){
                return enemyindex;
            }
        }
    }
    return -1;
}
Exemplo n.º 9
0
/*------------------------------------------------------------
 * ¥Ñ¡¼  ¥£¤Ë  ¤í¤¦¤È¤¹¤ë¡e
 ------------------------------------------------------------*/
BOOL CHAR_JoinParty( int charaindex )
{

	int     result = -1;
	int     x,y;
	OBJECT  object;
	int     found = FALSE;
	int     fd;
	int		cnt;
	int	i;
	fd = getfdFromCharaIndex( charaindex );
	if( fd == -1 ) {
		print( "%s : %d err\n", __FILE__, __LINE__);
		return FALSE;
	}
        /* ¼«Ê¬¤¬¥Ñ¡¼  ¥£ÁȤó¤Ç¤¿¤éÂÌ   */
	if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE ) {
		lssproto_PR_send( fd, 1, FALSE);
		return FALSE;
	}
	/*   ¤ÎÁ°¤ÎºÂ  ¤ò  ¤ë */
	CHAR_getCoordinationDir( CHAR_getInt( charaindex, CHAR_DIR ) ,
							 CHAR_getInt( charaindex , CHAR_X ),
							 CHAR_getInt( charaindex , CHAR_Y ) ,
							 1 , &x , &y );

	/* ½é´ü²½¤¹¤ë */
	for( i = 0; i < CONNECT_WINDOWBUFSIZE; i ++ ) {
        CONNECT_setJoinpartycharaindex(fd,i,-1);
    }
	cnt = 0;

	/*¼«Ê¬¤Î  ¤ÎÁ°¤Î¥­¥ã¥é¤ò¼è  ¤¹¤ë */
	for( object = MAP_getTopObj( CHAR_getInt( charaindex, CHAR_FLOOR),x,y) ;
		 object ;
		 object = NEXT_OBJECT(object ) )
	{
		int toindex;
		int parray;
		int objindex = GET_OBJINDEX(object);
		int targetindex = -1;
		/* ¥­¥ã¥é¥¯¥¿¡¼¤¸¤ã¤Ê¤¤ */
		if( OBJECT_getType( objindex) != OBJTYPE_CHARA) continue;
		toindex = OBJECT_getIndex( objindex);
	
                // shan begin
                if( CHAR_getInt(charaindex, CHAR_FMINDEX) > 0 && CHAR_getInt(toindex, CHAR_FMINDEX) >0){
                    for( i = 0; i < FAMILY_FMPKFLOOR; i++){
                        if( fmpkflnum[i].fl == CHAR_getInt( charaindex, CHAR_FLOOR) )
                            if( CHAR_getInt(charaindex, CHAR_FMINDEX) != CHAR_getInt(toindex, CHAR_FMINDEX) ){
                                lssproto_PR_send( fd, 1, FALSE);
                                return FALSE;
                            }
                    }
                }
                // shan end
	
		/* ¥×¥ì¥¤¥ä¡¼¤Î»þ */
		if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER ){
			found = TRUE;
			/* Áê¼ê¤¬»Ò¤À¤Ã¤¿¤é¿Æ¤ò°ú¤ÃÄ¥¤ê½Ð¤¹ */
			if( CHAR_getWorkInt( toindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_CLIENT ) {
				targetindex = CHAR_getWorkInt( toindex, CHAR_WORKPARTYINDEX1);
				if( !CHAR_CHECKINDEX( targetindex) ) {
					print( " %s:%d err\n", __FILE__, __LINE__);
					continue;
				}
				if( CHAR_getInt( targetindex, CHAR_WHICHTYPE) == CHAR_TYPEBUS) {
					continue;
				}
			}
			else {
				targetindex = toindex;
			}
			/*   ¿Æ¤È  £±¬¤°Ê  ¤Ë¤¤¤ë¤« */
			if( NPC_Util_CharDistance( charaindex, targetindex ) > 1) {
				continue;
			}

			/* Àï    ¤Ï¤Ç¤Ê¤¤»ö¡e*/
			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, "¨ÏªÌ¤£¥i¥H·í»â¶¤¡C", CHAR_COLORYELLOW);
				continue;
			}
#endif
#ifdef _ESCAPE_RESET // ¨Ï¥Î´cÄ_°k¶]«áx¤ÀÄÁ¤º¤£¥i»P¤H²Õ¶¤
			if( getStayEncount( getfdFromCharaIndex(targetindex) ) ) {
				//print(" ´cÄ_¤¤²Õ¶¤ ");
				if( time(NULL) - CHAR_getWorkInt( targetindex, CHAR_WORKLASTESCAPE) < 5*60 ) {
					//print(" ´cÄ_°k¶]«á²Õ¶¤ ");
					CHAR_talkToCli( charaindex, -1, "¦¹¤H¼È®É¤£¥i¥H·í»â¶¤¡C", CHAR_COLORYELLOW);
					continue;
				}
			}
#endif
		}
		/* ¥Þ¥ó¥â¥¹¥Ð¥¹¤¬¤¤¤ë»þ¤Ï¡f¿Í´Ö¤è¤êÍ¥À褹¤ë¡e */
		else if( CHAR_getInt( toindex, CHAR_WHICHTYPE) == CHAR_TYPEBUS ) {
			targetindex = toindex;
			cnt = 0;
			if( !NPC_BusCheckJoinParty( toindex, charaindex, TRUE)) {
				/* ¾ò·ï¤ò  ¤¿¤µ¤Ê¤«¤Ã¤¿¡eÃç´Ö  ¤ë¤Î¤Ï½ª¤ï¤ë¡e¿Í´Ö¤Î½è  ¤â¤·¤Ê¤¤¡e
				 * ¤ä¤ä¤³¤·¤¤¤Î¤Ç¡e
				 */
				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;
		
		/* ¥Þ¥ó¥â¥¹¥Ð¥¹  ¸«¤·¤À¤¤¡f¥ë¡¼¥×¤ò  ¤±¤ë¡e */
		if( CHAR_getInt( targetindex, CHAR_WHICHTYPE) == CHAR_TYPEBUS ) break;

	}
	if( cnt == 0 ) {
		if( found == TRUE) {
			CHAR_talkToCli( charaindex, -1, "µLªk¥[¤J¹Î¶¤¡C", CHAR_COLORYELLOW);
		}
		result = FALSE;
	}else if( cnt == 1 ) {
#ifdef _DEATH_CONTEND
		int toindex = CONNECT_getJoinpartycharaindex( fd, 0);
		if(CHAR_getInt(toindex,CHAR_PKLISTTEAMNUM) == -1 && CHAR_getInt(charaindex,CHAR_PKLISTTEAMNUM) == -1){
		}else if( CHAR_getInt( charaindex, CHAR_PKLISTLEADER ) > 0 ||
			CHAR_getInt( toindex, CHAR_PKLISTTEAMNUM) < 0 ||
			CHAR_getInt( charaindex, CHAR_PKLISTTEAMNUM) < 0 ||
			CHAR_getInt( toindex, CHAR_PKLISTTEAMNUM) != CHAR_getInt( charaindex, CHAR_PKLISTTEAMNUM) ||
			CHAR_getInt(toindex,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER){

			CHAR_talkToCli( charaindex, -1, "¶¤¥î¤£¦P¡AµLªk¥[¤J¹Î¶¤¡C", CHAR_COLORYELLOW);
			result = FALSE;
		}else{
#endif
			CHAR_JoinParty_Main( charaindex, CONNECT_getJoinpartycharaindex(fd,0));
			result = TRUE;
#ifdef _DEATH_CONTEND
		}
#endif
	}else {
		int		strlength;
		char	msgbuf[1024];
		char	escapebuf[2048];
#ifdef _DEATH_CONTEND
		int toindex = CONNECT_getJoinpartycharaindex( fd, 0);
		if(CHAR_getInt(toindex,CHAR_PKLISTTEAMNUM) == -1 && CHAR_getInt(charaindex,CHAR_PKLISTTEAMNUM) == -1){
		}else if( CHAR_getInt( charaindex, CHAR_PKLISTLEADER ) > 0 ||
			CHAR_getInt( toindex, CHAR_PKLISTTEAMNUM) < 0 ||
			CHAR_getInt( charaindex, CHAR_PKLISTTEAMNUM) < 0 ||
			CHAR_getInt( toindex, CHAR_PKLISTTEAMNUM) != CHAR_getInt( charaindex, CHAR_PKLISTTEAMNUM) ||
			CHAR_getInt(toindex,CHAR_WHICHTYPE) != CHAR_TYPEPLAYER){

			CHAR_talkToCli( charaindex, -1, "¶¤¥î¤£¦P¡AµLªk¥[¤J¹Î¶¤¡C", CHAR_COLORYELLOW);
			result = FALSE;
		}
#endif
		strcpy( msgbuf, "1\n©M½Ö²Õ¦¨¹Î¶¤©O¡H\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µøµ¡°T®§buffer¤£¨¬¡C\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;
}
Exemplo n.º 10
0
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©M½Ö¥æ´«¦W¤ù©O¡H\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µøµ¡°T®§buffer¤£¨¬¡C\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;
}
Exemplo n.º 11
0
/*------------------------------------------------------------
 * 啖  允月[
 * 娄醒
 *  index       int     平乓仿及奶件犯永弁旦
 *  dir         int       轾
 * 忒曰袄
 *  CHAR_WALKRET
 ------------------------------------------------------------*/
static CHAR_WALKRET CHAR_walk_move( int charaindex, int dir )
{
    int     i;
    int     fx,fy,ff;
    int     ox,oy,of;
    int     objbuf[128];
    int     objbufindex=0;
    int     notover=FALSE;
    int     retvalue=CHAR_WALKSUCCESSED;

    if( !CHAR_CHECKINDEX( charaindex )) return CHAR_WALKSYSTEMERROR;
    ox = CHAR_getInt(charaindex,CHAR_X);
    oy = CHAR_getInt(charaindex,CHAR_Y);
    of = CHAR_getInt(charaindex,CHAR_FLOOR);
    CHAR_getCoordinationDir( dir,ox,oy,1,&fx,&fy);
    ff = of;

    if( CHAR_getInt( charaindex,CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ){
        RECT    walkr;
        POINT   nextp;
        int npccreateindex;
        npccreateindex = CHAR_getInt( charaindex,CHAR_NPCCREATEINDEX );
        if( CHAR_isInvincibleArea( ff,fx,fy)) {
            CHAR_setInt(charaindex,CHAR_DIR,dir);
            retvalue = CHAR_WALKEXTEND;
            goto CHAR_AFTERWALK;
        }
        if( NPC_isBoundarySet( npccreateindex ) &&
            NPC_createGetRECT( npccreateindex,&walkr ) == TRUE )
        {
            nextp.x = fx;
            nextp.y = fy;
            if( PointInRect( &walkr,&nextp ) == FALSE ){
                CHAR_setInt(charaindex,CHAR_DIR,dir);
                retvalue = CHAR_WALKEXTEND;
                goto CHAR_AFTERWALK;
            }
        }else{
            ;
        }
    }


    if( CHAR_getFlg( charaindex, CHAR_ISBIG ) == 1 ){
        static POINT offset[5]={
            { 0,-1},
            {-1, 0},
            { 0, 0},
            { 1, 0},
            { 0, 1},
        };
        int     k;
        for( k=0 ; k<5; k++ ){
            if( !MAP_walkAble( charaindex, ff, fx+offset[k].x,
                               fy+offset[k].y )){
                CHAR_setInt(charaindex,CHAR_DIR,dir);
                retvalue = CHAR_WALK1357;
                goto CHAR_AFTERWALK;
            }
        }

    }else{
        if( CHAR_getDX(dir)*CHAR_getDY(dir) == 0 ){
            if( !MAP_walkAble( charaindex,ff, fx, fy ) ){
                CHAR_setInt(charaindex,CHAR_DIR,dir);
                retvalue = CHAR_WALK1357;
                goto CHAR_AFTERWALK;
            }
        }else{
            int     xflg,yflg;
            if( !MAP_walkAble( charaindex,ff, fx, fy ) ){
                CHAR_setInt(charaindex,CHAR_DIR,dir);
                retvalue = CHAR_WALK1357;
                goto CHAR_AFTERWALK;
            }

            xflg = MAP_walkAble( charaindex,of, ox+CHAR_getDX(dir), oy );
            yflg = MAP_walkAble( charaindex,of, ox, oy+CHAR_getDY(dir) );

            if( !xflg || !yflg ) {
                CHAR_setInt(charaindex,CHAR_DIR,dir);
                retvalue = CHAR_WALK1357;
                goto CHAR_AFTERWALK;
            }
        }
    }
    objbufindex = CHAR_getSameCoordinateObjects( objbuf, arraysizeof( objbuf ), ff,fx,fy );
    for( i = 0 ; i < objbufindex ; i ++ ){
        int     objindex= objbuf[i];
        switch( OBJECT_getType(objindex) ){
        case OBJTYPE_CHARA:
            if( !CHAR_getFlg( OBJECT_getIndex(objindex),CHAR_ISOVERED) ){
            	if(!CHAR_CHECKINDEX(OBJECT_getIndex(objindex))){
	            	printf("自动删除一个问题对象!");
	        			endObjectOne(objindex);
	        			break;
	        		}
              notover= TRUE;
            }
            break;
        case OBJTYPE_ITEM:
            if( !ITEM_getInt( OBJECT_getIndex(objindex), ITEM_ISOVERED ) )
                notover= TRUE;
            break;
        case OBJTYPE_GOLD:
            break;
        default:
            break;
        }
    }
    if( notover == TRUE ){
        CHAR_setInt(charaindex,CHAR_DIR,dir);
        retvalue = CHAR_WALKHITOBJECT;
    }else{
        for( i = 0 ; i < objbufindex ; i ++ ){
            typedef void (*PREOFUNC)(int,int);
            PREOFUNC   pfunc=NULL;
            int     objindex=objbuf[i];
            switch( OBJECT_getType(objindex) ){
            case OBJTYPE_CHARA:
                pfunc = (PREOFUNC)CHAR_getFunctionPointer(
                    OBJECT_getIndex(objindex),
                    CHAR_PREOVERFUNC);
                break;
            case OBJTYPE_ITEM:
                pfunc = (PREOFUNC)ITEM_getFunctionPointer(
                    OBJECT_getIndex(objindex),
                    ITEM_PREOVERFUNC);
                break;
            case OBJTYPE_GOLD:
                break;
            default:
                break;
            }
            if( pfunc )pfunc( OBJECT_getIndex(objindex),charaindex );
        }

        CHAR_setInt(charaindex,CHAR_X,fx);
        CHAR_setInt(charaindex,CHAR_Y,fy);
        CHAR_setInt(charaindex,CHAR_FLOOR,ff);
        CHAR_setInt(charaindex,CHAR_DIR,dir);

        {
            int objindex;
            int ox,oy,of;
            objindex = CHAR_getWorkInt( charaindex,CHAR_WORKOBJINDEX );
            of = OBJECT_setFloor(objindex,
                                 CHAR_getInt(charaindex,CHAR_FLOOR));
            ox = OBJECT_setX(objindex,CHAR_getInt(charaindex,CHAR_X));
            oy = OBJECT_setY(objindex,CHAR_getInt(charaindex,CHAR_Y));
            if( !MAP_objmove( objindex, of,ox,oy,ff,fx,fy ) ){
                /*  仇氏卅氏升丹仄方丹手卅中    */
                fprint( "ERROR MAP_OBJMOVE objindex=%d(%s)\n",objindex,
                	CHAR_getUseName( charaindex ) );
            }
        }

        CHAR_setInt(charaindex,CHAR_WALKCOUNT,
                    CHAR_getInt(charaindex,CHAR_WALKCOUNT) + 1 );


        for( i = 0 ; i < objbufindex ; i ++ ){
            typedef void (*POSTOFUNC)(int,int);
            POSTOFUNC   pfunc=NULL;
            int     objindex=objbuf[i];

            switch( OBJECT_getType(objindex) ){
            case OBJTYPE_CHARA:
                pfunc = (POSTOFUNC)CHAR_getFunctionPointer(
                    OBJECT_getIndex(objindex),
                    CHAR_POSTOVERFUNC);
                break;
            case OBJTYPE_ITEM:
                pfunc = (POSTOFUNC)ITEM_getFunctionPointer( OBJECT_getIndex(objindex), ITEM_POSTOVERFUNC);
                break;
            case OBJTYPE_GOLD:
                break;
            default:
                break;
            }
            if( pfunc )pfunc( OBJECT_getIndex(objindex),charaindex );
        }
        objbufindex = CHAR_getSameCoordinateObjects(objbuf, arraysizeof(objbuf), of, ox, oy );
        for( i=0 ;i<objbufindex;i++){
            typedef void (*OFFFUNC)(int,int);
            OFFFUNC   ofunc=NULL;
            int     objindex = objbuf[i];

            switch( OBJECT_getType( objindex ) ){
            case OBJTYPE_CHARA:
                ofunc = (OFFFUNC)CHAR_getFunctionPointer( OBJECT_getIndex(objindex), CHAR_OFFFUNC);
                break;
            case OBJTYPE_ITEM:
                /*    卞窒手仄卅中  */
                break;
            case OBJTYPE_GOLD:
                /*    卞窒手仄卅中  */
                break;
            default:
                break;
            }
            if( ofunc )ofunc( OBJECT_getIndex(objindex), charaindex );

        }
    }
CHAR_AFTERWALK:
    if( retvalue == CHAR_WALK1357 || retvalue == CHAR_WALKHITOBJECT ){
	    {
	        int     opt[2] = { ox, oy};
	        CHAR_sendWatchEvent( CHAR_getWorkInt(charaindex,
	                                             CHAR_WORKOBJINDEX),
	                             CHAR_ACTWALK,opt,2,TRUE );
	    }
        CHAR_setWorkChar( charaindex, CHAR_WORKWALKARRAY, "");
		if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) {
		    CHAR_sendWatchEvent( CHAR_getWorkInt(charaindex, CHAR_WORKOBJINDEX),
    		                     CHAR_ACTWARP,NULL,0,TRUE);
		}
    }else if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){

		BOOL	flg = FALSE;
		int		par;
		int		count;
		CHAR_setWorkInt( charaindex, CHAR_WORKACTION, -1 );
		if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE ){
			CHAR_sendCharaAtWalk( charaindex, of,ox,oy,CHAR_getDX(dir), CHAR_getDY(dir));
		}

	    {
	        int     opt[2] = { ox, oy};
	        CHAR_sendWatchEvent( CHAR_getWorkInt(charaindex,
	                                             CHAR_WORKOBJINDEX),
	                             CHAR_ACTWALK,opt,2,TRUE );
	    }
		if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_CLIENT ) {
			CHAR_sendMapAtWalk( charaindex, of,
								ox,oy,
								CHAR_getInt( charaindex, CHAR_X),
								CHAR_getInt( charaindex, CHAR_Y));
		}
		count = CHAR_getWorkInt( charaindex, CHAR_WORK_TOHELOS_COUNT);
		if( count > 0 ) {
			CHAR_setWorkInt( charaindex, CHAR_WORK_TOHELOS_COUNT, count -1);
			if( count -1 == 0 ) {
				CHAR_talkToCli( charaindex, -1, "道具的效力已到。", CHAR_COLORWHITE);
			}
		}
		par = ENCOUNT_getEncountPercentMin( charaindex, of,ox,oy);
		if( par != -1 ) {
			if( CHAR_getWorkInt( charaindex, CHAR_WORKENCOUNTPROBABILITY_MIN) != par ){
				flg = TRUE;
				CHAR_setWorkInt( charaindex, CHAR_WORKENCOUNTPROBABILITY_MIN, par);
			}
		}

		par = ENCOUNT_getEncountPercentMax( charaindex, of,ox,oy);
		if( par != -1 ) {
			if( CHAR_getWorkInt( charaindex, CHAR_WORKENCOUNTPROBABILITY_MAX) != par ){
				flg = TRUE;
				CHAR_setWorkInt( charaindex, CHAR_WORKENCOUNTPROBABILITY_MAX, par);
			}
		}
		// Arminius 7.12 login announce
		/*
		{
		  int enfd = getfdFromCharaIndex( charaindex );
		  if (CONNECT_get_announced(enfd)==0) {
		    // Robin 0720
		    //AnnounceToPlayer(charaindex);
		    AnnounceToPlayerWN( enfd );
		    CONNECT_set_announced(enfd,1);
		  }
		}
		*/
		// Arminius 6.22 check Encounter
		// Nuke 0622: Provide No Enemy function
		{
		  int enfd = getfdFromCharaIndex( charaindex );
		  int eqen = getEqNoenemy( enfd );	// Arminius 7.2: Ra's amulet
		  int noen = getNoenemy(enfd);

          // Arminius 7.31 cursed stone
      if (getStayEncount(enfd)>0) {
			  clearStayEncount(enfd);
		  }
		  //print("\n enfd=%d,eqen=%d,noen=%d", enfd, eqen, noen);

		  // Arminius 7.2 Ra's amulet
		  if (eqen>=200) {
		    noen=1;
		  } else if (eqen>=120) {
		    if ((ff==100)||(ff==200)||(ff==300)||(ff==400)||(ff==500)) noen=1;
		  } else if (eqen>=80) {
		    if ((ff==100)||(ff==200)||(ff==300)||(ff==400)) noen=1;
		  } else if (eqen>=40) {
		    if ((ff==100)||(ff==200)) noen=1;
		  }


		  //print("\n noen=%d", noen);
		  if (noen==0) {
				int maxep = CHAR_getWorkInt(charaindex, CHAR_WORKENCOUNTPROBABILITY_MAX);
		    int minep = CHAR_getWorkInt(charaindex, CHAR_WORKENCOUNTPROBABILITY_MIN);
		    int cep = CONNECT_get_CEP(enfd);

		    if (cep<minep) cep=minep;
		    if (cep>maxep) cep=maxep;
		    if (CHAR_getWorkInt(charaindex,CHAR_WORKBATTLEMODE)==BATTLE_CHARMODE_NONE) {
				int entflag=1;
				{
					int objindex,index;
					OBJECT obj;
					for ( obj = MAP_getTopObj( ff, fx, fy); obj; obj = NEXT_OBJECT( obj)) {
						objindex = GET_OBJINDEX( obj);
						if (OBJECT_getType( objindex) == OBJTYPE_CHARA) {
							int etype;
							index = OBJECT_getIndex( objindex);
							if (!CHAR_CHECKINDEX( index)) continue;
							if( CHAR_getInt( index, CHAR_WHICHTYPE) == CHAR_TYPENPCENEMY &&
								CHAR_getWorkInt( index, CHAR_WORKEVENTTYPE) == CHAR_EVENT_ENEMY )	{
								CHAR_setInt( charaindex, CHAR_X, ox);
								CHAR_setInt( charaindex, CHAR_Y, oy);
								lssproto_XYD_send( getfdFromCharaIndex(charaindex),
								CHAR_getInt( charaindex, CHAR_X ),
								CHAR_getInt( charaindex, CHAR_Y ),
								CHAR_getInt( charaindex, CHAR_DIR ) );
								break;
							}
							etype = CHAR_getWorkInt( index, CHAR_WORKEVENTTYPE);
							if (etype!=CHAR_EVENT_NONE) {
								if (etype==CHAR_EVENT_WARP) entflag=0;
							}
						}
					}
				}
#ifdef _ENEMY_ACTION
				if( rand()%(120*getEnemyAction()) < cep ){
#else
		      if (rand()%120<cep){	// Arminius 6.28 lower encounter prob.
#endif
					if (entflag) {
#ifdef _Item_MoonAct
						if( getEqRandenemy( enfd) > 0 )	{
							int Rnum=0;
							int RandEnemy = getEqRandenemy( enfd);
							Rnum = RAND(0,100);
							if( Rnum > RandEnemy )	{
#endif
								//encounter!!
								cep = minep;
								lssproto_EN_recv(enfd,
								CHAR_getInt(charaindex,CHAR_X),
								CHAR_getInt(charaindex,CHAR_Y));
#ifdef _Item_MoonAct
							}
						}else{
								cep = minep;
								lssproto_EN_recv(enfd,
								CHAR_getInt(charaindex,CHAR_X),
								CHAR_getInt(charaindex,CHAR_Y));
						}
#endif
					}
		      } else {
		        if (cep<maxep) cep++;
		      }
		    }
		    CONNECT_set_CEP(enfd, cep);
		  }
		}
		if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE )!= CHAR_PARTY_CLIENT ){
			CHAR_setFlg( charaindex, CHAR_ISWARP, 0);
		}
    }
    else if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ||