Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #dota2_particle_example.py
  2.  
  3. from players.entity import Player
  4. from entities.entity import Entity
  5. from commands.say import SayCommand
  6. from stringtables import string_tables
  7. from stringtables.downloads import Downloadables
  8. from engines.precache import Generic
  9.  
  10.  
  11. # Since we're using Dota 2 materials, we need to make sure all players
  12. # get them, otherwise the particle effect will show up as an error, or
  13. # it won't show up at all.
  14. downloadables = Downloadables()
  15. downloadables.add('materials/particle/spotlight/spotlight.vmt')
  16. downloadables.add('materials/particle/spotlight/spotlight.vtf')
  17.  
  18. # The .pcf file containing our particle effect - aegis_respawn_spotlight.
  19. items_fx = 'particles/dota2/items_fx.pcf'
  20.  
  21.  
  22. def load():
  23.     # Before we get to use the particle effect, we need to precache it.
  24.     # Without this, the particle won't spawn.
  25.     Generic(items_fx, preload=True, download=True)
  26.  
  27.  
  28. @SayCommand('spawn')
  29. def spawn_effect(command, index, team_only=None):
  30.     player = Player(index)
  31.     create_particle(player.view_coordinates, 'aegis_respawn_spotlight')
  32.  
  33.  
  34. def create_particle(position, effect_name):
  35.     particle = Entity.create('info_particle_system')
  36.  
  37.     particle.effect_name = effect_name
  38.     particle.effect_index = string_tables.ParticleEffectNames.add_string(effect_name)
  39.  
  40.     particle.origin = position
  41.  
  42.     particle.start_active = 1
  43.     particle.start()