Creating rounds for team games...

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Dexter13

The Coding Machine
Dec 18, 2001
111
0
0
Visit site
How can I create a round for team games, so that when a team is eliminated a new round is started on the same level rather than a new game on a new level?

And also, how can I make it so that the game keeps track of whether one team is eliminated or not?

Can anyone please help?
 

Guy ON Drugs

He who knows but doesn't know he knows
Jan 26, 2002
24
0
0
37
Visit site
if you have tactical ops you can use some of the code from there about the rounds and stuff all thought some of it might be complicated(because there are so many files in each .u file )
 

RegularX

Master of Dagoth Lies
Feb 2, 2000
1,215
0
0
Chicago, IL
Went all around this last night. Very, very annoying. Essentially you have two methods:

1) The "Assault" method ... which restarts the game swaps the teams. It does this by saving the game info with SaveConfig() and then asking the server to restart the level.

2)Never actually end the game ... don't call EndGame at all and have a function which resets the player's state and replicationinfo. Counts down the rounds and when their over, it goes to EndGame instead.



I had a lot of problems with both, actually - probably just something really dumb I'm doing. My problem with #1 is that is required the server to reload (Did Assault do that? I don't remember), which was really the reason I wanted the rounds in the first place.

So I'm probably going with the second method ... but it was flaky as all get out. But that's mostly because my gametype does a lot of funky things to the map. I'm going to try and get it fixed up tonight, I'll let you know how it goes.



rgx
 

RegularX

Master of Dagoth Lies
Feb 2, 2000
1,215
0
0
Chicago, IL
Originally posted by Dexter13
Thanks, let me know how you get on


Bah-ang. Gots it working. In the end, it's pretty simple. I'll give you the rundown, and if you want code ask - I'll post it, send it, or you can download the latest Freehold build and rip open the Containment class (not up when I'm writing this - should be by Fri).


Essentially what you are doing is the opposite of trapping players into a spectating state, you reset them all to their original state.

The first thing you need to do is figure out when your round is over. For me, it's either when they complete the map objectives or everyone is dead. Essentially I used the same CheckEndGame() function I had before, but whenever I call EndGame() itself, I first check a global int RoundsLeft to see if I should just reset the level instead of ending the match.

If I'm resetting the level, I go to my ResetGameRound function which does the following:

1) Resets my custom game classes/information. This is some serious level tweaking the gametype does and probably isn't necessary for most mods (and, oddly, the part that isn't really working yet :) ).

2) Goes through the PawnList for the level. For each player it-

-resets their state to either PlayerWaking (PlayerPawns) or Startup for bots.
-strips their current inventory
-returns things like collision, and viewtarget, etc. to normal playing values. If you go to the GameInfo's version of RestartPlayer, you'll find a lot of it ... if you go through the various states of Pawn you can find the rest. This is really the most confusing part, because you are doing something kinda weird for the game - restarting a player that doesnt need restarting...
-reset their replicationinfo to the original values

3) With that, they get their new StartLocation and the round has restarted.


Hope this helps.


rgx
 

RegularX

Master of Dagoth Lies
Feb 2, 2000
1,215
0
0
Chicago, IL
no problemo, but I probably wont get a chance to today, or maybe tommorrow. If you want it sooner download -


http://www.webcosa.com/public/Freehold027.umod

and feel free to drift through the code. Like I said, it's the Containment class, and between the CheckEndGame() and ResetGameRound() functions it makes good sense.

I was tweaking it some more last night and the round code is actually running really well. Note - havent tested it as netcode yet, and the messaging is horrible.

My map restart was driving me crazy though. I have spawned actors moving their location without my permission....


Bah. But either way I'll post up the ResetGameRound() function when I get a chance.



rgx
 

RegularX

Master of Dagoth Lies
Feb 2, 2000
1,215
0
0
Chicago, IL
OK - here is the actual player restart part of it:

Code:
 for ( PawnLink=Level.PawnList; PawnLink!=None; PawnLink=PawnLink.nextPawn )
       {
          if ( PlayerPawn(PawnLink) != None )
          {
               PlayerPawn(PawnLink).bFrozen=False;
               PlayerPawn(PawnLink).ViewSelf();
               PawnLink.bBehindView = False;
               }
               Level.Game.DiscardInventory(PawnLink);
               PawnLink.SetDefaultDisplayProperties();
               PawnLink.PlayerReplicationInfo.bWaitingPlayer = false;
               PawnLink.PlayerReplicationInfo.bIsSpectator = false;
               PawnLink.PlayerRestartState = PawnLink.default.PlayerRestartState;
               if (ContainmentPRI(PawnLink.PlayerReplicationInfo) != None )
    {             //Killer is a player
     ContainmentPRI(PawnLink.PlayerReplicationInfo).Lives = 2;
     PawnLink.GotoState('PlayerWaking');
    }
    else if (ContainmentBRI(PawnLink.PlayerReplicationInfo) != None)
    {             //Killer is a bot
     ContainmentBRI(PawnLink.PlayerReplicationInfo).Lives = 2;
     PawnLink.GotoState('StartUp');
     }

     startSpot = FindPlayerStart(PawnLink, 255);
     if( startSpot == None )
     {
          log(" Player start not found!!!");
     }
     foundStart = PawnLink.SetLocation(startSpot.Location);
     if( foundStart )
     {
          startSpot.PlayTeleportEffect(PawnLink, true);
          PawnLink.SetRotation(startSpot.Rotation);
          PawnLink.ViewRotation = PawnLink.Rotation;
          PawnLink.Acceleration = vect(0,0,0);
          PawnLink.Velocity = vect(0,0,0);
          PawnLink.Health = PawnLink.Default.Health;
          PawnLink.SetCollision( true, true, true );
          PawnLink.ClientSetLocation( startSpot.Location, startSpot.Rotation );
          PawnLink.bHidden = false;
          PawnLink.DamageScaling = PawnLink.Default.DamageScaling;
          PawnLink.SoundDampening = PawnLink.Default.SoundDampening;
          AddDefaultInventory(PawnLink);
     }
     else
          log(startspot$" Player start not useable!!!");
     //     }

     }


*winces at people looking at me ugly code*

I've removed the gametype specific stuff as well. ContainmentPRI and BRI are ReplicationInfo Subclasses (obviously). Unlike LMS - i stored their number of lives here, so that I could have score be a seperate number.


rgx
 

RegularX

Master of Dagoth Lies
Feb 2, 2000
1,215
0
0
Chicago, IL
2 bugs - I forgot to reset the groundspeed and jumpz (which I noticed due to all the big jumps my bots were making)

Also, "PlayerWaking" may not be the best state, as there is a small pause before the player has control. Any suggestions for a better state are welcome.


rgx
 

butto

Red Orchestra Coder
Create a state where the player can't move and figure out the bitch-work to make it work propertly on the client. I can't distribute my source for this at the moment, but Tactical Ops and other mods might give you a clue.
 

RegularX

Master of Dagoth Lies
Feb 2, 2000
1,215
0
0
Chicago, IL
Originally posted by butto
Create a state where the player can't move and figure out the bitch-work to make it work propertly on the client. I can't distribute my source for this at the moment, but Tactical Ops and other mods might give you a clue.

Why do we want a state where the player can't move?
 

RegularX

Master of Dagoth Lies
Feb 2, 2000
1,215
0
0
Chicago, IL
Oddly, placing a pause in between the CheckEndGame and ResetGameRound and using 'Dying' as the state seems to work the best, but you'll have to play around with the code to get it to interact right with your own (HUD, Round info display, etc).

Also, in another post I recommended placing the CheckEndGame in the timer - which works fine, but you need to place a check for the ElapsedTime to be greater than 1 so that it works online.


rgx
 

RegularX

Master of Dagoth Lies
Feb 2, 2000
1,215
0
0
Chicago, IL
The only way I know to really ensure how something is working online is, well, to actually try it online. Fortunately XP seems to allow you to run two instances of UT at the same time without any tweaking, so running a server locally isn't hard ... or I throw onto the LAN.

On 98/NT I think you have to run another program or tweak something to get it to let you do that. I can't remember how it goes, maybe someone else can.

On the Timer() question (other thread - sorry, I'm lazy to write two posts) ... there's naturally a timer set, so all you need to do is make your own. Check out the timer for the LastManStanding class.


rgx