amar-rpg 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +675 -0
  3. data/README.md +155 -0
  4. data/amar-tui.rb +8195 -0
  5. data/cli_enc_output.rb +87 -0
  6. data/cli_enc_output_new.rb +433 -0
  7. data/cli_enc_output_new_3tier.rb +198 -0
  8. data/cli_enc_output_new_compact.rb +238 -0
  9. data/cli_name_gen.rb +21 -0
  10. data/cli_npc_output.rb +279 -0
  11. data/cli_npc_output_new.rb +700 -0
  12. data/cli_town_output.rb +39 -0
  13. data/cli_weather_output.rb +36 -0
  14. data/includes/class_enc.rb +341 -0
  15. data/includes/class_enc_new.rb +512 -0
  16. data/includes/class_monster_new.rb +551 -0
  17. data/includes/class_npc.rb +1378 -0
  18. data/includes/class_npc_new.rb +1187 -0
  19. data/includes/class_npc_new.rb.backup +706 -0
  20. data/includes/class_npc_new_skills.rb +153 -0
  21. data/includes/class_town.rb +237 -0
  22. data/includes/d6s.rb +40 -0
  23. data/includes/equipment_tables.rb +120 -0
  24. data/includes/functions.rb +67 -0
  25. data/includes/includes.rb +30 -0
  26. data/includes/randomizer.rb +15 -0
  27. data/includes/spell_catalog.rb +441 -0
  28. data/includes/tables/armour.rb +13 -0
  29. data/includes/tables/chartype.rb +4412 -0
  30. data/includes/tables/chartype_new.rb +765 -0
  31. data/includes/tables/chartype_new_full.rb +2713 -0
  32. data/includes/tables/enc_specific.rb +168 -0
  33. data/includes/tables/enc_type.rb +17 -0
  34. data/includes/tables/encounters.rb +99 -0
  35. data/includes/tables/magick.rb +169 -0
  36. data/includes/tables/melee.rb +36 -0
  37. data/includes/tables/missile.rb +17 -0
  38. data/includes/tables/monster_stats_new.rb +264 -0
  39. data/includes/tables/month.rb +18 -0
  40. data/includes/tables/names.rb +21 -0
  41. data/includes/tables/personality.rb +12 -0
  42. data/includes/tables/race_templates.rb +318 -0
  43. data/includes/tables/religions.rb +266 -0
  44. data/includes/tables/spells_new.rb +496 -0
  45. data/includes/tables/tier_system.rb +104 -0
  46. data/includes/tables/town.rb +71 -0
  47. data/includes/tables/weather.rb +41 -0
  48. data/includes/town_relations.rb +127 -0
  49. data/includes/weather.rb +108 -0
  50. data/includes/weather2latex.rb +114 -0
  51. data/lib/rcurses.rb +33 -0
  52. metadata +157 -0
@@ -0,0 +1,39 @@
1
+ # The CLI town output module for Amar Tools
2
+
3
+ def town_output(aTOWN, cli)
4
+
5
+ @town = aTOWN.town
6
+
7
+ # Start creating the output text
8
+ @tn= ""
9
+ f = ""
10
+ # Remove the hash lines and URL note for cleaner output
11
+
12
+ case aTOWN.town_size
13
+ when 1..4
14
+ @tn += "Castle"
15
+ when 5..25
16
+ @tn += "Village"
17
+ when 26..99
18
+ @tn += "Town"
19
+ else
20
+ @tn += "City"
21
+ end
22
+ @tn += " Of #{aTOWN.town_name}"
23
+ town_name = @tn.delete(' ')
24
+ @tn += " - Houses: #{aTOWN.town_size} - Residents: #{aTOWN.town_residents}\n\n"
25
+ f += @tn
26
+
27
+ @town.length.times do |house|
28
+ f += "##{house}: #{@town[house][0]}\n"
29
+ @town[house][1..-1].each do |r|
30
+ f += " #{r}\n"
31
+ end
32
+ f += "\n"
33
+ end
34
+
35
+ # from functions.rb - save to temp file and named file
36
+ save_temp_file(f, "town", cli)
37
+ save_named_file(f, town_name, cli)
38
+
39
+ end
@@ -0,0 +1,36 @@
1
+ # The CLI weather output module for Amar Tools
2
+
3
+ def weather_output(aWEATHER)
4
+
5
+ w = aWEATHER
6
+
7
+ # Start creating output text
8
+ f = "################################<By Amar Tools>################################\n\n"
9
+
10
+ f += "Month: #{$Month[w.month_n]}\n"
11
+
12
+ f += "-------------------------------------------------------------------------------\n"
13
+ w.day.each_with_index do |d,i|
14
+ g = "#{(i+1).to_s.rjust(2)}: #{$Weather[d.weather]}. #{$Wind_str[d.wind_str]}"
15
+ g += " (#{$Wind_dir[d.wind_dir]})" unless d.wind_str == 0
16
+ l1 = g.length
17
+ g += "[#{d.special}]".rjust(60-l1) unless d.special == ""
18
+ l2 = g.length
19
+ f += g
20
+ if w.month_n != 0
21
+ f += "[New moon]".rjust(79-l2) if i == 0
22
+ f += "[½ moon, vaxing]".rjust(79-l2) if i == 7
23
+ f += "[Full moon]".rjust(79-l2) if i == 14
24
+ f += "[½ moon, waning]".rjust(79-l2) if i == 21
25
+ end
26
+ f += "\n"
27
+ f += "-------------------------------------------------------------------------------\n" if ((i+1)%7) == 0
28
+ end
29
+
30
+ f += "\n###############################################################################\n\n"
31
+
32
+ # Save weather file
33
+ save_temp_file(f, "weather", "cli")
34
+ system("#{$editor} saved/weather.npc")
35
+
36
+ end
@@ -0,0 +1,341 @@
1
+ # The Amar Tool class for generating random encounters
2
+ #
3
+ # When the class is initialized, a random encounter is generated
4
+ # using data from the imported tables (hashes and arrays)
5
+ #
6
+ # This class is pretty straight forward and shouldn't need much comments
7
+
8
+ class Enc
9
+
10
+ attr_reader :encounter, :enc_attitude, :enc_number
11
+
12
+ Inf = 1.0/0
13
+
14
+ def initialize(enc_spec, enc_number)
15
+
16
+ $Terraintype = 8 if $Terraintype == nil
17
+ $Level = 0 if $Level == nil
18
+
19
+ @enc_spec = enc_spec.to_s
20
+ @enc_number = enc_number.to_i
21
+
22
+ @enc_spec == "" ? @enc = false : @enc = true
23
+ @enc_type = ""
24
+ if @enc == false
25
+ @enc_terrain = {}
26
+ $Enc_type.each do |key,value|
27
+ @enc_terrain[key] = value[$Terraintype]
28
+ end
29
+ @enc_type = randomizer(@enc_terrain)
30
+ end
31
+
32
+ @encounter = []
33
+
34
+ if @enc_type =~ /NO ENCOUNTER/
35
+ @encounter[0] = {}
36
+ @encounter[0]["string"] = "NO ENCOUNTER"
37
+ return
38
+ end
39
+
40
+ @enc_attitude = ""
41
+ case d6
42
+ when 1
43
+ @enc_attitude = "HOSTILE"
44
+ when 2
45
+ @enc_attitude = "ANTAGONISTIC"
46
+ when 3..4
47
+ @enc_attitude = "NEUTRAL"
48
+ when 5
49
+ @enc_attitude = "POSITIVE"
50
+ when 6
51
+ @enc_attitude = "FRIENDLY"
52
+ end
53
+
54
+ if @enc == false
55
+ @enc_terrain2 = {}
56
+ $Enc_specific[@enc_type].each do |key,value|
57
+ @enc_terrain2[key] = value[$Terraintype]
58
+ end
59
+ end
60
+
61
+ if @enc_number == 0
62
+ case oD6
63
+ when -Inf..3
64
+ @enc_number = 1
65
+ when 4
66
+ @enc_number = dX (3)
67
+ when 5
68
+ @enc_number = d6
69
+ when 6..7
70
+ @enc_number = 2*d6
71
+ else
72
+ @enc_number = 3*d6
73
+ end
74
+ @enc_number = 5 if @enc_number > 5 and @enc_type =~ /onster/
75
+ end
76
+
77
+ @enc_number.times do |i|
78
+ @encounter[i] = {}
79
+ @enc == true ? @encounter[i]["string"] = @enc_spec : @encounter[i]["string"] = randomizer(@enc_terrain2)
80
+ if @encounter[i]["string"] =~ /Event:/
81
+ break
82
+ else
83
+ begin
84
+ @stats = $Encounters[@encounter[i]["string"]].dup
85
+
86
+ @encounter[i]["level"] = dX(@stats[0]) + $Level
87
+ @encounter[i]["level"] += 2 if @encounter[i]["string"] =~ /Elf/
88
+ @encounter[i]["level"] += 1 if @encounter[i]["string"] =~ /Dwarf/
89
+ @level = @encounter[i]["level"]
90
+
91
+ case rand(2).to_i
92
+ when 0
93
+ @encounter[i]["sex"] = "F"
94
+ else
95
+ @encounter[i]["sex"] = "M"
96
+ end
97
+ @encounter[i]["sex"] = "M" if @encounter[i]["string"] =~ /officer/ and rand(6) != 0
98
+ @encounter[i]["sex"] = "F" if @encounter[i]["string"] =~ /Prostitute/ and rand(10) != 0
99
+ @encounter[i]["sex"] = "F" if @encounter[i]["string"] =~ /Nanny/ and rand(10) != 0
100
+ @encounter[i]["sex"] = "F" if @encounter[i]["string"] =~ /wife/
101
+
102
+ @encounter[i]["race"] = ""
103
+ case @encounter[i]["string"]
104
+ when /Human/
105
+ @encounter[i]["race"] = "Human"
106
+ when /Dwarf/
107
+ @encounter[i]["race"] = "Dwarf"
108
+ when /Elf/, /Faerie/
109
+ @encounter[i]["race"] = "Elf"
110
+ when /Troll/
111
+ @encounter[i]["race"] = "Troll"
112
+ when /Arax/
113
+ @encounter[i]["race"] = "Arax"
114
+ when /Lizardman/
115
+ @encounter[i]["race"] = "Lizardfolk"
116
+ else
117
+ @encounter[i]["race"] = "Other"
118
+ end
119
+
120
+ @encounter[i]["name"] = naming(@encounter[i]["race"], @encounter[i]["sex"])
121
+
122
+ @encounter[i]["size"] = @stats[1] + (rand(10 * @stats[1]+1) + rand(10 * @stats[1]+1) - 10 * @stats[1])/20
123
+ @encounter[i]["size"] = 1 if @encounter[i]["size"] < 1
124
+
125
+ @encounter[i]["strength"] = ((@stats[2] * @level + 1) / 3 - 2 + aD6)
126
+ @encounter[i]["strength"] = 1 if @encounter[i]["strength"] < 1
127
+
128
+ @db = (@encounter[i]["strength"] + @encounter[i]["size"]) / 3
129
+
130
+ @wpnmax = 0
131
+ case @encounter[i]["strength"]
132
+ when 1
133
+ @wpnmax = 2
134
+ when 2
135
+ @wpnmax = 4
136
+ when 3
137
+ @wpnmax = 11
138
+ when 4
139
+ @wpnmax = 18
140
+ when 5
141
+ @wpnmax = 22
142
+ when 7..8
143
+ @wpnmax = 28
144
+ else
145
+ @wpnmax = 30
146
+ end
147
+
148
+ @mslmax = 0
149
+ case @encounter[i]["strength"]
150
+ when 1
151
+ @mslmax = 2
152
+ when 2
153
+ @mslmax = 5
154
+ when 3
155
+ @mslmax = 7
156
+ when 4..5
157
+ @mslmax = 9
158
+ when 6..7
159
+ @mslmax = 10
160
+ when 8..9
161
+ @mslmax = 11
162
+ else
163
+ @mslmax = 12
164
+ end
165
+
166
+ @encounter[i]["endurance"] = ((@stats[3] * @level + 1) / 3 - 2 + aD6)
167
+ @encounter[i]["endurance"] = 1 if @encounter[i]["endurance"] < 1
168
+
169
+ @encounter[i]["bp"] = 2 * @encounter[i]["size"] + (@encounter[i]["endurance"] / 3)
170
+
171
+ @encounter[i]["awareness"] = ((@stats[4] * @level + 1) / 3 - 2 + aD6)
172
+ @encounter[i]["awareness"] = 1 if @encounter[i]["awareness"] < 1
173
+
174
+ @encounter[i]["dodge"] = ((@stats[5] * @level + 1) / 3 - 2 + aD6)
175
+ @encounter[i]["dodge"] = 0 if @encounter[i]["dodge"] < 0
176
+
177
+ @stats[9] > 0 ? @encounter[i]["mag"] = ((@stats[9] * @level + 1) / 3 - 2 + aD6) : @encounter[i]["mag"] = 0
178
+ @encounter[i]["mag"] = 0 if @encounter[i]["mag"] < 0
179
+
180
+ @arax = 0
181
+ if @encounter[i]["race"] == "Arax"
182
+ case rand(24).to_i
183
+ when 0
184
+ @encounter[i]["size"] += d6 - 1
185
+ when 1
186
+ @encounter[i]["strength"] += oD6 + 3
187
+ @encounter[i]["strength"] = 3 if @encounter[i]["strength"] < 3
188
+ when 2
189
+ @encounter[i]["endurance"] += oD6 + 3
190
+ @encounter[i]["endurance"] = 2 if @encounter[i]["endurance"] < 2
191
+ when 3
192
+ @encounter[i]["awareness"] += oD6 + 3
193
+ @encounter[i]["awareness"] = 0 if @encounter[i]["awareness"] < 0
194
+ when 4
195
+ @encounter[i]["mag"] += oD6
196
+ @encounter[i]["mag"] = 1 if @encounter[i]["mag"] < 1
197
+ when 5
198
+ @encounter[i]["dodge"] += oD6
199
+ @encounter[i]["dodge"] = 5 if @encounter[i]["dodge"] < 5
200
+ when 6
201
+ @encounter[i]["mag_lore"] = ((@stats[10] * @level + 1) / 3 - 2 + aD6)
202
+ @encounter[i]["spells"] = 1
203
+ @encounter[i]["mag_type"] = randomizer(
204
+ "Black" => 3,
205
+ "Earth" => 3,
206
+ "Prot." => 2,
207
+ "Perc." => 2)
208
+ when 7..12
209
+ @arax = 1
210
+ end
211
+ end
212
+
213
+ if @stats[10] > 0
214
+ @encounter[i]["mag_lore"] = ((@stats[10] * @level + 1) / 3 - 2 + aD6)
215
+ @encounter[i]["mag_lore"] = 1 if @encounter[i]["mag_lore"] < 1
216
+ @encounter[i]["spells"] = ((@encounter[i]["mag_lore"] * @level + 1) / 5 - 2 + aD6)
217
+ @encounter[i]["spells"] = 0 if @encounter[i]["spells"] < 0
218
+ @encounter[i]["mag_type"] = ""
219
+ case @encounter[i]["string"]
220
+ when /black/
221
+ @encounter[i]["mag_type"] = "Black"
222
+ when /white/
223
+ @encounter[i]["mag_type"] = "White"
224
+ when /air/
225
+ @encounter[i]["mag_type"] = "Air"
226
+ when /earth/
227
+ @encounter[i]["mag_type"] = "Earth"
228
+ when /fire/
229
+ @encounter[i]["mag_type"] = "Fire"
230
+ when /water/
231
+ @encounter[i]["mag_type"] = "Water"
232
+ when /prot/
233
+ @encounter[i]["mag_type"] = "Prot."
234
+ when /Summoner/
235
+ @encounter[i]["mag_type"] = "Summ."
236
+ else
237
+ @encounter[i]["mag_type"] = randomizer(
238
+ "Black" => 3,
239
+ "White" => 8,
240
+ "Air" => 5,
241
+ "Earth" => 5,
242
+ "Fire" => 5,
243
+ "Water" => 5,
244
+ "Prot." => 5,
245
+ "Summ." => 4,
246
+ "Magic" => 3)
247
+ end
248
+ end
249
+
250
+ @wpn = $Melee[rand(@wpnmax) + 1].dup
251
+ @wpn = $Melee[1].dup if @stats[6] < 0
252
+ @encounter[i]["wpn_name"] = @wpn[0]
253
+ @encounter[i]["wpn_skill"] = ((@stats[6].abs * @level + 1) / 3 - 2 + aD6)
254
+ @encounter[i]["wpn_skill"] = 1 if @encounter[i]["wpn_skill"] < 1
255
+ # Reaction speed is calculated as weighted average between Awareness and Melee skill
256
+ if @encounter[i]["wpn_skill"] < @encounter[i]["awareness"]
257
+ @encounter[i]["reaction"] = (@encounter[i]["wpn_skill"] * 2 + @encounter[i]["awareness"]) / 3 + d6 - 3
258
+ else
259
+ @encounter[i]["reaction"] = (@encounter[i]["awareness"] * 2 + @encounter[i]["wpn_skill"]) / 3 + d6 - 3
260
+ end
261
+ @encounter[i]["reaction"] = @encounter[i]["awareness"] / 3 if @encounter[i]["reaction"] < @encounter[i]["awareness"] / 3
262
+ @encounter[i]["wpn_ini"] = @wpn[4] + @encounter[i]["reaction"]
263
+ @encounter[i]["wpn_off"] = @encounter[i]["wpn_skill"] + @wpn[5]
264
+ @encounter[i]["wpn_def"] = @encounter[i]["wpn_skill"] + @wpn[6] + @encounter[i]["dodge"] / 5
265
+ @encounter[i]["wpn_dam"] = @db + @wpn[3]
266
+
267
+ if @stats[8] < 0
268
+ @encounter[i]["ap"] = @stats[8].abs
269
+ elsif @stats[8] > 0
270
+ @encounter[i]["ap"] = rand(@stats[8])
271
+ else
272
+ @encounter[i]["ap"] = 0
273
+ end
274
+
275
+ @encumberance = 3 + @encounter[i]["ap"] * 7
276
+ if @encounter[i]["strength"] * 2 > @encumberance
277
+ @encounter[i]["status"] = 0
278
+ elsif @encounter[i]["strength"] * 5 > @encumberance
279
+ @encounter[i]["status"] = -1
280
+ elsif @encounter[i]["strength"] * 10 > @encumberance
281
+ @encounter[i]["status"] = -3
282
+ else
283
+ @encounter[i]["status"] = -5
284
+ end
285
+
286
+ if @stats[7] != 0
287
+ @msl = $Missile[rand(@mslmax) + 1].dup
288
+ @encounter[i]["msl_name"] = @msl[0]
289
+ @encounter[i]["msl_skill"] = ((@stats[7] * @level + 1) / 3 - 2 + aD6)
290
+ @encounter[i]["msl_skill"] = 1 if @encounter[i]["msl_skill"] < 1
291
+ @encounter[i]["msl_ini"] = @msl[7] + @encounter[i]["reaction"]
292
+ @encounter[i]["msl_off"] = @encounter[i]["msl_skill"] + @msl[4]
293
+ @encounter[i]["msl_dam"] = @msl[3]
294
+ @encounter[i]["msl_rng"] = @msl[5]
295
+ if @msl[1] !~ /bow/
296
+ @encounter[i]["msl_dam"] += @encounter[i]["strength"] / 5
297
+ end
298
+ end
299
+
300
+ if @arax == 1
301
+ case rand(11).to_i
302
+ when 0
303
+ @encounter[i]["ap"] += d6
304
+ when 1..3
305
+ @tmp = oD6 + 3
306
+ @encounter[i]["wpn_skill"] += @tmp
307
+ @encounter[i]["wpn_off"] += @tmp
308
+ @encounter[i]["wpn_def"] += @tmp
309
+ when 4..5
310
+ @tmp = oD6 + 3
311
+ @encounter[i]["msl_skill"] += @tmp
312
+ @encounter[i]["msl_off"] += @tmp
313
+ when 6
314
+ @encounter[i]["msl_name"] = "Poison spit"
315
+ @encounter[i]["msl_skill"] = ((@stats[7] * @level + 1) / 3 - 2 + aD6)
316
+ @encounter[i]["msl_skill"] = 1 if @encounter[i]["msl_skill"] < 1
317
+ @encounter[i]["msl_off"] = @encounter[i]["msl_skill"]
318
+ @encounter[i]["msl_dam"] = 2
319
+ @encounter[i]["msl_rng"] = 10
320
+ when 7
321
+ @encounter[i]["msl_name"] = "Poison breath"
322
+ @encounter[i]["msl_skill"] = ((@stats[7] * @level + 1) / 3 + aD6)
323
+ @encounter[i]["msl_skill"] = 1 if @encounter[i]["msl_skill"] < 1
324
+ @encounter[i]["msl_off"] = @encounter[i]["msl_skill"]
325
+ @encounter[i]["msl_dam"] = 0
326
+ @encounter[i]["msl_rng"] = 3
327
+ else
328
+ @encounter[i]["string"] += " [Chaos feature, GM's discr.]"
329
+ end
330
+ end
331
+
332
+ rescue # Result for corner cases
333
+ @encounter[0] = {}
334
+ @encounter[0]["string"] = "NO ENCOUNTER"
335
+ return
336
+ end
337
+ end
338
+ @enc_terrain2[@encounter[i]["string"]] += 20 if @encounter[i]["string"] =~ /Human/ and @enc == false
339
+ end
340
+ end
341
+ end