Added delivery quest (very crappy realisation)

This commit is contained in:
gotfishmakesticks 2023-11-21 12:59:19 +03:00
commit c6bf51f1b0
9 changed files with 71 additions and 13 deletions

View file

@ -11,9 +11,10 @@ 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 available_quests : Array[Quest.TYPE]= [Quest.TYPE.ELIMINATION, Quest.TYPE.DELIVERY]
const restrictions_foreach_type : Dictionary = {
Quest.TYPE.ELIMINATION : [Quest.RESTRICTIONS.NO_DEATHS, Quest.RESTRICTIONS.TIMER]
Quest.TYPE.ELIMINATION : [Quest.RESTRICTIONS.NO_DEATHS, Quest.RESTRICTIONS.TIMER],
Quest.TYPE.DELIVERY : [Quest.RESTRICTIONS.NO_DEATHS, Quest.RESTRICTIONS.NO_WEAPON, Quest.RESTRICTIONS.TIMER]
}
func _ready():
@ -44,6 +45,9 @@ func _ready():
want_to_buy.append(Game.get_item("Water Barrel"))
want_to_buy.append(Game.get_item("Energy Cell"))
want_to_buy.append(Game.get_item("Raw Materials"))
get_tree().current_scene.scene_ready.connect(post_ready)
func post_ready():
update_prices()
generate_quest()
@ -80,11 +84,17 @@ func generate_quest():
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)
if restrictions.has(Quest.RESTRICTIONS.TIMER):
data['timer'] = int(difficulty * 30)
Quest.TYPE.DELIVERY:
var bases : Array[Node] = get_tree().current_scene.bases.get_children()
bases.erase(self)
data['destination'] = bases.pick_random()
reward_money = 50
if restrictions.has(Quest.RESTRICTIONS.TIMER):
data['timer'] = int(difficulty * 30)
var reward_multiplier = 1
for rest in restrictions:
reward_multiplier += 0.5
reward_money *= reward_multiplier
quest.create(quest_type, progress_max, reward_money, restrictions, data)

View file

@ -46,6 +46,8 @@ func destroy():
func add_quest(quest : Quest):
if quest.restrictions.has(Quest.RESTRICTIONS.TIMER):
get_tree().create_timer(quest.data['timer']).timeout.connect(timer_failed)
if quest.type == Quest.TYPE.DELIVERY:
minimap.add_marker(quest.data['destination'], "quest")
func kill_quest(success : bool):
if success:

View file

@ -8,13 +8,17 @@ var type = "hostile"
var tmi = {
"hostile": 0,
"base": 1,
"loot": 2
"loot": 2,
"quest": 3
}
func _ready():
marker.frame = tmi[type]
func _process(_delta):
if !is_instance_valid(target):
queue_free()
return
rotation = ship.global_position.angle_to_point(target.global_position)
var sp_scale = 1024 / clamp(ship.global_position.distance_to(target.global_position), 512, 2048)
marker.scale = Vector2(sp_scale, sp_scale)