]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
random dialog
authorClyne Sullivan <tullivan99@gmail.com>
Wed, 9 Dec 2015 13:46:35 +0000 (08:46 -0500)
committerClyne Sullivan <tullivan99@gmail.com>
Wed, 9 Dec 2015 13:46:35 +0000 (08:46 -0500)
include/entities.h
src/entities.cpp

index 77ca347b9855d074bde55bdf4bd12875dc6898d8..64a251ae3f1ed276ef118bf99b2274d140d8aa75 100644 (file)
@@ -79,6 +79,7 @@ public:
        
        Texturec *tex;
 
+       unsigned int randDialog;
 
        void draw(void);
        void spawn(float, float);
index 08af0a9b05c0b5d6f72b1d5d96c13094a4203f5e..fc2c316cae96eaf0e90e91deff9a45a40fb20719 100644 (file)
@@ -102,6 +102,8 @@ NPC::NPC(){ //sets all of the NPC specific traits on object creation
        
        tex = new Texturec(1,"assets/NPC.png");
        inv = new Inventory(NPC_INV_SIZE);
+       
+       randDialog = rand() % 10;
 }
 NPC::~NPC(){
        while(!aiFunc.empty()){
@@ -307,26 +309,43 @@ void NPC::addAIFunc(int (*func)(NPC *),bool preload){
        else aiFunc.push_back(func);
 }
 
+const char *randomDialog[10] = {
+       "What a beautiful day it is.",
+       "Have you ever went fast? I have.",
+       "I heard if you complete a quest, you'll get a special reward."
+       "How much wood could a woodchuck chuck if a woodchuck could chuck wood?",
+       "I don\'t think anyone has ever been able to climb up that hill.",
+       "If you ever see a hole in the ground, watch out; it could mean the end for you.",
+       "Did you know this game has over 4000 lines of code? I didn\'t. I didn't even know I was in a game until now...",
+       "HELP MY CAPS LOCK IS STUCK",
+       "You know, if anyone ever asked me who I wanted to be when I grow up, I would say Abby Ross.",
+       "I want to have the wallpaper in our house changed. It doesn\'t really fit the environment."
+};
+
 void NPC::interact(){ //have the npc's interact back to the player
        int (*func)(NPC *);
        loc.y += 5;
+       
+       canMove=false;
+       left = (player->loc.x < loc.x);
+       right = !left;
+       
        if(aiFunc.size()){
                func=aiFunc.front();
-               canMove=false;
-               
-               left = (player->loc.x < loc.x);
-               right = !left;
                
                if(!func(this)){
                        if(aiFunc.size())aiFunc.erase(aiFunc.begin());
                }
-               canMove=true;
+       }else{
+               ui::dialogBox(name,NULL,randomDialog[randDialog]);
        }
+       ui::waitForDialog();
+       canMove=true;
 }
 
 void Object::interact(void){
        if(questObject && alive){
-               ui::dialogBox("You",":Yes:No",pickupDialog);            
+               ui::dialogBox(player->name,":Yes:No",pickupDialog);             
                ui::waitForDialog();
                if(ui::dialogOptChosen == 1){
                        player->inv->addItem((ITEM_ID)(identifier), (char)1);