Page 1 of 1

IEffects library now available!!!

Posted: Thu Aug 16, 2012 5:52 am
by satoon101
Development on the plugin is going strong. We now have the ability to use the IEffects class:
  • Beam:
    • Start (Vector)
    • End (Vector)
    • nModelIndex (index - use GameEngine.PrecacheModel)
    • mHaloIndex (index - use GameEngine.PrecacheModel)
    • frameStart (integer)
    • frameRate (integer)
    • flLife (float - seconds for the beam to remain)
    • width (integer)
    • endWidth (integer)
    • fadeLength (integer)
    • noise (integer)
    • red (integer 0-255)
    • green (integer 0-255)
    • blue (integer 0-255)
    • brightness (integer 0-255)
    • speed
  • Dust:
    • pos (Vector - position of the dust)
    • dir (Vector - direction of the dust)
    • size (float)
    • speed (float)
  • EnergySplash:
    • position (Vector)
    • direction (Vector)
    • bExplosive (bool)
  • MetalSparks:
    • position (Vector)
    • direction (Vector)
  • MuzzleFlash:
    • vecOrigin (Vector)
    • vecAngles (Vector)
    • flScale (float)
    • iType (integer)
  • Ricochet:
    • position (Vector)
    • direction (Vector)
  • Smoke:
    • origin (Vector)
    • modelIndex (index - use GameEngine.PrecacheModel)
    • scale (float)
    • framerate (float)
  • Sparks:
    • position (Vector)
    • nMagnitude (integer)
    • nTrailLength (integer)
    • pvecDir (Vector - direction)

Here is a simple DeathBeam script I tried out:

Syntax: Select all

# =============================================================================
# >> IMPORTS
# =============================================================================
# Source.Python Imports
from Source import Misc
from Source import Player
# Core
from core import GameEngine
# Events
from events.decorator import Event


# =============================================================================
# >> GLOBAL VARIABLES
# =============================================================================
effects = Misc.GetEffects()
model = GameEngine.PrecacheModel('sprites/laserbeam.vmt')


# =============================================================================
# >> GAME EVENTS
# =============================================================================
@Event
def player_death(GameEvent):
victim = Player.PlayerOfUserid(GameEvent.GetInt('userid'))
killer = Player.PlayerOfUserid(GameEvent.GetInt('attacker'))

green = 0

if killer.GetTeamIndex() == 2:
red = 255
blue = 0
else:
red = 0
blue = 255

effects.Beam(victim.GetAbsOrigin(), killer.GetAbsOrigin(),
model, model, 0, 0, 20.0, 1, 1, 0, 0, red, green, blue, 255, 0)
Here is a pic of the results of that script:
http://steamcommunity.com/profiles/76561197970633142/screenshot/558698452561908099?tab=public

Do note, though, that while this is currently in the Misc structure, it will be moved out once we decide how to move forward with the structure on the C++ side. For future updates, if any functionality is in Misc, it is there for an undetermined time until it gets moved out, but it will be moved out at some point. If you create a script that uses Misc, be sure to keep up-to-date, so you know when you need to modify your script.

Note also, that the script above takes advantage of more new functionality available to us as of the latest updates. You can now use Player.PlayerOfUserid(<userid>) to get a userid's IPlayerInfo instance, Player.EdictOfUserid(<userid>) to get a userid's entity edict, and Player.PlayerOfIndex(<index>) to get a player's IPlayerInfo from their index.

Satoon

Posted: Sat Aug 18, 2012 5:49 pm
by DreTaX14
satoon101 wrote:Development on the plugin is going strong. We now have the ability to use the IEffects class:
  • Beam:
    • Start (Vector)
    • End (Vector)
    • nModelIndex (index - use GameEngine.PrecacheModel)
    • mHaloIndex (index - use GameEngine.PrecacheModel)
    • frameStart (integer)
    • frameRate (integer)
    • flLife (float - seconds for the beam to remain)
    • width (integer)
    • endWidth (integer)
    • fadeLength (integer)
    • noise (integer)
    • red (integer 0-255)
    • green (integer 0-255)
    • blue (integer 0-255)
    • brightness (integer 0-255)
    • speed
  • Dust:
    • pos (Vector - position of the dust)
    • dir (Vector - direction of the dust)
    • size (float)
    • speed (float)
  • EnergySplash:
    • position (Vector)
    • direction (Vector)
    • bExplosive (bool)
  • MetalSparks:
    • position (Vector)
    • direction (Vector)
  • MuzzleFlash:
    • vecOrigin (Vector)
    • vecAngles (Vector)
    • flScale (float)
    • iType (integer)
  • Ricochet:
    • position (Vector)
    • direction (Vector)
  • Smoke:
    • origin (Vector)
    • modelIndex (index - use GameEngine.PrecacheModel)
    • scale (float)
    • framerate (float)
  • Sparks:
    • position (Vector)
    • nMagnitude (integer)
    • nTrailLength (integer)
    • pvecDir (Vector - direction)

Here is a simple DeathBeam script I tried out:

Syntax: Select all

# =============================================================================
# >> IMPORTS
# =============================================================================
# Source.Python Imports
from Source import Misc
from Source import Player
# Core
from core import GameEngine
# Events
from events.decorator import Event


# =============================================================================
# >> GLOBAL VARIABLES
# =============================================================================
effects = Misc.GetEffects()
model = GameEngine.PrecacheModel('sprites/laserbeam.vmt')


# =============================================================================
# >> GAME EVENTS
# =============================================================================
@Event
def player_death(GameEvent):
victim = Player.PlayerOfUserid(GameEvent.GetInt('userid'))
killer = Player.PlayerOfUserid(GameEvent.GetInt('attacker'))

green = 0

if killer.GetTeamIndex() == 2:
red = 255
blue = 0
else:
red = 0
blue = 255

effects.Beam(victim.GetAbsOrigin(), killer.GetAbsOrigin(),
model, model, 0, 0, 20.0, 1, 1, 0, 0, red, green, blue, 255, 0)
Here is a pic of the results of that script:
http://steamcommunity.com/profiles/76561197970633142/screenshot/558698452561908099?tab=public

Do note, though, that while this is currently in the Misc structure, it will be moved out once we decide how to move forward with the structure on the C++ side. For future updates, if any functionality is in Misc, it is there for an undetermined time until it gets moved out, but it will be moved out at some point. If you create a script that uses Misc, be sure to keep up-to-date, so you know when you need to modify your script.

Note also, that the script above takes advantage of more new functionality available to us as of the latest updates. You can now use Player.PlayerOfUserid(<userid>) to get a userid's IPlayerInfo instance, Player.EdictOfUserid(<userid>) to get a userid's entity edict, and Player.PlayerOfIndex(<index>) to get a player's IPlayerInfo from their index.

Satoon

Do you have that sprite file?

Posted: Sat Aug 18, 2012 8:36 pm
by Omega_K2
Awesome :D

Posted: Sun Aug 19, 2012 12:33 am
by satoon101
DreTaX14 wrote:Do you have that sprite file?
You do not need that specific sprite on the server. It is located, for clients, in their pak01_dir.vpk file, if you wish to reference it.

Satoon

Posted: Sun Aug 19, 2012 8:22 am
by DreTaX14
Okay but somehow it doesnt really work for me if i want to test it.

Posted: Sun Aug 19, 2012 12:40 pm
by satoon101
I have been having 1 issue with it, but I cannot figure out what is causing it. If "I" kill someone, the beam does not show, but if anyone else gets a kill, it shows. This is tested with just me vs bots, not sure if that has anything to do with it either.

Satoon

Posted: Sun Aug 19, 2012 12:57 pm
by DreTaX14
looooooolll

Posted: Sun Aug 19, 2012 4:21 pm
by Monday
Thats a weird issue...

Posted: Sun Aug 19, 2012 6:33 pm
by DreTaX14
yes it is xD

Posted: Tue Nov 20, 2012 4:36 am
by Tuck
Be sure to note that

Syntax: Select all

model = GameEngine.PrecacheModel('sprites/laserbeam.vmt')


will crash the game if you load this before a map has loaded completly (for example having sp load <plugin> in autoexec.cfg) you will have to use something like this for precaching model for clients not to crash:

Syntax: Select all

from events import Event

model = None


@Event
def server_spawn(GameEvent):
global model
model = GameEngine.PrecacheModel('sprites/laserbeam.vmt')


#Be sure this can be only be called after map load such as player_say or another player_ event
#that way it will be save to precache if not already precached.
def beam(<example>):
global model
if model is None:
model = GameEngine.PrecacheModel('sprites/laserbeam.vmt')
effects.Beam(victim.GetAbsOrigin(), killer.GetAbsOrigin(),
model, model, 0, 0, 20.0, 1, 1, 0, 0, 255, 255, 255, 255, 0)

Posted: Sun Aug 10, 2014 1:45 pm
by DJiSer
Effects also unavailable for current build?

Posted: Sun Aug 10, 2014 2:11 pm
by Ayuto
No, they are available since a long time. :) https://github.com/Source-Python-Dev-Team/Source.Python/blob/master/addons/source-python/packages/source-python/effects/__init__.py

There are two effect classes you can use: Effects and TempEntities

TempEntities also gives you the possibility to specify users who should see the effects.

Posted: Sun Aug 10, 2014 3:35 pm
by satoon101
Also note that this thread is two years old. A lot has changed in the plugin since then. Pretty much none of the examples above work with the current version of the plugin.

Posted: Sun Aug 10, 2014 9:18 pm
by DJiSer

Syntax: Select all

from engines.server import EngineServer
from effects import Effects
from events import Event
from players.entity import PlayerEntity
from players.helpers import index_from_userid


@Event
def player_hurt(game_event):
model = EngineServer.precache_model('sprites/laserbeam.vmt')
userid = game_event.get_int('userid')
attacker = game_event.get_int('attacker')
pos1 = PlayerEntity(index_from_userid(userid)).location
pos2 = PlayerEntity(index_from_userid(attacker)).location
Effects.beam(pos1, pos2, model, model, 0, 0, 20.0, 1, 1, 0, 0, 255, 0, 255, 255, 0)

Just nothing happens.

Posted: Sun Aug 10, 2014 9:32 pm
by satoon101
A player's origin (location) is at their feet. If both players are on the ground and at the same altitude, the beam will essentially be in the ground. Try increasing the z value of the vectors by 20 and see what that does.

Posted: Sun Aug 10, 2014 9:38 pm
by Ayuto
I just tested it, you are right. What happens if you try this?

Syntax: Select all

from engines.server import EngineServer
from effects import Effects
from events import Event
from players.entity import PlayerEntity
from players.helpers import index_from_userid

@Event
def player_hurt(game_event):
model = EngineServer.precache_model('sprites/laserbeam.vmt')
userid = game_event.get_int('userid')
attacker = game_event.get_int('attacker')
pos1 = PlayerEntity(index_from_userid(userid)).location
pos2 = PlayerEntity(index_from_userid(attacker)).location

#Effects.beam(pos1, pos2, model, model, 0, 0, 20.0, 1, 1, 0, 0, 255, 0, 255, 255, 0)

from listeners.tick.delays import TickDelays
TickDelays.delay(0, Effects.beam, pos1, pos2, model, model, 0, 0, 20.0, 1, 1, 0, 0, 255, 0, 255, 255, 0)

Posted: Sun Aug 10, 2014 9:43 pm
by DJiSer
Ayuto wrote:I just tested it, you are right. What happens if you try this?

Syntax: Select all

from engines.server import EngineServer
from effects import Effects
from events import Event
from players.entity import PlayerEntity
from players.helpers import index_from_userid

@Event
def player_hurt(game_event):
model = EngineServer.precache_model('sprites/laserbeam.vmt')
userid = game_event.get_int('userid')
attacker = game_event.get_int('attacker')
pos1 = PlayerEntity(index_from_userid(userid)).location
pos2 = PlayerEntity(index_from_userid(attacker)).location

#Effects.beam(pos1, pos2, model, model, 0, 0, 20.0, 1, 1, 0, 0, 255, 0, 255, 255, 0)

from listeners.tick.delays import TickDelays
TickDelays.delay(0, Effects.beam, pos1, pos2, model, model, 0, 0, 20.0, 1, 1, 0, 0, 255, 0, 255, 255, 0)


It works now.

Posted: Sun Aug 10, 2014 9:49 pm
by Ayuto
Okay, but this is obviously a bug. We will look into this issue.

Posted: Thu Aug 28, 2014 12:33 pm
by Ayuto