Fireball
Member
Hi,
I am trying to modify Detect Hidden to reveal trapped containers and display [Trapped] above the found trapped containers in the appropriate colour as per OSI. I want this to require 50 skill to work with 100 being flawless.
Initially I got it to display [trapped] but this appears at the target cursor and not over the container and since then I added the skill check which fails to compile.
I also added code to select the correct hue for the overhead message and this throws up errors too on TrapType. As you may remember I have struggled with enums before!
I am quite certain I am doing something elementally stupid but I can't figure it out!
Thanks so much for any help.
FB.
Here are the errors:
And here is my DetectHidden.cs. My code starts at line 85 in this segment "containerinRange"
I am trying to modify Detect Hidden to reveal trapped containers and display [Trapped] above the found trapped containers in the appropriate colour as per OSI. I want this to require 50 skill to work with 100 being flawless.
Initially I got it to display [trapped] but this appears at the target cursor and not over the container and since then I added the skill check which fails to compile.
I also added code to select the correct hue for the overhead message and this throws up errors too on TrapType. As you may remember I have struggled with enums before!
I am quite certain I am doing something elementally stupid but I can't figure it out!
Thanks so much for any help.
FB.
Here are the errors:
Code:
Errors:
+ Skills/DetectHidden.cs:
CS1502: Line 94: The best overloaded method match for 'Server.Mobile.CheckSk
ill(Server.SkillName, double, double)' has some invalid arguments
CS1503: Line 94: Argument 2: cannot convert from 'Server.Items.Container' to
'double'
CS1061: Line 96: 'Server.Items.Container' does not contain a definition for
'TrapType' and no extension method 'TrapType' accepting a first argument of type
'Server.Items.Container' could be found (are you missing a using directive or a
n assembly reference?)
CS1061: Line 99: 'Server.Items.Container' does not contain a definition for
'TrapType' and no extension method 'TrapType' accepting a first argument of type
'Server.Items.Container' could be found (are you missing a using directive or a
n assembly reference?)
CS1061: Line 102: 'Server.Items.Container' does not contain a definition for
'TrapType' and no extension method 'TrapType' accepting a first argument of typ
e 'Server.Items.Container' could be found (are you missing a using directive or
an assembly reference?)
CS1061: Line 105: 'Server.Items.Container' does not contain a definition for
'TrapType' and no extension method 'TrapType' accepting a first argument of typ
e 'Server.Items.Container' could be found (are you missing a using directive or
an assembly reference?)
And here is my DetectHidden.cs. My code starts at line 85 in this segment "containerinRange"
Code:
using System;
using Server.Items;
using Server.Factions;
using Server.Mobiles;
using Server.Multis;
using Server.Targeting;
using Server.Regions;
namespace Server.SkillHandlers
{
public class DetectHidden
{
public static void Initialize()
{
SkillInfo.Table[(int)SkillName.DetectHidden].Callback = new SkillUseCallback( OnUse );
}
public static TimeSpan OnUse( Mobile src )
{
src.SendLocalizedMessage( 500819 );//Where will you search?
src.Target = new InternalTarget();
return TimeSpan.FromSeconds( 6.0 );
}
private class InternalTarget : Target
{
public InternalTarget() : base( 12, true, TargetFlags.None )
{
}
protected override void OnTarget( Mobile src, object targ )
{
bool foundAnyone = false;
Point3D p;
if ( targ is Mobile )
p = ((Mobile)targ).Location;
else if ( targ is Item )
p = ((Item)targ).Location;
else if ( targ is IPoint3D )
p = new Point3D( (IPoint3D)targ );
else
p = src.Location;
double srcSkill = src.Skills[SkillName.DetectHidden].Value;
int range = (int)(srcSkill / 10.0);
if ( !src.CheckSkill( SkillName.DetectHidden, 0.0, 100.0 ) )
range /= 2;
BaseHouse house = BaseHouse.FindHouseAt( p, src.Map, 16 );
bool inHouse = ( house != null && house.IsFriend( src ) );
if ( inHouse )
range = 22;
if ( range > 0 )
{
IPooledEnumerable inRange = src.Map.GetMobilesInRange( p, range );
foreach ( Mobile trg in inRange )
{
if ( trg.Hidden && src != trg )
{
double ss = srcSkill + Utility.Random( 21 ) - 10;
double ts = trg.Skills[SkillName.Hiding].Value + Utility.Random( 21 ) - 10;
if ( src.AccessLevel >= trg.AccessLevel && ( ss >= ts || ( inHouse && house.IsInside( trg ) ) ) )
{
if ( trg is ShadowKnight && (trg.X != p.X || trg.Y != p.Y) )
continue;
trg.RevealingAction();
trg.SendLocalizedMessage( 500814 ); // You have been revealed!
foundAnyone = true;
}
}
}
inRange.Free();
IPooledEnumerable containerinRange = src.Map.GetItemsInRange( p, range );
int trapHue = 0x3B2;
foreach ( Item item in containerinRange )
{
if (item is Container)
{
Container cont = (Container)item;
if (src.CheckSkill(SkillName.DetectHidden, cont, 0.10))
{
if ( cont.TrapType == TrapType.ExplosionTrap )
trapHue = 0x21;
else if ( cont.TrapType == TrapType.PoisonTrap )
trapHue = 0x44;
else if ( cont.TrapType == TrapType.DartTrap )
trapHue = 0x3;
else if ( cont.TrapType == TrapType.MagicTrap )
trapHue = 0x30;
cont.PublicOverheadMessage( Server.Network.MessageType.Label, trapHue, 500813 ); //trapped
}
}
}
inRange.Free();
if ( Faction.Find( src ) != null )
{
IPooledEnumerable itemsInRange = src.Map.GetItemsInRange( p, range );
foreach ( Item item in itemsInRange )
{
if ( item is BaseFactionTrap )
{
BaseFactionTrap trap = (BaseFactionTrap) item;
if ( src.CheckTargetSkill( SkillName.DetectHidden, trap, 80.0, 100.0 ) )
{
src.SendLocalizedMessage( 1042712, true, " " + (trap.Faction == null ? "" : trap.Faction.Definition.FriendlyName) ); // You reveal a trap placed by a faction:
trap.Visible = true;
trap.BeginConceal();
foundAnyone = true;
}
}
}
itemsInRange.Free();
}
}
if ( !foundAnyone )
{
src.SendLocalizedMessage( 500817 ); // You can see nothing hidden there.
}
}
}
}
}