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

📄 playerquest.cpp.svn-base

📁 ROSE的源代码。了解的自己研究,编译通过
💻 SVN-BASE
📖 第 1 页 / 共 5 页
字号:
/*
    Rose Online Server Emulator
    Copyright (C) 2006,2007 OSRose Team http://www.osrose.net
    
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2
    of the License, or (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

    depeloped with Main erose/hrose source server + some change from the original eich source        
*/
#include "player.h"
#include "worldserver.h"


//LMA function for logging quest info (IG)
//void CPlayer::LogQuest( char buffer2[200] )
void CPlayer::LogQuest( char *Format, ...)
{
	va_list ap;	      // For arguments
    va_start( ap, Format );
    
    if (this->questdebug)
     {
         char buffer2[200];
         vsprintf ( buffer2, Format, ap );
         GServer->SendPM(this, buffer2); 
         Log(MSG_INFO,buffer2);
     }
     
	va_end  ( ap );
}

bool CPlayer::AddQuest( unsigned long int questid )
{   
    LogQuest("Adding questid %lu ?", questid );
    
    if( GetQuestByQuestID( questid ) !=0 )
    {
           CQuest* thisquest = GServer->GetQuestByQuestID( questid );        
           LogQuest("Quest already in list %lu, quest %u",questid,thisquest->id);
           return false;        
    }
    
    // Check if is Start Quest ID        
    CQuest* thisquest = GServer->GetQuestByQuestID( questid ); 
    if(thisquest!=0)
    { 
        if( thisquest->script == 1 ) //Teleport Bypass 
        {
             LogQuest("questid %lu is Quest nb %i, teleport quest",questid,thisquest->id);
             return GServer->DoQuestScript( this, thisquest );
        }
        
        //LMA begin
        LogQuest("questid %lu is Quest nb %i, NEW quest",questid,thisquest->id);
        //LMA end
        
        //LMA: main quest
        if(thisquest->id>=203&&thisquest->id<=205)
        {
            CQuest* oldquest = GServer->GetQuestByID( 202 );
            if( oldquest!=NULL )
            {
                QUESTS* myoldquest = GetQuestByQuestID( oldquest->questid ); 
                if( myoldquest!=NULL )
                {
                    Log(MSG_INFO,"deleting old quest id %u",202);
                    myoldquest->active = false;
                    ActiveQuest--;
                }
            }           
            
        }
        
        if( ActiveQuest >= 10 ) //Can't Take more quest
            return false;
            
        //LMA BEGIN
        //Clan Wars
        //we pay :)
        //and we check so that the other guy is happy...
        if (thisquest->id==2813)
        {
            if (CharInfo->Zulies>=10000000)
            {
                CharInfo->Zulies-=10000000;
                BEGINPACKET( pak, 0x71e );
                ADDQWORD   ( pak, CharInfo->Zulies );
                ADDBYTE    ( pak, 0x00 );
                client->SendPacket( &pak ); 
            }
            else
            {
                LogQuest("We got a hacker here :)");
                return false;
            }
        }
        
        QUESTS* myquest = new QUESTS;
        assert(myquest);
        myquest->questid = thisquest->questid;
        myquest->thisquest = thisquest;        
        myquest->active = true;
        for(int i=0;i<5;i++)
            myquest->items[i] = 0;  
            
        //LMA BEGIN
        //rev.70 org code (modified)
        for(int i=0;i<5;i++) // Look for start items
        {
            if( myquest->thisquest->startItems[i] != 0)
            {
                //myquest->items[i]++;
                myquest->items[i]=myquest->thisquest->startItems[i];
            }        
        } 
        
        MyQuest.push_back( myquest );  
        ActiveQuest++;
        
         //LMA begin
         //20070621-211100
        //sometimes you want a script at the beginning of the quest
        if (thisquest->script>0&&thisquest->value3==2)
        {
            LogQuest("Time for script for new quest %lu !!",questid);
            GServer->DoQuestScript( this, thisquest );              
        }
        //LMA end
        
        //Patch for First Jobs
        //We got to disable Identification.
        if (thisquest->id==851||thisquest->id==901||thisquest->id==951||thisquest->id==1001)
        {
            CQuest* questtemp = GServer->GetQuestByID(801);
            QUESTS* myquesttemp = 0;
            
            if(questtemp!=NULL)
            {
                myquesttemp = GetQuestByQuestID( questtemp->questid);
                if (myquesttemp!=NULL)
                {
                    LogQuest("Patch for Junon ID.");
                    myquesttemp->active=false;
                    ActiveQuest--;            
                }
                
            }

         }
        //LMA END
        
    }      
    
    // Check if is Finish Quest ID
    CQuest* finalquest = GServer->GetQuestByFinalID( questid );    
    QUESTS* myquest = 0;
    bool flag = false;
    if( finalquest != 0) 
    {                       
         //LMA begin
         LogQuest("Final Quest nb %i",finalquest->id);                    
         //LMA end
                         
        //Search if this user have the quest
        myquest = GetQuestByQuestID( finalquest->questid ); 
        if( myquest != 0 )
        {
            flag = true;            
            //LMA
            //20070622, 153000
            //patch for lost children
            if(myquest->thisquest->id>=9001&&myquest->thisquest->id<=9003)
            {
                CQuest* thisquestlc = GServer->GetQuestByID(215); 
                if(thisquestlc!=0)
                {                   
                  if( ActiveQuest < 10 )
                  {
                        QUESTS* myquestlc = new QUESTS;
                        assert(myquestlc);
                        myquestlc->questid = thisquestlc->questid;
                        myquestlc->thisquest = thisquestlc;        
                        myquestlc->active = true;
                        for(int i=0;i<5;i++)
                            myquestlc->items[i] = 0;  
                            myquestlc->items[0] = 1;
                        MyQuest.push_back( myquestlc );  
                        ActiveQuest++;
                        LogQuest("Special Activation for Lost children quest...");
                    }
                 }
            }
            //LMA END
        }
        
    }    
    else
    {
        // Search the quest who have this item
        myquest = GetQuestByItemID( questid );
        if( myquest!=0 )
        {
            //LMA begin
            LogQuest("questid %lu is Quest nb %i, item quest",questid,myquest->thisquest->id);
            //LMA end
            

            //LMA begin
            //20070621-211100
            //a peculiar item quest can launch the script
            //the script will be launched (if any) according to the place of the questitemid in the database in itemid field (item1|item2).
            //if in 0 position (so item1), the value 3 must be set to 3, if you want the script to be triggered when receiving item2, then 
            //as it is in offset 1, put 4 (always offset +3) 
            int itemquest_script=0;
            //LMA end
            
            for(int i=0;i<5;i++) // Search the Item Quest
            {
                if( myquest->thisquest->itemid[i] == questid )
                {
                    //LMA BEGIN
                    //20070621-211100--mod
                    //2do:compatibility with rev.70
                    //we calculate according to quest...
                    itemquest_script=i+3;

⌨️ 快捷键说明

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