forked from mozilla/BrowserQuest
/
npc.js
188 lines (163 loc) · 6.5 KB
/
npc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
define(['character'], function(Character) {
var NpcTalk = {
"guard": [
"Hello there",
"We don't need to see your identification",
"You are not the player we're looking for",
"Move along, move along..."
],
"king": [
"Hi, I'm the King",
"I run this place",
"Like a boss",
"I talk to people",
"Like a boss",
"I wear a crown",
"Like a boss",
"I do nothing all day",
"Like a boss",
"Now leave me alone",
"Like a boss"
],
"villagegirl": [
"Hi there, adventurer!",
"How do you like this game?",
"It's all happening in a single web page! Isn't it crazy?",
"It's all made possible thanks to WebSockets.",
"I don't know much about it, after all I'm just a program.",
'Why don't you read this <a target="_blank" href="http://hacks.mozilla.org/2012/03/browserquest/">blog post</a> and learn all about it?'
],
"villager": [
"Howdy stranger. Do you like poetry?",
"Roses are red, violets are blue...",
"I like hunting rats, and so do you...",
"The rats are dead, now what to do?",
"To be honest, I have no clue.",
"Maybe the forest, could interest you...",
"or instead, cook a rat stew."
],
"agent": [
"Do not try to bend the sword",
"That's impossible",
"Instead, only try to realize the truth...",
"There is no sword."
],
"rick": [
"We're no strangers to love",
"You know the rules and so do I",
"A full commitment's what I'm thinking of",
"You wouldn't get this from any other guy",
"I just wanna tell you how I'm feeling",
"Gotta make you understand",
"Never gonna give you up",
"Never gonna let you down",
"Never gonna run around and desert you",
"Never gonna make you cry",
"Never gonna say goodbye",
"Never gonna tell a lie and hurt you"
],
"scientist": [
"Greetings.",
"I am the inventor of these two potions.",
"The red one will replenish your health points...",
"The orange one will turn you into a firefox and make you invincible...",
"But it only lasts for a short while.",
"So make good use of it!",
"Now if you'll excuse me, I need to get back to my experiments..."
],
"nyan": [
"nyan nyan nyan nyan nyan",
"nyan nyan nyan nyan nyan nyan nyan",
"nyan nyan nyan nyan nyan nyan",
"nyan nyan nyan nyan nyan nyan nyan nyan"
],
"beachnpc": [
"lorem ipsum dolor sit amet",
"consectetur adipisicing elit, sed do eiusmod tempor"
],
"forestnpc": [
"lorem ipsum dolor sit amet",
"consectetur adipisicing elit, sed do eiusmod tempor"
],
"desertnpc": [
"lorem ipsum dolor sit amet",
"consectetur adipisicing elit, sed do eiusmod tempor"
],
"lavanpc": [
"lorem ipsum dolor sit amet",
"consectetur adipisicing elit, sed do eiusmod tempor"
],
"priest": [
"Oh, hello, young man.",
"Wisdom is everything, so I'll share a few guidelines with you.",
"You are free to go wherever you like in this world",
"but beware of the many foes that await you.",
"You can find many weapons and armors by killing enemies.",
"The tougher the enemy, the higher the potential rewards.",
"You can also unlock achievements by exploring and hunting.",
"Click on the small cup icon to see a list of all the achievements.",
"Please stay a while and enjoy the many surprises of BrowserQuest",
"Farewell, young friend."
],
"sorcerer": [
"Ah... I had foreseen you would come to see me.",
"Well? How do you like my new staff?",
"Pretty cool, eh?",
"Where did I get it, you ask?",
"I understand. It's easy to get envious.",
"I actually crafted it myself, using my mad wizard skills.",
"But let me tell you one thing...",
"There are lots of items in this game.",
"Some more powerful than others.",
"In order to find them, exploration is key.",
"Good luck."
],
"octocat": [
"Welcome to BrowserQuest!",
"Want to see the source code?",
'Check out <a target="_blank" href="http://github.com/mozilla/BrowserQuest">the repository on GitHub</a>'
],
"coder": [
"Hi! Do you know that you can also play BrowserQuest on your tablet or mobile?",
"That's the beauty of HTML5!",
"Give it a try..."
],
"beachnpc": [
"Don't mind me, I'm just here on vacation.",
"I have to say...",
"These giant crabs are somewhat annoying.",
"Could you please get rid of them for me?"
],
"desertnpc": [
"One does not simply walk into these mountains...",
"An ancient undead lord is said to dwell here.",
"Nobody knows exactly what he looks like...",
"...for none has lived to tell the tale.",
"It's not too late to turn around and go home, kid."
],
"othernpc": [
"lorem ipsum",
"lorem ipsum"
]
};
var Npc = Character.extend({
init: function(id, kind) {
this._super(id, kind, 1);
this.itemKind = Types.getKindAsString(this.kind);
this.talkCount = NpcTalk[this.itemKind].length;
this.talkIndex = 0;
},
talk: function() {
var msg = null;
if(this.talkIndex > this.talkCount) {
this.talkIndex = 0;
}
if(this.talkIndex < this.talkCount) {
msg = NpcTalk[this.itemKind][this.talkIndex];
}
this.talkIndex += 1;
return msg;
}
});
return Npc;
});