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

📄 worldpackets.cpp.svn-base

📁 ROSE的源代码。了解的自己研究,编译通过
💻 SVN-BASE
📖 第 1 页 / 共 5 页
字号:
                    if(type<421)
                        if(type<311)
                            flag = false;
                        else
                            if(type>312)
                                flag = false;
                            else
                                flag = true;
                    else
                        if(type<=428)
                            flag = true;
                        else
                            if(type<311)
                                flag = false;
                            else
                                flag = true;                   
                    if(flag)
                    {
                        value = pvalue;        
                        if(value>=11)
                            value ^= 0xffffffff;
                        else
                            value = values[value];     
                        value -= 0x32;      
                        value *= pricerate;   
                        price = value * 0.001;
                        price += 1;     
                        price *= bprice;                                                                                                                 
                        price += 0.5;
                        price = (float)floor(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*count;                            
                    }
                    else
                    {
                        float price = pricerate;
                        unsigned int value = 0x61 - 0x32; // misc rate - 0x32
                        price *= value;                
                        price *= 0.001;
                        price += 1; 
                        price *= bprice;                                                                                   
                        price += 0.5;
                        price = (float)floor(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*count;                                             
                    }
                }   
                break;    
                case 7:
                case 11:
                case 13:
                {
                    float price = 0;
                    UINT bprice = 0;
                    UINT pricerate;
                    if(thisitem.itemtype==7)
                    {
                        pricerate = EquipList[7].Index[thisitem.itemnum]->pricerate;
                        bprice = EquipList[7].Index[thisitem.itemnum]->price;
                    }
                    else
                    {
                        switch(thisitem.itemtype)
                        {
                            case 11:
                                pricerate = JemList.Index[thisitem.itemnum]->pricerate;
                                bprice = JemList.Index[thisitem.itemnum]->price;                                
                            break;
                            case 13:continue;
                        }
                    }     
                    price = pricerate;                               
                    unsigned int value = 0x61 - 0x32; // misc rate - 0x32                    
                    price *= value;                
                    price *= 0.001;
                    price += 1;   
                    price *= bprice;                                              
                    price += 0.5;
                    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*count;                     
                }
                break;
                default:
                    Log( MSG_WARNING, "Invalid Item Type: %i", thisitem.itemtype );                            
            }            
			ncount++;
		}
	}
	for (int i=0; i<sellcount; i++) 
    {
		BYTE slotid = GETBYTE((*P), 8+(buycount*4)+(i*3)); 
		WORD count = GETWORD((*P), 9+(buycount*4)+(i*3));
        if (thisclient->items[slotid].count < count)
           return true;
		CItem thisitem = thisclient->items[slotid];
		thisitem.count = count;
		switch(thisitem.itemtype)
		{
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 8:
            case 9:
            case 14:
            {
                float price = 0;
                price = 7.142857E-05F * 5000;
                if(thisitem.itemtype<10)
                {
                    price *= EquipList[thisitem.itemtype].Index[thisitem.itemnum]->price;
                }
                else
                {
                    price *= PatList.Index[thisitem.itemnum]->price;
                }                
                price *= thisitem.durability + 0xc8; 
                price *= 40;                   
                price *= 0xc8 - 0x62; //town rate
                price *= 1.000000E-06;
                price = (float)floor(price);
    			Log( MSG_WARNING, "Item Sold: itemnum %i, itemtype %i, itemcount %i, price %0.0f", thisitem.itemnum, thisitem.itemtype, thisitem.count, price);                                                            
        		thisclient->CharInfo->Zulies += (long int)price*count;
            }
            break;	
            case 10:
            case 12:
            {
                // this values are the same from 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;
                if(type<421)
                {
                    if(type<311)
                        flag = false;
                    else
                        if(type>312)
                            flag = false;
                        else
                            flag = true;
                }
                else
                {
                    if(type<=428)
                        flag = true;
                    else
                        if(type<311)
                            flag = false;
                        else
                            flag = true;                                                              
                }
                if(flag)
                {           
                    value = pvalue;
                    if(value>=11)
                        value ^= 0xffffffff;
                    else
                        value = values[value];
                    value -= 0x32;
                    value *= pricerate;
                    value += 1000;
                    value *= bprice; 
                    value *= (200 - 0x62); //town rate ( 100)
                    price = value * 5.555555555555556E-06;           
                    price = (float)floor(price);                 
                	Log( MSG_WARNING, "Item Sold: itemnum %i, itemtype %i, itemcount %i, price %0.0f", thisitem.itemnum, thisitem.itemtype, thisitem.count, price);                                                                    			
                    thisclient->CharInfo->Zulies += (long int)price*count;                                                                                                                                                        
                }
                else
                {                   
                    float price = pricerate;
                    unsigned int value = 0x61 - 0x32; // misc rate -0x32
                    price *= value;
                    price += 1000;
                    price *= bprice;                                                                   
                    price *= (200 - 0x62); //town rate ( 100)
                    price *= 5.555555555555556E-06;           
                    price = (float)floor(price);                 
                	Log( MSG_WARNING, "Item Sold: itemnum %i, itemtype %i, itemcount %i, price %0.0f", thisitem.itemnum, thisitem.itemtype, thisitem.count, price);                                                                    			
                    thisclient->CharInfo->Zulies += (long int)price*count;                     
                }                                         
            }
            break;
            case 7:
            case 11:
            case 13:
            {
                float price = 0;
                UINT bprice = 0;
                UINT pricerate = 0;
                switch(thisitem.itemtype)
                {
                    case 7:              
                        pricerate = EquipList[thisitem.itemtype].Index[thisitem.itemnum]->pricerate;
                        bprice *= EquipList[thisitem.itemtype].Index[thisitem.itemnum]->price;                 
                    break;
                    case 11:
                        pricerate = JemList.Index[thisitem.itemnum]->pricerate;
                        bprice *= JemList.Index[thisitem.itemnum]->price;              
                    break;
                    case 13:continue;//can we sell quest items? :S
                        
                }      
                price = pricerate;     
                price *= 0x61 - 0x32;   // misc rate -0x32   
                price += 1000; 
                price *= bprice;                                  
                price *= (200 - 0x62); //town rate ( 100)
                price *= 5.555555555555556E-06;                  
                price = (float)floor(price);          
        		Log( MSG_WARNING, "Item Sold: itemnum %i, itemtype %i, itemcount %i, price %0.0f", thisitem.itemnum, thisitem.itemtype, thisitem.count, price);                                                                    			
            	thisclient->CharInfo->Zulies += (long int)price*count;                     
            }
            break;
            default:
                Log( MSG_WARNING, "Invalid Item Type: %i", thisitem.itemtype );
        }
        thisclient->items[slotid].count	-= count;
        if( thisclient->items[slotid].count <=0 )	
    		ClearItem( thisclient->items[slotid] );
		ADDBYTE( pak, slotid );
		ADDDWORD( pak, BuildItemHead( thisclient->items[slotid] ) );
		ADDDWORD( pak, BuildItemData( thisclient->items[slotid] ) );
        //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 );   

		ncount++;
	}
	SETQWORD( pak, 0, thisclient->CharInfo->Zulies );
	SETBYTE( pak, 8, ncount );
	thisclient->client->SendPacket( &pak );
	return true;
}

// Attack skill
bool CWorldServer::pakStartSkill ( CPlayer* thisclient, CPacket* P )
{
    if( thisclient->Shop->open || thisclient->Status->Stance==DRIVING || thisclient->Status->Mute !=0xff ) 
        return true;    
    fPoint thispoint;
    UINT targetid = GETWORD( (*P), 0 );
    BYTE skillnum = GETBYTE( (*P), 2 );
    if(skillnum>=MAX_SKILL)
    {
        Log( MSG_HACK, "Invalid Skill id %i for %s ", skillnum, thisclient->CharInfo->charname );
        return false;
    }    
    unsigned int skillid = thisclient->cskills[skillnum].id+thisclient->cskills[skillnum].level-1;	    
    CMap* map = MapList.Index[thisclient->Position->Map];
    CCharacter* character = map->GetCharInMap( targetid );
    if(character==NULL) return true;
    
	if(character->IsMonster())
	{
	   BEGINPACKET( pak, 0x79f );
	   ADDWORD( pak, character->clientid );
	   ADDWORD( pak, character->Stats->HP );
	   ADDWORD( pak, 0 );
	   thisclient->client->SendPacket( &pak );
    }    
	CSkills* thisskill = GetSkillByID( skillid );
	if(thisskill==NULL)
	   return true;
	if(thisskill->target==9 && !character->IsDead())
	{
        ClearBattle( thisclient->Battle );
        return true;
    }    
    if( isSkillTargetFriendly( thisskill ) )
    {
        thisclient->StartAction( character, SKILL_BUFF, skillid );
    }
    else
    {
        thisclient->StartAction( character, SKILL_ATTACK, skillid );        
    }
	return true;
}

// Trade action
bool CWorldServer::pakTradeAction ( CPlayer* thisclient, CPacket* P )
{
    if(thisclient->Shop->open)
        return true;    
	CPacket pak;
	BYTE action = GETBYTE( (*P), 0 );
	thisclient->Trade->trade_target = GETWORD( (*P), 1 );
	CPlayer* otherclient = GetClientByID( thisclient->Trade->trade_target, thisclient->Position->Map );
	if (otherclient==NULL) return true;
	switch(action) 
    {
		case 0:
			// REQUEST TRADE
			RESETPACKET( pak, 0x7c0 );
			ADDBYTE( pak, 0 );
			ADDWORD( pak, thisclient->clientid );
			ADDBYTE( pak, 0 );
			otherclient->client->SendPacket( &pak );
			thisclient->Trade->trade_status=2;
			otherclient->Trade->trade_status=1;
			break;
		case 1:
			// ACCEPT TRADE
			RESETPACKET( pak, 0x7c0 );
			ADDBYTE( pak, 1 );
			ADDWORD( pak, thisclient->clientid );
			ADDBYTE( pak, 0 );
			otherclient->client->SendPacket( &pak );
			thisclient->Trade->trade_status=3;
			otherclient->Trade->trade_status=3;
			for(int i=0; i<11; i++) thisclient-

⌨️ 快捷键说明

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