📄 worldpackets.cpp.svn-base
字号:
}
// Picks up item
bool CWorldServer::pakPickDrop( CPlayer* thisclient, CPacket* P )
{
if(thisclient->Shop->open)
return true;
thisclient->RestartPlayerVal( );
WORD dropid = GETWORD((*P), 0x00);
CDrop* thisdrop = GetDropByID( dropid, thisclient->Position->Map );
if (thisdrop==NULL) return true;
bool flag = false;
BEGINPACKET( pak, 0x7a7 );
ADDWORD ( pak, thisdrop->clientid );
CPlayer* dropowner = 0;
if( (thisdrop->owner==0 || thisdrop->owner==thisclient->CharInfo->charid || time(NULL)-thisdrop->droptime>=30 ) || ( thisclient->Party->party!=NULL && thisclient->Party->party == thisdrop->thisparty ))
{
if( thisclient->Party->party!=NULL )
{
unsigned int dropparty = thisclient->Party->party->Option/0x10;
if( dropparty == 8 ) // Orderly
{
unsigned int num = 0;
bool dpflag = false;
if( thisdrop->type==1 )
{
num = thisclient->Party->party->LastZulies;
thisclient->Party->party->LastZulies++;
if( thisclient->Party->party->LastZulies>=thisclient->Party->party->Members.size() )
thisclient->Party->party->LastZulies = 0;
}
else
if( thisdrop->type==2 )
{
num = thisclient->Party->party->LastItem;
thisclient->Party->party->LastItem++;
if( thisclient->Party->party->LastItem>=thisclient->Party->party->Members.size() )
thisclient->Party->party->LastItem = 0;
}
unsigned int n = 0;
while( !dpflag )
{
n++;
if( num>=thisclient->Party->party->Members.size() )
num = 0;
dropowner = thisclient->Party->party->Members.at( num );
if( dropowner == NULL )
num++;
else
{
dpflag = true;
num++;
}
if(n>20) // not founded yet? >.>
{
dropowner = thisclient;
dpflag = true;
}
}
}
else // Equal Loot
{
dropowner = thisclient;
}
}
else
{
dropowner = thisclient;
}
if( thisdrop->type == 1 ) //Zulie
{
dropowner->CharInfo->Zulies += thisdrop->amount;
ADDWORD( pak, 0 );
ADDBYTE( pak, 0 );
ADDDWORD( pak, 0xccccccdf );
ADDDWORD( pak, thisdrop->amount );
dropowner->client->SendPacket( &pak );
flag = true;
}
else
if( thisdrop->type == 2 ) // Item
{
unsigned int tempslot = dropowner->AddItem( thisdrop->item );
if(tempslot!=0xffff)// we have slot
{
unsigned int slot1 = tempslot;
unsigned int slot2 = 0xffff;
if(tempslot>MAX_INVENTORY)
{
slot1 = tempslot/1000;
slot2 = tempslot%1000;
}
ADDBYTE ( pak, 0x00 );
ADDBYTE ( pak, slot1 );
ADDBYTE ( pak, 0x00 );
ADDDWORD ( pak, BuildItemHead( dropowner->items[slot1] ) );
ADDDWORD ( pak, BuildItemData( dropowner->items[slot1] ) );
//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 );
dropowner->client->SendPacket( &pak );
dropowner->UpdateInventory( slot1, slot2 );
flag = true;
}
else
{
ADDBYTE (pak, 0x03);
dropowner->client->SendPacket(&pak);
}
}
}
else
{
ADDBYTE (pak, 0x02);
thisclient->client->SendPacket(&pak);
}
if( flag )
{
if( thisclient->Party->party!=NULL )
{
unsigned int dropparty = thisclient->Party->party->Option/0x10;
if( dropparty == 8 )
{
BEGINPACKET( pak, 0x7d3 );
ADDWORD ( pak, dropowner->clientid );
if( thisdrop->type == 1 )
{
ADDDWORD( pak, 0xccccccdf );
ADDDWORD( pak, thisdrop->amount );
}
else
if( thisdrop->type == 2 )
{
ADDDWORD ( pak, BuildItemHead( thisdrop->item ) );
ADDDWORD ( pak, BuildItemData( thisdrop->item ) );
//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 );
}
thisclient->Party->party->SendToMembers( &pak, dropowner );
}
}
CMap* map = MapList.Index[thisdrop->posMap];
pthread_mutex_lock( &map->DropMutex );
map->DeleteDrop( thisdrop );
pthread_mutex_unlock( &map->DropMutex );
}
return true;
}
// Changes equipment
bool CWorldServer::pakChangeEquip( CPlayer* thisclient, CPacket* P )
{
if(thisclient->Shop->open)
return true;
WORD srcslot = GETWORD((*P), 0);
WORD destslot = GETWORD((*P), 2);
if(!CheckInventorySlot(thisclient, srcslot))
return false;
if(!CheckInventorySlot(thisclient, destslot))
return false;
if (destslot < 13 && GServer->EquipList[thisclient->items[srcslot].itemtype].Index[thisclient->items[srcslot].itemnum]->level > thisclient->Stats->Level)
return true;
if( destslot==0 ) destslot = thisclient->GetNewItemSlot( thisclient->items[srcslot] );
if( destslot==0xffff ) return true;
if( srcslot==7 || destslot==7 )
{
// clear the buffs if we change the weapon
for(UINT i=0;i<15;i++)
{
switch(thisclient->MagicStatus[i].Buff)
{
case A_ATTACK:
case A_ACCUR:
case A_HASTE:
case A_CRITICAL:
thisclient->MagicStatus[i].Duration = 0;
break;
}
}
}
CItem tmpitm = thisclient->items[srcslot];
thisclient->items[srcslot] = thisclient->items[destslot];
thisclient->items[destslot] = tmpitm;
thisclient->UpdateInventory( srcslot, destslot );
BEGINPACKET( pak, 0x7a5 );
ADDWORD ( pak, thisclient->clientid );
ADDWORD ( pak, srcslot );
ADDWORD ( pak, thisclient->items[srcslot].itemnum );
ADDWORD ( pak, BuildItemRefine( thisclient->items[srcslot] ) );
ADDWORD ( pak, thisclient->Stats->Move_Speed );
SendToVisible( &pak, thisclient );
if( srcslot==7 || destslot==7 )
{
// if is two hand weapon, we have to check if have shield and unequip it
UINT weapontype = EquipList[WEAPON].Index[thisclient->items[7].itemnum]->type;
switch(weapontype)
{
case TWO_HAND_SWORD:
case SPEAR:
case TWO_HAND_AXE:
case BOW:
case GUN:
case LAUNCHER:
case STAFF:
case KATAR:
case DOUBLE_SWORD:
case DUAL_GUN:
{
if(thisclient->items[8].itemnum!=0)
{ // we should unequip the shield
UINT newslot = thisclient->GetNewItemSlot( thisclient->items[8] );
if(newslot==0xffff)
{
// we have no slot for the shield, we have to change back the items
tmpitm = thisclient->items[destslot];
thisclient->items[destslot] = thisclient->items[srcslot];
thisclient->items[srcslot] = tmpitm;
SendSysMsg( thisclient, "You don't have free slot" );
return true;
}
thisclient->items[newslot] = thisclient->items[8];
ClearItem( thisclient->items[8] );
thisclient->UpdateInventory( newslot, 8 );
RESETPACKET( pak, 0x7a5 );
ADDWORD ( pak, thisclient->clientid );
ADDWORD ( pak, 8 );
ADDWORD ( pak, thisclient->items[8].itemnum );
ADDWORD ( pak, BuildItemRefine( thisclient->items[8] ) );
ADDWORD ( pak, thisclient->Stats->Move_Speed );
SendToVisible( &pak, thisclient );
}
}
break;
}
}
thisclient->SetStats( );
return true;
}
// Construct a cart/change parts
bool CWorldServer::pakChangeCart( CPlayer* thisclient, CPacket* P )
{
if(thisclient->Shop->open)
return true;
WORD cartslot = GETWORD((*P), 0);
WORD srcslot = GETWORD((*P), 0) + 135;
WORD destslot = GETWORD((*P), 2);
if(!CheckInventorySlot( thisclient, srcslot ))
return false;
if(!CheckInventorySlot( thisclient, destslot ))
return false;
if( destslot == 0 ) destslot=thisclient->GetNewItemSlot( thisclient->items[srcslot] );
if( destslot == 0xffff ) return true;
CItem tmpitm = thisclient->items[srcslot];
thisclient->items[srcslot] = thisclient->items[destslot];
thisclient->items[destslot] = tmpitm;
BEGINPACKET( pak, 0x7ca );
ADDWORD ( pak, thisclient->clientid );
ADDWORD ( pak, cartslot);
ADDWORD ( pak, thisclient->items[srcslot].itemnum);
ADDWORD ( pak, BuildItemRefine( thisclient->items[srcslot] ) );
ADDWORD ( pak, thisclient->Stats->Move_Speed );
SendToVisible( &pak, thisclient );
thisclient->UpdateInventory( srcslot, destslot );
thisclient->Stats->Move_Speed = thisclient->GetMoveSpeed( );
return true;
}
// Start attacking a monster or player
bool CWorldServer::pakStartAttack( CPlayer* thisclient, CPacket* P )
{
if(!thisclient->CanAttack( )) return true;
WORD clientid = GETWORD((*P),0x00);
if ( thisclient->Battle->target == clientid ) return true;
int weapontype = EquipList[WEAPON].Index[thisclient->items[7].itemnum]->type;
if( weapontype == 231 && thisclient->items[132].count<1 )
return true;
else
if( weapontype == 232 && thisclient->items[133].count<1 )
return true;
else
if( weapontype == 233 && thisclient->items[134].count<1 )
return true;
else
if( weapontype == 271 && thisclient->items[132].count<1 )
return true;
CMap* map = MapList.Index[thisclient->Position->Map];
CCharacter* character = map->GetCharInMap( clientid );
if(character==NULL) return true;
if(character->IsMonster( ))
{
if(map->allowpvp==0 && character->IsSummon( )) return true;
if(!character->IsSummon())
character->AddDamage( (CCharacter*)thisclient, 0 );
}
if(character->IsMonster())
{
// SET MONSTER HEALTH
BEGINPACKET( pak, 0x79f );
ADDWORD ( pak, character->clientid );
ADDDWORD ( pak, character->Stats->HP );
thisclient->client->SendPacket( &pak );
}
thisclient->StartAction( character, NORMAL_ATTACK, 0 );
thisclient->Battle->contatk = true;
return true;
}
// Goto next map through gate
bool CWorldServer::pakGate( CPlayer* thisclient, CPacket* P )
{
thisclient->Session->inGame = false;
CTeleGate* thisgate = GetTeleGateByID( GETWORD((*P), 0x00) );
fPoint position;
UINT map = 0;
if( thisgate==NULL )
{
map = 61;
position.x = 5800.00;
position.y = 5200.00;
}
else
{
map = thisgate->destMap;
position = thisgate->dest;
}
MapList.Index[map]->TeleportPlayer( thisclient, position );
return true;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -