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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
|
game.title = "Bloodfields: STAGE Edition";
global
{
command: "quit"
{
exit();
}
command: "exit"
{
exit();
}
}
situation <<start>>
{
setup
{
global.enemyTypes = [
{
'name': 'snail',
'action': 'oozes on',
'hp': 3,
'attack': 2
},
{
'name': 'wolf',
'action': 'bites',
'hp': 7,
'attack': 3
},
{
'name': 'snake',
'action': 'strikes at',
'hp': 3,
'attack': 3
}
];
global.enemyMods = [
{
'name': 'pathetic',
'hp': 0,
'attack': 0
},
{
'name': 'sickly',
'hp': 3,
'attack': 1
},
{
'name': 'wimpy',
'hp': 5,
'attack': 2
}
];
player.hpMax = 10;
player.hpCur = player.hpMax;
player.xp = 0;
player.level = 1;
player.attack = 3;
player.potions = 1;
global.bJustTravelled = false;
display('Welcome to Bloodfields: STAGE Edition!');
display('Type "help" for help and more information at any time.');
goto( <<field>> );
}
}
function status()
{
display('You have ' + (100-player.xp) + ' xp until your next level.');
display('You have ' + player.hpCur + ' of ' + player.hpMax + ' hp.');
display('You are carrying ' + player.potions + ' potions.');
}
function look()
{
display('''You are standing in a field of wheat.''');
if exists(global.enemy) then
{
display('You see a ' + global.enemy['name'] + ' in front of you.');
}
else if exists( global.treasure ) then
{
display('You find a ' + global.treasure['name'] + ' lying here!');
}
}
function mkEnemy()
{
eid = random( 0, count(global.enemyTypes) - 1 );
global.enemy = global.enemyTypes[eid];
mod = player.level;
if mod > count(global.enemyMods) - 1 then
{
mod = count(global.enemyMods);
}
mod -= 1;
global.enemy['name'] = global.enemyMods[mod]['name'] + ' ' +
global.enemy['name'];
global.enemy['attack'] += global.enemyMods[mod]['attack'];
global.enemy['hp'] += global.enemyMods[mod]['hp'];
global.enemy['level'] = mod;
}
function mkTreasure()
{
global.treasure = {
'name': 'potion'
};
}
function rollAttack( attack )
{
return( random( attack-attack/3, attack+attack/3 ) );
}
function playerAttack()
{
damage = rollAttack( player.attack );
global.enemy['hp'] = global.enemy['hp'] - damage;
display('You strike the ' + global.enemy['name'] + ' for ' + damage +
' damage.');
if global.enemy['hp'] <= 0 then
{
xp = 10;
display('You killed the ' + global.enemy['name'] + '! You gained ' +
xp + ' experience points.');
player.xp += xp;
while player.xp >= 100 do
{
player.xp -= 100;
player.level += 1;
player.attack += 1;
player.hpMax += integer(random(0.25,0.75)*player.hpMax);
player.hpCur = player.hpMax;
display("You have leveled! Welcome to level " + player.level );
}
select = random(1, 3);
if select == 1 then
{
display('It looks like the ' + global.enemy['name'] +
' dropped something...');
mkTreasure();
}
delete( global.enemy );
}
}
function enemyAttack()
{
damage = rollAttack( global.enemy['attack'] );
player.hpCur -= damage;
display("The " + global.enemy['name'] + ' ' + global.enemy['action'] +
' you for ' + damage + ' damage.');
if player.hpCur <= 0 then
{
display('The ' + global.enemy['name'] + ' killed you!');
exit();
}
else
{
display('''You have ''' + player.hpCur + ''' hp left.''');
}
}
situation <<travel>>
{
enter
{
delete( global.enemy );
delete( global.treasure );
display('You wander aimlessly through the endless field of wheat.');
select = random(1,6);
if select <= 4 then // 66% of the time, enemy!
{
mkEnemy();
display('''There's a ''' + global.enemy['name'] + ''' here!''');
}
else if select == 6 then // 16% of the time, treasure!
{
mkTreasure();
display('''You find a ''' + global.treasure['name'] +
''' lying here!''');
}
global.bJustTravelled = true;
goto( <<field>> );
}
}
situation <<field>>
{
command: "attack"
{
if exists(global.enemy) then
{
playerAttack();
goto( <<field>> );
}
else
{
display('''There's nothing here to attack...''');
}
}
command: "take"
{
if exists(global.treasure) then
{
if global.treasure['name'] == 'potion' then
{
display('''You pickup the ''' + global.treasure['name'] +
''' and put it in your pocket.''');
player.potions += 1;
delete( global.treasure );
}
}
else
{
display('''There's nothing here to take...''');
}
}
command: 'drink'
{
if player.potions == 0 then
{
display('''You don't have anything to drink!''');
}
else
{
if player.hpCur == player.hpMax then
{
display('''You're already as healthy as can be!
Save the potions for when you're more injured.''');
}
else
{
player.potions -= 1;
gain = integer( random( 0.25, 0.5 ) * player.hpMax );
player.hpCur += gain;
if player.hpCur > player.hpMax then
{
gain -= player.hpCur - player.hpMax;
player.hpCur = player.hpMax;
}
display('''That really hit the spot! The potion restored ''' +
gain + ''' hp!''');
goto( <<field>> );
}
}
}
command: "look"
{
look();
}
command: "status"
{
status();
}
command: "walk"
{
if not exists(global.enemy) then
{
goto( <<travel>> );
}
else
{
display("You can't leave, the " + global.enemy['name'] +
' is blocking your path.');
}
}
command: "help"
{
display("Available commands are: walk, status, look, attack, take,
drink");
}
setup
{
look();
}
enter
{
if not global.bJustTravelled then
{
if exists( global.enemy ) then
{
enemyAttack();
}
}
global.bJustTravelled = false;
}
}
|