Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / NPC class

Author
Message
How is it going
17
Years of Service
User Offline
Joined: 18th Sep 2007
Location: California
Posted: 23rd Jul 2009 04:40
ok I have a problem.
I'm trying to make a class for NPCs where I can define their names and statistics later on.
Here's what I have so far:

class NPC
{
public:
char Name[20];
int ex, ey, ebx, eby;
int Ehealth, EDamage;
bool attack;
}C1;
wickedly kick it
18
Years of Service
User Offline
Joined: 13th Jul 2006
Location: Fort-worth Texas
Posted: 23rd Jul 2009 07:15
You need more information,
What kind of game?
Is their Dialogue?
Are there quests?
and questions like that need to be answered,
also you need to put which way the npc is facing.

How is it going
17
Years of Service
User Offline
Joined: 18th Sep 2007
Location: California
Posted: 23rd Jul 2009 07:40
Well, the npcs will have RPG elements, so yes, there wilbe dialouge, quests, questions... which I'm not sure how to do without the iostream...
wickedly kick it
18
Years of Service
User Offline
Joined: 13th Jul 2006
Location: Fort-worth Texas
Posted: 23rd Jul 2009 07:43
iostream is irrelevant.
make a class for quests and assign them an id, and have several things like dialogue strings and quest id integers, just assign variables to everything to match everything up.

How is it going
17
Years of Service
User Offline
Joined: 18th Sep 2007
Location: California
Posted: 24th Jul 2009 00:23
Okay, I'm not sure what you meant by the integers and lining up..
but I just made this function instead:

void pick_a_quest( int a ) {
switch(a) {
case 1:
blah.. blah..
}
}
wickedly kick it
18
Years of Service
User Offline
Joined: 13th Jul 2006
Location: Fort-worth Texas
Posted: 24th Jul 2009 06:36
Im not experienced with DGDK yet, but i can tell you this, in Dark Basic Pro, i'd make variable for each aspect of the quest, for example i'd make each quest have a quest ID, then i'd assign quest id's to each NPC that gives a quest.

How is it going
17
Years of Service
User Offline
Joined: 18th Sep 2007
Location: California
Posted: 24th Jul 2009 07:23 Edited at: 24th Jul 2009 07:24
Okay, I understand what you're saying now...
I don't know, it seems that declaring all of those Varibles would be a lot of un-needed work...\
btw the "int a" in my switch is determined by object collision...
so collide w/ this person: get this dialouge...
wickedly kick it
18
Years of Service
User Offline
Joined: 13th Jul 2006
Location: Fort-worth Texas
Posted: 24th Jul 2009 08:09
Actually theres not alot of un-needed work, theres less! Im reading up on classes right now and i understand you can use functions within them, so say npc.collide(object1,object2)=1 then npc.give.quest(questId).

hope that may give some insperation maybe?

How is it going
17
Years of Service
User Offline
Joined: 18th Sep 2007
Location: California
Posted: 24th Jul 2009 09:28
Interesting... I'll try it.
How is it going
17
Years of Service
User Offline
Joined: 18th Sep 2007
Location: California
Posted: 24th Jul 2009 10:04 Edited at: 24th Jul 2009 10:04
okay I got a little work in and completely re-wrote the NPC class:
wickedly kick it
18
Years of Service
User Offline
Joined: 13th Jul 2006
Location: Fort-worth Texas
Posted: 24th Jul 2009 10:08
So far looks good, you may want to make it so that the user can converse with the NPC, add a variable for the users question and another for the response, i'd make quiet a few with a tree structure to make the questions have other questions associated with it.

How is it going
17
Years of Service
User Offline
Joined: 18th Sep 2007
Location: California
Posted: 24th Jul 2009 10:12
Hey, I will... as soon as I figure out how to do it effectively.
wickedly kick it
18
Years of Service
User Offline
Joined: 13th Jul 2006
Location: Fort-worth Texas
Posted: 24th Jul 2009 10:14 Edited at: 24th Jul 2009 10:15
I usually just make Types( classes in c++ ) for each of my repetitive components of a game, such as quests, buildings, items, enemies, and everything else. Then i can call their ID easily making them easily cross compatible

How is it going
17
Years of Service
User Offline
Joined: 18th Sep 2007
Location: California
Posted: 24th Jul 2009 10:18
so something like:
class talking
{
int select_statement(int& s)
};

int select_statement(int& s) {
if up ++s;
if down --s;
switch(s)
stuff....
return s;
}
How is it going
17
Years of Service
User Offline
Joined: 18th Sep 2007
Location: California
Posted: 24th Jul 2009 10:42
Okay, got it... kind of.

UPDATED NPC CLASS:


and TALKING HEADER:

Jumpster
16
Years of Service
User Offline
Joined: 7th Feb 2008
Location:
Posted: 24th Jul 2009 11:05
I would go about it something like so:



Regards,
Jumpster
How is it going
17
Years of Service
User Offline
Joined: 18th Sep 2007
Location: California
Posted: 24th Jul 2009 19:43
okay so make a class for each quest...
I'll try that...
How is it going
17
Years of Service
User Offline
Joined: 18th Sep 2007
Location: California
Posted: 24th Jul 2009 20:26
Hmmm...
Jumpster, I'm not sure how that code is supposed to work.
Could you please explain a little more.
For example: "player_class *player"?
How is it going
17
Years of Service
User Offline
Joined: 18th Sep 2007
Location: California
Posted: 24th Jul 2009 21:04
Okay never mind I've got something that works...


Thats in the "quests.h", which I call in "NPCs.h"
and call the q1 functions
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 24th Jul 2009 22:22
Quote: "okay so make a class for each quest..."


I'd highly advise you NOT do this. Instead, make your quest system able to handle all of your quest types, hard-coding such things just makes things hard to manage and expand, plus you don't want level specific things in code anyway.

How is it going
17
Years of Service
User Offline
Joined: 18th Sep 2007
Location: California
Posted: 24th Jul 2009 22:31
okay, how can I change the prompt then...?
a base class and strings?
How is it going
17
Years of Service
User Offline
Joined: 18th Sep 2007
Location: California
Posted: 24th Jul 2009 23:47 Edited at: 25th Jul 2009 00:37
Ok I think I've figured it out:


please comment if there's a better way to do this or you have a suggestion.
wickedly kick it
18
Years of Service
User Offline
Joined: 13th Jul 2006
Location: Fort-worth Texas
Posted: 25th Jul 2009 05:44
Quote: "I'd highly advise you NOT do this. Instead, make your quest system able to handle all of your quest types, hard-coding such things just makes things hard to manage and expand, plus you don't want level specific things in code anyway.
"

you could define the variables/classes/objects using an external file. Am i right?

dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 25th Jul 2009 13:25
Quote: "you could define the variables/classes/objects using an external file. Am i right?"


Of course, but that doesn't stop making hard-code that's only executed for a specific level bad practice.

How is it going
17
Years of Service
User Offline
Joined: 18th Sep 2007
Location: California
Posted: 25th Jul 2009 21:26
So I should code some sort of quest function where I can change things like the title, objectives, ect...
I'll try to do something that.
Bubzy
15
Years of Service
User Offline
Joined: 29th Jun 2009
Location: somewhere
Posted: 26th Jul 2009 00:23
i no longer use darkgdk but generally i would use something more like


class quest
{
public :
int questId;
/*stringtypehere*/ questText;
/*stringtypehere*/ completedText;


quest::quest(int id, /*stringtypehere*/ objective, /*stringtypehere*/ complete)
{
questId = id;
questText = objective;
completedText = complete;
}
};

assuming that you would want some sort of reward for your quest and that you would probably want it to be different for each quest, you would either have to overload the class constructor or have a very long single constructor call.

you would call your class like this(i think )

quest sandwich(1,"Get me a sandwich","thanks thats a nice sandwich);

also add a function to display the quest later on.

something like
void pickupQuest(quest &quest1)
{
dbText(x,y,quest1.questText);
}

void deliverQuest(quest &quest1)
{
// if quest complete
dbText(x,y,quest1.CompletedText);
}

something like this anyway. its best to make your code reusable. im working with XNA at the moment which allows you to create arrays of classes, assuming that c++ also lets you do this, this would be a good way to make your code more compact. hope i havent waffled on too much and good luck.

void void void void void void void
How is it going
17
Years of Service
User Offline
Joined: 18th Sep 2007
Location: California
Posted: 26th Jul 2009 03:56
Okay, I've read your post Bubzy.
I wrote this code before your post, but I think it handles pretty much what you and darkcoder are saying about it being reusable.


the stuff that starts with 'p' are pointers to C-style strings that I hard-coded earlier.
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 26th Jul 2009 07:15
You'd probably want it to be more dynamic than that, or at least in the future. On the current project I'm working on, NPC conversations are parsed from files into various instances of a Convo class. This class stores mainly the conversation pages and buttons that can be associated with any of them. However these are both stored in std::vector containers so I can easily add more to them when parsing.

The conversation pages I mentioned above are also classes, these store the NPC chat message and a list of buttons(stored in the convo class) you can press to continue the conversation or do whatever. These buttons are also classes and they store the button text, the page(stored in the convo) it jumps to when clicked and also a list of conditions for it to be displayed as well as actions performed when it's clicked.

Obviously you don't have to use a system like this, but this is an example of one conversation system that allows for pretty dynamic interactions.

How is it going
17
Years of Service
User Offline
Joined: 18th Sep 2007
Location: California
Posted: 26th Jul 2009 07:38
hmm... that seems a little more complex for what I'm looking for, but I would like to make the conversations more dynamic.
I would like it to be kind of like a web (like most RPGs) so that I can return to the start of the conversation which shouldn't be too hard to implement.
Also I mean to make t so that you can continue the conversation when you've finished reading.
And just a question, could you point me in the right direction to learn how to text wrap?
by the way what do you mean by conversation pages?
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 26th Jul 2009 16:42
Quote: "could you point me in the right direction to learn how to text wrap?"


The logic behind it is pretty simple if you think about it, but if you want code I think there's some in the TGC codebase.

Quote: "by the way what do you mean by conversation pages?"


Think of a page like... a page in a book. You start on page 1 and your buttons tell you to go to a different page and so on.

How is it going
17
Years of Service
User Offline
Joined: 18th Sep 2007
Location: California
Posted: 26th Jul 2009 20:59
Thanks for the link, dark coder

Login to post a reply

Server time is: 2024-10-01 08:34:03
Your offset time is: 2024-10-01 08:34:03