Page 1 of 1

scripts to produce player trails and icon above player's head

Posted: Mon Nov 10, 2014 6:50 am
by 8guawong

Posted: Mon Nov 10, 2014 3:57 pm
by satoon101
Once the entities_changes branch is finished, the following should work for trails (actually tested with my local version and it does work):

Syntax: Select all

from colors import BLUE
from colors import RED
from engines.precache import Model
from entities.entity import BaseEntity
from entities.helpers import create_entity
from events import Event
from filters.players import PlayerIter


model = Model('materials/sprites/laser.vmt')
teams = {
2: RED,
3: BLUE,
}


@Event
def player_say(game_event):
for index, team in PlayerIter('alive', return_types=['index', 'team']):
create_trail(index, teams[team])


def create_trail(index, color):
entity = BaseEntity(index)
trail = BaseEntity(create_entity('env_spritetrail'))
trail.lifetime = 10
trail.startwidth = 1
trail.endwidth = 1
trail.spritename = model
trail.color = color
origin = entity.origin
origin.z += 10
trail.origin = origin
trail.spawn()
trail.set_parent(entity.pointer, -1)
trail.set_prop_float('m_flTextureRes', 0.05)
trail.show_sprite()



I haven't tested the emote, as of yet.

Posted: Tue Nov 11, 2014 6:37 am
by 8guawong
satoon101 wrote:Once the entities_changes branch is finished, the following should work for trails (actually tested with my local version and it does work):

Syntax: Select all

from colors import BLUE
from colors import RED
from engines.precache import Model
from entities.entity import BaseEntity
from entities.helpers import create_entity
from events import Event
from filters.players import PlayerIter


model = Model('materials/sprites/laser.vmt')
teams = {
2: RED,
3: BLUE,
}


@Event
def player_say(game_event):
for index, team in PlayerIter('alive', return_types=['index', 'team']):
create_trail(index, teams[team])


def create_trail(index, color):
entity = BaseEntity(index)
trail = BaseEntity(create_entity('env_spritetrail'))
trail.lifetime = 10
trail.startwidth = 1
trail.endwidth = 1
trail.spritename = model
trail.color = color
origin = entity.origin
origin.z += 10
trail.origin = origin
trail.spawn()
trail.set_parent(entity.pointer, -1)
trail.set_prop_float('m_flTextureRes', 0.05)
trail.show_sprite()



I haven't tested the emote, as of yet.


very cool but if i want to use custom trails do i just replace the

Syntax: Select all

model = Model('materials/sprites/laser.vmt')

for the emote i was thinking it would cool to attach floating admin/vip text over players head ;-)

Posted: Tue Nov 11, 2014 2:36 pm
by satoon101
Yes, you would replace the model to change the trail. Also, since you are just passing the string when setting the spritename, you will need to precache when using a custom material:

Syntax: Select all

model.index
trail.spritename = model


We will work on a fix for this, possibly something like:

Syntax: Select all

trail.spritename = model.path


Also, I should have mentioned this yesterday, but I only tested this on CS:S. I will test on CS:GO, when I get the chance, to verify it works.

*Edit: had to change the model to laserbeam instead of laser on CS:GO, but it works :)
http://cloud-4.steampowered.com/ugc/541884075847249020/C35B4AE88412ACBDF6DE25341473C127A431B480/

Posted: Wed Nov 12, 2014 1:41 am
by 8guawong
satoon101 wrote:Yes, you would replace the model to change the trail. Also, since you are just passing the string when setting the spritename, you will need to precache when using a custom material:

Syntax: Select all

model.index
trail.spritename = model


We will work on a fix for this, possibly something like:

Syntax: Select all

trail.spritename = model.path


Also, I should have mentioned this yesterday, but I only tested this on CS:S. I will test on CS:GO, when I get the chance, to verify it works.

*Edit: had to change the model to laserbeam instead of laser on CS:GO, but it works :)
http://cloud-4.steampowered.com/ugc/541884075847249020/C35B4AE88412ACBDF6DE25341473C127A431B480/


coolio
looking foward to the the next SP release