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

📄 playerquest.cpp.svn-base

📁 ROSE的源代码。了解的自己研究,编译通过
💻 SVN-BASE
📖 第 1 页 / 共 5 页
字号:
                                                  found= (myquest->thisquest->numitems[j] > myquest->items[j]);
                                                  if (found)
                                                  {
                                                     myquest->items[j]++;
                                                     break;
                                                  }
                                           }
                                           break;
                                        }
                                        else
                                        {
                                            myquest->items[i]++;    
                                            break;    
                                        }
                                                                                  
                                      }                                       
           
                                   }
                                break;       
                    }
                    
                    break;
                    //LMA END                    
                }        
            }
            for(int i=0;i<5;i++) // look if Quest is Finished
            {
                if( myquest->thisquest->finalid!=0 )
                {
                    LogQuest("final id not 0, is %lu",myquest->thisquest->finalid);
                    break;
                }
                
                if( myquest->thisquest->numitems[i] != myquest->items[i] )
                {
                    //LMA begin
                    LogQuest("Quest not finished");
                    //LMA end
                    break; // Not Finished
                }
                
                if( i==4 )
                {
                    //LMA begin
                    LogQuest("Quest finished");
                    //LMA end
                    //Quest Finished
                    flag = true;
                  }
            }        
            
                 //LMA Begin
                 //20070621-211100
                 //sometimes if we receive an item quest event, we need to script...
                if (myquest->thisquest->script>0&&myquest->thisquest->value3!=0&&myquest->thisquest->value3==itemquest_script)
                {
                    LogQuest("Time for script for item quest %lu !!",questid);
                    GServer->DoQuestScript( this, myquest->thisquest );              
                }
                //LMA END
         }
        else
        {
            //LMA begin
            LogQuest("Questid %lu not found (by item).",questid); 
            //LMA end
        } 
           
    }
    if( flag ) // Check if finish the quest
    {  
        if( myquest!=0 )
        {
            if( myquest->active )
            {
                //LMA begin
                LogQuest("Quest reward time");
                //LMA end
                //Patch for Muse lvl 30 quest
                if (myquest->thisquest->id==9997)
                {
                   char bufferquest[200];
                   sprintf ( bufferquest, "You received Healing vials!");
                   GServer->pakGMItemQuest(this,2,10,2,0,100,0,0,bufferquest);
                }
                
                  GiveQuestReward( myquest->thisquest );
                  myquest->active = false;
                  ActiveQuest--;         
            }
        }
    }

    if(finalquest!=0)
    { 
        if(finalquest->script>0)
        {
            //LMA begin
            //20070621-211100
            //only if it's a "end of quest" script...
            LogQuest("Time for final script !!");
            if (finalquest->value3==0||finalquest->script==20)
            {
               return GServer->DoQuestScript( this, finalquest ); 
            }
            //LMA END
            
        }
        
    }
    
    
    return true;    
}

bool CPlayer::DelQuest( unsigned long int questid )
{
    CQuest* thisquest = GServer->GetQuestByID( questid );
    if(thisquest==0)
        return true;
    QUESTS* myquest = GetQuestByQuestID( thisquest->questid );
    if( myquest == 0 )
        return false;
    for(UINT i=0;i<MyQuest.size( );i++)
    {
        if(MyQuest.at(i)==myquest)
        {
            MyQuest.erase( MyQuest.begin()+i );
            delete myquest;
            break;
        }
    }
	ActiveQuest--;
    return true;
}


bool CPlayer::GiveQuestReward( CQuest* thisquest )
{
    if( thisquest==0 )
        return false;
    if( thisquest->ExpReward>0 )//Give Exp
    {
        CharInfo->Exp += thisquest->ExpReward;
        BEGINPACKET( pak, 0x79b );
        ADDDWORD   ( pak, CharInfo->Exp );
        ADDWORD    ( pak, CharInfo->stamina );
		ADDWORD    ( pak, 0 );
        client->SendPacket( &pak );                        
    }   
    if( thisquest->ZulieReward>0 )//Give Zuly
    {
        CharInfo->Zulies += thisquest->ZulieReward;
        BEGINPACKET( pak, 0x71e );
        ADDQWORD   ( pak, CharInfo->Zulies );
        ADDBYTE    ( pak, 0x00 );
        client->SendPacket( &pak ); 
    } 
    for(int i=0;i<10;i++)
    {
        if( thisquest->Itemreward[i]==0 || thisquest->ItemType[i]==0 )
            break;
        CItem item;
        item.count = thisquest->CountItem[i];
        item.durability = 50;
        item.itemnum = thisquest->Itemreward[i];
        item.itemtype = thisquest->ItemType[i];
        item.lifespan = 100;
        item.refine = 0;
        item.stats = 0;
        item.socketed = 0;
        item.appraised = 0;    
        item.gem = 0;  
        unsigned int newslot = GetNewItemSlot( item );   
        if(newslot==0xffff)
            continue;
        if(items[newslot].count>0)
            items[newslot].count += item.count;
        else
            items[newslot] = item;                            
        BEGINPACKET( pak, 0x71f ); // Give Item
        ADDBYTE    ( pak, 0x01 );
        ADDBYTE    ( pak, newslot );
        ADDDWORD   ( pak, GServer->BuildItemHead( items[newslot] ) );
        ADDDWORD   ( pak, GServer->BuildItemData( items[newslot] ) );
        ADDBYTE    ( pak, 0x00 );
        client->SendPacket( &pak );
    }      
    return true;
}

// Search Quest by QuestID
QUESTS* CPlayer::GetQuestByQuestID( unsigned long int questid )
{
    for(int i=0;i<MyQuest.size();i++)
    {
        QUESTS* myquest = MyQuest.at( i );
        if( myquest->questid == questid )
            return myquest;
    }
    return 0;
}

// Get MyQuest by ItemID
QUESTS* CPlayer::GetQuestByItemID( unsigned long int itemid )
{    
	for(int j=0; j<MyQuest.size( ); j++) 
    {
        QUESTS* myquest = MyQuest.at( j );
		for(int i=0;i<5;i++)
		{   // fixed by Drakia [If a quest had multiple monsters, but only one counter (Like the first hunting quest, kill 3 Jelly Bean's, or Mini-Jelly Bean's) you would need to kill 3 of the first creature in the list to finish the quest]
            if( itemid == myquest->thisquest->itemid[i] && myquest->active )
                return myquest;
        }
	}
	return 0;
}

// Get MyQuest by ItemID
QUESTS* CPlayer::GetQuestByMob( unsigned int mob )
{    
	for(int j=0; j<MyQuest.size( ); j++) 
    {
        QUESTS* myquest = MyQuest.at( j );
		for(int i=0;i<5;i++)
		{
            if( mob == myquest->thisquest->mobs[i] )
                return myquest;
        }
	}
	return 0;
}

⌨️ 快捷键说明

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