示例#1
0
//»¹Ô­ÌúǹÈþ¶Ñµþ
void NPC_reCheckItemPilenum( int meindex, int toindex)
{
	int i, itemindex;
	for( i=0; i<CHAR_MAXITEMHAVE; i++){
		itemindex = CHAR_getItemIndex( toindex , i );
		if( !ITEM_CHECKINDEX( itemindex) ) continue;//ITEM_USEPILENUMS
		if( ITEM_getInt( itemindex, ITEM_ID) != 20284 ) continue;
		if( ITEM_getInt( itemindex, ITEM_CANBEPILE) != 1 ) continue;

		if( ITEM_getInt( itemindex, ITEM_USEPILENUMS) > 1 ){
			int itemID, pilenum=1, newindex;
			itemID = ITEM_getInt( itemindex, ITEM_ID);
			if( !ITEM_CHECKITEMTABLE( itemID) ) continue;
			pilenum = ITEM_getInt( itemindex, ITEM_USEPILENUMS);
			while( pilenum > 1 ){
				int ti = CHAR_findEmptyItemBox( toindex);
				if( ti == -1 ){
					CHAR_sendItemDataOne( toindex, i);
					CHAR_talkToCli( toindex, -1, "µÀ¾ßÀ¸Î»ÒÑÂú¡£", CHAR_COLORYELLOW);
					return;
				}
				newindex = ITEM_makeItemAndRegist( itemID);
				if( !ITEM_CHECKINDEX( newindex) ) break;
				CHAR_setItemIndex( toindex , ti, newindex);
				CHAR_sendItemDataOne( toindex, ti);
				pilenum--;
				ITEM_setInt( itemindex, ITEM_USEPILENUMS, pilenum);
			}
			if( ITEM_getInt( itemindex, ITEM_CANBEPILE) != ITEMTBL_getInt( itemID, ITEM_CANBEPILE) )
				ITEM_setInt( itemindex, ITEM_CANBEPILE, ITEMTBL_getInt( itemID, ITEM_CANBEPILE) );
			CHAR_sendItemDataOne( toindex, i);
		}
	}
	CHAR_talkToCli( toindex, -1, "ÌúǹÈþ´¦ÀíÍê±Ï¡£", CHAR_COLORYELLOW);
}
示例#2
0
BOOL NPC_DepotItem_gettItem( int meindex, int talkerindex, int num)
{
	int emptyindex;
	int itemindex;

	if( !CHAR_CheckDepotItem( talkerindex) ) return FALSE;

	if( (emptyindex=CHAR_findEmptyItemBox( talkerindex)) == -1 ) return FALSE;
	itemindex = CHAR_getDepotItemIndex( talkerindex, num);
	if( !ITEM_CHECKINDEX( itemindex) )return FALSE;

	CHAR_setDepotItemIndex( talkerindex, num, -1);
	CHAR_setItemIndex( talkerindex, emptyindex, itemindex);
	CHAR_sendItemDataOne( talkerindex, emptyindex);
	
	CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD);

	LogItem(
		CHAR_getChar( talkerindex, CHAR_NAME ),
		CHAR_getChar( talkerindex, CHAR_CDKEY ),
#ifdef _add_item_log_name
		itemindex,
#else
		ITEM_getInt( itemindex, ITEM_ID),
#endif
		"Depot(取出道具)",
		CHAR_getInt( talkerindex,CHAR_FLOOR),
		CHAR_getInt( talkerindex,CHAR_X ),
 		CHAR_getInt( talkerindex,CHAR_Y ),
		ITEM_getChar( itemindex, ITEM_UNIQUECODE),
		ITEM_getChar( itemindex, ITEM_NAME),
		ITEM_getInt( itemindex, ITEM_ID) );

	{
		int i, cnt=0;
		int work[CHAR_MAXDEPOTITEMHAVE];
		for( i = 0; i < CHAR_MAXDEPOTITEMHAVE; i ++ ) {
			work[i] = -1;
		}
		for( i = 0; i < CHAR_MAXDEPOTITEMHAVE; i ++ ) {
			itemindex = CHAR_getDepotItemIndex( talkerindex, i);
			if( !ITEM_CHECKINDEX( itemindex)) continue;
			work[ cnt++] = itemindex;
		}
		for( i = 0; i < CHAR_MAXDEPOTITEMHAVE; i ++ ) {
			CHAR_setDepotItemIndex( talkerindex, i, work[i]);
		}
	}


	return TRUE;
}
static BOOL NPC_PoolItemShop_DrawItem( int meindex, int talkerindex, int num)
{
	int emptyindex;
	int itemindex;
	int i;
	int cnt;
	int work[CHAR_MAXPOOLITEMHAVE];

	emptyindex = CHAR_findEmptyItemBox( talkerindex);
	if( emptyindex == -1 ) return FALSE;
	
	itemindex = CHAR_getPoolItemIndex( talkerindex, num);
	if( !ITEM_CHECKINDEX( itemindex)) {
		fprint( "err\n");
		return FALSE;
	}
	CHAR_setItemIndex( talkerindex, emptyindex, itemindex);
	CHAR_setPoolItemIndex( talkerindex, num, -1);
	CHAR_sendItemDataOne( talkerindex, emptyindex);
	for( i = 0; i < CHAR_MAXPOOLITEMHAVE; i ++ ) {
		work[i] = -1;
	}
	cnt = 0;
	for( i = 0; i < CHAR_MAXPOOLITEMHAVE; i ++ ) {
		itemindex = CHAR_getPoolItemIndex( talkerindex, i);
		if( ITEM_CHECKINDEX( itemindex)) {
			work[ cnt++] = itemindex;
		}
	}
	for( i = 0; i < CHAR_MAXPOOLITEMHAVE; i ++ ) {
		CHAR_setPoolItemIndex( talkerindex, i, work[i]);
	}
	LogItem(
		CHAR_getChar( talkerindex, CHAR_NAME ),
		CHAR_getChar( talkerindex, CHAR_CDKEY ),
#ifdef _add_item_log_name  // WON ADD 在item的log中增加item名稱
		itemindex,
#else
		ITEM_getInt( itemindex, ITEM_ID),
#endif
		"draw(領取道具)",
		CHAR_getInt( talkerindex,CHAR_FLOOR),
		CHAR_getInt( talkerindex,CHAR_X ),
 		CHAR_getInt( talkerindex,CHAR_Y ),
		ITEM_getChar( itemindex, ITEM_UNIQUECODE),
		ITEM_getChar( itemindex, ITEM_NAME),
		ITEM_getInt( itemindex, ITEM_ID)
	);
	return TRUE;
}
示例#4
0
BOOL NPC_Util_createItemToChar( int charindex, int itemid , BOOL net)
{
    int emptyitemindexinchara, itemindex;
    emptyitemindexinchara = CHAR_findEmptyItemBox( charindex );

    if( emptyitemindexinchara < 0 )return FALSE;
	itemindex = ITEM_makeItemAndRegist( itemid );
    if( itemindex != -1 ){
        CHAR_setItemIndex( charindex, emptyitemindexinchara, itemindex );
        ITEM_setWorkInt(itemindex, ITEM_WORKOBJINDEX,-1);
        ITEM_setWorkInt(itemindex, ITEM_WORKCHARAINDEX,charindex);

        if(net) {
        	CHAR_sendItemDataOne( charindex, emptyitemindexinchara);
        }
        return TRUE;
    }
    return FALSE;
}
示例#5
0
BOOL NPC_Util_moveItemToChar(int charindex, int itemindex, BOOL net)
{
	int emptyindex, oind, cind;
	emptyindex = CHAR_findEmptyItemBox(charindex);
	if (emptyindex < 0)
		return FALSE;

	if (!ITEM_CHECKINDEX(itemindex))
		return FALSE;
	oind = ITEM_getWorkInt(itemindex, ITEM_WORKOBJINDEX);
	cind = ITEM_getWorkInt(itemindex, ITEM_WORKCHARAINDEX);

	if (oind >= 0) {
		CHAR_ObjectDelete(oind);
		CHAR_setItemIndex(charindex, emptyindex, itemindex);
		ITEM_setWorkInt(itemindex, ITEM_WORKOBJINDEX, -1);
		ITEM_setWorkInt(itemindex, ITEM_WORKCHARAINDEX, charindex);
		if (net)
			CHAR_sendItemDataOne(charindex, emptyindex);
		return TRUE;
	} else if (cind >= 0) {
		int itemgrp[2];
		int itemindexinchara;
		if (cind == charindex)
			return FALSE;
		itemindexinchara = NPC_Util_SearchItemInChar(cind, itemindex);
		if (itemindexinchara == -1)
			return FALSE;
		CHAR_setItemIndex(cind, itemindexinchara, -1);
		CHAR_complianceParameter(cind);
		itemgrp[0] = itemindexinchara;
		CHAR_setItemIndex(charindex, emptyindex, itemindex);
		itemgrp[1] = emptyindex;
		if (net)
			CHAR_sendItemData(charindex, itemgrp,
					  arraysizeof(itemgrp));
		ITEM_setWorkInt(itemindex, ITEM_WORKOBJINDEX, -1);
		ITEM_setWorkInt(itemindex, ITEM_WORKCHARAINDEX, charindex);
		return TRUE;
	}
	return FALSE;
}
BOOL NPC_DepotItem_gettItem( int meindex, int talkerindex, int num)
{
	int emptyindex;
	int itemindex;

	if( !CHAR_CheckDepotItem( talkerindex) ) return FALSE;

	if( (emptyindex=CHAR_findEmptyItemBox( talkerindex)) == -1 ) return FALSE;
	itemindex = CHAR_getDepotItemIndex( talkerindex, num);
	if( !ITEM_CHECKINDEX( itemindex) )return FALSE;
#ifdef _JZ_CF_DELPETITEM
	int ID1,ID2,j;
	ID1 = ITEM_getInt( itemindex, ITEM_ID);
	for( j=0;j<5;j++ ) {
		ID2 = getDelItem(j);
		if(ID2 == 0)break;
		if( ID1 == ID2){
			CHAR_setDepotItemIndex( talkerindex, num, -1);
			LogItem(CHAR_getChar( talkerindex, CHAR_NAME ), //人物名
							CHAR_getChar( talkerindex, CHAR_CDKEY ), //帳號
#ifdef _add_item_log_name  // WON ADD 在item的log中增加item名稱
							itemindex,
#else
      				ITEM_getInt( itemindex, ITEM_ID ),
#endif
							"poolitemshop(CF設置清除物品)",
							CHAR_getInt( talkerindex,CHAR_FLOOR),
							CHAR_getInt( talkerindex,CHAR_X ),
 	     				CHAR_getInt( talkerindex,CHAR_Y ),
           		ITEM_getChar( itemindex, ITEM_UNIQUECODE),
							ITEM_getChar( itemindex, ITEM_NAME),
							ITEM_getInt( itemindex, ITEM_ID)
							);
			CHAR_talkToCli( talkerindex, -1, "系統清除你倉庫裡的道具", CHAR_COLORWHITE );
			return TRUE;
		}
	}
#endif
	CHAR_setDepotItemIndex( talkerindex, num, -1);
	CHAR_setItemIndex( talkerindex, emptyindex, itemindex);
	CHAR_sendItemDataOne( talkerindex, emptyindex);
	
	CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD);

	LogItem(
		CHAR_getChar( talkerindex, CHAR_NAME ),
		CHAR_getChar( talkerindex, CHAR_CDKEY ),
#ifdef _add_item_log_name
		itemindex,
#else
		ITEM_getInt( itemindex, ITEM_ID),
#endif
		"Depot(取出道具)",
		CHAR_getInt( talkerindex,CHAR_FLOOR),
		CHAR_getInt( talkerindex,CHAR_X ),
 		CHAR_getInt( talkerindex,CHAR_Y ),
		ITEM_getChar( itemindex, ITEM_UNIQUECODE),
		ITEM_getChar( itemindex, ITEM_NAME),
		ITEM_getInt( itemindex, ITEM_ID) );

	{
		int i, cnt=0;
		int work[CHAR_MAXDEPOTITEMHAVE];
		for( i = 0; i < CHAR_MAXDEPOTITEMHAVE; i ++ ) {
			work[i] = -1;
		}
		for( i = 0; i < CHAR_MAXDEPOTITEMHAVE; i ++ ) {
			itemindex = CHAR_getDepotItemIndex( talkerindex, i);
			if( !ITEM_CHECKINDEX( itemindex)) continue;
			work[ cnt++] = itemindex;
		}
		for( i = 0; i < CHAR_MAXDEPOTITEMHAVE; i ++ ) {
			CHAR_setDepotItemIndex( talkerindex, i, work[i]);
		}
	}


	return TRUE;
}
void NPC_PoolItemShopWindowTalked( int meindex, int talkerindex, 
								int seqno, int select, char *data)
{
	if( NPC_Util_CharDistance( talkerindex, meindex ) > 2) return;

	//print("\n NPC_PoolItemShopWindowTalked: seq:%d sel:%d data:%s", seqno, select, data);

	switch( seqno ) {
	  case CHAR_WINDOWTYPE_POOLITEMSHOP_START:
		switch( atoi( data)) {
		  case 1:
			if( CHAR_getCharPoolItemIndexElement( talkerindex) != -1 ) {
				NPC_PoolItemShop_printWindow_Pool( meindex, talkerindex);
			}else {
				NPC_PoolItemShop_printWindow_Full( meindex, talkerindex);
			}
			break;
		  case 2:
			if( CHAR_findEmptyItemBox( talkerindex) != -1 ) {
				NPC_PoolItemShop_printWindow_Draw( meindex, talkerindex);
			}else {
				NPC_PoolItemShop_printWindow_HaveItemFull( meindex, talkerindex);
			}
			break;
#ifdef _NPC_DEPOTITEM
		  case 3:
			if( !CHAR_CheckDepotItem( talkerindex) ){
				CHAR_GetDepotItem( meindex, talkerindex);
				CHAR_talkToCli( talkerindex, -1, "取得道具,請稍後!", CHAR_COLORYELLOW);
			}else{
				NPC_PoolItemShop_DepotItem_Menu( meindex, talkerindex);
			}
			break;
#endif

		}
		break;
	  case CHAR_WINDOWTYPE_POOLITEMSHOP_POOL_MSG:
	  	if( atoi( data) == 0){
			NPC_PoolItemShop_printWindow_Start( meindex, talkerindex);
	  	}else {
			NPC_PoolItemShop_PoolItem( meindex, talkerindex, atoi(data)-1);
		}
		break;
	  case CHAR_WINDOWTYPE_POOLITEMSHOP_DRAW_MSG:
	  	if( atoi( data) == 0){
			NPC_PoolItemShop_printWindow_Start( meindex, talkerindex);
	  	}else {
		  	NPC_PoolItemShop_DrawItem( meindex, talkerindex, atoi(data)-1);
		}
	  	break;
	  case CHAR_WINDOWTYPE_POOLITEMSHOP_FULL_MSG:
		NPC_PoolItemShop_printWindow_Start( meindex, talkerindex);
	  	break;
	  case CHAR_WINDOWTYPE_POOLITEMSHOP_HAVEITEMFULL_MSG:
		NPC_PoolItemShop_printWindow_Start( meindex, talkerindex);
	  	break;

#ifdef _NPC_DEPOTITEM
	  case CHAR_WINDOWTYPE_DEPOTITEMSHOP_MENU:
			if( !CHAR_CheckDepotItem( talkerindex) ){
				CHAR_GetDepotItem( meindex, talkerindex);
				return;
			}else{
				NPC_PoolItemShop_DepotItem_Menu( meindex, talkerindex);
			}
		  break;
	  case CHAR_WINDOWTYPE_DEPOTITEMSHOP_HANDLE:
		  if( !CHAR_CheckDepotItem( talkerindex) ) return ;
		  switch( atoi( data)) {
		  case 1://放入
				if( CHAR_findEmptyDepotItem( talkerindex) == -1 ){
					CHAR_talkToCli( talkerindex, -1, "倉庫已滿!", CHAR_COLORYELLOW);
					return;
				}
				NPC_DepotItem_Item_printWindow( meindex, talkerindex);
			  break;
		  case 2:
				if( CHAR_findEmptyItemBox( talkerindex) == -1 ) {
					CHAR_talkToCli( talkerindex, -1, "身上道具欄位已滿!", CHAR_COLORYELLOW);
					return;
				}
				NPC_DepotItem_Depot_printWindow( meindex, talkerindex);
			  break;
		  }
		  break;
	  case CHAR_WINDOWTYPE_DEPOTITEMSHOP_ADD://放入
			if( !CHAR_CheckDepotItem( talkerindex) ) return ;
			if( atoi( data) == 0){
				NPC_PoolItemShop_DepotItem_Menu( meindex, talkerindex);
			}else {
				if( NPC_DepotItem_InsertItem( meindex, talkerindex, atoi( data)-1) == FALSE ){
					NPC_PoolItemShop_DepotItem_Menu( meindex, talkerindex);
					CHAR_talkToCli( talkerindex, -1, "存放道具失敗,請稍後再試!", CHAR_COLORYELLOW);
				}
			}
		  break;
	  case CHAR_WINDOWTYPE_DEPOTITEMSHOP_GET:
			if( !CHAR_CheckDepotItem( talkerindex) ) return ;
			if( atoi( data) == 0){
				NPC_PoolItemShop_DepotItem_Menu( meindex, talkerindex);
			}else {
				if( NPC_DepotItem_gettItem( meindex, talkerindex, atoi( data)-1) == FALSE ){
					NPC_PoolItemShop_DepotItem_Menu( meindex, talkerindex);
					CHAR_talkToCli( talkerindex, -1, "取出道具失敗,請稍後再試!", CHAR_COLORYELLOW);
				}
			}
		  break;
#endif
  
	  default:
		break;
	}
}
示例#8
0
/*
 * 既存のアイテムをあるキャラに持たせる。
 * もちものがいっぱいかどうか、スキルの判定、等は
 * この関数の中でやる。
 * 
 * int charindex:もたせるキャラのキャラindex
 * int itemindex:もたせるアイテムのアイテムindex
 * BOOL net:    この関数にネットワークやらせる TRUEにする事。
 * 返り値:無事持たせれたらTRUE,なんらかの原因で持たせれなかったらFALSE
 *  
 * by nakamura
 *
 *  この関数の中で、キャラが持っているものだったら持ちものから外す、
 * 地面に置いてあるものだったら置いてなくする、という処理もしてしまう
 * ようにした。
 * by ringo
 *
 * some bug fix.( ITEM_setWorkInt etc.)
 *  by taka
 *
 * 現在の仕様。
 *  o   itemindex のアイテムが自分の持っているアイテムであったら、
 *      return FALSE する
 */
BOOL NPC_Util_moveItemToChar( int charindex, int itemindex,BOOL net )
{
    int emptyindex, oind ,cind;
    emptyindex = CHAR_findEmptyItemBox( charindex );
    if(  emptyindex < 0 )
        /*  アイテム欄に空きがない  */
        return FALSE;

    if( !ITEM_CHECKINDEX( itemindex ) )return FALSE;
        
    /* 持たせる空きはある   */
    /*
     * 次に地形に落ちているアイテムか、それとも、
     * 誰かが持っているアイテムかを調べる
     */
    oind = ITEM_getWorkInt( itemindex , ITEM_WORKOBJINDEX );
    cind = ITEM_getWorkInt( itemindex , ITEM_WORKCHARAINDEX );

    if( oind >= 0 ){
        /* 地形に置かれているものだ。 */
        /* 地形から抹消 */
        CHAR_ObjectDelete( oind );

        /*  アイテムを移動  */
        CHAR_setItemIndex( charindex, emptyindex, itemindex );

        /*  アイテムのWork領域を書きかえる  */
        ITEM_setWorkInt( itemindex, ITEM_WORKOBJINDEX, -1 );
        ITEM_setWorkInt( itemindex, ITEM_WORKCHARAINDEX, charindex );

        /*  charindex がプレイヤーだったらアイテム変更ステータス送信    */
        if( net )            CHAR_sendStatusString( charindex, "I");

        return TRUE;

    }else if( cind >= 0 ){
        /* キャラクタが持っているものだ。 */
        int itemindexinchara;

        /*  自分が持っている場合には何もしない  */
        if( cind == charindex )return FALSE;

        /* もってるものを消す */
        itemindexinchara = NPC_Util_SearchItemInChar( cind , itemindex);
        if( itemindexinchara == -1 )return FALSE;

        CHAR_setItemIndex( cind , itemindexinchara , -1 );
        if( itemindexinchara == CHAR_ARM1
            && CHAR_getItemIndex( cind,CHAR_ARM2 )== -2){
            CHAR_setItemIndex(cind,CHAR_ARM2,-1);
        }
        CHAR_complianceParameter(cind);
        if( net ) CHAR_sendStatusString( cind,"I");
            
        /* アイテムを持たせる */
        CHAR_setItemIndex( charindex , emptyindex , itemindex );
        if( net )  CHAR_sendStatusString( charindex,"I");

        /*  アイテムのWork領域を書きかえる  */
        ITEM_setWorkInt( itemindex, ITEM_WORKOBJINDEX, -1 );
        ITEM_setWorkInt( itemindex, ITEM_WORKCHARAINDEX, charindex );

        return TRUE; /* fixed by nakamura(なんもreturnしてなかった) */
            
    }
    return FALSE;
}
示例#9
0
void NPC_FmLetterWindowTalked( int meindex, int talkerindex, 
								int seqno, int select, char *data)

{
	
	
	int		button = -1;
	char	buf[512];

	/* ㄠ弘伉永玉動  及心 */
	if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) return;
	
	/* 仇及它奴件玉它  寞及犯□正毛  心  戈 */	
	if( !NPC_FmLetter_readData( meindex, seqno - 100, FALSE) ) {
		print( "fmletter:readdata error\n");
		return;
	}
	/* 瓷仄凶示正件毛譬屯月 */
	if( w.windowtype == WINDOW_MESSAGETYPE_SELECT ) {
		button = atoi( data)+5;
		if( button > 12 ) {
			print( "fmletter:invalid button[%d]\n", button);
			return;
		}
	}
	else if( select & WINDOW_BUTTONTYPE_OK) button = 0;
	else if( select & WINDOW_BUTTONTYPE_CANCEL) button = 1;
	else if( select & WINDOW_BUTTONTYPE_YES) button = 2;
	else if( select & WINDOW_BUTTONTYPE_NO) button = 3;
	else if( select & WINDOW_BUTTONTYPE_PREV) button = 4;
	else if( select & WINDOW_BUTTONTYPE_NEXT) button = 5;
	else {
		print( "fmletter:invalid button[%d]\n", select);
		return;
	}
	if( buttonproc[button].use == TRUE ) {
		int	fd;
		int	newwin = -1;
	
		fd = getfdFromCharaIndex( talkerindex);
		
		/* 示正件卞方勻化質  毛孔曰歹仃月 */
		if( newwin == -1 ) {
			newwin = buttonproc[button].gotowin;
		}
		
		
		// Robin
		if( newwin == 5 )	{
			int	emptyitemindexinchara = CHAR_findEmptyItemBox( talkerindex );
			int	itemindex = ITEM_makeItemAndRegist( w.letter );

			if( emptyitemindexinchara < 0 )	return;

			if( itemindex != -1 ){
				char    msgbuf[128];
				CHAR_setItemIndex( talkerindex, emptyitemindexinchara, itemindex );
				/*  Work犯□正毛澀爛    */
				ITEM_setWorkInt(itemindex, ITEM_WORKOBJINDEX,-1);
				ITEM_setWorkInt(itemindex, ITEM_WORKCHARAINDEX, talkerindex);
				CHAR_sendItemDataOne( talkerindex, emptyitemindexinchara);
				LogItem(
					CHAR_getChar( talkerindex, CHAR_NAME ), /* 平乓仿   */
					CHAR_getChar( talkerindex, CHAR_CDKEY ),
#ifdef _add_item_log_name  // WON ADD 在item的log中增加item名稱
					itemindex,
#else
					ITEM_getInt( itemindex, ITEM_ID ),  /* 失奶  丞  寞 */
#endif
					"AddLetter(製作邀請函)",
					CHAR_getInt( talkerindex,CHAR_FLOOR),
					CHAR_getInt( talkerindex,CHAR_X ),
					CHAR_getInt( talkerindex,CHAR_Y ),
					ITEM_getChar( itemindex, ITEM_UNIQUECODE),
					ITEM_getChar( itemindex, ITEM_NAME),
					ITEM_getInt( itemindex, ITEM_ID)
				);
				snprintf( msgbuf, sizeof( msgbuf), "製作%s成功\。",
					ITEM_getChar( itemindex, ITEM_NAME));
				CHAR_talkToCli( talkerindex, -1,msgbuf, CHAR_COLORWHITE);
			}
		}

		// Robin
		if( newwin == 6 )	{
			int	emptyitemindexinchara = CHAR_findEmptyItemBox( talkerindex );
			int	itemindex = ITEM_makeItemAndRegist( w.letter );

			if( emptyitemindexinchara < 0 )	return;

			if( itemindex != -1 ){
				char    msgbuf[128];
				CHAR_setItemIndex( talkerindex, emptyitemindexinchara, itemindex );
				/*  Work犯□正毛澀爛    */
				ITEM_setWorkInt(itemindex, ITEM_WORKOBJINDEX,-1);
				ITEM_setWorkInt(itemindex, ITEM_WORKCHARAINDEX, talkerindex);
				CHAR_sendItemDataOne( talkerindex, emptyitemindexinchara);
				LogItem(
					CHAR_getChar( talkerindex, CHAR_NAME ), /* 平乓仿   */
					CHAR_getChar( talkerindex, CHAR_CDKEY ),
#ifdef _add_item_log_name  // WON ADD 在item的log中增加item名稱
					itemindex,
#else
					ITEM_getInt( itemindex, ITEM_ID ),  /* 失奶  丞  寞 */
#endif
					"AddLetter(製作邀請函)",
					CHAR_getInt( talkerindex,CHAR_FLOOR),
					CHAR_getInt( talkerindex,CHAR_X ),
					CHAR_getInt( talkerindex,CHAR_Y ),
					ITEM_getChar( itemindex, ITEM_UNIQUECODE),
					ITEM_getChar( itemindex, ITEM_NAME),
					ITEM_getInt( itemindex, ITEM_ID)
				);
				snprintf( msgbuf, sizeof( msgbuf), "製作%s成功\。",
					ITEM_getChar( itemindex, ITEM_NAME));
				CHAR_talkToCli( talkerindex, -1,msgbuf, CHAR_COLORWHITE);
			}
		}

				
		if( !NPC_FmLetter_readData( meindex, newwin, FALSE) ) {
			print( "fmletter:readdata error\n");
			return;
		}		

		//fd = getfdFromCharaIndex( talkerindex);
		if( fd != -1 ) {
			lssproto_WN_send( fd, w.windowtype, 
							w.buttontype,
							w.windowno+100,
							CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX),
							makeEscapeString( w.message, buf, sizeof(buf)));
		}
		
		
		
	}
}
示例#10
0
void NPC_FmLetterWindowTalked( int meindex, int talkerindex, 
								int seqno, int select, char *data)

{
	
	
	int		button = -1;
	char	buf[512];

	/* £±¥°¥ê¥Ã¥É°Ê  ¤Î¤ß */
	if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) return;
	
	/* ¤³¤Î¥¦¥£¥ó¥É¥¦  ¹æ¤Î¥Ç¡¼¥¿¤ò  ¤ß  ¤à */	
	if( !NPC_FmLetter_readData( meindex, seqno - 100, FALSE) ) {
		print( "fmletter:readdata error\n");
		return;
	}
	/* ²¡¤·¤¿¥Ü¥¿¥ó¤òÄ´¤Ù¤ë */
	if( w.windowtype == WINDOW_MESSAGETYPE_SELECT ) {
		button = atoi( data)+5;
		if( button > 12 ) {
			print( "fmletter:invalid button[%d]\n", button);
			return;
		}
	}
	else if( select & WINDOW_BUTTONTYPE_OK) button = 0;
	else if( select & WINDOW_BUTTONTYPE_CANCEL) button = 1;
	else if( select & WINDOW_BUTTONTYPE_YES) button = 2;
	else if( select & WINDOW_BUTTONTYPE_NO) button = 3;
	else if( select & WINDOW_BUTTONTYPE_PREV) button = 4;
	else if( select & WINDOW_BUTTONTYPE_NEXT) button = 5;
	else {
		print( "fmletter:invalid button[%d]\n", select);
		return;
	}
	if( buttonproc[button].use == TRUE ) {
		int	fd;
		int	newwin = -1;
	
		fd = getfdFromCharaIndex( talkerindex);
		
		/* ¥Ü¥¿¥ó¤Ë¤è¤Ã¤Æ½è  ¤ò¤Õ¤ê¤ï¤±¤ë */
		if( newwin == -1 ) {
			newwin = buttonproc[button].gotowin;
		}
		
		
		// Robin
		if( newwin == 5 )	{
			int	emptyitemindexinchara = CHAR_findEmptyItemBox( talkerindex );
			int	itemindex = ITEM_makeItemAndRegist( w.letter );

			if( emptyitemindexinchara < 0 )	return;

			if( itemindex != -1 ){
				char    msgbuf[128];
				CHAR_setItemIndex( talkerindex, emptyitemindexinchara, itemindex );
				/*  Work¥Ç¡¼¥¿¤òÀßÄê    */
				ITEM_setWorkInt(itemindex, ITEM_WORKOBJINDEX,-1);
				ITEM_setWorkInt(itemindex, ITEM_WORKCHARAINDEX, talkerindex);
				CHAR_sendItemDataOne( talkerindex, emptyitemindexinchara);
				LogItem(
					CHAR_getChar( talkerindex, CHAR_NAME ), /* ¥­¥ã¥é   */
					CHAR_getChar( talkerindex, CHAR_CDKEY ),
#ifdef _add_item_log_name  // WON ADD ¦bitemªºlog¤¤¼W¥[item¦WºÙ
					itemindex,
#else
					ITEM_getInt( itemindex, ITEM_ID ),  /* ¥¢¥¤  ¥à  ¹æ */
#endif
					"AddLetter(»s§@ÁܽШç)",
					CHAR_getInt( talkerindex,CHAR_FLOOR),
					CHAR_getInt( talkerindex,CHAR_X ),
					CHAR_getInt( talkerindex,CHAR_Y ),
					ITEM_getChar( itemindex, ITEM_UNIQUECODE),
					ITEM_getChar( itemindex, ITEM_NAME),
					ITEM_getInt( itemindex, ITEM_ID)
				);
				snprintf( msgbuf, sizeof( msgbuf), "»s§@%s¦¨¥\\¡C",
					ITEM_getChar( itemindex, ITEM_NAME));
				CHAR_talkToCli( talkerindex, -1,msgbuf, CHAR_COLORWHITE);
			}
		}

		// Robin
		if( newwin == 6 )	{
			int	emptyitemindexinchara = CHAR_findEmptyItemBox( talkerindex );
			int	itemindex = ITEM_makeItemAndRegist( w.letter );

			if( emptyitemindexinchara < 0 )	return;

			if( itemindex != -1 ){
				char    msgbuf[128];
				CHAR_setItemIndex( talkerindex, emptyitemindexinchara, itemindex );
				/*  Work¥Ç¡¼¥¿¤òÀßÄê    */
				ITEM_setWorkInt(itemindex, ITEM_WORKOBJINDEX,-1);
				ITEM_setWorkInt(itemindex, ITEM_WORKCHARAINDEX, talkerindex);
				CHAR_sendItemDataOne( talkerindex, emptyitemindexinchara);
				LogItem(
					CHAR_getChar( talkerindex, CHAR_NAME ), /* ¥­¥ã¥é   */
					CHAR_getChar( talkerindex, CHAR_CDKEY ),
#ifdef _add_item_log_name  // WON ADD ¦bitemªºlog¤¤¼W¥[item¦WºÙ
					itemindex,
#else
					ITEM_getInt( itemindex, ITEM_ID ),  /* ¥¢¥¤  ¥à  ¹æ */
#endif
					"AddLetter(»s§@ÁܽШç)",
					CHAR_getInt( talkerindex,CHAR_FLOOR),
					CHAR_getInt( talkerindex,CHAR_X ),
					CHAR_getInt( talkerindex,CHAR_Y ),
					ITEM_getChar( itemindex, ITEM_UNIQUECODE),
					ITEM_getChar( itemindex, ITEM_NAME),
					ITEM_getInt( itemindex, ITEM_ID)
				);
				snprintf( msgbuf, sizeof( msgbuf), "»s§@%s¦¨¥\\¡C",
					ITEM_getChar( itemindex, ITEM_NAME));
				CHAR_talkToCli( talkerindex, -1,msgbuf, CHAR_COLORWHITE);
			}
		}

				
		if( !NPC_FmLetter_readData( meindex, newwin, FALSE) ) {
			print( "fmletter:readdata error\n");
			return;
		}		

		//fd = getfdFromCharaIndex( talkerindex);
		if( fd != -1 ) {
			lssproto_WN_send( fd, w.windowtype, 
							w.buttontype,
							w.windowno+100,
							CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX),
							makeEscapeString( w.message, buf, sizeof(buf)));
		}
		
		
		
	}
}
void ITEM_contractSign( int fd, int itemindex, int signindex)
{
	int charaindex;
	int i;
	int conIndex;
	int complete =0;
	int item_id;
	char contractSignData[512];
	contractSignTag contractSign[4];

	print("\n contractSign:%d:%d ", itemindex, signindex);
	
	charaindex = CONNECT_getCharaindex( fd );
	if( !CHAR_CHECKINDEX(charaindex))	return;

	if( signindex <0 || signindex >=4)	return;
    for( i=0 ; i<CHAR_MAXITEMHAVE ; i++ ){
        if( CHAR_getItemIndex( charaindex,i ) == itemindex )
			break;
	}
	if( i >= CHAR_MAXITEMHAVE )	return;
	if( strcmp( ITEM_getChar( itemindex, ITEM_USEFUNC), "ITEM_contract") )	return;
	
	conIndex = atoi( ITEM_getChar( itemindex, ITEM_ARGUMENT));
	if( signindex >= ITEM_contractTbl[conIndex].argnum )	return;

	strcpy( contractSignData, ITEM_getChar( itemindex, ITEM_CONTRACTARG) );

	for( i=0; i<4; i++) contractSign[i].used = FALSE;

	for( i=0; i<4; i++) {
		int index;
		char buf[512];
		char token[32];
		if( getStringFromIndexWithDelim( contractSignData, ",", i+1, buf, sizeof( buf )-1) == FALSE )
			break;
		if( strlen( buf) == 0)	break;
		getStringFromIndexWithDelim( buf, ":", 1, token, sizeof( token )-1 );
		index = atoi( token);
		if( index <0 || index >=4)	break;
		getStringFromIndexWithDelim( buf, ":", 2, contractSign[index].name, sizeof( contractSign[index].name )-1 );
		getStringFromIndexWithDelim( buf, ":", 3, contractSign[index].fmname, sizeof( contractSign[index].fmname )-1 );
		contractSign[index].used = TRUE;
	}

	if( contractSign[signindex].used == TRUE)	return;
	
	strcpy( contractSign[signindex].name, CHAR_getChar( charaindex, CHAR_NAME) );
	strcpy( contractSign[signindex].fmname, CHAR_getChar( charaindex, CHAR_FMNAME) );
	contractSign[signindex].used = TRUE;

	// 檢查是否完成契約
	for( i =0; i<4; i++) {
		if( contractSign[i].used == TRUE)
			complete++;
	}
	if( complete >= ITEM_contractTbl[conIndex].argnum ) {
		char buf[512];
		if( CHAR_findEmptyItemBoxNo( charaindex ) < ITEM_contractTbl[conIndex].argnum -1 ) {
			sprintf( buf, "要完成這個契約,請先準備%d個空道具欄位。", ITEM_contractTbl[conIndex].argnum -1);
			CHAR_talkToCli( charaindex, -1, buf, CHAR_COLORYELLOW);
			return;
		}
	}


	strcpy( contractSignData, "");
	for( i=0; i<4; i++) {
		char buf[512];
		if( contractSign[i].used == FALSE)	continue;
		sprintf( buf, "%d:%s:%s,", i, contractSign[i].name, contractSign[i].fmname);
		strcat( contractSignData, buf);
	}
	ITEM_setChar( itemindex, ITEM_CONTRACTARG, contractSignData);

	CHAR_talkToCli( charaindex, -1, "完成契約簽名。", CHAR_COLORYELLOW);


	// 完成契約
	if( complete >= ITEM_contractTbl[conIndex].argnum ) {
		struct tm *nowtime;
		char timebuf[512];

		// 紀錄日期
		nowtime = localtime( (time_t *)&NowTime.tv_sec );
		sprintf( timebuf, "%04d年%02d月%02d日",
			nowtime->tm_year +1900, nowtime->tm_mon+1, nowtime->tm_mday);
		ITEM_setChar( itemindex, ITEM_CONTRACTTIME, timebuf);

		CHAR_talkToCli( charaindex, -1, "完成所有簽名,契約成立!", CHAR_COLORYELLOW);
		// 複製契約
		item_id = ITEM_getInt( itemindex, ITEM_ID);
		for( i =0 ; i < ITEM_contractTbl[conIndex].argnum -1 ; i++)
		{
			int	emptyindex;
			int newitemindex;
			
			emptyindex = CHAR_findEmptyItemBox( charaindex );
			
			if( emptyindex < 0 ){
				CHAR_talkToCli( charaindex, -1, "空間欄位不足。", CHAR_COLORYELLOW);
				break;
			}
			
			newitemindex = ITEM_makeItemAndRegist( item_id );
			
			if( newitemindex != -1 ){
				CHAR_setItemIndex( charaindex, emptyindex, newitemindex );
				ITEM_setWorkInt( newitemindex, ITEM_WORKOBJINDEX, -1);
				ITEM_setWorkInt( newitemindex, ITEM_WORKCHARAINDEX, charaindex);
				CHAR_sendItemDataOne( charaindex, emptyindex);
				ITEM_setChar( newitemindex, ITEM_CONTRACTARG, contractSignData);
				ITEM_setChar( newitemindex, ITEM_CONTRACTTIME, timebuf);
			}
			
			CHAR_talkToCli( charaindex, -1, "複製契約書。", CHAR_COLORYELLOW);
		}
	}
}