Exemplo n.º 1
0
void NPC_reCheckMyPetUnusual( int meindex, int toindex)//¼ì²é³èÎïÒì³£
{
	char *buf=NULL;
	int petindex,i;
	for( i=0; i<CHAR_MAXPETHAVE; i++)	{
		petindex = CHAR_getCharPet( toindex, i);
		if( !CHAR_CHECKINDEX( petindex) )continue;
		if( (buf=CHAR_getChar( petindex, CHAR_NAME)) == NULL ||
			strlen( buf) <= 0 ){
			char *PetNAME;
			int array, parry, petID;

			petID = CHAR_getInt( petindex, CHAR_PETID);
			array = ENEMY_getEnemyArrayFromTempNo( petID);

			if( !ENEMY_CHECKINDEX( array)){
				print("ANDY Pet(ID:%d) err Array:%d (file:%s %d) !! \n",
					petID, array, __FILE__, __LINE__ );
				continue;
			}
			parry = ENEMYTEMP_getEnemyTempArray( array);
			if( (PetNAME = ENEMYTEMP_getChar( parry, E_T_NAME)) == NULL ||
				strlen( PetNAME) <= 0 ){
				print("ANDY Pet(ID:%d) Array:%d err Name:%s (file:%s %d) !! \n",
					petID, array, (PetNAME==NULL)?"NULL":PetNAME, __FILE__, __LINE__ );
				continue;
			}
			char tempname[128];
			if(strstr(CHAR_getChar(petindex,CHAR_NAME),"*")!=NULL)
				sprintf(tempname,"*%s",ENEMYTEMP_getChar( parry, E_T_NAME));
			else
				sprintf(tempname,"%s",ENEMYTEMP_getChar( parry, E_T_NAME));
			CHAR_setChar( petindex, CHAR_NAME, tempname);
			CHAR_setChar( petindex, CHAR_USERPETNAME , "");
			//andy_log
			print("ANDY Pet(ID:%d) Name -> %s (%s:%s)(file:%s %d) !! \n",
				petID, PetNAME, CHAR_getUseName( toindex),
				CHAR_getChar( toindex, CHAR_CDKEY), __FILE__, __LINE__ );
		}
	}

	for( i=0; i<CHAR_MAXPETHAVE; i++){
		char szPet[256];
		petindex = CHAR_getCharPet(toindex, i);
		if( !CHAR_CHECKINDEX( petindex) )continue;
		CHAR_complianceParameter( petindex );
		snprintf( szPet, sizeof( szPet ), "K%d", i);
		CHAR_sendStatusString( toindex, szPet );
		snprintf( szPet, sizeof( szPet ), "W%d", i);
		CHAR_sendStatusString( toindex, szPet );
	}
}
Exemplo n.º 2
0
BOOL CHECK_PETBBI( int toindex)
{
	int i, petindex, PetID;
	BOOL Finds = FALSE;
	char token[256];
	for( i=0; i < CHAR_MAXPETHAVE; i++)	{
		int parry, array, PetBBI;
		petindex = CHAR_getCharPet( toindex, i);
		if( !CHAR_CHECKINDEX( petindex) ) continue;
		PetID = CHAR_getInt( petindex, CHAR_PETID);
		array = ENEMY_getEnemyArrayFromTempNo( PetID);
		if( !ENEMY_CHECKINDEX( array)) continue;
		parry = ENEMYTEMP_getEnemyTempArray( array);
		PetBBI = ENEMYTEMP_getInt( parry, E_T_IMGNUMBER);

		if( CHAR_getInt( petindex, CHAR_BASEBASEIMAGENUMBER) != PetBBI ||
			CHAR_getInt( petindex, CHAR_BASEIMAGENUMBER) != PetBBI ){
			CHAR_setInt( petindex, CHAR_BASEBASEIMAGENUMBER, PetBBI);
			CHAR_setInt( petindex, CHAR_BASEIMAGENUMBER, PetBBI);
			sprintf( token, "ÐÞÕý%sͼºÅ", CHAR_getUseName( petindex));
			CHAR_talkToCli( toindex, -1, token, CHAR_COLORYELLOW);
			Finds = TRUE;
		}
		CHAR_setInt( petindex, CHAR_EARTHAT, ENEMYTEMP_getInt( parry, E_T_EARTHAT) );
		CHAR_setInt( petindex, CHAR_WATERAT, ENEMYTEMP_getInt( parry, E_T_WATERAT) );
		CHAR_setInt( petindex, CHAR_FIREAT, ENEMYTEMP_getInt( parry, E_T_FIREAT) );
		CHAR_setInt( petindex, CHAR_WINDAT, ENEMYTEMP_getInt( parry, E_T_WINDAT) );
		char tempname[128];
		if(strstr(CHAR_getChar(petindex,CHAR_NAME),"*")!=NULL)
			sprintf(tempname,"*%s",ENEMYTEMP_getChar( parry, E_T_NAME));
		else
			sprintf(tempname,"%s",ENEMYTEMP_getChar( parry, E_T_NAME));
		CHAR_setChar( petindex, CHAR_NAME, tempname);
		CHAR_setChar( petindex, CHAR_USERPETNAME , "");
	}
	for( i=0; i<CHAR_MAXPETHAVE; i++){
		char szPet[128];
		petindex = CHAR_getCharPet(toindex, i);
		if( !CHAR_CHECKINDEX( petindex) )continue;
		CHAR_complianceParameter( petindex );
		snprintf( szPet, sizeof( szPet ), "K%d", i);
		CHAR_sendStatusString( toindex, szPet );
		snprintf( szPet, sizeof( szPet ), "W%d", i);
		CHAR_sendStatusString( toindex, szPet );
	}
	if( Finds == FALSE ){
		sprintf( token, "ûÓдíÎóͼºÅµÄ³èÎï");
		CHAR_talkToCli( toindex, -1, token, CHAR_COLORYELLOW);
	}
	return Finds;
}
Exemplo n.º 3
0
void NPC_DepotPet_Get( int meindex, int talker, int select, char *token)
{
	
	int petindex;
	int selectpet;
	int emptyindex;
	char szPet[128];
	int workindex[CHAR_MAXPOOLPETHAVE];
	int i;
	int cnt;

	selectpet = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANT) ;
	petindex = CHAR_getDepotPetIndex( talker, selectpet);
	if( !CHAR_CHECKINDEX( petindex) ) return;
	emptyindex = CHAR_getCharPetElement( talker);
	if( emptyindex == -1 ) {
		fprint( "err\n");
		return;
	}
	CHAR_setCharPet( talker, emptyindex, petindex);
	CHAR_setChar( petindex, CHAR_OWNERCHARANAME, CHAR_getChar( talker, CHAR_NAME));
	CHAR_setDepotPetIndex( talker, selectpet, -1);
	NPC_MaxGoldOver( meindex, talker, NPC_PETSHOP_MSG_POOLTHANKS, token);
	snprintf( szPet, sizeof( szPet ), "K%d", emptyindex);
	CHAR_sendStatusString( talker, szPet );
	snprintf( szPet, sizeof( szPet), "W%d",emptyindex);
	CHAR_sendStatusString( talker, szPet );
	for( i = 0; i < CHAR_MAXDEPOTPETHAVE; i ++ ) {
		workindex[i] = -1;
	}
	cnt = 0;
	for( i = 0; i < CHAR_MAXDEPOTPETHAVE; i ++ ) {
		int petindex = CHAR_getDepotPetIndex( talker, i);
		if( CHAR_CHECKINDEX( petindex) ) {
			workindex[cnt++] = petindex;
		}
	}
	for( i = 0; i < CHAR_MAXDEPOTPETHAVE; i ++ ) {
		CHAR_setDepotPetIndex( talker, i, workindex[i]);
	}
	LogPet(
		CHAR_getChar( talker, CHAR_NAME ),
		CHAR_getChar( talker, CHAR_CDKEY ),
		CHAR_getChar( petindex, CHAR_NAME),
		CHAR_getInt( petindex, CHAR_LV),
		"draw(ÁìÈ¡²Ö¿â³èÎï)",
		CHAR_getInt( talker,CHAR_FLOOR),
		CHAR_getInt( talker,CHAR_X ),
		CHAR_getInt( talker,CHAR_Y ),
		CHAR_getChar( petindex, CHAR_UNIQUECODE)   // shan 2001/12/14
	);
#ifdef _PET_EVOLUTION
	if( CHAR_getInt( petindex, CHAR_FUSIONBEIT) == 1 &&
		CHAR_getInt( petindex, CHAR_FUSIONRAISE) > 0 ){//¼ì²éÊÇ·ñΪÈںϳè
		CHAR_setInt( petindex, CHAR_FUSIONTIMELIMIT, (int)time( NULL));
	}
#endif
}	
Exemplo n.º 4
0
/**************************************
 * route  į���գ�  󡻥ؤ�����չ�ľë
 * ��į�����屾�������£�
 **************************************/
static void NPC_BusSetDestPoint( int meindex, char *argstr)
{
	char 	buf[256];
	char	routename[256];

	snprintf( routename, sizeof( routename), "routename%d", 
				CHAR_getWorkInt( meindex, NPC_WORK_CURRENTROUTE));

	if( NPC_Util_GetStrFromStrWithDelim( argstr, routename, buf, sizeof( buf))
		!= NULL ) 
	{
		CHAR_setChar( meindex, CHAR_OWNTITLE, buf);
		CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX));
	}
}
Exemplo n.º 5
0
static void NPC_NewNpcMan_selectWindow( int meindex, int toindex, int num, int flg)
{
	char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE];
	char token[256];

	int buttontype = 0, windowtype = 0, windowno = 0;
	int fd = getfdFromCharaIndex( toindex);

	windowtype = WINDOW_MESSAGETYPE_MESSAGE;

	if(NPC_Util_isFaceToFace( meindex ,toindex , 2) == FALSE) {
		if(NPC_Util_isFaceToChara( toindex, meindex, 1) == FALSE)
			return;
	}

	memset( npcarg, 0, sizeof( npcarg));
	if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){
		return;
	}

	memset( token, 0, sizeof( token));
	switch( num)	{
	case WINDOW_START:
		if( NPC_Util_GetStrFromStrWithDelim( npcarg, "START_MSG", token, sizeof( token) ) == NULL) {
			return;
		}
		buttontype = WINDOW_BUTTONTYPE_YESNO;
		windowno = NPC_PROGRAMEGINEER_DEFIND;
		break;
	case WINDOW_SELECT1:
		sprintf(token,"              ÇëÑ¡Ôñ"
			      "\n             ¡¶ÐÞÕý³èÎïÒì³£¡·"
				  "\n             ¡¶ÐÞÕý³èÎïͼºÅ¡·"
			      "\n              ¡¶¸ü»»ÁéÁ¦îø¡·"
#ifdef _PET_LOSTPET
				  "\n             ¡¶Áì»ØÒÅʧ³èÎï¡·"
#endif
//				  "\n            ¡¶»¹Ô­ÌúǹÈþ¶Ñµþ¡·"

				  );
		windowtype = WINDOW_MESSAGETYPE_SELECT;
		buttontype = WINDOW_BUTTONTYPE_CANCEL;
		windowno = NPC_PROGRAMEGINEER_SELECT2;
		break;
	case WINDOW_SELECT2:
		switch( flg){
		case 1://ÐÞÕý³èÎïÒì³£
			NPC_reCheckMyPetUnusual( meindex, toindex);
			CHAR_talkToCli( toindex, -1, "ÉíÉϳèÎï¼ì²éÍê±Ï!", CHAR_COLORYELLOW);
			return;
			break;
		case 2://ÐÞÕý³èÎïͼºÅ
			CHECK_PETBBI( toindex);
			return;
			break;
		case 3://¸ü»»ÁéÁ¦îø
			if( CHECK_ITEMEQUIT( toindex) == TRUE ){
				CHAR_talkToCli( toindex, -1, "¼ì²éÍê±Ï!", CHAR_COLORYELLOW);
			}
			return;
			break;

		case 4:
#ifdef _PET_LOSTPET
			if( NPC_reFindMyLostPet( meindex, toindex, token) == FALSE ){
				CHAR_talkToCli( toindex, -1, "²éÎÞ×ÊÁÏ£¡", CHAR_COLORYELLOW);
				return;
			}
			windowtype = WINDOW_MESSAGETYPE_SELECT;
			buttontype = WINDOW_BUTTONTYPE_CANCEL;
			windowno = NPC_PROGRAMEGINEER_SELECTLOSTPET;
#endif
			break;
		case 5: //»¹Ô­ÌúǹÈþ¶Ñµþ
//			NPC_reCheckItemPilenum( meindex, toindex);
			return;
			break;
		}
		break;
/*
	case WINDOW_SELECT3:
			{
				int petnum, petindex;
				petnum = atoi( data)-1;
				if( petnum >= CHAR_MAXPETHAVE || petnum < 0 ) return;
				petindex = CHAR_getCharPet( talker, petsel);
				if( !CHAR_CHECKINDEX(petindex) ) return;
				break;
			}
*/
	case WINDOW_SELECTLOSTPET:
#ifdef _PET_LOSTPET
		{
			int ret, i, ti, ltime, cost;
			Char ch;
			char msgbuf[256];
			char petstring1[2048];

			int havepetelement = CHAR_getCharPetElement( toindex);
			ti = flg;
			if( havepetelement < 0 ){
				CHAR_talkToCli( toindex, -1, "³èÎïÀ¸Î»ÒÑÂú£¡", CHAR_COLORYELLOW);
				return;
			}
			if( NPC_getLostPetString( meindex, toindex) == FALSE ) {
				CHAR_talkToCli( toindex, -1, "ÁìÈ¡³èÎïʧ°Ü£¡", CHAR_COLORYELLOW);
				return;
			}

			if( getStringFromIndexWithDelim( petstring[ti-1], "#", 2, petstring1, sizeof( petstring1)) == FALSE ){
				CHAR_talkToCli( toindex, -1, "ÁìÈ¡³èÎïʧ°Ü£¡", CHAR_COLORYELLOW);
				return;	
			}else{
				char buf1[256];
				if( getStringFromIndexWithDelim( petstring[ti-1], "|", 6, buf1, sizeof( buf1)) == FALSE ) return;
					ltime = atoi(buf1);
					ltime = time( NULL) - ltime;
					ltime = ltime/(60*60*24);
				if( getStringFromIndexWithDelim( petstring[ti-1], "|", 4, buf1, sizeof( buf1)) == FALSE ) return;
					cost = atoi( buf1);
#if 0	// ÐÞÕý±£Êͽð
				cost = cost + (ltime*100);
				cost = (cost>10000)?10000:cost;
#else
				cost = cost + (ltime*10000);
#endif
				if( CHAR_getInt( toindex, CHAR_GOLD) < cost ) {
					sprintf( buf1, "³èÎïÒѼķÅ%dÌ죬¹²Ðè%dʯ±Ò²Å¿ÉÁì»Ø¡£", ltime, cost);
					CHAR_talkToCli( toindex, meindex, buf1, CHAR_COLORYELLOW);
					return;	
				}
			}


			ret = CHAR_makePetFromStringToArg( petstring1, &ch, -2);
			strcpy( petstring[ti-1], "");
			if( ret ) {
				char buf1[256];
				int petindex = PET_initCharOneArray( &ch );
				if( !CHAR_CHECKINDEX( petindex) ){
					CHAR_talkToCli( toindex, -1, "ÁìÈ¡³èÎïʧ°Ü£¡", CHAR_COLORYELLOW);
					return;
				}
				print("ANDY petindex:%d[%s]\n", petindex, CHAR_getChar( petindex, CHAR_NAME) );

				CHAR_complianceParameter( petindex );
				CHAR_setInt( petindex, CHAR_HP, CHAR_getWorkInt( petindex, CHAR_WORKMAXHP));
				CHAR_setWorkInt( petindex, CHAR_WORKPLAYERINDEX, toindex);
				CHAR_setCharPet( toindex, havepetelement, petindex);
				CHAR_setChar( petindex, CHAR_OWNERCDKEY,
							CHAR_getChar( toindex, CHAR_CDKEY));
				CHAR_setChar( petindex, CHAR_OWNERCHARANAME,
							CHAR_getChar( toindex, CHAR_NAME));

				if( NPC_backupLostPetString( toindex) == FALSE ){
					print("ANDY err backup petstring !!\n");
					return;
				}
				
				sprintf( buf1, "LostPGet:%d", cost);
				LogPet(
					CHAR_getChar( toindex, CHAR_NAME ),
					CHAR_getChar( toindex, CHAR_CDKEY ),
					CHAR_getChar( petindex, CHAR_NAME),
					CHAR_getInt( petindex, CHAR_LV),
					buf1,
					CHAR_getInt( toindex,CHAR_FLOOR),
					CHAR_getInt( toindex,CHAR_X ),
					CHAR_getInt( toindex,CHAR_Y ),
					CHAR_getChar( petindex, CHAR_UNIQUECODE)   // shan 2001/12/14
				);
				sprintf( buf1, "ÁìÈ¡³èÎï%s¡£", CHAR_getUseName( petindex));
				CHAR_talkToCli( toindex, meindex, buf1, CHAR_COLORYELLOW);
				for( i = 0; i < CHAR_MAXPETHAVE; i++){
					int petindex = CHAR_getCharPet( toindex, i);
					if( !CHAR_CHECKINDEX( petindex) )
						continue;
					CHAR_complianceParameter( petindex );
					snprintf( msgbuf, sizeof( msgbuf ), "K%d", i );
					CHAR_sendStatusString( toindex, msgbuf );
					snprintf( msgbuf, sizeof( msgbuf ), "W%d", i );
					CHAR_sendStatusString( toindex, msgbuf );
				}
				CHAR_DelGold( toindex, cost);
			}else{
					CHAR_talkToCli( toindex, -1, "ÁìÈ¡³èÎïʧ°Ü£¡", CHAR_COLORYELLOW);
					return;
			}
			return;
 		}
#endif
		return;
		break;
	case WINDOW_DEFIND:
		{
			int i;
			int face = CHAR_getInt( toindex, CHAR_FACEIMAGENUMBER);
			if( NPC_Util_GetStrFromStrWithDelim( npcarg, "CHECK_MSG", token, sizeof( token) ) == NULL) {
				return;
			}
			for( i=0; i<48; i++){
				if( face >= checkPc[i][0] && face < checkPc[i][1] )
					break;
			}
			if( i >= 48 )return;
			CHAR_setWorkInt( toindex, CHAR_WORKNPCMETAMO, meindex);
			CHAR_setInt( toindex, CHAR_BASEIMAGENUMBER, checkPc[i][2]);
			CHAR_complianceParameter( toindex );
			CHAR_sendCToArroundCharacter( CHAR_getWorkInt( toindex , CHAR_WORKOBJINDEX ));
			CHAR_send_P_StatusString( toindex , CHAR_P_STRING_BASEBASEIMAGENUMBER);

			buttontype = WINDOW_BUTTONTYPE_YESNO;
			windowno = NPC_PROGRAMEGINEER_END;
		}
		break;
	case WINDOW_END:
		{
			CHAR_setWorkInt( toindex, CHAR_WORKNPCMETAMO, -1);
			CHAR_setInt( toindex, CHAR_BASEBASEIMAGENUMBER,
				CHAR_getInt( toindex, CHAR_BASEIMAGENUMBER) );

			CHAR_complianceParameter( toindex );
			CHAR_sendCToArroundCharacter( CHAR_getWorkInt( toindex , CHAR_WORKOBJINDEX ));
			CHAR_send_P_StatusString( toindex , CHAR_P_STRING_BASEBASEIMAGENUMBER);
			return;
		}
		break;
	}

	lssproto_WN_send( fd, windowtype, buttontype, windowno,
		CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token);
}
void NPC_PetRaceMasterLoop( int meindex)
{
	int floor = CHAR_getInt(meindex, CHAR_FLOOR);
	time_t t1;
	time(&t1);
	switch(CHAR_getWorkInt(meindex, NPC_WORK_STATE))
	{
		case NPC_State_Init:	
				// ´M§äÃdª«index
				NPC_findRacePetIndex(meindex, floor);
			break;
		case NPC_State_WaitDropStake:
			{
				char tmpbuf[256];
				int statechangetime = CHAR_getWorkInt(meindex, NPC_WORK_STATECHANGE);
				if (t1 < statechangetime)
				{
					if (statechangetime - t1 <= 5)
					{
						CHAR_setInt(meindex, CHAR_LOOPINTERVAL, PETRACEMASTER_WAITDROPIV_LOOPTIME);
						snprintf(tmpbuf, sizeof(tmpbuf), "ÁÙ¦³%2d¬í´N­n¶}¶]¤F¡A½Ð¤j®a¿ãÅD¤Uª`¡I",
							(int)(statechangetime - t1) % 60);
					}
					else if (statechangetime - t1 <= 10)
					{
						CHAR_setInt(meindex, CHAR_LOOPINTERVAL, PETRACEMASTER_WAITDROPIII_LOOPTIME);
						snprintf(tmpbuf, sizeof(tmpbuf), "ÁÙ¦³%2d¬í´N­n¶}¶]¤F¡A½Ð¤j®a¿ãÅD¤Uª`¡I",
							(int)(statechangetime - t1) % 60);
					}
					else if (statechangetime - t1 <= 30)
					{
						CHAR_setInt(meindex, CHAR_LOOPINTERVAL, PETRACEMASTER_WAITDROPII_LOOPTIME);
						snprintf(tmpbuf, sizeof(tmpbuf), "ÁÙ¦³%2d¬í´N­n¶}¶]¤F¡A½Ð¤j®a¿ãÅD¤Uª`¡I",
							(int)(statechangetime - t1) % 60);
					}
					else
						snprintf(tmpbuf, sizeof(tmpbuf), "ÁÙ¦³%2d¤ÀÄÁ%2d¬í´N­n¶}¶]¤F¡A½Ð¤j®a¿ãÅD¤Uª`¡I",
							(int)(statechangetime - t1) / 60, (int)(statechangetime - t1) % 60);
				}
				if (t1 >= statechangetime)
				{
#ifdef _DROPSTAKENEW
#else
					float payrate1 = 0, payrate2 = 0, payrate3 = 0;
					int pet1gold = 0, pet2gold = 0, pet3gold = 0, totalgold = 0;
					int petindex1 = CHAR_getWorkInt(meindex, NPC_WORK_PET1);
					int petindex2 = CHAR_getWorkInt(meindex, NPC_WORK_PET2);
					int petindex3 = CHAR_getWorkInt(meindex, NPC_WORK_PET3);
					int randpet	= CHAR_getWorkInt(meindex, NPC_WORK_PETGROUP);
					float droprate1 = 0, droprate2 = 0, droprate3 = 0, totaldroprate, Npayrate = PETRACESTDPAYRATE;
#endif
					int i = 0;
					CHAR_setWorkInt(meindex, NPC_WORK_STATE, NPC_State_PetRacing);
					// ³]©w¦a­±¤£¥i¤Uª`
					SetCasinoMap(meindex, 0, FALSE);
#ifdef _DROPSTAKENEW
					snprintf(tmpbuf, sizeof(tmpbuf), "½Ð¤j®a°±¤î¤Uª`¡AÃdª«Áɶ]¶}©lÅo¡I");
#else
					// §iª¾¤j®a½ß²v¡]¨ú±oÃdª«¤Uª`ª÷ÃB­pºâ½ß²v¡^
					GetCasinoMapGold(meindex, PET_RACE1, &pet1gold);
					GetCasinoMapGold(meindex, PET_RACE2, &pet2gold);
					GetCasinoMapGold(meindex, PET_RACE3, &pet3gold);
					totalgold = pet1gold + pet2gold + pet3gold;
					if (totalgold <= 0)
					{
						payrate1 = 2; payrate2 = 2; payrate3 = 2;
					}
					else
					{
						if (pet1gold <= PETRACESTDGOLD)
							pet1gold = PETRACESTDGOLD;
						if (pet2gold <= PETRACESTDGOLD)
							pet2gold = PETRACESTDGOLD;
						if (pet3gold <= PETRACESTDGOLD)
							pet3gold = PETRACESTDGOLD;
						totalgold = pet1gold + pet2gold + pet3gold;
						droprate1 = totalgold / pet1gold;
						droprate2 = totalgold / pet2gold;
						droprate3 = totalgold / pet3gold;
						totaldroprate = droprate1 + droprate2 + droprate3;
						if (totaldroprate / droprate1 > PETRACESTDPAYRATE)
						{
							payrate1 = 1; Npayrate -= 1;
						}
						if (totaldroprate / droprate2 > PETRACESTDPAYRATE)
						{
							payrate2 = 1; Npayrate -= 1;
						}
						if (totaldroprate / droprate3 > PETRACESTDPAYRATE)
						{
							payrate3 = 1; Npayrate -= 1;
						}
						if (payrate1 != 1)
							payrate1 = droprate1 / totaldroprate * Npayrate;
						if (payrate2 != 1)
							payrate2 = droprate2 / totaldroprate * Npayrate;
						if (payrate3 != 1)
							payrate3 = droprate3 / totaldroprate * Npayrate;
					}
					petracegra[randpet].payrate1 = payrate1;
					petracegra[randpet].payrate3 = payrate2;
					petracegra[randpet].payrate2 = payrate3;
					SetCasinoPayRate(meindex, PET_RACE1, payrate1);
					SetCasinoPayRate(meindex, PET_RACE2, payrate2);
					SetCasinoPayRate(meindex, PET_RACE3, payrate3);
					snprintf(tmpbuf, sizeof(tmpbuf), "½Ð¤j®a°±¤î¤Uª`¡AÃdª«Áɶ]¶}©lÅo¡I%sªº½ß²v¬°%5.2f¡F%sªº½ß²v¬°%5.2f¡F%sªº½ß²v¬°%5.2f",
						CHAR_getChar(petindex1, CHAR_NAME), payrate1,
						CHAR_getChar(petindex2, CHAR_NAME), payrate2,
						CHAR_getChar(petindex3, CHAR_NAME), payrate3);
#endif
					CHAR_setInt(meindex, CHAR_LOOPINTERVAL, PETRACEMASTER_PETRACING_LOOPTIME);
					// ³]©wÃdª«ª¬ºA
					for (i = 0; i < PETRACEPETNUM; i++)
					{
						CHAR_setWorkInt(CHAR_getWorkInt(meindex, NPC_WORK_PET1 + i), NPC_WORK_STATE, NPC_State_Run);
						CHAR_setInt(CHAR_getWorkInt(meindex, NPC_WORK_PET1 + i), CHAR_LOOPINTERVAL, 1000);
					}
				}
				CHAR_talkToFloor(floor, meindex, tmpbuf, CHAR_COLORWHITE);
			}
			break;
		case NPC_State_PetRacing:
			if (CHAR_getWorkInt(meindex, NPC_WORK_PETGOAL) == PETRACEPETNUM)
			{
				char tmpbuf[256];
				int winpetindex = CHAR_getWorkInt(meindex, NPC_WORK_WINPET);
				int petgroup = CHAR_getWorkInt(meindex, NPC_WORK_PETGROUP);
				snprintf(tmpbuf, sizeof(tmpbuf), "ÄvÁɵ²§ô¡A³Ó§QªºÃdª«¬O¡G%s\n", 
					CHAR_getChar(winpetindex, CHAR_NAME));
				CHAR_talkToFloor(floor, meindex, tmpbuf, CHAR_COLORYELLOW);
				// ³]©w¿éĹ¡A¥H­pºâ½ß²v
				if (CHAR_getWorkInt(meindex, NPC_WORK_PET1) == winpetindex)
					petracegra[petgroup].pet1win = petracegra[petgroup].pet1win + 1;
				else if (CHAR_getWorkInt(meindex, NPC_WORK_PET2) == winpetindex)
					petracegra[petgroup].pet2win = petracegra[petgroup].pet2win + 1;
				else if (CHAR_getWorkInt(meindex, NPC_WORK_PET3) == winpetindex)
					petracegra[petgroup].pet3win = petracegra[petgroup].pet3win + 1;
				CHAR_setWorkInt(meindex, NPC_WORK_STATE, NPC_State_ShowWinPet);
				CHAR_setInt(meindex, CHAR_LOOPINTERVAL, PETRACEMASTER_SHOWWINPET_LOOPTIME);
				CHAR_setWorkInt(meindex, NPC_WORK_STATECHANGE, t1 + PETRACESHOWWINPET);	
				// µo¼úª÷
				NPC_givePriceToPlayer(meindex, floor, winpetindex);
			}
			break;
		case NPC_State_ShowWinPet:
			{
				int statechangetime = CHAR_getWorkInt(meindex, NPC_WORK_STATECHANGE);
				if (t1 >= statechangetime)
				{
					int randpet = RAND(0, arraysizeof(petracegra) - 1);
					int petindex1 = CHAR_getWorkInt(meindex, NPC_WORK_PET1);
					int petindex2 = CHAR_getWorkInt(meindex, NPC_WORK_PET2);
					int petindex3 = CHAR_getWorkInt(meindex, NPC_WORK_PET3);
					char tmpbuf[256];
					CHAR_setWorkInt(meindex, NPC_WORK_PETGROUP, randpet);
					CHAR_setWorkInt(meindex, NPC_WORK_STATE, NPC_State_WaitDropStake);
					CHAR_setWorkInt(meindex, NPC_WORK_WINPET, 0);
					CHAR_setWorkInt(meindex, NPC_WORK_PETGOAL, 0);
					CHAR_setWorkInt(meindex, NPC_WORK_STATECHANGE, t1 + PETRACEDROPSTAKETIME);
					CHAR_setInt(meindex, CHAR_LOOPINTERVAL, PETRACEMASTER_WAITDROPI_LOOPTIME);
					// ³]©w¦a­±¥i¤Uª`
					SetCasinoMap(meindex, 0, TRUE);
					// ³]©wÃdª«
					CHAR_setWorkInt(petindex1, NPC_WORK_STATE, NPC_State_Wait);
					CHAR_setInt(petindex1, CHAR_LOOPINTERVAL, 1000);
					CHAR_setInt(petindex1, CHAR_BASEIMAGENUMBER, petracegra[randpet].pet1gra);
					CHAR_setChar(petindex1, CHAR_NAME, petracegra[randpet].pet1name);

					CHAR_setWorkInt(petindex2, NPC_WORK_STATE, NPC_State_Wait);
					CHAR_setInt(petindex2, CHAR_LOOPINTERVAL, 1000);
					CHAR_setInt(petindex2, CHAR_BASEIMAGENUMBER, petracegra[randpet].pet2gra);
					CHAR_setChar(petindex2, CHAR_NAME, petracegra[randpet].pet2name);

					CHAR_setWorkInt(petindex3, NPC_WORK_STATE, NPC_State_Wait);
					CHAR_setInt(petindex3, CHAR_LOOPINTERVAL, 1000);
					CHAR_setInt(petindex3, CHAR_BASEIMAGENUMBER, petracegra[randpet].pet3gra);
					CHAR_setChar(petindex3, CHAR_NAME, petracegra[randpet].pet3name);
					// ³]©wÃdª«ª¬ªp
#ifdef _DROPSTAKENEW
#else
					petracegra[randpet].payrate1 = 0;
					petracegra[randpet].payrate3 = 0;
					petracegra[randpet].payrate2 = 0;
#endif
					{
						int state1 = RAND(0, 3);
						int state2 = RAND(0, 3);
						int state3 = RAND(0, 3);
						if (state1 == 0)
							sprintf(petracegra[randpet].state1, "¨}¦n");
						else if (state1 == 1)
							sprintf(petracegra[randpet].state1, "´¶³q");
						else if (state1 == 2)
							sprintf(petracegra[randpet].state1, "¤£¨Î");
						else if (state1 == 3)
							sprintf(petracegra[randpet].state1, "¥¼ª¾");
						if (state2 == 0)
							sprintf(petracegra[randpet].state2, "¨}¦n");
						else if (state2 == 1)
							sprintf(petracegra[randpet].state2, "´¶³q");
						else if (state2 == 2)
							sprintf(petracegra[randpet].state2, "¤£¨Î");
						else if (state2 == 3)
							sprintf(petracegra[randpet].state2, "¥¼ª¾");
						if (state3 == 0)
							sprintf(petracegra[randpet].state3, "¨}¦n");
						else if (state3 == 1)
							sprintf(petracegra[randpet].state3, "´¶³q");
						else if (state3 == 2)
							sprintf(petracegra[randpet].state3, "¤£¨Î");
						else if (state3 == 3)
							sprintf(petracegra[randpet].state3, "¥¼ª¾");
					}
					snprintf(tmpbuf, sizeof(tmpbuf), "Ãdª«Äv³t·Ç³Æ¤¤¡A½Ð¤j®a¿ãÅD¤Uª`¡I");
					CHAR_talkToFloor(floor, meindex, tmpbuf, CHAR_COLORYELLOW);
				}
			}
			break;
		default:
			break;
	}
}