[GUIDE] Mixing Gamemode Logics

Past 72hr Jam Entry [GUIDE] Mixing Gamemode Logics 2022-10-18

  • Hey you! Yes, you! Add images to your downloads, it's free! Use the orange "Manage Download Image" button in the top right.

Past 72hr Jam Entry [GUIDE] Mixing Gamemode Logics 2022-10-18

gamemode mix guide

72hrjam.gif

Recommended for Advanced mappers


----------Introduction----------
Hello there! Have you ever tried to switch between different gamemodes at one map? Well, now you can! Check videos below to see what i'm talking about. I'm changing logic from arena's one in order to make cool hud for minigames in one of mine maps.



----------Basics----------
For now, let's start from basic logic. I'd say something really simple like Player Destruction logic. It's single entity, so it will be easier to work with. Next thing you want to do is to create point_template and type in Template01 keyvalue of point_template targetname of your logic. I'll call mine pd_logic. It will look something like this:
hammerplusplus_bgDQeYP3Gl.png


----------Actual secret reveal----------
If you've tried to spawn logic with point_template before, it didn't worked. Here's when magic happens.

Now, I want you to create separate tf_gamerules entity even if you already have one in your map. I'll call it pd_logic_gamerules.
After this, do the same thing as you did with your pd_logic - Put pd_logic_gamerules into template
hammerplusplus_9YdOaxHRHA.png


After this, create logic_relay. Leave targetname empty. Go to Outputs tab, and make next output:

OnSpawn > pd_logic_gamerules_temp > Addoutput > classname entity_saucer
hammerplusplus_986JapCnIW.png


Short explanation why we do this is that it'll allow us to spawn tf_gamerules. You'll see why soon :)

----------Spawning our logic replacement----------
After we finally made our setup, we can spawn our new logic we want to switch to! I'll use func_button for that. Can be anything really that can trigger ForceSpawn.

Type the following in Outputs tab:

OnPressed > pd_logic_temp > ForceSpawn
OnPressed > pd_logic_gamerules_temp> ForceSpawn [DELAY 0.01/0.05. Your choice]
hammerplusplus_t88WFGkTcL.png


Reason behind why we're spawning gamerules is to actually refresh our HUD and all other junk that's normally not getting refreshed. It must be spawned AFTER gamemode change. That's why we put Delay in here.


----------Checking if it works----------
As you can see, everything works perfectly!

----------(IMPORTANT) Troubleshooting----------

As you probably understood, that's not all and it has one serious problem we have to fix.

#1 Switched logic keeps going through rounds and original doesn't return to it's old state

#2 Spawned through this way tf_gamerules will still exist even after round end (Will cover later. Just continue reading)

Issue #1 Solution

Yeah... That's not good sign... Fortunately to us, there's a solution to this!

You have to to kill gamemode you spawned (Switched to) after round end.
And also you'd have to put your original gamemode in the same weird template scheme. BUT, call it differently of course. To avoid confusion, That's how I made it.

(WARNING: DO NOT CREATE TF_GAMERULES THIS TIME. WE'LL USE THE ONE WE CREATED BEFORE)

hammerplusplus_479628F8MH.png


hammerplusplus_jKh2mZd9Lx.png


hammerplusplus_0S04rEr3S5.png


Now we're prepared to do actual fix.

----------(IMPORTANT) Fixing our issue #1----------
In order to fix this problem where switched gamemode stays after switch of gamemodes, we must our original gamemode by creating (or using one logic_relay for all of those outputs. Just making separate ones for you to understand it better :) ) logic_relay with OnSpawn output

hammerplusplus_HgUgPyspo5.png


(IGNORE THAT ENTITY IS INVALID. DELAY 0.10 IS SET. MUST BE EXACTLY 0.10)

Remember, right now we're spawning ORIGINAL gamemode that we want to be on main map (Initial map load basically)

Don't forgot about spawning gamerules. Explained why in [Spawning our logic replacement] section


As well as spawning original gamemode initially (OnSpawn), we also spawn it ~0.05-1 seconds after round end no matter what was result RED/BLUE victory / STALEMATE.

You can do it by creating/going to your gamerules you've created to handle some map events.
(WARNING: NOT TESTED IF ORIGINAL GAMERULES WILL WORK! USE THE ONES YOU CREATED TO HANDLE THAT. Maybe parse same thing in all gamerules just to be sure. Another way I haven't tested is to actually handle it not through gamerules, but using your logic. For example if it's going to change to Player Destruction (As we do in our guide, but it can be any gamemode, i'd go to Player Destruction logic and using OnBlueFinalePeriodEnd either OnRedFinalePeriodEnd). Of course it's really specific and if you're not advanced mapper, however, I recommend this guide to only advanced mappers, just use the solution I wrote with red text. About detecting Stalemate: Ask TF2Maps discord)

Now, type following in gamerules of last gamemode that got created:

hammerplusplus_060cETqSPj.png


First, we're killing our old gamemodes. Both of them. I've added slight delay just in case because it's source

Second, we're spawning our original gamemode. Again with delay just because of source. Don't forgot about gamerules spawn (The one that happens 0.05 after main logic spawn)

By doing that we pre-spawn actual logic after round end so we confuse our game to think that nothing really happened and it'll just load up normal old gamemode.

Now we can check if everything works


----------(IMPORTANT) Fixing our issue #2----------

(I just forgot about it and adding up later)

In order to fix our issue where tf_gamerules entities go through round, we must do following:

First, we must go to our point_template that spawns tf_gamerules and rename it by adding _ to the start of the name. DO NOT EDIT OUTPUTS. They will show invalid but it's fine. For example, if it's name was pd_logic_gamerules_temp, Rename it to

_pd_logic_gamerules_temp
hammerplusplus_DzEibDwxaz.png


After that, go to Outputs of the same template and create this output:
OnUser1 _pd_logic_gamerules_temp Kill
hammerplusplus_PoNG8BsEQB.png


Next, go to your logic_relay that changes classname of this template above and add following:

edit existing output from

OnSpawn pd_logic_gamerules_temp AddOutput classname entity_saucer
To
OnSpawn _pd_logic_gamerules_temp AddOutput classname entity_saucer

And also add new ones

OnSpawn _pd_logic_gamerules_temp Addoutput targetname pd_logic_gamerules_temp
OnSpawn pd_logic_gamerules_temp FireUser1
OnSpawn pd_logic_gamerules Kill

It must look like this
hammerplusplus_2zwN5NjmVv.png


All of the entities
hammerplusplus_KlvyvyrHTG.png


Basically we're done but I want to cover one more thing

----------Does old gamemode still functioning?----------
Yes. Old gamemode will function. You can just kill it I think. But not for arena. Even killing arena logic wouldn't stop condition of where 1 team dies - round ends. Haven't tested this that much

----------Where I can use this?----------
You can use it on Any gamemode but I see it mostly being used in some kind of Minigames/Halloween map. Or Deathrun, that has a lot of minigames :D

----------Is it possible to spawn (Switch to) more complex gamemodes like PL/PLR/RD?----------

YES! Almost any gamemode is possible. As example, RD is consist out of large amount of entities. All you do is you put all of them in your template.

Gamemodes that I know they won't work:

Training ; Mannpower ; MVM ; PASS time is messy

With PL it's more complex, but still possible. You do same trick as with RD but you also should send Enable to train watcher and Resume the timer in order for it to start (Might be different. DM me if that's the case (Click me, I want to help you!)

----------Special Thanks----------
I want to thank Berke for showing me trick on how to spawn preserved entities, what tf_gamerules basically is. Figured out logic change myself of course :D
  • hammerplusplus_vCJdBbeH4Y.png
    hammerplusplus_vCJdBbeH4Y.png
    22 KB · Views: 76
  • hammerplusplus_VxgVpCyVsa.png
    hammerplusplus_VxgVpCyVsa.png
    29.9 KB · Views: 73
  • 72hrjam.gif
    72hrjam.gif
    25.2 KB · Views: 70

Latest reviews

Didn't even imagine that changing gamemodes like that is possible