chuyiwen_gmsv/npc/npc_transmigration.c

1812 lines
49 KiB
C
Raw Normal View History

2016-12-24 08:45:52 +08:00
#include "version.h"
#include <string.h>
#include <math.h>
#include "char.h"
#include "object.h"
#include "char_base.h"
#include "npcutil.h"
#include "lssproto_serv.h"
#include "enemy.h"
#include "log.h"
#include "battle.h"
#include "readmap.h"
#include "npc_transmigration.h"
#ifdef _FUSIONBEIT_TRANS
#include "configfile.h"
#endif
#ifdef _PET_TRANS
#include "npc_pettransman.h"
#endif
static void NPC_Transmigration_selectWindow( int meindex, int toindex, int num);
static int NPC_TransmigrationCheck(int meindex, int talker);
BOOL NPC_TransmigrationAddPet(int meindex, int talker, int petid);
//<2F><><EFBFBD>Ѽ<EFBFBD><D1BC><EFBFBD><EFBFBD><EFBFBD>
int NPC_StartpointCheck(int meindex,int talker);
BOOL NPC_TransmigrationMain(int meindex, int toindex, char *buf);
int NPC_TransmigrationFlg_CLS(int meindex, int toindex);
BOOL NPC_TransmigrationDelPet(int meindex, int talker);
BOOL NPC_TransmigrationStatus(int meindex, int toindex,int *work);
BOOL NPC_TransmigratiomWarp(int meindex, int toindex, char *buf);
void s_eventsetend( int charaindex, int shiftbit );
#ifdef _PET_TRANS
int Pet_Select;
#endif
/*********************************
*********************************/
BOOL NPC_TransmigrationInit( int meindex )
{
/*--ƽ<>ҷ¼<D2B7><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ëɬ<C3AB><C9AC>--*/
CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_TYPETRANSMIGRATION );
return TRUE;
}
/*********************************
*********************************/
void NPC_TransmigrationTalked( int meindex , int talkerindex , char *szMes ,int color )
{
#ifdef _PET_TRANS
int i,petindex;
char buf[256];
#endif
if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER )
{
return;
}
if(NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) {
if(NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) return;
}
// print("savepoot=%d",CHAR_getInt( talkerindex, CHAR_SAVEPOINT));
// NPC_StartpointCheck( meindex, talkerindex);
//<2F><><EFBFBD>׷<EFBFBD><D7B7><EFBFBD><EFBFBD>ж<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>
#ifdef _PET_TRANS
for(i=0 ; i < CHAR_MAXPETHAVE ; i++) {
petindex = CHAR_getCharPet( talkerindex, i);
if( petindex == -1 )
continue;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ID <20>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>׷<EFBFBD><D7B7><EFBFBD> 1479 ID Ϊ718
if( CHAR_getInt( petindex, CHAR_PETID) == 718
#ifdef _PET_2TRANS
|| CHAR_getInt( petindex, CHAR_PETID) == 401
#endif
#ifdef _PET_3TRANS
|| CHAR_getInt( petindex, CHAR_PETID) == getMMPETID2()
#endif
) {
if( CHAR_getInt( petindex, CHAR_LV) > 79 ) {
//continue;
}else if( CHAR_getInt( petindex, CHAR_LV) == 79 ) {
if( strcmp( CHAR_getChar( petindex, CHAR_OWNERCDKEY), CHAR_getChar( talkerindex, CHAR_CDKEY) ) ||
strcmp( CHAR_getChar( petindex, CHAR_OWNERCHARANAME), CHAR_getChar( talkerindex, CHAR_NAME) )) {
sprintf( buf,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>׷<EFBFBD><EFBFBD>ţ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD><EFBFBD><EFBFBD>");
CHAR_talkToCli( talkerindex, -1, buf, CHAR_COLORWHITE);
return;
}
break;
}
}
}
if(i != CHAR_MAXPETHAVE) {
CHAR_setWorkInt(talkerindex,CHAR_WORKSHOPRELEVANT,1);
NPC_PetTransMan_selectWindow( meindex, talkerindex,0,-1);
}else {
#endif
CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT,1);
NPC_Transmigration_selectWindow( meindex, talkerindex, 0);
#ifdef _PET_TRANS
}
#endif
//ԭת<D4AD><D7AA>
//CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT,1);
//NPC_Transmigration_selectWindow( meindex, talkerindex, 0);
}
static void NPC_Transmigration_selectWindow( int meindex, int toindex, int num)
{
char token[1024];
char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE];
char buf[2048];
char buf2[512];
char tmp[512];
char s_tensei[64];
int buttontype = 0;
int windowtype = 0;
int windowno = 0;
int tenseiNo = 1;
int fd = getfdFromCharaIndex( toindex);
int i = 1;
BOOL tenflg = FALSE;
char *elder[4] = {"samugiru","marinasu","jaja","karutarna"};
int point;
int ten_no;
if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){
print("Tensei:GetArgStrErr");
return;
}
windowtype = WINDOW_MESSAGETYPE_MESSAGE;
tenseiNo = CHAR_getInt( toindex, CHAR_TRANSMIGRATION);
tenseiNo++;
if(CHAR_getWorkInt( toindex, CHAR_WORKSHOPRELEVANT) >= 2){
tenseiNo--;
}
sprintf(s_tensei,"TENSEI:%d",tenseiNo);
while(getStringFromIndexWithDelim( npcarg,"END",i,buf,sizeof( buf)) != FALSE){
i++;
if(strstr(buf,s_tensei) != NULL) {
tenflg = TRUE;
break;
}
}
//ttom
// print("\nTrans meindex=%d,toindex=%d,num=%d",meindex,toindex,num);
//ttom
CONNECT_set_state_trans(fd,6);
//ttom end
switch( num){
case 0:
//ttom
//CONNECT_set_state_trans(fd,0);
//ttom end
ten_no = NPC_TransmigrationCheck(meindex, toindex);
if(
#ifdef _TRANS_6
ten_no < 6
#else
ten_no < 5
#endif//_TRANS_6
&& ten_no >= 0){
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>
if(NPC_Util_GetStrFromStrWithDelim( buf,"startmsg", token,sizeof( token) ) == NULL)
{
print("startmsgErr");
return;
}
buttontype = WINDOW_BUTTONTYPE_NEXT;
//ttom
CONNECT_set_state_trans(fd,0);
//ttom end
}else if(
#ifdef _TRANS_6
ten_no == 6
#else
ten_no == 5
#endif//_TRANS_6
){
//<2F><>Ϸë<CFB7><C3AB><EFBFBD><EFBFBD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD>
if(NPC_Util_GetStrFromStrWithDelim( npcarg,"maxmsg", token,sizeof( token) ) == NULL)
{
print("maxmsgErr");
return;
}
buttontype = WINDOW_BUTTONTYPE_OK;
}else{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ƻ<EFBFBD>ئ<EFBFBD><D8A6>
if(NPC_Util_GetStrFromStrWithDelim( buf,"nonemsg", token,sizeof( token) ) == NULL)
{
print("nonemsgErr");
return;
}
buttontype = WINDOW_BUTTONTYPE_OK;
}
windowno = CHAR_WINDOWTYPE_TRANSMIGRATION_START;
break;
case 1:
if(NPC_Util_GetStrFromStrWithDelim( buf,"mainmsg", token,sizeof( token) ) == NULL)
{
print("mainmsgErr");
return;
}
buttontype = WINDOW_BUTTONTYPE_OKCANCEL;
windowno = CHAR_WINDOWTYPE_TRANSMIGRATION_MAIN;
break;
case 2:
// Robin 2001/03/05 Tensei Check
//if(!CHAR_getWorkInt(toindex,CHAR_TENSEICHECKED)) return;
point = NPC_StartpointCheck( meindex, toindex);
if(point == -1) {
return;
}
NPC_Util_GetStrFromStrWithDelim( npcarg,elder[point],buf2,sizeof( buf2));
if(NPC_TransmigrationMain(meindex, toindex, buf2) == FALSE)
{
return;
}
sprintf( tmp, "yesmsg%d",
CHAR_getWorkInt( toindex, CHAR_WORKSHOPRELEVANT));
if(NPC_Util_GetStrFromStrWithDelim( buf,tmp, token,sizeof( token) ) == NULL)
{
print("yesmsgErr");
return;
}
CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT,
CHAR_getWorkInt( toindex, CHAR_WORKSHOPRELEVANT) +1
);
sprintf( tmp, "yesmsg%d",
CHAR_getWorkInt( toindex, CHAR_WORKSHOPRELEVANT));
if(strstr(buf, tmp) == NULL) {
buttontype = WINDOW_BUTTONTYPE_OK;
windowno = CHAR_WINDOWTYPE_TRANSMIGRATION_END;
}else {
buttontype = WINDOW_BUTTONTYPE_NEXT;
windowno = CHAR_WINDOWTYPE_TRANSMIGRATION_END;
}
break;
case 3:
/*--ƽ<><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ë<EFBFBD>浤--*/
if(NPC_Util_GetStrFromStrWithDelim( buf,"nomsg", token,sizeof( token) ) == NULL)
{
print("nomsgErr");
return;
}
buttontype = WINDOW_BUTTONTYPE_OK;
windowno = CHAR_WINDOWTYPE_TRANSMIGRATION_NONE;
break;
case 4:
sprintf( tmp, "yesmsg%d",
CHAR_getWorkInt( toindex, CHAR_WORKSHOPRELEVANT));
if(NPC_Util_GetStrFromStrWithDelim( buf,tmp, token,sizeof( token) ) == NULL)
{
print("yesmsgErr");
return;
}
CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT,
CHAR_getWorkInt( toindex, CHAR_WORKSHOPRELEVANT) +1
);
sprintf( tmp, "yesmsg%d",
CHAR_getWorkInt( toindex, CHAR_WORKSHOPRELEVANT));
if(strstr(buf, tmp) == NULL)
{
buttontype = WINDOW_BUTTONTYPE_OK;
windowno = CHAR_WINDOWTYPE_TRANSMIGRATION_END;
}else{
buttontype = WINDOW_BUTTONTYPE_NEXT;
windowno = CHAR_WINDOWTYPE_TRANSMIGRATION_END;
}
break;
case 5:
// Robin 2001/03/05 Tensei Check
//if(!CHAR_getWorkInt(toindex,CHAR_TENSEICHECKED)) return;
point = NPC_StartpointCheck( meindex, toindex);
if(point == -1) return;
NPC_Util_GetStrFromStrWithDelim( npcarg,elder[point],buf2,sizeof( buf2));
NPC_TransmigratiomWarp(meindex, toindex, buf2);
// buttontype = WINDOW_BUTTONTYPE_OK;
// windowno = CHAR_WINDOWTYPE_TRANSMIGRATION_END;
return;
break;
}
// makeEscapeString( token, escapedname, sizeof(escapedname));
/*-<2D><><EFBFBD><EFBFBD>ƥ˪<C6A5><CBAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>--*/
lssproto_WN_send( fd, windowtype,
buttontype,
windowno,
CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX),
token);
}
/*-----------------------------------------
-------------------------------------------*/
void NPC_TransmigrationWindowTalked( int meindex, int talkerindex,
int seqno, int select, char *data)
{
int datanum = -1;
int fd = getfdFromCharaIndex( talkerindex);
if( NPC_Util_CharDistance( talkerindex, meindex ) > 2) {
return;
}
//ttom
//CONNECT_set_state_trans(fd,6);
//ttom end
datanum = atoi( data);
switch( seqno) {
case CHAR_WINDOWTYPE_TRANSMIGRATION_START:
if( select == WINDOW_BUTTONTYPE_NEXT) {
//ttom
if(CONNECT_get_state_trans(fd)==0){ } else return;
//ttom end
NPC_Transmigration_selectWindow( meindex, talkerindex,1);
//ttom
CONNECT_set_state_trans(fd,1);
//ttom end
}
break;
case CHAR_WINDOWTYPE_TRANSMIGRATION_MAIN:
if( select == WINDOW_BUTTONTYPE_OK) {
#ifdef _FIX_SUPERPERSON_STRANS
if( CHAR_getInt(talkerindex,CHAR_TRANSMIGRATION) == 5 && CHAR_getInt(talkerindex,CHAR_SUPER) > 0){
if(NPC_EventCheckFlg( talkerindex, 63) == FALSE
|| NPC_EventCheckFlg( talkerindex, 136) == FALSE
|| NPC_EventCheckFlg( talkerindex, 175) == FALSE
|| NPC_EventCheckFlg( talkerindex, 176) == FALSE){
print("\n<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
return;
}
}
#endif
//ttom
if(CONNECT_get_state_trans(fd)==1){ } else return;
//ttom end
NPC_Transmigration_selectWindow( meindex, talkerindex, 2);
//ttom
CONNECT_set_state_trans(fd,2);
//ttom end
}else if(select == WINDOW_BUTTONTYPE_CANCEL) {
NPC_Transmigration_selectWindow( meindex, talkerindex, 3);
}
break;
case CHAR_WINDOWTYPE_TRANSMIGRATION_END:
if( select == WINDOW_BUTTONTYPE_NEXT) {
//ttom
if(CONNECT_get_state_trans(fd)==2){ } else return;
//ttom end
NPC_Transmigration_selectWindow( meindex, talkerindex, 4);
//ttom
CONNECT_set_state_trans(fd,4);
//ttom end
}else if( select == WINDOW_BUTTONTYPE_OK) {
//ttom
if(CONNECT_get_state_trans(fd)==4){ } else return;
//ttom end
NPC_Transmigration_selectWindow( meindex, talkerindex, 5);
}
break;
//ANDY_ADD 10/19
#ifdef _PET_TRANS
case CHAR_WINDOWTYPE_PETTRANS_START: //<2F><>ʼ<EFBFBD>Ի<EFBFBD>
if( select == WINDOW_BUTTONTYPE_NEXT) {
NPC_PetTransMan_selectWindow( meindex, talkerindex, 1, 0);
}
break;
case CHAR_WINDOWTYPE_PETTRANS_SELECT: //<2F>Ƿ<EFBFBD><C7B7>ó<EFBFBD><C3B3><EFBFBD>ת<EFBFBD><D7AA>
if( select == WINDOW_BUTTONTYPE_YES) {
NPC_PetTransMan_selectWindow( meindex, talkerindex, 2, 0);
}else {
NPC_PetTransMan_selectWindow( meindex, talkerindex, 5, 0);
}
break;
case CHAR_WINDOWTYPE_PETTRANS_SELPET: //ѡ<><D1A1>
if(select==WINDOW_BUTTONTYPE_CANCEL) {
NPC_PetTransMan_selectWindow( meindex, talkerindex, 5,-1 );
}else {
Pet_Select = datanum;
NPC_PetTransMan_selectWindow( meindex, talkerindex, 3, datanum );
}
break;
case CHAR_WINDOWTYPE_PETTRANS_MAIN1: //ȷ<><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ȷ<><C8B7><><C8A1>
if(select==WINDOW_BUTTONTYPE_YES){
NPC_PetTransMan_selectWindow( meindex, talkerindex, 4, Pet_Select);
}else {
NPC_PetTransMan_selectWindow( meindex, talkerindex, 5, -1);
}
break;
case CHAR_WINDOWTYPE_PETTRANS_END: //<2F><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CHAR_setWorkInt( talkerindex, CHAR_WORKSHOPRELEVANT, 0);
break;
#endif
}
}
//************************************************************
//************************************************************
BOOL NPC_TransmigratiomWarp(int meindex, int toindex, char *buf)
{
char buf2[512];
char buf3[128];
char buf4[64];
int floor=0 , x = 0, y = 0;
int i = 1;
int ret;
while(getStringFromIndexWithDelim( buf,",",i,buf2,sizeof( buf2))
!= FALSE)
{
i++;
if(strstr(buf2,"Warp") != NULL)
{
getStringFromIndexWithDelim( buf2 ,"=" ,2, buf3 ,sizeof(buf3));
//<2F>׷<EFBFBD>ʧ
ret = getStringFromIndexWithDelim( buf3,".",1 ,buf4 ,sizeof( buf4));
if(ret ==FALSE) return FALSE;
floor = atoi(buf4);
ret = getStringFromIndexWithDelim( buf3,".",2 ,buf4 ,sizeof( buf4));
if(ret ==FALSE) return FALSE;
x = atoi(buf4);
ret = getStringFromIndexWithDelim( buf3,".",3 ,buf4 ,sizeof( buf4));
if(ret ==FALSE) return FALSE;
y = atoi(buf4);
}
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƽ<EFBFBD><C6BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if( MAP_IsValidCoordinate( floor, x, y )== FALSE ){
return FALSE;
}
//ttom
/*
{
int tenseiNo;
tenseiNo=CHAR_getInt( toindex, CHAR_TRANSMIGRATION);
CHAR_setInt( toindex,CHAR_SKILLUPPOINT,tenseiNo*10);
print("\n the set the skillpoint %d",tenseiNo*10);
CHAR_sendStatusString( toindex , "P");
}
*/
//ttom
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CHAR_warpToSpecificPoint(toindex, floor, x, y);
return TRUE;
}
//************************************************************
//
// <09>ߡ<EFBFBD><DFA1><EFBFBD>ة<EFBFBD>׻<EFBFBD>
// <09>ࡰѨ<E0A1B0><D1A8><EFBFBD>ϵ<EFBFBD>
// <09><EFBFBD><E1A1B0><EFBFBD>ҳ<EFBFBD><D2B3><EFBFBD>
// <09><EFBFBD>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// <09>Ԩࡰ<D4A8>޷¡<DEB7>
//************************************************************
int NPC_StartpointCheck(int meindex,int talker)
{
int point;
int shift = 0;
point = CHAR_getInt( talker, CHAR_SAVEPOINT);
for(shift = 0; shift < 4 ;shift++){
if( (point & ( 1<< shift)) == ( 1<< shift)) {
return shift;
}
}
return -1;
}
//********************************************************
//
//
//
//********************************************************
static int NPC_TransmigrationCheck(int meindex, int talker)
{
// <09><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>
//<2F><>ì<EFBFBD><EFBFBD><EFBBA5><EFBFBD>߶<EFBFBD><DFB6><EFBFBD>
//<2F><EFBFBD><E3B9B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ì<EFBFBD><C3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD>³<EFBFBD><C2B3><EFBFBD>
int i,j,k=0;
int ch_no[4] = {39,40,42,46};
int petindex;
int num;
// int petid[4] = {1, 2, 3, 4}; //ʸ<><CAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ë϶<C3AB><CFB6>
int petid[4] = {693, 694, 695, 696}; //ʸ<><CAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ë϶<C3AB><CFB6>
// int petidfinal[4] = {11, 12, 13, 14}; //ʸ<><CAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ë϶<C3AB><CFB6>
int petidfinal[4] = {693, 694, 695, 696}; //ʸ<><CAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ë϶<C3AB><CFB6>
// Robin 2001/03/05
//CHAR_setWorkInt(talker,CHAR_TENSEICHECKED,FALSE);
#ifdef _TRANS_6
if(CHAR_getInt( talker, CHAR_TRANSMIGRATION) >= 6){
return 6;
}
#else
if(CHAR_getInt( talker, CHAR_TRANSMIGRATION) >= 5){
return 5;
}
#endif
//<2F><>ì<EFBFBD><EFBFBD><EFBBA5><EFBFBD>߶<EFBFBD><DFB6><EFBFBD>
if(CHAR_getInt( talker, CHAR_LV) < 80) return -1;
//<2F><>ì<EFBFBD><C3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׷º<D7B7><C2BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#ifdef _TRANS_6
if(CHAR_getInt( talker, CHAR_TRANSMIGRATION) < 6){
#else
if(CHAR_getInt( talker, CHAR_TRANSMIGRATION) < 5){
#endif
for(i = 0; i < 4 ;i++)
if(NPC_EventCheckFlg( talker, ch_no[i] ) == FALSE) return -1;
}
num = CHAR_getInt(talker, CHAR_TRANSMIGRATION);
if(num < 4 ){
//϶<><CFB6>ʸ<EFBFBD><CAB8><EFBFBD><EFBFBD>ë<EFBFBD><C3AB><EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD>¾<EFBFBD>ʸ<EFBFBD><CAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for(i=0 ; i < CHAR_MAXPETHAVE ; i++){
petindex = CHAR_getCharPet( talker, i);
if( petindex == -1 ) continue;
//ttom
//print("petid=%d ",CHAR_getInt( petindex, CHAR_PETID));
if(CHAR_getInt( petindex, CHAR_PETID) != petid[num]) continue;
// if(CHAR_getInt( petindex, CHAR_LV) < PETLEVEL) continue;
break;
}
if(i == CHAR_MAXPETHAVE) return -1;
}else
#ifdef _TRANS_6
if( num == 4 )
#endif
{
for(j = 0; j < 4 ;j++){
for(i=0 ; i < CHAR_MAXPETHAVE ; i++){
petindex = CHAR_getCharPet( talker, i);
if( petindex == -1 ) continue;
// print("petid=%d ",CHAR_getInt( petindex, CHAR_PETID));
if(CHAR_getInt( petindex, CHAR_PETID) != petidfinal[j]) continue;
k++;
break;
}
}
if(k < 4) return -1;
}
#ifdef _TRANS_6
else{
/*int lasttalkelder = 2;//<2F><><EFBFBD><EFBFBD>
if( CHAR_getInt( talker, CHAR_LASTTALKELDER) == 1 )//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿
lasttalkelder = 112;//<2F><><EFBFBD><EFBFBD>
else if( CHAR_getInt( talker, CHAR_LASTTALKELDER) == 2 )//<2F>Ӽ<EFBFBD>
lasttalkelder = 102;//<2F>˿˶<CBBF>
else if( CHAR_getInt( talker, CHAR_LASTTALKELDER) == 3 )//<2F><>³<EFBFBD><C2B3><EFBFBD><EFBFBD>
lasttalkelder = 34;//<2F><><EFBFBD><EFBFBD>
print("\npetid:%d",lasttalkelder);*/
//<2F>ҿ<EFBFBD><D2BF><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>д<EFBFBD><32><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for(i=0 ; i < CHAR_MAXPETHAVE ; i++){
petindex = CHAR_getCharPet( talker, i);
if( petindex == -1 ) continue;
if( CHAR_getInt( petindex, CHAR_TRANSMIGRATION) == 2
&& ( CHAR_getInt( petindex, CHAR_PETID) == 2
|| CHAR_getInt( petindex, CHAR_PETID) == 112
|| CHAR_getInt( petindex, CHAR_PETID) == 102
|| CHAR_getInt( petindex, CHAR_PETID) == 34 ) ) break;
//if(CHAR_getInt( petindex, CHAR_TRANSMIGRATION) != 2 || CHAR_getInt( petindex, CHAR_PETID) != lasttalkelder ) continue;
}
if(i == CHAR_MAXPETHAVE){
CHAR_talkToCli( talker,-1,"<EFBFBD><EFBFBD>û<EFBFBD>д<EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŷ!",CHAR_COLORWHITE);
return -1;
}
if(NPC_EventCheckFlg( talker, 63) == FALSE){ print("\nerr63");return -1;}
if(NPC_EventCheckFlg( talker, 136) == FALSE){ print("\nerr136");return -1;}
if(NPC_EventCheckFlg( talker, 175) == FALSE){ print("\nerr175");return -1;}
if(NPC_EventCheckFlg( talker, 176) == FALSE){ print("\nerr176");return -1;}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>15<31><35>ħ<EFBFBD><C4A7>֮<EFBFBD><D6AE><EFBFBD><EFBFBD>Ƭ
j=0;
for( i=0 ; i<CHAR_MAXITEMHAVE ; i++ ){
int itemindex;
itemindex = CHAR_getItemIndex(talker,i);
if( ITEM_CHECKINDEX(itemindex) == FALSE )continue;
if( ITEM_getInt( itemindex, ITEM_ID ) == 20613 ) {
++j;
}
}
if( j < 15 ){
CHAR_talkToCli( talker,-1,"<EFBFBD><EFBFBD>û<EFBFBD>д<EFBFBD>15<EFBFBD><EFBFBD>ħ<EFBFBD><EFBFBD>֮<EFBFBD>ŵ<EFBFBD><EFBFBD><EFBFBD>ƬŶ!",CHAR_COLORWHITE);
print("\nitem:%d",j);
return -1;
}
#ifdef _NO_TRANS_ANGLE
if(getTrans6Angle()==0){
#endif
if( CHAR_getInt(talker, CHAR_HEROCNT) <= 0 ){
CHAR_talkToCli( talker,-1,"<EFBFBD><EFBFBD>û<EFBFBD><EFBFBD>ִ<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!",CHAR_COLORWHITE);
return -1;
}
#ifdef _NO_TRANS_ANGLE
}
#endif
}
#endif
// Robin 2001/03/05
//CHAR_setWorkInt(talker,CHAR_TENSEICHECKED,TRUE);
return CHAR_getInt(talker, CHAR_TRANSMIGRATION);
}
BOOL NPC_TransmigrationMain(int meindex, int toindex, char *buf)
{
int i = 1;
char buf2[128];
char buf3[64];
char buf4[32];
int item = 10;
int pet = 5;
int present = 0;
int ten_no;
int work[10];
int fd = getfdFromCharaIndex( toindex );
#ifdef _ADD_POOL_ITEM // WON ADD <20><><EFBFBD>ӿɼķŵĵ<C5B5><C4B5><EFBFBD>
int tran_pool_item[5] = { 4, 4, 4, 4, 4 }; // <20><><EFBFBD>ӵĵ<D3B5><C4B5>߼ķ<DFBC><C4B7><EFBFBD>
int tran_pool_pet[5] = { 2, 2, 2, 2, 2}; // <20><><EFBFBD>ӵij<D3B5><C4B3><EFBFBD><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>
int j,item_sum=0, pet_sum=0;
for(j=0; j<5 ;j++){
item_sum += tran_pool_item[j] ;
pet_sum += tran_pool_pet[j];
}
item_sum += 10; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļĵ<C4BC><C4B5><EFBFBD><EFBFBD><EFBFBD>
pet_sum += 5; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļij<C4BC><C4B3><EFBFBD>
#endif
while(getStringFromIndexWithDelim( buf,",",i,buf2,sizeof( buf2))!= FALSE){
i++;
if(strstr(buf2,"Item") != NULL){
getStringFromIndexWithDelim( buf2 ,"=" ,2, buf3 ,sizeof(buf3));
item = atoi(buf3);
}else if(strstr(buf2,"Pet") != NULL){
getStringFromIndexWithDelim( buf2 ,"=" ,2, buf3 ,sizeof(buf3));
pet = atoi(buf3);
}else if(strstr(buf2,"Present") != NULL){
ten_no = CHAR_getInt(toindex,CHAR_TRANSMIGRATION);
ten_no++;
getStringFromIndexWithDelim( buf2 ,"=" ,2, buf3 ,sizeof(buf3));
getStringFromIndexWithDelim( buf3,".",ten_no ,buf4 ,sizeof( buf4));
present = atoi(buf4);
}
}
CHAR_setInt(toindex ,CHAR_TRANSMIGRATION,
CHAR_getInt(toindex,CHAR_TRANSMIGRATION) + 1);
#ifdef _TRANS_6
if(CHAR_getInt( toindex, CHAR_TRANSMIGRATION) > 6)
CHAR_setInt(toindex ,CHAR_TRANSMIGRATION,6);
if( CHAR_getInt(toindex,CHAR_TRANSMIGRATION) == 6 )//6ת<36><D7AA><EFBFBD><EFBFBD><EFBFBD>͵ij<CDB5>
present = 2546;
#else
if(CHAR_getInt( toindex, CHAR_TRANSMIGRATION) > 5)
CHAR_setInt(toindex ,CHAR_TRANSMIGRATION,5);
#endif
NPC_TransmigrationStatus(meindex, toindex, work);
NPC_TransmigrationFlg_CLS(meindex, toindex);
CHAR_setInt(toindex, CHAR_LV ,1);
CHAR_setMaxExp( toindex, 0);
#ifdef _TRANS_6
//ɾ<><C9BE>ħ<EFBFBD><C4A7>֮<EFBFBD><D6AE><EFBFBD><EFBFBD>Ƭ
for( i=0 ; i<CHAR_MAXITEMHAVE ; i++ ){
int itemindex;
itemindex = CHAR_getItemIndex(toindex,i);
if( ITEM_CHECKINDEX(itemindex) == FALSE )continue;
if( ITEM_getInt( itemindex, ITEM_ID ) == 20613 ) {
CHAR_DelItem( toindex, i);
}
}
#endif
if(NPC_TransmigrationDelPet(meindex, toindex) == FALSE) return FALSE;
if( NPC_TransmigrationAddPet( meindex, toindex, present)== FALSE) return FALSE;
// Robin 0718
{
int tenseiNo;
tenseiNo=CHAR_getInt( toindex, CHAR_TRANSMIGRATION);
CHAR_setInt( toindex,CHAR_SKILLUPPOINT,tenseiNo*10);
CHAR_Skillupsend( toindex );
//CHAR_setInt( toindex,CHAR_LEARNRIDE, 0);
CHAR_setInt( toindex,CHAR_RIDEPET, -1 );
CHAR_setInt( toindex , CHAR_BASEIMAGENUMBER , CHAR_getInt( toindex , CHAR_BASEBASEIMAGENUMBER) );
//CHAR_sendStatusString( toindex , "P");
}
lssproto_WO_send(fd ,0 );
// <20><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>ë<EFBFBD><C3AB><EFBFBD><EFBFBD>
LogTensei(
CHAR_getChar( toindex, CHAR_NAME ), /* ƽ<>ҷ<EFBFBD> */
CHAR_getChar( toindex, CHAR_CDKEY),
"Tensei",
work[0],
CHAR_getInt(toindex,CHAR_TRANSMIGRATION),
work[1],
NPC_StartpointCheck( meindex, toindex),
item, pet,
work[2],work[3],work[4],work[5],
work[6],work[7],work[8],work[9]
);
//<2F><>ޥ
CHAR_complianceParameter( toindex );
//HPë<50><C3AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؤ<EFBFBD><D8A4><EFBFBD><EFBFBD>
CHAR_setInt(toindex, CHAR_HP, CHAR_getWorkInt(toindex, CHAR_WORKMAXHP) );
CHAR_setInt(toindex,CHAR_LASTTALKELDER, NPC_StartpointCheck(meindex,toindex));
CHAR_sendStatusString( toindex, "P" );
/*
CHAR_send_P_StatusString( toindex,
CHAR_P_STRING_LV|CHAR_P_STRING_EXP|
CHAR_P_STRING_NEXTEXP|
CHAR_P_STRING_HP|CHAR_P_STRING_MAXHP|
CHAR_P_STRING_MP|CHAR_P_STRING_MAXMP|
CHAR_P_STRING_ATK|CHAR_P_STRING_DEF|
CHAR_P_STRING_QUICK|CHAR_P_STRING_CHARM|
CHAR_P_STRING_LUCK|CHAR_P_STRING_EARTH|
CHAR_P_STRING_WATER|CHAR_P_STRING_FIRE|
CHAR_P_STRING_WIND|CHAR_P_STRING_VITAL|
CHAR_P_STRING_STR|CHAR_P_STRING_DEX|
CHAR_P_STRING_TOUGH|
CHAR_P_STRING_DUELPOINT //ttom
);
*/
return TRUE;
}
static int questTbl[20] = {
1,2,4,5,8,12,14,15,16,17,19,22,27,30,31,34,35,38,45,47
};
//*******************************************************
//<2F>;޵<CDBE><DEB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ë<EFBFBD><C3AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//*******************************************************
int NPC_TransmigrationQuestCheck(int toindex)
{
int i;
int num = 0;
for(i = 0 ; i < 20; i++){
if(NPC_EventCheckFlg(toindex ,questTbl[i]) == TRUE){
num++;
}
}
return num;
}
//*******************************************************
//*******************************************************
int NPC_TransCalculation(int toindex, int para)
{
float quest, level, num, tmp;
float ans;
int equ;
equ = CHAR_getInt(toindex, CHAR_TRANSEQUATION);
quest = (float)(( equ >> 16 ) & 0xFFFF);
level = (float)(( equ >> 0 ) & 0xFFFF);
//tttom
//print("\n this test equ=%d,quest=%f,level=%f",equ,quest,level);
//<2F><>Ϸ<EFBFBD><CFB7><EFBFBD><EFBFBD>
num = CHAR_getInt(toindex, CHAR_TRANSMIGRATION); // ǰ<><C7B0><EFBFBD>Ѽ<EFBFBD>1,<2C><>0ת1ʱΪ1
tmp = (float)para / 100;
#ifdef _TRANS_6
if (num == 6) tmp = 620; // <20><>ת<EFBFBD><D7AA>ʱ<EFBFBD>ɵ<EFBFBD><C9B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#endif
ans =(float)tmp/12 + (float)(quest / 4) +( (float)(level- num * 85) /4);
return (int)ans;
}
//*******************************************************
//*******************************************************
float Rounding(float work,int num)
{
float p;
if(num <0 ) return work;
num--;
p = (float)pow(10,num);
return ( (work * p + 0.5) /p);
}
//*******************************************************
//
//
//*******************************************************
BOOL NPC_TransmigrationStatus(int meindex, int toindex,int work[10])
{
int vital, str, tgh, dex;
int quest , level ,equ;
int t_quest, t_level;
int total,ans;
float tmp,lvup;
vital = CHAR_getInt(toindex,CHAR_VITAL);
str = CHAR_getInt(toindex,CHAR_STR);
tgh = CHAR_getInt(toindex,CHAR_TOUGH);
dex = CHAR_getInt(toindex,CHAR_DEX);
//<2F>;޵<CDBE><DEB5><EFBFBD><EFBFBD>׷º<D7B7>ë<EFBFBD><C3AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
quest = NPC_TransmigrationQuestCheck( toindex);
//<2F><>ì<EFBFBD><C3AC>
level = CHAR_getInt(toindex,CHAR_LV);
work[0] = level;
work[1] = quest;
equ = CHAR_getInt(toindex, CHAR_TRANSEQUATION);
t_quest = (float)(( equ >> 16 ) & 0xFFFF);
t_level = (float)(( equ >> 0 ) & 0xFFFF);
if( level > 130 ) level = 130;
t_quest = t_quest + quest;
t_level = t_level + level;
CHAR_setInt(toindex, CHAR_TRANSEQUATION,
( t_quest << 16 )+( t_level << 0 )
);
total = vital + str + tgh + dex;
ans = NPC_TransCalculation(toindex, total);
work[2] = vital;
tmp = (float)vital/total * ans;
work[3] = Rounding(tmp,1) * 100;
work[4] = str;
tmp = (float)str/total * ans;
work[5] = Rounding(tmp,1) * 100;
work[6] = tgh;
tmp = (float)tgh/total * ans;
work[7] = Rounding(tmp,1) * 100;
work[8] = dex;
tmp = (float)dex/total * ans;
work[9] = Rounding(tmp,1) * 100;
//vital<61><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if(work[3] < 0) work[3] = 0;
CHAR_setInt(toindex, CHAR_VITAL, work[3]);
//str<74><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if(work[5] < 0) work[5] = 0;
CHAR_setInt(toindex, CHAR_STR, work[5]);
//tghr<68><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if(work[7] < 0) work[7] = 0;
CHAR_setInt(toindex, CHAR_TOUGH, work[7]);
//dex<65><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if(work[9] < 0) work[9] = 0;
CHAR_setInt(toindex, CHAR_DEX, work[9]);
lvup = CHAR_getInt(toindex, CHAR_SKILLUPPOINT );
/*#ifdef _TRANS_6
if( CHAR_getInt(toindex, CHAR_TRANSMIGRATION) == 6)
lvup = 620;
#endif*/
lvup = lvup / 12;
lvup = Rounding(lvup, 1);
if(lvup < 0) lvup = 0;
CHAR_setInt(toindex, CHAR_SKILLUPPOINT, (int)lvup);
/* <20><>ƽ<EFBFBD><C6BD>ʧ<EFBFBD><CAA7><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD><EFBFBD>ճ<EFBFBD>ľë˪<C3AB><CBAA> */
if( CHAR_getInt( toindex,CHAR_SKILLUPPOINT ) >=1 )
CHAR_Skillupsend(toindex);
return TRUE;
}
/*----------------------------
* ʸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ëܰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
------------------------------*/
BOOL NPC_TransmigrationAddPet(int meindex, int talker, int petid)
{
int ret;
char msgbuf[64];
int enemynum;
int i,j;
int petindex;
int petindex2;
for( i = 0 ;i < CHAR_MAXPETHAVE ; i++) {
petindex = CHAR_getCharPet( talker, i);
if( petindex == -1 ) break;
}
if(i == CHAR_MAXPETHAVE) return FALSE;
enemynum = ENEMY_getEnemyNum();
for( i = 0; i < enemynum; i ++ ) {
if( ENEMY_getInt( i, ENEMY_ID) == petid) {
break;
}
}
if( i == enemynum ) return FALSE;
ret = ENEMY_createPetFromEnemyIndex( talker, i);
for( i = 0; i < CHAR_MAXPETHAVE; i ++ ){
if( CHAR_getCharPet( talker, i ) == ret )break;
}
if( i == CHAR_MAXPETHAVE ) i = 0;
if( CHAR_CHECKINDEX( ret ) == TRUE ){
CHAR_setMaxExpFromLevel( ret, CHAR_getInt( ret, CHAR_LV ));
}
petindex2 = CHAR_getCharPet(talker, i);
if( !CHAR_CHECKINDEX( petindex2) ) return FALSE;
snprintf( msgbuf,sizeof( msgbuf), "<EFBFBD>õ<EFBFBD>%s<><73>",
CHAR_getChar(petindex2,CHAR_NAME));
CHAR_talkToCli( talker, -1, msgbuf, CHAR_COLORWHITE);
for(j = 0; j < CHAR_MAXPETHAVE; j++){
petindex = CHAR_getCharPet(talker, j);
if( !CHAR_CHECKINDEX( petindex) ) continue;
CHAR_complianceParameter( petindex );
snprintf( msgbuf, sizeof( msgbuf ), "K%d", j );
CHAR_sendStatusString( talker, msgbuf );
snprintf( msgbuf, sizeof( msgbuf ), "W%d", j );
CHAR_sendStatusString( talker, msgbuf );
}
LogPet(
CHAR_getChar( talker, CHAR_NAME ), /* ƽ<>ҷ<EFBFBD> */
CHAR_getChar( talker, CHAR_CDKEY ),
CHAR_getChar( petindex2, CHAR_NAME),
CHAR_getInt( petindex2, CHAR_LV),
"TenseiGet",
CHAR_getInt( talker,CHAR_FLOOR),
CHAR_getInt( talker,CHAR_X ),
CHAR_getInt( talker,CHAR_Y ),
CHAR_getChar( petindex2, CHAR_UNIQUECODE) // shan 2001/12/14
);
return TRUE;
}
#ifdef _TEACHER_SYSTEM
extern int FMAdvTbl[];
#endif
int NPC_TransmigrationFlg_CLS(int meindex, int toindex)
{
#ifdef _TEACHER_SYSTEM
int iGetFame = 0;
#endif
#ifdef _PET_TRANS
#ifdef _PROSK99
int endevflg[]={69,70,71,72,109,118,122,131,127,158,159,181,-1};//181:<3A><><EFBFBD>ǽ<EFBFBD>Ʒ
#else
int endevflg[]={69,70,71,72,109,118,122,131,127,158,159,-1};
#endif
int nowevflg[]={69,70,71,72,-1};
#endif
#ifdef _TRANS_6
int flg[6] = {48,49,50,51,52,179};
#else
int flg[5] = {48,49,50,51,52};
#endif
int num= CHAR_getInt(toindex ,CHAR_TRANSMIGRATION);
int i;
#ifdef _PET_TRANS
i=0;
while(endevflg[i] != -1 ) {
if( NPC_EventCheckFlg( toindex, endevflg[i] ) == FALSE ) {
endevflg[i] = 0;
}
i++;
}
i=0;
while( nowevflg[i] != -1 ) {
if( NPC_NowEventCheckFlg( toindex, nowevflg[i] ) == FALSE ) {
nowevflg[i] = 0;
}
i++;
}
#endif
CHAR_setInt(toindex,CHAR_ENDEVENT,0);
CHAR_setInt(toindex,CHAR_ENDEVENT2,0);
CHAR_setInt(toindex,CHAR_ENDEVENT3,0);
#ifdef _NEWEVENT
CHAR_setInt(toindex,CHAR_ENDEVENT4,0);
CHAR_setInt(toindex,CHAR_ENDEVENT5,0);
CHAR_setInt(toindex,CHAR_ENDEVENT6,0);
#endif
CHAR_setInt(toindex,CHAR_NOWEVENT,0);
CHAR_setInt(toindex,CHAR_NOWEVENT2,0);
CHAR_setInt(toindex,CHAR_NOWEVENT3,0);
#ifdef _NEWEVENT
CHAR_setInt(toindex,CHAR_NOWEVENT4,0);
CHAR_setInt(toindex,CHAR_NOWEVENT5,0);
CHAR_setInt(toindex,CHAR_NOWEVENT6,0);
#endif
#ifdef _ADD_NEWEVENT // WON <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CHAR_setInt(toindex,CHAR_ENDEVENT7,0);
CHAR_setInt(toindex,CHAR_NOWEVENT7,0);
CHAR_setInt(toindex,CHAR_ENDEVENT8,0);
CHAR_setInt(toindex,CHAR_NOWEVENT8,0);
#endif
#ifdef _PET_TRANS
i=0;
while( endevflg[i] != -1 ) {
if( endevflg[i] > 0 ) {
// shan Begin
//NPC_EventSetFlg( toindex, endevflg[i]);
s_eventsetend(toindex, endevflg[i]);
// End
}
i++;
}
i=0;
while( nowevflg[i] != -1 ) {
if( nowevflg[i] > 0 ) {
NPC_NowEventSetFlg( toindex, nowevflg[i]);
}
i++;
}
#endif
for(i = 0 ;i < num ;i++) {
NPC_EventSetFlg(toindex, flg[i]);
// CoolFish: Family Adv 2001/8/4
AddFMAdv(toindex, flg[i]);
#ifdef _TEACHER_SYSTEM
// <20>ۼ<EFBFBD><DBBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if(flg[i] < 179){
if (getPetUpGetExp()!=2){
iGetFame += FMAdvTbl[flg[i]];
}else{
iGetFame +=0;
}
}
#endif
}
#ifdef _TEACHER_SYSTEM
iGetFame /= 20; // <20><>ʦ<EFBFBD><CAA6><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 5% (1/20)
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>д<EFBFBD><D0B4><EFBFBD>0
if(iGetFame > 0){
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>е<EFBFBD>ʦ
if(strlen(CHAR_getChar(toindex,CHAR_TEACHER_ID)) > 0 && strlen(CHAR_getChar(toindex,CHAR_TEACHER_NAME)) > 0){
int iPlayernum = CHAR_getPlayerMaxNum();
char szMsg[128];
// <20><><EFBFBD>鵼ʦ<E9B5BC>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for(i=0;i<iPlayernum;i++){
if(CHAR_getCharUse(i) == FALSE) continue;
if(strcmp(CHAR_getChar(toindex,CHAR_TEACHER_ID),CHAR_getChar(i,CHAR_CDKEY)) == 0 &&
strcmp(CHAR_getChar(toindex,CHAR_TEACHER_NAME),CHAR_getChar(i,CHAR_NAME)) == 0){
float fGetFame = (float)iGetFame/100;
// <20><>ʦ<EFBFBD><CAA6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CHAR_setWorkInt(i,CHAR_WORK_GET_TEACHER_FAME,CHAR_getWorkInt(i,CHAR_WORK_GET_TEACHER_FAME) + iGetFame);
sprintf(szMsg,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD> %s %.2f <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",CHAR_getChar(toindex,CHAR_NAME),fGetFame);
CHAR_talkToCli(i,-1,szMsg,CHAR_COLORYELLOW);
break;
}
}
}
}
#endif
#ifdef _TRANS_6
if( num == 6 ){
NPC_EventSetFlg(toindex, 63); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҽ<EFBFBD>Ӣ<EFBFBD>۵<EFBFBD>ף<EFBFBD><D7A3>
NPC_EventSetFlg(toindex, 136);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҽ<EFBFBD><D2BD><EFBFBD>֮ʯ
NPC_EventSetFlg(toindex, 175);//<2F>׶<EFBFBD><D7B6><EFBFBD><EFBFBD><EFBFBD>
NPC_EventSetFlg(toindex, 176);//<2F>׶<EFBFBD><D7B6><EFBFBD><EFBFBD><EFBFBD>
}
#endif
return 1;
}
//******************************************************************
//ʸ<><CAB8><EFBFBD><EFBFBD>ë<EFBFBD><C3AB><EFBFBD><EFBFBD>
//******************************************************************
BOOL NPC_TransmigrationDelPetDel(int meindex,int talker,int petsel)
{
int petindex;
int fd = getfdFromCharaIndex( talker );
char msgbuf[64];
char szPet[128];
int defpet;
petindex = CHAR_getCharPet( talker, petsel);
if( !CHAR_CHECKINDEX(petindex) ) return FALSE;
if( CHAR_getWorkInt( CONNECT_getCharaindex( fd),
CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) return FALSE;
/*--<2D><><EFBFBD><EFBFBD>ʸ<EFBFBD><CAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBEAE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>--*/
defpet = CHAR_getInt( talker, CHAR_DEFAULTPET);
if(defpet == petsel){
CHAR_setInt( talker, CHAR_DEFAULTPET, -1);
lssproto_KS_send( fd, -1, TRUE);
}
snprintf( msgbuf,sizeof( msgbuf), "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>%s<><73>",
CHAR_getChar( petindex, CHAR_NAME)); CHAR_talkToCli( talker, -1, msgbuf, CHAR_COLORWHITE);
LogPet(
CHAR_getChar( talker, CHAR_NAME ), /* ƽ<>ҷ’o */
CHAR_getChar( talker, CHAR_CDKEY ),
CHAR_getChar( petindex, CHAR_NAME),
CHAR_getInt( petindex, CHAR_LV),
"TenseiDel",
CHAR_getInt( talker,CHAR_FLOOR),
CHAR_getInt( talker,CHAR_X ),
CHAR_getInt( talker,CHAR_Y ),
CHAR_getChar( petindex, CHAR_UNIQUECODE) // shan 2001/12/14
);
CHAR_setCharPet( talker, petsel, -1);
CHAR_endCharOneArray( petindex );
snprintf( szPet, sizeof( szPet ), "K%d", petsel);
CHAR_sendStatusString( talker, szPet );
return TRUE;
}
//***********************************************************
//***********************************************************
BOOL NPC_TransmigrationDelPet(int meindex, int talker)
{
int petsel;
int petindex;
int num;
int j, k;
// int petid[4] = {1, 2, 3, 4}; //ʸ<><CAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ë϶<C3AB><CFB6>
int petid[4] = {693, 694, 695, 696}; //ʸ<><CAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ë϶<C3AB><CFB6>
// int petidfinal[4] = {11, 12, 13, 14}; //ʸ<><CAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ë϶<C3AB><CFB6>
int petidfinal[4] = {693, 694, 695, 696}; //ʸ<><CAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ë϶<C3AB><CFB6>
int petwork[4] ={ -1, -1, -1, -1};
num = CHAR_getInt(talker, CHAR_TRANSMIGRATION);
num--;
if(num < 4 ){
//϶<><CFB6>ʸ<EFBFBD><CAB8><EFBFBD><EFBFBD>ë<EFBFBD><C3AB><EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD>¾<EFBFBD>ʸ<EFBFBD><CAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for(petsel=0 ; petsel < CHAR_MAXPETHAVE ; petsel++){
petindex = CHAR_getCharPet( talker, petsel);
if( petindex == -1 ) continue;
if(CHAR_getInt( petindex, CHAR_PETID) != petid[num]) continue;
break;
}
if(petsel == CHAR_MAXPETHAVE) return FALSE;
if(NPC_TransmigrationDelPetDel(meindex, talker, petsel) == FALSE) return FALSE;
}
#ifdef _TRANS_6
else if( num == 4 )
#else
else
#endif
{
for(j = 0; j < 4; j++){
//϶<><CFB6>ʸ<EFBFBD><CAB8><EFBFBD><EFBFBD>ë<EFBFBD><C3AB><EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD>¾<EFBFBD>ʸ<EFBFBD><CAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for(petsel=0 ; petsel < CHAR_MAXPETHAVE ; petsel++){
petindex = CHAR_getCharPet( talker, petsel);
if( petindex == -1 ) continue;
if(CHAR_getInt( petindex, CHAR_PETID) != petidfinal[j]) continue;
petwork[j] = petsel;
break;
}
}
for(k=0; k < 4 ;k++)
{
if(petwork[k] == -1) return FALSE;
}
for(k = 0 ; k < 4 ;k++){
if(NPC_TransmigrationDelPetDel(meindex, talker, petwork[k]) == FALSE) return FALSE;
}
}
#ifdef _TRANS_6
else{
/*int lasttalkelder = 2;//<2F><><EFBFBD><EFBFBD>
if( CHAR_getInt( talker, CHAR_LASTTALKELDER) == 1 )//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿
lasttalkelder = 112;//<2F><><EFBFBD><EFBFBD>
else if( CHAR_getInt( talker, CHAR_LASTTALKELDER) == 2 )//<2F>Ӽ<EFBFBD>
lasttalkelder = 102;//<2F>˿˶<CBBF>
else if( CHAR_getInt( talker, CHAR_LASTTALKELDER) == 3 )//<2F><>³<EFBFBD><C2B3><EFBFBD><EFBFBD>
lasttalkelder = 34;//<2F><><EFBFBD><EFBFBD>
*/
//϶<><CFB6>ʸ<EFBFBD><CAB8><EFBFBD><EFBFBD>ë<EFBFBD><C3AB><EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD>¾<EFBFBD>ʸ<EFBFBD><CAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for(petsel=0 ; petsel < CHAR_MAXPETHAVE ; petsel++){
int petid;
petindex = CHAR_getCharPet( talker, petsel);
if( petindex == -1 ) continue;
if(CHAR_getInt( petindex, CHAR_TRANSMIGRATION) != 2) continue;
petid=CHAR_getInt( petindex, CHAR_PETID );
if (petid == 2) break;
if (petid == 112) break;
if (petid == 102) break;
if (petid == 34) break;
}
if(petsel == CHAR_MAXPETHAVE) return FALSE;
if(NPC_TransmigrationDelPetDel(meindex, talker, petsel) == FALSE) return FALSE;
}
#endif
return TRUE;
}
#ifdef _PET_TRANS
void NPC_PetTransMan_selectWindow(int meindex,int toindex,int num,int select)
{
char token[1024],buf[1024],buf1[256];
char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE];
char s_tensei[128];
char errchar[][56]={"errormy","erroritem","errorpet","failmsg"};
int buttontype = 0, windowtype = 0, windowno = 0, errtype = 0;
int petindex = 0,i=1;
char *petname;
BOOL tenflg = FALSE;
int fd = getfdFromCharaIndex( toindex);
if( fd == -1 ) {
print( "getfd err\n");
return;
}
if(NPC_Util_GetArgStr( meindex, npcarg, sizeof(npcarg))==NULL){
print("Tensei:GetArgStrErr");
return;
}
sprintf(s_tensei,"PETTRANS:");
//<2F>ȶ<EFBFBD>npc̸<63><CCB8>
while(getStringFromIndexWithDelim( npcarg,"END",i,buf,sizeof( buf)) != FALSE) {
i++;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> tenflg <20><>ΪTRUE
if( strstr(buf,s_tensei) != NULL) {
tenflg = TRUE;
break;
}
}
if( CHAR_getWorkInt( toindex, CHAR_WORKSHOPRELEVANT) < 0 )
CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 0);
token[0] = '0';
switch(num) {
case 0: //<2F>Ի<EFBFBD>
if( NPC_Util_GetStrFromStrWithDelim( buf,"mainmsg", token,sizeof( token)) == NULL ) {
print("\n ERROR buf str!!");
return;
}
buttontype = WINDOW_BUTTONTYPE_NEXT;
windowno = CHAR_WINDOWTYPE_PETTRANS_START;
break;
case 1: //<2F>Ƿ<EFBFBD><C7B7>ó<EFBFBD><C3B3><EFBFBD>ת<EFBFBD><D7AA>
//ת<><D7AA><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
errtype = NPC_PetTransManCheck( meindex, toindex, 0);
if( errtype >= 0 )
errtype = 3;
if( errtype >= 0 ) {
if( NPC_Util_GetStrFromStrWithDelim( buf,errchar[ errtype], token,sizeof( token)) == NULL ) {
print("\n ERROR str errchar !!");
return;
}
buttontype = WINDOW_BUTTONTYPE_OK;
windowtype = WINDOW_MESSAGETYPE_MESSAGE;
windowno = CHAR_WINDOWTYPE_PETTRANS_END;
break;
}
if( NPC_Util_GetStrFromStrWithDelim( buf,"selectmsg", token,sizeof( token)) == NULL ) {
print("\n ERROR selectmsg !!");
return;
}
CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 1);
windowno = CHAR_WINDOWTYPE_PETTRANS_SELECT;
windowtype = WINDOW_MESSAGETYPE_MESSAGE;
buttontype=WINDOW_BUTTONTYPE_YESNO;
break;
case 2: //ѡ<><D1A1>
if( NPC_Util_GetStrFromStrWithDelim( buf,"setpetmsg", token,sizeof( token)) == NULL ) {
print("\n ERROR setpetmsg !!");
return;
}
buttontype = WINDOW_BUTTONTYPE_NONE;
windowtype = WINDOW_MESSAGETYPE_PETSELECT;
windowno = CHAR_WINDOWTYPE_PETTRANS_SELPET;
break;
case 3: //<2F><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA> ȷ<><C8B7><><C8A1>
if( NPC_Util_GetStrFromStrWithDelim( buf,"transmsg", buf1,sizeof( buf1)) == NULL ){
print("\n ERROR transmsg !!");
return;
}
strcpy( token,"\0");
petindex = CHAR_getCharPet( toindex, select-1);
petname = CHAR_getUseName( petindex);
sprintf(token, "\n<EFBFBD><EFBFBD>[%s]û<><C3BB><EFBFBD>ɣ<EFBFBD> \n\n %s",petname,buf1);
windowtype = WINDOW_MESSAGETYPE_MESSAGE;
buttontype = WINDOW_BUTTONTYPE_YESNO;
windowno = CHAR_WINDOWTYPE_PETTRANS_MAIN1;
break;
case 4: //<2F><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA> CHAR_TRANSMIGRATION
//ת<><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
petindex = CHAR_getCharPet( toindex, select-1);
if( !CHAR_CHECKINDEX( petindex) ) {
return;
}
#ifdef _FUSIONBEIT_TRANS
if( CHAR_getInt( petindex, CHAR_FUSIONBEIT ) > getFusionbeitTrans()) {
sprintf(token, "\n\n<EFBFBD>ںϹ<EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܹ<EFBFBD>ף<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
#else
if( CHAR_getInt( petindex, CHAR_FUSIONBEIT ) == 1 ) {
sprintf(token, "\n\n<EFBFBD>ںϹ<EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD>");
#endif
CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 0);
}else
#ifdef _PET_2TRANS
if( CHAR_getInt( toindex, CHAR_RIDEPET ) == select-1 /*&& CHAR_getInt( petindex, CHAR_TRANSMIGRATION ) > 0*/ ){//<2F><><EFBFBD><EFBFBD><EFBFBD>еij<D0B5><C4B3><EFBFBD><EFB2BB>ת<EFBFBD><D7AA>
sprintf(token, "\n\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>еij<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD>");
}else
#endif
if( CHAR_getInt( petindex, CHAR_LV) < 80 ) {
sprintf(token, "\n\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD>ף<EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ȼ<EFBFBD>80<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 0);
}else if( CHAR_getInt( petindex, CHAR_PETID) == 718
#ifdef _PET_2TRANS
|| CHAR_getInt( petindex, CHAR_PETID) == 401
#endif
#ifdef _PET_3TRANS
|| CHAR_getInt( petindex, CHAR_PETID) == getMMPETID2()
#endif
){
sprintf(token, "\n\n<EFBFBD><EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD>");
CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 0);
#ifdef _PET_2TRANS
#ifdef _FUSIONBEIT_TRANS
}else if( CHAR_getInt( petindex, CHAR_FUSIONBEIT ) == 0 &&
CHAR_getInt( petindex, CHAR_TRANSMIGRATION ) > 2 ) {
#else
}else if( CHAR_getInt( petindex, CHAR_TRANSMIGRATION ) > 1 ) {
#endif
#else
}else if( CHAR_getInt( petindex, CHAR_TRANSMIGRATION ) > 0 ) {
#endif
sprintf(token, "\n\n<EFBFBD><EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܹ<EFBFBD>ף<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 0);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ظ<EFBFBD>ת<EFBFBD><D7AA>
}else { // ת<><D7AA><EFBFBD>ϣ<EFBFBD>
petindex = CHAR_getCharPet( toindex, select-1);
if( NPC_PetTransManStatus( meindex, toindex, petindex) == FALSE )
return;
if( NPC_Util_GetStrFromStrWithDelim( buf,"main1msg", token,sizeof( token)) == NULL )
return;
#ifdef _FUSIONBEIT_TRANS
if( CHAR_getInt( petindex, CHAR_FUSIONBEIT ) >= 1 )
CHAR_setInt( petindex, CHAR_FUSIONBEIT ,CHAR_getInt( petindex, CHAR_FUSIONBEIT )+1);
#endif
CHAR_charSaveFromConnect(toindex, FALSE);
CHAR_talkToCli(toindex, -1, "ϵͳΪ<EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", CHAR_COLORRED);
}
buttontype = WINDOW_BUTTONTYPE_OK;
windowtype = WINDOW_MESSAGETYPE_MESSAGE;
windowno = CHAR_WINDOWTYPE_PETTRANS_END; //<2F><><EFBFBD><EFBFBD>
break;
case 5: //<2F><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>ȡ<EFBFBD><C8A1>
if( NPC_Util_GetStrFromStrWithDelim( buf,"cancelmsg", token,sizeof( token)) == NULL )
return;
CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT, 0);
buttontype = WINDOW_BUTTONTYPE_OK;
windowtype = WINDOW_MESSAGETYPE_MESSAGE;
windowno = CHAR_WINDOWTYPE_PETTRANS_END; //<2F><><EFBFBD><EFBFBD>
break;
default:
break;
}
lssproto_WN_send( fd, windowtype, buttontype, windowno, CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token);
}
int NPC_PetTransManCheck( int meindex, int toindex, int select)
{
//char errchar[][56]={"errormy","erroritem","errorpet","failmsg"};
int i;
int petindex = 0;
char token[256];
int PetEvent_no[3]={4,69,70};
//int PetEvent_no[3]={4,4,4};
int petNum = 0;
//<2F><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if( CHAR_getInt( toindex, CHAR_LV ) < 80 ) {
return 0;
}else {
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>FLAG <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɳ<EFBFBD>ת<EFBFBD><D7AA>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for(i = 0; i < 3 ;i++) {
if( NPC_EventCheckFlg( toindex, PetEvent_no[i] ) == FALSE) {
return 0;
}
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD>) & <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ
for(i=0 ; i < CHAR_MAXPETHAVE ; i++) {
petindex = CHAR_getCharPet( toindex, i);
if( petindex == -1 )
continue;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ID <20>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>׷<EFBFBD><D7B7><EFBFBD> 1479 ID Ϊ718
if(CHAR_getInt( petindex, CHAR_PETID) == 718
#ifdef _PET_2TRANS
|| CHAR_getInt( petindex, CHAR_PETID) == 401
#endif
#ifdef _PET_3TRANS
|| CHAR_getInt( petindex, CHAR_PETID) == getMMPETID2()
#endif
){
petNum ++;
if( CHAR_getInt( petindex, CHAR_LV) > 79 ) {
return 0;
}else if( CHAR_getInt( petindex, CHAR_LV) == 79 ) {
if( strcmp( CHAR_getChar( petindex, CHAR_OWNERCDKEY), CHAR_getChar( toindex, CHAR_CDKEY) ) ||
strcmp( CHAR_getChar( petindex, CHAR_OWNERCHARANAME), CHAR_getChar( toindex, CHAR_NAME) )) {
sprintf( token,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>׷<EFBFBD><EFBFBD>ţ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>İ<EFBFBD><EFBFBD><EFBFBD>");
CHAR_talkToCli( toindex, -1, token, CHAR_COLORWHITE);
return 0;
}
}
}
}
if( petNum > 1 ) {
sprintf( token,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׷<EFBFBD><EFBFBD><EFBFBD><EFBFBD>أ<EFBFBD>");
CHAR_talkToCli( toindex, -1, token, CHAR_COLORWHITE);
print("\n error PetTrans : (PETID = 718) > 1 !!");
return 0;
}else if( petNum != 1 ) {
print("\n <20><>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> !!");
return 0;
}
}
return -1;
}
BOOL NPC_PetTransManStatus( int meindex, int toindex, int petNo)
{
int petindex;
int LevelUpPoint = 0,petrank = 0;
int i,j,k,itemindex,itemID,count;
int vital1,str1,tgh1,dex1;
int vital2,str2,tgh2,dex2;
#ifdef _PET_3TRANS
int vital3,str3,tgh3,dex3,total3,tpetidx3;
#endif
char token[128];
int total1,total2,total,petLV,ans;
int petID,enemynum,ret;
int work[4]={0,0,0,0};
struct PetTransDelItem {
int minItemID;
int maxItemID;
}DelItem[3] = { {19629,19632} , {19672,19687} , {19625,19628} };
#define RAND(x,y) ((x-1)+1+ (int)( (double)(y-(x-1))*rand()/(RAND_MAX+1.0)) )
#ifdef _PET_2TRANS
int tran = CHAR_getInt ( petNo, CHAR_TRANSMIGRATION );
int tpetidx1,tpetidx2;
if( tran == 0 ){
tpetidx1 = 718;
tpetidx2 = 401;
#ifdef _PET_3TRANS
tpetidx3 = getMMPETID2();
}
else
if( tran == 1 ){
tpetidx1 = 401;
tpetidx2 = getMMPETID2();
tpetidx3 = getMMPETID2();
}else
if( tran == 2 ){
tpetidx1 = getMMPETID2();
tpetidx2 = getMMPETID2();
tpetidx3 = getMMPETID2();
}else{
tpetidx1 = 401;
tpetidx2 = getMMPETID2();
tpetidx3 = getMMPETID2();
}
#else
}
else{
tpetidx1 = 401;
tpetidx2 = 401;
}
#endif
#endif
for(i=0 ; i < CHAR_MAXPETHAVE ; i++) {
petindex = CHAR_getCharPet( toindex, i);
if( petindex == -1 )
continue;
if(
#ifdef _PET_2TRANS
CHAR_getInt( petindex, CHAR_PETID) == tpetidx1
|| CHAR_getInt( petindex, CHAR_PETID) == tpetidx2
#ifdef _PET_3TRANS
|| CHAR_getInt( petindex, CHAR_PETID) == tpetidx3
#endif
#else
CHAR_getInt( petindex, CHAR_PETID) == 718
#endif
){
if( CHAR_getInt( petindex, CHAR_LV) == 79 ){
if( strcmp( CHAR_getChar( petindex, CHAR_OWNERCDKEY), CHAR_getChar( toindex, CHAR_CDKEY) ) ||
strcmp( CHAR_getChar( petindex, CHAR_OWNERCHARANAME), CHAR_getChar( toindex, CHAR_NAME) )) {
continue;
}
break;
}
}
}
if(i == CHAR_MAXPETHAVE) {
print("\n <20><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> !!");
return FALSE;
}
LevelUpPoint = CHAR_getInt( petindex, CHAR_ALLOCPOINT );
petrank = CHAR_getInt( petindex, CHAR_PETRANK );
vital1 = (float)(( LevelUpPoint >> 24 ) & 0xFF);
str1 = (float)(( LevelUpPoint >> 16 ) & 0xFF);
tgh1 = (float)(( LevelUpPoint >> 8 ) & 0xFF);
dex1 = (float)(( LevelUpPoint >> 0 ) & 0xFF);
if(vital1 < 1)vital1 = 1;
if(str1 < 1)str1 = 1;
if(tgh1 < 1)tgh1 = 1;
if(dex1 < 1)dex1 = 1;
total1 = ( vital1 + str1 + tgh1 + dex1 );
#ifdef _PET_TRANS_ABILITY
if( total1 > getPetTransAbility1() ) total1 = getPetTransAbility1();
#else
if( total1 > 150 ) total1 = 150;
#endif
if( total1 < 0 ) total1 = 0;
LevelUpPoint = CHAR_getInt( petNo, CHAR_ALLOCPOINT );
petrank = CHAR_getInt( petNo, CHAR_PETRANK );
petLV = CHAR_getInt( petNo, CHAR_LV);
vital2 = (float)(( LevelUpPoint >> 24 ) & 0xFF);
str2 = (float)(( LevelUpPoint >> 16 ) & 0xFF);
tgh2 = (float)(( LevelUpPoint >> 8 ) & 0xFF);
dex2 = (float)(( LevelUpPoint >> 0 ) & 0xFF);
if(vital2 < 1)vital2 = 1;
if(str2 < 1)str2 = 1;
if(tgh2 < 1)tgh2 = 1;
if(dex2 < 1)dex2 = 1;
total2 = ( vital2 + str2 + tgh2 + dex2 );
#ifdef _PET_3TRANS
#ifdef _PET_TRANS_ABILITY
if( total2 > getPetTransAbility2() ) total2 = getPetTransAbility2();
#else
if( total2 > 200 ) total2 = 200;
#endif
if( total2 < 0 ) total2 = 0;
LevelUpPoint = CHAR_getInt( petNo, CHAR_ALLOCPOINT );
petrank = CHAR_getInt( petNo, CHAR_PETRANK );
petLV = CHAR_getInt( petNo, CHAR_LV);
vital3 = (float)(( LevelUpPoint >> 24 ) & 0xFF);
str3 = (float)(( LevelUpPoint >> 16 ) & 0xFF);
tgh3 = (float)(( LevelUpPoint >> 8 ) & 0xFF);
dex3 = (float)(( LevelUpPoint >> 0 ) & 0xFF);
total3 = ( vital3 + str3 + tgh3 + dex3 );
#ifdef _PET_TRANS_ABILITY
if( total3 > getPetTransAbility3() ) total3 = getPetTransAbility3();
#else
if( total3 > 250 ) total3 = 250;
#endif
#endif
#ifdef _PET_2TRANS
ans = NPC_PetTransManGetAns( total1, total2, petLV, petrank, CHAR_getInt( petNo, CHAR_TRANSMIGRATION ) );
#else
ans = NPC_PetTransManGetAns( total1, total2, petLV, petrank);
#endif
total = total1 + (total2*4);
work[0] = ( ans * ( vital1 + (vital2*4) ) ) / total;
work[1] = ( ans * ( str1 + (str2*4) ) ) / total;
work[2] = ( ans * ( tgh1 + (tgh2*4) ) ) / total;
work[3] = ( ans * ( dex1 + (dex2*4) ) ) / total;
//ȡarray=========================
enemynum = ENEMY_getEnemyNum();
for(i=0;i<CHAR_MAXPETHAVE;i++) {
if( CHAR_getCharPet( toindex , i) == petNo) {
break;
}
}
if( CHAR_MAXPETHAVE == i ) {
return FALSE;
}
petID = CHAR_getInt( petNo, CHAR_PETID);
for(k=0;k<enemynum;k++) {
if(ENEMY_getInt(k, ENEMY_TEMPNO) == petID )
break;
}
if(k == enemynum) {
print("\n test *-7 : petID=%d", petID);
return FALSE;
}
{
BOOL FINDs = FALSE;
#ifdef _PET_2TRANS
tpetidx1 = CHAR_getInt( petindex, CHAR_PETID);
#endif
//ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for(j=0 ; j < CHAR_MAXPETHAVE ; j++){
int pet_index = CHAR_getCharPet( toindex, j);
if( pet_index == -1 ) continue;
if(
#ifdef _PET_2TRANS
CHAR_getInt( pet_index, CHAR_PETID) == tpetidx1
#else
CHAR_getInt( pet_index, CHAR_PETID) == 718
#endif
){
if( NPC_TransmigrationDelPetDel( meindex, toindex, j) == FALSE){
return FALSE;
}else {
FINDs = TRUE;
}
}
}
if( FINDs == FALSE )
return FALSE;
}
ret = GetNewPet( toindex , petNo, k, work);
if( ret < 0 )
return FALSE;
for(count=0;count<CHAR_MAXPETHAVE;count++) {
if(CHAR_getCharPet(toindex,count) == ret) {
CHAR_send_K_StatusString(toindex,count,CHAR_K_STRING_HP|CHAR_K_STRING_AI);
}
}
{
/*
LogPetTrans(
CHAR_getChar( toindex, CHAR_CDKEY ),
CHAR_getChar( petNo, CHAR_UNIQUECODE),
CHAR_getChar( petindex, CHAR_UNIQUECODE),//<2F><><EFBFBD><EFBFBD>
CHAR_getChar( toindex, CHAR_NAME),
CHAR_getInt( toindex, CHAR_FLOOR),
CHAR_getInt( toindex, CHAR_X),
CHAR_getInt( toindex, CHAR_Y),
CHAR_getInt( petNo, CHAR_PETID),
CHAR_getChar( petNo, CHAR_NAME),
petLV, petrank,
vital2, str2, tgh2, dex2, total2,
CHAR_getInt( petindex, CHAR_PETID),
CHAR_getChar( petindex, CHAR_NAME),
vital1, str1, tgh1, dex1, total1,
work[0], work[1], work[2], work[3], ans, CHAR_getInt ( petNo, CHAR_TRANSMIGRATION ) );
*/
}
sprintf(token,"%s <20><><EFBFBD><EFBFBD><EFBFBD>˾<EFBFBD><CBBE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ף<EFBFBD><D7A3><EFBFBD><EFBFBD>", CHAR_getUseName( ret));
CHAR_talkToCli( toindex, -1,token,CHAR_COLORWHITE);
sprintf( token, "K%d", i );
CHAR_sendStatusString( toindex , token );
//--------------------------------------------------------------------------
//ɾ<><C9BE><EFBFBD><EFBFBD>Ʒ itemindex,itemID;
for( i =0 ; i < CHAR_MAXITEMHAVE ; i++ ){
itemindex = CHAR_getItemIndex( toindex , i );
if( ITEM_CHECKINDEX(itemindex) ){
itemID = ITEM_getInt(itemindex ,ITEM_ID );
for( j = 0;j < 3;j++) {
if( ( itemID >= DelItem[j].minItemID ) && ( itemID <= DelItem[j].maxItemID ) ) {
LogItem(
CHAR_getChar( toindex, CHAR_NAME ),
CHAR_getChar( toindex, CHAR_CDKEY ),
#ifdef _add_item_log_name // WON ADD <20><>item<65><6D>log<6F><67><EFBFBD><EFBFBD><EFBFBD><EFBFBD>item<65><6D><EFBFBD><EFBFBD>
itemindex,
#else
ITEM_getInt( itemindex, ITEM_ID),
#endif
"WarpManDelItem",
CHAR_getInt( toindex, CHAR_FLOOR),
CHAR_getInt( toindex, CHAR_X ),
CHAR_getInt( toindex, CHAR_Y ),
ITEM_getChar( itemindex, ITEM_UNIQUECODE),
ITEM_getChar( itemindex, ITEM_NAME),
ITEM_getInt( itemindex, ITEM_ID)
);
CHAR_DelItem( toindex, i);
}
}//for(j)
}
}
NPC_NowEventSetFlg( toindex, 71 );
return TRUE;
}
// shan add
void s_eventsetend( int charaindex, int shiftbit )
{
#ifdef _ADD_NEWEVENT // WON <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int event_num = 8;
#else
int event_num = 6;
#endif
int point;
int array;
int shift;
array = shiftbit / 32;
shift = shiftbit % 32;
if( array>=event_num ){
//print("<22><><EFBFBD>󣡣<EFBFBD><F3A3A1A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѳ<EFBFBD><D1B3><EFBFBD><EFBFBD><EFBFBD>Χ(0~%d)<29><>",32*event_num-1);
return;
}
point = CHAR_getInt( charaindex, CHAR_ENDEVENT+array);
point = point | (1<<shift);
CHAR_setInt( charaindex, CHAR_ENDEVENT+array, point);
}
#endif