chuyiwen_gmsv/npc/npc_petracemaster.c
chuyiwen bea5ac05b3 sq_gmsv_chuyiwen
sa_sever
2016-12-24 09:45:52 +09:00

583 lines
23 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "version.h"
#include <string.h>
#include <time.h>
#include "char.h"
#include "object.h"
#include "char_base.h"
#include "npcutil.h"
#include "lssproto_serv.h"
#include "handletime.h"
#ifdef _PETRACE
#include "npc_petracemaster.h"
#define PETRACEPETNUM 3
#define PETRACEMASTER_INITPET_LOOPTIME 3000 // 3취
#define PETRACEMASTER_WAITDROPI_LOOPTIME 30000 // 30취
#define PETRACEMASTER_WAITDROPII_LOOPTIME 10000 // 10취
#define PETRACEMASTER_WAITDROPIII_LOOPTIME 5000 // 5취
#define PETRACEMASTER_WAITDROPIV_LOOPTIME 1000 // 1취
#define PETRACEMASTER_PETRACING_LOOPTIME 3000 // 3취
#define PETRACEMASTER_SHOWWINPET_LOOPTIME 10000 // 10취
#define PETRACEDROPSTAKETIME 120 // 2롸爐 120
#define PETRACESHOWWINPET 30 // 30취
#define PETRACESTDPAYRATE 6
#define PETRACESTDGOLD 1 // 셕炬톄쪽珂샘굶쏜띨 1000
static void NPC_PetRaceMaster_selectWindow(int meindex, int toindex, int num, int select);
void NPC_findRacePetIndex(int meindex, int floor);
void NPC_givePriceToPlayer(int meindex, int floor, int winpetindex);
enum
{
NPC_WORK_STATE = CHAR_NPCWORKINT1,
NPC_WORK_PET1 = CHAR_NPCWORKINT2,
NPC_WORK_PET2 = CHAR_NPCWORKINT3,
NPC_WORK_PET3 = CHAR_NPCWORKINT4,
NPC_WORK_PETGROUP = CHAR_NPCWORKINT5,
NPC_WORK_STATECHANGE = CHAR_NPCWORKINT6,
NPC_WORK_FINDPETFLAG = CHAR_NPCWORKINT7,
NPC_WORK_WINPET = CHAR_NPCWORKINT8,
NPC_WORK_PETGOAL = CHAR_NPCWORKINT9,
};
enum
{
NPC_State_Init,
NPC_State_WaitDropStake,
NPC_State_PetRacing,
NPC_State_ShowWinPet,
};
enum
{
NPC_State_Wait,
NPC_State_Run,
NPC_State_ShowWin,
};
typedef struct tagPetRaceGraTable
{
int pet1gra;
int pet2gra;
int pet3gra;
char pet1name[64];
char pet2name[64];
char pet3name[64];
int pet1win;
int pet2win;
int pet3win;
#ifdef _DROPSTAKENEW
#else
float payrate1;
float payrate2;
float payrate3;
#endif
char state1[64];
char state2[64];
char state3[64];
}PetRaceGraTable;
#ifdef _DROPSTAKENEW
PetRaceGraTable petracegra[27] =
{
{100820, 100821, 100822, "팝찮魁제", "魁제윰돠", "魁제미제", 0, 0, 0, "좁봤", "좁봤", "좁봤"},
{100823, 100824, 100825, "꼈弩꼈쨀", "꼈弩꼈弩", "꼈弩텅", 0, 0, 0, "좁봤", "좁봤", "좁봤"},
{100842, 100843, 100844, "콩속薑", "콩샘薑", "景쭤옵薑", 0, 0, 0, "좁봤", "좁봤", "좁봤"},
{100852, 100853, 100855, "옹윗랑", "윗薑샘", "옹댐댐", 0, 0, 0, "좁봤", "좁봤", "좁봤"},
{100859, 100856, 100857, "옵엥景", "엥엥景", "웹弩景", 0, 0, 0, "좁봤", "좁봤", "좁봤"},
{100864, 100865, 100866, "융괜", "흩돠괜", "챘괜", 0, 0, 0, "좁봤", "좁봤", "좁봤"},
{100829, 100826, 100827, "궐궐속", "속속", "속薑걔", 0, 0, 0, "좁봤", "좁봤", "좁봤"},
{100830, 100832, 100833, "魁괜弩", "瓜궐", "魁윗윗", 0, 0, 0, "좁봤", "좁봤", "좁봤"},
{100883, 100884, 100885, "談쟁鵠", "遷쟁鵠", "갔랑鵠", 0, 0, 0, "좁봤", "좁봤", "좁봤"},
{100898, 100900, 100901, "옵옵람", "꼈읊람", "둑꼈람", 0, 0, 0, "좁봤", "좁봤", "좁봤"},
{100834, 100836, 100837, "굔쭤쏜", "굔쭤굔", "굔쭤꺼꺼", 0, 0, 0, "좁봤", "좁봤", "좁봤"},
{100838, 100840, 100841, "융밴", "밴裂멀", "엥윗밴", 0, 0, 0, "좁봤", "좁봤", "좁봤"},
{100879, 100881, 100880, "둑속", "꺼꺼뛰", "<EFBFBD>", 0, 0, 0, "좁봤", "좁봤", "좁봤"},
{100888, 100887, 100889, "칭윗鱇", "<EFBFBD>", "쯔薑景", 0, 0, 0, "좁봤", "좁봤", "좁봤"},
{100913, 100914, 100915, "윰캠쭤薑", "聾적쭤薑", "僅팹쭤薑", 0, 0, 0, "좁봤", "좁봤", "좁봤"},
{100845, 100846, 100847, "빌꺼꺼", "빌쨀쨀", "쨀윗페薑", 0, 0, 0, "좁봤", "좁봤", "좁봤"},
{100849, 100850, 100851, "곡킵薑컹", "煖목薑", "둑샘목薑", 0, 0, 0, "좁봤", "좁봤", "좁봤"},
{100878, 100876, 100877, "깼쭤꼈薑", "속內꼈薑", "둑쵠꼈薑", 0, 0, 0, "좁봤", "좁봤", "좁봤"},
{100908, 100909, 100906, "각쵠뜸", "곡鱇졸뜸", "뜸것켑景", 0, 0, 0, "좁봤", "좁봤", "좁봤"},
{100916, 100918, 100919, "접뗘쨀薑", "것옹饑鱇", "잉돠제옹薑", 0, 0, 0, "좁봤", "좁봤", "좁봤"},
{100860, 100862, 100861, "鱇랑뛰", "첨랑뛰", "목랑句쭤", 0, 0, 0, "좁봤", "좁봤", "좁봤"},
{100867, 100870, 100868, "킹주섈쨀", "거윗거", "袈열쨀", 0, 0, 0, "좁봤", "좁봤", "좁봤"},
{100871, 100873, 100874, "팹쨀謳", "힉목쨀", "쯔薑굔엥", 0, 0, 0, "좁봤", "좁봤", "좁봤"},
{100894, 100895, 100896, "미제칡", "칡섈칡섈", "칡쵠乞윗", 0, 0, 0, "좁봤", "좁봤", "좁봤"},
{100902, 100903, 100905, "목쟁읊", "칡쟁", "檢薑뤼", 0, 0, 0, "좁봤", "좁봤", "좁봤"},
{100912, 100911, 100910, "怒뤼샅람", "꼈弩쬈薑", "꼈윰律", 0, 0, 0, "좁봤", "좁봤", "좁봤"},
{100891, 100892, 100893, "맞鍊윗", "며薑며薑", "촁며윗薑", 0, 0, 0, "좁봤", "좁봤", "좁봤"},
};
#else
PetRaceGraTable petracegra[27] =
{
{100820, 100821, 100822, "팝찮魁제", "魁제윰돠", "魁제미제", 0, 0, 0, 2, 2, 2, "좁봤", "좁봤", "좁봤"},
{100823, 100824, 100825, "꼈弩꼈쨀", "꼈弩꼈弩", "꼈弩텅", 0, 0, 0, 2, 2, 2, "좁봤", "좁봤", "좁봤"},
{100842, 100843, 100844, "콩속薑", "콩샘薑", "景쭤옵薑", 0, 0, 0, 2, 2, 2, "좁봤", "좁봤", "좁봤"},
{100852, 100853, 100855, "옹윗랑", "윗薑샘", "옹댐댐", 0, 0, 0, 2, 2, 2, "좁봤", "좁봤", "좁봤"},
{100859, 100856, 100857, "옵엥景", "엥엥景", "웹弩景", 0, 0, 0, 2, 2, 2, "좁봤", "좁봤", "좁봤"},
{100864, 100865, 100866, "융괜", "흩돠괜", "챘괜", 0, 0, 0, 2, 2, 2, "좁봤", "좁봤", "좁봤"},
{100829, 100826, 100827, "궐궐속", "속속", "속薑걔", 0, 0, 0, 2, 2, 2, "좁봤", "좁봤", "좁봤"},
{100830, 100832, 100833, "魁괜弩", "瓜궐", "魁윗윗", 0, 0, 0, 2, 2, 2, "좁봤", "좁봤", "좁봤"},
{100883, 100884, 100885, "談쟁鵠", "遷쟁鵠", "갔랑鵠", 0, 0, 0, 2, 2, 2, "좁봤", "좁봤", "좁봤"},
{100898, 100900, 100901, "옵옵람", "꼈읊람", "둑꼈람", 0, 0, 0, 2, 2, 2, "좁봤", "좁봤", "좁봤"},
{100834, 100836, 100837, "굔쭤쏜", "굔쭤굔", "굔쭤꺼꺼", 0, 0, 0, 2, 2, 2, "좁봤", "좁봤", "좁봤"},
{100838, 100840, 100841, "융밴", "밴裂멀", "엥윗밴", 0, 0, 0, 2, 2, 2, "좁봤", "좁봤", "좁봤"},
{100879, 100881, 100880, "둑속", "꺼꺼뛰", "<EFBFBD>", 0, 0, 0, 2, 2, 2, "좁봤", "좁봤", "좁봤"},
{100888, 100887, 100889, "칭윗鱇", "<EFBFBD>", "쯔薑景", 0, 0, 0, 2, 2, 2, "좁봤", "좁봤", "좁봤"},
{100913, 100914, 100915, "윰캠쭤薑", "聾적쭤薑", "僅팹쭤薑", 0, 0, 0, 2, 2, 2, "좁봤", "좁봤", "좁봤"},
{100845, 100846, 100847, "빌꺼꺼", "빌쨀쨀", "쨀윗페薑", 0, 0, 0, 2, 2, 2, "좁봤", "좁봤", "좁봤"},
{100849, 100850, 100851, "곡킵薑컹", "煖목薑", "둑샘목薑", 0, 0, 0, 2, 2, 2, "좁봤", "좁봤", "좁봤"},
{100878, 100876, 100877, "깼쭤꼈薑", "속內꼈薑", "둑쵠꼈薑", 0, 0, 0, 2, 2, 2, "좁봤", "좁봤", "좁봤"},
{100908, 100909, 100906, "각쵠뜸", "곡鱇졸뜸", "뜸것켑景", 0, 0, 0, 2, 2, 2, "좁봤", "좁봤", "좁봤"},
{100916, 100918, 100919, "접뗘쨀薑", "것옹饑鱇", "잉돠제옹薑", 0, 0, 0, 2, 2, 2, "좁봤", "좁봤", "좁봤"},
{100860, 100862, 100861, "鱇랑뛰", "첨랑뛰", "목랑句쭤", 0, 0, 0, 2, 2, 2, "좁봤", "좁봤", "좁봤"},
{100867, 100870, 100868, "킹주섈쨀", "거윗거", "袈열쨀", 0, 0, 0, 2, 2, 2, "좁봤", "좁봤", "좁봤"},
{100871, 100873, 100874, "팹쨀謳", "힉목쨀", "쯔薑굔엥", 0, 0, 0, 2, 2, 2, "좁봤", "좁봤", "좁봤"},
{100894, 100895, 100896, "미제칡", "칡섈칡섈", "칡쵠乞윗", 0, 0, 0, 2, 2, 2, "좁봤", "좁봤", "좁봤"},
{100902, 100903, 100905, "목쟁읊", "칡쟁", "檢薑뤼", 0, 0, 0, 2, 2, 2, "좁봤", "좁봤", "좁봤"},
{100912, 100911, 100910, "怒뤼샅람", "꼈弩쬈薑", "꼈윰律", 0, 0, 0, 2, 2, 2, "좁봤", "좁봤", "좁봤"},
{100891, 100892, 100893, "맞鍊윗", "며薑며薑", "촁며윗薑", 0, 0, 0, 2, 2, 2, "좁봤", "좁봤", "좁봤"},
};
#endif
BOOL NPC_PetRaceMasterInit( int meindex )
{
CHAR_setInt(meindex, CHAR_LOOPINTERVAL, PETRACEMASTER_INITPET_LOOPTIME);
CHAR_setInt(meindex, CHAR_WHICHTYPE, CHAR_PETRACEMASTER);
CHAR_setWorkInt(meindex, NPC_WORK_STATE, NPC_State_Init);
CHAR_setWorkInt(meindex, NPC_WORK_PETGROUP, 0);
#ifdef _DROPSTAKENEW
#else
petracegra[0].payrate1 = 0;
petracegra[0].payrate2 = 0;
petracegra[0].payrate3 = 0;
#endif
return TRUE;
}
void NPC_PetRaceMasterTalked( int meindex , int talkerindex , char *szMes , int color )
{
// <20>伎劤藤綱츠鹿섟녘膠榴워
if (CHAR_getInt(talkerindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER)
return;
if (NPC_Util_isFaceToFace(talkerindex, meindex, 2) == FALSE)
if (NPC_Util_CharDistance(talkerindex, meindex) > 1)
return;
NPC_PetRaceMaster_selectWindow(meindex, talkerindex, 0, -1);
}
static void NPC_PetRaceMaster_selectWindow(int meindex, int toindex, int num, int select)
{
char token[1024];
int buttontype = 0, windowtype = 0, windowno = 0;
int fd = getfdFromCharaIndex(toindex);
if (fd == -1) return;
token[0] = '\0';
switch(num)
{
case 0:
sprintf(token, "4\n\n ∽녘膠씌醵끝∽\n"
"콱봤,拳狼列돛痂投헙괩찐?\n"
"\n 《뀁였踏狗방橙》"
"\n 《녘膠榴워》"
"\n 《잼역》");
buttontype = WINDOW_BUTTONTYPE_NONE;
windowtype = WINDOW_MESSAGETYPE_SELECT;
windowno = CHAR_WINDOWTYPE_PETRACEMASTER_START;
break;
case 1:
#ifdef _DROPSTAKENEW
sprintf(token,
"\n씌醵끝방橙:"
"\n꽝속씌醵돨녘膠悧묾唐힛怜,퀭옵鹿弩亮녘膠"
"\n돨榴워샀몸훙毆봤苟鬧,헝쉥뚝뻣돤돕돨꽈환"
"\n렴零異挑苟鬧돨뵀쯤품렘。뎠씌醵써監珂,寮"
"\n넣훙쉥삔菱땡곤퀭셕炬생롸。"
"\n헝鬧雷:뎠퀭잼역늪렛쇌샀되놔珂,苟鬧돨꽈"
"\n얩섟생롸쉥轟랬혤쀼胥!");
#else
sprintf(token,
"\n씌醵끝방橙:꽝속씌醵돨녘膠묾唐힛怜,퀭옵"
"\n鹿弩亮녘膠榴워샀몸훙毆봤苟鬧,첼몸녘膠唐"
"\n菱성돨톄쪽。헝쉥柯귑땔零異挑苟鬧돨뵀쯤품"
"\n렘。뎠씌醵써監珂,寮넣훙삔菱땡뒈쉥쏜띨렴"
"\n쀼콱돨<EFBFBD><EFBFBD>샀닸흙몸훙陵契。"
"\n헝鬧雷:陵契쏜띨헝蕎낚법寧푤拱!뎠퀭잼역"
"\n늪렛쇌샀되놔珂,苟鬧돨쏜띨쉥轟랬혤쀼胥!");
#endif
buttontype = WINDOW_BUTTONTYPE_OK;
windowtype = WINDOW_MESSAGETYPE_MESSAGE;
windowno = CHAR_WINDOWTYPE_PETRACEMASTER_RULE;
break;
case 2:
{
int petgroup = CHAR_getWorkInt(meindex, NPC_WORK_PETGROUP);
int petindex1 = CHAR_getWorkInt(meindex, NPC_WORK_PET1);
int petindex2 = CHAR_getWorkInt(meindex, NPC_WORK_PET2);
int petindex3 = CHAR_getWorkInt(meindex, NPC_WORK_PET3);
int pet1win = petracegra[petgroup].pet1win;
int pet2win = petracegra[petgroup].pet2win;
int pet3win = petracegra[petgroup].pet3win;
int total = pet1win + pet2win + pet3win;
float winrate1 = 0, winrate2 = 0, winrate3 = 0;
#ifdef _DROPSTAKENEW
#else
char cpayrate1[64], cpayrate2[64], cpayrate3[64];
if (petracegra[petgroup].payrate1 == 0)
snprintf(cpayrate1, sizeof(cpayrate1), "???");
else
snprintf(cpayrate1, sizeof(cpayrate1), "%6.2f", petracegra[petgroup].payrate1);
if (petracegra[petgroup].payrate2 == 0)
snprintf(cpayrate2, sizeof(cpayrate2), "???");
else
snprintf(cpayrate2, sizeof(cpayrate2), "%6.2f", petracegra[petgroup].payrate2);
if (petracegra[petgroup].payrate3 == 0)
snprintf(cpayrate3, sizeof(cpayrate3), "???");
else
snprintf(cpayrate3, sizeof(cpayrate3), "%6.2f", petracegra[petgroup].payrate3);
#endif
if (total == 0)
{
winrate1 = 0; winrate2 = 0; winrate3 = 0;
}
else
{
winrate1 = (float)pet1win / (float)total;
winrate2 = (float)pet2win / (float)total;
winrate3 = (float)pet3win / (float)total;
}
#ifdef _DROPSTAKENEW
sprintf(token, "녘膠榴워\n\n 녘膠 價끝 겨끝 榴워 價끝쪽\n"
"========================================"
"%-10s%-6d%-6d%-8s%-6.2f\n"
"%-10s%-6d%-6d%-8s%-6.2f\n"
"%-10s%-6d%-6d%-8s%-6.2f\n",
CHAR_getChar(petindex1, CHAR_NAME), pet1win, total - pet1win,
petracegra[petgroup].state1, winrate1,
CHAR_getChar(petindex2, CHAR_NAME), pet2win, total - pet2win,
petracegra[petgroup].state2, winrate2,
CHAR_getChar(petindex3, CHAR_NAME), pet3win, total - pet3win,
petracegra[petgroup].state3, winrate3);
#else
sprintf(token, "녘膠榴워\n\n 녘膠 價끝 겨끝 榴워 價끝쪽 톄쪽\n"
"========================================"
"%-10s%-6d%-6d%-6s%-6.2f%-4s\n"
"%-10s%-6d%-6d%-6s%-6.2f%-4s\n"
"%-10s%-6d%-6d%-6s%-6.2f%-4s\n",
CHAR_getChar(petindex1, CHAR_NAME), pet1win, total - pet1win,
petracegra[petgroup].state1, winrate1, cpayrate1,
CHAR_getChar(petindex2, CHAR_NAME), pet2win, total - pet2win,
petracegra[petgroup].state2, winrate2, cpayrate2,
CHAR_getChar(petindex3, CHAR_NAME), pet3win, total - pet3win,
petracegra[petgroup].state3, winrate3, cpayrate3);
#endif
buttontype = WINDOW_BUTTONTYPE_OK;
windowtype = WINDOW_MESSAGETYPE_MESSAGE;
windowno = CHAR_WINDOWTYPE_PETRACEMASTER_PET;
}
break;
case 3:
default:
break;
}
lssproto_WN_send(fd, windowtype, buttontype, windowno,
CHAR_getWorkInt(meindex, CHAR_WORKOBJINDEX), token);
}
void NPC_PetRaceMasterWindowTalked(int meindex, int talkerindex, int seqno, int select, char *data)
{
int datanum = 0;
makeStringFromEscaped(data);
datanum = atoi(data);
switch(seqno)
{
case CHAR_WINDOWTYPE_PETRACEMASTER_START:
if (datanum == 1)
NPC_PetRaceMaster_selectWindow(meindex, talkerindex, 1, -1);
else if (datanum == 2)
NPC_PetRaceMaster_selectWindow(meindex, talkerindex, 2, -1);
break;
case CHAR_WINDOWTYPE_PETRACEMASTER_RULE:
if (datanum == 3)
NPC_PetRaceMaster_selectWindow(meindex, talkerindex, 1, -1);
case CHAR_WINDOWTYPE_PETRACEMASTER_PET:
case CHAR_WINDOWTYPE_PETRACEMASTER_LEAVE:
default:
break;
}
}
void NPC_PetRaceMasterLoop( int meindex)
{
int floor = CHAR_getInt(meindex, CHAR_FLOOR);
time_t t1;
time(&t1);
switch(CHAR_getWorkInt(meindex, NPC_WORK_STATE))
{
case NPC_State_Init:
// 璣冷녘膠index
NPC_findRacePetIndex(meindex, floor);
break;
case NPC_State_WaitDropStake:
{
char tmpbuf[256];
int statechangetime = CHAR_getWorkInt(meindex, NPC_WORK_STATECHANGE);
if (t1 < statechangetime)
{
if (statechangetime - t1 <= 5)
{
CHAR_setInt(meindex, CHAR_LOOPINTERVAL, PETRACEMASTER_WAITDROPIV_LOOPTIME);
snprintf(tmpbuf, sizeof(tmpbuf), "뻘唐%2d취앎狼역텝죄헝댕소坍禿苟鬧",
(int)(statechangetime - t1) % 60);
}
else if (statechangetime - t1 <= 10)
{
CHAR_setInt(meindex, CHAR_LOOPINTERVAL, PETRACEMASTER_WAITDROPIII_LOOPTIME);
snprintf(tmpbuf, sizeof(tmpbuf), "뻘唐%2d취앎狼역텝죄헝댕소坍禿苟鬧",
(int)(statechangetime - t1) % 60);
}
else if (statechangetime - t1 <= 30)
{
CHAR_setInt(meindex, CHAR_LOOPINTERVAL, PETRACEMASTER_WAITDROPII_LOOPTIME);
snprintf(tmpbuf, sizeof(tmpbuf), "뻘唐%2d취앎狼역텝죄헝댕소坍禿苟鬧",
(int)(statechangetime - t1) % 60);
}
else
snprintf(tmpbuf, sizeof(tmpbuf), "뻘唐%2d롸爐%2d취앎狼역텝죄헝댕소坍禿苟鬧",
(int)(statechangetime - t1) / 60, (int)(statechangetime - t1) % 60);
}
if (t1 >= statechangetime)
{
#ifdef _DROPSTAKENEW
#else
float payrate1 = 0, payrate2 = 0, payrate3 = 0;
int pet1gold = 0, pet2gold = 0, pet3gold = 0, totalgold = 0;
int petindex1 = CHAR_getWorkInt(meindex, NPC_WORK_PET1);
int petindex2 = CHAR_getWorkInt(meindex, NPC_WORK_PET2);
int petindex3 = CHAR_getWorkInt(meindex, NPC_WORK_PET3);
int randpet = CHAR_getWorkInt(meindex, NPC_WORK_PETGROUP);
float droprate1 = 0, droprate2 = 0, droprate3 = 0, totaldroprate, Npayrate = PETRACESTDPAYRATE;
#endif
int i = 0;
CHAR_setWorkInt(meindex, NPC_WORK_STATE, NPC_State_PetRacing);
// <20>땍뒈충꼇옵苟鬧
SetCasinoMap(meindex, 0, FALSE);
#ifdef _DROPSTAKENEW
snprintf(tmpbuf, sizeof(tmpbuf), "헝댕소界岺苟鬧,녘膠힙텝역迦쭈!");
#else
// 멩列댕소톄쪽(혤돤녘膠苟鬧쏜띨셕炬톄쪽)
GetCasinoMapGold(meindex, PET_RACE1, &pet1gold);
GetCasinoMapGold(meindex, PET_RACE2, &pet2gold);
GetCasinoMapGold(meindex, PET_RACE3, &pet3gold);
totalgold = pet1gold + pet2gold + pet3gold;
if (totalgold <= 0)
{
payrate1 = 2; payrate2 = 2; payrate3 = 2;
}
else
{
if (pet1gold <= PETRACESTDGOLD)
pet1gold = PETRACESTDGOLD;
if (pet2gold <= PETRACESTDGOLD)
pet2gold = PETRACESTDGOLD;
if (pet3gold <= PETRACESTDGOLD)
pet3gold = PETRACESTDGOLD;
totalgold = pet1gold + pet2gold + pet3gold;
droprate1 = totalgold / pet1gold;
droprate2 = totalgold / pet2gold;
droprate3 = totalgold / pet3gold;
totaldroprate = droprate1 + droprate2 + droprate3;
if (totaldroprate / droprate1 > PETRACESTDPAYRATE)
{
payrate1 = 1; Npayrate -= 1;
}
if (totaldroprate / droprate2 > PETRACESTDPAYRATE)
{
payrate2 = 1; Npayrate -= 1;
}
if (totaldroprate / droprate3 > PETRACESTDPAYRATE)
{
payrate3 = 1; Npayrate -= 1;
}
if (payrate1 != 1)
payrate1 = droprate1 / totaldroprate * Npayrate;
if (payrate2 != 1)
payrate2 = droprate2 / totaldroprate * Npayrate;
if (payrate3 != 1)
payrate3 = droprate3 / totaldroprate * Npayrate;
}
petracegra[randpet].payrate1 = payrate1;
petracegra[randpet].payrate3 = payrate2;
petracegra[randpet].payrate2 = payrate3;
SetCasinoPayRate(meindex, PET_RACE1, payrate1);
SetCasinoPayRate(meindex, PET_RACE2, payrate2);
SetCasinoPayRate(meindex, PET_RACE3, payrate3);
snprintf(tmpbuf, sizeof(tmpbuf), "헝댕소界岺苟鬧,녘膠힙텝역迦쭈!%s돨톄쪽槨%5.2f%s돨톄쪽槨%5.2f%s돨톄쪽槨%5.2f",
CHAR_getChar(petindex1, CHAR_NAME), payrate1,
CHAR_getChar(petindex2, CHAR_NAME), payrate2,
CHAR_getChar(petindex3, CHAR_NAME), payrate3);
#endif
CHAR_setInt(meindex, CHAR_LOOPINTERVAL, PETRACEMASTER_PETRACING_LOOPTIME);
// <20>땍녘膠榴檄
for (i = 0; i < PETRACEPETNUM; i++)
{
CHAR_setWorkInt(CHAR_getWorkInt(meindex, NPC_WORK_PET1 + i), NPC_WORK_STATE, NPC_State_Run);
CHAR_setInt(CHAR_getWorkInt(meindex, NPC_WORK_PET1 + i), CHAR_LOOPINTERVAL, 1000);
}
}
CHAR_talkToFloor(floor, meindex, tmpbuf, CHAR_COLORWHITE);
}
break;
case NPC_State_PetRacing:
if (CHAR_getWorkInt(meindex, NPC_WORK_PETGOAL) == PETRACEPETNUM)
{
char tmpbuf[256];
int winpetindex = CHAR_getWorkInt(meindex, NPC_WORK_WINPET);
int petgroup = CHAR_getWorkInt(meindex, NPC_WORK_PETGROUP);
snprintf(tmpbuf, sizeof(tmpbuf), "씌힙써監,價적돨녘膠角:%s\n",
CHAR_getChar(winpetindex, CHAR_NAME));
CHAR_talkToFloor(floor, meindex, tmpbuf, CHAR_COLORYELLOW);
// <20>땍渴端鹿셕炬톄쪽
if (CHAR_getWorkInt(meindex, NPC_WORK_PET1) == winpetindex)
petracegra[petgroup].pet1win = petracegra[petgroup].pet1win + 1;
else if (CHAR_getWorkInt(meindex, NPC_WORK_PET2) == winpetindex)
petracegra[petgroup].pet2win = petracegra[petgroup].pet2win + 1;
else if (CHAR_getWorkInt(meindex, NPC_WORK_PET3) == winpetindex)
petracegra[petgroup].pet3win = petracegra[petgroup].pet3win + 1;
CHAR_setWorkInt(meindex, NPC_WORK_STATE, NPC_State_ShowWinPet);
CHAR_setInt(meindex, CHAR_LOOPINTERVAL, PETRACEMASTER_SHOWWINPET_LOOPTIME);
CHAR_setWorkInt(meindex, NPC_WORK_STATECHANGE, t1 + PETRACESHOWWINPET);
// 랙쉽쏜
NPC_givePriceToPlayer(meindex, floor, winpetindex);
}
break;
case NPC_State_ShowWinPet:
{
int statechangetime = CHAR_getWorkInt(meindex, NPC_WORK_STATECHANGE);
if (t1 >= statechangetime)
{
int randpet = RAND(0, arraysizeof(petracegra) - 1);
int petindex1 = CHAR_getWorkInt(meindex, NPC_WORK_PET1);
int petindex2 = CHAR_getWorkInt(meindex, NPC_WORK_PET2);
int petindex3 = CHAR_getWorkInt(meindex, NPC_WORK_PET3);
char tmpbuf[256];
CHAR_setWorkInt(meindex, NPC_WORK_PETGROUP, randpet);
CHAR_setWorkInt(meindex, NPC_WORK_STATE, NPC_State_WaitDropStake);
CHAR_setWorkInt(meindex, NPC_WORK_WINPET, 0);
CHAR_setWorkInt(meindex, NPC_WORK_PETGOAL, 0);
CHAR_setWorkInt(meindex, NPC_WORK_STATECHANGE, t1 + PETRACEDROPSTAKETIME);
CHAR_setInt(meindex, CHAR_LOOPINTERVAL, PETRACEMASTER_WAITDROPI_LOOPTIME);
// <20>땍뒈충옵苟鬧
SetCasinoMap(meindex, 0, TRUE);
// <20>땍녘膠
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);
// <20>땍녘膠榴워
#ifdef _DROPSTAKENEW
#else
petracegra[randpet].payrate1 = 0;
petracegra[randpet].payrate3 = 0;
petracegra[randpet].payrate2 = 0;
#endif
{
int state1 = RAND(0, 3);
int state2 = RAND(0, 3);
int state3 = RAND(0, 3);
if (state1 == 0)
sprintf(petracegra[randpet].state1, "좁봤");
else if (state1 == 1)
sprintf(petracegra[randpet].state1, "팹繫");
else if (state1 == 2)
sprintf(petracegra[randpet].state1, "꼇솅");
else if (state1 == 3)
sprintf(petracegra[randpet].state1, "灌列");
if (state2 == 0)
sprintf(petracegra[randpet].state2, "좁봤");
else if (state2 == 1)
sprintf(petracegra[randpet].state2, "팹繫");
else if (state2 == 2)
sprintf(petracegra[randpet].state2, "꼇솅");
else if (state2 == 3)
sprintf(petracegra[randpet].state2, "灌列");
if (state3 == 0)
sprintf(petracegra[randpet].state3, "좁봤");
else if (state3 == 1)
sprintf(petracegra[randpet].state3, "팹繫");
else if (state3 == 2)
sprintf(petracegra[randpet].state3, "꼇솅");
else if (state3 == 3)
sprintf(petracegra[randpet].state3, "灌列");
}
snprintf(tmpbuf, sizeof(tmpbuf), "녘膠씌醵硫구櫓,헝댕소坍禿苟鬧!");
CHAR_talkToFloor(floor, meindex, tmpbuf, CHAR_COLORYELLOW);
}
}
break;
default:
break;
}
}
void NPC_findRacePetIndex(int meindex, int floor)
{
int i = 0, j = 0;
time_t t1;
time(&t1);
if (CHAR_getWorkInt(meindex, NPC_WORK_FINDPETFLAG) == 0)
{
for (i = 0; i < CHAR_getCharNum(); i++)
{
if (CHAR_getInt(i, CHAR_FLOOR) == floor)
{
if (CHAR_getInt(i, CHAR_WHICHTYPE) == CHAR_PETRACEPET)
{
for (j = 0; j < PETRACEPETNUM; j++)
{
if (CHAR_getWorkInt(meindex, NPC_WORK_PET1 + j) == 0)
{
CHAR_setWorkInt(meindex, NPC_WORK_PET1 + j, i);
CHAR_setWorkInt(i, CHAR_NPCWORKINT2, meindex);
break;
}
}
}
}
}
if (CHAR_getWorkInt(meindex, NPC_WORK_PET1) > 0
&& CHAR_getWorkInt(meindex, NPC_WORK_PET2) > 0
&& CHAR_getWorkInt(meindex, NPC_WORK_PET3) > 0)
{
CHAR_setWorkInt(meindex, NPC_WORK_FINDPETFLAG, 1);
CHAR_setWorkInt(meindex, NPC_WORK_STATE, NPC_State_WaitDropStake);
CHAR_setInt(meindex, CHAR_LOOPINTERVAL, PETRACEMASTER_WAITDROPI_LOOPTIME);
CHAR_setWorkInt(meindex, NPC_WORK_STATECHANGE, t1 + PETRACEDROPSTAKETIME);
}
else CHAR_setWorkInt(meindex, NPC_WORK_FINDPETFLAG, 0);
}
}
void NPC_givePriceToPlayer(int meindex, int floor, int winpetindex)
{
int wincasinotype = 0;
if (CHAR_getWorkInt(meindex, NPC_WORK_PET1) == winpetindex)
wincasinotype = PET_RACE1;
else if (CHAR_getWorkInt(meindex, NPC_WORK_PET2) == winpetindex)
wincasinotype = PET_RACE2;
else if (CHAR_getWorkInt(meindex, NPC_WORK_PET3) == winpetindex)
wincasinotype = PET_RACE3;
if (wincasinotype == 0) return;
else
CasinoPay(meindex, wincasinotype);
}
#endif