Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @TypedServerCommand('wcs_teleport_new')
- def teleport_new(command_info, player:convert_userid_to_player, distance:int=0):
- if player is None:
- return
- coords = player.get_view_coordinates()
- pre_coords = player.origin
- post_coords = get_coord_with_distance(pre_coords, coords, distance)
- post_coords[2] += 10
- if not is_player_stuck(player.index, post_coords):
- player.origin = post_coords
- def is_player_stuck(player_index, origin):
- '''Return whether or not the given player is stuck in solid.'''
- # Get the player's PlayerInfo instance...
- player_info = playerinfo_from_index(player_index)
- # Get the player's origin...
- # origin = player_info.origin
- # Get a Ray object based on the player physic box...
- ray = Ray(origin, origin, player_info.mins,
- player_info.maxs)
- # Get a new GameTrace instance...
- trace = GameTrace()
- # Do the trace...
- engine_trace.trace_ray(ray, ContentMasks.PLAYER_SOLID, TraceFilterSimple(
- PlayerIter()), trace)
- # Return whether or not the trace did hit...
- return trace.did_hit()
- def get_coord_with_distance(player_coords, coords, distance):
- vector1 = Vector(*coords)
- vector2 = Vector(*player_coords)
- length = (vector2 - vector1).length
- velocity = vector1 - vector2
- velocity1 = [(velocity[x] / length) for x in (0, 1, 2)]
- if length > distance + 80:
- length = distance + 80
- velocity2 = Vector(*[velocity1[x] * (length - 80) for x in (0, 1, 2)])
- return player_coords + velocity2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement