Esempio n. 1
0
int CPlayer::ExecuteQuestTrigger(dword hash)
{
    CQuestTrigger* trigger = NULL;
    CQuestTrigger* nexttrigger = NULL;
    CheckQuest = -1;
    for(unsigned j=0; j < GServer->TriggerList.size(); j++)
    {
        if (GServer->TriggerList.at(j)->TriggerHash == hash)
        {
            trigger = GServer->TriggerList.at(j);
            nexttrigger = GServer->TriggerList.at(j + 1);
            break;
        }
    }
    if (trigger == NULL) return QUEST_FAILURE;

    int success = QUEST_SUCCESS;
    //Log(MSG_DEBUG, "Trigger Executed: %s [%i] hash %i", trigger->TriggerName, trigger->CheckNext, hash);
    if(Session->codedebug)GServer->SendPM(this, "Trigger executed %s[%i]", trigger->TriggerName, trigger->CheckNext);
    for (dword i = 0; i < trigger->ConditionCount; i++)
    {
        int command = trigger->Conditions[i]->opcode;
        
        if (command > 30 || command < 0) continue;
        success = (*GServer->qstCondFunc[command])(GServer, this, trigger->Conditions[i]->data);
        //Log(MSG_DEBUG, "Condition %03u returned %d", command, success);
        if(Session->codedebug)GServer->SendPM(this, "Condition %03u returned %d", command, success);
        if (success == QUEST_FAILURE)
	    {
            if (!trigger->CheckNext)
		        return success;
            else return ExecuteQuestTrigger(nexttrigger->TriggerHash);
        }
    }
    for (dword i = 0; i < trigger->ActionCount; i++)
    {
        int command = trigger->Actions[i]->opcode;
        if(Session->codedebug)GServer->SendPM(this, "command %03u", command);
        if (command > 30 || command < 0) continue;
        if(Session->codedebug)GServer->SendPM(this, "Still good after command value check");
        success = (*GServer->qstRewdFunc[command])(GServer, this, trigger->Actions[i]->data);
        if(Session->codedebug)GServer->SendPM(this, "reward %03u returned %d", command, success);
        //Log(MSG_DEBUG, "Reward %03u returned %d", command, success);
    }
    return success;
}
Esempio n. 2
0
//LMA: AIP (qsd quests).
int CCharacter::ExecuteQuestTrigger(dword hash)
{
    CQuestTrigger* trigger = NULL;
    CQuestTrigger* nexttrigger = NULL;
    for(unsigned j=0; j < GServer->TriggerList.size(); j++)
    {
      if (GServer->TriggerList.at(j)->TriggerHash == hash)
      {
        trigger = GServer->TriggerList.at(j);

        //LMA: bug on next trigger.
        if(j+1<GServer->TriggerList.size())
        {
            nexttrigger = GServer->TriggerList.at(j + 1);
        }

        break;
      }
    }

    if (trigger == NULL)
    {
        LogDebug( "EXTC::Trigger not found hash %u", hash);
        return QUEST_FAILURE;
    }

    int success = QUEST_SUCCESS;
    LogDebug( "EXTC::Trigger Executed: %s[%i]", trigger->TriggerName, trigger->CheckNext);

    for (dword i = 0; i < trigger->ConditionCount; i++)
    {
      int command = trigger->Conditions[i]->opcode;
      if (command > 30 || command < 0) continue;
      success = (*GServer->qstCondFuncC[command])(GServer, this, trigger->Conditions[i]->data);
      LogDebug( "EXTC::Condition %03u returned %d", command, success);

      if (success == QUEST_FAILURE)
      {
        if (!trigger->CheckNext)
        {
            LogDebug("EXTC::No checknext, FAILURE");
            return success;
        }
        else
        {
            LogDebug("EXTC::checknext, FAILURE");
            if(nexttrigger==NULL)
            {
                Log(MSG_WARNING,"CCharacter::ExecuteQuestTrigger, Next trigger but NULL! %u",hash);
                return QUEST_SUCCESS;
            }

            return ExecuteQuestTrigger(nexttrigger->TriggerHash);
        }

      }

      LogDebug("EXTC::Quest cdt success");
    }

    for (dword i = 0; i < trigger->ActionCount; i++)
    {
      int command = trigger->Actions[i]->opcode;
      if ((command > 28 || command < 0) && command != 34)
      {
          LogDebug( "EXTC::unknown Action command %i", command);
          continue;
      }

      //LogDebug("EXTC::QSD ACT %03u BEGIN",command);
      LogDebug( "EXTC::Reward %03u returned %d", command, (*GServer->qstRewdFuncC[command])(GServer, this, trigger->Actions[i]->data));
    }


    return success;
}
Esempio n. 3
0
//LMA: AIP (qsd quests).
int CCharacter::ExecuteQuestTrigger(dword hash, UINT index)
{
    if(IsPlayer())
    {
        Log(MSG_WARNING,"In CHARACTER!!! %u",hash);
    }

    CQuestTrigger* trigger = NULL;
    CQuestTrigger* nexttrigger = NULL;

    //LMA: To counter some very weird cases where the hashes exist several times...
    UINT my_index=0;
    //for(unsigned j=0; j < GServer->TriggerList.size(); j++)
    for(unsigned j=index; j < GServer->TriggerList.size(); j++)
    {
      if (GServer->TriggerList.at(j)->TriggerHash == hash)
      {
        trigger = GServer->TriggerList.at(j);

        //LMA: bug on next trigger.
        if(j+1<GServer->TriggerList.size())
        {
            my_index=j+1;
            nexttrigger = GServer->TriggerList.at(j + 1);
        }

        break;
      }

    }

    if (trigger == NULL)
    {
        LogDebug( "EXTC::Trigger not found hash %u, index %u", hash,index);
        return QUEST_FAILURE;
    }

    int success = QUEST_SUCCESS;
    //LogDebug( "EXTC::Trigger Executed: %s[%i]", trigger->TriggerName, trigger->CheckNext);
    //Log(MSG_WARNING,"EXTP::Trigger Executed: %s[next? %i]", trigger->TriggerName, trigger->CheckNext);

    for (dword i = 0; i < trigger->ConditionCount; i++)
    {
        int command = trigger->Conditions[i]->opcode;
        if (command > 30 || command < 0) continue;
        success = (*GServer->qstCondFuncC[command])(GServer, this, trigger->Conditions[i]->data);
       // LogDebug( "EXTC::Condition %03u returned %d", command, success);
        //Log(MSG_WARNING,"EXTP::Condition %03u returned %d", command, success);

        if (success == QUEST_FAILURE)
        {
            if (!trigger->CheckNext)
            {
                //LogDebug("EXTC::No checknext, FAILURE");
                //Log(MSG_WARNING,"EXTP::No checknext (FAILURE)");
                return success;
            }
            else
            {
                //LogDebug("EXTC::checknext, FAILURE");
                //Log(MSG_WARNING,"EXTP::checknext because FAILURE, will do %u",nexttrigger->TriggerHash);
                if(nexttrigger==NULL)
                {
                    //Log(MSG_WARNING,"CCharacter::ExecuteQuestTrigger, Next trigger but NULL! %u",hash);
                    return QUEST_SUCCESS;
                }
               // if(GServer->ServerDebug)
                    //Log(MSG_DEBUG,"Executing Quest Trigger for NextTrigger from Playerfunction");
                return ExecuteQuestTrigger(nexttrigger->TriggerHash,my_index);
            }
        }
        //LogDebug("EXTC::Quest cdt success");
            //Log(MSG_WARNING,"EXTP::Quest cdt %i / %i success",i+1,trigger->ConditionCount);
    }
    for (dword i = 0; i < trigger->ActionCount; i++)
    {
      int command = trigger->Actions[i]->opcode;

       //LMA: command 29 is ok.
      //if ((command > 28 || command < 0) && command != 34)
      if ((command > 29 || command < 0) && command != 34)
      {
          //LogDebug( "EXTC::unknown Action command %i", command);
          //Log(MSG_WARNING,"unknown Action command %i", command);
          continue;
      }

      //LogDebug("EXTC::QSD ACT %03u BEGIN",command);
      //LogDebug( "EXTC::Reward %03u returned %d", command, (*GServer->qstRewdFuncC[command])(GServer, this, trigger->Actions[i]->data));
    }
    return success;
}