For b36 users running CTF, here are the GameRegion.cs and Notoriety.cs files that "should" work for b36. Atleast they compile without an error message. Unf I am just building my shard so don't really have a way to test them to see if I made some kinda logic mistake. But if you find one, let me know and I will see if I can fix it.
As you can see by the thread, this aint my code. Just trying to help some peeps out with the move to b36
GameRegion.cs
[code:1]
using Server;
using System;
using Server.Items;
using System.Collections;
using Server.Spells.Third;
using Server.Spells.Fifth;
using Server.Spells.Eighth;
using Server.Spells.Fourth;
using Server.Spells.Sixth;
using Server.Spells.Seventh;
using Server.Spells.Necromancy;
using Server.Spells.Chivalry;
using System.Text;
namespace Server.Regions
{
public class CtfGameRegion : Region
{
public static void Initialize()
{
Region.AddRegion( new CtfGameRegion() );
}
public CtfGameRegion() : base( "", "CTF Game", Map.Felucca )
{
Priority = Region.HighestPriority;
LoadFromXml = false;
this.Coords = new ArrayList( 1 );
this.Coords.Add( new Rectangle2D( 6031 ,400, 100, 100 ) );//ctf ( topleft, bottomright, width, height )
this.Coords.Add( new Rectangle2D( 5901, 270, 96, 95 ) );//dd ( topleft, bottomright, width, height )
}
public override bool CanUseStuckMenu( Mobile m )
{
return false;
}
public override bool OnBeginSpellCast( Mobile m, ISpell s )
{
if ( m.AccessLevel == AccessLevel.Player &&
( s is MarkSpell || s is RecallSpell || s is GateTravelSpell || s is PolymorphSpell ||
s is SummonDaemonSpell || s is AirElementalSpell || s is EarthElementalSpell || s is EnergyVortexSpell ||
s is FireElementalSpell || s is WaterElementalSpell || s is BladeSpiritsSpell || s is SummonCreatureSpell || s is VengefulSpiritSpell || s is SummonFamiliarSpell || s is SacredJourneySpell || s is ParalyzeFieldSpell || s is EnergyFieldSpell || s is WallOfStoneSpell ) )
{
m.SendMessage( "That spell is not allowed." );
return false;
}
else
return base.OnBeginSpellCast( m, s );
}
public override bool AllowHousing( Mobile from, Point3D p )
{
if ( from.AccessLevel == AccessLevel.Player )
return false;
else
return true;
}
public override void AlterLightLevel( Mobile m, ref int global, ref int personal )
{
global = LightCycle.DungeonLevel;
}
public override bool OnSingleClick( Mobile from, object o )
{
if ( o is Mobile )
{
Mobile m = (Mobile)o;
for (int i=0;i<CTFGame.Registry.Count;i++)
{
CTFGame game = (CTFGame)CTFGame.Registry
;
CTFTeam team = game.FindTeam( m );
if ( team != null )
{
string msg;
Item[] items;
if ( m.Backpack != null )
items = m.Backpack.FindItemsByType(typeof(CTFFlag));
else
items = new Item[0];
if ( items.Length == 0 )
{
msg = String.Format( "(Team: {0})", team.Name );
}
else
{
StringBuilder sb = new StringBuilder("(Team: " );
sb.Append( team.Name );
sb.Append( "; Flag" );
if ( items.Length > 1 )
sb.Append( "s" );
sb.Append( ": " );
for(int j=0;j<items.Length;j++)
{
CTFFlag flag = (CTFFlag)items[j];
if ( flag != null && flag.Team != null )
{
if ( j > 0 )
sb.Append( ", " );
sb.Append( flag.Team.Name );
}
}
sb.Append( "" );
msg = sb.ToString();
}
m.PrivateOverheadMessage( Network.MessageType.Regular, team.Hue, true, msg, from.NetState );
break;
}
}
}
return true;
}
}
}
[/code:1]
Notoriety.cs
[code:1]using System;
using System.Collections;
using Server;
using Server.Items;
using Server.Guilds;
using Server.Multis;
using Server.Mobiles;
namespace Server.Misc
{
public class NotorietyHandlers
{
public static void Initialize()
{
Notoriety.Hues[Notoriety.Innocent] = 0x59;
Notoriety.Hues[Notoriety.Ally] = 0x3F;
Notoriety.Hues[Notoriety.CanBeAttacked] = 0x3B2;
Notoriety.Hues[Notoriety.Criminal] = 0x3B2;
Notoriety.Hues[Notoriety.Enemy] = 0x90;
Notoriety.Hues[Notoriety.Murderer] = 0x22;
Notoriety.Hues[Notoriety.Invulnerable] = 0x35;
Notoriety.Handler = new NotorietyHandler( MobileNotoriety );
Mobile.AllowBeneficialHandler = new AllowBeneficialHandler( Mobile_AllowBeneficial );
Mobile.AllowHarmfulHandler = new AllowHarmfulHandler( Mobile_AllowHarmful );
}
private enum GuildStatus{ None, Peaceful, Waring }
private static GuildStatus GetGuildStatus( Mobile m )
{
if ( m.Guild == null )
return GuildStatus.None;
else if ( m.Guild.Enemies.Count == 0 && m.Guild.Type == GuildType.Regular )
return GuildStatus.Peaceful;
return GuildStatus.Waring;
}
private static bool CheckBeneficialStatus( GuildStatus from, GuildStatus target )
{
if ( from == GuildStatus.Waring || target == GuildStatus.Waring )
return false;
return true;
}
/*private static bool CheckHarmfulStatus( GuildStatus from, GuildStatus target )
{
if ( from == GuildStatus.Waring && target == GuildStatus.Waring )
return true;
return false;
}*/
public static bool Mobile_AllowBeneficial( Mobile from, Mobile target )
{
if ( from == null || target == null )
return true;
Map map = from.Map;
// Added for CTF game by sh1ny
for (int i=0;i<CTFGame.Registry.Count;i++)
{
CTFGame game = (CTFGame)CTFGame.Registry;
CTFTeam ft = game.FindTeam( from );
CTFTeam tt = game.FindTeam( target );
if ( ft != null && tt != null && ft != tt )
return false;
}
if ( map != null && (map.Rules & MapRules.BeneficialRestrictions) == 0 )
return true; // In felucca, anything goes
if ( !from.Player )
return true; // NPCs have no restrictions
if ( target is BaseCreature && !((BaseCreature)target).Controled )
return false; // Players cannot heal uncontroled mobiles
Guild fromGuild = from.Guild;
Guild targetGuild = target.Guild;
if ( fromGuild != null && targetGuild != null && (targetGuild == fromGuild || fromGuild.IsAlly( targetGuild )) )
return true; // Guild members can be beneficial
return CheckBeneficialStatus( GetGuildStatus( from ), GetGuildStatus( target ) );
}
public static bool Mobile_AllowHarmful( Mobile from, Mobile target )
{
if ( from == null || target == null )
return true;
Map map = from.Map;
// Added for CTF game by sh1ny
for (int i=0;i<CTFGame.Registry.Count;i++)
{
CTFGame game = (CTFGame)CTFGame.Registry;
CTFTeam ft = game.FindTeam( from );
CTFTeam tt = game.FindTeam( target );
if ( ft != null && tt != null && ft == tt )
return false;
}
if ( map != null && (map.Rules & MapRules.HarmfulRestrictions) == 0 )
return true; // In felucca, anything goes
if ( !from.Player && !(from is BaseCreature && (((BaseCreature)from).Controled || ((BaseCreature)from).Summoned)) )
return true; // Uncontroled NPCs have no restrictions
Guild fromGuild = GetGuildFor( from.Guild, from );
Guild targetGuild = GetGuildFor( target.Guild, target );
if ( fromGuild != null && targetGuild != null && (fromGuild == targetGuild || fromGuild.IsAlly( targetGuild ) || fromGuild.IsEnemy( targetGuild )) )
return true; // Guild allies or enemies can be harmful
if ( target is BaseCreature && ((BaseCreature)target).Controled )
return false; // Cannot harm other controled mobiles
if ( target.Player )
return false; // Cannot harm other players
if ( !(target is BaseCreature && ((BaseCreature)target).InitialInnocent) )
{
if ( Notoriety.Compute( from, target ) == Notoriety.Innocent )
return false; // Cannot harm innocent mobiles
}
return true;
}
public static Guild GetGuildFor( Guild def, Mobile m )
{
Guild g = def;
BaseCreature c = m as BaseCreature;
if ( c != null && c.Controled && c.ControlMaster != null )
{
c.DisplayGuildTitle = false;
if ( c.Map != Map.Internal && (c.ControlOrder == OrderType.Attack || c.ControlOrder == OrderType.Guard) )
g = c.Guild = c.ControlMaster.Guild;
else if ( c.Map == Map.Internal || c.ControlMaster.Guild == null )
g = c.Guild = null;
}
return g;
}
public static int CorpseNotoriety( Mobile source, Corpse target )
{
if ( target.AccessLevel > AccessLevel.Player )
return Notoriety.CanBeAttacked;
Body body = (Body) target.Amount;
//Added for CTF game by sh1ny
Guild sourceGuild = GetGuildFor( source.Guild, source );
Guild targetGuild = GetGuildFor( target.Guild, target.Owner );
for (int i=0;i<CTFGame.Registry.Count;i++)
{
CTFGame game = (CTFGame)CTFGame.Registry;
CTFTeam ft = game.FindTeam( source );
CTFTeam tt = game.FindTeam( target.Owner );
if ( ft != null && tt != null )
{
if ( ft == tt )
return Notoriety.Ally;
else
return Notoriety.Enemy;
}
else
{//changed to here
if ( target.Kills >= 5 || (body.IsMonster && IsSummoned( target.Owner as BaseCreature )) || (target.Owner is BaseCreature && ((BaseCreature)target.Owner).AlwaysMurderer) )
return Notoriety.Murderer;
if ( target.Criminal )
return Notoriety.Criminal;
//Guild sourceGuild = GetGuildFor( source.Guild, source );
//Guild targetGuild = GetGuildFor( target.Guild, target.Owner );
if ( sourceGuild != null && targetGuild != null )
{
if ( sourceGuild == targetGuild || sourceGuild.IsAlly( targetGuild ) )
return Notoriety.Ally;
else if ( sourceGuild.IsEnemy( targetGuild ) )
return Notoriety.Enemy;
}
}//Added for CTF game by sh1ny
}//Added for CTF game by sh1ny
if ( target.Kills >= 5 || (body.IsMonster && IsSummoned( target.Owner as BaseCreature )) || (target.Owner is BaseCreature && (((BaseCreature)target.Owner).AlwaysMurderer || ((BaseCreature)target.Owner).IsAnimatedDead)) )
return Notoriety.Murderer;
if ( target.Criminal )
return Notoriety.Criminal;
// Guild sourceGuild = GetGuildFor( source.Guild, source );
// Guild targetGuild = GetGuildFor( target.Guild, target.Owner );
if ( sourceGuild != null && targetGuild != null )
{
if ( sourceGuild == targetGuild || sourceGuild.IsAlly( targetGuild ) )
return Notoriety.Ally;
else if ( sourceGuild.IsEnemy( targetGuild ) )
return Notoriety.Enemy;
}
if ( target.Owner != null && target.Owner is BaseCreature && ((BaseCreature)target.Owner).AlwaysAttackable )
return Notoriety.CanBeAttacked;
if ( CheckHouseFlag( source, target.Owner, target.Location, target.Map ) )
return Notoriety.CanBeAttacked;
if ( !body.IsHuman && !body.IsGhost && !IsPet( target.Owner as BaseCreature ) )
return Notoriety.CanBeAttacked;
ArrayList list = target.Aggressors;
for ( int i = 0; i < list.Count; ++i )
{
if ( list == source )
return Notoriety.CanBeAttacked;
}
return Notoriety.Innocent;
}
public static int MobileNotoriety( Mobile source, Mobile target )
{
if ( Core.AOS && (target.Blessed || (target is BaseVendor && ((BaseVendor)target).IsInvulnerable) || target is PlayerVendor || target is TownCrier) )
return Notoriety.Invulnerable;
if ( target.AccessLevel > AccessLevel.Player )
return Notoriety.CanBeAttacked;
if ( source.Player && !target.Player && source is PlayerMobile && target is BaseCreature )
{
BaseCreature bc = (BaseCreature)target;
if ( !bc.Summoned && !bc.Controled && ((PlayerMobile)source).EnemyOfOneType == target.GetType() )
return Notoriety.Enemy;
}
if ( target.Kills >= 5 || (target.Body.IsMonster && IsSummoned( target as BaseCreature ) && !(target is BaseFamiliar) && !(target is Golem)) || (target is BaseCreature && (((BaseCreature)target).AlwaysMurderer || ((BaseCreature)target).IsAnimatedDead)) )
return Notoriety.Murderer;
if ( target.Criminal )
return Notoriety.Criminal;
Guild sourceGuild = GetGuildFor( source.Guild, source );
Guild targetGuild = GetGuildFor( target.Guild, target );
if ( sourceGuild != null && targetGuild != null )
{
if ( sourceGuild == targetGuild || sourceGuild.IsAlly( targetGuild ) )
return Notoriety.Ally;
else if ( sourceGuild.IsEnemy( targetGuild ) )
return Notoriety.Enemy;
}
//Added for CTF game by sh1ny
for (int i=0;i<CTFGame.Registry.Count;i++)
{
CTFGame game = (CTFGame)CTFGame.Registry;
CTFTeam ft = game.FindTeam( source );
CTFTeam tt = game.FindTeam( target );
if ( ft != null && tt != null )
{
if ( ft == tt )
return Notoriety.Ally;
else
return Notoriety.Enemy;
}
else
{//Added for CTF game by sh1ny
if ( target.Kills >= 5 || (target.Body.IsMonster && IsSummoned( target as BaseCreature ) && !(target is BaseFamiliar) && !(target is Golem)) || (target is BaseCreature && ((BaseCreature)target).AlwaysMurderer) )
return Notoriety.Murderer;
if ( target.Criminal )
return Notoriety.Criminal;
//Guild sourceGuild = GetGuildFor( source.Guild, source );
//Guild targetGuild = GetGuildFor( target.Guild, target );
if ( sourceGuild != null && targetGuild != null )
{
if ( sourceGuild == targetGuild || sourceGuild.IsAlly( targetGuild ) )
return Notoriety.Ally;
else if ( sourceGuild.IsEnemy( targetGuild ) )
return Notoriety.Enemy;
}
}//Added for CTF game by sh1ny
}//Added for CTF game by sh1ny
if ( SkillHandlers.Stealing.ClassicMode && target is PlayerMobile && ((PlayerMobile)target).PermaFlags.Contains( source ) )
return Notoriety.CanBeAttacked;
if ( target is BaseCreature && ((BaseCreature)target).AlwaysAttackable )
return Notoriety.CanBeAttacked;
if ( CheckHouseFlag( source, target, target.Location, target.Map ) )
return Notoriety.CanBeAttacked;
if ( !(target is BaseCreature && ((BaseCreature)target).InitialInnocent) )
{
if ( !target.Body.IsHuman && !target.Body.IsGhost && !IsPet( target as BaseCreature ) )
return Notoriety.CanBeAttacked;
}
if ( CheckAggressor( source.Aggressors, target ) )
return Notoriety.CanBeAttacked;
if ( CheckAggressed( source.Aggressed, target ) )
return Notoriety.CanBeAttacked;
if ( target is BaseCreature )
{
BaseCreature bc = (BaseCreature)target;
if ( bc.Controled && bc.ControlOrder == OrderType.Guard && bc.ControlTarget == source )
return Notoriety.CanBeAttacked;
}
return Notoriety.Innocent;
}
public static bool CheckHouseFlag( Mobile from, Mobile m, Point3D p, Map map )
{
BaseHouse house = BaseHouse.FindHouseAt( p, map, 16 );
if ( house == null || house.Public || !house.IsFriend( from ) )
return false;
if ( m != null && house.IsFriend( m ) )
return false;
BaseCreature c = m as BaseCreature;
if ( c != null && !c.Deleted && c.Controled && c.ControlMaster != null )
return !house.IsFriend( c.ControlMaster );
return true;
}
public static bool IsPet( BaseCreature c )
{
return ( c != null && c.Controled );
}
public static bool IsSummoned( BaseCreature c )
{
return ( c != null && /*c.Controled &&*/ c.Summoned );
}
public static bool CheckAggressor( ArrayList list, Mobile target )
{
for ( int i = 0; i < list.Count; ++i )
if ( ((AggressorInfo)list).Attacker == target )
return true;
return false;
}
public static bool CheckAggressed( ArrayList list, Mobile target )
{
for ( int i = 0; i < list.Count; ++i )
{
AggressorInfo info = (AggressorInfo)list;
if ( !info.CriminalAggression && info.Defender == target )
return true;
}
return false;
}
}
}
[/code:1]