From 65452ced085485962753e9a6589f8736732dbed8 Mon Sep 17 00:00:00 2001 From: Luna Date: Mon, 28 May 2018 22:08:10 -0400 Subject: [PATCH] Improve build_charge for neg values; use that --- scripts/heroes/0.gd | 2 +- scripts/heroes/4.gd | 2 +- scripts/heroes/5.gd | 2 +- scripts/player.gd | 8 ++++++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/scripts/heroes/0.gd b/scripts/heroes/0.gd index 8818133..862e3b2 100644 --- a/scripts/heroes/0.gd +++ b/scripts/heroes/0.gd @@ -27,7 +27,7 @@ func control_player(state): if get_node("MasterOnly/Boost").is_pressed() and switch_charge > cost: walk_speed *= 2 air_accel *= 3 - switch_charge -= cost + build_charge(-cost) .control_player(state) wallride(state) walk_speed = original_speed diff --git a/scripts/heroes/4.gd b/scripts/heroes/4.gd index b76049c..15221bc 100644 --- a/scripts/heroes/4.gd +++ b/scripts/heroes/4.gd @@ -36,7 +36,7 @@ func _process(delta): destroy_ability.disabled = false if Input.is_action_just_pressed("primary_ability"): if switch_charge > looking_at.destroy_cost: - switch_charge -= looking_at.destroy_cost + build_charge(-looking_at.destroy_cost) looking_at.rpc("destroy") else: destroy_ability.disabled = true diff --git a/scripts/heroes/5.gd b/scripts/heroes/5.gd index 565cc37..875beb4 100644 --- a/scripts/heroes/5.gd +++ b/scripts/heroes/5.gd @@ -31,7 +31,7 @@ func _process(delta): get_node("MasterOnly/Crosshair").set_text(crosshair) var can_build = switch_charge > portal_ability.cost if placement.place_input(radius, can_build, true) and is_second: - switch_charge -= portal_ability.cost + build_charge(-portal_ability.cost) teleport_ability.disabled = placement.placed.size() <= 1 diff --git a/scripts/player.gd b/scripts/player.gd index e5995aa..e78dc4c 100644 --- a/scripts/player.gd +++ b/scripts/player.gd @@ -98,8 +98,6 @@ func _process(delta): switch_charge = switch_charge_cap switch_bar.value = switch_charge switch_bar_extra.value = switch_charge - 100 - # ... And it's network value - rset_unreliable("switch_charge", switch_charge) # AI recording if "record" in player_info: @@ -133,7 +131,13 @@ func build_charge(amount): if obj.right_active != player_info.is_right_team and obj.active: # Point against us (right active and left, or vice versa) amount *= uncapped_advantage + else: + # Only build down to 0 + amount = max(amount, -switch_charge) switch_charge += amount + if is_network_master(): + rset_unreliable("switch_charge", switch_charge) + return amount sync func spawn(): emit_signal("spawn")