📄 npc_eventaction.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 "saacproto_cli.h"
#include "map_deal.h"
#include "readmap.h"
#include "battle.h"
#include "log.h"
#include "enemy.h"
#include "handletime.h"
#include "npc_eventaction.h"
#include "family.h"
#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能
#include "profession_skill.h"
#include "chatmagic.h"
#endif
enum{
NPC_EVENTMODE_NONE,
NPC_EVENTMODE_OPEN,
NPC_EVENTMODE_EVENT,
};
typedef struct {
char arg[32];
int born;
int dead;
}NPC_TimeMan;
#define YOAKE 700
#define NICHIBOTU 300
#define SHOUGO 125
#define YONAKA 500
static NPC_TimeMan TimeTble[] = {
{"ALLNIGHT", NICHIBOTU+1, YOAKE},
{"ALLNOON", YOAKE+1, NICHIBOTU},
{"AM", YONAKA+1, SHOUGO},
{"PM", SHOUGO+1, YONAKA},
{"FORE", YOAKE+1, SHOUGO},
{"AFTER", SHOUGO+1, NICHIBOTU},
{"EVNING", NICHIBOTU+1, YONAKA},
{"MORNING", YONAKA+1, YOAKE},
{"FREE", 0, 1024},
};
extern void BATTLE_changeRideImage( int index );
#define MAXNPCPOINT 10
BOOL ActionNpc_WarpPoint(int meindex,int talker,char *npcarg)
{
char data[1024], buf1[256], buf2[256];
int i=1, j=0;
BOOL EvFlg=FALSE;
struct {
int FLOOR;
int X;
int Y;
}Points[MAXNPCPOINT];
for( i=0;i<MAXNPCPOINT;i++) {
Points[i].FLOOR = -1;
Points[i].X = -1;
Points[i].Y = -1;
}
//NPC_POINT
if( NPC_Util_GetStrFromStrWithDelim( npcarg, "NPC_POINT", data, sizeof( data)) != NULL ) {
int where=0;
i=1;
j=0;
while( getStringFromIndexWithDelim( data, ";", i, buf1, sizeof( buf1)) != FALSE ) {
i++;
getStringFromIndexWithDelim( buf1, ",", 1, buf2, sizeof( buf2));
Points[j].FLOOR = atoi( buf2);
getStringFromIndexWithDelim( buf1, ",", 2, buf2, sizeof( buf2));
Points[j].X = atoi( buf2);
getStringFromIndexWithDelim( buf1, ",", 3, buf2, sizeof( buf2));
Points[j].Y = atoi( buf2);
j++;
if( j >= MAXNPCPOINT )
break;
}
where = RAND( 0, j-1);
if( MAP_IsValidCoordinate( Points[where].FLOOR, Points[where].X, Points[where].Y ) == TRUE ){
CHAR_warpToSpecificPoint( meindex, Points[where].FLOOR, Points[where].X, Points[where].Y);
EvFlg = TRUE;
}else {
for( i=0; i<10; i++) {
print("%d.[%d,%d,%d]\n", i, Points[i].FLOOR, Points[i].X, Points[i].Y);
}
}
}
if( NPC_Util_GetStrFromStrWithDelim( npcarg, "WARPPOINT", data, sizeof( data)) != NULL ) {
int where=0;
i=1;
j=0;
while( getStringFromIndexWithDelim( data, ";", i, buf1, sizeof( buf1)) != FALSE ) {
i++;
getStringFromIndexWithDelim( buf1, ",", 1, buf2, sizeof( buf2));
Points[j].FLOOR = atoi( buf2);
getStringFromIndexWithDelim( buf1, ",", 2, buf2, sizeof( buf2));
Points[j].X = atoi( buf2);
getStringFromIndexWithDelim( buf1, ",", 3, buf2, sizeof( buf2));
Points[j].Y = atoi( buf2);
j++;
if( j >= MAXNPCPOINT )
break;
}
where = RAND( 0, j-1);
if( MAP_IsValidCoordinate( Points[where].FLOOR, Points[where].X, Points[where].Y ) == TRUE ){
CHAR_warpToSpecificPoint( talker, Points[where].FLOOR, Points[where].X, Points[where].Y);
EvFlg = TRUE;
}else {
for( i=0; i<10; i++) {
print("%d.[%d,%d,%d]\n", i, Points[i].FLOOR, Points[i].X, Points[i].Y);
}
}
}
return EvFlg;
}
BOOL ActionNpc_CheckMenuFree( int meindex, int toindex, char *npcarg, int nums)
{
char buf1[1024], buf2[256];
if( nums < 1 ) return FALSE;
if( NPC_Util_GetStrFromStrWithDelim( npcarg, "CHECKPARTY", buf1, sizeof( buf1) ) != NULL){
if( strstr( buf1, "TRUE") != 0 ) {
if( Action_PartyCheck( meindex, toindex) == FALSE) {
CHAR_talkToCli( toindex, meindex, "请一个一个来!", CHAR_COLORYELLOW);
return FALSE;
}
}
}
if( getStringFromIndexWithDelim( npcarg,"}", nums, buf1, sizeof( buf1)) == FALSE )
return FALSE;
if( NPC_Util_GetStrFromStrWithDelim( buf1, "FREE", buf2, sizeof( buf2) ) == NULL)
return FALSE;
if( NPC_ActionPassCheck( meindex, toindex, buf2) == FALSE ) {
CHAR_talkToCli( toindex, meindex, "条件不足!", CHAR_COLORYELLOW);
return FALSE;
}
return Action_RunDoEventAction( meindex, toindex, buf1);
}
BOOL ActionNpc_CheckFree( int meindex, int toindex, char *npcarg)
{
char buf1[1024], buf2[256];
if( NPC_Util_GetStrFromStrWithDelim( npcarg, "CHECKPARTY", buf1, sizeof( buf1) ) != NULL){
if( strstr( buf1, "TRUE") != 0 ) {
if( Action_PartyCheck( meindex, toindex) == FALSE) {
CHAR_talkToCli( toindex, meindex, "请一个一个来!", CHAR_COLORYELLOW);
return FALSE;
}
}
}
if( NPC_Util_GetStrFromStrWithDelim( npcarg, "FREE", buf2, sizeof( buf2) ) == NULL)
return FALSE;
if( NPC_ActionPassCheck( meindex, toindex, buf2) == FALSE ) {
CHAR_talkToCli( toindex, meindex, "条件不足!", CHAR_COLORYELLOW);
return FALSE;
}
return Action_RunDoEventAction( meindex, toindex, buf1);
}
#ifdef _CHANNEL_MODIFY
extern int *piOccChannelMember;
#endif
BOOL Action_RunDoEventAction( int meindex, int toindex, char *buf1)
{
char buf2[1256];
#if 1 // Robin NPC执行动作前再一次检查FREE条件
if( NPC_Util_GetStrFromStrWithDelim( buf1, "FREE", buf2, sizeof( buf2)) != NULL ) {
if( NPC_ActionPassCheck( meindex, toindex, buf2 ) == FALSE && buf2[0] != NULL ) {
print("\n 改封包!?跳过NPC的FREE检查!!:%s:%d,%d,%d ",
CHAR_getChar(toindex, CHAR_CDKEY),
CHAR_getInt(toindex, CHAR_FLOOR),
CHAR_getInt(toindex, CHAR_X),
CHAR_getInt(toindex, CHAR_Y) );
CHAR_warpToSpecificPoint(toindex,117,225,13);
return FALSE;
}
}
#endif
if( NPC_Util_GetStrFromStrWithDelim( buf1, "AddGold", buf2, sizeof( buf2)) != NULL ) {
if( NPC_ActionAddGold2( toindex, buf2) == FALSE )
return FALSE;
}
if( NPC_Util_GetStrFromStrWithDelim( buf1, "DelGold", buf2, sizeof( buf2)) != NULL ) {
if( NPC_ActionDelGold( toindex, buf2) == FALSE )
return FALSE;
}
if( NPC_Util_GetStrFromStrWithDelim( buf1, "DelItem", buf2, sizeof( buf2)) != NULL ) {
//print("\n DelItem:%s:%d ", __FILE__, __LINE__);
if( NPC_ActionDelItem( toindex, buf2) == FALSE ) {
//print("\n 改封包??NPC_ActionDelItem:%s:%s ", CHAR_getChar(toindex, CHAR_CDKEY), buf2);
//CHAR_warpToSpecificPoint(toindex,117,225,13);
return FALSE;
}
}
//条件成立後npc所给的道具
if( NPC_Util_GetStrFromStrWithDelim( buf1, "AddItem", buf2, sizeof( buf2)) != NULL ) {
if( NPC_ActionAddItem( toindex, buf2) == FALSE )
return FALSE;
}
if( NPC_Util_GetStrFromStrWithDelim( buf1, "DelPet", buf2, sizeof( buf2)) != NULL ) {
if( NPC_ActionDelPet( toindex, buf2) == FALSE )
return FALSE;
}
#ifdef _NPC_NewDelPet
if( NPC_Util_GetStrFromStrWithDelim( buf1, "NewDelPet", buf2, sizeof( buf2)) != NULL ) {
if( NPC_ActionNewDelPet( toindex, buf2) == FALSE )
return FALSE;
}
#endif
if( NPC_Util_GetStrFromStrWithDelim( buf1, "AddPet", buf2, sizeof( buf2)) != NULL ) {
if( NPC_ActionAddPet( toindex, buf2) == FALSE )
return FALSE;
}
if( NPC_Util_GetStrFromStrWithDelim( buf1, "EvEnd", buf2, sizeof( buf2)) != NULL ) {
if( NPC_ActionSetEend( toindex, buf2) == FALSE )
return FALSE;
}
if( NPC_Util_GetStrFromStrWithDelim( buf1, "EvNow", buf2, sizeof( buf2)) != NULL ) {
if( NPC_ActionSetNow( toindex, buf2) == FALSE )
return FALSE;
}
if( NPC_Util_GetStrFromStrWithDelim( buf1, "Event_End", buf2, sizeof( buf2) ) != NULL) {
if( NPC_ActionSetEend( toindex, buf2) == FALSE ) {
return FALSE;
}
}
if( NPC_Util_GetStrFromStrWithDelim( buf1, "Event_Now", buf2, sizeof( buf2) ) != NULL) {
if( NPC_ActionSetNow( toindex, buf2) == FALSE )
return FALSE;
}
if( NPC_Util_GetStrFromStrWithDelim( buf1, "EvClr", buf2, sizeof( buf2) ) != NULL) {
if( NPC_ActionClearEvent( toindex, buf2) == FALSE )
return FALSE;
}
#ifdef _NPCCHANGE_PLAYERIMG
if( NPC_Util_GetStrFromStrWithDelim( buf1, "CHANGEBBI", buf2, sizeof( buf2) ) != NULL) {
if( NPC_ActionChangePlayerBBI( meindex, toindex, buf2) == FALSE )
return FALSE;
}
#endif
if( NPC_Util_GetStrFromStrWithDelim( buf1, "SetLastTalkelder", buf2, sizeof( buf2) ) != NULL) {
CHAR_setInt( toindex, CHAR_LASTTALKELDER, atoi( buf2));
}
#ifdef _TYPE_TOXICATION
if( NPC_Util_GetStrFromStrWithDelim( buf1, "TOXICATION", buf2, sizeof( buf2) ) != NULL) {
int fd = getfdFromCharaIndex( toindex );
if( strstr( buf2, "TRUE") != 0 ){
setToxication( fd, 1);
CHAR_setWorkInt( toindex, CHAR_WORKTOXICATION, 0 );
if( NPC_Util_GetStrFromStrWithDelim( buf1, "TOXICATIONMSG", buf2, sizeof( buf2) ) != NULL) {
CHAR_talkToCli( toindex, -1, buf1, CHAR_COLORYELLOW);
}
}else {
CHAR_setWorkInt( toindex, CHAR_WORKTOXICATION, 0 );
setToxication( fd, 0);
if( NPC_Util_GetStrFromStrWithDelim( buf1, "DETOXIFYMSG", buf2, sizeof( buf2) ) != NULL) {
CHAR_talkToCli( toindex, -1, buf2, CHAR_COLORYELLOW);
}
}
}
#endif
#ifdef _ACTION_GMQUE
if( NPC_Util_GetStrFromStrWithDelim( buf1, "GMACTION", buf2, sizeof( buf2) ) != NULL) {
if( strstr( buf2, "TRUE") != 0 ){
if( GMQUE_getQueStr( meindex, toindex) == FALSE ){
return FALSE;
}
}
}
if( NPC_Util_GetStrFromStrWithDelim( buf1, "ShowGmque", buf2, sizeof( buf2) ) != NULL) {
if( strstr( buf2, "TRUE") != 0 )
GMQUE_showQueStr( meindex, toindex);
}
if( NPC_Util_GetStrFromStrWithDelim( buf1, "DelGmquePet", buf2, sizeof( buf2) ) != NULL) {
int count = atoi( buf2);
if( GMQUE_DelQueStrPet( meindex, toindex, count) == FALSE ){
return FALSE;
}
}
if( NPC_Util_GetStrFromStrWithDelim( buf1, "GetGmPrize", buf2, sizeof( buf2) ) != NULL) {
if( GMQUE_AddQueStrTrophy( meindex, toindex) == FALSE ){
return FALSE;
}
}
if( NPC_Util_GetStrFromStrWithDelim( buf1, "CleanGmque", buf2, sizeof( buf2) ) != NULL) {
if( strstr( buf2, "TRUE") != 0 )
GMQUE_cleanQueStr( toindex);
}
#endif
#ifdef _NEW_PLAYERGOLD
if( NPC_Util_GetStrFromStrWithDelim( buf1, "CHECKNEWPLAYER", buf2, sizeof( buf2) ) != NULL) {
if( strstr( buf2, "TRUE") != 0 ){
char *CdKey;
char *UserName;
CdKey = CHAR_getChar( toindex, CHAR_CDKEY);
UserName = CHAR_getChar( toindex, CHAR_NAME);
saacproto_ACNEWPlayerList_send( acfd, CdKey, UserName, toindex, 1);
}
}
#endif
if(NPC_Util_GetStrFromStrWithDelim( buf1, "GetRandItem", buf2, sizeof( buf2) ) != NULL ){
int j=1, rand_cnt=1;
char buf3[256];
while( getStringFromIndexWithDelim( buf2 , "," , j, buf3, sizeof( buf3)) != FALSE ){
j++;
rand_cnt++;
}
NPC_ActionTreasureRandItemGet( meindex, toindex, rand_cnt, buf2);
}
#ifdef _ACTION_BULLSCR
if( NPC_Util_GetStrFromStrWithDelim( buf1, "ABULLSCORE", buf2, sizeof( buf2) ) != NULL) {
if( strstr( buf2, "TRUE") != NULL ){
if( CHAR_getInt( toindex, CHAR_ABULLSTART) != 20 ){
CHAR_setInt( toindex, CHAR_ABULLSTART, 10);
CHAR_setInt( toindex, CHAR_ABULLSCORE, 0);
CHAR_setInt( toindex, CHAR_ABULLTIME, 0);
CHAR_setInt( toindex, CHAR_ABULLSTARTTIME, (int)time( NULL));
CHAR_talkToCli( toindex, -1, "你开始参予与此活动。", CHAR_COLORYELLOW);
}else {
return FALSE;
}
}else {
CHAR_setInt( toindex, CHAR_ABULLSTART, 20);
CHAR_setInt( toindex, CHAR_ABULLSCORE, 0);
CHAR_setInt( toindex, CHAR_ABULLTIME, 0);
CHAR_setInt( toindex, CHAR_ABULLSTARTTIME, 0);
}
}
if( NPC_Util_GetStrFromStrWithDelim( buf1, "CHECKSCORE", buf2, sizeof( buf2) ) != NULL) {
if( strstr( buf2, "TRUE") != 0 ){
if( CHAR_getInt( toindex, CHAR_ABULLSTART) != 20 &&
CHAR_getInt( toindex, CHAR_ABULLSTART) == 10 ){
int jointime, joindata, joinhr, ntime;
ntime = CHAR_getInt( toindex, CHAR_ABULLTIME);
jointime = CHAR_getInt( toindex, CHAR_ABULLSTARTTIME);
jointime = (int)time( NULL) - jointime;
joindata = jointime/(24*60*60);
joinhr = (jointime%(24*60*60))/(60*60);
if( ntime < 0 ) ntime = 0;
sprintf( buf1, "战斗时间已累积%d分%d秒,活动累积积分:%d, 参与%d天%d小时。",
ntime/60, ntime%60, CHAR_getInt( toindex, CHAR_ABULLSCORE),
joindata, joinhr);
CHAR_talkToCli( toindex, -1, buf1, CHAR_COLORYELLOW);
}
}
}
#endif
#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能
//andy_add 2003/07/17
if( NPC_Util_GetStrFromStrWithDelim( buf1, "AddPFSkillPoint", buf2, sizeof( buf2) ) != NULL) {
if( NPC_ActionAddProfessionSkillPoint( toindex, buf2 ) == FALSE ){
return FALSE;
}
}
//andy_add 2003/07/17
if( NPC_Util_GetStrFromStrWithDelim( buf1, "CleanProfession", buf2, sizeof( buf2) ) != NULL) {
if( NPC_ActionCleanProfession( toindex, buf2 ) == FALSE ){
sprintf( buf2, "处理职业参数失败!!" );
CHAR_talkToCli( toindex, -1, buf2, CHAR_COLORYELLOW);
return FALSE;
}
}
if( NPC_Util_GetStrFromStrWithDelim( buf1, "PROFESSION", buf2, sizeof( buf2) ) != NULL) {
int p_class = atoi(buf2);
// 判断职业
if( CHAR_getInt( toindex, PROFESSION_CLASS ) != PROFESSION_CLASS_NONE && (p_class != 0) ){
sprintf( buf2, "你已经有职业了!!" );
CHAR_talkToCli( toindex, -1, buf2, CHAR_COLORYELLOW);
return FALSE;
}
if( p_class > PROFESSION_CLASS_NONE && p_class < PROFESSION_CLASS_NUM ) // 1:战士 2:巫师 3:猎人
{
int i, value = 0;
int skill_id = -1;
// 还原点数
if( PROFESSION_RESTORE_POINT( toindex ) != 1 ) return FALSE;
// 设定职业
CHAR_setInt( toindex, PROFESSION_CLASS, p_class );
#ifdef _CHANNEL_MODIFY
if(CHAR_getInt(toindex,PROFESSION_CLASS) > 0){
int i,pclass = CHAR_getInt(toindex,PROFESSION_CLASS) - 1;
for(i=0;i<getFdnum();i++){
if(*(piOccChannelMember + (pclass * getFdnum()) + i) == -1){
*(piOccChannelMember + (pclass * getFdnum()) + i) = toindex;
break;
}
}
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -