📄 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"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 500static 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 10BOOL 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)#ifdef _VIP_SHOP if( NPC_Util_GetStrFromStrWithDelim( buf1, "VipItem", buf2, sizeof( buf2) ) == NULL) if(NPC_Util_GetStrFromStrWithDelim( buf1, "VipPet", buf2, sizeof( buf2) ) == NULL)#endif return FALSE; if( NPC_ActionPassCheck( meindex, toindex, buf2) == FALSE ) {#ifdef _VIP_SHOP if( NPC_Util_GetStrFromStrWithDelim( buf1, "VipItem", buf2, sizeof( buf2) ) == NULL) if( NPC_Util_GetStrFromStrWithDelim( buf1, "VipPet", buf2, sizeof( buf2) ) == NULL)#endif { 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)#ifdef _VIP_SHOP if( NPC_Util_GetStrFromStrWithDelim( buf1, "VipItem", buf2, sizeof( buf2) ) == NULL) if( NPC_Util_GetStrFromStrWithDelim( buf1, "VipPet", buf2, sizeof( buf2) ) == NULL)#endif return FALSE; if( NPC_ActionPassCheck( meindex, toindex, buf2) == FALSE ) {#ifdef _VIP_SHOP if( NPC_Util_GetStrFromStrWithDelim( buf1, "VipItem", buf2, sizeof( buf2) ) == NULL) if( NPC_Util_GetStrFromStrWithDelim( buf1, "VipPet", buf2, sizeof( buf2) ) == NULL)#endif { CHAR_talkToCli( toindex, meindex, "条件不足!", CHAR_COLORYELLOW); return FALSE; } } return Action_RunDoEventAction( meindex, toindex, buf1);}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] == '\n' ) { 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; }#ifdef _DP_NPC if( NPC_Util_GetStrFromStrWithDelim( buf1, "DelDP", buf2, sizeof( buf2)) != NULL ) { if( NPC_ActionDP( toindex, buf2) == FALSE ) return FALSE; }#endif 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; }#ifdef _VIP_SHOP if( NPC_Util_GetStrFromStrWithDelim( buf1, "VipItem", buf2, sizeof( buf2)) != NULL ) { if( NPC_ActionVipItem( toindex, buf2) == FALSE ) return FALSE; } if( NPC_Util_GetStrFromStrWithDelim( buf1, "VipPet", buf2, sizeof( buf2)) != NULL ) { if( NPC_ActionVipPet( toindex, buf2) == FALSE ) return FALSE; }#endif #ifdef _TRANS_7_NPC if( NPC_Util_GetStrFromStrWithDelim( buf1, "TRANS7", buf2, sizeof( buf2)) != NULL ) { if( NPC_ActionTrans7( toindex, buf2) == FALSE ) return FALSE; }#endif 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 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 _TREASURE_BOX if( NPC_Util_GetStrFromStrWithDelim( buf1, "TREASURE_EVENT", buf2, sizeof( buf2) ) != NULL) { if( strstr( buf2, "OPEN") != NULL){ if( NPC_Util_GetStrFromStrWithDelim( buf1, "TREASURE_TIME", buf2, sizeof( buf2) ) == NULL) return FALSE; //NPC_TIME_EVENTMODE = CHAR_NPCWORKINT6,// 1 //NPC_TIME_EVENTTIME = CHAR_NPCWORKINT7, CHAR_setWorkInt( meindex, CHAR_NPCWORKINT6, NPC_EVENTMODE_OPEN ); CHAR_setWorkInt( meindex, CHAR_NPCWORKINT7, NowTime.tv_sec+atoi( buf2) ); //变图 //NPC_TIME_EVENONBBI = CHAR_NPCWORKINT8, CHAR_setInt( meindex, CHAR_BASEBASEIMAGENUMBER, CHAR_getWorkInt( meindex, CHAR_NPCWORKINT8)); CHAR_setInt( meindex, CHAR_BASEIMAGENUMBER, CHAR_getWorkInt( meindex, CHAR_NPCWORKINT8)); CHAR_sendCToArroundCharacter( CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX ) ); } }#endif#ifdef _NPC_ADDWARPMAN1 if( NPC_Util_GetStrFromStrWithDelim( buf1, "PartyCount", buf2, sizeof( buf2) ) != NULL) { //取得组队人数 int partys=0; int leaderindex=-1; int flg=0; //0:等於 1:大於等於 2:小於等於 3:大於 4:小於 5:不等於 char Head[32],buf3[32]; leaderindex = toindex; if( CHAR_getWorkInt( toindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_NONE ){ partys = 0; }else if( CHAR_getWorkInt( toindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_CLIENT ){ leaderindex = CHAR_getWorkInt( toindex, CHAR_WORKPARTYINDEX1); if( CHAR_getWorkInt( leaderindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_LEADER ){ int i; for( i=0; i<5; i++) { int pindex = CHAR_getWorkInt( leaderindex, CHAR_WORKPARTYINDEX1+i); if( !CHAR_CHECKINDEX( pindex) ) partys++; } } } memset( Head, 0, sizeof( Head)); memset( buf3, 0, sizeof( buf3)); if( strstr( buf2, "=" ) != NULL ){ strcpy( Head, "="); flg = 0; if( strstr( buf2, ">") != NULL ){ strcat( Head, ">"); flg = 1; }else if( strstr( buf2, "<") != NULL ){ strcat( Head, "<"); flg = 2; }else if( strstr( buf2, "!") != NULL ) { strcat( Head, "!"); flg = 5; } }else if(strstr( buf2, "<") != NULL){ strcpy( Head, "<"); flg = 4; }else if(strstr( buf2, ">") != NULL){ strcpy( Head, ">"); flg = 3; } Head[ strlen( Head)+1] = 0; if( NPC_Util_GetStrFromStrWithDelim( buf2, Head, buf3, sizeof( buf3) ) != NULL) { if( flg == 0 ) if( atoi(buf3) != partys ) return FALSE; else if( flg == 1 ) if( atoi(buf3) < partys ) return FALSE; else if( flg == 2 ) if( atoi(buf3) > partys ) return FALSE; else if( flg == 3 ) if( atoi(buf3) <= partys ) return FALSE; else if( flg == 4 ) if( atoi(buf3) >= partys ) return FALSE; else if( flg == 5 ) if( atoi(buf3) == partys ) return FALSE; } }#endif ActionNpc_WarpPoint( meindex, toindex, buf1); return TRUE;}BOOL Action_PartyCheck( int meindex, int talker){ if(CHAR_getWorkInt(talker,CHAR_WORKPARTYMODE) != CHAR_PARTY_NONE){ return FALSE; } return TRUE;}BOOL NPC_ActionAddGold( int talker, int Golds){ CHAR_AddGold( talker, Golds); return TRUE;}BOOL NPC_ActionDelGold( int talker,char *buf){ int Golds=0; int PGold=0; if( buf == NULL ) return FALSE; Golds = atoi( buf); PGold = CHAR_getInt( talker, CHAR_GOLD); if( PGold < Golds ) { CHAR_talkToCli( talker, -1, "你身上的钱不够喔!", CHAR_COLORYELLOW); return FALSE; }else { char buf1[256]; sprintf( buf1, "交出%d石币", Golds); CHAR_talkToCli( talker, -1, buf1, CHAR_COLORYELLOW); } CHAR_setInt( talker, CHAR_GOLD, PGold-Golds); CHAR_send_P_StatusString( talker , CHAR_P_STRING_GOLD); return TRUE;}#ifdef _DP_NPCBOOL NPC_ActionDP( int talker,char *buf){ int DPs=0; int PDP=0; if( buf == NULL ) return FALSE; DPs = atoi( buf); PDP = CHAR_getInt( talker, CHAR_DUELPOINT); if( PDP < DPs ) { CHAR_talkToCli( talker, -1, "你的DP不够哦!", CHAR_COLORYELLOW); return FALSE; }else { char buf1[256]; sprintf( buf1, "扣除DP%d", DPs); CHAR_talkToCli( talker, -1, buf1, CHAR_COLORYELLOW); } CHAR_setInt( talker, CHAR_DUELPOINT, PDP-DPs); CHAR_send_P_StatusString( talker ,CHAR_P_STRING_DUELPOINT ); return TRUE;}#endif// WON ADDBOOL NPC_ActionAddGold2( int talker,char *buf){ int Golds=0; int PGold=0; int MaxGold = 0; int total_gold = 0; if( buf == NULL ) return FALSE; Golds = atoi( buf); PGold = CHAR_getInt( talker, CHAR_GOLD); MaxGold = CHAR_getMaxHaveGold( talker ); total_gold = PGold + Golds; if( total_gold > MaxGold ) total_gold = MaxGold; CHAR_setInt( talker, CHAR_GOLD, total_gold ); CHAR_send_P_StatusString( talker , CHAR_P_STRING_GOLD); return TRUE;}BOOL NPC_ActionDelPet( int talker, char *buf){ int petsel; int petindex=0, k=1; int fd = getfdFromCharaIndex( talker ); char msgbuf[64], szPet[128],buff2[256],buff3[256]; char buf2[256],buff1[256]; int defpet; int petno,kNum,find=0,petLv=0,flg=-1; while( getStringFromIndexWithDelim(buf , "," , k, buff1, sizeof( buff1)) !=FALSE ) { k++; if( strstr( buff1,"-") != NULL ) { getStringFromIndexWithDelim(buff1,"-",2,buff3,sizeof(buff3)); getStringFromIndexWithDelim(buff1,"-",1,buf2,sizeof(buf2)); if( strstr( buf2,"!") != NULL ) { flg = 0; getStringFromIndexWithDelim(buf2,"!=",2,buff2,sizeof(buff2)); }else if( strstr( buf,"<") != NULL ) { flg = 1; getStringFromIndexWithDelim(buf2,"<",2,buff2,sizeof(buff2)); }else if( strstr( buf,">") != NULL ) { flg = 2; getStringFromIndexWithDelim(buf2,">",2,buff2,sizeof(buff2)); }else if( strstr( buf,"=") != NULL) { flg = 3; getStringFromIndexWithDelim(buf2,"=",2,buff2,sizeof(buff2)); }else return FALSE; petLv = atoi( buff2); } continue; if(strstr(buff3,"*")!=NULL){ getStringFromIndexWithDelim(buff3,"*",1,buf2,sizeof(buf2)); petno = atoi(buf2); getStringFromIndexWithDelim(buff3,"*",2,buf2,sizeof(buf2));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -