📄 init_npc_table.cpp
字号:
#include "StdAfx.h"
#include "main.h"
NPCName_by_Gender NPC_Name_Ref[Num_Of_NPC_Name] ;
NPC_Info NPC_Info_Ref[Num_Of_NPC_Type] ;
NPC_Generation NPC_Gen_Ref[Num_Of_NPC_Generation] ;
int NPC_First_Ref[2][10]= {
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003
} ;
int NPC_Class_Ref[6][10]= {
1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002,
1010, 1008, 0, 0, 0, 1005, 1006, 1004, 0, 0,
0, 1005, 1008, 0, 1004, 1010, 0, 0, 0, 1006,
1006, 1005, 1010, 0, 1004, 1008, 0, 0, 0, 0,
0, 0, 0, 1008, 1010, 1005, 0, 1006, 0, 1004,
0, 1005, 0, 1010, 1008, 0, 1004, 1006, 0, 0
} ;
short int nNPC_Type, nNPC_Name, nNPC_Lev ;
int initNPCInfoTable(void) ;
int initNPCNameTable(void) ;
int initNPCGenerationTable(void) ;
extern HDBC hDBC ;
// DB俊 乐绰 3俺狼 NPC 抛捞喉阑 皋葛府肺 佬绢柯促.
int initNPCTable(void)
{
if(initNPCInfoTable() < 0) return -1 ;
if(initNPCNameTable() < 0) return -1 ;
if(initNPCGenerationTable() < 0) return -1 ;
return 1 ;
}
// NPC捞抚 积己阑 困茄 抛捞喉阑 DB俊辑 佬绢坷绰 窃荐
int initNPCNameTable(void)
{
if(Num_Of_NPC_Name <= 0) {
//fprintf(stdout, "\n No item's available ") ;
return -4 ; // No item's available
}
HSTMT hStmt= NULL ;
RETCODE ret ;
char query_stmt[80]= {0, } ;
SDWORD cbValue ;
int c= 0 ;
SQLAllocStmt(hDBC, &hStmt);
/////////////////////////////////////////////////////////////////////////////
//strcpy(query_stmt, "select * from NPC_NamebyGender") ;
sprintf(query_stmt, "EXEC up_get_npc_namebygender");
/////////////////////////////////////////////////////////////////////////////
ret= SQLExecDirect(hStmt, (UCHAR *)query_stmt, SQL_NTS) ;
if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
printf("\nNPC init: ExecDirect Error ") ;
return -1 ;
}
//SQLNumResultCols(hStmt, &nCols) ;
ret= SQLFetch(hStmt) ;
if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
LPVOID lpMsgBuf;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf, 0, NULL );// Process any inserts in lpMsgBuf.
// ...// Display the string.
printf("\nLast Error: %s", (LPCTSTR)lpMsgBuf) ;
// Free the buffer.
LocalFree( lpMsgBuf );
printf("\nNPC init: Fetch Error ") ;
return -1 ;
}
while(c < Num_Of_NPC_Name && ret == SQL_SUCCESS)
{
ret= SQLGetData(hStmt, 2, SQL_C_CHAR, (UCHAR *)NPC_Name_Ref[c].Female, 17, &cbValue) ;
if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
printf("\nString GET Error!!! (%d)", ret) ;
return -1 ;
}
ret= SQLGetData(hStmt, 3, SQL_C_CHAR, (UCHAR *)NPC_Name_Ref[c].Male, 17, &cbValue) ;
if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
printf("\nString GET Error!!! (%d)", ret) ;
return -1 ;
}
ret= SQLGetData(hStmt, 4, SQL_C_CHAR, (UCHAR *)NPC_Name_Ref[c].Last, 17, &cbValue) ;
if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
printf("\nString GET Error!!! (%d)", ret) ;
return -1 ;
}
c++ ;
ret= SQLFetch(hStmt) ;
}
nNPC_Name= c ;
SQLFreeStmt(hStmt, SQL_DROP) ;
printf(" .NPC Name %3d data Loaded !\n", c) ;
return c ;
}
// NPC沥焊(惑怕沥焊, 塞/瘤瓷 殿狼 阿辆 荐摹)甫 淬绊 乐绰 抛捞喉阑
// DB俊辑 佬绢坷绰 窃荐
int initNPCInfoTable(void)
{
if(Num_Of_NPC_Type <= 0) {
//fprintf(stdout, "\n No item's available ") ;
return -4 ; // No item's available
}
HSTMT hStmt= NULL ;
RETCODE ret ;
char query_stmt[80]= {0, } ;
SDWORD cbValue ;
int c= 0 ;
SQLAllocStmt(hDBC, &hStmt);
/////////////////////////////////////////////////////////////////////////////
//strcpy(query_stmt, "select * from NPC_Info") ;
strcpy(query_stmt, "EXEC up_get_npc_info");
/////////////////////////////////////////////////////////////////////////////
ret= SQLExecDirect(hStmt, (UCHAR *)query_stmt, SQL_NTS) ;
if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
printf("\nNPC init: ExecDirect Error ") ;
return -1 ;
}
//SQLNumResultCols(hStmt, &nCols) ;
ret= SQLFetch(hStmt) ;
if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
LPVOID lpMsgBuf;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf, 0, NULL );// Process any inserts in lpMsgBuf.
// ...// Display the string.
printf("\nLast Error: %s", (LPCTSTR)lpMsgBuf) ;
// Free the buffer.
LocalFree( lpMsgBuf );
printf("\nNPC init: Fetch Error ") ;
return -1 ;
}
while(c < Num_Of_NPC_Type && ret == SQL_SUCCESS)
{
// Accquire the DATA
/*
ret= SQLGetData(hStmt, 1, SQL_C_CHAR, (UCHAR *)NPC_Ref[c].Name, 20, &cbValue) ;
if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
printf("\nString GET Error!!! (%d)", ret) ;
return -1 ;
}
ret= SQLGetData(hStmt, 2, SQL_C_SLONG, &NPC_Ref[c].SprNo, sizeof(NPC_Ref[c].SprNo), &cbValue) ;
if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
printf("\nError!!! (%d)", ret) ;
return -1 ;
}
*/
//printf("\n %s %d", NPC_Ref[c].Name, NPC_Ref[c].SprNo) ;
ret = SQLGetData(hStmt, 3, SQL_C_ULONG, &NPC_Info_Ref[c].sprno, 0, &cbValue);
ret = SQLGetData(hStmt, 4, SQL_C_ULONG, &NPC_Info_Ref[c].face, 0, &cbValue);
ret = SQLGetData(hStmt, 5, SQL_C_ULONG, &NPC_Info_Ref[c].race, 0, &cbValue);
ret = SQLGetData(hStmt, 6, SQL_C_ULONG, &NPC_Info_Ref[c].spritvalue, 0, &cbValue);
ret = SQLGetData(hStmt, 7, SQL_C_ULONG, &NPC_Info_Ref[c].Class, 0, &cbValue);
ret = SQLGetData(hStmt, 8, SQL_C_ULONG, &NPC_Info_Ref[c].class_sprituality, 0, &cbValue);
ret = SQLGetData(hStmt, 9, SQL_C_ULONG, &NPC_Info_Ref[c].class_poisoning, 0, &cbValue);
ret = SQLGetData(hStmt, 10, SQL_C_ULONG, &NPC_Info_Ref[c].class_bombplay, 0, &cbValue);
ret = SQLGetData(hStmt, 11, SQL_C_ULONG, &NPC_Info_Ref[c].class_entrapment, 0, &cbValue);
ret = SQLGetData(hStmt, 12, SQL_C_ULONG, &NPC_Info_Ref[c].class_scrolling, 0, &cbValue);
ret = SQLGetData(hStmt, 13, SQL_C_ULONG, &NPC_Info_Ref[c].class_cunning1, 0, &cbValue);
ret = SQLGetData(hStmt, 14, SQL_C_ULONG, &NPC_Info_Ref[c].class_cunning2, 0, &cbValue);
ret = SQLGetData(hStmt, 15, SQL_C_ULONG, &NPC_Info_Ref[c].class_cunning3, 0, &cbValue);
ret = SQLGetData(hStmt, 16, SQL_C_ULONG, &NPC_Info_Ref[c].class_stealing, 0, &cbValue);
ret = SQLGetData(hStmt, 17, SQL_C_ULONG, &NPC_Info_Ref[c].job, 0, &cbValue);
ret = SQLGetData(hStmt, 18, SQL_C_ULONG, &NPC_Info_Ref[c].age, 0, &cbValue);
ret = SQLGetData(hStmt, 19, SQL_C_ULONG, &NPC_Info_Ref[c].lev, 0, &cbValue);
ret = SQLGetData(hStmt, 20, SQL_C_ULONG, &NPC_Info_Ref[c].hd, 0, &cbValue);
ret = SQLGetData(hStmt, 21, SQL_C_ULONG, &NPC_Info_Ref[c].exp, 0, &cbValue);
ret = SQLGetData(hStmt, 22, SQL_C_ULONG, &NPC_Info_Ref[c].pspow, 0, &cbValue);
ret = SQLGetData(hStmt, 23, SQL_C_ULONG, &NPC_Info_Ref[c].wspow, 0, &cbValue);
ret = SQLGetData(hStmt, 24, SQL_C_ULONG, &NPC_Info_Ref[c].divpow, 0, &cbValue);
ret = SQLGetData(hStmt, 25, SQL_C_ULONG, &NPC_Info_Ref[c].manapow, 0, &cbValue);
ret = SQLGetData(hStmt, 26, SQL_C_ULONG, &NPC_Info_Ref[c].orsnpow, 0, &cbValue);
ret = SQLGetData(hStmt, 27, SQL_C_ULONG, &NPC_Info_Ref[c].mjypow, 0, &cbValue);
ret = SQLGetData(hStmt, 28, SQL_C_ULONG, &NPC_Info_Ref[c].attackpow, 0, &cbValue);
ret = SQLGetData(hStmt, 29, SQL_C_ULONG, &NPC_Info_Ref[c].vitalpow, 0, &cbValue);
ret = SQLGetData(hStmt, 30, SQL_C_ULONG, &NPC_Info_Ref[c].hungrymax, 0, &cbValue);
ret = SQLGetData(hStmt, 31, SQL_C_ULONG, &NPC_Info_Ref[c].money, 0, &cbValue);
ret = SQLGetData(hStmt, 32, SQL_C_ULONG, &NPC_Info_Ref[c].strold, 0, &cbValue);
ret = SQLGetData(hStmt, 33, SQL_C_ULONG, &NPC_Info_Ref[c].conold, 0, &cbValue);
ret = SQLGetData(hStmt, 34, SQL_C_ULONG, &NPC_Info_Ref[c].dexold, 0, &cbValue);
ret = SQLGetData(hStmt, 35, SQL_C_ULONG, &NPC_Info_Ref[c].wisold, 0, &cbValue);
ret = SQLGetData(hStmt, 36, SQL_C_ULONG, &NPC_Info_Ref[c].intold, 0, &cbValue);
ret = SQLGetData(hStmt, 37, SQL_C_ULONG, &NPC_Info_Ref[c].movepold, 0, &cbValue);
ret = SQLGetData(hStmt, 38, SQL_C_ULONG, &NPC_Info_Ref[c].charold, 0, &cbValue);
ret = SQLGetData(hStmt, 39, SQL_C_ULONG, &NPC_Info_Ref[c].enduold, 0, &cbValue);
ret = SQLGetData(hStmt, 40, SQL_C_ULONG, &NPC_Info_Ref[c].healthold, 0, &cbValue);
ret = SQLGetData(hStmt, 41, SQL_C_ULONG, &NPC_Info_Ref[c].moralold, 0, &cbValue);
ret = SQLGetData(hStmt, 42, SQL_C_ULONG, &NPC_Info_Ref[c].luckold, 0, &cbValue);
ret = SQLGetData(hStmt, 43, SQL_C_ULONG, &NPC_Info_Ref[c].condition, 0, &cbValue);
//< CSD-010907
/*
ret = SQLGetData(hStmt, 44, SQL_C_ULONG, &NPC_Info_Ref[c].resist_poison, 0, &cbValue);
ret = SQLGetData(hStmt, 45, SQL_C_ULONG, &NPC_Info_Ref[c].resist_stone, 0, &cbValue);
ret = SQLGetData(hStmt, 46, SQL_C_ULONG, &NPC_Info_Ref[c].resist_magic, 0, &cbValue);
ret = SQLGetData(hStmt, 47, SQL_C_ULONG, &NPC_Info_Ref[c].resist_fire, 0, &cbValue);
ret = SQLGetData(hStmt, 48, SQL_C_ULONG, &NPC_Info_Ref[c].resist_ice, 0, &cbValue);
ret = SQLGetData(hStmt, 49, SQL_C_ULONG, &NPC_Info_Ref[c].resist_elect, 0, &cbValue);
*/
ret = SQLGetData(hStmt, 44, SQL_C_ULONG, &NPC_Info_Ref[c].nPoison, 0, &cbValue);
ret = SQLGetData(hStmt, 45, SQL_C_ULONG, &NPC_Info_Ref[c].nCurse, 0, &cbValue);
ret = SQLGetData(hStmt, 46, SQL_C_ULONG, &NPC_Info_Ref[c].nHoly, 0, &cbValue);
ret = SQLGetData(hStmt, 47, SQL_C_ULONG, &NPC_Info_Ref[c].nFire, 0, &cbValue);
ret = SQLGetData(hStmt, 48, SQL_C_ULONG, &NPC_Info_Ref[c].nIce, 0, &cbValue);
ret = SQLGetData(hStmt, 49, SQL_C_ULONG, &NPC_Info_Ref[c].nElect, 0, &cbValue);
//> CSD-010907
ret = SQLGetData(hStmt, 50, SQL_C_ULONG, &NPC_Info_Ref[c].ws[0], 0, &cbValue);
ret = SQLGetData(hStmt, 51, SQL_C_ULONG, &NPC_Info_Ref[c].ws[1], 0, &cbValue);
ret = SQLGetData(hStmt, 52, SQL_C_ULONG, &NPC_Info_Ref[c].ws[2], 0, &cbValue);
ret = SQLGetData(hStmt, 53, SQL_C_ULONG, &NPC_Info_Ref[c].ws[3], 0, &cbValue);
ret = SQLGetData(hStmt, 54, SQL_C_ULONG, &NPC_Info_Ref[c].ws[4], 0, &cbValue);
ret = SQLGetData(hStmt, 55, SQL_C_ULONG, &NPC_Info_Ref[c].ws[5], 0, &cbValue);
ret = SQLGetData(hStmt, 56, SQL_C_ULONG, &NPC_Info_Ref[c].ws[6], 0, &cbValue);
ret = SQLGetData(hStmt, 57, SQL_C_ULONG, &NPC_Info_Ref[c].ws[7], 0, &cbValue);
ret = SQLGetData(hStmt, 58, SQL_C_ULONG, &NPC_Info_Ref[c].ws[8], 0, &cbValue);
ret = SQLGetData(hStmt, 59, SQL_C_ULONG, &NPC_Info_Ref[c].ws[9], 0, &cbValue);
ret = SQLGetData(hStmt, 60, SQL_C_ULONG, &NPC_Info_Ref[c].ps[0], 0, &cbValue);
ret = SQLGetData(hStmt, 61, SQL_C_ULONG, &NPC_Info_Ref[c].ps[1], 0, &cbValue);
ret = SQLGetData(hStmt, 62, SQL_C_ULONG, &NPC_Info_Ref[c].ps[2], 0, &cbValue);
ret = SQLGetData(hStmt, 63, SQL_C_ULONG, &NPC_Info_Ref[c].ps[3], 0, &cbValue);
ret = SQLGetData(hStmt, 64, SQL_C_ULONG, &NPC_Info_Ref[c].ps[4], 0, &cbValue);
ret = SQLGetData(hStmt, 65, SQL_C_ULONG, &NPC_Info_Ref[c].ps[5], 0, &cbValue);
ret = SQLGetData(hStmt, 66, SQL_C_ULONG, &NPC_Info_Ref[c].ps[6], 0, &cbValue);
ret = SQLGetData(hStmt, 67, SQL_C_ULONG, &NPC_Info_Ref[c].ps[7], 0, &cbValue);
ret = SQLGetData(hStmt, 68, SQL_C_ULONG, &NPC_Info_Ref[c].ps[8], 0, &cbValue);
ret = SQLGetData(hStmt, 69, SQL_C_ULONG, &NPC_Info_Ref[c].ps[9], 0, &cbValue);
ret = SQLGetData(hStmt, 70, SQL_C_ULONG, &NPC_Info_Ref[c].acc_equip[0], 0, &cbValue);
ret = SQLGetData(hStmt, 71, SQL_C_ULONG, &NPC_Info_Ref[c].acc_equip[1], 0, &cbValue);
ret = SQLGetData(hStmt, 72, SQL_C_ULONG, &NPC_Info_Ref[c].acc_equip[2], 0, &cbValue);
ret = SQLGetData(hStmt, 73, SQL_C_ULONG, &NPC_Info_Ref[c].acc_equip[3], 0, &cbValue);
ret = SQLGetData(hStmt, 74, SQL_C_ULONG, &NPC_Info_Ref[c].acc_equip[4], 0, &cbValue);
ret = SQLGetData(hStmt, 75, SQL_C_ULONG, &NPC_Info_Ref[c].acc_equip[5], 0, &cbValue);
ret = SQLGetData(hStmt, 76, SQL_C_ULONG, &NPC_Info_Ref[c].normal_sight, 0, &cbValue);
ret = SQLGetData(hStmt, 77, SQL_C_ULONG, &NPC_Info_Ref[c].battle_sight, 0, &cbValue);
ret = SQLGetData(hStmt, 78, SQL_C_ULONG, &NPC_Info_Ref[c].invtry[0], 0, &cbValue);
ret = SQLGetData(hStmt, 79, SQL_C_ULONG, &NPC_Info_Ref[c].invtry[1], 0, &cbValue);
ret = SQLGetData(hStmt, 80, SQL_C_ULONG, &NPC_Info_Ref[c].invtry[2], 0, &cbValue);
ret = SQLGetData(hStmt, 81, SQL_C_ULONG, &NPC_Info_Ref[c].invtry[3], 0, &cbValue);
ret = SQLGetData(hStmt, 82, SQL_C_ULONG, &NPC_Info_Ref[c].invtry[4], 0, &cbValue);
ret = SQLGetData(hStmt, 83, SQL_C_ULONG, &NPC_Info_Ref[c].invtry[5], 0, &cbValue);
ret = SQLGetData(hStmt, 84, SQL_C_ULONG, &NPC_Info_Ref[c].invtry[6], 0, &cbValue);
ret = SQLGetData(hStmt, 85, SQL_C_ULONG, &NPC_Info_Ref[c].invtry[7], 0, &cbValue);
ret = SQLGetData(hStmt, 86, SQL_C_ULONG, &NPC_Info_Ref[c].invtry[8], 0, &cbValue);
ret = SQLGetData(hStmt, 87, SQL_C_ULONG, &NPC_Info_Ref[c].invtry[9], 0, &cbValue);
ret = SQLGetData(hStmt, 88, SQL_C_ULONG, &NPC_Info_Ref[c].invtry[10], 0, &cbValue);
ret = SQLGetData(hStmt, 89, SQL_C_ULONG, &NPC_Info_Ref[c].invtry[11], 0, &cbValue);
ret = SQLGetData(hStmt, 90, SQL_C_ULONG, &NPC_Info_Ref[c].invtry[12], 0, &cbValue);
ret = SQLGetData(hStmt, 91, SQL_C_ULONG, &NPC_Info_Ref[c].invtry[13], 0, &cbValue);
ret = SQLGetData(hStmt, 92, SQL_C_ULONG, &NPC_Info_Ref[c].invtry[14], 0, &cbValue);
ret = SQLGetData(hStmt, 93, SQL_C_ULONG, &NPC_Info_Ref[c].tactics, 0, &cbValue);
ret = SQLGetData(hStmt, 94, SQL_C_ULONG, &NPC_Info_Ref[c].CRAPPLE, 0, &cbValue);
ret = SQLGetData(hStmt, 95, SQL_C_ULONG, &NPC_Info_Ref[c].SWORDMANSHIP, 0, &cbValue);
ret = SQLGetData(hStmt, 96, SQL_C_ULONG, &NPC_Info_Ref[c].ARCHERY, 0, &cbValue);
ret = SQLGetData(hStmt, 97, SQL_C_ULONG, &NPC_Info_Ref[c].FENCING, 0, &cbValue);
ret = SQLGetData(hStmt, 98, SQL_C_ULONG, &NPC_Info_Ref[c].MACEFIGHTING, 0, &cbValue);
ret = SQLGetData(hStmt, 99, SQL_C_ULONG, &NPC_Info_Ref[c].PIERCE, 0, &cbValue);
ret = SQLGetData(hStmt, 100, SQL_C_ULONG, &NPC_Info_Ref[c].WHIRL, 0, &cbValue);
ret = SQLGetData(hStmt, 101, SQL_C_ULONG, &NPC_Info_Ref[c].HURL, 0, &cbValue);
ret = SQLGetData(hStmt, 102, SQL_C_ULONG, &NPC_Info_Ref[c].PARRING, 0, &cbValue);
ret = SQLGetData(hStmt, 103, SQL_C_ULONG, &NPC_Info_Ref[c].DOUBL_SWORDMANSHIP, 0, &cbValue);
ret = SQLGetData(hStmt, 104, SQL_C_ULONG, &NPC_Info_Ref[c].DOUBL_MACEFIGHTING, 0, &cbValue);
ret = SQLGetData(hStmt, 105, SQL_C_ULONG, &NPC_Info_Ref[c].cooper, 0, &cbValue);
ret = SQLGetData(hStmt, 106, SQL_C_ULONG, &NPC_Info_Ref[c].MORDERATION, 0, &cbValue);
ret = SQLGetData(hStmt, 107, SQL_C_ULONG, &NPC_Info_Ref[c].royal, 0, &cbValue);
ret = SQLGetData(hStmt, 108, SQL_C_ULONG, &NPC_Info_Ref[c].courage, 0, &cbValue);
ret = SQLGetData(hStmt, 109, SQL_C_ULONG, &NPC_Info_Ref[c].faith, 0, &cbValue);
ret = SQLGetData(hStmt, 110, SQL_C_ULONG, &NPC_Info_Ref[c].truth, 0, &cbValue);
ret = SQLGetData(hStmt, 111, SQL_C_ULONG, &NPC_Info_Ref[c].justice, 0, &cbValue);
ret = SQLGetData(hStmt, 112, SQL_C_ULONG, &NPC_Info_Ref[c].mercy, 0, &cbValue);
ret = SQLGetData(hStmt, 113, SQL_C_ULONG, &NPC_Info_Ref[c].murder, 0, &cbValue);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -