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.

54 lines
1.6 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 players = get_node("/root/Level/Players").get_children()
  14. var player = pick_from(players)
  15. if player != -1:
  16. # We get charge for just stunning, plus charge for how much linear velocity we cut out
  17. switch_charge += stun_charge * delta
  18. switch_charge += velocity_charge * players[player].get_linear_velocity().length() * delta
  19. rpc("stun", players[player].get_name(), get_node("TPCamera/Camera/Ray").get_collision_point())
  20. is_stunning = true
  21. if not is_stunning:
  22. rpc("unstun")
  23. # --- Player overrides ---
  24. # --- Own ---
  25. sync func stun(net_id, position):
  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. # We move the beam up by half the scale because the position is based on the center, not the bottom
  37. beam.translation.z = -distance.length() / 2 # We face -z direction
  38. sync func unstun():
  39. var beam = get_node("Yaw/Pitch/Beam")
  40. beam.hide()