📄 worldpackets.cpp.svn-base
字号:
// Emotions
bool CWorldServer::pakDoEmote( CPlayer* thisclient, CPacket* P )
{
if(thisclient->Shop->open)
return true;
thisclient->RestartPlayerVal( );
BEGINPACKET( pak, 0x781 );
ADDWORD( pak, GETWORD((*P), 0) );
ADDWORD( pak, 0x8000 );
ADDWORD( pak, thisclient->clientid );
SendToVisible( &pak, thisclient );
return true;
}
// This function is for increasing your stats
bool CWorldServer::pakAddStats( CPlayer* thisclient, CPacket* P )
{
BYTE statid = GETBYTE((*P), 0);
int statval = -1;
int nstatval = 0;
switch(statid)
{
case 0: nstatval=(int)floor((float)thisclient->Attr->Str/5); break;
case 1: nstatval=(int)floor((float)thisclient->Attr->Dex/5); break;
case 2: nstatval=(int)floor((float)thisclient->Attr->Int/5); break;
case 3: nstatval=(int)floor((float)thisclient->Attr->Con/5); break;
case 4: nstatval=(int)floor((float)thisclient->Attr->Cha/5); break;
case 5: nstatval=(int)floor((float)thisclient->Attr->Sen/5); break;
}
if (thisclient->CharInfo->StatPoints>=nstatval && nstatval < ((Config.MaxStat/5)+1))
{
switch(statid)
{
case 0: statval=++thisclient->Attr->Str; break;
case 1: statval=++thisclient->Attr->Dex; break;
case 2: statval=++thisclient->Attr->Int; break;
case 3: statval=++thisclient->Attr->Con; break;
case 4: statval=++thisclient->Attr->Cha; break;
case 5: statval=++thisclient->Attr->Sen; break;
}
}
if (statval>0)
{
thisclient->CharInfo->StatPoints-=nstatval;
BEGINPACKET( pak, 0x7a9 );
ADDBYTE( pak, statid );
ADDWORD( pak, (unsigned short)statval );
thisclient->client->SendPacket( &pak );
}
thisclient->SetStats( );
return true;
}
// Normal Chat
bool CWorldServer::pakNormalChat( CPlayer* thisclient, CPacket* P )
{
if (P->Buffer[0]=='/')
{
return pakGMCommand( thisclient, P );
//std::cout << thisclient->CharInfo->charname << ": " << P->Buffer << "\n";
}
else
{
BEGINPACKET( pak, 0x783 );
ADDWORD( pak, thisclient->clientid );
ADDSTRING( pak, P->Buffer );
ADDBYTE( pak, 0 );
SendToVisible( &pak, thisclient );
}
return true;
};
// Exit rose
bool CWorldServer::pakExit( CPlayer* thisclient, CPacket* P )
{
BEGINPACKET( pak, 0x707 );
ADDWORD( pak, 0 );
thisclient->client->SendPacket( &pak );
thisclient->client->isActive = false;
return true;
}
// move skill to function keys
bool CWorldServer::pakMoveSkill ( CPlayer* thisclient, CPacket* P )
{
BYTE slotid = GETBYTE((*P), 0x0 );
WORD itemid = GETWORD((*P), 0x1 );
if(slotid>47) return true;
thisclient->quickbar[slotid] = itemid;
BEGINPACKET( pak, 0x7aa );
ADDBYTE( pak, slotid );
ADDWORD( pak, itemid );
thisclient->client->SendPacket( &pak );
return true;
}
// User is checking up on the server
bool CWorldServer::pakPing ( CPlayer* thisclient, CPacket* P )
{
BEGINPACKET( pak, 0x0700 );
ADDWORD( pak, 0 );
thisclient->client->SendPacket( &pak );
return true;
}
// GameGuard
bool CWorldServer::pakGameGuard ( CPlayer* thisclient, CPacket* P )
{
thisclient->lastGG = clock();
return true;
}
// User Died
bool CWorldServer::pakUserDied ( CPlayer* thisclient, CPacket* P )
{
thisclient->Session->inGame = false;
BYTE respawn = GETBYTE((*P),0);
//1 - Current / 2 - save point
CMap* map = MapList.Index[thisclient->Position->Map];
CRespawnPoint* thisrespawn = NULL;
if(respawn==1)
{
thisrespawn = map->GetNearRespawn( thisclient );
}
else
{
thisrespawn = GetRespawnByID( thisclient->Position->saved );
}
thisclient->Stats->HP = thisclient->Stats->MaxHP * 10 / 100;
if(thisrespawn!=NULL)
{
map->TeleportPlayer( thisclient, thisrespawn->dest, false );
}
else
{
fPoint coord;
coord.x = 5200;
coord.y = 5200;
MapList.Index[2]->TeleportPlayer( thisclient, coord, false );
}
for(unsigned int i=0;i<30;i++)
{ // Clean Buffs
thisclient->MagicStatus[i].Duration = 0;
}
return true;
}
// Shouting
bool CWorldServer::pakShout ( CPlayer* thisclient, CPacket* P )
{
BEGINPACKET(pak, 0x0785);
ADDSTRING ( pak, thisclient->CharInfo->charname );
ADDBYTE ( pak, 0 );
ADDSTRING ( pak, &P->Buffer[0] );
ADDBYTE ( pak, 0 );
SendToMap ( &pak, thisclient->Position->Map );
return true;
}
// Whispering
bool CWorldServer::pakWhisper ( CPlayer* thisclient, CPacket* P )
{
char msgto[17];
memset( &msgto, '\0', 17 );
strncpy( msgto, (char*)&(*P).Buffer[0],16 );
CPlayer* otherclient = GetClientByCharName( msgto );
if(otherclient!=NULL)
{
BEGINPACKET( pak, 0x0784 );
ADDSTRING( pak, thisclient->CharInfo->charname );
ADDBYTE( pak, 0 );
ADDSTRING( pak, &P->Buffer[strlen(msgto)+1] );
ADDBYTE( pak, 0 );
otherclient->client->SendPacket( &pak );
return true;
}
BEGINPACKET( pak, 0x0784 );
ADDSTRING( pak, msgto );
ADDBYTE( pak, 0 );
ADDBYTE( pak, 0 );
thisclient->client->SendPacket( &pak );
return true;
}
// Return to Char Select
bool CWorldServer::pakCharSelect ( CPlayer* thisclient, CPacket* P )
{
thisclient->savedata();
if(!thisclient->Session->inGame) return true;
thisclient->Session->isLoggedIn = false;
if(thisclient->client!=NULL) thisclient->client->isActive = false;
//send packet to change messenger status (offline)
BEGINPACKET( pak, 0x7e1 );
ADDBYTE ( pak, 0xfa );
ADDWORD ( pak, thisclient->CharInfo->charid );
ADDBYTE ( pak, 0x00 );
cryptPacket( (char*)&pak, cct );
send( csock, (char*)&pak, pak.Size, 0 );
pakClearUser( thisclient );
ClearClientID( thisclient->clientid );
thisclient->Saved = true;
RESETPACKET( pak, 0x505 );
ADDDWORD( pak, thisclient->Session->userid );
cryptPacket( (char*)&pak, cct );
send( csock, (char*)&pak, pak.Size, 0 );
return true;
}
// Buy from NPC
bool CWorldServer::pakNPCBuy ( CPlayer* thisclient, CPacket* P )
{
if(thisclient->Shop->open)
return true;
WORD NPC = GETWORD((*P), 0);
CNPC* thisnpc = GetNPCByID( NPC, thisclient->Position->Map );
if( thisnpc==NULL )
return true;
BYTE buycount = GETBYTE((*P), 2);
BYTE sellcount = GETBYTE((*P), 3);
BYTE ncount = 0;
BEGINPACKET( pak, 0x717 );
ADDQWORD ( pak, thisclient->CharInfo->Zulies );
ADDBYTE ( pak, 0x00 );
for (int i=0; i<buycount; i++)
{
BYTE tabid = GETBYTE((*P), 8+(i*4));
BYTE itemid = GETBYTE((*P), 9+(i*4));
WORD count = GETWORD((*P), 10+(i*4));
unsigned sellid = 0;
switch(tabid)
{
case 0:
sellid = thisnpc->thisnpc->tab1;
break;
case 1:
sellid = thisnpc->thisnpc->tab2;
break;
case 2:
sellid = thisnpc->thisnpc->tab3;
break;
case 3:
sellid = thisnpc->thisnpc->specialtab;
break;
default:
sellid = 0;
}
if(SellList.Index[sellid]==NULL) // invalid tab
continue;
int tmpcount = count;
while (tmpcount>0)
{
CItem thisitem;
thisitem.itemnum = SellList.Index[sellid]->item[itemid] % 1000;
thisitem.itemtype = SellList.Index[sellid]->item[itemid] / 1000;
unsigned newslot = thisclient->GetNewItemSlot( thisitem );
if ( newslot == 0xffff ) { ncount-=1; break; }
int thisslotcount = 999 - thisclient->items[newslot].count;
if ( thisslotcount > tmpcount ) thisslotcount=tmpcount;
tmpcount -= thisslotcount;
thisitem.count = thisslotcount + thisclient->items[newslot].count;
thisitem.refine = 0;
thisitem.durability = 35;
thisitem.lifespan = 100;
thisitem.appraised = true;
thisitem.socketed = false;
thisitem.stats = 0;
thisitem.gem = 0;
thisclient->items[newslot] = thisitem;
ADDBYTE ( pak, newslot );
ADDDWORD ( pak, BuildItemHead( thisclient->items[newslot] ) );
ADDDWORD ( pak, BuildItemData( thisclient->items[newslot] ) );
//Added 2 lines below for 139+ Clients - code on osRose Forum - Purple / Drakia
// Disabled for now, problems in drops
// ADDDWORD( pak, 0x00000000 );
// ADDWORD ( pak, 0x0000 );
switch(thisitem.itemtype)
{
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 8:
case 9:
case 14:
{
float price = 0;
UINT quality = 0;
UINT bprice = 0;
if(thisitem.itemtype<10 )
{
quality = EquipList[thisitem.itemtype].Index[thisitem.itemnum]->quality;
bprice = EquipList[thisitem.itemtype].Index[thisitem.itemnum]->price;
}
else
{
quality = PatList.Index[thisitem.itemnum]->quality;
bprice = PatList.Index[thisitem.itemnum]->price;
}
price = quality;
price += 0x32; // town rate
price *= bprice;
price += 0.5;
price /= 100;
price = (float)round(price);
Log( MSG_WARNING, "Item bought: itemnum %i, itemtype %i, itemcount %i, price %0.0f", thisitem.itemnum, thisitem.itemtype, thisitem.count, price);
thisclient->CharInfo->Zulies -= (long int)price;
}
break;
case 10:
case 12:
{
// this values should be the same than packet 753
BYTE values[11] = {0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32};
UINT type = 0;
UINT bprice = 0;
UINT pricerate = 0;
UINT pvalue = 0;
if(thisitem.itemtype==10)
{
type = UseList.Index[thisitem.itemnum]->type;
bprice = UseList.Index[thisitem.itemnum]->price;
pricerate = UseList.Index[thisitem.itemnum]->pricerate;
pvalue = UseList.Index[thisitem.itemnum]->pricevalue;
}
else
{
type = NaturalList.Index[thisitem.itemnum]->type;
bprice = NaturalList.Index[thisitem.itemnum]->price;
pricerate = NaturalList.Index[thisitem.itemnum]->pricerate;
pvalue = NaturalList.Index[thisitem.itemnum]->pricevalue;
}
unsigned int value = 0;
float price = 0;
bool flag;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -