Page 1 of 1

Reproduce trigger_push

Posted: Tue Apr 03, 2018 4:47 pm
by decompile
Hey,

I'm currently trying to find out, how I can reproduce the trigger_push entity.

My idea is, to create a clean trigger and make it useable for all in one, like teleport, gravity, push, etc, but I'm stuck on the push part.

The first approach I did was, that I simply set the base velocity to the boost vector on start touch. (push dir with speed/length) But i have to adjust it on top of the normal player base velocity.

But the trigger_push behaves like, it constantly pushes you until you leave the trigger.

If i would do that every tick, i would most likely leave the zone with like 100.000 u/s, lol.

Do you guys have any idea? It works for the very first tick, but after I have to somehow filter the real-player-base-velocity next to boosted vector. (So the player can also strafe and is not limited) I tried to look it up on valve's source but I couldnt find anything how they add that speed.

Re: Reproduce trigger_push

Posted: Tue Apr 03, 2018 6:52 pm
by Ayuto

Re: Reproduce trigger_push

Posted: Tue Apr 03, 2018 11:35 pm
by decompile
Hey,

Thanks.

I tried to convert it somehow to source.python, and this is my work so far:

Syntax: Select all

from listeners import OnPlayerRunCommand
from entities.constants import EntityStates
from entities.constants import MoveType
from players.constants import PlayerStates

from mathlib import Vector

@OnPlayerRunCommand
def on_player_run_command(player, user_cmd):
# Push Angle = 0 180 0
# Push Speed = 1500

# Get Push Vector
push_vector = Vector(0, 180, 0)
push_vector.length = 1500

# Get Origin
origin = player.origin

# Get Base Velocity Flag
on_ground_flag = player.flags & PlayerStates.ONGROUND
base_velocity_flag = player.flags & EntityStates.BASEVELOCITY

if base_velocity_flag:
# Apply Base Velocity
push_vector += player.base_velocity

if push_vector.z > 0 and on_ground_flag:
# Set Move Type
player.move_type = MoveType.NONE

# Adjust Origin
origin.z += 1

# Set Base Velocity
player.base_velocity = push_vector

# Add Flag (NOT SURE?)
player.flags &= EntityStates.BASEVELOCITY


I sadly cant test it, and wish someone could and tell me, if it works and what I've forgot.

Thanks