How could I create this mod/mutator? Start in Spectator

Search, find and discuss about Mutators!
Marscaleb
Average
Posts: 48
Joined: Tue Jun 07, 2016 6:50 am

How could I create this mod/mutator? Start in Spectator

Post by Marscaleb » Tue Jun 07, 2016 8:45 am

I realized recently a particular mod or mutator that I would want to have in my UT99. However, I have never created anything for UT99 other than maps, and I don't know where to begin.
So, I'm asking for some direction. Could someone point me to a worth-while tutorial?

And on the off-chance that someone has already created the mod I want, I will describe what I want to accomplish. If anyone has already done this or something close to this, please let me know.

I want to make it so that when a match starts (in a network game, not single player,) all the human players start off in spectator mode. (Or the fly-around mode you are in before the match starts, which IIRC is not the same as the actual spectator mode.) The game would spawn in bots to fill the requisite number of of players, and they start playing right away. There will be a prompt for the humans to press fire to join, and if they do, a bot is removed, and they join the game proper. And to possibly take it a step further, if a player dies and remains inactive for too long, a bot will be added until they respawn.
Oh yeah, and I'd also like a mod/mutator that will change the "minimum number of players" to one dynamically set for each map, like just the minimum recommended or the max, or the closest it can reach in between according to a float value. (Though I can't recall off the top of my head which UT's have the recommended player loads set as a distinct value and which ones just display a second line of text, and if UT99 is the latter it likely wouldn't work.)

The reason I want this is because twice now I have had the luxury of hosting a classic UT tournament at a local gaming con, and I have the computers set up for free-play for most of the con. Since it's an environment where people are just freely coming and going, sometimes there is a person on every machine and sometimes there are just a couple. But this means when there are just a few, there are a bunch of players just sitting there, doing nothing. Which isn't very fun for the few people that are playing. But if the match just started with all the humans in spectator mode, then when someone leaves its not a problem. The computer will just be waiting for someone to get in on the fun, and I can have bots running around the map without having to worry about having too many bots in the match.

User avatar
papercoffee
Godlike
Posts: 10133
Joined: Wed Jul 15, 2009 11:36 am
Personal rank: coffee addicted !!!
Location: Cologne, the city with the big cathedral.

Re: How could I create this mod/mutator? Start in Spectator

Post by papercoffee » Tue Jun 07, 2016 10:03 am

This is indeed an interesting idea.
I've never heard of something similar ...but that doesn't count, because my knowledge about server mods isn't that great. :wink:

User avatar
PrinceOfFunky
Godlike
Posts: 1192
Joined: Mon Aug 31, 2015 10:31 pm

Re: How could I create this mod/mutator? Start in Spectator

Post by PrinceOfFunky » Tue Jun 07, 2016 7:32 pm

Marscaleb wrote:I'd also like a mod/mutator that will change the "minimum number of players" to one dynamically set for each map, like just the minimum recommended or the max, or the closest it can reach in between according to a float value.
Don't you think it would be a bit a problem? Let's suppose there are 10 players playing in a map, then the server switches the map with one with maxPlayers on 9, the last player with the slowest connection won't get in to play :/
If you're talking about recomended players amount, it already exists in the map itself, there's an attribute that specifies the recommended players amount.
You should need a map voting system that doesn't let players choose maps, depending on how many players are connected and what's the maximum players amount recommended for every map.
"Your stuff is known to be buggy and unfinished/not properly tested"

User avatar
Barbie
Godlike
Posts: 2390
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: How could I create this mod/mutator? Start in Spectator

Post by Barbie » Tue Jun 07, 2016 7:50 pm

PrinceOfFunky wrote:If you're talking about recomended players amount, it already exists in the map itself, there's an attribute that specifies the recommended players amount.
Do you mean "LevelInfo.IdealPlayerCount"? It's a string variable and often contains terms like "2-4" or even waste - I would not rely on that.
You do not have the required permissions to view the files attached to this post.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett

User avatar
sektor2111
Godlike
Posts: 5871
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: How could I create this mod/mutator? Start in Spectator

Post by sektor2111 » Tue Jun 07, 2016 9:06 pm

And show me where "IdealPlayerCount" is used in game-type controller (any), except ChallengeHUD which doesn't control nothing in game since it is client side.

Marscaleb
Average
Posts: 48
Joined: Tue Jun 07, 2016 6:50 am

Re: How could I create this mod/mutator? Start in Spectator

Post by Marscaleb » Wed Jun 08, 2016 1:52 am

PrinceOfFunky wrote: Don't you think it would be a bit a problem? Let's suppose there are 10 players playing in a map, then the server switches the map with one with maxPlayers on 9, the last player with the slowest connection won't get in to play :/
No, not "max players" but the "min. total players" on the "bots" tab. That variable only adjusts the number of bots in the game (in accordance with the number of human players.)
Basically, adjusting the bots dynamically for each map.
So let's say you want the match the minimum ideal player load. On GM-Turbine that's 4. On DM-Codex that's 2. On DM-Conveyor that's 6.
On each map, the number of bots would change so that there are lots of bots on a big map, and few bots on a small map.
Honestly I have always wondered why this feature hasn't been inside UT already. Dynamically change the number of bots (minimum number of players) for each map to fit the map.
PrinceOfFunky wrote: You should need a map voting system that doesn't let players choose maps, depending on how many players are connected and what's the maximum players amount recommended for every map.
Not really using any map voting system here, just a set playlist.
Barbie wrote:Do you mean "LevelInfo.IdealPlayerCount"? It's a string variable and often contains terms like "2-4" or even waste - I would not rely on that.
Hmmm... You could still convert that into an int, you'd just have to add a couple extra bits of code in case the string doesn't contain numbers where you expect them to be.

So, no such mod already created then? Alright; where do I begin to make it myself?
The only scripting I've done with Unreal is UDK, and I would expect UT99 to be a whole different can of worms.
I'm not even sure if this qualifies as a "mod" or a "mutator."

MrLoathsome
Inhuman
Posts: 958
Joined: Wed Mar 31, 2010 9:02 pm
Personal rank: I am quite rank.
Location: MrLoathsome fell out of the world!

Re: How could I create this mod/mutator? Start in Spectator

Post by MrLoathsome » Wed Jun 08, 2016 2:08 am

There is a mutator called Autofill out there somewhere that attempts to populate a map with
the number of bots that seem to fit well. (Not sure where to find it....)

It is however sort of buggy, and the configuration is so weird it makes little sense to me.

But you can manually specify a number of bots for each map individually, but have to add a line
in its ini file for each map you have on the server.
blarg

User avatar
PrinceOfFunky
Godlike
Posts: 1192
Joined: Mon Aug 31, 2015 10:31 pm

Re: How could I create this mod/mutator? Start in Spectator

Post by PrinceOfFunky » Wed Jun 08, 2016 2:23 am

MrLoathsome wrote:There is a mutator called Autofill out there somewhere that attempts to populate a map with
the number of bots that seem to fit well. (Not sure where to find it....)

It is however sort of buggy, and the configuration is so weird it makes little sense to me.

But you can manually specify a number of bots for each map individually, but have to add a line
in its ini file for each map you have on the server.
viewtopic.php?f=7&t=2573
"Your stuff is known to be buggy and unfinished/not properly tested"

Iacobus_Imrlz
Average
Posts: 63
Joined: Sat Apr 30, 2016 1:41 pm

Re: How could I create this mod/mutator? Start in Spectator

Post by Iacobus_Imrlz » Wed Jun 08, 2016 4:04 pm

Marscaleb wrote:I want to make it so that when a match starts (in a network game, not single player,) all the human players start off in spectator mode. (Or the fly-around mode you are in before the match starts
For toggling between Spectator/Player it is necessary to reconnect. I'd recommend to set all your clients to Spectator before openning the server, to leave alone active players during map transitions and kick idlers according to specified conditions during the match so they respawn as Spectator until the next player comes in
Marscaleb wrote:There will be a prompt for the humans to press fire to join, and if they do, a bot is removed, and they join the game proper. And to possibly take it a step further, if a player dies and remains inactive for too long, a bot will be added until they respawn
XConsole has the toggle function embedded in the console. Take a look on its script to have an idea on how to do it but instead of mapping it to a button you can bind it to a key (let's say ENTER) and add a prompt message in the HUD saying "Press <KEY> to join" while in spectator mode.
Marscaleb wrote:Oh yeah, and I'd also like a mod/mutator that will change the "minimum number of players" to one dynamically set for each map, like just the minimum recommended or the max, or the closest it can reach in between according to a float value. (Though I can't recall off the top of my head which UT's have the recommended player loads set as a distinct value and which ones just display a second line of text, and if UT99 is the latter it likely wouldn't work.)
As an Admin, you can set Min/Max players and number of Bots via Console Commands or via TXT file being called with the EXEC command for each map. There's a handful of Admin tools that automates it.

To remove idlers, there's the kickidleplayers2, that tracks even mouse movement and kick idlers according to a set of predefined customizable criterias. I don't know if it's bug free but it's worth a check. You could complement that with a function that adds a bot whenever it kicks a player and other that kills the last Bot in the scoreboard when a Spectator joins as a player. On the client side, all you need is a function that whenever it gets kicked for being idle, it toggles on Spectator mode and reconnect.

Marscaleb
Average
Posts: 48
Joined: Tue Jun 07, 2016 6:50 am

Re: How could I create this mod/mutator? Start in Spectator

Post by Marscaleb » Fri Jun 10, 2016 10:07 pm

Iacobus_Imrlz wrote: For toggling between Spectator/Player it is necessary to reconnect. I'd recommend to set all your clients to Spectator before openning the server, to leave alone active players during map transitions and kick idlers according to specified conditions during the match so they respawn as Spectator until the next player comes in
Okay, this is good to know. But I'm not sure that I follow your suggestion.
If toggling between Spectator/Player requires a machine to reconnect to the server, what options do I really have? Even if I otherwise set up the game to handle switching between spectator and and player, it would requiring setting up the system to constantly disconnect and re-connect to the server. That sounds like a huge headache and would slow down the game a lot.

So now I'm thinking I would need to establish some kind of "fake spectator" system. Where players are connected to the server as players, but they just don't spawn until the player calls for it, and bots jump in for them when they take too long to spawn, and drop out when the player comes in. Possibly that could easily be applied to taking too long to respawn as well. Maybe the fake spawn could just be players being "dead" when they start the match, but with no deaths counted against them.

Although, I would prefer to keep the ability to fly around the map and look at stuff like you can before the match starts, but I guess I'll take what I can get.

Iacobus_Imrlz
Average
Posts: 63
Joined: Sat Apr 30, 2016 1:41 pm

Re: How could I create this mod/mutator? Start in Spectator

Post by Iacobus_Imrlz » Sat Jun 11, 2016 1:31 am

Marscaleb wrote:it would requiring setting up the system to constantly disconnect and re-connect to the server. That sounds like a huge headache and would slow down the game a lot
Not really. I said RECONNECT because that's the command you use to toggle between Player/Spectator. Unsing 'RECONNECT' doesn't take the same time and loading that it does when you first connect to a server. I think all it does is to reset your settings and put you back right in. The problem is that TPlayer and CHSpectator are different classes under PlayerPawn with many unshared functions (it would be a no brainer if spectator was just a function within TPlayer), so there's no smooth transition between states while in game.

It's unfortunate that the game doesn't have the function built in already. If you join a server in spectator mode just to check and then decide to join in, you have to bring the player setup screen, uncheck "play as a spectator" and then type RECONNECT on the console. What you can do is to create a TXT with the commands and then bind it to a key, but you won't have the prompt message blinking on screen without coding.

What I'm suggesting you is to add a script on the client side that automates this whenever it gets kicked (not really kicked, just have a function that triggers this on the client) by a specific kickidler command in your server. This way you can keep all your clients clycling through maps as Spectator and when someobody comes in to play, all they have to do is press a button and in 3 secs they are ready for action. That way you don't have to mess with PlayerPawn, ReplicationInfo or GameInfo, all you need is a little mutator that calls preexistent functions and it will work for all game modes.
Marscaleb wrote:So now I'm thinking I would need to establish some kind of "fake spectator" system. Where players are connected to the server as players, but they just don't spawn until the player calls for it, and bots jump in for them when they take too long to spawn, and drop out when the player comes in. Possibly that could easily be applied to taking too long to respawn as well. Maybe the fake spawn could just be players being "dead" when they start the match, but with no deaths counted against them
I'd initially suggest you to create a new hybrid pawn in between, but that just means more coding and them you'll also have to mess with ReplicationInfo as well I'd imagine. You'd also have to remove idlers from the scoreboard and then put back when someone else comes in. You may end up having to create a whole new Game mode just to be able to do that. All that trouble just to save 3 secs of loading on the client side when they have to reset.

I think you can unlock the ability to fly while dead as a player, but if someone wants to just sit and watch the match, it would be cool to keep the spectator function of toggling between players pov as well, and if they decide to join, it would be better if their scores were reset so they can keep track of their own frags.

MrLoathsome
Inhuman
Posts: 958
Joined: Wed Mar 31, 2010 9:02 pm
Personal rank: I am quite rank.
Location: MrLoathsome fell out of the world!

Re: How could I create this mod/mutator? Start in Spectator

Post by MrLoathsome » Sun Jun 12, 2016 3:38 am

Those are some excellent suggestions.

For some reason this thread makes me think of the default CityIntro.unr map.

If you could track down how the fly thru on that map works, and perhaps adapt it so it tracks the
whole Pathnode or whatever list(s) on whatever map you are running, that might cool.
I am pretty sure the path that takes is just hardcoded some way or another....

You would probably have to add code there so the thing would start at a random SpawnPoint, and then do a
search for the next nearest Pathnode, and then repeat the search for the next closest and continue in that way.
(I would not assume Mappers are adding these Pathnodes or other locations in any sort of predictable way....)

Then when a player presses fire, have them join the game normally.

I have noticed that you can tap the spacebar while the cityintro is running, and you will drop out of the
fly thru routine, and into the map. You can run around, but that is about it.
Due to the lack of a SpawnPoint or any other pathing/items etc.... Which is also why none of my mutators, or probably any others, will spawn anything in that map.
Doing something about this has been on my list of things to look into for a while, but not near the top. (It is a kickass looking map. Would be killer for DM or DOM I think.)

Half the code you want is in there already. I think. I hate UED and don't know nothing about no maps.

*Edit: Write it so that it starts in Fly Thru mode. Then if there is any input activity other than Fire, have it switch to Spectator/Ghost mode.
Fire still has them join the game of course.
blarg

Marscaleb
Average
Posts: 48
Joined: Tue Jun 07, 2016 6:50 am

Re: How could I create this mod/mutator? Start in Spectator

Post by Marscaleb » Mon Jun 13, 2016 7:24 am

Iacobus_Imrlz wrote: It's unfortunate that the game doesn't have the function built in already. If you join a server in spectator mode just to check and then decide to join in, you have to bring the player setup screen, uncheck "play as a spectator" and then type RECONNECT on the console. What you can do is to create a TXT with the commands and then bind it to a key, but you won't have the prompt message blinking on screen without coding.
I've just done some experiments with this to see how smooth it is.
It still drops the player for a half second or so, which I guess isn't *too* bad; I guess it would be better that completely rebuilding the gametype. But still, it's rather annoying when you'd have to do that at the start of every match. Just jumping in on an empty computer would be fine, but when you stick around and you have to reconnect to the server twice, that would be annoying.
Also, I found that if everyone on the server is a spectator, the game will never spawn any bots, and just perpetually waits for players to join. Also, if the host reconnects, it seems to reset the whole match. Although I suppose I could solve that by running a dedicated server. (Probably better if I ran a dedicated server anyway.)

...I guess though, I could drop the idea of having them start in spectator mode, and just drop players into spectator mode if they are in idle too long.
Then if someone leaves after a match ends, there would be a player just sitting around doing nothing for a minute or two, but he would then be dropped and replaced with a bot until someone comes by. Theoretically, I could even have the match start with the idle counter near the limit, so at the start of the match they are dropped if they are idle for just 20 seconds.
This would also solve the problem of no game playing if everyone is in spectator mode, because that would only happen if there was literally no one playing, in which case it's not a problem.

This sounds like it would work well.
I am just left with one question. Does UT come packaged with a way to tell if someone is in idle?

JackGriffin
Godlike
Posts: 3767
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: How could I create this mod/mutator? Start in Spectator

Post by JackGriffin » Mon Jun 13, 2016 5:32 pm

I've written several idle mutators. Here's a simple but really good one:
kickidle.zip
It checks for changes in rotation or if the player has fired. Stop doing both for the 'KickTime' and you get punted. Super simple, very useful.

Starting a game with spectators only just won't happen. The engine needs at least one live player (or bot) to launch the map gametype correctly. If this were me I'd set the 'spectators' to some obscure team number then have a mutator apply changes to members of that team (stop interactions, set physics to fly, etc). When you are ready for them then sort then to the correct team by respawn. No reconnecting required.
You do not have the required permissions to view the files attached to this post.
So long, and thanks for all the fish

Marscaleb
Average
Posts: 48
Joined: Tue Jun 07, 2016 6:50 am

Re: How could I create this mod/mutator? Start in Spectator

Post by Marscaleb » Mon Jun 13, 2016 8:59 pm

JackGriffin wrote:I've written several idle mutators. Here's a simple but really good one:
kickidle.zip
It checks for changes in rotation or if the player has fired. Stop doing both for the 'KickTime' and you get punted. Super simple, very useful.
Nice! I'll take a look at it when I get the time.
JackGriffin wrote: Starting a game with spectators only just won't happen. The engine needs at least one live player (or bot) to launch the map gametype correctly. If this were me I'd set the 'spectators' to some obscure team number then have a mutator apply changes to members of that team (stop interactions, set physics to fly, etc). When you are ready for them then sort then to the correct team by respawn. No reconnecting required.
If I'm just bumping them to spectators when they idle, (instead of starting the match as spectators,) then I won't need to worry about not starting the game.

Dropping them in some obscure team sounds like a nice idea, but would only work in team games. Most of the time we'll be playing FFA.