示例#1
0
ORESULT        AbilityGather::OnProcOver(Obj_Human* pHuman)
{
__ENTER_FUNCTION
    
    AbilityOpera* pAbilityOpera;

    pAbilityOpera = pHuman->GetAbilityOpera();
    Assert( pAbilityOpera );

    ObjID_t        ItemBoxObjID = pAbilityOpera->m_Obj;

    if( ItemBoxObjID == INVALID_ID )
    {
        Assert(FALSE) ;
    }

    Scene* pScene = pHuman->getScene();
    Assert(pScene);

    Obj* pObj = pScene->GetObjManager()->GetObj( ItemBoxObjID ) ;

    if( pObj==NULL )
    {
        g_pLog->FastSaveLog( LOG_FILE_1, "AbilityGather: not find obj=%d", ItemBoxObjID ) ;
        return OR_INVALID_TARGET ;
    }

    Obj_ItemBox*    pItemBox = (Obj_ItemBox*)pObj;

    if( pItemBox->GetObjType()!= Obj::OBJ_TYPE_ITEM_BOX)
    {
        g_pLog->FastSaveLog( LOG_FILE_1, "AbilityGather: Obj_ItemBox obj    =    %d\r\n  is Not class of ITEM_CLASS_BOX", ItemBoxObjID ) ;
        return OR_INVALID_TARGET ;
    }

    INT ItemBoxType = pItemBox->GetType();

    _GROW_POINT_INFO*    pGET = g_GrowPointInfoTbl.Get(ItemBoxType);
    Assert(pGET);

    if(pGET->m_ScriptID>0)
    {
        if(pScene->GetGrowPointManager()->CallScriptProcOverFunc(pGET->m_ScriptID,pHuman->GetID(),ItemBoxObjID,pScene->SceneID()))
        {
            return OnProcFailure(pHuman);
        }
        else
        {
            return OnProcSuccess(pHuman);
            
        }
    }
    else
    {
        return OnProcSuccess(pHuman);
    }
    
__LEAVE_FUNCTION

    return OR_ERROR ;
}
示例#2
0
ORESULT    AbilityGather::CanUseAbility(Obj_Human* pHuman)
{
__ENTER_FUNCTION

    Assert( pHuman );

    ORESULT res;
    res = Ability::CanUseAbility(pHuman);
    if( res != OR_OK )
    {
        return res;
    }
    AbilityOpera* pAbilityOpera;
    pAbilityOpera = pHuman->GetAbilityOpera();
    Assert( pAbilityOpera );

    ObjID_t        ItemBoxObjID = pAbilityOpera->m_Obj;

    if( ItemBoxObjID == INVALID_ID )
    {
        Assert(FALSE) ;
    }
    
    Scene* pScene = pHuman->getScene();
    Assert(pScene);

    Obj* pObj = pScene->GetObjManager()->GetObj( ItemBoxObjID ) ;

    if( pObj==NULL )
    {
        g_pLog->FastSaveLog( LOG_FILE_1, "AbilityGatherMine: not find obj=%d", ItemBoxObjID ) ;
        return OR_INVALID_TARGET ;
    }

    Obj_ItemBox*    pItemBox = (Obj_ItemBox*)pObj;

    if( pItemBox->GetObjType()!= Obj::OBJ_TYPE_ITEM_BOX)
    {
        g_pLog->FastSaveLog( LOG_FILE_1, "AbilityGatherMine: Obj_ItemBox obj    =    %d\r\n  is Not class of ITEM_CLASS_BOX", ItemBoxObjID ) ;
        return OR_INVALID_TARGET ;
    }

    if(!pItemBox->CanPickBox(pHuman->GetID(),pHuman->GetID()))
        return OR_FAILURE;



    INT ItemBoxType = pItemBox->GetType();

    _GROW_POINT_INFO*    pGET = g_GrowPointInfoTbl.Get(ItemBoxType);
    Assert(pGET);

    if(pGET->m_ScriptID>0)
    {
        return (OPERATE_RESULT)(pScene->GetGrowPointManager()->CallScriptOpenBoxFunc(pGET->m_ScriptID,pHuman->GetID(),ItemBoxObjID,pScene->SceneID()));
        
    }


    return OR_OK;

__LEAVE_FUNCTION

    return OR_ERROR ;
}