Enki

Custom Packages that plugins can require for common usages.
User avatar
VinciT
Senior Member
Posts: 331
Joined: Thu Dec 18, 2014 2:41 am

Enki

Postby VinciT » Wed Aug 31, 2022 10:36 pm

Image
Enki is a small custom package that gives plugin developers quick and easy access to the Player instance whenever the player starts or stops touching water.
As of the current version, the following can be found within the package:

Image Image

If, for example, you wanted to create a big water splash effect whenever the player initially touches the water (see the first gif):

Syntax: Select all

# ../water_splash/water_splash.py

# Source.Python
from entities.entity import Entity
from stringtables import string_tables

# Enki
from enki.listeners import OnPlayerEnterWater


@OnPlayerEnterWater
def on_player_enter_water(player):
"""Called when a player starts touching water."""
# Did the player enter the water at a reasonable velocity?
if player.velocity.length > 300:
# Let's make a big water splash!
particle = Entity.create('info_particle_system')
particle.origin = player.origin
# NOTE: This particle effect only exists in CS:GO, there are similar
# effects in other games, e.g. 'water_splash_01' in CS:S.
particle.effect_name = 'explosion_basic_water'
particle.effect_index = string_tables.ParticleEffectNames.add_string(
'explosion_basic_water'
)
particle.start()
particle.delay(1, particle.remove)
Or maybe you want to give players the ability to walk on water (second gif):

Syntax: Select all

# ../water_walk/water_walk.py

# Source.Python
from commands import CommandReturn
from commands.client import ClientCommand
from messages import HintText

# Enki
from enki.players.entity import EnkiPlayer


@ClientCommand('+lookatweapon')
def inspect_weapon_pressed(command, index):
"""Called when a player presses their weapon inspect key."""
EnkiPlayer(index).enable_water_walking()
# Tell the player that they can walk on water.
HintText('You can now walk on water.').send(index)
# Block the inspect animation from playing.
return CommandReturn.BLOCK


@ClientCommand('-lookatweapon')
def inspect_weapon_released(command, index):
"""Called when a player releases their weapon inspect key."""
EnkiPlayer(index).disable_water_walking()
HintText('You can no longer walk on water!').send(index)
return CommandReturn.BLOCK

You can find more examples in the repository.

Image
Latest release
enki_v1.0.zip
(5.03 KiB) Downloaded 2147 times
ImageImageImageImageImage
User avatar
Ayuto
Project Leader
Posts: 2195
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: Enki

Postby Ayuto » Fri Sep 09, 2022 10:19 am

This is very cool! :grin:
User avatar
VinciT
Senior Member
Posts: 331
Joined: Thu Dec 18, 2014 2:41 am

Re: Enki

Postby VinciT » Sat Sep 17, 2022 3:33 pm

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

Re: Enki

Postby L'In20Cible » Sun Sep 18, 2022 6:48 am

It is indeed very cool! Fighting client prediction on physics or movements is always a pain and it looks really smooth in your previews which is impressive.

I've not looked much at the code, but 2 things I've noticed:

  • In your first example (water_splash.py), I think you could use the following effect that is [from what I remember] available on all games and is the same and/or look pretty similar as the particles you currently use:

    Syntax: Select all

    player.dispatch_effect('WaterSurfaceExplosion')

  • Into enki/listeners.py line #44:

    Syntax: Select all

    # Is this SourceTV/GOTV?
    if tv_enable.get_int() > 0 and userid == 2:

    I don't think this is reliable. If the TV is enabled while there is already players on the server, it won't have a that userid. In any case, Player.is_hltv() should be set by the time player_spawn is fired and is undefined much earlier than that (connect listeners, etc).

Return to “Custom Packages”

Who is online

Users browsing this forum: No registered users and 2 guests