Quest generating + quest adding interface + some bugfixes
This commit is contained in:
parent
008e74eba3
commit
f4cf1ef4e9
7 changed files with 71 additions and 20 deletions
|
|
@ -10,7 +10,14 @@ var want_to_buy : Array[Item] = []
|
|||
var sell_prices : Array[float] = []
|
||||
var buy_prices : Array[float] = []
|
||||
|
||||
var quest : Quest = Quest.new()
|
||||
const available_quests : Array[Quest.TYPE]= [Quest.TYPE.ELIMINATION]
|
||||
const restrictions_foreach_type : Dictionary = {
|
||||
Quest.TYPE.ELIMINATION : [Quest.RESTRICTIONS.NO_DEATHS, Quest.RESTRICTIONS.TIMER]
|
||||
}
|
||||
|
||||
func _ready():
|
||||
randomize()
|
||||
ship.minimap.add_marker(self, "base")
|
||||
match type:
|
||||
Game.BASE_TYPE.POWER:
|
||||
|
|
@ -38,6 +45,7 @@ func _ready():
|
|||
want_to_buy.append(Game.get_item("Energy Cell"))
|
||||
want_to_buy.append(Game.get_item("Raw Materials"))
|
||||
update_prices()
|
||||
generate_quest()
|
||||
|
||||
func update_prices():
|
||||
sell_prices = []
|
||||
|
|
@ -55,3 +63,28 @@ func update_prices():
|
|||
else:
|
||||
price = randi_range(item.min_price * 100, (item.max_price + item.min_price) / 2 * 100) / 100.0
|
||||
buy_prices.append(price)
|
||||
|
||||
func generate_quest():
|
||||
var difficulty : float = randi_range(100, 300) / 100.0
|
||||
var reward_multi : float = randi_range(100, max(difficulty/1.5 * 100, 100)) / 100.0
|
||||
var quest_type : Quest.TYPE = available_quests.pick_random()
|
||||
var progress_max : int
|
||||
var reward_money : int
|
||||
var restrictions : Array[Quest.RESTRICTIONS] = []
|
||||
var data : Dictionary = {}
|
||||
for restriction in restrictions_foreach_type[quest_type]:
|
||||
var hit = randi_range(0, 1)
|
||||
if hit:
|
||||
restrictions.append(restriction)
|
||||
match quest_type:
|
||||
Quest.TYPE.ELIMINATION:
|
||||
progress_max = difficulty * 2
|
||||
reward_money = 50 * progress_max * reward_multi
|
||||
if restrictions.has(Quest.RESTRICTIONS.NO_DEATHS):
|
||||
reward_money *= 1.5
|
||||
if restrictions.has(Quest.RESTRICTIONS.NO_WEAPON):
|
||||
reward_money *= 1.5
|
||||
if restrictions.has(Quest.RESTRICTIONS.TIMER):
|
||||
reward_money *= 1.5
|
||||
data['timer'] = int(difficulty * 30)
|
||||
quest.create(quest_type, progress_max, reward_money, restrictions, data)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue