browserquest/BrowserQuest — pull request #26 by lzbk (2013-01-28 18:33:28+00:00)
Title: "Adaptative" NPCs and entry points…

As discussed on the mailing list, here are the generic modifications performed for my project (i.e. the ones that do not alter the content, just the global functionnalities).
Modifications performed to :
* game.js: adds parameter to npc.talk, to take into account the following modifications
* npc.js:
- selectTalk, selects the discourse depending on the state of the game
- talk, talks the talk selected
To structure the info, see the example of the scientist : Each object (except the first, default discussion) has a "condition" property (parameterless function) which decides when to use this discussion and a "text" property, which contain the array of lines of the conversation.
* entrypoint.js: An entry point is used to get into the game through encoded urls (used sha1 by caligatio http://caligatio.github.com/jsSHA) to identify them. This can be used to establish connexion with the outside world, might it be on the Web (e.g.: achievement obtained through activity on another site, section of the site) or in the real world (e.g.: QRCode found on an item). We needed that on our project, maybe you can use it as well.
It can be tested with the following variable in the url : ./client/?entrance=almostFoxy
This is supposed to change the sprite of the player to a firefox, but without granting it invulnerability. The 3 states (normal, firefox and firefox+invulnerable) are then used to direct the speech of the scientist present in the house below.
![testhouse](https://f.cloud.github.com/assets/3218235/104103/a2fd53dc-6978-11e2-84ae-40c2501e6e46.png)

To prevent entry points values from being checked out by users in the .js file, they are encoded using Brian Turek's js SHA library. I also added a page in the tool directory to be able to create the hashcode associated to the value the coder wants to put in their url.

Hope some of this can be useful…

Cheers