Friday 29 July 2011

Dialogue tweaks & NPC's


Almost every game has npc's, and this one has them as well!
Though they may not be as "smart" as other npc's in other games, they sure have their use.

More after the break!




I've also tweaked the dialogue system a little bit so that you can attach dialogues to a certain npc.
Npc's can also have a "restricted" pony. That means that the npc will only talk to the "restricted" pony.

In addition to that, you can also use "[heroname]" in your dialogue to make the npc say the name of the current pony.

Once I've finished the npc's I'll release a new public beta version.

Some code

Again, if you're not interested in how the game is made, this can be a boring part.

//Create dialogue variable
var spitfireDialogue:Dialogue = new Dialogue("","",0x000000,0x000000,"",null);
var notdashDialogue:Dialogue = new Dialogue("","",0x000000,0x000000,"",null);

//Setup Dialogues
spitfireDialogue.addDialoguePony(new Spitfire, "Heya Dash.\nIt's been a while since we last met.", "spitfire00.png");
spitfireDialogue.addDialoguePony(new RainbowDash, "OHMYGOSHOHMYGOSHOHMYGOSHOHMYGOSHOHMYGOSH! It's Spitfire!", "rainbowdash00.png");
spitfireDialogue.addDialoguePony(new Spitfire, "I hope you still know how to fly because we're organising tryouts next summer and I want you to be ready for it.", "spitfire00.png");

notdashDialogue.addDialoguePony(new Spitfire, "I'm sorry [heroname], but I have to talk to Rainbow Dash", "spitfire00.png");

//Add dialogues to the NPC;
spitfire.attachDialogue(spitfireDialogue);
spitfire.attachRestriction(RainbowDash, notdashDialogue);
A few things have changed. Note that I've created a dialogue for the ponies that the npc doesn't want to talk to.
notdashDialogue.addDialoguePony(new Spitfire, "I'm sorry [heroname], but I have to talk to Rainbow Dash", "spitfire00.png");
The [heroname] will be interpreted and will output the name of your currently selected pony.



The second thing that's changed (well, added actually) is the ability to attach dialogue to an npc.
spitfire.attachDialogue(spitfireDialogue);
This will add a normal dialogue to the npc without a "restricted" pony. When clicked on the npc the dialogue will show.

However, if you wish to restrict the dialogue to a certain pony, you can use the second function:
spitfire.attachRestriction(RainbowDash, notdashDialogue);
This function requires 2 variables.
- The first is the Class of the Pony you wish to restrict the dialogue to. (in this case it's Rainbowdash)
- And the second variable is the dialogue you wish to show when it's not Rainbow Dash talking to the npc.

I hope I'll be able to release the new public beta soon!

Your brony
Michiel De Mey

3 comments:

  1. I'm liking the direction you took for the NPCs. Can't wait for a new beta!

    ReplyDelete
  2. Small update: NPC movement is now working.
    (raw version)

    ReplyDelete
  3. Another small update: Collision Filtering now works, so you shouldn't be able to collide with the NPC.

    ReplyDelete