Crystal Space
Welcome, Guest. Please login or register.
April 21, 2014, 05:58:59 am

Login with username, password and session length
Search:     Advanced search
8990 Posts in 2037 Topics by 7600 Members
Latest Member: Chandrabeck
* Home Help Search Login Register
+  Crystal Space
|-+  Associate Projects
| |-+  CEL Discussion
| | |-+  Quest System
« previous next »
Pages: [1] Print
Author Topic: Quest System  (Read 3440 times)
Gladius_Coldhead
Newbie
*
Posts: 9


View Profile Email
« on: July 17, 2007, 05:45:01 am »

Hi.


Somebody know where I find an example of  CEL Quest System in C++ or an example of some Custom Quest System(using CEL Quest)?


Thanks
Logged
jorrit
Administrator
Hero Member
*****
Posts: 1704


View Profile
« Reply #1 on: July 17, 2007, 08:34:36 am »

Hi.


Somebody know where I find an example of  CEL Quest System in C++ or an example of some Custom Quest System(using CEL Quest)?


Thanks

There is no such example at the moment but it should be just a matter of using the API. In very early versions of celtest when the quest manager was just created there was actually an example there. I extracted it from svn for you:

Code:
csPtr<iCelEntity> CelTest::CreateQuest (const char* name)
{
  // The Quest Entity
  csRef<iCelEntity> entity_quest = pl->CreateEntity (name, bltest, "quest",
       "pclogic.quest", "pctools.properties", CEL_PROPCLASS_END);
  if (!entity_quest) return 0;

  csRef<iQuestManager> qm = csQueryRegistry<iQuestManager> (object_reg);
  iChangePropertyQuestRewardFactory* rf_changeprop;

  //-----------------------------------------------------------
  // Create 'testquest'.
  //-----------------------------------------------------------
  iQuestFactory* fact = qm->CreateQuestFactory ("testquest");

  // ---- init ----
  iQuestStateFactory* state_init = fact->CreateState ("init");
  iQuestTriggerResponseFactory* init_response1 =
        state_init->CreateTriggerResponseFactory ();

  qm->SetTimeoutTrigger (init_response1, "1000");
  qm->AddDebugPrintReward (init_response1, "$message");
  qm->AddNewStateReward (init_response1, "$ent", "start");
  rf_changeprop = qm->AddChangePropertyReward (init_response1,
       "$ent", "counter");
  rf_changeprop->SetLongParameter ("0");

  // ---- start ----
  iQuestStateFactory* state_start = fact->CreateState ("start");
  iQuestTriggerResponseFactory* start_response1 =
       state_start->CreateTriggerResponseFactory ();

  qm->SetMeshEnterSectorTrigger (start_response1, "camera", "room0,1");
  qm->AddDebugPrintReward (start_response1, "Done!");
  qm->AddNewStateReward (start_response1, "$ent", "middle");

  iQuestTriggerResponseFactory* start_response2 =
        state_start->CreateTriggerResponseFactory ();
  qm->SetPropertyChangeTrigger (start_response2, "$ent", "counter", "5");
  qm->AddDebugPrintReward (start_response2, "We reached 5!");
  qm->AddNewStateReward (start_response2, "$ent", "end");

  // ---- middle ----
  iQuestStateFactory* state_middle = fact->CreateState ("middle");
  iQuestTriggerResponseFactory* middle_response1 =
        state_middle->CreateTriggerResponseFactory ();

  qm->SetMeshEnterSectorTrigger (middle_response1, "camera", "room");
  qm->AddNewStateReward (middle_response1, "$ent", "start");
  qm->AddDebugPrintReward (middle_response1, "And Back!");
  rf_changeprop = qm->AddChangePropertyReward (middle_response1,
        "$ent", "counter");
  rf_changeprop->SetDiffParameter ("1");

  // ---- end ----
  fact->CreateState ("end");

  //-----------------------------------------------------------

  csRef<iPcQuest> pcquest = CEL_QUERY_PROPCLASS_ENT (entity_quest, iPcQuest);
  celQuestParams params;
  params.Put ("message", "Hallo Hallo!");
  params.Put ("ent", name);
  if (!pcquest->NewQuest ("testquest", params))
  {
    ReportError ("Error creating quest '%s'!", "testquest");
    return 0;
  }
  pcquest->GetQuest ()->SwitchState ("init");

  return csPtr<iCelEntity> (entity_quest);
}

I haven't tested if it still works but I think it should. Let me know if you have further questions.

Greetings,
Logged
Gladius_Coldhead
Newbie
*
Posts: 9


View Profile Email
« Reply #2 on: July 21, 2007, 05:18:12 am »

Oh...really thanks xD
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 7.697 seconds with 18 queries.