Garry's Mod

Garry's Mod

[TTT2] Mimic and Doppelganger [ROLE]
Cpt.Haxray 28 Dec, 2020 @ 7:40pm
Doppleganger Bug Reports with other role interactions
Hey! saw your addon and decided to test it out with some of the roles we're currently using on our server, and ran into a few bugs/weird interactions. I figured i'll share them here incase they're something you can/are willing to fix.

Infected: If the Doppleganger steals the Infected's Role, any person who respawn as Infected after the Doppleganger kills them will still be on the original Infected Team, and not the Doppleganger team, resulting in the round never ending unless the Doppleganger then kills all of his infected a second time. Notably, the Doppleganger is still treated as the infected for other interactions, so a single infected killing him results in all infected dying, despite not being on the same team.

Mesermist: Upon using the Mesermist Defib, the revived player is still on the T team, not the Doppler Team.

Jester: They do not copy the Jester's winstate upon stealing their role. This means they now become unable to damage anyone, and cannot win or do anything else upon being killed. (Could probably use an exception convar similar to the Marker so they simply become an Amnesiac if they try to steal the Jester's role as i imagine more problems would ensure due to the Jester's "Win upon dying" winstate).
< >
Showing 1-10 of 10 comments
Cpt.Haxray 28 Dec, 2020 @ 7:49pm 
One extra one:

Beacon: Not necessarily a bug, but definitely a feel bad interaction. If they kill an innocent after stealing the Beacon role, they are swapped back to the innocent team alongside turning into an innocent.
Wasted  [developer] 29 Dec, 2020 @ 8:08pm 
Saw your bug reports on GitHub too so thanks. Unfortunately, for most of these it's not entirely something I can address, since the issues are rooted in how those roles are written.

I'll push a change to Mesmerist later since it's a role I developed.

I'll also update to add unique handling for these "issue" roles. If you have ideas for how you think they should be handled, suggestions are welcome.

I also should post a guide in these discussions, but if you know Lua, I've written this role so that there is a hook for editing the Mimic/Doppelganger's role info before they steal/change roles. So it's possible for server owners/addon writers to create their own special handling without editing the role's code.
Cpt.Haxray 29 Dec, 2020 @ 8:42pm 
Thanks for the reply! Sorry about the doublepost, i realised the day after posting this the github pages would likely be more organised to write. I don't really know lua, but our current server manager does, so i'll let them know about the hook and let them know about the guide if/when it is posted.

As for ideas for how to handle the exception roles, Jester as i mentioned in this post would ideally simply turn the Doppelganger/Mimic into an Amnesiac instead. For Beacon it would make the most sense to be Innocent(ableit still as Doppel team), and for Infected it could be Unknown.
Wasted  [developer] 30 Dec, 2020 @ 12:09pm 
I've added these special cases to the Role and updated my Mesmerist role to include an option which makes the Thrall inherit the Mesmerist's team, so these should be at least somewhat fixed.
Cpt.Haxray 30 Dec, 2020 @ 12:15pm 
Originally posted by Wasted:
I've added these special cases to the Role and updated my Mesmerist role to include an option which makes the Thrall inherit the Mesmerist's team, so these should be at least somewhat fixed.

Thank you!
Ember The Flareon 26 Sep, 2021 @ 1:12am 
I am having issues with my role, the Alchemist, and I wanted your opinion on how I may fix things.

Alchemist has 2 timers. The main one on the server-side is set to give an equipment item after a certain amount of time. The other is client-side and simply exists as a way for the HUD element to know when the next potion is being made and how many are left. They are set up and ran at the same time.

The problem is that when a Mimic/Doppelganger copies an Alchemist, it seems that only the client-side timer that operates the HUD element starts up, meaning that they will never actually make a potion.

Would you have any idea how I may go about fixing this?
Wasted  [developer] 26 Sep, 2021 @ 6:19am 
Originally posted by Ember The Flareon:
I am having issues with my role, the Alchemist, and I wanted your opinion on how I may fix things.

Alchemist has 2 timers. The main one on the server-side is set to give an equipment item after a certain amount of time. The other is client-side and simply exists as a way for the HUD element to know when the next potion is being made and how many are left. They are set up and ran at the same time.

The problem is that when a Mimic/Doppelganger copies an Alchemist, it seems that only the client-side timer that operates the HUD element starts up, meaning that they will never actually make a potion.

Would you have any idea how I may go about fixing this?

I would create a fallback using either the ROLE:GiveRoleLoadout function or the Role Change hook to start your timers.

Here is an example of the GiveRoleLoadout from Tim

https://github.com/TTT-2/ttt2-role_pha/blob/19734d15685e6fe21d24d0c04c082462f7a7205f/lua/terrortown/entities/roles/pharaoh/shared.lua#L40

And here is an example where I use the role change hook for Doppelganger's various role handlings.

https://github.com/ZacharyHinds/ttt2-role-dop/blob/master/lua/terrortown/autorun/server/sv_spec_dop_roles.lua

Ember The Flareon 26 Sep, 2021 @ 6:39pm 
I use ROLE:GiveRoleLoadout to start the timer in the first place, though.

That function calls another function to handle the timer and set up the HUD at the same time.
https://github.com/EmberTheFlareon/ttt2-role-alch/blob/638847fd0165539367fa15212d40906b73bf2a5e/lua/terrortown/entities/roles/alchemist/shared.lua#L52

See? It sets up the potion timer's function along with sending a net message to the client to start the HUD timer.
That's why I am so confused as to why the HUD timer and element start up but the potion timer doesn't. The HUD timer even correctly pulls the ConVars for how long it will take and how many potions left.

I've looked over your role handler so many times and tried so many things to get that first timer working.
Wasted  [developer] 27 Sep, 2021 @ 7:33am 
Okay, I see what you've got going on. I'm not sure exactly, but have you tested if there is a similar problem any time a second Alchemist appears later in a round? Just want to know if it is something I've done on my side.

The following is what my cursory look-over spots which could be the issue. Because what it looks like to me, is that there can only be a single Alchemist timer at a time because there can only be one timer

Looking over your code, it seems to me that there can only be a single Alchemist timer running because each individual timer needs a unique string identifier. Currently, GiveMeAPotion(ply) always tries to create a timer with the identifier "MakePotion".

If I am right and this is the issue, what you would need to do is to create a unique identifier per player when they become an alchemist.
Last edited by Wasted; 27 Sep, 2021 @ 7:34am
Ember The Flareon 27 Sep, 2021 @ 8:48am 
Oh my gosh, you're absolutely right.
I don't have anything that handles individual timers for multiple Alchemists. That explains everything!

Looking at Imposter, the way I'd set it up is timer.Create("MakePotion" .. ply:SteamID64", timetomake ect ect....

That makes perfect sense. Right now, it sets the timer up for the role and not the player. That's also probably why the client-side timer functions just fine. It's already assigned to the client!

Thank you so much! I'll get the fix out as soon as I can.
< >
Showing 1-10 of 10 comments
Per page: 1530 50