Exemple #1
0
void Buff::FinalChanges()
{
    CreatureObject*	creature = dynamic_cast<PlayerObject*>(mTarget);
    if(!creature)
    {
        mMarkedForDeletion =true;
        EraseAttributes();
        return;
    }

    AttributeList::iterator It = Attributes.begin();
    while(It != Attributes.end())
    {
        BuffAttribute* temp = (*It);
        ModifyAttribute(temp->GetType(), temp->GetFinalValue());
        It++;
    }

    PlayerObject* Player = dynamic_cast<PlayerObject*>(mTarget);
    if(Player)
    {
        if(mIcon > 0)
        {
            gMessageLib->sendPlayerRemoveBuff(Player, mIcon);
        }
    }

    //Complete entertainer mission
    //gMissionManager->missionCompleteEntertainer(Player,this);


}
Exemple #2
0
void Buff::InitialChanges()
{
    if(mDoInit)
    {
        PlayerObject* Player = dynamic_cast<PlayerObject*>(mTarget);
        if(Player)
        {

            if(mIcon > 0) //if internal buff
            {
                gMessageLib->sendPlayerAddBuff(Player, mIcon, (float)(mTick/1000));
            }

        }
        else
        {
            //if Creature/NPC
        }
        AttributeList::iterator It = Attributes.begin();
        while(It != Attributes.end())
        {
            BuffAttribute* temp = (*It);
            //make sure we know if the ham has altered our value!
            temp->SetInitialValue(ModifyAttribute(temp->GetType(), temp->GetInitialValue()));
            if(temp->GetFinalValue())
                temp->SetFinalValue(-temp->GetInitialValue());

            It++;
        }
        mDoInit=false;
    }
}
Exemple #3
0
uint64 Buff::Update(uint64 CurrentTime, void* ref)
{
    //Todo
    // we need a way to mark damaging buffs from nondamaging buffs
    // ie docbuff restoring original ham values vs poison
    if(mNoTicks > mCurrentTick)  //If we aren't on the final tick
    {
        //Modify Attributes
        AttributeList::iterator It = Attributes.begin();
        while(It != Attributes.end())
        {
            BuffAttribute* temp = (*It);
            ModifyAttribute(temp->GetType(), temp->GetTickValue());
            //were not interested in the return value here as ticking buffs are not applying final changes to restore an attribute
            ++It;
        }

        //Increment the Tick Counter
        IncrementTick();

        //Recreate Timer
        if(mNextTickLength != 0)
            return mNextTickLength;
        else
            return mTick;

    }
    else
    {   //If  Buff is on final tick

        FinalChanges();
        if(mChild!=0)
        {
            gWorldManager->addBuffToProcess(mChild);
        }
       
        mTarget->CleanUpBuffs();
		mMarkedForDeletion = true;
        return 0;
    }
}
Exemple #4
0
void BuffManager::AddBuffToDB(Buff* buff, uint64 currenttime)
{
    //If we have been passed a null Buff
    if(!buff)
        return;

    //Check for deletion of buff
    if(buff->GetIsMarkedForDeletion())
        return;


    buffAsyncContainer* envelope	= new buffAsyncContainer();
    envelope->mQueryType	= BMQuery_Null;

    /*TODO Should I Reset the Stat here on the player so it doesn't get double buffed
    	For now, this is dealt with by removing hte modifiers when saving Player HAM to DB,
    	but this might not be the best long term solution
    */

    //Get PlayerObjects from CreatureObjects
    PlayerObject* Player = dynamic_cast<PlayerObject*>(buff->GetTarget());
    PlayerObject* target = dynamic_cast<PlayerObject*>(buff->GetInstigator());

    //If target is a player, not Creature/NPC
    if(Player)
    {
        //Get ID for Instigator (if not Creature/NPC)
        uint64 instigatorid = 0;
        if(target)
        {
            instigatorid = target->getId();
        }

        uint32 bufficon = buff->GetIcon();
        int8 sql[550];
        sprintf(sql, "INSERT INTO %s.character_buffs (character_id, buff_id, instigator_id, max_ticks, tick_length, current_tick, icon, current_global_tick, start_global_tick) values(",mDatabase->galaxy());
        sprintf(sql+strlen(sql), "%" PRIu64 ",", Player->getId());
        sprintf(sql+strlen(sql), "%" PRIu64 ",", buff->GetID());
        sprintf(sql+strlen(sql), "%" PRIu64 ",", instigatorid);
        sprintf(sql+strlen(sql), "%u,", buff->GetNoOfTicks());
        sprintf(sql+strlen(sql), "%" PRIu64 ",", buff->GetTickLength());
        sprintf(sql+strlen(sql), "%u,", buff->GetCurrentTickNumber());
        sprintf(sql+strlen(sql), "%u,", bufficon);
        sprintf(sql+strlen(sql), "%" PRIu64 ",", currenttime);
        sprintf(sql+strlen(sql), "%" PRIu64 ");", buff->GetStartGlobalTick());

        //Lloydyboy Changed Save SQL back to Sync, not ASync to ensure this is saved, before new zone loads
        //mDatabase->ExecuteSqlAsync(this,envelope,sql);
        mDatabase->destroyResult(mDatabase->executeSynchSql(sql));

        int8 sql2[550];
        sprintf(sql2, "INSERT INTO %s.character_buff_attributes (buff_id,character_id,type,initial,tick,final) VALUES",mDatabase->galaxy());
        //Add Attributes
        AttributeList::iterator it = buff->Attributes.begin();

        //if we have no attributes
        if(it == buff->Attributes.end())
        {
            return;
        }

        while(it != buff->Attributes.end())
        {
            BuffAttribute* batemp = *it;

            //undo the attribute pre safe - we will reapply this on login
            buff->ModifyAttribute(batemp->GetType(), batemp->GetFinalValue());

            sprintf(sql2+strlen(sql2), "(%" PRIu64 ",", buff->GetID());
            sprintf(sql2+strlen(sql2), "%" PRIu64 ",", Player->getId());
            sprintf(sql2+strlen(sql2), "%" PRIu64 ",", batemp->GetType());
            sprintf(sql2+strlen(sql2), "%d,", batemp->GetInitialValue());
            sprintf(sql2+strlen(sql2), "%d,", batemp->GetTickValue());

            AttributeList::iterator it2 = it;
            it2++;
            if(it2 != buff->Attributes.end())
            {
                sprintf(sql2+strlen(sql2), "%d),", batemp->GetFinalValue());
            } else {
                sprintf(sql2+strlen(sql2), "%d);", batemp->GetFinalValue());
            }
            it++;
        }

        //Lloydyboy Changed Save SQL back to Sync, not ASync to ensure this is saved, before new zone loads
        //mDatabase->ExecuteSqlAsync(this,envelope,sql2);

        //then just put the notification of the new zone into the callback handler ?
        //having the zone wait for synch db calls everytime someone travels is simply stupid
        mDatabase->destroyResult(mDatabase->executeSynchSql(sql2));
    }
}
Exemple #5
0
bool BuffManager::AddBuffToDB(WMAsyncContainer* asyncContainer,DatabaseCallback* callback, Buff* buff, uint64 currenttime)
{
    // we are counting the queries we will have to start so the callbackhandler knows when the last query is through
    // not sure what to do for creatures yet but my guess is thatthe handling will be very similiar
    // thus the respective counter is in the creatureobject
    // all asyncqueries will be returned to the callbackHandler provided
    // we can decrease then the call counter of the creature object and in the case it reaches zero continue with
    // whatever it was we set out to do


    //If we have been passed a null Buff
    if(!buff)
        return false;

    //Get PlayerObjects from CreatureObjects
    PlayerObject* player = nullptr;
    PlayerObject* target = nullptr;

    try {
        player = dynamic_cast<PlayerObject*>(buff->GetTarget());
        target = dynamic_cast<PlayerObject*>(buff->GetInstigator());   //what is the difference ?
    } catch (...) {
        // The target or the instigator may have logged off in the process, bail out.
        return false;
    }

    //If target is a player, not Creature/NPC
    if(player)
    {
        //Get ID for Instigator (if not Creature/NPC)
        uint64 instigatorid = 0;
        if(target)
        {
            instigatorid = target->getId();
        }

        uint32 bufficon = buff->GetIcon();
        int8 sql[550];
        sprintf(sql, "INSERT INTO %s.character_buffs (character_id, buff_id, instigator_id, max_ticks, tick_length, current_tick, icon, current_global_tick, start_global_tick) values(",mDatabase->galaxy());
        sprintf(sql+strlen(sql), "%" PRIu64 ",", player->getId());
        sprintf(sql+strlen(sql), "%" PRIu64 ",", buff->GetID());
        sprintf(sql+strlen(sql), "%" PRIu64 ",", instigatorid);
        sprintf(sql+strlen(sql), "%u,", buff->GetNoOfTicks());
        sprintf(sql+strlen(sql), "%" PRIu64 ",", buff->GetTickLength());
        sprintf(sql+strlen(sql), "%u,", buff->GetCurrentTickNumber());
        sprintf(sql+strlen(sql), "%u,", bufficon);
        sprintf(sql+strlen(sql), "%" PRIu64 ",", currenttime);
        sprintf(sql+strlen(sql), "%" PRIu64 ");", buff->GetStartGlobalTick());

        buffAsyncContainer*	asContainer = new(buffAsyncContainer);
        asContainer->mQueryType		= BMQuery_Save_Async;
        asContainer->player			= player;
        asContainer->asyncContainer	= asyncContainer;
        asContainer->callBack		= callback;


        mDatabase->executeSqlAsync(this,asContainer,sql);



        int8 sql2[550];
        sprintf(sql2, "INSERT INTO %s.character_buff_attributes (buff_id,character_id,type,initial,tick,final) VALUES",mDatabase->galaxy());
        //Add Attributes
        AttributeList::iterator it = buff->Attributes.begin();

        //if we have no attributes
        if(it == buff->Attributes.end())
        {
            return true; //the first part generates already a callback
        }

        while(it != buff->Attributes.end())
        {
            BuffAttribute* batemp = *it;

            sprintf(sql2+strlen(sql2), "(%" PRIu64 ",", buff->GetID());
            sprintf(sql2+strlen(sql2), "%" PRIu64 ",", player->getId());
            sprintf(sql2+strlen(sql2), "%" PRIu64 ",", batemp->GetType());
            sprintf(sql2+strlen(sql2), "%d,", batemp->GetInitialValue());
            sprintf(sql2+strlen(sql2), "%d,", batemp->GetTickValue());

            AttributeList::iterator it2 = it;
            it2++;
            if(it2 != buff->Attributes.end())
            {
                sprintf(sql2+strlen(sql2), "%d),", batemp->GetFinalValue());
            } else
            {
                sprintf(sql2+strlen(sql2), "%d);", batemp->GetFinalValue());
            }
            it++;
        }

        asContainer					= new(buffAsyncContainer);
        asContainer->mQueryType		= BMQuery_Save_Async;
        asContainer->player			= player;
        asContainer->asyncContainer	= asyncContainer;
        asContainer->callBack		= callback;

        mDatabase->executeSqlAsync(this,asContainer,sql2);


        return true;
    }
    else
        return false;

}