TTT-2 / TTT2

Trouble in Terrorist Town 2 for Garry's Mod (gmod)
https://steamcommunity.com/sharedfiles/filedetails/?id=1357204556
179 stars 77 forks source link

Fix weapons spawning besides wrong kind of ammo #1004

Open schockocraft opened 2 years ago

schockocraft commented 2 years ago

Is your feature request related to a problem? Please describe. With the automatic weapon replacement TTT2 introduces now weapons can spawn besides the wrong kind of ammo, because Weapons with differrent ammo types are grouped in the same weapon type.

This causes Pistols and Glocks to spawn besides Deagle Ammo (when replacing a Deagle), M16s besides smg ammo (when replacing a Mac10/249), and Mac10s/249s besides 9mm ammo (when replacing a M16).

Also there is no way for map makers or Server owners to define that certain maps should not have their weapons replaced.

Generally i would say, weapons should not be replaced, if there are (at least a few?) ttt_random_weapon entities on the map, as that already indicates that all other weapons are meant to stay the specific weapon chosen by the map maker or spawn script creator.

Then again there should be a way to spawn random primaries/ppistols/grenades, instead of just a random anything, for maps created or edited with tt2 in mind, but this way should work so that the map would still be compatible with base ttt.

Describe the solution you'd like

  1. Replace weapons only with weapons that use the same ammo type if the weapon is close to ammo (i'd imagine checking that for any weapon might cause some lag, but then again you replace any ammo anyways already, so whatever...)
  2. Allow a way to Flag a map as not needing weapon replacement. Checking if a map has ttt_random_weapon entities seems to be the obvious choice to me.
  3. Add a Server Config/Variable to set if weapons should be replaced always, only if the map doesn't have the respective flag, only if the map is not a ttt map (could check if map name starts with ttt_), or not at all
  4. Add a way to flag weapon entities to be replaced by random weapons of the same weapon type (aka. how it happens rn), for maps without spawn script I'd suggest just using a special entity name to identify these? That way it would stay 100% compatible with old ttt. For maps using Spawn scripts idk what to suggest for this.

Describe alternatives you've considered Alternatively to solution 1 you could also change close by ammo to the ammo type of the new random weapon type

Additional context -

wgetJane commented 2 years ago

i think it would be a lot better if weapons were grouped according to their ammo type

while grouping them by "pistol", "heavy", whatever seems to make real-world sense, it doesn't really make sense for a weapon replacement system where they'd spawn next to incorrect ammo which is just really inconvenient

or outright just group them based on the exact weapon they're replacing, like spawn types can just be "shotgun", "m16", "glock", etc and it'd be more explicit and give more control over where you want certain weapon types to be spawned (like if i wanted automatic pistols to have the "glock" spawn type and semi-auto pistols to have the "pistol" spawn type)

having weapon spawn type be a bitflag or table would also be great if you want a weapon to replace different kinds of weapon spawns

schockocraft commented 2 years ago

mhhh if you would go that route i'd suggest keeping the weapon groups but splitting off separate ammo consuming weapons into own groups. Because imo there's actually no reason a mac10 and a Huge shouldn't replace each other.

The weapon groupd could then be

Also regarding my

Then again there should be a way to spawn random primaries/ppistols/grenades

i have had some more thoughts, what if you'd use the weapon entitie's names for that? they get ignored by original ttt, and ttt2 could use these to derive additional information about how to replace these weapons. for example weapons with the name ttt2_replaceable would still be replaced, even on a map that already has ttt_random_weapons

One could also implement further subcategories for addons that add custom sweps to use. for example grenades could be grouped into primarily damaging (Incendiary, etc.) and primarily tactical (Disco, Smoke) grenades. An incendiary grenade with the name ttt2_keep_similar would then only be replaced by grenades that damage the player, aka only incendiary grenades in vanilla ttt2, but with the right addons also frag grenades and HEs. alternatively i'd suggest splitting WEAPON_TYPE_NADE in the first place.

Idk if that would be worth an own suggestion tho, as it is already quite away from the original point.

wgetJane commented 2 years ago

imo there's actually no reason a mac10 and a Huge shouldn't replace each other

mappers typically place the m249 without any ammo nearby

mognify commented 2 years ago

i think there should be 3 options • a bundle to place the weapon + its ammo • place ammo alone • place weapon alone

TimGoll commented 2 years ago

i think there should be 3 options • a bundle to place the weapon + its ammo • place ammo alone • place weapon alone

already possible

TimGoll commented 2 years ago

I will come back to the general issue here, but I'm very busy at the moment

schockocraft commented 2 years ago

i think there should be 3 options • a bundle to place the weapon + its ammo • place ammo alone • place weapon alone

Yea that's already possible. there's a random ammo entity that will not have a weapon spawned, and the random weapon entity also has a configurable value to specify how much ammo it will spawen (which allows 0 aka no ammo aswell)

Also in vanilla TTT just placing specific weapons or ammo can be done however you want. just with TTT2's weapon randomization you get them being replaced aswell.

Unrelated: I thought about it furthert, and wouldn't it be actually possible to add support for a custom keyvalue in weapon entities for ttt2 only? i think vanilla ttt would just ignore it, and there wouldn't be an error or any other issues from that.

Then you could add a keyvalue to the ttt_map_settings for map wide weapon replacement rules, and to the weapon entities themselfes for rules for only that one weapon.