#include "version.h" #ifdef _NPC_WELFARE_2 // WON ADD 职业NPC-2 #ifdef _PROFESSION_SKILL // WON ADD 人物职业技能 #include #include "char.h" #include "object.h" #include "char_base.h" #include "npcutil.h" #include "lssproto_serv.h" #include "pet_skill.h" #include "readmap.h" #include "battle.h" #include "profession_skill.h" #include "chatmagic.h" #include "npc_welfare2.h" static void NPC_Welfare_selectWindow2(int meindex, int toindex, int num, int select); //载入好康NPC的初始化 BOOL NPC_WelfareInit2( int meindex ) { CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPEWELFARE); print("名称:%s\n",CHAR_getChar( meindex, CHAR_NAME)); return TRUE; } //对话时的处理 void NPC_WelfareTalked2( int meindex , int talkerindex , char *szMes ,int color ) { if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ) { return; } if(NPC_Util_isFaceToFace(talkerindex,meindex,2 )==FALSE){ if( NPC_Util_CharDistance( talkerindex, meindex ) > 1) return; } NPC_Welfare_selectWindow2( meindex, talkerindex,0,-1); } static void NPC_Welfare_selectWindow2( int meindex, int toindex, int num,int select) { switch(num){ case 0: //free NPC_WelfareMakeStr2(meindex, toindex, select); break; case 1: break; } } void NPC_WelfareWindowTalked2( int meindex, int talkerindex, int seqno, int select, char *data) { int skill, i, j; int skillID = -1, skillid = -1; int ENDEV = -1, NOWEV = -1; char buf[64]; char argstr[NPC_UTIL_GETARGSTR_BUFSIZE]; char msg[512]; int fd = getfdFromCharaIndex( talkerindex ); double rate= 1.0; int skillarray; CHAR_HaveSkill* hskill; char err_msg[128] = {0}; if( NPC_Util_CharDistance( talkerindex, meindex ) > 2) { return; } if(NPC_Util_GetArgStr( meindex, argstr, sizeof(argstr))==NULL){ print("GetArgStrErr"); return; } if( NPC_Util_GetStrFromStrWithDelim( argstr, "ENDEV:", msg, sizeof( msg)) != NULL){ ENDEV=atof(msg); } if( NPC_Util_GetStrFromStrWithDelim( argstr, "NOWEV:", msg, sizeof( msg)) != NULL){ NOWEV=atof(msg); } if( NPC_Util_GetStrFromStrWithDelim( argstr, "err_msg:", err_msg, sizeof( msg)) == NULL){ print("GetArgStrErr"); return; } if( ENDEV > 0 ){ if( NPC_EventCheckFlg( talkerindex, ENDEV ) != TRUE ){ CHAR_talkToCli( talkerindex, -1, err_msg, CHAR_COLORYELLOW); return; } }else if( NOWEV > 0 ){ if( NPC_EventCheckFlg( talkerindex, NOWEV ) != TRUE ){ CHAR_talkToCli( talkerindex, -1, err_msg, CHAR_COLORYELLOW); return; } } makeStringFromEscaped( data); getStringFromIndexWithDelim(data,"|",1,buf,sizeof(buf)); skill=atoi(buf); // 技能id skillid = CHAR_getCharSkill( talkerindex, skill - 1 ); skillID = skillid; if(skillID <= 0) return ; if( CHAR_getWorkInt( CONNECT_getCharaindex(fd), CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) return ; if( NPC_Util_GetStrFromStrWithDelim( argstr, "skill_rate", msg, sizeof( msg)) != NULL){ rate = atof( msg); } // 不扣钱 CHAR_send_P_StatusString( talkerindex, CHAR_P_STRING_GOLD); skillarray = PROFESSION_SKILL_getskillArray( skillID ); // 检查是否有不能删除的技能 for( i=0; i 0 && limit == skillID ){ char token[256] = {0}; sprintf( token, "需先遗忘%s,才可删除此技能", PROFESSION_SKILL_getChar( skillarray_temp, PROFESSION_SKILL_NAME ) ); CHAR_talkToCli( talkerindex, -1, token, CHAR_COLORYELLOW); return; } } } // 遗忘技能 { int skill_level = -1; int count = 0; int skill_id[CHAR_SKILLMAXHAVE] = {0}; int skill_temp[CHAR_SKILLMAXHAVE] = {0}; // 取熟练度 for( i=0; iskill, SKILL_LEVEL); skill_id[count] = skillid; skill_temp[count] = skill_level; count++; } // 删除所有技能 CHAR_CHAT_DEBUG_delsk( talkerindex, "all" ); // 还原技能 for( i=0; iskill, SKILL_LEVEL); sprintf(token2,"|%s|%d|%s|%d", PROFESSION_SKILL_getChar( skillarray, PROFESSION_SKILL_NAME ), // 技能名称 skill_level, // 熟练度 PROFESSION_SKILL_getChar( skillarray, PROFESSION_SKILL_TXT ), // 说明 PROFESSION_SKILL_getInt( skillarray, PROFESSION_SKILL_ICON ) // 图示 ); strcat(token,token2); } lssproto_WN_send( fd, WINDOW_MESSAGETYPE_PROFESSIONSHOP2, WINDOW_BUTTONTYPE_NONE, WINDOW_MESSAGETYPE_PROFESSIONSHOP, CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token); return; } #endif #endif