[help] npc chat system

You must understand the Game Editor concepts, before post here.

[help] npc chat system

Postby GrimmDingo » Sat Jul 02, 2011 3:19 am

okay, I've began working on a banter/chit chat system parallel to the main dialogue system. It is a text bubble that appears above the NPC. Handling actions per clone is where my problem is, i've been trying to figure out how to use clones dynamically and it is almost dabblingly obscure, it's beyond my understanding of game editors scripting syntax, i would see it logical to be able to use something like
int i=cloneindex and then have textactor.[i]->text =dialogue
or some such, and i can't use strcpy it won't accept variable actor names. I've been trying different methods that seem logical but get innumerable errors, i've attempted to use things like using a function to call cloneID but it got too confusing on how to use it in the statements.

okay well I'll try to explain my goal and logical method:
I have a variable that stores a value directly relating to which line is called from an array of strings(chatlist), i want it also to be an array. Lets call it CHAT, and the reason for having it as an array is that each index of the array points to an NPC,
i.e. CHAT[2] is the relevant chat for NPC 2, so if CHAT[2]=15 then string 15 from the chatlist would be displayed above NPC2.
it is so that multiple instances can be going at once, i.e multiple NPCs chatting simultaneously.
also note that a single chatlist will be used by the entire CHAT array, so in most cases the same dialogue won't be called by other NPCs, except in special cases with generic reusable dialogue, I'll probably be separating chatlines by comment lines like NPC# and greetings etc.

okay this is incorrect I know, but this is to illustrate what I want happening to each clone seperately.
For text actor:
Code: Select all
if (CHAT[cloneindex] >0) // checking if the NPC with the same value is engaged in chat
{
 ChatID=getclone
char i= CHAT[cloneindex] //set the CHAT
ChatID->text= chatlist[i]
}


and of course I have a creator actor that creates a chat bubble parented to the NPC.
And the bubbles spawn the text, also The NPCs themselves will likely be separate actors so the anim list is separate and so I don't have to deal with the mess of actions per clone, also unless I create and pre parent each window to the npc invisible at startup, how will I reserve or assign clone index relative to the NPC number? :S
I'll upload a ged,
just a note though it hasn't got the CHAT array, just a single int called displaychat. I hadn't decided to use an array when I started prototyping it I'd have to change the scripts to reflect it being an array so I didn't change it.
Attachments
dialog.png
ChitChatproto.zip
(112.14 KiB) Downloaded 148 times
User avatar
GrimmDingo
 
Posts: 49
Joined: Wed Jun 08, 2011 12:49 pm
Location: Adelaide, Australia
Score: 7 Give a positive score

Re: [help] npc chat system

Postby GrimmDingo » Sat Jul 02, 2011 3:22 am

Also I'm having issue with the formatting of bitmap font in game editor :/
in my OriginalPost is an example image, the one on the left is the ideal placement of characters i did in the font creation and mock up phase, and is easily achieved with a bitmap parsing script, in fact I've used one before in SDL, (which I used reference to write), but calculated pixel distance between characters, so they were say 1px apart and spaces were 4 pixels, it was great for small fonts with wider and legible Ms and Ws, but game editors just places each character in a contiguous grid which kinda sucks for bitmap fonts, also just to point out one issue characters that aren't the same width as the other characters create formatting issues, for example unless your i is freakishly wide it looks like there are spaces in the middle of words :/ "i t would look a b i t like th i s ", in my prototype I just went with truetype scaled down but it is no real substitute especially considering 8 is the smallest size and my desired characters are smaller, which has made me create bigger text bubbles which obscure more of the playing field, I don't know how proper bitmap font formatting has been neglected this long, it's good it is there, most engines don't have it, but i can't understand why it is so lacking. Especially considering bitmapfont script source are reasonably common and simple to implement i would think, but suppose i'll manage with mono-tonal truetype font for the small text... Because i read in another post that it's not possible or atleast extremely difficult to create one with the script editor, and it'd likely add another layer of complication to calling text.
User avatar
GrimmDingo
 
Posts: 49
Joined: Wed Jun 08, 2011 12:49 pm
Location: Adelaide, Australia
Score: 7 Give a positive score

Re: [help] npc chat system

Postby jimmynewguy » Sat Jul 02, 2011 4:01 am

GrimmDingo wrote:...and i can't use strcpy it won't accept variable actor names

From Documentation:
sprintf: Use sprintf to mix fixed text (like "Hello...") with text in variables (like actor name, numbers, ...)

Code: Select all
sprintf(youractor.text, "Hello %s", stringvar);


and as for bitmap fonts maybe looking at pyro's will help? I've never used it so I don't know what's wrong really, but his works very well

just save it as a bmp, apparently .bmp extension is not allowed here..?
Attachments
pyro_font.PNG
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: [help] npc chat system

Postby GrimmDingo » Sat Jul 02, 2011 5:47 am

jimmynewguy wrote:
GrimmDingo wrote:...and i can't use strcpy it won't accept variable actor names

From Documentation:
sprintf: Use sprintf to mix fixed text (like "Hello...") with text in variables (like actor name, numbers, ...)

Code: Select all
sprintf(youractor.text, "Hello %s", stringvar);


and as for bitmap fonts maybe looking at pyro's will help? I've never used it so I don't know what's wrong really, but his works very well

just save it as a bmp, apparently .bmp extension is not allowed here..?

oh yeah i was using sprintf in other things i'm not sure if i did with this problem, fixed with mixed? Can it be mixed with mixed, you know to print a string from an array, would something like
Code: Select all
 
 
Actor 'actor' *getclone
eventID='actor'
a=cloneindex;
int i=CHAT[a]; /need to grab the current value of the chat relative to the NPC actor
sprintf (eventID.text, chatlist[i]);

if i used d%/i% will it print that? Or would something like this work?
sprintf(actorname.d%.text, s%, a, mystring);
i thought the % operators in sprintf only work for printing, and because the string is in an array would i need to call the string into a char variable, like char mystring=chatlist[i]?
Or do i need to specify it as a string like this
char mystring[255]=chatlist[i]
255 being the character limit in chatlist,

If not any of that how can i state it in a way that'll work? Will i need to compound the actorname and cloneindex into a string and use that in the statement?

it's starting to give me a headache, Can you see why i'm having trouble, would be good if it was less abstracted and ge could handle something as simple as
clonename.text=blahblah[i]
and it figures out the clone to handle on its own, and figure that blahblah is a string list and [i] is the line index, it'd make it as easy to use as the documentation claims, i'll be on pc soon so i'll try again, my major issue wasn't so much printing the text as it was handling it so with unique instances of the clone (relative to each NPC) the text would be called accordingly.

And the way it creates and destroys clones, it creates an index based on how many clones are already created? is it possible to create a clone with an index specified by the target parent

it's a nice balanced font, but it's not the bitmap font itself that's the problem, it's how game editor displays it, my font works as you can see in the image, but which looks better? Left or right, because as it is game editor can can only achieve the right on it's own, left is manual placement in gimp the right is game editor using the same character set, i had to widen the i or it looked too disjointed with the space between
User avatar
GrimmDingo
 
Posts: 49
Joined: Wed Jun 08, 2011 12:49 pm
Location: Adelaide, Australia
Score: 7 Give a positive score

Re: [help] npc chat system

Postby jimmynewguy » Sat Jul 02, 2011 7:53 pm

Both of them look fine to me. left maybe a little better not sure though.

I don't do much with strings or chat systems for that matter, maybe this will help you?

viewtopic.php?f=6&t=5206&p=34731&hilit=rpg#p34731

I'm not very good at explaining but if this doesn't help I'm sure I'll find another way to try and help
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: [help] npc chat system

Postby GrimmDingo » Mon Jul 11, 2011 5:44 pm

Sorry for late reply difficult getting on lately, mobile signal issues being one factor,
Thanks for trying to help, i appreciate it and glad you're offering to assist if and how you can, and that dialog example isn't really what i needed, because it doesn't use clones and it's just an ordinary dialog which my game has but is completely unrelated to this chat system, this system is basically text floaters above non player entities, i still haven't worked out a solution, but i've moved away from it for now until i understand how to dynamically handle clones in a single script, help achieving that would be great,

i've been working on a digital realm in my game when the player jacks into computer systems, i've got a sufficient collision system and control, and wrote my own movement with anti moonwalk, all in a single draw actor script using get key state, i find using key down key up to be a mess, i'll upload that in another thread sometime soon, also i've designed and mocked up a computer interface which is real basic and will use text scroll code i found in the forums to handle a window to display emails etc, i'll post that too, i'm thinking about other major gameplay mechanics and prototyped various things, so if anyone just read all this you'll know i'm still actively developing the game, i'll try my hardest to avoid this project becoming vapourware.
User avatar
GrimmDingo
 
Posts: 49
Joined: Wed Jun 08, 2011 12:49 pm
Location: Adelaide, Australia
Score: 7 Give a positive score

Re: [help] npc chat system

Postby jimmynewguy » Mon Jul 11, 2011 7:26 pm

This might be close to what you want, but I bet it's pretty unpractical for you. But it's really bugging me that I haven't helped yet :lol: either way glad you didn't give up on this project.

If this isn't it then I have a different idea I started to implement in this but didn't go that route. Since you were having problems with cloneindex matching the npc, you can make a variable called npc_num then when you create the text box set it equal to the npc.

Code: Select all
Actor * this;
this = CreateActor("chitchatbubble", "CHITCHATBUBBLE +", "Creator Actor", "(none)", 40, -55, false);
this->npc_num = cloneindex;


Then maybe the code you were trying earlier...?
Code: Select all
if (CHAT[npc_num] >0) // checking if the NPC with the same value is engaged in chat
{
ChatID = getclone2("TEXT", npc_num);
int i = CHAT[npc_num]; //set the CHAT
strcpy(ChatID->text, chat_list[displaychat]);
}


Jazz_e_bob's getclone2
Code: Select all
Actor *getclone2 ( char *actorName, long cloneNumber )
{
  char resultString[256] = "";
  char cloneNumberAsString[10];
  Actor *resultActor;

  strcpy ( resultString, actorName );
  strncat ( resultString, ".", 1 );
  sprintf (cloneNumberAsString, "%i", cloneNumber);
  strncat  ( resultString, cloneNumberAsString, 10 );

  resultActor = getclone(resultString);

  return resultActor;
}


I have a feeling none of this is helping either. If it is not maybe I could help a lot more if I saw an example .ged using the CHAT array that you have? It seems now that's the only part I don't understand, what CHAT array did and how it was used.
Attachments
ChitChatproto.zip
(113.29 KiB) Downloaded 121 times
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: [help] npc chat system

Postby GrimmDingo » Tue Jul 12, 2011 6:13 pm

thanks again, i've just downloaded the attachment, but reading your code i think you might've solved one of my major problems, which was trying to use getclone relative to the individual cloned actor being created, even though i thought of ways how i could get it working, i didn't do it right and got errors with the actor pointers, getclone2 should definitly address that, i just didn't know how to use it, so i'll check this out on pc when i can. But i've got the feeling you've nailed the problem that was holding me back :) i'll update you soon as i can
User avatar
GrimmDingo
 
Posts: 49
Joined: Wed Jun 08, 2011 12:49 pm
Location: Adelaide, Australia
Score: 7 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest

cron