Thursday, November 18, 2010

Improving NPC Interaction (Rm2k/2k3)



Improving NPC interaction(Rm2k/2k3)
 
By Hawkeye

      RPG's are quite dull when NPC's(Non-Playable Characters) always repeat the same things over and over again. 


     So, why not improve your Hero's interaction with them by having them give advice or get mad at you. This is a very simple thing to do using only one variable. First off; make an event that you want to be an NPC, let's say a random man down by the water. Set the event start condition to PUSH KEY and position to SAME LEVEL AS HERO and then make the graphic whatever you want. For this tutorial I'll put mine as a random man.

      Next move over to the EVENTS COMMANDS area and insert a CHANGE VARIABLE command. Pick a variable and name it whatever you want; I set mine to TALK. Make sure the Set area is set to "SET" and then make the operand "RANDOM". Make the RANDOM operand set at 1 to 3. The coding afterwards should look somewhat like this...

<>Change Variable: Var[0001:TALK] = Random(1 to 3)

      What we've done so far is: When you click on the NPC it will randomize the variable TALK to 1,2 or 3. Now, let's make him talk. So under the change variable command insert a FORK CONDITIONS command and have it set that if variable TALK is set to " 1 and EQUAL " and uncheck the add else case box. 


     Now inside this command place a message saying something like "Man: Lovely day today isn't it?" or whatever you want one of his messages to say.

      Next after the <>end case make another FORK CONDITION command and have it set that if variable TALK is set to " 2 and EQUAL " and uncheck the add else case box. Now inside this command, place another message that you might want this man to say, for instance; "Man: The water sure looks choppy this evening, don't think it's a good time for sailing..."


      Then last of all after the next <>end case make another FORK CONDITION command and have it set that if variable TALK is set to "3 and EQUAL" and uncheck the add else case box. Now inside this command place another message that you might want this man to say, for instance; "Man: Perhaps you should go visit the old witch down by the beach cove, she's always giving out good advice to weary travelers


     That's it, that's all the coding to it. You could even have him give out different quests or advice or carry on various conversations and for ever random number you have; you make another fork condition. If we had set it to random 1 to 15 you would have to make 15 fork conditions: one for every possible thing he has to say. So in the end our coding looked like this...


<>Change Variable: Var[0001:TALK] = Random(1 to 3)
<>If Var(0001:TALK) 1
<>Message: Man: Lovely day today isn't it?
<>
:EndCase
<>If Var(0001:TALK) 2
<>Message: Man: The water sure looks choppy this
: :evening, don't think it's a good time for
: :sailing...
<>
:EndCase
<>If Var(0001:TALK) 3
<>Message: Man: Perhaps you should go visit the old
: :witch down by the beach cove, she's always giving
: :out good advice to weary travelers
<>
:EndCase

.

1 comment:

  1. Good idea! Randomising things in games certainly piques interest and keeps things interesting.

    ReplyDelete