⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 worldpackets.cpp.svn-base

📁 ROSE的源代码。了解的自己研究,编译通过
💻 SVN-BASE
📖 第 1 页 / 共 5 页
字号:
    thisclient->client->SendPacket( &pak );

    RESETPACKET( pak, 0x753 );
    ADDWORD    ( pak, thisclient->clientid );			// USER ID
    ADDWORD    ( pak, thisclient->Stats->HP );		// CURRENT HP
    ADDWORD    ( pak, thisclient->Stats->MP );		// CURRENT MP
    ADDDWORD   ( pak, thisclient->CharInfo->Exp );				// CURRENT EXP
    ADDDWORD   ( pak, 0x00000000 );						// LVL EXP (UNSUSED)        
    // thanks to StrikeX to post this source  
        //[economy]    
    ADDWORD    ( pak, 0x0063 );  // World Rate
    ADDBYTE    ( pak, 0x70 );
    ADDBYTE    ( pak, 0x69 );
    ADDBYTE    ( pak, 0x68 );
    ADDBYTE    ( pak, 0x67 );                
    ADDWORD    ( pak, 0x0062 );  // Town rate    
    ADDBYTE    ( pak, 0x61 );  // misc rate
    ADDBYTE    ( pak, 0x32 );  //1
    ADDBYTE    ( pak, 0x32 );  //2
    ADDBYTE    ( pak, 0x32 );  //3           
    ADDBYTE    ( pak, 0x32 );  //4
    ADDBYTE    ( pak, 0x32 );  //5
    ADDBYTE    ( pak, 0x32 );  //6
    ADDBYTE    ( pak, 0x32 );  //7    
    ADDBYTE    ( pak, 0x32 );  //8
    ADDBYTE    ( pak, 0x32 );  //9
    ADDBYTE    ( pak, 0x32 );  //10
    ADDBYTE    ( pak, 0x32 );  //11
    CMap* map = MapList.Index[thisclient->Position->Map];
    if(map->allowpvp!=0)
        ADDWORD(pak, 0x0001)//player vs player map
    else
        ADDWORD(pak, 0x0000)//non player vs player map
    ADDWORD    (pak, 0x0000 );//??
    // Map Time
    ADDDWORD( pak, map->MapTime );
    if(map->allowpvp==1){ ADDWORD(pak, 51 );} // pvp all vs all
    else if(map->allowpvp==2) // pvp group vs group
    {
        /*ADDWORD(pak, thisclient->Clan->clanid );*/ 
        ADDWORD(pak, 51);
    }
    else 
    {
        ADDWORD(pak, 2 );
    }
    thisclient->client->SendPacket( &pak );
    // set weight
    RESETPACKET( pak, 0x762 );
    ADDWORD    ( pak, thisclient->clientid );       	// USER ID
    ADDBYTE    ( pak, 1 );								// SOMETHING TO DO WITH WEIGHT
    thisclient->client->SendPacket( &pak );
    // set speed
	RESETPACKET(pak, 0x782 );
	ADDWORD    ( pak, thisclient->clientid );
	ADDBYTE    ( pak, thisclient->Status->Stance );
	ADDWORD    ( pak, thisclient->Stats->Move_Speed );
	SendToVisible( &pak, thisclient );
    thisclient->CleanPlayerVector( );
	thisclient->Session->inGame = true;
	thisclient->firstlogin=clock();    //LMA for fairy
	return true;
}

// Move Characters in map
bool CWorldServer::pakMoveChar( CPlayer* thisclient, CPacket* P )
{
    if( thisclient->Shop->open || (!thisclient->Ride->Drive && thisclient->Ride->Ride) || !thisclient->Status->CanMove )
        return true;
    if( thisclient->Status->Stance==1 )
        thisclient->Status->Stance=3;                
    ClearBattle( thisclient->Battle );
	thisclient->Battle->target = GETWORD((*P), 0x00 );
	thisclient->Position->destiny.x = GETFLOAT((*P), 0x02 )/100;
    thisclient->Position->destiny.y = GETFLOAT((*P), 0x06 )/100;
    thisclient->Position->lastMoveTime = clock();
	BEGINPACKET( pak, 0x79a );
	ADDWORD    ( pak, thisclient->clientid );		// USER ID
	ADDWORD    ( pak, thisclient->Battle->target );		// TARGET
	ADDWORD    ( pak, thisclient->Stats->Move_Speed );	// MSPEED
	ADDFLOAT   ( pak, GETFLOAT((*P), 0x02 ) );	// POSITION X
	ADDFLOAT   ( pak, GETFLOAT((*P), 0x06 ) );	// POSITION Y
	ADDWORD    ( pak, GETWORD((*P), 0x0a ) );		// POSITION Z (NOT USED)
	SendToVisible( &pak, thisclient );    
	return true;
}

// Stop Character movement
bool CWorldServer::pakStopChar( CPlayer* thisclient, CPacket* P )
{
    ClearBattle( thisclient->Battle );
	thisclient->Position->destiny.x = GETFLOAT((*P), 0x00 )/100;
    thisclient->Position->destiny.y = GETFLOAT((*P), 0x04 )/100;
	BEGINPACKET( pak, 0x770 );
	ADDWORD    ( pak, thisclient->clientid );		// USER ID
	ADDFLOAT   ( pak, thisclient->Position->destiny.x*100 );	// POSITION X 
	ADDFLOAT   ( pak, thisclient->Position->destiny.y*100 );	// POSITION Y
	ADDWORD    ( pak, GETWORD((*P), 0x08 ) );		// POSITION Z (NOT USED)
	SendToVisible( &pak, thisclient );
	return true;
}

// Spawn NPC
bool CWorldServer::pakSpawnNPC( CPlayer* thisclient, CNPC* thisnpc )
{
	BEGINPACKET( pak, 0x791 );
    ADDWORD( pak, thisnpc->clientid );
	ADDFLOAT( pak, thisnpc->pos.x*100 );
    ADDFLOAT( pak, thisnpc->pos.y*100 );
    ADDFLOAT( pak, thisnpc->pos.x*100 );
    ADDFLOAT( pak, thisnpc->pos.y*100 );
	ADDBYTE( pak, 0x00 );
    ADDWORD( pak, 0x0000 );
	ADDWORD( pak, 0x0000 );
	ADDWORD( pak, 0x03e8 );
	ADDWORD( pak, 0x0000 );
	ADDWORD( pak, 0x0001 );
	ADDWORD( pak, 0x0000 );//Buffs
	ADDWORD( pak, 0x0000 );//Buffs
	ADDWORD( pak, 0x0000 );//buffs
	ADDWORD( pak, thisnpc->npctype );	
    if(thisnpc->thisnpc->dialogid!=0)
    {
        ADDWORD( pak, thisnpc->thisnpc->dialogid );
    }
    else
    {// fixed by tomiz [npc dialogs fixed [still not all]]
         unsigned int factor;
        if (thisnpc->npctype >= 1000 && thisnpc->npctype <=1041 || thisnpc->npctype >= 1043 && thisnpc->npctype <=1084 || thisnpc->npctype >= 1086 && thisnpc->npctype <=1119 || thisnpc->npctype >= 1131 && thisnpc->npctype <=1199 || thisnpc->npctype >= 1207 && thisnpc->npctype <=1299) factor=900;
       	//else if (thisnpc->npctype >= 1200 && thisnpc->npctype <=1203 || thisnpc->npctype >= 1205 && thisnpc->npctype <=1206) factor=896; // event npc
       	else if (thisnpc->npctype >= 1200 && thisnpc->npctype <=1203 || thisnpc->npctype >= 1206 && thisnpc->npctype <=1206) factor=896; // event npc
        else if (thisnpc->npctype == 1042 || thisnpc->npctype == 1085 ) factor=899;  // Storage Adventure Plain -> Fabrizio - Junon Clan Field -> Nell
        else if (thisnpc->npctype == 1120 ) factor=896;  // dunno if that dialog are corect 1120 [Clan Clerk] Regina
        else if (thisnpc->npctype == 1204 ) factor=897;  // event npc another warp to zant dialog npc 1203 [Event Info] Lucielle Fete
        else if (thisnpc->npctype == 1473 ) factor=1457; // should be ok 1473 Melendino adventure plain
        else if (thisnpc->npctype == 1752 ) factor=1528; // Clan Merchant Aliche Patt ver 141
        else if (thisnpc->npctype == 1121 ) factor=900; // Ikaness Staff Shroon - Anima Lake
        else if (thisnpc->npctype == 1205 ) factor=901; // Event Santa Claus - Non event factor 896, event 901
        else if (thisnpc->npctype >= 1122 && thisnpc->npctype <=1130) factor=905;                
        else if (thisnpc->npctype >= 1500 && thisnpc->npctype <=1599) factor=1210;
        else if (thisnpc->npctype >= 1750 && thisnpc->npctype <=1755 || !thisnpc->npctype == 1752 ) factor=1000; //should be ok
        
        if (thisnpc->dialog!=0)
        {
            ADDWORD( pak, thisnpc->dialog );    
        }
        else
        {
            ADDWORD( pak, thisnpc->npctype - factor );    
        }
        
    }	
	ADDFLOAT( pak, thisnpc->dir );
	
    if (thisnpc->npctype == 1115)
    { 
       ADDBYTE( pak, GServer->Config.Cfmode ) // Burland Clan Field open/close
    }
    
    //Event:
    if (thisnpc->event!=0&&thisnpc->npctype!=1115)
    {
        Log(MSG_INFO,"Event number %i",thisnpc->event);
        ADDBYTE ( pak, thisnpc->event);
    }
    else
    {
        ADDBYTE ( pak, 0 );
     }
    
    ADDBYTE( pak, 0 );
    thisclient->client->SendPacket( &pak );
	return true;
}

// Changes stance
bool CWorldServer::pakChangeStance( CPlayer* thisclient, CPacket* P )
{
    if(thisclient->Shop->open)
        return true;    
	BYTE stancenum = GETBYTE((*P),0x00);
	if (stancenum == 0)
	{
        if(thisclient->Status->Stance == RUNNING) //Walking
        {
            stancenum = WALKING;
            thisclient->Status->Stance = WALKING;
        }
        else
        if(thisclient->Status->Stance != DRIVING) // Running
        {
            stancenum = RUNNING;
            thisclient->Status->Stance = RUNNING;
        }
    }	
    else   
	if (stancenum == 1) 
    {
        if(thisclient->Status->Stance!=DRIVING && thisclient->Status->Stance>0x01) //
        {   // Walking
			thisclient->Status->Stance = 0x01;            			
        }
        else
        if(thisclient->Status->Stance<0x04)
        {   //Runing         
			thisclient->Status->Stance = 0x03;                      
        }
    }    
    else
	if (stancenum == 2) 
    {
		if (thisclient->Status->Stance==RUNNING || thisclient->Status->Stance==0x02)
		{// // Driving
            // Clean Buffs 		  
            stancenum = DRIVING;
			thisclient->Status->Stance = DRIVING;			
            thisclient->Ride->Ride = false;
            thisclient->Ride->Drive = true;
            thisclient->Ride->charid = 0;
        }
		else
		{ // Running
            stancenum = RUNNING;
			thisclient->Status->Stance = RUNNING;
        }
	}
    else
		thisclient->Status->Stance = stancenum;
	if(!thisclient->Status->CanMove)
	   thisclient->Status->Stance = RUNNING;
	thisclient->Stats->Move_Speed = thisclient->GetMoveSpeed( );
	BEGINPACKET( pak, 0x782 );
	ADDWORD( pak, thisclient->clientid );
	ADDBYTE( pak, thisclient->Status->Stance );
	ADDWORD( pak, thisclient->Stats->Move_Speed );
	SendToVisible( &pak, thisclient );       
            
	return true;
}

// Spawn Drop
bool CWorldServer::pakSpawnDrop( CPlayer* thisclient, CDrop* thisdrop )
{
	BEGINPACKET( pak, 0x7a6 );
	ADDFLOAT( pak, thisdrop->pos.x*100 );
	ADDFLOAT( pak, thisdrop->pos.y*100 );
	if (thisdrop->type==1) 
    {
		// -- ZULY --
		ADDDWORD( pak, 0xccccccdf );
		ADDDWORD( pak, thisdrop->amount );
		ADDWORD( pak, thisdrop->clientid );
		ADDWORD( pak, 0x0000 );
		ADDWORD( pak, 0x5f90 );
	}
    else 
    {
		// -- ITEM --
		ADDDWORD( pak, BuildItemHead( thisdrop->item ) );
		ADDDWORD( pak, thisdrop->amount );
		ADDWORD( pak, thisdrop->clientid );
		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->client->SendPacket( &pak );
	return true;
}

// Player Left
void CWorldServer::pakClearUser( CPlayer* thisclient )
{
	BEGINPACKET( pak, 0x794 );
	ADDWORD( pak, thisclient->clientid );
	SendToVisible( &pak, thisclient, false );			
}

// Drop items on map
bool CWorldServer::pakDoDrop( CPlayer* thisclient, CPacket* P )
{
	BYTE itemid = GETBYTE((*P), 0x0);
	if(!CheckInventorySlot(thisclient, itemid ))
	   return false;
	DWORD amount = GETDWORD((*P), 0x1);
	if (itemid == 0) 
    {
		if ( amount<1 ) return true;
		if ( thisclient->CharInfo->Zulies < amount ) return true;
		CDrop* thisdrop = new CDrop;
		assert(thisdrop);
		thisdrop->clientid = GetNewClientID();
		thisdrop->type = 1; // ZULY
		thisdrop->pos = RandInCircle( thisclient->Position->current, 3 );
		thisdrop->posMap = thisclient->Position->Map;
		thisdrop->droptime = time(NULL);
		thisdrop->amount = amount;
		thisdrop->owner = 0;
		CMap* map = MapList.Index[thisdrop->posMap];
		map->AddDrop( thisdrop );
		thisclient->CharInfo->Zulies -= amount;
		BEGINPACKET( pak, 0x71d );
		ADDQWORD( pak, thisclient->CharInfo->Zulies );
		thisclient->client->SendPacket( &pak );
	}
    else
    {
        // fixed by tomciaaa [item count drop correctly and dissaper from inventory]		
        bool flag = false;
        if(thisclient->items[itemid].itemtype >=10 && thisclient->items[itemid].itemtype <= 13)
        {
            if(thisclient->items[itemid].count<amount) return true;
           thisclient->items[itemid].count -= amount;
           flag= (thisclient->items[itemid].count <= 0);
        }
        else
        {
           flag= true;
        }		
		CDrop* thisdrop = new CDrop;
		assert(thisdrop);
		thisdrop->clientid = GetNewClientID();
		thisdrop->type = 2; // ITEM
		thisdrop->pos = RandInCircle( thisclient->Position->current, 3 );
		thisdrop->posMap = thisclient->Position->Map;
		thisdrop->droptime = time(NULL);
		thisdrop->amount = amount;
		thisdrop->item = thisclient->items[itemid];
		thisdrop->item.count = amount;
		thisdrop->owner = 0;
		CMap* map = MapList.Index[thisdrop->posMap];
		map->AddDrop( thisdrop );
		if (flag)
		   ClearItem(thisclient->items[itemid]);
        thisclient->UpdateInventory( itemid );
	}
	return true;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -