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.

73 lines
2.3 KiB

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