Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #taser_particle_example.py
- from players.entity import Player
- from entities.entity import Entity
- from commands.say import SayCommand
- from stringtables import string_tables
- @SayCommand('spawn')
- def spawn_effect(command, index, team_only=None):
- player = Player(index)
- taze(player.eye_location, player.view_coordinates, player.view_angle)
- def taze(start_pos, end_pos, start_angle):
- # This is our main particle effect.
- particle1 = Entity.create('info_particle_system')
- # We are using particle2 as our controlpoint1.
- particle2 = Entity.create('info_particle_system')
- # Name for controlpoint1 (cpoint1).
- cp_name = f'cp_for_{particle1.index}'
- # Setting the correct particle effects.
- particle1.effect_name = 'weapon_tracers_taser'
- particle2.effect_name = 'weapon_taser_glow_impact'
- # Add the particle effects to the stringtables,
- # and in return, get the particle effect indexes
- particle1.effect_index = string_tables.ParticleEffectNames.add_string('weapon_tracers_taser')
- particle2.effect_index = string_tables.ParticleEffectNames.add_string('weapon_taser_glow_impact')
- # Setting the position and angle of the particle effect.
- # (without the angle, the taser effect will look odd)
- particle1.origin = start_pos
- particle1.teleport(None, start_angle, None)
- particle2.origin = end_pos
- # Use 'cp_name' as the targetname for particle2 - since this is where we
- # want the taser effect to go / end.
- particle2.set_key_value_string('targetname', cp_name)
- # This is where the magic happens.
- # Setting this to the same name as particle2's targetname will make it
- # work properly.
- particle1.cpoint1 = cp_name
- # Make sure the particle starts as soon as it spawns.
- particle1.start_active = 1
- particle2.start_active = 1
- # In case the above part fails, force them to start.
- particle1.start()
- particle2.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement