chuyiwen_gmsv/npc/npc_action.c

138 lines
3.8 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 "npc_action.h"
/*
2017-01-13 23:37:03 +08:00
* NPC
*
*
2016-12-24 08:45:52 +08:00
*
2017-01-13 23:37:03 +08:00
*
* msgcol:
* normal:
* attack:
* damage:
* down:
* sit:
* hand:
* pleasure:
* angry:
* sad:
* guard:
2016-12-24 08:45:52 +08:00
*/
#define NPC_ACTION_MSGCOLOR_DEFAULT CHAR_COLORYELLOW
enum {
CHAR_WORK_MSGCOLOR = CHAR_NPCWORKINT1,
};
/*********************************
2017-01-13 23:37:03 +08:00
*
2016-12-24 08:45:52 +08:00
*********************************/
BOOL NPC_ActionInit( int meindex )
{
char argstr[NPC_UTIL_GETARGSTR_BUFSIZE];
int tmp;
tmp = NPC_Util_GetNumFromStrWithDelim( argstr, "msgcol");
if( tmp == -1 ) tmp = NPC_ACTION_MSGCOLOR_DEFAULT;
CHAR_setWorkInt( meindex, CHAR_WORK_MSGCOLOR, tmp);
CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEACTION );
return TRUE;
}
/*********************************
2017-01-13 23:37:03 +08:00
*
2016-12-24 08:45:52 +08:00
*********************************/
void NPC_ActionTalked( int meindex , int talkerindex , char *szMes ,
int color )
{
char argstr[NPC_UTIL_GETARGSTR_BUFSIZE];
char buf[64];
2017-01-13 23:37:03 +08:00
/* 皿伊奶乩□卞覆仄化分仃 杀允月 */
2016-12-24 08:45:52 +08:00
if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) {
return;
}
2017-01-13 23:37:03 +08:00
/* ㄠ弘伉永玉动 及心 */
2016-12-24 08:45:52 +08:00
if( !NPC_Util_charIsInFrontOfChar( talkerindex, meindex, 1 )) return;
NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr));
if( NPC_Util_GetStrFromStrWithDelim( argstr,
"normal",
buf, sizeof( buf))
!= NULL )
{
CHAR_talkToCli( talkerindex, meindex ,buf ,
CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR ));
}
}
/*********************************
2017-01-13 23:37:03 +08:00
* watch质
2016-12-24 08:45:52 +08:00
*********************************/
void NPC_ActionWatch( int meobjindex, int objindex, CHAR_ACTION act,
int x,int y,int dir, int* opt,int optlen )
{
int meindex;
int index;
char argstr[NPC_UTIL_GETARGSTR_BUFSIZE];
char buf[64];
int i;
struct {
CHAR_ACTION act;
char *string;
}searchtbl[] = {
{ CHAR_ACTATTACK, "attack"},
{ CHAR_ACTDAMAGE, "damage"},
{ CHAR_ACTDOWN, "down"},
{ CHAR_ACTSIT, "sit"},
{ CHAR_ACTHAND, "hand"},
{ CHAR_ACTPLEASURE, "pleasure"},
{ CHAR_ACTANGRY, "angry"},
{ CHAR_ACTSAD, "sad"},
{ CHAR_ACTGUARD, "guard"},
{ CHAR_ACTNOD, "nod"},
{ CHAR_ACTTHROW, "throw"},
};
if( OBJECT_getType( objindex) != OBJTYPE_CHARA) return;
index = OBJECT_getIndex( objindex);
2017-01-13 23:37:03 +08:00
/* 皿伊奶乩□卞及心 杀允月 */
2016-12-24 08:45:52 +08:00
if( CHAR_getInt( index, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER) return;
meindex = OBJECT_getIndex( meobjindex);
2017-01-13 23:37:03 +08:00
/* 轾五宁匀化ㄠ弘伉永玉匹卅中午 杀仄卅中 */
2016-12-24 08:45:52 +08:00
if( NPC_Util_isFaceToFace( meindex, index, 1 ) != TRUE ) return;
NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr));
for( i = 0; i < arraysizeof( searchtbl); i ++ ) {
if( searchtbl[i].act == act) {
if( NPC_Util_GetStrFromStrWithDelim( argstr,
searchtbl[i].string,
buf, sizeof( buf))
!= NULL )
{
CHAR_talkToCli( index, meindex ,buf ,
CHAR_getWorkInt( meindex, CHAR_WORK_MSGCOLOR ));
break;
}
}
}
}