summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Gay <david@davidgay.org>2021-05-28 09:52:57 -0400
committerDavid Gay <david@davidgay.org>2021-05-28 09:52:57 -0400
commit19d790dc0e6c10ffcce1fa71a59ded558d0ac0c9 (patch)
tree90a30e60c606c277a6270be0761e60b1ba759234
parent3ebe4b17cc64bd96c05d493e04dcb4ffa9c5c36f (diff)
Monster drops, with a bunch of relevant data
-rw-r--r--app/controllers/game_controller.rb58
-rw-r--r--data/activities.yml6
-rw-r--r--data/items.yml31
-rw-r--r--data/monsters.yml75
4 files changed, 159 insertions, 11 deletions
diff --git a/app/controllers/game_controller.rb b/app/controllers/game_controller.rb
index 886b37a..b785b25 100644
--- a/app/controllers/game_controller.rb
+++ b/app/controllers/game_controller.rb
@@ -65,7 +65,7 @@ class GameController < ApplicationController
end
if table_roll >= score
- give_item_with_xp(table_entry, quantity)
+ give_item(table_entry, quantity, with_xp: true)
table_entry[:titles]&.each do |title_data|
title = Title.find_by_gid(title_data[:gid])
@@ -77,8 +77,10 @@ class GameController < ApplicationController
end
end
else
- quantity = result[:quantity] || 1
- give_item_with_xp(result, quantity)
+ min_quantity = result[:min_quantity] || result[:quantity] || 1
+ max_quantity = result[:max_quantity] || result[:quantity] || 1
+ quantity = rand(min_quantity..max_quantity)
+ give_item(result, quantity, with_xp: true)
end
when "hearth_amenity"
bhi = current_char.hearth.built_hearth_amenities
@@ -132,11 +134,14 @@ class GameController < ApplicationController
end
private
- def give_item_with_xp(data, quantity)
+ def give_item(data, quantity, with_xp: false)
item = Item.find_by_gid(data[:gid])
- xp_awards = data[:xp]&.map { |xpe| { skill: Skill.find_by_gid(xpe[:gid]), amount: xpe[:value] } }
- xp_awards&.each do |award|
- current_char.add_skill_xp(award[:skill], (award[:amount] * quantity))
+ xp_awards = []
+ if with_xp
+ xp_awards = data[:xp]&.map { |xpe| { skill: Skill.find_by_gid(xpe[:gid]), amount: xpe[:value] } }
+ xp_awards&.each do |award|
+ current_char.add_skill_xp(award[:skill], (award[:amount] * quantity))
+ end
end
current_char.shift_item(item, quantity)
@results.push({ type: "item", item: item, quantity: quantity, xp: xp_awards })
@@ -190,6 +195,45 @@ class GameController < ApplicationController
amount = award_data[:base]
char.add_skill_xp(skill, amount)
@results.push({ type: "xp", skill: skill, xp: amount })
+ when "item"
+ # TODO: This is basically duplicated from earlier
+ next if rand > (award_data[:chance] || 1)
+
+ if award_data[:table]
+ table_roll = rand
+
+ award_data[:table].sort_by { |t| -t[:score] }.each do |table_entry|
+ min_quantity = table_entry[:min_quantity] || table_entry[:quantity] || 1
+ max_quantity = table_entry[:max_quantity] || table_entry[:quantity] || 1
+ quantity = rand(min_quantity..max_quantity)
+
+ score = table_entry[:score]
+ table_scaling = award_data[:table_scaling]
+ table_scaling&.each do |scale_entry|
+ case scale_entry[:type]
+ when "skill"
+ score = score**(1 + (scale_entry[:scale_value] * current_char.skill_level(scale_entry[:gid])))
+ end
+ end
+
+ if table_roll >= score
+ give_item(table_entry, quantity)
+
+ table_entry[:titles]&.each do |title_data|
+ title = Title.find_by_gid(title_data[:gid])
+ if current_char.award_title(title)
+ @results.push({ type: "title", title: title })
+ end
+ end
+ break
+ end
+ end
+ else
+ min_quantity = award_data[:min_quantity] || award_data[:quantity] || 1
+ max_quantity = award_data[:max_quantity] || award_data[:quantity] || 1
+ quantity = rand(min_quantity..max_quantity)
+ give_item(award_data, quantity)
+ end
else
raise "Invalid award type string (#{award_data[:type]})"
end
diff --git a/data/activities.yml b/data/activities.yml
index ddb6081..9b5e01b 100644
--- a/data/activities.yml
+++ b/data/activities.yml
@@ -402,9 +402,11 @@ beastslay_killing_fields:
- gid: "pit_leech"
score: 0
- gid: "stalk_beast"
- score: 0.50
+ score: 0.45
+ - gid: "grinpad"
+ score: 0.75
- gid: "lesser_trodgeathomp"
- score: 0.95
+ score: 0.98
wealdreap_twil_woods:
name: "Reap Twil Woods"
description: "Wealdreap within Twil Woods."
diff --git a/data/items.yml b/data/items.yml
index dabb603..2c00f61 100644
--- a/data/items.yml
+++ b/data/items.yml
@@ -132,3 +132,34 @@ wisp_of_the_current:
manadross_tincture:
name: "manadross tincture"
description: "A clear, blue-tinted liquid containing a swirling, silver cloud."
+waning_light:
+ name: "waning light"
+ description: "A fading, yellow light taken from the eye socket of a trodgeathomp."
+rusted_lockbox:
+ name: "rusted lockbox"
+ description: "A small, rusty, metal box with a lock on it."
+warm_diadem:
+ name: "warm diadem"
+ description: "A thin, blood-colored circlet giving off a faint warmth."
+ whatnot:
+ equip_slots:
+ - "head"
+ equip_effects:
+ - type: "stat"
+ gid: "max_hp"
+ modifier: 1
+warped_eyestalk:
+ name: "warped eyestalk"
+ description: "An anomalous stalk from a stalk beast."
+pit_leech_trophy:
+ name: "pit leech trophy"
+ description: "A trophy from a pit leech."
+stalk_beast_trophy:
+ name: "stalk beast trophy"
+ description: "A trophy from a stalk beast."
+grinpad_trophy:
+ name: "grinpad trophy"
+ description: "A trophy from a grinpad."
+lesser_trodgeathomp_trophy:
+ name: "lesser trodgeathomp trophy"
+ description: "A trophy from a lesser trodgeathomp."
diff --git a/data/monsters.yml b/data/monsters.yml
index aa7afda..7b51bbb 100644
--- a/data/monsters.yml
+++ b/data/monsters.yml
@@ -21,7 +21,16 @@ pit_leech:
awards:
- type: "xp"
skill: "beastslay"
- base: 5
+ base: 4
+ - type: "item"
+ chance: 1
+ table:
+ - gid: "vestige"
+ score: 0.90
+ max_quantity: 2
+ - type: "item"
+ chance: 0.001
+ gid: "pit_leech_trophy"
stalk_beast:
name: "stalk beast"
description: >-
@@ -46,9 +55,60 @@ stalk_beast:
- type: "xp"
skill: "beastslay"
base: 9
+ - type: "item"
+ chance: 1
+ table:
+ - gid: "vestige"
+ score: 0.75
+ max_quantity: 4
+ - gid: "warped_eyestalk"
+ score: 0.95
+ - type: "item"
+ chance: 0.001
+ gid: "stalk_beast_trophy"
+grinpad:
+ name: "grinpad"
+ description: >-
+ A smiling, bearded figure wearing a jovial red cap. Hunched forward as if burdened by some great weight of sin,
+ it creeps toward you with a scissorblade in one hand.
+ whatnot:
+ max_hp:
+ base: 15
+ speed:
+ base: 3
+ accuracy:
+ base: 3
+ power:
+ base: 2
+ evasion:
+ base: 5
+ block:
+ base: 1
+ block_value:
+ base: 1
+ awards:
+ - type: "xp"
+ skill: "beastslay"
+ base: 13
+ - type: "item"
+ chance: 1
+ table:
+ - gid: "vestige"
+ score: 0.5
+ max_quantity: 3
+ - gid: "vestige"
+ score: 0.85
+ max_quantity: 10
+ - gid: "rusted_lockbox"
+ score: 0.995
+ - gid: "warm_diadem"
+ score: 0.9985
+ - type: "item"
+ chance: 0.001
+ gid: "grinpad_trophy"
lesser_trodgeathomp:
name: "lesser trodgeathomp"
- description: >-
+ description: >
Its body is almost entirely composed of four legs, thick as tree trunks. They meet at the top, where a faint yellow
dot of light shines dimly from a wide, horizontal slit. The dot of light follows your movements calmly.
whatnot:
@@ -70,3 +130,14 @@ lesser_trodgeathomp:
- type: "xp"
skill: "beastslay"
base: 24
+ - type: "item"
+ chance: 1
+ table:
+ - gid: "vestige"
+ score: 0.75
+ max_quantity: 20
+ - gid: "waning_light"
+ score: 0.95
+ - type: "item"
+ chance: 0.001
+ gid: "lesser_trodgeathomp_trophy"