Reproduce trigger_push

Please post any questions about developing your plugin here. Please use the search function before posting!
decompile
Senior Member
Posts: 416
Joined: Sat Oct 10, 2015 10:37 am
Location: Germany
Contact:

Reproduce trigger_push

Postby decompile » Tue Apr 03, 2018 4:47 pm

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.
User avatar
Ayuto
Project Leader
Posts: 2195
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: Reproduce trigger_push

Postby Ayuto » Tue Apr 03, 2018 6:52 pm

decompile
Senior Member
Posts: 416
Joined: Sat Oct 10, 2015 10:37 am
Location: Germany
Contact:

Re: Reproduce trigger_push

Postby decompile » Tue Apr 03, 2018 11:35 pm

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

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 20 guests