forked from ScruffyFurn/HTML5RPG2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnpc.js
More file actions
127 lines (117 loc) · 5.05 KB
/
Copy pathnpc.js
File metadata and controls
127 lines (117 loc) · 5.05 KB
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
//NPC Object File
/*
Copyright (c) 2014, Mickey "@ScruffyFurn" MacDonald,
Will "@WStieh" Stieh
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//This code is stored here, but because of how JavaScript operates and the way each object is created any file can reference them
//Basic NPC
//His only property is 'say' function which prints out the passed in message
var npc = {
say: function (game,message) {
game.getPlayer().getStatusLabel().height = 12;
game.getPlayer().getStatusLabel().text = message;
}
};
//Enemy NPC
//He is your most common foe
var brawler = {
name: "Brawler", //Needs a name doesnt he?
maxHp: 5, //Maximum health he can have
hp: 5, //His current health
sprite: 15, //His sprite within the sprite sheet, referenced within the battle.js file
attack: 3, //His attack value refer to battle.js's enemyAttack to see how it is implemented
exp: 3, //Experience reward when he dies
gp: 5, //Gold reward when he dies
action: function (game) {
//His action sets up combat
//First he tells the player that he is their current enemy
//Next, he uses the passed in game object to grab the battle scene and push it to the screen
//After that the battle scene takes over, refer to battle.js
game.getPlayer().object.currentEnemy = this;
game.pushScene(game.getBattle().getScene());
}
};
//Giant Rat NPC , he is your foe within the Rat Quest
var giantRat = {
name: "Giant Rat",//Needs a name doesnt he?
maxHp: 8,//Maximum health he can have
hp: 8,//His current health
sprite: 17,//His sprite within the sprite sheet, referenced within the battle.js file
attack: 3,//His attack value refer to battle.js's enemyAttack to see how it is implemented
exp: 8,//Experience reward when he dies
gp: 15,//Gold reward when he dies
action: function (game) {
//His action sets up combat
//First he tells the player that he is their current enemy
//Next, he uses the passed in game object to grab the battle scene and push it to the screen
//After that the battle scene takes over, refer to battle.js
game.getPlayer().object.currentEnemy = this;
game.pushScene(game.getBattle().getScene());
}
}
//Angry owner npc, he is your foe within the Revenge Quest
var angryOwner = {
name: "Miniga Ontoya",//Needs a name doesnt he?
maxHp: 15,//Maximum health he can have
hp: 15,//His current health
sprite: 18,//His sprite within the sprite sheet, referenced within the battle.js file
attack: 3,//His attack value refer to battle.js's enemyAttack to see how it is implemented
exp: 8,//Experience reward when he dies
gp: 15,//Gold reward when he dies
action: function (game) {
//His action sets up combat
//First he tells the player that he is their current enemy
//Next, he uses the passed in game object to grab the battle scene and push it to the screen
//After that the battle scene takes over, refer to battle.js
game.getPlayer().object.currentEnemy = this;
game.pushScene(game.getBattle().getScene());
}
}
//Very basic NPC, he just says hi!
//His action calls the npc object (look above) and calls it's say function, and passes in the message "hello"
var greeter = {
action: function (game) {
npc.say(game,"hello");
}
};
//This NPC is special, he starts the passed in quest
//Within game.js you will see he is used to start the rat quest (questdata.js), but this could be changed
var ratQuestGiver = {
action: function (game,quest) {
npc.say(game, "Help!!");
quest.setQuest();
game.pushScene(quest.getQuestScene());
quest.isActive = true;
}
}
//This NPC is special, he starts the passed in quest
//Within game.js you will see he is used to start the revenge quest (questdata.js), but this could be changed
var revengeQuestGiver = {
action: function (game, quest) {
npc.say(game, "Hey You!!");
quest.setQuest();
game.pushScene(quest.getQuestScene());
quest.isActive = true;
}
}
//Meow!
//Its our friendly feline shopkeeper
//His action brings up the shop
var cat = {
action: function (game) {
game.pushScene(game.getShop().getShopScene());
}
};