tass23 submitted a new resource:

CTF and DD Games - Capture the Flag and Double Domination PvP games

This was originally Zippy's release years ago. I have dusted it off and cleared up a few issues. It's stable, but once added will require some tweaking (you have to set up the game stone, etc). I added regions in some of the files where values can be changed, just look for CTFValues. Please see Instructions/Installation and notes in the second post.

Many thanks to Zippy for this! :)

Read more about this resource...
 
Last edited:
Instructions/Notes (included in the resource archive as well):
Code:
Update: 9-26-2016 Raist/Tass23
Verified stability. Marked regions where values need to be changed (#region CTFValues). Corrected a few incompatibility issues.

NOTES:
Not all of the instructions below will apply in every case, as this code is fairly old.
You might not have a GameRegion.cs file, in which case, you can create a new region in Regions.xml or use Regions-In-A-Box.
Also, it is mentioned that you must delete your Notoriety.cs file, this was not an issue during testing.
When adding a GameStone, the proper Add constructor was Add CTFGame 2, where the 2 is the Number of Teams.
*** After the game has been set up, place a Join Stone and immediately set it to the GameStone. If you don't, when a player gets near the Join Stone, it will crash the shard! ***

Update on 8/11/04:
This is a small clean-up & update for the CTF and DD games.  If you already have CTF/DD on your shard you will NOT need to re-setup your games to use the new version of the scripts.  The only thing you must do after unextracting is re-add all of your signup stones (and relink them to the game stone).  Please delete DDJoin.cs, CTFJoin.cs, and CTFJoinGump.cs from previous installations.

What changed? The game no longer infinitely restarts itself.  The game now runs once for it's set length and then stops.  If someone reaches the max score before the game time is over, it will end early.  You can use [startgame and [stopgame (see below) to control the game as you see fit.  When the game is not running, players will be unable to fight (or heal) each other, and none of the flags/waypoints will work.
Also, Notoriety.cs is now much less cluttered with CTF stuff.  There are only 2 places, (both are clearly marked) where CTF stuff is in there.
There is a comment in CTFGame.cs where you can add code to give prizes to members of the winning team.

**** Installation ****
Extract to your scripts folder. Then make SURE you delete your "Scripts/Misc/Notoriety.cs" file. This is very important....
Follow the instructions below to setup your game.

**** Setup Instuctions ****
Okay, this is a fairly large system... there are lot of little things and you'll want to play around with it before dropping it right on to your shard... Here is a "crash" course in how to set it up.

Before setting up the script on the shard, you may want to change the Coords in the "GameRegion.cs" script. The coords in there now are some nice places me & alkiser found a while ago on the default map... but you might want to use something else.

Capture the Flag:
1) [add CTFGame put it some place out of the way.. this is used for controlling game options only, players don't need to see it.
2) [props or double click the game stone and setup the properties of the game (like how many teams, etc).
3) [add CTFFlag, this is the flag so it should go some place in your "arena"
4) Double click or do [props on the Flag, you will get a props menu... FIRST Set the TeamID to the Team Number (0, 1, 2, 3) etc you want the team to have. (This should never be >= the number of teams in the game)
5) Next set the Flag's Game property to the game stone you added in step 1.
6) Set all the other properties how you want, Note:set the flag's Hue to the color you want the team to wear (a blue flag means everyone on the team will wear a blue robe).

*) Repeat steps 3-6 for each team

Now you may [add gamejoinstone all around your shard to allow players to join the game. These must also be linked via props to the game stone from step 1.
You may also [add ctfscoreboard all over your shard (and dont forget to link them to the gamestone) so your players can see the scores. You might also want to add one in the arena.

Double Donimation:
First off, what is double domination?
This is a game I originally saw in Unreal on the Xbox. Basically 2 teams fight to control 2 way points at the same time, to control the point they must stand on it for 10 seconds without the other team touching it. Once they control both points at the same time for 30 seconds, they "score" and then the game resets.
It's very fast paced, but if teams are too large it can get out of hand.

The setup for double domination is pretty similar to CTF, with a few exceptions:

1) For each team you need to add a DDTeamControl (similar to the gamestone this will not be used by players) to control the DDTeams since they don't have flags. Otherwise, it acts the same as a ctfflag (including hue...).
2) You must add 2 DDWayPoints in your arena. DO NOT FORGET TO DO [inc z 5 on them so you can see the whole thing (it's rather large). And you of course have to link them to your CTFGame (yes it's still a CTFGame even though is DoubleDom)... These points must also be linked to each other. Your DD Game can have as many teams as you want, but it can only have 2 way points.

You should also be able to use the CTFScoreBoard for DD games.

Also included in this package is an "AutoSupply Stone" which when double clicked, gives a player items based on their skills, it's designed to make it so when a player dies he/she can re-equip very quickly.

Commands:
[endgame : (target gamestone) will end the current game
[startgame <reset> : will start the game, or if the game is already running, will restart it.  The parameter reset should be true (or yes) if you want everyone to reselect their teams, or false (or no) to keep the current teams.  [startgame true to reset/rebalance teams.
[t and [team : These commands allow players to talk to the entire team ( no matter where they are )

New to this package is the LeaveGameGate. [add leavegamegate Do not forget to [props and set the target location & map for the gate to take players. When stepped on the gate will remove the player for any/all games they are currently in, remove their game robe, and teleport them to the desired location.

When you die in a CTF or DD Game you are resurrected automatically and taken back to your team's "home." A good strategy for this is to make the home a place somewhere outside of the battle area where the player can re-equip in peace, and then go through a gate to enter the game. This also prevents people from restocking on the stones when they didn't die.

Also this is provided AS IS, I am usually too busy to provide support for it. Please don't try to contact about it. There is a thread for it on runuo.com script submissions where you can seek support.

Thanks, enjoy.
~Zippy

NOTE: The GameJoinStone seems to be a bit flaky. Make sure the game is NOT running when you link it to the GameStone and make sure the NAME is the identical to the name of the game. For example: Reds vs Greens is NOT the same as Reds Vs Greens.

Edit: DO NOT USE DD (Double Domination), ONLY CTF IS STABLE.

(Currently, DD can be set up, but once the game is started, it crashed the shard. There is no error report being generated. So if anyone would like to help troubleshoot this, just send me a PM. It appears to be an issue with the DD Timer, after the match begins. This is only an issue with DD and does not effect CTF.)

Update on 11/03/16:
Fixed an issue with the Game Join Stone causing shard crashes when set up with a DD game.
 
Last edited:
I have issues with DD if i start a game and nobody joins, server crash:


Exception:
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at Server.Items.CTFGame.StartTimer.OnTick()
at Server.Timer.Slice()
at Server.Core.Main(String[] args)

this is the code that handles it i guess:

Code:
protected override void OnTick()
            {
                 PlayerMobile pm = (PlayerMobile)m_Mob;

                CTFTeam teamo = (CTFTeam)m_Game.Teams[0];
                CTFTeam teamt = (CTFTeam)m_Game.Teams[1];
                if (teamo.ActiveMemberCount == 0 && teamt.ActiveMemberCount == 0)
                {
                    m_Game.ExEndGame();
                }
                else
                {
                    m_Game.LeaveGame(pm);
                    Stop();
                }
            }
 
Once you get a game set up, make sure the Game Join Stone is linked to the CTF Stone, before ANY players (or even staff) get near it. Otherwise your shard will crash. After everything has been set up, it's totally stable as far as I can see through the testing I did originally.
 
Thanks for reply, it is linked, i read carefully the installation notes, idk maybe im doing something wrong, will try to setup a brand new game again
 
Just make sure the Game Join Stone is the LAST item you place and that everything else is linked to the Game Stone. I did notice that if the Game Join Stone was placed (and not linked right away) and a World Save hit, I would crash. Likely there needs to be a Null check somewhere.
 
It still crash... im pretty sure i setup it well, everything is linked.


I will provide screenshots later, cant do it right now
[doublepost=1477649877][/doublepost]Sorry for late answer: here is the pic, as u can see everything seems to be linked.
[doublepost=1477650062][/doublepost]linkedstones.png
 

Attachments

  • linkedstones.png
    linkedstones.png
    300.8 KB · Views: 11
Last edited:
During testing with this, there wasn't much of a delay between starting the match and getting players to join (as I was logged into 3 accounts at once). It's possible that if at least two players join, before the initial Start tick, no crash, but if the initial Start tick happens and no one has joined, crash. A possible workaround would be to not Start a match until you at least have two players ready to join.

Do you have a Region set up that includes the entire match arena? If not, that might be your problem.
 
During testing with this, there wasn't much of a delay between starting the match and getting players to join (as I was logged into 3 accounts at once). It's possible that if at least two players join, before the initial Start tick, no crash, but if the initial Start tick happens and no one has joined, crash. A possible workaround would be to not Start a match until you at least have two players ready to join.

Do you have a Region set up that includes the entire match arena? If not, that might be your problem.

A possible workaround would be to not Start a match until you at least have two players ready to join.
I wish i knew how to do that, it seems to be the problem.

And yes, the time to join is like 30 secs only.

A region setup? what do u mean
 
A region...an area set up with designated coordinates. When you type Where and it says blah, blah, your Region is ______
I used Regions-In-A-Box to set up a temporary region (just a basic square area). Give that a try first and see if you stop getting crashes.
 
In GameJoinGump i setup there the coords. I really dont get what you want me to do and why do i have to make a new region for the arena.

I setup the coords at Ilshenar, Spectre Dungeon, thats all ive done,

i have Custom regions in a box. Want me to create a region and give it a name? i dont think it will make any difference, crash sems to be related when the game arrange the players to start a game
 
In GameJoinGump i setup there the coords. I really dont get what you want me to do and why do i have to make a new region for the arena.

I setup the coords at Ilshenar, Spectre Dungeon, thats all ive done,

i have Custom regions in a box. Want me to create a region and give it a name? i dont think it will make any difference, crash sems to be related when the game arrange the players to start a game
When I first tried to use this system, there was no region defined (originally there was some GameRegion that was defined, but I never had that file). Players would join the game, but wouldn't be assigned to teams, because the region wouldn't allow PvP. Since Fel is the only facet, by default, that allows PvP, you need to setup a specific region for this system to use, as the arena. After that is done and you are ready to start the game, have the players join, then use the Startgame True, then target the GameStone. This will re-assign players to teams and then the game will begin.
 
So i have to create an new region area with regions in a box as arena, give it a name and allow pvp, then add it to regionsxml?

Im Sorry, im so useless
 
No, you don't have to add it to Regions.xml, if you use Regions-In-A-Box, instead. ;)
The only silly question is the one not asked ;)
 
I missed an important piece of information that you said earlier...
I setup the coords at Ilshenar, Spectre Dungeon, thats all ive done
Is Ilsh a PvP facet on your shard?
Set it up in Fel GA first, and then move it to it's final destination.
 
I missed an important piece of information that you said earlier...

Is Ilsh a PvP facet on your shard?
Set it up in Fel GA first, and then move it to it's final destination.

I tested at Fel too, still getting the same crash error.

I ran the server in debug mode, heres the error log:



Exception:
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at Server.Items.CTFGame.StartTimer.OnTick() in c:\Users\uoodnc\Desktop\Scripts\CUSTOM\Dominion\CTFGame.cs:line 613
at Server.Timer.Slice()
at Server.Core.Main(String[] args)



Code:
            protected override void OnTick()
            {
                int sm = -1, ns = -1;
                int[] amc = new int[m_Game.m_Teams.Count];
                for(int i=0;i<m_Game.m_Teams.Count;i++)
                {
                    amc[i] = ((CTFTeam)m_Game.m_Teams[i]).ActiveMemberCount;
                    if ( sm == -1 || amc[i] < amc[sm] )
                    {
                        ns = sm;
                        sm = i;
                    }
                    else if ( amc[i] < amc[ns] )   ////613 LINE
                    {
                        ns = i;
                    }
                }
                for (int i=0;i<m_List.Count;i++)
                {
                    Mobile m = (Mobile)m_List[i];
                    m.Frozen = false;
                    m.CloseGump( typeof( GameTeamSelector ) );

                    if ( m_Game.GetTeam( m ) == null )
                    {
                        int t;
                        if ( m.NetState == null )
                        {
                            t = Utility.Random( amc.Length );
                        }
                        else
                        {
                            if ( amc[sm] >= amc[ns] )
                                t = Utility.Random( amc.Length );
                            else
                                t = sm;
                            amc[t]++;
                        }
                        CTFTeam team = (CTFTeam)m_Game.m_Teams[t];
                        m_Game.SwitchTeams( m, team );
                        m.SendMessage( "You have joined team {0}!", team.Name );
                    }
                }
                m_Game.ResetGame();
            }
 
Last edited:
heya tass23

just installed the script and i got this error:

Errors:
+ Customs / [ServUO.com] -CTF_and_DD_Games (1) /CTF.cs:
CS0115: Line 38: 'Server.Regions.CTF.AllowHarmful (Server.Mobile, Server.Mobile)': no suitable method was found for substitution
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.

any idea how to fix plz?
 
Last edited:
heya tass23

just installed the script and i got this error:

Errors:
+ Customs / [ServUO.com] -CTF_and_DD_Games (1) /CTF.cs:
CS0115: Line 38: 'Server.Regions.CTF.AllowHarmful (Server.Mobile, Server.Mobile)': no suitable method was found for substitution
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.

any idea how to fix plz?
You must be in a PvP region (or at least a region that allows players to harm one another). Use Regions-in-A-Box to create regions in-game on the fly, or edit your Regions.xml in your Data folder, and add a region where you want to set up the CTF and/or DD game(s).
 
thank you for replay.

i coudln't compile the script at start, i have felucca, ilshenar , tokuno pvp allowed on.

do i need setup something there before i compile the script?

i am confused.
 
Did you install the scripts twice? Just curious because of the way the folder is named.
What server are you running? What did you change in terms of PvP on your shard?
Send me a PM with some details and we'll go from there. I'm guessing you still have Notoriety.cs?
 
I'd like to use this script, but i'ts crashing.

Crash Log:
--------------------------------------------------------------------------------
ServUO - [https://www.servuo.com] Version 0.5, Build 6396.27340
Core: Optimizing for 8 64-bit processors
RandomImpl: CSPRandom (Software)
Core: Loading config...
Scripts: Compiling C# scripts...Failed with: 1 errors, 3 warnings
Warnings:
+ Customs/[ServUO.com]-Stripper/Stripper.cs:
CS0105: Line 11: The using directive for 'Server.Misc' appeared previously in this namespace
+ Multis/Boats/BaseBoat.cs:
CS0105: Line 11: The using directive for 'Server.Network' appeared previously in this namespace
+ Customs/[ServUO.com]-Spellbar_Ver 2/Spellbar_Ver 2/Spellbar/SpellBarScroll_XML.cs:
CS0108: Line 27: 'Server.Engines.XmlSpawner2.SpellBarScroll.Initialize()' hides inherited member 'Server.Engines.XmlSpawner2.XmlAttachment.Initialize()'. Use the new keyword if hiding was intended.
Errors:
+ Customs/[ServUO.com]-CTF_and_DD_Games/CTF.cs:
CS0115: Line 38: 'Server.Regions.CTF.AllowHarmful(Server.Mobile, Server.Mobile)': no suitable method found to override
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.
 
I'd like to use this script, but i'ts crashing.

Crash Log:
--------------------------------------------------------------------------------
ServUO - [https://www.servuo.com] Version 0.5, Build 6396.27340
Core: Optimizing for 8 64-bit processors
RandomImpl: CSPRandom (Software)
Core: Loading config...
Scripts: Compiling C# scripts...Failed with: 1 errors, 3 warnings
Warnings:
+ Customs/[ServUO.com]-Stripper/Stripper.cs:
CS0105: Line 11: The using directive for 'Server.Misc' appeared previously in this namespace
+ Multis/Boats/BaseBoat.cs:
CS0105: Line 11: The using directive for 'Server.Network' appeared previously in this namespace
+ Customs/[ServUO.com]-Spellbar_Ver 2/Spellbar_Ver 2/Spellbar/SpellBarScroll_XML.cs:
CS0108: Line 27: 'Server.Engines.XmlSpawner2.SpellBarScroll.Initialize()' hides inherited member 'Server.Engines.XmlSpawner2.XmlAttachment.Initialize()'. Use the new keyword if hiding was intended.
Errors:
+ Customs/[ServUO.com]-CTF_and_DD_Games/CTF.cs:
CS0115: Line 38: 'Server.Regions.CTF.AllowHarmful(Server.Mobile, Server.Mobile)': no suitable method found to override
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.

You must be in a PvP region (or at least a region that allows players to harm one another). Use Regions-in-A-Box to create regions in-game on the fly, or edit your Regions.xml in your Data folder, and add a region where you want to set up the CTF and/or DD game(s).
 
Did you install the scripts twice? Just curious because of the way the folder is named.
What server are you running? What did you change in terms of PvP on your shard?
Send me a PM with some details and we'll go from there. I'm guessing you still have Notoriety.cs?

Curious, was there any resolution to this issue? I also have the same problem. I'm unable to compile with the same mentioned error. Deleting Notoriety.cs does not resolve.
 
heya tass23

just installed the script and i got this error:

Errors:
+ Customs / [ServUO.com] -CTF_and_DD_Games (1) /CTF.cs:
CS0115: Line 38: 'Server.Regions.CTF.AllowHarmful (Server.Mobile, Server.Mobile)': no suitable method was found for substitution
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.

any idea how to fix plz?
The base class method signature (Region.cs) in the latest version on ServUO is:
Code:
public virtual bool AllowHarmful(Mobile from, IDamageable target)
Change the method signature to match the types (Mobile, IDamageable).

Explanation:
IDamageable is an interface. An interface defines methods and properties that must be implemented on any class which uses the interface. Originally, RunUO and ServUO simply used a Mobile type for this second parameter and the IDamageable interface was unnecessary. Now, an IDamageable can be a mobile, or any other class that implements the IDamageable interface. You can read more about interfaces and understand their usefulness here:
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/interfaces/
https://www.dotnetperls.com/interface
https://stackoverflow.com/questions/6802573/c-sharp-interfaces-whats-the-point

So to fix it, first fix the signature of the method, then fix the code within that method to allow it to handle the new IDamageable type that is passed. The only place where "target" is used in that method is the following line:

Code:
CTFTeam tt = CTFGame.FindTeamFor( target );

FindTeamFor requires a Mobile parameter. Rather than try to convert all these methods to use IDamageable, let's just cast to Mobile here (safely).

Code:
		public override bool AllowHarmful(Mobile from, IDamageable target)
		{
			CTFTeam ft = CTFGame.FindTeamFor( from );
			if ( ft == null )
				return false;
			Mobile mobTarget = target as Mobile;
			// what do we want AllowHarmful to return if target was not a mobile? Passing a null mobTarget to FindTeamFor could be dangerous!
			CTFTeam tt = CTFGame.FindTeamFor( mobTarget );
			if ( tt == null )
				return false;

			return (ft != tt && ft.Game == tt.Game && ft.Game.Running);
		}

Lastly, think about what is the purpose of this method, "AllowHarmful"? The return value (true or false) tells you whether "from" is allowed to harm "target". If the target is not of type MOBILE, do you want to allow "from" to damage the target in a CTFRegion? It's up to you. For the sake of completing the code, let's say yes, and implement a return value when "target" is not of type Mobile.

Code:
		public override bool AllowHarmful(Mobile from, IDamageable target)
		{
			CTFTeam ft = CTFGame.FindTeamFor( from );
			if ( ft == null )
				return false;
			Mobile mobTarget = target as Mobile;
			if(mobTarget == null)
				return true;
			CTFTeam tt = CTFGame.FindTeamFor( mobTarget );
			if ( tt == null )
				return false;

			return (ft != tt && ft.Game == tt.Game && ft.Game.Running);
		}

I hope by following this post and trying to understand its content you are able to solve any similar issues you'll have.
 
Last edited:
I hope by following this post and trying to understand its content you are able to solve any similar issues you'll have.

This post is fantastic!! The community needs more people like you, thanks for the well worded post and teaching me to fish, rather than giving me a fish!
 
Tried making AllowHarmful to virtual:

(regions.cs)

#if ServUO
public override bool AllowHarmful(Mobile from, IDamageable target)
{
if (target is Mobile)
{
return AllowHarmful(from, (Mobile)target);
}
return base.AllowHarmful(from, target);
}
public virtual bool AllowHarmful(Mobile from, Mobile target)
#else
public virtual bool AllowHarmful(Mobile from, Mobile target)
#endif
{
if (Battle != null)
{
PlayerMobile x, y;
if (NotoUtility.Resolve(from, target, out x, out y))
{
bool handled;
var result = Battle.AllowHarmful(x, y, out handled);
if (handled)
{
return result;
}
}
}
return base.AllowHarmful(from, target);
}


AND allowharmful to be an override:


public override bool AllowHarmful(Mobile from, Mobile target)
{
CTFTeam ft = CTFGame.FindTeamFor( from );
if ( ft == null )
return false;
CTFTeam tt = CTFGame.FindTeamFor( target );
if ( tt == null )
return false;
return (ft != tt && ft.Game == tt.Game && ft.Game.Running);
}

No dice.




Stacktrace:

CS0108: Line 27: 'Server.Engines.
Errors:
+ Customs/[ServUO.com]-CTF_and_DD_Games/CTF.cs:
CS0115: Line 38: 'Server.Regions.CTF.AllowHarmful(Server.Mobile, Server.Mobile)': no suitable method found to override
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.
 
Back