Launch console commands?
I'm fairly new to Hammer modding.
I'm trying to create a custom map for Portal 2 in Hammer.
Now, one of the functions in the map will (if I can manage) be a rocket launcher (i.e. a player-wielded rocket launcher).
I've managed to create a paintgun using game_ui and info_paint_sprayer etc.
I would like to replace that info_paint_sprayer with something that fires rockets, but there seems to be no such entity in the SDK, but I know that the game supports rockets since the prop_rocket_tripwire does fire rockets, and more to the point - fire_rocket_projectile works as a console command.
Now, I figure that the easiest route would be to somehow trigger this fire_rocket_projectile command. Is this possible to to from within Hammer? For example by binding it to an output in game_ui.
If that's not possible, does anyone have any idea on how to create a rocket launcher in any other way? For example by lifting the rocket script from prop_rocket_tripwire. But I have absolutely no idea on how to do that.
Thanks for any help!
I'll try the good way first, then. I've read up on env_entity_maker and I think I understand how it works. However, where do I find the rocket_turret_projectile? It's not available as an entity in Hammer.
Do I need to import it from somewhere? Or am I misunderstanding something?
FelixGriffin wrote:
The easy way would be to use a point_servercommand or point_clientcommand. The good way would be to use an env_entity_maker set to launch the templateat a certain speed in a certain direction with a rocket_turret_projectile (which shows up broken in Hammer but actually does work).
The entity will not show as a valid entity, just type it in and press enter a few times. It won't have any properties most likely, but give it a name and put it in a point_template, and that point template in the entity maker.
Just creating an entity rocket_turret_projectile did indeed work! If I place it in the air it just hangs there 
However, I am having trouble pointing the point_template to it.
In my rocket_turret_projectile I created a property "Name" and named it "rocket_projectile".
However, when I try to point Template 1 in my point_template to it, it doesn't work. I can't use the dropper-thingy and simply click on "rocket_projectile"; Template 1 just remains empty. I can, however, manually write "rocket_projectile" but the text is red, indicating that it doesn't exist.
Also, I get an error message when trying the map, "CreateInstance called on a point_template that has no templates: rockettemplate1" where rockettemplate1 is my point_template.
I trigger it from an env_entity_maker.
Any ideas?
Thanks again!
I didn't realize that the name property was supposed to be "targetname", not "Name". Smartedit fooled me 
Thank you for your help!
One final question: I don't get any sound while the rocket is moving, and console gives me an error message saying that the sound files "weapons\rocket\rocket_fly_loop1.wav" and "weapons\rocket\rocket_fire1.wav" is missing. However, the client command fire_rocket_projectile has these sounds. Do I need to manually include these sounds in my map somehow?
bawng wrote:
One final question: I don't get any sound while the rocket is moving, and console gives me an error message saying that the sound files "weapons\rocket\rocket_fly_loop1.wav" and "weapons\rocket\rocket_fire1.wav" is missing. However, the client command fire_rocket_projectile has these sounds. Do I need to manually include these sounds in my map somehow?
Yes, if the entity wasn't finally included into the game, maybe those sounds weren't either... Maybe you can get them from HL2 or any other game (I don't know where that entity was used), then pack them with pakrat: place them in the path you posted inside the sounds folder, then use pakrat to add them manually... the game should locate the sounds from inside the .bsp.
Thanks again!
I'm having a bit of trouble with parenting to the player. I thought the parent should be "!player" but apparently that doesn't work. The button works, but it doesn't follow the player. How do I do this? Also, how do I solve this for multiplayer?
*
- OnMapSpawn > [func_button_name_here] > SetParent > red
- OnMapSpawn > [func_button_name_here] > SetParentattachmentMaintainOffset > eyes*
Same for the blue player.
I tried using a trigger to parent my func_button to red but that didn't work. Neither to blue.
I get this error in console: "Entity func_button(pl1_button) has bad parent blue". I'm guessing it's a syntax error?
!red
For now I parented it to !player and it works.
However, I'm having trouble with the attachment part. When Using SetParentAttachment to "eyes" the button hovers "in" the eyes and the player get stuck in it. When using SetParentAttachmentMaintainOffset to "eyes", the button hovers a bit above the player instead.
In neither case is it usable.
Does this have to do with where I place the brush entity in Hammer?
However, in order to find a better attachment point for the players, you can use the model viewer and load whatever player model, then go to the "attachment" tab and check their names and locations easily in the model.
The problem remains, though. I found that by moving the button's Origin point I could get it a bit away from the player, so I won't get stuck. However, if I move to quickly, or if I jump, the button doesn't move quick enough so I get temporarily stuck until the button catches up.
And still, it's no longer usable.
I really appreciate that you try to help me though!
Thanks!