chuyiwen_gmsv/npc/npc_action.c

138 lines
3.5 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"
/*
* <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>NPC<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>ئ<EFBFBD>У<EFBFBD>
*
* ¦<EFBFBD>ѡ<EFBFBD>
* msgcol: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ۷<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* normal: ɧ<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>
* attack: <EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߯<EFBFBD><EFBFBD>
* damage: ĸ<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>
* down: <EFBFBD><EFBFBD>ľ<EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߯<EFBFBD><EFBFBD>
* sit: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD><EFBFBD><EFBFBD>߯<EFBFBD><EFBFBD>
* hand: <EFBFBD><EFBFBD>ë<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD><EFBFBD><EFBFBD>߯<EFBFBD><EFBFBD>
* pleasure: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD><EFBFBD><EFBFBD>߯<EFBFBD><EFBFBD>
* angry: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD><EFBFBD><EFBFBD>߯<EFBFBD><EFBFBD>
* sad: <EFBFBD>Ƹ<EFBFBD>ʧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD><EFBFBD><EFBFBD>߯<EFBFBD><EFBFBD>
* guard: <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>
*/
#define NPC_ACTION_MSGCOLOR_DEFAULT CHAR_COLORYELLOW
enum {
CHAR_WORK_MSGCOLOR = CHAR_NPCWORKINT1,
};
/*********************************
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*********************************/
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;
}
/*********************************
* <EFBFBD>ƾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ľ<EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD><EFBFBD><EFBFBD>
*********************************/
void NPC_ActionTalked( int meindex , int talkerindex , char *szMes ,
int color )
{
char argstr[NPC_UTIL_GETARGSTR_BUFSIZE];
char buf[64];
/* <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><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> */
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 ));
}
}
/*********************************
* watch<EFBFBD><EFBFBD>
*********************************/
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);
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E5BCB0> ɱ<><C9B1><EFBFBD><EFBFBD> */
if( CHAR_getInt( index, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER) return;
meindex = OBJECT_getIndex( meobjindex);
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥئ<C6A5><D8A6><EFBFBD><EFBFBD> ɱ<><C9B1>ئ<EFBFBD><D8A6> */
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;
}
}
}
}