Added delivery quest (very crappy realisation)
This commit is contained in:
parent
33bcd65c53
commit
c6bf51f1b0
9 changed files with 71 additions and 13 deletions
|
|
@ -15,8 +15,8 @@ var color_enemy
|
|||
@onready var ship = $MainShip
|
||||
@onready var bases = $Bases
|
||||
@onready var enemy_faction = $EnemyFaction
|
||||
|
||||
signal enemy_destroyed
|
||||
signal scene_ready
|
||||
|
||||
func _ready():
|
||||
randomize()
|
||||
|
|
@ -60,6 +60,7 @@ func _ready():
|
|||
if data['got_reward']:
|
||||
ship.quest.new = true
|
||||
ship.quest_completed = true
|
||||
scene_ready.emit()
|
||||
|
||||
func addtargetlist(body : Node2D):
|
||||
if !can_target.has(body):
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ func _on_body_entered(body):
|
|||
menu_inst.base = get_parent()
|
||||
body.find_child("GUI").add_child(menu_inst)
|
||||
body.minimap.visible = false
|
||||
if body.quest.type == Quest.TYPE.DELIVERY:
|
||||
if body.quest.data['destination'] == get_parent():
|
||||
body.quest.do_progress()
|
||||
|
||||
func _on_body_exited(body):
|
||||
if body is MainShip:
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue