Scags / TF2-Jailbreak-Redux

A modified, rewritten version of the original TF2Jail. https://forums.alliedmods.net/showthread.php?p=2626905
GNU General Public License v3.0
23 stars 8 forks source link

Version 2.0 #106

Open Scags opened 4 years ago

Scags commented 4 years ago

Alright, it's time I picked this back up. There's a lot of things that I want to rework and redo. For one, I want to redo how last requests are made.

I'm thinking that the core plugin TF2Jail_Redux can be the engine to build last requests/sub-plugins with. That way, coders won't have to worry about mucking through code to add an LR.

I want the main plugin to be the engine that handles the game mode and its execution. Subplugins (mainly LRs) would be able to pick and choose what to do and when.

Secondly, config support for LRs. I'll make it optional; pull some method how to do that later.

Scags commented 4 years ago

I've got a nice sketch down so far, but it completely changes how forwards are done internally. Essentially, there won't be forwards. I'm adopting and adapting what Boss Fight Fortress does. External implementation will be almost the same, but internally, instead of forwards, I will manually go through an list of function ptrs. Pseudocode below:

public void Freedays_Init()
{
    // New method for creating last requests
    g_FreedaySelf = new LastRequest("Freeday for Yourself");
    // Only fires when it is *this* last request index
    g_FreedaySelf.AddHook(OnLRPicked, FreedaySelf_OnLRPicked);
    g_FreedaySelf.AddHook(OnRoundStartPlayer2, Freeday_OnRoundStartPlayer);
    g_FreedaySelf.AddHook(OnLRDenied, Freeday_OnLRDenied);

    g_FreedayOther = new LastRequest("Freeday for Others");
    g_FreedayOther.AddHook(OnLRPicked, FreedayOther_OnLRPicked);
    g_FreedayOther.AddHook(OnRoundStartPlayer2, Freeday_OnRoundStartPlayer);
    g_FreedayOther.AddHook(OnLRDenied, Freeday_OnLRDenied);

    g_FreedayAll = new LastRequest("Freeday for All");
    g_FreedayAll.AddHook(OnRoundStart2, FreedayAll_OnRoundStart);

    // Global hooking, same as before
    JB_Hook(OnTakeDamage, Freeday_OnTakeDamage);
    JB_Hook(OnCheckLivingPlayers, Freeday_OnCheckLivingPlayers);
    JB_Hook(OnLRPicked, Freeday_OnLRPicked);
    JB_Hook(OnRoundStart2, Freeday_OnRoundStart);
    JB_Hook(OnPlayerSpawned, Freeday_OnPlayerSpawned);
    JB_Hook(OnPlayerDeath, Freeday_OnPlayerDeath);
}

Each last request handle will either be a KV or a StringMap, I haven't quite decided yet. KV feels nice because it'll need to cache the structure anyways for config support.

The main struggle is probably going to be managing all the function pointers. TF2JR might not have forwards anymore (minus the bcompat legacy forwards), so I'll be running through a list of them and checking if they're a valid func.

It'll probably fire the global (JB_Hook) functions first, then the ones that pertain to the certain last request that's happening (or involved).

Did I mention that this will absolutely destroy backwards compatibility?

Scags commented 4 years ago

Another thing, I'm thinking of breaking the main methodmaps down into singletons.

There's jailbase.sp, jailgamemode.sp, and their counterparts in the include (which im splitting into multiple files).

Instead of having counterparts, just keep everything as its own methodmap in the include and have TF2Jail_Redux call its own natives. I might as well add all these fricking natives to their own file too.

EDIT: I half-gave-up, half-did this. It's kinda ugly but it feels better doing it the way I did. Essentially, the internal methodmaps (in the main plugin) inherit from the ones in the include, and the natives there call into the inherited functions. Doesn't really change anything in the end.

Scags commented 4 years ago

Implement LR importing and exporting to/from the config file. This way, sub-plugins and LRs can generate a config entry similar to how plugins create config through ConVars. This config will be imported into the main lastrequest.cfg.

MrPanica commented 4 years ago

Hi, great that you are back to working with the plugin! I would like to suggest some changes to the new version. I'm on version V1.4.0 right now, so some points might already have been added. So:

  1. Refreshing rebel timer. Just update the timer every time a prisoner rebels again and his last riot has not yet disappeared.
  2. Remove repeat and marker conflict. When the prisoner asks for a repeat, and the commander has set a marker, the marker disappears. It seems the annotation has an ID that should not be repeated.
  3. Add a command to the warden to restore health for red.
  4. Add a variable to adjust the damage in the back of the warden. Here it is better to do damage from maximum health, for example 50%, or you can add a one-time or recovering shield to protect against a blow to the back.
  5. When PvP is turned on from warden, only the Reds can fight. This is logical, because usually the red ones fight, but you can add a variable, nevertheless)
  6. Variable, responsible for immortality or MB FreeDay during the choice of LR.
  7. Embed protection against a spawn bug in the middle of a round, something like this: https://forums.alliedmods.net/showthread.php?p=2653764

Sorry for my English

Scags commented 4 years ago

@MrPanica I like these ideas and I should be able to do all of them. ->5 is a bit tricky but I'll give it a shot.

Scags commented 4 years ago

Alright, finished a large chunk of what I wanted to do. I'll call this a beta release for now. Since this fucking obliterates backwards compatibility, I've put it to a separate branch which will eventually become the main branch of the repo. The master branch will remain untouched for legacy purposes.

Everything that is currently included within this repo should work out of the box (give or take a few bugs that I need to squash). But like I said, backwards compatibility is completely destroyed. God save the server owners that paid for custom last requests.

Next I'll bounce around between updating the wiki and knocking out some of the requests and issues for the next version.

MrPanica commented 4 years ago

There is 1 more bug. I was informed about him recently. It allows you to spawn during the round for team 0 (TFTeam_Unassigned) Video: https://www.youtube.com/watch?v=abMLyG_Jj7I

You must go to the server and wait 1 round. In this case, you should not choose a team. After the start of the next round, you should select the class through the console (joinclass)

This is complicated by the fact that when spawning with the help of this bug, you can fall through the map and run under the textures!

I solved this with a simple spawn check:

    if(GetEntProp(iClient, Prop_Send, "m_iTeamNum") == 0)
    {
        ForcePlayerSuicide(iClient);
    }

For some reason, GetClientTeam did not help)

MrPanica commented 4 years ago

And you used my weapon search plugin. Nice!

Scags commented 4 years ago

I'll see what I can do about that bug!

Scags commented 4 years ago
Scags commented 4 years ago
Stropyt commented 4 years ago

Hey, I updated to the newest develop release yesterday and I've ran into some issues. I'll try to keep it brief and simple.

  1. After the warday and/or class warfare round has finished, reds have ammo one round right after and they continue to spawn on the wd location for the rest of the map. This does not occur after vsh or ph round. I haven't changed anything except the q announce messages.

  2. The timer reportedly runs faster than it should, for example 3s are subtracted instead of 1s, etc. //EDIT: sometimes the timer doesn't stop when the rounds end, continues until the start of the next round, times get set to normal time and thus it is at double speed, etc. //EDIT2: So it appears sometimes the plugin doesn't even know the round ended, meaning when the timer was going at 2x speed and you tried to give lr, it would say it has already been given. Might be related to 1. as well.

  3. Getting this in error logs all day:

L 05/12/2020 - 18:08:25: [SM] Blaming: TF2Jail_Redux.smx L 05/12/2020 - 18:08:25: [SM] Call stack trace: L 05/12/2020 - 18:08:25: [SM] [0] KillTimer L 05/12/2020 - 18:08:25: [SM] [1] Line 1341, TF2JailRedux/stocks.inc::KillTimerSafe L 05/12/2020 - 18:08:25: [SM] [2] Line 745, TF2JailRedux/jailbase.sp::JailFighter.MarkRebel L 05/12/2020 - 18:08:25: [SM] [3] Line 329, TF2JailRedux/jailhandler.sp::ManageOnTakeDamage L 05/12/2020 - 18:08:25: [SM] [4] Line 857, TF2Jail_Redux::OnPlayerTakeDamage L 05/12/2020 - 18:08:25: [SM] Exception reported: Invalid timer handle 917d1049 (error 3) L 05/12/2020 - 18:08:25: [SM] Blaming: TF2Jail_Redux.smx L 05/12/2020 - 18:08:25: [SM] Call stack trace: L 05/12/2020 - 18:08:25: [SM] [0] KillTimer L 05/12/2020 - 18:08:25: [SM] [1] Line 1341, TF2JailRedux/stocks.inc::KillTimerSafe L 05/12/2020 - 18:08:25: [SM] [2] Line 813, TF2JailRedux/jailbase.sp::JailFighter.ClearRebel L 05/12/2020 - 18:08:25: [SM] [3] Line 347, TF2JailRedux/jailevents.sp::OnRoundEnded L 05/12/2020 - 18:19:15: [SM] Exception reported: Handle 6d88106d is invalid (error 3) L 05/12/2020 - 18:19:15: [SM] Blaming: TF2Jail_Redux.smx L 05/12/2020 - 18:19:15: [SM] Call stack trace: L 05/12/2020 - 18:19:15: [SM] [0] CloseHandle L 05/12/2020 - 18:19:15: [SM] [1] Line 1342, TF2JailRedux/stocks.inc::KillTimerSafe L 05/12/2020 - 18:19:15: [SM] [2] Line 813, TF2JailRedux/jailbase.sp::JailFighter.ClearRebel L 05/12/2020 - 18:19:15: [SM] [3] Line 1517, TF2Jail_Redux::RemoveRebel L 05/12/2020 - 18:19:15: [SM] [5] Call_Finish L 05/12/2020 - 18:19:15: [SM] [6] Line 442, TF2JailRedux/stocks.inc::DoThink L 05/12/2020 - 18:19:38: [SM] Exception reported: Invalid timer handle 6d88106d (error 1) L 05/12/2020 - 18:19:38: [SM] Blaming: TF2Jail_Redux.smx L 05/12/2020 - 18:19:38: [SM] Call stack trace: L 05/12/2020 - 18:19:38: [SM] [0] KillTimer L 05/12/2020 - 18:19:38: [SM] [1] Line 1341, TF2JailRedux/stocks.inc::KillTimerSafe L 05/12/2020 - 18:19:38: [SM] [2] Line 745, TF2JailRedux/jailbase.sp::JailFighter.MarkRebel L 05/12/2020 - 18:19:38: [SM] [3] Line 329, TF2JailRedux/jailhandler.sp::ManageOnTakeDamage L 05/12/2020 - 18:19:38: [SM] [4] Line 857, TF2Jail_Redux::OnPlayerTakeDamage L 05/12/2020 - 18:19:40: [SM] Exception reported: Invalid timer handle 6d88106d (error 1) L 05/12/2020 - 18:19:40: [SM] Blaming: TF2Jail_Redux.smx L 05/12/2020 - 18:19:40: [SM] Call stack trace: L 05/12/2020 - 18:19:40: [SM] [0] KillTimer L 05/12/2020 - 18:19:40: [SM] [1] Line 1341, TF2JailRedux/stocks.inc::KillTimerSafe L 05/12/2020 - 18:19:40: [SM] [2] Line 745, TF2JailRedux/jailbase.sp::JailFighter.MarkRebel L 05/12/2020 - 18:19:40: [SM] [3] Line 329, TF2JailRedux/jailhandler.sp::ManageOnTakeDamage L 05/12/2020 - 18:19:40: [SM] [4] Line 857, TF2Jail_Redux::OnPlayerTakeDamage

  1. I tried to set lifetime of the FD beam to 0, the whole map was covered in red (as it didn't despawn at all) and it would stay that way until the map change. I would suggest adding "-1" option to the cvar, which would disable the trail entirely, as someone might not want the trail at all.

That's all for now. I've had some issues (server crashing all the time) with the VSH LR previously, but it seems to be working fine so far, no crashes yet.

Thank you for supporting the plugin.

Scags commented 4 years ago

@Stropyt Hi thanks for letting me know about this stuff.

For 1 I've been looking for a while and I'm not sure how that's happening, especially since it doesn't happen with VSH and PH. I'll take a closer look this weekend. EDIT: I think it has to do with the "RegenerateReds" config entry, I'll see what I can do.

2 and 3 are related. The plugin errors when the round ends (because of the rebel status issue), and this prevents the plugin from understanding that the round is ending, thus allowing the timer to continue indefinitely and create another instance of the timer next round.

For 4, setting it to 0 for a permanent effect is slightly unintentional but I can add a -1 option for it no problem.

Thanks again for catching these, I'll see if I can get to them this weekend. In the meantime, you can disable the rebel cvar which should prevent those errors.

Stropyt commented 4 years ago

Hello, ran into an issue with VSH LR - server crashes are back, but they are far less frequent than they used to be. Happened 4 times so far. As you recommended it, I installed accelerator last time we were discussing this, here's crash ID of the most recent one: MTJN-3VUK-6JEE. From what I've seen it happens right after the round ends, while the Red won everytime this happened. Hopefully it will help you figure out what is happening.

Scags commented 4 years ago

@Stropyt Crashes should be fixed now. One had to do with engineer PDAs. Another had to do with the boss healthbar which never even worked properly to begin with. Let me know how it goes.

MrPanica commented 4 years ago

Hey. I wanted to ask, how long is it planned to develop a new version? I would like to reconfigure my servers to it. In my version there are many good things, for example, those that I suggested to you here. But they are made, as it were, not very high quality.

Scags commented 4 years ago

It's basically ready to use right now. There is one more thing I want to add, and once that is stable, I will remove the "Beta" tag and publish a release.