chuyiwen_gmsv/npc/npc_checkman.c

473 lines
9.6 KiB
C
Raw Normal View History

2016-12-24 08:45:52 +08:00
#include "version.h"
#include <string.h>
#include "char.h"
#include "object.h"
#include "char_base.h"
#include "npcutil.h"
#include "lssproto_serv.h"
//<2F>ػ<EFBFBD><D8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD>°׷º뼰<C2BA><EBBCB0>
#define MAXEVENTFLG 96
/*
* <EFBFBD><EFBFBD>ì<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׷º<EFBFBD>ë<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*
*/
static void NPC_CheckMan_selectWindow( int meindex, int toindex, int num);
int NPC_NowFlgCheck(int meindex,int talker,int now[MAXEVENTFLG]);
int NPC_EndFlgCheck(int meindex,int talker ,int nowflg[MAXEVENTFLG]);
BOOL NPC_FlgCheckMain( int meindex,int talker,int nowindex,int now[MAXEVENTFLG],char *work2);
/*********************************
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*********************************/
BOOL NPC_CheckManInit( int meindex )
{
/*--ƽ<>ҷ¼<D2B7><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ëɬ<C3AB><C9AC>--*/
CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPECHECKMAN);
return TRUE;
}
/*********************************
* <EFBFBD>ƾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ľ<EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD><EFBFBD><EFBFBD>
*********************************/
void NPC_CheckManTalked( int meindex , int talkerindex , char *szMes ,int color )
{
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD><C6BB><EFBFBD><EFBFBD><EFBFBD> ɱ<><C9B1><EFBFBD><EFBFBD> */
if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER )
{
return;
}
/*-- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¾<EFBFBD><C2BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>--*/
if(NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) {
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> */
if(NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) return;
}
// <20>ټ<EFBFBD><D9BC><EFBFBD><EFBFBD>̼<EFBFBD><CCBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
NPC_CheckMan_selectWindow( meindex, talkerindex, 0);
}
/*
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
static void NPC_CheckMan_selectWindow( int meindex, int talker, int num)
{
char token[1024];
char work[256];
char work2[512];
char escapedname[1024];
int fd = getfdFromCharaIndex( talker);
int buttontype = 0;
int windowtype = 0;
int windowno = 0;
int now[MAXEVENTFLG];
int nowindex;
int i;
int page;
work[0] = 0;
work2[0] = 0;
token[0] = 0;
now[0] =0;
/*--<2D><><EFBFBD>̼<EFBFBD><CCBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E2BBA5><EFBFBD><EFBFBD><EFBFBD>м<EFBFBD>ƥ<EFBFBD>Ʊ<EFBFBD>ɬ<EFBFBD><C9AC>--*/
windowtype = WINDOW_MESSAGETYPE_MESSAGE;
switch( num) {
case 0:
CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANT,0);
CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC,0);
/*--<2D><> --*/
sprintf(token,"3\n <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѩ<EFBFBD><D1A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "
"\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ػ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>׷º<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ë<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"
"\n"
"\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>գ<EFBFBD>NOW<4F>׷º<D7B7><C2BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD> "
"\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>գ<EFBFBD>END<4E>׷º<D7B7><C2BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD> "
"\n\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>գ<EFBFBD>NOW<4F>׷º<D7B7><C2BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> "
"\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>գ<EFBFBD>END<4E>׷º<D7B7><C2BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> "
);
buttontype = WINDOW_BUTTONTYPE_CANCEL;
windowtype = WINDOW_MESSAGETYPE_SELECT;
windowno = CHAR_WINDOWTYPE_CHECKMAN_START;
break;
//NOW<4F>׷º뼰<C2BA><EBBCB0>ǩ <20><>
case 1:
//NOW<4F>׷º뼰<C2BA><EBBCB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
nowindex = NPC_NowFlgCheck( meindex, talker, now);
//<2F><>ʸ<EFBFBD><CAB8><EFBFBD><EFBFBD> <20><>
page = CHAR_getWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC) ;
if(page == 0 || page == 1){
i = 0;
}else{
i = 83;
}
//ʸ<><CAB8><EFBFBD><EFBFBD>
for(; i < nowindex ; i++)
{
sprintf(work,"%d,",now[ i]);
strcat(work2,work);
}
sprintf(token,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "
"\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ػ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD> NOW<4F><57>ì<EFBFBD><C3AC><EFBFBD><EFBFBD>"
"\n%s"
,work2);
if(page != 2 && nowindex > 83)
{
//ƹ<><C6B9><EFBFBD><EFBFBD>
CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANT,1);
//ʸ<><CAB8><EFBFBD><EFBFBD>
CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC,2);
buttontype = WINDOW_BUTTONTYPE_NEXT;
windowtype = WINDOW_MESSAGETYPE_MESSAGE;
windowno = CHAR_WINDOWTYPE_CHECKMAN_MAIN;
}else{
buttontype = WINDOW_BUTTONTYPE_OK;
windowtype = WINDOW_MESSAGETYPE_MESSAGE;
}
break;
//END<4E>׷º뼰<C2BA><EBBCB0>ǩ <20><>
case 2:
//<2F><> <20>׷º뼰<C2BA><EBBCB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
nowindex = NPC_EndFlgCheck( meindex, talker, now);
//<2F><>ʸ<EFBFBD><CAB8><EFBFBD><EFBFBD> <20><>
page = CHAR_getWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC) ;
if(page == 0 || page == 1){
i = 0;
}else{
i = 83;
}
work2[0]=0;
//ʸ<><CAB8><EFBFBD><EFBFBD>
for(; i < nowindex ; i++)
{
sprintf(work,"%d,",now[ i]);
strcat(work2,work);
}
sprintf(token,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "
"\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ػ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD> END<4E><44>ì<EFBFBD><C3AC><EFBFBD><EFBFBD>"
"\n%s"
,work2);
if(page != 2 && nowindex > 83)
{
//ƹ<><C6B9><EFBFBD><EFBFBD>
CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANT,2);
//ʸ<><CAB8><EFBFBD><EFBFBD>
CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC,2);
buttontype = WINDOW_BUTTONTYPE_NEXT;
windowtype = WINDOW_MESSAGETYPE_MESSAGE;
windowno = CHAR_WINDOWTYPE_CHECKMAN_MAIN;
}else{
buttontype = WINDOW_BUTTONTYPE_OK;
windowtype = WINDOW_MESSAGETYPE_MESSAGE;
}
break;
// NOW<4F>׷º뼰<C2BA><EBBCB0><EFBFBD><EFBFBD> <20><>
case 4:
{
//NOW<4F>׷º<D7B7><C2BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
nowindex = NPC_NowFlgCheck( meindex, talker, now);
if(NPC_FlgCheckMain( meindex, talker, nowindex,now,work2)
== FALSE)
{
return;
}
sprintf(token,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "
"\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ػ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD> NOW<4F><57>ì<EFBFBD><C3AC><EFBFBD><EFBFBD>"
"\n%s"
,work2);
page = CHAR_getWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC) ;
nowindex = (nowindex / ((6*page)+1));
if(page != 16 && nowindex != 0)
{
//ƹ<><C6B9><EFBFBD><EFBFBD>
CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANT,4);
//ʸ<><CAB8><EFBFBD><EFBFBD>
page = CHAR_getWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC);
page++;
CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC,page);
buttontype = WINDOW_BUTTONTYPE_NEXT;
windowtype = WINDOW_MESSAGETYPE_MESSAGE;
windowno = CHAR_WINDOWTYPE_CHECKMAN_MAIN;
}else{
buttontype = WINDOW_BUTTONTYPE_OK;
windowtype = WINDOW_MESSAGETYPE_MESSAGE;
}
}
break;
// END<4E>׷º뼰<C2BA><EBBCB0><EFBFBD><EFBFBD> <20><>
case 5:
{
//END<4E>׷º뼰<C2BA><EBBCB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
nowindex = NPC_EndFlgCheck( meindex, talker, now);
if(NPC_FlgCheckMain( meindex, talker, nowindex, now, work2)
== FALSE)
{
return;
}
sprintf(token,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "
"\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ػ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD> END<4E><44>ì<EFBFBD><C3AC><EFBFBD><EFBFBD>"
"\n%s"
,work2);
page = CHAR_getWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC) ;
nowindex = (nowindex / ((6*page)+1));
if(page != 16 && nowindex != 0)
{
//ƹ<><C6B9><EFBFBD><EFBFBD>
CHAR_setWorkInt(talker, CHAR_WORKSHOPRELEVANT, 5);
//ʸ<><CAB8><EFBFBD><EFBFBD>
page = CHAR_getWorkInt( talker, CHAR_WORKSHOPRELEVANTSEC);
page++;
CHAR_setWorkInt( talker, CHAR_WORKSHOPRELEVANTSEC, page);
buttontype = WINDOW_BUTTONTYPE_NEXT;
windowtype = WINDOW_MESSAGETYPE_MESSAGE;
windowno = CHAR_WINDOWTYPE_CHECKMAN_MAIN;
}else{
buttontype = WINDOW_BUTTONTYPE_OK;
windowtype = WINDOW_MESSAGETYPE_MESSAGE;
}
}
}
makeEscapeString( token, escapedname, sizeof( escapedname));
/*-<2D><><EFBFBD><EFBFBD>ƥ˪<C6A5><CBAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>--*/
lssproto_WN_send( fd, windowtype,
buttontype,
windowno,
CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX),
escapedname);
}
/*-----------------------------------------
<EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߯<EFBFBD>Ȼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD><EFBFBD><EFBFBD>̫<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ľ<EFBFBD>£<EFBFBD>
-------------------------------------------*/
void NPC_CheckManWindowTalked( int meindex, int talkerindex,
int seqno, int select, char *data)
{
int datano;
if( NPC_Util_CharDistance( talkerindex, meindex ) > 2) return;
datano = atoi(data);
if(select == WINDOW_BUTTONTYPE_OK)
{
NPC_CheckMan_selectWindow( meindex, talkerindex, 0 );
}else if(select == WINDOW_BUTTONTYPE_CANCEL) {
return;
}
switch(CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANT)){
case 1:
if(CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTSEC) == 2){
NPC_CheckMan_selectWindow( meindex, talkerindex, 1 );
}
break;
case 2:
if(CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTSEC) == 2){
NPC_CheckMan_selectWindow( meindex, talkerindex, 2 );
}
break;
case 4:
if(CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTSEC) >= 2){
NPC_CheckMan_selectWindow( meindex, talkerindex, 4 );
}
case 5:
if(CHAR_getWorkInt(talkerindex,CHAR_WORKSHOPRELEVANTSEC) >= 2){
NPC_CheckMan_selectWindow( meindex, talkerindex, 5 );
}
break;
}
switch( datano ){
case 1:
NPC_CheckMan_selectWindow( meindex, talkerindex, 1 );
break;
case 2:
NPC_CheckMan_selectWindow( meindex, talkerindex, 2 );
break;
case 4:
NPC_CheckMan_selectWindow( meindex, talkerindex, 4 );
break;
case 5:
NPC_CheckMan_selectWindow( meindex, talkerindex, 5 );
break;
}
}
/*
*<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ì<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>׷º<EFBFBD>ë<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
int NPC_NowFlgCheck(int meindex,int talker ,int nowflg[MAXEVENTFLG])
{
int i = 0;
int j = 0;
for(i= 0; i < MAXEVENTFLG ; i++){
if(NPC_NowEventCheckFlg( talker, i) == TRUE)
{
nowflg[j] = i;
j++;
}
}
return j;
}
/*
*<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ì<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>׷º<EFBFBD>ë<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
int NPC_EndFlgCheck(int meindex,int talker ,int nowflg[MAXEVENTFLG])
{
int i = 0;
int j = 0;
for(i= 0; i < MAXEVENTFLG ; i++){
if(NPC_EventCheckFlg( talker, i) == TRUE)
{
nowflg[j] = i;
j++;
}
}
return j;
}
/*
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*
*/
BOOL NPC_FlgCheckMain( int meindex,int talker,int nowindex,int now[MAXEVENTFLG],char *work2)
{
int page;
int max;
int i;
int shou;
int j=1;
char argstr[NPC_UTIL_GETARGSTR_BUFSIZE];
char work[512];
char buf[40];
char buf2[42];
//<2F><>ʸ<EFBFBD><CAB8><EFBFBD><EFBFBD> <20><>
page = CHAR_getWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC) ;
if(page == 0) {
page =1;
CHAR_setWorkInt(talker,CHAR_WORKSHOPRELEVANTSEC,1) ;
}
if(page == 1){
i = 0;
if( nowindex >6 ){
max =7;
}else{
max =nowindex;
}
}else{
max = (page * 6) +1;
i = max - 7;
shou = nowindex / max;
if(shou == 0){
max = nowindex;
}else{
i = max - 7;
}
}
//<2F><>ì<EFBFBD><C3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD>̤<EFBFBD><CCA4>ľ<EFBFBD><C4BE><EFBFBD><EFBFBD><EFBFBD>°<EFBFBD><C2B0><EFBFBD><EFBFBD>̻<EFBFBD>ë <20>ij<EFBFBD><C4B3><EFBFBD>
if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr)) == NULL) {
print("NPC_CheckMan:GetArgStrErr");
return FALSE;
}
work[0] = 0;
work2[0] = 0;
//ʸ<><CAB8><EFBFBD><EFBFBD>
for(; i < max ; i++)
{
sprintf(work,"#%d:",now[ i]);
j = 1;
while( getStringFromIndexWithDelim(argstr, "|", j, buf,sizeof( buf))
!=FALSE )
{
j++;
if(strstr(buf,work) != NULL){
sprintf(buf2,"%s\n",buf);
strcat(work2,buf2);
break;
}
}
}
return TRUE;
}