-#include <Quest.h>\r
-#include <entities.h>\r
+#include <common.h>\r
+//#include <Quest.h>\r
+//#include <entities.h>\r
\r
const Quest QuestList[TOTAL_QUESTS]={\r
Quest("Test","A test quest",(struct item_t){1,TEST_ITEM})\r
\r
int QuestHandler::assign(const char *t){\r
unsigned char i;\r
- for(i=0;i<current.size();i++){\r
+ for(i=0;i<current.size();i++){ // Make sure we don't already have this quest\r
if(!strcmp(current[i]->title,t)){\r
+#ifdef DEBUG\r
+ DEBUG_printf("The QuestHandler already has this quest: %s\n",t);\r
+#endif // DEBUG\r
return -2;\r
}\r
}\r
- for(i=0;i<TOTAL_QUESTS;i++){\r
+ for(i=0;i<TOTAL_QUESTS;i++){ // Add the quest (if it really exists)\r
if(!strcmp(QuestList[i].title,t)){\r
current.push_back(&QuestList[i]);\r
+#ifdef DEBUG\r
+ DEBUG_printf("Added quest %s, now have %u active quests.\n",t,current.size());\r
+#endif // DEBUG\r
return current.size();\r
}\r
}\r
+#ifdef DEBUG\r
+ DEBUG_printf("Quest %s does not exist.\n",t);\r
+#endif // DEBUG\r
return -1;\r
}\r
\r
unsigned int r;\r
for(i=0;i<current.size();i++){\r
if(!strcmp(current[i]->title,t)){\r
+#ifdef DEBUG\r
+ DEBUG_printf("Completing quest %s.\n",t);\r
+#endif // DEBUG\r
((Entity *)completer)->inv->addItem(current[i]->reward.id,current[i]->reward.count);\r
current.erase(current.begin()+i);\r
+#ifdef DEBUG\r
+ DEBUG_printf("QuestHandler now has %u active quests.\n",current.size());\r
+#endif // DEBUG\r
return 0;\r
}\r
}\r
+#ifdef DEBUG\r
+ DEBUG_printf("QuestHandler never had quest %s.\n",t);\r
+#endif // DEBUG\r
return -1;\r
}\r
\r
SDL_Surface *image = IMG_Load(fileName);
if(!image)return 0;
- #ifdef DEBUG
+#ifdef DEBUG
DEBUG_printf("Loaded image file: %s\n", fileName);
- #endif // DEBUG
+#endif // DEBUG
unsigned object = 0; //creates a new unsigned variable for the texture
glGenTextures(1, &object); //turns "object" into a texture
}
int giveTestQuest(NPC *speaker){
- static bool done=false;
- if(!done){
- ui::dialogBox(speaker->name,"Here, have a quest!");
- player->qh.assign("Test");
- done=true;
- }
- /*while(ui::dialogBoxExists){
- mainLoop();
- }*/
+ ui::dialogBox(speaker->name,"Here, have a quest!");
+ player->qh.assign("Test");
NPCp(entity[2])->addAIFunc(compTestQuest);
return 0;
}
entity[entity.size()-1]->spawn(200,100); //sets the position of the villager around the village
entity.pop_back();
+
+ NPCp(entity[1])->addAIFunc(giveStuff);
NPCp(entity[1])->addAIFunc(giveTestQuest);
for(i=0;i<entity.size()+1;i++){
entity[i]->inWorld=test;
- if(entity[i]->type==NPCT&&i>1)NPCp(entity[i])->addAIFunc(giveStuff);
}
}