Capture The Flag

11/05/2011 23:21 shadowman123#1
Well i wanted to make CTF Tournament So what i did is when Right time Comes its starts Such that 2 Teams will be Spawned and Then teleported to The Map && i added The Flag Sobs Too successfuly but there r 2 things i wanna add but couldnt do it :-

1st - After 30 sec of Carrying the Flag...the Flagbase become in the place where the The Flag Holder Exist

2nd - for example i have brought the Flag now to my base So what i need to know how to make it like i cant attack my own Flagbase ...

just need The General Idea or Hints..
11/06/2011 01:45 pro4never#2
I'd suggest thinking in a more object oriented manner...

By this I mean that every single variable you create in programming is an object (Disclaimer: Obviously this only applies to object oriented programming languages such as C#). This object can represent virtually limitless things but you as the programmer control that (ints represent numbers... but more complex classes can represent things like npcs... teams... tournaments).

You then need to break things down into their required parts in a logical way (you may need to revise this structure quite a few times if you're just learning or your needs change). From there you code them one at a time and test them out together to find issues and correct them.

Now from a less abstract viewpoint, lets talk about CTF.

What does this tournament require? It needs something to represent the entire tournament for starters! The fact we might want multiple ctfs running means it should not be static (can create multiple versions/copies of the object) so a public class would be appropriate in this case.


What belongs inside the ctf class?... well we know that we have teams competing in the tournament so we know we'll need a class to represent teams..

What belongs to teams?... well members of course! but we can also include things like their base! We can then store what team we are on and check during our attacks to check..

A: if we are attacking a player and we're inside ctf... are they on our team?
B: if we are attacking a npc and we're inside ctf... is this object our base?

I could get really detailed and start talking about all the helper methods and other things that might belong to these different classes but I'd say you should be able to figure it out ;)