Initial MSVC 2008 projects workspace

This commit is contained in:
alexey.min
2012-02-01 05:25:08 +00:00
commit 03de3bdc95
1446 changed files with 476853 additions and 0 deletions

View File

@@ -0,0 +1,215 @@
#include "stdafx.h"
#include "L2Character.h"
#include "../game/L2GamePacket.h"
#include "../os/os_abstraction.h"
L2Character::L2Character()
{
setUnused();
}
L2Character::~L2Character()
{
setUnused();
}
L2Character::L2Character( const L2Character& other ): L2Object()
{
setUnused();
this->operator=( other );
}
const L2Character& L2Character::operator=( const L2Character& other )
{
if( this == &other ) return (*this);
L2Object::operator=( other );
// copy
level = other.level;
setName( other.charName );
setTitle( other.charTitle );
xDst = other.xDst;
yDst = other.yDst;
zDst = other.zDst;
heading = other.heading;
runSpeed = other.runSpeed;
walkSpeed = other.walkSpeed;
isRunning = other.isRunning;
isSitting = other.isSitting;
isAlikeDead = other.isAlikeDead;
isFlying = other.isFlying;
lastMoveTickTime = other.lastMoveTickTime;
s_STR = other.s_STR;
s_DEX = other.s_DEX;
s_CON = other.s_CON;
s_INT = other.s_INT;
s_WIT = other.s_WIT;
s_MEN = other.s_MEN;
pAtk = other.pAtk;
pDef = other.pDef;
mAtk = other.mAtk;
mDef = other.mDef;
pAtkSpd = other.pAtkSpd;
mAtkSpd = other.mAtkSpd;
accuracy = other.accuracy;
evasion = other.evasion;
critical = other.critical;
curHp = other.curHp;
maxHp = other.maxHp;
curMp = other.curMp;
maxMp = other.maxMp;
curCp = other.curCp;
maxCp = other.maxCp;
abnormalEffect = other.abnormalEffect;
targetObjectID = other.targetObjectID;
isInCombat = other.isInCombat;
collisionRadius = other.collisionRadius;
collisionHeight = other.collisionHeight;
pvpFlag = other.pvpFlag;
karma = other.karma;
clanID = other.clanID;
clanCrestID = other.clanCrestID;
clanCrestLargeID = other.clanCrestLargeID;
allyID = other.allyID;
allyCrestID = other.allyCrestID;
return (*this);
}
void L2Character::setUnused()
{
L2Object::setUnused();
stopMove();
charName[0] = charTitle[0] = 0;
level = 0;
heading = 0;
runSpeed = walkSpeed = isRunning = isSitting = isAlikeDead = 0;
lastMoveTickTime = 0;
s_STR = s_DEX = s_CON = s_INT = s_WIT = s_MEN = 0;
pAtk = pDef = mAtk = mDef = pAtkSpd = mAtkSpd = accuracy = evasion = critical = 0;
curHp = maxHp = curMp = maxMp = curCp = maxCp = 0.0;
abnormalEffect = 0;
targetObjectID = 0;
isInCombat = 0;
collisionRadius = collisionHeight = 1.0;
}
void L2Character::setName( const wchar_t *name )
{
if( name )
{
wcsncpy( charName, name, sizeof(charName)/sizeof(charName[0]) - 1 );
charName[ sizeof(charName)/sizeof(charName[0]) - 1 ] = 0;
}
}
void L2Character::setName( const char *name )
{
if( name )
{
#ifdef L2PACKETS_WINDOWS
_snwprintf( charName, sizeof(charName)/sizeof(charName[0]), L"%S", name );
#endif
#ifdef L2PACKETS_LINUX
swprintf( charName, sizeof(charName)/sizeof(charName[0]), L"%ls", name );
#endif
charName[ sizeof(charName)/sizeof(charName[0]) - 1 ] = 0;
}
}
void L2Character::setTitle( const wchar_t *title )
{
if( title )
{
wcsncpy( charTitle, title, sizeof(charTitle)/sizeof(charTitle[0]) - 1 );
charTitle[ sizeof(charTitle)/sizeof(charTitle[0]) - 1 ] = 0;
}
}
void L2Character::setTitle( const char *title )
{
if( title )
{
#ifdef L2PACKETS_WINDOWS
_snwprintf( charTitle, sizeof(charTitle)/sizeof(charTitle[0]), L"%S", title );
#endif
#ifdef L2PACKETS_LINUX
swprintf( charTitle, sizeof(charTitle)/sizeof(charTitle[0]), L"%ls", title );
#endif
charTitle[ sizeof(charTitle)/sizeof(charTitle[0]) - 1 ] = 0;
}
}
const wchar_t *L2Character::getName()
{
this->charName[sizeof(this->charName) - 1] = 0;
return (const wchar_t *)(this->charName);
}
const wchar_t *L2Character::getTitle()
{
this->charTitle[sizeof(this->charTitle) - 1] = 0;
return (const wchar_t *)(this->charTitle);
}
bool L2Character::parse_MoveToLocation( void *l2_game_packet )
{
L2GamePacket *p = (L2GamePacket *)l2_game_packet;
p->getPacketType();
unsigned int oid = p->readUInt();
if( oid != this->objectID ) return false; // not my move
xDst = p->readInt();
yDst = p->readInt();
zDst = p->readInt();
x = p->readInt();
y = p->readInt();
z = p->readInt();
this->lastMoveTickTime = OS_GetTickCount(); // last time when x,y,z, xDst,yDst,zDst were known exactly
return true;
}
void L2Character::processMoveTick()
{
unsigned long long int curTick = OS_GetTickCount();
unsigned long long int millisecsPassed = curTick - lastMoveTickTime;
if( millisecsPassed < 100 ) return;
lastMoveTickTime = curTick;
const int near_range = 50; // range in which point is reached
if( isMoving() )
{
int dx = xDst - x;
int dy = yDst - y;
int dz = zDst - z;
if( ((dx > -near_range)&&(dx < near_range)) &&
((dy > -near_range)&&(dy < near_range)) &&
((dz > -near_range)&&(dz < near_range)) ) // target ~~ reached?
{
stopMove();
return;
}
float useSpeed = (float)runSpeed;
if( isRunning ) useSpeed = (float)walkSpeed;
float secs = ((float)millisecsPassed) / 1000;
float movedDist = useSpeed * secs;
float totalDist = sqrtf( (float)(dx*dx + dy*dy) );
float k = totalDist / movedDist;
if( k < 1.1 ) // cannot be < 1
{
stopMove();
return;
}
float xDelta = (float)dx / k;
float yDelta = (float)dy / k;
x += (int)xDelta;
y += (int)yDelta;
}
}
void L2Character::startMoveTo( int mxd, int myd, int mzd, int mx, int my, int mz )
{
x = mx;
y = my;
z = mz;
xDst = mxd;
yDst = myd;
zDst = mzd;
lastMoveTickTime = OS_GetTickCount();
}

View File

@@ -0,0 +1,162 @@
#ifndef H_L2CHARACTER
#define H_L2CHARACTER
#include "L2Object.h"
/** \class L2Character
L2Character represents common properties for all moving objects in game:\n
treasure chests, doors, chairs, mobs, npcs, players...\n
\n
Every character is L2Object:\n
Every L2Object has its objectID and can also have its coordinates in L2World)\n
\n
Additionally:\n
Every L2Character has LEVEL!\n
Every L2Character has its charName and charTitle\n
Every L2Character has its heading\n
Every L2Character has moving speed in states: running, walking\n
Every L2Character has its move destination: xDst, yDst, zDst\n
Every L2Character can calc its position based on destnation point and time passed since last calc\n
Every L2Character has its base stats: INT WIT MEN CON STR DEX\n
Every L2Character has its stats: pAtk, mAtk, ..., curHp, maxHp, ...\n
Every L2Character has abnormalEffect\n
Every L2Character has its target\n
Every L2Character can be in combat\n
Every L2Character has its collision radius and height\n
Every L2Character has its pvpFlag, karma\n
Every L2Character has its clan, ally IDs and clan/ally crest IDs\n
*/
class L2Character : public L2Object
{
public:
/** Default constructor, just calls setUnused() (zeroes all members) */
L2Character();
/** Copy constructor
* \param other source to copy from */
L2Character( const L2Character& other );
/** Operator =
* \param other source to copy from
* \return reference to this object
*/
virtual const L2Character& operator=( const L2Character& other );
/** Default destructor, just calls setUnused() (zeroes all members) */
virtual ~L2Character();
public:
/** Initializes object's state (zeroes all members)
* \return none
*/
virtual void setUnused();
public:
/** MoveToLocation packet parser.
* MoveToLocation packet is sent when some object starts moving to some point.
* Updates x,y,z, xDst,yDst,zDst.
* Updates lastMoveTickTime (sets to current time).
* \param l2_game_packet pointer to L2GamePacket object to parse
* \return none
* \see lastMoveTickTime
*/
virtual bool parse_MoveToLocation( void *l2_game_packet );
/** Calculates current character position based on x, y, z, xDst, yDst, zDst,
* runSpeed / walkSpeed, isRunning, current time and last time when character coords were
* known exactly (from some packet or after previous calculation).
* Updates x,y,z and lastMoveTickTime (sets to current time).
* \return none
* \see lastMoveTickTime
*/
virtual void processMoveTick();
/** Starts 'moving' character: sets destination coords and current coords.
* Updates x,y,z,xDst,yDst,zDst,lastMoveTickTime.
* \param mxd,myd,mzd destination point coords
* \param mx,my,mz current char coords
* \return none
* \see lastMoveTickTime
*/
virtual void startMoveTo( int mxd, int myd, int mzd, int mx, int my, int mz );
/** sets xDst,yDst,zDst to 0x7FFFFFFF, indicating that character is not moving.
* \return none
* \see xDst,yDst,zDst
*/
virtual void stopMove() { xDst = 0x7FFFFFFF; yDst = 0x7FFFFFFF; zDst = 0x7FFFFFFF; }
/** moving test
* \return 1 if char is moving, 0 if not
* \see xDst,yDst,zDst
*/
virtual int isMoving() { return ((xDst != 0x7FFFFFFF) && (yDst != 0x7FFFFFFF) && (zDst!=0x7FFFFFFF)); }
public:
/** Sets char name.
* \param name new char name to set.
*/
virtual void setName( const wchar_t *name );
virtual void setName( const char *name );
/** Sets char title.
* \param title new char title to set.
*/
virtual void setTitle( const wchar_t *title );
virtual void setTitle( const char *title );
virtual const wchar_t *getName(); //< not really used
virtual const wchar_t *getTitle(); //< not really used
public:
int level; ///< character level
wchar_t charName[128]; ///< character name
wchar_t charTitle[128]; ///< character title (displayed above name in client ^^)
int xDst; ///< x-destination move coord (=0x7FFFFFFF if char is not moving)
int yDst; ///< y-destination move coord (=0x7FFFFFFF if char is not moving)
int zDst; ///< z-destination move coord (=0x7FFFFFFF if char is not moving)
unsigned int heading; ///< heading... not really used
int runSpeed; ///< run speed
int walkSpeed; ///< walk speed
int isRunning; ///< 1, if char is runing, 0 if walking
int isSitting; ///< 1, if char is sitting, 0 if standing
int isAlikeDead; ///< 1, if characted is dead or looks like dead (fake death)
int isFlying; ///< 1, if character is flying (?) T2.3
unsigned long long int lastMoveTickTime; ///< timer used to store last time when character coords were known exactly
int s_STR; ///< STR base stat
int s_DEX; ///< DEX base stat
int s_CON; ///< CON base stat
int s_INT; ///< INT base stat
int s_WIT; ///< WIT base stat
int s_MEN; ///< MEN base stat
int pAtk;
int pDef;
int mAtk;
int mDef;
int pAtkSpd;
int mAtkSpd;
int accuracy;
int evasion;
int critical;
double curHp; ///< current HP value
double maxHp; ///< maximum HP value
double curMp; ///< current MP value
double maxMp; ///< maximum MP value
double curCp; ///< current CP value
double maxCp; ///< maximum CP value
unsigned int abnormalEffect; ///< flags for visible buffs/defuffs: poison, medusa, bleed, ...
unsigned int targetObjectID; ///< objectID of object which is targeted by this character
int isInCombat; ///< 1, if char is in combat state, 0 if not
double collisionRadius;
double collisionHeight;
int pvpFlag;
int karma;
unsigned int clanID;
unsigned int clanCrestID;
unsigned int clanCrestLargeID;
unsigned int allyID;
unsigned int allyCrestID;
};
#endif

View File

@@ -0,0 +1,30 @@
#ifndef H_L2_CHAT_MESSAGE_TYPES
#define H_L2_CHAT_MESSAGE_TYPES
/** \class L2_CHAT_MESSAGE
* Defines constants used in S->C CreatureSay and C->S Say2 packets.\n
* Chat message type.
*/
class L2_CHAT_MESSAGE
{
public:
static const unsigned int ALL = 0;
static const unsigned int SHOUT = 1; //!
static const unsigned int TELL = 2;
static const unsigned int PARTY = 3; //#
static const unsigned int CLAN = 4; //@
static const unsigned int GM = 5;
static const unsigned int PETITION_PLAYER = 6; // used for petition
static const unsigned int PETITION_GM = 7; //* used for petition
static const unsigned int TRADE = 8; //+
static const unsigned int ALLIANCE = 9; //$
static const unsigned int ANNOUNCEMENT = 10;
static const unsigned int PARTYROOM_ALL = 16; //(Red)
static const unsigned int PARTYROOM_COMMANDER = 15; //(Yellow)
static const unsigned int HERO_VOICE = 17;
static const unsigned int L2_CHAT_MESSAGE_LAST = HERO_VOICE;
};
#endif

View File

@@ -0,0 +1,39 @@
#include "stdafx.h"
#include "L2ElementalInfo.h"
L2ElementalInfo::L2ElementalInfo()
{
clear();
}
L2ElementalInfo::L2ElementalInfo( const L2ElementalInfo& other )
{
clear();
this->operator=( other );
}
const L2ElementalInfo& L2ElementalInfo::operator=( const L2ElementalInfo& other )
{
if( this == &other ) return (*this);
attackElementType = other.attackElementType;
attackElementValue = other.attackElementValue;
defAttrFire = other.defAttrFire;
defAttrWater = other.defAttrWater;
defAttrWind = other.defAttrWind;
defAttrEarth = other.defAttrEarth;
defAttrHoly = other.defAttrHoly;
defAttrUnholy = other.defAttrUnholy;
return (*this);
}
void L2ElementalInfo::clear()
{
attackElementType = 0;
attackElementValue = 0;
defAttrFire = 0;
defAttrWater = 0;
defAttrWind = 0;
defAttrEarth = 0;
defAttrHoly = 0;
defAttrUnholy = 0;
}

View File

@@ -0,0 +1,23 @@
#ifndef H_L2_ELEMENTAL_INFO
#define H_L2_ELEMENTAL_INFO
class L2ElementalInfo
{
public:
L2ElementalInfo();
L2ElementalInfo( const L2ElementalInfo& other );
const L2ElementalInfo& operator=( const L2ElementalInfo& other );
public:
void clear();
public:
int attackElementType;
int attackElementValue;
int defAttrFire;
int defAttrWater;
int defAttrWind;
int defAttrEarth;
int defAttrHoly;
int defAttrUnholy;
};
#endif

View File

@@ -0,0 +1,118 @@
#include "stdafx.h"
#include "L2Experience.h"
double L2Experience::getExpPercent( long long exp )
{
double ret = 0.0;
#ifndef __GNUC__
const long long int exp_at_level[] =
#else
const double exp_at_level[] =
#endif
{
-1, // level 0 (unreachable)
0,
68,
363,
1168,
2884,
6038,
11287,
19423,
31378,
48229, //level 10
71201,
101676,
141192,
191452,
254327,
331864,
426284,
539995,
675590,
835854, //level 20
1023775,
1242536,
1495531,
1786365,
2118860,
2497059,
2925229,
3407873,
3949727,
4555766, //level 30
5231213,
5981539,
6812472,
7729999,
8740372,
9850111,
11066012,
12395149,
13844879,
15422851, //level 40
17137002,
18995573,
21007103,
23180442,
25524751,
28049509,
30764519,
33679907,
36806133,
40153995, //level 50
45524865,
51262204,
57383682,
63907585,
70852742,
80700339,
91162131,
102265326,
114038008,
126509030, //level 60
146307211,
167243291,
189363788,
212716741,
237351413,
271973532,
308441375,
346825235,
387197529,
429632402, //level 70
474205751,
532692055,
606319094,
696376867,
804219972,
931275828,
1151275834,
1511275834,
#ifdef __GNUC__
2099275834.0,
4200000000.0, //level 80
6300000000.0, //level 81
8820000000.0, //level 82
11844000000.0, //level 83
15472800000.0, //level 84
19827360000.0, //level 85
25314000000.0
#else
2099275834,
4200000000, //level 80
6300000000, //level 81
8820000000, //level 82
11844000000, //level 83
15472800000, //level 84
19827360000, //level 85
25314000000
#endif
};
int i = 0;
//int cur_level = 0;
for( i=0; i<86; i++ ) if( exp_at_level[i+1] > exp ) break;
//cur_level = i;
ret = 100.0 * (exp - exp_at_level[i]) / (exp_at_level[i+1] - exp_at_level[i]);
return ret;
}

View File

@@ -0,0 +1,28 @@
#ifndef H_L2_EXPERIENCE_
#define H_L2_EXPERIENCE_
/** \class L2Experience
* Some functions and constants to work with player exp values.
*/
class L2Experience
{
public:
/**
* Converts exp value to current exp percent.
* \param exp current experience value
* \return precent value in current level
*/
static double getExpPercent( long long exp );
public:
/**
* This is the first UNREACHABLE level.<BR>
* ex: If you want a max at 85 & 100.00%, you have to put 86.<BR><BR>
*/
static const int MAX_LEVEL = 86;
static const int MIN_NEWBIE_LEVEL = 6;
static const int MAX_NEWBIE_LEVEL = 39;
};
#endif

139
l2packets/l2world/L2Npc.cpp Normal file
View File

@@ -0,0 +1,139 @@
#include "stdafx.h"
#include "L2Npc.h"
#include "../l2data/L2Data.h"
#include "../game/L2GamePacket.h"
#include "../os/os_abstraction.h"
L2Npc::L2Npc()
{
setUnused();
}
L2Npc::~L2Npc()
{
setUnused();
}
L2Npc::L2Npc( const L2Npc& other ): L2Character()
{
setUnused();
operator=( other );
}
const L2Npc& L2Npc::operator=( const L2Npc& other )
{
if( this == &other ) return (*this);
L2Character::operator=( other );
templateID = other.templateID;
isAttackable = other.isAttackable;
iid_left_hand = other.iid_left_hand;
iid_right_hand = other.iid_right_hand;
iid_chest = other.iid_chest;
return (*this);
}
void L2Npc::setUnused()
{
L2Character::setUnused();
templateID = 0;
isAttackable = 0;
// weapon
iid_left_hand = iid_right_hand = iid_chest = 0;
}
void L2Npc::setNpcNameTitleByTemplate()
{
char db_name[256], db_title[256];
db_name[0] = db_title[0] = 0;
if( L2Data_DB_GetNPCNameTitleByID( templateID, db_name, db_title ) )
{
setName( db_name );
setTitle( db_title );
}
}
bool L2Npc::parse_NpcInfo( void *l2_game_packet, L2_VERSION l2_version )
{
if( !l2_game_packet ) return false;
L2GamePacket *p = (L2GamePacket *)l2_game_packet;
// parse
unsigned char ptype = p->getPacketType();
if( ptype != 0x0C ) return false; // 0x0C NpcInfo
//
objectID = p->readUInt();
templateID = p->readUInt() - 1000000; // ? :) L2J adds 1000000 to this field
isAttackable = p->readD(); // _isAttackable
x = p->readD();
y = p->readD();
z = p->readD();
heading = p->readUInt();
p->readD(); // 0x00
mAtkSpd = p->readD();
pAtkSpd = p->readD();
runSpeed = p->readD();
walkSpeed = p->readD();
p->readD(); // swim run speed
p->readD(); // swim walk speed
p->readD(); // fl run speed (?)
p->readD(); // fl walk speed (?)
p->readD(); // fly run speed (?) same as fl
p->readD(); // fly walk speed (?)
double moveSpeedMultiplier = p->readF();
double attackSpeedMultiplier = p->readF();
if( moveSpeedMultiplier > 0 )
{
runSpeed = (int)( ((double)runSpeed) * moveSpeedMultiplier );
walkSpeed = (int)( ((double)walkSpeed) * moveSpeedMultiplier );
}
if( attackSpeedMultiplier > 0 ) pAtkSpd = (int)( ((double)pAtkSpd) * attackSpeedMultiplier );
collisionRadius = p->readF();
collisionHeight = p->readF();
iid_right_hand = p->readUInt();
iid_chest = p->readUInt();
iid_left_hand = p->readUInt();
p->readC(); // has title
isRunning = p->readC();
isInCombat = p->readC();
isAlikeDead = p->readC();
p->readC(); // is summoned
setName( p->readUnicodeStringPtr() );
setTitle( p->readUnicodeStringPtr() );
p->readD(); // title color
p->readD(); // 0x00
pvpFlag = p->readD(); // pvp flag
abnormalEffect = p->readUInt();
clanID = p->readUInt(); // Gracia Final
clanCrestID = p->readUInt(); // Gracia Final
isFlying = p->readC(); // Gracia Final
p->readC(); // 0x00
p->readF(); // collisionRadius (again?)
p->readF(); // collisionHeight (again?)
p->readD(); // 0x00
p->readD(); // isFlying? (again?) Gracia Final
p->readD(); // 0x00
p->readD(); // pet form and skills (?)
// Gracia Final has some more to read
if( l2_version >= L2_VERSION_T23 )
{
p->readC(); // 0x01
p->readC(); // 0x01
p->readD(); // 0x00000000
}
// set last time when npc coordinates were known exactly
lastMoveTickTime = OS_GetTickCount();
return true;
}

67
l2packets/l2world/L2Npc.h Normal file
View File

@@ -0,0 +1,67 @@
#ifndef H_L2NPC
#define H_L2NPC
#include "L2Character.h"
/** \class L2Npc
Every L2Npc is L2Character:\n
Every L2Character is L2Object (has objectID, x, y, z)\n
Every L2Character has LEVEL!\n
Every L2Character has its charName and charTitle\n
Every L2Character has its heading\n
Every L2Character has moving speed in states: running, walking\n
Every L2Character has its move destination: xDst, yDst, zDst\n
Every l2Character can calc its position based on destnation point and time passed since last calc\n
Every L2Character has its base stats: INT WIT MEN CON STR DEX\n
Every L2Character has its stats: pAtk, mAtk, ..., curHp, maxHp, ...\n
Every L2Character has abnormalEffect\n
Every L2Character has its target\n
Every L2Character can be in combat\n
Every L2Character has its collision radius and height\n
\n
Additionally:\n
Every L2Npc has its NPC templateID\n
Every L2Npc can be attackable or not (attackable is mob, other is NPC. chooses default action on click)\n
Every L2Npc has weapon/shield or bow/arrow in left/right hand\n
*/
class L2Npc : public L2Character
{
public:
/** Default constructor calls setUnused() (zeroes all members) */
L2Npc();
/** Copy constructor
* \param other source to copy from
*/
L2Npc( const L2Npc& other );
/* Assigns all members of L2Npc class instance to other
* \param other source to copy from
* \return reference to this object */
virtual const L2Npc& operator=( const L2Npc& other );
/** Default destructor calls setUnused() (zeroes all members) */
virtual ~L2Npc();
public:
/** Initializes object's state (zeroes all members)
* \return none
*/
virtual void setUnused();
public:
/** Query database for name and title, using this object's templateID, and set them */
virtual void setNpcNameTitleByTemplate();
public:
bool parse_NpcInfo( void *l2_game_packet, L2_VERSION l2_version );
public:
unsigned int templateID; ///< NPC template ID
int isAttackable; ///< =1, if npc is auto attackable on double click (mob); 0 if double click begins chat with NPC (NPC)
unsigned int iid_left_hand; ///< item ID of left hand weapon item
unsigned int iid_chest; ///< item ID of chest (?)
unsigned int iid_right_hand; ///< item ID of right hand weapon item
};
#endif

View File

@@ -0,0 +1,27 @@
#include "stdafx.h"
#include "L2Object.h"
L2Object::~L2Object()
{
setUnused();
}
L2Object::L2Object( const L2Object& other )
{
this->operator=( other );
}
const L2Object& L2Object::operator=( const L2Object& other )
{
if( this == &other ) return (*this);
this->x = other.x;
this->y = other.y;
this->z = other.z;
this->objectID = other.objectID;
return (*this);
}
bool L2Object::operator==( const L2Object& other )
{
return this->objectID == other.objectID;
}

View File

@@ -0,0 +1,64 @@
#ifndef H_L2OBJECT
#define H_L2OBJECT
#include "../L2_versions.h"
/** \class L2Object
Every object has its objectID and can also have its coordinates in L2World
*/
class L2Object
{
public:
/** L2Object default constructor
*/
L2Object(): x(0), y(0), z(0), objectID(0) {}
/** L2Object copy constructor
* \param other copy source
*/
L2Object( const L2Object& other );
/** Assigns this->x,y,z,objectID to other's x,y,z,objectID
* \param other copy source
* \return reference to this object
*/
virtual const L2Object& operator=( const L2Object& other );
/** Compares objectIDs
* \param other object to compare with
* \return true, if objects are equal (equal objectIDs)
*/
virtual bool operator==( const L2Object& other );
/** Destructor calls setUnused()
* \see setUnused
*/
virtual ~L2Object();
public:
/** Sets object coordinates in world
* \param sx, sy, sz - new coordinates
* \return none
*/
virtual void setXYZ( int sx, int sy, int sz ) { x = sx; y = sy; z = sz; }
public:
/** Test objectID
* \return 1, if objectID == 0; 0 if objectID is nonzero.
*/
virtual int isUnused() const { return (objectID == 0); }
/** Initializes object's state, zeroes all members (sets coords to 0, objectID to 0)
* \return none
*/
virtual void setUnused() { objectID = 0; x = 0; y = 0; z = 0; }
public:
/** object's X coordinate */
int x;
/** object's Y coordinate */
int y;
/** object's Z coordinate */
int z;
/** objectID is unique in game world */
unsigned int objectID;
};
#endif

View File

@@ -0,0 +1,678 @@
#include "stdafx.h"
#include "L2Player.h"
#include "../l2data/L2Data.h"
#include "../game/L2GamePacket.h"
#include "../os/os_abstraction.h"
L2Player::L2Player()
{
setUnused();
}
L2Player::~L2Player()
{
setUnused();
}
L2Player::L2Player( const L2Player& other ): L2Character()
{
setUnused();
this->operator=( other );
}
const L2Player& L2Player::operator=( const L2Player& other )
{
if( this == &other ) return (*this); // self-assign
L2Character::operator=( other );
//
int i;
//
classID = other.classID;
baseClassID = other.baseClassID;
race = other.race;
sex = other.sex;
hairStyle = other.hairStyle;
hairColor = other.hairColor;
face = other.face;
experience = other.experience;
skill_points = other.skill_points;
curLoad = other.curLoad;
maxLoad = other.maxLoad;
pkKills = other.pkKills;
pvpKills = other.pvpKills;
enchantEffect = other.enchantEffect;
relation = other.relation;
autoAttackable = other.autoAttackable;
for( i=0; i<32; i++ )
{
paperdoll_oid[i] = other.paperdoll_oid[i];
paperdoll_iid[i] = other.paperdoll_iid[i];
paperdoll_augid[i] = other.paperdoll_augid[i];
}
isFakeDeath = other.isFakeDeath;
isFishing = other.isFishing;
fishX = other.fishX;
fishY = other.fishY;
fishZ = other.fishZ;
privateStoreType = other.privateStoreType;
wcsncpy( privateStoreMsgBuy, other.privateStoreMsgBuy, 64 );
privateStoreMsgBuy[63] = 0;
wcsncpy( privateStoreMsgSell, other.privateStoreMsgSell, 64 );
privateStoreMsgSell[63] = 0;
wcsncpy( privateStoreMsgRecipe, other.privateStoreMsgRecipe, 64 );
privateStoreMsgRecipe[63] = 0;
mountType = other.mountType;
mountNpcId = other.mountNpcId;
recomLeft = other.recomLeft;
recomHave = other.recomHave;
isNoble = other.isNoble;
isHero = other.isHero;
nameColor = other.nameColor;
titleColor = other.titleColor;
pledgeClass = other.pledgeClass;
pledgeType = other.pledgeType;
cursedWeaponId = other.cursedWeaponId;
clanRepScore = other.clanRepScore;
transformId = other.transformId;
agathionId = other.agathionId;
vehicleObjectId = other.vehicleObjectId;
hasDwarvenCraft = other.hasDwarvenCraft;
numCubics = other.numCubics;
for( i=0; i<4; i++ ) cubicId[i] = other.cubicId[i];
clanPrivs = other.clanPrivs;
inventoryLimit = other.inventoryLimit;
elements = other.elements;
fame = other.fame;
vitalityLevel = other.vitalityLevel;
//
return (*this);
}
void L2Player::setUnused()
{
L2Character::setUnused();
classID = baseClassID = 0;
clanID = clanCrestID = clanCrestLargeID = allyID = allyCrestID = 0;
race = sex = 0;
hairStyle = hairColor = face = 0;
experience = 0;
skill_points = 0;
curLoad = maxLoad = 0;
pkKills = pvpKills = 0;
relation = RELATION_NONE;
autoAttackable = 0;
int i;
for( i=0; i<32; i++ )
{
paperdoll_oid[i] = 0;
paperdoll_iid[i] = 0;
paperdoll_augid[i] = 0;
}
isFishing = 0;
fishX = fishY = fishZ = 0;
privateStoreType = 0;
privateStoreMsgBuy[0] = privateStoreMsgSell[0] = privateStoreMsgRecipe[0] = 0;
mountType = mountNpcId = 0;
recomLeft = recomHave = 0;
isNoble = isHero = 0;
nameColor = titleColor = 0;
pledgeClass = pledgeType = 0;
cursedWeaponId = transformId = agathionId = 0;
clanRepScore = 0;
vehicleObjectId = 0;
hasDwarvenCraft = 0;
numCubics = 0;
for( i=0; i<4; i++ ) cubicId[i] = 0;
clanPrivs = 0;
inventoryLimit = 0;
elements.clear();
}
void L2Player::getRaceStr( wchar_t *out ) const
{
if( !out ) return;
out[0] = 0;
const char *ansi = L2Data_getRace( this->race );
#ifdef L2PACKETS_WINDOWS
_snwprintf( out, 32, L"%S", ansi );
#endif
#ifdef L2PACKETS_LINUX
swprintf( out, 32, L"%ls", ansi );
#endif
out[31] = 0;
}
void L2Player::getSexStr( wchar_t *out ) const
{
if( !out ) return;
out[0] = 0;
const char *ansi = L2Data_getSex( this->sex );
#ifdef L2PACKETS_WINDOWS
_snwprintf( out, 32, L"%S", ansi );
#endif
#ifdef L2PACKETS_LINUX
swprintf( out, 32, L"%ls", ansi );
#endif
out[31] = 0;
}
void L2Player::getClassStr( wchar_t *out ) const
{
if( !out ) return;
out[0] = 0;
const char *ansi = L2Data_getClass( this->classID );
#ifdef L2PACKETS_WINDOWS
_snwprintf( out, 32, L"%S", ansi );
#endif
#ifdef L2PACKETS_LINUX
swprintf( out, 32, L"%ls", ansi );
#endif
out[31] = 0;
}
void L2Player::getBaseClassStr( wchar_t *out ) const
{
if( !out ) return;
out[0] = 0;
const char *ansi = L2Data_getClass( this->baseClassID );
#ifdef L2PACKETS_WINDOWS
_snwprintf( out, 32, L"%S", ansi );
#endif
#ifdef L2PACKETS_LINUX
swprintf( out, 32, L"%ls", ansi );
#endif
}
bool L2Player::parse_CharInfo( void *l2_game_packet, L2_VERSION l2_version )
{
if( !l2_game_packet ) return false;
int i;
L2GamePacket *p = (L2GamePacket *)l2_game_packet;
// parse
unsigned char ptype = p->getPacketType(); // 0x31
if( ptype != 0x31 ) return false;
x = p->readInt(); // x
y = p->readInt(); // y
z = p->readInt(); // z
p->readUInt(); // 0x00
objectID = p->readUInt(); // objectID
setName( p->readUnicodeStringPtr() ); // name
race = p->readUInt(); // race
sex = p->readInt(); // sex (0-male)
baseClassID = p->readUInt(); // base class
// paperdoll item IDs
paperdoll_iid[L2_PAPERDOLL_UNDER] = p->readUInt(); // PAPERDOLL_UNDER
paperdoll_iid[L2_PAPERDOLL_HEAD] = p->readUInt(); // PAPERDOLL_HEAD
paperdoll_iid[L2_PAPERDOLL_RHAND] = p->readUInt(); // PAPERDOLL_RHAND
paperdoll_iid[L2_PAPERDOLL_LHAND] = p->readUInt(); // PAPERDOLL_LHAND
paperdoll_iid[L2_PAPERDOLL_GLOVES] = p->readUInt(); // PAPERDOLL_GLOVES
paperdoll_iid[L2_PAPERDOLL_CHEST] = p->readUInt(); // PAPERDOLL_CHEST
paperdoll_iid[L2_PAPERDOLL_LEGS] = p->readUInt(); // PAPERDOLL_LEGS
paperdoll_iid[L2_PAPERDOLL_FEET] = p->readUInt(); // PAPERDOLL_FEET
paperdoll_iid[L2_PAPERDOLL_BACK] = p->readUInt(); // PAPERDOLL_BACK
paperdoll_iid[L2_PAPERDOLL_LRHAND] = p->readUInt(); // PAPERDOLL_LRHAND
paperdoll_iid[L2_PAPERDOLL_HAIR] = p->readUInt(); // PAPERDOLL_HAIR
paperdoll_iid[L2_PAPERDOLL_HAIR2] = p->readUInt(); // PAPERDOLL_HAIR2
// kamael
paperdoll_iid[L2_PAPERDOLL_RBRACELET] = p->readUInt(); // PAPERDOLL_RBRACELET
paperdoll_iid[L2_PAPERDOLL_LBRACELET] = p->readUInt(); // PAPERDOLL_LBRACELET
paperdoll_iid[L2_PAPERDOLL_DECO1] = p->readUInt(); // PAPERDOLL_DECO1
paperdoll_iid[L2_PAPERDOLL_DECO2] = p->readUInt(); // PAPERDOLL_DECO2
paperdoll_iid[L2_PAPERDOLL_DECO3] = p->readUInt(); // PAPERDOLL_DECO3
paperdoll_iid[L2_PAPERDOLL_DECO4] = p->readUInt(); // PAPERDOLL_DECO4
paperdoll_iid[L2_PAPERDOLL_DECO5] = p->readUInt(); // PAPERDOLL_DECO5
paperdoll_iid[L2_PAPERDOLL_DECO6] = p->readUInt(); // PAPERDOLL_DECO6
//
if( l2_version >= L2_VERSION_T23 )
paperdoll_iid[L2_PAPERDOLL_BELT] = p->readUInt(); // PAPERDOLL_BELT
// paperdoll augmentation IDs
paperdoll_augid[L2_PAPERDOLL_UNDER] = p->readUInt(); // PAPERDOLL_UNDER
paperdoll_augid[L2_PAPERDOLL_HEAD] = p->readUInt(); // PAPERDOLL_HEAD
paperdoll_augid[L2_PAPERDOLL_RHAND] = p->readUInt(); // PAPERDOLL_RHAND
paperdoll_augid[L2_PAPERDOLL_LHAND] = p->readUInt(); // PAPERDOLL_LHAND
paperdoll_augid[L2_PAPERDOLL_GLOVES] = p->readUInt(); // PAPERDOLL_GLOVES
paperdoll_augid[L2_PAPERDOLL_CHEST] = p->readUInt(); // PAPERDOLL_CHEST
paperdoll_augid[L2_PAPERDOLL_LEGS] = p->readUInt(); // PAPERDOLL_LEGS
paperdoll_augid[L2_PAPERDOLL_FEET] = p->readUInt(); // PAPERDOLL_FEET
paperdoll_augid[L2_PAPERDOLL_BACK] = p->readUInt(); // PAPERDOLL_BACK
paperdoll_augid[L2_PAPERDOLL_LRHAND] = p->readUInt(); // PAPERDOLL_LRHAND
paperdoll_augid[L2_PAPERDOLL_HAIR] = p->readUInt(); // PAPERDOLL_HAIR
paperdoll_augid[L2_PAPERDOLL_HAIR2] = p->readUInt(); // PAPERDOLL_HAIR2
// kamael
paperdoll_augid[L2_PAPERDOLL_RBRACELET] = p->readUInt(); // PAPERDOLL_RBRACELET
paperdoll_augid[L2_PAPERDOLL_LBRACELET] = p->readUInt(); // PAPERDOLL_LBRACELET
paperdoll_augid[L2_PAPERDOLL_DECO1] = p->readUInt(); // PAPERDOLL_DECO1
paperdoll_augid[L2_PAPERDOLL_DECO2] = p->readUInt(); // PAPERDOLL_DECO2
paperdoll_augid[L2_PAPERDOLL_DECO3] = p->readUInt(); // PAPERDOLL_DECO3
paperdoll_augid[L2_PAPERDOLL_DECO4] = p->readUInt(); // PAPERDOLL_DECO4
paperdoll_augid[L2_PAPERDOLL_DECO5] = p->readUInt(); // PAPERDOLL_DECO5
paperdoll_augid[L2_PAPERDOLL_DECO6] = p->readUInt(); // PAPERDOLL_DECO6
//
if( l2_version >= L2_VERSION_T23 )
paperdoll_augid[L2_PAPERDOLL_BELT] = p->readUInt(); // PAPERDOLL_BELT
// Gracia Final 2.3
if( l2_version == L2_VERSION_T23 )
{
p->readD();
p->readD();
}
pvpFlag = p->readUInt(); // pvp flag
karma = p->readInt(); // karma
mAtkSpd = p->readInt(); // cast speed
pAtkSpd = p->readInt(); // atk speed
pvpFlag = p->readUInt(); // pvp flag
karma = p->readInt(); // karma
runSpeed = p->readInt(); // run spd
walkSpeed = p->readInt(); // walk spd
p->readInt(); // _swimRunSpd (?)
p->readInt(); // _swimWalkSpd (?)
p->readInt(); // _flRunSpd (?)
p->readInt(); // _flWalkSpd (?)
p->readInt(); // _flyRunSpd (?)
p->readInt(); // _flyWalkSpd (?)
double moveMult = p->readDouble(); // move spd mult
double atkMult = p->readDouble(); // atk spd mult
// apply multipliers
if( moveMult > 0 )
{
runSpeed = (int)( ((double)(runSpeed)) * moveMult );
walkSpeed = (int)( ((double)(walkSpeed)) * moveMult );
}
if( atkMult > 0 ) pAtkSpd = (int)( ((double)(pAtkSpd)) * atkMult );
collisionRadius = p->readF(); // collisionRadius
collisionHeight = p->readF(); // collisionHeight
hairStyle = p->readInt();
hairColor = p->readInt();
face = p->readInt();
setTitle( p->readUnicodeStringPtr() ); // title
clanID = p->readUInt();
clanCrestID = p->readInt();
allyID = p->readInt();
allyCrestID = p->readInt();
p->readInt(); // relation(?), which is always 0
isSitting = (int)(!p->readUChar()); // standing = 1 sitting = 0
isRunning = (int)p->readUChar(); // running = 1 walking = 0
isInCombat = (int)p->readUChar();
isAlikeDead = (int)p->readUChar();
p->readUChar(); // invisible = 1 visible =0
this->mountType = p->readUChar(); // 1-on Strider, 2-on Wyvern, 3-on Great Wolf, 0-no mount
this->privateStoreType = p->readUChar(); // 1 - sellshop
// cubics
numCubics = (int)p->readUShort(); // cubics count
if( numCubics > 4 ) numCubics = 4;
for( i=0; i<numCubics; i++ )
cubicId[i] = (unsigned int)p->readUShort(); // cubic ID
p->readUChar(); // find party members
abnormalEffect = p->readUInt(); // abnormalEffect
recomLeft = (int)p->readUChar();
recomHave = (int)p->readUShort(); // Blue value for name (0 = white, 255 = pure blue)
mountNpcId = p->readUInt() - 1000000; // mountNpcId + 1000000
classID = p->readUInt(); // class ID
p->readUInt(); // 0x00
enchantEffect = (unsigned int)p->readUChar();
p->readUChar(); // team circle around feet 1 = Blue, 2 = red
clanCrestLargeID = p->readUInt();
isNoble = p->readUChar();
isHero = p->readUChar(); // hero aura
isFishing = p->readUChar(); // 0x01: Fishing Mode (Cant be undone by setting back to 0)
fishX = p->readInt();
fishY = p->readInt();
fishZ = p->readInt();
nameColor = p->readInt();
heading = p->readUInt();
pledgeClass = p->readUInt(); // PledgeClass
pledgeType = p->readUInt(); // PledgeType
titleColor = p->readUInt(); // TitleColor
cursedWeaponId = p->readUInt(); // CursedWeaponEquippedId
clanRepScore = p->readInt(); // clan ReputationScore
// T1
transformId = p->readUInt(); // TransformationId
agathionId = p->readUInt(); // AgathionId
// T2
//writeD(0x01);
// T2.3
//writeD(0x00);
//writeD(0x00);
//writeD(0x00);
//writeD(0x00);
// set last time when char coordinates were known exactly
lastMoveTickTime = OS_GetTickCount();
return true;
}
bool L2Player::parse_UserInfo( void *l2_game_packet, L2_VERSION l2_version )
{
if( !l2_game_packet ) return false;
unsigned int tempUINT;
int i;
L2GamePacket *p = (L2GamePacket *)l2_game_packet;
unsigned char ptype = p->getPacketType();
if( ptype != 0x32 ) return false;
x = p->readInt();
y = p->readInt();
z = p->readInt();
if( l2_version <= L2_VERSION_T22 ) heading = p->readUInt();
else if( l2_version >= L2_VERSION_T23 ) vehicleObjectId = p->readUInt();
objectID = p->readUInt();
setName( p->readUnicodeStringPtr() );
race = p->readInt();
sex = p->readInt();
baseClassID = p->readUInt();
level = p->readInt();
experience = p->readUInt64();
s_STR = p->readInt(); // writeD(_activeChar.getSTR());
s_DEX = p->readInt(); // writeD(_activeChar.getDEX());
s_CON = p->readInt(); // writeD(_activeChar.getCON());
s_INT = p->readInt(); // writeD(_activeChar.getINT());
s_WIT = p->readInt(); // writeD(_activeChar.getWIT());
s_MEN = p->readInt(); // writeD(_activeChar.getMEN());
maxHp = (double)p->readInt(); // writeD(_activeChar.getMaxHp());
curHp = (double)p->readInt(); // writeD((int) _activeChar.getCurrentHp());
maxMp = (double)p->readInt(); // writeD(_activeChar.getMaxMp());
curMp = (double)p->readInt(); //writeD((int) _activeChar.getCurrentMp());
skill_points = p->readUInt(); // writeD(_activeChar.getSp());
curLoad = p->readUInt(); // writeD(_activeChar.getCurrentLoad());
maxLoad = p->readUInt(); // writeD(_activeChar.getMaxLoad());
//writeD(_activeChar.getActiveWeaponItem() != null ? 0x40 : 0x20); // 0x20 no weapon, 0x40 weapon equipped
bool isWeaponEquipped = false; // why?... cannot we check weapon paperdoll objectId/itemId?
tempUINT = p->readUInt();
if( tempUINT == 0x40 ) isWeaponEquipped = true;
// paperdoll and its augments
// paperdoll objectIDs (25 items)
paperdoll_oid[L2_PAPERDOLL_UNDER] = p->readUInt(); // Inventory.PAPERDOLL_UNDER));
paperdoll_oid[L2_PAPERDOLL_REAR] = p->readUInt(); // writeD(....PAPERDOLL_REAR));
paperdoll_oid[L2_PAPERDOLL_LEAR] = p->readUInt(); // writeD(....PAPERDOLL_LEAR));
paperdoll_oid[L2_PAPERDOLL_NECK] = p->readUInt(); // writeD(....PAPERDOLL_NECK));
paperdoll_oid[L2_PAPERDOLL_RFINGER] = p->readUInt(); // writeD(....PAPERDOLL_RFINGER));
paperdoll_oid[L2_PAPERDOLL_LFINGER] = p->readUInt(); // writeD(....PAPERDOLL_LFINGER));
paperdoll_oid[L2_PAPERDOLL_HEAD] = p->readUInt(); // writeD(....PAPERDOLL_HEAD));
paperdoll_oid[L2_PAPERDOLL_RHAND] = p->readUInt(); // writeD(....PAPERDOLL_RHAND));
paperdoll_oid[L2_PAPERDOLL_LHAND] = p->readUInt(); // writeD(....PAPERDOLL_LHAND));
paperdoll_oid[L2_PAPERDOLL_GLOVES] = p->readUInt(); // writeD(....PAPERDOLL_GLOVES));
paperdoll_oid[L2_PAPERDOLL_CHEST] = p->readUInt(); // writeD(....PAPERDOLL_CHEST));
paperdoll_oid[L2_PAPERDOLL_LEGS] = p->readUInt(); // writeD(....PAPERDOLL_LEGS));
paperdoll_oid[L2_PAPERDOLL_FEET] = p->readUInt(); // writeD(....PAPERDOLL_FEET));
paperdoll_oid[L2_PAPERDOLL_BACK] = p->readUInt(); // writeD(....PAPERDOLL_BACK));
paperdoll_oid[L2_PAPERDOLL_LRHAND] = p->readUInt(); // writeD(....PAPERDOLL_LRHAND));
paperdoll_oid[L2_PAPERDOLL_HAIR] = p->readUInt(); // writeD(....PAPERDOLL_HAIR));
paperdoll_oid[L2_PAPERDOLL_HAIR2] = p->readUInt(); // writeD(....PAPERDOLL_HAIR2));
// T1 new D's
paperdoll_oid[L2_PAPERDOLL_RBRACELET] = p->readUInt(); // writeD(....PAPERDOLL_RBRACELET));
paperdoll_oid[L2_PAPERDOLL_LBRACELET] = p->readUInt(); // writeD(....PAPERDOLL_LBRACELET));
paperdoll_oid[L2_PAPERDOLL_DECO1] = p->readUInt(); // writeD(....PAPERDOLL_DECO1));
paperdoll_oid[L2_PAPERDOLL_DECO2] = p->readUInt(); // writeD(....PAPERDOLL_DECO2));
paperdoll_oid[L2_PAPERDOLL_DECO3] = p->readUInt(); // writeD(....PAPERDOLL_DECO3));
paperdoll_oid[L2_PAPERDOLL_DECO4] = p->readUInt(); // writeD(....PAPERDOLL_DECO4));
paperdoll_oid[L2_PAPERDOLL_DECO5] = p->readUInt(); // writeD(....PAPERDOLL_DECO5));
paperdoll_oid[L2_PAPERDOLL_DECO6] = p->readUInt(); // writeD(....PAPERDOLL_DECO6));
if( l2_version >= L2_VERSION_T23 )
paperdoll_oid[L2_PAPERDOLL_BELT] = p->readUInt(); // PAPERDOLL_BELT
// paperdoll itemIDs (25 items)
paperdoll_iid[L2_PAPERDOLL_UNDER] = p->readUInt(); // Inventory.PAPERDOLL_UNDER));
paperdoll_iid[L2_PAPERDOLL_REAR] = p->readUInt(); // writeD(....PAPERDOLL_REAR));
paperdoll_iid[L2_PAPERDOLL_LEAR] = p->readUInt(); // writeD(....PAPERDOLL_LEAR));
paperdoll_iid[L2_PAPERDOLL_NECK] = p->readUInt(); // writeD(....PAPERDOLL_NECK));
paperdoll_iid[L2_PAPERDOLL_RFINGER] = p->readUInt(); // writeD(....PAPERDOLL_RFINGER));
paperdoll_iid[L2_PAPERDOLL_LFINGER] = p->readUInt(); // writeD(....PAPERDOLL_LFINGER));
paperdoll_iid[L2_PAPERDOLL_HEAD] = p->readUInt(); // writeD(....PAPERDOLL_HEAD));
paperdoll_iid[L2_PAPERDOLL_RHAND] = p->readUInt(); // writeD(....PAPERDOLL_RHAND));
paperdoll_iid[L2_PAPERDOLL_LHAND] = p->readUInt(); // writeD(....PAPERDOLL_LHAND));
paperdoll_iid[L2_PAPERDOLL_GLOVES] = p->readUInt(); // writeD(....PAPERDOLL_GLOVES));
paperdoll_iid[L2_PAPERDOLL_CHEST] = p->readUInt(); // writeD(....PAPERDOLL_CHEST));
paperdoll_iid[L2_PAPERDOLL_LEGS] = p->readUInt(); // writeD(....PAPERDOLL_LEGS));
paperdoll_iid[L2_PAPERDOLL_FEET] = p->readUInt(); // writeD(....PAPERDOLL_FEET));
paperdoll_iid[L2_PAPERDOLL_BACK] = p->readUInt(); // writeD(....PAPERDOLL_BACK));
paperdoll_iid[L2_PAPERDOLL_LRHAND] = p->readUInt(); // writeD(....PAPERDOLL_LRHAND));
paperdoll_iid[L2_PAPERDOLL_HAIR] = p->readUInt(); // writeD(....PAPERDOLL_HAIR));
paperdoll_iid[L2_PAPERDOLL_HAIR2] = p->readUInt(); // writeD(....PAPERDOLL_HAIR2));
// T1 new D's
paperdoll_iid[L2_PAPERDOLL_RBRACELET] = p->readUInt(); // writeD(....PAPERDOLL_RBRACELET));
paperdoll_iid[L2_PAPERDOLL_LBRACELET] = p->readUInt(); // writeD(....PAPERDOLL_LBRACELET));
paperdoll_iid[L2_PAPERDOLL_DECO1] = p->readUInt(); // writeD(....PAPERDOLL_DECO1));
paperdoll_iid[L2_PAPERDOLL_DECO2] = p->readUInt(); // writeD(....PAPERDOLL_DECO2));
paperdoll_iid[L2_PAPERDOLL_DECO3] = p->readUInt(); // writeD(....PAPERDOLL_DECO3));
paperdoll_iid[L2_PAPERDOLL_DECO4] = p->readUInt(); // writeD(....PAPERDOLL_DECO4));
paperdoll_iid[L2_PAPERDOLL_DECO5] = p->readUInt(); // writeD(....PAPERDOLL_DECO5));
paperdoll_iid[L2_PAPERDOLL_DECO6] = p->readUInt(); // writeD(....PAPERDOLL_DECO6));
if( l2_version >= L2_VERSION_T23 )
paperdoll_iid[L2_PAPERDOLL_BELT] = p->readUInt(); // PAPERDOLL_BELT
// paperdoll augmentation IDs (25 items)
//for( i=0; i<25; i++ ) p->readUInt();
paperdoll_augid[L2_PAPERDOLL_UNDER] = p->readUInt(); // Inventory.PAPERDOLL_UNDER));
paperdoll_augid[L2_PAPERDOLL_REAR] = p->readUInt(); // writeD(....PAPERDOLL_REAR));
paperdoll_augid[L2_PAPERDOLL_LEAR] = p->readUInt(); // writeD(....PAPERDOLL_LEAR));
paperdoll_augid[L2_PAPERDOLL_NECK] = p->readUInt(); // writeD(....PAPERDOLL_NECK));
paperdoll_augid[L2_PAPERDOLL_RFINGER] = p->readUInt(); // writeD(....PAPERDOLL_RFINGER));
paperdoll_augid[L2_PAPERDOLL_LFINGER] = p->readUInt(); // writeD(....PAPERDOLL_LFINGER));
paperdoll_augid[L2_PAPERDOLL_HEAD] = p->readUInt(); // writeD(....PAPERDOLL_HEAD));
paperdoll_augid[L2_PAPERDOLL_RHAND] = p->readUInt(); // writeD(....PAPERDOLL_RHAND));
paperdoll_augid[L2_PAPERDOLL_LHAND] = p->readUInt(); // writeD(....PAPERDOLL_LHAND));
paperdoll_augid[L2_PAPERDOLL_GLOVES] = p->readUInt(); // writeD(....PAPERDOLL_GLOVES));
paperdoll_augid[L2_PAPERDOLL_CHEST] = p->readUInt(); // writeD(....PAPERDOLL_CHEST));
paperdoll_augid[L2_PAPERDOLL_LEGS] = p->readUInt(); // writeD(....PAPERDOLL_LEGS));
paperdoll_augid[L2_PAPERDOLL_FEET] = p->readUInt(); // writeD(....PAPERDOLL_FEET));
paperdoll_augid[L2_PAPERDOLL_BACK] = p->readUInt(); // writeD(....PAPERDOLL_BACK));
paperdoll_augid[L2_PAPERDOLL_LRHAND] = p->readUInt(); // writeD(....PAPERDOLL_LRHAND));
paperdoll_augid[L2_PAPERDOLL_HAIR] = p->readUInt(); // writeD(....PAPERDOLL_HAIR));
paperdoll_augid[L2_PAPERDOLL_HAIR2] = p->readUInt(); // writeD(....PAPERDOLL_HAIR2));
// T1 new D's
paperdoll_augid[L2_PAPERDOLL_RBRACELET] = p->readUInt(); // writeD(....PAPERDOLL_RBRACELET));
paperdoll_augid[L2_PAPERDOLL_LBRACELET] = p->readUInt(); // writeD(....PAPERDOLL_LBRACELET));
paperdoll_augid[L2_PAPERDOLL_DECO1] = p->readUInt(); // writeD(....PAPERDOLL_DECO1));
paperdoll_augid[L2_PAPERDOLL_DECO2] = p->readUInt(); // writeD(....PAPERDOLL_DECO2));
paperdoll_augid[L2_PAPERDOLL_DECO3] = p->readUInt(); // writeD(....PAPERDOLL_DECO3));
paperdoll_augid[L2_PAPERDOLL_DECO4] = p->readUInt(); // writeD(....PAPERDOLL_DECO4));
paperdoll_augid[L2_PAPERDOLL_DECO5] = p->readUInt(); // writeD(....PAPERDOLL_DECO5));
paperdoll_augid[L2_PAPERDOLL_DECO6] = p->readUInt(); // writeD(....PAPERDOLL_DECO6));
if( l2_version >= L2_VERSION_T23 )
paperdoll_augid[L2_PAPERDOLL_BELT] = p->readUInt(); // PAPERDOLL_BELT
// T2.3 some 2 Ds
if( l2_version >= L2_VERSION_T23 )
{
p->readD();
p->readD();
}
pAtk = p->readInt(); // writeD(_activeChar.getPAtk(null));
pAtkSpd = p->readInt(); // writeD(_activeChar.getPAtkSpd());
pDef = p->readInt(); // writeD(_activeChar.getPDef(null));
evasion = p->readInt(); // writeD(_activeChar.getEvasionRate(null));
accuracy = p->readInt(); // writeD(_activeChar.getAccuracy());
critical = p->readInt(); // writeD(_activeChar.getCriticalHit(null, null));
mAtk = p->readInt(); // writeD(_activeChar.getMAtk(null, null));
mAtkSpd = p->readInt(); // writeD(_activeChar.getMAtkSpd());
pAtkSpd = p->readInt(); // writeD(_activeChar.getPAtkSpd());
mDef = p->readInt(); // writeD(_activeChar.getMDef(null, null));
pvpFlag = p->readInt(); // writeD(_activeChar.getPvpFlag()); // 0-non-pvp 1-pvp = violett name
karma = p->readInt(); // writeD(_activeChar.getKarma());
runSpeed = p->readInt(); // writeD(_runSpd);
walkSpeed = p->readInt(); // writeD(_walkSpd);
p->readInt(); // writeD(_swimRunSpd); // swimspeed
p->readInt(); // writeD(_swimWalkSpd); // swimspeed
p->readInt(); // writeD(_flRunSpd);
p->readInt(); // writeD(_flWalkSpd);
p->readInt(); // writeD(_flyRunSpd);
p->readInt(); // writeD(_flyWalkSpd);
double moveMultiplier = p->readDouble(); // writeF(_moveMultiplier);
double attackSpeedMultiplier = p->readDouble(); // writeF(_activeChar.getAttackSpeedMultiplier());
if( moveMultiplier > 0.0 )
{
runSpeed = (int)( ((double)(runSpeed)) * moveMultiplier + 0.5 );
walkSpeed = (int)( ((double)(walkSpeed)) * moveMultiplier + 0.5 );
}
if( attackSpeedMultiplier > 0.0 )
{
pAtkSpd = (int)( ((double)(pAtkSpd)) * attackSpeedMultiplier);
}
collisionRadius = p->readDouble(); // writeF(_activeChar.getBaseTemplate().collisionRadius);
collisionHeight = p->readDouble(); // writeF(_activeChar.getBaseTemplate().collisionHeight);
hairStyle = p->readInt(); // writeD(_activeChar.getAppearance().getHairStyle());
hairColor = p->readInt(); // writeD(_activeChar.getAppearance().getHairColor());
face = p->readInt(); // writeD(_activeChar.getAppearance().getFace());
/*isGm =*/ p->readInt(); // writeD(_activeChar.isGM() ? 1 : 0); // builder level
setTitle( p->readS() ); // writeS(title);
clanID = p->readUInt(); // writeD(_activeChar.getClanId());
clanCrestID = p->readUInt(); // writeD(_activeChar.getClanCrestId());
allyID = p->readUInt(); // writeD(_activeChar.getAllyId());
allyCrestID = p->readUInt(); // writeD(_activeChar.getAllyCrestId()); // ally crest id
// 0x40 leader rights
// siege flags: attacker - 0x180 sword over name, defender - 0x80 shield, 0xC0 crown (|leader), 0x1C0 flag (|leader)
relation = p->readUInt(); // writeD(_relation);
mountType = p->readUChar(); // writeC(_activeChar.getMountType()); // mount type
privateStoreType = (int)p->readUChar(); // writeC(_activeChar.getPrivateStoreType());
hasDwarvenCraft = p->readUChar(); // writeC(_activeChar.hasDwarvenCraft() ? 1 : 0);
pkKills = p->readInt(); // writeD(_activeChar.getPkKills());
pvpKills = p->readInt(); // writeD(_activeChar.getPvpKills());
numCubics = p->readUShort(); // writeH(_activeChar.getCubics().size());
if( numCubics > 4 ) numCubics = 4; // safe
for( i=0; i<numCubics; i++ )
cubicId[i] = p->readUShort(); //for (int id : _activeChar.getCubics().keySet()) writeH(id);
p->readUChar(); // writeC(0x00); //1-find party members
abnormalEffect = p->readUInt(); // writeD(_activeChar.getAbnormalEffect());
p->readChar(); // writeC(0x00);
clanPrivs = p->readUInt(); // writeD(_activeChar.getClanPrivileges());
recomLeft = p->readUShort(); // writeH(_activeChar.getRecomLeft());
recomHave = p->readUShort(); // writeH(_activeChar.getRecomHave());
mountNpcId = p->readUInt(); // writeD(_activeChar.getMountNpcId() + 1000000);
inventoryLimit = p->readUShort(); // writeH(_activeChar.getInventoryLimit());
classID = p->readUInt(); // writeD(_activeChar.getClassId().getId());
p->readUInt(); // writeD(0x00); // special effects? circles around player...
maxCp = (double)p->readInt(); // writeD(_activeChar.getMaxCp());
curCp = (double)p->readInt(); // writeD((int) _activeChar.getCurrentCp());
enchantEffect = p->readUChar(); // writeC(_activeChar.getEnchantEffect());
p->readUChar(); // writeC(0x00); //team circle around feet 1= Blue, 2 = red
clanCrestLargeID = p->readUInt(); // writeD(_activeChar.getClanCrestLargeId());
isNoble = p->readUChar(); // writeC(_activeChar.isNoble() ? 1 : 0);
isHero = p->readUChar(); // writeC(_activeChar.isHero()
isFishing = p->readUChar(); // writeC(_activeChar.isFishing() ? 1 : 0); //Fishing Mode
fishX = p->readUInt(); // writeD(_activeChar.getFishx()); //fishing x
fishY = p->readUInt(); // writeD(_activeChar.getFishy()); //fishing y
fishZ = p->readUInt(); // writeD(_activeChar.getFishz()); //fishing z
nameColor = p->readUInt(); // writeD(_activeChar.getAppearance().getNameColor());
//new c5
isRunning = (int)p->readUChar(); // writeC(_activeChar.isRunning() ? 0x01 : 0x00); //changes the Speed display on Status Window
pledgeClass = p->readUInt(); // writeD(_activeChar.getPledgeClass()); //changes the text above CP on Status Window
pledgeType = p->readUInt(); // writeD(_activeChar.getPledgeType());
titleColor = p->readUInt(); // writeD(_activeChar.getAppearance().getTitleColor());
// writeD(CursedWeaponsManager.getInstance().getLevel(_activeChar.getCursedWeaponEquippedId()));
cursedWeaponId = p->readUInt(); // cursedWeapon
// T1 Starts
transformId = p->readUInt(); // writeD(_activeChar.getTransformationId());
if( l2_version < L2_VERSION_T23 )
{
elements.attackElementType = p->readD(); // writeD(_activeChar.getAttackElement());
elements.attackElementValue = p->readD(); // writeD(_activeChar.getAttackElementValue());
elements.defAttrFire = p->readD(); // writeD(_activeChar.getDefAttrFire());
elements.defAttrWater = p->readD(); // writeD(_activeChar.getDefAttrWater());
elements.defAttrWind = p->readD(); // writeD(_activeChar.getDefAttrWind());
elements.defAttrEarth = p->readD(); // writeD(_activeChar.getDefAttrEarth());
elements.defAttrHoly = p->readD(); // writeD(_activeChar.getDefAttrHoly());
elements.defAttrUnholy = p->readD(); // writeD(_activeChar.getDefAttrUnholy());
}
else
{
elements.attackElementType = p->readH(); // writeH(attackAttribute);
elements.attackElementValue = p->readH(); // writeH(_activeChar.getAttackElementValue(attackAttribute));
elements.defAttrFire = p->readH(); // writeH(_activeChar.getDefenseElementValue(Elementals.FIRE));
elements.defAttrWater = p->readH(); // writeH(_activeChar.getDefenseElementValue(Elementals.WATER));
elements.defAttrWind = p->readH(); // writeH(_activeChar.getDefenseElementValue(Elementals.WIND));
elements.defAttrEarth = p->readH(); // writeH(_activeChar.getDefenseElementValue(Elementals.EARTH));
elements.defAttrHoly = p->readH(); // writeH(_activeChar.getDefenseElementValue(Elementals.HOLY));
elements.defAttrUnholy = p->readH(); // writeH(_activeChar.getDefenseElementValue(Elementals.DARK));
}
agathionId = p->readUInt(); // writeD(_activeChar.getAgathionId());
// T2
if( l2_version >= L2_VERSION_T2 )
{
fame = p->readUInt(); // writeD(_activeChar.getFame()); // Fame
p->readUInt(); // writeD(0x00); // Unknown // 0x01 in CT2.3
vitalityLevel = p->readUInt(); // writeD(_activeChar.getVitalityLevel()); // Vitality Level
}
// T2.3
//if( l2_version >= L2_VERSION_T23 )
//{
//writeD(0x00); // CT2.3
//writeD(0x00); // CT2.3
//writeD(0x00); // CT2.3
//writeD(0x00); // CT2.3
//}
// set last time when char coordinates were known exactly
lastMoveTickTime = OS_GetTickCount();
return true;
}

View File

@@ -0,0 +1,170 @@
#ifndef H_L2PLAYER
#define H_L2PLAYER
#include "L2Character.h"
#include "L2PlayerPaperDoll.h"
#include "L2ElementalInfo.h"
/** \class L2Player
Every L2Npc is L2Character:\n
Every L2Character is L2Object (has objectID, x, y, z)\n
Every L2Character has LEVEL!\n
Every L2Character has its charName and charTitle\n
Every L2Character has its heading\n
Every L2Character has its hairStyle, hairColor and face\n
Every L2Character has moving speed in states: running, walking\n
Every L2Character has its move destination: xDst, yDst, zDst\n
Every L2Character can calc its position based on destnation point and time passed since last calc\n
Every L2Character has its base stats: INT WIT MEN CON STR DEX\n
Every L2Character has its stats: pAtk, mAtk, ..., curHp, maxHp, ...\n
Every L2Character has abnormalEffect\n
Every L2Character has its target\n
Every L2Character can be in combat\n
Every L2Character has its collision radius and height\n
\n
Additionally:\n
Every L2Player has classID, baseClassID\n
Every L2Player has its appearance (Race, Sex, Face, Hair style, Hair color)\n
Every L2Player has enchantEffect\n
Every L2Player has its paperdoll: items equipped on it. Every paperdoll item can have augment ID\n
Every L2Player can fish: has isFishing, fishX, fishY, fishZ\n
Every L2Player can create sell shop: sell, buy, package sale, craft shop (has shop type and shop message)\n
Every L2Player can ride animals (mount NPC)\n
Every L2Player can give and receive recommendations\n
Every L2Player can be noble and hero\n
\n
Additionally, some values come from RelationChanged packet, not in CharInfo\n
Every L2Player has relation to current user\n
Every L2Player can be autoAttackable\n
\n
*/
class L2Player : public L2Character
{
public:
/** Default constructor, just calls setUnused() (zeroes all members) */
L2Player();
/** Copy constructor.
* \param other source to copy from
*/
L2Player( const L2Player& other );
/** Operator=
* \param other source to copy from
* \return reference to this object
*/
virtual const L2Player& operator=( const L2Player& other );
/** Just calls setUnused() (zeroes all members) */
virtual ~L2Player();
public:
/** Initializes object state (zeroes all members) */
virtual void setUnused();
public:
/** Converts player's race ID to displayable string
* \param out pointer to unicode string buffer to receive string
* \return out
*/
virtual void getRaceStr( wchar_t *out ) const;
/** Converts player's sex number to displayable string
* \param out pointer to unicode string buffer to receive string
* \return out
*/
virtual void getSexStr( wchar_t *out ) const;
/** Converts player's class ID to displayable string.\n
* This is current selected subclass (not base class).
* \param out pointer to unicode string buffer to receive string
* \return out
*/
virtual void getClassStr( wchar_t *out ) const;
/** Converts player's base class ID to displayable string.\n
* This is always player's base class.
* \param out pointer to unicode string buffer to receive string
* \return out
*/
virtual void getBaseClassStr( wchar_t *out ) const;
public:
// relation to current user constants
static const int RELATION_NONE = 0; ///< default value, no mean
static const int RELATION_PVP_FLAG = 0x00002; ///< pvp ???
static const int RELATION_HAS_KARMA = 0x00004; ///< karma ???
static const int RELATION_LEADER = 0x00080; ///< leader
static const int RELATION_INSIEGE = 0x00200; ///< true if in siege
static const int RELATION_ATTACKER = 0x00400; ///< true when attacker
static const int RELATION_ALLY = 0x00800; ///< blue siege icon, cannot have if red
static const int RELATION_ENEMY = 0x01000; ///< true when red icon, doesn't matter with blue
static const int RELATION_MUTUAL_WAR = 0x08000; ///< double fist (war)
static const int RELATION_1SIDED_WAR = 0x10000; ///< single fist (war)
// private store type constants
static const int PRIVATE_STORE_NONE = 0; ///< player has no private store
static const int PRIVATE_STORE_SELL = 1; ///< player is selling
static const int PRIVATE_STORE_BUY = 3; ///< player is buying
static const int PRIVATE_STORE_CRAFT = 5; ///< player is sitting in recipe shop mode
static const int PRIVATE_STORE_PACKAGESALE = 8; ///< player is in package sale mode
public:
bool parse_CharInfo( void *l2_game_packet, L2_VERSION l2_version );
bool parse_UserInfo( void *l2_game_packet, L2_VERSION l2_version );
public:
unsigned int classID; ///< current class ID, which may be subclass and may differ from base class ID
unsigned int baseClassID; ///< player's base class ID
int race; ///< race number
int sex; ///< 1 - female, 0 - male
int hairStyle;
int hairColor;
int face;
unsigned long long experience; // only from UserInfo
unsigned int skill_points; // only from UserInfo
int curLoad; // only from UserInfo
int maxLoad; // only from UserInfo
int pkKills; // only from UserInfo
int pvpKills; // only from UserInfo
unsigned int enchantEffect; ///< player's weapon enchant value
// from RelationChanged
unsigned int relation; ///< relation (siege flags and clan war flags,fists)
int autoAttackable; ///< 1, if player is auto attackable (2-sided war, for example)
unsigned int paperdoll_oid[32]; ///< array of paperdoll objectIDs (only from UserInfo)
unsigned int paperdoll_iid[32]; ///< array of paperdoll itemIDs
unsigned int paperdoll_augid[32]; ///< array of paperdoll augmentationIDs
int isFakeDeath;
int isFishing;
int fishX;
int fishY;
int fishZ;
int privateStoreType; ///< player's private store type. See PRIVATE_STORE_* constants (1 - sellshop, ...)
wchar_t privateStoreMsgBuy[64]; ///< buy shop message
wchar_t privateStoreMsgSell[64]; ///< sell shop message
wchar_t privateStoreMsgRecipe[64]; ///< recipe shop message
unsigned int mountType; ///< 1-on Strider, 2-on Wyvern, 3-on Great Wolf, 0-no mount
unsigned int mountNpcId; ///< mount NPC template ID
int recomLeft; ///< number of recommendations this player can give to others
int recomHave; ///< number of received recommendations
int isNoble; ///< 1 if is noblesse
int isHero; ///< 1 if is hero
unsigned int nameColor;
unsigned int titleColor;
unsigned int pledgeClass; ///< pledge class (TODO)
unsigned int pledgeType; ///< pledge type (TODO)
unsigned int cursedWeaponId;
int clanRepScore; ///< clan reputation score or 0, if no clan
unsigned int transformId;
unsigned int agathionId;
unsigned int vehicleObjectId; // O_o Gracia Final
int hasDwarvenCraft; // only for UserInfo
int numCubics;
unsigned int cubicId[4];
unsigned int clanPrivs; // only for UserInfo
int inventoryLimit; // only for UserInfo
L2ElementalInfo elements; // only for UserInfo
int fame; // only for UserInfo
int vitalityLevel; // only for UserInfo
};
#endif

View File

@@ -0,0 +1,42 @@
#ifndef H_L2PLAYER_PAPERDOLL_
#define H_L2PLAYER_PAPERDOLL_
/** \file L2PlayerPaperDoll.h
* Defines paperdoll items indexes in arrays:
* unsigned int L2Player::paperdoll_iid[32];
* unsigned int L2Player::paperdoll_augid[32];
*/
#define L2_PAPERDOLL_UNDER 0
#define L2_PAPERDOLL_REAR 1
#define L2_PAPERDOLL_LEAR 2
#define L2_PAPERDOLL_LREAR 3
#define L2_PAPERDOLL_NECK 4
#define L2_PAPERDOLL_LFINGER 5
#define L2_PAPERDOLL_RFINGER 6
#define L2_PAPERDOLL_LRFINGER 7
#define L2_PAPERDOLL_HEAD 8
#define L2_PAPERDOLL_RHAND 9
#define L2_PAPERDOLL_LHAND 10
#define L2_PAPERDOLL_GLOVES 11
#define L2_PAPERDOLL_CHEST 12
#define L2_PAPERDOLL_LEGS 13
#define L2_PAPERDOLL_FEET 14
#define L2_PAPERDOLL_BACK 15
#define L2_PAPERDOLL_LRHAND 16
#define L2_PAPERDOLL_FULLARMOR 17
#define L2_PAPERDOLL_HAIR 18
#define L2_PAPERDOLL_ALLDRESS 19
#define L2_PAPERDOLL_HAIR2 20
#define L2_PAPERDOLL_HAIRALL 21
#define L2_PAPERDOLL_RBRACELET 22
#define L2_PAPERDOLL_LBRACELET 23
#define L2_PAPERDOLL_DECO1 24
#define L2_PAPERDOLL_DECO2 25
#define L2_PAPERDOLL_DECO3 26
#define L2_PAPERDOLL_DECO4 27
#define L2_PAPERDOLL_DECO5 28
#define L2_PAPERDOLL_DECO6 29
#define L2_PAPERDOLL_BELT 30
#endif

View File

@@ -0,0 +1,19 @@
#ifndef L2SKILL_H_
#define L2SKILL_H_
/** \class L2Skill
* Information about skill: skill ID, skill level and active/passive type.
*/
class L2Skill
{
public:
L2Skill(): isPassive(1), id(0), level(0) {}
~L2Skill() {}
public:
int isPassive; ///< 1, if is passive; 0 otherwise
unsigned int id; ///< skill ID
unsigned int level; ///< skill level
};
#endif

View File

@@ -0,0 +1,21 @@
#ifndef H_L2WORLD
#define H_L2WORLD
/** \file L2World.h
* Just a header to include all information about Lineage2 world...
*/
#include "L2Object.h"
#include "L2Character.h"
#include "L2Npc.h"
#include "L2Player.h"
#include "L2Skill.h"
#include "L2ChatMessageTypes.h"
#include "L2PlayerPaperDoll.h"
#include "L2Experience.h"
#include "L2ElementalInfo.h"
#endif