Skip to content

Commit

Permalink
Updated the README file.
Browse files Browse the repository at this point in the history
  • Loading branch information
vinci6k committed Aug 31, 2022
1 parent 4ef9458 commit 486b75f
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 7 deletions.
51 changes: 50 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,50 @@
# enki
# Enki
This is a small custom package for [Source.Python](https://github.com/Source-Python-Dev-Team/Source.Python) that gives plugin developers quick and easy access to the Player instance whenever the player starts or stops touching water.

<img src="https://i.giphy.com/media/Wayqf54mH2LabBeJlM/giphy.webp" width="412px" /> <img src="https://media0.giphy.com/media/pqWtHQWqZDcbV5cn1C/giphy.gif" width="412px" />
*First gif: [water_spash.py](https://github.com/vinci6k/enki/blob/master/examples/water_splash/water_splash.py); Second gif: [water_walk.py](https://github.com/vinci6k/enki/blob/master/examples/water_walk/water_walk.py)*

## Installation
1. [Install Source.Python](http://wiki.sourcepython.com/general/installation.html).
2. Download [the latest release](https://github.com/vinci6k/enki/releases) of Enki.
3. Extract the files into your game server's root folder.<br/>(e.g. ../csgo/ for Counter-Strike: Global Offensive)
4. Restart your server.

## Usage
```py
# ../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)
```
There are a few more [examples](https://github.com/vinci6k/enki/tree/master/examples) which showcase how this package works.
To see all the available imports/modules, head over to the [wiki](https://github.com/vinci6k/enki/wiki).


## Supported Games
Counter-Strike: Source
Counter-Strike: Global Offensive
Half Life 2: Deathmatch
Team Fortress 2
12 changes: 6 additions & 6 deletions addons/source-python/packages/custom/enki/players/entity.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# ../enki/players/entity.py

# Source.Python
from engines.trace import (ContentMasks, GameTrace, Ray, TraceFilterSimple,
engine_trace)
from engines.trace import (
ContentMasks, GameTrace, Ray, TraceFilterSimple, engine_trace
)
from mathlib import Vector
from players.entity import Player

Expand All @@ -17,7 +18,7 @@

class EnkiPlayer(Player):
"""Extended Player class.
Args:
index (int): A valid player index.
caching (bool): Check for a cached instance?
Expand Down Expand Up @@ -67,10 +68,10 @@ def disable_water_walking(self):

self.walk_on_water = False
self.rise_think.stop()

def _rise_think(self):
water_level = self.water_level

# Is the player no longer touching the water?
if water_level == WaterLevel.NOT_IN_WATER:
self.rise_think.stop()
Expand Down Expand Up @@ -104,4 +105,3 @@ def get_water_trace(self):
)

return trace

2 changes: 2 additions & 0 deletions examples/water_splash/water_splash.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ def on_player_enter_water(player):
# 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'
Expand Down
3 changes: 3 additions & 0 deletions examples/water_walk/water_walk.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# ../water_walk/water_walk.py

# NOTE: This example was made for Counter-Strike: Global Offensive, as it
# uses the weapon inspect command to trigger the water walking mechanic.

# Source.Python
from commands import CommandReturn
from commands.client import ClientCommand
Expand Down

0 comments on commit 486b75f

Please sign in to comment.