Archived

This topic is now archived and is closed to further replies.

Text Rpg

This topic is 5735 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m planning on making a text rpg, strongly based on magic spells. I need some ideas. Should I feature different races and classes, and if so, which ones? Also, how should I do the (turn-based) combat system???

Share this post


Link to post
Share on other sites
Hey, what are you doing it in?

If you care about her/him, you''''ll listen
If you love her/him, you''''ll heal his/her wounds
If you like her/him, you''''ll do all of the above, and help her/him in need

A person who cares is a person who never speaks

Share this post


Link to post
Share on other sites
Hmm....I attempted this once before! I did OK but it got to hard (for me) to code after a while so the project was basically scrapped. In my opinion, all RPG''s should have different races and classes. I once found a website that hosted a zip file containing a combat system code for a MUD. I got lost trying to figure out what was what.

If your going to code a text-based RPG, I suggest using C++. THe "If" statements are great. Let me know if you need any help and I''ll be glad to help you out!

Master Conjurer

Share this post


Link to post
Share on other sites
quote:
Original post by masterconjurer
Let me know if you need any help and I''ll be glad to help you out!


I ain''t on this project, but can you help on the "if" statements, because here''s my problem:
I want to have an yes/no type of thing, and here''s the code for choice:

if (yesno == 1 || yesno == 2 || yesno == 3 || yesno == 4)
cout << "Ok, now your ready to go....aren''t you?\n";
cin >> "yesno";

now, after the cin >> "yesno";, I typed this:
if (yesno == no)
cout << "Just start this prog when your ready.";
else
{
cout << "Great let''s start!";
}, the only thing that works is the else statement. Does anyone know how to fix this?




If you care about her/him, you''''ll listen
If you love her/him, you''''ll heal his/her wounds
If you like her/him, you''''ll do all of the above, and help her/him in need

A person who cares is a person who never speaks

Share this post


Link to post
Share on other sites
Three points:

1) Learn to use switch statements where appropriate (incidental to your code):


      switch (yourNumber)
{
case 1: doSomething();
break;
case 2: doAnotherThing();
break;
// etc.

}


2) Learn to use the operators >, >=, <, <=, etc. It'll save you quite a lot of bother.


  if (yesno >= 1 && yesno <= 4)...  


3) Your code doesn't work because you put quotes around "yesno" in your cin statement. It's a variable, so it doesn't want those quotes. Also, it is after the if statement. "if this variable holds these values, then get its value?" Use a different variable, because you seem to be comparing it as a string at one point and as an int at another point.

Sorry about being so snippy, but I've got to do work and it's put me in a bad mood. Grrrrrrrr!
EDIT: Andrew, I assume you code with your eyes shut? Yo mama's so fat, she stepped on a talking scale and it told her "Sorry, we don't do livestock."

Alimonster

"If anyone can show me, and prove to me, that I am wrong in thought or deed, I will gladly change. I seek the truth, which never yet hurt anybody. It is only persistence in self-delusion and ignorance which does harm." -- Marcus Aurelius

[edited by - Alimonster on March 24, 2002 2:03:03 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by Alimonster
Three points:

1) Learn to use switch statements where appropriate (incidental to your code):



      switch (yourNumber)
{
case 1: doSomething();
break;
case 2: doAnotherThing();
break;
// etc.

}

2) Learn to use the operators >, >=, <, <=, etc. It'll save you quite a lot of bother.

if (yesno >= 1 && yesno <= 4)...


3) Your code doesn't work because you put quotes around "yesno" in your cin statement. It's a variable, so it doesn't want those quotes. Also, it is after the if statement. "if this variable holds these values, then get its value?" Use a different variable, because you seem to be comparing it as a string at one point and as an int at another point.

1. I did start out with swtiches, but it wouldn't work, so I decided to go with "if" statements, and then I just realized that I did that little quote thing, so I'll fix that...and I'll do the <= and stuff, thanks.



If you care about her/him, you''ll listen
If you love her/him, you''ll heal his/her wounds
If you like her/him, you''ll do all of the above, and help her/him in need

A person who cares is a person who never speaks

[edited by - Quantrizi on March 24, 2002 1:41:26 PM]

Share this post


Link to post
Share on other sites
Switch statements are useful if you want to get rid of many if statements of the form:

if (something == 1)
// blah
else
if (something == 2)
// blah
else
if (something...) // etc

...so it''s not what you need to do here, but is handy to know for the future. You want something akin to the following. User validation and making it good is left as an exercise.


  int choice;
char blah[100];

cout << "Enter your choice, punk: ";

cin >> choice;

if (choice >= 1 && choice <= 4)
{
cout << "All your base are belong to us?" << endl;
cin >> blah;

if (strcmp(blah, "yes") == 0)
{
// they said yes.

}
}


Alimonster

"If anyone can show me, and prove to me, that I am wrong in thought or deed, I will gladly change. I seek the truth, which never yet hurt anybody. It is only persistence in self-delusion and ignorance which does harm." -- Marcus Aurelius

Share this post


Link to post
Share on other sites
I''m wondering if I should do my game in Vb6, or C++6. I''m more experienced in VB. I don''t know how to make a GUI in C++. Also, if I used C++, would I do it for DOS or Windows? BTW, I want to make one text-box for output, and one for input, so my simple DOS C++ line-by-line knowledge would not be sufficient, and I don''t know how to program for Windows in C++. I could do it in Java, which I''m currently learning.

Share this post


Link to post
Share on other sites
I''m wondering if I should do my game in Vb6, or C++6. I''m more experienced in VB. I don''t know how to make a GUI in C++. Also, if I used C++, would I do it for DOS or Windows? BTW, I want to make one text-box for output, and one for input, so my simple DOS C++ line-by-line knowledge would not be sufficient, and I don''t know how to program for Windows in C++. I could do it in Java, which I''m currently learning. Also, I need help with ideas for designing caracter classes, spells...

Share this post


Link to post
Share on other sites
Heres MY implementation:


  
#include <iostream>
#include <string>
#include <stdio>

string direction_msg = "1- Up\n2- Down\n3- Left\n4- Right";
string choice;
char* msgofroom[bufferx][buffery];

void takestringsfromfile()
{
//insert code that puts strings

// into msgofroom

}

int main()
{
while (1) //For is a waste of space here

{
cout << msgofperson[x][y] << endl;
cout << direction_msg;
cin.getline(choice, 100);
//clipping code

//Movement code

}
}

that is my implementation.

Share this post


Link to post
Share on other sites
You can kind of do graphics in DOS if you really try. Check this link out. I did not do it but it is very creative.

telnet://towel.blinkenlights.nl/


-----------------------------
"There are ones that say they can and there are those who actually do."

"...u can not learn programming in a class, you have to learn it on your own."

Share this post


Link to post
Share on other sites
quote:
Original post by Andrew Nguyen
Heres MY implementation:
what follows amounts to rubbish

It doesn''t compile, for a number of reasons. It''s not complete either, and all the critical logic is absent.

Ergo, you suck. :D

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!

Share this post


Link to post
Share on other sites
quote:
Original post by Andrew Nguyen
OF COURSE ITS NOT GOING TO COMPILE! I was just showing how I would do the rooms stuff.


What's the point of posting unrelated code that doesn't compile?

  #include <iostream>


int main()
{
while("Andrew Nguyen is annoying")
std::cout << "Yo momma!" << std::endl;

return 0;
}

gamechampionx: you can do GUI with C++ using MFC, but that blows chunks. If you can, try to get hold of Borland C++ Builder because it's much simpler. Most difficult case, you can use the Windows API directly (which isn't actually that far removed from MFC ).

I would say, though, that if this is a learning exercise you could try doing it in Java. The syntax is quite similar (to an extent). Computer language skills should be transferable - once you know a language well (I mean well!) you should be able to switch to another in a week or two.

First of all, before deciding on classes, let's have a storyline

Alimonster

[edited by - Alimonster on March 25, 2002 1:16:26 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by gamechampionx
BTW, what's std::cout?
What syntax and format should I use? Also, which header files??

It's to do with "namespaces", which are a way to keep parts of your code in a separate place. You've probably been doing this:

#include <iostream.h>
cout << "whatever" << endl;

However, that's actually non-standard (old, inadvisable). Namespaces let you wrap up things, so if you did this:

      namespace Something
{
void myFunc();
}

namespace AnotherNamespace
{
void myFunc();
}

...then you'd access them like this:
Something::myFunc(); // or AnotherNamespace::myFunc();

That can help to reduce conflicts with any code named the same.

The iostream is contained in the namespace "std", which means that you can either do this:


  #include <iostream> /* no .h */


using namespace std;
// from now on, no need for std:: before everything



//...or this:


#include <iostream>


std::cout << "something" << std::endl;

etc.

Namespaces are a way of cleaning up your code. There was a discussion about them over here and here not long ago. Also, have a look over here.

Alimonster

"If anyone can show me, and prove to me, that I am wrong in thought or deed, I will gladly change. I seek the truth, which never yet hurt anybody. It is only persistence in self-delusion and ignorance which does harm." -- Marcus Aurelius

[edited by - Alimonster on March 27, 2002 8:41:46 PM]

Share this post


Link to post
Share on other sites
Perhaps it''s good to be exposed to more advanced things early, but I would just begin with cout<< instead of namespaces. I''ve been programming for awhile, and have never even heard of namespaces. Granted, I''m still a newbie for the most part, but I think cout<< is fine for now

Anyway... I don''t know if this is helpful, but I''d definetly advise switches over multiple ifs. For example, if you wanted to make some sort of battle menu:


  

switch(choice)
{
case ''a'':
case ''A'':
{
Attack();
}

case ''r'':
case ''R'':
{
Run();
}

} //switch




Two cases, in case the user accidentally has capslock on. Of course, you could retrieve choice (a char) using cin or, for a bit of extra spiffiness, use a kbhit() and getch() combo so that the user doesn''t have to press enter For some semblance of a GUI, you could make a box using various ascii charcters and then have something like:

====================
-


' Target=_Blank>Link

Share this post


Link to post
Share on other sites
Why not do it in real time?


  

void Attack(int direction,int currententity);
void Run(int direction,int currententity);

void Attack(int direction,int currententity)
{
// Insert a message in the message loop.

mymessageeventclass M;

M.time = GetMyCurrentTime();
M.message = ATTACK; // can be a constant

M.owner = currententity; // Global owner identifyer.


PostMyMessage(M);
}

void Run(int direction,int currententity)
{
// Insert a message in the message loop.

mymessageeventclass M;

M.time = GetMyCurrentTime();
M.message = RUN; // can be a constant

M.owner = currententity; // Global owner identifyer.


PostMyMessage(M);
}


void DoGameRules(int self)
{
myentityclass E;

E = GetEntity(self);

// Here you insert you user input stuff or automatic NPC stuff


if(!E.npc)
FeelForUserInput(E);
else
DoNPCInput(E);

switch(something)
{
case ATTACK:
Attack(E.userdirection,self);
case RUN:
Run(E.userdirection,self);
}
}

int MainLoop(int params)
{

int ret=0;

// Read all your message events and handle them

while( (ret = GetMyMessage()) != 0)
;

if(ret == 0)
return 0;

// Produce more messages for next frame.

for(int i=0; i <= NUM_ENTITIES; i++)
{
ret = DoGameRules(i);
if(ret == 0)
return 0;
}

return ret;
}

int main(void)
{
while(DoMainLoop() != 0)
;
}



I left alot for you to write yourself, but it will be fairly easy:
The message event could be a simple linked list or a stack ().

The benefits for this system is that you can post anything into the message loop, even messages to change desktop resolution or send messages over the net.

Even if this is a turn based game, you want to be able to feel for user inputs while it calculates the next frame. This can be done by either threads or message loops. Just post a ''FeelUserInput'' message every now and then and let user do stuff while processing.

This is great stuff, I promise you.



Share this post


Link to post
Share on other sites
quote:
Original post by Andrew Nguyen
Ahhh... forget I ever said anything.

we will... until you open your bleeding hole again...

Share this post


Link to post
Share on other sites
I probably won''t use namespaces for now. Anyway, how do you locate a certain position on the screen to input/output text? And how do you clear the screen (DOS).


On a separate note, I''m thinking of adding many classes and races, so you can mix and match, like having an elf mage or human fighter. Which classes should I implement.
Also, what sould be different between races. Maybe some start with stats in certain areas, and certain abilities. However, I want it to even out at the end so all races are equal, just getting there is different. I also want to do different spells for different classes. How should you learn magic? Maybe books, or should I go by level, or both?

Input is appreciated!!!

Share this post


Link to post
Share on other sites