chuyiwen_gmsv/npc/npc_doorman.c

216 lines
7.8 KiB
C
Raw Normal View History

2016-12-24 08:45:52 +08:00
#include "version.h"
#include <string.h>
#include "object.h"
#include "char_base.h"
#include "char.h"
#include "item.h"
#include "util.h"
#include "handletime.h"
#include "npc_doorman.h"
#include "npc_door.h"
#include "npcutil.h"
#include "configfile.h"
/*
*
2017-01-13 23:37:03 +08:00
* NPC.
* create允月分仃匹
* 仿8
*
2016-12-24 08:45:52 +08:00
*
2017-01-13 23:37:03 +08:00
* Talk匹
2016-12-24 08:45:52 +08:00
*
2017-01-13 23:37:03 +08:00
*
2016-12-24 08:45:52 +08:00
*
2017-01-13 23:37:03 +08:00
* 1 gold|100
* 2 1 item|45
* 3 itemhave|44
* 4
2016-12-24 08:45:52 +08:00
* itemnothave|333
2017-01-13 23:37:03 +08:00
* 5 titlehave|string
* 6
2016-12-24 08:45:52 +08:00
* titlenothave|string
*
2017-01-13 23:37:03 +08:00
*
*100100
* 100
*
2016-12-24 08:45:52 +08:00
*
2017-01-13 23:37:03 +08:00
*
* 36
2016-12-24 08:45:52 +08:00
*
*
*
2017-01-13 23:37:03 +08:00
*
2016-12-24 08:45:52 +08:00
*
2017-01-13 23:37:03 +08:00
*1
*2 NPC毛赝癫卞玉失及午卅曰卞 gold|100
*3 NPC卞覆仄化100
*4
2016-12-24 08:45:52 +08:00
*
*/
static void NPC_DoormanOpenDoor( char *nm );
BOOL NPC_DoormanInit( int meindex )
{
char arg[NPC_UTIL_GETARGSTR_BUFSIZE];
char dname[1024];
2017-01-13 23:37:03 +08:00
/* 奶矛件玄及正奶皿涩烂 */
2016-12-24 08:45:52 +08:00
CHAR_setWorkInt( meindex, CHAR_WORKEVENTTYPE,CHAR_EVENT_NPC);
CHAR_setInt( meindex , CHAR_HP , 0 );
CHAR_setInt( meindex , CHAR_MP , 0 );
CHAR_setInt( meindex , CHAR_MAXMP , 0 );
CHAR_setInt( meindex , CHAR_STR , 0 );
CHAR_setInt( meindex , CHAR_TOUGH, 0 );
CHAR_setInt( meindex , CHAR_LV , 0 );
CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPETOWNPEOPLE );
CHAR_setFlg( meindex , CHAR_ISOVERED , 0 );
2017-01-13 23:37:03 +08:00
CHAR_setFlg( meindex , CHAR_ISATTACKED , 0 ); /* 猾今木卅中方氏 */
2016-12-24 08:45:52 +08:00
NPC_Util_GetArgStr( meindex, arg, sizeof( arg));
if(!getStringFromIndexWithDelim( arg, "|", 3, dname, sizeof(dname ))){
2017-01-13 23:37:03 +08:00
print("RINGO: 设定看门者时需要门的名字唷!:%s:\n",
2016-12-24 08:45:52 +08:00
arg );
return FALSE;
}
print( "RINGO: Doorman create: arg: %s dname: %s\n",arg,dname);
CHAR_setWorkChar( meindex , CHAR_WORKDOORMANDOORNAME , dname );
return TRUE;
}
void NPC_DoormanTalked( int meindex , int talkerindex , char *msg ,
int color )
{
char mode[128];
char opt[256];
char arg[NPC_UTIL_GETARGSTR_BUFSIZE];
2017-01-13 23:37:03 +08:00
/* 皿伊奶乩□互玉失穴件及1弘伉永玉动 卅日反氏及丹 */
2016-12-24 08:45:52 +08:00
if(NPC_Util_CharDistance( talkerindex, meindex ) > 1)return;
NPC_Util_GetArgStr( meindex, arg, sizeof( arg));
if( !getStringFromIndexWithDelim( arg, "|", 1, mode, sizeof( mode )))
return;
if( !getStringFromIndexWithDelim( arg, "|", 2, opt, sizeof( opt ) ))
return;
if( strcmp( mode , "gold" ) == 0 ){
int g = atoi( opt );
int yn = NPC_Util_YN( msg );
/*char *nm = CHAR_getChar( meindex , CHAR_NAME );*/
char msg[256];
if( g > 0 && yn < 0 ){
snprintf( msg ,sizeof( msg ) ,
2017-01-13 23:37:03 +08:00
"打开门需要给我%d的金子这样可以吗", g );
2016-12-24 08:45:52 +08:00
CHAR_talkToCli( talkerindex, meindex , msg, CHAR_COLORWHITE );
} else if( g > 0 && yn == 0 ){
snprintf( msg , sizeof( msg ),
2017-01-13 23:37:03 +08:00
"打开门 %d的金子是必要的。", g );
2016-12-24 08:45:52 +08:00
} else if( g > 0 && yn == 1 ){
int now_g = CHAR_getInt( talkerindex, CHAR_GOLD );
if( now_g < g ){
snprintf( msg , sizeof( msg ) ,
2017-01-13 23:37:03 +08:00
"打开门 %d的金子是必要的。", g );
2016-12-24 08:45:52 +08:00
CHAR_talkToCli( talkerindex, meindex , msg, CHAR_COLORWHITE );
} else {
snprintf( msg , sizeof( msg ),
2017-01-13 23:37:03 +08:00
"%d 收到金子了。现在就来开门。", g );
2016-12-24 08:45:52 +08:00
CHAR_talkToCli( talkerindex, meindex , msg, CHAR_COLORWHITE );
2017-01-13 23:37:03 +08:00
/* 云嗯毛必永玄 */
2016-12-24 08:45:52 +08:00
now_g -= g;
CHAR_setInt( talkerindex , CHAR_GOLD , now_g );
2017-01-13 23:37:03 +08:00
/* 丐凶日仄中旦 □正旦毛霜耨 */
2016-12-24 08:45:52 +08:00
CHAR_send_P_StatusString(talkerindex, CHAR_P_STRING_GOLD);
2017-01-13 23:37:03 +08:00
/* 玉失夫日仁 */
2016-12-24 08:45:52 +08:00
NPC_DoormanOpenDoor(
CHAR_getWorkChar( meindex, CHAR_WORKDOORMANDOORNAME));
}
}
} else if( strcmp( mode , "item" ) == 0 ){
CHAR_talkToCli( talkerindex, meindex ,
2017-01-13 23:37:03 +08:00
"尚在未支援模式。",
2016-12-24 08:45:52 +08:00
CHAR_COLORWHITE);
} else if( strcmp( mode , "itemhave" ) == 0 ){
CHAR_talkToCli( talkerindex, meindex ,
2017-01-13 23:37:03 +08:00
"尚在未支援模式。",
2016-12-24 08:45:52 +08:00
CHAR_COLORWHITE);
} else if( strcmp( mode , "itemnothave" ) == 0 ){
CHAR_talkToCli( talkerindex, meindex ,
2017-01-13 23:37:03 +08:00
"尚在未支援模式。",
2016-12-24 08:45:52 +08:00
CHAR_COLORWHITE);
} else if( strcmp( mode , "titlehave" ) == 0 ){
CHAR_talkToCli( talkerindex, meindex ,
2017-01-13 23:37:03 +08:00
"尚在未支援模式。",
2016-12-24 08:45:52 +08:00
CHAR_COLORWHITE);
} else if( strcmp( mode , "roomlimit" ) == 0 ){
2017-01-13 23:37:03 +08:00
/* 盒及谛醒孺蜃互丐月桦宁 */
2016-12-24 08:45:52 +08:00
char szOk[256], szNg[256], szBuf[32];
int checkfloor;
int maxnum, i, iNum;
if( !getStringFromIndexWithDelim( arg, "|", 2, szBuf, sizeof( szBuf ) ))
return;
2017-01-13 23:37:03 +08:00
/* 譬屯月白夫失午 谛醒 */
2016-12-24 08:45:52 +08:00
if( sscanf( szBuf, "%d:%d", &checkfloor, &maxnum ) != 2 ){
return;
}
for( iNum = 0,i = 0; i < getFdnum(); i ++ ){
2017-01-13 23:37:03 +08:00
/* 皿伊奶乩□动陆卞反饬 互 中 */
2016-12-24 08:45:52 +08:00
if( CHAR_getCharUse( i ) == FALSE )continue;
if( CHAR_getInt( i, CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER )continue;
2017-01-13 23:37:03 +08:00
/* 隙烂及白夫失动陆卞饬 互 中 */
2016-12-24 08:45:52 +08:00
if( CHAR_getInt( i, CHAR_FLOOR ) != checkfloor )continue;
iNum++;
}
if( !getStringFromIndexWithDelim( arg, "|", 5, szNg, sizeof( szNg ))){
2017-01-13 23:37:03 +08:00
strcpy( szNg, "。。。。" ); /* 凤伞卅仄及本伉白 */
2016-12-24 08:45:52 +08:00
}
if( !getStringFromIndexWithDelim( arg, "|", 4, szOk, sizeof( szOk ))){
2017-01-13 23:37:03 +08:00
strcpy( szOk, "开门吧。。。" ); /* 凤伞丐曰及本伉白 */
2016-12-24 08:45:52 +08:00
}
if( iNum >= maxnum ){
2017-01-13 23:37:03 +08:00
/* 毛译尹化中月桦宁 */
2016-12-24 08:45:52 +08:00
CHAR_talkToCli( talkerindex, meindex ,szNg, CHAR_COLORWHITE);
}else{
2017-01-13 23:37:03 +08:00
/* 卞 凶卅中桦宁 */
2016-12-24 08:45:52 +08:00
CHAR_talkToCli( talkerindex, meindex ,szOk, CHAR_COLORWHITE);
NPC_DoormanOpenDoor(
CHAR_getWorkChar( meindex, CHAR_WORKDOORMANDOORNAME));
}
} else if( strcmp( mode , "titlenothave" ) == 0 ){
CHAR_talkToCli( talkerindex, meindex ,
2017-01-13 23:37:03 +08:00
"尚在未支援模式。",
2016-12-24 08:45:52 +08:00
CHAR_COLORWHITE);
}
}
/*
2017-01-13 23:37:03 +08:00
*
2016-12-24 08:45:52 +08:00
*
*/
static void NPC_DoormanOpenDoor( char *nm)
{
int doori = NPC_DoorSearchByName( nm );
print( "RINGO: Doorman's Door: index: %d\n", doori );
NPC_DoorOpen( doori , -1 );
}