Parachute v0.03!

Release your plugins here!
User avatar
L'In20Cible
Project Leader
Posts: 1078
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Parachute v0.03!

Postby L'In20Cible » Tue Jan 30, 2018 12:56 pm

I didn't compile a model for BM:S, but I believe it use the same version as OB. Try this:

Syntax: Select all

# ../addons/source-python/plugins/parachute/parachute.py

# ============================================================================
# >> IMPORTS
# ============================================================================
# Python Imports
# Math
from math import cos
from math import radians
from math import sin

# Source.Python Imports
# Core
from core import SOURCE_ENGINE
# Engines
from engines.precache import Model
# Entities
from entities.constants import MoveType
from entities.entity import Entity
# Listeners
from listeners import OnPlayerRunCommand
# Mathlib
from mathlib import Vector
# Paths
from paths import GAME_PATH
# Players
from players.constants import PlayerButtons
from players.constants import PlayerStates
from players.entity import Player
from players.dictionary import EntityDictionary
# Stringtables
from stringtables.downloads import Downloadables


# ============================================================================
# >> CONFIGURATION
# ============================================================================
# Define the falling speed in units/s. The higher this value is, the
# faster parachutists will fall.
falling_speed = 32

# Define the speed of the steering lines in units/s. To pull a steering line,
# parachutists must use their A or D keys to gain speed into the right or left
# direction allowing them to have a better control of their landing. However,
# pulling a line come with a falling speed cost.
#
# Set to 0 to disable the ability to pull a line.
steering_lines_speed = 5

# Define the falling speed penalty multiplier when pulling a line.
# e.g. With a falling speed of 32 and a penalty of 1.5, parachutists pulling
# their lines would fall at a speed of 48 units/s.
#
# Set to 1 to disable the falling speed penalty.
steering_lines_penalty = 1.5

# Define the key players must hold to deploy their parachute.
deployment_button = PlayerButtons.SPEED


# ============================================================================
# >> GLOBALS
# ============================================================================
if SOURCE_ENGINE == 'bms':
SOURCE_ENGINE = 'orangebox'

downloadables = Downloadables()
downloadables.add_directory(f'models/parachute/{SOURCE_ENGINE}')
downloadables.add_directory('materials/models/parachute')

parachutes = EntityDictionary()

_path = f'models/parachute/{SOURCE_ENGINE}/parachute_default.mdl'
if not (GAME_PATH / _path).isfile():
parachute_model = None
else:
parachute_model = Model(_path)


# ============================================================================
# >> FUNCTIONS
# ============================================================================
def get_player_parachute(player):
for parachute in parachutes.values():
if parachute.owner_handle != player.inthandle:
continue
return parachute


def close_parachute(player):
parachute = get_player_parachute(player)
if parachute is None:
return
parachute.remove()


def parachute_check(player):
angles = Vector(y=player.eye_angle.y)
parachute = get_player_parachute(player)
if parachute is None:
parachute = Entity.create('prop_dynamic_override')
parachutes[parachute.index] = parachute

weapon = player.active_weapon
if weapon is not None:
parachute.parent = weapon

parachute.model = parachute_model
parachute.owner_handle = player.inthandle
parachute.origin = player.origin
parachute.angles = angles
parachute.model_scale = 0.7

parachute.spawn()
return

weapon = player.active_weapon
if weapon is not None:
parent = parachute.parent
if parent != weapon:
parachute.parent = weapon

origin = player.origin
else:
parachute.parent = None
view_offset = player.view_offset.copy()
view_offset.z /= 2
origin = player.origin + view_offset

parachute.origin = origin
parachute.angles = angles

if parachute.model_scale >= 1.0:
return

parachute.model_scale += 0.024


# ============================================================================
# >> LISTENERS
# ============================================================================
@OnPlayerRunCommand
def _on_player_run_command(player, usercmd):
if player.is_bot():
return

if (player.dead or
player.move_type == MoveType.LADDER or
player.flags & PlayerStates.INWATER or
not usercmd.buttons & deployment_button):

close_parachute(player)
return

fall_velocity = player.fall_velocity
if fall_velocity < 1.0:
close_parachute(player)
return

side_move = usercmd.side_move
if side_move and steering_lines_speed > 1:
yaw = player.eye_angle.y

if side_move < 0:
yaw += 90
else:
yaw -= 90
yaw = radians(yaw)

vec = Vector(
x=cos(yaw) * steering_lines_speed,
y=sin(yaw) * steering_lines_speed,
z=fall_velocity + -(falling_speed * steering_lines_penalty))
else:
vec = Vector(z=fall_velocity + -falling_speed)

player.base_velocity = vec

if parachute_model is None:
return

player.delay(0, parachute_check, (player,))
If it doesn't work, let me know and I will see to compile a version for it.
User avatar
Painkiller
Senior Member
Posts: 376
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: Parachute v0.03!

Postby Painkiller » Tue Jan 30, 2018 4:16 pm

I have this in the downloadables.res but it download not.

I have the files on server and fastDL.


Code: Select all

models/parachute/parachute_blue.dx80.vtx
models/parachute/parachute_blue.dx90.vtx
models/parachute/parachute_blue.mdl
models/parachute/parachute_blue.sw.vtx
models/parachute/parachute_blue.vvd
models/parachute/parachute_blue.xbox.vtx
models/parachute/parachute_carbon.dx80.vtx
models/parachute/parachute_carbon.dx90.vtx
models/parachute/parachute_carbon.mdl
models/parachute/parachute_carbon.sw.vtx
models/parachute/parachute_carbon.vvd
models/parachute/parachute_carbon.xbox.vtx
models/parachute/parachute_green_v2.dx80.vtx
models/parachute/parachute_green_v2.dx90.vtx
models/parachute/parachute_green_v2.mdl
models/parachute/parachute_green_v2.sw.vtx
models/parachute/parachute_green_v2.vvd
models/parachute/parachute_green_v2.xbox.vtx
models/parachute/parachute_ice_v2.dx80.vtx
models/parachute/parachute_ice_v2.dx90.vtx
models/parachute/parachute_ice_v2.mdl
models/parachute/parachute_ice_v2.sw.vtx
models/parachute/parachute_ice_v2.vvd
models/parachute/parachute_ice_v2.xbox.vtx
materials/models/parachute/pack.vmt
materials/models/parachute/pack.vtf
materials/models/parachute/pack_carbon.vmt
materials/models/parachute/pack_carbon.vtf
materials/models/parachute/parachute_blue.vmt
materials/models/parachute/parachute_blue.vtf
materials/models/parachute/parachute_carbon.vmt
materials/models/parachute/parachute_carbon.vtf
materials/models/parachute/parachute_green_v2.vmt
materials/models/parachute/parachute_green_v2.vtf
materials/models/parachute/parachute_ice_v2.vmt
materials/models/parachute/parachute_ice_v2.vtf


and in the precache.res

Code: Select all

models/parachute/parachute_blue.mdl
models/parachute/parachute_carbon.mdl
models/parachute/parachute_green_v2.mdl
models/parachute/parachute_ice_v2.mdl
User avatar
L'In20Cible
Project Leader
Posts: 1078
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Parachute v0.03!

Postby L'In20Cible » Tue Jan 30, 2018 4:52 pm

You are using a different version. Download this version: Parachute_v0.03.zip And change the code of ../parachute.py by the one I posted above. I won't be supporting the old models, even if I have permission from SWAT_88 to use/ship them, because they are not adapted by the new system of parenting I implemented.

Return to “Plugin Releases”

Who is online

Users browsing this forum: No registered users and 1 guest