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.

56 lines
1.7 KiB

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