📄 npctemplate.c
字号:
"","","","TranserManLoop",
"","TranserManTalked","","",
"","", "","","TranserManWindowTalked"
}
#endif
#ifdef _NPC_SELLSTH
/* SellsthMan */
,{ "SellsthMan","SellsthManInit","","",
"","","","SellsthManLoop",
"","SellsthManTalked","","",
"","", "","","SellsthManWindowTalked"
}
#endif
#ifdef _NPC_MAKEPAIR
,{ "MakePair","MakePairManInit","","",
"","","","MakePairManLoop",
"","MakePairManTalked","","",
"","", "","","MakePairManWindowTalked"
}
#endif
#ifdef _NPC_FUSION
,{ "PetFusion","PetFusionManInit","","",
"","","","PetFusionManLoop",
"","PetFusionManTalked","","",
"","", "","","PetFusionManWindowTalked"
}
#endif
#ifdef _PAUCTION_MAN
/* PauctionMan */
,{ "PauctionMan","PauctionManInit","","",
"","","","PauctionManLoop",
"","PauctionManTalked","","",
"","", "","","PauctionManWindowTalked"
}
#endif
#ifdef _ITEM_NPCCHANGE
,{ "ItemchangeMan","ItemchangeManInit","","",
"","","","ItemchangeManLoop",
"","ItemchangeManTalked","","",
"","", "","","ItemchangeManWindowTalked"
}
#endif
#ifdef _CFREE_petskill
,{
"NPC_FreePetSkill","FreePetSkillInit","","","","","",
"","",
"FreePetSkillTalked","","","","","","",
"FreePetSkillWindowTalked"
}
#endif
#ifdef _PETRACE
//主持人
,{
"PetRaceMaster","PetRaceMasterInit","","","","","",
"PetRaceMasterLoop","",
"PetRaceMasterTalked","","","","","","",
"PetRaceMasterWindowTalked"
}
// 宠物
,{
"PetRacePet","PetRacePetInit","","","","","",
"PetRacePetLoop","",
"PetRacePetTalked","","","","","","",""
}
#endif
#ifdef _NEW_WARPMAN
,{
"NPC_NewNpcMan","NewNpcManInit","","","","","",
"NewNpcManLoop","",
"NewNpcManTalked","","","","","","",
"NewNpcManWindowTalked"
}
#endif
#ifdef _MARKET_TRADE
,{
"NPC_MTradeNpcMan","MapTradeManInit","","","","","",
"MapTradeManLoop","",
"MapTradeManTalked","","","","","","",
"MapTradeManWindowTalked"
}
#endif
#ifdef _BLACK_MARKET
,{
"BlackMarket",
"BlackMarketInit","","","","","","","","BlackMarketTalked","","",
"","", "","","BlackMarketWindowTalked"
}
#endif
#ifdef _ALLDOMAN // (不可开) Syu ADD 排行榜NPC
,{
"Alldoman","AlldomanInit","","",
"","","","","","AlldomanTalked","","","","","","",
"AlldomanWindowTalked"}
#endif
#ifdef _NPC_WELFARE
,{ "Welfare","WelfareInit","","",
"","","","",
"","WelfareTalked","","",
"","", "","","WelfareWindowTalked"}
#endif
#ifdef _NPC_VERYWELFARE
,{ "VeryWelfare","VeryWelfareInit","","",
"","","","",
"","VeryWelfareTalked","","",
"","", "","","VeryWelfareWindowTalked"}
#endif
#ifdef _NPC_WELFARE_2 // WON ADD 职业NPC-2
,{ "Welfare2","WelfareInit2","","",
"","","","",
"","WelfareTalked2","","",
"","", "","","WelfareWindowTalked2"}
#endif
#ifdef _RACEMAN
,{"Raceman","RacemanInit", "", "",
"", "", "", "",
"", "RacemanTalked", "", "",
"", "", "", "","RacemanWindowTalked"},
#endif
};
static int NPC_searchFunctionSet( char* name, int* unuse)
{
int i;
for( i=0 ; i <arraysizeof( functionSet ) ; i++ )
if( strcasecmp( name, functionSet[i].id ) == 0 )
return i;
return -1;
}
BOOL NPC_copyFunctionSetToChar( int id, Char* ch )
{
if( id<0 || id>=arraysizeof(functionSet) )return FALSE;
strcpysafe( ch->charfunctable[CHAR_INITFUNC].string,
sizeof( ch->charfunctable[CHAR_INITFUNC].string ),
functionSet[id].initfunc);
strcpysafe( ch->charfunctable[CHAR_WALKPREFUNC].string,
sizeof(ch->charfunctable[CHAR_WALKPREFUNC].string),
functionSet[id].walkprefunc);
strcpysafe( ch->charfunctable[CHAR_WALKPOSTFUNC].string,
sizeof(ch->charfunctable[CHAR_WALKPOSTFUNC].string),
functionSet[id].walkpostfunc);
strcpysafe( ch->charfunctable[CHAR_PREOVERFUNC].string,
sizeof(ch->charfunctable[CHAR_PREOVERFUNC].string),
functionSet[id].preoverfunc);
strcpysafe( ch->charfunctable[CHAR_POSTOVERFUNC].string,
sizeof(ch->charfunctable[CHAR_POSTOVERFUNC].string),
functionSet[id].postoverfunc);
strcpysafe( ch->charfunctable[CHAR_WATCHFUNC].string,
sizeof(ch->charfunctable[CHAR_WATCHFUNC].string),
functionSet[id].watchfunc);
strcpysafe( ch->charfunctable[CHAR_LOOPFUNC].string,
sizeof(ch->charfunctable[CHAR_LOOPFUNC].string),
functionSet[id].loopfunc);
strcpysafe( ch->charfunctable[CHAR_TALKEDFUNC].string,
sizeof(ch->charfunctable[CHAR_TALKEDFUNC].string),
functionSet[id].talkedfunc);
strcpysafe( ch->charfunctable[CHAR_DYINGFUNC].string,
sizeof(ch->charfunctable[CHAR_DYINGFUNC].string),
functionSet[id].dyingfunc);
strcpysafe( ch->charfunctable[CHAR_PREATTACKEDFUNC].string,
sizeof(ch->charfunctable[CHAR_PREATTACKEDFUNC].string),
functionSet[id].preattackedfunc);
strcpysafe( ch->charfunctable[CHAR_POSTATTACKEDFUNC].string,
sizeof(ch->charfunctable[CHAR_POSTATTACKEDFUNC].string),
functionSet[id].postattackedfunc);
strcpysafe( ch->charfunctable[CHAR_OFFFUNC].string,
sizeof(ch->charfunctable[CHAR_OFFFUNC].string),
functionSet[id].offfunc );
strcpysafe( ch->charfunctable[CHAR_LOOKEDFUNC].string,
sizeof(ch->charfunctable[CHAR_LOOKEDFUNC].string),
functionSet[id].lookedfunc );
strcpysafe( ch->charfunctable[CHAR_ITEMPUTFUNC].string,
sizeof(ch->charfunctable[CHAR_ITEMPUTFUNC].string),
functionSet[id].itemputfunc );
strcpysafe( ch->charfunctable[CHAR_SPECIALTALKEDFUNC].string,
sizeof(ch->charfunctable[CHAR_SPECIALTALKEDFUNC].string),
functionSet[id].specialtalkedfunc );
strcpysafe( ch->charfunctable[CHAR_WINDOWTALKEDFUNC].string,
sizeof(ch->charfunctable[CHAR_WINDOWTALKEDFUNC].string),
functionSet[id].windowtalkedfunc );
#ifdef _USER_CHARLOOPS
strcpysafe( ch->charfunctable[CHAR_LOOPFUNCTEMP1].string,
sizeof(ch->charfunctable[CHAR_LOOPFUNCTEMP1].string), "");
strcpysafe( ch->charfunctable[CHAR_LOOPFUNCTEMP2].string,
sizeof(ch->charfunctable[CHAR_LOOPFUNCTEMP2].string), "");
#endif
return TRUE;
}
typedef enum
{
NPC_INTENTRY=0,
NPC_CHARENTRY=1,
NPC_INTFUNC=2,
NPC_CHARFUNC=3,
}NPC_TYPECATEGORYATREADFILE;
/*------------------------------------------------------------
* Template index 午仄化恳仄中井升丹井check允月
* 娄醒
* index int index
* 忒曰袄
* valid TRUE
* invalid FALSE
------------------------------------------------------------*/
INLINE int NPC_CHECKTEMPLATEINDEX(int index)
{
if( NPC_templatenum <= index || index < 0 )return FALSE;
return TRUE;
}
/*------------------------------------------------------------
* Template intdata index 午仄化恳仄中井升丹井check允月
* 娄醒
* index int index
* 忒曰袄
* valid TRUE
* invalid FALSE
------------------------------------------------------------*/
static INLINE int NPC_CHECKTEMPLATEINTINDEX(int index)
{
if( NPC_TEMPLATEINTNUM <= index || index < 0 )return FALSE;
return TRUE;
}
/*------------------------------------------------------------
* Template chardata index 午仄化恳仄中井升丹井check允月
* 娄醒
* index int index
* 忒曰袄
* valid TRUE
* invalid FALSE
------------------------------------------------------------*/
static INLINE int NPC_CHECKTEMPLATECHARINDEX(int index)
{
if( NPC_TEMPLATECHARNUM <= index || index < 0 )return FALSE;
return TRUE;
}
/*------------------------------------------------------------
* NPC_Template毛赓渝祭允月[
* 娄醒
* filenum int 白央奶伙醒
* 忒曰袄
* 岳 TRUE(1)
* 撩 FALSE(0)
------------------------------------------------------------*/
BOOL NPC_initTemplateArray( int templatenum )
{
NPC_templatenum = templatenum;
NPC_template = (NPC_Template*)allocateMemory( sizeof( NPC_Template ) *
NPC_templatenum );
if( NPC_template == NULL )return FALSE;
NPC_template_readindex = 0;
return TRUE;
}
/*------------------------------------------------------------
* 犯白巧伙玄及NPC 件皿伊□玄毛医 允月[
* 娄醒
* temp NPC_Template* 件皿伊□玄及禾奶件正□
* 忒曰袄
* 卅仄
------------------------------------------------------------*/
void NPC_setDefaultNPCTemplate( NPC_Template* temp )
{
int i;
if( temp == NULL )return;
for( i=0 ; i< arraysizeof(temp->chardata) ; i ++ )
memset( &temp->chardata[i], 0, sizeof(temp->chardata[i] ));
temp->intdata[NPC_TEMPLATEMAKEATNOBODY]=0;
temp->intdata[NPC_TEMPLATEMAKEATNOSEE]=0;
temp->intdata[NPC_TEMPLATEIMAGENUMBER]=0;
temp->intdata[NPC_TEMPLATETYPE]=-1;
temp->intdata[NPC_TEMPLATEMINHP]=0;
temp->intdata[NPC_TEMPLATEMINMP]=0;
temp->intdata[NPC_TEMPLATEMINSTR]=0;
temp->intdata[NPC_TEMPLATEMINTOUGH]=0;
temp->intdata[NPC_TEMPLATEISFLYING]=0;
temp->intdata[NPC_TEMPLATEITEMNUM]=0;
temp->intdata[NPC_TEMPLATELOOPFUNCTIME]=-1;
temp->intdata[NPC_TEMPLATEFUNCTIONINDEX]=-1;
for( i=0; i<NPC_TEMPLATEINTNUM; i++){
temp->randomdata[i] = 0;
}
temp->hash = 0;
temp->haveitem=NULL;
}
BOOL NPC_IsNPCTemplateFile( char* filename )
{
FILE* f;
char line1[128];
char* ret;
if( filename == NULL
||strlen( filename ) < 1
||filename[strlen(filename)-1] == '~'
||filename[0] == '#'
||strcmptail( filename, ".bak" ) == 0 )return FALSE;
f = fopen( filename , "r" );
if( f == NULL ) goto RETURNFALSE;
ret = fgets( line1, sizeof( line1 ), f );
if( ret == NULL )goto FCLOSERETURNFALSE;
if( strcmp( NPC_TEMPLATEFILEMAGIC, line1 ) == 0 ){
fclose(f);
return TRUE;
}
FCLOSERETURNFALSE:
fclose(f);
RETURNFALSE:
return FALSE;
}
void NPC_templateallocitemdata( NPC_Template* one )
{
int itemnum = one->intdata[NPC_TEMPLATEITEMNUM];
if( itemnum > 8 ) itemnum = 8;
else if( itemnum <= 0 ) itemnum = 0;
/* 袄及 凳 */
one->intdata[NPC_TEMPLATEITEMNUM] = itemnum;
one->haveitem = allocateMemory( sizeof( NPC_haveItem ) * itemnum );
}
/*------------------------------------------------------------
* NPC_getRandomValue 午及娄醒及询晶岭及凶户及楮醒
* 娄醒
* string char* 侬
* unuse int* 银歹卅中[
* 忒曰袄
* 仿件母丞及 斓及袄 汔及涩烂反}2 及娄醒卞忡绣允月[
------------------------------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -