A team game with an emphasis on movement (with no shooting), inspired by Overwatch and Zineth
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.5 KiB

  1. # Stuns people at a distance, removing their linear velocity
  2. extends "res://scripts/player.gd"
  3. onready var destroy_ability = get_node("MasterOnly/Destroy")
  4. var stun_charge = 1
  5. var velocity_charge = 10 # This one is instantaneous, so it gets quita weight
  6. var zoom_factor = 3
  7. var sens_factor = 10
  8. # --- Godot overrides ---
  9. func _ready():
  10. colored_meshes.append("Yaw/Pitch/Beam")
  11. func _process(delta):
  12. if is_network_master():
  13. var stun = Input.is_action_pressed("hero_4_stun")
  14. var is_stunning = false
  15. if Input.is_action_just_pressed("hero_4_zoom"):
  16. get_node("TPCamera").cam_fov /= zoom_factor
  17. get_node("TPCamera").cam_view_sensitivity /= sens_factor
  18. get_node("TPCamera").cam_smooth_movement = false
  19. if Input.is_action_just_released("hero_4_zoom"):
  20. get_node("TPCamera").cam_fov *= zoom_factor
  21. get_node("TPCamera").cam_view_sensitivity *= sens_factor
  22. get_node("TPCamera").cam_smooth_movement = true
  23. var looking_at = pick()
  24. if looking_at and looking_at.has_method("destroy"):
  25. destroy_ability.cost = looking_at.destroy_cost
  26. destroy_ability.disabled = false
  27. if Input.is_action_just_pressed("primary_ability"):
  28. if switch_charge > looking_at.destroy_cost:
  29. build_charge(-looking_at.destroy_cost)
  30. looking_at.rpc("destroy")
  31. else:
  32. destroy_ability.disabled = true
  33. if stun:
  34. var players = get_node("/root/Level/Players").get_children()
  35. var player = pick_from(players)
  36. if player != -1:
  37. # We get charge for just stunning, plus charge for how much linear velocity we cut out
  38. build_charge(stun_charge * delta)
  39. build_charge(velocity_charge * players[player].linear_velocity.length() * delta)
  40. rpc("stun", players[player].get_name(), get_node("TPCamera/Camera/Ray").get_collision_point())
  41. is_stunning = true
  42. if not is_stunning:
  43. rpc("unstun")
  44. # --- Player overrides ---
  45. # --- Own ---
  46. sync func stun(net_id, position):
  47. # Stun the thing!
  48. var player = util.get_player(net_id)
  49. player.set_linear_velocity(Vector3())
  50. # Show the beam!
  51. var beam = get_node("Yaw/Pitch/Beam")
  52. get_node("Yaw/Pitch").look_at(position, Vector3(0,1,0))
  53. beam.show()
  54. var us = get_node("TPCamera/Camera").get_global_transform().origin
  55. var distance = position - us
  56. beam.scale = Vector3(1,distance.length(),1)
  57. # We move the beam up by half the scale because the position is based on the center, not the bottom
  58. beam.translation.z = -distance.length() / 2 # We face -z direction
  59. sync func unstun():
  60. var beam = get_node("Yaw/Pitch/Beam")
  61. beam.hide()