Author Topic: NPC dialogue?  (Read 4627 times)

0 Members and 1 Guest are viewing this topic.

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
NPC dialogue?
« on: October 27, 2007, 06:03:00 am »
I was wondering what would be the quickest way to retrieve NPC dialouge in an RPG? For example; you are standing in front of an NPC and PRESS 2nd. The program checks and verifies that there is an NPC standing in front of you and then the subroutine determines what text is to be put on the screen is run. My quesion is what would be the most efficent way to determine what text the NPC you are talking to will say. The only way I can think of is ALOT of IF statments, but I don't want it to take longer and longer to retrive text the further you progess into the game, but i can't think of a way to keep the speed from degrading over time. Can some one help me out with this, Im probably over thinking this.

Offline Halifax

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1334
  • Rating: +2/-1
    • View Profile
    • TI-Freakware
NPC dialogue?
« Reply #1 on: October 27, 2007, 06:43:00 am »
Well, this is how I used to solve it.

Have a string like this:

"/npc text 1/npc text 2/npc text 3" etc.

Then find out which NPC the player is talking to, and then from there you do an inString() look for the '/' that is NPC number. Does that make sense?
There are 10 types of people in this world-- those that can read binary, and those that can't.

Offline Netham45

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2103
  • Rating: +213/-4
  • *explodes*
    • View Profile
NPC dialogue?
« Reply #2 on: October 27, 2007, 06:45:00 am »
idk, but mabye you  could put all the text in a string, where every NPC has a static length of characters, then use the Sub( command to pull out that ones characters based on a number the NPC has been assigned.
Omnimaga Admin

Offline Halifax

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1334
  • Rating: +2/-1
    • View Profile
    • TI-Freakware
NPC dialogue?
« Reply #3 on: October 27, 2007, 07:07:00 am »
Well I used the instring method

Goes like this(in pseudo code):

instring(1,SlashYouWant)->A
instring(A,1)->B
B-A->length

sub(Str, A, length)

pretty simple
There are 10 types of people in this world-- those that can read binary, and those that can't.

Offline Netham45

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2103
  • Rating: +213/-4
  • *explodes*
    • View Profile
NPC dialogue?
« Reply #4 on: October 27, 2007, 07:29:00 am »
Ok, that will work too.
Omnimaga Admin

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
NPC dialogue?
« Reply #5 on: October 27, 2007, 09:24:00 am »
I'm not familar with instring, what does it do and what arguments does it take on?
Here is what I was considering though, store all the game's text in one big string and use variables to determine start point of an npcs dialogue and then length. ie;
Where; A= text start point, B=length-1. P and Q are Y and X text coordinates respectivley.
code:
QUOTE

For I,A,B+A
Text(P,Q,sub(Str1,I,1
Q+4->Q
If sub(Str1,I,1=" "
Q-3->Q
If Q>=90
Then P+6->P
21->Q
End
End
Return

What I need Is somwhere withing the program structure to change the values of A and B depending on what NPC you are talking with, and i don't want to use for example;
Pseudcode;
QuoteBegin
-->
QUOTE

If NPC=1
1->A
2->B
If NPC=2
21->A
3->B
If NPC=3
52->A
25->B
ect...

That is what I am having trouble figuring out.  :(sad.gif

Offline Halifax

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1334
  • Rating: +2/-1
    • View Profile
    • TI-Freakware
NPC dialogue?
« Reply #6 on: October 27, 2007, 09:37:00 am »
Don't you have a TI Handbook handy to look up inString()?

It is hard for me to explain.
There are 10 types of people in this world-- those that can read binary, and those that can't.

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
NPC dialogue?
« Reply #7 on: October 27, 2007, 09:40:00 am »
No :(sad.gif old one got lost a long time ago :(sad.gif
Edit: found it in my ti-89's book.
inString(source string,Substring,startpoint)
It basically searches for a substring within a string starting at a specifed point (If included).

Offline tifreak

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2708
  • Rating: +82/-3
  • My Kung Fu IS strong...
    • View Profile
    • TI-Freakware
NPC dialogue?
« Reply #8 on: October 27, 2007, 01:38:00 pm »
get on irc. http://tifreakware.net/irc

There, you can find help. :Ptongue.gif
Projects: AOD Series: 75% | FFME: 80% | Pokemon: 18% | RPGSK: 60% | Star Trek: 70% | Star Trek 83+: 40% | TI-City: 5%

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
NPC dialogue?
« Reply #9 on: October 27, 2007, 01:56:00 pm »
usually in my RPGs I make events have an ID, which is the same than your char position. So for example if my char is at 99,57, in the event subprogram if there is a if condition that is like If N=9957 it will execute an event. I do this instead of making a huge NPC dialogue only database because I usually make talking to NPCs do more than displaying text sometimes, like for example if I want the NPC to walk to the next building and enter it I have code to animate him or stuff like this.

If your NPC interaction is only gonna be talking, nothing else, no special events like a boss fight, then i suggest storing your text like Halifax

Liazon

  • Guest
NPC dialogue?
« Reply #10 on: October 28, 2007, 06:57:00 am »
i wonder how Ranman organizes dialogue in UV since he said that there can be long conversations.

Offline simplethinker

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 695
  • Rating: +16/-5
  • snjwffl
    • View Profile
NPC dialogue?
« Reply #11 on: October 28, 2007, 12:08:00 pm »
You could also store the strings into a few sub programs and then do a couple If statements to decide which sub to open.  Then you could just run the sub and return the string in Ans and extract what you wanted (so you don't have some massive string that takes forever to search).

I don't know if you use Asm libs or not, but you could also store the text in an archived program and have Celtic extract the line it's stored in.  This is the least memory-intensive way to do it and would also be fairly fast, since if you numbered them like DJ Omnimaga does you would just read the Nth line.
"We've all heard that a million monkeys banging on a million typewriters will eventually reproduce the entire works of Shakespeare. Now, thanks to the Internet, we know this is not true." -- Professor Robert Silensky



Chip's Challenge: ħ%

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
NPC dialogue?
« Reply #12 on: October 28, 2007, 12:09:00 pm »
QUOTE
If your NPC interaction is only gonna be talking, nothing else, no special events like a boss fight, then i suggest storing your text like Halifax

No, it will be more interactive as you were saying. That's more along the lines of how I'll implement it.
QuoteBegin
-->
QUOTE
i wonder how Ranman organizes dialogue in UV since he said that there can be long conversations.

Yea, I'd really like to know. That would be really useful :Ptongue.gif

Offline tifreak

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2708
  • Rating: +82/-3
  • My Kung Fu IS strong...
    • View Profile
    • TI-Freakware
NPC dialogue?
« Reply #13 on: October 28, 2007, 01:26:00 pm »
Well, my npc dialogues are stored in programs. I use If statements to figure out where the character is at, and which NPC he is talkin to, then store the data to a string, using / to designate a new line, + to pause for key, then clear and continue displaying, and +* to pause, then exit. :)smile.gif Works wonderfully. If you don't believe me, look at the pokemon screenshots. :Ptongue.gif
Projects: AOD Series: 75% | FFME: 80% | Pokemon: 18% | RPGSK: 60% | Star Trek: 70% | Star Trek 83+: 40% | TI-City: 5%

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
NPC dialogue?
« Reply #14 on: October 28, 2007, 01:53:00 pm »
Couldnt you just check the character's current positon on the map to tell where he is at without using ifs? Or  am I misunderstanding you? Also, some source code for me to look at would be nice  ;)wink.gif .