[Help] How to trigger game_player_equip only if the ammo is not full? Created 3 years ago2020-12-06 21:39:28 UTC by mahagon mahagon

Created 3 years ago2020-12-06 21:39:28 UTC by mahagon mahagon

Posted 3 years ago2020-12-06 21:39:28 UTC Post #345033
I am currently working on a mutliplayer map that is designed to be for a fast paced deathmatch mod. The goal of the map is to provide a fast, seamless action packed experience, where the players will stay in motion for the majority of the time (speedcap is removed so its possible to bunnyhop and gain a lot of speed) and here is the gist: The weapons in HL have too small of a pickup hitbox for what I want to achieve.

The idea is to make them collectable as you jump at a very high speed, without having to be too precise about it.
The solution I came up with for this is by placing a trigger_multiple that targets a multi_manager which in turn targets a game_player_equip that will give you the corresponding weapon. In addition I added a bunch of sprite effects to make it pretty. The multi_manager handles this on a 20s timer, so that the "weapon" respawns after 20 seconds, just like it would be if the weapon was placed normally.
User posted image
The trigger_multiple allows me to design it as big as I want it to be for more "loose" dimensions in regards to the weapon pickup. Perfect for when I want to create a bigger weapon pickup hitbox.

The problem with this solution is, that if the players ammo is full, it will obviously still trigger the game_player_equip upon touching the trigger, resulting in my makeshift weapon rune to disappear (and spawning an actual weapon to be picked up from the ground).
User posted image
My question is if there is any way to prevent this? I'm looking for a solution where the trigger_multiple would only be triggered if the player has less than max ammo (i.e. is able to pick up the weapon in the first place).
Posted 3 years ago2020-12-07 01:08:11 UTC Post #345036
The only thing I can come up with is to first use a player_weaponstrip, but that's also a big change in terms of gameplay, with players only being able to carry one weapon at a time (unless you've got pickup spots that equip them with multiple weapons of course). If that's not acceptable then you'll have to modify the game code.

On a sidenote, you might be interested in a compile tool I've been working on, called MESS (Macro Entity Scripting System). It makes duplicating groups of related entities easier by letting you create a single template that can be reused. The latest version also lets you create custom entities for templates. With the right setup, you can place standard weapon and item entities in your map, and let MESS replace each of them with a trigger, multi_manager, game_player_equip and various sprites. And if you need to adjust something, you only need to modify a single template map, instead of every weapon pickup.
Posted 3 years ago2020-12-07 23:45:52 UTC Post #345039
I've created an example package for you. It doesn't solve the full-ammo problem, but it does make it much easier to add these high-speed weapon pickups to your maps. And if you do find a better solution, then all you need to do is update a single template and recompile your map.

To get back on topic, game_player_equip works by calling CBasePlayer::GiveNamedItem, which spawns an item and then immediately makes it touch the player. This is also used by the give and impulse 101 cheats. impulse 101 uses a bit of a hack to ensure that the item is killed afterwards (just in case the player already has max ammo), so I think the easiest solution would be to always apply that hack.
Posted 3 years ago2020-12-08 12:43:54 UTC Post #345040
You can spawn weapons with monstermaker (just type the weapon entity class in Monster Type field) and give them a name on spawn, then delete them after half a second with trigger_relay. You may need to make trigger_multiple smaller to make sure the player picks up the weapon.
Posted 3 years ago2020-12-10 01:55:10 UTC Post #345050
Thanks a lot for the input guys. I was going to do the map for 2 mods, one im working on myself where I'd have freedom with code but the other one is an existing mod, with no access to code. Guess I'll have to make a different version for the latter with regular weapons.
As for the former, I'd have full control over what I want to do. I guess that means I'll try creating a custom entity for the weapon solution which will allow me to do exactly what I want.

@Captain P: That compile tool sounds very interesting! Also appreciate the example package. I'll give your tool a try in the coming days, it sounds like it could definitely come in handy.
You must be logged in to post a response.