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.

55 lines
1.5 KiB

  1. # Hero 4 stuns people at a distance, removing their linear velocity
  2. extends "res://scripts/player.gd"
  3. var stun_charge = 5
  4. # --- Godot overrides ---
  5. func _ready():
  6. colored_meshes.append("Yaw/Pitch/Beam")
  7. func _process(delta):
  8. if is_network_master():
  9. var stun = Input.is_action_pressed("hero_4_stun")
  10. var is_stunning = false
  11. if stun:
  12. var look_ray = get_node("TPCamera/Camera/Ray")
  13. var stunning = look_ray.get_collider()
  14. var players = get_node("/root/Level/Players").get_children()
  15. var player = players.find(stunning)
  16. if player != -1:
  17. switch_charge += stun_charge * delta
  18. rpc("stun", players[player].get_name(), look_ray.get_collision_point())
  19. is_stunning = true
  20. if not is_stunning:
  21. rpc("unstun")
  22. # --- Player overrides ---
  23. # --- Own ---
  24. sync func stun(net_id, position):
  25. print("stunnnn")
  26. # Stun the thing!
  27. var player = get_node("/root/Level/Players/%s" % net_id)
  28. player.set_linear_velocity(Vector3())
  29. # Show the beam!
  30. var beam = get_node("Yaw/Pitch/Beam")
  31. get_node("Yaw/Pitch").look_at(position, Vector3(0,1,0))
  32. beam.show()
  33. var us = get_node("TPCamera/Camera").get_global_transform().origin
  34. var distance = position - us
  35. beam.scale = Vector3(1,distance.length(),1)
  36. print(beam.scale)
  37. # We move the beam up by half the scale because the position is based on the center, not the bottom
  38. beam.translation.z = -distance.length() / 2 # We face -z direction
  39. sync func unstun():
  40. var beam = get_node("Yaw/Pitch/Beam")
  41. beam.hide()