Empty rocket launcher. Created 9 years ago2015-03-28 08:27:42 UTC by Dr. Orange Dr. Orange

Created 9 years ago2015-03-28 08:27:42 UTC by Dr. Orange Dr. Orange

Posted 9 years ago2015-03-28 08:27:42 UTC Post #325065
I'm working on a project, and I'm having a problem with the equipment when a player starts a new game in a specific map.
Basicly what I want is that the player should start with a whole bunch of items, including an empty rocket launcher.
I allready know how to set up a system to give the player all the items they need through point_templates and env_entity_makers. But what I want is the player to have the rocket launcher, but not being able to use it, becuase it have no ammo.
Think this is impossible? Well, try and start up a new game in the chapter "Follow Freeman". You'll see a red rocket launcher pickup icon, and the weapon will be in your inventory, but it's out of ammo.

So, my question is:
How do I use point_templates and env_entity_makers to give the player a rocket launcher that's out of ammo?
Dr. Orange Dr. OrangeSource good.
Posted 9 years ago2015-03-28 15:29:41 UTC Post #325068
I can't see any options for that. It might be a hard-coded event.
There's no other options for ammo counts, or an 'empty' flag.
Perhaps just equip the Launcher later?
Tetsu0 Tetsu0Positive Chaos
Posted 9 years ago2015-03-28 15:54:35 UTC Post #325070
You could cheeze out and simulate it, i.e., make a prop static disappear and have an ambient_generic play the pickup sound when triggered. You could add a info_text displaying:
Now I just have to find some ammo...
for good measure.

Put a little problem map in the vault; someone will figure how to fix it properly if it's possible ;)
Captain Terror Captain Terrorwhen a man loves a woman
Posted 9 years ago2015-03-28 15:54:53 UTC Post #325071
thing is you get 3 rockets when equipped. I know you can run custom scripts but i have no idea if you can directly affect held ammunition with an entity-fired script.
I couldn't find anything helpful on the VDC and you apparently can't directly modify variables with scripts (i tried)
Tetsu0 Tetsu0Positive Chaos
Posted 9 years ago2015-03-28 16:31:09 UTC Post #325073
Thing is, I know it's possible, I've seen it with my own eyes, and probably a few others. The reason I found out about this in the first place was becuase I was trying to get the "Counter Sniper" achievement.
I started a new game in "Follow Freeman" and then I thought I coul use the RPG to take out the snipers. Problem was, it was somehow mysteriously out of ammo. I hadn't used it, but I still had it. The red Icon was still in the weapon selection screen, and I saw the pickup Icon at the beggining of the map (wich was red by the way, indicating out of ammo). If Valve did this, how do I do it? I suppose it may be a hardcoded event to remove all RPG ammo if it's a new game, and the map is d3_c17_09, but if anyone knows how to do this I would appreciate it.
Dr. Orange Dr. OrangeSource good.
Posted 9 years ago2015-03-30 12:49:28 UTC Post #325129
I ran the level with developer 4 and inspected the console when the map loaded. A logic_auto is triggering a player_equip entity (among other things for AI control) If you can find a way to decompile the map, you'll find an answer.

I tried to play with console commands seeing if I could inspect the entity details but I'm afraid I couldn't find anything.

I also tried equipping weapon_rpg entities with various arguments passed along with it (-1, 1, 0, etc) and all those had no affect on the ammo provided.

Valve is either hard-coding that event, or there's a way to access player ammo counts via the I/O system that we don't know about. I'm curious to keep playing around with this though; it's an interesting challenge.
Tetsu0 Tetsu0Positive Chaos
Posted 9 years ago2015-03-30 17:41:32 UTC Post #325131
Ha! I finally found it! It seems like it was hardcoded after all. I found this piece of code and comment while looking through the source code for Half-Life 2:
{
#ifdef HL2_DLL
	if( FStrEq(STRING(gpGlobals->mapname), "d3_c17_09") && FClassnameIs(pWeapon, "weapon_rpg") && pWeapon->NameMatches("player_spawn_items") )
	{
		// !!!HACK - Don't give any ammo with the spawn equipment RPG in d3_c17_09. This is a chapter
		// start and the map is way to easy if you start with 3 RPG rounds. It's fine if a player conserves
		// them and uses them here, but it's not OK to start with enough ammo to bypass the snipers completely.
		GiveAmmo( 0, pWeapon->m_iPrimaryAmmoType);
	}
	else
#endif // HL2_DLL
	GiveAmmo(pWeapon->GetDefaultClip1(), pWeapon->m_iPrimaryAmmoType); 
}
Dr. Orange Dr. OrangeSource good.
Posted 9 years ago2015-03-30 18:22:14 UTC Post #325132
Bastards!
I was looking in the wrong place. This is a bittersweet victory; we found an answer but we have to take a different route to accomplish your goals.
Perhaps you can 'cheese' it like Captain mentioned, or just give the player a rocket launcher when the need arises.
Tetsu0 Tetsu0Positive Chaos
Posted 9 years ago2015-03-31 02:18:49 UTC Post #325140
What part of HL2 are you guys talking about? I've played it forever ago and I don't remember being in this situation, and I haven't yet encountered an empty RPG in my current playthrough of Half-Life 2: Updated (last I played I was about to unplug the field at the bridge).
Posted 9 years ago2015-03-31 02:46:18 UTC Post #325145
Only happens if you start a game from that level.
Tetsu0 Tetsu0Positive Chaos
Posted 9 years ago2015-03-31 07:26:28 UTC Post #325148
Well, since I am in fact making a mod, and I finally got the code to work, I guess that I could do the proper coding if that ever comes into question... But, I never brought up this question becuse I really needed to know, but more becuase it was an interesting concept.

Anyway, it seems like it's in the part of code that give you the ammo in the gun, so for instance when you pick up the pistol there's an ammo clip in there. It appearantly checks if the map name is d3_c17_09, and the RPG's name is player_spawn_items. If both are true it will give the player 0 rockets, if they are false the player will be given 3 rockets (like normal).
Dr. Orange Dr. OrangeSource good.
Posted 9 years ago2015-03-31 08:50:31 UTC Post #325151
Seems a bit shoddy as coding goes, but I suppose it is a single, quite situational instance.
Jessie JessieTrans Rights <3
Posted 9 years ago2015-03-31 19:23:59 UTC Post #325161
the RPG's name is player_spawn_items
Not exactly correct.
There's a game_player_equip entity with the name player_spawn_items.
I think that code is referencing the caller. It's right inside the level entity list. I dislike valve's code because something like that is VERY misleading.

Everything else you said Is correct (i think)
Tetsu0 Tetsu0Positive Chaos
Posted 9 years ago2015-03-31 20:16:51 UTC Post #325167
Just name your map d3_c17_09.bsp and you'll be good. No custom code needed!
Posted 9 years ago2015-04-01 07:00:40 UTC Post #325171
I did decompile the map in question - not beacuase I wanted to steal something from valve, I only do it when I want to learn something that isn't doceumented elseweher - and a lot of other maps, and it seems like every map, starting from d1_trainstation_06 have an equip system based on a point_template, an env_entity_maker, a logic_auto firing it's OnNewGame output, and the corepiece of it all: A lot of items given the same name, player_spawn_items.
So far, I haven't found a single instance of a game_player_equip entity in any of Valve's singleplayer maps. As far as I know, the entity is used exclusively for multiplayer maps to give the default weapons, but I may be wrong.
Anyway, the map also have a weapon_rpg entity named player_spawn_items to be spawned from template.
Dr. Orange Dr. OrangeSource good.
Posted 9 years ago2015-04-01 11:10:15 UTC Post #325172
that's interesting.
I stand corrected.
Tetsu0 Tetsu0Positive Chaos
You must be logged in to post a response.