Page 1 of 1

Enki

Posted: Wed Aug 31, 2022 10:36 pm
by VinciT
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 715 times

Re: Enki

Posted: Fri Sep 09, 2022 10:19 am
by Ayuto
This is very cool! :grin:

Re: Enki

Posted: Sat Sep 17, 2022 3:33 pm
by VinciT
Thank you Ayuto! :embarrassed:

Re: Enki

Posted: Sun Sep 18, 2022 6:48 am
by L'In20Cible
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).