📄 init_npc_table.cpp
字号:
#include "..\stdafx.h"
#include "DefaultHeader.h"
#include "..\LowerLayers\MyLog.h"
NPCName_by_Gender NPC_Name_Ref[Num_Of_NPC_Name];
NPCLev_to_Exp NPC_Lev_Ref[Num_Of_NPC_Lev];
NPC_Generation NPC_Gen_Ref[Num_Of_NPC_Generation];
BYTE EnemyEnemy[100][100];
int NPC_FemaleName_Count;
int NPC_MaleName_Count;
int NPC_LastName_Count;
short int nNPC_Type, nNPC_Name, nNPC_Lev ;
int initNPCNameTable(void) ;
int initNPCLevTable(void) ;
int initNPCGenerationTable(void) ;
void MakeEnemyEnemyTable( void );
extern HDBC hDBC ;
// DB俊 乐绰 3俺狼 NPC 抛捞喉阑 皋葛府肺 佬绢柯促.
int initNPCTable(void)
{
if(initNPCNameTable() < 0) return -1 ;
if(initNPCLevTable() < 0) return -1 ;
if(initNPCGenerationTable() < 0) return -1 ;
MakeEnemyEnemyTable();
return 1 ;
}
void MakeEnemyEnemyTable( void )
{
int i,j;
int d;
for( i = 0 ; i < 98 ; i ++)
{
for( j = 0 ; j < 10 ; j ++)
{
d = NPC_Gen_Ref[i].offset[j];
if( d )
{
EnemyEnemy[i+1][d] = 1;
}
}
for( j = 10 ; j < 20 ; j ++)
{
d = NPC_Gen_Ref[i].offset[j];
if( d )
{
EnemyEnemy[i+1][d] = 2;
}
}
}
}
int GetEnemyEnemy( CHARLIST *attacker, CHARLIST *defender )
{
if( defender == NULL ) return 100;
int d = EnemyEnemy[attacker->SprNo][ defender->SprNo];
switch( d )
{
case 0 : return 100;
case 1 : return 75;
}
return 125;
}
// 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 order by No") ;
ret= SQLExecDirect(hStmt, (UCHAR *)query_stmt, SQL_NTS) ;
if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
extern void displaySQLError(SQLHSTMT hstmt);
displaySQLError( hStmt );
MyLog( LOG_FATAL, "NPC_NamebyGender : ExecDirect Error" );
return -1 ;
}
//SQLNumResultCols(hStmt, &nCols) ;
ret= SQLFetch(hStmt) ;
ret= SQLFetch(hStmt) ;
if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS)
{
MyLog( LOG_FATAL, "NPC_NamebyGender : Fetch ERROR" );
return -1 ;
}
NPC_FemaleName_Count = 0;
NPC_MaleName_Count = 0;
NPC_LastName_Count = 0;
while(c < Num_Of_NPC_Name && ret == SQL_SUCCESS)
{
ret= SQLGetData(hStmt, 2, SQL_C_CHAR, (UCHAR *)NPC_Name_Ref[NPC_FemaleName_Count].Female, 17, &cbValue) ;
if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
MyLog( LOG_FATAL, "NPC_NamebyGender :String GET Error!!! (%d)", ret);
return -1 ;
}
if( NPC_Name_Ref[NPC_FemaleName_Count].Female[0] )
{
NPC_FemaleName_Count++;
}
ret= SQLGetData(hStmt, 3, SQL_C_CHAR, (UCHAR *)NPC_Name_Ref[NPC_MaleName_Count].Male, 17, &cbValue) ;
if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
MyLog( LOG_FATAL, "NPC_NamebyGender :String GET Error!!! (%d)", ret);
return -1 ;
}
if( NPC_Name_Ref[NPC_MaleName_Count].Male[0] )
{
NPC_MaleName_Count++;
}
ret= SQLGetData(hStmt, 4, SQL_C_CHAR, (UCHAR *)NPC_Name_Ref[NPC_LastName_Count].Last, 17, &cbValue) ;
if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
MyLog( LOG_FATAL, "NPC_NamebyGender :String GET Error!!! (%d)", ret);
return -1 ;
}
if( NPC_Name_Ref[NPC_LastName_Count].Last[0] )
{
NPC_LastName_Count++;
}
c++ ;
ret= SQLFetch(hStmt) ;
}
nNPC_Name = c ;
SQLFreeStmt(hStmt, SQL_DROP) ;
MyLog( LOG_NORMAL, " .NPC_NamebyGender %4d data Loaded", c) ;
FILE * fp;
int i;
// 泅犁 巢/咯 备盒捞 绝绰惑怕捞促.
fp = fopen( "./OutPut/Mon_Name.bin", "wb" );
if( fp )
{
for( i = 0 ; i < NPC_FemaleName_Count ; i ++)
{
char *p = strchr( NPC_Name_Ref[i].Male, ' ' );
if( p ) *p = '-';
fwrite( NPC_Name_Ref[i].Male, 17, 1, fp );
}
fclose( fp );
}
fp = fopen( "./OutPut/Mon_Name.txt", "wt" );
if( fp )
{
for( i = 0 ; i < NPC_FemaleName_Count ; i ++)
{
fprintf( fp, "%s\n", NPC_Name_Ref[i].Male );
}
fclose( fp );
}
return c ;
}
// 0811 NPC KHS
// NPC饭骇苞 版氰摹 包访 沥焊甫 淬绊 乐绰 抛捞喉阑 DB俊辑 佬绢坷绰 窃荐
int initNPCLevTable(void)
{
if(Num_Of_NPC_Lev <= 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= 1 ;
SQLAllocStmt(hDBC, &hStmt);
strcpy(query_stmt, "select * from NPC_Lv2Exp order by Lv") ;
ret= SQLExecDirect(hStmt, (UCHAR *)query_stmt, SQL_NTS) ;
if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS) {
MyLog( LOG_FATAL, "NPC_Lv2Exp: ExecDirect Error " );
return -1 ;
}
//SQLNumResultCols(hStmt, &nCols) ;
ret= SQLFetch(hStmt) ;
if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS)
{
MyLog( LOG_FATAL, "NPC_Lv2Exp:: Fetch Error" ) ;
return -1 ;
}
while(c < Num_Of_NPC_Lev && ret == SQL_SUCCESS)
{
ret = SQLGetData(hStmt, 2, SQL_C_SLONG, &NPC_Lev_Ref[c].nMinExp, 0, &cbValue);
ret = SQLGetData(hStmt, 3, SQL_C_SLONG, &NPC_Lev_Ref[c].nMaxExp, 0, &cbValue);
ret = SQLGetData(hStmt, 4, SQL_C_SLONG, &NPC_Lev_Ref[c].nNeedExp, 0, &cbValue);
ret = SQLGetData(hStmt, 5, SQL_C_SLONG, &NPC_Lev_Ref[c].nTrainingExp, 0, &cbValue);
ret = SQLGetData(hStmt, 6, SQL_C_FLOAT, &NPC_Lev_Ref[c].fExpReduction, 0, &cbValue); // CSD-030430
ret = SQLGetData(hStmt, 7, SQL_C_FLOAT, &NPC_Lev_Ref[c].fNKReduction, 0, &cbValue); // CSD-030430
ret = SQLGetData(hStmt, 8, SQL_C_SLONG, &NPC_Lev_Ref[c].nTacRate, 0, &cbValue);
ret = SQLGetData(hStmt, 9, SQL_C_SLONG, &NPC_Lev_Ref[c].nMaxTactic, 0, &cbValue);
ret = SQLGetData(hStmt, 10, SQL_C_SLONG, &NPC_Lev_Ref[c].nDyeingPrice, 0, &cbValue);
ret = SQLGetData(hStmt, 11, SQL_C_SLONG, &NPC_Lev_Ref[c].nLessRate, 0, &cbValue);
ret = SQLGetData(hStmt, 12, SQL_C_SLONG, &NPC_Lev_Ref[c].nGreatRate, 0, &cbValue);
ret = SQLGetData(hStmt, 13, SQL_C_SLONG, &NPC_Lev_Ref[c].nCspMax, 0, &cbValue);
ret = SQLGetData(hStmt, 14, SQL_C_SLONG, &NPC_Lev_Ref[c].nBaseCP, 0, &cbValue);
ret = SQLGetData(hStmt, 15, SQL_C_SLONG, &NPC_Lev_Ref[c].bank_loan, 0, &cbValue);
ret = SQLGetData(hStmt, 16, SQL_C_SLONG, &NPC_Lev_Ref[c].nStep, 0, &cbValue);
ret = SQLGetData(hStmt, 17, SQL_C_SLONG, &NPC_Lev_Ref[c].nWarriorLife, 0, &cbValue);
ret = SQLGetData(hStmt, 18, SQL_C_SLONG, &NPC_Lev_Ref[c].nThiefLife, 0, &cbValue);
ret = SQLGetData(hStmt, 19, SQL_C_SLONG, &NPC_Lev_Ref[c].nArcherLife, 0, &cbValue);
ret = SQLGetData(hStmt, 20, SQL_C_SLONG, &NPC_Lev_Ref[c].nWizardLife, 0, &cbValue);
ret = SQLGetData(hStmt, 21, SQL_C_SLONG, &NPC_Lev_Ref[c].nPriestLife, 0, &cbValue);
ret = SQLGetData(hStmt, 22, SQL_C_SLONG, &NPC_Lev_Ref[c].nWarriorExpRate, 0, &cbValue);
ret = SQLGetData(hStmt, 23, SQL_C_SLONG, &NPC_Lev_Ref[c].nThiefExpRate, 0, &cbValue);
ret = SQLGetData(hStmt, 24, SQL_C_SLONG, &NPC_Lev_Ref[c].nArcherExpRate, 0, &cbValue);
ret = SQLGetData(hStmt, 25, SQL_C_SLONG, &NPC_Lev_Ref[c].nWizardExpRate, 0, &cbValue);
ret = SQLGetData(hStmt, 26, SQL_C_SLONG, &NPC_Lev_Ref[c].nPriestExpRate, 0, &cbValue);
if(ret != SQL_SUCCESS_WITH_INFO && ret != SQL_SUCCESS)
{
MyLog( LOG_FATAL, "NPC_Lv2Exp: Error!!! (%d)", ret) ;
return -1 ;
}
c++ ;
ret= SQLFetch(hStmt) ;
}
nNPC_Lev= c ;
SQLFreeStmt(hStmt, SQL_DROP) ;
MyLog( LOG_NORMAL, " .NPC_Lv2Exp %4d data Loaded", c );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -