📄 char.c
字号:
#include "version.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h> // shan
#include <ctype.h>
#include <time.h>
#include <sys/time.h>
#include <errno.h>
#include "net.h"
#include "common.h"
#include "char_base.h"
#include "char_data.h"
#include "char.h"
#include "lssproto_serv.h"
#include "item.h"
#include "item_event.h"
#include "buf.h"
#include "object.h"
#include "map_deal.h"
#include "saacproto_cli.h"
#include "readmap.h"
#include "handletime.h"
#include "char_event.h"
#include "npccreate.h"
#include "addressbook.h"
#include "item_event.h"
#include "magic_base.h"
#include "magic.h"
#include "chatmagic.h"
#include "configfile.h"
#include "log.h"
#include "anim_tbl.h"
#include "encount.h"
#include "battle.h"
#include "pet_skill.h"
#include "util.h"
#include "enemy.h"
#include "npcutil.h"
#include "pet.h"
#include "family.h"
#include "correct_bug.h"
extern int channelMember[FAMILY_MAXNUM][FAMILY_MAXCHANNEL][FAMILY_MAXMEMBER];
extern int familyMemberIndex[FAMILY_MAXNUM][FAMILY_MAXMEMBER];
extern tagRidePetTable ridePetTable[296];
extern int BATTLE_getRidePet( int charaindex );
int CharaData( int sockfd, Char* ch );
extern void GOLD_DeleteTimeCheckOne( int objindex);
// WON ADD 修正道具的设定问题
void fix_item_bug(int charaindex, int i);
/*====================平乓仿及综岳卞楮允月楮醒====================*/
/*------------------------------------------------------------
* 综岳允月凛及左皿扑亦件及袄毛涩烂仄方丹午允月[
* 娄醒
* ch Char* 涩烂燮及平乓仿及犯□正
* option char* 弁仿奶失件玄井日仁月犯□正
* 忒曰袄
* 岳 TRUE
* 撩 FALSE
------------------------------------------------------------*/
static BOOL CHAR_makeCharFromOptionAtCreate( Char* ch ,
int vital, int str, int tgh, int dex,
int earth, int water, int fire, int wind)
{
/* 躲岭及腹据毛垫丹 */
int para[4];
int attr[4];
int i;
int parasum,attrsum;
int cnt;
para[0] = vital;
para[1] = str;
para[2] = tgh;
para[3] = dex;
attr[0] = earth;
attr[1] = water;
attr[2] = fire;
attr[3] = wind;
#define MAXPARAMETER 20
#define PKMAXPARAMETER 300
parasum = 0;
/*
* 允屯化及犯□正及 卞 - 反丐匀化反卅日卅中仄
* 瑕丐孔木及仪毛哔尹化云中化 及袄手译尹卅中
*/
for( i = 0; i < arraysizeof( para); i ++ ) {
if( para[i] < 0 || para[i] > MAXPARAMETER )return FALSE;
parasum += para[i];
}
#ifdef _NEW_PLAYER_CF //新手出生配置
if( parasum > MAXPARAMETER ) return FALSE;
#else
if( parasum != MAXPARAMETER ) return FALSE;
#endif
#undef MAXPARAMETER
#define MAXATTRIBUTE 10
cnt = 0;
attrsum = 0;
/* 箪岭及民尼永弁毛允月 */
for( i = 0; i < arraysizeof( para); i ++ ) {
if( attr[i] < 0 || attr[i] > MAXATTRIBUTE )return FALSE;
attrsum += attr[i];
if( attr[i] > 0 ) cnt ++;
}
/* 宁煌袄反10 */
if( attrsum != MAXATTRIBUTE ) return FALSE;
/* 2勾方曰聂仁喃曰癫化日木化中凶日蛲 */
if( cnt > 2 ) return FALSE;
/* 菅箪岭反喃曰癫化日木卅中 */
if( attr[0] > 0 && attr[2] > 0 ) return FALSE;
if( attr[1] > 0 && attr[3] > 0 ) return FALSE;
#undef MAXATTRIBUTE
/* 戊疋□ */
ch->data[CHAR_VITAL] = vital*100;
ch->data[CHAR_STR] = str*100;
ch->data[CHAR_TOUGH] = tgh*100;
ch->data[CHAR_DEX] = dex*100;
ch->data[CHAR_EARTHAT] = attr[0] * 10;
ch->data[CHAR_WATERAT] = attr[1] * 10;
ch->data[CHAR_FIREAT] = attr[2] * 10;
ch->data[CHAR_WINDAT] = attr[3] * 10;
#ifdef _NEWOPEN_MAXEXP
ch->data[CHAR_OLDEXP] = 0;
#endif
ch->data[CHAR_EXP] = 0;
#ifdef _NEW_PLAYER_CF //新手出生配置
ch->data[CHAR_TRANSMIGRATION] = getNewplayertrans();
ch->data[CHAR_GOLD] = getNewplayergivegold();;
ch->data[CHAR_LV] = getNewplayerlv();
#ifdef _VIP_SERVER
ch->data[CHAR_AMPOINT] = getNewplayergivevip();
#endif
// ch->data[CHAR_LEARNRIDE] = 200;
// ch->data[CHAR_LASTTALKELDER] = (rand()%10)>5?35:36;//34;
// ch->data[CHAR_SKILLUPPOINT] = 616;//600;
#endif
#ifdef _PETSKILL_BECOMEPIG
ch->data[CHAR_BECOMEPIG] = -1;
ch->data[CHAR_BECOMEPIG_BBI] = 100250;
#endif
ch->data[CHAR_LASTLEAVETIME] = 0;
return TRUE;
}
#ifdef _HELP_NEWHAND
void CHAR_loginAddItemForNew( int charindex )
{
int emptyitemindexinchara, itemindex;
int i;
char msgbuf[128];
#ifdef _NEW_PLAYER_CF
for( i = 0; i < 15; i ++ ) {
#else
int num = 4;
int itemid[4] = { 20626 , 20627 , 20628 , 20628 };
for( i = 0; i < num; i ++ ) {
#endif
emptyitemindexinchara = CHAR_findEmptyItemBox( charindex );
if( emptyitemindexinchara < 0 ){
sprintf( msgbuf, "空间栏位不足。" );
CHAR_talkToCli( charindex, -1, msgbuf, CHAR_COLORYELLOW);
return;
}
#ifdef _NEW_PLAYER_CF
if(getNewplayergiveitem(i)==-1)continue;
itemindex = ITEM_makeItemAndRegist( getNewplayergiveitem(i) );
#else
itemindex = ITEM_makeItemAndRegist( itemid[i] );
#endif
if( itemindex != -1 ){
CHAR_setItemIndex( charindex, emptyitemindexinchara, itemindex );
ITEM_setWorkInt(itemindex, ITEM_WORKOBJINDEX,-1);
ITEM_setWorkInt(itemindex, ITEM_WORKCHARAINDEX,charindex);
CHAR_sendItemDataOne( charindex, emptyitemindexinchara);
}
}
print("Get New Hand Item");
}
#endif
void CHAR_createNewChar( int clifd, int dataplacenum, char* charname ,
int imgno,int faceimgno,
int vital,int str,int tgh,int dex,
int earth,int water,int fire,int wind,
int hometown , char *cdkey )
{
Char ch, *chwk;
int charaindex, petindex;
int enemyarray;
char szKey[256];
#ifdef _NEW_PLAYER_CF //新手出生配置
int add_pet[]={0,0,0,0,0};
#endif
memset(&ch,0,sizeof(Char));
if( !CHAR_checkPlayerImageNumber( imgno)) {
lssproto_CreateNewChar_send( clifd ,FAILED, "" );
CONNECT_setState( clifd, NOTLOGIN );
return;
}
if( !CHAR_checkFaceImageNumber( imgno, faceimgno)) {
lssproto_CreateNewChar_send( clifd ,FAILED, "" );
CONNECT_setState( clifd, NOTLOGIN );
return;
}
CHAR_getDefaultChar(&ch,imgno);
ch.data[CHAR_WALKINTERVAL] = getWalksendinterval();
if( CHAR_getInitElderPosition( &ch ,hometown) == FALSE ){
lssproto_CreateNewChar_send( clifd ,FAILED, "" );
CONNECT_setState( clifd, NOTLOGIN );
return;
}else if( MAP_checkCoordinates( ch.data[CHAR_FLOOR], ch.data[CHAR_X],
ch.data[CHAR_Y] ) == FALSE ){
lssproto_CreateNewChar_send( clifd ,FAILED, "");
CONNECT_setState( clifd, NOTLOGIN );
return;
}
strcpysafe( ch.string[CHAR_NAME].string ,
sizeof(ch.string[CHAR_NAME].string),
charname);
if( CHAR_getNewImagenumberFromEquip( imgno,0) == -1 ){
lssproto_CreateNewChar_send( clifd ,FAILED, "");
CONNECT_setState( clifd, NOTLOGIN );
return;
}
ch.data[CHAR_BASEIMAGENUMBER] = imgno;
ch.data[CHAR_BASEBASEIMAGENUMBER] = imgno;
ch.data[CHAR_FACEIMAGENUMBER] = faceimgno;
ch.data[CHAR_DATAPLACENUMBER] = dataplacenum;
#ifdef _FM_JOINLIMIT
ch.data[CHAR_FMTIMELIMIT] = 0;
#endif
#ifdef _NEWSAVE
ch.data[CHAR_SAVEINDEXNUMBER] = -1;
#endif
ch.data[CHAR_HP] = 0x7fffffff;
ch.data[CHAR_CHARM] = 60;
ch.data[CHAR_MAXMP] = ch.data[CHAR_MP] = 100;
strcpysafe( ch.string[CHAR_CDKEY].string,
sizeof( ch.string[CHAR_CDKEY].string), cdkey );
// Robin 0724
ch.data[CHAR_RIDEPET] = -1;
#ifdef _NEW_PLAYER_CF
ch.data[CHAR_LEARNRIDE] = getRidePetLevel();
#endif
#ifdef _PERSONAL_FAME // Arminius: 家族个人声望
ch.data[CHAR_FAME] = 0;
#ifdef _ITEM_SETLOVER
memset(ch.string[CHAR_LOVERID].string,0,sizeof(STRING128));
memset(ch.string[CHAR_LOVERNAME].string,0,sizeof(STRING128));
#endif
#endif
#ifdef _PETSKILL_BECOMEPIG
ch.data[CHAR_BECOMEPIG] = -1;
ch.data[CHAR_BECOMEPIG_BBI] = 100250;
#endif
strcpysafe( ch.string[CHAR_FMNAME].string,
sizeof( ch.string[CHAR_FMNAME].string), "\0" );
ch.data[CHAR_FMINDEX] = -1;
if( CHAR_makeCharFromOptionAtCreate( &ch,
vital,str,tgh,dex,
earth,water,fire,wind ) == FALSE )
{
lssproto_CreateNewChar_send( clifd ,FAILED,
"option data is invalid\n");
CONNECT_setState( clifd, NOTLOGIN );
return;
}
{
int mp=ch.data[CHAR_MAXMP];
int str=ch.data[CHAR_STR];
int tough=ch.data[CHAR_TOUGH];
ch.data[CHAR_INITDATA] = 2*100*100*100*100 /*+ hp*100*100*100*/
+ mp*100*100 + str* 100 + tough;
}
charaindex = CHAR_initCharOneArray( &ch );
if( charaindex == -1 ) {
lssproto_CreateNewChar_send( clifd ,FAILED, "");
CONNECT_setState( clifd, NOTLOGIN );
return;
}
#ifdef _NEW_PLAYER_CF //新手出生配置
int petNum=0;
int k=0;
int mylevel,level;
if(getNewplayergivepet(0)==-1){
if( CHAR_getInt( charaindex, CHAR_LASTTALKELDER) == 1 )//玛丽娜丝
setNewplayergivepet(0,2);
else if( CHAR_getInt( charaindex, CHAR_LASTTALKELDER) == 2 )//加加
setNewplayergivepet(0,3);
else if( CHAR_getInt( charaindex, CHAR_LASTTALKELDER) == 3 )//卡鲁它那
setNewplayergivepet(0,4);
else
setNewplayergivepet(0,1);
}
#ifdef _NEW_PLAYER_RIDE
if(!strstr( getPlayerRide(), "不送配套骑宠"))
CHAR_PlayerRide(charaindex);
#endif
for( petNum=0; petNum<5; petNum++) {
if(getNewplayergivepet(petNum)==0)continue;
enemyarray = ENEMY_getEnemyArrayFromId( getNewplayergivepet(petNum)); //白虎
petindex = ENEMY_createPetFromEnemyIndex( charaindex, enemyarray);
if( petindex == -1 ) {
continue;
}
add_pet[petNum]=petindex;
mylevel = CHAR_getInt( petindex, CHAR_LV);
level = getNewplayerpetlv()-mylevel;
if(level<1)level=1;
for( k = 1; k < level; k ++ ){ //升级
CHAR_PetLevelUp( petindex );
CHAR_PetAddVariableAi( petindex, AI_FIX_PETLEVELUP );
CHAR_setInt( petindex, CHAR_LV, CHAR_getInt( petindex, CHAR_LV) +1 );
}
CHAR_complianceParameter( petindex );
CHAR_setInt( petindex , CHAR_HP , CHAR_getWorkInt( petindex , CHAR_WORKMAXHP ) );
}
#else
enemyarray = ENEMY_getEnemyArrayFromId( hometown + 1);
petindex = ENEMY_createPetFromEnemyIndex( charaindex, enemyarray);
if( !CHAR_CHECKINDEX( petindex )){
CHAR_endCharOneArray( charaindex);
lssproto_CreateNewChar_send( clifd ,FAILED, "");
CONNECT_setState( clifd, NOTLOGIN );
return;
}
CHAR_setMaxExpFromLevel( petindex, 1);
#endif
#ifdef _HELP_NEWHAND
CHAR_loginAddItemForNew(charaindex);
#endif
#if 1
if( CHAR_makeDBKey( charaindex, szKey, sizeof( szKey ) ) != FALSE ){
int dp;
char info[512];
snprintf( info, sizeof( info),
"%d,%d,%d,%d,%d,%d",
CHAR_getInt( charaindex, CHAR_LV),
CHAR_getInt( charaindex, CHAR_DUELBATTLECOUNT),
CHAR_getInt( charaindex, CHAR_DUELWINCOUNT),
CHAR_getInt( charaindex, CHAR_DUELLOSECOUNT),
CHAR_getInt( charaindex, CHAR_DUELSTWINCOUNT),
CHAR_getInt( charaindex, CHAR_DUELMAXSTWINCOUNT));
dp = CHAR_getInt( charaindex, CHAR_DUELPOINT );
saacproto_DBUpdateEntryInt_send(
acfd,
DB_DUELPOINT,
szKey,
(max(dp,0)),
info,
CONNECT_getFdid(clifd ),0 );
}
#endif
chwk = CHAR_getCharPointer( charaindex);
CHAR_charSaveFromConnectAndChar( clifd,chwk ,FALSE );
CHAR_endCharData(&ch);
CHAR_endCharOneArray( charaindex);
#ifdef _NEW_PLAYER_CF //新手出生配置
{
int k=0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -