Parachute v0.03!

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

Re: Parachute!

Postby L'In20Cible » Tue Jan 24, 2017 12:19 am

Remove the info part.
User avatar
Painkiller
Senior Member
Posts: 726
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: Parachute!

Postby Painkiller » Tue Jan 24, 2017 8:11 am

Ok i have, but now come this.

Syntax: Select all

09:10:17 [SP] Loading plugin 'parachute'...

[SP] Caught an Exception:
Traceback (most recent call last):
File "../addons/source-python/packages/source-python/plugins/command.py", line 162, in load_plugin
plugin = self.manager.load(plugin_name)
File "../addons/source-python/packages/source-python/plugins/manager.py", line 174, in load
plugin._load()
File "../addons/source-python/packages/source-python/plugins/instance.py", line 67, in _load
self.module = import_module(self.import_name)
File "../addons/source-python/plugins/parachute/parachute.py", line 48, in <module>
configuration = ConfigManager(informations.basename)

NameError: name 'informations' is not defined


[SP] Plugin 'parachute' was unable to be loaded.
User avatar
L'In20Cible
Project Leader
Posts: 1534
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Parachute!

Postby L'In20Cible » Tue Jan 24, 2017 8:17 am

Replace all occurences of informations.basename with 'parachute'.
User avatar
Painkiller
Senior Member
Posts: 726
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: Parachute!

Postby Painkiller » Tue Oct 03, 2017 10:01 am

Hii have find an error.

Code: Select all

[SP] Loading plugin 'parachute'...

[SP] Caught an Exception:
Traceback (most recent call last):
  File "../addons/source-python/packages/source-python/plugins/command.py", line 162, in load_plugin
    plugin = self.manager.load(plugin_name)
  File "../addons/source-python/packages/source-python/plugins/manager.py", line 193, in load
    plugin._load()
  File "../addons/source-python/packages/source-python/plugins/instance.py", line 74, in _load
    self.module = import_module(self.import_name)
  File "../addons/source-python/plugins/parachute/parachute.py", line 67, in <module>
    with open(CFG_PATH / 'parachute' / 'precache.res') as f:

FileNotFoundError: [Errno 2] No such file or directory: Path('../cfg/source-python/parachute/precache.res')


[SP] Plugin 'parachute' was unable to be loaded.
User avatar
Ayuto
Project Leader
Posts: 2195
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: Parachute!

Postby Ayuto » Tue Oct 03, 2017 10:51 am

Looks like you are using this version, but didn't fully installed it...:
viewtopic.php?p=9047#p9047
User avatar
L'In20Cible
Project Leader
Posts: 1534
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Parachute!

Postby L'In20Cible » Wed Oct 04, 2017 4:42 am

Like Ayuto said, you didn't install it correctly. The traceback you posted clearly tells you that you are missing a file:

Code: Select all

FileNotFoundError: [Errno 2] No such file or directory: Path('../cfg/source-python/parachute/precache.res')
User avatar
iPlayer
Developer
Posts: 590
Joined: Sat Nov 14, 2015 8:37 am
Location: Moscow
Contact:

Re: Parachute!

Postby iPlayer » Wed Oct 04, 2017 5:03 am

Well, the plugin needed to be updated, too (due to the PluginInfo changes - it hasn't been updated since then)

Here's the new version

Syntax: Select all

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


# ============================================================================
# >> IMPORTS
# ============================================================================
# Python Imports
from random import choice

# Source.Python Imports
from cvars import ConVarFlags
from entities.constants import MoveType
from paths import CFG_PATH
from players.constants import PlayerStates
from players.constants import PlayerButtons

from mathlib import Vector
# Config
from config.manager import ConfigManager
# Core
from core import echo_console
# ConVars
from cvars import ConVar
# Models
from engines.precache import Model
# Entities
from entities.entity import Entity
# Events
from events import Event
# Filters
from filters.players import PlayerIter
# Messages
from messages import HintText
# Players
from players.entity import Player
# Plugins
from plugins.info import PluginInfo
from plugins.manager import plugin_manager
# Tick
from listeners import OnTick
from listeners.tick import Delay
# Stringtables
from stringtables.downloads import Downloadables
# Translations
from translations.strings import LangStrings


# ============================================================================
# >> INFORMATIONS
# ============================================================================
info = plugin_manager.get_plugin_info(__name__)


# ============================================================================
# >> GLOBAL VARIABLES
# ============================================================================
# Create and execute the configuration file...
configuration = ConfigManager(info.name)
parachute_advert = configuration.cvar('parachute_advert', '1',
description='Enable/Disable the advert every round start.')
parachute_button = configuration.cvar('parachute_button', 'SPEED',
description='Defines the button to use the parachute.')
parachute_falling_speed = configuration.cvar('parachute_falling_speed', '10',
description='Defines the falling speed of the parachute.')
configuration.write()
configuration.execute()

# Parse the translations files...
translations = LangStrings(info.name)

# Get a global HintText...
advert = HintText(message=translations['Advert'])


# Parse precache.res
models = []
with open(CFG_PATH / info.name / 'precache.res') as f:
for line in f:
line = line.strip()
if not line:
continue
models.append(Model(line))

# Parse downloadables.res
downloadables = Downloadables()
with open(CFG_PATH / info.name / 'downloadables.res') as f:
for line in f:
line = line.strip()
if not line:
continue
downloadables.add(line)

parachutes = {}


# ============================================================================
# >> FUNCTIONS
# ============================================================================
def open_parachute(player):
parachute = Entity.create('prop_dynamic_override')
parachutes[player.userid] = (player, parachute)

parachute.model = choice(models)
parachute.teleport(player.origin, player.angles, None)
parachute.spawn()


def close_parachute(player):
parachutes.pop(player.userid)[1].remove()


# ============================================================================
# >> LISTENER CALLBACKS
# ============================================================================
@OnTick
def tick_listener():
'''Fired each game frame...'''

try:
# Teleport existing parachutes to their owners
for player, parachute in parachutes.values():
parachute.teleport(player.origin, player.angles, None)

# Loop through all living, human players...
for player in PlayerIter(is_filters=['alive'], not_filters=['bot']):

# Is the player not falling?
if (player.fall_velocity < 1.0 or

# Is the player not holding his parachute key?
not player.buttons & getattr(PlayerButtons,
parachute_button.get_string().upper()) or

# Is the player currently in a ladder?
player.move_type & MoveType.LADDER or

# Is the player currently in water?
player.flags & PlayerStates.INWATER):

if player.userid in parachutes:
close_parachute(player)

continue

# Revert the falling velocity to slow down the player speed...
player.base_velocity = Vector(
0,
0,
player.fall_velocity + (
parachute_falling_speed.get_float() * -1)
)

if player.userid not in parachutes:
open_parachute(player)

except Exception as e:
echo_console(str(e))


# ============================================================================
# >> GAME EVENTS
# ============================================================================
@Event('round_start')
def round_start(game_event):
'''Fired at the beginning of every round...'''

# Clear entities list
parachutes.clear()

# Is the advert disabled?
if not parachute_advert.get_bool():

# No need to go further...
return

# Send the advert...
# NOTE: Since ResetHud is sent every round, we need to wait a bit before
# sending a HintText message...
Delay(0.5, advert.send,
kwargs={'button': parachute_button.get_string().lower()})


Here's info.ini:

Syntax: Select all

verbose_name = "Parachute"
author = "L'In20Cible, iPlayer"
description = "You know..."
version = "1.0"


This plugin desperately needs a repo.
Image /id/its_iPlayer
My plugins: Map Cycle • Killstreaker • DeadChat • Infinite Jumping • TripMines • AdPurge • Bot Damage • PLRBots • Entity AntiSpam

Hail, Companion. [...] Hands to yourself, sneak thief. Image
User avatar
L'In20Cible
Project Leader
Posts: 1534
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Parachute!

Postby L'In20Cible » Sat Oct 14, 2017 10:17 pm



  • Optimizations.
  • New mechanic: Steering lines!
  • New model for OrangeBox and CS:GO engines.
  • Cheap "scaling" animation to simulate the deployment of the parachute.
  • Parachute parenting for movement prediction.
User avatar
satoon101
Project Leader
Posts: 2698
Joined: Sat Jul 07, 2012 1:59 am

Re: Parachute v0.02!

Postby satoon101 » Sat Dec 02, 2017 6:55 pm

This works great on Windows, but I'm experiencing a crash on Linux. I have narrowed down the crash to line 145:

Syntax: Select all

parachute.parent = weapon


Output of "sp info":

Code: Select all

Date          : 2017-12-02 18:54:00.610238
OS            : Linux-3.14.1-ub-100hz-x86_64-with-debian-7.11
Game          : css
SP version    : 621
Server plugins:
   00: Source.Python, (C) 2012-2016, Source.Python Team.
SP plugins:
   00: gungame, 1.1.1, https://forums.sourcepython.com/viewtopic.php?t=1621
   01: map_config
   02: parachute, 0.02, https://forums.sourcepython.com/viewtopic.php?f=7&p=10736#p10736
Image
User avatar
L'In20Cible
Project Leader
Posts: 1534
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Parachute v0.02!

Postby L'In20Cible » Sun Dec 03, 2017 1:24 am

Interesting. Does the Entity.set_parent call itself crash on Linux, or only when you parent to a carried weapon? Does the following also crashes?

Syntax: Select all

parachute.call_input('SetParent', '!activator', activator=weapon)
User avatar
satoon101
Project Leader
Posts: 2698
Joined: Sat Jul 07, 2012 1:59 am

Re: Parachute v0.02!

Postby satoon101 » Sun Dec 03, 2017 1:42 am

L'In20Cible wrote:Interesting. Does the Entity.set_parent call itself crash on Linux, or only when you parent to a carried weapon?

I use Entity.set_parent in multi_level, and that seems to function correctly.


L'In20Cible wrote:Does the following also crashes?

Syntax: Select all

parachute.call_input('SetParent', '!activator', activator=weapon)

This also crashes, unfortunately.
Image
User avatar
L'In20Cible
Project Leader
Posts: 1534
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Parachute v0.02!

Postby L'In20Cible » Sun Dec 03, 2017 1:54 am

Hmm. What if you move it after the spawn() call?
User avatar
satoon101
Project Leader
Posts: 2698
Joined: Sat Jul 07, 2012 1:59 am

Re: Parachute v0.02!

Postby satoon101 » Sun Dec 03, 2017 2:39 am

L'In20Cible wrote:Hmm. What if you move it after the spawn() call?

When I did that, it crashed on setting the model. I moved both down, and it crashed on either of those 2 depending on the order I had them after spawn().
Image
User avatar
L'In20Cible
Project Leader
Posts: 1534
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Parachute v0.02!

Postby L'In20Cible » Sun Dec 03, 2017 2:45 am

EDIT: Actually, this is probably because set_parent and call_input are both dynamically calling a function which is most likely related to issue #157.
User avatar
L'In20Cible
Project Leader
Posts: 1534
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Parachute v0.02!

Postby L'In20Cible » Sun Dec 03, 2017 4:09 am

The following should do it, I guess:

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
from listeners.tick import Delay
# 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
# ============================================================================
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()


# ============================================================================
# >> 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

Delay(0, parachute_check, (player,))

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
User avatar
satoon101
Project Leader
Posts: 2698
Joined: Sat Jul 07, 2012 1:59 am

Re: Parachute v0.02!

Postby satoon101 » Sun Dec 03, 2017 4:39 am

That works!

I'm having an issue with my server when it comes to models, so it just shows the big red error, but it does work. The model error has nothing to do with this plugin, so if I can't figure it out, I'll start a new thread.

Thank you!
Image
User avatar
L'In20Cible
Project Leader
Posts: 1534
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Parachute v0.02!

Postby L'In20Cible » Sun Dec 03, 2017 5:10 am

If you see error models, that means your client didn't download the models. This can be caused by the server being unable to push the files because it doesn't have the correct permissions for the models/materials folders and cannot generate the ztmp files. This can also be caused by your client ignoring downloadables (cl_downloadfilter).
User avatar
L'In20Cible
Project Leader
Posts: 1534
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: Parachute v0.03!

Postby L'In20Cible » Sun Dec 03, 2017 5:29 am

I've just updated to v0.03 which adds the delay workaround. I recommend it over the code I posted above because it use Player.delay which will ensure the delay is tracked and cancelled if needed (should not matters, but just to be safe ;)).
User avatar
Painkiller
Senior Member
Posts: 726
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: Parachute v0.03!

Postby Painkiller » Fri Jan 12, 2018 5:59 pm

No longer work for BMS


Code: Select all

[SP] Loading plugin 'parachute'...

[SP] Caught an Exception:
Traceback (most recent call last):
  File "../addons/source-python/packages/source-python/plugins/command.py", line 162, in load_plugin
    plugin = self.manager.load(plugin_name)
  File "../addons/source-python/packages/source-python/plugins/manager.py", line 193, in load
    plugin._load()
  File "../addons/source-python/packages/source-python/plugins/instance.py", line 74, in _load
    self.module = import_module(self.import_name)
  File "../addons/source-python/plugins/parachute/parachute.py", line 65, in <module>
    downloadables.add_directory(f'models/parachute/{SOURCE_ENGINE}')
  File "../addons/source-python/packages/source-python/stringtables/downloads.py", line 65, in add_directory
    for index, file in enumerate(GAME_PATH.joinpath(directory).walkfiles(), 1):
  File "../addons/source-python/packages/site-packages/path.py", line 665, in walkfiles
    childList = self.listdir()
  File "../addons/source-python/packages/site-packages/path.py", line 532, in listdir
    for child in map(self._always_unicode, os.listdir(self))

FileNotFoundError: [Errno 2] No such file or directory: Path('../models/parachute/bms')


[SP] Plugin 'parachute' was unable to be loaded.
User avatar
Kill
Member
Posts: 88
Joined: Wed Aug 31, 2016 10:05 pm

Re: Parachute v0.03!

Postby Kill » Sun Jan 28, 2018 12:28 pm

Painkiller wrote:No longer work for BMS


Code: Select all

[SP] Loading plugin 'parachute'...

[SP] Caught an Exception:
Traceback (most recent call last):
  File "../addons/source-python/packages/source-python/plugins/command.py", line 162, in load_plugin
    plugin = self.manager.load(plugin_name)
  File "../addons/source-python/packages/source-python/plugins/manager.py", line 193, in load
    plugin._load()
  File "../addons/source-python/packages/source-python/plugins/instance.py", line 74, in _load
    self.module = import_module(self.import_name)
  File "../addons/source-python/plugins/parachute/parachute.py", line 65, in <module>
    downloadables.add_directory(f'models/parachute/{SOURCE_ENGINE}')
  File "../addons/source-python/packages/source-python/stringtables/downloads.py", line 65, in add_directory
    for index, file in enumerate(GAME_PATH.joinpath(directory).walkfiles(), 1):
  File "../addons/source-python/packages/site-packages/path.py", line 665, in walkfiles
    childList = self.listdir()
  File "../addons/source-python/packages/site-packages/path.py", line 532, in listdir
    for child in map(self._always_unicode, os.listdir(self))

FileNotFoundError: [Errno 2] No such file or directory: Path('../models/parachute/bms')


[SP] Plugin 'parachute' was unable to be loaded.



Download the models files.

Return to “Plugin Releases”

Who is online

Users browsing this forum: No registered users and 6 guests