732 lines
21 KiB
C
732 lines
21 KiB
C
![]() |
#include "version.h"
|
|||
|
#include <string.h>
|
|||
|
#include "char.h"
|
|||
|
#include "object.h"
|
|||
|
#include "char_base.h"
|
|||
|
#include "npcutil.h"
|
|||
|
#include "lssproto_serv.h"
|
|||
|
#include "npc_bus.h"
|
|||
|
#include "handletime.h"
|
|||
|
|
|||
|
/*
|
|||
|
* <EFBFBD>ﵩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ئ<EFBFBD><EFBFBD>ë<EFBFBD><EFBFBD><EFBFBD><EFBFBD>NPC
|
|||
|
*/
|
|||
|
|
|||
|
enum {
|
|||
|
NPC_WORK_ROUTETOX = CHAR_NPCWORKINT1, /* <20><><EFBFBD><EFBFBD><EFBFBD>ߣ<EFBFBD> <20><> */
|
|||
|
NPC_WORK_ROUTETOY = CHAR_NPCWORKINT2, /* <20><><EFBFBD><EFBFBD><EFBFBD>ߣ<EFBFBD> <20><> */
|
|||
|
NPC_WORK_ROUTEPOINT = CHAR_NPCWORKINT3, /* <20><><EFBFBD><EFBFBD> <20><> */
|
|||
|
NPC_WORK_ROUNDTRIP = CHAR_NPCWORKINT4, /* <20><><EFBFBD>微<EFBFBD><E5BEAE>Ի<EFBFBD><D4BB> <20>ߡ<EFBFBD><DFA1><EFBFBD><EFBFBD><EFBFBD> <20>ࡰ<EFBFBD><E0A1B0>Ի */
|
|||
|
NPC_WORK_MODE = CHAR_NPCWORKINT5,
|
|||
|
NPC_WORK_CURRENTROUTE = CHAR_NPCWORKINT6,
|
|||
|
NPC_WORK_ROUTEMAX = CHAR_NPCWORKINT7,
|
|||
|
NPC_WORK_WAITTIME = CHAR_NPCWORKINT8,
|
|||
|
NPC_WORK_CURRENTTIME = CHAR_NPCWORKINT9,
|
|||
|
NPC_WORK_SEFLG = CHAR_NPCWORKINT10,
|
|||
|
};
|
|||
|
|
|||
|
/* <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⼰enum */
|
|||
|
enum {
|
|||
|
NPC_BUS_MSG_GETTINGON,
|
|||
|
NPC_BUS_MSG_NOTPARTY,
|
|||
|
NPC_BUS_MSG_OVERPARTY,
|
|||
|
NPC_BUS_MSG_DENIEDITEM,
|
|||
|
NPC_BUS_MSG_ALLOWITEM,
|
|||
|
NPC_BUS_MSG_LEVEL,
|
|||
|
NPC_BUS_MSG_GOLD,
|
|||
|
NPC_BUS_MSG_EVENT,
|
|||
|
NPC_BUS_MSG_START,
|
|||
|
NPC_BUS_MSG_END,
|
|||
|
};
|
|||
|
typedef struct {
|
|||
|
char option[32];
|
|||
|
char defaultmsg[128];
|
|||
|
}NPC_BUS_MSG;
|
|||
|
NPC_BUS_MSG busmsg[] = {
|
|||
|
{ "msg_gettingon", "PAON<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ࡣ<EFBFBD><EFBFBD><EFBFBD>"},
|
|||
|
{ "msg_notparty", "PAPAON<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŶӼ<EFBFBD><EFBFBD><EFBFBD>ࡣ<EFBFBD>"},
|
|||
|
{ "msg_overparty", "PAON<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"},
|
|||
|
{ "msg_denieditem", "PAPAON<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҿɲ<EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߣ<EFBFBD>"},
|
|||
|
{ "msg_allowitem", "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>~(<28><>Ҫ<EFBFBD>Ǹ<EFBFBD><C7B8><EFBFBD><EFBFBD>߰<EFBFBD>!)"},
|
|||
|
{ "msglevel", "PAPAON<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵȼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ࡣ<EFBFBD>"},
|
|||
|
{ "msg_stone", "PAPAON<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ࡣ<EFBFBD>"},
|
|||
|
{ "msg_event", "PAON<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ࡣ<EFBFBD>"},
|
|||
|
{ "msg_start", "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>~(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)"},
|
|||
|
{ "msg_end", "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>~(<28><><EFBFBD><EFBFBD>)"}
|
|||
|
|
|||
|
};
|
|||
|
|
|||
|
static int NPC_BusSetPoint( int meindex, char *argstr);
|
|||
|
static void NPC_BusSetDestPoint( int meindex, char *argstr);
|
|||
|
static BOOL NPC_BusCheckDeniedItem( int meindex, int charaindex, char *argstr);
|
|||
|
static BOOL NPC_BusCheckLevel( int meindex, int charaindex, char *argstr);
|
|||
|
static int NPC_BusCheckStone( int meindex, int charaindex, char *argstr);
|
|||
|
static void NPC_BusSendMsg( int meindex, int talkerindex, int tablenum);
|
|||
|
static int NPC_BusGetRoutePointNum( int meindex, char *argstr );
|
|||
|
static void NPC_Bus_walk( int meindex);
|
|||
|
|
|||
|
#define NPC_BUS_LOOPTIME 200
|
|||
|
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><DEB7><EFBFBD><EFBFBD>ɻ<EFBFBD><C9BB><EFBFBD> */
|
|||
|
#define NPC_BUS_WAITTIME_DEFAULT 180
|
|||
|
|
|||
|
#define NPC_BUS_WAITINGMODE_WAITTIME 5000
|
|||
|
|
|||
|
/*********************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*********************************/
|
|||
|
BOOL NPC_BusInit( int meindex )
|
|||
|
{
|
|||
|
char argstr[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20];
|
|||
|
int i;
|
|||
|
char buf[256];
|
|||
|
int routenum;
|
|||
|
int waittime;
|
|||
|
int seflg;
|
|||
|
|
|||
|
NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr));
|
|||
|
|
|||
|
/* ئ<><D8A6>ľ<EFBFBD><C4BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ئ<EFBFBD><D8A6>¦<EFBFBD>Ѽ<EFBFBD><D1BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
routenum = NPC_Util_GetNumFromStrWithDelim( argstr, "routenum");//<2F><>ʻ·<CABB><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
if( routenum == -1 ) {
|
|||
|
print( "npcbus:nothing routenum \n");
|
|||
|
return FALSE;
|
|||
|
}
|
|||
|
CHAR_setWorkInt( meindex, NPC_WORK_ROUTEMAX, routenum);
|
|||
|
|
|||
|
for( i = 1; i <= routenum; i ++ ) {
|
|||
|
char routetostring[64];
|
|||
|
snprintf( routetostring, sizeof( routetostring), "routeto%d", i);
|
|||
|
if( NPC_Util_GetStrFromStrWithDelim( argstr, routetostring,buf, sizeof(buf))
|
|||
|
== NULL )
|
|||
|
{
|
|||
|
print( "npcbus:nothing route to \n");
|
|||
|
return FALSE;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
waittime = NPC_Util_GetNumFromStrWithDelim( argstr, "waittime");
|
|||
|
|
|||
|
if( waittime == -1 ) waittime = NPC_BUS_WAITTIME_DEFAULT;
|
|||
|
CHAR_setWorkInt( meindex, NPC_WORK_WAITTIME, waittime);
|
|||
|
|
|||
|
seflg = NPC_Util_GetNumFromStrWithDelim( argstr, "seflg");
|
|||
|
|
|||
|
if( seflg == -1 ) seflg = TRUE;
|
|||
|
CHAR_setWorkInt( meindex, NPC_WORK_SEFLG, seflg);
|
|||
|
|
|||
|
CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEBUS );
|
|||
|
|
|||
|
CHAR_setWorkInt( meindex, NPC_WORK_MODE, 0);
|
|||
|
CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, 2);
|
|||
|
CHAR_setWorkInt( meindex, NPC_WORK_ROUNDTRIP, 0);
|
|||
|
CHAR_setWorkInt( meindex, NPC_WORK_CURRENTROUTE, 0);
|
|||
|
|
|||
|
CHAR_setInt( meindex, CHAR_LOOPINTERVAL,
|
|||
|
NPC_BUS_WAITINGMODE_WAITTIME);
|
|||
|
|
|||
|
/* <20>ػ<EFBFBD><D8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ë<EFBFBD><C3AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec);
|
|||
|
|
|||
|
for( i = 0; i < CHAR_PARTYMAX; i ++) {
|
|||
|
CHAR_setWorkInt( meindex, CHAR_WORKPARTYINDEX1 + i, -1);
|
|||
|
}
|
|||
|
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
{
|
|||
|
int rev;
|
|||
|
int r = CHAR_getWorkInt( meindex, NPC_WORK_ROUTEMAX);
|
|||
|
CHAR_setWorkInt( meindex, NPC_WORK_CURRENTROUTE, RAND( 1, r));
|
|||
|
//print( "route:%d\n",CHAR_getWorkInt( meindex, NPC_WORK_CURRENTROUTE));
|
|||
|
|
|||
|
/* Ƿ<><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
rev = NPC_Util_GetNumFromStrWithDelim( argstr, "reverse");
|
|||
|
|
|||
|
if( rev == 1 ) {
|
|||
|
int num = NPC_BusGetRoutePointNum( meindex, argstr);
|
|||
|
|
|||
|
if( num <= 0 ) {
|
|||
|
print( "npcbus:<3A><><EFBFBD><EFBFBD><EFBFBD>֣<EFBFBD>\n");
|
|||
|
return FALSE;
|
|||
|
}
|
|||
|
CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, num-1);
|
|||
|
CHAR_setWorkInt( meindex, NPC_WORK_ROUNDTRIP, 1);
|
|||
|
}
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ë<EFBFBD><C3AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
NPC_BusSetPoint( meindex, argstr);
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ë <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
NPC_BusSetDestPoint( meindex, argstr);
|
|||
|
}
|
|||
|
|
|||
|
return TRUE;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
/*********************************
|
|||
|
* <EFBFBD>ƾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ľ<EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*********************************/
|
|||
|
void NPC_BusTalked( int meindex , int talkerindex , char *szMes ,
|
|||
|
int color )
|
|||
|
{
|
|||
|
int i;
|
|||
|
int partyflg = FALSE;
|
|||
|
|
|||
|
/* <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><D0BC>ɡ<EFBFBD> ū <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʃ<EFBFBD><C6A9><EFBFBD><EFBFBD> */
|
|||
|
for( i = 0; i < CHAR_PARTYMAX; i ++ ) {
|
|||
|
int index = CHAR_getWorkInt( meindex, CHAR_WORKPARTYINDEX1+i);
|
|||
|
if( CHAR_CHECKINDEX(index)){
|
|||
|
if( index == talkerindex) {
|
|||
|
partyflg = TRUE;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
if( !partyflg ) {
|
|||
|
//NPC_BusCheckJoinParty( meindex, talkerindex, TRUE);
|
|||
|
}
|
|||
|
else {
|
|||
|
if( CHAR_getWorkInt( meindex, NPC_WORK_MODE) == 0 ) {
|
|||
|
int i;
|
|||
|
// #define NPC_BUS_DEBUGROUTINTG "routingtable:"
|
|||
|
if( strstr( szMes, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>" ) ||
|
|||
|
strstr( szMes, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>" ) ||
|
|||
|
strstr( szMes, "Go" ) ||
|
|||
|
strstr( szMes, "go" ))
|
|||
|
{
|
|||
|
CHAR_setWorkInt( meindex, NPC_WORK_MODE,1);
|
|||
|
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѽ<EFBFBD><D1BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ë<EFBFBD><C3AB><EFBFBD>ʻ<EFBFBD>պ<EFBFBD><D5BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
CHAR_setInt( meindex, CHAR_LOOPINTERVAL, NPC_BUS_LOOPTIME);
|
|||
|
/* SE <20><><EFBFBD><EFBFBD> Ѩ<><D1A8>ƹ<EFBFBD><C6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̫ */
|
|||
|
if( CHAR_getWorkInt( meindex, NPC_WORK_SEFLG )) {
|
|||
|
CHAR_sendSEoArroundCharacter(
|
|||
|
CHAR_getInt( meindex, CHAR_FLOOR),
|
|||
|
CHAR_getInt( meindex, CHAR_X),
|
|||
|
CHAR_getInt( meindex, CHAR_Y),
|
|||
|
60,
|
|||
|
TRUE);
|
|||
|
}
|
|||
|
/* <20><> <20><><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|||
|
for( i = 1; i < CHAR_PARTYMAX; i ++ ) {
|
|||
|
int partyindex = CHAR_getWorkInt( meindex, CHAR_WORKPARTYINDEX1+i);
|
|||
|
if( CHAR_CHECKINDEX( partyindex)) {
|
|||
|
NPC_BusSendMsg( meindex, partyindex, NPC_BUS_MSG_START);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
/**************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
**************************************/
|
|||
|
void NPC_BusLoop( int meindex)
|
|||
|
{
|
|||
|
int i;
|
|||
|
switch( CHAR_getWorkInt( meindex, NPC_WORK_MODE )) {
|
|||
|
case 0:
|
|||
|
/* <20><><EFBFBD><EFBFBD>ƹ<EFBFBD><C6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD><EFBFBD>ë<EFBFBD><C3AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
/* <20><><EFBFBD><EFBFBD><DEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> */
|
|||
|
if( CHAR_getWorkInt( meindex, NPC_WORK_CURRENTTIME)
|
|||
|
+ CHAR_getWorkInt( meindex, NPC_WORK_WAITTIME)
|
|||
|
< NowTime.tv_sec)
|
|||
|
{
|
|||
|
/* SE <20><><EFBFBD><EFBFBD> Ѩ<><D1A8>ƹ<EFBFBD><C6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̫ */
|
|||
|
if( CHAR_getWorkInt( meindex, NPC_WORK_SEFLG )) {
|
|||
|
CHAR_sendSEoArroundCharacter(
|
|||
|
CHAR_getInt( meindex, CHAR_FLOOR),
|
|||
|
CHAR_getInt( meindex, CHAR_X),
|
|||
|
CHAR_getInt( meindex, CHAR_Y),
|
|||
|
60,
|
|||
|
TRUE);
|
|||
|
}
|
|||
|
/* <20><> <20><><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|||
|
for( i = 1; i < CHAR_PARTYMAX; i ++ ) {
|
|||
|
int partyindex = CHAR_getWorkInt( meindex, CHAR_WORKPARTYINDEX1+i);
|
|||
|
if( CHAR_CHECKINDEX( partyindex)) {
|
|||
|
NPC_BusSendMsg( meindex, partyindex, NPC_BUS_MSG_START);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
CHAR_setWorkInt( meindex, NPC_WORK_MODE,1);
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѽ<EFBFBD><D1BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ë<EFBFBD><C3AB><EFBFBD>ʻ<EFBFBD>պ<EFBFBD><D5BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
CHAR_setInt( meindex, CHAR_LOOPINTERVAL, NPC_BUS_LOOPTIME);
|
|||
|
}
|
|||
|
return;
|
|||
|
case 1:
|
|||
|
/* <20><><EFBFBD><EFBFBD> */
|
|||
|
NPC_Bus_walk( meindex);
|
|||
|
case 2:
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD>ƹ<EFBFBD><C6B9><EFBFBD><EFBFBD> */
|
|||
|
/* <20><><EFBFBD><EFBFBD><DEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> */
|
|||
|
if( CHAR_getWorkInt( meindex, NPC_WORK_CURRENTTIME)
|
|||
|
+ (CHAR_getWorkInt( meindex, NPC_WORK_WAITTIME) /3)
|
|||
|
< NowTime.tv_sec)
|
|||
|
{
|
|||
|
CHAR_setWorkInt( meindex, NPC_WORK_MODE,1);
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѽ<EFBFBD><D1BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ë<EFBFBD><C3AB><EFBFBD>ʻ<EFBFBD>պ<EFBFBD><D5BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
CHAR_setInt( meindex, CHAR_LOOPINTERVAL, NPC_BUS_LOOPTIME);
|
|||
|
|
|||
|
}
|
|||
|
return;
|
|||
|
case 3:
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD><C6BB>֣<EFBFBD><D6A3>ͷ<EFBFBD><CDB7><EFBFBD>ʧ<EFBFBD><CAA7><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>м<EFBFBD><D0BC>б<EFBFBD><D0B1><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD>Ƴ<EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ë<EFBFBD><EFBFBD>ľ<EFBFBD><EFBFBD>֧<EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
if( CHAR_getWorkInt( meindex, NPC_WORK_CURRENTTIME) + 3
|
|||
|
< NowTime.tv_sec)
|
|||
|
{
|
|||
|
char argstr[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20];
|
|||
|
|
|||
|
NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr));
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѽ<EFBFBD><D1BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ë<EFBFBD><C3AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
CHAR_setInt( meindex, CHAR_LOOPINTERVAL,
|
|||
|
NPC_BUS_WAITINGMODE_WAITTIME);
|
|||
|
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
{
|
|||
|
int r = CHAR_getWorkInt( meindex, NPC_WORK_ROUTEMAX);
|
|||
|
CHAR_setWorkInt( meindex, NPC_WORK_CURRENTROUTE, RAND( 1, r));
|
|||
|
//print( "route:%d\n",CHAR_getWorkInt( meindex, NPC_WORK_CURRENTROUTE));
|
|||
|
}
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ի<EFBFBD>º<D7B7> <20><> */
|
|||
|
CHAR_setWorkInt( meindex, NPC_WORK_ROUNDTRIP,
|
|||
|
CHAR_getWorkInt( meindex, NPC_WORK_ROUNDTRIP)^1);
|
|||
|
|
|||
|
/* <20>ݺ<EFBFBD><DDBA>̼<EFBFBD><CCBC><EFBFBD><EFBFBD><EFBFBD>Ʃ<EFBFBD><C6A9> */
|
|||
|
/* <20><>Ի<EFBFBD><D4BB> <20><><EFBFBD><EFBFBD> */
|
|||
|
if( CHAR_getWorkInt( meindex, NPC_WORK_ROUNDTRIP) == 1) {
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>κ<EFBFBD><CEBA>̼<EFBFBD><CCBC><EFBFBD><EFBFBD><EFBFBD>ë <20><> */
|
|||
|
int num = NPC_BusGetRoutePointNum( meindex, argstr);
|
|||
|
CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT, num-1);
|
|||
|
}
|
|||
|
else {
|
|||
|
CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT,
|
|||
|
CHAR_getWorkInt( meindex, NPC_WORK_ROUTEPOINT) +1);
|
|||
|
}
|
|||
|
/* <20>ݼ<EFBFBD><DDBC><EFBFBD><EFBFBD>̼<EFBFBD><CCBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ë<><C3AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
NPC_BusSetPoint( meindex, argstr);
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ë <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
NPC_BusSetDestPoint( meindex, argstr);
|
|||
|
/* <20>ɡ<EFBFBD> ū <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ë<><C3AB><EFBFBD><EFBFBD> */
|
|||
|
CHAR_DischargeParty( meindex, 0);
|
|||
|
/* <20>ػ<EFBFBD><D8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ë<EFBFBD><C3AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec);
|
|||
|
/* ƹ<><C6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ */
|
|||
|
CHAR_setWorkInt( meindex, NPC_WORK_MODE, 0);
|
|||
|
}
|
|||
|
return;
|
|||
|
default:
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
/**************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD>ʣ<EFBFBD>
|
|||
|
**************************************/
|
|||
|
static void NPC_Bus_walk( int meindex)
|
|||
|
{
|
|||
|
POINT start, end;
|
|||
|
int dir;
|
|||
|
int ret;
|
|||
|
int i;
|
|||
|
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD> */
|
|||
|
start.x = CHAR_getInt( meindex, CHAR_X);
|
|||
|
start.y = CHAR_getInt( meindex, CHAR_Y);
|
|||
|
end.x = CHAR_getWorkInt( meindex, NPC_WORK_ROUTETOX);
|
|||
|
end.y = CHAR_getWorkInt( meindex, NPC_WORK_ROUTETOY);
|
|||
|
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD><EFBFBD>̼<EFBFBD><CCBC><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
if( start.x == end.x && start.y == end.y ) {
|
|||
|
int add = 1;
|
|||
|
char argstr[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20];
|
|||
|
|
|||
|
NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr));
|
|||
|
|
|||
|
if( CHAR_getWorkInt( meindex, NPC_WORK_ROUNDTRIP ) == 1 ) {
|
|||
|
add *= -1;
|
|||
|
}
|
|||
|
CHAR_setWorkInt( meindex, NPC_WORK_ROUTEPOINT,
|
|||
|
CHAR_getWorkInt( meindex, NPC_WORK_ROUTEPOINT) +add);
|
|||
|
if( NPC_BusSetPoint( meindex, argstr) == FALSE ) {
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|||
|
/* <20><><EFBFBD><EFBFBD>ƹ<EFBFBD><C6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
CHAR_setWorkInt( meindex, NPC_WORK_MODE,3);
|
|||
|
|
|||
|
/* SE <20><><EFBFBD><EFBFBD> Ѩ<><D1A8>ƹ<EFBFBD><C6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̫ */
|
|||
|
if( CHAR_getWorkInt( meindex, NPC_WORK_SEFLG )) {
|
|||
|
CHAR_sendSEoArroundCharacter(
|
|||
|
CHAR_getInt( meindex, CHAR_FLOOR),
|
|||
|
CHAR_getInt( meindex, CHAR_X),
|
|||
|
CHAR_getInt( meindex, CHAR_Y),
|
|||
|
60,
|
|||
|
TRUE);
|
|||
|
}
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|||
|
for( i = 1; i < CHAR_PARTYMAX; i ++ ) {
|
|||
|
int partyindex = CHAR_getWorkInt( meindex, CHAR_WORKPARTYINDEX1+i);
|
|||
|
if( CHAR_CHECKINDEX( partyindex)) {
|
|||
|
NPC_BusSendMsg( meindex, partyindex, NPC_BUS_MSG_END);
|
|||
|
}
|
|||
|
}
|
|||
|
/* <20>ػ<EFBFBD><D8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ë<EFBFBD><C3AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
CHAR_setWorkInt( meindex, NPC_WORK_CURRENTTIME, NowTime.tv_sec);
|
|||
|
return;
|
|||
|
}
|
|||
|
else {
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
/*-------------------------------------------------------*/
|
|||
|
/* <20>ھ<EFBFBD><DABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
|
|||
|
/* <20><>ë<EFBFBD>ƻ<EFBFBD><C6BB><EFBFBD> */
|
|||
|
dir = NPC_Util_getDirFromTwoPoint( &start,&end );
|
|||
|
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ɡ<EFBFBD> ū<><C5AB><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD> */
|
|||
|
end.x = CHAR_getInt( meindex, CHAR_X);
|
|||
|
end.y = CHAR_getInt( meindex, CHAR_Y);
|
|||
|
|
|||
|
/* <20><><EFBFBD>Ⱦ<EFBFBD><C8BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD><DDBC>м<EFBFBD><D0BC><EFBFBD> */
|
|||
|
for( i = 0; i < 100; i ++ ) {
|
|||
|
if( dir < 0 ) {
|
|||
|
dir = RAND( 0,7);
|
|||
|
}
|
|||
|
dir = NPC_Util_SuberiWalk( meindex, dir);
|
|||
|
if( dir >= 0 && dir <= 7) break;
|
|||
|
}
|
|||
|
|
|||
|
if( dir >= 0 && dir <= 7 ) {
|
|||
|
/* <20><><EFBFBD><EFBFBD> */
|
|||
|
ret = CHAR_walk( meindex, dir, 0);
|
|||
|
|
|||
|
if( ret == CHAR_WALKSUCCESSED ) {
|
|||
|
/* <20><><EFBFBD>л<EFBFBD><D0BB><EFBFBD>ئ<EFBFBD><D8A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ë<EFBFBD>ھ<EFBFBD><DABE><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
int i;
|
|||
|
for( i = 1; i < CHAR_PARTYMAX; i ++ ) {
|
|||
|
int toindex = CHAR_getWorkInt( meindex, i + CHAR_WORKPARTYINDEX1);
|
|||
|
if( CHAR_CHECKINDEX(toindex) ) {
|
|||
|
int parent_dir;
|
|||
|
/* <20>Ҽ<EFBFBD><D2BC><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><F3A1BCB0> <20><><EFBFBD><EFBFBD> <20><>ë<EFBFBD>ƻ<EFBFBD><C6BB><EFBFBD> */
|
|||
|
/* <20><><EFBFBD><EFBFBD> */
|
|||
|
start.x = CHAR_getInt( toindex, CHAR_X);
|
|||
|
start.y = CHAR_getInt( toindex, CHAR_Y);
|
|||
|
parent_dir = NPC_Util_getDirFromTwoPoint( &start,&end );
|
|||
|
/* <20><><EFBFBD>·<EFBFBD>ū<EFBFBD><C5AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ë <20><><EFBFBD><EFBFBD><EFBFBD>¿б<C2BF><D0B1><EFBFBD>
|
|||
|
* <EFBFBD>ݼ<EFBFBD><EFBFBD>ҷ<EFBFBD><EFBFBD>Ҽ<EFBFBD> ëܰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
end = start;
|
|||
|
if( parent_dir != -1 ) {
|
|||
|
CHAR_walk( toindex, parent_dir, 0);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
/**************************************
|
|||
|
* <EFBFBD>ݼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ë<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
**************************************/
|
|||
|
static int NPC_BusSetPoint( int meindex, char *argstr)
|
|||
|
{
|
|||
|
char buf[4096];
|
|||
|
char buf2[256];
|
|||
|
char buf3[256];
|
|||
|
int ret;
|
|||
|
char routetostring[64];
|
|||
|
|
|||
|
snprintf( routetostring, sizeof( routetostring), "routeto%d",
|
|||
|
CHAR_getWorkInt( meindex, NPC_WORK_CURRENTROUTE));
|
|||
|
|
|||
|
if( NPC_Util_GetStrFromStrWithDelim( argstr, routetostring,buf, sizeof(buf))
|
|||
|
== NULL )
|
|||
|
{
|
|||
|
print( "npcbus:nothing route \n");
|
|||
|
return FALSE;
|
|||
|
}
|
|||
|
ret = getStringFromIndexWithDelim( buf, ";",
|
|||
|
CHAR_getWorkInt( meindex, NPC_WORK_ROUTEPOINT),
|
|||
|
buf2, sizeof(buf2));
|
|||
|
|
|||
|
if( ret == FALSE ) return FALSE;
|
|||
|
|
|||
|
ret = getStringFromIndexWithDelim( buf2, ",", 1,
|
|||
|
buf3, sizeof(buf3));
|
|||
|
if( ret == FALSE) return FALSE;
|
|||
|
CHAR_setWorkInt( meindex, NPC_WORK_ROUTETOX, atoi( buf3));
|
|||
|
|
|||
|
ret = getStringFromIndexWithDelim( buf2, ",", 2,
|
|||
|
buf3, sizeof(buf3));
|
|||
|
if( ret == FALSE) return FALSE;
|
|||
|
CHAR_setWorkInt( meindex, NPC_WORK_ROUTETOY, atoi( buf3));
|
|||
|
return TRUE;
|
|||
|
}
|
|||
|
/**************************************
|
|||
|
* route į<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>
|
|||
|
**************************************/
|
|||
|
static void NPC_BusSetDestPoint( int meindex, char *argstr)
|
|||
|
{
|
|||
|
char buf[256];
|
|||
|
char routename[256];
|
|||
|
|
|||
|
snprintf( routename, sizeof( routename), "routename%d",
|
|||
|
CHAR_getWorkInt( meindex, NPC_WORK_CURRENTROUTE));
|
|||
|
|
|||
|
if( NPC_Util_GetStrFromStrWithDelim( argstr, routename, buf, sizeof( buf))
|
|||
|
!= NULL )
|
|||
|
{
|
|||
|
CHAR_setChar( meindex, CHAR_OWNTITLE, buf);
|
|||
|
CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX));
|
|||
|
}
|
|||
|
}
|
|||
|
/**************************************
|
|||
|
* ϶<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>
|
|||
|
**************************************/
|
|||
|
static BOOL NPC_BusCheckDeniedItem( int meindex, int charaindex, char *argstr)
|
|||
|
{
|
|||
|
char buf[1024];
|
|||
|
BOOL found = TRUE;
|
|||
|
|
|||
|
if( NPC_Util_GetStrFromStrWithDelim( argstr, "denieditem", buf, sizeof( buf))
|
|||
|
!= NULL )
|
|||
|
{
|
|||
|
int i;
|
|||
|
int ret;
|
|||
|
for( i = 1; ; i ++) {
|
|||
|
int itemid;
|
|||
|
char buf2[64];
|
|||
|
int j;
|
|||
|
ret = getStringFromIndexWithDelim( buf, ",", i, buf2, sizeof(buf2));
|
|||
|
if( ret == FALSE ) break;
|
|||
|
itemid = atoi( buf2);
|
|||
|
for( j = 0; j < CHAR_MAXITEMHAVE; j ++) {
|
|||
|
int itemindex = CHAR_getItemIndex( charaindex, j);
|
|||
|
if( ITEM_CHECKINDEX( itemindex)) {
|
|||
|
if( ITEM_getInt( itemindex, ITEM_ID) == itemid) {
|
|||
|
found = FALSE;
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
return found;
|
|||
|
}
|
|||
|
/**************************************
|
|||
|
* ϶<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><EFBFBD>ֻ<EFBFBD>
|
|||
|
**************************************/
|
|||
|
BOOL NPC_BusCheckAllowItem( int meindex, int charaindex, BOOL pickupmode)
|
|||
|
{
|
|||
|
char buf[1024];
|
|||
|
BOOL found = TRUE;
|
|||
|
BOOL pickup = FALSE;
|
|||
|
char argstr[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20];
|
|||
|
|
|||
|
NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr));
|
|||
|
|
|||
|
if( NPC_Util_GetStrFromStrWithDelim( argstr, "pickupitem", buf, sizeof( buf))!= NULL ){
|
|||
|
pickup = TRUE;
|
|||
|
}
|
|||
|
if( NPC_Util_GetStrFromStrWithDelim( argstr, "allowitem", buf, sizeof( buf))!= NULL ){
|
|||
|
int i;
|
|||
|
int ret;
|
|||
|
for( i = 1; ; i ++) {
|
|||
|
int itemid;
|
|||
|
char buf2[64];
|
|||
|
int j;
|
|||
|
BOOL getflg;
|
|||
|
ret = getStringFromIndexWithDelim( buf, ",", i, buf2, sizeof(buf2));
|
|||
|
if( ret == FALSE ) break;
|
|||
|
itemid = atoi( buf2);
|
|||
|
getflg = FALSE;
|
|||
|
for( j = 0; j < CHAR_MAXITEMHAVE; j ++) {
|
|||
|
int itemindex = CHAR_getItemIndex( charaindex, j);
|
|||
|
if( ITEM_CHECKINDEX( itemindex)) {
|
|||
|
if( ITEM_getInt( itemindex, ITEM_ID) == itemid) {
|
|||
|
if( pickupmode && pickup && !getflg) {
|
|||
|
CHAR_DelItem( charaindex, j);
|
|||
|
getflg = TRUE;
|
|||
|
}
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
if( j == CHAR_MAXITEMHAVE) {
|
|||
|
found = FALSE;
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
return found;
|
|||
|
}
|
|||
|
|
|||
|
/**************************************
|
|||
|
* ϶<EFBFBD>ý<EFBFBD>ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ì<EFBFBD>ﶯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
**************************************/
|
|||
|
static BOOL NPC_BusCheckLevel( int meindex, int charaindex, char *argstr)
|
|||
|
{
|
|||
|
int level;
|
|||
|
|
|||
|
/* ئ<><D8A6>ľ<EFBFBD><C4BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ئ<EFBFBD><D8A6>¦<EFBFBD>Ѽ<EFBFBD><D1BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
level = NPC_Util_GetNumFromStrWithDelim( argstr, "needlevel");
|
|||
|
if( level == -1 ) {
|
|||
|
return TRUE;
|
|||
|
}
|
|||
|
if( CHAR_getInt( charaindex, CHAR_LV) >= level ) return TRUE;
|
|||
|
|
|||
|
return FALSE;
|
|||
|
}
|
|||
|
/**************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ë<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* -1 <EFBFBD><EFBFBD> 0<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>ݾ<EFBFBD><EFBFBD><EFBFBD> ۢStone
|
|||
|
**************************************/
|
|||
|
static int NPC_BusCheckStone( int meindex, int charaindex, char *argstr)
|
|||
|
{
|
|||
|
int gold;
|
|||
|
|
|||
|
/* ئ<><D8A6>ľ<EFBFBD><C4BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ئ<EFBFBD><D8A6>¦<EFBFBD>Ѽ<EFBFBD><D1BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
gold = NPC_Util_GetNumFromStrWithDelim( argstr, "needstone");
|
|||
|
if( gold == -1 ) {
|
|||
|
return 0;
|
|||
|
}
|
|||
|
if( CHAR_getInt( charaindex, CHAR_GOLD) >= gold ) return gold;
|
|||
|
|
|||
|
return -1;
|
|||
|
}
|
|||
|
/**************************************
|
|||
|
* <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><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ë˪<EFBFBD><EFBFBD>
|
|||
|
**************************************/
|
|||
|
static void NPC_BusSendMsg( int meindex, int talkerindex, int tablenum)
|
|||
|
{
|
|||
|
char argstr[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20];
|
|||
|
char buf[256];
|
|||
|
char msg[256];
|
|||
|
if( tablenum < 0 || tablenum >= arraysizeof( busmsg)) return;
|
|||
|
|
|||
|
NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr));
|
|||
|
|
|||
|
if( NPC_Util_GetStrFromStrWithDelim( argstr, busmsg[tablenum].option, buf, sizeof( buf))
|
|||
|
!= NULL )
|
|||
|
{
|
|||
|
strcpy( msg, buf);
|
|||
|
}
|
|||
|
else {
|
|||
|
snprintf( msg, sizeof(msg),busmsg[tablenum].defaultmsg);
|
|||
|
}
|
|||
|
CHAR_talkToCli( talkerindex, meindex, msg, CHAR_COLORYELLOW);
|
|||
|
}
|
|||
|
/**************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>Ƥ<EFBFBD>P<EFBFBD><EFBFBD><EFBFBD>̼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ë<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
**************************************/
|
|||
|
static int NPC_BusGetRoutePointNum( int meindex, char *argstr )
|
|||
|
{
|
|||
|
int i;
|
|||
|
char buf[4096];
|
|||
|
char buf2[256];
|
|||
|
int ret;
|
|||
|
char routetostring[64];
|
|||
|
|
|||
|
snprintf( routetostring, sizeof( routetostring), "routeto%d",
|
|||
|
CHAR_getWorkInt( meindex, NPC_WORK_CURRENTROUTE));
|
|||
|
|
|||
|
if( NPC_Util_GetStrFromStrWithDelim( argstr, routetostring,buf, sizeof(buf))
|
|||
|
== NULL )
|
|||
|
{
|
|||
|
print( "npcbus:nothing route \n");
|
|||
|
return -1;
|
|||
|
}
|
|||
|
for( i = 1; ; i ++ ) {
|
|||
|
ret = getStringFromIndexWithDelim( buf, ";", i, buf2, sizeof(buf2));
|
|||
|
if( ret == FALSE) break;
|
|||
|
}
|
|||
|
return( i -1);
|
|||
|
}
|
|||
|
BOOL NPC_BusCheckJoinParty( int meindex, int charaindex, BOOL msgflg)
|
|||
|
{
|
|||
|
//int fd;
|
|||
|
char argstr[NPC_UTIL_GETARGSTR_BUFSIZE - 1024 * 20];
|
|||
|
int ret;
|
|||
|
NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr));
|
|||
|
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> */
|
|||
|
if( !NPC_Util_charIsInFrontOfChar( charaindex, meindex, 1 )) return FALSE;
|
|||
|
/* <20><><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD> <20><><EFBFBD><EFBFBD> */
|
|||
|
if( CHAR_getWorkInt( meindex, NPC_WORK_MODE) != 0 ) {
|
|||
|
if( msgflg) NPC_BusSendMsg( meindex, charaindex, NPC_BUS_MSG_GETTINGON);
|
|||
|
return FALSE;
|
|||
|
}
|
|||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>շֻ<D5B7> */
|
|||
|
if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE ) != CHAR_PARTY_NONE) {
|
|||
|
if( msgflg) NPC_BusSendMsg( meindex, charaindex, NPC_BUS_MSG_NOTPARTY);
|
|||
|
return FALSE;
|
|||
|
}
|
|||
|
/* <20>ɡ<EFBFBD> ū<><C5AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ë<EFBFBD><C3AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
if( CHAR_getEmptyPartyArray( meindex) == -1 ) {
|
|||
|
if( msgflg) NPC_BusSendMsg( meindex, charaindex, NPC_BUS_MSG_OVERPARTY);
|
|||
|
return FALSE;
|
|||
|
}
|
|||
|
/* ʧ<><CAA7> ة<><D8A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ë<EFBFBD><C3AB><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7> ة) */
|
|||
|
if( !NPC_BusCheckDeniedItem( meindex, charaindex, argstr)) {
|
|||
|
if( msgflg) NPC_BusSendMsg( meindex, charaindex, NPC_BUS_MSG_DENIEDITEM);
|
|||
|
return FALSE;
|
|||
|
}
|
|||
|
#ifdef _ITEM_CHECKWARES
|
|||
|
if( CHAR_CheckInItemForWares( charaindex, 0) == FALSE ) {
|
|||
|
CHAR_talkToCli( charaindex, -1, "<EFBFBD><EFBFBD>Я<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϳ<EFBFBD><EFBFBD><EFBFBD>", CHAR_COLORYELLOW);
|
|||
|
return FALSE;
|
|||
|
}
|
|||
|
#endif
|
|||
|
/* ʧ<><CAA7> ة<><D8A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ë<EFBFBD><C3AB><EFBFBD><EFBFBD>( ۢʧ<DBA2><CAA7> ة) */
|
|||
|
if( !NPC_BusCheckAllowItem( meindex, charaindex, FALSE)) {
|
|||
|
if( msgflg) NPC_BusSendMsg( meindex, charaindex, NPC_BUS_MSG_ALLOWITEM);
|
|||
|
return FALSE;
|
|||
|
}
|
|||
|
/* <20><>ì<EFBFBD>P<EFBFBD><EFBCB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ë<EFBFBD><C3AB><EFBFBD><EFBFBD> */
|
|||
|
if( !NPC_BusCheckLevel( meindex, charaindex, argstr)) {
|
|||
|
if( msgflg) NPC_BusSendMsg( meindex, charaindex, NPC_BUS_MSG_LEVEL);
|
|||
|
return FALSE;
|
|||
|
}
|
|||
|
/* <20><>ì<EFBFBD><C3AC><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
// if( CHAR_getInt( charaindex, CHAR_NOWEVENT) != 0 ||
|
|||
|
// CHAR_getInt( charaindex, CHAR_NOWEVENT2) != 0 ||
|
|||
|
// CHAR_getInt( charaindex, CHAR_NOWEVENT3) != 0 )
|
|||
|
// {
|
|||
|
// if( msgflg) NPC_BusSendMsg( meindex, charaindex, NPC_BUS_MSG_EVENT);
|
|||
|
// return FALSE;
|
|||
|
// }
|
|||
|
/* <20><><EFBFBD>ż<EFBFBD><C5BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ë<EFBFBD><C3AB><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ë<EFBFBD><C3AB><EFBFBD>¼<EFBFBD>ƥ<EFBFBD><C6A5> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD><EFBFBD>³<EFBFBD><C2B3><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
ret = NPC_BusCheckStone( meindex, charaindex, argstr);
|
|||
|
if( ret == -1 ) {
|
|||
|
if( msgflg) NPC_BusSendMsg( meindex, charaindex, NPC_BUS_MSG_GOLD);
|
|||
|
return FALSE;
|
|||
|
}
|
|||
|
if( ret != 0 ) {
|
|||
|
char msgbuf[128];
|
|||
|
/* <20><><EFBFBD><EFBFBD>ë<EFBFBD><C3AB><EFBFBD><EFBFBD> */
|
|||
|
CHAR_setInt( charaindex, CHAR_GOLD,
|
|||
|
CHAR_getInt( charaindex, CHAR_GOLD) - ret);
|
|||
|
/* ˪<><CBAA> */
|
|||
|
CHAR_send_P_StatusString( charaindex, CHAR_P_STRING_GOLD);
|
|||
|
snprintf( msgbuf, sizeof( msgbuf), "֧<EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d Stone<6E><65>", ret);
|
|||
|
CHAR_talkToCli( charaindex, -1, msgbuf, CHAR_COLORYELLOW);
|
|||
|
}
|
|||
|
/* <20>ɡ<EFBFBD> ū<><C5AB> <20><> */
|
|||
|
//CHAR_JoinParty_Main( charaindex, meindex);
|
|||
|
|
|||
|
//fd = getfdFromCharaIndex( charaindex );
|
|||
|
|
|||
|
//lssproto_PR_send( fd, 1, 1);
|
|||
|
|
|||
|
|
|||
|
return TRUE;
|
|||
|
}
|