I don't need to test my programs. I have an error-correcting modem.
Legacy:Wormbo/Developer Journal
Contents
Reversed CTF[edit]
This mod started out quite nicely, but then came to halt due to a lack of interest in messing with bot AI and the existance of other, more interesting projects.
Status of this project: Canceled. You can get the unfinished but basically working mod without bot support from my spare parts page.
How Do I Start?[edit]
I think this mod should be quite simple to do since it's only a small change. (I'll see about that after understanding the CTF code.)
The Rules[edit]
The first step obviously is to specify the new gametype's rules:
- The gametype will use CTF maps.
- Each team starts in its base. (the base with the flag of the same color)
- Players can pick up and carry their team's flag.
- Touching the enemy flag sends it back to its base.
- Points are scored by a player who touches the enemy flag at its base while holding his/her team's flag.
- The Translocator is enabled by default, but if a player translocates while carrying the flag causes him/her to drop the flag.
I'll examine the relevant UScript classes now, before I start scripting at all. This will allow me to think up a possible class tree for the mod. (Which classes need to be subclassed at all and which classes can I extend from?)
A Look At Existing Classes[edit]
The mod might be more difficult than I though in the first place. There are lots of classes for CTF and I'm sure most of them need to be subclassed.
Some Info subclasses:
- GameInfo >> UnrealMPGameInfo >> DeathMatch >> TeamGame >> CTFGame >> xCTFGame
- CTFGame obviously is the base class for CTF gametypes and xCTFGame is the gametype used in UT 2003. I'm not yet sure which of them should be subclassed.
- TeamAI >> CTFTeamAI
- ReplicationInfo >> SquadAI >> CTFSquadAI
- I don't know, what exactly these are used for, but they seem to handle the bot AI. Need to look into those classes.
- LocalMessage >> CTFHUDMessage
- LocalMessage >> CriticalEventPlus >> CTFMessage
- The message classes. CTFMessage is ok, but CTFHUDMessage needs to be subclassed.
Other Actor classes:
- Decoration >> GameObject >> CTFFlag
- The flag itself. Needs to be subclassed.
- NavigationPoint >> JumpDest >> JumpSpot >> GameObjectives >> CTFBase
- The flag base. I can't replace it because it's bNoDelete=True, but I'm sure I can handle all the important stuff from the flags. It's not bStatic, so I might be able to change the FlagType to my own CTFFlag subclass before the flags are spawned.
- HUD >> HudBase >> HudBDeathMatch >> HudBTeamDeathMatch >> HudBCaptureTheFlag
- The HUD class. I'm not sure whether I need to subclass it.
Starting The Real Work[edit]
Easy Start[edit]
I decided to subclass xCTFGame and not CTFGame and also found out that I need to subclass HudBCaptureTheFlag to replace the CTFHUDMessage with my own class.
Currently I have these:
- ReversedCTFGame (extends xCTFGame)
- The GameInfo class. Currently only replaces the HUD.
- HudReversedCTF (extends HudBCaptureTheFlag)
- The HUD class. Currently only replaces the CTFHUDMessage.
- ReversedCTFHUDMessage (extends CTFHUDMessage)
- Displays the warn messages when a player of the enemy team or the local player has the flag.
- ReversedCTF.int
- Adds the new game type to the list of game types.
Up to this point I didn't have to do any real coding work: The GameInfo and the message class only change some default properties and the HUD class has two small changes in its Timer function. Tomorrow I'll start with the real work, i.e. the changes in the CTFFlag and CTFGame code to allow the flag's team to pick it up, score points, etc.
Helpful Tools[edit]
Before continuing with the actual coding work I set up a batch file for recompiling the package:
UCCMakeReversedCTF.bat
@echo off d: cd\ut2003\system :start del reversedctf.u ucc make echo. pause goto start
This little script automatically deletes ReversedCTF.u and runs UCC Make to recompile it. It might be even better if I creaded a special INI file for UCC to use, but with only one project this almost seems too much work...
Hmm, gotta get used to the new look of the Make commandlet. :)
- Mychaeel: Note to self: I need to get (a new version of) UMake out to the public.
Gameplay and Scoring[edit]
First I'm going to change what happens when a player touches a flag and how scored are awarded, i.e. which flag must be carried by whom. The ReversedCTFFlag script only contains this function:
function bool SameTeam(Controller c) { if (c == None || c.PlayerReplicationInfo.Team == Team) // changed from "!= Team" return false; return true; }
This tiny change of a single character effectively switches around the teams from the flag's view. Now the blue flag can only be picked up by the blue team and will be returned to its (blue) base by the red team.
The scoring required a bit more work. Exactly two changes in the ScoreFlag function, to be precice: :rolleyes:
function ScoreFlag(Controller Scorer, CTFFlag theFlag) { local float Dist,oppDist; local int i; local float ppp,numtouch; local vector FlagLoc; if ( Scorer.PlayerReplicationInfo.Team != theFlag.Team ) { // was "== theFlag.Team" Scorer.AwardAdrenaline(ADR_Return); FlagLoc = TheFlag.Position().Location; Dist = vsize(FlagLoc - TheFlag.HomeBase.Location); if ( TheFlag.TeamNum != 0 ) // was "== 0" oppDist = vsize(FlagLoc - Teams[1].HomeBase.Location); else oppDist = vsize(FlagLoc - Teams[0].HomeBase.Location); ...
The gametype almost works as intended and could even be played online already. The only problem now is the AI: The bots gather around their team's flag carrier and keep saying "enemy flag carrier is here" while the bot that has the flag doesn't move at all.
This will be the next problem to solve.
AI → Explaining The Rules To The Bots[edit]
AI is the most difficult part in creating a new gametype. (not counting tweaking and bug-fixing)
Luckily in UT2003 gametype-specific bot AI is stored in seperate classes: SquadAI and (for team games) TeamAI.
But first:
The First Major Bug! :([edit]
The flags are invisible while they are not at their bases.
It turned out that my class analysis was incomplete, the CTFFlag class has some subclasses:
CTFFlag >> xBlueFlag/xRedFlag
I copied the xRedFlag and xBlueFlag classes and made them subclasses of my ReversedCTFFlag class.
Back To AI[edit]
I need to create completely new code for at least one of the larger CTFSquadAI functions. It might take some time to get the basic structure and I will do that on paper first.
Months pass...[edit]
Meanwhile I switched from batch file compiling to UMake and finished the Mercury Missile InstaGib mutator but instead of continuing with Reversed CTF I started playing Diablo 2 again – bad thing. :P
Reversed CTF is now in the "Overload v100 state", i.e. it works online perfectly and you could try to play it offline with bots, but don't expect too much from them. They just grab the flag and run towards the enemy base.
Comments[edit]
EntropicLqd: Jolly good, it might be finished by the time I get back on-line.
Wormbo: I didn't look at the details of the AI classes, but I guess in this case it will be mostly swapping EnemyFlag and FriendlyFlag or the teams.
Wormbo: Urgh, I take back everything I said. This gametype requires a completely different strategy, since you have to prevent the enemies from breaking into your base instead of reaching their base after escaping from yours. I need to completely rewrite that part of the SquadAI class. Also I just noticed, why the flags are invisible when they are carried or otherwise not at their base: CTFFlag has two subclasses xRedFlag and xBlueFlag. :/
Wormbo: Oh well, I'll have to take a break from this mod. Not because I needed it, but because I forgot to copy it to my notebook. :/ Actual coding work will be delayed till Monday, but in the meantime I could try to create the main structure for the bot behavior.
Aphelion: Thought I'd wish you luck... Looks like you're going well...
Nuclear Fuzz Grunge: This is an interesting exploratory type of tutorial. Perfect for Retro characters. Excellent. Complete clarity. An Exposition of Your Thinking Process. Thanks.
- Weeks pass...
Wormbo: I should really continue this sometimes... o_O
Trystan: hehehe. I've said that myself so many times. =)
- More week pass...
GRAF!K: Are you going to continue this?
Wormbo: Yes, I planned to... sometimes at least... :rolleyes:
- Even more weeks (or better: months) pass...
Wormbo: Enough is enough. This project got stuck at the bot AI and I hereby officially cancel development. You can get the mod and its source code at my spare parts page. If you want you can continue it, the only thing really missing is the bot AI. Reversed CTF itself is in "Overload v100 state", i.e. it works online without any problems as long as no bots are involved.