#dota2_particle_example.py
from players.entity import Player
from entities.entity import Entity
from commands.say import SayCommand
from stringtables import string_tables
from stringtables.downloads import Downloadables
from engines.precache import Generic
# Since we're using Dota 2 materials, we need to make sure all players
# get them, otherwise the particle effect will show up as an error, or
# it won't show up at all.
downloadables = Downloadables()
downloadables.add('materials/particle/spotlight/spotlight.vmt')
downloadables.add('materials/particle/spotlight/spotlight.vtf')
# The .pcf file containing our particle effect - aegis_respawn_spotlight.
items_fx = 'particles/dota2/items_fx.pcf'
def load():
# Before we get to use the particle effect, we need to precache it.
# Without this, the particle won't spawn.
Generic(items_fx, preload=True, download=True)
@SayCommand('spawn')
def spawn_effect(command, index, team_only=None):
player = Player(index)
create_particle(player.view_coordinates, 'aegis_respawn_spotlight')
def create_particle(position, effect_name):
particle = Entity.create('info_particle_system')
particle.effect_name = effect_name
particle.effect_index = string_tables.ParticleEffectNames.add_string(effect_name)
particle.origin = position
particle.start_active = 1
particle.start()